From 98a0aca8f228b9294cf26bbbc9847222a48a7552 Mon Sep 17 00:00:00 2001 From: terencehill Date: Fri, 12 May 2017 17:10:20 +0200 Subject: [PATCH] Optimize waypoint_getdistancecost --- qcsrc/server/bot/default/waypoints.qc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) 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; } -- 2.39.2