Adjust HWWall to allocate vertices from renderstate

This commit is contained in:
Magnus Norddahl 2022-12-28 15:32:03 +01:00 committed by Christoph Oelckers
parent 4be3e2d53a
commit 3cae271219
5 changed files with 12 additions and 11 deletions

View file

@ -304,8 +304,8 @@ void HWDrawList::SortWallIntoPlane(HWDrawInfo* di, SortNode * head, SortNode * s
w->tcs[HWWall::UPLFT].v = ws->tcs[HWWall::LOLFT].v = w->tcs[HWWall::UPRGT].v = ws->tcs[HWWall::LORGT].v = newtexv;
w->lightuv[HWWall::UPLFT].v = ws->lightuv[HWWall::LOLFT].v = w->lightuv[HWWall::UPRGT].v = ws->lightuv[HWWall::LORGT].v = newlmv;
}
w->MakeVertices(di, false);
ws->MakeVertices(di, false);
w->MakeVertices(di, *screen->RenderState(), false);
ws->MakeVertices(di, *screen->RenderState(), false);
}
SortNode * sort2 = SortNodes.GetNew();
@ -451,8 +451,8 @@ void HWDrawList::SortWallIntoWall(HWDrawInfo *di, SortNode * head,SortNode * sor
w->zbottom[0]=ws->zbottom[1]=izb;
w->tcs[HWWall::LOLFT].u = w->tcs[HWWall::UPLFT].u = ws->tcs[HWWall::LORGT].u = ws->tcs[HWWall::UPRGT].u = iu;
w->lightuv[HWWall::LOLFT].u = w->lightuv[HWWall::UPLFT].u = ws->lightuv[HWWall::LORGT].u = ws->lightuv[HWWall::UPRGT].u = iu;
ws->MakeVertices(di, false);
w->MakeVertices(di, false);
ws->MakeVertices(di, *screen->RenderState(), false);
w->MakeVertices(di, *screen->RenderState(), false);
SortNode * sort2=SortNodes.GetNew();
memset(sort2,0,sizeof(SortNode));

View file

@ -81,7 +81,7 @@ void HWDrawInfo::AddMirrorSurface(HWWall *w)
auto tcs = newwall->tcs;
tcs[HWWall::LOLFT].u = tcs[HWWall::LORGT].u = tcs[HWWall::UPLFT].u = tcs[HWWall::UPRGT].u = v.X;
tcs[HWWall::LOLFT].v = tcs[HWWall::LORGT].v = tcs[HWWall::UPLFT].v = tcs[HWWall::UPRGT].v = v.Z;
newwall->MakeVertices(this, false);
newwall->MakeVertices(this, *screen->RenderState(), false);
bool hasDecals = newwall->seg->sidedef && newwall->seg->sidedef->AttachedDecals;
if (hasDecals && Level->HasDynamicLights && !isFullbrightScene())

View file

@ -214,7 +214,7 @@ public:
void SetupLights(HWDrawInfo *di, FDynLightData &lightdata);
void MakeVertices(HWDrawInfo *di, bool nosplit);
void MakeVertices(HWDrawInfo *di, FRenderState& state, bool nosplit);
void SkyPlane(HWDrawInfo *di, sector_t *sector, int plane, bool allowmirror);
void SkyLine(HWDrawInfo *di, sector_t *sec, line_t *line);

View file

@ -346,7 +346,7 @@ void HWWall::DrawWall(HWDrawInfo *di, FRenderState &state, bool translucent)
{
SetupLights(di, lightdata);
}
MakeVertices(di, !!(flags & HWWall::HWF_TRANSLUCENT));
MakeVertices(di, state, !!(flags & HWWall::HWF_TRANSLUCENT));
}
state.SetNormal(glseg.Normal());
@ -523,7 +523,7 @@ void HWWall::PutWall(HWDrawInfo *di, bool translucent)
{
SetupLights(di, lightdata);
}
MakeVertices(di, translucent);
MakeVertices(di, *screen->RenderState(), translucent);
}
@ -567,7 +567,7 @@ void HWWall::PutPortal(HWDrawInfo *di, int ptype, int plane)
{
HWPortal * portal = nullptr;
MakeVertices(di, false);
MakeVertices(di, *screen->RenderState(), false);
switch (ptype)
{
// portals don't go into the draw list.

View file

@ -23,6 +23,7 @@
#include "r_defs.h"
#include "flatvertices.h"
#include "hw_renderstate.h"
#include "hwrenderer/scene/hw_drawinfo.h"
#include "hwrenderer/scene/hw_drawstructs.h"
@ -282,12 +283,12 @@ int HWWall::CountVertices()
//
//==========================================================================
void HWWall::MakeVertices(HWDrawInfo *di, bool nosplit)
void HWWall::MakeVertices(HWDrawInfo *di, FRenderState& state, bool nosplit)
{
if (vertcount == 0)
{
bool split = (gl_seamless && !nosplit && seg->sidedef != nullptr && !(seg->sidedef->Flags & WALLF_POLYOBJ) && !(flags & HWF_NOSPLIT));
auto ret = screen->mVertexData->AllocVertices(split ? CountVertices() : 4);
auto ret = state.AllocVertices(split ? CountVertices() : 4);
vertindex = ret.second;
vertcount = CreateVertices(ret.first, split);
}