Fix 3D velocity controls

This commit is contained in:
Patrick Walton 2019-01-29 15:44:31 -08:00
parent e3bf703105
commit 13716fd733
2 changed files with 17 additions and 1 deletions

View File

@ -136,7 +136,9 @@ fn main() {
let mut event_handled = false;
while !event_handled {
if camera_velocity.is_zero() {
events.push(sdl_event_pump.wait_event());
}
for event in sdl_event_pump.poll_iter() {
events.push(event);
}
@ -178,6 +180,11 @@ fn main() {
event_handled = true;
}
// FIXME(pcwalton): This is so ugly!
if !camera_velocity.is_zero() {
event_handled = true;
}
}
}
}

View File

@ -238,6 +238,15 @@ impl Point4DF32 {
pub fn approx_eq(&self, other: &Point4DF32, epsilon: f32) -> bool {
self.0.approx_eq(other.0, epsilon)
}
/// Checks to see whether this *homogeneous* coordinate equals zero.
///
/// Note that since this treats the coordinate as a homogeneous coordinate, the `w` is ignored.
// TODO(pcwalton): Optimize with SIMD.
#[inline]
pub fn is_zero(self) -> bool {
self.x() == 0.0 && self.y() == 0.0 && self.z() == 0.0
}
}
impl Add<Point4DF32> for Point4DF32 {