[Bf-blender-cvs] [a391a01509a] sculpt-dev: sculpt-dev: Cleanup and fix bugs in dyntopo subdivide
Joseph Eagar
noreply at git.blender.org
Tue Jan 31 00:55:05 CET 2023
Commit: a391a01509a3984df37b634b3a11c14ede556ab4
Author: Joseph Eagar
Date: Mon Jan 30 15:53:19 2023 -0800
Branches: sculpt-dev
https://developer.blender.org/rBa391a01509a3984df37b634b3a11c14ede556ab4
sculpt-dev: Cleanup and fix bugs in dyntopo subdivide
* Removed unused code.
* Fixed nasty double increment bug.
* Fixed subdivision patterns.
===================================================================
M source/blender/blenkernel/intern/customdata.cc
M source/blender/blenkernel/intern/dyntopo.cc
M source/blender/blenkernel/intern/dyntopo_intern.hh
M source/blender/bmesh/intern/bmesh_idmap.cc
M source/blender/bmesh/intern/bmesh_log.c
M source/blender/editors/sculpt_paint/sculpt_undo.c
===================================================================
diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc
index 7b912cb7285..f04a78eaa11 100644
--- a/source/blender/blenkernel/intern/customdata.cc
+++ b/source/blender/blenkernel/intern/customdata.cc
@@ -4265,7 +4265,7 @@ void CustomData_bmesh_free_block_data_exclude_by_type(CustomData *data,
}
#ifndef USE_BMESH_PAGE_CUSTOMDATA
-static void CustomData_bmesh_set_default_n(CustomData *data, void **block, const int n)
+ATTR_NO_OPT static void CustomData_bmesh_set_default_n(CustomData *data, void **block, const int n)
{
if (ELEM(data->layers[n].type, CD_TOOLFLAGS, CD_MESH_ID)) {
/* do not do toolflags or mesh ids */
@@ -4414,11 +4414,11 @@ void CustomData_bmesh_swap_data(CustomData *source,
}
}
-void CustomData_bmesh_copy_data_exclude_by_type(const CustomData *source,
- CustomData *dest,
- void *src_block,
- void **dest_block,
- const eCustomDataMask mask_exclude)
+ATTR_NO_OPT void CustomData_bmesh_copy_data_exclude_by_type(const CustomData *source,
+ CustomData *dest,
+ void *src_block,
+ void **dest_block,
+ const eCustomDataMask mask_exclude)
{
/* Note that having a version of this function without a 'mask_exclude'
* would cause too much duplicate code, so add a check instead. */
@@ -4444,7 +4444,6 @@ void CustomData_bmesh_copy_data_exclude_by_type(const CustomData *source,
for (int dest_i = 0; dest_i < dest->totlayer; dest_i++) {
CustomData_bmesh_set_default_n(dest, dest_block, dest_i);
- dest_i++;
}
/* copies a layer at a time */
diff --git a/source/blender/blenkernel/intern/dyntopo.cc b/source/blender/blenkernel/intern/dyntopo.cc
index 28e456c76a3..987bcb1879f 100644
--- a/source/blender/blenkernel/intern/dyntopo.cc
+++ b/source/blender/blenkernel/intern/dyntopo.cc
@@ -1257,6 +1257,10 @@ static void unified_edge_queue_task_cb(void *__restrict userdata,
bool check_face_is_tri(PBVH *pbvh, BMFace *f)
{
+#if DYNTOPO_DISABLE_FLAG & DYNTOPO_DISABLE_TRIANGULATOR
+ return true;
+#endif
+
if (f->len == 3) {
return true;
}
@@ -1391,7 +1395,7 @@ bool check_face_is_tri(PBVH *pbvh, BMFace *f)
ATTR_NO_OPT bool destroy_nonmanifold_fins(PBVH *pbvh, BMEdge *e_root)
{
-#if 0
+#if !(DYNTOPO_DISABLE_FLAG & DYNTOPO_DISABLE_FIN_REMOVAL)
bm_logstack_push();
static int max_faces = 64;
@@ -2756,6 +2760,13 @@ extern "C" bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
mode |= PBVH_Collapse;
}
+#if DYNTOPO_DISABLE_FLAG & DYNTOPO_DISABLE_COLLAPSE
+ mode &= ~PBVH_Collapse;
+#endif
+#if DYNTOPO_DISABLE_FLAG & DYNTOPO_DISABLE_SPLIT_EDGES
+ mode &= ~PBVH_Subdivide;
+#endif
+
if (mode & (PBVH_Subdivide | PBVH_Collapse)) {
unified_edge_queue_create(&eq_ctx,
pbvh,
@@ -2907,7 +2918,11 @@ extern "C" bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
if (bm_elem_is_free((BMElem *)e->v1, BM_VERT) ||
bm_elem_is_free((BMElem *)e->v2, BM_VERT)) {
- printf("%s: error!\n");
+ printf("%s: error! operated on freed bmesh elements! e: %p, e->v1: %p, e->v2: %p\n",
+ __func__,
+ e,
+ e->v1,
+ e->v2);
break;
}
@@ -3012,15 +3027,16 @@ extern "C" bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
return modified;
}
-#define SPLIT_TAG BM_ELEM_TAG_ALT
+#define SPLIT_TAG BM_ELEM_TAG
/*
-#generate shifted and mirrored patterns
+#generate shifted and mirrored patterns
+# [number of verts, vert_connections... ]
table = [
- [4, 3, -1, -1, -1],
- [5, -1, 3, -1, 4, -1],
- [6, -1, 3, -1, 5, -1, 1, -1]
+ [4, -1, 3, -1, -1],
+ [5, -1, 3, -1, 0, -1],
+ [6, -1, 3, -1, 5, -1, 1]
]
table2 = {}
@@ -3032,9 +3048,8 @@ def getmask(row):
mask |= 1 << i
return mask
+ii = 0
for row in table:
- #table2.append(row)
-
n = row[0]
row = row[1:]
@@ -3046,13 +3061,23 @@ for row in table:
row2 = []
for j in range(n):
j2 = row[(j + i) % n]
- if j2 >= 0:
- j2 = (j2 + i) % n
+
+ if j2 != -1:
+ j2 = (j2 - i + n) % n
+
row2.append(j2)
- mask = getmask(row2)
- if mask not in table2:
- table2[mask] = [n] + row2
+ if row2[0] != -1:
+ continue
+
+ mask2 = getmask(row2)
+ if mask2 not in table2:
+ table2[mask2] = [n] + row2
+
+ #reverse row
+ for i in range(n):
+ if row[i] != -1:
+ row[i] = n - row[i]
row.reverse()
@@ -3064,126 +3089,93 @@ buf = 'static const int splitmap[%i][16] = {\n' % (maxk+1)
buf += ' //{numverts, vert_connections...}\n'
for k in range(maxk+1):
+ line = ""
+
if k not in table2:
- buf += ' {-1},\n'
- continue
-
- buf += ' {'
- row = table2[k]
- for j in range(len(row)):
- if j > 0:
- buf += ", "
- buf += str(row[j])
- buf += '},\n'
+ line += ' {-1},'
+ else:
+ line += ' {'
+ row = table2[k]
+ for j in range(len(row)):
+ if j > 0:
+ line += ", "
+ line += str(row[j])
+ line += '},'
+
+ while len(line) < 35:
+ line += " "
+ line += "//" + str(k) + " "
+
+ if k in table2:
+ for i in range(table2[k][0]):
+ ch = "1" if k & (1 << i) else "0"
+ line += str(ch) + " "
+
+ buf += line + "\n"
buf += '};\n'
print(buf)
*/
-
static const int splitmap[43][16] = {
//{numverts, vert_connections...}
- {-1}, // 0
- {4, 2, -1, -1, -1}, // 1
- {4, -1, 3, -1, -1}, // 2
- {-1}, // 3
- {4, -1, -1, 0, -1}, // 4
- {5, 2, -1, 4, -1, -1}, // 5
- {-1}, // 6
- {-1}, // 7
- {4, -1, -1, -1, 1}, // 8
- {5, 2, -1, -1, 0, -1}, // 9
- {5, -1, 3, -1, 0, -1}, // 10
- {-1}, // 11
- {-1}, // 12
- {-1}, // 13
- {-1}, // 14
- {-1}, // 15
- {-1}, // 16
- {-1}, // 17
- {5, -1, 3, -1, -1, 1}, // 18
- {-1}, // 19
- {5, -1, -1, 4, -1, 1}, // 20
- {6, 2, -1, 4, -1, 0, -1}, // 21
- {-1}, // 22
- {-1}, // 23
- {-1}, // 24
- {-1}, // 25
- {-1}, // 26
- {-1}, // 27
- {-1}, // 28
- {-1}, // 29
- {-1}, // 30
- {-1}, // 31
- {-1}, // 32
- {-1}, // 33
- {-1}, // 34
- {-1}, // 35
- {-1}, // 36
- {-1}, // 37
- {-1}, // 38
- {-1}, // 39
- {-1}, // 40
- {-1}, // 41
- {6, -1, 3, -1, 5, -1, 1, -1}, // 42
+ {-1}, // 0
+ {-1}, // 1
+ {4, -1, 3, -1, -1}, // 2 0 1 0 0
+ {-1}, // 3
+ {4, -1, -1, 0, -1}, // 4 0 0 1 0
+ {-1}, // 5
+ {-1}, // 6
+ {-1}, // 7
+ {4, -1, -1, -1, 1}, // 8 0 0 0 1
+ {-1}, // 9
+ {5, -1, 3, -1, 0, -1}, // 10 0 1 0 1 0
+ {-1}, // 11
+ {-1}, // 12
+ {-1}, // 13
+ {-1}, // 14
+ {-1}, // 15
+ {-1}, // 16
+ {-1}, // 17
+ {5, -1, 3, -1, -1, 1}, // 18 0 1 0 0 1
+ {-1}, // 19
+ {5, -1, -1, 4, -1, 1}, // 20 0 0 1 0 1
+ {-1}, // 21
+ {-1}, // 22
+ {-1}, // 23
+ {-1}, // 24
+ {-1}, // 25
+ {-1}, // 26
+ {-1}, // 27
+ {-1}, // 28
+ {-1}, // 29
+ {-1}, // 30
+ {-1}, // 31
+ {-1}, // 32
+ {-1}, // 33
+ {-1}, // 34
+ {-1}, // 35
+ {-1}, // 36
+ {-1}, // 37
+ {-1}, // 38
+ {-1}, // 39
+ {-1}, // 40
+ {-1}, // 41
+ {6, -1, 3, -1, 5, -1, 1}, // 42 0 1 0 1 0 1
};
-static void pbvh_split_edges(EdgeQueueContext *eq_ctx,
- PBVH *pbvh,
- BMesh *bm,
- BMEdge **edges1,
- int totedge,
- bool ignore_isolated_edges)
+ATTR_NO_OPT static void pbvh_split_edges(EdgeQueueContext *eq_ctx,
+ PBVH *pbvh,
+ BMesh *bm,
+ BMEdge **edges1,
+ int totedge,
+ bool ignore_isolated_edges)
{
bm_logstack_push();
-
bm_log_message(" == split edges == ");
-#ifndef EXPAND_SPLIT_REGION
BMEdge **edges = edges1;
-#endif
-
Vector<BMFace *> faces;
- bm_log_message(" == split edges == ");
-
-//# define EXPAND_SPLIT_REGION
-#ifdef EXPAND_SPLIT_REGION
-
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list