PyAPI - *.insertkey()
authorJoshua Leung <aligorith@gmail.com>
Sat, 20 Sep 2008 10:30:10 +0000 (10:30 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sat, 20 Sep 2008 10:30:10 +0000 (10:30 +0000)
Updated insertkey calls in PyAPI so that they behave like the new common_insertkey() behaviour.

source/blender/python/api2_2x/Camera.c
source/blender/python/api2_2x/Lamp.c
source/blender/python/api2_2x/Material.c
source/blender/python/api2_2x/Object.c
source/blender/python/api2_2x/Pose.c
source/blender/python/api2_2x/World.c

index 87c605ef612a242c02104453703bd52d6eb6be73..af93a1130cb3631e6e40c98005f6c1cc5caadf68 100644 (file)
@@ -36,6 +36,7 @@
 #include "BKE_utildefines.h"
 #include "BLI_blenlib.h"
 #include "BLI_arithb.h" /* for M_PI */
+#include "DNA_userdef_types.h"
 #include "BSE_editipo.h"
 #include "BIF_keyframing.h"
 #include "BIF_space.h"
@@ -1032,18 +1033,21 @@ static PyObject *Camera_repr( BPy_Camera * self )
 
 static PyObject *Camera_insertIpoKey( BPy_Camera * self, PyObject * args )
 {
-       int key = 0;
+       int key = 0, flag = 0;
 
        if( !PyArg_ParseTuple( args, "i", &( key ) ) )
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
                                                                                "expected int argument" ) );
-
+       
+       /* flag should be initialised with the 'autokeying' flags like for normal keying */
+       if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
+       
        if (key == IPOKEY_LENS){
-               insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_LENS, 0);     
+               insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_LENS, flag);     
        }
        else if (key == IPOKEY_CLIPPING){
-               insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_STA, 0);
-               insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_END, 0);   
+               insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_STA, flag);
+               insertkey((ID *)self->camera, ID_CA, NULL, NULL, CAM_END, flag);   
        }
 
        allspace(REMAKEIPO, 0);
index 38968b64cf51a569da080ec165b9848fb0ac8ea1..799833d4ee01cd649cefc95eea70c9b6a5be60ff 100644 (file)
@@ -46,6 +46,7 @@
 #include "gen_utils.h"
 #include "gen_library.h"
 #include "BKE_utildefines.h"
+#include "DNA_userdef_types.h"
 #include "MEM_guardedalloc.h"
 
 /*****************************************************************************/
@@ -1336,7 +1337,7 @@ static int Lamp_setIpo( BPy_Lamp * self, PyObject * value )
 
 static PyObject *Lamp_insertIpoKey( BPy_Lamp * self, PyObject * args )
 {
-       int key = 0, map;
+       int key = 0, flag = 0, map;
 
        if( !PyArg_ParseTuple( args, "i", &( key ) ) )
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
@@ -1344,26 +1345,29 @@ static PyObject *Lamp_insertIpoKey( BPy_Lamp * self, PyObject * args )
 
        map = texchannel_to_adrcode(self->lamp->texact);
 
+       /* flag should be initialised with the 'autokeying' flags like for normal keying */
+       if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
+       
        if (key == IPOKEY_RGB ) {
-               insertkey((ID *)self->lamp, ID_LA, NULL, NULL, LA_COL_R, 0);
-               insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_COL_G, 0);
-               insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_COL_B, 0);
+               insertkey((ID *)self->lamp, ID_LA, NULL, NULL, LA_COL_R, flag);
+               insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_COL_G, flag);
+               insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_COL_B, flag);
        }
        if (key == IPOKEY_ENERGY ) {
-               insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_ENERGY, 0);
+               insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_ENERGY, flag);
        }       
        if (key == IPOKEY_SPOTSIZE ) {
-               insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_SPOTSI, 0);
+               insertkey((ID *)self->lamp, ID_LA, NULL, NULL,LA_SPOTSI, flag);
        }
        if (key == IPOKEY_OFFSET ) {
-               insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_OFS_X, 0);
-               insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_OFS_Y, 0);
-               insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_OFS_Z, 0);
+               insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_OFS_X, flag);
+               insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_OFS_Y, flag);
+               insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_OFS_Z, flag);
        }
        if (key == IPOKEY_SIZE ) {
-               insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_SIZE_X, 0);
-               insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_SIZE_Y, 0);
-               insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_SIZE_Z, 0);
+               insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_SIZE_X, flag);
+               insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_SIZE_Y, flag);
+               insertkey((ID *)self->lamp, ID_LA, NULL, NULL, map+MAP_SIZE_Z, flag);
        }
 
        allspace(REMAKEIPO, 0);
