[Bf-blender-cvs] [c3f0a0477b9] greasepencil-object: Cleanup: Reorganize and rename

Antonio Vazquez noreply at git.blender.org
Mon Jul 31 13:19:36 CEST 2017


Commit: c3f0a0477b9694ba992af4e9270d4b17e4b72aeb
Author: Antonio Vazquez
Date:   Mon Jul 31 10:42:42 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rBc3f0a0477b9694ba992af4e9270d4b17e4b72aeb

Cleanup: Reorganize and rename

New gpencil_modider.c module for modifiers and rename functions to keep naming convention

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

M	source/blender/blenkernel/BKE_gpencil.h
M	source/blender/blenkernel/CMakeLists.txt
M	source/blender/blenkernel/intern/gpencil.c
A	source/blender/blenkernel/intern/gpencil_modifier.c
M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/modifiers/intern/MOD_gpencilarray.c
M	source/blender/modifiers/intern/MOD_gpencilcolor.c
M	source/blender/modifiers/intern/MOD_gpencildupli.c
M	source/blender/modifiers/intern/MOD_gpencillattice.c
M	source/blender/modifiers/intern/MOD_gpencilnoise.c
M	source/blender/modifiers/intern/MOD_gpencilopacity.c
M	source/blender/modifiers/intern/MOD_gpencilsubdiv.c
M	source/blender/modifiers/intern/MOD_gpencilthick.c
M	source/blender/modifiers/intern/MOD_gpenciltint.c

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

diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index a51a8a49b33..b8c920093dc 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -155,23 +155,23 @@ bool BKE_gpencil_vgroup_remove_point_weight(struct bGPDspoint *pt, int index);
 void BKE_gpencil_stroke_weights_duplicate(struct bGPDstroke *gps_src, struct bGPDstroke *gps_dst);
 
 /* modifiers */
-void ED_gpencil_reset_modifiers(struct Object *ob);
-bool ED_gpencil_has_geometry_modifiers(struct Object *ob);
-void ED_gpencil_stroke_modifiers(struct Object *ob, struct bGPDlayer *gpl, struct bGPDframe *gpf, struct bGPDstroke *gps);
-void ED_gpencil_geometry_modifiers(struct Object *ob, struct bGPDlayer *gpl, struct bGPDframe *gpf);
-void ED_gpencil_fill_random_array(float *ar, int count);
-void ED_gpencil_stroke_normal(const struct bGPDstroke *gps, float r_normal[3]);
-void ED_gpencil_noise_modifier(int id, struct GpencilNoiseModifierData *mmd, struct Object *ob, struct bGPDlayer *gpl, struct bGPDstroke *gps);
-void ED_gpencil_subdiv_modifier(int id, struct GpencilSubdivModifierData *mmd, struct Object *ob, struct bGPDlayer *gpl, struct bGPDstroke *gps);
-void ED_gpencil_thick_modifier(int id, struct GpencilThickModifierData *mmd, struct Object *ob, struct bGPDlayer *gpl, struct bGPDstroke *gps);
-void ED_gpencil_tint_modifier(int id, struct GpencilTintModifierData *mmd, struct Object *ob, struct bGPDlayer *gpl, struct bGPDstroke *gps);
-void ED_gpencil_color_modifier(int id, struct GpencilColorModifierData *mmd, struct Object *ob, struct bGPDlayer *gpl, struct bGPDstroke *gps);
-void ED_gpencil_array_modifier(int id, struct GpencilArrayModifierData *mmd, struct Object *ob, int elem_idx[3], float r_mat[4][4]);
-void ED_gpencil_dupli_modifier(int id, struct GpencilDupliModifierData *mmd, struct Object *ob, struct bGPDlayer *gpl, struct bGPDframe *gpf);
-void ED_gpencil_opacity_modifier(int id, struct GpencilOpacityModifierData *mmd, struct Object *ob, struct bGPDlayer *gpl, struct bGPDstroke *gps);
-
-bool ED_gpencil_use_this_lattice(struct Object *ob, struct Object *lattice);
-void ED_gpencil_lattice_init(struct Object *ob);
-void ED_gpencil_lattice_modifier(int id, struct GpencilLatticeModifierData *mmd, struct Object *ob, struct bGPDlayer *gpl, struct bGPDstroke *gps);
+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);
+void BKE_gpencil_thick_modifier(int id, struct GpencilThickModifierData *mmd, struct Object *ob, struct bGPDlayer *gpl, struct bGPDstroke *gps);
+void BKE_gpencil_tint_modifier(int id, struct GpencilTintModifierData *mmd, struct Object *ob, struct bGPDlayer *gpl, struct bGPDstroke *gps);
+void BKE_gpencil_color_modifier(int id, struct GpencilColorModifierData *mmd, struct Object *ob, struct bGPDlayer *gpl, struct bGPDstroke *gps);
+void BKE_gpencil_array_modifier(int id, struct GpencilArrayModifierData *mmd, struct Object *ob, int elem_idx[3], float r_mat[4][4]);
+void BKE_gpencil_dupli_modifier(int id, struct GpencilDupliModifierData *mmd, struct Object *ob, struct bGPDlayer *gpl, struct bGPDframe *gpf);
+void BKE_gpencil_opacity_modifier(int id, struct GpencilOpacityModifierData *mmd, struct Object *ob, struct bGPDlayer *gpl, struct bGPDstroke *gps);
+
+bool BKE_gpencil_use_this_lattice(struct Object *ob, struct Object *lattice);
+void BKE_gpencil_lattice_init(struct Object *ob);
+void BKE_gpencil_lattice_modifier(int id, struct GpencilLatticeModifierData *mmd, struct Object *ob, struct bGPDlayer *gpl, struct bGPDstroke *gps);
 
 #endif /*  __BKE_GPENCIL_H__ */
