diff options
Diffstat (limited to 'src/tool/room_tool.rs')
| -rw-r--r-- | src/tool/room_tool.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/tool/room_tool.rs b/src/tool/room_tool.rs index 8288c97..6a9ad55 100644 --- a/src/tool/room_tool.rs +++ b/src/tool/room_tool.rs @@ -29,7 +29,11 @@ impl Tool for RoomTool { let mouse_pos_m = transform.point_px_to_m(rl.get_mouse_position()); // Update the currently drawn rectangle, if it exists if let Some((_, ref mut pos2)) = &mut self.unfinished_rect { - *pos2 = mouse_pos_m; + let snapped_mouse_pos = Vector2::new( + math::round(mouse_pos_m.x, 0.5), + math::round(mouse_pos_m.y, 0.5), + ); + *pos2 = snapped_mouse_pos; } // Start or finish drawing the currently unfinished rectangle @@ -38,7 +42,11 @@ impl Tool for RoomTool { self.room_rects.push(math::bounding_rect(pos1, pos2)); self.unfinished_rect = None; } else { - self.unfinished_rect = Some((mouse_pos_m, mouse_pos_m)) + let snapped_mouse_pos = Vector2::new( + math::round(mouse_pos_m.x, 0.5), + math::round(mouse_pos_m.y, 0.5), + ); + self.unfinished_rect = Some((snapped_mouse_pos, snapped_mouse_pos)) } } |