index b118bdb30e734296e54b8c064b6c7a68a0520cb5..d3bb6c8d15867fcab5df34fc6b9004b4a88280f3 100644 (file)
@@ -32,6 +32,7 @@
 
 #include "DNA_space_types.h"
 #include "DNA_material_types.h"
+#include "DNA_userdef_types.h"
 #include "BKE_main.h"
 #include "BKE_global.h"
 #include "BKE_library.h"
@@ -1873,7 +1874,7 @@ static int Material_setIpo( BPy_Material * self, PyObject * value )
 
 static PyObject *Material_insertIpoKey( BPy_Material * self, PyObject * args )
 {
-    int key = 0, map;
+    int key = 0, flag = 0, map;
     
        if( !PyArg_ParseTuple( args, "i", &( key ) ) )
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
@@ -1881,59 +1882,62 @@ static PyObject *Material_insertIpoKey( BPy_Material * self, PyObject * args )
                                
        map = texchannel_to_adrcode(self->material->texact);
        
+       /* flag should be initialised with the 'autokeying' flags like for normal keying */
+       if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
+       
        if(key==IPOKEY_RGB || key==IPOKEY_ALLCOLOR) {
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_R, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_G, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_B, 0);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_R, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_G, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_COL_B, flag);
        }
        if(key==IPOKEY_ALPHA || key==IPOKEY_ALLCOLOR) {
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_ALPHA, 0);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_ALPHA, flag);
        }
        if(key==IPOKEY_HALOSIZE || key==IPOKEY_ALLCOLOR) {
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_HASIZE, 0);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_HASIZE, flag);
        }
        if(key==IPOKEY_MODE || key==IPOKEY_ALLCOLOR) {
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_MODE, 0);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_MODE, flag);
        }
        if(key==IPOKEY_ALLCOLOR) {
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_R, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_G, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_B, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_REF, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_EMIT, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_AMB, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_HARD, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_MODE, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_TRANSLU, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_ADD, 0);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_R, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_G, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC_B, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_REF, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_EMIT, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_AMB, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_SPEC, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_HARD, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_MODE, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_TRANSLU, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_ADD, flag);
        }
        if(key==IPOKEY_ALLMIRROR) {
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_RAYM, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESMIR, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESMIRI, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESTRA, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESTRAI, 0);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_RAYM, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESMIR, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESMIRI, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESTRA, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, MA_FRESTRAI, flag);
        }
        if(key==IPOKEY_OFS || key==IPOKEY_ALLMAPPING) {
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_X, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_Y, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_Z, 0);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_X, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_Y, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_OFS_Z, flag);
        }
        if(key==IPOKEY_SIZE || key==IPOKEY_ALLMAPPING) {
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_X, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_Y, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_Z, 0);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_X, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_Y, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_SIZE_Z, flag);
        }
        if(key==IPOKEY_ALLMAPPING) {
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_R, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_G, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_B, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_DVAR, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_COLF, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_NORF, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_VARF, 0);
-               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_DISP, 0);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_R, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_G, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_B, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_DVAR, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_COLF, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_NORF, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_VARF, flag);
+               insertkey((ID *)self->material, ID_MA, NULL, NULL, map+MAP_DISP, flag);
        }
 
        allspace(REMAKEIPO, 0);
