[Bf-blender-cvs] [f94384afc6e] greasepencil-object: Changes after merge and some cleanup

Antonioya noreply at git.blender.org
Sun Aug 26 17:27:33 CEST 2018


Commit: f94384afc6e789797f53c9b0cecc2c6a8c8fa4c7
Author: Antonioya
Date:   Sun Aug 26 17:06:43 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rBf94384afc6e789797f53c9b0cecc2c6a8c8fa4c7

Changes after merge and some cleanup

Added some initialization code and fixed some isues after merge.

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

M	source/blender/editors/gpencil/gpencil_edit.c
M	source/blender/editors/gpencil/gpencil_fill.c
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/gpencil/gpencil_primitive.c

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

diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 88a73fef26e..9f46ec6959f 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -2965,7 +2965,6 @@ static int gp_stroke_subdivide_exec(bContext *C, wmOperator *op)
 				i2 = 0;
 				for (int i = 0; i < oldtotpoints; i++) {
 					bGPDspoint *pt = &temp_points[i];
-					MDeformVert *dvert = &temp_dverts[i];
 					bGPDspoint *pt_final = &gps->points[i2];
 
 					MDeformVert *dvert = NULL;
diff --git a/source/blender/editors/gpencil/gpencil_fill.c b/source/blender/editors/gpencil/gpencil_fill.c
index 6930627c389..cd574cd771c 100644
--- a/source/blender/editors/gpencil/gpencil_fill.c
+++ b/source/blender/editors/gpencil/gpencil_fill.c
@@ -866,7 +866,7 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
 	point2D = (tGPspoint *)tgpf->sbuffer;
 
 	const int def_nr = tgpf->ob->actdef - 1;
-	const bool is_weight = (bool)BLI_findlink(&tgpf->ob->defbase, def_nr);
+	const bool have_weight = (bool)BLI_findlink(&tgpf->ob->defbase, def_nr);
 
 	for (int i = 0; i < tgpf->sbuffer_size && point2D; i++, point2D++, pt++, dvert++) {
 		/* convert screen-coordinates to 3D coordinates */
@@ -880,7 +880,8 @@ static void gpencil_stroke_from_buffer(tGPDfill *tgpf)
 		pt->strength = 1.0f;;
 		pt->time = 0.0f;
 
-		if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (is_weight)) {
+		if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) {
+			BKE_gpencil_dvert_ensure(gps);
 			BKE_gpencil_vgroup_add_point_weight(dvert, def_nr, ts->vgroup_weight);
 		}
 		else {
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 8643fc03786..0fb5a4f2e64 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -555,7 +555,7 @@ static short gp_stroke_addpoint(
 	View3D *v3d = p->sa->spacedata.first;
 	MaterialGPencilStyle *gp_style = p->material->gp_style;
 	const int def_nr = obact->actdef - 1;
-	const bool is_weight = (bool)BLI_findlink(&obact->defbase, def_nr);
+	const bool have_weight = (bool)BLI_findlink(&obact->defbase, def_nr);
 
 	/* check painting mode */
 	if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) {
@@ -794,7 +794,8 @@ static short gp_stroke_addpoint(
 			pts->uv_fac = pt->uv_fac;
 			pts->uv_rot = pt->uv_rot;
 
-			if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (is_weight)) {
+			if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) {
+				BKE_gpencil_dvert_ensure(gps);
 				BKE_gpencil_vgroup_add_point_weight(dvert, def_nr, ts->vgroup_weight);
 			}
 			else {
@@ -913,7 +914,7 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
 	Depsgraph *depsgraph = p->depsgraph;
 	Object *obact = (Object *)p->ownerPtr.data;
 	const int def_nr = obact->actdef - 1;
-	const bool is_weight = (bool)BLI_findlink(&obact->defbase, def_nr);
+	const bool have_weight = (bool)BLI_findlink(&obact->defbase, def_nr);
 
 	int i, totelem;
 	/* since strokes are so fine, when using their depth we need a margin otherwise they might get missed */
@@ -992,7 +993,8 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
 			pt->time = ptc->time;
 			pt++;
 
-			if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (is_weight)) {
+			if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) {
+				BKE_gpencil_dvert_ensure(gps);
 				BKE_gpencil_vgroup_add_point_weight(dvert, def_nr, ts->vgroup_weight);
 				dvert++;
 			}
@@ -1003,8 +1005,6 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
 					dvert++;
 				}
 			}
-
-			}
 		}
 
 		if (totelem == 2) {
@@ -1019,7 +1019,8 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
 			CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
 			pt->time = ptc->time;
 
-			if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (is_weight)) {
+			if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) {
+				BKE_gpencil_dvert_ensure(gps);
 				BKE_gpencil_vgroup_add_point_weight(dvert, def_nr, ts->vgroup_weight);
 			}
 			else {
@@ -1054,7 +1055,8 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
 		CLAMP(pt->strength, GPENCIL_STRENGTH_MIN, 1.0f);
 		pt->time = ptc->time;
 
-		if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (is_weight)) {
+		if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) {
+			BKE_gpencil_dvert_ensure(gps);
 			BKE_gpencil_vgroup_add_point_weight(dvert, def_nr, ts->vgroup_weight);
 		}
 		else {
@@ -1143,8 +1145,10 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
 			pt->uv_fac = ptc->uv_fac;
 			pt->uv_rot = ptc->uv_rot;
 
-			dvert->totweight = 0;
-			dvert->dw = NULL;
+			if (gps->dvert != NULL) {
+				dvert->totweight = 0;
+				dvert->dw = NULL;
+			}
 		}
 
 		/* subdivide and smooth the stroke */
