mirror of
https://github.com/FyroxEngine/Fyrox.git
synced 2026-10-11 22:50:08 +00:00
[BREAKING] drop backward compatibility for assets
- use this tool from 1.0.0-rc.1 https://fyrox.rs/blog/post/fyrox-game-engine-1-0-0-rc-1/#migration to migrate the assets
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#![allow(clippy::doc_lazy_continuation)]
|
||||
#![allow(mismatched_lifetime_syntaxes)]
|
||||
|
||||
use crate::track::TrackBinding;
|
||||
use crate::{
|
||||
core::{
|
||||
algebra::{UnitQuaternion, Vector3},
|
||||
@@ -39,7 +40,11 @@ use crate::{
|
||||
track::Track,
|
||||
};
|
||||
use fxhash::FxHashMap;
|
||||
pub use fyrox_core as core;
|
||||
use fyrox_resource::untyped::ResourceKind;
|
||||
use fyrox_resource::{Resource, ResourceData};
|
||||
pub use pose::{AnimationPose, NodePose};
|
||||
pub use signal::{AnimationEvent, AnimationSignal};
|
||||
use std::{
|
||||
collections::VecDeque,
|
||||
error::Error,
|
||||
@@ -50,13 +55,6 @@ use std::{
|
||||
};
|
||||
use value::{nlerp, TrackValue, ValueBinding};
|
||||
|
||||
use crate::container::TrackDataContainer;
|
||||
use crate::track::TrackBinding;
|
||||
pub use fyrox_core as core;
|
||||
use fyrox_resource::untyped::ResourceKind;
|
||||
pub use pose::{AnimationPose, NodePose};
|
||||
pub use signal::{AnimationEvent, AnimationSignal};
|
||||
|
||||
pub mod container;
|
||||
pub mod machine;
|
||||
pub mod pose;
|
||||
@@ -268,7 +266,7 @@ pub type AnimationTracksDataResource = Resource<AnimationTracksData>;
|
||||
/// The code above creates a simple animation that moves a node along X axis in various ways. The usage of the animation
|
||||
/// is only for the sake of completeness of the example. In the real games you need to add the animation to an animation
|
||||
/// player scene node and it will do the job for you.
|
||||
#[derive(Debug, Reflect, PartialEq)]
|
||||
#[derive(Debug, Reflect, Visit, PartialEq)]
|
||||
pub struct Animation<T: EntityId> {
|
||||
name: ImmutableString,
|
||||
tracks_data: AnimationTracksDataResource,
|
||||
@@ -283,79 +281,16 @@ pub struct Animation<T: EntityId> {
|
||||
max_event_capacity: usize,
|
||||
|
||||
#[reflect(hidden)]
|
||||
#[visit(skip)]
|
||||
root_motion: Option<RootMotion>,
|
||||
// Non-serialized
|
||||
#[reflect(hidden)]
|
||||
#[visit(skip)]
|
||||
pose: AnimationPose<T>,
|
||||
// Non-serialized
|
||||
#[reflect(hidden)]
|
||||
#[visit(skip)]
|
||||
events: VecDeque<AnimationEvent>,
|
||||
}
|
||||
|
||||
#[derive(Visit, Default)]
|
||||
struct OldTrack<T: EntityId> {
|
||||
binding: ValueBinding,
|
||||
frames: TrackDataContainer,
|
||||
enabled: bool,
|
||||
node: T,
|
||||
id: Uuid,
|
||||
}
|
||||
|
||||
impl<T: EntityId> Visit for Animation<T> {
|
||||
fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult {
|
||||
let mut region = visitor.enter_region(name)?;
|
||||
|
||||
// Backward compatibility.
|
||||
let mut old_tracks = Vec::<OldTrack<T>>::new();
|
||||
if region.is_reading() {
|
||||
if old_tracks.visit("Tracks", &mut region).is_ok() {
|
||||
let mut tracks_data = AnimationTracksData::default();
|
||||
for old_track in old_tracks {
|
||||
self.track_bindings.insert(
|
||||
old_track.id,
|
||||
TrackBinding {
|
||||
enabled: old_track.enabled,
|
||||
target: old_track.node,
|
||||
},
|
||||
);
|
||||
tracks_data.tracks.push(Track {
|
||||
binding: old_track.binding,
|
||||
frames: old_track.frames,
|
||||
id: old_track.id,
|
||||
});
|
||||
}
|
||||
self.tracks_data = AnimationTracksDataResource::new_ok(
|
||||
Uuid::new_v4(),
|
||||
ResourceKind::Embedded,
|
||||
tracks_data,
|
||||
);
|
||||
} else {
|
||||
self.tracks_data.visit("TracksData", &mut region)?;
|
||||
self.track_bindings.visit("TrackBindings", &mut region)?;
|
||||
}
|
||||
} else {
|
||||
self.tracks_data.visit("TracksData", &mut region)?;
|
||||
self.track_bindings.visit("TrackBindings", &mut region)?;
|
||||
}
|
||||
|
||||
let _ = self.name.visit("Name", &mut region);
|
||||
self.time_position.visit("TimePosition", &mut region)?;
|
||||
let _ = self.time_slice.visit("TimeSlice", &mut region);
|
||||
self.speed.visit("Speed", &mut region)?;
|
||||
self.looped.visit("Looped", &mut region)?;
|
||||
self.enabled.visit("Enabled", &mut region)?;
|
||||
self.signals.visit("Signals", &mut region)?;
|
||||
let _ = self
|
||||
.max_event_capacity
|
||||
.visit("MaxEventCapacity", &mut region);
|
||||
let _ = self
|
||||
.root_motion_settings
|
||||
.visit("RootMotionSettings", &mut region);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: EntityId> TypeUuidProvider for Animation<T> {
|
||||
fn type_uuid() -> Uuid {
|
||||
uuid!("aade8e9d-e2cf-401d-a4d1-59c6943645f3")
|
||||
|
||||
@@ -88,25 +88,13 @@ impl<T: EntityId> TrackBinding<T> {
|
||||
/// Track is responsible in animating a property of a single scene node. The track consists up to 4 parametric curves
|
||||
/// that contains the actual property data. Parametric curves allows the engine to perform various interpolations between
|
||||
/// key values.
|
||||
#[derive(Debug, Reflect, Clone, PartialEq)]
|
||||
#[derive(Debug, Reflect, Clone, PartialEq, Visit)]
|
||||
pub struct Track {
|
||||
pub(super) binding: ValueBinding,
|
||||
pub(super) frames: TrackDataContainer,
|
||||
pub(super) id: Uuid,
|
||||
}
|
||||
|
||||
impl Visit for Track {
|
||||
fn visit(&mut self, name: &str, visitor: &mut Visitor) -> VisitResult {
|
||||
let mut region = visitor.enter_region(name)?;
|
||||
|
||||
let _ = self.binding.visit("Binding", &mut region); // Backward compatibility
|
||||
let _ = self.id.visit("Id", &mut region); // Backward compatibility
|
||||
let _ = self.frames.visit("Frames", &mut region); // Backward compatibility
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Track {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
|
||||
Reference in New Issue
Block a user