diff --git a/src/level/doomdata.h b/src/level/doomdata.h index bed5d4f..12b2774 100644 --- a/src/level/doomdata.h +++ b/src/level/doomdata.h @@ -320,24 +320,20 @@ struct FLevel TArray props; + TArray ThingLights; + TArray SurfaceLights; + void FindMapBounds (); void RemoveExtraLines (); void RemoveExtraSides (); void RemoveExtraSectors (); + void SetupLights(); int NumSides() const { return Sides.Size(); } int NumLines() const { return Lines.Size(); } int NumSectors() const { return Sectors.Size(); } int NumThings() const { return Things.Size(); } - // Dlight helpers - - TArray ThingLights; - TArray SurfaceLights; - - void SetupDlight(); - void CreateLights(); - const Vec3 &GetSunColor() const; const Vec3 &GetSunDirection() const; IntSector *GetFrontSector(const IntSideDef *side); @@ -348,6 +344,7 @@ struct FLevel private: void CheckSkySectors(); + void CreateLights(); }; const int BLOCKSIZE = 128; diff --git a/src/level/level.cpp b/src/level/level.cpp index 6bec2d5..7ad3a3f 100644 --- a/src/level/level.cpp +++ b/src/level/level.cpp @@ -615,19 +615,8 @@ void FProcessor::BuildNodes() void FProcessor::BuildLightmaps() { - LMBuilder.ambience = 0.0f; - LMBuilder.samples = Samples; - LMBuilder.textureWidth = LMDims; - LMBuilder.textureHeight = LMDims; - - Level.SetupDlight(); - Level.CreateLights(); - - LMBuilder.CreateLightmaps(Level); - - //LMBuilder.WriteTexturesToTGA(); - //LMBuilder.WriteMeshToOBJ(); - + Level.SetupLights(); + LMBuilder.CreateLightmaps(Level, Samples, LMDims); LightmapsBuilt = true; } diff --git a/src/level/level_light.cpp b/src/level/level_light.cpp index 9f75604..a09b25a 100644 --- a/src/level/level_light.cpp +++ b/src/level/level_light.cpp @@ -41,7 +41,7 @@ static const Vec3 defaultSunColor(1, 1, 1); static const Vec3 defaultSunDirection(0.45f, 0.3f, 0.9f); -void FLevel::SetupDlight() +void FLevel::SetupLights() { CheckSkySectors(); @@ -79,6 +79,8 @@ void FLevel::SetupDlight() } } } + + CreateLights(); } void FLevel::CheckSkySectors() diff --git a/src/lightmap/lightmap.cpp b/src/lightmap/lightmap.cpp index ad87f24..c942635 100644 --- a/src/lightmap/lightmap.cpp +++ b/src/lightmap/lightmap.cpp @@ -719,9 +719,13 @@ void LightmapBuilder::CreateSurfaceLights() } } -void LightmapBuilder::CreateLightmaps(FLevel &doomMap) +void LightmapBuilder::CreateLightmaps(FLevel &doomMap, int sampleDistance, int textureSize) { map = &doomMap; + samples = sampleDistance; + textureWidth = textureSize; + textureHeight = textureSize; + mesh = std::make_unique(doomMap); CreateSurfaceLights(); diff --git a/src/lightmap/lightmap.h b/src/lightmap/lightmap.h index bda3824..678e438 100644 --- a/src/lightmap/lightmap.h +++ b/src/lightmap/lightmap.h @@ -61,15 +61,9 @@ public: LightmapBuilder(); ~LightmapBuilder(); - void CreateLightmaps(FLevel &doomMap); - //void WriteTexturesToTGA(); + void CreateLightmaps(FLevel &doomMap, int sampleDistance, int textureSize); void AddLightmapLump(FWadWriter &wadFile); - int samples = 16; - float ambience = 0.0f; - int textureWidth = 128; - int textureHeight = 128; - private: void NewTexture(); bool MakeRoomForBlock(const int width, const int height, int *x, int *y, int *num); @@ -87,8 +81,12 @@ private: void CreateSurfaceLights(); - std::unique_ptr mesh; FLevel *map; + int samples = 16; + int textureWidth = 128; + int textureHeight = 128; + + std::unique_ptr mesh; std::vector> surfaceLights; std::vector> textures; std::vector indirectoutput;