Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 6 files). Show all
Unified · Split
| @@ -1110,6 +1110,68 @@ glm::quat EntityScriptingInterface::getAbsoluteJointRotationInObjectFrame(const · 1109 unmodified lines | |||
| 1110 | } | 1110 | } |
| 1111 | } | 1111 | } |
| 1112 | 1112 | ||
| 1113 | bool EntityScriptingInterface::setAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, | ||
| 1114 | int jointIndex, glm::vec3 translation) { | ||
| 1115 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { | ||
| 1116 | auto now = usecTimestampNow(); | ||
| 1117 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); | ||
| 1118 | bool result = modelEntity->setAbsoluteJointTranslationInObjectFrame(jointIndex, translation); | ||
| 1119 | if (result) { | ||
| 1120 | EntityItemProperties properties; | ||
| 1121 | _entityTree->withWriteLock([&] { | ||
| 1122 | properties = entity->getProperties(); | ||
| 1123 | entity->setLastBroadcast(now); | ||
| 1124 | }); | ||
| 1125 | |||
| 1126 | properties.setJointTranslationsDirty(); | ||
| 1127 | properties.setLastEdited(now); | ||
| 1128 | queueEntityMessage(PacketType::EntityEdit, entityID, properties); | ||
| 1129 | return true; | ||
| 1130 | } | ||
| 1131 | } | ||
| 1132 | return false; | ||
| 1133 | } | ||
| 1134 | |||
| 1135 | bool EntityScriptingInterface::setAbsoluteJointRotationInObjectFrame(const QUuid& entityID, | ||
| 1136 | int jointIndex, glm::quat rotation) { | ||
| 1137 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { | ||
| 1138 | auto now = usecTimestampNow(); | ||
| 1139 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); | ||
| 1140 | bool result = modelEntity->setAbsoluteJointRotationInObjectFrame(jointIndex, rotation); | ||
| 1141 | if (result) { | ||
| 1142 | EntityItemProperties properties; | ||
| 1143 | _entityTree->withWriteLock([&] { | ||
| 1144 | properties = entity->getProperties(); | ||
| 1145 | entity->setLastBroadcast(now); | ||
| 1146 | }); | ||
| 1147 | |||
| 1148 | properties.setJointRotationsDirty(); | ||
| 1149 | properties.setLastEdited(now); | ||
| 1150 | queueEntityMessage(PacketType::EntityEdit, entityID, properties); | ||
| 1151 | return true; | ||
| 1152 | } | ||
| 1153 | } | ||
| 1154 | return false; | ||
| 1155 | } | ||
| 1156 | |||
| 1157 | glm::vec3 EntityScriptingInterface::getLocalJointTranslation(const QUuid& entityID, int jointIndex) { | ||
| 1158 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { | ||
| 1159 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); | ||
| 1160 | return modelEntity->getLocalJointTranslation(jointIndex); | ||
| 1161 | } else { | ||
| 1162 | return glm::vec3(0.0f); | ||
| 1163 | } | ||
| 1164 | } | ||
| 1165 | |||
| 1166 | glm::quat EntityScriptingInterface::getLocalJointRotation(const QUuid& entityID, int jointIndex) { | ||
| 1167 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { | ||
| 1168 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); | ||
| 1169 | return modelEntity->getLocalJointRotation(jointIndex); | ||
| 1170 | } else { | ||
| 1171 | return glm::quat(); | ||
| 1172 | } | ||
| 1173 | } | ||
| 1174 | |||
| 1113 | bool EntityScriptingInterface::setLocalJointTranslation(const QUuid& entityID, int jointIndex, glm::vec3 translation) { | 1175 | bool EntityScriptingInterface::setLocalJointTranslation(const QUuid& entityID, int jointIndex, glm::vec3 translation) { |
| 1114 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { | 1176 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { |
| 1115 | auto now = usecTimestampNow(); | 1177 | auto now = usecTimestampNow(); |