52 #define LEAF_LIMIT 10000
56 #define STACK_FIXED_DEPTH 100
84 for (
int i = 0; i < 3; i++) {
93 for (
int i = 0; i < 3; i++) {
104 for (
int i = 0; i < 3; i++) {
108 if (dim[0] > dim[1]) {
109 if (dim[0] > dim[2]) {
116 if (dim[1] > dim[2]) {
125 for (
int i = 0; i < 3; i++) {
179 for (; prim_bbc[prim_indices[i]].
bcentroid[axis] < mid; i++) {
182 for (; mid < prim_bbc[prim_indices[j]].
bcentroid[axis]; j--) {
190 SWAP(
int, prim_indices[i], prim_indices[j]);
255 PBVH *pbvh,
GHash *map,
unsigned int *face_verts,
unsigned int *uniq_verts,
int vertex)
257 void *key, **value_p;
264 value_i = *uniq_verts;
268 value_i = ~(*face_verts);
281 bool has_visible =
false;
283 node->uniq_verts =
node->face_verts = 0;
284 const int totface =
node->totprim;
289 int(*face_vert_indices)[3] =
MEM_mallocN(
sizeof(
int[3]) * totface,
"bvh node face vert indices");
291 node->face_vert_indices = (
const int(*)[3])face_vert_indices;
297 for (
int i = 0; i < totface; i++) {
299 for (
int j = 0; j < 3; j++) {
304 if (has_visible ==
false) {
312 "bvh node vert indices");
313 node->vert_indices = vert_indices;
322 ndx = -ndx +
node->uniq_verts - 1;
328 for (
int i = 0; i < totface; i++) {
331 for (
int j = 0; j < sides; j++) {
332 if (face_vert_indices[i][j] < 0) {
333 face_vert_indices[i][j] = -face_vert_indices[i][j] +
node->uniq_verts - 1;
348 for (
int i = offset +
count - 1; i >= offset; i--) {
356 const int *grid_indices,
360 const int gridarea = (gridsize - 1) * (gridsize - 1);
366 for (
int i = 0; i < totgrid; i++) {
367 const BLI_bitmap *gh = grid_hidden[grid_indices[i]];
371 for (
int y = 0;
y < gridsize - 1;
y++) {
372 for (
int x = 0;
x < gridsize - 1;
x++) {
390 for (
int i = 0; i < pbvh->
totgrid; i++) {
393 if (!gh && pbvh->
face_sets[face_index] < 0) {
395 "partialvis_update_grids");
398 for (
int y = 0;
y < gridsize;
y++) {
399 for (
int x = 0;
x < gridsize;
x++) {
445 for (
int i = offset +
count - 1; i > offset; i--) {
456 for (
int i = offset +
count - 1; i > offset; i--) {
485 if (below_leaf_limit) {
499 if (!below_leaf_limit) {
504 for (
int i = offset +
count - 1; i >= offset; i--) {
515 (cb->
bmax[axis] + cb->
bmin[axis]) * 0.5f,
530 offset +
count - end);
535 if (totprim != pbvh->
totprim) {
544 for (
int i = 0; i < totprim; i++) {
555 build_sub(pbvh, 0, cb, prim_bbc, 0, totprim);
600 for (
int i = 0; i < looptri_num; i++) {
603 BBC *bbc = prim_bbc + i;
607 for (
int j = 0; j < sides; j++) {
650 for (
int i = 0; i < totgrid; i++) {
652 BBC *bbc = prim_bbc + i;
656 for (
int j = 0; j < gridsize * gridsize; j++) {
681 for (
int i = 0; i < pbvh->
totnode; i++) {
685 if (
node->draw_buffers) {
688 if (
node->vert_indices) {
691 if (
node->face_vert_indices) {
694 if (
node->bm_faces) {
697 if (
node->bm_unique_verts) {
700 if (
node->bm_other_verts) {
848 int tot = 0, space = 0;
856 space = (tot == 0) ? 32 : space * 2;
867 if (tot == 0 &&
array) {
910 tree->left = new_node;
918 tree->right = new_node;
932 hcb(
tree->data, hit_data, tmin);
992 float tmin = FLT_MAX;
1003 return (
node->flag & flag) != 0;
1030 unsigned int mpoly_prev =
UINT_MAX;
1034 const int totface =
node->totprim;
1036 for (
int i = 0; i < totface; i++) {
1038 const unsigned int vtri[3] = {
1043 const int sides = 3;
1046 if (lt->
poly != mpoly_prev) {
1049 mpoly_prev = lt->
poly;
1052 for (
int j = sides; j--;) {
1053 const int v = vtri[j];
1060 for (
int k = 3; k--;) {
1080 const int totvert =
node->uniq_verts;
1082 for (
int i = 0; i < totvert; i++) {
1140 bool has_unmasked =
false;
1141 bool has_masked =
true;
1147 has_unmasked =
true;
1156 has_unmasked =
true;
1223 const int flag =
data->flag;
1258 return update_flags;
1273 switch (pbvh->
type) {
1297 switch (pbvh->
type) {
1326 node->bm_unique_verts,
1327 node->bm_other_verts,
1338 for (
int n = 0; n < totnode; n++) {
1366 for (
int i = 0; i < totnode; i++) {
1463 const int *vert_indices;
1468 for (i = 0; i < totvert; i++) {
1469 MVert *
v = &mvert[vert_indices[i]];
1483 int *grid_indices, totgrid, i;
1489 for (i = 0; i < totgrid; i++) {
1490 int g = grid_indices[i],
x,
y;
1512 GSet *unique, *other;
1624 for (
uint i = 0; i <
node->totprim; i++) {
1640 *r_gridfaces =
NULL;
1656 *r_gridfaces =
faces;
1822 const int **r_vert_indices,
1825 if (r_vert_indices) {
1826 *r_vert_indices =
node->vert_indices;
1830 *r_verts = pbvh->
verts;
1838 switch (pbvh->
type) {
1845 *r_uniquevert = tot;
1850 *r_totvert =
node->uniq_verts +
node->face_verts;
1853 *r_uniquevert =
node->uniq_verts;
1862 *r_uniquevert = tot;
1870 int **r_grid_indices,
1876 switch (pbvh->
type) {
1878 if (r_grid_indices) {
1879 *r_grid_indices =
node->prim_indices;
1882 *r_totgrid =
node->totprim;
1891 *r_griddata = pbvh->
grids;
1896 if (r_grid_indices) {
1897 *r_grid_indices =
NULL;
1929 if (
node->proxy_count > 0) {
1931 *proxies =
node->proxies;
1934 *proxy_count =
node->proxy_count;
1948 int (**r_orco_tris)[3],
1949 int *r_orco_tris_num,
1950 float (**r_orco_coords)[3])
1952 *r_orco_tris =
node->bm_ortri;
1953 *r_orco_tris_num =
node->bm_tot_ortri;
1954 *r_orco_coords =
node->bm_orco;
1966 const int totvert =
node->uniq_verts +
node->face_verts;
1968 for (
int i = 0; i < totvert; i++) {
1990 const float *bb_min, *bb_max;
1994 bb_min =
node->orig_vb.bmin;
1995 bb_max =
node->orig_vb.bmax;
1999 bb_min =
node->vb.bmin;
2000 bb_max =
node->vb.bmax;
2009 const float ray_start[3],
2010 const float ray_normal[3],
2032 (depth_test < *depth)) ||
2034 (depth_test < *depth))) {
2035 *depth = depth_test;
2051 (depth_test < *depth))) {
2052 *depth = depth_test;
2062 const float ray_direction[3],
2069 const float *tri[3] = {v0,
v1,
v2};
2070 float dist_sq_best = FLT_MAX;
2071 for (
int i = 0, j = 2; i < 3; j = i++) {
2072 float point_test[3], depth_test = FLT_MAX;
2074 ray_origin, ray_direction, tri[i], tri[j], point_test, &depth_test);
2075 if (dist_sq_test < dist_sq_best || i == 0) {
2077 *r_depth = depth_test;
2078 dist_sq_best = dist_sq_test;
2081 return dist_sq_best;
2085 const float ray_normal[3],
2094 float co[3], depth_test;
2097 ray_start, ray_normal, t0, t1, t2, co, &depth_test)) < *dist_sq)) {
2098 *dist_sq = dist_sq_test;
2099 *depth = depth_test;
2101 ray_start, ray_normal, t0, t2, t3, co, &depth_test)) < *dist_sq)) {
2102 *dist_sq = dist_sq_test;
2103 *depth = depth_test;
2112 const float ray_normal[3],
2120 float co[3], depth_test;
2123 ray_start, ray_normal, t0, t1, t2, co, &depth_test)) < *dist_sq)) {
2124 *dist_sq = dist_sq_test;
2125 *depth = depth_test;
2135 const float ray_start[3],
2136 const float ray_normal[3],
2139 int *r_active_vertex_index,
2140 int *r_active_face_index,
2141 float *r_face_normal)
2146 int totface =
node->totprim;
2148 float nearest_vertex_co[3] = {0.0f};
2150 for (
int i = 0; i < totface; i++) {
2152 const int *face_verts =
node->face_vert_indices[i];
2161 co[0] = origco[face_verts[0]];
2162 co[1] = origco[face_verts[1]];
2163 co[2] = origco[face_verts[2]];
2167 co[0] = vert[mloop[lt->
tri[0]].
v].
co;
2168 co[1] = vert[mloop[lt->
tri[1]].
v].
co;
2169 co[2] = vert[mloop[lt->
tri[2]].
v].
co;
2175 if (r_face_normal) {
2179 if (r_active_vertex_index) {
2180 float location[3] = {0.0f};
2182 for (
int j = 0; j < 3; j++) {
2189 *r_active_vertex_index = mloop[lt->
tri[j]].
v;
2190 *r_active_face_index = lt->
poly;
2203 const float ray_start[3],
2204 const float ray_normal[3],
2207 int *r_active_vertex_index,
2208 int *r_active_grid_index,
2209 float *r_face_normal)
2211 const int totgrid =
node->totprim;
2214 float nearest_vertex_co[3] = {0.0};
2217 for (
int i = 0; i < totgrid; i++) {
2218 const int grid_index =
node->prim_indices[i];
2228 for (
int y = 0;
y < gridsize - 1;
y++) {
2229 for (
int x = 0;
x < gridsize - 1;
x++) {
2239 co[0] = origco[
y * gridsize +
x];
2240 co[1] = origco[
y * gridsize +
x + 1];
2241 co[2] = origco[(
y + 1) * gridsize +
x + 1];
2242 co[3] = origco[(
y + 1) * gridsize +
x];
2252 ray_start, isect_precalc, co[0], co[1], co[2], co[3], depth)) {
2255 if (r_face_normal) {
2259 if (r_active_vertex_index) {
2260 float location[3] = {0.0};
2263 const int x_it[4] = {0, 1, 1, 0};
2264 const int y_it[4] = {0, 0, 1, 1};
2266 for (
int j = 0; j < 4; j++) {
2274 *r_active_vertex_index = gridkey->
grid_area * grid_index +
2275 (
y + y_it[j]) * gridkey->
grid_size + (
x + x_it[j]);
2279 if (r_active_grid_index) {
2280 *r_active_grid_index = grid_index;
2287 origco += gridsize * gridsize;
2298 const float ray_start[3],
2299 const float ray_normal[3],
2302 int *active_vertex_index,
2303 int *active_face_grid_index,
2312 switch (pbvh->
type) {
2321 active_vertex_index,
2322 active_face_grid_index,
2333 active_vertex_index,
2334 active_face_grid_index,
2345 active_vertex_index,
2354 PBVH *pbvh,
bool original,
float ray_start[3],
float ray_end[3],
float ray_normal[3])
2357 float rootmin_start, rootmin_end;
2358 float bb_min_root[3], bb_max_root[3], bb_center[3], bb_diff[3];
2360 float ray_normal_inv[3];
2361 float offset = 1.0f + 1e-3f;
2362 const float offset_vec[3] = {1e-3f, 1e-3f, 1e-3f};
2410 const float *bb_min, *bb_max;
2414 bb_min =
node->orig_vb.bmin;
2415 bb_max =
node->orig_vb.bmax;
2419 bb_min =
node->vb.bmin;
2420 bb_max =
node->vb.bmax;
2423 float co_dummy[3], depth;
2427 return depth > 0.0f;
2433 const float ray_start[3],
2434 const float ray_normal[3],
2448 const float ray_start[3],
2449 const float ray_normal[3],
2456 int i, totface =
node->totprim;
2459 for (i = 0; i < totface; i++) {
2461 const int *face_verts =
node->face_vert_indices[i];
2471 origco[face_verts[0]],
2472 origco[face_verts[1]],
2473 origco[face_verts[2]],
2481 vert[mloop[lt->
tri[0]].
v].
co,
2482 vert[mloop[lt->
tri[1]].v].
co,
2483 vert[mloop[lt->
tri[2]].v].
co,
2495 const float ray_start[3],
2496 const float ray_normal[3],
2500 const int totgrid =
node->totprim;
2504 for (
int i = 0; i < totgrid; i++) {
2514 for (
int y = 0;
y < gridsize - 1;
y++) {
2515 for (
int x = 0;
x < gridsize - 1;
x++) {
2526 origco[
y * gridsize +
x],
2527 origco[
y * gridsize +
x + 1],
2528 origco[(
y + 1) * gridsize +
x + 1],
2529 origco[(
y + 1) * gridsize +
x],
2547 origco += gridsize * gridsize;
2558 const float ray_start[3],
2559 const float ray_normal[3],
2569 switch (pbvh->
type) {
2572 pbvh,
node, origco, ray_start, ray_normal, depth, dist_sq);
2576 pbvh,
node, origco, ray_start, ray_normal, depth, dist_sq);
2580 node, ray_start, ray_normal, depth, dist_sq, use_origco);
2599 const float bb_max[3],
2605 for (
int i = 0; i < frustum->
num_planes; i++) {
2606 float vmin[3], vmax[3];
2608 for (
int axis = 0; axis < 3; axis++) {
2609 if (planes[i][axis] < 0) {
2610 vmin[axis] = bb_min[axis];
2611 vmax[axis] = bb_max[axis];
2614 vmin[axis] = bb_max[axis];
2615 vmax[axis] = bb_min[axis];
2619 if (
dot_v3v3(planes[i], vmin) + planes[i][3] < 0) {
2622 if (
dot_v3v3(planes[i], vmax) + planes[i][3] <= 0) {
2632 const float *bb_min, *bb_max;
2634 bb_min =
node->vb.bmin;
2635 bb_max =
node->vb.bmax;
2642 const float *bb_min, *bb_max;
2644 bb_min =
node->vb.bmin;
2645 bb_max =
node->vb.bmax;
2670 if (num_faces > 0) {
2702 data->accum_update_flag |=
node->flag;
2707 bool update_only_visible,
2715 int update_flag = 0;
2718 if (update_only_visible) {
2722 update_flag =
data.accum_update_flag;
2742 for (
int i = 0; i < totnode; i++) {
2767 pbvh->
grids = grids;
2788 float *co = (
float *)vertCos;
2790 for (
int a = 0;
a < pbvh->
totvert;
a++, mvert++, co += 3) {
2800 if (totvert != pbvh->
totvert) {
2801 BLI_assert(!
"PBVH: Given deforming vcos number does not natch PBVH vertex number!");
2822 for (
int a = 0;
a < pbvh->
totvert;
a++, mvert++) {
2824 if (memcmp(mvert->
co, vertCos[
a],
sizeof(
float[3])) != 0) {
2850 int index, totverts;
2852 index =
node->proxy_count;
2854 node->proxy_count++;
2856 if (
node->proxies) {
2864 node->proxies[index].co =
MEM_callocN(
sizeof(
float[3]) * totverts,
"PBVHNodeProxy.co");
2866 return node->proxies + index;
2871 for (
int p = 0; p <
node->proxy_count; p++) {
2879 node->proxy_count = 0;
2885 int tot = 0, space = 0;
2887 for (
int n = 0; n < pbvh->
totnode; n++) {
2890 if (
node->proxy_count > 0) {
2893 space = (tot == 0) ? 32 : space * 2;
2902 if (tot == 0 &&
array) {
2914 if (!
node->color_buffer.color) {
2915 node->color_buffer.color =
MEM_callocN(
sizeof(
float[4]) *
node->uniq_verts,
"Color buffer");
2917 return &
node->color_buffer;
2925 for (
int i = 0; i < totnode; i++) {
2935 const int *vert_indices;
2937 int totgrid, gridsize, uniq_verts, totvert;
2957 vi->
totgrid = (grids) ? totgrid : 1;
2990 switch (pbvh->
type) {
3004 switch (pbvh->
type) {
3037 for (
int i = 0; i < planes->
num_planes; i++) {
3046 memset(settings, 0,
sizeof(*settings));
typedef float(TangentPoint)[2]
BLI_INLINE float * CCG_grid_elem_co(const CCGKey *key, CCGElem *elem, int x, int y)
BLI_INLINE float * CCG_elem_offset_co(const CCGKey *key, CCGElem *elem, int offset)
void * CustomData_get_layer(const struct CustomData *data, int type)
int CustomData_get_offset(const struct CustomData *data, int type)
void BKE_mesh_calc_normals_looptri(struct MVert *mverts, int numVerts, const struct MLoop *mloop, const struct MLoopTri *looptri, int looptri_num, float(*r_tri_nors)[3])
void BKE_mesh_calc_poly_normal(const struct MPoly *mpoly, const struct MLoop *loopstart, const struct MVert *mvarray, float r_no[3])
bool paint_is_face_hidden(const struct MLoopTri *lt, const struct MVert *mvert, const struct MLoop *mloop)
bool paint_is_grid_face_hidden(const unsigned int *grid_hidden, int gridsize, int x, int y)
A BVH for high poly meshes.
#define BKE_pbvh_vertex_iter_begin(pbvh, node, vi, mode)
void(* BKE_pbvh_HitCallback)(PBVHNode *node, void *data)
#define BKE_pbvh_vertex_iter_end
struct GSet * BKE_pbvh_bmesh_node_other_verts(PBVHNode *node)
void(* BKE_pbvh_HitOccludedCallback)(PBVHNode *node, void *data, float *tmin)
struct GSet * BKE_pbvh_bmesh_node_unique_verts(PBVHNode *node)
void(* BKE_pbvh_SearchNearestCallback)(PBVHNode *node, void *data, float *tmin)
@ PBVH_RebuildDrawBuffers
bool(* BKE_pbvh_SearchCallback)(PBVHNode *node, void *data)
void BKE_subdiv_ccg_update_normals(SubdivCCG *subdiv_ccg, struct CCGFace **effected_faces, int num_effected_faces)
int BKE_subdiv_ccg_grid_to_face_index(const SubdivCCG *subdiv_ccg, const int grid_index)
#define BLI_BITMAP_TEST(_bitmap, _index)
#define BLI_BITMAP_ENABLE(_bitmap, _index)
#define BLI_BITMAP_NEW(_tot, _alloc_string)
#define BLI_BITMAP_SET(_bitmap, _index, _set)
#define GSET_ITER_INDEX(gs_iter_, gset_, i_)
BLI_INLINE void * BLI_ghashIterator_getKey(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
BLI_INLINE void * BLI_ghashIterator_getValue(GHashIterator *ghi) ATTR_WARN_UNUSED_RESULT
unsigned int BLI_gset_len(GSet *gs) ATTR_WARN_UNUSED_RESULT
#define GHASH_ITER(gh_iter_, ghash_)
GSet * BLI_gset_ptr_new(const char *info)
GHash * BLI_ghash_int_new_ex(const char *info, const unsigned int nentries_reserve) ATTR_MALLOC ATTR_WARN_UNUSED_RESULT
#define GSET_ITER(gs_iter_, gset_)
BLI_INLINE void BLI_gsetIterator_init(GSetIterator *gsi, GSet *gs)
void BLI_ghash_free(GHash *gh, GHashKeyFreeFP keyfreefp, GHashValFreeFP valfreefp)
void BLI_gset_free(GSet *gs, GSetKeyFreeFP keyfreefp)
BLI_INLINE void * BLI_gsetIterator_getKey(GSetIterator *gsi)
bool BLI_ghash_ensure_p(GHash *gh, void *key, void ***r_val) ATTR_WARN_UNUSED_RESULT
bool BLI_gset_add(GSet *gs, void *key)
void BLI_kdtree_nd_() free(KDTree *tree)
MINLINE float max_ff(float a, float b)
MINLINE float min_ff(float a, float b)
MINLINE int max_ii(int a, int b)
float normal_quad_v3(float n[3], const float v1[3], const float v2[3], const float v3[3], const float v4[3])
bool isect_ray_aabb_v3(const struct IsectRayAABB_Precalc *data, const float bb_min[3], const float bb_max[3], float *tmin)
void dist_squared_ray_to_aabb_v3_precalc(struct DistRayAABB_Precalc *neasrest_precalc, const float ray_origin[3], const float ray_direction[3])
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 isect_ray_aabb_v3_precalc(struct IsectRayAABB_Precalc *data, const float ray_origin[3], const float ray_direction[3])
float dist_squared_ray_to_seg_v3(const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], float r_point[3], float *r_depth)
float dist_squared_ray_to_aabb_v3(const struct DistRayAABB_Precalc *data, const float bb_min[3], const float bb_max[3], float r_point[3], float *r_depth)
float normal_tri_v3(float n[3], const float v1[3], const float v2[3], const float v3[3])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void normal_float_to_short_v3(short r[3], const float n[3])
MINLINE float normalize_v3(float r[3])
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void madd_v3_v3v3fl(float r[3], const float a[3], const float b[3], float f)
MINLINE void zero_v3(float r[3])
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
void BLI_task_parallel_range(const int start, const int stop, void *userdata, TaskParallelRangeFunc func, const TaskParallelSettings *settings)
#define POINTER_FROM_INT(i)
#define POINTER_AS_INT(i)
@ GPU_PBVH_BUFFERS_SHOW_MASK
@ GPU_PBVH_BUFFERS_SHOW_VCOL
@ GPU_PBVH_BUFFERS_SHOW_SCULPT_FACE_SETS
void GPU_pbvh_buffers_free(GPU_PBVH_Buffers *buffers)
void GPU_pbvh_bmesh_buffers_update(GPU_PBVH_Buffers *buffers, struct BMesh *bm, struct GSet *bm_faces, struct GSet *bm_unique_verts, struct GSet *bm_other_verts, const int update_flags)
void GPU_pbvh_bmesh_buffers_update_free(GPU_PBVH_Buffers *buffers)
GPU_PBVH_Buffers * GPU_pbvh_mesh_buffers_build(const struct MPoly *mpoly, const struct MLoop *mloop, const struct MLoopTri *looptri, const struct MVert *mvert, const int *face_indices, const int *sculpt_face_sets, const int face_indices_len, const struct Mesh *mesh)
void GPU_pbvh_buffers_update_flush(GPU_PBVH_Buffers *buffers)
void GPU_pbvh_mesh_buffers_update(GPU_PBVH_Buffers *buffers, const struct MVert *mvert, const float *vmask, const struct MLoopCol *vcol, const int *sculpt_face_sets, const int face_sets_color_seed, const int face_sets_color_default, const struct MPropCol *vtcol, const int update_flags)
GPU_PBVH_Buffers * GPU_pbvh_bmesh_buffers_build(bool smooth_shading)
void GPU_pbvh_grid_buffers_update_free(GPU_PBVH_Buffers *buffers, const struct DMFlagMat *grid_flag_mats, const int *grid_indices)
GPU_PBVH_Buffers * GPU_pbvh_grid_buffers_build(int totgrid, unsigned int **grid_hidden)
void GPU_pbvh_grid_buffers_update(GPU_PBVH_Buffers *buffers, struct SubdivCCG *subdiv_ccg, struct CCGElem **grids, const struct DMFlagMat *grid_flag_mats, int *grid_indices, int totgrid, const int *sculpt_face_sets, const int face_sets_color_seed, const int face_sets_color_default, const struct CCGKey *key, const int update_flags)
_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 y
_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
Read Guarded memory(de)allocation.
#define MEM_recallocN(vmemh, len)
#define MEM_reallocN(vmemh, len)
Platform independent time functions.
Provides wrapper around system-specific atomic primitives, and some extensions (faked-atomic operatio...
ATOMIC_INLINE float atomic_add_and_fetch_fl(float *p, const float x)
#define BM_elem_flag_test(ele, hflag)
void BM_mesh_elem_index_ensure(BMesh *bm, const char htype)
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMVert * v
static unsigned long seed
void(* MEM_freeN)(void *vmemh)
void *(* MEM_dupallocN)(const void *vmemh)
void *(* MEM_recallocN_id)(void *vmemh, size_t len, const char *str)
void *(* MEM_callocN)(size_t len, const char *str)
void *(* MEM_mallocN)(size_t len, const char *str)
static void clear(Message *msg)
static void update(bNodeTree *ntree)
static PlaneAABBIsect test_frustum_aabb(const float bb_min[3], const float bb_max[3], PBVHFrustumPlanes *frustum)
bool BKE_pbvh_node_fully_masked_get(PBVHNode *node)
static float dist_squared_ray_to_tri_v3_fast(const float ray_origin[3], const float ray_direction[3], const float v0[3], const float v1[3], const float v2[3], float r_point[3], float *r_depth)
static void pbvh_build(PBVH *pbvh, BB *cb, BBC *prim_bbc, int totprim)
bool ray_face_nearest_tri(const float ray_start[3], const float ray_normal[3], const float t0[3], const float t1[3], const float t2[3], float *depth, float *dist_sq)
int BKE_pbvh_get_grid_num_faces(const PBVH *pbvh)
void BKE_pbvh_node_free_proxies(PBVHNode *node)
void BKE_pbvh_set_frustum_planes(PBVH *pbvh, PBVHFrustumPlanes *planes)
static void pbvh_iter_end(PBVHIter *iter)
static void build_mesh_leaf_node(PBVH *pbvh, PBVHNode *node)
void BKE_pbvh_node_mark_update(PBVHNode *node)
BLI_bitmap ** BKE_pbvh_get_grid_visibility(const PBVH *pbvh)
void BKE_pbvh_node_get_bm_orco_data(PBVHNode *node, int(**r_orco_tris)[3], int *r_orco_tris_num, float(**r_orco_coords)[3])
void BKE_pbvh_build_grids(PBVH *pbvh, CCGElem **grids, int totgrid, CCGKey *key, void **gridfaces, DMFlagMat *flagmats, BLI_bitmap **grid_hidden)
static void node_tree_insert(node_tree *tree, node_tree *new_node)
void BKE_pbvh_sync_face_sets_to_grids(PBVH *pbvh)
static bool grid_materials_match(const DMFlagMat *f1, const DMFlagMat *f2)
void BKE_pbvh_node_fully_masked_set(PBVHNode *node, int fully_masked)
static int partition_indices(int *prim_indices, int lo, int hi, int axis, float mid, BBC *prim_bbc)
struct PBVHUpdateData PBVHUpdateData
void BKE_pbvh_node_get_original_BB(PBVHNode *node, float bb_min[3], float bb_max[3])
void BKE_pbvh_subdiv_cgg_set(PBVH *pbvh, SubdivCCG *subdiv_ccg)
void BKE_pbvh_node_mark_update_visibility(PBVHNode *node)
struct CCGElem ** BKE_pbvh_get_grids(const PBVH *pbvh)
void BKE_pbvh_node_mark_update_color(PBVHNode *node)
static void BKE_pbvh_search_callback_occluded(PBVH *pbvh, BKE_pbvh_SearchCallback scb, void *search_data, BKE_pbvh_HitOccludedCallback hcb, void *hit_data)
void BKE_pbvh_vert_coords_apply(PBVH *pbvh, const float(*vertCos)[3], const int totvert)
bool pbvh_has_mask(PBVH *pbvh)
void BKE_pbvh_get_frustum_planes(PBVH *pbvh, PBVHFrustumPlanes *planes)
static PBVHNode * pbvh_iter_next(PBVHIter *iter)
void BKE_pbvh_raycast_project_ray_root(PBVH *pbvh, bool original, float ray_start[3], float ray_end[3], float ray_normal[3])
void BKE_pbvh_gather_proxies(PBVH *pbvh, PBVHNode ***r_array, int *r_tot)
void BKE_pbvh_redraw_BB(PBVH *pbvh, float bb_min[3], float bb_max[3])
void BKE_pbvh_node_num_verts(PBVH *pbvh, PBVHNode *node, int *r_uniquevert, int *r_totvert)
void BB_expand_with_bb(BB *bb, BB *bb2)
static void pbvh_update_draw_buffer_cb(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
struct node_tree node_tree
void BKE_pbvh_node_fully_unmasked_set(PBVHNode *node, int fully_masked)
void BKE_pbvh_update_bounds(PBVH *pbvh, int flag)
void BKE_pbvh_draw_debug_cb(PBVH *pbvh, void(*draw_fn)(void *user_data, const float bmin[3], const float bmax[3], PBVHNodeFlags flag), void *user_data)
static void update_vb(PBVH *pbvh, PBVHNode *node, BBC *prim_bbc, int offset, int count)
static void build_sub(PBVH *pbvh, int node_index, BB *cb, BBC *prim_bbc, int offset, int count)
static void pbvh_faces_update_normals(PBVH *pbvh, PBVHNode **nodes, int totnode)
void BKE_pbvh_update_visibility(PBVH *pbvh)
static void pbvh_iter_begin(PBVHIter *iter, PBVH *pbvh, BKE_pbvh_SearchCallback scb, void *search_data)
void BKE_pbvh_get_grid_updates(PBVH *pbvh, bool clear, void ***r_gridfaces, int *r_totface)
MVert * BKE_pbvh_get_verts(const PBVH *pbvh)
void pbvh_show_mask_set(PBVH *pbvh, bool show_mask)
static int pbvh_flush_bb(PBVH *pbvh, PBVHNode *node, int flag)
static bool ray_aabb_intersect(PBVHNode *node, void *data_v)
static int pbvh_get_buffers_update_flags(PBVH *UNUSED(pbvh))
static bool nearest_to_ray_aabb_dist_sq(PBVHNode *node, void *data_v)
void BKE_pbvh_free(PBVH *pbvh)
int BB_widest_axis(const BB *bb)
void BKE_pbvh_node_get_BB(PBVHNode *node, float bb_min[3], float bb_max[3])
static bool leaf_needs_material_split(PBVH *pbvh, int offset, int count)
void BKE_pbvh_node_color_buffer_free(PBVH *pbvh)
static bool pbvh_grids_node_nearest_to_ray(PBVH *pbvh, PBVHNode *node, float(*origco)[3], const float ray_start[3], const float ray_normal[3], float *depth, float *dist_sq)
PBVHType BKE_pbvh_type(const PBVH *pbvh)
static void pbvh_update_visibility_redraw_task_cb(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
void pbvh_show_face_sets_set(PBVH *pbvh, bool show_face_sets)
bool ray_face_nearest_quad(const float ray_start[3], const float ray_normal[3], const float t0[3], const float t1[3], const float t2[3], const float t3[3], float *depth, float *dist_sq)
static bool pbvh_grids_node_raycast(PBVH *pbvh, PBVHNode *node, float(*origco)[3], const float ray_start[3], const float ray_normal[3], struct IsectRayPrecalc *isect_precalc, float *depth, int *r_active_vertex_index, int *r_active_grid_index, float *r_face_normal)
float BKE_pbvh_node_get_tmin(PBVHNode *node)
static bool pbvh_draw_search_cb(PBVHNode *node, void *data_v)
void pbvh_grow_nodes(PBVH *pbvh, int totnode)
void pbvh_update_BB_redraw(PBVH *pbvh, PBVHNode **nodes, int totnode, int flag)
static void pbvh_update_visibility(PBVH *pbvh, PBVHNode **nodes, int totnode)
bool ray_face_intersection_tri(const float ray_start[3], struct IsectRayPrecalc *isect_precalc, const float t0[3], const float t1[3], const float t2[3], float *depth)
void BKE_pbvh_node_mark_rebuild_draw(PBVHNode *node)
static void pbvh_update_visibility_redraw(PBVH *pbvh, PBVHNode **nodes, int totnode, int flag)
bool BKE_pbvh_node_raycast(PBVH *pbvh, PBVHNode *node, float(*origco)[3], bool use_origco, const float ray_start[3], const float ray_normal[3], struct IsectRayPrecalc *isect_precalc, float *depth, int *active_vertex_index, int *active_face_grid_index, float *face_normal)
void BKE_pbvh_node_mark_normals_update(PBVHNode *node)
void BKE_pbvh_face_sets_color_set(PBVH *pbvh, int seed, int color_default)
void BKE_pbvh_raycast(PBVH *pbvh, BKE_pbvh_HitOccludedCallback cb, void *data, const float ray_start[3], const float ray_normal[3], bool original)
void BKE_pbvh_update_vertex_data(PBVH *pbvh, int flag)
void BKE_pbvh_build_mesh(PBVH *pbvh, const Mesh *mesh, const MPoly *mpoly, const MLoop *mloop, MVert *verts, int totvert, struct CustomData *vdata, struct CustomData *ldata, struct CustomData *pdata, const MLoopTri *looptri, int looptri_num)
bool ray_face_intersection_quad(const float ray_start[3], struct IsectRayPrecalc *isect_precalc, const float t0[3], const float t1[3], const float t2[3], const float t3[3], float *depth)
void BKE_pbvh_draw_cb(PBVH *pbvh, bool update_only_visible, PBVHFrustumPlanes *update_frustum, PBVHFrustumPlanes *draw_frustum, void(*draw_fn)(void *user_data, GPU_PBVH_Buffers *buffers), void *user_data)
void BKE_pbvh_search_gather(PBVH *pbvh, BKE_pbvh_SearchCallback scb, void *search_data, PBVHNode ***r_array, int *r_tot)
static void pbvh_update_visibility_task_cb(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
static void pbvh_bmesh_node_visibility_update(PBVHNode *node)
struct PBVHDrawSearchData PBVHDrawSearchData
static bool pbvh_faces_node_nearest_to_ray(PBVH *pbvh, const PBVHNode *node, float(*origco)[3], const float ray_start[3], const float ray_normal[3], float *depth, float *dist_sq)
static void pbvh_update_normals_accum_task_cb(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
bool BKE_pbvh_is_deformed(PBVH *pbvh)
int BKE_pbvh_get_grid_num_vertices(const PBVH *pbvh)
int BKE_pbvh_count_grid_quads(BLI_bitmap **grid_hidden, const int *grid_indices, int totgrid, int gridsize)
void BKE_pbvh_update_normals(PBVH *pbvh, struct SubdivCCG *subdiv_ccg)
bool BKE_pbvh_node_find_nearest_to_ray(PBVH *pbvh, PBVHNode *node, float(*origco)[3], bool use_origco, const float ray_start[3], const float ray_normal[3], float *depth, float *dist_sq)
static void pbvh_update_mask_redraw_task_cb(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
static bool face_materials_match(const MPoly *f1, const MPoly *f2)
PBVHProxyNode * BKE_pbvh_node_add_proxy(PBVH *pbvh, PBVHNode *node)
static void build_leaf(PBVH *pbvh, int node_index, BBC *prim_bbc, int offset, int count)
bool BKE_pbvh_node_vert_update_check_any(PBVH *pbvh, PBVHNode *node)
static bool update_search_cb(PBVHNode *node, void *data_v)
static void pbvh_stack_push(PBVHIter *iter, PBVHNode *node, bool revisiting)
PBVH * BKE_pbvh_new(void)
static bool pbvh_faces_node_raycast(PBVH *pbvh, const PBVHNode *node, float(*origco)[3], const float ray_start[3], const float ray_normal[3], struct IsectRayPrecalc *isect_precalc, float *depth, int *r_active_vertex_index, int *r_active_face_index, float *r_face_normal)
bool BKE_pbvh_has_faces(const PBVH *pbvh)
bool BKE_pbvh_node_fully_hidden_get(PBVHNode *node)
static void build_grid_leaf_node(PBVH *pbvh, PBVHNode *node)
void BKE_pbvh_node_fully_hidden_set(PBVHNode *node, int fully_hidden)
void BKE_pbvh_grids_update(PBVH *pbvh, CCGElem **grids, void **gridfaces, DMFlagMat *flagmats, BLI_bitmap **grid_hidden)
bool BKE_pbvh_node_frustum_contain_AABB(PBVHNode *node, void *data)
static void pbvh_update_normals_store_task_cb(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
PBVHColorBufferNode * BKE_pbvh_node_color_buffer_get(PBVHNode *node)
static void pbvh_grids_node_visibility_update(PBVH *pbvh, PBVHNode *node)
const CCGKey * BKE_pbvh_get_grid_key(const PBVH *pbvh)
static void pbvh_faces_node_visibility_update(PBVH *pbvh, PBVHNode *node)
bool BKE_pbvh_node_frustum_exclude_AABB(PBVHNode *node, void *data)
void BKE_pbvh_respect_hide_set(PBVH *pbvh, bool respect_hide)
void BKE_pbvh_node_mark_update_mask(PBVHNode *node)
void BBC_update_centroid(BBC *bbc)
void BKE_pbvh_node_get_verts(PBVH *pbvh, PBVHNode *node, const int **r_vert_indices, MVert **r_verts)
static int map_insert_vert(PBVH *pbvh, GHash *map, unsigned int *face_verts, unsigned int *uniq_verts, int vertex)
bool BKE_pbvh_node_fully_unmasked_get(PBVHNode *node)
BMesh * BKE_pbvh_get_bmesh(PBVH *pbvh)
static void pbvh_update_BB_redraw_task_cb(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
BLI_bitmap ** BKE_pbvh_grid_hidden(const PBVH *pbvh)
static int partition_indices_material(PBVH *pbvh, int lo, int hi)
static void update_node_vb(PBVH *pbvh, PBVHNode *node)
void BKE_pbvh_bounding_box(const PBVH *pbvh, float min[3], float max[3])
void BKE_pbvh_search_callback(PBVH *pbvh, BKE_pbvh_SearchCallback scb, void *search_data, BKE_pbvh_HitCallback hcb, void *hit_data)
void BKE_pbvh_node_mark_redraw(PBVHNode *node)
#define STACK_FIXED_DEPTH
static PBVHNode * pbvh_iter_next_occluded(PBVHIter *iter)
static void traverse_tree(node_tree *tree, BKE_pbvh_HitOccludedCallback hcb, void *hit_data, float *tmin)
void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int mode)
void BKE_pbvh_node_get_grids(PBVH *pbvh, PBVHNode *node, int **r_grid_indices, int *r_totgrid, int *r_maxgrid, int *r_gridsize, CCGElem ***r_griddata)
struct PBVHStack PBVHStack
static void pbvh_update_mask_redraw(PBVH *pbvh, PBVHNode **nodes, int totnode, int flag)
void BKE_pbvh_face_sets_set(PBVH *pbvh, int *face_sets)
void BKE_pbvh_node_get_proxies(PBVHNode *node, PBVHProxyNode **proxies, int *proxy_count)
void BKE_pbvh_find_nearest_to_ray(PBVH *pbvh, BKE_pbvh_SearchNearestCallback cb, void *data, const float ray_start[3], const float ray_normal[3], bool original)
static void free_tree(node_tree *tree)
float(* BKE_pbvh_vert_coords_alloc(PBVH *pbvh))[3]
void BB_expand(BB *bb, const float co[3])
static void pbvh_update_draw_buffers(PBVH *pbvh, PBVHNode **nodes, int totnode, int update_flag)
void BKE_pbvh_parallel_range_settings(TaskParallelSettings *settings, bool use_threading, int totnode)
bool pbvh_has_face_sets(PBVH *pbvh)
bool pbvh_bmesh_node_nearest_to_ray(PBVHNode *node, const float ray_start[3], const float ray_normal[3], float *depth, float *dist_sq, bool use_original)
bool pbvh_bmesh_node_raycast(PBVHNode *node, const float ray_start[3], const float ray_normal[3], struct IsectRayPrecalc *isect_precalc, float *depth, bool use_original, int *r_active_vertex_index, float *r_face_normal)
void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode)
@ PBVH_DYNTOPO_SMOOTH_SHADING
struct DistRayAABB_Precalc dist_ray_to_aabb_precalc
int face_sets_color_default
PBVHFrustumPlanes * frustum
PBVHStack stackfixed[STACK_FIXED_DEPTH]
BKE_pbvh_SearchCallback scb
bool show_sculpt_face_sets
BLI_bitmap ** grid_hidden
struct GSetIterator bm_other_verts
struct GSetIterator bm_unique_verts
struct CustomData * bm_vdata
const DMFlagMat * grid_flag_mats
BLI_bitmap ** grid_hidden
struct SubdivCCG * subdiv_ccg
int face_sets_color_default
struct IsectRayAABB_Precalc ray