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;
154 void Init(
unsigned _frame,
156 float _costFromStart,
161 void InitSentinel() {
163 Init( 0, 0, FLT_MAX, FLT_MAX, 0 );
189 void AddBefore(
PathNode* addThis ) {
190 addThis->next =
this;
191 addThis->prev = prev;
192 prev->next = addThis;
195 #ifdef TETRAEDGE_MICROPATHER_DEBUG 198 MPASSERT( totalCost == FLT_MAX );
199 for(
PathNode* it = next; it !=
this; it=it->next ) {
200 MPASSERT( it->prev ==
this || it->totalCost >= it->prev->totalCost );
201 MPASSERT( it->totalCost <= it->next->totalCost );
206 void CalcTotalCost() {
207 if ( costFromStart < FLT_MAX && estToGoal < FLT_MAX )
208 totalCost = costFromStart + estToGoal;
223 PathNodePool(
unsigned allocate,
unsigned typicalAdjacent );
241 PathNode* GetPathNode(
unsigned frame,
243 float _costFromStart,
251 bool PushCache(
const NodeCost* nodes,
int nNodes,
int* start );
255 void GetCache(
int start,
int nNodes,
NodeCost* nodes );
268 unsigned Hash(
void* voidval );
269 unsigned HashSize()
const {
return 1<<hashShift; }
270 unsigned HashMask()
const {
return ((1<<hashShift)-1); }
271 void AddPathNode(
unsigned key,
PathNode* p );
289 unsigned totalCollide;
305 bool KeyEqual(
const Item& item )
const {
return start == item.start && end == item.end; }
306 bool Empty()
const {
return start == 0 && end == 0; }
312 unsigned Hash()
const {
313 const unsigned char *p = (
const unsigned char *)(&start);
314 uint h = 2166136261U;
316 for(
unsigned i=0; i<
sizeof(
void*)*2; ++i, ++p ) {
329 void AddNoSolution(
void* end,
void* states[],
int count );
332 int AllocatedBytes()
const {
return allocated *
sizeof(
Item); }
333 int UsedBytes()
const {
return nItems *
sizeof(
Item); }
339 void AddItem(
const Item& item );
340 const Item* Find(
void* start,
void* end );
352 float memoryFraction;
411 MicroPather(
Graph* graph,
unsigned allocate = 250,
unsigned typicalAdjacent=6,
bool cache=
true );
453 #ifdef TETRAEDGE_MICROPATHER_DEBUG 471 #endif // TETRAEDGE_TE_MICROPATHER Definition: detection.h:27
Definition: micropather.h:373
float cost
The cost to the state. Use FLT_MAX for infinite cost.
Definition: micropather.h:90
Definition: micropather.h:220
Definition: micropather.h:87
Definition: micropather.h:151
void * state
The state as a void*.
Definition: micropather.h:89
Definition: micropather.h:300
Definition: micropather.h:347
Definition: micropather.h:297
Definition: micropather.h:140
Definition: micropather.h:108