summaryrefslogtreecommitdiff
path: root/editor/plugins
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-02-09 11:15:43 +0100
committerGitHub <noreply@github.com>2020-02-09 11:15:43 +0100
commit23531207a5cde7d67692b667606ac3f6e8638853 (patch)
treeb442467cf4c4b3f1a3cbe97032d85dae81e2e04b /editor/plugins
parentde932a528512a6312e08ba6926b658a577168f9d (diff)
parent557d38cad3db98967c71a031298e703e3b5ed3c2 (diff)
Merge pull request #36008 from AndreaCatania/physical_bone_impr
Skeleton animates physical bones
Diffstat (limited to 'editor/plugins')
-rw-r--r--editor/plugins/skeleton_editor_plugin.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/editor/plugins/skeleton_editor_plugin.cpp b/editor/plugins/skeleton_editor_plugin.cpp
index 8b5fe7d2c5..9101c64eab 100644
--- a/editor/plugins/skeleton_editor_plugin.cpp
+++ b/editor/plugins/skeleton_editor_plugin.cpp
@@ -103,8 +103,10 @@ void SkeletonEditor::create_physical_skeleton() {
PhysicalBone *SkeletonEditor::create_physical_bone(int bone_id, int bone_child_id, const Vector<BoneInfo> &bones_infos) {
- real_t half_height(skeleton->get_bone_rest(bone_child_id).origin.length() * 0.5);
- real_t radius(half_height * 0.2);
+ const Transform child_rest = skeleton->get_bone_rest(bone_child_id);
+
+ const real_t half_height(child_rest.origin.length() * 0.5);
+ const real_t radius(half_height * 0.2);
CapsuleShape *bone_shape_capsule = memnew(CapsuleShape);
bone_shape_capsule->set_height((half_height - radius) * 2);
@@ -114,7 +116,8 @@ PhysicalBone *SkeletonEditor::create_physical_bone(int bone_id, int bone_child_i
bone_shape->set_shape(bone_shape_capsule);
Transform body_transform;
- body_transform.origin = Vector3(0, 0, -half_height);
+ body_transform.set_look_at(Vector3(0, 0, 0), child_rest.origin, Vector3(0, 1, 0));
+ body_transform.origin = body_transform.basis.xform(Vector3(0, 0, -half_height));
Transform joint_transform;
joint_transform.origin = Vector3(0, 0, half_height);