From: terencehill Date: Fri, 12 May 2017 15:10:20 +0000 (+0200) Subject: Optimize waypoint_getdistancecost X-Git-Tag: xonotic-v0.8.5~2378^2~164 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=98a0aca8f228b9294cf26bbbc9847222a48a7552;p=xonotic%2Fxonotic-data.pk3dir.git Optimize waypoint_getdistancecost --- diff --git a/qcsrc/server/bot/default/waypoints.qc b/qcsrc/server/bot/default/waypoints.qc index e545c6c85..54f3c8fc4 100644 --- a/qcsrc/server/bot/default/waypoints.qc +++ b/qcsrc/server/bot/default/waypoints.qc @@ -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; }