add asserts to catch dangling pointers sooner

This commit is contained in:
Andrew Meadows 2017-05-25 14:29:14 -07:00
parent c22e4ef883
commit 971855e6bf
2 changed files with 4 additions and 0 deletions

View file

@ -114,6 +114,7 @@ void EntityMotionState::handleDeactivation() {
// virtual // virtual
void EntityMotionState::handleEasyChanges(uint32_t& flags) { void EntityMotionState::handleEasyChanges(uint32_t& flags) {
assert(_entity);
assert(entityTreeIsLocked()); assert(entityTreeIsLocked());
updateServerPhysicsVariables(); updateServerPhysicsVariables();
ObjectMotionState::handleEasyChanges(flags); ObjectMotionState::handleEasyChanges(flags);
@ -170,6 +171,7 @@ void EntityMotionState::handleEasyChanges(uint32_t& flags) {
// virtual // virtual
bool EntityMotionState::handleHardAndEasyChanges(uint32_t& flags, PhysicsEngine* engine) { bool EntityMotionState::handleHardAndEasyChanges(uint32_t& flags, PhysicsEngine* engine) {
assert(_entity);
updateServerPhysicsVariables(); updateServerPhysicsVariables();
return ObjectMotionState::handleHardAndEasyChanges(flags, engine); return ObjectMotionState::handleHardAndEasyChanges(flags, engine);
} }

View file

@ -202,6 +202,7 @@ void ObjectMotionState::setShape(const btCollisionShape* shape) {
} }
void ObjectMotionState::handleEasyChanges(uint32_t& flags) { void ObjectMotionState::handleEasyChanges(uint32_t& flags) {
assert(_body && _shape);
if (flags & Simulation::DIRTY_POSITION) { if (flags & Simulation::DIRTY_POSITION) {
btTransform worldTrans = _body->getWorldTransform(); btTransform worldTrans = _body->getWorldTransform();
btVector3 newPosition = glmToBullet(getObjectPosition()); btVector3 newPosition = glmToBullet(getObjectPosition());
@ -282,6 +283,7 @@ void ObjectMotionState::handleEasyChanges(uint32_t& flags) {
} }
bool ObjectMotionState::handleHardAndEasyChanges(uint32_t& flags, PhysicsEngine* engine) { bool ObjectMotionState::handleHardAndEasyChanges(uint32_t& flags, PhysicsEngine* engine) {
assert(_body && _shape);
if (flags & Simulation::DIRTY_SHAPE) { if (flags & Simulation::DIRTY_SHAPE) {
// make sure the new shape is valid // make sure the new shape is valid
if (!isReadyToComputeShape()) { if (!isReadyToComputeShape()) {