From 2c676eea433f883b5812a6f712e189dab2fc9a49 Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Sun, 12 Jun 2016 19:27:34 +0100 Subject: [PATCH] P_ReverseQuantiseMomentumToSlope is now a function. (I was thinking about a macro, but couldn't get it down.) Also, the teetering angle on slopes is now FRACUNIT/2 because there's literally no way to stand still on a slope that steep unless it doesn't have physics. --- src/p_mobj.c | 5 +---- src/p_slopes.c | 18 ++++++++++++------ src/p_slopes.h | 1 + src/p_user.c | 10 +++------- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 843123d5..2cf94e83 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2377,10 +2377,7 @@ static boolean P_ZMovement(mobj_t *mo) if ((mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope) { mo->standingslope = (mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope; - // Reverse quantizing might could use its own function later - mo->standingslope->zangle = ANGLE_MAX-mo->standingslope->zangle; - P_QuantizeMomentumToSlope(&mom, mo->standingslope); - mo->standingslope->zangle = ANGLE_MAX-mo->standingslope->zangle; + P_ReverseQuantizeMomentumToSlope(&mom, mo->standingslope); } #endif diff --git a/src/p_slopes.c b/src/p_slopes.c index 8df94e75..d939fee9 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -767,6 +767,17 @@ void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) FV3_Rotate(momentum, &axis, slope->zangle >> ANGLETOFINESHIFT); } +// +// P_ReverseQuantizeMomentumToSlope +// +// When given a vector, rotates and aligns it to a flat surface (from being relative to a given slope) +void P_ReverseQuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) +{ + slope->zangle = InvAngle(slope->zangle); + P_QuantizeMomentumToSlope(momentum, slope); + slope->zangle = InvAngle(slope->zangle); +} + // // P_SlopeLaunch // @@ -810,12 +821,7 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) mom.y = thing->momy; mom.z = thing->momz*2; - //CONS_Printf("Landing on slope\n"); - - // Reverse quantizing might could use its own function later - slope->zangle = ANGLE_MAX-slope->zangle; - P_QuantizeMomentumToSlope(&mom, slope); - slope->zangle = ANGLE_MAX-slope->zangle; + P_ReverseQuantizeMomentumToSlope(&mom, slope); if (P_MobjFlip(thing)*mom.z < 0) { // falling, land on slope thing->momx = mom.x; diff --git a/src/p_slopes.h b/src/p_slopes.h index dd9b6f2d..de38f1d9 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -35,6 +35,7 @@ fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y); // Lots of physics-based bullshit void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope); +void P_ReverseQuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope); void P_SlopeLaunch(mobj_t *mo); void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope); void P_ButteredSlope(mobj_t *mo); diff --git a/src/p_user.c b/src/p_user.c index 49996679..7bf2b1f6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1851,12 +1851,8 @@ static void P_CheckBouncySectors(player_t *player) momentum.y = player->mo->momy; momentum.z = player->mo->momz*2; - if (slope) { - // Reverse quantizing might could use its own function later - slope->zangle = ANGLE_MAX-slope->zangle; - P_QuantizeMomentumToSlope(&momentum, slope); - slope->zangle = ANGLE_MAX-slope->zangle; - } + if (slope) + P_ReverseQuantizeMomentumToSlope(&momentum, slope); newmom = momentum.z = -FixedMul(momentum.z,linedist)/2; #else @@ -2856,7 +2852,7 @@ static void P_DoTeeter(player_t *player) fixed_t topheight, bottomheight; // for 3d floor usage const fixed_t tiptop = FixedMul(MAXSTEPMOVE, player->mo->scale); // Distance you have to be above the ground in order to teeter. -#define maxzdelta 3<<(FRACBITS-2) // 3/4 on the fixed scale +#define maxzdelta 1<<(FRACBITS-1) // 1/2 on the fixed scale if (player->mo->standingslope && player->mo->standingslope->zdelta >= maxzdelta) // Always teeter if the slope is too steep. teeter = true; #undef maxzdelta