aboutsummaryrefslogtreecommitdiff
path: root/src/tool/room_tool.rs
diff options
context:
space:
mode:
authorArne Dußin2020-11-10 23:31:58 +0100
committerArne Dußin2020-11-10 23:31:58 +0100
commit6aabd0123961d90095df3cefefeb0718f94aa6fc (patch)
tree110e3b867ea15b4fbcb1a1ad086ec211e753811a /src/tool/room_tool.rs
parent94b9d39bd32ced4435951dc7a61612c3ea826b87 (diff)
downloadgraf_karto-6aabd0123961d90095df3cefefeb0718f94aa6fc.tar.gz
graf_karto-6aabd0123961d90095df3cefefeb0718f94aa6fc.zip
Add constant for the grid accuracy
0.5 was used as a magical number throughout the code for that until now, which I now changed.
Diffstat (limited to 'src/tool/room_tool.rs')
-rw-r--r--src/tool/room_tool.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/tool/room_tool.rs b/src/tool/room_tool.rs
index bb719e0..0ac74b5 100644
--- a/src/tool/room_tool.rs
+++ b/src/tool/room_tool.rs
@@ -2,7 +2,7 @@ use super::Tool;
use crate::button::Button;
use crate::config::{RoomToolKeybindings, ToolKeybindings};
use crate::dimension_indicator::DimensionIndicator;
-use crate::grid::snap_to_grid;
+use crate::grid::{snap_to_grid, SNAP_SIZE};
use crate::map_data::MapData;
use crate::math::{Rect, Vec2};
use crate::transform::Transform;
@@ -34,7 +34,7 @@ impl Tool for RoomTool {
let mouse_pos_m = transform.point_px_to_m(rl.get_mouse_position().into());
// Update the currently drawn rectangle, if it exists, and also its dimension indicator.
if let Some((ref pos1, ref mut pos2)) = &mut self.unfinished_rect {
- *pos2 = snap_to_grid(mouse_pos_m, 0.5);
+ *pos2 = snap_to_grid(mouse_pos_m, SNAP_SIZE);
self.dimension_indicator.update_dimensions(&[*pos1, *pos2]);
}
@@ -44,7 +44,7 @@ impl Tool for RoomTool {
let (pos1, pos2) = self.unfinished_rect.take().unwrap();
map_data.rooms_mut().push(Rect::bounding_rect(pos1, pos2));
} else if self.keybindings.start_draw.is_pressed(rl) {
- let snapped_mouse_pos = snap_to_grid(mouse_pos_m, 0.5);
+ let snapped_mouse_pos = snap_to_grid(mouse_pos_m, SNAP_SIZE);
self.unfinished_rect = Some((snapped_mouse_pos, snapped_mouse_pos))
}