[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58172] branches/soc-2013-depsgraph_mt/ source/blender: Code cleanup: de-duplicate display list minmax routines

Sergey Sharybin sergey.vfx at gmail.com
Thu Jul 11 13:29:45 CEST 2013


Revision: 58172
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58172
Author:   nazgul
Date:     2013-07-11 11:29:45 +0000 (Thu, 11 Jul 2013)
Log Message:
-----------
Code cleanup: de-duplicate display list minmax routines

Modified Paths:
--------------
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_displist.h
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/displist.c
    branches/soc-2013-depsgraph_mt/source/blender/editors/curve/editcurve.c

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_displist.h
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_displist.h	2013-07-11 11:05:56 UTC (rev 58171)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/BKE_displist.h	2013-07-11 11:29:45 UTC (rev 58172)
@@ -28,6 +28,8 @@
 #ifndef __BKE_DISPLIST_H__
 #define __BKE_DISPLIST_H__
 
+struct ListBase;
+
 /** \file BKE_displist.h
  *  \ingroup bke
  *  \brief display list (or rather multi purpose list) stuff.
@@ -102,4 +104,6 @@
 /* add Orco layer to the displist object which has got derived mesh and return orco */
 float *BKE_displist_make_orco(struct Scene *scene, struct Object *ob, struct DerivedMesh *derivedFinal, int forRender, int renderResolution);
 
+void BKE_displist_minmax(struct ListBase *dispbase, float min[3], float max[3]);
+
 #endif

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/displist.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/displist.c	2013-07-11 11:05:56 UTC (rev 58171)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/displist.c	2013-07-11 11:29:45 UTC (rev 58172)
@@ -62,7 +62,6 @@
 
 #include "BLI_sys_types.h" // for intptr_t support
 
-static void boundbox_dispbase(BoundBox *bb, ListBase *dispbase);
 static void boundbox_displist_object(Object *ob);
 
 void BKE_displist_elem_free(DispList *dl)
@@ -1634,16 +1633,13 @@
 	return orco;
 }
 
-static void boundbox_dispbase(BoundBox *bb, ListBase *dispbase)
+void BKE_displist_minmax(ListBase *dispbase, float min[3], float max[3])
 {
-	float min[3], max[3];
 	DispList *dl;
 	float *vert;
 	int a, tot = 0;
 	int doit = 0;
 
-	INIT_MINMAX(min, max);
-
 	for (dl = dispbase->first; dl; dl = dl->next) {
 		tot = (dl->type == DL_INDEX3) ? dl->nr : dl->nr * dl->parts;
 		vert = dl->verts;
@@ -1658,8 +1654,6 @@
 		zero_v3(min);
 		zero_v3(max);
 	}
-
-	BKE_boundbox_init_from_minmax(bb, min, max);
 }
 
 /* this is confusing, there's also min_max_object, appplying the obmat... */
@@ -1678,7 +1672,11 @@
 			DM_set_object_boundbox(ob, ob->derivedFinal);
 		}
 		else {
-			boundbox_dispbase(ob->bb, &ob->curve_cache->disp);
+			float min[3], max[3];
+
+			INIT_MINMAX(min, max);
+			BKE_displist_minmax(&ob->curve_cache->disp, min, max);
+			BKE_boundbox_init_from_minmax(ob->bb, min, max);
 		}
 	}
 }

Modified: branches/soc-2013-depsgraph_mt/source/blender/editors/curve/editcurve.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/editors/curve/editcurve.c	2013-07-11 11:05:56 UTC (rev 58171)
+++ branches/soc-2013-depsgraph_mt/source/blender/editors/curve/editcurve.c	2013-07-11 11:29:45 UTC (rev 58172)
@@ -7160,9 +7160,7 @@
 	Scene *scene = CTX_data_scene(C);
 	Object *object = CTX_data_active_object(C);
 	Curve *curve = (Curve *) object->data;
-	DispList *dl;
 	float min[3], max[3], size[3], loc[3];
-	bool do_it = false;
 	int a;
 
 	if (ELEM(NULL, object->curve_cache, object->curve_cache->disp.first)) {
@@ -7170,29 +7168,8 @@
 	}
 
 	INIT_MINMAX(min, max);
+	BKE_displist_minmax(&object->curve_cache->disp, min, max);
 
-	dl = object->curve_cache->disp.first;
-	while (dl) {
-		int tot = ELEM(dl->type, DL_INDEX3, DL_INDEX4) ? dl->nr : dl->nr * dl->parts;
-		float *fp;
-
-		if (tot) {
-			do_it = true;
-		}
-
-		fp = dl->verts;
-		while (tot--) {
-			minmax_v3v3_v3(min, max, fp);
-			fp += 3;
-		}
-		dl = dl->next;
-	}
-
-	if (do_it == false) {
-		min[0] = min[1] = min[2] = -1.0f;
-		max[0] = max[1] = max[2] = 1.0f;
-	}
-
 	mid_v3_v3v3(loc, min, max);
 
 	size[0] = (max[0] - min[0]) / 2.0f;




More information about the Bf-blender-cvs mailing list