| 72 | } |
| 73 | |
| 74 | void UpdateDecals() |
| 75 | { |
| 76 | if (Decals.empty()) |
| 77 | return; |
| 78 | |
| 79 | for (auto& decal : Decals) |
| 80 | { |
| 81 | if (decal.Life <= 0) |
| 82 | continue; |
| 83 | |
| 84 | if (decal.Life <= decal.LifeStartFading) |
| 85 | { |
| 86 | float alpha = 1.0f - ((float)decal.Life / (float)decal.LifeStartFading); |
| 87 | decal.Opacity = Lerp(decal.StartOpacity, 0.0f, alpha); |
| 88 | } |
| 89 | else |
| 90 | { |
| 91 | decal.Opacity = decal.StartOpacity; |
| 92 | } |
| 93 | |
| 94 | decal.Life--; |
| 95 | } |
| 96 | |
| 97 | if ((int)Decals.size() > Decal::COUNT_THRESHOLD) |
| 98 | { |
| 99 | int excess = (int)Decals.size() - Decal::COUNT_THRESHOLD; |
| 100 | |
| 101 | for (auto& decal : Decals) |
| 102 | { |
| 103 | if (decal.LifeStartFading <= Decal::LIFE_QUEUE_FADEOUT) |
| 104 | { |
| 105 | excess--; |
| 106 | continue; |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | if (excess > 0) |
| 111 | { |
| 112 | for (auto& decal : Decals) |
| 113 | { |
| 114 | if (decal.LifeStartFading <= Decal::LIFE_QUEUE_FADEOUT) |
| 115 | continue; |
| 116 | |
| 117 | decal.Life = ((float)decal.Life / (float)decal.LifeStartFading) * Decal::LIFE_QUEUE_FADEOUT; |
| 118 | decal.LifeStartFading = Decal::LIFE_QUEUE_FADEOUT; |
| 119 | excess--; |
| 120 | |
| 121 | if (excess <= 0) |
| 122 | break; |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | ClearInactiveEffects(Decals); |
| 128 | } |
| 129 | |
| 130 | void ClearDecals() |
| 131 | { |
no test coverage detected