Sculpt: Fast Navigate option for multires. This will show the lowest multires

level when rotating/panning/zooming the viewport, and only draw the full thing
at the end, to make the viewport more interactive.
This commit is contained in:
Brecht Van Lommel 2009-11-25 14:13:43 +00:00
parent 2fd2c04381
commit 436969ce49
10 changed files with 46 additions and 24 deletions

@ -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()

@ -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

@ -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;

@ -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;

@ -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)

@ -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);

@ -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 */

@ -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 */

@ -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

@ -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)