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)
28 ++pathlib_searched_cnt;
30 where.x = fsnap(where.x,pathlib_gridsize);
31 where.y = fsnap(where.y,pathlib_gridsize);
33 node = findradius(where,pathlib_gridsize * 0.5);
36 if(node.is_path_node == true)
45 float tile_check_cross(entity this, vector where)
49 f = PLIB_FORWARD * tile_check_size;
50 r = PLIB_RIGHT * tile_check_size;
55 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
56 if (!location_isok(trace_endpos, 1, 0))
61 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
62 if (!location_isok(trace_endpos, 1, 0))
67 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
68 if (!location_isok(trace_endpos, 1 ,0))
73 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
74 if (!location_isok(trace_endpos, 1, 0))
80 float tile_check_plus(entity this, vector where)
84 f = PLIB_FORWARD * tile_check_size;
85 r = PLIB_RIGHT * tile_check_size;
89 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
90 if (!location_isok(trace_endpos,1,0))
96 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
97 if (!location_isok(trace_endpos,1,0))
102 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
103 if (!location_isok(trace_endpos,1,0))
108 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
109 if (!location_isok(trace_endpos,1,0))
115 float tile_check_plus2(entity this, vector where)
120 f = PLIB_FORWARD * pathlib_gridsize;
121 r = PLIB_RIGHT * pathlib_gridsize;
123 //#define pathlib_node_edgeflag_left 2
124 //#define pathlib_node_edgeflag_right 4
125 //#define pathlib_node_edgeflag_forward 8
126 //#define pathlib_node_edgeflag_back 16
130 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
131 if (location_isok(trace_endpos,1,0))
134 e |= pathlib_node_edgeflag_forward;
140 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
141 if (location_isok(trace_endpos,1,0))
144 e |= pathlib_node_edgeflag_left;
150 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
151 if (location_isok(trace_endpos,1,0))
154 e |= pathlib_node_edgeflag_right;
159 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
160 if (location_isok(trace_endpos,1,0))
163 e |= pathlib_node_edgeflag_back;
168 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
169 if (location_isok(trace_endpos, 1, 0))
172 e |= pathlib_node_edgeflag_forwardright;
177 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
178 if (location_isok(trace_endpos, 1, 0))
181 e |= pathlib_node_edgeflag_forwardleft;
186 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
187 if (location_isok(trace_endpos, 1 ,0))
190 e |= pathlib_node_edgeflag_backright;
195 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
196 if (location_isok(trace_endpos, 1, 0))
199 e |= pathlib_node_edgeflag_backleft;
204 e = pathlib_node_edgeflag_none;
209 float tile_check_star(entity this, vector where)
211 if(tile_check_plus(this, where))
212 return tile_check_cross(this, where);