Blender V5.3
bmesh_log.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
19
20#include "MEM_guardedalloc.h"
21
22#include "BLI_listbase.hh"
23#include "BLI_map.hh"
24#include "BLI_math_vector_c.hh"
25#include "BLI_pool.hh"
26#include "BLI_utildefines.hh"
27
28#include "BKE_customdata.hh"
29
30#include "bmesh.hh"
31#include "bmesh_log.hh"
32
33#include "range_tree.h"
34
35#include "BLI_strict_flags.hh" /* IWYU pragma: keep. Keep last. */
36
37namespace blender {
38
39struct BMLogFace;
40struct BMLogVert;
41
75
107
114
115struct BMLogFace {
116 std::array<uint, 3> v_ids;
117 char hflag;
118};
119
120/* -------------------------------------------------------------------- */
123
124/* Get the vertex's unique ID from the log */
126{
127 return log->elem_to_id.lookup(reinterpret_cast<BMElem *>(v));
128}
129
130/* Set the vertex's unique ID in the log */
131static void bm_log_vert_id_set(BMLog *log, BMVert *v, const uint id)
132{
133 log->id_to_elem.add_overwrite(id, reinterpret_cast<BMElem *>(v));
134 log->elem_to_id.add_overwrite(reinterpret_cast<BMElem *>(v), id);
135}
136
137/* Get a vertex from its unique ID */
139{
140 return reinterpret_cast<BMVert *>(log->id_to_elem.lookup(id));
141}
142
143/* Get the face's unique ID from the log */
145{
146 return log->elem_to_id.lookup(reinterpret_cast<BMElem *>(f));
147}
148
149/* Set the face's unique ID in the log */
150static void bm_log_face_id_set(BMLog *log, BMFace *f, const uint id)
151{
152 log->id_to_elem.add_overwrite(id, reinterpret_cast<BMElem *>(f));
153 log->elem_to_id.add_overwrite(reinterpret_cast<BMElem *>(f), id);
154}
155
156/* Get a face from its unique ID */
158{
159 return reinterpret_cast<BMFace *>(log->id_to_elem.lookup(id));
160}
161
163
164/* -------------------------------------------------------------------- */
167
168/* Get a vertex's paint-mask value
169 *
170 * Returns zero if no paint-mask layer is present */
171static float vert_mask_get(BMVert *v, const int cd_vert_mask_offset)
172{
173 if (cd_vert_mask_offset != -1) {
174 return BM_ELEM_CD_GET_FLOAT(v, cd_vert_mask_offset);
175 }
176 return 0.0f;
177}
178
179/* Set a vertex's paint-mask value
180 *
181 * Has no effect is no paint-mask layer is present */
182static void vert_mask_set(BMVert *v, const float new_mask, const int cd_vert_mask_offset)
183{
184 if (cd_vert_mask_offset != -1) {
185 BM_ELEM_CD_SET_FLOAT(v, cd_vert_mask_offset, new_mask);
186 }
187}
188
189/* Update a BMLogVert with data from a BMVert */
190static void bm_log_vert_bmvert_copy(BMLogVert *lv, BMVert *v, const int cd_vert_mask_offset)
191{
192 copy_v3_v3(lv->position, v->co);
193 copy_v3_v3(lv->normal, v->no);
194 lv->mask = vert_mask_get(v, cd_vert_mask_offset);
195 lv->hflag = v->head.hflag;
196}
197
198/* Allocate and initialize a BMLogVert */
199static BMLogVert *bm_log_vert_alloc(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
200{
201 BMLogEntry *entry = log->current_entry;
202 BMLogVert *lv = &entry->vert_pool.construct();
203 entry->allocated_verts.append(lv);
204
205 bm_log_vert_bmvert_copy(lv, v, cd_vert_mask_offset);
206
207 return lv;
208}
209
210/* Allocate and initialize a BMLogFace */
212{
213 BMLogEntry *entry = log->current_entry;
214 BMLogFace *lf = &entry->face_pool.construct();
215 entry->allocated_faces.append(lf);
216 BMVert *v[3];
217
218 BLI_assert(f->len == 3);
219
220 // BM_iter_as_array(nullptr, BM_VERTS_OF_FACE, f, (void **)v, 3);
222
223 lf->v_ids[0] = bm_log_vert_id_get(log, v[0]);
224 lf->v_ids[1] = bm_log_vert_id_get(log, v[1]);
225 lf->v_ids[2] = bm_log_vert_id_get(log, v[2]);
226
227 lf->hflag = f->head.hflag;
228 return lf;
229}
230
232
233/* -------------------------------------------------------------------- */
236
238{
239 const int cd_vert_mask_offset = CustomData_get_offset_named(
240 &bm->vdata, CD_PROP_FLOAT, ".sculpt_mask");
241
242 for (const auto item : verts.items()) {
243 BMVert *v = bm_log_vert_from_id(log, item.key);
244
245 /* Ensure the log has the final values of the vertex before
246 * deleting it */
247 bm_log_vert_bmvert_copy(item.value, v, cd_vert_mask_offset);
248
249 BM_vert_kill(bm, v);
250 }
251}
252
254{
255 for (const uint id : faces.keys()) {
257 std::array<BMEdge *, 3> e_tri;
258
259 BMLoop *l_iter = BM_FACE_FIRST_LOOP(f);
260 for (uint i = 0; i < e_tri.size(); i++, l_iter = l_iter->next) {
261 e_tri[i] = l_iter->e;
262 }
263
264 /* Remove any unused edges */
265 BM_face_kill(bm, f);
266 for (uint i = 0; i < e_tri.size(); i++) {
267 if (BM_edge_is_wire(e_tri[i])) {
268 BM_edge_kill(bm, e_tri[i]);
269 }
270 }
271 }
272}
273
275{
276 const int cd_vert_mask_offset = CustomData_get_offset_named(
277 &bm->vdata, CD_PROP_FLOAT, ".sculpt_mask");
278
279 for (const auto item : verts.items()) {
280 BMLogVert *lv = item.value;
281 BMVert *v = BM_vert_create(bm, lv->position, nullptr, BM_CREATE_NOP);
282 vert_mask_set(v, lv->mask, cd_vert_mask_offset);
283 v->head.hflag = lv->hflag;
284 copy_v3_v3(v->no, lv->normal);
285 bm_log_vert_id_set(log, v, item.key);
286 }
287}
288
290{
291 const int cd_face_sets = CustomData_get_offset_named(
292 &bm->pdata, CD_PROP_INT32, ".sculpt_face_set");
293
294 for (const auto item : faces.items()) {
295 BMLogFace *lf = item.value;
296 BMVert *v[3] = {
300 };
301
302 BMFace *f = BM_face_create_verts(bm, v, 3, nullptr, BM_CREATE_NOP, true);
303 f->head.hflag = lf->hflag;
304 bm_log_face_id_set(log, f, item.key);
305
306 /* Ensure face sets have valid values. Fixes #80174. */
307 if (cd_face_sets != -1) {
308 BM_ELEM_CD_SET_INT(f, cd_face_sets, 1);
309 }
310 }
311}
312
314{
315 const int cd_vert_mask_offset = CustomData_get_offset_named(
316 &bm->vdata, CD_PROP_FLOAT, ".sculpt_mask");
317
318 for (const auto item : verts.items()) {
319 BMLogVert *lv = item.value;
320 BMVert *v = bm_log_vert_from_id(log, item.key);
321
322 swap_v3_v3(v->co, lv->position);
323 swap_v3_v3(v->no, lv->normal);
324 std::swap(v->head.hflag, lv->hflag);
325 float mask = lv->mask;
326 lv->mask = vert_mask_get(v, cd_vert_mask_offset);
327 vert_mask_set(v, mask, cd_vert_mask_offset);
328 }
329}
330
332{
333
334 for (const auto item : faces.items()) {
335 BMLogFace *lf = item.value;
336 BMFace *f = bm_log_face_from_id(log, item.key);
337
338 std::swap(f->head.hflag, lf->hflag);
339 }
340}
341
342/* Assign unique IDs to all vertices and faces already in the BMesh */
344{
345 BMIter iter;
346
347 BMVert *v;
348 /* Generate vertex IDs */
349 BM_ITER_MESH (v, &iter, bm, BM_VERTS_OF_MESH) {
350 uint id = range_tree_uint_take_any(log->unused_ids);
352 }
353
354 BMFace *f;
355 /* Generate face IDs */
356 BM_ITER_MESH (f, &iter, bm, BM_FACES_OF_MESH) {
357 uint id = range_tree_uint_take_any(log->unused_ids);
358 bm_log_face_id_set(log, f, id);
359 }
360}
361
362/* Allocate an empty log entry */
364{
365 BMLogEntry *entry = MEM_new<BMLogEntry>(__func__);
366
367 return entry;
368}
369
370/* Free the data in a log entry
371 *
372 * NOTE: does not free the log entry itself. */
373static void bm_log_entry_free(BMLogEntry *entry)
374{
375 BLI_assert(entry->vert_pool.size() == entry->allocated_verts.size());
376 BLI_assert(entry->face_pool.size() == entry->allocated_faces.size());
377
378 for (BMLogVert *log_vert : entry->allocated_verts) {
379 entry->vert_pool.destruct(*log_vert);
380 }
381
382 for (BMLogFace *log_face : entry->allocated_faces) {
383 entry->face_pool.destruct(*log_face);
384 }
385
386 BLI_assert(entry->vert_pool.is_empty());
387 BLI_assert(entry->face_pool.is_empty());
388}
389
391
392/* -------------------------------------------------------------------- */
395
397{
398 BMLog *log = MEM_new<BMLog>(__func__);
399 const uint reserve_num = uint(bm->totvert + bm->totface);
400
401 log->unused_ids = range_tree_uint_alloc(0, uint(-1));
402 log->id_to_elem.reserve(reserve_num);
403 log->elem_to_id.reserve(reserve_num);
404
405 /* Assign IDs to all existing vertices and faces */
407
408 return log;
409}
410
412{
413 BMLog *log = entry->log;
414
415 if (log) {
416 /* Take all used IDs */
417 for (const uint id : entry->deleted_verts.keys()) {
418 range_tree_uint_retake(log->unused_ids, id);
419 }
420 for (const uint id : entry->deleted_faces.keys()) {
421 range_tree_uint_retake(log->unused_ids, id);
422 }
423 for (const uint id : entry->added_verts.keys()) {
424 range_tree_uint_retake(log->unused_ids, id);
425 }
426 for (const uint id : entry->added_faces.keys()) {
427 range_tree_uint_retake(log->unused_ids, id);
428 }
429 for (const uint id : entry->modified_verts.keys()) {
430 range_tree_uint_retake(log->unused_ids, id);
431 }
432 for (const uint id : entry->modified_faces.keys()) {
433 range_tree_uint_retake(log->unused_ids, id);
434 }
435
436 /* delete entries to avoid releasing ids in node cleanup */
437 entry->deleted_verts.clear();
438 entry->deleted_faces.clear();
439 entry->added_verts.clear();
440 entry->added_faces.clear();
441 entry->modified_verts.clear();
442
443 /* Is this last one needed? */
444 entry->modified_faces.clear();
445 }
446}
447
449{
451
452 if (entry->prev) {
453 log->current_entry = entry;
454 }
455 else {
456 log->current_entry = nullptr;
457 }
458
459 /* Let BMLog manage the entry list again */
460 log->entries.first_ = log->entries.last_ = entry;
461
462 {
463 while (entry->prev) {
464 entry = entry->prev;
465 log->entries.first_ = entry;
466 }
467 entry = log->entries.last();
468 while (entry->next) {
469 entry = entry->next;
470 log->entries.last_ = entry;
471 }
472 }
473
474 for (entry = log->entries.first(); entry; entry = entry->next) {
475 entry->log = log;
476
477 /* Take all used IDs */
478 for (const uint id : entry->deleted_verts.keys()) {
479 range_tree_uint_retake(log->unused_ids, id);
480 }
481 for (const uint id : entry->deleted_faces.keys()) {
482 range_tree_uint_retake(log->unused_ids, id);
483 }
484 for (const uint id : entry->added_verts.keys()) {
485 range_tree_uint_retake(log->unused_ids, id);
486 }
487 for (const uint id : entry->added_faces.keys()) {
488 range_tree_uint_retake(log->unused_ids, id);
489 }
490 for (const uint id : entry->modified_verts.keys()) {
491 range_tree_uint_retake(log->unused_ids, id);
492 }
493 for (const uint id : entry->modified_faces.keys()) {
494 range_tree_uint_retake(log->unused_ids, id);
495 }
496 }
497
498 return log;
499}
500
502{
503 if (log->unused_ids) {
504 range_tree_uint_free(log->unused_ids);
505 }
506
507 /* Clear the BMLog references within each entry, but do not free
508 * the entries themselves */
509 for (BMLogEntry &entry : log->entries) {
510 entry.log = nullptr;
511 }
512
513 MEM_delete(log);
514}
515
517{
518 /* WARNING: Deleting any entries after the current one is now handled by the
519 * UndoSystem: BKE_UNDOSYS_TYPE_SCULPT freeing here causes unnecessary complications. */
520
521 /* Create and append the new entry */
523 BLI_addtail(&log->entries, entry);
524 entry->log = log;
525 log->current_entry = entry;
526
527 return entry;
528}
529
531{
532 BMLog *log = entry->log;
533
534 if (!log) {
535 /* Unlink */
536 BLI_assert(!(entry->prev && entry->next));
537 if (entry->prev) {
538 entry->prev->next = nullptr;
539 }
540 else if (entry->next) {
541 entry->next->prev = nullptr;
542 }
543
544 bm_log_entry_free(entry);
545 MEM_delete(entry);
546 return;
547 }
548
549 if (!entry->prev) {
550 /* Release IDs of elements that are deleted by this
551 * entry. Since the entry is at the beginning of the undo
552 * stack, and it's being deleted, those elements can never be
553 * restored. Their IDs can go back into the pool. */
554
555 /* This would never happen usually since first entry of log is
556 * usually dyntopo enable, which, when reverted will free the log
557 * completely. However, it is possible have a stroke instead of
558 * dyntopo enable as first entry if nodes have been cleaned up
559 * after sculpting on a different object than A, B.
560 *
561 * The steps are:
562 * A dyntopo enable - sculpt
563 * B dyntopo enable - sculpt - undo (A objects operators get cleaned up)
564 * A sculpt (now A's log has a sculpt operator as first entry)
565 *
566 * Causing a cleanup at this point will call the code below, however
567 * this will invalidate the state of the log since the deleted vertices
568 * have been reclaimed already on step 2 (see BM_log_cleanup_entry)
569 *
570 * Also, design wise, a first entry should not have any deleted vertices since it
571 * should not have anything to delete them -from-
572 */
573 // bm_log_id_ghash_release(log, entry->deleted_faces);
574 // bm_log_id_ghash_release(log, entry->deleted_verts);
575 }
576 else if (!entry->next) {
577 /* Release IDs of elements that are added by this entry. Since
578 * the entry is at the end of the undo stack, and it's being
579 * deleted, those elements can never be restored. Their IDs
580 * can go back into the pool. */
581 for (const uint id : entry->added_faces.keys()) {
582 range_tree_uint_release(log->unused_ids, id);
583 }
584 for (const uint id : entry->added_verts.keys()) {
585 range_tree_uint_release(log->unused_ids, id);
586 }
587 }
588 else {
589 BLI_assert_msg(0, "Cannot drop BMLogEntry from middle");
590 }
591
592 if (log->current_entry == entry) {
593 log->current_entry = entry->prev;
594 }
595
596 bm_log_entry_free(entry);
597 BLI_remlink(&log->entries, entry);
598 MEM_delete(entry);
599}
600
602{
603 BMLogEntry *entry = log->current_entry;
604
605 if (entry) {
606 log->current_entry = entry->prev;
607
608 /* Delete added faces and verts */
611
612 /* Restore deleted verts and faces */
615
616 /* Restore vertex coordinates, mask, and hflag */
619 }
620}
621
623{
624 BMLogEntry *entry = log->current_entry;
625
626 if (!entry) {
627 /* Currently at the beginning of the undo stack, move to first entry */
628 entry = log->entries.first();
629 }
630 else if (entry->next) {
631 /* Move to next undo entry */
632 entry = entry->next;
633 }
634 else {
635 /* Currently at the end of the undo stack, nothing left to redo */
636 return;
637 }
638
639 log->current_entry = entry;
640
641 if (entry) {
642 /* Re-delete previously deleted faces and verts */
645
646 /* Restore previously added verts and faces */
649
650 /* Restore vertex coordinates, mask, and hflag */
653 }
654}
655
656void BM_log_vert_before_modified(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
657{
658 BMLogEntry *entry = log->current_entry;
659 const uint v_id = bm_log_vert_id_get(log, v);
660
661 /* Find or create the BMLogVert entry */
662 if (entry->added_verts.contains(v_id)) {
663 bm_log_vert_bmvert_copy(entry->added_verts.lookup(v_id), v, cd_vert_mask_offset);
664 }
665 else {
666 entry->modified_verts.lookup_or_add_cb(
667 v_id, [&] { return bm_log_vert_alloc(log, v, cd_vert_mask_offset); });
668 }
669}
670
671void BM_log_vert_added(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
672{
673 const uint v_id = range_tree_uint_take_any(log->unused_ids);
674
675 bm_log_vert_id_set(log, v, v_id);
676 BMLogVert *lv = bm_log_vert_alloc(log, v, cd_vert_mask_offset);
677 log->current_entry->added_verts.add(v_id, lv);
678}
679
681{
682 const uint f_id = bm_log_face_id_get(log, f);
683
685 log->current_entry->modified_faces.add(f_id, lf);
686}
687
689{
690 const uint f_id = range_tree_uint_take_any(log->unused_ids);
691
692 /* Only triangles are supported for now */
693 BLI_assert(f->len == 3);
694
695 bm_log_face_id_set(log, f, f_id);
697 log->current_entry->added_faces.add(f_id, lf);
698}
699
700void BM_log_vert_removed(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
701{
702 BMLogEntry *entry = log->current_entry;
703 const uint v_id = bm_log_vert_id_get(log, v);
704
705 BLI_assert(!entry->added_verts.contains(v_id) ||
706 (entry->added_verts.contains(v_id) && entry->added_verts.lookup(v_id) != nullptr));
707
708 if (entry->added_verts.remove(v_id)) {
709 range_tree_uint_release(log->unused_ids, v_id);
710 }
711 else {
712 BMLogVert *lv = bm_log_vert_alloc(log, v, cd_vert_mask_offset);
713 entry->deleted_verts.add(v_id, lv);
714
715 /* If the vertex was modified before deletion, ensure that the
716 * original vertex values are stored */
717 if (std::optional<BMLogVert *> lv_mod = entry->modified_verts.lookup_try(v_id)) {
718 *lv = *lv_mod.value();
719 entry->modified_verts.remove(v_id);
720 }
721 }
722}
723
725{
726 BMLogEntry *entry = log->current_entry;
727 const uint f_id = bm_log_face_id_get(log, f);
728
729 BLI_assert(!entry->added_faces.contains(f_id) ||
730 (entry->added_faces.contains(f_id) && entry->added_faces.lookup(f_id) != nullptr));
731
732 if (entry->added_faces.remove(f_id)) {
733 range_tree_uint_release(log->unused_ids, f_id);
734 }
735 else {
737 entry->deleted_faces.add(f_id, lf);
738 }
739}
740
742{
743 const int cd_vert_mask_offset = CustomData_get_offset_named(
744 &bm->vdata, CD_PROP_FLOAT, ".sculpt_mask");
745
746 /* avoid unnecessary resizing on initialization */
747 if (log->current_entry->added_verts.is_empty()) {
748 log->current_entry->added_verts.reserve(bm->totvert);
749 }
750
751 if (log->current_entry->added_faces.is_empty()) {
752 log->current_entry->added_faces.reserve(bm->totface);
753 }
754
755 BMIter bm_iter;
756 BMVert *v;
757 /* Log all vertices as newly created */
758 BM_ITER_MESH (v, &bm_iter, bm, BM_VERTS_OF_MESH) {
759 BM_log_vert_added(log, v, cd_vert_mask_offset);
760 }
761
762 BMFace *f;
763 /* Log all faces as newly created */
764 BM_ITER_MESH (f, &bm_iter, bm, BM_FACES_OF_MESH) {
766 }
767}
768
770{
771 const int cd_vert_mask_offset = CustomData_get_offset_named(
772 &bm->vdata, CD_PROP_FLOAT, ".sculpt_mask");
773
774 BMIter bm_iter;
775 BMFace *f;
776 /* Log deletion of all faces */
777 BM_ITER_MESH (f, &bm_iter, bm, BM_FACES_OF_MESH) {
779 }
780
781 BMVert *v;
782 /* Log deletion of all vertices */
783 BM_ITER_MESH (v, &bm_iter, bm, BM_VERTS_OF_MESH) {
784 BM_log_vert_removed(log, v, cd_vert_mask_offset);
785 }
786}
787
789{
790 BMLogEntry *entry = log->current_entry;
791 const uint v_id = bm_log_vert_id_get(log, v);
792
793 if (std::optional<BMLogVert *> log_vert = entry->modified_verts.lookup_try(v_id)) {
794 return log_vert.value()->position;
795 }
796 return nullptr;
797}
798
800{
801 BMLogEntry *entry = log->current_entry;
802 const uint v_id = bm_log_vert_id_get(log, v);
803
804 if (std::optional<BMLogVert *> log_vert = entry->modified_verts.lookup_try(v_id)) {
805 return &log_vert.value()->mask;
806 }
807 return nullptr;
808}
809
810void BM_log_original_vert_data(BMLog *log, BMVert *v, const float **r_co, const float **r_no)
811{
812 BMLogEntry *entry = log->current_entry;
813 BLI_assert(entry);
814
815 const uint v_id = bm_log_vert_id_get(log, v);
816
817 BLI_assert(entry->modified_verts.contains(v_id));
818
819 const BMLogVert *lv = entry->modified_verts.lookup(v_id);
820 *r_co = lv->position;
821 *r_no = lv->normal;
822}
823
825
826/* -------------------------------------------------------------------- */
829
830#ifndef NDEBUG
832{
833 return log->current_entry;
834}
835
837{
838 return log->unused_ids;
839}
840
841/* Print the list of entries, marking the current one
842 *
843 * Keep around for debugging */
844void BM_log_print(const BMLog *log, const char *description)
845{
846 const BMLogEntry *entry;
847 const char *current = " <-- current";
848 int i;
849
850 printf("%s:\n", description);
851 printf(" % 2d: [ initial ]%s\n", 0, (!log->current_entry) ? current : "");
852 for (entry = log->entries.first(), i = 1; entry; entry = entry->next, i++) {
853 printf(" % 2d: [%p]%s\n", i, entry, (entry == log->current_entry) ? current : "");
854 }
855}
856
858{
859 if (bm) {
860 printf("BM { totvert=%d totedge=%d totloop=%d faces_num=%d\n",
861 bm->totvert,
862 bm->totedge,
863 bm->totloop,
864 bm->totface);
865
866 if (!bm->totvert) {
867 printf("%s: Warning: empty bmesh\n", __func__);
868 }
869 }
870 else {
871 printf("BM { totvert=unknown totedge=unknown totloop=unknown faces_num=unknown\n");
872 }
873
874 printf("v | added: %d, removed: %d, modified: %d\n",
875 int(entry->added_verts.size()),
876 int(entry->deleted_verts.size()),
877 int(entry->modified_verts.size()));
878 printf("f | added: %d, removed: %d, modified: %d\n",
879 int(entry->added_faces.size()),
880 int(entry->deleted_faces.size()),
881 int(entry->modified_faces.size()));
882 printf("}\n");
883}
884#endif
885
887
888} // namespace blender
CustomData interface, see also DNA_customdata_types.h.
Read Blender memory allocation and freeing.
#define BLI_assert_msg(a, msg)
#define BM_ELEM_CD_SET_FLOAT(ele, offset, f)
#define BM_ELEM_CD_GET_FLOAT(ele, offset)
#define BM_ELEM_CD_SET_INT(ele, offset, f)
#define BM_FACE_FIRST_LOOP(p)
#define BM_ITER_MESH(ele, iter, bm, itype)
KeyIterator keys() const &
Definition BLI_map.hh:875
ItemIterator items() const &
Definition BLI_map.hh:902
#define log
BMesh Iterators.
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
BMFace * BM_face_create_verts(BMesh *bm, BMVert **vert_arr, const int len, const BMFace *f_example, const eBMCreateFlag create_flag, const bool create_edges)
BMLogEntry * BM_log_current_entry(BMLog *log)
Definition bmesh_log.cc:831
void BM_log_face_added(BMLog *log, BMFace *f)
Definition bmesh_log.cc:688
BLI_INLINE bool BM_edge_is_wire(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
static BMLogFace * bm_log_face_alloc(BMLog *log, BMFace *f)
Definition bmesh_log.cc:211
static void bm_log_assign_ids(BMesh *bm, BMLog *log)
Definition bmesh_log.cc:343
MINLINE void copy_v3_v3(float r[3], const float a[3])
unsigned int uint
Definition BKE_text.h:55
static void bm_log_entry_free(BMLogEntry *entry)
Definition bmesh_log.cc:373
void BM_log_original_vert_data(BMLog *log, BMVert *v, const float **r_co, const float **r_no)
Definition bmesh_log.cc:810
void BM_vert_kill(BMesh *bm, BMVert *v)
void BM_log_print(const BMLog *log, const char *description)
Definition bmesh_log.cc:844
static uint bm_log_face_id_get(BMLog *log, BMFace *f)
Definition bmesh_log.cc:144
void BM_log_vert_added(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
Definition bmesh_log.cc:671
void BM_log_redo(BMesh *bm, BMLog *log)
Definition bmesh_log.cc:622
static void bm_log_face_values_swap(BMLog *log, const Map< uint, BMLogFace *, 0 > &faces)
Definition bmesh_log.cc:331
void BM_log_free(BMLog *log)
Definition bmesh_log.cc:501
ATTR_WARN_UNUSED_RESULT const BMVert * v
BMVert * BM_vert_create(BMesh *bm, const float co[3], const BMVert *v_example, const eBMCreateFlag create_flag)
Main function for creating a new vertex.
static BMLogVert * bm_log_vert_alloc(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
Definition bmesh_log.cc:199
void BM_log_all_added(BMesh *bm, BMLog *log)
Definition bmesh_log.cc:741
static void bm_log_faces_restore(BMesh *bm, BMLog *log, const Map< uint, BMLogFace *, 0 > &faces)
Definition bmesh_log.cc:289
void BM_log_cleanup_entry(BMLogEntry *entry)
Definition bmesh_log.cc:411
static void bm_log_vert_values_swap(BMesh *bm, BMLog *log, const Map< uint, BMLogVert *, 0 > &verts)
Definition bmesh_log.cc:313
void BM_log_vert_removed(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
Definition bmesh_log.cc:700
@ BM_CREATE_NOP
Definition bmesh_core.hh:34
void BM_log_before_all_removed(BMesh *bm, BMLog *log)
Definition bmesh_log.cc:769
static BMFace * bm_log_face_from_id(BMLog *log, const uint id)
Definition bmesh_log.cc:157
void BLI_remlink(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:138
void BM_edge_kill(BMesh *bm, BMEdge *e)
MINLINE void swap_v3_v3(float a[3], float b[3])
int CustomData_get_offset_named(const CustomData *data, eCustomDataType type, StringRef name)
static float vert_mask_get(BMVert *v, const int cd_vert_mask_offset)
Definition bmesh_log.cc:171
void BM_log_print_entry(BMesh *bm, BMLogEntry *entry)
Definition bmesh_log.cc:857
BMLog * BM_log_from_existing_entries_create(BMesh *bm, BMLogEntry *entry)
Definition bmesh_log.cc:448
static BMVert * bm_log_vert_from_id(BMLog *log, const uint id)
Definition bmesh_log.cc:138
BMLog * BM_log_create(BMesh *bm)
Definition bmesh_log.cc:396
const float * BM_log_find_original_vert_mask(BMLog *log, BMVert *v)
Definition bmesh_log.cc:799
static void bm_log_face_id_set(BMLog *log, BMFace *f, const uint id)
Definition bmesh_log.cc:150
static uint bm_log_vert_id_get(BMLog *log, BMVert *v)
Definition bmesh_log.cc:125
static BMLogEntry * bm_log_entry_create()
Definition bmesh_log.cc:363
void BM_face_as_array_vert_tri(BMFace *f, BMVert *r_verts[3])
void BM_log_face_modified(BMLog *log, BMFace *f)
Definition bmesh_log.cc:680
BMLogEntry * BM_log_entry_add(BMLog *log)
Definition bmesh_log.cc:516
void BM_log_undo(BMesh *bm, BMLog *log)
Definition bmesh_log.cc:601
void BM_log_face_removed(BMLog *log, BMFace *f)
Definition bmesh_log.cc:724
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
RangeTreeUInt * BM_log_unused_ids(BMLog *log)
Definition bmesh_log.cc:836
void BM_face_kill(BMesh *bm, BMFace *f)
static void bm_log_verts_unmake(BMesh *bm, BMLog *log, const Map< uint, BMLogVert *, 0 > &verts)
Definition bmesh_log.cc:237
static void vert_mask_set(BMVert *v, const float new_mask, const int cd_vert_mask_offset)
Definition bmesh_log.cc:182
VecBase< float, 3 > float3
static void bm_log_vert_id_set(BMLog *log, BMVert *v, const uint id)
Definition bmesh_log.cc:131
void BM_log_vert_before_modified(BMLog *log, BMVert *v, const int cd_vert_mask_offset)
Definition bmesh_log.cc:656
const float * BM_log_find_original_vert_co(BMLog *log, BMVert *v)
Definition bmesh_log.cc:788
static void bm_log_vert_bmvert_copy(BMLogVert *lv, BMVert *v, const int cd_vert_mask_offset)
Definition bmesh_log.cc:190
static void bm_log_verts_restore(BMesh *bm, BMLog *log, const Map< uint, BMLogVert *, 0 > &verts)
Definition bmesh_log.cc:274
void BM_log_entry_drop(BMLogEntry *entry)
Definition bmesh_log.cc:530
static void bm_log_faces_unmake(BMesh *bm, BMLog *log, const Map< uint, BMLogFace *, 0 > &faces)
Definition bmesh_log.cc:253
BMLogEntry * prev
Definition bmesh_log.cc:43
Map< uint, BMLogVert *, 0 > deleted_verts
Definition bmesh_log.cc:48
Pool< BMLogFace > face_pool
Definition bmesh_log.cc:60
Map< uint, BMLogVert *, 0 > modified_verts
Definition bmesh_log.cc:56
Map< uint, BMLogFace *, 0 > deleted_faces
Definition bmesh_log.cc:49
BMLogEntry * next
Definition bmesh_log.cc:43
Pool< BMLogVert > vert_pool
Definition bmesh_log.cc:59
Map< uint, BMLogVert *, 0 > added_verts
Definition bmesh_log.cc:52
Map< uint, BMLogFace *, 0 > added_faces
Definition bmesh_log.cc:53
Vector< BMLogVert *, 0 > allocated_verts
Definition bmesh_log.cc:62
Vector< BMLogFace *, 0 > allocated_faces
Definition bmesh_log.cc:63
Map< uint, BMLogFace *, 0 > modified_faces
Definition bmesh_log.cc:57
std::array< uint, 3 > v_ids
Definition bmesh_log.cc:116
Map< BMElem *, uint, 0 > elem_to_id
Definition bmesh_log.cc:91
BMLogEntry * current_entry
Definition bmesh_log.cc:105
ListBaseT< BMLogEntry > entries
Definition bmesh_log.cc:94
RangeTreeUInt * unused_ids
Definition bmesh_log.cc:78
Map< uint, BMElem *, 0 > id_to_elem
Definition bmesh_log.cc:90
struct BMLoop * next
struct BMEdge * e