dungeon_crawler

diff prototype/psys/pstrack.c @ 67:2560a7ab0243

internalized libanim, libimago2, and libpsys
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 07 Oct 2012 02:04:00 +0300
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/prototype/psys/pstrack.c	Sun Oct 07 02:04:00 2012 +0300
     1.3 @@ -0,0 +1,97 @@
     1.4 +#include "pstrack.h"
     1.5 +
     1.6 +int psys_init_track(struct psys_track *track)
     1.7 +{
     1.8 +	track->cache_tm = ANM_TIME_INVAL;
     1.9 +
    1.10 +	if(anm_init_track(&track->trk) == -1) {
    1.11 +		return -1;
    1.12 +	}
    1.13 +	return 0;
    1.14 +}
    1.15 +
    1.16 +void psys_destroy_track(struct psys_track *track)
    1.17 +{
    1.18 +	anm_destroy_track(&track->trk);
    1.19 +}
    1.20 +
    1.21 +int psys_init_track3(struct psys_track3 *track)
    1.22 +{
    1.23 +	track->cache_tm = ANM_TIME_INVAL;
    1.24 +
    1.25 +	if(anm_init_track(&track->x) == -1) {
    1.26 +		return -1;
    1.27 +	}
    1.28 +	if(anm_init_track(&track->y) == -1) {
    1.29 +		anm_destroy_track(&track->x);
    1.30 +		return -1;
    1.31 +	}
    1.32 +	if(anm_init_track(&track->z) == -1) {
    1.33 +		anm_destroy_track(&track->x);
    1.34 +		anm_destroy_track(&track->z);
    1.35 +		return -1;
    1.36 +	}
    1.37 +	return 0;
    1.38 +}
    1.39 +
    1.40 +void psys_destroy_track3(struct psys_track3 *track)
    1.41 +{
    1.42 +	anm_destroy_track(&track->x);
    1.43 +	anm_destroy_track(&track->y);
    1.44 +	anm_destroy_track(&track->z);
    1.45 +}
    1.46 +
    1.47 +void psys_eval_track(struct psys_track *track, anm_time_t tm)
    1.48 +{
    1.49 +	if(track->cache_tm != tm) {
    1.50 +		track->cache_tm = tm;
    1.51 +		track->cache_val = anm_get_value(&track->trk, tm);
    1.52 +	}
    1.53 +}
    1.54 +
    1.55 +void psys_set_value(struct psys_track *track, anm_time_t tm, float v)
    1.56 +{
    1.57 +	anm_set_value(&track->trk, tm, v);
    1.58 +	track->cache_tm = ANM_TIME_INVAL;
    1.59 +}
    1.60 +
    1.61 +float psys_get_value(struct psys_track *track, anm_time_t tm)
    1.62 +{
    1.63 +	psys_eval_track(track, tm);
    1.64 +	return track->cache_val;
    1.65 +}
    1.66 +
    1.67 +float psys_get_cur_value(struct psys_track *track)
    1.68 +{
    1.69 +	return track->cache_val;
    1.70 +}
    1.71 +
    1.72 +
    1.73 +void psys_eval_track3(struct psys_track3 *track, anm_time_t tm)
    1.74 +{
    1.75 +	if(track->cache_tm != tm) {
    1.76 +		track->cache_tm = tm;
    1.77 +		track->cache_vec.x = anm_get_value(&track->x, tm);
    1.78 +		track->cache_vec.y = anm_get_value(&track->y, tm);
    1.79 +		track->cache_vec.z = anm_get_value(&track->z, tm);
    1.80 +	}
    1.81 +}
    1.82 +
    1.83 +void psys_set_value3(struct psys_track3 *track, anm_time_t tm, vec3_t v)
    1.84 +{
    1.85 +	anm_set_value(&track->x, tm, v.x);
    1.86 +	anm_set_value(&track->y, tm, v.y);
    1.87 +	anm_set_value(&track->z, tm, v.z);
    1.88 +	track->cache_tm = ANM_TIME_INVAL;
    1.89 +}
    1.90 +
    1.91 +vec3_t psys_get_value3(struct psys_track3 *track, anm_time_t tm)
    1.92 +{
    1.93 +	psys_eval_track3(track, tm);
    1.94 +	return track->cache_vec;
    1.95 +}
    1.96 +
    1.97 +vec3_t psys_get_cur_value3(struct psys_track3 *track)
    1.98 +{
    1.99 +	return track->cache_vec;
   1.100 +}