From e046e7a50825bc710bf70941a8e0fa5947f942de Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Tue, 6 Nov 2018 11:08:02 +0100 Subject: [PATCH] - fix floor light surfaces not working --- src/level/level_light.cpp | 4 ++-- src/lightmap/lightsurface.cpp | 9 ++++----- src/lightmap/lightsurface.h | 4 +--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/level/level_light.cpp b/src/level/level_light.cpp index 120e266..c210924 100644 --- a/src/level/level_light.cpp +++ b/src/level/level_light.cpp @@ -275,7 +275,7 @@ void FLevel::CreateLights() desc.rgb.y = ((lightcolor >> 8) & 0xff) / 255.0f; desc.rgb.z = (lightcolor & 0xff) / 255.0f; - auto lightSurface = std::make_unique(desc, surface, true); + auto lightSurface = std::make_unique(desc, surface); lightSurface->Subdivide(16); //lightSurface->CreateCenterOrigin(); lightSurfaces.push_back(std::move(lightSurface)); @@ -338,7 +338,7 @@ void FLevel::CreateLights() desc.rgb.y = ((lightcolor >> 8) & 0xff) / 255.0f; desc.rgb.z = (lightcolor & 0xff) / 255.0f; - auto lightSurface = std::make_unique(desc, surface, false); + auto lightSurface = std::make_unique(desc, surface); lightSurface->Subdivide(16); lightSurfaces.push_back(std::move(lightSurface)); numSurfLights++; diff --git a/src/lightmap/lightsurface.cpp b/src/lightmap/lightsurface.cpp index cb68178..87305e8 100644 --- a/src/lightmap/lightsurface.cpp +++ b/src/lightmap/lightsurface.cpp @@ -36,13 +36,12 @@ #include "level/level.h" #include "lightsurface.h" -kexLightSurface::kexLightSurface(const surfaceLightDef &lightSurfaceDef, surface_t *surface, const bool bWall) +kexLightSurface::kexLightSurface(const surfaceLightDef &lightSurfaceDef, surface_t *surface) { this->intensity = lightSurfaceDef.intensity; this->distance = lightSurfaceDef.distance; this->rgb = lightSurfaceDef.rgb; this->surface = surface; - this->bWall = bWall; } kexLightSurface::~kexLightSurface() @@ -52,7 +51,7 @@ kexLightSurface::~kexLightSurface() // Creates a single origin point if we're not intending on subdividing this light surface void kexLightSurface::CreateCenterOrigin() { - if (!bWall) + if (surface->type == ST_CEILING || surface->type == ST_FLOOR) { kexVec3 center; @@ -254,7 +253,7 @@ float kexLightSurface::TraceSurface(FLevel *map, const surface_t *surf, const ke { kexVec3 center = origins[i]; - if (!bWall && origin.z > center.z) + if ((surface->type == ST_CEILING && origin.z > center.z) || (surface->type == ST_FLOOR && origin.z < center.z)) { // origin is not going to seen or traced by the light surface // so don't even bother. this also fixes some bizzare light @@ -276,7 +275,7 @@ float kexLightSurface::TraceSurface(FLevel *map, const surface_t *surf, const ke if (attenuation <= 0.0f) continue; // not even facing the light surface - if (bWall) + if (surface->type != ST_CEILING && surface->type != ST_FLOOR) { if (origin.z >= surface->verts[0].z && origin.z <= surface->verts[2].z) { diff --git a/src/lightmap/lightsurface.h b/src/lightmap/lightsurface.h index 0cccdf5..870ddf7 100644 --- a/src/lightmap/lightsurface.h +++ b/src/lightmap/lightsurface.h @@ -35,7 +35,7 @@ struct surfaceLightDef; class kexLightSurface { public: - kexLightSurface(const surfaceLightDef &lightSurfaceDef, surface_t *surface, const bool bWall); + kexLightSurface(const surfaceLightDef &lightSurfaceDef, surface_t *surface); ~kexLightSurface(); void Subdivide(const float divide); @@ -45,7 +45,6 @@ public: const float Distance() const { return distance; } const float Intensity() const { return intensity; } const kexVec3 GetRGB() const { return rgb; } - const bool IsAWall() const { return bWall; } const surface_t *Surface() const { return surface; } private: @@ -57,7 +56,6 @@ private: float distance; float intensity; kexVec3 rgb; - bool bWall; vertexBatch_t origins; surface_t *surface; };