mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-11-22 20:00:53 +00:00
chore(): some clippy changes
This commit is contained in:
parent
7a8b91f4ec
commit
742c5b19f0
@ -41,7 +41,7 @@ pub struct AnimationInfo {
|
||||
}
|
||||
|
||||
/// Stores information about animations, to make things a bit easier api wise:
|
||||
/// these components are automatically inserted by gltf_auto_export on entities that have animations
|
||||
/// these components are automatically inserted by `gltf_auto_export` on entities that have animations
|
||||
#[derive(Component, Reflect, Default, Debug)]
|
||||
#[reflect(Component)]
|
||||
pub struct AnimationInfos {
|
||||
@ -56,7 +56,7 @@ pub struct AnimationMarker {
|
||||
}
|
||||
|
||||
/// Stores information about animation markers: practical for adding things like triggering events at specific keyframes etc
|
||||
/// it is essentiall a hashmap of AnimationName => HashMap<FrameNumber, Vec of marker names>
|
||||
/// it is essentiall a hashmap of `AnimationName` => `HashMap`<`FrameNumber`, Vec of marker names>
|
||||
#[derive(Component, Reflect, Default, Debug)]
|
||||
#[reflect(Component)]
|
||||
pub struct AnimationMarkers(pub HashMap<String, HashMap<u32, Vec<String>>>);
|
||||
@ -115,23 +115,23 @@ pub fn trigger_instance_animation_markers_events(
|
||||
let time_in_animation = animation_player.elapsed()
|
||||
- (animation_player.completions() as f32) * animation_length_seconds;
|
||||
let frame_seconds =
|
||||
(animation_length_frames as f32 / animation_length_seconds) * time_in_animation;
|
||||
(animation_length_frames / animation_length_seconds) * time_in_animation;
|
||||
let frame = frame_seconds as u32;
|
||||
|
||||
let matching_animation_marker = &markers.0[animation_name];
|
||||
if matching_animation_marker.contains_key(&frame) {
|
||||
let matching_markers_per_frame = matching_animation_marker.get(&frame).unwrap();
|
||||
|
||||
let foo = animation_length_seconds - time_in_animation;
|
||||
println!("foo {}", foo);
|
||||
// let timediff = animation_length_seconds - time_in_animation;
|
||||
// println!("timediff {}", timediff);
|
||||
// println!("FOUND A MARKER {:?} at frame {}", matching_markers_per_frame, frame);
|
||||
// emit an event AnimationMarkerReached(entity, animation_name, frame, marker_name)
|
||||
// FIXME: problem, this can fire multiple times in a row, depending on animation length , speed , etc
|
||||
for marker in matching_markers_per_frame {
|
||||
animation_marker_events.send(AnimationMarkerReached {
|
||||
entity: entity,
|
||||
entity,
|
||||
animation_name: animation_name.clone(),
|
||||
frame: frame,
|
||||
frame,
|
||||
marker_name: marker.clone(),
|
||||
});
|
||||
}
|
||||
@ -199,9 +199,9 @@ pub fn trigger_blueprint_animation_markers_events(
|
||||
if diff < 0.1 {
|
||||
for marker in matching_markers_per_frame {
|
||||
animation_marker_events.send(AnimationMarkerReached {
|
||||
entity: entity,
|
||||
entity,
|
||||
animation_name: animation_name.clone(),
|
||||
frame: frame,
|
||||
frame,
|
||||
marker_name: marker.clone(),
|
||||
});
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ use std::time::Duration;
|
||||
use bevy::prelude::*;
|
||||
|
||||
use bevy_gltf_blueprints::{
|
||||
AnimationPlayerLink, Animations, BluePrintBundle, BlueprintName, GameWorldTag,
|
||||
BlueprintAnimationPlayerLink, BlueprintAnimations, BluePrintBundle, BlueprintName, GameWorldTag,
|
||||
};
|
||||
|
||||
use super::{Fox, Robot};
|
||||
@ -90,7 +90,7 @@ pub fn spawn_test(
|
||||
// example of changing animation of entities based on proximity to the player, for "fox" entities (Tag component)
|
||||
pub fn animation_change_on_proximity_foxes(
|
||||
players: Query<&GlobalTransform, With<Player>>,
|
||||
animated_foxes: Query<(&GlobalTransform, &AnimationPlayerLink, &Animations), With<Fox>>,
|
||||
animated_foxes: Query<(&GlobalTransform, &BlueprintAnimationPlayerLink, &BlueprintAnimations), With<Fox>>,
|
||||
|
||||
mut animation_players: Query<&mut AnimationPlayer>,
|
||||
) {
|
||||
@ -126,7 +126,7 @@ pub fn animation_change_on_proximity_foxes(
|
||||
// example of changing animation of entities based on proximity to the player, this time for the "robot" entities (Tag component)
|
||||
pub fn animation_change_on_proximity_robots(
|
||||
players: Query<&GlobalTransform, With<Player>>,
|
||||
animated_robots: Query<(&GlobalTransform, &AnimationPlayerLink, &Animations), With<Robot>>,
|
||||
animated_robots: Query<(&GlobalTransform, &BlueprintAnimationPlayerLink, &BlueprintAnimations), With<Robot>>,
|
||||
|
||||
mut animation_players: Query<&mut AnimationPlayer>,
|
||||
) {
|
||||
@ -162,13 +162,13 @@ pub fn animation_change_on_proximity_robots(
|
||||
}
|
||||
|
||||
pub fn animation_control(
|
||||
animated_enemies: Query<(&AnimationPlayerLink, &Animations), With<Robot>>,
|
||||
animated_foxes: Query<(&AnimationPlayerLink, &Animations), With<Fox>>,
|
||||
animated_enemies: Query<(&BlueprintAnimationPlayerLink, &BlueprintAnimations), With<Robot>>,
|
||||
animated_foxes: Query<(&BlueprintAnimationPlayerLink, &BlueprintAnimations), With<Fox>>,
|
||||
|
||||
mut animation_players: Query<&mut AnimationPlayer>,
|
||||
|
||||
keycode: Res<ButtonInput<KeyCode>>,
|
||||
// mut entities_with_animations : Query<(&mut AnimationPlayer, &mut Animations)>,
|
||||
// mut entities_with_animations : Query<(&mut AnimationPlayer, &mut BlueprintAnimations)>,
|
||||
) {
|
||||
// robots
|
||||
if keycode.just_pressed(KeyCode::KeyB) {
|
||||
|
@ -34,6 +34,7 @@ pub fn setup_main_scene_animations(asset_server: Res<AssetServer>, mut commands:
|
||||
commands.insert_resource(AnimTest(asset_server.load("models/World.glb")));
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn animations(
|
||||
added_animation_players: Query<(Entity, &Name, &AnimationPlayer)>,
|
||||
added_animation_infos: Query<(Entity, &Name, &AnimationInfos), Added<AnimationInfos>>,
|
||||
@ -71,10 +72,10 @@ pub fn animations(
|
||||
// info!("{:?} is an ancestor of {:?}", ancestor, player);
|
||||
}
|
||||
}
|
||||
println!("");
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub fn play_animations(
|
||||
animated_marker1: Query<
|
||||
(&SceneAnimationPlayerLink, &SceneAnimations),
|
||||
|
@ -7,7 +7,7 @@ use std::{collections::HashMap, fs, time::Duration};
|
||||
|
||||
use bevy_gltf_blueprints::{
|
||||
BlueprintAnimationPlayerLink, BlueprintName, BlueprintsList,
|
||||
GltfBlueprintsSet,
|
||||
GltfBlueprintsSet, SceneAnimations,
|
||||
};
|
||||
|
||||
use bevy::{
|
||||
@ -26,18 +26,20 @@ fn start_game(mut next_app_state: ResMut<NextState<AppState>>) {
|
||||
// if the export from Blender worked correctly, we should have a blueprints_list
|
||||
// if the export from Blender worked correctly, we should have the correct tree of entities
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn validate_export(
|
||||
parents: Query<&Parent>,
|
||||
children: Query<&Children>,
|
||||
names: Query<&Name>,
|
||||
blueprints: Query<(Entity, &Name, &BlueprintName)>,
|
||||
animation_player_links: Query<(Entity, &BlueprintAnimationPlayerLink)>,
|
||||
scene_animations: Query<(Entity, &SceneAnimations)>,
|
||||
empties_candidates: Query<(Entity, &Name, &GlobalTransform)>,
|
||||
|
||||
blueprints_list: Query<(Entity, &BlueprintsList)>,
|
||||
root: Query<(Entity, &Name, &Children), (Without<Parent>, With<Children>)>,
|
||||
) {
|
||||
let animations_found = !animation_player_links.is_empty();
|
||||
let animations_found = !animation_player_links.is_empty() && scene_animations.into_iter().len() == 4;
|
||||
|
||||
let mut nested_blueprint_found = false;
|
||||
for (entity, name, blueprint_name) in blueprints.iter() {
|
||||
|
Loading…
Reference in New Issue
Block a user