summaryrefslogtreecommitdiff
path: root/scene/animation/animation_tree.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/animation/animation_tree.cpp')
-rw-r--r--scene/animation/animation_tree.cpp75
1 files changed, 0 insertions, 75 deletions
diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp
index 56e224819f..81575b7f48 100644
--- a/scene/animation/animation_tree.cpp
+++ b/scene/animation/animation_tree.cpp
@@ -73,7 +73,6 @@ Variant AnimationNode::get_parameter(const StringName &p_name) const {
}
void AnimationNode::get_child_nodes(List<ChildNode> *r_child_nodes) {
-
if (get_script_instance()) {
Dictionary cn = get_script_instance()->call("get_child_nodes");
List<Variant> keys;
@@ -88,14 +87,12 @@ void AnimationNode::get_child_nodes(List<ChildNode> *r_child_nodes) {
}
void AnimationNode::blend_animation(const StringName &p_animation, float p_time, float p_delta, bool p_seeked, float p_blend) {
-
ERR_FAIL_COND(!state);
ERR_FAIL_COND(!state->player->has_animation(p_animation));
Ref<Animation> animation = state->player->get_animation(p_animation);
if (animation.is_null()) {
-
AnimationNodeBlendTree *btree = Object::cast_to<AnimationNodeBlendTree>(parent);
if (btree) {
String name = btree->get_node_name(Ref<AnimationNodeAnimation>(this));
@@ -120,7 +117,6 @@ void AnimationNode::blend_animation(const StringName &p_animation, float p_time,
}
float AnimationNode::_pre_process(const StringName &p_base_path, AnimationNode *p_parent, State *p_state, float p_time, bool p_seek, const Vector<StringName> &p_connections) {
-
base_path = p_base_path;
parent = p_parent;
connections = p_connections;
@@ -176,12 +172,10 @@ float AnimationNode::blend_input(int p_input, float p_time, bool p_seek, float p
}
float AnimationNode::blend_node(const StringName &p_sub_path, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize) {
-
return _blend_node(p_sub_path, Vector<StringName>(), this, p_node, p_time, p_seek, p_blend, p_filter, p_optimize);
}
float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<StringName> &p_connections, AnimationNode *p_new_parent, Ref<AnimationNode> p_node, float p_time, bool p_seek, float p_blend, FilterAction p_filter, bool p_optimize, float *r_max) {
-
ERR_FAIL_COND_V(!p_node.is_valid(), 0);
ERR_FAIL_COND_V(!state, 0);
@@ -197,7 +191,6 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin
bool any_valid = false;
if (has_filter() && is_filter_enabled() && p_filter != FILTER_IGNORE) {
-
for (int i = 0; i < blend_count; i++) {
blendw[i] = 0.0; //all to zero by default
}
@@ -228,7 +221,6 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin
} break;
case FILTER_STOP: {
-
//values filtered don't pass, the rest are blended
for (int i = 0; i < blend_count; i++) {
@@ -243,7 +235,6 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin
} break;
case FILTER_BLEND: {
-
//filtered values are blended, the rest are passed without blending
for (int i = 0; i < blend_count; i++) {
@@ -262,7 +253,6 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin
}
} else {
for (int i = 0; i < blend_count; i++) {
-
//regular blend
blendw[i] = blendr[i] * p_blend;
if (blendw[i] > CMP_EPSILON) {
@@ -297,7 +287,6 @@ float AnimationNode::_blend_node(const StringName &p_subpath, const Vector<Strin
}
int AnimationNode::get_input_count() const {
-
return inputs.size();
}
String AnimationNode::get_input_name(int p_input) {
@@ -306,7 +295,6 @@ String AnimationNode::get_input_name(int p_input) {
}
String AnimationNode::get_caption() const {
-
if (get_script_instance()) {
return get_script_instance()->call("get_caption");
}
@@ -338,7 +326,6 @@ void AnimationNode::remove_input(int p_index) {
}
float AnimationNode::process(float p_time, bool p_seek) {
-
if (get_script_instance()) {
return get_script_instance()->call("process", p_time, p_seek);
}
@@ -371,7 +358,6 @@ bool AnimationNode::has_filter() const {
}
Array AnimationNode::_get_filters() const {
-
Array paths;
const NodePath *K = nullptr;
@@ -403,7 +389,6 @@ Ref<AnimationNode> AnimationNode::get_child_by_name(const StringName &p_name) {
}
void AnimationNode::_bind_methods() {
-
ClassDB::bind_method(D_METHOD("get_input_count"), &AnimationNode::get_input_count);
ClassDB::bind_method(D_METHOD("get_input_name", "input"), &AnimationNode::get_input_name);
@@ -452,7 +437,6 @@ void AnimationNode::_bind_methods() {
}
AnimationNode::AnimationNode() {
-
state = nullptr;
parent = nullptr;
filter_enabled = false;
@@ -461,7 +445,6 @@ AnimationNode::AnimationNode() {
////////////////////
void AnimationTree::set_tree_root(const Ref<AnimationNode> &p_root) {
-
if (root.is_valid()) {
root->disconnect("tree_changed", callable_mp(this, &AnimationTree::_tree_changed));
}
@@ -482,7 +465,6 @@ Ref<AnimationNode> AnimationTree::get_tree_root() const {
}
void AnimationTree::set_active(bool p_active) {
-
if (active == p_active)
return;
@@ -492,13 +474,11 @@ void AnimationTree::set_active(bool p_active) {
if (process_mode == ANIMATION_PROCESS_IDLE) {
set_process_internal(active);
} else {
-
set_physics_process_internal(active);
}
if (!active && is_inside_tree()) {
for (Set<TrackCache *>::Element *E = playing_caches.front(); E; E = E->next()) {
-
if (ObjectDB::get_instance(E->get()->object_id)) {
E->get()->object->call("stop");
}
@@ -509,12 +489,10 @@ void AnimationTree::set_active(bool p_active) {
}
bool AnimationTree::is_active() const {
-
return active;
}
void AnimationTree::set_process_mode(AnimationProcessMode p_mode) {
-
if (process_mode == p_mode)
return;
@@ -539,7 +517,6 @@ void AnimationTree::_node_removed(Node *p_node) {
}
bool AnimationTree::_update_caches(AnimationPlayer *player) {
-
setup_pass++;
if (!player->has_node(player->get_root())) {
@@ -572,7 +549,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
}
if (!track) {
-
RES resource;
Vector<StringName> leftover_path;
Node *child = parent->get_node_and_resource(path, resource, leftover_path);
@@ -588,7 +564,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
switch (track_type) {
case Animation::TYPE_VALUE: {
-
TrackCacheValue *track_value = memnew(TrackCacheValue);
if (resource.is_valid()) {
@@ -604,7 +579,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
} break;
case Animation::TYPE_TRANSFORM: {
-
Node3D *spatial = Object::cast_to<Node3D>(child);
if (!spatial) {
@@ -619,11 +593,9 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
track_xform->bone_idx = -1;
if (path.get_subname_count() == 1 && Object::cast_to<Skeleton3D>(spatial)) {
-
Skeleton3D *sk = Object::cast_to<Skeleton3D>(spatial);
int bone_idx = sk->find_bone(path.get_subname(0));
if (bone_idx != -1) {
-
track_xform->skeleton = sk;
track_xform->bone_idx = bone_idx;
}
@@ -636,7 +608,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
} break;
case Animation::TYPE_METHOD: {
-
TrackCacheMethod *track_method = memnew(TrackCacheMethod);
if (resource.is_valid()) {
@@ -651,7 +622,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
} break;
case Animation::TYPE_BEZIER: {
-
TrackCacheBezier *track_bezier = memnew(TrackCacheBezier);
if (resource.is_valid()) {
@@ -666,7 +636,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
track = track_bezier;
} break;
case Animation::TYPE_AUDIO: {
-
TrackCacheAudio *track_audio = memnew(TrackCacheAudio);
track_audio->object = child;
@@ -676,7 +645,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
} break;
case Animation::TYPE_ANIMATION: {
-
TrackCacheAnimation *track_animation = memnew(TrackCacheAnimation);
track_animation->object = child;
@@ -732,7 +700,6 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) {
}
void AnimationTree::_clear_caches() {
-
const NodePath *K = nullptr;
while ((K = track_cache.next(K))) {
memdelete(track_cache[*K]);
@@ -744,7 +711,6 @@ void AnimationTree::_clear_caches() {
}
void AnimationTree::_process_graph(float p_delta) {
-
_update_properties(); //if properties need updating, update them
//check all tracks, see if they need modification
@@ -774,7 +740,6 @@ void AnimationTree::_process_graph(float p_delta) {
}
if (last_animation_player != current_animation_player) {
-
if (last_animation_player.is_valid()) {
Object *old_player = ObjectDB::get_instance(last_animation_player);
if (old_player) {
@@ -826,7 +791,6 @@ void AnimationTree::_process_graph(float p_delta) {
//process
{
-
if (started) {
//if started, seek
root->_pre_process(SceneStringNames::get_singleton()->parameters_base_path, nullptr, &state, 0, true, Vector<StringName>());
@@ -842,11 +806,9 @@ void AnimationTree::_process_graph(float p_delta) {
//apply value/transform/bezier blends to track caches and execute method/audio/animation tracks
{
-
bool can_call = is_inside_tree() && !Engine::get_singleton()->is_editor_hint();
for (List<AnimationNode::AnimationState>::Element *E = state.animation_states.front(); E; E = E->next()) {
-
const AnimationNode::AnimationState &as = E->get();
Ref<Animation> a = as.animation;
@@ -855,7 +817,6 @@ void AnimationTree::_process_graph(float p_delta) {
bool seeked = as.seeked;
for (int i = 0; i < a->get_track_count(); i++) {
-
NodePath path = a->track_get_path(i);
ERR_CONTINUE(!track_cache.has(path));
@@ -878,15 +839,11 @@ void AnimationTree::_process_graph(float p_delta) {
continue; //nothing to blend
switch (track->type) {
-
case Animation::TYPE_TRANSFORM: {
-
TrackCacheTransform *t = static_cast<TrackCacheTransform *>(track);
if (track->root_motion) {
-
if (t->process_pass != process_pass) {
-
t->process_pass = process_pass;
t->loc = Vector3();
t->rot = Quat();
@@ -908,7 +865,6 @@ void AnimationTree::_process_graph(float p_delta) {
Vector3 scale[2];
if (prev_time > time) {
-
Error err = a->transform_track_interpolate(i, prev_time, &loc[0], &rot[0], &scale[0]);
if (err != OK) {
continue;
@@ -947,7 +903,6 @@ void AnimationTree::_process_graph(float p_delta) {
//ERR_CONTINUE(err!=OK); //used for testing, should be removed
if (t->process_pass != process_pass) {
-
t->process_pass = process_pass;
t->loc = loc;
t->rot = rot;
@@ -972,7 +927,6 @@ void AnimationTree::_process_graph(float p_delta) {
} break;
case Animation::TYPE_VALUE: {
-
TrackCacheValue *t = static_cast<TrackCacheValue *>(track);
Animation::UpdateMode update_mode = a->value_track_get_update_mode(i);
@@ -992,12 +946,10 @@ void AnimationTree::_process_graph(float p_delta) {
Variant::interpolate(t->value, value, blend, t->value);
} else if (delta != 0) {
-
List<int> indices;
a->value_track_get_key_indices(i, time, delta, &indices);
for (List<int>::Element *F = indices.front(); F; F = F->next()) {
-
Variant value = a->track_get_key_value(i, F->get());
t->object->set_indexed(t->subpath, value);
}
@@ -1005,7 +957,6 @@ void AnimationTree::_process_graph(float p_delta) {
} break;
case Animation::TYPE_METHOD: {
-
if (delta == 0) {
continue;
}
@@ -1016,7 +967,6 @@ void AnimationTree::_process_graph(float p_delta) {
a->method_track_get_key_indices(i, time, delta, &indices);
for (List<int>::Element *F = indices.front(); F; F = F->next()) {
-
StringName method = a->method_track_get_name(i, F->get());
Vector<Variant> params = a->method_track_get_params(i, F->get());
@@ -1036,7 +986,6 @@ void AnimationTree::_process_graph(float p_delta) {
} break;
case Animation::TYPE_BEZIER: {
-
TrackCacheBezier *t = static_cast<TrackCacheBezier *>(track);
float bezier = a->bezier_track_interpolate(i, time);
@@ -1050,7 +999,6 @@ void AnimationTree::_process_graph(float p_delta) {
} break;
case Animation::TYPE_AUDIO: {
-
TrackCacheAudio *t = static_cast<TrackCacheAudio *>(track);
if (seeked) {
@@ -1122,7 +1070,6 @@ void AnimationTree::_process_graph(float p_delta) {
t->start = time;
}
} else if (t->playing) {
-
bool loop = a->has_loop();
bool stop = false;
@@ -1154,7 +1101,6 @@ void AnimationTree::_process_graph(float p_delta) {
}
} break;
case Animation::TYPE_ANIMATION: {
-
TrackCacheAnimation *t = static_cast<TrackCacheAnimation *>(track);
AnimationPlayer *player2 = Object::cast_to<AnimationPlayer>(t->object);
@@ -1202,7 +1148,6 @@ void AnimationTree::_process_graph(float p_delta) {
StringName anim_name = a->animation_track_get_key_animation(i, idx);
if (String(anim_name) == "[stop]" || !player2->has_animation(anim_name)) {
-
if (playing_caches.has(t)) {
playing_caches.erase(t);
player2->stop();
@@ -1231,9 +1176,7 @@ void AnimationTree::_process_graph(float p_delta) {
continue; //not processed, ignore
switch (track->type) {
-
case Animation::TYPE_TRANSFORM: {
-
TrackCacheTransform *t = static_cast<TrackCacheTransform *>(track);
Transform xform;
@@ -1242,31 +1185,26 @@ void AnimationTree::_process_graph(float p_delta) {
xform.basis.set_quat_scale(t->rot, t->scale);
if (t->root_motion) {
-
root_motion_transform = xform;
if (t->skeleton && t->bone_idx >= 0) {
root_motion_transform = (t->skeleton->get_bone_rest(t->bone_idx) * root_motion_transform) * t->skeleton->get_bone_rest(t->bone_idx).affine_inverse();
}
} else if (t->skeleton && t->bone_idx >= 0) {
-
t->skeleton->set_bone_pose(t->bone_idx, xform);
} else {
-
t->spatial->set_transform(xform);
}
} break;
case Animation::TYPE_VALUE: {
-
TrackCacheValue *t = static_cast<TrackCacheValue *>(track);
t->object->set_indexed(t->subpath, t->value);
} break;
case Animation::TYPE_BEZIER: {
-
TrackCacheBezier *t = static_cast<TrackCacheBezier *>(track);
t->object->set_indexed(t->subpath, t->value);
@@ -1280,12 +1218,10 @@ void AnimationTree::_process_graph(float p_delta) {
}
void AnimationTree::advance(float p_time) {
-
_process_graph(p_time);
}
void AnimationTree::_notification(int p_what) {
-
if (active && p_what == NOTIFICATION_INTERNAL_PHYSICS_PROCESS && process_mode == ANIMATION_PROCESS_PHYSICS) {
_process_graph(get_physics_process_delta_time());
}
@@ -1297,7 +1233,6 @@ void AnimationTree::_notification(int p_what) {
if (p_what == NOTIFICATION_EXIT_TREE) {
_clear_caches();
if (last_animation_player.is_valid()) {
-
Object *player = ObjectDB::get_instance(last_animation_player);
if (player) {
player->disconnect("caches_cleared", callable_mp(this, &AnimationTree::_clear_caches));
@@ -1305,7 +1240,6 @@ void AnimationTree::_notification(int p_what) {
}
} else if (p_what == NOTIFICATION_ENTER_TREE) {
if (last_animation_player.is_valid()) {
-
Object *player = ObjectDB::get_instance(last_animation_player);
if (player) {
player->connect("caches_cleared", callable_mp(this, &AnimationTree::_clear_caches));
@@ -1324,11 +1258,9 @@ NodePath AnimationTree::get_animation_player() const {
}
bool AnimationTree::is_state_invalid() const {
-
return !state.valid;
}
String AnimationTree::get_invalid_state_reason() const {
-
return state.invalid_reasons;
}
@@ -1337,7 +1269,6 @@ uint64_t AnimationTree::get_last_process_pass() const {
}
String AnimationTree::get_configuration_warning() const {
-
String warning = Node::get_configuration_warning();
if (!root.is_valid()) {
@@ -1348,7 +1279,6 @@ String AnimationTree::get_configuration_warning() const {
}
if (!has_node(animation_player)) {
-
if (warning != String()) {
warning += "\n\n";
}
@@ -1402,13 +1332,11 @@ void AnimationTree::_tree_changed() {
}
void AnimationTree::_update_properties_for_node(const String &p_base_path, Ref<AnimationNode> node) {
-
if (!property_parent_map.has(p_base_path)) {
property_parent_map[p_base_path] = HashMap<StringName, StringName>();
}
if (node->get_input_count() && !input_activity_map.has(p_base_path)) {
-
Vector<Activity> activity;
for (int i = 0; i < node->get_input_count(); i++) {
Activity a;
@@ -1503,7 +1431,6 @@ void AnimationTree::_get_property_list(List<PropertyInfo> *p_list) const {
}
void AnimationTree::rename_parameter(const String &p_base, const String &p_new_base) {
-
//rename values first
for (const List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) {
if (E->get().name.begins_with(p_base)) {
@@ -1518,7 +1445,6 @@ void AnimationTree::rename_parameter(const String &p_base, const String &p_new_b
}
float AnimationTree::get_connection_activity(const StringName &p_path, int p_connection) const {
-
if (!input_activity_map_get.has(p_path)) {
return 0;
}
@@ -1572,7 +1498,6 @@ void AnimationTree::_bind_methods() {
}
AnimationTree::AnimationTree() {
-
process_mode = ANIMATION_PROCESS_IDLE;
active = false;
cache_valid = false;