[Bf-blender-cvs] [47239b40419] blender2.8: Cleanup: use depsgraph for scene/layer access

Campbell Barton noreply at git.blender.org
Tue May 2 16:09:16 CEST 2017


Commit: 47239b40419750f0ad8284ba1de1012a638660fb
Author: Campbell Barton
Date:   Wed May 3 00:05:57 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB47239b40419750f0ad8284ba1de1012a638660fb

Cleanup: use depsgraph for scene/layer access

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

M	source/blender/draw/DRW_engine.h
M	source/blender/draw/intern/draw_manager.c
M	source/blender/editors/curve/editcurve_paint.c
M	source/blender/editors/gpencil/gpencil_edit.c
M	source/blender/editors/gpencil/gpencil_paint.c
M	source/blender/editors/gpencil/gpencil_utils.c
M	source/blender/editors/include/ED_view3d.h
M	source/blender/editors/interface/interface_eyedropper.c
M	source/blender/editors/sculpt_paint/paint_image_proj.c
M	source/blender/editors/space_view3d/view3d_draw.c
M	source/blender/editors/space_view3d/view3d_edit.c
M	source/blender/editors/space_view3d/view3d_intern.h
M	source/blender/editors/space_view3d/view3d_view.c

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

diff --git a/source/blender/draw/DRW_engine.h b/source/blender/draw/DRW_engine.h
index dbb25796050..62dae9b3e7b 100644
--- a/source/blender/draw/DRW_engine.h
+++ b/source/blender/draw/DRW_engine.h
@@ -64,12 +64,12 @@ void DRW_engine_viewport_data_size_get(
 
 void DRW_draw_view(const struct bContext *C);
 void DRW_draw_select_loop(
-        struct ViewContext *vc, struct Depsgraph *graph,
-        struct Scene *scene, struct SceneLayer *sl, struct View3D *v3d, struct ARegion *ar,
+        struct Depsgraph *graph,
+        struct View3D *v3d, struct ARegion *ar,
         bool use_obedit_skip, bool use_nearest, const struct rcti *rect);
 void DRW_draw_depth_loop(
         struct Depsgraph *graph,
-        struct Scene *scene, struct ARegion *ar, struct View3D *v3d);
+        struct ARegion *ar, struct View3D *v3d);
 
 void DRW_object_engine_data_free(struct Object *ob);
 
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 00937b55f92..d6c86d82291 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -2253,29 +2253,32 @@ void DRW_draw_view(const bContext *C)
  * object mode select-loop, see: ED_view3d_draw_select_loop (legacy drawing).
  */
 void DRW_draw_select_loop(
-        struct ViewContext *vc, Depsgraph *graph,
-        Scene *scene, struct SceneLayer *sl, View3D *v3d, ARegion *ar,
+        struct Depsgraph *graph,
+        View3D *v3d, ARegion *ar,
         bool UNUSED(use_obedit_skip), bool UNUSED(use_nearest), const rcti *rect)
 {
+	Scene *scene = DAG_get_scene(graph);
+	SceneLayer *sl = DAG_get_scene_layer(graph);
 #ifndef USE_GPU_SELECT
 	UNUSED_VARS(vc, scene, sl, v3d, ar, rect);
 #else
-	RegionView3D *rv3d = vc->rv3d;
+	RegionView3D *rv3d = ar->regiondata;
 
 	/* backup (_never_ use rv3d->viewport) */
-	void *backup_viewport = vc->rv3d->viewport;
+	void *backup_viewport = rv3d->viewport;
 	rv3d->viewport = NULL;
 
 	bool use_obedit = false;
 	int obedit_mode = 0;
-	if (vc->obedit && vc->obedit->type == OB_MBALL) {
+	if (scene->obedit && scene->obedit->type == OB_MBALL) {
 		use_obedit = true;
-		DRW_engines_cache_populate(vc->obedit);
+		DRW_engines_cache_populate(scene->obedit);
 		obedit_mode = CTX_MODE_EDIT_METABALL;
 	}
-	else if ((vc->obedit && vc->obedit->type == OB_ARMATURE)) {
+	else if ((scene->obedit && scene->obedit->type == OB_ARMATURE)) {
 		/* if not drawing sketch, draw bones */
-		if (!BDR_drawSketchNames(vc)) {
+		// if (!BDR_drawSketchNames(vc))
+		{
 			use_obedit = true;
 			obedit_mode = CTX_MODE_EDIT_ARMATURE;
 		}
@@ -2323,7 +2326,7 @@ void DRW_draw_select_loop(
 		DRW_engines_cache_init();
 
 		if (use_obedit) {
-			DRW_engines_cache_populate(vc->obedit);
+			DRW_engines_cache_populate(scene->obedit);
 		}
 		else {
 			DEG_OBJECT_ITER(graph, ob)
@@ -2364,8 +2367,10 @@ void DRW_draw_select_loop(
  */
 void DRW_draw_depth_loop(
         Depsgraph *graph,
-        Scene *scene, ARegion *ar, View3D *v3d)
+        ARegion *ar, View3D *v3d)
 {
+	Scene *scene = DAG_get_scene(graph);
+	SceneLayer *sl = DAG_get_scene_layer(graph);
 	RegionView3D *rv3d = ar->regiondata;
 
 	/* backup (_never_ use rv3d->viewport) */
@@ -2392,7 +2397,7 @@ void DRW_draw_depth_loop(
 
 	/* Instead of 'DRW_context_state_init(C, &DST.draw_ctx)', assign from args */
 	DST.draw_ctx = (DRWContextState){
-		ar, rv3d, v3d, scene, BKE_scene_layer_context_active(scene), (bContext *)NULL,
+		ar, rv3d, v3d, scene, sl, (bContext *)NULL,
 	};
 
 	DRW_viewport_var_init();
diff --git a/source/blender/editors/curve/editcurve_paint.c b/source/blender/editors/curve/editcurve_paint.c
index aee479da173..867aec61922 100644
--- a/source/blender/editors/curve/editcurve_paint.c
+++ b/source/blender/editors/curve/editcurve_paint.c
@@ -1181,7 +1181,7 @@ static int curve_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
 				/* needed or else the draw matrix can be incorrect */
 				view3d_operator_needs_opengl(C);
 
-				ED_view3d_autodist_init(cdd->vc.depsgraph, cdd->vc.scene, cdd->vc.ar, cdd->vc.v3d, 0);
+				ED_view3d_autodist_init(cdd->vc.depsgraph, cdd->vc.ar, cdd->vc.v3d, 0);
 
 				if (cdd->vc.rv3d->depths) {
 					cdd->vc.rv3d->depths->damaged = true;
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 5286302ddad..546f5e4208a 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -2012,7 +2012,7 @@ static int gp_strokes_reproject_exec(bContext *C, wmOperator *op)
 	if (mode == GP_REPROJECT_SURFACE) {
 		struct Depsgraph *graph = CTX_data_depsgraph(C);
 		view3d_region_operator_needs_opengl(CTX_wm_window(C), gsc.ar);
-		ED_view3d_autodist_init(graph, scene, gsc.ar, CTX_wm_view3d(C), 0);
+		ED_view3d_autodist_init(graph, gsc.ar, CTX_wm_view3d(C), 0);
 	}
 	
 	// TODO: For deforming geometry workflow, create new frames?
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 6659510c6cc..d794e6b8760 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -641,7 +641,7 @@ static short gp_stroke_addpoint(tGPsdata *p, const int mval[2], float pressure,
 				
 				view3d_region_operator_needs_opengl(p->win, p->ar);
 				ED_view3d_autodist_init(
-				        p->graph, p->scene, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
+				        p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
 			}
 			
 			/* convert screen-coordinates to appropriate coordinates (and store them) */
@@ -1242,7 +1242,7 @@ static void gp_stroke_doeraser(tGPsdata *p)
 		if (p->flags & GP_PAINTFLAG_V3D_ERASER_DEPTH) {
 			View3D *v3d = p->sa->spacedata.first;
 			view3d_region_operator_needs_opengl(p->win, p->ar);
-			ED_view3d_autodist_init(p->graph, p->scene, p->ar, v3d, 0);
+			ED_view3d_autodist_init(p->graph, p->ar, v3d, 0);
 		}
 	}
 	
@@ -1809,7 +1809,7 @@ static void gp_paint_strokeend(tGPsdata *p)
 		
 		/* need to restore the original projection settings before packing up */
 		view3d_region_operator_needs_opengl(p->win, p->ar);
-		ED_view3d_autodist_init(p->graph, p->scene, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
+		ED_view3d_autodist_init(p->graph, p->ar, v3d, (ts->gpencil_v3d_align & GP_PROJECT_DEPTH_STROKE) ? 1 : 0);
 	}
 	
 	/* check if doing eraser or not */
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c
index 9ed5cf57eec..05b45a2f2eb 100644
--- a/source/blender/editors/gpencil/gpencil_utils.c
+++ b/source/blender/editors/gpencil/gpencil_utils.c
@@ -529,7 +529,7 @@ void gp_point_conversion_init(bContext *C, GP_SpaceConversion *r_gsc)
 		view3d_operator_needs_opengl(C);
 		
 		view3d_region_operator_needs_opengl(win, ar);
-		ED_view3d_autodist_init(graph, scene, ar, v3d, 0);
+		ED_view3d_autodist_init(graph, ar, v3d, 0);
 		
 		/* for camera view set the subrect */
 		if (rv3d->persp == RV3D_CAMOB) {
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 0cb6f054f12..24a1b06d940 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -295,12 +295,12 @@ int          ED_view3d_backbuf_sample_size_clamp(struct ARegion *ar, const float
 unsigned int ED_view3d_backbuf_sample(struct ViewContext *vc, int x, int y);
 
 bool ED_view3d_autodist(
-        struct Depsgraph *graph, struct Scene *scene, struct ARegion *ar, struct View3D *v3d,
+        struct Depsgraph *graph, struct ARegion *ar, struct View3D *v3d,
         const int mval[2], float mouse_worldloc[3],
         const bool alphaoverride, const float fallback_depth_pt[3]);
 
 /* only draw so ED_view3d_autodist_simple can be called many times after */
-void ED_view3d_autodist_init(struct Depsgraph *graph, struct Scene *scene, struct ARegion *ar, struct View3D *v3d, int mode);
+void ED_view3d_autodist_init(struct Depsgraph *graph, struct ARegion *ar, struct View3D *v3d, int mode);
 bool ED_view3d_autodist_simple(struct ARegion *ar, const int mval[2], float mouse_worldloc[3], int margin, float *force_depth);
 bool ED_view3d_autodist_depth(struct ARegion *ar, const int mval[2], int margin, float *depth);
 bool ED_view3d_autodist_depth_seg(struct ARegion *ar, const int mval_sta[2], const int mval_end[2], int margin, float *depth);
diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c
index ea13e67e600..bad47512d12 100644
--- a/source/blender/editors/interface/interface_eyedropper.c
+++ b/source/blender/editors/interface/interface_eyedropper.c
@@ -920,7 +920,7 @@ static void depthdropper_depth_sample_pt(bContext *C, DepthDropper *ddr, int mx,
 
 				view3d_operator_needs_opengl(C);
 
-				if (ED_view3d_autodist(graph, scene, ar, v3d, mval, co, true, NULL)) {
+				if (ED_view3d_autodist(graph, ar, v3d, mval, co, true, NULL)) {
 					const float mval_center_fl[2] = {
 					    (float)ar->winx / 2,
 					    (float)ar->winy / 2};
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index 16d81c6e923..901f24844e4 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -5025,8 +5025,9 @@ void paint_proj_stroke(
 
 		view3d_operator_needs_opengl(C);
 
-		if (!ED_view3d_autodist(graph, scene, ar, v3d, mval_i, cursor, false, NULL))
+		if (!ED_view3d_autodist(graph, ar, v3d, mval_i, cursor, false, NULL)) {
 			return;
+		}
 
 		ED_region_tag_redraw(ar);
 
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 7e2789de33d..1f46a891e76 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -70,6 +70,8 @@
 #include "ED_transform.h"
 #include "ED_gpencil.h"
 
+#include "DEG_depsgraph_query.h"
+
 #include "GPU_matrix.h"
 #include "GPU_immediate.h"
 #include "GPU_immediate_util.h"
@@ -755,8 +757,9 @@

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list