Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
Path Class Reference

#include <AIPathfind.h>

Inherits MemoryPoolObject, and Snapshot.

Public Member Functions

 Path ()
 
PathNodegetFirstNode (void)
 
PathNodegetLastNode (void)
 
void updateLastNode (const Coord3D *pos)
 
void prependNode (const Coord3D *pos, PathfindLayerEnum layer)
 Create a new node at the head of the path.
 
void appendNode (const Coord3D *pos, PathfindLayerEnum layer)
 Create a new node at the end of the path.
 
void setBlockedByAlly (Bool blocked)
 
Bool getBlockedByAlly (void)
 
void optimize (const Object *obj, LocomotorSurfaceTypeMask acceptableSurfaces, Bool blocked)
 Optimize the path to discard redundant nodes.
 
void optimizeGroundPath (Bool crusher, Int diameter)
 Optimize the ground path to discard redundant nodes.
 
void computePointOnPath (const Object *obj, const LocomotorSet &locomotorSet, const Coord3D &pos, ClosestPointOnPathInfo &out)
 Given a location, return nearest location on path, and along-path dist to end as function result.
 
void peekCachedPointOnPath (Coord3D &pos) const
 Given a location, return nearest location on path, and along-path dist to end as function result.
 
Real computeFlightDistToGoal (const Coord3D *pos, Coord3D &goalPos)
 Given a flight path, compute the distance to goal (0 if we are past it) & return the goal pos.
 
void markOptimized (void)
 Given a location, return closest location on path, and along-path dist to end as function result.
 
- Public Member Functions inherited from MemoryPoolObject
void deleteInstance ()
 
- Public Member Functions inherited from Snapshot
 Snapshot (void)
 
 ~Snapshot (void)
 

Protected Types

enum  { MAX_CPOP =20 }
 

Protected Member Functions

virtual void crc (Xfer *xfer)
 
virtual void xfer (Xfer *xfer)
 
virtual void loadPostProcess ()
 
 MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE (Path, "PathPool")
 
- Protected Member Functions inherited from MemoryPoolObject
virtual ~MemoryPoolObject ()
 
void * operator new (size_t s)
 
void operator delete (void *p)
 
virtual MemoryPoolgetObjectMemoryPool ()=0
 

Protected Attributes

PathNodem_path
 The list of PathNode objects that define the path.
 
PathNodem_pathTail
 
Bool m_isOptimized
 True if the path has been optimized.
 
Bool m_blockedByAlly
 An ally needs to move off of this path.
 
Bool m_cpopValid
 
Int m_cpopCountdown
 We only return the same cpop MAX_CPOP times. It is occasionally possible to get stuck.
 
Coord3D m_cpopIn
 
ClosestPointOnPathInfo m_cpopOut
 
const PathNodem_cpopRecentStart
 

Detailed Description

This class encapsulates a "path" returned by the Pathfinder.

Definition at line 147 of file AIPathfind.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
MAX_CPOP 

Definition at line 184 of file AIPathfind.h.

Constructor & Destructor Documentation

◆ Path()

Path::Path ( )

Definition at line 243 of file AIPathfind.cpp.

Member Function Documentation

◆ appendNode()

void Path::appendNode ( const Coord3D * pos,
PathfindLayerEnum layer )

Create a new node at the end of the path.

Create a new node at the tail of the path

Definition at line 421 of file AIPathfind.cpp.

◆ computeFlightDistToGoal()

Real Path::computeFlightDistToGoal ( const Coord3D * pos,
Coord3D & goalPos )

Given a flight path, compute the distance to goal (0 if we are past it) & return the goal pos.

Given a position, computes the distance to the goal. Returns 0 if we are past the goal. Returns the goal position in goalPos. This is intended for use with flying paths, that go directly to the goal and don't consider obstacles. jba.

Definition at line 1046 of file AIPathfind.cpp.

◆ computePointOnPath()

void Path::computePointOnPath ( const Object * obj,
const LocomotorSet & locomotorSet,
const Coord3D & pos,
ClosestPointOnPathInfo & out )

Given a location, return nearest location on path, and along-path dist to end as function result.

Given a location, return the closest position on the path. If 'allowBacktrack' is true, the entire path is considered. If it is false, the point computed cannot be prior to previously returned non-backtracking points on this path. Because the path "knows" the direction of travel, it will "lead" the given position a bit to ensure the path is followed in the inteded direction.

Note: The path cleanup does not take into account rolling terrain, so we can end up with these situations:

      B
   ######
 ##########

