fix crash bug when invalid entity ptr accessed

This commit is contained in:
Andrew Meadows 2015-05-07 10:30:22 -07:00
parent fe5cfdf495
commit 070140440d
2 changed files with 4 additions and 2 deletions

View file

@ -79,6 +79,8 @@ void EntityMotionState::handleHardAndEasyChanges(uint32_t flags, PhysicsEngine*
void EntityMotionState::clearEntity() { void EntityMotionState::clearEntity() {
_entity = nullptr; _entity = nullptr;
// set the type to INVALID so that external logic that pivots on the type won't try to access _entity
_type = MOTION_STATE_TYPE_INVALID;
} }
MotionType EntityMotionState::computeObjectMotionType() const { MotionType EntityMotionState::computeObjectMotionType() const {

View file

@ -27,7 +27,7 @@ enum MotionType {
}; };
enum MotionStateType { enum MotionStateType {
MOTION_STATE_TYPE_UNKNOWN, MOTION_STATE_TYPE_INVALID,
MOTION_STATE_TYPE_ENTITY, MOTION_STATE_TYPE_ENTITY,
MOTION_STATE_TYPE_AVATAR MOTION_STATE_TYPE_AVATAR
}; };
@ -125,7 +125,7 @@ protected:
virtual void setMotionType(MotionType motionType); virtual void setMotionType(MotionType motionType);
void setRigidBody(btRigidBody* body); void setRigidBody(btRigidBody* body);
MotionStateType _type = MOTION_STATE_TYPE_UNKNOWN; // type of MotionState MotionStateType _type = MOTION_STATE_TYPE_INVALID; // type of MotionState
MotionType _motionType; // type of motion: KINEMATIC, DYNAMIC, or STATIC MotionType _motionType; // type of motion: KINEMATIC, DYNAMIC, or STATIC
btCollisionShape* _shape; btCollisionShape* _shape;