5e63435e749ab2cba3ebaf1a1af04848e63d15f2
Currently each sculpt BVH node stores the indices of its triangles. It also stores triangles of vertex indices local to the node, and also potentially the indices of the face corners in the node. The problem with this is that the leaf nodes store plenty of redundant information. The triangles in each face aren't split up between multiple nodes, so storing triangle instead of face indices is unnecesssary. For the local vertex triangles, there is also duplicate information-- twice the number of indices as necessary for quad meshes. We also often need a node's faces, which is currently done with a triangle to face map using 4 bytes per triangle. This "double storage" results in extra processing too. For example, during BVH builds we need to combine twice the number of "Bounds" objects for a quad mesh. And we have to recalculate a node's face indices every time we want them. This commit replaces the PBVH triangle indices with face indices, and replaces the local vertex triangles array by using a `VectorSet` to store each node's vertex indices. This results in significant performance and memory usage improvements. | | Before | After | Improvement | | ----------------- | -------- | -------- | ----------- | | BVH build time | 1.29 s | 0.552 s | 2.3x | | Brush stroke time | 3.57 s | 2.52 s | 1.4x | | Memory usage | 4.14 GiB | 3.66 GiB | 1.3x | All testing is done with a 16 million vertex grid and a Ryzen 7950x. My guess is that the brush stroke time is improved by the added sorting of node vertex indices, and by the overall increase in memory bandwidth availability for mesh data. Personally I'm pleasantly surprised by the whole improvement, since I usually try to avoid hash table data structures for this sort of use case. But a lookup into this set ends up just being a boolean and with an array lookup, so it's quite cheap. Pull Request: https://projects.blender.org/blender/blender/pulls/127162
…
Blender
Blender is the free and open source 3D creation suite. It supports the entirety of the 3D pipeline-modeling, rigging, animation, simulation, rendering, compositing, motion tracking and video editing.
Project Pages
Development
License
Blender as a whole is licensed under the GNU General Public License, Version 3. Individual files may have a different, but compatible license.
See blender.org/about/license for details.
Description
Languages
C++
78%
Python
14.9%
C
2.9%
GLSL
1.9%
CMake
1.2%
Other
0.9%
