mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2024-11-30 15:41:47 +00:00
Convert r_flatplane and r_slopeplane into classes
This commit is contained in:
parent
fc29958dc7
commit
0885ff44a0
7 changed files with 92 additions and 65 deletions
|
@ -41,20 +41,7 @@
|
|||
|
||||
namespace swrenderer
|
||||
{
|
||||
namespace
|
||||
{
|
||||
double planeheight;
|
||||
bool plane_shade;
|
||||
int planeshade;
|
||||
fixed_t pviewx, pviewy;
|
||||
float yslope[MAXHEIGHT];
|
||||
fixed_t xscale, yscale;
|
||||
double xstepscale, ystepscale;
|
||||
double basexfrac, baseyfrac;
|
||||
visplane_light *ds_light_list;
|
||||
}
|
||||
|
||||
void R_DrawNormalPlane(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked)
|
||||
void RenderFlatPlane::Render(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked)
|
||||
{
|
||||
using namespace drawerargs;
|
||||
|
||||
|
@ -189,18 +176,12 @@ namespace swrenderer
|
|||
}
|
||||
}
|
||||
|
||||
ds_light_list = pl->lights;
|
||||
light_list = pl->lights;
|
||||
|
||||
R_MapVisPlane(pl, R_MapPlane, R_StepPlane);
|
||||
RenderLines(pl);
|
||||
}
|
||||
|
||||
void R_StepPlane()
|
||||
{
|
||||
basexfrac -= xstepscale;
|
||||
baseyfrac -= ystepscale;
|
||||
}
|
||||
|
||||
void R_MapPlane(int y, int x1, int x2)
|
||||
void RenderFlatPlane::RenderLine(int y, int x1, int x2)
|
||||
{
|
||||
using namespace drawerargs;
|
||||
|
||||
|
@ -275,7 +256,7 @@ namespace swrenderer
|
|||
// Setup lights for row
|
||||
dc_num_lights = 0;
|
||||
dc_lights = lightbuffer + nextlightindex;
|
||||
visplane_light *cur_node = ds_light_list;
|
||||
visplane_light *cur_node = light_list;
|
||||
while (cur_node && nextlightindex < 64 * 1024)
|
||||
{
|
||||
double lightX = cur_node->lightsource->X() - ViewPos.X;
|
||||
|
@ -326,17 +307,13 @@ namespace swrenderer
|
|||
(R_Drawers()->*spanfunc)();
|
||||
}
|
||||
|
||||
void R_DrawColoredPlane(visplane_t *pl)
|
||||
void RenderFlatPlane::StepColumn()
|
||||
{
|
||||
R_MapVisPlane(pl, R_MapColoredPlane, nullptr);
|
||||
basexfrac -= xstepscale;
|
||||
baseyfrac -= ystepscale;
|
||||
}
|
||||
|
||||
void R_MapColoredPlane(int y, int x1, int x2)
|
||||
{
|
||||
R_Drawers()->DrawColoredSpan(y, x1, x2);
|
||||
}
|
||||
|
||||
void R_SetupPlaneSlope()
|
||||
void RenderFlatPlane::SetupSlope()
|
||||
{
|
||||
int e, i;
|
||||
|
||||
|
@ -377,4 +354,18 @@ namespace swrenderer
|
|||
} while (++i < e);
|
||||
}
|
||||
}
|
||||
|
||||
float RenderFlatPlane::yslope[MAXHEIGHT];
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void RenderColoredPlane::Render(visplane_t *pl)
|
||||
{
|
||||
RenderLines(pl);
|
||||
}
|
||||
|
||||
void RenderColoredPlane::RenderLine(int y, int x1, int x2)
|
||||
{
|
||||
R_Drawers()->DrawColoredSpan(y, x1, x2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,12 +17,35 @@
|
|||
|
||||
namespace swrenderer
|
||||
{
|
||||
void R_SetupPlaneSlope();
|
||||
class RenderFlatPlane : PlaneRenderer
|
||||
{
|
||||
public:
|
||||
void Render(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked);
|
||||
|
||||
void R_DrawNormalPlane(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked);
|
||||
void R_MapPlane(int y, int x1, int x2);
|
||||
void R_StepPlane();
|
||||
static void SetupSlope();
|
||||
|
||||
void R_DrawColoredPlane(visplane_t *pl);
|
||||
void R_MapColoredPlane(int y, int x1, int x2);
|
||||
private:
|
||||
void RenderLine(int y, int x1, int x2) override;
|
||||
void StepColumn() override;
|
||||
|
||||
double planeheight;
|
||||
bool plane_shade;
|
||||
int planeshade;
|
||||
fixed_t pviewx, pviewy;
|
||||
fixed_t xscale, yscale;
|
||||
double xstepscale, ystepscale;
|
||||
double basexfrac, baseyfrac;
|
||||
visplane_light *light_list;
|
||||
|
||||
static float yslope[MAXHEIGHT];
|
||||
};
|
||||
|
||||
class RenderColoredPlane : PlaneRenderer
|
||||
{
|
||||
public:
|
||||
void Render(visplane_t *pl);
|
||||
|
||||
private:
|
||||
void RenderLine(int y, int x1, int x2) override;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -45,17 +45,7 @@
|
|||
|
||||
namespace swrenderer
|
||||
{
|
||||
namespace
|
||||
{
|
||||
FVector3 plane_sz, plane_su, plane_sv;
|
||||
float planelightfloat;
|
||||
bool plane_shade;
|
||||
int planeshade;
|
||||
fixed_t pviewx, pviewy;
|
||||
fixed_t xscale, yscale;
|
||||
}
|
||||
|
||||
void R_DrawTiltedPlane(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked)
|
||||
void RenderSlopePlane::Render(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked)
|
||||
{
|
||||
using namespace drawerargs;
|
||||
|
||||
|
@ -182,10 +172,10 @@ namespace swrenderer
|
|||
plane_su[2] = plane_su[1] = plane_su[0] = 0;
|
||||
}
|
||||
|
||||
R_MapVisPlane(pl, R_MapTiltedPlane, nullptr);
|
||||
RenderLines(pl);
|
||||
}
|
||||
|
||||
void R_MapTiltedPlane(int y, int x1, int x2)
|
||||
void RenderSlopePlane::RenderLine(int y, int x1, int x2)
|
||||
{
|
||||
R_Drawers()->DrawTiltedSpan(y, x1, x2, plane_sz, plane_su, plane_sv, plane_shade, planeshade, planelightfloat, pviewx, pviewy);
|
||||
}
|
||||
|
|
|
@ -17,6 +17,19 @@
|
|||
|
||||
namespace swrenderer
|
||||
{
|
||||
void R_DrawTiltedPlane(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked);
|
||||
void R_MapTiltedPlane(int y, int x1, int x2);
|
||||
class RenderSlopePlane : PlaneRenderer
|
||||
{
|
||||
public:
|
||||
void Render(visplane_t *pl, double _xscale, double _yscale, fixed_t alpha, bool additive, bool masked);
|
||||
|
||||
private:
|
||||
void RenderLine(int y, int x1, int x2) override;
|
||||
|
||||
FVector3 plane_sz, plane_su, plane_sv;
|
||||
float planelightfloat;
|
||||
bool plane_shade;
|
||||
int planeshade;
|
||||
fixed_t pviewx, pviewy;
|
||||
fixed_t xscale, yscale;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -52,8 +52,6 @@ namespace swrenderer
|
|||
enum { max_plane_lights = 32 * 1024 };
|
||||
visplane_light plane_lights[max_plane_lights];
|
||||
int next_plane_light = 0;
|
||||
|
||||
short spanend[MAXHEIGHT];
|
||||
}
|
||||
|
||||
void R_DeinitPlanes()
|
||||
|
@ -509,17 +507,19 @@ namespace swrenderer
|
|||
|
||||
if (!pl->height.isSlope() && !tilt)
|
||||
{
|
||||
R_DrawNormalPlane(pl, xscale, yscale, alpha, additive, masked);
|
||||
RenderFlatPlane renderer;
|
||||
renderer.Render(pl, xscale, yscale, alpha, additive, masked);
|
||||
}
|
||||
else
|
||||
{
|
||||
R_DrawTiltedPlane(pl, xscale, yscale, alpha, additive, masked);
|
||||
RenderSlopePlane renderer;
|
||||
renderer.Render(pl, xscale, yscale, alpha, additive, masked);
|
||||
}
|
||||
}
|
||||
NetUpdate();
|
||||
}
|
||||
|
||||
void R_MapVisPlane(visplane_t *pl, void(*mapfunc)(int y, int x1, int x2), void(*stepfunc)())
|
||||
void PlaneRenderer::RenderLines(visplane_t *pl)
|
||||
{
|
||||
// t1/b1 are at x
|
||||
// t2/b2 are at x+1
|
||||
|
@ -547,14 +547,14 @@ namespace swrenderer
|
|||
{
|
||||
int y = t2++;
|
||||
int x2 = spanend[y];
|
||||
mapfunc(y, xr, x2);
|
||||
RenderLine(y, xr, x2);
|
||||
}
|
||||
stop = MAX(b1, t2);
|
||||
while (b2 > stop)
|
||||
{
|
||||
int y = --b2;
|
||||
int x2 = spanend[y];
|
||||
mapfunc(y, xr, x2);
|
||||
RenderLine(y, xr, x2);
|
||||
}
|
||||
|
||||
// Mark any spans that have just opened
|
||||
|
@ -572,15 +572,14 @@ namespace swrenderer
|
|||
t2 = pl->top[x];
|
||||
b2 = pl->bottom[x];
|
||||
|
||||
if (stepfunc)
|
||||
stepfunc();
|
||||
StepColumn();
|
||||
}
|
||||
// Draw any spans that are still open
|
||||
while (t2 < b2)
|
||||
{
|
||||
int y = --b2;
|
||||
int x2 = spanend[y];
|
||||
mapfunc(y, pl->left, x2);
|
||||
RenderLine(y, pl->left, x2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,5 +87,16 @@ namespace swrenderer
|
|||
int R_DrawPlanes();
|
||||
void R_DrawHeightPlanes(double height);
|
||||
void R_DrawSinglePlane(visplane_t *pl, fixed_t alpha, bool additive, bool masked);
|
||||
void R_MapVisPlane(visplane_t *pl, void(*mapfunc)(int y, int x1, int x2), void(*stepfunc)());
|
||||
|
||||
class PlaneRenderer
|
||||
{
|
||||
public:
|
||||
void RenderLines(visplane_t *pl);
|
||||
|
||||
virtual void RenderLine(int y, int x1, int x2) = 0;
|
||||
virtual void StepColumn() { }
|
||||
|
||||
private:
|
||||
short spanend[MAXHEIGHT];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -467,7 +467,7 @@ void R_SetupFreelook()
|
|||
globaluclip = -CenterY / InvZtoScale;
|
||||
globaldclip = (viewheight - CenterY) / InvZtoScale;
|
||||
|
||||
R_SetupPlaneSlope();
|
||||
RenderFlatPlane::SetupSlope();
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
Loading…
Reference in a new issue