Make tilting work even on no physics slopes

This commit is contained in:
James R authored and Galactice committed 2022-11-08 10:42:37 -05:00
1 parent 43678ddcfe
commit 459d73ad86
4 files changed
+39 -13

No files matched your search

+3
View File
@@ -1341,6 +1341,7 @@ static int slope_set(lua_State *L)
case slope_zdelta: { // zdelta, this is temp until i figure out wtf to do
slope->zdelta = luaL_checkfixed(L, 3);
slope->zangle = R_PointToAngle2(0, 0, FRACUNIT, -slope->zdelta);
slope->real_zangle = slope->zangle;
P_CalculateSlopeNormal(slope);
break;
}
@@ -1349,12 +1350,14 @@ static int slope_set(lua_State *L)
if (zangle == ANGLE_90 || zangle == ANGLE_270)
return luaL_error(L, "invalid zangle for slope!");
slope->zangle = zangle;
slope->real_zangle = slope->zangle;
slope->zdelta = -FINETANGENT(((slope->zangle+ANGLE_90)>>ANGLETOFINESHIFT) & 4095);
P_CalculateSlopeNormal(slope);
break;
}
case slope_xydirection: // xydirection
slope->xydirection = luaL_checkangle(L, 3);
slope->real_xydirection = slope->xydirection;
slope->d.x = -FINECOSINE((slope->xydirection>>ANGLETOFINESHIFT) & FINEMASK);
slope->d.y = -FINESINE((slope->xydirection>>ANGLETOFINESHIFT) & FINEMASK);
P_CalculateSlopeNormal(slope);
+30 -11
View File
@@ -39,6 +39,8 @@ static void P_ReconfigureVertexSlope(pslope_t *slope)
{
vector3_t vec1, vec2;
fixed_t extent;
// Set slope normal
vec1.x = (slope->vertices[1]->x - slope->vertices[0]->x) << FRACBITS;
vec1.y = (slope->vertices[1]->y - slope->vertices[0]->y) << FRACBITS;
@@ -75,21 +77,25 @@ static void P_ReconfigureVertexSlope(pslope_t *slope)
slope->o.y = slope->vertices[0]->y << FRACBITS;
slope->o.z = slope->vertices[0]->z << FRACBITS;
// Get direction vector
extent = R_PointToDist2(0, 0, slope->normal.x, slope->normal.y);
slope->d.x = -FixedDiv(slope->normal.x, extent);
slope->d.y = -FixedDiv(slope->normal.y, extent);
// Z delta
slope->zdelta = FixedDiv(extent, slope->normal.z);
// Get angles
slope->real_xydirection = R_PointToAngle2(0, 0, slope->d.x, slope->d.y)+ANGLE_180;
slope->real_zangle = InvAngle(R_PointToAngle2(0, 0, FRACUNIT, slope->zdelta));
if (slope->normal.x == 0 && slope->normal.y == 0) { // Set some defaults for a non-sloped "slope"
slope->zangle = slope->xydirection = 0;
slope->zdelta = slope->d.x = slope->d.y = 0;
} else {
// Get direction vector
slope->extent = R_PointToDist2(0, 0, slope->normal.x, slope->normal.y);
slope->d.x = -FixedDiv(slope->normal.x, slope->extent);
slope->d.y = -FixedDiv(slope->normal.y, slope->extent);
// Z delta
slope->zdelta = FixedDiv(slope->extent, slope->normal.z);
// Get angles
slope->xydirection = R_PointToAngle2(0, 0, slope->d.x, slope->d.y)+ANGLE_180;
slope->zangle = InvAngle(R_PointToAngle2(0, 0, FRACUNIT, slope->zdelta));
slope->extent = extent;
slope->xydirection = slope->real_xydirection;
slope->zangle = slope->real_zangle;
}
}
@@ -147,6 +153,7 @@ void P_RunDynamicSlopes(void) {
if (slope->zdelta != FixedDiv(zdelta, slope->extent)) {
slope->zdelta = FixedDiv(zdelta, slope->extent);
slope->zangle = R_PointToAngle2(0, 0, slope->extent, -zdelta);
slope->real_zangle = slope->zangle;
P_CalculateSlopeNormal(slope);
}
}
@@ -357,6 +364,9 @@ void P_SpawnSlope_Line(int linenum)
fslope->zangle = R_PointToAngle2(0, origin.z, extent, point.z);
fslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y);
fslope->real_zangle = fslope->zangle;
fslope->real_xydirection = fslope->xydirection;
P_CalculateSlopeNormal(fslope);
}
if(frontceil)
@@ -400,6 +410,9 @@ void P_SpawnSlope_Line(int linenum)
cslope->zangle = R_PointToAngle2(0, origin.z, extent, point.z);
cslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y);
cslope->real_zangle = cslope->zangle;
cslope->real_xydirection = cslope->xydirection;
P_CalculateSlopeNormal(cslope);
}
}
@@ -466,6 +479,9 @@ void P_SpawnSlope_Line(int linenum)
fslope->zangle = R_PointToAngle2(0, origin.z, extent, point.z);
fslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y);
fslope->real_zangle = fslope->zangle;
fslope->real_xydirection = fslope->xydirection;
P_CalculateSlopeNormal(fslope);
}
if(backceil)
@@ -509,6 +525,9 @@ void P_SpawnSlope_Line(int linenum)
cslope->zangle = R_PointToAngle2(0, origin.z, extent, point.z);
cslope->xydirection = R_PointToAngle2(origin.x, origin.y, point.x, point.y);
cslope->real_zangle = cslope->zangle;
cslope->real_xydirection = cslope->xydirection;
P_CalculateSlopeNormal(cslope);
}
}
+2 -2
View File
@@ -8299,7 +8299,7 @@ DoABarrelRoll (player_t *player)
if (player->mo->standingslope)
{
slope = player->mo->standingslope->zangle;
slope = player->mo->standingslope->real_zangle;
}
else
{
@@ -8308,7 +8308,7 @@ DoABarrelRoll (player_t *player)
if (abs((INT32)slope) > ANGLE_11hh)
{
delta = ( player->mo->angle - player->mo->standingslope->xydirection );
delta = ( player->mo->angle - player->mo->standingslope->real_xydirection );
slope = -(FixedMul(FINESINE (delta>>ANGLETOFINESHIFT), slope));
}
else
+4
View File
@@ -253,6 +253,10 @@ typedef struct pslope_s
angle_t zangle; // Angle of the plane going up from the ground (not mesured in degrees)
angle_t xydirection; // The direction the slope is facing (north, west, south, etc.)
// Applies even if the slope has no physics, for tilting
angle_t real_zangle;
angle_t real_xydirection;
struct line_s *sourceline; // The line that generated the slope
fixed_t extent; // Distance value used for recalculating zdelta
UINT8 refpos; // 1=front floor 2=front ceiling 3=back floor 4=back ceiling (used for dynamic sloping)