[Bf-blender-cvs] [6d09fa35773] master: DynamicPaint: Remove Previews

Jeroen Bakker noreply at git.blender.org
Thu Apr 25 08:03:04 CEST 2019


Commit: 6d09fa357731e3444a08aa7e705aab8fb4ed895d
Author: Jeroen Bakker
Date:   Wed Apr 24 15:43:58 2019 +0200
Branches: master
https://developer.blender.org/rB6d09fa357731e3444a08aa7e705aab8fb4ed895d

DynamicPaint: Remove Previews

Modifier previews should be implemented by a more generic system.
The current system is already a hack and needed a lot of work
to get it working again in 2.80 and even so that would be replaced by
another system in the near future.

For Vertex Colors we have a work around in place by using Workbench
Vertex Colors. For Vertex Weights we loose the previewing. Not sure
targetting weight is working (even for 279).

Reviewed By: brecht

Maniphest Tasks: T63857

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

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

M	release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
M	source/blender/blenkernel/BKE_dynamicpaint.h
M	source/blender/blenkernel/intern/dynamicpaint.c
M	source/blender/editors/physics/dynamicpaint_ops.c
M	source/blender/makesdna/DNA_dynamicpaint_types.h
M	source/blender/makesrna/intern/rna_dynamicpaint.c

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

diff --git a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
index fec8723ef5e..4eb43695eb5 100644
--- a/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
+++ b/release/scripts/startup/bl_ui/properties_physics_dynamicpaint.py
@@ -39,15 +39,6 @@ class PHYSICS_UL_dynapaint_surfaces(UIList):
             row.label(text="", icon_value=icon)
             row.prop(surf, "name", text="", emboss=False, icon_value=sticon)
             row = layout.row(align=True)
-
-            if surf.use_color_preview:
-                row.prop(
-                    surf,
-                    "show_preview",
-                    text="",
-                    emboss=False,
-                    icon='RESTRICT_VIEW_OFF' if surf.show_preview else 'RESTRICT_VIEW_ON'
-                )
             row.prop(surf, "is_active", text="")
 
         elif self.layout_type == 'GRID':
@@ -373,9 +364,6 @@ class PHYSICS_PT_dp_canvas_output(PhysicButtonsPanel, Panel):
         # vertex format outputs.
         if surface.surface_format == 'VERTEX':
             if surface_type == 'PAINT':
-                # toggle active preview.
-                layout.prop(surface, "preview_id")
-
                 # paint-map output.
                 row = layout.row()
                 row.prop_search(surface, "output_name_a", ob.data, "vertex_colors", text="Paintmap Layer")
diff --git a/source/blender/blenkernel/BKE_dynamicpaint.h b/source/blender/blenkernel/BKE_dynamicpaint.h
index 9f4f2862c95..c4f05d404ce 100644
--- a/source/blender/blenkernel/BKE_dynamicpaint.h
+++ b/source/blender/blenkernel/BKE_dynamicpaint.h
@@ -83,13 +83,11 @@ void dynamicPaint_freeBrush(struct DynamicPaintModifierData *pmd);
 void dynamicPaint_freeSurfaceData(struct DynamicPaintSurface *surface);
 
 void dynamicPaint_cacheUpdateFrames(struct DynamicPaintSurface *surface);
-bool dynamicPaint_surfaceHasColorPreview(struct DynamicPaintSurface *surface);
 bool dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface,
                                     struct Object *ob,
                                     int output);
 void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface);
 void dynamicPaintSurface_setUniqueName(struct DynamicPaintSurface *surface, const char *basename);
-void dynamicPaint_resetPreview(struct DynamicPaintCanvasSettings *canvas);
 struct DynamicPaintSurface *get_activeSurface(struct DynamicPaintCanvasSettings *canvas);
 
 /* image sequence baking */
diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c
index 7fef07346c3..38ecc95da22 100644
--- a/source/blender/blenkernel/intern/dynamicpaint.c
+++ b/source/blender/blenkernel/intern/dynamicpaint.c
@@ -302,56 +302,12 @@ static int dynamicPaint_surfaceNumOfPoints(DynamicPaintSurface *surface)
   return 0;
 }
 
