1 float fsnap(float val,float fsize)
3 return rint(val / fsize) * fsize;
6 vector vsnap(vector point,float fsize)
10 vret_x = rint(point_x / fsize) * fsize;
11 vret_y = rint(point_y / fsize) * fsize;
12 vret_z = ceil(point_z / fsize) * fsize;
17 float location_isok(vector point, float water_isok, float air_isok)
21 if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
24 pc = pointcontents(point);
25 pc2 = pointcontents(point - '0 0 1');
42 if (pc2 == CONTENT_SOLID)
45 if (pc2 == CONTENT_EMPTY)
49 if (pc2 == CONTENT_WATER)
65 entity pathlib_nodeatpoint(vector where)
69 ++pathlib_searched_cnt;
71 where_x = fsnap(where_x,pathlib_gridsize);
72 where_y = fsnap(where_y,pathlib_gridsize);
74 node = findradius(where,pathlib_gridsize * 0.5);
77 if(node.is_path_node == TRUE)
86 float tile_check_cross(vector where)
90 f = PLIB_FORWARD * tile_check_size;
91 r = PLIB_RIGHT * tile_check_size;
96 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
97 if not (location_isok(trace_endpos, 1, 0))
102 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
103 if not (location_isok(trace_endpos, 1, 0))
108 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
109 if not (location_isok(trace_endpos, 1 ,0))
114 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
115 if not (location_isok(trace_endpos, 1, 0))
121 float tile_check_plus(vector where)
125 f = PLIB_FORWARD * tile_check_size;
126 r = PLIB_RIGHT * tile_check_size;
130 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
131 if not (location_isok(trace_endpos,1,0))
137 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
138 if not (location_isok(trace_endpos,1,0))
143 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
144 if not (location_isok(trace_endpos,1,0))
149 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
150 if not (location_isok(trace_endpos,1,0))
156 float tile_check_plus2(vector where)
161 f = PLIB_FORWARD * pathlib_gridsize;
162 r = PLIB_RIGHT * pathlib_gridsize;
164 //#define pathlib_node_edgeflag_left 2
165 //#define pathlib_node_edgeflag_right 4
166 //#define pathlib_node_edgeflag_forward 8
167 //#define pathlib_node_edgeflag_back 16
171 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
172 if (location_isok(trace_endpos,1,0))
175 e |= pathlib_node_edgeflag_forward;
181 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
182 if (location_isok(trace_endpos,1,0))
185 e |= pathlib_node_edgeflag_left;
191 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
192 if (location_isok(trace_endpos,1,0))
195 e |= pathlib_node_edgeflag_right;
200 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self);
201 if (location_isok(trace_endpos,1,0))
204 e |= pathlib_node_edgeflag_back;
209 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
210 if (location_isok(trace_endpos, 1, 0))
213 e |= pathlib_node_edgeflag_forwardright;
218 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
219 if (location_isok(trace_endpos, 1, 0))
222 e |= pathlib_node_edgeflag_forwardleft;
227 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
228 if (location_isok(trace_endpos, 1 ,0))
231 e |= pathlib_node_edgeflag_backright;
236 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self);
237 if (location_isok(trace_endpos, 1, 0))
240 e |= pathlib_node_edgeflag_backleft;
245 e = pathlib_node_edgeflag_none;
250 float tile_check_star(vector where)
252 if(tile_check_plus(where))
253 return tile_check_cross(where);