entity pathlib_nodeatpoint(vector where)
{
- entity node;
-
++pathlib_searched_cnt;
where.x = fsnap(where.x,pathlib_gridsize);
where.y = fsnap(where.y,pathlib_gridsize);
- node = findradius(where,pathlib_gridsize * 0.5);
- while(node)
+ FOREACH_ENTITY_RADIUS(where, pathlib_gridsize * 0.5, it.is_path_node,
{
- if(node.is_path_node == true)
- return node;
-
- node = node.chain;
- }
+ return it;
+ });
return NULL;
}
-float tile_check_cross(entity this, vector where)
+bool tile_check_cross(entity this, vector where)
{
- vector p,f,r;
-
- f = PLIB_FORWARD * tile_check_size;
- r = PLIB_RIGHT * tile_check_size;
+ vector p;
+ vector f = PLIB_FORWARD * tile_check_size;
+ vector r = PLIB_RIGHT * tile_check_size;
// forward-right
p = where + f + r;
traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (!location_isok(trace_endpos, 1, 0))
- return 0;
+ return false;
// Forward-left
p = where + f - r;
traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (!location_isok(trace_endpos, 1, 0))
- return 0;
+ return false;
// Back-right
p = where - f + r;
traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (!location_isok(trace_endpos, 1 ,0))
- return 0;
+ return false;
//Back-left
p = where - f - r;
traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (!location_isok(trace_endpos, 1, 0))
- return 0;
+ return false;
- return 1;
+ return true;
}
-float tile_check_plus(entity this, vector where)
+bool tile_check_plus(entity this, vector where)
{
- vector p,f,r;
+ vector p;
- f = PLIB_FORWARD * tile_check_size;
- r = PLIB_RIGHT * tile_check_size;
+ vector f = PLIB_FORWARD * tile_check_size;
+ vector r = PLIB_RIGHT * tile_check_size;
// forward
p = where + f;
traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (!location_isok(trace_endpos,1,0))
- return 0;
+ return false;
//left
p = where - r;
traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (!location_isok(trace_endpos,1,0))
- return 0;
+ return false;
// Right
p = where + r;
traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (!location_isok(trace_endpos,1,0))
- return 0;
+ return false;
//Back
p = where - f;
traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (!location_isok(trace_endpos,1,0))
- return 0;
+ return false;
- return 1;
+ return true;
}
float tile_check_plus2(entity this, vector where)
{
- vector p,f,r;
- float i = 0, e = 0;
+ vector p;
+ int j = 0, e = 0;
- f = PLIB_FORWARD * pathlib_gridsize;
- r = PLIB_RIGHT * pathlib_gridsize;
+ vector f = PLIB_FORWARD * pathlib_gridsize;
+ vector r = PLIB_RIGHT * pathlib_gridsize;
//#define pathlib_node_edgeflag_left 2
//#define pathlib_node_edgeflag_right 4
traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (location_isok(trace_endpos,1,0))
{
- ++i;
+ ++j;
e |= pathlib_node_edgeflag_forward;
}
traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (location_isok(trace_endpos,1,0))
{
- ++i;
+ ++j;
e |= pathlib_node_edgeflag_left;
}
traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (location_isok(trace_endpos,1,0))
{
- ++i;
+ ++j;
e |= pathlib_node_edgeflag_right;
}
traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
if (location_isok(trace_endpos,1,0))
{
- ++i;
+ ++j;
e |= pathlib_node_edgeflag_back;
}
traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (location_isok(trace_endpos, 1, 0))
{
- ++i;
+ ++j;
e |= pathlib_node_edgeflag_forwardright;
}
traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (location_isok(trace_endpos, 1, 0))
{
- ++i;
+ ++j;
e |= pathlib_node_edgeflag_forwardleft;
}
traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (location_isok(trace_endpos, 1 ,0))
{
- ++i;
+ ++j;
e |= pathlib_node_edgeflag_backright;
}
traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
if (location_isok(trace_endpos, 1, 0))
{
- ++i;
+ ++j;
e |= pathlib_node_edgeflag_backleft;
}
- if(i == 0)
+ if(j == 0)
e = pathlib_node_edgeflag_none;
return e;
}
-float tile_check_star(entity this, vector where)
+bool tile_check_star(entity this, vector where)
{
if(tile_check_plus(this, where))
return tile_check_cross(this, where);
- return 0;
+ return false;
}