Merge branch 'polyobject-cleanup' into 'next'

PolyObject cleanup

See merge request STJr/SRB2!919
This commit is contained in:
MascaraSnake 2020-05-04 14:18:08 -04:00
commit 023c095d55
4 changed files with 200 additions and 463 deletions

View file

@ -760,6 +760,7 @@ linedeftypes
{ {
title = "Parameters"; title = "Parameters";
prefix = "(22)"; prefix = "(22)";
flags8text = "[3] Set translucency by X offset";
flags32text = "[5] Render outer sides only"; flags32text = "[5] Render outer sides only";
flags64text = "[6] Trigger linedef executor"; flags64text = "[6] Trigger linedef executor";
flags128text = "[7] Intangible"; flags128text = "[7] Intangible";

File diff suppressed because it is too large Load diff

View file

@ -29,7 +29,6 @@
#define POLYOBJ_SPAWNCRUSH_DOOMEDNUM 762 // todo: REMOVE #define POLYOBJ_SPAWNCRUSH_DOOMEDNUM 762 // todo: REMOVE
#define POLYOBJ_START_LINE 20 #define POLYOBJ_START_LINE 20
#define POLYOBJ_EXPLICIT_LINE 21
#define POLYINFO_SPECIALNUM 22 #define POLYINFO_SPECIALNUM 22
typedef enum typedef enum
@ -299,6 +298,14 @@ typedef struct polyrotdisplacedata_s
UINT8 turnobjs; UINT8 turnobjs;
} polyrotdisplacedata_t; } polyrotdisplacedata_t;
typedef struct polyflagdata_s
{
INT32 polyObjNum;
INT32 speed;
UINT32 angle;
fixed_t momx;
} polyflagdata_t;
typedef struct polyfadedata_s typedef struct polyfadedata_s
{ {
INT32 polyObjNum; INT32 polyObjNum;
@ -320,7 +327,6 @@ boolean P_PointInsidePolyobj(polyobj_t *po, fixed_t x, fixed_t y);
boolean P_MobjTouchingPolyobj(polyobj_t *po, mobj_t *mo); boolean P_MobjTouchingPolyobj(polyobj_t *po, mobj_t *mo);
boolean P_MobjInsidePolyobj(polyobj_t *po, mobj_t *mo); boolean P_MobjInsidePolyobj(polyobj_t *po, mobj_t *mo);
boolean P_BBoxInsidePolyobj(polyobj_t *po, fixed_t *bbox); boolean P_BBoxInsidePolyobj(polyobj_t *po, fixed_t *bbox);
void Polyobj_GetInfo(INT16 poid, INT32 *poflags, INT32 *parentID, INT32 *potrans);
// thinkers (needed in p_saveg.c) // thinkers (needed in p_saveg.c)
void T_PolyObjRotate(polyrotate_t *); void T_PolyObjRotate(polyrotate_t *);
@ -333,14 +339,14 @@ void T_PolyObjRotDisplace (polyrotdisplace_t *);
void T_PolyObjFlag (polymove_t *); void T_PolyObjFlag (polymove_t *);
void T_PolyObjFade (polyfade_t *); void T_PolyObjFade (polyfade_t *);
INT32 EV_DoPolyDoor(polydoordata_t *); boolean EV_DoPolyDoor(polydoordata_t *);
INT32 EV_DoPolyObjMove(polymovedata_t *); boolean EV_DoPolyObjMove(polymovedata_t *);
INT32 EV_DoPolyObjWaypoint(polywaypointdata_t *); boolean EV_DoPolyObjWaypoint(polywaypointdata_t *);
INT32 EV_DoPolyObjRotate(polyrotdata_t *); boolean EV_DoPolyObjRotate(polyrotdata_t *);
INT32 EV_DoPolyObjDisplace(polydisplacedata_t *); boolean EV_DoPolyObjDisplace(polydisplacedata_t *);
INT32 EV_DoPolyObjRotDisplace(polyrotdisplacedata_t *); boolean EV_DoPolyObjRotDisplace(polyrotdisplacedata_t *);
INT32 EV_DoPolyObjFlag(struct line_s *); boolean EV_DoPolyObjFlag(polyflagdata_t *);
INT32 EV_DoPolyObjFade(polyfadedata_t *); boolean EV_DoPolyObjFade(polyfadedata_t *);
// //

View file

@ -1044,9 +1044,6 @@ static INT32 P_FindLineFromTag(INT32 tag, INT32 start)
} }
} }
//
// P_FindSpecialLineFromTag
//
INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start) INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start)
{ {
if (tag == -1) if (tag == -1)
@ -1076,11 +1073,8 @@ INT32 P_FindSpecialLineFromTag(INT16 special, INT16 tag, INT32 start)
} }
} }
//
// PolyDoor
//
// Parses arguments for parameterized polyobject door types // Parses arguments for parameterized polyobject door types
//
static boolean PolyDoor(line_t *line) static boolean PolyDoor(line_t *line)
{ {
polydoordata_t pdd; polydoordata_t pdd;
@ -1117,11 +1111,7 @@ static boolean PolyDoor(line_t *line)
return EV_DoPolyDoor(&pdd); return EV_DoPolyDoor(&pdd);
} }
//
// PolyMove
//
// Parses arguments for parameterized polyobject move specials // Parses arguments for parameterized polyobject move specials
//
static boolean PolyMove(line_t *line) static boolean PolyMove(line_t *line)
{ {
polymovedata_t pmd; polymovedata_t pmd;
@ -1136,12 +1126,8 @@ static boolean PolyMove(line_t *line)
return EV_DoPolyObjMove(&pmd); return EV_DoPolyObjMove(&pmd);
} }
//
// PolyInvisible
//
// Makes a polyobject invisible and intangible // Makes a polyobject invisible and intangible
// If NOCLIMB is ticked, the polyobject will still be tangible, just not visible. // If NOCLIMB is ticked, the polyobject will still be tangible, just not visible.
//
static void PolyInvisible(line_t *line) static void PolyInvisible(line_t *line)
{ {
INT32 polyObjNum = line->tag; INT32 polyObjNum = line->tag;
@ -1164,12 +1150,8 @@ static void PolyInvisible(line_t *line)
po->flags &= ~POF_RENDERALL; po->flags &= ~POF_RENDERALL;
} }
//
// PolyVisible
//
// Makes a polyobject visible and tangible // Makes a polyobject visible and tangible
// If NOCLIMB is ticked, the polyobject will not be tangible, just visible. // If NOCLIMB is ticked, the polyobject will not be tangible, just visible.
//
static void PolyVisible(line_t *line) static void PolyVisible(line_t *line)
{ {
INT32 polyObjNum = line->tag; INT32 polyObjNum = line->tag;
@ -1192,16 +1174,14 @@ static void PolyVisible(line_t *line)
po->flags |= (po->spawnflags & POF_RENDERALL); po->flags |= (po->spawnflags & POF_RENDERALL);
} }
//
// PolyTranslucency
//
// Sets the translucency of a polyobject // Sets the translucency of a polyobject
// Frontsector floor / 100 = translevel // Frontsector floor / 100 = translevel
//
static void PolyTranslucency(line_t *line) static void PolyTranslucency(line_t *line)
{ {
INT32 polyObjNum = line->tag; INT32 polyObjNum = line->tag;
polyobj_t *po; polyobj_t *po;
INT32 value;
if (!(po = Polyobj_GetForNum(polyObjNum))) if (!(po = Polyobj_GetForNum(polyObjNum)))
{ {
@ -1213,37 +1193,28 @@ static void PolyTranslucency(line_t *line)
if (po->isBad) if (po->isBad)
return; return;
// if DONTPEGBOTTOM, specify raw translucency value in Front X Offset // If Front X Offset is specified, use that. Else, use floorheight.
// else, take it out of 1000. If Front X Offset is specified, use that. Else, use floorheight. value = (sides[line->sidenum[0]].textureoffset ? sides[line->sidenum[0]].textureoffset : line->frontsector->floorheight) >> FRACBITS;
// If DONTPEGBOTTOM, specify raw translucency value. Else, take it out of 1000.
if (!(line->flags & ML_DONTPEGBOTTOM))
value /= 100;
if (line->flags & ML_EFFECT3) // relative calc if (line->flags & ML_EFFECT3) // relative calc
po->translucency = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? po->translucency += value;
(sides[line->sidenum[0]].textureoffset ?
max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS)
: max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS))
: (sides[line->sidenum[0]].textureoffset ?
max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100
: max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)),
NUMTRANSMAPS), 0);
else else
po->translucency = (line->flags & ML_DONTPEGBOTTOM) ? po->translucency = value;
(sides[line->sidenum[0]].textureoffset ?
max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) po->translucency = max(min(po->translucency, NUMTRANSMAPS), 0);
: max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), 0))
: (sides[line->sidenum[0]].textureoffset ?
max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100
: max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100);
} }
//
// PolyFade
//
// Makes a polyobject translucency fade and applies tangibility // Makes a polyobject translucency fade and applies tangibility
//
static boolean PolyFade(line_t *line) static boolean PolyFade(line_t *line)
{ {
INT32 polyObjNum = line->tag; INT32 polyObjNum = line->tag;
polyobj_t *po; polyobj_t *po;
polyfadedata_t pfd; polyfadedata_t pfd;
INT32 value;
if (!(po = Polyobj_GetForNum(polyObjNum))) if (!(po = Polyobj_GetForNum(polyObjNum)))
{ {
@ -1266,25 +1237,19 @@ static boolean PolyFade(line_t *line)
pfd.polyObjNum = polyObjNum; pfd.polyObjNum = polyObjNum;
// if DONTPEGBOTTOM, specify raw translucency value in Front X Offset // If Front X Offset is specified, use that. Else, use floorheight.
// else, take it out of 1000. If Front X Offset is specified, use that. Else, use floorheight. value = (sides[line->sidenum[0]].textureoffset ? sides[line->sidenum[0]].textureoffset : line->frontsector->floorheight) >> FRACBITS;
// If DONTPEGBOTTOM, specify raw translucency value. Else, take it out of 1000.
if (!(line->flags & ML_DONTPEGBOTTOM))
value /= 100;
if (line->flags & ML_EFFECT3) // relative calc if (line->flags & ML_EFFECT3) // relative calc
pfd.destvalue = max(min(po->translucency + ((line->flags & ML_DONTPEGBOTTOM) ? pfd.destvalue = po->translucency + value;
(sides[line->sidenum[0]].textureoffset ?
max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS)
: max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), -NUMTRANSMAPS))
: (sides[line->sidenum[0]].textureoffset ?
max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), -1000) / 100
: max(min(line->frontsector->floorheight>>FRACBITS, 1000), -1000) / 100)),
NUMTRANSMAPS), 0);
else else
pfd.destvalue = (line->flags & ML_DONTPEGBOTTOM) ? pfd.destvalue = value;
(sides[line->sidenum[0]].textureoffset ?
max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, NUMTRANSMAPS), 0) pfd.destvalue = max(min(pfd.destvalue, NUMTRANSMAPS), 0);
: max(min(line->frontsector->floorheight>>FRACBITS, NUMTRANSMAPS), 0))
: (sides[line->sidenum[0]].textureoffset ?
max(min(sides[line->sidenum[0]].textureoffset>>FRACBITS, 1000), 0) / 100
: max(min(line->frontsector->floorheight>>FRACBITS, 1000), 0) / 100);
// already equal, nothing to do // already equal, nothing to do
if (po->translucency == pfd.destvalue) if (po->translucency == pfd.destvalue)
@ -1303,11 +1268,7 @@ static boolean PolyFade(line_t *line)
return EV_DoPolyObjFade(&pfd); return EV_DoPolyObjFade(&pfd);
} }
//
// PolyWaypoint
//
// Parses arguments for parameterized polyobject waypoint movement // Parses arguments for parameterized polyobject waypoint movement
//
static boolean PolyWaypoint(line_t *line) static boolean PolyWaypoint(line_t *line)
{ {
polywaypointdata_t pwd; polywaypointdata_t pwd;
@ -1323,11 +1284,7 @@ static boolean PolyWaypoint(line_t *line)
return EV_DoPolyObjWaypoint(&pwd); return EV_DoPolyObjWaypoint(&pwd);
} }
//
// PolyRotate
//
// Parses arguments for parameterized polyobject rotate specials // Parses arguments for parameterized polyobject rotate specials
//
static boolean PolyRotate(line_t *line) static boolean PolyRotate(line_t *line)
{ {
polyrotdata_t prd; polyrotdata_t prd;
@ -1352,11 +1309,20 @@ static boolean PolyRotate(line_t *line)
return EV_DoPolyObjRotate(&prd); return EV_DoPolyObjRotate(&prd);
} }
// // Parses arguments for polyobject flag waving special
// PolyDisplace static boolean PolyFlag(line_t *line)
// {
polyflagdata_t pfd;
pfd.polyObjNum = line->tag;
pfd.speed = P_AproxDistance(line->dx, line->dy) >> FRACBITS;
pfd.angle = R_PointToAngle2(line->v1->x, line->v1->y, line->v2->x, line->v2->y) >> ANGLETOFINESHIFT;
pfd.momx = sides[line->sidenum[0]].textureoffset >> FRACBITS;
return EV_DoPolyObjFlag(&pfd);
}
// Parses arguments for parameterized polyobject move-by-sector-heights specials // Parses arguments for parameterized polyobject move-by-sector-heights specials
//
static boolean PolyDisplace(line_t *line) static boolean PolyDisplace(line_t *line)
{ {
polydisplacedata_t pdd; polydisplacedata_t pdd;
@ -1371,8 +1337,7 @@ static boolean PolyDisplace(line_t *line)
} }
/** Similar to PolyDisplace(). // Parses arguments for parameterized polyobject rotate-by-sector-heights specials
*/
static boolean PolyRotDisplace(line_t *line) static boolean PolyRotDisplace(line_t *line)
{ {
polyrotdisplacedata_t pdd; polyrotdisplacedata_t pdd;
@ -7323,7 +7288,7 @@ void P_SpawnSpecials(boolean fromnetsave)
switch (lines[i].special) switch (lines[i].special)
{ {
case 30: // Polyobj_Flag case 30: // Polyobj_Flag
EV_DoPolyObjFlag(&lines[i]); PolyFlag(&lines[i]);
break; break;
case 31: // Polyobj_Displace case 31: // Polyobj_Displace