| 90 | } |
| 91 | |
| 92 | void UpdateDrips() |
| 93 | { |
| 94 | constexpr auto RIPPLE_SIZE_WATER_MAX = 24.0f; |
| 95 | constexpr auto RIPPLE_SIZE_WATER_MIN = 16.0f; |
| 96 | constexpr auto RIPPLE_SIZE_GROUND_MAX = 16.0f; |
| 97 | constexpr auto RIPPLE_SIZE_GROUND_MIN = 8.0f; |
| 98 | constexpr auto RIPPLE_HEIGHT_OFFSET = 4; |
| 99 | |
| 100 | if (Drips.empty()) |
| 101 | return; |
| 102 | |
| 103 | for (auto& drip : Drips) |
| 104 | { |
| 105 | if (drip.Life <= 0.0f) |
| 106 | continue; |
| 107 | |
| 108 | drip.StoreInterpolationData(); |
| 109 | |
| 110 | // Update velocity. |
| 111 | drip.Velocity.y += drip.Gravity; |
| 112 | if (TestEnvironment(ENV_FLAG_WIND, drip.RoomNumber)) |
| 113 | drip.Velocity += Weather.Wind(); |
| 114 | |
| 115 | int prevRoomNumber = drip.RoomNumber; |
| 116 | auto pointColl = GetPointCollision(drip.Position, drip.RoomNumber); |
| 117 | |
| 118 | // Update position. |
| 119 | drip.Position += drip.Velocity; |
| 120 | drip.RoomNumber = pointColl.GetRoomNumber(); |
| 121 | |
| 122 | // Update size and color. |
| 123 | float alpha = 1.0f - (drip.Life / drip.LifeMax); |
| 124 | drip.Size.y = Lerp(drip.Size.x / (1 / 6.4f), 0.0f, alpha); |
| 125 | drip.Color = Vector4::Lerp(DRIP_COLOR_WHITE, Vector4::Zero, alpha); |
| 126 | |
| 127 | // Hit water. |
| 128 | if (TestEnvironment(ENV_FLAG_WATER, drip.RoomNumber)) |
| 129 | { |
| 130 | // Spawn ripple on surface only. |
| 131 | if (!TestEnvironment(ENV_FLAG_WATER, prevRoomNumber)) |
| 132 | { |
| 133 | SpawnRipple( |
| 134 | Vector3(drip.Position.x, pointColl.GetWaterTopHeight() - RIPPLE_HEIGHT_OFFSET, drip.Position.z), |
| 135 | pointColl.GetRoomNumber(), |
| 136 | Random::GenerateFloat(RIPPLE_SIZE_WATER_MIN, RIPPLE_SIZE_WATER_MAX), |
| 137 | (int)RippleFlags::SlowFade | (int)RippleFlags::LowOpacity); |
| 138 | } |
| 139 | |
| 140 | drip.Life = 0.0f; |
| 141 | continue; |
| 142 | } |
| 143 | // Hit floor; spawn ripple. |
| 144 | else if (drip.Position.y >= pointColl.GetFloorHeight()) |
| 145 | { |
| 146 | SpawnRipple( |
| 147 | Vector3(drip.Position.x, pointColl.GetFloorHeight() - RIPPLE_HEIGHT_OFFSET, drip.Position.z), |
| 148 | pointColl.GetRoomNumber(), |
| 149 | Random::GenerateFloat(RIPPLE_SIZE_GROUND_MIN, RIPPLE_SIZE_GROUND_MAX), |
no test coverage detected