49 const float (*cos_cage)[3],
50 const bool cos_cage_free)
59 const float (*cos_cage)[3],
60 const bool cos_cage_free,
65 const float epsilon = FLT_EPSILON * 2.0f;
72 BMFace *f_test, *f_test_prev;
97 for (
int i = 0; i < looptris_tot; i++) {
98 f_test = looptris[i][0]->f;
99 if (f_test != f_test_prev) {
100 test_fn_ret = test_fn(f_test,
user_data);
101 f_test_prev = f_test;
110 tottri = looptris_tot;
118 for (
int i = 0; i < looptris_tot; i++) {
121 f_test = looptris[i][0]->f;
122 if (f_test != f_test_prev) {
123 test_fn_ret = test_fn(f_test,
user_data);
124 f_test_prev = f_test;
165 const float (*cos_cage)[3],
166 const bool cos_cage_free)
183 bm, looptris, looptris_tot, flag, cos_cage, cos_cage_free, test_fn,
NULL);
210 const float (*cos_cage)[3])
212 if (cos_cage ==
NULL) {
271 const float *tri_cos[3];
286 #ifdef USE_KDOPBVH_WATERTIGHT
294 if (isect && dist < hit->dist) {
316 const float dist = r_dist ? *r_dist : FLT_MAX;
331 if (hit.
index != -1 && hit.
dist != dist) {
372 void *filter_userdata)
378 const float dist = r_dist ? *r_dist : FLT_MAX;
396 if (hit.
index != -1 && hit.
dist != dist) {
425 const float *tri_cos[3];
428 for (
int i = 0; i < 3; i++) {
430 if (dist_sq < hit->dist_sq && dist_sq <
dist_max_sq) {
459 if (hit.
index != -1) {
485 const float *tri_cos[3];
492 if (dist_sq < hit->dist_sq && dist_sq <
dist_max_sq) {
502 const float dist_max)
520 if (hit.
index != -1) {
544 const float *tri_a_co[3] = {tri_a[0]->
v->
co, tri_a[1]->
v->
co, tri_a[2]->
v->
co};
545 const float *tri_b_co[3] = {tri_b[0]->
v->
co, tri_b[1]->
v->
co, tri_b[2]->
v->
co};
547 int verts_shared = 0;
550 if (
UNLIKELY(tri_a[0]->f == tri_b[0]->f)) {
558 if (verts_shared >= 2) {
573 unsigned int *r_overlap_tot)
577 data.tree_pair[0] = bmtree_a;
578 data.tree_pair[1] = bmtree_b;
588 if (index_a < index_b) {
601 data.tree_pair[0] = bmtree;
602 data.tree_pair[1] = bmtree;
typedef float(TangentPoint)[2]
bool(* BMBVHTree_FaceFilter)(struct BMFace *f, void *userdata)
BVHTreeOverlap * BLI_bvhtree_overlap(const BVHTree *tree1, const BVHTree *tree2, unsigned int *r_overlap_tot, BVHTree_OverlapCallback callback, void *userdata)
void BLI_bvhtree_balance(BVHTree *tree)
BVHTree * BLI_bvhtree_new(int maxsize, float epsilon, char tree_type, char axis)
void BLI_bvhtree_free(BVHTree *tree)
void BLI_bvhtree_insert(BVHTree *tree, int index, const float co[3], int numpoints)
float BLI_bvhtree_get_epsilon(const BVHTree *tree)
int BLI_bvhtree_ray_cast(BVHTree *tree, const float co[3], const float dir[3], float radius, BVHTreeRayHit *hit, BVHTree_RayCastCallback callback, void *userdata)
int BLI_bvhtree_find_nearest(BVHTree *tree, const float co[3], BVHTreeNearest *nearest, BVHTree_NearestPointCallback callback, void *userdata)
MINLINE float max_ff(float a, float b)
bool isect_ray_tri_v3(const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2])
bool isect_ray_tri_watertight_v3(const float ray_origin[3], const struct IsectRayPrecalc *isect_precalc, const float v0[3], const float v1[3], const float v2[3], float *r_dist, float r_uv[2])
void closest_on_tri_to_point_v3(float r[3], const float p[3], const float v1[3], const float v2[3], const float v3[3])
bool isect_tri_tri_v3(const float t_a0[3], const float t_a1[3], const float t_a2[3], const float t_b0[3], const float t_b1[3], const float t_b2[3], float r_i1[3], float r_i2[3])
bool isect_ray_tri_epsilon_v3(const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], const float v2[3], float *r_lambda, float r_uv[2], const float epsilon)
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v2_v2(float r[2], const float a[2])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
void interp_v3_v3v3v3_uv(float p[3], const float v1[3], const float v2[3], const float v3[3], const float uv[2])
Read Guarded memory(de)allocation.
#define BM_elem_index_get(ele)
#define BM_elem_flag_test(ele, hflag)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
ATTR_WARN_UNUSED_RESULT const BMVert * v
void BKE_bmbvh_free(BMBVHTree *bmtree)
BVHTreeOverlap * BKE_bmbvh_overlap_self(const BMBVHTree *bmtree, unsigned int *r_overlap_tot)
static bool bmbvh_overlap_cb(void *userdata, int index_a, int index_b, int UNUSED(thread))
BMBVHTree * BKE_bmbvh_new(BMesh *bm, BMLoop *(*looptris)[3], int looptris_tot, int flag, const float(*cos_cage)[3], const bool cos_cage_free)
BVHTreeOverlap * BKE_bmbvh_overlap(const BMBVHTree *bmtree_a, const BMBVHTree *bmtree_b, unsigned int *r_overlap_tot)
static void bmbvh_ray_cast_cb_filter(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
BMFace * BKE_bmbvh_ray_cast(BMBVHTree *bmtree, const float co[3], const float dir[3], const float radius, float *r_dist, float r_hitout[3], float r_cagehit[3])
static bool bm_face_is_select(BMFace *f, void *UNUSED(user_data))
static bool bm_face_is_not_hidden(BMFace *f, void *UNUSED(user_data))
static bool bmbvh_overlap_self_cb(void *userdata, int index_a, int index_b, int thread)
BMBVHTree * BKE_bmbvh_new_from_editmesh(BMEditMesh *em, int flag, const float(*cos_cage)[3], const bool cos_cage_free)
BVHTree * BKE_bmbvh_tree_get(BMBVHTree *bmtree)
BMBVHTree * BKE_bmbvh_new_ex(BMesh *bm, BMLoop *(*looptris)[3], int looptris_tot, int flag, const float(*cos_cage)[3], const bool cos_cage_free, bool(*test_fn)(BMFace *, void *user_data), void *user_data)
BMVert * BKE_bmbvh_find_vert_closest(BMBVHTree *bmtree, const float co[3], const float dist_max)
static void bmbvh_ray_cast_cb(void *userdata, int index, const BVHTreeRay *ray, BVHTreeRayHit *hit)
struct BMFace * BKE_bmbvh_find_face_closest(BMBVHTree *bmtree, const float co[3], const float dist_max)
static BMFace * bmbvh_ray_cast_handle_hit(BMBVHTree *bmtree, struct RayCastUserData *bmcb_data, const BVHTreeRayHit *hit, float *r_dist, float r_hitout[3], float r_cagehit[3])
static void bmbvh_tri_from_face(const float *cos[3], const BMLoop **ltri, const float(*cos_cage)[3])
static void bmbvh_find_face_closest_cb(void *userdata, int index, const float co[3], BVHTreeNearest *hit)
BMFace * BKE_bmbvh_ray_cast_filter(BMBVHTree *bmtree, const float co[3], const float dir[3], const float radius, float *r_dist, float r_hitout[3], float r_cagehit[3], BMBVHTree_FaceFilter filter_cb, void *filter_userdata)
static void bmbvh_find_vert_closest_cb(void *userdata, int index, const float co[3], BVHTreeNearest *hit)
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
INLINE Rall1d< T, V, S > cos(const Rall1d< T, V, S > &arg)
const BMBVHTree * tree_pair[2]
const float(* cos_cage)[3]
struct BMLoop *(* looptris)[3]
struct IsectRayPrecalc * isect_precalc
const BMLoop *(* looptris)[3]
const float(* cos_cage)[3]
struct RayCastUserData bmcb_data
BMBVHTree_FaceFilter filter_cb
const float(* cos_cage)[3]
const BMLoop *(* looptris)[3]
const float(* cos_cage)[3]
const BMLoop *(* looptris)[3]