[Bf-blender-cvs] [e9f9217f756] temp_bmesh_multires: Merge from master
Joseph Eagar
noreply at git.blender.org
Mon Mar 1 02:05:55 CET 2021
Commit: e9f9217f756364f722593bdb2d67675858507adc
Author: Joseph Eagar
Date: Sun Feb 28 17:05:35 2021 -0800
Branches: temp_bmesh_multires
https://developer.blender.org/rBe9f9217f756364f722593bdb2d67675858507adc
Merge from master
===================================================================
M source/blender/blenkernel/BKE_pbvh.h
M source/blender/blenkernel/intern/pbvh.c
M source/blender/blenkernel/intern/pbvh_bmesh.c
M source/blender/editors/sculpt_paint/sculpt.c
M source/blender/editors/sculpt_paint/sculpt_automasking.c
M source/blender/editors/sculpt_paint/sculpt_boundary.c
M source/blender/editors/sculpt_paint/sculpt_intern.h
===================================================================
diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 9428834f99d..b1d2156f1e4 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -368,6 +368,18 @@ bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
int symaxis,
bool updatePBVH);
+bool BKE_pbvh_bmesh_update_topology_nodes(PBVH *pbvh,
+ bool (*searchcb)(PBVHNode *node, void *data),
+ void (*undopush)(PBVHNode *node, void *data),
+ void *searchdata,
+ PBVHTopologyUpdateMode mode,
+ const float center[3],
+ const float view_normal[3],
+ float radius,
+ const bool use_frontface,
+ const bool use_projected,
+ int sym_axis,
+ bool updatePBVH);
/* Node Access */
void BKE_pbvh_node_mark_update(PBVHNode *node);
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index a93c6eef77a..9cd1c87a518 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -1944,6 +1944,19 @@ void BKE_pbvh_node_num_verts(PBVH *pbvh, PBVHNode *node, int *r_uniquevert, int
}
break;
case PBVH_BMESH:
+ // not a leaf? return zero
+ if (!(node->flag & PBVH_Leaf)) {
+ if (r_totvert) {
+ *r_totvert = 0;
+ }
+
+ if (r_uniquevert) {
+ *r_uniquevert = 0;
+ }
+
+ return;
+ }
+
tot = BLI_table_gset_len(node->bm_unique_verts);
if (r_totvert) {
*r_totvert = tot + BLI_table_gset_len(node->bm_other_verts);
diff --git a/source/blender/blenkernel/intern/pbvh_bmesh.c b/source/blender/blenkernel/intern/pbvh_bmesh.c
index 561dd0e6c45..746463dfc42 100644
--- a/source/blender/blenkernel/intern/pbvh_bmesh.c
+++ b/source/blender/blenkernel/intern/pbvh_bmesh.c
@@ -992,8 +992,7 @@ off fort;
fdis := (sqrt(dis)/nz)**2 + planedis**2;
*/
-static float dist_to_tri_sphere(
- float p[3], float v1[3], float v2[3], float v3[3], float n[3])
+static float dist_to_tri_sphere(float p[3], float v1[3], float v2[3], float v3[3], float n[3])
{
// find projection axis;
@@ -1027,7 +1026,7 @@ static float dist_to_tri_sphere(
double bx = v2[axis1] - ax, by = v2[axis2] - ay;
double cx = v3[axis1] - ax, cy = v3[axis2] - ay;
double bx2 = bx * bx, by2 = by * by, cx2 = cx * cx, cy2 = cy * cy;
-
+
double x1 = p[axis1] - ax;
double y1 = p[axis2] - ay;
@@ -1043,7 +1042,6 @@ static float dist_to_tri_sphere(
}
double d1, d2, d3, div;
-
/*
//\ 3|
@@ -1096,7 +1094,7 @@ static float dist_to_tri_sphere(
d3 = (d3 * d3) / div;
}
else {
- d3 = (x1-cx)*(x1-cx) + (y1-cy)*(y1-cy);
+ d3 = (x1 - cx) * (x1 - cx) + (y1 - cy) * (y1 - cy);
}
dis = d3;
@@ -1122,10 +1120,10 @@ static bool edge_queue_tri_in_sphere(const EdgeQueue *q, BMFace *f)
/* Check if triangle intersects the sphere */
float dis = dist_to_tri_sphere(q->center, l->v->co, l->next->v->co, l->prev->v->co, f->no);
- //closest_on_tri_to_point_v3(c, co, v1, v2, v3);
+ // closest_on_tri_to_point_v3(c, co, v1, v2, v3);
- //float dis2 = len_squared_v3v3(q->center, c);
- //float dis3 = sqrtf(dis2);
+ // float dis2 = len_squared_v3v3(q->center, c);
+ // float dis3 = sqrtf(dis2);
return dis <= q->radius_squared;
@@ -2991,6 +2989,48 @@ static double last_update_time[128] = {
0,
};
+bool BKE_pbvh_bmesh_update_topology_nodes(PBVH *pbvh,
+ bool (*searchcb)(PBVHNode *node, void *data),
+ void (*undopush)(PBVHNode *node, void *data),
+ void *searchdata,
+ PBVHTopologyUpdateMode mode,
+ const float center[3],
+ const float view_normal[3],
+ float radius,
+ const bool use_frontface,
+ const bool use_projected,
+ int sym_axis,
+ bool updatePBVH)
+{
+ bool modified = false;
+
+ for (int i = 0; i < pbvh->totnode; i++) {
+ PBVHNode *node = pbvh->nodes + i;
+
+ if (!(node->flag & PBVH_Leaf) || !searchcb(node, searchdata)) {
+ continue;
+ }
+
+ undopush(node, searchdata);
+
+ modified =
+ modified ||
+ BKE_pbvh_bmesh_update_topology(
+ pbvh, mode, center, view_normal, radius, use_frontface, use_projected, sym_axis, updatePBVH);
+
+ if (i < pbvh->totnode) { //nodes could have been reallocated on us
+ node = pbvh->nodes + i;
+
+ if (node->flag & PBVH_Leaf) {
+ BKE_pbvh_node_mark_topology_update(pbvh->nodes + i);
+ BKE_pbvh_bmesh_node_save_ortri(pbvh->bm, pbvh->nodes + i);
+ }
+ }
+ }
+
+ return modified;
+}
+
/* Collapse short edges, subdivide long edges */
bool BKE_pbvh_bmesh_update_topology(PBVH *pbvh,
PBVHTopologyUpdateMode mode,
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 5deb13885ed..2d9df99210f 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -818,6 +818,8 @@ void SCULPT_visibility_sync_all_vertex_to_face_sets(SculptSession *ss)
}
break;
}
+ case PBVH_GRIDS:
+ break;
case PBVH_BMESH: {
BMIter iter;
BMFace *f;
@@ -2396,8 +2398,9 @@ static void calc_area_normal_and_center_task_cb(void *__restrict userdata,
if (use_original) {
if (unode->bm_entry) {
- const float *temp_co;
- const float *temp_no;
+ float *temp_co;
+ float *temp_no;
+
BKE_pbvh_bmesh_update_origvert(ss->pbvh, vd.bm_vert, &temp_co, &temp_no, NULL);
if (temp_no) {
normal_float_to_short_v3(no_s, temp_no);
@@ -6179,6 +6182,17 @@ void SCULPT_vertcos_to_key(Object *ob, KeyBlock *kb, const float (*vertCos)[3])
BKE_keyblock_update_from_vertcos(ob, kb, vertCos);
}
+static void topology_undopush_cb(PBVHNode *node, void *data)
+{
+ SculptSearchSphereData *sdata = (SculptSearchSphereData *)data;
+
+ SCULPT_undo_push_node(sdata->ob,
+ node,
+ sdata->brush->sculpt_tool == SCULPT_TOOL_MASK ? SCULPT_UNDO_MASK :
+ SCULPT_UNDO_COORDS);
+ BKE_pbvh_node_mark_update(node);
+}
+
/* Note: we do the topology update before any brush actions to avoid
* issues with the proxies. The size of the proxy can't change, so
* topology must be updated first. */
@@ -6194,13 +6208,6 @@ static void sculpt_topology_update(Sculpt *sd,
const bool use_original = sculpt_tool_needs_original(brush->sculpt_tool) ? true :
ss->cache->original;
const float radius_scale = 1.25f;
- PBVHNode **nodes = sculpt_pbvh_gather_generic(
- ob, sd, brush, use_original, radius_scale, &totnode);
-
- /* Only act if some verts are inside the brush area. */
- if (totnode == 0) {
- return;
- }
/* Free index based vertex info as it will become invalid after modifying the topology during the
* stroke. */
@@ -6220,35 +6227,35 @@ static void sculpt_topology_update(Sculpt *sd,
}
}
- for (n = 0; n < totnode; n++) {
- SCULPT_undo_push_node(ob,
- nodes[n],
- brush->sculpt_tool == SCULPT_TOOL_MASK ? SCULPT_UNDO_MASK :
- SCULPT_UNDO_COORDS);
- BKE_pbvh_node_mark_update(nodes[n]);
-
- if (BKE_pbvh_type(ss->pbvh) == PBVH_BMESH) {
- int symidx = ss->cache->mirror_symmetry_pass + (ss->cache->radial_symmetry_pass * 8);
- if (symidx > 127) {
- symidx = 127;
- }
-
- BKE_pbvh_bmesh_update_topology(ss->pbvh,
- mode,
- ss->cache->location,
- ss->cache->view_normal,
- ss->cache->radius,
- (brush->flag & BRUSH_FRONTFACE) != 0,
- (brush->falloff_shape != PAINT_FALLOFF_SHAPE_SPHERE),
- symidx,
- brush->sculpt_tool != SCULPT_TOOL_DRAW_SHARP);
-
- BKE_pbvh_node_mark_topology_update(nodes[n]);
- BKE_pbvh_bmesh_node_save_orig(ss->bm, nodes[n]);
- }
- }
-
- MEM_SAFE_FREE(nodes);
+ PBVHNode **nodes = NULL;
+ SculptSearchSphereData sdata = {.ss = ss,
+ .sd = sd,
+ .ob = ob,
+ .radius_squared = square_f(ss->cache->radius * radius_scale),
+ .original = use_original,
+ .ignore_fully_ineffective = brush->sculpt_tool !=
+ SCULPT_TOOL_MASK,
+ .center = NULL,
+ .brush = brush};
+
+ int symidx = ss->cache->mirror_symmetry_pass + (ss->cache->radial_symmetry_pass * 8);
+ if (symidx > 127) {
+ symidx = 127;
+ }
+
+ /* do nodes under the brush cursor */
+ BKE_pbvh_bmesh_update_topology_nodes(ss->pbvh,
+ SCULPT_search_sphere_cb,
+ topology_undopush_cb,
+ &sdat
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list