From: TimePath Date: Mon, 30 Nov 2015 05:16:47 +0000 (+1100) Subject: Viewmodels: match engine cl_followmodel and cl_bobmodel X-Git-Tag: xonotic-v0.8.2~1601^2~2 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1c45f952149e8460c22aa401f21259c568ddc4f0;p=xonotic%2Fxonotic-data.pk3dir.git Viewmodels: match engine cl_followmodel and cl_bobmodel --- diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 81098c1eb..6a6214a98 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -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; } diff --git a/qcsrc/lib/vector.qh b/qcsrc/lib/vector.qh index 776bf6eed..ec8257e3a 100644 --- a/qcsrc/lib/vector.qh +++ b/qcsrc/lib/vector.qh @@ -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); \