X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fpathlib%2Futility.qc;h=7bdc70877420a38d60bd7ce7b3da04e99abe4c28;hb=4e85c153239969d8dccea38031e18ddb24b6c935;hp=81d06b2c9a6d494b73ebf5dbce42aee8a3a1efd5;hpb=0e7ed909bffb4ff21f0c68d163edfc17487e380a;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/pathlib/utility.qc b/qcsrc/server/pathlib/utility.qc index 81d06b2c9..7bdc70877 100644 --- a/qcsrc/server/pathlib/utility.qc +++ b/qcsrc/server/pathlib/utility.qc @@ -7,9 +7,9 @@ vector vsnap(vector point,float fsize) { vector vret; - vret_x = rint(point_x / fsize) * fsize; - vret_y = rint(point_y / fsize) * fsize; - vret_z = ceil(point_z / fsize) * fsize; + vret.x = rint(point.x / fsize) * fsize; + vret.y = rint(point.y / fsize) * fsize; + vret.z = ceil(point.z / fsize) * fsize; return vret; } @@ -68,13 +68,13 @@ entity pathlib_nodeatpoint(vector where) ++pathlib_searched_cnt; - where_x = fsnap(where_x,pathlib_gridsize); - where_y = fsnap(where_y,pathlib_gridsize); + where.x = fsnap(where.x,pathlib_gridsize); + where.y = fsnap(where.y,pathlib_gridsize); node = findradius(where,pathlib_gridsize * 0.5); while(node) { - if(node.is_path_node == TRUE) + if(node.is_path_node == true) return node; node = node.chain; @@ -90,28 +90,29 @@ float tile_check_cross(vector where) f = PLIB_FORWARD * tile_check_size; r = PLIB_RIGHT * tile_check_size; + // forward-right p = where + f + r; - traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); - if not (location_isok(trace_endpos,1,0)) + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + if (!location_isok(trace_endpos, 1, 0)) return 0; // Forward-left p = where + f - r; - traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); - if not (location_isok(trace_endpos,1,0)) + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + if (!location_isok(trace_endpos, 1, 0)) return 0; // Back-right p = where - f + r; - traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); - if not (location_isok(trace_endpos,1,0)) + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + if (!location_isok(trace_endpos, 1 ,0)) return 0; //Back-left p = where - f - r; - traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); - if not (location_isok(trace_endpos,1,0)) + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + if (!location_isok(trace_endpos, 1, 0)) return 0; return 1; @@ -127,31 +128,125 @@ float tile_check_plus(vector where) // forward p = where + f; traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); - if not (location_isok(trace_endpos,1,0)) + if (!location_isok(trace_endpos,1,0)) return 0; + //left p = where - r; traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); - if not (location_isok(trace_endpos,1,0)) + if (!location_isok(trace_endpos,1,0)) return 0; - // Right p = where + r; traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); - if not (location_isok(trace_endpos,1,0)) + if (!location_isok(trace_endpos,1,0)) return 0; //Back p = where - f; traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); - if not (location_isok(trace_endpos,1,0)) + if (!location_isok(trace_endpos,1,0)) return 0; return 1; } +float tile_check_plus2(vector where) +{ + vector p,f,r; + float i = 0, e = 0; + + f = PLIB_FORWARD * pathlib_gridsize; + r = PLIB_RIGHT * pathlib_gridsize; + +//#define pathlib_node_edgeflag_left 2 +//#define pathlib_node_edgeflag_right 4 +//#define pathlib_node_edgeflag_forward 8 +//#define pathlib_node_edgeflag_back 16 + + // forward + p = where + f; + traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); + if (location_isok(trace_endpos,1,0)) + { + ++i; + e |= pathlib_node_edgeflag_forward; + } + + + //left + p = where - r; + traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); + if (location_isok(trace_endpos,1,0)) + { + ++i; + e |= pathlib_node_edgeflag_left; + } + + + // Right + p = where + r; + traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); + if (location_isok(trace_endpos,1,0)) + { + ++i; + e |= pathlib_node_edgeflag_right; + } + + //Back + p = where - f; + traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); + if (location_isok(trace_endpos,1,0)) + { + ++i; + e |= pathlib_node_edgeflag_back; + } + + // forward-right + p = where + f + r; + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + if (location_isok(trace_endpos, 1, 0)) + { + ++i; + e |= pathlib_node_edgeflag_forwardright; + } + + // Forward-left + p = where + f - r; + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + if (location_isok(trace_endpos, 1, 0)) + { + ++i; + e |= pathlib_node_edgeflag_forwardleft; + } + + // Back-right + p = where - f + r; + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + if (location_isok(trace_endpos, 1 ,0)) + { + ++i; + e |= pathlib_node_edgeflag_backright; + } + + //Back-left + p = where - f - r; + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + if (location_isok(trace_endpos, 1, 0)) + { + ++i; + e |= pathlib_node_edgeflag_backleft; + } + + + if(i == 0) + e = pathlib_node_edgeflag_none; + + return e; +} + float tile_check_star(vector where) { if(tile_check_plus(where))