-/* checks whether surface's format/type has realtime preview */
-bool dynamicPaint_surfaceHasColorPreview(DynamicPaintSurface *surface)
-{
-  if (surface->format == MOD_DPAINT_SURFACE_F_IMAGESEQ) {
-    return false;
-  }
-  else if (surface->format == MOD_DPAINT_SURFACE_F_VERTEX) {
-    return !ELEM(surface->type, MOD_DPAINT_SURFACE_T_DISPLACE, MOD_DPAINT_SURFACE_T_WAVE);
-  }
-
-  return true;
-}
-
 /* get currently active surface (in user interface) */
 DynamicPaintSurface *get_activeSurface(DynamicPaintCanvasSettings *canvas)
 {
   return BLI_findlink(&canvas->surfaces, canvas->active_sur);
 }
 
-/* set preview to first previewable surface */
-void dynamicPaint_resetPreview(DynamicPaintCanvasSettings *canvas)
-{
-  DynamicPaintSurface *surface = canvas->surfaces.first;
-  bool done = false;
-
-  for (; surface; surface = surface->next) {
-    if (!done && dynamicPaint_surfaceHasColorPreview(surface)) {
-      surface->flags |= MOD_DPAINT_PREVIEW;
-      done = true;
-    }
-    else {
-      surface->flags &= ~MOD_DPAINT_PREVIEW;
-    }
-  }
-}
-
-/* set preview to defined surface */
-static void dynamicPaint_setPreview(DynamicPaintSurface *t_surface)
-{
-  DynamicPaintSurface *surface = t_surface->canvas->surfaces.first;
-  for (; surface; surface = surface->next) {
-    if (surface == t_surface) {
-      surface->flags |= MOD_DPAINT_PREVIEW;
-    }
-    else {
-      surface->flags &= ~MOD_DPAINT_PREVIEW;
-    }
-  }
-}
-
 bool dynamicPaint_outputLayerExists(struct DynamicPaintSurface *surface, Object *ob, int output)
 {
   const char *name;
@@ -471,14 +427,6 @@ void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface)
   }
 
   surface_setUniqueOutputName(surface, surface->output_name, 0);
-
-  /* update preview */
-  if (dynamicPaint_surfaceHasColorPreview(surface)) {
-    dynamicPaint_setPreview(surface);
-  }
-  else {
-    dynamicPaint_resetPreview(surface->canvas);
-  }
 }
 
 static int surface_totalSamples(DynamicPaintSurface *surface)
