| 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 |
|
| 35 |
class LimitAngularVelocityModifier3D : public SkeletonModifier3D { |
| 36 |
GDCLASS(LimitAngularVelocityModifier3D, SkeletonModifier3D); |
| 37 |
|
| 38 |
public: |
| 39 |
struct BoneJoint { |
| 40 |
StringName name; |
| 41 |
int bone = -1; |
| 42 |
}; |
| 43 |
|
| 44 |
struct Chain { |
| 45 |
BoneJoint root_bone; |
| 46 |
BoneJoint end_bone; |
| 47 |
}; |
| 48 |
|
| 49 |
typedef Pair<int, Quaternion> BoneRot; |
| 50 |
|
| 51 |
private: |
| 52 |
bool exclude = false; |
| 53 |
double max_angular_velocity = Math::TAU; |
| 54 |
|
| 55 |
LocalVector<Chain> chains; |
| 56 |
LocalVector<BoneJoint> joints; |
| 57 |
LocalVector<BoneRot> bones; |
| 58 |
|
| 59 |
bool joints_dirty = false; |
| 60 |
bool init_needed = true; |
| 61 |
|
| 62 |
protected: |
| 63 |
bool _get(const StringName &p_path, Variant &r_ret) const; |
| 64 |
bool _set(const StringName &p_path, const Variant &p_value); |
| 65 |
void _get_property_list(List<PropertyInfo> *p_list) const; |
| 66 |
void _validate_property(PropertyInfo &p_property) const; |
| 67 |
|
| 68 |
static void _bind_methods(); |
| 69 |
|
| 70 |
void _notification(int p_what); |
| 71 |
|
| 72 |
virtual void _set_active(bool p_active) override; |
| 73 |
virtual void _skeleton_changed(Skeleton3D *p_old, Skeleton3D *p_new) override; |
| 74 |
|
| 75 |
virtual void _validate_bone_names() override; |
| 76 |
|
| 77 |
void _make_joints_dirty(); |
| 78 |
void _update_joints(); |
| 79 |
bool _is_joint_contained(int p_bone); |
| 80 |
|
| 81 |
|
| 82 |
int _get_joint_count() const; |
| 83 |
|
| 84 |
virtual void _process_modification(double p_delta) override; |
| 85 |
|
| 86 |
public: |
| 87 |
void set_root_bone_name(int p_index, const String &p_bone_name); |
| 88 |
String get_root_bone_name(int p_index) const; |
| 89 |
void set_root_bone(int p_index, int p_bone); |
| 90 |
int get_root_bone(int p_index) const; |
| 91 |
|
| 92 |
void set_end_bone_name(int p_index, const String &p_bone_name); |
| 93 |
String get_end_bone_name(int p_index) const; |
| 94 |
void set_end_bone(int p_index, int p_bone); |
| 95 |
int get_end_bone(int p_index) const; |
| 96 |
|
| 97 |
String get_joint_bone_name(int p_index) const; |
| 98 |
int get_joint_bone(int p_index) const; |
| 99 |
|
| 100 |
void set_chain_count(int p_count); |
| 101 |
int get_chain_count() const; |
| 102 |
void clear_chains(); |
| 103 |
|
| 104 |
void set_max_angular_velocity(double p_angular_velocity); |
| 105 |
double get_max_angular_velocity() const; |
| 106 |
|
| 107 |
void set_exclude(bool p_exclude); |
| 108 |
bool is_exclude() const; |
| 109 |
|
| 110 |
void reset(); |
| 111 |
|
| 112 |
~LimitAngularVelocityModifier3D(); |
| 113 |
}; |