mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-04-10 14:53:00 +02:00
Merge pull request #8984 from sethalves/fix-setLocalJointRotation-name
fix names of model-entity joint setters
This commit is contained in:
commit
5b91c8f32b
10 changed files with 251 additions and 74 deletions
|
@ -308,6 +308,13 @@ void Rig::clearIKJointLimitHistory() {
|
|||
}
|
||||
}
|
||||
|
||||
int Rig::getJointParentIndex(int childIndex) const {
|
||||
if (_animSkeleton && isIndexValid(childIndex)) {
|
||||
return _animSkeleton->getParentIndex(childIndex);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
void Rig::setJointTranslation(int index, bool valid, const glm::vec3& translation, float priority) {
|
||||
if (isIndexValid(index)) {
|
||||
if (valid) {
|
||||
|
@ -414,6 +421,16 @@ bool Rig::getAbsoluteJointTranslationInRigFrame(int jointIndex, glm::vec3& trans
|
|||
}
|
||||
}
|
||||
|
||||
bool Rig::getAbsoluteJointPoseInRigFrame(int jointIndex, AnimPose& returnPose) const {
|
||||
QReadLocker readLock(&_externalPoseSetLock);
|
||||
if (jointIndex >= 0 && jointIndex < (int)_externalPoseSet._absolutePoses.size()) {
|
||||
returnPose = _externalPoseSet._absolutePoses[jointIndex];
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Rig::getJointCombinedRotation(int jointIndex, glm::quat& result, const glm::quat& rotation) const {
|
||||
// AJT: TODO: used by attachments
|
||||
ASSERT(false);
|
||||
|
|
|
@ -105,6 +105,8 @@ public:
|
|||
|
||||
void clearIKJointLimitHistory();
|
||||
|
||||
int getJointParentIndex(int childIndex) const;
|
||||
|
||||
// geometry space
|
||||
void setJointState(int index, bool valid, const glm::quat& rotation, const glm::vec3& translation, float priority);
|
||||
|
||||
|
@ -133,6 +135,7 @@ public:
|
|||
// rig space (thread-safe)
|
||||
bool getAbsoluteJointRotationInRigFrame(int jointIndex, glm::quat& rotation) const;
|
||||
bool getAbsoluteJointTranslationInRigFrame(int jointIndex, glm::vec3& translation) const;
|
||||
bool getAbsoluteJointPoseInRigFrame(int jointIndex, AnimPose& returnPose) const;
|
||||
|
||||
// legacy
|
||||
bool getJointCombinedRotation(int jointIndex, glm::quat& result, const glm::quat& rotation) const;
|
||||
|
|
|
@ -310,14 +310,14 @@ bool RenderableModelEntityItem::getAnimationFrame() {
|
|||
}
|
||||
glm::mat4 finalMat = (translationMat * fbxJoints[index].preTransform *
|
||||
rotationMat * fbxJoints[index].postTransform);
|
||||
_absoluteJointTranslationsInObjectFrame[j] = extractTranslation(finalMat);
|
||||
_absoluteJointTranslationsInObjectFrameSet[j] = true;
|
||||
_absoluteJointTranslationsInObjectFrameDirty[j] = true;
|
||||
_localJointTranslations[j] = extractTranslation(finalMat);
|
||||
_localJointTranslationsSet[j] = true;
|
||||
_localJointTranslationsDirty[j] = true;
|
||||
|
||||
_absoluteJointRotationsInObjectFrame[j] = glmExtractRotation(finalMat);
|
||||
_localJointRotations[j] = glmExtractRotation(finalMat);
|
||||
|
||||
_absoluteJointRotationsInObjectFrameSet[j] = true;
|
||||
_absoluteJointRotationsInObjectFrameDirty[j] = true;
|
||||
_localJointRotationsSet[j] = true;
|
||||
_localJointRotationsDirty[j] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -390,18 +390,18 @@ void RenderableModelEntityItem::render(RenderArgs* args) {
|
|||
getAnimationFrame();
|
||||
|
||||
// relay any inbound joint changes from scripts/animation/network to the model/rig
|
||||
for (int index = 0; index < _absoluteJointRotationsInObjectFrame.size(); index++) {
|
||||
if (_absoluteJointRotationsInObjectFrameDirty[index]) {
|
||||
glm::quat rotation = _absoluteJointRotationsInObjectFrame[index];
|
||||
for (int index = 0; index < _localJointRotations.size(); index++) {
|
||||
if (_localJointRotationsDirty[index]) {
|
||||
glm::quat rotation = _localJointRotations[index];
|
||||
_model->setJointRotation(index, true, rotation, 1.0f);
|
||||
_absoluteJointRotationsInObjectFrameDirty[index] = false;
|
||||
_localJointRotationsDirty[index] = false;
|
||||
}
|
||||
}
|
||||
for (int index = 0; index < _absoluteJointTranslationsInObjectFrame.size(); index++) {
|
||||
if (_absoluteJointTranslationsInObjectFrameDirty[index]) {
|
||||
glm::vec3 translation = _absoluteJointTranslationsInObjectFrame[index];
|
||||
for (int index = 0; index < _localJointTranslations.size(); index++) {
|
||||
if (_localJointTranslationsDirty[index]) {
|
||||
glm::vec3 translation = _localJointTranslations[index];
|
||||
_model->setJointTranslation(index, true, translation, 1.0f);
|
||||
_absoluteJointTranslationsInObjectFrameDirty[index] = false;
|
||||
_localJointTranslationsDirty[index] = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1028,15 +1028,101 @@ glm::vec3 RenderableModelEntityItem::getAbsoluteJointTranslationInObjectFrame(in
|
|||
}
|
||||
|
||||
bool RenderableModelEntityItem::setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) {
|
||||
if (!_model) {
|
||||
return false;
|
||||
}
|
||||
RigPointer rig = _model->getRig();
|
||||
if (!rig) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int jointParentIndex = rig->getJointParentIndex(index);
|
||||
if (jointParentIndex == -1) {
|
||||
return setLocalJointRotation(index, rotation);
|
||||
}
|
||||
|
||||
bool success;
|
||||
AnimPose jointParentPose;
|
||||
success = rig->getAbsoluteJointPoseInRigFrame(jointParentIndex, jointParentPose);
|
||||
if (!success) {
|
||||
return false;
|
||||
}
|
||||
AnimPose jointParentInversePose = jointParentPose.inverse();
|
||||
|
||||
AnimPose jointAbsolutePose; // in rig frame
|
||||
success = rig->getAbsoluteJointPoseInRigFrame(index, jointAbsolutePose);
|
||||
if (!success) {
|
||||
return false;
|
||||
}
|
||||
jointAbsolutePose.rot = rotation;
|
||||
|
||||
AnimPose jointRelativePose = jointParentInversePose * jointAbsolutePose;
|
||||
return setLocalJointRotation(index, jointRelativePose.rot);
|
||||
}
|
||||
|
||||
bool RenderableModelEntityItem::setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) {
|
||||
if (!_model) {
|
||||
return false;
|
||||
}
|
||||
RigPointer rig = _model->getRig();
|
||||
if (!rig) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int jointParentIndex = rig->getJointParentIndex(index);
|
||||
if (jointParentIndex == -1) {
|
||||
return setLocalJointTranslation(index, translation);
|
||||
}
|
||||
|
||||
bool success;
|
||||
AnimPose jointParentPose;
|
||||
success = rig->getAbsoluteJointPoseInRigFrame(jointParentIndex, jointParentPose);
|
||||
if (!success) {
|
||||
return false;
|
||||
}
|
||||
AnimPose jointParentInversePose = jointParentPose.inverse();
|
||||
|
||||
AnimPose jointAbsolutePose; // in rig frame
|
||||
success = rig->getAbsoluteJointPoseInRigFrame(index, jointAbsolutePose);
|
||||
if (!success) {
|
||||
return false;
|
||||
}
|
||||
jointAbsolutePose.trans = translation;
|
||||
|
||||
AnimPose jointRelativePose = jointParentInversePose * jointAbsolutePose;
|
||||
return setLocalJointTranslation(index, jointRelativePose.trans);
|
||||
}
|
||||
|
||||
glm::quat RenderableModelEntityItem::getLocalJointRotation(int index) const {
|
||||
if (_model) {
|
||||
glm::quat result;
|
||||
if (_model->getJointRotation(index, result)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return glm::quat();
|
||||
}
|
||||
|
||||
glm::vec3 RenderableModelEntityItem::getLocalJointTranslation(int index) const {
|
||||
if (_model) {
|
||||
glm::vec3 result;
|
||||
if (_model->getJointTranslation(index, result)) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
return glm::vec3();
|
||||
}
|
||||
|
||||
bool RenderableModelEntityItem::setLocalJointRotation(int index, const glm::quat& rotation) {
|
||||
bool result = false;
|
||||
_jointDataLock.withWriteLock([&] {
|
||||
_jointRotationsExplicitlySet = true;
|
||||
resizeJointArrays();
|
||||
if (index >= 0 && index < _absoluteJointRotationsInObjectFrame.size() &&
|
||||
_absoluteJointRotationsInObjectFrame[index] != rotation) {
|
||||
_absoluteJointRotationsInObjectFrame[index] = rotation;
|
||||
_absoluteJointRotationsInObjectFrameSet[index] = true;
|
||||
_absoluteJointRotationsInObjectFrameDirty[index] = true;
|
||||
if (index >= 0 && index < _localJointRotations.size() &&
|
||||
_localJointRotations[index] != rotation) {
|
||||
_localJointRotations[index] = rotation;
|
||||
_localJointRotationsSet[index] = true;
|
||||
_localJointRotationsDirty[index] = true;
|
||||
result = true;
|
||||
_needsJointSimulation = true;
|
||||
}
|
||||
|
@ -1044,16 +1130,16 @@ bool RenderableModelEntityItem::setAbsoluteJointRotationInObjectFrame(int index,
|
|||
return result;
|
||||
}
|
||||
|
||||
bool RenderableModelEntityItem::setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) {
|
||||
bool RenderableModelEntityItem::setLocalJointTranslation(int index, const glm::vec3& translation) {
|
||||
bool result = false;
|
||||
_jointDataLock.withWriteLock([&] {
|
||||
_jointTranslationsExplicitlySet = true;
|
||||
resizeJointArrays();
|
||||
if (index >= 0 && index < _absoluteJointTranslationsInObjectFrame.size() &&
|
||||
_absoluteJointTranslationsInObjectFrame[index] != translation) {
|
||||
_absoluteJointTranslationsInObjectFrame[index] = translation;
|
||||
_absoluteJointTranslationsInObjectFrameSet[index] = true;
|
||||
_absoluteJointTranslationsInObjectFrameDirty[index] = true;
|
||||
if (index >= 0 && index < _localJointTranslations.size() &&
|
||||
_localJointTranslations[index] != translation) {
|
||||
_localJointTranslations[index] = translation;
|
||||
_localJointTranslationsSet[index] = true;
|
||||
_localJointTranslationsDirty[index] = true;
|
||||
result = true;
|
||||
_needsJointSimulation = true;
|
||||
}
|
||||
|
|
|
@ -74,6 +74,12 @@ public:
|
|||
virtual bool setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) override;
|
||||
virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) override;
|
||||
|
||||
|
||||
virtual glm::quat getLocalJointRotation(int index) const override;
|
||||
virtual glm::vec3 getLocalJointTranslation(int index) const override;
|
||||
virtual bool setLocalJointRotation(int index, const glm::quat& rotation) override;
|
||||
virtual bool setLocalJointTranslation(int index, const glm::vec3& translation) override;
|
||||
|
||||
virtual void setJointRotations(const QVector<glm::quat>& rotations) override;
|
||||
virtual void setJointRotationsSet(const QVector<bool>& rotationsSet) override;
|
||||
virtual void setJointTranslations(const QVector<glm::vec3>& translations) override;
|
||||
|
|
|
@ -411,8 +411,9 @@ public:
|
|||
// these are in the frame of this object
|
||||
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override { return glm::quat(); }
|
||||
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override { return glm::vec3(0.0f); }
|
||||
virtual bool setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) override { return false; }
|
||||
virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) override { return false; }
|
||||
|
||||
virtual bool setLocalJointRotation(int index, const glm::quat& rotation) override { return false; }
|
||||
virtual bool setLocalJointTranslation(int index, const glm::vec3& translation) override { return false; }
|
||||
|
||||
virtual int getJointIndex(const QString& name) const { return -1; }
|
||||
virtual QStringList getJointNames() const { return QStringList(); }
|
||||
|
|
|
@ -1154,17 +1154,76 @@ bool EntityScriptingInterface::setAbsoluteJointRotationInObjectFrame(const QUuid
|
|||
return false;
|
||||
}
|
||||
|
||||
glm::vec3 EntityScriptingInterface::getLocalJointTranslation(const QUuid& entityID, int jointIndex) {
|
||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||
return modelEntity->getLocalJointTranslation(jointIndex);
|
||||
} else {
|
||||
return glm::vec3(0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
glm::quat EntityScriptingInterface::getLocalJointRotation(const QUuid& entityID, int jointIndex) {
|
||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||
return modelEntity->getLocalJointRotation(jointIndex);
|
||||
} else {
|
||||
return glm::quat();
|
||||
}
|
||||
}
|
||||
|
||||
bool EntityScriptingInterface::setLocalJointTranslation(const QUuid& entityID, int jointIndex, glm::vec3 translation) {
|
||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||
auto now = usecTimestampNow();
|
||||
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||
bool result = modelEntity->setLocalJointTranslation(jointIndex, translation);
|
||||
if (result) {
|
||||
EntityItemProperties properties;
|
||||
_entityTree->withWriteLock([&] {
|
||||
properties = entity->getProperties();
|
||||
entity->setLastBroadcast(now);
|
||||
});
|
||||
|
||||
properties.setJointTranslationsDirty();
|
||||
properties.setLastEdited(now);
|
||||
queueEntityMessage(PacketType::EntityEdit, entityID, properties);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool EntityScriptingInterface::setLocalJointRotation(const QUuid& entityID, int jointIndex, glm::quat rotation) {
|
||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||
auto now = usecTimestampNow();
|
||||
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||
bool result = modelEntity->setLocalJointRotation(jointIndex, rotation);
|
||||
if (result) {
|
||||
EntityItemProperties properties;
|
||||
_entityTree->withWriteLock([&] {
|
||||
properties = entity->getProperties();
|
||||
entity->setLastBroadcast(now);
|
||||
});
|
||||
|
||||
properties.setJointRotationsDirty();
|
||||
properties.setLastEdited(now);
|
||||
queueEntityMessage(PacketType::EntityEdit, entityID, properties);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool EntityScriptingInterface::setAbsoluteJointRotationsInObjectFrame(const QUuid& entityID,
|
||||
const QVector<glm::quat>& rotations) {
|
||||
|
||||
bool EntityScriptingInterface::setLocalJointRotations(const QUuid& entityID, const QVector<glm::quat>& rotations) {
|
||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||
auto now = usecTimestampNow();
|
||||
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||
|
||||
bool result = false;
|
||||
for (int index = 0; index < rotations.size(); index++) {
|
||||
result |= modelEntity->setAbsoluteJointRotationInObjectFrame(index, rotations[index]);
|
||||
result |= modelEntity->setLocalJointRotation(index, rotations[index]);
|
||||
}
|
||||
if (result) {
|
||||
EntityItemProperties properties;
|
||||
|
@ -1184,15 +1243,14 @@ bool EntityScriptingInterface::setAbsoluteJointRotationsInObjectFrame(const QUui
|
|||
}
|
||||
|
||||
|
||||
bool EntityScriptingInterface::setAbsoluteJointTranslationsInObjectFrame(const QUuid& entityID,
|
||||
const QVector<glm::vec3>& translations) {
|
||||
bool EntityScriptingInterface::setLocalJointTranslations(const QUuid& entityID, const QVector<glm::vec3>& translations) {
|
||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||
auto now = usecTimestampNow();
|
||||
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||
|
||||
bool result = false;
|
||||
for (int index = 0; index < translations.size(); index++) {
|
||||
result |= modelEntity->setAbsoluteJointTranslationInObjectFrame(index, translations[index]);
|
||||
result |= modelEntity->setLocalJointTranslation(index, translations[index]);
|
||||
}
|
||||
if (result) {
|
||||
EntityItemProperties properties;
|
||||
|
@ -1211,12 +1269,12 @@ bool EntityScriptingInterface::setAbsoluteJointTranslationsInObjectFrame(const Q
|
|||
return false;
|
||||
}
|
||||
|
||||
bool EntityScriptingInterface::setAbsoluteJointsDataInObjectFrame(const QUuid& entityID,
|
||||
const QVector<glm::quat>& rotations,
|
||||
const QVector<glm::vec3>& translations) {
|
||||
bool EntityScriptingInterface::setLocalJointsData(const QUuid& entityID,
|
||||
const QVector<glm::quat>& rotations,
|
||||
const QVector<glm::vec3>& translations) {
|
||||
// for a model with 80 joints, sending both these in one edit packet causes the packet to be too large.
|
||||
return setAbsoluteJointRotationsInObjectFrame(entityID, rotations) ||
|
||||
setAbsoluteJointTranslationsInObjectFrame(entityID, translations);
|
||||
return setLocalJointRotations(entityID, rotations) ||
|
||||
setLocalJointTranslations(entityID, translations);
|
||||
}
|
||||
|
||||
int EntityScriptingInterface::getJointIndex(const QUuid& entityID, const QString& name) {
|
||||
|
|
|
@ -186,13 +186,17 @@ public slots:
|
|||
Q_INVOKABLE glm::quat getAbsoluteJointRotationInObjectFrame(const QUuid& entityID, int jointIndex);
|
||||
Q_INVOKABLE bool setAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, int jointIndex, glm::vec3 translation);
|
||||
Q_INVOKABLE bool setAbsoluteJointRotationInObjectFrame(const QUuid& entityID, int jointIndex, glm::quat rotation);
|
||||
Q_INVOKABLE bool setAbsoluteJointRotationsInObjectFrame(const QUuid& entityID,
|
||||
const QVector<glm::quat>& rotations);
|
||||
Q_INVOKABLE bool setAbsoluteJointTranslationsInObjectFrame(const QUuid& entityID,
|
||||
const QVector<glm::vec3>& translations);
|
||||
Q_INVOKABLE bool setAbsoluteJointsDataInObjectFrame(const QUuid& entityID,
|
||||
const QVector<glm::quat>& rotations,
|
||||
const QVector<glm::vec3>& translations);
|
||||
|
||||
Q_INVOKABLE glm::vec3 getLocalJointTranslation(const QUuid& entityID, int jointIndex);
|
||||
Q_INVOKABLE glm::quat getLocalJointRotation(const QUuid& entityID, int jointIndex);
|
||||
Q_INVOKABLE bool setLocalJointTranslation(const QUuid& entityID, int jointIndex, glm::vec3 translation);
|
||||
Q_INVOKABLE bool setLocalJointRotation(const QUuid& entityID, int jointIndex, glm::quat rotation);
|
||||
|
||||
Q_INVOKABLE bool setLocalJointRotations(const QUuid& entityID, const QVector<glm::quat>& rotations);
|
||||
Q_INVOKABLE bool setLocalJointTranslations(const QUuid& entityID, const QVector<glm::vec3>& translations);
|
||||
Q_INVOKABLE bool setLocalJointsData(const QUuid& entityID,
|
||||
const QVector<glm::quat>& rotations,
|
||||
const QVector<glm::vec3>& translations);
|
||||
|
||||
Q_INVOKABLE int getJointIndex(const QUuid& entityID, const QString& name);
|
||||
Q_INVOKABLE QStringList getJointNames(const QUuid& entityID);
|
||||
|
|
|
@ -389,13 +389,13 @@ bool ModelEntityItem::shouldBePhysical() const {
|
|||
}
|
||||
|
||||
void ModelEntityItem::resizeJointArrays(int newSize) {
|
||||
if (newSize >= 0 && newSize > _absoluteJointRotationsInObjectFrame.size()) {
|
||||
_absoluteJointRotationsInObjectFrame.resize(newSize);
|
||||
_absoluteJointRotationsInObjectFrameSet.resize(newSize);
|
||||
_absoluteJointRotationsInObjectFrameDirty.resize(newSize);
|
||||
_absoluteJointTranslationsInObjectFrame.resize(newSize);
|
||||
_absoluteJointTranslationsInObjectFrameSet.resize(newSize);
|
||||
_absoluteJointTranslationsInObjectFrameDirty.resize(newSize);
|
||||
if (newSize >= 0 && newSize > _localJointRotations.size()) {
|
||||
_localJointRotations.resize(newSize);
|
||||
_localJointRotationsSet.resize(newSize);
|
||||
_localJointRotationsDirty.resize(newSize);
|
||||
_localJointTranslations.resize(newSize);
|
||||
_localJointTranslationsSet.resize(newSize);
|
||||
_localJointTranslationsDirty.resize(newSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -404,9 +404,9 @@ void ModelEntityItem::setJointRotations(const QVector<glm::quat>& rotations) {
|
|||
_jointRotationsExplicitlySet = rotations.size() > 0;
|
||||
resizeJointArrays(rotations.size());
|
||||
for (int index = 0; index < rotations.size(); index++) {
|
||||
if (_absoluteJointRotationsInObjectFrameSet[index]) {
|
||||
_absoluteJointRotationsInObjectFrame[index] = rotations[index];
|
||||
_absoluteJointRotationsInObjectFrameDirty[index] = true;
|
||||
if (_localJointRotationsSet[index]) {
|
||||
_localJointRotations[index] = rotations[index];
|
||||
_localJointRotationsDirty[index] = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -417,7 +417,7 @@ void ModelEntityItem::setJointRotationsSet(const QVector<bool>& rotationsSet) {
|
|||
_jointRotationsExplicitlySet = rotationsSet.size() > 0;
|
||||
resizeJointArrays(rotationsSet.size());
|
||||
for (int index = 0; index < rotationsSet.size(); index++) {
|
||||
_absoluteJointRotationsInObjectFrameSet[index] = rotationsSet[index];
|
||||
_localJointRotationsSet[index] = rotationsSet[index];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -427,9 +427,9 @@ void ModelEntityItem::setJointTranslations(const QVector<glm::vec3>& translation
|
|||
_jointTranslationsExplicitlySet = translations.size() > 0;
|
||||
resizeJointArrays(translations.size());
|
||||
for (int index = 0; index < translations.size(); index++) {
|
||||
if (_absoluteJointTranslationsInObjectFrameSet[index]) {
|
||||
_absoluteJointTranslationsInObjectFrame[index] = translations[index];
|
||||
_absoluteJointTranslationsInObjectFrameSet[index] = true;
|
||||
if (_localJointTranslationsSet[index]) {
|
||||
_localJointTranslations[index] = translations[index];
|
||||
_localJointTranslationsSet[index] = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -440,7 +440,7 @@ void ModelEntityItem::setJointTranslationsSet(const QVector<bool>& translationsS
|
|||
_jointTranslationsExplicitlySet = translationsSet.size() > 0;
|
||||
resizeJointArrays(translationsSet.size());
|
||||
for (int index = 0; index < translationsSet.size(); index++) {
|
||||
_absoluteJointTranslationsInObjectFrameSet[index] = translationsSet[index];
|
||||
_localJointTranslationsSet[index] = translationsSet[index];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ QVector<glm::quat> ModelEntityItem::getJointRotations() const {
|
|||
QVector<glm::quat> result;
|
||||
_jointDataLock.withReadLock([&] {
|
||||
if (_jointRotationsExplicitlySet) {
|
||||
result = _absoluteJointRotationsInObjectFrame;
|
||||
result = _localJointRotations;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
|
@ -459,7 +459,7 @@ QVector<bool> ModelEntityItem::getJointRotationsSet() const {
|
|||
QVector<bool> result;
|
||||
_jointDataLock.withReadLock([&] {
|
||||
if (_jointRotationsExplicitlySet) {
|
||||
result = _absoluteJointRotationsInObjectFrameSet;
|
||||
result = _localJointRotationsSet;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -470,7 +470,7 @@ QVector<glm::vec3> ModelEntityItem::getJointTranslations() const {
|
|||
QVector<glm::vec3> result;
|
||||
_jointDataLock.withReadLock([&] {
|
||||
if (_jointTranslationsExplicitlySet) {
|
||||
result = _absoluteJointTranslationsInObjectFrame;
|
||||
result = _localJointTranslations;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
|
@ -480,7 +480,7 @@ QVector<bool> ModelEntityItem::getJointTranslationsSet() const {
|
|||
QVector<bool> result;
|
||||
_jointDataLock.withReadLock([&] {
|
||||
if (_jointTranslationsExplicitlySet) {
|
||||
result = _absoluteJointTranslationsInObjectFrameSet;
|
||||
result = _localJointTranslationsSet;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
|
|
|
@ -117,9 +117,6 @@ public:
|
|||
|
||||
virtual bool shouldBePhysical() const override;
|
||||
|
||||
virtual glm::vec3 getJointPosition(int jointIndex) const { return glm::vec3(); }
|
||||
virtual glm::quat getJointRotation(int jointIndex) const { return glm::quat(); }
|
||||
|
||||
virtual void setJointRotations(const QVector<glm::quat>& rotations);
|
||||
virtual void setJointRotationsSet(const QVector<bool>& rotationsSet);
|
||||
virtual void setJointTranslations(const QVector<glm::vec3>& translations);
|
||||
|
@ -143,14 +140,14 @@ protected:
|
|||
ReadWriteLockable _jointDataLock;
|
||||
|
||||
bool _jointRotationsExplicitlySet { false }; // were the joints set as a property or just side effect of animations
|
||||
QVector<glm::quat> _absoluteJointRotationsInObjectFrame;
|
||||
QVector<bool> _absoluteJointRotationsInObjectFrameSet; // ever set?
|
||||
QVector<bool> _absoluteJointRotationsInObjectFrameDirty; // needs a relay to model/rig?
|
||||
|
||||
QVector<glm::quat> _localJointRotations;
|
||||
QVector<bool> _localJointRotationsSet; // ever set?
|
||||
QVector<bool> _localJointRotationsDirty; // needs a relay to model/rig?
|
||||
|
||||
bool _jointTranslationsExplicitlySet { false }; // were the joints set as a property or just side effect of animations
|
||||
QVector<glm::vec3> _absoluteJointTranslationsInObjectFrame;
|
||||
QVector<bool> _absoluteJointTranslationsInObjectFrameSet; // ever set?
|
||||
QVector<bool> _absoluteJointTranslationsInObjectFrameDirty; // needs a relay to model/rig?
|
||||
QVector<glm::vec3> _localJointTranslations;
|
||||
QVector<bool> _localJointTranslationsSet; // ever set?
|
||||
QVector<bool> _localJointTranslationsDirty; // needs a relay to model/rig?
|
||||
int _lastKnownCurrentFrame;
|
||||
virtual void resizeJointArrays(int newSize = -1);
|
||||
|
||||
|
|
|
@ -144,6 +144,11 @@ public:
|
|||
virtual bool setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) { return false; }
|
||||
virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) {return false; }
|
||||
|
||||
virtual glm::quat getLocalJointRotation(int index) const {return glm::quat(); }
|
||||
virtual glm::vec3 getLocalJointTranslation(int index) const {return glm::vec3(); }
|
||||
virtual bool setLocalJointRotation(int index, const glm::quat& rotation) { return false; }
|
||||
virtual bool setLocalJointTranslation(int index, const glm::vec3& translation) { return false; }
|
||||
|
||||
SpatiallyNestablePointer getThisPointer() const;
|
||||
|
||||
void markAncestorMissing(bool value) { _missingAncestor = value; }
|
||||
|
|
Loading…
Reference in a new issue