bevy/crates
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_a11y Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_animation Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_anti_aliasing Clean up several miscellaneous uses of weak_handle. (#19408) 2025-07-08 06:45:40 +00:00
bevy_app Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_asset Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_audio remove unused dependencies (#19998) 2025-07-07 20:10:33 +00:00
bevy_camera Add doc examples to viewport_to_world(_2d) (#20096) 2025-07-14 21:24:28 +00:00
bevy_color Ugrade to wgpu version 25.0 (#19563) 2025-06-26 19:41:47 +00:00
bevy_core_pipeline Use RenderStartup for all basic cases in bevy_core_pipeline. (#20002) 2025-07-15 07:10:43 +00:00
bevy_core_widgets Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_derive Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_dev_tools Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_diagnostic Add max_history_length to EntityCountDiagnosticsPlugin (#20085) 2025-07-12 23:00:38 +00:00
bevy_dylib Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_ecs Change event to event_key where it refers to an EventKey (#20060) 2025-07-16 18:19:30 +00:00
bevy_encase_derive Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_feathers Rename the InterpolationColorSpace variants to match Color. (#20142) 2025-07-14 22:30:43 +00:00
bevy_gilrs remove unused dependencies (#19998) 2025-07-07 20:10:33 +00:00
bevy_gizmos Use RenderStartup in bevy_sprite. (#20147) 2025-07-15 06:30:34 +00:00
bevy_gltf Fix glTF light orientation (#20122) 2025-07-14 13:20:18 +00:00
bevy_image Add zstd release note (#20053) 2025-07-14 20:53:26 +00:00
bevy_input Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_input_focus Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_internal make optional crates for mesh, camera, and light (#19997) 2025-07-07 07:35:32 +00:00
bevy_light Allow NotShadowCaster to be used with HierarchyPropagatePlugin. (#20120) 2025-07-14 21:55:12 +00:00
bevy_log Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
bevy_macro_utils Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_math Rhombus sampling (#20082) 2025-07-14 21:05:42 +00:00
bevy_mesh Add angle-weighted smooth normals implementation (#18383) (#18552) 2025-07-17 19:23:30 +00:00
bevy_mikktspace Bump Version after Release (#19774) 2025-06-22 23:06:43 +00:00
bevy_pbr Fix AmbientLight::affects_lightmapped_meshes not working (#20083) 2025-07-14 21:13:10 +00:00
bevy_picking Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_platform bevy_platform: clippy without default features (#19860) 2025-06-29 17:12:57 +00:00
bevy_ptr Add newlines before impl blocks (#19746) 2025-06-22 23:07:02 +00:00
bevy_reflect Streamline GetOwnership/FromArg/IntoReturn (#20126) 2025-07-14 21:57:34 +00:00
bevy_remote formatting fix in bevy_remote cargo.toml (#20033) 2025-07-08 17:02:02 +00:00
bevy_render Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_scene Remove the need to derive Event when deriving EntityEvent (#20104) 2025-07-15 16:45:38 +00:00
bevy_solari Fix link to bevy_solari logo (#20097) 2025-07-14 21:25:44 +00:00
bevy_sprite Use RenderStartup in bevy_sprite. (#20147) 2025-07-15 06:30:34 +00:00
bevy_state Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_tasks Update derive_more requirement from 1 to 2 (#19671) 2025-06-24 11:13:04 +00:00
bevy_text Text2d bounding box fix (#20148) 2025-07-15 17:14:49 +00:00
bevy_time Added finish method for timer (#20154) 2025-07-15 22:57:57 +00:00
bevy_transform Add EntityWorldMut::(try_)resource_scope (#20162) 2025-07-16 17:37:25 +00:00
bevy_ui Improved UI scrolling support and bug fixes (#20093) 2025-07-15 17:33:04 +00:00
bevy_ui_render Preconvert colors before sending to shader (#20074) 2025-07-16 16:06:45 +00:00
bevy_utils Make Parallel<T> more T: !Default accessible (#17943) 2025-07-07 20:22:20 +00:00
bevy_window Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00
bevy_winit Split BufferedEvent from Event (#20101) 2025-07-14 21:31:48 +00:00