[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59264] trunk/blender: Get rid of a display list stored in Curve datablock

Sergey Sharybin sergey.vfx at gmail.com
Mon Aug 19 11:13:16 CEST 2013


Revision: 59264
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59264
Author:   nazgul
Date:     2013-08-19 09:13:15 +0000 (Mon, 19 Aug 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 calculation.

Since we already do have bounding 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
bounding 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.

--
svn merge -r57939:57940 ^/branches/soc-2013-depsgraph_mt

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57939

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/curve.c
    trunk/blender/source/blender/blenkernel/intern/displist.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/makesdna/DNA_curve_types.h

Property Changed:
----------------
    trunk/blender/
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/space_outliner/


Property changes on: trunk/blender
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/ge_dev:58091-58422
/branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48679,48790,48792-48793,49076,49087,49292,49294,49466,49894,50052,50126,52854-52856,54573,58822,58989
/branches/soc-2013-depsgraph_mt:57516,57900,57939
/branches/soc-2013-dingto:57424,57487,57507,57525,57599,57670,57918-57919,57981,58091,58245,58253,58587,58772,58774-58775,58828,58835,59032
/tags/blender-2.67b-release/blender:57122
   + /branches/ge_dev:58091-58422
/branches/ge_harmony:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48679,48790,48792-48793,49076,49087,49292,49294,49466,49894,50052,50126,52854-52856,54573,58822,58989
/branches/soc-2013-depsgraph_mt:57516,57900,57939-57940
/branches/soc-2013-dingto:57424,57487,57507,57525,57599,57670,57918-57919,57981,58091,58245,58253,58587,58772,58774-58775,58828,58835,59032
/tags/blender-2.67b-release/blender:57122

Modified: trunk/blender/source/blender/blenkernel/intern/curve.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/curve.c	2013-08-19 09:07:09 UTC (rev 59263)
+++ trunk/blender/source/blender/blenkernel/intern/curve.c	2013-08-19 09:13:15 UTC (rev 59264)
@@ -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: trunk/blender/source/blender/blenkernel/intern/displist.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/displist.c	2013-08-19 09:07:09 UTC (rev 59263)
+++ trunk/blender/source/blender/blenkernel/intern/displist.c	2013-08-19 09:13:15 UTC (rev 59264)
@@ -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)
 {
@@ -727,9 +727,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)
@@ -1285,10 +1285,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);
@@ -1595,10 +1596,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);
@@ -1615,7 +1617,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.
@@ -1628,23 +1629,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,
@@ -1708,21 +1695,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: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2013-08-19 09:07:09 UTC (rev 59263)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2013-08-19 09:13:15 UTC (rev 59264)
@@ -3400,7 +3400,6 @@
 	}
 
 	cu->bev.first = cu->bev.last = NULL;
-	cu->disp.first = cu->disp.last = NULL;
 	cu->editnurb = NULL;
 	cu->lastsel = NULL;
 	cu->path = NULL;


Property changes on: trunk/blender/source/blender/editors/interface/interface.c
___________________________________________________________________
Modified: svn:mergeinfo
   - /branches/ge_candy/source/blender/editors/interface/interface.c:45070-46163
/branches/ge_harmony/source/blender/editors/interface/interface.c:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber/source/blender/editors/interface/interface.c:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato/source/blender/editors/interface/interface.c:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48679,48790,48792-48793,49076,49087,49292,49294,49466,49894,50052,50126,52854-52856,54573,58822,58989
/branches/soc-2013-depsgraph_mt/source/blender/editors/interface/interface.c:57516,57900,57939
   + /branches/ge_candy/source/blender/editors/interface/interface.c:45070-46163
/branches/ge_harmony/source/blender/editors/interface/interface.c:42255,42279-42282,42286,42302,42338,42349,42616,42620,42698-42699,42739,42753,42773-42774,42832,44568,44597-44598,44793-44794
/branches/soc-2011-cucumber/source/blender/editors/interface/interface.c:37517,38166-38167,38177,38179-38180,38187,38242,38384,38387,38403-38404,38407,38968,38970,38973,39045,40845,42997-42998,43439
/branches/soc-2011-tomato/source/blender/editors/interface/interface.c:42376,42378-42379,42383,42385,42395,42397-42400,42407,42411,42418,42443-42444,42446,42467,42472,42486,42650-42652,42654-42655,42709-42710,42733-42734,42801,43872,44130,44141,44147-44149,44151-44152,44229-44230,45623-45625,46037,48089,48092,48551-48552,48679,48790,48792-48793,49076,49087,49292,49294,49466,49894,50052,50126,52854-52856,54573,58822,58989
/branches/soc-2013-depsgraph_mt/source/blender/editors/interface/interface.c:57516,57900,57939-57940


Property changes on: trunk/blender/source/blender/editors/space_outliner
___________________________________________________________________
Modified: svn:mergeinfo

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list