From e09ac00121f3495f22b656be3dd2562c4e95c297 Mon Sep 17 00:00:00 2001 From: RaveYard <29225776+MrRaveYard@users.noreply.github.com> Date: Thu, 31 Aug 2023 10:13:42 +0200 Subject: [PATCH] Minor cleanup --- src/maploader/maploader.cpp | 22 +-------------------- src/rendering/hwrenderer/doom_levelmesh.cpp | 17 ++++++---------- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index 7cc432bdc3..3da89759e2 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -3341,21 +3341,6 @@ void MapLoader::InitLightmap(MapData* map) Level->LMTextureCount = 1; Level->LMTextureSize = 1024; - for (int i = 0; i < 1024; ++i) // avoid crashing lol - { - Level->LMTexCoords.Push(0); - Level->LMTexCoords.Push(0); - - Level->LMTexCoords.Push(1); - Level->LMTexCoords.Push(0); - - Level->LMTexCoords.Push(1); - Level->LMTexCoords.Push(1); - - Level->LMTexCoords.Push(0); - Level->LMTexCoords.Push(1); - } - auto constructDebugTexture = [&](TArray& buffer, int width, int height) { uint16_t* ptr = buffer.Data(); @@ -3421,15 +3406,13 @@ void MapLoader::InitLightmap(MapData* map) for (auto& surface : Level->levelMesh->Surfaces) { LightmapSurface l; - //LightmapSurface& l = Level->LMSurfaces[index++]; memset(&l, 0, sizeof(LightmapSurface)); l.ControlSector = surface.controlSector; l.Type = surface.type; l.LightmapNum = 0; - //l.TexCoords = &Level->LMTexCoords[0]; - //l.TexCoords = &Level->levelMesh->LightmapUvs[surface.startUvIndex]; + l.TexCoords = &Level->LMTexCoords[surface.startUvIndex]; if (surface.type == ST_FLOOR || surface.type == ST_CEILING) @@ -3443,9 +3426,6 @@ void MapLoader::InitLightmap(MapData* map) l.Side = &Level->sides[surface.typeIndex]; SetSideLightmap(l); } - - //Level->LMSurfaces.Push(l); - } Printf("Generated custom lightmap data"); diff --git a/src/rendering/hwrenderer/doom_levelmesh.cpp b/src/rendering/hwrenderer/doom_levelmesh.cpp index 695ae34507..076bcaf9a4 100644 --- a/src/rendering/hwrenderer/doom_levelmesh.cpp +++ b/src/rendering/hwrenderer/doom_levelmesh.cpp @@ -469,8 +469,6 @@ void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTex secplane_t* plane; BBox bounds; FVector3 roundedSize; - int i; - PlaneAxis axis; FVector3 tOrigin; int width; int height; @@ -482,15 +480,12 @@ void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTex if (surface.sampleDimension <= 0) { - surface.sampleDimension = 1; // TODO change? + surface.sampleDimension = 4; } - - surface.sampleDimension = 1; //surface->sampleDimension = Math::RoundPowerOfTwo(surface->sampleDimension); - // round off dimensions - for (i = 0; i < 3; i++) + for (int i = 0; i < 3; i++) { bounds.min[i] = surface.sampleDimension * (floor(bounds.min[i] / surface.sampleDimension) - 1); bounds.max[i] = surface.sampleDimension * (ceil(bounds.max[i] / surface.sampleDimension) + 1); @@ -500,7 +495,7 @@ void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTex FVector3 tCoords[2] = { FVector3(0.0f, 0.0f, 0.0f), FVector3(0.0f, 0.0f, 0.0f) }; - axis = BestAxis(*plane); + PlaneAxis axis = BestAxis(*plane); switch (axis) { @@ -546,7 +541,7 @@ void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTex surface.startUvIndex = AllocUvs(surface.numVerts); auto uv = surface.startUvIndex; - for (i = 0; i < surface.numVerts; i++) + for (int i = 0; i < surface.numVerts; i++) { FVector3 tDelta = MeshVertices[surface.startVertIndex + i] - surface.translateWorldToLocal; @@ -561,7 +556,7 @@ void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTex d = float(((bounds.min | FVector3(plane->Normal())) - plane->D) / plane->Normal()[axis]); //d = (plane->PointToDist(bounds.min)) / plane->Normal()[axis]; tOrigin[axis] -= d; - for (i = 0; i < 2; i++) + for (int i = 0; i < 2; i++) { tCoords[i].MakeUnit(); d = (tCoords[i] | FVector3(plane->Normal())) / plane->Normal()[axis]; //d = dot(tCoords[i], plane->Normal()) / plane->Normal()[axis]; @@ -574,4 +569,4 @@ void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTex surface.worldOrigin = tOrigin; surface.worldStepX = tCoords[0] * (float)surface.sampleDimension; surface.worldStepY = tCoords[1] * (float)surface.sampleDimension; -} \ No newline at end of file +}