@@ -1079,7 +1027,7 @@ DynamicPaintSurface *dynamicPaint_createNewSurface(DynamicPaintCanvasSettings *c
 
   /* Set initial values */
   surface->flags = MOD_DPAINT_ANTIALIAS | MOD_DPAINT_MULALPHA | MOD_DPAINT_DRY_LOG |
-                   MOD_DPAINT_DISSOLVE_LOG | MOD_DPAINT_ACTIVE | MOD_DPAINT_PREVIEW |
+                   MOD_DPAINT_DISSOLVE_LOG | MOD_DPAINT_ACTIVE |
                    MOD_DPAINT_OUT1 | MOD_DPAINT_USE_DRYING;
   surface->effect = 0;
   surface->effect_ui = 1;
@@ -1280,7 +1228,6 @@ void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd,
       t_surface->disp_type = surface->disp_type;
       t_surface->image_fileformat = surface->image_fileformat;
       t_surface->effect_ui = surface->effect_ui;
-      t_surface->preview_id = surface->preview_id;
       t_surface->init_color_type = surface->init_color_type;
       t_surface->flags = surface->flags;
       t_surface->effect = surface->effect;
@@ -1323,7 +1270,6 @@ void dynamicPaint_Modifier_copy(const struct DynamicPaintModifierData *pmd,
       BLI_strncpy(t_surface->output_name, surface->output_name, sizeof(t_surface->output_name));
       BLI_strncpy(t_surface->output_name2, surface->output_name2, sizeof(t_surface->output_name2));
     }
-    dynamicPaint_resetPreview(tpmd->canvas);
   }
   else if (tpmd->brush) {
     DynamicPaintBrushSettings *brush = pmd->brush, *t_brush = tpmd->brush;
@@ -1841,7 +1787,6 @@ typedef struct DynamicPaintModifierApplyData {
   float (*fcolor)[4];
   MLoopCol *mloopcol;
   MLoopCol *mloopcol_wet;
-  MLoopCol *mloopcol_preview;
 } DynamicPaintModifierApplyData;
 
 static void dynamic_paint_apply_surface_displace_cb(void *__restrict userdata,
@@ -1906,7 +1851,6 @@ static void dynamic_paint_apply_surface_vpaint_cb(void *__restrict userdata,
                                                   const ParallelRangeTLS *__restrict UNUSED(tls))
 {
   const DynamicPaintModifierApplyData *data = userdata;
-  Object *ob = data->ob;
 
   const MLoop *mloop = data->mloop;
   const MPoly *mpoly = data->mpoly;
@@ -1917,11 +1861,6 @@ static void dynamic_paint_apply_surface_vpaint_cb(void *__restrict userdata,
 
   MLoopCol *mloopcol = data->mloopcol;
   MLoopCol *mloopcol_wet = data->mloopcol_wet;
-  MLoopCol *mloopcol_preview = data->mloopcol_preview;
-
-  const Material *material = mloopcol_preview ?
-                                 give_current_material(ob, mpoly[p_index].mat_nr + 1) :
-                                 NULL;
 
   for (int j = 0; j < mpoly[p_index].totloop; j++) {
     const int l_index = mpoly[p_index].loopstart + j;
@@ -1940,37 +1879,6 @@ static void dynamic_paint_apply_surface_vpaint_cb(void *__restrict userdata,
       mloopcol_wet[l_index].b = c;
       mloopcol_wet[l_index].a = 255;
     }
-
-    /* viewport preview */
-    if (mloopcol_preview) {
-      if (surface->preview_id == MOD_DPAINT_SURFACE_PREV_PAINT) {
-        float c[3];
-
-        /* Apply material color as base vertex color for preview */
-        mloopcol_preview[l_index].a = 255;
-        if (material) {
-          c[0] = material->r;
-          c[1] = material->g;
-          c[2] = material->b;
-        }
-        else { /* default gray */
-          c[0] = 0.65f;
-          c[1] = 0.65f;
-          c[2] = 0.65f;
-        }
-        /* mix surface color */
-        interp_v3_v3v3(c, c, fcolor[v_index], fcolor[v_index][3]);
-
-        rgb_float_to_uchar((unsigned char *)&mloopcol_preview[l_index].r, c);
-      }
-      else {
-        const char c = unit_float_to_uchar_clamp(pPoint[v_index].wetness);
-        mloopcol_preview[l_index].r = c;
-        mloopcol_preview[l_index].g = c;
-        mloopcol_preview[l_index].b = c;
-        mloopcol_preview[l_index].a = 255;
-      }
-    }
   }
 }
 
@@ -2056,22 +1964,11 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
                   &result->ldata, CD_MLOOPCOL, CD_CALLOC, NULL, totloop, surface->output_name2);
             }
 
-            /* Save preview results to weight layer to be able to share same drawing methods */
-            MLoopCol *mloopcol_preview = NULL;
-            if (surface->flags & MOD_DPAINT_PREVIEW) {
-              mloopcol_preview = CustomData_get_layer(&result->ldata, CD_PREVIEW_MLOOPCOL);
-              if (!mloopcol_preview) {
-                mloopcol_preview = CustomData_add_layer(
-                    &result->ldata, CD_PREVIEW_MLOOPCOL, CD_CALLOC, NULL, totloop);
-              }
-            }
-
             data.ob = ob;
             data.mloop = mloop;
             data.mpoly = mpoly;
             data.mloopcol = mloopcol;
             data.mloopcol_wet = mloopcol_wet;
-            data.mloopcol_preview = mloopcol_preview;
 
             {
               ParallelRangeSettings settings;
@@ -2092,15 +1989,6 @@ static Mesh *dynamicPaint_Modifier_apply(DynamicPaintModifierData *pmd, Object *
             MDeformVert *dvert = CustomData_get_layer(&result->vdata, CD_MDEFORMVERT);
             float *weight = (float *)sData->type_data;
 
-            /* viewport preview */
-            if (surface->flags & MOD_DPAINT_PREVIEW) {
-              /* Save preview results to weight layer to be
-               * able to share same drawing methods.
-               * Note this func also sets DM_DIRTY_TESS_CDLAYERS fl

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list