diff options
Diffstat (limited to 'editor/plugins')
-rw-r--r-- | editor/plugins/skeleton_3d_editor_plugin.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/editor/plugins/skeleton_3d_editor_plugin.cpp b/editor/plugins/skeleton_3d_editor_plugin.cpp index ef171e9115..065683d632 100644 --- a/editor/plugins/skeleton_3d_editor_plugin.cpp +++ b/editor/plugins/skeleton_3d_editor_plugin.cpp @@ -419,8 +419,14 @@ PhysicalBone3D *Skeleton3DEditor::create_physical_bone(int bone_id, int bone_chi capsule_transform.basis = Basis(Vector3(1, 0, 0), Vector3(0, 0, 1), Vector3(0, -1, 0)); bone_shape->set_transform(capsule_transform); + /// Get an up vector not collinear with child rest origin + Vector3 up = Vector3(0, 1, 0); + if (up.cross(child_rest.origin).is_equal_approx(Vector3())) { + up = Vector3(0, 0, 1); + } + Transform3D body_transform; - body_transform.basis = Basis::looking_at(child_rest.origin); + body_transform.basis = Basis::looking_at(child_rest.origin, up); body_transform.origin = body_transform.basis.xform(Vector3(0, 0, -half_height)); Transform3D joint_transform; |