MCPcopy Create free account
hub / github.com/FastLED/FastLED / update

Method update

src/fl/math/wave/wave_simulation.cpp.hpp:219–247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

217}
218
219void WaveSimulation2D::update() {
220 if (mUseChangeGrid) {
221 const vec2<i16> min_max = mChangeGrid.minMax();
222 const bool has_updates = min_max != vec2<i16>(0, 0);
223 for (u8 i = 0; i < mExtraFrames + 1; ++i) {
224 if (has_updates) {
225 // apply them
226 const u32 w = mChangeGrid.width();
227 const u32 h = mChangeGrid.height();
228 for (u32 x = 0; x < w; ++x) {
229 for (u32 y = 0; y < h; ++y) {
230 i16 v16 = mChangeGrid(x, y);
231 if (v16 != 0) {
232 mSim->seti16(x, y, v16);
233 }
234 }
235 }
236 }
237 mSim->update();
238 }
239 // zero out mChangeGrid
240 mChangeGrid.clear();
241 } else {
242 // When change grid is disabled, just run the simulation updates
243 for (u8 i = 0; i < mExtraFrames + 1; ++i) {
244 mSim->update();
245 }
246 }
247}
248
249u32 WaveSimulation2D::getWidth() const { return mOuterWidth; }
250u32 WaveSimulation2D::getHeight() const { return mOuterHeight; }

Callers

nothing calls this directly

Calls 5

minMaxMethod · 0.80
widthMethod · 0.45
heightMethod · 0.45
seti16Method · 0.45
clearMethod · 0.45

Tested by

no test coverage detected