From f674976edd884d7a9a409042708f2b1169fd4e98 Mon Sep 17 00:00:00 2001 From: Germano Cavalcante Date: Thu, 1 Apr 2021 10:41:12 -0300 Subject: Curve: Remove 'CU_2D' flag used for nurbs This fixes T86440 As the CU_2D flag is set for nurbs, a Curve can have 2D nurbs mixed with 3D. But the UI does not allow this mixing. It updates all nurbs to 2D or 3D when set. So remove this specific flag for nurbs. This may break old files, since 2D curves with mixed 3D are now set as 3D. Differential Revision: https://developer.blender.org/D10738 --- source/blender/blenkernel/intern/curve.c | 49 +++++++++++++------------------- 1 file changed, 20 insertions(+), 29 deletions(-) (limited to 'source/blender/blenkernel/intern/curve.c') diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 021aea20d22..95c242c31b2 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -462,24 +462,19 @@ short BKE_curve_type_get(const Curve *cu) return type; } -void BKE_curve_curve_dimension_update(Curve *cu) +void BKE_curve_dimension_update(Curve *cu) { ListBase *nurbs = BKE_curve_nurbs_get(cu); + bool is_2d = CU_IS_2D(cu); - if (cu->flag & CU_3D) { - LISTBASE_FOREACH (Nurb *, nu, nurbs) { - nu->flag &= ~CU_2D; + LISTBASE_FOREACH (Nurb *, nu, nurbs) { + if (is_2d) { + BKE_nurb_project_2d(nu); } - } - else { - LISTBASE_FOREACH (Nurb *, nu, nurbs) { - nu->flag |= CU_2D; - BKE_nurb_test_2d(nu); - /* since the handles are moved they need to be auto-located again */ - if (nu->type == CU_BEZIER) { - BKE_nurb_handles_calc(nu); - } + /* since the handles are moved they need to be auto-located again */ + if (nu->type == CU_BEZIER) { + BKE_nurb_handles_calc(nu); } } } @@ -489,7 +484,10 @@ void BKE_curve_type_test(Object *ob) ob->type = BKE_curve_type_get(ob->data); if (ob->type == OB_CURVE) { - BKE_curve_curve_dimension_update((Curve *)ob->data); + Curve *cu = ob->data; + if (CU_IS_2D(cu)) { + BKE_curve_dimension_update(cu); + } } } @@ -745,16 +743,12 @@ void BKE_nurbList_duplicate(ListBase *lb1, const ListBase *lb2) } } -void BKE_nurb_test_2d(Nurb *nu) +void BKE_nurb_project_2d(Nurb *nu) { BezTriple *bezt; BPoint *bp; int a; - if ((nu->flag & CU_2D) == 0) { - return; - } - if (nu->type == CU_BEZIER) { a = nu->pntsu; bezt = nu->bezt; @@ -2712,8 +2706,9 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render) continue; } - /* check if we will calculate tilt data */ - do_tilt = CU_DO_TILT(cu, nu); + /* Tilt, as the rotation angle of curve control points, is only calculated for 3D curves, + * (since this transformation affects the 3D space). */ + do_tilt = (cu->flag & CU_3D) != 0; /* Normal display uses the radius, better just to calculate them. */ do_radius = CU_DO_RADIUS(cu, nu); @@ -3125,7 +3120,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render) } /* turning direction */ - if ((cu->flag & CU_3D) == 0) { + if (CU_IS_2D(cu)) { sd = sortdata; for (a = 0; a < poly; a++, sd++) { if (sd->bl->hole == sd->dir) { @@ -3145,7 +3140,7 @@ void BKE_curve_bevelList_make(Object *ob, ListBase *nurbs, bool for_render) } /* STEP 4: 2D-COSINES or 3D ORIENTATION */ - if ((cu->flag & CU_3D) == 0) { + if (CU_IS_2D(cu)) { /* 2D Curves */ LISTBASE_FOREACH (BevList *, bl, bev) { if (bl->nr < 2) { @@ -4730,9 +4725,7 @@ void BKE_curve_nurbs_vert_coords_apply_with_mat4(ListBase *lb, } if (constrain_2d) { - if (nu->flag & CU_2D) { - BKE_nurb_test_2d(nu); - } + BKE_nurb_project_2d(nu); } calchandlesNurb_intern(nu, SELECT, true); @@ -4768,9 +4761,7 @@ void BKE_curve_nurbs_vert_coords_apply(ListBase *lb, } if (constrain_2d) { - if (nu->flag & CU_2D) { - BKE_nurb_test_2d(nu); - } + BKE_nurb_project_2d(nu); } calchandlesNurb_intern(nu, SELECT, true); -- cgit v1.2.3