diff options
author | Campbell Barton <ideasman42@gmail.com> | 2010-10-02 23:31:23 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2010-10-02 23:31:23 +0400 |
commit | a6e78239424fa735fd71dd03a4c9501aa6635d9a (patch) | |
tree | 53fa9564ca5b4718fd3dfe5cd24c22259bc97b7b /source/blender/editors/space_view3d | |
parent | 5faa29b01dd6b47219d1aabb3217459ba1e2f56d (diff) |
make fly mode border draw into a area drawing callback rather then using a flag (no functional change).
Diffstat (limited to 'source/blender/editors/space_view3d')
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 50 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 57 |
2 files changed, 57 insertions, 50 deletions
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 871057801f8..6d61123de24 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -926,52 +926,6 @@ void view3d_set_1_to_1_viewborder(Scene *scene, ARegion *ar) rv3d->camzoom= CLAMPIS(rv3d->camzoom, RV3D_CAMZOOM_MIN, RV3D_CAMZOOM_MAX); } - -static void drawviewborder_flymode(ARegion *ar) -{ - /* 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.45*(float)ar->winx; - y1= 0.45*(float)ar->winy; - x2= 0.55*(float)ar->winx; - y2= 0.55*(float)ar->winy; - cpack(0); - - - glBegin(GL_LINES); - /* bottom left */ - 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); - - /* top left */ - 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); - glEnd(); -} - - static void drawviewborder(Scene *scene, ARegion *ar, View3D *v3d) { float fac, a; @@ -2456,8 +2410,8 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar) /* Draw particle edit brush XXX (removed) */ - if(rv3d->persp==RV3D_CAMOB) drawviewborder(scene, ar, v3d); - if(rv3d->rflag & RV3D_FLYMODE) drawviewborder_flymode(ar); + if(rv3d->persp==RV3D_CAMOB) + drawviewborder(scene, ar, v3d); if ((v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { /* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */ diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 146e90baeb1..ebfa77a4a15 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -64,6 +64,7 @@ #include "ED_keyframing.h" #include "ED_screen.h" #include "ED_armature.h" +#include "ED_space_api.h" #include "GPU_draw.h" @@ -1973,11 +1974,59 @@ typedef struct FlyInfo { double time_lastwheel; /* used to accelerate when using the mousewheel a lot */ double time_lastdraw; /* time between draws */ + void *draw_handle_pixel; + /* use for some lag */ float dvec_prev[3]; /* old for some lag */ } FlyInfo; +static void drawFlyPixel(const struct bContext *C, struct ARegion *ar, void *arg) +{ + FlyInfo *fly = arg; + + /* 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.45*(float)fly->ar->winx; + y1= 0.45*(float)fly->ar->winy; + x2= 0.55*(float)fly->ar->winx; + y2= 0.55*(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); + + /* top right */ + 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); + + /* bottom right */ + glVertex2f(x2,y1); + glVertex2f(x2,y1+5); + + glVertex2f(x2,y1); + glVertex2f(x2-5,y1); + glEnd(); +} + /* FlyInfo->state */ #define FLY_RUNNING 0 #define FLY_CANCEL 1 @@ -2029,7 +2078,9 @@ static int initFlyInfo (bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *even fly->time_lastdraw= fly->time_lastwheel= PIL_check_seconds_timer(); - fly->rv3d->rflag |= RV3D_FLYMODE|RV3D_NAVIGATING; /* so we draw the corner margins */ + 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; @@ -2094,6 +2145,8 @@ static int flyEnd(bContext *C, FlyInfo *fly) WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), fly->timer); + ED_region_draw_cb_exit(fly->ar->type, fly->draw_handle_pixel); + rv3d->dist= fly->dist_backup; if (fly->state == FLY_CANCEL) { @@ -2146,7 +2199,7 @@ static int flyEnd(bContext *C, FlyInfo *fly) /*Done with correcting for the dist */ } - rv3d->rflag &= ~(RV3D_FLYMODE|RV3D_NAVIGATING); + rv3d->rflag &= ~RV3D_NAVIGATING; //XXX2.5 BIF_view3d_previewrender_signal(fly->sa, PR_DBASE|PR_DISPRECT); /* not working at the moment not sure why */ if(fly->obtfm) |