Skip to content

Commit

Permalink
Emit region AABB on undo/redo
Browse files Browse the repository at this point in the history
  • Loading branch information
TokisanGames committed Nov 3, 2024
1 parent deecc41 commit bbced6d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
# Terrain3D
project/test/
project/addons/godot-jolt/
project/addons/terrain_3d/bin/
project/_dev/
project/_export/
project/_tests/
project/test/
src/_archive/
_misc/
_patches/
*.zip

# Docs
doc/_build
doc/art/

# Godot-specific ignores (Include script cache. See godot issue #75388)
/project/.import/
Expand All @@ -36,4 +36,3 @@ export_presets.cfg
# Editors
.vscode/
.vs/
doc/art/
14 changes: 12 additions & 2 deletions src/terrain_3d_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,10 @@ void Terrain3DEditor::_store_undo() {
}
}

if (_undo_data.has("edited_area")) {
if (_terrain->get_data()->get_edited_area().has_volume()) {
_undo_data["edited_area"] = _terrain->get_data()->get_edited_area();
LOG(DEBUG, "Updating undo snapshot edited area: ", _undo_data["edited_area"]);
redo_data["edited_area"] = _terrain->get_data()->get_edited_area();
LOG(DEBUG, "Adding edited area to snapshots: ", _undo_data["edited_area"]);
}

// Store data in Godot's Undo/Redo Manager
Expand Down Expand Up @@ -573,6 +574,11 @@ void Terrain3DEditor::_apply_undo(const Dictionary &p_data) {
}
}

if (p_data.has("edited_area")) {
LOG(DEBUG, "Edited area: ", p_data["edited_area"]);
data->add_edited_area(p_data["edited_area"]);
}

if (p_data.has("added_regions")) {
LOG(DEBUG, "Added regions: ", p_data["added_regions"]);
TypedArray<Vector2i> region_locs = p_data["added_regions"];
Expand All @@ -589,6 +595,10 @@ void Terrain3DEditor::_apply_undo(const Dictionary &p_data) {
data->set_region_deleted(region_locs[i], false);
data->set_region_modified(region_locs[i], true);
LOG(DEBUG, "Marking region: ", region_locs[i], " -deleted, +modified");
Ref<Terrain3DRegion> region = data->get_region(region_locs[i]);
if (region.is_valid()) {
_send_region_aabb(region_locs[i], region->get_height_range());
}
}
}

Expand Down

0 comments on commit bbced6d

Please sign in to comment.