- removed level references in the software renderers.
This commit is contained in:
parent
4f540c1703
commit
8c542e9be8
31 changed files with 99 additions and 77 deletions
|
|
@ -34,6 +34,7 @@
|
|||
#include "st_stuff.h"
|
||||
#include "g_levellocals.h"
|
||||
#include "p_effect.h"
|
||||
#include "actorinlines.h"
|
||||
#include "polyrenderer/scene/poly_light.h"
|
||||
#include "swrenderer/scene/r_scene.h"
|
||||
#include "swrenderer/drawers/r_draw_rgba.h"
|
||||
|
|
@ -131,8 +132,9 @@ void PolyRenderer::RenderActorView(AActor *actor, bool dontmaplines)
|
|||
NetUpdate();
|
||||
|
||||
DontMapLines = dontmaplines;
|
||||
|
||||
|
||||
R_SetupFrame(Viewpoint, Viewwindow, actor);
|
||||
Level = Viewpoint.ViewLevel;
|
||||
P_FindParticleSubsectors();
|
||||
PO_LinkToSubsectors(&level);
|
||||
|
||||
|
|
@ -222,7 +224,7 @@ PolyPortalViewpoint PolyRenderer::SetupPerspectiveMatrix(bool mirror)
|
|||
// We have to scale the pitch to account for the pixel stretching, because the playsim doesn't know about this and treats it as 1:1.
|
||||
double radPitch = Viewpoint.Angles.Pitch.Normalized180().Radians();
|
||||
double angx = cos(radPitch);
|
||||
double angy = sin(radPitch) * level.info->pixelstretch;
|
||||
double angy = sin(radPitch) * PolyRenderer::Instance()->Level->info->pixelstretch;
|
||||
double alen = sqrt(angx*angx + angy*angy);
|
||||
float adjustedPitch = (float)asin(angy / alen);
|
||||
float adjustedViewAngle = (float)(Viewpoint.Angles.Yaw - 90).Radians();
|
||||
|
|
@ -238,7 +240,7 @@ PolyPortalViewpoint PolyRenderer::SetupPerspectiveMatrix(bool mirror)
|
|||
Mat4f::Rotate((float)Viewpoint.Angles.Roll.Radians(), 0.0f, 0.0f, 1.0f) *
|
||||
Mat4f::Rotate(adjustedPitch, 1.0f, 0.0f, 0.0f) *
|
||||
Mat4f::Rotate(adjustedViewAngle, 0.0f, -1.0f, 0.0f) *
|
||||
Mat4f::Scale(1.0f, level.info->pixelstretch, 1.0f) *
|
||||
Mat4f::Scale(1.0f, PolyRenderer::Instance()->Level->info->pixelstretch, 1.0f) *
|
||||
Mat4f::SwapYZ() *
|
||||
Mat4f::Translate((float)-Viewpoint.Pos.X, (float)-Viewpoint.Pos.Y, (float)-Viewpoint.Pos.Z);
|
||||
|
||||
|
|
|
|||
|
|
@ -68,6 +68,7 @@ public:
|
|||
FRenderViewpoint Viewpoint;
|
||||
PolyLightVisibility Light;
|
||||
RenderPolyScene Scene;
|
||||
FLevelLocals *Level;
|
||||
|
||||
private:
|
||||
void RenderActorView(AActor *actor, bool dontmaplines);
|
||||
|
|
|
|||
|
|
@ -32,18 +32,18 @@ void PolyCull::CullScene(sector_t *portalSector, line_t *portalLine)
|
|||
{
|
||||
for (uint32_t sub : PvsSubsectors)
|
||||
SubsectorDepths[sub] = 0xffffffff;
|
||||
SubsectorDepths.resize(level.subsectors.Size(), 0xffffffff);
|
||||
SubsectorDepths.resize(PolyRenderer::Instance()->Level->subsectors.Size(), 0xffffffff);
|
||||
|
||||
for (uint32_t sector : SeenSectors)
|
||||
SectorSeen[sector] = false;
|
||||
SectorSeen.resize(level.sectors.Size());
|
||||
SectorSeen.resize(PolyRenderer::Instance()->Level->sectors.Size());
|
||||
|
||||
PvsSubsectors.clear();
|
||||
SeenSectors.clear();
|
||||
|
||||
NextPvsLineStart = 0;
|
||||
PvsLineStart.clear();
|
||||
PvsLineVisible.resize(level.segs.Size());
|
||||
PvsLineVisible.resize(PolyRenderer::Instance()->Level->segs.Size());
|
||||
|
||||
PortalSector = portalSector;
|
||||
PortalLine = portalLine;
|
||||
|
|
@ -78,10 +78,10 @@ void PolyCull::CullScene(sector_t *portalSector, line_t *portalLine)
|
|||
FirstSkyHeight = true;
|
||||
MaxCeilingHeight = 0.0;
|
||||
MinFloorHeight = 0.0;
|
||||
if (level.nodes.Size() == 0)
|
||||
CullSubsector(&level.subsectors[0]);
|
||||
if (PolyRenderer::Instance()->Level->nodes.Size() == 0)
|
||||
CullSubsector(&PolyRenderer::Instance()->Level->subsectors[0]);
|
||||
else
|
||||
CullNode(level.HeadNode());
|
||||
CullNode(PolyRenderer::Instance()->Level->HeadNode());
|
||||
}
|
||||
|
||||
void PolyCull::CullNode(void *node)
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void PolyLightVisibility::SetVisibility(FViewWindow &viewwindow, float vis)
|
|||
|
||||
fixed_t PolyLightVisibility::LightLevelToShade(int lightlevel, bool foggy)
|
||||
{
|
||||
bool nolightfade = !foggy && ((level.flags3 & LEVEL3_NOLIGHTFADE));
|
||||
bool nolightfade = !foggy && ((PolyRenderer::Instance()->Level->flags3 & LEVEL3_NOLIGHTFADE));
|
||||
if (nolightfade)
|
||||
{
|
||||
return (MAX(255 - lightlevel, 0) * NUMCOLORMAPS) << (FRACBITS - 8);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ EXTERN_CVAR(Int, gl_particles_style)
|
|||
void RenderPolyParticle::Render(PolyRenderThread *thread, particle_t *particle, subsector_t *sub, uint32_t stencilValue)
|
||||
{
|
||||
double timefrac = r_viewpoint.TicFrac;
|
||||
if (paused || bglobal.freeze || (level.flags2 & LEVEL2_FROZEN))
|
||||
if (paused || bglobal.freeze || (PolyRenderer::Instance()->Level->flags2 & LEVEL2_FROZEN))
|
||||
timefrac = 0.;
|
||||
DVector3 pos = particle->Pos + (particle->Vel * timefrac);
|
||||
double psize = particle->size / 8.0;
|
||||
|
|
|
|||
|
|
@ -246,7 +246,7 @@ void RenderPolyPlane::RenderSkyWalls(PolyRenderThread *thread, PolyDrawArgs &arg
|
|||
|
||||
void RenderPolyPlane::SetLightLevel(PolyRenderThread *thread, PolyDrawArgs &args, const PolyTransferHeights &fakeflat, bool ceiling)
|
||||
{
|
||||
bool foggy = level.fadeto || fakeflat.FrontSector->Colormap.FadeColor || (level.flags & LEVEL_HASFADETABLE);
|
||||
bool foggy = PolyRenderer::Instance()->Level->fadeto || fakeflat.FrontSector->Colormap.FadeColor || (PolyRenderer::Instance()->Level->flags & LEVEL_HASFADETABLE);
|
||||
|
||||
int lightlevel = ceiling ? fakeflat.CeilingLightLevel : fakeflat.FloorLightLevel;
|
||||
int actualextralight = foggy ? 0 : PolyRenderer::Instance()->Viewpoint.extralight << 4;
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ void RenderPolyPlayerSprites::Render(PolyRenderThread *thread)
|
|||
}
|
||||
|
||||
// [RH] set foggy flag
|
||||
bool foggy = (level.fadeto || basecolormap->Fade || (level.flags & LEVEL_HASFADETABLE));
|
||||
bool foggy = (PolyRenderer::Instance()->Level->fadeto || basecolormap->Fade || (PolyRenderer::Instance()->Level->flags & LEVEL_HASFADETABLE));
|
||||
|
||||
// get light level
|
||||
lightnum = ((floorlight + ceilinglight) >> 1) + (foggy ? 0 : viewpoint.extralight << 4);
|
||||
|
|
@ -458,7 +458,7 @@ void RenderPolyPlayerSprites::RenderSprite(PolyRenderThread *thread, DPSprite *p
|
|||
|
||||
fixed_t RenderPolyPlayerSprites::LightLevelToShade(int lightlevel, bool foggy)
|
||||
{
|
||||
bool nolightfade = !foggy && ((level.flags3 & LEVEL3_NOLIGHTFADE));
|
||||
bool nolightfade = !foggy && ((PolyRenderer::Instance()->Level->flags3 & LEVEL3_NOLIGHTFADE));
|
||||
if (nolightfade)
|
||||
{
|
||||
return (MAX(255 - lightlevel, 0) * NUMCOLORMAPS) << (FRACBITS - 8);
|
||||
|
|
|
|||
|
|
@ -91,13 +91,13 @@ void PolyDrawSectorPortal::SaveGlobals()
|
|||
viewpoint.SetViewAngle(viewwindow);
|
||||
|
||||
Portal->mFlags |= PORTSF_INSKYBOX;
|
||||
if (Portal->mPartner > 0) level.sectorPortals[Portal->mPartner].mFlags |= PORTSF_INSKYBOX;
|
||||
if (Portal->mPartner > 0) PolyRenderer::Instance()->Level->sectorPortals[Portal->mPartner].mFlags |= PORTSF_INSKYBOX;
|
||||
}
|
||||
|
||||
void PolyDrawSectorPortal::RestoreGlobals()
|
||||
{
|
||||
Portal->mFlags &= ~PORTSF_INSKYBOX;
|
||||
if (Portal->mPartner > 0) level.sectorPortals[Portal->mPartner].mFlags &= ~PORTSF_INSKYBOX;
|
||||
if (Portal->mPartner > 0) PolyRenderer::Instance()->Level->sectorPortals[Portal->mPartner].mFlags &= ~PORTSF_INSKYBOX;
|
||||
|
||||
auto &viewpoint = PolyRenderer::Instance()->Viewpoint;
|
||||
const auto &viewwindow = PolyRenderer::Instance()->Viewwindow;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ void RenderPolyScene::Render(PolyPortalViewpoint *viewpoint)
|
|||
const auto &rviewpoint = PolyRenderer::Instance()->Viewpoint;
|
||||
for (uint32_t sectorIndex : Cull.SeenSectors)
|
||||
{
|
||||
sector_t *sector = &level.sectors[sectorIndex];
|
||||
sector_t *sector = &PolyRenderer::Instance()->Level->sectors[sectorIndex];
|
||||
for (AActor *thing = sector->thinglist; thing != nullptr; thing = thing->snext)
|
||||
{
|
||||
if (!RenderPolySprite::IsThingCulled(thing))
|
||||
|
|
@ -132,7 +132,7 @@ void RenderPolyScene::RenderSectors()
|
|||
int end = thread->End;
|
||||
for (int i = start; i < end; i++)
|
||||
{
|
||||
RenderSubsector(thread, &level.subsectors[subsectors[i]], i);
|
||||
RenderSubsector(thread, &PolyRenderer::Instance()->Level->subsectors[subsectors[i]], i);
|
||||
}
|
||||
}, [&](PolyRenderThread *thread)
|
||||
{
|
||||
|
|
@ -254,15 +254,15 @@ int RenderPolyScene::PointOnSide(const DVector2 &pos, const node_t *node)
|
|||
|
||||
void RenderPolyScene::AddSprite(PolyRenderThread *thread, AActor *thing, double sortDistance, const DVector2 &left, const DVector2 &right)
|
||||
{
|
||||
if (level.nodes.Size() == 0)
|
||||
if (PolyRenderer::Instance()->Level->nodes.Size() == 0)
|
||||
{
|
||||
subsector_t *sub = &level.subsectors[0];
|
||||
subsector_t *sub = &PolyRenderer::Instance()->Level->subsectors[0];
|
||||
if (Cull.SubsectorDepths[sub->Index()] != 0xffffffff)
|
||||
thread->TranslucentObjects.push_back(thread->FrameMemory->NewObject<PolyTranslucentThing>(thing, sub, Cull.SubsectorDepths[sub->Index()], sortDistance, 0.0f, 1.0f, CurrentViewpoint->StencilValue));
|
||||
}
|
||||
else
|
||||
{
|
||||
AddSprite(thread, thing, sortDistance, left, right, 0.0, 1.0, level.HeadNode());
|
||||
AddSprite(thread, thing, sortDistance, left, right, 0.0, 1.0, PolyRenderer::Instance()->Level->HeadNode());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -303,15 +303,15 @@ void RenderPolyScene::AddSprite(PolyRenderThread *thread, AActor *thing, double
|
|||
|
||||
void RenderPolyScene::AddModel(PolyRenderThread *thread, AActor *thing, double sortDistance, DVector2 pos)
|
||||
{
|
||||
if (level.nodes.Size() == 0)
|
||||
if (PolyRenderer::Instance()->Level->nodes.Size() == 0)
|
||||
{
|
||||
subsector_t *sub = &level.subsectors[0];
|
||||
subsector_t *sub = &PolyRenderer::Instance()->Level->subsectors[0];
|
||||
if (Cull.SubsectorDepths[sub->Index()] != 0xffffffff)
|
||||
thread->TranslucentObjects.push_back(thread->FrameMemory->NewObject<PolyTranslucentThing>(thing, sub, Cull.SubsectorDepths[sub->Index()], sortDistance, 0.0f, 1.0f, CurrentViewpoint->StencilValue));
|
||||
}
|
||||
else
|
||||
{
|
||||
void *node = level.HeadNode();
|
||||
void *node = PolyRenderer::Instance()->Level->HeadNode();
|
||||
|
||||
while (!((size_t)node & 1)) // Keep going until found a subsector
|
||||
{
|
||||
|
|
@ -444,7 +444,7 @@ PolyTransferHeights::PolyTransferHeights(subsector_t *sub) : Subsector(sub)
|
|||
|
||||
// If player's view height is underneath fake floor, lower the
|
||||
// drawn ceiling to be just under the floor height, and replace
|
||||
// the drawn floor and ceiling textures, and light level, with
|
||||
// the drawn floor and ceiling textures, and light PolyRenderer::Instance()->Level->, with
|
||||
// the control sector's.
|
||||
//
|
||||
// Similar for ceiling, only reflected.
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ Mat4f PolySkyDome::GLSkyMath()
|
|||
|
||||
float xscale = texw < 1024.f ? floor(1024.f / float(texw)) : 1.f;
|
||||
float yscale = 1.f;
|
||||
if (texh <= 128 && (level.flags & LEVEL_FORCETILEDSKY))
|
||||
if (texh <= 128 && (PolyRenderer::Instance()->Level->flags & LEVEL_FORCETILEDSKY))
|
||||
{
|
||||
modelMatrix = modelMatrix * Mat4f::Translate(0.f, 0.f, (-40 + tex->GetSkyOffset() + skyoffset)*skyoffsetfactor);
|
||||
modelMatrix = modelMatrix * Mat4f::Scale(1.f, 1.f, 1.2f * 1.17f);
|
||||
|
|
@ -307,7 +307,7 @@ void PolySkySetup::Update()
|
|||
}
|
||||
else if (skyheight > 200)
|
||||
{
|
||||
skytexturemid = (200 - skyheight) * sskytex1->GetScale().Y + ((r_skymode == 2 && !(level.flags & LEVEL_FORCETILEDSKY)) ? skytex1->GetSkyOffset() : 0);
|
||||
skytexturemid = (200 - skyheight) * sskytex1->GetScale().Y + ((r_skymode == 2 && !(PolyRenderer::Instance()->Level->flags & LEVEL_FORCETILEDSKY)) ? skytex1->GetSkyOffset() : 0);
|
||||
}
|
||||
|
||||
if (viewwidth != 0 && viewheight != 0)
|
||||
|
|
@ -337,7 +337,7 @@ void PolySkySetup::Update()
|
|||
FTextureID sky1tex, sky2tex;
|
||||
double frontdpos = 0, backdpos = 0;
|
||||
|
||||
if ((level.flags & LEVEL_SWAPSKIES) && !(level.flags & LEVEL_DOUBLESKY))
|
||||
if ((PolyRenderer::Instance()->Level->flags & LEVEL_SWAPSKIES) && !(PolyRenderer::Instance()->Level->flags & LEVEL_DOUBLESKY))
|
||||
{
|
||||
sky1tex = sky2texture;
|
||||
}
|
||||
|
|
@ -355,7 +355,7 @@ void PolySkySetup::Update()
|
|||
{ // use sky1
|
||||
sky1:
|
||||
frontskytex = GetSWTex(sky1tex);
|
||||
if (level.flags & LEVEL_DOUBLESKY)
|
||||
if (PolyRenderer::Instance()->Level->flags & LEVEL_DOUBLESKY)
|
||||
backskytex = GetSWTex(sky2tex);
|
||||
else
|
||||
backskytex = nullptr;
|
||||
|
|
@ -376,7 +376,7 @@ void PolySkySetup::Update()
|
|||
else
|
||||
{ // MBF's linedef-controlled skies
|
||||
// Sky Linedef
|
||||
const line_t *l = &level.lines[(sectorSky & ~PL_SKYFLAT) - 1];
|
||||
const line_t *l = &PolyRenderer::Instance()->Level->lines[(sectorSky & ~PL_SKYFLAT) - 1];
|
||||
|
||||
// Sky transferred from first sidedef
|
||||
const side_t *s = l->sidedef[0];
|
||||
|
|
@ -384,7 +384,7 @@ void PolySkySetup::Update()
|
|||
|
||||
// Texture comes from upper texture of reference sidedef
|
||||
// [RH] If swapping skies, then use the lower sidedef
|
||||
if (level.flags & LEVEL_SWAPSKIES && s->GetTexture(side_t::bottom).isValid())
|
||||
if (PolyRenderer::Instance()->Level->flags & LEVEL_SWAPSKIES && s->GetTexture(side_t::bottom).isValid())
|
||||
{
|
||||
pos = side_t::bottom;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue