mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:13:05 +02:00
dont do work if not needed
This commit is contained in:
parent
486cdf14d2
commit
c58286d371
1 changed files with 29 additions and 10 deletions
|
@ -1606,23 +1606,42 @@ void EntityItem::setParentID(const QUuid& value) {
|
||||||
tree->removeFromChildrenOfAvatars(getThisPointer());
|
tree->removeFromChildrenOfAvatars(getThisPointer());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool enableNoBootStrapping = false;
|
uint32_t oldParentNoBootstrapping = 0;
|
||||||
|
uint32_t newParentNoBootstrapping = 0;
|
||||||
if (!value.isNull() && tree) {
|
if (!value.isNull() && tree) {
|
||||||
EntityItemPointer entity = tree->findEntityByEntityItemID(value);
|
EntityItemPointer entity = tree->findEntityByEntityItemID(value);
|
||||||
if (entity) {
|
if (entity) {
|
||||||
enableNoBootStrapping = (bool)(entity->getDirtyFlags() & Simulation::NO_BOOTSTRAPPING);
|
newParentNoBootstrapping = entity->getDirtyFlags() & Simulation::NO_BOOTSTRAPPING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enableNoBootStrapping ? markDirtyFlags(Simulation::NO_BOOTSTRAPPING) : clearDirtyFlags(Simulation::NO_BOOTSTRAPPING);
|
if (!oldParentID.isNull() && tree) {
|
||||||
forEachDescendant([&](SpatiallyNestablePointer object) {
|
EntityItemPointer entity = tree->findEntityByEntityItemID(oldParentID);
|
||||||
if (object->getNestableType() == NestableType::Entity) {
|
if (entity) {
|
||||||
EntityItemPointer entity = std::static_pointer_cast<EntityItem>(object);
|
oldParentNoBootstrapping = entity->getDirtyFlags() & Simulation::NO_BOOTSTRAPPING;
|
||||||
entity->markDirtyFlags(Simulation::DIRTY_COLLISION_GROUP);
|
|
||||||
enableNoBootStrapping ? entity->markDirtyFlags(Simulation::NO_BOOTSTRAPPING) :
|
|
||||||
entity->clearDirtyFlags(Simulation::NO_BOOTSTRAPPING);
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
if ((bool)(oldParentNoBootstrapping ^ newParentNoBootstrapping)) {
|
||||||
|
if ((bool)(newParentNoBootstrapping & Simulation::NO_BOOTSTRAPPING)) {
|
||||||
|
markDirtyFlags(Simulation::NO_BOOTSTRAPPING);
|
||||||
|
forEachDescendant([&](SpatiallyNestablePointer object) {
|
||||||
|
if (object->getNestableType() == NestableType::Entity) {
|
||||||
|
EntityItemPointer entity = std::static_pointer_cast<EntityItem>(object);
|
||||||
|
entity->markDirtyFlags(Simulation::DIRTY_COLLISION_GROUP | Simulation::NO_BOOTSTRAPPING);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
clearDirtyFlags(Simulation::NO_BOOTSTRAPPING);
|
||||||
|
forEachDescendant([&](SpatiallyNestablePointer object) {
|
||||||
|
if (object->getNestableType() == NestableType::Entity) {
|
||||||
|
EntityItemPointer entity = std::static_pointer_cast<EntityItem>(object);
|
||||||
|
entity->markDirtyFlags(Simulation::DIRTY_COLLISION_GROUP);
|
||||||
|
entity->clearDirtyFlags(Simulation::NO_BOOTSTRAPPING);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SpatiallyNestable::setParentID(value);
|
SpatiallyNestable::setParentID(value);
|
||||||
// children are forced to be kinematic
|
// children are forced to be kinematic
|
||||||
|
|
Loading…
Reference in a new issue