| 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/2d/skeleton_2d.h" |
| 34 |
#include "scene/resources/2d/skeleton/skeleton_modification_2d.h" |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
class SkeletonModification2DCCDIK : public SkeletonModification2D { |
| 41 |
GDCLASS(SkeletonModification2DCCDIK, SkeletonModification2D); |
| 42 |
|
| 43 |
private: |
| 44 |
struct CCDIK_Joint_Data2D { |
| 45 |
int bone_idx = -1; |
| 46 |
NodePath bone2d_node; |
| 47 |
ObjectID bone2d_node_cache; |
| 48 |
bool rotate_from_joint = false; |
| 49 |
|
| 50 |
bool enable_constraint = false; |
| 51 |
float constraint_angle_min = 0; |
| 52 |
float constraint_angle_max = (2.0 * Math::PI); |
| 53 |
bool constraint_angle_invert = false; |
| 54 |
bool constraint_in_localspace = true; |
| 55 |
|
| 56 |
bool editor_draw_gizmo = true; |
| 57 |
}; |
| 58 |
|
| 59 |
Vector<CCDIK_Joint_Data2D> ccdik_data_chain; |
| 60 |
|
| 61 |
NodePath target_node; |
| 62 |
ObjectID target_node_cache; |
| 63 |
void update_target_cache(); |
| 64 |
|
| 65 |
NodePath tip_node; |
| 66 |
ObjectID tip_node_cache; |
| 67 |
void update_tip_cache(); |
| 68 |
|
| 69 |
void ccdik_joint_update_bone2d_cache(int p_joint_idx); |
| 70 |
void _execute_ccdik_joint(int p_joint_idx, Node2D *p_target, Node2D *p_tip); |
| 71 |
|
| 72 |
protected: |
| 73 |
static void _bind_methods(); |
| 74 |
bool _set(const StringName &p_path, const Variant &p_value); |
| 75 |
bool _get(const StringName &p_path, Variant &r_ret) const; |
| 76 |
void _get_property_list(List<PropertyInfo> *p_list) const; |
| 77 |
|
| 78 |
public: |
| 79 |
void _execute(float p_delta) override; |
| 80 |
void _setup_modification(SkeletonModificationStack2D *p_stack) override; |
| 81 |
void _draw_editor_gizmo() override; |
| 82 |
|
| 83 |
void set_target_node(const NodePath &p_target_node); |
| 84 |
NodePath get_target_node() const; |
| 85 |
void set_tip_node(const NodePath &p_tip_node); |
| 86 |
NodePath get_tip_node() const; |
| 87 |
|
| 88 |
int get_ccdik_data_chain_length(); |
| 89 |
void set_ccdik_data_chain_length(int p_new_length); |
| 90 |
|
| 91 |
void set_ccdik_joint_bone2d_node(int p_joint_idx, const NodePath &p_target_node); |
| 92 |
NodePath get_ccdik_joint_bone2d_node(int p_joint_idx) const; |
| 93 |
void set_ccdik_joint_bone_index(int p_joint_idx, int p_bone_idx); |
| 94 |
int get_ccdik_joint_bone_index(int p_joint_idx) const; |
| 95 |
|
| 96 |
void set_ccdik_joint_rotate_from_joint(int p_joint_idx, bool p_rotate_from_joint); |
| 97 |
bool get_ccdik_joint_rotate_from_joint(int p_joint_idx) const; |
| 98 |
void set_ccdik_joint_enable_constraint(int p_joint_idx, bool p_constraint); |
| 99 |
bool get_ccdik_joint_enable_constraint(int p_joint_idx) const; |
| 100 |
void set_ccdik_joint_constraint_angle_min(int p_joint_idx, float p_angle_min); |
| 101 |
float get_ccdik_joint_constraint_angle_min(int p_joint_idx) const; |
| 102 |
void set_ccdik_joint_constraint_angle_max(int p_joint_idx, float p_angle_max); |
| 103 |
float get_ccdik_joint_constraint_angle_max(int p_joint_idx) const; |
| 104 |
void set_ccdik_joint_constraint_angle_invert(int p_joint_idx, bool p_invert); |
| 105 |
bool get_ccdik_joint_constraint_angle_invert(int p_joint_idx) const; |
| 106 |
void set_ccdik_joint_constraint_in_localspace(int p_joint_idx, bool p_constraint_in_localspace); |
| 107 |
bool get_ccdik_joint_constraint_in_localspace(int p_joint_idx) const; |
| 108 |
void set_ccdik_joint_editor_draw_gizmo(int p_joint_idx, bool p_draw_gizmo); |
| 109 |
bool get_ccdik_joint_editor_draw_gizmo(int p_joint_idx) const; |
| 110 |
|
| 111 |
SkeletonModification2DCCDIK(); |
| 112 |
~SkeletonModification2DCCDIK(); |
| 113 |
}; |