Update to ZDoom r2448:

- addition of and changes for new polyobject code.


git-svn-id: http://mancubus.net/svn/hosted/gzdoom/trunk@846 b0f79afe-0144-0410-b225-9a4edf0717df
This commit is contained in:
Christoph Oelckers 2010-07-23 14:32:07 +00:00
parent 0dcbdf347b
commit 76780fd5b1
25 changed files with 1347 additions and 889 deletions

View file

@ -58,6 +58,7 @@
#include "am_map.h" #include "am_map.h"
#include "a_artifacts.h" #include "a_artifacts.h"
#include "po_man.h"
struct AMColor struct AMColor
{ {
@ -177,6 +178,10 @@ CVAR (Color, am_ovthingcolor_friend, 0xe88800, CVAR_ARCHIVE);
CVAR (Color, am_ovthingcolor_monster, 0xe88800, CVAR_ARCHIVE); CVAR (Color, am_ovthingcolor_monster, 0xe88800, CVAR_ARCHIVE);
CVAR (Color, am_ovthingcolor_item, 0xe88800, CVAR_ARCHIVE); CVAR (Color, am_ovthingcolor_item, 0xe88800, CVAR_ARCHIVE);
CVAR(Int, am_showsubsector, -1, 0);
// Disable the ML_DONTDRAW line flag if x% of all lines in a map are flagged with it // Disable the ML_DONTDRAW line flag if x% of all lines in a map are flagged with it
// (To counter annoying mappers who think they are smart by making the automap unusable) // (To counter annoying mappers who think they are smart by making the automap unusable)
bool am_showallenabled; bool am_showallenabled;
@ -1614,6 +1619,64 @@ static bool AM_CheckSecret(line_t *line)
} }
//=============================================================================
//
// Polyobject debug stuff
//
//=============================================================================
void AM_drawSeg(seg_t *seg, const AMColor &color)
{
mline_t l;
l.a.x = seg->v1->x >> FRACTOMAPBITS;
l.a.y = seg->v1->y >> FRACTOMAPBITS;
l.b.x = seg->v2->x >> FRACTOMAPBITS;
l.b.y = seg->v2->y >> FRACTOMAPBITS;
if (am_rotate == 1 || (am_rotate == 2 && viewactive))
{
AM_rotatePoint (&l.a.x, &l.a.y);
AM_rotatePoint (&l.b.x, &l.b.y);
}
AM_drawMline(&l, color);
}
void AM_showSS()
{
if (am_showsubsector >= 0 && am_showsubsector < numsubsectors)
{
AMColor yellow;
yellow.FromRGB(255,255,0);
AMColor red;
red.FromRGB(255,0,0);
subsector_t *sub = &subsectors[am_showsubsector];
for(unsigned int i=0;i<sub->numlines;i++)
{
AM_drawSeg(&segs[sub->firstline+i], yellow);
}
PO_LinkToSubsectors();
for(int i=0;i<po_NumPolyobjs;i++)
{
FPolyObj *po = &polyobjs[i];
FPolyNode *pnode = po->subsectorlinks;
while (pnode != NULL)
{
if (pnode->subsector == sub)
{
for(unsigned j=0;j<pnode->segs.Size();j++)
{
AM_drawSeg(&pnode->segs[j], red);
}
}
pnode = pnode->snext;
}
}
}
}
//============================================================================= //=============================================================================
// //
// Determines visible lines, draws them. // Determines visible lines, draws them.
@ -2166,6 +2229,8 @@ void AM_Drawer ()
AM_drawCrosshair(XHairColor); AM_drawCrosshair(XHairColor);
AM_drawMarks(); AM_drawMarks();
AM_showSS();
} }
//============================================================================= //=============================================================================

View file

@ -71,6 +71,7 @@
#include "r_interpolate.h" #include "r_interpolate.h"
#include "doomstat.h" #include "doomstat.h"
#include "m_argv.h" #include "m_argv.h"
#include "po_man.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------

View file

