diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 277a5280ae..ffea0b545a 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -331,6 +331,33 @@ bool UpdateEntityOperator::PreRecursion(OctreeElement* element) { // If this element is the best fit for the new entity properties, then add/or update it if (entityTreeElement->bestFitBounds(_newEntityCube)) { + + + /********* + // + // + // LOOK AT THIS NEXT... this is crashing... the old code was working.... but this is not... + // + // + // + + // if we are the existing containing element, then we can just do the update of the entity properties + if (entityTreeElement == _containingElement) { + assert(!_removeOld); // We shouldn't be in a remove old case and also be the new best fit + + // set the entity properties and mark our element as changed. + _existingEntity->setProperties(_properties); + entityTreeElement->markWithChangedTime(); + + } else { + // otherwise, this is an add case. + entityTreeElement->addEntityItem(_existingEntity); + _existingEntity->setProperties(_properties); // still need to update the properties! + entityTreeElement->markWithChangedTime(); + _tree->setContainingElement(_entityItemID, entityTreeElement); + } + *************/ + if (entityTreeElement->addOrUpdateEntity(_existingEntity, _properties)) { //qDebug() << "UpdateEntityOperator::PreRecursion()... entity was updated!"; diff --git a/libraries/entities/src/EntityTreeElement.cpp b/libraries/entities/src/EntityTreeElement.cpp index c6c0b85376..7fe6d99cf3 100644 --- a/libraries/entities/src/EntityTreeElement.cpp +++ b/libraries/entities/src/EntityTreeElement.cpp @@ -401,6 +401,9 @@ bool EntityTreeElement::findSpherePenetration(const glm::vec3& center, float rad // TODO... how do we handle older/newer with this interface? +// Look at getting rid of this, and moving this logic to Entity Tree +// AND/OR remove the O(n) lookup for the entity since we know it should already exist in this +// element list. bool EntityTreeElement::addOrUpdateEntity(EntityItem* entity, const EntityItemProperties& properties) { const bool wantDebug = false; if (wantDebug) {