From 701f99d28ead6b5a908456610e6e9296fd1695a7 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Fri, 18 Dec 2015 16:28:11 -0800 Subject: [PATCH] only send a queryAACube for entities to entity-server --- .../entities/src/EntityScriptingInterface.cpp | 26 +++++++++++-------- libraries/physics/src/EntityMotionState.cpp | 12 ++++++--- libraries/shared/src/SpatiallyNestable.cpp | 2 ++ 3 files changed, 25 insertions(+), 15 deletions(-) diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 57201174f5..56dc13a126 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -278,18 +278,22 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& properties.setQueryAACube(entity->getQueryAACube()); } entity->setLastBroadcast(usecTimestampNow()); - } - // if we've moved an entity with children, check/update the queryAACube of all descendents and tell the server - // if they've changed. - // TODO -- ancestors of this entity may also need to expand their queryAACubes. - entity->forEachDescendant([&](SpatiallyNestablePointer descendant) { - if (descendant->setPuffedQueryAACube()) { - EntityItemProperties newQueryCubeProperties; - newQueryCubeProperties.setQueryAACube(descendant->getQueryAACube()); - queueEntityMessage(PacketType::EntityEdit, descendant->getID(), newQueryCubeProperties); - } - }); + // if we've moved an entity with children, check/update the queryAACube of all descendents and tell the server + // if they've changed. + // TODO -- ancestors of this entity may also need to expand their queryAACubes. + entity->forEachDescendant([&](SpatiallyNestablePointer descendant) { + if (descendant->getNestableType() == NestableType::Entity) { + EntityItemPointer entityDescendant = std::static_pointer_cast(descendant); + if (descendant->setPuffedQueryAACube()) { + EntityItemProperties newQueryCubeProperties; + newQueryCubeProperties.setQueryAACube(descendant->getQueryAACube()); + queueEntityMessage(PacketType::EntityEdit, descendant->getID(), newQueryCubeProperties); + entityDescendant->setLastBroadcast(usecTimestampNow()); + } + } + }); + } }); queueEntityMessage(PacketType::EntityEdit, entityID, properties); return id; diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index ac0e25a233..4dd61608cc 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -515,10 +515,14 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, const Q // if they've changed. // TODO -- ancestors of this entity may also need to expand their queryAACubes. _entity->forEachDescendant([&](SpatiallyNestablePointer descendant) { - if (descendant->setPuffedQueryAACube()) { - EntityItemProperties newQueryCubeProperties; - newQueryCubeProperties.setQueryAACube(descendant->getQueryAACube()); - entityPacketSender->queueEditEntityMessage(PacketType::EntityEdit, descendant->getID(), newQueryCubeProperties); + if (descendant->getNestableType() == NestableType::Entity) { + EntityItemPointer entityDescendant = std::static_pointer_cast(descendant); + if (descendant->setPuffedQueryAACube()) { + EntityItemProperties newQueryCubeProperties; + newQueryCubeProperties.setQueryAACube(descendant->getQueryAACube()); + entityPacketSender->queueEditEntityMessage(PacketType::EntityEdit, descendant->getID(), newQueryCubeProperties); + entityDescendant->setLastBroadcast(usecTimestampNow()); + } } }); diff --git a/libraries/shared/src/SpatiallyNestable.cpp b/libraries/shared/src/SpatiallyNestable.cpp index af889b8245..ef8c39292b 100644 --- a/libraries/shared/src/SpatiallyNestable.cpp +++ b/libraries/shared/src/SpatiallyNestable.cpp @@ -296,6 +296,8 @@ void SpatiallyNestable::setPosition(const glm::vec3& position, bool& success) { }); if (success) { locationChanged(); + } else { + qDebug() << "setPosition failed for" << getID(); } }