From 2c4f310395ea5ae8da80c81df97f40e2f66f3662 Mon Sep 17 00:00:00 2001 From: Thomas Kolb Date: Sun, 8 Dec 2019 22:58:09 +0100 Subject: [PATCH] FireAnimation: fixed top row --- src/Animation/FireAnimation.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Animation/FireAnimation.cpp b/src/Animation/FireAnimation.cpp index 82129a5..7a441f6 100644 --- a/src/Animation/FireAnimation.cpp +++ b/src/Animation/FireAnimation.cpp @@ -94,6 +94,16 @@ void FireAnimation::loop(uint64_t frame) // pull energy from cell below std::uniform_int_distribution m_pullEnergyPctRNG(0, MAX_PULL_ENERGY_PCT); + // special energy removal handling of topmost row + for(std::size_t strip = 0; strip < nstrip; strip++) { + uint32_t &energy = m_energy[idx(strip,nled-1)]; + + uint32_t pulled_energy = m_pullEnergyPctRNG(m_gen) * energy / 100; + + energy -= pulled_energy; + } + + // normal rows for(std::size_t strip = 0; strip < nstrip; strip++) { for(std::size_t led = nled-1; led > 0; led--) { uint32_t &energy = m_energy[idx(strip,led)];