Debian Codegraph @

scene/animation/animation_blend_space_2d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* animation_blend_space_2d.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "scene/animation/animation_tree.h"
34
35 class AnimationNodeBlendSpace2D : public AnimationRootNode {
36 GDCLASS(AnimationNodeBlendSpace2D, 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 Vector2 position;
54 };
55
56 BlendPoint blend_points[MAX_BLEND_POINTS];
57 int blend_points_used = 0;
58
59 struct BlendTriangle {
60 int points[3] = {};
61 };
62
63 Vector<BlendTriangle> triangles;
64
65 StringName blend_position = "blend_position";
66 StringName closest = "closest";
67 Vector2 max_space = Vector2(1, 1);
68 Vector2 min_space = Vector2(-1, -1);
69 Vector2 snap = Vector2(0.1, 0.1);
70 String x_label = "x";
71 String y_label = "y";
72 BlendMode blend_mode = BLEND_MODE_INTERPOLATED;
73
74 void _add_blend_point(int p_index, const Ref<AnimationRootNode> &p_node);
75 void _set_triangles(const Vector<int> &p_triangles);
76 Vector<int> _get_triangles() const;
77
78 void _blend_triangle(const Vector2 &p_pos, const Vector2 *p_points, float *r_weights);
79
80 bool auto_triangles = true;
81 bool triangles_dirty = false;
82
83 void _update_triangles();
84 void _queue_auto_triangles();
85
86 bool sync = false;
87
88 void _validate_property(PropertyInfo &p_property) const;
89 static void _bind_methods();
90
91 virtual void _tree_changed() override;
92 virtual void _animation_node_renamed(const ObjectID &p_oid, const String &p_old_name, const String &p_new_name) override;
93 virtual void _animation_node_removed(const ObjectID &p_oid, const StringName &p_node) override;
94
95 public:
96 virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
97 virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
98
99 virtual void get_child_nodes(List<ChildNode> *r_child_nodes) override;
100
101 void add_blend_point(const Ref<AnimationRootNode> &p_node, const Vector2 &p_position, int p_at_index = -1);
102 void set_blend_point_position(int p_point, const Vector2 &p_position);
103 void set_blend_point_node(int p_point, const Ref<AnimationRootNode> &p_node);
104 Vector2 get_blend_point_position(int p_point) const;
105 Ref<AnimationRootNode> get_blend_point_node(int p_point) const;
106 void remove_blend_point(int p_point);
107 int get_blend_point_count() const;
108
109 bool has_triangle(int p_x, int p_y, int p_z) const;
110 void add_triangle(int p_x, int p_y, int p_z, int p_at_index = -1);
111 int get_triangle_point(int p_triangle, int p_point);
112 void remove_triangle(int p_triangle);
113 int get_triangle_count() const;
114
115 void set_min_space(const Vector2 &p_min);
116 Vector2 get_min_space() const;
117
118 void set_max_space(const Vector2 &p_max);
119 Vector2 get_max_space() const;
120
121 void set_snap(const Vector2 &p_snap);
122 Vector2 get_snap() const;
123
124 void set_x_label(const String &p_label);
125 String get_x_label() const;
126
127 void set_y_label(const String &p_label);
128 String get_y_label() const;
129
130 virtual NodeTimeInfo _process(const AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only = false) override;
131 virtual String get_caption() const override;
132
133 Vector2 get_closest_point(const Vector2 &p_point);
134
135 void set_auto_triangles(bool p_enable);
136 bool get_auto_triangles() const;
137
138 void set_blend_mode(BlendMode p_blend_mode);
139 BlendMode get_blend_mode() const;
140
141 void set_use_sync(bool p_sync);
142 bool is_using_sync() const;
143
144 virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name) const override;
145
146 AnimationNodeBlendSpace2D();
147 ~AnimationNodeBlendSpace2D();
148 };
149
150 VARIANT_ENUM_CAST(AnimationNodeBlendSpace2D::BlendMode)