Rework AnimationNode process for retrieving the semantic time info
This commit is contained in:
@@ -33,12 +33,17 @@
|
||||
#include "animation_blend_tree.h"
|
||||
|
||||
void AnimationNodeBlendSpace1D::get_parameter_list(List<PropertyInfo> *r_list) const {
|
||||
AnimationNode::get_parameter_list(r_list);
|
||||
r_list->push_back(PropertyInfo(Variant::FLOAT, blend_position));
|
||||
r_list->push_back(PropertyInfo(Variant::INT, closest, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE));
|
||||
r_list->push_back(PropertyInfo(Variant::FLOAT, length_internal, PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE));
|
||||
}
|
||||
|
||||
Variant AnimationNodeBlendSpace1D::get_parameter_default_value(const StringName &p_parameter) const {
|
||||
Variant ret = AnimationNode::get_parameter_default_value(p_parameter);
|
||||
if (ret != Variant()) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (p_parameter == closest) {
|
||||
return -1;
|
||||
} else {
|
||||
@@ -272,9 +277,9 @@ void AnimationNodeBlendSpace1D::_add_blend_point(int p_index, const Ref<Animatio
|
||||
}
|
||||
}
|
||||
|
||||
double AnimationNodeBlendSpace1D::_process(const AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only) {
|
||||
AnimationNode::NodeTimeInfo AnimationNodeBlendSpace1D::_process(const AnimationMixer::PlaybackInfo p_playback_info, bool p_test_only) {
|
||||
if (blend_points_used == 0) {
|
||||
return 0.0;
|
||||
return NodeTimeInfo();
|
||||
}
|
||||
|
||||
AnimationMixer::PlaybackInfo pi = p_playback_info;
|
||||
@@ -287,8 +292,7 @@ double AnimationNodeBlendSpace1D::_process(const AnimationMixer::PlaybackInfo p_
|
||||
|
||||
double blend_pos = get_parameter(blend_position);
|
||||
int cur_closest = get_parameter(closest);
|
||||
double cur_length_internal = get_parameter(length_internal);
|
||||
double max_time_remaining = 0.0;
|
||||
NodeTimeInfo mind;
|
||||
|
||||
if (blend_mode == BLEND_MODE_INTERPOLATED) {
|
||||
int point_lower = -1;
|
||||
@@ -341,12 +345,17 @@ double AnimationNodeBlendSpace1D::_process(const AnimationMixer::PlaybackInfo p_
|
||||
}
|
||||
|
||||
// actually blend the animations now
|
||||
|
||||
bool first = true;
|
||||
double max_weight = 0.0;
|
||||
for (int i = 0; i < blend_points_used; i++) {
|
||||
if (i == point_lower || i == point_higher) {
|
||||
pi.weight = weights[i];
|
||||
double remaining = blend_node(blend_points[i].node, blend_points[i].name, pi, FILTER_IGNORE, true, p_test_only);
|
||||
max_time_remaining = MAX(max_time_remaining, remaining);
|
||||
NodeTimeInfo t = blend_node(blend_points[i].node, blend_points[i].name, pi, FILTER_IGNORE, true, p_test_only);
|
||||
if (first || pi.weight > max_weight) {
|
||||
max_weight = pi.weight;
|
||||
mind = t;
|
||||
first = false;
|
||||
}
|
||||
} else if (sync) {
|
||||
pi.weight = 0;
|
||||
blend_node(blend_points[i].node, blend_points[i].name, pi, FILTER_IGNORE, true, p_test_only);
|
||||
@@ -365,7 +374,7 @@ double AnimationNodeBlendSpace1D::_process(const AnimationMixer::PlaybackInfo p_
|
||||
}
|
||||
|
||||
if (new_closest != cur_closest && new_closest != -1) {
|
||||
double from = 0.0;
|
||||
NodeTimeInfo from;
|
||||
if (blend_mode == BLEND_MODE_DISCRETE_CARRY && cur_closest != -1) {
|
||||
//for ping-pong loop
|
||||
Ref<AnimationNodeAnimation> na_c = static_cast<Ref<AnimationNodeAnimation>>(blend_points[cur_closest].node);
|
||||
@@ -376,18 +385,17 @@ double AnimationNodeBlendSpace1D::_process(const AnimationMixer::PlaybackInfo p_
|
||||
//see how much animation remains
|
||||
pi.seeked = false;
|
||||
pi.weight = 0;
|
||||
from = cur_length_internal - blend_node(blend_points[cur_closest].node, blend_points[cur_closest].name, pi, FILTER_IGNORE, true, p_test_only);
|
||||
from = blend_node(blend_points[cur_closest].node, blend_points[cur_closest].name, pi, FILTER_IGNORE, true, p_test_only);
|
||||
}
|
||||
|
||||
pi.time = from;
|
||||
pi.time = from.position;
|
||||
pi.seeked = true;
|
||||
pi.weight = 1.0;
|
||||
max_time_remaining = blend_node(blend_points[new_closest].node, blend_points[new_closest].name, pi, FILTER_IGNORE, true, p_test_only);
|
||||
cur_length_internal = from + max_time_remaining;
|
||||
mind = blend_node(blend_points[new_closest].node, blend_points[new_closest].name, pi, FILTER_IGNORE, true, p_test_only);
|
||||
cur_closest = new_closest;
|
||||
} else {
|
||||
pi.weight = 1.0;
|
||||
max_time_remaining = blend_node(blend_points[cur_closest].node, blend_points[cur_closest].name, pi, FILTER_IGNORE, true, p_test_only);
|
||||
mind = blend_node(blend_points[cur_closest].node, blend_points[cur_closest].name, pi, FILTER_IGNORE, true, p_test_only);
|
||||
}
|
||||
|
||||
if (sync) {
|
||||
@@ -402,8 +410,7 @@ double AnimationNodeBlendSpace1D::_process(const AnimationMixer::PlaybackInfo p_
|
||||
}
|
||||
|
||||
set_parameter(closest, cur_closest);
|
||||
set_parameter(length_internal, cur_length_internal);
|
||||
return max_time_remaining;
|
||||
return mind;
|
||||
}
|
||||
|
||||
String AnimationNodeBlendSpace1D::get_caption() const {
|
||||
|
||||
Reference in New Issue
Block a user