5 float fsnap(float val,float fsize)
7 return rint(val / fsize) * fsize;
10 vector vsnap(vector point,float fsize)
14 vret.x = rint(point.x / fsize) * fsize;
15 vret.y = rint(point.y / fsize) * fsize;
16 vret.z = ceil(point.z / fsize) * fsize;
21 float location_isok(vector point, float water_isok, float air_isok)
25 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
28 pc = pointcontents(point);
29 pc2 = pointcontents(point - '0 0 1');
46 if (pc2 == CONTENT_SOLID)
49 if (pc2 == CONTENT_EMPTY)
53 if (pc2 == CONTENT_WATER)
69 entity pathlib_nodeatpoint(vector where)
73 ++pathlib_searched_cnt;
75 where.x = fsnap(where.x,pathlib_gridsize);
76 where.y = fsnap(where.y,pathlib_gridsize);
78 node = findradius(where,pathlib_gridsize * 0.5);
81 if(node.is_path_node == true)
90 float tile_check_cross(vector where)
94 f = PLIB_FORWARD * tile_check_size;
95 r = PLIB_RIGHT * tile_check_size;
100 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
101 if (!location_isok(trace_endpos, 1, 0))
106 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
107 if (!location_isok(trace_endpos, 1, 0))
112 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
113 if (!location_isok(trace_endpos, 1 ,0))
118 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
119 if (!location_isok(trace_endpos, 1, 0))
125 float tile_check_plus(vector where)
129 f = PLIB_FORWARD * tile_check_size;
130 r = PLIB_RIGHT * tile_check_size;
134 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
135 if (!location_isok(trace_endpos,1,0))
141 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
142 if (!location_isok(trace_endpos,1,0))
147 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
148 if (!location_isok(trace_endpos,1,0))
153 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
154 if (!location_isok(trace_endpos,1,0))
160 float tile_check_plus2(vector where)
165 f = PLIB_FORWARD * pathlib_gridsize;
166 r = PLIB_RIGHT * pathlib_gridsize;
168 //#define pathlib_node_edgeflag_left 2
169 //#define pathlib_node_edgeflag_right 4
170 //#define pathlib_node_edgeflag_forward 8
171 //#define pathlib_node_edgeflag_back 16
175 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
176 if (location_isok(trace_endpos,1,0))
179 e |= pathlib_node_edgeflag_forward;
185 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
186 if (location_isok(trace_endpos,1,0))
189 e |= pathlib_node_edgeflag_left;
195 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
196 if (location_isok(trace_endpos,1,0))
199 e |= pathlib_node_edgeflag_right;
204 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
205 if (location_isok(trace_endpos,1,0))
208 e |= pathlib_node_edgeflag_back;
213 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
214 if (location_isok(trace_endpos, 1, 0))
217 e |= pathlib_node_edgeflag_forwardright;
222 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
223 if (location_isok(trace_endpos, 1, 0))
226 e |= pathlib_node_edgeflag_forwardleft;
231 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
232 if (location_isok(trace_endpos, 1 ,0))
235 e |= pathlib_node_edgeflag_backright;
240 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
241 if (location_isok(trace_endpos, 1, 0))
244 e |= pathlib_node_edgeflag_backleft;
249 e = pathlib_node_edgeflag_none;
254 float tile_check_star(vector where)
256 if(tile_check_plus(where))
257 return tile_check_cross(where);