From e589544a311606ad13381044e2efb3d46a3256b9 Mon Sep 17 00:00:00 2001 From: lisk77 Date: Thu, 13 Nov 2025 00:43:37 +0100 Subject: [PATCH 1/2] feat(math): vectors now have the hadamard product for multiplication --- crates/comet_math/src/vector.rs | 59 +++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/crates/comet_math/src/vector.rs b/crates/comet_math/src/vector.rs index 860a5b0..ea7e35e 100644 --- a/crates/comet_math/src/vector.rs +++ b/crates/comet_math/src/vector.rs @@ -149,6 +149,17 @@ impl Mul for f32 { } } +impl Mul for v2 { + type Output = v2; + + fn mul(self, other: v2) -> v2 { + v2 { + x: self.x * other.x, + y: self.y * other.y, + } + } +} + impl Div for v2 { type Output = v2; @@ -388,6 +399,17 @@ impl Mul for v2i { } } +impl Mul for v2i { + type Output = v2i; + + fn mul(self, other: v2i) -> v2i { + v2i { + x: self.x * other.x, + y: self.y * other.y, + } + } +} + impl From for v2 { fn from(v: v2i) -> v2 { v2 { @@ -584,6 +606,18 @@ impl Mul for f32 { } } +impl Mul for v3 { + type Output = v3; + + fn mul(self, other: v3) -> v3 { + v3 { + x: self.x * other.x, + y: self.y * other.y, + z: self.z * other.z, + } + } +} + impl Div for v3 { type Output = v3; @@ -797,6 +831,18 @@ impl Mul for v3i { } } +impl Mul for v3i { + type Output = v3i; + + fn mul(self, other: v3i) -> v3i { + v3i { + x: self.x * other.x, + y: self.y * other.y, + z: self.z * other.z, + } + } +} + impl From for v3 { fn from(v: v3i) -> v3 { v3 { @@ -1002,6 +1048,19 @@ impl Mul for f32 { } } +impl Mul for v4 { + type Output = v4; + + fn mul(self, other: v4) -> v4 { + v4 { + x: self.x * other.x, + y: self.y * other.y, + z: self.z * other.z, + w: self.w * other.w, + } + } +} + impl MulAssign for v4 { fn mul_assign(&mut self, other: f32) { self.x *= other; From bf7f0bebe9c8fc16f6b567b05b5a53b8b119defe Mon Sep 17 00:00:00 2001 From: lisk77 Date: Thu, 13 Nov 2025 00:45:54 +0100 Subject: [PATCH 2/2] fix(app): surface errors are handled properly now --- crates/comet_app/Cargo.toml | 1 + crates/comet_app/src/app.rs | 14 +++++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/crates/comet_app/Cargo.toml b/crates/comet_app/Cargo.toml index 59bd1f5..4965b46 100755 --- a/crates/comet_app/Cargo.toml +++ b/crates/comet_app/Cargo.toml @@ -18,6 +18,7 @@ pollster = "0.3" winit_input_helper = "0.16.0" crossbeam-channel = "0.5.14" chrono = "0.4.40" +wgpu = "22.0" [dependencies.image] version = "0.24" diff --git a/crates/comet_app/src/app.rs b/crates/comet_app/src/app.rs index 888fc2a..2f3d23a 100755 --- a/crates/comet_app/src/app.rs +++ b/crates/comet_app/src/app.rs @@ -387,7 +387,19 @@ impl App { window.request_redraw(); match renderer.render() { Ok(_) => {} - Err(e) => error!("Error rendering: {}", e), + Err( + wgpu::SurfaceError::Lost | wgpu::SurfaceError::Outdated, + ) => { + let size = renderer.size(); + renderer.resize(size); + } + Err(wgpu::SurfaceError::OutOfMemory) => { + error!("Out of memory!"); + elwt.exit(); + } + Err(wgpu::SurfaceError::Timeout) => { + warn!("Surface timeout - skipping frame"); + } } } _ => {}