diff options
Diffstat (limited to 'scene/3d/skeleton_3d.cpp')
-rw-r--r-- | scene/3d/skeleton_3d.cpp | 59 |
1 files changed, 24 insertions, 35 deletions
diff --git a/scene/3d/skeleton_3d.cpp b/scene/3d/skeleton_3d.cpp index 93f7dbcd91..f9d613a4bb 100644 --- a/scene/3d/skeleton_3d.cpp +++ b/scene/3d/skeleton_3d.cpp @@ -135,9 +135,9 @@ void Skeleton3D::_get_property_list(List<PropertyInfo> *p_list) const { String prep = "bones/" + itos(i) + "/"; p_list->push_back(PropertyInfo(Variant::STRING, prep + "name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::INT, prep + "parent", PROPERTY_HINT_RANGE, "-1," + itos(bones.size() - 1) + ",1", PROPERTY_USAGE_NOEDITOR)); - p_list->push_back(PropertyInfo(Variant::TRANSFORM, prep + "rest", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); + p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, prep + "rest", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); p_list->push_back(PropertyInfo(Variant::BOOL, prep + "enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); - p_list->push_back(PropertyInfo(Variant::TRANSFORM, prep + "pose", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); + p_list->push_back(PropertyInfo(Variant::TRANSFORM3D, prep + "pose", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); } } @@ -211,7 +211,7 @@ void Skeleton3D::_notification(int p_what) { if (b.disable_rest) { if (b.enabled) { - Transform pose = b.pose; + Transform3D pose = b.pose; if (b.custom_pose_enable) { pose = b.custom_pose * pose; } @@ -227,14 +227,14 @@ void Skeleton3D::_notification(int p_what) { b.pose_global = bonesptr[b.parent].pose_global; b.pose_global_no_override = bonesptr[b.parent].pose_global; } else { - b.pose_global = Transform(); - b.pose_global_no_override = Transform(); + b.pose_global = Transform3D(); + b.pose_global_no_override = Transform3D(); } } } else { if (b.enabled) { - Transform pose = b.pose; + Transform3D pose = b.pose; if (b.custom_pose_enable) { pose = b.custom_pose * pose; } @@ -337,7 +337,6 @@ void Skeleton3D::_notification(int p_what) { } break; -#ifndef _3D_DISABLED case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: { // This is active only if the skeleton animates the physical bones // and the state of the bone is not active. @@ -356,7 +355,6 @@ void Skeleton3D::_notification(int p_what) { set_physics_process_internal(true); } } break; -#endif } } @@ -368,7 +366,7 @@ void Skeleton3D::clear_bones_global_pose_override() { _make_dirty(); } -void Skeleton3D::set_bone_global_pose_override(int p_bone, const Transform &p_pose, float p_amount, bool p_persistent) { +void Skeleton3D::set_bone_global_pose_override(int p_bone, const Transform3D &p_pose, float p_amount, bool p_persistent) { ERR_FAIL_INDEX(p_bone, bones.size()); bones.write[p_bone].global_pose_override_amount = p_amount; bones.write[p_bone].global_pose_override = p_pose; @@ -376,16 +374,16 @@ void Skeleton3D::set_bone_global_pose_override(int p_bone, const Transform &p_po _make_dirty(); } -Transform Skeleton3D::get_bone_global_pose(int p_bone) const { - ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform()); +Transform3D Skeleton3D::get_bone_global_pose(int p_bone) const { + ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform3D()); if (dirty) { const_cast<Skeleton3D *>(this)->notification(NOTIFICATION_UPDATE_SKELETON); } return bones[p_bone].pose_global; } -Transform Skeleton3D::get_bone_global_pose_no_override(int p_bone) const { - ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform()); +Transform3D Skeleton3D::get_bone_global_pose_no_override(int p_bone) const { + ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform3D()); if (dirty) { const_cast<Skeleton3D *>(this)->notification(NOTIFICATION_UPDATE_SKELETON); } @@ -496,15 +494,14 @@ int Skeleton3D::get_bone_parent(int p_bone) const { return bones[p_bone].parent; } -void Skeleton3D::set_bone_rest(int p_bone, const Transform &p_rest) { +void Skeleton3D::set_bone_rest(int p_bone, const Transform3D &p_rest) { ERR_FAIL_INDEX(p_bone, bones.size()); bones.write[p_bone].rest = p_rest; _make_dirty(); } - -Transform Skeleton3D::get_bone_rest(int p_bone) const { - ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform()); +Transform3D Skeleton3D::get_bone_rest(int p_bone) const { + ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform3D()); return bones[p_bone].rest; } @@ -563,7 +560,7 @@ void Skeleton3D::clear_bones() { // posing api -void Skeleton3D::set_bone_pose(int p_bone, const Transform &p_pose) { +void Skeleton3D::set_bone_pose(int p_bone, const Transform3D &p_pose) { ERR_FAIL_INDEX(p_bone, bones.size()); bones.write[p_bone].pose = p_pose; @@ -571,24 +568,23 @@ void Skeleton3D::set_bone_pose(int p_bone, const Transform &p_pose) { _make_dirty(); } } - -Transform Skeleton3D::get_bone_pose(int p_bone) const { - ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform()); +Transform3D Skeleton3D::get_bone_pose(int p_bone) const { + ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform3D()); return bones[p_bone].pose; } -void Skeleton3D::set_bone_custom_pose(int p_bone, const Transform &p_custom_pose) { +void Skeleton3D::set_bone_custom_pose(int p_bone, const Transform3D &p_custom_pose) { ERR_FAIL_INDEX(p_bone, bones.size()); //ERR_FAIL_COND( !is_inside_scene() ); - bones.write[p_bone].custom_pose_enable = (p_custom_pose != Transform()); + bones.write[p_bone].custom_pose_enable = (p_custom_pose != Transform3D()); bones.write[p_bone].custom_pose = p_custom_pose; _make_dirty(); } -Transform Skeleton3D::get_bone_custom_pose(int p_bone) const { - ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform()); +Transform3D Skeleton3D::get_bone_custom_pose(int p_bone) const { + ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform3D()); return bones[p_bone].custom_pose; } @@ -623,8 +619,6 @@ void Skeleton3D::localize_rests() { } } -#ifndef _3D_DISABLED - void Skeleton3D::set_animate_physical_bones(bool p_animate) { animate_physical_bones = p_animate; @@ -698,7 +692,7 @@ void Skeleton3D::_rebuild_physical_bones_cache() { const int b_size = bones.size(); for (int i = 0; i < b_size; ++i) { PhysicalBone3D *parent_pb = _get_physical_bone_parent(i); - if (parent_pb != bones[i].physical_bone) { + if (parent_pb != bones[i].cache_parent_physical_bone) { bones.write[i].cache_parent_physical_bone = parent_pb; if (bones[i].physical_bone) { bones[i].physical_bone->_on_bone_parent_changed(); @@ -785,8 +779,6 @@ void Skeleton3D::physical_bones_remove_collision_exception(RID p_exception) { _physical_bones_add_remove_collision_exception(false, this, p_exception); } -#endif // _3D_DISABLED - void Skeleton3D::_skin_changed() { _make_dirty(); } @@ -852,11 +844,11 @@ Ref<SkinReference> Skeleton3D::register_skin(const Ref<Skin> &p_skin) { } // helper functions -Transform Skeleton3D::bone_transform_to_world_transform(Transform p_bone_transform) { +Transform3D Skeleton3D::bone_transform_to_world_transform(Transform3D p_bone_transform) { return get_global_transform() * p_bone_transform; } -Transform Skeleton3D::world_transform_to_bone_transform(Transform p_world_transform) { +Transform3D Skeleton3D::world_transform_to_bone_transform(Transform3D p_world_transform) { return get_global_transform().affine_inverse() * p_world_transform; } @@ -900,8 +892,6 @@ void Skeleton3D::_bind_methods() { ClassDB::bind_method(D_METHOD("bone_transform_to_world_transform", "bone_transform"), &Skeleton3D::bone_transform_to_world_transform); ClassDB::bind_method(D_METHOD("world_transform_to_bone_transform", "world_transform"), &Skeleton3D::world_transform_to_bone_transform); -#ifndef _3D_DISABLED - ClassDB::bind_method(D_METHOD("set_animate_physical_bones"), &Skeleton3D::set_animate_physical_bones); ClassDB::bind_method(D_METHOD("get_animate_physical_bones"), &Skeleton3D::get_animate_physical_bones); @@ -911,7 +901,6 @@ void Skeleton3D::_bind_methods() { ClassDB::bind_method(D_METHOD("physical_bones_remove_collision_exception", "exception"), &Skeleton3D::physical_bones_remove_collision_exception); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "animate_physical_bones"), "set_animate_physical_bones", "get_animate_physical_bones"); -#endif // _3D_DISABLED #ifdef TOOLS_ENABLED ADD_SIGNAL(MethodInfo("pose_updated")); |