diff --git a/src/p_saveg.c b/src/p_saveg.c index 8e2517473de63c166a1867518485495174b9fed9..6c6548c567f195cfc7bbc884e1e45dea18afde1a 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3221,6 +3221,8 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) slope->normal.x = READFIXED(save_p); slope->normal.y = READFIXED(save_p); slope->normal.z = READFIXED(save_p); + + slope->moved = true; } if (diff2 & MD2_DRAWONLYFORPLAYER) mobj->drawonlyforplayer = &players[READUINT8(save_p)]; diff --git a/src/p_slopes.c b/src/p_slopes.c index 72e643c8a20efa1bc43f8d24823aa238016419a2..e75d36edefe8d8484cb0c9bebb4d02d5f1b1e174 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -29,13 +29,14 @@ pslope_t *slopelist = NULL; UINT16 slopecount = 0; // Calculate line normal -void P_CalculateSlopeNormal(pslope_t *slope) { +void P_CalculateSlopeNormal(pslope_t *slope) +{ slope->normal.z = FINECOSINE(slope->zangle>>ANGLETOFINESHIFT); slope->normal.x = FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), slope->d.x); slope->normal.y = FixedMul(FINESINE(slope->zangle>>ANGLETOFINESHIFT), slope->d.y); } -static void CalculateVectors(pslope_t *slope, dvector3_t *dnormal) +static void CalculateNormalDir(pslope_t *slope, dvector3_t *dnormal) { double hyp = hypot(dnormal->x, dnormal->y); @@ -52,17 +53,14 @@ static void CalculateVectors(pslope_t *slope, dvector3_t *dnormal) } } -void P_RecalculateSlopeVectors(pslope_t *slope) +void P_CalculateSlopeVectors(pslope_t *slope) { dvector3_t dnormal; - dnormal.x = FixedToDouble(slope->normal.x); - dnormal.y = FixedToDouble(slope->normal.y); - dnormal.z = FixedToDouble(slope->normal.z); - + DVector3_Load(&dnormal, FixedToDouble(slope->normal.x), FixedToDouble(slope->normal.y), FixedToDouble(slope->normal.z)); DVector3_Load(&slope->dorigin, FixedToDouble(slope->o.x), FixedToDouble(slope->o.y), FixedToDouble(slope->o.z)); - CalculateVectors(slope, &dnormal); + CalculateNormalDir(slope, &dnormal); } /// Setup slope via 3 vertexes. @@ -121,7 +119,7 @@ static void ReconfigureViaVertexes (pslope_t *slope, const vector3_t v1, const v slope->zangle = InvAngle(R_PointToAngle2(0, 0, FRACUNIT, slope->zdelta)); } - P_RecalculateSlopeVectors(slope); + P_CalculateSlopeVectors(slope); } /// Setup slope via constants. @@ -173,7 +171,7 @@ static void ReconfigureViaConstants (pslope_t *slope, const double pa, const dou DVector3_Load(&slope->dorigin, 0, 0, d_o); - CalculateVectors(slope, &dnormal); + CalculateNormalDir(slope, &dnormal); } /// Recalculate dynamic slopes. @@ -212,8 +210,8 @@ void T_DynamicSlopeLine (dynlineplanethink_t* th) if (slope->zdelta != FixedDiv(zdelta, th->extent)) { slope->zdelta = FixedDiv(zdelta, th->extent); slope->zangle = R_PointToAngle2(0, 0, th->extent, -zdelta); + slope->moved = true; P_CalculateSlopeNormal(slope); - P_RecalculateSlopeVectors(slope); } } @@ -444,7 +442,7 @@ static void line_SpawnViaLine(const int linenum, const boolean spawnthinker) fslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y); P_CalculateSlopeNormal(fslope); - P_RecalculateSlopeVectors(fslope); + P_CalculateSlopeVectors(fslope); if (spawnthinker && (flags & SL_DYNAMIC)) P_AddDynLineSlopeThinker(fslope, DP_FRONTFLOOR, line, extent); @@ -462,7 +460,7 @@ static void line_SpawnViaLine(const int linenum, const boolean spawnthinker) cslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y); P_CalculateSlopeNormal(cslope); - P_RecalculateSlopeVectors(cslope); + P_CalculateSlopeVectors(cslope); if (spawnthinker && (flags & SL_DYNAMIC)) P_AddDynLineSlopeThinker(cslope, DP_FRONTCEIL, line, extent); @@ -503,7 +501,7 @@ static void line_SpawnViaLine(const int linenum, const boolean spawnthinker) fslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y); P_CalculateSlopeNormal(fslope); - P_RecalculateSlopeVectors(fslope); + P_CalculateSlopeVectors(fslope); if (spawnthinker && (flags & SL_DYNAMIC)) P_AddDynLineSlopeThinker(fslope, DP_BACKFLOOR, line, extent); @@ -521,7 +519,7 @@ static void line_SpawnViaLine(const int linenum, const boolean spawnthinker) cslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y); P_CalculateSlopeNormal(cslope); - P_RecalculateSlopeVectors(cslope); + P_CalculateSlopeVectors(cslope); if (spawnthinker && (flags & SL_DYNAMIC)) P_AddDynLineSlopeThinker(cslope, DP_BACKCEIL, line, extent); diff --git a/src/p_slopes.h b/src/p_slopes.h index 1a7e604b284b60ec0ceff3aa27ca764b3391450f..fdc07f67e257ba05eef35fc481c3be3a0ebdfd7c 100644 --- a/src/p_slopes.h +++ b/src/p_slopes.h @@ -51,7 +51,7 @@ typedef enum void P_LinkSlopeThinkers (void); void P_CalculateSlopeNormal(pslope_t *slope); -void P_RecalculateSlopeVectors(pslope_t *slope); +void P_CalculateSlopeVectors(pslope_t *slope); void P_InitSlopes(void); void P_SpawnSlopes(const boolean fromsave); diff --git a/src/r_defs.h b/src/r_defs.h index 4e03afd81032c15b9426898027aa4061f50bc066..6e0375e615aed5596e68eb67b113fe61a907e477 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -349,6 +349,8 @@ typedef struct pslope_s double dzdelta; + boolean moved : 1; + UINT8 flags; // Slope options } pslope_t; diff --git a/src/r_fps.c b/src/r_fps.c index dd43ca8d4ac681d06bf3fd12e07605622af92dd8..284d1005c01af38e673559c024e43d81cd3c854e 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -631,7 +631,7 @@ void R_ApplyLevelInterpolators(fixed_t frac) R_LerpVector3(&interp->dynslope.oldo, &interp->dynslope.bako, frac, &interp->dynslope.slope->o); R_LerpVector2(&interp->dynslope.oldd, &interp->dynslope.bakd, frac, &interp->dynslope.slope->d); interp->dynslope.slope->zdelta = R_LerpFixed(interp->dynslope.oldzdelta, interp->dynslope.bakzdelta, frac); - P_RecalculateSlopeVectors(interp->dynslope.slope); + interp->dynslope.slope->moved = true; break; } } diff --git a/src/r_plane.c b/src/r_plane.c index 1295b63ba54889ff2e23e3eb4c69e0b3a5899d86..11aa6c941ae916cfcd924d0ea55c20709f1f3081 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -699,6 +699,12 @@ void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, double height, z_at_xy; float ang; + if (slope->moved) + { + P_CalculateSlopeVectors(slope); + slope->moved = false; + } + R_SetSlopePlaneOrigin(slope, xpos, ypos, zpos, xoff, yoff, angle); height = R_GetSlopeZAt(slope, xpos, ypos); zeroheight = height - FixedToDouble(zpos); @@ -735,9 +741,14 @@ void R_SetSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, void R_SetScaledSlopePlane(pslope_t *slope, fixed_t xpos, fixed_t ypos, fixed_t zpos, fixed_t xs, fixed_t ys, fixed_t xoff, fixed_t yoff, angle_t angle, angle_t plangle) { double height, z_at_xy; - float ang; + if (slope->moved) + { + P_CalculateSlopeVectors(slope); + slope->moved = false; + } + R_SetSlopePlaneOrigin(slope, xpos, ypos, zpos, xoff, yoff, angle); height = R_GetSlopeZAt(slope, xpos, ypos); zeroheight = height - FixedToDouble(zpos);