mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-27 22:31:02 +00:00
- [polyobj branch] cleaned up polyobject code for upcoming rework:
* no longer uses segs to create polyobjects * use TArrays instead of doing multiple passes over the data. * started with node list to allow linking a polyobject into multiple subsectors. SVN r2375 (polyobjects)
This commit is contained in:
parent
1436f0a4fa
commit
0913fb16a4
13 changed files with 474 additions and 489 deletions
|
@ -173,7 +173,6 @@ void FNodeBuilder::CreateSubsectorsForReal ()
|
|||
subsector_t sub;
|
||||
unsigned int i;
|
||||
|
||||
sub.poly = NULL;
|
||||
sub.validcount = 0;
|
||||
sub.CenterX = 0; // Code in p_setup.cpp will set these for us later.
|
||||
sub.CenterY = 0;
|
||||
|
|
|
@ -95,7 +95,6 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
|
|||
DWORD numsegs = CloseSubsector (segs, i, outVerts);
|
||||
outSubs[i].numlines = numsegs;
|
||||
outSubs[i].firstline = segs.Size() - numsegs;
|
||||
outSubs[i].poly = NULL;
|
||||
}
|
||||
|
||||
segCount = segs.Size ();
|
||||
|
|
|
@ -539,7 +539,7 @@ bool PO_MovePolyobj (int num, int x, int y, bool force=false);
|
|||
bool PO_RotatePolyobj (int num, angle_t angle);
|
||||
void PO_Init ();
|
||||
bool PO_Busy (int polyobj);
|
||||
void PO_ClosestPoint(const FPolyObj *poly, fixed_t ox, fixed_t oy, fixed_t &x, fixed_t &y, seg_t **seg);
|
||||
void PO_ClosestPoint(const FPolyObj *poly, fixed_t ox, fixed_t oy, fixed_t &x, fixed_t &y, side_t **seg);
|
||||
struct FPolyObj *PO_GetPolyobj(int polyNum);
|
||||
|
||||
//
|
||||
|
|
|
@ -687,9 +687,9 @@ line_t *FBlockLinesIterator::Next()
|
|||
polyLink->polyobj->validcount = validcount;
|
||||
}
|
||||
|
||||
line_t *ld = polyLink->polyobj->lines[polyIndex];
|
||||
line_t *ld = polyLink->polyobj->Linedefs[polyIndex];
|
||||
|
||||
if (++polyIndex >= polyLink->polyobj->numlines)
|
||||
if (++polyIndex >= (int)polyLink->polyobj->Linedefs.Size())
|
||||
{
|
||||
polyLink = polyLink->next;
|
||||
polyIndex = 0;
|
||||
|
|
|
@ -496,8 +496,8 @@ void P_SerializePolyobjs (FArchive &arc)
|
|||
arc << seg << po_NumPolyobjs;
|
||||
for(i = 0, po = polyobjs; i < po_NumPolyobjs; i++, po++)
|
||||
{
|
||||
arc << po->tag << po->angle << po->startSpot[0] <<
|
||||
po->startSpot[1] << po->interpolation;
|
||||
arc << po->tag << po->angle << po->StartSpot.x <<
|
||||
po->StartSpot.y << po->interpolation;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -525,8 +525,8 @@ void P_SerializePolyobjs (FArchive &arc)
|
|||
arc << angle;
|
||||
PO_RotatePolyobj (po->tag, angle);
|
||||
arc << deltaX << deltaY << po->interpolation;
|
||||
deltaX -= po->startSpot[0];
|
||||
deltaY -= po->startSpot[1];
|
||||
deltaX -= po->StartSpot.x;
|
||||
deltaY -= po->StartSpot.y;
|
||||
PO_MovePolyobj (po->tag, deltaX, deltaY, true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3301,6 +3301,7 @@ void P_FreeLevelData ()
|
|||
}
|
||||
|
||||
extern msecnode_t *headsecnode;
|
||||
extern FPolyNode *headpolynode;
|
||||
|
||||
void P_FreeExtraLevelData()
|
||||
{
|
||||
|
@ -3327,6 +3328,17 @@ void P_FreeExtraLevelData()
|
|||
}
|
||||
headsecnode = NULL;
|
||||
}
|
||||
{
|
||||
FPolyNode *node = headpolynode;
|
||||
|
||||
while (node != NULL)
|
||||
{
|
||||
FPolyNode *next = node->pnext;
|
||||
delete node;
|
||||
node = next;
|
||||
}
|
||||
headpolynode = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -305,7 +305,7 @@ bool SightCheck::P_SightBlockLinesIterator (int x, int y)
|
|||
int *list;
|
||||
|
||||
polyblock_t *polyLink;
|
||||
int i;
|
||||
unsigned int i;
|
||||
extern polyblock_t **PolyBlockMap;
|
||||
|
||||
offset = y*bmapwidth+x;
|
||||
|
@ -318,9 +318,9 @@ bool SightCheck::P_SightBlockLinesIterator (int x, int y)
|
|||
if (polyLink->polyobj->validcount != validcount)
|
||||
{
|
||||
polyLink->polyobj->validcount = validcount;
|
||||
for (i = 0; i < polyLink->polyobj->numlines; i++)
|
||||
for (i = 0; i < polyLink->polyobj->Linedefs.Size(); i++)
|
||||
{
|
||||
if (!P_SightCheckLine (polyLink->polyobj->lines[i]))
|
||||
if (!P_SightCheckLine (polyLink->polyobj->Linedefs[i]))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
818
src/po_man.cpp
818
src/po_man.cpp
File diff suppressed because it is too large
Load diff
|
@ -1098,6 +1098,7 @@ void R_Subsector (subsector_t *sub)
|
|||
R_ProjectParticle (Particles + i, subsectors[sub-subsectors].sector, shade, FakeSide);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (sub->poly)
|
||||
{ // Render the polyobj in the subsector first
|
||||
int polyCount = sub->poly->numsegs;
|
||||
|
@ -1107,6 +1108,9 @@ void R_Subsector (subsector_t *sub)
|
|||
R_AddLine (*polySeg++);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#pragma warning("Deactivated polyobj code!")
|
||||
#endif
|
||||
|
||||
while (count--)
|
||||
{
|
||||
|
|
77
src/r_defs.h
77
src/r_defs.h
|
@ -854,6 +854,9 @@ struct side_t
|
|||
|
||||
DInterpolation *SetInterpolation(int position);
|
||||
void StopInterpolation(int position);
|
||||
|
||||
vertex_t *V1() const;
|
||||
vertex_t *V2() const;
|
||||
};
|
||||
|
||||
FArchive &operator<< (FArchive &arc, side_t::part &p);
|
||||
|
@ -916,19 +919,20 @@ struct msecnode_t
|
|||
bool visited; // killough 4/4/98, 4/7/98: used in search algorithms
|
||||
};
|
||||
|
||||
struct FPolyNode;
|
||||
|
||||
//
|
||||
// A SubSector.
|
||||
// References a Sector.
|
||||
// Basically, this is a list of LineSegs indicating the visible walls that
|
||||
// define (all or some) sides of a convex BSP leaf.
|
||||
//
|
||||
struct FPolyObj;
|
||||
struct subsector_t
|
||||
{
|
||||
sector_t *sector;
|
||||
DWORD numlines;
|
||||
DWORD firstline;
|
||||
FPolyObj *poly;
|
||||
FPolyNode *polys;
|
||||
int validcount;
|
||||
fixed_t CenterX, CenterY;
|
||||
};
|
||||
|
@ -954,9 +958,52 @@ struct seg_t
|
|||
BITFIELD bPolySeg:1;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// Linked lists of polyobjects
|
||||
//
|
||||
struct FPolyObj;
|
||||
struct FPolyNode
|
||||
{
|
||||
FPolyObj *poly; // owning polyobject
|
||||
FPolyNode *pnext; // next polyobj in list
|
||||
FPolyNode **pprev; // previous polyobj
|
||||
|
||||
subsector_t *subsector; // containimg subsector
|
||||
FPolyNode *snext; // next subsector
|
||||
FPolyNode **sprev; // previous subsector
|
||||
|
||||
TArray<seg_t> segs; // segs for this node
|
||||
};
|
||||
|
||||
struct FPolyVertex
|
||||
{
|
||||
fixed_t x, y;
|
||||
};
|
||||
|
||||
// ===== Polyobj data =====
|
||||
struct FPolyObj
|
||||
{
|
||||
TArray<side_t *> Sidedefs;
|
||||
TArray<line_t *> Linedefs;
|
||||
TArray<vertex_t *> Vertices;
|
||||
TArray<FPolyVertex> OriginalPts;
|
||||
TArray<FPolyVertex> PrevPts;
|
||||
FPolyVertex StartSpot;
|
||||
|
||||
angle_t angle;
|
||||
int tag; // reference tag assigned in HereticEd
|
||||
int bbox[4];
|
||||
int validcount;
|
||||
int crush; // should the polyobj attempt to crush mobjs?
|
||||
bool bHurtOnTouch; // should the polyobj hurt anything it touches?
|
||||
int seqType;
|
||||
fixed_t size; // polyobj size (area of POLY_AREAUNIT == size of FRACUNIT)
|
||||
FPolyNode *subsectorlinks;
|
||||
DThinker *specialdata; // pointer to a thinker, if the poly is moving
|
||||
TObjPtr<DInterpolation> interpolation;
|
||||
|
||||
/*
|
||||
int numsegs;
|
||||
seg_t **segs;
|
||||
int numlines;
|
||||
|
@ -966,16 +1013,22 @@ struct FPolyObj
|
|||
fixed_t startSpot[2];
|
||||
vertex_t *originalPts; // used as the base for the rotations
|
||||
vertex_t *prevPts; // use to restore the old point values
|
||||
angle_t angle;
|
||||
int tag; // reference tag assigned in HereticEd
|
||||
int bbox[4];
|
||||
int validcount;
|
||||
int crush; // should the polyobj attempt to crush mobjs?
|
||||
bool bHurtOnTouch; // should the polyobj hurt anything it touches?
|
||||
int seqType;
|
||||
fixed_t size; // polyobj size (area of POLY_AREAUNIT == size of FRACUNIT)
|
||||
DThinker *specialdata; // pointer to a thinker, if the poly is moving
|
||||
TObjPtr<DInterpolation> interpolation;
|
||||
*/
|
||||
|
||||
FPolyObj()
|
||||
{
|
||||
StartSpot.x = StartSpot.y = 0;
|
||||
angle = 0;
|
||||
tag = 0;
|
||||
memset(bbox, 0, sizeof(bbox));
|
||||
validcount = 0;
|
||||
crush = 0;
|
||||
bHurtOnTouch = false;
|
||||
seqType = 0;
|
||||
size = 0;
|
||||
subsectorlinks = NULL;
|
||||
specialdata = NULL;
|
||||
}
|
||||
|
||||
~FPolyObj();
|
||||
DInterpolation *SetInterpolation();
|
||||
|
|
|
@ -728,8 +728,8 @@ void DWallScrollInterpolation::Serialize(FArchive &arc)
|
|||
DPolyobjInterpolation::DPolyobjInterpolation(FPolyObj *po)
|
||||
{
|
||||
poly = po;
|
||||
oldverts.Resize(po->numvertices<<1);
|
||||
bakverts.Resize(po->numvertices<<1);
|
||||
oldverts.Resize(po->Vertices.Size() << 1);
|
||||
bakverts.Resize(po->Vertices.Size() << 1);
|
||||
UpdateInterpolation ();
|
||||
interpolator.AddInterpolation(this);
|
||||
}
|
||||
|
@ -755,10 +755,10 @@ void DPolyobjInterpolation::Destroy()
|
|||
|
||||
void DPolyobjInterpolation::UpdateInterpolation()
|
||||
{
|
||||
for(int i = 0; i < poly->numvertices; i++)
|
||||
for(unsigned int i = 0; i < poly->Vertices.Size(); i++)
|
||||
{
|
||||
oldverts[i*2 ] = poly->vertices[i]->x;
|
||||
oldverts[i*2+1] = poly->vertices[i]->y;
|
||||
oldverts[i*2 ] = poly->Vertices[i]->x;
|
||||
oldverts[i*2+1] = poly->Vertices[i]->y;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -770,10 +770,10 @@ void DPolyobjInterpolation::UpdateInterpolation()
|
|||
|
||||
void DPolyobjInterpolation::Restore()
|
||||
{
|
||||
for(int i = 0; i < poly->numvertices; i++)
|
||||
for(unsigned int i = 0; i < poly->Vertices.Size(); i++)
|
||||
{
|
||||
poly->vertices[i]->x = bakverts[i*2 ];
|
||||
poly->vertices[i]->y = bakverts[i*2+1];
|
||||
poly->Vertices[i]->x = bakverts[i*2 ];
|
||||
poly->Vertices[i]->y = bakverts[i*2+1];
|
||||
}
|
||||
//poly->Moved();
|
||||
}
|
||||
|
@ -786,10 +786,10 @@ void DPolyobjInterpolation::Restore()
|
|||
|
||||
void DPolyobjInterpolation::Interpolate(fixed_t smoothratio)
|
||||
{
|
||||
for(int i = 0; i < poly->numvertices; i++)
|
||||
for(unsigned int i = 0; i < poly->Vertices.Size(); i++)
|
||||
{
|
||||
fixed_t *px = &poly->vertices[i]->x;
|
||||
fixed_t *py = &poly->vertices[i]->y;
|
||||
fixed_t *px = &poly->Vertices[i]->x;
|
||||
fixed_t *py = &poly->Vertices[i]->y;
|
||||
|
||||
bakverts[i*2 ] = *px;
|
||||
bakverts[i*2+1] = *py;
|
||||
|
|
|
@ -1471,6 +1471,7 @@ void RP_Subsector (subsector_t *sub)
|
|||
// R_ProjectParticle (Particles + i, subsectors[sub-subsectors].sector, shade, FakeSide);
|
||||
// }
|
||||
|
||||
#if 0
|
||||
if (sub->poly)
|
||||
{ // Render the polyobj in the subsector first
|
||||
int polyCount = sub->poly->numsegs;
|
||||
|
@ -1480,6 +1481,7 @@ void RP_Subsector (subsector_t *sub)
|
|||
RP_AddLine (*polySeg++);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
while (count--)
|
||||
{
|
||||
|
|
|
@ -795,11 +795,11 @@ static void CalcSectorSoundOrg(const sector_t *sec, int channum, fixed_t *x, fix
|
|||
|
||||
static void CalcPolyobjSoundOrg(const FPolyObj *poly, fixed_t *x, fixed_t *y, fixed_t *z)
|
||||
{
|
||||
seg_t *seg;
|
||||
side_t *side;
|
||||
sector_t *sec;
|
||||
|
||||
PO_ClosestPoint(poly, *x, *y, *x, *y, &seg);
|
||||
sec = seg->frontsector;
|
||||
PO_ClosestPoint(poly, *x, *y, *x, *y, &side);
|
||||
sec = side->sector;
|
||||
*z = clamp(*z, sec->floorplane.ZatPoint(*x, *y), sec->ceilingplane.ZatPoint(*x, *y));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue