mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-09 21:44:54 +00:00
Merge branch 'rm_path_to_next_path_point' into 'master'
Do not build path to next path point via navmesh See merge request OpenMW/openmw!3306
This commit is contained in:
commit
4aafcf5fdc
@ -314,13 +314,6 @@ namespace MWMechanics
|
|||||||
completeManualWalking(actor, storage);
|
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)
|
if (storage.mState == AiWanderStorage::Wander_MoveNow && storage.mCanWanderAlongPathGrid)
|
||||||
{
|
{
|
||||||
// Construct a new path if there isn't one
|
// 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()));
|
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)
|
float getHeight(const MWWorld::ConstPtr& actor)
|
||||||
{
|
{
|
||||||
const auto world = MWBase::Environment::get().getWorld();
|
const auto world = MWBase::Environment::get().getWorld();
|
||||||
@ -457,47 +450,6 @@ namespace MWMechanics
|
|||||||
return status;
|
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,
|
void PathFinder::buildLimitedPath(const MWWorld::ConstPtr& actor, const osg::Vec3f& startPoint,
|
||||||
const osg::Vec3f& endPoint, const MWWorld::CellStore* cell, const PathgridGraph& pathgridGraph,
|
const osg::Vec3f& endPoint, const MWWorld::CellStore* cell, const PathgridGraph& pathgridGraph,
|
||||||
const DetourNavigator::AgentBounds& agentBounds, const DetourNavigator::Flags flags,
|
const DetourNavigator::AgentBounds& agentBounds, const DetourNavigator::Flags flags,
|
||||||
|
@ -115,10 +115,6 @@ namespace MWMechanics
|
|||||||
const DetourNavigator::AgentBounds& agentBounds, const DetourNavigator::Flags flags,
|
const DetourNavigator::AgentBounds& agentBounds, const DetourNavigator::Flags flags,
|
||||||
const DetourNavigator::AreaCosts& areaCosts, float endTolerance, PathType pathType);
|
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,
|
void buildLimitedPath(const MWWorld::ConstPtr& actor, const osg::Vec3f& startPoint, const osg::Vec3f& endPoint,
|
||||||
const MWWorld::CellStore* cell, const PathgridGraph& pathgridGraph,
|
const MWWorld::CellStore* cell, const PathgridGraph& pathgridGraph,
|
||||||
const DetourNavigator::AgentBounds& agentBounds, const DetourNavigator::Flags flags,
|
const DetourNavigator::AgentBounds& agentBounds, const DetourNavigator::Flags flags,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user