Commit: 217c58917c82e2fb26269b5ba831efe148eb7a72
Author: Joshua Leung
Date:   Tue Oct 31 15:42:35 2017 +1300
Branches: greasepencil-object
https://developer.blender.org/rB217c58917c82e2fb26269b5ba831efe148eb7a72

Cleanup - Move helper functions for GP modifiers into the modifiers module

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

M       source/blender/blenkernel/BKE_gpencil.h
M       source/blender/blenkernel/intern/gpencil_modifier.c
M       source/blender/modifiers/CMakeLists.txt
A       source/blender/modifiers/intern/MOD_gpencil_util.c
A       source/blender/modifiers/intern/MOD_gpencil_util.h
M       source/blender/modifiers/intern/MOD_gpencilarray.c
M       source/blender/modifiers/intern/MOD_gpencildupli.c

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

diff --git a/source/blender/blenkernel/BKE_gpencil.h 
b/source/blender/blenkernel/BKE_gpencil.h
index 5bdeb7598d6..955782d9a62 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -198,7 +198,7 @@ void BKE_gpencil_reset_modifiers(struct Object *ob);
 bool BKE_gpencil_has_geometry_modifiers(struct Object *ob);
 void BKE_gpencil_stroke_modifiers(struct Object *ob, struct bGPDlayer *gpl, 
struct bGPDframe *gpf, struct bGPDstroke *gps);
 void BKE_gpencil_geometry_modifiers(struct Object *ob, struct bGPDlayer *gpl, 
struct bGPDframe *gpf);
-void BKE_gpencil_fill_random_array(float *ar, int count);
+
 void BKE_gpencil_stroke_normal(const struct bGPDstroke *gps, float 
r_normal[3]);
 void BKE_gpencil_noise_modifier(int id, struct GpencilNoiseModifierData *mmd, 
struct Object *ob, struct bGPDlayer *gpl, struct bGPDstroke *gps);
 void BKE_gpencil_subdiv_modifier(int id, struct GpencilSubdivModifierData 
*mmd, struct Object *ob, struct bGPDlayer *gpl, struct bGPDstroke *gps);
diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c 
b/source/blender/blenkernel/intern/gpencil_modifier.c
index c978350e007..9b7042b32e9 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -49,6 +49,9 @@
 #include "BKE_gpencil.h"
 #include "BKE_modifier.h"
 #include "BKE_colortools.h"
+ 
+// XXX: temp transitional code
+#include "../../modifiers/intern/MOD_gpencil_util.h"
 
 #define GPENCIL_ANY_EDIT_MODE(gpd) \
        ((gpd) && ((gpd)->flag & (GP_DATA_STROKE_EDITMODE | 
GP_DATA_STROKE_SCULPTMODE | GP_DATA_STROKE_WEIGHTMODE)))
@@ -64,78 +67,6 @@ typedef struct tbGPDspoint {
        float p2d[2];
 } tbGPDspoint;
 
