Debian Codegraph @

scene/animation/animation_blend_space_1d.h

raw symbols SCIP
1 /**************************************************************************/
2 /* animation_blend_space_1d.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 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)