Commit: b57d6e920e84e815e8fab854d4219aa8b882be2c
Author: Antonio Vazquez
Date:   Sat Aug 5 17:52:45 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBb57d6e920e84e815e8fab854d4219aa8b882be2c

WIP: Basic structure of VFX Gaussian Blur

This is the first step to implement a system for adding VFX modifiers that are 
applied to viewport and not to strokes

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

M       release/scripts/startup/bl_ui/properties_data_modifier.py
M       source/blender/blenkernel/BKE_gpencil.h
M       source/blender/makesdna/DNA_modifier_types.h
M       source/blender/makesrna/RNA_access.h
M       source/blender/makesrna/intern/rna_modifier.c
M       source/blender/modifiers/CMakeLists.txt
M       source/blender/modifiers/MOD_modifiertypes.h
A       source/blender/modifiers/intern/MOD_gpencilblur.c
M       source/blender/modifiers/intern/MOD_util.c

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

diff --git a/release/scripts/startup/bl_ui/properties_data_modifier.py 
b/release/scripts/startup/bl_ui/properties_data_modifier.py
index 9674221ad6f..11e1f78b1e0 100644
--- a/release/scripts/startup/bl_ui/properties_data_modifier.py
+++ b/release/scripts/startup/bl_ui/properties_data_modifier.py
@@ -1782,6 +1782,13 @@ class DATA_PT_modifiers(ModifierButtonsPanel, Panel):
         layout.separator()
         layout.prop(md, "strength", slider=True)
 
+    def GP_BLUR(self, layout, ob, md):
+        split = layout.split()
+
+        col = split.column()
+        col.label(text="Factor:")
+        col.prop(md, "factor", text="")
+
 classes = (
     DATA_PT_modifiers,
 )
diff --git a/source/blender/blenkernel/BKE_gpencil.h 
b/source/blender/blenkernel/BKE_gpencil.h
index 09e12fde229..570e64ac1af 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -55,6 +55,8 @@ struct GpencilDupliModifierData;
 struct GpencilOpacityModifierData;
 struct GpencilLatticeModifierData;
 
+struct GpencilBlurModifierData;
+
 /* ------------ Grease-Pencil API ------------------ */
 
 void BKE_gpencil_free_point_weights(struct bGPDspoint *pt);
diff --git a/source/blender/makesdna/DNA_modifier_types.h 
b/source/blender/makesdna/DNA_modifier_types.h
index be020da5e22..6b6f2e3e25f 100644
--- a/source/blender/makesdna/DNA_modifier_types.h
+++ b/source/blender/makesdna/DNA_modifier_types.h
@@ -97,6 +97,7 @@ typedef enum ModifierType {
        eModifierType_GpencilColor      = 61,
        eModifierType_GpencilLattice    = 62,
        eModifierType_GpencilSimplify   = 63,
+       eModifierType_GpencilBlur       = 64,
        NUM_MODIFIER_TYPES
 } ModifierType;
 
@@ -1800,6 +1801,14 @@ typedef enum eGpencilSimplify_Flag {
        GP_SIMPLIFY_INVERSE_PASS = (1 << 1),
 } eGpencilSimplify_Flag;
 
+typedef struct GpencilBlurModifierData {
+       ModifierData modifier;
+       float resolution[2];
+       float radius[2];
+       int flag;                    /* flags */
+       char pad[4];
+} GpencilBlurModifierData;
+
 #define MOD_MESHSEQ_READ_ALL \
        (MOD_MESHSEQ_READ_VERT | MOD_MESHSEQ_READ_POLY | MOD_MESHSEQ_READ_UV | 
MOD_MESHSEQ_READ_COLOR)
 
diff --git a/source/blender/makesrna/RNA_access.h 
b/source/blender/makesrna/RNA_access.h
index 13001ae8b0b..f5f40546109 100644
--- a/source/blender/makesrna/RNA_access.h
+++ b/source/blender/makesrna/RNA_access.h
@@ -622,6 +622,7 @@ extern StructRNA RNA_GpencilArrayModifier;
 extern StructRNA RNA_GpencilDupliModifier;
 extern StructRNA RNA_GpencilOpacityModifier;
 extern StructRNA RNA_GpencilLatticeModifier;
