commit 142c72369b52fe7423fca70ec107c6e2149df527
Author: Leszek Koltunski <leszek@koltunski.pl>
Date:   Sun Apr 7 19:22:17 2019 +0100

    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)

diff --git a/src/main/java/org/distorted/library/main/EffectQueue.java b/src/main/java/org/distorted/library/main/EffectQueue.java
index ee65ec0..768ebd9 100644
--- a/src/main/java/org/distorted/library/main/EffectQueue.java
+++ b/src/main/java/org/distorted/library/main/EffectQueue.java
@@ -315,9 +315,6 @@ abstract class EffectQueue implements DistortedMaster.Slave
     {
     if( mMax[mIndex]>mNumEffectsToBe || !mCreated )
       {
-      //android.util.Log.e("queue", "scheduling future add of "+effect.getName().name()+" to "+mNumEffectsToBe+" id="+effect.getID());
-      //android.util.Log.e("queue", "queue id="+mDistortedEffectsID);
-
       mJobs.add(new Job(ATTACH,0,false,effect));
       DistortedMaster.newSlave(this);
       mNumEffectsToBe++;
diff --git a/src/main/java/org/distorted/library/main/EffectQueueFragment.java b/src/main/java/org/distorted/library/main/EffectQueueFragment.java
index 9cacb25..47273c0 100644
--- a/src/main/java/org/distorted/library/main/EffectQueueFragment.java
+++ b/src/main/java/org/distorted/library/main/EffectQueueFragment.java
@@ -69,13 +69,6 @@ class EffectQueueFragment extends EffectQueue
         {
         for(int j=0; j<mNumListeners; j++)
           EffectMessageSender.newMessage( mListeners.get(j), EffectMessage.EFFECT_FINISHED, mEffects[i].getID(), mDistortedEffectsID);
-
-        if( mEffects[i].isUnity( mUniforms, NUM_UNIFORMS*i) )
-          {
-          remove(i--);
-          mNumEffectsToBe--;
-          continue;
-          }
         }
 
       mUniforms[NUM_UNIFORMS*i+5] -= halfX;
diff --git a/src/main/java/org/distorted/library/main/EffectQueueMatrix.java b/src/main/java/org/distorted/library/main/EffectQueueMatrix.java
index b772b43..e85f67d 100644
--- a/src/main/java/org/distorted/library/main/EffectQueueMatrix.java
+++ b/src/main/java/org/distorted/library/main/EffectQueueMatrix.java
@@ -130,12 +130,6 @@ class EffectQueueMatrix extends EffectQueue
         {
         for(int j=0; j<mNumListeners; j++)
           EffectMessageSender.newMessage( mListeners.get(j), EffectMessage.EFFECT_FINISHED, mEffects[i].getID(), mDistortedEffectsID);
-
-        if( mEffects[i].isUnity( mUniforms, NUM_UNIFORMS*i) )
-          {
-          remove(i--);
-          mNumEffectsToBe--;
-          }
         }
       }
      
diff --git a/src/main/java/org/distorted/library/main/EffectQueuePostprocess.java b/src/main/java/org/distorted/library/main/EffectQueuePostprocess.java
index c88c009..6affcd2 100644
--- a/src/main/java/org/distorted/library/main/EffectQueuePostprocess.java
+++ b/src/main/java/org/distorted/library/main/EffectQueuePostprocess.java
@@ -80,14 +80,6 @@ class EffectQueuePostprocess extends EffectQueue
         {
         for(int j=0; j<mNumListeners; j++)
           EffectMessageSender.newMessage( mListeners.get(j), EffectMessage.EFFECT_FINISHED, mEffects[i].getID(), mDistortedEffectsID);
-
-        if( mEffects[i].isUnity( mUniforms, NUM_UNIFORMS*i) )
-          {
-          remove(i--);
-          mNumEffectsToBe--;
-          regenerateIDandSort();
-          continue;
-          }
         }
 
       halo = (int)mUniforms[NUM_UNIFORMS*i];
diff --git a/src/main/java/org/distorted/library/main/EffectQueueVertex.java b/src/main/java/org/distorted/library/main/EffectQueueVertex.java
index ad99c13..61058ef 100644
--- a/src/main/java/org/distorted/library/main/EffectQueueVertex.java
+++ b/src/main/java/org/distorted/library/main/EffectQueueVertex.java
@@ -71,13 +71,6 @@ class EffectQueueVertex extends EffectQueue
         {
         for(int j=0; j<mNumListeners; j++)
           EffectMessageSender.newMessage( mListeners.get(j), EffectMessage.EFFECT_FINISHED, mEffects[i].getID(), mDistortedEffectsID);
-
-        if( mEffects[i].isUnity( mUniforms, NUM_UNIFORMS*i) )
-          {
-          remove(i--);
-          mNumEffectsToBe--;
-          continue;
-          }
         }
 
       mUniforms[NUM_UNIFORMS*i+5] -= halfX;
diff --git a/src/main/java/org/distorted/library/message/EffectMessage.java b/src/main/java/org/distorted/library/message/EffectMessage.java
index 76523b4..5ccf38d 100644
--- a/src/main/java/org/distorted/library/message/EffectMessage.java
+++ b/src/main/java/org/distorted/library/message/EffectMessage.java
@@ -30,12 +30,8 @@ import org.distorted.library.main.DistortedEffects;
 public enum EffectMessage 
   {
 /**
- * The effect has been removed. This can happen if:
- * <ul>
- * <li> someone explicitly removed the effect with a call to {@link DistortedEffects#abortById(long)}
- *      (or one of the other 'abort' methods)
- * <li> the interpolation of the effect has finished and the end result is equal to the effect's unity.
- * </ul>    
+ * The effect has been removed. This can happen if someone explicitly removed the effect with a call to
+ * {@link DistortedEffects#abortById(long)} (or one of the other 'abort' methods)
  */
   EFFECT_REMOVED,
   
@@ -43,7 +39,7 @@ public enum EffectMessage
  * Interpolation of the effect has finished. 
  * <p>
  * If you set up an interpolated effect and set its Dynamic to do 3.5 interpolations of 1000 ms each
- * with calls to {@link org.distorted.library.type.Dynamic#setCount(float)} and {@link org.distorted.library.type.Dynamic#setDuration(long)},
+ * with calls to {@link org.distorted.library.type.Dynamic#setCount(float)} and {@link org.distorted.library.type.Dynamic#makeRunNowFor(long)},
  * then you are going to get this message exactly once after 3.5*1000 = 3500 milliseconds when the interpolation 
  * finishes. You will never get this message if you set the effect to go on indefinitely with a call to 
  * {@link org.distorted.library.type.Dynamic#setCount(float)} where float=0.0f.
diff --git a/src/main/java/org/distorted/library/type/Dynamic.java b/src/main/java/org/distorted/library/type/Dynamic.java
index 8d059a3..9139f7f 100644
--- a/src/main/java/org/distorted/library/type/Dynamic.java
+++ b/src/main/java/org/distorted/library/type/Dynamic.java
@@ -154,6 +154,8 @@ public abstract class Dynamic
   private static Random mRnd = new Random();
   private static final int NUM_NOISE = 5; // used iff mNoise>0.0. Number of intermediary points between each pair of adjacent vectors
                                           // where we randomize noise factors to make the way between the two vectors not so smooth.
+  private long mTimeLastInterpolated;
+  private long mTimeWhenSetDuration;
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
 // hide this from Javadoc
@@ -179,6 +181,9 @@ public abstract class Dynamic
     mLastPos   = -1;
     mAccessMode= ACCESS_RANDOM;
 
+    mTimeLastInterpolated = 0;
+    mTimeWhenSetDuration  = 0;
+
     baseV      = new float[mDimension][mDimension];
     buf        = new float[mDimension];
     old        = new float[mDimension];
@@ -484,17 +489,6 @@ public abstract class Dynamic
         for(int k=0;k<mDimension; k++) baseV[i][k] *= tmp;                //
         }                                                                 /// End Normalize
       }
-
-    //printBase("end");
-    //checkBase();
-    }
-
-///////////////////////////////////////////////////////////////////////////////////////////////////
-// internal debugging only!
-
-  public String print()
-    {
-    return "duration="+mDuration+" count="+mCount+" Noise[0]="+mNoise[0]+" numVectors="+numPoints+" mMode="+mMode;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -552,12 +546,13 @@ public abstract class Dynamic
 /**
  * Sets the time it takes to do one full interpolation.
  * 
- * @param duration Time, in milliseconds, it takes to do one full interpolation, i.e. go from the first 
- *                 Point to the last and back. 
+ * @param durationInMilliseconds time it takes to do one full interpolation, i.e. go from the first
+ *                               Point to the last and back.
  */
-  public void setDuration(long duration)
+  public void makeRunNowFor(long durationInMilliseconds)
     {
-    mDuration = duration;
+    mDuration = durationInMilliseconds;
+    mTimeWhenSetDuration = mTimeLastInterpolated;
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////////
@@ -592,13 +587,15 @@ public abstract class Dynamic
  */
   public void get(float[] buffer, int offset, long time)
     {
+    mTimeLastInterpolated = time;
+
     if( mDuration<=0.0f )
       {
       interpolate(buffer,offset,mCount-(int)mCount);
       }
     else
       {
-      double pos = (double)time/mDuration;
+      double pos = (double)(time-mTimeWhenSetDuration)/mDuration;
 
       if( pos<=mCount || mCount<=0.0f )
         {
@@ -624,6 +621,9 @@ public abstract class Dynamic
  */
   public boolean get(float[] buffer, int offset, long time, long step)
     {
+    mTimeLastInterpolated = time;
+    time -= mTimeWhenSetDuration;
+
     if( mDuration<=0.0f )
       {
       interpolate(buffer,offset,mCount-(int)mCount);
