[Bf-blender-cvs] [30beb53b783] experimental_gp_weight: WIP: Initial change of weight struct

Antonio Vazquez noreply at git.blender.org
Tue May 15 18:33:23 CEST 2018


Commit: 30beb53b78348404286a57c01a3a87095502ec87
Author: Antonio Vazquez
Date:   Tue May 15 14:04:15 2018 +0200
Branches: experimental_gp_weight
https://developer.blender.org/rB30beb53b78348404286a57c01a3a87095502ec87

WIP: Initial change of weight struct

This commit is not completed. Saved to get a backup point.

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

M	source/blender/blenkernel/BKE_gpencil.h
M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/blenloader/intern/versioning_280.c
M	source/blender/blenloader/intern/writefile.c
M	source/blender/editors/gpencil/gpencil_brush.c
M	source/blender/editors/gpencil/gpencil_data.c
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesrna/intern/rna_gpencil.c

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

diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index 77f8a3a1702..622ef89e681 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -52,6 +52,8 @@ struct SimplifyGpencilModifierData;
 struct InstanceGpencilModifierData;
 struct LatticeGpencilModifierData;
 
+struct MDeformWeight;
+
 /* ------------ Grease-Pencil API ------------------ */
 
 void BKE_gpencil_free_point_weights(struct bGPDspoint *pt);
@@ -151,7 +153,7 @@ void BKE_gpencil_centroid_3D(struct bGPdata *gpd, float r_centroid[3]);
 /* vertex groups */
 float BKE_gpencil_vgroup_use_index(struct bGPDspoint *pt, int index);
 void BKE_gpencil_vgroup_remove(struct Object *ob, struct bDeformGroup *defgroup);
-struct bGPDweight *BKE_gpencil_vgroup_add_point_weight(struct bGPDspoint *pt, int index, float weight);
+struct MDeformWeight *BKE_gpencil_vgroup_add_point_weight(struct bGPDspoint *pt, int index, float weight);
 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);
 
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 9ea235429bf..c75ecd45c33 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -47,6 +47,7 @@
 #include "BLT_translation.h"
 
 #include "DNA_anim_types.h"
+#include "DNA_meshdata_types.h"
 #include "DNA_material_types.h"
 #include "DNA_gpencil_types.h"
 #include "DNA_userdef_types.h"
@@ -1283,7 +1284,7 @@ void BKE_gpencil_vgroup_remove(Object *ob, bDeformGroup *defgroup)
 {
 	bGPdata *gpd = ob->data;
 	bGPDspoint *pt = NULL;
-	bGPDweight *gpw = NULL;
+	MDeformWeight *gpw = NULL;
 	const int def_nr = BLI_findindex(&ob->defbase, defgroup);
 
 	/* Remove points data */
@@ -1314,10 +1315,10 @@ void BKE_gpencil_vgroup_remove(Object *ob, bDeformGroup *defgroup)
 }
 
 /* add a new weight */
