Revision 3fa519ee
Added by Leszek Koltunski 7 months ago
| src/main/java/org/distorted/library/type/Dynamic.kt | ||
|---|---|---|
| 731 | 731 |
* |
| 732 | 732 |
* @param buffer Float buffer we will write the results to. |
| 733 | 733 |
* @param offset Offset in the buffer where to write the result. |
| 734 |
* @param tm Time of interpolation. Time=0.0 is the beginning of the first revolution, time=1.0 - the end
|
|
| 734 |
* @param time Time of interpolation. Time=0.0 is the beginning of the first revolution, time=1.0 - the end
|
|
| 735 | 735 |
* of the first revolution, time=2.5 - the middle of the third revolution. |
| 736 | 736 |
* What constitutes 'one revolution' depends on the MODE: |
| 737 | 737 |
* [Dynamic.MODE_LOOP], [Dynamic.MODE_PATH] or [Dynamic.MODE_JUMP]. |
| 738 |
* @param st Time difference between now and the last time we called this function. Needed to figure |
|
| 738 |
* @param step Time difference between now and the last time we called this function. Needed to figure
|
|
| 739 | 739 |
* out if the previous time we were called the effect wasn't finished yet, but now it is. |
| 740 | 740 |
* @return true if the interpolation reached its end. |
| 741 | 741 |
*/ |
| 742 |
fun get(buffer: FloatArray, offset: Int, tm: Long, st: Long): Boolean
|
|
| 742 |
fun get(buffer: FloatArray, offset: Int, time: Long, step: Long): Boolean
|
|
| 743 | 743 |
{
|
| 744 |
var time = tm
|
|
| 745 |
var step = st
|
|
| 744 |
var tm = time
|
|
| 745 |
var st = step
|
|
| 746 | 746 |
val pos: Double |
| 747 | 747 |
|
| 748 | 748 |
if (duration <= 0.0f) |
| ... | ... | |
| 753 | 753 |
|
| 754 | 754 |
if (mStartTime == -1L) |
| 755 | 755 |
{
|
| 756 |
mStartTime = time
|
|
| 756 |
mStartTime = tm
|
|
| 757 | 757 |
mLastPos = -1.0 |
| 758 | 758 |
} |
| 759 | 759 |
|
| 760 |
val diff = time-mPausedTime
|
|
| 760 |
val diff = tm-mPausedTime
|
|
| 761 | 761 |
|
| 762 |
if (mStartTime<mPausedTime && mCorrectedTime<mPausedTime && diff>=0 && diff<=step)
|
|
| 762 |
if (mStartTime<mPausedTime && mCorrectedTime<mPausedTime && diff>=0 && diff<=st) |
|
| 763 | 763 |
{
|
| 764 | 764 |
mCorrectedTime = mPausedTime |
| 765 | 765 |
mStartTime += diff |
| 766 |
step -= diff
|
|
| 766 |
st -= diff |
|
| 767 | 767 |
} |
| 768 | 768 |
|
| 769 |
time -= mStartTime
|
|
| 769 |
tm -= mStartTime
|
|
| 770 | 770 |
|
| 771 |
if (time+step > duration*count && count>0.0f)
|
|
| 771 |
if (tm+st > duration*count && count>0.0f)
|
|
| 772 | 772 |
{
|
| 773 | 773 |
interpolate(buffer, offset, count-count.toInt()) |
| 774 | 774 |
return true |
| ... | ... | |
| 776 | 776 |
|
| 777 | 777 |
if (mAccessType == ACCESS_TYPE_SEQUENTIAL) |
| 778 | 778 |
{
|
| 779 |
pos = if (mLastPos < 0) time.toDouble()/duration else step.toDouble()/duration + mLastPos
|
|
| 779 |
pos = if (mLastPos < 0) tm.toDouble()/duration else st.toDouble()/duration + mLastPos
|
|
| 780 | 780 |
mLastPos = pos |
| 781 | 781 |
} |
| 782 | 782 |
else |
| 783 | 783 |
{
|
| 784 |
pos = time.toDouble() / duration
|
|
| 784 |
pos = tm.toDouble() / duration
|
|
| 785 | 785 |
} |
| 786 | 786 |
|
| 787 | 787 |
interpolate(buffer, offset, (pos-pos.toInt()).toFloat()) |
Also available in: Unified diff
minor