fix for [#17895] Python-generated Curves can't be beveled
authorCampbell Barton <ideasman42@gmail.com>
Sun, 26 Oct 2008 08:06:48 +0000 (08:06 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sun, 26 Oct 2008 08:06:48 +0000 (08:06 +0000)
radius and weight's values were not initialized for nurbs curves

for 2.48a just use set radius from curve specials menu to work around this.

source/blender/python/api2_2x/BezTriple.c
source/blender/python/api2_2x/CurNurb.c
source/blender/python/api2_2x/Curve.c

index b7b94dc93e12a4080a6130e2a3576eb4fc9bd6a3..9e57994d2da13322f0d62e8005747fe851d1367f 100644 (file)
@@ -694,6 +694,7 @@ PyObject *newBezTriple( float *numbuf )
        }
        bzt->h1 = HD_ALIGN;
        bzt->h2 = HD_ALIGN;
+       bzt->radius = 1.0;
 
        /* wrap it */
        pyobj = BezTriple_CreatePyObject( bzt );
index b2120bd63c604841c3ab60dfcb7aaee7bcfdf7b7..63a1dccbc50daa8009ab7139274d487c02f5150b 100644 (file)
@@ -522,7 +522,7 @@ PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * value )
        else if( PySequence_Check( value ) ) {
                size = PySequence_Size( value );
 /*             printf("\ndbg: got a sequence of size %d\n", size );  */
-               if( size == 4 || size == 5 ) {
+               if( size == 4 || size == 5 || size == 6) {
                        BPoint *tmp;
 
                        tmp = nurb->bp; /* save old pts */
@@ -556,8 +556,8 @@ PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * value )
                                Py_DECREF( item );
                        }
 
-                       if (size == 5) {
-                               PyObject *item = PySequence_GetItem( value, i );
+                       if (size >= 5) {
+                               PyObject *item = PySequence_GetItem( value, 4 );
 
                                if (item == NULL)
                                        return NULL;
@@ -568,18 +568,33 @@ PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * value )
                        else {
                                nurb->bp[npoints].alfa = 0.0f;
                        }
+                       
+                       if (size == 6) {
+                               PyObject *item = PySequence_GetItem( value, 5 );
+
+                               if (item == NULL)
+                                       return NULL;
 
+                               nurb->bp[npoints].radius = ( float ) PyFloat_AsDouble( item );
+                               Py_DECREF( item );
+                       }
+                       else {
+                               nurb->bp[npoints].radius = 1.0f;
+                       }
+                       
+                       nurb->bp[npoints].weight = 0.0; /* softbody weight TODO - add access to this, is zero elsewhere but through blender is 1.0 by default */
+                       
                        makeknots( nurb, 1, nurb->flagu >> 1 );
 
                } else {
                        return EXPP_ReturnPyObjError( PyExc_TypeError,
-                                       "expected a sequence of 4 or 5 floats" );
+                                       "expected a sequence of 4 or 6 floats" );
                }
 
        } else {
                /* bail with error */
                return EXPP_ReturnPyObjError( PyExc_TypeError,
-                                       "expected a sequence of 4 or 5 floats" );
+                                       "expected a sequence of 4 to 6 floats" );
 
        }
 
index 26208e600e65445b899226dc982766cae549bc2d..d1abde19de907f14b973b0ccd7dfadb9fdc6db0b 100644 (file)
@@ -822,6 +822,7 @@ static PyObject *Curve_appendNurb( BPy_Curve * self, PyObject * value )
                        new_nurb->bezt->f2 = SELECT;
                        new_nurb->bezt->f3 = SELECT;
                        new_nurb->bezt->hide = 0;
+                       new_nurb->bezt->radius = 1.0;
                        /* calchandlesNurb( new_nurb ); */
                } else {        /* set up bp */
                        new_nurb->pntsv = 1;
@@ -831,6 +832,7 @@ static PyObject *Curve_appendNurb( BPy_Curve * self, PyObject * value )
                        new_nurb->flagv = 0;
                        new_nurb->bp->f1 = 0;
                        new_nurb->bp->hide = 0;
+                       new_nurb->bp->radius = 1.0;
                        new_nurb->knotsu = 0;
                        /*makenots( new_nurb, 1, new_nurb->flagu >> 1); */
                }