Fix null pointer crash for translucent flats with no texture

This commit is contained in:
Magnus Norddahl 2024-03-09 13:28:50 +01:00
commit 192cdcd9cb
2 changed files with 7 additions and 7 deletions

View file

@ -405,16 +405,16 @@ void DoomLevelMesh::UpdateFlat(FLevelLocals& doomMap, unsigned int sectorIndex)
state.ClearDepthBias();
state.EnableTexture(true);
state.EnableBrightmap(true);
CreateFlatSurface(disp, state, result.list);
CreateFlatSurface(disp, state, result.list, false, false);
CreateFlatSurface(disp, state, result.portals, true);
CreateFlatSurface(disp, state, result.portals, true, false);
// final pass: translucent stuff
state.AlphaFunc(Alpha_GEqual, gl_mask_sprite_threshold);
state.SetRenderStyle(STYLE_Translucent);
CreateFlatSurface(disp, state, result.translucentborder);
CreateFlatSurface(disp, state, result.translucentborder, false, true);
state.SetDepthMask(false);
CreateFlatSurface(disp, state, result.translucent);
CreateFlatSurface(disp, state, result.translucent, false, true);
state.AlphaFunc(Alpha_GEqual, 0.f);
state.SetDepthMask(true);
state.SetRenderStyle(STYLE_Normal);
@ -594,7 +594,7 @@ int DoomLevelMesh::GetSampleDimension(const DoomLevelMeshSurface& surf, uint16_t
return sampleDimension;
}
void DoomLevelMesh::CreateFlatSurface(HWFlatDispatcher& disp, MeshBuilder& state, TArray<HWFlat>& list, bool isSky)
void DoomLevelMesh::CreateFlatSurface(HWFlatDispatcher& disp, MeshBuilder& state, TArray<HWFlat>& list, bool isSky, bool translucent)
{
for (HWFlat& flatpart : list)
{
@ -620,7 +620,7 @@ void DoomLevelMesh::CreateFlatSurface(HWFlatDispatcher& disp, MeshBuilder& state
state.AlphaFunc(Alpha_GEqual, 0.f);
}
flatpart.DrawFlat(&disp, state, false);
flatpart.DrawFlat(&disp, state, translucent);
}
VSMatrix textureMatrix;

View file

@ -78,7 +78,7 @@ private:
void SortIndexes();
void CreateWallSurface(side_t* side, HWWallDispatcher& disp, MeshBuilder& state, TArray<HWWall>& list, bool isPortal, bool translucent);
void CreateFlatSurface(HWFlatDispatcher& disp, MeshBuilder& state, TArray<HWFlat>& list, bool isSky = false);
void CreateFlatSurface(HWFlatDispatcher& disp, MeshBuilder& state, TArray<HWFlat>& list, bool isSky, bool translucent);
void LinkSurfaces(FLevelLocals& doomMap);