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

◆ spawnDebrisFromMeteor()

void fl::PerlinParticlePunch::spawnDebrisFromMeteor ( MeteorParticle & m,
u32 now )
private

Definition at line 380 of file perlin_particle_punch.cpp.hpp.

380 {
382 if (!d)
383 return;
384
385 float tailLen = m.tailLength();
386 u8 maxOffset = clamp_u8(tailLen);
387 if (maxOffset < 3)
388 maxOffset = 3;
389 float spawnOffset = float(random8(2, maxOffset));
390 float spawnPos = m.position - spawnOffset;
391 if (spawnPos < 0.0f)
392 spawnPos = 0.0f;
393
394 // Interpolate meteor tail color at detach point
395 float t = spawnOffset / tailLen;
396 if (t > 1.0f)
397 t = 1.0f;
398 fract8 blendAmt = clamp_u8(t * 255.0f);
399 CRGB debrisColor = blend(mMeteorMidColor, mMeteorTailColor, blendAmt);
400
401 d->alive = true;
402 d->position = spawnPos;
403 d->velocity = float(random8(10, 40)) / 100.0f; // 0.1-0.4 LEDs/frame
404 d->brightness = 180.0f;
405 d->color = debrisColor;
406 m.debrisSpawned++;
407}
LIB8STATIC fl::u8 random8() FL_NOEXCEPT
Generate an 8-bit random number.
Definition random8.h:53
u8 fract8
Fixed-Point Fractional Types.
Definition s16x16x4.h:161
unsigned char u8
Definition stdint.h:131
fl::CRGB CRGB
Definition video.h:15
CRGB blend(const CRGB &p1, const CRGB &p2, fract8 amountOfP2)

References fl::PerlinParticlePunch::DebrisParticle::alive, fl::blend(), fl::PerlinParticlePunch::DebrisParticle::brightness, fl::PerlinParticlePunch::DebrisParticle::color, fl::PerlinParticlePunch::MeteorParticle::debrisSpawned, mMeteorMidColor, mMeteorTailColor, fl::PerlinParticlePunch::DebrisParticle::position, fl::PerlinParticlePunch::MeteorParticle::position, random8(), fl::t, fl::PerlinParticlePunch::MeteorParticle::tailLength(), tryAllocateDebris(), and fl::PerlinParticlePunch::DebrisParticle::velocity.

Referenced by draw().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: