diff --git a/apps/openmw/mwphysics/actor.cpp b/apps/openmw/mwphysics/actor.cpp index 61022da28..9be34495e 100644 --- a/apps/openmw/mwphysics/actor.cpp +++ b/apps/openmw/mwphysics/actor.cpp @@ -47,7 +47,7 @@ Actor::Actor(const MWWorld::Ptr& ptr, osg::ref_ptr updateScale(); updatePosition(); - updateCollisionMask(); + addCollisionMask(getCollisionMask()); } Actor::~Actor() @@ -70,15 +70,26 @@ void Actor::enableCollisionBody(bool collision) } } +void Actor::addCollisionMask(int collisionMask) +{ + mCollisionWorld->addCollisionObject(mCollisionObject.get(), CollisionType_Actor, collisionMask); +} + void Actor::updateCollisionMask() { mCollisionWorld->removeCollisionObject(mCollisionObject.get()); + addCollisionMask(getCollisionMask()); +} + +int Actor::getCollisionMask() +{ int collisionMask = CollisionType_World | CollisionType_HeightMap; if (mExternalCollisionMode) collisionMask |= CollisionType_Actor | CollisionType_Projectile | CollisionType_Door; if (mCanWaterWalk) collisionMask |= CollisionType_Water; - mCollisionWorld->addCollisionObject(mCollisionObject.get(), CollisionType_Actor, collisionMask); + return collisionMask; + } void Actor::updatePosition() diff --git a/apps/openmw/mwphysics/actor.hpp b/apps/openmw/mwphysics/actor.hpp index b238547e1..a0bf5bfc0 100644 --- a/apps/openmw/mwphysics/actor.hpp +++ b/apps/openmw/mwphysics/actor.hpp @@ -139,6 +139,8 @@ namespace MWPhysics private: /// Removes then re-adds the collision object to the dynamics world void updateCollisionMask(); + void addCollisionMask(int collisionMask); + int getCollisionMask(); bool mCanWaterWalk; bool mWalkingOnWater; diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index 1a97fc6ff..f94ee14b6 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -1467,7 +1467,10 @@ namespace MWPhysics } if (!mWaterEnabled) + { + mWaterCollisionObject.reset(); return; + } mWaterCollisionObject.reset(new btCollisionObject()); mWaterCollisionShape.reset(new btStaticPlaneShape(btVector3(0,0,1), mWaterHeight));