Skip to content

mesh_picking not updating when mesh data changes, bug or intended? #18221

@ncorbin786

Description

@ncorbin786

Bevy version

0.15.3

What you did

Might be a bug with mesh_picking. I noticed that when I adjusted the vertex positions on a Plane3d in real time the Trigger<Pointer<Click>> events would still fire, but only based on the dimensions of the initial mesh.

The updates I made to the Mesh3d vertex positions wouldn't affect it. Visually I could see the new mesh was larger, but if I clicked anywhere in those zones nothing happened. I had to click the original position to get it to fire.

I was using mesh.insert_attribute(Mesh::ATTRIBUTE_POSITION, new_positions.clone()); to adjust the vertex positions.

What went wrong

  • Adjusting Mesh3d vertex positions does not update mesh_picking

Additional information

I found I was able to get it to work, as intended, after updating the vertex position by removing the Aabb component and re-adding it:

                    // Update the AABB to refresh raycasting
                    commands.entity(parent.get()).remove::<Aabb>();
                    commands.entity(parent.get()).insert(mesh.compute_aabb().unwrap());

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-AssetsLoad files from disk to use for things like images, models, and soundsA-PickingPointing at and selecting objects of all sortsC-BugAn unexpected or incorrect behaviorD-StraightforwardSimple bug fixes and API improvements, docs, test and examplesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions