Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickgravity.cpp
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#include <QtQml/qqmlinfo.h>
5#include <QtCore/QtMath>
6#include "qquickgravity_p.h"
8
33{
34 if (m_magnitude != arg) {
35 m_magnitude = arg;
36 m_needRecalc = true;
38 }
39}
40
42{
43 return m_magnitude;
44}
45
46
54{
55 qmlWarning(this) << "The acceleration property is deprecated. Please use magnitude instead.";
57}
58
65{
66 if (m_angle != arg) {
67 m_angle = arg;
68 m_needRecalc = true;
70 }
71}
72
74{
75 return m_angle;
76}
77
79 QQuickParticleAffector(parent), m_magnitude(-10), m_angle(90), m_needRecalc(true)
80{
81}
82
84{
85 if (!m_magnitude)
86 return false;
87 if (m_needRecalc) {
88 m_needRecalc = false;
89 m_dx = m_magnitude * qCos(qDegreesToRadians(m_angle));
90 m_dy = m_magnitude * qSin(qDegreesToRadians(m_angle));
91 }
92
93 d->setInstantaneousVX(d->curVX(m_system) + m_dx*dt, m_system);
94 d->setInstantaneousVY(d->curVY(m_system) + m_dy*dt, m_system);
95 return true;
96}
97
98
99
101
102#include "moc_qquickgravity_p.cpp"
void angleChanged(qreal arg)
void setAcceleration(qreal arg)
\qmlproperty real QtQuick.Particles::Gravity::acceleration
bool affectParticle(QQuickParticleData *d, qreal dt) override
void setAngle(qreal arg)
\qmlproperty real QtQuick.Particles::Gravity::angle
void setMagnitude(qreal arg)
\qmltype Gravity \instantiates QQuickGravityAffector \inqmlmodule QtQuick.Particles\inherits Affector
void magnitudeChanged(qreal arg)
QQuickGravityAffector(QQuickItem *parent=nullptr)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
QQuickParticleSystem * m_system
Combined button and popup list for selecting options.
auto qCos(T v)
Definition qmath.h:60
auto qSin(T v)
Definition qmath.h:54
constexpr float qDegreesToRadians(float degrees)
Definition qmath.h:260
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
SSL_CTX int void * arg
#define emit
double qreal
Definition qtypes.h:187