diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index 374464788..f10094782 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -3482,7 +3482,8 @@ void MapLoader::InitLightmap(MapData* map) if (surface.type == ST_FLOOR || surface.type == ST_CEILING) { l.Subsector = &Level->subsectors[surface.typeIndex]; - l.Subsector->firstline->sidedef->sector->HasLightmaps = true; + if(l.Subsector->firstline && l.Subsector->firstline->sidedef) + l.Subsector->firstline->sidedef->sector->HasLightmaps = true; SetSubsectorLightmap(l); } else diff --git a/src/rendering/hwrenderer/doom_levelmesh.cpp b/src/rendering/hwrenderer/doom_levelmesh.cpp index 4f8fc100b..cfbd5995d 100644 --- a/src/rendering/hwrenderer/doom_levelmesh.cpp +++ b/src/rendering/hwrenderer/doom_levelmesh.cpp @@ -457,10 +457,23 @@ void DoomLevelMesh::DumpMesh(const FString& filename) const fprintf(f, "v %f %f %f\n", v.X * scale, v.Y * scale, v.Z * scale); } + { + const auto s = LightmapUvs.Size(); + for (int i = 0; i + 1 < s; i += 2) + { + fprintf(f, "vt %f %f\n", LightmapUvs[i], LightmapUvs[i + 1]); + } + } + const auto s = MeshElements.Size(); for (auto i = 0; i + 2 < s; i += 3) { - fprintf(f, "f %d %d %d\n", MeshElements[i] + 1, MeshElements[i + 1] + 1, MeshElements[i + 2] + 1); + // fprintf(f, "f %d %d %d\n", MeshElements[i] + 1, MeshElements[i + 1] + 1, MeshElements[i + 2] + 1); + fprintf(f, "f %d/%d %d/%d %d/%d\n", + MeshElements[i + 0] + 1, MeshElements[i + 0] + 1, + MeshElements[i + 1] + 1, MeshElements[i + 1] + 1, + MeshElements[i + 2] + 1, MeshElements[i + 2] + 1); + } fclose(f); @@ -502,8 +515,8 @@ void DoomLevelMesh::FinishSurface(int lightmapTextureWidth, int lightmapTextureH auto uvIndex = surface.startUvIndex; for (int i = 0; i < (int)surface.numVerts; i++) { - auto& u = LightmapUvs[++uvIndex]; - auto& v = LightmapUvs[++uvIndex]; + auto& u = LightmapUvs[uvIndex++]; + auto& v = LightmapUvs[uvIndex++]; u = (u + x) / (float)lightmapTextureWidth; v = (v + y) / (float)lightmapTextureHeight; } @@ -601,7 +614,7 @@ void DoomLevelMesh::BuildSurfaceParams(int lightMapTextureWidth, int lightMapTex if (surface.sampleDimension <= 0) { - surface.sampleDimension = 4; + surface.sampleDimension = 16; } //surface->sampleDimension = Math::RoundPowerOfTwo(surface->sampleDimension);