[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [44514] trunk/blender/source/blender: code cleanup: make clipping enable/disable into functions ( was being done inline in drawobject.c)

Campbell Barton ideasman42 at gmail.com
Tue Feb 28 14:04:07 CET 2012


Revision: 44514
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=44514
Author:   campbellbarton
Date:     2012-02-28 13:03:56 +0000 (Tue, 28 Feb 2012)
Log Message:
-----------
code cleanup: make clipping enable/disable into functions (was being done inline in drawobject.c)

Modified Paths:
--------------
    trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c
    trunk/blender/source/blender/editors/include/ED_view3d.h
    trunk/blender/source/blender/editors/mesh/bmesh_select.c
    trunk/blender/source/blender/editors/mesh/knifetool.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/editors/space_view3d/drawobject.c
    trunk/blender/source/blender/editors/space_view3d/space_view3d.c
    trunk/blender/source/blender/editors/space_view3d/view3d_draw.c
    trunk/blender/source/blender/editors/space_view3d/view3d_edit.c
    trunk/blender/source/blender/editors/space_view3d/view3d_intern.h
    trunk/blender/source/blender/editors/space_view3d/view3d_view.c

Modified: trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c
===================================================================
--- trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c	2012-02-28 12:05:11 UTC (rev 44513)
+++ trunk/blender/source/blender/bmesh/intern/bmesh_opdefines.c	2012-02-28 13:03:56 UTC (rev 44514)
@@ -1024,7 +1024,7 @@
 	 {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 */},

Modified: trunk/blender/source/blender/editors/include/ED_view3d.h
===================================================================
--- trunk/blender/source/blender/editors/include/ED_view3d.h	2012-02-28 12:05:11 UTC (rev 44513)
+++ trunk/blender/source/blender/editors/include/ED_view3d.h	2012-02-28 13:03:56 UTC (rev 44514)
@@ -231,8 +231,12 @@
 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]);
 

Modified: trunk/blender/source/blender/editors/mesh/bmesh_select.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/bmesh_select.c	2012-02-28 12:05:11 UTC (rev 44513)
+++ trunk/blender/source/blender/editors/mesh/bmesh_select.c	2012-02-28 13:03:56 UTC (rev 44514)
@@ -476,7 +476,7 @@
 			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;
 			}

Modified: trunk/blender/source/blender/editors/mesh/knifetool.c
===================================================================
--- trunk/blender/source/blender/editors/mesh/knifetool.c	2012-02-28 12:05:11 UTC (rev 44513)
+++ trunk/blender/source/blender/editors/mesh/knifetool.c	2012-02-28 13:03:56 UTC (rev 44514)
@@ -1324,7 +1324,7 @@
 						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 @@
 					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 @@
 						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;
 						}

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2012-02-28 12:05:11 UTC (rev 44513)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2012-02-28 13:03:56 UTC (rev 44514)
@@ -862,7 +862,7 @@
 	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 @@
 						/* 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 @@
 												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 @@
 	/* ---- 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 */
 	

Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c	2012-02-28 12:05:11 UTC (rev 44513)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c	2012-02-28 13:03:56 UTC (rev 44514)
@@ -206,7 +206,7 @@
 /* ************* 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 @@
 	
 	/* 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 @@
 }
 
 /* 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 @@
 
 	/* 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 @@
 	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 @@
 			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 @@
 		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 @@
 		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 @@
 					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 @@
 		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 @@
 	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 @@
 		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 @@
 	data.clipVerts = clipVerts;
 
 	if (clipVerts != V3D_CLIP_TEST_OFF)

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list