Truncate coordinates rather than using floor.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
30250a4310
commit
8e4369163a
10
src/core.rs
10
src/core.rs
|
@ -298,11 +298,11 @@ pub trait PointLike {
|
|||
fn y(&self) -> f32;
|
||||
|
||||
fn x_i32(&self) -> i32 {
|
||||
self.x().round() as i32
|
||||
self.x().trunc() as i32
|
||||
}
|
||||
|
||||
fn y_i32(&self) -> i32 {
|
||||
self.y().round() as i32
|
||||
self.y().trunc() as i32
|
||||
}
|
||||
|
||||
fn x_usize(&self) -> usize {
|
||||
|
@ -321,12 +321,12 @@ pub trait PointLike {
|
|||
(self.x_i32(), self.y_i32())
|
||||
}
|
||||
|
||||
fn floor(&self) -> (f32, f32) {
|
||||
(self.x().floor(), self.y().floor())
|
||||
fn trunc(&self) -> (f32, f32) {
|
||||
(self.x().trunc(), self.y().trunc())
|
||||
}
|
||||
|
||||
fn to_index(&self, width: usize) -> usize {
|
||||
((self.y_i32() * width as i32) + self.x_i32()) as usize
|
||||
(self.y_usize() * width) + self.x_usize()
|
||||
}
|
||||
|
||||
fn distance_squared(&self, other: &dyn PointLike) -> f32 {
|
||||
|
|
|
@ -132,7 +132,7 @@ where
|
|||
let mut features = features
|
||||
.iter()
|
||||
.filter(|v| visible_entities.contains(&v.0))
|
||||
.map(|v| (v.1.floor(), v.2))
|
||||
.map(|v| (v.1.trunc(), v.2))
|
||||
.collect::<Vec<((f32, f32), &ExplorationType)>>();
|
||||
if features.is_empty() {
|
||||
tts.speak("Nothing visible.", true)?;
|
||||
|
@ -166,7 +166,7 @@ where
|
|||
if let Some((coordinates, _)) = target {
|
||||
commands
|
||||
.entity(entity)
|
||||
.insert(Exploring(coordinates.floor()));
|
||||
.insert(Exploring(coordinates.trunc()));
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -291,7 +291,7 @@ where
|
|||
MapData: 'static + Clone + Default + Send + Sync,
|
||||
{
|
||||
if let Ok((coordinates, exploring, viewshed)) = explorer.get_single() {
|
||||
let coordinates = coordinates.floor();
|
||||
let coordinates = coordinates.trunc();
|
||||
let point = **exploring;
|
||||
let shape = Collider::cuboid(0.5 - f32::EPSILON, 0.5 - f32::EPSILON);
|
||||
let (known, idx) = if let Ok((map, revealed_tiles)) = map.get_single() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user