1
0
Fork 0
mirror of https://github.com/Orama-Interactive/Pixelorama.git synced 2025-01-18 09:09:47 +00:00

Fix crash when using the move tool snapped to the grid

This commit is contained in:
Emmanouil Papadeas 2024-09-12 18:26:42 +03:00
parent f62770ece9
commit 1b48eac843

View file

@ -18,16 +18,18 @@ func _input(event: InputEvent) -> void:
_snap_to_grid = true _snap_to_grid = true
_offset = _offset.snapped(Global.grid_size) _offset = _offset.snapped(Global.grid_size)
if Global.current_project.has_selection and selection_node.is_moving_content: if Global.current_project.has_selection and selection_node.is_moving_content:
var prev_pos: Vector2 = selection_node.big_bounding_rectangle.position var prev_pos: Vector2i = selection_node.big_bounding_rectangle.position
selection_node.big_bounding_rectangle.position = prev_pos.snapped(Global.grid_size) selection_node.big_bounding_rectangle.position = Vector2i(
prev_pos.snapped(Global.grid_size)
)
# The first time transform_snap_grid is enabled then _snap_position() is not called # The first time transform_snap_grid is enabled then _snap_position() is not called
# and the selection had wrong offset, so do selection offsetting here # and the selection had wrong offset, so do selection offsetting here
var grid_offset := Global.grid_offset var grid_offset := Vector2i(
grid_offset = Vector2( fmod(Global.grid_offset.x, Global.grid_size.x),
fmod(grid_offset.x, Global.grid_size.x), fmod(grid_offset.y, Global.grid_size.y) fmod(Global.grid_offset.y, Global.grid_size.y)
) )
selection_node.big_bounding_rectangle.position += grid_offset selection_node.big_bounding_rectangle.position += grid_offset
selection_node.marching_ants_outline.offset += ( selection_node.marching_ants_outline.offset += Vector2(
selection_node.big_bounding_rectangle.position - prev_pos selection_node.big_bounding_rectangle.position - prev_pos
) )
elif event.is_action_released("transform_snap_grid"): elif event.is_action_released("transform_snap_grid"):