diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index b98a863ae2..27c1dc851c 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -191,8 +191,7 @@ Ogre::Vector3 CharacterController::update(float duration) Ogre::Quaternion(Ogre::Radian(-refpos.rot[2]), Ogre::Vector3::UNIT_Z)) * movement; - // FIXME: Get the actual radius for the object. Maybe this should go into mwworld to replace pmove? - Ogre::Vector3 res = mMovementSolver->move(mPtr, movement, duration, Ogre::Vector3(15,15,30)); + Ogre::Vector3 res = mMovementSolver->move(mPtr, movement, duration); MWBase::Environment::get().getWorld()->moveObject(mPtr, res.x, res.y, res.z); } diff --git a/apps/openmw/mwmechanics/movementsolver.cpp b/apps/openmw/mwmechanics/movementsolver.cpp index 4a7a59cb31..f17671a61b 100644 --- a/apps/openmw/mwmechanics/movementsolver.cpp +++ b/apps/openmw/mwmechanics/movementsolver.cpp @@ -76,7 +76,7 @@ float MovementSolver::getSlope(const Ogre::Vector3 &normal) } -Ogre::Vector3 MovementSolver::move(const MWWorld::Ptr &ptr, const Ogre::Vector3 &movement, float time, const Ogre::Vector3 &halfExtents) +Ogre::Vector3 MovementSolver::move(const MWWorld::Ptr &ptr, const Ogre::Vector3 &movement, float time) { Ogre::Vector3 position(ptr.getRefData().getPosition().pos); @@ -96,6 +96,7 @@ Ogre::Vector3 MovementSolver::move(const MWWorld::Ptr &ptr, const Ogre::Vector3 float remainingTime = time; bool isInterior = !ptr.getCell()->isExterior(); float verticalRotation = mPhysicActor->getRotation().getYaw().valueDegrees(); + Ogre::Vector3 halfExtents = mPhysicActor->getHalfExtents(); Ogre::Vector3 lastNormal(0.0f); Ogre::Vector3 currentNormal(0.0f); diff --git a/apps/openmw/mwmechanics/movementsolver.hpp b/apps/openmw/mwmechanics/movementsolver.hpp index 450bc055ed..a8b9bf1442 100644 --- a/apps/openmw/mwmechanics/movementsolver.hpp +++ b/apps/openmw/mwmechanics/movementsolver.hpp @@ -25,7 +25,7 @@ namespace MWMechanics MovementSolver(); virtual ~MovementSolver(); - Ogre::Vector3 move(const MWWorld::Ptr &ptr, const Ogre::Vector3 &movement, float time, const Ogre::Vector3 &halfExtents); + Ogre::Vector3 move(const MWWorld::Ptr &ptr, const Ogre::Vector3 &movement, float time); private: bool stepMove(Ogre::Vector3& position, const Ogre::Vector3 &velocity, float remainingTime, float verticalRotation, const Ogre::Vector3 &halfExtents, bool isInterior); diff --git a/libs/openengine/bullet/physic.cpp b/libs/openengine/bullet/physic.cpp index b39ba53a22..7f0f6e2f90 100644 --- a/libs/openengine/bullet/physic.cpp +++ b/libs/openengine/bullet/physic.cpp @@ -156,6 +156,20 @@ namespace Physic } } + Ogre::Vector3 PhysicActor::getHalfExtents() const + { + if(mBody) + { + btBoxShape *box = static_cast(mBody->getCollisionShape()); + if(box != NULL) + { + btVector3 size = box->getHalfExtentsWithMargin(); + return Ogre::Vector3(size.getX(), size.getY(), size.getZ()); + } + } + return Ogre::Vector3(0.0f); + } + void PhysicActor::runPmove(){ Pmove(pmove); Ogre::Vector3 newpos = pmove->ps.origin; diff --git a/libs/openengine/bullet/physic.hpp b/libs/openengine/bullet/physic.hpp index 76bdb491d9..d98625c0ae 100644 --- a/libs/openengine/bullet/physic.hpp +++ b/libs/openengine/bullet/physic.hpp @@ -117,6 +117,11 @@ namespace Physic */ void setScale(float scale); + /** + * Returns the half extents for this PhysiActor + */ + Ogre::Vector3 getHalfExtents() const; + /** * Runs pmove for this PhysicActor */