diff --git a/src/g_game.c b/src/g_game.c index bbe6e7374ca74d1d2a84e41e9615d3789b26b5ce..6867f925cafdff81ba915b4d01a3478d8483fe59 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -414,6 +414,8 @@ consvar_t cv_firenaxis2 = CVAR_INIT ("joyaxis2_firenormal", "Z-Axis", NULL, CV_S consvar_t cv_deadzone2 = CVAR_INIT ("joy_deadzone2", "0.125", "How far a joystick have to be pushed before it registers any input", CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL); consvar_t cv_digitaldeadzone2 = CVAR_INIT ("joy_digdeadzone2", "0.25", NULL, CV_FLOAT|CV_SAVE, zerotoone_cons_t, NULL); +consvar_t cv_sloperoll = CVAR_INIT ("sloperoll", "Off", "Rotate sprites/models of objects on sloped surfaces", CV_SAVE, CV_OnOff, NULL); + player_t *seenplayer; // player we're aiming at right now // now automatically allocated in D_RegisterClientCommands diff --git a/src/g_game.h b/src/g_game.h index f72ea6b41b1b29b4b263b9039c0ad588bc78de17..258c8c27c764a367d76ce9bffcd60e55af19d900 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -61,6 +61,8 @@ extern consvar_t cv_invertmouse2, cv_alwaysfreelook2, cv_chasefreelook2, cv_mous extern consvar_t cv_useranalog[2], cv_analog[2]; extern consvar_t cv_directionchar[2]; +extern consvar_t cv_sloperoll; + typedef enum { CS_LEGACY, CS_LMAOGALOG, diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 397dcdfba212a7b2c8b2f6e8ba2866052bc63cc7..8c48cfab6831156dc319478fa698113c34ea7496 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1692,13 +1692,8 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) } } -#if 0 p.anglez = FIXED_TO_FLOAT(AngleFixed(interp.pitch)); p.anglex = FIXED_TO_FLOAT(AngleFixed(interp.roll)); -#else - p.anglez = 0.f; - p.anglex = 0.f; -#endif p.flip = atransform.flip; p.mirror = atransform.mirror; diff --git a/src/p_local.h b/src/p_local.h index 6123e001e907d58929ef04539136ec6eea4afd91..be7e2a6b88b99fcc770631fdc0c2bfb7d0f68763 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -115,6 +115,8 @@ extern consvar_t cv_cam_speed, cv_cam_rotate, cv_cam_rotspeed, cv_cam_turnmultip extern consvar_t cv_cam2_dist, cv_cam2_still, cv_cam2_height; extern consvar_t cv_cam2_speed, cv_cam2_rotate, cv_cam2_rotspeed, cv_cam2_turnmultiplier, cv_cam2_orbit, cv_cam2_adjust; +extern consvar_t cv_viewroll; + extern consvar_t cv_cam_savedist[2][2], cv_cam_saveheight[2][2]; void CV_UpdateCamDist(void); void CV_UpdateCam2Dist(void); @@ -553,6 +555,7 @@ void P_DoSuperTransformation(player_t *player, boolean giverings); void P_DoSuperDetransformation(player_t *player); void P_ExplodeMissile(mobj_t *mo); void P_CheckGravity(mobj_t *mo, boolean affect); -void P_SetPitchRollFromSlope(mobj_t *mo, pslope_t *slope); +void P_SetPitchRollFromSlope(player_t *player, pslope_t *slope); +void P_ResetPitchRoll(mobj_t *mo); #endif // __P_LOCAL__ diff --git a/src/p_map.c b/src/p_map.c index 849249bf5fd0d0db8fac352d629e20cac8bb447c..13cfabd2c3ae25a1fa087a1393181fc56b8a510e 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2900,7 +2900,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (thing->momz <= 0) { thing->standingslope = tmfloorslope; - P_SetPitchRollFromSlope(thing, thing->standingslope); + //P_SetPitchRollFromSlope(thing, thing->standingslope); if (thing->momz == 0 && thing->player && !startingonground) P_PlayerHitFloor(thing->player, true); @@ -2913,7 +2913,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (thing->momz >= 0) { thing->standingslope = tmceilingslope; - P_SetPitchRollFromSlope(thing, thing->standingslope); + //P_SetPitchRollFromSlope(thing, thing->standingslope); if (thing->momz == 0 && thing->player && !startingonground) P_PlayerHitFloor(thing->player, true); diff --git a/src/p_mobj.c b/src/p_mobj.c index fd5d6f8924b08bc755a2f5189564dd260527076c..d5a98c97cfe03df5d5469d8c44fb4c081d3025ae 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1440,28 +1440,33 @@ void P_CheckGravity(mobj_t *mo, boolean affect) // // P_SetPitchRollFromSlope // -void P_SetPitchRollFromSlope(mobj_t *mo, pslope_t *slope) +void P_SetPitchRollFromSlope(player_t *player, pslope_t *slope) { -#if 0 - if (slope) + if (slope && cv_sloperoll.value) { fixed_t tempz = slope->normal.z; 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); + player->mo->pitch = R_PointToAngle2(0, 0, FixedSqrt(FixedMul(tempy, tempy) + FixedMul(tempz, tempz)), tempx); + player->mo->roll = R_PointToAngle2(0, 0, tempz, tempy); } else { - mo->pitch = mo->roll = 0; + P_ResetPitchRoll(player->mo); } -#else - (void)mo; - (void)slope; -#endif } +// +// P_ResetPitchRoll +// +void P_ResetPitchRoll(mobj_t *mo) +{ + mo->pitch = 0; + mo->roll = 0; +} + + #define STOPSPEED (FRACUNIT) // @@ -1895,7 +1900,7 @@ void P_XYMovement(mobj_t *mo) // Now compare the Zs of the different quantizations if (oldangle-newangle > ANG30 && oldangle-newangle < ANGLE_180) { // Allow for a bit of sticking - this value can be adjusted later mo->standingslope = oldslope; - P_SetPitchRollFromSlope(mo, mo->standingslope); + //P_SetPitchRollFromSlope(mo, mo->standingslope); P_SlopeLaunch(mo); //CONS_Printf("launched off of slope - "); @@ -2445,7 +2450,7 @@ boolean P_ZMovement(mobj_t *mo) if (((mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope) && (mo->type != MT_STEAM)) { mo->standingslope = (mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope; - P_SetPitchRollFromSlope(mo, mo->standingslope); + //P_SetPitchRollFromSlope(mo, mo->standingslope); P_ReverseQuantizeMomentumToSlope(&mom, mo->standingslope); } @@ -6700,6 +6705,10 @@ static boolean P_ShieldLook(mobj_t *thing, shieldtype_t shield) } P_SetThingPosition(thing); P_CheckPosition(thing, thing->x, thing->y); + + thing->pitch = thing->target->pitch; + thing->roll = thing->target->roll; + #undef NewMH #undef NewPH #undef OldMH diff --git a/src/p_slopes.c b/src/p_slopes.c index e7d084e690f71ff56f4692b04db64e1bc29b167f..a78d5c46f75c2eb39323b91da42a666511b242d4 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -1099,7 +1099,7 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) if (P_MobjFlip(thing)*(thing->momz) < 0) // falling, land on slope { thing->standingslope = slope; - P_SetPitchRollFromSlope(thing, slope); + //P_SetPitchRollFromSlope(thing, slope); if (!thing->player || !(thing->player->pflags & PF_BOUNCING)) thing->momz = -P_MobjFlip(thing); @@ -1117,7 +1117,7 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) thing->momx = mom.x; thing->momy = mom.y; thing->standingslope = slope; - P_SetPitchRollFromSlope(thing, slope); + //P_SetPitchRollFromSlope(thing, slope); if (!thing->player || !(thing->player->pflags & PF_BOUNCING)) thing->momz = -P_MobjFlip(thing); } diff --git a/src/p_user.c b/src/p_user.c index e1edeca8b2438affaf51ab0b9f2c00aa531fcaa3..5a812a7e4bc6cb1b839f534fc45b1c34f95ab79c 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1117,6 +1117,10 @@ void P_ResetPlayer(player_t *player) player->skidtime = 0; if (player-players == consoleplayer && botingame) CV_SetValue(&cv_analog[1], true); + if (player->mo != NULL && P_MobjWasRemoved(player->mo) == false) + { + P_ResetPitchRoll(player->mo); + } } // P_PlayerCanDamage @@ -9849,6 +9853,8 @@ consvar_t cv_cam2_turnmultiplier = CVAR_INIT ("cam2_turnmultiplier", "0.75", NUL consvar_t cv_cam2_orbit = CVAR_INIT ("cam2_orbit", "Off", "If enabled, vertical camera movement will rotate around the player character rather than staying in place", CV_SAVE|CV_ALLOWLUA, CV_OnOff, NULL); consvar_t cv_cam2_adjust = CVAR_INIT ("cam2_adjust", "On", "Adjust camera angle relative to the slope the player is on", CV_SAVE|CV_ALLOWLUA, CV_OnOff, NULL); +consvar_t cv_viewroll = CVAR_INIT ("viewroll", "Off", "Tilt camera on sloped surfaces", CV_SAVE, CV_OnOff, NULL);; + // [standard vs simple][p1 or p2] consvar_t cv_cam_savedist[2][2] = { { // standard @@ -11512,6 +11518,9 @@ void P_DoTailsOverlay(player_t *player, mobj_t *tails) tails->flags2 |= MF2_SHADOW; else tails->flags2 &= ~MF2_SHADOW; + + tails->pitch = player->mo->pitch; + tails->roll = player->mo->roll; } // Metal Sonic's jet fume @@ -11735,6 +11744,40 @@ void P_DoFollowMobj(player_t *player, mobj_t *followmobj) } } + + +static void +DoABarrelRoll (player_t *player) +{ + angle_t slope; + angle_t delta; + + if (player->mo->standingslope) + { + slope = player->mo->standingslope->zangle; + } + else + { + slope = 0; + } + + + if (player->mo->standingslope && cv_viewroll.value && (abs((INT32)slope) > ANGLE_11hh)) + { + delta = ( player->mo->angle - player->mo->standingslope->xydirection ); + slope = -(FixedMul(FINESINE (delta>>ANGLETOFINESHIFT), slope)); + } + else + slope = 0; + + delta = (INT32)( slope - player->viewrollangle )/ 16; + + if (delta) + player->viewrollangle += delta; + else + player->viewrollangle = slope; +} + // // P_PlayerThink // @@ -12664,6 +12707,8 @@ void P_PlayerThink(player_t *player) I_Error("I'm done!\n"); }*/ + DoABarrelRoll(player); + P_SetPitchRollFromSlope(player, player->mo->standingslope); } // Checks if the mobj is above lava. Used by Pterabyte. diff --git a/src/r_main.c b/src/r_main.c index 133c1862a3f4b628a9ef73799d48779cd6686792..d724db8ec50460023f62aa5bf3259aa1bc186ac5 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1734,6 +1734,10 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_cam_saveheight[1][0]); CV_RegisterVar(&cv_cam_saveheight[1][1]); + CV_RegisterVar(&cv_viewroll); + + CV_RegisterVar(&cv_sloperoll); + CV_RegisterVar(&cv_showhud); CV_RegisterVar(&cv_translucenthud); diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c index 989665d74179854fcfac552814132671c3d00ed2..6fb8783369dfd4ac08e8cd994bf495ecc2381170 100644 --- a/src/r_patchrotation.c +++ b/src/r_patchrotation.c @@ -26,7 +26,6 @@ angle_t R_ModelRotationAngle(interpmobjstate_t *interp) angle_t R_SpriteRotationAngle(interpmobjstate_t *interp) { -#if 0 angle_t viewingAngle = R_PointToAngle(interp->x, interp->y); fixed_t pitchMul = -FINESINE(viewingAngle >> ANGLETOFINESHIFT); @@ -35,9 +34,6 @@ angle_t R_SpriteRotationAngle(interpmobjstate_t *interp) angle_t rollOrPitch = FixedMul(interp->pitch, pitchMul) + FixedMul(interp->roll, rollMul); return (rollOrPitch + R_ModelRotationAngle(interp)); -#else - return R_ModelRotationAngle(interp); -#endif } INT32 R_GetRollAngle(angle_t rollangle)