dungeon_crawler

annotate prototype/psys/pstrack.c @ 75:b05ab29cd17d

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