Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2013-08-19 13:13:15 +0400
committerSergey Sharybin <sergey.vfx@gmail.com>2013-08-19 13:13:15 +0400
commit0312b183194e703d778e6b989caccdfa35059d13 (patch)
tree7760904b11743798783ec84092a9320607cc53fc /source
parent2acf0a13546ab0f12774174f18d373e163f0f19a (diff)
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
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/curve.c38
-rw-r--r--source/blender/blenkernel/intern/displist.c60
-rw-r--r--source/blender/blenloader/intern/readfile.c1
-rw-r--r--source/blender/makesdna/DNA_curve_types.h1
4 files changed, 31 insertions, 69 deletions
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c
index 801ed4f00a5..7377a48a87e 100644
--- a/source/blender/blenkernel/intern/curve.c
+++ b/source/blender/blenkernel/intern/curve.c
@@ -146,7 +146,6 @@ void BKE_curve_free(Curve *cu)
{
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 @@ Curve *BKE_curve_copy(Curve *cu)
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,36 +372,14 @@ void BKE_curve_type_test(Object *ob)
void BKE_curve_texspace_calc(Curve *cu)
{
- DispList *dl;
- BoundBox *bb;
- float *fp, min[3], max[3];
- int tot, do_it = FALSE;
-
- if (cu->bb == NULL)
- cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox");
- bb = cu->bb;
-
- 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;
- }
+ BoundBox *bb = cu->bb;
+ float min[3], max[3];
- BKE_boundbox_init_from_minmax(bb, min, max);
+ /* 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]);
if (cu->texflag & CU_AUTOSPACE) {
mid_v3_v3v3(cu->loc, min, max);
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index f728d06d88d..cfd89e91fdd 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -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 @@ void BKE_displist_make_mball(Scene *scene, Object *ob)
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 @@ void BKE_displist_make_surf(Scene *scene, Object *ob, ListBase *dispbase,
}
}
- /* 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 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
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 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
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 @@ void BKE_displist_make_curveTypes(Scene *scene, Object *ob, int forOrco)
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 @@ static void boundbox_dispbase(BoundBox *bb, ListBase *dispbase)
}
/* 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;
-
- /* 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);
+ /* Curver's BB is already calculated as a part of modifier stack,
+ * here we only calculate object BB based on final display list.
+ */
/* 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);
+ }
}
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 16dd4c9ebd8..96a6913e6e9 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3400,7 +3400,6 @@ static void direct_link_curve(FileData *fd, Curve *cu)
}
cu->bev.first = cu->bev.last = NULL;
- cu->disp.first = cu->disp.last = NULL;
cu->editnurb = NULL;
cu->lastsel = NULL;
cu->path = NULL;
diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h
index 7ff8667f90e..a66919329df 100644
--- a/source/blender/makesdna/DNA_curve_types.h
+++ b/source/blender/makesdna/DNA_curve_types.h
@@ -178,7 +178,6 @@ typedef struct Curve {
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 */