| 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/animation/animation_tree.h" |
| 34 |
|
| 35 |
class AnimationNodeBlendSpace1D : public AnimationRootNode { |
| 36 |
GDCLASS(AnimationNodeBlendSpace1D, AnimationRootNode); |
| 37 |
|
| 38 |
public: |
| 39 |
enum BlendMode { |
| 40 |
BLEND_MODE_INTERPOLATED, |
| 41 |
BLEND_MODE_DISCRETE, |
| 42 |
BLEND_MODE_DISCRETE_CARRY, |
| 43 |
}; |
| 44 |
|
| 45 |
protected: |
| 46 |
enum { |
| 47 |
MAX_BLEND_POINTS = 64 |
| 48 |
}; |
| 49 |
|
| 50 |
struct BlendPoint { |
| 51 |
StringName name; |
| 52 |
Ref<AnimationRootNode> node; |
| 53 |
float position = 0.0; |
| 54 |
}; |
| 55 |
|
| 56 |
BlendPoint blend_points[MAX_BLEND_POINTS]; |
| 57 |
int blend_points_used = 0; |
| 58 |
|
| 59 |
float max_space = 1.0; |
| 60 |
float min_space = -1.0; |
| 61 |
|
| 62 |
float snap = 0.1; |
| 63 |
|
| 64 |
String value_label = "value"; |
| 65 |
|
| 66 |
void _add_blend_point(int p_index, const Ref<AnimationRootNode> &p_node); |
| 67 |
|
| 68 |
StringName blend_position = "blend_position"; |
| 69 |
StringName closest = "closest"; |
| 70 |
|
| 71 |
BlendMode blend_mode = BLEND_MODE_INTERPOLATED; |
| 72 |
|
| 73 |
bool sync = false; |
| 74 |
|
| 75 |
void _validate_property(PropertyInfo &p_property) const; |
| 76 |
static void _bind_methods(); |
| 77 |
|
| 78 |
virtual void _tree_changed() override; |
| 79 |
virtual void _animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) override; |
| 80 |
virtual void _animation_node_removed(const ObjectID &p_oid, const StringName &p_node) override; |
| 81 |
|
| 82 |
public: |
| 83 |
virtual void get_parameter_list(List<PropertyInfo> *r_list) const override; |
| 84 |
virtual Variant get_parameter_default_value(const StringName &p_parameter) const override; |
| 85 |
|
| 86 |
virtual void get_child_nodes(List<ChildNode> *r_child_nodes) override; |
| 87 |
|
| 88 |
void add_blend_point(const Ref<AnimationRootNode> &p_node, float p_position, int p_at_index = -1); |
| 89 |
void set_blend_point_position(int p_point, float p_position); |
| 90 |
void set_blend_point_node(int p_point, const Ref<AnimationRootNode> &p_node); |
| 91 |
|
| 92 |
float get_blend_point_position(int p_point) const; |
| 93 |
Ref<AnimationRootNode> get_blend_point_node(int p_point) const; |
| 94 |
void remove_blend_point(int p_point); |
| 95 |
int get_blend_point_count() const; |
| 96 |
|
| 97 |
void set_min_space(float p_min); |
| 98 |
float get_min_space() const; |
| 99 |
|
| 100 |
void set_max_space(float p_max); |
| 101 |
float get_max_space() const; |
| 102 |
|
| 103 |
void set_snap(float p_snap); |
| 104 |
float get_snap() const; |
| 105 |
|
| 106 |
void set_value_label(const String &p_label); |
| 107 |
String get_value_label() const; |
| 108 |
|
| 109 |
void set_blend_mode(BlendMode p_blend_mode); |
| 110 |
BlendMode get_blend_mode() const; |
| 111 |
|
| 112 |
void set_use_sync(bool p_sync); |
| 113 |
bool is_using_sync() const; |
| 114 |
|
| 115 |
virtual NodeTimeInfo _process(const AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only = false) override; |
| 116 |
String get_caption() const override; |
| 117 |
|
| 118 |
Ref<AnimationNode> get_child_by_name(const StringName &p_name) const override; |
| 119 |
|
| 120 |
AnimationNodeBlendSpace1D(); |
| 121 |
~AnimationNodeBlendSpace1D(); |
| 122 |
}; |
| 123 |
|
| 124 |
VARIANT_ENUM_CAST(AnimationNodeBlendSpace1D::BlendMode) |