diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index eab532d9e..6d826e3bb 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -32,6 +32,8 @@ enum mobj_e { mobj_angle, mobj_pitch, mobj_roll, + mobj_slopepitch, + mobj_sloperoll, mobj_rollangle, mobj_sprite, mobj_frame, @@ -117,6 +119,8 @@ static const char *const mobj_opt[] = { "angle", "pitch", "roll", + "slopepitch", + "sloperoll", "rollangle", "sprite", "frame", diff --git a/src/p_mobj.c b/src/p_mobj.c index dc2c82439..f533d63ca 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1290,12 +1290,12 @@ void P_SetPitchRollFromSlope(mobj_t *mo, pslope_t *slope) fixed_t tempy = slope->normal.y; fixed_t tempx = slope->normal.x; - mo->pitch = R_PointToAngle2(0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx); - mo->roll = R_PointToAngle2(0, 0, tempz, tempy); + mo->slopepitch = R_PointToAngle2(0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx); + mo->sloperoll = R_PointToAngle2(0, 0, tempz, tempy); } else { - mo->pitch = mo->roll = 0; + mo->slopepitch = mo->sloperoll = 0; } } diff --git a/src/p_mobj.h b/src/p_mobj.h index cdd0ba610..58477770c 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -294,6 +294,7 @@ struct mobj_t // More drawing info: to determine current sprite. angle_t angle, pitch, roll; // orientation + angle_t slopepitch, sloperoll; angle_t old_angle, old_pitch, old_roll; // orientation interpolation angle_t old_angle2, old_pitch2, old_roll2; angle_t rollangle; diff --git a/src/p_saveg.c b/src/p_saveg.c index c5b7d7feb..1b297244b 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3735,6 +3735,10 @@ static thinker_t* LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker) mobj->terrain = NULL; } + // Reset some non-synch values + mobj->sloperoll = 0; + mobj->slopepitch = 0; + // set sprev, snext, bprev, bnext, subsector P_SetThingPosition(mobj); diff --git a/src/p_user.c b/src/p_user.c index f995b863d..0f2c785b7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4105,6 +4105,21 @@ Quaketilt (player_t *player) return moma; } +static angle_t P_GetCameraPitchRollAngle(mobj_t *mobj, player_t *viewPlayer) +{ + angle_t viewingAngle = R_PointToAnglePlayer(viewPlayer, mobj->x, mobj->y); + + fixed_t pitchMul = -FINESINE(viewingAngle >> ANGLETOFINESHIFT); + fixed_t rollMul = FINECOSINE(viewingAngle >> ANGLETOFINESHIFT); + + angle_t sloperolll = mobj->slopepitch; + angle_t slopepitch = mobj->sloperoll; + + angle_t rollOrPitch = FixedMul(mobj->pitch + sloperolll, pitchMul) + FixedMul(mobj->roll + slopepitch, rollMul); + + return rollOrPitch; +} + static void DoABarrelRoll (player_t *player) { @@ -4129,7 +4144,7 @@ DoABarrelRoll (player_t *player) return; } - slope = InvAngle(R_GetPitchRollAngle(player->mo, player)); + slope = InvAngle(P_GetCameraPitchRollAngle(player->mo, player)); if (AbsAngle(slope) < ANGLE_11hh) { diff --git a/src/r_main.cpp b/src/r_main.cpp index 02577f964..f80181fc4 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -193,6 +193,8 @@ consvar_t cv_maxportals = CVAR_INIT ("maxportals", "2", CV_SAVE, maxportals_cons consvar_t cv_renderstats = CVAR_INIT ("renderstats", "Off", 0, CV_OnOff, NULL); +consvar_t cv_sloperoll = CVAR_INIT ("spritesloperoll", "On", CV_SAVE, CV_OnOff, NULL); + void SplitScreen_OnChange(void) { UINT8 i; @@ -1826,6 +1828,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_tilting); CV_RegisterVar(&cv_actionmovie); CV_RegisterVar(&cv_windowquake); + CV_RegisterVar(&cv_sloperoll); CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); diff --git a/src/r_main.h b/src/r_main.h index fbf3484f2..762095bff 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -156,6 +156,8 @@ extern consvar_t cv_skybox; extern consvar_t cv_tailspickup; extern consvar_t cv_debugfinishline; +extern consvar_t cv_sloperoll; + // debugging typedef enum { diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c index 2051d5ca0..7ecfe3ee7 100644 --- a/src/r_patchrotation.c +++ b/src/r_patchrotation.c @@ -28,7 +28,16 @@ angle_t R_GetPitchRollAngle(mobj_t *mobj, player_t *viewPlayer) fixed_t pitchMul = -FINESINE(viewingAngle >> ANGLETOFINESHIFT); fixed_t rollMul = FINECOSINE(viewingAngle >> ANGLETOFINESHIFT); - angle_t rollOrPitch = FixedMul(mobj->pitch, pitchMul) + FixedMul(mobj->roll, rollMul); + angle_t sloperolll = mobj->slopepitch; + angle_t slopepitch = mobj->sloperoll; + + if (!cv_sloperoll.value) + { + sloperolll = 0; + slopepitch = 0; + } + + angle_t rollOrPitch = FixedMul(mobj->pitch + sloperolll, pitchMul) + FixedMul(mobj->roll + slopepitch, rollMul); return rollOrPitch; }