From b6e0e93930722f553812ab79a01d824ecbecdd46 Mon Sep 17 00:00:00 2001 From: Sufhal Date: Sat, 21 Sep 2024 23:32:20 +0200 Subject: [PATCH] chore: cleaning imports --- src/modules/camera/camera.rs | 7 +---- src/modules/camera/free_camera_controller.rs | 2 +- src/modules/camera/orbit_controller.rs | 2 +- src/modules/character/character.rs | 3 +- src/modules/core/directional_light.rs | 33 ++------------------ src/modules/core/motions.rs | 2 -- src/modules/environment/sun.rs | 2 +- src/modules/pipelines/common_pipeline.rs | 2 +- src/modules/state.rs | 9 +++--- 9 files changed, 14 insertions(+), 48 deletions(-) diff --git a/src/modules/camera/camera.rs b/src/modules/camera/camera.rs index dd37bf39..813b97e0 100644 --- a/src/modules/camera/camera.rs +++ b/src/modules/camera/camera.rs @@ -1,11 +1,6 @@ use cgmath::*; -use winit::event::*; -use winit::dpi::PhysicalPosition; -use instant::Duration; -use winit::keyboard::KeyCode; -use std::f32::consts::FRAC_PI_2; -use crate::modules::core::{directional_light::{self, DirectionalLight}, object_3d::{GroundAttachable, Position, Translate}}; +use crate::modules::core::{directional_light::DirectionalLight, object_3d::{GroundAttachable, Position, Translate}}; #[rustfmt::skip] pub const OPENGL_TO_WGPU_MATRIX: cgmath::Matrix4 = cgmath::Matrix4::new( diff --git a/src/modules/camera/free_camera_controller.rs b/src/modules/camera/free_camera_controller.rs index d8ad38a7..e346b3eb 100644 --- a/src/modules/camera/free_camera_controller.rs +++ b/src/modules/camera/free_camera_controller.rs @@ -38,7 +38,7 @@ impl FreeCameraController { boost: 1.0, speed, sensitivity, - enabled: true, + enabled: false, } } diff --git a/src/modules/camera/orbit_controller.rs b/src/modules/camera/orbit_controller.rs index 9686f864..ad4d8659 100644 --- a/src/modules/camera/orbit_controller.rs +++ b/src/modules/camera/orbit_controller.rs @@ -1,6 +1,6 @@ use cgmath::{num_traits::Signed, Point3, Rad}; use winit::{dpi::PhysicalPosition, event::MouseScrollDelta}; -use crate::modules::{core::{object_3d::GroundAttachable, raycaster::Raycaster}, terrain::terrain::Terrain}; +use crate::modules::{core::object_3d::GroundAttachable, terrain::terrain::Terrain}; use super::camera::Camera; diff --git a/src/modules/character/character.rs b/src/modules/character/character.rs index 685833ee..1d65dd1c 100644 --- a/src/modules/character/character.rs +++ b/src/modules/character/character.rs @@ -20,6 +20,7 @@ pub struct Character { kind: CharacterKind, pub objects: Vec<(String, String)>, // (Object ID, Object3DInstance ID) pub position: [f32; 3], + #[allow(dead_code)] direction: [f32; 3], velocity: f32, motions: MotionsGroups, @@ -288,7 +289,7 @@ impl AdditiveTranslationWithScene for Character { if let Some(object) = scene.get_mut(object_id) { if let Some(object3d) = &mut object.object3d { match object3d { - Object3D::Simple(simple) => todo!(), + Object3D::Simple(_simple) => todo!(), Object3D::Skinned(skinned) => { if let Some(instance) = skinned.get_instance(&instance_id) { instance.additive_translation(&[x, y, z]); diff --git a/src/modules/core/directional_light.rs b/src/modules/core/directional_light.rs index 122c8ca2..6138be23 100644 --- a/src/modules/core/directional_light.rs +++ b/src/modules/core/directional_light.rs @@ -1,5 +1,5 @@ -use cgmath::{perspective, Deg, EuclideanSpace, InnerSpace, Matrix4, Point3, SquareMatrix, Transform, Vector3, Vector4, Zero}; -use crate::modules::{camera::camera::OPENGL_TO_WGPU_MATRIX, environment::sun::Sun, terrain::terrain::Terrain}; +use cgmath::{perspective, Deg, InnerSpace, Matrix4, Point3, SquareMatrix, Transform, Vector3, Vector4, Zero}; +use crate::modules::{camera::camera::OPENGL_TO_WGPU_MATRIX, terrain::terrain::Terrain}; use super::texture::Texture; const SHADOW_MAP_SIZE: u32 = 8192; @@ -81,7 +81,7 @@ impl DirectionalLight { } } - pub fn uniform_from_camera(&self, camera_view_proj: Matrix4) -> DirectionalLightUniform { + pub fn uniform_from_camera(&self, _camera_view_proj: Matrix4) -> DirectionalLightUniform { DirectionalLightUniform { view_proj: self.cascade_projections[0].into(), ..Default::default() @@ -230,31 +230,4 @@ fn get_frustum_center(frustum_corners: &[Point3; 8]) -> Point3 { center.z /= 8.0; center -} - -const TEXEL_SCALE: f32 = 2.0 / SHADOW_MAP_SIZE as f32; // résolution de la shadow map de 1024px -const INV_TEXEL_SCALE: f32 = 1.0 / TEXEL_SCALE; - -fn stabilize_cascade_center(center: Point3, cascade_view_projection: Matrix4) -> Point3 { - // Projeter le nouveau centre en utilisant la projection précédente - let projected_center = cascade_view_projection * center.to_homogeneous(); - - // Diviser par w pour obtenir les coordonnées normalisées - let w = projected_center.w; - - // Arrondir les coordonnées x et y à des valeurs de texels entiers - let x = ((projected_center.x / w) * INV_TEXEL_SCALE).floor() * TEXEL_SCALE; - let y = ((projected_center.y / w) * INV_TEXEL_SCALE).floor() * TEXEL_SCALE; - let z = projected_center.z / w; - - // Re-projeter dans l'espace monde - let inv_cascade_view_projection = cascade_view_projection.invert().unwrap(); - let corrected_center = inv_cascade_view_projection * Vector4::new(x, y, z, 1.0); - - // Diviser par w pour obtenir les coordonnées 3D finales - Point3::new( - corrected_center.x / corrected_center.w, - corrected_center.y / corrected_center.w, - corrected_center.z / corrected_center.w - ) } \ No newline at end of file diff --git a/src/modules/core/motions.rs b/src/modules/core/motions.rs index 1715ceae..88906c88 100644 --- a/src/modules/core/motions.rs +++ b/src/modules/core/motions.rs @@ -1,8 +1,6 @@ use serde::{Deserialize, Serialize}; use crate::modules::{assets::assets::load_string, utils::functions::random_u8}; -use super::skinning::{AnimationMixer, MixerState}; - #[derive(Serialize, Deserialize, Debug, Clone)] pub struct MotionsGroups { pub groups: Vec, diff --git a/src/modules/environment/sun.rs b/src/modules/environment/sun.rs index adf9bb19..92610199 100644 --- a/src/modules/environment/sun.rs +++ b/src/modules/environment/sun.rs @@ -1,4 +1,4 @@ -use cgmath::{Angle, Deg, Matrix4, Quaternion, Rad, Rotation3, Vector3}; +use cgmath::{Angle, Matrix4, Rad}; use crate::modules::{core::model::{CustomMesh, TransformUniform}, geometry::plane::Plane, state::State}; use super::{cycle::Cycle, environment::MsEnv, Position}; diff --git a/src/modules/pipelines/common_pipeline.rs b/src/modules/pipelines/common_pipeline.rs index b247b3de..4ddb60b8 100644 --- a/src/modules/pipelines/common_pipeline.rs +++ b/src/modules/pipelines/common_pipeline.rs @@ -1,5 +1,5 @@ use wgpu::util::DeviceExt; -use crate::modules::{camera::camera::CameraUniform, core::{directional_light::{self, DirectionalLight, DirectionalLightUniform}, light::LightUniform}, environment::{cycle::CycleUniform, fog::FogUniform, sun::SunUniform}}; +use crate::modules::{camera::camera::CameraUniform, core::{directional_light::{DirectionalLight, DirectionalLightUniform}, light::LightUniform}, environment::{cycle::CycleUniform, fog::FogUniform, sun::SunUniform}}; pub struct Buffers { pub light: wgpu::Buffer, diff --git a/src/modules/state.rs b/src/modules/state.rs index 090105ef..9b95848d 100644 --- a/src/modules/state.rs +++ b/src/modules/state.rs @@ -1,4 +1,4 @@ -use std::{char, iter}; +use std::iter; use cgmath::Rotation3; use log::info; use winit::keyboard::KeyCode; @@ -12,16 +12,15 @@ use crate::modules::core::texture::{self, Texture}; use crate::modules::camera::camera; use crate::modules::ui::ui::MetricData; use crate::modules::utils::time_factory::TimeFragment; -use super::assets::gltf_loader::load_model_glb; use super::camera::free_camera_controller::FreeCameraController; use super::character::actor::Actor; -use super::character::character::{Character, CharacterKind, CharacterState, GetActor, NPCType, PCType, Sex}; -use super::core::directional_light::{self, DirectionalLight}; +use super::character::character::{Character, CharacterKind, CharacterState, GetActor, PCType, Sex}; +use super::core::directional_light::DirectionalLight; use super::core::object_3d::{Object3D, TranslateWithScene}; use super::core::scene; use super::pipelines::clouds_pipeline::CloudsPipeline; use super::pipelines::common_pipeline::CommonPipeline; -use super::pipelines::shadow_pipeline::{self, ShadowPipeline}; +use super::pipelines::shadow_pipeline::ShadowPipeline; use super::pipelines::simple_models_pipeline::SimpleModelPipeline; use super::pipelines::skinned_models_pipeline::SkinnedModelPipeline; use super::pipelines::sky_pipeline::SkyPipeline;