mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 06:51:15 +02:00
Merge pull request #36 from birarda/entity-script-server
force full send if query changes, don't check inclusion if not updated
This commit is contained in:
commit
4ec5d70e76
5 changed files with 42 additions and 13 deletions
|
@ -316,8 +316,9 @@ int OctreeSendThread::packetDistributor(SharedNodePointer node, OctreeQueryNode*
|
|||
int truePacketsSent = 0;
|
||||
int trueBytesSent = 0;
|
||||
int packetsSentThisInterval = 0;
|
||||
bool isFullScene = nodeData->getUsesFrustum() &&
|
||||
((!viewFrustumChanged && nodeData->getViewFrustumJustStoppedChanging()) || nodeData->hasLodChanged());
|
||||
bool isFullScene = nodeData->haveJSONParametersChanged() ||
|
||||
(nodeData->getUsesFrustum()
|
||||
&& ((!viewFrustumChanged && nodeData->getViewFrustumJustStoppedChanging()) || nodeData->hasLodChanged()));
|
||||
|
||||
bool somethingToSend = true; // assume we have something
|
||||
|
||||
|
|
|
@ -960,11 +960,20 @@ void DomainServer::sendDomainListToNode(const SharedNodePointer& node, const Hif
|
|||
// (1/19/17) Agents only need to connect to Entity Script Servers to perform administrative tasks
|
||||
// related to entity server scripts. Only agents with rez permissions should be doing that, so
|
||||
// if the agent does not have those permissions, we do not want them and the server to incur the
|
||||
// overhead of connecting to one another.
|
||||
bool shouldNotConnect = (node->getType() == NodeType::Agent && otherNode->getType() == NodeType::EntityScriptServer
|
||||
&& !node->getCanRez() && !node->getCanRezTmp())
|
||||
|| (node->getType() == NodeType::EntityScriptServer && otherNode->getType() == NodeType::Agent
|
||||
&& !otherNode->getCanRez() && !otherNode->getCanRezTmp());
|
||||
// overhead of connecting to one another. Additionally we exclude agents that do not care about the
|
||||
// Entity Script Server and won't attempt to connect to it.
|
||||
auto otherNodeData = static_cast<DomainServerNodeData*>(otherNode->getLinkedData());
|
||||
|
||||
bool isAgentWithoutRights = node->getType() == NodeType::Agent
|
||||
&& otherNode->getType() == NodeType::EntityScriptServer
|
||||
&& !node->getCanRez() && !node->getCanRezTmp();
|
||||
|
||||
bool isScriptServerForIneffectiveAgent =
|
||||
(node->getType() == NodeType::EntityScriptServer && otherNode->getType() == NodeType::Agent)
|
||||
&& (!otherNodeData->getNodeInterestSet().contains(NodeType::EntityServer)
|
||||
|| (!otherNode->getCanRez() && !otherNode->getCanRezTmp()));
|
||||
|
||||
bool shouldNotConnect = isAgentWithoutRights || isScriptServerForIneffectiveAgent;
|
||||
|
||||
if (!shouldNotConnect) {
|
||||
// since we're about to add a node to the packet we start a segment
|
||||
|
|
|
@ -302,14 +302,15 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
|
|||
includeThisEntity = false;
|
||||
}
|
||||
|
||||
if (!jsonFilters.isEmpty()) {
|
||||
// if this entity has been updated since our last full send and there are json filters, check them
|
||||
if (includeThisEntity && !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;
|
||||
includeThisEntity = true;
|
||||
|
||||
// make sure this entity is in the set of entities sent last frame
|
||||
entityNodeData->insertEntitySentLastFrame(entity->getID());
|
||||
|
@ -317,7 +318,7 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
|
|||
} else {
|
||||
// we might include this entity if it matched in the previous frame
|
||||
if (entityNodeData->sentEntityLastFrame(entity->getID())) {
|
||||
includeThisEntity = includeThisEntity && true;
|
||||
includeThisEntity = true;
|
||||
|
||||
entityNodeData->removeEntitySentLastFrame(entity->getID());
|
||||
} else {
|
||||
|
@ -326,11 +327,12 @@ OctreeElement::AppendState EntityTreeElement::appendElementData(OctreePacketData
|
|||
}
|
||||
}
|
||||
|
||||
if (hadElementExtraData) {
|
||||
includeThisEntity = includeThisEntity &&
|
||||
entityTreeElementExtraEncodeData->entities.contains(entity->getEntityItemID());
|
||||
if (includeThisEntity && hadElementExtraData) {
|
||||
includeThisEntity = entityTreeElementExtraEncodeData->entities.contains(entity->getEntityItemID());
|
||||
}
|
||||
|
||||
// we only check the bounds against our frustum and LOD if the query has asked us to check against the frustum
|
||||
// which can sometimes not be the case when JSON filters are sent
|
||||
if (params.usesFrustum && (includeThisEntity || params.recurseEverything)) {
|
||||
|
||||
// we want to use the maximum possible box for this, so that we don't have to worry about the nuance of
|
||||
|
|
|
@ -320,3 +320,15 @@ void OctreeQueryNode::parseNackPacket(ReceivedMessage& message) {
|
|||
_nackedSequenceNumbers.enqueue(sequenceNumber);
|
||||
}
|
||||
}
|
||||
|
||||
bool OctreeQueryNode::haveJSONParametersChanged() {
|
||||
bool parametersChanged = false;
|
||||
auto currentParameters = getJSONParameters();
|
||||
|
||||
if (_lastCheckJSONParameters != currentParameters) {
|
||||
parametersChanged = true;
|
||||
_lastCheckJSONParameters = currentParameters;
|
||||
}
|
||||
|
||||
return parametersChanged;
|
||||
}
|
||||
|
|
|
@ -100,6 +100,9 @@ public:
|
|||
bool hasNextNackedPacket() const;
|
||||
const NLPacket* getNextNackedPacket();
|
||||
|
||||
// call only from OctreeSendThread for the given node
|
||||
bool haveJSONParametersChanged();
|
||||
|
||||
private:
|
||||
OctreeQueryNode(const OctreeQueryNode &);
|
||||
OctreeQueryNode& operator= (const OctreeQueryNode&);
|
||||
|
@ -143,6 +146,8 @@ private:
|
|||
quint64 _sceneSendStartTime = 0;
|
||||
|
||||
std::array<char, udt::MAX_PACKET_SIZE> _lastOctreePayload;
|
||||
|
||||
QJsonObject _lastCheckJSONParameters;
|
||||
};
|
||||
|
||||
#endif // hifi_OctreeQueryNode_h
|
||||
|
|
Loading…
Reference in a new issue