Merge pull request #3934 from ZappoMan/bugfixes

fix a bug in MovingEntitiesOperator that would sometimes leave dangling entities
This commit is contained in:
AndrewMeadows 2014-12-09 18:08:14 -08:00
commit 9aaaae6759
5 changed files with 1 additions and 26 deletions

View file

@ -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

View file

@ -106,7 +106,6 @@ void EntitySimulation::sortEntitiesThatMoved() {
if (moveOperator.hasMovingEntities()) {
PerformanceTimer perfTimer("recurseTreeWithOperator");
_entityTree->recurseTreeWithOperator(&moveOperator);
moveOperator.finish();
}
}

View file

@ -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) {

View file

@ -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);
}
}

View file

@ -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<EntityToMoveDetails> _entitiesToMove;