- rename LightSurface to SurfaceLight

This commit is contained in:
Magnus Norddahl 2018-11-09 22:17:36 +01:00
parent 908c048464
commit b3250f4bac
6 changed files with 45 additions and 64 deletions

View file

@ -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<thingLight_t> ThingLights;
TArray<surfaceLightDef> SurfaceLights;
TArray<ThingLight> ThingLights;
TArray<SurfaceLightDef> SurfaceLights;
void SetupDlight();
void CreateLights();

View file

@ -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;

View file

@ -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<LightSurface>(map->SurfaceLights[lightdefidx], surface);
lightSurface->Subdivide(16);
lightSurfaces.push_back(std::move(lightSurface));
auto surfaceLight = std::make_unique<SurfaceLight>(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<LightSurface>(map->SurfaceLights[sector->floorlightdef], surface);
lightSurface->Subdivide(16);
lightSurfaces.push_back(std::move(lightSurface));
auto surfaceLight = std::make_unique<SurfaceLight>(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<LightSurface>(map->SurfaceLights[sector->ceilinglightdef], surface);
lightSurface->Subdivide(16);
lightSurfaces.push_back(std::move(lightSurface));
auto surfaceLight = std::make_unique<SurfaceLight>(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<LevelMesh>(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);

View file

@ -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<LevelMesh> mesh;
FLevel *map;
std::vector<std::unique_ptr<LightSurface>> lightSurfaces;
std::vector<std::unique_ptr<SurfaceLight>> surfaceLights;
std::vector<std::vector<uint16_t>> textures;
std::vector<uint16_t> indirectoutput;
std::vector<std::vector<int>> allocBlocks;

View file

@ -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<float> dists;
std::vector<char> 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<std::unique_ptr<VertexBatch>> &points)
bool SurfaceLight::SubdivideRecursion(VertexBatch &surfPoints, float divide, std::vector<std::unique_ptr<VertexBatch>> &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

View file

@ -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);