mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-25 21:41:03 +00:00
Somehow fix lightmaps being corrupted in debug build
This commit is contained in:
parent
f9580f081e
commit
9b3a3c6115
5 changed files with 47 additions and 48 deletions
|
@ -54,7 +54,6 @@ void VkLightmap::Raytrace(LevelMesh* level, const TArray<LevelMeshSurface*>& sur
|
||||||
{
|
{
|
||||||
bool newLevel = (mesh != level);
|
bool newLevel = (mesh != level);
|
||||||
mesh = level;
|
mesh = level;
|
||||||
|
|
||||||
if (newLevel)
|
if (newLevel)
|
||||||
{
|
{
|
||||||
UpdateAccelStructDescriptors();
|
UpdateAccelStructDescriptors();
|
||||||
|
@ -63,6 +62,8 @@ void VkLightmap::Raytrace(LevelMesh* level, const TArray<LevelMeshSurface*>& sur
|
||||||
lightmapRaytraceLast.Reset();
|
lightmapRaytraceLast.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (surfaces.Size())
|
||||||
|
{
|
||||||
lightmapRaytrace.active = true;
|
lightmapRaytrace.active = true;
|
||||||
lightmapRaytraceLast.active = true;
|
lightmapRaytraceLast.active = true;
|
||||||
|
|
||||||
|
@ -119,6 +120,7 @@ void VkLightmap::Raytrace(LevelMesh* level, const TArray<LevelMeshSurface*>& sur
|
||||||
|
|
||||||
lightmapRaytrace.Unclock();
|
lightmapRaytrace.Unclock();
|
||||||
lightmapRaytraceLast.Unclock();
|
lightmapRaytraceLast.Unclock();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VkLightmap::RenderAtlasImage(size_t pageIndex, const TArray<LevelMeshSurface*>& surfaces)
|
void VkLightmap::RenderAtlasImage(size_t pageIndex, const TArray<LevelMeshSurface*>& surfaces)
|
||||||
|
@ -272,7 +274,7 @@ void VkLightmap::CreateAtlasImages(const TArray<LevelMeshSurface*>& surfaces)
|
||||||
LevelMeshSurface* surface = surfaces[i];
|
LevelMeshSurface* surface = surfaces[i];
|
||||||
//for (int i = 0, count = mesh->GetSurfaceCount(); i < count; i++)
|
//for (int i = 0, count = mesh->GetSurfaceCount(); i < count; i++)
|
||||||
//{
|
//{
|
||||||
//LevelMeshSurface* surface = mesh->GetSurface(i);
|
// LevelMeshSurface* surface = mesh->GetSurface(i);
|
||||||
|
|
||||||
auto result = packer.insert(surface->texWidth + 2, surface->texHeight + 2);
|
auto result = packer.insert(surface->texWidth + 2, surface->texHeight + 2);
|
||||||
surface->lightmapperAtlasX = result.pos.x + 1;
|
surface->lightmapperAtlasX = result.pos.x + 1;
|
||||||
|
|
|
@ -369,8 +369,6 @@ void DoomLevelMesh::BindLightmapSurfacesToGeometry(FLevelLocals& doomMap)
|
||||||
{
|
{
|
||||||
surface.TexCoords = (float*)&LightmapUvs[surface.startUvIndex];
|
surface.TexCoords = (float*)&LightmapUvs[surface.startUvIndex];
|
||||||
|
|
||||||
surface.LightmapNum = surface.atlasPageIndex;
|
|
||||||
|
|
||||||
if (surface.Type == ST_FLOOR || surface.Type == ST_CEILING)
|
if (surface.Type == ST_FLOOR || surface.Type == ST_CEILING)
|
||||||
{
|
{
|
||||||
surface.Subsector = &doomMap.subsectors[surface.typeIndex];
|
surface.Subsector = &doomMap.subsectors[surface.typeIndex];
|
||||||
|
|
|
@ -16,10 +16,9 @@ struct FLevelLocals;
|
||||||
|
|
||||||
struct DoomLevelMeshSurface : public LevelMeshSurface
|
struct DoomLevelMeshSurface : public LevelMeshSurface
|
||||||
{
|
{
|
||||||
subsector_t* Subsector;
|
subsector_t* Subsector = nullptr;
|
||||||
side_t* Side;
|
side_t* Side = nullptr;
|
||||||
sector_t* ControlSector;
|
sector_t* ControlSector = nullptr;
|
||||||
uint32_t LightmapNum; // To do: same as atlasPageIndex. Delete one of them!
|
|
||||||
float* TexCoords;
|
float* TexCoords;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,7 @@ static int CreateIndexedSectorVerticesLM(FRenderState& renderstate, sector_t* se
|
||||||
if (lightmap && lightmap->Type != ST_UNKNOWN) // lightmap may be missing if the subsector is degenerate triangle
|
if (lightmap && lightmap->Type != ST_UNKNOWN) // lightmap may be missing if the subsector is degenerate triangle
|
||||||
{
|
{
|
||||||
float* luvs = lightmap->TexCoords;
|
float* luvs = lightmap->TexCoords;
|
||||||
int lindex = lightmap->LightmapNum;
|
int lindex = lightmap->atlasPageIndex;
|
||||||
for (unsigned int j = 0; j < sub->numlines; j++)
|
for (unsigned int j = 0; j < sub->numlines; j++)
|
||||||
{
|
{
|
||||||
SetFlatVertex(vbo_shadowdata[vi + pos], sub->firstline[j].v1, plane, luvs[j * 2], luvs[j * 2 + 1], lindex);
|
SetFlatVertex(vbo_shadowdata[vi + pos], sub->firstline[j].v1, plane, luvs[j * 2], luvs[j * 2 + 1], lindex);
|
||||||
|
|
|
@ -1019,7 +1019,7 @@ bool HWWall::SetWallCoordinates(seg_t * seg, FTexCoordInfo *tci, float textureto
|
||||||
if (lightmap && lightmap->Type != ST_UNKNOWN)
|
if (lightmap && lightmap->Type != ST_UNKNOWN)
|
||||||
{
|
{
|
||||||
srclightuv = (texcoord*)lightmap->TexCoords;
|
srclightuv = (texcoord*)lightmap->TexCoords;
|
||||||
lindex = (float)lightmap->LightmapNum;
|
lindex = (float)lightmap->atlasPageIndex;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1725,7 +1725,7 @@ void HWWall::BuildFFBlock(HWDrawInfo *di, FRenderState& state, seg_t * seg, F3DF
|
||||||
if (lightmap && lightmap->Type != ST_UNKNOWN)
|
if (lightmap && lightmap->Type != ST_UNKNOWN)
|
||||||
{
|
{
|
||||||
srclightuv = (texcoord*)lightmap->TexCoords;
|
srclightuv = (texcoord*)lightmap->TexCoords;
|
||||||
lindex = (float)lightmap->LightmapNum;
|
lindex = (float)lightmap->atlasPageIndex;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue