libpsys

view src/pstrack.c @ 10:0f83e882fd04

install target
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 29 Aug 2012 03:16:58 +0300
parents
children
line source
1 #include "pstrack.h"
3 int psys_init_track(struct psys_track *track)
4 {
5 track->cache_tm = ANM_TIME_INVAL;
7 if(anm_init_track(&track->trk) == -1) {
8 return -1;
9 }
10 return 0;
11 }
13 void psys_destroy_track(struct psys_track *track)
14 {
15 anm_destroy_track(&track->trk);
16 }
18 int psys_init_track3(struct psys_track3 *track)
19 {
20 track->cache_tm = ANM_TIME_INVAL;
22 if(anm_init_track(&track->x) == -1) {
23 return -1;
24 }
25 if(anm_init_track(&track->y) == -1) {
26 anm_destroy_track(&track->x);
27 return -1;
28 }
29 if(anm_init_track(&track->z) == -1) {
30 anm_destroy_track(&track->x);
31 anm_destroy_track(&track->z);
32 return -1;
33 }
34 return 0;
35 }
37 void psys_destroy_track3(struct psys_track3 *track)
38 {
39 anm_destroy_track(&track->x);
40 anm_destroy_track(&track->y);
41 anm_destroy_track(&track->z);
42 }
44 void psys_eval_track(struct psys_track *track, anm_time_t tm)
45 {
46 if(track->cache_tm != tm) {
47 track->cache_tm = tm;
48 track->cache_val = anm_get_value(&track->trk, tm);
49 }
50 }
52 void psys_set_value(struct psys_track *track, anm_time_t tm, float v)
53 {
54 anm_set_value(&track->trk, tm, v);
55 track->cache_tm = ANM_TIME_INVAL;
56 }
58 float psys_get_value(struct psys_track *track, anm_time_t tm)
59 {
60 psys_eval_track(track, tm);
61 return track->cache_val;
62 }
64 float psys_get_cur_value(struct psys_track *track)
65 {
66 return track->cache_val;
67 }
70 void psys_eval_track3(struct psys_track3 *track, anm_time_t tm)
71 {
72 if(track->cache_tm != tm) {
73 track->cache_tm = tm;
74 track->cache_vec.x = anm_get_value(&track->x, tm);
75 track->cache_vec.y = anm_get_value(&track->y, tm);
76 track->cache_vec.z = anm_get_value(&track->z, tm);
77 }
78 }
80 void psys_set_value3(struct psys_track3 *track, anm_time_t tm, vec3_t v)
81 {
82 anm_set_value(&track->x, tm, v.x);
83 anm_set_value(&track->y, tm, v.y);
84 anm_set_value(&track->z, tm, v.z);
85 track->cache_tm = ANM_TIME_INVAL;
86 }
88 vec3_t psys_get_value3(struct psys_track3 *track, anm_time_t tm)
89 {
90 psys_eval_track3(track, tm);
91 return track->cache_vec;
92 }
94 vec3_t psys_get_cur_value3(struct psys_track3 *track)
95 {
96 return track->cache_vec;
97 }