diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/light.cpp | 11 | ||||
-rw-r--r-- | src/light.hpp | 3 |
2 files changed, 10 insertions, 4 deletions
diff --git a/src/light.cpp b/src/light.cpp index ed7c4ae1..ed9469f2 100644 --- a/src/light.cpp +++ b/src/light.cpp @@ -43,14 +43,19 @@ bool light::update(size_t, float) { return false; } bool light::is_dynamic() const { return true; } bool light::is_virtual() const { return true; } -float light::calc_intensity(float half_dist, light_falloff falloff) +Vector2 light::intensity(Vector2 half_dist, light_falloff falloff) { switch (falloff) { case light_falloff::linear: return 2 * half_dist; - case light_falloff::quadratic: return std::sqrt(2 * half_dist); - default: case light_falloff::constant: return 1; + case light_falloff::quadratic: return Vector2{std::sqrt(2 * half_dist.x()), std::sqrt(2 * half_dist.y())}; + default: case light_falloff::constant: return Vector2{1, 1}; } } +Vector2 light::intensity() const +{ + return intensity(half_dist, falloff); +} + } // namespace floormat diff --git a/src/light.hpp b/src/light.hpp index 15dbc7c6..e228c8b5 100644 --- a/src/light.hpp +++ b/src/light.hpp @@ -37,7 +37,8 @@ struct light final : entity bool is_dynamic() const override; bool is_virtual() const override; - static float calc_intensity(float half_dist, light_falloff falloff); + static Vector2 intensity(Vector2 half_dist, light_falloff falloff); + Vector2 intensity() const; friend struct world; }; |