Use not scaled player half extents as default to find path

pull/541/head
elsid 6 years ago
parent 1218e4e15d
commit 43b39e8418
No known key found for this signature in database
GPG Key ID: B845CB9FEE18AB40

@ -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);

@ -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.

@ -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);

@ -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;

@ -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);
}

@ -111,6 +111,8 @@ namespace MWWorld
std::string mUserDataPath;
osg::Vec3f mDefaultHalfExtents;
// not implemented
World (const World&);
World& operator= (const World&);

Loading…
Cancel
Save