[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [38672] branches/merwin-spacenav/source/ blender: added option to invert axes for orbiting (part 1 of 2)

Mike Erwin significant.bit at gmail.com
Mon Jul 25 02:20:46 CEST 2011


Revision: 38672
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=38672
Author:   merwin
Date:     2011-07-25 00:20:45 +0000 (Mon, 25 Jul 2011)
Log Message:
-----------
added option to invert axes for orbiting (part 1 of 2)

Modified Paths:
--------------
    branches/merwin-spacenav/source/blender/editors/space_view3d/view3d_edit.c
    branches/merwin-spacenav/source/blender/makesdna/DNA_userdef_types.h
    branches/merwin-spacenav/source/blender/makesrna/intern/rna_userdef.c

Modified: branches/merwin-spacenav/source/blender/editors/space_view3d/view3d_edit.c
===================================================================
--- branches/merwin-spacenav/source/blender/editors/space_view3d/view3d_edit.c	2011-07-25 00:10:42 UTC (rev 38671)
+++ branches/merwin-spacenav/source/blender/editors/space_view3d/view3d_edit.c	2011-07-25 00:20:45 UTC (rev 38672)
@@ -1019,6 +1019,8 @@
 
 	if (has_rotation) {
 
+		const int invert = U.ndof_flag & NDOF_ORBIT_INVERT_AXES;
+
 		rv3d->view = RV3D_VIEW_USER;
 
 		if (U.flag & USER_TRACKBALL) {
@@ -1027,8 +1029,8 @@
 			float view_inv[4], view_inv_conj[4];
 
 			ndof_to_quat(ndof, rot);
-			// scale by rot_sensitivity?
-			// mul_qt_fl(rot, rot_sensitivity);
+			// mul_qt_fl(rot, rot_sensitivity * (invert ? -1.f : 1.f));
+			// ^^ no apparent effect
 
 			invert_qt_qt(view_inv, rv3d->viewquat);
 			copy_qt_qt(view_inv_conj, view_inv);
@@ -1038,6 +1040,10 @@
 			mul_qt_qtqt(rot, view_inv, rot);
 			mul_qt_qtqt(rot, rot, view_inv_conj);
 
+			// if (invert)
+			//	invert_qt(rot);
+			// ^^ argh!! this does something crazy
+
 			// apply rotation
 			mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot);
 
@@ -1053,12 +1059,16 @@
 
 			/* Perform the up/down rotation */
 			angle = rot_sensitivity * dt * ndof->rx;
+			if (invert)
+				angle = -angle;
 			rot[0] = cos(angle);
 			mul_v3_v3fl(rot+1, xvec, sin(angle));
 			mul_qt_qtqt(rv3d->viewquat, rv3d->viewquat, rot);
 
 			/* Perform the orbital rotation */
 			angle = rot_sensitivity * dt * ndof->ry;
+			if (invert)
+				angle = -angle;
 			rot[0] = cos(angle);
 			rot[1] = rot[2] = 0.0;
 			rot[3] = sin(angle);

Modified: branches/merwin-spacenav/source/blender/makesdna/DNA_userdef_types.h
===================================================================
--- branches/merwin-spacenav/source/blender/makesdna/DNA_userdef_types.h	2011-07-25 00:10:42 UTC (rev 38671)
+++ branches/merwin-spacenav/source/blender/makesdna/DNA_userdef_types.h	2011-07-25 00:20:45 UTC (rev 38672)
@@ -589,6 +589,17 @@
 #define NDOF_SHOULD_PAN     (1 << 3)
 #define NDOF_SHOULD_ZOOM    (1 << 4)
 #define NDOF_SHOULD_ROTATE  (1 << 5)
+/* orbit navigation modes
+   only two options, so it's sort of a hyrbrid bool/enum
+   if ((U.ndof_flag & NDOF_ORBIT_MODE) == NDOF_OM_OBJECT)... */
+/*
+#define NDOF_ORBIT_MODE     (1 << 6)
+#define NDOF_OM_TARGETCAMERA 0
+#define NDOF_OM_OBJECT      NDOF_ORBIT_MODE
+*/
+/* actually... users probably don't care about what the mode
+   is called, just that it feels right */
+#define NDOF_ORBIT_INVERT_AXES (1 << 6)
 
 
 #ifdef __cplusplus

Modified: branches/merwin-spacenav/source/blender/makesrna/intern/rna_userdef.c
===================================================================
--- branches/merwin-spacenav/source/blender/makesrna/intern/rna_userdef.c	2011-07-25 00:10:42 UTC (rev 38671)
+++ branches/merwin-spacenav/source/blender/makesrna/intern/rna_userdef.c	2011-07-25 00:20:45 UTC (rev 38672)
@@ -2748,13 +2748,17 @@
 	RNA_def_property_ui_text(prop, "Show Navigation Guide", "Display the center and axis during rotation");
 	/* TODO: update description when fly-mode visuals are in place  ("projected position in fly mode")*/
 
+	prop= RNA_def_property(srna, "ndof_orbit_invert_axes", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_ORBIT_INVERT_AXES);
+	RNA_def_property_ui_text(prop, "Invert Axes", "Toggle between moving the viewpoint or moving the scene being viewed");
+
 	prop= RNA_def_property(srna, "ndof_lock_horizon", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_LOCK_HORIZON);
 	RNA_def_property_ui_text(prop, "Lock Horizon", "Keep horizon level while flying with 3D Mouse");
 
 	prop= RNA_def_property(srna, "ndof_fly_helicopter", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "ndof_flag", NDOF_FLY_HELICOPTER);
-	RNA_def_property_ui_text(prop, "Helicopter Fly Mode", "");
+	RNA_def_property_ui_text(prop, "Helicopter Mode", "Device up/down directly controls your Z position");
 
 
 	prop= RNA_def_property(srna, "mouse_double_click_time", PROP_INT, PROP_NONE);




More information about the Bf-blender-cvs mailing list