+extern StructRNA RNA_GpencilBlurModifier;
 extern StructRNA RNA_TexMapping;
 extern StructRNA RNA_Text;
 extern StructRNA RNA_TextBox;
diff --git a/source/blender/makesrna/intern/rna_modifier.c 
b/source/blender/makesrna/intern/rna_modifier.c
index bc1b21896d5..aa18c5ee050 100644
--- a/source/blender/makesrna/intern/rna_modifier.c
+++ b/source/blender/makesrna/intern/rna_modifier.c
@@ -131,6 +131,8 @@ EnumPropertyItem rna_enum_object_modifier_type_items[] = {
        {eModifierType_GpencilTint, "GP_TINT", ICON_COLOR, "Tint", "Tint 
strokes with new color" },
        {eModifierType_GpencilColor, "GP_COLOR", ICON_GROUP_VCOL, 
"Hue/Saturation", "Apply changes to color" },
        {eModifierType_GpencilOpacity, "GP_OPACITY", ICON_MOD_MASK, "Opacity", 
"Opacity of the strokes" },
+       { 0, "", 0, N_("VFX"), "" },
+       {eModifierType_GpencilBlur, "GP_BLUR", ICON_MOD_ARRAY, "Blur", "Apply 
Gaussian Blur to object" },
        {0, NULL, 0, NULL, NULL}
 };
 
@@ -462,6 +464,8 @@ static StructRNA *rna_Modifier_refine(struct PointerRNA 
*ptr)
                        return &RNA_GpencilOpacityModifier;
                case eModifierType_GpencilLattice:
                        return &RNA_GpencilLatticeModifier;
+               case eModifierType_GpencilBlur:
+                       return &RNA_GpencilBlurModifier;
                        /* Default */
                case eModifierType_None:
                case eModifierType_ShapeKey:
@@ -5392,6 +5396,25 @@ static void rna_def_modifier_gpencillattice(BlenderRNA 
*brna)
        RNA_def_property_update(prop, 0, "rna_Modifier_update");
 }
 
+static void rna_def_modifier_gpencilblur(BlenderRNA *brna)
+{
+       StructRNA *srna;
+       PropertyRNA *prop;
+
+       srna = RNA_def_struct(brna, "GpencilBlurModifier", "Modifier");
+       RNA_def_struct_ui_text(srna, "Blur Modifier", "Gaussian Blur modifier");
+       RNA_def_struct_sdna(srna, "GpencilBlurModifierData");
+       RNA_def_struct_ui_icon(srna, ICON_MAN_ROT);
+
+       //prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_NONE);
+       prop = RNA_def_property(srna, "factor", PROP_FLOAT, PROP_XYZ);
+       RNA_def_property_float_sdna(prop, NULL, "radius");
+       RNA_def_property_range(prop, 0, 100.0);
+       RNA_def_property_ui_range(prop, 0, 100.0, 1.0f, 3);
+       RNA_def_property_ui_text(prop, "Factor", "Factor of Blur");
+       RNA_def_property_update(prop, 0, "rna_Modifier_update");
+}
+
 void RNA_def_modifier(BlenderRNA *brna)
 {
        StructRNA *srna;
@@ -5520,6 +5543,7 @@ void RNA_def_modifier(BlenderRNA *brna)
        rna_def_modifier_gpencildupli(brna);
        rna_def_modifier_gpencilopacity(brna);
        rna_def_modifier_gpencillattice(brna);
+       rna_def_modifier_gpencilblur(brna);
 }
 
 #endif
diff --git a/source/blender/modifiers/CMakeLists.txt 
b/source/blender/modifiers/CMakeLists.txt
index 80548f52397..315c16c84d6 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -123,6 +123,7 @@ set(SRC
        intern/MOD_gpencildupli.c
        intern/MOD_gpencilopacity.c
        intern/MOD_gpencillattice.c
+       intern/MOD_gpencilblur.c
 )
 
 if(WITH_ALEMBIC)
diff --git a/source/blender/modifiers/MOD_modifiertypes.h 
b/source/blender/modifiers/MOD_modifiertypes.h
index 75b639bc541..09610a239aa 100644
--- a/source/blender/modifiers/MOD_modifiertypes.h
+++ b/source/blender/modifiers/MOD_modifiertypes.h
@@ -98,6 +98,8 @@ extern ModifierTypeInfo modifierType_GpencilDupli;
 extern ModifierTypeInfo modifierType_GpencilOpacity;
 extern ModifierTypeInfo modifierType_GpencilLattice;
 
+extern ModifierTypeInfo modifierType_GpencilBlur;
+
 /* MOD_util.c */
 void modifier_type_init(ModifierTypeInfo *types[]);
 
diff --git a/source/blender/modifiers/intern/MOD_gpencilblur.c 
b/source/blender/modifiers/intern/MOD_gpencilblur.c
new file mode 100644
index 00000000000..7c620fd5a66
--- /dev/null
+++ b/source/blender/modifiers/intern/MOD_gpencilblur.c
@@ -0,0 +1,85 @@
+/*
+ * ***** 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) 2005 by the Blender Foundation.
+ * All rights reserved.
+ *
+ * Contributor(s): Antonio Vazquez
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ *
+ */
+
+/** \file blender/modifiers/intern/MOD_gpencilblur.c
+ *  \ingroup modifiers
+ */
+
+#include <stdio.h>
+
+#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
+#include "DNA_gpencil_types.h"
+
+#include "BLI_utildefines.h"
+#include "BKE_DerivedMesh.h"
+#include "BKE_gpencil.h"
+
+#include "MOD_modifiertypes.h"
+
+static void initData(ModifierData *md)
+{
+       GpencilBlurModifierData *gpmd = (GpencilBlurModifierData *)md;
+       ARRAY_SET_ITEMS(gpmd->radius, 1.0f, 1.0f);
+       ARRAY_SET_ITEMS(gpmd->resolution, 1024.0f, 1024.0f);
+
+       BKE_gpencil_batch_cache_alldirty();
+}
+
+static void copyData(ModifierData *md, ModifierData *target)
+{
+       GpencilBlurModifierData *smd = (GpencilBlurModifierData *)md;
+       GpencilBlurModifierData *tsmd = (GpencilBlurModifierData *)target;
+
+       modifier_copyData_generic(md, target);
+}
+
+ModifierTypeInfo modifierType_GpencilBlur = {
+       /* name */              "Gaussian Blur",
+       /* structName */        "GpencilBlurModifierData",
+       /* structSize */        sizeof(GpencilBlurModifierData),
+       /* type */              eModifierTypeType_Gpencil,
+       /* flags */             eModifierTypeFlag_GpencilMod | 
eModifierTypeFlag_SupportsEditmode 
+                                                       | 
eModifierTypeFlag_GpencilVFX | eModifierTypeFlag_Single,
+
+       /* copyData */          copyData,
+       /* deformVerts */       NULL,
+       /* deformMatrices */    NULL,
+       /* deformVertsEM */     NULL,
+       /* deformMatricesEM */  NULL,
+       /* applyModifier */     NULL,
+       /* applyModifierEM */   NULL,
+       /* initData */          initData,
+       /* requiredDataMask */  NULL,
+       /* freeData */          NULL,
+       /* isDisabled */        NULL,
+       /* updateDepsgraph */   NULL,
+       /* dependsOnTime */     NULL,
+       /* dependsOnNormals */  NULL,
+       /* foreachObjectLink */ NULL,
+       /* foreachIDLink */     NULL,
+       /* foreachTexLink */    NULL,
+};
diff --git a/source/blender/modifiers/intern/MOD_util.c 
b/source/blender/modifiers/intern/MOD_util.c
index 3b6e802356f..206cf42422b 100644
--- a/source/blender/modifiers/intern/MOD_util.c
+++ b/source/blender/modifiers/intern/MOD_util.c
@@ -299,5 +299,6 @@ void modifier_type_init(ModifierTypeInfo *types[])
        INIT_TYPE(GpencilDupli);
        INIT_TYPE(GpencilOpacity);
        INIT_TYPE(GpencilLattice);
+       INIT_TYPE(GpencilBlur);
 #undef INIT_TYPE
 }

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to