1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-04-01 12:36:42 +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,10 +37,12 @@ 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());
if(box != NULL){
btVector3 size = box->getHalfExtentsWithMargin(); btVector3 size = box->getHalfExtentsWithMargin();
Ogre::Vector3 halfExtents = Ogre::Vector3(size.getX(), size.getY(), size.getZ()); Ogre::Vector3 halfExtents = Ogre::Vector3(size.getX(), size.getY(), size.getZ());
pmove->ps.halfExtents = halfExtents; pmove->ps.halfExtents = halfExtents;
} }
}
PhysicActor::~PhysicActor() PhysicActor::~PhysicActor()
{ {
@ -147,10 +149,12 @@ 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());
if(box != NULL){
btVector3 size = box->getHalfExtentsWithMargin(); btVector3 size = box->getHalfExtentsWithMargin();
Ogre::Vector3 halfExtents = Ogre::Vector3(size.getX(), size.getY(), size.getZ()); Ogre::Vector3 halfExtents = Ogre::Vector3(size.getX(), size.getY(), size.getZ());
pmove->ps.halfExtents = halfExtents; pmove->ps.halfExtents = halfExtents;
} }
}
void PhysicActor::runPmove(){ void PhysicActor::runPmove(){
Pmove(pmove); Pmove(pmove);