[Bf-blender-cvs] [0ad8f3ff585] master: Sculpt: fix T102348: Don't fold area normal automasking into cache

Joseph Eagar noreply at git.blender.org
Mon Nov 28 22:12:01 CET 2022


Commit: 0ad8f3ff585c9693bb0cc84108ced00e8e0e1771
Author: Joseph Eagar
Date:   Mon Nov 28 12:59:53 2022 -0800
Branches: master
https://developer.blender.org/rB0ad8f3ff585c9693bb0cc84108ced00e8e0e1771

Sculpt: fix T102348: Don't fold area normal automasking into cache

Certain automasking modes build a factor cache.  Modes
that rely on the mirror symmetry pass should not fold into
this pass.

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

M	source/blender/editors/sculpt_paint/sculpt_automasking.cc

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

diff --git a/source/blender/editors/sculpt_paint/sculpt_automasking.cc b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
index 211ff14c906..e490cb762fc 100644
--- a/source/blender/editors/sculpt_paint/sculpt_automasking.cc
+++ b/source/blender/editors/sculpt_paint/sculpt_automasking.cc
@@ -185,9 +185,8 @@ static bool SCULPT_automasking_needs_factors_cache(const Sculpt *sd, const Brush
     return true;
   }
 
-  if (automasking_flags &
-      (BRUSH_AUTOMASKING_BOUNDARY_EDGES | BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS |
-       BRUSH_AUTOMASKING_BRUSH_NORMAL | BRUSH_AUTOMASKING_VIEW_NORMAL)) {
+  if (automasking_flags & (BRUSH_AUTOMASKING_BOUNDARY_EDGES |
+                           BRUSH_AUTOMASKING_BOUNDARY_FACE_SETS | BRUSH_AUTOMASKING_VIEW_NORMAL)) {
     return brush && brush->automasking_boundary_edges_propagation_steps != 1;
   }
   return false;
@@ -507,6 +506,16 @@ float SCULPT_automasking_factor_get(AutomaskingCache *automasking,
     return 1.0f;
   }
 
+  float mask = 1.0f;
+
+  /* Since brush normal mode depends on the current mirror symmery pass
+   * it is not folded into the factor cache (when it exists).
+   */
+  if ((ss->cache || ss->filter_cache) &&
+      (automasking->settings.flags & BRUSH_AUTOMASKING_BRUSH_NORMAL)) {
+    mask *= automasking_brush_normal_factor(automasking, ss, vert, automask_data);
+  }
+
   /* If the cache is initialized with valid info, use the cache. This is used when the
    * automasking information can't be computed in real time per vertex and needs to be
    * initialized for the whole mesh when the stroke starts. */
@@ -517,7 +526,7 @@ float SCULPT_automasking_factor_get(AutomaskingCache *automasking,
       factor *= sculpt_automasking_cavity_factor(automasking, ss, vert);
     }
 
-    return factor;
+    return factor * mask;
   }
 
   uchar stroke_id = ss->attrs.automasking_stroke_id ?
@@ -554,13 +563,6 @@ float SCULPT_automasking_factor_get(AutomaskingCache *automasking,
     }
   }
 
-  float mask = 1.0f;
-
-  if ((ss->cache || ss->filter_cache) &&
-      (automasking->settings.flags & BRUSH_AUTOMASKING_BRUSH_NORMAL)) {
-    mask *= automasking_brush_normal_factor(automasking, ss, vert, automask_data);
-  }
-
   if ((ss->cache || ss->filter_cache) &&
       (automasking->settings.flags & BRUSH_AUTOMASKING_VIEW_NORMAL)) {
     mask *= automasking_view_normal_factor(automasking, ss, vert, automask_data);
@@ -782,9 +784,6 @@ static void sculpt_normal_occlusion_automasking_fill(AutomaskingCache *automaski
 
     float f = *(float *)SCULPT_vertex_attr_get(vertex, ss->attrs.automasking_factor);
 
-    if (int(mode) & BRUSH_AUTOMASKING_BRUSH_NORMAL) {
-      f *= automasking_brush_normal_factor(automasking, ss, vertex, &nodedata);
-    }
     if (int(mode) & BRUSH_AUTOMASKING_VIEW_NORMAL) {
       if (int(mode) & BRUSH_AUTOMASKING_VIEW_OCCLUSION) {
         f *= automasking_view_occlusion_factor(automasking, ss, vertex, -1, &nodedata);
@@ -940,8 +939,7 @@ AutomaskingCache *SCULPT_automasking_cache_init(Sculpt *sd, Brush *brush, Object
 
   /* Subtractive modes. */
   int normal_bits = sculpt_automasking_mode_effective_bits(sd, brush) &
-                    (BRUSH_AUTOMASKING_BRUSH_NORMAL | BRUSH_AUTOMASKING_VIEW_NORMAL |
-                     BRUSH_AUTOMASKING_VIEW_OCCLUSION);
+                    (BRUSH_AUTOMASKING_VIEW_NORMAL | BRUSH_AUTOMASKING_VIEW_OCCLUSION);
 
   if (normal_bits) {
     sculpt_normal_occlusion_automasking_fill(automasking, ob, (eAutomasking_flag)normal_bits);



More information about the Bf-blender-cvs mailing list