mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-12 07:34:50 +00:00
Convert r_visibleplane into classes
This commit is contained in:
parent
9f8ac7e498
commit
2988a5fe87
9 changed files with 195 additions and 156 deletions
|
@ -537,7 +537,7 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
if (ceilingplane)
|
if (ceilingplane)
|
||||||
{ // killough 4/11/98: add NULL ptr checks
|
{ // killough 4/11/98: add NULL ptr checks
|
||||||
ceilingplane = R_CheckPlane(ceilingplane, start, stop);
|
ceilingplane = VisiblePlaneList::Instance()->GetRange(ceilingplane, start, stop);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -549,7 +549,7 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
if (floorplane)
|
if (floorplane)
|
||||||
{ // killough 4/11/98: add NULL ptr checks
|
{ // killough 4/11/98: add NULL ptr checks
|
||||||
floorplane = R_CheckPlane(floorplane, start, stop);
|
floorplane = VisiblePlaneList::Instance()->GetRange(floorplane, start, stop);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -559,7 +559,8 @@ namespace swrenderer
|
||||||
|
|
||||||
RenderWallSegmentTextures(start, stop);
|
RenderWallSegmentTextures(start, stop);
|
||||||
|
|
||||||
if (clip3d->fake3D & FAKE3D_FAKEMASK) {
|
if (clip3d->fake3D & FAKE3D_FAKEMASK)
|
||||||
|
{
|
||||||
return (clip3d->fake3D & FAKE3D_FAKEMASK) == 0;
|
return (clip3d->fake3D & FAKE3D_FAKEMASK) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "g_level.h"
|
#include "g_level.h"
|
||||||
#include "gl/dynlights/gl_dynlight.h"
|
#include "gl/dynlights/gl_dynlight.h"
|
||||||
#include "swrenderer/r_main.h"
|
#include "swrenderer/r_main.h"
|
||||||
|
#include "swrenderer/r_memory.h"
|
||||||
#include "swrenderer/scene/r_opaque_pass.h"
|
#include "swrenderer/scene/r_opaque_pass.h"
|
||||||
#include "swrenderer/scene/r_3dfloors.h"
|
#include "swrenderer/scene/r_3dfloors.h"
|
||||||
#include "swrenderer/scene/r_portal.h"
|
#include "swrenderer/scene/r_portal.h"
|
||||||
|
@ -42,19 +43,101 @@ CVAR(Bool, tilt, false, 0);
|
||||||
|
|
||||||
namespace swrenderer
|
namespace swrenderer
|
||||||
{
|
{
|
||||||
// [RH] Allocate one extra for sky box planes.
|
void visplane_t::AddLights(FLightNode *node)
|
||||||
visplane_t *visplanes[MAXVISPLANES + 1];
|
|
||||||
visplane_t *freetail;
|
|
||||||
visplane_t **freehead = &freetail;
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
{
|
||||||
enum { max_plane_lights = 32 * 1024 };
|
if (!r_dynlights)
|
||||||
visplane_light plane_lights[max_plane_lights];
|
return;
|
||||||
int next_plane_light = 0;
|
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
if (!(node->lightsource->flags2&MF2_DORMANT))
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
visplane_light *light_node = lights;
|
||||||
|
while (light_node)
|
||||||
|
{
|
||||||
|
if (light_node->lightsource == node->lightsource)
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
light_node = light_node->next;
|
||||||
|
}
|
||||||
|
if (!found)
|
||||||
|
{
|
||||||
|
visplane_light *newlight = R_NewPlaneLight();
|
||||||
|
if (!newlight)
|
||||||
|
return;
|
||||||
|
|
||||||
|
newlight->next = lights;
|
||||||
|
newlight->lightsource = node->lightsource;
|
||||||
|
lights = newlight;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
node = node->nextLight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_DeinitPlanes()
|
void visplane_t::Render(fixed_t alpha, bool additive, bool masked)
|
||||||
|
{
|
||||||
|
if (left >= right)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (picnum == skyflatnum) // sky flat
|
||||||
|
{
|
||||||
|
RenderSkyPlane::Render(this);
|
||||||
|
}
|
||||||
|
else // regular flat
|
||||||
|
{
|
||||||
|
FTexture *tex = TexMan(picnum, true);
|
||||||
|
|
||||||
|
if (tex->UseType == FTexture::TEX_Null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!masked && !additive)
|
||||||
|
{ // If we're not supposed to see through this plane, draw it opaque.
|
||||||
|
alpha = OPAQUE;
|
||||||
|
}
|
||||||
|
else if (!tex->bMasked)
|
||||||
|
{ // Don't waste time on a masked texture if it isn't really masked.
|
||||||
|
masked = false;
|
||||||
|
}
|
||||||
|
R_SetSpanTexture(tex);
|
||||||
|
double xscale = xform.xScale * tex->Scale.X;
|
||||||
|
double yscale = xform.yScale * tex->Scale.Y;
|
||||||
|
|
||||||
|
basecolormap = colormap;
|
||||||
|
|
||||||
|
if (!height.isSlope() && !tilt)
|
||||||
|
{
|
||||||
|
RenderFlatPlane renderer;
|
||||||
|
renderer.Render(this, xscale, yscale, alpha, additive, masked);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RenderSlopePlane renderer;
|
||||||
|
renderer.Render(this, xscale, yscale, alpha, additive, masked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
NetUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
VisiblePlaneList *VisiblePlaneList::Instance()
|
||||||
|
{
|
||||||
|
static VisiblePlaneList instance;
|
||||||
|
return &instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
VisiblePlaneList::VisiblePlaneList()
|
||||||
|
{
|
||||||
|
for (auto &plane : visplanes)
|
||||||
|
plane = nullptr;
|
||||||
|
freehead = &freetail;
|
||||||
|
}
|
||||||
|
|
||||||
|
void VisiblePlaneList::Deinit()
|
||||||
{
|
{
|
||||||
// do not use R_ClearPlanes because at this point the screen pointer is no longer valid.
|
// 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 (int i = 0; i <= MAXVISPLANES; i++) // new code -- killough
|
||||||
|
@ -72,7 +155,7 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
visplane_t *new_visplane(unsigned hash)
|
visplane_t *VisiblePlaneList::Add(unsigned hash)
|
||||||
{
|
{
|
||||||
visplane_t *check = freetail;
|
visplane_t *check = freetail;
|
||||||
|
|
||||||
|
@ -94,7 +177,7 @@ namespace swrenderer
|
||||||
return check;
|
return check;
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_PlaneInitData()
|
void VisiblePlaneList::Init()
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
visplane_t *pl;
|
visplane_t *pl;
|
||||||
|
@ -124,7 +207,7 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_ClearPlanes(bool fullclear)
|
void VisiblePlaneList::Clear(bool fullclear)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -159,47 +242,10 @@ namespace swrenderer
|
||||||
freehead = &(*freehead)->next;
|
freehead = &(*freehead)->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
next_plane_light = 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_AddPlaneLights(visplane_t *plane, FLightNode *node)
|
visplane_t *VisiblePlaneList::FindPlane(const secplane_t &height, FTextureID picnum, int lightlevel, double Alpha, bool additive, const FTransform &xxform, int sky, FSectorPortal *portal)
|
||||||
{
|
|
||||||
if (!r_dynlights)
|
|
||||||
return;
|
|
||||||
|
|
||||||
while (node)
|
|
||||||
{
|
|
||||||
if (!(node->lightsource->flags2&MF2_DORMANT))
|
|
||||||
{
|
|
||||||
bool found = false;
|
|
||||||
visplane_light *light_node = plane->lights;
|
|
||||||
while (light_node)
|
|
||||||
{
|
|
||||||
if (light_node->lightsource == node->lightsource)
|
|
||||||
{
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
light_node = light_node->next;
|
|
||||||
}
|
|
||||||
if (!found)
|
|
||||||
{
|
|
||||||
if (next_plane_light == max_plane_lights)
|
|
||||||
return;
|
|
||||||
|
|
||||||
visplane_light *newlight = &plane_lights[next_plane_light++];
|
|
||||||
newlight->next = plane->lights;
|
|
||||||
newlight->lightsource = node->lightsource;
|
|
||||||
plane->lights = newlight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
node = node->nextLight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
visplane_t *R_FindPlane(const secplane_t &height, FTextureID picnum, int lightlevel, double Alpha, bool additive, const FTransform &xxform, int sky, FSectorPortal *portal)
|
|
||||||
{
|
{
|
||||||
secplane_t plane;
|
secplane_t plane;
|
||||||
visplane_t *check;
|
visplane_t *check;
|
||||||
|
@ -246,7 +292,7 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
// New visplane algorithm uses hash table -- killough
|
// New visplane algorithm uses hash table -- killough
|
||||||
hash = isskybox ? MAXVISPLANES : visplane_hash(picnum.GetIndex(), lightlevel, height);
|
hash = isskybox ? MAXVISPLANES : CalcHash(picnum.GetIndex(), lightlevel, height);
|
||||||
|
|
||||||
RenderPortal *renderportal = RenderPortal::Instance();
|
RenderPortal *renderportal = RenderPortal::Instance();
|
||||||
|
|
||||||
|
@ -307,7 +353,7 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
check = new_visplane(hash); // killough
|
check = Add(hash); // killough
|
||||||
|
|
||||||
check->height = plane;
|
check->height = plane;
|
||||||
check->picnum = picnum;
|
check->picnum = picnum;
|
||||||
|
@ -333,7 +379,7 @@ namespace swrenderer
|
||||||
return check;
|
return check;
|
||||||
}
|
}
|
||||||
|
|
||||||
visplane_t *R_CheckPlane(visplane_t *pl, int start, int stop)
|
visplane_t *VisiblePlaneList::GetRange(visplane_t *pl, int start, int stop)
|
||||||
{
|
{
|
||||||
int intrl, intrh;
|
int intrl, intrh;
|
||||||
int unionl, unionh;
|
int unionl, unionh;
|
||||||
|
@ -384,9 +430,9 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hash = visplane_hash(pl->picnum.GetIndex(), pl->lightlevel, pl->height);
|
hash = CalcHash(pl->picnum.GetIndex(), pl->lightlevel, pl->height);
|
||||||
}
|
}
|
||||||
visplane_t *new_pl = new_visplane(hash);
|
visplane_t *new_pl = Add(hash);
|
||||||
|
|
||||||
new_pl->height = pl->height;
|
new_pl->height = pl->height;
|
||||||
new_pl->picnum = pl->picnum;
|
new_pl->picnum = pl->picnum;
|
||||||
|
@ -413,7 +459,7 @@ namespace swrenderer
|
||||||
return pl;
|
return pl;
|
||||||
}
|
}
|
||||||
|
|
||||||
int R_DrawPlanes()
|
int VisiblePlaneList::Render()
|
||||||
{
|
{
|
||||||
visplane_t *pl;
|
visplane_t *pl;
|
||||||
int i;
|
int i;
|
||||||
|
@ -433,14 +479,14 @@ namespace swrenderer
|
||||||
// kg3D - draw only real planes now
|
// kg3D - draw only real planes now
|
||||||
if (pl->sky >= 0) {
|
if (pl->sky >= 0) {
|
||||||
vpcount++;
|
vpcount++;
|
||||||
R_DrawSinglePlane(pl, OPAQUE, false, false);
|
pl->Render(OPAQUE, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return vpcount;
|
return vpcount;
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_DrawHeightPlanes(double height)
|
void VisiblePlaneList::RenderHeight(double height)
|
||||||
{
|
{
|
||||||
visplane_t *pl;
|
visplane_t *pl;
|
||||||
int i;
|
int i;
|
||||||
|
@ -465,7 +511,7 @@ namespace swrenderer
|
||||||
ViewAngle = pl->viewangle;
|
ViewAngle = pl->viewangle;
|
||||||
renderportal->MirrorFlags = pl->MirrorFlags;
|
renderportal->MirrorFlags = pl->MirrorFlags;
|
||||||
|
|
||||||
R_DrawSinglePlane(pl, pl->sky & 0x7FFFFFFF, pl->Additive, true);
|
pl->Render(pl->sky & 0x7FFFFFFF, pl->Additive, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -473,52 +519,6 @@ namespace swrenderer
|
||||||
ViewAngle = oViewAngle;
|
ViewAngle = oViewAngle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_DrawSinglePlane(visplane_t *pl, fixed_t alpha, bool additive, bool masked)
|
|
||||||
{
|
|
||||||
if (pl->left >= pl->right)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (pl->picnum == skyflatnum) // sky flat
|
|
||||||
{
|
|
||||||
RenderSkyPlane::Render(pl);
|
|
||||||
}
|
|
||||||
else // regular flat
|
|
||||||
{
|
|
||||||
FTexture *tex = TexMan(pl->picnum, true);
|
|
||||||
|
|
||||||
if (tex->UseType == FTexture::TEX_Null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!masked && !additive)
|
|
||||||
{ // If we're not supposed to see through this plane, draw it opaque.
|
|
||||||
alpha = OPAQUE;
|
|
||||||
}
|
|
||||||
else if (!tex->bMasked)
|
|
||||||
{ // Don't waste time on a masked texture if it isn't really masked.
|
|
||||||
masked = false;
|
|
||||||
}
|
|
||||||
R_SetSpanTexture(tex);
|
|
||||||
double xscale = pl->xform.xScale * tex->Scale.X;
|
|
||||||
double yscale = pl->xform.yScale * tex->Scale.Y;
|
|
||||||
|
|
||||||
basecolormap = pl->colormap;
|
|
||||||
|
|
||||||
if (!pl->height.isSlope() && !tilt)
|
|
||||||
{
|
|
||||||
RenderFlatPlane renderer;
|
|
||||||
renderer.Render(pl, xscale, yscale, alpha, additive, masked);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RenderSlopePlane renderer;
|
|
||||||
renderer.Render(pl, xscale, yscale, alpha, additive, masked);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
NetUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PlaneRenderer::RenderLines(visplane_t *pl)
|
void PlaneRenderer::RenderLines(visplane_t *pl)
|
||||||
{
|
{
|
||||||
// t1/b1 are at x
|
// t1/b1 are at x
|
||||||
|
|
|
@ -64,29 +64,37 @@ namespace swrenderer
|
||||||
unsigned short *bottom; // [RH] bottom and top arrays are dynamically
|
unsigned short *bottom; // [RH] bottom and top arrays are dynamically
|
||||||
unsigned short pad; // allocated immediately after the
|
unsigned short pad; // allocated immediately after the
|
||||||
unsigned short top[]; // visplane.
|
unsigned short top[]; // visplane.
|
||||||
|
|
||||||
|
void AddLights(FLightNode *node);
|
||||||
|
void Render(fixed_t alpha, bool additive, bool masked);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAXVISPLANES 128 /* must be a power of 2 */
|
class VisiblePlaneList
|
||||||
#define visplane_hash(picnum,lightlevel,height) ((unsigned)((picnum)*3+(lightlevel)+(FLOAT2FIXED((height).fD()))*7) & (MAXVISPLANES-1))
|
{
|
||||||
|
public:
|
||||||
|
static VisiblePlaneList *Instance();
|
||||||
|
|
||||||
extern visplane_t *visplanes[MAXVISPLANES + 1];
|
void Init();
|
||||||
extern visplane_t *freetail;
|
void Deinit();
|
||||||
extern visplane_t **freehead;
|
void Clear(bool fullclear);
|
||||||
|
|
||||||
void R_DeinitPlanes();
|
visplane_t *FindPlane(const secplane_t &height, FTextureID picnum, int lightlevel, double Alpha, bool additive, const FTransform &xxform, int sky, FSectorPortal *portal);
|
||||||
visplane_t *new_visplane(unsigned hash);
|
visplane_t *GetRange(visplane_t *pl, int start, int stop);
|
||||||
|
|
||||||
void R_PlaneInitData();
|
int Render();
|
||||||
void R_ClearPlanes(bool fullclear);
|
void RenderHeight(double height);
|
||||||
|
|
||||||
void R_AddPlaneLights(visplane_t *plane, FLightNode *node);
|
enum { MAXVISPLANES = 128 }; // must be a power of 2
|
||||||
|
visplane_t *visplanes[MAXVISPLANES + 1];
|
||||||
|
visplane_t *freetail = nullptr;
|
||||||
|
visplane_t **freehead = nullptr;
|
||||||
|
|
||||||
visplane_t *R_FindPlane(const secplane_t &height, FTextureID picnum, int lightlevel, double Alpha, bool additive, const FTransform &xxform, int sky, FSectorPortal *portal);
|
private:
|
||||||
visplane_t *R_CheckPlane(visplane_t *pl, int start, int stop);
|
VisiblePlaneList();
|
||||||
|
visplane_t *Add(unsigned hash);
|
||||||
|
|
||||||
int R_DrawPlanes();
|
static unsigned CalcHash(int picnum, int lightlevel, const secplane_t &height) { return (unsigned)((picnum) * 3 + (lightlevel)+(FLOAT2FIXED((height).fD())) * 7) & (MAXVISPLANES - 1); }
|
||||||
void R_DrawHeightPlanes(double height);
|
};
|
||||||
void R_DrawSinglePlane(visplane_t *pl, fixed_t alpha, bool additive, bool masked);
|
|
||||||
|
|
||||||
class PlaneRenderer
|
class PlaneRenderer
|
||||||
{
|
{
|
||||||
|
|
|
@ -386,7 +386,7 @@ void R_InitRenderer()
|
||||||
static void R_ShutdownRenderer()
|
static void R_ShutdownRenderer()
|
||||||
{
|
{
|
||||||
RenderTranslucentPass::Deinit();
|
RenderTranslucentPass::Deinit();
|
||||||
R_DeinitPlanes();
|
VisiblePlaneList::Instance()->Deinit();
|
||||||
Clip3DFloors::Instance()->Cleanup();
|
Clip3DFloors::Instance()->Cleanup();
|
||||||
R_DeinitOpenings();
|
R_DeinitOpenings();
|
||||||
R_FreeDrawSegs();
|
R_FreeDrawSegs();
|
||||||
|
@ -527,7 +527,8 @@ void R_RenderActorView (AActor *actor, bool dontmaplines)
|
||||||
// Clear buffers.
|
// Clear buffers.
|
||||||
R_ClearClipSegs (0, viewwidth);
|
R_ClearClipSegs (0, viewwidth);
|
||||||
R_ClearDrawSegs ();
|
R_ClearDrawSegs ();
|
||||||
R_ClearPlanes (true);
|
VisiblePlaneList::Instance()->Clear(true);
|
||||||
|
R_FreePlaneLights();
|
||||||
RenderTranslucentPass::Clear();
|
RenderTranslucentPass::Clear();
|
||||||
|
|
||||||
// opening / clipping determination
|
// opening / clipping determination
|
||||||
|
@ -568,7 +569,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines)
|
||||||
if (viewactive)
|
if (viewactive)
|
||||||
{
|
{
|
||||||
PlaneCycles.Clock();
|
PlaneCycles.Clock();
|
||||||
R_DrawPlanes();
|
VisiblePlaneList::Instance()->Render();
|
||||||
RenderPortal::Instance()->RenderPlanePortals();
|
RenderPortal::Instance()->RenderPlanePortals();
|
||||||
PlaneCycles.Unclock();
|
PlaneCycles.Unclock();
|
||||||
|
|
||||||
|
@ -655,7 +656,7 @@ void R_RenderViewToCanvas (AActor *actor, DCanvas *canvas,
|
||||||
|
|
||||||
void R_MultiresInit ()
|
void R_MultiresInit ()
|
||||||
{
|
{
|
||||||
R_PlaneInitData ();
|
VisiblePlaneList::Instance()->Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include "p_setup.h"
|
#include "p_setup.h"
|
||||||
#include "swrenderer/r_main.h"
|
#include "swrenderer/r_main.h"
|
||||||
#include "swrenderer/drawers/r_draw.h"
|
#include "swrenderer/drawers/r_draw.h"
|
||||||
|
#include "swrenderer/plane/r_visibleplane.h"
|
||||||
#include "a_sharedglobal.h"
|
#include "a_sharedglobal.h"
|
||||||
#include "g_level.h"
|
#include "g_level.h"
|
||||||
#include "p_effect.h"
|
#include "p_effect.h"
|
||||||
|
@ -70,4 +71,25 @@ namespace swrenderer
|
||||||
openings = nullptr;
|
openings = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
enum { max_plane_lights = 32 * 1024 };
|
||||||
|
visplane_light plane_lights[max_plane_lights];
|
||||||
|
int next_plane_light = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
visplane_light *R_NewPlaneLight()
|
||||||
|
{
|
||||||
|
if (next_plane_light == max_plane_lights)
|
||||||
|
return nullptr;
|
||||||
|
return &plane_lights[next_plane_light++];
|
||||||
|
}
|
||||||
|
|
||||||
|
void R_FreePlaneLights()
|
||||||
|
{
|
||||||
|
next_plane_light = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,14 @@
|
||||||
|
|
||||||
namespace swrenderer
|
namespace swrenderer
|
||||||
{
|
{
|
||||||
|
struct visplane_light;
|
||||||
|
|
||||||
extern short *openings;
|
extern short *openings;
|
||||||
|
|
||||||
ptrdiff_t R_NewOpening(ptrdiff_t len);
|
ptrdiff_t R_NewOpening(ptrdiff_t len);
|
||||||
void R_FreeOpenings();
|
void R_FreeOpenings();
|
||||||
void R_DeinitOpenings();
|
void R_DeinitOpenings();
|
||||||
|
|
||||||
|
visplane_light *R_NewPlaneLight();
|
||||||
|
void R_FreePlaneLights();
|
||||||
}
|
}
|
||||||
|
|
|
@ -501,7 +501,7 @@ namespace swrenderer
|
||||||
(frontsector->heightsec &&
|
(frontsector->heightsec &&
|
||||||
!(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) &&
|
!(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) &&
|
||||||
frontsector->heightsec->GetTexture(sector_t::floor) == skyflatnum) ?
|
frontsector->heightsec->GetTexture(sector_t::floor) == skyflatnum) ?
|
||||||
R_FindPlane(frontsector->ceilingplane, // killough 3/8/98
|
VisiblePlaneList::Instance()->FindPlane(frontsector->ceilingplane, // killough 3/8/98
|
||||||
frontsector->GetTexture(sector_t::ceiling),
|
frontsector->GetTexture(sector_t::ceiling),
|
||||||
ceilinglightlevel + r_actualextralight, // killough 4/11/98
|
ceilinglightlevel + r_actualextralight, // killough 4/11/98
|
||||||
frontsector->GetAlpha(sector_t::ceiling),
|
frontsector->GetAlpha(sector_t::ceiling),
|
||||||
|
@ -512,7 +512,7 @@ namespace swrenderer
|
||||||
) : nullptr;
|
) : nullptr;
|
||||||
|
|
||||||
if (ceilingplane)
|
if (ceilingplane)
|
||||||
R_AddPlaneLights(ceilingplane, frontsector->lighthead);
|
ceilingplane->AddLights(frontsector->lighthead);
|
||||||
|
|
||||||
if (fixedlightlev < 0 && frontsector->e && frontsector->e->XFloor.lightlist.Size())
|
if (fixedlightlev < 0 && frontsector->e && frontsector->e->XFloor.lightlist.Size())
|
||||||
{
|
{
|
||||||
|
@ -541,7 +541,7 @@ namespace swrenderer
|
||||||
(frontsector->heightsec &&
|
(frontsector->heightsec &&
|
||||||
!(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) &&
|
!(frontsector->heightsec->MoreFlags & SECF_IGNOREHEIGHTSEC) &&
|
||||||
frontsector->heightsec->GetTexture(sector_t::ceiling) == skyflatnum) ?
|
frontsector->heightsec->GetTexture(sector_t::ceiling) == skyflatnum) ?
|
||||||
R_FindPlane(frontsector->floorplane,
|
VisiblePlaneList::Instance()->FindPlane(frontsector->floorplane,
|
||||||
frontsector->GetTexture(sector_t::floor),
|
frontsector->GetTexture(sector_t::floor),
|
||||||
floorlightlevel + r_actualextralight, // killough 3/16/98
|
floorlightlevel + r_actualextralight, // killough 3/16/98
|
||||||
frontsector->GetAlpha(sector_t::floor),
|
frontsector->GetAlpha(sector_t::floor),
|
||||||
|
@ -552,7 +552,7 @@ namespace swrenderer
|
||||||
) : nullptr;
|
) : nullptr;
|
||||||
|
|
||||||
if (floorplane)
|
if (floorplane)
|
||||||
R_AddPlaneLights(floorplane, frontsector->lighthead);
|
floorplane->AddLights(frontsector->lighthead);
|
||||||
|
|
||||||
// kg3D - fake planes rendering
|
// kg3D - fake planes rendering
|
||||||
if (r_3dfloors && frontsector->e && frontsector->e->XFloor.ffloors.Size())
|
if (r_3dfloors && frontsector->e && frontsector->e->XFloor.ffloors.Size())
|
||||||
|
@ -606,7 +606,7 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
|
|
||||||
ceilingplane = nullptr;
|
ceilingplane = nullptr;
|
||||||
floorplane = R_FindPlane(frontsector->floorplane,
|
floorplane = VisiblePlaneList::Instance()->FindPlane(frontsector->floorplane,
|
||||||
frontsector->GetTexture(sector_t::floor),
|
frontsector->GetTexture(sector_t::floor),
|
||||||
floorlightlevel + r_actualextralight, // killough 3/16/98
|
floorlightlevel + r_actualextralight, // killough 3/16/98
|
||||||
frontsector->GetAlpha(sector_t::floor),
|
frontsector->GetAlpha(sector_t::floor),
|
||||||
|
@ -616,7 +616,7 @@ namespace swrenderer
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
if (floorplane)
|
if (floorplane)
|
||||||
R_AddPlaneLights(floorplane, frontsector->lighthead);
|
floorplane->AddLights(frontsector->lighthead);
|
||||||
|
|
||||||
FakeDrawLoop(sub, floorplane, ceilingplane);
|
FakeDrawLoop(sub, floorplane, ceilingplane);
|
||||||
clip3d->fake3D = 0;
|
clip3d->fake3D = 0;
|
||||||
|
@ -671,7 +671,7 @@ namespace swrenderer
|
||||||
tempsec.ceilingplane.ChangeHeight(1 / 65536.);
|
tempsec.ceilingplane.ChangeHeight(1 / 65536.);
|
||||||
|
|
||||||
floorplane = nullptr;
|
floorplane = nullptr;
|
||||||
ceilingplane = R_FindPlane(frontsector->ceilingplane, // killough 3/8/98
|
ceilingplane = VisiblePlaneList::Instance()->FindPlane(frontsector->ceilingplane, // killough 3/8/98
|
||||||
frontsector->GetTexture(sector_t::ceiling),
|
frontsector->GetTexture(sector_t::ceiling),
|
||||||
ceilinglightlevel + r_actualextralight, // killough 4/11/98
|
ceilinglightlevel + r_actualextralight, // killough 4/11/98
|
||||||
frontsector->GetAlpha(sector_t::ceiling),
|
frontsector->GetAlpha(sector_t::ceiling),
|
||||||
|
@ -681,7 +681,7 @@ namespace swrenderer
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
if (ceilingplane)
|
if (ceilingplane)
|
||||||
R_AddPlaneLights(ceilingplane, frontsector->lighthead);
|
ceilingplane->AddLights(frontsector->lighthead);
|
||||||
|
|
||||||
FakeDrawLoop(sub, floorplane, ceilingplane);
|
FakeDrawLoop(sub, floorplane, ceilingplane);
|
||||||
clip3d->fake3D = 0;
|
clip3d->fake3D = 0;
|
||||||
|
|
|
@ -88,7 +88,9 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
numskyboxes = 0;
|
numskyboxes = 0;
|
||||||
|
|
||||||
if (visplanes[MAXVISPLANES] == nullptr)
|
VisiblePlaneList *planes = VisiblePlaneList::Instance();
|
||||||
|
|
||||||
|
if (planes->visplanes[VisiblePlaneList::MAXVISPLANES] == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Clip3DFloors::Instance()->EnterSkybox();
|
Clip3DFloors::Instance()->EnterSkybox();
|
||||||
|
@ -107,19 +109,19 @@ namespace swrenderer
|
||||||
int i;
|
int i;
|
||||||
visplane_t *pl;
|
visplane_t *pl;
|
||||||
|
|
||||||
for (pl = visplanes[MAXVISPLANES]; pl != nullptr; pl = visplanes[MAXVISPLANES])
|
for (pl = planes->visplanes[VisiblePlaneList::MAXVISPLANES]; pl != nullptr; pl = planes->visplanes[VisiblePlaneList::MAXVISPLANES])
|
||||||
{
|
{
|
||||||
// Pop the visplane off the list now so that if this skybox adds more
|
// Pop the visplane off the list now so that if this skybox adds more
|
||||||
// skyboxes to the list, they will be drawn instead of skipped (because
|
// skyboxes to the list, they will be drawn instead of skipped (because
|
||||||
// new skyboxes go to the beginning of the list instead of the end).
|
// new skyboxes go to the beginning of the list instead of the end).
|
||||||
visplanes[MAXVISPLANES] = pl->next;
|
planes->visplanes[VisiblePlaneList::MAXVISPLANES] = pl->next;
|
||||||
pl->next = nullptr;
|
pl->next = nullptr;
|
||||||
|
|
||||||
if (pl->right < pl->left || !r_skyboxes || numskyboxes == MAX_SKYBOX_PLANES || pl->portal == nullptr)
|
if (pl->right < pl->left || !r_skyboxes || numskyboxes == MAX_SKYBOX_PLANES || pl->portal == nullptr)
|
||||||
{
|
{
|
||||||
R_DrawSinglePlane(pl, OPAQUE, false, false);
|
pl->Render(OPAQUE, false, false);
|
||||||
*freehead = pl;
|
*planes->freehead = pl;
|
||||||
freehead = &pl->next;
|
planes->freehead = &pl->next;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,9 +160,9 @@ namespace swrenderer
|
||||||
// not implemented yet
|
// not implemented yet
|
||||||
|
|
||||||
default:
|
default:
|
||||||
R_DrawSinglePlane(pl, OPAQUE, false, false);
|
pl->Render(OPAQUE, false, false);
|
||||||
*freehead = pl;
|
*planes->freehead = pl;
|
||||||
freehead = &pl->next;
|
planes->freehead = &pl->next;
|
||||||
numskyboxes--;
|
numskyboxes--;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -173,7 +175,7 @@ namespace swrenderer
|
||||||
R_SetViewAngle();
|
R_SetViewAngle();
|
||||||
validcount++; // Make sure we see all sprites
|
validcount++; // Make sure we see all sprites
|
||||||
|
|
||||||
R_ClearPlanes(false);
|
planes->Clear(false);
|
||||||
R_ClearClipSegs(pl->left, pl->right);
|
R_ClearClipSegs(pl->left, pl->right);
|
||||||
WindowLeft = pl->left;
|
WindowLeft = pl->left;
|
||||||
WindowRight = pl->right;
|
WindowRight = pl->right;
|
||||||
|
@ -227,7 +229,7 @@ namespace swrenderer
|
||||||
|
|
||||||
RenderOpaquePass::Instance()->RenderScene();
|
RenderOpaquePass::Instance()->RenderScene();
|
||||||
Clip3DFloors::Instance()->ResetClip(); // reset clips (floor/ceiling)
|
Clip3DFloors::Instance()->ResetClip(); // reset clips (floor/ceiling)
|
||||||
R_DrawPlanes();
|
planes->Render();
|
||||||
|
|
||||||
port->mFlags &= ~PORTSF_INSKYBOX;
|
port->mFlags &= ~PORTSF_INSKYBOX;
|
||||||
if (port->mPartner > 0) sectorPortals[port->mPartner].mFlags &= ~PORTSF_INSKYBOX;
|
if (port->mPartner > 0) sectorPortals[port->mPartner].mFlags &= ~PORTSF_INSKYBOX;
|
||||||
|
@ -256,10 +258,10 @@ namespace swrenderer
|
||||||
visplaneStack.Pop(pl);
|
visplaneStack.Pop(pl);
|
||||||
if (pl->Alpha > 0 && pl->picnum != skyflatnum)
|
if (pl->Alpha > 0 && pl->picnum != skyflatnum)
|
||||||
{
|
{
|
||||||
R_DrawSinglePlane(pl, pl->Alpha, pl->Additive, true);
|
pl->Render(pl->Alpha, pl->Additive, true);
|
||||||
}
|
}
|
||||||
*freehead = pl;
|
*planes->freehead = pl;
|
||||||
freehead = &pl->next;
|
planes->freehead = &pl->next;
|
||||||
}
|
}
|
||||||
VisibleSpriteList::firstvissprite = VisibleSpriteList::vissprites;
|
VisibleSpriteList::firstvissprite = VisibleSpriteList::vissprites;
|
||||||
VisibleSpriteList::vissprite_p = VisibleSpriteList::vissprites + savedvissprite_p;
|
VisibleSpriteList::vissprite_p = VisibleSpriteList::vissprites + savedvissprite_p;
|
||||||
|
@ -281,8 +283,8 @@ namespace swrenderer
|
||||||
|
|
||||||
if (Clip3DFloors::Instance()->fakeActive) return;
|
if (Clip3DFloors::Instance()->fakeActive) return;
|
||||||
|
|
||||||
for (*freehead = visplanes[MAXVISPLANES], visplanes[MAXVISPLANES] = nullptr; *freehead; )
|
for (*planes->freehead = planes->visplanes[VisiblePlaneList::MAXVISPLANES], planes->visplanes[VisiblePlaneList::MAXVISPLANES] = nullptr; *planes->freehead; )
|
||||||
freehead = &(*freehead)->next;
|
planes->freehead = &(*planes->freehead)->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderPortal::RenderLinePortals()
|
void RenderPortal::RenderLinePortals()
|
||||||
|
@ -421,7 +423,7 @@ namespace swrenderer
|
||||||
PortalDrawseg* prevpds = CurrentPortal;
|
PortalDrawseg* prevpds = CurrentPortal;
|
||||||
CurrentPortal = pds;
|
CurrentPortal = pds;
|
||||||
|
|
||||||
R_ClearPlanes(false);
|
VisiblePlaneList::Instance()->Clear(false);
|
||||||
R_ClearClipSegs(pds->x1, pds->x2);
|
R_ClearClipSegs(pds->x1, pds->x2);
|
||||||
|
|
||||||
WindowLeft = pds->x1;
|
WindowLeft = pds->x1;
|
||||||
|
@ -451,7 +453,7 @@ namespace swrenderer
|
||||||
if (!savedvisibility && camera) camera->renderflags &= ~RF_INVISIBLE;
|
if (!savedvisibility && camera) camera->renderflags &= ~RF_INVISIBLE;
|
||||||
|
|
||||||
PlaneCycles.Clock();
|
PlaneCycles.Clock();
|
||||||
R_DrawPlanes();
|
VisiblePlaneList::Instance()->Render();
|
||||||
RenderPlanePortals();
|
RenderPlanePortals();
|
||||||
PlaneCycles.Unclock();
|
PlaneCycles.Unclock();
|
||||||
|
|
||||||
|
|
|
@ -586,7 +586,7 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
clip3d->sclipBottom = hl->height;
|
clip3d->sclipBottom = hl->height;
|
||||||
DrawMaskedSingle(true);
|
DrawMaskedSingle(true);
|
||||||
R_DrawHeightPlanes(hl->height);
|
VisiblePlaneList::Instance()->RenderHeight(hl->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// floors
|
// floors
|
||||||
|
@ -595,7 +595,7 @@ namespace swrenderer
|
||||||
DrawMaskedSingle(true);
|
DrawMaskedSingle(true);
|
||||||
for (HeightLevel *hl = clip3d->height_top; hl != nullptr && hl->height < ViewPos.Z; hl = hl->next)
|
for (HeightLevel *hl = clip3d->height_top; hl != nullptr && hl->height < ViewPos.Z; hl = hl->next)
|
||||||
{
|
{
|
||||||
R_DrawHeightPlanes(hl->height);
|
VisiblePlaneList::Instance()->RenderHeight(hl->height);
|
||||||
if (hl->next)
|
if (hl->next)
|
||||||
{
|
{
|
||||||
clip3d->fake3D = FAKE3D_DOWN2UP | FAKE3D_CLIPTOP | FAKE3D_CLIPBOTTOM;
|
clip3d->fake3D = FAKE3D_DOWN2UP | FAKE3D_CLIPTOP | FAKE3D_CLIPBOTTOM;
|
||||||
|
|
Loading…
Reference in a new issue