Skip to content
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

Deterministic fallible_systems example #17813

Merged
Merged
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
3 changes: 1 addition & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2159,13 +2159,13 @@ wasm = false
name = "fallible_systems"
path = "examples/ecs/fallible_systems.rs"
doc-scrape-examples = true
required-features = ["bevy_mesh_picking_backend"]
Copy link
Contributor

@rparrett rparrett Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? Example seems to work if I remove it and I see bevy_mesh_picking_backend in default.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strictly speaking, no, it's a default feature


[package.metadata.example.fallible_systems]
name = "Fallible Systems"
description = "Systems that return results to handle errors"
category = "ECS (Entity Component System)"
wasm = false
required-features = ["bevy_mesh_picking_backend"]

[[example]]
name = "startup_system"
Expand Down Expand Up @@ -4003,7 +4003,6 @@ name = "Sprite Picking"
description = "Demonstrates picking sprites and sprite atlases"
category = "Picking"
wasm = true
required-features = ["bevy_sprite_picking_backend"]

[[example]]
name = "debug_picking"
Expand Down
6 changes: 4 additions & 2 deletions examples/ecs/fallible_systems.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use bevy::math::sampling::UniformMeshSampler;
use bevy::prelude::*;

use rand::distributions::Distribution;
use rand::SeedableRng;
use rand_chacha::ChaCha8Rng;

fn main() {
let mut app = App::new();
Expand Down Expand Up @@ -68,7 +70,7 @@ fn setup(
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) -> Result {
let mut rng = rand::thread_rng();
let mut seeded_rng = ChaCha8Rng::seed_from_u64(19878367467712);

// Make a plane for establishing space.
commands.spawn((
Expand Down Expand Up @@ -116,7 +118,7 @@ fn setup(
});

// Add sample points as children of the sphere:
for point in distribution.sample_iter(&mut rng).take(10000) {
for point in distribution.sample_iter(&mut seeded_rng).take(10000) {
sphere.with_child((
Mesh3d(point_mesh.clone()),
MeshMaterial3d(point_material.clone()),
Expand Down
Loading