From e9782340188d98ca99e695a7ef2a3ca320865e9e Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 13 Jan 2024 02:00:23 +0900 Subject: [PATCH] [qw] Fix a bunch of punchangle issues punchangle wasn't getting decayed for two reasons: I had forgotten to set the flag in qw, and the decayed value was not getting written to viewstate. Also, the rotation was misapplied (I had the two quaternions swapped) so punchangle was being applied to world Y instead of local Y, thus the seemingly random rolls. --- libs/client/cl_view.c | 8 ++++++-- qw/source/cl_parse.c | 2 ++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/client/cl_view.c b/libs/client/cl_view.c index f4d49baa2..ff0718aea 100644 --- a/libs/client/cl_view.c +++ b/libs/client/cl_view.c @@ -873,8 +873,9 @@ V_CalcRefdef (viewstate_t *vs) renderer->skin = 0; // set up the refresh position + rotation = Transform_GetWorldRotation (vs->camera_transform); Transform_SetWorldRotation (vs->camera_transform, - qmulf (vs->punchangle, rotation)); + qmulf (rotation, vs->punchangle)); // smooth out stair step ups if ((vs->onground != -1) && (gun_origin[2] - oldz > 0)) { @@ -907,8 +908,9 @@ DropPunchAngle (viewstate_t *vs) float ps = magnitude3f (punch)[0]; if (ps < 1e-3) { // < 0.2 degree rotation, not worth worrying about - //ensure the quaternion is normalized + //ensure the quaternion is identity vs->punchangle = (vec4f_t) { 0, 0, 0, 1 }; + vs->decay_punchangle = 0; return; } float pc = punch[3]; @@ -918,9 +920,11 @@ DropPunchAngle (viewstate_t *vs) float c = pc * dc + ps * ds; if (s <= 0 || c >= 1) { vs->punchangle = (vec4f_t) { 0, 0, 0, 1 }; + vs->decay_punchangle = 0; } else { punch *= s / ps; punch[3] = c; + vs->punchangle = punch; } } diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index 780643365..aa7f36bb7 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -1491,6 +1491,7 @@ CL_ParseServerMessage (void) // svc_cutscene (same value as svc_smallkick) case svc_smallkick: + cl.viewstate.decay_punchangle = 1; cl.viewstate.punchangle = (vec4f_t) { // -2 degrees pitch 0, -0.0174524064, 0, 0.999847695 @@ -1498,6 +1499,7 @@ CL_ParseServerMessage (void) break; case svc_bigkick: + cl.viewstate.decay_punchangle = 1; cl.viewstate.punchangle = (vec4f_t) { // -4 degrees pitch 0, -0.0348994967, 0, 0.999390827