Added back set_bone_pose to Skeleton, as I don't see any reason not to have it. Also improved it it.

This commit is contained in:
Relintai 2022-08-09 18:31:47 +02:00
parent 6d293dc7a3
commit 27aaa70037
3 changed files with 23 additions and 1 deletions

View File

@ -190,6 +190,14 @@
[b]Note:[/b] [code]parent_idx[/code] must be less than [code]bone_idx[/code].
</description>
</method>
<method name="set_bone_pose">
<return type="void" />
<argument index="0" name="bone_idx" type="int" />
<argument index="1" name="pose" type="Transform" />
<description>
Sets the pose transform for bone [code]bone_idx[/code]. Prefer set_bone_pose_position, set_bone_pose_rotation, or set_bone_pose_scale instead.
</description>
</method>
<method name="set_bone_pose_position">
<return type="void" />
<argument index="0" name="bone_idx" type="int" />

View File

@ -571,6 +571,19 @@ void Skeleton::clear_bones() {
}
// posing api
void Skeleton::set_bone_pose(int p_bone, const Transform &p_pose) {
const int bone_size = bones.size();
ERR_FAIL_INDEX(p_bone, bone_size);
bones.write[p_bone].pose_position = p_pose.origin;
bones.write[p_bone].pose_rotation = p_pose.basis.get_rotation_quat();
bones.write[p_bone].pose_scale = p_pose.basis.get_scale();
bones.write[p_bone].pose_cache_dirty = true;
if (is_inside_tree()) {
_make_dirty();
}
}
void Skeleton::set_bone_pose_position(int p_bone, const Vector3 &p_position) {
const int bone_size = bones.size();
@ -983,6 +996,7 @@ void Skeleton::_bind_methods() {
ClassDB::bind_method(D_METHOD("clear_bones"), &Skeleton::clear_bones);
ClassDB::bind_method(D_METHOD("set_bone_pose", "bone_idx", "pose"), &Skeleton::set_bone_pose);
ClassDB::bind_method(D_METHOD("set_bone_pose_position", "bone_idx", "position"), &Skeleton::set_bone_pose_position);
ClassDB::bind_method(D_METHOD("set_bone_pose_rotation", "bone_idx", "rotation"), &Skeleton::set_bone_pose_rotation);
ClassDB::bind_method(D_METHOD("set_bone_pose_scale", "bone_idx", "scale"), &Skeleton::set_bone_pose_scale);

View File

@ -206,7 +206,7 @@ public:
void clear_bones();
// posing api
void set_bone_pose(int p_bone, const Transform &p_pose);
void set_bone_pose_position(int p_bone, const Vector3 &p_position);
void set_bone_pose_rotation(int p_bone, const Quat &p_rotation);
void set_bone_pose_scale(int p_bone, const Vector3 &p_scale);