mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-28 06:42:09 +00:00
Move visplane_t to its own file
This commit is contained in:
parent
775deeb151
commit
80e369541a
6 changed files with 178 additions and 197 deletions
|
@ -825,6 +825,7 @@ set( FASTMATH_PCH_SOURCES
|
|||
swrenderer/scene/r_draw_segment.cpp
|
||||
swrenderer/scene/r_portal_segment.cpp
|
||||
swrenderer/scene/r_portal.cpp
|
||||
swrenderer/scene/r_visible_plane.cpp
|
||||
polyrenderer/poly_renderer.cpp
|
||||
polyrenderer/scene/poly_scene.cpp
|
||||
polyrenderer/scene/poly_portal.cpp
|
||||
|
|
|
@ -377,7 +377,6 @@ void R_InitRenderer()
|
|||
// viewwidth / viewheight are set by the defaults
|
||||
fillshort (zeroarray, MAXWIDTH, 0);
|
||||
|
||||
R_InitPlanes ();
|
||||
R_InitShadeMaps();
|
||||
R_InitColumnDrawers ();
|
||||
}
|
||||
|
@ -392,6 +391,7 @@ static void R_ShutdownRenderer()
|
|||
{
|
||||
R_DeinitSprites();
|
||||
R_DeinitPlanes();
|
||||
fakeActive = 0;
|
||||
// Free openings
|
||||
if (openings != NULL)
|
||||
{
|
||||
|
|
|
@ -89,20 +89,9 @@ static void R_DrawSkyStriped (visplane_t *pl);
|
|||
planefunction_t floorfunc;
|
||||
planefunction_t ceilingfunc;
|
||||
|
||||
// [RH] Allocate one extra for sky box planes.
|
||||
visplane_t *visplanes[MAXVISPLANES+1];
|
||||
visplane_t *freetail;
|
||||
visplane_t **freehead = &freetail;
|
||||
|
||||
visplane_t *floorplane;
|
||||
visplane_t *ceilingplane;
|
||||
|
||||
// killough -- hash function for visplanes
|
||||
// Empirically verified to be fairly uniform:
|
||||
|
||||
#define visplane_hash(picnum,lightlevel,height) \
|
||||
((unsigned)((picnum)*3+(lightlevel)+(FLOAT2FIXED((height).fD()))*7) & (MAXVISPLANES-1))
|
||||
|
||||
// These are copies of the main parameters used when drawing stacked sectors.
|
||||
// When you change the main parameters, you should copy them here too *unless*
|
||||
// you are changing them to draw a stacked sector. Otherwise, stacked sectors
|
||||
|
@ -146,44 +135,6 @@ static double basexfrac, baseyfrac;
|
|||
|
||||
void R_DrawSinglePlane (visplane_t *, fixed_t alpha, bool additive, bool masked);
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_InitPlanes
|
||||
//
|
||||
// Called at game startup.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void R_InitPlanes ()
|
||||
{
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_DeinitPlanes
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
void R_DeinitPlanes ()
|
||||
{
|
||||
fakeActive = 0;
|
||||
|
||||
// do not use R_ClearPlanes because at this point the screen pointer is no longer valid.
|
||||
for (int i = 0; i <= MAXVISPLANES; i++) // new code -- killough
|
||||
{
|
||||
for (*freehead = visplanes[i], visplanes[i] = NULL; *freehead; )
|
||||
{
|
||||
freehead = &(*freehead)->next;
|
||||
}
|
||||
}
|
||||
for (visplane_t *pl = freetail; pl != NULL; )
|
||||
{
|
||||
visplane_t *next = pl->next;
|
||||
free (pl);
|
||||
pl = next;
|
||||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_MapPlane
|
||||
|
@ -537,38 +488,6 @@ void R_ClearPlanes (bool fullclear)
|
|||
}
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// new_visplane
|
||||
//
|
||||
// New function, by Lee Killough
|
||||
// [RH] top and bottom buffers get allocated immediately after the visplane.
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
static visplane_t *new_visplane (unsigned hash)
|
||||
{
|
||||
visplane_t *check = freetail;
|
||||
|
||||
if (check == NULL)
|
||||
{
|
||||
check = (visplane_t *)M_Malloc (sizeof(*check) + 3 + sizeof(*check->top)*(MAXWIDTH*2));
|
||||
memset(check, 0, sizeof(*check) + 3 + sizeof(*check->top)*(MAXWIDTH*2));
|
||||
check->bottom = check->top + MAXWIDTH+2;
|
||||
}
|
||||
else if (NULL == (freetail = freetail->next))
|
||||
{
|
||||
freehead = &freetail;
|
||||
}
|
||||
|
||||
check->lights = nullptr;
|
||||
|
||||
check->next = visplanes[hash];
|
||||
visplanes[hash] = check;
|
||||
return check;
|
||||
}
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_FindPlane
|
||||
|
@ -1754,42 +1673,4 @@ void R_MapVisPlane (visplane_t *pl, void (*mapfunc)(int y, int x1))
|
|||
ds_light_list = nullptr;
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
// R_PlaneInitData
|
||||
//
|
||||
//==========================================================================
|
||||
|
||||
bool R_PlaneInitData ()
|
||||
{
|
||||
int i;
|
||||
visplane_t *pl;
|
||||
|
||||
// Free all visplanes and let them be re-allocated as needed.
|
||||
pl = freetail;
|
||||
|
||||
while (pl)
|
||||
{
|
||||
visplane_t *next = pl->next;
|
||||
M_Free (pl);
|
||||
pl = next;
|
||||
}
|
||||
freetail = NULL;
|
||||
freehead = &freetail;
|
||||
|
||||
for (i = 0; i < MAXVISPLANES; i++)
|
||||
{
|
||||
pl = visplanes[i];
|
||||
visplanes[i] = NULL;
|
||||
while (pl)
|
||||
{
|
||||
visplane_t *next = pl->next;
|
||||
M_Free (pl);
|
||||
pl = next;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,63 +23,11 @@
|
|||
#ifndef __R_PLANE_H__
|
||||
#define __R_PLANE_H__
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
class ASkyViewpoint;
|
||||
class ADynamicLight;
|
||||
struct FLightNode;
|
||||
#include "r_visible_plane.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
|
||||
struct visplane_light
|
||||
{
|
||||
ADynamicLight *lightsource;
|
||||
visplane_light *next;
|
||||
};
|
||||
|
||||
//
|
||||
// The infamous visplane
|
||||
//
|
||||
struct visplane_s
|
||||
{
|
||||
struct visplane_s *next; // Next visplane in hash chain -- killough
|
||||
|
||||
FDynamicColormap *colormap; // [RH] Support multiple colormaps
|
||||
FSectorPortal *portal; // [RH] Support sky boxes
|
||||
visplane_light *lights;
|
||||
|
||||
FTransform xform;
|
||||
secplane_t height;
|
||||
FTextureID picnum;
|
||||
int lightlevel;
|
||||
int left, right;
|
||||
int sky;
|
||||
|
||||
// [RH] This set of variables copies information from the time when the
|
||||
// visplane is created. They are only used by stacks so that you can
|
||||
// have stacked sectors inside a skybox. If the visplane is not for a
|
||||
// stack, then they are unused.
|
||||
int extralight;
|
||||
double visibility;
|
||||
DVector3 viewpos;
|
||||
DAngle viewangle;
|
||||
fixed_t Alpha;
|
||||
bool Additive;
|
||||
|
||||
// kg3D - keep track of mirror and skybox owner
|
||||
int CurrentSkybox;
|
||||
int CurrentPortalUniq; // mirror counter, counts all of them
|
||||
int MirrorFlags; // this is not related to CurrentMirror
|
||||
|
||||
unsigned short *bottom; // [RH] bottom and top arrays are dynamically
|
||||
unsigned short pad; // allocated immediately after the
|
||||
unsigned short top[]; // visplane.
|
||||
};
|
||||
typedef struct visplane_s visplane_t;
|
||||
|
||||
|
||||
|
||||
typedef void (*planefunction_t) (int top, int bottom);
|
||||
|
||||
extern planefunction_t floorfunc;
|
||||
|
@ -90,8 +38,6 @@ extern short ceilingclip[MAXWIDTH];
|
|||
|
||||
extern float yslope[MAXHEIGHT];
|
||||
|
||||
void R_InitPlanes ();
|
||||
void R_DeinitPlanes ();
|
||||
void R_ClearPlanes (bool fullclear);
|
||||
|
||||
void R_AddPlaneLights(visplane_t *plane, FLightNode *light_head);
|
||||
|
@ -108,32 +54,12 @@ void R_MapColoredPlane(int y, int x1);
|
|||
|
||||
void R_DrawFogBoundary(int x1, int x2, short *uclip, short *dclip);
|
||||
|
||||
visplane_t *R_FindPlane
|
||||
( const secplane_t &height,
|
||||
FTextureID picnum,
|
||||
int lightlevel,
|
||||
double alpha,
|
||||
bool additive,
|
||||
const FTransform &xform,
|
||||
int sky,
|
||||
FSectorPortal *portal);
|
||||
|
||||
visplane_t *R_CheckPlane (visplane_t *pl, int start, int stop);
|
||||
|
||||
|
||||
// [RH] Added for multires support
|
||||
bool R_PlaneInitData (void);
|
||||
|
||||
visplane_t *R_FindPlane(const secplane_t &height, FTextureID picnum, int lightlevel, double alpha, bool additive, const FTransform &xform, int sky, FSectorPortal *portal);
|
||||
visplane_t *R_CheckPlane(visplane_t *pl, int start, int stop);
|
||||
|
||||
extern visplane_t* floorplane;
|
||||
extern visplane_t* ceilingplane;
|
||||
|
||||
#define MAXVISPLANES 128 /* must be a power of 2 */
|
||||
|
||||
extern visplane_t *visplanes[MAXVISPLANES + 1];
|
||||
extern visplane_t *freetail;
|
||||
extern visplane_t **freehead;
|
||||
|
||||
}
|
||||
|
||||
#endif // __R_PLANE_H__
|
||||
|
|
106
src/swrenderer/scene/r_visible_plane.cpp
Normal file
106
src/swrenderer/scene/r_visible_plane.cpp
Normal file
|
@ -0,0 +1,106 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "templates.h"
|
||||
#include "i_system.h"
|
||||
#include "w_wad.h"
|
||||
#include "doomdef.h"
|
||||
#include "doomstat.h"
|
||||
#include "swrenderer/r_main.h"
|
||||
#include "swrenderer/scene/r_things.h"
|
||||
#include "r_sky.h"
|
||||
#include "stats.h"
|
||||
#include "v_video.h"
|
||||
#include "a_sharedglobal.h"
|
||||
#include "c_console.h"
|
||||
#include "cmdlib.h"
|
||||
#include "d_net.h"
|
||||
#include "g_level.h"
|
||||
#include "r_bsp.h"
|
||||
#include "r_visible_plane.h"
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
// [RH] Allocate one extra for sky box planes.
|
||||
visplane_t *visplanes[MAXVISPLANES + 1];
|
||||
visplane_t *freetail;
|
||||
visplane_t **freehead = &freetail;
|
||||
|
||||
namespace
|
||||
{
|
||||
enum { max_plane_lights = 32 * 1024 };
|
||||
visplane_light plane_lights[max_plane_lights];
|
||||
int next_plane_light = 0;
|
||||
}
|
||||
|
||||
void R_DeinitPlanes()
|
||||
{
|
||||
// do not use R_ClearPlanes because at this point the screen pointer is no longer valid.
|
||||
for (int i = 0; i <= MAXVISPLANES; i++) // new code -- killough
|
||||
{
|
||||
for (*freehead = visplanes[i], visplanes[i] = NULL; *freehead; )
|
||||
{
|
||||
freehead = &(*freehead)->next;
|
||||
}
|
||||
}
|
||||
for (visplane_t *pl = freetail; pl != NULL; )
|
||||
{
|
||||
visplane_t *next = pl->next;
|
||||
free(pl);
|
||||
pl = next;
|
||||
}
|
||||
}
|
||||
|
||||
visplane_t *new_visplane(unsigned hash)
|
||||
{
|
||||
visplane_t *check = freetail;
|
||||
|
||||
if (check == NULL)
|
||||
{
|
||||
check = (visplane_t *)M_Malloc(sizeof(*check) + 3 + sizeof(*check->top)*(MAXWIDTH * 2));
|
||||
memset(check, 0, sizeof(*check) + 3 + sizeof(*check->top)*(MAXWIDTH * 2));
|
||||
check->bottom = check->top + MAXWIDTH + 2;
|
||||
}
|
||||
else if (NULL == (freetail = freetail->next))
|
||||
{
|
||||
freehead = &freetail;
|
||||
}
|
||||
|
||||
check->lights = nullptr;
|
||||
|
||||
check->next = visplanes[hash];
|
||||
visplanes[hash] = check;
|
||||
return check;
|
||||
}
|
||||
|
||||
void R_PlaneInitData()
|
||||
{
|
||||
int i;
|
||||
visplane_t *pl;
|
||||
|
||||
// Free all visplanes and let them be re-allocated as needed.
|
||||
pl = freetail;
|
||||
|
||||
while (pl)
|
||||
{
|
||||
visplane_t *next = pl->next;
|
||||
M_Free(pl);
|
||||
pl = next;
|
||||
}
|
||||
freetail = NULL;
|
||||
freehead = &freetail;
|
||||
|
||||
for (i = 0; i < MAXVISPLANES; i++)
|
||||
{
|
||||
pl = visplanes[i];
|
||||
visplanes[i] = NULL;
|
||||
while (pl)
|
||||
{
|
||||
visplane_t *next = pl->next;
|
||||
M_Free(pl);
|
||||
pl = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
67
src/swrenderer/scene/r_visible_plane.h
Normal file
67
src/swrenderer/scene/r_visible_plane.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include "r_defs.h"
|
||||
|
||||
class ASkyViewpoint;
|
||||
class ADynamicLight;
|
||||
struct FLightNode;
|
||||
struct FDynamicColormap;
|
||||
struct FSectorPortal;
|
||||
|
||||
namespace swrenderer
|
||||
{
|
||||
struct visplane_light
|
||||
{
|
||||
ADynamicLight *lightsource;
|
||||
visplane_light *next;
|
||||
};
|
||||
|
||||
struct visplane_t
|
||||
{
|
||||
visplane_t *next; // Next visplane in hash chain -- killough
|
||||
|
||||
FDynamicColormap *colormap; // [RH] Support multiple colormaps
|
||||
FSectorPortal *portal; // [RH] Support sky boxes
|
||||
visplane_light *lights;
|
||||
|
||||
FTransform xform;
|
||||
secplane_t height;
|
||||
FTextureID picnum;
|
||||
int lightlevel;
|
||||
int left, right;
|
||||
int sky;
|
||||
|
||||
// [RH] This set of variables copies information from the time when the
|
||||
// visplane is created. They are only used by stacks so that you can
|
||||
// have stacked sectors inside a skybox. If the visplane is not for a
|
||||
// stack, then they are unused.
|
||||
int extralight;
|
||||
double visibility;
|
||||
DVector3 viewpos;
|
||||
DAngle viewangle;
|
||||
fixed_t Alpha;
|
||||
bool Additive;
|
||||
|
||||
// kg3D - keep track of mirror and skybox owner
|
||||
int CurrentSkybox;
|
||||
int CurrentPortalUniq; // mirror counter, counts all of them
|
||||
int MirrorFlags; // this is not related to CurrentMirror
|
||||
|
||||
unsigned short *bottom; // [RH] bottom and top arrays are dynamically
|
||||
unsigned short pad; // allocated immediately after the
|
||||
unsigned short top[]; // visplane.
|
||||
};
|
||||
|
||||
#define MAXVISPLANES 128 /* must be a power of 2 */
|
||||
#define visplane_hash(picnum,lightlevel,height) ((unsigned)((picnum)*3+(lightlevel)+(FLOAT2FIXED((height).fD()))*7) & (MAXVISPLANES-1))
|
||||
|
||||
extern visplane_t *visplanes[MAXVISPLANES + 1];
|
||||
extern visplane_t *freetail;
|
||||
extern visplane_t **freehead;
|
||||
|
||||
void R_DeinitPlanes();
|
||||
visplane_t *new_visplane(unsigned hash);
|
||||
void R_PlaneInitData();
|
||||
}
|
Loading…
Reference in a new issue