diff options
-rw-r--r-- | source/blender/blenkernel/BKE_curve.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/curve_bevel.c | 24 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/displist.cc | 11 |
3 files changed, 18 insertions, 19 deletions
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 21f362c8c7e..eb9c68f80ec 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -156,7 +156,7 @@ struct ListBase *BKE_curve_editNurbs_get(struct Curve *cu); void BKE_curve_bevelList_free(struct ListBase *bev); void BKE_curve_bevelList_make(struct Object *ob, struct ListBase *nurbs, bool for_render); -void BKE_curve_bevel_make(struct Object *ob, struct ListBase *disp); +ListBase BKE_curve_bevel_make(const struct Curve *ob); void BKE_curve_forward_diff_bezier( float q0, float q1, float q2, float q3, float *p, int it, int stride); diff --git a/source/blender/blenkernel/intern/curve_bevel.c b/source/blender/blenkernel/intern/curve_bevel.c index 911a98cb607..51418a6485f 100644 --- a/source/blender/blenkernel/intern/curve_bevel.c +++ b/source/blender/blenkernel/intern/curve_bevel.c @@ -83,7 +83,7 @@ static void bevel_quarter_fill(Curve *curve, float *quarter_coords_x, float *qua } } -static void curve_bevel_make_extrude_and_fill(Curve *cu, +static void curve_bevel_make_extrude_and_fill(const Curve *cu, ListBase *disp, const bool use_extrude, const CurveBevelFillType fill_type) @@ -193,7 +193,7 @@ static void curve_bevel_make_extrude_and_fill(Curve *cu, } } -static void curve_bevel_make_full_circle(Curve *cu, ListBase *disp) +static void curve_bevel_make_full_circle(const Curve *cu, ListBase *disp) { const int nr = 4 + 2 * cu->bevresol; @@ -218,7 +218,7 @@ static void curve_bevel_make_full_circle(Curve *cu, ListBase *disp) } } -static void curve_bevel_make_only_extrude(Curve *cu, ListBase *disp) +static void curve_bevel_make_only_extrude(const Curve *cu, ListBase *disp) { DispList *dl = MEM_callocN(sizeof(DispList), __func__); dl->verts = MEM_malloc_arrayN(2, sizeof(float[3]), __func__); @@ -235,7 +235,7 @@ static void curve_bevel_make_only_extrude(Curve *cu, ListBase *disp) fp[5] = cu->ext1; } -static void curve_bevel_make_from_object(Curve *cu, ListBase *disp) +static void curve_bevel_make_from_object(const Curve *cu, ListBase *disp) { if (cu->bevobj == NULL) { return; @@ -287,15 +287,13 @@ static void curve_bevel_make_from_object(Curve *cu, ListBase *disp) } } -void BKE_curve_bevel_make(Object *ob, ListBase *disp) +ListBase BKE_curve_bevel_make(const Curve *curve) { - Curve *curve = ob->data; - - BLI_listbase_clear(disp); + ListBase bevel_shape = {NULL, NULL}; if (curve->bevel_mode == CU_BEV_MODE_OBJECT) { if (curve->bevobj != NULL) { - curve_bevel_make_from_object(curve, disp); + curve_bevel_make_from_object(curve, &bevel_shape); } } else { @@ -303,18 +301,20 @@ void BKE_curve_bevel_make(Object *ob, ListBase *disp) const bool use_bevel = curve->ext2 != 0.0f; /* Pass. */ if (use_extrude && !use_bevel) { - curve_bevel_make_only_extrude(curve, disp); + curve_bevel_make_only_extrude(curve, &bevel_shape); } else if (use_extrude || use_bevel) { CurveBevelFillType fill_type = curve_bevel_get_fill_type(curve); if (!use_extrude && fill_type == FULL && curve->bevel_mode == CU_BEV_MODE_ROUND) { - curve_bevel_make_full_circle(curve, disp); + curve_bevel_make_full_circle(curve, &bevel_shape); } else { /* The general case for nonzero extrusion or an incomplete loop. */ - curve_bevel_make_extrude_and_fill(curve, disp, use_extrude, fill_type); + curve_bevel_make_extrude_and_fill(curve, &bevel_shape, use_extrude, fill_type); } } } + + return bevel_shape; } diff --git a/source/blender/blenkernel/intern/displist.cc b/source/blender/blenkernel/intern/displist.cc index 7337f1d929f..e501e0a2f45 100644 --- a/source/blender/blenkernel/intern/displist.cc +++ b/source/blender/blenkernel/intern/displist.cc @@ -1411,7 +1411,7 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph, const bool for_orco, Mesh **r_final) { - Curve *cu = (Curve *)ob->data; + const Curve *cu = (const Curve *)ob->data; /* we do allow duplis... this is only displist on curve level */ if (!ELEM(ob->type, OB_SURF, OB_CURVE, OB_FONT)) { @@ -1422,7 +1422,6 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph, displist_make_surf(depsgraph, scene, ob, dispbase, r_final, for_render, for_orco); } else if (ELEM(ob->type, OB_CURVE, OB_FONT)) { - ListBase dlbev; ListBase nubase = {nullptr, nullptr}; bool force_mesh_conversion = false; @@ -1442,7 +1441,7 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph, BKE_vfont_to_curve_nubase(ob, FO_EDIT, &nubase); } else { - BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(cu)); + BKE_nurbList_duplicate(&nubase, BKE_curve_nurbs_get(const_cast<Curve *>(cu))); } if (!for_orco) { @@ -1453,17 +1452,17 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph, BKE_curve_bevelList_make(ob, &nubase, for_render); /* If curve has no bevel will return nothing */ - BKE_curve_bevel_make(ob, &dlbev); + ListBase dlbev = BKE_curve_bevel_make(cu); /* no bevel or extrude, and no width correction? */ - if (!dlbev.first && cu->width == 1.0f) { + if (BLI_listbase_is_empty(&dlbev) && cu->width == 1.0f) { curve_to_displist(cu, &nubase, for_render, dispbase); } else { const float widfac = cu->width - 1.0f; + BevList *bl = (BevList *)ob->runtime.curve_cache->bev.first; Nurb *nu = (Nurb *)nubase.first; - for (; bl && nu; bl = bl->next, nu = nu->next) { float *data; |