diff options
author | Joshua Leung <aligorith@gmail.com> | 2007-11-08 12:49:49 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2007-11-08 12:49:49 +0300 |
commit | 0100ebe2302d5ed36c4f4258e779e81a7e7bec66 (patch) | |
tree | 255dd1f8c06925cb7a7b5f86f364ccc4603ca856 /source/blender/python/api2_2x/Constraint.c | |
parent | 45f72036a55b4a1411b43080749cab8dc0ed4145 (diff) |
Bugfix #7682: Constraint.InsertKey works odd for PoseBones
Constraint.InsertKey was inserting keyframes for the wrong action-channel. It was doing so for the active bone, not the owner of the constraint.
Diffstat (limited to 'source/blender/python/api2_2x/Constraint.c')
-rw-r--r-- | source/blender/python/api2_2x/Constraint.c | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/source/blender/python/api2_2x/Constraint.c b/source/blender/python/api2_2x/Constraint.c index 1836c0c6bc2..749e05426bd 100644 --- a/source/blender/python/api2_2x/Constraint.c +++ b/source/blender/python/api2_2x/Constraint.c @@ -409,12 +409,13 @@ static PyObject *Constraint_getType( BPy_Constraint * self ) */ static PyObject *Constraint_insertKey( BPy_Constraint * self, PyObject * value ) { + bConstraint *con = self->con; + Object *ob = self->obj; + bPoseChannel *pchan = self->pchan; IpoCurve *icu; float cfra = (float)PyFloat_AsDouble(value); char actname[32] = ""; - Object *ob = self->obj; - bConstraint *con = self->con; - + if( !self->con ) return EXPP_ReturnPyObjError( PyExc_RuntimeError, "This constraint has been removed!" ); @@ -423,9 +424,22 @@ static PyObject *Constraint_insertKey( BPy_Constraint * self, PyObject * value ) if( PyFloat_Check(value) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a float argument" ); - - /* constraint_active_func(ob_v, con_v); */ - get_constraint_ipo_context( ob, actname ); + + /* find actname for locating that action-channel that a constraint channel should be added to */ + if (ob) { + if (pchan) { + /* actname is the name of the pchan that this constraint belongs to */ + BLI_strncpy(actname, pchan->name, 32); + } + else { + /* hardcoded achan name -> "Object" (this may change in future) */ + strcpy(actname, "Object"); + } + } + else { + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "constraint doesn't belong to anything" ); + } icu= verify_ipocurve((ID *)ob, ID_CO, actname, con->name, CO_ENFORCE); if (!icu) |