dsys2

view src/dsys_impl.h @ 0:34d90cd9ef9b

starting a new demosystem
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 20 Aug 2011 07:48:16 +0300
parents
children 1705e550bd91
line source
1 #ifndef DSYS_IMPL_H_
2 #define DSYS_IMPL_H_
4 #include "dsys2.h"
6 static float eval_step(struct dsys_event *ev, demotime_t t);
7 static float eval_lerp(struct dsys_event *ev, demotime_t t);
8 static float eval_sigmoid(struct dsys_event *ev, demotime_t t);
11 struct dsys_demo {
12 demotime_t srctime;
14 struct dsys_event *ev;
15 int num_ev;
16 };
18 struct callback {
19 void (*func)(struct dsys_event*, void*);
20 void *cls;
22 struct callback *next;
23 };
26 struct dsys_event {
27 enum dsys_evtype type;
29 demotime_t t0, t1;
30 float val;
32 float (*eval_func)(struct dsys_event*);
34 struct callback *cblist;
35 };
38 static float eval_step(struct dsys_event *ev, demotime_t t)
39 {
40 return t >= ev->t1 ? 1.0 : 0.0;
41 }
43 static float eval_lerp(struct dsys_event *ev, demotime_t t)
44 {
45 return (t - ev->t0) / (ev->t1 - ev->t0);
46 }
48 static float eval_sigmoid(struct dsys_event *ev, demotime_t t)
49 {
50 t = eval_lerp(ev, t);
51 return 1.0 - (cos(t * M_PI) * 0.5 + 0.5);
52 }
54 #endif /* DSYS_IMPL_H_ */