Skip to content

Commit d17f464

Browse files
author
Jakub Hlusička
committed
fix camera movement speed
1 parent 3957270 commit d17f464

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "euclider"
3-
version = "0.13.0"
3+
version = "0.13.1"
44
description = "A non-euclidean ray tracer"
55
license = "MIT/Unlicense"
66
authors = ["Jakub Hlusička <[email protected]>"]

src/universe/d3/entity/camera.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ impl<F: CustomFloat> Camera<F, Point3<F>, Vector3<F>> for Camera3Impl<F> {
150150
let delta_millis = <F as NumCast>::from((*delta_time * 1000u32).as_secs()).unwrap() /
151151
Cast::from(1000.0);
152152
let distance = self.speed * delta_millis;
153+
154+
if distance == <F as Zero>::zero() {
155+
return;
156+
}
157+
153158
let mut direction: Vector3<F> = na::zero();
154159

155160
for &(_, keycode) in pressed_keys {
@@ -166,13 +171,12 @@ impl<F: CustomFloat> Camera<F, Point3<F>, Vector3<F>> for Camera3Impl<F> {
166171
}
167172
}
168173

169-
let velocity = direction * distance;
170-
171-
if velocity.norm_squared() != <F as Zero>::zero() {
172-
if let Some((new_location, new_direction)) = universe.trace_path_unknown(delta_time,
173-
&distance,
174-
&self.location,
175-
&velocity) {
174+
if direction.norm_squared() != <F as Zero>::zero() {
175+
if let Some((new_location, new_direction))
176+
= universe.trace_path_unknown(delta_time,
177+
&distance,
178+
&self.location,
179+
&direction) {
176180
let rotation_scale = direction.angle_between(&new_direction);
177181

178182
if rotation_scale == <F as Zero>::zero() {

src/universe/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,6 @@ impl<F: CustomFloat, P: CustomPoint<F, V>, V: CustomVector<F, P>, U: Universe<F,
368368
.try_write()
369369
.expect("Could not update the camera. It is already borrowed.");
370370

371-
camera.update(delta_time, context, self)
371+
camera.update(delta_time, context, self);
372372
}
373373
}

0 commit comments

Comments
 (0)