[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52209] trunk/blender/source/blender/ editors/space_view3d/drawobject.c: avoid using goto's in previous commit

Campbell Barton ideasman42 at gmail.com
Wed Nov 14 16:06:32 CET 2012


Revision: 52209
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52209
Author:   campbellbarton
Date:     2012-11-14 15:06:32 +0000 (Wed, 14 Nov 2012)
Log Message:
-----------
avoid using goto's in previous commit

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_view3d/drawobject.c

Modified: trunk/blender/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- trunk/blender/source/blender/editors/space_view3d/drawobject.c	2012-11-14 14:47:45 UTC (rev 52208)
+++ trunk/blender/source/blender/editors/space_view3d/drawobject.c	2012-11-14 15:06:32 UTC (rev 52209)
@@ -3600,9 +3600,12 @@
 	return 0;
 }
 
-/* returns 1 when nothing was drawn */
-static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
-                        const short dt, const short dflag, const unsigned char ob_wire_col[4])
+/**
+ * Only called by #drawDispList
+ * \return 1 when nothing was drawn
+ */
+static int drawDispList_nobackface(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
+                                   const short dt, const short dflag, const unsigned char ob_wire_col[4])
 {
 	Object *ob = base->object;
 	ListBase *lb = NULL;
@@ -3610,17 +3613,9 @@
 	Curve *cu;
 	const short render_only = (v3d->flag2 & V3D_RENDER_OVERRIDE);
 	const short solid = (dt > OB_WIRE);
-	int retval = 0;
 
-	/* backface culling */
-	if (v3d->flag2 & V3D_BACKFACE_CULLING) {
-		/* not all displists use same in/out normal direction convention */
-		glEnable(GL_CULL_FACE);
-		glCullFace((ob->type == OB_MBALL) ? GL_BACK : GL_FRONT);
-	}
-
 	if (drawCurveDerivedMesh(scene, v3d, rv3d, base, dt) == 0) {
-		goto quit;
+		return FALSE;
 	}
 
 	switch (ob->type) {
@@ -3633,8 +3628,7 @@
 			if (solid) {
 				dl = lb->first;
 				if (dl == NULL) {
-					retval = 1;
-					goto quit;
+					return TRUE;
 				}
 
 				if (dl->nors == NULL) BKE_displist_normals_add(lb);
@@ -3669,9 +3663,11 @@
 			}
 			else {
 				if (!render_only || (render_only && BKE_displist_has_faces(lb))) {
+					int retval;
 					draw_index_wire = 0;
 					retval = drawDispListwire(lb);
 					draw_index_wire = 1;
+					return retval;
 				}
 			}
 			break;
@@ -3682,8 +3678,7 @@
 			if (solid) {
 				dl = lb->first;
 				if (dl == NULL) {
-					retval = 1;
-					goto quit;
+					return TRUE;
 				}
 
 				if (dl->nors == NULL) BKE_displist_normals_add(lb);
@@ -3700,7 +3695,7 @@
 				}
 			}
 			else {
-				retval = drawDispListwire(lb);
+				return drawDispListwire(lb);
 			}
 			break;
 		case OB_MBALL:
@@ -3709,8 +3704,7 @@
 				lb = &ob->disp;
 				if (lb->first == NULL) BKE_displist_make_mball(scene, ob);
 				if (lb->first == NULL) {
-					retval = 1;
-					goto quit;
+					return TRUE;
 				}
 
 				if (solid) {
@@ -3728,15 +3722,31 @@
 				}
 				else {
 					/* MetaBalls use DL_INDEX4 type of DispList */
-					retval = drawDispListwire(lb);
+					return drawDispListwire(lb);
 				}
 			}
 			break;
 	}
-	
-quit:
-	if (v3d->flag2 & V3D_BACKFACE_CULLING)
+
+	return FALSE;
+}
+static int drawDispList(Scene *scene, View3D *v3d, RegionView3D *rv3d, Base *base,
+                        const short dt, const short dflag, const unsigned char ob_wire_col[4])
+{
+	int retval;
+
+	/* backface culling */
+	if (v3d->flag2 & V3D_BACKFACE_CULLING) {
+		/* not all displists use same in/out normal direction convention */
+		glEnable(GL_CULL_FACE);
+		glCullFace((base->object->type == OB_MBALL) ? GL_BACK : GL_FRONT);
+	}
+
+	retval = drawDispList_nobackface(scene, v3d, rv3d, base, dt, dflag, ob_wire_col);
+
+	if (v3d->flag2 & V3D_BACKFACE_CULLING) {
 		glDisable(GL_CULL_FACE);
+	}
 
 	return retval;
 }




More information about the Bf-blender-cvs mailing list