Revision 142c7236
Added by Leszek Koltunski over 5 years ago
src/main/java/org/distorted/library/main/EffectQueue.java | ||
---|---|---|
315 | 315 |
{ |
316 | 316 |
if( mMax[mIndex]>mNumEffectsToBe || !mCreated ) |
317 | 317 |
{ |
318 |
//android.util.Log.e("queue", "scheduling future add of "+effect.getName().name()+" to "+mNumEffectsToBe+" id="+effect.getID()); |
|
319 |
//android.util.Log.e("queue", "queue id="+mDistortedEffectsID); |
|
320 |
|
|
321 | 318 |
mJobs.add(new Job(ATTACH,0,false,effect)); |
322 | 319 |
DistortedMaster.newSlave(this); |
323 | 320 |
mNumEffectsToBe++; |
src/main/java/org/distorted/library/main/EffectQueueFragment.java | ||
---|---|---|
69 | 69 |
{ |
70 | 70 |
for(int j=0; j<mNumListeners; j++) |
71 | 71 |
EffectMessageSender.newMessage( mListeners.get(j), EffectMessage.EFFECT_FINISHED, mEffects[i].getID(), mDistortedEffectsID); |
72 |
|
|
73 |
if( mEffects[i].isUnity( mUniforms, NUM_UNIFORMS*i) ) |
|
74 |
{ |
|
75 |
remove(i--); |
|
76 |
mNumEffectsToBe--; |
|
77 |
continue; |
|
78 |
} |
|
79 | 72 |
} |
80 | 73 |
|
81 | 74 |
mUniforms[NUM_UNIFORMS*i+5] -= halfX; |
src/main/java/org/distorted/library/main/EffectQueueMatrix.java | ||
---|---|---|
130 | 130 |
{ |
131 | 131 |
for(int j=0; j<mNumListeners; j++) |
132 | 132 |
EffectMessageSender.newMessage( mListeners.get(j), EffectMessage.EFFECT_FINISHED, mEffects[i].getID(), mDistortedEffectsID); |
133 |
|
|
134 |
if( mEffects[i].isUnity( mUniforms, NUM_UNIFORMS*i) ) |
|
135 |
{ |
|
136 |
remove(i--); |
|
137 |
mNumEffectsToBe--; |
|
138 |
} |
|
139 | 133 |
} |
140 | 134 |
} |
141 | 135 |
|
src/main/java/org/distorted/library/main/EffectQueuePostprocess.java | ||
---|---|---|
80 | 80 |
{ |
81 | 81 |
for(int j=0; j<mNumListeners; j++) |
82 | 82 |
EffectMessageSender.newMessage( mListeners.get(j), EffectMessage.EFFECT_FINISHED, mEffects[i].getID(), mDistortedEffectsID); |
83 |
|
|
84 |
if( mEffects[i].isUnity( mUniforms, NUM_UNIFORMS*i) ) |
|
85 |
{ |
|
86 |
remove(i--); |
|
87 |
mNumEffectsToBe--; |
|
88 |
regenerateIDandSort(); |
|
89 |
continue; |
|
90 |
} |
|
91 | 83 |
} |
92 | 84 |
|
93 | 85 |
halo = (int)mUniforms[NUM_UNIFORMS*i]; |
src/main/java/org/distorted/library/main/EffectQueueVertex.java | ||
---|---|---|
71 | 71 |
{ |
72 | 72 |
for(int j=0; j<mNumListeners; j++) |
73 | 73 |
EffectMessageSender.newMessage( mListeners.get(j), EffectMessage.EFFECT_FINISHED, mEffects[i].getID(), mDistortedEffectsID); |
74 |
|
|
75 |
if( mEffects[i].isUnity( mUniforms, NUM_UNIFORMS*i) ) |
|
76 |
{ |
|
77 |
remove(i--); |
|
78 |
mNumEffectsToBe--; |
|
79 |
continue; |
|
80 |
} |
|
81 | 74 |
} |
82 | 75 |
|
83 | 76 |
mUniforms[NUM_UNIFORMS*i+5] -= halfX; |
src/main/java/org/distorted/library/message/EffectMessage.java | ||
---|---|---|
30 | 30 |
public enum EffectMessage |
31 | 31 |
{ |
32 | 32 |
/** |
33 |
* The effect has been removed. This can happen if: |
|
34 |
* <ul> |
|
35 |
* <li> someone explicitly removed the effect with a call to {@link DistortedEffects#abortById(long)} |
|
36 |
* (or one of the other 'abort' methods) |
|
37 |
* <li> the interpolation of the effect has finished and the end result is equal to the effect's unity. |
|
38 |
* </ul> |
|
33 |
* The effect has been removed. This can happen if someone explicitly removed the effect with a call to |
|
34 |
* {@link DistortedEffects#abortById(long)} (or one of the other 'abort' methods) |
|
39 | 35 |
*/ |
40 | 36 |
EFFECT_REMOVED, |
41 | 37 |
|
... | ... | |
43 | 39 |
* Interpolation of the effect has finished. |
44 | 40 |
* <p> |
45 | 41 |
* If you set up an interpolated effect and set its Dynamic to do 3.5 interpolations of 1000 ms each |
46 |
* with calls to {@link org.distorted.library.type.Dynamic#setCount(float)} and {@link org.distorted.library.type.Dynamic#setDuration(long)},
|
|
42 |
* with calls to {@link org.distorted.library.type.Dynamic#setCount(float)} and {@link org.distorted.library.type.Dynamic#makeRunNowFor(long)},
|
|
47 | 43 |
* then you are going to get this message exactly once after 3.5*1000 = 3500 milliseconds when the interpolation |
48 | 44 |
* finishes. You will never get this message if you set the effect to go on indefinitely with a call to |
49 | 45 |
* {@link org.distorted.library.type.Dynamic#setCount(float)} where float=0.0f. |
src/main/java/org/distorted/library/type/Dynamic.java | ||
---|---|---|
154 | 154 |
private static Random mRnd = new Random(); |
155 | 155 |
private static final int NUM_NOISE = 5; // used iff mNoise>0.0. Number of intermediary points between each pair of adjacent vectors |
156 | 156 |
// where we randomize noise factors to make the way between the two vectors not so smooth. |
157 |
private long mTimeLastInterpolated; |
|
158 |
private long mTimeWhenSetDuration; |
|
157 | 159 |
|
158 | 160 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
159 | 161 |
// hide this from Javadoc |
... | ... | |
179 | 181 |
mLastPos = -1; |
180 | 182 |
mAccessMode= ACCESS_RANDOM; |
181 | 183 |
|
184 |
mTimeLastInterpolated = 0; |
|
185 |
mTimeWhenSetDuration = 0; |
|
186 |
|
|
182 | 187 |
baseV = new float[mDimension][mDimension]; |
183 | 188 |
buf = new float[mDimension]; |
184 | 189 |
old = new float[mDimension]; |
... | ... | |
484 | 489 |
for(int k=0;k<mDimension; k++) baseV[i][k] *= tmp; // |
485 | 490 |
} /// End Normalize |
486 | 491 |
} |
487 |
|
|
488 |
//printBase("end"); |
|
489 |
//checkBase(); |
|
490 |
} |
|
491 |
|
|
492 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
493 |
// internal debugging only! |
|
494 |
|
|
495 |
public String print() |
|
496 |
{ |
|
497 |
return "duration="+mDuration+" count="+mCount+" Noise[0]="+mNoise[0]+" numVectors="+numPoints+" mMode="+mMode; |
|
498 | 492 |
} |
499 | 493 |
|
500 | 494 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
552 | 546 |
/** |
553 | 547 |
* Sets the time it takes to do one full interpolation. |
554 | 548 |
* |
555 |
* @param duration Time, in milliseconds, it takes to do one full interpolation, i.e. go from the first
|
|
556 |
* Point to the last and back.
|
|
549 |
* @param durationInMilliseconds time it takes to do one full interpolation, i.e. go from the first
|
|
550 |
* Point to the last and back.
|
|
557 | 551 |
*/ |
558 |
public void setDuration(long duration)
|
|
552 |
public void makeRunNowFor(long durationInMilliseconds)
|
|
559 | 553 |
{ |
560 |
mDuration = duration; |
|
554 |
mDuration = durationInMilliseconds; |
|
555 |
mTimeWhenSetDuration = mTimeLastInterpolated; |
|
561 | 556 |
} |
562 | 557 |
|
563 | 558 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
... | ... | |
592 | 587 |
*/ |
593 | 588 |
public void get(float[] buffer, int offset, long time) |
594 | 589 |
{ |
590 |
mTimeLastInterpolated = time; |
|
591 |
|
|
595 | 592 |
if( mDuration<=0.0f ) |
596 | 593 |
{ |
597 | 594 |
interpolate(buffer,offset,mCount-(int)mCount); |
598 | 595 |
} |
599 | 596 |
else |
600 | 597 |
{ |
601 |
double pos = (double)time/mDuration;
|
|
598 |
double pos = (double)(time-mTimeWhenSetDuration)/mDuration;
|
|
602 | 599 |
|
603 | 600 |
if( pos<=mCount || mCount<=0.0f ) |
604 | 601 |
{ |
... | ... | |
624 | 621 |
*/ |
625 | 622 |
public boolean get(float[] buffer, int offset, long time, long step) |
626 | 623 |
{ |
624 |
mTimeLastInterpolated = time; |
|
625 |
time -= mTimeWhenSetDuration; |
|
626 |
|
|
627 | 627 |
if( mDuration<=0.0f ) |
628 | 628 |
{ |
629 | 629 |
interpolate(buffer,offset,mCount-(int)mCount); |
Also available in: Unified diff
Many things.
1) make the Dynamic.setDuration() able to be called AFTER the Dynamic has already been run. (and rename it to 'makeRunNowFor()' )
2) remove the automatic removal of zero Effects from EffectQueues.
3) adjust several Apps to cope with 2)
4) add post-rotation to Rubik (still not finished)