libanim

changeset 3:9cd8afd6fa6d

fixed a bug in time clamping
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 27 Feb 2013 06:20:26 +0200
parents f561282b13e8
children 1ce7e250bae3
files src/track.c
diffstat 1 files changed, 11 insertions(+), 2 deletions(-) [+]
line diff
     1.1 --- a/src/track.c	Mon Feb 25 05:58:09 2013 +0200
     1.2 +++ b/src/track.c	Wed Feb 27 06:20:26 2013 +0200
     1.3 @@ -276,18 +276,27 @@
     1.4  
     1.5  static anm_time_t remap_clamp(anm_time_t tm, anm_time_t start, anm_time_t end)
     1.6  {
     1.7 +	if(start == end) {
     1.8 +		return start;
     1.9 +	}
    1.10  	return tm < start ? start : (tm >= end ? end - 1 : tm);
    1.11  }
    1.12  
    1.13  static anm_time_t remap_repeat(anm_time_t tm, anm_time_t start, anm_time_t end)
    1.14  {
    1.15  	anm_time_t interv = end - start;
    1.16 +	anm_time_t x = (tm - start) % interv;
    1.17  
    1.18 -	if(tm < start) {
    1.19 +	if(x < 0) {
    1.20 +		x += interv;
    1.21 +	}
    1.22 +	return x + start;
    1.23 +
    1.24 +	/*if(tm < start) {
    1.25  		while(tm < start) {
    1.26  			tm += interv;
    1.27  		}
    1.28  		return tm;
    1.29  	}
    1.30 -	return (tm - start) % interv + start;
    1.31 +	return (tm - start) % interv + start;*/
    1.32  }