| 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 BoneConstraint3D : public SkeletonModifier3D { |
| 36 |
GDCLASS(BoneConstraint3D, SkeletonModifier3D); |
| 37 |
|
| 38 |
public: |
| 39 |
enum ReferenceType { |
| 40 |
REFERENCE_TYPE_BONE, |
| 41 |
REFERENCE_TYPE_NODE, |
| 42 |
}; |
| 43 |
|
| 44 |
struct BoneConstraint3DSetting { |
| 45 |
float amount = 1.0; |
| 46 |
|
| 47 |
String apply_bone_name; |
| 48 |
int apply_bone = -1; |
| 49 |
|
| 50 |
ReferenceType reference_type = REFERENCE_TYPE_BONE; |
| 51 |
|
| 52 |
String reference_bone_name; |
| 53 |
int reference_bone = -1; |
| 54 |
|
| 55 |
NodePath reference_node; |
| 56 |
}; |
| 57 |
|
| 58 |
protected: |
| 59 |
LocalVector<BoneConstraint3DSetting *> settings; |
| 60 |
|
| 61 |
bool _get(const StringName &p_path, Variant &r_ret) const; |
| 62 |
bool _set(const StringName &p_path, const Variant &p_value); |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
void get_property_list(List<PropertyInfo> *p_list) const; |
| 67 |
void _validate_dynamic_prop(PropertyInfo &p_property) const; |
| 68 |
|
| 69 |
virtual void _validate_bone_names() override; |
| 70 |
static void _bind_methods(); |
| 71 |
|
| 72 |
virtual void _process_modification(double p_delta) override; |
| 73 |
|
| 74 |
virtual void _process_constraint_by_bone(int p_index, Skeleton3D *p_skeleton, int p_apply_bone, int p_reference_bone, float p_amount); |
| 75 |
virtual void _process_constraint_by_node(int p_index, Skeleton3D *p_skeleton, int p_apply_bone, const NodePath &p_reference_node, float p_amount); |
| 76 |
virtual void _validate_setting(int p_index); |
| 77 |
|
| 78 |
public: |
| 79 |
void set_amount(int p_index, float p_amount); |
| 80 |
float get_amount(int p_index) const; |
| 81 |
|
| 82 |
void set_apply_bone_name(int p_index, const String &p_bone_name); |
| 83 |
String get_apply_bone_name(int p_index) const; |
| 84 |
void set_apply_bone(int p_index, int p_bone); |
| 85 |
int get_apply_bone(int p_index) const; |
| 86 |
|
| 87 |
void set_reference_type(int p_index, ReferenceType p_type); |
| 88 |
ReferenceType get_reference_type(int p_index) const; |
| 89 |
|
| 90 |
void set_reference_bone_name(int p_index, const String &p_bone_name); |
| 91 |
String get_reference_bone_name(int p_index) const; |
| 92 |
void set_reference_bone(int p_index, int p_bone); |
| 93 |
int get_reference_bone(int p_index) const; |
| 94 |
|
| 95 |
void set_reference_node(int p_index, const NodePath &p_node); |
| 96 |
NodePath get_reference_node(int p_index) const; |
| 97 |
|
| 98 |
void set_setting_count(int p_count); |
| 99 |
int get_setting_count() const; |
| 100 |
|
| 101 |
void clear_settings(); |
| 102 |
|
| 103 |
~BoneConstraint3D(); |
| 104 |
}; |
| 105 |
|
| 106 |
VARIANT_ENUM_CAST(BoneConstraint3D::ReferenceType); |