Merge pull request #15 from birarda/entity-script-server

stop script engine when entity server goes away, fix inefficient repeated send
This commit is contained in:
Clément Brisset 2017-01-19 16:54:38 -08:00 committed by GitHub
commit 3f8dc58c57
4 changed files with 15 additions and 11 deletions

View file

@ -316,9 +316,8 @@ 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->getUsesFrustum() &&
((!viewFrustumChanged && nodeData->getViewFrustumJustStoppedChanging()) || nodeData->hasLodChanged());
bool somethingToSend = true; // assume we have something

View file

@ -297,7 +297,11 @@ void EntityScriptServer::checkAndCallPreload(const EntityItemID& entityID, const
void EntityScriptServer::nodeKilled(SharedNodePointer killedNode) {
if (killedNode->getType() == NodeType::EntityServer) {
_entitiesScriptEngine->unloadAllEntityScripts();
if (_entitiesScriptEngine) {
_entitiesScriptEngine->unloadAllEntityScripts();
_entitiesScriptEngine->stop();
}
resetEntitiesScriptEngine();
}
}

View file

@ -221,7 +221,7 @@ public:
DEFINE_PROPERTY_REF(PROP_LAST_EDITED_BY, LastEditedBy, lastEditedBy, QUuid, ENTITY_ITEM_DEFAULT_LAST_EDITED_BY);
DEFINE_PROPERTY_REF(PROP_SERVER_SCRIPTS, ServerScripts, serverScripts, QString, "");
DEFINE_PROPERTY_REF(PROP_SERVER_SCRIPTS, ServerScripts, serverScripts, QString, ENTITY_ITEM_DEFAULT_SERVER_SCRIPTS);
static QString getBackgroundModeString(BackgroundMode mode);

View file

@ -899,7 +899,7 @@ int Octree::encodeTreeBitstream(OctreeElementPointer element,
}
// If we're at a element that is out of view, then we can return, because no nodes below us will be in view!
if (!params.recurseEverything && !element->isInView(params.viewFrustum)) {
if (params.usesFrustum && !params.recurseEverything && !element->isInView(params.viewFrustum)) {
params.stopReason = EncodeBitstreamParams::OUT_OF_VIEW;
return bytesWritten;
}
@ -1015,7 +1015,7 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element,
}
ViewFrustum::intersection nodeLocationThisView = ViewFrustum::INSIDE; // assume we're inside
if (!params.recurseEverything) {
if (params.usesFrustum && !params.recurseEverything) {
float boundaryDistance = boundaryDistanceForRenderLevel(element->getLevel() + params.boundaryLevelAdjust,
params.octreeElementSizeScale);
@ -1176,7 +1176,7 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element,
int originalIndex = indexOfChildren[i];
bool childIsInView = (childElement &&
(params.recurseEverything ||
(params.recurseEverything || !params.usesFrustum ||
(nodeLocationThisView == ViewFrustum::INSIDE) || // parent was fully in view, we can assume ALL children are
(nodeLocationThisView == ViewFrustum::INTERSECT &&
childElement->isInView(params.viewFrustum)) // the parent intersects and the child is in view
@ -1189,7 +1189,7 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element,
}
} else {
// Before we consider this further, let's see if it's in our LOD scope...
float boundaryDistance = params.recurseEverything ? 1 :
float boundaryDistance = params.recurseEverything || !params.usesFrustum ? 1 :
boundaryDistanceForRenderLevel(childElement->getLevel() + params.boundaryLevelAdjust,
params.octreeElementSizeScale);
@ -1211,7 +1211,7 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element,
bool childIsOccluded = false; // assume it's not occluded
bool shouldRender = params.recurseEverything ||
bool shouldRender = params.recurseEverything || !params.usesFrustum ||
childElement->calculateShouldRender(params.viewFrustum,
params.octreeElementSizeScale, params.boundaryLevelAdjust);
@ -1451,7 +1451,8 @@ int Octree::encodeTreeBitstreamRecursion(OctreeElementPointer element,
// called databits), then we wouldn't send the children. So those types of Octree's should tell us to keep
// recursing, by returning TRUE in recurseChildrenWithData().
if (params.recurseEverything || recurseChildrenWithData() || !oneAtBit(childrenDataBits, originalIndex)) {
if (params.recurseEverything || !params.usesFrustum
|| recurseChildrenWithData() || !oneAtBit(childrenDataBits, originalIndex)) {
// Allow the datatype a chance to determine if it really wants to recurse this tree. Usually this
// will be true. But if the tree has already been encoded, we will skip this.