FireAnimation: fixed top row

This commit is contained in:
Thomas Kolb 2019-12-08 22:58:09 +01:00
parent 13a758b01f
commit 2c4f310395

View file

@ -94,6 +94,16 @@ void FireAnimation::loop(uint64_t frame)
// pull energy from cell below // pull energy from cell below
std::uniform_int_distribution<uint32_t> m_pullEnergyPctRNG(0, MAX_PULL_ENERGY_PCT); std::uniform_int_distribution<uint32_t> 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 strip = 0; strip < nstrip; strip++) {
for(std::size_t led = nled-1; led > 0; led--) { for(std::size_t led = nled-1; led > 0; led--) {
uint32_t &energy = m_energy[idx(strip,led)]; uint32_t &energy = m_energy[idx(strip,led)];