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 entity found = NULL; // TODO: using FOREACH_ENTITY_RADIUS here causes mutex loop warnings, this may need a proper fix!
32 IL_EACH(g_pathlib_nodes, it.is_path_node && vdist(it.origin - where, <, pathlib_gridsize * 0.5),
41 bool tile_check_cross(entity this, vector where)
44 vector f = PLIB_FORWARD * tile_check_size;
45 vector r = PLIB_RIGHT * tile_check_size;
50 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
51 if (!location_isok(trace_endpos, 1, 0))
56 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
57 if (!location_isok(trace_endpos, 1, 0))
62 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
63 if (!location_isok(trace_endpos, 1 ,0))
68 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
69 if (!location_isok(trace_endpos, 1, 0))
75 bool tile_check_plus(entity this, vector where)
79 vector f = PLIB_FORWARD * tile_check_size;
80 vector r = PLIB_RIGHT * tile_check_size;
84 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
85 if (!location_isok(trace_endpos,1,0))
91 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
92 if (!location_isok(trace_endpos,1,0))
97 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
98 if (!location_isok(trace_endpos,1,0))
103 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
104 if (!location_isok(trace_endpos,1,0))
110 float tile_check_plus2(entity this, vector where)
115 vector f = PLIB_FORWARD * pathlib_gridsize;
116 vector r = PLIB_RIGHT * pathlib_gridsize;
118 //#define pathlib_node_edgeflag_left 2
119 //#define pathlib_node_edgeflag_right 4
120 //#define pathlib_node_edgeflag_forward 8
121 //#define pathlib_node_edgeflag_back 16
125 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
126 if (location_isok(trace_endpos,1,0))
129 e |= pathlib_node_edgeflag_forward;
135 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
136 if (location_isok(trace_endpos,1,0))
139 e |= pathlib_node_edgeflag_left;
145 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
146 if (location_isok(trace_endpos,1,0))
149 e |= pathlib_node_edgeflag_right;
154 traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this);
155 if (location_isok(trace_endpos,1,0))
158 e |= pathlib_node_edgeflag_back;
163 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
164 if (location_isok(trace_endpos, 1, 0))
167 e |= pathlib_node_edgeflag_forwardright;
172 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
173 if (location_isok(trace_endpos, 1, 0))
176 e |= pathlib_node_edgeflag_forwardleft;
181 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
182 if (location_isok(trace_endpos, 1 ,0))
185 e |= pathlib_node_edgeflag_backright;
190 traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this);
191 if (location_isok(trace_endpos, 1, 0))
194 e |= pathlib_node_edgeflag_backleft;
199 e = pathlib_node_edgeflag_none;
204 bool tile_check_star(entity this, vector where)
206 if(tile_check_plus(this, where))
207 return tile_check_cross(this, where);