ndof data change: operators can access values as vectors or components, as both are...
authorMike Erwin <significant.bit@gmail.com>
Sun, 7 Aug 2011 17:22:47 +0000 (17:22 +0000)
committerMike Erwin <significant.bit@gmail.com>
Sun, 7 Aug 2011 17:22:47 +0000 (17:22 +0000)
source/blender/windowmanager/WM_types.h
source/blender/windowmanager/intern/wm_event_system.c

index 7fd52e89a5ffa5daa1453d41b0370454ea9896c0..697133bb163644247b2afcec824241cabe2ac8ab 100644 (file)
@@ -389,8 +389,14 @@ typedef struct wmNDOFMotionData {
        /* awfully similar to GHOST_TEventNDOFMotionData... */
        // Each component normally ranges from -1 to +1, but can exceed that.
        // These use blender standard view coordinates, with positive rotations being CCW about the axis.
-       float tvec[3]; // translation
-       float rvec[3]; // rotation:
+       union {
+               float tvec[3]; // translation
+               struct { float tx, ty, tz; };
+               };
+       union {
+               float rvec[3]; // rotation:
+               struct { float rx, ry, rz; };
+               };
                // axis = (rx,ry,rz).normalized
                // amount = (rx,ry,rz).magnitude [in revolutions, 1.0 = 360 deg]
        float dt; // time since previous NDOF Motion event
index 258d6bbc025fe95198069f6769a5d0999021de8a..c1fd903c479df78225ccca5169447ca2d48c49bb 100644 (file)
@@ -2329,29 +2329,32 @@ static void attach_ndof_data(wmEvent* event, const GHOST_TEventNDOFMotionData* g
 
        const float s = U.ndof_sensitivity;
 
-       data->tvec[0]= s * ghost->tx;
+       data->t= s * ghost->tx;
 
-       data->rvec[0]= s * ghost->rx;
-       data->rvec[1]= s * ghost->ry;
-       data->rvec[2]= s * ghost->rz;
+       data->r= s * ghost->rx;
+       data->r= s * ghost->ry;
+       data->r= s * ghost->rz;
 
        if (U.ndof_flag & NDOF_ZOOM_UPDOWN)
                {
-               // rotate so Y is where Z was (maintain handed-ness)
-               data->tvec[1]= s * ghost->tz;
-               data->tvec[2]= s * -ghost->ty;
-
-               // should this affect rotation also?
-               // initial guess is 'yes', but get user feedback immediately!
-#if 0  // after turning this on, my guess becomes 'no'
-               data->rvec[1]= s * ghost->rz;
-               data->rvec[2]= s * ghost->ry;
+               /* rotate so Y is where Z was */
+               data->ty = s * ghost->tz;
+               data->tz = s * ghost->ty;
+               /* maintain handed-ness? or just do what feels right? */
+
+               /* should this affect rotation also?
+                * initial guess is 'yes', but get user feedback immediately!
+                */
+#if 0
+               /* after turning this on, my guess becomes 'no' */
+               data->ry = s * ghost->rz;
+               data->rz = s * ghost->ry;
 #endif
                }
        else
                {
-               data->tvec[1]= s * ghost->ty;
-               data->tvec[2]= s * ghost->tz;
+               data->t= s * ghost->ty;
+               data->t= s * ghost->tz;
                }
 
        data->dt = ghost->dt;