Skip to content

Commit 55a337d

Browse files
committed
Start migration
1 parent 0223d29 commit 55a337d

34 files changed

Lines changed: 1359 additions & 1238 deletions

File tree

Cargo.lock

Lines changed: 1208 additions & 1101 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,27 @@ members = ["crates/*", "examples/*"]
33
resolver = "2"
44

55
[workspace.package]
6-
version = "0.10.0"
6+
version = "0.11.0"
77
license = "MIT OR Apache-2.0"
88
readme = "README.md"
99
edition = "2024"
1010
repository = "https://github.com/mbrea-c/bevy_animation_graph"
1111

1212
[workspace.dependencies]
13-
bevy_animation_graph_proc_macros = { version = "0.10.0", path = "./crates/bevy_animation_graph_proc_macros" }
14-
bevy_animation_graph = { version = "0.10.0", path = "./crates/bevy_animation_graph" }
15-
bevy_animation_graph_core = { version = "0.10.0", path = "./crates/bevy_animation_graph_core" }
16-
bevy_animation_graph_builtin_nodes = { version = "0.10.0", path = "./crates/bevy_animation_graph_builtin_nodes" }
13+
bevy_animation_graph_proc_macros = { version = "0.11.0", path = "./crates/bevy_animation_graph_proc_macros" }
14+
bevy_animation_graph = { version = "0.11.0", path = "./crates/bevy_animation_graph" }
15+
bevy_animation_graph_core = { version = "0.11.0", path = "./crates/bevy_animation_graph_core" }
16+
bevy_animation_graph_builtin_nodes = { version = "0.11.0", path = "./crates/bevy_animation_graph_builtin_nodes" }
1717

18-
bevy = { version = "0.18" }
19-
avian3d = { version = "0.5" }
18+
bevy = { version = "0.19" }
19+
avian3d = { version = "0.7" }
2020

21-
egui_dock = "0.18"
22-
egui-notify = { version = "0.21" }
23-
egui = { version = "0.33" }
24-
egui_extras = { version = "0.33", features = ["all_loaders"] }
25-
bevy_egui = { version = "0.39" }
26-
bevy-inspector-egui = { version = "0.36" }
21+
egui_dock = "0.19"
22+
egui-notify = { version = "0.22" }
23+
egui = { version = "0.34" }
24+
egui_extras = { version = "0.34", features = ["all_loaders"] }
25+
bevy_egui = { version = "0.40.0" }
26+
bevy-inspector-egui = { version = "0.37" }
2727

2828
ron = "0.10.1"
2929
serde = "1.0"

crates/bevy_animation_graph_core/src/animated_scene/loader.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use bevy::{
22
asset::{AssetLoader, AssetPath, Handle, LoadContext, io::Reader},
33
platform::collections::HashMap,
44
reflect::TypePath,
5-
scene::Scene,
5+
world_serialization::WorldAsset,
66
};
77
use serde::{Deserialize, Serialize};
88