index e8f45b82da4c3bb39a006089eb9f40057d76b451..5151fae8c65a2c57ddec013d4ba5214c96ebad4f 100644 (file)
@@ -2568,7 +2568,7 @@ static int Object_setMatrix( BPy_Object * self, MatrixObject * mat )
 static PyObject *Object_insertIpoKey( BPy_Object * self, PyObject * args )
 {
        Object *ob= self->object;
-       int key = 0;
+       int key = 0, flag = 0;
        char *actname= NULL;
 
        if( !PyArg_ParseTuple( args, "i", &key ) )
@@ -2578,35 +2578,39 @@ static PyObject *Object_insertIpoKey( BPy_Object * self, PyObject * args )
        if(ob->ipoflag & OB_ACTION_OB)
                actname= "Object";
        
+       /* flag should be initialised with the 'autokeying' flags like for normal keying */
+       if (IS_AUTOKEY_FLAG(AUTOMATKEY)) flag |= INSERTKEY_MATRIX;
+       if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
+       
        if (key == IPOKEY_LOC || key == IPOKEY_LOCROT || key == IPOKEY_LOCROTSIZE){
-               insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_X, 0);
-               insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_Y, 0);
-               insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_Z, 0);      
+               insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_X, flag);
+               insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_Y, flag);
+               insertkey((ID *)ob, ID_OB, actname, NULL,OB_LOC_Z, flag);      
        }
        if (key == IPOKEY_ROT || key == IPOKEY_LOCROT || key == IPOKEY_LOCROTSIZE){
-               insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_X, 0);
-               insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_Y, 0);
-               insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_Z, 0);      
+               insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_X, flag);
+               insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_Y, flag);
+               insertkey((ID *)ob, ID_OB, actname, NULL,OB_ROT_Z, flag);      
        }
        if (key == IPOKEY_SIZE || key == IPOKEY_LOCROTSIZE ){
-               insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_X, 0);
-               insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_Y, 0);
-               insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_Z, 0);      
+               insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_X, flag);
+               insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_Y, flag);
+               insertkey((ID *)ob, ID_OB, actname, NULL,OB_SIZE_Z, flag);      
        }
        if (key == IPOKEY_LAYER ){
-               insertkey((ID *)ob, ID_OB, actname, NULL,OB_LAY, 0);
+               insertkey((ID *)ob, ID_OB, actname, NULL,OB_LAY, flag);
        }
 
        if (key == IPOKEY_PI_STRENGTH ){
-               insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_FSTR, 0);   
+               insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_FSTR, flag);   
        } else if (key == IPOKEY_PI_FALLOFF ){
-               insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_FFALL, 0);   
+               insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_FFALL, flag);   
        } else if (key == IPOKEY_PI_SURFACEDAMP ){
-               insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_SDAMP, 0);   
+               insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_SDAMP, flag);   
        } else if (key == IPOKEY_PI_RANDOMDAMP ){
-               insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_RDAMP, 0);   
+               insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_RDAMP, flag);   
        } else if (key == IPOKEY_PI_PERM ){
-               insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_PERM, 0);   
+               insertkey((ID *)ob, ID_OB, actname, NULL, OB_PD_PERM, flag);   
        }
 
        allspace(REMAKEIPO, 0);
@@ -2630,6 +2634,7 @@ static PyObject *Object_insertPoseKey( BPy_Object * self, PyObject * args )
        BPy_Action *sourceact;
        char *chanName;
        int actframe;
+       int flag=0;
 
 
        /* for doing the time trick, similar to editaction bake_action_with_client() */
@@ -2648,17 +2653,21 @@ static PyObject *Object_insertPoseKey( BPy_Object * self, PyObject * args )
 
        /* XXX: must check chanName actually exists, otherwise segfaults! */
        //achan = get_action_channel(sourceact->action, chanName);
-
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_W, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z, 0);
+       
+       /* flag should be initialised with the 'autokeying' flags like for normal keying */
+       if (IS_AUTOKEY_FLAG(AUTOMATKEY)) flag |= INSERTKEY_MATRIX;
+       if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
+
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_W, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z, flag);
        
        G.scene->r.cfra = oldframe;
 
