From 7efc998f6eda20672c907896c3ed89f56256cdb0 Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Fri, 2 Nov 2018 22:57:03 +0100 Subject: [PATCH] - remove unused stuff --- CMakeLists.txt | 2 - src/level/level.cpp | 2 +- src/lightmap/lightmap.cpp | 51 ------ src/lightmap/mapdata.cpp | 1 - src/lightmap/surfaces.cpp | 14 +- src/lightmap/surfaces.h | 4 +- src/lightmap/wad.cpp | 326 -------------------------------------- src/lightmap/wad.h | 161 ------------------- 8 files changed, 9 insertions(+), 552 deletions(-) delete mode 100644 src/lightmap/wad.cpp delete mode 100644 src/lightmap/wad.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e9a7f00..48ac10c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -149,7 +149,6 @@ set( SOURCES src/lightmap/mapdata.cpp src/lightmap/surfaces.cpp src/lightmap/trace.cpp - src/lightmap/wad.cpp src/lightmap/worker.cpp src/lightmap/collision.cpp src/lightmap/halffloat.cpp @@ -192,7 +191,6 @@ set( HEADERS src/lightmap/mapdata.h src/lightmap/surfaces.h src/lightmap/trace.h - src/lightmap/wad.h src/lightmap/worker.h src/lightmap/collision.h src/lightmap/halffloat.h diff --git a/src/level/level.cpp b/src/level/level.cpp index 67d3191..a7e1cc1 100644 --- a/src/level/level.cpp +++ b/src/level/level.cpp @@ -617,7 +617,7 @@ void FProcessor::BuildLightmaps() LMBuilder.textureHeight = LMDims; Level.SetupDlight(); - Surface_AllocateFromMap(Level); + CreateSurfaces(Level); Level.CreateLights(); LMBuilder.CreateLightmaps(Level); diff --git a/src/lightmap/lightmap.cpp b/src/lightmap/lightmap.cpp index ab45b01..180343f 100644 --- a/src/lightmap/lightmap.cpp +++ b/src/lightmap/lightmap.cpp @@ -37,7 +37,6 @@ #include "lightmap.h" #include "worker.h" #include "kexlib/binfile.h" -#include "wad.h" #include "framework/templates.h" #include "halffloat.h" #include @@ -855,53 +854,3 @@ void kexLightmapBuilder::WriteMeshToOBJ() fclose(f); } - -// -// kexLightmapBuilder::ExportTexelsToObjFile -// - -void kexLightmapBuilder::ExportTexelsToObjFile(FILE *f, const kexVec3 &org, int indices) -{ -#define BLOCK(idx, offs) (org[idx] + offs)/256.0f - fprintf(f, "o texel_%03d\n", indices); - fprintf(f, "v %f %f %f\n", -BLOCK(1, -6), BLOCK(2, -6), -BLOCK(0, 6)); - fprintf(f, "v %f %f %f\n", -BLOCK(1, -6), BLOCK(2, 6), -BLOCK(0, 6)); - fprintf(f, "v %f %f %f\n", -BLOCK(1, -6), BLOCK(2, 6), -BLOCK(0, -6)); - fprintf(f, "v %f %f %f\n", -BLOCK(1, -6), BLOCK(2, -6), -BLOCK(0, -6)); - fprintf(f, "v %f %f %f\n", -BLOCK(1, 6), BLOCK(2, -6), -BLOCK(0, 6)); - fprintf(f, "v %f %f %f\n", -BLOCK(1, 6), BLOCK(2, 6), -BLOCK(0, 6)); - fprintf(f, "v %f %f %f\n", -BLOCK(1, 6), BLOCK(2, 6), -BLOCK(0, -6)); - fprintf(f, "v %f %f %f\n", -BLOCK(1, 6), BLOCK(2, -6), -BLOCK(0, -6)); - fprintf(f, "f %i %i %i %i\n", indices+1, indices+2, indices+3, indices+4); - fprintf(f, "f %i %i %i %i\n", indices+5, indices+8, indices+7, indices+6); - fprintf(f, "f %i %i %i %i\n", indices+1, indices+5, indices+6, indices+2); - fprintf(f, "f %i %i %i %i\n", indices+2, indices+6, indices+7, indices+3); - fprintf(f, "f %i %i %i %i\n", indices+3, indices+7, indices+8, indices+4); - fprintf(f, "f %i %i %i %i\n\n", indices+5, indices+1, indices+4, indices+8); -#undef BLOCK -} - -// -// kexLightmapBuilder::WriteBlock -// - -void kexLightmapBuilder::WriteBlock(FILE *f, const int i, const kexVec3 &org, int indices, kexBBox &box) -{ -#define BLOCK(idx, offs) (org[idx] + box[offs][idx])/256.0f - fprintf(f, "o texel_%03d\n", i); - fprintf(f, "v %f %f %f\n", -BLOCK(1, 0), BLOCK(2, 0), -BLOCK(0, 1)); - fprintf(f, "v %f %f %f\n", -BLOCK(1, 0), BLOCK(2, 1), -BLOCK(0, 1)); - fprintf(f, "v %f %f %f\n", -BLOCK(1, 0), BLOCK(2, 1), -BLOCK(0, 0)); - fprintf(f, "v %f %f %f\n", -BLOCK(1, 0), BLOCK(2, 0), -BLOCK(0, 0)); - fprintf(f, "v %f %f %f\n", -BLOCK(1, 1), BLOCK(2, 0), -BLOCK(0, 1)); - fprintf(f, "v %f %f %f\n", -BLOCK(1, 1), BLOCK(2, 1), -BLOCK(0, 1)); - fprintf(f, "v %f %f %f\n", -BLOCK(1, 1), BLOCK(2, 1), -BLOCK(0, 0)); - fprintf(f, "v %f %f %f\n", -BLOCK(1, 1), BLOCK(2, 0), -BLOCK(0, 0)); - fprintf(f, "f %i %i %i %i\n", indices+1, indices+2, indices+3, indices+4); - fprintf(f, "f %i %i %i %i\n", indices+5, indices+8, indices+7, indices+6); - fprintf(f, "f %i %i %i %i\n", indices+1, indices+5, indices+6, indices+2); - fprintf(f, "f %i %i %i %i\n", indices+2, indices+6, indices+7, indices+3); - fprintf(f, "f %i %i %i %i\n", indices+3, indices+7, indices+8, indices+4); - fprintf(f, "f %i %i %i %i\n\n", indices+5, indices+1, indices+4, indices+8); -#undef BLOCK -} diff --git a/src/lightmap/mapdata.cpp b/src/lightmap/mapdata.cpp index b4912c2..c53b29c 100644 --- a/src/lightmap/mapdata.cpp +++ b/src/lightmap/mapdata.cpp @@ -31,7 +31,6 @@ //----------------------------------------------------------------------------- #include "common.h" -#include "wad.h" #include "mapdata.h" #include "lightsurface.h" diff --git a/src/lightmap/surfaces.cpp b/src/lightmap/surfaces.cpp index 79ae109..8be9586 100644 --- a/src/lightmap/surfaces.cpp +++ b/src/lightmap/surfaces.cpp @@ -36,7 +36,7 @@ kexArray surfaces; -static void Surface_AllocateFromSide(FLevel &doomMap, IntSideDef *side) +static void CreateSideSurfaces(FLevel &doomMap, IntSideDef *side) { surface_t *surf; IntSector *front; @@ -172,7 +172,7 @@ static void Surface_AllocateFromSide(FLevel &doomMap, IntSideDef *side) } } -static void Surface_AllocateFromLeaf(FLevel &doomMap) +static void CreateSubsectorSurfaces(FLevel &doomMap) { surface_t *surf; IntSector *sector = NULL; @@ -198,7 +198,7 @@ static void Surface_AllocateFromLeaf(FLevel &doomMap) // sector hacks if(sector == NULL) { - Error("Surface_AllocateFromLeaf: subsector %i has no sector\n", i); + Error("CreateSubsectorSurfaces: subsector %i has no sector\n", i); return; } @@ -272,7 +272,7 @@ static bool IsDegenerate(const kexVec3 &v0, const kexVec3 &v1, const kexVec3 &v2 return crosslengthsqr <= 1.e-6f; } -void Surface_AllocateFromMap(FLevel &doomMap) +void CreateSurfaces(FLevel &doomMap) { for (unsigned int i = 0; i < surfaces.Length(); i++) Mem_Free(surfaces[i]); @@ -313,17 +313,17 @@ void Surface_AllocateFromMap(FLevel &doomMap) } } - printf("------------- Building seg surfaces -------------\n"); + printf("------------- Building side surfaces -------------\n"); for(unsigned int i = 0; i < doomMap.Sides.Size(); i++) { - Surface_AllocateFromSide(doomMap, &doomMap.Sides[i]); + CreateSideSurfaces(doomMap, &doomMap.Sides[i]); printf("sides: %i / %i\r", i+1, doomMap.Sides.Size()); } printf("\nSide surfaces: %i\n", surfaces.Length()); - Surface_AllocateFromLeaf(doomMap); + CreateSubsectorSurfaces(doomMap); printf("Surfaces total: %i\n\n", surfaces.Length()); diff --git a/src/lightmap/surfaces.h b/src/lightmap/surfaces.h index f113058..8a5da02 100644 --- a/src/lightmap/surfaces.h +++ b/src/lightmap/surfaces.h @@ -59,13 +59,11 @@ struct surface_t float *lightmapCoords; surfaceType_t type; int typeIndex; - //void *data; bool bSky; - //MapSubsectorEx *subSector; }; extern kexArray surfaces; struct FLevel; -void Surface_AllocateFromMap(FLevel &doomMap); +void CreateSurfaces(FLevel &doomMap); diff --git a/src/lightmap/wad.cpp b/src/lightmap/wad.cpp deleted file mode 100644 index 0b7d9ae..0000000 --- a/src/lightmap/wad.cpp +++ /dev/null @@ -1,326 +0,0 @@ -//----------------------------------------------------------------------------- -// Note: this is a modified version of dlight. It is not the original software. -//----------------------------------------------------------------------------- -// -// Copyright (c) 2013-2014 Samuel Villarreal -// svkaiser@gmail.com -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// -//----------------------------------------------------------------------------- -// -// DESCRIPTION: General wad loading mechanics -// -//----------------------------------------------------------------------------- - -#include "common.h" -#include "wad.h" - -// -// kexWadFile::~kexWadFile -// - -kexWadFile::~kexWadFile() -{ - Close(); -} - -// -// kexWadFile::Open -// - -bool kexWadFile::Open(const char *fileName) -{ - if(!file.Open(fileName)) - { - return false; - } - - memcpy(&header, file.Buffer(), sizeof(wadHeader_t)); - lumps = (lump_t*)file.GetOffset(2); - wadName = fileName; - bWriting = false; - return true; -} - -// -// kexWadFile::Write -// - -void kexWadFile::Write(const char *fileName) -{ - assert(bWriting == true); - - file.Create(fileName); - file.Write8(header.id[0]); - file.Write8(header.id[1]); - file.Write8(header.id[2]); - file.Write8(header.id[3]); - file.Write32(header.lmpcount); - file.Write32(header.lmpdirpos); - - for(unsigned int i = 0; i < writeLumpList.Length(); i++) - { - byte *data = writeDataList[i]; - - if(!data) - { - continue; - } - - for(int j = 0; j < writeLumpList[i].size; j++) - { - file.Write8(data[j]); - } - } - - for(unsigned int i = 0; i < writeLumpList.Length(); i++) - { - file.Write32(writeLumpList[i].filepos); - file.Write32(writeLumpList[i].size); - for(int j = 0; j < 8; j++) - { - file.Write8(writeLumpList[i].name[j]); - } - } -} - -// -// kexWadFile::Close -// - -void kexWadFile::Close() -{ - if(file.Opened()) - { - file.Close(); - } -} - -// -// kexWadFile::GetLumpFromName -// - -lump_t *kexWadFile::GetLumpFromName(const char *name) -{ - char n[9]; - - for(int i = 0; i < header.lmpcount; i++) - { - // could be optimized here but I really don't feel like - // wasting time on this - strncpy(n, lumps[i].name, 8); - n[8] = 0; - - if(!strncmp(n, name, 8)) - { - return &lumps[i]; - } - } - - return NULL; -} - -// -// kexWadFile::GetLumpData -// - -byte *kexWadFile::GetLumpData(const lump_t *lump) -{ - file.SetOffset(lump->filepos); - return &file.Buffer()[lump->filepos]; -} - -// -// kexWadFile::GetLumpData -// - -byte *kexWadFile::GetLumpData(const char *name) -{ - lump_t *lump = GetLumpFromName(name); - - if(!lump) - { - return NULL; - } - - file.SetOffset(lump->filepos); - return &file.Buffer()[lump->filepos]; -} - -// -// kexWadFile::SetCurrentMap -// - -void kexWadFile::SetCurrentMap(const int map) -{ - lump_t *lump = GetLumpFromName(Va("MAP%02d", map)); - - if(lump == NULL) - { - Error("kexWadFile::SetCurrentMap: MAP%02d not found\n", map); - return; - } - - mapLumpID = lump - lumps; - - lump = GetLumpFromName(Va("GL_MAP%02d", map)); - - if(lump == NULL) - { - Error("kexWadFile::SetCurrentMap: GL_MAP%02d not found\n", map); - return; - } - - glMapLumpID = lump - lumps; - currentmap = map; -} - -// -// kexWadFile::GetMapLump -// - -lump_t *kexWadFile::GetMapLump(mapLumps_t lumpID) -{ - if(mapLumpID + lumpID >= header.lmpcount) - { - return NULL; - } - - return &lumps[mapLumpID + lumpID]; -} - -// -// kexWadFile::GetGLMapLump -// - -lump_t *kexWadFile::GetGLMapLump(glMapLumps_t lumpID) -{ - if(glMapLumpID + lumpID >= header.lmpcount) - { - return NULL; - } - - return &lumps[glMapLumpID + lumpID]; -} - -// -// kexWadFile::InitForWrite -// - -void kexWadFile::InitForWrite() -{ - header.id[0] = 'P'; - header.id[1] = 'W'; - header.id[2] = 'A'; - header.id[3] = 'D'; - - writePos = sizeof(wadHeader_t); - bWriting = true; - - header.lmpcount = 0; - header.lmpdirpos = writePos; -} - -// -// kexWadFile::CopyLumpsFromWadFile -// - -void kexWadFile::CopyLumpsFromWadFile(kexWadFile &wadFile) -{ - lump_t lump; - - assert(bWriting == true); - - for(int i = 0; i < wadFile.header.lmpcount; ++i) - { - lump = wadFile.lumps[i]; - AddLump(wadFile.lumps[i].name, lump.size, &wadFile.file.Buffer()[lump.filepos]); - } -} - -// -// kexWadFile::CopyLumpsFromWadFile -// - -void kexWadFile::CopyLumpsFromWadFile(kexWadFile &wadFile, kexArray &lumpIgnoreList) -{ - lump_t lump; - unsigned int j; - bool bSkip; - - assert(bWriting == true); - - for(int i = 0; i < wadFile.header.lmpcount; ++i) - { - lump = wadFile.lumps[i]; - bSkip = false; - - for(j = 0; j < lumpIgnoreList.Length(); ++j) - { - if(lumpIgnoreList[j] == i) - { - bSkip = true; - break; - } - } - - if(bSkip) - { - continue; - } - - AddLump(wadFile.lumps[i].name, lump.size, &wadFile.file.Buffer()[lump.filepos]); - } -} - -// -// kexWadFile::AddLump -// - -void kexWadFile::AddLump(const char *name, const int size, byte *data) -{ - lump_t lump; - - assert(bWriting == true); - - lump.filepos = writePos; - lump.size = size; - strncpy(lump.name, name, 8); - - writeLumpList.Push(lump); - writeDataList.Push(data); - - header.lmpcount++; - header.lmpdirpos += lump.size; - writePos += lump.size; -} - -// -// kexWadFile::CreateBackup -// - -void kexWadFile::CreateBackup() -{ - kexStr backupName = wadName; - - backupName.StripExtension(); - file.Duplicate(backupName + ".wad.bak"); -} diff --git a/src/lightmap/wad.h b/src/lightmap/wad.h deleted file mode 100644 index 360db46..0000000 --- a/src/lightmap/wad.h +++ /dev/null @@ -1,161 +0,0 @@ -//----------------------------------------------------------------------------- -// Note: this is a modified version of dlight. It is not the original software. -//----------------------------------------------------------------------------- -// -// Copyright (c) 2013-2014 Samuel Villarreal -// svkaiser@gmail.com -// -// This software is provided 'as-is', without any express or implied -// warranty. In no event will the authors be held liable for any damages -// arising from the use of this software. -// -// Permission is granted to anyone to use this software for any purpose, -// including commercial applications, and to alter it and redistribute it -// freely, subject to the following restrictions: -// -// 1. The origin of this software must not be misrepresented; you must not -// claim that you wrote the original software. If you use this software -// in a product, an acknowledgment in the product documentation would be -// appreciated but is not required. -// -// 2. Altered source versions must be plainly marked as such, and must not be -// misrepresented as being the original software. -// -// 3. This notice may not be removed or altered from any source -// distribution. -// - -#pragma once - -#include "kexlib/binfile.h" - -enum mapLumps_t -{ - ML_HEADER = 0, - ML_THINGS, - ML_LINEDEFS, - ML_SIDEDEFS, - ML_VERTEXES, - ML_SEGS, - ML_SUBSECTORS, - ML_NODES, - ML_SECTORS, - ML_REJECT, - ML_BLOCKMAP, - ML_LIGHTMAP, - ML_NUMLUMPS -}; - -enum glMapLumps_t -{ - ML_GL_LABEL = 0, // A separator name, GL_ExMx or GL_MAPxx - ML_GL_VERTS, // Extra Vertices - ML_GL_SEGS, // Segs, from linedefs & minisegs - ML_GL_SSECT, // SubSectors, list of segs - ML_GL_NODES, // GL BSP nodes - ML_GL_PVS // PVS portals -}; - -enum lmMapLumps_t -{ - ML_LM_LABEL = 0, - ML_LM_CELLS, - ML_LM_SUN, - ML_LM_SURFS, - ML_LM_TXCRD, - ML_LM_LMAPS -}; - -#define gNd2 0x32644E67 - -#define GL_VERT_OFFSET 4 - -struct wadHeader_t -{ - char id[4]; - int lmpcount; - int lmpdirpos; -}; - -struct lump_t -{ - int filepos; - int size; - char name[8]; -}; - -class kexWadFile -{ -public: - ~kexWadFile(); - - wadHeader_t header; - lump_t *lumps; - unsigned int size; - int mapLumpID; - int glMapLumpID; - kexStr wadName; - int currentmap; - - lump_t *GetLumpFromName(const char *name); - lump_t *GetMapLump(mapLumps_t lumpID); - lump_t *GetGLMapLump(glMapLumps_t lumpID); - byte *GetLumpData(const lump_t *lump); - byte *GetLumpData(const char *name); - void SetCurrentMap(const int map); - bool Open(const char *fileName); - void Write(const char *fileName); - void Close(); - void CreateBackup(); - void InitForWrite(); - void CopyLumpsFromWadFile(kexWadFile &wadFile); - void CopyLumpsFromWadFile(kexWadFile &wadFile, kexArray &lumpIgnoreList); - void AddLump(const char *name, const int size, byte *data); - - template - void GetMapLump(mapLumps_t lumpID, type **ptr, int *count) - { - if(mapLumpID + lumpID >= header.lmpcount) - { - return; - } - lump_t *lump = GetMapLump(lumpID); - if(lump == NULL || lump->size == 0) - { - return; - } - *ptr = (type*)GetLumpData(lump); - - if(count) - { - *count = lump->size / sizeof(type); - } - } - - template - void GetGLMapLump(glMapLumps_t lumpID, type **ptr, int *count) - { - if(glMapLumpID + lumpID >= header.lmpcount) - { - return; - } - lump_t *lump = GetGLMapLump(lumpID); - if(lump == NULL || lump->size == 0) - { - return; - } - *ptr = (type*)GetLumpData(lump); - - if(count) - { - *count = lump->size / sizeof(type); - } - } - -private: - kexBinFile file; - bool bWriting; - int writePos; - kexArray writeLumpList; - kexArray writeDataList; -};