@ -42,6 +42,7 @@
#include "p_local.h" #include "p_local.h"
#include "a_sharedglobal.h" #include "a_sharedglobal.h"
#include "r_sky.h" #include "r_sky.h"
#include "po_man.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/data/gl_data.h" #include "gl/data/gl_data.h"
@ -132,7 +133,7 @@ static void AddLine (seg_t *seg,sector_t * sector,subsector_t * polysub)
seg->linedef->flags |= ML_MAPPED; seg->linedef->flags |= ML_MAPPED;
if (seg->linedef->validcount!=validcount) if (seg->linedef->validcount!=validcount || polysub != NULL)
{ {
seg->linedef->validcount=validcount; seg->linedef->validcount=validcount;
@ -149,6 +150,53 @@ static void AddLine (seg_t *seg,sector_t * sector,subsector_t * polysub)
} }
} }
//==========================================================================
//
//
//
//==========================================================================
static int STACK_ARGS polycmp(const void *a, const void *b)
{
const FPolyNode *A = *(FPolyNode **)a;
const FPolyNode *B = *(FPolyNode **)b;
return A->dist - B->dist;
}
//==========================================================================
//
//
//
//==========================================================================
static void AddPolyobjs(subsector_t *sub, sector_t *sector)
{
static TArray<FPolyNode *> sortedpolys;
FPolyNode *pn = sub->polys;
sortedpolys.Clear();
while (pn != NULL)
{
sortedpolys.Push(pn);
pn->dist = R_PointToDist2(pn->poly->CenterSpot.x - viewx, pn->poly->CenterSpot.y - viewy);
pn = pn->pnext;
}
if (sortedpolys.Size() > 1)
{
qsort(&sortedpolys[0], sortedpolys.Size(), sizeof (sortedpolys[0]), polycmp);
}
for(unsigned i=0; i<sortedpolys.Size(); i++)
{
pn = sortedpolys[i];
for(unsigned j=0; j<pn->segs.Size(); j++)
{
AddLine (&pn->segs[j], sector, sub);
}
}
}
//========================================================================== //==========================================================================
// //
// //
@ -157,14 +205,9 @@ static void AddLine (seg_t *seg,sector_t * sector,subsector_t * polysub)
static inline void AddLines(subsector_t * sub, sector_t * sector) static inline void AddLines(subsector_t * sub, sector_t * sector)
{ {
ClipWall.Clock(); ClipWall.Clock();
if (sub->poly) if (sub->polys != NULL)
{ // Render the polyobj in the subsector first {
int polyCount = sub->poly->numsegs; AddPolyobjs(sub, sector);
seg_t **polySeg = sub->poly->segs;
while (polyCount--)
{
AddLine (*polySeg++, sector, sub);
}
} }
int count = sub->numlines; int count = sub->numlines;
@ -206,6 +249,7 @@ static inline void RenderThings(subsector_t * sub, sector_t * sector)
SetupSprite.Unclock(); SetupSprite.Unclock();
} }
//========================================================================== //==========================================================================
// //
// R_Subsector // R_Subsector

View file

@ -49,6 +49,7 @@
#include "r_main.h" #include "r_main.h"
#include "r_things.h" #include "r_things.h"
#include "sbar.h" #include "sbar.h"
#include "po_man.h"
#include "gl/gl_functions.h" #include "gl/gl_functions.h"
#include "gl/system/gl_framebuffer.h" #include "gl/system/gl_framebuffer.h"
@ -305,6 +306,7 @@ void FGLRenderer::CreateScene()
{ {
// reset the portal manager // reset the portal manager
GLPortal::StartFrame(); GLPortal::StartFrame();
PO_LinkToSubsectors();
ProcessAll.Clock(); ProcessAll.Clock();

View file

@ -163,6 +163,8 @@ void GLWall::PutWall(bool translucent)
} }
else if (sub) else if (sub)
{ {
// for polyobjects we cannot use the side's light list.
// We must use the subsector's.
light = sub->lighthead[0] != NULL; light = sub->lighthead[0] != NULL;
} }
} }
@ -1490,8 +1492,27 @@ void GLWall::Process(seg_t *seg, sector_t * frontsector, sector_t * backsector,
v1=seg->linedef->v2; v1=seg->linedef->v2;
v2=seg->linedef->v1; v2=seg->linedef->v1;
} }
glseg.fracleft=0;
glseg.fracright=1; if (polysub == NULL)
{
glseg.fracleft=0;
glseg.fracright=1;
}
else // polyobjects must be rendered per seg.
{
if (abs(v1->x-v2->x) > abs(v1->y-v2->y))
{
glseg.fracleft = float(seg->v1->x - v1->x)/float(v2->x-v1->x);
glseg.fracright = float(seg->v2->x - v1->x)/float(v2->x-v1->x);
}
else
{
glseg.fracleft = float(seg->v1->y - v1->y)/float(v2->y-v1->y);
glseg.fracright = float(seg->v2->y - v1->y)/float(v2->y-v1->y);
}
v1=seg->v1;
v2=seg->v2;
}
if (gl_seamless) if (gl_seamless)
{ {

View file

@ -91,8 +91,3 @@ int FBoundingBox::BoxOnLineSide (const line_t *ld) const
return (p1 == p2) ? p1 : -1; return (p1 == p2) ? p1 : -1;
} }

