-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
A-RenderingDrawing game state to the screenDrawing game state to the screenC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorP-RegressionFunctionality that used to work but no longer does. Add a test for this!Functionality that used to work but no longer does. Add a test for this!
Milestone
Description
Bevy version
bevy 0.16.0-rc.3
with bevy_pbr 0.16.0-rc.4
What you did
Despawning a Mesh in the Last schedule at a later time as spawning.
Minimal code:
use bevy::prelude::*;
fn main(){
let mut app = App::new();
app .add_plugins(DefaultPlugins)
.add_systems(Startup,startup)
.add_systems(Last,despawn)
.run();
}
fn startup(
mut cmd: Commands,
mut ass: ResMut<Assets<Mesh>>,
mut ase: ResMut<Assets<StandardMaterial>>
){
cmd.spawn((
Transform::from_xyz(0.,0.,5.),
Camera3d::default(),
));
cmd.spawn((
Mesh3d(ass.add(Cuboid::new(1.,1.,1.))),
MeshMaterial3d(ase.add(Color::srgb(1.,0.,0.)))
));
cmd.spawn(DirectionalLight{
shadows_enabled: true,
..default()
});
}
// despawn after 2 seconds
fn despawn(
mut cmd: Commands,
query: Query<Entity,With<Mesh3d>>,
time: Res<Time>,
mut delay: Local<f32>
){
*delay += time.delta_secs();
if *delay < 2. {return}
for e in &query {
cmd.entity(e).despawn();
}
}What went wrong
Running it (on linux 6.13.8-arch1-1 btw) always panics here:
thread 'Compute Task Pool (23)' panicked at ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_pbr-0.16.0-rc.4/src/material.rs:1014:79:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Encountered a panic in system `bevy_pbr::material::specialize_material_meshes<bevy_pbr::pbr_material::StandardMaterial>`!
If a DirectionalLight with enabled shadows is present, it also panics here:
thread 'Compute Task Pool (15)' panicked at ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/bevy_pbr-0.16.0-rc.4/src/render/light.rs:1820:84:
called `Option::unwrap()` on a `None` value
Encountered a panic in system `bevy_pbr::render::light::specialize_shadows<bevy_pbr::pbr_material::StandardMaterial>`!
Additional information
- It's easily avoidable by despawning in any schedule before
Last. - but afaik: this worked in bevy_pbr
0.16.0-rc.3
Metadata
Metadata
Assignees
Labels
A-RenderingDrawing game state to the screenDrawing game state to the screenC-BugAn unexpected or incorrect behaviorAn unexpected or incorrect behaviorP-RegressionFunctionality that used to work but no longer does. Add a test for this!Functionality that used to work but no longer does. Add a test for this!