Skip to content

Update rand, glam and encase to latest versions #18047

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ jobs:
with:
target: wasm32-unknown-unknown
- name: Check wasm
env:
RUSTFLAGS: --cfg getrandom_backend="wasm_js"
run: cargo check --target wasm32-unknown-unknown

build-wasm-atomics:
Expand All @@ -247,7 +249,7 @@ jobs:
- name: Check wasm
run: cargo check --target wasm32-unknown-unknown -Z build-std=std,panic_abort
env:
RUSTFLAGS: "-C target-feature=+atomics,+bulk-memory -D warnings"
RUSTFLAGS: '-C target-feature=+atomics,+bulk-memory -D warnings --cfg getrandom_backend="wasm_js"'

markdownlint:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/validation-jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ jobs:
cd ../..

- name: First Wasm build
env:
RUSTFLAGS: --cfg getrandom_backend="wasm_js"
run: |
cargo build --release --example testbed_ui --target wasm32-unknown-unknown

Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -546,8 +546,8 @@ tracing = { version = "0.1", default-features = false, optional = true }
bevy_dylib = { path = "crates/bevy_dylib", version = "0.16.0-dev", default-features = false, optional = true }

[dev-dependencies]
rand = "0.8.0"
rand_chacha = "0.3.1"
rand = "0.9.0"
rand_chacha = "0.9.0"
ron = "0.8.0"
flate2 = "1.0"
serde = { version = "1", features = ["derive"] }
Expand Down Expand Up @@ -582,6 +582,7 @@ smol-hyper = "0.1"
ureq = { version = "3.0.8", features = ["json"] }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
getrandom = { version = "0.3", features = ["wasm_js"] }
wasm-bindgen = { version = "0.2" }
web-sys = { version = "0.3", features = ["Window"] }

Expand Down
6 changes: 3 additions & 3 deletions benches/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ bevy_platform = { path = "../crates/bevy_platform", default-features = false, fe
] }

# Other crates
glam = "0.29"
rand = "0.8"
rand_chacha = "0.3"
glam = { version = "0.30.1" }
rand = "0.9"
rand_chacha = "0.9"
nonmax = { version = "0.5", default-features = false }

# Make `bevy_render` compile on Linux with x11 windowing. x11 vs. Wayland does not matter here
Expand Down
4 changes: 2 additions & 2 deletions benches/benches/bevy_ecs/observers/propagation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl<const N: usize> Event for TestEvent<N> {
}

