mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 09:29:02 +02:00
Merge pull request #14517 from luiscuenca/getEntityJointParent
Add method to check entities joint hierarchy
This commit is contained in:
commit
bb9a764855
6 changed files with 31 additions and 1 deletions
|
@ -773,6 +773,14 @@ bool RenderableModelEntityItem::shouldBePhysical() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int RenderableModelEntityItem::getJointParent(int index) const {
|
||||||
|
auto model = getModel();
|
||||||
|
if (model) {
|
||||||
|
return model->getRig().getJointParentIndex(index);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
glm::quat RenderableModelEntityItem::getAbsoluteJointRotationInObjectFrame(int index) const {
|
glm::quat RenderableModelEntityItem::getAbsoluteJointRotationInObjectFrame(int index) const {
|
||||||
auto model = getModel();
|
auto model = getModel();
|
||||||
if (model) {
|
if (model) {
|
||||||
|
|
|
@ -94,6 +94,7 @@ public:
|
||||||
// these are in the frame of this object (model space)
|
// these are in the frame of this object (model space)
|
||||||
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override;
|
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override;
|
||||||
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override;
|
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override;
|
||||||
|
virtual int getJointParent(int index) const override;
|
||||||
virtual bool setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) override;
|
virtual bool setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) override;
|
||||||
virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) override;
|
virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) override;
|
||||||
|
|
||||||
|
|
|
@ -467,6 +467,7 @@ public:
|
||||||
// these are in the frame of this object
|
// these are in the frame of this object
|
||||||
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override { return glm::quat(); }
|
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 glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override { return glm::vec3(0.0f); }
|
||||||
|
virtual int getJointParent(int index) const override { return -1; }
|
||||||
|
|
||||||
virtual bool setLocalJointRotation(int index, const glm::quat& rotation) 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 bool setLocalJointTranslation(int index, const glm::vec3& translation) override { return false; }
|
||||||
|
|
|
@ -1834,6 +1834,15 @@ glm::vec3 EntityScriptingInterface::localCoordsToVoxelCoords(const QUuid& entity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int EntityScriptingInterface::getJointParent(const QUuid& entityID, int index) {
|
||||||
|
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||||
|
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||||
|
return modelEntity->getJointParent(index);
|
||||||
|
} else {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glm::vec3 EntityScriptingInterface::getAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, int jointIndex) {
|
glm::vec3 EntityScriptingInterface::getAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, int jointIndex) {
|
||||||
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) {
|
||||||
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity);
|
||||||
|
|
|
@ -1007,7 +1007,16 @@ public slots:
|
||||||
*/
|
*/
|
||||||
// FIXME move to a renderable entity interface
|
// FIXME move to a renderable entity interface
|
||||||
Q_INVOKABLE glm::vec3 getAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, int jointIndex);
|
Q_INVOKABLE glm::vec3 getAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, int jointIndex);
|
||||||
|
|
||||||
|
/**jsdoc
|
||||||
|
* Get the index of the parent joint.
|
||||||
|
* @function Entities.getJointParent
|
||||||
|
* @param {Uuid} entityID - The ID of the entity.
|
||||||
|
* @param {number} index - The integer index of the joint.
|
||||||
|
* @returns {number} The index of the parent joint.
|
||||||
|
*/
|
||||||
|
Q_INVOKABLE int getJointParent(const QUuid& entityID, int index);
|
||||||
|
|
||||||
/**jsdoc
|
/**jsdoc
|
||||||
* Get the translation of a joint in a {@link Entities.EntityType|Model} entity relative to the entity's position and
|
* Get the translation of a joint in a {@link Entities.EntityType|Model} entity relative to the entity's position and
|
||||||
* orientation.
|
* orientation.
|
||||||
|
|
|
@ -163,6 +163,8 @@ public:
|
||||||
virtual glm::vec3 getAbsoluteJointScaleInObjectFrame(int index) const { return glm::vec3(1.0f); }
|
virtual glm::vec3 getAbsoluteJointScaleInObjectFrame(int index) const { return glm::vec3(1.0f); }
|
||||||
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const { return glm::quat(); }
|
virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const { return glm::quat(); }
|
||||||
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const { return glm::vec3(); }
|
virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const { return glm::vec3(); }
|
||||||
|
virtual int getJointParent(int index) const { return -1; }
|
||||||
|
|
||||||
virtual bool setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) { return false; }
|
virtual bool setAbsoluteJointRotationInObjectFrame(int index, const glm::quat& rotation) { return false; }
|
||||||
virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) {return false; }
|
virtual bool setAbsoluteJointTranslationInObjectFrame(int index, const glm::vec3& translation) {return false; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue