Region post redraw is now split up in a view space and pixel space
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 20 Oct 2009 21:05:22 +0000 (21:05 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Tue, 20 Oct 2009 21:05:22 +0000 (21:05 +0000)
part. This fixes a bug where transform help line drawing would not
work with view clipping and mess up the z-buffer. This avoids the
transform code having to figure out what kind of opengl state is
enabled and disable it temporarily.

source/blender/editors/include/ED_space_api.h
source/blender/editors/mesh/loopcut.c
source/blender/editors/space_api/spacetypes.c
source/blender/editors/space_image/image_draw.c
source/blender/editors/space_image/image_ops.c
source/blender/editors/space_image/space_image.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform.h
source/blender/editors/transform/transform_generics.c

index 04b6be3bcaa8cdbfd4a32eda533e10d958607e7b..14819206dfa5f39205f858a466988ac1f1ffaa8f 100644 (file)
@@ -60,8 +60,8 @@ void ED_spacetype_userpref(void);
 void ED_file_init(void);
 void ED_file_exit(void);
 
-#define REGION_DRAW_PRE                1
-#define REGION_DRAW_POST       0
+#define REGION_DRAW_POST_VIEW  0
+#define REGION_DRAW_POST_PIXEL 1
 
 void *ED_region_draw_cb_activate(struct ARegionType *, 
                                                                 void   (*draw)(const struct bContext *, struct ARegion *, void *),
index b7a37f7493881a7642aa47d1e823e33d77354555..e12f3c99fcd407d4578c75bfdb1abfd45a149b90 100644 (file)
@@ -301,7 +301,7 @@ static int ringsel_init (bContext *C, wmOperator *op, int do_cut)
        
        /* assign the drawing handle for drawing preview line... */
        lcd->ar= CTX_wm_region(C);
-       lcd->draw_handle= ED_region_draw_cb_activate(lcd->ar->type, ringsel_draw, lcd, REGION_DRAW_POST);
+       lcd->draw_handle= ED_region_draw_cb_activate(lcd->ar->type, ringsel_draw, lcd, REGION_DRAW_POST_VIEW);
        lcd->ob = CTX_data_edit_object(C);
        lcd->em= BKE_mesh_get_editmesh((Mesh *)lcd->ob->data);
        lcd->extend = do_cut ? 0 : RNA_boolean_get(op->ptr, "extend");
index bdcfd20b5f0846274f240dc949d4d1ff47a2df66..f3db414099f26dcf46fd186dedae2d3a5fea7e3f 100644 (file)
@@ -151,10 +151,6 @@ void ED_spacetypes_keymap(wmKeyConfig *keyconf)
 
 /* ********************** custom drawcall api ***************** */
 
-/* type */
-#define REGION_DRAW_PRE                1
-#define REGION_DRAW_POST       0
-
 typedef struct RegionDrawCB {
        struct RegionDrawCB *next, *prev;
        
index a42fec30c4592a95a37455f01319c99967ecfe0a..46ec41eda58024e479c8efd2f691101fe560a306 100644 (file)
@@ -173,8 +173,6 @@ void draw_image_info(ARegion *ar, int channels, int x, int y, char *cp, float *f
 {
        char str[256];
        int ofs;
-
-       ED_region_pixelspace(ar);
        
        ofs= sprintf(str, "X: %d Y: %d ", x, y);
        if(cp)
index ffc737eb9af144ee367842ebe654e446dfb0f6b2..8d7295e9f20e3db0fe44b57b0251f481a93f3183 100644 (file)
@@ -1539,7 +1539,7 @@ static int sample_invoke(bContext *C, wmOperator *op, wmEvent *event)
        
        info= MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
        info->art= ar->type;
-       info->draw_handle = ED_region_draw_cb_activate(ar->type, sample_draw, info, REGION_DRAW_POST);
+       info->draw_handle = ED_region_draw_cb_activate(ar->type, sample_draw, info, REGION_DRAW_POST_PIXEL);
        op->customdata= info;
 
        sample_apply(C, op, event);
index 115f970046f5c7252749895b8b9cdf30e0b179f9..36d1573a12c0e4e2a943749b98eb2638b88281e4 100644 (file)
@@ -431,15 +431,17 @@ static void image_main_area_draw(const bContext *C, ARegion *ar)
        UI_view2d_view_ortho(C, v2d);
        draw_uvedit_main(sima, ar, scene, obedit);
 
-       ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST);
+       ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
                
        /* Grease Pencil too (in addition to UV's) */
        draw_image_grease_pencil((bContext *)C, 1); 
 
        UI_view2d_view_restore(C);
-       
+
        /* draw Grease Pencil - screen space only */
        draw_image_grease_pencil((bContext *)C, 0);
+
+       ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_PIXEL);
        
        /* scrollers? */
        /*scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_UNIT_VALUES, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
index fac3f9fb555cb2ca4909fa796c7827c01023ada9..15e41a6698104446f00bf3b983139588ffa501b3 100644 (file)
@@ -2056,7 +2056,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
                view3d_update_depths(ar, v3d);
        }
        
-       ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST);
+       ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW);
        
 //     REEB_draw();
        
@@ -2123,6 +2123,8 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
        ob= OBACT;
        if(U.uiflag & USER_DRAWVIEWINFO) 
                draw_selected_name(scene, ob, v3d);
+
+       ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_PIXEL);
        
        /* XXX here was the blockhandlers for floating panels */
 
index 1319fdc0bc4fcb8193f4f7d81836d838b2b7958d..3df74020fab397e8d15c367871c3fcfa15b4d9d7 100644 (file)
@@ -1124,15 +1124,8 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
 
                projectFloatView(t, vecrot, cent);      // no overflow in extreme cases
 
-               glDisable(GL_DEPTH_TEST);
-
-               glMatrixMode(GL_PROJECTION);
-               glPushMatrix();
-               glMatrixMode(GL_MODELVIEW);
                glPushMatrix();
 
-               ED_region_pixelspace(t->ar);
-
                switch(t->helpline)
                {
                        case HLP_SPRING:
@@ -1238,22 +1231,23 @@ void drawHelpline(const struct bContext *C, TransInfo *t)
                                }
                }
 
-               glMatrixMode(GL_PROJECTION);
                glPopMatrix();
-               glMatrixMode(GL_MODELVIEW);
-               glPopMatrix();
-
-               glEnable(GL_DEPTH_TEST);
        }
 }
 
