diff --git a/src/level/doomdata.h b/src/level/doomdata.h index d776735..bed5d4f 100644 --- a/src/level/doomdata.h +++ b/src/level/doomdata.h @@ -247,7 +247,7 @@ class Vec3; class Vec2; struct vertex_t; struct Surface; -struct thingLight_t; +struct ThingLight; struct FloatVertex { @@ -255,30 +255,11 @@ struct FloatVertex float y; }; -struct lightDef_t -{ - int doomednum; - float height; - float radius; - float intensity; - float falloff; - bool bCeiling; - Vec3 rgb; -}; - -struct mapDef_t -{ - int map; - int sunIgnoreTag; - Vec3 sunDir; - Vec3 sunColor; -}; - -struct thingLight_t +struct ThingLight { IntThing *mapThing; - Vec2 origin; - Vec3 rgb; + Vec2 origin; + Vec3 rgb; float intensity; float innerAngleCos; float outerAngleCos; @@ -289,11 +270,11 @@ struct thingLight_t MapSubsectorEx *ssect; }; -struct surfaceLightDef +struct SurfaceLightDef { float distance; float intensity; - Vec3 rgb; + Vec3 rgb; }; enum mapFlags_t @@ -351,8 +332,8 @@ struct FLevel // Dlight helpers - TArray ThingLights; - TArray SurfaceLights; + TArray ThingLights; + TArray SurfaceLights; void SetupDlight(); void CreateLights(); diff --git a/src/level/level_light.cpp b/src/level/level_light.cpp index de8f60d..522c2a6 100644 --- a/src/level/level_light.cpp +++ b/src/level/level_light.cpp @@ -247,7 +247,7 @@ void FLevel::CreateLights() int x = thing->x >> FRACBITS; int y = thing->y >> FRACBITS; - thingLight_t thingLight; + ThingLight thingLight; thingLight.mapThing = thing; thingLight.rgb.x = ((lightcolor >> 16) & 0xff) / 255.0f; thingLight.rgb.y = ((lightcolor >> 8) & 0xff) / 255.0f; @@ -300,7 +300,7 @@ void FLevel::CreateLights() if (lightdistance > 0.0f && lightintensity > 0.0f && lightcolor != 0) { - surfaceLightDef desc; + SurfaceLightDef desc; desc.intensity = lightintensity; desc.distance = lightdistance; desc.rgb.x = ((lightcolor >> 16) & 0xff) / 255.0f; @@ -341,7 +341,7 @@ void FLevel::CreateLights() if (lightdistance > 0.0f && lightintensity > 0.0f && lightcolor != 0) { - surfaceLightDef desc; + SurfaceLightDef desc; desc.intensity = lightintensity; desc.distance = lightdistance; desc.rgb.x = ((lightcolor >> 16) & 0xff) / 255.0f; @@ -373,7 +373,7 @@ void FLevel::CreateLights() if (lightdistance > 0.0f && lightintensity > 0.0f && lightcolor != 0) { - surfaceLightDef desc; + SurfaceLightDef desc; desc.intensity = lightintensity; desc.distance = lightdistance; desc.rgb.x = ((lightcolor >> 16) & 0xff) / 255.0f; diff --git a/src/lightmap/lightmap.cpp b/src/lightmap/lightmap.cpp index e51c62a..fc71ab4 100644 --- a/src/lightmap/lightmap.cpp +++ b/src/lightmap/lightmap.cpp @@ -213,7 +213,7 @@ Vec3 LightmapBuilder::LightTexelSample(const Vec3 &origin, Surface *surface) // check all thing lights for (unsigned int i = 0; i < map->ThingLights.Size(); i++) { - thingLight_t *tl = &map->ThingLights[i]; + ThingLight *tl = &map->ThingLights[i]; float originZ; if (!tl->bCeiling) @@ -286,9 +286,9 @@ Vec3 LightmapBuilder::LightTexelSample(const Vec3 &origin, Surface *surface) } // trace against surface lights - for (size_t i = 0; i < lightSurfaces.size(); ++i) + for (size_t i = 0; i < surfaceLights.size(); ++i) { - LightSurface *surfaceLight = lightSurfaces[i].get(); + SurfaceLight *surfaceLight = surfaceLights[i].get(); float attenuation = surfaceLight->TraceSurface(mesh.get(), surface, origin); if (attenuation > 0.0f) @@ -646,7 +646,7 @@ void LightmapBuilder::TraceIndirectLight(Surface *surface) } } -void LightmapBuilder::LightSurfacex(const int surfid) +void LightmapBuilder::LightSurface(const int surfid) { BuildSurfaceParams(mesh->surfaces[surfid].get()); TraceSurface(mesh->surfaces[surfid].get()); @@ -679,7 +679,7 @@ void LightmapBuilder::LightIndirect(const int surfid) } } -void LightmapBuilder::CreateLightSurfaces() +void LightmapBuilder::CreateSurfaceLights() { for (size_t j = 0; j < mesh->surfaces.size(); ++j) { @@ -690,9 +690,9 @@ void LightmapBuilder::CreateLightSurfaces() int lightdefidx = map->Sides[surface->typeIndex].lightdef; if (lightdefidx != -1) { - auto lightSurface = std::make_unique(map->SurfaceLights[lightdefidx], surface); - lightSurface->Subdivide(16); - lightSurfaces.push_back(std::move(lightSurface)); + auto surfaceLight = std::make_unique(map->SurfaceLights[lightdefidx], surface); + surfaceLight->Subdivide(16); + surfaceLights.push_back(std::move(surfaceLight)); } } else if (surface->type == ST_FLOOR || surface->type == ST_CEILING) @@ -704,15 +704,15 @@ void LightmapBuilder::CreateLightSurfaces() { if (sector->floorlightdef != -1 && surface->type == ST_FLOOR) { - auto lightSurface = std::make_unique(map->SurfaceLights[sector->floorlightdef], surface); - lightSurface->Subdivide(16); - lightSurfaces.push_back(std::move(lightSurface)); + auto surfaceLight = std::make_unique(map->SurfaceLights[sector->floorlightdef], surface); + surfaceLight->Subdivide(16); + surfaceLights.push_back(std::move(surfaceLight)); } else if (sector->ceilinglightdef != -1 && surface->type == ST_CEILING) { - auto lightSurface = std::make_unique(map->SurfaceLights[sector->ceilinglightdef], surface); - lightSurface->Subdivide(16); - lightSurfaces.push_back(std::move(lightSurface)); + auto surfaceLight = std::make_unique(map->SurfaceLights[sector->ceilinglightdef], surface); + surfaceLight->Subdivide(16); + surfaceLights.push_back(std::move(surfaceLight)); } } } @@ -724,7 +724,7 @@ void LightmapBuilder::CreateLightmaps(FLevel &doomMap) map = &doomMap; mesh = std::make_unique(doomMap); - CreateLightSurfaces(); + CreateSurfaceLights(); printf("-------------- Tracing cells ---------------\n"); @@ -743,7 +743,7 @@ void LightmapBuilder::CreateLightmaps(FLevel &doomMap) tracedTexels = 0; processed = 0; Worker::RunJob(mesh->surfaces.size(), [=](int id) { - LightSurfacex(id); + LightSurface(id); }); printf("Texels traced: %i \n\n", tracedTexels); diff --git a/src/lightmap/lightmap.h b/src/lightmap/lightmap.h index 2618c06..bda3824 100644 --- a/src/lightmap/lightmap.h +++ b/src/lightmap/lightmap.h @@ -37,7 +37,7 @@ #define LIGHTCELL_BLOCK_SIZE 16 class FWadWriter; -class LightSurface; +class SurfaceLight; class LightCellBlock { @@ -82,14 +82,14 @@ private: void TraceIndirectLight(Surface *surface); void SetupLightCellGrid(); void LightBlock(int blockid); - void LightSurfacex(const int surfid); + void LightSurface(const int surfid); void LightIndirect(const int surfid); - void CreateLightSurfaces(); + void CreateSurfaceLights(); std::unique_ptr mesh; FLevel *map; - std::vector> lightSurfaces; + std::vector> surfaceLights; std::vector> textures; std::vector indirectoutput; std::vector> allocBlocks; diff --git a/src/lightmap/lightsurface.cpp b/src/lightmap/lightsurface.cpp index fcaed21..6e4d109 100644 --- a/src/lightmap/lightsurface.cpp +++ b/src/lightmap/lightsurface.cpp @@ -29,20 +29,20 @@ #include "level/level.h" #include "lightsurface.h" -LightSurface::LightSurface(const surfaceLightDef &lightSurfaceDef, Surface *surface) +SurfaceLight::SurfaceLight(const SurfaceLightDef &surfaceLightDef, Surface *surface) { - this->intensity = lightSurfaceDef.intensity; - this->distance = lightSurfaceDef.distance; - this->rgb = lightSurfaceDef.rgb; + this->intensity = surfaceLightDef.intensity; + this->distance = surfaceLightDef.distance; + this->rgb = surfaceLightDef.rgb; this->surface = surface; } -LightSurface::~LightSurface() +SurfaceLight::~SurfaceLight() { } // Splits surface vertices into two groups while adding new ones caused by the split -void LightSurface::Clip(VertexBatch &points, const Vec3 &normal, float dist, VertexBatch *frontPoints, VertexBatch *backPoints) +void SurfaceLight::Clip(VertexBatch &points, const Vec3 &normal, float dist, VertexBatch *frontPoints, VertexBatch *backPoints) { std::vector dists; std::vector sides; @@ -116,7 +116,7 @@ void LightSurface::Clip(VertexBatch &points, const Vec3 &normal, float dist, Ver } // Recursively divides the surface -bool LightSurface::SubdivideRecursion(VertexBatch &surfPoints, float divide, std::vector> &points) +bool SurfaceLight::SubdivideRecursion(VertexBatch &surfPoints, float divide, std::vector> &points) { BBox bounds; Vec3 splitNormal; @@ -161,7 +161,7 @@ bool LightSurface::SubdivideRecursion(VertexBatch &surfPoints, float divide, std return false; } -void LightSurface::Subdivide(const float divide) +void SurfaceLight::Subdivide(const float divide) { if (surface->type == ST_CEILING || surface->type == ST_FLOOR) { @@ -234,7 +234,7 @@ void LightSurface::Subdivide(const float divide) } } -float LightSurface::TraceSurface(LevelMesh *mesh, const Surface *fragmentSurface, const Vec3 &fragmentPos) +float SurfaceLight::TraceSurface(LevelMesh *mesh, const Surface *fragmentSurface, const Vec3 &fragmentPos) { if (fragmentSurface == surface) return 1.0f; // light surface will always be fullbright diff --git a/src/lightmap/lightsurface.h b/src/lightmap/lightsurface.h index 68872e4..78aa5a1 100644 --- a/src/lightmap/lightsurface.h +++ b/src/lightmap/lightsurface.h @@ -30,13 +30,13 @@ #include "surfaces.h" struct FLevel; -struct surfaceLightDef; +struct SurfaceLightDef; -class LightSurface +class SurfaceLight { public: - LightSurface(const surfaceLightDef &lightSurfaceDef, Surface *surface); - ~LightSurface(); + SurfaceLight(const SurfaceLightDef &surfaceLightDef, Surface *surface); + ~SurfaceLight(); void Subdivide(const float divide); float TraceSurface(LevelMesh *map, const Surface *surface, const Vec3 &origin);