4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
21 * All rights reserved.
23 * Contributor(s): Blender Foundation, 2005. Full recode.
24 * Roland Hess, 2007. Visual Key refactor.
26 * ***** END GPL LICENSE BLOCK *****
30 /* this code feels over-complex, mostly because I choose in the past to devise a system
31 that converts the Ipo blocks (linked to Object, Material, etc), into a copy of that
32 data which is being worked on; the 'editipo'.
33 The editipo then can have 'ipokey' data, which is optimized for editing curves as if
34 it were key positions. This is still a great feature to work with, which makes ipo editing
35 in Blender still valuable. However, getting this beast under control was hard, even
47 #include "MEM_guardedalloc.h"
50 #include "BLI_blenlib.h"
51 #include "BLI_arithb.h"
53 #include "DNA_constraint_types.h"
54 #include "DNA_action_types.h"
55 #include "DNA_armature_types.h"
56 #include "DNA_camera_types.h"
57 #include "DNA_curve_types.h"
58 #include "DNA_group_types.h"
59 #include "DNA_ipo_types.h"
60 #include "DNA_key_types.h"
61 #include "DNA_lamp_types.h"
62 #include "DNA_material_types.h"
63 #include "DNA_modifier_types.h"
64 #include "DNA_object_types.h"
65 #include "DNA_object_fluidsim.h"
66 #include "DNA_particle_types.h"
67 #include "DNA_screen_types.h"
68 #include "DNA_scene_types.h"
69 #include "DNA_space_types.h"
70 #include "DNA_sequence_types.h"
71 #include "DNA_sound_types.h"
72 #include "DNA_texture_types.h"
73 #include "DNA_userdef_types.h"
74 #include "DNA_view3d_types.h"
75 #include "DNA_world_types.h"
77 #include "BKE_action.h"
78 #include "BKE_armature.h"
80 #include "BKE_constraint.h"
81 #include "BKE_depsgraph.h"
82 #include "BKE_global.h"
83 #include "BKE_group.h"
87 #include "BKE_material.h"
88 #include "BKE_modifier.h"
89 #include "BKE_particle.h"
90 #include "BKE_texture.h"
91 #include "BKE_utildefines.h"
92 #include "BKE_object.h"
94 #include "BIF_butspace.h"
95 #include "BIF_editaction.h"
96 #include "BIF_editconstraint.h"
97 #include "BIF_editkey.h"
98 #include "BIF_editnla.h"
99 #include "BIF_editseq.h"
100 #include "BIF_editview.h"
101 #include "BIF_interface.h"
102 #include "BIF_keyframing.h"
103 #include "BIF_mywindow.h"
104 #include "BIF_poseobject.h"
105 #include "BIF_screen.h"
106 #include "BIF_space.h"
107 #include "BIF_toolbox.h"
108 #include "BIF_poseobject.h"
110 #include "BDR_drawobject.h"
111 #include "BDR_editobject.h"
112 #include "BDR_editcurve.h" // for bezt_compare
114 #include "BSE_trans_types.h"
115 #include "BSE_editipo_types.h"
116 #include "BSE_drawipo.h"
117 #include "BSE_editipo.h"
118 #include "BSE_edit.h"
119 #include "BSE_drawview.h"
120 #include "BSE_headerbuttons.h"
121 #include "BSE_node.h"
122 #include "BSE_sequence.h"
123 #include "BSE_seqaudio.h"
124 #include "BSE_time.h"
127 #include "mydevice.h"
128 #include "transform.h"
141 extern int fluidsim_ar[]; // NT
142 extern int part_ar[];
145 #define IPOTHRESH 0.9
147 /* tests if only one editipo is active */
148 static void check_active_editipo(void)
153 actei= G.sipo->editipo;
155 for(a=0; a<G.sipo->totipo; a++, actei++) {
156 if(actei->flag & IPO_ACTIVE)
160 /* set visible active */
161 for(a=0, ei=G.sipo->editipo; a<G.sipo->totipo; a++, ei++) {
162 if(ei->flag & IPO_VISIBLE)
165 if(ei==NULL) ei=G.sipo->editipo;
166 ei->flag |= IPO_ACTIVE;
167 if(ei->icu) ei->icu->flag |= IPO_ACTIVE;
170 /* make sure no others are active */
171 for(a=0, ei=G.sipo->editipo; a<G.sipo->totipo; a++, ei++) {
173 ei->flag &= ~IPO_ACTIVE;
174 if(ei->icu) ei->icu->flag &= ~IPO_ACTIVE;
181 /* sets this ei channel active */
182 static void set_active_editipo(EditIpo *actei)
187 for(a=0, ei=G.sipo->editipo; a<G.sipo->totipo; a++, ei++) {
188 ei->flag &= ~IPO_ACTIVE;
189 if(ei->icu) ei->icu->flag &= ~IPO_ACTIVE;
191 actei->flag |= IPO_ACTIVE;
192 if(actei->icu) actei->icu->flag |= IPO_ACTIVE;
195 EditIpo *get_active_editipo(void)
203 /* prevent confusing situations, like for sequencer */
204 if(G.sipo->totipo==1) {
206 ei->flag |= IPO_ACTIVE;
209 for(a=0, ei=G.sipo->editipo; a<G.sipo->totipo; a++, ei++)
210 if(ei->flag & IPO_ACTIVE)
216 static void set_active_key(int index)
218 if(G.sipo->blocktype==ID_KE && G.sipo->from) {
219 Object *ob= (Object *)G.sipo->from;
220 Key *key= ob_get_key(ob);
225 curkb= BLI_findlink(&key->block, index-1);
228 ob->shapeflag |= OB_SHAPE_TEMPLOCK;
231 DAG_object_flush_update(G.scene, ob, OB_RECALC_DATA);
232 allqueue(REDRAWVIEW3D, 0);
233 allqueue(REDRAWBUTSEDIT, 0);
239 void editipo_changed(SpaceIpo *si, int doredraw)
251 for(a=0; a<si->totipo; a++, ei++) {
255 /* twice because of ittererating new autohandle */
256 calchandles_ipocurve(ei->icu);
257 calchandles_ipocurve(ei->icu);
259 if(ei->flag & IPO_VISIBLE) {
261 boundbox_ipocurve(ei->icu, 0);
262 sort_time_ipocurve(ei->icu);
264 si->v2d.tot= ei->icu->totrct;
267 else BLI_union_rctf(&(si->v2d.tot), &(ei->icu->totrct));
276 if(si->blocktype==ID_KE) {
277 key= ob_get_key((Object *)G.sipo->from);
278 if(key && key->block.first) {
279 kb= key->block.first;
280 if(kb->pos < v2d->tot.ymin) v2d->tot.ymin= kb->pos;
282 if(kb->pos > v2d->tot.ymax) v2d->tot.ymax= kb->pos;
286 /* is there no curve? */
290 v2d->tot.ymin= (float)-0.1;
291 v2d->tot.ymax= (float)1.1;
293 if(si->blocktype==ID_SEQ) {
295 v2d->tot.xmax= 105.0;
296 v2d->tot.ymin= (float)-0.1;
297 v2d->tot.ymax= (float)1.1;
304 /* if you always call do_ipo: you get problems with insertkey, for example
305 * when inserting only a 'loc' the 'ob->rot' value then is changed.
308 if(si->blocktype==ID_OB) {
309 /* clear delta loc,rot,size (when free/delete ipo) */
310 clear_delta_obipo(si->ipo);
316 allqueue(REDRAWIPO, 0);
317 allqueue(REDRAWACTION, 0);
318 allqueue(REDRAWTIME, 0);
319 allqueue(REDRAWNLA, 0);
320 allqueue(REDRAWBUTSOBJECT, 0);
322 if(si->blocktype==ID_OB) {
323 Object *ob= (Object *)si->from;
324 if(ob) DAG_object_flush_update(G.scene, ob, OB_RECALC_OB);
325 allqueue(REDRAWVIEW3D, 0);
326 allqueue(REDRAWNLA, 0);
329 else if(si->blocktype==ID_MA) allqueue(REDRAWBUTSSHADING, 0);
330 else if(si->blocktype==ID_TE) allqueue(REDRAWBUTSSHADING, 0);
331 else if(si->blocktype==ID_WO) allqueue(REDRAWBUTSSHADING, 0);
332 else if(si->blocktype==ID_LA) allqueue(REDRAWBUTSSHADING, 0);
333 // else if(si->blocktype==ID_SO) allqueue(REDRAWBUTSSOUND, 0);
334 else if(si->blocktype==ID_CA) {
335 allqueue(REDRAWBUTSEDIT, 0);
336 allqueue(REDRAWVIEW3D, 0);
338 else if(si->blocktype==ID_SEQ) free_imbuf_seq_with_ipo(si->ipo);
339 else if(si->blocktype==ID_PO) {
342 DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
344 allqueue(REDRAWVIEW3D, 0);
345 allqueue(REDRAWACTION, 0);
346 allqueue(REDRAWNLA, 0);
348 else if(si->blocktype==ID_KE) {
349 DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
350 allqueue(REDRAWVIEW3D, 0);
352 else if(si->blocktype==ID_CU) {
353 DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
354 allqueue(REDRAWVIEW3D, 0);
356 else if(si->blocktype==ID_PA){
357 DAG_object_flush_update(G.scene, OBACT, OB_RECALC_DATA);
358 allqueue(REDRAWVIEW3D, 0);
362 if(si->showkey) make_ipokey();
365 synchronize_action_strips();
368 void scale_editipo(void)
370 /* comes from buttons, scale with G.sipo->tot rect */
377 facx= (G.sipo->tot.xmax-G.sipo->tot.xmin)/(G.sipo->v2d.tot.xmax-G.sipo->v2d.tot.xmin);
378 facy= (G.sipo->tot.ymax-G.sipo->tot.ymin)/(G.sipo->v2d.tot.ymax-G.sipo->v2d.tot.ymin);
382 for(a=0; a<G.sipo->totipo; a++, ei++) {
383 if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
388 bezt->vec[0][0]= facx*(bezt->vec[0][0] - G.sipo->v2d.tot.xmin) + G.sipo->tot.xmin;
389 bezt->vec[1][0]= facx*(bezt->vec[1][0] - G.sipo->v2d.tot.xmin) + G.sipo->tot.xmin;
390 bezt->vec[2][0]= facx*(bezt->vec[2][0] - G.sipo->v2d.tot.xmin) + G.sipo->tot.xmin;
392 bezt->vec[0][1]= facy*(bezt->vec[0][1] - G.sipo->v2d.tot.ymin) + G.sipo->tot.ymin;
393 bezt->vec[1][1]= facy*(bezt->vec[1][1] - G.sipo->v2d.tot.ymin) + G.sipo->tot.ymin;
394 bezt->vec[2][1]= facy*(bezt->vec[2][1] - G.sipo->v2d.tot.ymin) + G.sipo->tot.ymin;
401 editipo_changed(G.sipo, 1);
403 BIF_undo_push("Scale Edit Ipo");
404 allqueue(REDRAWNLA, 0);
405 allqueue (REDRAWACTION, 0);
406 allqueue(REDRAWIPO, 0);
409 static void make_ob_editipo(Object *ob, SpaceIpo *si)
412 int a, len, colipo=0;
415 if(ob->type==OB_MESH) colipo= 1;
417 ei= si->editipo= MEM_callocN(OB_TOTIPO*sizeof(EditIpo), "editipo");
419 si->totipo= OB_TOTIPO;
421 for(a=0; a<OB_TOTIPO; a++) {
422 name = getname_ob_ei(ob_ar[a], colipo);
423 strcpy(ei->name, name);
424 ei->adrcode= ob_ar[a];
426 if ELEM6(ei->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z, OB_DROT_X, OB_DROT_Y, OB_DROT_Z) ei->disptype= IPO_DISPDEGR;
427 else if(ei->adrcode==OB_LAY) ei->disptype= IPO_DISPBITS;
428 else if(ei->adrcode==OB_TIME) ei->disptype= IPO_DISPTIME;
430 ei->col= ipo_rainbow(a, OB_TOTIPO);
433 len= strlen(ei->name);
435 if( ei->name[ len-1 ]=='R') ei->col= 0x5050FF;
436 else if( ei->name[ len-1 ]=='G') ei->col= 0x50FF50;
437 else if( ei->name[ len-1 ]=='B') ei->col= 0xFF7050;
441 ei->icu= find_ipocurve(si->ipo, ei->adrcode);
443 ei->flag= ei->icu->flag;
449 //fprintf(stderr,"FSIMAKE_OPBJ call %d \n", si->totipo);
452 static void make_part_editipo(SpaceIpo *si)
458 if(si->from==0) return;
460 ei= si->editipo= MEM_callocN(PART_TOTIPO*sizeof(EditIpo), "editipo");
462 si->totipo= PART_TOTIPO;
464 for(a=0; a<PART_TOTIPO; a++) {
465 name = getname_part_ei(part_ar[a]);
466 strcpy(ei->name, name);
467 ei->adrcode= part_ar[a];
468 ei->col= ipo_rainbow(a, PART_TOTIPO);
469 ei->icu= find_ipocurve(si->ipo, ei->adrcode);
471 ei->flag= ei->icu->flag;
478 // copied from make_seq_editipo
479 static void make_fluidsim_editipo(SpaceIpo *si, Object *ob) // NT
484 int numipos = FLUIDSIM_TOTIPO;
485 int ipo_start_index = 0;
486 FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
487 FluidsimSettings *fss= fluidmd->fss;
489 // we don't need all fluid ipos for all types! - dg
490 if(fss->type == OB_FLUIDSIM_CONTROL)
492 numipos = 4; // there are 4 fluid control ipos
496 else if(fss->type == OB_FLUIDSIM_DOMAIN)
498 numipos = 5; // there are 5 ipos for fluid domains
502 numipos = 4; // there are 4 for the rest
506 ei= si->editipo= MEM_callocN(numipos*sizeof(EditIpo), "fluidsim_editipo");
507 si->totipo = numipos;
508 for(a=ipo_start_index; a<ipo_start_index+numipos; a++) {
509 //fprintf(stderr,"FSINAME %d %d \n",a,fluidsim_ar[a], (int)(getname_fluidsim_ei(fluidsim_ar[a])) );
510 name = getname_fluidsim_ei(fluidsim_ar[a]);
511 strcpy(ei->name, name);
512 ei->adrcode= fluidsim_ar[a];
513 ei->col= ipo_rainbow(a, numipos);
514 ei->icu= find_ipocurve(si->ipo, ei->adrcode);
516 ei->flag = ei->icu->flag;
518 //else { ei->flag |= IPO_VISIBLE; }
519 //fprintf(stderr,"FSIMAKE eif%d,icuf%d icu%d %d|%d\n", ei->flag,ei->icu->flag, (int)ei->icu, IPO_VISIBLE,IPO_SELECT);
520 //fprintf(stderr,"FSIMAKE eif%d icu%d %d|%d\n", ei->flag, (int)ei->icu, IPO_VISIBLE,IPO_SELECT);
525 static void make_seq_editipo(SpaceIpo *si)
531 ei= si->editipo= MEM_callocN(SEQ_TOTIPO*sizeof(EditIpo), "editipo");
533 si->totipo= SEQ_TOTIPO;
536 for(a=0; a<SEQ_TOTIPO; a++) {
537 name = getname_seq_ei(seq_ar[a]);
538 strcpy(ei->name, name);
539 ei->adrcode= seq_ar[a];
541 ei->col= ipo_rainbow(a, SEQ_TOTIPO);
543 ei->icu= find_ipocurve(si->ipo, ei->adrcode);
545 ei->flag= ei->icu->flag;
547 else ei->flag |= IPO_VISIBLE;
553 static void make_cu_editipo(SpaceIpo *si)
559 ei= si->editipo= MEM_callocN(CU_TOTIPO*sizeof(EditIpo), "editipo");
561 si->totipo= CU_TOTIPO;
564 for(a=0; a<CU_TOTIPO; a++) {
565 name = getname_cu_ei(cu_ar[a]);
566 strcpy(ei->name, name);
567 ei->adrcode= cu_ar[a];
569 ei->col= ipo_rainbow(a, CU_TOTIPO);
571 ei->icu= find_ipocurve(si->ipo, ei->adrcode);
573 ei->flag= ei->icu->flag;
575 else ei->flag |= IPO_VISIBLE;
581 static void make_key_editipo(SpaceIpo *si)
588 key= ob_get_key((Object *)G.sipo->from);
589 if(key==NULL) return;
591 si->totipo= BLI_countlist(&key->block);
592 ei= si->editipo= MEM_callocN(si->totipo*sizeof(EditIpo), "editipo");
594 for(a=0, kb= key->block.first; a<si->totipo; a++, ei++, kb= kb->next) {
596 if(kb->name[0] != 0) strncpy(ei->name, kb->name, 31); // length both same
597 ei->adrcode= kb->adrcode;
599 ei->col= ipo_rainbow(a, KEY_TOTIPO);
601 ei->icu= find_ipocurve(si->ipo, ei->adrcode);
603 ei->flag= ei->icu->flag;
606 if(key && key->type==KEY_NORMAL)
607 ei->flag |= IPO_VISIBLE;
609 /* active ipo is tied to active shape */
613 set_active_editipo(ei);
618 if(key && key->type==KEY_RELATIVE) {
619 strcpy(ei->name, "----");
622 ei->flag |= IPO_VISIBLE;
626 static void make_mat_editipo(SpaceIpo *si)
632 if(si->from==0) return;
634 ei= si->editipo= MEM_callocN(MA_TOTIPO*sizeof(EditIpo), "editipo");
636 si->totipo= MA_TOTIPO;
638 for(a=0; a<MA_TOTIPO; a++) {
639 name = getname_mat_ei(ma_ar[a]);
640 strcpy(ei->name, name);
641 ei->adrcode= ma_ar[a];
643 if(ei->adrcode & MA_MAP1) {
644 ei->adrcode-= MA_MAP1;
645 ei->adrcode |= texchannel_to_adrcode(si->channel);
648 if(ei->adrcode==MA_MODE) ei->disptype= IPO_DISPBITS;
651 ei->col= ipo_rainbow(a, MA_TOTIPO);
653 len= strlen(ei->name);
655 if( ei->name[ len-1 ]=='R') ei->col= 0x5050FF;
656 else if( ei->name[ len-1 ]=='G') ei->col= 0x50FF50;
657 else if( ei->name[ len-1 ]=='B') ei->col= 0xFF7050;
660 ei->icu= find_ipocurve(si->ipo, ei->adrcode);
662 ei->flag= ei->icu->flag;
669 static void make_texture_editipo(SpaceIpo *si)
675 if(si->from==0) return;
677 ei= si->editipo= MEM_callocN(TE_TOTIPO*sizeof(EditIpo), "editipo");
679 si->totipo= TE_TOTIPO;
681 for(a=0; a<TE_TOTIPO; a++) {
682 name = getname_tex_ei(te_ar[a]);
683 strcpy(ei->name, name);
684 ei->adrcode= te_ar[a];
686 ei->col= ipo_rainbow(a, TE_TOTIPO);
688 len= strlen(ei->name);
690 if( ei->name[ len-1 ]=='R') ei->col= 0x5050FF;
691 else if( ei->name[ len-1 ]=='G') ei->col= 0x50FF50;
692 else if( ei->name[ len-1 ]=='B') ei->col= 0xFF7050;
694 ei->icu= find_ipocurve(si->ipo, ei->adrcode);
696 ei->flag= ei->icu->flag;
703 static void make_world_editipo(SpaceIpo *si)
709 if(si->from==0) return;
711 ei= si->editipo= MEM_callocN(WO_TOTIPO*sizeof(EditIpo), "editipo");
713 si->totipo= WO_TOTIPO;
715 for(a=0; a<WO_TOTIPO; a++) {
716 name = getname_world_ei(wo_ar[a]);
718 strcpy(ei->name, name);
719 ei->adrcode= wo_ar[a];
721 if(ei->adrcode & MA_MAP1) {
722 ei->adrcode-= MA_MAP1;
723 ei->adrcode |= texchannel_to_adrcode(si->channel);
726 if(ei->adrcode==MA_MODE) ei->disptype= IPO_DISPBITS;
729 ei->col= ipo_rainbow(a, WO_TOTIPO);
731 len= strlen(ei->name);
733 if( ei->name[ len-1 ]=='R') ei->col= 0x5050FF;
734 else if( ei->name[ len-1 ]=='G') ei->col= 0x50FF50;
735 else if( ei->name[ len-1 ]=='B') ei->col= 0xFF7050;
738 ei->icu= find_ipocurve(si->ipo, ei->adrcode);
740 ei->flag= ei->icu->flag;
747 static void make_lamp_editipo(SpaceIpo *si)
753 ei= si->editipo= MEM_callocN(LA_TOTIPO*sizeof(EditIpo), "editipo");
755 si->totipo= LA_TOTIPO;
757 for(a=0; a<LA_TOTIPO; a++) {
758 name = getname_la_ei(la_ar[a]);
759 strcpy(ei->name, name);
760 ei->adrcode= la_ar[a];
762 if(ei->adrcode & MA_MAP1) {
763 ei->adrcode-= MA_MAP1;
764 ei->adrcode |= texchannel_to_adrcode(si->channel);
767 ei->col= ipo_rainbow(a, LA_TOTIPO);
769 ei->icu= find_ipocurve(si->ipo, ei->adrcode);
771 ei->flag= ei->icu->flag;
778 static void make_camera_editipo(SpaceIpo *si)
784 ei= si->editipo= MEM_callocN(CAM_TOTIPO*sizeof(EditIpo), "editipo");
786 si->totipo= CAM_TOTIPO;
789 for(a=0; a<CAM_TOTIPO; a++) {
790 name = getname_cam_ei(cam_ar[a]);
791 strcpy(ei->name, name);
792 ei->adrcode= cam_ar[a];
794 ei->col= ipo_rainbow(a, CAM_TOTIPO);
796 ei->icu= find_ipocurve(si->ipo, ei->adrcode);
798 ei->flag= ei->icu->flag;
805 static int make_constraint_editipo(Ipo *ipo, EditIpo **si)
811 ei= *si= MEM_callocN(CO_TOTIPO*sizeof(EditIpo), "editipo");
813 for(a=0; a<CO_TOTIPO; a++) {
814 name = getname_co_ei(co_ar[a]);
815 strcpy(ei->name, name);
816 ei->adrcode= co_ar[a];
818 ei->col= ipo_rainbow(a, CO_TOTIPO);
820 ei->icu= find_ipocurve(ipo, ei->adrcode);
822 ei->flag= ei->icu->flag;
831 static int make_bone_editipo(Ipo *ipo, EditIpo **si)
837 ei= *si= MEM_callocN(AC_TOTIPO*sizeof(EditIpo), "editipo");
839 for(a=0; a<AC_TOTIPO; a++) {
840 name = getname_ac_ei(ac_ar[a]);
841 strcpy(ei->name, name);
842 ei->adrcode= ac_ar[a];
844 ei->col= ipo_rainbow(a, AC_TOTIPO);
846 ei->icu= find_ipocurve(ipo, ei->adrcode);
848 ei->flag= ei->icu->flag;
857 static void make_sound_editipo(SpaceIpo *si)
863 ei= si->editipo= MEM_callocN(SND_TOTIPO*sizeof(EditIpo), "editipo");
865 si->totipo= SND_TOTIPO;
868 for(a=0; a<SND_TOTIPO; a++) {
869 name = getname_snd_ei(snd_ar[a]);
870 strcpy(ei->name, name);
871 ei->adrcode= snd_ar[a];
873 ei->col= ipo_rainbow(a, SND_TOTIPO);
875 ei->icu= find_ipocurve(si->ipo, ei->adrcode);
877 ei->flag= ei->icu->flag;
884 /* only called in test_editipo() below */
885 static void make_editipo(void)
893 MEM_freeN(G.sipo->editipo);
895 G.sipo->editipo= NULL;
898 if(G.sipo->from==NULL) return;
902 if(G.sipo->ipo) G.sipo->showkey= G.sipo->ipo->showkey;
904 if(G.sipo->blocktype==ID_SEQ) {
905 make_seq_editipo(G.sipo);
907 else if(G.sipo->blocktype==ID_WO) {
908 make_world_editipo(G.sipo);
910 else if(G.sipo->blocktype==ID_OB) {
913 make_ob_editipo(ob, G.sipo);
916 else if(G.sipo->blocktype==ID_MA) {
919 make_mat_editipo(G.sipo);
922 else if(G.sipo->blocktype==ID_CU) {
925 make_cu_editipo(G.sipo);
928 else if(G.sipo->blocktype==ID_KE) {
931 make_key_editipo(G.sipo);
934 else if(G.sipo->blocktype==ID_LA) {
937 make_lamp_editipo(G.sipo);
940 else if(G.sipo->blocktype==ID_TE) {
943 make_texture_editipo(G.sipo);
945 else if(G.scene->world && give_current_world_texture()) {
946 make_texture_editipo(G.sipo);
949 else if(G.sipo->blocktype==ID_CA) {
952 make_camera_editipo(G.sipo);
955 else if(G.sipo->blocktype==ID_SO) {
958 make_sound_editipo(G.sipo);
961 else if(G.sipo->blocktype==ID_CO){
962 G.sipo->totipo = make_constraint_editipo(G.sipo->ipo, (EditIpo**)&G.sipo->editipo);
967 else if(G.sipo->blocktype==ID_PO) {
969 G.sipo->totipo = make_bone_editipo(G.sipo->ipo, (EditIpo**)&G.sipo->editipo);
974 else if(G.sipo->blocktype==ID_FLUIDSIM) {
976 ob->ipowin= ID_FLUIDSIM;
977 make_fluidsim_editipo(G.sipo, ob);
980 else if(G.sipo->blocktype==ID_PA) {
983 make_part_editipo(G.sipo);
987 if(G.sipo->editipo==0) return;
990 for(a=0; a<G.sipo->totipo; a++, ei++) {
991 if(ei->icu) ei->icu->flag= ei->flag;
993 editipo_changed(G.sipo, 0);
995 /* sets globals, bad stuff but we need these variables in other parts of code */
996 get_status_editipo();
999 if (G.sipo->flag & SIPO_LOCK_VIEW) {
1000 rf= &(G.v2d->cur); /* view is locked, dont move it, just to sanity check */
1001 if(rf->xmin>=rf->xmax || rf->ymin>=rf->ymax) ipo_default_v2d_cur(G.sipo->blocktype, &G.v2d->cur);
1005 rf= &(G.sipo->v2d.cur);
1007 rf= &(G.sipo->ipo->cur);
1009 if(rf->xmin<rf->xmax && rf->ymin<rf->ymax) G.v2d->cur= *rf;
1010 else ipo_default_v2d_cur(G.sipo->blocktype, &G.v2d->cur);
1013 ipo_default_v2d_cur(G.sipo->blocktype, &G.v2d->cur);
1016 view2d_do_locks(curarea, V2D_LOCK_COPY);
1019 /* evaluates context in the current UI */
1020 /* blocktype is type of ipo */
1021 /* from is the base pointer to find data to change (ob in case of action or pose) */
1022 /* bonename is for local bone ipos (constraint only now) */
1023 static void get_ipo_context(short blocktype, ID **from, Ipo **ipo, char *actname, char *constname, char *bonename)
1030 if(blocktype==ID_CO) {
1032 bConstraintChannel *chan;
1033 bConstraint *con= get_active_constraint(ob);
1038 BLI_strncpy(constname, con->name, 32);
1040 /* a bit hackish, but we want con->ipo to work */
1041 if(con->flag & CONSTRAINT_OWN_IPO) {
1042 if(ob->flag & OB_POSEMODE) {
1043 bPoseChannel *pchan= get_active_posechannel(ob);
1045 BLI_strncpy(bonename, pchan->name, 32);
1051 chan= get_active_constraint_channel(ob);
1054 BLI_strncpy(constname, con->name, 32);
1057 /* set actname if in posemode */
1059 if (ob->flag & OB_POSEMODE) {
1060 bPoseChannel *pchan= get_active_posechannel(ob);
1062 BLI_strncpy(actname, pchan->name, 32);
1063 BLI_strncpy(bonename, pchan->name, 32);
1066 else if (ob->ipoflag & OB_ACTION_OB)
1067 strcpy(actname, "Object");
1070 if (ob->flag & OB_POSEMODE) {
1071 bPoseChannel *pchan= get_active_posechannel(ob);
1073 BLI_strncpy(actname, pchan->name, 32);
1074 BLI_strncpy(bonename, pchan->name, 32);
1082 else if(blocktype==ID_PO) {
1083 if (ob && ob->action && ob->type==OB_ARMATURE) {
1084 bPoseChannel *pchan= get_active_posechannel(ob);
1088 bActionChannel *achan;
1090 BLI_strncpy(actname, pchan->name, 32); /* also set when no channel yet */
1092 achan= get_action_channel(ob->action, pchan->name);
1099 else if(blocktype==ID_OB) {
1102 if(ob->ipoflag & OB_ACTION_OB) {
1104 bActionChannel *achan= get_action_channel(ob->action, "Object");
1107 BLI_strncpy(actname, achan->name, 32);
1116 else if(blocktype==ID_SEQ) {
1117 Sequence *last_seq = get_last_seq();
1120 *from= (ID *)last_seq;
1121 *ipo= last_seq->ipo;
1124 else if(blocktype==ID_WO) {
1125 World *wo= G.scene->world;
1127 if(wo) *ipo= wo->ipo;
1129 else if(blocktype==ID_TE) {
1131 Tex *tex= give_current_texture(ob, ob->actcol);
1133 if(tex) *ipo= tex->ipo;
1135 else if(G.scene->world) {
1136 Tex *tex= give_current_world_texture();
1138 if(tex) *ipo= tex->ipo;
1141 else if(blocktype==ID_MA) {
1143 Material *ma= give_current_material(ob, ob->actcol);
1144 ma= editnode_get_active_material(ma);
1146 if(ma) *ipo= ma->ipo;
1149 else if(blocktype==ID_KE) {
1151 Key *key= ob_get_key(ob);
1153 if(ob->ipoflag & OB_ACTION_KEY) {
1155 bActionChannel *achan= get_action_channel(ob->action, "Shape");
1158 BLI_strncpy(actname, achan->name, 32);
1162 else if(key) *ipo= key->ipo;
1167 else if(blocktype==ID_CU) {
1168 if(ob && ob->type==OB_CURVE) {
1169 Curve *cu= ob->data;
1174 else if(blocktype==ID_LA) {
1175 if(ob && ob->type==OB_LAMP) {
1181 else if(blocktype==ID_CA) {
1182 if(ob && ob->type==OB_CAMERA) {
1183 Camera *ca= ob->data;
1185 if(ca) *ipo= ca->ipo;
1188 else if(blocktype==ID_SO) {
1190 // if (G.buts && G.buts->mainb == BUTS_SOUND) {
1191 // bSound *sound = G.buts->lockpoin;
1192 // *from= (ID *)sound;
1193 // if(sound) *ipo= sound->ipo;
1196 else if(blocktype==ID_FLUIDSIM) {
1199 FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
1201 FluidsimSettings *fss= fluidmd->fss;
1203 if(fss) *ipo= fss->ipo;
1207 else if(blocktype==ID_PA) {
1208 ParticleSystem *psys = psys_get_current(ob);
1211 *ipo= psys->part->ipo;
1216 /* called on each redraw, check if editipo data has to be remade */
1217 /* if doit already set, it always makes (in case no ipo exists, we need to see the channels */
1218 void test_editipo(int doit)
1221 if(G.sipo->pin==0) {
1224 char actname[32]="", constname[32]="", bonename[32]="";
1226 get_ipo_context(G.sipo->blocktype, &from, &ipo, actname, constname, bonename);
1228 if(G.sipo->ipo != ipo) {
1230 /* if lock we don't copy from ipo, this makes the UI jump around confusingly */
1231 if(G.v2d->flag & V2D_VIEWLOCK || G.sipo->flag & SIPO_LOCK_VIEW);
1232 else if(ipo) G.v2d->cur= ipo->cur;
1235 if(G.sipo->from != from) {
1239 if( strcmp(G.sipo->actname, actname)) {
1240 BLI_strncpy(G.sipo->actname, actname, 32);
1243 if( strcmp(G.sipo->constname, constname)) {
1244 BLI_strncpy(G.sipo->constname, constname, 32);
1247 if( strcmp(G.sipo->bonename, bonename)) {
1248 BLI_strncpy(G.sipo->bonename, bonename, 32);
1249 /* urmf; if bonename, then no action */
1250 if(bonename[0]) G.sipo->actname[0]= 0;
1255 G.sipo->ipo->cur = G.v2d->cur;
1259 if(G.sipo->editipo==NULL || doit) {
1264 /* ****************** EditIpo ************************ */
1266 int totipo_edit=0, totipo_sel=0, totipo_curve=0, totipo_vis=0, totipo_vert=0, totipo_vertsel=0, totipo_key=0, totipo_keysel=0;
1268 void get_status_editipo(void)
1284 if(G.sipo->ipo && G.sipo->ipo->id.lib) return;
1286 ei= G.sipo->editipo;
1288 for(a=0; a<G.sipo->totipo; a++) {
1289 if( ei->flag & IPO_VISIBLE ) {
1291 if(ei->flag & IPO_SELECT) totipo_sel++;
1292 if(ei->icu && ei->icu->totvert) totipo_curve++;
1293 if(G.sipo->showkey || (ei->flag & IPO_EDIT)) {
1295 /* if showkey: do count the vertices (for grab) */
1296 if(G.sipo->showkey==0) totipo_edit++;
1300 bezt= ei->icu->bezt;
1301 b= ei->icu->totvert;
1303 if(ei->icu->ipo==IPO_BEZ) {
1304 if(bezt->f1 & SELECT) totipo_vertsel++;
1305 if(bezt->f3 & SELECT) totipo_vertsel++;
1308 if(bezt->f2 & SELECT) totipo_vertsel++;
1320 if(G.sipo->showkey) {
1321 ik= G.sipo->ipokey.first;
1324 if(ik->flag & 1) totipo_keysel++;
1330 /* synchronize editipo flag with icu flag and ipokey flags */
1331 void update_editipo_flags(void)
1337 ei= G.sipo->editipo;
1339 for(a=0; a<G.sipo->totipo; a++, ei++) {
1340 if(ei->icu) ei->icu->flag= ei->flag;
1343 if(G.sipo->showkey) {
1344 ik= G.sipo->ipokey.first;
1346 for(a=0; a<G.sipo->totipo; a++) {
1349 BEZ_SEL(ik->data[a]);
1352 BEZ_DESEL(ik->data[a]);
1361 /* sort of enter/leave editmode for curves */
1362 void set_editflag_editipo(void)
1365 int a; /* , tot= 0, ok= 0; */
1367 /* after showkey immediately go to editing of selected points */
1368 if(G.sipo->showkey) {
1370 if(G.sipo->ipo) G.sipo->ipo->showkey= 0;
1371 ei= G.sipo->editipo;
1372 for(a=0; a<G.sipo->totipo; a++, ei++) ei->flag |= IPO_SELECT;
1373 scrarea_queue_headredraw(curarea);
1374 allqueue(REDRAWVIEW3D, 0);
1377 get_status_editipo();
1379 if(G.sipo->ipo && G.sipo->ipo->id.lib) return;
1381 ei= G.sipo->editipo;
1382 for(a=0; a<G.sipo->totipo; a++, ei++) {
1384 if(ei->flag & IPO_VISIBLE) {
1386 if(totipo_edit==0 && (ei->flag & IPO_SELECT)) {
1387 ei->flag |= IPO_EDIT;
1388 ei->icu->flag= ei->flag;
1390 else if(totipo_edit && (ei->flag & IPO_EDIT)) {
1391 ei->flag -= IPO_EDIT;
1392 ei->icu->flag= ei->flag;
1394 else if(totipo_vis==1) {
1395 if(ei->flag & IPO_EDIT) ei->flag -= IPO_EDIT;
1396 else ei->flag |= IPO_EDIT;
1397 ei->icu->flag= ei->flag;
1402 scrarea_queue_headredraw(curarea);
1403 scrarea_queue_winredraw(curarea);
1406 static short findnearest_ipovert(IpoCurve **icu, BezTriple **bezt)
1408 /* selected verts get a disadvantage */
1409 /* in icu and (bezt or bp) the nearest is written */
1410 /* return 0 1 2: handlepunt */
1413 int dist= 100, temp, a, b;
1414 short mval[2], hpoint=0, sco[3][2];
1419 getmouseco_areawin(mval);
1421 ei= G.sipo->editipo;
1422 for(a=0; a<G.sipo->totipo; a++, ei++) {
1423 if (ISPOIN3(ei, flag & IPO_VISIBLE, flag & IPO_EDIT, icu)) {
1426 bezt1= ei->icu->bezt;
1427 b= ei->icu->totvert;
1430 ipoco_to_areaco_noclip(G.v2d, bezt1->vec[0], sco[0]);
1431 ipoco_to_areaco_noclip(G.v2d, bezt1->vec[1], sco[1]);
1432 ipoco_to_areaco_noclip(G.v2d, bezt1->vec[2], sco[2]);
1434 if(ei->disptype==IPO_DISPBITS) {
1435 temp= abs(mval[0]- sco[1][0]);
1437 else temp= abs(mval[0]- sco[1][0])+ abs(mval[1]- sco[1][1]);
1439 if( bezt1->f2 & SELECT) temp+=5;
1447 if(ei->disptype!=IPO_DISPBITS && ei->icu->ipo==IPO_BEZ) {
1448 /* middle points get an advantage */
1449 temp= -3+abs(mval[0]- sco[0][0])+ abs(mval[1]- sco[0][1]);
1450 if( bezt1->f1 & SELECT) temp+=5;
1458 temp= abs(mval[0]- sco[2][0])+ abs(mval[1]- sco[2][1]);
1459 if( bezt1->f3 & 1) temp+=5;
1476 void mouse_select_ipo(void)
1479 KeyBlock *actkb=NULL;
1480 EditIpo *ei, *actei= 0;
1485 float x, y, dist, mindist;
1486 int a, oldflag = 0, hand, ok;
1487 short mval[2], xo, yo;
1489 if(G.sipo->editipo==0) return;
1491 get_status_editipo();
1492 marker=find_nearest_marker(SCE_MARKERS, 1);
1494 /* map ipo-points for editing if scaled ipo */
1495 if (NLA_IPO_SCALED) {
1496 actstrip_map_ipo_keys(OBACT, G.sipo->ipo, 0, 0);
1499 if(G.sipo->showkey) {
1502 view2d_getscale(G.v2d, &pixelwidth, NULL);
1504 getmouseco_areawin(mval);
1505 areamouseco_to_ipoco(G.v2d, mval, &x, &y);
1508 ik= G.sipo->ipokey.first;
1510 dist= (float)(fabs(ik->val-x));
1511 if(ik->flag & SELECT) dist+= pixelwidth;
1512 if(dist < mindist) {
1519 oldflag= actik->flag;
1521 if(G.qual & LR_SHIFTKEY);
1522 else deselectall_editipo();
1524 if(G.qual & LR_SHIFTKEY) {
1525 if(oldflag & 1) actik->flag &= ~1;
1526 else actik->flag |= 1;
1533 else if(totipo_edit) {
1535 hand= findnearest_ipovert(&icu, &bezt);
1537 if(G.qual & LR_SHIFTKEY) {
1540 if(BEZSELECTED(bezt)) {
1548 if(bezt->f1 & SELECT) bezt->f1 &= ~SELECT;
1549 else bezt->f1= SELECT;
1552 if(bezt->f3 & SELECT) bezt->f3 &= ~SELECT;
1553 else bezt->f3= SELECT;
1558 deselectall_editipo();
1564 else if(hand==0) bezt->f1 |= SELECT;
1565 else bezt->f3 |= SELECT;
1570 /* select timeline marker */
1571 if ((G.qual & LR_SHIFTKEY)==0) {
1572 oldflag= marker->flag;
1573 deselect_markers(0, 0);
1575 if (oldflag & SELECT)
1576 marker->flag &= ~SELECT;
1578 marker->flag |= SELECT;
1581 marker->flag |= SELECT;
1587 if(G.sipo->blocktype==ID_KE && G.sipo->from) {
1589 KeyBlock *kb, *curkb;
1592 ob= (Object *)G.sipo->from;
1593 key= ob_get_key(ob);
1594 curkb= BLI_findlink(&key->block, ob->shapenr-1);
1596 ei= G.sipo->editipo;
1597 if(key->type==KEY_NORMAL || (ei->flag & IPO_VISIBLE)) {
1598 getmouseco_areawin(mval);
1600 areamouseco_to_ipoco(G.v2d, mval, &x, &y);
1601 /* how much is 20 pixels? */
1602 mindist= (float)(20.0*(G.v2d->cur.ymax-G.v2d->cur.ymin)/(float)curarea->winy);
1604 for(i=1, kb= key->block.first; kb; kb= kb->next, i++) {
1605 dist= (float)(fabs(kb->pos-y));
1606 if(kb==curkb) dist+= (float)0.01;
1607 if(dist < mindist) {
1615 if(G.obedit && actkb!=curkb) {
1616 ok= okee("Copy key after leaving Edit Mode");
1619 /* also does all keypos */
1620 deselectall_editipo();
1621 set_active_key(index);
1622 set_active_editipo(ei+index-1);
1631 ei= G.sipo->editipo;
1632 for(a=0; a<G.sipo->totipo; a++, ei++) {
1634 if(ei->flag & IPO_VISIBLE) actei= ei;
1638 else if(totipo_vis>1) {
1639 actei= select_proj_ipo(0, 0);
1642 if(actei) oldflag= actei->flag;
1644 if(G.qual & LR_SHIFTKEY);
1645 else deselectall_editipo();
1648 if(G.qual & LR_SHIFTKEY) {
1649 if(oldflag & IPO_SELECT) actei->flag &= ~IPO_SELECT;
1650 else actei->flag |= IPO_SELECT;
1653 actei->flag |= IPO_SELECT;
1655 set_active_editipo(actei);
1660 /* undo mapping of ipo-points for editing if scaled ipo */
1661 if (NLA_IPO_SCALED) {
1662 actstrip_map_ipo_keys(OBACT, G.sipo->ipo, 1, 0);
1665 update_editipo_flags();
1668 BIF_undo_push("Select Ipo");
1670 if(G.sipo->showkey && G.sipo->blocktype==ID_OB) {
1672 if(ob && (ob->ipoflag & OB_DRAWKEY)) allqueue(REDRAWVIEW3D, 0);
1674 /* points inside of curve are drawn selected too */
1675 if(G.sipo->blocktype==ID_CU)
1676 allqueue(REDRAWVIEW3D, 0);
1678 getmouseco_areawin(mval);
1682 while (get_mbut() & ((U.flag & USER_LMOUSESELECT)?L_MOUSE:R_MOUSE)) {
1683 getmouseco_areawin(mval);
1684 if(abs(mval[0]-xo)+abs(mval[1]-yo) > 4) {
1687 transform_markers('g', 0);
1690 if(actkb) move_keys(OBACT);
1691 else transform_ipo('g');
1696 BIF_wait_for_statechange();
1701 /* *********************************** */
1703 /* handling of right-hand channel/curve buttons in ipo window */
1704 void do_ipowin_buts(short event)
1709 /* without shift, all other channels are made invisible */
1710 if((G.qual & LR_SHIFTKEY)==0) {
1711 if(event>G.sipo->totipo) return;
1712 ei = G.sipo->editipo;
1713 for(a=0; a<G.sipo->totipo; a++) {
1714 if(a!=event) ei->flag &= ~IPO_VISIBLE;
1715 else ei->flag |= IPO_VISIBLE;
1721 if(event>=0 && event<G.sipo->totipo) {
1722 ei= G.sipo->editipo; // void pointer...
1723 set_active_editipo(ei+event);
1724 set_active_key(event+1); // only if there's a key, of course
1726 scrarea_queue_winredraw(curarea);
1728 update_editipo_flags();
1729 get_status_editipo();
1731 if(G.sipo->showkey) {
1733 if(G.sipo->blocktype==ID_OB) allqueue(REDRAWVIEW3D, 0);
1738 /* the fake buttons to the left of channel names, for select/deselect curves */
1739 void do_ipo_selectbuttons(void)
1745 if(G.sipo->showkey) return;
1747 /* do not allow editipo here: convert editipos to selected */
1748 get_status_editipo();
1750 set_editflag_editipo();
1754 getmouseco_areawin(mval);
1756 nr= -(mval[1]-curarea->winy+30-G.sipo->butofs-IPOBUTY)/IPOBUTY;
1757 if(G.sipo->blocktype==ID_KE) nr--; /* keys show something else in first channel */
1759 if(nr>=0 && nr<G.sipo->totipo) {
1760 ei= G.sipo->editipo;
1763 set_active_editipo(ei);
1764 set_active_key(nr+1);
1767 if((ei->flag & IPO_VISIBLE)==0) {
1768 ei->flag |= IPO_VISIBLE|IPO_SELECT;
1771 if((G.qual & LR_SHIFTKEY)==0) {
1772 ei1= G.sipo->editipo;
1773 for(a=0; a<G.sipo->totipo; a++) {
1774 ei1->flag &= ~IPO_SELECT;
1779 if(ei->flag & IPO_SELECT) {
1780 ei->flag &= ~IPO_SELECT;
1783 ei->flag |= IPO_SELECT;
1786 update_editipo_flags();
1787 scrarea_queue_winredraw(curarea);
1790 BIF_undo_push("Select Ipo curve");
1793 /* ********************************* Inserting keys ********************************************* */
1795 /* depending type, it returns ipo, if needed it creates one */
1796 /* returns either action ipo or "real" ipo */
1797 /* arguments define full context;
1798 - *from has to be set always, to Object in case of Actions
1799 - blocktype defines available channels of Ipo struct (blocktype ID_OB can be in action too)
1800 - if actname, use this to locate actionchannel, and optional constname
1801 - if bonename, the constname is the ipo to the constraint
1804 /* note: check header_ipo.c, spaceipo_assign_ipo() too */
1805 Ipo *verify_ipo(ID *from, short blocktype, char *actname, char *constname, char *bonename, short add)
1807 /* lib-linked data is not appropriate here */
1808 if ((from==NULL) || (from->lib))
1811 /* first check action ipos */
1812 if (actname && actname[0]) {
1813 Object *ob= (Object *)from;
1814 bActionChannel *achan;
1816 if (GS(from->name)!=ID_OB) {
1817 printf("called ipo system for action with wrong base pointer\n");
1821 if ((ob->action==NULL) && (add))
1822 ob->action= add_empty_action("Action");
1825 achan= verify_action_channel(ob->action, actname);
1827 achan= get_action_channel(ob->action, actname);
1830 /* automatically assign achan to act-group based on pchan's grouping */
1831 if ((blocktype == ID_PO) && (add))
1832 verify_pchan2achan_grouping(ob->action, ob->pose, actname);
1834 /* constraint exception */
1835 if (blocktype==ID_CO) {
1836 bConstraintChannel *conchan;
1839 conchan= verify_constraint_channel(&achan->constraintChannels, constname);
1841 conchan= get_constraint_channel(&achan->constraintChannels, constname);
1844 if ((conchan->ipo==NULL) && (add))
1845 conchan->ipo= add_ipo("CoIpo", ID_CO);
1846 return conchan->ipo;
1850 if ((achan->ipo==NULL) && (add))
1851 achan->ipo= add_ipo("ActIpo", blocktype);
1857 switch (GS(from->name)) {
1860 Object *ob= (Object *)from;
1862 /* constraint exception */
1863 if (blocktype==ID_CO) {
1864 /* check the local constraint ipo */
1865 if (bonename && bonename[0] && ob->pose) {
1866 bPoseChannel *pchan= get_pose_channel(ob->pose, bonename);
1869 for (con= pchan->constraints.first; con; con= con->next) {
1870 if (strcmp(con->name, constname)==0)
1875 if ((con->ipo==NULL) && (add))
1876 con->ipo= add_ipo("CoIpo", ID_CO);
1880 else { /* the actionchannel */
1881 bConstraintChannel *conchan;
1884 conchan= verify_constraint_channel(&ob->constraintChannels, constname);
1886 conchan= get_constraint_channel(&ob->constraintChannels, constname);
1889 if ((conchan->ipo==NULL) && (add))
1890 conchan->ipo= add_ipo("CoIpo", ID_CO);
1891 return conchan->ipo;
1895 else if (blocktype==ID_OB) {
1896 if ((ob->ipo==NULL) && (add))
1897 ob->ipo= add_ipo("ObIpo", ID_OB);
1900 else if (blocktype==ID_KE) {
1901 Key *key= ob_get_key((Object *)from);
1904 if ((key->ipo==NULL) && (add))
1905 key->ipo= add_ipo("KeyIpo", ID_KE);
1910 else if (blocktype== ID_FLUIDSIM) {
1911 Object *ob= (Object *)from;
1913 FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(ob, eModifierType_Fluidsim);
1915 FluidsimSettings *fss= fluidmd->fss;
1917 if ((fss->ipo==NULL) && (add))
1918 fss->ipo= add_ipo("FluidsimIpo", ID_FLUIDSIM);
1922 else if(blocktype== ID_PA) {
1923 Object *ob= (Object *)from;
1924 ParticleSystem *psys= psys_get_current(ob);
1927 if ((psys->part->ipo==NULL) && (add))
1928 psys->part->ipo= add_ipo("ParticleIpo", ID_PA);
1929 return psys->part->ipo;
1937 Material *ma= (Material *)from;
1939 if ((ma->ipo==NULL) && (add))
1940 ma->ipo= add_ipo("MatIpo", ID_MA);
1946 Tex *tex= (Tex *)from;
1948 if ((tex->ipo==NULL) && (add))
1949 tex->ipo= add_ipo("TexIpo", ID_TE);
1955 Sequence *seq= (Sequence *)from; /* note, sequence is mimicing Id */
1957 if ((seq->ipo==NULL) && (add))
1958 seq->ipo= add_ipo("SeqIpo", ID_SEQ);
1959 update_seq_ipo_rect(seq);
1965 Curve *cu= (Curve *)from;
1967 if ((cu->ipo==NULL) && (add))
1968 cu->ipo= add_ipo("CuIpo", ID_CU);
1974 World *wo= (World *)from;
1976 if ((wo->ipo==NULL) && (add))
1977 wo->ipo= add_ipo("WoIpo", ID_WO);
1983 Lamp *la= (Lamp *)from;
1985 if ((la->ipo==NULL) && (add))
1986 la->ipo= add_ipo("LaIpo", ID_LA);
1992 Camera *ca= (Camera *)from;
1994 if ((ca->ipo==NULL) && (add))
1995 ca->ipo= add_ipo("CaIpo", ID_CA);
2001 bSound *snd= (bSound *)from;
2003 if ((snd->ipo==NULL) && (add))
2004 snd->ipo= add_ipo("SndIpo", ID_SO);
2013 /* returns and creates
2014 * Make sure functions check for NULL or they will crash!
2016 IpoCurve *verify_ipocurve(ID *from, short blocktype, char *actname, char *constname, char *bonename, int adrcode, short add)
2019 IpoCurve *icu= NULL;
2021 /* return 0 if lib */
2022 /* creates ipo too (if add) */
2023 ipo= verify_ipo(from, blocktype, actname, constname, bonename, add);
2025 if (ipo && ipo->id.lib==NULL && from->lib==NULL) {
2026 /* try to find matching curve */
2027 for (icu= ipo->curve.first; icu; icu= icu->next) {
2028 if (icu->adrcode==adrcode)
2032 /* make a new one if none found (and can add) */
2033 if ((icu==NULL) && (add)) {
2034 icu= MEM_callocN(sizeof(IpoCurve), "ipocurve");
2036 icu->flag |= (IPO_VISIBLE|IPO_AUTO_HORIZ);
2037 if (ipo->curve.first==NULL)
2038 icu->flag |= IPO_ACTIVE; /* first one added active */
2040 icu->blocktype= blocktype;
2041 icu->adrcode= adrcode;
2045 BLI_addtail(&ipo->curve, icu);
2047 switch (GS(from->name)) {
2049 Sequence *seq= (Sequence *)from;
2051 update_seq_icu_rects(seq);
2058 /* return ipo-curve */
2063 void add_vert_ipo(void)
2070 if(G.sipo->ipo && G.sipo->ipo->id.lib) return;
2071 if(G.sipo->showkey) {
2073 free_ipokey(&G.sipo->ipokey);
2076 getmouseco_areawin(mval);
2078 if(mval[0]>G.v2d->mask.xmax) return;
2080 ei= get_active_editipo();
2082 error("No active Ipo curve");
2085 ei->flag |= IPO_VISIBLE; /* can happen it is active but not visible */
2087 areamouseco_to_ipoco(G.v2d, mval, &x, &y);
2089 /* convert click-time to ipo-time */
2090 if (NLA_IPO_SCALED) {
2091 x= get_action_frame(OBACT, x);
2096 ei->icu= verify_ipocurve(G.sipo->from, G.sipo->blocktype, G.sipo->actname, G.sipo->constname, G.sipo->bonename, ei->adrcode, 1);
2098 ei->flag |= ei->icu->flag & IPO_AUTO_HORIZ; /* new curve could have been added, weak... */
2100 error("Cannot create an IPO curve, you may be using libdata");
2103 if(ei->icu==NULL) return;
2105 if(ei->disptype==IPO_DISPBITS) {
2106 ei->icu->vartype= IPO_BITS;
2107 val= (int)floor(y-0.5);
2109 y= (float)(1 << val);
2112 insert_vert_icu(ei->icu, x, y, 0);
2114 /* to be sure: if icu was 0, or only 1 curve visible */
2115 ei->flag |= IPO_SELECT;
2116 ei->icu->flag= ei->flag;
2118 editipo_changed(G.sipo, 1);
2119 BIF_undo_push("Add Ipo vertex");
2123 void insertkey_editipo(void)
2128 float *fp, cfra, *insertvals;
2132 ei= get_active_editipo();
2133 if(ei && ei->icu && ei->icu->driver)
2134 event= pupmenu("Insert Curve %t|Default one-to-one mapping %x3");
2135 else if(G.sipo->showkey)
2136 event= pupmenu("Insert Key Vertices %t|Current Frame %x1|Selected Keys %x2");
2138 event= pupmenu("Insert Key Vertices %t|Current Frame %x1");
2143 IpoDriver *driver= ei->icu->driver;
2145 if(ei->icu->bezt) MEM_freeN(ei->icu->bezt);
2146 ei->icu->totvert= 0;
2147 ei->icu->bezt= NULL;
2149 insert_vert_icu(ei->icu, 0.0f, 0.0f, 0);
2151 if(ELEM3(driver->adrcode, OB_ROT_X, OB_ROT_Y, OB_ROT_Z)) {
2152 if(ei->disptype==IPO_DISPDEGR)
2153 insert_vert_icu(ei->icu, 18.0f, 18.0f, 0);
2155 insert_vert_icu(ei->icu, 18.0f, 1.0f, 0);
2158 insert_vert_icu(ei->icu, 1.0f, 1.0f, 0);
2160 ei->flag |= IPO_SELECT|IPO_VISIBLE;
2161 ei->icu->flag= ei->flag;
2162 ei->icu->extrap= IPO_DIR;
2164 do_ipo_buttons(B_IPOHOME);
2167 ei= G.sipo->editipo;
2168 for(nr=0; nr<G.sipo->totipo; nr++, ei++) {
2169 if (ISPOIN(ei, flag & IPO_VISIBLE, icu)) {
2172 if(G.sipo->showkey) ok= 1;
2173 else if(ei->flag & IPO_SELECT) ok= 1;
2177 if(event==1) tot= 1;
2179 ik= G.sipo->ipokey.first;
2182 if(ik->flag & 1) tot++;
2188 /* correction for ob timeoffs */
2189 cfra= frame_to_float(CFRA);
2191 if(id && GS(id->name)==ID_OB ) {
2192 Object *ob= (Object *)id;
2193 if((ob->ipoflag & OB_OFFS_OB) && (give_timeoffset(ob)!=0.0) ) {
2194 cfra-= give_timeoffset(ob)*G.scene->r.framelen;
2197 else if(id && GS(id->name)==ID_SEQ) {
2198 Sequence *last_seq = get_last_seq(); /* editsequence.c */
2200 if(last_seq && (last_seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) {
2201 cfra= (float)(100.0*(cfra-last_seq->startdisp)/((float)(last_seq->enddisp-last_seq->startdisp)));
2205 /* convert cfra to ipo-time */
2206 if (NLA_IPO_SCALED) {
2207 cfra= get_action_frame(OBACT, cfra);
2210 insertvals= MEM_mallocN(sizeof(float)*2*tot, "insertkey_editipo");
2211 /* make sure icu->curval is correct */
2212 calc_ipo(G.sipo->ipo, cfra);
2215 insertvals[0]= cfra;
2217 insertvals[1]= ei->icu->curval;
2221 ik= G.sipo->ipokey.first;
2224 calc_ipo(G.sipo->ipo, ik->val);
2227 fp[1]= ei->icu->curval;
2234 for(a=0; a<tot; a++, fp+=2) {
2235 insert_vert_icu(ei->icu, fp[0], fp[1], 0);
2238 MEM_freeN(insertvals);
2239 calc_ipo(G.sipo->ipo, (float)CFRA);
2245 BIF_undo_push("Insert Key Ipo");
2246 allqueue (REDRAWACTION, 0);
2247 allqueue(REDRAWNLA, 0);
2248 allqueue(REDRAWIPO, 0);
2249 allspace(REMAKEIPO, 0);
2253 /* ****************************************************************************** */
2255 void add_duplicate_editipo(void)
2260 BezTriple *bezt, *beztn, *newb;
2263 get_status_editipo();
2264 if(totipo_vertsel==0) return;
2266 ei= G.sipo->editipo;
2267 for(a=0; a<G.sipo->totipo; a++, ei++) {
2268 if (ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt)) {
2269 if(G.sipo->showkey || (ei->flag & IPO_EDIT)) {
2272 /* how many points */
2277 if(bezt->f2 & SELECT) tot++;
2283 newb= beztn= MEM_mallocN(icu->totvert*sizeof(BezTriple), "bezt");
2285 b= icu->totvert-tot;
2288 if(bezt->f2 & SELECT) {
2296 MEM_freeN(icu->bezt);
2299 calchandles_ipocurve(icu);
2305 if(G.sipo->showkey) {
2307 if(G.sipo->blocktype==ID_OB) {
2309 if(ob && (ob->ipoflag & OB_DRAWKEY)) allqueue(REDRAWVIEW3D, 0);
2312 BIF_undo_push("Duplicate Ipo");
2316 void remove_doubles_ipo(void)
2320 BezTriple *bezt, *newb, *new1;
2324 ei= G.sipo->editipo;
2325 for(a=0; a<G.sipo->totipo; a++, ei++) {
2326 if (ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt)) {
2328 /* OR the curve is selected OR in editmode OR in keymode */
2330 if(G.sipo->showkey || (ei->flag & IPO_EDIT)) mode= 1;
2331 else if(ei->flag & IPO_SELECT) mode= 2;
2334 bezt= ei->icu->bezt;
2335 newb= new1= MEM_mallocN(ei->icu->totvert*sizeof(BezTriple), "newbezt");
2337 b= ei->icu->totvert-1;
2341 /* can we remove? */
2342 if(mode==2 || (bezt->f2 & SELECT)) {
2344 /* are the points different? */
2345 if( fabs( bezt->vec[1][0]-newb->vec[1][0] ) > 0.9 ) {
2351 VecMidf(newb->vec[0], newb->vec[0], bezt->vec[0]);
2352 VecMidf(newb->vec[1], newb->vec[1], bezt->vec[1]);
2353 VecMidf(newb->vec[2], newb->vec[2], bezt->vec[2]);
2355 newb->h1= newb->h2= HD_FREE;
2368 MEM_freeN(ei->icu->bezt);
2369 ei->icu->bezt= new1;
2371 calchandles_ipocurve(ei->icu);
2376 editipo_changed(G.sipo, 1); /* makes ipokeys again! */
2378 /* remove double keys */
2379 if(G.sipo->showkey) {
2380 ik= G.sipo->ipokey.first;
2384 if( (ik->flag & 1) && (ikn->flag & 1) ) {
2385 if( fabs(ik->val-ikn->val) < 0.9 ) {
2386 val= (float)((ik->val + ikn->val)/2.0);
2388 for(a=0; a<G.sipo->totipo; a++) {
2389 if(ik->data[a]) ik->data[a]->vec[1][0]= val;
2390 if(ikn->data[a]) ikn->data[a]->vec[1][0]= val;
2399 editipo_changed(G.sipo, 1); /* makes ipokeys agian! */
2402 deselectall_editipo();
2403 BIF_undo_push("Remove Doubles (IPO)");
2407 void clean_ipo(void)
2413 ok= fbutton(&G.scene->toolsettings->clean_thresh,
2414 0.0000001f, 1.0, 0.001, 0.1,
2418 get_status_editipo();
2420 ei= G.sipo->editipo;
2421 for(b=0; b<G.sipo->totipo; b++, ei++) {
2422 if (ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt)) {
2425 if(G.sipo->showkey) ok= 1;
2426 else if(totipo_vert && (ei->flag & IPO_EDIT)) ok= 2;
2427 else if(totipo_vert==0 && (ei->flag & IPO_SELECT)) ok= 3;
2430 /* only clean if ok */
2431 clean_ipo_curve(ei->icu);
2436 editipo_changed(G.sipo, 1);
2437 BIF_undo_push("Clean IPO");
2440 void clean_ipo_curve(IpoCurve *icu)
2442 BezTriple *old_bezts, *bezt, *beztn;
2447 /* check if any points */
2448 if (icu == NULL || icu->totvert <= 1)
2451 /* get threshold for match-testing */
2452 thresh= G.scene->toolsettings->clean_thresh;
2454 /* make a copy of the old BezTriples, and clear IPO curve */
2455 old_bezts = icu->bezt;
2456 totCount = icu->totvert;
2460 /* now insert first keyframe, as it should be ok */
2462 insert_vert_icu(icu, bezt->vec[1][0], bezt->vec[1][1], 0);
2464 /* Loop through BezTriples, comparing them. Skip any that do
2465 * not fit the criteria for "ok" points.
2467 for (i=1; i<totCount; i++) {
2468 float prev[2], cur[2], next[2];
2470 /* get BezTriples and their values */
2471 if (i < (totCount - 1)) {
2472 beztn = (old_bezts + (i+1));
2473 next[0]= beztn->vec[1][0]; next[1]= beztn->vec[1][1];
2477 next[0] = next[1] = 0.0f;
2479 lastb= (icu->bezt + (icu->totvert - 1));
2480 bezt= (old_bezts + i);
2482 /* get references for quicker access */
2483 prev[0] = lastb->vec[1][0]; prev[1] = lastb->vec[1][1];
2484 cur[0] = bezt->vec[1][0]; cur[1] = bezt->vec[1][1];
2486 /* check if current bezt occurs at same time as last ok */
2487 if (IS_EQT(cur[0], prev[0], thresh)) {
2488 /* If there is a next beztriple, and if occurs at the same time, only insert
2489 * if there is a considerable distance between the points, and also if the
2490 * current is further away than the next one is to the previous.
2492 if (beztn && (IS_EQT(cur[0], next[0], thresh)) &&
2493 (IS_EQT(next[1], prev[1], thresh)==0))
2495 /* only add if current is further away from previous */
2496 if (cur[1] > next[1]) {
2497 if (IS_EQT(cur[1], prev[1], thresh) == 0) {
2498 /* add new keyframe */
2499 insert_vert_icu(icu, cur[0], cur[1], 0);
2504 /* only add if values are a considerable distance apart */
2505 if (IS_EQT(cur[1], prev[1], thresh) == 0) {
2506 /* add new keyframe */
2507 insert_vert_icu(icu, cur[0], cur[1], 0);
2512 /* checks required are dependent on whether this is last keyframe or not */
2514 /* does current have same value as previous and next? */
2515 if (IS_EQT(cur[1], prev[1], thresh) == 0) {
2516 /* add new keyframe*/
2517 insert_vert_icu(icu, cur[0], cur[1], 0);
2519 else if (IS_EQT(cur[1], next[1], thresh) == 0) {
2520 /* add new keyframe */
2521 insert_vert_icu(icu, cur[0], cur[1], 0);
2525 /* add if value doesn't equal that of previous */
2526 if (IS_EQT(cur[1], prev[1], thresh) == 0) {
2527 /* add new keyframe */
2528 insert_vert_icu(icu, cur[0], cur[1], 0);
2534 /* now free the memory used by the old BezTriples */
2536 MEM_freeN(old_bezts);
2540 /* temp struct used for smooth_ipo */
2541 typedef struct tSmooth_Bezt {
2542 float *h1, *h2, *h3; /* bezt->vec[0,1,2][1] */
2545 void smooth_ipo(void)
2551 get_status_editipo();
2553 ei= G.sipo->editipo;
2554 for(b=0; b<G.sipo->totipo; b++, ei++) {
2555 if (ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt)) {
2557 if(G.sipo->showkey) ok= 1;
2558 else if(totipo_vert && (ei->flag & IPO_EDIT)) ok= 2;
2559 else if(totipo_vert==0 && (ei->flag & IPO_SELECT)) ok= 3;
2562 IpoCurve *icu= ei->icu;
2564 int i, x, totSel = 0;
2566 /* check if enough points */
2567 if (icu->totvert >= 3) {
2568 /* first loop through - count how many verts are selected, and fix up handles */
2570 for (i=0; i < icu->totvert; i++, bezt++) {
2571 if (BEZSELECTED(bezt)) {
2572 /* line point's handles up with point's vertical position */
2573 bezt->vec[0][1]= bezt->vec[2][1]= bezt->vec[1][1];
2574 if ((bezt->h1==HD_AUTO) || (bezt->h1==HD_VECT)) bezt->h1= HD_ALIGN;
2575 if ((bezt->h2==HD_AUTO) || (bezt->h2==HD_VECT)) bezt->h2= HD_ALIGN;
2577 /* add value to total */
2582 /* if any points were selected, allocate tSmooth_Bezt points to work on */
2584 tSmooth_Bezt *tarray, *tsb;
2586 /* allocate memory in one go */
2587 tsb= tarray= MEM_callocN(totSel*sizeof(tSmooth_Bezt), "tSmooth_Bezt Array");
2589 /* populate tarray with data of selected points */
2591 for (i=0, x=0; (i < icu->totvert) && (x < totSel); i++, bezt++) {
2592 if (BEZSELECTED(bezt)) {
2593 /* tsb simply needs pointer to vec, and index */
2594 tsb->h1 = &bezt->vec[0][1];
2595 tsb->h2 = &bezt->vec[1][1];
2596 tsb->h3 = &bezt->vec[2][1];
2598 /* advance to the next tsb to populate */
2606 /* calculate the new smoothed ipo's with weighted averages:
2607 * - this is done with two passes
2608 * - uses 5 points for each operation (which stores in the relevant handles)
2609 * - previous: w/a ratio = 3:5:2:1:1
2610 * - next: w/a ratio = 1:1:2:5:3
2613 /* round 1: calculate previous and next */
2615 for (i=0; i < totSel; i++, tsb++) {
2616 /* don't touch end points (otherwise, curves slowly explode) */
2617 if (ELEM(i, 0, (totSel-1)) == 0) {
2618 tSmooth_Bezt *tP1 = tsb - 1;
2619 tSmooth_Bezt *tP2 = (i-2 > 0) ? (tsb - 2) : (NULL);
2620 tSmooth_Bezt *tN1 = tsb + 1;
2621 tSmooth_Bezt *tN2 = (i+2 < totSel) ? (tsb + 2) : (NULL);
2623 float p1 = *tP1->h2;
2624 float p2 = (tP2) ? (*tP2->h2) : (*tP1->h2);
2625 float c1 = *tsb->h2;
2626 float n1 = *tN1->h2;
2627 float n2 = (tN2) ? (*tN2->h2) : (*tN1->h2);
2629 /* calculate previous and next */
2630 *tsb->h1= (3*p2 + 5*p1 + 2*c1 + n1 + n2) / 12;
2631 *tsb->h3= (p2 + p1 + 2*c1 + 5*n1 + 3*n2) / 12;
2635 /* round 2: calculate new values and reset handles */
2637 for (i=0; i < totSel; i++, tsb++) {
2638 /* calculate new position by averaging handles */
2639 *tsb->h2 = (*tsb->h1 + *tsb->h3) / 2;
2641 /* reset handles now */
2642 *tsb->h1 = *tsb->h2;
2643 *tsb->h3 = *tsb->h2;
2646 /* free memory required for tarray */
2651 /* recalculate handles */
2652 calchandles_ipocurve(icu);
2657 editipo_changed(G.sipo, 1);
2658 BIF_undo_push("Smooth IPO");
2661 void join_ipo_menu(void)
2664 mode= pupmenu("Join %t|All Selected %x1|Selected Doubles %x2");
2666 if (mode == -1) return;
2671 void join_ipo(int mode)
2676 BezTriple *bezt, *beztn, *newb;
2680 get_status_editipo();
2684 * Selected Doubles: 2
2688 remove_doubles_ipo();
2692 /* first: multiple selected verts in 1 curve */
2693 ei= G.sipo->editipo;
2694 for(a=0; a<G.sipo->totipo; a++, ei++) {
2695 if (ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt)) {
2696 if(G.sipo->showkey || (ei->flag & IPO_EDIT)) {
2699 /* how many points */
2704 if(bezt->f2 & SELECT) tot++;
2712 newb= MEM_mallocN(icu->totvert*sizeof(BezTriple), "bezt");
2713 /* the first point is the new one */
2718 b= icu->totvert+tot+1;
2721 if(bezt->f2 & SELECT) {
2722 if(tot==0) *newb= *bezt;
2724 VecAddf(newb->vec[0], newb->vec[0], bezt->vec[0]);
2725 VecAddf(newb->vec[1], newb->vec[1], bezt->vec[1]);
2726 VecAddf(newb->vec[2], newb->vec[2], bezt->vec[2]);
2737 VecMulf(newb->vec[0], (float)(1.0/((float)tot)));
2738 VecMulf(newb->vec[1], (float)(1.0/((float)tot)));
2739 VecMulf(newb->vec[2], (float)(1.0/((float)tot)));
2741 MEM_freeN(icu->bezt);
2744 sort_time_ipocurve(icu);
2745 calchandles_ipocurve(icu);
2751 /* next: in keymode: join multiple selected keys */
2753 editipo_changed(G.sipo, 1); /* makes ipokeys again! */
2755 if(G.sipo->showkey) {
2756 ik= G.sipo->ipokey.first;
2761 for(a=0; a<G.sipo->totipo; a++) {
2763 val+= ik->data[a]->vec[1][0];
2774 ik= G.sipo->ipokey.first;
2777 for(a=0; a<G.sipo->totipo; a++) {
2779 ik->data[a]->vec[1][0]= val;
2785 editipo_changed(G.sipo, 0);
2788 deselectall_editipo();
2789 BIF_undo_push("Join Ipo");
2792 void ipo_snap_menu(void)
2796 event= pupmenu("Snap %t|Horizontal %x1|To Next %x2|To Frame %x3|To Current Frame%x4");
2797 if(event < 1) return;
2802 void ipo_snap(short event)
2814 * To Current Frame: 4
2817 get_status_editipo();
2819 /* map ipo-points for editing if scaled ipo */
2820 if (NLA_IPO_SCALED) {
2821 actstrip_map_ipo_keys(OBACT, G.sipo->ipo, 0, 0);
2824 ei= G.sipo->editipo;
2825 for(b=0; b<G.sipo->totipo; b++, ei++) {
2826 if (ISPOIN3(ei, flag & IPO_VISIBLE, icu, icu->bezt)) {
2829 if(G.sipo->showkey) ok2= 1;
2830 else if(totipo_vert && (ei->flag & IPO_EDIT)) ok2= 2;
2831 else if(totipo_vert==0 && (ei->flag & IPO_SELECT)) ok2= 3;
2834 bezt= ei->icu->bezt;
2835 a= ei->icu->totvert;
2839 if(bezt->f2 & SELECT) ok= 1;
2845 bezt->vec[0][1]= bezt->vec[2][1]= bezt->vec[1][1];
2846 if(bezt->h1==HD_AUTO || bezt->h1==HD_VECT) bezt->h1= HD_ALIGN;
2847 if(bezt->h2==HD_AUTO || bezt->h2==HD_VECT) bezt->h2= HD_ALIGN;
2851 bezt->vec[0][1]= bezt->vec[1][1]= bezt->vec[2][1]= (bezt+1)->vec[1][1];
2852 if(bezt->h1==HD_AUTO || bezt->h1==HD_VECT) bezt->h1= HD_ALIGN;
2853 if(bezt->h2==HD_AUTO || bezt->h2==HD_VECT) bezt->h2= HD_ALIGN;
2857 bezt->vec[1][0]= (float)(floor(bezt->vec[1][0]+0.5));
2859 else if(event==4) { /* to current frame */
2861 if(ok2==1 || ok2==2) {
2863 if(G.sipo->blocktype==ID_SEQ) {
2866 seq= (Sequence *)G.sipo->from;
2867 if(seq && (seq->flag & SEQ_IPO_FRAME_LOCKED) == 0) {