]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Viewmodels: match engine cl_followmodel and cl_bobmodel
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 30 Nov 2015 05:16:47 +0000 (16:16 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 30 Nov 2015 05:16:47 +0000 (16:16 +1100)
qcsrc/client/view.qc
qcsrc/lib/vector.qh

index 81098c1eb13248f029a86ceaad4a1e5039811901..6a6214a98a15d629105c9a4f6296b7947e73544e 100644 (file)
@@ -252,13 +252,15 @@ void viewmodel_animate(entity this)
                        t *= 5;
                }
                bspeed = xyspeed * 0.01;
-               MAKEVECTORS(makevectors, gunangles, forward, right, up);
+               MAKEVECTORS(makevectors, view_angles, forward, right, up);
                float bobr = bspeed * autocvar_cl_bobmodel_side * autocvar_cl_viewmodel_scale * sin(s) * t;
                gunorg += bobr * right;
                float bobu = bspeed * autocvar_cl_bobmodel_up * autocvar_cl_viewmodel_scale * cos(s * 2) * t;
                gunorg += bobu * up;
        }
-       this.origin += view_forward * gunorg.x + view_right * gunorg.y + view_up * gunorg.z;
+       vector v = rotate(gunorg, YAW(view_angles) * DEG2RAD); // rotate world coordinates to relative ones
+       v.z = gunorg.z;
+       this.origin += v;
        gunangles.x = -gunangles.x; // pitch was inverted, now that actually matters
        this.angles += gunangles;
 }
index 776bf6eedb888c8fd0df39b4d37b3ca0321894ca..ec8257e3a672ce72d5007689208111fe2d2ca44d 100644 (file)
@@ -67,9 +67,9 @@ float boxesoverlap(vector m1, vector m2, vector m3, vector m4) { return m2_x >=
 /** requires the same as boxesoverlap, but is a stronger condition */
 float boxinsidebox(vector smins, vector smaxs, vector bmins, vector bmaxs) { return smins.x >= bmins.x && smaxs.x <= bmaxs.x && smins.y >= bmins.y && smaxs.y <= bmaxs.y && smins.z >= bmins.z && smaxs.z <= bmaxs.z; }
 
-#define PITCH(v) (v).x
-#define YAW(v) (v).y
-#define ROLL(v) (v).z
+#define PITCH(v) ((v).x)
+#define YAW(v) ((v).y)
+#define ROLL(v) ((v).z)
 
 #define MAKEVECTORS(f, angles, forward, right, up) do { \
        f(angles); \