declare EntitySimulation::getEntitiesToDelete()

This commit is contained in:
Andrew Meadows 2015-04-29 16:26:46 -07:00
parent 31ab16ac62
commit 9c5f51917a
2 changed files with 8 additions and 5 deletions

View file

@ -160,15 +160,15 @@ void EntitySimulation::removeEntity(EntityItem* entity) {
_entitiesToUpdate.remove(entity); _entitiesToUpdate.remove(entity);
_mortalEntities.remove(entity); _mortalEntities.remove(entity);
_entitiesToSort.remove(entity); _entitiesToSort.remove(entity);
if (entity->_tree) { if (entity->_element) {
// the tree still references this entity, but it's being removed from this simulation // some EntityTreeElement still references this entity, but it's being removed from this simulation
_entitiesToDelete.remove(entity); _entitiesToDelete.remove(entity);
removeEntityInternal(entity); removeEntityInternal(entity);
} else { } else {
// we're the last to reference this entity, so we really need to delete it // we're the last to reference this entity, so we really need to delete it
deleteEntityInternal(entity); deleteEntityInternal(entity);
} }
} else if (!entity->_tree) { } else if (!entity->_element) {
// nothing else is referencing this entity, so we delete it now // nothing else is referencing this entity, so we delete it now
delete entity; delete entity;
} }
@ -182,8 +182,8 @@ void EntitySimulation::deleteEntity(EntityItem* entity) {
_entitiesToSort.remove(entity); _entitiesToSort.remove(entity);
deleteEntityInternal(entity); deleteEntityInternal(entity);
} else { } else {
if (entity->_tree) { if (entity->_element) {
// the tree still references this entity, so we put it on the list // some EntityTreeElement still references this entity, so we put it on the list
// which will be harvested by the tree later // which will be harvested by the tree later
_entitiesToDelete.insert(entity); _entitiesToDelete.insert(entity);
} else { } else {
@ -246,3 +246,4 @@ void EntitySimulation::clearEntities() {
_entitiesToSort.clear(); _entitiesToSort.clear();
clearEntitiesInternal(); clearEntitiesInternal();
} }

View file

@ -70,6 +70,8 @@ public:
EntityTree* getEntityTree() { return _entityTree; } EntityTree* getEntityTree() { return _entityTree; }
void getEntitiesToDelete(SetOfEntities& entitiesToDelete);
signals: signals:
void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision); void entityCollisionWithEntity(const EntityItemID& idA, const EntityItemID& idB, const Collision& collision);