mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 09:08:47 +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 "PhysicsEntity.h"
|
||||||
|
|
||||||
|
#include "PhysicsSimulation.h"
|
||||||
#include "Shape.h"
|
#include "Shape.h"
|
||||||
#include "ShapeCollider.h"
|
#include "ShapeCollider.h"
|
||||||
|
|
||||||
|
@ -23,8 +25,10 @@ PhysicsEntity::PhysicsEntity() :
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicsEntity::~PhysicsEntity() {
|
PhysicsEntity::~PhysicsEntity() {
|
||||||
// entity should be removed from the simulation before it is deleted
|
if (_simulation) {
|
||||||
assert(_simulation == NULL);
|
_simulation->removeEntity(this);
|
||||||
|
_simulation = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsEntity::setTranslation(const glm::vec3& translation) {
|
void PhysicsEntity::setTranslation(const glm::vec3& translation) {
|
||||||
|
|
|
@ -31,11 +31,14 @@ PhysicsSimulation::PhysicsSimulation() : _collisionList(MAX_COLLISIONS_PER_SIMUL
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicsSimulation::~PhysicsSimulation() {
|
PhysicsSimulation::~PhysicsSimulation() {
|
||||||
|
// entities have a backpointer to this simulator that must be cleaned up
|
||||||
int numEntities = _entities.size();
|
int numEntities = _entities.size();
|
||||||
for (int i = 0; i < numEntities; ++i) {
|
for (int i = 0; i < numEntities; ++i) {
|
||||||
_entities[i]->_simulation = NULL;
|
_entities[i]->_simulation = NULL;
|
||||||
}
|
}
|
||||||
_entities.clear();
|
_entities.clear();
|
||||||
|
|
||||||
|
// but Ragdolls do not
|
||||||
_dolls.clear();
|
_dolls.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue