Skip to content

Commit

Permalink
Revised R_InitLineNeighbors() to make use of vertex lineowners. In do…
Browse files Browse the repository at this point in the history
…ing so, the majority of the visual fakeradio glitches when playing maps utilizing DOOM renderer hacks have been resolved (the old code was sometimes finding the wrong line neighbors). Is also noticeably quicker as we don't have to traverse all the lines in a sector for each vertex for each side, for each neighbor.

Fixed a bug in R_RationalizeSectors() which could result in an infinite loop in complex maps (e.g. bludwrks.wad).
Began changing the method used to support linked planes to a per-subsector (group) based design. Currently waiting on an algorithm to find the subsectors which have at least one seg belonging to linedefs detected in R_RationalizeSectors() and seperating into groups. Atm, subsectors of a sector are simply added to the same group.
Added cvar "rend-dev-surface-linked" for debug; temporarily disable the visual results of linked surfaces.
Various other minor tweaks/optimizations.
  • Loading branch information
danij committed Feb 4, 2007
1 parent d72ee5f commit 0d43796
Show file tree
Hide file tree
Showing 17 changed files with 920 additions and 841 deletions.
3 changes: 3 additions & 0 deletions doomsday/engine/data/cphelp.txt
Expand Up @@ -610,6 +610,9 @@ desc = 1=Render player view in wireframe mode.
[rend-dev-framecount]
desc = Frame counter.

[rend-dev-surface-linked]
desc = 1=Disable linked surfaces for render.

[rend-info-lums]
desc = 1=Print lumobj count after rendering a frame.

Expand Down
621 changes: 319 additions & 302 deletions doomsday/engine/portable/include/mapdata.hs

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions doomsday/engine/portable/include/p_mapdata.h
Expand Up @@ -101,16 +101,6 @@ typedef struct fvertex_s {
float pos[2];
} fvertex_t;

enum {
PLN_FLOOR,
PLN_CEILING,
NUM_PLANE_TYPES
};

typedef struct skyfix_s {
float offset;
} skyfix_t;

#include "p_maptypes.h"

