Sculpt-dev: fix missing NULL assignment

This commit is contained in:
Joseph Eagar 2021-11-13 16:17:16 -08:00
parent a72721a2ae
commit c88701178b
5 changed files with 34 additions and 18 deletions

View File

@ -431,7 +431,7 @@ void BKE_pbvh_draw_cb(PBVH *pbvh,
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 (*draw_fn)(void *user_data, const float bmin[3], const float bmax[3], PBVHNodeFlags flag, int depth),
void *user_data);
/* PBVH Access */

View File

@ -3312,7 +3312,7 @@ extern bool pbvh_show_orig_co;
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 (*draw_fn)(void *user_data, const float bmin[3], const float bmax[3], PBVHNodeFlags flag, int depth),
void *user_data)
{
for (int a = 0; a < pbvh->totnode; a++) {
@ -3321,10 +3321,10 @@ void BKE_pbvh_draw_debug_cb(
int num = a + node->updategen;
if (pbvh_show_orig_co) {
draw_fn(&num, node->orig_vb.bmin, node->orig_vb.bmax, node->flag);
draw_fn(&num, node->orig_vb.bmin, node->orig_vb.bmax, node->flag, node->depth);
}
else {
draw_fn(&num, node->vb.bmin, node->vb.bmax, node->flag);
draw_fn(&num, node->vb.bmin, node->vb.bmax, node->flag, node->depth);
}
}
}

View File

@ -339,6 +339,14 @@ static void pbvh_print_mem_size(PBVH *pbvh)
memsize2[1],
memsize2[2],
memsize2[3]);
#ifdef WITH_BM_ID_FREELIST
if (bm->idmap.free_idx_map) {
printf("free_idx_map: nentries %d, size %d\n",
bm->idmap.free_idx_map->nentries,
bm->idmap.free_idx_map->nbuckets);
}
#endif
}
/* Recursively split the node if it exceeds the leaf_limit */
@ -394,6 +402,7 @@ static void pbvh_bmesh_node_split(
c1->flag |= PBVH_Leaf;
c2->flag |= PBVH_Leaf;
c1->bm_faces = BLI_table_gset_new_ex("bm_faces", BLI_table_gset_len(n->bm_faces) / 2);
c2->bm_faces = BLI_table_gset_new_ex("bm_faces", BLI_table_gset_len(n->bm_faces) / 2);
@ -1581,8 +1590,8 @@ static void pbvh_bmesh_create_nodes_fast_recursive_create(PBVH *pbvh,
n->children_offset = children_offset;
n->depth = node->depth;
(n + 1)->depth = node->depth + 1;
(n + 2)->depth = node->depth + 1;
(n + 1)->depth = node->child1->depth;
(n + 2)->depth = node->child2->depth;
node->child1->node_index = children_offset;
node->child2->node_index = children_offset + 1;
@ -3846,6 +3855,8 @@ void BKE_pbvh_bmesh_after_stroke(PBVH *pbvh, bool force_balance)
}
}
}
pbvh_print_mem_size(pbvh);
}
void BKE_pbvh_bmesh_detail_size_set(PBVH *pbvh, float detail_size, float detail_range)

View File

@ -54,7 +54,7 @@
static void bm_id_freelist_check_hashmap(BMesh *bm)
{
if (!bm->idmap.free_idx_map && bm->idmap.freelist_len >= FREELIST_HASHMAP_THRESHOLD_HIGH) {
printf("switching on freelist idx map");
printf("switching on freelist idx map\n");
bm->idmap.free_idx_map = MEM_callocN(sizeof(SmallHash), "free_idx_map");
BLI_smallhash_init_ex(bm->idmap.free_idx_map, bm->idmap.freelist_len);
@ -66,8 +66,9 @@ static void bm_id_freelist_check_hashmap(BMesh *bm)
else if (bm->idmap.free_idx_map && bm->idmap.freelist_len <= FREELIST_HASHMAP_THRESHOLD_LOW) {
BLI_smallhash_release(bm->idmap.free_idx_map);
MEM_freeN(bm->idmap.free_idx_map);
bm->idmap.free_idx_map = NULL;
printf("switching off freelist idx map");
printf("switching off freelist idx map\n");
}
}
@ -126,6 +127,8 @@ void bm_id_freelist_take(BMesh *bm, uint id)
bm->idmap.freelist[i] = bm->idmap.freelist[bm->idmap.freelist_len - 1];
bm->idmap.freelist_len--;
}
BLI_smallhash_remove(bm->idmap.free_idx_map, (uintptr_t)id);
}
else {
for (int i = 0; i < bm->idmap.freelist_len; i++) {
@ -273,7 +276,7 @@ void bm_free_id(BMesh *bm, BMElem *elem)
range_tree_uint_release(bm->idmap.idtree, id);
}
#else
bm_id_freelist_push(bm, id);
#endif
if ((bm->idmap.flag & BM_HAS_ID_MAP)) {

View File

@ -966,8 +966,7 @@ static void sculpt_draw_cb(DRWSculptCallbackData *scd, GPU_PBVH_Buffers *buffers
if (SCULPT_DEBUG_BUFFERS) {
/* Color each buffers in different colors. Only work in solid/Xray mode. */
shgrp = DRW_shgroup_create_sub(shgrp);
DRW_shgroup_uniform_vec3(
shgrp, "materialDiffuseColor", SCULPT_DEBUG_COLOR(scd->debug_node_nr++), 1);
DRW_shgroup_uniform_vec3(shgrp, "materialDiffuseColor", SCULPT_DEBUG_COLOR(scd->debug_node_nr++), 1);
}
#if 0
float extramat[4][4], mat[4][4];
@ -989,10 +988,8 @@ static void sculpt_draw_cb(DRWSculptCallbackData *scd, GPU_PBVH_Buffers *buffers
}
}
static void sculpt_debug_cb(void *user_data,
const float bmin[3],
const float bmax[3],
PBVHNodeFlags flag)
static void sculpt_debug_cb(
void *user_data, const float bmin[3], const float bmax[3], PBVHNodeFlags flag, int depth)
{
int *debug_node_nr = (int *)user_data;
BoundBox bb;
@ -1007,7 +1004,12 @@ static void sculpt_debug_cb(void *user_data,
}
#else /* Color coded leaf bounds. */
if (flag & PBVH_Leaf) {
DRW_debug_bbox(&bb, SCULPT_DEBUG_COLOR((*debug_node_nr)++));
float color[4];
copy_v4_v4(color, SCULPT_DEBUG_COLOR((*debug_node_nr)++));
mul_v3_fl(color, 1.0f - fminf((float)depth / 16.0f, 1.0f));
DRW_debug_bbox(&bb, color);
}
#endif
}
@ -1100,8 +1102,8 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd)
DRW_debug_modelmat(scd->ob->obmat);
BKE_pbvh_draw_debug_cb(
pbvh,
(void (*)(
void *d, const float min[3], const float max[3], PBVHNodeFlags f))sculpt_debug_cb,
(void (*)(void *d, const float min[3], const float max[3], PBVHNodeFlags f, int depth))
sculpt_debug_cb,
&debug_node_nr);
}
}