diff --git a/src/p_local.h b/src/p_local.h index 6a4aa241c2f989d560f4753d69c842da5bb3459d..249c3cd4b6de5248140c00e2dfc2332081a5d00e 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -399,7 +399,6 @@ extern camera_t *mapcampointer; extern fixed_t tmx; extern fixed_t tmy; extern pslope_t *tmfloorslope, *tmceilingslope; -extern line_t *tmfloorline, *tmceilingline; /* cphipps 2004/08/30 */ extern void P_MapStart(void); diff --git a/src/p_map.c b/src/p_map.c index aeeeda056336768e0153b63a46d8fd252a9e07af..f97ddfa3cd8aa3fa9f7e9dbb3e6d76b041aca164 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -55,7 +55,6 @@ mobj_t *tmfloorthing; // the thing corresponding to tmfloorz or NULL if tmfloorz mobj_t *tmhitthing; // the solid thing you bumped into (for collisions) ffloor_t *tmfloorrover, *tmceilingrover; pslope_t *tmfloorslope, *tmceilingslope; -line_t *tmfloorline, *tmceilingline; // keep track of the line that lowers the ceiling, // so missiles don't explode against sky hack walls @@ -1761,7 +1760,6 @@ static unsigned PIT_DoCheckThing(mobj_t *thing) tmfloorz = thing->z + thing->height; tmfloorrover = NULL; tmfloorslope = NULL; - tmfloorline = NULL; } return CHECKTHING_COLLIDE; } @@ -1781,7 +1779,6 @@ static unsigned PIT_DoCheckThing(mobj_t *thing) tmfloorz = tmceilingz = topz; // block while in air tmceilingrover = NULL; tmceilingslope = NULL; - tmceilingline = NULL; tmfloorthing = thing; // needed for side collision collide = CHECKTHING_COLLIDE; @@ -1791,7 +1788,6 @@ static unsigned PIT_DoCheckThing(mobj_t *thing) tmceilingz = topz; tmceilingrover = NULL; tmceilingslope = NULL; - tmceilingline = NULL; tmfloorthing = thing; // thing we may stand on collide = CHECKTHING_COLLIDE; @@ -1809,7 +1805,6 @@ static unsigned PIT_DoCheckThing(mobj_t *thing) tmceilingz = thing->z; tmceilingrover = NULL; tmceilingslope = NULL; - tmceilingline = NULL; } return CHECKTHING_COLLIDE; } @@ -1829,7 +1824,6 @@ static unsigned PIT_DoCheckThing(mobj_t *thing) tmfloorz = tmceilingz = topz; // block while in air tmfloorrover = NULL; tmfloorslope = NULL; - tmfloorline = NULL; tmfloorthing = thing; // needed for side collision collide = CHECKTHING_COLLIDE; @@ -1839,7 +1833,6 @@ static unsigned PIT_DoCheckThing(mobj_t *thing) tmfloorz = topz; tmfloorrover = NULL; tmfloorslope = NULL; - tmfloorline = NULL; tmfloorthing = thing; // thing we may stand on collide = CHECKTHING_COLLIDE; @@ -2007,7 +2000,6 @@ static boolean PIT_CheckLine(line_t *ld) ceilingline = ld; tmceilingrover = openceilingrover; tmceilingslope = opentopslope; - tmceilingline = opentopline; } if (openbottom > tmfloorz) @@ -2015,7 +2007,6 @@ static boolean PIT_CheckLine(line_t *ld) tmfloorz = openbottom; tmfloorrover = openfloorrover; tmfloorslope = openbottomslope; - tmfloorline = openbottomline; } if (highceiling > tmdrpoffceilz) @@ -2066,8 +2057,6 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) tmceilingz = P_GetCeilingZ(thing, newsubsec->sector, x, y, NULL); //newsubsec->sector->ceilingheight; tmfloorrover = NULL; tmceilingrover = NULL; - tmfloorline = NULL; - tmceilingline = NULL; tmfloorslope = newsubsec->sector->f_slope; tmceilingslope = newsubsec->sector->c_slope; @@ -2653,8 +2642,6 @@ boolean PIT_PushableMoved(mobj_t *thing) ffloor_t *oldceilrover = tmceilingrover; pslope_t *oldfslope = tmfloorslope; pslope_t *oldcslope = tmceilingslope; - line_t *oldfline = tmfloorline; - line_t *oldcline = tmceilingline; // Move the player P_TryMove(thing, thing->x+stand->momx, thing->y+stand->momy, true); @@ -2671,8 +2658,6 @@ boolean PIT_PushableMoved(mobj_t *thing) tmceilingrover = oldceilrover; tmfloorslope = oldfslope; tmceilingslope = oldcslope; - tmfloorline = oldfline; - tmceilingline = oldcline; thing->momz = stand->momz; } else @@ -2914,12 +2899,11 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) // Assign thing's standingslope if needed if (thing->z <= tmfloorz && !(thing->eflags & MFE_VERTICALFLIP)) { if (!startingonground && tmfloorslope) - P_HandleSlopeLanding(thing, tmfloorslope, tmfloorline); + P_HandleSlopeLanding(thing, tmfloorslope); if (thing->momz <= 0) { thing->standingslope = tmfloorslope; - thing->standingline = tmfloorline; P_SetPitchRollFromSlope(thing, thing->standingslope); if (thing->momz == 0 && thing->player && !startingonground) @@ -2928,12 +2912,11 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) } else if (thing->z+thing->height >= tmceilingz && (thing->eflags & MFE_VERTICALFLIP)) { if (!startingonground && tmceilingslope) - P_HandleSlopeLanding(thing, tmceilingslope, tmceilingline); + P_HandleSlopeLanding(thing, tmceilingslope); if (thing->momz >= 0) { thing->standingslope = tmceilingslope; - thing->standingline = tmceilingline; P_SetPitchRollFromSlope(thing, thing->standingslope); if (thing->momz == 0 && thing->player && !startingonground) @@ -2941,12 +2924,8 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) } } } - else - { - // don't set standingslope or standingline if you're not going to clip against them + else // don't set standingslope if you're not going to clip against it thing->standingslope = NULL; - thing->standingline = NULL; - } thing->x = x; thing->y = y; diff --git a/src/p_maputl.c b/src/p_maputl.c index 7de5b5369061a3f4310e80c486d64a829a134da2..18a15a9282e7fc5d67975cb46012a820cbc44ccb 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -280,7 +280,6 @@ fixed_t P_InterceptVector(divline_t *v2, divline_t *v1) fixed_t opentop, openbottom, openrange, lowfloor, highceiling; pslope_t *opentopslope, *openbottomslope; ffloor_t *openfloorrover, *openceilingrover; -line_t *opentopline, *openbottomline; // P_CameraLineOpening // P_LineOpening, but for camera @@ -441,8 +440,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) I_Assert(back != NULL); openfloorrover = openceilingrover = NULL; - opentopline = openbottomline = NULL; - if (linedef->polyobj) { // set these defaults so that polyobjects don't interfere with collision above or below them @@ -547,7 +544,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if ((linedef->flags & ML_MIDPEG) != 0) { opentopslope = openbottomslope; } - opentopline = linedef; } } else { // Above if (openbottom < textop) { @@ -555,7 +551,6 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if ((linedef->flags & ML_MIDPEG) == 0) { openbottomslope = opentopslope; } - openbottomline = linedef; } } } diff --git a/src/p_maputl.h b/src/p_maputl.h index ca29fc20313871d7427305084ba954d28bd80d77..e894c08a2461caf82397c569549e5bd3213ae3b7 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -57,7 +57,6 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y); extern fixed_t opentop, openbottom, openrange, lowfloor, highceiling; extern pslope_t *opentopslope, *openbottomslope; extern ffloor_t *openfloorrover, *openceilingrover; -extern line_t *opentopline, *openbottomline; void P_LineOpening(line_t *plinedef, mobj_t *mobj); diff --git a/src/p_mobj.c b/src/p_mobj.c index 221149f700d502c3f91509dd819886d888b81f81..9cdd2628db8cfec3ee8af83a6f96b3713879b164 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1672,7 +1672,6 @@ void P_XYMovement(mobj_t *mo) fixed_t oldx, oldy; // reducing bobbing/momentum on ice when up against walls boolean moved; pslope_t *oldslope = NULL; - line_t *oldstandingline = NULL; vector3_t slopemom = {0,0,0}; fixed_t predictedz = 0; @@ -1705,10 +1704,7 @@ void P_XYMovement(mobj_t *mo) oldy = mo->y; if (mo->flags & MF_NOCLIPHEIGHT) - { mo->standingslope = NULL; - mo->standingline = NULL; - } // adjust various things based on slope if (mo->standingslope && abs(mo->standingslope->zdelta) > FRACUNIT>>8) { @@ -1720,7 +1716,7 @@ void P_XYMovement(mobj_t *mo) slopemom.x = xmove; slopemom.y = ymove; slopemom.z = 0; - P_QuantizeObjectMomentumToSlope(mo, &slopemom); + P_QuantizeMomentumToSlope(&slopemom, mo->standingslope); xmove = slopemom.x; ymove = slopemom.y; @@ -1728,7 +1724,6 @@ void P_XYMovement(mobj_t *mo) predictedz = mo->z + slopemom.z; // We'll use this later... oldslope = mo->standingslope; - oldstandingline = mo->standingline; } } else if (P_IsObjectOnGround(mo) && !mo->momz) predictedz = mo->z; @@ -1804,16 +1799,12 @@ void P_XYMovement(mobj_t *mo) { // try to slide along it // Wall transfer part 1. pslope_t *transferslope = NULL; - line_t *transferline = NULL; fixed_t transfermomz = 0; if (oldslope && (P_MobjFlip(mo)*(predictedz - mo->z) > 0)) // Only for moving up (relative to gravity), otherwise there's a failed launch when going down slopes and hitting walls { - angle_t zangle; transferslope = ((mo->standingslope) ? mo->standingslope : oldslope); - transferline = ((mo->standingline) ? mo->standingline : oldstandingline); - zangle = P_GetStandingSlopeZAngle(transferslope, transferline); - if (((zangle < ANGLE_180) ? zangle : InvAngle(zangle)) >= ANGLE_45) // Prevent some weird stuff going on on shallow slopes. - transfermomz = P_GetWallTransferMomZ(mo, transferslope, transferline); + if (((transferslope->zangle < ANGLE_180) ? transferslope->zangle : InvAngle(transferslope->zangle)) >= ANGLE_45) // Prevent some weird stuff going on on shallow slopes. + transfermomz = P_GetWallTransferMomZ(mo, transferslope); } P_SlideMove(mo); @@ -1826,7 +1817,7 @@ void P_XYMovement(mobj_t *mo) { angle_t relation; // Scale transfer momentum based on how head-on it is to the slope. if (mo->momx || mo->momy) // "Guess" the angle of the wall you hit using new momentum - relation = P_GetStandingSlopeDirection(transferslope, transferline) - R_PointToAngle2(0, 0, mo->momx, mo->momy); + relation = transferslope->xydirection - R_PointToAngle2(0, 0, mo->momx, mo->momy); else // Give it for free, I guess. relation = ANGLE_90; transfermomz = FixedMul(transfermomz, @@ -1835,7 +1826,6 @@ void P_XYMovement(mobj_t *mo) { mo->momz = transfermomz; mo->standingslope = NULL; - mo->standingline = NULL; if (player) { player->powers[pw_justlaunched] = 2; @@ -1885,7 +1875,7 @@ void P_XYMovement(mobj_t *mo) oldangle = FixedMul((signed)oldslope->zangle, FINECOSINE((moveangle - oldslope->xydirection) >> ANGLETOFINESHIFT)); if (mo->standingslope) - newangle = FixedMul((signed)P_GetObjectStandingSlopeZAngle(mo), FINECOSINE((moveangle - P_GetObjectStandingSlopeDirection(mo)) >> ANGLETOFINESHIFT)); + newangle = FixedMul((signed)mo->standingslope->zangle, FINECOSINE((moveangle - mo->standingslope->xydirection) >> ANGLETOFINESHIFT)); else newangle = 0; @@ -1909,7 +1899,7 @@ void P_XYMovement(mobj_t *mo) } } else if (moved && mo->standingslope && predictedz) { angle_t moveangle = R_PointToAngle2(0, 0, mo->momx, mo->momy); - angle_t newangle = FixedMul((signed)P_GetObjectStandingSlopeZAngle(mo), FINECOSINE((moveangle - P_GetObjectStandingSlopeDirection(mo)) >> ANGLETOFINESHIFT)); + angle_t newangle = FixedMul((signed)mo->standingslope->zangle, FINECOSINE((moveangle - mo->standingslope->xydirection) >> ANGLETOFINESHIFT)); /*CONS_Printf("flat to angle %f - predicted z of %f\n", FIXED_TO_FLOAT(AngleFixed(ANGLE_MAX-newangle)), @@ -2442,9 +2432,8 @@ 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; - mo->standingline = (mo->eflags & MFE_VERTICALFLIP) ? tmceilingline : tmfloorline; P_SetPitchRollFromSlope(mo, mo->standingslope); - P_ReverseQuantizeObjectMomentumToSlope(mo, &mom); + P_ReverseQuantizeMomentumToSlope(&mom, mo->standingslope); } // hit the floor @@ -2590,7 +2579,7 @@ boolean P_ZMovement(mobj_t *mo) mom.z = tmfloorthing->momz; if (mo->standingslope) { // MT_STEAM will never have a standingslope, see above. - P_QuantizeObjectMomentumToSlope(mo, &mom); + P_QuantizeMomentumToSlope(&mom, mo->standingslope); } mo->momx = mom.x; @@ -2836,9 +2825,7 @@ void P_PlayerZMovement(mobj_t *mo) if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope)) { // Handle landing on slope during Z movement - P_HandleSlopeLanding(mo, - (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope), - (mo->eflags & MFE_VERTICALFLIP ? tmceilingline : tmfloorline)); + P_HandleSlopeLanding(mo, (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope)); } if (P_MobjFlip(mo)*mo->momz < 0) // falling diff --git a/src/p_mobj.h b/src/p_mobj.h index ae4c5a51d3859aa3fb137daf0b5a3a58c9816f38..2f013a2f30fac7f7d117cb190fcbc5bd1db17e54 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -412,9 +412,7 @@ typedef struct mobj_s INT32 cusval; INT32 cvmem; - struct pslope_s *standingslope; // The slope that the object is standing on (shouldn't need synced in savegames, right?) (it does) - - struct line_s *standingline; // The line that the object is standing on + struct pslope_s *standingslope; // The slope that the object is standing on (shouldn't need synced in savegames, right?) boolean resetinterp; // if true, some fields should not be interpolated (see R_InterpolateMobjState implementation) boolean colorized; // Whether the mobj uses the rainbow colormap diff --git a/src/p_saveg.c b/src/p_saveg.c index 675d68acde6b25bdaacd98b4df813eec6f09a85c..5e4d6d0760441e6bc94c6815824b8b7e1ab38c80 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1746,8 +1746,7 @@ typedef enum MD2_DISPOFFSET = 1<<23, MD2_DRAWONLYFORPLAYER = 1<<24, MD2_DONTDRAWFORVIEWMOBJ = 1<<25, - MD2_TRANSLATION = 1<<26, - MD2_STANDINGLINE = 1<<27 + MD2_TRANSLATION = 1<<26 } mobj_diff2_t; typedef enum @@ -1954,8 +1953,6 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_CEILINGROVER; if (mobj->standingslope) diff2 |= MD2_SLOPE; - if (mobj->standingline) - diff2 |= MD2_STANDINGLINE; if (mobj->colorized) diff2 |= MD2_COLORIZED; if (mobj->mirrored) @@ -2128,8 +2125,6 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEUINT32(save_p, mobj->hprev->mobjnum); if (diff2 & MD2_SLOPE) WRITEUINT16(save_p, mobj->standingslope->id); - if (diff2 & MD2_STANDINGLINE) - WRITEUINT32(save_p, SaveLine(mobj->standingline)); if (diff2 & MD2_COLORIZED) WRITEUINT8(save_p, mobj->colorized); if (diff2 & MD2_MIRRORED) @@ -3186,8 +3181,6 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) mobj->hprev = (mobj_t *)(size_t)READUINT32(save_p); if (diff2 & MD2_SLOPE) mobj->standingslope = P_SlopeById(READUINT16(save_p)); - if (diff2 & MD2_STANDINGLINE) - mobj->standingline = LoadLine(READUINT32(save_p)); if (diff2 & MD2_COLORIZED) mobj->colorized = READUINT8(save_p); if (diff2 & MD2_MIRRORED) diff --git a/src/p_slopes.c b/src/p_slopes.c index 745be2eac4afa39c2ddaf4c383e84de77640ad3e..e75d36edefe8d8484cb0c9bebb4d02d5f1b1e174 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -859,10 +859,11 @@ fixed_t P_GetLightZAt(const lightlist_t *light, fixed_t x, fixed_t y) // When given a vector, rotates it and aligns it to a slope void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) { + vector3_t axis; // Fuck you, C90. + if (slope->flags & SL_NOPHYSICS) return; // No physics, no quantizing. - vector3_t axis; axis.x = -slope->d.y; axis.y = slope->d.x; axis.z = 0; @@ -876,91 +877,9 @@ void P_QuantizeMomentumToSlope(vector3_t *momentum, pslope_t *slope) // 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) { - if (slope->flags & SL_NOPHYSICS) - return; // No physics, no quantizing. - - vector3_t axis; - axis.x = -slope->d.y; - axis.y = slope->d.x; - axis.z = 0; - - FV3_Rotate(momentum, &axis, InvAngle(slope->zangle) >> ANGLETOFINESHIFT); -} - -angle_t P_GetStandingSlopeZAngle(pslope_t *slope, line_t *line) -{ - angle_t zangle = slope->zangle; - - if (line) - { - zangle = R_PointToAngle2(0, P_GetSlopeZAt(slope, line->v1->x, line->v1->y), - R_PointToDist2(line->v1->x, line->v1->y, line->v2->x, line->v2->y), P_GetSlopeZAt(slope, line->v2->x, line->v2->y)); - } - - return zangle; -} - -angle_t P_GetStandingSlopeDirection(pslope_t *slope, line_t *line) -{ - angle_t xydirection = slope->xydirection; - - if (line) - { - xydirection = R_PointToAngle2(line->v1->x, line->v1->y, line->v2->x, line->v2->y); - } - - return xydirection; -} - -angle_t P_GetObjectStandingSlopeZAngle(mobj_t *mo) -{ - return P_GetStandingSlopeZAngle(mo->standingslope, mo->standingline); -} - -angle_t P_GetObjectStandingSlopeDirection(mobj_t *mo) -{ - return P_GetStandingSlopeDirection(mo->standingslope, mo->standingline); -} - -static void QuantizeMomentumToSlope(pslope_t *slope, line_t *line, vector3_t *momentum, boolean reverse) -{ - if (!slope || slope->flags & SL_NOPHYSICS) - return; - - angle_t zangle = P_GetStandingSlopeZAngle(slope, line); - - if (reverse) - zangle = InvAngle(zangle); - - vector3_t axis; - axis.z = 0; - - if (line) - { - fixed_t len = R_PointToDist2(0, 0, line->dx, line->dy); - axis.x = FixedDiv(line->dy, len); - axis.y = -FixedDiv(line->dx, len); - } - else - { - axis.x = -slope->d.y; - axis.y = slope->d.x; - } - - FV3_Rotate(momentum, &axis, zangle >> ANGLETOFINESHIFT); -} - -// Given a vector of the object's momentum, rotates it and aligns it to the slope the object is standing on -void P_QuantizeObjectMomentumToSlope(mobj_t *mo, vector3_t *momentum) -{ - QuantizeMomentumToSlope(mo->standingslope, mo->standingline, momentum, false); -} - -// Given a vector of the object's momentum, rotates and aligns it to a flat surface -// (from being relative to the slope the object is standing on) -void P_ReverseQuantizeObjectMomentumToSlope(mobj_t *mo, vector3_t *momentum) -{ - QuantizeMomentumToSlope(mo->standingslope, mo->standingline, momentum, true); + slope->zangle = InvAngle(slope->zangle); + P_QuantizeMomentumToSlope(momentum, slope); + slope->zangle = InvAngle(slope->zangle); } // @@ -980,7 +899,7 @@ void P_SlopeLaunch(mobj_t *mo) slopemom.x = mo->momx; slopemom.y = mo->momy; slopemom.z = mo->momz*2; - P_QuantizeObjectMomentumToSlope(mo, &slopemom); + P_QuantizeMomentumToSlope(&slopemom, mo->standingslope); mo->momx = slopemom.x; mo->momy = slopemom.y; @@ -1000,7 +919,7 @@ void P_SlopeLaunch(mobj_t *mo) // It would be nice to have a single function that does everything necessary for slope-to-wall transfer. // However, it needs to be seperated out in P_XYMovement to take into account momentum before and after hitting the wall. // This just performs the necessary calculations for getting the base vertical momentum; the horizontal is already reasonably calculated by P_SlideMove. -fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope, line_t *line) +fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope) { vector3_t slopemom, axis; angle_t ang; @@ -1008,30 +927,18 @@ fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope, line_t *line) if (slope->flags & SL_NOPHYSICS) return 0; - angle_t zangle = P_GetStandingSlopeZAngle(slope, line); - // If there's physics, time for launching. // Doesn't kill the vertical momentum as much as P_SlopeLaunch does. - ang = zangle + ANG15*((zangle > 0) ? 1 : -1); + ang = slope->zangle + ANG15*((slope->zangle > 0) ? 1 : -1); if (ang > ANGLE_90 && ang < ANGLE_180) - ang = ((zangle > 0) ? ANGLE_90 : InvAngle(ANGLE_90)); // hard cap of directly upwards + ang = ((slope->zangle > 0) ? ANGLE_90 : InvAngle(ANGLE_90)); // hard cap of directly upwards slopemom.x = mo->momx; slopemom.y = mo->momy; slopemom.z = 3*(mo->momz/2); - if (line) - { - fixed_t len = R_PointToDist2(0, 0, line->dx, line->dy); - axis.x = FixedDiv(line->dy, len); - axis.y = -FixedDiv(line->dx, len); - } - else - { - axis.x = -slope->d.y; - axis.y = slope->d.x; - } - + axis.x = -slope->d.y; + axis.y = slope->d.x; axis.z = 0; FV3_Rotate(&slopemom, &axis, ang >> ANGLETOFINESHIFT); @@ -1040,7 +947,7 @@ fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope, line_t *line) } // Function to help handle landing on slopes -void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope, line_t *line) +void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope) { vector3_t mom; // Ditto. if (slope->flags & SL_NOPHYSICS || (slope->normal.x == 0 && slope->normal.y == 0)) { // No physics, no need to make anything complicated. @@ -1059,13 +966,12 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope, line_t *line) mom.y = thing->momy; mom.z = thing->momz*2; - QuantizeMomentumToSlope(slope, line, &mom, true); + P_ReverseQuantizeMomentumToSlope(&mom, slope); if (P_MobjFlip(thing)*mom.z < 0) { // falling, land on slope thing->momx = mom.x; thing->momy = mom.y; thing->standingslope = slope; - thing->standingline = line; P_SetPitchRollFromSlope(thing, slope); if (!thing->player || !(thing->player->pflags & PF_BOUNCING)) thing->momz = -P_MobjFlip(thing); @@ -1077,7 +983,6 @@ void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope, line_t *line) void P_ButteredSlope(mobj_t *mo) { fixed_t thrust; - angle_t zangle, xydirection; if (!mo->standingslope) return; @@ -1096,15 +1001,12 @@ void P_ButteredSlope(mobj_t *mo) return; // Allow the player to stand still on slopes below a certain steepness } - zangle = P_GetStandingSlopeZAngle(mo->standingslope, mo->standingline); - xydirection = P_GetStandingSlopeDirection(mo->standingslope, mo->standingline); - - thrust = FINESINE(zangle>>ANGLETOFINESHIFT) * 3 / 2 * (mo->eflags & MFE_VERTICALFLIP ? 1 : -1); + thrust = FINESINE(mo->standingslope->zangle>>ANGLETOFINESHIFT) * 3 / 2 * (mo->eflags & MFE_VERTICALFLIP ? 1 : -1); if (mo->player && (mo->player->pflags & PF_SPINNING)) { fixed_t mult = 0; if (mo->momx || mo->momy) { - angle_t angle = R_PointToAngle2(0, 0, mo->momx, mo->momy) - xydirection; + angle_t angle = R_PointToAngle2(0, 0, mo->momx, mo->momy) - mo->standingslope->xydirection; if (P_MobjFlip(mo) * mo->standingslope->zdelta < 0) angle ^= ANGLE_180; @@ -1125,5 +1027,5 @@ void P_ButteredSlope(mobj_t *mo) // ... and its friction against the ground for good measure (divided by original friction to keep behaviour for normal slopes the same). thrust = FixedMul(thrust, FixedDiv(mo->friction, ORIG_FRICTION)); - P_Thrust(mo, xydirection, thrust); + P_Thrust(mo, mo->standingslope->xydirection, thrust); } diff --git a/src/p_slopes.h b/src/p_slopes.h index f33053ac1f1ea565401987c83e0e4c974e01098b..fdc07f67e257ba05eef35fc481c3be3a0ebdfd7c 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -84,15 +84,9 @@ fixed_t P_GetLightZAt(const lightlist_t *light, 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_QuantizeObjectMomentumToSlope(mobj_t *mo, vector3_t *momentum); -void P_ReverseQuantizeObjectMomentumToSlope(mobj_t *mo, vector3_t *momentum); -angle_t P_GetStandingSlopeZAngle(pslope_t *slope, line_t *line); -angle_t P_GetStandingSlopeDirection(pslope_t *slope, line_t *line); -angle_t P_GetObjectStandingSlopeZAngle(mobj_t *mo); -angle_t P_GetObjectStandingSlopeDirection(mobj_t *mo); void P_SlopeLaunch(mobj_t *mo); -fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope, line_t *line); -void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope, line_t *line); +fixed_t P_GetWallTransferMomZ(mobj_t *mo, pslope_t *slope); +void P_HandleSlopeLanding(mobj_t *thing, pslope_t *slope); void P_ButteredSlope(mobj_t *mo); pslope_t *P_MakeSlopeViaEquationConstants(const double a, const double b, const double c, const double d); diff --git a/src/p_user.c b/src/p_user.c index 1782c5386e90ffd8f15e0e3f550cf8c13e206e30..7cd128cf080792f64df4a56ca4aeb4e9076e6b94 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6257,15 +6257,15 @@ static void P_3dMovement(player_t *player) && player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) && abs(player->mo->standingslope->zdelta) > FRACUNIT/2) { // Factor thrust to slope, but only for the part pushing up it! // The rest is unaffected. - angle_t thrustangle = R_PointToAngle2(0, 0, totalthrust.x, totalthrust.y)-P_GetObjectStandingSlopeDirection(player->mo); + angle_t thrustangle = R_PointToAngle2(0, 0, totalthrust.x, totalthrust.y)-player->mo->standingslope->xydirection; if (player->mo->standingslope->zdelta < 0) { // Direction goes down, so thrustangle needs to face toward if (thrustangle < ANGLE_90 || thrustangle > ANGLE_270) { - P_QuantizeObjectMomentumToSlope(player->mo, &totalthrust); + P_QuantizeMomentumToSlope(&totalthrust, player->mo->standingslope); } } else { // Direction goes up, so thrustangle needs to face away if (thrustangle > ANGLE_90 && thrustangle < ANGLE_270) { - P_QuantizeObjectMomentumToSlope(player->mo, &totalthrust); + P_QuantizeMomentumToSlope(&totalthrust, player->mo->standingslope); } } }