Started animation tree
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
#ifndef ANIMATION_SYSTEM_H
|
||||
#define ANIMATION_SYSTEM_H
|
||||
|
||||
class AnimationNode;
|
||||
|
||||
namespace ECS {
|
||||
struct AnimationPlayer;
|
||||
struct AnimationTreee;
|
||||
enum AnimationProcessMode {
|
||||
ANIMATION_PROCESS_PHYSICS,
|
||||
ANIMATION_PROCESS_IDLE,
|
||||
@@ -23,12 +25,6 @@ struct TrackNodeCache {
|
||||
NodePath path;
|
||||
flecs::entity_t id;
|
||||
Ref<Resource> resource;
|
||||
#if 0
|
||||
Node *node;
|
||||
Spatial *spatial;
|
||||
Node2D *node_2d;
|
||||
Skeleton *skeleton;
|
||||
#endif
|
||||
flecs::entity_t bone_idx;
|
||||
// accumulated transforms
|
||||
Vector3 loc_accum;
|
||||
@@ -39,51 +35,9 @@ struct TrackNodeCache {
|
||||
float audio_start;
|
||||
float audio_len;
|
||||
bool animation_playing;
|
||||
#if 0
|
||||
struct PropertyAnim {
|
||||
TrackNodeCache *owner;
|
||||
SpecialProperty special;
|
||||
Vector<StringName> subpath;
|
||||
Object *object;
|
||||
Variant value_accum;
|
||||
uint64_t accum_pass;
|
||||
Variant capture;
|
||||
PropertyAnim() :
|
||||
owner(nullptr),
|
||||
special(SP_NONE),
|
||||
object(nullptr),
|
||||
accum_pass(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
Map<StringName, PropertyAnim> property_anim;
|
||||
#endif
|
||||
#if 0
|
||||
struct BezierAnim {
|
||||
Vector<StringName> bezier_property;
|
||||
TrackNodeCache *owner;
|
||||
float bezier_accum;
|
||||
Object *object;
|
||||
uint64_t accum_pass;
|
||||
|
||||
BezierAnim() :
|
||||
owner(nullptr),
|
||||
bezier_accum(0.0),
|
||||
object(nullptr),
|
||||
accum_pass(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
Map<StringName, BezierAnim> bezier_anim;
|
||||
#endif
|
||||
TrackNodeCache() :
|
||||
used(false), id(-1),
|
||||
#if 0
|
||||
node(nullptr),
|
||||
spatial(nullptr),
|
||||
node_2d(nullptr),
|
||||
skeleton(nullptr),
|
||||
#endif
|
||||
used(false),
|
||||
id(-1),
|
||||
bone_idx(-1),
|
||||
accum_pass(0),
|
||||
audio_playing(false),
|
||||
@@ -199,10 +153,7 @@ struct AnimationData {
|
||||
assert(animation);
|
||||
animation = anim;
|
||||
}
|
||||
AnimationData() :
|
||||
animation(nullptr), node_cache_size(0)
|
||||
{
|
||||
}
|
||||
AnimationData() : animation(nullptr), node_cache_size(0) {}
|
||||
AnimationData(const AnimationData &d)
|
||||
{
|
||||
int i;
|
||||
@@ -236,10 +187,7 @@ struct AnimationData {
|
||||
memnew_placement(this, AnimationData(d));
|
||||
return *this;
|
||||
}
|
||||
const Animation *get_animation() const
|
||||
{
|
||||
return animation;
|
||||
}
|
||||
const Animation *get_animation() const { return animation; }
|
||||
|
||||
~AnimationData() { animation = nullptr; }
|
||||
|
||||
@@ -305,12 +253,6 @@ struct AnimationPlayerData {
|
||||
TrackNodeCache *cache_update[NODE_CACHE_UPDATE_MAX];
|
||||
int cache_update_size;
|
||||
|
||||
#if 0
|
||||
TrackNodeCache::PropertyAnim *cache_update_prop[NODE_CACHE_UPDATE_MAX];
|
||||
int cache_update_prop_size;
|
||||
TrackNodeCache::BezierAnim *cache_update_bezier[NODE_CACHE_UPDATE_MAX];
|
||||
int cache_update_bezier_size;
|
||||
#endif
|
||||
Set<TrackNodeCache *> playing_caches;
|
||||
uint64_t accum_pass;
|
||||
float speed_scale;
|
||||
@@ -327,9 +269,6 @@ struct AnimationPlayerData {
|
||||
AnimationProcessMode animation_process_mode;
|
||||
bool processing;
|
||||
bool active;
|
||||
#if 0
|
||||
NodePath root;
|
||||
#endif
|
||||
bool playing;
|
||||
AnimationPlayerData(int id)
|
||||
{
|
||||
@@ -380,29 +319,6 @@ struct AnimationPlayerData {
|
||||
AnimationPlayerData(AnimationPlayerData &&d)
|
||||
{
|
||||
memnew_placement(this, AnimationPlayerData(d));
|
||||
#if 0
|
||||
int i;
|
||||
node_cache_map = d.node_cache_map;
|
||||
for (i = 0; i < NODE_CACHE_UPDATE_MAX; i++)
|
||||
cache_update[i] = d.cache_update[i];
|
||||
cache_update_size = d.cache_update_size;
|
||||
playing_caches = d.playing_caches;
|
||||
accum_pass = d.accum_pass;
|
||||
speed_scale = d.speed_scale;
|
||||
default_blend_time = d.default_blend_time;
|
||||
animation_set = d.animation_set;
|
||||
blend_times = d.blend_times;
|
||||
playback = d.playback;
|
||||
queued = d.queued;
|
||||
end_reached = d.end_reached;
|
||||
end_notify = d.end_notify;
|
||||
autoplay = d.autoplay;
|
||||
reset_on_save = d.reset_on_save;
|
||||
animation_process_mode = d.animation_process_mode;
|
||||
processing = d.processing;
|
||||
active = d.active;
|
||||
playing = d.playing;
|
||||
#endif
|
||||
d.playing = playing;
|
||||
d.cache_update_size = 0;
|
||||
d.active = false;
|
||||
@@ -410,29 +326,6 @@ struct AnimationPlayerData {
|
||||
AnimationPlayerData &operator=(const AnimationPlayerData &d)
|
||||
{
|
||||
memnew_placement(this, AnimationPlayerData(d));
|
||||
#if 0
|
||||
int i;
|
||||
node_cache_map = d.node_cache_map;
|
||||
for (i = 0; i < NODE_CACHE_UPDATE_MAX; i++)
|
||||
cache_update[i] = d.cache_update[i];
|
||||
cache_update_size = d.cache_update_size;
|
||||
playing_caches = d.playing_caches;
|
||||
accum_pass = d.accum_pass;
|
||||
speed_scale = d.speed_scale;
|
||||
default_blend_time = d.default_blend_time;
|
||||
animation_set = d.animation_set;
|
||||
blend_times = d.blend_times;
|
||||
playback = d.playback;
|
||||
queued = d.queued;
|
||||
end_reached = d.end_reached;
|
||||
end_notify = d.end_notify;
|
||||
autoplay = d.autoplay;
|
||||
reset_on_save = d.reset_on_save;
|
||||
animation_process_mode = d.animation_process_mode;
|
||||
processing = d.processing;
|
||||
active = d.active;
|
||||
playing = d.playing;
|
||||
#endif
|
||||
return *this;
|
||||
}
|
||||
AnimationPlayerData &operator=(AnimationPlayerData &&d)
|
||||
@@ -464,11 +357,13 @@ struct AnimationPlayerData {
|
||||
}
|
||||
~AnimationPlayerData() { playing = false; }
|
||||
};
|
||||
/* AnimationPlayer */
|
||||
/* public functions */
|
||||
StringName find_animation(
|
||||
struct AnimationPlayerData *player, const Ref<Animation> &p_animation);
|
||||
Error add_animation(flecs::entity_t entity, flecs::world &ecs, struct AnimationPlayerData *player,
|
||||
const StringName &p_name, const Animation *p_animation);
|
||||
Error add_animation(flecs::entity_t entity, flecs::world &ecs,
|
||||
struct AnimationPlayerData *player, const StringName &p_name,
|
||||
const Animation *p_animation);
|
||||
void remove_animation(flecs::entity_t entity, flecs::world &ecs,
|
||||
struct AnimationPlayerData *player, const StringName &p_name);
|
||||
void rename_animation(struct AnimationPlayerData *player,
|
||||
@@ -537,7 +432,8 @@ void advance(flecs::entity_t entity, flecs::world &ecs,
|
||||
AnimationPlayerData *player, float p_time);
|
||||
void set_root(struct AnimationPlayerData *player, const NodePath &p_root);
|
||||
NodePath get_root(struct AnimationPlayerData *player);
|
||||
void clear_caches(flecs::entity_t entity, flecs::world &ecs, struct AnimationPlayerData *player);
|
||||
void clear_caches(flecs::entity_t entity, flecs::world &ecs,
|
||||
struct AnimationPlayerData *player);
|
||||
void get_argument_options(struct AnimationPlayerData *player,
|
||||
const StringName &p_function, int p_idx, List<String> *r_options);
|
||||
} //namespace ECS
|
||||
|
||||
8
src/modules/character/animation_system_tree.cpp
Normal file
8
src/modules/character/animation_system_tree.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <cassert>
|
||||
#include <scene/resources/animation.h>
|
||||
#include <servers/audio/audio_stream.h>
|
||||
#include <scene/animation/animation_tree.h>
|
||||
|
||||
#include <flecs.h>
|
||||
|
||||
#include "animation_system_tree.h"
|
||||
13
src/modules/character/animation_system_tree.h
Normal file
13
src/modules/character/animation_system_tree.h
Normal file
@@ -0,0 +1,13 @@
|
||||
#ifndef ANIMATION_SYSTEM_TREE
|
||||
#define ANIMATION_SYSTEM_TREE
|
||||
struct AnimationTree {
|
||||
HashMap<NodePath, int> track_cache_map;
|
||||
TrackCache track_cache_data[NODE_CACHE_UPDATE_MAX];
|
||||
Set<int> playing_caches;
|
||||
Ref<AnimationNode> root;
|
||||
|
||||
AnimationProcessMode process_mode;
|
||||
bool active;
|
||||
NodePath animation_player;
|
||||
};
|
||||
#endif
|
||||
@@ -23,11 +23,7 @@ struct Skeleton {
|
||||
int parent;
|
||||
bool disable_rest;
|
||||
bool custom_pose_enable;
|
||||
Transform
|
||||
custom_pose,
|
||||
rest,
|
||||
pose,
|
||||
pose_global,
|
||||
Transform custom_pose, rest, pose, pose_global,
|
||||
pose_global_no_override;
|
||||
int sort_index;
|
||||
};
|
||||
@@ -55,16 +51,6 @@ struct BonePose {
|
||||
int index;
|
||||
Transform pose;
|
||||
};
|
||||
struct AnimationTree {
|
||||
void *root;
|
||||
AnimationTree() :
|
||||
root(nullptr)
|
||||
{
|
||||
}
|
||||
~AnimationTree()
|
||||
{
|
||||
}
|
||||
};
|
||||
struct CharacterSlot {
|
||||
String name;
|
||||
RID instance;
|
||||
|
||||
Reference in New Issue
Block a user