Blender  V3.3
Classes
bvhutils.cc File Reference
#include <cmath>
#include <cstdio>
#include <cstring>
#include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h"
#include "DNA_pointcloud_types.h"
#include "BLI_linklist.h"
#include "BLI_math.h"
#include "BLI_task.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "BKE_attribute.hh"
#include "BKE_bvhutils.h"
#include "BKE_editmesh.h"
#include "BKE_mesh.h"
#include "BKE_mesh_runtime.h"
#include "MEM_guardedalloc.h"

Go to the source code of this file.

Classes

struct  BVHCacheItem
 
struct  BVHCache
 

Functions

BVHCache
static bool bvhcache_find (BVHCache **bvh_cache_p, BVHCacheType type, BVHTree **r_tree, bool *r_locked, ThreadMutex *mesh_eval_mutex)
 
static void bvhcache_unlock (BVHCache *bvh_cache, bool lock_started)
 
bool bvhcache_has_tree (const BVHCache *bvh_cache, const BVHTree *tree)
 
BVHCache * bvhcache_init ()
 
static void bvhcache_insert (BVHCache *bvh_cache, BVHTree *tree, BVHCacheType type)
 
void bvhcache_free (BVHCache *bvh_cache)
 
static void bvhtree_balance_isolated (void *userdata)
 
static void bvhtree_balance (BVHTree *tree, const bool isolate)
 
Local Callbacks
float bvhtree_ray_tri_intersection (const BVHTreeRay *ray, const float UNUSED(m_dist), const float v0[3], const float v1[3], const float v2[3])
 
float bvhtree_sphereray_tri_intersection (const BVHTreeRay *ray, float radius, const float m_dist, const float v0[3], const float v1[3], const float v2[3])
 
