summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorSilc Renew <tokage.it.lab@gmail.com>2022-07-31 23:35:19 +0900
committerSilc Renew <tokage.it.lab@gmail.com>2022-08-23 16:43:33 +0900
commitc7e4eeb8a47b78e65dd35b506b559e592ad71e90 (patch)
treef164973f63687784f3a7ddc3e9c65d57cb203fac /scene/resources
parent3f3ade9e5b19e8d13169a9af45a80877b3fa1c65 (diff)
Add simple auto mapping to BoneMapper
Co-authored-by: K. S. Ernest (iFire) Lee <ernest.lee@chibifire.com>
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/bone_map.cpp12
-rw-r--r--scene/resources/bone_map.h4
-rw-r--r--scene/resources/skeleton_profile.cpp2
3 files changed, 11 insertions, 7 deletions
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<SkeletonProfile> get_profile() const;
void set_profile(const Ref<SkeletonProfile> &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";