Skip to content

Commit

Permalink
clamp damping between 0 and 1
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasEi committed Jan 4, 2025
1 parent 6916fc3 commit 7ce501d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/spatial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ fn run_spatial_audio(
let sound_path = emitter_transform.translation() - receiver_transform.translation();
let progress = (sound_path.length() / range.map_or(spatial_audio.radius, |r| r.radius))
.clamp(0., 1.);
let volume: f32 = (1.
- EasingCurve::new(0., 1., damping_curve.0).sample_unchecked(progress))
.clamp(0., 1.);
let volume: f32 = 1.
- EasingCurve::new(0., 1., damping_curve.0)
.sample_unchecked(progress)
.clamp(0., 1.);

let right_ear_angle = if sound_path == Vec3::ZERO {
PI / 2.
Expand Down

0 comments on commit 7ce501d

Please sign in to comment.