== Global 'Delete Key' Tool ==
authorJoshua Leung <aligorith@gmail.com>
Sun, 14 Sep 2008 12:41:42 +0000 (12:41 +0000)
committerJoshua Leung <aligorith@gmail.com>
Sun, 14 Sep 2008 12:41:42 +0000 (12:41 +0000)
The 'opposite' of the "Insert Key" tool.
- Use the hotkey Ctrl-Alt-IKEY to activate.
- Only available in 3d-view and buttons window

I've added an extra var to verify_ipo and verify_ipocurve to save having to make another duplicate of that code. Hopefully the gameengine compiles ok with this.

12 files changed:
source/blender/blenkernel/bad_level_call_stubs/stubs.c
source/blender/include/BSE_editipo.h
source/blender/python/api2_2x/Constraint.c
source/blender/python/api2_2x/Object.c
source/blender/src/buttons_object.c
source/blender/src/drawipo.c
source/blender/src/editaction.c
source/blender/src/editipo.c
source/blender/src/editkey.c
source/blender/src/keyframing.c
source/blender/src/toets.c
source/gameengine/Converter/KX_BlenderSceneConverter.cpp

index d7ef5cb54ff471fde4d99fd253486da3b70d0f60..f4beca262d7a97d4c8b389fb7b75fc32ba5c81c3 100644 (file)
@@ -60,7 +60,7 @@ struct EditFace;
 
 char *getIpoCurveName( struct IpoCurve * icu );
 void insert_vert_icu(struct IpoCurve *icu, float x, float y, short fast);
-struct IpoCurve *verify_ipocurve(struct ID *id, short a, char *b, char *d, int e);
+struct IpoCurve *verify_ipocurve(struct ID *id, short a, char *b, char *d, int e, short f);
 void elbeemDebugOut(char *msg);
 void fluidsimSettingsFree(struct FluidsimSettings* sb);
 void fluidsimSettingsCopy(struct FluidsimSettings* sb);
@@ -88,7 +88,7 @@ void insert_vert_icu(struct IpoCurve *icu, float x, float y, short fast)
 }
 
 
-struct IpoCurve *verify_ipocurve(struct ID *id, short a, char *b, char *d, int e)
+struct IpoCurve *verify_ipocurve(struct ID *id, short a, char *b, char *d, int e, short f)
 {
        return 0;
 }
index b7b19a373aa9139bcf707031e19e2e35e1866212..807e338f514fb2f5efe837cba96a9102ac00de58 100644 (file)
@@ -86,8 +86,8 @@ void do_ipo_selectbuttons(void);
 
 
 /* gets ipo curve, creates if needed */
-struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int);
-struct Ipo *verify_ipo(struct ID *, short, char *, char *, char *);
+struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int, short);
+struct Ipo *verify_ipo(struct ID *, short, char *, char *, char *, short);
 int texchannel_to_adrcode(int channel);
 
 
index 156d32d55c0b6fe9c0a538fbec7198748877c0fb..b0b9aa04a087b3a1ac7dd4a1645d5e8c452f60a3 100644 (file)
@@ -442,7 +442,7 @@ static PyObject *Constraint_insertKey( BPy_Constraint * self, PyObject * value )
                return EXPP_ReturnPyObjError( PyExc_RuntimeError,
                                "constraint doesn't belong to anything" );
        }