A-##-------—##—C #######################

When an agent gets to B, he seems far off of the path, but it really not. There are similar problems with valleys.

Since agents track the closest path, if a high hill gets close to the underside of a bridge, an agent may 'jump' to the higher path. This must be avoided in maps.

return along-path distance to the end will be returned as function result

Todo
Precompute this and store in path

Definition at line 756 of file AIPathfind.cpp.

◆ crc()

void Path::crc ( Xfer * xfer)
protectedvirtual

CRC

Implements Snapshot.

Definition at line 273 of file AIPathfind.cpp.

◆ getBlockedByAlly()

Bool Path::getBlockedByAlly ( void )
inline

Definition at line 160 of file AIPathfind.h.

◆ getFirstNode()

PathNode * Path::getFirstNode ( void )
inline

Definition at line 152 of file AIPathfind.h.

◆ getLastNode()

PathNode * Path::getLastNode ( void )
inline

Definition at line 153 of file AIPathfind.h.

◆ loadPostProcess()

void Path::loadPostProcess ( void )
protectedvirtual

Load post process

Implements Snapshot.

Definition at line 392 of file AIPathfind.cpp.

◆ markOptimized()

void Path::markOptimized ( void )
inline

Given a location, return closest location on path, and along-path dist to end as function result.

Definition at line 175 of file AIPathfind.h.

◆ MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE()

Path::MEMORY_POOL_GLUE_WITH_USERLOOKUP_CREATE ( Path ,
"PathPool"  )
protected
Todo
Set real numbers for mem alloc

◆ optimize()

void Path::optimize ( const Object * obj,
LocomotorSurfaceTypeMask acceptableSurfaces,
Bool blocked )

Optimize the path to discard redundant nodes.

Optimize the path by checking line of sight

Definition at line 474 of file AIPathfind.cpp.

◆ optimizeGroundPath()

void Path::optimizeGroundPath ( Bool crusher,
Int pathDiameter )

Optimize the ground path to discard redundant nodes.

Optimize the path by checking line of sight

Definition at line 602 of file AIPathfind.cpp.

◆ peekCachedPointOnPath()

void Path::peekCachedPointOnPath ( Coord3D & pos) const
inline

Given a location, return nearest location on path, and along-path dist to end as function result.

Definition at line 169 of file AIPathfind.h.

◆ prependNode()

void Path::prependNode ( const Coord3D * pos,
PathfindLayerEnum layer )

Create a new node at the head of the path.

Create a new node at the head of the path

Definition at line 399 of file AIPathfind.cpp.

◆ setBlockedByAlly()

void Path::setBlockedByAlly ( Bool blocked)
inline

Definition at line 159 of file AIPathfind.h.

◆ updateLastNode()

void Path::updateLastNode ( const Coord3D * pos)

Create a new node at the tail of the path

Definition at line 452 of file AIPathfind.cpp.

◆ xfer()

void Path::xfer ( Xfer * xfer)
protectedvirtual

Xfer Method

Implements Snapshot.

Definition at line 280 of file AIPathfind.cpp.

Member Data Documentation

◆ m_blockedByAlly

Bool Path::m_blockedByAlly
protected

An ally needs to move off of this path.

Definition at line 190 of file AIPathfind.h.

◆ m_cpopCountdown

Int Path::m_cpopCountdown
protected

We only return the same cpop MAX_CPOP times. It is occasionally possible to get stuck.

Definition at line 193 of file AIPathfind.h.

◆ m_cpopIn

Coord3D Path::m_cpopIn
protected

Definition at line 194 of file AIPathfind.h.

◆ m_cpopOut

ClosestPointOnPathInfo Path::m_cpopOut
protected

Definition at line 195 of file AIPathfind.h.

◆ m_cpopRecentStart

const PathNode* Path::m_cpopRecentStart
protected

Definition at line 196 of file AIPathfind.h.

◆ m_cpopValid

Bool Path::m_cpopValid
protected

Definition at line 192 of file AIPathfind.h.

◆ m_isOptimized

Bool Path::m_isOptimized
protected

True if the path has been optimized.

Definition at line 189 of file AIPathfind.h.

◆ m_path

PathNode* Path::m_path
protected

The list of PathNode objects that define the path.

Definition at line 187 of file AIPathfind.h.

◆ m_pathTail

PathNode* Path::m_pathTail
protected

Definition at line 188 of file AIPathfind.h.


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