View file

@ -25,6 +25,7 @@
#include "doomtype.h" #include "doomtype.h"
struct line_t; struct line_t;
struct node_t;
class FBoundingBox class FBoundingBox
{ {

View file

@ -173,11 +173,11 @@ void FNodeBuilder::CreateSubsectorsForReal ()
subsector_t sub; subsector_t sub;
unsigned int i; unsigned int i;
sub.poly = NULL;
sub.validcount = 0; sub.validcount = 0;
sub.CenterX = 0; // Code in p_setup.cpp will set these for us later. sub.CenterX = 0; // Code in p_setup.cpp will set these for us later.
sub.CenterY = 0; sub.CenterY = 0;
sub.sector = NULL; sub.sector = NULL;
sub.polys = NULL;
for (i = 0; i < SubsectorSets.Size(); ++i) for (i = 0; i < SubsectorSets.Size(); ++i)
{ {

View file

@ -106,7 +106,6 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount,
DWORD numsegs = CloseSubsector (segs, i, outVerts); DWORD numsegs = CloseSubsector (segs, i, outVerts);
outSubs[i].numlines = numsegs; outSubs[i].numlines = numsegs;
outSubs[i].firstline = segs.Size() - numsegs; outSubs[i].firstline = segs.Size() - numsegs;
outSubs[i].poly = NULL;
} }
segCount = segs.Size (); segCount = segs.Size ();

View file

@ -237,6 +237,7 @@ struct FLineOpening
void P_LineOpening (FLineOpening &open, AActor *thing, const line_t *linedef, fixed_t x, fixed_t y, fixed_t refx=FIXED_MIN, fixed_t refy=0); void P_LineOpening (FLineOpening &open, AActor *thing, const line_t *linedef, fixed_t x, fixed_t y, fixed_t refx=FIXED_MIN, fixed_t refy=0);
class FBoundingBox; class FBoundingBox;
struct polyblock_t;
class FBlockLinesIterator class FBlockLinesIterator
{ {
@ -537,12 +538,9 @@ extern int po_NumPolyobjs;
extern polyspawns_t *polyspawns; // [RH] list of polyobject things to spawn extern polyspawns_t *polyspawns; // [RH] list of polyobject things to spawn
bool PO_MovePolyobj (int num, int x, int y, bool force=false);
bool PO_RotatePolyobj (int num, angle_t angle);
void PO_Init (); void PO_Init ();
bool PO_Busy (int polyobj); 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); FPolyObj *PO_GetPolyobj(int polyNum);
struct FPolyObj *PO_GetPolyobj(int polyNum);
// //
// P_SPEC // P_SPEC

View file

@ -39,8 +39,7 @@
// State. // State.
#include "r_state.h" #include "r_state.h"
#include "templates.h" #include "templates.h"
#include "po_man.h"
#include "gl/gl_functions.h"
static AActor *RoughBlockCheck (AActor *mo, int index, void *); static AActor *RoughBlockCheck (AActor *mo, int index, void *);
@ -323,7 +322,6 @@ void AActor::LinkToWorld (sector_t *sec)
return; return;
} }
Sector = sec; Sector = sec;
subsector = R_PointInSubsector(x, y); // this is from the rendering nodes, not the gameplay nodes!
if ( !(flags & MF_NOSECTOR) ) if ( !(flags & MF_NOSECTOR) )
{ {
@ -462,7 +460,7 @@ static int R_PointOnSideSlow (fixed_t x, fixed_t y, node_t *node)
sector_t *AActor::LinkToWorldForMapThing () sector_t *AActor::LinkToWorldForMapThing ()
{ {
node_t *node = gamenodes + numgamenodes - 1; node_t *node = nodes + numnodes - 1;
do do
{ {
@ -695,9 +693,9 @@ line_t *FBlockLinesIterator::Next()
polyLink->polyobj->validcount = validcount; 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; polyLink = polyLink->next;
polyIndex = 0; polyIndex = 0;

View file

@ -46,12 +46,14 @@
#include "a_sharedglobal.h" #include "a_sharedglobal.h"
#include "r_interpolate.h" #include "r_interpolate.h"
#include "g_level.h" #include "g_level.h"
#include "po_man.h"
static void CopyPlayer (player_t *dst, player_t *src, const char *name); static void CopyPlayer (player_t *dst, player_t *src, const char *name);
static void ReadOnePlayer (FArchive &arc, bool skipload); static void ReadOnePlayer (FArchive &arc, bool skipload);
static void ReadMultiplePlayers (FArchive &arc, int numPlayers, int numPlayersNow, bool skipload); static void ReadMultiplePlayers (FArchive &arc, int numPlayers, int numPlayersNow, bool skipload);
static void SpawnExtraPlayers (); static void SpawnExtraPlayers ();
// //
// P_ArchivePlayers // P_ArchivePlayers
// //
@ -497,8 +499,8 @@ void P_SerializePolyobjs (FArchive &arc)
arc << seg << po_NumPolyobjs; arc << seg << po_NumPolyobjs;
for(i = 0, po = polyobjs; i < po_NumPolyobjs; i++, po++) for(i = 0, po = polyobjs; i < po_NumPolyobjs; i++, po++)
{ {
arc << po->tag << po->angle << po->startSpot[0] << arc << po->tag << po->angle << po->StartSpot.x <<
po->startSpot[1] << po->interpolation; po->StartSpot.y << po->interpolation;
} }
} }
else else
@ -524,11 +526,11 @@ void P_SerializePolyobjs (FArchive &arc)
I_Error ("UnarchivePolyobjs: Invalid polyobj tag"); I_Error ("UnarchivePolyobjs: Invalid polyobj tag");
} }
arc << angle; arc << angle;
PO_RotatePolyobj (po->tag, angle); po->RotatePolyobj (angle);
arc << deltaX << deltaY << po->interpolation; arc << deltaX << deltaY << po->interpolation;
deltaX -= po->startSpot[0]; deltaX -= po->StartSpot.x;
deltaY -= po->startSpot[1]; deltaY -= po->StartSpot.y;
PO_MovePolyobj (po->tag, deltaX, deltaY, true); po->MovePolyobj (deltaX, deltaY, true);
} }
} }
} }

