Fix #107123: Refactor sculpt normal calculation to require vert poly map #107458

Merged
Joseph Eagar merged 6 commits from HooglyBoogly/blender:pbvh-faces-normals-fix-alternate into main 2023-05-09 22:36:37 +02:00
1 changed files with 4 additions and 3 deletions
Showing only changes of commit 08acc45f93 - Show all commits

View File

@ -1420,9 +1420,10 @@ static void pbvh_faces_update_normals(PBVH *pbvh, Span<PBVHNode *> nodes)
for (const int poly : polys_to_update) {

We can't afford to iterate over all the verts of the mesh here. It's better to build a list of verts to update from the PBVH nodes.

We can't afford to iterate over all the verts of the mesh here. It's better to build a list of verts to update from the PBVH nodes.

The list doesn't have to be unique btw, there's no point going through the effort to eliminate duplicates.

The list doesn't have to be unique btw, there's no point going through the effort to eliminate duplicates.

Well, since a face usually has four corners, not de-duplicating will mean we have to do 4x the calculations, for both vertices and faces. I didn't benchmark it yet, but I'll bet using VectorSet to de-duplicate is worth it here.

Well, since a face usually has four corners, not de-duplicating will mean we have to do 4x the calculations, for both vertices and faces. I didn't benchmark it yet, but I'll bet using `VectorSet` to de-duplicate is worth it here.

Hrm, you might be right.

Hrm, you might be right.
verts_to_update.add_multiple(corner_verts.slice(polys[poly]));
}
},
[&]() {
update_tags.fill(false);
for (const int vert : verts_to_update) {
update_tags[vert] = false;

Use verts_to_update or the node unique verts to clear the update tags.

Use `verts_to_update` or the node unique verts to clear the update tags.
}
for (PBVHNode *node : nodes) {
node->flag &= ~PBVH_UpdateNormals;
}