mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 07:43:35 +02:00
more dtor cleanup of back pointers
This commit is contained in:
parent
9950c5b209
commit
828c365b25
2 changed files with 9 additions and 2 deletions
|
@ -10,6 +10,8 @@
|
|||
//
|
||||
|
||||
#include "PhysicsEntity.h"
|
||||
|
||||
#include "PhysicsSimulation.h"
|
||||
#include "Shape.h"
|
||||
#include "ShapeCollider.h"
|
||||
|
||||
|
@ -23,8 +25,10 @@ PhysicsEntity::PhysicsEntity() :
|
|||
}
|
||||
|
||||
PhysicsEntity::~PhysicsEntity() {
|
||||
// entity should be removed from the simulation before it is deleted
|
||||
assert(_simulation == NULL);
|
||||
if (_simulation) {
|
||||
_simulation->removeEntity(this);
|
||||
_simulation = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void PhysicsEntity::setTranslation(const glm::vec3& translation) {
|
||||
|
|
|
@ -31,11 +31,14 @@ PhysicsSimulation::PhysicsSimulation() : _collisionList(MAX_COLLISIONS_PER_SIMUL
|
|||
}
|
||||
|
||||
PhysicsSimulation::~PhysicsSimulation() {
|
||||
// entities have a backpointer to this simulator that must be cleaned up
|
||||
int numEntities = _entities.size();
|
||||
for (int i = 0; i < numEntities; ++i) {
|
||||
_entities[i]->_simulation = NULL;
|
||||
}
|
||||
_entities.clear();
|
||||
|
||||
// but Ragdolls do not
|
||||
_dolls.clear();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue