diff options
author | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-03-21 00:57:49 +1100 |
---|---|---|
committer | Kae <80987908+Novaenia@users.noreply.github.com> | 2024-03-21 00:57:49 +1100 |
commit | 57ca6776e41eb4d72fd65bc6b88ca8074180ef15 (patch) | |
tree | 154c718fa32d4454c017d5f50ea0ea87b57b49ae /source/base/StarCellularLighting.hpp | |
parent | a096fa3ffc3627ace2d858b61456e578fb7bc25a (diff) |
Lua patches
Diffstat (limited to 'source/base/StarCellularLighting.hpp')
-rw-r--r-- | source/base/StarCellularLighting.hpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/source/base/StarCellularLighting.hpp b/source/base/StarCellularLighting.hpp index 170cbb5..7cb230f 100644 --- a/source/base/StarCellularLighting.hpp +++ b/source/base/StarCellularLighting.hpp @@ -27,6 +27,7 @@ public: void set(unsigned x, unsigned y, float v); void set(unsigned x, unsigned y, Vec3F const& v); + void add(unsigned x, unsigned y, Vec3F const& v); Vec3F get(unsigned x, unsigned y) const; bool empty() const; @@ -64,6 +65,16 @@ inline void Lightmap::set(unsigned x, unsigned y, Vec3F const& v) { ptr[2] = v.z(); } +inline void Lightmap::add(unsigned x, unsigned y, Vec3F const& v) { + if (x >= m_width || y >= m_height) { + throw LightmapException(strf("[{}, {}] out of range in Lightmap::add", x, y)); + return; + } + float* ptr = m_data.get() + (y * m_width * 3 + x * 3); + ptr[0] += v.x(); + ptr[1] += v.y(); + ptr[2] += v.z(); +} inline Vec3F Lightmap::get(unsigned x, unsigned y) const { if (x >= m_width || y >= m_height) { @@ -74,6 +85,7 @@ inline Vec3F Lightmap::get(unsigned x, unsigned y) const { return Vec3F(ptr[0], ptr[1], ptr[2]); } + inline bool Lightmap::empty() const { return m_width == 0 || m_height == 0; } |