diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index d911e745db65..30fdd003af6f 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -1935,9 +1935,8 @@ void Node3DEditorViewport::_sinput(const Ref &p_event) { surface->queue_redraw(); } else { if (_edit.gizmo.is_valid()) { - if (_edit.original_mouse_pos != _edit.mouse_pos) { - _edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, _edit.gizmo_initial_value, false); - } + _edit.gizmo->commit_handle(_edit.gizmo_handle, _edit.gizmo_handle_secondary, _edit.gizmo_initial_value, false); + spatial_editor->get_single_selected_node()->update_gizmos(); _edit.gizmo = Ref(); break; } diff --git a/scene/3d/soft_body_3d.cpp b/scene/3d/soft_body_3d.cpp index 4fe5dd2385f4..ff2194fb61ba 100644 --- a/scene/3d/soft_body_3d.cpp +++ b/scene/3d/soft_body_3d.cpp @@ -200,12 +200,18 @@ bool SoftBody3D::_set_property_pinned_points_indices(const Array &p_indices) { int point_index; for (int i = 0; i < p_indices_size; ++i) { point_index = p_indices.get(i); - if (w[i].point_index != point_index) { - if (-1 != w[i].point_index) { + if (w[i].point_index != point_index || pinned_points.size() < p_indices_size) { + bool insert = false; + if (-1 != w[i].point_index && -1 == p_indices.find(w[i].point_index)) { pin_point(w[i].point_index, false); + insert = true; } w[i].point_index = point_index; - pin_point(w[i].point_index, true); + if (insert) { + pin_point(w[i].point_index, true, NodePath(), i); + } else { + pin_point(w[i].point_index, true); + } } } return true; @@ -668,10 +674,10 @@ void SoftBody3D::pin_point_toggle(int p_point_index) { pin_point(p_point_index, !(-1 != _has_pinned_point(p_point_index))); } -void SoftBody3D::pin_point(int p_point_index, bool pin, const NodePath &p_spatial_attachment_path) { +void SoftBody3D::pin_point(int p_point_index, bool pin, const NodePath &p_spatial_attachment_path, int p_insert_at) { _pin_point_on_physics_server(p_point_index, pin); if (pin) { - _add_pinned_point(p_point_index, p_spatial_attachment_path); + _add_pinned_point(p_point_index, p_spatial_attachment_path, p_insert_at); } else { _remove_pinned_point(p_point_index); } @@ -730,7 +736,7 @@ void SoftBody3D::_pin_point_on_physics_server(int p_point_index, bool pin) { PhysicsServer3D::get_singleton()->soft_body_pin_point(physics_rid, p_point_index, pin); } -void SoftBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_attachment_path) { +void SoftBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_attachment_path, int p_insert_at) { SoftBody3D::PinnedPoint *pinned_point; if (-1 == _get_pinned_point(p_point_index, pinned_point)) { // Create new @@ -743,7 +749,11 @@ void SoftBody3D::_add_pinned_point(int p_point_index, const NodePath &p_spatial_ pp.offset = (pp.spatial_attachment->get_global_transform().affine_inverse() * get_global_transform()).xform(PhysicsServer3D::get_singleton()->soft_body_get_point_global_position(physics_rid, pp.point_index)); } - pinned_points.push_back(pp); + if (-1 != p_insert_at) { + pinned_points.insert(p_insert_at, pp); + } else { + pinned_points.push_back(pp); + } } else { pinned_point->point_index = p_point_index; diff --git a/scene/3d/soft_body_3d.h b/scene/3d/soft_body_3d.h index ab30f7e654ff..4e9c39d65577 100644 --- a/scene/3d/soft_body_3d.h +++ b/scene/3d/soft_body_3d.h @@ -177,7 +177,7 @@ class SoftBody3D : public MeshInstance3D { Vector3 get_point_transform(int p_point_index); void pin_point_toggle(int p_point_index); - void pin_point(int p_point_index, bool pin, const NodePath &p_spatial_attachment_path = NodePath()); + void pin_point(int p_point_index, bool pin, const NodePath &p_spatial_attachment_path = NodePath(), int p_insert_at = -1); bool is_point_pinned(int p_point_index) const; void _pin_point_deferred(int p_point_index, bool pin, const NodePath p_spatial_attachment_path); @@ -193,7 +193,7 @@ class SoftBody3D : public MeshInstance3D { void _update_cache_pin_points_datas(); void _pin_point_on_physics_server(int p_point_index, bool pin); - void _add_pinned_point(int p_point_index, const NodePath &p_spatial_attachment_path); + void _add_pinned_point(int p_point_index, const NodePath &p_spatial_attachment_path, int p_insert_at = -1); void _reset_points_offsets(); void _remove_pinned_point(int p_point_index);