View file

@ -65,6 +65,7 @@
#include "g_level.h" #include "g_level.h"
#include "md5.h" #include "md5.h"
#include "compatibility.h" #include "compatibility.h"
#include "po_man.h"
#include "gl/gl_functions.h" #include "gl/gl_functions.h"
@ -1527,7 +1528,6 @@ void P_LoadNodes (MapData * map)
memset (used, 0, sizeof(WORD)*numnodes); memset (used, 0, sizeof(WORD)*numnodes);
mnp = new char[lumplen]; mnp = new char[lumplen];
mn = (nodetype*)(mnp + nodetype::NF_LUMPOFFSET); mn = (nodetype*)(mnp + nodetype::NF_LUMPOFFSET);
map->Read(ML_NODES, mnp); map->Read(ML_NODES, mnp);
no = nodes; no = nodes;
@ -3384,6 +3384,7 @@ extern polyblock_t **PolyBlockMap;
void P_FreeLevelData () void P_FreeLevelData ()
{ {
gl_CleanLevelData(); gl_CleanLevelData();
FPolyObj::ClearAllSubsectorLinks(); // can't be done as part of the polyobj deletion process.
SN_StopAllSequences (); SN_StopAllSequences ();
DThinker::DestroyAllThinkers (); DThinker::DestroyAllThinkers ();
level.total_monsters = level.total_items = level.total_secrets = level.total_monsters = level.total_items = level.total_secrets =

View file

@ -18,6 +18,7 @@
#include "m_bbox.h" #include "m_bbox.h"
#include "p_lnspec.h" #include "p_lnspec.h"
#include "g_level.h" #include "g_level.h"
#include "po_man.h"
// State. // State.
#include "r_state.h" #include "r_state.h"
@ -305,7 +306,7 @@ bool SightCheck::P_SightBlockLinesIterator (int x, int y)
int *list; int *list;
polyblock_t *polyLink; polyblock_t *polyLink;
int i; unsigned int i;
extern polyblock_t **PolyBlockMap; extern polyblock_t **PolyBlockMap;
offset = y*bmapwidth+x; offset = y*bmapwidth+x;
@ -318,9 +319,9 @@ bool SightCheck::P_SightBlockLinesIterator (int x, int y)
if (polyLink->polyobj->validcount != validcount) if (polyLink->polyobj->validcount != validcount)
{ {
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; return false;
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -50,6 +50,7 @@
#include "r_bsp.h" #include "r_bsp.h"
#include "v_palette.h" #include "v_palette.h"
#include "r_sky.h" #include "r_sky.h"
#include "po_man.h"
int WallMost (short *mostbuf, const secplane_t &plane); int WallMost (short *mostbuf, const secplane_t &plane);
@ -1006,6 +1007,46 @@ void R_GetExtraLight (int *light, const secplane_t &plane, FExtraLight *el)
} }
} }
} }
static int STACK_ARGS polycmp(const void *a, const void *b)
{
const FPolyNode *A = *(FPolyNode **)a;
const FPolyNode *B = *(FPolyNode **)b;
return A->dist - B->dist;
}
static void R_AddPolyobjs(subsector_t *sub)
{
static TArray<FPolyNode *> sortedpolys;
FPolyNode *pn = sub->polys;
sortedpolys.Clear();
while (pn != NULL)
{
sortedpolys.Push(pn);
pn->dist = R_PointToDist2(pn->poly->CenterSpot.x - viewx, pn->poly->CenterSpot.y - viewy);
pn = pn->pnext;
}
if (sortedpolys.Size() > 1)
{
qsort(&sortedpolys[0], sortedpolys.Size(), sizeof (sortedpolys[0]), polycmp);
}
for(unsigned i=0; i<sortedpolys.Size(); i++)
{
pn = sortedpolys[i];
for(unsigned j=0; j<pn->segs.Size(); j++)
{
R_AddLine(&pn->segs[j]);
}
}
}
// //
// R_Subsector // R_Subsector
// Determine floor/ceiling planes. // Determine floor/ceiling planes.
@ -1098,14 +1139,9 @@ void R_Subsector (subsector_t *sub)
R_ProjectParticle (Particles + i, subsectors[sub-subsectors].sector, shade, FakeSide); R_ProjectParticle (Particles + i, subsectors[sub-subsectors].sector, shade, FakeSide);
} }
if (sub->poly) if (sub->polys)
{ // Render the polyobj in the subsector first { // Render the polyobjs in the subsector first
int polyCount = sub->poly->numsegs; R_AddPolyobjs(sub);
seg_t **polySeg = sub->poly->segs;
while (polyCount--)
{
R_AddLine (*polySeg++);
}
} }
while (count--) while (count--)

