mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-30 16:20:21 +00:00
Do not fallback to direct path without pathgrid
Assume this might happen only due buildPath call when navmesh can't provide path.
This commit is contained in:
parent
c4cd3b2c4f
commit
d863267d5c
@ -158,10 +158,7 @@ namespace MWMechanics
|
|||||||
// Maybe there is no pathgrid for this cell. Just go to destination and let
|
// Maybe there is no pathgrid for this cell. Just go to destination and let
|
||||||
// physics take care of any blockages.
|
// physics take care of any blockages.
|
||||||
if(!pathgrid || pathgrid->mPoints.empty())
|
if(!pathgrid || pathgrid->mPoints.empty())
|
||||||
{
|
|
||||||
*out++ = endPoint;
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
// NOTE: getClosestPoint expects local coordinates
|
// NOTE: getClosestPoint expects local coordinates
|
||||||
Misc::CoordinateConverter converter(mCell->getCell());
|
Misc::CoordinateConverter converter(mCell->getCell());
|
||||||
@ -179,6 +176,9 @@ namespace MWMechanics
|
|||||||
endPointInLocalCoords,
|
endPointInLocalCoords,
|
||||||
startNode);
|
startNode);
|
||||||
|
|
||||||
|
if (!endNode.second)
|
||||||
|
return;
|
||||||
|
|
||||||
// if it's shorter for actor to travel from start to end, than to travel from either
|
// if it's shorter for actor to travel from start to end, than to travel from either
|
||||||
// start or end to nearest pathgrid point, just travel from start to end.
|
// start or end to nearest pathgrid point, just travel from start to end.
|
||||||
float startToEndLength2 = (endPointInLocalCoords - startPointInLocalCoords).length2();
|
float startToEndLength2 = (endPointInLocalCoords - startPointInLocalCoords).length2();
|
||||||
@ -249,8 +249,7 @@ namespace MWMechanics
|
|||||||
// unreachable pathgrid point.
|
// unreachable pathgrid point.
|
||||||
//
|
//
|
||||||
// The AI routines will have to deal with such situations.
|
// The AI routines will have to deal with such situations.
|
||||||
if(endNode.second)
|
*out++ = endPoint;
|
||||||
*out++ = endPoint;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
float PathFinder::getZAngleToNext(float x, float y) const
|
float PathFinder::getZAngleToNext(float x, float y) const
|
||||||
@ -328,16 +327,21 @@ namespace MWMechanics
|
|||||||
mPath.clear();
|
mPath.clear();
|
||||||
mCell = cell;
|
mCell = cell;
|
||||||
|
|
||||||
if (!actor.getClass().isPureWaterCreature(actor) && !actor.getClass().isPureFlyingCreature(actor))
|
bool hasNavMesh = false;
|
||||||
buildPathByNavigatorImpl(actor, startPoint, endPoint, halfExtents, flags, std::back_inserter(mPath));
|
|
||||||
|
|
||||||
if (mPath.empty())
|
if (!actor.getClass().isPureWaterCreature(actor) && !actor.getClass().isPureFlyingCreature(actor))
|
||||||
|
hasNavMesh = buildPathByNavigatorImpl(actor, startPoint, endPoint, halfExtents, flags, std::back_inserter(mPath));
|
||||||
|
|
||||||
|
if (hasNavMesh && mPath.empty())
|
||||||
buildPathByNavigatorImpl(actor, startPoint, endPoint, halfExtents,
|
buildPathByNavigatorImpl(actor, startPoint, endPoint, halfExtents,
|
||||||
flags | DetourNavigator::Flag_usePathgrid, std::back_inserter(mPath));
|
flags | DetourNavigator::Flag_usePathgrid, std::back_inserter(mPath));
|
||||||
|
|
||||||
if (mPath.empty())
|
if (mPath.empty())
|
||||||
buildPathByPathgridImpl(startPoint, endPoint, pathgridGraph, std::back_inserter(mPath));
|
buildPathByPathgridImpl(startPoint, endPoint, pathgridGraph, std::back_inserter(mPath));
|
||||||
|
|
||||||
|
if (!hasNavMesh && mPath.empty())
|
||||||
|
mPath.push_back(endPoint);
|
||||||
|
|
||||||
mConstructed = true;
|
mConstructed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user