diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 572ca661a5..04c2ecec56 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -1021,7 +1021,7 @@ void EntityItemProperties::entityPropertyFlagsFromScriptValue(const QScriptValue ADD_PROPERTY_TO_MAP(PROP_X_P_NEIGHBOR_ID, XPNeighborID, xPNeighborID, EntityItemID); ADD_PROPERTY_TO_MAP(PROP_Y_P_NEIGHBOR_ID, YPNeighborID, yPNeighborID, EntityItemID); ADD_PROPERTY_TO_MAP(PROP_Z_P_NEIGHBOR_ID, ZPNeighborID, zPNeighborID, EntityItemID); - + ADD_PROPERTY_TO_MAP(PROP_PARENT_ID, ParentID, parentID, QUuid); ADD_PROPERTY_TO_MAP(PROP_PARENT_JOINT_INDEX, ParentJointIndex, parentJointIndex, uint16_t); diff --git a/libraries/entities/src/EntityTreeElement.cpp b/libraries/entities/src/EntityTreeElement.cpp index 7ece947e89..4cd82f223d 100644 --- a/libraries/entities/src/EntityTreeElement.cpp +++ b/libraries/entities/src/EntityTreeElement.cpp @@ -284,6 +284,16 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData // entities for encoding. This is needed because we encode the element data at the "parent" level, and so we // need to handle the case where our sibling elements need encoding but we don't. if (!entityTreeElementExtraEncodeData->elementCompleted) { + + QJsonObject jsonFilters; + auto entityNodeData = static_cast(params.nodeData); + + if (entityNodeData) { + // we have an EntityNodeData instance + // so we should assume that means we might have JSON filters to check + jsonFilters = entityNodeData->getJSONParameters(); + } + for (uint16_t i = 0; i < _entityItems.size(); i++) { EntityItemPointer entity = _entityItems[i]; bool includeThisEntity = true; @@ -291,35 +301,27 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData if (!params.forceSendScene && entity->getLastChangedOnServer() < params.lastQuerySent) { includeThisEntity = false; } - - auto entityNodeData = dynamic_cast(params.nodeData); - - if (entityNodeData) { - // we have an EntityNodeData instance - // so we should assume that means we might have JSON filters to check - auto jsonFilters = entityNodeData->getJSONParameters(); - - if (!jsonFilters.isEmpty()) { - - // if params include JSON filters, check if this entity matches - bool entityMatchesFilters = entity->matchesJSONFilters(jsonFilters); - - if (entityMatchesFilters) { - // we should include this entity unless it has already been excluded + + if (!jsonFilters.isEmpty()) { + + // if params include JSON filters, check if this entity matches + bool entityMatchesFilters = entity->matchesJSONFilters(jsonFilters); + + if (entityMatchesFilters) { + // we should include this entity unless it has already been excluded + includeThisEntity = includeThisEntity && true; + + // make sure this entity is in the set of entities sent last frame + entityNodeData->insertEntitySentLastFrame(entity->getID()); + + } else { + // we might include this entity if it matched in the previous frame + if (entityNodeData->sentEntityLastFrame(entity->getID())) { includeThisEntity = includeThisEntity && true; - - // make sure this entity is in the set of entities sent last frame - entityNodeData->insertEntitySentLastFrame(entity->getID()); - + + entityNodeData->removeEntitySentLastFrame(entity->getID()); } else { - // we might include this entity if it matched in the previous frame - if (entityNodeData->sentEntityLastFrame(entity->getID())) { - includeThisEntity = includeThisEntity && true; - - entityNodeData->removeEntitySentLastFrame(entity->getID()); - } else { - includeThisEntity = false; - } + includeThisEntity = false; } } } diff --git a/libraries/networking/src/udt/PacketHeaders.cpp b/libraries/networking/src/udt/PacketHeaders.cpp index e2203389d0..89f30829fd 100644 --- a/libraries/networking/src/udt/PacketHeaders.cpp +++ b/libraries/networking/src/udt/PacketHeaders.cpp @@ -50,7 +50,7 @@ PacketVersion versionForPacketType(PacketType packetType) { case PacketType::EntityData: return VERSION_ENTITIES_SERVER_SCRIPTS; case PacketType::EntityQuery: - return VERSION_ENTITIES_JSON_FILTER; + return static_cast(EntityQueryPacketVersion::JsonFilter); case PacketType::AvatarIdentity: case PacketType::AvatarData: case PacketType::BulkAvatarData: diff --git a/libraries/networking/src/udt/PacketHeaders.h b/libraries/networking/src/udt/PacketHeaders.h index 375043a370..aeeb15c057 100644 --- a/libraries/networking/src/udt/PacketHeaders.h +++ b/libraries/networking/src/udt/PacketHeaders.h @@ -201,7 +201,10 @@ const PacketVersion VERSION_WEB_ENTITIES_SUPPORT_DPI = 63; const PacketVersion VERSION_ENTITIES_ARROW_ACTION = 64; const PacketVersion VERSION_ENTITIES_LAST_EDITED_BY = 65; const PacketVersion VERSION_ENTITIES_SERVER_SCRIPTS = 66; -const PacketVersion VERSION_ENTITIES_JSON_FILTER = 67; + +enum class EntityQueryPacketVersion: PacketVersion { + JsonFilter = 18 +}; enum class AssetServerPacketVersion: PacketVersion { VegasCongestionControl = 19