mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Merge branch 'equationslopes' into 'next'
Add generalized slopes in UDMF See merge request STJr/SRB2!1530
This commit is contained in:
commit
ce98758bd6
3 changed files with 126 additions and 5 deletions
|
@ -1501,6 +1501,22 @@ typedef struct textmap_colormap_s {
|
|||
|
||||
textmap_colormap_t textmap_colormap = { false, 0, 25, 0, 25, 0, 31, 0 };
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PD_A = 1,
|
||||
PD_B = 1<<1,
|
||||
PD_C = 1<<2,
|
||||
PD_D = 1<<3,
|
||||
} planedef_t;
|
||||
|
||||
typedef struct textmap_plane_s {
|
||||
UINT8 defined;
|
||||
fixed_t a, b, c, d;
|
||||
} textmap_plane_t;
|
||||
|
||||
textmap_plane_t textmap_planefloor = {0, 0, 0, 0, 0};
|
||||
textmap_plane_t textmap_planeceiling = {0, 0, 0, 0, 0};
|
||||
|
||||
static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val)
|
||||
{
|
||||
if (fastcmp(param, "heightfloor"))
|
||||
|
@ -1539,6 +1555,46 @@ static void ParseTextmapSectorParameter(UINT32 i, char *param, char *val)
|
|||
sectors[i].floorpic_angle = FixedAngle(FLOAT_TO_FIXED(atof(val)));
|
||||
else if (fastcmp(param, "rotationceiling"))
|
||||
sectors[i].ceilingpic_angle = FixedAngle(FLOAT_TO_FIXED(atof(val)));
|
||||
else if (fastcmp(param, "floorplane_a"))
|
||||
{
|
||||
textmap_planefloor.defined |= PD_A;
|
||||
textmap_planefloor.a = FLOAT_TO_FIXED(atof(val));
|
||||
}
|
||||
else if (fastcmp(param, "floorplane_b"))
|
||||
{
|
||||
textmap_planefloor.defined |= PD_B;
|
||||
textmap_planefloor.b = FLOAT_TO_FIXED(atof(val));
|
||||
}
|
||||
else if (fastcmp(param, "floorplane_c"))
|
||||
{
|
||||
textmap_planefloor.defined |= PD_C;
|
||||
textmap_planefloor.c = FLOAT_TO_FIXED(atof(val));
|
||||
}
|
||||
else if (fastcmp(param, "floorplane_d"))
|
||||
{
|
||||
textmap_planefloor.defined |= PD_D;
|
||||
textmap_planefloor.d = FLOAT_TO_FIXED(atof(val));
|
||||
}
|
||||
else if (fastcmp(param, "ceilingplane_a"))
|
||||
{
|
||||
textmap_planeceiling.defined |= PD_A;
|
||||
textmap_planeceiling.a = FLOAT_TO_FIXED(atof(val));
|
||||
}
|
||||
else if (fastcmp(param, "ceilingplane_b"))
|
||||
{
|
||||
textmap_planeceiling.defined |= PD_B;
|
||||
textmap_planeceiling.b = FLOAT_TO_FIXED(atof(val));
|
||||
}
|
||||
else if (fastcmp(param, "ceilingplane_c"))
|
||||
{
|
||||
textmap_planeceiling.defined |= PD_C;
|
||||
textmap_planeceiling.c = FLOAT_TO_FIXED(atof(val));
|
||||
}
|
||||
else if (fastcmp(param, "ceilingplane_d"))
|
||||
{
|
||||
textmap_planeceiling.defined |= PD_D;
|
||||
textmap_planeceiling.d = FLOAT_TO_FIXED(atof(val));
|
||||
}
|
||||
else if (fastcmp(param, "lightcolor"))
|
||||
{
|
||||
textmap_colormap.used = true;
|
||||
|
@ -1868,6 +1924,10 @@ static void P_LoadTextmap(void)
|
|||
textmap_colormap.fadestart = 0;
|
||||
textmap_colormap.fadeend = 31;
|
||||
textmap_colormap.flags = 0;
|
||||
|
||||
textmap_planefloor.defined = 0;
|
||||
textmap_planeceiling.defined = 0;
|
||||
|
||||
TextmapParse(sectorsPos[i], i, ParseTextmapSectorParameter);
|
||||
|
||||
P_InitializeSector(sc);
|
||||
|
@ -1877,6 +1937,19 @@ static void P_LoadTextmap(void)
|
|||
INT32 fadergba = P_ColorToRGBA(textmap_colormap.fadecolor, textmap_colormap.fadealpha);
|
||||
sc->extra_colormap = sc->spawn_extra_colormap = R_CreateColormap(rgba, fadergba, textmap_colormap.fadestart, textmap_colormap.fadeend, textmap_colormap.flags);
|
||||
}
|
||||
|
||||
if (textmap_planefloor.defined == (PD_A|PD_B|PD_C|PD_D))
|
||||
{
|
||||
sc->f_slope = MakeViaEquationConstants(textmap_planefloor.a, textmap_planefloor.b, textmap_planefloor.c, textmap_planefloor.d);
|
||||
sc->hasslope = true;
|
||||
}
|
||||
|
||||
if (textmap_planeceiling.defined == (PD_A|PD_B|PD_C|PD_D))
|
||||
{
|
||||
sc->c_slope = MakeViaEquationConstants(textmap_planeceiling.a, textmap_planeceiling.b, textmap_planeceiling.c, textmap_planeceiling.d);
|
||||
sc->hasslope = true;
|
||||
}
|
||||
|
||||
TextmapFixFlatOffsets(sc);
|
||||
}
|
||||
|
||||
|
@ -4274,6 +4347,8 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
|
|||
|
||||
P_MapStart(); // tmthing can be used starting from this point
|
||||
|
||||
P_InitSlopes();
|
||||
|
||||
if (!P_LoadMapFromFile())
|
||||
return false;
|
||||
|
||||
|
|
|
@ -90,6 +90,36 @@ static void ReconfigureViaVertexes (pslope_t *slope, const vector3_t v1, const v
|
|||
}
|
||||
}
|
||||
|
||||
/// Setup slope via constants.
|
||||
static void ReconfigureViaConstants (pslope_t *slope, const fixed_t a, const fixed_t b, const fixed_t c, const fixed_t d)
|
||||
{
|
||||
fixed_t m;
|
||||
vector3_t *normal = &slope->normal;
|
||||
|
||||
// Set origin.
|
||||
FV3_Load(&slope->o, 0, 0, c ? -FixedDiv(d, c) : 0);
|
||||
|
||||
// Get slope's normal.
|
||||
FV3_Load(normal, a, b, c);
|
||||
FV3_Normalize(normal);
|
||||
|
||||
// Invert normal if it's facing down.
|
||||
if (normal->z < 0)
|
||||
FV3_Negate(normal);
|
||||
|
||||
// Get direction vector
|
||||
m = FixedHypot(normal->x, normal->y);
|
||||
slope->d.x = -FixedDiv(normal->x, m);
|
||||
slope->d.y = -FixedDiv(normal->y, m);
|
||||
|
||||
// Z delta
|
||||
slope->zdelta = FixedDiv(m, 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));
|
||||
}
|
||||
|
||||
/// Recalculate dynamic slopes.
|
||||
void T_DynamicSlopeLine (dynplanethink_t* th)
|
||||
{
|
||||
|
@ -631,13 +661,20 @@ pslope_t *P_SlopeById(UINT16 id)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/// Creates a new slope from equation constants.
|
||||
pslope_t *MakeViaEquationConstants(const fixed_t a, const fixed_t b, const fixed_t c, const fixed_t d)
|
||||
{
|
||||
pslope_t* ret = Slope_Add(0);
|
||||
|
||||
ReconfigureViaConstants(ret, a, b, c, d);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/// Initializes and reads the slopes from the map data.
|
||||
void P_SpawnSlopes(const boolean fromsave) {
|
||||
size_t i;
|
||||
|
||||
slopelist = NULL;
|
||||
slopecount = 0;
|
||||
|
||||
/// Generates vertex slopes.
|
||||
SpawnVertexSlopes();
|
||||
|
||||
|
@ -671,6 +708,13 @@ void P_SpawnSlopes(const boolean fromsave) {
|
|||
}
|
||||
}
|
||||
|
||||
/// Initializes slopes.
|
||||
void P_InitSlopes(void)
|
||||
{
|
||||
slopelist = NULL;
|
||||
slopecount = 0;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
//
|
||||
// Various utilities related to slopes
|
||||
|
|
|
@ -50,6 +50,7 @@ typedef enum
|
|||
void P_LinkSlopeThinkers (void);
|
||||
|
||||
void P_CalculateSlopeNormal(pslope_t *slope);
|
||||
void P_InitSlopes(void);
|
||||
void P_SpawnSlopes(const boolean fromsave);
|
||||
|
||||
//
|
||||
|
@ -86,6 +87,7 @@ 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 *MakeViaEquationConstants(const fixed_t a, const fixed_t b, const fixed_t c, const fixed_t d);
|
||||
|
||||
/// Dynamic plane type enum for the thinker. Will have a different functionality depending on this.
|
||||
typedef enum {
|
||||
|
|
Loading…
Reference in a new issue