be more careful about fixing up entities which arrived before their parents

This commit is contained in:
Seth Alves 2017-05-19 13:48:29 -07:00
parent 936d0e2d50
commit 5c93dbd20d
4 changed files with 6 additions and 19 deletions

View file

@ -27,10 +27,6 @@ AddEntityOperator::AddEntityOperator(EntityTreePointer tree, EntityItemPointer n
bool success;
auto queryCube = _newEntity->getQueryAACube(success);
if (!success) {
_newEntity->markAncestorMissing(true);
}
_newEntityBox = queryCube.clamp((float)(-HALF_TREE_SCALE), (float)HALF_TREE_SCALE);
}

View file

@ -1373,11 +1373,9 @@ bool EntityItem::setProperties(const EntityItemProperties& properties) {
if (saveQueryAACube != _queryAACube) {
somethingChanged = true;
}
} else {
markAncestorMissing(true);
}
// Now check the sub classes
// Now check the sub classes
somethingChanged |= setSubClassProperties(properties);
// Finally notify if change detected

View file

@ -295,7 +295,7 @@ bool EntityTree::updateEntityWithElement(EntityItemPointer entity, const EntityI
_missingParent.append(childEntity);
continue;
}
if (!childEntity->isParentIDValid()) {
if (!childEntity->getParentID().isNull()) {
QWriteLocker locker(&_missingParentLock);
_missingParent.append(childEntity);
}
@ -383,9 +383,7 @@ EntityItemPointer EntityTree::addEntity(const EntityItemID& entityID, const Enti
// Recurse the tree and store the entity in the correct tree element
AddEntityOperator theOperator(getThisPointer(), result);
recurseTreeWithOperator(&theOperator);
if (result->getAncestorMissing()) {
// we added the entity, but didn't know about all its ancestors, so it went into the wrong place.
// add it to a list of entities needing to be fixed once their parents are known.
if (!result->getParentID().isNull()) {
QWriteLocker locker(&_missingParentLock);
_missingParent.append(result);
}
@ -1221,11 +1219,11 @@ void EntityTree::fixupMissingParents() {
// entity was deleted before we found its parent
iter.remove();
}
bool queryAACubeSuccess;
bool queryAACubeSuccess { false };
bool maxAACubeSuccess { false };
AACube newCube = entity->getQueryAACube(queryAACubeSuccess);
if (queryAACubeSuccess) {
// make sure queryAACube encompasses maxAACube
bool maxAACubeSuccess;
AACube maxAACube = entity->getMaximumAACube(maxAACubeSuccess);
if (maxAACubeSuccess && !newCube.contains(maxAACube)) {
newCube = maxAACube;
@ -1233,7 +1231,7 @@ void EntityTree::fixupMissingParents() {
}
bool doMove = false;
if (entity->isParentIDValid()) {
if (entity->isParentIDValid() && maxAACubeSuccess) { // maxAACubeSuccess of true means all ancestors are known
iter.remove(); // this entity is all hooked up; we can remove it from the list
// this entity's parent was previously not known, and now is. Update its location in the EntityTree...
doMove = true;
@ -1266,7 +1264,6 @@ void EntityTree::fixupMissingParents() {
if (queryAACubeSuccess && doMove) {
moveOperator.addEntityToMoveList(entity, newCube);
entity->markAncestorMissing(false);
}
}

View file

@ -158,9 +158,6 @@ public:
SpatiallyNestablePointer getThisPointer() const;
void markAncestorMissing(bool value) { _missingAncestor = value; }
bool getAncestorMissing() { return _missingAncestor; }
void forEachChild(std::function<void(SpatiallyNestablePointer)> actor);
void forEachDescendant(std::function<void(SpatiallyNestablePointer)> actor);
@ -207,7 +204,6 @@ protected:
mutable AACube _queryAACube;
mutable bool _queryAACubeSet { false };
bool _missingAncestor { false };
quint64 _scaleChanged { 0 };
quint64 _translationChanged { 0 };
quint64 _rotationChanged { 0 };