~ubuntu-branches/ubuntu/utopic/blender/utopic-proposed

« back to all changes in this revision

Viewing changes to source/blender/blenkernel/intern/pbvh_bmesh.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-19 11:24:23 UTC
  • mfrom: (14.2.23 sid)
  • Revision ID: package-import@ubuntu.com-20140219112423-rkmaz2m7ha06d4tk
Tags: 2.69-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure without OpenImageIO on armhf, as it is not available on
    Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 * ***** END GPL LICENSE BLOCK *****
19
19
 */
20
20
 
 
21
/** \file blender/blenkernel/intern/pbvh_bmesh.c
 
22
 *  \ingroup bli
 
23
 */
 
24
 
21
25
#include "MEM_guardedalloc.h"
22
26
 
23
27
#include "BLI_utildefines.h"
48
52
        PBVHNode *n = &bvh->nodes[node_index];
49
53
 
50
54
        /* Create vert hash sets */
51
 
        n->bm_unique_verts = BLI_ghash_ptr_new("bm_unique_verts");
52
 
        n->bm_other_verts = BLI_ghash_ptr_new("bm_other_verts");
 
55
        n->bm_unique_verts = BLI_gset_ptr_new("bm_unique_verts");
 
56
        n->bm_other_verts = BLI_gset_ptr_new("bm_other_verts");
53
57
 
54
58
        BB_reset(&n->vb);
55
59
 
67
71
                l_iter = l_first = BM_FACE_FIRST_LOOP(f);