diff --git a/source/blender/blenkernel/CMakeLists.txt b/source/blender/blenkernel/CMakeLists.txt
index 2a3d4c9fed7..89ca0124352 100644
--- a/source/blender/blenkernel/CMakeLists.txt
+++ b/source/blender/blenkernel/CMakeLists.txt
@@ -110,6 +110,7 @@ set(SRC
 	intern/font.c
 	intern/freestyle.c
 	intern/gpencil.c
+	intern/gpencil_modifier.c
 	intern/group.c
 	intern/icons.c
 	intern/idcode.c
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 6f3dec76203..80e79fe3e80 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -51,7 +51,6 @@
 #include "DNA_userdef_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_object_types.h"
-#include "DNA_modifier_types.h"
 
 #include "BKE_context.h"
 #include "BKE_action.h"
@@ -60,18 +59,10 @@
 #include "BKE_gpencil.h"
 #include "BKE_colortools.h"
 #include "BKE_library.h"
-#include "BKE_lattice.h"
 #include "BKE_main.h"
 #include "BKE_object.h"
-#include "BKE_modifier.h"
 
- /* used to save gpencil objects */
-typedef struct tGPencilStrokeCache {
-	struct bGPDstroke *gps;
-	int idx;
-} tGPencilStrokeCache;
-
- /* Draw Engine */
+/* Draw Engine */
 void(*BKE_gpencil_batch_cache_dirty_cb)(bGPdata *gpd) = NULL;
 void(*BKE_gpencil_batch_cache_free_cb)(bGPdata *gpd) = NULL;
 
@@ -1786,728 +1777,3 @@ bool BKE_gpencil_vgroup_remove_point_weight(bGPDspoint *pt, int index)
 
 	return true;
 }
