Skip to content

Commit

Permalink
State machine animation node
Browse files Browse the repository at this point in the history
  • Loading branch information
reduz committed Jun 25, 2018
1 parent c45a8a5 commit 4f5a7eb
Show file tree
Hide file tree
Showing 30 changed files with 3,660 additions and 13 deletions.
45 changes: 45 additions & 0 deletions core/method_ptrcall.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,58 @@ struct PtrToArg<const T *> {
} \
}

#define MAKE_VECARG_ALT(m_type, m_type_alt) \
template <> \
struct PtrToArg<Vector<m_type_alt> > { \
_FORCE_INLINE_ static Vector<m_type_alt> convert(const void *p_ptr) { \
const PoolVector<m_type> *dvs = reinterpret_cast<const PoolVector<m_type> *>(p_ptr); \
Vector<m_type_alt> ret; \
int len = dvs->size(); \
ret.resize(len); \
{ \
PoolVector<m_type>::Read r = dvs->read(); \
for (int i = 0; i < len; i++) { \
ret[i] = r[i]; \
} \
} \
return ret; \
} \
_FORCE_INLINE_ static void encode(Vector<m_type_alt> p_vec, void *p_ptr) { \
PoolVector<m_type> *dv = reinterpret_cast<PoolVector<m_type> *>(p_ptr); \
int len = p_vec.size(); \
dv->resize(len); \
{ \
PoolVector<m_type>::Write w = dv->write(); \
for (int i = 0; i < len; i++) { \
w[i] = p_vec[i]; \
} \
} \
} \
}; \
template <> \
struct PtrToArg<const Vector<m_type_alt> &> { \
_FORCE_INLINE_ static Vector<m_type_alt> convert(const void *p_ptr) { \
const PoolVector<m_type> *dvs = reinterpret_cast<const PoolVector<m_type> *>(p_ptr); \
Vector<m_type_alt> ret; \
int len = dvs->size(); \
ret.resize(len); \
{ \
PoolVector<m_type>::Read r = dvs->read(); \
for (int i = 0; i < len; i++) { \
ret[i] = r[i]; \
} \
} \
return ret; \
} \
}
MAKE_VECARG(String);
MAKE_VECARG(uint8_t);
MAKE_VECARG(int);
MAKE_VECARG(float);
MAKE_VECARG(Vector2);
MAKE_VECARG(Vector3);
MAKE_VECARG(Color);
MAKE_VECARG_ALT(String, StringName);

//for stuff that gets converted to Array vectors
#define MAKE_VECARR(m_type) \
Expand Down
1 change: 1 addition & 0 deletions core/type_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ MAKE_TEMPLATE_TYPE_INFO(Vector, Color, Variant::POOL_COLOR_ARRAY)
MAKE_TEMPLATE_TYPE_INFO(Vector, Variant, Variant::ARRAY)
MAKE_TEMPLATE_TYPE_INFO(Vector, RID, Variant::ARRAY)
MAKE_TEMPLATE_TYPE_INFO(Vector, Plane, Variant::ARRAY)
MAKE_TEMPLATE_TYPE_INFO(Vector, StringName, Variant::POOL_STRING_ARRAY)

MAKE_TEMPLATE_TYPE_INFO(PoolVector, Plane, Variant::ARRAY)
MAKE_TEMPLATE_TYPE_INFO(PoolVector, Face3, Variant::POOL_VECTOR3_ARRAY)
Expand Down
24 changes: 24 additions & 0 deletions core/variant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2012,6 +2012,19 @@ Variant::operator Vector<String>() const {
}
return to;
}
Variant::operator Vector<StringName>() const {

PoolVector<String> from = operator PoolVector<String>();
Vector<StringName> to;
int len = from.size();
to.resize(len);
for (int i = 0; i < len; i++) {

to[i] = from[i];
}
return to;
}

Variant::operator Vector<Vector3>() const {

PoolVector<Vector3> from = operator PoolVector<Vector3>();
Expand Down Expand Up @@ -2444,6 +2457,17 @@ Variant::Variant(const Vector<String> &p_array) {
*this = v;
}

Variant::Variant(const Vector<StringName> &p_array) {

type = NIL;
PoolVector<String> v;
int len = p_array.size();
v.resize(len);
for (int i = 0; i < len; i++)
v.set(i, p_array[i]);
*this = v;
}

Variant::Variant(const Vector<Vector3> &p_array) {

type = NIL;
Expand Down
2 changes: 2 additions & 0 deletions core/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ class Variant {
operator Vector<int>() const;
operator Vector<real_t>() const;
operator Vector<String>() const;
operator Vector<StringName>() const;
operator Vector<Vector3>() const;
operator Vector<Color>() const;
operator Vector<RID>() const;
Expand Down Expand Up @@ -280,6 +281,7 @@ class Variant {
Variant(const Vector<int> &p_int_array);
Variant(const Vector<real_t> &p_real_array);
Variant(const Vector<String> &p_string_array);
Variant(const Vector<StringName> &p_string_array);
Variant(const Vector<Vector3> &p_vector3_array);
Variant(const Vector<Color> &p_color_array);
Variant(const Vector<Plane> &p_array); // helper
Expand Down
2 changes: 2 additions & 0 deletions editor/editor_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
#include "editor/plugins/animation_blend_space_editor.h"
#include "editor/plugins/animation_blend_tree_editor_plugin.h"
#include "editor/plugins/animation_player_editor_plugin.h"
#include "editor/plugins/animation_state_machine_editor.h"
#include "editor/plugins/animation_tree_editor_plugin.h"
#include "editor/plugins/asset_library_editor_plugin.h"
#include "editor/plugins/baked_lightmap_editor_plugin.h"
Expand Down Expand Up @@ -5401,6 +5402,7 @@ EditorNode::EditorNode() {
//add_editor_plugin(memnew(ShaderGraphEditorPlugin(this)));
add_editor_plugin(memnew(AnimationNodeBlendTreeEditorPlugin(this)));
add_editor_plugin(memnew(AnimationNodeBlendSpaceEditorPlugin(this)));
add_editor_plugin(memnew(AnimationNodeStateMachineEditorPlugin(this)));

add_editor_plugin(memnew(CameraEditorPlugin(this)));
add_editor_plugin(memnew(ThemeEditorPlugin(this)));
Expand Down
68 changes: 68 additions & 0 deletions editor/icons/icon_auto_end.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
85 changes: 85 additions & 0 deletions editor/icons/icon_play_travel.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
80 changes: 80 additions & 0 deletions editor/icons/icon_tool_add_node.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4f5a7eb

Please sign in to comment.