diff --git a/studio/src/anim/mod.rs b/studio/src/anim/mod.rs index e9b87be..2957988 100644 --- a/studio/src/anim/mod.rs +++ b/studio/src/anim/mod.rs @@ -100,7 +100,7 @@ fn process_skinned_meshes( // ``` // Building this hashmap before processing each joint avoids redundancy in // the common case where the same joints are bound to multiple skinned meshes - let mut joint_collections = EntityHashMap::>::default(); + let mut joint_collections = EntityHashMap::::default(); for (ent, skinned_mesh) in q_skinned_meshes.iter() { cmd.entity(ent) .insert(NoFrustumCulling) diff --git a/studio/src/bvh/mod.rs b/studio/src/bvh/mod.rs index 888dc02..675a283 100644 --- a/studio/src/bvh/mod.rs +++ b/studio/src/bvh/mod.rs @@ -129,7 +129,7 @@ pub fn animate_bvh( } } - anim.timer.percent() + anim.timer.fraction() } else { 0. }; diff --git a/studio/src/headless.rs b/studio/src/headless.rs index f71a638..63659f0 100644 --- a/studio/src/headless.rs +++ b/studio/src/headless.rs @@ -8,7 +8,7 @@ use wgpu::Extent3d; use crate::{ bvh::{BvhAnimCompleteEvent, TestBvh}, - scene::SceneState, + scene::{SceneState, SkyboxHolder}, screenshot::{ScreenCapture, ScreenShotPlugin}, BvhPlugin, CommonPlugins, LoadLibraryObjectEvent, LoadSceneEvent, MainCamera, MixamoImportEvent, MixamoPlugin, SkyboxId, StudioMode, WorldGridPlugin, @@ -72,12 +72,11 @@ pub fn start_headless( HeadlessMode::Scene(scene, skybox) => { app.add_systems( Startup, - move |mut cmd: Commands, mut ew: EventWriter| { - cmd.insert_resource(Skybox { - image : skybox.clone(), - brightness: 1.0 - }); - ew.send(EditorEvent::Load(EditorPrefabPath::File(scene.clone()))) + move |mut cmd: Commands, mut ew: EventWriter, mut asset_server: Res| { + + cmd.insert_resource(SkyboxHolder(Some(Skybox { image: asset_server.load(skybox.clone()), brightness: 1.0 }))); + + ew.send(EditorEvent::Load(EditorPrefabPath::File(scene.clone()))); }, ); } diff --git a/studio/src/hierarchy.rs b/studio/src/hierarchy.rs index 01a5235..45bd1ac 100644 --- a/studio/src/hierarchy.rs +++ b/studio/src/hierarchy.rs @@ -28,7 +28,7 @@ pub(crate) fn nearest_common_ancestor( q_parents: &Query>, ) -> Option { // Find the depth of each entity in the tree - let mut depths: EntityHashMap = EntityHashMap::default(); + let mut depths = EntityHashMap::default(); for &ent in entities { depths.insert(ent, find_depth(ent, q_parents)); } @@ -40,7 +40,7 @@ pub(crate) fn nearest_common_ancestor( // Traverse up the tree from each entity until we find each one's ancestor // at the level of lowest_depth - let mut equalized: EntityHashSet = EntityHashSet::default(); + let mut equalized = EntityHashSet::default(); for ent in entities { let mut depth = depths[ent]; let mut result = *ent; @@ -60,7 +60,7 @@ pub(crate) fn nearest_common_ancestor( // by adding a some kind of mode switch to this function's parameters. // Walk up the tree from each of those entities until we find the common ancestor - let mut parents: EntityHashSet = EntityHashSet::default(); + let mut parents = EntityHashSet::default(); loop { for &ent in equalized.iter() { if let Some(parent) = find_parent(ent, q_parents) { diff --git a/studio/src/input.rs b/studio/src/input.rs index 72b800f..4ba2f40 100644 --- a/studio/src/input.rs +++ b/studio/src/input.rs @@ -97,9 +97,9 @@ fn translate_selection_events(keyboard: Res>, mut input: Ev input.send(InputAction(Lifecycle::Stop, Selection::Clear.into())); } - if keyboard.just_pressed(KeyCode::F) { + if keyboard.just_pressed(KeyCode::KeyF) { input.send(InputAction(Lifecycle::Start, Selection::Focus.into())); - } else if keyboard.just_released(KeyCode::F) { + } else if keyboard.just_released(KeyCode::KeyF) { input.send(InputAction(Lifecycle::Stop, Selection::Focus.into())); } @@ -112,9 +112,9 @@ fn translate_selection_events(keyboard: Res>, mut input: Ev fn translate_debug_toggle(keyboard: Res>, mut input: EventWriter) { if keyboard.pressed(KeyCode::ControlLeft) || keyboard.pressed(KeyCode::ControlRight) { - if keyboard.just_pressed(KeyCode::Grave) { + if keyboard.just_pressed(KeyCode::Backquote) { input.send(InputAction(Lifecycle::Start, Action::ToggleDebug)); - } else if keyboard.just_released(KeyCode::Grave) { + } else if keyboard.just_released(KeyCode::Backquote) { input.send(InputAction(Lifecycle::Stop, Action::ToggleDebug)); } } @@ -232,7 +232,7 @@ fn translate_fps_camera_events( ) { // Camera Translation (FPS-like) use KeyCode::*; - let wasd_keys = [KeyCode::W, KeyCode::A, KeyCode::S, KeyCode::D, KeyCode::E, KeyCode::Q]; + let wasd_keys = [KeyCode::KeyW, KeyCode::KeyA, KeyCode::KeyS, KeyCode::KeyD, KeyCode::KeyE, KeyCode::KeyQ]; let wasd_keys_set = wasd_keys.into_iter().collect::>(); // A little unfortunate that `get_pressed()` doesn't just return a reference @@ -247,12 +247,12 @@ fn translate_fps_camera_events( let mut mvmt = Vec3::ZERO; #[rustfmt::skip] { - if wasd_keys_pressed.contains(&KeyCode::W) { mvmt.z -= 1.; } - if wasd_keys_pressed.contains(&KeyCode::A) { mvmt.x -= 1.; } - if wasd_keys_pressed.contains(&KeyCode::S) { mvmt.z += 1.; } - if wasd_keys_pressed.contains(&KeyCode::D) { mvmt.x += 1.; } - if wasd_keys_pressed.contains(&KeyCode::E) { mvmt.y += 1.; } - if wasd_keys_pressed.contains(&KeyCode::Q) { mvmt.y -= 1.; } + if wasd_keys_pressed.contains(&KeyCode::KeyW) { mvmt.z -= 1.; } + if wasd_keys_pressed.contains(&KeyCode::KeyA) { mvmt.x -= 1.; } + if wasd_keys_pressed.contains(&KeyCode::KeyS) { mvmt.z += 1.; } + if wasd_keys_pressed.contains(&KeyCode::KeyD) { mvmt.x += 1.; } + if wasd_keys_pressed.contains(&KeyCode::KeyE) { mvmt.y += 1.; } + if wasd_keys_pressed.contains(&KeyCode::KeyQ) { mvmt.y -= 1.; } }; let mvmt = mvmt.normalize_or_zero(); @@ -335,7 +335,7 @@ fn read_mouse_delta( // TODO: Make it configurable fn send_undo_event(mut events: EventWriter, keyboard: Res>) { if keyboard.pressed(KeyCode::ControlLeft) - && keyboard.just_pressed(KeyCode::Z) + && keyboard.just_pressed(KeyCode::KeyZ) && !keyboard.pressed(KeyCode::ShiftLeft) { events.send(UndoRedo::Undo); @@ -343,7 +343,7 @@ fn send_undo_event(mut events: EventWriter, keyboard: Res::into(design_system::Color::RED)); + let translate_yz = ra_mats.add(Into::::into(design_system::Color::RED)); - let translate_y = ra_mats.add(design_system::Color::GREEN.into()); - let translate_xz = ra_mats.add(design_system::Color::GREEN.into()); + let translate_y = ra_mats.add(Into::::into(design_system::Color::GREEN)); + let translate_xz = ra_mats.add(Into::::into(design_system::Color::GREEN)); - let translate_z = ra_mats.add(design_system::Color::BLUE.into()); - let translate_xy = ra_mats.add(design_system::Color::BLUE.into()); + let translate_z = ra_mats.add(Into::::into(design_system::Color::BLUE)); + let translate_xy = ra_mats.add(Into::::into(design_system::Color::BLUE)); - let translate_ss = ra_mats.add(Color::WHITE.into()); + let translate_ss = ra_mats.add(Into::::into(Color::WHITE)); - let rotate_x = ra_mats.add(design_system::Color::RED.into()); - let rotate_y = ra_mats.add(design_system::Color::GREEN.into()); - let rotate_z = ra_mats.add(design_system::Color::BLUE.into()); - let rotate_ss = ra_mats.add(Color::WHITE.into()); + let rotate_x = ra_mats.add(Into::::into(design_system::Color::RED)); + let rotate_y = ra_mats.add(Into::::into(design_system::Color::GREEN)); + let rotate_z = ra_mats.add(Into::::into(design_system::Color::BLUE)); + let rotate_ss = ra_mats.add(Into::::into(Color::WHITE)); - let scale_x = ra_mats.add(design_system::Color::RED.into()); - let scale_y = ra_mats.add(design_system::Color::GREEN.into()); - let scale_z = ra_mats.add(design_system::Color::BLUE.into()); + let scale_x = ra_mats.add(Into::::into(design_system::Color::RED)); + let scale_y = ra_mats.add(Into::::into(design_system::Color::GREEN)); + let scale_z = ra_mats.add(Into::::into(design_system::Color::BLUE)); let rotate_trackball = ra_mats.add(GizmoMaterial { color: Color::WHITE.with_a(0.0), diff --git a/studio/src/interaction/gizmos/rotation.rs b/studio/src/interaction/gizmos/rotation.rs index 3c0420e..4363984 100644 --- a/studio/src/interaction/gizmos/rotation.rs +++ b/studio/src/interaction/gizmos/rotation.rs @@ -302,7 +302,7 @@ pub(super) fn on_rotate( } let view_plane_normal = (cam_xform.translation() - p1).normalize(); - let hit_dist = ray.intersect_plane(p1, view_plane_normal).unwrap(); + let hit_dist = ray.intersect_plane(p1, Plane3d::new(view_plane_normal)).unwrap(); let p2 = ray.origin + ray.direction * hit_dist; let drag_dist = (p2 - p1).length(); // TODO: Sensitivity could use some tuning @@ -366,7 +366,7 @@ pub(super) fn on_rotate( }; // Find the world-space p2, if possible - let Some(hit_dist) = ray.intersect_plane(p0, axis_ws) else { + let Some(hit_dist) = ray.intersect_plane(p0, Plane3d::new(axis_ws)) else { // This could fail if the axis of rotation is nearly // perpendicular to the view direction return; diff --git a/studio/src/interaction/gizmos/scale.rs b/studio/src/interaction/gizmos/scale.rs index 1babb0a..6e20b42 100644 --- a/studio/src/interaction/gizmos/scale.rs +++ b/studio/src/interaction/gizmos/scale.rs @@ -261,7 +261,7 @@ pub(super) fn on_scale( let plane_vector = axis_ws.cross(axis_tan); // Find the intersection of the camera-to-world ray against that plane - let Some(hit_dist) = ray.intersect_plane(origin_ws, plane_vector) else { + let Some(hit_dist) = ray.intersect_plane(origin_ws, Plane3d::new(plane_vector)) else { return; }; let hit_point = ray.origin + ray.direction * hit_dist; @@ -299,7 +299,7 @@ pub(super) fn on_scale( .affine() .transform_vector3(*plane_normal) .normalize(); - let Some(hit_dist) = ray.intersect_plane(origin_ws, normal_ws) else { + let Some(hit_dist) = ray.intersect_plane(origin_ws, Plane3d::new(normal_ws)) else { return; }; let hit_point = ray.origin + ray.direction * hit_dist; diff --git a/studio/src/interaction/gizmos/translation.rs b/studio/src/interaction/gizmos/translation.rs index 14d4f75..7f966cc 100644 --- a/studio/src/interaction/gizmos/translation.rs +++ b/studio/src/interaction/gizmos/translation.rs @@ -257,7 +257,7 @@ pub(super) fn on_translate( let plane_vector = axis_ws.cross(axis_tan); // Find the intersection of the camera-to-world ray against that plane - let Some(hit_dist) = ray.intersect_plane(origin_ws, plane_vector) else { + let Some(hit_dist) = ray.intersect_plane(origin_ws, Plane3d::new(plane_vector)) else { return; }; let hit_point = ray.origin + ray.direction * hit_dist; @@ -290,7 +290,7 @@ pub(super) fn on_translate( }; // Find the intersection of the camera-to-world ray against that plane - let Some(hit_dist) = ray.intersect_plane(origin_ws, plane_normal) else { + let Some(hit_dist) = ray.intersect_plane(origin_ws, Plane3d::new(plane_normal)) else { return; }; let target_ws = ray.origin + ray.direction * hit_dist; diff --git a/studio/src/interaction/selection.rs b/studio/src/interaction/selection.rs index 3c42ae9..01401e9 100644 --- a/studio/src/interaction/selection.rs +++ b/studio/src/interaction/selection.rs @@ -20,7 +20,7 @@ impl Plugin for SelectionPlugin { Update, ( update_selection, - process_delete_inputs.run_if(resource_exists::()), + process_delete_inputs.run_if(resource_exists::), ), ) .add_systems( diff --git a/studio/src/remote/mod.rs b/studio/src/remote/mod.rs index 99ce463..6aafc00 100644 --- a/studio/src/remote/mod.rs +++ b/studio/src/remote/mod.rs @@ -16,7 +16,7 @@ impl Plugin for RemoteAssetPlugin { AssetSourceId::Name("remote".into()), AssetSource::build() .with_reader(|| Box::new(RemoteAssetReader)) - .with_writer(|| None), + .with_writer(|_| None), ); } } diff --git a/studio/src/remote/reader.rs b/studio/src/remote/reader.rs index f45d933..aca12c3 100644 --- a/studio/src/remote/reader.rs +++ b/studio/src/remote/reader.rs @@ -1,4 +1,4 @@ -use std::{io::ErrorKind, path::Path}; +use std::{io::ErrorKind, path::Path, sync::Arc}; use bevy::{ asset::io::{AssetReader, AssetReaderError, PathStream, Reader, VecReader}, @@ -26,10 +26,10 @@ impl AssetReader for RemoteAssetReader { let token = path .ext_file_prefix() .ok_or_else(|| { - AssetReaderError::Io(std::io::Error::new( + AssetReaderError::Io(Arc::new(std::io::Error::new( ErrorKind::Other, format!("Failed to parse token from '{path:?}'"), - )) + ))) })? .to_str() .unwrap(); @@ -45,10 +45,10 @@ impl AssetReader for RemoteAssetReader { .json::() .await .map_err(IntoError::::into), - other => Err(AssetReaderError::Io(std::io::Error::new( + other => Err(AssetReaderError::Io(Arc::new(std::io::Error::new( ErrorKind::Other, format!("Status Code from endpoint: {other}"), - ))), + )))), }?; let url = format!( @@ -74,10 +74,10 @@ impl AssetReader for RemoteAssetReader { .map_err(IntoError::::into)? .into_iter() .collect::>()), - other => Err(AssetReaderError::Io(std::io::Error::new( + other => Err(AssetReaderError::Io(Arc::new(std::io::Error::new( ErrorKind::Other, format!("Status Code from bucket URL: {other}"), - ))), + )))), }?; let reader: Box = Box::new(VecReader::new(bytes)); @@ -113,6 +113,6 @@ trait IntoError { impl IntoError for reqwest::Error { fn into(self) -> AssetReaderError { - AssetReaderError::Io(std::io::Error::new(ErrorKind::Other, format!("{self}"))) + AssetReaderError::Io(Arc::new(std::io::Error::new(ErrorKind::Other, format!("{self}")))) } }