Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Source/engine/render/light_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,10 +450,11 @@ Lightmap::Lightmap(const uint8_t *outBuffer, uint16_t outPitch,

Lightmap Lightmap::build(Point tilePosition, Point targetBufferPosition,
int viewportWidth, int viewportHeight, int rows, int columns,
const uint8_t *outBuffer, const uint8_t *lightTables, size_t lightTableSize)
const uint8_t *outBuffer, uint16_t outPitch,
const uint8_t *lightTables, size_t lightTableSize)
{
BuildLightmap(tilePosition, targetBufferPosition, viewportWidth, viewportHeight, rows, columns);
return Lightmap(outBuffer, LightmapBuffer, gnScreenWidth, lightTables, lightTableSize);
return Lightmap(outBuffer, outPitch, LightmapBuffer, gnScreenWidth, lightTables, lightTableSize);
}

Lightmap Lightmap::bleedUp(const Lightmap &source, Point targetBufferPosition, std::span<uint8_t> lightmapBuffer)
Expand All @@ -466,7 +467,7 @@ Lightmap Lightmap::bleedUp(const Lightmap &source, Point targetBufferPosition, s
const int sourceHeight = static_cast<int>(source.lightmapBuffer.size() / source.lightmapPitch);
const int clipLeft = std::max(0, -targetBufferPosition.x);
const int clipTop = std::max(0, -(targetBufferPosition.y - TILE_HEIGHT + 1));
const int clipRight = std::max(0, targetBufferPosition.x + TILE_WIDTH - source.outPitch);
const int clipRight = std::max(0, targetBufferPosition.x + TILE_WIDTH - source.lightmapPitch);
const int clipBottom = std::max(0, targetBufferPosition.y - sourceHeight + 1);

// Nothing we can do if the tile is completely outside the bounds of the lightmap
Expand Down Expand Up @@ -499,7 +500,7 @@ Lightmap Lightmap::bleedUp(const Lightmap &source, Point targetBufferPosition, s

// Copy data from the source lightmap between the top edge of the base diamond
assert(dst + lightOffset + lightLength <= lightmapBuffer.data() + TILE_WIDTH * TILE_HEIGHT);
assert(src + lightOffset + lightLength <= LightmapBuffer.data() + LightmapBuffer.size());
assert(src + lightOffset + lightLength <= source.lightmapBuffer.data() + source.lightmapBuffer.size());
memcpy(dst + lightOffset, src + lightOffset, lightLength);

src -= source.lightmapPitch;
Expand Down
3 changes: 2 additions & 1 deletion Source/engine/render/light_render.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class Lightmap {

static Lightmap build(Point tilePosition, Point targetBufferPosition,
int viewportWidth, int viewportHeight, int rows, int columns,
const uint8_t *outBuffer, const uint8_t *lightTables, size_t lightTableSize);
const uint8_t *outBuffer, uint16_t outPitch,
const uint8_t *lightTables, size_t lightTableSize);

static Lightmap bleedUp(const Lightmap &source, Point targetBufferPosition, std::span<uint8_t> lightmapBuffer);

Expand Down
2 changes: 1 addition & 1 deletion Source/engine/render/scrollrt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@ void DrawGame(const Surface &fullOut, Point position, Displacement offset)

Lightmap lightmap = Lightmap::build(position, Point {} + offset,
gnScreenWidth, gnViewportHeight, rows, columns,
out.at(0, 0), LightTables[0].data(), LightTables[0].size());
out.at(0, 0), out.pitch(), LightTables[0].data(), LightTables[0].size());

DrawFloor(out, lightmap, position, Point {} + offset, rows, columns);
DrawTileContent(out, lightmap, position, Point {} + offset, rows, columns);
Expand Down