From 33ddd8131599625cec6484a0206542df6b6ad68d Mon Sep 17 00:00:00 2001 From: rewin Date: Fri, 2 Feb 2024 22:19:39 +0300 Subject: [PATCH] formatting fix --- studio/src/debug.rs | 10 ++++++++-- studio/src/lib.rs | 8 ++++++-- studio/src/scene.rs | 30 +++++++++++++++--------------- 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/studio/src/debug.rs b/studio/src/debug.rs index 6c17940..14a76f8 100644 --- a/studio/src/debug.rs +++ b/studio/src/debug.rs @@ -6,12 +6,18 @@ use bevy_mod_picking::debug::DebugPickingMode; use space_editor::{ prelude::EditorCameraMarker, space_editor_ui::{ - bottom_menu::BottomMenuPlugin, tools::gizmo::GizmoToolPlugin, EditorDefaultCameraPlugin, EditorGizmoConfigPlugin, EditorPickingPlugin, EditorPluginGroup, EditorUiCore, ShowEditorUi + bottom_menu::BottomMenuPlugin, tools::gizmo::GizmoToolPlugin, EditorDefaultCameraPlugin, + EditorGizmoConfigPlugin, EditorPickingPlugin, EditorPluginGroup, EditorUiCore, + ShowEditorUi, }, }; use crate::{ - camera_controller::{CameraController, CameraMotionSystem}, input::{Action, InputAction, Lifecycle}, is_editor, scene::SkeletalJoint, MainCamera, StudioMode + camera_controller::{CameraController, CameraMotionSystem}, + input::{Action, InputAction, Lifecycle}, + is_editor, + scene::SkeletalJoint, + MainCamera, }; #[derive(Resource, Deref, DerefMut)] diff --git a/studio/src/lib.rs b/studio/src/lib.rs index da16228..e69b20e 100644 --- a/studio/src/lib.rs +++ b/studio/src/lib.rs @@ -4,6 +4,7 @@ use bevy::{app::PluginGroupBuilder, prelude::*}; use bevy_mod_picking::DefaultPickingPlugins; use bevy_web_asset::WebAssetPlugin; +use bvh::BvhPlugin; #[cfg(feature = "wasm")] use wasm_bindgen::prelude::*; @@ -69,6 +70,7 @@ impl PluginGroup for CommonPlugins { .add(UiLayerPlugin) .add(WorldGridPlugin) .add(persistance::PersistancePlugin) + .add(BvhPlugin) } } @@ -105,7 +107,8 @@ pub fn start_viewer( canvas_alt, viewport_size, StudioMode::Viewer, - ); + ) + .run(); } #[cfg_attr(feature = "wasm", wasm_bindgen(js_name = startEditor))] @@ -123,7 +126,8 @@ pub fn start_editor( canvas_alt, viewport_size, StudioMode::Editor, - ); + ) + .run(); } #[cfg_attr(feature = "wasm", wasm_bindgen(js_name = startBvhViewer))] diff --git a/studio/src/scene.rs b/studio/src/scene.rs index 75d8b42..571f4ad 100644 --- a/studio/src/scene.rs +++ b/studio/src/scene.rs @@ -403,21 +403,21 @@ fn frame_scene_in_view( f32::atan(pproj.aspect_ratio * f32::tan(pproj.fov / 2.)) }; - // // TODO: - // // According to "I eat babies" at the Ars Technica forums - // // (https://arstechnica.com/civis/threads/if-you-have-aspect-ratio-and-vertical-fov-can-you-calc-horizontal-fov.37447/): - // // - // // tan(fov_v / 2) = y / z - // // tan(fov_h / 2) = x / z - // // - // // Theoretically, this would let us skip some costly tan/atan - // // computations, but I must be missing something, because just - // // substituting (s / depth) for the divisor below would make the - // // whole equation independent of the FOV, which is obviously - // // wrong. - // // - // // Unfortunately I'm embarrassingly bad at algebra, but there - // // must be some room for simplification here. + // TODO: + // According to "I eat babies" at the Ars Technica forums + // (https://arstechnica.com/civis/threads/if-you-have-aspect-ratio-and-vertical-fov-can-you-calc-horizontal-fov.37447/): + // + // tan(fov_v / 2) = y / z + // tan(fov_h / 2) = x / z + // + // Theoretically, this would let us skip some costly tan/atan + // computations, but I must be missing something, because just + // substituting (s / depth) for the divisor below would make the + // whole equation independent of the FOV, which is obviously + // wrong. + // + // Unfortunately I'm embarrassingly bad at algebra, but there + // must be some room for simplification here. let radius = (s / 2.) / f32::tan(a / 2.); cam.focus = aabb.center.into();