MCPcopy Create free account
hub / github.com/PerroEngine/Perro / approach

Function approach

perro_source/api_modules/perro_modules/src/math.rs:203–214  ·  view source on GitHub ↗
(current: f32, target: f32, max_delta: f32)

Source from the content-addressed store, hash-verified

201
202#[inline]
203pub 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]
217pub fn damp(current: f32, target: f32, lambda: f32, delta_time: f32) -> f32 {

Callers 1

Calls 2

absMethod · 0.45
signumMethod · 0.45

Tested by 1