[Bf-blender-cvs] [6dde88c5366] master: Vertex paint mode tried to do a "fast update" by trying to avoid tagging the mesh ID for a full update. The conditions it uses are troublesome: 1. There must be an evaluated mesh 2. The evaluated mesh's active byte color layer must equal the original's

Hans Goudey noreply at git.blender.org
Thu Jun 23 19:05:53 CEST 2022


Commit: 6dde88c5366be0d855fded2588290818fbf53928
Author: Hans Goudey
Date:   Thu Jun 23 12:05:48 2022 -0500
Branches: master
https://developer.blender.org/rB6dde88c5366be0d855fded2588290818fbf53928

Vertex paint mode tried to do a "fast update" by trying to avoid tagging
the mesh ID for a full update. The conditions it uses are troublesome:
 1. There must be an evaluated mesh
 2. The evaluated mesh's active byte color layer must equal the original's

This logic doesn't make sense for a few reasons. First of all, the
`mloopcol` pointer doesn't make sense in the context of color
attributes (rather than the old vertex colors), since it only points
to byte color attribute on face corners. Second, just because the
layer pointers are equal doesn't mean something doesn't depend
on the attribute's values.

I think the best solution currently is to remove this "fast update"
case and instead work on optimizing the general case.

Also, T95842 suggests removing these pointers, and this is one
of the last remaining uses of `Mesh.mloopcol`.

Differential Revision: https://developer.blender.org/D15275

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

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

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

diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc
index 67b60acc667..ec7ba1741b7 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.cc
+++ b/source/blender/editors/sculpt_paint/paint_vertex.cc
@@ -227,22 +227,6 @@ static MDeformVert *defweight_prev_init(MDeformVert *dvert_prev,
   return dv_prev;
 }
 
-/* check if we can do partial updates and have them draw realtime
- * (without evaluating modifiers) */
-static bool vertex_paint_use_fast_update_check(Object *ob)
-{
-  const Mesh *me_eval = BKE_object_get_evaluated_mesh(ob);
-
-  if (me_eval != nullptr) {
-    const Mesh *me = BKE_mesh_from_object(ob);
-    if (me && me->mloopcol) {
-      return (me->mloopcol == CustomData_get_layer(&me_eval->ldata, CD_PROP_BYTE_COLOR));
-    }
-  }
-
-  return false;
-}
-
 static void paint_last_stroke_update(Scene *scene, const float location[3])
 {
   UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
@@ -2838,12 +2822,6 @@ struct VPaintData : public VPaintDataBase {
   struct VertProjHandle *vp_handle;
   CoNo *vertexcosnos;
 
-  /**
-   * Modify #Mesh.mloopcol directly, since the derived mesh is drawing from this
-   * array, otherwise we need to refresh the modifier stack.
-   */
-  bool use_fast_update;
-
   /* loops tagged as having been painted, to apply shared vertex color
    * blending only to modified loops */
   bool *mlooptag;
@@ -2893,15 +2871,6 @@ static void *vpaint_init_vpaint(bContext *C,
 
   vpd->is_texbrush = !(brush->vertexpaint_tool == VPAINT_TOOL_BLUR) && brush->mtex.tex;
 
-  /* are we painting onto a modified mesh?,
-   * if not we can skip face map trickiness */
-  if (vertex_paint_use_fast_update_check(ob)) {
-    vpd->use_fast_update = true;
-  }
-  else {
-    vpd->use_fast_update = false;
-  }
-
   /* to keep tracked of modified loops for shared vertex color blending */
   if (brush->vertexpaint_tool == VPAINT_TOOL_BLUR) {
     vpd->mlooptag = (bool *)MEM_mallocN(sizeof(bool) * elem_num, "VPaintData mlooptag");
@@ -3901,15 +3870,7 @@ static void vpaint_stroke_update_step_intern(bContext *C, PaintStroke *stroke, P
 
   ED_region_tag_redraw(vc->region);
 
-  if (vpd->use_fast_update == false) {
-    /* recalculate modifier stack to get new colors, slow,
-     * avoid this if we can! */
-    DEG_id_tag_update((ID *)ob->data, 0);
-  }
-  else {
-    /* Flush changes through DEG. */
-    DEG_id_tag_update((ID *)ob->data, ID_RECALC_COPY_ON_WRITE);
-  }
+  DEG_id_tag_update((ID *)ob->data, ID_RECALC_GEOMETRY);
 }
 
 static void vpaint_stroke_update_step(bContext *C,



More information about the Bf-blender-cvs mailing list