Merge pull request #32362 from fire/skeleton-custom-bind-pose
Restore bone_custom_pose in skeletons
This commit is contained in:
commit
0d253845c2
2 changed files with 33 additions and 1 deletions
|
@ -245,6 +245,9 @@ void Skeleton::_notification(int p_what) {
|
|||
if (b.enabled) {
|
||||
|
||||
Transform pose = b.pose;
|
||||
if (b.custom_pose_enable) {
|
||||
pose = b.custom_pose * pose;
|
||||
}
|
||||
if (b.parent >= 0) {
|
||||
|
||||
b.pose_global = bonesptr[b.parent].pose_global * pose;
|
||||
|
@ -267,7 +270,9 @@ void Skeleton::_notification(int p_what) {
|
|||
if (b.enabled) {
|
||||
|
||||
Transform pose = b.pose;
|
||||
|
||||
if (b.custom_pose_enable) {
|
||||
pose = b.custom_pose * pose;
|
||||
}
|
||||
if (b.parent >= 0) {
|
||||
|
||||
b.pose_global = bonesptr[b.parent].pose_global * (b.rest * pose);
|
||||
|
@ -533,6 +538,23 @@ Transform Skeleton::get_bone_pose(int p_bone) const {
|
|||
return bones[p_bone].pose;
|
||||
}
|
||||
|
||||
void Skeleton::set_bone_custom_pose(int p_bone, const Transform &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 = p_custom_pose;
|
||||
|
||||
_make_dirty();
|
||||
}
|
||||
|
||||
Transform Skeleton::get_bone_custom_pose(int p_bone) const {
|
||||
|
||||
ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform());
|
||||
return bones[p_bone].custom_pose;
|
||||
}
|
||||
|
||||
void Skeleton::_make_dirty() {
|
||||
|
||||
if (dirty)
|
||||
|
@ -808,6 +830,9 @@ void Skeleton::_bind_methods() {
|
|||
ClassDB::bind_method(D_METHOD("set_bone_global_pose_override", "bone_idx", "pose", "amount", "persistent"), &Skeleton::set_bone_global_pose_override, DEFVAL(false));
|
||||
ClassDB::bind_method(D_METHOD("get_bone_global_pose", "bone_idx"), &Skeleton::get_bone_global_pose);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_bone_custom_pose", "bone_idx"), &Skeleton::get_bone_custom_pose);
|
||||
ClassDB::bind_method(D_METHOD("set_bone_custom_pose", "bone_idx", "custom_pose"), &Skeleton::set_bone_custom_pose);
|
||||
|
||||
#ifndef _3D_DISABLED
|
||||
|
||||
ClassDB::bind_method(D_METHOD("physical_bones_stop_simulation"), &Skeleton::physical_bones_stop_simulation);
|
||||
|
|
|
@ -87,6 +87,9 @@ private:
|
|||
Transform pose;
|
||||
Transform pose_global;
|
||||
|
||||
bool custom_pose_enable;
|
||||
Transform custom_pose;
|
||||
|
||||
float global_pose_override_amount;
|
||||
bool global_pose_override_reset;
|
||||
Transform global_pose_override;
|
||||
|
@ -102,6 +105,7 @@ private:
|
|||
parent = -1;
|
||||
enabled = true;
|
||||
disable_rest = false;
|
||||
custom_pose_enable = false;
|
||||
global_pose_override_amount = 0;
|
||||
global_pose_override_reset = false;
|
||||
#ifndef _3D_DISABLED
|
||||
|
@ -184,6 +188,9 @@ public:
|
|||
void set_bone_pose(int p_bone, const Transform &p_pose);
|
||||
Transform get_bone_pose(int p_bone) const;
|
||||
|
||||
void set_bone_custom_pose(int p_bone, const Transform &p_custom_pose);
|
||||
Transform get_bone_custom_pose(int p_bone) const;
|
||||
|
||||
void localize_rests(); // used for loaders and tools
|
||||
int get_process_order(int p_idx);
|
||||
|
||||
|
|
Loading…
Reference in a new issue