From 486cdf14d2a71824b079af5ba0b427787b373a91 Mon Sep 17 00:00:00 2001 From: Dante Ruiz Date: Mon, 4 Dec 2017 15:34:53 -0800 Subject: [PATCH] make sure that NO_BOOTSTRAPPING is disbaled correctly if parent is changed --- libraries/entities/src/EntityItem.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 29b104b421..82e364486b 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1605,6 +1605,25 @@ void EntityItem::setParentID(const QUuid& value) { if (tree && !oldParentID.isNull()) { tree->removeFromChildrenOfAvatars(getThisPointer()); } + + bool enableNoBootStrapping = false; + if (!value.isNull() && tree) { + EntityItemPointer entity = tree->findEntityByEntityItemID(value); + if (entity) { + enableNoBootStrapping = (bool)(entity->getDirtyFlags() & Simulation::NO_BOOTSTRAPPING); + } + } + + enableNoBootStrapping ? markDirtyFlags(Simulation::NO_BOOTSTRAPPING) : clearDirtyFlags(Simulation::NO_BOOTSTRAPPING); + forEachDescendant([&](SpatiallyNestablePointer object) { + if (object->getNestableType() == NestableType::Entity) { + EntityItemPointer entity = std::static_pointer_cast(object); + entity->markDirtyFlags(Simulation::DIRTY_COLLISION_GROUP); + enableNoBootStrapping ? entity->markDirtyFlags(Simulation::NO_BOOTSTRAPPING) : + entity->clearDirtyFlags(Simulation::NO_BOOTSTRAPPING); + } + }); + SpatiallyNestable::setParentID(value); // children are forced to be kinematic // may need to not collide with own avatar