Make sloperoll+pitch toggleable and make cameratilt not rely on sloperoll toggle

The toggle is handled in renderer for both gl and software!
This commit is contained in:
NepDisk 2025-03-11 22:48:02 -04:00
parent a55393bf4c
commit 52b532f265
8 changed files with 43 additions and 5 deletions

View file

@ -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",

View file

@ -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;
}
}

View file

@ -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;

View file

@ -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);

View file

@ -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)
{

View file

@ -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);

View file

@ -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 {

View file

@ -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;
}