Commit: 08d04e4ed6f71157477f53e20e881382d809da27
Author: Joseph Eagar
Date:   Mon Feb 21 22:43:14 2022 -0800
Branches: temp-sculpt-colors
https://developer.blender.org/rB08d04e4ed6f71157477f53e20e881382d809da27

temp-sculpt-colors: Fix mask by color and
                    a few other minor bugs

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

M       source/blender/editors/sculpt_paint/sculpt_ops.c
M       source/blender/editors/sculpt_paint/sculpt_undo.c

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

diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c 
b/source/blender/editors/sculpt_paint/sculpt_ops.c
index 888f9c53d92..5d1b176537a 100644
--- a/source/blender/editors/sculpt_paint/sculpt_ops.c
+++ b/source/blender/editors/sculpt_paint/sculpt_ops.c
@@ -1030,12 +1030,11 @@ static int sculpt_mask_by_color_invoke(bContext *C, 
wmOperator *op, const wmEven
     return OPERATOR_CANCELLED;
   }
 
-  if (!ss->vcol) {
+  if (!SCULPT_has_colors(ss)) {
     return OPERATOR_CANCELLED;
   }
 
   BKE_pbvh_ensure_node_loops(ss->pbvh, BKE_object_get_original_mesh(ob));
-
   SCULPT_vertex_random_access_ensure(ss);
 
   /* Tools that are not brushes do not have the brush gizmo to update the 
vertex as the mouse move,
diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.c 
b/source/blender/editors/sculpt_paint/sculpt_undo.c
index 0db85ebc430..42437a6bb64 100644
--- a/source/blender/editors/sculpt_paint/sculpt_undo.c
+++ b/source/blender/editors/sculpt_paint/sculpt_undo.c
@@ -343,14 +343,14 @@ static bool sculpt_undo_restore_color(bContext *C, 
SculptUndoNode *unode)
 
   /* Note: even with loop colors we still store (derived)
    * vertex colors for original data lookup. */
-  if (unode->maxvert && !unode->totloop) {
+  if (unode->col && !unode->loop_col) {
     BKE_pbvh_swap_colors(ss->pbvh, unode->col, unode->index, unode->totvert);
     modified = true;
   }
 
   Mesh *me = BKE_object_get_original_mesh(ob);
 
-  if (unode->totloop && unode->maxloop == me->totloop) {
+  if (unode->loop_col && unode->maxloop == me->totloop) {
     BKE_pbvh_swap_colors(ss->pbvh, unode->loop_col, unode->loop_index, 
unode->totloop);
 
     modified = true;
@@ -1221,7 +1221,7 @@ static void sculpt_undo_store_color(Object *ob, 
SculptUndoNode *unode)
    * vertex colors for original data lookup. */
   BKE_pbvh_store_colors_vertex(ss->pbvh, unode->col, unode->index, allvert);
 
-  if (unode->maxloop && unode->totloop) {
+  if (unode->loop_col && unode->totloop) {
     BKE_pbvh_store_colors(ss->pbvh, unode->loop_col, unode->loop_index, 
unode->totloop);
   }
 }
@@ -1402,11 +1402,13 @@ SculptUndoNode *SCULPT_undo_push_node(Object *ob, 
PBVHNode *node, SculptUndoType
     BKE_pbvh_node_get_verts(ss->pbvh, node, &vert_indices, NULL);
     memcpy(unode->index, vert_indices, sizeof(int) * allvert);
 
-    BKE_pbvh_node_num_loops(ss->pbvh, unode->node, &uniqloop, NULL);
-    BKE_pbvh_node_get_loops(ss->pbvh, unode->node, &loop_indices, NULL);
-    memcpy(unode->loop_index, loop_indices, sizeof(int) * uniqloop);
+    if (unode->loop_index) {
+      BKE_pbvh_node_num_loops(ss->pbvh, unode->node, &uniqloop, NULL);
+      BKE_pbvh_node_get_loops(ss->pbvh, unode->node, &loop_indices, NULL);
+      memcpy(unode->loop_index, loop_indices, sizeof(int) * uniqloop);
 
-    unode->maxloop = BKE_object_get_original_mesh(ob)->totloop;
+      unode->maxloop = BKE_object_get_original_mesh(ob)->totloop;
+    }
   }
 
   switch (type) {

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
List details, subscription details or unsubscribe:
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to