Expand description
This module holds local implementations of the Distribution
trait for StandardUniform
, which
allow certain Bevy math types (those whose values can be randomly generated without additional
input other than an Rng
) to be produced using rand
’s APIs. It also holds FromRng
,
an ergonomic extension to that functionality which permits the omission of type annotations.
For instance:
let mut rng = StdRng::seed_from_u64(7313429298);
// Random direction using thread-local rng
let random_direction1: Dir3 = random();
// Random direction using the rng constructed above
let random_direction2: Dir3 = rng.random();
// The same as the previous but with different syntax
let random_direction3 = Dir3::from_rng(&mut rng);
// Five random directions, using StandardUniform explicitly
let many_random_directions: Vec<Dir3> = rng.sample_iter(StandardUniform).take(5).collect();
Traits§
- FromRng
- Ergonomics trait for a type with a
StandardUniform
distribution, allowing values to be generated uniformly from anRng
by a method in its own namespace.