diff --git a/studio/src/bvh/mod.rs b/studio/src/bvh/mod.rs index d8053a8..808709b 100644 --- a/studio/src/bvh/mod.rs +++ b/studio/src/bvh/mod.rs @@ -1,11 +1,26 @@ use std::backtrace::Backtrace; -use bevy::{prelude::*, ecs::{system::{Command, EntityCommands, SystemParam}, query::{WorldQuery, ReadOnlyWorldQuery}}, asset::AsyncReadExt, transform::commands}; -use studio_bvh::{joint, frames::Frame}; +use bevy::{ + asset::AsyncReadExt, + ecs::{ + query::{self, ReadOnlyWorldQuery, WorldQuery}, + system::{Command, EntityCommands, SystemParam}, + }, + gltf::Gltf, + prelude::*, + scene, + transform::commands, + utils::hashbrown::HashMap, +}; +use bevy_inspector_egui::egui::TextBuffer; +use bevy_rapier3d::parry::transformation; +use studio_bvh::{frames::Frame, joint}; mod error; mod loader; +use crate::scene::SceneState; + use self::loader::BvhLoader; pub struct BvhPlugin; @@ -14,18 +29,12 @@ impl Plugin for BvhPlugin { fn build(&self, app: &mut App) { app.init_asset::() .register_asset_loader(BvhLoader) - .add_systems(Update, animate_bvh) - + .add_systems(Update, animate_bvh.run_if(in_state(SceneState::Active))) .register_type::() - .register_type::() - ; + .register_type::(); } } -//============================================================================== -// Bvh Asset -//============================================================================== - #[derive(Clone, Debug, Default, Asset, TypePath)] pub struct Bvh(studio_bvh::Bvh); @@ -36,26 +45,29 @@ pub struct Bvh(studio_bvh::Bvh); #[derive(Component, Debug, Reflect)] pub struct BvhAnim { #[reflect(ignore)] - bvh : Handle, - should_play : bool, - frame : usize, + bvh: Handle, + should_play: bool, + frame: usize, #[reflect(ignore)] - timer : Timer, + timer: Timer, #[reflect(ignore)] - last_frame : usize, + last_frame: usize, } pub fn animate_bvh( - mut command : Commands, - mut bvh_anims : Query<(Entity, &mut BvhAnim, &mut Transform, &mut Children)>, - mut bvh_joints : Query>, - bvh_assets : Res>, - time : Res