mirror of
https://github.com/storytold/storyteller-bevy.git
synced 2026-10-16 00:03:29 +00:00
All stuff beside lerp and screenshot
This commit is contained in:
@@ -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::<Entity, EntityHashSet<Entity>>::default();
|
||||
let mut joint_collections = EntityHashMap::<EntityHashSet>::default();
|
||||
for (ent, skinned_mesh) in q_skinned_meshes.iter() {
|
||||
cmd.entity(ent)
|
||||
.insert(NoFrustumCulling)
|
||||
|
||||
@@ -129,7 +129,7 @@ pub fn animate_bvh(
|
||||
}
|
||||
}
|
||||
|
||||
anim.timer.percent()
|
||||
anim.timer.fraction()
|
||||
} else {
|
||||
0.
|
||||
};
|
||||
|
||||
@@ -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<EditorEvent>| {
|
||||
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<EditorEvent>, mut asset_server: Res<AssetServer>| {
|
||||
|
||||
cmd.insert_resource(SkyboxHolder(Some(Skybox { image: asset_server.load(skybox.clone()), brightness: 1.0 })));
|
||||
|
||||
ew.send(EditorEvent::Load(EditorPrefabPath::File(scene.clone())));
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ pub(crate) fn nearest_common_ancestor(
|
||||
q_parents: &Query<Option<&Parent>>,
|
||||
) -> Option<Entity> {
|
||||
// Find the depth of each entity in the tree
|
||||
let mut depths: EntityHashMap<Entity, usize> = 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<Entity> = 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<Entity> = EntityHashSet::default();
|
||||
let mut parents = EntityHashSet::default();
|
||||
loop {
|
||||
for &ent in equalized.iter() {
|
||||
if let Some(parent) = find_parent(ent, q_parents) {
|
||||
|
||||
+13
-13
@@ -97,9 +97,9 @@ fn translate_selection_events(keyboard: Res<ButtonInput<KeyCode>>, 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<ButtonInput<KeyCode>>, mut input: Ev
|
||||
|
||||
fn translate_debug_toggle(keyboard: Res<ButtonInput<KeyCode>>, mut input: EventWriter<InputAction>) {
|
||||
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::<HashSet<_>>();
|
||||
|
||||
// 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<UndoRedo>, keyboard: Res<ButtonInput<KeyCode>>) {
|
||||
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<UndoRedo>, keyboard: Res<ButtonInput<
|
||||
}
|
||||
|
||||
if keyboard.pressed(KeyCode::ControlLeft)
|
||||
&& keyboard.just_pressed(KeyCode::Z)
|
||||
&& keyboard.just_pressed(KeyCode::KeyZ)
|
||||
&& keyboard.pressed(KeyCode::ShiftLeft)
|
||||
{
|
||||
events.send(UndoRedo::Redo);
|
||||
|
||||
@@ -2,7 +2,7 @@ use bevy::prelude::*;
|
||||
|
||||
use crate::{design_system, math::geo};
|
||||
|
||||
use super::material::GizmoMaterial;
|
||||
use super::material::*;
|
||||
|
||||
#[derive(Resource, Reflect, Debug, Default)]
|
||||
#[reflect(Resource)]
|
||||
@@ -98,25 +98,25 @@ pub(super) fn init_resources(
|
||||
uniform_scale_cube,
|
||||
});
|
||||
|
||||
let translate_x = ra_mats.add(design_system::Color::RED.into());
|
||||
let translate_yz = ra_mats.add(design_system::Color::RED.into());
|
||||
let translate_x = ra_mats.add(Into::<GizmoMaterial>::into(design_system::Color::RED));
|
||||
let translate_yz = ra_mats.add(Into::<GizmoMaterial>::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::<GizmoMaterial>::into(design_system::Color::GREEN));
|
||||
let translate_xz = ra_mats.add(Into::<GizmoMaterial>::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::<GizmoMaterial>::into(design_system::Color::BLUE));
|
||||
let translate_xy = ra_mats.add(Into::<GizmoMaterial>::into(design_system::Color::BLUE));
|
||||
|
||||
let translate_ss = ra_mats.add(Color::WHITE.into());
|
||||
let translate_ss = ra_mats.add(Into::<GizmoMaterial>::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::<GizmoMaterial>::into(design_system::Color::RED));
|
||||
let rotate_y = ra_mats.add(Into::<GizmoMaterial>::into(design_system::Color::GREEN));
|
||||
let rotate_z = ra_mats.add(Into::<GizmoMaterial>::into(design_system::Color::BLUE));
|
||||
let rotate_ss = ra_mats.add(Into::<GizmoMaterial>::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::<GizmoMaterial>::into(design_system::Color::RED));
|
||||
let scale_y = ra_mats.add(Into::<GizmoMaterial>::into(design_system::Color::GREEN));
|
||||
let scale_z = ra_mats.add(Into::<GizmoMaterial>::into(design_system::Color::BLUE));
|
||||
|
||||
let rotate_trackball = ra_mats.add(GizmoMaterial {
|
||||
color: Color::WHITE.with_a(0.0),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -20,7 +20,7 @@ impl Plugin for SelectionPlugin {
|
||||
Update,
|
||||
(
|
||||
update_selection,
|
||||
process_delete_inputs.run_if(resource_exists::<Selection>()),
|
||||
process_delete_inputs.run_if(resource_exists::<Selection>),
|
||||
),
|
||||
)
|
||||
.add_systems(
|
||||
|
||||
@@ -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),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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::<GetMediaFileSuccessResponse>()
|
||||
.await
|
||||
.map_err(IntoError::<AssetReaderError>::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::<AssetReaderError>::into)?
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>()),
|
||||
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<Reader> = Box::new(VecReader::new(bytes));
|
||||
@@ -113,6 +113,6 @@ trait IntoError<Output> {
|
||||
|
||||
impl IntoError<AssetReaderError> 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}"))))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user