Fix #29369: bpy.data.curves.new(name= "test" , type = 'SURFACE') does not create...
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 24 Nov 2011 14:30:37 +0000 (14:30 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 24 Nov 2011 14:30:37 +0000 (14:30 +0000)
This issue it totally related on issue with changing object datablock.
For curves it used to guess object type from curve datablock based on
count of control points in V direction.
This quess fails in case when SurfCircle datablock is trying to be reused
by another surface object or as another sample empty surface databouck used
to be treated as curve.

Store type in Curve when creating new Curve datablock which is used in
this object type quessing function.

Note: Previously saved files wouldn't change behavior at all.

source/blender/blenkernel/intern/curve.c
source/blender/editors/object/object_add.c
source/blender/makesdna/DNA_curve_types.h

index 8a6e8faf29af2055e15715ab6c397d8fa4266460..358c63b4f9f819384d02a8847f5c14b124eeabcd 100644 (file)
@@ -169,6 +169,7 @@ Curve *add_curve(const char *name, int type)
        cu->texflag= CU_AUTOSPACE;
        cu->smallcaps_scale= 0.75f;
        cu->twist_mode= CU_TWIST_MINIMUM;       // XXX: this one seems to be the best one in most cases, at least for curve deform...
+       cu->type= type;
        
        cu->bb= unit_boundbox();
        
@@ -303,16 +304,23 @@ ListBase *curve_editnurbs(Curve *cu)
 short curve_type(Curve *cu)
 {
        Nurb *nu;
+       int type= cu->type;
+
        if(cu->vfont) {
                return OB_FONT;
        }
-       for (nu= cu->nurb.first; nu; nu= nu->next) {
-               if(nu->pntsv>1) {
-                       return OB_SURF;
+
+       if(!cu->type) {
+               type= OB_CURVE;
+
+               for (nu= cu->nurb.first; nu; nu= nu->next) {
+                       if(nu->pntsv>1) {
+                               type= OB_SURF;
+                       }
                }
        }
-       
-       return OB_CURVE;
+
+       return type;
 }
 
 void update_curve_dimension(Curve *cu)
index a6d3365ad8a5dd8b368cb686c144c842d71c29ae..bcd8b8903e77ea2611ae9957624b78d09e057362 100644 (file)
@@ -1366,6 +1366,7 @@ static int convert_exec(bContext *C, wmOperator *op)
                                makeDispListCurveTypes(scene, newob, 0);
 
                        newob->type= OB_CURVE;
+                       cu->type= OB_CURVE;
 
                        if(cu->vfont) {
                                cu->vfont->id.us--;
index d189a692083c24d87eb9238bda5f83a76eeaee5e..236d6dd47320f460d0fb5db8419141d445d982bb 100644 (file)
@@ -186,7 +186,9 @@ typedef struct Curve {
        float size[3];
        float rot[3];
 
-       short texflag, pad1; /* keep a short because of give_obdata_texspace() */
+       short type;     /* creation-time type of curve datablock */
+
+       short texflag; /* keep a short because of give_obdata_texspace() */
        short drawflag, twist_mode;
        float twist_smooth, smallcaps_scale;