From f78b5b20f398b5dbcda13fae9e343eaa6c597a4a Mon Sep 17 00:00:00 2001 From: "K. S. Ernest (iFire) Lee" Date: Sat, 4 Nov 2023 19:39:30 -0700 Subject: [PATCH] Revert "Refactor kusudama limit cone center calculations" This reverts commit a150212d43e99017813139f33f8e56685f521f2d. --- src/many_bone_ik_3d.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/many_bone_ik_3d.cpp b/src/many_bone_ik_3d.cpp index 61eea704..4489889b 100644 --- a/src/many_bone_ik_3d.cpp +++ b/src/many_bone_ik_3d.cpp @@ -622,11 +622,16 @@ void ManyBoneIK3D::set_kusudama_limit_cone_center(int32_t p_effector_index, int3 ERR_FAIL_INDEX(p_effector_index, kusudama_limit_cones.size()); ERR_FAIL_INDEX(p_index, kusudama_limit_cones[p_effector_index].size()); Vector4 &cone = kusudama_limit_cones.write[p_effector_index].write[p_index]; + Basis basis; + basis.set_column(0, Vector3(1, 0, 0)); + basis.set_column(1, Vector3(0, 0, -1)); + basis.set_column(2, Vector3(0, 1, 0)); if (Math::is_zero_approx(p_center.length_squared())) { cone.x = 0; cone.y = 0; cone.z = 1; } else { + p_center = basis.xform(p_center); cone.x = p_center.x; cone.y = p_center.y; cone.z = p_center.z; @@ -648,7 +653,11 @@ Vector3 ManyBoneIK3D::get_kusudama_limit_cone_center(int32_t p_constraint_index, ret.x = cone.x; ret.y = cone.y; ret.z = cone.z; - return ret; + Basis basis; + basis.set_column(0, Vector3(1, 0, 0)); + basis.set_column(1, Vector3(0, 0, -1)); + basis.set_column(2, Vector3(0, 1, 0)); + return basis.xform_inv(ret); } void ManyBoneIK3D::set_constraint_name(int32_t p_index, String p_name) {