vrshoot

view libs/psys/pstrack.c @ 3:c179c72369be

rename candy->vr
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 03 Feb 2014 08:52:13 +0200
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_copy_track(struct psys_track *dest, const struct psys_track *src)
45 {
46 anm_copy_track(&dest->trk, &src->trk);
47 dest->cache_tm = ANM_TIME_INVAL;
48 }
50 void psys_copy_track3(struct psys_track3 *dest, const struct psys_track3 *src)
51 {
52 anm_copy_track(&dest->x, &src->x);
53 anm_copy_track(&dest->y, &src->y);
54 anm_copy_track(&dest->z, &src->z);
56 dest->cache_tm = ANM_TIME_INVAL;
57 }
59 void psys_eval_track(struct psys_track *track, anm_time_t tm)
60 {
61 if(track->cache_tm != tm) {
62 track->cache_tm = tm;
63 track->cache_val = anm_get_value(&track->trk, tm);
64 }
65 }
67 void psys_set_value(struct psys_track *track, anm_time_t tm, float v)
68 {
69 anm_set_value(&track->trk, tm, v);
70 track->cache_tm = ANM_TIME_INVAL;
71 }
73 float psys_get_value(struct psys_track *track, anm_time_t tm)
74 {
75 psys_eval_track(track, tm);
76 return track->cache_val;
77 }
79 float psys_get_cur_value(struct psys_track *track)
80 {
81 return track->cache_val;
82 }
85 void psys_eval_track3(struct psys_track3 *track, anm_time_t tm)
86 {
87 if(track->cache_tm != tm) {
88 track->cache_tm = tm;
89 track->cache_vec.x = anm_get_value(&track->x, tm);
90 track->cache_vec.y = anm_get_value(&track->y, tm);
91 track->cache_vec.z = anm_get_value(&track->z, tm);
92 }
93 }
95 void psys_set_value3(struct psys_track3 *track, anm_time_t tm, vec3_t v)
96 {
97 anm_set_value(&track->x, tm, v.x);
98 anm_set_value(&track->y, tm, v.y);
99 anm_set_value(&track->z, tm, v.z);
100 track->cache_tm = ANM_TIME_INVAL;
101 }
103 vec3_t psys_get_value3(struct psys_track3 *track, anm_time_t tm)
104 {
105 psys_eval_track3(track, tm);
106 return track->cache_vec;
107 }
109 vec3_t psys_get_cur_value3(struct psys_track3 *track)
110 {
111 return track->cache_vec;
112 }