Make visplanes hash list private

This commit is contained in:
Magnus Norddahl 2017-01-19 03:02:32 +01:00
parent a92771431b
commit 9eef7f9b32
3 changed files with 33 additions and 16 deletions

View file

@ -302,6 +302,27 @@ namespace swrenderer
return pl;
}
bool VisiblePlaneList::HasPortalPlanes() const
{
return visplanes[MAXVISPLANES] != nullptr;
}
visplane_t *VisiblePlaneList::PopFirstPortalPlane()
{
visplane_t *pl = visplanes[VisiblePlaneList::MAXVISPLANES];
if (pl)
{
visplanes[VisiblePlaneList::MAXVISPLANES] = pl->next;
pl->next = nullptr;
}
return pl;
}
void VisiblePlaneList::ClearPortalPlanes()
{
visplanes[VisiblePlaneList::MAXVISPLANES] = nullptr;
}
int VisiblePlaneList::Render()
{
visplane_t *pl;

View file

@ -32,16 +32,20 @@ namespace swrenderer
visplane_t *FindPlane(const secplane_t &height, FTextureID picnum, int lightlevel, double Alpha, bool additive, const FTransform &xxform, int sky, FSectorPortal *portal, FDynamicColormap *basecolormap);
visplane_t *GetRange(visplane_t *pl, int start, int stop);
bool HasPortalPlanes() const;
visplane_t *PopFirstPortalPlane();
void ClearPortalPlanes();
int Render();
void RenderHeight(double height);
enum { MAXVISPLANES = 128 }; // must be a power of 2
visplane_t *visplanes[MAXVISPLANES + 1];
private:
VisiblePlaneList();
visplane_t *Add(unsigned hash);
enum { MAXVISPLANES = 128 }; // must be a power of 2
visplane_t *visplanes[MAXVISPLANES + 1];
static unsigned CalcHash(int picnum, int lightlevel, const secplane_t &height) { return (unsigned)((picnum) * 3 + (lightlevel)+(FLOAT2FIXED((height).fD())) * 7) & (MAXVISPLANES - 1); }
};
}

View file

@ -94,7 +94,7 @@ namespace swrenderer
VisiblePlaneList *planes = VisiblePlaneList::Instance();
if (planes->visplanes[VisiblePlaneList::MAXVISPLANES] == nullptr)
if (!planes->HasPortalPlanes())
return;
Clip3DFloors::Instance()->EnterSkybox();
@ -109,17 +109,8 @@ namespace swrenderer
AActor *savedcamera = camera;
sector_t *savedsector = viewsector;
int i;
visplane_t *pl;
for (pl = planes->visplanes[VisiblePlaneList::MAXVISPLANES]; pl != nullptr; pl = planes->visplanes[VisiblePlaneList::MAXVISPLANES])
for (visplane_t *pl = planes->PopFirstPortalPlane(); pl != nullptr; pl = planes->PopFirstPortalPlane())
{
// 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
// new skyboxes go to the beginning of the list instead of the end).
planes->visplanes[VisiblePlaneList::MAXVISPLANES] = pl->next;
pl->next = nullptr;
if (pl->right < pl->left || !r_skyboxes || numskyboxes == MAX_SKYBOX_PLANES || pl->portal == nullptr)
{
pl->Render(OPAQUE, false, false);
@ -181,7 +172,7 @@ namespace swrenderer
auto ceilingclip = RenderOpaquePass::Instance()->ceilingclip;
auto floorclip = RenderOpaquePass::Instance()->floorclip;
for (i = pl->left; i < pl->right; i++)
for (int i = pl->left; i < pl->right; i++)
{
if (pl->top[i] == 0x7fff)
{
@ -253,6 +244,7 @@ namespace swrenderer
VisibleSpriteList::Instance()->PopPortal();
visplane_t *pl;
visplaneStack.Pop(pl);
if (pl->Alpha > 0 && pl->picnum != skyflatnum)
{
@ -277,7 +269,7 @@ namespace swrenderer
if (Clip3DFloors::Instance()->fakeActive) return;
planes->visplanes[VisiblePlaneList::MAXVISPLANES] = nullptr;
planes->ClearPortalPlanes();
}
void RenderPortal::RenderLinePortals()