View file

@ -88,6 +88,11 @@ struct vertex_t
return x == other.x && y == other.y; return x == other.x && y == other.y;
} }
void clear()
{
x = y = 0;
}
angle_t GetClipAngle(); angle_t GetClipAngle();
}; };
@ -943,6 +948,10 @@ struct side_t
DInterpolation *SetInterpolation(int position); DInterpolation *SetInterpolation(int position);
void StopInterpolation(int position); void StopInterpolation(int position);
vertex_t *V1() const;
vertex_t *V2() const;
//For GL //For GL
FLightNode * lighthead[2]; // all blended lights that may affect this wall FLightNode * lighthead[2]; // all blended lights that may affect this wall
bool dirty; // GL info needs to be recalculated bool dirty; // GL info needs to be recalculated
@ -965,6 +974,7 @@ enum slopetype_t
ST_NEGATIVE ST_NEGATIVE
}; };
struct line_t struct line_t
{ {
vertex_t *v1, *v2; // vertices, from v1 to v2 vertex_t *v1, *v2; // vertices, from v1 to v2
@ -1011,19 +1021,20 @@ struct msecnode_t
bool visited; // killough 4/4/98, 4/7/98: used in search algorithms bool visited; // killough 4/4/98, 4/7/98: used in search algorithms
}; };
struct FPolyNode;
// //
// A SubSector. // A SubSector.
// References a Sector. // References a Sector.
// Basically, this is a list of LineSegs indicating the visible walls that // Basically, this is a list of LineSegs indicating the visible walls that
// define (all or some) sides of a convex BSP leaf. // define (all or some) sides of a convex BSP leaf.
// //
struct FPolyObj;
struct subsector_t struct subsector_t
{ {
sector_t *sector; sector_t *sector;
DWORD numlines; DWORD numlines;
DWORD firstline; DWORD firstline;
FPolyObj *poly; FPolyNode *polys;
int validcount; int validcount;
fixed_t CenterX, CenterY; fixed_t CenterX, CenterY;
@ -1059,45 +1070,7 @@ struct seg_t
float sidefrac; // relative position of seg's ending vertex on owning sidedef float sidefrac; // relative position of seg's ending vertex on owning sidedef
}; };
// ===== Polyobj data =====
struct FPolyObj
{
int numsegs;
seg_t **segs;
int numlines;
line_t **lines;
int numvertices;
vertex_t **vertices;
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();
DInterpolation *SetInterpolation();
void StopInterpolation();
};
extern FPolyObj *polyobjs; // list of all poly-objects on the level
inline FArchive &operator<< (FArchive &arc, FPolyObj *&poly)
{
return arc.SerializePointer (polyobjs, (BYTE **)&poly, sizeof(FPolyObj));
}
inline FArchive &operator<< (FArchive &arc, const FPolyObj *&poly)
{
return arc.SerializePointer (polyobjs, (BYTE **)&poly, sizeof(FPolyObj));
}
// //
// BSP node. // BSP node.
@ -1110,6 +1083,7 @@ struct node_t
fixed_t dx; fixed_t dx;
fixed_t dy; fixed_t dy;
fixed_t bbox[2][4]; // Bounding box for each child. fixed_t bbox[2][4]; // Bounding box for each child.
float len;
union union
{ {
void *children[2]; // If bit 0 is set, it's a subsector. void *children[2]; // If bit 0 is set, it's a subsector.
@ -1118,15 +1092,6 @@ struct node_t
}; };
struct polyblock_t
{
FPolyObj *polyobj;
struct polyblock_t *prev;
struct polyblock_t *next;
};
// posts are runs of non masked source pixels // posts are runs of non masked source pixels
struct column_t struct column_t
{ {

View file

@ -38,6 +38,8 @@
#include "stats.h" #include "stats.h"
#include "r_interpolate.h" #include "r_interpolate.h"
#include "p_local.h" #include "p_local.h"
#include "i_system.h"
#include "po_man.h"
//========================================================================== //==========================================================================
// //
@ -134,6 +136,8 @@ class DPolyobjInterpolation : public DInterpolation
FPolyObj *poly; FPolyObj *poly;
TArray<fixed_t> oldverts, bakverts; TArray<fixed_t> oldverts, bakverts;
fixed_t oldcx, oldcy;
fixed_t bakcx, bakcy;
public: public:
@ -728,8 +732,8 @@ void DWallScrollInterpolation::Serialize(FArchive &arc)
DPolyobjInterpolation::DPolyobjInterpolation(FPolyObj *po) DPolyobjInterpolation::DPolyobjInterpolation(FPolyObj *po)
{ {
poly = po; poly = po;
oldverts.Resize(po->numvertices<<1); oldverts.Resize(po->Vertices.Size() << 1);
bakverts.Resize(po->numvertices<<1); bakverts.Resize(po->Vertices.Size() << 1);
UpdateInterpolation (); UpdateInterpolation ();
interpolator.AddInterpolation(this); interpolator.AddInterpolation(this);
} }
@ -755,11 +759,13 @@ void DPolyobjInterpolation::Destroy()
void DPolyobjInterpolation::UpdateInterpolation() 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 ] = poly->Vertices[i]->x;
oldverts[i*2+1] = poly->vertices[i]->y; oldverts[i*2+1] = poly->Vertices[i]->y;
} }
oldcx = poly->CenterSpot.x;
oldcy = poly->CenterSpot.y;
} }
//========================================================================== //==========================================================================
@ -770,12 +776,14 @@ void DPolyobjInterpolation::UpdateInterpolation()
void DPolyobjInterpolation::Restore() 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]->x = bakverts[i*2 ];
poly->vertices[i]->y = bakverts[i*2+1]; poly->Vertices[i]->y = bakverts[i*2+1];
} }
//poly->Moved(); poly->CenterSpot.x = bakcx;
poly->CenterSpot.y = bakcy;
poly->ClearSubsectorLinks();
} }
//========================================================================== //==========================================================================
@ -786,10 +794,10 @@ void DPolyobjInterpolation::Restore()
void DPolyobjInterpolation::Interpolate(fixed_t smoothratio) 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 *px = &poly->Vertices[i]->x;
fixed_t *py = &poly->vertices[i]->y; fixed_t *py = &poly->Vertices[i]->y;
bakverts[i*2 ] = *px; bakverts[i*2 ] = *px;
bakverts[i*2+1] = *py; bakverts[i*2+1] = *py;
@ -797,7 +805,12 @@ void DPolyobjInterpolation::Interpolate(fixed_t smoothratio)
*px = oldverts[i*2 ] + FixedMul(bakverts[i*2 ] - oldverts[i*2 ], smoothratio); *px = oldverts[i*2 ] + FixedMul(bakverts[i*2 ] - oldverts[i*2 ], smoothratio);
*py = oldverts[i*2+1] + FixedMul(bakverts[i*2+1] - oldverts[i*2+1], smoothratio); *py = oldverts[i*2+1] + FixedMul(bakverts[i*2+1] - oldverts[i*2+1], smoothratio);
} }
//poly->Moved(); bakcx = poly->CenterSpot.x;
bakcy = poly->CenterSpot.y;
poly->CenterSpot.x = bakcx + FixedMul(bakcx - oldcx, smoothratio);
poly->CenterSpot.y = bakcy + FixedMul(bakcy - oldcy, smoothratio);
poly->ClearSubsectorLinks();
} }
//========================================================================== //==========================================================================
@ -808,11 +821,21 @@ void DPolyobjInterpolation::Interpolate(fixed_t smoothratio)
void DPolyobjInterpolation::Serialize(FArchive &arc) void DPolyobjInterpolation::Serialize(FArchive &arc)
{ {
Super::Serialize(arc); Super::Serialize(arc);
int po = int(poly - polyobjs); int po = int(poly - polyobjs);
arc << po << oldverts; arc << po << oldverts;
poly = polyobjs + po; poly = polyobjs + po;
if (SaveVersion >= 2448)
{
arc << oldcx << oldcy;
}
else
{
// This will glitch if an old savegame is loaded but at least it'll allow loading it.
oldcx = poly->CenterSpot.x;
oldcy = poly->CenterSpot.y;
}
if (arc.IsLoading()) bakverts.Resize(oldverts.Size()); if (arc.IsLoading()) bakverts.Resize(oldverts.Size());
} }

