mirror of
https://github.com/overte-org/overte.git
synced 2025-08-11 06:53:00 +02:00
don't grab the JSON filters for each entity checked
This commit is contained in:
parent
6376068021
commit
67951517b4
1 changed files with 29 additions and 27 deletions
|
@ -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
|
// 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.
|
// need to handle the case where our sibling elements need encoding but we don't.
|
||||||
if (!entityTreeElementExtraEncodeData->elementCompleted) {
|
if (!entityTreeElementExtraEncodeData->elementCompleted) {
|
||||||
|
|
||||||
|
QJsonObject jsonFilters;
|
||||||
|
auto entityNodeData = dynamic_cast<EntityNodeData*>(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++) {
|
for (uint16_t i = 0; i < _entityItems.size(); i++) {
|
||||||
EntityItemPointer entity = _entityItems[i];
|
EntityItemPointer entity = _entityItems[i];
|
||||||
bool includeThisEntity = true;
|
bool includeThisEntity = true;
|
||||||
|
@ -291,35 +301,27 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
|
||||||
if (!params.forceSendScene && entity->getLastChangedOnServer() < params.lastQuerySent) {
|
if (!params.forceSendScene && entity->getLastChangedOnServer() < params.lastQuerySent) {
|
||||||
includeThisEntity = false;
|
includeThisEntity = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto entityNodeData = dynamic_cast<EntityNodeData*>(params.nodeData);
|
if (!jsonFilters.isEmpty()) {
|
||||||
|
|
||||||
if (entityNodeData) {
|
// if params include JSON filters, check if this entity matches
|
||||||
// we have an EntityNodeData instance
|
bool entityMatchesFilters = entity->matchesJSONFilters(jsonFilters);
|
||||||
// so we should assume that means we might have JSON filters to check
|
|
||||||
auto jsonFilters = entityNodeData->getJSONParameters();
|
if (entityMatchesFilters) {
|
||||||
|
// we should include this entity unless it has already been excluded
|
||||||
if (!jsonFilters.isEmpty()) {
|
includeThisEntity = includeThisEntity && true;
|
||||||
|
|
||||||
// if params include JSON filters, check if this entity matches
|
// make sure this entity is in the set of entities sent last frame
|
||||||
bool entityMatchesFilters = entity->matchesJSONFilters(jsonFilters);
|
entityNodeData->insertEntitySentLastFrame(entity->getID());
|
||||||
|
|
||||||
if (entityMatchesFilters) {
|
} else {
|
||||||
// we should include this entity unless it has already been excluded
|
// we might include this entity if it matched in the previous frame
|
||||||
|
if (entityNodeData->sentEntityLastFrame(entity->getID())) {
|
||||||
includeThisEntity = includeThisEntity && true;
|
includeThisEntity = includeThisEntity && true;
|
||||||
|
|
||||||
// make sure this entity is in the set of entities sent last frame
|
entityNodeData->removeEntitySentLastFrame(entity->getID());
|
||||||
entityNodeData->insertEntitySentLastFrame(entity->getID());
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// we might include this entity if it matched in the previous frame
|
includeThisEntity = false;
|
||||||
if (entityNodeData->sentEntityLastFrame(entity->getID())) {
|
|
||||||
includeThisEntity = includeThisEntity && true;
|
|
||||||
|
|
||||||
entityNodeData->removeEntitySentLastFrame(entity->getID());
|
|
||||||
} else {
|
|
||||||
includeThisEntity = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue