From 084c5fe45db52ca922c1f10e422d1bdbfaa48133 Mon Sep 17 00:00:00 2001 From: ragnarok-clanker Date: Sat, 7 Nov 2026 07:36:44 +0000 Subject: [PATCH] Decompile fn_17579 (GroundGeometry::LightmapSample) Batch #14104 by Yommy: 0 byte-identical, 1 confirmed by peer review. - fn_17579 GroundGeometry::LightmapSample: logic confirmed by peer review Peer-reviewed-by: secret, KWDev, codeplay Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes). --- Source/Contents/Ground/GroundSamples.cpp | 28 +++++++++++++++++++----- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/Source/Contents/Ground/GroundSamples.cpp b/Source/Contents/Ground/GroundSamples.cpp index 30314aaf6..0aeca87c8 100644 --- a/Source/Contents/Ground/GroundSamples.cpp +++ b/Source/Contents/Ground/GroundSamples.cpp @@ -45,6 +45,14 @@ int GroundGeometry::Slot12(int, int, int, int, int) const { return 0; } +// INLINED +static __forceinline void ReadLightmapSample(const GroundCell& cell, unsigned sample, unsigned char& alpha, unsigned char& red, unsigned char& green, unsigned char& blue) { + alpha = static_cast(cell.top->lightmap->unknown_0028[sample] >> 24); + red = static_cast(cell.top->lightmap->unknown_0028[sample] >> 16); + green = static_cast(cell.top->lightmap->unknown_0028[sample] >> 8); + blue = static_cast(cell.top->lightmap->unknown_0028[sample]); +} + // OFFSET: 0x00AC11D0 // FUNCTION: fn_17579 void GroundGeometry::LightmapSample(int column, int row, unsigned char& alpha, unsigned char& red, unsigned char& green, unsigned char& blue) const { @@ -60,13 +68,21 @@ void GroundGeometry::LightmapSample(int column, int row, unsigned char& alpha, u return; } - const unsigned sample = (static_cast(column) & 1u) + 2u * (static_cast(row) & 1u); + const GroundCell& cell = this->cells[index]; - const auto read = [&](unsigned shift) { return static_cast(this->cells[index].top->lightmap->unknown_0028[sample] >> shift); }; - alpha = read(24); - red = read(16); - green = read(8); - blue = read(0); + if ((column & 1) == 0) { + if ((row & 1) == 0) { + ReadLightmapSample(cell, 0, alpha, red, green, blue); + } else { + ReadLightmapSample(cell, 2, alpha, red, green, blue); + } + } else { + if ((row & 1) == 0) { + ReadLightmapSample(cell, 1, alpha, red, green, blue); + } else { + ReadLightmapSample(cell, 3, alpha, red, green, blue); + } + } } // OFFSET: 0x00AC0C40