[Bf-blender-cvs] [4735ea927bf] greasepencil-object: Add Depsgraph parameter to calculate evaluate object matrix

Antonio Vazquez noreply at git.blender.org
Sun May 13 17:22:20 CEST 2018


Commit: 4735ea927bfd821a134a4bca947b11ae0dcd829f
Author: Antonio Vazquez
Date:   Sun May 13 17:21:53 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rB4735ea927bfd821a134a4bca947b11ae0dcd829f

Add Depsgraph parameter to calculate evaluate object matrix

The matrix for object and parent object need to be evaluated using depsgraph to get the right value.

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

M	source/blender/draw/engines/gpencil/gpencil_draw_utils.c
M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/editors/gpencil/gpencil_brush.c
M	source/blender/editors/gpencil/gpencil_convert.c
M	source/blender/editors/gpencil/gpencil_data.c
M	source/blender/editors/gpencil/gpencil_edit.c
M	source/blender/editors/gpencil/gpencil_fill.c
M	source/blender/editors/gpencil/gpencil_intern.h
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/gpencil/gpencil_primitive.c
M	source/blender/editors/gpencil/gpencil_utils.c
M	source/blender/editors/include/ED_gpencil.h
M	source/blender/editors/object/object_transform.c
M	source/blender/editors/transform/transform_conversions.c
M	source/blender/editors/transform/transform_manipulator_3d.c

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

diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
index 1b9be888355..14ee9e0af92 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_utils.c
@@ -631,10 +631,13 @@ static void gpencil_draw_onion_strokes(GpencilBatchCache *cache, GPENCIL_e_data
 {
 	GPENCIL_PassList *psl = ((GPENCIL_Data *)vedata)->psl;
 	GPENCIL_StorageList *stl = ((GPENCIL_Data *)vedata)->stl;
+	const DRWContextState *draw_ctx = DRW_context_state_get();
+	Depsgraph *depsgraph = draw_ctx->depsgraph;
+
 	float viewmatrix[4][4];
 
 	/* get parent matrix and save as static data */
-	ED_gpencil_parent_location(ob, gpd, gpl, viewmatrix);
+	ED_gpencil_parent_location(depsgraph, ob, gpd, gpl, viewmatrix);
 	copy_m4_m4(gpf->runtime.viewmatrix, viewmatrix);
 
 	for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
@@ -693,7 +696,7 @@ static void gpencil_draw_strokes(GpencilBatchCache *cache, GPENCIL_e_data *e_dat
 	Depsgraph *depsgraph = draw_ctx->depsgraph;
 
 	/* get parent matrix and save as static data */
-	ED_gpencil_parent_location(ob, gpd, gpl, viewmatrix);
+	ED_gpencil_parent_location(depsgraph, ob, gpd, gpl, viewmatrix);
 	copy_m4_m4(derived_gpf->runtime.viewmatrix, viewmatrix);
 
 	/* apply geometry modifiers */
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index bc9ba23ff6b..7037de12cfe 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -1461,6 +1461,8 @@ void ED_gp_draw_interpolation(const bContext *C, tGPDinterpolate *tgpi, const in
 	RegionView3D *rv3d = ar->regiondata;
 	tGPDinterpolate_layer *tgpil;
 	Object *obact = CTX_data_active_object(C);
+	Depsgraph *depsgraph = CTX_data_depsgraph(C);                                      \
+
 	float color[4];
 
 	UI_GetThemeColor3fv(TH_GP_VERTEX_SELECT, color);
@@ -1472,6 +1474,7 @@ void ED_gp_draw_interpolation(const bContext *C, tGPDinterpolate *tgpi, const in
 	}
 
 	tgpw.rv3d = rv3d;	
+	tgpw.depsgraph = depsgraph;
 	tgpw.ob = obact;
 	tgpw.gpd = tgpi->gpd;
 	tgpw.offsx = 0;
@@ -1484,7 +1487,7 @@ void ED_gp_draw_interpolation(const bContext *C, tGPDinterpolate *tgpi, const in
 	glEnable(GL_BLEND);
 	for (tgpil = tgpi->ilayers.first; tgpil; tgpil = tgpil->next) {
 		/* calculate parent position */
-		ED_gpencil_parent_location(obact, tgpi->gpd, tgpil->gpl, tgpw.diff_mat);
+		ED_gpencil_parent_location(depsgraph, obact, tgpi->gpd, tgpil->gpl, tgpw.diff_mat);
 		if (tgpil->interFrame) {
 			tgpw.gpl = tgpil->gpl;
 			tgpw.gpf = tgpil->interFrame;
@@ -1515,6 +1518,8 @@ void ED_gp_draw_primitives(const bContext *C, tGPDprimitive *tgpi, const int typ
 	}
 
 	Object *obact = CTX_data_active_object(C);
+	Depsgraph *depsgraph = CTX_data_depsgraph(C);                                      \
+
 	float color[4];
 	UI_GetThemeColor3fv(TH_GP_VERTEX_SELECT, color);
 	color[3] = 0.6f;
@@ -1525,6 +1530,7 @@ void ED_gp_draw_primitives(const bContext *C, tGPDprimitive *tgpi, const int typ
 	}
 
 	tgpw.rv3d = rv3d;
+	tgpw.depsgraph = depsgraph;
 	tgpw.ob = obact;
 	tgpw.gpd = tgpi->gpd;
 	tgpw.offsx = 0;
@@ -1536,7 +1542,7 @@ void ED_gp_draw_primitives(const bContext *C, tGPDprimitive *tgpi, const int typ
 	/* turn on alpha-blending */
 	glEnable(GL_BLEND);
 	/* calculate parent position */
-	ED_gpencil_parent_location(obact, tgpi->gpd, tgpi->gpl, tgpw.diff_mat);
+	ED_gpencil_parent_location(depsgraph, obact, tgpi->gpd, tgpi->gpl, tgpw.diff_mat);
 	if (tgpi->gpf) {
 		tgpw.gps = tgpi->gpf->strokes.first;
 		if (tgpw.gps->totpoints > 0) {
@@ -1571,6 +1577,7 @@ static void gp_draw_data_layers(RegionView3D *rv3d,
 	tGPDdraw tgpw;
 
 	tgpw.rv3d = rv3d;
+	tgpw.depsgraph = NULL; /* XXX: This is not used here */
 	tgpw.ob = ob;
 	tgpw.gpd = gpd;
 	tgpw.gpl = NULL;
@@ -1584,7 +1591,7 @@ static void gp_draw_data_layers(RegionView3D *rv3d,
 
 	for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
 		/* calculate parent position */
-		ED_gpencil_parent_location(ob, gpd, gpl, diff_mat);
+		ED_gpencil_parent_location(tgpw.depsgraph, ob, gpd, gpl, diff_mat);
 
 		short lthick = brush->size + gpl->thickness;
 
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index bba0d825c13..17b4493591d 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -1566,6 +1566,7 @@ static bool gpsculpt_brush_do_frame(
 static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso)
 {
 	ToolSettings *ts = CTX_data_tool_settings(C);
+	Depsgraph *depsgraph = CTX_data_depsgraph(C);                                      \
 	Object *obact = gso->object;
 	bGPdata *gpd = gso->gpd;
 	bool changed = false;
@@ -1610,7 +1611,7 @@ static bool gpsculpt_brush_apply_standard(bContext *C, tGP_BrushEditData *gso)
 		
 		/* calculate difference matrix */
 		float diff_mat[4][4];
-		ED_gpencil_parent_location(obact, gpd, gpl, diff_mat);
+		ED_gpencil_parent_location(depsgraph, obact, gpd, gpl, diff_mat);
 		
 		/* Active Frame or MultiFrame? */
 		if (gso->is_multiframe) {
diff --git a/source/blender/editors/gpencil/gpencil_convert.c b/source/blender/editors/gpencil/gpencil_convert.c
index 68ec9047ca6..ac0866debda 100644
--- a/source/blender/editors/gpencil/gpencil_convert.c
+++ b/source/blender/editors/gpencil/gpencil_convert.c
@@ -152,6 +152,7 @@ static void gp_strokepoint_convertcoords(
 	Scene *scene = CTX_data_scene(C);
 	View3D *v3d = CTX_wm_view3d(C);
 	ARegion *ar = CTX_wm_region(C);
+	Depsgraph *depsgraph = CTX_data_depsgraph(C);                                      \
 	Object *obact = CTX_data_active_object(C);   
 	bGPDspoint mypt, *pt;
 
@@ -160,7 +161,7 @@ static void gp_strokepoint_convertcoords(
 
 	/* apply parent transform */
 	float fpt[3];
-	ED_gpencil_parent_location(obact, gpd, gpl, diff_mat);
+	ED_gpencil_parent_location(depsgraph, obact, gpd, gpl, diff_mat);
 	mul_v3_m4v3(fpt, diff_mat, &source_pt->x);
 	copy_v3_v3(&pt->x, fpt);
 
diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index 2379015a585..38a6e154e74 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -1908,7 +1908,7 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
 					float inverse_diff_mat[4][4];
 
 					/* recalculate all stroke points */
-					ED_gpencil_parent_location(base->object, gpd_src, gpl_src, diff_mat);
+					ED_gpencil_parent_location(depsgraph, base->object, gpd_src, gpl_src, diff_mat);
 					invert_m4_m4(inverse_diff_mat, diff_mat);
 
 					Material *ma_src = NULL;
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 0715e3a4051..7f081ec6a05 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -105,7 +105,7 @@ static int gpencil_editmode_toggle_poll(bContext *C)
 static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *op)
 {
 	const int back = RNA_boolean_get(op->ptr, "back");
-
+	Depsgraph *depsgraph = CTX_data_depsgraph(C);                                      \
 	bGPdata *gpd = ED_gpencil_data_get_active(C);
 	bool is_object = false;
 	short mode;
@@ -125,7 +125,7 @@ static int gpencil_editmode_toggle_exec(bContext *C, wmOperator *op)
 	gpd->flag ^= GP_DATA_STROKE_EDITMODE;
 	/* recalculate parent matrix */
 	if (gpd->flag & GP_DATA_STROKE_EDITMODE) {
-		ED_gpencil_reset_layers_parent(ob, gpd);
+		ED_gpencil_reset_layers_parent(depsgraph, ob, gpd);
 	}
 	/* set mode */
 	if (gpd->flag & GP_DATA_STROKE_EDITMODE) {
@@ -1919,6 +1919,7 @@ static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op))
 {
 	bGPdata *gpd = ED_gpencil_data_get_active(C);
 	RegionView3D *rv3d = CTX_wm_region_data(C);
+	Depsgraph *depsgraph = CTX_data_depsgraph(C);                                      \
 	Object *obact = CTX_data_active_object(C);
 	const float gridf = rv3d->gridview;
 	
@@ -1929,7 +1930,7 @@ static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op))
 			float diff_mat[4][4];
 			
 			/* calculate difference matrix object */
-			ED_gpencil_parent_location(obact, gpd, gpl, diff_mat);
+			ED_gpencil_parent_location(depsgraph, obact, gpd, gpl, diff_mat);
 			
 			for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
 				bGPDspoint *pt;
@@ -1956,7 +1957,7 @@ static int gp_snap_to_grid(bContext *C, wmOperator *UNUSED(op))
 
 						/* return data */
 						copy_v3_v3(&pt->x, fpt);
-						gp_apply_parent_point(obact, gpd, gpl, pt);
+						gp_apply_parent_point(depsgraph, obact, gpd, gpl, pt);
 					}
 				}
 			}
@@ -1991,6 +1992,7 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op)
 	
 	Scene *scene = CTX_data_scene(C);
 	View3D *v3d = CTX_wm_view3d(C);
+	Depsgraph *depsgraph = CTX_data_depsgraph(C);                                      \
 	Object *obact = CTX_data_active_object(C);                                          \
 
 	const bool use_offset = RNA_boolean_get(op->ptr, "use_offset");
@@ -2003,7 +2005,7 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op)
 			float diff_mat[4][4];
 			
 			/* calculate difference matrix */
-			ED_gpencil_parent_location(obact, gpd, gpl, diff_mat);
+			ED_gpencil_parent_location(depsgraph, obact, gpd, gpl, diff_mat);
 			
 			for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
 				bGPDspoint *pt;
@@ -2036,7 +2038,7 @@ static int gp_snap_to_cursor(bContext *C, wmOperator *op)
 					for (i = 0, pt = gps->points; i < gps->totpoints; i++, pt++) {
 						if (pt->flag & GP_SPOINT_SELECT) {
 							copy_v3_v3(&pt->x, cursor_global);
-							gp_apply_parent_point(obact, gpd, gpl, pt);
+							gp_apply_parent_point(depsgraph, obact, gpd, gpl, pt);
 						}
 					}
 				}
@@ -2077,6 +2079,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
 	
 	Scene *scene = CTX_data_scene(C);
 	View3D *v3d = CTX_wm_view3d(C);
+	Depsgraph *depsgraph = CTX_data_depsgraph(C);                                      \
 	Object *obact = CTX_data_active

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list