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
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenkernel/intern/displist.c')
-rw-r--r--source/blender/blenkernel/intern/displist.c136
1 files changed, 82 insertions, 54 deletions
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 083cb02fd3d..e4d7814c4e1 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -63,6 +63,7 @@
#include "BLO_sys_types.h" // for intptr_t support
static void boundbox_displist(Object *ob);
+static void boundbox_dispbase(BoundBox *bb, ListBase *dispbase);
void BKE_displist_elem_free(DispList *dl)
{
@@ -121,17 +122,17 @@ DispList *BKE_displist_find(ListBase *lb, int type)
return NULL;
}
-int BKE_displist_has_faces(ListBase *lb)
+bool BKE_displist_has_faces(ListBase *lb)
{
DispList *dl;
for (dl = lb->first; dl; dl = dl->next) {
if (ELEM3(dl->type, DL_INDEX3, DL_INDEX4, DL_SURF)) {
- return TRUE;
+ return true;
}
}
- return FALSE;
+ return false;
}
void BKE_displist_copy(ListBase *lbn, ListBase *lb)
@@ -225,36 +226,55 @@ void BKE_displist_normals_add(ListBase *lb)
}
}
-void BKE_displist_count(ListBase *lb, int *totvert, int *totface)
+void BKE_displist_count(ListBase *lb, int *totvert, int *totface, int *tottri)
{
DispList *dl;
- dl = lb->first;
- while (dl) {
+ for (dl = lb->first; dl; dl = dl->next) {
+ int vert_tot = 0;
+ int face_tot = 0;
+ int tri_tot = 0;
+
switch (dl->type) {
case DL_SURF:
- *totvert += dl->nr * dl->parts;
- *totface += (dl->nr - 1) * (dl->parts - 1);
+ {
+ vert_tot = dl->nr * dl->parts;
+ face_tot = (dl->nr - 1) * (dl->parts - 1);
+ tri_tot = face_tot * 2;
break;
+ }
case DL_INDEX3:
+ {
+ vert_tot = dl->nr;
+ face_tot = dl->parts;
+ tri_tot = face_tot;
+ break;
+ }
case DL_INDEX4:
- *totvert += dl->nr;
- *totface += dl->parts;
+ {
+ vert_tot = dl->nr;
+ face_tot = dl->parts;
+ tri_tot = face_tot * 2;
break;
+ }
case DL_POLY:
case DL_SEGM:
- *totvert += dl->nr * dl->parts;
+ {
+ vert_tot = dl->nr * dl->parts;
break;
+ }
}
- dl = dl->next;
+ *totvert += vert_tot;
+ *totface += face_tot;
+ *tottri += tri_tot;
}
}
-int BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4)
+bool BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, int *p3, int *p4)
{
if ((dl->flag & DL_CYCL_V) == 0 && a == (dl->parts) - 1) {
- return 0;
+ return false;
}
if (dl->flag & DL_CYCL_U) {
@@ -277,7 +297,7 @@ int BKE_displist_surfindex_get(DispList *dl, int a, int *b, int *p1, int *p2, in
(*p4) -= dl->nr * dl->parts;
}
- return 1;
+ return true;
}
/* ****************** make displists ********************* */
@@ -290,10 +310,11 @@ static void curve_to_displist(Curve *cu, ListBase *nubase, ListBase *dispbase, i
BPoint *bp;
float *data;
int a, len, resolu;
+ const int editmode = (!forRender && (cu->editnurb || cu->editfont));
nu = nubase->first;
while (nu) {
- if (nu->hide == 0) {
+ if (nu->hide == 0 || editmode == 0) {
if (forRender && cu->resolu_ren != 0)
resolu = cu->resolu_ren;
else
@@ -486,8 +507,8 @@ void BKE_displist_fill(ListBase *dispbase, ListBase *to, int flipnormal)
dl = dl->next;
}
- /* XXX (obedit && obedit->actcol)?(obedit->actcol-1):0)) { */
- if (totvert && (tot = BLI_scanfill_calc(&sf_ctx, BLI_SCANFILL_CALC_REMOVE_DOUBLES))) {
+ /* XXX (obedit && obedit->actcol) ? (obedit->actcol-1) : 0)) { */
+ if (totvert && (tot = BLI_scanfill_calc(&sf_ctx, BLI_SCANFILL_CALC_REMOVE_DOUBLES | BLI_SCANFILL_CALC_HOLES))) {
if (tot) {
dlnew = MEM_callocN(sizeof(DispList), "filldisplist");
dlnew->type = DL_INDEX3;
@@ -738,7 +759,7 @@ static ModifierData *curve_get_tessellate_point(Scene *scene, Object *ob, int fo
/* this modifiers are moving point of tessellation automatically
* (some of them even can't be applied on tessellated curve), set flag
- * for incformation button in modifier's header
+ * for information button in modifier's header
*/
md->mode |= eModifierMode_ApplyOnSpline;
}
@@ -780,7 +801,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
required_mode |= eModifierMode_Editmode;
if (cu->editnurb == NULL) {
- keyVerts = do_ob_key(scene, ob);
+ keyVerts = BKE_key_evaluate_object(scene, ob, &numVerts);
if (keyVerts) {
/* split coords from key data, the latter also includes
@@ -789,7 +810,7 @@ static void curve_calc_modifiers_pre(Scene *scene, Object *ob, int forRender, fl
* shape key modifier yet. */
deformedVerts = BKE_curve_keyVertexCos_get(cu, nurb, keyVerts);
originalVerts = MEM_dupallocN(deformedVerts);
- numVerts = BKE_nurbList_verts_count(nurb);
+ BLI_assert(BKE_nurbList_verts_count(nurb) == numVerts);
}
}
@@ -956,7 +977,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
curve_to_filledpoly(cu, nurb, dispbase);
}
- dm = CDDM_from_curve_displist(ob, dispbase, NULL);
+ dm = CDDM_from_curve_displist(ob, dispbase);
CDDM_calc_normals_mapping(dm);
}
@@ -1046,7 +1067,7 @@ static DerivedMesh *create_orco_dm(Scene *scene, Object *ob)
/* OrcoDM should be created from underformed disp lists */
BKE_displist_make_curveTypes_forOrco(scene, ob, &disp);
- dm = CDDM_from_curve_displist(ob, &disp, NULL);
+ dm = CDDM_from_curve_displist(ob, &disp);
BKE_displist_free(&disp);
@@ -1466,8 +1487,7 @@ static void do_makeDispListCurveTypes(Scene *scene, Object *ob, ListBase *dispba
float *cur_data = data;
if (cu->taperobj == NULL) {
- if ( (cu->bevobj != NULL) || !((cu->flag & CU_FRONT) || (cu->flag & CU_BACK)) )
- fac = bevp->radius;
+ fac = bevp->radius;
}
else {
float len, taper_fac;
@@ -1579,15 +1599,15 @@ void BKE_displist_make_curveTypes(Scene *scene, Object *ob, int forOrco)
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);
-
- /* if there is no derivedMesh, object's boundbox is unneeded */
- if (ob->bb) {
- MEM_freeN(ob->bb);
- ob->bb = NULL;
- }
}
}
@@ -1623,42 +1643,50 @@ float *BKE_displist_make_orco(Scene *scene, Object *ob, DerivedMesh *derivedFina
return orco;
}
-/* this is confusing, there's also min_max_object, appplying the obmat... */
-static void boundbox_displist(Object *ob)
+static void boundbox_dispbase(BoundBox *bb, ListBase *dispbase)
{
- BoundBox *bb = NULL;
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;
+ for (a = 0; a < tot; a++, vert += 3) {
+ minmax_v3v3_v3(min, max, vert);
+ }
+ doit |= (tot != 0);
+ }
+
+ if (!doit) {
+ /* there's no geometry in displist, use zero-sized boundbox */
+ 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... */
+static void boundbox_displist(Object *ob)
+{
if (ELEM3(ob->type, OB_CURVE, OB_SURF, OB_FONT)) {
Curve *cu = ob->data;
- int doit = 0;
-
- if (cu->bb == NULL) cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox");
- bb = cu->bb;
- for (dl = ob->disp.first; dl; dl = dl->next) {
- tot = (dl->type == DL_INDEX3) ? dl->nr : dl->nr * dl->parts;
- vert = dl->verts;
- for (a = 0; a < tot; a++, vert += 3) {
- minmax_v3v3_v3(min, max, vert);
- }
- doit = (tot != 0);
- }
+ /* calculate curve's BB based on non-deformed displist */
+ if (cu->bb == NULL)
+ cu->bb = MEM_callocN(sizeof(BoundBox), "boundbox");
- if (!doit) {
- /* there's no geometry in displist, use zero-sized boundbox */
- zero_v3(min);
- zero_v3(max);
- }
+ 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");
- if (bb) {
- BKE_boundbox_init_from_minmax(bb, min, max);
+ boundbox_dispbase(ob->bb, &ob->disp);
}
}