@@ -51,7 +51,7 @@ impl AssetLoader for AnimatedSceneLoader {
5151

5252
let animation_graph: Handle<AnimationGraph> = load_context.load(serial.animation_graph);
5353
let skeleton: Handle<Skeleton> = load_context.load(serial.skeleton);
54-
let source: Handle<Scene> = load_context.load(serial.source);
54+
let source: Handle<WorldAsset> = load_context.load(serial.source);
5555
let retargeting: Option<Retargeting> = serial.retargeting.map(|r| Retargeting {
5656
source_skeleton: load_context.load(r.source_skeleton),
5757
bone_path_overrides: r.bone_path_overrides,

crates/bevy_animation_graph_core/src/animated_scene/mod.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ use bevy::{
1515
},
1616
platform::collections::HashMap,
1717
reflect::Reflect,
18-
scene::{Scene, SceneInstanceReady, SceneRoot},
1918
transform::components::Transform,
19+
world_serialization::{WorldAsset, WorldAssetRoot, WorldInstanceReady},
2020
};
2121

2222
use super::{animation_clip::EntityPath, errors::AssetLoaderError, id::BoneId, skeleton::Skeleton};
@@ -29,8 +29,8 @@ use crate::{
2929
#[derive(Clone, Asset, Reflect)]
3030
#[reflect(Asset)]
3131
pub struct AnimatedScene {
32-
pub source: Handle<Scene>,
33-
pub processed_scene: Option<Handle<Scene>>,
32+
pub source: Handle<WorldAsset>,
33+
pub processed_scene: Option<Handle<WorldAsset>>,
3434
pub animation_graph: Handle<AnimationGraph>,
3535
pub retargeting: Option<Retargeting>,
3636
/// Skeleton of the animations we want to play on the source scene.
@@ -84,20 +84,20 @@ impl AnimatedSceneHandle {
8484
/// Processed animated scenes are "cached".
8585
pub(crate) fn spawn_animated_scenes(
8686
mut commands: Commands,
87-
unloaded_scenes: Query<(Entity, &AnimatedSceneHandle), Without<SceneRoot>>,
87+
unloaded_scenes: Query<(Entity, &AnimatedSceneHandle), Without<WorldAssetRoot>>,
8888
mut animated_scene_assets: ResMut<Assets<AnimatedScene>>,
89-
mut scenes: ResMut<Assets<Scene>>,
89+
mut scenes: ResMut<Assets<WorldAsset>>,
9090
skeletons: Res<Assets<Skeleton>>,
9191
app_type_registry: Res<AppTypeRegistry>,
9292
) {
9393
for (entity, animscn_handle) in &unloaded_scenes {
94-
let Some(animscn) = animated_scene_assets.get_mut(&animscn_handle.handle) else {
94+
let Some(mut animscn) = animated_scene_assets.get_mut(&animscn_handle.handle) else {
9595
continue;
9696
};
9797

9898
let processed_scene = if let Some(val) = animscn.processed_scene.as_ref() {
9999
val
100-
} else if is_scene_ready_to_process(animscn, &scenes, &skeletons) {
100+
} else if is_scene_ready_to_process(&animscn, &scenes, &skeletons) {
101101
let Some(scene) = scenes
102102
.get(&animscn.source)
103103
.and_then(|scn| scn.clone_with(&app_type_registry).ok())
@@ -124,14 +124,14 @@ pub(crate) fn spawn_animated_scenes(
124124

125125
commands
126126
.entity(entity)
127-
.insert(SceneRoot(processed_scene.clone()));
127+
.insert(WorldAssetRoot(processed_scene.clone()));
128128
}
129129
}
130130

131131
/// Checks whether the scene can be processed
132132
fn is_scene_ready_to_process(
133133
animscn: &AnimatedScene,
134-
scenes: &Assets<Scene>,
134+
scenes: &Assets<WorldAsset>,
135135
skeletons: &Assets<Skeleton>,
136136
) -> bool {
137137
scenes.contains(&animscn.source) && skeletons.contains(&animscn.skeleton)
@@ -142,14 +142,14 @@ fn is_scene_ready_to_process(
142142
/// It also applies retargeting if necessary.
143143
#[allow(clippy::result_large_err, clippy::too_many_arguments)]
144144
fn process_scene_into_animscn(
145-
mut scene: Scene,
145+
mut scene: WorldAsset,
146146
skeleton_handle: Handle<Skeleton>,
147147
ragdoll_handle: Option<Handle<Ragdoll>>,
148148
ragdoll_bone_map_handle: Option<Handle<RagdollBoneMap>>,
149149
graph: Handle<AnimationGraph>,
150150
skeletons: &Assets<Skeleton>,
151151
retargeting: Option<&Retargeting>,
152-
) -> Result<Scene, AssetLoaderError> {
152+
) -> Result<WorldAsset, AssetLoaderError> {
153153
let mut query = scene
154154
.world
155155
.query_filtered::<Entity, With<bevy::animation::AnimationPlayer>>();
@@ -219,7 +219,7 @@ fn apply_bone_path_overrides(
219219
/// Adds an `AnimatedSceneInstance` pointing to the animation graph player when the scene is
220220
/// spawned
221221
pub(crate) fn locate_animated_scene_player(
222-
trigger: On<SceneInstanceReady>,
222+
trigger: On<WorldInstanceReady>,
223223
handle_query: Query<&AnimatedSceneHandle>,
224224
mut player_query: Query<&mut AnimationGraphPlayer>,
225225
children_query: Query<&Children>,

crates/bevy_animation_graph_core/src/animation_clip/loader.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,8 @@ impl AssetLoader for GraphClipLoader {
4848
path,
4949
animation_name,
5050
} => {
51-
let gltf_loaded_asset = load_context
52-
.loader()
53-
.immediate()
54-
.with_unknown_type()
55-
.load(path)
56-
.await?;
51+
let gltf_loaded_asset =
52+
load_context.load_builder().load_untyped_value(path).await?;
5753
let gltf: &Gltf = gltf_loaded_asset.get().unwrap();
5854

5955
let Some(clip_handle) = gltf
@@ -78,7 +74,7 @@ impl AssetLoader for GraphClipLoader {
7874
}
7975
};
8076

81-
let skeleton = load_context.loader().load(serial.skeleton);
77+
let skeleton = load_context.load_builder().load(serial.skeleton);
8278

8379
let clip_mine = GraphClip::from_bevy_clip(
8480
bevy_clip,

crates/bevy_animation_graph_core/src/animation_node/dyn_node_like/mod.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,11 @@ impl ::bevy::reflect::Typed for DynNodeLike {
4141
static CELL: ::bevy::reflect::utility::NonGenericTypeInfoCell =
4242
::bevy::reflect::utility::NonGenericTypeInfoCell::new();
4343
CELL.get_or_set(|| {
44-
::bevy::reflect::TypeInfo::TupleStruct(::bevy::reflect::TupleStructInfo::new::<Self>(
45-
&[
44+
::bevy::reflect::TypeInfo::TupleStruct(
45+
::bevy::reflect::tuple_struct::TupleStructInfo::new::<Self>(&[
4646
// ::bevy::reflect::UnnamedField::new::<Box<dyn NodeLike>>(0usize),
47-
],
48-
))
47+
]),
48+
)
4949
})
5050
}
5151
}
@@ -103,7 +103,7 @@ impl ::bevy::reflect::Reflect for DynNodeLike {
103103
::bevy::reflect::__macro_exports::auto_register::inventory::submit! {
104104
::bevy::reflect::__macro_exports::auto_register::AutomaticReflectRegistrations(<DynNodeLike as ::bevy::reflect::__macro_exports::auto_register::RegisterForReflection> ::__register)
105105
}
106-
impl ::bevy::reflect::TupleStruct for DynNodeLike {
106+
impl ::bevy::reflect::tuple_struct::TupleStruct for DynNodeLike {
107107
fn field(&self, index: usize) -> Option<&dyn ::bevy::reflect::PartialReflect> {
108108
match index {
109109
0usize => Some(self.0.as_partial_reflect()),
@@ -121,8 +121,8 @@ impl ::bevy::reflect::TupleStruct for DynNodeLike {
121121
1usize
122122
}
123123
#[inline]
124-
fn iter_fields(&'_ self) -> ::bevy::reflect::TupleStructFieldIter<'_> {
125-
::bevy::reflect::TupleStructFieldIter::new(self)
124+
fn iter_fields(&'_ self) -> ::bevy::reflect::tuple_struct::TupleStructFieldIter<'_> {
125+
::bevy::reflect::tuple_struct::TupleStructFieldIter::new(self)
126126
}
127127
}
128128
impl ::bevy::reflect::PartialReflect for DynNodeLike {
@@ -139,10 +139,10 @@ impl ::bevy::reflect::PartialReflect for DynNodeLike {
139139
::bevy::reflect::PartialReflect::reflect_ref(value)
140140
{
141141
for (i, value) in ::core::iter::Iterator::enumerate(
142-
::bevy::reflect::TupleStruct::iter_fields(struct_value),
142+
::bevy::reflect::tuple_struct::TupleStruct::iter_fields(struct_value),
143143
) {
144144
if let ::core::option::Option::Some(v) =
145-
::bevy::reflect::TupleStruct::field_mut(self, i)
145+
::bevy::reflect::tuple_struct::TupleStruct::field_mut(self, i)
146146
{
147147
::bevy::reflect::PartialReflect::try_apply(v, value)?;
148148
}
@@ -201,7 +201,7 @@ impl ::bevy::reflect::PartialReflect for DynNodeLike {
201201
self
202202
}
203203
fn reflect_partial_eq(&self, value: &dyn ::bevy::reflect::PartialReflect) -> Option<bool> {
204-
(::bevy::reflect::tuple_struct_partial_eq)(self, value)
204+
(::bevy::reflect::tuple_struct::tuple_struct_partial_eq)(self, value)
205205
}
206206
#[inline]
207207
fn reflect_clone(

crates/bevy_animation_graph_core/src/animation_node/dyn_node_like/serial.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,8 @@ impl ReflectDeserializerProcessor for HandleDeserializeProcessor<'_, '_> {
7878
let asset_path = deserializer.deserialize_str(AssetPathVisitor)?;
7979
let untyped_handle = self
8080
.load_context
81-
.loader()
82-
.with_dynamic_type(asset_type_id)
83-
.load(asset_path);
81+
.load_builder()
82+
.load_erased(asset_type_id, asset_path);
8483
let typed_handle = handle_info.typed(untyped_handle);
8584
Ok(Ok(typed_handle.into_partial_reflect()))
8685
}

crates/bevy_animation_graph_core/src/context/node_state_box.rs

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ impl ::bevy::reflect::Typed for NodeStateBox {
4646
static CELL: ::bevy::reflect::utility::NonGenericTypeInfoCell =
4747
::bevy::reflect::utility::NonGenericTypeInfoCell::new();
4848
CELL.get_or_set(|| {
49-
::bevy::reflect::TypeInfo::Struct(::bevy::reflect::StructInfo::new::<Self>(&[
49+
::bevy::reflect::TypeInfo::Struct(::bevy::reflect::structs::StructInfo::new::<Self>(&[
5050
::bevy::reflect::NamedField::new::<String>("value"),
5151
]))
5252
})
@@ -116,7 +116,7 @@ impl ::bevy::reflect::Reflect for NodeStateBox {
116116
::bevy::reflect::__macro_exports::auto_register::inventory::submit! {
117117
::bevy::reflect::__macro_exports::auto_register::AutomaticReflectRegistrations(<NodeStateBox as ::bevy::reflect::__macro_exports::auto_register::RegisterForReflection> ::__register)
118118
}
119-
impl ::bevy::reflect::Struct for NodeStateBox {
119+
impl ::bevy::reflect::structs::Struct for NodeStateBox {
120120
fn field(&self, name: &str) -> ::core::option::Option<&dyn ::bevy::reflect::PartialReflect> {
121121
match name {
122122
"value" => ::core::option::Option::Some(self.value.as_reflect()),
@@ -159,11 +159,12 @@ impl ::bevy::reflect::Struct for NodeStateBox {
159159
fn field_len(&self) -> usize {
160160
1usize
161161
}
162-
fn iter_fields(&'_ self) -> ::bevy::reflect::FieldIter<'_> {
163-
::bevy::reflect::FieldIter::new(self)
162+
fn iter_fields(&'_ self) -> ::bevy::reflect::structs::FieldIter<'_> {
163+
::bevy::reflect::structs::FieldIter::new(self)
164164
}
165-
fn to_dynamic_struct(&self) -> ::bevy::reflect::DynamicStruct {
166-
let mut dynamic: ::bevy::reflect::DynamicStruct = ::core::default::Default::default();
165+
fn to_dynamic_struct(&self) -> ::bevy::reflect::structs::DynamicStruct {
166+
let mut dynamic: ::bevy::reflect::structs::DynamicStruct =
167+
::core::default::Default::default();
167168
dynamic.set_represented_type(::bevy::reflect::PartialReflect::get_represented_type_info(
168169
self,
169170
));
@@ -173,6 +174,13 @@ impl ::bevy::reflect::Struct for NodeStateBox {
173174
);
174175
dynamic
175176
}
177+
178+
fn index_of_name(&self, name: &str) -> Option<usize> {
179+
match name {
180+
"value" => ::core::option::Option::Some(0usize),
181+
_ => ::core::option::Option::None,
182+
}
183+
}
176184
}
177185
impl ::bevy::reflect::PartialReflect for NodeStateBox {
178186
#[inline]
@@ -189,12 +197,9 @@ impl ::bevy::reflect::PartialReflect for NodeStateBox {
189197
if let ::bevy::reflect::ReflectRef::Struct(struct_value) =
190198
::bevy::reflect::PartialReflect::reflect_ref(value)
191199
{
192-
for (i, value) in ::core::iter::Iterator::enumerate(
193-
::bevy::reflect::Struct::iter_fields(struct_value),
194-
) {
195-
let name = ::bevy::reflect::Struct::name_at(struct_value, i).unwrap();
200+
for (name, value) in ::bevy::reflect::structs::Struct::iter_fields(struct_value) {
196201
if let ::core::option::Option::Some(v) =
197-
::bevy::reflect::Struct::field_mut(self, name)
202+
::bevy::reflect::structs::Struct::field_mut(self, name)
198203
{
199204
::bevy::reflect::PartialReflect::try_apply(v, value)?;
200205
}
@@ -261,7 +266,7 @@ impl ::bevy::reflect::PartialReflect for NodeStateBox {
261266
&self,
262267
value: &dyn ::bevy::reflect::PartialReflect,
263268
) -> ::core::option::Option<bool> {
264-
(::bevy::reflect::struct_partial_eq)(self, value)
269+
(::bevy::reflect::structs::struct_partial_eq)(self, value)
265270
}
266271
#[inline]
267272
fn reflect_clone(

crates/bevy_animation_graph_core/src/plugin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl AnimationGraphCorePlugin {
201201
fn register_component_hooks(&self, app: &mut App) {
202202
app.world_mut()
203203
.register_component_hooks::<AnimationGraphPlayer>()
204-
.on_replace(|mut world, context| {
204+
.on_discard(|mut world, context| {
205205
if let Some(spawned_ragdoll) = world
206206
.entity(context.entity)
207207
.get::<AnimationGraphPlayer>()

crates/bevy_animation_graph_core/src/ragdoll/spawning.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#[cfg(feature = "physics_avian")]
2+
use avian3d::dynamics::joints::AngularMotor;
3+
#[cfg(feature = "physics_avian")]
24
use bevy::{ecs::system::Commands, math::Isometry3d};
35
use bevy::{
46
ecs::{entity::Entity, event::EntityEvent},
@@ -220,6 +222,7 @@ pub fn spawn_ragdoll_avian(
220222
min: limit.min,
221223
max: limit.max,
222224
}),
225+
motor: AngularMotor::default(),
223226
point_compliance: revolute_joint.point_compliance,
224227
align_compliance: revolute_joint.align_compliance,
225228
limit_compliance: revolute_joint.limit_compliance,

0 commit comments

Comments
 (0)