@@ -2680,6 +2689,7 @@ static PyObject *Object_insertPoseKey( BPy_Object * self, PyObject * args )
 static PyObject *Object_insertCurrentPoseKey( BPy_Object * self, PyObject * args )
 {
        Object *ob= self->object;
+       int flag = 0;
        char *chanName;
 
        /* for doing the time trick, similar to editaction bake_action_with_client() */
@@ -2695,16 +2705,20 @@ static PyObject *Object_insertCurrentPoseKey( BPy_Object * self, PyObject * args
 
        /* XXX: must check chanName actually exists, otherwise segfaults! */
 
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_W, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y, 0);
-       insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z, 0);
+       /* flag should be initialised with the 'autokeying' flags like for normal keying */
+       if (IS_AUTOKEY_FLAG(AUTOMATKEY)) flag |= INSERTKEY_MATRIX;
+       if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
+       
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_X, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Y, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_LOC_Z, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_X, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Y, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_Z, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_QUAT_W, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_X, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Y, flag);
+       insertkey(&ob->id, ID_PO, chanName, NULL, AC_SIZE_Z, flag);
 
        G.scene->r.cfra = oldframe;
 
index 52ede1cb3eec09de33501b93427413c95582c8c2..06d736f2cb61e1cf5a739433da71a7412508ad09 100644 (file)
@@ -414,16 +414,17 @@ static PyObject *PoseBone_insertKey(BPy_PoseBone *self, PyObject *args)
 {
        PyObject *parent_object = NULL;
        PyObject *constants = NULL, *item = NULL;
-       int frame = 1, oldframe, length, x, numeric_value = 0, oldflag, no_ipo_update = 0;
+       int frame = 1, oldframe, length, x, numeric_value = 0, oldflag, no_ipo_update = 0, flag = 0;
        bPoseChannel *pchan = NULL;
        
 
        if (!PyArg_ParseTuple(args, "O!i|Oi", &Object_Type, &parent_object, &frame, &constants, &no_ipo_update ))
                goto AttributeError;
        
-       /* incase we ever have a value other then 1 for fast */
-       if (no_ipo_update)
-               no_ipo_update = 1;
+       /* flag should be initialised with the 'autokeying' flags like for normal keying */
+       if (no_ipo_update) flag |= INSERTKEY_FAST;
+       if (IS_AUTOKEY_FLAG(AUTOMATKEY)) flag |= INSERTKEY_MATRIX;
+       if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
        
        //verify that this pchannel is part of the object->pose
        for (pchan = ((BPy_Object*)parent_object)->object->pose->chanbase.first; 
@@ -493,29 +494,29 @@ static PyObject *PoseBone_insertKey(BPy_PoseBone *self, PyObject *args)
        //insert the pose keys
        if (self->posechannel->flag & POSE_ROT){
                insertkey(&((BPy_Object*)parent_object)->object->id, 
-                       ID_PO, self->posechannel->name, NULL, AC_QUAT_X, no_ipo_update);
+                       ID_PO, self->posechannel->name, NULL, AC_QUAT_X, flag);
                insertkey(&((BPy_Object*)parent_object)->object->id, 
-                       ID_PO, self->posechannel->name, NULL, AC_QUAT_Y, no_ipo_update);
+                       ID_PO, self->posechannel->name, NULL, AC_QUAT_Y, flag);
                insertkey(&((BPy_Object*)parent_object)->object->id, 
-                       ID_PO, self->posechannel->name, NULL, AC_QUAT_Z, no_ipo_update);
+                       ID_PO, self->posechannel->name, NULL, AC_QUAT_Z, flag);
                insertkey(&((BPy_Object*)parent_object)->object->id, 
-                       ID_PO, self->posechannel->name, NULL, AC_QUAT_W, no_ipo_update);
+                       ID_PO, self->posechannel->name, NULL, AC_QUAT_W, flag);
        }
        if (self->posechannel->flag & POSE_LOC){
                insertkey(&((BPy_Object*)parent_object)->object->id, 
-                       ID_PO, self->posechannel->name, NULL, AC_LOC_X, no_ipo_update);
+                       ID_PO, self->posechannel->name, NULL, AC_LOC_X, flag);
                insertkey(&((BPy_Object*)parent_object)->object->id, 
-                       ID_PO, self->posechannel->name, NULL, AC_LOC_Y, no_ipo_update);
+                       ID_PO, self->posechannel->name, NULL, AC_LOC_Y, flag);
                insertkey(&((BPy_Object*)parent_object)->object->id, 
-                       ID_PO, self->posechannel->name, NULL, AC_LOC_Z, no_ipo_update);
+                       ID_PO, self->posechannel->name, NULL, AC_LOC_Z, flag);
        }
        if (self->posechannel->flag & POSE_SIZE){
                insertkey(&((BPy_Object*)parent_object)->object->id, 
-                       ID_PO, self->posechannel->name, NULL, AC_SIZE_X, no_ipo_update);
+                       ID_PO, self->posechannel->name, NULL, AC_SIZE_X, flag);
                insertkey(&((BPy_Object*)parent_object)->object->id, 
-                       ID_PO, self->posechannel->name, NULL, AC_SIZE_Y, no_ipo_update);
+                       ID_PO, self->posechannel->name, NULL, AC_SIZE_Y, flag);
                insertkey(&((BPy_Object*)parent_object)->object->id, 
-                       ID_PO, self->posechannel->name, NULL, AC_SIZE_Z, no_ipo_update);
+                       ID_PO, self->posechannel->name, NULL, AC_SIZE_Z, flag);
        }
 
        //flip the frame back