fn send_events<const N: usize, const N_EVENTS: usize>(world: &mut World, leaves: &[Entity]) {
let target = leaves.iter().choose(&mut rand::thread_rng()).unwrap();
let target = leaves.iter().choose(&mut rand::rng()).unwrap();

(0..N_EVENTS).for_each(|_| {
world.trigger_targets(TestEvent::<N> {}, *target);
Expand Down Expand Up @@ -111,7 +111,7 @@ fn add_listeners_to_hierarchy<const DENSITY: usize, const N: usize>(
}
let mut rng = deterministic_rand();
for e in nodes.iter() {
if rng.gen_bool(DENSITY as f64 / 100.0) {
if rng.random_bool(DENSITY as f64 / 100.0) {
world.entity_mut(*e).observe(empty_listener::<N>);
}
}
Expand Down
4 changes: 2 additions & 2 deletions benches/benches/bevy_ecs/world/entity_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ fn make_entity(rng: &mut impl Rng, size: usize) -> Entity {
// * For ids, half are in [0, size), half are unboundedly larger.
// * For generations, half are in [1, 3), half are unboundedly larger.

let x: f64 = rng.r#gen();
let x: f64 = rng.random();
let id = -(1.0 - x).log2() * (size as f64);
let x: f64 = rng.r#gen();
let x: f64 = rng.random();
let generation = 1.0 + -(1.0 - x).log2() * 2.0;

// this is not reliable, but we're internal so a hack is ok
Expand Down
10 changes: 5 additions & 5 deletions benches/benches/bevy_reflect/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use core::{fmt::Write, hint::black_box, str, time::Duration};
use benches::bench;
use bevy_reflect::ParsedPath;
use criterion::{criterion_group, BatchSize, BenchmarkId, Criterion, Throughput};
use rand::{distributions::Uniform, Rng, SeedableRng};
use rand::{distr::Uniform, Rng, SeedableRng};
use rand_chacha::ChaCha8Rng;

criterion_group!(benches, parse_reflect_path);
Expand All @@ -18,20 +18,20 @@ fn deterministic_rand() -> ChaCha8Rng {
ChaCha8Rng::seed_from_u64(42)
}
fn random_ident(rng: &mut ChaCha8Rng, f: &mut dyn Write) {
let between = Uniform::from(b'a'..=b'z');
let ident_size = rng.gen_range(1..128);
let between = Uniform::new_inclusive(b'a', b'z').unwrap();
let ident_size = rng.random_range(1..128);
let ident: Vec<u8> = rng.sample_iter(between).take(ident_size).collect();
let ident = str::from_utf8(&ident).unwrap();
let _ = write!(f, "{ident}");
}

fn random_index(rng: &mut ChaCha8Rng, f: &mut dyn Write) {
let index = rng.gen_range(1..128);
let index = rng.random_range(1..128);
let _ = write!(f, "{index}");
}

fn write_random_access(rng: &mut ChaCha8Rng, f: &mut dyn Write) {
match rng.gen_range(0..4) {
match rng.random_range(0..4) {
0 => {
// Access::Field
f.write_char('.').unwrap();
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_color/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ serde = { version = "1.0", features = [
thiserror = { version = "2", default-features = false }
derive_more = { version = "1", default-features = false, features = ["from"] }
wgpu-types = { version = "24", default-features = false, optional = true }
encase = { version = "0.10", default-features = false, optional = true }
encase = { version = "0.11", default-features = false, optional = true }

[features]
default = ["std", "bevy_reflect", "encase"]
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ concurrent-queue = { version = "2.5.0", default-features = false, features = [
] }

[dev-dependencies]
rand = "0.8"
rand = "0.9"
static_assertions = "1.1.0"
serde_test = "1.0"

Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/examples/change_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ enum SimulationSystems {
// The entity will start with an age of 0 frames
// If an entity gets spawned, we increase the counter in the EntityCounter resource
fn spawn_entities(mut commands: Commands, mut entity_counter: ResMut<EntityCounter>) {
if rand::thread_rng().gen_bool(0.6) {
if rand::rng().random_bool(0.6) {
let entity_id = commands.spawn(Age::default()).id();
println!(" spawning {entity_id:?}");
entity_counter.value += 1;
Expand Down
2 changes: 1 addition & 1 deletion crates/bevy_ecs/examples/resources.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct Counter {
}

fn increase_counter(mut counter: ResMut<Counter>) {
if rand::thread_rng().gen_bool(0.5) {
if rand::rng().random_bool(0.5) {
counter.value += 1;
println!(" Increased counter value");
}
Expand Down
15 changes: 9 additions & 6 deletions crates/bevy_math/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ keywords = ["bevy"]
rust-version = "1.85.0"

[dependencies]
glam = { version = "0.29.3", default-features = false, features = ["bytemuck"] }
glam = { version = "0.30.1", default-features = false, features = ["bytemuck"] }
thiserror = { version = "2", default-features = false }
derive_more = { version = "1", default-features = false, features = [
"from",
Expand All @@ -22,8 +22,8 @@ serde = { version = "1", default-features = false, features = [
], optional = true }
libm = { version = "0.2", optional = true }
approx = { version = "0.5", default-features = false, optional = true }
rand = { version = "0.8", default-features = false, optional = true }
rand_distr = { version = "0.4.3", optional = true }
rand = { version = "0.9", default-features = false, optional = true }
rand_distr = { version = "0.5", optional = true }
smallvec = { version = "1.11" }
bevy_reflect = { path = "../bevy_reflect", version = "0.16.0-dev", default-features = false, features = [
"glam",
Expand All @@ -33,11 +33,14 @@ variadics_please = "1.1"
[dev-dependencies]
approx = "0.5"
# Supply rngs for examples and tests
rand = "0.8"
rand_chacha = "0.3"
rand = "0.9"
rand_chacha = "0.9"
# Enable the approx feature when testing.
bevy_math = { path = ".", default-features = false, features = ["approx"] }
glam = { version = "0.29.3", default-features = false, features = ["approx"] }
glam = { version = "0.30.1", default-features = false, features = ["approx"] }

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
getrandom = { version = "0.3", features = ["wasm_js"] }

[features]
default = ["std", "rand", "curve"]
Expand Down
7 changes: 5 additions & 2 deletions crates/bevy_math/src/sampling/mesh_sampling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ use crate::{
};
use alloc::vec::Vec;
use rand::Rng;
use rand_distr::{Distribution, WeightedAliasIndex, WeightedError};
use rand_distr::{
weighted::{Error as WeightedError, WeightedAliasIndex},
Distribution,
};

/// A [distribution] that caches data to allow fast sampling from a collection of triangles.
/// Generally used through [`sample`] or [`sample_iter`].
Expand All @@ -19,7 +22,7 @@ use rand_distr::{Distribution, WeightedAliasIndex, WeightedError};
/// ```
/// # use bevy_math::{Vec3, primitives::*};
/// # use bevy_math::sampling::mesh_sampling::UniformMeshSampler;
/// # use rand::{SeedableRng, rngs::StdRng, distributions::Distribution};
/// # use rand::{SeedableRng, rngs::StdRng, distr::Distribution};
/// let faces = Tetrahedron::default().faces();
/// let sampler = UniformMeshSampler::try_new(faces).unwrap();
/// let rng = StdRng::seed_from_u64(8765309);
Expand Down
Loading
Loading