diff options
| author | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-20 00:04:53 +0200 |
|---|---|---|
| committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-06-20 00:04:53 +0200 |
| commit | 3158f6378e4267e9d9405b985ccb4cde9cd82164 (patch) | |
| tree | 5d739daf7801af5bc01ce02c9f987a325ab9ed11 /modules/gridmap | |
| parent | 6aa7fd7d8bb196948a433f2fec18b76125f787fb (diff) | |
| parent | 0defaefdba7c7e747191445dc5ef0e5256b54d60 (diff) | |
| download | redot-engine-3158f6378e4267e9d9405b985ccb4cde9cd82164.tar.gz | |
Merge pull request #78265 from caseyjoy/57068_gridmap_grid_position
Update GridMap editor grid location when required
Diffstat (limited to 'modules/gridmap')
| -rw-r--r-- | modules/gridmap/editor/grid_map_editor_plugin.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/modules/gridmap/editor/grid_map_editor_plugin.cpp b/modules/gridmap/editor/grid_map_editor_plugin.cpp index 14f7b9b502..de04d376a0 100644 --- a/modules/gridmap/editor/grid_map_editor_plugin.cpp +++ b/modules/gridmap/editor/grid_map_editor_plugin.cpp @@ -704,6 +704,9 @@ EditorPlugin::AfterGUIInput GridMapEditor::forward_spatial_input_event(Camera3D Ref<InputEventMouseMotion> mm = p_event; if (mm.is_valid()) { + // Update the grid, to check if the grid needs to be moved to a tile cursor. + update_grid(); + if (do_input_action(p_camera, mm->get_position(), false)) { return EditorPlugin::AFTER_GUI_INPUT_STOP; } @@ -951,7 +954,8 @@ void GridMapEditor::update_grid() { grid_ofs[edit_axis] = edit_floor[edit_axis] * node->get_cell_size()[edit_axis]; - edit_grid_xform.origin = grid_ofs; + // If there's a valid tile cursor, offset the grid, otherwise move it back to the node. + edit_grid_xform.origin = cursor_instance.is_valid() ? grid_ofs : Vector3(); edit_grid_xform.basis = Basis(); for (int i = 0; i < 3; i++) { @@ -1076,6 +1080,9 @@ void GridMapEditor::_notification(int p_what) { Ref<MeshLibrary> cgmt = node->get_mesh_library(); if (cgmt.operator->() != last_mesh_library) { update_palette(); + // Update the cursor and grid in case the library is changed or removed. + _update_cursor_instance(); + update_grid(); } } break; |
