Merge pull request #61626 from Haydoggo/path-editor-handle-swap

Swap Path3DGizmo control points order
This commit is contained in:
Rémi Verschelde 2022-06-02 18:51:36 +02:00 committed by GitHub
commit 1baee2189c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -52,7 +52,7 @@ String Path3DGizmo::get_handle_name(int p_id, bool p_secondary) const {
int idx = p_id / 2; int idx = p_id / 2;
int t = p_id % 2; int t = p_id % 2;
String n = TTR("Curve Point #") + itos(idx); String n = TTR("Curve Point #") + itos(idx);
if (t == 0) { if (t == 1) {
n += " In"; n += " In";
} else { } else {
n += " Out"; n += " Out";
@ -78,7 +78,7 @@ Variant Path3DGizmo::get_handle_value(int p_id, bool p_secondary) const {
int t = p_id % 2; int t = p_id % 2;
Vector3 ofs; Vector3 ofs;
if (t == 0) { if (t == 1) {
ofs = c->get_point_in(idx); ofs = c->get_point_in(idx);
} else { } else {
ofs = c->get_point_out(idx); ofs = c->get_point_out(idx);
@ -144,7 +144,7 @@ void Path3DGizmo::set_handle(int p_id, bool p_secondary, Camera3D *p_camera, con
local.snap(Vector3(snap, snap, snap)); local.snap(Vector3(snap, snap, snap));
} }
if (t == 0) { if (t == 1) {
c->set_point_in(idx, local); c->set_point_in(idx, local);
if (Path3DEditorPlugin::singleton->mirror_angle_enabled()) { if (Path3DEditorPlugin::singleton->mirror_angle_enabled()) {
c->set_point_out(idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -local : (-local.normalized() * orig_out_length)); c->set_point_out(idx, Path3DEditorPlugin::singleton->mirror_length_enabled() ? -local : (-local.normalized() * orig_out_length));
@ -184,7 +184,7 @@ void Path3DGizmo::commit_handle(int p_id, bool p_secondary, const Variant &p_res
int idx = p_id / 2; int idx = p_id / 2;
int t = p_id % 2; int t = p_id % 2;
if (t == 0) { if (t == 1) {
if (p_cancel) { if (p_cancel) {
c->set_point_in(p_id, p_restore); c->set_point_in(p_id, p_restore);
return; return;
@ -263,17 +263,17 @@ void Path3DGizmo::redraw() {
for (int i = 0; i < c->get_point_count(); i++) { for (int i = 0; i < c->get_point_count(); i++) {
Vector3 p = c->get_point_position(i); Vector3 p = c->get_point_position(i);
handles.push_back(p); handles.push_back(p);
if (i > 0) { // push Out points first so they get selected if the In and Out points are on top of each other.
v3p.push_back(p);
v3p.push_back(p + c->get_point_in(i));
sec_handles.push_back(p + c->get_point_in(i));
}
if (i < c->get_point_count() - 1) { if (i < c->get_point_count() - 1) {
v3p.push_back(p); v3p.push_back(p);
v3p.push_back(p + c->get_point_out(i)); v3p.push_back(p + c->get_point_out(i));
sec_handles.push_back(p + c->get_point_out(i)); sec_handles.push_back(p + c->get_point_out(i));
} }
if (i > 0) {
v3p.push_back(p);
v3p.push_back(p + c->get_point_in(i));
sec_handles.push_back(p + c->get_point_in(i));
}
} }
if (v3p.size() > 1) { if (v3p.size() > 1) {