From ad9ce2edd3f63d121411fa7d0de0c18fb07b596e Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Thu, 28 Aug 2014 21:34:12 -0700 Subject: [PATCH] delete moving entities that travel outside of domain --- examples/editModels.js | 1 - libraries/entities/src/EntityTree.cpp | 40 +++++++++++++++++---------- libraries/entities/src/todo.txt | 2 +- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/examples/editModels.js b/examples/editModels.js index a63233809b..90398113bf 100644 --- a/examples/editModels.js +++ b/examples/editModels.js @@ -2835,7 +2835,6 @@ function handeMenuEvent(menuItem) { } array.push({ button: "Cancel" }); - var propertyName = Window.form("Edit Properties", array); if (Window.form("Edit Properties", array)) { var index = 0; if (properties.type == "Model") { diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 87961841aa..45767d9f1a 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -768,23 +768,33 @@ void EntityTree::updateMovingEntities(quint64 now, QSet& entitiesT AACube oldCube = thisEntity->getAACube(); thisEntity->update(now); AACube newCube = thisEntity->getAACube(); - - if (wantDebug) { - qDebug() << "EntityTree::update() thisEntity=" << thisEntity; - qDebug() << " oldCube=" << oldCube; - qDebug() << " newCube=" << newCube; + + // check to see if this movement has sent the entity outside of the domain. + AACube domainBounds(glm::vec3(0.0f,0.0f,0.0f), 1.0f); + if (!domainBounds.touches(newCube)) { + if (wantDebug) { + qDebug() << "The entity " << thisEntity->getEntityItemID() << " moved outside of the domain. Delete it."; } - - moveOperator.addEntityToMoveList(thisEntity, oldCube, newCube); - - // check to see if this entity is no longer moving - EntityItem::SimulationState newState = thisEntity->getSimulationState(); - if (newState == EntityItem::Changing) { - entitiesBecomingChanging << thisEntity; - } else if (newState == EntityItem::Mortal) { - entitiesBecomingMortal << thisEntity; - } else if (newState == EntityItem::Static) { + entitiesToDelete << thisEntity->getEntityItemID(); entitiesBecomingStatic << thisEntity; + } else { + if (wantDebug) { + qDebug() << "EntityTree::update() thisEntity=" << thisEntity; + qDebug() << " oldCube=" << oldCube; + qDebug() << " newCube=" << newCube; + } + + moveOperator.addEntityToMoveList(thisEntity, oldCube, newCube); + + // check to see if this entity is no longer moving + EntityItem::SimulationState newState = thisEntity->getSimulationState(); + if (newState == EntityItem::Changing) { + entitiesBecomingChanging << thisEntity; + } else if (newState == EntityItem::Mortal) { + entitiesBecomingMortal << thisEntity; + } else if (newState == EntityItem::Static) { + entitiesBecomingStatic << thisEntity; + } } } } diff --git a/libraries/entities/src/todo.txt b/libraries/entities/src/todo.txt index 4f7afd1692..549236a528 100644 --- a/libraries/entities/src/todo.txt +++ b/libraries/entities/src/todo.txt @@ -1,6 +1,5 @@ // REQUIRED: - 3) if velocity sends a model out of the domain - delete it 4) Test file save load for case where two siblings have more than MTU amount of data. I wonder if the fact that file save doesn't include the extra exists bits will break something. @@ -248,6 +247,7 @@ // SOLVED -- 42) Crash in delete model - deleting the geometry... // SOLVED -- 43) Moving models don't always move.. I think this relates to the render optimization... // need to make sure we re-simulate when a model is moving... +// SOLVED -- 44) if velocity sends a model out of the domain - delete it