-       icu= verify_ipocurve((ID *)ob, ID_CO, actname, con->name, NULL, CO_ENFORCE);
+       icu= verify_ipocurve((ID *)ob, ID_CO, actname, con->name, NULL, CO_ENFORCE, 1);
        
        if (!icu)
                return EXPP_ReturnPyObjError( PyExc_RuntimeError,
index a9cbd1c7766e0e747a0b17ce0d0fb57b22ed550f..45d6bfa3c01073645a7a88a5d3dddf13cc85022e 100644 (file)
@@ -2735,7 +2735,7 @@ static PyObject *Object_setConstraintInfluenceForBone( BPy_Object * self,
                                "expects bonename, constraintname, influenceval" );
        
        icu = verify_ipocurve((ID *)self->object, ID_CO, boneName, constName, NULL,
-                       CO_ENFORCE);
+                       CO_ENFORCE, 1);
        
        if (!icu)
                return EXPP_ReturnPyObjError( PyExc_RuntimeError,
index 71e5ff6c10eba4f71305b657626005660ee140c4..c1af6c2d00c944093926ffa4a53acdb8a0954f50 100644 (file)
@@ -242,9 +242,9 @@ static void enable_constraint_ipo_func (void *ob_v, void *con_v)
        
        /* adds ipo & channels & curve if needed */
        if(con->flag & CONSTRAINT_OWN_IPO)
-               verify_ipo((ID *)ob, ID_CO, NULL, con->name, actname);
+               verify_ipo((ID *)ob, ID_CO, NULL, con->name, actname, 1);
        else
-               verify_ipo((ID *)ob, ID_CO, actname, con->name, NULL);
+               verify_ipo((ID *)ob, ID_CO, actname, con->name, NULL, 1);
                
        /* make sure ipowin shows it */
        ob->ipowin= ID_CO;
@@ -269,9 +269,9 @@ static void add_influence_key_to_constraint_func (void *ob_v, void *con_v)
 
        /* adds ipo & channels & curve if needed */
        if(con->flag & CONSTRAINT_OWN_IPO)
-               icu= verify_ipocurve((ID *)ob, ID_CO, NULL, con->name, actname, CO_ENFORCE);
+               icu= verify_ipocurve((ID *)ob, ID_CO, NULL, con->name, actname, CO_ENFORCE, 1);
        else
-               icu= verify_ipocurve((ID *)ob, ID_CO, actname, con->name, NULL, CO_ENFORCE);
+               icu= verify_ipocurve((ID *)ob, ID_CO, actname, con->name, NULL, CO_ENFORCE, 1);
                
        if (!icu) {
                error("Cannot get a curve from this IPO, may be dealing with linked data");
index 87e36c4ad2429b4364a762d5b88852a5601a7adf..ec6a0f0d75b8174be547a8efaef9eaf4b381adb1 100644 (file)
@@ -1952,7 +1952,7 @@ void do_ipobuts(unsigned short event)
                ei= get_active_editipo();
                if(ei) {
                        if(ei->icu==NULL) {
-                               ei->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, G.sipo->bonename, ei->adrcode);
+                               ei->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, G.sipo->bonename, ei->adrcode, 1);
                                if (!ei->icu) {
                                        error("Could not add a driver to this curve, may be linked data!");
                                        break;
index 95a69171bf8bf8ce9cdd63af52cdb2e63a8be883..fe83976ee570d6be9f0e37c7abab81e874be091f 100644 (file)
@@ -2154,7 +2154,7 @@ void paste_actdata ()
                
                /* loop over curves, pasting keyframes */
                for (ico= ipo_src->curve.first; ico; ico= ico->next) {
-                       icu= verify_ipocurve((ID*)ob, ico->blocktype, actname, conname, "", ico->adrcode);
+                       icu= verify_ipocurve((ID*)ob, ico->blocktype, actname, conname, "", ico->adrcode, 1);
                        
                        if (icu) {
                                /* just start pasting, with the the first keyframe on the current frame, and so on */
index e6c7e155a0fe718916d9dea60d1c36a7d08fc5bc..09862636085934d00a1de1f213e142fada15ae3d 100644 (file)
@@ -1777,113 +1777,129 @@ void do_ipo_selectbuttons(void)
    - if bonename, the constname is the ipo to the constraint
 */
 
-/* note; check header_ipo.c, spaceipo_assign_ipo() too */
-Ipo *verify_ipo(ID *from, short blocktype, char *actname, char *constname, char *bonename)
+/* note: check header_ipo.c, spaceipo_assign_ipo() too */
+Ipo *verify_ipo(ID *from, short blocktype, char *actname, char *constname, char *bonename, short add)
 {
-
-       if(from==NULL || from->lib) return NULL;
+       /* lib-linked data is not appropriate here */
+       if ((from==NULL) || (from->lib))
+               return NULL;
        
        /* first check action ipos */
-       if(actname && actname[0]) {
+       if (actname && actname[0]) {
                Object *ob= (Object *)from;
                bActionChannel *achan;
                
-               if(GS(from->name)!=ID_OB) {
+               if (GS(from->name)!=ID_OB) {
                        printf("called ipo system for action with wrong base pointer\n");
                        return NULL;
                }
                
-               if(ob->action==NULL)
+               if ((ob->action==NULL) && (add))
                        ob->action= add_empty_action("Action");
                
-               achan= verify_action_channel(ob->action, actname);
+               if (add)
+                       achan= verify_action_channel(ob->action, actname);
+               else    
+                       achan= get_action_channel(ob->action, actname);
                
-               if(achan) {
+               if (achan) {
                        /* automatically assign achan to act-group based on pchan's grouping */
-                       if (blocktype == ID_PO)
+                       if ((blocktype == ID_PO) && (add))
                                verify_pchan2achan_grouping(ob->action, ob->pose, actname);
                        
                        /* constraint exception */
-                       if(blocktype==ID_CO) {
-                               bConstraintChannel *conchan= verify_constraint_channel(&achan->constraintChannels, constname);
-                               if(conchan->ipo==NULL) {
-                                       conchan->ipo= add_ipo("CoIpo", ID_CO);  
+                       if (blocktype==ID_CO) {
+                               bConstraintChannel *conchan;
+                               
+                               if (add)
+                                       conchan= verify_constraint_channel(&achan->constraintChannels, constname);
+                               else
+                                       conchan= get_constraint_channel(&achan->constraintChannels, constname);
+                                       
+                               if (conchan) {
+                                       if ((conchan->ipo==NULL) && (add))
+                                               conchan->ipo= add_ipo("CoIpo", ID_CO);  
+                                       return conchan->ipo;
                                }
-                               return conchan->ipo;
                        }
                        else {
-                               if(achan->ipo==NULL) {
+                               if ((achan->ipo==NULL) && (add))
                                        achan->ipo= add_ipo("ActIpo", blocktype);
-                               }
-                               
                                return achan->ipo;
                        }
                }
        }
        else {
-               
-               switch(GS(from->name)) {
+               switch (GS(from->name)) {
                case ID_OB:
                        {
                                Object *ob= (Object *)from;
                                
                                /* constraint exception */
-                               if(blocktype==ID_CO) {
+                               if (blocktype==ID_CO) {
                                        /* check the local constraint ipo */
-                                       if(bonename && bonename[0] && ob->pose) {
+                                       if (bonename && bonename[0] && ob->pose) {
                                                bPoseChannel *pchan= get_pose_channel(ob->pose, bonename);
                                                bConstraint *con;
-                                               for(con= pchan->constraints.first; con; con= con->next)
-                                                       if(strcmp(con->name, constname)==0)
+                                               
+                                               for (con= pchan->constraints.first; con; con= con->next) {
+                                                       if (strcmp(con->name, constname)==0)
                                                                break;
-                                               if(con) {
-                                                       if(con->ipo==NULL) {
+                                               }
+                                               
+                                               if (con) {
+                                                       if ((con->ipo==NULL) && (add))
                                                                con->ipo= add_ipo("CoIpo", ID_CO);
-                                                       }
                                                        return con->ipo;
                                                }
                                        }
                                        else { /* the actionchannel */
-                                               bConstraintChannel *conchan= verify_constraint_channel(&ob->constraintChannels, constname);
-                                               if(conchan->ipo==NULL) {
-                                                       conchan->ipo= add_ipo("CoIpo", ID_CO);  
+                                               bConstraintChannel *conchan;
+                                               
+                                               if (add)
+                                                       conchan= verify_constraint_channel(&ob->constraintChannels, constname);
+                                               else
+                                                       conchan= get_constraint_channel(&ob->constraintChannels, constname);
+                                                       
+                                               if (conchan) {
+                                                       if ((conchan->ipo==NULL) && (add))
+                                                               conchan->ipo= add_ipo("CoIpo", ID_CO);  
+                                                       return conchan->ipo;
                                                }
-                                               return conchan->ipo;
                                        }
                                }
-                               else if(blocktype==ID_OB) {
-                                       if(ob->ipo==NULL) {
+                               else if (blocktype==ID_OB) {
+                                       if ((ob->ipo==NULL) && (add))
                                                ob->ipo= add_ipo("ObIpo", ID_OB);
-                                       }
                                        return ob->ipo;
                                }
-                               else if(blocktype==ID_KE) {
+                               else if (blocktype==ID_KE) {
                                        Key *key= ob_get_key((Object *)from);
                                        
-                                       if(key) {
-                                               if(key->ipo==NULL) {
+                                       if (key) {
+                                               if ((key->ipo==NULL) && (add))
                                                        key->ipo= add_ipo("KeyIpo", ID_KE);
-                                               }
                                                return key->ipo;
                                        }
                                        return NULL;
                                }
-                               else if(blocktype== ID_FLUIDSIM) {
+                               else if (blocktype== ID_FLUIDSIM) {
                                        Object *ob= (Object *)from;
-                                       if(ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) {
+                                       
+                                       if (ob->fluidsimFlag & OB_FLUIDSIM_ENABLE) {
                                                FluidsimSettings *fss= ob->fluidsimSettings;
-                                               if(fss->ipo==NULL) {
+                                               
+                                               if ((fss->ipo==NULL) && (add))
                                                        fss->ipo= add_ipo("FluidsimIpo", ID_FLUIDSIM);
-                                                       //fprintf(stderr,"FSIPO NEW!\n");
-                                               }
                                                return fss->ipo;
                                        }
                                }
-                               else if(blocktype== ID_PA){
+                               else if(blocktype== ID_PA) {
                                        Object *ob= (Object *)from;
                                        ParticleSystem *psys= psys_get_current(ob);
-                                       if(psys){
-                                               if(psys->part->ipo==0)
+                                       
+                                       if (psys) {
+                                               if ((psys->part->ipo==NULL) && (add))
                                                        psys->part->ipo= add_ipo("ParticleIpo", ID_PA);
                                                return psys->part->ipo;
                                        }
@@ -1894,30 +1910,27 @@ Ipo *verify_ipo(ID *from, short blocktype, char *actname, char *constname, char
                case ID_MA:
                        {
                                Material *ma= (Material *)from;
-
-                               if(ma->ipo==NULL) {
+                               
+                               if ((ma->ipo==NULL) && (add))
                                        ma->ipo= add_ipo("MatIpo", ID_MA);
-                               }
                                return ma->ipo;
                        }
                        break;
                case ID_TE:
                        {
                                Tex *tex= (Tex *)from;
-
-                               if(tex->ipo==NULL) {
+                               
+                               if ((tex->ipo==NULL) && (add))
                                        tex->ipo= add_ipo("TexIpo", ID_TE);
-                               }
                                return tex->ipo;
                        }
                        break;
                case ID_SEQ:
                        {
                                Sequence *seq= (Sequence *)from;        /* note, sequence is mimicing Id */
-
-                               if(seq->ipo==NULL) {
+                               
+                               if ((seq->ipo==NULL) && (add))
                                        seq->ipo= add_ipo("SeqIpo", ID_SEQ);
-                               }
                                update_seq_ipo_rect(seq);
                                return seq->ipo;
                        }
@@ -1926,19 +1939,17 @@ Ipo *verify_ipo(ID *from, short blocktype, char *actname, char *constname, char
                        {
                                Curve *cu= (Curve *)from;
                                
-                               if(cu->ipo==NULL) {
+                               if ((cu->ipo==NULL) && (add))
                                        cu->ipo= add_ipo("CuIpo", ID_CU);
-                               }
                                return cu->ipo;
                        }
                        break;
                case ID_WO:
                        {
                                World *wo= (World *)from;
-
-                               if(wo->ipo==NULL) {
+                               
+                               if ((wo->ipo==NULL) && (add))
                                        wo->ipo= add_ipo("WoIpo", ID_WO);
-                               }
                                return wo->ipo;
                        }
                        break;
@@ -1946,29 +1957,26 @@ Ipo *verify_ipo(ID *from, short blocktype, char *actname, char *constname, char
                        {
                                Lamp *la= (Lamp *)from;
                                
-                               if(la->ipo==NULL) {
+                               if ((la->ipo==NULL) && (add))
                                        la->ipo= add_ipo("LaIpo", ID_LA);
-                               }
                                return la->ipo;
                        }
                        break;
                case ID_CA:
                        {
                                Camera *ca= (Camera *)from;
-
-                               if(ca->ipo==NULL) {
+                               
+                               if ((ca->ipo==NULL) && (add))
                                        ca->ipo= add_ipo("CaIpo", ID_CA);
-                               }
                                return ca->ipo;
                        }
                        break;
                case ID_SO:
                        {
                                bSound *snd= (bSound *)from;
-
-                               if(snd->ipo==NULL) {
+                               
+                               if ((snd->ipo==NULL) && (add))
                                        snd->ipo= add_ipo("SndIpo", ID_SO);
-                               }
                                return snd->ipo;
                        }
                }
@@ -1980,32 +1988,36 @@ Ipo *verify_ipo(ID *from, short blocktype, char *actname, char *constname, char
 /* returns and creates
  * Make sure functions check for NULL or they will crash!
  *  */
-IpoCurve *verify_ipocurve(ID *from, short blocktype, char *actname, char *constname, char *bonename, int adrcode)
+IpoCurve *verify_ipocurve(ID *from, short blocktype, char *actname, char *constname, char *bonename, int adrcode, short add)
 {
        Ipo *ipo;
        IpoCurve *icu= NULL;
        
        /* return 0 if lib */
-       /* creates ipo too */
-       ipo= verify_ipo(from, blocktype, actname, constname, bonename);
+       /* creates ipo too (if add) */
+       ipo= verify_ipo(from, blocktype, actname, constname, bonename, add);
        
-       if(ipo && ipo->id.lib==NULL && from->lib==NULL) {
-               
-               for(icu= ipo->curve.first; icu; icu= icu->next) {
-                       if(icu->adrcode==adrcode) break;
+       if (ipo && ipo->id.lib==NULL && from->lib==NULL) {
+               /* try to find matching curve */
+               for (icu= ipo->curve.first; icu; icu= icu->next) {
+                       if (icu->adrcode==adrcode) 
+                               break;
                }
-               if(icu==NULL) {
+               
+               /* make a new one if none found (and can add) */
+               if ((icu==NULL) && (add)) {
                        icu= MEM_callocN(sizeof(IpoCurve), "ipocurve");
                        
-                       icu->flag |= IPO_VISIBLE|IPO_AUTO_HORIZ;
-                       if(ipo->curve.first==NULL) icu->flag |= IPO_ACTIVE;     /* first one added active */
+                       icu->flag |= (IPO_VISIBLE|IPO_AUTO_HORIZ);
+                       if (ipo->curve.first==NULL) 
+                               icu->flag |= IPO_ACTIVE;        /* first one added active */
                        
                        icu->blocktype= blocktype;
                        icu->adrcode= adrcode;
                        
                        set_icu_vars(icu);
                        
-                       BLI_addtail( &(ipo->curve), icu);
+                       BLI_addtail(&ipo->curve, icu);
                        
                        switch (GS(from->name)) {
                                case ID_SEQ: {
@@ -2017,7 +2029,8 @@ IpoCurve *verify_ipocurve(ID *from, short blocktype, char *actname, char *constn
                        }
                }
        }
-
+       
+       /* return ipo-curve */
        return icu;
 }
 
@@ -2055,7 +2068,7 @@ void add_vert_ipo(void)
        
        if(ei->icu==NULL) {
                if(G.sipo->from) {
-                       ei->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, G.sipo->bonename, ei->adrcode);
+                       ei->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, G.sipo->bonename, ei->adrcode, 1);
                        if (ei->icu)
                                ei->flag |= ei->icu->flag & IPO_AUTO_HORIZ;     /* new curve could have been added, weak... */
                        else
@@ -3185,7 +3198,7 @@ void paste_editipo(void)
                                int i;
                                
                                /* make sure an ipo-curve exists (it may not, as this is an editipo) */
-                               ei->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, G.sipo->bonename, ei->adrcode);
+                               ei->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, G.sipo->bonename, ei->adrcode, 1);
                                if (ei->icu == NULL) return;
                                
                                /* Copy selected beztriples from source icu onto this edit-icu,
@@ -3226,7 +3239,7 @@ void paste_editipo(void)
                        else  {
                                
                                /* make sure an ipo-curve exists (it may not, as this is an editipo) */
-                               ei->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, G.sipo->bonename, ei->adrcode);
+                               ei->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, G.sipo->bonename, ei->adrcode, 1);
                                if (ei->icu==NULL) return;
                                
                                /* clear exisiting dynamic memory (keyframes, driver) */
@@ -4341,7 +4354,7 @@ void ipo_record(void)
 
        /* make curves ready, start values */
        if(ei1->icu==NULL) 
-               ei1->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, G.sipo->bonename, ei1->adrcode);
+               ei1->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, G.sipo->bonename, ei1->adrcode, 1);
        if(ei1->icu==NULL) return;
        
        poin= get_ipo_poin(G.sipo->from, ei1->icu, &type);
@@ -4351,7 +4364,7 @@ void ipo_record(void)
 
        if(ei2) {
                if(ei2->icu==NULL)
-                       ei2->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, G.sipo->bonename, ei2->adrcode);
+                       ei2->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, G.sipo->bonename, ei2->adrcode, 1);
                if(ei2->icu==NULL) return;
                
                poin= get_ipo_poin(G.sipo->from, ei2->icu, &type);
index cf12e171a9c5c5e3301730c25fc4618d9ec97731..dbabf9d19fb9b3ef3f1aa6534c753ffc0fd488cf 100644 (file)
@@ -171,9 +171,9 @@ static void rvk_slider_func(void *voidob, void *voidkeynum)
 
        /* ipo on action or ob? */
        if(ob->ipoflag & OB_ACTION_KEY)
-               icu = verify_ipocurve(&ob->id, ID_KE, "Shape", NULL, NULL, keynum);
+               icu = verify_ipocurve(&ob->id, ID_KE, "Shape", NULL, NULL, keynum, 1);
        else 
-               icu = verify_ipocurve(&ob->id, ID_KE, NULL, NULL, NULL, keynum);
+               icu = verify_ipocurve(&ob->id, ID_KE, NULL, NULL, NULL, keynum, 1);
 
        if (icu) {
                /* if the ipocurve exists, try to get a bezier
index fd9b19cc3b081c53306166749a300448962fc9be..80d4ebffec9627665ae7adee3df5a12bbdcadb49 100644 (file)
@@ -723,7 +723,7 @@ short insertkey (ID *id, int blocktype, char *actname, char *constname, int adrc
        IpoCurve *icu;
        
        /* get ipo-curve */
-       icu= verify_ipocurve(id, blocktype, actname, constname, NULL, adrcode);
+       icu= verify_ipocurve(id, blocktype, actname, constname, NULL, adrcode, 1);
        
        /* only continue if we have an ipo-curve to add keyframe to */
        if (icu) {
@@ -815,12 +815,58 @@ short insertkey (ID *id, int blocktype, char *actname, char *constname, int adrc
  */
 short deletekey (ID *id, int blocktype, char *actname, char *constname, int adrcode, short flag)
 {
+       Ipo *ipo;
        IpoCurve *icu;
        
-       // locate ipo-curve
-       icu= NULL; // fixme..
+       /* get ipo-curve 
+        * Note: here is one of the places where we don't want new ipo + ipo-curve added!
+        *              so 'add' var must be 0
+        */
+       ipo= verify_ipo(id, blocktype, actname, constname, NULL, 0);
+       icu= verify_ipocurve(id, blocktype, actname, constname, NULL, adrcode, 0);
        
-       // TODO: implement me!
+       /* only continue if we have an ipo-curve to remove keyframes from */
+       if (icu) {
+               BezTriple bezt;
+               float cfra = frame_to_float(CFRA);
+               short found = -1;
+               int i;
+               
+               /* apply special time tweaking */
+               if (GS(id->name) == ID_OB) {
+                       Object *ob= (Object *)id;
+                       
+                       /* apply NLA-scaling (if applicable) */
+                       if (actname && actname[0]) 
+                               cfra= get_action_frame(ob, cfra);
+                       
+                       /* ancient time-offset cruft */
+                       if ( (ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)) ) {
+                               /* actually frametofloat calc again! */
+                               cfra-= give_timeoffset(ob)*G.scene->r.framelen;
+                       }
+               }
+               
+               /* only need to set bezt->vec[1][0], as that's all binarysearch uses */
+               memset(&bezt, 0, sizeof(BezTriple));
+               bezt.vec[1][0]= cfra;
+               
+               /* try to find index of beztriple to get rid of */
+               i = binarysearch_bezt_index(icu->bezt, &bezt, icu->totvert, &found);
+               if (found) {                    
+                       /* delete the key at the index (will sanity check + do recalc afterwards ) */
+                       delete_icu_key(icu, i, 1);
+                       
+                       /* Only delete curve too if there isn't an ipo-driver still hanging around on an empty curve */
+                       if (icu->totvert==0 && icu->driver==NULL) {
+                               BLI_remlink(&ipo->curve, icu);
+                               free_ipo_curve(icu);
+                       }
+                       
+                       /* return success */
+                       return 1;
+               }
+       }
        
        /* return failure */
        return 0;
index 8bd10b7186d26449f2362c1af8f9d4f12005097d..41ee557c9c2499b2e2ecd95b464743efbd8a6619 100644 (file)
@@ -793,6 +793,10 @@ int blenderqread(unsigned short event, short val)
                        ob= OBACT;
 
                        if(G.f & G_SCULPTMODE) return 1;
+                       else if(G.qual==(LR_CTRLKEY|LR_ALTKEY)) {
+                               common_deletekey();
+                               return 0;
+                       }
                        else if(G.qual==0) {
                                common_insertkey();
                                return 0;
index b05893da4e14edaca1789b4d2ea641a7e8cff052..7eec93dc402ee6fa32d1591ecf3e09d2787afed2 100644 (file)
@@ -660,7 +660,7 @@ extern "C"
 {
        Ipo *add_ipo( char *name, int idcode );
        char *getIpoCurveName( IpoCurve * icu );
-       struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int);
+       struct IpoCurve *verify_ipocurve(struct ID *, short, char *, char *, char *, int, short);
        void testhandles_ipocurve(struct IpoCurve *icu);
        void insert_vert_icu(struct IpoCurve *, float, float, short);
        void Mat3ToEul(float tmat[][3], float *eul);
@@ -873,27 +873,27 @@ void      KX_BlenderSceneConverter::WritePhysicsObjectToAnimationIpo(int frameNumber)
 
                                        IpoCurve *icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocX");
                                        if (!icu1)
-                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X);
+                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X, 1);
                                        
                                        icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocY");
                                        if (!icu1)
-                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y);
+                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y, 1);
                                        
                                        icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ");
                                        if (!icu1)
-                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z);
+                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z, 1);
 
                                        icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotX");
                                        if (!icu1)
-                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X);
+                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X, 1);
 
                                        icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotY");
                                        if (!icu1)
-                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y);
+                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y, 1);
 
                                        icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ");
                                        if (!icu1)
-                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z);
+                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z, 1);
 
 
 
@@ -1029,27 +1029,27 @@ void    KX_BlenderSceneConverter::TestHandlesPhysicsObjectToAnimationIpo()
 
                                        IpoCurve *icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocX");
                                        if (!icu1)
-                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X);
+                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_X, 1);
                                        
                                        icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocY");
                                        if (!icu1)
-                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y);
+                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Y, 1);
                                        
                                        icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"LocZ");
                                        if (!icu1)
-                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z);
+                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_LOC_Z, 1);
 
                                        icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotX");
                                        if (!icu1)
-                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X);
+                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_X, 1);
 
                                        icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotY");
                                        if (!icu1)
-                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y);
+                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Y, 1);
 
                                        icu1 = findIpoCurve((IpoCurve *)ipo->curve.first,"RotZ");
                                        if (!icu1)
-                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z);
+                                               icu1 = verify_ipocurve(&blenderObject->id, ipo->blocktype, NULL, NULL, NULL, OB_ROT_Z, 1);