static void mesh_faces_nearest_point (void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
 
static void mesh_looptri_nearest_point (void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
 
static void editmesh_looptri_nearest_point (void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
 
static void mesh_faces_spherecast (void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
 
static void mesh_looptri_spherecast (void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
 
static void editmesh_looptri_spherecast (void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
 
static void mesh_edges_nearest_point (void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
 
static void mesh_verts_spherecast_do (int index, const float v[3], const BVHTreeRay *ray, BVHTreeRayHit *hit)
 
static void editmesh_verts_spherecast (void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
 
static void mesh_verts_spherecast (void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
 
static void mesh_edges_spherecast (void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
 
Common Utils
static void bvhtree_from_mesh_setup_data (BVHTree *tree, const BVHCacheType bvh_cache_type, const MVert *vert, const MEdge *edge, const MFace *face, const MLoop *loop, const MLoopTri *looptri, const float(*vert_normals)[3], BVHTreeFromMesh *r_data)
 
static void bvhtree_from_editmesh_setup_data (BVHTree *tree, const BVHCacheType bvh_cache_type, struct BMEditMesh *em, BVHTreeFromEditMesh *r_data)
 
Vertex Builder
static BVHTree * bvhtree_from_editmesh_verts_create_tree (float epsilon, int tree_type, int axis, BMEditMesh *em, const BLI_bitmap *verts_mask, int verts_num_active)
 
static BVHTree * bvhtree_from_mesh_verts_create_tree (float epsilon, int tree_type, int axis, const MVert *vert, const int verts_num, const BLI_bitmap *verts_mask, int verts_num_active)
 
BVHTree * bvhtree_from_editmesh_verts_ex (BVHTreeFromEditMesh *data, BMEditMesh *em, const BLI_bitmap *verts_mask, int verts_num_active, float epsilon, int tree_type, int axis)
 
BVHTree * bvhtree_from_editmesh_verts (BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis)
 
BVHTree * bvhtree_from_mesh_verts_ex (BVHTreeFromMesh *data, const MVert *vert, const int verts_num, const BLI_bitmap *verts_mask, int verts_num_active, float epsilon, int tree_type, int axis)
 
Edge Builder
static BVHTree * bvhtree_from_editmesh_edges_create_tree (float epsilon, int tree_type, int axis, BMEditMesh *em, const BLI_bitmap *edges_mask, int edges_num_active)
 
static BVHTree * bvhtree_from_mesh_edges_create_tree (const MVert *vert, const MEdge *edge, const int edge_num, const BLI_bitmap *edges_mask, int edges_num_active, float epsilon, int tree_type, int axis)
 
BVHTree * bvhtree_from_editmesh_edges_ex (BVHTreeFromEditMesh *data, BMEditMesh *em, const BLI_bitmap *edges_mask, int edges_num_active, float epsilon, int tree_type, int axis)
 
BVHTree * bvhtree_from_editmesh_edges (BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis)
 
BVHTree * bvhtree_from_mesh_edges_ex (BVHTreeFromMesh *data, const MVert *vert, const MEdge *edge, const int edges_num, const BLI_bitmap *edges_mask, int edges_num_active, float epsilon, int tree_type, int axis)
 
Tessellated Face Builder
static BVHTree * bvhtree_from_mesh_faces_create_tree (float epsilon, int tree_type, int axis, const MVert *vert, const MFace *face, const int faces_num, const BLI_bitmap *faces_mask, int faces_num_active)
 
LoopTri Face Builder
static BVHTree * bvhtree_from_editmesh_looptri_create_tree (float epsilon, int tree_type, int axis, BMEditMesh *em, const BLI_bitmap *looptri_mask, int looptri_num_active)
 
static BVHTree * bvhtree_from_mesh_looptri_create_tree (float epsilon, int tree_type, int axis, const MVert *vert, const MLoop *mloop, const MLoopTri *looptri, const int looptri_num, const BLI_bitmap *looptri_mask, int looptri_num_active)
 
BVHTree * bvhtree_from_editmesh_looptri_ex (BVHTreeFromEditMesh *data, BMEditMesh *em, const BLI_bitmap *looptri_mask, int looptri_num_active, float epsilon, int tree_type, int axis)
 
BVHTree * bvhtree_from_editmesh_looptri (BVHTreeFromEditMesh *data, BMEditMesh *em, float epsilon, int tree_type, int axis)
 
BVHTree * bvhtree_from_mesh_looptri_ex (BVHTreeFromMesh *data, const struct MVert *vert, const struct MLoop *mloop, const struct MLoopTri *looptri, const int looptri_num, const BLI_bitmap *looptri_mask, int looptri_num_active, float epsilon, int tree_type, int axis)
 
static BLI_bitmap * loose_verts_map_get (const MEdge *medge, int edges_num, const MVert *UNUSED(mvert), int verts_num, int *r_loose_vert_num)
 
static BLI_bitmap * loose_edges_map_get (const MEdge *medge, const int edges_len, int *r_loose_edge_len)
 
static BLI_bitmap * looptri_no_hidden_map_get (const MPoly *mpoly, const int looptri_len, int *r_looptri_active_len)
 
BVHTree * BKE_bvhtree_from_mesh_get (struct BVHTreeFromMesh *data, const struct Mesh *mesh, const BVHCacheType bvh_cache_type, const int tree_type)
 
BVHTree * BKE_bvhtree_from_editmesh_get (BVHTreeFromEditMesh *data, struct BMEditMesh *em, const int tree_type, const BVHCacheType bvh_cache_type, BVHCache **bvh_cache_p, ThreadMutex *mesh_eval_mutex)
 
Free Functions
void free_bvhtree_from_editmesh (struct BVHTreeFromEditMesh *data)
 
void free_bvhtree_from_mesh (struct BVHTreeFromMesh *data)
 
Point Cloud BVH Building
BVHTree * BKE_bvhtree_from_pointcloud_get (BVHTreeFromPointCloud *data, const PointCloud *pointcloud, const int tree_type)
 
void free_bvhtree_from_pointcloud (BVHTreeFromPointCloud *data)
 

Function Documentation

◆ BKE_bvhtree_from_editmesh_get()

BVHTree* BKE_bvhtree_from_editmesh_get ( BVHTreeFromEditMesh *  data,
struct BMEditMesh *  em,
int  tree_type,
BVHCacheType  bvh_cache_type,
struct BVHCache **  bvh_cache_p,
ThreadMutex *  mesh_eval_mutex 
)

◆ BKE_bvhtree_from_mesh_get()

BVHTree* BKE_bvhtree_from_mesh_get ( struct BVHTreeFromMesh *  data,
const struct Mesh *  mesh,
BVHCacheType  bvh_cache_type,
int  tree_type 
)

Builds or queries a BVH-cache for the cache BVH-tree of the request type.

Note
This function only fills a cache, and therefore the mesh argument can be considered logically const. Concurrent access is protected by a mutex.

Definition at line 1213 of file bvhutils.cc.

References ATTR_FALLTHROUGH, BKE_mesh_runtime_looptri_ensure(), BKE_mesh_runtime_looptri_len(), BKE_mesh_vertex_normals_ensure(), BLI_assert, BLI_bvhtree_get_tree_type(), Mesh_Runtime::bvh_cache, bvhcache_find(), bvhcache_insert(), bvhcache_unlock(), bvhtree_balance(), BVHTREE_FROM_EDGES, BVHTREE_FROM_EM_EDGES, BVHTREE_FROM_EM_LOOPTRI, BVHTREE_FROM_EM_VERTS, BVHTREE_FROM_FACES, BVHTREE_FROM_LOOPTRI, BVHTREE_FROM_LOOPTRI_NO_HIDDEN, BVHTREE_FROM_LOOSEEDGES, BVHTREE_FROM_LOOSEVERTS, bvhtree_from_mesh_edges_create_tree(), bvhtree_from_mesh_faces_create_tree(), bvhtree_from_mesh_looptri_create_tree(), bvhtree_from_mesh_setup_data(), bvhtree_from_mesh_verts_create_tree(), BVHTREE_FROM_VERTS, BVHTREE_MAX_ITEM, data, ELEM, Mesh_Runtime::eval_mutex, looptri_no_hidden_map_get(), loose_edges_map_get(), loose_verts_map_get(), mask(), Mesh::medge, MEM_freeN, mesh, Mesh::mface, Mesh::mloop, Mesh::mpoly, Mesh::mvert, Mesh::runtime, Mesh::totedge, Mesh::totface, Mesh::totpoly, and Mesh::totvert.

Referenced by BKE_mesh_remap_calc_difference_from_mesh(), BKE_mesh_remap_calc_edges_from_mesh(), BKE_mesh_remap_calc_loops_from_mesh(), BKE_mesh_remap_calc_polys_from_mesh(), BKE_mesh_remap_calc_verts_from_mesh(), BKE_mesh_remesh_reproject_paint_mask(), BKE_remesh_reproject_sculpt_face_sets(), BKE_remesh_reproject_vertex_paint(), BKE_shrinkwrap_init_tree(), blender::nodes::node_geo_proximity_cc::calculate_mesh_proximity(), cloth_build_springs(), deformVerts(), dynamicPaint_paintMesh(), blender::ed::sculpt_paint::AddOperationExecutor::execute(), blender::ed::sculpt_paint::DensityAddOperationExecutor::execute(), blender::ed::sculpt_paint::DensitySubtractOperationExecutor::execute(), blender::ed::sculpt_paint::PuffOperationExecutor::execute(), blender::ed::sculpt_paint::SlideOperationExecutor::execute(), followtrack_project_to_depth_object_if_needed(), blender::nodes::node_geo_transfer_attribute_cc::get_closest_mesh_edges(), blender::nodes::node_geo_transfer_attribute_cc::get_closest_mesh_looptris(), blender::nodes::node_geo_transfer_attribute_cc::get_closest_mesh_points(), get_vert2geom_distance(), harmonic_coordinates_bind(), blender::ed::sculpt_paint::min_distance_edit::min_distance_edit_invoke(), PE_create_shape_tree(), blender::nodes::node_geo_raycast_cc::raycast_to_mesh(), RE_bake_pixels_populate_from_objects(), remap_hair_emitter(), blender::ed::sculpt_paint::sample_curves_3d_brush(), blender::ed::curves::snap_curves_to_surface::snap_curves_to_surface_exec_object(), snap_object_data_mesh_get(), snapMesh(), blender::draw::statvis_calc_intersect(), blender::draw::statvis_calc_thickness(), surfacedeformBind(), blender::ed::curves::convert_to_particle_system::try_convert_single_object(), and blender::ed::sculpt_paint::use_add_density_mode().

◆ BKE_bvhtree_from_pointcloud_get()

BVHTree* BKE_bvhtree_from_pointcloud_get ( BVHTreeFromPointCloud *  data,
const PointCloud *  pointcloud,
const int  tree_type 
)

◆ bvhcache_find()

static bool bvhcache_find ( BVHCache **  bvh_cache_p,
BVHCacheType  type,
BVHTree **  r_tree,
bool *  r_locked,
ThreadMutex *  mesh_eval_mutex 
)
static

Queries a bvhcache for the cache bvhtree of the request type

When the r_locked is filled and the tree could not be found the caches mutex will be locked. This mutex can be unlocked by calling bvhcache_unlock.

When r_locked is used the mesh_eval_mutex must contain the Mesh_Runtime.eval_mutex.

Definition at line 52 of file bvhutils.cc.

References BLI_mutex_lock(), BLI_mutex_unlock(), bvhcache_init(), BVHCacheItem::is_filled, BVHCache::items, BVHCache::mutex, BVHCacheItem::tree, and type.

Referenced by BKE_bvhtree_from_editmesh_get(), and BKE_bvhtree_from_mesh_get().

◆ bvhcache_free()

void bvhcache_free ( struct BVHCache *  bvh_cache)

◆ bvhcache_has_tree()

bool bvhcache_has_tree ( const BVHCache *  bvh_cache,
const BVHTree *  tree 
)

Definition at line 99 of file bvhutils.cc.

References BVHTREE_MAX_ITEM, BVHCache::items, BVHCacheItem::tree, and tree.

◆ bvhcache_init()

BVHCache* bvhcache_init ( void  )

Definition at line 113 of file bvhutils.cc.

References BLI_mutex_init(), and BVHCache::mutex.

Referenced by bvhcache_find().

◆ bvhcache_insert()

static void bvhcache_insert ( BVHCache *  bvh_cache,
BVHTree *  tree,
BVHCacheType  type 
)
static

Inserts a BVHTree of the given type under the cache After that the caller no longer needs to worry when to free the BVHTree as that will be done when the cache is freed.

A call to this assumes that there was no previous cached tree of the given type

Warning
The BVHTree can be nullptr.

Definition at line 127 of file bvhutils.cc.

References BLI_assert, BVHCacheItem::is_filled, BVHCache::items, BVHCacheItem::tree, tree, and type.

Referenced by BKE_bvhtree_from_editmesh_get(), and BKE_bvhtree_from_mesh_get().

◆ bvhcache_unlock()

static void bvhcache_unlock ( BVHCache *  bvh_cache,
bool  lock_started 
)
static

Definition at line 92 of file bvhutils.cc.

References BLI_mutex_unlock(), and BVHCache::mutex.

Referenced by BKE_bvhtree_from_editmesh_get(), and BKE_bvhtree_from_mesh_get().

◆ bvhtree_balance()

static void bvhtree_balance ( BVHTree *  tree,
const bool  isolate 
)
static

◆ bvhtree_balance_isolated()

static void bvhtree_balance_isolated ( void *  userdata)
static

BVH-tree balancing inside a mutex lock must be run in isolation. Balancing is multithreaded, and we do not want the current thread to start another task that may involve acquiring the same mutex lock that it is waiting for.

Definition at line 151 of file bvhutils.cc.

References BLI_bvhtree_balance().

Referenced by bvhtree_balance().

◆ bvhtree_from_editmesh_edges()

BVHTree* bvhtree_from_editmesh_edges ( BVHTreeFromEditMesh *  data,
BMEditMesh *  em,
float  epsilon,
int  tree_type,
int  axis 
)

◆ bvhtree_from_editmesh_edges_create_tree()

static BVHTree* bvhtree_from_editmesh_edges_create_tree ( float  epsilon,
int  tree_type,
int  axis,
BMEditMesh *  em,
const BLI_bitmap *  edges_mask,
int  edges_num_active 
)
static

◆ bvhtree_from_editmesh_edges_ex()

BVHTree* bvhtree_from_editmesh_edges_ex ( BVHTreeFromEditMesh *  data,
struct BMEditMesh *  em,
const BLI_bitmap *  edges_mask,
int  edges_num_active,
float  epsilon,
int  tree_type,
int  axis 
)

Builds a BVH-tree where nodes are the edges of the given em.

Definition at line 866 of file bvhutils.cc.

References bvhtree_balance(), bvhtree_from_editmesh_edges_create_tree(), bvhtree_from_editmesh_setup_data(), BVHTREE_FROM_EM_EDGES, data, blender::robust_pred::epsilon, and tree.

Referenced by bvhtree_from_editmesh_edges(), and snapEditMesh().

◆ bvhtree_from_editmesh_looptri()

BVHTree* bvhtree_from_editmesh_looptri ( BVHTreeFromEditMesh *  data,
BMEditMesh *  em,
float  epsilon,
int  tree_type,
int  axis 
)

◆ bvhtree_from_editmesh_looptri_create_tree()

static BVHTree* bvhtree_from_editmesh_looptri_create_tree ( float  epsilon,
int  tree_type,
int  axis,
BMEditMesh *  em,
const BLI_bitmap *  looptri_mask,
int  looptri_num_active 
)
static

◆ bvhtree_from_editmesh_looptri_ex()

BVHTree* bvhtree_from_editmesh_looptri_ex ( BVHTreeFromEditMesh *  data,
struct BMEditMesh *  em,
const BLI_bitmap *  mask,
int  looptri_num_active,
float  epsilon,
int  tree_type,
int  axis 
)

◆ bvhtree_from_editmesh_setup_data()

static void bvhtree_from_editmesh_setup_data ( BVHTree *  tree,
const BVHCacheType  bvh_cache_type,
struct BMEditMesh *  em,
BVHTreeFromEditMesh *  r_data 
)
static

◆ bvhtree_from_editmesh_verts()

BVHTree* bvhtree_from_editmesh_verts ( BVHTreeFromEditMesh *  data,
struct BMEditMesh *  em,
float  epsilon,
int  tree_type,
int  axis 
)

Builds a BVH tree where nodes are the relevant elements of the given mesh. Configures BVHTreeFromMesh.

The tree is build in mesh space coordinates, this means special care must be made on queries so that the coordinates and rays are first translated on the mesh local coordinates. Reason for this is that bvh_from_mesh_* can use a cache in some cases and so it becomes possible to reuse a BVHTree.

free_bvhtree_from_mesh should be called when the tree is no longer needed.

Definition at line 753 of file bvhutils.cc.

References bvhtree_from_editmesh_verts_ex(), data, and blender::robust_pred::epsilon.

◆ bvhtree_from_editmesh_verts_create_tree()

static BVHTree* bvhtree_from_editmesh_verts_create_tree ( float  epsilon,
int  tree_type,
int  axis,
BMEditMesh *  em,
const BLI_bitmap *  verts_mask,
int  verts_num_active 
)
static

◆ bvhtree_from_editmesh_verts_ex()

BVHTree* bvhtree_from_editmesh_verts_ex ( BVHTreeFromEditMesh *  data,
struct BMEditMesh *  em,
const BLI_bitmap *  mask,
int  verts_num_active,
float  epsilon,
int  tree_type,
int  axis 
)

Builds a BVH-tree where nodes are the vertices of the given em.

Definition at line 732 of file bvhutils.cc.

References bvhtree_balance(), bvhtree_from_editmesh_setup_data(), bvhtree_from_editmesh_verts_create_tree(), BVHTREE_FROM_EM_VERTS, data, blender::robust_pred::epsilon, and tree.

Referenced by bvhtree_from_editmesh_verts(), and snapEditMesh().

◆ bvhtree_from_mesh_edges_create_tree()

static BVHTree* bvhtree_from_mesh_edges_create_tree ( const MVert *  vert,
const MEdge *  edge,
const int  edge_num,
const BLI_bitmap *  edges_mask,
int  edges_num_active,
float  epsilon,
int  tree_type,
int  axis 
)
static

◆ bvhtree_from_mesh_edges_ex()

BVHTree* bvhtree_from_mesh_edges_ex ( BVHTreeFromMesh *  data,
const MVert *  vert,
const MEdge *  edge,
const int  edges_num,
const BLI_bitmap *  edges_mask,
int  edges_num_active,
float  epsilon,
int  tree_type,
int  axis 
)

◆ bvhtree_from_mesh_faces_create_tree()

static BVHTree* bvhtree_from_mesh_faces_create_tree ( float  epsilon,
int  tree_type,
int  axis,
const MVert *  vert,
const MFace *  face,
const int  faces_num,
const BLI_bitmap *  faces_mask,
int  faces_num_active 
)
static

◆ bvhtree_from_mesh_looptri_create_tree()

static BVHTree* bvhtree_from_mesh_looptri_create_tree ( float  epsilon,
int  tree_type,
int  axis,
const MVert *  vert,
const MLoop *  mloop,
const MLoopTri *  looptri,
const int  looptri_num,
const BLI_bitmap *  looptri_mask,
int  looptri_num_active 
)
static

◆ bvhtree_from_mesh_looptri_ex()

BVHTree* bvhtree_from_mesh_looptri_ex ( struct BVHTreeFromMesh *  data,
const struct MVert *  vert,
const struct MLoop *  mloop,
const struct MLoopTri *  looptri,
int  looptri_num,
const BLI_bitmap *  mask,
int  looptri_num_active,
float  epsilon,
int  tree_type,
int  axis 
)

Builds a BVH-tree where nodes are the looptri faces of the given mesh.

Definition at line 1100 of file bvhutils.cc.

References bvhtree_balance(), BVHTREE_FROM_LOOPTRI, bvhtree_from_mesh_looptri_create_tree(), bvhtree_from_mesh_setup_data(), data, blender::robust_pred::epsilon, and tree.

Referenced by BKE_mesh_remap_calc_loops_from_mesh().

◆ bvhtree_from_mesh_setup_data()

static void bvhtree_from_mesh_setup_data ( BVHTree *  tree,
const BVHCacheType  bvh_cache_type,
const MVert *  vert,
const MEdge *  edge,
const MFace *  face,
const MLoop *  loop,
const MLoopTri *  looptri,
const float(*)  vert_normals[3],
BVHTreeFromMesh *  r_data 
)
static

◆ bvhtree_from_mesh_verts_create_tree()

static BVHTree* bvhtree_from_mesh_verts_create_tree ( float  epsilon,
int  tree_type,
int  axis,
const MVert *  vert,
const int  verts_num,
const BLI_bitmap *  verts_mask,
int  verts_num_active 
)
static

◆ bvhtree_from_mesh_verts_ex()

BVHTree* bvhtree_from_mesh_verts_ex ( BVHTreeFromMesh *  data,
const MVert *  vert,
const int  verts_num,
const BLI_bitmap *  verts_mask,
int  verts_num_active,
float  epsilon,
int  tree_type,
int  axis 
)

◆ bvhtree_ray_tri_intersection()

float bvhtree_ray_tri_intersection ( const BVHTreeRay *  ray,
const float   UNUSEDm_dist,
const float  v0[3],
const float  v1[3],
const float  v2[3] 
)

◆ bvhtree_sphereray_tri_intersection()

float bvhtree_sphereray_tri_intersection ( const BVHTreeRay *  ray,
float  radius,
const float  m_dist,
const float  v0[3],
const float  v1[3],
const float  v2[3] 
)

◆ editmesh_looptri_nearest_point()

static void editmesh_looptri_nearest_point ( void *  userdata,
int  index,
const float  co[3],
BVHTreeNearest *  nearest 
)
static

◆ editmesh_looptri_spherecast()

static void editmesh_looptri_spherecast ( void *  userdata,
int  index,
const BVHTreeRay *  ray,
BVHTreeRayHit *  hit 
)
static

◆ editmesh_verts_spherecast()

static void editmesh_verts_spherecast ( void *  userdata,
int  index,
const BVHTreeRay *  ray,
BVHTreeRayHit *  hit 
)
static

◆ free_bvhtree_from_editmesh()

void free_bvhtree_from_editmesh ( struct BVHTreeFromEditMesh *  data)

Frees data allocated by a call to bvhtree_from_editmesh_*.

Definition at line 1400 of file bvhutils.cc.

References BLI_bvhtree_free(), and data.

Referenced by SnapData_EditMesh::clear().

◆ free_bvhtree_from_mesh()

void free_bvhtree_from_mesh ( struct BVHTreeFromMesh *  data)

Frees data allocated by a call to bvhtree_from_mesh_*.

Definition at line 1410 of file bvhutils.cc.

References BLI_bvhtree_free(), and data.

Referenced by BKE_mesh_remap_calc_edges_from_mesh(), BKE_mesh_remap_calc_loops_from_mesh(), BKE_mesh_remap_calc_polys_from_mesh(), BKE_mesh_remap_calc_verts_from_mesh(), BKE_mesh_remesh_reproject_paint_mask(), BKE_remesh_reproject_sculpt_face_sets(), BKE_remesh_reproject_vertex_paint(), BKE_shrinkwrap_free_tree(), SnapData_Mesh::clear(), cloth_build_springs(), deformVerts(), dynamicPaint_paintMesh(), blender::ed::sculpt_paint::AddOperationExecutor::execute(), blender::ed::sculpt_paint::DensityAddOperationExecutor::execute(), blender::ed::sculpt_paint::DensitySubtractOperationExecutor::execute(), blender::ed::sculpt_paint::PuffOperationExecutor::execute(), blender::ed::sculpt_paint::SlideOperationExecutor::execute(), followtrack_project_to_depth_object_if_needed(), freeData(), blender::nodes::node_geo_transfer_attribute_cc::get_closest_mesh_edges(), blender::nodes::node_geo_transfer_attribute_cc::get_closest_mesh_looptris(), blender::nodes::node_geo_transfer_attribute_cc::get_closest_mesh_points(), get_vert2geom_distance(), harmonic_coordinates_bind(), blender::ed::sculpt_paint::min_distance_edit::min_distance_edit_invoke(), PE_free_shape_tree(), blender::nodes::node_geo_raycast_cc::raycast_to_mesh(), RE_bake_pixels_populate_from_objects(), remap_hair_emitter(), blender::ed::sculpt_paint::sample_curves_3d_brush(), blender::ed::curves::snap_curves_to_surface::snap_curves_to_surface_exec_object(), surfacedeformBind(), blender::ed::curves::convert_to_particle_system::try_convert_single_object(), and blender::ed::sculpt_paint::use_add_density_mode().

◆ free_bvhtree_from_pointcloud()

void free_bvhtree_from_pointcloud ( BVHTreeFromPointCloud *  data)

◆ looptri_no_hidden_map_get()

static BLI_bitmap* looptri_no_hidden_map_get ( const MPoly *  mpoly,
const int  looptri_len,
int *  r_looptri_active_len 
)
static

Definition at line 1183 of file bvhutils.cc.

References BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, MPoly::flag, ME_HIDE, and MPoly::totloop.

Referenced by BKE_bvhtree_from_mesh_get().

◆ loose_edges_map_get()

static BLI_bitmap* loose_edges_map_get ( const MEdge *  medge,
const int  edges_len,
int *  r_loose_edge_len 
)
static

Definition at line 1160 of file bvhutils.cc.

References BLI_BITMAP_DISABLE, BLI_BITMAP_ENABLE, BLI_BITMAP_NEW, e, and ME_LOOSEEDGE.

Referenced by BKE_bvhtree_from_mesh_get().

◆ loose_verts_map_get()

static BLI_bitmap* loose_verts_map_get ( const MEdge *  medge,
int  edges_num,
const MVert *  UNUSEDmvert,
int  verts_num,
int *  r_loose_vert_num 
)
static

◆ mesh_edges_nearest_point()

static void mesh_edges_nearest_point ( void *  userdata,
int  index,
const float  co[3],
BVHTreeNearest *  nearest 
)
static

Callback to BVH-tree nearest point. The tree must have been built using #bvhtree_from_mesh_edges.

Parameters
userdataMust be a #BVHMeshCallbackUserdata built from the same mesh as the tree.

Definition at line 432 of file bvhutils.cc.

References closest_to_line_segment_v3(), BVHTreeNearest::co, MVert::co, copy_v3_v3(), data, BVHTreeNearest::dist_sq, BVHTreeNearest::index, len_squared_v3v3(), BVHTreeNearest::no, normalize_v3(), and sub_v3_v3v3().

Referenced by bvhtree_from_mesh_setup_data().

◆ mesh_edges_spherecast()

static void mesh_edges_spherecast ( void *  userdata,
int  index,
const BVHTreeRay *  ray,
BVHTreeRayHit *  hit 
)
static

Callback to BVH-tree ray-cast. The tree must have been built using bvhtree_from_mesh_edges.

Parameters
userdataMust be a #BVHMeshCallbackUserdata built from the same mesh as the tree.

Definition at line 514 of file bvhutils.cc.

References add_v3_v3v3(), BVHTreeRayHit::co, MVert::co, copy_v3_v3(), data, BVHTreeRay::direction, BVHTreeRayHit::dist, dot_v3v3v3(), equals_v3v3(), i1, BVHTreeRayHit::index, isect_line_line_v3(), len_squared_v3v3(), len_v3v3(), line_point_factor_v3(), mesh_verts_spherecast_do(), BVHTreeRay::origin, BVHTreeRay::radius, square_f(), v1, and v2.

Referenced by bvhtree_from_mesh_setup_data().

◆ mesh_faces_nearest_point()

static void mesh_faces_nearest_point ( void *  userdata,
int  index,
const float  co[3],
BVHTreeNearest *  nearest 
)
static

Callback to BVH-tree nearest point. The tree must have been built using #bvhtree_from_mesh_faces.

Parameters
userdataMust be a #BVHMeshCallbackUserdata built from the same mesh as the tree.

Definition at line 227 of file bvhutils.cc.

References closest_on_tri_to_point_v3(), BVHTreeNearest::co, MVert::co, copy_v3_v3(), data, BVHTreeNearest::dist_sq, BVHTreeNearest::index, len_squared_v3v3(), BVHTreeNearest::no, normal_tri_v3(), MFace::v1, MFace::v2, MFace::v3, and MFace::v4.

Referenced by bvhtree_from_mesh_setup_data().

◆ mesh_faces_spherecast()

static void mesh_faces_spherecast ( void *  userdata,
int  index,
const BVHTreeRay *  ray,
BVHTreeRayHit *  hit 
)
static

Callback to BVH-tree ray-cast. The tree must have been built using bvhtree_from_mesh_faces.

Parameters
userdataMust be a #BVHMeshCallbackUserdata built from the same mesh as the tree.

Definition at line 323 of file bvhutils.cc.

References bvhtree_ray_tri_intersection(), bvhtree_sphereray_tri_intersection(), BVHTreeRayHit::co, MVert::co, data, BVHTreeRay::direction, BVHTreeRayHit::dist, BVHTreeRayHit::index, madd_v3_v3v3fl(), BVHTreeRayHit::no, normal_tri_v3(), BVHTreeRay::origin, BVHTreeRay::radius, MFace::v1, MFace::v2, MFace::v3, and MFace::v4.

Referenced by bvhtree_from_mesh_setup_data().

◆ mesh_looptri_nearest_point()

static void mesh_looptri_nearest_point ( void *  userdata,
int  index,
const float  co[3],
BVHTreeNearest *  nearest 
)
static

◆ mesh_looptri_spherecast()

static void mesh_looptri_spherecast ( void *  userdata,
int  index,
const BVHTreeRay *  ray,
BVHTreeRayHit *  hit 
)
static

◆ mesh_verts_spherecast()

static void mesh_verts_spherecast ( void *  userdata,
int  index,
const BVHTreeRay *  ray,
BVHTreeRayHit *  hit 
)
static

Callback to BVH-tree ray-cast. The tree must have been built using bvhtree_from_mesh_verts.

Parameters
userdataMust be a #BVHMeshCallbackUserdata built from the same mesh as the tree.

Definition at line 497 of file bvhutils.cc.

References data, mesh_verts_spherecast_do(), and v.

Referenced by bvhtree_from_mesh_setup_data().

◆ mesh_verts_spherecast_do()

static void mesh_verts_spherecast_do ( int  index,
const float  v[3],
const BVHTreeRay *  ray,
BVHTreeRayHit *  hit 
)
static