mirror of
https://github.com/overte-org/overte.git
synced 2025-04-12 22:59:02 +02:00
all delete pass through EntitySimulation::prepareEntityForDelete()
This commit is contained in:
parent
03db88009f
commit
9557ba80c9
3 changed files with 15 additions and 16 deletions
|
@ -19,11 +19,11 @@
|
|||
|
||||
void EntitySimulation::setEntityTree(EntityTreePointer tree) {
|
||||
if (_entityTree && _entityTree != tree) {
|
||||
_mortalEntities.clear();
|
||||
_nextExpiry = std::numeric_limits<uint64_t>::max();
|
||||
_entitiesToUpdate.clear();
|
||||
_entitiesToSort.clear();
|
||||
_simpleKinematicEntities.clear();
|
||||
_entitiesToUpdate.clear();
|
||||
_mortalEntities.clear();
|
||||
_nextExpiry = std::numeric_limits<uint64_t>::max();
|
||||
}
|
||||
_entityTree = tree;
|
||||
}
|
||||
|
@ -49,11 +49,11 @@ void EntitySimulation::takeDeadEntities(SetOfEntities& entitiesToDelete) {
|
|||
|
||||
void EntitySimulation::removeEntityFromInternalLists(EntityItemPointer entity) {
|
||||
// remove from all internal lists except _deadEntities
|
||||
_mortalEntities.remove(entity);
|
||||
_entitiesToUpdate.remove(entity);
|
||||
_entitiesToSort.remove(entity);
|
||||
_simpleKinematicEntities.remove(entity);
|
||||
_allEntities.remove(entity);
|
||||
_entitiesToUpdate.remove(entity);
|
||||
_mortalEntities.remove(entity);
|
||||
entity->setSimulated(false);
|
||||
}
|
||||
|
||||
|
@ -218,11 +218,11 @@ void EntitySimulation::processChangedEntity(const EntityItemPointer& entity) {
|
|||
|
||||
void EntitySimulation::clearEntities() {
|
||||
QMutexLocker lock(&_mutex);
|
||||
_mortalEntities.clear();
|
||||
_nextExpiry = std::numeric_limits<uint64_t>::max();
|
||||
_entitiesToUpdate.clear();
|
||||
_entitiesToSort.clear();
|
||||
_simpleKinematicEntities.clear();
|
||||
_entitiesToUpdate.clear();
|
||||
_mortalEntities.clear();
|
||||
_nextExpiry = std::numeric_limits<uint64_t>::max();
|
||||
|
||||
clearEntitiesInternal();
|
||||
|
||||
|
|
|
@ -115,10 +115,9 @@ private:
|
|||
// An entity may be in more than one list.
|
||||
std::unordered_set<EntityItemPointer> _changedEntities; // all changes this frame
|
||||
SetOfEntities _allEntities; // tracks all entities added the simulation
|
||||
SetOfEntities _entitiesToUpdate; // entities that need to call EntityItem::update()
|
||||
SetOfEntities _mortalEntities; // entities that have an expiry
|
||||
uint64_t _nextExpiry;
|
||||
|
||||
SetOfEntities _entitiesToUpdate; // entities that need to call EntityItem::update()
|
||||
};
|
||||
|
||||
#endif // hifi_EntitySimulation_h
|
||||
|
|
|
@ -71,7 +71,8 @@ void PhysicalEntitySimulation::removeEntityFromInternalLists(EntityItemPointer e
|
|||
if (motionState) {
|
||||
removeOwnershipData(motionState);
|
||||
_entitiesToRemoveFromPhysics.insert(entity);
|
||||
} else if (entity->isDead() && entity->getElement()) {
|
||||
}
|
||||
if (entity->isDead() && entity->getElement()) {
|
||||
_deadEntities.insert(entity);
|
||||
}
|
||||
if (entity->isAvatarEntity()) {
|
||||
|
@ -215,7 +216,8 @@ void PhysicalEntitySimulation::clearEntitiesInternal() {
|
|||
|
||||
// virtual
|
||||
void PhysicalEntitySimulation::prepareEntityForDelete(EntityItemPointer entity) {
|
||||
// this can be called on any thread
|
||||
// DANGER! this can be called on any thread
|
||||
// do no dirty deeds here --> assemble list for later
|
||||
assert(entity);
|
||||
assert(entity->isDead());
|
||||
QMutexLocker lock(&_mutex);
|
||||
|
@ -223,13 +225,11 @@ void PhysicalEntitySimulation::prepareEntityForDelete(EntityItemPointer entity)
|
|||
}
|
||||
|
||||
void PhysicalEntitySimulation::removeDeadEntities() {
|
||||
// only ever call this on the main thread
|
||||
// DANGER! only ever call this on the main thread
|
||||
QMutexLocker lock(&_mutex);
|
||||
for (auto& entity : _entitiesToDeleteLater) {
|
||||
entity->clearActions(getThisPointer());
|
||||
if (entity->isSimulated()) {
|
||||
removeEntityFromInternalLists(entity);
|
||||
}
|
||||
EntitySimulation::prepareEntityForDelete(entity);
|
||||
}
|
||||
_entitiesToDeleteLater.clear();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue