[Bf-blender-cvs] [99c01fa330d] greasepencil-object: GPencil: Basic structure of the new Vertex Color modifier

Antonio Vazquez noreply at git.blender.org
Tue Nov 5 19:51:53 CET 2019


Commit: 99c01fa330de3421a447995ce3f8cecde3ec5cec
Author: Antonio Vazquez
Date:   Tue Nov 5 17:55:26 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB99c01fa330de3421a447995ce3f8cecde3ec5cec

GPencil: Basic structure of the new Vertex Color modifier

Still not working, only put in place all parts.

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

M	release/scripts/startup/bl_ui/properties_data_modifier.py
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/space_outliner/outliner_draw.c
M	source/blender/gpencil_modifiers/CMakeLists.txt
M	source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
M	source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
A	source/blender/gpencil_modifiers/intern/MOD_gpencilvertexcolor.c
M	source/blender/makesdna/DNA_gpencil_modifier_types.h
M	source/blender/makesrna/RNA_access.h
M	source/blender/makesrna/intern/rna_gpencil_modifier.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 3f1764faabe..8890bb9a1ec 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -2350,6 +2350,55 @@ class DATA_PT_gpencil_modifiers(ModifierButtonsPanel, Panel):
         sub.active = bool(md.vertex_group)
         sub.prop(md, "invert_vertex_group", text="", icon='ARROW_LEFTRIGHT')
 
+    def GP_VERTEXCOLOR(self, layout, ob, md):
+        gpd = ob.data
+        split = layout.split()
+
+        col = split.column()
+        col.label(text="Object:")
+        col.prop(md, "object", text="")
+
+        layout.separator()
+
+        row = layout.row(align=True)
+        row.prop(md, "radius")
+        row = layout.row(align=True)
+        row.prop(md, "factor", slider=True)
+
+        col = layout.column()
+        col.separator()
+        col.label(text="Colors:")
+        col.template_color_ramp(md, "colors")
+
+        col = layout.column()
+        col.separator()
+        col.label(text="Vertex Group:")
+        row = col.row(align=True)
+        row.prop_search(md, "vertex_group", ob, "vertex_groups", text="")
+        row.prop(md, "invert_vertex", text="", icon='ARROW_LEFTRIGHT')
+
+        col = layout.column()
+        col.separator()
+
+        col.label(text="Material:")
+        row = col.row(align=True)
+        row.prop_search(md, "material", gpd, "materials", text="", icon='SHADING_TEXTURE')
+        row.prop(md, "invert_materials", text="", icon='ARROW_LEFTRIGHT')
+        row = layout.row(align=True)
+        row.prop(md, "pass_index", text="Pass")
+        row.prop(md, "invert_material_pass", text="", icon='ARROW_LEFTRIGHT')
+
+        col = layout.column()
+        col.separator()
+
+        col.label(text="Layer:")
+        row = col.row(align=True)
+        row.prop_search(md, "layer", gpd, "layers", text="", icon='GREASEPENCIL')
+        row.prop(md, "invert_layers", text="", icon='ARROW_LEFTRIGHT')
+        row = layout.row(align=True)
+        row.prop(md, "layer_pass", text="Pass")
+        row.prop(md, "invert_layer_pass", text="", icon='ARROW_LEFTRIGHT')
+
 
 classes = (
     DATA_PT_modifiers,
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 3866878b12a..fa37ea23978 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -5834,6 +5834,10 @@ static void direct_link_gpencil_modifiers(FileData *fd, ListBase *lb)
         BKE_curvemapping_initialize(gpmd->curve_thickness);
       }
     }
+    else if (md->type == eGpencilModifierType_Vertexcolor) {
+      VertexcolorGpencilModifierData *hmd = (VertexcolorGpencilModifierData *)md;
+      hmd->colorband = newdataadr(fd, hmd->colorband);
+    }
   }
 }
 
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index 2966a030f63..64c12122380 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -1792,6 +1792,12 @@ static void write_gpencil_modifiers(WriteData *wd, ListBase *modbase)
         write_curvemapping(wd, gpmd->curfalloff);
       }
     }
+    else if (md->type == eGpencilModifierType_Vertexcolor) {
+      VertexcolorGpencilModifierData *gpmd = (VertexcolorGpencilModifierData *)md;
+      if (gpmd->colorband) {
+        writestruct(wd, DATA, ColorBand, 1, gpmd->colorband);
+      }
+    }
   }
 }
 
diff --git a/source/blender/editors/space_outliner/outliner_draw.c b/source/blender/editors/space_outliner/outliner_draw.c
index d7a7d57b100..f6f5e9f2da0 100644
--- a/source/blender/editors/space_outliner/outliner_draw.c
+++ b/source/blender/editors/space_outliner/outliner_draw.c
@@ -2238,6 +2238,9 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
             case eGpencilModifierType_Armature:
               data.icon = ICON_MOD_ARMATURE;
               break;
+            case eGpencilModifierType_Vertexcolor:
+              data.icon = ICON_MOD_NORMALEDIT;
+              break;
 
               /* Default */
             default:
diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt
index 41543448a15..ce44addbc3c 100644
--- a/source/blender/gpencil_modifiers/CMakeLists.txt
+++ b/source/blender/gpencil_modifiers/CMakeLists.txt
@@ -59,6 +59,7 @@ set(SRC
   intern/MOD_gpencilthick.c
   intern/MOD_gpenciltime.c
   intern/MOD_gpenciltint.c
+  intern/MOD_gpencilvertexcolor.c
 
   MOD_gpencil_modifiertypes.h
 )
diff --git a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
index 9fc00754744..11c7cf9d9d3 100644
--- a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
+++ b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
@@ -42,6 +42,7 @@ extern GpencilModifierTypeInfo modifierType_Gpencil_Hook;
 extern GpencilModifierTypeInfo modifierType_Gpencil_Offset;
 extern GpencilModifierTypeInfo modifierType_Gpencil_Armature;
 extern GpencilModifierTypeInfo modifierType_Gpencil_Time;
+extern GpencilModifierTypeInfo modifierType_Gpencil_Vertexcolor;
 
 /* MOD_gpencil_util.c */
 void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[]);
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
index 2d1a845330b..417fd89b25e 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
@@ -71,6 +71,7 @@ void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[])
   INIT_GP_TYPE(Offset);
   INIT_GP_TYPE(Armature);
   INIT_GP_TYPE(Time);
+  INIT_GP_TYPE(Vertexcolor);
 #undef INIT_GP_TYPE
 }
 
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilvertexcolor.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilvertexcolor.c
new file mode 100644
index 00000000000..7ac6b60d862
--- /dev/null
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilvertexcolor.c
@@ -0,0 +1,231 @@
+/*
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software  Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2017, Blender Foundation
+ * This is a new part of Blender
+ */
+
+/** \file
+ * \ingroup modifiers
+ */
+
+#include <stdio.h>
+
+#include "BLI_utildefines.h"
+
+#include "BLI_math.h"
+
+#include "DNA_meshdata_types.h"
+#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
+#include "DNA_gpencil_types.h"
+#include "DNA_gpencil_modifier_types.h"
+#include "DNA_modifier_types.h"
+
+#include "BKE_action.h"
+#include "BKE_colorband.h"
+#include "BKE_colortools.h"
+#include "BKE_deform.h"
+#include "BKE_gpencil.h"
+#include "BKE_gpencil_modifier.h"
+#include "BKE_modifier.h"
+#include "BKE_library_query.h"
+#include "BKE_scene.h"
+#include "BKE_main.h"
+#include "BKE_layer.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "MOD_gpencil_util.h"
+#include "MOD_gpencil_modifiertypes.h"
+
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
+
+static void initData(GpencilModifierData *md)
+{
+  VertexcolorGpencilModifierData *gpmd = (VertexcolorGpencilModifierData *)md;
+  gpmd->pass_index = 0;
+  gpmd->layername[0] = '\0';
+  gpmd->materialname[0] = '\0';
+  gpmd->vgname[0] = '\0';
+  gpmd->object = NULL;
+  gpmd->colorband = BKE_colorband_add(false);
+  if (gpmd->colorband) {
+    BKE_colorband_init(gpmd->colorband, true);
+  }
+  CBData *ramp = gpmd->colorband->data;
+  /* Add default smooth-falloff ramp. */
+  ramp[0].r = ramp[0].g = ramp[0].b = ramp[0].a = 1.0f;
+  ramp[0].pos = 0.0f;
+  ramp[1].r = ramp[1].g = ramp[1].b = ramp[1].pos = 1.0f;
+  ramp[1].a = 0.0f;
+  gpmd->colorband->tot = 2;
+}
+
+static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
+{
+  VertexcolorGpencilModifierData *gmd = (VertexcolorGpencilModifierData *)md;
+  VertexcolorGpencilModifierData *tgmd = (VertexcolorGpencilModifierData *)target;
+
+  MEM_SAFE_FREE(tgmd->colorband);
+
+  BKE_gpencil_modifier_copyData_generic(md, target);
+  if (gmd->colorband) {
+    memcpy(tgmd->colorband, gmd->colorband, sizeof(gmd->colorband));
+  }
+}
+
+/* deform stroke */
+static void deformStroke(GpencilModifierData *md,
+                         Depsgraph *UNUSED(depsgraph),
+                         Object *ob,
+                         bGPDlayer *gpl,
+                         bGPDframe *UNUSED(gpf),
+                         bGPDstroke *gps)
+{
+  VertexcolorGpencilModifierData *mmd = (VertexcolorGpencilModifierData *)md;
+  if (!mmd->object) {
+    return;
+  }
+
+  const int def_nr = defgroup_name_index(ob, mmd->vgname);
+
+  if (!is_stroke_affected_by_modifier(ob,
+                                      mmd->layername,
+                                      mmd->materialname,
+                                      mmd->pass_index,
+                                      mmd->layer_pass,
+                                      1,
+                                      gpl,
+                                      gps,
+                                      mmd->flag & GP_HOOK_INVERT_LAYER,
+                                      mmd->flag & GP_HOOK_INVERT_PASS,
+                                      mmd->flag & GP_HOOK_INVERT_LAYERPASS,
+                                      mmd->flag & GP_HOOK_INVERT_MATERIAL)) {
+    return;
+  }
+
+  //  /* ju

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list