Skip to content

Commit 2133fcd

Browse files
authored
Delete animation graph migration code. (#21286)
# Objective - Finish the migration from #19615. ## Solution - Delete all the serialization shenanigans that allowed loading both old and new animation graphs. ## Testing - Ran the `animation_graph` example and it works without changing anything.
1 parent 523f40a commit 2133fcd

File tree

1 file changed

+5
-60
lines changed

1 file changed

+5
-60
lines changed

crates/bevy_animation/src/graph.rs

Lines changed: 5 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ use ron::de::SpannedError;
2929
use serde::{Deserialize, Serialize};
3030
use smallvec::SmallVec;
3131
use thiserror::Error;
32-
use tracing::warn;
3332

3433
use crate::{AnimationClip, AnimationTargetId};
3534

@@ -408,42 +407,13 @@ pub struct SerializedAnimationGraphNode {
408407
#[derive(Serialize, Deserialize)]
409408
pub enum SerializedAnimationNodeType {
410409
/// Corresponds to [`AnimationNodeType::Clip`].
411-
Clip(MigrationSerializedAnimationClip),
410+
Clip(AssetPath<'static>),
412411
/// Corresponds to [`AnimationNodeType::Blend`].
413412
Blend,
414413
/// Corresponds to [`AnimationNodeType::Add`].
415414
Add,
416415
}
417416

418-
/// A type to facilitate migration from the legacy format of [`SerializedAnimationGraph`] to the
419-
/// new format.
420-
///
421-
/// By using untagged serde deserialization, we can try to deserialize the modern form, then
422-
/// fallback to the legacy form. Users must migrate to the modern form by Bevy 0.18.
423-
// TODO: Delete this after Bevy 0.17.
424-
#[derive(Serialize, Deserialize)]
425-
#[serde(untagged)]
426-
pub enum MigrationSerializedAnimationClip {
427-
/// This is the new type of this field.
428-
Modern(AssetPath<'static>),
429-
/// This is the legacy type of this field. Users must migrate away from this.
430-
#[serde(skip_serializing)]
431-
Legacy(SerializedAnimationClip),
432-
}
433-
434-
/// The legacy form of serialized animation clips. This allows raw asset IDs to be deserialized.
435-
// TODO: Delete this after Bevy 0.17.
436-
#[derive(Deserialize)]
437-
pub enum SerializedAnimationClip {
438-
/// Records an asset path.
439-
AssetPath(AssetPath<'static>),
440-
/// The fallback that records an asset ID.
441-
///
442-
/// Because asset IDs can change, this should not be relied upon. Prefer to
443-
/// use asset paths where possible.
444-
AssetId(AssetId<AnimationClip>),
445-
}
446-
447417
/// The type of an animation mask bitfield.
448418
///
449419
/// Bit N corresponds to mask group N.
@@ -801,35 +771,12 @@ impl AssetLoader for AnimationGraphAssetLoader {
801771
serialized_animation_graph.graph.edge_count(),
802772
);
803773

804-
let mut already_warned = false;
805774
for serialized_node in serialized_animation_graph.graph.node_weights() {
806775
animation_graph.add_node(AnimationGraphNode {
807776
node_type: match serialized_node.node_type {
808-
SerializedAnimationNodeType::Clip(ref clip) => match clip {
809-
MigrationSerializedAnimationClip::Modern(path) => {
810-
AnimationNodeType::Clip(load_context.load(path.clone()))
811-
}
812-
MigrationSerializedAnimationClip::Legacy(
813-
SerializedAnimationClip::AssetPath(path),
814-
) => {
815-
if !already_warned {
816-
let path = load_context.asset_path();
817-
warn!(
818-
"Loaded an AnimationGraph asset at \"{path}\" which contains a \
819-
legacy-style SerializedAnimationClip. Please re-save the asset \
820-
using AnimationGraph::save to automatically migrate to the new \
821-
format"
822-
);
823-
already_warned = true;
824-
}
825-
AnimationNodeType::Clip(load_context.load(path.clone()))
826-
}
827-
MigrationSerializedAnimationClip::Legacy(
828-
SerializedAnimationClip::AssetId(_),
829-
) => {
830-
return Err(AnimationGraphLoadError::GraphContainsLegacyAssetId);
831-
}
832-
},
777+
SerializedAnimationNodeType::Clip(ref path) => {
778+
AnimationNodeType::Clip(load_context.load(path.clone()))
779+
}
833780
SerializedAnimationNodeType::Blend => AnimationNodeType::Blend,
834781
SerializedAnimationNodeType::Add => AnimationNodeType::Add,
835782
},
@@ -870,9 +817,7 @@ impl TryFrom<AnimationGraph> for SerializedAnimationGraph {
870817
mask: node.mask,
871818
node_type: match node.node_type {
872819
AnimationNodeType::Clip(ref clip) => match clip.path() {
873-
Some(path) => SerializedAnimationNodeType::Clip(
874-
MigrationSerializedAnimationClip::Modern(path.clone()),
875-
),
820+
Some(path) => SerializedAnimationNodeType::Clip(path.clone()),
876821
None => return Err(NonPathHandleError),
877822
},
878823
AnimationNodeType::Blend => SerializedAnimationNodeType::Blend,

0 commit comments

Comments
 (0)