Fix #31021: Render settings are not taken into account for curves

Refactored code a bit to make naming a bit more clear and added a
function to create mesh from given display list rather than from
object's displist.

Tested using plain curves (which doesn't imply using derived meshes)
and curves with constructive modifiers (which are using derived meshed).
This commit is contained in:
Sergey Sharybin
2012-07-14 17:30:49 +00:00
parent f67ee4ff00
commit 8a9d1c0a79
6 changed files with 29 additions and 16 deletions
@@ -66,7 +66,7 @@ struct DerivedMesh *CDDM_from_curve(struct Object *ob);
/* creates a CDDerivedMesh from the given curve object and specified dispbase */
/* useful for OrcoDM creation for curves with constructive modifiers */
DerivedMesh *CDDM_from_curve_customDB(struct Object *ob, struct ListBase *dispbase);
DerivedMesh *CDDM_from_curve_displist(struct Object *ob, struct ListBase *dispbase);
/* Copies the given DerivedMesh with verts, faces & edges stored as
* custom element data.
+2 -1
View File
@@ -141,10 +141,11 @@ void BKE_mesh_from_metaball(struct ListBase *lb, struct Mesh *me);
int BKE_mesh_nurbs_to_mdata(struct Object *ob, struct MVert **allvert, int *totvert,
struct MEdge **alledge, int *totedge, struct MLoop **allloop, struct MPoly **allpoly,
int *totloop, int *totpoly);
int BKE_mesh_nurbs_to_mdata_customdb(struct Object *ob, struct ListBase *dispbase, struct MVert **allvert, int *_totvert,
int BKE_mesh_nurbs_displist_to_mdata(struct Object *ob, struct ListBase *dispbase, struct MVert **allvert, int *_totvert,
struct MEdge **alledge, int *_totedge, struct MLoop **allloop, struct MPoly **allpoly,
int *_totloop, int *_totpoly);
void BKE_mesh_from_nurbs(struct Object *ob);
void BKE_mesh_from_nurbs_displist(struct Object *ob, struct ListBase *dispbase);
void BKE_mesh_from_curve(struct Scene *scene, struct Object *ob);
void free_dverts(struct MDeformVert *dvert, int totvert);
void copy_dverts(struct MDeformVert *dst, struct MDeformVert *src, int totvert); /* __NLA */
@@ -1709,10 +1709,10 @@ DerivedMesh *CDDM_from_mesh(Mesh *mesh, Object *UNUSED(ob))
DerivedMesh *CDDM_from_curve(Object *ob)
{
return CDDM_from_curve_customDB(ob, &ob->disp);
return CDDM_from_curve_displist(ob, &ob->disp);
}
DerivedMesh *CDDM_from_curve_customDB(Object *ob, ListBase *dispbase)
DerivedMesh *CDDM_from_curve_displist(Object *ob, ListBase *dispbase)
{
DerivedMesh *dm;
CDDerivedMesh *cddm;
@@ -1722,7 +1722,7 @@ DerivedMesh *CDDM_from_curve_customDB(Object *ob, ListBase *dispbase)
MPoly *allpoly;
int totvert, totedge, totloop, totpoly;
if (BKE_mesh_nurbs_to_mdata_customdb(ob, dispbase, &allvert, &totvert, &alledge,
if (BKE_mesh_nurbs_displist_to_mdata(ob, dispbase, &allvert, &totvert, &alledge,
&totedge, &allloop, &allpoly, &totloop, &totpoly) != 0)
{
/* Error initializing mdata. This often happens when curve is empty */
+2 -2
View File
@@ -948,7 +948,7 @@ static void curve_calc_modifiers_post(Scene *scene, Object *ob, ListBase *dispba
curve_to_filledpoly(cu, nurb, dispbase);
}
dm = CDDM_from_curve_customDB(ob, dispbase);
dm = CDDM_from_curve_displist(ob, dispbase);
CDDM_calc_normals_mapping(dm);
}
@@ -1038,7 +1038,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_customDB(ob, &disp);
dm = CDDM_from_curve_displist(ob, &disp);
BKE_displist_free(&disp);
+11 -6
View File
@@ -1230,7 +1230,7 @@ int BKE_mesh_nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert,
MEdge **alledge, int *totedge, MLoop **allloop, MPoly **allpoly,
int *totloop, int *totpoly)
{
return BKE_mesh_nurbs_to_mdata_customdb(ob, &ob->disp,
return BKE_mesh_nurbs_displist_to_mdata(ob, &ob->disp,
allvert, totvert,
alledge, totedge,
allloop, allpoly,
@@ -1242,7 +1242,7 @@ int BKE_mesh_nurbs_to_mdata(Object *ob, MVert **allvert, int *totvert,
/* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */
/* use specified dispbase */
int BKE_mesh_nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase,
int BKE_mesh_nurbs_displist_to_mdata(Object *ob, ListBase *dispbase,
MVert **allvert, int *_totvert,
MEdge **alledge, int *_totedge,
MLoop **allloop, MPoly **allpoly,
@@ -1462,7 +1462,7 @@ int BKE_mesh_nurbs_to_mdata_customdb(Object *ob, ListBase *dispbase,
}
/* this may fail replacing ob->data, be sure to check ob->type */
void BKE_mesh_from_nurbs(Object *ob)
void BKE_mesh_from_nurbs_displist(Object *ob, ListBase *dispbase)
{
Main *bmain = G.main;
Object *ob1;
@@ -1478,9 +1478,9 @@ void BKE_mesh_from_nurbs(Object *ob)
cu = ob->data;
if (dm == NULL) {
if (BKE_mesh_nurbs_to_mdata(ob, &allvert, &totvert,
&alledge, &totedge, &allloop,
&allpoly, &totloop, &totpoly) != 0)
if (BKE_mesh_nurbs_displist_to_mdata(ob, dispbase, &allvert, &totvert,
&alledge, &totedge, &allloop,
&allpoly, &totloop, &totpoly) != 0)
{
/* Error initializing */
return;
@@ -1534,6 +1534,11 @@ void BKE_mesh_from_nurbs(Object *ob)
}
}
void BKE_mesh_from_nurbs(Object *ob)
{
return BKE_mesh_from_nurbs_displist(ob, &ob->disp);
}
typedef struct EdgeLink {
Link *next, *prev;
void *edge;
@@ -84,7 +84,9 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_
switch (ob->type) {
case OB_FONT:
case OB_CURVE:
case OB_SURF:
case OB_SURF: {
ListBase dispbase = {NULL, NULL};
DerivedMesh *derivedFinal = NULL;
/* copies object and modifiers (but not the data) */
tmpobj = BKE_object_copy(ob);
@@ -105,12 +107,16 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_
copycu->editnurb = tmpcu->editnurb;
/* get updated display list, and convert to a mesh */
BKE_displist_make_curveTypes(sce, tmpobj, 0);
BKE_displist_make_curveTypes_forRender(sce, tmpobj, &dispbase, &derivedFinal, FALSE);
copycu->editfont = NULL;
copycu->editnurb = NULL;
BKE_mesh_from_nurbs(tmpobj);
tmpobj->derivedFinal = derivedFinal;
BKE_mesh_from_nurbs_displist(tmpobj, &dispbase);
BKE_displist_free(&dispbase);
/* BKE_mesh_from_nurbs changes the type to a mesh, check it worked */
if (tmpobj->type != OB_MESH) {
@@ -121,6 +127,7 @@ Mesh *rna_Object_to_mesh(Object *ob, ReportList *reports, Scene *sce, int apply_
tmpmesh = tmpobj->data;
BKE_libblock_free_us(&G.main->object, tmpobj);
break;
}
case OB_MBALL: {
/* metaballs don't have modifiers, so just convert to mesh */