From b48503a82d9af4a6842ec88be9fc538b86c87b71 Mon Sep 17 00:00:00 2001 From: Brad Hefta-Gaub Date: Wed, 13 Apr 2016 19:52:50 -0700 Subject: [PATCH] only export joint values if they've been explicitly set by scripts --- .../src/RenderableModelEntityItem.cpp | 2 ++ .../entities/src/EntityItemProperties.cpp | 7 ------- libraries/entities/src/ModelEntityItem.cpp | 21 +++++++++++++++---- libraries/entities/src/ModelEntityItem.h | 4 ++++ 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp index 879ff01056..7edd856688 100644 --- a/libraries/entities-renderer/src/RenderableModelEntityItem.cpp +++ b/libraries/entities-renderer/src/RenderableModelEntityItem.cpp @@ -748,6 +748,7 @@ glm::vec3 RenderableModelEntityItem::getAbsoluteJointTranslationInObjectFrame(in bool RenderableModelEntityItem::setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) { bool result = false; _jointDataLock.withWriteLock([&] { + _jointRotationsExplicitlySet = true; resizeJointArrays(); if (index >= 0 && index < _absoluteJointRotationsInObjectFrame.size() && _absoluteJointRotationsInObjectFrame[index] != rotation) { @@ -764,6 +765,7 @@ bool RenderableModelEntityItem::setAbsoluteJointRotationInObjectFrame(int index, bool RenderableModelEntityItem::setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) { bool result = false; _jointDataLock.withWriteLock([&] { + _jointTranslationsExplicitlySet = true; resizeJointArrays(); if (index >= 0 && index < _absoluteJointTranslationsInObjectFrame.size() && _absoluteJointTranslationsInObjectFrame[index] != translation) { diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 32aac1efe5..92849d6e2f 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -541,13 +541,6 @@ QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_LOCAL_POSITION, localPosition); COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_LOCAL_ROTATION, localRotation); - COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_JOINT_ROTATIONS_SET, jointRotationsSet); - COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_JOINT_ROTATIONS, jointRotations); - COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_JOINT_TRANSLATIONS_SET, jointTranslationsSet); - COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_JOINT_TRANSLATIONS, jointTranslations); - - COPY_PROPERTY_TO_QSCRIPTVALUE(PROP_QUERY_AA_CUBE, queryAACube); - // FIXME - I don't think these properties are supported any more //COPY_PROPERTY_TO_QSCRIPTVALUE(glowLevel); //COPY_PROPERTY_TO_QSCRIPTVALUE(localRenderAlpha); diff --git a/libraries/entities/src/ModelEntityItem.cpp b/libraries/entities/src/ModelEntityItem.cpp index e5511c0b25..6c7287ecb3 100644 --- a/libraries/entities/src/ModelEntityItem.cpp +++ b/libraries/entities/src/ModelEntityItem.cpp @@ -404,6 +404,7 @@ void ModelEntityItem::resizeJointArrays(int newSize) { void ModelEntityItem::setJointRotations(const QVector& rotations) { _jointDataLock.withWriteLock([&] { + _jointRotationsExplicitlySet = rotations.size() > 0; resizeJointArrays(rotations.size()); for (int index = 0; index < rotations.size(); index++) { if (_absoluteJointRotationsInObjectFrameSet[index]) { @@ -416,6 +417,7 @@ void ModelEntityItem::setJointRotations(const QVector& rotations) { void ModelEntityItem::setJointRotationsSet(const QVector& rotationsSet) { _jointDataLock.withWriteLock([&] { + _jointRotationsExplicitlySet = rotationsSet.size() > 0; resizeJointArrays(rotationsSet.size()); for (int index = 0; index < rotationsSet.size(); index++) { _absoluteJointRotationsInObjectFrameSet[index] = rotationsSet[index]; @@ -425,6 +427,7 @@ void ModelEntityItem::setJointRotationsSet(const QVector& rotationsSet) { void ModelEntityItem::setJointTranslations(const QVector& translations) { _jointDataLock.withWriteLock([&] { + _jointTranslationsExplicitlySet = translations.size() > 0; resizeJointArrays(translations.size()); for (int index = 0; index < translations.size(); index++) { if (_absoluteJointTranslationsInObjectFrameSet[index]) { @@ -437,6 +440,7 @@ void ModelEntityItem::setJointTranslations(const QVector& translation void ModelEntityItem::setJointTranslationsSet(const QVector& translationsSet) { _jointDataLock.withWriteLock([&] { + _jointTranslationsExplicitlySet = translationsSet.size() > 0; resizeJointArrays(translationsSet.size()); for (int index = 0; index < translationsSet.size(); index++) { _absoluteJointTranslationsInObjectFrameSet[index] = translationsSet[index]; @@ -447,7 +451,9 @@ void ModelEntityItem::setJointTranslationsSet(const QVector& translationsS QVector ModelEntityItem::getJointRotations() const { QVector result; _jointDataLock.withReadLock([&] { - result = _absoluteJointRotationsInObjectFrame; + if (_jointRotationsExplicitlySet) { + result = _absoluteJointRotationsInObjectFrame; + } }); return result; } @@ -455,15 +461,20 @@ QVector ModelEntityItem::getJointRotations() const { QVector ModelEntityItem::getJointRotationsSet() const { QVector result; _jointDataLock.withReadLock([&] { - result = _absoluteJointRotationsInObjectFrameSet; + if (_jointRotationsExplicitlySet) { + result = _absoluteJointRotationsInObjectFrameSet; + } }); + return result; } QVector ModelEntityItem::getJointTranslations() const { QVector result; _jointDataLock.withReadLock([&] { - result = _absoluteJointTranslationsInObjectFrame; + if (_jointTranslationsExplicitlySet) { + result = _absoluteJointTranslationsInObjectFrame; + } }); return result; } @@ -471,7 +482,9 @@ QVector ModelEntityItem::getJointTranslations() const { QVector ModelEntityItem::getJointTranslationsSet() const { QVector result; _jointDataLock.withReadLock([&] { - result = _absoluteJointTranslationsInObjectFrameSet; + if (_jointTranslationsExplicitlySet) { + result = _absoluteJointTranslationsInObjectFrameSet; + } }); return result; } diff --git a/libraries/entities/src/ModelEntityItem.h b/libraries/entities/src/ModelEntityItem.h index d0e0909b27..640c00f14d 100644 --- a/libraries/entities/src/ModelEntityItem.h +++ b/libraries/entities/src/ModelEntityItem.h @@ -140,9 +140,13 @@ protected: // they aren't currently updated from data in the model/rig, and they don't have a direct effect // on what's rendered. ReadWriteLockable _jointDataLock; + + bool _jointRotationsExplicitlySet { false }; // were the joints set as a property or just side effect of animations QVector _absoluteJointRotationsInObjectFrame; QVector _absoluteJointRotationsInObjectFrameSet; // ever set? QVector _absoluteJointRotationsInObjectFrameDirty; // needs a relay to model/rig? + + bool _jointTranslationsExplicitlySet { false }; // were the joints set as a property or just side effect of animations QVector _absoluteJointTranslationsInObjectFrame; QVector _absoluteJointTranslationsInObjectFrameSet; // ever set? QVector _absoluteJointTranslationsInObjectFrameDirty; // needs a relay to model/rig?