[Bf-blender-cvs] [e4851c22b07] sculpt-dev: sculpt-dev: Rewrite BMLog
Joseph Eagar
noreply at git.blender.org
Mon Feb 6 11:22:17 CET 2023
Commit: e4851c22b07717ceb353788d690c54caa8b749f5
Author: Joseph Eagar
Date: Sat Feb 4 04:29:35 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rBe4851c22b07717ceb353788d690c54caa8b749f5
sculpt-dev: Rewrite BMLog
Part one of BMLog C++ rewrite.
===================================================================
M source/blender/blenkernel/BKE_paint.h
M source/blender/blenkernel/BKE_pbvh.h
M source/blender/blenkernel/intern/dyntopo.cc
M source/blender/blenkernel/intern/dyntopo_collapse.cc
M source/blender/blenkernel/intern/paint.cc
M source/blender/blenkernel/intern/pbvh.c
M source/blender/blenkernel/intern/pbvh_bmesh.c
M source/blender/blenkernel/intern/pbvh_intern.h
M source/blender/bmesh/CMakeLists.txt
M source/blender/bmesh/intern/bmesh_construct.c
M source/blender/bmesh/intern/bmesh_core.c
D source/blender/bmesh/intern/bmesh_log.c
A source/blender/bmesh/intern/bmesh_log.cc
M source/blender/bmesh/intern/bmesh_log.h
M source/blender/bmesh/intern/bmesh_log_intern.h
M source/blender/editors/sculpt_paint/sculpt.cc
M source/blender/editors/sculpt_paint/sculpt_dyntopo.c
M source/blender/editors/sculpt_paint/sculpt_face_set.cc
M source/blender/editors/sculpt_paint/sculpt_intern.h
M source/blender/editors/sculpt_paint/sculpt_ops.c
M source/blender/editors/sculpt_paint/sculpt_undo.c
===================================================================
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 3cee0640af7..31f466e5223 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -22,6 +22,8 @@
#include "BKE_attribute.h"
#include "BKE_pbvh.h"
+#include "bmesh_log.h"
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -847,7 +849,7 @@ typedef struct SculptSession {
bool ignore_uvs;
/* Undo/redo log for dynamic topology sculpting */
- struct BMLog *bm_log;
+ BMLog *bm_log;
/* Limit surface/grids. */
struct SubdivCCG *subdiv_ccg;
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 6dd175c47a6..c3aafb88da5 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -12,6 +12,7 @@
#include "BLI_ghash.h"
#include "bmesh.h"
+#include "bmesh_log.h"
/* For embedding CCGKey in iterator. */
#include "BKE_attribute.h"
@@ -93,7 +94,6 @@ typedef struct PBVHTriBuf {
//#define WITH_PBVH_CACHE
-struct BMLog;
struct BMesh;
struct BMVert;
struct BMEdge;
@@ -434,7 +434,7 @@ void BKE_pbvh_build_bmesh(PBVH *pbvh,
struct Mesh *me,
struct BMesh *bm,
bool smooth_shading,
- struct BMLog *log,
+ BMLog *log,
struct BMIdMap *idmap,
const int cd_vert_node_offset,
const int cd_face_node_offset,
@@ -462,8 +462,8 @@ void BKE_pbvh_build_pixels(PBVH *pbvh,
struct ImageUser *image_user);
void BKE_pbvh_free(PBVH *pbvh);
-void BKE_pbvh_set_bm_log(PBVH *pbvh, struct BMLog *log);
-struct BMLog *BKE_pbvh_get_bm_log(PBVH *pbvh);
+void BKE_pbvh_set_bm_log(PBVH *pbvh, BMLog *log);
+BMLog *BKE_pbvh_get_bm_log(PBVH *pbvh);
/* update MSculptVerts, doesn't take pbvh argument to allow usage if pbvh doesn't currently exist
*/
diff --git a/source/blender/blenkernel/intern/dyntopo.cc b/source/blender/blenkernel/intern/dyntopo.cc
index 5cef8751343..18351f48c79 100644
--- a/source/blender/blenkernel/intern/dyntopo.cc
+++ b/source/blender/blenkernel/intern/dyntopo.cc
@@ -44,7 +44,7 @@
#include "dyntopo_intern.hh"
#include "pbvh_intern.h"
-#include <stdio.h>
+#include <cstdio>
namespace blender::dyntopo {
@@ -205,13 +205,13 @@ static void pbvh_kill_vert(PBVH *pbvh, BMVert *v, bool log_vert, bool log_edges)
if (log_edges) {
if (e) {
do {
- BM_log_edge_removed(pbvh->bm_log, e);
+ BM_log_edge_removed(pbvh->header.bm, pbvh->bm_log, e);
} while ((e = BM_DISK_EDGE_NEXT(e, v)) != v->e);
}
}
if (log_vert) {
- BM_log_vert_removed(pbvh->bm_log, v, -1);
+ BM_log_vert_removed(pbvh->header.bm, pbvh->bm_log, v);
}
#ifdef USE_NEW_IDMAP
@@ -300,7 +300,7 @@ static BMVert *pbvh_bmesh_vert_create(PBVH *pbvh,
node->flag |= PBVH_UpdateDrawBuffers | PBVH_UpdateBB | PBVH_UpdateTris | PBVH_UpdateOtherVerts;
/* Log the new vertex */
- BM_log_vert_added(pbvh->bm_log, v, cd_vert_mask_offset);
+ BM_log_vert_added(pbvh->header.bm, pbvh->bm_log, v);
v->head.index = pbvh->header.bm->totvert; // set provisional index
return v;
@@ -324,7 +324,7 @@ static BMFace *bmesh_face_create_edge_log(PBVH *pbvh,
if (!e) {
e = BM_edge_create(pbvh->header.bm, v1, v2, nullptr, BM_CREATE_NOP);
- BM_log_edge_added(pbvh->bm_log, e);
+ BM_log_edge_added(pbvh->header.bm, pbvh->bm_log, e);
}
e_tri2[i] = e;
@@ -372,7 +372,7 @@ static BMFace *pbvh_bmesh_face_create(PBVH *pbvh,
/* Log the new face */
if (log_face) {
- BM_log_face_added(pbvh->bm_log, f);
+ BM_log_face_added(pbvh->header.bm, pbvh->bm_log, f);
}
int cd_vert_node = pbvh->cd_vert_node_offset;
@@ -687,7 +687,7 @@ void pbvh_bmesh_face_remove(
/* Log removed face */
if (log_face) {
- BM_log_face_removed(pbvh->bm_log, f);
+ BM_log_face_removed(pbvh->header.bm, pbvh->bm_log, f);
}
/* mark node for update */
@@ -1229,7 +1229,7 @@ static void unified_edge_queue_task_cb(void *__restrict userdata,
int randval = (seed = dyntopo_thread_rand(seed)) & 255;
if (do_smooth && randval > 127) {
- PBVHVertRef sv = {.i = (intptr_t)l_iter->v};
+ PBVHVertRef sv = {(intptr_t)l_iter->v};
surface_smooth_v_safe(tdata->pbvh,
l_iter->v,
eq_ctx->surface_smooth_fac *
@@ -1289,7 +1289,7 @@ bool check_face_is_tri(PBVH *pbvh, BMFace *f)
// BKE_pbvh_bmesh_remove_face(pbvh, f, true);
pbvh_bmesh_face_remove(pbvh, f, false, true, true);
- BM_log_face_pre(pbvh->bm_log, f);
+ BM_log_face_removed(pbvh->header.bm, pbvh->bm_log, f);
#ifdef USE_NEW_IDMAP
BM_idmap_release(pbvh->bm_idmap, (BMElem *)f, true);
#endif
@@ -1333,8 +1333,8 @@ bool check_face_is_tri(PBVH *pbvh, BMFace *f)
}
if (f == f2) {
- BM_log_face_post(pbvh->bm_log, f);
- BM_log_face_removed(pbvh->bm_log, f);
+ BM_log_face_added(pbvh->header.bm, pbvh->bm_log, f);
+ BM_log_face_removed_no_check(pbvh->header.bm, pbvh->bm_log, f);
f = nullptr;
}
@@ -1363,7 +1363,7 @@ bool check_face_is_tri(PBVH *pbvh, BMFace *f)
BMLoop *l = f2->l_first;
do {
if (l->e->head.index == -1) {
- BM_log_edge_added(pbvh->bm_log, l->e);
+ BM_log_edge_added(pbvh->header.bm, pbvh->bm_log, l->e);
l->e->head.index = 0;
}
} while ((l = l->next) != f2->l_first);
@@ -1372,12 +1372,12 @@ bool check_face_is_tri(PBVH *pbvh, BMFace *f)
BKE_pbvh_bmesh_add_face(pbvh, f2, false, true);
// BM_log_face_post(pbvh->bm_log, f2);
- BM_log_face_added(pbvh->bm_log, f2);
+ BM_log_face_added(pbvh->header.bm, pbvh->bm_log, f2);
}
if (f) {
BKE_pbvh_bmesh_add_face(pbvh, f, false, true);
- BM_log_face_post(pbvh->bm_log, f);
+ BM_log_face_added(pbvh->header.bm, pbvh->bm_log, f);
}
if (arena) {
@@ -1547,7 +1547,7 @@ bool destroy_nonmanifold_fins(PBVH *pbvh, BMEdge *e_root)
BMEdge *e = es[i];
if (!e->l) {
- BM_log_edge_removed(pbvh->bm_log, e);
+ BM_log_edge_removed(pbvh->header.bm, pbvh->bm_log, e);
# ifdef USE_NEW_IDMAP
BM_idmap_release(pbvh->bm_idmap, (BMElem *)e, true);
# endif
@@ -1561,7 +1561,7 @@ bool destroy_nonmanifold_fins(PBVH *pbvh, BMEdge *e_root)
if (!v->e) {
pbvh_bmesh_vert_remove(pbvh, v);
- BM_log_vert_removed(pbvh->bm_log, v, pbvh->cd_vert_mask_offset);
+ BM_log_vert_removed(pbvh->header.bm, pbvh->bm_log, v);
# ifdef USE_NEW_IDMAP
BM_idmap_release(pbvh->bm_idmap, (BMElem *)v, true);
# endif
@@ -1829,11 +1829,11 @@ static void unified_edge_queue_create(EdgeQueueContext *eq_ctx,
MSculptVert *mv2 = BKE_PBVH_SCULPTVERT(cd_sculpt_vert, e->v2);
if (mv1->flag & SCULPTVERT_NEED_VALENCE) {
- BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (PBVHVertRef){.i = (intptr_t)e->v1});
+ BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, {(intptr_t)e->v1});
}
if (mv2->flag & SCULPTVERT_NEED_VALENCE) {
- BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (PBVHVertRef){.i = (intptr_t)e->v2});
+ BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, {(intptr_t)e->v2});
}
// check_vert_fan_are_tris(pbvh, e->v1);
@@ -2005,7 +2005,7 @@ static void edge_queue_create_local(EdgeQueueContext *eq_ctx,
MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
if (mv->flag & SCULPTVERT_NEED_VALENCE) {
- BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (PBVHVertRef){.i = (intptr_t)v});
+ BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, {(intptr_t)v});
}
edge_queue_insert_val34_vert(eq_ctx, v);
@@ -2209,14 +2209,14 @@ cleanup_valence_3_4(EdgeQueueContext *ectx,
MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
- BKE_pbvh_bmesh_check_valence(pbvh, (PBVHVertRef){.i = (intptr_t)v});
+ BKE_pbvh_bmesh_check_valence(pbvh, {(intptr_t)v});
int val = mv->valence;
if (val != 4 && val != 3) {
continue;
}
- PBVHVertRef sv = {.i = (intptr_t)v};
+ PBVHVertRef sv = {(intptr_t)v};
if (len_squared_v3v3(v->co, center) >= rsqr || !v->e ||
ectx->mask_cb(sv, ectx->mask_cb_data) < 0.5f) {
@@ -2355,7 +2355,7 @@ cleanup_valence_3_4(EdgeQueueContext *ectx,
pbvh_bmesh_face_remove(pbvh, f, true, true, true);
}
else {
- BM_log_face_removed(pbvh->bm_log, f);
+ BM_log_face_removed(pbvh->header.bm, pbvh->bm_log, f);
}
}
@@ -2471,7 +2471,7 @@ cleanup_valence_3_4(EdgeQueueContext *ectx,
normal_tri_v3(
f2->no, f2->l_first->v->co, f2->l_first->next->v->co, f2->l_first->prev->v->co);
- BM_log_face_added(pbvh->bm_log, f2);
+ BM_log_face_added(pbvh->header.bm, pbvh->bm_log, f2);
validate_face(pbvh, pbvh->header.bm, f2, false, false);
}
@@ -2484,7 +2484,7 @@ cleanup_valence_3_4(EdgeQueueContext *ectx,
CustomData_bmesh_swap_data_simple(
&pbvh->header.bm->ldata, &f1->l_first->prev->head.data, &ls[2]->head.data);
- BM_log_face_added(pbvh->bm_log, f1);
+ BM_log_face_added(pbvh->header.bm, pbvh->bm_log, f1);
}
validate_vert(pbvh, pbvh->header.bm, v, false, false);
@@ -2605,7 +2605,7 @@ static bool do_cleanup_3_4(EdgeQueueContext *eq_ctx,
MSculptVert *mv = BKE_PBVH_SCULPTVERT(pbvh->cd_sculpt_vert, v);
if (mv->flag & SCULPTVERT_NEED_VALENCE) {
- BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, (PBVHVertRef){.i = (intptr_t)v});
+ BKE_pbvh_bmesh_update_valence(pbvh->cd_sculpt_vert, {(intptr_t)v});
}
if (mv->valence < 5) {
@@ -2717,22 +2717,23 @@ extern "C" bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
safe_smooth = DYNTOPO_SAFE_SMOOTH_FAC;
}
- EdgeQueueContext eq_ctx = {.pool = nullptr,
- .bm = pbvh->header.bm,
- .mask_cb = mask_cb,
- .mask_cb_data = mask_cb_data,
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list