cargo fmt
This commit is contained in:
parent
171fc4bce2
commit
53400497dd
@ -6,7 +6,10 @@ use crate::{
|
||||
};
|
||||
use alloc::vec::Vec;
|
||||
use rand::Rng;
|
||||
use rand_distr::{Distribution, weighted::{WeightedAliasIndex, Error as 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`].
|
||||
|
||||
@ -42,7 +42,7 @@ use core::f32::consts::{PI, TAU};
|
||||
|
||||
use crate::{ops, primitives::*, NormedVectorSpace, Vec2, Vec3};
|
||||
use rand::{
|
||||
distr::{Distribution, weighted::WeightedIndex},
|
||||
distr::{weighted::WeightedIndex, Distribution},
|
||||
Rng,
|
||||
};
|
||||
|
||||
@ -201,7 +201,8 @@ impl ShapeSample for Annulus {
|
||||
let outer_radius = self.outer_circle.radius;
|
||||
|
||||
// Like random sampling for a circle, radius is weighted by the square.
|
||||
let r_squared = rng.random_range((inner_radius * inner_radius)..(outer_radius * outer_radius));
|
||||
let r_squared =
|
||||
rng.random_range((inner_radius * inner_radius)..(outer_radius * outer_radius));
|
||||
let r = ops::sqrt(r_squared);
|
||||
let theta = rng.random_range(0.0..TAU);
|
||||
let (sin, cos) = ops::sin_cos(theta);
|
||||
|
||||
@ -98,7 +98,10 @@ fn user_input(
|
||||
let texture = asset_server.load("textures/simplespace/enemy_A.png");
|
||||
commands.spawn((
|
||||
Enemy {
|
||||
origin: Vec2::new(rng.random_range(-200.0..200.0), rng.random_range(-200.0..200.0)),
|
||||
origin: Vec2::new(
|
||||
rng.random_range(-200.0..200.0),
|
||||
rng.random_range(-200.0..200.0),
|
||||
),
|
||||
radius: rng.random_range(50.0..150.0),
|
||||
rotation: rng.random_range(0.0..std::f32::consts::TAU),
|
||||
rotation_speed: rng.random_range(0.5..1.5),
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
use std::time::Duration;
|
||||
|
||||
use bevy::{log::LogPlugin, prelude::*, time::common_conditions::on_timer};
|
||||
use rand::{seq::IteratorRandom, rng, Rng};
|
||||
use rand::{rng, seq::IteratorRandom, Rng};
|
||||
|
||||
fn main() {
|
||||
App::new()
|
||||
|
||||
@ -575,7 +575,12 @@ fn init_textures(textures: &mut Vec<Handle<Image>>, args: &Args, images: &mut As
|
||||
// This isn't strictly required in practical use unless you need your app to be deterministic.
|
||||
let mut color_rng = ChaCha8Rng::seed_from_u64(42);
|
||||
while textures.len() < args.material_texture_count {
|
||||
let pixel = [color_rng.random(), color_rng.random(), color_rng.random(), 255];
|
||||
let pixel = [
|
||||
color_rng.random(),
|
||||
color_rng.random(),
|
||||
color_rng.random(),
|
||||
255,
|
||||
];
|
||||
textures.push(images.add(Image::new_fill(
|
||||
Extent3d {
|
||||
width: BIRD_TEXTURE_SIZE as u32,
|
||||
|
||||
@ -27,7 +27,7 @@ use bevy::{
|
||||
MinimalPlugins,
|
||||
};
|
||||
|
||||
use rand::prelude::{Rng, SeedableRng, IndexedRandom};
|
||||
use rand::prelude::{IndexedRandom, Rng, SeedableRng};
|
||||
use rand_chacha::ChaCha8Rng;
|
||||
use std::{alloc::Layout, mem::ManuallyDrop, num::Wrapping};
|
||||
|
||||
|
||||
@ -262,7 +262,13 @@ fn init_textures(args: &Args, images: &mut Assets<Image>) -> Vec<Handle<Image>>
|
||||
// This isn't strictly required in practical use unless you need your app to be deterministic.
|
||||
let mut color_rng = ChaCha8Rng::seed_from_u64(42);
|
||||
let color_bytes: Vec<u8> = (0..(args.material_texture_count * 4))
|
||||
.map(|i| if (i % 4) == 3 { 255 } else { color_rng.random() })
|
||||
.map(|i| {
|
||||
if (i % 4) == 3 {
|
||||
255
|
||||
} else {
|
||||
color_rng.random()
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
color_bytes
|
||||
.chunks(4)
|
||||
@ -311,7 +317,11 @@ fn init_materials(
|
||||
materials.extend(
|
||||
std::iter::repeat_with(|| {
|
||||
assets.add(StandardMaterial {
|
||||
base_color: Color::srgb_u8(color_rng.random(), color_rng.random(), color_rng.random()),
|
||||
base_color: Color::srgb_u8(
|
||||
color_rng.random(),
|
||||
color_rng.random(),
|
||||
color_rng.random(),
|
||||
),
|
||||
base_color_texture: textures.choose(&mut texture_rng).cloned(),
|
||||
..default()
|
||||
})
|
||||
|
||||
@ -12,7 +12,7 @@ use bevy::{
|
||||
|
||||
use argh::FromArgs;
|
||||
use rand::{
|
||||
seq::{IteratorRandom, IndexedRandom},
|
||||
seq::{IndexedRandom, IteratorRandom},
|
||||
Rng, SeedableRng,
|
||||
};
|
||||
use rand_chacha::ChaCha8Rng;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user