From 426517b072322a0fc68d46a956e8224372a91f26 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 9 Dec 2014 17:11:01 -0800 Subject: [PATCH] fix a bug in MovingEntitiesOperator that would sometimes leave dangling entities --- libraries/entities/src/EntityItem.h | 3 --- libraries/entities/src/EntitySimulation.cpp | 1 - libraries/entities/src/EntityTree.cpp | 2 -- .../entities/src/MovingEntitiesOperator.cpp | 19 +------------------ .../entities/src/MovingEntitiesOperator.h | 2 -- 5 files changed, 1 insertion(+), 26 deletions(-) diff --git a/libraries/entities/src/EntityItem.h b/libraries/entities/src/EntityItem.h index 915440ee6a..d5a4689657 100644 --- a/libraries/entities/src/EntityItem.h +++ b/libraries/entities/src/EntityItem.h @@ -227,8 +227,6 @@ public: float getSize() const; /// get maximum dimension in domain scale units (0.0 - 1.0) AACube getMaximumAACube() const; AACube getMinimumAACube() const; - AACube getOldMaximumAACube() const { return _oldMaximumAACube; } - void setOldMaximumAACube(const AACube& cube) { _oldMaximumAACube = cube; } AABox getAABox() const; /// axis aligned bounding box in domain scale units (0.0 - 1.0) static const QString DEFAULT_SCRIPT; @@ -347,7 +345,6 @@ protected: void setRadius(float value); AACubeShape _collisionShape; - AACube _oldMaximumAACube; // remember this so we know where the entity used to live in the tree // DirtyFlags are set whenever a property changes that the EntitySimulation needs to know about. uint32_t _dirtyFlags; // things that have changed from EXTERNAL changes (via script or packet) but NOT from simulation diff --git a/libraries/entities/src/EntitySimulation.cpp b/libraries/entities/src/EntitySimulation.cpp index 223df588d5..6d3b81715d 100644 --- a/libraries/entities/src/EntitySimulation.cpp +++ b/libraries/entities/src/EntitySimulation.cpp @@ -106,7 +106,6 @@ void EntitySimulation::sortEntitiesThatMoved() { if (moveOperator.hasMovingEntities()) { PerformanceTimer perfTimer("recurseTreeWithOperator"); _entityTree->recurseTreeWithOperator(&moveOperator); - moveOperator.finish(); } } diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 48ea2b7c07..17178ccbed 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -83,7 +83,6 @@ EntityItem* EntityTree::getOrCreateEntityItem(const EntityItemID& entityID, cons /// Adds a new entity item to the tree void EntityTree::postAddEntity(EntityItem* entity) { assert(entity); - entity->setOldMaximumAACube(entity->getMaximumAACube()); // check to see if we need to simulate this entity.. if (_simulation) { _simulation->addEntity(entity); @@ -138,7 +137,6 @@ bool EntityTree::updateEntityWithElement(EntityItem* entity, const EntityItemPro UpdateEntityOperator theOperator(this, containingElement, entity, properties); recurseTreeWithOperator(&theOperator); - entity->setOldMaximumAACube(entity->getMaximumAACube()); _isDirty = true; if (_simulation && entity->getDirtyFlags() != 0) { diff --git a/libraries/entities/src/MovingEntitiesOperator.cpp b/libraries/entities/src/MovingEntitiesOperator.cpp index 86b8de7b10..1ec67967b6 100644 --- a/libraries/entities/src/MovingEntitiesOperator.cpp +++ b/libraries/entities/src/MovingEntitiesOperator.cpp @@ -52,14 +52,10 @@ MovingEntitiesOperator::~MovingEntitiesOperator() { void MovingEntitiesOperator::addEntityToMoveList(EntityItem* entity, const AACube& newCube) { EntityTreeElement* oldContainingElement = _tree->getContainingElement(entity->getEntityItemID()); AABox newCubeClamped = newCube.clamp(0.0f, 1.0f); - AACube oldCube = entity->getOldMaximumAACube(); - AABox oldCubeClamped = oldCube.clamp(0.0f, 1.0f); if (_wantDebug) { qDebug() << "MovingEntitiesOperator::addEntityToMoveList() -----------------------------"; - qDebug() << " oldCube:" << oldCube; qDebug() << " newCube:" << newCube; - qDebug() << " oldCubeClamped:" << oldCubeClamped; qDebug() << " newCubeClamped:" << newCubeClamped; if (oldContainingElement) { qDebug() << " oldContainingElement:" << oldContainingElement->getAACube(); @@ -86,9 +82,7 @@ void MovingEntitiesOperator::addEntityToMoveList(EntityItem* entity, const AACub details.entity = entity; details.oldFound = false; details.newFound = false; - details.oldCube = oldCube; details.newCube = newCube; - details.oldCubeClamped = oldCubeClamped; details.newCubeClamped = newCubeClamped; _entitiesToMove << details; _lookingCount++; @@ -97,7 +91,6 @@ void MovingEntitiesOperator::addEntityToMoveList(EntityItem* entity, const AACub qDebug() << "MovingEntitiesOperator::addEntityToMoveList() -----------------------------"; qDebug() << " details.entity:" << details.entity->getEntityItemID(); qDebug() << " details.oldContainingElementCube:" << details.oldContainingElementCube; - qDebug() << " details.oldCube:" << details.oldCube; qDebug() << " details.newCube:" << details.newCube; qDebug() << " details.newCubeClamped:" << details.newCubeClamped; qDebug() << " _lookingCount:" << _lookingCount; @@ -130,17 +123,14 @@ bool MovingEntitiesOperator::shouldRecurseSubTree(OctreeElement* element) { qDebug() << " element:" << element->getAACube(); qDebug() << " details.entity:" << details.entity->getEntityItemID(); qDebug() << " details.oldContainingElementCube:" << details.oldContainingElementCube; - qDebug() << " details.oldCube:" << details.oldCube; qDebug() << " details.newCube:" << details.newCube; qDebug() << " details.newCubeClamped:" << details.newCubeClamped; - qDebug() << " elementCube.contains(details.oldCube)" << elementCube.contains(details.oldCube); qDebug() << " elementCube.contains(details.newCube)" << elementCube.contains(details.newCube); - qDebug() << " elementCube.contains(details.oldCubeClamped)" << elementCube.contains(details.oldCubeClamped); qDebug() << " elementCube.contains(details.newCubeClamped)" << elementCube.contains(details.newCubeClamped); qDebug() << "--------------------------------------------------------------------------"; } - if (elementCube.contains(details.oldCubeClamped) || elementCube.contains(details.newCubeClamped)) { + if (elementCube.contains(details.oldContainingElementCube) || elementCube.contains(details.newCubeClamped)) { containsEntity = true; break; // if it contains at least one, we're good to go } @@ -179,7 +169,6 @@ bool MovingEntitiesOperator::preRecursion(OctreeElement* element) { qDebug() << " details.entity:" << details.entity->getEntityItemID(); qDebug() << " details.oldContainingElementCube:" << details.oldContainingElementCube; qDebug() << " entityTreeElement:" << entityTreeElement; - qDebug() << " details.oldCube:" << details.oldCube; qDebug() << " details.newCube:" << details.newCube; qDebug() << " details.newCubeClamped:" << details.newCubeClamped; qDebug() << " _lookingCount:" << _lookingCount; @@ -291,9 +280,3 @@ OctreeElement* MovingEntitiesOperator::possiblyCreateChildAt(OctreeElement* elem } return NULL; } - -void MovingEntitiesOperator::finish() { - foreach(const EntityToMoveDetails& details, _entitiesToMove) { - details.entity->setOldMaximumAACube(details.newCube); - } -} diff --git a/libraries/entities/src/MovingEntitiesOperator.h b/libraries/entities/src/MovingEntitiesOperator.h index bddf5da450..fefda3328e 100644 --- a/libraries/entities/src/MovingEntitiesOperator.h +++ b/libraries/entities/src/MovingEntitiesOperator.h @@ -17,7 +17,6 @@ public: EntityItem* entity; AACube oldCube; AACube newCube; - AABox oldCubeClamped; AABox newCubeClamped; EntityTreeElement* oldContainingElement; AACube oldContainingElementCube; @@ -43,7 +42,6 @@ public: virtual bool postRecursion(OctreeElement* element); virtual OctreeElement* possiblyCreateChildAt(OctreeElement* element, int childIndex); bool hasMovingEntities() const { return _entitiesToMove.size() > 0; } - void finish(); private: EntityTree* _tree; QSet _entitiesToMove;