picking: disable raycast backface culling for Mesh2d (#16657)

# Objective

- This fixes raycast picking with lyon
- reverse winding of 2D meshes currently results in them being rendered
but not pickable as the raycast passes through the backface and would
only hit "from below"

## Solution

- Disables backface culling for Mesh2d

## Testing

- Tested picking with bevy_prototype_lyon
- Could probably use testing with Mesh3d (should not be affected) and
SimplifiedMesh (no experience with that, could have the same issue if
used for 2D?)

---------

Co-authored-by: Aevyrie <aevyrie@gmail.com>
This commit is contained in:
Robin Gloster 2024-12-05 21:22:29 +00:00 committed by GitHub
parent d3241c4f8d
commit e763b71591
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -274,9 +274,10 @@ impl<'w, 's> MeshRayCast<'w, 's> {
return;
};
let backfaces = match has_backfaces {
true => Backfaces::Include,
false => Backfaces::Cull,
// Backfaces of 2d meshes are never culled, unlike 3d mehses.
let backfaces = match (has_backfaces, mesh2d.is_some()) {
(false, false) => Backfaces::Cull,
_ => Backfaces::Include,
};
// Perform the actual ray cast.