Update glam, encase and hexasphere (#11082)

Update to `glam` 0.25, `encase` 0.7 and `hexasphere` to 10.0

## Changelog
Added the `FloatExt` trait to the `bevy_math` prelude which adds `lerp`,
`inverse_lerp` and `remap` methods to the `f32` and `f64` types.
This commit is contained in:
irate 2024-01-08 23:58:45 +01:00 committed by GitHub
parent c0f8338697
commit ec14e946b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 15 additions and 16 deletions

View File

@ -7,7 +7,7 @@ publish = false
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
[dev-dependencies] [dev-dependencies]
glam = "0.24.1" glam = "0.25"
rand = "0.8" rand = "0.8"
rand_chacha = "0.3" rand_chacha = "0.3"
criterion = { version = "0.3", features = ["html_reports"] } criterion = { version = "0.3", features = ["html_reports"] }

View File

@ -10,7 +10,7 @@ use bevy_asset::{Asset, AssetApp, Assets, Handle};
use bevy_core::Name; use bevy_core::Name;
use bevy_ecs::prelude::*; use bevy_ecs::prelude::*;
use bevy_hierarchy::{Children, Parent}; use bevy_hierarchy::{Children, Parent};
use bevy_math::{Quat, Vec3}; use bevy_math::{FloatExt, Quat, Vec3};
use bevy_reflect::Reflect; use bevy_reflect::Reflect;
use bevy_render::mesh::morph::MorphWeights; use bevy_render::mesh::morph::MorphWeights;
use bevy_time::Time; use bevy_time::Time;
@ -593,7 +593,7 @@ fn run_animation_player(
fn lerp_morph_weights(weights: &mut [f32], keyframe: impl Iterator<Item = f32>, key_lerp: f32) { fn lerp_morph_weights(weights: &mut [f32], keyframe: impl Iterator<Item = f32>, key_lerp: f32) {
let zipped = weights.iter_mut().zip(keyframe); let zipped = weights.iter_mut().zip(keyframe);
for (morph_weight, keyframe) in zipped { 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_start = curve.keyframe_timestamps[step_start];
let ts_end = curve.keyframe_timestamps[step_start + 1]; 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( apply_keyframe(
curve, curve,
@ -844,7 +844,7 @@ fn apply_keyframe(
let result = morph_start let result = morph_start
.iter() .iter()
.zip(morph_end) .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); lerp_morph_weights(morphs.weights_mut(), result, weight);
} }
} }

View File

@ -9,7 +9,7 @@ license = "MIT OR Apache-2.0"
keywords = ["bevy"] keywords = ["bevy"]
[dependencies] [dependencies]
glam = { version = "0.24.1", features = ["bytemuck"] } glam = { version = "0.25", features = ["bytemuck"] }
serde = { version = "1", features = ["derive"], optional = true } serde = { version = "1", features = ["derive"], optional = true }
[features] [features]

View File

@ -26,8 +26,8 @@ pub mod prelude {
CubicBSpline, CubicBezier, CubicCardinalSpline, CubicGenerator, CubicHermite, CubicBSpline, CubicBezier, CubicCardinalSpline, CubicGenerator, CubicHermite,
CubicSegment, CubicSegment,
}, },
primitives, BVec2, BVec3, BVec4, EulerRot, IRect, IVec2, IVec3, IVec4, Mat2, Mat3, Mat4, primitives, BVec2, BVec3, BVec4, EulerRot, FloatExt, IRect, IVec2, IVec3, IVec4, Mat2,
Quat, Ray2d, Ray3d, Rect, URect, UVec2, UVec3, UVec4, Vec2, Vec2Swizzles, Vec3, Mat3, Mat4, Quat, Ray2d, Ray3d, Rect, URect, UVec2, UVec3, UVec4, Vec2, Vec2Swizzles, Vec3,
Vec3Swizzles, Vec4, Vec4Swizzles, Vec3Swizzles, Vec4, Vec4Swizzles,
}; };
} }

View File

@ -15,7 +15,7 @@ license = "Zlib AND (MIT OR Apache-2.0)"
keywords = ["bevy", "3D", "graphics", "algorithm", "tangent"] keywords = ["bevy", "3D", "graphics", "algorithm", "tangent"]
[dependencies] [dependencies]
glam = "0.24.1" glam = "0.25"
[[example]] [[example]]
name = "generate" name = "generate"

View File

@ -32,7 +32,7 @@ downcast-rs = "1.2"
thiserror = "1.0" thiserror = "1.0"
serde = "1" 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 } smol_str = { version = "0.2.0", optional = true }
[dev-dependencies] [dev-dependencies]

View File

@ -77,7 +77,7 @@ downcast-rs = "1.2.0"
thread_local = "1.1" thread_local = "1.1"
thiserror = "1.0" thiserror = "1.0"
futures-lite = "2.0.1" futures-lite = "2.0.1"
hexasphere = "9.0" hexasphere = "10.0"
ddsfile = { version = "0.5.0", optional = true } ddsfile = { version = "0.5.0", optional = true }
ktx2 = { version = "0.3.0", optional = true } ktx2 = { version = "0.3.0", optional = true }
# For ktx2 supercompression # For ktx2 supercompression
@ -85,7 +85,7 @@ flate2 = { version = "1.0.22", optional = true }
ruzstd = { version = "0.4.0", optional = true } ruzstd = { version = "0.4.0", optional = true }
# For transcoding of UASTC/ETC1S universal formats, and for .basis file support # For transcoding of UASTC/ETC1S universal formats, and for .basis file support
basis-universal = { version = "0.3.0", optional = true } basis-universal = { version = "0.3.0", optional = true }
encase = { version = "0.6.1", features = ["glam"] } encase = { version = "0.7", features = ["glam"] }
# For wgpu profiling using tracing. Use `RUST_LOG=info` to also capture the wgpu spans. # For wgpu profiling using tracing. Use `RUST_LOG=info` to also capture the wgpu spans.
profiling = { version = "1", features = [ profiling = { version = "1", features = [
"profile-with-tracing", "profile-with-tracing",

View File

@ -99,8 +99,7 @@ fn update_parallax_depth_scale(
let mut text = text.single_mut(); let mut text = text.single_mut();
for (_, mat) in materials.iter_mut() { for (_, mat) in materials.iter_mut() {
let current_depth = mat.parallax_depth_scale; let current_depth = mat.parallax_depth_scale;
let new_depth = let new_depth = current_depth.lerp(target_depth.0, DEPTH_CHANGE_RATE);
current_depth * (1.0 - DEPTH_CHANGE_RATE) + (target_depth.0 * DEPTH_CHANGE_RATE);
mat.parallax_depth_scale = new_depth; mat.parallax_depth_scale = new_depth;
text.sections[0].value = format!("Parallax depth scale: {new_depth:.5}\n"); text.sections[0].value = format!("Parallax depth scale: {new_depth:.5}\n");
if (new_depth - current_depth).abs() <= 0.000000001 { if (new_depth - current_depth).abs() <= 0.000000001 {

View File

@ -113,8 +113,8 @@ impl TargetScale {
fn current_scale(&self) -> f32 { fn current_scale(&self) -> f32 {
let completion = self.target_time.fraction(); let completion = self.target_time.fraction();
let multiplier = ease_in_expo(completion); let t = ease_in_expo(completion);
self.start_scale + (self.target_scale - self.start_scale) * multiplier self.start_scale.lerp(self.target_scale, t)
} }
fn tick(&mut self, delta: Duration) -> &Self { fn tick(&mut self, delta: Duration) -> &Self {