mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-01-18 23:21:41 +00:00
- give the hardware renderer's drawinfo its own level pointer
This commit is contained in:
parent
0124cecc15
commit
ba114f6f23
33 changed files with 172 additions and 157 deletions
|
@ -902,7 +902,7 @@ public:
|
||||||
|
|
||||||
DVector2 Vec2Offset(double dx, double dy, bool absolute = false);
|
DVector2 Vec2Offset(double dx, double dy, bool absolute = false);
|
||||||
DVector3 Vec2OffsetZ(double dx, double dy, double atz, bool absolute = false);
|
DVector3 Vec2OffsetZ(double dx, double dy, double atz, bool absolute = false);
|
||||||
DVector2 AActor::Vec2Angle(double length, DAngle angle, bool absolute = false);
|
DVector2 Vec2Angle(double length, DAngle angle, bool absolute = false);
|
||||||
DVector3 Vec3Offset(double dx, double dy, double dz, bool absolute = false);
|
DVector3 Vec3Offset(double dx, double dy, double dz, bool absolute = false);
|
||||||
DVector3 Vec3Offset(const DVector3 &ofs, bool absolute = false);
|
DVector3 Vec3Offset(const DVector3 &ofs, bool absolute = false);
|
||||||
DVector3 Vec3Angle(double length, DAngle angle, double dz, bool absolute = false);
|
DVector3 Vec3Angle(double length, DAngle angle, double dz, bool absolute = false);
|
||||||
|
|
|
@ -625,7 +625,7 @@ void DThinker::RunThinkers ()
|
||||||
auto next = light->next;
|
auto next = light->next;
|
||||||
light->Tick();
|
light->Tick();
|
||||||
light = next;
|
light = next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "p_local.h"
|
#include "p_local.h"
|
||||||
#include "serializer.h"
|
#include "serializer.h"
|
||||||
#include "g_levellocals.h"
|
#include "g_levellocals.h"
|
||||||
|
#include "actorinlines.h"
|
||||||
#include "r_data/models/models.h"
|
#include "r_data/models/models.h"
|
||||||
#include "hwrenderer/dynlights/hw_dynlightdata.h"
|
#include "hwrenderer/dynlights/hw_dynlightdata.h"
|
||||||
#include "hwrenderer/utility/hw_clock.h"
|
#include "hwrenderer/utility/hw_clock.h"
|
||||||
|
@ -175,7 +176,7 @@ sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * came
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
auto di = HWDrawInfo::StartDrawInfo(nullptr, mainvp, nullptr);
|
auto di = HWDrawInfo::StartDrawInfo(mainvp.ViewLevel, nullptr, mainvp, nullptr);
|
||||||
auto &vp = di->Viewpoint;
|
auto &vp = di->Viewpoint;
|
||||||
|
|
||||||
di->Set3DViewport(gl_RenderState);
|
di->Set3DViewport(gl_RenderState);
|
||||||
|
@ -221,4 +222,4 @@ sector_t * FGLRenderer::RenderViewpoint (FRenderViewpoint &mainvp, AActor * came
|
||||||
return mainvp.sector;
|
return mainvp.sector;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -232,9 +232,9 @@ int FFlatVertexBuffer::CreateIndexedVertices(int h, sector_t *sec, const secplan
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void FFlatVertexBuffer::CreateIndexedFlatVertices()
|
void FFlatVertexBuffer::CreateIndexedFlatVertices(TArray<sector_t> §ors)
|
||||||
{
|
{
|
||||||
auto verts = BuildVertices();
|
auto verts = BuildVertices(sectors);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
/*
|
/*
|
||||||
|
@ -259,7 +259,7 @@ void FFlatVertexBuffer::CreateIndexedFlatVertices()
|
||||||
|
|
||||||
for (int h = sector_t::floor; h <= sector_t::ceiling; h++)
|
for (int h = sector_t::floor; h <= sector_t::ceiling; h++)
|
||||||
{
|
{
|
||||||
for (auto &sec : level.sectors)
|
for (auto &sec : sectors)
|
||||||
{
|
{
|
||||||
CreateIndexedVertices(h, &sec, sec.GetSecPlane(h), h == sector_t::floor, verts);
|
CreateIndexedVertices(h, &sec, sec.GetSecPlane(h), h == sector_t::floor, verts);
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ void FFlatVertexBuffer::CreateIndexedFlatVertices()
|
||||||
|
|
||||||
// We need to do a final check for Vavoom water and FF_FIX sectors.
|
// We need to do a final check for Vavoom water and FF_FIX sectors.
|
||||||
// No new vertices are needed here. The planes come from the actual sector
|
// No new vertices are needed here. The planes come from the actual sector
|
||||||
for (auto &sec : level.sectors)
|
for (auto &sec : sectors)
|
||||||
{
|
{
|
||||||
for (auto ff : sec.e->XFloor.ffloors)
|
for (auto ff : sec.e->XFloor.ffloors)
|
||||||
{
|
{
|
||||||
|
@ -310,10 +310,10 @@ void FFlatVertexBuffer::UpdatePlaneVertices(sector_t *sec, int plane)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void FFlatVertexBuffer::CreateVertices()
|
void FFlatVertexBuffer::CreateVertices(TArray<sector_t> §ors)
|
||||||
{
|
{
|
||||||
vbo_shadowdata.Resize(NUM_RESERVED);
|
vbo_shadowdata.Resize(NUM_RESERVED);
|
||||||
CreateIndexedFlatVertices();
|
CreateIndexedFlatVertices(sectors);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -390,10 +390,10 @@ void FFlatVertexBuffer::Copy(int start, int count)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void FFlatVertexBuffer::CreateVBO()
|
void FFlatVertexBuffer::CreateVBO(TArray<sector_t> §ors)
|
||||||
{
|
{
|
||||||
vbo_shadowdata.Resize(mNumReserved);
|
vbo_shadowdata.Resize(mNumReserved);
|
||||||
FFlatVertexBuffer::CreateVertices();
|
FFlatVertexBuffer::CreateVertices(sectors);
|
||||||
mCurIndex = mIndex = vbo_shadowdata.Size();
|
mCurIndex = mIndex = vbo_shadowdata.Size();
|
||||||
Copy(0, mIndex);
|
Copy(0, mIndex);
|
||||||
mIndexBuffer->SetData(ibo_data.Size() * sizeof(uint32_t), &ibo_data[0]);
|
mIndexBuffer->SetData(ibo_data.Size() * sizeof(uint32_t), &ibo_data[0]);
|
||||||
|
|
|
@ -84,7 +84,7 @@ public:
|
||||||
return std::make_pair(mVertexBuffer, mIndexBuffer);
|
return std::make_pair(mVertexBuffer, mIndexBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CreateVBO();
|
void CreateVBO(TArray<sector_t> §ors);
|
||||||
void Copy(int start, int count);
|
void Copy(int start, int count);
|
||||||
|
|
||||||
FFlatVertex *GetBuffer(int index) const
|
FFlatVertex *GetBuffer(int index) const
|
||||||
|
@ -119,11 +119,11 @@ private:
|
||||||
int CreateIndexedSectionVertices(subsector_t *sub, const secplane_t &plane, int floor, VertexContainer &cont);
|
int CreateIndexedSectionVertices(subsector_t *sub, const secplane_t &plane, int floor, VertexContainer &cont);
|
||||||
int CreateIndexedSectorVertices(sector_t *sec, const secplane_t &plane, int floor, VertexContainer &cont);
|
int CreateIndexedSectorVertices(sector_t *sec, const secplane_t &plane, int floor, VertexContainer &cont);
|
||||||
int CreateIndexedVertices(int h, sector_t *sec, const secplane_t &plane, int floor, VertexContainers &cont);
|
int CreateIndexedVertices(int h, sector_t *sec, const secplane_t &plane, int floor, VertexContainers &cont);
|
||||||
void CreateIndexedFlatVertices();
|
void CreateIndexedFlatVertices(TArray<sector_t> §ors);
|
||||||
|
|
||||||
void UpdatePlaneVertices(sector_t *sec, int plane);
|
void UpdatePlaneVertices(sector_t *sec, int plane);
|
||||||
protected:
|
protected:
|
||||||
void CreateVertices();
|
void CreateVertices(TArray<sector_t> §ors);
|
||||||
void CheckPlanes(sector_t *sector);
|
void CheckPlanes(sector_t *sector);
|
||||||
public:
|
public:
|
||||||
void CheckUpdate(sector_t *sector);
|
void CheckUpdate(sector_t *sector);
|
||||||
|
|
|
@ -137,12 +137,12 @@ static void CreateVerticesForSector(sector_t *sec, VertexContainer &gen)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TArray<VertexContainer> BuildVertices()
|
TArray<VertexContainer> BuildVertices(TArray<sector_t> §ors)
|
||||||
{
|
{
|
||||||
TArray<VertexContainer> verticesPerSector(level.sectors.Size(), true);
|
TArray<VertexContainer> verticesPerSector(sectors.Size(), true);
|
||||||
for (unsigned i=0; i<level.sectors.Size(); i++)
|
for (unsigned i=0; i< sectors.Size(); i++)
|
||||||
{
|
{
|
||||||
CreateVerticesForSector(&level.sectors[i], verticesPerSector[i]);
|
CreateVerticesForSector(§ors[i], verticesPerSector[i]);
|
||||||
}
|
}
|
||||||
return verticesPerSector;
|
return verticesPerSector;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,6 +64,6 @@ struct VertexContainer
|
||||||
|
|
||||||
using VertexContainers = TArray<VertexContainer>;
|
using VertexContainers = TArray<VertexContainer>;
|
||||||
|
|
||||||
VertexContainers BuildVertices();
|
VertexContainers BuildVertices(TArray<sector_t> §ors);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -686,7 +686,7 @@ void HWDrawInfo::DoSubsector(subsector_t * sub)
|
||||||
fakesector = hw_FakeFlat(sector, in_area, false);
|
fakesector = hw_FakeFlat(sector, in_area, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t &srf = section_renderflags[level.sections.SectionIndex(sub->section)];
|
uint8_t &srf = section_renderflags[Level->sections.SectionIndex(sub->section)];
|
||||||
if (!(srf & SSRF_PROCESSED))
|
if (!(srf & SSRF_PROCESSED))
|
||||||
{
|
{
|
||||||
srf |= SSRF_PROCESSED;
|
srf |= SSRF_PROCESSED;
|
||||||
|
@ -761,9 +761,9 @@ void HWDrawInfo::DoSubsector(subsector_t * sub)
|
||||||
|
|
||||||
void HWDrawInfo::RenderBSPNode (void *node)
|
void HWDrawInfo::RenderBSPNode (void *node)
|
||||||
{
|
{
|
||||||
if (level.nodes.Size() == 0)
|
if (Level->nodes.Size() == 0)
|
||||||
{
|
{
|
||||||
DoSubsector (&level.subsectors[0]);
|
DoSubsector (&Level->subsectors[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
while (!((size_t)node & 1)) // Keep going until found a subsector
|
while (!((size_t)node & 1)) // Keep going until found a subsector
|
||||||
|
|
|
@ -49,7 +49,7 @@ void GLDecal::DrawDecal(HWDrawInfo *di, FRenderState &state)
|
||||||
auto tex = gltexture;
|
auto tex = gltexture;
|
||||||
|
|
||||||
// calculate dynamic light effect.
|
// calculate dynamic light effect.
|
||||||
if (level.HasDynamicLights && !di->isFullbrightScene() && gl_light_sprites)
|
if (di->Level->HasDynamicLights && !di->isFullbrightScene() && gl_light_sprites)
|
||||||
{
|
{
|
||||||
// Note: This should be replaced with proper shader based lighting.
|
// Note: This should be replaced with proper shader based lighting.
|
||||||
double x, y;
|
double x, y;
|
||||||
|
@ -107,7 +107,7 @@ void GLDecal::DrawDecal(HWDrawInfo *di, FRenderState &state)
|
||||||
thiscm.FadeColor = Colormap.FadeColor;
|
thiscm.FadeColor = Colormap.FadeColor;
|
||||||
thiscm.CopyFrom3DLight(&lightlist[k]);
|
thiscm.CopyFrom3DLight(&lightlist[k]);
|
||||||
di->SetColor(state, thisll, rellight, di->isFullbrightScene(), thiscm, alpha);
|
di->SetColor(state, thisll, rellight, di->isFullbrightScene(), thiscm, alpha);
|
||||||
if (level.flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING) thiscm.Decolorize();
|
if (di->Level->flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING) thiscm.Decolorize();
|
||||||
di->SetFog(state, thisll, rellight, di->isFullbrightScene(), &thiscm, false);
|
di->SetFog(state, thisll, rellight, di->isFullbrightScene(), &thiscm, false);
|
||||||
state.SetSplitPlanes(lightlist[k].plane, lowplane);
|
state.SetSplitPlanes(lightlist[k].plane, lowplane);
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@ void GLWall::ProcessDecal(HWDrawInfo *di, DBaseDecal *decal, const FVector3 &nor
|
||||||
|
|
||||||
gldecal->Colormap = Colormap;
|
gldecal->Colormap = Colormap;
|
||||||
|
|
||||||
if (level.flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING)
|
if (di->Level->flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING)
|
||||||
{
|
{
|
||||||
gldecal->Colormap.Decolorize();
|
gldecal->Colormap.Decolorize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,13 +85,14 @@ HWDrawInfo *FDrawInfoList::GetNew()
|
||||||
mList.Pop(di);
|
mList.Pop(di);
|
||||||
return di;
|
return di;
|
||||||
}
|
}
|
||||||
return new HWDrawInfo;
|
return new HWDrawInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
void FDrawInfoList::Release(HWDrawInfo * di)
|
void FDrawInfoList::Release(HWDrawInfo * di)
|
||||||
{
|
{
|
||||||
di->DrawScene = nullptr;
|
di->DrawScene = nullptr;
|
||||||
di->ClearBuffers();
|
di->ClearBuffers();
|
||||||
|
di->Level = nullptr;
|
||||||
mList.Push(di);
|
mList.Push(di);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,10 +102,11 @@ void FDrawInfoList::Release(HWDrawInfo * di)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
HWDrawInfo *HWDrawInfo::StartDrawInfo(HWDrawInfo *parent, FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms)
|
HWDrawInfo *HWDrawInfo::StartDrawInfo(FLevelLocals *lev, HWDrawInfo *parent, FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms)
|
||||||
{
|
{
|
||||||
HWDrawInfo *di = di_list.GetNew();
|
HWDrawInfo *di = di_list.GetNew();
|
||||||
if (parent) di->DrawScene = parent->DrawScene;
|
if (parent) di->DrawScene = parent->DrawScene;
|
||||||
|
di->Level = lev;
|
||||||
di->StartScene(parentvp, uniforms);
|
di->StartScene(parentvp, uniforms);
|
||||||
return di;
|
return di;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +127,7 @@ void HWDrawInfo::StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uni
|
||||||
mClipper = &staticClipper;
|
mClipper = &staticClipper;
|
||||||
|
|
||||||
Viewpoint = parentvp;
|
Viewpoint = parentvp;
|
||||||
lightmode = level.lightMode;
|
lightmode = Level->lightMode;
|
||||||
if (uniforms)
|
if (uniforms)
|
||||||
{
|
{
|
||||||
VPUniforms = *uniforms;
|
VPUniforms = *uniforms;
|
||||||
|
@ -193,16 +195,19 @@ void HWDrawInfo::ClearBuffers()
|
||||||
HandledSubsectors.Clear();
|
HandledSubsectors.Clear();
|
||||||
spriteindex = 0;
|
spriteindex = 0;
|
||||||
|
|
||||||
CurrentMapSections.Resize(level.NumMapSections);
|
if (Level)
|
||||||
CurrentMapSections.Zero();
|
{
|
||||||
|
CurrentMapSections.Resize(Level->NumMapSections);
|
||||||
|
CurrentMapSections.Zero();
|
||||||
|
|
||||||
section_renderflags.Resize(level.sections.allSections.Size());
|
section_renderflags.Resize(Level->sections.allSections.Size());
|
||||||
ss_renderflags.Resize(level.subsectors.Size());
|
ss_renderflags.Resize(Level->subsectors.Size());
|
||||||
no_renderflags.Resize(level.subsectors.Size());
|
no_renderflags.Resize(Level->subsectors.Size());
|
||||||
|
|
||||||
memset(§ion_renderflags[0], 0, level.sections.allSections.Size() * sizeof(section_renderflags[0]));
|
memset(§ion_renderflags[0], 0, Level->sections.allSections.Size() * sizeof(section_renderflags[0]));
|
||||||
memset(&ss_renderflags[0], 0, level.subsectors.Size() * sizeof(ss_renderflags[0]));
|
memset(&ss_renderflags[0], 0, Level->subsectors.Size() * sizeof(ss_renderflags[0]));
|
||||||
memset(&no_renderflags[0], 0, level.nodes.Size() * sizeof(no_renderflags[0]));
|
memset(&no_renderflags[0], 0, Level->nodes.Size() * sizeof(no_renderflags[0]));
|
||||||
|
}
|
||||||
|
|
||||||
Decals[0].Clear();
|
Decals[0].Clear();
|
||||||
Decals[1].Clear();
|
Decals[1].Clear();
|
||||||
|
@ -245,7 +250,7 @@ void HWDrawInfo::SetViewArea()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
in_area = level.HasHeightSecs ? area_default : area_normal; // depends on exposed lower sectors, if map contains heightsecs.
|
in_area = Level->HasHeightSecs ? area_default : area_normal; // depends on exposed lower sectors, if map contains heightsecs.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -335,7 +340,7 @@ angle_t HWDrawInfo::FrustumAngle()
|
||||||
void HWDrawInfo::SetViewMatrix(const FRotator &angles, float vx, float vy, float vz, bool mirror, bool planemirror)
|
void HWDrawInfo::SetViewMatrix(const FRotator &angles, float vx, float vy, float vz, bool mirror, bool planemirror)
|
||||||
{
|
{
|
||||||
float mult = mirror ? -1.f : 1.f;
|
float mult = mirror ? -1.f : 1.f;
|
||||||
float planemult = planemirror ? -level.info->pixelstretch : level.info->pixelstretch;
|
float planemult = planemirror ? -Level->info->pixelstretch : Level->info->pixelstretch;
|
||||||
|
|
||||||
VPUniforms.mViewMatrix.loadIdentity();
|
VPUniforms.mViewMatrix.loadIdentity();
|
||||||
VPUniforms.mViewMatrix.rotate(angles.Roll.Degrees, 0.0f, 0.0f, 1.0f);
|
VPUniforms.mViewMatrix.rotate(angles.Roll.Degrees, 0.0f, 0.0f, 1.0f);
|
||||||
|
@ -424,7 +429,7 @@ void HWDrawInfo::CreateScene()
|
||||||
|
|
||||||
// reset the portal manager
|
// reset the portal manager
|
||||||
screen->mPortalState->StartFrame();
|
screen->mPortalState->StartFrame();
|
||||||
PO_LinkToSubsectors(&level);
|
PO_LinkToSubsectors(Level);
|
||||||
|
|
||||||
ProcessAll.Clock();
|
ProcessAll.Clock();
|
||||||
|
|
||||||
|
@ -432,7 +437,7 @@ void HWDrawInfo::CreateScene()
|
||||||
screen->mVertexData->Map();
|
screen->mVertexData->Map();
|
||||||
screen->mLights->Map();
|
screen->mLights->Map();
|
||||||
|
|
||||||
RenderBSP(level.HeadNode());
|
RenderBSP(Level->HeadNode());
|
||||||
|
|
||||||
// And now the crappy hacks that have to be done to avoid rendering anomalies.
|
// And now the crappy hacks that have to be done to avoid rendering anomalies.
|
||||||
// These cannot be multithreaded when the time comes because all these depend
|
// These cannot be multithreaded when the time comes because all these depend
|
||||||
|
@ -551,7 +556,7 @@ void HWDrawInfo::RenderPortal(HWPortal *p, FRenderState &state, bool usestencil)
|
||||||
{
|
{
|
||||||
auto gp = static_cast<HWPortal *>(p);
|
auto gp = static_cast<HWPortal *>(p);
|
||||||
gp->SetupStencil(this, state, usestencil);
|
gp->SetupStencil(this, state, usestencil);
|
||||||
auto new_di = StartDrawInfo(this, Viewpoint, &VPUniforms);
|
auto new_di = StartDrawInfo(this->Level, this, Viewpoint, &VPUniforms);
|
||||||
new_di->mCurrentPortal = gp;
|
new_di->mCurrentPortal = gp;
|
||||||
state.SetLightIndex(-1);
|
state.SetLightIndex(-1);
|
||||||
gp->DrawContents(new_di, state);
|
gp->DrawContents(new_di, state);
|
||||||
|
|
|
@ -97,11 +97,6 @@ enum DrawListType
|
||||||
|
|
||||||
struct HWDrawInfo
|
struct HWDrawInfo
|
||||||
{
|
{
|
||||||
virtual ~HWDrawInfo()
|
|
||||||
{
|
|
||||||
ClearBuffers();
|
|
||||||
}
|
|
||||||
|
|
||||||
struct wallseg
|
struct wallseg
|
||||||
{
|
{
|
||||||
float x1, y1, z1, x2, y2, z2;
|
float x1, y1, z1, x2, y2, z2;
|
||||||
|
@ -142,6 +137,7 @@ struct HWDrawInfo
|
||||||
int vpIndex;
|
int vpIndex;
|
||||||
ELightMode lightmode;
|
ELightMode lightmode;
|
||||||
|
|
||||||
|
FLevelLocals *Level;
|
||||||
HWDrawInfo * outer = nullptr;
|
HWDrawInfo * outer = nullptr;
|
||||||
int FullbrightFlags;
|
int FullbrightFlags;
|
||||||
std::atomic<int> spriteindex;
|
std::atomic<int> spriteindex;
|
||||||
|
@ -243,7 +239,7 @@ public:
|
||||||
void RenderBSPNode(void *node);
|
void RenderBSPNode(void *node);
|
||||||
void RenderBSP(void *node);
|
void RenderBSP(void *node);
|
||||||
|
|
||||||
static HWDrawInfo *StartDrawInfo(HWDrawInfo *parent, FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms);
|
static HWDrawInfo *StartDrawInfo(FLevelLocals *lev, HWDrawInfo *parent, FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms);
|
||||||
void StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms);
|
void StartScene(FRenderViewpoint &parentvp, HWViewpointUniforms *uniforms);
|
||||||
void ClearBuffers();
|
void ClearBuffers();
|
||||||
HWDrawInfo *EndDrawInfo();
|
HWDrawInfo *EndDrawInfo();
|
||||||
|
|
|
@ -289,7 +289,7 @@ void HWDrawList::SortWallIntoPlane(SortNode * head, SortNode * sort)
|
||||||
float newtexv = ws->tcs[GLWall::UPLFT].v + ((ws->tcs[GLWall::LOLFT].v - ws->tcs[GLWall::UPLFT].v) / (ws->zbottom[0] - ws->ztop[0])) * (fh->z - ws->ztop[0]);
|
float newtexv = ws->tcs[GLWall::UPLFT].v + ((ws->tcs[GLWall::LOLFT].v - ws->tcs[GLWall::UPLFT].v) / (ws->zbottom[0] - ws->ztop[0])) * (fh->z - ws->ztop[0]);
|
||||||
|
|
||||||
// I make the very big assumption here that translucent walls in sloped sectors
|
// I make the very big assumption here that translucent walls in sloped sectors
|
||||||
// and 3D-floors never coexist in the same level. If that were the case this
|
// and 3D-floors never coexist in the same level - If that were the case this
|
||||||
// code would become extremely more complicated.
|
// code would become extremely more complicated.
|
||||||
if (!ceiling)
|
if (!ceiling)
|
||||||
{
|
{
|
||||||
|
@ -709,7 +709,7 @@ void HWDrawList::Sort(HWDrawInfo *di)
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// Sorting the drawitems first by texture and then by light level.
|
// Sorting the drawitems first by texture and then by light level
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
|
|
|
@ -196,8 +196,9 @@ static sector_t *allocateSector(sector_t *sec)
|
||||||
{
|
{
|
||||||
if (fakesectorbuffer == nullptr)
|
if (fakesectorbuffer == nullptr)
|
||||||
{
|
{
|
||||||
fakesectorbuffer = (sector_t**)FakeSectorAllocator.Alloc(level.sectors.Size() * sizeof(sector_t*));
|
unsigned numsectors = level.sectors.Size();
|
||||||
memset(fakesectorbuffer, 0, level.sectors.Size() * sizeof(sector_t*));
|
fakesectorbuffer = (sector_t**)FakeSectorAllocator.Alloc(numsectors * sizeof(sector_t*));
|
||||||
|
memset(fakesectorbuffer, 0, numsectors * sizeof(sector_t*));
|
||||||
}
|
}
|
||||||
auto sectornum = sec->sectornum;
|
auto sectornum = sec->sectornum;
|
||||||
fakesectorbuffer[sectornum] = (sector_t*)FakeSectorAllocator.Alloc(sizeof(sector_t));
|
fakesectorbuffer[sectornum] = (sector_t*)FakeSectorAllocator.Alloc(sizeof(sector_t));
|
||||||
|
|
|
@ -141,7 +141,7 @@ void GLFlat::SetupLights(HWDrawInfo *di, FLightNode * node, FDynLightData &light
|
||||||
Plane p;
|
Plane p;
|
||||||
|
|
||||||
lightdata.Clear();
|
lightdata.Clear();
|
||||||
if (renderstyle == STYLE_Add && !level.lightadditivesurfaces)
|
if (renderstyle == STYLE_Add && !di->Level->lightadditivesurfaces)
|
||||||
{
|
{
|
||||||
dynlightindex = -1;
|
dynlightindex = -1;
|
||||||
return; // no lights on additively blended surfaces.
|
return; // no lights on additively blended surfaces.
|
||||||
|
@ -182,7 +182,7 @@ void GLFlat::SetupLights(HWDrawInfo *di, FLightNode * node, FDynLightData &light
|
||||||
|
|
||||||
void GLFlat::DrawSubsectors(HWDrawInfo *di, FRenderState &state)
|
void GLFlat::DrawSubsectors(HWDrawInfo *di, FRenderState &state)
|
||||||
{
|
{
|
||||||
if (level.HasDynamicLights && screen->BuffersArePersistent() && !di->isFullbrightScene())
|
if (di->Level->HasDynamicLights && screen->BuffersArePersistent() && !di->isFullbrightScene())
|
||||||
{
|
{
|
||||||
SetupLights(di, section->lighthead, lightdata, sector->PortalGroup);
|
SetupLights(di, section->lighthead, lightdata, sector->PortalGroup);
|
||||||
}
|
}
|
||||||
|
@ -377,7 +377,7 @@ inline void GLFlat::PutFlat(HWDrawInfo *di, bool fog)
|
||||||
}
|
}
|
||||||
else if (!screen->BuffersArePersistent())
|
else if (!screen->BuffersArePersistent())
|
||||||
{
|
{
|
||||||
if (level.HasDynamicLights && gltexture != nullptr && !di->isFullbrightScene() && !(hacktype & (SSRF_PLANEHACK|SSRF_FLOODHACK)) )
|
if (di->Level->HasDynamicLights && gltexture != nullptr && !di->isFullbrightScene() && !(hacktype & (SSRF_PLANEHACK|SSRF_FLOODHACK)) )
|
||||||
{
|
{
|
||||||
SetupLights(di, section->lighthead, lightdata, sector->PortalGroup);
|
SetupLights(di, section->lighthead, lightdata, sector->PortalGroup);
|
||||||
}
|
}
|
||||||
|
@ -484,13 +484,13 @@ void GLFlat::ProcessSector(HWDrawInfo *di, sector_t * frontsector, int which)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Get the real sector for this one.
|
// Get the real sector for this one.
|
||||||
sector = &level.sectors[frontsector->sectornum];
|
sector = &di->Level->sectors[frontsector->sectornum];
|
||||||
extsector_t::xfloor &x = sector->e->XFloor;
|
extsector_t::xfloor &x = sector->e->XFloor;
|
||||||
dynlightindex = -1;
|
dynlightindex = -1;
|
||||||
hacktype = (which & (SSRF_PLANEHACK|SSRF_FLOODHACK));
|
hacktype = (which & (SSRF_PLANEHACK|SSRF_FLOODHACK));
|
||||||
|
|
||||||
uint8_t sink;
|
uint8_t sink;
|
||||||
uint8_t &srf = hacktype? sink : di->section_renderflags[level.sections.SectionIndex(section)];
|
uint8_t &srf = hacktype? sink : di->section_renderflags[di->Level->sections.SectionIndex(section)];
|
||||||
const auto &vp = di->Viewpoint;
|
const auto &vp = di->Viewpoint;
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -733,7 +733,7 @@ const char *HWSkyboxPortal::GetName() { return "Skybox"; }
|
||||||
|
|
||||||
static uint8_t SetCoverage(HWDrawInfo *di, void *node)
|
static uint8_t SetCoverage(HWDrawInfo *di, void *node)
|
||||||
{
|
{
|
||||||
if (level.nodes.Size() == 0)
|
if (di->Level->nodes.Size() == 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -759,12 +759,12 @@ void HWSectorStackPortal::SetupCoverage(HWDrawInfo *di)
|
||||||
int plane = origin->plane;
|
int plane = origin->plane;
|
||||||
for (int j = 0; j<sub->portalcoverage[plane].sscount; j++)
|
for (int j = 0; j<sub->portalcoverage[plane].sscount; j++)
|
||||||
{
|
{
|
||||||
subsector_t *dsub = &::level.subsectors[sub->portalcoverage[plane].subsectors[j]];
|
subsector_t *dsub = &di->Level->subsectors[sub->portalcoverage[plane].subsectors[j]];
|
||||||
di->CurrentMapSections.Set(dsub->mapsection);
|
di->CurrentMapSections.Set(dsub->mapsection);
|
||||||
di->ss_renderflags[dsub->Index()] |= SSRF_SEEN;
|
di->ss_renderflags[dsub->Index()] |= SSRF_SEEN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SetCoverage(di, ::level.HeadNode());
|
SetCoverage(di, di->Level->HeadNode());
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -1020,7 +1020,7 @@ void HWEEHorizonPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
|
||||||
sector->GetTexture(sector_t::ceiling) == skyflatnum)
|
sector->GetTexture(sector_t::ceiling) == skyflatnum)
|
||||||
{
|
{
|
||||||
GLSkyInfo skyinfo;
|
GLSkyInfo skyinfo;
|
||||||
skyinfo.init(sector->sky, 0);
|
skyinfo.init(di, sector->sky, 0);
|
||||||
HWSkyPortal sky(screen->mSkyData, mState, &skyinfo, true);
|
HWSkyPortal sky(screen->mSkyData, mState, &skyinfo, true);
|
||||||
sky.DrawContents(di, state);
|
sky.DrawContents(di, state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct GLSkyInfo
|
||||||
{
|
{
|
||||||
return !!memcmp(this, &inf, sizeof(*this));
|
return !!memcmp(this, &inf, sizeof(*this));
|
||||||
}
|
}
|
||||||
void init(int sky1, PalEntry fadecolor);
|
void init(HWDrawInfo *di, int sky1, PalEntry fadecolor);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GLHorizonInfo
|
struct GLHorizonInfo
|
||||||
|
|
|
@ -55,28 +55,28 @@ void HWDrawInfo::DispatchRenderHacks()
|
||||||
glflat.section = nullptr;
|
glflat.section = nullptr;
|
||||||
while (ofi.NextPair(pair))
|
while (ofi.NextPair(pair))
|
||||||
{
|
{
|
||||||
auto sec = hw_FakeFlat(&level.sectors[pair->Key], in_area, false);
|
auto sec = hw_FakeFlat(&Level->sectors[pair->Key], in_area, false);
|
||||||
glflat.ProcessSector(this, sec, SSRF_RENDERFLOOR | SSRF_PLANEHACK);
|
glflat.ProcessSector(this, sec, SSRF_RENDERFLOOR | SSRF_PLANEHACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
TMap<int, gl_subsectorrendernode*>::Iterator oci(otherCeilingPlanes);
|
TMap<int, gl_subsectorrendernode*>::Iterator oci(otherCeilingPlanes);
|
||||||
while (oci.NextPair(pair))
|
while (oci.NextPair(pair))
|
||||||
{
|
{
|
||||||
auto sec = hw_FakeFlat(&level.sectors[pair->Key], in_area, false);
|
auto sec = hw_FakeFlat(&Level->sectors[pair->Key], in_area, false);
|
||||||
glflat.ProcessSector(this, sec, SSRF_RENDERCEILING | SSRF_PLANEHACK);
|
glflat.ProcessSector(this, sec, SSRF_RENDERCEILING | SSRF_PLANEHACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
TMap<int, gl_floodrendernode*>::Iterator ffi(floodFloorSegs);
|
TMap<int, gl_floodrendernode*>::Iterator ffi(floodFloorSegs);
|
||||||
while (ffi.NextPair(fpair))
|
while (ffi.NextPair(fpair))
|
||||||
{
|
{
|
||||||
auto sec = hw_FakeFlat(&level.sectors[fpair->Key], in_area, false);
|
auto sec = hw_FakeFlat(&Level->sectors[fpair->Key], in_area, false);
|
||||||
glflat.ProcessSector(this, sec, SSRF_RENDERFLOOR | SSRF_FLOODHACK);
|
glflat.ProcessSector(this, sec, SSRF_RENDERFLOOR | SSRF_FLOODHACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
TMap<int, gl_floodrendernode*>::Iterator fci(floodCeilingSegs);
|
TMap<int, gl_floodrendernode*>::Iterator fci(floodCeilingSegs);
|
||||||
while (fci.NextPair(fpair))
|
while (fci.NextPair(fpair))
|
||||||
{
|
{
|
||||||
auto sec = hw_FakeFlat(&level.sectors[fpair->Key], in_area, false);
|
auto sec = hw_FakeFlat(&Level->sectors[fpair->Key], in_area, false);
|
||||||
glflat.ProcessSector(this, sec, SSRF_RENDERCEILING | SSRF_FLOODHACK);
|
glflat.ProcessSector(this, sec, SSRF_RENDERCEILING | SSRF_FLOODHACK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ static gl_floodrendernode *NewFloodRenderNode()
|
||||||
|
|
||||||
int HWDrawInfo::SetupLightsForOtherPlane(subsector_t * sub, FDynLightData &lightdata, const secplane_t *plane)
|
int HWDrawInfo::SetupLightsForOtherPlane(subsector_t * sub, FDynLightData &lightdata, const secplane_t *plane)
|
||||||
{
|
{
|
||||||
if (level.HasDynamicLights && !isFullbrightScene())
|
if (Level->HasDynamicLights && !isFullbrightScene())
|
||||||
{
|
{
|
||||||
Plane p;
|
Plane p;
|
||||||
|
|
||||||
|
@ -170,8 +170,8 @@ void HWDrawInfo::AddOtherFloorPlane(int sector, gl_subsectorrendernode * node)
|
||||||
auto pNode = otherFloorPlanes.CheckKey(sector);
|
auto pNode = otherFloorPlanes.CheckKey(sector);
|
||||||
|
|
||||||
node->next = pNode? *pNode : nullptr;
|
node->next = pNode? *pNode : nullptr;
|
||||||
node->lightindex = SetupLightsForOtherPlane(node->sub, lightdata, &level.sectors[sector].floorplane);
|
node->lightindex = SetupLightsForOtherPlane(node->sub, lightdata, &Level->sectors[sector].floorplane);
|
||||||
node->vertexindex = CreateOtherPlaneVertices(node->sub, &level.sectors[sector].floorplane);
|
node->vertexindex = CreateOtherPlaneVertices(node->sub, &Level->sectors[sector].floorplane);
|
||||||
otherFloorPlanes[sector] = node;
|
otherFloorPlanes[sector] = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,8 +180,8 @@ void HWDrawInfo::AddOtherCeilingPlane(int sector, gl_subsectorrendernode * node)
|
||||||
auto pNode = otherCeilingPlanes.CheckKey(sector);
|
auto pNode = otherCeilingPlanes.CheckKey(sector);
|
||||||
|
|
||||||
node->next = pNode? *pNode : nullptr;
|
node->next = pNode? *pNode : nullptr;
|
||||||
node->lightindex = SetupLightsForOtherPlane(node->sub, lightdata, &level.sectors[sector].ceilingplane);
|
node->lightindex = SetupLightsForOtherPlane(node->sub, lightdata, &Level->sectors[sector].ceilingplane);
|
||||||
node->vertexindex = CreateOtherPlaneVertices(node->sub, &level.sectors[sector].ceilingplane);
|
node->vertexindex = CreateOtherPlaneVertices(node->sub, &Level->sectors[sector].ceilingplane);
|
||||||
otherCeilingPlanes[sector] = node;
|
otherCeilingPlanes[sector] = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -837,7 +837,7 @@ void HWDrawInfo::PrepareLowerGap(seg_t * seg)
|
||||||
|
|
||||||
void HWDrawInfo::PrepareUnhandledMissingTextures()
|
void HWDrawInfo::PrepareUnhandledMissingTextures()
|
||||||
{
|
{
|
||||||
if (!level.notexturefill)
|
if (!Level->notexturefill)
|
||||||
{
|
{
|
||||||
validcount++;
|
validcount++;
|
||||||
for (int i = MissingUpperSegs.Size() - 1; i >= 0; i--)
|
for (int i = MissingUpperSegs.Size() - 1; i >= 0; i--)
|
||||||
|
@ -894,7 +894,7 @@ void HWDrawInfo::PrepareUnhandledMissingTextures()
|
||||||
|
|
||||||
void HWDrawInfo::AddHackedSubsector(subsector_t * sub)
|
void HWDrawInfo::AddHackedSubsector(subsector_t * sub)
|
||||||
{
|
{
|
||||||
if (!(level.maptype == MAPTYPE_HEXEN))
|
if (!(Level->maptype == MAPTYPE_HEXEN))
|
||||||
{
|
{
|
||||||
SubsectorHackInfo sh={sub, 0};
|
SubsectorHackInfo sh={sub, 0};
|
||||||
SubsectorHacks.Push (sh);
|
SubsectorHacks.Push (sh);
|
||||||
|
|
|
@ -100,7 +100,7 @@ void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, int rellight, bool
|
||||||
PalEntry fogcolor;
|
PalEntry fogcolor;
|
||||||
float fogdensity;
|
float fogdensity;
|
||||||
|
|
||||||
if (level.flags&LEVEL_HASFADETABLE)
|
if (Level->flags&LEVEL_HASFADETABLE)
|
||||||
{
|
{
|
||||||
fogdensity = 70;
|
fogdensity = 70;
|
||||||
fogcolor = 0x808080;
|
fogcolor = 0x808080;
|
||||||
|
@ -150,7 +150,7 @@ void HWDrawInfo::SetFog(FRenderState &state, int lightlevel, int rellight, bool
|
||||||
state.SetFog(fogcolor, fogdensity);
|
state.SetFog(fogcolor, fogdensity);
|
||||||
|
|
||||||
// Korshun: fullbright fog like in software renderer.
|
// Korshun: fullbright fog like in software renderer.
|
||||||
if (isSoftwareLighting() && cmap->BlendFactor == 0 && level.brightfog && fogdensity != 0 && fogcolor != 0)
|
if (isSoftwareLighting() && cmap->BlendFactor == 0 && Level->brightfog && fogdensity != 0 && fogcolor != 0)
|
||||||
{
|
{
|
||||||
state.SetSoftLightLevel(255);
|
state.SetSoftLightLevel(255);
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,16 +41,16 @@ CVAR(Bool,gl_noskyboxes, false, 0)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void GLSkyInfo::init(int sky1, PalEntry FadeColor)
|
void GLSkyInfo::init(HWDrawInfo *di, int sky1, PalEntry FadeColor)
|
||||||
{
|
{
|
||||||
memset(this, 0, sizeof(*this));
|
memset(this, 0, sizeof(*this));
|
||||||
if ((sky1 & PL_SKYFLAT) && (sky1 & (PL_SKYFLAT - 1)))
|
if ((sky1 & PL_SKYFLAT) && (sky1 & (PL_SKYFLAT - 1)))
|
||||||
{
|
{
|
||||||
const line_t *l = &level.lines[(sky1&(PL_SKYFLAT - 1)) - 1];
|
const line_t *l = &di->Level->lines[(sky1&(PL_SKYFLAT - 1)) - 1];
|
||||||
const side_t *s = l->sidedef[0];
|
const side_t *s = l->sidedef[0];
|
||||||
int pos;
|
int pos;
|
||||||
|
|
||||||
if (level.flags & LEVEL_SWAPSKIES && s->GetTexture(side_t::bottom).isValid())
|
if (di->Level->flags & LEVEL_SWAPSKIES && s->GetTexture(side_t::bottom).isValid())
|
||||||
{
|
{
|
||||||
pos = side_t::bottom;
|
pos = side_t::bottom;
|
||||||
}
|
}
|
||||||
|
@ -70,14 +70,14 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
normalsky:
|
normalsky:
|
||||||
if (level.flags&LEVEL_DOUBLESKY)
|
if (di->Level->flags&LEVEL_DOUBLESKY)
|
||||||
{
|
{
|
||||||
texture[1] = FMaterial::ValidateTexture(sky1texture, false, true);
|
texture[1] = FMaterial::ValidateTexture(sky1texture, false, true);
|
||||||
x_offset[1] = hw_sky1pos;
|
x_offset[1] = hw_sky1pos;
|
||||||
doublesky = true;
|
doublesky = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((level.flags&LEVEL_SWAPSKIES || (sky1 == PL_SKYFLAT) || (level.flags&LEVEL_DOUBLESKY)) &&
|
if ((di->Level->flags&LEVEL_SWAPSKIES || (sky1 == PL_SKYFLAT) || (di->Level->flags&LEVEL_DOUBLESKY)) &&
|
||||||
sky2texture != sky1texture) // If both skies are equal use the scroll offset of the first!
|
sky2texture != sky1texture) // If both skies are equal use the scroll offset of the first!
|
||||||
{
|
{
|
||||||
texture[0] = FMaterial::ValidateTexture(sky2texture, false, true);
|
texture[0] = FMaterial::ValidateTexture(sky2texture, false, true);
|
||||||
|
@ -92,7 +92,7 @@ void GLSkyInfo::init(int sky1, PalEntry FadeColor)
|
||||||
x_offset[0] = hw_sky1pos;
|
x_offset[0] = hw_sky1pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (level.skyfog > 0)
|
if (di->Level->skyfog > 0)
|
||||||
{
|
{
|
||||||
fadecolor = FadeColor;
|
fadecolor = FadeColor;
|
||||||
fadecolor.a = 0;
|
fadecolor.a = 0;
|
||||||
|
@ -119,7 +119,7 @@ void GLWall::SkyPlane(HWDrawInfo *di, sector_t *sector, int plane, bool allowref
|
||||||
if ((sportal == nullptr && sector->GetTexture(plane) == skyflatnum) || (gl_noskyboxes && sportal != nullptr && sportal->mType == PORTS_SKYVIEWPOINT))
|
if ((sportal == nullptr && sector->GetTexture(plane) == skyflatnum) || (gl_noskyboxes && sportal != nullptr && sportal->mType == PORTS_SKYVIEWPOINT))
|
||||||
{
|
{
|
||||||
GLSkyInfo skyinfo;
|
GLSkyInfo skyinfo;
|
||||||
skyinfo.init(sector->sky, Colormap.FadeColor);
|
skyinfo.init(di, sector->sky, Colormap.FadeColor);
|
||||||
ptype = PORTALTYPE_SKY;
|
ptype = PORTALTYPE_SKY;
|
||||||
sky = &skyinfo;
|
sky = &skyinfo;
|
||||||
PutPortal(di, ptype, plane);
|
PutPortal(di, ptype, plane);
|
||||||
|
@ -189,7 +189,7 @@ void GLWall::SkyLine(HWDrawInfo *di, sector_t *fs, line_t *line)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
skyinfo.init(fs->sky, Colormap.FadeColor);
|
skyinfo.init(di, fs->sky, Colormap.FadeColor);
|
||||||
ptype = PORTALTYPE_SKY;
|
ptype = PORTALTYPE_SKY;
|
||||||
sky = &skyinfo;
|
sky = &skyinfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,6 +66,7 @@
|
||||||
#include "hwrenderer/textures/hw_material.h"
|
#include "hwrenderer/textures/hw_material.h"
|
||||||
#include "hw_skydome.h"
|
#include "hw_skydome.h"
|
||||||
#include "hw_renderstate.h"
|
#include "hw_renderstate.h"
|
||||||
|
#include "hw_drawinfo.h"
|
||||||
#include "hwrenderer/data/buffers.h"
|
#include "hwrenderer/data/buffers.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -281,7 +282,7 @@ void FSkyVertexBuffer::CreateDome()
|
||||||
//
|
//
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void FSkyVertexBuffer::SetupMatrices(FMaterial *tex, float x_offset, float y_offset, bool mirror, int mode, VSMatrix &modelMatrix, VSMatrix &textureMatrix)
|
void FSkyVertexBuffer::SetupMatrices(HWDrawInfo *di, FMaterial *tex, float x_offset, float y_offset, bool mirror, int mode, VSMatrix &modelMatrix, VSMatrix &textureMatrix)
|
||||||
{
|
{
|
||||||
int texw = tex->TextureWidth();
|
int texw = tex->TextureWidth();
|
||||||
int texh = tex->TextureHeight();
|
int texh = tex->TextureHeight();
|
||||||
|
@ -291,7 +292,7 @@ void FSkyVertexBuffer::SetupMatrices(FMaterial *tex, float x_offset, float y_off
|
||||||
|
|
||||||
float xscale = texw < 1024.f ? floor(1024.f / float(texw)) : 1.f;
|
float xscale = texw < 1024.f ? floor(1024.f / float(texw)) : 1.f;
|
||||||
float yscale = 1.f;
|
float yscale = 1.f;
|
||||||
if (texh <= 128 && (level.flags & LEVEL_FORCETILEDSKY))
|
if (texh <= 128 && (di->Level->flags & LEVEL_FORCETILEDSKY))
|
||||||
{
|
{
|
||||||
modelMatrix.translate(0.f, (-40 + tex->tex->GetSkyOffset() + skyoffset)*skyoffsetfactor, 0.f);
|
modelMatrix.translate(0.f, (-40 + tex->tex->GetSkyOffset() + skyoffset)*skyoffsetfactor, 0.f);
|
||||||
modelMatrix.scale(1.f, 1.2f * 1.17f, 1.f);
|
modelMatrix.scale(1.f, 1.2f * 1.17f, 1.f);
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
class FMaterial;
|
class FMaterial;
|
||||||
class FRenderState;
|
class FRenderState;
|
||||||
class IVertexBuffer;
|
class IVertexBuffer;
|
||||||
|
struct HWSkyPortal;
|
||||||
|
struct HWDrawInfo;
|
||||||
|
|
||||||
struct FSkyVertex
|
struct FSkyVertex
|
||||||
{
|
{
|
||||||
|
@ -34,7 +36,6 @@ struct FSkyVertex
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct HWSkyPortal;
|
|
||||||
class FSkyVertexBuffer
|
class FSkyVertexBuffer
|
||||||
{
|
{
|
||||||
friend struct HWSkyPortal;
|
friend struct HWSkyPortal;
|
||||||
|
@ -68,7 +69,7 @@ public:
|
||||||
|
|
||||||
FSkyVertexBuffer();
|
FSkyVertexBuffer();
|
||||||
~FSkyVertexBuffer();
|
~FSkyVertexBuffer();
|
||||||
void SetupMatrices(FMaterial *tex, float x_offset, float y_offset, bool mirror, int mode, VSMatrix &modelmatrix, VSMatrix &textureMatrix);
|
void SetupMatrices(HWDrawInfo *di, FMaterial *tex, float x_offset, float y_offset, bool mirror, int mode, VSMatrix &modelmatrix, VSMatrix &textureMatrix);
|
||||||
std::pair<IVertexBuffer *, IIndexBuffer *> GetBufferObjects() const
|
std::pair<IVertexBuffer *, IIndexBuffer *> GetBufferObjects() const
|
||||||
{
|
{
|
||||||
return std::make_pair(mVertexBuffer, nullptr);
|
return std::make_pair(mVertexBuffer, nullptr);
|
||||||
|
|
|
@ -58,7 +58,7 @@ void HWSkyPortal::RenderDome(HWDrawInfo *di, FRenderState &state, FMaterial * te
|
||||||
state.EnableModelMatrix(true);
|
state.EnableModelMatrix(true);
|
||||||
state.EnableTextureMatrix(true);
|
state.EnableTextureMatrix(true);
|
||||||
|
|
||||||
vertexBuffer->SetupMatrices(tex, x_offset, y_offset, mirror, mode, state.mModelMatrix, state.mTextureMatrix);
|
vertexBuffer->SetupMatrices(di, tex, x_offset, y_offset, mirror, mode, state.mModelMatrix, state.mTextureMatrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
int rc = vertexBuffer->mRows + 1;
|
int rc = vertexBuffer->mRows + 1;
|
||||||
|
@ -104,9 +104,9 @@ void HWSkyPortal::RenderBox(HWDrawInfo *di, FRenderState &state, FTextureID texn
|
||||||
state.mModelMatrix.loadIdentity();
|
state.mModelMatrix.loadIdentity();
|
||||||
|
|
||||||
if (!sky2)
|
if (!sky2)
|
||||||
state.mModelMatrix.rotate(-180.0f+x_offset, ::level.info->skyrotatevector.X, ::level.info->skyrotatevector.Z, ::level.info->skyrotatevector.Y);
|
state.mModelMatrix.rotate(-180.0f+x_offset, di->Level->info->skyrotatevector.X, di->Level->info->skyrotatevector.Z, di->Level->info->skyrotatevector.Y);
|
||||||
else
|
else
|
||||||
state.mModelMatrix.rotate(-180.0f+x_offset, ::level.info->skyrotatevector2.X, ::level.info->skyrotatevector2.Z, ::level.info->skyrotatevector2.Y);
|
state.mModelMatrix.rotate(-180.0f+x_offset, di->Level->info->skyrotatevector2.X, di->Level->info->skyrotatevector2.Z, di->Level->info->skyrotatevector2.Y);
|
||||||
|
|
||||||
if (sb->faces[5])
|
if (sb->faces[5])
|
||||||
{
|
{
|
||||||
|
@ -203,10 +203,10 @@ void HWSkyPortal::DrawContents(HWDrawInfo *di, FRenderState &state)
|
||||||
RenderDome(di, state, origin->texture[1], origin->x_offset[1], origin->y_offset, false, FSkyVertexBuffer::SKYMODE_SECONDLAYER);
|
RenderDome(di, state, origin->texture[1], origin->x_offset[1], origin->y_offset, false, FSkyVertexBuffer::SKYMODE_SECONDLAYER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (::level.skyfog>0 && !di->isFullbrightScene() && (origin->fadecolor & 0xffffff) != 0)
|
if (di->Level->skyfog>0 && !di->isFullbrightScene() && (origin->fadecolor & 0xffffff) != 0)
|
||||||
{
|
{
|
||||||
PalEntry FadeColor = origin->fadecolor;
|
PalEntry FadeColor = origin->fadecolor;
|
||||||
FadeColor.a = clamp<int>(::level.skyfog, 0, 255);
|
FadeColor.a = clamp<int>(di->Level->skyfog, 0, 255);
|
||||||
|
|
||||||
state.EnableTexture(false);
|
state.EnableTexture(false);
|
||||||
state.SetObjectColor(FadeColor);
|
state.SetObjectColor(FadeColor);
|
||||||
|
|
|
@ -67,13 +67,13 @@ void HWDrawInfo::GetDynSpriteLight(AActor *self, float x, float y, float z, FLig
|
||||||
|
|
||||||
// This is a performance critical section of code where we cannot afford to let the compiler decide whether to inline the function or not.
|
// This is a performance critical section of code where we cannot afford to let the compiler decide whether to inline the function or not.
|
||||||
// This will do the calculations explicitly rather than calling one of AActor's utility functions.
|
// This will do the calculations explicitly rather than calling one of AActor's utility functions.
|
||||||
if (level.Displacements.size > 0)
|
if (Level->Displacements.size > 0)
|
||||||
{
|
{
|
||||||
int fromgroup = light->Sector->PortalGroup;
|
int fromgroup = light->Sector->PortalGroup;
|
||||||
int togroup = portalgroup;
|
int togroup = portalgroup;
|
||||||
if (fromgroup == togroup || fromgroup == 0 || togroup == 0) goto direct;
|
if (fromgroup == togroup || fromgroup == 0 || togroup == 0) goto direct;
|
||||||
|
|
||||||
DVector2 offset = level.Displacements.getOffset(fromgroup, togroup);
|
DVector2 offset = Level->Displacements.getOffset(fromgroup, togroup);
|
||||||
L = FVector3(x - (float)(light->X() + offset.X), y - (float)(light->Y() + offset.Y), z - (float)light->Z());
|
L = FVector3(x - (float)(light->X() + offset.X), y - (float)(light->Y() + offset.Y), z - (float)light->Z());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -127,7 +127,7 @@ void GLSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent)
|
||||||
state.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold);
|
state.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold);
|
||||||
state.SetColor(0.2f, 0.2f, 0.2f, fuzzalpha, Colormap.Desaturation);
|
state.SetColor(0.2f, 0.2f, 0.2f, fuzzalpha, Colormap.Desaturation);
|
||||||
additivefog = true;
|
additivefog = true;
|
||||||
lightlist = nullptr; // the fuzz effect does not use the sector's light level so splitting is not needed.
|
lightlist = nullptr; // the fuzz effect does not use the sector's light di->Level-> so splitting is not needed.
|
||||||
}
|
}
|
||||||
else if (RenderStyle.BlendOp == STYLEOP_Add && RenderStyle.DestAlpha == STYLEALPHA_One)
|
else if (RenderStyle.BlendOp == STYLEOP_Add && RenderStyle.DestAlpha == STYLEALPHA_One)
|
||||||
{
|
{
|
||||||
|
@ -142,7 +142,7 @@ void GLSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent)
|
||||||
}
|
}
|
||||||
if (RenderStyle.BlendOp != STYLEOP_Shadow)
|
if (RenderStyle.BlendOp != STYLEOP_Shadow)
|
||||||
{
|
{
|
||||||
if (level.HasDynamicLights && !di->isFullbrightScene() && !fullbright)
|
if (di->Level->HasDynamicLights && !di->isFullbrightScene() && !fullbright)
|
||||||
{
|
{
|
||||||
if (dynlightindex == -1) // only set if we got no light buffer index. This covers all cases where sprite lighting is used.
|
if (dynlightindex == -1) // only set if we got no light buffer index. This covers all cases where sprite lighting is used.
|
||||||
{
|
{
|
||||||
|
@ -224,7 +224,7 @@ void GLSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent)
|
||||||
FColormap thiscm;
|
FColormap thiscm;
|
||||||
thiscm.CopyFog(Colormap);
|
thiscm.CopyFog(Colormap);
|
||||||
thiscm.CopyFrom3DLight(&(*lightlist)[i]);
|
thiscm.CopyFrom3DLight(&(*lightlist)[i]);
|
||||||
if (level.flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING)
|
if (di->Level->flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING)
|
||||||
{
|
{
|
||||||
thiscm.Decolorize();
|
thiscm.Decolorize();
|
||||||
}
|
}
|
||||||
|
@ -459,7 +459,7 @@ bool GLSprite::CalculateVertices(HWDrawInfo *di, FVector3 *v, DVector3 *vp)
|
||||||
inline void GLSprite::PutSprite(HWDrawInfo *di, bool translucent)
|
inline void GLSprite::PutSprite(HWDrawInfo *di, bool translucent)
|
||||||
{
|
{
|
||||||
// That's a lot of checks...
|
// That's a lot of checks...
|
||||||
if (modelframe && !modelframe->isVoxel && RenderStyle.BlendOp != STYLEOP_Shadow && gl_light_sprites && level.HasDynamicLights && !di->isFullbrightScene() && !fullbright)
|
if (modelframe && !modelframe->isVoxel && RenderStyle.BlendOp != STYLEOP_Shadow && gl_light_sprites && di->Level->HasDynamicLights && !di->isFullbrightScene() && !fullbright)
|
||||||
{
|
{
|
||||||
hw_GetDynModelLight(actor, lightdata);
|
hw_GetDynModelLight(actor, lightdata);
|
||||||
dynlightindex = screen->mLights->UploadLights(lightdata);
|
dynlightindex = screen->mLights->UploadLights(lightdata);
|
||||||
|
@ -528,7 +528,7 @@ void GLSprite::SplitSprite(HWDrawInfo *di, sector_t * frontsector, bool transluc
|
||||||
copySprite.lightlevel = hw_ClampLight(*lightlist[i].p_lightlevel);
|
copySprite.lightlevel = hw_ClampLight(*lightlist[i].p_lightlevel);
|
||||||
copySprite.Colormap.CopyLight(lightlist[i].extra_colormap);
|
copySprite.Colormap.CopyLight(lightlist[i].extra_colormap);
|
||||||
|
|
||||||
if (level.flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING)
|
if (di->Level->flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING)
|
||||||
{
|
{
|
||||||
copySprite.Colormap.Decolorize();
|
copySprite.Colormap.Decolorize();
|
||||||
}
|
}
|
||||||
|
@ -696,13 +696,13 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
||||||
|
|
||||||
// [RH] Interpolate the sprite's position to make it look smooth
|
// [RH] Interpolate the sprite's position to make it look smooth
|
||||||
DVector3 thingpos = thing->InterpolatedPosition(vp.TicFrac);
|
DVector3 thingpos = thing->InterpolatedPosition(vp.TicFrac);
|
||||||
if (thruportal == 1) thingpos += level.Displacements.getOffset(thing->Sector->PortalGroup, sector->PortalGroup);
|
if (thruportal == 1) thingpos += di->Level->Displacements.getOffset(thing->Sector->PortalGroup, sector->PortalGroup);
|
||||||
|
|
||||||
// Some added checks if the camera actor is not supposed to be seen. It can happen that some portal setup has this actor in view in which case it may not be skipped here
|
// Some added checks if the camera actor is not supposed to be seen. It can happen that some portal setup has this actor in view in which case it may not be skipped here
|
||||||
if (thing == camera && !vp.showviewer)
|
if (thing == camera && !vp.showviewer)
|
||||||
{
|
{
|
||||||
DVector3 thingorigin = thing->Pos();
|
DVector3 thingorigin = thing->Pos();
|
||||||
if (thruportal == 1) thingorigin += level.Displacements.getOffset(thing->Sector->PortalGroup, sector->PortalGroup);
|
if (thruportal == 1) thingorigin += di->Level->Displacements.getOffset(thing->Sector->PortalGroup, sector->PortalGroup);
|
||||||
if (fabs(thingorigin.X - vp.ActorPos.X) < 2 && fabs(thingorigin.Y - vp.ActorPos.Y) < 2) return;
|
if (fabs(thingorigin.X - vp.ActorPos.X) < 2 && fabs(thingorigin.Y - vp.ActorPos.Y) < 2) return;
|
||||||
}
|
}
|
||||||
// Thing is invisible if close to the camera.
|
// Thing is invisible if close to the camera.
|
||||||
|
@ -773,7 +773,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
||||||
x = thingpos.X;
|
x = thingpos.X;
|
||||||
z = thingpos.Z;
|
z = thingpos.Z;
|
||||||
y = thingpos.Y;
|
y = thingpos.Y;
|
||||||
if (spritetype == RF_FACESPRITE) z -= thing->Floorclip; // wall and flat sprites are to be considered level geometry so this may not apply.
|
if (spritetype == RF_FACESPRITE) z -= thing->Floorclip; // wall and flat sprites are to be considered di->Level-> geometry so this may not apply.
|
||||||
|
|
||||||
// [RH] Make floatbobbing a renderer-only effect.
|
// [RH] Make floatbobbing a renderer-only effect.
|
||||||
if (thing->flags2 & MF2_FLOATBOB)
|
if (thing->flags2 & MF2_FLOATBOB)
|
||||||
|
@ -946,7 +946,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
||||||
Colormap = rendersector->Colormap;
|
Colormap = rendersector->Colormap;
|
||||||
if (fullbright)
|
if (fullbright)
|
||||||
{
|
{
|
||||||
if (rendersector == &level.sectors[rendersector->sectornum] || in_area != area_below)
|
if (rendersector == &di->Level->sectors[rendersector->sectornum] || in_area != area_below)
|
||||||
// under water areas keep their color for fullbright objects
|
// under water areas keep their color for fullbright objects
|
||||||
{
|
{
|
||||||
// Only make the light white but keep everything else (fog, desaturation and Boom colormap.)
|
// Only make the light white but keep everything else (fog, desaturation and Boom colormap.)
|
||||||
|
@ -960,7 +960,7 @@ void GLSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
|
||||||
Colormap.LightColor.b = (3 * Colormap.LightColor.b + 0xff) / 4;
|
Colormap.LightColor.b = (3 * Colormap.LightColor.b + 0xff) / 4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (level.flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING)
|
else if (di->Level->flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING)
|
||||||
{
|
{
|
||||||
Colormap.Decolorize();
|
Colormap.Decolorize();
|
||||||
}
|
}
|
||||||
|
@ -1143,7 +1143,7 @@ void GLSprite::ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t *
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (level.flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING)
|
if (di->Level->flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING)
|
||||||
{
|
{
|
||||||
Colormap.Decolorize(); // ZDoom never applies colored light to particles.
|
Colormap.Decolorize(); // ZDoom never applies colored light to particles.
|
||||||
}
|
}
|
||||||
|
@ -1198,7 +1198,7 @@ void GLSprite::ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t *
|
||||||
|
|
||||||
const auto &vp = di->Viewpoint;
|
const auto &vp = di->Viewpoint;
|
||||||
double timefrac = vp.TicFrac;
|
double timefrac = vp.TicFrac;
|
||||||
if (paused || bglobal.freeze || (level.flags2 & LEVEL2_FROZEN))
|
if (paused || bglobal.freeze || (di->Level->flags2 & LEVEL2_FROZEN))
|
||||||
timefrac = 0.;
|
timefrac = 0.;
|
||||||
float xvf = (particle->Vel.X) * timefrac;
|
float xvf = (particle->Vel.X) * timefrac;
|
||||||
float yvf = (particle->Vel.Y) * timefrac;
|
float yvf = (particle->Vel.Y) * timefrac;
|
||||||
|
|
|
@ -281,7 +281,7 @@ void GLWall::DrawWall(HWDrawInfo *di, FRenderState &state, bool translucent)
|
||||||
{
|
{
|
||||||
if (screen->BuffersArePersistent())
|
if (screen->BuffersArePersistent())
|
||||||
{
|
{
|
||||||
if (level.HasDynamicLights && !di->isFullbrightScene() && gltexture != nullptr)
|
if (di->Level->HasDynamicLights && !di->isFullbrightScene() && gltexture != nullptr)
|
||||||
{
|
{
|
||||||
SetupLights(di, lightdata);
|
SetupLights(di, lightdata);
|
||||||
}
|
}
|
||||||
|
@ -322,7 +322,7 @@ void GLWall::SetupLights(HWDrawInfo *di, FDynLightData &lightdata)
|
||||||
{
|
{
|
||||||
lightdata.Clear();
|
lightdata.Clear();
|
||||||
|
|
||||||
if (RenderStyle == STYLE_Add && !level.lightadditivesurfaces) return; // no lights on additively blended surfaces.
|
if (RenderStyle == STYLE_Add && !di->Level->lightadditivesurfaces) return; // no lights on additively blended surfaces.
|
||||||
|
|
||||||
// check for wall types which cannot have dynamic lights on them (portal types never get here so they don't need to be checked.)
|
// check for wall types which cannot have dynamic lights on them (portal types never get here so they don't need to be checked.)
|
||||||
switch (type)
|
switch (type)
|
||||||
|
@ -456,7 +456,7 @@ void GLWall::PutWall(HWDrawInfo *di, bool translucent)
|
||||||
|
|
||||||
if (!screen->BuffersArePersistent())
|
if (!screen->BuffersArePersistent())
|
||||||
{
|
{
|
||||||
if (level.HasDynamicLights && !di->isFullbrightScene() && gltexture != nullptr)
|
if (di->Level->HasDynamicLights && !di->isFullbrightScene() && gltexture != nullptr)
|
||||||
{
|
{
|
||||||
SetupLights(di, lightdata);
|
SetupLights(di, lightdata);
|
||||||
}
|
}
|
||||||
|
@ -567,7 +567,7 @@ void GLWall::PutPortal(HWDrawInfo *di, int ptype, int plane)
|
||||||
if (!portal)
|
if (!portal)
|
||||||
{
|
{
|
||||||
line_t *otherside = lineportal->lines[0]->mDestination;
|
line_t *otherside = lineportal->lines[0]->mDestination;
|
||||||
if (otherside != nullptr && otherside->portalindex < level.linePortals.Size())
|
if (otherside != nullptr && otherside->portalindex < di->Level->linePortals.Size())
|
||||||
{
|
{
|
||||||
di->ProcessActorsInPortal(otherside->getPortal()->mGroup, di->in_area);
|
di->ProcessActorsInPortal(otherside->getPortal()->mGroup, di->in_area);
|
||||||
}
|
}
|
||||||
|
@ -604,7 +604,7 @@ void GLWall::PutPortal(HWDrawInfo *di, int ptype, int plane)
|
||||||
|
|
||||||
void GLWall::Put3DWall(HWDrawInfo *di, lightlist_t * lightlist, bool translucent)
|
void GLWall::Put3DWall(HWDrawInfo *di, lightlist_t * lightlist, bool translucent)
|
||||||
{
|
{
|
||||||
// only modify the light level if it doesn't originate from the seg's frontsector. This is to account for light transferring effects
|
// only modify the light di->Level-> if it doesn't originate from the seg's frontsector. This is to account for light transferring effects
|
||||||
if (lightlist->p_lightlevel != &seg->sidedef->sector->lightlevel)
|
if (lightlist->p_lightlevel != &seg->sidedef->sector->lightlevel)
|
||||||
{
|
{
|
||||||
lightlevel = hw_ClampLight(*lightlist->p_lightlevel);
|
lightlevel = hw_ClampLight(*lightlist->p_lightlevel);
|
||||||
|
@ -1516,7 +1516,7 @@ void GLWall::BuildFFBlock(HWDrawInfo *di, seg_t * seg, F3DFloor * rover,
|
||||||
light = P_GetPlaneLight(rover->target, rover->top.plane, true);
|
light = P_GetPlaneLight(rover->target, rover->top.plane, true);
|
||||||
Colormap.Clear();
|
Colormap.Clear();
|
||||||
Colormap.LightColor = light->extra_colormap.FadeColor;
|
Colormap.LightColor = light->extra_colormap.FadeColor;
|
||||||
// the fog plane defines the light level, not the front sector
|
// the fog plane defines the light di->Level->, not the front sector
|
||||||
lightlevel = hw_ClampLight(*light->p_lightlevel);
|
lightlevel = hw_ClampLight(*light->p_lightlevel);
|
||||||
gltexture = NULL;
|
gltexture = NULL;
|
||||||
type = RENDERWALL_FFBLOCK;
|
type = RENDERWALL_FFBLOCK;
|
||||||
|
@ -1867,8 +1867,8 @@ void GLWall::Process(HWDrawInfo *di, seg_t *seg, sector_t * frontsector, sector_
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Need these for aligning the textures
|
// Need these for aligning the textures
|
||||||
realfront = &level.sectors[frontsector->sectornum];
|
realfront = &di->Level->sectors[frontsector->sectornum];
|
||||||
realback = backsector ? &level.sectors[backsector->sectornum] : NULL;
|
realback = backsector ? &di->Level->sectors[backsector->sectornum] : NULL;
|
||||||
segfront = frontsector;
|
segfront = frontsector;
|
||||||
segback = backsector;
|
segback = backsector;
|
||||||
}
|
}
|
||||||
|
@ -1928,7 +1928,7 @@ void GLWall::Process(HWDrawInfo *di, seg_t *seg, sector_t * frontsector, sector_
|
||||||
|
|
||||||
int rel = 0;
|
int rel = 0;
|
||||||
int orglightlevel = hw_ClampLight(frontsector->lightlevel);
|
int orglightlevel = hw_ClampLight(frontsector->lightlevel);
|
||||||
bool foggy = (!Colormap.FadeColor.isBlack() || level.flags&LEVEL_HASFADETABLE); // fog disables fake contrast
|
bool foggy = (!Colormap.FadeColor.isBlack() || di->Level->flags&LEVEL_HASFADETABLE); // fog disables fake contrast
|
||||||
lightlevel = hw_ClampLight(seg->sidedef->GetLightLevel(foggy, orglightlevel, false, &rel));
|
lightlevel = hw_ClampLight(seg->sidedef->GetLightLevel(foggy, orglightlevel, false, &rel));
|
||||||
if (orglightlevel >= 253) // with the software renderer fake contrast won't be visible above this.
|
if (orglightlevel >= 253) // with the software renderer fake contrast won't be visible above this.
|
||||||
{
|
{
|
||||||
|
|
|
@ -237,7 +237,7 @@ WeaponLighting HWDrawInfo::GetWeaponLighting(sector_t *viewsector, const DVector
|
||||||
l.lightlevel = hw_ClampLight(fakesec->lightlevel);
|
l.lightlevel = hw_ClampLight(fakesec->lightlevel);
|
||||||
|
|
||||||
// calculate colormap for weapon sprites
|
// calculate colormap for weapon sprites
|
||||||
if (viewsector->e->XFloor.ffloors.Size() && !(level.flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING))
|
if (viewsector->e->XFloor.ffloors.Size() && !(Level->flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING))
|
||||||
{
|
{
|
||||||
TArray<lightlist_t> & lightlist = viewsector->e->XFloor.lightlist;
|
TArray<lightlist_t> & lightlist = viewsector->e->XFloor.lightlist;
|
||||||
for (unsigned i = 0; i<lightlist.Size(); i++)
|
for (unsigned i = 0; i<lightlist.Size(); i++)
|
||||||
|
@ -264,7 +264,7 @@ WeaponLighting HWDrawInfo::GetWeaponLighting(sector_t *viewsector, const DVector
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
l.cm = fakesec->Colormap;
|
l.cm = fakesec->Colormap;
|
||||||
if (level.flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING) l.cm.ClearColor();
|
if (Level->flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING) l.cm.ClearColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
l.lightlevel = CalcLightLevel(l.lightlevel, getExtraLight(), true, 0);
|
l.lightlevel = CalcLightLevel(l.lightlevel, getExtraLight(), true, 0);
|
||||||
|
@ -289,7 +289,7 @@ WeaponLighting HWDrawInfo::GetWeaponLighting(sector_t *viewsector, const DVector
|
||||||
}
|
}
|
||||||
|
|
||||||
// Korshun: fullbright fog in opengl, render weapon sprites fullbright (but don't cancel out the light color!)
|
// Korshun: fullbright fog in opengl, render weapon sprites fullbright (but don't cancel out the light color!)
|
||||||
if (level.brightfog && ((level.flags&LEVEL_HASFADETABLE) || l.cm.FadeColor != 0))
|
if (Level->brightfog && ((Level->flags&LEVEL_HASFADETABLE) || l.cm.FadeColor != 0))
|
||||||
{
|
{
|
||||||
l.lightlevel = 255;
|
l.lightlevel = 255;
|
||||||
}
|
}
|
||||||
|
@ -530,7 +530,7 @@ void HWDrawInfo::PreparePlayerSprites(sector_t * viewsector, area_t in_area)
|
||||||
hudsprite.dynrgb[0] = hudsprite.dynrgb[1] = hudsprite.dynrgb[2] = 0;
|
hudsprite.dynrgb[0] = hudsprite.dynrgb[1] = hudsprite.dynrgb[2] = 0;
|
||||||
hudsprite.lightindex = -1;
|
hudsprite.lightindex = -1;
|
||||||
// set the lighting parameters
|
// set the lighting parameters
|
||||||
if (hudsprite.RenderStyle.BlendOp != STYLEOP_Shadow && level.HasDynamicLights && !isFullbrightScene() && gl_light_sprites)
|
if (hudsprite.RenderStyle.BlendOp != STYLEOP_Shadow && Level->HasDynamicLights && !isFullbrightScene() && gl_light_sprites)
|
||||||
{
|
{
|
||||||
if (!hudModelStep)
|
if (!hudModelStep)
|
||||||
{
|
{
|
||||||
|
|
|
@ -167,8 +167,9 @@ void CheckBench()
|
||||||
FString compose;
|
FString compose;
|
||||||
|
|
||||||
auto &vp = r_viewpoint;
|
auto &vp = r_viewpoint;
|
||||||
|
auto Level = vp.ViewLevel;
|
||||||
compose.Format("Map %s: \"%s\",\nx = %1.4f, y = %1.4f, z = %1.4f, angle = %1.4f, pitch = %1.4f\n",
|
compose.Format("Map %s: \"%s\",\nx = %1.4f, y = %1.4f, z = %1.4f, angle = %1.4f, pitch = %1.4f\n",
|
||||||
level.MapName.GetChars(), level.LevelName.GetChars(), vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw.Degrees, vp.Angles.Pitch.Degrees);
|
Level->MapName.GetChars(), Level->LevelName.GetChars(), vp.Pos.X, vp.Pos.Y, vp.Pos.Z, vp.Angles.Yaw.Degrees, vp.Angles.Pitch.Degrees);
|
||||||
|
|
||||||
AppendRenderStats(compose);
|
AppendRenderStats(compose);
|
||||||
AppendRenderTimes(compose);
|
AppendRenderTimes(compose);
|
||||||
|
|
|
@ -164,7 +164,7 @@ PalEntry HWDrawInfo::CalcLightColor(int light, PalEntry pe, int blendfactor)
|
||||||
// This is what Legacy's GL render does.
|
// This is what Legacy's GL render does.
|
||||||
// 2. black fog means no fog and always uses the distfogtable based on the level's fog density setting
|
// 2. black fog means no fog and always uses the distfogtable based on the level's fog density setting
|
||||||
// 3. If outside fog is defined and the current fog color is the same as the outside fog
|
// 3. If outside fog is defined and the current fog color is the same as the outside fog
|
||||||
// the engine always uses the outside fog density to make the fog uniform across the level.
|
// the engine always uses the outside fog density to make the fog uniform across the Level->
|
||||||
// If the outside fog's density is undefined it uses the level's fog density and if that is
|
// If the outside fog's density is undefined it uses the level's fog density and if that is
|
||||||
// not defined it uses a default of 70.
|
// not defined it uses a default of 70.
|
||||||
// 4. If a global fog density is specified it is being used for all fog on the level
|
// 4. If a global fog density is specified it is being used for all fog on the level
|
||||||
|
@ -182,7 +182,7 @@ float HWDrawInfo::GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfog
|
||||||
if (lightmode == ELightMode::DoomLegacy)
|
if (lightmode == ELightMode::DoomLegacy)
|
||||||
{
|
{
|
||||||
// uses approximations of Legacy's default settings.
|
// uses approximations of Legacy's default settings.
|
||||||
density = level.fogdensity ? (float)level.fogdensity : 18;
|
density = Level->fogdensity ? (float)Level->fogdensity : 18;
|
||||||
}
|
}
|
||||||
else if (sectorfogdensity != 0)
|
else if (sectorfogdensity != 0)
|
||||||
{
|
{
|
||||||
|
@ -192,7 +192,7 @@ float HWDrawInfo::GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfog
|
||||||
else if ((fogcolor.d & 0xffffff) == 0)
|
else if ((fogcolor.d & 0xffffff) == 0)
|
||||||
{
|
{
|
||||||
// case 2: black fog
|
// case 2: black fog
|
||||||
if ((!isSoftwareLighting() || blendfactor > 0) && !(level.flags3 & LEVEL3_NOLIGHTFADE))
|
if ((!isSoftwareLighting() || blendfactor > 0) && !(Level->flags3 & LEVEL3_NOLIGHTFADE))
|
||||||
{
|
{
|
||||||
density = distfogtable[lightmode != ELightMode::LinearStandard][hw_ClampLight(lightlevel)];
|
density = distfogtable[lightmode != ELightMode::LinearStandard][hw_ClampLight(lightlevel)];
|
||||||
}
|
}
|
||||||
|
@ -201,15 +201,15 @@ float HWDrawInfo::GetFogDensity(int lightlevel, PalEntry fogcolor, int sectorfog
|
||||||
density = 0;
|
density = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (level.outsidefogdensity != 0 && APART(level.info->outsidefog) != 0xff && (fogcolor.d & 0xffffff) == (level.info->outsidefog & 0xffffff))
|
else if (Level->outsidefogdensity != 0 && APART(Level->info->outsidefog) != 0xff && (fogcolor.d & 0xffffff) == (Level->info->outsidefog & 0xffffff))
|
||||||
{
|
{
|
||||||
// case 3. outsidefogdensity has already been set as needed
|
// case 3. outsidefogdensity has already been set as needed
|
||||||
density = (float)level.outsidefogdensity;
|
density = (float)Level->outsidefogdensity;
|
||||||
}
|
}
|
||||||
else if (level.fogdensity != 0)
|
else if (Level->fogdensity != 0)
|
||||||
{
|
{
|
||||||
// case 4: level has fog density set
|
// case 4: level has fog density set
|
||||||
density = (float)level.fogdensity;
|
density = (float)Level->fogdensity;
|
||||||
}
|
}
|
||||||
else if (lightlevel < 248)
|
else if (lightlevel < 248)
|
||||||
{
|
{
|
||||||
|
@ -249,10 +249,10 @@ bool HWDrawInfo::CheckFog(sector_t *frontsector, sector_t *backsector)
|
||||||
else if (fogcolor.a != 0)
|
else if (fogcolor.a != 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else if (level.outsidefogdensity != 0 && APART(level.info->outsidefog) != 0xff && (fogcolor.d & 0xffffff) == (level.info->outsidefog & 0xffffff))
|
else if (Level->outsidefogdensity != 0 && APART(Level->info->outsidefog) != 0xff && (fogcolor.d & 0xffffff) == (Level->info->outsidefog & 0xffffff))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else if (level.fogdensity!=0 || lightmode == ELightMode::DoomLegacy)
|
else if (Level->fogdensity!=0 || lightmode == ELightMode::DoomLegacy)
|
||||||
{
|
{
|
||||||
// case 3: level has fog density set
|
// case 3: level has fog density set
|
||||||
}
|
}
|
||||||
|
@ -267,11 +267,11 @@ bool HWDrawInfo::CheckFog(sector_t *frontsector, sector_t *backsector)
|
||||||
if ((fogcolor.d & 0xffffff) == 0)
|
if ((fogcolor.d & 0xffffff) == 0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
else if (level.outsidefogdensity != 0 && APART(level.info->outsidefog) != 0xff && (fogcolor.d & 0xffffff) == (level.info->outsidefog & 0xffffff))
|
else if (Level->outsidefogdensity != 0 && APART(Level->info->outsidefog) != 0xff && (fogcolor.d & 0xffffff) == (Level->info->outsidefog & 0xffffff))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (level.fogdensity!=0 || lightmode == ELightMode::DoomLegacy)
|
else if (Level->fogdensity!=0 || lightmode == ELightMode::DoomLegacy)
|
||||||
{
|
{
|
||||||
// case 3: level has fog density set
|
// case 3: level has fog density set
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -3276,7 +3276,7 @@ void MapLoader::LoadLevel(MapData *map, const char *lumpname, int position)
|
||||||
|
|
||||||
InitRenderInfo(); // create hardware independent renderer resources for the level. This must be done BEFORE the PolyObj Spawn!!!
|
InitRenderInfo(); // create hardware independent renderer resources for the level. This must be done BEFORE the PolyObj Spawn!!!
|
||||||
P_ClearDynamic3DFloorData(); // CreateVBO must be run on the plain 3D floor data.
|
P_ClearDynamic3DFloorData(); // CreateVBO must be run on the plain 3D floor data.
|
||||||
screen->mVertexData->CreateVBO();
|
screen->mVertexData->CreateVBO(Level->sectors);
|
||||||
|
|
||||||
for (auto &sec : Level->sectors)
|
for (auto &sec : Level->sectors)
|
||||||
{
|
{
|
||||||
|
|
|
@ -643,3 +643,32 @@ CCMD(listmapsections)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//==========================================================================
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//==========================================================================
|
||||||
|
|
||||||
|
CUSTOM_CVAR(Bool, forcewater, false, CVAR_ARCHIVE | CVAR_SERVERINFO)
|
||||||
|
{
|
||||||
|
if (gamestate == GS_LEVEL)
|
||||||
|
{
|
||||||
|
auto Level = &level;
|
||||||
|
for (auto &sec : Level->sectors)
|
||||||
|
{
|
||||||
|
sector_t *hsec = sec.GetHeightSec();
|
||||||
|
if (hsec && !(hsec->MoreFlags & SECMF_UNDERWATER))
|
||||||
|
{
|
||||||
|
if (self)
|
||||||
|
{
|
||||||
|
hsec->MoreFlags |= SECMF_FORCEDUNDERWATER;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hsec->MoreFlags &= ~SECMF_FORCEDUNDERWATER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -103,6 +103,7 @@
|
||||||
static FRandom pr_playerinspecialsector ("PlayerInSpecialSector");
|
static FRandom pr_playerinspecialsector ("PlayerInSpecialSector");
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, cl_predict_specials)
|
EXTERN_CVAR(Bool, cl_predict_specials)
|
||||||
|
EXTERN_CVAR(Bool, forcewater)
|
||||||
|
|
||||||
// [RH] Check dmflags for noexit and respond accordingly
|
// [RH] Check dmflags for noexit and respond accordingly
|
||||||
bool FLevelLocals::CheckIfExitIsGood (AActor *self, level_info_t *info)
|
bool FLevelLocals::CheckIfExitIsGood (AActor *self, level_info_t *info)
|
||||||
|
@ -680,35 +681,10 @@ void P_UpdateSpecials (FLevelLocals *Level)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// SPECIAL SPAWNING
|
// SPECIAL SPAWNING
|
||||||
//
|
//
|
||||||
|
|
||||||
CUSTOM_CVAR (Bool, forcewater, false, CVAR_ARCHIVE|CVAR_SERVERINFO)
|
|
||||||
{
|
|
||||||
if (gamestate == GS_LEVEL)
|
|
||||||
{
|
|
||||||
auto Level = &level;
|
|
||||||
for (auto &sec : Level->sectors)
|
|
||||||
{
|
|
||||||
sector_t *hsec = sec.GetHeightSec();
|
|
||||||
if (hsec && !(hsec->MoreFlags & SECMF_UNDERWATER))
|
|
||||||
{
|
|
||||||
if (self)
|
|
||||||
{
|
|
||||||
hsec->MoreFlags |= SECMF_FORCEDUNDERWATER;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hsec->MoreFlags &= ~SECMF_FORCEDUNDERWATER;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IMPLEMENT_CLASS(DLightTransfer, false, false)
|
IMPLEMENT_CLASS(DLightTransfer, false, false)
|
||||||
|
|
||||||
void DLightTransfer::Serialize(FSerializer &arc)
|
void DLightTransfer::Serialize(FSerializer &arc)
|
||||||
|
|
|
@ -1034,6 +1034,7 @@ void R_SetupFrame (FRenderViewpoint &viewpoint, FViewWindow &viewwindow, AActor
|
||||||
viewpoint.HWAngles.Pitch = RAD2DEG((float)asin(angy / alen));
|
viewpoint.HWAngles.Pitch = RAD2DEG((float)asin(angy / alen));
|
||||||
|
|
||||||
viewpoint.HWAngles.Roll.Degrees = (float)viewpoint.Angles.Roll.Degrees; // copied for convenience.
|
viewpoint.HWAngles.Roll.Degrees = (float)viewpoint.Angles.Roll.Degrees; // copied for convenience.
|
||||||
|
viewpoint.ViewLevel = &level;
|
||||||
|
|
||||||
// ViewActor only gets set, if the camera actor should not be rendered
|
// ViewActor only gets set, if the camera actor should not be rendered
|
||||||
if (actor->player && actor->player - players == consoleplayer &&
|
if (actor->player && actor->player - players == consoleplayer &&
|
||||||
|
|
|
@ -13,6 +13,8 @@ struct FViewWindow;
|
||||||
// There a 0-31, i.e. 32 LUT in the COLORMAP lump.
|
// There a 0-31, i.e. 32 LUT in the COLORMAP lump.
|
||||||
#define NUMCOLORMAPS 32
|
#define NUMCOLORMAPS 32
|
||||||
|
|
||||||
|
struct FLevelLocals;
|
||||||
|
|
||||||
struct FRenderViewpoint
|
struct FRenderViewpoint
|
||||||
{
|
{
|
||||||
FRenderViewpoint();
|
FRenderViewpoint();
|
||||||
|
@ -24,6 +26,7 @@ struct FRenderViewpoint
|
||||||
FRotator HWAngles; // Actual rotation angles for the hardware renderer
|
FRotator HWAngles; // Actual rotation angles for the hardware renderer
|
||||||
DVector2 ViewVector; // HWR only: direction the camera is facing.
|
DVector2 ViewVector; // HWR only: direction the camera is facing.
|
||||||
AActor *ViewActor; // either the same as camera or nullptr
|
AActor *ViewActor; // either the same as camera or nullptr
|
||||||
|
FLevelLocals *ViewLevel; // The level this viewpoint is on.
|
||||||
|
|
||||||
DVector3 Path[2]; // View path for portal calculations
|
DVector3 Path[2]; // View path for portal calculations
|
||||||
double Cos; // cos(Angles.Yaw)
|
double Cos; // cos(Angles.Yaw)
|
||||||
|
|
Loading…
Reference in a new issue