diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-03-14 22:44:32 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-03-14 22:44:32 +0400 |
commit | 7626101dc9749a3c6066a0f51720d9953b8b3c69 (patch) | |
tree | ff1da292d033004900bc03ce7b7bcdfc11549ee2 /source/blender | |
parent | a0dbd88311ae85c6713a91a6dca97eee6e90db9d (diff) |
split up BKE_mesh_to_curve() into 2 functions, adding BKE_mesh_to_curve_ex() which doesn't do object type conversion.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/BKE_mesh.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 28 |
2 files changed, 20 insertions, 9 deletions
diff --git a/source/blender/blenkernel/BKE_mesh.h b/source/blender/blenkernel/BKE_mesh.h index c90ea90f09d..9b43d0f1471 100644 --- a/source/blender/blenkernel/BKE_mesh.h +++ b/source/blender/blenkernel/BKE_mesh.h @@ -169,6 +169,7 @@ int BKE_mesh_nurbs_displist_to_mdata(struct Object *ob, struct ListBase *dispbas struct MLoopUV **alluv, int *_totloop, int *_totpoly); void BKE_mesh_from_nurbs_displist(struct Object *ob, struct ListBase *dispbase, int use_orco_uv); void BKE_mesh_from_nurbs(struct Object *ob); +void BKE_mesh_to_curve_ex(struct DerivedMesh *dm, struct ListBase *nurblist); void BKE_mesh_to_curve(struct Scene *scene, struct Object *ob); void BKE_mesh_delete_material_index(struct Mesh *me, short index); void BKE_mesh_smooth_flag_set(struct Object *meshOb, int enableSmooth); diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index 604a273efc5..1b2af2fb501 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -1586,11 +1586,8 @@ static void appendPolyLineVert(ListBase *lb, unsigned int index) BLI_addtail(lb, vl); } -void BKE_mesh_to_curve(Scene *scene, Object *ob) +void BKE_mesh_to_curve_ex(DerivedMesh *dm, ListBase *nurblist) { - /* make new mesh data from the original copy */ - DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_MESH); - MVert *mverts = dm->getVertArray(dm); MEdge *med, *medge = dm->getEdgeArray(dm); MPoly *mp, *mpoly = dm->getPolyArray(dm); @@ -1600,7 +1597,6 @@ void BKE_mesh_to_curve(Scene *scene, Object *ob) int totpoly = dm->getNumPolys(dm); int totedges = 0; int i; - bool needsFree = false; /* only to detect edge polylines */ int *edge_users; @@ -1632,9 +1628,6 @@ void BKE_mesh_to_curve(Scene *scene, Object *ob) MEM_freeN(edge_users); if (edges.first) { - Curve *cu = BKE_curve_add(G.main, ob->id.name + 2, OB_CURVE); - cu->flag |= CU_3D; - while (edges.first) { /* each iteration find a polyline and add this as a nurbs poly spline */ @@ -1721,10 +1714,27 @@ void BKE_mesh_to_curve(Scene *scene, Object *ob) BLI_freelistN(&polyline); /* add nurb to curve */ - BLI_addtail(&cu->nurb, nu); + BLI_addtail(nurblist, nu); } /* --- done with nurbs --- */ } + } +} + +void BKE_mesh_to_curve(Scene *scene, Object *ob) +{ + /* make new mesh data from the original copy */ + DerivedMesh *dm = mesh_get_derived_final(scene, ob, CD_MASK_MESH); + ListBase nurblist = {NULL, NULL}; + bool needsFree = false; + + BKE_mesh_to_curve_ex(dm, &nurblist); + + if (nurblist.first) { + Curve *cu = BKE_curve_add(G.main, ob->id.name + 2, OB_CURVE); + cu->flag |= CU_3D; + + cu->nurb = nurblist; ((Mesh *)ob->data)->id.us--; ob->data = cu; |