From 790dcf8e76412136b6f7362fe6a9d00251d6416d Mon Sep 17 00:00:00 2001 From: Elham Aryanpur Date: Sat, 13 Jul 2024 11:58:49 +0300 Subject: [PATCH] feat: camera is now a collection than a single entity, where the operations done on camera is done on "main" camera --- Cargo.lock | 139 +---------------------- Cargo.toml | 2 +- examples/shapes/models.rs | 1 - examples/shapes/square.rs | 2 +- resources/monkey.glb | Bin 69624 -> 0 bytes src/definition.rs | 10 +- src/header.rs | 25 +++- src/objects.rs | 42 +++---- src/primitive_shapes/three_dimensions.rs | 4 +- src/primitive_shapes/two_dimensions.rs | 6 +- src/render.rs | 10 +- src/utils/camera.rs | 114 ++++++++++++++++++- src/window.rs | 79 ++++++------- 13 files changed, 208 insertions(+), 226 deletions(-) delete mode 100644 examples/shapes/models.rs delete mode 100644 resources/monkey.glb diff --git a/Cargo.lock b/Cargo.lock index d4a1447..bbe878a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -18,15 +18,6 @@ version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" -[[package]] -name = "addr2line" -version = "0.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a76fd60b23679b7d19bd066031410fb7e458ccc5e958eb5c325888ce4baedc97" -dependencies = [ - "gimli", -] - [[package]] name = "adler" version = "1.0.2" @@ -262,21 +253,6 @@ dependencies = [ "arrayvec", ] -[[package]] -name = "backtrace" -version = "0.3.67" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "233d376d6d185f2a3093e58f283f60f880315b6c60075b01f36b3b85154564ca" -dependencies = [ - "addr2line", - "cc", - "cfg-if", - "libc", - "miniz_oxide 0.6.2", - "object", - "rustc-demangle", -] - [[package]] name = "bit-set" version = "0.5.2" @@ -347,9 +323,9 @@ version = "0.5.13" dependencies = [ "android_logger", "bytemuck", - "color-eyre", "downcast", "env_logger", + "eyre", "futures", "image", "log", @@ -482,33 +458,6 @@ dependencies = [ "unicode-width", ] -[[package]] -name = "color-eyre" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a667583cca8c4f8436db8de46ea8233c42a7d9ae424a82d338f2e4675229204" -dependencies = [ - "backtrace", - "color-spantrace", - "eyre", - "indenter", - "once_cell", - "owo-colors", - "tracing-error", -] - -[[package]] -name = "color-spantrace" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd6be1b2a7e382e2b98b43b2adcca6bb0e465af0bdd38123873ae61eb17a72c2" -dependencies = [ - "once_cell", - "owo-colors", - "tracing-core", - "tracing-error", -] - [[package]] name = "color_quant" version = "1.1.0" @@ -959,12 +908,6 @@ dependencies = [ "weezl", ] -[[package]] -name = "gimli" -version = "0.27.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0a93d233ebf96623465aad4046a8d3aa4da22d4f4beba5388838c8a434bbb4" - [[package]] name = "gl_generator" version = "0.14.0" @@ -1442,15 +1385,6 @@ dependencies = [ "adler", ] -[[package]] -name = "miniz_oxide" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.7.4" @@ -1687,15 +1621,6 @@ version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d079845b37af429bfe5dfa76e6d087d788031045b25cfc6fd898486fd9847666" -[[package]] -name = "object" -version = "0.30.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ea86265d3d3dcb6a27fc51bd29a4bf387fae9d2986b823079d4986af253eb439" -dependencies = [ - "memchr", -] - [[package]] name = "once_cell" version = "1.19.0" @@ -1720,12 +1645,6 @@ dependencies = [ "ttf-parser", ] -[[package]] -name = "owo-colors" -version = "3.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" - [[package]] name = "parking_lot" version = "0.12.1" @@ -2072,12 +1991,6 @@ dependencies = [ "bytemuck", ] -[[package]] -name = "rustc-demangle" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4a36c42d1873f9a77c53bde094f9664d9891bc604a45b4798fd2c389ed12e5b" - [[package]] name = "rustc-hash" version = "1.1.0" @@ -2169,15 +2082,6 @@ dependencies = [ "serde", ] -[[package]] -name = "sharded-slab" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6" -dependencies = [ - "lazy_static", -] - [[package]] name = "simba" version = "0.9.0" @@ -2364,16 +2268,6 @@ dependencies = [ "syn 2.0.48", ] -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if", - "once_cell", -] - [[package]] name = "tiff" version = "0.9.1" @@ -2468,31 +2362,6 @@ name = "tracing-core" version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" -dependencies = [ - "once_cell", - "valuable", -] - -[[package]] -name = "tracing-error" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d686ec1c0f384b1277f097b2f279a2ecc11afe8c133c1aabf036a27cb4cd206e" -dependencies = [ - "tracing", - "tracing-subscriber", -] - -[[package]] -name = "tracing-subscriber" -version = "0.3.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad0f048c97dbd9faa9b7df56362b8ebcaa52adb06b498c050d2f4e32f90a7a8b" -dependencies = [ - "sharded-slab", - "thread_local", - "tracing-core", -] [[package]] name = "ttf-parser" @@ -2547,12 +2416,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "valuable" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b7e5d4d90034032940e4ace0d9a9a057e7a45cd94e6c007832e39edb82f6d" - [[package]] name = "version-compare" version = "0.2.0" diff --git a/Cargo.toml b/Cargo.toml index 621c8b6..749bf80 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,7 +27,7 @@ winit = { version = "0.29.8", features = ["rwh_05"] } winit_input_helper = "0.16" wgpu = { version = "0.20.1" } bytemuck = { version = "1.16", features = ["derive"] } -color-eyre = "0.6" +eyre = "0.6" downcast = "0.11" nalgebra-glm = "0.19" # debug logs diff --git a/examples/shapes/models.rs b/examples/shapes/models.rs deleted file mode 100644 index 2132047..0000000 --- a/examples/shapes/models.rs +++ /dev/null @@ -1 +0,0 @@ -//? ADD SPHERE FROM GIGANTESQUE diff --git a/examples/shapes/square.rs b/examples/shapes/square.rs index bc47221..a0d9189 100644 --- a/examples/shapes/square.rs +++ b/examples/shapes/square.rs @@ -11,7 +11,7 @@ use blue_engine::{ StringBuffer, }; -pub fn square(name: impl StringBuffer, engine: &mut Engine) -> color_eyre::Result<()> { +pub fn square(name: impl StringBuffer, engine: &mut Engine) -> eyre::Result<()> { engine.objects.new_object( name, vec![ diff --git a/resources/monkey.glb b/resources/monkey.glb deleted file mode 100644 index 2d21f1ef920dbfd704c849b8ecaec8bbf125fd8b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 69624 zcmcG%2V53M_XWK5u{W$(5qn2OLFAc>ioIdS-W3%Q#a^-3Sfa)nd+fbOVb`uP#@=Ey zVyv-uO>Ey?W%s@EIj_V2{XTxbx##e3?wQ%ync3NWHl|BNqpFG|NpI50QiLi=H5=Be zJJ`Ejbabaa-hqR?yL5`|)Vp1up1r*Ty=#T{?itxL+N%qucvXt%6xp#;Z?77q>Us4m zT{56#>GIyiz58|Q9o@BOB#M1Y`gjj5?j79$4ZH(=5?Hi%V2i=tk?nfmXWk7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j*bTa< zbIR0Ad!{ZaUGsFpKB2#KT6xO0v(=~^73!#cR44VDij-^T>XZt!So`h$I-&zwqGG#P z$5f{Nx`#6Ji|%KTD(ng!)CBd>!%Q%quJlv9x)LujR^!#gZbEaKF;Q`9Mx3rDMq?Cc z2XYN98K+paBvv;tT%**=ZpDqXVYH&vhG^Z&U`45|-Im*E&qzh8J(0STa1Buhy90OA znPG}hXCm|ff9O~BvU|~;P=41Lg>ptu@Ho8*v%?t7v-G8h-Gk?epdZn8G?Bc=NMs+;31+I!d^w0N7<>r6>JAH zh@J%SvwE6g99K6k=(sNEPhCa`XYI2(uYJ0U!{$l*X}VCaE*w(5I?|s$bTs$!6a(mF zcj7*7Vie(aIJff*uhPzL#~obDXkzRbZsrxn(%Np#EnLYs#@J)HjyD)j3%do^)08-_ z;3_6?Ifwl|Ut*WAfN~D_dS6bxU&sl6#OK+0%q5>={d#&oUBdu01}1J-(9n z$f3wCVkwI$B+*V}1rwPhdlCgClgb?CF`H?Wxz&EVFLT@d66*XqU+L=1 nO3GaYrFJQsT^Y++{{L=^t9F}QG1X?TUqr3j=oYcj9rFJHt5@$> diff --git a/src/definition.rs b/src/definition.rs index 2ec6de9..7c6cc40 100644 --- a/src/definition.rs +++ b/src/definition.rs @@ -23,7 +23,7 @@ impl crate::header::Renderer { vertex_buffer: VertexBuffers, texture: Textures, uniform: Option, - ) -> color_eyre::Result { + ) -> eyre::Result { Ok(Pipeline { shader: PipelineData::Data(shader), vertex_buffer: PipelineData::Data(vertex_buffer), @@ -39,7 +39,7 @@ impl crate::header::Renderer { shader_source: String, uniform_layout: Option<&BindGroupLayout>, settings: ShaderSettings, - ) -> color_eyre::Result { + ) -> eyre::Result { let shader = self .device .create_shader_module(wgpu::ShaderModuleDescriptor { @@ -119,7 +119,7 @@ impl crate::header::Renderer { texture_data: TextureData, texture_mode: TextureMode, //texture_format: TextureFormat, - ) -> color_eyre::Result { + ) -> eyre::Result { let mode: wgpu::AddressMode = match texture_mode { TextureMode::Clamp => wgpu::AddressMode::Repeat, TextureMode::Repeat => wgpu::AddressMode::MirrorRepeat, @@ -260,7 +260,7 @@ impl crate::header::Renderer { pub fn build_uniform_buffer( &mut self, uniforms: &[wgpu::Buffer], - ) -> color_eyre::Result<(UniformBuffers, BindGroupLayout)> { + ) -> eyre::Result<(UniformBuffers, BindGroupLayout)> { let mut buffer_entry = Vec::::new(); let mut buffer_layout = Vec::::new(); @@ -303,7 +303,7 @@ impl crate::header::Renderer { &mut self, vertices: &Vec, indices: &Vec, - ) -> color_eyre::Result { + ) -> eyre::Result { let vertex_buffer = self .device .create_buffer_init(&wgpu::util::BufferInitDescriptor { diff --git a/src/header.rs b/src/header.rs index a29c2d2..bde4131 100644 --- a/src/header.rs +++ b/src/header.rs @@ -204,7 +204,7 @@ pub struct Engine { /// do not have the know-how, or wish to handle all the work of rendering data manually. pub objects: ObjectStorage, /// The camera handles the way the scene looks when rendered. You can modify everything there is to camera through this. - pub camera: Camera, + pub camera: CameraContainer, /// Handles all engine plugins pub signals: SignalStorage, } @@ -348,7 +348,7 @@ unsafe impl Send for WindowDescriptor {} unsafe impl Sync for WindowDescriptor {} /// Container for the projection used by the camera -#[derive(Debug)] +#[derive(Debug, Clone, PartialEq, PartialOrd)] pub enum Projection { /// Perspective projection /// @@ -389,13 +389,28 @@ pub struct Camera { // For checking and rebuilding it's uniform buffer pub(crate) changed: bool, /// The uniform data of the camera to be sent to the gpu - pub uniform_data: crate::UniformBuffers, + pub uniform_data: UniformBuffers, /// The position and target of the camera pub(crate) add_position_and_target: bool, } unsafe impl Send for Camera {} unsafe impl Sync for Camera {} +/// Container for Cameras +/// +/// This allows for different objects have a different camera perspective. +#[derive(Debug)] +pub struct CameraContainer { + /// The list of cameras + // Arc is used instead of String for performance + pub cameras: std::collections::HashMap, Camera>, +} +impl_deref_field!( + CameraContainer, + std::collections::HashMap, Camera>, + cameras +); + /// These definitions are taken from wgpu API docs #[derive(Debug, Clone, Copy)] pub struct ShaderSettings { @@ -498,7 +513,7 @@ pub trait Signal: Any { _objects: &mut ObjectStorage, _events: &crate::Event<()>, _input: &crate::InputHelper, - _camera: &mut crate::Camera, + _camera: &mut crate::CameraContainer, ) { } @@ -509,7 +524,7 @@ pub trait Signal: Any { _renderer: &mut crate::Renderer, _window: &crate::Window, _objects: &mut ObjectStorage, - _camera: &mut crate::Camera, + _camera: &mut crate::CameraContainer, _input: &crate::InputHelper, _encoder: &mut crate::CommandEncoder, _view: &crate::TextureView, diff --git a/src/objects.rs b/src/objects.rs index b8654d8..221641c 100644 --- a/src/objects.rs +++ b/src/objects.rs @@ -29,7 +29,7 @@ impl Renderer { vertices: Vec, indices: Vec, settings: ObjectSettings, - ) -> color_eyre::Result { + ) -> eyre::Result { let vertex_buffer = self.build_vertex_buffer(&vertices, &indices)?; let uniform = self.build_uniform_buffer(&vec![ @@ -123,7 +123,7 @@ impl ObjectStorage { indices: Vec, settings: ObjectSettings, renderer: &mut Renderer, - ) -> color_eyre::Result<()> { + ) -> eyre::Result<()> { self.add_object( name.clone(), renderer.build_object(name.clone(), vertices, indices, settings)?, @@ -140,12 +140,12 @@ impl ObjectStorage { } /// Adds an object to the storage - pub fn add_object(&mut self, key: impl StringBuffer, object: Object) -> color_eyre::Result<()> { + pub fn add_object(&mut self, key: impl StringBuffer, object: Object) -> eyre::Result<()> { fn add_object_inner( object_storage: &mut ObjectStorage, key: String, object: Object, - ) -> color_eyre::Result<()> { + ) -> eyre::Result<()> { object_storage.insert(key, object); Ok(()) @@ -296,13 +296,7 @@ impl Object { } /// Changes the color of the object. If textures exist, the color of textures will change - pub fn set_color( - &mut self, - red: f32, - green: f32, - blue: f32, - alpha: f32, - ) -> color_eyre::Result<()> { + pub fn set_color(&mut self, red: f32, green: f32, blue: f32, alpha: f32) -> eyre::Result<()> { self.color = Array4 { data: [red, green, blue, alpha], }; @@ -317,7 +311,7 @@ impl Object { green: f32, blue: f32, alpha: f32, - ) -> color_eyre::Result<()> { + ) -> eyre::Result<()> { self.uniform_color = Array4 { data: [red, green, blue, alpha], }; @@ -329,14 +323,14 @@ impl Object { /// Changes the render order of the Object. /// /// Objects with higher number get rendered later and appear "on top" when occupying the same space - pub fn set_render_order(&mut self, render_order: usize) -> color_eyre::Result<()> { + pub fn set_render_order(&mut self, render_order: usize) -> eyre::Result<()> { self.render_order = render_order; Ok(()) } /// Replaces the object's texture with provided one - pub fn set_texture(&mut self, texture: Textures) -> color_eyre::Result<()> { + pub fn set_texture(&mut self, texture: Textures) -> eyre::Result<()> { self.pipeline.texture = PipelineData::Data(texture); self.changed = true; @@ -364,7 +358,7 @@ impl Object { } /// Update and apply changes done to an object - pub fn update(&mut self, renderer: &mut Renderer) -> color_eyre::Result<()> { + pub fn update(&mut self, renderer: &mut Renderer) -> eyre::Result<()> { self.update_vertex_buffer(renderer)?; self.update_uniform_buffer(renderer)?; self.update_shader(renderer)?; @@ -377,7 +371,7 @@ impl Object { pub fn update_and_return( &mut self, renderer: &mut Renderer, - ) -> color_eyre::Result<(crate::VertexBuffers, crate::UniformBuffers, crate::Shaders)> { + ) -> eyre::Result<(crate::VertexBuffers, crate::UniformBuffers, crate::Shaders)> { let vertex_buffer = self.update_vertex_buffer_and_return(renderer)?; let uniform_buffer = self.update_uniform_buffer_and_return(renderer)?; let shader = self.update_shader_and_return(renderer)?; @@ -386,7 +380,7 @@ impl Object { } /// Update and apply changes done to the vertex buffer - pub fn update_vertex_buffer(&mut self, renderer: &mut Renderer) -> color_eyre::Result<()> { + pub fn update_vertex_buffer(&mut self, renderer: &mut Renderer) -> eyre::Result<()> { let updated_buffer = renderer.build_vertex_buffer(&self.vertices, &self.indices)?; self.pipeline.vertex_buffer = PipelineData::Data(updated_buffer); @@ -397,7 +391,7 @@ impl Object { pub fn update_vertex_buffer_and_return( &mut self, renderer: &mut Renderer, - ) -> color_eyre::Result { + ) -> eyre::Result { let updated_buffer = renderer.build_vertex_buffer(&self.vertices, &self.indices)?; let updated_buffer_2 = renderer.build_vertex_buffer(&self.vertices, &self.indices)?; self.pipeline.vertex_buffer = PipelineData::Data(updated_buffer); @@ -406,7 +400,7 @@ impl Object { } /// Update and apply changes done to the shader - pub fn update_shader(&mut self, renderer: &mut Renderer) -> color_eyre::Result<()> { + pub fn update_shader(&mut self, renderer: &mut Renderer) -> eyre::Result<()> { let updated_shader = renderer.build_shader( self.name.as_str(), self.shader_builder.shader.clone(), @@ -422,7 +416,7 @@ impl Object { pub fn update_shader_and_return( &mut self, renderer: &mut Renderer, - ) -> color_eyre::Result { + ) -> eyre::Result { let updated_shader = renderer.build_shader( self.name.as_str(), self.shader_builder.shader.clone(), @@ -441,7 +435,7 @@ impl Object { } /// Update and apply changes done to the uniform buffer - pub fn update_uniform_buffer(&mut self, renderer: &mut Renderer) -> color_eyre::Result<()> { + pub fn update_uniform_buffer(&mut self, renderer: &mut Renderer) -> eyre::Result<()> { self.uniform_buffers[0] = renderer.build_uniform_buffer_part( "Transformation Matrix", uniform_type::Matrix::from_im( @@ -462,7 +456,7 @@ impl Object { pub fn update_uniform_buffer_and_return( &mut self, renderer: &mut Renderer, - ) -> color_eyre::Result { + ) -> eyre::Result { self.uniform_buffers[0] = renderer.build_uniform_buffer_part( "Transformation Matrix", uniform_type::Matrix::from_im( @@ -481,7 +475,7 @@ impl Object { } /// Updates the instance buffer - pub fn update_instance_buffer(&mut self, renderer: &mut Renderer) -> color_eyre::Result<()> { + pub fn update_instance_buffer(&mut self, renderer: &mut Renderer) -> eyre::Result<()> { let instance_data = self .instances .iter() @@ -496,7 +490,7 @@ impl Object { pub fn update_instance_buffer_and_return( &mut self, renderer: &mut Renderer, - ) -> color_eyre::Result { + ) -> eyre::Result { let instance_data = self .instances .iter() diff --git a/src/primitive_shapes/three_dimensions.rs b/src/primitive_shapes/three_dimensions.rs index 7e1a2cc..5855c84 100644 --- a/src/primitive_shapes/three_dimensions.rs +++ b/src/primitive_shapes/three_dimensions.rs @@ -5,7 +5,7 @@ pub fn cube( name: impl StringBuffer, renderer: &mut Renderer, objects: &mut ObjectStorage, -) -> color_eyre::Result<()> { +) -> eyre::Result<()> { objects.new_object( name.clone(), vec![ @@ -162,7 +162,7 @@ pub fn uv_sphere( details: (usize, usize, f32), renderer: &mut Renderer, objects: &mut ObjectStorage, -) -> color_eyre::Result<()> { +) -> eyre::Result<()> { let sectors = details.1 as f32; let stacks = details.0 as f32; let length_inv = 1. / details.2; diff --git a/src/primitive_shapes/two_dimensions.rs b/src/primitive_shapes/two_dimensions.rs index bc5a262..ca0ad2b 100644 --- a/src/primitive_shapes/two_dimensions.rs +++ b/src/primitive_shapes/two_dimensions.rs @@ -15,7 +15,7 @@ pub fn triangle( settings: ObjectSettings, renderer: &mut Renderer, objects: &mut ObjectStorage, -) -> color_eyre::Result<()> { +) -> eyre::Result<()> { objects.new_object( name.clone(), vec![ @@ -49,7 +49,7 @@ pub fn square( settings: ObjectSettings, renderer: &mut Renderer, objects: &mut ObjectStorage, -) -> color_eyre::Result<()> { +) -> eyre::Result<()> { objects.new_object( name.clone(), vec![ @@ -90,7 +90,7 @@ pub fn rectangle( settings: ObjectSettings, renderer: &mut Renderer, objects: &mut ObjectStorage, -) -> color_eyre::Result<()> { +) -> eyre::Result<()> { objects.new_object( name.clone(), vec![ diff --git a/src/render.rs b/src/render.rs index 9a3bda2..a919f80 100644 --- a/src/render.rs +++ b/src/render.rs @@ -9,9 +9,9 @@ use std::sync::Arc; use crate::{ - header::{uniform_type, Camera, Renderer, ShaderSettings, TextureData}, + header::{uniform_type, Renderer, ShaderSettings, TextureData}, utils::default_resources::{DEFAULT_COLOR, DEFAULT_MATRIX_4, DEFAULT_SHADER, DEFAULT_TEXTURE}, - ObjectStorage, PipelineData, + CameraContainer, ObjectStorage, PipelineData, }; use winit::window::Window; @@ -24,7 +24,7 @@ impl Renderer { pub(crate) async fn new( window: Arc, settings: crate::WindowDescriptor, - ) -> color_eyre::Result { + ) -> eyre::Result { let size = window.inner_size(); // The instance is a handle to our GPU @@ -221,7 +221,7 @@ impl Renderer { &mut self, objects: &ObjectStorage, window_size: winit::dpi::PhysicalSize, - camera: &Camera, + camera: &CameraContainer, ) -> Result< Option<( wgpu::CommandEncoder, @@ -293,7 +293,7 @@ impl Renderer { render_pass.set_bind_group(0, &default_data.0, &[]); render_pass.set_pipeline(&default_data.1); - render_pass.set_bind_group(1, &camera.uniform_data, &[]); + render_pass.set_bind_group(1, &camera.get("main").unwrap().uniform_data, &[]); // sort the object list in descending render order let mut object_list: Vec<_> = objects.iter().collect(); diff --git a/src/utils/camera.rs b/src/utils/camera.rs index 87868e6..c04d721 100644 --- a/src/utils/camera.rs +++ b/src/utils/camera.rs @@ -6,9 +6,9 @@ use crate::{ header::{uniform_type::Matrix, Camera, Renderer}, - Projection, + CameraContainer, Projection, }; -use color_eyre::Result; +use eyre::Result; use winit::dpi::PhysicalSize; use super::default_resources::{DEFAULT_MATRIX_4, OPENGL_TO_WGPU_MATRIX}; @@ -203,3 +203,113 @@ impl Camera { } } } + +impl CameraContainer { + /// Creates new CameraContainer with one main camera + pub fn new(window_size: PhysicalSize, renderer: &mut Renderer) -> eyre::Result { + let mut cameras = std::collections::HashMap::new(); + let main_camera = Camera::new(window_size, renderer)?; + cameras.insert("main".into(), main_camera); + + Ok(CameraContainer { cameras }) + } + + /// Updates the view uniform matrix that decides how camera works + pub fn build_view_projection_matrix(&mut self) -> eyre::Result<()> { + self.cameras + .get_mut("main") + .unwrap() + .build_view_projection_matrix()?; + Ok(()) + } + /// Updates the view uniform matrix that decides how camera works + pub fn build_view_orthographic_matrix(&mut self) -> eyre::Result<()> { + self.cameras + .get_mut("main") + .unwrap() + .build_view_orthographic_matrix()?; + Ok(()) + } + /// Returns a matrix uniform buffer from camera data that can be sent to GPU + pub fn camera_uniform_buffer(&self) -> eyre::Result { + Ok(Matrix::from_im(self.cameras.get("main").unwrap().view_data)) + } + /// Sets the position of camera + pub fn set_position(&mut self, x: f32, y: f32, z: f32) -> eyre::Result<()> { + self.cameras + .get_mut("main") + .unwrap() + .set_position(x, y, z)?; + Ok(()) + } + /// Sets the target of camera + pub fn set_target(&mut self, x: f32, y: f32, z: f32) -> eyre::Result<()> { + self.cameras.get_mut("main").unwrap().set_target(x, y, z)?; + Ok(()) + } + /// Sets the up of camera + pub fn set_up(&mut self, x: f32, y: f32, z: f32) -> eyre::Result<()> { + self.cameras.get_mut("main").unwrap().set_up(x, y, z)?; + Ok(()) + } + /// Sets how far camera can look + pub fn set_far(&mut self, new_far: f32) -> eyre::Result<()> { + self.cameras.get_mut("main").unwrap().set_far(new_far)?; + Ok(()) + } + /// Sets how near the camera can look + pub fn set_near(&mut self, new_near: f32) -> eyre::Result<()> { + self.cameras.get_mut("main").unwrap().set_near(new_near)?; + Ok(()) + } + /// Sets the aspect ratio of the camera + pub fn set_resolution(&mut self, window_size: PhysicalSize) -> eyre::Result<()> { + self.cameras + .get_mut("main") + .unwrap() + .set_resolution(window_size)?; + Ok(()) + } + /// Sets the projection of the camera + pub fn set_projection(&mut self, projection: Projection) -> eyre::Result<()> { + self.cameras + .get_mut("main") + .unwrap() + .set_projection(projection)?; + Ok(()) + } + /// Enables adding position and target for the view target + pub fn add_position_and_target(&mut self, enable: bool) { + self.cameras + .get_mut("main") + .unwrap() + .add_position_and_target(enable); + } + /// This builds a uniform buffer data from camera view data that is sent to the GPU in next frame + pub fn update_view_projection(&mut self, renderer: &mut Renderer) -> eyre::Result<()> { + self.cameras + .get_mut("main") + .unwrap() + .update_view_projection(renderer)?; + Ok(()) + } + /// This builds a uniform buffer data from camera view data that is sent to the GPU in next frame, and returns the bindgroup + pub fn update_view_projection_and_return( + &mut self, + renderer: &mut Renderer, + ) -> eyre::Result { + Ok(self + .cameras + .get_mut("main") + .unwrap() + .update_view_projection_and_return(renderer)?) + } + /// Builds a view matrix for camera projection + pub fn build_view_matrix(&self) -> nalgebra_glm::Mat4 { + self.cameras.get("main").unwrap().build_view_matrix() + } + /// Builds a projection matrix for camera + pub fn build_projection_matrix(&self) -> nalgebra_glm::Mat4 { + self.cameras.get("main").unwrap().build_projection_matrix() + } +} diff --git a/src/window.rs b/src/window.rs index 6191be4..9fa1643 100644 --- a/src/window.rs +++ b/src/window.rs @@ -5,8 +5,8 @@ */ use crate::{ - header::{Camera, Engine, Renderer, WindowDescriptor}, - ObjectStorage, Window, + header::{Engine, Renderer, WindowDescriptor}, + CameraContainer, ObjectStorage, Window, }; use winit::{ @@ -17,7 +17,7 @@ use winit::{ impl Engine { /// Creates a new window in current thread using default settings. - pub fn new() -> color_eyre::Result { + pub fn new() -> eyre::Result { Self::new_inner( WindowDescriptor::default(), #[cfg(target_os = "android")] @@ -26,7 +26,7 @@ impl Engine { } /// Creates a new window in current thread using provided settings. - pub fn new_config(settings: WindowDescriptor) -> color_eyre::Result { + pub fn new_config(settings: WindowDescriptor) -> eyre::Result { Self::new_inner( settings, #[cfg(target_os = "android")] @@ -39,7 +39,7 @@ impl Engine { pub fn new_android( settings: WindowDescriptor, app: winit::platform::android::activity::AndroidApp, - ) -> color_eyre::Result { + ) -> eyre::Result { Self::new_inner(settings, Some(app)) } @@ -50,7 +50,7 @@ impl Engine { #[cfg(target_os = "android")] android_app: Option< winit::platform::android::activity::AndroidApp, >, - ) -> color_eyre::Result { + ) -> eyre::Result { #[cfg(feature = "debug")] env_logger::init(); // Dimensions of the window, as width and height @@ -121,7 +121,7 @@ impl Engine { // The renderer init on current window let mut renderer = futures::executor::block_on(Renderer::new(window.clone(), settings))?; - let camera = Camera::new(window_inner_size, &mut renderer)?; + let camera = CameraContainer::new(window_inner_size, &mut renderer)?; Ok(Self { window: Window::new(window), @@ -139,21 +139,19 @@ impl Engine { /// /// Renderer, window, vec of objects, events, and camera are passed to the update code. #[allow(unreachable_code)] - pub fn update_loop< - F: 'static + pub fn update_loop( + self, + mut update_function: impl 'static + FnMut( // Core &mut Renderer, &mut Window, &mut ObjectStorage, &winit_input_helper::WinitInputHelper, - &mut Camera, + &mut CameraContainer, &mut crate::SignalStorage, ), - >( - self, - mut update_function: F, - ) -> color_eyre::Result<()> { + ) -> eyre::Result<()> { let Self { event_loop, mut renderer, @@ -264,34 +262,37 @@ impl Engine { _ => {} }, - #[cfg(feature = "android")] Event::Resumed => { - // let surface = unsafe { - // renderer - // .instance - // .create_surface_unsafe( - // wgpu::SurfaceTargetUnsafe::from_window(&window.window) - // .expect("Couldn't create surface target"), - // ) - // .expect("Couldn't create surface") - // }; - - let surface = renderer - .instance - .create_surface(window.window.clone()) - .unwrap(); - surface.configure(&renderer.device, &renderer.config); - - renderer.depth_buffer = Renderer::build_depth_buffer( - "Depth Buffer", - &renderer.device, - &renderer.config, - ); - renderer.surface = Some(surface); + if renderer.surface.is_none() { + // let surface = unsafe { + // renderer + // .instance + // .create_surface_unsafe( + // wgpu::SurfaceTargetUnsafe::from_window(&window.window) + // .expect("Couldn't create surface target"), + // ) + // .expect("Couldn't create surface") + // }; + + let surface = renderer + .instance + .create_surface(window.window.clone()) + .unwrap(); + surface.configure(&renderer.device, &renderer.config); + + renderer.depth_buffer = Renderer::build_depth_buffer( + "Depth Buffer", + &renderer.device, + &renderer.config, + ); + renderer.surface = Some(surface); + } } - #[cfg(feature = "android")] + Event::Suspended => { - renderer.surface = None; + if renderer.surface.is_none() { + renderer.surface = None; + } } Event::DeviceEvent { event, .. } => _device_event = event,