Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 37 additions & 2 deletions crates/bevy_animation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1098,7 +1098,7 @@ pub fn animate_targets(
};

match animation_graph_node.node_type {
AnimationNodeType::Blend | AnimationNodeType::Add => {
AnimationNodeType::Blend => {
// This is a blend node.
for edge_index in threaded_animation_graph.sorted_edge_ranges
[animation_graph_node_index.index()]
Expand All @@ -1119,6 +1119,27 @@ pub fn animate_targets(
}
}

AnimationNodeType::Add => {
// This is an additive blend node.
for edge_index in threaded_animation_graph.sorted_edge_ranges
[animation_graph_node_index.index()]
.clone()
{
if let Err(err) = evaluation_state
.add_all(threaded_animation_graph.sorted_edges[edge_index as usize])
{
warn!("Failed to blend animation: {:?}", err);
}
}

if let Err(err) = evaluation_state.push_blend_register_all(
animation_graph_node.weight,
animation_graph_node_index,
) {
warn!("Animation blending failed: {:?}", err);
}
}

AnimationNodeType::Clip(ref animation_clip_handle) => {
// This is a clip node.
let Some(active_animation) = animation_player
Expand Down Expand Up @@ -1169,7 +1190,7 @@ pub fn animate_targets(
continue;
};

let weight = active_animation.weight;
let weight = active_animation.weight * animation_graph_node.weight;
let seek_time = active_animation.seek_time;

for curve in curves {
Expand Down Expand Up @@ -1317,6 +1338,20 @@ impl AnimationEvaluationState {
Ok(())
}

/// Calls [`AnimationCurveEvaluator::add`] on all curve evaluator types
/// that we've been building up for a single target.
///
/// The given `node_index` is the node that we're evaluating.
fn add_all(&mut self, node_index: AnimationNodeIndex) -> Result<(), AnimationEvaluationError> {
for curve_evaluator_type in self.current_curve_evaluator_types.keys() {
self.curve_evaluators
.get_mut(curve_evaluator_type)
.unwrap()
.add(node_index)?;
}
Ok(())
}

/// Calls [`AnimationCurveEvaluator::push_blend_register`] on all curve
/// evaluator types that we've been building up for a single target.
///
Expand Down