Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGermano Cavalcante <mano-wii>2021-04-01 16:41:12 +0300
committerGermano Cavalcante <germano.costa@ig.com.br>2021-04-01 16:54:49 +0300
commitf674976edd884d7a9a409042708f2b1169fd4e98 (patch)
tree1b2b293170e06d635aa6d3145db61bd4f6d4e535 /source/blender/blenkernel
parent7a757662bc0a99b6f4720bb0e92735e54f9a1441 (diff)
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
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_curve.h12
-rw-r--r--source/blender/blenkernel/intern/curve.c49
-rw-r--r--source/blender/blenkernel/intern/curve_convert.c2
-rw-r--r--source/blender/blenkernel/intern/displist.c10
-rw-r--r--source/blender/blenkernel/intern/font.c1
5 files changed, 32 insertions, 42 deletions
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h
index 2380af6a08e..8381f015bee 100644
--- a/source/blender/blenkernel/BKE_curve.h
+++ b/source/blender/blenkernel/BKE_curve.h
@@ -69,16 +69,16 @@ typedef struct CVKeyIndex {
#define SEGMENTSU(nu) (((nu)->flagu & CU_NURB_CYCLIC) ? (nu)->pntsu : (nu)->pntsu - 1)
#define SEGMENTSV(nu) (((nu)->flagv & CU_NURB_CYCLIC) ? (nu)->pntsv : (nu)->pntsv - 1)
-#define CU_DO_TILT(cu, nu) ((((nu)->flag & CU_2D) && ((cu)->flag & CU_3D) == 0) ? 0 : 1)
#define CU_DO_RADIUS(cu, nu) \
- ((CU_DO_TILT(cu, nu) || ((cu)->flag & CU_PATH_RADIUS) || (cu)->bevobj || (cu)->ext1 != 0.0f || \
+ ((((cu)->flag & (CU_PATH_RADIUS | CU_3D)) || (cu)->bevobj || (cu)->ext1 != 0.0f || \
(cu)->ext2 != 0.0f) ? \
1 : \
0)
+#define CU_IS_2D(cu) (((cu)->flag & CU_3D) == 0)
+
/* not 3d and not unfilled */
-#define CU_DO_2DFILL(cu) \
- ((((cu)->flag & CU_3D) == 0) && (((cu)->flag & (CU_FRONT | CU_BACK)) != 0))
+#define CU_DO_2DFILL(cu) (CU_IS_2D(cu) && (((cu)->flag & (CU_FRONT | CU_BACK)) != 0))
/* ** Curve ** */
void BKE_curve_editfont_free(struct Curve *cu);
@@ -86,7 +86,7 @@ void BKE_curve_init(struct Curve *cu, const short curve_type);
struct Curve *BKE_curve_add(struct Main *bmain, const char *name, int type);
short BKE_curve_type_get(const struct Curve *cu);
void BKE_curve_type_test(struct Object *ob);
-void BKE_curve_curve_dimension_update(struct Curve *cu);
+void BKE_curve_dimension_update(struct Curve *cu);
struct BoundBox *BKE_curve_boundbox_get(struct Object *ob);
@@ -186,7 +186,7 @@ void BKE_nurb_free(struct Nurb *nu);
struct Nurb *BKE_nurb_duplicate(const struct Nurb *nu);
struct Nurb *BKE_nurb_copy(struct Nurb *src, int pntsu, int pntsv);
-void BKE_nurb_test_2d(struct Nurb *nu);
+void BKE_nurb_project_2d(struct Nurb *nu);
void BKE_nurb_minmax(const struct Nurb *nu, bool use_radius, float min[3], float max[3]);
float BKE_nurb_calc_length(const struct Nurb *nu, int resolution);
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);
diff --git a/source/blender/blenkernel/intern/curve_convert.c b/source/blender/blenkernel/intern/curve_convert.c
index 988ddb3bbc0..5bcce9c339e 100644
--- a/source/blender/blenkernel/intern/curve_convert.c
+++ b/source/blender/blenkernel/intern/curve_convert.c
@@ -44,7 +44,7 @@ static Curve *curve_from_font_object(Object *object, Depsgraph *depsgraph)
new_curve->type = OB_CURVE;
new_curve->flag &= ~CU_3D;
- BKE_curve_curve_dimension_update(new_curve);
+ BKE_curve_dimension_update(new_curve);
return new_curve;
}
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index a04bad45bf6..9022760fe34 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -1185,7 +1185,7 @@ void BKE_displist_make_surf(Depsgraph *depsgraph,
/* dl->rt will be used as flag for render face and */
/* CU_2D conflicts with R_NOPUNOFLIP */
- dl->rt = nu->flag & ~CU_2D;
+ dl->rt = nu->flag;
data = dl->verts;
if (nu->flagu & CU_NURB_CYCLIC) {
@@ -1209,7 +1209,7 @@ void BKE_displist_make_surf(Depsgraph *depsgraph,
/* dl->rt will be used as flag for render face and */
/* CU_2D conflicts with R_NOPUNOFLIP */
- dl->rt = nu->flag & ~CU_2D;
+ dl->rt = nu->flag;
data = dl->verts;
dl->type = DL_SURF;
@@ -1320,7 +1320,7 @@ static void fillBevelCap(const Nurb *nu,
/* dl->rt will be used as flag for render face and */
/* CU_2D conflicts with R_NOPUNOFLIP */
- dl->rt = nu->flag & ~CU_2D;
+ dl->rt = nu->flag;
BLI_addtail(dispbase, dl);
}
@@ -1551,7 +1551,7 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
/* dl->rt will be used as flag for render face and */
/* CU_2D conflicts with R_NOPUNOFLIP */
- dl->rt = nu->flag & ~CU_2D;
+ dl->rt = nu->flag;
int a = dl->nr;
BevPoint *bevp = bl->bevpoints;
@@ -1606,7 +1606,7 @@ static void do_makeDispListCurveTypes(Depsgraph *depsgraph,
/* dl->rt will be used as flag for render face and */
/* CU_2D conflicts with R_NOPUNOFLIP */
- dl->rt = nu->flag & ~CU_2D;
+ dl->rt = nu->flag;
/* for each point of poly make a bevel piece */
BevPoint *bevp_first = bl->bevpoints;
diff --git a/source/blender/blenkernel/intern/font.c b/source/blender/blenkernel/intern/font.c
index febc9e24c9f..64f44240eed 100644
--- a/source/blender/blenkernel/intern/font.c
+++ b/source/blender/blenkernel/intern/font.c
@@ -447,7 +447,6 @@ static void build_underline(Curve *cu,
nu2->resolu = cu->resolu;
nu2->bezt = NULL;
nu2->knotsu = nu2->knotsv = NULL;
- nu2->flag = CU_2D;
nu2->charidx = charidx + 1000;
if (mat_nr > 0) {
nu2->mat_nr = mat_nr - 1;