From 96f506a98db225816da67dabfc97952d1768b90a Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 5 Jan 2016 07:27:27 -0800 Subject: [PATCH] code review --- libraries/avatars/src/AvatarData.cpp | 10 ++++++++++ libraries/avatars/src/AvatarData.h | 3 +++ .../entities/src/EntityScriptingInterface.cpp | 6 +++--- libraries/physics/src/EntityMotionState.cpp | 4 ++-- libraries/shared/src/SpatiallyNestable.cpp | 14 ++------------ libraries/shared/src/SpatiallyNestable.h | 6 +++--- 6 files changed, 23 insertions(+), 20 deletions(-) diff --git a/libraries/avatars/src/AvatarData.cpp b/libraries/avatars/src/AvatarData.cpp index d955808e34..1848845a07 100644 --- a/libraries/avatars/src/AvatarData.cpp +++ b/libraries/avatars/src/AvatarData.cpp @@ -1648,3 +1648,13 @@ void AvatarData::setPosition(const glm::vec3& position) { void AvatarData::setOrientation(const glm::quat& orientation) { SpatiallyNestable::setOrientation(orientation); } + +glm::quat AvatarData::getAbsoluteJointRotationInObjectFrame(int index) const { + assert(false); + return glm::quat(); +} + +glm::vec3 AvatarData::getAbsoluteJointTranslationInObjectFrame(int index) const { + assert(false); + return glm::vec3(); +} diff --git a/libraries/avatars/src/AvatarData.h b/libraries/avatars/src/AvatarData.h index 42ecf098b3..c0fe62c7c4 100644 --- a/libraries/avatars/src/AvatarData.h +++ b/libraries/avatars/src/AvatarData.h @@ -356,6 +356,9 @@ public slots: void setJointMappingsFromNetworkReply(); void setSessionUUID(const QUuid& sessionUUID) { setID(sessionUUID); } + virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const override; + virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const override; + protected: glm::vec3 _handPosition; diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 59aa4dac85..cfb8e0b5a9 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -274,7 +274,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& entity->flagForOwnership(); } } - if (properties.parentRelatedPropertyChanged() && entity->setPuffedQueryAACube()) { + if (properties.parentRelatedPropertyChanged() && entity->computePuffedQueryAACube()) { properties.setQueryAACube(entity->getQueryAACube()); } entity->setLastBroadcast(usecTimestampNow()); @@ -283,8 +283,8 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& // if they've changed. entity->forEachDescendant([&](SpatiallyNestablePointer descendant) { if (descendant->getNestableType() == NestableType::Entity) { - EntityItemPointer entityDescendant = std::static_pointer_cast(descendant); - if (descendant->setPuffedQueryAACube()) { + if (descendant->computePuffedQueryAACube()) { + EntityItemPointer entityDescendant = std::static_pointer_cast(descendant); EntityItemProperties newQueryCubeProperties; newQueryCubeProperties.setQueryAACube(descendant->getQueryAACube()); queueEntityMessage(PacketType::EntityEdit, descendant->getID(), newQueryCubeProperties); diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 430db2b2aa..cd07b4112f 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -470,7 +470,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, const Q properties.setActionData(_serverActionData); } - if (properties.parentRelatedPropertyChanged() && _entity->setPuffedQueryAACube()) { + if (properties.parentRelatedPropertyChanged() && _entity->computePuffedQueryAACube()) { // due to parenting, the server may not know where something is in world-space, so include the bounding cube. properties.setQueryAACube(_entity->getQueryAACube()); } @@ -516,7 +516,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, const Q _entity->forEachDescendant([&](SpatiallyNestablePointer descendant) { if (descendant->getNestableType() == NestableType::Entity) { EntityItemPointer entityDescendant = std::static_pointer_cast(descendant); - if (descendant->setPuffedQueryAACube()) { + if (descendant->computePuffedQueryAACube()) { EntityItemProperties newQueryCubeProperties; newQueryCubeProperties.setQueryAACube(descendant->getQueryAACube()); entityPacketSender->queueEditEntityMessage(PacketType::EntityEdit, descendant->getID(), newQueryCubeProperties); diff --git a/libraries/shared/src/SpatiallyNestable.cpp b/libraries/shared/src/SpatiallyNestable.cpp index 841d8c3d44..07d5ddeeb0 100644 --- a/libraries/shared/src/SpatiallyNestable.cpp +++ b/libraries/shared/src/SpatiallyNestable.cpp @@ -497,16 +497,6 @@ const Transform SpatiallyNestable::getAbsoluteJointTransformInObjectFrame(int jo return jointTransformInObjectFrame; } -glm::quat SpatiallyNestable::getAbsoluteJointRotationInObjectFrame(int index) const { - assert(false); - return glm::quat(); -} - -glm::vec3 SpatiallyNestable::getAbsoluteJointTranslationInObjectFrame(int index) const { - assert(false); - return glm::vec3(); -} - SpatiallyNestablePointer SpatiallyNestable::getThisPointer() const { SpatiallyNestableConstPointer constThisPointer = shared_from_this(); SpatiallyNestablePointer thisPointer = std::const_pointer_cast(constThisPointer); // ermahgerd !!! @@ -562,7 +552,7 @@ bool SpatiallyNestable::queryAABoxNeedsUpdate() const { // make sure children are still in their boxes, also. bool childNeedsUpdate = false; getThisPointer()->forEachDescendant([&](SpatiallyNestablePointer descendant) { - if (descendant->queryAABoxNeedsUpdate()) { + if (!childNeedsUpdate && descendant->queryAABoxNeedsUpdate()) { childNeedsUpdate = true; } }); @@ -577,7 +567,7 @@ bool SpatiallyNestable::queryAABoxNeedsUpdate() const { return true; } -bool SpatiallyNestable::setPuffedQueryAACube() { +bool SpatiallyNestable::computePuffedQueryAACube() { if (!queryAABoxNeedsUpdate()) { return false; } diff --git a/libraries/shared/src/SpatiallyNestable.h b/libraries/shared/src/SpatiallyNestable.h index 91fdd84be0..6573c0c2ce 100644 --- a/libraries/shared/src/SpatiallyNestable.h +++ b/libraries/shared/src/SpatiallyNestable.h @@ -69,7 +69,7 @@ public: virtual void setOrientation(const glm::quat& orientation); virtual AACube getMaximumAACube(bool& success) const; - virtual bool setPuffedQueryAACube(); + virtual bool computePuffedQueryAACube(); virtual void setQueryAACube(const AACube& queryAACube); virtual bool queryAABoxNeedsUpdate() const; @@ -102,8 +102,8 @@ public: // this object's frame virtual const Transform getAbsoluteJointTransformInObjectFrame(int jointIndex) const; - virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const; - virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const; + virtual glm::quat getAbsoluteJointRotationInObjectFrame(int index) const = 0; + virtual glm::vec3 getAbsoluteJointTranslationInObjectFrame(int index) const = 0; SpatiallyNestablePointer getThisPointer() const;