mirror of
https://github.com/lubosz/overte.git
synced 2025-04-07 04:42:49 +02:00
remove cruft, add comments, change variable name
This commit is contained in:
parent
8ab70225d9
commit
052a0c3ebe
5 changed files with 17 additions and 36 deletions
|
@ -549,28 +549,6 @@ void AvatarManager::removeDeadAvatarEntities(const SetOfEntities& deadEntities)
|
|||
}
|
||||
}
|
||||
|
||||
/* ADEBUG: I don't think the code below is necessary because any dead entities will have already been removed from tree and simulation
|
||||
if (entityTree && entity->isMyAvatarEntity()) {
|
||||
entityTree->withWriteLock([&] {
|
||||
// We only need to delete the direct children (rather than the descendants) because
|
||||
// when the child is deleted, it will take care of its own children. If the child
|
||||
// is also an avatar-entity, we'll end up back here. If it's not, the entity-server
|
||||
// will take care of it in the usual way.
|
||||
entity->forEachChild([&](SpatiallyNestablePointer child) {
|
||||
EntityItemPointer childEntity = std::dynamic_pointer_cast<EntityItem>(child);
|
||||
if (childEntity) {
|
||||
entityTree->deleteEntity(childEntity->getID(), true, true);
|
||||
if (avatar) {
|
||||
avatar->clearAvatarEntity(childEntity->getID(), REQUIRES_REMOVAL_FROM_TREE);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void AvatarManager::handleRemovedAvatar(const AvatarSharedPointer& removedAvatar, KillAvatarReason removalReason) {
|
||||
auto avatar = std::static_pointer_cast<OtherAvatar>(removedAvatar);
|
||||
AvatarHashMap::handleRemovedAvatar(avatar, removalReason);
|
||||
|
|
|
@ -43,7 +43,7 @@ void EntitySimulation::updateEntities() {
|
|||
}
|
||||
|
||||
void EntitySimulation::removeEntityFromInternalLists(EntityItemPointer entity) {
|
||||
// remove from all internal lists except _deadEntities
|
||||
// remove from all internal lists except _deadEntitiesToRemoveFromTree
|
||||
_entitiesToSort.remove(entity);
|
||||
_simpleKinematicEntities.remove(entity);
|
||||
_allEntities.remove(entity);
|
||||
|
@ -59,7 +59,7 @@ void EntitySimulation::prepareEntityForDelete(EntityItemPointer entity) {
|
|||
QMutexLocker lock(&_mutex);
|
||||
removeEntityFromInternalLists(entity);
|
||||
if (entity->getElement()) {
|
||||
_deadEntities.insert(entity);
|
||||
_deadEntitiesToRemoveFromTree.insert(entity);
|
||||
_entityTree->cleanupCloneIDs(entity->getEntityItemID());
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ void EntitySimulation::clearEntities() {
|
|||
_simpleKinematicEntities.clear();
|
||||
_changedEntities.clear();
|
||||
_allEntities.clear();
|
||||
_deadEntities.clear();
|
||||
_deadEntitiesToRemoveFromTree.clear();
|
||||
_entitiesToUpdate.clear();
|
||||
_mortalEntities.clear();
|
||||
_nextExpiry = std::numeric_limits<uint64_t>::max();
|
||||
|
@ -257,18 +257,21 @@ void EntitySimulation::moveSimpleKinematics(uint64_t now) {
|
|||
}
|
||||
|
||||
void EntitySimulation::processDeadEntities() {
|
||||
if (_deadEntities.empty()) {
|
||||
if (_deadEntitiesToRemoveFromTree.empty()) {
|
||||
return;
|
||||
}
|
||||
SetOfEntities entitiesToDeleteImmediately;
|
||||
SetOfEntities dummyList; // ignore this list: it will be empty
|
||||
foreach (auto entity, _deadEntities) {
|
||||
QUuid nullSessionID;
|
||||
// NOTE: dummyList will be empty because this base-class implementation is only used server-side
|
||||
// for which ATM we only process domain-entities, and since we are passing nullSessionID for authorization
|
||||
// EntityItem::collectChildrenForDelete() will not collect domain-entities into this side list.
|
||||
SetOfEntities dummyList;
|
||||
QUuid nullSessionID;
|
||||
foreach (auto entity, _deadEntitiesToRemoveFromTree) {
|
||||
entitiesToDeleteImmediately.insert(entity);
|
||||
entity->collectChildrenForDelete(entitiesToDeleteImmediately, dummyList, nullSessionID);
|
||||
}
|
||||
if (_entityTree) {
|
||||
_entityTree->deleteEntitiesByPointer(entitiesToDeleteImmediately);
|
||||
}
|
||||
_deadEntities.clear();
|
||||
_deadEntitiesToRemoveFromTree.clear();
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ protected:
|
|||
|
||||
SetOfEntities _entitiesToSort; // entities moved by simulation (and might need resort in EntityTree)
|
||||
SetOfEntities _simpleKinematicEntities; // entities undergoing non-colliding kinematic motion
|
||||
SetOfEntities _deadEntities; // dead entities that might still be in the _entityTree
|
||||
SetOfEntities _deadEntitiesToRemoveFromTree;
|
||||
|
||||
private:
|
||||
void moveSimpleKinematics();
|
||||
|
|
|
@ -69,7 +69,7 @@ void PhysicalEntitySimulation::removeEntityFromInternalLists(EntityItemPointer e
|
|||
_entitiesToRemoveFromPhysics.insert(entity);
|
||||
}
|
||||
if (entity->isDead() && entity->getElement()) {
|
||||
_deadEntities.insert(entity);
|
||||
_deadEntitiesToRemoveFromTree.insert(entity);
|
||||
}
|
||||
if (entity->isAvatarEntity()) {
|
||||
_deadAvatarEntities.insert(entity);
|
||||
|
@ -171,7 +171,7 @@ void PhysicalEntitySimulation::processChangedEntity(const EntityItemPointer& ent
|
|||
}
|
||||
|
||||
void PhysicalEntitySimulation::processDeadEntities() {
|
||||
if (_deadEntities.empty()) {
|
||||
if (_deadEntitiesToRemoveFromTree.empty()) {
|
||||
return;
|
||||
}
|
||||
PROFILE_RANGE(simulation_physics, "Deletes");
|
||||
|
@ -179,7 +179,7 @@ void PhysicalEntitySimulation::processDeadEntities() {
|
|||
SetOfEntities domainEntities;
|
||||
QUuid sessionID = Physics::getSessionUUID();
|
||||
QMutexLocker lock(&_mutex);
|
||||
for (auto entity : _deadEntities) {
|
||||
for (auto entity : _deadEntitiesToRemoveFromTree) {
|
||||
EntityMotionState* motionState = static_cast<EntityMotionState*>(entity->getPhysicsInfo());
|
||||
if (motionState) {
|
||||
_entitiesToRemoveFromPhysics.insert(entity);
|
||||
|
@ -191,7 +191,7 @@ void PhysicalEntitySimulation::processDeadEntities() {
|
|||
entity->collectChildrenForDelete(entitiesToDeleteImmediately, domainEntities, sessionID);
|
||||
}
|
||||
}
|
||||
_deadEntities.clear();
|
||||
_deadEntitiesToRemoveFromTree.clear();
|
||||
|
||||
// interface-client can't delete domainEntities outright, they must roundtrip through the entity-server
|
||||
for (auto entity : domainEntities) {
|
||||
|
|
|
@ -124,7 +124,7 @@ private:
|
|||
|
||||
VectorOfEntityMotionStates _owned;
|
||||
VectorOfEntityMotionStates _bids;
|
||||
SetOfEntities _deadAvatarEntities;
|
||||
SetOfEntities _deadAvatarEntities; // to remove from Avatar's lists
|
||||
std::vector<EntityItemPointer> _entitiesToDeleteLater;
|
||||
|
||||
QList<EntityDynamicPointer> _dynamicsToAdd;
|
||||
|
|
Loading…
Reference in a new issue