/*
Expand Down
23 changes: 20 additions & 3 deletions doomsday/engine/portable/include/p_maptypes.h
Expand Up @@ -61,6 +61,7 @@ typedef struct subsector_s {
struct fvertex_s* vertices;
int validcount;
struct shadowlink_s* shadows;
unsigned int group;
} subsector_t;

// Surface flags.
Expand Down Expand Up @@ -91,6 +92,16 @@ typedef struct surface_s {
struct translation_s* xlat;
} surface_t;

enum {
PLN_FLOOR,
PLN_CEILING,
NUM_PLANE_TYPES
};

typedef struct skyfix_s {
float offset;
} skyfix_t;

typedef struct plane_s {
runtime_mapdata_header_t header;
float height; // Current height
Expand All @@ -104,7 +115,6 @@ typedef struct plane_s {
struct sector_s* sector; // Owner of the plane (temp)
float visheight; // Visible plane height (smoothed)
float visoffset;
struct sector_s* linked; // Plane attached to another sector.
} plane_t;

// Helper macros for accessing sector floor/ceiling plane data elements.
Expand All @@ -123,7 +133,6 @@ typedef struct plane_s {
#define SP_ceiltexmove planes[PLN_CEILING]->surface.texmove
#define SP_ceilsoundorg planes[PLN_CEILING]->soundorg
#define SP_ceilvisheight planes[PLN_CEILING]->visheight
#define SP_ceillinked planes[PLN_CEILING]->linked

#define SP_floorsurface planes[PLN_FLOOR]->surface
#define SP_floorheight planes[PLN_FLOOR]->height
Expand All @@ -140,7 +149,6 @@ typedef struct plane_s {
#define SP_floortexmove planes[PLN_FLOOR]->surface.texmove
#define SP_floorsoundorg planes[PLN_FLOOR]->soundorg
#define SP_floorvisheight planes[PLN_FLOOR]->visheight
#define SP_floorlinked planes[PLN_FLOOR]->linked

#define SECT_PLANE_HEIGHT(x, n) (x->planes[n]->visheight)

Expand All @@ -153,6 +161,11 @@ typedef struct plane_s {
#define SECF_INVIS_FLOOR 0x1
#define SECF_INVIS_CEILING 0x2

typedef struct ssecgroup_s {
struct sector_s** linked; // [sector->planecount] size.
// Plane attached to another sector.
} ssecgroup_t;

typedef struct sector_s {
runtime_mapdata_header_t header;
short lightlevel;
Expand All @@ -165,6 +178,8 @@ typedef struct sector_s {
struct line_s** Lines; // [linecount] size.
unsigned int subscount;
struct subsector_s** subsectors; // [subscount] size.
unsigned int subsgroupcount;
ssecgroup_t* subsgroups; // [subsgroupcount] size.
skyfix_t skyfix[2]; // floor, ceiling.
degenmobj_t soundorg;
float reverb[NUM_REVERB_DATA];
Expand Down Expand Up @@ -254,6 +269,8 @@ typedef struct side_s {
#define L_frontside sides[FRONT]
#define L_backside sides[BACK]

#define LINE_NEIGHBOR(line, side) (side? line->vo[side]->next->line : line->vo[side]->prev->line)

typedef struct line_s {
runtime_mapdata_header_t header;
struct vertex_s* v[2];
Expand Down
1 change: 1 addition & 0 deletions doomsday/engine/portable/include/r_data.h
Expand Up @@ -186,6 +186,7 @@ typedef struct linkmobj_s {

typedef struct shadowpoly_s {
struct line_s *line;
struct subsector_s *ssec;
short flags;
ushort visframe; // Last visible frame (for rendering).
struct vertex_s *outer[2]; // Left and right.
Expand Down
3 changes: 2 additions & 1 deletion doomsday/engine/portable/include/r_shadow.h
Expand Up @@ -31,6 +31,7 @@
void R_InitSectorShadows(void);
line_t *R_GetShadowNeighbor(shadowpoly_t *poly, boolean left,
boolean back);
sector_t *R_GetShadowSector(shadowpoly_t *poly);
sector_t *R_GetShadowSector(shadowpoly_t *poly, uint plane,
boolean getLinked);

#endif
2 changes: 1 addition & 1 deletion doomsday/engine/portable/include/r_world.h
Expand Up @@ -46,7 +46,7 @@ void R_SetupLevel(int mode, int flags);
void R_InitLinks(void);
void R_SetupFog(void);
void R_SetupSky(void);
sector_t *R_GetLinkedSector(sector_t *startsec, uint plane);
sector_t *R_GetLinkedSector(subsector_t *startssec, uint plane);
void R_UpdatePlanes(void);
void R_ClearSectorFlags(void);
void R_SkyFix(boolean fixFloors, boolean fixCeilings);
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/portable/include/rend_fakeradio.h
Expand Up @@ -30,7 +30,7 @@

void Rend_RadioRegister(void);
void Rend_RadioInitForFrame(void);
void Rend_RadioInitForSector(sector_t *sector);
void Rend_RadioInitForSubsector(subsector_t *sector);
void Rend_RadioWallSection(const seg_t *seg, rendpoly_t *origQuad);
void Rend_RadioSubsectorEdges(subsector_t *subsector);

Expand Down
1 change: 1 addition & 0 deletions doomsday/engine/portable/include/rend_main.h
Expand Up @@ -43,6 +43,7 @@ extern int missileBlend, litSprites;
extern boolean usingFog;
extern byte fogColor[4];
extern int r_ambient;
extern byte devNoLinkedSurfaces;

extern signed short lightRangeModMatrix[MOD_RANGE][255];

Expand Down
17 changes: 10 additions & 7 deletions doomsday/engine/portable/src/dam_main.c
Expand Up @@ -1836,6 +1836,7 @@ static void allocateMapData(gamemap_t *map)
subsector_t *ssec = &map->subsectors[k];

ssec->header.type = DMU_SUBSECTOR;
ssec->group = 0;
}

// Nodes.
Expand Down Expand Up @@ -2641,9 +2642,6 @@ static void finalizeMapData(gamemap_t *map)
for(j = 0, seg = ss->firstseg; j < ss->segcount; ++j, seg++)
if(seg->sidedef)
{
#if _DEBUG
ASSERT_DMU_TYPE(seg->sidedef->sector, DMU_SECTOR);
#endif
ss->sector = seg->sidedef->sector;
ss->sector->subscount++;
break;
Expand Down Expand Up @@ -2710,6 +2708,12 @@ ASSERT_DMU_TYPE(seg->sidedef->sector, DMU_SECTOR);
if(ssecsInSector[i] != sec->subscount)
Con_Error("finalizeMapData: miscounted subsectors"); // Hmm? Unusual...

sec->subsgroupcount = 1;
sec->subsgroups = Z_Malloc(sizeof(ssecgroup_t) * sec->subsgroupcount, PU_LEVEL, 0);
sec->subsgroups[0].linked = Z_Malloc(sizeof(sector_t*) * sec->planecount, PU_LEVEL, 0);
for(k = 0; k < sec->planecount; ++k)
sec->subsgroups[0].linked[k] = NULL;

if(sec->linecount != 0)
{
M_ClearBox(bbox);
Expand Down Expand Up @@ -2755,17 +2759,16 @@ ASSERT_DMU_TYPE(seg->sidedef->sector, DMU_SECTOR);
sec->soundorg.pos[VZ] =
FLT2FIX((sec->SP_ceilheight - sec->SP_floorheight) / 2);

// Set the position of the sound origin for all plane sound origins.
// Set the position of the sound origin for all plane sound origins
// and target heights of all planes.
for(k = 0; k < sec->planecount; ++k)
{
sec->planes[k]->soundorg.pos[VX] = sec->soundorg.pos[VX];
sec->planes[k]->soundorg.pos[VY] = sec->soundorg.pos[VY];
sec->planes[k]->soundorg.pos[VZ] = FLT2FIX(sec->planes[k]->height);
}

// Set target heights of all planes.
for(k = 0; k < sec->planecount; ++k)
sec->planes[k]->target = sec->planes[k]->height;
}
}

M_Free(linesInSector);
Expand Down
4 changes: 1 addition & 3 deletions doomsday/engine/portable/src/p_data.c
Expand Up @@ -174,9 +174,7 @@ void P_PlaneChanged(sector_t *sector, uint plane)
back = sector->Lines[i]->sides[1];

if(!front || !front->sector ||
front->sector->planes[plane]->linked ||
!back || !back->sector ||
back->sector->planes[plane]->linked)
!back || !back->sector)
continue;

// Do as in the original Doom if the texture has not been defined -
Expand Down
30 changes: 9 additions & 21 deletions doomsday/engine/portable/src/r_main.c
Expand Up @@ -350,12 +350,7 @@ void R_NewSharpWorld(void)

if(resetNextViewer)
resetNextViewer = 2;
/*
if(useVSync)
gl.Enable(DGL_VSYNC);
else
gl.Disable(DGL_VSYNC);
*/

