Add sunlight trace

This commit is contained in:
Magnus Norddahl 2023-04-06 16:13:03 +02:00
commit 34d2b2e440
5 changed files with 51 additions and 13 deletions

View file

@ -3347,7 +3347,12 @@ void MapLoader::LoadLightmap(MapData *map)
return;
int version = fr.ReadInt32();
if (version != 0)
if (version == 0)
{
Printf(PRINT_HIGH, "LoadLightmap: This is an old unsupported alpha version of the lightmap lump. Please rebuild the map with a newer version of zdray.\n");
return;
}
if (version != 1)
{
Printf(PRINT_HIGH, "LoadLightmap: unsupported lightmap lump version\n");
return;
@ -3357,26 +3362,22 @@ void MapLoader::LoadLightmap(MapData *map)
uint16_t numTextures = fr.ReadUInt16();
uint32_t numSurfaces = fr.ReadUInt32();
uint32_t numTexCoords = fr.ReadUInt32();
uint32_t numLightProbes = fr.ReadUInt32();
uint32_t numSubsectors = fr.ReadUInt32();
uint32_t numTexBytes = numTextures * textureSize * textureSize * 3 * 2;
if (numSurfaces == 0 || numTexCoords == 0 || numTexBytes == 0)
return;
Printf(PRINT_HIGH, "WARNING! Lightmaps are an experimental feature and are subject to change before being finalized. Do not expect this to work as-is in future releases of %s!\n", GAMENAME);
float sunDir[3], sunColor[3];
fr.Read(sunDir, sizeof(float) * 3);
fr.Read(sunColor, sizeof(float) * 3);
Level->SunDirection = FVector3(sunDir);
Level->SunColor = FVector3(sunColor);
/*if (numSubsectors != Level->subsectors.Size())
{
Printf(PRINT_HIGH, "LoadLightmap: subsector count for level doesn't match (%d in wad vs %d in engine)\n", (int)numSubsectors, (int)Level->subsectors.Size());
}*/
if (numLightProbes > 0)
{
Printf(PRINT_HIGH, "LoadLightmap: This is an old unsupported alpha version of the lightmap lump. Please rebuild the map with a newer version of zdray.\n");
return;
}
Level->LMTexCoords.Resize(numTexCoords * 2);
// Allocate room for all surfaces