mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-15 00:51:24 +00:00
Convert r_visiblesprite to classes
This commit is contained in:
parent
8ed66791e7
commit
32b91dd978
8 changed files with 170 additions and 139 deletions
|
@ -92,7 +92,6 @@ namespace swrenderer
|
||||||
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
|
||||||
|
|
||||||
void R_SpanInitData ();
|
void R_SpanInitData ();
|
||||||
void R_DeinitSprites();
|
|
||||||
|
|
||||||
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
|
// PUBLIC FUNCTION PROTOTYPES ----------------------------------------------
|
||||||
|
|
||||||
|
@ -385,7 +384,7 @@ void R_InitRenderer()
|
||||||
|
|
||||||
static void R_ShutdownRenderer()
|
static void R_ShutdownRenderer()
|
||||||
{
|
{
|
||||||
R_DeinitSprites();
|
RenderTranslucent::Deinit();
|
||||||
R_DeinitPlanes();
|
R_DeinitPlanes();
|
||||||
Clip3DFloors::Instance()->Cleanup();
|
Clip3DFloors::Instance()->Cleanup();
|
||||||
R_DeinitOpenings();
|
R_DeinitOpenings();
|
||||||
|
@ -528,7 +527,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines)
|
||||||
R_ClearClipSegs (0, viewwidth);
|
R_ClearClipSegs (0, viewwidth);
|
||||||
R_ClearDrawSegs ();
|
R_ClearDrawSegs ();
|
||||||
R_ClearPlanes (true);
|
R_ClearPlanes (true);
|
||||||
R_ClearSprites ();
|
RenderTranslucent::Clear();
|
||||||
|
|
||||||
// opening / clipping determination
|
// opening / clipping determination
|
||||||
RenderBSP::Instance()->ClearClip();
|
RenderBSP::Instance()->ClearClip();
|
||||||
|
@ -577,7 +576,7 @@ void R_RenderActorView (AActor *actor, bool dontmaplines)
|
||||||
NetUpdate ();
|
NetUpdate ();
|
||||||
|
|
||||||
MaskedCycles.Clock();
|
MaskedCycles.Clock();
|
||||||
R_DrawMasked ();
|
RenderTranslucent::Render();
|
||||||
MaskedCycles.Unclock();
|
MaskedCycles.Unclock();
|
||||||
|
|
||||||
NetUpdate ();
|
NetUpdate ();
|
||||||
|
|
|
@ -96,7 +96,7 @@ namespace swrenderer
|
||||||
int savedextralight = extralight;
|
int savedextralight = extralight;
|
||||||
DVector3 savedpos = ViewPos;
|
DVector3 savedpos = ViewPos;
|
||||||
DAngle savedangle = ViewAngle;
|
DAngle savedangle = ViewAngle;
|
||||||
ptrdiff_t savedvissprite_p = vissprite_p - vissprites;
|
ptrdiff_t savedvissprite_p = VisibleSpriteList::vissprite_p - VisibleSpriteList::vissprites;
|
||||||
ptrdiff_t savedds_p = ds_p - drawsegs;
|
ptrdiff_t savedds_p = ds_p - drawsegs;
|
||||||
size_t savedinteresting = FirstInterestingDrawseg;
|
size_t savedinteresting = FirstInterestingDrawseg;
|
||||||
double savedvisibility = R_GetVisibility();
|
double savedvisibility = R_GetVisibility();
|
||||||
|
@ -212,14 +212,14 @@ namespace swrenderer
|
||||||
memcpy(openings + draw_segment->sprbottomclip, floorclip + pl->left, (pl->right - pl->left) * sizeof(short));
|
memcpy(openings + draw_segment->sprbottomclip, floorclip + pl->left, (pl->right - pl->left) * sizeof(short));
|
||||||
memcpy(openings + draw_segment->sprtopclip, ceilingclip + pl->left, (pl->right - pl->left) * sizeof(short));
|
memcpy(openings + draw_segment->sprtopclip, ceilingclip + pl->left, (pl->right - pl->left) * sizeof(short));
|
||||||
|
|
||||||
firstvissprite = vissprite_p;
|
VisibleSpriteList::firstvissprite = VisibleSpriteList::vissprite_p;
|
||||||
firstdrawseg = draw_segment;
|
firstdrawseg = draw_segment;
|
||||||
FirstInterestingDrawseg = InterestingDrawsegs.Size();
|
FirstInterestingDrawseg = InterestingDrawsegs.Size();
|
||||||
|
|
||||||
interestingStack.Push(FirstInterestingDrawseg);
|
interestingStack.Push(FirstInterestingDrawseg);
|
||||||
ptrdiff_t diffnum = firstdrawseg - drawsegs;
|
ptrdiff_t diffnum = firstdrawseg - drawsegs;
|
||||||
drawsegStack.Push(diffnum);
|
drawsegStack.Push(diffnum);
|
||||||
diffnum = firstvissprite - vissprites;
|
diffnum = VisibleSpriteList::firstvissprite - VisibleSpriteList::vissprites;
|
||||||
visspriteStack.Push(diffnum);
|
visspriteStack.Push(diffnum);
|
||||||
viewposStack.Push(ViewPos);
|
viewposStack.Push(ViewPos);
|
||||||
visplaneStack.Push(pl);
|
visplaneStack.Push(pl);
|
||||||
|
@ -242,15 +242,15 @@ namespace swrenderer
|
||||||
drawsegStack.Pop(pd);
|
drawsegStack.Pop(pd);
|
||||||
firstdrawseg = drawsegs + pd;
|
firstdrawseg = drawsegs + pd;
|
||||||
visspriteStack.Pop(pd);
|
visspriteStack.Pop(pd);
|
||||||
firstvissprite = vissprites + pd;
|
VisibleSpriteList::firstvissprite = VisibleSpriteList::vissprites + pd;
|
||||||
|
|
||||||
// Masked textures and planes need the view coordinates restored for proper positioning.
|
// Masked textures and planes need the view coordinates restored for proper positioning.
|
||||||
viewposStack.Pop(ViewPos);
|
viewposStack.Pop(ViewPos);
|
||||||
|
|
||||||
R_DrawMasked();
|
RenderTranslucent::Render();
|
||||||
|
|
||||||
ds_p = firstdrawseg;
|
ds_p = firstdrawseg;
|
||||||
vissprite_p = firstvissprite;
|
VisibleSpriteList::vissprite_p = VisibleSpriteList::firstvissprite;
|
||||||
|
|
||||||
visplaneStack.Pop(pl);
|
visplaneStack.Pop(pl);
|
||||||
if (pl->Alpha > 0 && pl->picnum != skyflatnum)
|
if (pl->Alpha > 0 && pl->picnum != skyflatnum)
|
||||||
|
@ -260,8 +260,8 @@ namespace swrenderer
|
||||||
*freehead = pl;
|
*freehead = pl;
|
||||||
freehead = &pl->next;
|
freehead = &pl->next;
|
||||||
}
|
}
|
||||||
firstvissprite = vissprites;
|
VisibleSpriteList::firstvissprite = VisibleSpriteList::vissprites;
|
||||||
vissprite_p = vissprites + savedvissprite_p;
|
VisibleSpriteList::vissprite_p = VisibleSpriteList::vissprites + savedvissprite_p;
|
||||||
firstdrawseg = drawsegs;
|
firstdrawseg = drawsegs;
|
||||||
ds_p = drawsegs + savedds_p;
|
ds_p = drawsegs + savedds_p;
|
||||||
InterestingDrawsegs.Resize((unsigned int)FirstInterestingDrawseg);
|
InterestingDrawsegs.Resize((unsigned int)FirstInterestingDrawseg);
|
||||||
|
@ -469,7 +469,7 @@ namespace swrenderer
|
||||||
NetUpdate();
|
NetUpdate();
|
||||||
|
|
||||||
MaskedCycles.Clock(); // [ZZ] count sprites in portals/mirrors along with normal ones.
|
MaskedCycles.Clock(); // [ZZ] count sprites in portals/mirrors along with normal ones.
|
||||||
R_DrawMasked(); // this is required since with portals there often will be cases when more than 80% of the view is inside a portal.
|
RenderTranslucent::Render(); // this is required since with portals there often will be cases when more than 80% of the view is inside a portal.
|
||||||
MaskedCycles.Unclock();
|
MaskedCycles.Unclock();
|
||||||
|
|
||||||
NetUpdate();
|
NetUpdate();
|
||||||
|
|
|
@ -177,7 +177,7 @@ namespace swrenderer
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// store information in a vissprite
|
// store information in a vissprite
|
||||||
vis = R_NewVisSprite();
|
vis = VisibleSpriteList::Add();
|
||||||
vis->CurrentPortalUniq = renderportal->CurrentPortalUniq;
|
vis->CurrentPortalUniq = renderportal->CurrentPortalUniq;
|
||||||
vis->heightsec = heightsec;
|
vis->heightsec = heightsec;
|
||||||
vis->xscale = FLOAT2FIXED(xscale);
|
vis->xscale = FLOAT2FIXED(xscale);
|
||||||
|
@ -253,7 +253,7 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx)
|
for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx)
|
||||||
{
|
{
|
||||||
if (R_ClipSpriteColumnWithPortals(x, vis))
|
if (RenderTranslucent::ClipSpriteColumnWithPortals(x, vis))
|
||||||
continue;
|
continue;
|
||||||
uint32_t *dest = ylookup[yl] + x + (uint32_t*)dc_destorg;
|
uint32_t *dest = ylookup[yl] + x + (uint32_t*)dc_destorg;
|
||||||
DrawerCommandQueue::QueueCommand<DrawParticleColumnRGBACommand>(dest, yl, spacing, ycount, fg, alpha, fracposx);
|
DrawerCommandQueue::QueueCommand<DrawParticleColumnRGBACommand>(dest, yl, spacing, ycount, fg, alpha, fracposx);
|
||||||
|
@ -263,7 +263,7 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx)
|
for (int x = x1; x < (x1 + countbase); x++, fracposx += fracstepx)
|
||||||
{
|
{
|
||||||
if (R_ClipSpriteColumnWithPortals(x, vis))
|
if (RenderTranslucent::ClipSpriteColumnWithPortals(x, vis))
|
||||||
continue;
|
continue;
|
||||||
uint8_t *dest = ylookup[yl] + x + dc_destorg;
|
uint8_t *dest = ylookup[yl] + x + dc_destorg;
|
||||||
DrawerCommandQueue::QueueCommand<DrawParticleColumnPalCommand>(dest, yl, spacing, ycount, fg, alpha, fracposx);
|
DrawerCommandQueue::QueueCommand<DrawParticleColumnPalCommand>(dest, yl, spacing, ycount, fg, alpha, fracposx);
|
||||||
|
|
|
@ -153,7 +153,7 @@ namespace swrenderer
|
||||||
double yscale = spriteScale.Y / tex->Scale.Y;
|
double yscale = spriteScale.Y / tex->Scale.Y;
|
||||||
|
|
||||||
// store information in a vissprite
|
// store information in a vissprite
|
||||||
vissprite_t *vis = R_NewVisSprite();
|
vissprite_t *vis = VisibleSpriteList::Add();
|
||||||
|
|
||||||
vis->CurrentPortalUniq = renderportal->CurrentPortalUniq;
|
vis->CurrentPortalUniq = renderportal->CurrentPortalUniq;
|
||||||
vis->xscale = FLOAT2FIXED(xscale);
|
vis->xscale = FLOAT2FIXED(xscale);
|
||||||
|
@ -330,7 +330,7 @@ namespace swrenderer
|
||||||
{
|
{
|
||||||
while (x < x2)
|
while (x < x2)
|
||||||
{
|
{
|
||||||
if (ispsprite || !R_ClipSpriteColumnWithPortals(x, vis))
|
if (ispsprite || !RenderTranslucent::ClipSpriteColumnWithPortals(x, vis))
|
||||||
R_DrawMaskedColumn(x, iscale, tex, frac, spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip, false);
|
R_DrawMaskedColumn(x, iscale, tex, frac, spryscale, sprtopscreen, sprflipvert, mfloorclip, mceilingclip, false);
|
||||||
x++;
|
x++;
|
||||||
frac += xiscale;
|
frac += xiscale;
|
||||||
|
|
|
@ -43,24 +43,7 @@ CVAR(Bool, r_splitsprites, true, CVAR_ARCHIVE)
|
||||||
|
|
||||||
namespace swrenderer
|
namespace swrenderer
|
||||||
{
|
{
|
||||||
int MaxVisSprites;
|
void VisibleSpriteList::Deinit()
|
||||||
vissprite_t **vissprites;
|
|
||||||
vissprite_t **firstvissprite;
|
|
||||||
vissprite_t **vissprite_p;
|
|
||||||
vissprite_t **lastvissprite;
|
|
||||||
|
|
||||||
bool DrewAVoxel;
|
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
vissprite_t **spritesorter;
|
|
||||||
int spritesortersize = 0;
|
|
||||||
int vsprcount;
|
|
||||||
|
|
||||||
TArray<drawseg_t *> portaldrawsegs;
|
|
||||||
}
|
|
||||||
|
|
||||||
void R_DeinitVisSprites()
|
|
||||||
{
|
{
|
||||||
// Free vissprites
|
// Free vissprites
|
||||||
for (int i = 0; i < MaxVisSprites; ++i)
|
for (int i = 0; i < MaxVisSprites; ++i)
|
||||||
|
@ -73,12 +56,12 @@ namespace swrenderer
|
||||||
MaxVisSprites = 0;
|
MaxVisSprites = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_ClearVisSprites()
|
void VisibleSpriteList::Clear()
|
||||||
{
|
{
|
||||||
vissprite_p = firstvissprite;
|
vissprite_p = firstvissprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
vissprite_t *R_NewVisSprite()
|
vissprite_t *VisibleSpriteList::Add()
|
||||||
{
|
{
|
||||||
if (vissprite_p == lastvissprite)
|
if (vissprite_p == lastvissprite)
|
||||||
{
|
{
|
||||||
|
@ -103,27 +86,97 @@ namespace swrenderer
|
||||||
return *(vissprite_p - 1);
|
return *(vissprite_p - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_DeinitSprites()
|
int VisibleSpriteList::MaxVisSprites;
|
||||||
{
|
vissprite_t **VisibleSpriteList::vissprites;
|
||||||
R_DeinitVisSprites();
|
vissprite_t **VisibleSpriteList::firstvissprite;
|
||||||
RenderVoxel::Deinit();
|
vissprite_t **VisibleSpriteList::vissprite_p;
|
||||||
|
vissprite_t **VisibleSpriteList::lastvissprite;
|
||||||
|
|
||||||
// Free vissprites sorter
|
/////////////////////////////////////////////////////////////////////////
|
||||||
if (spritesorter != nullptr)
|
|
||||||
{
|
void SortedVisibleSpriteList::Deinit()
|
||||||
delete[] spritesorter;
|
{
|
||||||
spritesortersize = 0;
|
delete[] spritesorter;
|
||||||
spritesorter = nullptr;
|
spritesortersize = 0;
|
||||||
}
|
spritesorter = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_ClearSprites()
|
// This is the standard version, which does a simple test based on depth.
|
||||||
|
bool SortedVisibleSpriteList::sv_compare(vissprite_t *a, vissprite_t *b)
|
||||||
{
|
{
|
||||||
R_ClearVisSprites();
|
return a->idepth > b->idepth;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is an alternate version, for when one or more voxel is in view.
|
||||||
|
// It does a 2D distance test based on whichever one is furthest from
|
||||||
|
// the viewpoint.
|
||||||
|
bool SortedVisibleSpriteList::sv_compare2d(vissprite_t *a, vissprite_t *b)
|
||||||
|
{
|
||||||
|
return DVector2(a->deltax, a->deltay).LengthSquared() < DVector2(b->deltax, b->deltay).LengthSquared();
|
||||||
|
}
|
||||||
|
|
||||||
|
void SortedVisibleSpriteList::Sort(bool(*compare)(vissprite_t *, vissprite_t *), size_t first)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
vissprite_t **spr;
|
||||||
|
|
||||||
|
vsprcount = int(VisibleSpriteList::vissprite_p - &VisibleSpriteList::vissprites[first]);
|
||||||
|
|
||||||
|
if (vsprcount == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (spritesortersize < VisibleSpriteList::MaxVisSprites)
|
||||||
|
{
|
||||||
|
if (spritesorter != nullptr)
|
||||||
|
delete[] spritesorter;
|
||||||
|
spritesorter = new vissprite_t *[VisibleSpriteList::MaxVisSprites];
|
||||||
|
spritesortersize = VisibleSpriteList::MaxVisSprites;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(i_compatflags & COMPATF_SPRITESORT))
|
||||||
|
{
|
||||||
|
for (i = 0, spr = VisibleSpriteList::firstvissprite; i < vsprcount; i++, spr++)
|
||||||
|
{
|
||||||
|
spritesorter[i] = *spr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// If the compatibility option is on sprites of equal distance need to
|
||||||
|
// be sorted in inverse order. This is most easily achieved by
|
||||||
|
// filling the sort array backwards before the sort.
|
||||||
|
for (i = 0, spr = VisibleSpriteList::firstvissprite + vsprcount - 1; i < vsprcount; i++, spr--)
|
||||||
|
{
|
||||||
|
spritesorter[i] = *spr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::stable_sort(&spritesorter[0], &spritesorter[vsprcount], compare);
|
||||||
|
}
|
||||||
|
|
||||||
|
vissprite_t **SortedVisibleSpriteList::spritesorter;
|
||||||
|
int SortedVisibleSpriteList::spritesortersize = 0;
|
||||||
|
int SortedVisibleSpriteList::vsprcount;
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
bool RenderTranslucent::DrewAVoxel;
|
||||||
|
TArray<drawseg_t *> RenderTranslucent::portaldrawsegs;
|
||||||
|
|
||||||
|
void RenderTranslucent::Deinit()
|
||||||
|
{
|
||||||
|
VisibleSpriteList::Deinit();
|
||||||
|
SortedVisibleSpriteList::Deinit();
|
||||||
|
RenderVoxel::Deinit();
|
||||||
|
}
|
||||||
|
|
||||||
|
void RenderTranslucent::Clear()
|
||||||
|
{
|
||||||
|
VisibleSpriteList::Clear();
|
||||||
DrewAVoxel = false;
|
DrewAVoxel = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_CollectPortals()
|
void RenderTranslucent::CollectPortals()
|
||||||
{
|
{
|
||||||
// This function collects all drawsegs that may be of interest to R_ClipSpriteColumnWithPortals
|
// This function collects all drawsegs that may be of interest to R_ClipSpriteColumnWithPortals
|
||||||
// Having that function over the entire list of drawsegs can break down performance quite drastically.
|
// Having that function over the entire list of drawsegs can break down performance quite drastically.
|
||||||
|
@ -153,7 +206,7 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool R_ClipSpriteColumnWithPortals(int x, vissprite_t* spr)
|
bool RenderTranslucent::ClipSpriteColumnWithPortals(int x, vissprite_t* spr)
|
||||||
{
|
{
|
||||||
RenderPortal *renderportal = RenderPortal::Instance();
|
RenderPortal *renderportal = RenderPortal::Instance();
|
||||||
|
|
||||||
|
@ -181,60 +234,7 @@ namespace swrenderer
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the standard version, which does a simple test based on depth.
|
void RenderTranslucent::DrawSprite(vissprite_t *spr)
|
||||||
bool sv_compare(vissprite_t *a, vissprite_t *b)
|
|
||||||
{
|
|
||||||
return a->idepth > b->idepth;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This is an alternate version, for when one or more voxel is in view.
|
|
||||||
// It does a 2D distance test based on whichever one is furthest from
|
|
||||||
// the viewpoint.
|
|
||||||
bool sv_compare2d(vissprite_t *a, vissprite_t *b)
|
|
||||||
{
|
|
||||||
return DVector2(a->deltax, a->deltay).LengthSquared() < DVector2(b->deltax, b->deltay).LengthSquared();
|
|
||||||
}
|
|
||||||
|
|
||||||
void R_SortVisSprites(bool(*compare)(vissprite_t *, vissprite_t *), size_t first)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
vissprite_t **spr;
|
|
||||||
|
|
||||||
vsprcount = int(vissprite_p - &vissprites[first]);
|
|
||||||
|
|
||||||
if (vsprcount == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (spritesortersize < MaxVisSprites)
|
|
||||||
{
|
|
||||||
if (spritesorter != nullptr)
|
|
||||||
delete[] spritesorter;
|
|
||||||
spritesorter = new vissprite_t *[MaxVisSprites];
|
|
||||||
spritesortersize = MaxVisSprites;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!(i_compatflags & COMPATF_SPRITESORT))
|
|
||||||
{
|
|
||||||
for (i = 0, spr = firstvissprite; i < vsprcount; i++, spr++)
|
|
||||||
{
|
|
||||||
spritesorter[i] = *spr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// If the compatibility option is on sprites of equal distance need to
|
|
||||||
// be sorted in inverse order. This is most easily achieved by
|
|
||||||
// filling the sort array backwards before the sort.
|
|
||||||
for (i = 0, spr = firstvissprite + vsprcount - 1; i < vsprcount; i++, spr--)
|
|
||||||
{
|
|
||||||
spritesorter[i] = *spr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::stable_sort(&spritesorter[0], &spritesorter[vsprcount], compare);
|
|
||||||
}
|
|
||||||
|
|
||||||
void R_DrawSprite(vissprite_t *spr)
|
|
||||||
{
|
{
|
||||||
static short clipbot[MAXWIDTH];
|
static short clipbot[MAXWIDTH];
|
||||||
static short cliptop[MAXWIDTH];
|
static short cliptop[MAXWIDTH];
|
||||||
|
@ -639,15 +639,15 @@ namespace swrenderer
|
||||||
spr->Style.ColormapNum = colormapnum;
|
spr->Style.ColormapNum = colormapnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_DrawMaskedSingle(bool renew)
|
void RenderTranslucent::DrawMaskedSingle(bool renew)
|
||||||
{
|
{
|
||||||
RenderPortal *renderportal = RenderPortal::Instance();
|
RenderPortal *renderportal = RenderPortal::Instance();
|
||||||
|
|
||||||
for (int i = vsprcount; i > 0; i--)
|
for (int i = SortedVisibleSpriteList::vsprcount; i > 0; i--)
|
||||||
{
|
{
|
||||||
if (spritesorter[i - 1]->CurrentPortalUniq != renderportal->CurrentPortalUniq)
|
if (SortedVisibleSpriteList::spritesorter[i - 1]->CurrentPortalUniq != renderportal->CurrentPortalUniq)
|
||||||
continue; // probably another time
|
continue; // probably another time
|
||||||
R_DrawSprite(spritesorter[i - 1]);
|
DrawSprite(SortedVisibleSpriteList::spritesorter[i - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// render any remaining masked mid textures
|
// render any remaining masked mid textures
|
||||||
|
@ -676,15 +676,15 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void R_DrawMasked()
|
void RenderTranslucent::Render()
|
||||||
{
|
{
|
||||||
R_CollectPortals();
|
CollectPortals();
|
||||||
R_SortVisSprites(DrewAVoxel ? sv_compare2d : sv_compare, firstvissprite - vissprites);
|
SortedVisibleSpriteList::Sort(DrewAVoxel ? SortedVisibleSpriteList::sv_compare2d : SortedVisibleSpriteList::sv_compare, VisibleSpriteList::firstvissprite - VisibleSpriteList::vissprites);
|
||||||
|
|
||||||
Clip3DFloors *clip3d = Clip3DFloors::Instance();
|
Clip3DFloors *clip3d = Clip3DFloors::Instance();
|
||||||
if (clip3d->height_top == nullptr)
|
if (clip3d->height_top == nullptr)
|
||||||
{ // kg3D - no visible 3D floors, normal rendering
|
{ // kg3D - no visible 3D floors, normal rendering
|
||||||
R_DrawMaskedSingle(false);
|
DrawMaskedSingle(false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{ // kg3D - correct sorting
|
{ // kg3D - correct sorting
|
||||||
|
@ -701,14 +701,14 @@ namespace swrenderer
|
||||||
clip3d->fake3D = FAKE3D_CLIPBOTTOM;
|
clip3d->fake3D = FAKE3D_CLIPBOTTOM;
|
||||||
}
|
}
|
||||||
clip3d->sclipBottom = hl->height;
|
clip3d->sclipBottom = hl->height;
|
||||||
R_DrawMaskedSingle(true);
|
DrawMaskedSingle(true);
|
||||||
R_DrawHeightPlanes(hl->height);
|
R_DrawHeightPlanes(hl->height);
|
||||||
}
|
}
|
||||||
|
|
||||||
// floors
|
// floors
|
||||||
clip3d->fake3D = FAKE3D_DOWN2UP | FAKE3D_CLIPTOP;
|
clip3d->fake3D = FAKE3D_DOWN2UP | FAKE3D_CLIPTOP;
|
||||||
clip3d->sclipTop = clip3d->height_top->height;
|
clip3d->sclipTop = clip3d->height_top->height;
|
||||||
R_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);
|
R_DrawHeightPlanes(hl->height);
|
||||||
|
@ -722,7 +722,7 @@ namespace swrenderer
|
||||||
clip3d->fake3D = FAKE3D_DOWN2UP | FAKE3D_CLIPBOTTOM;
|
clip3d->fake3D = FAKE3D_DOWN2UP | FAKE3D_CLIPBOTTOM;
|
||||||
}
|
}
|
||||||
clip3d->sclipBottom = hl->height;
|
clip3d->sclipBottom = hl->height;
|
||||||
R_DrawMaskedSingle(true);
|
DrawMaskedSingle(true);
|
||||||
}
|
}
|
||||||
clip3d->DeleteHeights();
|
clip3d->DeleteHeights();
|
||||||
clip3d->fake3D = 0;
|
clip3d->fake3D = 0;
|
||||||
|
|
|
@ -23,6 +23,8 @@ struct FVoxel;
|
||||||
|
|
||||||
namespace swrenderer
|
namespace swrenderer
|
||||||
{
|
{
|
||||||
|
struct drawseg_t;
|
||||||
|
|
||||||
struct vissprite_t
|
struct vissprite_t
|
||||||
{
|
{
|
||||||
struct posang
|
struct posang
|
||||||
|
@ -88,25 +90,55 @@ namespace swrenderer
|
||||||
vissprite_t() {}
|
vissprite_t() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int MaxVisSprites;
|
class VisibleSpriteList
|
||||||
extern vissprite_t **vissprites, **firstvissprite;
|
{
|
||||||
extern vissprite_t **vissprite_p;
|
public:
|
||||||
|
static int MaxVisSprites;
|
||||||
|
static vissprite_t **vissprites;
|
||||||
|
static vissprite_t **firstvissprite;
|
||||||
|
static vissprite_t **vissprite_p;
|
||||||
|
|
||||||
extern bool DrewAVoxel;
|
static void Deinit();
|
||||||
|
static void Clear();
|
||||||
|
static vissprite_t *Add();
|
||||||
|
|
||||||
void R_DeinitVisSprites();
|
private:
|
||||||
void R_ClearVisSprites();
|
static vissprite_t **lastvissprite;
|
||||||
vissprite_t *R_NewVisSprite();
|
};
|
||||||
|
|
||||||
void R_DeinitSprites();
|
class SortedVisibleSpriteList
|
||||||
void R_ClearSprites();
|
{
|
||||||
void R_CollectPortals();
|
public:
|
||||||
bool R_ClipSpriteColumnWithPortals(int x, vissprite_t* spr);
|
static void Deinit();
|
||||||
void R_SortVisSprites(bool(*compare)(vissprite_t *, vissprite_t *), size_t first);
|
|
||||||
void R_DrawSprite(vissprite_t *spr);
|
|
||||||
void R_DrawMaskedSingle(bool renew);
|
|
||||||
void R_DrawMasked();
|
|
||||||
|
|
||||||
bool sv_compare(vissprite_t *a, vissprite_t *b);
|
static void Sort(bool(*compare)(vissprite_t *, vissprite_t *), size_t first);
|
||||||
bool sv_compare2d(vissprite_t *a, vissprite_t *b);
|
|
||||||
|
static bool sv_compare(vissprite_t *a, vissprite_t *b);
|
||||||
|
static bool sv_compare2d(vissprite_t *a, vissprite_t *b);
|
||||||
|
|
||||||
|
static vissprite_t **spritesorter;
|
||||||
|
static int vsprcount;
|
||||||
|
|
||||||
|
private:
|
||||||
|
static int spritesortersize;
|
||||||
|
};
|
||||||
|
|
||||||
|
class RenderTranslucent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static void Deinit();
|
||||||
|
static void Clear();
|
||||||
|
static void Render();
|
||||||
|
|
||||||
|
static bool DrewAVoxel;
|
||||||
|
|
||||||
|
static bool ClipSpriteColumnWithPortals(int x, vissprite_t* spr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static void CollectPortals();
|
||||||
|
static void DrawSprite(vissprite_t *spr);
|
||||||
|
static void DrawMaskedSingle(bool renew);
|
||||||
|
|
||||||
|
static TArray<drawseg_t *> portaldrawsegs;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -101,7 +101,7 @@ namespace swrenderer
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
vissprite_t *vis = R_NewVisSprite();
|
vissprite_t *vis = VisibleSpriteList::Add();
|
||||||
|
|
||||||
vis->CurrentPortalUniq = renderportal->CurrentPortalUniq;
|
vis->CurrentPortalUniq = renderportal->CurrentPortalUniq;
|
||||||
vis->xscale = FLOAT2FIXED(xscale);
|
vis->xscale = FLOAT2FIXED(xscale);
|
||||||
|
@ -152,7 +152,7 @@ namespace swrenderer
|
||||||
vis->voxel = voxel->Voxel;
|
vis->voxel = voxel->Voxel;
|
||||||
vis->bIsVoxel = true;
|
vis->bIsVoxel = true;
|
||||||
vis->bWallSprite = false;
|
vis->bWallSprite = false;
|
||||||
DrewAVoxel = true;
|
RenderTranslucent::DrewAVoxel = true;
|
||||||
|
|
||||||
// The software renderer cannot invert the source without inverting the overlay
|
// The software renderer cannot invert the source without inverting the overlay
|
||||||
// too. That means if the source is inverted, we need to do the reverse of what
|
// too. That means if the source is inverted, we need to do the reverse of what
|
||||||
|
|
|
@ -102,7 +102,7 @@ namespace swrenderer
|
||||||
gzt = pos.Z + scale.Y * scaled_to;
|
gzt = pos.Z + scale.Y * scaled_to;
|
||||||
gzb = pos.Z + scale.Y * scaled_bo;
|
gzb = pos.Z + scale.Y * scaled_bo;
|
||||||
|
|
||||||
vis = R_NewVisSprite();
|
vis = VisibleSpriteList::Add();
|
||||||
vis->CurrentPortalUniq = renderportal->CurrentPortalUniq;
|
vis->CurrentPortalUniq = renderportal->CurrentPortalUniq;
|
||||||
vis->x1 = wallc.sx1 < renderportal->WindowLeft ? renderportal->WindowLeft : wallc.sx1;
|
vis->x1 = wallc.sx1 < renderportal->WindowLeft ? renderportal->WindowLeft : wallc.sx1;
|
||||||
vis->x2 = wallc.sx2 >= renderportal->WindowRight ? renderportal->WindowRight : wallc.sx2;
|
vis->x2 = wallc.sx2 >= renderportal->WindowRight ? renderportal->WindowRight : wallc.sx2;
|
||||||
|
@ -222,7 +222,7 @@ namespace swrenderer
|
||||||
{ // calculate lighting
|
{ // calculate lighting
|
||||||
R_SetColorMapLight(usecolormap, light, shade);
|
R_SetColorMapLight(usecolormap, light, shade);
|
||||||
}
|
}
|
||||||
if (!R_ClipSpriteColumnWithPortals(x, spr))
|
if (!RenderTranslucent::ClipSpriteColumnWithPortals(x, spr))
|
||||||
DrawColumn(x, WallSpriteTile, maskedScaleY, sprflipvert, mfloorclip, mceilingclip);
|
DrawColumn(x, WallSpriteTile, maskedScaleY, sprflipvert, mfloorclip, mceilingclip);
|
||||||
light += lightstep;
|
light += lightstep;
|
||||||
x++;
|
x++;
|
||||||
|
|
Loading…
Reference in a new issue