From b126fedc348053651fccd5295490f6e3553c77b5 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Tue, 28 Dec 2021 22:41:40 +0100 Subject: [PATCH] Add variables for constant first-person model offset This can be used to make the first-person weapon model less intrusive (or left-handed, although this isn't ideal as the model itself won't be mirrored). --- src/game/game.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/game/game.cpp b/src/game/game.cpp index 7237c1a7c..fbc0b0428 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -224,6 +224,10 @@ namespace game FVAR(IDF_PERSIST, firstpersonswayinertia, 0.0f, 0.2f, 1.0f); FVAR(IDF_PERSIST, firstpersonswaymaxinertia, 0.0f, 32.0f, 1000.0f); + FVAR(IDF_PERSIST, firstpersonside, -10.0f, 0.0f, 10.0f); + FVAR(IDF_PERSIST, firstpersonup, -10.0f, 0.0f, 10.0f); + FVAR(IDF_PERSIST, firstpersondist, -10.0f, 0.0f, 10.0f); + VAR(IDF_PERSIST, firstpersonbob, 0, 0, 1); FVAR(IDF_PERSIST, firstpersonbobmin, 0, 0.2f, 1); FVAR(IDF_PERSIST, firstpersonbobstep, 1, 40.f, 1000); @@ -3745,6 +3749,18 @@ namespace game if(!firstpersoncamera && gs_playing(gamestate) && firstpersonsway) calchwepsway(mdl); + // apply constant first-person model offset + + vec dirforward = vec(mdl.yaw*RAD, mdl.pitch*RAD); + vec dirside = vec((mdl.yaw+90)*RAD, 0.0f); + vec dirup = vec(mdl.yaw*RAD, (mdl.pitch+90)*RAD); + + vec trans = vec(0, 0, 0); + trans.add(vec(dirforward).mul(firstpersondist)); + trans.add(vec(dirside).mul(firstpersonside)); + trans.add(vec(dirup).mul(firstpersonup)); + mdl.o.add(trans); + if(d->sliding(true) && firstpersonslidetime && firstpersonslideroll != 0) { int dur = min(impulseslidelen/2, firstpersonslidetime), millis = lastmillis-d->slidetime();