summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/3d/skeleton.cpp23
-rw-r--r--scene/3d/skeleton.h2
-rw-r--r--scene/animation/animation_tree_player.cpp2
3 files changed, 24 insertions, 3 deletions
diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp
index a4a43c1a88..417fe90d7c 100644
--- a/scene/3d/skeleton.cpp
+++ b/scene/3d/skeleton.cpp
@@ -153,6 +153,24 @@ void Skeleton::_notification(int p_what) {
case NOTIFICATION_EXIT_WORLD: {
} break;
+ case NOTIFICATION_TRANSFORM_CHANGED: {
+
+ if (dirty)
+ break; //will be eventually updated
+
+ //if moved, just update transforms
+ VisualServer *vs = VisualServer::get_singleton();
+ Bone *bonesptr = &bones[0];
+ int len = bones.size();
+ Transform global_transform = get_global_transform();
+ Transform global_transform_inverse = global_transform.affine_inverse();
+
+ for (int i = 0; i < len; i++) {
+
+ Bone &b = bonesptr[i];
+ vs->skeleton_bone_set_transform(skeleton, i, global_transform * (b.transform_final * global_transform_inverse));
+ }
+ } break;
case NOTIFICATION_UPDATE_SKELETON: {
VisualServer *vs = VisualServer::get_singleton();
@@ -242,8 +260,8 @@ void Skeleton::_notification(int p_what) {
}
}
- Transform transform = b.pose_global * b.rest_global_inverse;
- vs->skeleton_bone_set_transform(skeleton, i, global_transform * (transform * global_transform_inverse));
+ b.transform_final = b.pose_global * b.rest_global_inverse;
+ vs->skeleton_bone_set_transform(skeleton, i, global_transform * (b.transform_final * global_transform_inverse));
for (List<uint32_t>::Element *E = b.nodes_bound.front(); E; E = E->next()) {
@@ -547,6 +565,7 @@ Skeleton::Skeleton() {
rest_global_inverse_dirty = true;
dirty = false;
skeleton = VisualServer::get_singleton()->skeleton_create();
+ set_notify_transform(true);
}
Skeleton::~Skeleton() {
diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h
index fdc1100472..11ff728474 100644
--- a/scene/3d/skeleton.h
+++ b/scene/3d/skeleton.h
@@ -57,6 +57,8 @@ class Skeleton : public Spatial {
bool custom_pose_enable;
Transform custom_pose;
+ Transform transform_final;
+
List<uint32_t> nodes_bound;
Bone() {
diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp
index a50047e426..d110984bbc 100644
--- a/scene/animation/animation_tree_player.cpp
+++ b/scene/animation/animation_tree_player.cpp
@@ -556,7 +556,7 @@ float AnimationTreePlayer::_process_node(const StringName &p_node, AnimationNode
return _process_node(osn->inputs[0].node, r_prev_anim, p_time, p_seek, p_fallback_weight, p_weights);
}
- float os_seek = p_seek;
+ bool os_seek = p_seek;
if (p_seek)
osn->time = p_time;