[Bf-blender-cvs] [da885b922c1] blender2.8: Merge branch 'master' into blender2.8

Campbell Barton noreply at git.blender.org
Mon Jan 29 07:31:53 CET 2018


Commit: da885b922c1c2aeed8776504bad57e8e3bb2c2e6
Author: Campbell Barton
Date:   Mon Jan 29 17:32:20 2018 +1100
Branches: blender2.8
https://developer.blender.org/rBda885b922c1c2aeed8776504bad57e8e3bb2c2e6

Merge branch 'master' into blender2.8

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



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

diff --cc source/blender/editors/space_view3d/view3d_edit.c
index 1e368e2d171,ebd0bbe0129..2457a890f71
--- a/source/blender/editors/space_view3d/view3d_edit.c
+++ b/source/blender/editors/space_view3d/view3d_edit.c
@@@ -96,28 -131,53 +133,54 @@@ typedef struct ViewOpsData 
  	ARegion *ar;
  	View3D *v3d;
  	RegionView3D *rv3d;
++	Depsgraph *depsgraph;
  
- 	/* needed for continuous zoom */
+ 	/** Needed for continuous zoom. */
  	wmTimer *timer;
- 	double timer_lastdraw;
  
- 	float oldquat[4];
- 	float viewquat[4]; /* working copy of rv3d->viewquat */
- 	float trackvec[3];
- 	float mousevec[3]; /* dolly only */
+ 	/** Viewport state on initialization, don't change afterwards. */
+ 	struct {
+ 		float dist;
+ 		float camzoom;
+ 		float quat[4];
+ 		/** #wmEvent.x, y. */
+ 		int event_xy[2];
+ 		/** Offset to use when #VIEWOPS_FLAG_USE_MOUSE_INIT is not set.
+ 		 * so we can simulate pressing in the middle of the screen. */
+ 		int event_xy_offset[2];
+ 		/** #wmEvent.type that triggered the operator. */
+ 		int event_type;
+ 		float ofs[3];
+ 		/** Initial distance to 'ofs'. */
+ 		float zfac;
+ 
+ 		/** Trackball rotation only. */
+ 		float trackvec[3];
+ 		/** Dolly only. */
+ 		float mousevec[3];
+ 	} init;
+ 
+ 	/** Previous state (previous modal event handled). */
+ 	struct {
+ 		int event_xy[2];
+ 		/** For operators that use time-steps (continuous zoom). */
+ 		double time;
+ 	} prev;
+ 
+ 	/** Current state. */
+ 	struct {
+ 		/** Working copy of #RegionView3D.viewquat, needed for rotation calculation
+ 		 * so we can apply snap to the view-port while keeping the unsnapped rotation
+ 		 * here to use when snap is disabled and for continued calculation. */
+ 		float viewquat[4];
+ 	} curr;
+ 
  	float reverse;
- 	float dist_prev, camzoom_prev;
- 	float grid, far;
  	bool axis_snap;  /* view rotate only */
- 	float zfac;
  
- 	/* use for orbit selection and auto-dist */
- 	float ofs[3], dyn_ofs[3];
+ 	/** Use for orbit selection and auto-dist. */
+ 	float dyn_ofs[3];
  	bool use_dyn_ofs;
- 
- 	int origx, origy, oldx, oldy;
- 	int origkey; /* the key that triggered the operator */
- 
  } ViewOpsData;
  
  #define TRACKBALLSIZE  (1.1f)
@@@ -302,14 -366,15 +370,19 @@@ static void viewops_data_create
  	ViewOpsData *vod = op->customdata;
  	RegionView3D *rv3d = vod->rv3d;
  
+ 	/* Could do this more nicely. */
+ 	if ((viewops_flag & VIEWOPS_FLAG_USE_MOUSE_INIT) == 0) {
+ 		viewops_flag &= ~VIEWOPS_FLAG_DEPTH_NAVIGATE;
+ 	}
+ 
  	/* we need the depth info before changing any viewport options */
