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
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-12-24 18:46:26 +0300
committerCampbell Barton <ideasman42@gmail.com>2008-12-24 18:46:26 +0300
commitcbebe4ad46082198b5a59fd21efeb99b4e6fd7be (patch)
treebbfcaaa56c6fa58c3661d234baa1ec8fa2bc2c63 /source
parent3a4ead8f0f5b4c8d7af96d8d1984d0469b0c200f (diff)
* bpy curve api wouldn't give correct errors for bad arguments when appending nurbs.
* the radius on the curves first point was ignored. * mesh_edges2curves.py was giving all points a tilt of 1.0
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/api2_2x/CurNurb.c118
-rw-r--r--source/blender/python/api2_2x/Curve.c2
2 files changed, 46 insertions, 74 deletions
diff --git a/source/blender/python/api2_2x/CurNurb.c b/source/blender/python/api2_2x/CurNurb.c
index 63a1dccbc50..bd360585b19 100644
--- a/source/blender/python/api2_2x/CurNurb.c
+++ b/source/blender/python/api2_2x/CurNurb.c
@@ -467,9 +467,6 @@ PyObject *CurNurb_append( BPy_CurNurb * self, PyObject * value )
PyObject *CurNurb_appendPointToNurb( Nurb * nurb, PyObject * value )
{
-
- int i;
- int size;
int npoints = nurb->pntsu;
/*
@@ -520,81 +517,58 @@ 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 || size == 6) {
- BPoint *tmp;
-
- tmp = nurb->bp; /* save old pts */
-
- nurb->bp =
- ( BPoint * ) MEM_mallocN( sizeof( BPoint ) *
- ( npoints + 1 ),
- "CurNurb_append1" );
- if( !nurb->bp )
- return ( EXPP_ReturnPyObjError
- ( PyExc_MemoryError,
- "allocation failed" ) );
-
- memmove( nurb->bp, tmp, sizeof( BPoint ) * npoints );
- if( tmp )
- MEM_freeN( tmp );
-
- ++nurb->pntsu;
- /* initialize new BPoint from old */
- memcpy( nurb->bp + npoints, nurb->bp,
- sizeof( BPoint ) );
-
- for( i = 0; i < 4; ++i ) {
- PyObject *item = PySequence_GetItem( value, i );
-
- if (item == NULL)
- return NULL;
-
-
- nurb->bp[npoints].vec[i] = ( float ) PyFloat_AsDouble( item );
- Py_DECREF( item );
- }
-
- if (size >= 5) {
- PyObject *item = PySequence_GetItem( value, 4 );
-
- if (item == NULL)
- return NULL;
+ float xco, yco, zco, wval, tilt=0.0f, radius=1.0f;
+ PyObject *args;
+ BPoint *tmp;
+
+ if (PyTuple_Check(args)) {
+ args= value;
+ }
+ else {
+ args= PySequence_Tuple(value);
+ }
+
+ if (!PyArg_ParseTuple(args, "ffff|ff", &xco, &yco, &zco, &wval, &tilt, &radius)) {
+ return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a sequence of 4 to 6 floats" );
+ }
+
+ if (args != value) {
+ Py_DECREF(args);
+ }
+ tmp = nurb->bp; /* save old pts */
- nurb->bp[npoints].alfa = ( float ) PyFloat_AsDouble( item );
- Py_DECREF( item );
- }
- else {
- nurb->bp[npoints].alfa = 0.0f;
- }
-
- if (size == 6) {
- PyObject *item = PySequence_GetItem( value, 5 );
+ nurb->bp =
+ ( BPoint * ) MEM_mallocN( sizeof( BPoint ) *
+ ( npoints + 1 ),
+ "CurNurb_append1" );
+ if( !nurb->bp )
+ return ( EXPP_ReturnPyObjError
+ ( PyExc_MemoryError,
+ "allocation failed" ) );
- if (item == NULL)
- return NULL;
+ memmove( nurb->bp, tmp, sizeof( BPoint ) * npoints );
+ if( tmp )
+ MEM_freeN( tmp );
- 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 6 floats" );
- }
+ ++nurb->pntsu;
+ /* initialize new BPoint from old */
+ memcpy( nurb->bp + npoints, nurb->bp,
+ sizeof( BPoint ) );
+
+ tmp= nurb->bp+npoints;
+ tmp->vec[0] = xco;
+ tmp->vec[1] = yco;
+ tmp->vec[2] = zco;
+ tmp->vec[3] = wval;
+ tmp->alfa = tilt;
+ tmp->radius = radius;
+ tmp->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 {
/* bail with error */
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a sequence of 4 to 6 floats" );
+ return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a sequence of 4 to 6 floats" );
}
diff --git a/source/blender/python/api2_2x/Curve.c b/source/blender/python/api2_2x/Curve.c
index d1abde19de9..26208e600e6 100644
--- a/source/blender/python/api2_2x/Curve.c
+++ b/source/blender/python/api2_2x/Curve.c
@@ -822,7 +822,6 @@ 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;
@@ -832,7 +831,6 @@ 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); */
}