Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 8 files). Show all
Unified · Split
| @@ -1110,12 +1110,11 @@ glm::quat EntityScriptingInterface::getAbsoluteJointRotationInObjectFrame(const · 1109 unmodified lines | |||
| 1110 | } | 1110 | } |
| 1111 | } | 1111 | } |
| 1112 | 1112 | ||
| 1113 | bool EntityScriptingInterface::setAbsoluteJointTranslationInObjectFrame(const QUuid& entityID, | 1113 | bool EntityScriptingInterface::setLocalJointTranslation(const QUuid& entityID, int jointIndex, glm::vec3 translation) { |
| 1114 | int jointIndex, glm::vec3 translation) { | ||
| 1115 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { | 1114 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { |
| 1116 | auto now = usecTimestampNow(); | 1115 | auto now = usecTimestampNow(); |
| 1117 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); | 1116 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); |
| 1118 | bool result = modelEntity->setAbsoluteJointTranslationInObjectFrame(jointIndex, translation); | 1117 | bool result = modelEntity->setLocalJointTranslation(jointIndex, translation); |
| 1119 | if (result) { | 1118 | if (result) { |
| 1120 | EntityItemProperties properties; | 1119 | EntityItemProperties properties; |
| 1121 | _entityTree->withWriteLock([&] { | 1120 | _entityTree->withWriteLock([&] { |
| @@ -1132,12 +1131,11 @@ bool EntityScriptingInterface::setAbsoluteJointTranslationInObjectFrame(const QU · 10 unmodified lines | |||
| 1132 | return false; | 1131 | return false; |
| 1133 | } | 1132 | } |
| 1134 | 1133 | ||
| 1135 | bool EntityScriptingInterface::setAbsoluteJointRotationInObjectFrame(const QUuid& entityID, | 1134 | bool EntityScriptingInterface::setLocalJointRotation(const QUuid& entityID, int jointIndex, glm::quat rotation) { |
| 1136 | int jointIndex, glm::quat rotation) { | ||
| 1137 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { | 1135 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { |
| 1138 | auto now = usecTimestampNow(); | 1136 | auto now = usecTimestampNow(); |
| 1139 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); | 1137 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); |
| 1140 | bool result = modelEntity->setAbsoluteJointRotationInObjectFrame(jointIndex, rotation); | 1138 | bool result = modelEntity->setLocalJointRotation(jointIndex, rotation); |
| 1141 | if (result) { | 1139 | if (result) { |
| 1142 | EntityItemProperties properties; | 1140 | EntityItemProperties properties; |
| 1143 | _entityTree->withWriteLock([&] { | 1141 | _entityTree->withWriteLock([&] { |
| @@ -1156,15 +1154,14 @@ bool EntityScriptingInterface::setAbsoluteJointRotationInObjectFrame(const QUuid · 12 unmodified lines | |||
| 1156 | 1154 | ||
| 1157 | 1155 | ||
| 1158 | 1156 | ||
| 1159 | bool EntityScriptingInterface::setAbsoluteJointRotationsInObjectFrame(const QUuid& entityID, | 1157 | bool EntityScriptingInterface::setLocalJointRotations(const QUuid& entityID, const QVector<glm::quat>& rotations) { |
| 1160 | const QVector<glm::quat>& rotations) { | ||
| 1161 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { | 1158 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { |
| 1162 | auto now = usecTimestampNow(); | 1159 | auto now = usecTimestampNow(); |
| 1163 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); | 1160 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); |
| 1164 | 1161 | ||
| 1165 | bool result = false; | 1162 | bool result = false; |
| 1166 | for (int index = 0; index < rotations.size(); index++) { | 1163 | for (int index = 0; index < rotations.size(); index++) { |
| 1167 | result |= modelEntity->setAbsoluteJointRotationInObjectFrame(index, rotations[index]); | 1164 | result |= modelEntity->setLocalJointRotation(index, rotations[index]); |
| 1168 | } | 1165 | } |
| 1169 | if (result) { | 1166 | if (result) { |
| 1170 | EntityItemProperties properties; | 1167 | EntityItemProperties properties; |
| @@ -1184,15 +1181,14 @@ bool EntityScriptingInterface::setAbsoluteJointRotationsInObjectFrame(const QUui · 13 unmodified lines | |||
| 1184 | } | 1181 | } |
| 1185 | 1182 | ||
| 1186 | 1183 | ||
| 1187 | bool EntityScriptingInterface::setAbsoluteJointTranslationsInObjectFrame(const QUuid& entityID, | 1184 | bool EntityScriptingInterface::setLocalJointTranslations(const QUuid& entityID, const QVector<glm::vec3>& translations) { |
| 1188 | const QVector<glm::vec3>& translations) { | ||
| 1189 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { | 1185 | if (auto entity = checkForTreeEntityAndTypeMatch(entityID, EntityTypes::Model)) { |
| 1190 | auto now = usecTimestampNow(); | 1186 | auto now = usecTimestampNow(); |
| 1191 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); | 1187 | auto modelEntity = std::dynamic_pointer_cast<ModelEntityItem>(entity); |
| 1192 | 1188 | ||
| 1193 | bool result = false; | 1189 | bool result = false; |
| 1194 | for (int index = 0; index < translations.size(); index++) { | 1190 | for (int index = 0; index < translations.size(); index++) { |
| 1195 | result |= modelEntity->setAbsoluteJointTranslationInObjectFrame(index, translations[index]); | 1191 | result |= modelEntity->setLocalJointTranslation(index, translations[index]); |
| 1196 | } | 1192 | } |
| 1197 | if (result) { | 1193 | if (result) { |
| 1198 | EntityItemProperties properties; | 1194 | EntityItemProperties properties; |
| @@ -1211,12 +1207,12 @@ bool EntityScriptingInterface::setAbsoluteJointTranslationsInObjectFrame(const Q · 12 unmodified lines | |||
| 1211 | return false; | 1207 | return false; |
| 1212 | } | 1208 | } |
| 1213 | 1209 | ||
| 1214 | bool EntityScriptingInterface::setAbsoluteJointsDataInObjectFrame(const QUuid& entityID, | 1210 | bool EntityScriptingInterface::setLocalJointsData(const QUuid& entityID, |
| 1215 | const QVector<glm::quat>& rotations, | 1211 | const QVector<glm::quat>& rotations, |
| 1216 | const QVector<glm::vec3>& translations) { | 1212 | const QVector<glm::vec3>& translations) { |
| 1217 | // for a model with 80 joints, sending both these in one edit packet causes the packet to be too large. | 1213 | // for a model with 80 joints, sending both these in one edit packet causes the packet to be too large. |
| 1218 | return setAbsoluteJointRotationsInObjectFrame(entityID, rotations) || | 1214 | return setLocalJointRotations(entityID, rotations) || |
| 1219 | setAbsoluteJointTranslationsInObjectFrame(entityID, translations); | 1215 | setLocalJointTranslations(entityID, translations); |
| 1220 | } | 1216 | } |
| 1221 | 1217 | ||
| 1222 | int EntityScriptingInterface::getJointIndex(const QUuid& entityID, const QString& name) { | 1218 | int EntityScriptingInterface::getJointIndex(const QUuid& entityID, const QString& name) { |