1
0
forked from 0ad/0ad
0ad/source/simulation/PathfindSparse.h
janwas 5814e10126 # complete revamp of build system in preparation for automated self tests.
* now splits everything up into independent static libraries.
* fixed a great deal of incorrect #include statements. all headers must
now be specified with their full path relative to source. exception: if
file being included and including file are in the same directory, no
path needed.
use <> when relying on the build system's include path (e.g. for system
headers and external libraries, e.g. boost), otherwise "".

* temporarily renamed maths/Vector2D to Vector2D_Maths to avoid
conflict. these should be merged.
* hacked around VC linker stupidness when building static libs; texture
codecs must now be registered manually.

This was SVN commit r3931.
2006-06-02 03:56:24 +00:00

76 lines
2.1 KiB
C++

// PathfindSparse.h
//
// Mark Thompson mot20@cam.ac.uk / mark@wildfiregames.com
//
// Sparse pathfinder.
//
// Usage: You won't. See PathfindEngine.h
//
// Notes: A geometric pathfinder primarily for path postprocessing. Takes straight line
// paths and warps them to avoid obstacles.
// Sparse, because it runs in /exponential/ time with number of detours. Hence, only use
// where obstructions are sparse. You'll have fun if you try and path through, say,
// a forest with this.
//
// It also won't work at all through impassable terrain.
//
// TODO: Fix the algorithm for OABB obstacles.
// TODO: Replace with timesliced version and proper manager (either a singleton or tasks linked into g_Pathfinder)
//
// Mark Thompson mot20@cam.ac.uk / mark@wildfiregames.com
#ifndef PATHFIND_SPARSE_INCLUDED
#define PATHFIND_SPARSE_INCLUDED
#include "EntityHandles.h"
#include "ps/Vector2D.h"
#include "Collision.h"
struct sparsePathTree
{
enum
{
SPF_IMPOSSIBLE = 0,
SPF_OPEN_UNVISITED = 4,
SPF_OPEN_PROCESSING = 5,
SPF_CLOSED_DIRECT = 2,
SPF_CLOSED_WAYPOINTED = 3,
SPF_OPEN = 4,
SPF_SOLVED = 2
} type;
int recursionDepth;
HEntity entity;
CBoundingObject* destinationCollisionObject;
CVector2D from;
CVector2D to;
bool leftImpossible;
CVector2D left;
bool rightImpossible;
CVector2D right;
bool favourLeft;
union
{
struct
{
sparsePathTree* leftPre;
sparsePathTree* leftPost;
sparsePathTree* rightPre;
sparsePathTree* rightPost;
};
sparsePathTree* subtrees[4];
};
unsigned short nextSubtree;
sparsePathTree( const CVector2D& from, const CVector2D& to, HEntity entity, CBoundingObject* destinationCollisionObject, int _recursionDepth );
~sparsePathTree();
bool slice();
void pushResults( std::vector<CVector2D>& nodelist );
};
extern int SPF_RECURSION_DEPTH;
void nodePostProcess( HEntity entity, std::vector<CVector2D>& nodelist );
void pathSparse( HEntity entity, CVector2D destination );
bool pathSparseRecursive( HEntity entity, CVector2D from, CVector2D to, CBoundingObject* destinationCollisionObject );
#endif