From 7b0bb7e2b0fe6ec43a28c9189db7811a7cb428e2 Mon Sep 17 00:00:00 2001 From: irate-devil Date: Sun, 24 Dec 2023 17:44:31 +0100 Subject: [PATCH 1/6] update --- benches/Cargo.toml | 2 +- crates/bevy_math/Cargo.toml | 2 +- crates/bevy_math/src/lib.rs | 4 ++-- crates/bevy_mikktspace/Cargo.toml | 2 +- crates/bevy_reflect/Cargo.toml | 2 +- crates/bevy_render/Cargo.toml | 2 +- crates/bevy_transform/Cargo.toml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/benches/Cargo.toml b/benches/Cargo.toml index b78352a55dabe..7afdde7e2001e 100644 --- a/benches/Cargo.toml +++ b/benches/Cargo.toml @@ -7,7 +7,7 @@ publish = false license = "MIT OR Apache-2.0" [dev-dependencies] -glam = "0.24.1" +glam = "0.25" rand = "0.8" rand_chacha = "0.3" criterion = { version = "0.3", features = ["html_reports"] } diff --git a/crates/bevy_math/Cargo.toml b/crates/bevy_math/Cargo.toml index 7ee418a42158e..98213fadcfac3 100644 --- a/crates/bevy_math/Cargo.toml +++ b/crates/bevy_math/Cargo.toml @@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0" keywords = ["bevy"] [dependencies] -glam = { version = "0.24.1", features = ["bytemuck"] } +glam = { version = "0.25", features = ["bytemuck"] } serde = { version = "1", features = ["derive"], optional = true } [features] diff --git a/crates/bevy_math/src/lib.rs b/crates/bevy_math/src/lib.rs index c6fb416d7eacf..7444a0f3466cf 100644 --- a/crates/bevy_math/src/lib.rs +++ b/crates/bevy_math/src/lib.rs @@ -26,8 +26,8 @@ pub mod prelude { CubicBSpline, CubicBezier, CubicCardinalSpline, CubicGenerator, CubicHermite, CubicSegment, }, - primitives, BVec2, BVec3, BVec4, EulerRot, IRect, IVec2, IVec3, IVec4, Mat2, Mat3, Mat4, - Quat, Ray2d, Ray3d, Rect, URect, UVec2, UVec3, UVec4, Vec2, Vec2Swizzles, Vec3, + primitives, BVec2, BVec3, BVec4, EulerRot, FloatExt, IRect, IVec2, IVec3, IVec4, Mat2, + Mat3, Mat4, Quat, Ray2d, Ray3d, Rect, URect, UVec2, UVec3, UVec4, Vec2, Vec2Swizzles, Vec3, Vec3Swizzles, Vec4, Vec4Swizzles, }; } diff --git a/crates/bevy_mikktspace/Cargo.toml b/crates/bevy_mikktspace/Cargo.toml index 451e4e24a07a8..03ff2c30e6d4e 100644 --- a/crates/bevy_mikktspace/Cargo.toml +++ b/crates/bevy_mikktspace/Cargo.toml @@ -15,7 +15,7 @@ license = "Zlib AND (MIT OR Apache-2.0)" keywords = ["bevy", "3D", "graphics", "algorithm", "tangent"] [dependencies] -glam = "0.24.1" +glam = "0.25" [[example]] name = "generate" diff --git a/crates/bevy_reflect/Cargo.toml b/crates/bevy_reflect/Cargo.toml index 0b3be900d20bc..16d2eef4c2cfc 100644 --- a/crates/bevy_reflect/Cargo.toml +++ b/crates/bevy_reflect/Cargo.toml @@ -32,7 +32,7 @@ downcast-rs = "1.2" thiserror = "1.0" serde = "1" -glam = { version = "0.24.1", features = ["serde"], optional = true } +glam = { version = "0.25", features = ["serde"], optional = true } smol_str = { version = "0.2.0", optional = true } [dev-dependencies] diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index ba2f794504ef0..3298ca323ad4c 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -83,7 +83,7 @@ flate2 = { version = "1.0.22", optional = true } ruzstd = { version = "0.4.0", optional = true } # For transcoding of UASTC/ETC1S universal formats, and for .basis file support basis-universal = { version = "0.3.0", optional = true } -encase = { version = "0.6.1", features = ["glam"] } +encase = { git = "https://github.com/irate-devil/encase", branch = "update-glam", features = ["glam"] } # For wgpu profiling using tracing. Use `RUST_LOG=info` to also capture the wgpu spans. profiling = { version = "1", features = [ "profile-with-tracing", diff --git a/crates/bevy_transform/Cargo.toml b/crates/bevy_transform/Cargo.toml index 4bd7ea5724a54..bdccf9eefd500 100644 --- a/crates/bevy_transform/Cargo.toml +++ b/crates/bevy_transform/Cargo.toml @@ -25,7 +25,7 @@ thiserror = "1.0" [dev-dependencies] bevy_tasks = { path = "../bevy_tasks", version = "0.12.0" } approx = "0.5.1" -glam = { version = "0.24", features = ["approx"] } +glam = { version = "0.25", features = ["approx"] } [features] serialize = ["dep:serde", "bevy_math/serialize"] From 524942bb261ee04962f0bb6e31a52faae6944676 Mon Sep 17 00:00:00 2001 From: irate-devil Date: Sun, 24 Dec 2023 18:25:31 +0100 Subject: [PATCH 2/6] Use `lerp` in examples --- examples/3d/parallax_mapping.rs | 3 +-- examples/ui/ui_scaling.rs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/3d/parallax_mapping.rs b/examples/3d/parallax_mapping.rs index dfdca7d2e222c..d5b9d324796c2 100644 --- a/examples/3d/parallax_mapping.rs +++ b/examples/3d/parallax_mapping.rs @@ -99,8 +99,7 @@ fn update_parallax_depth_scale( let mut text = text.single_mut(); for (_, mat) in materials.iter_mut() { let current_depth = mat.parallax_depth_scale; - let new_depth = - current_depth * (1.0 - DEPTH_CHANGE_RATE) + (target_depth.0 * DEPTH_CHANGE_RATE); + let new_depth = current_depth.lerp(target_depth.0, DEPTH_CHANGE_RATE); mat.parallax_depth_scale = new_depth; text.sections[0].value = format!("Parallax depth scale: {new_depth:.5}\n"); if (new_depth - current_depth).abs() <= 0.000000001 { diff --git a/examples/ui/ui_scaling.rs b/examples/ui/ui_scaling.rs index 3d812bed24055..9c1beccbcd76a 100644 --- a/examples/ui/ui_scaling.rs +++ b/examples/ui/ui_scaling.rs @@ -113,8 +113,8 @@ impl TargetScale { fn current_scale(&self) -> f32 { let completion = self.target_time.fraction(); - let multiplier = ease_in_expo(completion); - self.start_scale + (self.target_scale - self.start_scale) * multiplier + let t = ease_in_expo(completion); + self.start_scale.lerp(self.target_scale, t) } fn tick(&mut self, delta: Duration) -> &Self { From 6f558d6d19b4f8ee2ebf83d828228a37f1bcb6f2 Mon Sep 17 00:00:00 2001 From: irate-devil Date: Fri, 5 Jan 2024 13:13:18 +0100 Subject: [PATCH 3/6] Update encase to 0.7 --- crates/bevy_render/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index 3298ca323ad4c..4bcb232490fa9 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -83,7 +83,7 @@ flate2 = { version = "1.0.22", optional = true } ruzstd = { version = "0.4.0", optional = true } # For transcoding of UASTC/ETC1S universal formats, and for .basis file support basis-universal = { version = "0.3.0", optional = true } -encase = { git = "https://github.com/irate-devil/encase", branch = "update-glam", features = ["glam"] } +encase = { version = "0.7", features = ["glam"] } # For wgpu profiling using tracing. Use `RUST_LOG=info` to also capture the wgpu spans. profiling = { version = "1", features = [ "profile-with-tracing", From ba12385869fa838398b2e73b51fb3e8879012a27 Mon Sep 17 00:00:00 2001 From: irate-devil Date: Fri, 5 Jan 2024 15:15:05 +0100 Subject: [PATCH 4/6] Use lerp method in bevy_animation --- crates/bevy_animation/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_animation/src/lib.rs b/crates/bevy_animation/src/lib.rs index fc5d1d2804e66..7aeed4f1a600d 100644 --- a/crates/bevy_animation/src/lib.rs +++ b/crates/bevy_animation/src/lib.rs @@ -10,7 +10,7 @@ use bevy_asset::{Asset, AssetApp, Assets, Handle}; use bevy_core::Name; use bevy_ecs::prelude::*; use bevy_hierarchy::{Children, Parent}; -use bevy_math::{Quat, Vec3}; +use bevy_math::{FloatExt, Quat, Vec3}; use bevy_reflect::Reflect; use bevy_render::mesh::morph::MorphWeights; use bevy_time::Time; @@ -723,7 +723,7 @@ fn apply_animation( let result = morph_start .iter() .zip(morph_end) - .map(|(a, b)| *a + lerp * (*b - *a)); + .map(|(a, b)| a.lerp(*b, lerp)); lerp_morph_weights(morphs.weights_mut(), result, weight); } } From d35d83ad2616c1c9af9f44121ca8efc226f9f2fe Mon Sep 17 00:00:00 2001 From: Devil Ira Date: Sun, 7 Jan 2024 17:55:25 +0100 Subject: [PATCH 5/6] Switched another manual lerp and an inverse_lerp to use the new methods --- crates/bevy_animation/src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_animation/src/lib.rs b/crates/bevy_animation/src/lib.rs index 5fd585fd374af..f3fe022035e76 100644 --- a/crates/bevy_animation/src/lib.rs +++ b/crates/bevy_animation/src/lib.rs @@ -593,7 +593,7 @@ fn run_animation_player( fn lerp_morph_weights(weights: &mut [f32], keyframe: impl Iterator, key_lerp: f32) { let zipped = weights.iter_mut().zip(keyframe); for (morph_weight, keyframe) in zipped { - *morph_weight += (keyframe - *morph_weight) * key_lerp; + *morph_weight = morph_weight.lerp(keyframe, key_lerp); } } @@ -721,7 +721,7 @@ fn apply_animation( }; let ts_start = curve.keyframe_timestamps[step_start]; let ts_end = curve.keyframe_timestamps[step_start + 1]; - let lerp = (animation.seek_time - ts_start) / (ts_end - ts_start); + let lerp = f32::inverse_lerp(ts_start, ts_end, animation.seek_time); apply_keyframe( curve, From a23c3575a976e67c64782f79415d971c44e89e22 Mon Sep 17 00:00:00 2001 From: devil-ira Date: Mon, 8 Jan 2024 22:47:12 +0100 Subject: [PATCH 6/6] Update hexasphere --- crates/bevy_render/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/bevy_render/Cargo.toml b/crates/bevy_render/Cargo.toml index 4bcb232490fa9..fb4a0a04bdea1 100644 --- a/crates/bevy_render/Cargo.toml +++ b/crates/bevy_render/Cargo.toml @@ -75,7 +75,7 @@ downcast-rs = "1.2.0" thread_local = "1.1" thiserror = "1.0" futures-lite = "2.0.1" -hexasphere = "9.0" +hexasphere = "10.0" ddsfile = { version = "0.5.0", optional = true } ktx2 = { version = "0.3.0", optional = true } # For ktx2 supercompression