1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-14 06:40:40 +00:00

protection for null cast

This commit is contained in:
Jason Hooks 2012-09-16 17:48:18 -04:00
parent 0fa1dea6c1
commit 05687c120f

View File

@ -37,9 +37,11 @@ namespace Physic
pmove = new playerMove; pmove = new playerMove;
pmove->mEngine = mEngine; pmove->mEngine = mEngine;
btBoxShape* box = static_cast<btBoxShape*> (mBody->getCollisionShape()); btBoxShape* box = static_cast<btBoxShape*> (mBody->getCollisionShape());
btVector3 size = box->getHalfExtentsWithMargin(); if(box != NULL){
Ogre::Vector3 halfExtents = Ogre::Vector3(size.getX(), size.getY(), size.getZ()); btVector3 size = box->getHalfExtentsWithMargin();
pmove->ps.halfExtents = halfExtents; Ogre::Vector3 halfExtents = Ogre::Vector3(size.getX(), size.getY(), size.getZ());
pmove->ps.halfExtents = halfExtents;
}
} }
PhysicActor::~PhysicActor() PhysicActor::~PhysicActor()
@ -147,9 +149,11 @@ namespace Physic
mBody = mEngine->createAndAdjustRigidBody(mMesh, mName, scale, position, rotation); mBody = mEngine->createAndAdjustRigidBody(mMesh, mName, scale, position, rotation);
mEngine->addRigidBody(mBody, false); //Add rigid body to dynamics world, but do not add to object map mEngine->addRigidBody(mBody, false); //Add rigid body to dynamics world, but do not add to object map
btBoxShape* box = static_cast<btBoxShape*> (mBody->getCollisionShape()); btBoxShape* box = static_cast<btBoxShape*> (mBody->getCollisionShape());
btVector3 size = box->getHalfExtentsWithMargin(); if(box != NULL){
Ogre::Vector3 halfExtents = Ogre::Vector3(size.getX(), size.getY(), size.getZ()); btVector3 size = box->getHalfExtentsWithMargin();
pmove->ps.halfExtents = halfExtents; Ogre::Vector3 halfExtents = Ogre::Vector3(size.getX(), size.getY(), size.getZ());
pmove->ps.halfExtents = halfExtents;
}
} }
void PhysicActor::runPmove(){ void PhysicActor::runPmove(){