[Bf-blender-cvs] [d293de425f8] temp_bmesh_multires: Sculpt Dyntopo: fix bug in dyntopo brush spacing.
Joseph Eagar
noreply at git.blender.org
Fri Jun 25 20:49:54 CEST 2021
Commit: d293de425f8b746681032ec65c8a2651b3269755
Author: Joseph Eagar
Date: Fri Jun 25 11:49:28 2021 -0700
Branches: temp_bmesh_multires
https://developer.blender.org/rBd293de425f8b746681032ec65c8a2651b3269755
Sculpt Dyntopo: fix bug in dyntopo brush spacing.
===================================================================
M source/blender/blenkernel/intern/pbvh_bmesh.c
M source/blender/bmesh/intern/bmesh_mesh_convert_threaded.c
M source/blender/editors/object/object_modifier.c
M source/blender/editors/sculpt_paint/paint_stroke.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_automasking.c
M source/blender/gpu/intern/gpu_buffers.c
===================================================================
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 04c5b0c2e4a..bd3aec20d00 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -817,7 +817,7 @@ BMVert *BKE_pbvh_vert_create_bmesh(
PBVHNode *BKE_pbvh_node_from_face_bmesh(PBVH *pbvh, BMFace *f)
{
- return BM_ELEM_CD_GET_INT(f, pbvh->cd_face_node_offset);
+ return pbvh->nodes + BM_ELEM_CD_GET_INT(f, pbvh->cd_face_node_offset);
}
BMFace *BKE_pbvh_face_create_bmesh(PBVH *pbvh,
@@ -1537,7 +1537,7 @@ typedef struct EdgeQueueThreadData {
int size;
} EdgeQueueThreadData;
-void edge_thread_data_insert(EdgeQueueThreadData *tdata, BMEdge *e)
+static void edge_thread_data_insert(EdgeQueueThreadData *tdata, BMEdge *e)
{
if (tdata->size <= tdata->totedge) {
tdata->size = (tdata->totedge + 1) << 1;
@@ -1859,9 +1859,9 @@ static void long_edge_queue_edge_add_recursive_2(EdgeQueueThreadData *tdata,
}
}
-void long_edge_queue_task_cb(void *__restrict userdata,
- const int n,
- const TaskParallelTLS *__restrict tls)
+static void long_edge_queue_task_cb(void *__restrict userdata,
+ const int n,
+ const TaskParallelTLS *__restrict tls)
{
EdgeQueueThreadData *tdata = ((EdgeQueueThreadData *)userdata) + n;
PBVHNode *node = tdata->node;
@@ -2246,16 +2246,6 @@ static void pbvh_bmesh_split_edge(EdgeQueueContext *eq_ctx,
mv_new->flag |= DYNVERT_BOUNDARY;
}
- /* update paint mask */
- if (eq_ctx->cd_dyn_vert != -1) {
- float mask_v1 = DYNTOPO_MASK(eq_ctx->cd_dyn_vert, e->v1);
- float mask_v2 = DYNTOPO_MASK(eq_ctx->cd_dyn_vert, e->v2);
-
- float mask_v_new = 0.5f * (mask_v1 + mask_v2);
-
- // BM_ELEM_CD_SET_FLOAT(v_new, eq_ctx->cd_vert_mask_offset, mask_v_new);
- }
-
/* For each face, add two new triangles and delete the original */
for (int i = 0; i < (int)edge_loops->count; i++) {
BMLoop *l_adj = BLI_buffer_at(edge_loops, BMLoop *, i);
@@ -2850,7 +2840,7 @@ static bool pbvh_bmesh_collapse_short_edges(EdgeQueueContext *eq_ctx,
GHash *deleted_verts = BLI_ghash_ptr_new("deleted_verts");
double time = PIL_check_seconds_timer();
- RNG *rng = BLI_rng_new(time * 1000.0f);
+ RNG *rng = BLI_rng_new((unsigned int)(time * 1000.0f));
//#define TEST_COLLAPSE
#ifdef TEST_COLLAPSE
@@ -3637,26 +3627,33 @@ bool BKE_pbvh_bmesh_update_topology_nodes(PBVH *pbvh,
return modified;
}
-static bool cleanup_valence_3_4(PBVH *pbvh,
- const float center[3],
- const float view_normal[3],
- float radius,
- const bool use_frontface,
- const bool use_projected)
+// this function is being buggy under clang's optimizer, at least on windows
+#ifdef __clang__
+# define CLANG_OPT_BUG __attribute__((optnone))
+#else
+# define CLANG_OPT_BUG
+#endif
+
+CLANG_OPT_BUG static bool cleanup_valence_3_4(PBVH *pbvh,
+ const float center[3],
+ const float view_normal[3],
+ float radius,
+ const bool use_frontface,
+ const bool use_projected)
{
bool modified = false;
- BMVert **relink_verts = NULL;
- BLI_array_staticdeclare(relink_verts, 1024);
float radius2 = radius * 1.25;
float rsqr = radius2 * radius2;
+ GSet *vset = BLI_gset_ptr_new("vset");
+
for (int n = 0; n < pbvh->totnode; n++) {
PBVHNode *node = pbvh->nodes + n;
/* Check leaf nodes marked for topology update */
bool ok = (node->flag & PBVH_Leaf) && (node->flag & PBVH_UpdateTopology);
- ok = ok && !(node->flag & PBVH_FullyHidden);
+ ok = ok && !(node->flag & (PBVH_FullyHidden | PBVH_Delete));
if (!ok) {
continue;
@@ -3665,12 +3662,12 @@ static bool cleanup_valence_3_4(PBVH *pbvh,
BMVert *v;
TGSET_ITER (v, node->bm_unique_verts) {
- if (len_squared_v3v3(v->co, center) >= rsqr) {
+ if (len_squared_v3v3(v->co, center) >= rsqr || !v->e) {
continue;
}
const int val = BM_vert_edge_count(v);
- if (val < 3 || val > 4) {
+ if (val != 4 && val != 3) {
continue;
}
@@ -3678,7 +3675,6 @@ static bool cleanup_valence_3_4(PBVH *pbvh,
BMLoop *l;
BMLoop *ls[4];
BMVert *vs[4];
- BMEdge *es[4];
l = v->e->l;
@@ -3729,14 +3725,12 @@ static bool cleanup_valence_3_4(PBVH *pbvh,
continue;
}
- pbvh_bmesh_vert_remove(pbvh, v);
BM_log_vert_removed(pbvh->bm_log, v, pbvh->cd_vert_mask_offset);
- BLI_array_clear(relink_verts);
-
BMFace *f;
BM_ITER_ELEM (f, &iter, v, BM_FACES_OF_VERT) {
int ni2 = BM_ELEM_CD_GET_INT(f, pbvh->cd_face_node_offset);
+
if (ni2 != DYNTOPO_NODE_NONE) {
PBVHNode *node2 = pbvh->nodes + ni2;
@@ -3747,6 +3741,8 @@ static bool cleanup_valence_3_4(PBVH *pbvh,
}
}
+ // pbvh_bmesh_vert_remove(pbvh, v);
+
modified = true;
l = v->e->l;
@@ -3761,6 +3757,9 @@ static bool cleanup_valence_3_4(PBVH *pbvh,
normal_tri_v3(
f1->no, f1->l_first->v->co, f1->l_first->next->v->co, f1->l_first->prev->v->co);
}
+ else {
+ printf("eek!\n");
+ }
if (val == 4 && vs[0] != vs[2] && vs[2] != vs[3] && vs[0] != vs[3]) {
vs[0] = ls[0]->v;
@@ -3779,6 +3778,9 @@ static bool cleanup_valence_3_4(PBVH *pbvh,
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);
}
+ else {
+ printf("eek2!\n");
+ }
if (f1) {
SWAP(void *, f1->l_first->head.data, ls[0]->head.data);
@@ -3789,23 +3791,11 @@ static bool cleanup_valence_3_4(PBVH *pbvh,
}
BM_vert_kill(pbvh->bm, v);
-#if 0
- for (int j = 0; j < pbvh->totnode; j++) {
- PBVHNode *node2 = pbvh->nodes + j;
-
- if (!node2->bm_unique_verts || !node2->bm_other_verts) { //(node2->flag & PBVH_Leaf)) {
- continue;
- }
-
- BLI_table_gset_remove(node2->bm_unique_verts, v, NULL);
- BLI_table_gset_remove(node2->bm_other_verts, v, NULL);
- }
-#endif
}
TGSET_ITER_END
}
- BLI_array_free(relink_verts);
+ BLI_gset_free(vset, NULL);
if (modified) {
pbvh->bm->elem_index_dirty |= BM_VERT | BM_FACE | BM_EDGE;
@@ -4308,7 +4298,6 @@ static void pbvh_bmesh_join_subnodes(PBVH *pbvh, PBVHNode *node, PBVHNode *paren
static void BKE_pbvh_bmesh_correct_tree(PBVH *pbvh, PBVHNode *node, PBVHNode *parent)
{
const int size_lower = pbvh->leaf_limit - (pbvh->leaf_limit >> 1);
- const int size_higher = pbvh->leaf_limit + (pbvh->leaf_limit >> 1);
if (node->flag & PBVH_Leaf) {
// pbvh_bmesh_node_limit_ensure(pbvh, (int)(node - pbvh->nodes));
@@ -4524,8 +4513,6 @@ static void pbvh_bmesh_join_nodes(PBVH *bvh)
bvh->totnode = j;
- BMVert *v;
-
// set vert/face node indices again
for (int i = 0; i < bvh->totnode; i++) {
PBVHNode *n = bvh->nodes + i;
diff --git a/source/blender/bmesh/intern/bmesh_mesh_convert_threaded.c b/source/blender/bmesh/intern/bmesh_mesh_convert_threaded.c
index 0f7ea38c3c0..1e21d4887ae 100644
--- a/source/blender/bmesh/intern/bmesh_mesh_convert_threaded.c
+++ b/source/blender/bmesh/intern/bmesh_mesh_convert_threaded.c
@@ -68,9 +68,7 @@ typedef struct BMThreadData {
# define ELEM_NEXT(type, ptr, size) ((type *)(((char *)ptr) + size))
-ATTR_NO_OPT void bm_vert_task(void *__restrict userdata,
- const int n,
- const TaskParallelTLS *__restrict tls)
+void bm_vert_task(void *__restrict userdata, const int n, const TaskParallelTLS *__restrict tls)
{
BMThreadData *data = userdata;
BMesh *bm = data->bm;
@@ -306,10 +304,10 @@ static void bm_mesh_cd_flag_apply(BMesh *bm, const char cd_flag)
}
}
-ATTR_NO_OPT BMesh *BM_mesh_bm_from_me_threaded(BMesh *bm,
- Object *ob,
- const Mesh *me,
- const struct BMeshFromMeshParams *params)
+BMesh *BM_mesh_bm_from_me_threaded(BMesh *bm,
+ Object *ob,
+ const Mesh *me,
+ const struct BMeshFromMeshParams *params)
{
if (!bm) {
bm = MEM_callocN(sizeof(BMesh), "BM_mesh_bm_from_me_threaded bm");
diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c
index 75d15e931c4..5f9301d2b48 100644
--- a/source/blender/editors/object/object_modifier.c
+++ b/source/blender/editors/object/object_modifier.c
@@ -846,14 +846,14 @@ static bool modifier_apply_obdata(
return true;
}
-ATTR_NO_OPT bool ED_object_modifier_apply(Main *bmain,
- ReportList *reports,
- Depsgraph *depsgraph,
- Scene *scene,
- Object *ob,
- ModifierData *md,
- int mode,
- bool keep_modifier)
+bool ED_object_modifier_apply(Main *bmain,
+ ReportList *reports,
+ Depsgraph *depsgraph,
+ Scene *scene,
+ Object *ob,
+ ModifierData *md,
+ int mode,
+ bool keep_modifier)
{
if (BKE_object_is_in_editmode(ob)) {
BKE_report(reports, RPT_ERROR, "Modifiers cannot be applied in edit mode");
@@ -1395,8 +1395,7 @@ void OBJECT_OT_modifier_move_to_index(wmOperatorType *ot)
/** \name Apply Modif
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list