- 	if (orbit_mode & VIEWOPS_ORBIT_DEPTH) {
+ 	if (viewops_flag & VIEWOPS_FLAG_DEPTH_NAVIGATE) {
 +		EvaluationContext eval_ctx;
 +		struct Depsgraph *graph = CTX_data_depsgraph(C);
  		float fallback_depth_pt[3];
  
 +		CTX_data_eval_ctx(C, &eval_ctx);
 +
  		view3d_operator_needs_opengl(C); /* needed for zbuf drawing */
  
  		negate_v3_v3(fallback_depth_pt, rv3d->ofs);
@@@ -1700,9 -1785,12 +1796,12 @@@ void viewzoom_modal_keymap(wmKeyConfig 
  	WM_modalkeymap_assign(keymap, "VIEW3D_OT_zoom");
  }
  
- static void view_zoom_mouseloc_camera(
+ /**
+  * \param zoom_xy: Optionally zoom to window location (coords compatible w/ #wmEvent.x, y). Use when not NULL.
+  */
+ static void view_zoom_to_window_xy_camera(
 -        Scene *scene, View3D *v3d,
 +        Scene *scene, const Depsgraph *depsgraph, View3D *v3d,
-         ARegion *ar, float dfac, int mx, int my)
+         ARegion *ar, float dfac, const int zoom_xy[2])
  {
  	RegionView3D *rv3d = ar->regiondata;
  	const float zoomfac = BKE_screen_view3d_zoom_to_fac(rv3d->camzoom);
@@@ -1871,9 -1985,9 +1996,9 @@@ static void viewzoom_apply_camera
  	if (zfac != 1.0f && zfac != 0.0f) {
  		/* calculate inverted, then invert again (needed because of camera zoom scaling) */
  		zfac = 1.0f / zfac;
- 		view_zoom_mouseloc_camera(
+ 		view_zoom_to_window_xy_camera(
 -		        vod->scene, vod->v3d,
 +		        vod->scene, vod->depsgraph, vod->v3d,
- 		        vod->ar, zfac, vod->oldx, vod->oldy);
+ 		        vod->ar, zfac, zoom_to_pos ? vod->prev.event_xy : NULL);
  	}
  
  	ED_region_tag_redraw(vod->ar);
@@@ -2024,7 -2148,7 +2160,7 @@@ static int viewzoom_exec(bContext *C, w
  		const float step = 1.2f;
  		/* this min and max is also in viewmove() */
  		if (use_cam_zoom) {
- 			view_zoom_mouseloc_camera(scene, depsgraph, v3d, ar, step, mx, my);
 -			view_zoom_to_window_xy_camera(scene, v3d, ar, step, zoom_xy);
++			view_zoom_to_window_xy_camera(scene, depsgraph, v3d, ar, step, zoom_xy);
  		}
  		else {
  			if (rv3d->dist < dist_range[1]) {
@@@ -2035,7 -2159,7 +2171,7 @@@
  	else {
  		const float step = 1.0f / 1.2f;
  		if (use_cam_zoom) {
- 			view_zoom_mouseloc_camera(scene, depsgraph, v3d, ar, step, mx, my);
 -			view_zoom_to_window_xy_camera(scene, v3d, ar, step, zoom_xy);
++			view_zoom_to_window_xy_camera(scene, depsgraph, v3d, ar, step, zoom_xy);
  		}
  		else {
  			if (rv3d->dist > dist_range[0]) {
@@@ -3237,8 -3353,9 +3376,8 @@@ static int view3d_zoom_border_exec(bCon
  	float new_ofs[3];
  
  	/* ZBuffer depth vars */
 -	bglMats mats;
  	float depth_close = FLT_MAX;
- 	float p[3];
 -	double cent[2],  p[3];
++	float cent[2],  p[3];
  
  	/* note; otherwise opengl won't work */
  	view3d_operator_needs_opengl(C);
@@@ -3254,8 -3369,9 +3393,8 @@@
  	ED_view3d_dist_range_get(v3d, dist_range);
  
  	/* Get Z Depths, needed for perspective, nice for ortho */
 -	bgl_get_mats(&mats);
 -	ED_view3d_draw_depth(scene, ar, v3d, true);
 +	ED_view3d_draw_depth(&eval_ctx, CTX_data_depsgraph(C), ar, v3d, true);
- 	
+ 
  	{
  		/* avoid allocating the whole depth buffer */
  		ViewDepths depth_temp = {0};
@@@ -3269,11 -3385,11 +3408,11 @@@
  		MEM_SAFE_FREE(depth_temp.depths);
  	}
  
- 	float centx = (((float)rect.xmin) + ((float)rect.xmax)) / 2;
- 	float centy = (((float)rect.ymin) + ((float)rect.ymax)) / 2;
 -	cent[0] = (((double)rect.xmin) + ((double)rect.xmax)) / 2;
 -	cent[1] = (((double)rect.ymin) + ((double)rect.ymax)) / 2;
++	cent[0] = (((float)rect.xmin) + ((float)rect.xmax)) / 2;
++	cent[1] = (((float)rect.ymin) + ((float)rect.ymax)) / 2;
  
  	if (rv3d->is_persp) {
 -		double p_corner[3];
 +		float p_corner[3];
  
  		/* no depths to use, we cant do anything! */
  		if (depth_close == FLT_MAX) {
@@@ -3281,8 -3397,12 +3420,8 @@@
  			return OPERATOR_CANCELLED;
  		}
  		/* convert border to 3d coordinates */
- 		if ((!ED_view3d_unproject(ar, centx, centy, depth_close, p)) ||
 -		if ((!gluUnProject(cent[0], cent[1], depth_close,
 -		                   mats.modelview, mats.projection, (GLint *)mats.viewport,
 -		                   &p[0], &p[1], &p[2])) ||
 -		    (!gluUnProject((double)rect.xmin, (double)rect.ymin, depth_close,
 -		                   mats.modelview, mats.projection, (GLint *)mats.viewport,
 -		                   &p_corner[0], &p_corner[1], &p_corner[2])))
++		if ((!ED_view3d_unproject(ar, cent[0], cent[1], depth_close, p)) ||
 +		    (!ED_view3d_unproject(ar, rect.xmin, rect.ymin, depth_close, p_corner)))
  		{
  			return OPERATOR_CANCELLED;
  		}
@@@ -3303,8 -3428,13 +3442,8 @@@
  		new_dist = rv3d->dist;
  
  		/* convert the drawn rectangle into 3d space */
- 		if (depth_close != FLT_MAX && ED_view3d_unproject(ar, centx, centy, depth_close, p)) {
 -		if (depth_close != FLT_MAX && gluUnProject(cent[0], cent[1], depth_close,
 -		                                           mats.modelview, mats.projection, (GLint *)mats.viewport,
 -		                                           &p[0], &p[1], &p[2]))
 -		{
 -			new_ofs[0] = -p[0];
 -			new_ofs[1] = -p[1];
 -			new_ofs[2] = -p[2];
++		if (depth_close != FLT_MAX && ED_view3d_unproject(ar, cent[0], cent[1], depth_close, p)) {
 +			negate_v3_v3(new_ofs, p);
  		}
  		else {
  			float mval_f[2];
@@@ -3399,8 -3529,8 +3538,8 @@@ static void view3d_set_1_to_1_viewborde
  	RegionView3D *rv3d = ar->regiondata;
  	float size[2];
  	int im_width = (scene->r.size * scene->r.xsch) / 100;
- 	
+ 
 -	ED_view3d_calc_camera_border_size(scene, ar, v3d, rv3d, size);
 +	ED_view3d_calc_camera_border_size(scene, depsgraph, ar, v3d, rv3d, size);
  
  	rv3d->camzoom = BKE_screen_view3d_zoom_from_fac((float)im_width / size[0]);
  	CLAMP(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX);
@@@ -4207,10 -4335,10 +4346,10 @@@ static int background_image_add_exec(bC
  
  static int background_image_add_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
  {
 -	View3D *v3d = CTX_wm_view3d(C);
 +	Camera *cam = CTX_data_pointer_get_type(C, "camera", &RNA_Camera).data;
  	Image *ima;
 -	BGpic *bgpic;
 +	CameraBGImage *bgpic;
- 	
+ 
  	ima = (Image *)WM_operator_drop_load_path(C, op, ID_IM);
  	/* may be NULL, continue anyway */
  
@@@ -4268,10 -4396,9 +4407,9 @@@ static int background_image_remove_exec
  			id_us_min((ID *)bgpic_rem->clip);
  		}
  
 -		ED_view3d_background_image_remove(v3d, bgpic_rem);
 +		BKE_camera_background_image_remove(cam, bgpic_rem);
  
 -		WM_event_add_notifier(C, NC_SPACE | ND_SPACE_VIEW3D, v3d);
 +		WM_event_add_notifier(C, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, cam);
- 
  		return OPERATOR_FINISHED;
  	}
  	else {
@@@ -4415,16 -4546,10 +4551,16 @@@ void ED_view3d_cursor3d_position(bConte
  		ED_view3d_calc_zfac(rv3d, fp, NULL /* &flip */ );
  	}
  
- 	if (U.uiflag & USER_ZBUF_CURSOR) {  /* maybe this should be accessed some other way */
+ 	if (U.uiflag & USER_DEPTH_CURSOR) {  /* maybe this should be accessed some other way */
 +		EvaluationContext eval_ctx;
 +		struct Depsgraph *graph = CTX_data_depsgraph(C);
 +
 +		CTX_data_eval_ctx(C, &eval_ctx);
 +
  		view3d_operator_needs_opengl(C);
 -		if (ED_view3d_autodist(scene, ar, v3d, mval, fp, true, NULL))
 +		if (ED_view3d_autodist(&eval_ctx, graph, ar, v3d, mval, fp, true, NULL)) {
  			depth_used = true;
 +		}
  	}
  
  	if (depth_used == false) {



More information about the Bf-blender-cvs mailing list