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

Unwrap on mesh with no index buffer #1228

Closed
JCapucho opened this issue Jan 10, 2021 · 0 comments · Fixed by #1229
Closed

Unwrap on mesh with no index buffer #1228

JCapucho opened this issue Jan 10, 2021 · 0 comments · Fixed by #1229

Comments

@JCapucho
Copy link
Contributor

Bevy version

I tested both the 0.4 version and commit 4a08370 on master

Operating system & version

Arch linux using the 5.10 kernel and latest nvidia drivers

What you did

Created a mesh with only the positions attribute

use bevy::{prelude::*, render::pipeline::PrimitiveTopology};

fn main() {
    App::build()
        .add_plugins(DefaultPlugins)
        .add_startup_system(setup.system())
        .run();
}

fn setup(commands: &mut Commands, mut meshes: ResMut<Assets<Mesh>>) {
    let positions = vec![[0., 0., 0.], [0., 0., 1.], [1., 0., 0.]];
    let mut mesh = Mesh::new(PrimitiveTopology::TriangleList);
    mesh.set_attribute(Mesh::ATTRIBUTE_POSITION, positions);

    commands.spawn(MeshBundle {
        mesh: meshes.add(mesh),
        ..Default::default()
    });
}

What you expected to happen

The program running normally or crashing because of missing attributes

What actually happened

The program crashed because it tried to unwrap the value returned by mesh.get_index_buffer_bytes() and it was None because the mesh didn't have a index buffer

Additional information
The unwrap occurs in bevy_render/src/mesh/mesh.rs:395:48

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.

1 participant