[Bf-blender-cvs] [f3cf950] epic-navigation: Merge remote-tracking branch 'origin/master' into epic-navigation

Dalai Felinto noreply at git.blender.org
Mon Aug 24 16:34:50 CEST 2015


Commit: f3cf9507398517d31a41364a6c6eaa39aeb23563
Author: Dalai Felinto
Date:   Mon Aug 24 11:32:59 2015 -0300
Branches: epic-navigation
https://developer.blender.org/rBf3cf9507398517d31a41364a6c6eaa39aeb23563

Merge remote-tracking branch 'origin/master' into epic-navigation

Conflicts:
	source/blender/blenlib/BLI_math_vector.h
	source/blender/blenlib/intern/math_vector_inline.c
	source/blender/editors/space_view3d/view3d_walk.c
	source/blender/makesrna/intern/rna_wm.c

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



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

diff --cc source/blender/blenlib/BLI_math_vector.h
index ea24e91,493c285..de508a9
--- a/source/blender/blenlib/BLI_math_vector.h
+++ b/source/blender/blenlib/BLI_math_vector.h
@@@ -146,12 -146,20 +146,22 @@@ MINLINE void negate_v4_v4(float r[4], c
  
  MINLINE void negate_v3_short(short r[3]);
  
 +MINLINE void negate_v2_int(int r[2]);
 +
+ MINLINE void abs_v2(float r[2]);
+ MINLINE void abs_v2_v2(float r[2], const float a[2]);
+ MINLINE void abs_v3(float r[3]);
+ MINLINE void abs_v3_v3(float r[3], const float a[3]);
+ MINLINE void abs_v4(float r[4]);
+ MINLINE void abs_v4_v4(float r[4], const float a[4]);
+ 
  MINLINE float dot_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
  MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
+ MINLINE float dot_v3v3v3(const float p[3], const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
  MINLINE float dot_v4v4(const float a[4], const float b[4]) ATTR_WARN_UNUSED_RESULT;
  
+ MINLINE double dot_v3db_v3fl(const double a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT;
+ 
  MINLINE float cross_v2v2(const float a[2], const float b[2]) ATTR_WARN_UNUSED_RESULT;
  MINLINE void cross_v3_v3v3(float r[3], const float a[3], const float b[3]);
  
diff --cc source/blender/blenlib/intern/math_vector_inline.c
index 1d1d662,c21b097..2dec52a
--- a/source/blender/blenlib/intern/math_vector_inline.c
+++ b/source/blender/blenlib/intern/math_vector_inline.c
@@@ -611,12 -611,48 +611,54 @@@ MINLINE void negate_v3_short(short r[3]
  	r[2] = (short)-r[2];
  }
  
 +MINLINE void negate_v2_int(int r[2])
 +{
 +	r[0] = -r[0];
 +	r[1] = -r[1];
 +}
 +
+ MINLINE void abs_v2(float r[2])
+ {
+ 	r[0] = fabsf(r[0]);
+ 	r[1] = fabsf(r[1]);
+ }
+ 
+ MINLINE void abs_v2_v2(float r[2], const float a[2])
+ {
+ 	r[0] = fabsf(a[0]);
+ 	r[1] = fabsf(a[1]);
+ }
+ 
+ MINLINE void abs_v3(float r[3])
+ {
+ 	r[0] = fabsf(r[0]);
+ 	r[1] = fabsf(r[1]);
+ 	r[2] = fabsf(r[2]);
+ }
+ 
+ MINLINE void abs_v3_v3(float r[3], const float a[3])
+ {
+ 	r[0] = fabsf(a[0]);
+ 	r[1] = fabsf(a[1]);
+ 	r[2] = fabsf(a[2]);
+ }
+ 
+ MINLINE void abs_v4(float r[4])
+ {
+ 	r[0] = fabsf(r[0]);
+ 	r[1] = fabsf(r[1]);
+ 	r[2] = fabsf(r[2]);
+ 	r[3] = fabsf(r[3]);
+ }
+ 
+ MINLINE void abs_v4_v4(float r[4], const float a[4])
+ {
+ 	r[0] = fabsf(a[0]);
+ 	r[1] = fabsf(a[1]);
+ 	r[2] = fabsf(a[2]);
+ 	r[3] = fabsf(a[3]);
+ }
+ 
  MINLINE float dot_v2v2(const float a[2], const float b[2])
  {
  	return a[0] * b[0] + a[1] * b[1];
diff --cc source/blender/editors/space_view3d/view3d_walk.c
index 02f362e,e2bb366..04dbb68
--- a/source/blender/editors/space_view3d/view3d_walk.c
+++ b/source/blender/editors/space_view3d/view3d_walk.c
@@@ -40,12 -38,8 +38,11 @@@
  #include "BKE_context.h"
  #include "BKE_report.h"
  
- #include "BLF_translation.h"
+ #include "BLT_translation.h"
  
 +#include "RNA_access.h"
 +#include "RNA_define.h"
- #include "RNA_enum_types.h"
 +#include "RNA_types.h"
  
  #include "BIF_gl.h"
  
@@@ -382,9 -392,7 +407,9 @@@ static void walk_navigation_mode_set(bC
  		walk->gravity_state = WALK_GRAVITY_STATE_START;
  	}
  
 -	walk_update_header(C, op, walk);
 +	if (walk->use_mouse) {
- 		walk_update_header(C, walk);
++		walk_update_header(C, op, walk);
 +	}
  }
  
  /**
@@@ -613,16 -616,18 +644,20 @@@ static int walkEnd(bContext *C, WalkInf
  	if (walk->ndof)
  		MEM_freeN(walk->ndof);
  
 -	/* restore the cursor */
 -	WM_cursor_modal_restore(win);
 +	WM_event_remove_timer(CTX_wm_manager(C), win, walk->timer);
  
- 	if (walk->use_mouse) {
+ #ifdef USE_TABLET_SUPPORT
 -	if (walk->is_cursor_absolute == false)
++	if ((walk->is_cursor_absolute == false) &&
++	    (walk->use_mouse))
+ #endif
+ 	{
 -		/* center the mouse */
 -		WM_cursor_warp(
 -		        win,
 -		        walk->ar->winrct.xmin + walk->center_mval[0],
 -		        walk->ar->winrct.ymin + walk->center_mval[1]);
 +		ED_region_draw_cb_exit(walk->ar->type, walk->draw_handle_pixel);
 +
 +		/* restore the cursor */
 +		WM_cursor_modal_restore(win);
 +
 +		/* restore the mouse position */
 +		WM_cursor_warp(win, walk->init_mval[0], walk->init_mval[1]);
  	}
  
  	if (walk->state == WALK_CONFIRM) {
@@@ -810,91 -924,6 +845,126 @@@ static void walkEvent(bContext *C, wmOp
  				break;
  		}
  	}
 +	else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE, MOUSEPAN)) {
 +		int xy[2], prevxy[2];
 +
++#ifdef USE_TABLET_SUPPORT
++		if (walk->is_cursor_first) {
++			/* wait until we get the 'warp' event */
++			if ((walk->center_mval[0] == event->mval[0]) &&
++			    (walk->center_mval[1] == event->mval[1]))
++			{
++				walk->is_cursor_first = false;
++			}
++			else {
++				/* note, its possible the system isn't giving us the warp event
++				 * ideally we shouldn't have to worry about this, see: T45361 */
++				wmWindow *win = CTX_wm_window(C);
++				WM_cursor_warp(win,
++				               walk->ar->winrct.xmin + walk->center_mval[0],
++				               walk->ar->winrct.ymin + walk->center_mval[1]);
++			}
++			return;
++		}
++
++		if ((walk->is_cursor_absolute == false) && WM_event_is_absolute(event)) {
++			walk->is_cursor_absolute = true;
++			copy_v2_v2_int(walk->prev_mval, event->mval);
++			copy_v2_v2_int(walk->center_mval, event->mval);
++			/* without this we can't turn 180d */
++			CLAMP_MIN(walk->mouse_speed, 4.0f);
++		}
++#endif  /* USE_TABLET_SUPPORT */
++
 +		xy[0] = event->x;
 +		xy[1] = event->y;
 +		prevxy[0] = event->prevx;
 +		prevxy[1] = event->prevy;
 +
 +		if ((event->type == MOUSEPAN) && U.uiflag2 & USER_TRACKPAD_NATURAL) {
 +			negate_v2_int(xy);
 +			negate_v2_int(prevxy);
 +		}
 +
 +		walk->moffset[0] += xy[0] - prevxy[0];
 +		walk->moffset[1] += xy[1] - prevxy[1];
 +
 +		copy_v2_v2_int(walk->prev_mval, xy);
 +
 +		if ((walk->center_mval[0] != event->mval[0]) ||
 +		    (walk->center_mval[1] != event->mval[1]))
 +		{
 +			walk->redraw = true;
 +
++#ifdef USE_TABLET_SUPPORT
++			if (walk->is_cursor_absolute) {
++				/* pass */
++			}
++			else
++#endif
++
 +			if (wm_event_is_last_mousemove(event) && walk->use_mouse) {
 +				wmWindow *win = CTX_wm_window(C);
 +
 +#ifdef __APPLE__
 +				if ((abs(walk->prev_mval[0] - walk->center_mval[0]) > walk->center_mval[0] / 2) ||
 +				    (abs(walk->prev_mval[1] - walk->center_mval[1]) > walk->center_mval[1] / 2))
 +#endif
 +				{
 +					WM_cursor_warp(win,
 +					               walk->ar->winrct.xmin + walk->center_mval[0],
 +					               walk->ar->winrct.ymin + walk->center_mval[1]);
 +					copy_v2_v2_int(walk->prev_mval, walk->center_mval);
 +				}
 +			}
 +		}
 +	}
 +	else if (event->type == NDOF_MOTION) {
 +		/* do these automagically get delivered? yes. */
 +		// puts("ndof motion detected in walk mode!");
 +		// static const char *tag_name = "3D mouse position";
 +
 +		const wmNDOFMotionData *incoming_ndof = event->customdata;
 +		switch (incoming_ndof->progress) {
 +			case P_STARTING:
 +				/* start keeping track of 3D mouse position */
 +#ifdef NDOF_WALK_DEBUG
 +				puts("start keeping track of 3D mouse position");
 +#endif
 +				/* fall-through */
 +			case P_IN_PROGRESS:
 +				/* update 3D mouse position */
 +#ifdef NDOF_WALK_DEBUG
 +				putchar('.'); fflush(stdout);
 +#endif
 +				if (walk->ndof == NULL) {
 +					// walk->ndof = MEM_mallocN(sizeof(wmNDOFMotionData), tag_name);
 +					walk->ndof = MEM_dupallocN(incoming_ndof);
 +					// walk->ndof = malloc(sizeof(wmNDOFMotionData));
 +				}
 +				else {
 +					memcpy(walk->ndof, incoming_ndof, sizeof(wmNDOFMotionData));
 +				}
 +				break;
 +			case P_FINISHING:
 +				/* stop keeping track of 3D mouse position */
 +#ifdef NDOF_WALK_DEBUG
 +				puts("stop keeping track of 3D mouse position");
 +#endif
 +				if (walk->ndof) {
 +					MEM_freeN(walk->ndof);
 +					// free(walk->ndof);
 +					walk->ndof = NULL;
 +				}
 +
 +				/* update the time else the view will jump when 2D mouse/timer resume */
 +				walk->time_lastdraw = PIL_check_seconds_timer();
 +
 +				break;
 +			default:
 +				break; /* should always be one of the above 3 */
 +		}
 +	}
  }
  
  static void walkMoveCamera(bContext *C, WalkInfo *walk,
@@@ -919,128 -950,6 +989,128 @@@ static float getVelocityZeroTime(const 
  #define WALK_MOVE_SPEED base_speed
  #define WALK_BOOST_FACTOR ((void)0, walk->speed_factor)
  
 +/* rotate about the Y axis- look left/right */
 +static void walk_mouse_rotate_horizontal(ARegion *ar, RegionView3D *rv3d, const float mouse_speed, int moffset[2], float r_mat[3][3], float r_upvec[3])
 +{
 +	float x;
 +	float tmp_quat[4];
 +
 +	/* if we're upside down invert the moffset */
 +	copy_v3_fl3(r_upvec, 0.0f, 1.0f, 0.0f);
 +	mul_m3_v3(r_mat, r_upvec);
 +
 +	if (r_upvec[2] < 0.0f)
 +		moffset[0] = -moffset[0];
 +
 +	/* relative offset */
 +	x = (float) moffset[0] / ar->winx;
 +
 +	/* speed factor */
 +	x *= WALK_ROTATE_FAC;
 +
 +	/* user adjustement factor */
 +	x *= mouse_speed;
 +
 +	copy_v3_fl3(r_upvec, 0.0f, 0.0f, 1.0f);
 +
 +	/* Rotate about the relative up vec */
 +	axis_angle_normalized_to_quat(tmp_quat, r_upvec, x);
 +	mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat);
 +}
 +
 +/* rotate about the X axis- look up/down */
 +static void walk_mouse_rotate_vertical(ARegion *ar, RegionView3D *rv3d, const float mouse_speed, int moffset[2], float r_mat[3][3], float r_upvec[3])
 +{
 +	float angle, y;
 +	float tmp_quat[4];
 +
 +	/* relative offset */
 +	y = (float) moffset[1] / ar->winy;
 +
 +	/* speed factor */
 +	y *= WALK_ROTATE_FAC;
 +
 +	/* user adjustement factor */
 +	y *= mouse_speed;
 +
 +	/* clamp the angle limits */
 +	/* it ranges from 90.0f to -90.0f */
 +	angle = -asinf(rv3d->viewmat[2][2]);
 +
 +	if (angle > WALK_TOP_LIMIT && y > 0.0f)
 +		y = 0.0f;
 +
 +	else if (angle < WALK_BOTTOM_LIMIT && y < 0.0f)
 +		y = 0.0f;
 +
 +	copy_v3_fl3(r_upvec, 1.0f, 0.0f, 0.0f);
 +	mul_m3_v3(r_mat, r_upvec);
 +	/* Rotate about the relative up vec */
 +	axis_angle_to_quat(tmp_quat, r_upvec, -y);
 +	mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, tmp_quat);
 +}
 +
 +static void walk_forward(float mat[3][3], const float speed,
 +                        const bool is_world_forward, float r_dvec[3])
 +{
 +	float dvec_tmp[3] = {0.0f, 0.0f, speed};
 +
 +	mul_m3_v3(mat, dvec_tmp);
 +
 +	if (is_world_forward)
 +		dvec_tmp[2] = 0.0f;
 +
 +	normalize_v3(dvec_tmp);
 +	mu

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list