mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:13:05 +02:00
Merge pull request #29 from birarda/entity-script-server
some fixes from code review
This commit is contained in:
commit
b60ba0ff5c
4 changed files with 35 additions and 30 deletions
|
@ -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_X_P_NEIGHBOR_ID, XPNeighborID, xPNeighborID, EntityItemID);
|
||||||
ADD_PROPERTY_TO_MAP(PROP_Y_P_NEIGHBOR_ID, YPNeighborID, yPNeighborID, 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_Z_P_NEIGHBOR_ID, ZPNeighborID, zPNeighborID, EntityItemID);
|
||||||
|
|
||||||
ADD_PROPERTY_TO_MAP(PROP_PARENT_ID, ParentID, parentID, QUuid);
|
ADD_PROPERTY_TO_MAP(PROP_PARENT_ID, ParentID, parentID, QUuid);
|
||||||
ADD_PROPERTY_TO_MAP(PROP_PARENT_JOINT_INDEX, ParentJointIndex, parentJointIndex, uint16_t);
|
ADD_PROPERTY_TO_MAP(PROP_PARENT_JOINT_INDEX, ParentJointIndex, parentJointIndex, uint16_t);
|
||||||
|
|
||||||
|
|
|
@ -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 = static_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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ PacketVersion versionForPacketType(PacketType packetType) {
|
||||||
case PacketType::EntityData:
|
case PacketType::EntityData:
|
||||||
return VERSION_ENTITIES_SERVER_SCRIPTS;
|
return VERSION_ENTITIES_SERVER_SCRIPTS;
|
||||||
case PacketType::EntityQuery:
|
case PacketType::EntityQuery:
|
||||||
return VERSION_ENTITIES_JSON_FILTER;
|
return static_cast<PacketVersion>(EntityQueryPacketVersion::JsonFilter);
|
||||||
case PacketType::AvatarIdentity:
|
case PacketType::AvatarIdentity:
|
||||||
case PacketType::AvatarData:
|
case PacketType::AvatarData:
|
||||||
case PacketType::BulkAvatarData:
|
case PacketType::BulkAvatarData:
|
||||||
|
|
|
@ -201,7 +201,10 @@ const PacketVersion VERSION_WEB_ENTITIES_SUPPORT_DPI = 63;
|
||||||
const PacketVersion VERSION_ENTITIES_ARROW_ACTION = 64;
|
const PacketVersion VERSION_ENTITIES_ARROW_ACTION = 64;
|
||||||
const PacketVersion VERSION_ENTITIES_LAST_EDITED_BY = 65;
|
const PacketVersion VERSION_ENTITIES_LAST_EDITED_BY = 65;
|
||||||
const PacketVersion VERSION_ENTITIES_SERVER_SCRIPTS = 66;
|
const PacketVersion VERSION_ENTITIES_SERVER_SCRIPTS = 66;
|
||||||
const PacketVersion VERSION_ENTITIES_JSON_FILTER = 67;
|
|
||||||
|
enum class EntityQueryPacketVersion: PacketVersion {
|
||||||
|
JsonFilter = 18
|
||||||
|
};
|
||||||
|
|
||||||
enum class AssetServerPacketVersion: PacketVersion {
|
enum class AssetServerPacketVersion: PacketVersion {
|
||||||
VegasCongestionControl = 19
|
VegasCongestionControl = 19
|
||||||
|
|
Loading…
Reference in a new issue