Page Menu
Home
Search
Configure Global Search
Log In
Files
F2632
stage4-patch-Ipo.c-p2
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Ken Hughes (khughes)
Nov 13 2013, 1:05 PM
Size
3 KB
Subscribers
None
stage4-patch-Ipo.c-p2
View Options
--- source/blender/python/api2_2x/Ipo.c 2005-07-08 09:39:14.000000000 -0700
+++ source/blender/python/api2_2x/Ipo.c 2005-07-10 08:10:00.000000000 -0700
@@ -790,7 +790,8 @@
if ( str ) {
BPy_constant *obj = (BPy_constant *)Ipo_checkCurveTypes ( self, str );
if (!obj)
- return EXPP_incr_ret ( Py_None );
+ return EXPP_ReturnPyObjError ( PyExc_ValueError,
+ "invalid curve name" );
param = PyInt_AS_LONG( PyDict_GetItemString( obj->dict, "value" ) );
Py_DECREF (obj);
}
@@ -840,15 +841,51 @@
static
int Ipo_setItem( BPy_Ipo *self, PyObject *key, PyObject *value )
{
- char * strname = PyString_AsString ( key );
IpoCurve *icu;
+ int param = 0;
+ int mask = MA_MAP1-1; /* used to figure out range for adr_code */
+
+#if BLENDER_VERSION < 241
+ static int depcount=2;
+ char * str = NULL;
+
+ /* check for string argument */
+
+ if ( PyString_Check ( key ) ) {
+ str = PyString_AS_STRING ( key );
+ if ( depcount ) {
+ printf ("Using ipo[] with a string key is deprecated by module constants.\n");
+ printf (" This will throw an exception after version 2.40.\n");
+ --depcount;
+ }
+ } else if ( BPy_Constant_Check(key) )
+ param = PyInt_AS_LONG( PyDict_GetItemString(
+ ((BPy_constant *)key)->dict, "value"));
+ else
+ return EXPP_ReturnIntError
+ ( PyExc_TypeError, "expected string or module constant" );
/*
- * if PyString_AsString returns NULL. key wasn't a string
+ * is str is not NULL, get adr_code from corresponding dictionary
+ * (return None if string not found).
*/
- if ( !strname )
- return -1;
+ if ( str ) {
+ BPy_constant *obj = (BPy_constant *)Ipo_checkCurveTypes ( self, str );
+ if (!obj)
+ return EXPP_ReturnIntError ( PyExc_ValueError,
+ "invalid curve name" );
+ param = PyInt_AS_LONG( PyDict_GetItemString( obj->dict, "value" ) );
+ Py_DECREF (obj);
+ }
+#else
+ if ( !BPy_Constant_Check(key) )
+ return EXPP_ReturnPyObjError
+ ( PyExc_TypeError, "expected module constant" );
+
+ param = PyInt_AS_LONG( PyDict_GetItemString(
+ ((BPy_constant *)key)->dict, "value"));
+#endif
/*
* currently only deletion is supported, so if we get an
@@ -860,23 +897,47 @@
"cannot set IPO curves" );
/*
- * search curve list for a match, delete if found
+ * since largest curve for Keys is larger than MA_MAP1,
+ * adjust the mask if this is a Key IPO
+ */
+
+ if ( self->ipo->blocktype == ID_KE )
+ mask = 127;
+
+ /*
+ * search curve list for a match
*/
for( icu = self->ipo->curve.first; icu; icu = icu->next ) {
- char *str1 = getIpoCurveName( icu );
- if( !strcmp( str1, strname ) ) {
- BLI_remlink( &( self->ipo->curve ), icu );
- if( icu->bezt )
- MEM_freeN( icu->bezt );
- MEM_freeN( icu );
- allspace( REMAKEIPO, 0 );
- EXPP_allqueue( REDRAWIPO, 0 );
- return 0;
+ if ( ( icu->adrcode & mask ) == param ) {
+#ifdef TEXCHANNELS
+ if ( icu->adrcode <= mask ) { /* not texture channel */
+ if ( !self->channel ) /* no channel specified */
+ break;
+ else
+ return EXPP_ReturnIntError ( PyExc_ValueError,
+ "texture channel value specified for non-texchannel curve" );
+ } else if ( self->channel & icu->adrcode ) /* texture channel matches */
+#endif
+ break;
}
}
/*
+ * if icu pointing at a curve, delete that curve
+ */
+
+ if ( icu ) {
+ if( icu->bezt )
+ MEM_freeN( icu->bezt );
+ BLI_remlink( &( self->ipo->curve ), icu );
+ MEM_freeN( icu );
+ allspace( REMAKEIPO, 0 );
+ EXPP_allqueue( REDRAWIPO, 0 );
+ return 0;
+ }
+
+ /*
* no match; error
*/
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
02/d6/fcd08eeba29aaec1e46daccc443e
Event Timeline
Log In to Comment