mirror of
https://github.com/ZDoom/gzdoom.git
synced 2025-02-17 01:31:25 +00:00
Fix bad UV indices in FinishSurface and export UVs in dumplevelmesh
This commit is contained in:
parent
73b968d79a
commit
2bce8b86c3
2 changed files with 19 additions and 5 deletions
|
@ -3477,7 +3477,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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue