[Bf-blender-cvs] [be004d8e7e1] sculpt-dev: Sculpt: Fix fairing brush for dyntopo

Joseph Eagar noreply at git.blender.org
Thu Sep 30 20:03:32 CEST 2021


Commit: be004d8e7e100482de7c0c394ffb82644d8e0223
Author: Joseph Eagar
Date:   Thu Sep 30 11:02:17 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rBbe004d8e7e100482de7c0c394ffb82644d8e0223

Sculpt: Fix fairing brush for dyntopo

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

M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h

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

diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index c15ec5340d6..c4c39decf8d 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -732,12 +732,8 @@ static bool sculpt_temp_customlayer_get(SculptSession *ss,
   return true;
 }
 
-void SCULPT_update_customdata_refs(SculptSession *ss)
+ATTR_NO_OPT void SCULPT_update_customdata_refs(SculptSession *ss)
 {
-  if (ss->bm) {
-    SCULPT_dyntopo_node_layers_update_offsets(ss);
-  }
-
   /* run twice, in case sculpt_temp_customlayer_get had to recreate a layer and
      messed up the ordering. */
   for (int i = 0; i < 2; i++) {
@@ -750,6 +746,10 @@ void SCULPT_update_customdata_refs(SculptSession *ss)
       }
     }
   }
+
+  if (ss->bm) {
+    SCULPT_dyntopo_node_layers_update_offsets(ss);
+  }
 }
 
 float SCULPT_vertex_mask_get(SculptSession *ss, SculptVertRef index)
@@ -4811,7 +4811,7 @@ static void do_fairing_brush_tag_store_task_cb_ex(void *__restrict userdata,
   BKE_pbvh_vertex_iter_end;
 }
 
-static void do_fairing_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
+ATTR_NO_OPT static void do_fairing_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode)
 {
   SculptSession *ss = ob->sculpt;
   Brush *brush = BKE_paint_brush(&sd->paint);
@@ -4821,6 +4821,9 @@ static void do_fairing_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
     return;
   }
 
+  SCULPT_vertex_random_access_ensure(ss);
+  SCULPT_face_random_access_ensure(ss);
+
   if (!ss->custom_layers[SCULPT_SCL_FAIRING_MASK]) {
     // SCULPT_temp_customlayer_ensure(ss, ATTR_DOMAIN_POINT, CD_PROP_BOOL, "fairing_mask");
     // SCULPT_temp_customlayer_ensure(ss, ATTR_DOMAIN_POINT, CD_PROP_FLOAT, "fairing_fade");
@@ -4835,24 +4838,31 @@ static void do_fairing_brush(Sculpt *sd, Object *ob, PBVHNode **nodes, int totno
 
     SculptLayerParams params = {.permanent = false, .simple_array = true};
 
-    SCULPT_temp_customlayer_get(ss,
+    sculpt_temp_customlayer_get(ss,
                                 ATTR_DOMAIN_POINT,
                                 CD_PROP_BOOL,
                                 "fairing_mask",
                                 ss->custom_layers[SCULPT_SCL_FAIRING_MASK],
+                                true,
                                 &params);
-    SCULPT_temp_customlayer_get(ss,
+
+    sculpt_temp_customlayer_get(ss,
                                 ATTR_DOMAIN_POINT,
                                 CD_PROP_FLOAT,
                                 "fairing_fade",
                                 ss->custom_layers[SCULPT_SCL_FAIRING_FADE],
+                                true,
                                 &params);
-    SCULPT_temp_customlayer_get(ss,
+
+    sculpt_temp_customlayer_get(ss,
                                 ATTR_DOMAIN_POINT,
                                 CD_PROP_FLOAT3,
                                 "prefairing_co",
                                 ss->custom_layers[SCULPT_SCL_PREFAIRING_CO],
+                                true,
                                 &params);
+
+    SCULPT_update_customdata_refs(ss);
   }
 
   if (SCULPT_stroke_is_main_symmetry_pass(ss->cache)) {
diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h
index 600cc8e3cc9..fd05a7b7f8b 100644
--- a/source/blender/editors/sculpt_paint/sculpt_intern.h
+++ b/source/blender/editors/sculpt_paint/sculpt_intern.h
@@ -1804,7 +1804,7 @@ int SCULPT_get_symmetry_pass(const SculptSession *ss);
 void SCULPT_on_sculptsession_bmesh_free(SculptSession *ss);
 void SCULPT_reorder_bmesh(SculptSession *ss);
 
-static inline void *SCULPT_temp_cdata_get(SculptVertRef vertex, SculptCustomLayer *scl)
+ATTR_NO_OPT static inline void *SCULPT_temp_cdata_get(SculptVertRef vertex, SculptCustomLayer *scl)
 {
   if (scl->data) {
     char *p = (char *)scl->data;
@@ -1815,7 +1815,7 @@ static inline void *SCULPT_temp_cdata_get(SculptVertRef vertex, SculptCustomLaye
       idx = v->head.index;
     }
 
-    return p + scl->elemsize * (int)vertex.i;
+    return p + scl->elemsize * (int)idx;
   }
   else {
     BMElem *v = (BMElem *)vertex.i;
@@ -1837,7 +1837,7 @@ static inline void *SCULPT_temp_cdata_get_f(SculptFaceRef vertex, SculptCustomLa
       idx = v->head.index;
     }
 
-    return p + scl->elemsize * (int)vertex.i;
+    return p + scl->elemsize * (int)idx;
   }
   else {
     BMElem *v = (BMElem *)vertex.i;



More information about the Bf-blender-cvs mailing list