diff --git a/src/bformat.rs b/src/bformat.rs index 1bc148c..606cc84 100644 --- a/src/bformat.rs +++ b/src/bformat.rs @@ -102,7 +102,7 @@ impl Bweights { /// Compute weights that correspond to a sound source at given position. pub fn from_position(pos: [f32; 3]) -> Self { - let dist = (pos[0] * pos[0] + pos[1] * pos[1] + pos[1] * pos[2]).sqrt(); + let dist = (pos[0] * pos[0] + pos[1] * pos[1] + pos[2] * pos[2]).sqrt(); let falloff = 1.0 / dist.max(1.0); // todo: proper falloff and distance model(s) Bweights { w: falloff / 2f32.sqrt(), diff --git a/src/bstream.rs b/src/bstream.rs index 13072da..af86b3e 100644 --- a/src/bstream.rs +++ b/src/bstream.rs @@ -209,12 +209,12 @@ impl SoundController { fn doppler_rate(&self) -> f32 { let dist = (self.position[0] * self.position[0] + self.position[1] * self.position[1] - + self.position[1] * self.position[2]) + + self.position[2] * self.position[2]) .sqrt(); let relative_velocity = (self.position[0] * self.velocity[0] + self.position[1] * self.velocity[1] - + self.position[1] * self.velocity[2]) / dist; + + self.position[2] * self.velocity[2]) / dist; self.speed_of_sound / (self.speed_of_sound + self.doppler_factor * relative_velocity) }