Skip to content

Commit

Permalink
picking: disable raycast backface culling for Mesh2d (#16657)
Browse files Browse the repository at this point in the history
# 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 <[email protected]>
  • Loading branch information
globin and aevyrie authored Dec 5, 2024
1 parent d3241c4 commit e763b71
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions crates/bevy_picking/src/mesh_picking/ray_cast/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit e763b71

Please sign in to comment.