mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-23 04:22:34 +00:00
DoomLevelMesh LightmapUVs are now finally correct
This commit is contained in:
parent
2bce8b86c3
commit
73030b9315
1 changed files with 27 additions and 0 deletions
|
@ -499,6 +499,33 @@ int DoomLevelMesh::SetupLightmapUvs(int lightmapSize)
|
|||
FinishSurface(lightmapSize, lightmapSize, packer, *surf);
|
||||
}
|
||||
|
||||
// You have no idea how long this took me to figure out...
|
||||
|
||||
// Reorder vertices into renderer format
|
||||
for (Surface& surface : Surfaces)
|
||||
{
|
||||
if (surface.type == ST_FLOOR)
|
||||
{
|
||||
// reverse vertices on floor
|
||||
for (int j = surface.startUvIndex + surface.numVerts * 2 - 2, k = surface.startUvIndex; j > k; j-=2, k+=2)
|
||||
{
|
||||
std::swap(LightmapUvs[k], LightmapUvs[j]);
|
||||
std::swap(LightmapUvs[k + 1], LightmapUvs[j + 1]);
|
||||
}
|
||||
}
|
||||
else if (surface.type != ST_CEILING) // walls
|
||||
{
|
||||
// from 0 1 2 3
|
||||
// to 0 2 1 3
|
||||
std::swap(LightmapUvs[surface.startUvIndex + 2 * 1], LightmapUvs[surface.startUvIndex + 2 * 2]);
|
||||
std::swap(LightmapUvs[surface.startUvIndex + 2 * 2], LightmapUvs[surface.startUvIndex + 2 * 3]);
|
||||
|
||||
std::swap(LightmapUvs[surface.startUvIndex + 2 * 1 + 1], LightmapUvs[surface.startUvIndex + 2 * 2 + 1]);
|
||||
std::swap(LightmapUvs[surface.startUvIndex + 2 * 2 + 1], LightmapUvs[surface.startUvIndex + 2 * 3 + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return packer.getNumPages();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue