From 0f6da0df5df75319d4f576feaffb82627c9da16b Mon Sep 17 00:00:00 2001 From: Magnus Norddahl Date: Sat, 3 Nov 2018 19:37:50 +0100 Subject: [PATCH] - make the LIGHTMAP_MAX_SIZE define actually work if someone changes it --- src/lightmap/lightmap.cpp | 8 ++++---- src/lightmap/worker.cpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lightmap/lightmap.cpp b/src/lightmap/lightmap.cpp index ed44dbd..410ce0e 100644 --- a/src/lightmap/lightmap.cpp +++ b/src/lightmap/lightmap.cpp @@ -463,7 +463,7 @@ void kexLightmapBuilder::TraceSurface(surface_t *surface) } kexMath::Clamp(c, 0, 1); - colorSamples[i * 1024 + j] = c; + colorSamples[i * LIGHTMAP_MAX_SIZE + j] = c; } } @@ -525,9 +525,9 @@ void kexLightmapBuilder::TraceSurface(surface_t *surface) int offs = (((textureWidth * (i + surface->lightmapOffs[1])) + surface->lightmapOffs[0]) * 3); // convert RGB to bytes - currentTexture[offs + j * 3 + 0] = floatToHalf(colorSamples[i * 1024 + j].x); - currentTexture[offs + j * 3 + 1] = floatToHalf(colorSamples[i * 1024 + j].y); - currentTexture[offs + j * 3 + 2] = floatToHalf(colorSamples[i * 1024 + j].z); + currentTexture[offs + j * 3 + 0] = floatToHalf(colorSamples[i * LIGHTMAP_MAX_SIZE + j].x); + currentTexture[offs + j * 3 + 1] = floatToHalf(colorSamples[i * LIGHTMAP_MAX_SIZE + j].y); + currentTexture[offs + j * 3 + 2] = floatToHalf(colorSamples[i * LIGHTMAP_MAX_SIZE + j].z); } } } diff --git a/src/lightmap/worker.cpp b/src/lightmap/worker.cpp index a4a86df..b73882e 100644 --- a/src/lightmap/worker.cpp +++ b/src/lightmap/worker.cpp @@ -1,6 +1,7 @@ #include "worker.h" #include "math/mathlib.h" +#include "lightmap.h" #include #include #include @@ -24,7 +25,7 @@ void kexWorker::RunJob(int count, std::function callback) { threads.push_back(std::thread([=]() { - std::vector samples(1024 * 1024); + std::vector samples(LIGHTMAP_MAX_SIZE * LIGHTMAP_MAX_SIZE); colorSamples = samples.data(); int start = threadIndex * count / numThreads;