Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/mesh_convert.c
| Context not available. | |||||
| /* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */ | /* Initialize mverts, medges and, faces for converting nurbs to mesh and derived mesh */ | ||||
| /* return non-zero on error */ | /* return non-zero on error */ | ||||
| int BKE_mesh_nurbs_to_mdata(Object *ob, | //int BKE_mesh_nurbs_to_mdata(Object *ob, | ||||
| MVert **r_allvert, | // MVert **r_allvert, | ||||
| int *r_totvert, | // int *r_totvert, | ||||
| MEdge **r_alledge, | // MEdge **r_alledge, | ||||
| int *r_totedge, | // int *r_totedge, | ||||
| MLoop **r_allloop, | // MLoop **r_allloop, | ||||
| MPoly **r_allpoly, | // MPoly **r_allpoly, | ||||
| int *r_totloop, | // int *r_totloop, | ||||
| int *r_totpoly) | // int *r_totpoly) | ||||
| { | //{ | ||||
| ListBase disp = {NULL, NULL}; | // ListBase disp = {NULL, NULL}; | ||||
| // | |||||
| if (ob->runtime.curve_cache) { | // if (ob->runtime.curve_cache) { | ||||
| disp = ob->runtime.curve_cache->disp; | // disp = ob->runtime.curve_cache->disp; | ||||
| } | // } | ||||
| // | |||||
| return BKE_mesh_nurbs_displist_to_mdata(ob, | // return BKE_mesh_nurbs_displist_to_mdata(ob, | ||||
| &disp, | // &disp, | ||||
| r_allvert, | // r_allvert, | ||||
| r_totvert, | // r_totvert, | ||||
| r_alledge, | // r_alledge, | ||||
| r_totedge, | // r_totedge, | ||||
| r_allloop, | // r_allloop, | ||||
| r_allpoly, | // r_allpoly, | ||||
| NULL, | // NULL, | ||||
| r_totloop, | // r_totloop, | ||||
| r_totpoly); | // r_totpoly); | ||||
| } | //} | ||||
| /* BMESH: this doesn't calculate all edges from polygons, | /* BMESH: this doesn't calculate all edges from polygons, | ||||
| * only free standing edges are calculated */ | * only free standing edges are calculated */ | ||||
| Context not available. | |||||
| MLoopUV *mloopuv = NULL; | MLoopUV *mloopuv = NULL; | ||||
| MEdge *medge; | MEdge *medge; | ||||
| const float *data; | const float *data; | ||||
| int a, b, ofs, vertcount, startvert, totvert = 0, totedge = 0, totloop = 0, totpoly = 0; | int i, a, b, ofs, vertcount, startvert, totvert = 0, totedge = 0, totloop = 0, totpoly = 0; | ||||
| int p1, p2, p3, p4, *index; | int p1, p2, p3, p4, *index; | ||||
| const bool conv_polys = ( | const bool conv_polys = ( | ||||
| /* 2d polys are filled with DL_INDEX3 displists */ | /* 2d polys are filled with DL_INDEX3 displists */ | ||||
| (CU_DO_2DFILL(cu) == false) || | (CU_DO_2DFILL(cu) == false) || | ||||
| /* surf polys are never filled */ | /* surf polys are never filled */ | ||||
| (ob->type == OB_SURF)); | (ob->type == OB_SURF)); | ||||
| float *nors; | |||||
| /* count */ | /* count */ | ||||
| dl = dispbase->first; | dl = dispbase->first; | ||||
| while (dl) { | while (dl) { | ||||
| Context not available. | |||||
| startvert = vertcount; | startvert = vertcount; | ||||
| a = dl->nr; | a = dl->nr; | ||||
| data = dl->verts; | data = dl->verts; | ||||
| nors = dl->nors; | |||||
| while (a--) { | while (a--) { | ||||
| copy_v3_v3(mvert->co, data); | copy_v3_v3(mvert->co, data); | ||||
| data += 3; | data += 3; | ||||
| if (nors) { | |||||
| normal_float_to_short_v3(mvert->no, nors); | |||||
| nors += 3; | |||||
| } | |||||
| vertcount++; | vertcount++; | ||||
| mvert++; | mvert++; | ||||
| } | } | ||||
| Context not available. | |||||
| mpoly->mat_nr = dl->col; | mpoly->mat_nr = dl->col; | ||||
| if (mloopuv) { | if (mloopuv) { | ||||
| int i; | for (i = 0; i < 3; i++, mloopuv++) { | ||||
| for (i = 0; i < 3; i++, mloopuv++) { | |||||
| mloopuv->uv[0] = (mloop[i].v - startvert) / (float)(dl->nr - 1); | mloopuv->uv[0] = (mloop[i].v - startvert) / (float)(dl->nr - 1); | ||||
| mloopuv->uv[1] = 0.0f; | mloopuv->uv[1] = 0.0f; | ||||
| } | } | ||||
| Context not available. | |||||
| nu->orderu = 4; | nu->orderu = 4; | ||||
| nu->flagu = CU_NURB_ENDPOINT | (closed ? CU_NURB_CYCLIC : 0); /* endpoint */ | nu->flagu = CU_NURB_ENDPOINT | (closed ? CU_NURB_CYCLIC : 0); /* endpoint */ | ||||
| nu->resolu = 12; | nu->resolu = 12; | ||||
| nu->editknot = NULL; | |||||
| nu->bp = (BPoint *)MEM_calloc_arrayN(totpoly, sizeof(BPoint), "bpoints"); | nu->bp = (BPoint *)MEM_calloc_arrayN(totpoly, sizeof(BPoint), "bpoints"); | ||||
| Context not available. | |||||