refactor(animation): renamed instancexxx to scenexxx (ie InstanceAnimations & InstancePlayerLinks)

This commit is contained in:
kaosat.dev 2024-04-08 23:48:07 +02:00
parent cf4673c1e3
commit 8683a6482f
4 changed files with 16 additions and 16 deletions

View File

@ -17,8 +17,8 @@ pub struct BlueprintAnimationPlayerLink(pub Entity);
#[derive(Component, Reflect, Default, Debug)] #[derive(Component, Reflect, Default, Debug)]
#[reflect(Component)] #[reflect(Component)]
/// storage for animations for a given entity (hierarchy), essentially a clone of gltf's `named_animations` /// storage for scene level animations for a given entity (hierarchy), essentially a clone of gltf's `named_animations`
pub struct InstanceAnimations { pub struct SceneAnimations {
pub named_animations: HashMap<String, Handle<AnimationClip>>, pub named_animations: HashMap<String, Handle<AnimationClip>>,
} }
@ -27,7 +27,7 @@ pub struct InstanceAnimations {
/// so that the root entity knows which of its children contains an actualy `AnimationPlayer` component /// so that the root entity knows which of its children contains an actualy `AnimationPlayer` component
/// this is for convenience, because currently , Bevy's gltf parsing inserts `AnimationPlayers` "one level down" /// this is for convenience, because currently , Bevy's gltf parsing inserts `AnimationPlayers` "one level down"
/// ie armature/root for animated models, which means more complex queries to trigger animations that we want to avoid /// ie armature/root for animated models, which means more complex queries to trigger animations that we want to avoid
pub struct InstanceAnimationPlayerLink(pub Entity); pub struct SceneAnimationPlayerLink(pub Entity);
/// Stores Animation information: name, frame informations etc /// Stores Animation information: name, frame informations etc
#[derive(Reflect, Default, Debug)] #[derive(Reflect, Default, Debug)]
@ -78,8 +78,8 @@ pub fn trigger_instance_animation_markers_events(
animation_infos: Query<( animation_infos: Query<(
Entity, Entity,
&AnimationMarkers, &AnimationMarkers,
&InstanceAnimationPlayerLink, &SceneAnimationPlayerLink,
&InstanceAnimations, &SceneAnimations,
&AnimationInfos, &AnimationInfos,
)>, )>,
animation_players: Query<&AnimationPlayer>, animation_players: Query<&AnimationPlayer>,

View File

@ -120,7 +120,7 @@ impl Plugin for BlueprintsPlugin {
.register_type::<MaterialInfo>() .register_type::<MaterialInfo>()
.register_type::<SpawnHere>() .register_type::<SpawnHere>()
.register_type::<BlueprintAnimations>() .register_type::<BlueprintAnimations>()
.register_type::<InstanceAnimations>() .register_type::<SceneAnimations>()
.register_type::<AnimationInfo>() .register_type::<AnimationInfo>()
.register_type::<AnimationInfos>() .register_type::<AnimationInfos>()
.register_type::<Vec<AnimationInfo>>() .register_type::<Vec<AnimationInfo>>()

View File

@ -3676,7 +3676,7 @@
"type": "object", "type": "object",
"typeInfo": "Struct" "typeInfo": "Struct"
}, },
"bevy_gltf_blueprints::animation::InstanceAnimations": { "bevy_gltf_blueprints::animation::SceneAnimations": {
"additionalProperties": false, "additionalProperties": false,
"isComponent": true, "isComponent": true,
"isResource": false, "isResource": false,
@ -3690,8 +3690,8 @@
"required": [ "required": [
"named_animations" "named_animations"
], ],
"short_name": "InstanceAnimations", "short_name": "SceneAnimations",
"title": "bevy_gltf_blueprints::animation::InstanceAnimations", "title": "bevy_gltf_blueprints::animation::SceneAnimations",
"type": "object", "type": "object",
"typeInfo": "Struct" "typeInfo": "Struct"
}, },

View File

@ -2,7 +2,7 @@ use std::time::Duration;
use bevy_gltf_blueprints::{ use bevy_gltf_blueprints::{
AnimationInfos, AnimationMarkerReached, BlueprintAnimationPlayerLink, BlueprintAnimations, AnimationInfos, AnimationMarkerReached, BlueprintAnimationPlayerLink, BlueprintAnimations,
InstanceAnimationPlayerLink, InstanceAnimations, SceneAnimationPlayerLink, SceneAnimations,
}; };
use bevy::{gltf::Gltf, prelude::*}; use bevy::{gltf::Gltf, prelude::*};
@ -58,7 +58,7 @@ pub fn animations(
name, entity name, entity
); );
println!("Found match {:?}", gltf.named_animations); println!("Found match {:?}", gltf.named_animations);
commands.entity(entity).insert(InstanceAnimations { commands.entity(entity).insert(SceneAnimations {
named_animations: gltf.named_animations.clone(), named_animations: gltf.named_animations.clone(),
}); });
for ancestor in parents.iter_ancestors(entity) { for ancestor in parents.iter_ancestors(entity) {
@ -66,7 +66,7 @@ pub fn animations(
// println!("found match with animationPlayer !! {:?}",names.get(ancestor)); // println!("found match with animationPlayer !! {:?}",names.get(ancestor));
commands commands
.entity(entity) .entity(entity)
.insert(InstanceAnimationPlayerLink(ancestor)); .insert(SceneAnimationPlayerLink(ancestor));
} }
// info!("{:?} is an ancestor of {:?}", ancestor, player); // info!("{:?} is an ancestor of {:?}", ancestor, player);
} }
@ -77,17 +77,17 @@ pub fn animations(
pub fn play_animations( pub fn play_animations(
animated_marker1: Query< animated_marker1: Query<
(&InstanceAnimationPlayerLink, &InstanceAnimations), (&SceneAnimationPlayerLink, &SceneAnimations),
(With<AnimationInfos>, With<Marker1>), (With<AnimationInfos>, With<Marker1>),
>, >,
animated_marker2: Query< animated_marker2: Query<
(&InstanceAnimationPlayerLink, &InstanceAnimations), (&SceneAnimationPlayerLink, &SceneAnimations),
(With<AnimationInfos>, With<Marker2>), (With<AnimationInfos>, With<Marker2>),
>, >,
animated_marker3: Query< animated_marker3: Query<
( (
&InstanceAnimationPlayerLink, &SceneAnimationPlayerLink,
&InstanceAnimations, &SceneAnimations,
&BlueprintAnimationPlayerLink, &BlueprintAnimationPlayerLink,
&BlueprintAnimations, &BlueprintAnimations,
), ),