Project

General

Profile

« Previous | Next » 

Revision d403b466

Added by Leszek Koltunski almost 3 years ago

Dynamics: consolidation of code.

View differences:

src/main/java/org/distorted/library/type/Dynamic.java
69 69
   * Have the speed be always, globally the same across all segments. Time to cover one segment will
70 70
   * thus generally no longer be the same.
71 71
   */
72
  public static final int SPEED_MODE_GLOBALLY_CONSTANT = 2;
72
  public static final int SPEED_MODE_GLOBALLY_CONSTANT = 2;  // TODO: not supported yet
73 73

  
74 74
  /**
75 75
   * One revolution takes us from the first point to the last and back to first through the shortest path.
......
109 109
  protected double mLastPos;
110 110
  protected int mAccessType;
111 111
  protected int mSpeedMode;
112
  protected float mTmpTime;
113
  protected int mTmpVec, mTmpSeg;
112 114

  
113 115
  protected class VectorNoise
114 116
    {
......
234 236
    mPausedTime = System.currentTimeMillis();
235 237
    }
236 238

  
239
///////////////////////////////////////////////////////////////////////////////////////////////////
240

  
241
  protected void computeSegmentAndTime(float time)
242
    {
243
    switch(mMode)
244
      {
245
      case MODE_LOOP: mTmpTime= time*numPoints;
246
                      mTmpSeg = (int)mTmpTime;
247
                      mTmpVec = mTmpSeg;
248
                      break;
249
      case MODE_PATH: mTmpSeg = (int)(2*time*(numPoints-1));
250

  
251
                      if( time<=0.5f )  // this has to be <= (otherwise when effect ends at t=0.5, then time=1.0
252
                        {               // and end position is slightly not equal to the end point => might not get autodeleted!
253
                        mTmpTime = 2*time*(numPoints-1);
254
                        mTmpVec = mTmpSeg;
255
                        }
256
                      else
257
                        {
258
                        mTmpTime = 2*(1-time)*(numPoints-1);
259
                        mTmpVec  = 2*numPoints-3-mTmpSeg;
260
                        }
261
                      break;
262
      case MODE_JUMP: mTmpTime= time*(numPoints-1);
263
                      mTmpSeg = (int)mTmpTime;
264
                      mTmpVec = mTmpSeg;
265
                      break;
266
      default       : mTmpVec = 0;
267
                      mTmpSeg = 0;
268
      }
269
    }
270

  
237 271
///////////////////////////////////////////////////////////////////////////////////////////////////
238 272

  
239 273
  private float valueAtPoint(float t, VectorCache cache)

Also available in: Unified diff