Blender  V3.3
BKE_bvhutils.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2006 NaN Holding BV. All rights reserved. */
3 #pragma once
4 
9 #include "BLI_bitmap.h"
10 #include "BLI_kdopbvh.h"
11 #include "BLI_threads.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
21 struct BMEditMesh;
22 struct MFace;
23 struct MVert;
24 struct Mesh;
25 struct PointCloud;
26 
27 struct BVHCache;
28 
32 typedef struct BVHTreeFromEditMesh {
33  struct BVHTree *tree;
34 
38 
39  struct BMEditMesh *em;
40 
41  /* Private data */
42  bool cached;
43 
45 
49 typedef struct BVHTreeFromMesh {
50  struct BVHTree *tree;
51 
55 
56  /* Vertex array, so that callbacks have instant access to data. */
57  const struct MVert *vert;
58  const float (*vert_normals)[3];
59  const struct MEdge *edge;
60  const struct MFace *face;
61  const struct MLoop *loop;
62  const struct MLoopTri *looptri;
63 
64  /* Private data */
65  bool cached;
66 
68 
69 typedef enum BVHCacheType {
75 
78 
82 
83  /* Keep `BVHTREE_MAX_ITEM` as last item. */
86 
99  BVHTreeFromEditMesh *data, struct BMEditMesh *em, float epsilon, int tree_type, int axis);
100 
105  struct BMEditMesh *em,
106  const BLI_bitmap *mask,
107  int verts_num_active,
108  float epsilon,
109  int tree_type,
110  int axis);
111 
120  const struct MVert *vert,
121  int verts_num,
122  const BLI_bitmap *verts_mask,
123  int verts_num_active,
124  float epsilon,
125  int tree_type,
126  int axis);
127 
129  BVHTreeFromEditMesh *data, struct BMEditMesh *em, float epsilon, int tree_type, int axis);
130 
135  struct BMEditMesh *em,
136  const BLI_bitmap *edges_mask,
137  int edges_num_active,
138  float epsilon,
139  int tree_type,
140  int axis);
141 
151  const struct MVert *vert,
152  const struct MEdge *edge,
153  int edges_num,
154  const BLI_bitmap *edges_mask,
155  int edges_num_active,
156  float epsilon,
157  int tree_type,
158  int axis);
159 
161  BVHTreeFromEditMesh *data, struct BMEditMesh *em, float epsilon, int tree_type, int axis);
162 
167  struct BMEditMesh *em,
168  const BLI_bitmap *mask,
169  int looptri_num_active,
170  float epsilon,
171  int tree_type,
172  int axis);
173 
178  const struct MVert *vert,
179  const struct MLoop *mloop,
180  const struct MLoopTri *looptri,
181  int looptri_num,
182  const BLI_bitmap *mask,
183  int looptri_num_active,
184  float epsilon,
185  int tree_type,
186  int axis);
187 
195  const struct Mesh *mesh,
196  BVHCacheType bvh_cache_type,
197  int tree_type);
198 
203  struct BMEditMesh *em,
204  int tree_type,
205  BVHCacheType bvh_cache_type,
206  struct BVHCache **bvh_cache_p,
207  ThreadMutex *mesh_eval_mutex);
208 
217 
222  const BVHTreeRay *ray, float m_dist, const float v0[3], const float v1[3], const float v2[3]);
224  float radius,
225  float m_dist,
226  const float v0[3],
227  const float v1[3],
228  const float v2[3]);
229 
230 typedef struct BVHTreeFromPointCloud {
231  struct BVHTree *tree;
232 
234 
235  const float (*coords)[3];
237 
239  const struct PointCloud *pointcloud,
240  int tree_type);
241 
243 
248 /* Using local coordinates */
249 
250 bool bvhcache_has_tree(const struct BVHCache *bvh_cache, const BVHTree *tree);
251 struct BVHCache *bvhcache_init(void);
255 void bvhcache_free(struct BVHCache *bvh_cache);
256 
257 #ifdef __cplusplus
258 }
259 #endif
typedef float(TangentPoint)[2]
BVHTree * BKE_bvhtree_from_pointcloud_get(struct BVHTreeFromPointCloud *data, const struct PointCloud *pointcloud, int tree_type)
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)
Definition: bvhutils.cc:866
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)
Definition: bvhutils.cc:1100
void free_bvhtree_from_mesh(struct BVHTreeFromMesh *data)
Definition: bvhutils.cc:1410
void bvhcache_free(struct BVHCache *bvh_cache)
Definition: bvhutils.cc:135
struct BVHTreeFromPointCloud BVHTreeFromPointCloud
BVHTree * bvhtree_from_editmesh_looptri(BVHTreeFromEditMesh *data, struct BMEditMesh *em, float epsilon, int tree_type, int axis)
Definition: bvhutils.cc:1094
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)
Definition: bvhutils.cc:732
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)
Definition: bvhutils.cc:1327
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)
Definition: bvhutils.cc:1071
BVHCacheType
Definition: BKE_bvhutils.h:69
@ BVHTREE_FROM_EDGES
Definition: BKE_bvhutils.h:71
@ BVHTREE_FROM_EM_EDGES
Definition: BKE_bvhutils.h:80
@ BVHTREE_FROM_FACES
Definition: BKE_bvhutils.h:72
@ BVHTREE_FROM_LOOPTRI
Definition: BKE_bvhutils.h:73
@ BVHTREE_FROM_LOOSEEDGES
Definition: BKE_bvhutils.h:77
@ BVHTREE_FROM_EM_VERTS
Definition: BKE_bvhutils.h:79
@ BVHTREE_FROM_LOOSEVERTS
Definition: BKE_bvhutils.h:76
@ BVHTREE_FROM_EM_LOOPTRI
Definition: BKE_bvhutils.h:81
@ BVHTREE_FROM_LOOPTRI_NO_HIDDEN
Definition: BKE_bvhutils.h:74
@ BVHTREE_MAX_ITEM
Definition: BKE_bvhutils.h:84
@ BVHTREE_FROM_VERTS
Definition: BKE_bvhutils.h:70
BVHTree * bvhtree_from_editmesh_edges(BVHTreeFromEditMesh *data, struct BMEditMesh *em, float epsilon, int tree_type, int axis)
Definition: bvhutils.cc:887
struct BVHTreeFromMesh BVHTreeFromMesh
float bvhtree_ray_tri_intersection(const BVHTreeRay *ray, float m_dist, const float v0[3], const float v1[3], const float v2[3])
void free_bvhtree_from_pointcloud(struct BVHTreeFromPointCloud *data)
Definition: bvhutils.cc:1451
BVHTree * BKE_bvhtree_from_mesh_get(struct BVHTreeFromMesh *data, const struct Mesh *mesh, BVHCacheType bvh_cache_type, int tree_type)
Definition: bvhutils.cc:1213
BVHTree * bvhtree_from_mesh_edges_ex(struct BVHTreeFromMesh *data, const struct MVert *vert, const struct MEdge *edge, int edges_num, const BLI_bitmap *edges_mask, int edges_num_active, float epsilon, int tree_type, int axis)
bool bvhcache_has_tree(const struct BVHCache *bvh_cache, const BVHTree *tree)
BVHTree * bvhtree_from_mesh_verts_ex(struct BVHTreeFromMesh *data, const struct MVert *vert, int verts_num, const BLI_bitmap *verts_mask, int verts_num_active, float epsilon, int tree_type, int axis)
void free_bvhtree_from_editmesh(struct BVHTreeFromEditMesh *data)
Definition: bvhutils.cc:1400
BVHTree * bvhtree_from_editmesh_verts(BVHTreeFromEditMesh *data, struct BMEditMesh *em, float epsilon, int tree_type, int axis)
Definition: bvhutils.cc:753
struct BVHTreeFromEditMesh BVHTreeFromEditMesh
struct BVHCache * bvhcache_init(void)
Definition: bvhutils.cc:113
float bvhtree_sphereray_tri_intersection(const BVHTreeRay *ray, float radius, float m_dist, const float v0[3], const float v1[3], const float v2[3])
Definition: bvhutils.cc:197
unsigned int BLI_bitmap
Definition: BLI_bitmap.h:16
void(* BVHTree_RayCastCallback)(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
Definition: BLI_kdopbvh.h:102
void(* BVHTree_NearestPointCallback)(void *userdata, int index, const float co[3], BVHTreeNearest *nearest)
Definition: BLI_kdopbvh.h:94
pthread_mutex_t ThreadMutex
Definition: BLI_threads.h:82
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble v1
ATTR_WARN_UNUSED_RESULT const BMVert * v2
void * tree
ccl_device_inline float4 mask(const int4 &mask, const float4 &a)
Definition: math_float4.h:513
static double epsilon
struct BVHTree * tree
Definition: BKE_bvhutils.h:33
struct BMEditMesh * em
Definition: BKE_bvhutils.h:39
BVHTree_NearestPointCallback nearest_callback
Definition: BKE_bvhutils.h:36
BVHTree_RayCastCallback raycast_callback
Definition: BKE_bvhutils.h:37
BVHTree_RayCastCallback raycast_callback
Definition: BKE_bvhutils.h:54
const struct MFace * face
Definition: BKE_bvhutils.h:60
const struct MEdge * edge
Definition: BKE_bvhutils.h:59
const float(* vert_normals)[3]
Definition: BKE_bvhutils.h:58
const struct MLoop * loop
Definition: BKE_bvhutils.h:61
struct BVHTree * tree
Definition: BKE_bvhutils.h:50
const struct MVert * vert
Definition: BKE_bvhutils.h:57
BVHTree_NearestPointCallback nearest_callback
Definition: BKE_bvhutils.h:53
const struct MLoopTri * looptri
Definition: BKE_bvhutils.h:62
struct BVHTree * tree
Definition: BKE_bvhutils.h:231
BVHTree_NearestPointCallback nearest_callback
Definition: BKE_bvhutils.h:233
const float(* coords)[3]
Definition: BKE_bvhutils.h:235
char tree_type
Definition: BLI_kdopbvh.c:86