[Bf-blender-cvs] [f9a2a9ae456] sculpt-dev: Sculpt-dev: fix extraneous calls to SCULPT_vertex_random_access_ensure

Joseph Eagar noreply at git.blender.org
Sat Dec 11 22:25:11 CET 2021


Commit: f9a2a9ae4564e6605527041c034cbf36646c3a44
Author: Joseph Eagar
Date:   Sat Dec 11 13:24:31 2021 -0800
Branches: sculpt-dev
https://developer.blender.org/rBf9a2a9ae4564e6605527041c034cbf36646c3a44

Sculpt-dev: fix extraneous calls to
            SCULPT_vertex_random_access_ensure

Fixes performance regression in simplify brush.

===================================================================

M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_smooth.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 005edb9b7c5..1c231841eb3 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -7947,7 +7947,7 @@ bool SCULPT_cursor_geometry_info_update(bContext *C,
   /* Update the active vertex of the SculptSession. */
   ss->active_vertex_index = srd.active_vertex_index;
 
-  SCULPT_vertex_random_access_ensure(ss);
+  //SCULPT_vertex_random_access_ensure(ss);
   copy_v3_v3(out->active_vertex_co, SCULPT_active_vertex_co_get(ss));
 
   switch (BKE_pbvh_type(ss->pbvh)) {
@@ -9428,11 +9428,13 @@ void SCULPT_connected_components_ensure(Object *ob)
   }
 }
 
+/* builds topological boundary bitmap. TODO: eliminate this function
+   and just used modern boundary API */
 void SCULPT_boundary_info_ensure(Object *object)
 {
   SculptSession *ss = object->sculpt;
 
-  // PBVH_BMESH now handles itself
+  // PBVH_BMESH now handles boundaries itself
   if (ss->bm) {
     return;
   }
diff --git a/source/blender/editors/sculpt_paint/sculpt_smooth.c b/source/blender/editors/sculpt_paint/sculpt_smooth.c
index e199ce6d834..11df2ef3b3a 100644
--- a/source/blender/editors/sculpt_paint/sculpt_smooth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_smooth.c
@@ -1056,7 +1056,9 @@ void vec_transform(float r_dir2[3], float no[3], int bits)
 }
 
 /* For bmesh: Average surrounding verts based on an orthogonality measure.
- * Naturally converges to a quad-like structure. */
+ * Naturally converges to a quad-like structure. Builds a simple cross
+ * field combining either mesh curvature principle direction or
+   stroke direction, and edge boundaries. */
 void SCULPT_bmesh_four_neighbor_average(SculptSession *ss,
                                         float avg[3],
                                         float direction[3],
@@ -1156,19 +1158,13 @@ void SCULPT_bmesh_four_neighbor_average(SculptSession *ss,
       no2 = mv2->origno;
     }
 
-    // bool bound = (mv2->flag &
-    //             (SCULPTVERT_BOUNDARY));  // | SCULPTVERT_FSET_BOUNDARY |
-    //             SCULPTVERT_SHARP_BOUNDARY));
-    // bool bound2 = (mv2->flag &
-    //               (SCULPTVERT_BOUNDARY | SCULPTVERT_FSET_BOUNDARY | SCULPTVERT_SHARP_BOUNDARY));
-
     SculptBoundaryType bflag = SCULPT_BOUNDARY_FACE_SET | SCULPT_BOUNDARY_MESH |
                                SCULPT_BOUNDARY_SHARP | SCULPT_BOUNDARY_SEAM | SCULPT_BOUNDARY_UV;
 
     int bound = SCULPT_edge_is_boundary(ss, (SculptEdgeRef){.i = (intptr_t)e}, bflag);
     float dirw = 1.0f;
 
-    if (bound) {  // || v_other->head.hflag & BM_ELEM_SELECT) {  // XXX
+    if (bound) {
       had_bound = true;
 
       sub_v3_v3v3(dir2, co2, co1);
@@ -1580,6 +1576,8 @@ static void SCULPT_enhance_details_brush(Sculpt *sd,
       ss, ob, ATTR_DOMAIN_POINT, CD_PROP_FLOAT3, "__dyntopo_detail_dir", &scl, &params);
 
   if (SCULPT_stroke_is_first_brush_step(ss->cache)) {
+    SCULPT_vertex_random_access_ensure(ss);
+
     const int totvert = SCULPT_vertex_count_get(ss);
 
     for (int i = 0; i < totvert; i++) {
@@ -2022,7 +2020,6 @@ void SCULPT_smooth(Sculpt *sd,
     return;
   }
 
-  SCULPT_vertex_random_access_ensure(ss);
   SCULPT_boundary_info_ensure(ob);
 
   float bound_smooth = SCULPT_get_float(ss, boundary_smooth, sd, brush);



More information about the Bf-blender-cvs mailing list