]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/angle.qc
Merge branch 'Mario/addtolist_cleanup' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / angle.qc
index f921d74b01bdc43953101260514e9ffb5d0c3eca..e2e7ae628b8099682c5434216707aa55bfc81567 100644 (file)
@@ -4,6 +4,7 @@
 /*
 * Return a angle within +/- 360.
 */
+ERASEABLE
 float anglemods(float v)
 {
        v = v - 360 * floor(v / 360);
@@ -19,6 +20,7 @@ float anglemods(float v)
 /*
 * Return the short angle
 */
+ERASEABLE
 float shortangle_f(float ang1, float ang2)
 {
        if(ang1 > ang2)
@@ -35,6 +37,7 @@ float shortangle_f(float ang1, float ang2)
        return ang1;
 }
 
+ERASEABLE
 vector shortangle_v(vector ang1, vector ang2)
 {
        vector vtmp;
@@ -46,6 +49,7 @@ vector shortangle_v(vector ang1, vector ang2)
        return vtmp;
 }
 
+ERASEABLE
 vector shortangle_vxy(vector ang1, vector ang2)
 {
        vector vtmp = '0 0 0';
@@ -57,32 +61,17 @@ 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)
+ERASEABLE
+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 +81,5 @@ vector angleofs3(vector from, vector from_a, entity to)
 
        return v_res;
 }
+
+#define angleofs(from, to) angleofs3(from.origin, from.angles, to.origin)