Mesh *BKE_mesh_new_nomain_from_curve_displist(Object *ob, ListBase *dispbase) { Curve *cu = ob->data; Mesh *mesh; MVert *allvert; MEdge *alledge; MLoop *allloop; MPoly *allpoly; MLoopUV *alluv = NULL; int totvert, totedge, totloop, totpoly; bool use_orco_uv = (cu->flag & CU_UV_ORCO) != 0; if (BKE_mesh_nurbs_displist_to_mdata(ob, dispbase, &allvert, &totvert, &alledge, &totedge, &allloop, &allpoly, (use_orco_uv) ? &alluv : NULL, &totloop, &totpoly) != 0) { /* Error initializing mdata. This often happens when curve is empty */ return BKE_mesh_new_nomain(0, 0, 0, 0, 0); } mesh = BKE_mesh_new_nomain(totvert, totedge, 0, totloop, totpoly); mesh->runtime.cd_dirty_vert |= CD_MASK_NORMAL; memcpy(mesh->mvert, allvert, totvert * sizeof(MVert)); memcpy(mesh->medge, alledge, totedge * sizeof(MEdge)); memcpy(mesh->mloop, allloop, totloop * sizeof(MLoop)); memcpy(mesh->mpoly, allpoly, totpoly * sizeof(MPoly)); if (alluv) { const char *uvname = "Orco"; CustomData_add_layer_named(&mesh->ldata, CD_MLOOPUV, CD_ASSIGN, alluv, totloop, uvname); } MEM_freeN(allvert); MEM_freeN(alledge); MEM_freeN(allloop); MEM_freeN(allpoly); return mesh; }
/* allocate and initialize a DualConOutput */ static void *dualcon_alloc_output(int totvert, int totquad) { DualConOutput *output; if (!(output = MEM_callocN(sizeof(DualConOutput), "DualConOutput"))) { return NULL; } output->mesh = BKE_mesh_new_nomain(totvert, 0, 0, 4 * totquad, totquad); return output; }