== Ipo ==

This fixes [#11118] Record Mouse in IPO Curve Editor 2.46rc3
and adds thereby a new feature: correct audio sync to IPO mouse recording :)
This commit is contained in:
Peter Schlaile 2008-05-12 17:16:54 +00:00
parent c471b6db74
commit d2fcba7f65
3 changed files with 32 additions and 13 deletions

@ -59,7 +59,7 @@ void drawview3d_render(struct View3D *v3d, int winx, int winy, float winmat[][4]
void draw_depth(struct ScrArea *sa, void *spacedata);
void view3d_update_depths(struct View3D *v3d);
int update_time(void);
int update_time(int cfra);
void calc_viewborder(struct View3D *v3d, struct rctf *viewborder_r);
void view3d_set_1_to_1_viewborder(struct View3D *v3d);

@ -3398,12 +3398,12 @@ static float redrawtimes_fps[REDRAW_FRAME_AVERAGE];
static short redrawtime_index;
int update_time(void)
int update_time(int cfra)
{
static double ltime;
double time;
if ((audiostream_pos() != CFRA)
if ((audiostream_pos() != cfra)
&& (G.scene->audio.flag & AUDIO_SYNC)) {
return 0;
}
@ -3641,7 +3641,7 @@ void inner_play_anim_loop(int init, int mode)
/* make sure that swaptime passed by */
tottime -= swaptime;
while (update_time()) {
while (update_time(CFRA)) {
PIL_sleep_ms(1);
}
@ -3700,7 +3700,7 @@ int play_anim(int mode)
inner_play_prefetch_startup(mode);
update_time();
update_time(CFRA);
inner_play_anim_loop(1, mode); /* 1==init */

@ -116,6 +116,7 @@
#include "BSE_headerbuttons.h"
#include "BSE_node.h"
#include "BSE_sequence.h"
#include "BSE_seqaudio.h"
#include "BSE_time.h"
#include "blendef.h"
@ -5643,7 +5644,7 @@ void ipo_record(void)
if(poin) ei1->icu->curval= read_ipo_poin(poin, type);
or1= ei1->icu->curval;
ei1->icu->flag |= IPO_LOCK;
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);
@ -5671,8 +5672,9 @@ void ipo_record(void)
}
sa= sa->next;
}
if(sa) areawinset(sa->win);
/* can we? */
while(get_mbut()&L_MOUSE) BIF_wait_for_statechange();
data1= MEM_callocN(sizeof(float)*(EFRA-SFRA+1), "data1");
@ -5681,14 +5683,18 @@ void ipo_record(void)
getmouseco_areawin(mvalo);
xn= mvalo[0]; yn= mvalo[1];
waitcursor(1);
tottime= 0.0;
swaptime= 1.0/FPS;
cfrao= CFRA;
cfra=efra= SFRA;
sfra= EFRA;
if (G.scene->audio.flag & AUDIO_SYNC) {
audiostream_start(cfra);
}
while(afbreek==0) {
getmouseco_areawin(mval);
@ -5698,7 +5704,7 @@ void ipo_record(void)
else firsttime= 0;
set_timecursor(cfra);
/* do ipo: first all, then the specific ones */
if(anim==2) {
do_ob_ipo(ob);
@ -5729,7 +5735,7 @@ void ipo_record(void)
/* minimal wait swaptime */
tottime -= swaptime;
while (update_time()) PIL_sleep_ms(1);
while (update_time(cfra)) PIL_sleep_ms(1);
screen_swapbuffers();
@ -5739,8 +5745,18 @@ void ipo_record(void)
mvalo[1]= mval[1];
if(anim || (G.qual & LR_CTRLKEY)) {
cfra++;
if(cfra>EFRA) cfra= SFRA;
if (G.scene->audio.flag & AUDIO_SYNC) {
cfra = audiostream_pos();
} else {
cfra++;
}
if(cfra>EFRA) {
cfra= SFRA;
if (G.scene->audio.flag & AUDIO_SYNC) {
audiostream_stop();
audiostream_start( cfra );
}
}
}
}
@ -5793,6 +5809,9 @@ void ipo_record(void)
editipo_changed(G.sipo, 0);
do_ipo(G.sipo->ipo);
waitcursor(0);
if (G.scene->audio.flag & AUDIO_SYNC) {
audiostream_stop();
}
allqueue(REDRAWVIEW3D, 0);
if(sa) scrarea_queue_headredraw(sa); /* headerprint */