56 #ifndef TETRAEDGE_TE_MICROPATHER 57 #define TETRAEDGE_TE_MICROPATHER 59 #include "common/array.h" 60 #include "common/util.h" 61 #include "common/types.h" 62 #include "math/utils.h" 79 typedef uintptr MP_UPTR;
119 virtual float LeastCostEstimate(
void* stateStart,
void* stateEnd ) = 0;
134 virtual void PrintStateInfo(
void* state ) = 0;
160 void Init(
unsigned _frame,
162 float _costFromStart,
167 void InitSentinel() {
169 Init( 0, 0, FLT_MAX, FLT_MAX, 0 );
195 void AddBefore(
PathNode* addThis ) {
196 addThis->next =
this;
197 addThis->prev = prev;
198 prev->next = addThis;
201 #ifdef TETRAEDGE_MICROPATHER_DEBUG 204 MPASSERT( totalCost == FLT_MAX );
205 for(
PathNode* it = next; it !=
this; it=it->next ) {
206 MPASSERT( it->prev ==
this || it->totalCost >= it->prev->totalCost );
207 MPASSERT( it->totalCost <= it->next->totalCost );
212 void CalcTotalCost() {
213 if ( costFromStart < FLT_MAX && estToGoal < FLT_MAX )
214 totalCost = costFromStart + estToGoal;
225 PathNodePool(
unsigned allocate,
unsigned typicalAdjacent );
243 PathNode* GetPathNode(
unsigned frame,
245 float _costFromStart,
253 bool PushCache(
const NodeCost* nodes,
int nNodes,
int* start );
257 void GetCache(
int start,
int nNodes,
NodeCost* nodes );
270 unsigned Hash(
void* voidval );
271 unsigned HashSize()
const {
return 1<<hashShift; }
272 unsigned HashMask()
const {
return ((1<<hashShift)-1); }
273 void AddPathNode(
unsigned key,
PathNode* p );
291 unsigned totalCollide;
308 bool KeyEqual(
const Item& item )
const {
return start == item.start && end == item.end; }
309 bool Empty()
const {
return start == 0 && end == 0; }
315 unsigned Hash()
const {
316 const unsigned char *p = (
const unsigned char *)(&start);
317 uint h = 2166136261U;
319 for(
unsigned i=0; i<
sizeof(
void*)*2; ++i, ++p ) {
332 void AddNoSolution(
void* end,
void* states[],
int count );
335 int AllocatedBytes()
const {
return allocated *
sizeof(
Item); }
336 int UsedBytes()
const {
return nItems *
sizeof(
Item); }
342 void AddItem(
const Item& item );
343 const Item* Find(
void* start,
void* end );
355 float memoryFraction;
414 MicroPather(
Graph* graph,
unsigned allocate = 250,
unsigned typicalAdjacent=6,
bool cache=
true );
456 #ifdef TETRAEDGE_MICROPATHER_DEBUG 474 #endif // TETRAEDGE_TE_MICROPATHER Definition: detection.h:27
Definition: micropather.h:376
float cost
The cost to the state. Use FLT_MAX for infinite cost.
Definition: micropather.h:90
Definition: micropather.h:222
Definition: micropather.h:87
Definition: micropather.h:151
void * state
The state as a void*.
Definition: micropather.h:89
Definition: micropather.h:303
Definition: micropather.h:350
Definition: micropather.h:300
Definition: micropather.h:140
Definition: micropather.h:108