moai/src/moaicore/MOAIAnimCurveBase.cpp
//----------------------------------------------------------------//
// return the time wrapped to fall within the time span defined by the curve
// in APPEND mode, 'repeat' gives the cycle (how many complete spans have elapsed)
return the time wrapped to fall within the time span defined by the curve
in APPEND mode, 'repeat' gives the cycle (how many complete spans have elapsed)
return the time wrapped to fall within the time span defined by the curve in APPEND mode ' repeat ' gives the cycle ( how many complete spans have elapsed )
float MOAIAnimCurveBase::WrapTime ( float t, float &repeat ) const {
	float startTime = this->mKeys [ 0 ].mTime;
	float length = GetLength ();
	float time = ( t - startTime ) / length; 
	float wrappedT = 0.0f;
	repeat = 0.0f;
	switch ( mWrapMode ) {
		case CLAMP: {
			wrappedT = USFloat::Clamp ( time, 0.0f, 1.0f );
		}
		break;
		case WRAP: {
			wrappedT = time - USFloat::Floor ( time );
		}
		break;
		case MIRROR: {
			u32 tFloor = ( u32 ) USFloat::Floor ( time );
			if ( tFloor % 2 ) {
				wrappedT = 1.0f - ( time - tFloor );
			}
			else {
				wrappedT = ( time - tFloor );
			}
		}
		break;
		case APPEND: {
			wrappedT = time - USFloat::Floor ( time );
			repeat = USFloat::Floor ( time );
		}
		break;
	}
	wrappedT = wrappedT * length + startTime;
	if ( wrappedT + EPSILON > t && wrappedT - EPSILON < t ) { 
		wrappedT = t; 
	}
	return wrappedT;
}
float MOAIAnimCurveBase :: WrapTime ( float t , float & repeat ) const { float startTime = this -> mKeys [ 0 ] . mTime ; float length = GetLength ( ) ; float time = ( t - startTime ) / length ; float wrappedT = 0.0f ; repeat = 0.0f ; switch ( mWrapMode ) { case CLAMP : { wrappedT = USFloat :: Clamp ( time , 0.0f , 1.0f ) ; } break ; case WRAP : { wrappedT = time - USFloat :: Floor ( time ) ; } break ; case MIRROR : { u32 tFloor = ( u32 ) USFloat :: Floor ( time ) ; if ( tFloor % 2 ) { wrappedT = 1.0f - ( time - tFloor ) ; } else { wrappedT = ( time - tFloor ) ; } } break ; case APPEND : { wrappedT = time - USFloat :: Floor ( time ) ; repeat = USFloat :: Floor ( time ) ; } break ; } wrappedT = wrappedT * length + startTime ; if ( wrappedT + EPSILON > t && wrappedT - EPSILON < t ) { wrappedT = t ; } return wrappedT ; }
return the time wrapped to fall within the time span defined by the curve
in APPEND mode, 'repeat' gives the cycle (how many complete spans have elapsed)
return the time wrapped to fall within the time span defined by the curve in APPEND mode ' repeat ' gives the cycle ( how many complete spans have elapsed )
// normalize time