MCPcopy Create free account
hub / github.com/TombEngine/TombEngine / UpdateRipples

Function UpdateRipples

TombEngine/Game/effects/Ripple.cpp:48–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46 }
47
48 void UpdateRipples()
49 {
50 constexpr auto RIPPLE_SIZE_MAX = BLOCK(0.5f);
51 constexpr auto SIZE_STEP_LARGE = 4.0f;
52 constexpr auto SIZE_STEP_SMALL = 2.0f;
53
54 if (Ripples.empty())
55 return;
56
57 for (auto& ripple : Ripples)
58 {
59 if (ripple.Life <= 0.0f)
60 continue;
61
62 ripple.StoreInterpolationData();
63
64 // Update size.
65 if (ripple.Size < RIPPLE_SIZE_MAX)
66 ripple.Size += (ripple.Flags & ((int)RippleFlags::SlowFade | (int)RippleFlags::OnGround)) ? SIZE_STEP_SMALL : SIZE_STEP_LARGE;
67
68 float lifeFullOpacity = ripple.LifeMax - (ripple.FadeDuration * 0.75f);
69 float lifeStartFading = ripple.FadeDuration;
70
71 // Update opacity.
72 if (ripple.Life >= lifeFullOpacity)
73 {
74 float alpha = 1.0f - ((ripple.Life - lifeFullOpacity) / (ripple.LifeMax - lifeFullOpacity));
75 ripple.Color.w = Lerp(0.0f, RIPPLE_OPACITY_MAX, alpha);
76 }
77 else if (ripple.Life <= lifeStartFading)
78 {
79 float alpha = 1.0f - (ripple.Life / lifeStartFading);
80 ripple.Color.w = Lerp(RIPPLE_OPACITY_MAX, 0.0f, alpha);
81 }
82
83 // Update life.
84 ripple.Life -= 1.0f;
85 }
86
87 ClearInactiveEffects(Ripples);
88 }
89
90 void ClearRipples()
91 {

Callers 1

GamePhaseFunction · 0.85

Calls 4

LerpFunction · 0.85
ClearInactiveEffectsFunction · 0.85
emptyMethod · 0.45

Tested by

no test coverage detected