FastLED 3.9.15
Loading...
Searching...
No Matches

◆ update()

void fl::WaveSimulation2D::update ( )

Definition at line 211 of file wave_simulation.cpp.

211 {
212 if (mUseChangeGrid) {
213 const vec2<i16> min_max = mChangeGrid.minMax();
214 const bool has_updates = min_max != vec2<i16>(0, 0);
215 for (u8 i = 0; i < mExtraFrames + 1; ++i) {
216 if (has_updates) {
217 // apply them
218 const u32 w = mChangeGrid.width();
219 const u32 h = mChangeGrid.height();
220 for (u32 x = 0; x < w; ++x) {
221 for (u32 y = 0; y < h; ++y) {
222 i16 v16 = mChangeGrid(x, y);
223 if (v16 != 0) {
224 mSim->seti16(x, y, v16);
225 }
226 }
227 }
228 }
229 mSim->update();
230 }
231 // zero out mChangeGrid
232 mChangeGrid.clear();
233 } else {
234 // When change grid is disabled, just run the simulation updates
235 for (u8 i = 0; i < mExtraFrames + 1; ++i) {
236 mSim->update();
237 }
238 }
239}
int y
Definition simple.h:93
int x
Definition simple.h:92
fl::Grid< i16 > mChangeGrid
fl::unique_ptr< WaveSimulation2D_Real > mSim
unsigned char u8
Definition int.h:17

References mChangeGrid, mExtraFrames, mSim, mUseChangeGrid, x, and y.