Revision: 44782
          
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44782
Author:   campbellbarton
Date:     2012-03-10 06:46:23 +0000 (Sat, 10 Mar 2012)
Log Message:
-----------
style cleanup: fly mode.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_view3d/view3d_fly.c

Modified: trunk/blender/source/blender/editors/space_view3d/view3d_fly.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/view3d_fly.c      
2012-03-10 05:20:41 UTC (rev 44781)
+++ trunk/blender/source/blender/editors/space_view3d/view3d_fly.c      
2012-03-10 06:46:23 UTC (rev 44782)
@@ -24,12 +24,10 @@
  *  \ingroup spview3d
  */
 
-
 /* defines VIEW3D_OT_fly modal operator */
 
 //#define NDOF_FLY_DEBUG
 //#define NDOF_FLY_DRAW_TOOMUCH // is this needed for ndof? - commented so 
redraw doesnt thrash - campbell
-
 #include "DNA_anim_types.h"
 #include "DNA_scene_types.h"
 #include "DNA_object_types.h"
@@ -59,10 +57,9 @@
 #include "PIL_time.h" /* smoothview */
 
 #include "view3d_intern.h"     // own include
-
 /* NOTE: these defines are saved in keymap files, do not change values but 
just add new ones */
 enum {
-       FLY_MODAL_CANCEL= 1,
+       FLY_MODAL_CANCEL = 1,
        FLY_MODAL_CONFIRM,
        FLY_MODAL_ACCELERATE,
        FLY_MODAL_DECELERATE,
@@ -87,41 +84,42 @@
 void fly_modal_keymap(wmKeyConfig *keyconf)
 {
        static EnumPropertyItem modal_items[] = {
-           {FLY_MODAL_CANCEL,  "CANCEL", 0, "Cancel", ""},
-           {FLY_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
-           {FLY_MODAL_ACCELERATE, "ACCELERATE", 0, "Accelerate", ""},
-           {FLY_MODAL_DECELERATE, "DECELERATE", 0, "Decelerate", ""},
+               {FLY_MODAL_CANCEL, "CANCEL", 0, "Cancel", ""},
+               {FLY_MODAL_CONFIRM, "CONFIRM", 0, "Confirm", ""},
+               {FLY_MODAL_ACCELERATE, "ACCELERATE", 0, "Accelerate", ""},
+               {FLY_MODAL_DECELERATE, "DECELERATE", 0, "Decelerate", ""},
 
-           {FLY_MODAL_PAN_ENABLE,      "PAN_ENABLE", 0, "Pan Enable", ""},
-           {FLY_MODAL_PAN_DISABLE,     "PAN_DISABLE", 0, "Pan Disable", ""},
+               {FLY_MODAL_PAN_ENABLE, "PAN_ENABLE", 0, "Pan Enable", ""},
+               {FLY_MODAL_PAN_DISABLE, "PAN_DISABLE", 0, "Pan Disable", ""},
 
-           {FLY_MODAL_DIR_FORWARD,     "FORWARD", 0, "Fly Forward", ""},
-           {FLY_MODAL_DIR_BACKWARD,"BACKWARD", 0, "Fly Backward", ""},
-           {FLY_MODAL_DIR_LEFT,        "LEFT", 0, "Fly Left", ""},
-           {FLY_MODAL_DIR_RIGHT,       "RIGHT", 0, "Fly Right", ""},
-           {FLY_MODAL_DIR_UP,          "UP", 0, "Fly Up", ""},
-           {FLY_MODAL_DIR_DOWN,        "DOWN", 0, "Fly Down", ""},
+               {FLY_MODAL_DIR_FORWARD, "FORWARD", 0, "Fly Forward", ""},
+               {FLY_MODAL_DIR_BACKWARD, "BACKWARD", 0, "Fly Backward", ""},
+               {FLY_MODAL_DIR_LEFT, "LEFT", 0, "Fly Left", ""},
+               {FLY_MODAL_DIR_RIGHT, "RIGHT", 0, "Fly Right", ""},
+               {FLY_MODAL_DIR_UP, "UP", 0, "Fly Up", ""},
+               {FLY_MODAL_DIR_DOWN, "DOWN", 0, "Fly Down", ""},
 
-           {FLY_MODAL_AXIS_LOCK_X,     "AXIS_LOCK_X", 0, "X Axis Correction", 
"X axis correction (toggle)"},
-           {FLY_MODAL_AXIS_LOCK_Z,     "AXIS_LOCK_Z", 0, "X Axis Correction", 
"Z axis correction (toggle)"},
+               {FLY_MODAL_AXIS_LOCK_X, "AXIS_LOCK_X", 0, "X Axis Correction", 
"X axis correction (toggle)"},
+               {FLY_MODAL_AXIS_LOCK_Z, "AXIS_LOCK_Z", 0, "X Axis Correction", 
"Z axis correction (toggle)"},
 
-           {FLY_MODAL_PRECISION_ENABLE,        "PRECISION_ENABLE", 0, 
"Precision Enable", ""},
-           {FLY_MODAL_PRECISION_DISABLE,       "PRECISION_DISABLE", 0, 
"Precision Disable", ""},
+               {FLY_MODAL_PRECISION_ENABLE, "PRECISION_ENABLE", 0, "Precision 
Enable", ""},
+               {FLY_MODAL_PRECISION_DISABLE, "PRECISION_DISABLE", 0, 
"Precision Disable", ""},
 
-           {FLY_MODAL_FREELOOK_ENABLE,         "FREELOOK_ENABLE", 0, "Rotation 
Enable", ""},
-           {FLY_MODAL_FREELOOK_DISABLE,        "FREELOOK_DISABLE", 0, 
"Rotation Disable", ""},
+               {FLY_MODAL_FREELOOK_ENABLE, "FREELOOK_ENABLE", 0, "Rotation 
Enable", ""},
+               {FLY_MODAL_FREELOOK_DISABLE, "FREELOOK_DISABLE", 0, "Rotation 
Disable", ""},
 
-           {0, NULL, 0, NULL, NULL}};
+               {0, NULL, 0, NULL, NULL}};
 
-       wmKeyMap *keymap= WM_modalkeymap_get(keyconf, "View3D Fly Modal");
+       wmKeyMap *keymap = WM_modalkeymap_get(keyconf, "View3D Fly Modal");
 
        /* this function is called for each spacetype, only needs to add map 
once */
-       if (keymap) return;
+       if (keymap)
+               return;
 
-       keymap= WM_modalkeymap_add(keyconf, "View3D Fly Modal", modal_items);
+       keymap = WM_modalkeymap_add(keyconf, "View3D Fly Modal", modal_items);
 
        /* items for modal map */
-       WM_modalkeymap_add_item(keymap, ESCKEY,    KM_PRESS, KM_ANY, 0, 
FLY_MODAL_CANCEL);
+       WM_modalkeymap_add_item(keymap, ESCKEY, KM_PRESS, KM_ANY, 0, 
FLY_MODAL_CANCEL);
        WM_modalkeymap_add_item(keymap, RIGHTMOUSE, KM_ANY, KM_ANY, 0, 
FLY_MODAL_CANCEL);
 
        WM_modalkeymap_add_item(keymap, LEFTMOUSE, KM_ANY, KM_ANY, 0, 
FLY_MODAL_CONFIRM);
@@ -171,8 +169,9 @@
        short state;
        short redraw;
        unsigned char use_precision;
-       unsigned char use_freelook; /* if the user presses shift they can look 
about
-                                    * without moving the direction there 
looking */
+       /* if the user presses shift they can look about
+        * without moving the direction there looking */
+       unsigned char use_freelook;
 
        int mval[2]; /* latest 2D mouse values */
        wmNDOFMotionData* ndof; /* latest 3D mouse values */
@@ -197,14 +196,16 @@
        /* backup values */
        float dist_backup; /* backup the views distance since we use a zero 
dist for fly mode */
        float ofs_backup[3]; /* backup the views offset in case the user 
cancels flying in non camera mode */
-       float rot_backup[4]; /* backup the views quat in case the user cancels 
flying in non camera mode.
-                             * (quat for view, eul for camera) */
+
+       /* backup the views quat in case the user cancels flying in non camera 
mode.
+        * (quat for view, eul for camera) */
+       float rot_backup[4];
        short persp_backup; /* remember if were ortho or not, only used for 
restoring the view if it was a ortho view */
 
-       short is_ortho_cam; /* are we flying an ortho camera in perspective 
view,
-                            * which was originall in ortho view?
-                            * could probably figure it out but better be 
explicit */
-
+       /* are we flying an ortho camera in perspective view,
+        * which was originall in ortho view?
+        * could probably figure it out but better be explicit */
+       short is_ortho_cam;
        void *obtfm; /* backup the objects transform */
 
        /* compare between last state */
@@ -225,42 +226,41 @@
        /* draws 4 edge brackets that frame the safe area where the
         * mouse can move during fly mode without spinning the view */
        float x1, x2, y1, y2;
-       
-       x1= 0.45f * (float)fly->ar->winx;
-       y1= 0.45f * (float)fly->ar->winy;
-       x2= 0.55f * (float)fly->ar->winx;
-       y2= 0.55f * (float)fly->ar->winy;
+
+       x1 = 0.45f * (float)fly->ar->winx;
+       y1 = 0.45f * (float)fly->ar->winy;
+       x2 = 0.55f * (float)fly->ar->winx;
+       y2 = 0.55f * (float)fly->ar->winy;
        cpack(0);
-       
-       
+
        glBegin(GL_LINES);
        /* bottom left */
-       glVertex2f(x1,y1); 
-       glVertex2f(x1,y1+5);
-       
-       glVertex2f(x1,y1); 
-       glVertex2f(x1+5,y1);
-       
+       glVertex2f(x1, y1);
+       glVertex2f(x1, y1 + 5);
+
+       glVertex2f(x1, y1);
+       glVertex2f(x1 + 5, y1);
+
        /* top right */
-       glVertex2f(x2,y2); 
-       glVertex2f(x2,y2-5);
-       
-       glVertex2f(x2,y2); 
-       glVertex2f(x2-5,y2);
-       
+       glVertex2f(x2, y2);
+       glVertex2f(x2, y2 - 5);
+
+       glVertex2f(x2, y2);
+       glVertex2f(x2 - 5, y2);
+
        /* top left */
-       glVertex2f(x1,y2); 
-       glVertex2f(x1,y2-5);
-       
-       glVertex2f(x1,y2); 
-       glVertex2f(x1+5,y2);
-       
+       glVertex2f(x1, y2);
+       glVertex2f(x1, y2 - 5);
+
+       glVertex2f(x1, y2);
+       glVertex2f(x1 + 5, y2);
+
        /* bottom right */
-       glVertex2f(x2,y1); 
-       glVertex2f(x2,y1+5);
-       
-       glVertex2f(x2,y1); 
-       glVertex2f(x2-5,y1);
+       glVertex2f(x2, y1);
+       glVertex2f(x2, y1 + 5);
+
+       glVertex2f(x2, y1);
+       glVertex2f(x2 - 5, y1);
        glEnd();
 }
 
@@ -269,21 +269,22 @@
 #define FLY_CANCEL             1
 #define FLY_CONFIRM            2
 
-static int initFlyInfo (bContext *C, FlyInfo *fly, wmOperator *op, wmEvent 
*event)
+static int initFlyInfo(bContext *C, FlyInfo *fly, wmOperator *op, wmEvent 
*event)
 {
+       wmWindow *win = CTX_wm_window(C);
        float upvec[3]; // tmp
        float mat[3][3];
 
-       fly->rv3d= CTX_wm_region_view3d(C);
+       fly->rv3d = CTX_wm_region_view3d(C);
        fly->v3d = CTX_wm_view3d(C);
        fly->ar = CTX_wm_region(C);
-       fly->scene= CTX_data_scene(C);
+       fly->scene = CTX_data_scene(C);
 
 #ifdef NDOF_FLY_DEBUG
        puts("\n-- fly begin --");
 #endif
 
-       if (fly->rv3d->persp==RV3D_CAMOB && fly->v3d->camera->id.lib) {
+       if (fly->rv3d->persp == RV3D_CAMOB && fly->v3d->camera->id.lib) {
                BKE_report(op->reports, RPT_ERROR, "Cannot fly a camera from an 
external library");
                return FALSE;
        }
@@ -293,85 +294,89 @@
                return FALSE;
        }
 
-       if (fly->rv3d->persp==RV3D_CAMOB && 
fly->v3d->camera->constraints.first) {
+       if (fly->rv3d->persp == RV3D_CAMOB && 
fly->v3d->camera->constraints.first) {
                BKE_report(op->reports, RPT_ERROR, "Cannot fly an object with 
constraints");
                return FALSE;
        }
 
-       fly->state= FLY_RUNNING;
-       fly->speed= 0.0f;
-       fly->axis= 2;
-       fly->pan_view= FALSE;
-       fly->xlock= FALSE;
-       fly->zlock= FALSE;
-       fly->xlock_momentum=0.0f;
-       fly->zlock_momentum=0.0f;
-       fly->grid= 1.0f;
-       fly->use_precision= FALSE;
-       fly->use_freelook= FALSE;
+       fly->state = FLY_RUNNING;
+       fly->speed = 0.0f;
+       fly->axis = 2;
+       fly->pan_view = FALSE;
+       fly->xlock = FALSE;
+       fly->zlock = FALSE;
+       fly->xlock_momentum = 0.0f;
+       fly->zlock_momentum = 0.0f;
+       fly->grid = 1.0f;
+       fly->use_precision = FALSE;
+       fly->use_freelook = FALSE;
 
 #ifdef NDOF_FLY_DRAW_TOOMUCH
        fly->redraw= 1;
 #endif
-       fly->dvec_prev[0]= fly->dvec_prev[1]= fly->dvec_prev[2]= 0.0f;
+       fly->dvec_prev[0] = fly->dvec_prev[1] = fly->dvec_prev[2] = 0.0f;
 
-       fly->timer= WM_event_add_timer(CTX_wm_manager(C), CTX_wm_window(C), 
TIMER, 0.01f);
+       fly->timer = WM_event_add_timer(CTX_wm_manager(C), win, TIMER, 0.01f);
 
        copy_v2_v2_int(fly->mval, event->mval);
        fly->ndof = NULL;
 
-       fly->time_lastdraw= fly->time_lastwheel= PIL_check_seconds_timer();
+       fly->time_lastdraw = fly->time_lastwheel = PIL_check_seconds_timer();
 
        fly->draw_handle_pixel = ED_region_draw_cb_activate(fly->ar->type, 
drawFlyPixel, fly, REGION_DRAW_POST_PIXEL);
 
        fly->rv3d->rflag |= RV3D_NAVIGATING; /* so we draw the corner margins */
 
        /* detect weather to start with Z locking */
-       upvec[0]=1.0f; upvec[1]=0.0f; upvec[2]=0.0f;
+       upvec[0] = 1.0f;
+       upvec[1] = 0.0f;
+       upvec[2] = 0.0f;
        copy_m3_m4(mat, fly->rv3d->viewinv);
        mul_m3_v3(mat, upvec);
        if (fabs(upvec[2]) < 0.1)
                fly->zlock = 1;
-       upvec[0]=0; upvec[1]=0; upvec[2]=0;
+       upvec[0] = 0;
+       upvec[1] = 0;
+       upvec[2] = 0;
 
-       fly->persp_backup= fly->rv3d->persp;
-       fly->dist_backup= fly->rv3d->dist;
+       fly->persp_backup = fly->rv3d->persp;
+       fly->dist_backup = fly->rv3d->dist;
 
        /* check for flying ortho camera - which we cant support well
         * we _could_ also check for an ortho camera but this is easier */
-       if (     (fly->rv3d->persp == RV3D_CAMOB) &&

@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to