-
-/********************  Modifiers **********************************/
-void ED_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, int inv1, int inv2)
-{
-	/* omit if filter by layer */
-	if (mlayername[0] != '\0') {
-		if (inv1 == 0) {
-			if (!STREQ(mlayername, gpl->info)) {
-				return false;
-			}
-		}
-		else {
-			if (STREQ(mlayername, gpl->info)) {
-				return false;
-			}
-		}
-	}
-	/* verify pass */
-	if (mpassindex > 0) {
-		if (inv2 == 0) {
-			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)
-{
-	int vindex = -1;
-	/* get vertex group index */
-	if (vgname[0] != '\0') {
-		bDeformGroup *defgrp = BLI_findstring(&ob->defbase, vgname, offsetof(bDeformGroup, name));
-		if (defgrp) {
-			vindex = BLI_findindex(&ob->defbase, defgrp);
-		}
-	}
-	
-	return vindex;
-}
-
-/* calculate stroke normal using some points */
-void ED_gpencil_stroke_normal(const bGPDstroke *gps, float r_normal[3])
-{
-	if (gps->totpoints < 3) {
-		zero_v3(r_normal);
-		return;
-	}
-
-	bGPDspoint *points = gps->points;
-	int totpoints = gps->totpoints;
-
-	const bGPDspoint *pt0 = &points[0];
-	const bGPDspoint *pt1 = &points[1];
-	const bGPDspoint *pt3 = &points[(int)(totpoints * 0.75)];
-
-	float vec1[3];
-	float vec2[3];
-
-	/* initial vector (p0 -> p1) */
-	sub_v3_v3v3(vec1, &pt1->x, &pt0->x);
-
-	/* point vector at 3/4 */
-	sub_v3_v3v3(vec2, &pt3->x, &pt0->x);
-
-	/* vector orthogonal to polygon plane */
-	cross_v3_v3v3(r_normal, vec1, vec2);
-
-	/* Normalize vector */
-	normalize_v3(r_normal);
-}
-
-/* calculate a noise base on stroke direction */
-void ED_gpencil_noise_modifier(int UNUSED(id), GpencilNoiseModifierData *mmd, Object *ob, bGPDlayer *gpl, bGPDstroke *gps)
-{
-	bGPDspoint *pt0, *pt1;
-	float shift, vran, vdir;
-	float normal[3];
-	float vec1[3], vec2[3];
-	Scene *scene = NULL;
-	int sc_frame = 0;
-	int sc_diff = 0;
-	int vindex = get_vertex_group_index(ob, mmd->vgname);
-	float weight = 1.0f;
-
-	if (!is_stroke_affected_by_modifier(mmd->layername, mmd->passindex, 3, gpl, gps, 
-		(int) mmd->flag & GP_NOISE_INVERSE_LAYER, (int)mmd->flag & GP_NOISE_INVERSE_PASS)) {
-		return;
-	}
-
-	scene = mmd->modifier.scene;
-	sc_frame = (scene) ? CFRA : 0;
-
-	zero_v3(vec2);
-
-	/* calculate stroke normal*/
-	ED_gpencil_stroke_normal(gps, normal);
-
-	/* move points */
-	for (int i = 0; i < gps->totpoints; i++) {
-		if (((i == 0) || (i == gps->totpoints - 1)) && ((mmd->flag & GP_NOISE_MOVE_EXTREME) == 0))
-		{
-			continue;
-		}
-
-		/* last point is special */
-		if (i == gps->totpoints) {
-			pt0 = &gps->points[i - 2];
-			pt1 = &gps->points[i - 1];
-		}
-		else {
-			pt0 = &gps->points[i - 1];
-			pt1 = &gps->points[i];
-		}
-		/* verify vertex group */
-		weight = is_point_affected_by_modifier(pt0, (int)(!(mmd->flag & GP_NOISE_INVERSE_VGROUP) == 0), vindex);
-		if (weight < 0) {
-			continue;
-		}
-
-		/* initial vector (p0 -> p1) */
-		sub_v3_v3v3(vec1, &pt1->x, &pt0->x);
-		vran = len_v3(vec1);
-		/* vector orthogonal to normal */
-		cross_v3_v3v3(vec2, vec1, normal);
-		normalize_v3(vec2);
-		/* use random noise */
-		if (mmd->flag & GP_NOISE_USE_RANDOM) {
-			sc_diff = abs(mmd->scene_frame - sc_frame);
-			/* only recalc if the gp frame change or the number of scene frames is bigger than step */
-			if ((!gpl->actframe) || (mmd->gp_frame != gpl->actframe->framenum) || 
-				(sc_diff >= mmd->ste

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list