[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57940] branches/soc-2013-depsgraph_mt/ source/blender: Get rid of a display list stored in Curve datablock

Sergey Sharybin sergey.vfx at gmail.com
Tue Jul 2 21:22:59 CEST 2013


Revision: 57940
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57940
Author:   nazgul
Date:     2013-07-02 19:22:59 +0000 (Tue, 02 Jul 2013)
Log Message:
-----------
Get rid of a display list stored in Curve datablock

This display list was only used for texture space calculation,
and even there this display list was only used for bounding
box calulation.

Since we alreayd do have boundgind box in a curve datablock
there's no reason to duplicate non-modified display list
just to calculate bounding box later, let's just calculate
boundding box at the first point.

This makes code a little be more thread-safe but curves are
still not safe for threads at all because of bevel list and
path. That would be solved later.

Modified Paths:
--------------
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/curve.c
    branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/displist.c
    branches/soc-2013-depsgraph_mt/source/blender/blenloader/intern/readfile.c
    branches/soc-2013-depsgraph_mt/source/blender/makesdna/DNA_curve_types.h

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/curve.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/curve.c	2013-07-02 19:22:55 UTC (rev 57939)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/curve.c	2013-07-02 19:22:59 UTC (rev 57940)
@@ -146,7 +146,6 @@
 {
 	BKE_nurbList_free(&cu->nurb);
 	BLI_freelistN(&cu->bev);
-	BKE_displist_free(&cu->disp);
 	BKE_curve_editfont_free(cu);
 
 	BKE_curve_editNurb_free(cu);
@@ -228,7 +227,6 @@
 	cun->key = BKE_key_copy(cu->key);
 	if (cun->key) cun->key->from = (ID *)cun;
 
-	cun->disp.first = cun->disp.last = NULL;
 	cun->bev.first = cun->bev.last = NULL;
 	cun->path = NULL;
 
@@ -374,37 +372,15 @@
 
 void BKE_curve_texspace_calc(Curve *cu)
 {
-	DispList *dl;
-	BoundBox *bb;
-	float *fp, min[3], max[3];
-	int tot, do_it = FALSE;
+	BoundBox *bb = cu->bb;
+	float min[3], max[3];
 
-	if (cu->bb == NULL)
-		cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox");
-	bb = cu->bb;
+	/* Curve's undeformed bounding box is calculated in displist.c,
+	 * as a part of display list calculation.
+	 */
+	copy_v3_v3(min, bb->vec[0]);
+	copy_v3_v3(max, bb->vec[6]);
 
-	INIT_MINMAX(min, max);
-
-	dl = cu->disp.first;
-	while (dl) {
-		tot = ELEM(dl->type, DL_INDEX3, DL_INDEX4) ? dl->nr : dl->nr * dl->parts;
-
-		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;
-	}
-
-	BKE_boundbox_init_from_minmax(bb, min, max);
-
 	if (cu->texflag & CU_AUTOSPACE) {
 		mid_v3_v3v3(cu->loc, min, max);
 		cu->size[0] = (max[0] - min[0]) / 2.0f;

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-02 19:22:55 UTC (rev 57939)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenkernel/intern/displist.c	2013-07-02 19:22:59 UTC (rev 57940)
@@ -62,8 +62,8 @@
 
 #include "BLI_sys_types.h" // for intptr_t support
 
-static void boundbox_displist(Object *ob);
 static void boundbox_dispbase(BoundBox *bb, ListBase *dispbase);
+static void boundbox_displist_object(Object *ob);
 
 void BKE_displist_elem_free(DispList *dl)
 {
@@ -721,9 +721,9 @@
 
 			object_deform_mball(ob, &ob->disp);
 		}
-	}
 
-	boundbox_displist(ob);
+		boundbox_displist_object(ob);
+	}
 }
 
 void BKE_displist_make_mball_forRender(Scene *scene, Object *ob, ListBase *dispbase)
@@ -1279,10 +1279,11 @@
 		}
 	}
 
-	/* make copy of 'undeformed" displist for texture space calculation
-	 * actually, it's not totally undeformed -- pre-tessellation modifiers are
-	 * already applied, thats how it worked for years, so keep for compatibility (sergey) */
-	BKE_displist_copy(&cu->disp, dispbase);
+	/* Calculate curve's boundig box from non-modified display list. */
+	if (cu->bb == NULL) {
+		cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox");
+	}
+	boundbox_dispbase(cu->bb, dispbase);
 
 	if (!forRender) {
 		BKE_curve_texspace_calc(cu);
@@ -1589,10 +1590,11 @@
 		if ((cu->flag & CU_PATH) && !forOrco)
 			calc_curvepath(ob);
 
-		/* make copy of 'undeformed" displist for texture space calculation
-		 * actually, it's not totally undeformed -- pre-tessellation modifiers are
-		 * already applied, thats how it worked for years, so keep for compatibility (sergey) */
-		BKE_displist_copy(&cu->disp, dispbase);
+		/* Calculate curve's boundig box from non-modified display list. */
+		if (cu->bb == NULL) {
+			cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox");
+		}
+		boundbox_dispbase(cu->bb, dispbase);
 
 		if (!forRender) {
 			BKE_curve_texspace_calc(cu);
@@ -1609,7 +1611,6 @@
 
 void BKE_displist_make_curveTypes(Scene *scene, Object *ob, int forOrco)
 {
-	Curve *cu = ob->data;
 	ListBase *dispbase;
 
 	/* The same check for duplis as in do_makeDispListCurveTypes.
@@ -1622,23 +1623,9 @@
 	dispbase = &(ob->disp);
 	BKE_displist_free(dispbase);
 
-	/* free displist used for textspace */
-	BKE_displist_free(&cu->disp);
-
 	do_makeDispListCurveTypes(scene, ob, dispbase, &ob->derivedFinal, 0, forOrco, 0);
 
-	if (ob->derivedFinal) {
-		DM_set_object_boundbox(ob, ob->derivedFinal);
-
-		/* always keep curve's  BB in sync with non-deformed displist */
-		if (cu->bb == NULL)
-			cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox");
-
-		boundbox_dispbase(cu->bb, &cu->disp);
-	}
-	else {
-		boundbox_displist(ob);
-	}
+	boundbox_displist_object(ob);
 }
 
 void BKE_displist_make_curveTypes_forRender(Scene *scene, Object *ob, ListBase *dispbase,
@@ -1702,21 +1689,22 @@
 }
 
 /* this is confusing, there's also min_max_object, appplying the obmat... */
-static void boundbox_displist(Object *ob)
+static void boundbox_displist_object(Object *ob)
 {
 	if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
-		Curve *cu = ob->data;
+		/* Curver's BB is already calculated as a part of modifier stack,
+		 * here we only calculate object BB based on final display list.
+		 */
 
-		/* calculate curve's BB based on non-deformed displist */
-		if (cu->bb == NULL)
-			cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox");
-
-		boundbox_dispbase(cu->bb, &cu->disp);
-
 		/* object's BB is calculated from final displist */
 		if (ob->bb == NULL)
 			ob->bb = MEM_callocN(sizeof(BoundBox), "boundbox");
 
-		boundbox_dispbase(ob->bb, &ob->disp);
+		if (ob->derivedFinal) {
+			DM_set_object_boundbox(ob, ob->derivedFinal);
+		}
+		else {
+			boundbox_dispbase(ob->bb, &ob->disp);
+		}
 	}
 }

Modified: branches/soc-2013-depsgraph_mt/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/blenloader/intern/readfile.c	2013-07-02 19:22:55 UTC (rev 57939)
+++ branches/soc-2013-depsgraph_mt/source/blender/blenloader/intern/readfile.c	2013-07-02 19:22:59 UTC (rev 57940)
@@ -3392,7 +3392,6 @@
 	}
 
 	cu->bev.first = cu->bev.last = NULL;
-	cu->disp.first = cu->disp.last = NULL;
 	cu->editnurb = NULL;
 	cu->lastsel = NULL;
 	cu->path = NULL;

Modified: branches/soc-2013-depsgraph_mt/source/blender/makesdna/DNA_curve_types.h
===================================================================
--- branches/soc-2013-depsgraph_mt/source/blender/makesdna/DNA_curve_types.h	2013-07-02 19:22:55 UTC (rev 57939)
+++ branches/soc-2013-depsgraph_mt/source/blender/makesdna/DNA_curve_types.h	2013-07-02 19:22:59 UTC (rev 57940)
@@ -177,7 +177,6 @@
 	struct BoundBox *bb;
 	
 	ListBase nurb;		/* actual data, called splines in rna */
-	ListBase disp;		/* undeformed display list, used mostly for texture space calculation */
 	
 	EditNurb *editnurb;	/* edited data, not in file, use pointer so we can check for it */
 	




More information about the Bf-blender-cvs mailing list