28 n.is_path_node =
false;
44 mark_error(where, 60);
54 node.is_path_node =
true;
58 setsize(node,
'0 0 0',
'0 0 0');
62 pathlib_showsquare(where, 1 ,15);
115 if(node.pathlib_node_g > g)
117 node.pathlib_node_h = h;
118 node.pathlib_node_g = g;
119 node.pathlib_node_f = f;
139 LOG_DEBUG(
"pathlib_movenode_goodnode = 0");
159 pathlib_showsquare(where, 0 ,30);
204 node.pathlib_node_h = h;
205 node.pathlib_node_g = g;
206 node.pathlib_node_f = f;
231 if(!bestnode || it.pathlib_node_f < bestnode.pathlib_node_f)
242 LOG_TRACE(
"Pathlib: Tried to close a closed node!");
293 float f = (1 -
cos(ft)) * 0.5;
295 return a*(1-f) + b*f;
303 if(
vdist(d1 - d2, <, 0.25))
336 path.path_next =
next;
341 path.classname =
"path_end";
345 path.classname =
"path_start";
347 path.classname =
"path_node";
444 LOG_DEBUG(
"AStar: Goal found on first node!");
446 open =
new(path_end);
475 LOG_TRACE(
"Path took too long to compute!");
496 LOG_DEBUG(
"Target found. Rebuilding and filtering path...");
498 ptime = ftime - ptime;
505 for(open =
goal_node; open.path_prev != path; open = open.path_prev)
507 n =
path_build(ln,open.origin,open.path_prev,start);
521 pathlib_showpath2(start);
526 LOG_TRACE(
"Time used - total: ",
ftos(ptime + ftime + ctime));
542 LOG_TRACE(
"A* Faild to find a path! Try a smaller gridsize.");
ERASEABLE void IL_REMOVE(IntrusiveList this, entity it)
Remove any element, anywhere in the list.
#define IL_EACH(this, cond, body)
#define IL_CLEAR(this)
Remove all elements.
var float pathlib_cost(entity parent, vector to, float static_cost)
IntrusiveList g_pathlib_nodes
float pathlib_g_euclidean_water(entity parent, vector to, float static_cost)
entity pathlib_astar(entity this, vector from, vector to)
bool tile_check_cross(entity this, vector where)
float pathlib_expandnode_star(entity node, vector start, vector goal)
const float PATHLIB_NODEEXPIRE
vector pathlib_swimnode(entity this, vector start, vector end, float doedge)
float pathlib_h_diagonal(vector a, vector b)
This heuristic consider both straight and diagonal moves to have the same cost.
bool pathlib_makenode_adaptive(entity parent, vector start, vector to, vector goal, float cost)
var vector pathlib_movenode(entity this, vector start, vector end, float doedge)
const float pathlib_maxtime
#define FOREACH_ENTITY_ENT(fld, match, body)
var float pathlib_expandnode(entity node, vector start, vector goal)
float pathlib_bestcash_saved
void pathlib_close_node(entity node, vector goal)
entity pathlib_mknode(vector where, entity parent)
float pathlib_bestopen_searched
float pathlib_expandnode_box(entity node, vector start, vector goal)
float pathlib_searched_cnt
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
entity pathlib_nodeatpoint(vector where)
float pathlib_movecost_waterfactor
bool buildpath_nodefilter_none(vector n, vector c, vector p)
var bool pathlib_makenode(entity parent, vector start, vector to, vector goal, float cost)
var bool buildpath_nodefilter(vector n, vector c, vector p)
entity pathlib_getbestopen()
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
float pathlib_bestcash_hits
entity path_build(entity next, vector where, entity prev, entity start)
bool pathlib_movenode_goodnode
float pathlib_movecost_diag
var bool tile_check(entity this, vector where)
void pathlib_deletepath(entity start)
float Cosine_Interpolate(float a, float b, float c)
bool buildpath_nodefilter_directional(vector n, vector c, vector p)
vector pathlib_walknode(entity this, vector start, vector end, float doedge)
bool buildpath_nodefilter_moveskip(entity this, vector n, vector c, vector p)
var float pathlib_heuristic(vector from, vector to)
ERASEABLE float fsnap(float val, float fsize)