mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Create an undo/redo action when pinning a SoftBody3D point in the editor
Previously, if you pinned a point by clicking on one of the soft body vertex handles, the scene was not marked as modified, and the action could not be undone by hitting Ctrl + Z. Co-authored-by: Tomasz Chabora <kobewi4e@gmail.com>
This commit is contained in:
committed by
Hugo Locurcio
parent
17fb6e3bd0
commit
edfe631c7c
@@ -30,6 +30,7 @@
|
||||
|
||||
#include "soft_body_3d_gizmo_plugin.h"
|
||||
|
||||
#include "editor/editor_undo_redo_manager.h"
|
||||
#include "scene/3d/physics/soft_body_3d.h"
|
||||
|
||||
SoftBody3DGizmoPlugin::SoftBody3DGizmoPlugin() {
|
||||
@@ -106,7 +107,15 @@ Variant SoftBody3DGizmoPlugin::get_handle_value(const EditorNode3DGizmo *p_gizmo
|
||||
|
||||
void SoftBody3DGizmoPlugin::commit_handle(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) {
|
||||
SoftBody3D *soft_body = Object::cast_to<SoftBody3D>(p_gizmo->get_node_3d());
|
||||
soft_body->pin_point_toggle(p_id);
|
||||
const bool is_pinned = soft_body->is_point_pinned(p_id);
|
||||
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(vformat(is_pinned ? TTR("Remove SoftBody3D pinned point %d") : TTR("Add SoftBody3D pinned point %d"), p_id));
|
||||
undo_redo->add_do_method(soft_body, "set_point_pinned", p_id, !is_pinned);
|
||||
undo_redo->add_do_method(soft_body, "update_gizmos");
|
||||
undo_redo->add_undo_method(soft_body, "set_point_pinned", p_id, is_pinned);
|
||||
undo_redo->add_undo_method(soft_body, "update_gizmos");
|
||||
undo_redo->commit_action();
|
||||
}
|
||||
|
||||
bool SoftBody3DGizmoPlugin::is_handle_highlighted(const EditorNode3DGizmo *p_gizmo, int p_id, bool p_secondary) const {
|
||||
|
||||
Reference in New Issue
Block a user