index 0c57488a2664cb629e551cde0f5cd69cece7c59a..354d8cda0b79dfa5be28be51f78291de89cb1491 100644 (file)
@@ -43,6 +43,7 @@
 #include "World.h"  /*This must come first*/
 
 #include "DNA_scene_types.h"  /* for G.scene */
+#include "DNA_userdef_types.h"
 #include "BKE_global.h"
 #include "BKE_world.h"
 #include "BKE_main.h"
@@ -988,7 +989,7 @@ World *World_FromPyObject( PyObject * py_obj )
 
 static PyObject *World_insertIpoKey( BPy_World * self, PyObject * args )
 {
-       int key = 0, map;
+       int key = 0, flag = 0, map;
 
        if( !PyArg_ParseTuple( args, "i", &( key ) ) )
                return ( EXPP_ReturnPyObjError( PyExc_AttributeError,
@@ -996,38 +997,41 @@ static PyObject *World_insertIpoKey( BPy_World * self, PyObject * args )
 
        map = texchannel_to_adrcode(self->world->texact);
 
+       /* flag should be initialised with the 'autokeying' flags like for normal keying */
+       if (IS_AUTOKEY_FLAG(INSERTNEEDED)) flag |= INSERTKEY_NEEDED;
+       
        if(key == IPOKEY_ZENITH) {
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_ZEN_R, 0);
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_ZEN_G, 0);
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_ZEN_B, 0);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_ZEN_R, flag);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_ZEN_G, flag);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_ZEN_B, flag);
        }
        if(key == IPOKEY_HORIZON) {
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_HOR_R, 0);
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_HOR_G, 0);
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_HOR_B, 0);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_HOR_R, flag);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_HOR_G, flag);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_HOR_B, flag);
        }
        if(key == IPOKEY_MIST) {
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISI, 0);
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISTDI, 0);
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISTSTA, 0);
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISTHI, 0);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISI, flag);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISTDI, flag);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISTSTA, flag);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_MISTHI, flag);
        }
        if(key == IPOKEY_STARS) {
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STAR_R, 0);
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STAR_G, 0);
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STAR_B, 0);
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STARDIST, 0);
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STARSIZE, 0);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STAR_R, flag);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STAR_G, flag);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STAR_B, flag);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STARDIST, flag);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, WO_STARSIZE, flag);
        }
        if(key == IPOKEY_OFFSET) {
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_OFS_X, 0);
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_OFS_Y, 0);
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_OFS_Z, 0);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_OFS_X, flag);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_OFS_Y, flag);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_OFS_Z, flag);
        }
        if(key == IPOKEY_SIZE) {
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_SIZE_X, 0);
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_SIZE_Y, 0);
-               insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_SIZE_Z, 0);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_SIZE_X, flag);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_SIZE_Y, flag);
+               insertkey((ID *)self->world, ID_WO, NULL, NULL, map+MAP_SIZE_Z, flag);
        }
 
        allspace(REMAKEIPO, 0);