View file

@ -50,6 +50,7 @@
#include "r_bsp.h" #include "r_bsp.h"
#include "r_plane.h" #include "r_plane.h"
#include "v_palette.h" #include "v_palette.h"
#include "po_man.h"
//#include "gl/data/gl_data.h" //#include "gl/data/gl_data.h"
#include "gl/gl_functions.h" #include "gl/gl_functions.h"
@ -1496,6 +1497,8 @@ void R_RenderActorView (AActor *actor, bool dontmaplines)
{ {
camera->renderflags |= RF_INVISIBLE; camera->renderflags |= RF_INVISIBLE;
} }
// Link the polyobjects right before drawing the scene to reduce the amounts of calls to this function
PO_LinkToSubsectors();
if (r_polymost < 2) if (r_polymost < 2)
{ {
R_RenderBSPNode (nodes + numnodes - 1); // The head node is the last node output. R_RenderBSPNode (nodes + numnodes - 1); // The head node is the last node output.

View file

@ -1471,6 +1471,7 @@ void RP_Subsector (subsector_t *sub)
// R_ProjectParticle (Particles + i, subsectors[sub-subsectors].sector, shade, FakeSide); // R_ProjectParticle (Particles + i, subsectors[sub-subsectors].sector, shade, FakeSide);
// } // }
#if 0
if (sub->poly) if (sub->poly)
{ // Render the polyobj in the subsector first { // Render the polyobj in the subsector first
int polyCount = sub->poly->numsegs; int polyCount = sub->poly->numsegs;
@ -1480,6 +1481,7 @@ void RP_Subsector (subsector_t *sub)
RP_AddLine (*polySeg++); RP_AddLine (*polySeg++);
} }
} }
#endif
while (count--) while (count--)
{ {

View file

@ -22,6 +22,7 @@
#include "i_system.h" #include "i_system.h"
#include "cmdlib.h" #include "cmdlib.h"
#include "p_local.h" #include "p_local.h"
#include "po_man.h"
#include "gi.h" #include "gi.h"
#include "templates.h" #include "templates.h"
#include "c_dispatch.h" #include "c_dispatch.h"

View file

@ -49,6 +49,7 @@
#include "templates.h" #include "templates.h"
#include "timidity/timidity.h" #include "timidity/timidity.h"
#include "g_level.h" #include "g_level.h"
#include "po_man.h"
// MACROS ------------------------------------------------------------------ // MACROS ------------------------------------------------------------------
@ -795,11 +796,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) static void CalcPolyobjSoundOrg(const FPolyObj *poly, fixed_t *x, fixed_t *y, fixed_t *z)
{ {
seg_t *seg; side_t *side;
sector_t *sec; sector_t *sec;
PO_ClosestPoint(poly, *x, *y, *x, *y, &seg); poly->ClosestPoint(*x, *y, *x, *y, &side);
sec = seg->frontsector; sec = side->sector;
*z = clamp(*z, sec->floorplane.ZatPoint(*x, *y), sec->ceilingplane.ZatPoint(*x, *y)); *z = clamp(*z, sec->floorplane.ZatPoint(*x, *y), sec->ceilingplane.ZatPoint(*x, *y));
} }

View file

@ -3,5 +3,5 @@
// This file was automatically generated by the // This file was automatically generated by the
// updaterevision tool. Do not edit by hand. // updaterevision tool. Do not edit by hand.
#define ZD_SVN_REVISION_STRING "2442" #define ZD_SVN_REVISION_STRING "2448"
#define ZD_SVN_REVISION_NUMBER 2442 #define ZD_SVN_REVISION_NUMBER 2448

View file

@ -129,6 +129,12 @@ public:
{ {
return Array[index]; return Array[index];
} }
// Returns a reference to the last element
T &Last() const
{
return Array[Count-1];
}
unsigned int Push (const T &item) unsigned int Push (const T &item)
{ {
Grow (1); Grow (1);

View file

@ -618,7 +618,6 @@ int FMultiPatchTexture::CopyTrueColorPixels(FBitmap *bmp, int x, int y, int rota
FBitmap bmp1; FBitmap bmp1;
if (bmp1.Create(Parts[i].Texture->GetWidth(), Parts[i].Texture->GetHeight())) if (bmp1.Create(Parts[i].Texture->GetWidth(), Parts[i].Texture->GetHeight()))
{ {
bmp1.Zero();
bmp1.Zero(); bmp1.Zero();
Parts[i].Texture->CopyTrueColorPixels(&bmp1, 0, 0); Parts[i].Texture->CopyTrueColorPixels(&bmp1, 0, 0);
bmp->CopyPixelDataRGB(x+Parts[i].OriginX, y+Parts[i].OriginY, bmp1.GetPixels(), bmp->CopyPixelDataRGB(x+Parts[i].OriginX, y+Parts[i].OriginY, bmp1.GetPixels(),