diff options
author | jfons <joan.fonssanchez@gmail.com> | 2022-01-11 12:33:37 +0100 |
---|---|---|
committer | Joan Fons <joan.fonssanchez@gmail.com> | 2022-01-12 14:21:20 +0100 |
commit | 5ebea2d120d1d85d0b9f6379bcafd5c78a8d702d (patch) | |
tree | 642aa28af8d5ccf97aab2bbe8a6a028d74c1e3e0 /editor/plugins/path_3d_editor_plugin.cpp | |
parent | 46624388d48379350ca9b9020bc55eef61102145 (diff) | |
download | redot-engine-5ebea2d120d1d85d0b9f6379bcafd5c78a8d702d.tar.gz |
Fix secondary handles in editor gizmos
Primary and secondary handles are no longer differentiated by their ids, so a bool was added to tell them apart in all the handle-related methods.
Includes a minor fix in CollisionPolygon3DEditor, unrelated to editor gizmos.
Diffstat (limited to 'editor/plugins/path_3d_editor_plugin.cpp')
-rw-r--r-- | editor/plugins/path_3d_editor_plugin.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/editor/plugins/path_3d_editor_plugin.cpp b/editor/plugins/path_3d_editor_plugin.cpp index c31b893498..cb62dcdccc 100644 --- a/editor/plugins/path_3d_editor_plugin.cpp +++ b/editor/plugins/path_3d_editor_plugin.cpp @@ -36,17 +36,17 @@ #include "node_3d_editor_plugin.h" #include "scene/resources/curve.h" -String Path3DGizmo::get_handle_name(int p_id) const { +String Path3DGizmo::get_handle_name(int p_id, bool p_secondary) const { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) { return ""; } - if (p_id < c->get_point_count()) { + if (!p_secondary) { return TTR("Curve Point #") + itos(p_id); } - p_id = p_id - c->get_point_count() + 1; + p_id += 1; // Account for the first point only having an "out" handle int idx = p_id / 2; int t = p_id % 2; @@ -60,18 +60,18 @@ String Path3DGizmo::get_handle_name(int p_id) const { return n; } -Variant Path3DGizmo::get_handle_value(int p_id) const { +Variant Path3DGizmo::get_handle_value(int p_id, bool p_secondary) const { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) { return Variant(); } - if (p_id < c->get_point_count()) { + if (!p_secondary) { original = c->get_point_position(p_id); return original; } - p_id = p_id - c->get_point_count() + 1; + p_id += 1; // Account for the first point only having an "out" handle int idx = p_id / 2; int t = p_id % 2; @@ -88,7 +88,7 @@ Variant Path3DGizmo::get_handle_value(int p_id) const { return ofs; } -void Path3DGizmo::set_handle(int p_id, Camera3D *p_camera, const Point2 &p_point) { +void Path3DGizmo::set_handle(int p_id, bool p_secondary, Camera3D *p_camera, const Point2 &p_point) { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) { return; @@ -100,7 +100,7 @@ void Path3DGizmo::set_handle(int p_id, Camera3D *p_camera, const Point2 &p_point Vector3 ray_dir = p_camera->project_ray_normal(p_point); // Setting curve point positions - if (p_id < c->get_point_count()) { + if (!p_secondary) { const Plane p = Plane(p_camera->get_transform().basis.get_axis(2), gt.xform(original)); Vector3 inters; @@ -118,7 +118,7 @@ void Path3DGizmo::set_handle(int p_id, Camera3D *p_camera, const Point2 &p_point return; } - p_id = p_id - c->get_point_count() + 1; + p_id += 1; // Account for the first point only having an "out" handle int idx = p_id / 2; int t = p_id % 2; @@ -157,7 +157,7 @@ void Path3DGizmo::set_handle(int p_id, Camera3D *p_camera, const Point2 &p_point } } -void Path3DGizmo::commit_handle(int p_id, const Variant &p_restore, bool p_cancel) { +void Path3DGizmo::commit_handle(int p_id, bool p_secondary, const Variant &p_restore, bool p_cancel) { Ref<Curve3D> c = path->get_curve(); if (c.is_null()) { return; @@ -165,7 +165,7 @@ void Path3DGizmo::commit_handle(int p_id, const Variant &p_restore, bool p_cance UndoRedo *ur = Node3DEditor::get_singleton()->get_undo_redo(); - if (p_id < c->get_point_count()) { + if (!p_secondary) { if (p_cancel) { c->set_point_position(p_id, p_restore); return; @@ -178,7 +178,7 @@ void Path3DGizmo::commit_handle(int p_id, const Variant &p_restore, bool p_cance return; } - p_id = p_id - c->get_point_count() + 1; + p_id += 1; // Account for the first point only having an "out" handle int idx = p_id / 2; int t = p_id % 2; |