From aebcfe4342df75051944d60dca0dacd14a363b74 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 24 Sep 2021 17:02:40 +0200 Subject: [PATCH] Remove light cells --- src/lightmap/lightmap.cpp | 18 ++++++++++++------ src/lightmap/lightmap.h | 6 +++--- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/lightmap/lightmap.cpp b/src/lightmap/lightmap.cpp index 94511f3..81e0907 100644 --- a/src/lightmap/lightmap.cpp +++ b/src/lightmap/lightmap.cpp @@ -67,6 +67,7 @@ void LightmapBuilder::CreateLightmaps(FLevel &doomMap, int sampleDistance, int t CreateSurfaceLights(); CreateTraceTasks(); + /* SetupLightCellGrid(); SetupTaskProcessed("Tracing cells", grid.blocks.size()); @@ -75,6 +76,7 @@ void LightmapBuilder::CreateLightmaps(FLevel &doomMap, int sampleDistance, int t PrintTaskProcessed(); }); printf("Cells traced: %i \n\n", tracedTexels); + */ SetupTaskProcessed("Tracing surfaces", traceTasks.size()); Worker::RunJob(traceTasks.size(), [=](int id) { @@ -690,6 +692,7 @@ void LightmapBuilder::CreateSurfaceLights() } } +/* void LightmapBuilder::SetupLightCellGrid() { BBox worldBBox = mesh->CollisionMesh->get_bbox(); @@ -790,6 +793,7 @@ void LightmapBuilder::LightBlock(int id) block.layers = 0; } } +*/ void LightmapBuilder::AddLightmapLump(FWadWriter &wadFile) { @@ -806,17 +810,17 @@ void LightmapBuilder::AddLightmapLump(FWadWriter &wadFile) numSurfaces++; } } - int numCells = 0; - for (size_t i = 0; i < grid.blocks.size(); i++) - numCells += grid.blocks[i].cells.Size(); + //int numCells = 0; + //for (size_t i = 0; i < grid.blocks.size(); i++) + // numCells += grid.blocks[i].cells.Size(); int version = 0; int headerSize = 4 * sizeof(uint32_t) + 6 * sizeof(uint16_t); - int cellBlocksSize = grid.blocks.size() * 2 * sizeof(uint16_t); - int cellsSize = numCells * sizeof(float) * 3; + //int cellBlocksSize = grid.blocks.size() * 2 * sizeof(uint16_t); + //int cellsSize = numCells * sizeof(float) * 3; int surfacesSize = surfaces.size() * 5 * sizeof(uint32_t); int texCoordsSize = numTexCoords * 2 * sizeof(float); int texDataSize = textures.size() * textureWidth * textureHeight * 3 * 2; - int lumpSize = headerSize + cellBlocksSize + cellsSize + surfacesSize + texCoordsSize + texDataSize; + int lumpSize = headerSize + /*cellBlocksSize + cellsSize +*/ surfacesSize + texCoordsSize + texDataSize; // Setup buffer std::vector buffer(lumpSize); @@ -829,6 +833,7 @@ void LightmapBuilder::AddLightmapLump(FWadWriter &wadFile) lumpFile.Write16(textures.size()); lumpFile.Write32(numSurfaces); lumpFile.Write32(numTexCoords); + /* lumpFile.Write16(grid.x); lumpFile.Write16(grid.y); lumpFile.Write16(grid.width); @@ -853,6 +858,7 @@ void LightmapBuilder::AddLightmapLump(FWadWriter &wadFile) lumpFile.WriteFloat(cells[j].z); } } + */ // Write surfaces int coordOffsets = 0; diff --git a/src/lightmap/lightmap.h b/src/lightmap/lightmap.h index fbd5dcf..a87a275 100644 --- a/src/lightmap/lightmap.h +++ b/src/lightmap/lightmap.h @@ -102,8 +102,8 @@ private: void TraceSurface(Surface *surface, int offset); void TraceIndirectLight(Surface *surface, int offset); void FinishSurface(Surface *surface); - void SetupLightCellGrid(); - void LightBlock(int blockid); + //void SetupLightCellGrid(); + //void LightBlock(int blockid); void CreateTraceTasks(); void LightSurface(const int taskid); void LightIndirect(const int taskid); @@ -126,7 +126,7 @@ private: std::vector traceTasks; int tracedTexels = 0; - LightCellGrid grid; + //LightCellGrid grid; std::mutex mutex; int processed = 0;