Skip to content

Commit 8da2b46

Browse files
committed
Clean and fix viewbobbing code pal (Hi Ryley)
1 parent 162c14c commit 8da2b46

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

cl_dll/view.cpp

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ void V_CalcNormalRefdef(struct ref_params_s* pparams)
10401040
{
10411041
cl_entity_t* ent, * view;
10421042
int i;
1043-
float bob;
1043+
float bob = 0.0f;
10441044

10451045
vec3_t camAngles, camForward, camRight, camUp;
10461046

@@ -1153,36 +1153,39 @@ void V_CalcNormalRefdef(struct ref_params_s* pparams)
11531153
// Let the viewmodel shake at about 10% of the amplitude
11541154
gEngfuncs.V_ApplyShake(view->origin, view->angles, 0.9);
11551155

1156+
// VIEW BOBBING
11561157
if (cl_legacy_bob_enabled->value != 0)
11571158
{
11581159
bob = V_CalcLegacyBob(pparams);
1160+
11591161
VectorCopy(pparams->simorg, pparams->vieworg);
11601162
for (int i = 0; i < 3; i++)
11611163
pparams->vieworg[i] -= bob * 0.4 * pparams->forward[i];
1164+
11621165
VectorAdd(pparams->vieworg, pparams->viewheight, pparams->vieworg);
1166+
1167+
// pushing the view origin down off of the same X/Z plane as the ent's origin will give the
1168+
// gun a very nice 'shifting' effect when the player looks up/down. If there is a problem
1169+
// with view model distortion, this may be a cause. (SJB).
1170+
view->origin[2] -= 1;
11631171
}
11641172
else
1173+
{
11651174
V_ApplyBob(pparams, view);
1166-
1167-
for (i = 0; i < 3; i++)
1168-
{
1169-
view->origin[i] += bob * 0.4 * pparams->forward[i];
1175+
V_CalcViewModelLag(pparams, view);
1176+
V_RetractWeapon(pparams, view);
1177+
V_Jump(pparams, view);
11701178
}
1171-
view->origin[2] += bob;
11721179

11731180
// throw in a little tilt.
1181+
/*
11741182
view->angles[YAW] -= bob * 0.5;
11751183
view->angles[ROLL] -= bob * 1;
11761184
view->angles[PITCH] -= bob * 0.3;
1185+
*/
11771186

11781187
VectorCopy(view->angles, view->curstate.angles);
11791188

1180-
// pushing the view origin down off of the same X/Z plane as the ent's origin will give the
1181-
// gun a very nice 'shifting' effect when the player looks up/down. If there is a problem
1182-
// with view model distortion, this may be a cause. (SJB).
1183-
if (cl_legacy_bob_enabled->value != 0)
1184-
view->origin[2] -= 1;
1185-
11861189
// fudge position around to keep amount of weapon visible
11871190
// roughly equal with different FOV
11881191
if (pparams->viewsize == 110)
@@ -1218,13 +1221,6 @@ void V_CalcNormalRefdef(struct ref_params_s* pparams)
12181221
view->angles = view->angles + ev_punchangle + sv_punchangle;
12191222
// view->curstate.angles = view->curstate.angles + ev_punchangle + Legacy_Vector(pparams->punchangle);
12201223

1221-
if (cl_legacy_bob_enabled->value <= 0)
1222-
{
1223-
V_CalcViewModelLag(pparams, view);
1224-
V_RetractWeapon(pparams, view);
1225-
V_Jump(pparams, view);
1226-
}
1227-
12281224
VectorAdd(pparams->viewangles, InvPitch(cl_jumpangle) / 3.0f, pparams->viewangles);
12291225
VectorAdd(view->angles, cl_jumpangle, view->angles);
12301226
VectorCopy(view->angles, view->curstate.angles);

0 commit comments

Comments
 (0)