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.
This commit is contained in:
Sergey Sharybin 2011-11-03 16:16:19 +00:00
parent 665f602f15
commit b99f6e3d08
3 changed files with 31 additions and 18 deletions

@ -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);

@ -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)

@ -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);
if(value==CU_3D) cu->flag |= CU_3D;
else cu->flag &= ~CU_3D;
/* since the handles are moved they need to be auto-located again */
if(nu->type == CU_BEZIER)
calchandlesNurb(nu);
}
}
update_curve_dimension(cu);
}
static EnumPropertyItem *rna_Curve_fill_mode_itemf(bContext *UNUSED(C), PointerRNA *ptr, PropertyRNA *UNUSED(prop), int *UNUSED(free))