5 bool location_isok(vector point, bool waterok, bool air_isok)
7 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
10 int pc = pointcontents(point);
11 int pc2 = pointcontents(point - '0 0 1');
13 if(pc == CONTENT_EMPTY && pc2 == CONTENT_SOLID)
15 if(pc == CONTENT_EMPTY && pc2 == CONTENT_WATER && waterok)
17 if(pc == CONTENT_EMPTY && pc2 == CONTENT_EMPTY && air_isok)
19 if(pc == CONTENT_WATER && waterok)
24 entity pathlib_nodeatpoint(vector where)
26 ++pathlib_searched_cnt;
28 where.x = fsnap(where.x,pathlib_gridsize);
29 where.y = fsnap(where.y,pathlib_gridsize);
31 FOREACH_ENTITY_RADIUS(where, pathlib_gridsize * 0.5, it.is_path_node,
39 bool tile_check_cross(entity this, vector where)
42 vector f = PLIB_FORWARD * tile_check_size;
43 vector r = PLIB_RIGHT * tile_check_size;
48 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
49 if (!location_isok(trace_endpos, 1, 0))
54 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
55 if (!location_isok(trace_endpos, 1, 0))
60 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
61 if (!location_isok(trace_endpos, 1 ,0))
66 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
67 if (!location_isok(trace_endpos, 1, 0))
73 bool tile_check_plus(entity this, vector where)
77 vector f = PLIB_FORWARD * tile_check_size;
78 vector r = PLIB_RIGHT * tile_check_size;
82 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
83 if (!location_isok(trace_endpos,1,0))
89 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
90 if (!location_isok(trace_endpos,1,0))
95 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
96 if (!location_isok(trace_endpos,1,0))
101 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
102 if (!location_isok(trace_endpos,1,0))
108 float tile_check_plus2(entity this, vector where)
113 vector f = PLIB_FORWARD * pathlib_gridsize;
114 vector r = PLIB_RIGHT * pathlib_gridsize;
116 //#define pathlib_node_edgeflag_left 2
117 //#define pathlib_node_edgeflag_right 4
118 //#define pathlib_node_edgeflag_forward 8
119 //#define pathlib_node_edgeflag_back 16
123 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
124 if (location_isok(trace_endpos,1,0))
127 e |= pathlib_node_edgeflag_forward;
133 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
134 if (location_isok(trace_endpos,1,0))
137 e |= pathlib_node_edgeflag_left;
143 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
144 if (location_isok(trace_endpos,1,0))
147 e |= pathlib_node_edgeflag_right;
152 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
153 if (location_isok(trace_endpos,1,0))
156 e |= pathlib_node_edgeflag_back;
161 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
162 if (location_isok(trace_endpos, 1, 0))
165 e |= pathlib_node_edgeflag_forwardright;
170 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
171 if (location_isok(trace_endpos, 1, 0))
174 e |= pathlib_node_edgeflag_forwardleft;
179 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
180 if (location_isok(trace_endpos, 1 ,0))
183 e |= pathlib_node_edgeflag_backright;
188 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
189 if (location_isok(trace_endpos, 1, 0))
192 e |= pathlib_node_edgeflag_backleft;
197 e = pathlib_node_edgeflag_none;
202 bool tile_check_star(entity this, vector where)
204 if(tile_check_plus(this, where))
205 return tile_check_cross(this, where);