-/* fill an array with random numbers */
-void BKE_gpencil_fill_random_array(float *ar, int count)
-{
-       for (int i = 0; i < count; i++) {
-               ar[i] = BLI_frand();
-       }
-}
-
-/* verify if valid layer and pass index */
-static bool is_stroke_affected_by_modifier(
-        char *mlayername, int mpassindex, int minpoints,
-        bGPDlayer *gpl, bGPDstroke *gps, bool inv1, bool inv2)
-{
-       /* omit if filter by layer */
-       if (mlayername[0] != '\0') {
-               if (inv1 == false) {
-                       if (!STREQ(mlayername, gpl->info)) {
-                               return false;
-                       }
-               }
-               else {
-                       if (STREQ(mlayername, gpl->info)) {
-                               return false;
-                       }
-               }
-       }
-       /* verify pass */
-       if (mpassindex > 0) {
-               if (inv2 == false) {
-                       if (gps->palcolor->index != mpassindex) {
-                               return false;
-                       }
-               }
-               else {
-                       if (gps->palcolor->index == mpassindex) {
-                               return false;
-                       }
-               }
-       }
-       /* need to have a minimum number of points */
-       if ((minpoints > 0) && (gps->totpoints < minpoints)) {
-               return false;
-       }
-
-       return true;
-}
-
-/* verify if valid vertex group *and return weight */
-static float is_point_affected_by_modifier(bGPDspoint *pt, int inverse, int 
vindex)
-{
-       float weight = 1.0f;
-
-       if (vindex >= 0) {
-               weight = BKE_gpencil_vgroup_use_index(pt, vindex);
-               if ((weight >= 0.0f) && (inverse == 1)) {
-                       return -1.0f;
-               }
-
-               if ((weight < 0.0f) && (inverse == 0)) {
-                       return -1.0f;
-               }
-
-               /* if inverse, weight is always 1 */
-               if ((weight < 0.0f) && (inverse == 1)) {
-                       return 1.0f;
-               }
-
-       }
-
-       return weight;
-}
-
 /* get the vertex group index or -1 if empty */
 static int get_vertex_group_index(Object *ob, char *vgname)
 {
diff --git a/source/blender/modifiers/CMakeLists.txt 
b/source/blender/modifiers/CMakeLists.txt
index c59901a8b55..6d9a45dbc15 100644
--- a/source/blender/modifiers/CMakeLists.txt
+++ b/source/blender/modifiers/CMakeLists.txt
@@ -109,10 +109,12 @@ set(SRC
        MOD_modifiertypes.h
        intern/MOD_boolean_util.h
        intern/MOD_fluidsim_util.h
+       intern/MOD_gpencil_util.h
        intern/MOD_meshcache_util.h
        intern/MOD_util.h
        intern/MOD_weightvg_util.h
 
+       intern/MOD_gpencil_util.c
        intern/MOD_gpencilnoise.c
        intern/MOD_gpencilsubdiv.c
        intern/MOD_gpencilsimplify.c
diff --git a/source/blender/modifiers/intern/MOD_gpencil_util.c 
b/source/blender/modifiers/intern/MOD_gpencil_util.c
new file mode 100644
index 00000000000..5dcc5ae2914
--- /dev/null
+++ b/source/blender/modifiers/intern/MOD_gpencil_util.c
@@ -0,0 +1,125 @@
+/*
+ * ***** 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
+ *
+ * Contributor(s): Antonio Vazquez
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/modifiers/intern/MOD_gpencil_util.c
+ *  \ingroup bke
+ */
+
+ 
+#include <stdio.h>
+
+#include "MEM_guardedalloc.h"
+
+#include "BLI_blenlib.h"
+#include "BLI_utildefines.h"
+#include "BLI_math_vector.h"
+#include "BLI_math_color.h"
+#include "BLI_rand.h"
+
+#include "DNA_scene_types.h"
+#include "DNA_object_types.h"
+#include "DNA_gpencil_types.h"
+#include "DNA_modifier_types.h"
+
+#include "BKE_global.h"
+#include "BKE_object.h"
+#include "BKE_lattice.h"
+#include "BKE_gpencil.h"
+#include "BKE_modifier.h"
+#include "BKE_colortools.h"
+
+
+/* fill an array with random numbers */
+void gp_mod_fill_random_array(float *ar, int count)
+{
+       for (int i = 0; i < count; i++) {
+               ar[i] = BLI_frand();
+       }
+} 
+
+/* verify if valid layer and pass index */
+bool is_stroke_affected_by_modifier(
+        char *mlayername, int mpassindex, int minpoints,
+        bGPDlayer *gpl, bGPDstroke *gps, bool inv1, bool inv2)
+{
+       /* omit if filter by layer */
+       if (mlayername[0] != '\0') {
+               if (inv1 == false) {
+                       if (!STREQ(mlayername, gpl->info)) {
+                               return false;
+                       }
+               }
+               else {
+                       if (STREQ(mlayername, gpl->info)) {
+                               return false;
+                       }
+               }
+       }
+       /* verify pass */
+       if (mpassindex > 0) {
+               if (inv2 == false) {
+                       if (gps->palcolor->index != mpassindex) {
+                               return false;
+                       }
+               }
+               else {
+                       if (gps->palcolor->index == mpassindex) {
+                               return false;
+                       }
+               }
+       }
+       /* need to have a minimum number of points */
+       if ((minpoints > 0) && (gps->totpoints < minpoints)) {
+               return false;
+       }
+
+       return true;
+}
+
+/* verify if valid vertex group *and return weight */
+float is_point_affected_by_modifier(bGPDspoint *pt, int inverse, int vindex)
+{
+       float weight = 1.0f;
+
+       if (vindex >= 0) {
+               weight = BKE_gpencil_vgroup_use_index(pt, vindex);
+               if ((weight >= 0.0f) && (inverse == 1)) {
+                       return -1.0f;
+               }
+
+               if ((weight < 0.0f) && (inverse == 0)) {
+                       return -1.0f;
+               }
+
+               /* if inverse, weight is always 1 */
+               if ((weight < 0.0f) && (inverse == 1)) {
+                       return 1.0f;
+               }
+
+       }
+
+       return weight;
+}
+
diff --git a/source/blender/modifiers/intern/MOD_gpencil_util.h 
b/source/blender/modifiers/intern/MOD_gpencil_util.h
new file mode 100644
index 00000000000..c63b349434e
--- /dev/null
+++ b/source/blender/modifiers/intern/MOD_gpencil_util.h
@@ -0,0 +1,44 @@
+/*
+ * ***** 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) Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/modifiers/intern/MOD_gpencil_util.h
+ *  \ingroup modifiers
+ */
+
+
+#ifndef __MOD_GPENCIL_UTIL_H__
+#define __MOD_GPENCIL_UTIL_H__
+
+bool is_stroke_affected_by_modifier(
+        char *mlayername, int mpassindex, int minpoints,
+        bGPDlayer *gpl, bGPDstroke *gps, bool inv1, bool inv2);
+
+float is_point_affected_by_modifier(bGPDspoint *pt, int inverse, int vindex);
+
+void gp_mod_fill_random_array(float *ar, int count);
+
+#endif  /* __MOD_GPENCIL_UTIL_H__ */
diff --git a/source/blender/modifiers/intern/MOD_gpencilarray.c 
b/source/blender/modifiers/intern/MOD_gpencilarray.c
index a8f38795fcd..9aa01a0ca15 100644
--- a/source/blender/modifiers/intern/MOD_gpencilarray.c
+++ b/source/blender/modifiers/intern/MOD_gpencilarray.c
@@ -49,6 +49,7 @@
 #include "DEG_depsgraph_build.h"
 
 #include "MOD_modifiertypes.h"
+#include "MOD_gpencil_util.h"
 
 static void initData(ModifierData *md)
 {
@@ -68,8 +69,9 @@ static void initData(ModifierData *md)
        gpmd->rnd_rot = 0.5f;
        gpmd->rnd_size = 0.5f;
        gpmd->lock_axis |= GP_LOCKAXIS_X;
+       
        /* fill random values */
-       BKE_gpencil_fill_random_array(gpmd->rnd, 20);
+       gp_mod_fill_random_array(gpmd->rnd, 20);
        gpmd->rnd[0] = 1;
 }
 
diff --git a/source/blender/modifiers/intern/MOD_gpencildupli.c 
b/source/blender/modifiers/intern/MOD_gpencildupli.c
index 38371134f33..32b289def6e 100644
--- a/source/blender/modifiers/intern/MOD_gpencildupli.c
+++ b/source/blender/modifiers/intern/MOD_gpencildupli.c
@@ -41,6 +41,7 @@
 #include "DEG_depsgraph.h"
 
 #include "MOD_modifiertypes.h"
+#include "MOD_gpencil_util.h"
 
 static void initData(ModifierData *md)
 {
@@ -54,8 +55,9 @@ static void initData(ModifierData *md)
        gpmd->scale[2] = 1.0f;
        gpmd->rnd_rot = 0.5f;
        gpmd->rnd_size = 0

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to