-bGPDweight *BKE_gpencil_vgroup_add_point_weight(bGPDspoint *pt, int index, float weight)
+MDeformWeight *BKE_gpencil_vgroup_add_point_weight(bGPDspoint *pt, int index, float weight)
 {
-	bGPDweight *new_gpw = NULL;
-	bGPDweight *tmp_gpw;
+	MDeformWeight *new_gpw = NULL;
+	MDeformWeight *tmp_gpw;
 
 	/* need to verify if was used before to update */
 	for (int i = 0; i < pt->totweight; i++) {
@@ -1330,10 +1331,10 @@ bGPDweight *BKE_gpencil_vgroup_add_point_weight(bGPDspoint *pt, int index, float
 
 	pt->totweight++;
 	if (pt->totweight == 1) {
-		pt->weights = MEM_callocN(sizeof(bGPDweight), "gp_weight");
+		pt->weights = MEM_callocN(sizeof(MDeformWeight), "gp_weight");
 	}
 	else {
-		pt->weights = MEM_reallocN(pt->weights, sizeof(bGPDweight) * pt->totweight);
+		pt->weights = MEM_reallocN(pt->weights, sizeof(MDeformWeight) * pt->totweight);
 	}
 	new_gpw = &pt->weights[pt->totweight - 1];
 	new_gpw->def_nr = index;
@@ -1345,7 +1346,7 @@ bGPDweight *BKE_gpencil_vgroup_add_point_weight(bGPDspoint *pt, int index, float
 /* return the weight if use index  or -1*/
 float BKE_gpencil_vgroup_use_index(bGPDspoint *pt, int index)
 {
-	bGPDweight *gpw;
+	MDeformWeight *gpw;
 	for (int i = 0; i < pt->totweight; i++) {
 		gpw = &pt->weights[i];
 		if (gpw->def_nr == index) {
@@ -1372,13 +1373,13 @@ bool BKE_gpencil_vgroup_remove_point_weight(bGPDspoint *pt, int index)
 	}
 
 	/* realloc weights */
-	bGPDweight *tmp = MEM_dupallocN(pt->weights);
+	MDeformWeight *tmp = MEM_dupallocN(pt->weights);
 	MEM_SAFE_FREE(pt->weights);
-	pt->weights = MEM_callocN(sizeof(bGPDweight) * pt->totweight - 1, "gp_weights");
+	pt->weights = MEM_callocN(sizeof(MDeformWeight) * pt->totweight - 1, "gp_weights");
 
 	for (int x = 0; x < pt->totweight; x++) {
-		bGPDweight *gpw = &tmp[e];
-		bGPDweight *final_gpw = &pt->weights[e];
+		MDeformWeight *gpw = &tmp[e];
+		MDeformWeight *final_gpw = &pt->weights[e];
 		if (gpw->def_nr != index) {
 			final_gpw->def_nr = gpw->def_nr;
 			final_gpw->weight = gpw->weight;
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index da0e7becb07..66a0b288b41 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -6311,7 +6311,6 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd)
 	bGPDlayer *gpl;
 	bGPDframe *gpf;
 	bGPDstroke *gps;
-	bGPDspoint *pt;
 	bGPDpalette *palette;
 
 	/* we must firstly have some grease-pencil data to link! */
@@ -6354,15 +6353,9 @@ static void direct_link_gpencil(FileData *fd, bGPdata *gpd)
 			for (gps = gpf->strokes.first; gps; gps = gps->next) {
 				/* relink stroke points array */
 				gps->points = newdataadr(fd, gps->points);
-				
 				/* relink point weight data */
-				for (int i = 0; i < gps->totpoints; ++i) {
-					pt = &gps->points[i];
-					if (pt->totweight > 0) {
-						pt->weights = newdataadr(fd, pt->weights);
-					}
-				}
-				
+				direct_link_dverts(fd,gps->totpoints, gps->dvert);
+
 				/* the triangulation is not saved, so need to be recalculated */
 				gps->triangles = NULL;
 				gps->tot_triangles = 0;
diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c
index e53c63119b1..117a73beadf 100644
--- a/source/blender/blenloader/intern/versioning_280.c
+++ b/source/blender/blenloader/intern/versioning_280.c
@@ -968,6 +968,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
 				}
 			}
 
+#if 0 /* GPXXX */
 			/* Init grease pencil vertex groups */
 			if (!DNA_struct_elem_find(fd->filesdna, "bGPDweight", "int", "index")) {
 				for (bGPdata *gpd = main->gpencil.first; gpd; gpd = gpd->id.next) {
@@ -984,6 +985,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *main)
 					}
 				}
 			}
+#endif
 
 			/* Init grease pencil edit line color */
 			if (!DNA_struct_elem_find(fd->filesdna, "bGPdata", "float", "line_color[4]")) {
diff --git a/source/blender/blenloader/intern/writefile.c b/source/blender/blenloader/intern/writefile.c
index e4d6d65f50a..3d8ea584248 100644
--- a/source/blender/blenloader/intern/writefile.c
+++ b/source/blender/blenloader/intern/writefile.c
@@ -2675,10 +2675,7 @@ static void write_gpencil(WriteData *wd, bGPdata *gpd)
 				for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
 					gps->colorname[0] = '\0'; /* field deprecated, clear data */
 					writestruct(wd, DATA, bGPDspoint, gps->totpoints, gps->points);
-					for (int i = 0; i < gps->totpoints; ++i) {
-						bGPDspoint *pt = &gps->points[i];
-						writestruct(wd, DATA, bGPDweight, pt->totweight, pt->weights);
-					}
+					write_dverts(wd, gps->totpoints, gps->dvert);
 				}
 			}
 		}
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 925e444e32b..6c972e523c9 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -46,6 +46,7 @@
 
 #include "BLT_translation.h"
 
+#include "DNA_meshdata_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_space_types.h"
@@ -875,7 +876,7 @@ static bool gp_brush_weight_apply(
 	/* get current weight */
 	float curweight = 0.0f;
 	for (int i = 0; i < pt->totweight; ++i) {
-		bGPDweight *gpw = &pt->weights[i];
+		MDeformWeight *gpw = &pt->weights[i];
 		if (gpw->def_nr == gso->vrgroup) {
 			curweight = gpw->weight;
 			break;
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index e7e0d4fe8e0..5c8ea0fcfc4 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -49,6 +49,7 @@
 #include "DNA_anim_types.h"
 #include "DNA_brush_types.h"
 #include "DNA_gpencil_types.h"
+#include "DNA_meshdata_types.h"
 #include "DNA_modifier_types.h"
 #include "DNA_object_types.h"
 #include "DNA_scene_types.h"
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index 973ea569082..524cc27bb9c 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -37,6 +37,7 @@
 struct AnimData;
 struct CurveMapping;
 struct GHash;
+struct MDeformVert;
 
 /* TODO: add size as userprefs parameter */
 #define GP_OBGPENCIL_DEFAULT_SIZE  0.2f 
@@ -44,15 +45,6 @@ struct GHash;
 #define GP_DEFAULT_GRID_SIZE 100 
 #define GP_MAX_INPUT_SAMPLES 10
 
-/* ***************************************** */
-/* GP Point Weights */
-
-/* Vertex weight info for one GP point, in one group */
-typedef struct bGPDweight {
-	int def_nr;            /* vertex group index */
-	float weight;          /* weight factor */
-} bGPDweight;
-
 /* ***************************************** */
 /* GP Stroke Points */
 
@@ -70,9 +62,6 @@ typedef struct bGPDspoint {
 
 	float uv_fac;           /* factor of uv along the stroke */
 	float uv_rot;           /* uv rotation for dot mode */
-
-	int totweight;          /* number of vertexgroups used */
-	bGPDweight *weights;    /* vertex weight data */
 } bGPDspoint;
 
 /* bGPDspoint->flag */
@@ -181,6 +170,8 @@ typedef struct bGPDstroke {
 	int mat_nr;             /* material index */
 	char pad_[4];
 
+	struct MDeformVert *dvert;    /* vertex weight data */
+
 	bGPDstroke_runtime runtime;
 	char pad_1[4];
 } bGPDstroke;
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 0526912b721..adcfce8629c 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -638,6 +638,7 @@ static int rna_GPencil_info_total_points(PointerRNA *ptr)
 
 #else
 
+#if 0 /* GPXXX */
 /* information of vertex groups by point */
 static void rna_def_gpencil_point_weight(BlenderRNA *brna)
 {
@@ -659,6 +660,7 @@ static void rna_def_gpencil_point_weight(BlenderRNA *brna)
 	RNA_def_property_ui_text(prop, "Weight", "Factor of weight for this vertex group");
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 }
+#endif
 
 static void rna_def_gpencil_stroke_point(BlenderRNA *brna)
 {
@@ -705,11 +707,6 @@ static void rna_def_gpencil_strok

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list