summaryrefslogtreecommitdiffstats
path: root/src/runtime/Qt3DSElementSystem.cpp
diff options
context:
space:
mode:
authorJanne Kangas <janne.kangas@qt.io>2019-07-26 14:49:10 +0300
committerJanne Kangas <janne.kangas@qt.io>2019-08-29 10:55:21 +0300
commit67a5d7ddc604578f69e5add5210f084b9d28addc (patch)
treea1a39c671d317f781bacaf83291b7a330b6d7965 /src/runtime/Qt3DSElementSystem.cpp
parent9ea345e6372433217915a45b73acb81a81627bde (diff)
Stop animation when property is controlled by datainput
Disable animation for the target property when datainput value is set. This is to prevent running animations from overriding datainput control, which happens by default in runtime engine due to ordering of scene update sequence. Change-Id: I148d7fd80ad01f4ec5ad1d5ba69ecc74865d27fb Task-id: QT3DS-3896 Reviewed-by: Tomi Korpipää <tomi.korpipaa@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/runtime/Qt3DSElementSystem.cpp')
-rw-r--r--src/runtime/Qt3DSElementSystem.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/runtime/Qt3DSElementSystem.cpp b/src/runtime/Qt3DSElementSystem.cpp
index f77bac5..81a27b1 100644
--- a/src/runtime/Qt3DSElementSystem.cpp
+++ b/src/runtime/Qt3DSElementSystem.cpp
@@ -43,6 +43,7 @@
#include "foundation/SerializationTypes.h"
#include "foundation/IOStreams.h"
#include "foundation/Qt3DSIndexableLinkedList.h"
+#include "Qt3DSAnimationSystem.h"
using namespace qt3ds::runtime::element;
using namespace qt3ds;
@@ -651,12 +652,29 @@ void SElement::SetAttribute(const Q3DStudio::TAttributeHash inKey,
SetAttribute(*existing, inValue);
}
+void SElement::stopAnimations(QT3DSU32 propHash)
+{
+ QT3DSI32 animTrack = m_BelongedPresentation->GetAnimationSystem().getActiveTrackForElemProp(
+ this, propHash);
+
+ if (animTrack != 0) {
+ qWarning() << "Property animation in element" << m_Name.c_str()
+ << "stopped due to datainput or setAttribute targeting the same property";
+
+ m_BelongedPresentation->GetAnimationSystem().SetActive(animTrack, false);
+ }
+}
void SElement::SetAttribute(TPropertyDescAndValuePtr inKey, const Q3DStudio::UVariant inValue,
bool forceSet)
{
Q3DStudio::EAttributeType theType = inKey.first.m_Type;
Q3DStudio::UVariant *currentValue = inKey.second;
QT3DSU32 attHash = inKey.first.GetNameHash();
+
+ // If there is an active animation for this property, disable it. Otherwise the set value
+ // gets overwritten immediately as animation update takes place.
+ // Do this even if the value gets rejected in the code below.
+ stopAnimations(attHash);
if (!forceSet) {
switch (theType) {
case Q3DStudio::ATTRIBUTETYPE_FLOAT: // Early return