| 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 SkeletonModification2DTwoBoneIK : public SkeletonModification2D { |
| 41 |
GDCLASS(SkeletonModification2DTwoBoneIK, SkeletonModification2D); |
| 42 |
|
| 43 |
private: |
| 44 |
NodePath target_node; |
| 45 |
ObjectID target_node_cache; |
| 46 |
float target_minimum_distance = 0; |
| 47 |
float target_maximum_distance = 0; |
| 48 |
bool flip_bend_direction = false; |
| 49 |
|
| 50 |
NodePath joint_one_bone2d_node; |
| 51 |
ObjectID joint_one_bone2d_node_cache; |
| 52 |
int joint_one_bone_idx = -1; |
| 53 |
|
| 54 |
NodePath joint_two_bone2d_node; |
| 55 |
ObjectID joint_two_bone2d_node_cache; |
| 56 |
int joint_two_bone_idx = -1; |
| 57 |
|
| 58 |
#ifdef TOOLS_ENABLED |
| 59 |
bool editor_draw_min_max = false; |
| 60 |
#endif |
| 61 |
|
| 62 |
void update_target_cache(); |
| 63 |
void update_joint_one_bone2d_cache(); |
| 64 |
void update_joint_two_bone2d_cache(); |
| 65 |
|
| 66 |
protected: |
| 67 |
static void _bind_methods(); |
| 68 |
bool _get(const StringName &p_path, Variant &r_ret) const; |
| 69 |
bool _set(const StringName &p_path, const Variant &p_value); |
| 70 |
void _get_property_list(List<PropertyInfo> *p_list) const; |
| 71 |
|
| 72 |
public: |
| 73 |
void _execute(float p_delta) override; |
| 74 |
void _setup_modification(SkeletonModificationStack2D *p_stack) override; |
| 75 |
void _draw_editor_gizmo() override; |
| 76 |
|
| 77 |
void set_target_node(const NodePath &p_target_node); |
| 78 |
NodePath get_target_node() const; |
| 79 |
|
| 80 |
void set_target_minimum_distance(float p_minimum_distance); |
| 81 |
float get_target_minimum_distance() const; |
| 82 |
void set_target_maximum_distance(float p_maximum_distance); |
| 83 |
float get_target_maximum_distance() const; |
| 84 |
void set_flip_bend_direction(bool p_flip_direction); |
| 85 |
bool get_flip_bend_direction() const; |
| 86 |
|
| 87 |
void set_joint_one_bone2d_node(const NodePath &p_node); |
| 88 |
NodePath get_joint_one_bone2d_node() const; |
| 89 |
void set_joint_one_bone_idx(int p_bone_idx); |
| 90 |
int get_joint_one_bone_idx() const; |
| 91 |
|
| 92 |
void set_joint_two_bone2d_node(const NodePath &p_node); |
| 93 |
NodePath get_joint_two_bone2d_node() const; |
| 94 |
void set_joint_two_bone_idx(int p_bone_idx); |
| 95 |
int get_joint_two_bone_idx() const; |
| 96 |
|
| 97 |
#ifdef TOOLS_ENABLED |
| 98 |
void set_editor_draw_min_max(bool p_draw); |
| 99 |
bool get_editor_draw_min_max() const; |
| 100 |
#endif |
| 101 |
|
| 102 |
SkeletonModification2DTwoBoneIK(); |
| 103 |
~SkeletonModification2DTwoBoneIK(); |
| 104 |
}; |