Sculpt: Fast Navigate option for multires. This will show the lowest multires
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 25 Nov 2009 14:13:43 +0000 (14:13 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 25 Nov 2009 14:13:43 +0000 (14:13 +0000)
level when rotating/panning/zooming the viewport, and only draw the full thing
at the end, to make the viewport more interactive.

release/scripts/ui/space_view3d_toolbar.py
source/blender/blenkernel/BKE_DerivedMesh.h
source/blender/blenkernel/intern/cdderivedmesh.c
source/blender/blenkernel/intern/subsurf_ccg.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_edit.c
source/blender/editors/space_view3d/view3d_view.c
source/blender/makesdna/DNA_scene_types.h
source/blender/makesdna/DNA_view3d_types.h
source/blender/makesrna/intern/rna_sculpt_paint.c

index defeec0b8470659dc6defe04ef314f209b461674..5dcd0c655ef84b4df11d3814459b949548bcdd79 100644 (file)
@@ -671,6 +671,7 @@ class VIEW3D_PT_sculpt_options(PaintPanel):
 
         col = layout.column()
         col.itemR(sculpt, "show_brush")
+        col.itemR(sculpt, "fast_navigate")
 
         split = self.layout.split()
 
index 6bce7575556d72a27441715fe385b1fb6a7ce497..bb14ac7e8036ed5a97d8a5c9786f082db520861d 100644 (file)
@@ -232,7 +232,7 @@ struct DerivedMesh {
         * Also called for *final* editmode DerivedMeshes
         */
        void (*drawFacesSolid)(DerivedMesh *dm, float (*partial_redraw_planes)[4],
-                              int (*setMaterial)(int, void *attribs));
+                              int fast, int (*setMaterial)(int, void *attribs));
 
        /* Draw all faces
         *  o If useTwoSided, draw front and back using col arrays
index b3e75549028c29e92b2f6629a55405f663ed66f3..77ad9fb7a7b7da82d9b16581453150a1d33fd874 100644 (file)
@@ -395,7 +395,7 @@ static void cdDM_drawLooseEdges(DerivedMesh *dm)
 
 static void cdDM_drawFacesSolid(DerivedMesh *dm,
                                float (*partial_redraw_planes)[4],
-                               int (*setMaterial)(int, void *attribs))
+                               int fast, int (*setMaterial)(int, void *attribs))
 {
        CDDerivedMesh *cddm = (CDDerivedMesh*) dm;
        MVert *mvert = cddm->mvert;
index 30766931a0b2a6effa9e37c0df792983ffb07978..716229e6eadc7a93a657bbc01e804d6b26cf0d21 100644 (file)
@@ -1223,15 +1223,15 @@ static void ccgDM_glNormalFast(float *a, float *b, float *c, float *d)
 }
 
        /* Only used by non-editmesh types */
-static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)[4]/*, int fast*/, int (*setMaterial)(int, void *attribs)) {
+static void ccgDM_drawFacesSolid(DerivedMesh *dm, float (*partial_redraw_planes)[4], int fast, int (*setMaterial)(int, void *attribs)) {
        CCGDerivedMesh *ccgdm = (CCGDerivedMesh*) dm;
        CCGSubSurf *ss = ccgdm->ss;
        CCGFaceIterator *fi;
        int gridSize = ccgSubSurf_getGridSize(ss);
        char *faceFlags = ccgdm->faceFlags;
-       int step = 1; //(fast)? gridSize-1: 1;
+       int step = (fast)? gridSize-1: 1;
 
-       if(ccgdm->pbvh && ccgdm->multires.mmd) { // && !fast) {
+       if(ccgdm->pbvh && ccgdm->multires.mmd && !fast) {
                CCGFace **faces;
                int totface;
 
index 491559bf13d4e5d94107aba0d6a362998daef860..01af339e7f70b7b9cc9703b4dc25323eda009673 100644 (file)
@@ -2692,7 +2692,7 @@ static void draw_mesh_object_outline(View3D *v3d, Object *ob, DerivedMesh *dm)
                   drawFacesSolid() doesn't draw the transparent faces */
                if(ob->dtx & OB_DRAWTRANSP) {
                        glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); 
-                       dm->drawFacesSolid(dm, NULL, GPU_enable_material);
+                       dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material);
                        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
                        GPU_disable_material();
                }
@@ -2793,8 +2793,10 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                glFrontFace((ob->transflag&OB_NEG_SCALE)?GL_CW:GL_CCW);
 
                if(ob->sculpt) {
+                       Paint *p = paint_get_active(scene);
                        float planes[4][4];
                        float (*fpl)[4] = NULL;
+                       int fast= (p->flags & PAINT_FAST_NAVIGATE) && (rv3d->rflag & RV3D_NAVIGATING);
 
                        if(ob->sculpt->partial_redraw) {
                                sculpt_get_redraw_planes(planes, ar, rv3d, ob);
@@ -2802,10 +2804,10 @@ static void draw_mesh_fancy(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
                                ob->sculpt->partial_redraw = 0;
                        }
 
-                       dm->drawFacesSolid(dm, fpl, GPU_enable_material);
+                       dm->drawFacesSolid(dm, fpl, fast, GPU_enable_material);
                }
                else
-                       dm->drawFacesSolid(dm, NULL, GPU_enable_material);
+                       dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material);
 
                GPU_disable_material();
 
@@ -6270,7 +6272,7 @@ static void draw_object_mesh_instance(Scene *scene, View3D *v3d, RegionView3D *r
                glEnable(GL_LIGHTING);
                
                if(dm) {
-                       dm->drawFacesSolid(dm, NULL, GPU_enable_material);
+                       dm->drawFacesSolid(dm, NULL, 0, GPU_enable_material);
                        GPU_end_object_materials();
                }
                else if(edm)
index 937a662e274015f49dd5a1f802ea9eb572bad304..b0cbba9efc5ddfe2c210d9f508eafc9299f3774b 100644 (file)
@@ -275,7 +275,7 @@ static void calctrackballvec(rcti *rect, int mx, int my, float *vec)
 }
 
 
-static void viewops_data(bContext *C, wmOperator *op, wmEvent *event)
+static void viewops_data_create(bContext *C, wmOperator *op, wmEvent *event)
 {
        static float lastofs[3] = {0,0,0};
        View3D *v3d = CTX_wm_view3d(C);
@@ -314,6 +314,21 @@ static void viewops_data(bContext *C, wmOperator *op, wmEvent *event)
        if (rv3d->persmat[2][1] < 0.0f)
                vod->reverse= -1.0f;
 
+       rv3d->rflag |= RV3D_NAVIGATING;
+}
+
+static void viewops_data_free(bContext *C, wmOperator *op)
+{
+       Paint *p = paint_get_active(CTX_data_scene(C));
+       ViewOpsData *vod= op->customdata;
+
+       vod->rv3d->rflag &= ~RV3D_NAVIGATING;
+
+       if(p && (p->flags & PAINT_FAST_NAVIGATE))
+               ED_region_tag_redraw(vod->ar);
+
+       MEM_freeN(vod);
+       op->customdata= NULL;
 }
 
 /* ************************** viewrotate **********************************/
@@ -578,9 +593,7 @@ static int viewrotate_modal(bContext *C, wmOperator *op, wmEvent *event)
        }
        else if (event_code==VIEW_CONFIRM) {
                request_depth_update(CTX_wm_region_view3d(C));
-
-               MEM_freeN(vod);
-               op->customdata= NULL;
+               viewops_data_free(C, op);
 
                return OPERATOR_FINISHED;
        }
@@ -597,7 +610,7 @@ static int viewrotate_invoke(bContext *C, wmOperator *op, wmEvent *event)
                return OPERATOR_CANCELLED;
 
        /* makes op->customdata */
-       viewops_data(C, op, event);
+       viewops_data_create(C, op, event);
        vod= op->customdata;
 
        /* switch from camera view when: */
@@ -718,8 +731,7 @@ static int viewmove_modal(bContext *C, wmOperator *op, wmEvent *event)
        else if (event_code==VIEW_CONFIRM) {
                request_depth_update(CTX_wm_region_view3d(C));
 
-               MEM_freeN(vod);
-               op->customdata= NULL;
+               viewops_data_free(C, op);
 
                return OPERATOR_FINISHED;
        }
@@ -730,7 +742,7 @@ static int viewmove_modal(bContext *C, wmOperator *op, wmEvent *event)
 static int viewmove_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
        /* makes op->customdata */
-       viewops_data(C, op, event);
+       viewops_data_create(C, op, event);
 
        /* add temp handler */
        WM_event_add_modal_handler(C, op);
@@ -911,9 +923,7 @@ static int viewzoom_modal(bContext *C, wmOperator *op, wmEvent *event)
        }
        else if (event_code==VIEW_CONFIRM) {
                request_depth_update(CTX_wm_region_view3d(C));
-
-               MEM_freeN(vod);
-               op->customdata= NULL;
+               viewops_data_free(C, op);
 
                return OPERATOR_FINISHED;
        }