-void drawTransform(const struct bContext *C, struct ARegion *ar, void *arg)
+void drawTransformView(const struct bContext *C, struct ARegion *ar, void *arg)
 {
        TransInfo *t = arg;
 
        drawConstraint(C, t);
        drawPropCircle(C, t);
        drawSnapping(C, t);
+}
+
+void drawTransformPixel(const struct bContext *C, struct ARegion *ar, void *arg)
+{
+       TransInfo *t = arg;
+
        drawHelpline(C, t);
 }
 
@@ -1373,11 +1367,13 @@ int initTransform(bContext *C, TransInfo *t, wmOperator *op, wmEvent *event, int
                //calc_manipulator_stats(curarea);
                initTransformOrientation(C, t);
 
-               t->draw_handle = ED_region_draw_cb_activate(t->ar->type, drawTransform, t, REGION_DRAW_POST);
+               t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
+               t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL);
        }
        else if(t->spacetype == SPACE_IMAGE) {
                Mat3One(t->spacemtx);
-               t->draw_handle = ED_region_draw_cb_activate(t->ar->type, drawTransform, t, REGION_DRAW_POST);
+               t->draw_handle_view = ED_region_draw_cb_activate(t->ar->type, drawTransformView, t, REGION_DRAW_POST_VIEW);
+               t->draw_handle_pixel = ED_region_draw_cb_activate(t->ar->type, drawTransformPixel, t, REGION_DRAW_POST_PIXEL);
        }
        else
                Mat3One(t->spacemtx);
index fc31fad622aba420edd84cff51789788fdea08e4..46e5dad3e053a49e8b7d1ef485a1d8021eb2a1f0 100644 (file)
@@ -302,7 +302,8 @@ typedef struct TransInfo {
        struct wmTimer *animtimer;
     short       mval[2];        /* current mouse position               */
     struct Object   *obedit;
-    void               *draw_handle;
+    void               *draw_handle_view;
+    void               *draw_handle_pixel;
 } TransInfo;
 
 
index 5372a9112c37900016762ac99d1e1f0e2a427a8a..2af92719d19fc6443d0f3284ccd4505430aea0e1 100644 (file)
@@ -1045,10 +1045,10 @@ void postTrans (TransInfo *t)
 {
        TransData *td;
        
-       if (t->draw_handle)
-       {
-               ED_region_draw_cb_exit(t->ar->type, t->draw_handle);
-       }
+       if (t->draw_handle_view)
+               ED_region_draw_cb_exit(t->ar->type, t->draw_handle_view);
+       if (t->draw_handle_pixel)
+               ED_region_draw_cb_exit(t->ar->type, t->draw_handle_pixel);
        
 
        if (t->customFree) {