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

View file

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