diff options
Diffstat (limited to 'source/blender/blenkernel/intern/curve.c')
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 226 |
1 files changed, 0 insertions, 226 deletions
diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index dc677449a4c..388a2d3a926 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -1737,232 +1737,6 @@ static void forward_diff_bezier_cotangent(const float p0[3], } } -/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ - -float *BKE_curve_surf_make_orco(Object *ob) -{ - /* Note: this function is used in convertblender only atm, so - * suppose nonzero curve's render resolution should always be used */ - Curve *cu = ob->data; - Nurb *nu; - int a, b, tot = 0; - int sizeu, sizev; - int resolu, resolv; - float *fp, *coord_array; - - /* first calculate the size of the datablock */ - nu = cu->nurb.first; - while (nu) { - /* as we want to avoid the seam in a cyclic nurbs - * texture wrapping, reserve extra orco data space to save these extra needed - * vertex based UV coordinates for the meridian vertices. - * Vertices on the 0/2pi boundary are not duplicated inside the displist but later in - * the renderface/vert construction. - * - * See also convertblender.c: init_render_surf() - */ - - resolu = cu->resolu_ren ? cu->resolu_ren : nu->resolu; - resolv = cu->resolv_ren ? cu->resolv_ren : nu->resolv; - - sizeu = nu->pntsu * resolu; - sizev = nu->pntsv * resolv; - if (nu->flagu & CU_NURB_CYCLIC) { - sizeu++; - } - if (nu->flagv & CU_NURB_CYCLIC) { - sizev++; - } - if (nu->pntsv > 1) { - tot += sizeu * sizev; - } - - nu = nu->next; - } - /* makeNurbfaces wants zeros */ - fp = coord_array = MEM_calloc_arrayN(tot, 3 * sizeof(float), "make_orco"); - - nu = cu->nurb.first; - while (nu) { - resolu = cu->resolu_ren ? cu->resolu_ren : nu->resolu; - resolv = cu->resolv_ren ? cu->resolv_ren : nu->resolv; - - if (nu->pntsv > 1) { - sizeu = nu->pntsu * resolu; - sizev = nu->pntsv * resolv; - - if (nu->flagu & CU_NURB_CYCLIC) { - sizeu++; - } - if (nu->flagv & CU_NURB_CYCLIC) { - sizev++; - } - - if (cu->flag & CU_UV_ORCO) { - for (b = 0; b < sizeu; b++) { - for (a = 0; a < sizev; a++) { - - if (sizev < 2) { - fp[0] = 0.0f; - } - else { - fp[0] = -1.0f + 2.0f * ((float)a) / (sizev - 1); - } - - if (sizeu < 2) { - fp[1] = 0.0f; - } - else { - fp[1] = -1.0f + 2.0f * ((float)b) / (sizeu - 1); - } - - fp[2] = 0.0; - - fp += 3; - } - } - } - else { - int size = (nu->pntsu * resolu) * (nu->pntsv * resolv) * 3 * sizeof(float); - float *_tdata = MEM_mallocN(size, "temp data"); - float *tdata = _tdata; - - BKE_nurb_makeFaces(nu, tdata, 0, resolu, resolv); - - for (b = 0; b < sizeu; b++) { - int use_b = b; - if (b == sizeu - 1 && (nu->flagu & CU_NURB_CYCLIC)) { - use_b = false; - } - - for (a = 0; a < sizev; a++) { - int use_a = a; - if (a == sizev - 1 && (nu->flagv & CU_NURB_CYCLIC)) { - use_a = false; - } - - tdata = _tdata + 3 * (use_b * (nu->pntsv * resolv) + use_a); - - fp[0] = (tdata[0] - cu->loc[0]) / cu->size[0]; - fp[1] = (tdata[1] - cu->loc[1]) / cu->size[1]; - fp[2] = (tdata[2] - cu->loc[2]) / cu->size[2]; - fp += 3; - } - } - - MEM_freeN(_tdata); - } - } - nu = nu->next; - } - - return coord_array; -} - -/* NOTE: This routine is tied to the order of vertex - * built by displist and as passed to the renderer. - */ -float *BKE_curve_make_orco(Depsgraph *depsgraph, Scene *scene, Object *ob, int *r_numVerts) -{ - Curve *cu = ob->data; - DispList *dl; - int u, v, numVerts; - float *fp, *coord_array; - ListBase disp = {NULL, NULL}; - - BKE_displist_make_curveTypes_forOrco(depsgraph, scene, ob, &disp, NULL); - - numVerts = 0; - for (dl = disp.first; dl; dl = dl->next) { - if (dl->type == DL_INDEX3) { - numVerts += dl->nr; - } - else if (dl->type == DL_SURF) { - /* convertblender.c uses the Surface code for creating renderfaces when cyclic U only - * (closed circle beveling) - */ - if (dl->flag & DL_CYCL_U) { - if (dl->flag & DL_CYCL_V) { - numVerts += (dl->parts + 1) * (dl->nr + 1); - } - else { - numVerts += dl->parts * (dl->nr + 1); - } - } - else if (dl->flag & DL_CYCL_V) { - numVerts += (dl->parts + 1) * dl->nr; - } - else { - numVerts += dl->parts * dl->nr; - } - } - } - - if (r_numVerts) { - *r_numVerts = numVerts; - } - - fp = coord_array = MEM_malloc_arrayN(numVerts, 3 * sizeof(float), "cu_orco"); - for (dl = disp.first; dl; dl = dl->next) { - if (dl->type == DL_INDEX3) { - for (u = 0; u < dl->nr; u++, fp += 3) { - if (cu->flag & CU_UV_ORCO) { - fp[0] = 2.0f * u / (dl->nr - 1) - 1.0f; - fp[1] = 0.0; - fp[2] = 0.0; - } - else { - copy_v3_v3(fp, &dl->verts[u * 3]); - - fp[0] = (fp[0] - cu->loc[0]) / cu->size[0]; - fp[1] = (fp[1] - cu->loc[1]) / cu->size[1]; - fp[2] = (fp[2] - cu->loc[2]) / cu->size[2]; - } - } - } - else if (dl->type == DL_SURF) { - int sizeu = dl->nr, sizev = dl->parts; - - /* exception as handled in convertblender.c too */ - if (dl->flag & DL_CYCL_U) { - sizeu++; - if (dl->flag & DL_CYCL_V) { - sizev++; - } - } - else if (dl->flag & DL_CYCL_V) { - sizev++; - } - - for (u = 0; u < sizev; u++) { - for (v = 0; v < sizeu; v++, fp += 3) { - if (cu->flag & CU_UV_ORCO) { - fp[0] = 2.0f * u / (sizev - 1) - 1.0f; - fp[1] = 2.0f * v / (sizeu - 1) - 1.0f; - fp[2] = 0.0; - } - else { - const float *vert; - int realv = v % dl->nr; - int realu = u % dl->parts; - - vert = dl->verts + 3 * (dl->nr * realu + realv); - copy_v3_v3(fp, vert); - - fp[0] = (fp[0] - cu->loc[0]) / cu->size[0]; - fp[1] = (fp[1] - cu->loc[1]) / cu->size[1]; - fp[2] = (fp[2] - cu->loc[2]) / cu->size[2]; - } - } - } - } - } - - BKE_displist_free(&disp); - - return coord_array; -} - /* ***************** BEVEL ****************** */ void BKE_curve_bevel_make(Depsgraph *depsgraph, |