Add bone name/idx matching validation & virtual func to skel Modifier

This commit is contained in:
Silc Lizard (Tokage) Renew 2025-03-25 01:37:25 +09:00
parent 1b4ed4c038
commit 17d068963f
9 changed files with 85 additions and 2 deletions

View file

@ -58,6 +58,15 @@ void SpringBoneCollision3D::_validate_property(PropertyInfo &p_property) const {
}
}
void SpringBoneCollision3D::_validate_bone_name() {
// Prior bone name.
if (!bone_name.is_empty()) {
set_bone_name(bone_name);
} else if (bone != -1) {
set_bone(bone);
}
}
Skeleton3D *SpringBoneCollision3D::get_skeleton() const {
SpringBoneSimulator3D *parent = Object::cast_to<SpringBoneSimulator3D>(get_parent());
if (!parent) {
@ -173,6 +182,15 @@ void SpringBoneCollision3D::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::QUATERNION, "rotation_offset"), "set_rotation_offset", "get_rotation_offset");
}
void SpringBoneCollision3D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE:
case NOTIFICATION_PARENTED: {
_validate_bone_name();
} break;
}
}
Vector3 SpringBoneCollision3D::collide(const Transform3D &p_center, float p_bone_radius, float p_bone_length, const Vector3 &p_current) const {
return _collide(p_center, p_bone_radius, p_bone_length, p_current);
}