-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Gizmos drawing despawned entities #13383
Comments
Does this occur on 0.13? |
Nope. |
Video of behavior on f91fd32 Screencast_20240515_195205.webm |
Additional behavior of bug: After despawning the entity, resizing or fullscreening the window causes whatever state is invalid to be updated making the gizmo no longer be drawn. |
I just tested it with the #10973 commit and it works correctly. So it's something else. I'll run a git bisect |
Modifying the code to this: use bevy::prelude::*;
#[derive(Component)]
struct Point(Vec2);
fn setup(mut cmds: Commands) {
cmds.spawn(Camera2dBundle::default());
cmds.spawn(Point(Vec2::new(0.0, 150.0)));
cmds.spawn(Point(Vec2::new(100.0, 150.0)));
cmds.spawn(Point(Vec2::new(200.0, 150.0)));
cmds.spawn(Point(Vec2::new(300.0, 150.0)));
}
fn draw(mut gizmos: Gizmos, tree: Query<&Point>) {
for Point(pos) in tree.iter() {
gizmos.circle_2d(*pos, 40., Color::WHITE);
}
}
fn despawn(
mut cmds: Commands,
points: Query<Entity, With<Point>>,
mouse_buttons: Res<ButtonInput<MouseButton>>,
) {
if mouse_buttons.just_pressed(MouseButton::Left) {
for entity in points.iter().take(1) {
cmds.entity(entity).despawn();
println!("despawned");
}
}
}
fn main() {
App::new()
.add_plugins(DefaultPlugins)
.add_systems(Startup, setup)
.add_systems(Update, (draw, despawn).chain())
.run();
} Reveals that this happens |
I'm currently running a bisect to figure out which commit introduced this bug |
Seems like #12982 is causing the issue. I'm investigating, I'm really not sure how that PR could affect gizmos |
Bevy version
f91fd32
Relevant system information
Rust version:
1.78.0
System info:
Adapter info:
What you did
Setup a point to be deleted when the mouse button is pressed anywhere, draw the point with a circle gizmo.
What went wrong
The text was updated successfully, but these errors were encountered: