From 79d0b257e1f29fd3408839692015e57ad2d88c74 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Mon, 31 Dec 2018 16:53:16 +0100 Subject: [PATCH] - remove some old broken debug code --- src/lightmap/lightmap.cpp | 38 -------------------- src/lightmap/surfaces.cpp | 75 --------------------------------------- src/lightmap/surfaces.h | 2 -- 3 files changed, 115 deletions(-) diff --git a/src/lightmap/lightmap.cpp b/src/lightmap/lightmap.cpp index bf98a6d..b46e725 100644 --- a/src/lightmap/lightmap.cpp +++ b/src/lightmap/lightmap.cpp @@ -1028,46 +1028,8 @@ void LightmapBuilder::AddLightmapLump(FWadWriter &wadFile) } } -#if 0 - // Apply compression predictor - uint8_t *texBytes = lumpFile.BufferAt() - texDataSize; - for (int i = texDataSize - 1; i > 0; i--) - { - texBytes[i] -= texBytes[i - 1]; - } -#endif - // Compress and store in lump ZLibOut zout(wadFile); wadFile.StartWritingLump("LIGHTMAP"); zout.Write(buffer.data(), lumpFile.BufferAt() - lumpFile.Buffer()); } - -/* -void LightmapBuilder::WriteTexturesToTGA() -{ - BinFile file; - - for (unsigned int i = 0; i < textures.size(); i++) - { - file.Create(Va("lightmap_%02d.tga", i)); - file.Write16(0); - file.Write16(2); - file.Write16(0); - file.Write16(0); - file.Write16(0); - file.Write16(0); - file.Write16(textureWidth); - file.Write16(textureHeight); - file.Write16(24); - - for (int j = 0; j < (textureWidth * textureHeight) * 3; j += 3) - { - file.Write8(textures[i][j + 2]); - file.Write8(textures[i][j + 1]); - file.Write8(textures[i][j + 0]); - } - file.Close(); - } -} -*/ diff --git a/src/lightmap/surfaces.cpp b/src/lightmap/surfaces.cpp index c18c249..be2ace8 100644 --- a/src/lightmap/surfaces.cpp +++ b/src/lightmap/surfaces.cpp @@ -422,78 +422,3 @@ bool LevelMesh::IsDegenerate(const Vec3 &v0, const Vec3 &v1, const Vec3 &v2) float crosslengthsqr = crossx * crossx + crossy * crossy + crossz * crossz; return crosslengthsqr <= 1.e-6f; } - -void LevelMesh::WriteMeshToOBJ() -{ - FILE *f = fopen("mesh.obj", "w"); - - std::map> sortedSurfs; - - for (unsigned int i = 0; i < surfaces.size(); i++) - sortedSurfs[surfaces[i]->lightmapNum].push_back(surfaces[i].get()); - - for (const auto &it : sortedSurfs) - { - for (const auto &s : it.second) - { - for (int j = 0; j < s->numVerts; j++) - { - fprintf(f, "v %f %f %f\n", s->verts[j].x, s->verts[j].z + 100.0f, s->verts[j].y); - } - } - } - - for (const auto &it : sortedSurfs) - { - for (const auto &s : it.second) - { - for (int j = 0; j < s->numVerts; j++) - { - fprintf(f, "vt %f %f\n", s->lightmapCoords[j * 2], s->lightmapCoords[j * 2 + 1]); - } - } - } - - int voffset = 1; - for (const auto &it : sortedSurfs) - { - int lightmapNum = it.first; - - if (lightmapNum != -1) - fprintf(f, "usemtl lightmap_%02d\n", lightmapNum); - else - fprintf(f, "usemtl black\n"); - - for (const auto &s : it.second) - { - switch (s->type) - { - case ST_FLOOR: - for (int j = 2; j < s->numVerts; j++) - { - fprintf(f, "f %d/%d %d/%d %d/%d\n", voffset + j, voffset + j, voffset + j - 1, voffset + j - 1, voffset, voffset); - } - break; - case ST_CEILING: - for (int j = 2; j < s->numVerts; j++) - { - fprintf(f, "f %d/%d %d/%d %d/%d\n", voffset, voffset, voffset + j - 1, voffset + j - 1, voffset + j, voffset + j); - } - break; - default: - for (int j = 2; j < s->numVerts; j++) - { - if (j % 2 == 0) - fprintf(f, "f %d/%d %d/%d %d/%d\n", voffset + j - 2, voffset + j - 2, voffset + j - 1, voffset + j - 1, voffset + j, voffset + j); - else - fprintf(f, "f %d/%d %d/%d %d/%d\n", voffset + j, voffset + j, voffset + j - 1, voffset + j - 1, voffset + j - 2, voffset + j - 2); - } - break; - } - - voffset += s->numVerts; - } - } - - fclose(f); -} diff --git a/src/lightmap/surfaces.h b/src/lightmap/surfaces.h index 5e46098..51578f6 100644 --- a/src/lightmap/surfaces.h +++ b/src/lightmap/surfaces.h @@ -88,8 +88,6 @@ public: LevelTraceHit Trace(const Vec3 &startVec, const Vec3 &endVec); bool TraceAnyHit(const Vec3 &startVec, const Vec3 &endVec); - void WriteMeshToOBJ(); - std::vector> surfaces; TArray MeshVertices;