R_GetSharpView(&sharpView, viewplayer);

// Update the camera angles that will be used when the camera is
Expand Down Expand Up @@ -386,12 +381,13 @@ void R_NewSharpWorld(void)
plane->oldheight[0] = plane->oldheight[1];
plane->oldheight[1] = plane->height;

if(fabs(plane->oldheight[0] - plane->oldheight[1]) >=
MAX_SMOOTH_PLANE_MOVE)
{
// Too fast: make an instantaneous jump.
plane->oldheight[0] = plane->oldheight[1];
}
if(plane->oldheight[0] != plane->oldheight[1])
if(fabs(plane->oldheight[0] - plane->oldheight[1]) >=
MAX_SMOOTH_PLANE_MOVE)
{
// Too fast: make an instantaneous jump.
plane->oldheight[0] = plane->oldheight[1];
}
}
}
}
Expand Down Expand Up @@ -448,15 +444,7 @@ void R_SetupWorldFrame(void)
plane->height;

// Visible plane height.
if(!plane->linked)
{
plane->visheight = plane->height + plane->visoffset;
}
else
{
plane->visheight =
R_GetLinkedSector(plane->linked, j)->planes[j]->height;
}
plane->visheight = plane->height + plane->visoffset;
}
}
}
Expand Down

0 comments on commit 0d43796

Please sign in to comment.