summaryrefslogtreecommitdiff
path: root/scene/animation/animation_blend_tree.h
diff options
context:
space:
mode:
Diffstat (limited to 'scene/animation/animation_blend_tree.h')
-rw-r--r--scene/animation/animation_blend_tree.h169
1 files changed, 85 insertions, 84 deletions
diff --git a/scene/animation/animation_blend_tree.h b/scene/animation/animation_blend_tree.h
index 7ebe3f5444..258443a999 100644
--- a/scene/animation/animation_blend_tree.h
+++ b/scene/animation/animation_blend_tree.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -34,27 +34,26 @@
#include "scene/animation/animation_tree.h"
class AnimationNodeAnimation : public AnimationRootNode {
-
GDCLASS(AnimationNodeAnimation, AnimationRootNode);
StringName animation;
- StringName time;
+ StringName time = "time";
- uint64_t last_version;
- bool skip;
+ uint64_t last_version = 0;
+ bool skip = false;
protected:
- void _validate_property(PropertyInfo &property) const;
+ void _validate_property(PropertyInfo &property) const override;
static void _bind_methods();
public:
- void get_parameter_list(List<PropertyInfo> *r_list) const;
+ void get_parameter_list(List<PropertyInfo> *r_list) const override;
static Vector<String> (*get_editable_animation_list)();
- virtual String get_caption() const;
- virtual float process(float p_time, bool p_seek);
+ virtual String get_caption() const override;
+ virtual double process(double p_time, bool p_seek) override;
void set_animation(const StringName &p_name);
StringName get_animation() const;
@@ -72,35 +71,35 @@ public:
};
private:
- float fade_in;
- float fade_out;
+ float fade_in = 0.1;
+ float fade_out = 0.1;
- bool autorestart;
- float autorestart_delay;
- float autorestart_random_delay;
- MixMode mix;
+ bool autorestart = false;
+ float autorestart_delay = 1.0;
+ float autorestart_random_delay = 0.0;
+ MixMode mix = MIX_MODE_BLEND;
- bool sync;
+ bool sync = false;
/* bool active;
bool do_start;
float time;
float remaining;*/
- StringName active;
- StringName prev_active;
- StringName time;
- StringName remaining;
- StringName time_to_restart;
+ StringName active = "active";
+ StringName prev_active = "prev_active";
+ StringName time = "time";
+ StringName remaining = "remaining";
+ StringName time_to_restart = "time_to_restart";
protected:
static void _bind_methods();
public:
- virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
+ virtual String get_caption() const override;
void set_fadein_time(float p_time);
void set_fadeout_time(float p_time);
@@ -122,8 +121,8 @@ public:
void set_use_sync(bool p_sync);
bool is_using_sync() const;
- virtual bool has_filter() const;
- virtual float process(float p_time, bool p_seek);
+ virtual bool has_filter() const override;
+ virtual double process(double p_time, bool p_seek) override;
AnimationNodeOneShot();
};
@@ -133,23 +132,23 @@ VARIANT_ENUM_CAST(AnimationNodeOneShot::MixMode)
class AnimationNodeAdd2 : public AnimationNode {
GDCLASS(AnimationNodeAdd2, AnimationNode);
- StringName add_amount;
- bool sync;
+ StringName add_amount = "add_amount";
+ bool sync = false;
protected:
static void _bind_methods();
public:
- void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
+ virtual String get_caption() const override;
void set_use_sync(bool p_sync);
bool is_using_sync() const;
- virtual bool has_filter() const;
- virtual float process(float p_time, bool p_seek);
+ virtual bool has_filter() const override;
+ virtual double process(double p_time, bool p_seek) override;
AnimationNodeAdd2();
};
@@ -157,23 +156,23 @@ public:
class AnimationNodeAdd3 : public AnimationNode {
GDCLASS(AnimationNodeAdd3, AnimationNode);
- StringName add_amount;
- bool sync;
+ StringName add_amount = "add_amount";
+ bool sync = false;
protected:
static void _bind_methods();
public:
- void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
+ virtual String get_caption() const override;
void set_use_sync(bool p_sync);
bool is_using_sync() const;
- virtual bool has_filter() const;
- virtual float process(float p_time, bool p_seek);
+ virtual bool has_filter() const override;
+ virtual double process(double p_time, bool p_seek) override;
AnimationNodeAdd3();
};
@@ -181,23 +180,23 @@ public:
class AnimationNodeBlend2 : public AnimationNode {
GDCLASS(AnimationNodeBlend2, AnimationNode);
- StringName blend_amount;
- bool sync;
+ StringName blend_amount = "blend_amount";
+ bool sync = false;
protected:
static void _bind_methods();
public:
- virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
- virtual float process(float p_time, bool p_seek);
+ virtual String get_caption() const override;
+ virtual double process(double p_time, bool p_seek) override;
void set_use_sync(bool p_sync);
bool is_using_sync() const;
- virtual bool has_filter() const;
+ virtual bool has_filter() const override;
AnimationNodeBlend2();
};
@@ -211,33 +210,33 @@ protected:
static void _bind_methods();
public:
- virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
+ virtual String get_caption() const override;
void set_use_sync(bool p_sync);
bool is_using_sync() const;
- float process(float p_time, bool p_seek);
+ double process(double p_time, bool p_seek) override;
AnimationNodeBlend3();
};
class AnimationNodeTimeScale : public AnimationNode {
GDCLASS(AnimationNodeTimeScale, AnimationNode);
- StringName scale;
+ StringName scale = "scale";
protected:
static void _bind_methods();
public:
- virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
+ virtual String get_caption() const override;
- float process(float p_time, bool p_seek);
+ double process(double p_time, bool p_seek) override;
AnimationNodeTimeScale();
};
@@ -245,18 +244,18 @@ public:
class AnimationNodeTimeSeek : public AnimationNode {
GDCLASS(AnimationNodeTimeSeek, AnimationNode);
- StringName seek_pos;
+ StringName seek_pos = "seek_position";
protected:
static void _bind_methods();
public:
- virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
+ virtual String get_caption() const override;
- float process(float p_time, bool p_seek);
+ double process(double p_time, bool p_seek) override;
AnimationNodeTimeSeek();
};
@@ -268,14 +267,12 @@ class AnimationNodeTransition : public AnimationNode {
MAX_INPUTS = 32
};
struct InputData {
-
String name;
- bool auto_advance;
- InputData() { auto_advance = false; }
+ bool auto_advance = false;
};
InputData inputs[MAX_INPUTS];
- int enabled_inputs;
+ int enabled_inputs = 0;
/*
float prev_xfading;
@@ -284,25 +281,25 @@ class AnimationNodeTransition : public AnimationNode {
int current;
int prev_current; */
- StringName prev_xfading;
- StringName prev;
- StringName time;
- StringName current;
- StringName prev_current;
+ StringName prev_xfading = "prev_xfading";
+ StringName prev = "prev";
+ StringName time = "time";
+ StringName current = "current";
+ StringName prev_current = "prev_current";
- float xfade;
+ float xfade = 0.0;
void _update_inputs();
protected:
static void _bind_methods();
- void _validate_property(PropertyInfo &property) const;
+ void _validate_property(PropertyInfo &property) const override;
public:
- virtual void get_parameter_list(List<PropertyInfo> *r_list) const;
- virtual Variant get_parameter_default_value(const StringName &p_parameter) const;
+ virtual void get_parameter_list(List<PropertyInfo> *r_list) const override;
+ virtual Variant get_parameter_default_value(const StringName &p_parameter) const override;
- virtual String get_caption() const;
+ virtual String get_caption() const override;
void set_enabled_inputs(int p_inputs);
int get_enabled_inputs();
@@ -316,7 +313,7 @@ public:
void set_cross_fade_time(float p_fade);
float get_cross_fade_time() const;
- float process(float p_time, bool p_seek);
+ double process(double p_time, bool p_seek) override;
AnimationNodeTransition();
};
@@ -325,8 +322,8 @@ class AnimationNodeOutput : public AnimationNode {
GDCLASS(AnimationNodeOutput, AnimationNode);
public:
- virtual String get_caption() const;
- virtual float process(float p_time, bool p_seek);
+ virtual String get_caption() const override;
+ virtual double process(double p_time, bool p_seek) override;
AnimationNodeOutput();
};
@@ -348,12 +345,16 @@ class AnimationNodeBlendTree : public AnimationRootNode {
void _tree_changed();
void _node_changed(const StringName &p_node);
+ void _initialize_node_tree();
+
protected:
static void _bind_methods();
bool _set(const StringName &p_name, const Variant &p_value);
bool _get(const StringName &p_name, Variant &r_ret) const;
void _get_property_list(List<PropertyInfo> *p_list) const;
+ virtual void reset_state() override;
+
public:
enum ConnectionError {
CONNECTION_OK,
@@ -376,29 +377,29 @@ public:
void set_node_position(const StringName &p_node, const Vector2 &p_position);
Vector2 get_node_position(const StringName &p_node) const;
- virtual void get_child_nodes(List<ChildNode> *r_child_nodes);
+ virtual void get_child_nodes(List<ChildNode> *r_child_nodes) override;
void connect_node(const StringName &p_input_node, int p_input_index, const StringName &p_output_node);
void disconnect_node(const StringName &p_node, int p_input_index);
struct NodeConnection {
StringName input_node;
- int input_index;
+ int input_index = 0;
StringName output_node;
};
ConnectionError can_connect_node(const StringName &p_input_node, int p_input_index, const StringName &p_output_node) const;
void get_node_connections(List<NodeConnection> *r_connections) const;
- virtual String get_caption() const;
- virtual float process(float p_time, bool p_seek);
+ virtual String get_caption() const override;
+ virtual double process(double p_time, bool p_seek) override;
void get_node_list(List<StringName> *r_list);
void set_graph_offset(const Vector2 &p_graph_offset);
Vector2 get_graph_offset() const;
- virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name);
+ virtual Ref<AnimationNode> get_child_by_name(const StringName &p_name) override;
AnimationNodeBlendTree();
~AnimationNodeBlendTree();