| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#include "scene/3d/skeleton_modifier_3d.h" |
| 34 |
#include "scene/resources/skeleton_profile.h" |
| 35 |
|
| 36 |
class RetargetModifier3D : public SkeletonModifier3D { |
| 37 |
GDCLASS(RetargetModifier3D, SkeletonModifier3D); |
| 38 |
|
| 39 |
public: |
| 40 |
enum TransformFlag { |
| 41 |
TRANSFORM_FLAG_POSITION = 1, |
| 42 |
TRANSFORM_FLAG_ROTATION = 2, |
| 43 |
TRANSFORM_FLAG_SCALE = 4, |
| 44 |
TRANSFORM_FLAG_ALL = TRANSFORM_FLAG_POSITION | TRANSFORM_FLAG_ROTATION | TRANSFORM_FLAG_SCALE, |
| 45 |
}; |
| 46 |
|
| 47 |
private: |
| 48 |
Ref<SkeletonProfile> profile; |
| 49 |
|
| 50 |
bool use_global_pose = false; |
| 51 |
BitField<TransformFlag> enable_flags = TRANSFORM_FLAG_ALL; |
| 52 |
|
| 53 |
struct RetargetBoneInfo { |
| 54 |
int bone_id = -1; |
| 55 |
Basis pre_basis; |
| 56 |
Basis post_basis; |
| 57 |
}; |
| 58 |
|
| 59 |
struct RetargetInfo { |
| 60 |
ObjectID skeleton_id; |
| 61 |
Vector<RetargetBoneInfo> humanoid_bone_rests; |
| 62 |
}; |
| 63 |
|
| 64 |
Vector<RetargetInfo> child_skeletons; |
| 65 |
Vector<int> source_bone_ids; |
| 66 |
|
| 67 |
void _update_child_skeleton_rests(int p_child_skeleton_idx); |
| 68 |
void _update_child_skeletons(); |
| 69 |
void _reset_child_skeleton_poses(); |
| 70 |
void _reset_child_skeletons(); |
| 71 |
|
| 72 |
#ifdef TOOLS_ENABLED |
| 73 |
void _force_update_child_skeletons(); |
| 74 |
#endif |
| 75 |
|
| 76 |
void cache_rests_with_reset(); |
| 77 |
void cache_rests(); |
| 78 |
Vector<RetargetBoneInfo> cache_bone_global_rests(Skeleton3D *p_skeleton); |
| 79 |
Vector<RetargetBoneInfo> cache_bone_rests(Skeleton3D *p_skeleton); |
| 80 |
Vector<RetargetBoneInfo> get_humanoid_bone_rests(Skeleton3D *p_skeleton); |
| 81 |
|
| 82 |
void _retarget_global_pose(); |
| 83 |
void _retarget_pose(); |
| 84 |
|
| 85 |
protected: |
| 86 |
virtual void _skeleton_changed(Skeleton3D *p_old, Skeleton3D *p_new) override; |
| 87 |
void _profile_changed(Ref<SkeletonProfile> p_old, Ref<SkeletonProfile> p_new); |
| 88 |
|
| 89 |
void _validate_property(PropertyInfo &p_property) const; |
| 90 |
|
| 91 |
static void _bind_methods(); |
| 92 |
virtual void _notification(int p_what); |
| 93 |
|
| 94 |
virtual void add_child_notify(Node *p_child) override; |
| 95 |
virtual void move_child_notify(Node *p_child) override; |
| 96 |
virtual void remove_child_notify(Node *p_child) override; |
| 97 |
|
| 98 |
virtual void _set_active(bool p_active) override; |
| 99 |
virtual void _process_modification(double p_delta) override; |
| 100 |
|
| 101 |
public: |
| 102 |
virtual PackedStringArray get_configuration_warnings() const override; |
| 103 |
|
| 104 |
void set_use_global_pose(bool p_use_global_pose); |
| 105 |
bool is_using_global_pose() const; |
| 106 |
void set_enable_flags(BitField<TransformFlag> p_enable_flags); |
| 107 |
BitField<TransformFlag> get_enable_flags() const; |
| 108 |
|
| 109 |
void set_position_enabled(bool p_enabled); |
| 110 |
bool is_position_enabled() const; |
| 111 |
void set_rotation_enabled(bool p_enabled); |
| 112 |
bool is_rotation_enabled() const; |
| 113 |
void set_scale_enabled(bool p_enabled); |
| 114 |
bool is_scale_enabled() const; |
| 115 |
|
| 116 |
void set_profile(Ref<SkeletonProfile> p_profile); |
| 117 |
Ref<SkeletonProfile> get_profile() const; |
| 118 |
|
| 119 |
#ifdef TOOLS_ENABLED |
| 120 |
virtual bool is_processed_on_saving() const override { return true; } |
| 121 |
#endif |
| 122 |
|
| 123 |
RetargetModifier3D(); |
| 124 |
virtual ~RetargetModifier3D(); |
| 125 |
}; |
| 126 |
|
| 127 |
VARIANT_BITFIELD_CAST(RetargetModifier3D::TransformFlag); |