diff options
Diffstat (limited to 'source/blender/blenkernel/intern/mesh_convert.c')
-rw-r--r-- | source/blender/blenkernel/intern/mesh_convert.c | 124 |
1 files changed, 38 insertions, 86 deletions
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c index e777eb7ffe9..0e4fe91e577 100644 --- a/source/blender/blenkernel/intern/mesh_convert.c +++ b/source/blender/blenkernel/intern/mesh_convert.c @@ -212,54 +212,19 @@ static void make_edges_mdata_extend( } /* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */ -/* return non-zero on error */ -int BKE_mesh_nurbs_to_mdata(Object *ob, - MVert **r_allvert, - int *r_totvert, - MEdge **r_alledge, - int *r_totedge, - MLoop **r_allloop, - MPoly **r_allpoly, - int *r_totloop, - int *r_totpoly) -{ - ListBase disp = {NULL, NULL}; - - if (ob->runtime.curve_cache) { - disp = ob->runtime.curve_cache->disp; - } - - return BKE_mesh_nurbs_displist_to_mdata(ob, - &disp, - r_allvert, - r_totvert, - r_alledge, - r_totedge, - r_allloop, - r_allpoly, - NULL, - r_totloop, - r_totpoly); -} - -/* BMESH: this doesn't calculate all edges from polygons, - * only free standing edges are calculated */ - -/* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */ /* use specified dispbase */ -int BKE_mesh_nurbs_displist_to_mdata(const Object *ob, - const ListBase *dispbase, - MVert **r_allvert, - int *r_totvert, - MEdge **r_alledge, - int *r_totedge, - MLoop **r_allloop, - MPoly **r_allpoly, - MLoopUV **r_alluv, - int *r_totloop, - int *r_totpoly) +static int mesh_nurbs_displist_to_mdata(const Curve *cu, + const ListBase *dispbase, + MVert **r_allvert, + int *r_totvert, + MEdge **r_alledge, + int *r_totedge, + MLoop **r_allloop, + MPoly **r_allpoly, + MLoopUV **r_alluv, + int *r_totloop, + int *r_totpoly) { - const Curve *cu = ob->data; MVert *mvert; MPoly *mpoly; MLoop *mloop; @@ -272,7 +237,7 @@ int BKE_mesh_nurbs_displist_to_mdata(const Object *ob, /* 2d polys are filled with DL_INDEX3 displists */ (CU_DO_2DFILL(cu) == false) || /* surf polys are never filled */ - (ob->type == OB_SURF)); + BKE_curve_type_get(cu) == OB_SURF); /* count */ LISTBASE_FOREACH (const DispList *, dl, dispbase) { @@ -527,17 +492,17 @@ Mesh *BKE_mesh_new_nomain_from_curve_displist(const Object *ob, const ListBase * MLoopUV *alluv = NULL; int totvert, totedge, totloop, totpoly; - if (BKE_mesh_nurbs_displist_to_mdata(ob, - dispbase, - &allvert, - &totvert, - &alledge, - &totedge, - &allloop, - &allpoly, - &alluv, - &totloop, - &totpoly) != 0) { + if (mesh_nurbs_displist_to_mdata(ob->data, + dispbase, + &allvert, + &totvert, + &alledge, + &totedge, + &allloop, + &allpoly, + &alluv, + &totloop, + &totpoly) != 0) { /* Error initializing mdata. This often happens when curve is empty */ return BKE_mesh_new_nomain(0, 0, 0, 0, 0); } @@ -571,7 +536,7 @@ Mesh *BKE_mesh_new_nomain_from_curve_displist(const Object *ob, const ListBase * return mesh; } -Mesh *BKE_mesh_new_nomain_from_curve(Object *ob) +Mesh *BKE_mesh_new_nomain_from_curve(const Object *ob) { ListBase disp = {NULL, NULL}; @@ -589,7 +554,6 @@ void BKE_mesh_from_nurbs_displist( Object *ob1; Mesh *me_eval = (Mesh *)ob->runtime.data_eval; Mesh *me; - Curve *cu; MVert *allvert = NULL; MEdge *alledge = NULL; MLoop *allloop = NULL; @@ -597,20 +561,20 @@ void BKE_mesh_from_nurbs_displist( MPoly *allpoly = NULL; int totvert, totedge, totloop, totpoly; - cu = ob->data; + Curve *cu = ob->data; if (me_eval == NULL) { - if (BKE_mesh_nurbs_displist_to_mdata(ob, - dispbase, - &allvert, - &totvert, - &alledge, - &totedge, - &allloop, - &allpoly, - &alluv, - &totloop, - &totpoly) != 0) { + if (mesh_nurbs_displist_to_mdata(cu, + dispbase, + &allvert, + &totvert, + &alledge, + &totedge, + &allloop, + &allpoly, + &alluv, + &totloop, + &totpoly) != 0) { /* Error initializing */ return; } @@ -702,18 +666,6 @@ void BKE_mesh_from_nurbs_displist( } } -void BKE_mesh_from_nurbs(Main *bmain, Object *ob) -{ - Curve *cu = (Curve *)ob->data; - ListBase disp = {NULL, NULL}; - - if (ob->runtime.curve_cache) { - disp = ob->runtime.curve_cache->disp; - } - - BKE_mesh_from_nurbs_displist(bmain, ob, &disp, cu->id.name, false); -} - typedef struct EdgeLink { struct EdgeLink *next, *prev; void *edge; @@ -1152,8 +1104,8 @@ static Mesh *mesh_new_from_curve_type_object(Object *object) BKE_mesh_from_nurbs_displist( NULL, temp_object, &temp_object->runtime.curve_cache->disp, curve->id.name + 2, true); - /* BKE_mesh_from_nurbs changes the type to a mesh, check it worked. If it didn't the curve did - * not have any segments or otherwise would have generated an empty mesh. */ + /* BKE_mesh_from_nurbs_displist changes the type to a mesh, check it worked. If it didn't + * the curve did not have any segments or otherwise would have generated an empty mesh. */ if (temp_object->type != OB_MESH) { BKE_id_free(NULL, temp_object->data); BKE_id_free(NULL, temp_object); |