(current: f32, target: f32, max_delta: f32)
| 201 | |
| 202 | #[inline] |
| 203 | pub fn approach(current: f32, target: f32, max_delta: f32) -> f32 { |
| 204 | if max_delta <= 0.0 { |
| 205 | return current; |
| 206 | } |
| 207 | |
| 208 | let delta = target - current; |
| 209 | if delta.abs() <= max_delta { |
| 210 | target |
| 211 | } else { |
| 212 | current + delta.signum() * max_delta |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | #[inline] |
| 217 | pub fn damp(current: f32, target: f32, lambda: f32, delta_time: f32) -> f32 { |