bevy/benches/benches
Waridley 9e1e8bc1bc
Add angle-weighted smooth normals implementation (#18383) (#18552)
# Objective

Closes #18383 

## Solution

Given the 2 votes (me and @komadori ) for making angle-weighted normals
the default, I went ahead and did so, moving the face-weighted
implementation to the new `Mesh::compute_face_weighted_normals` method.
I factored out the common code between both into
`Mesh::compute_custom_smooth_normals`, which I went ahead and made
public to make it easier for users to add any other weighting methods
they might come up with.

If any of these decisions are undesirable for any reason, please let me
know and I will gladly make modifications.

## Testing & Showcase

I made a demo that exaggerates the difference at
[Waridley/bevy_smooth_normals_comparison](https://github.com/Waridley/bevy_smooth_normals_comparison).
Screenshots included in the readme.

Another way it could be demonstrated is via scaling a mesh along its
normals, like for generating outline meshes with inverted faces. I'd be
willing to make a demo for that as well.

I also edited and renamed the `compute_smooth_normals` tests to use
face-weighted normals, and added a new test for angle-weighted ones
which validates that all normals of a unit cube have each component
equal to `(±1 / √3) ± f32::EPSILON`.

## Migration Guide

#16050 already did not mention a migration guide, and it is not even in
a stable release yet. If this lands in a 0.16 RC, updating from RC1
would probably not require any changes in the vast majority of cases,
anyway. If someone really needs face-weighted normals, they can switch
to `.compute_face_weighted_normals()` or
`.with_computed_face_weighted_normals()`. And if for some reason they
really liked the old count-weighted implementation from 0.15, there is
an example in the docs for `compute_custom_smooth_normals`.
2025-07-17 19:23:30 +00:00
..
bevy_ecs Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_math Improve Bevy's double-precision story for third-party crates (#19194) 2025-06-08 02:02:47 +00:00
bevy_picking Upstream raycasting UVs (#19791) 2025-06-24 18:10:59 +00:00
bevy_reflect Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_render Add angle-weighted smooth normals implementation (#18383) (#18552) 2025-07-17 19:23:30 +00:00
bevy_tasks Migrate to core::hint::black_box() (#16980) 2024-12-29 19:33:42 +00:00