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.
This commit is contained in:
toasterbabe 2016-06-12 19:27:34 +01:00
parent 9e87f6d85d
commit 2c676eea43
4 changed files with 17 additions and 17 deletions

View file

@ -2377,10 +2377,7 @@ static boolean P_ZMovement(mobj_t *mo)
if ((mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope) { if ((mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope) {
mo->standingslope = (mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope; mo->standingslope = (mo->eflags & MFE_VERTICALFLIP) ? tmceilingslope : tmfloorslope;
// Reverse quantizing might could use its own function later P_ReverseQuantizeMomentumToSlope(&mom, mo->standingslope);
mo->standingslope->zangle = ANGLE_MAX-mo->standingslope->zangle;
P_QuantizeMomentumToSlope(&mom, mo->standingslope);
mo->standingslope->zangle = ANGLE_MAX-mo->standingslope->zangle;
} }
#endif #endif

View file

@ -767,6 +767,17 @@ void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope)
FV3_Rotate(momentum, &axis, slope->zangle >> ANGLETOFINESHIFT); 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 // P_SlopeLaunch
// //
@ -810,12 +821,7 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope)
mom.y = thing->momy; mom.y = thing->momy;
mom.z = thing->momz*2; mom.z = thing->momz*2;
//CONS_Printf("Landing on slope\n"); P_ReverseQuantizeMomentumToSlope(&mom, slope);
// 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;
if (P_MobjFlip(thing)*mom.z < 0) { // falling, land on slope if (P_MobjFlip(thing)*mom.z < 0) { // falling, land on slope
thing->momx = mom.x; thing->momx = mom.x;

View file

@ -35,6 +35,7 @@ fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y);
// Lots of physics-based bullshit // Lots of physics-based bullshit
void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope); 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_SlopeLaunch(mobj_t *mo);
void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope); void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope);
void P_ButteredSlope(mobj_t *mo); void P_ButteredSlope(mobj_t *mo);

View file

@ -1851,12 +1851,8 @@ static void P_CheckBouncySectors(player_t *player)
momentum.y = player->mo->momy; momentum.y = player->mo->momy;
momentum.z = player->mo->momz*2; momentum.z = player->mo->momz*2;
if (slope) { if (slope)
// Reverse quantizing might could use its own function later P_ReverseQuantizeMomentumToSlope(&momentum, slope);
slope->zangle = ANGLE_MAX-slope->zangle;
P_QuantizeMomentumToSlope(&momentum, slope);
slope->zangle = ANGLE_MAX-slope->zangle;
}
newmom = momentum.z = -FixedMul(momentum.z,linedist)/2; newmom = momentum.z = -FixedMul(momentum.z,linedist)/2;
#else #else
@ -2856,7 +2852,7 @@ static void P_DoTeeter(player_t *player)
fixed_t topheight, bottomheight; // for 3d floor usage 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. 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. if (player->mo->standingslope && player->mo->standingslope->zdelta >= maxzdelta) // Always teeter if the slope is too steep.
teeter = true; teeter = true;
#undef maxzdelta #undef maxzdelta