From 3402585d1ac2b053c4708025765afe9d40c5eb26 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 30 Nov 2015 16:54:29 -0800 Subject: [PATCH] fix a crash from previous commit --- libraries/avatars/src/AvatarData.cpp | 12 +++++++-- .../entities/src/EntityScriptingInterface.cpp | 26 +++++++------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index ec363756f6..a7a3e74663 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -90,8 +90,10 @@ const QUrl& AvatarData::defaultFullAvatarModelUrl() { // There are a number of possible strategies for this set of tools through endRender, below. void AvatarData::nextAttitude(glm::vec3 position, glm::quat orientation) { avatarLock.lock(); - SpatiallyNestable::setPosition(position); - SpatiallyNestable::setOrientation(orientation); + Transform trans; + trans.setTranslation(position); + trans.setRotation(orientation); + SpatiallyNestable::setTransform(trans); avatarLock.unlock(); updateAttitude(); } @@ -478,6 +480,12 @@ int AvatarData::parseDataFromBuffer(const QByteArray& buffer) { } // TODO is this safe? will the floats not exactly match? + // Andrew says: + // Yes, there is a possibility that the transmitted will not quite match the extracted despite being originally + // extracted from the exact same quaternion. I followed the code through and it appears the risk is that the + // avatar's SkeletonModel might fall into the CPU expensive part of Model::updateClusterMatrices() when otherwise it + // would not have required it. However, we know we can update many simultaneously animating avatars, and most + // avatars will be moving constantly anyway, so I don't think we need to worry. if (getBodyYaw() != yaw || getBodyPitch() != pitch || getBodyRoll() != roll) { _hasNewJointRotations = true; glm::vec3 eulerAngles(pitch, yaw, roll); diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 39da57f3a8..9cb816be1f 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -191,7 +191,7 @@ EntityItemProperties EntityScriptingInterface::getEntityProperties(QUuid identit } QUuid EntityScriptingInterface::editEntity(QUuid id, EntityItemProperties scriptSideProperties) { - EntityItemProperties properties = convertLocationFromScriptSemantics(scriptSideProperties); + EntityItemProperties properties = scriptSideProperties; EntityItemID entityID(id); // If we have a local entity tree set, then also update it. if (!_entityTree) { @@ -204,25 +204,17 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, EntityItemProperties script if (scriptSideProperties.parentDependentPropertyChanged()) { // if the script sets a location property but didn't include parent information, grab the needed // properties from the entity. - bool recompute = false; - EntityItemPointer entity = nullptr; - if (!scriptSideProperties.parentIDChanged()) { - entity = _entityTree->findEntityByEntityItemID(entityID); - scriptSideProperties.setParentID(entity->getParentID()); - recompute = true; - } - if (!scriptSideProperties.parentJointIndexChanged()) { - if (!entity) { - entity = _entityTree->findEntityByEntityItemID(entityID); + if (!scriptSideProperties.parentIDChanged() || !scriptSideProperties.parentJointIndexChanged()) { + EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); + if (entity && !scriptSideProperties.parentIDChanged()) { + properties.setParentID(entity->getParentID()); + } + if (entity && !scriptSideProperties.parentJointIndexChanged()) { + properties.setParentJointIndex(entity->getParentJointIndex()); } - scriptSideProperties.setParentJointIndex(entity->getParentJointIndex()); - recompute = true; - } - if (recompute) { - properties = convertLocationFromScriptSemantics(scriptSideProperties); } } - + properties = convertLocationFromScriptSemantics(properties); updatedEntity = _entityTree->updateEntity(entityID, properties); });