Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
Loading...
Searching...
No Matches
qquickgroupgoal.cpp
Go to the documentation of this file.
1
// Copyright (C) 2016 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
"qquickgroupgoal_p.h"
5
#
include
<
private
/
qquickspriteengine_p
.
h
>
6
#
include
<
private
/
qquicksprite_p
.
h
>
7
#
include
"qquickimageparticle_p.h"
8
#
include
<
QDebug
>
9
10
QT_BEGIN_NAMESPACE
11
12
/*!
13
\qmltype GroupGoal
14
\nativetype QQuickGroupGoalAffector
15
\inqmlmodule QtQuick.Particles
16
\ingroup qtquick-particles
17
\inherits ParticleAffector
18
\brief For changing the state of a group of a particle.
19
20
*/
21
/*!
22
\qmlproperty string QtQuick.Particles::GroupGoal::goalState
23
24
The name of the group which the affected particles should move to.
25
26
Groups can have defined durations and transitions between them, setting goalState
27
will cause it to disregard any path weightings (including 0) and head down the path
28
which will reach the goalState quickest. It will pass through intermediate groups
29
on that path for their respective durations.
30
*/
31
/*!
32
\qmlproperty bool QtQuick.Particles::GroupGoal::jump
33
34
If true, affected particles will jump directly to the target group instead of taking the
35
shortest valid path to get there. They will also not finish their current state,
36
but immediately move to the beginning of the goal state.
37
38
Default is false.
39
*/
40
41
QQuickGroupGoalAffector::QQuickGroupGoalAffector(QQuickItem *parent) :
42
QQuickParticleAffector(parent), m_jump(
false
)
43
{
44
m_ignoresTime =
true
;
45
}
46
47
void
QQuickGroupGoalAffector::setGoalState(
const
QString &arg)
48
{
49
if
(m_goalState != arg) {
50
m_goalState = arg;
51
emit goalStateChanged(arg);
52
}
53
}
54
55
bool
QQuickGroupGoalAffector::affectParticle(QQuickParticleData *d, qreal dt)
56
{
57
Q_UNUSED(dt);
58
QQuickStochasticEngine *engine = m_system->stateEngine;
59
int
index = d->systemIndex;
60
int
goalIdx = m_system->groupIds[m_goalState];
61
if
(!engine){
//no stochastic states defined. So cut out the engine
62
//TODO: It's possible to move to a group that is intermediate and not used by painters or emitters - but right now that will redirect to the default group
63
m_system->moveGroups(d, goalIdx);
64
return
true
;
65
}
else
if
(engine->curState(index) != goalIdx){
66
engine->setGoal(goalIdx, index, m_jump);
67
return
true
;
68
}
69
return
false
;
70
}
71
72
QT_END_NAMESPACE
73
74
#
include
"moc_qquickgroupgoal_p.cpp"
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtdeclarative
src
particles
qquickgroupgoal.cpp
Generated on
for Qt by
1.18.0