libanim
diff src/anim.h @ 20:3c2428cb38f7
added the option of lightweight pre-pass top-down recursive calculation of
matrices instead of going through the existing lazy thread-specific caching
algorithm.
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 09 Dec 2013 04:06:30 +0200 |
parents | 2cf7284d2bbb |
children | 5993f405a1cb |
line diff
1.1 --- a/src/anim.h Sat Nov 16 12:31:03 2013 +0200 1.2 +++ b/src/anim.h Mon Dec 09 04:06:30 2013 +0200 1.3 @@ -42,6 +42,9 @@ 1.4 pthread_key_t cache_key; 1.5 pthread_mutex_t cache_list_lock; 1.6 1.7 + /* matrix calculated by anm_eval functions (no locking, meant as a pre-pass) */ 1.8 + mat4_t matrix; 1.9 + 1.10 struct anm_node *parent; 1.11 struct anm_node *child; 1.12 struct anm_node *next; 1.13 @@ -95,10 +98,24 @@ 1.14 void anm_set_pivot(struct anm_node *node, vec3_t pivot); 1.15 vec3_t anm_get_pivot(struct anm_node *node); 1.16 1.17 +/* those return the start and end times of the whole tree */ 1.18 +anm_time_t anm_get_start_time(struct anm_node *node); 1.19 +anm_time_t anm_get_end_time(struct anm_node *node); 1.20 + 1.21 /* these calculate the matrix and inverse matrix of this node alone */ 1.22 void anm_get_node_matrix(struct anm_node *node, mat4_t mat, anm_time_t tm); 1.23 void anm_get_node_inv_matrix(struct anm_node *node, mat4_t mat, anm_time_t tm); 1.24 1.25 +/* ---- top-down matrix calculation interface ---- */ 1.26 + 1.27 +/* calculate and set the matrix of this node */ 1.28 +void anm_eval_node(struct anm_node *node, anm_time_t tm); 1.29 +/* calculate and set the matrix of this node and all its children recursively */ 1.30 +void anm_eval(struct anm_node *node, anm_time_t tm); 1.31 + 1.32 + 1.33 +/* ---- bottom-up lazy matrix calculation interface ---- */ 1.34 + 1.35 /* These calculate the matrix and inverse matrix of this node taking hierarchy 1.36 * into account. The results are cached in thread-specific storage and returned 1.37 * if there's no change in time or tracks from the last query... 1.38 @@ -106,10 +123,6 @@ 1.39 void anm_get_matrix(struct anm_node *node, mat4_t mat, anm_time_t tm); 1.40 void anm_get_inv_matrix(struct anm_node *node, mat4_t mat, anm_time_t tm); 1.41 1.42 -/* those return the start and end times of the whole tree */ 1.43 -anm_time_t anm_get_start_time(struct anm_node *node); 1.44 -anm_time_t anm_get_end_time(struct anm_node *node); 1.45 - 1.46 #ifdef __cplusplus 1.47 } 1.48 #endif