*Made nearest surface also use "quad" bvh tree (instead of splitting quads in 2 bvh nodes).
Again that leaded to improvements in build and query time.
*BLI_bvhtree_find_nearest api is now following the same concept as BLI_bvhtree_ray_cast
removed code relative to bvhtree_from_mesh_tris.
Its now faster than raytree (both on build and query)
Things tryed:
X=>Y=>Z=>X split (reduces build time.. but increases query time)
bucket sorts
(initial sorts for fast usage of bucket take a long time)
(nth is linear.. so its quite fast already)
Best times archieve with:
*usage of 4-ary trees.. reduces build time and tree size but didnt decreased query time
*quads are on the same node instead of splitting in 2 tris..
(this actually turned on speedup on query time.. since tree size is reduced by a factor of 2)
*test ray-bb before ray-primitive gives better times on both tris and quads
Notes:
measures where made projecting a sphere from inside the head of suzanne.
small bvh fixes:
*allow to create any tree type >= 2
*save split axis
changed shrinkwrap to perform normal cast with raytree and bvh tree and print both times:
Shrinkwrap (OBCube)24578 over (OBSuzanne)504482
target = raytree_create_from_mesh(calc->target): 1260.000000ms
shrinkwrap_calc_normal_projection_raytree(&calc): 1850.000000ms
tree = bvhtree_from_mesh_tri(calc->target): 3330.000000ms
shrinkwrap_calc_normal_projection(&calc): 3780.000000ms
On general query time is bit smaller on bvh tree..
but the build time of bvh is pretty big.
(build time can be removed from both if a cache system is added)
But I am still trying to see how fast I can make the bvh build
*Fixed a few UI things
*Make SimpleDeform and Shrinkwrap to use vertexgroup_get_vertex_weight, a similar function
"static float vert_weight(MDeformVert *dvert, int group)" existed on modifier.c, changed
it a bit and moved into BKE_deform.h
Changed code to remove faces (now quad faces that got one vertice projected are turned on tri)
Merge option is still not very usefull since shrinkwrap does not yet moves unprojected vertices
I'll work on making it more generic.
So far it querys faster than kdtree, but building the tree is slower.
And bvhtree NN uses an heuristic based on the last match.
Shrinkwrap (OBCube)24578 over (OBSuzanne)31658
kdtree
build: 30.000000ms
query: 1360.000000ms
bvhtree
build: 140.000000ms
query: 490.000000ms
Shrinkwrap now uses bvhtree (binary tree, 6dop) for nearest vertex.
+added option to remove faces where all vertices got unprojected
Nearest surface point
+15% faster closest point on point-tri function
(archived by projecting the point on tri-plane and solving the problem on 2D)
(its still using bruteforce on triangles.. I'll add the right data structure later)
+control for normal projection direction (default,inverted,both)
There are some bugs on projection over quads.. it seems to work 100% on fully triangulized meshs
+ Nearest surface point
+ Normal projection
+ Nearest vertex (gives similar results to nearest surface if the target mesh has many vertexs and is a lot faster to calculate)
^^ all bruteforce calculation for now
+ fixed matrix order multiplication
+ request for CD_MDEDEFORMVERT
+vertex weights supported
+target object now saves to file: load/save works :)
for now simple moves objects vertexs to the nearest vertexs on target object
(so that I can test if its working correctly with the modifier API)