From: terencehill Date: Fri, 23 Jun 2017 16:25:16 +0000 (+0200) Subject: Turn angleofs into a macro; implement angleofs3 in a cleaner way X-Git-Tag: xonotic-v0.8.5~2705 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=eb454b00563bd7650a060f77c4128b240b982bf7;p=xonotic%2Fxonotic-data.pk3dir.git Turn angleofs into a macro; implement angleofs3 in a cleaner way --- diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index ae8cd5323..b9250f0a8 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -789,7 +789,7 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl } // Can we even aim this thing? - tvt_thadv = angleofs3(e_turret.tur_head.origin, e_turret.angles + e_turret.tur_head.angles, e_target); + tvt_thadv = angleofs3(e_turret.tur_head.origin, e_turret.angles + e_turret.tur_head.angles, e_target.origin); tvt_tadv = shortangle_vxy(angleofs(e_turret, e_target), e_turret.angles); tvt_thadf = vlen(tvt_thadv); tvt_tadf = vlen(tvt_tadv); diff --git a/qcsrc/common/turrets/util.qh b/qcsrc/common/turrets/util.qh index 5f52695ba..be207b711 100644 --- a/qcsrc/common/turrets/util.qh +++ b/qcsrc/common/turrets/util.qh @@ -1,9 +1,4 @@ #pragma once -float shortangle_f(float ang1, float ang2); -float anglemods(float v); float turret_tag_fire_update(entity this); -vector shortangle_vxy(vector ang1, vector ang2); -vector angleofs(entity from, entity to); -vector angleofs3(vector from, vector from_a, entity to); void FireImoBeam(entity this, vector start, vector end, vector smin, vector smax, float bforce, float f_dmg, float f_velfactor, float deathtype); diff --git a/qcsrc/lib/angle.qc b/qcsrc/lib/angle.qc index f921d74b0..302d78323 100644 --- a/qcsrc/lib/angle.qc +++ b/qcsrc/lib/angle.qc @@ -57,32 +57,16 @@ vector shortangle_vxy(vector ang1, vector ang2) } /* -* Return the angle between two enteties +* Return the angle offset between angle ang and angle of the vector from->to */ -vector angleofs(entity from, entity to) -{ - vector v_res; - - v_res = normalize(to.origin - from.origin); - v_res = vectoangles(v_res); - v_res = v_res - from.angles; - - if (v_res_x < 0) v_res_x += 360; - if (v_res_x > 180) v_res_x -= 360; - if (v_res_y < 0) v_res_y += 360; - if (v_res_y > 180) v_res_y -= 360; - - return v_res; -} - -vector angleofs3(vector from, vector from_a, entity to) +vector angleofs3(vector from, vector ang, vector to) { vector v_res; - v_res = normalize(to.origin - from); + v_res = normalize(to - from); v_res = vectoangles(v_res); - v_res = v_res - from_a; + v_res = v_res - ang; if (v_res_x < 0) v_res_x += 360; if (v_res_x > 180) v_res_x -= 360; @@ -92,3 +76,5 @@ vector angleofs3(vector from, vector from_a, entity to) return v_res; } + +#define angleofs(from, to) angleofs3(from.origin, from.angles, to.origin)