diff --git a/apps/openmw/mwphysics/actor.cpp b/apps/openmw/mwphysics/actor.cpp index 632d32c26..0f8814aca 100644 --- a/apps/openmw/mwphysics/actor.cpp +++ b/apps/openmw/mwphysics/actor.cpp @@ -201,6 +201,11 @@ osg::Vec3f Actor::getHalfExtents() const return osg::componentMultiply(mHalfExtents, mScale); } +osg::Vec3f Actor::getOriginalHalfExtents() const +{ + return mHalfExtents; +} + osg::Vec3f Actor::getRenderingHalfExtents() const { return osg::componentMultiply(mHalfExtents, mRenderingScale); diff --git a/apps/openmw/mwphysics/actor.hpp b/apps/openmw/mwphysics/actor.hpp index 31dd22a22..8752f7fee 100644 --- a/apps/openmw/mwphysics/actor.hpp +++ b/apps/openmw/mwphysics/actor.hpp @@ -66,6 +66,11 @@ namespace MWPhysics */ osg::Vec3f getHalfExtents() const; + /** + * Returns the half extents of the collision body (not scaled) + */ + osg::Vec3f getOriginalHalfExtents() const; + /** * Returns the position of the collision body * @note The collision shape's origin is in its center, so the position returned can be described as center of the actor collision box in world space. diff --git a/apps/openmw/mwphysics/physicssystem.cpp b/apps/openmw/mwphysics/physicssystem.cpp index d12f7fe6c..e3884afad 100644 --- a/apps/openmw/mwphysics/physicssystem.cpp +++ b/apps/openmw/mwphysics/physicssystem.cpp @@ -906,6 +906,14 @@ namespace MWPhysics return osg::Vec3f(); } + osg::Vec3f PhysicsSystem::getOriginalHalfExtents(const MWWorld::ConstPtr &actor) const + { + if (const Actor* physactor = getActor(actor)) + return physactor->getOriginalHalfExtents(); + else + return osg::Vec3f(); + } + osg::Vec3f PhysicsSystem::getRenderingHalfExtents(const MWWorld::ConstPtr &actor) const { const Actor* physactor = getActor(actor); diff --git a/apps/openmw/mwphysics/physicssystem.hpp b/apps/openmw/mwphysics/physicssystem.hpp index 76fbcf8c6..364a59ab1 100644 --- a/apps/openmw/mwphysics/physicssystem.hpp +++ b/apps/openmw/mwphysics/physicssystem.hpp @@ -136,6 +136,9 @@ namespace MWPhysics /// Get physical half extents (scaled) of the given actor. osg::Vec3f getHalfExtents(const MWWorld::ConstPtr& actor) const; + /// Get physical half extents (not scaled) of the given actor. + osg::Vec3f getOriginalHalfExtents(const MWWorld::ConstPtr& actor) const; + /// @see MWPhysics::Actor::getRenderingHalfExtents osg::Vec3f getRenderingHalfExtents(const MWWorld::ConstPtr& actor) const; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index fa394cc10..eb401658e 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -2443,6 +2443,7 @@ namespace MWWorld applyLoopingParticles(player); + mDefaultHalfExtents = mPhysics->getOriginalHalfExtents(getPlayerPtr()); mNavigator->addAgent(getPathfindingHalfExtents(getPlayerConstPtr())); } @@ -3795,7 +3796,7 @@ namespace MWWorld osg::Vec3f World::getPathfindingHalfExtents(const MWWorld::ConstPtr& actor) const { if (actor.isInCell() && actor.getCell()->isExterior()) - return getHalfExtents(getPlayerConstPtr()); // Using player half extents for better performance + return mDefaultHalfExtents; // Using default half extents for better performance else return getHalfExtents(actor); } diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 71d6c5afd..f0c28ea9e 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -111,6 +111,8 @@ namespace MWWorld std::string mUserDataPath; + osg::Vec3f mDefaultHalfExtents; + // not implemented World (const World&); World& operator= (const World&);