diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-03 20:16:19 +0400 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-11-03 20:16:19 +0400 |
commit | b99f6e3d082b1b47591cdae1d2f3b78a75dd719b (patch) | |
tree | ff5e76ae5c12f071a86496b161df50655a925c73 | |
parent | 665f602f152984f5a6f4ea05a2a90382acbf700a (diff) |
Fix #29005: Bezier/Surface Datablock switching bug?
This commit updates curve datablock to respect curve dimension flag
when setting datablock for curve.
Not ideal but this makes behavior quite expected, avoids big changes in
curves core stuff which depends on object type and prevents restrictions
on changing data datablock which works in general cases.
-rw-r--r-- | source/blender/blenkernel/BKE_curve.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/curve.c | 29 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_curve.c | 21 |
3 files changed, 32 insertions, 19 deletions
diff --git a/source/blender/blenkernel/BKE_curve.h b/source/blender/blenkernel/BKE_curve.h index 9282f0ef29a..f0704741ebb 100644 --- a/source/blender/blenkernel/BKE_curve.h +++ b/source/blender/blenkernel/BKE_curve.h @@ -65,6 +65,7 @@ void make_local_curve( struct Curve *cu); struct ListBase *curve_editnurbs(struct Curve *cu); short curve_type( struct Curve *cu); void test_curve_type( struct Object *ob); +void update_curve_dimension( struct Curve *cu ); void tex_space_curve( struct Curve *cu); int count_curveverts( struct ListBase *nurb); int count_curveverts_without_handles( struct ListBase *nurb); diff --git a/source/blender/blenkernel/intern/curve.c b/source/blender/blenkernel/intern/curve.c index 5d2180fe702..adc08f5cd9f 100644 --- a/source/blender/blenkernel/intern/curve.c +++ b/source/blender/blenkernel/intern/curve.c @@ -315,9 +315,34 @@ short curve_type(Curve *cu) return OB_CURVE; } +void update_curve_dimension(Curve *cu) +{ + ListBase *nurbs= BKE_curve_nurbs(cu); + Nurb *nu= nurbs->first; + + if(cu->flag&CU_3D) { + for( ; nu; nu= nu->next) { + nu->flag &= ~CU_2D; + } + } + else { + for( ; nu; nu= nu->next) { + nu->flag |= CU_2D; + test2DNurb(nu); + + /* since the handles are moved they need to be auto-located again */ + if(nu->type == CU_BEZIER) + calchandlesNurb(nu); + } + } +} + void test_curve_type(Object *ob) -{ - ob->type = curve_type(ob->data); +{ + ob->type= curve_type(ob->data); + + if(ob->type==OB_CURVE) + update_curve_dimension((Curve *)ob->data); } void tex_space_curve(Curve *cu) diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index cbac594a80f..1f52b0ac149 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -271,23 +271,10 @@ static void rna_Curve_dimension_set(PointerRNA *ptr, int value) ListBase *nurbs= BKE_curve_nurbs(cu); Nurb *nu= nurbs->first; - if(value==CU_3D) { - cu->flag |= CU_3D; - for( ; nu; nu= nu->next) { - nu->flag &= ~CU_2D; - } - } - else { - cu->flag &= ~CU_3D; - for( ; nu; nu= nu->next) { - nu->flag |= CU_2D; - test2DNurb(nu); - - /* since the handles are moved they need to be auto-located again */ - if(nu->type == CU_BEZIER) - calchandlesNurb(nu); - } - } + if(value==CU_3D) cu->flag |= CU_3D; + else cu->flag &= ~CU_3D; + + update_curve_dimension(cu); } static EnumPropertyItem *rna_Curve_fill_mode_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *UNUSED(free)) |