Skip to content

Commit

Permalink
update rand to 0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
tropical32 committed Jan 29, 2025
1 parent 8ac3dcc commit e30b0ea
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ default = ["egui"]
egui = ["dep:bevy-inspector-egui"]

[dependencies]
bevy = { version = "0.15.1", default-features = false, features = [
bevy = { version = "0.15.*", default-features = false, features = [
"bevy_render",
"bevy_core_pipeline",
"bevy_winit",
Expand All @@ -25,12 +25,12 @@ bevy = { version = "0.15.1", default-features = false, features = [
"multi_threaded",
"wayland",
] }
bevy-inspector-egui = { version = "0.29.1", optional = true }
log = "0.4.20"
rand = "0.8.5"
bevy-inspector-egui = { version = "0.29.*", optional = true }
log = "0.4.*"
rand = "0.9.*"

[dev-dependencies]
bevy = "0.15.1"
bevy = "0.15.*"

[profile.release]
codegen-units = 1
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ cargo run --example krypta

- [ ] Add examples and HUD explaining how to use example.

## Compatibility

| bevy | bevy_magic_light_2d |
| ------ | ------------------- |
| `0.15` | `0.9` |
| `0.14` | `0.8` |

### License

```
Expand Down
8 changes: 4 additions & 4 deletions examples/krypta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,13 +167,13 @@ fn setup(
let decorations_image = asset_server.load("art/atlas_decoration.png");

// Spawn floor tiles.
let mut rng = thread_rng();
let mut rng = rand::rng();
let mut floor_tiles = vec![];
for (i, row) in walls_info.iter().enumerate() {
for (j, _) in row.iter().enumerate() {
let xy = get_block_translation(i, j);
let z = get_floor_z(xy.y);
let id = rng.gen_range(0..(floor_atlas_cols * floor_atlas_rows));
let id = rng.random_range(0..(floor_atlas_cols * floor_atlas_rows));

floor_tiles.push(
commands
Expand Down Expand Up @@ -869,7 +869,7 @@ fn system_control_mouse_light(
keyboard: Res<ButtonInput<KeyCode>>,
)
{
let mut rng = thread_rng();
let mut rng = rand::rng();

// We only need to iter over first camera matched.
let (camera, camera_transform) = query_cameras.iter().next().unwrap();
Expand All @@ -888,7 +888,7 @@ fn system_control_mouse_light(
mouse_transform.translation = mouse_world.truncate().extend(1000.0);

if mouse.just_pressed(MouseButton::Right) {
mouse_color.color = Color::srgba(rng.gen(), rng.gen(), rng.gen(), 1.0);
mouse_color.color = Color::srgba(rng.random(), rng.random(), rng.random(), 1.0);
}
if mouse.just_pressed(MouseButton::Left) && keyboard.pressed(KeyCode::ShiftLeft) {
commands
Expand Down
10 changes: 5 additions & 5 deletions src/gi/pipeline_assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use bevy::prelude::*;
use bevy::render::render_resource::{StorageBuffer, UniformBuffer};
use bevy::render::renderer::{RenderDevice, RenderQueue};
use bevy::render::Extract;
use rand::{thread_rng, Rng};
use rand::Rng;

use crate::gi::constants::GI_SCREEN_PROBE_SIZE;
use crate::gi::resource::ComputedTargetSizes;
Expand Down Expand Up @@ -109,7 +109,7 @@ pub fn system_extract_pipeline_assets(

{
let light_sources = gpu_pipeline_assets.light_sources.get_mut();
let mut rng = thread_rng();
let mut rng = rand::rng();
light_sources.count = 0;
light_sources.data.clear();
for (transform, light_source, hviz, vviz) in query_lights.iter() {
Expand All @@ -118,14 +118,14 @@ pub fn system_extract_pipeline_assets(
light_sources.data.push(GpuOmniLightSource::new(
OmniLightSource2D {
intensity: light_source.intensity
+ rng.gen_range(-1.0..1.0) * light_source.jitter_intensity,
+ rng.random_range(-1.0..1.0) * light_source.jitter_intensity,
..*light_source
},
Vec2::new(
transform.translation().x
+ rng.gen_range(-1.0..1.0) * light_source.jitter_translation,
+ rng.random_range(-1.0..1.0) * light_source.jitter_translation,
transform.translation().y
+ rng.gen_range(-1.0..1.0) * light_source.jitter_translation,
+ rng.random_range(-1.0..1.0) * light_source.jitter_translation,
),
));
}
Expand Down

0 comments on commit e30b0ea

Please sign in to comment.