1
0
mirror of https://github.com/godotengine/godot.git synced 2026-01-05 19:31:35 +00:00

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.
This commit is contained in:
jfons
2022-01-11 12:33:37 +01:00
committed by Joan Fons
parent 46624388d4
commit 5ebea2d120
11 changed files with 251 additions and 246 deletions

View File

@@ -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;