]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Optimize waypoint_getdistancecost
authorterencehill <piuntn@gmail.com>
Fri, 12 May 2017 15:10:20 +0000 (17:10 +0200)
committerterencehill <piuntn@gmail.com>
Fri, 12 May 2017 15:10:20 +0000 (17:10 +0200)
qcsrc/server/bot/default/waypoints.qc

index e545c6c85f8a450855ead5f5675aba6066390237..54f3c8fc4ccb3d4fdc17c38ef279a336a551c5d0 100644 (file)
@@ -401,13 +401,12 @@ float waypoint_getdistancecost(vector from, vector to)
        float c = waypoint_getdistancecost_simple(vlen(to - from));
 
        float height = from.z - to.z;
-       if(height > 0 && autocvar_sv_gravity > 0)
+       if(height > jumpheight_vec.z && autocvar_sv_gravity > 0)
        {
                float height_cost = sqrt(height / (autocvar_sv_gravity / 2));
-               float xydist = vlen(vec2(to - from));
-               float xydist_cost = xydist / autocvar_sv_maxspeed;
-               if(max(height_cost, xydist_cost) < c)
-                       c = max(height_cost, xydist_cost);
+               c = waypoint_getdistancecost_simple(vlen(vec2(to - from))); // xy distance cost
+               if(height_cost > c)
+                       c = height_cost;
        }
        return c;
 }