Skip to content

Commit 787ed35

Browse files
committed
Update migration guide
1 parent c91d685 commit 787ed35

File tree

1 file changed

+27
-9
lines changed

1 file changed

+27
-9
lines changed

release-content/migration-guides/mesh_compute_smooth_normals.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,45 @@ title: Smooth normals implementation changed
33
pull_requests: [18552]
44
---
55

6-
In Bevy 0.16, `Mesh` smooth normal calculation used a face area-weighted
7-
algorithm. In 0.17, the area-weighted method was moved to separate methods,
6+
In Bevy 0.16, `Mesh` smooth normal calculation used a triangle area-weighted
7+
algorithm. In 0.17, the area-weighted algorithm was moved to separate methods,
88
the default implementation was switched to a corner angle-weighted algorithm,
99
and `Mesh::compute_custom_smooth_normals` was added for other cases.
1010

1111
The angle-weighted method is more suitable for growing or shrinking a mesh along
12-
its vertex normals, such as for generating an outline mesh. It also results in
13-
more expected lighting behavior in many cases. In most cases, the difference
12+
its vertex normals, such as when generating an outline mesh. It also results in
13+
more expected lighting behavior for some meshes. In most cases, the difference
1414
will be small and no change is needed. However, the new default is somewhat
1515
slower, and does not always produce the result desired by an artist. If you
16-
preferred the lighting in 0.16, have a significant performance regression,
17-
or needed face-weighted normals for any other reason, you can switch to the
18-
new dedicated face-weighted methods.
16+
preferred the lighting in 0.16, or have a significant performance regression,
17+
or needed area-weighted normals for any other reason, you can switch to the
18+
new dedicated area-weighted methods.
1919

2020
```diff
2121
// Only if the new smooth normals algorithm is unsatisfactory:
2222

2323
let mut mesh = Mesh::new(PrimitiveTopology::TriangleList, default())
24+
.with_inserted_attribute(Mesh::ATTRIBUTE_POSITION, positions)
2425
- .with_computed_smooth_normals();
25-
+ .with_computed_face_weighted_normals;
26+
+ .with_computed_area_weighted_normals;
2627

2728
- mesh.compute_smooth_normals();
28-
+ mesh.compute_face_weighted_normals;
29+
+ mesh.compute_area_weighted_normals();
30+
```
31+
32+
As part of this change, the helper functions `face_normal` and
33+
`face_area_normal`, were renamed to `triangle_normal` and `triangle_area_normal`
34+
respectively to better reflect the fact that they do not take an entire
35+
geometric face into account.
36+
37+
```diff
38+
- use bevy::render::mesh::face_normal;
39+
- let normal = face_normal(a, b, c);
40+
+ use bevy::render::mesh::triangle_normal;
41+
+ let normal = triangle_normal(a, b, c);
42+
43+
- use bevy::render::mesh::face_area_normal;
44+
- let normal = face_area_normal(a, b, c);
45+
+ use bevy::render::mesh::triangle_area_normal;
46+
+ let normal = triangle_area_normal(a, b, c);
2947
```

0 commit comments

Comments
 (0)