33 const float (*cos_cage)[3],
34 const bool cos_cage_free)
43 const float (*cos_cage)[3],
44 const bool cos_cage_free,
49 const float epsilon = FLT_EPSILON * 2.0f;
56 BMFace *f_test, *f_test_prev;
81 for (
int i = 0; i < looptris_tot; i++) {
82 f_test = looptris[i][0]->f;
83 if (f_test != f_test_prev) {
94 tottri = looptris_tot;
102 for (
int i = 0; i < looptris_tot; i++) {
105 f_test = looptris[i][0]->f;
106 if (f_test != f_test_prev) {
107 test_fn_ret = test_fn(f_test,
user_data);
108 f_test_prev = f_test;
149 const float (*cos_cage)[3],
150 const bool cos_cage_free)
167 bm, looptris, looptris_tot, flag, cos_cage, cos_cage_free, test_fn,
NULL);
194 const float (*cos_cage)[3])
196 if (cos_cage ==
NULL) {
255 const float *tri_cos[3];
270 #ifdef USE_KDOPBVH_WATERTIGHT
278 if (isect && dist < hit->dist) {
300 const float dist = r_dist ? *r_dist : FLT_MAX;
315 if (hit.
index != -1 && hit.
dist != dist) {
356 void *filter_userdata)
362 const float dist = r_dist ? *r_dist : FLT_MAX;
380 if (hit.
index != -1 && hit.
dist != dist) {
409 const float *tri_cos[3];
412 for (
int i = 0; i < 3; i++) {
414 if (dist_sq < hit->dist_sq && dist_sq <
dist_max_sq) {
443 if (hit.
index != -1) {
469 const float *tri_cos[3];
476 if (dist_sq < hit->dist_sq && dist_sq <
dist_max_sq) {
486 const float dist_max)
504 if (hit.
index != -1) {
528 const float *tri_a_co[3] = {tri_a[0]->
v->
co, tri_a[1]->
v->
co, tri_a[2]->
v->
co};
529 const float *tri_b_co[3] = {tri_b[0]->
v->
co, tri_b[1]->
v->
co, tri_b[2]->
v->
co};
531 int verts_shared = 0;
534 if (
UNLIKELY(tri_a[0]->f == tri_b[0]->f)) {
542 if (verts_shared >= 2) {
554 unsigned int *r_overlap_tot)
558 data.tree_pair[0] = bmtree_a;
559 data.tree_pair[1] = bmtree_b;
569 if (index_a < index_b) {
579 data.tree_pair[0] = bmtree;
580 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_num, 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], 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]