@@ -974,7 +984,7 @@ static int viewzoom_invoke(bContext *C, wmOperator *op, wmEvent *event)
        }
        else {
                /* makes op->customdata */
-               viewops_data(C, op, event);
+               viewops_data_create(C, op, event);
 
                /* add temp handler */
                WM_event_add_modal_handler(C, op);
index cf34cf742967594da5aad6e9cdb992669b095724..3ba2145e9d098ccefde6fbe97afe9a4990c48f15 100644 (file)
@@ -286,6 +286,8 @@ void smooth_view(bContext *C, Object *oldcamera, Object *camera, float *ofs, flo
                        
                        /* ensure it shows correct */
                        if(sms.to_camera) rv3d->persp= RV3D_PERSP;
+
+                       rv3d->rflag |= RV3D_NAVIGATING;
                        
                        /* keep track of running timer! */
                        if(rv3d->sms==NULL)
@@ -348,6 +350,7 @@ static int view3d_smoothview_invoke(bContext *C, wmOperator *op, wmEvent *event)
                
                WM_event_remove_timer(CTX_wm_manager(C), CTX_wm_window(C), rv3d->smooth_timer);
                rv3d->smooth_timer= NULL;
+               rv3d->rflag &= ~RV3D_NAVIGATING;
        }
        else {
                int i;
@@ -1885,7 +1888,7 @@ int initFlyInfo (bContext *C, FlyInfo *fly, wmOperator *op, wmEvent *event)
 
        fly->time_lastdraw= fly->time_lastwheel= PIL_check_seconds_timer();
 
-       fly->rv3d->rflag |= RV3D_FLYMODE; /* so we draw the corner margins */
+       fly->rv3d->rflag |= RV3D_FLYMODE|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;
@@ -1985,7 +1988,7 @@ static int flyEnd(bContext *C, FlyInfo *fly)
                /*Done with correcting for the dist */
        }
 
-       rv3d->rflag &= ~RV3D_FLYMODE;
+       rv3d->rflag &= ~(RV3D_FLYMODE|RV3D_NAVIGATING);
 //XXX2.5       BIF_view3d_previewrender_signal(fly->sa, PR_DBASE|PR_DISPRECT); /* not working at the moment not sure why */
 
 
index 037a8c46222f867d3b25869783e87e99988e8d96..bc592387a64c32a1de2f7331653b1a509955d2de 100644 (file)
@@ -1047,7 +1047,8 @@ typedef struct Scene {
 
 /* Paint.flags */
 typedef enum {
-       PAINT_SHOW_BRUSH = 1
+       PAINT_SHOW_BRUSH = 1,
+       PAINT_FAST_NAVIGATE = 2
 } PaintFlags;
 
 /* Sculpt.flags */
index 422c56fe4c1218fac0b367ccacedfd2fbaf06986..9c1f01f12b4a9694c1e6f65b93ed22720215af7e 100644 (file)
@@ -210,6 +210,7 @@ typedef struct View3D {
 /* RegionView3d->rflag */
 #define RV3D_FLYMODE                           2
 #define RV3D_CLIPPING                          4
+#define RV3D_NAVIGATING                                8
 
 /* RegionView3d->viewlock */
 #define RV3D_LOCKED                    1
index 89e295967466b5962ef8539b9d74d3b09da2c930..f365f053e7907672d6da5b9632f9173095b66afa 100644 (file)
@@ -174,6 +174,10 @@ static void rna_def_paint(BlenderRNA *brna)
        prop= RNA_def_property(srna, "show_brush", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flags", PAINT_SHOW_BRUSH);
        RNA_def_property_ui_text(prop, "Show Brush", "");
+
+       prop= RNA_def_property(srna, "fast_navigate", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "flags", PAINT_FAST_NAVIGATE);
+       RNA_def_property_ui_text(prop, "Fast Navigate", "For multires, show low resolution while navigating the view.");
 }
 
 static void rna_def_sculpt(BlenderRNA  *brna)