1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-01 20:15:34 +00:00

Build straight path for wandering flying and water creatures

This commit is contained in:
elsid 2019-03-20 01:08:06 +03:00
parent ebdff5d96e
commit ff67a9e233
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40
3 changed files with 20 additions and 4 deletions

View file

@ -318,10 +318,17 @@ namespace MWMechanics
if ((isWaterCreature || isFlyingCreature) && destinationThroughGround(currentPosition, mDestination)) if ((isWaterCreature || isFlyingCreature) && destinationThroughGround(currentPosition, mDestination))
continue; continue;
if (isWaterCreature || isFlyingCreature)
{
mPathFinder.buildStraightPath(mDestination);
}
else
{
const osg::Vec3f halfExtents = MWBase::Environment::get().getWorld()->getPathfindingHalfExtents(actor); const osg::Vec3f halfExtents = MWBase::Environment::get().getWorld()->getPathfindingHalfExtents(actor);
mPathFinder.buildPath(actor, currentPosition, mDestination, actor.getCell(), mPathFinder.buildPath(actor, currentPosition, mDestination, actor.getCell(),
getPathGridGraph(actor.getCell()), halfExtents, getNavigatorFlags(actor)); getPathGridGraph(actor.getCell()), halfExtents, getNavigatorFlags(actor));
mPathFinder.addPointToPath(mDestination); mPathFinder.addPointToPath(mDestination);
}
if (mPathFinder.isPathConstructed()) if (mPathFinder.isPathConstructed())
{ {

View file

@ -269,6 +269,13 @@ namespace MWMechanics
mPath.pop_front(); mPath.pop_front();
} }
void PathFinder::buildStraightPath(const osg::Vec3f& endPoint)
{
mPath.clear();
mPath.push_back(endPoint);
mConstructed = true;
}
void PathFinder::buildPathByPathgrid(const osg::Vec3f& startPoint, const osg::Vec3f& endPoint, void PathFinder::buildPathByPathgrid(const osg::Vec3f& startPoint, const osg::Vec3f& endPoint,
const MWWorld::CellStore* cell, const PathgridGraph& pathgridGraph) const MWWorld::CellStore* cell, const PathgridGraph& pathgridGraph)
{ {

View file

@ -72,6 +72,8 @@ namespace MWMechanics
mCell = nullptr; mCell = nullptr;
} }
void buildStraightPath(const osg::Vec3f& endPoint);
void buildPathByPathgrid(const osg::Vec3f& startPoint, const osg::Vec3f& endPoint, void buildPathByPathgrid(const osg::Vec3f& startPoint, const osg::Vec3f& endPoint,
const MWWorld::CellStore* cell, const PathgridGraph& pathgridGraph); const MWWorld::CellStore* cell, const PathgridGraph& pathgridGraph);