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

Visibility.is_visible is always overwritten after mesh building #108

Closed
rparrett opened this issue Jul 27, 2021 · 1 comment · Fixed by #111
Closed

Visibility.is_visible is always overwritten after mesh building #108

rparrett opened this issue Jul 27, 2021 · 1 comment · Fixed by #111

Comments

@rparrett
Copy link
Contributor

rparrett commented Jul 27, 2021

So it's seemingly impossible to spawn a shape in an initially invisible state.

I toyed with removing this behavior by setting is_visible to true in impl Default for ShapeBundle and removing the visible.is_visible = true in complete_shape_bundle. This didn't seem to harm anything, but it seems like this must be happening for a reason.

In my own code, I've worked around this with

struct ShapeStartsInvisible;

// ...

app.add_stage_after(
        bevy_prototype_lyon::plugin::Stage::Shape,
        "after_shape",
        SystemStage::parallel(),
    );
app.add_system_to_stage("after_shape", shape_visibility_fix.system());

// ...

fn shape_visibility_fix(
    mut invis: Query<&mut Visible, (Changed<Handle<Mesh>>, With<ShapeStartsInvisible>)>,
) {
    for mut visible in invis.iter_mut() {
        visible.is_visible = false;
    }
}

But adding a similar component to bevy_prototype_lyon to control initial visibility seems like an option if it turns out that having a visible shape without a mesh hanging around for a bit is harmful.

If you'd like to point me in one direction or the other I'd be happy to send a PR over.

@Nilirad
Copy link
Owner

Nilirad commented Jul 28, 2021

Thanks for pointing it out. I understand what the issue is. As soon as possible, I will put visibility to default in ShapeBundle::default and remove setting visibility to true in complete_shape_bundle.

I did that because I've put a dummy quad mesh during ShapeBundle creation, but it is unnecessary to set it to invisible, since it is immediately replaced by the shape even before the frame gets rendered.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants