OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes | List of all members
MWMechanics::PathFinder Class Reference

#include <pathfinding.hpp>

Collaboration diagram for MWMechanics::PathFinder:

Public Member Functions

 PathFinder ()
 
void clearPath ()
 
void buildPath (const ESM::Pathgrid::Point &startPoint, const ESM::Pathgrid::Point &endPoint, const MWWorld::CellStore *cell, const PathgridGraph &pathgridGraph)
 
bool checkPathCompleted (float x, float y, float tolerance=PathTolerance)
 true if we are within tolerance units of the last path point. More...
 
float getZAngleToNext (float x, float y) const
 In radians. More...
 
float getXAngleToNext (float x, float y, float z) const
 
bool isPathConstructed () const
 
int getPathSize () const
 
const std::list
< ESM::Pathgrid::Point > & 
getPath () const
 
const MWWorld::CellStoregetPathCell () const
 
void buildSyncedPath (const ESM::Pathgrid::Point &startPoint, const ESM::Pathgrid::Point &endPoint, const MWWorld::CellStore *cell, const PathgridGraph &pathgridGraph)
 
void addPointToPath (const ESM::Pathgrid::Point &point)
 

Static Public Member Functions

static float sgn (float val)
 
static int sgn (int a)
 
static ESM::Pathgrid::Point MakePathgridPoint (const osg::Vec3f &v)
 utility function to convert a osg::Vec3f to a Pathgrid::Point More...
 
static ESM::Pathgrid::Point MakePathgridPoint (const ESM::Position &p)
 utility function to convert an ESM::Position to a Pathgrid::Point More...
 
static osg::Vec3f MakeOsgVec3 (const ESM::Pathgrid::Point &p)
 
static float DistanceSquared (ESM::Pathgrid::Point point, const osg::Vec3f &pos)
 
static int GetClosestPoint (const ESM::Pathgrid *grid, const osg::Vec3f &pos)
 

Static Public Attributes

static const int PathTolerance = 32
 

Private Attributes

std::list< ESM::Pathgrid::PointmPath
 
const ESM::PathgridmPathgrid
 
const MWWorld::CellStoremCell
 

Constructor & Destructor Documentation

MWMechanics::PathFinder::PathFinder ( )

Member Function Documentation

void MWMechanics::PathFinder::addPointToPath ( const ESM::Pathgrid::Point point)
inline

Here is the caller graph for this function:

void MWMechanics::PathFinder::buildPath ( const ESM::Pathgrid::Point startPoint,
const ESM::Pathgrid::Point endPoint,
const MWWorld::CellStore cell,
const PathgridGraph pathgridGraph 
)

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::PathFinder::buildSyncedPath ( const ESM::Pathgrid::Point startPoint,
const ESM::Pathgrid::Point endPoint,
const MWWorld::CellStore cell,
const PathgridGraph pathgridGraph 
)

Synchronize new path with old one to avoid visiting 1 waypoint 2 times

Note
BuildPath() takes closest PathGrid point to NPC as first point of path. This is undesirable if NPC has just passed a Pathgrid point, as this makes the 2nd point of the new path == the 1st point of old path. Which results in NPC "running in a circle" back to the just passed waypoint.

Here is the call graph for this function:

Here is the caller graph for this function:

bool MWMechanics::PathFinder::checkPathCompleted ( float  x,
float  y,
float  tolerance = PathTolerance 
)

true if we are within tolerance units of the last path point.

Here is the call graph for this function:

Here is the caller graph for this function:

void MWMechanics::PathFinder::clearPath ( )

Here is the caller graph for this function:

static float MWMechanics::PathFinder::DistanceSquared ( ESM::Pathgrid::Point  point,
const osg::Vec3f &  pos 
)
inlinestatic

Here is the call graph for this function:

Here is the caller graph for this function:

static int MWMechanics::PathFinder::GetClosestPoint ( const ESM::Pathgrid grid,
const osg::Vec3f &  pos 
)
inlinestatic

Here is the call graph for this function:

Here is the caller graph for this function:

const std::list<ESM::Pathgrid::Point>& MWMechanics::PathFinder::getPath ( ) const
inline

Here is the caller graph for this function:

const MWWorld::CellStore * MWMechanics::PathFinder::getPathCell ( ) const
int MWMechanics::PathFinder::getPathSize ( ) const
inline
float MWMechanics::PathFinder::getXAngleToNext ( float  x,
float  y,
float  z 
) const

Here is the call graph for this function:

float MWMechanics::PathFinder::getZAngleToNext ( float  x,
float  y 
) const

In radians.

bool MWMechanics::PathFinder::isPathConstructed ( ) const
inline

Here is the caller graph for this function:

static osg::Vec3f MWMechanics::PathFinder::MakeOsgVec3 ( const ESM::Pathgrid::Point p)
inlinestatic

Here is the caller graph for this function:

static ESM::Pathgrid::Point MWMechanics::PathFinder::MakePathgridPoint ( const osg::Vec3f &  v)
inlinestatic

utility function to convert a osg::Vec3f to a Pathgrid::Point

Here is the caller graph for this function:

static ESM::Pathgrid::Point MWMechanics::PathFinder::MakePathgridPoint ( const ESM::Position p)
inlinestatic

utility function to convert an ESM::Position to a Pathgrid::Point

static float MWMechanics::PathFinder::sgn ( float  val)
inlinestatic
static int MWMechanics::PathFinder::sgn ( int  a)
inlinestatic

Member Data Documentation

const MWWorld::CellStore* MWMechanics::PathFinder::mCell
private
std::list<ESM::Pathgrid::Point> MWMechanics::PathFinder::mPath
private
const ESM::Pathgrid* MWMechanics::PathFinder::mPathgrid
private
const int MWMechanics::PathFinder::PathTolerance = 32
static

The documentation for this class was generated from the following files: