From c7e4eeb8a47b78e65dd35b506b559e592ad71e90 Mon Sep 17 00:00:00 2001 From: Silc Renew Date: Sun, 31 Jul 2022 23:35:19 +0900 Subject: Add simple auto mapping to BoneMapper Co-authored-by: K. S. Ernest (iFire) Lee --- scene/resources/bone_map.cpp | 12 +++++++++--- scene/resources/bone_map.h | 4 +--- scene/resources/skeleton_profile.cpp | 2 +- 3 files changed, 11 insertions(+), 7 deletions(-) (limited to 'scene/resources') diff --git a/scene/resources/bone_map.cpp b/scene/resources/bone_map.cpp index f4697a09b8..dfaf82f36a 100644 --- a/scene/resources/bone_map.cpp +++ b/scene/resources/bone_map.cpp @@ -82,9 +82,13 @@ StringName BoneMap::get_skeleton_bone_name(StringName p_profile_bone_name) const return bone_map.get(p_profile_bone_name); } -void BoneMap::set_skeleton_bone_name(StringName p_profile_bone_name, const StringName p_skeleton_bone_name) { +void BoneMap::_set_skeleton_bone_name(StringName p_profile_bone_name, const StringName p_skeleton_bone_name) { ERR_FAIL_COND(!bone_map.has(p_profile_bone_name)); bone_map.insert(p_profile_bone_name, p_skeleton_bone_name); +} + +void BoneMap::set_skeleton_bone_name(StringName p_profile_bone_name, const StringName p_skeleton_bone_name) { + _set_skeleton_bone_name(p_profile_bone_name, p_skeleton_bone_name); emit_signal("bone_map_updated"); } @@ -167,8 +171,10 @@ void BoneMap::_bind_methods() { ADD_SIGNAL(MethodInfo("profile_updated")); } -void BoneMap::_validate_property(PropertyInfo &p_property) const { - // +void BoneMap::_validate_property(PropertyInfo &property) const { + if (property.name == "bonemap" || property.name == "profile") { + property.usage = PROPERTY_USAGE_NO_EDITOR; + } } BoneMap::BoneMap() { diff --git a/scene/resources/bone_map.h b/scene/resources/bone_map.h index e1bb571df9..a07a776e27 100644 --- a/scene/resources/bone_map.h +++ b/scene/resources/bone_map.h @@ -50,9 +50,6 @@ protected: static void _bind_methods(); public: - int get_profile_type() const; - void set_profile_type(const int p_profile_type); - Ref get_profile() const; void set_profile(const Ref &p_profile); @@ -60,6 +57,7 @@ public: StringName get_skeleton_bone_name(StringName p_profile_bone_name) const; void set_skeleton_bone_name(StringName p_profile_bone_name, const StringName p_skeleton_bone_name); + void _set_skeleton_bone_name(StringName p_profile_bone_name, const StringName p_skeleton_bone_name); // Avoid to emit signal for editor. StringName find_profile_bone_name(StringName p_skeleton_bone_name) const; diff --git a/scene/resources/skeleton_profile.cpp b/scene/resources/skeleton_profile.cpp index 875d2dcff7..1367ea86dd 100644 --- a/scene/resources/skeleton_profile.cpp +++ b/scene/resources/skeleton_profile.cpp @@ -506,7 +506,7 @@ SkeletonProfileHumanoid::SkeletonProfileHumanoid() { bones.write[5].reference_pose = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.1, 0); bones.write[5].handle_offset = Vector2(0.5, 0.23); bones.write[5].group = "Body"; - bones.write[5].require = true; + bones.write[5].require = false; bones.write[6].bone_name = "Head"; bones.write[6].bone_parent = "Neck"; -- cgit v1.2.3