From 7a9596ae81dd55585dbe951145dc0f42b5460971 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 15 Dec 2021 12:23:50 +0100 Subject: [PATCH] - use SectionGeometry for 3D rendering. --- .../core/rendering/scene/hw_bunchdrawer.cpp | 2 +- source/core/rendering/scene/hw_drawstructs.h | 5 +- source/core/rendering/scene/hw_flats.cpp | 58 ++++++------------- 3 files changed, 22 insertions(+), 43 deletions(-) diff --git a/source/core/rendering/scene/hw_bunchdrawer.cpp b/source/core/rendering/scene/hw_bunchdrawer.cpp index 443d809cd..316045075 100644 --- a/source/core/rendering/scene/hw_bunchdrawer.cpp +++ b/source/core/rendering/scene/hw_bunchdrawer.cpp @@ -597,7 +597,7 @@ void BunchDrawer::ProcessSection(int sectionnum, bool portal) SetupFlat.Clock(); HWFlat flat; - flat.ProcessSector(di, §or[sectnum], nullptr, sectionnum); + flat.ProcessSector(di, §or[sectnum], sectionnum); SetupFlat.Unclock(); //Todo: process subsectors diff --git a/source/core/rendering/scene/hw_drawstructs.h b/source/core/rendering/scene/hw_drawstructs.h index 299b0f8ad..d492ef312 100644 --- a/source/core/rendering/scene/hw_drawstructs.h +++ b/source/core/rendering/scene/hw_drawstructs.h @@ -253,8 +253,7 @@ public: class HWFlat { public: - int oldsection; - Section* section; + int section; sectortype * sec; tspritetype* Sprite; // for flat sprites. FGameTexture *texture; @@ -281,7 +280,7 @@ public: //void SetupLights(HWDrawInfo *di, FLightNode *head, FDynLightData &lightdata, int portalgroup); void PutFlat(HWDrawInfo* di, int whichplane); - void ProcessSector(HWDrawInfo *di, sectortype * frontsector, Section* sectionp, int sectionnum, int which = 7 /*SSRF_RENDERALL*/); // cannot use constant due to circular dependencies. + void ProcessSector(HWDrawInfo *di, sectortype * frontsector, int sectionnum, int which = 7 /*SSRF_RENDERALL*/); // cannot use constant due to circular dependencies. void ProcessFlatSprite(HWDrawInfo* di, tspritetype* sprite, sectortype* sector); void DrawSubsectors(HWDrawInfo *di, FRenderState &state); diff --git a/source/core/rendering/scene/hw_flats.cpp b/source/core/rendering/scene/hw_flats.cpp index 0778148f1..050030345 100644 --- a/source/core/rendering/scene/hw_flats.cpp +++ b/source/core/rendering/scene/hw_flats.cpp @@ -36,6 +36,7 @@ #include "hw_drawstructs.h" #include "hw_renderstate.h" #include "sectorgeometry.h" +#include "hw_sections2.h" #ifdef _DEBUG CVAR(Int, gl_breaksec, -1, 0) @@ -98,44 +99,23 @@ void HWFlat::MakeVertices() bool canvas = texture->isHardwareCanvas(); if (Sprite == nullptr) { - if (section != nullptr) - { - TArray* pIndices; - auto mesh = sectionGeometry.get(section, plane, geoofs, &pIndices); + TArray* pIndices; + auto mesh = sectionGeometry.get(sections2[section], plane, geoofs, &pIndices); - auto ret = screen->mVertexData->AllocVertices(pIndices->Size()); - auto vp = ret.first; - float base = (plane == 0 ? sec->floorz : sec->ceilingz) * (1 / -256.f); - for (unsigned i = 0; i < pIndices->Size(); i++) - { - auto ii = (*pIndices)[i]; - auto& pt = mesh->vertices[ii]; - auto& uv = mesh->texcoords[ii]; - vp->SetVertex(pt.X, base + pt.Z, pt.Y); - vp->SetTexCoord(uv.X, canvas ? 1.f - uv.Y : uv.Y); - vp++; - } - vertindex = ret.second; - vertcount = pIndices->Size(); - } - else + auto ret = screen->mVertexData->AllocVertices(pIndices->Size()); + auto vp = ret.first; + float base = (plane == 0 ? sec->floorz : sec->ceilingz) * (1 / -256.f); + for (unsigned i = 0; i < pIndices->Size(); i++) { - auto mesh = sectorGeometry.get(oldsection, plane, geoofs); - if (!mesh) return; - auto ret = screen->mVertexData->AllocVertices(mesh->vertices.Size()); - auto vp = ret.first; - float base = (plane == 0 ? sec->floorz : sec->ceilingz) * (1 / -256.f); - for (unsigned i = 0; i < mesh->vertices.Size(); i++) - { - auto& pt = mesh->vertices[i]; - auto& uv = mesh->texcoords[i]; - vp->SetVertex(pt.X, base + pt.Z, pt.Y); - vp->SetTexCoord(uv.X, canvas ? 1.f - uv.Y : uv.Y); - vp++; - } - vertindex = ret.second; - vertcount = mesh->vertices.Size(); + auto ii = (*pIndices)[i]; + auto& pt = mesh->vertices[ii]; + auto& uv = mesh->texcoords[ii]; + vp->SetVertex(pt.X, base + pt.Z, pt.Y); + vp->SetTexCoord(uv.X, canvas ? 1.f - uv.Y : uv.Y); + vp++; } + vertindex = ret.second; + vertcount = pIndices->Size(); } else { @@ -181,7 +161,8 @@ void HWFlat::DrawFlat(HWDrawInfo *di, FRenderState &state, bool translucent) if (!Sprite) { - auto mesh = sectorGeometry.get(oldsection, plane, geoofs); + TArray *indices; + auto mesh = sectionGeometry.get(sections2[section], plane, geoofs, &indices); state.SetNormal(mesh->normal); } else @@ -261,7 +242,7 @@ void HWFlat::PutFlat(HWDrawInfo *di, int whichplane) // //========================================================================== -void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, Section* sectionp, int section_, int which) +void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, int section_, int which) { #ifdef _DEBUG if (sectnum(sec) == gl_breaksec) @@ -279,8 +260,7 @@ void HWFlat::ProcessSector(HWDrawInfo *di, sectortype * frontsector, Section* se visibility = sectorVisibility(frontsector); sec = frontsector; - oldsection = section_; - section = sectionp; + section = section_; Sprite = nullptr; geoofs = di->geoofs;