only send a queryAACube for entities to entity-server

This commit is contained in:
Seth Alves 2015-12-18 16:28:11 -08:00
parent 7689453ba2
commit 701f99d28e
3 changed files with 25 additions and 15 deletions

View file

@ -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<EntityItem>(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;

View file

@ -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<EntityItem>(descendant);
if (descendant->setPuffedQueryAACube()) {
EntityItemProperties newQueryCubeProperties;
newQueryCubeProperties.setQueryAACube(descendant->getQueryAACube());
entityPacketSender->queueEditEntityMessage(PacketType::EntityEdit, descendant->getID(), newQueryCubeProperties);
entityDescendant->setLastBroadcast(usecTimestampNow());
}
}
});

View file

@ -296,6 +296,8 @@ void SpatiallyNestable::setPosition(const glm::vec3& position, bool& success) {
});
if (success) {
locationChanged();
} else {
qDebug() << "setPosition failed for" << getID();
}
}