Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/bvhutils.c
| Show First 20 Lines • Show All 711 Lines • ▼ Show 20 Lines | if (in_cache == false) { | ||||
| tree = bvhtree_from_mesh_verts_create_tree( | tree = bvhtree_from_mesh_verts_create_tree( | ||||
| epsilon, tree_type, axis, vert, verts_num, verts_mask, verts_num_active); | epsilon, tree_type, axis, vert, verts_num, verts_mask, verts_num_active); | ||||
| if (bvh_cache_p) { | if (bvh_cache_p) { | ||||
| /* Save on cache for later use */ | /* Save on cache for later use */ | ||||
| /* printf("BVHTree built and saved on cache\n"); */ | /* printf("BVHTree built and saved on cache\n"); */ | ||||
| BVHCache *bvh_cache = *bvh_cache_p; | BVHCache *bvh_cache = *bvh_cache_p; | ||||
| bvhcache_insert(bvh_cache, tree, bvh_cache_type); | bvhcache_insert(bvh_cache, tree, bvh_cache_type); | ||||
| bvhcache_unlock(bvh_cache, lock_started); | |||||
| in_cache = true; | in_cache = true; | ||||
| } | } | ||||
| } | } | ||||
| if (bvh_cache_p) { | |||||
| bvhcache_unlock(*bvh_cache_p, lock_started); | |||||
| } | |||||
| /* Setup BVHTreeFromMesh */ | /* Setup BVHTreeFromMesh */ | ||||
| bvhtree_from_mesh_verts_setup_data(data, tree, in_cache, vert, vert_allocated); | bvhtree_from_mesh_verts_setup_data(data, tree, in_cache, vert, vert_allocated); | ||||
| return tree; | return tree; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| ▲ Show 20 Lines • Show All 191 Lines • ▼ Show 20 Lines | if (in_cache == false) { | ||||
| tree = bvhtree_from_mesh_edges_create_tree( | tree = bvhtree_from_mesh_edges_create_tree( | ||||
| vert, edge, edges_num, edges_mask, edges_num_active, epsilon, tree_type, axis); | vert, edge, edges_num, edges_mask, edges_num_active, epsilon, tree_type, axis); | ||||
| if (bvh_cache_p) { | if (bvh_cache_p) { | ||||
| BVHCache *bvh_cache = *bvh_cache_p; | BVHCache *bvh_cache = *bvh_cache_p; | ||||
| /* Save on cache for later use */ | /* Save on cache for later use */ | ||||
| /* printf("BVHTree built and saved on cache\n"); */ | /* printf("BVHTree built and saved on cache\n"); */ | ||||
| bvhcache_insert(bvh_cache, tree, bvh_cache_type); | bvhcache_insert(bvh_cache, tree, bvh_cache_type); | ||||
| bvhcache_unlock(bvh_cache, lock_started); | |||||
| in_cache = true; | in_cache = true; | ||||
| } | } | ||||
| } | } | ||||
| if (bvh_cache_p) { | |||||
| bvhcache_unlock(*bvh_cache_p, lock_started); | |||||
| } | |||||
| /* Setup BVHTreeFromMesh */ | /* Setup BVHTreeFromMesh */ | ||||
| bvhtree_from_mesh_edges_setup_data( | bvhtree_from_mesh_edges_setup_data( | ||||
| data, tree, in_cache, vert, vert_allocated, edge, edge_allocated); | data, tree, in_cache, vert, vert_allocated, edge, edge_allocated); | ||||
| return tree; | return tree; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| ▲ Show 20 Lines • Show All 108 Lines • ▼ Show 20 Lines | if (in_cache == false) { | ||||
| tree = bvhtree_from_mesh_faces_create_tree( | tree = bvhtree_from_mesh_faces_create_tree( | ||||
| epsilon, tree_type, axis, vert, face, numFaces, faces_mask, faces_num_active); | epsilon, tree_type, axis, vert, face, numFaces, faces_mask, faces_num_active); | ||||
| if (bvh_cache_p) { | if (bvh_cache_p) { | ||||
| /* Save on cache for later use */ | /* Save on cache for later use */ | ||||
| /* printf("BVHTree built and saved on cache\n"); */ | /* printf("BVHTree built and saved on cache\n"); */ | ||||
| BVHCache *bvh_cache = *bvh_cache_p; | BVHCache *bvh_cache = *bvh_cache_p; | ||||
| bvhcache_insert(bvh_cache, tree, bvh_cache_type); | bvhcache_insert(bvh_cache, tree, bvh_cache_type); | ||||
| bvhcache_unlock(bvh_cache, lock_started); | |||||
| in_cache = true; | in_cache = true; | ||||
| } | } | ||||
| } | } | ||||
| if (bvh_cache_p) { | |||||
| bvhcache_unlock(*bvh_cache_p, lock_started); | |||||
| } | |||||
| /* Setup BVHTreeFromMesh */ | /* Setup BVHTreeFromMesh */ | ||||
| bvhtree_from_mesh_faces_setup_data( | bvhtree_from_mesh_faces_setup_data( | ||||
| data, tree, in_cache, vert, vert_allocated, face, face_allocated); | data, tree, in_cache, vert, vert_allocated, face, face_allocated); | ||||
| return tree; | return tree; | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| ▲ Show 20 Lines • Show All 219 Lines • ▼ Show 20 Lines | tree = bvhtree_from_mesh_looptri_create_tree(epsilon, | ||||
| looptri, | looptri, | ||||
| looptri_num, | looptri_num, | ||||
| looptri_mask, | looptri_mask, | ||||
| looptri_num_active); | looptri_num_active); | ||||
| if (bvh_cache_p) { | if (bvh_cache_p) { | ||||
| BVHCache *bvh_cache = *bvh_cache_p; | BVHCache *bvh_cache = *bvh_cache_p; | ||||
| bvhcache_insert(bvh_cache, tree, bvh_cache_type); | bvhcache_insert(bvh_cache, tree, bvh_cache_type); | ||||
| bvhcache_unlock(bvh_cache, lock_started); | |||||
| in_cache = true; | in_cache = true; | ||||
| } | } | ||||
| } | } | ||||
| if (bvh_cache_p) { | |||||
| bvhcache_unlock(*bvh_cache_p, lock_started); | |||||
| } | |||||
| /* Setup BVHTreeFromMesh */ | /* Setup BVHTreeFromMesh */ | ||||
| bvhtree_from_mesh_looptri_setup_data(data, | bvhtree_from_mesh_looptri_setup_data(data, | ||||
| tree, | tree, | ||||
| in_cache, | in_cache, | ||||
| vert, | vert, | ||||
| vert_allocated, | vert_allocated, | ||||
| mloop, | mloop, | ||||
| loop_allocated, | loop_allocated, | ||||
| ▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | case BVHTREE_FROM_LOOSEVERTS: | ||||
| int loose_vert_len = -1; | int loose_vert_len = -1; | ||||
| int verts_len = mesh->totvert; | int verts_len = mesh->totvert; | ||||
| if (bvh_cache_type == BVHTREE_FROM_LOOSEVERTS) { | if (bvh_cache_type == BVHTREE_FROM_LOOSEVERTS) { | ||||
| loose_verts_mask = loose_verts_map_get( | loose_verts_mask = loose_verts_map_get( | ||||
| mesh->medge, mesh->totedge, mesh->mvert, verts_len, &loose_vert_len); | mesh->medge, mesh->totedge, mesh->mvert, verts_len, &loose_vert_len); | ||||
| } | } | ||||
| /* TODO: a global mutex lock held during the expensive operation of | |||||
| * building the BVH tree is really bad for performance. */ | |||||
| tree = bvhtree_from_mesh_verts_ex(data, | tree = bvhtree_from_mesh_verts_ex(data, | ||||
| mesh->mvert, | mesh->mvert, | ||||
| verts_len, | verts_len, | ||||
| false, | false, | ||||
| loose_verts_mask, | loose_verts_mask, | ||||
| loose_vert_len, | loose_vert_len, | ||||
| 0.0f, | 0.0f, | ||||
| tree_type, | tree_type, | ||||
| ▲ Show 20 Lines • Show All 271 Lines • Show Last 20 Lines | |||||