[Bf-blender-cvs] [c4c44ab0f5b] temp-npr-gpencil-modifiers: Gpencil: npr related modifier files added. Including length modifier and multiply modifier.

YimingWu noreply at git.blender.org
Sat Sep 14 10:19:15 CEST 2019


Commit: c4c44ab0f5bc8e63ee1d2775539a3441c85b55b3
Author: YimingWu
Date:   Sat Sep 14 15:36:15 2019 +0800
Branches: temp-npr-gpencil-modifiers
https://developer.blender.org/rBc4c44ab0f5bc8e63ee1d2775539a3441c85b55b3

Gpencil: npr related modifier files added.
Including length modifier and multiply modifier.

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

M	release/datafiles/locale
M	release/scripts/addons
M	release/scripts/addons_contrib
M	release/scripts/startup/bl_ui/properties_data_modifier.py
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_gpencillength.c
A	source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
M	source/blender/makesdna/DNA_gpencil_modifier_types.h
M	source/blender/makesrna/intern/rna_gpencil_modifier.c
M	source/tools

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

diff --git a/release/datafiles/locale b/release/datafiles/locale
index 1f6ec7f7a14..ad82c4ce43e 160000
--- a/release/datafiles/locale
+++ b/release/datafiles/locale
@@ -1 +1 @@
-Subproject commit 1f6ec7f7a145c36808231090c8666febb49db220
+Subproject commit ad82c4ce43ef2801ef51e75af1f9702992478b02
diff --git a/release/scripts/addons b/release/scripts/addons
index eb9bab0e715..8e6f485cf5b 160000
--- a/release/scripts/addons
+++ b/release/scripts/addons
@@ -1 +1 @@
-Subproject commit eb9bab0e7153fda8de113af9e3c54eca74c986ef
+Subproject commit 8e6f485cf5b160c425d7da7c743879b20f3d6a96
diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib
index 23b744fa47d..7077ff07384 160000
--- a/release/scripts/addons_contrib
+++ b/release/scripts/addons_contrib
@@ -1 +1 @@
-Subproject commit 23b744fa47da73c0b6c5b41b02cfe0efa008ec5c
+Subproject commit 7077ff07384491d1f7630484995557f1c7302dae
diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 124fe77cb52..badbdc5769d 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -2334,7 +2334,38 @@ 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_LENGTH(self, layout, ob, md):
+        sp = layout.split()
+        col = sp.column()
+        col.label(text="Absolute:")
+        col.prop(md, "length")
+
+        col = sp.column()
+        col.label(text="Relative:")
+        col.prop(md, "percentage")
+    
+    def GP_MULTIPLY(self, layout, ob, md):
+        sp = layout.split(factor = 0.5)
+
+        col = sp.column()
+        col.prop(md, "enable_duplication")
+        if md.enable_duplication:
+            col.prop(md,"duplications")
+            col.prop(md,"distance")
+            col.prop(md,"offset", slider=True)
+        
+            col.prop(md,"enable_fading")
+            if md.enable_fading:
+                col.prop(md, "fading_center")
+                c = col.column(align = True)
+                c.prop(md, "fading_thickness", slider=True)
+                c.prop(md, "fading_opacity", slider=True)
+
+        col = sp.column()
+        col.prop(md, "enable_angle_splitting")
+        if md.enable_angle_splitting:
+            col.prop(md,"split_angle")
+            
 classes = (
     DATA_PT_modifiers,
     DATA_PT_gpencil_modifiers,
diff --git a/source/blender/gpencil_modifiers/CMakeLists.txt b/source/blender/gpencil_modifiers/CMakeLists.txt
index 41543448a15..fa01a1cbad3 100644
--- a/source/blender/gpencil_modifiers/CMakeLists.txt
+++ b/source/blender/gpencil_modifiers/CMakeLists.txt
@@ -49,7 +49,9 @@ set(SRC
   intern/MOD_gpencilcolor.c
   intern/MOD_gpencilhook.c
   intern/MOD_gpencillattice.c
+  intern/MOD_gpencillength.c
   intern/MOD_gpencilmirror.c
+  intern/MOD_gpencilmultiply.c
   intern/MOD_gpencilnoise.c
   intern/MOD_gpenciloffset.c
   intern/MOD_gpencilopacity.c
diff --git a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
index 9fc00754744..b84ccbcab64 100644
--- a/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
+++ b/source/blender/gpencil_modifiers/MOD_gpencil_modifiertypes.h
@@ -42,6 +42,8 @@ extern GpencilModifierTypeInfo modifierType_Gpencil_Hook;
 extern GpencilModifierTypeInfo modifierType_Gpencil_Offset;
 extern GpencilModifierTypeInfo modifierType_Gpencil_Armature;
 extern GpencilModifierTypeInfo modifierType_Gpencil_Time;
+extern GpencilModifierTypeInfo modifierType_Gpencil_Length;
+extern GpencilModifierTypeInfo modifierType_Gpencil_Multiply;
 
 /* 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 b44965707d8..72385fd2f2c 100644
--- a/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencil_util.c
@@ -71,6 +71,8 @@ void gpencil_modifier_type_init(GpencilModifierTypeInfo *types[])
   INIT_GP_TYPE(Offset);
   INIT_GP_TYPE(Armature);
   INIT_GP_TYPE(Time);
+  INIT_GP_TYPE(Length);
+  INIT_GP_TYPE(Multiply);
 #undef INIT_GP_TYPE
 }
 
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c b/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c
new file mode 100644
index 00000000000..29c98eced26
--- /dev/null
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencillength.c
@@ -0,0 +1,155 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+/** \file blender/gpencil_modifiers/intern/MOD_gpencilstrokes.c
+ *  \ingroup modifiers
+ */
+
+#include <stdio.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
+#include "DNA_gpencil_types.h"
+#include "DNA_gpencil_modifier_types.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_rand.h"
+#include "BLI_math.h"
+#include "BLI_utildefines.h"
+#include "BLI_linklist.h"
+#include "BLI_alloca.h"
+
+#include "BKE_gpencil.h"
+#include "BKE_gpencil_modifier.h"
+#include "BKE_modifier.h"
+#include "BKE_context.h"
+#include "BKE_global.h"
+#include "BKE_object.h"
+#include "BKE_main.h"
+#include "BKE_scene.h"
+#include "BKE_layer.h"
+#include "BKE_library_query.h"
+#include "BKE_collection.h"
+#include "BKE_mesh.h"
+#include "BKE_mesh_mapping.h"
+
+#include "bmesh.h"
+#include "bmesh_tools.h"
+
+#include "DEG_depsgraph.h"
+#include "DEG_depsgraph_build.h"
+#include "DEG_depsgraph_query.h"
+
+#include "MOD_gpencil_util.h"
+#include "MOD_gpencil_modifiertypes.h"
+
+static void copyData(const GpencilModifierData *md, GpencilModifierData *target)
+{
+  BKE_gpencil_modifier_copyData_generic(md, target);
+}
+
+static void stretchOrShrinkStroke(bGPDstroke *gps, float length)
+{
+  if (length > 0) {
+    BKE_gpencil_stretch_stroke(gps, length);
+  }
+  else {
+    BKE_gpencil_shrink_stroke(gps, -length);
+  }
+}
+
+static void applyLength(bGPDstroke *gps, float length, float percentage)
+{
+
+  stretchOrShrinkStroke(gps, length);
+
+  float len = BKE_gpencil_stroke_length(gps, 1);
+  if (len < FLT_EPSILON) {
+    return;
+  }
+  float length2 = len * percentage;
+
+  stretchOrShrinkStroke(gps, length2);
+}
+
+static void bakeModifier(Main *UNUSED(bmain),
+                         Depsgraph *depsgraph,
+                         GpencilModifierData *md,
+                         Object *ob)
+{
+
+  bGPdata *gpd = ob->data;
+
+  for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+    for (bGPDframe *gpf = gpl->frames.first; gpf; gpf = gpf->next) {
+      LengthGpencilModifierData *lmd = (LengthGpencilModifierData *)md;
+      bGPDstroke *gps;
+      for (gps = gpf->strokes.first; gps; gps = gps->next) {
+        applyLength(gps, lmd->length, lmd->percentage);
+      }
+      return;
+    }
+  }
+}
+
+/* -------------------------------- */
+
+/* Generic "generateStrokes" callback */
+static void deformStroke(GpencilModifierData *md,
+                         Depsgraph *depsgraph,
+                         Object *ob,
+                         bGPDlayer *gpl,
+                         bGPDframe *UNUSED(gpf),
+                         bGPDstroke *gps)
+{
+  LengthGpencilModifierData *lmd = (LengthGpencilModifierData *)md;
+  applyLength(gps, lmd->length, lmd->percentage);
+}
+
+GpencilModifierTypeInfo modifierType_Gpencil_Length = {
+    /* name */ "Length",
+    /* structName */ "LengthGpencilModifierData",
+    /* structSize */ sizeof(LengthGpencilModifierData),
+    /* type */ eGpencilModifierTypeType_Gpencil,
+    /* flags */ eGpencilModifierTypeFlag_SupportsEditmode,
+
+    /* copyData */ copyData,
+
+    /* deformStroke */ deformStroke,
+    /* generateStrokes */ NULL,
+    /* bakeModifier */ bakeModifier,
+    /* remapTime */ NULL,
+
+    /* initData */ NULL,
+    /* freeData */ NULL,
+    /* isDisabled */ NULL,
+    /* updateDepsgraph */ NULL,
+    /* dependsOnTime */ NULL,
+    /* foreachObjectLink */ NULL,
+    /* foreachIDLink */ NULL,
+    /* foreachTexLink */ NULL,
+    /* getDuplicationFactor */ NULL,
+};
diff --git a/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
new file mode 100644
index 00000000000..941d454272c
--- /dev/null
+++ b/source/blender/gpencil_modifiers/intern/MOD_gpencilmultiply.c
@@ -0,0 +1,322 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * 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.
+ *

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list