-- Bugfix #3617; addBezier() was not initializing all the attributes for
a the beztriple, so things like the hidden and handle select states were set to random values. Added a beztriple.hide attribute so that the hide attribute can be set/cleared from the BPy API.
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
*/
|
||||
|
||||
#include "BezTriple.h" /*This must come first */
|
||||
#include "DNA_ipo_types.h"
|
||||
|
||||
#include "MEM_guardedalloc.h"
|
||||
#include "gen_utils.h"
|
||||
@@ -303,6 +304,8 @@ static PyObject *BezTripleGetAttr( BPy_BezTriple * self, char *name )
|
||||
return BezTriple_getTriple( self );
|
||||
else if( strcmp( name, "tilt" ) == 0 )
|
||||
return PyFloat_FromDouble(self->beztriple->alfa);
|
||||
else if( strcmp( name, "hide" ) == 0 )
|
||||
return PyFloat_FromDouble(self->beztriple->hide);
|
||||
else if( strcmp( name, "__members__" ) == 0 )
|
||||
return Py_BuildValue( "[s,s,s]", "pt", "vec", "tilt" );
|
||||
|
||||
@@ -329,7 +332,17 @@ static int BezTripleSetAttr( BPy_BezTriple * self, char *name, PyObject * value
|
||||
|
||||
return 0; /* normal exit */
|
||||
#endif
|
||||
if( strcmp( name, "tilt" ) == 0 ) {
|
||||
if( !strcmp( name, "hide" ) ) {
|
||||
int param;
|
||||
if( !PyInt_CheckExact( value ) )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError,
|
||||
"expected int argument" );
|
||||
|
||||
param = (int)PyInt_AS_LONG( value );
|
||||
self->beztriple->hide = (param == 0) ? 0 : IPO_BEZ;
|
||||
return 0;
|
||||
}
|
||||
if( !strcmp( name, "tilt" ) ) {
|
||||
if (!PyFloat_Check( value ) )
|
||||
return EXPP_ReturnIntError( PyExc_TypeError, "expected a float" );
|
||||
|
||||
@@ -337,8 +350,8 @@ static int BezTripleSetAttr( BPy_BezTriple * self, char *name, PyObject * value
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ( EXPP_ReturnIntError( PyExc_AttributeError,
|
||||
"cannot set a read-only attribute" ) );
|
||||
return EXPP_ReturnIntError( PyExc_AttributeError,
|
||||
"cannot set a read-only attribute" );
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
@@ -356,12 +369,11 @@ static PyObject *BezTripleRepr( BPy_BezTriple * self )
|
||||
*/
|
||||
char str[1000];
|
||||
sprintf( str,
|
||||
"BezTriple %f %f %f %f %f %f %f %f %f %f\n %d %d %d %d %d %d\n",
|
||||
"BezTriple (%f %f) (%f %f) (%f %f) %f\n (%d %d %d) (%d %d) %d\n",
|
||||
self->beztriple->vec[0][0], self->beztriple->vec[0][1],
|
||||
self->beztriple->vec[0][2], self->beztriple->vec[1][0],
|
||||
self->beztriple->vec[1][1], self->beztriple->vec[1][2],
|
||||
self->beztriple->vec[1][0], self->beztriple->vec[1][1],
|
||||
self->beztriple->vec[2][0], self->beztriple->vec[2][1],
|
||||
self->beztriple->vec[2][2], self->beztriple->alfa,
|
||||
self->beztriple->alfa,
|
||||
self->beztriple->h1, self->beztriple->h2, self->beztriple->f1,
|
||||
self->beztriple->f2, self->beztriple->f3,
|
||||
self->beztriple->hide );
|
||||
|
@@ -405,9 +405,11 @@ static PyObject *IpoCurve_addBezier( C_IpoCurve * self, PyObject * args )
|
||||
bzt->vec[0][1] = y - 1;
|
||||
bzt->vec[1][1] = y;
|
||||
bzt->vec[2][1] = y + 1;
|
||||
bzt->vec[0][2] = bzt->vec[1][2] = bzt->vec[2][2] = 0.0;
|
||||
/* set handle type to Auto */
|
||||
bzt->h1 = HD_AUTO;
|
||||
bzt->h2 = HD_AUTO;
|
||||
bzt->h1 = bzt->h2 = HD_AUTO;
|
||||
bzt->f1 = bzt->f2 = bzt->f3= 0;
|
||||
bzt->hide = IPO_BEZ;
|
||||
|
||||
Py_INCREF( Py_None );
|
||||
return Py_None;
|
||||
|
@@ -402,8 +402,12 @@ class BezTriple:
|
||||
The BezTriple object
|
||||
====================
|
||||
This object gives access to generic data from all beztriple objects in Blender. If an attribute is listed as being 'read-only' that means you cannot write to it. Use the set*() methods instead.
|
||||
@ivar pt : a list of the [x,y] coordinates for knot point of this BezTriple. read-only.
|
||||
@ivar vec : a list of the 3 points [ handle, knot, handle ] that comprise a BezTriple. See the getTriple() method for an example of the format. read-only.
|
||||
@ivar pt : the [x,y] coordinates for knot point of this BezTriple. Read-only.
|
||||
@type pt: list of floats
|
||||
@ivar vec : a list of the 3 points [ handle, knot, handle ] that comprise a BezTriple. See the getTriple() method for an example of the format. Read-only.
|
||||
@type vec: list of points
|
||||
@ivar hide: the visibility status of the control point.
|
||||
@type hide: int
|
||||
"""
|
||||
|
||||
def getPoints():
|
||||
|
Reference in New Issue
Block a user