68
72
                do {
69
73
                        v = l_iter->v;
70
 
                        if (!BLI_ghash_haskey(n->bm_unique_verts, v)) {
 
74
                        if (!BLI_gset_haskey(n->bm_unique_verts, v)) {
71
75
                                if (BLI_ghash_haskey(bvh->bm_vert_to_node, v)) {
72
 
                                        if (!BLI_ghash_haskey(n->bm_other_verts, v))
73
 
                                                BLI_ghash_insert(n->bm_other_verts, v, NULL);
 
76
                                        BLI_gset_reinsert(n->bm_other_verts, v, NULL);
74
77
                                }
75
78
                                else {
76
 
                                        BLI_ghash_insert(n->bm_unique_verts, v, NULL);
 
79
                                        BLI_gset_insert(n->bm_unique_verts, v);
77
80
                                        BLI_ghash_insert(bvh->bm_vert_to_node, v, node_val);
78
81
                                }
79
82
                        }
92
95
        if (!G.background) {
93
96
                int smooth = bvh->flags & PBVH_DYNTOPO_SMOOTH_SHADING;
94
97
                n->draw_buffers = GPU_build_bmesh_buffers(smooth);
95
 
                n->flag |= PBVH_UpdateDrawBuffers;
 
98
                n->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateNormals;
96
99
        }
97
100
}
98
101
 
101
104
{
102
105
        GHash *empty, *other;
103
106
        GHashIterator gh_iter;
 
107
        GSetIterator gs_iter;
104
108
        PBVHNode *n, *c1, *c2;
105
109
        BB cb;
106
110
        float mid;
140
144
        c2 = &bvh->nodes[children + 1];
141
145
        c1->flag |= PBVH_Leaf;
142
146
        c2->flag |= PBVH_Leaf;
143
 
        c1->bm_faces = BLI_ghash_ptr_new("bm_faces");
144
 
        c2->bm_faces = BLI_ghash_ptr_new("bm_faces");
 
147
        c1->bm_faces = BLI_ghash_ptr_new_ex("bm_faces", BLI_ghash_size(n->bm_faces) / 2);
 
148
        c2->bm_faces = BLI_ghash_ptr_new_ex("bm_faces", BLI_ghash_size(n->bm_faces) / 2);
145
149
 
146
150
        /* Partition the parent node's faces between the two children */
147
151
        GHASH_ITER (gh_iter, n->bm_faces) {
177
181
 
178
182
        /* Mark this node's unique verts as unclaimed */
179
183
        if (n->bm_unique_verts) {
180
 
                GHASH_ITER (gh_iter, n->bm_unique_verts) {
181
 
                        BMVert *v = BLI_ghashIterator_getKey(&gh_iter);
 
184
                GSET_ITER (gs_iter, n->bm_unique_verts) {
 
185
                        BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
182
186
                        BLI_ghash_remove(bvh->bm_vert_to_node, v, NULL, NULL);
183
187
                }
184
 
                BLI_ghash_free(n->bm_unique_verts, NULL, NULL);
 
188
                BLI_gset_free(n->bm_unique_verts, NULL);
185
189
        }
186
190
 
187
191
        /* Unclaim faces */
192
196
        BLI_ghash_free(n->bm_faces, NULL, NULL);
193
197
 
194
198
        if (n->bm_other_verts)
195
 
                BLI_ghash_free(n->bm_other_verts, NULL, NULL);
 
199
                BLI_gset_free(n->bm_other_verts, NULL);
196
200
 
197
201
        if (n->layer_disp)
198
202
                MEM_freeN(n->layer_disp);
227
231
static int pbvh_bmesh_node_limit_ensure(PBVH *bvh, int node_index)
228
232
{
229
233
        GHash *prim_bbc;
 
234
        GHash *bm_faces;
 
235
        int bm_faces_size;
230
236
        GHashIterator gh_iter;
 
237
        BBC *bbc_array;
 
238
        unsigned int i;
231
239
 
232
 
        if (BLI_ghash_size(bvh->nodes[node_index].bm_faces) <= bvh->leaf_limit) {
 
240
        bm_faces = bvh->nodes[node_index].bm_faces;
 
241
        bm_faces_size = BLI_ghash_size(bm_faces);
 
242
        if (bm_faces_size <= bvh->leaf_limit) {
233
243
                /* Node limit not exceeded */
234
244
                return FALSE;
235
245
        }
236
246
 
237
247
        /* For each BMFace, store the AABB and AABB centroid */
238
 
        prim_bbc = BLI_ghash_ptr_new("prim_bbc");
 
248
        prim_bbc = BLI_ghash_ptr_new_ex("prim_bbc", bm_faces_size);
 
249
        bbc_array = MEM_callocN(sizeof(BBC) * bm_faces_size, "BBC");
239
250
 
240
 
        GHASH_ITER (gh_iter, bvh->nodes[node_index].bm_faces) {
 
251
        GHASH_ITER_INDEX (gh_iter, bm_faces, i) {
241
252
                BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
242
 
                BBC *bbc = MEM_callocN(sizeof(BBC), "BBC");
 
253
                BBC *bbc = &bbc_array[i];
243
254
                BMLoop *l_iter;
244
255
                BMLoop *l_first;
245
256
 
255
266
 
256
267
        pbvh_bmesh_node_split(bvh, prim_bbc, node_index);
257
268
 
258
 
        BLI_ghash_free(prim_bbc, NULL, MEM_freeN);
 
269
        BLI_ghash_free(prim_bbc, NULL, NULL);
 
270
        MEM_freeN(bbc_array);
259
271
 
260
272
        return TRUE;
261
273
}
278
290
                                      const float co[3],
279
291
                                      const BMVert *example)
280
292
{
281
 
        BMVert *v = BM_vert_create(bvh->bm, co, example, 0);
 
293
        BMVert *v = BM_vert_create(bvh->bm, co, example, BM_CREATE_NOP);
282
294
        void *val = SET_INT_IN_POINTER(node_index);
283
295
 
284
296
        BLI_assert((bvh->totnode == 1 || node_index) && node_index <= bvh->totnode);
285
297
 
286
 
        BLI_ghash_insert(bvh->nodes[node_index].bm_unique_verts, v, NULL);
 
298
        BLI_gset_insert(bvh->nodes[node_index].bm_unique_verts, v);
287
299
        BLI_ghash_insert(bvh->bm_vert_to_node, v, val);
288
300
 
289
301
        /* Log the new vertex */
294
306
 
295
307
static BMFace *pbvh_bmesh_face_create(PBVH *bvh, int node_index,
296
308
                                      BMVert *v_tri[3], BMEdge *e_tri[3],
297
 
                                      const BMFace *UNUSED(example))
 
309
                                      const BMFace *f_example)
298
310
{
299
311
        BMFace *f;
300
312
        void *val = SET_INT_IN_POINTER(node_index);
302
314
        /* ensure we never add existing face */
303
315
        BLI_assert(BM_face_exists(v_tri, 3, NULL) == false);
304
316
 
305
 
        /* Note: passing NULL for the 'example' parameter, profiling shows
306
 
         * a small performance bump */
307
 
        f = BM_face_create(bvh->bm, v_tri, e_tri, 3, 0);
 
317
        f = BM_face_create(bvh->bm, v_tri, e_tri, 3, f_example, BM_CREATE_NOP);
 
318
 
308
319
        if (!BLI_ghash_haskey(bvh->bm_face_to_node, f)) {
309
320
 
310
321
                BLI_ghash_insert(bvh->nodes[node_index].bm_faces, f, NULL);
366
377
        BLI_assert(current_owner != new_owner);
367
378
 
368
379
        /* Remove current ownership */
369
 
        BLI_ghash_remove(bvh->bm_vert_to_node, v, NULL, NULL);
370
 
        BLI_ghash_remove(current_owner->bm_unique_verts, v, NULL, NULL);
 
380
        BLI_gset_remove(current_owner->bm_unique_verts, v, NULL);
371
381
 
372
382
        /* Set new ownership */
373
 
        BLI_ghash_insert(bvh->bm_vert_to_node, v,
374
 
                         SET_INT_IN_POINTER(new_owner - bvh->nodes));
375
 
        BLI_ghash_insert(new_owner->bm_unique_verts, v, NULL);
376
 
        BLI_ghash_remove(new_owner->bm_other_verts, v, NULL, NULL);
377
 
        BLI_assert(!BLI_ghash_haskey(new_owner->bm_other_verts, v));
 
383
        BLI_ghash_reinsert(bvh->bm_vert_to_node, v,
 
384
                           SET_INT_IN_POINTER(new_owner - bvh->nodes), NULL, NULL);
 
385
        BLI_gset_insert(new_owner->bm_unique_verts, v);
 
386
        BLI_gset_remove(new_owner->bm_other_verts, v, NULL);
 
387
        BLI_assert(!BLI_gset_haskey(new_owner->bm_other_verts, v));
378
388
}
379
389
 
380
390
static void pbvh_bmesh_vert_remove(PBVH *bvh, BMVert *v)
385
395
 
386
396
        BLI_assert(BLI_ghash_haskey(bvh->bm_vert_to_node, v));
387
397
        v_node = pbvh_bmesh_node_lookup(bvh, bvh->bm_vert_to_node, v);
388
 
        BLI_ghash_remove(v_node->bm_unique_verts, v, NULL, NULL);
 
398
        BLI_gset_remove(v_node->bm_unique_verts, v, NULL);
389
399
        BLI_ghash_remove(bvh->bm_vert_to_node, v, NULL, NULL);
390
400
 
391
401
        /* Have to check each neighboring face's node */
392
402
        BM_ITER_ELEM (f, &bm_iter, v, BM_FACES_OF_VERT) {
393
403
                PBVHNode *f_node = pbvh_bmesh_node_lookup(bvh, bvh->bm_face_to_node, f);
394
404
 
395
 
                BLI_ghash_remove(f_node->bm_unique_verts, v, NULL, NULL);
396
 
                BLI_ghash_remove(f_node->bm_other_verts, v, NULL, NULL);
 
405
                /* Remove current ownership */
 
406
                /* Should be handled above by vert_to_node removal, leaving just in case - psy-fi */
 
407
                //BLI_ghash_remove(f_node->bm_unique_verts, v, NULL, NULL);
 
408
                BLI_gset_remove(f_node->bm_other_verts, v, NULL);
397
409
 
398
 
                BLI_assert(!BLI_ghash_haskey(f_node->bm_unique_verts, v));
399
 
                BLI_assert(!BLI_ghash_haskey(f_node->bm_other_verts, v));
 
410
                BLI_assert(!BLI_gset_haskey(f_node->bm_unique_verts, v));
 
411
                BLI_assert(!BLI_gset_haskey(f_node->bm_other_verts, v));
400
412
        }
401
413
}
402
414
 
416
428
        do {
417
429
                v = l_iter->v;
418
430
                if (pbvh_bmesh_node_vert_use_count(bvh, f_node, v) == 1) {
419
 
                        if (BLI_ghash_haskey(f_node->bm_unique_verts, v)) {
 
431
                        if (BLI_gset_haskey(f_node->bm_unique_verts, v)) {
420
432
                                /* Find a different node that uses 'v' */
421
433
                                PBVHNode *new_node;
422
434
 
429
441
                        }
430
442
                        else {
431
443
                                /* Remove from other verts */
432
 
                                BLI_ghash_remove(f_node->bm_other_verts, v, NULL, NULL);
 
444
                                BLI_gset_remove(f_node->bm_other_verts, v, NULL);
433
445
                        }
434
446
                }
435
447
        } while ((l_iter = l_iter->next) != l_first);
478
490
        float limit_len_squared;
479
491
} EdgeQueue;
480
492
 
 
493
typedef struct {
 
494
        EdgeQueue *q;
 
495
        BLI_mempool *pool;
 
496
        BMesh *bm;
 
497
        int cd_vert_mask_offset;
 
498
} EdgeQueueContext;
 
499
 
481
500
static int edge_queue_tri_in_sphere(const EdgeQueue *q, BMFace *f)
482
501
{
483
502
        BMVert *v_tri[3];
493
512
        return ((len_squared_v3v3(q->center, c) <= q->radius_squared));
494
513
}
495
514
 
496
 
/* Return true if the vertex mask is less than 0.5, false otherwise */
497
 
static int check_mask_half(BMesh *bm, BMVert *v)
 
515
/* Return true if the vertex mask is less than 1.0, false otherwise */
 
516
static bool check_mask(EdgeQueueContext *eq_ctx, BMVert *v)
498
517
{
499
 
        const float *mask;
500
 
 
501
 
        mask = CustomData_bmesh_get(&bm->vdata, v->head.data, CD_PAINT_MASK);
502
 
        return ((*mask) < 0.5f);
 
518
        return (BM_ELEM_CD_GET_FLOAT(v, eq_ctx->cd_vert_mask_offset) < 1.0f);
503
519
}
504
520
 
505
 
static void edge_queue_insert(EdgeQueue *q, BLI_mempool *pool, BMEdge *e,
506
 
                              float priority, BMesh *bm)
 
521
static void edge_queue_insert(EdgeQueueContext *eq_ctx, BMEdge *e,
 
522
                              float priority)
507
523
{
508
524
        BMVert **pair;
509
525
 
510
 
        /* Don't let topology update affect masked vertices. Unlike with
511
 
         * displacements, can't do 50% topology update, so instead set
512
 
         * (arbitrary) cutoff: if both vertices' masks are less than 50%,
513
 
         * topology update can happen. */
514
 
        if (check_mask_half(bm, e->v1) && check_mask_half(bm, e->v2)) {
515
 
                pair = BLI_mempool_alloc(pool);
 
526
        /* Don't let topology update affect fully masked vertices. This used to
 
527
         * have a 50% mask cutoff, with the reasoning that you can't do a 50%
 
528
         * topology update. But this gives an ugly border in the mesh. The mask
 
529
         * should already make the brush move the vertices only 50%, which means
 
530
         * that topology updates will also happen less frequent, that should be
 
531
         * enough. */
 
532
        if (check_mask(eq_ctx, e->v1) || check_mask(eq_ctx, e->v2)) {
 
533
                pair = BLI_mempool_alloc(eq_ctx->pool);
516
534
                pair[0] = e->v1;
517
535
                pair[1] = e->v2;
518
 
                BLI_heap_insert(q->heap, priority, pair);
 
536
                BLI_heap_insert(eq_ctx->q->heap, priority, pair);
519
537
        }
520
538
}
521
539
 
522
 
static void long_edge_queue_edge_add(EdgeQueue *q, BLI_mempool *pool,
523
 
                                     BMEdge *e, BMesh *bm)
524
 
{
525
 
        const float len_sq = BM_edge_calc_length_squared(e);
526
 
        if (len_sq > q->limit_len_squared)
527
 
                edge_queue_insert(q, pool, e, 1.0f / len_sq, bm);
528
 
}
529
 
 
530
 
static void short_edge_queue_edge_add(EdgeQueue *q, BLI_mempool *pool,
531
 
                                      BMEdge *e, BMesh *bm)
532
 
{
533
 
        const float len_sq = BM_edge_calc_length_squared(e);
534
 
        if (len_sq < q->limit_len_squared)
535
 
                edge_queue_insert(q, pool, e, len_sq, bm);
536
 
}
537
 
 
538
 
static void long_edge_queue_face_add(EdgeQueue *q, BLI_mempool *pool,
539
 
                                     BMFace *f, BMesh *bm)
540
 
{
541
 
        if (edge_queue_tri_in_sphere(q, f)) {
 
540
static void long_edge_queue_edge_add(EdgeQueueContext *eq_ctx,
 
541
                                     BMEdge *e)
 
542
{
 
543
        const float len_sq = BM_edge_calc_length_squared(e);
 
544
        if (len_sq > eq_ctx->q->limit_len_squared)
 
545
                edge_queue_insert(eq_ctx, e, 1.0f / len_sq);
 
546
}
 
547
 
 
548
static void short_edge_queue_edge_add(EdgeQueueContext *eq_ctx,
 
549
                                      BMEdge *e)
 
550
{
 
551
        const float len_sq = BM_edge_calc_length_squared(e);
 
552
        if (len_sq < eq_ctx->q->limit_len_squared)
 
553
                edge_queue_insert(eq_ctx, e, len_sq);
 
554
}
 
555
 
 
556
static void long_edge_queue_face_add(EdgeQueueContext *eq_ctx,
 
557
                                     BMFace *f)
 
558
{
 
559
        if (edge_queue_tri_in_sphere(eq_ctx->q, f)) {
542
560
                BMLoop *l_iter;
543
561
                BMLoop *l_first;
544
562
 
545
563
                /* Check each edge of the face */
546
564
                l_iter = l_first = BM_FACE_FIRST_LOOP(f);
547
565
                do {
548
 
                        long_edge_queue_edge_add(q, pool, l_iter->e, bm);
 
566
                        long_edge_queue_edge_add(eq_ctx, l_iter->e);
549
567
                } while ((l_iter = l_iter->next) != l_first);
550
568
        }
551
569
}
552
570
 
553
 
static void short_edge_queue_face_add(EdgeQueue *q, BLI_mempool *pool,
554
 
                                      BMFace *f, BMesh *bm)
 
571
static void short_edge_queue_face_add(EdgeQueueContext *eq_ctx,
 
572
                                      BMFace *f)
555
573
{
556
 
        if (edge_queue_tri_in_sphere(q, f)) {
 
574
        if (edge_queue_tri_in_sphere(eq_ctx->q, f)) {
557
575
                BMLoop *l_iter;
558
576
                BMLoop *l_first;
559
577
 
560
578
                /* Check each edge of the face */
561
579
                l_iter = l_first = BM_FACE_FIRST_LOOP(f);
562
580
                do {
563
 
                        short_edge_queue_edge_add(q, pool, l_iter->e, bm);
 
581
                        short_edge_queue_edge_add(eq_ctx, l_iter->e);
564
582
                } while ((l_iter = l_iter->next) != l_first);
565
583
        }
566
584
}
574
592
 *
575
593
 * The highest priority (lowest number) is given to the longest edge.
576
594
 */
577
 
static void long_edge_queue_create(EdgeQueue *q, BLI_mempool *pool,
 
595
static void long_edge_queue_create(EdgeQueueContext *eq_ctx,
578
596
                                   PBVH *bvh, const float center[3],
579
597
                                   float radius)
580
598
{
581
599
        int n;
582
600
 
583
 
        q->heap = BLI_heap_new();
584
 
        q->center = center;
585
 
        q->radius_squared = radius * radius;
586
 
        q->limit_len_squared = bvh->bm_max_edge_len * bvh->bm_max_edge_len;
 
601
        eq_ctx->q->heap = BLI_heap_new();
 
602
        eq_ctx->q->center = center;
 
603
        eq_ctx->q->radius_squared = radius * radius;
 
604
        eq_ctx->q->limit_len_squared = bvh->bm_max_edge_len * bvh->bm_max_edge_len;
587
605
 
588
606
        for (n = 0; n < bvh->totnode; n++) {
589
607
                PBVHNode *node = &bvh->nodes[n];
598
616
                        GHASH_ITER (gh_iter, node->bm_faces) {
599
617
                                BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
600
618
 
601
 
                                long_edge_queue_face_add(q, pool, f, bvh->bm);
 
619
                                long_edge_queue_face_add(eq_ctx, f);
602
620
                        }
603
621
                }
604
622
        }
613
631
 *
614
632
 * The highest priority (lowest number) is given to the shortest edge.
615
633
 */
616
 
static void short_edge_queue_create(EdgeQueue *q, BLI_mempool *pool,
 
634
static void short_edge_queue_create(EdgeQueueContext *eq_ctx,
617
635
                                    PBVH *bvh, const float center[3],
618
636
                                    float radius)
619
637
{
620
638
        int n;
621
639
 
622
 
        q->heap = BLI_heap_new();
623
 
        q->center = center;
624
 
        q->radius_squared = radius * radius;
625
 
        q->limit_len_squared = bvh->bm_min_edge_len * bvh->bm_min_edge_len;
 
640
        eq_ctx->q->heap = BLI_heap_new();
 
641
        eq_ctx->q->center = center;
 
642
        eq_ctx->q->radius_squared = radius * radius;
 
643
        eq_ctx->q->limit_len_squared = bvh->bm_min_edge_len * bvh->bm_min_edge_len;
626
644
 
627
645
        for (n = 0; n < bvh->totnode; n++) {
628
646
                PBVHNode *node = &bvh->nodes[n];
637
655
                        GHASH_ITER (gh_iter, node->bm_faces) {
638
656
                                BMFace *f = BLI_ghashIterator_getKey(&gh_iter);
639
657
 
640
 
                                short_edge_queue_face_add(q, pool, f, bvh->bm);
 
658
                                short_edge_queue_face_add(eq_ctx, f);
641
659
                        }
642
660
                }
643
661
        }
652
670
        e_tri[2] = BM_edge_create(bm, v_tri[2], v_tri[0], NULL, BM_CREATE_NO_DOUBLE);
653
671
}
654
672
 
655
 
static void pbvh_bmesh_split_edge(PBVH *bvh, EdgeQueue *q, BLI_mempool *pool,
 
673
static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx, PBVH *bvh,
656
674
                                  BMEdge *e, BLI_Buffer *edge_loops)
657
675
{
658
676
        BMVert *v_new;
659
677
        float mid[3];
660
678
        int i, node_index;
 
679
        const int cd_vert_mask_offset = CustomData_get_offset(&bvh->bm->vdata, CD_PAINT_MASK);
661
680
 
662
681
        /* Get all faces adjacent to the edge */
663
682
        pbvh_bmesh_edge_loops(edge_loops, e);
669
688
                                                           e->v1));
670
689
        v_new = pbvh_bmesh_vert_create(bvh, node_index, mid, e->v1);
671
690
 
 
691
        /* update paint mask */
 
692
        if (cd_vert_mask_offset != -1) {
 
693
                float mask_v1 = BM_ELEM_CD_GET_FLOAT(e->v1, cd_vert_mask_offset);
 
694
                float mask_v2 = BM_ELEM_CD_GET_FLOAT(e->v2, cd_vert_mask_offset);
 
695
                float mask_v_new = 0.5f*(mask_v1 + mask_v2);
 
696
 
 
697
                BM_ELEM_CD_SET_FLOAT(v_new, cd_vert_mask_offset, mask_v_new);
 
698
        }
 
699
 
672
700
        /* For each face, add two new triangles and delete the original */
673
701
        for (i = 0; i < edge_loops->count; i++) {
674
702
                BMLoop *l_adj = BLI_buffer_at(edge_loops, BMLoop *, i);
685
713
                ni = GET_INT_FROM_POINTER(nip);
686
714
 
687
715
                /* Ensure node gets redrawn */
688
 
                bvh->nodes[ni].flag |= PBVH_UpdateDrawBuffers;
 
716
                bvh->nodes[ni].flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateNormals;
689
717
 
690
718
                /* Find the vertex not in the edge */
691
719
                v_opp = l_adj->prev->v;
705
733
                v_tri[2] = v_opp;
706
734
                bm_edges_from_tri(bvh->bm, v_tri, e_tri);
707
735
                f_new = pbvh_bmesh_face_create(bvh, ni, v_tri, e_tri, f_adj);
708
 
                long_edge_queue_face_add(q, pool, f_new, bvh->bm);
 
736
                long_edge_queue_face_add(eq_ctx, f_new);
709
737
 
710
738
                v_tri[0] = v_new;
711
739
                v_tri[1] = v2;
714
742
                e_tri[2] = e_tri[1];  /* switched */
715
743
                e_tri[1] = BM_edge_create(bvh->bm, v_tri[1], v_tri[2], NULL, BM_CREATE_NO_DOUBLE);
716
744
                f_new = pbvh_bmesh_face_create(bvh, ni, v_tri, e_tri, f_adj);
717
 
                long_edge_queue_face_add(q, pool, f_new, bvh->bm);
 
745
                long_edge_queue_face_add(eq_ctx, f_new);
718
746
 
719
747
                /* Delete original */
720
748
                pbvh_bmesh_face_remove(bvh, f_adj);
721
749
                BM_face_kill(bvh->bm, f_adj);
722
750
 
723
751
                /* Ensure new vertex is in the node */
724
 
                if (!BLI_ghash_haskey(bvh->nodes[ni].bm_unique_verts, v_new) &&
725
 
                        !BLI_ghash_haskey(bvh->nodes[ni].bm_other_verts, v_new))
 
752
                if (!BLI_gset_haskey(bvh->nodes[ni].bm_unique_verts, v_new) &&
 
753
                        !BLI_gset_haskey(bvh->nodes[ni].bm_other_verts, v_new))
726
754
                {
727
 
                        BLI_ghash_insert(bvh->nodes[ni].bm_other_verts, v_new, NULL);
 
755
                        BLI_gset_insert(bvh->nodes[ni].bm_other_verts, v_new);
728
756
                }
729
757
 
730
758
                if (BM_vert_edge_count(v_opp) >= 9) {
732
760
                        BMEdge *e2;
733
761
 
734
762
                        BM_ITER_ELEM (e2, &bm_iter, v_opp, BM_EDGES_OF_VERT) {
735
 
                                long_edge_queue_edge_add(q, pool, e2, bvh->bm);
 
763
                                long_edge_queue_edge_add(eq_ctx, e2);
736
764
                        }
737
765
                }
738
766
        }
740
768
        BM_edge_kill(bvh->bm, e);
741
769
}
742
770
 
743
 
static int pbvh_bmesh_subdivide_long_edges(PBVH *bvh, EdgeQueue *q,
744
 
                                           BLI_mempool *pool,
 
771
static int pbvh_bmesh_subdivide_long_edges(EdgeQueueContext *eq_ctx, PBVH *bvh,
745
772
                                           BLI_Buffer *edge_loops)
746
773
{
747
774
        int any_subdivided = FALSE;
748
775
 
749
 
        while (!BLI_heap_is_empty(q->heap)) {
750
 
                BMVert **pair = BLI_heap_popmin(q->heap);
 
776
        while (!BLI_heap_is_empty(eq_ctx->q->heap)) {
 
777
                BMVert **pair = BLI_heap_popmin(eq_ctx->q->heap);
751
778
                BMEdge *e;
752
779
 
753
780
                /* Check that the edge still exists */
754
781
                if (!(e = BM_edge_exists(pair[0], pair[1]))) {
755
 
                        BLI_mempool_free(pool, pair);
 
782
                        BLI_mempool_free(eq_ctx->pool, pair);
756
783
                        continue;
757
784
                }
758
785
 
759
 
                BLI_mempool_free(pool, pair);
 
786
                BLI_mempool_free(eq_ctx->pool, pair);
760
787
                pair = NULL;
761
788
 
762
789
                /* Check that the edge's vertices are still in the PBVH. It's
769
796
                        continue;
770
797
                }
771
798
 
772
 
                if (BM_edge_calc_length_squared(e) <= q->limit_len_squared)
 
799
                if (BM_edge_calc_length_squared(e) <= eq_ctx->q->limit_len_squared)
773
800
                        continue;
774
801
 
775
802
                any_subdivided = TRUE;
776
803
 
777
 
                pbvh_bmesh_split_edge(bvh, q, pool, e, edge_loops);
 
804
                pbvh_bmesh_split_edge(eq_ctx, bvh, e, edge_loops);
778
805
        }
779
806
 
780
807
        return any_subdivided;
845
872
                        pbvh_bmesh_face_create(bvh, ni, v_tri, e_tri, f);
846
873
 
847
874
                        /* Ensure that v1 is in the new face's node */
848
 
                        if (!BLI_ghash_haskey(n->bm_unique_verts, v1) &&
849
 
                            !BLI_ghash_haskey(n->bm_other_verts,  v1))
 
875
                        if (!BLI_gset_haskey(n->bm_unique_verts, v1) &&
 
876
                            !BLI_gset_haskey(n->bm_other_verts,  v1))
850
877
                        {
851
 
                                BLI_ghash_insert(n->bm_other_verts, v1, NULL);
 
878
                                BLI_gset_insert(n->bm_other_verts, v1);
852
879
                        }
853
880
                }
854
881
 
916
943
        BM_vert_kill(bvh->bm, v2);
917
944
}
918
945
 
919
 
static int pbvh_bmesh_collapse_short_edges(PBVH *bvh, EdgeQueue *q,
920
 
                                           BLI_mempool *pool,
 
946
static int pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx,
 
947
                                           PBVH *bvh,
921
948
                                           BLI_Buffer *edge_loops,
922
949
                                           BLI_Buffer *deleted_faces)
923
950
{
927
954
 
928
955
        deleted_verts = BLI_ghash_ptr_new("deleted_verts");
929
956
 
930
 
        while (!BLI_heap_is_empty(q->heap)) {
931
 
                BMVert **pair = BLI_heap_popmin(q->heap);
 
957
        while (!BLI_heap_is_empty(eq_ctx->q->heap)) {
 
958
                BMVert **pair = BLI_heap_popmin(eq_ctx->q->heap);
932
959
                BMEdge *e;
933
960
                BMVert *v1, *v2;
934
961
 
935
962
                v1 = pair[0];
936
963
                v2 = pair[1];
937
 
                BLI_mempool_free(pool, pair);
 
964
                BLI_mempool_free(eq_ctx->pool, pair);
938
965
                pair = NULL;
939
966
 
940
967
                /* Check that the vertices/edge still exist */
1011
1038
        return hit;
1012
1039
}
1013
1040
 
 
1041
 
1014
1042
void pbvh_bmesh_normals_update(PBVHNode **nodes, int totnode)
1015
1043
{
1016
1044
        int n;
1017
1045
 
1018
1046
        for (n = 0; n < totnode; n++) {
1019
1047
                PBVHNode *node = nodes[n];
1020
 
                GHashIterator gh_iter;
1021
 
 
1022
 
                GHASH_ITER (gh_iter, node->bm_faces) {
1023
 
                        BM_face_normal_update(BLI_ghashIterator_getKey(&gh_iter));
1024
 
                }
1025
 
                GHASH_ITER (gh_iter, node->bm_unique_verts) {
1026
 
                        BM_vert_normal_update(BLI_ghashIterator_getKey(&gh_iter));
 
1048
 
 
1049
                if (node->flag & PBVH_UpdateNormals) {
 
1050
                        GHashIterator gh_iter;
 
1051
                        GSetIterator gs_iter;
 
1052
 
 
1053
                        GHASH_ITER (gh_iter, node->bm_faces) {
 
1054
                                BM_face_normal_update(BLI_ghashIterator_getKey(&gh_iter));
 
1055
                        }
 
1056
                        GSET_ITER (gs_iter, node->bm_unique_verts) {
 
1057
                                BM_vert_normal_update(BLI_gsetIterator_getKey(&gs_iter));
 
1058
                        }
 
1059
                        /* This should be unneeded normally */
 
1060
                        GSET_ITER (gs_iter, node->bm_other_verts) {
 
1061
                                BM_vert_normal_update(BLI_gsetIterator_getKey(&gs_iter));
 
1062
                        }
 
1063
                        node->flag &= ~PBVH_UpdateNormals;
1027
1064
                }
1028
1065
        }
1029
1066
}
1058
1095
        n = bvh->nodes = MEM_callocN(sizeof(PBVHNode), "PBVHNode");
1059
1096
        bvh->totnode = 1;
1060
1097
        n->flag = PBVH_Leaf;
1061
 
        n->bm_faces = BLI_ghash_ptr_new("bm_faces");
 
1098
        n->bm_faces = BLI_ghash_ptr_new_ex("bm_faces", bvh->bm->totface);
1062
1099
        BM_ITER_MESH (f, &iter, bvh->bm, BM_FACES_OF_MESH) {
1063
1100
                BLI_ghash_insert(n->bm_faces, f, NULL);
1064
1101
        }
1076
1113
        /* 2 is enough for edge faces - manifold edge */
1077
1114
        BLI_buffer_declare_static(BMFace *, edge_loops, BLI_BUFFER_NOP, 2);
1078
1115
        BLI_buffer_declare_static(BMFace *, deleted_faces, BLI_BUFFER_NOP, 32);
 
1116
        const int cd_vert_mask_offset = CustomData_get_offset(&bvh->bm->vdata, CD_PAINT_MASK);
1079
1117
 
1080
1118
        int modified = FALSE;
1081
1119
        int n;
1082
1120
 
1083
1121
        if (mode & PBVH_Collapse) {
1084
1122
                EdgeQueue q;
1085
 
                BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert) * 2,
 
1123
                BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert *[2]),
1086
1124
                                                             128, 128, 0);
1087
 
                short_edge_queue_create(&q, queue_pool, bvh, center, radius);
1088
 
                pbvh_bmesh_collapse_short_edges(bvh, &q, queue_pool, &edge_loops,
 
1125
                EdgeQueueContext eq_ctx = {&q, queue_pool, bvh->bm, cd_vert_mask_offset};
 
1126
 
 
1127
                short_edge_queue_create(&eq_ctx, bvh, center, radius);
 
1128
                pbvh_bmesh_collapse_short_edges(&eq_ctx, bvh, &edge_loops,
1089
1129
                                                &deleted_faces);
1090
1130
                BLI_heap_free(q.heap, NULL);
1091
1131
                BLI_mempool_destroy(queue_pool);
1093
1133
 
1094
1134
        if (mode & PBVH_Subdivide) {
1095
1135
                EdgeQueue q;
1096
 
                BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert) * 2,
 
1136
                BLI_mempool *queue_pool = BLI_mempool_create(sizeof(BMVert *[2]),
1097
1137
                                                             128, 128, 0);
1098
 
                long_edge_queue_create(&q, queue_pool, bvh, center, radius);
1099
 
                pbvh_bmesh_subdivide_long_edges(bvh, &q, queue_pool, &edge_loops);
 
1138
                EdgeQueueContext eq_ctx = {&q, queue_pool, bvh->bm, cd_vert_mask_offset};
 
1139
 
 
1140
                long_edge_queue_create(&eq_ctx, bvh, center, radius);
 
1141
                pbvh_bmesh_subdivide_long_edges(&eq_ctx, bvh, &edge_loops);
1100
1142
                BLI_heap_free(q.heap, NULL);
1101
1143
                BLI_mempool_destroy(queue_pool);
1102
1144
        }
1135
1177
void BKE_pbvh_bmesh_node_save_orig(PBVHNode *node)
1136
1178
{
1137
1179
        GHashIterator gh_iter;
 
1180
        GSetIterator gs_iter;
1138
1181
        int i, totvert, tottri;
1139
1182
 
1140
1183
        /* Skip if original coords/triangles are already saved */
1141
1184
        if (node->bm_orco)
1142
1185
                return;
1143
1186
 
1144
 
        totvert = (BLI_ghash_size(node->bm_unique_verts) +
1145
 
                   BLI_ghash_size(node->bm_other_verts));
 
1187
        totvert = (BLI_gset_size(node->bm_unique_verts) +
 
1188
                   BLI_gset_size(node->bm_other_verts));
1146
1189
 
1147
1190
        tottri = BLI_ghash_size(node->bm_faces);
1148
1191
 
1151
1194
 
1152
1195
        /* Copy out the vertices and assign a temporary index */
1153
1196
        i = 0;
1154
 
        GHASH_ITER (gh_iter, node->bm_unique_verts) {
1155
 
                BMVert *v = BLI_ghashIterator_getKey(&gh_iter);
 
1197
        GSET_ITER (gs_iter, node->bm_unique_verts) {
 
1198
                BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
1156
1199
                copy_v3_v3(node->bm_orco[i], v->co);
1157
1200
                BM_elem_index_set(v, i); /* set_dirty! */
1158
1201
                i++;
1159
1202
        }
1160
 
        GHASH_ITER (gh_iter, node->bm_other_verts) {
1161
 
                BMVert *v = BLI_ghashIterator_getKey(&gh_iter);
 
1203
        GSET_ITER (gs_iter, node->bm_other_verts) {
 
1204
                BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
1162
1205
                copy_v3_v3(node->bm_orco[i], v->co);
1163
1206
                BM_elem_index_set(v, i); /* set_dirty! */
1164
1207
                i++;
1215
1258
        node->flag |= PBVH_UpdateTopology;
1216
1259
}
1217
1260
 
1218
 
GHash *BKE_pbvh_bmesh_node_unique_verts(PBVHNode *node)
 
1261
GSet *BKE_pbvh_bmesh_node_unique_verts(PBVHNode *node)
1219
1262
{
1220
1263
        return node->bm_unique_verts;
1221
1264
}
1222
1265
 
1223
 
GHash *BKE_pbvh_bmesh_node_other_verts(PBVHNode *node)
 
1266
GSet *BKE_pbvh_bmesh_node_other_verts(PBVHNode *node)
1224
1267
{
1225
1268
        return node->bm_other_verts;
1226
1269
}
1249
1292
        }
1250
1293
}
1251
1294
 
 
1295
void bli_gset_duplicate_key_check(GSet *gs)
 
1296
{
 
1297
        GSetIterator gs_iter1, gs_iter2;
 
1298
 
 
1299
        GSET_ITER (gs_iter1, gs) {
 
1300
                void *key1 = BLI_gsetIterator_getKey(&gs_iter1);
 
1301
                int dup = -1;
 
1302
 
 
1303
                GSET_ITER (gs_iter2, gs) {
 
1304
                        void *key2 = BLI_gsetIterator_getKey(&gs_iter2);
 
1305
 
 
1306
                        if (key1 == key2) {
 
1307
                                dup++;
 
1308
                                if (dup > 0) {
 
1309
                                        BLI_assert(!"duplicate in hash");
 
1310
                                }
 
1311
                        }
 
1312
                }
 
1313
        }
 
1314
}
 
1315
 
1252
1316
void bmesh_print(BMesh *bm)
1253
1317
{
1254
1318
        BMIter iter, siter;
1263
1327
                bm->totloop, bm->totface);
1264
1328
 
1265
1329
        fprintf(stderr, "vertices:\n");
1266
 
        BM_ITER_MESH(v, &iter, bm, BM_VERTS_OF_MESH) {
 
1330
        BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
1267
1331
                fprintf(stderr, "  %d co=(%.3f %.3f %.3f) oflag=%x\n",
1268
1332
                        BM_elem_index_get(v), v->co[0], v->co[1], v->co[2],
1269
1333
                        v->oflags[bm->stackdepth - 1].f);
1270
1334
        }
1271
1335
 
1272
1336
        fprintf(stderr, "edges:\n");
1273
 
        BM_ITER_MESH(e, &iter, bm, BM_EDGES_OF_MESH) {
 
1337
        BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
1274
1338
                fprintf(stderr, "  %d v1=%d, v2=%d, oflag=%x\n",
1275
1339
                        BM_elem_index_get(e),
1276
1340
                        BM_elem_index_get(e->v1),
1279
1343
        }
1280
1344
 
1281
1345
        fprintf(stderr, "faces:\n");
1282
 
        BM_ITER_MESH(f, &iter, bm, BM_FACES_OF_MESH) {
 
1346
        BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
1283
1347
                fprintf(stderr, "  %d len=%d, oflag=%x\n",
1284
1348
                        BM_elem_index_get(f), f->len,
1285
1349
                        f->oflags[bm->stackdepth - 1].f);
1310
1374
void pbvh_bmesh_print(PBVH *bvh)
1311
1375
{
1312
1376
        GHashIterator gh_iter;
 
1377
        GSetIterator gs_iter;
1313
1378
        int n;
1314
1379
 
1315
1380
        fprintf(stderr, "\npbvh=%p\n", bvh);
1337
1402
                        fprintf(stderr, "    %d\n",
1338
1403
                                BM_elem_index_get((BMFace *)BLI_ghashIterator_getKey(&gh_iter)));
1339
1404
                fprintf(stderr, "  unique verts:\n");
1340
 
                GHASH_ITER (gh_iter, node->bm_unique_verts)
 
1405
                GSET_ITER (gs_iter, node->bm_unique_verts)
1341
1406
                        fprintf(stderr, "    %d\n",
1342
 
                                BM_elem_index_get((BMVert *)BLI_ghashIterator_getKey(&gh_iter)));
 
1407
                                BM_elem_index_get((BMVert *)BLI_gsetIterator_getKey(&gs_iter)));
1343
1408
                fprintf(stderr, "  other verts:\n");
1344
 
                GHASH_ITER (gh_iter, node->bm_other_verts)
 
1409
                GSET_ITER (gs_iter, node->bm_other_verts)
1345
1410
                        fprintf(stderr, "    %d\n",
1346
 
                                BM_elem_index_get((BMVert *)BLI_ghashIterator_getKey(&gh_iter)));
 
1411
                                BM_elem_index_get((BMVert *)BLI_gsetIterator_getKey(&gs_iter)));
1347
1412
        }
1348
1413
}
1349
1414
 
1361
1426
void pbvh_bmesh_verify(PBVH *bvh)
1362
1427
{
1363
1428
        GHashIterator gh_iter;
1364
 
        int i;
 
1429
        GSetIterator gs_iter;
 
1430
        int i, vert_count = 0;
 
1431
        BMIter iter;
 
1432
        BMVert *vi;
1365
1433
 
1366
1434
        /* Check faces */
1367
1435
        BLI_assert(bvh->bm->totface == BLI_ghash_size(bvh->bm_face_to_node));
1384
1452
                        PBVHNode *nv;
1385
1453
 
1386
1454
                        /* Check that the vertex is in the node */
1387
 
                        BLI_assert(BLI_ghash_haskey(n->bm_unique_verts, v) ^
1388
 
                                   BLI_ghash_haskey(n->bm_other_verts, v));
 
1455
                        BLI_assert(BLI_gset_haskey(n->bm_unique_verts, v) ^
 
1456
                                   BLI_gset_haskey(n->bm_other_verts, v));
1389
1457
 
1390
1458
                        /* Check that the vertex has a node owner */
1391
1459
                        nv = pbvh_bmesh_node_lookup(bvh, bvh->bm_vert_to_node, v);
1392
1460
 
1393
1461
                        /* Check that the vertex's node knows it owns the vert */
1394
 
                        BLI_assert(BLI_ghash_haskey(nv->bm_unique_verts, v));
 
1462
                        BLI_assert(BLI_gset_haskey(nv->bm_unique_verts, v));
1395
1463
 
1396
1464
                        /* Check that the vertex isn't duplicated as an 'other' vert */
1397
 
                        BLI_assert(!BLI_ghash_haskey(nv->bm_other_verts, v));
 
1465
                        BLI_assert(!BLI_gset_haskey(nv->bm_other_verts, v));
1398
1466
                }
1399
1467
        }
1400
1468
 
1413
1481
                BLI_assert(n->flag & PBVH_Leaf);
1414
1482
 
1415
1483
                /* Check that the vert's node knows it owns the vert */
1416
 
                BLI_assert(BLI_ghash_haskey(n->bm_unique_verts, v));
 
1484
                BLI_assert(BLI_gset_haskey(n->bm_unique_verts, v));
1417
1485
 
1418
1486
                /* Check that the vertex isn't duplicated as an 'other' vert */
1419
 
                BLI_assert(!BLI_ghash_haskey(n->bm_other_verts, v));
 
1487
                BLI_assert(!BLI_gset_haskey(n->bm_other_verts, v));
1420
1488
 
1421
1489
                /* Check that the vert's node also contains one of the vert's
1422
1490
                 * adjacent faces */
1427
1495
                        }
1428
1496
                }
1429
1497
                BLI_assert(found);
1430
 
        }
 
1498
 
 
1499
                #if 1
 
1500
                /* total freak stuff, check if node exists somewhere else */
 
1501
                /* Slow */
 
1502
                for (i = 0; i < bvh->totnode; i++) {
 
1503
                        PBVHNode *n = &bvh->nodes[i];
 
1504
                        if (i != ni && n->bm_unique_verts)
 
1505
                                BLI_assert(!BLI_gset_haskey(n->bm_unique_verts, v));
 
1506
                }
 
1507
 
 
1508
                #endif
 
1509
        }
 
1510
 
 
1511
        #if 0
 
1512
        /* check that every vert belongs somewhere */
 
1513
        /* Slow */
 
1514
        BM_ITER_MESH (vi, &iter, bvh->bm, BM_VERTS_OF_MESH) {
 
1515
                bool has_unique = false;
 
1516
                for (i = 0; i < bvh->totnode; i++) {
 
1517
                        PBVHNode *n = &bvh->nodes[i];
 
1518
                        if ((n->bm_unique_verts != NULL) && BLI_gset_haskey(n->bm_unique_verts, vi))
 
1519
                                has_unique = true;
 
1520
                }
 
1521
                BLI_assert(has_unique);
 
1522
                vert_count++;
 
1523
        }
 
1524
 
 
1525
        /* if totvert differs from number of verts inside the hash. hash-totvert is checked above  */
 
1526
        BLI_assert(vert_count == bvh->bm->totvert);
 
1527
        #endif
1431
1528
 
1432
1529
        /* Check that node elements are recorded in the top level */
1433
1530
        for (i = 0; i < bvh->totnode; i++) {
1437
1534
                        /* Slow */
1438
1535
                        #if 0
1439
1536
                        bli_ghash_duplicate_key_check(n->bm_faces);
1440
 
                        bli_ghash_duplicate_key_check(n->bm_unique_verts);
1441
 
                        bli_ghash_duplicate_key_check(n->bm_other_verts);
 
1537
                        bli_gset_duplicate_key_check(n->bm_unique_verts);
 
1538
                        bli_gset_duplicate_key_check(n->bm_other_verts);
1442
1539
                        #endif
1443
1540
 
1444
1541
                        GHASH_ITER (gh_iter, n->bm_faces) {
1448
1545
                                BLI_assert(GET_INT_FROM_POINTER(nip) == (n - bvh->nodes));
1449
1546
                        }
1450
1547
 
1451
 
                        GHASH_ITER (gh_iter, n->bm_unique_verts) {
1452
 
                                BMVert *v = BLI_ghashIterator_getKey(&gh_iter);
 
1548
                        GSET_ITER (gs_iter, n->bm_unique_verts) {
 
1549
                                BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
1453
1550
                                void *nip = BLI_ghash_lookup(bvh->bm_vert_to_node, v);
1454
1551
                                BLI_assert(BLI_ghash_haskey(bvh->bm_vert_to_node, v));
1455
 
                                BLI_assert(!BLI_ghash_haskey(n->bm_other_verts, v));
 
1552
                                BLI_assert(!BLI_gset_haskey(n->bm_other_verts, v));
1456
1553
                                BLI_assert(GET_INT_FROM_POINTER(nip) == (n - bvh->nodes));
1457
1554
                        }
1458
1555
 
1459
 
                        GHASH_ITER (gh_iter, n->bm_other_verts) {
1460
 
                                BMVert *v = BLI_ghashIterator_getKey(&gh_iter);
 
1556
                        GSET_ITER (gs_iter, n->bm_other_verts) {
 
1557
                                BMVert *v = BLI_gsetIterator_getKey(&gs_iter);
1461
1558
                                BLI_assert(BLI_ghash_haskey(bvh->bm_vert_to_node, v));
1462
1559
                                BLI_assert(BM_vert_face_count(v) > 0);
1463
1560
                        }