Exemple #1
0
        /// <summary>
        /// Returns next index (clamped)
        /// </summary>
        int GetNextValueTrackIndex(AMActionData[] values, int curInd, float curTime)
        {
            AMActionData val = values[curInd];

            int retInd = curInd;

            if(curTime < val.startTime) { //go backwards
                for(retInd = curInd - 1; retInd >= 0; retInd--) {
                    if(values[retInd].startTime <= curTime) {
                        if(values[retInd].endTime < curTime) //current time hasn't reached this segment yet
                            retInd = curInd;
                        break;
                    }
                    else { //this segment has been skipped
                        curInd = retInd;
                    }
                }
            }
            else if(curTime > val.endTime) { //forward
                for(retInd = curInd + 1; retInd < values.Length; retInd++) {
                    if(values[retInd].endTime >= curTime) {
                        if(values[retInd].startTime > curTime) //current time hasn't reached this segment yet
                            retInd = curInd;
                        break;
                    }
                    else { //this segment has been skipped
                        curInd = retInd;
                    }
                }
            }

            if(retInd < 0) return 0;
            else if(retInd >= values.Length) return values.Length - 1;

            return retInd;
        }
Exemple #2
0
        /// <summary>
        /// Returns index based on given time (clamped)
        /// </summary>
        int GetValueIndex(AMActionData[] values, float curTime)
        {
            if(values[0].startTime > curTime)
                return 0;

            int max = values.Length;
            for(int i = 0; i < max; i++) {
                if(values[i].startTime <= curTime && curTime <= values[i].endTime) {
                    return i;
                }
            }
            return max-1;
        }
Exemple #3
0
 /// <summary>
 /// Only call this during build, the inserted value will be appended to the current insertValueTrack and will
 /// be processed after track is complete.
 /// </summary>
 public void Insert(AMActionData valueSet)
 {
     if(mInsertActionTrack == null)
         mInsertActionTrack = new List<AMActionData>();
     mInsertActionTrack.Add(valueSet);
 }