vrshoot

annotate libs/psys/pstrack.c @ 2:334d17aed7de

visual studio project files
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 02 Feb 2014 18:36:38 +0200
parents
children
rev   line source
nuclear@0 1 #include "pstrack.h"
nuclear@0 2
nuclear@0 3 int psys_init_track(struct psys_track *track)
nuclear@0 4 {
nuclear@0 5 track->cache_tm = ANM_TIME_INVAL;
nuclear@0 6
nuclear@0 7 if(anm_init_track(&track->trk) == -1) {
nuclear@0 8 return -1;
nuclear@0 9 }
nuclear@0 10 return 0;
nuclear@0 11 }
nuclear@0 12
nuclear@0 13 void psys_destroy_track(struct psys_track *track)
nuclear@0 14 {
nuclear@0 15 anm_destroy_track(&track->trk);
nuclear@0 16 }
nuclear@0 17
nuclear@0 18 int psys_init_track3(struct psys_track3 *track)
nuclear@0 19 {
nuclear@0 20 track->cache_tm = ANM_TIME_INVAL;
nuclear@0 21
nuclear@0 22 if(anm_init_track(&track->x) == -1) {
nuclear@0 23 return -1;
nuclear@0 24 }
nuclear@0 25 if(anm_init_track(&track->y) == -1) {
nuclear@0 26 anm_destroy_track(&track->x);
nuclear@0 27 return -1;
nuclear@0 28 }
nuclear@0 29 if(anm_init_track(&track->z) == -1) {
nuclear@0 30 anm_destroy_track(&track->x);
nuclear@0 31 anm_destroy_track(&track->z);
nuclear@0 32 return -1;
nuclear@0 33 }
nuclear@0 34 return 0;
nuclear@0 35 }
nuclear@0 36
nuclear@0 37 void psys_destroy_track3(struct psys_track3 *track)
nuclear@0 38 {
nuclear@0 39 anm_destroy_track(&track->x);
nuclear@0 40 anm_destroy_track(&track->y);
nuclear@0 41 anm_destroy_track(&track->z);
nuclear@0 42 }
nuclear@0 43
nuclear@0 44 void psys_copy_track(struct psys_track *dest, const struct psys_track *src)
nuclear@0 45 {
nuclear@0 46 anm_copy_track(&dest->trk, &src->trk);
nuclear@0 47 dest->cache_tm = ANM_TIME_INVAL;
nuclear@0 48 }
nuclear@0 49
nuclear@0 50 void psys_copy_track3(struct psys_track3 *dest, const struct psys_track3 *src)
nuclear@0 51 {
nuclear@0 52 anm_copy_track(&dest->x, &src->x);
nuclear@0 53 anm_copy_track(&dest->y, &src->y);
nuclear@0 54 anm_copy_track(&dest->z, &src->z);
nuclear@0 55
nuclear@0 56 dest->cache_tm = ANM_TIME_INVAL;
nuclear@0 57 }
nuclear@0 58
nuclear@0 59 void psys_eval_track(struct psys_track *track, anm_time_t tm)
nuclear@0 60 {
nuclear@0 61 if(track->cache_tm != tm) {
nuclear@0 62 track->cache_tm = tm;
nuclear@0 63 track->cache_val = anm_get_value(&track->trk, tm);
nuclear@0 64 }
nuclear@0 65 }
nuclear@0 66
nuclear@0 67 void psys_set_value(struct psys_track *track, anm_time_t tm, float v)
nuclear@0 68 {
nuclear@0 69 anm_set_value(&track->trk, tm, v);
nuclear@0 70 track->cache_tm = ANM_TIME_INVAL;
nuclear@0 71 }
nuclear@0 72
nuclear@0 73 float psys_get_value(struct psys_track *track, anm_time_t tm)
nuclear@0 74 {
nuclear@0 75 psys_eval_track(track, tm);
nuclear@0 76 return track->cache_val;
nuclear@0 77 }
nuclear@0 78
nuclear@0 79 float psys_get_cur_value(struct psys_track *track)
nuclear@0 80 {
nuclear@0 81 return track->cache_val;
nuclear@0 82 }
nuclear@0 83
nuclear@0 84
nuclear@0 85 void psys_eval_track3(struct psys_track3 *track, anm_time_t tm)
nuclear@0 86 {
nuclear@0 87 if(track->cache_tm != tm) {
nuclear@0 88 track->cache_tm = tm;
nuclear@0 89 track->cache_vec.x = anm_get_value(&track->x, tm);
nuclear@0 90 track->cache_vec.y = anm_get_value(&track->y, tm);
nuclear@0 91 track->cache_vec.z = anm_get_value(&track->z, tm);
nuclear@0 92 }
nuclear@0 93 }
nuclear@0 94
nuclear@0 95 void psys_set_value3(struct psys_track3 *track, anm_time_t tm, vec3_t v)
nuclear@0 96 {
nuclear@0 97 anm_set_value(&track->x, tm, v.x);
nuclear@0 98 anm_set_value(&track->y, tm, v.y);
nuclear@0 99 anm_set_value(&track->z, tm, v.z);
nuclear@0 100 track->cache_tm = ANM_TIME_INVAL;
nuclear@0 101 }
nuclear@0 102
nuclear@0 103 vec3_t psys_get_value3(struct psys_track3 *track, anm_time_t tm)
nuclear@0 104 {
nuclear@0 105 psys_eval_track3(track, tm);
nuclear@0 106 return track->cache_vec;
nuclear@0 107 }
nuclear@0 108
nuclear@0 109 vec3_t psys_get_cur_value3(struct psys_track3 *track)
nuclear@0 110 {
nuclear@0 111 return track->cache_vec;
nuclear@0 112 }