diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-02-28 17:03:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-02-28 17:03:56 +0400 |
commit | 9baab70aaf8cfb087ae756a6228c2a27c1d4a760 (patch) | |
tree | 9bbd509a990db9a937619cea014c693cbd5373f4 /source | |
parent | 95c14aa685522740eee03a9bdc2ee62b9414564f (diff) |
code cleanup: make clipping enable/disable into functions (was being done inline in drawobject.c)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/bmesh/intern/bmesh_opdefines.c | 2 | ||||
-rw-r--r-- | source/blender/editors/include/ED_view3d.h | 8 | ||||
-rw-r--r-- | source/blender/editors/mesh/bmesh_select.c | 2 | ||||
-rw-r--r-- | source/blender/editors/mesh/knifetool.c | 6 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_image.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 95 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_draw.c | 58 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_edit.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_intern.h | 2 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/view3d_view.c | 7 |
11 files changed, 106 insertions, 86 deletions
diff --git a/source/blender/bmesh/intern/bmesh_opdefines.c b/source/blender/bmesh/intern/bmesh_opdefines.c index e69d04fdf65..f6b066ca763 100644 --- a/source/blender/bmesh/intern/bmesh_opdefines.c +++ b/source/blender/bmesh/intern/bmesh_opdefines.c @@ -1024,7 +1024,7 @@ static BMOpDefine bmo_bevel_def = { {BMO_OP_SLOT_BOOL, "use_lengths"}, /* grab edge lengths from a PROP_FLT customdata laye */ {BMO_OP_SLOT_BOOL, "use_even"}, /* corner vert placement: use shell/angle calculations */ {BMO_OP_SLOT_BOOL, "use_dist"}, /* corner vert placement: evaluate percent as a distance, - * modifier uses this. We could do this as another float setting */ + * modifier uses this. We could do this as another float setting */ {BMO_OP_SLOT_INT, "lengthlayer"}, /* which PROP_FLT layer to us */ {BMO_OP_SLOT_FLT, "percent"}, /* percentage to expand bevelled edge */ {0} /* null-terminating sentine */}, diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 5627d3df91c..37eda55fc88 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -231,8 +231,12 @@ void mesh_foreachScreenFace(struct ViewContext *vc, void (*func)(void *userData, void nurbs_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct Nurb *nu, struct BPoint *bp, struct BezTriple *bezt, int beztindex, int x, int y), void *userData); void lattice_foreachScreenVert(struct ViewContext *vc, void (*func)(void *userData, struct BPoint *bp, int x, int y), void *userData); -void ED_view3d_local_clipping(struct RegionView3D *rv3d, float mat[][4]); -int ED_view3d_test_clipping(struct RegionView3D *rv3d, const float vec[3], const int local); +void ED_view3d_clipping_local(struct RegionView3D *rv3d, float mat[][4]); +int ED_view3d_clipping_test(struct RegionView3D *rv3d, const float vec[3], const int is_local); +void ED_view3d_clipping_set(struct RegionView3D *rv3d); +void ED_view3d_clipping_enable(void); +void ED_view3d_clipping_disable(void); + void ED_view3d_align_axis_to_vector(struct View3D *v3d, struct RegionView3D *rv3d, int axisidx, float vec[3]); float ED_view3d_pixel_size(struct RegionView3D *rv3d, const float co[3]); diff --git a/source/blender/editors/mesh/bmesh_select.c b/source/blender/editors/mesh/bmesh_select.c index 881027e7dc8..2fe177b71f1 100644 --- a/source/blender/editors/mesh/bmesh_select.c +++ b/source/blender/editors/mesh/bmesh_select.c @@ -476,7 +476,7 @@ static void findnearestedge__doClosest(void *userData, BMEdge *eed, int x0, int vec[2] = eed->v1->co[2] + labda * (eed->v2->co[2] - eed->v1->co[2]); mul_m4_v3(data->vc.obedit->obmat, vec); - if (ED_view3d_test_clipping(data->vc.rv3d, vec, 1) == 0) { + if (ED_view3d_clipping_test(data->vc.rv3d, vec, TRUE) == 0) { data->dist = distance; data->closest = eed; } diff --git a/source/blender/editors/mesh/knifetool.c b/source/blender/editors/mesh/knifetool.c index 3a9494f506d..fe1cc18086f 100644 --- a/source/blender/editors/mesh/knifetool.c +++ b/source/blender/editors/mesh/knifetool.c @@ -1324,7 +1324,7 @@ static int knife_sample_screen_density(knifetool_opdata *kcd, float radius) copy_v3_v3(vec, kfv->cageco); mul_m4_v3(kcd->vc.obedit->obmat, vec); - if (ED_view3d_test_clipping(kcd->vc.rv3d, vec, 1) == 0) { + if (ED_view3d_clipping_test(kcd->vc.rv3d, vec, TRUE) == 0) { c++; } } @@ -1398,7 +1398,7 @@ static KnifeEdge *knife_find_closest_edge(knifetool_opdata *kcd, float p[3], flo vec[2] = kfe->v1->cageco[2] + labda*(kfe->v2->cageco[2] - kfe->v1->cageco[2]); mul_m4_v3(kcd->vc.obedit->obmat, vec); - if (ED_view3d_test_clipping(kcd->vc.rv3d, vec, 1) == 0) { + if (ED_view3d_clipping_test(kcd->vc.rv3d, vec, TRUE) == 0) { cure = kfe; curdis = dis; } @@ -1483,7 +1483,7 @@ static KnifeVert *knife_find_closest_vert(knifetool_opdata *kcd, float p[3], flo copy_v3_v3(vec, kfv->cageco); mul_m4_v3(kcd->vc.obedit->obmat, vec); - if (ED_view3d_test_clipping(kcd->vc.rv3d, vec, 1) == 0) { + if (ED_view3d_clipping_test(kcd->vc.rv3d, vec, TRUE) == 0) { curv = kfv; curdis = dis; } diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index 84e3f317fdb..75e8c5860cd 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -862,7 +862,7 @@ static int project_paint_occlude_ptv_clip( if (side) interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w); else interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w); - if(!ED_view3d_test_clipping(ps->rv3d, wco, 1)) { + if (!ED_view3d_clipping_test(ps->rv3d, wco, TRUE)) { return 1; } @@ -2437,7 +2437,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i /* a pitty we need to get the worldspace pixel location here */ if(do_clip) { interp_v3_v3v3v3(wco, ps->dm_mvert[ (*(&mf->v1 + i1)) ].co, ps->dm_mvert[ (*(&mf->v1 + i2)) ].co, ps->dm_mvert[ (*(&mf->v1 + i3)) ].co, w); - if(ED_view3d_test_clipping(ps->rv3d, wco, 1)) { + if (ED_view3d_clipping_test(ps->rv3d, wco, TRUE)) { continue; /* Watch out that no code below this needs to run */ } } @@ -2660,7 +2660,7 @@ static void project_paint_face_init(const ProjPaintState *ps, const int thread_i if (side) interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v3].co, ps->dm_mvert[mf->v4].co, w); else interp_v3_v3v3v3(wco, ps->dm_mvert[mf->v1].co, ps->dm_mvert[mf->v2].co, ps->dm_mvert[mf->v3].co, w); - if(ED_view3d_test_clipping(ps->rv3d, wco, 1)) { + if (ED_view3d_clipping_test(ps->rv3d, wco, TRUE)) { continue; /* Watch out that no code below this needs to run */ } } @@ -2950,7 +2950,7 @@ static void project_paint_begin(ProjPaintState *ps) /* ---- end defines ---- */ if(ps->source==PROJ_SRC_VIEW) - ED_view3d_local_clipping(ps->rv3d, ps->ob->obmat); /* faster clipping lookups */ + ED_view3d_clipping_local(ps->rv3d, ps->ob->obmat); /* faster clipping lookups */ /* paint onto the derived mesh */ diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index de73acce7b4..98368acf714 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -206,7 +206,7 @@ static int check_ob_drawface_dot(Scene *sce, View3D *vd, char dt) /* ************* only use while object drawing ************** * or after running ED_view3d_init_mats_rv3d * */ -static void view3d_project_short_clip(ARegion *ar, const float vec[3], short adr[2], int local) +static void view3d_project_short_clip(ARegion *ar, const float vec[3], short adr[2], int is_local) { RegionView3D *rv3d= ar->regiondata; float fx, fy, vec4[4]; @@ -215,7 +215,7 @@ static void view3d_project_short_clip(ARegion *ar, const float vec[3], short adr /* clipplanes in eye space */ if (rv3d->rflag & RV3D_CLIPPING) { - if (ED_view3d_test_clipping(rv3d, vec, local)) + if (ED_view3d_clipping_test(rv3d, vec, is_local)) return; } @@ -271,7 +271,7 @@ static void UNUSED_FUNCTION(view3d_project_short_noclip)(ARegion *ar, const floa } /* same as view3d_project_short_clip but use persmat instead of persmatob for projection */ -static void view3d_project_short_clip_persmat(ARegion *ar, float *vec, short adr[2], int local) +static void view3d_project_short_clip_persmat(ARegion *ar, float *vec, short adr[2], int is_local) { RegionView3D *rv3d= ar->regiondata; float fx, fy, vec4[4]; @@ -280,7 +280,7 @@ static void view3d_project_short_clip_persmat(ARegion *ar, float *vec, short adr /* clipplanes in eye space */ if (rv3d->rflag & RV3D_CLIPPING) { - if (ED_view3d_test_clipping(rv3d, vec, local)) + if (ED_view3d_clipping_test(rv3d, vec, is_local)) return; } @@ -837,7 +837,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa RegionView3D *rv3d= ar->regiondata; ListBase *strings= &CachedText[CachedTextLevel-1]; ViewCachedString *vos; - int a, tot= 0; + int tot= 0; /* project first and test */ for (vos= strings->first; vos; vos= vos->next) { @@ -845,9 +845,9 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa mul_m4_v3(mat, vos->vec); if (vos->flag&V3D_CACHE_TEXT_GLOBALSPACE) - view3d_project_short_clip_persmat(ar, vos->vec, vos->sco, 0); + view3d_project_short_clip_persmat(ar, vos->vec, vos->sco, FALSE); else - view3d_project_short_clip(ar, vos->vec, vos->sco, 0); + view3d_project_short_clip(ar, vos->vec, vos->sco, FALSE); if (vos->sco[0]!=IS_CLIPPED) tot++; @@ -864,10 +864,10 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa if (v3d->zbuf) bgl_get_mats(&mats); #endif - if (rv3d->rflag & RV3D_CLIPPING) - for (a=0; a<6; a++) - glDisable(GL_CLIP_PLANE0+a); - + if (rv3d->rflag & RV3D_CLIPPING) { + ED_view3d_clipping_disable(); + } + glMatrixMode(GL_PROJECTION); glPushMatrix(); glMatrixMode(GL_MODELVIEW); @@ -877,7 +877,9 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa if (depth_write) { if (v3d->zbuf) glDisable(GL_DEPTH_TEST); } - else glDepthMask(0); + else { + glDepthMask(0); + } for (vos= strings->first; vos; vos= vos->next) { /* too slow, reading opengl info while drawing is very bad, @@ -898,6 +900,7 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa glColor3ubv(vos->col.ub); col_pack_prev= vos->col.pack; } + ((vos->flag & V3D_CACHE_TEXT_ASCII) ? BLF_draw_default_ascii : BLF_draw_default @@ -919,9 +922,9 @@ void view3d_cached_text_draw_end(View3D *v3d, ARegion *ar, int depth_write, floa glMatrixMode(GL_MODELVIEW); glPopMatrix(); - if (rv3d->rflag & RV3D_CLIPPING) - for (a=0; a<6; a++) - glEnable(GL_CLIP_PLANE0+a); + if (rv3d->rflag & RV3D_CLIPPING) { + ED_view3d_clipping_enable(); + } } if (strings->first) @@ -1915,11 +1918,11 @@ void lattice_foreachScreenVert(ViewContext *vc, void (*func)(void *userData, BPo int i, N = lt->editlatt->latt->pntsu*lt->editlatt->latt->pntsv*lt->editlatt->latt->pntsw; short s[2] = {IS_CLIPPED, 0}; - ED_view3d_local_clipping(vc->rv3d, obedit->obmat); /* for local clipping lookups */ + ED_view3d_clipping_local(vc->rv3d, obedit->obmat); /* for local clipping lookups */ for (i=0; i<N; i++, bp++, co+=3) { if (bp->hide==0) { - view3d_project_short_clip(vc->ar, dl?co:bp->vec, s, 1); + view3d_project_short_clip(vc->ar, dl?co:bp->vec, s, TRUE); if (s[0] != IS_CLIPPED) func(userData, bp, s[0], s[1]); } @@ -2025,7 +2028,7 @@ static void mesh_foreachScreenVert__mapFunc(void *userData, int index, float *co short s[2]= {IS_CLIPPED, 0}; if (data->clipVerts != V3D_CLIP_TEST_OFF) { - view3d_project_short_clip(data->vc.ar, co, s, 1); + view3d_project_short_clip(data->vc.ar, co, s, TRUE); } else { float co2[2]; @@ -2052,7 +2055,7 @@ void mesh_foreachScreenVert( data.clipVerts = clipVerts; if (clipVerts != V3D_CLIP_TEST_OFF) - ED_view3d_local_clipping(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ + ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ EDBM_init_index_arrays(vc->em, 1, 0, 0); dm->foreachMappedVert(dm, mesh_foreachScreenVert__mapFunc, &data); @@ -2104,8 +2107,8 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, float *v0 short s[2][2]; if (data->clipVerts == V3D_CLIP_TEST_RV3D_CLIPPING) { - view3d_project_short_clip(data->vc.ar, v0co, s[0], 1); - view3d_project_short_clip(data->vc.ar, v1co, s[1], 1); + view3d_project_short_clip(data->vc.ar, v0co, s[0], TRUE); + view3d_project_short_clip(data->vc.ar, v1co, s[1], TRUE); } else { float v1_co[3], v2_co[3]; @@ -2143,7 +2146,7 @@ void mesh_foreachScreenEdge( data.clipVerts = clipVerts; if (clipVerts != V3D_CLIP_TEST_OFF) - ED_view3d_local_clipping(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ + ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ EDBM_init_index_arrays(vc->em, 0, 1, 0); dm->foreachMappedEdge(dm, mesh_foreachScreenEdge__mapFunc, &data); @@ -2183,7 +2186,7 @@ void mesh_foreachScreenFace( data.userData = userData; //if (clipVerts) - ED_view3d_local_clipping(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ + ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ EDBM_init_index_arrays(vc->em, 0, 0, 1); dm->foreachMappedFaceCenter(dm, mesh_foreachScreenFace__mapFunc, &data); @@ -2203,7 +2206,7 @@ void nurbs_foreachScreenVert( int i; ListBase *nurbs= curve_editnurbs(cu); - ED_view3d_local_clipping(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ + ED_view3d_clipping_local(vc->rv3d, vc->obedit->obmat); /* for local clipping lookups */ for (nu= nurbs->first; nu; nu=nu->next) { if (nu->type == CU_BEZIER) { @@ -2213,18 +2216,18 @@ void nurbs_foreachScreenVert( if (bezt->hide==0) { if (cu->drawflag & CU_HIDE_HANDLES) { - view3d_project_short_clip(vc->ar, bezt->vec[1], s, 1); + view3d_project_short_clip(vc->ar, bezt->vec[1], s, TRUE); if (s[0] != IS_CLIPPED) func(userData, nu, NULL, bezt, 1, s[0], s[1]); } else { - view3d_project_short_clip(vc->ar, bezt->vec[0], s, 1); + view3d_project_short_clip(vc->ar, bezt->vec[0], s, TRUE); if (s[0] != IS_CLIPPED) func(userData, nu, NULL, bezt, 0, s[0], s[1]); - view3d_project_short_clip(vc->ar, bezt->vec[1], s, 1); + view3d_project_short_clip(vc->ar, bezt->vec[1], s, TRUE); if (s[0] != IS_CLIPPED) func(userData, nu, NULL, bezt, 1, s[0], s[1]); - view3d_project_short_clip(vc->ar, bezt->vec[2], s, 1); + view3d_project_short_clip(vc->ar, bezt->vec[2], s, TRUE); if (s[0] != IS_CLIPPED) func(userData, nu, NULL, bezt, 2, s[0], s[1]); } @@ -2236,7 +2239,7 @@ void nurbs_foreachScreenVert( BPoint *bp = &nu->bp[i]; if (bp->hide==0) { - view3d_project_short_clip(vc->ar, bp->vec, s, 1); + view3d_project_short_clip(vc->ar, bp->vec, s, TRUE); if (s[0] != IS_CLIPPED) func(userData, nu, bp, NULL, -1, s[0], s[1]); } @@ -2786,7 +2789,9 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS for (; eed; eed=BM_iter_step(&iter)) { /* draw selected edges, or edges next to selected verts while draging */ if (BM_elem_flag_test(eed, BM_ELEM_SELECT) || - (do_moving && (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || BM_elem_flag_test(eed->v2, BM_ELEM_SELECT) ))) { + (do_moving && (BM_elem_flag_test(eed->v1, BM_ELEM_SELECT) || + BM_elem_flag_test(eed->v2, BM_ELEM_SELECT)))) + { copy_v3_v3(v1, eed->v1->co); copy_v3_v3(v2, eed->v2->co); @@ -2818,9 +2823,9 @@ static void draw_em_measure_stats(View3D *v3d, Object *ob, BMEditMesh *em, UnitS int n; #define DRAW_EM_MEASURE_STATS_FACEAREA() \ - if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { \ + if (BM_elem_flag_test(f, BM_ELEM_SELECT)) { \ mul_v3_fl(vmid, 1.0/n); \ - if (unit->system) \ + if (unit->system) \ bUnit_AsString(numstr, sizeof(numstr), area*unit->scale_length, \ 3, unit->system, B_UNIT_LENGTH, do_split, FALSE); \ else \ @@ -4409,7 +4414,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv intensity = len_v3(pa->state.vel)/part->color_vec_max; break; case PART_DRAW_COL_ACC: - intensity = len_v3v3(pa->state.vel, pa->prev_state.vel)/((pa->state.time-pa->prev_state.time)*part->color_vec_max); + intensity = len_v3v3(pa->state.vel, pa->prev_state.vel) / ((pa->state.time - pa->prev_state.time) * part->color_vec_max); break; default: intensity= 1.0f; /* should never happen */ @@ -4541,7 +4546,9 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv } - if ((part->draw & PART_DRAW_NUM || part->draw & PART_DRAW_HEALTH) && (v3d->flag2 & V3D_RENDER_OVERRIDE)==0) { + if ((part->draw & PART_DRAW_NUM || part->draw & PART_DRAW_HEALTH) && + (v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) + { float vec_txt[3]; char *val_pos= numstr; numstr[0]= '\0'; @@ -6268,12 +6275,14 @@ static void draw_hooks(Object *ob) static void drawRBpivot(bRigidBodyJointConstraint *data) { + const char *axis_str[3] = {"px", "py", "pz"}; int axis; float mat[4][4]; /* color */ float curcol[4]; unsigned char tcol[4]; + glGetFloatv(GL_CURRENT_COLOR, curcol); rgb_float_to_uchar(tcol, curcol); tcol[3]= 255; @@ -6294,12 +6303,8 @@ static void drawRBpivot(bRigidBodyJointConstraint *data) glVertex3fv(&data->pivX); glVertex3fv(v); glEnd(); - if (axis==0) - view3d_cached_text_draw_add(v, "px", 0, V3D_CACHE_TEXT_ASCII, tcol); - else if (axis==1) - view3d_cached_text_draw_add(v, "py", 0, V3D_CACHE_TEXT_ASCII, tcol); - else - view3d_cached_text_draw_add(v, "pz", 0, V3D_CACHE_TEXT_ASCII, tcol); + + view3d_cached_text_draw_add(v, axis_str[axis], 0, V3D_CACHE_TEXT_ASCII, tcol); } glLineWidth (1.0f); setlinestyle(0); @@ -6451,7 +6456,9 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) if (is_obact && (ob->mode & (OB_MODE_VERTEX_PAINT|OB_MODE_WEIGHT_PAINT|OB_MODE_TEXTURE_PAINT))) { if (ob->type==OB_MESH) { - if (ob->mode & OB_MODE_EDIT); + if (ob->mode & OB_MODE_EDIT) { + /* pass */ + } else { if (dt<OB_SOLID) { zbufoff= 1; @@ -6588,11 +6595,13 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) } } else if (dt==OB_BOUNDBOX) { - if ((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE)==0) + if ((v3d->flag2 & V3D_RENDER_OVERRIDE && v3d->drawtype >= OB_WIRE) == 0) { draw_bounding_volume(scene, ob, ob->boundtype); + } } - else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) + else if (ED_view3d_boundbox_clip(rv3d, ob->obmat, ob->bb ? ob->bb : cu->bb)) { empty_object= drawDispList(scene, v3d, rv3d, base, dt); + } break; case OB_CURVE: diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 28fc4ff6d54..996d782be4d 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -226,7 +226,7 @@ void ED_view3d_init_mats_rv3d(struct Object *ob, struct RegionView3D *rv3d) mult_m4_m4m4(rv3d->persmatob, rv3d->persmat, ob->obmat); /* initializes object space clipping, speeds up clip tests */ - ED_view3d_local_clipping(rv3d, ob->obmat); + ED_view3d_clipping_local(rv3d, ob->obmat); } void ED_view3d_init_mats_rv3d_gl(struct Object *ob, struct RegionView3D *rv3d) diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index e304c6d75af..1fdffbed42c 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -170,30 +170,38 @@ static void view3d_draw_clipping(RegionView3D *rv3d) } } -void view3d_set_clipping(RegionView3D *rv3d) +void ED_view3d_clipping_set(RegionView3D *rv3d) { double plane[4]; - int a, tot=4; - - if (rv3d->viewlock) tot= 6; - - for (a=0; a<tot; a++) { + const unsigned int tot = (rv3d->viewlock) ? 4 : 6; + unsigned int a; + + for (a = 0; a < tot; a++) { QUATCOPY(plane, rv3d->clip[a]); - glClipPlane(GL_CLIP_PLANE0+a, plane); - glEnable(GL_CLIP_PLANE0+a); + glClipPlane(GL_CLIP_PLANE0 + a, plane); + glEnable(GL_CLIP_PLANE0 + a); } } -void view3d_clr_clipping(void) +/* use these to temp disable/enable clipping when 'rv3d->rflag & RV3D_CLIPPING' is set */ +void ED_view3d_clipping_disable(void) { - int a; - - for (a=0; a<6; a++) { - glDisable(GL_CLIP_PLANE0+a); + unsigned int a; + + for (a = 0; a < 6; a++) { + glDisable(GL_CLIP_PLANE0 + a); + } +} +void ED_view3d_clipping_enable(void) +{ + unsigned int a; + + for (a = 0; a < 6; a++) { + glEnable(GL_CLIP_PLANE0 + a); } } -static int test_clipping(const float vec[3], float clip[][4]) +static int view3d_clipping_test(const float vec[3], float clip[][4]) { float view[3]; copy_v3_v3(view, vec); @@ -207,11 +215,11 @@ static int test_clipping(const float vec[3], float clip[][4]) return 1; } -/* for 'local' ED_view3d_local_clipping must run first +/* for 'local' ED_view3d_clipping_local must run first * then all comparisons can be done in localspace */ -int ED_view3d_test_clipping(RegionView3D *rv3d, const float vec[3], const int local) +int ED_view3d_clipping_test(RegionView3D *rv3d, const float vec[3], const int is_local) { - return test_clipping(vec, local ? rv3d->clip_local : rv3d->clip); + return view3d_clipping_test(vec, is_local ? rv3d->clip_local : rv3d->clip); } /* ********* end custom clipping *********** */ @@ -1330,7 +1338,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) } if (rv3d->rflag & RV3D_CLIPPING) - view3d_set_clipping(rv3d); + ED_view3d_clipping_set(rv3d); G.f |= G_BACKBUFSEL; @@ -1348,7 +1356,7 @@ static void backdrawview3d(Scene *scene, ARegion *ar, View3D *v3d) glEnable(GL_MULTISAMPLE_ARB); if (rv3d->rflag & RV3D_CLIPPING) - view3d_clr_clipping(); + ED_view3d_clipping_disable(); /* it is important to end a view in a transform compatible with buttons */ // persp(PERSP_WIN); // set ortho @@ -2059,7 +2067,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *)) // persp(PERSP_STORE); // store correct view for persp(PERSP_VIEW) calls if (rv3d->rflag & RV3D_CLIPPING) { - view3d_set_clipping(rv3d); + ED_view3d_clipping_set(rv3d); } v3d->zbuf= TRUE; @@ -2151,7 +2159,7 @@ void draw_depth(Scene *scene, ARegion *ar, View3D *v3d, int (* func)(void *)) } if (rv3d->rflag & RV3D_CLIPPING) - view3d_clr_clipping(); + ED_view3d_clipping_disable(); v3d->zbuf = zbuf; if (!v3d->zbuf) glDisable(GL_DEPTH_TEST); @@ -2435,7 +2443,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, v3d->zbuf= FALSE; if (rv3d->rflag & RV3D_CLIPPING) - view3d_set_clipping(rv3d); + ED_view3d_clipping_set(rv3d); /* draw set first */ if (scene->set) { @@ -2473,7 +2481,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, if (v3d->afterdraw_xraytransp.first) view3d_draw_xraytransp(scene, ar, v3d, 1); if (rv3d->rflag & RV3D_CLIPPING) - view3d_clr_clipping(); + ED_view3d_clipping_disable(); /* cleanup */ if (v3d->zbuf) { @@ -2784,7 +2792,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const } if (rv3d->rflag & RV3D_CLIPPING) - view3d_set_clipping(rv3d); + ED_view3d_clipping_set(rv3d); /* draw set first */ if (scene->set) { @@ -2857,7 +2865,7 @@ static void view3d_main_area_draw_objects(const bContext *C, ARegion *ar, const ED_region_draw_cb_draw(C, ar, REGION_DRAW_POST_VIEW); if (rv3d->rflag & RV3D_CLIPPING) - view3d_clr_clipping(); + ED_view3d_clipping_disable(); BIF_draw_manipulator(C); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 785543e7ca2..8b224cea29d 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -3143,7 +3143,7 @@ static void calc_local_clipping(float clip_local[][4], BoundBox *clipbb, float m calc_clipping_plane(clip_local, &clipbb_local); } -void ED_view3d_local_clipping(RegionView3D *rv3d, float mat[][4]) +void ED_view3d_clipping_local(RegionView3D *rv3d, float mat[][4]) { if (rv3d->rflag & RV3D_CLIPPING) calc_local_clipping(rv3d->clip_local, rv3d->clipbb, mat); diff --git a/source/blender/editors/space_view3d/view3d_intern.h b/source/blender/editors/space_view3d/view3d_intern.h index 50dfc17af6f..16b7d5b0ebd 100644 --- a/source/blender/editors/space_view3d/view3d_intern.h +++ b/source/blender/editors/space_view3d/view3d_intern.h @@ -136,8 +136,6 @@ void draw_mesh_textured(Scene *scene, View3D *v3d, RegionView3D *rv3d, struct Ob void view3d_main_area_draw(const struct bContext *C, struct ARegion *ar); void draw_depth(Scene *scene, struct ARegion *ar, View3D *v3d, int (* func)(void *)); void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d); -void view3d_clr_clipping(void); -void view3d_set_clipping(RegionView3D *rv3d); void add_view3d_after(ListBase *lb, Base *base, int flag); void circf(float x, float y, float rad); diff --git a/source/blender/editors/space_view3d/view3d_view.c b/source/blender/editors/space_view3d/view3d_view.c index 74343163c39..9a7da7c177d 100644 --- a/source/blender/editors/space_view3d/view3d_view.c +++ b/source/blender/editors/space_view3d/view3d_view.c @@ -853,8 +853,9 @@ void project_short(ARegion *ar, const float vec[3], short adr[2]) /* clips */ adr[0]= IS_CLIPPED; if (rv3d->rflag & RV3D_CLIPPING) { - if (ED_view3d_test_clipping(rv3d, vec, 0)) + if (ED_view3d_clipping_test(rv3d, vec, FALSE)) { return; + } } copy_v3_v3(vec4, vec); @@ -1230,7 +1231,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b } if (vc->rv3d->rflag & RV3D_CLIPPING) - view3d_set_clipping(vc->rv3d); + ED_view3d_clipping_set(vc->rv3d); glSelectBuffer( bufsize, (GLuint *)buffer); glRenderMode(GL_SELECT); @@ -1309,7 +1310,7 @@ short view3d_opengl_select(ViewContext *vc, unsigned int *buffer, unsigned int b // XXX persp(PERSP_WIN); if (vc->rv3d->rflag & RV3D_CLIPPING) - view3d_clr_clipping(); + ED_view3d_clipping_disable(); if (hits<0) printf("Too many objects in select buffer\n"); // XXX make error message |