@@ -1211,7 +1215,8 @@ static void gp_stroke_newfrombuffer(tGPsdata *p)
 		BLI_addtail(&p->gpf->strokes, gps);
 	}
 	/* add weights */
-	if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (is_weight)) {
+	if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) {
+		BKE_gpencil_dvert_ensure(gps);
 		for (i = 0; i < gps->totpoints; i++) {
 			MDeformVert *ve = &gps->dvert[i];
 			BKE_gpencil_vgroup_add_point_weight(ve, def_nr, ts->vgroup_weight);
diff --git a/source/blender/editors/gpencil/gpencil_primitive.c b/source/blender/editors/gpencil/gpencil_primitive.c
index 1ea5bcf7bf9..760d74a57a9 100644
--- a/source/blender/editors/gpencil/gpencil_primitive.c
+++ b/source/blender/editors/gpencil/gpencil_primitive.c
@@ -534,7 +534,7 @@ static void gpencil_primitive_done(bContext *C, wmOperator *op, wmWindow *win, t
 	ToolSettings *ts = tgpi->scene->toolsettings;
 
 	const int def_nr = tgpi->ob->actdef - 1;
-	const bool is_weight = (bool)BLI_findlink(&tgpi->ob->defbase, def_nr);
+	const bool have_weight = (bool)BLI_findlink(&tgpi->ob->defbase, def_nr);
 
 	/* return to normal cursor and header status */
 	ED_workspace_status_text(C, NULL);
@@ -555,7 +555,8 @@ static void gpencil_primitive_done(bContext *C, wmOperator *op, wmWindow *win, t
 	BLI_assert(BLI_listbase_is_empty(&tgpi->gpf->strokes));
 
 	/* add weights if required */
-	if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (is_weight)) {
+	if ((ts->gpencil_flags & GP_TOOL_FLAG_CREATE_WEIGHTS) && (have_weight)) {
+		BKE_gpencil_dvert_ensure(gps);
 		for (int i = 0; i < gps->totpoints; i++) {
 			MDeformVert *ve = &gps->dvert[i];
 			BKE_gpencil_vgroup_add_point_weight(ve, def_nr, ts->vgroup_weight);



More information about the Bf-blender-cvs mailing list