mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-21 06:09:42 +00:00
Do not build path to next path point via navmesh
To void a situation when next path point continuously changing making actor go in circles. This is unnecessary but also creates problems since pathgrid is used to build path for AiWander.
This commit is contained in:
parent
8dd8961737
commit
fbeb3ab03a
3 changed files with 0 additions and 59 deletions
|
@ -314,13 +314,6 @@ namespace MWMechanics
|
|||
completeManualWalking(actor, storage);
|
||||
}
|
||||
|
||||
if (storage.mState == AiWanderStorage::Wander_Walking && mUsePathgrid)
|
||||
{
|
||||
const auto agentBounds = MWBase::Environment::get().getWorld()->getPathfindingAgentBounds(actor);
|
||||
mPathFinder.buildPathByNavMeshToNextPoint(
|
||||
actor, agentBounds, getNavigatorFlags(actor), getAreaCosts(actor));
|
||||
}
|
||||
|
||||
if (storage.mState == AiWanderStorage::Wander_MoveNow && storage.mCanWanderAlongPathGrid)
|
||||
{
|
||||
// Construct a new path if there isn't one
|
||||
|
|
|
@ -75,13 +75,6 @@ namespace
|
|||
return sqrDistance(osg::Vec2f(lhs.x(), lhs.y()), osg::Vec2f(rhs.x(), rhs.y()));
|
||||
}
|
||||
|
||||
float getPathStepSize(const MWWorld::ConstPtr& actor)
|
||||
{
|
||||
const auto world = MWBase::Environment::get().getWorld();
|
||||
const auto realHalfExtents = world->getHalfExtents(actor);
|
||||
return 2 * std::max(realHalfExtents.x(), realHalfExtents.y());
|
||||
}
|
||||
|
||||
float getHeight(const MWWorld::ConstPtr& actor)
|
||||
{
|
||||
const auto world = MWBase::Environment::get().getWorld();
|
||||
|
@ -457,47 +450,6 @@ namespace MWMechanics
|
|||
return status;
|
||||
}
|
||||
|
||||
void PathFinder::buildPathByNavMeshToNextPoint(const MWWorld::ConstPtr& actor,
|
||||
const DetourNavigator::AgentBounds& agentBounds, const DetourNavigator::Flags flags,
|
||||
const DetourNavigator::AreaCosts& areaCosts)
|
||||
{
|
||||
if (mPath.empty())
|
||||
return;
|
||||
|
||||
const auto stepSize = getPathStepSize(actor);
|
||||
const auto startPoint = actor.getRefData().getPosition().asVec3();
|
||||
|
||||
if (sqrDistanceIgnoreZ(mPath.front(), startPoint) <= 4 * stepSize * stepSize)
|
||||
return;
|
||||
|
||||
const auto navigator = MWBase::Environment::get().getWorld()->getNavigator();
|
||||
std::deque<osg::Vec3f> prePath;
|
||||
auto prePathInserter = std::back_inserter(prePath);
|
||||
const float endTolerance = 0;
|
||||
const auto status = DetourNavigator::findPath(
|
||||
*navigator, agentBounds, startPoint, mPath.front(), flags, areaCosts, endTolerance, prePathInserter);
|
||||
|
||||
if (status == DetourNavigator::Status::NavMeshNotFound)
|
||||
return;
|
||||
|
||||
if (status != DetourNavigator::Status::Success)
|
||||
{
|
||||
Log(Debug::Debug) << "Build path by navigator error: \"" << DetourNavigator::getMessage(status)
|
||||
<< "\" for \"" << actor.getClass().getName(actor) << "\" (" << actor.getBase()
|
||||
<< ") from " << startPoint << " to " << mPath.front() << " with flags ("
|
||||
<< DetourNavigator::WriteFlags{ flags } << ")";
|
||||
return;
|
||||
}
|
||||
|
||||
while (!prePath.empty() && sqrDistanceIgnoreZ(prePath.front(), startPoint) < stepSize * stepSize)
|
||||
prePath.pop_front();
|
||||
|
||||
while (!prePath.empty() && sqrDistanceIgnoreZ(prePath.back(), mPath.front()) < stepSize * stepSize)
|
||||
prePath.pop_back();
|
||||
|
||||
std::copy(prePath.rbegin(), prePath.rend(), std::front_inserter(mPath));
|
||||
}
|
||||
|
||||
void PathFinder::buildLimitedPath(const MWWorld::ConstPtr& actor, const osg::Vec3f& startPoint,
|
||||
const osg::Vec3f& endPoint, const MWWorld::CellStore* cell, const PathgridGraph& pathgridGraph,
|
||||
const DetourNavigator::AgentBounds& agentBounds, const DetourNavigator::Flags flags,
|
||||
|
|
|
@ -115,10 +115,6 @@ namespace MWMechanics
|
|||
const DetourNavigator::AgentBounds& agentBounds, const DetourNavigator::Flags flags,
|
||||
const DetourNavigator::AreaCosts& areaCosts, float endTolerance, PathType pathType);
|
||||
|
||||
void buildPathByNavMeshToNextPoint(const MWWorld::ConstPtr& actor,
|
||||
const DetourNavigator::AgentBounds& agentBounds, const DetourNavigator::Flags flags,
|
||||
const DetourNavigator::AreaCosts& areaCosts);
|
||||
|
||||
void buildLimitedPath(const MWWorld::ConstPtr& actor, const osg::Vec3f& startPoint, const osg::Vec3f& endPoint,
|
||||
const MWWorld::CellStore* cell, const PathgridGraph& pathgridGraph,
|
||||
const DetourNavigator::AgentBounds& agentBounds, const DetourNavigator::Flags flags,
|
||||
|
|
Loading…
Reference in a new issue