Commit: 72b709c4a4c0efc42bca0e26e2878650c2673fdf
Author: Antonio Vazquez
Date:   Sat Aug 5 18:20:14 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB72b709c4a4c0efc42bca0e26e2878650c2673fdf

Cleanup: Reorganize code

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

M       source/blender/blenkernel/intern/gpencil_modifier.c

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

diff --git a/source/blender/blenkernel/intern/gpencil_modifier.c 
b/source/blender/blenkernel/intern/gpencil_modifier.c
index 9b397cdc001..ff98c926f61 100644
--- a/source/blender/blenkernel/intern/gpencil_modifier.c
+++ b/source/blender/blenkernel/intern/gpencil_modifier.c
@@ -697,115 +697,6 @@ void BKE_gpencil_lattice_modifier(int UNUSED(id), 
GpencilLatticeModifierData *mm
        }
 }
 
-/* reset modifiers */
-void BKE_gpencil_reset_modifiers(Object *ob)
-{
-       ModifierData *md;
-       GpencilDupliModifierData *arr;
-
-       for (md = ob->modifiers.first; md; md = md->next) {
-               switch (md->type) {
-               case eModifierType_GpencilDupli:
-                       arr = (GpencilDupliModifierData *) md;
-                       arr->rnd[0] = 1;
-                       break;
-               }
-       }
-}
-
-/* verify if exist geometry modifiers */
-bool BKE_gpencil_has_geometry_modifiers(Object *ob)
-{
-       ModifierData *md;
-       for (md = ob->modifiers.first; md; md = md->next) {
-               if (md->type == eModifierType_GpencilDupli) {
-                       return true;
-               }
-       }
-       return false;
-}
-
-/* apply stroke modifiers */
-void BKE_gpencil_stroke_modifiers(Object *ob, bGPDlayer *gpl, bGPDframe *gpf, 
bGPDstroke *gps)
-{
-       ModifierData *md;
-       bGPdata *gpd = ob->gpd;
-       bool is_edit = (bool)((gpd->flag & (GP_DATA_STROKE_EDITMODE | 
GP_DATA_STROKE_SCULPTMODE | GP_DATA_STROKE_WEIGHTMODE)));
-
-       int id = 0;
-       for (md = ob->modifiers.first; md; md = md->next) {
-               if (((md->mode & eModifierMode_Realtime) && ((G.f & 
G_RENDER_OGL) == 0)) ||
-                       ((md->mode & eModifierMode_Render) && (G.f & 
G_RENDER_OGL))) {
-
-                       if (((md->mode & eModifierMode_Editmode) == 0) && 
(is_edit)) {
-                               continue;
-                       }
-
-                       switch (md->type) {
-                               // Noise Modifier
-                       case eModifierType_GpencilNoise:
-                               BKE_gpencil_noise_modifier(id, 
(GpencilNoiseModifierData *)md, ob, gpl, gps);
-                               break;
-                               // Subdiv Modifier
-                       case eModifierType_GpencilSubdiv:
-                               BKE_gpencil_subdiv_modifier(id, 
(GpencilSubdivModifierData *)md, ob, gpl, gps);
-                               break;
-                               // Simplify Modifier
-                       case eModifierType_GpencilSimplify:
-                               BKE_gpencil_simplify_modifier(id, 
(GpencilSimplifyModifierData *)md, ob, gpl, gps);
-                               break;
-                               // Thickness
-                       case eModifierType_GpencilThick:
-                               BKE_gpencil_thick_modifier(id, 
(GpencilThickModifierData *)md, ob, gpl, gps);
-                               break;
-                               // Tint
-                       case eModifierType_GpencilTint:
-                               BKE_gpencil_tint_modifier(id, 
(GpencilTintModifierData *)md, ob, gpl, gps);
-                               break;
-                               // Opacity
-                       case eModifierType_GpencilOpacity:
-                               BKE_gpencil_opacity_modifier(id, 
(GpencilOpacityModifierData *)md, ob, gpl, gps);
-                               break;
-                               // Color Correction
-                       case eModifierType_GpencilColor:
-                               BKE_gpencil_color_modifier(id, 
(GpencilColorModifierData *)md, ob, gpl, gps);
-                               break;
-                               // Lattice
-                       case eModifierType_GpencilLattice:
-                               BKE_gpencil_lattice_modifier(id, 
(GpencilLatticeModifierData *)md, ob, gpl, gps);
-                               break;
-                       }
-               }
-               ++id;
-       }
-}
-
-/* apply stroke geometry modifiers */
-void BKE_gpencil_geometry_modifiers(Object *ob, bGPDlayer *gpl, bGPDframe *gpf)
-{
-       ModifierData *md;
-       bGPdata *gpd = ob->gpd;
-       bool is_edit = (bool)((gpd->flag & (GP_DATA_STROKE_EDITMODE | 
GP_DATA_STROKE_SCULPTMODE | GP_DATA_STROKE_WEIGHTMODE)));
-
-       int id = 0;
-       for (md = ob->modifiers.first; md; md = md->next) {
-               if (((md->mode & eModifierMode_Realtime) && ((G.f & 
G_RENDER_OGL) == 0)) ||
-                       ((md->mode & eModifierMode_Render) && (G.f & 
G_RENDER_OGL))) {
-
-                       if (((md->mode & eModifierMode_Editmode) == 0) && 
(is_edit)) {
-                               continue;
-                       }
-
-                       switch (md->type) {
-                               // Array
-                       case eModifierType_GpencilDupli:
-                               BKE_gpencil_dupli_modifier(id, 
(GpencilDupliModifierData *)md, ob, gpl, gpf);
-                               break;
-                       }
-               }
-               ++id;
-       }
-}
 
 /* Get points of stroke always flat to view not affected by camera view or 
view position */
 static void gpencil_stroke_project_2d(const bGPDspoint *points, int totpoints, 
tbGPDspoint *points2d)
@@ -842,7 +733,7 @@ static void gpencil_stroke_project_2d(const bGPDspoint 
*points, int totpoints, t
 
                /* Get local space using first point as origin */
                sub_v3_v3v3(loc, &pt->x, &pt0->x);
-               
+
                tbGPDspoint *point = &points2d[i];
                point->p2d[0] = dot_v3v3(loc, locx);
                point->p2d[1] = dot_v3v3(loc, locy);
@@ -851,15 +742,15 @@ static void gpencil_stroke_project_2d(const bGPDspoint 
*points, int totpoints, t
 }
 
 /* --------------------------------------------------------------------------
- * Reduces a series of points to a simplified version, but
- * maintains the general shape of the series
- *
- * Ramer - Douglas - Peucker algorithm
- * by http ://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
- * -------------------------------------------------------------------------- 
*/
+* Reduces a series of points to a simplified version, but
+* maintains the general shape of the series
+*
+* Ramer - Douglas - Peucker algorithm
+* by http ://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm
+* -------------------------------------------------------------------------- */
 void gpencil_rdp_stroke(bGPDstroke *gps, tbGPDspoint *points2d, float epsilon)
 {
-       tbGPDspoint *old_points2d =points2d;
+       tbGPDspoint *old_points2d = points2d;
        int totpoints = gps->totpoints;
        char *marked = NULL;
        char work;
@@ -933,7 +824,7 @@ void gpencil_rdp_stroke(bGPDstroke *gps, tbGPDspoint 
*points2d, float epsilon)
 
        /* adding points marked */
        bGPDspoint *old_points = MEM_dupallocN(gps->points);
-       
+
        /* resize gps */
        gps->flag |= GP_STROKE_RECALC_CACHES;
        gps->tot_triangles = 0;
@@ -957,7 +848,7 @@ void gpencil_rdp_stroke(bGPDstroke *gps, tbGPDspoint 
*points2d, float epsilon)
        MEM_SAFE_FREE(marked);
 }
 
- /* simplify stroke using Ramer-Douglas-Peucker algorithm */
+/* simplify stroke using Ramer-Douglas-Peucker algorithm */
 void BKE_gpencil_simplify_modifier(int UNUSED(id), GpencilSimplifyModifierData 
*mmd, Object *UNUSED(ob), bGPDlayer *gpl, bGPDstroke *gps)
 {
        int direction = 0;
@@ -971,8 +862,118 @@ void BKE_gpencil_simplify_modifier(int UNUSED(id), 
GpencilSimplifyModifierData *
        tbGPDspoint *points2d = MEM_mallocN(sizeof(tbGPDspoint) * 
gps->totpoints, "GP Stroke temp 2d points");
 
        gpencil_stroke_project_2d(gps->points, gps->totpoints, points2d);
-       
+
        gpencil_rdp_stroke(gps, points2d, mmd->factor);
 
        MEM_SAFE_FREE(points2d);
 }
+
+/* reset modifiers */
+void BKE_gpencil_reset_modifiers(Object *ob)
+{
+       ModifierData *md;
+       GpencilDupliModifierData *arr;
+
+       for (md = ob->modifiers.first; md; md = md->next) {
+               switch (md->type) {
+               case eModifierType_GpencilDupli:
+                       arr = (GpencilDupliModifierData *) md;
+                       arr->rnd[0] = 1;
+                       break;
+               }
+       }
+}
+
+/* verify if exist geometry modifiers */
+bool BKE_gpencil_has_geometry_modifiers(Object *ob)
+{
+       ModifierData *md;
+       for (md = ob->modifiers.first; md; md = md->next) {
+               if (md->type == eModifierType_GpencilDupli) {
+                       return true;
+               }
+       }
+       return false;
+}
+
+/* apply stroke modifiers */
+void BKE_gpencil_stroke_modifiers(Object *ob, bGPDlayer *gpl, bGPDframe *gpf, 
bGPDstroke *gps)
+{
+       ModifierData *md;
+       bGPdata *gpd = ob->gpd;
+       bool is_edit = (bool)((gpd->flag & (GP_DATA_STROKE_EDITMODE | 
GP_DATA_STROKE_SCULPTMODE | GP_DATA_STROKE_WEIGHTMODE)));
+
+       int id = 0;
+       for (md = ob->modifiers.first; md; md = md->next) {
+               if (((md->mode & eModifierMode_Realtime) && ((G.f & 
G_RENDER_OGL) == 0)) ||
+                       ((md->mode & eModifierMode_Render) && (G.f & 
G_RENDER_OGL))) {
+
+                       if (((md->mode & eModifierMode_Editmode) == 0) && 
(is_edit)) {
+                               continue;
+                       }
+
+                       switch (md->type) {
+                               // Noise Modifier
+                       case eModifierType_GpencilNoise:
+                               BKE_gpencil_noise_modifier(id, 
(GpencilNoiseModifierData *)md, ob, gpl, gps);
+                               break;
+                               // Subdiv Modifier
+                       case eModifierType_GpencilSubdiv:
+                               BKE_gpencil_subdiv_modifier(id, 
(GpencilSubdivModifierData *)md, ob, gpl, gps);
+                               break;
+                               // Simplify Modifier
+                       case eModifierType_GpencilSimplify:
+                               BKE_gpencil_simplify_modifier(id, 
(GpencilSimplifyModifierData *)md, ob, gpl, gps);
+                               break;
+                               // Thickness
+                       case eModifierType_GpencilThick:
+                               BKE_gpencil_thick_modifier(id, 
(GpencilThickModifierData *)md, ob, gpl, gps);
+                               break;
+                               // Tint
+                       case eModifierType_GpencilTint:
+                               BKE_gpencil_tint_modifier(id, 
(GpencilTintModifierData *)md, ob, gpl, gps);
+                               break;
+                               // Opacity
+                       case eModifierType_GpencilOpacity:
+                               BKE_gpencil_opacity_modifier(id, 
(GpencilOpacityModifierData *)md, ob, gpl, gps);
+                               break;
+                               // Color Correction
+                       case eModifierType_GpencilColor:
+                               BKE_gpencil_color_modifier(id, 
(GpencilColorModifierData *)md, ob, gpl, gps);
+                               break;
+                               // Lattice
+                       case eModifierType_GpencilLattice:
+                               BKE_gpencil_lattice_modifier(id, 
(GpencilLatticeModifierData *)md, ob, gpl, gps);
+                               break;
+                       }
+               }
+               ++id;
+       }
+}
+
+/* apply stroke geometry modifiers */
+void BKE_gpencil_geometry_modifiers(Object *ob, bGPDlayer *gpl, bGPDframe *gpf)
+{
+       ModifierData *md;
+       bGPdata *gpd = ob->gpd;
+       bool is_edit = (bool)((gpd->flag & (GP_DATA_STROKE_EDITMODE | 
GP_DATA_STROKE_SCULPTMODE | GP_DATA_STROKE_WEIGHTMODE)));
+
+       int id = 0;
+       for (md = ob->modifiers.first; md; md = md->next) {
+               if (((md->mode & eModifierMode_Realtime) && ((G.f & 
G_RENDER_OGL) == 0)) ||
+                       ((md->mode & eModifierMode_Render) && (G.f & 
G_RENDER_OGL))) {
+
+                       if (((md->mode & eModifierMode_Editmode) == 0) && 
(is_edit)) {
+                               continue;
+                       }
+
+                       switch (md->type) {
+                               // Array
+                       case eModifierType_GpencilDupli:
+                               BKE_gpencil_dupli_modifier(id, 
(GpencilDupliModifierData *)md, ob, gpl, gpf);
+                               break;
+                       }
+               }
+               ++id;
+       }
+}

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

Reply via email to