Page MenuHome

Sculpt: Add face iterators to the PBVH
Needs ReviewPublic

Authored by Pablo Dobarro (pablodp606) on Thu, Mar 5, 9:25 PM.



This patch adds a face iterator to iterate over all faces in a node. For
this, faces need to be stored in leaf nodes when building the tree.

This iterator can be used to multithread Face Sets operations that need
to loop over all nodes (I implemented invert here as an example even it
is not a critical point for performance), but it will be used to
optimize undo and write faster box/lasso hide operations. It will also
simplify adding multires compatibility as the loop will only need to be
implemented once in the macro.

For building the tree I added an array to keep track if a face was added
to a leaf node to avoid adding faces witch a triangle on different nodes
to two nodes at the same time. I'm not sure how this will affect
multithreading the PBVH in the future.

Diff Detail

rB Blender
pbvh-mt-faces (branched from master)
Build Status
Buildable 6975
Build 6975: arc lint + arc unit

Event Timeline

This will increase sculpt memory usage. Is there really no other way to do this?

The BVH seems to be created from loop triangles. Two possible solutions I can think of (without checking how practical it is):

  • Build the BVH out of polygons instead of loop triangles, reducing memory usage a bit compared to what we have now.
  • Find some way to determine if a loop triangle is the first triangle of a polygon, and skip all the other ones when iterating.