Project

General

Profile

« Previous | Next » 

Revision 9aabc9eb

Added by Leszek Koltunski almost 3 years ago

Dynamics: introduce two speed modes - smooth and segment_constant.
Prepare the third mode - globally_constant.

View differences:

src/main/java/org/distorted/library/type/Dynamic.java
55 55

  
56 56
public abstract class Dynamic
57 57
  {
58
  /**
59
   * Keep the speed of interpolation always changing. Time to cover one segment (distance between
60
   * two consecutive points) always the same. Smoothly interpolate the speed between two segments.
61
   */
62
  public static final int SPEED_MODE_SMOOTH            = 0;
63
  /**
64
   * Make each segment have constant speed. Time to cover each segment is still the same, thus the
65
   * speed will jump when passing through a point and then keep constant.
66
   */
67
  public static final int SPEED_MODE_SEGMENT_CONSTANT  = 1;
68
  /**
69
   * Have the speed be always, globally the same across all segments. Time to cover one segment will
70
   * thus generally no longer be the same.
71
   */
72
  public static final int SPEED_MODE_GLOBALLY_CONSTANT = 2;
73

  
58 74
  /**
59 75
   * One revolution takes us from the first point to the last and back to first through the shortest path.
60 76
   */
......
92 108
  protected float mCount;       // number of loops/paths we will do; mCount = 1.5 means we go from the first vector to the last, back to first, and to the last again. 
93 109
  protected double mLastPos;
94 110
  protected int mAccessType;
111
  protected int mSpeedMode;
95 112

  
96 113
  protected class VectorNoise
97 114
    {
......
123 140
  protected float[][] baseV;
124 141

  
125 142
  ///////////////////////////////////////////////////////////////////////////////////////////////////
126
  // the coefficients of the X(t), Y(t) and Z(t) polynomials: X(t) = ax*T^3 + bx*T^2 + cx*t + dx  etc.
127
  // (tangent) is the vector tangent to the path.
143
  // the coefficients of the X(t), Y(t) and Z(t) polynomials: X(t) = a[0]*T^3 + b[0]*T^2 + c[0]*t + d[0]  etc.
144
  // (velocity) is the velocity vector.
128 145
  // (cached) is the original vector from vv (copied here so when interpolating we can see if it is
129 146
  // still valid and if not - rebuild the Cache
130 147

  
......
134 151
    float[] b;
135 152
    float[] c;
136 153
    float[] d;
137
    float[] tangent;
154
    float[] velocity;
138 155
    float[] cached;
156
    float[] path_ratio;
139 157

  
140 158
    VectorCache()
141 159
      {
......
143 161
      b = new float[mDimension];
144 162
      c = new float[mDimension];
145 163
      d = new float[mDimension];
146
      tangent = new float[mDimension];
147
      cached = new float[mDimension];
164

  
165
      velocity   = new float[mDimension];
166
      cached     = new float[mDimension];
167
      path_ratio = new float[NUM_RATIO];
148 168
      }
149 169
    }
150 170

  
151 171
  protected Vector<VectorCache> vc;
152
  protected VectorCache tmp1, tmp2;
172
  protected VectorCache tmpCache1, tmpCache2;
153 173
  protected float mConvexity;
154 174

  
175
  private static final int NUM_RATIO = 10; // we attempt to 'smooth out' the speed in each segment -
176
                                           // remember this many 'points' inside the Cache for each segment.
177

  
178
  protected static final float[] mTmpRatio = new float[NUM_RATIO];
179

  
155 180
  private float[] buf;
156 181
  private float[] old;
157 182
  private static final Random mRnd = new Random();
......
184 209
    mSegment   = -1;
185 210
    mLastPos   = -1;
186 211
    mAccessType= ACCESS_TYPE_RANDOM;
212
    mSpeedMode = SPEED_MODE_SMOOTH;
187 213
    mConvexity = 1.0f;
188 214
    mStartTime = -1;
189 215
    mCorrectedTime = 0;
......
208 234
    mPausedTime = System.currentTimeMillis();
209 235
    }
210 236

  
237
///////////////////////////////////////////////////////////////////////////////////////////////////
238

  
239
  private float valueAtPoint(float t, VectorCache cache)
240
    {
241
    float tmp,sum = 0.0f;
242

  
243
    for(int d=0; d<mDimension; d++)
244
      {
245
      tmp = (3*cache.a[d]*t + 2*cache.b[d])*t + cache.c[d];
246
      sum += tmp*tmp;
247
      }
248

  
249
    return (float)Math.sqrt(sum);
250
    }
251

  
252
///////////////////////////////////////////////////////////////////////////////////////////////////
253

  
254
  protected float smoothSpeed(float time, VectorCache cache)
255
    {
256
    float fndex = time*NUM_RATIO;
257
    int index = (int)fndex;
258
    float prev = index==0 ? 0.0f : cache.path_ratio[index-1];
259
    float next = cache.path_ratio[index];
260

  
261
    return prev + (next-prev)*(fndex-index);
262
    }
263

  
264
///////////////////////////////////////////////////////////////////////////////////////////////////
265
// First, compute the approx length of the segment from time=0 to time=(i+1)/NUM_TIME and store this
266
// in cache.path_ratio[i]. Then the last path_ratio is the length from 0 to 1, i.e. the total length
267
// of the segment.
268
// We do this by computing the integral from 0 to 1 of sqrt( (dx/dt)^2 + (dy/dt)^2 ) (i.e. the length
269
// of the segment) using the approx 'trapezoids' integration method.
270
//
271
// Then, for every i, divide path_ratio[i] by the total length to get the percentage of total path
272
// length covered at time i. At this time, path_ratio[3] = 0.45 means 'at time 3/NUM_RATIO, we cover
273
// 0.45 = 45% of the total length of the segment.
274
//
275
// Finally, invert this function (for quicker lookups in smoothSpeed) so that after this step,
276
// path_ratio[3] = 0.45 means 'at 45% of the time, we cover 3/NUM_RATIO distance'.
277

  
278
  protected void smoothOutSegment(VectorCache cache)
279
    {
280
    float vPrev, sum = 0.0f;
281
    float vNext = valueAtPoint(0.0f,cache);
282

  
283
    for(int i=0; i<NUM_RATIO; i++)
284
      {
285
      vPrev = vNext;
286
      vNext = valueAtPoint( (float)(i+1)/NUM_RATIO,cache);
287
      sum += (vPrev+vNext);
288
      cache.path_ratio[i] = sum;
289
      }
290

  
291
    float total = cache.path_ratio[NUM_RATIO-1];
292

  
293
    for(int i=0; i<NUM_RATIO; i++) cache.path_ratio[i] /= total;
294

  
295
    int writeIndex = 0;
296
    float prev=0.0f, next, ratio= 1.0f/NUM_RATIO;
297

  
298
    for(int readIndex=0; readIndex<NUM_RATIO; readIndex++)
299
      {
300
      next = cache.path_ratio[readIndex];
301

  
302
      while( prev<ratio && ratio<=next )
303
        {
304
        float a = (next-ratio)/(next-prev);
305
        mTmpRatio[writeIndex] = (readIndex+1-a)/NUM_RATIO;
306
        writeIndex++;
307
        ratio = (writeIndex+1.0f)/NUM_RATIO;
308
        }
309

  
310
      prev = next;
311
      }
312

  
313
    System.arraycopy(mTmpRatio, 0, cache.path_ratio, 0, NUM_RATIO);
314
    }
315

  
211 316
///////////////////////////////////////////////////////////////////////////////////////////////////
212 317

  
213 318
  protected float noise(float time,int vecNum)
......
340 445

  
341 446
    if( cosA<0.0f )
342 447
      {
343
/*
344
      /// DEBUGGING ////
345
      String s = index+" (";
346
      float t;
347

  
348
      for(int j=0; j<mDimension; j++)
349
        {
350
        t = ((int)(100*baseV[index][j]))/(100.0f);
351
        s+=(" "+t);
352
        }
353
      s += ") (";
354

  
355
      for(int j=0; j<mDimension; j++)
356
        {
357
        t = ((int)(100*old[j]))/(100.0f);
358
        s+=(" "+t);
359
        }
360
      s+= ")";
361

  
362
      android.util.Log.e("dynamic", "kat: " + s);
363
      /// END DEBUGGING ///
364
*/
365 448
      for(int j=0; j<mDimension; j++)
366 449
        baseV[index][j] = -baseV[index][j];
367 450
      }
......
658 741
    mLastPos = -1;
659 742
    }
660 743

  
744
///////////////////////////////////////////////////////////////////////////////////////////////////
745
/**
746
 * @return See {@link Dynamic#setSpeedMode(int)}
747
 */
748
  public float getSpeedMode()
749
    {
750
    return mSpeedMode;
751
    }
752

  
753
///////////////////////////////////////////////////////////////////////////////////////////////////
754
/**
755
 * Sets the way we compute the interpolation speed.
756
 *
757
 * @param mode {@link Dynamic#SPEED_MODE_SMOOTH} or {@link Dynamic#SPEED_MODE_SEGMENT_CONSTANT} or
758
 *             {@link Dynamic#SPEED_MODE_GLOBALLY_CONSTANT}
759
 */
760
  public void setSpeedMode(int mode)
761
    {
762
    if( mSpeedMode!=mode )
763
      {
764
      if( mSpeedMode==SPEED_MODE_SMOOTH )
765
        {
766
        for(int i=0; i<numPoints; i++)
767
          {
768
          tmpCache1 = vc.elementAt(i);
769
          smoothOutSegment(tmpCache1);
770
          }
771
        }
772

  
773
      mSpeedMode = mode;
774
      }
775
    }
776

  
661 777
///////////////////////////////////////////////////////////////////////////////////////////////////
662 778
/**
663 779
 * Return the Dimension, ie number of floats in a single Point this Dynamic interpolates through.
src/main/java/org/distorted/library/type/Dynamic1D.java
44 44
    curr = vv.elementAt(c);
45 45
    next = vv.elementAt(n);
46 46

  
47
    tmp1 = vc.elementAt(c);
47
    tmpCache1 = vc.elementAt(c);
48 48
    
49 49
    float px = curr.x - prev.x;
50 50
    float nx = next.x - curr.x;
......
57 57
      
58 58
      if( q>1 )
59 59
        {
60
        tmp1.tangent[0] = nx+px/q;
60
        tmpCache1.velocity[0] = nx+px/q;
61 61
        }
62 62
      else
63 63
        {
64
        tmp1.tangent[0] = px+nx*q;
64
        tmpCache1.velocity[0] = px+nx*q;
65 65
        }
66 66
      }
67 67
    else
68 68
      {
69
      tmp1.tangent[0] = 0.0f;
69
      tmpCache1.velocity[0] = 0.0f;
70 70
      }
71 71
    }
72 72
      
......
76 76
    {  
77 77
    if( numPoints==1 )
78 78
      {
79
      tmp1= vc.elementAt(0);
79
      tmpCache1 = vc.elementAt(0);
80 80
      curr= vv.elementAt(0);
81 81
        
82
      tmp1.a[0] = 0.0f;
83
      tmp1.b[0] = 0.0f;
84
      tmp1.c[0] = curr.x;
85
      tmp1.d[0] = 0.0f;
82
      tmpCache1.a[0] = 0.0f;
83
      tmpCache1.b[0] = 0.0f;
84
      tmpCache1.c[0] = curr.x;
85
      tmpCache1.d[0] = 0.0f;
86 86
      }
87 87
    else if( numPoints==2 )
88 88
      {
89
      tmp1= vc.elementAt(0);
90
      tmp2= vc.elementAt(1);
89
      tmpCache1 = vc.elementAt(0);
90
      tmpCache2 = vc.elementAt(1);
91 91
      curr= vv.elementAt(0);
92 92
      next= vv.elementAt(1);
93 93
          
94
      tmp1.a[0] = 0.0f;
95
      tmp1.b[0] = 0.0f;
96
      tmp1.c[0] = next.x - curr.x;
97
      tmp1.d[0] = curr.x;
94
      tmpCache1.a[0] = 0.0f;
95
      tmpCache1.b[0] = 0.0f;
96
      tmpCache1.c[0] = next.x - curr.x;
97
      tmpCache1.d[0] = curr.x;
98 98
      
99
      tmp2.a[0] = 0.0f;
100
      tmp2.b[0] = 0.0f;
101
      tmp2.c[0] = curr.x - next.x;
102
      tmp2.d[0] = next.x;
99
      tmpCache2.a[0] = 0.0f;
100
      tmpCache2.b[0] = 0.0f;
101
      tmpCache2.c[0] = curr.x - next.x;
102
      tmpCache2.d[0] = next.x;
103 103
      }
104 104
    else
105 105
      {
......
111 111
        {
112 112
        n = i<numPoints-1 ? i+1:0;  
113 113
      
114
        tmp1= vc.elementAt(i);
115
        tmp2= vc.elementAt(n);
114
        tmpCache1 = vc.elementAt(i);
115
        tmpCache2 = vc.elementAt(n);
116 116
        curr= vv.elementAt(i);
117 117
        next= vv.elementAt(n);
118 118
    
119
        tmp1.cached[0] = curr.x;
119
        tmpCache1.cached[0] = curr.x;
120 120
        
121
        tmp1.a[0] = mConvexity*( 2*curr.x +   tmp1.tangent[0] - 2*next.x + tmp2.tangent[0]);
122
        tmp1.b[0] = mConvexity*(-3*curr.x - 2*tmp1.tangent[0] + 3*next.x - tmp2.tangent[0]);
123
        tmp1.c[0] = mConvexity*(tmp1.tangent[0]) + (1.0f-mConvexity)*(next.x-curr.x);
124
        tmp1.d[0] = curr.x;
121
        tmpCache1.a[0] = mConvexity*( 2*curr.x +   tmpCache1.velocity[0] - 2*next.x + tmpCache2.velocity[0]);
122
        tmpCache1.b[0] = mConvexity*(-3*curr.x - 2* tmpCache1.velocity[0] + 3*next.x - tmpCache2.velocity[0]);
123
        tmpCache1.c[0] = mConvexity*(tmpCache1.velocity[0]) + (1.0f-mConvexity)*(next.x-curr.x);
124
        tmpCache1.d[0] = curr.x;
125

  
126
        if( mSpeedMode==SPEED_MODE_SEGMENT_CONSTANT ) smoothOutSegment(tmpCache1);
125 127
        }
126 128
      }
127 129
   
......
442 444
                  {
443 445
                  int vecNext = getNext(vecCurr,t);
444 446
                  next = vv.elementAt(vecNext);
445
                  tmp2 = vc.elementAt(vecNext);
447
                  tmpCache2 = vc.elementAt(vecNext);
446 448
              
447
                  if( tmp2.cached[0]!=next.x ) recomputeCache();
449
                  if( tmpCache2.cached[0]!=next.x ) recomputeCache();
448 450
                  }
449 451

  
450 452
                if( mSegment!= segment && vn!=null ) vn.elementAt(vecCurr).computeNoise();
451 453

  
452 454
                mSegment = segment;
453

  
454 455
                time = time-vecCurr;
455

  
456
                tmp1 = vc.elementAt(vecCurr);
456
                tmpCache1 = vc.elementAt(vecCurr);
457
                if( mSpeedMode==SPEED_MODE_SEGMENT_CONSTANT ) time = smoothSpeed(time, tmpCache1);
457 458

  
458 459
                if( vn!=null )
459 460
                  {
460 461
                  time = noise(time,vecCurr);
461 462
                  }
462 463
            
463
                buffer[offset] = ((tmp1.a[0]*time+tmp1.b[0])*time+tmp1.c[0])*time+tmp1.d[0];
464
                buffer[offset] = ((tmpCache1.a[0]*time+ tmpCache1.b[0])*time+ tmpCache1.c[0])*time+ tmpCache1.d[0];
464 465
                break;
465 466
                }
466 467
        }
src/main/java/org/distorted/library/type/Dynamic2D.java
44 44
    curr = vv.elementAt(c);
45 45
    next = vv.elementAt(n);
46 46

  
47
    tmp1 = vc.elementAt(c);
47
    tmpCache1 = vc.elementAt(c);
48 48
    
49 49
    float px = curr.x - prev.x;
50 50
    float py = curr.y - prev.y;
......
59 59
      
60 60
      if( q>1 )
61 61
        {
62
        tmp1.tangent[0] = nx+px/q;
63
        tmp1.tangent[1] = ny+py/q;
62
        tmpCache1.velocity[0] = nx+px/q;
63
        tmpCache1.velocity[1] = ny+py/q;
64 64
        }
65 65
      else
66 66
        {
67
        tmp1.tangent[0] = px+nx*q;
68
        tmp1.tangent[1] = py+ny*q;
67
        tmpCache1.velocity[0] = px+nx*q;
68
        tmpCache1.velocity[1] = py+ny*q;
69 69
        }
70 70
      }
71 71
    else
72 72
      {
73
      tmp1.tangent[0] = 0.0f;
74
      tmp1.tangent[1] = 0.0f;
73
      tmpCache1.velocity[0] = 0.0f;
74
      tmpCache1.velocity[1] = 0.0f;
75 75
      }
76 76
    }
77 77
   
......
81 81
    {  
82 82
    if( numPoints==1 )
83 83
      {
84
      tmp1= vc.elementAt(0);
84
      tmpCache1 = vc.elementAt(0);
85 85
      curr= vv.elementAt(0);
86 86
              
87
      tmp1.a[0] = tmp1.a[1] = 0.0f;
88
      tmp1.b[0] = tmp1.b[1] = 0.0f;
89
      tmp1.c[0] = curr.x;
90
      tmp1.c[1] = curr.y;
91
      tmp1.d[0] = tmp1.d[1] = 0.0f;
87
      tmpCache1.a[0] = tmpCache1.a[1] = 0.0f;
88
      tmpCache1.b[0] = tmpCache1.b[1] = 0.0f;
89
      tmpCache1.c[0] = curr.x;
90
      tmpCache1.c[1] = curr.y;
91
      tmpCache1.d[0] = tmpCache1.d[1] = 0.0f;
92 92
      }
93 93
    else if( numPoints==2 )
94 94
      {
95
      tmp1= vc.elementAt(0);
96
      tmp2= vc.elementAt(1);
95
      tmpCache1 = vc.elementAt(0);
96
      tmpCache2 = vc.elementAt(1);
97 97
      curr= vv.elementAt(0);
98 98
      next= vv.elementAt(1);
99 99
          
100
      tmp1.a[0] = tmp1.a[1] = 0.0f;
101
      tmp1.b[0] = tmp1.b[1] = 0.0f;
102
      tmp1.c[0] = next.x - curr.x;
103
      tmp1.c[1] = next.y - curr.y;
104
      tmp1.d[0] = curr.x;
105
      tmp1.d[1] = curr.y;
100
      tmpCache1.a[0] = tmpCache1.a[1] = 0.0f;
101
      tmpCache1.b[0] = tmpCache1.b[1] = 0.0f;
102
      tmpCache1.c[0] = next.x - curr.x;
103
      tmpCache1.c[1] = next.y - curr.y;
104
      tmpCache1.d[0] = curr.x;
105
      tmpCache1.d[1] = curr.y;
106 106
      
107
      tmp2.a[0] = tmp2.a[1] = 0.0f;
108
      tmp2.b[0] = tmp2.b[1] = 0.0f;
109
      tmp2.c[0] = curr.x - next.x;
110
      tmp2.c[1] = curr.y - next.y;
111
      tmp2.d[0] = next.x;
112
      tmp2.d[1] = next.y;
107
      tmpCache2.a[0] = tmpCache2.a[1] = 0.0f;
108
      tmpCache2.b[0] = tmpCache2.b[1] = 0.0f;
109
      tmpCache2.c[0] = curr.x - next.x;
110
      tmpCache2.c[1] = curr.y - next.y;
111
      tmpCache2.d[0] = next.x;
112
      tmpCache2.d[1] = next.y;
113 113
      }
114 114
    else
115 115
      {
......
121 121
        {
122 122
        n = i<numPoints-1 ? i+1:0;  
123 123
      
124
        tmp1= vc.elementAt(i);
125
        tmp2= vc.elementAt(n);
124
        tmpCache1 = vc.elementAt(i);
125
        tmpCache2 = vc.elementAt(n);
126 126
        curr= vv.elementAt(i);
127 127
        next= vv.elementAt(n);
128 128
      
129
        tmp1.cached[0] = curr.x;
130
        tmp1.cached[1] = curr.y;
131

  
132
        tmp1.a[0] = mConvexity*( 2*curr.x +   tmp1.tangent[0] - 2*next.x + tmp2.tangent[0]);
133
        tmp1.b[0] = mConvexity*(-3*curr.x - 2*tmp1.tangent[0] + 3*next.x - tmp2.tangent[0]);
134
        tmp1.c[0] = mConvexity*(tmp1.tangent[0]) + (1.0f-mConvexity)*(next.x-curr.x);
135
        tmp1.d[0] = curr.x;
136

  
137
        tmp1.a[1] = mConvexity*( 2*curr.y +   tmp1.tangent[1] - 2*next.y + tmp2.tangent[1]);
138
        tmp1.b[1] = mConvexity*(-3*curr.y - 2*tmp1.tangent[1] + 3*next.y - tmp2.tangent[1]);
139
        tmp1.c[1] = mConvexity*(tmp1.tangent[1]) + (1.0f-mConvexity)*(next.y-curr.y);
140
        tmp1.d[1] = curr.y;
129
        tmpCache1.cached[0] = curr.x;
130
        tmpCache1.cached[1] = curr.y;
131

  
132
        tmpCache1.a[0] = mConvexity*( 2*curr.x +   tmpCache1.velocity[0] - 2*next.x + tmpCache2.velocity[0]);
133
        tmpCache1.b[0] = mConvexity*(-3*curr.x - 2* tmpCache1.velocity[0] + 3*next.x - tmpCache2.velocity[0]);
134
        tmpCache1.c[0] = mConvexity*(tmpCache1.velocity[0]) + (1.0f-mConvexity)*(next.x-curr.x);
135
        tmpCache1.d[0] = curr.x;
136

  
137
        tmpCache1.a[1] = mConvexity*( 2*curr.y +   tmpCache1.velocity[1] - 2*next.y + tmpCache2.velocity[1]);
138
        tmpCache1.b[1] = mConvexity*(-3*curr.y - 2* tmpCache1.velocity[1] + 3*next.y - tmpCache2.velocity[1]);
139
        tmpCache1.c[1] = mConvexity*(tmpCache1.velocity[1]) + (1.0f-mConvexity)*(next.y-curr.y);
140
        tmpCache1.d[1] = curr.y;
141

  
142
        if( mSpeedMode==SPEED_MODE_SEGMENT_CONSTANT ) smoothOutSegment(tmpCache1);
141 143
        }
142 144
      }
143 145
    
......
475 477
                  {
476 478
                  int vecNext = getNext(vecCurr,t);
477 479
                  next = vv.elementAt(vecNext);
478
                  tmp2 = vc.elementAt(vecNext);
480
                  tmpCache2 = vc.elementAt(vecNext);
479 481

  
480
                  if( tmp2.cached[0]!=next.x || tmp2.cached[1]!=next.y ) recomputeCache();
482
                  if( tmpCache2.cached[0]!=next.x || tmpCache2.cached[1]!=next.y ) recomputeCache();
481 483
                  }
482 484

  
483 485
                if( mSegment!= segment && vn!=null ) vn.elementAt(vecCurr).computeNoise();
484 486

  
485 487
                mSegment = segment;
486

  
487 488
                time = time-vecCurr;
488
                tmp1 = vc.elementAt(vecCurr);
489
                tmpCache1 = vc.elementAt(vecCurr);
490
                if( mSpeedMode==SPEED_MODE_SEGMENT_CONSTANT ) time = smoothSpeed(time, tmpCache1);
489 491

  
490 492
                if( vn!=null )
491 493
                  {
492 494
                  time = noise(time,vecCurr);
493 495

  
494
                  baseV[1][0] = (3*tmp1.a[0]*time+2*tmp1.b[0])*time + tmp1.c[0];
495
                  baseV[1][1] = (3*tmp1.a[1]*time+2*tmp1.b[1])*time + tmp1.c[1];
496
                  baseV[1][0] = (3* tmpCache1.a[0]*time+2* tmpCache1.b[0])*time + tmpCache1.c[0];
497
                  baseV[1][1] = (3* tmpCache1.a[1]*time+2* tmpCache1.b[1])*time + tmpCache1.c[1];
496 498
                 
497
                  buffer[offset  ]= ((tmp1.a[0]*time+tmp1.b[0])*time+tmp1.c[0])*time+tmp1.d[0] +baseV[1][1]*mFactor[0];
498
                  buffer[offset+1]= ((tmp1.a[1]*time+tmp1.b[1])*time+tmp1.c[1])*time+tmp1.d[1] -baseV[1][0]*mFactor[0];
499
                  buffer[offset  ]= ((tmpCache1.a[0]*time+ tmpCache1.b[0])*time+ tmpCache1.c[0])*time+ tmpCache1.d[0] +baseV[1][1]*mFactor[0];
500
                  buffer[offset+1]= ((tmpCache1.a[1]*time+ tmpCache1.b[1])*time+ tmpCache1.c[1])*time+ tmpCache1.d[1] -baseV[1][0]*mFactor[0];
499 501
                  } 
500 502
                else
501 503
                  {
502
                  buffer[offset  ]= ((tmp1.a[0]*time+tmp1.b[0])*time+tmp1.c[0])*time+tmp1.d[0];
503
                  buffer[offset+1]= ((tmp1.a[1]*time+tmp1.b[1])*time+tmp1.c[1])*time+tmp1.d[1];
504
                  buffer[offset  ]= ((tmpCache1.a[0]*time+ tmpCache1.b[0])*time+ tmpCache1.c[0])*time+ tmpCache1.d[0];
505
                  buffer[offset+1]= ((tmpCache1.a[1]*time+ tmpCache1.b[1])*time+ tmpCache1.c[1])*time+ tmpCache1.d[1];
504 506
                  }
505 507
                
506 508
                break;
src/main/java/org/distorted/library/type/Dynamic3D.java
44 44
    curr = vv.elementAt(c);
45 45
    next = vv.elementAt(n);
46 46

  
47
    tmp1 = vc.elementAt(c);
47
    tmpCache1 = vc.elementAt(c);
48 48
    
49 49
    float px = curr.x - prev.x;
50 50
    float py = curr.y - prev.y;
......
61 61
      
62 62
      if( q>1 )
63 63
        {
64
        tmp1.tangent[0] = nx+px/q;
65
        tmp1.tangent[1] = ny+py/q;
66
        tmp1.tangent[2] = nz+pz/q;
64
        tmpCache1.velocity[0] = nx+px/q;
65
        tmpCache1.velocity[1] = ny+py/q;
66
        tmpCache1.velocity[2] = nz+pz/q;
67 67
        }
68 68
      else
69 69
        {
70
        tmp1.tangent[0] = px+nx*q;
71
        tmp1.tangent[1] = py+ny*q;
72
        tmp1.tangent[2] = pz+nz*q;
70
        tmpCache1.velocity[0] = px+nx*q;
71
        tmpCache1.velocity[1] = py+ny*q;
72
        tmpCache1.velocity[2] = pz+nz*q;
73 73
        }
74 74
      }
75 75
    else
76 76
      {
77
      tmp1.tangent[0] = 0.0f;
78
      tmp1.tangent[1] = 0.0f;
79
      tmp1.tangent[2] = 0.0f;
77
      tmpCache1.velocity[0] = 0.0f;
78
      tmpCache1.velocity[1] = 0.0f;
79
      tmpCache1.velocity[2] = 0.0f;
80 80
      }
81 81
    }
82 82
    
......
86 86
    {  
87 87
    if( numPoints==1 )
88 88
      {
89
      tmp1= vc.elementAt(0);
89
      tmpCache1 = vc.elementAt(0);
90 90
      curr= vv.elementAt(0);
91 91
        
92
      tmp1.a[0] = tmp1.a[1] = tmp1.a[2] = 0.0f;
93
      tmp1.b[0] = tmp1.b[1] = tmp1.b[2] = 0.0f;
94
      tmp1.c[0] = curr.x;
95
      tmp1.c[1] = curr.y;
96
      tmp1.c[2] = curr.z;
97
      tmp1.d[0] = tmp1.d[1] = tmp1.d[2] = 0.0f;
92
      tmpCache1.a[0] = tmpCache1.a[1] = tmpCache1.a[2] = 0.0f;
93
      tmpCache1.b[0] = tmpCache1.b[1] = tmpCache1.b[2] = 0.0f;
94
      tmpCache1.c[0] = curr.x;
95
      tmpCache1.c[1] = curr.y;
96
      tmpCache1.c[2] = curr.z;
97
      tmpCache1.d[0] = tmpCache1.d[1] = tmpCache1.d[2] = 0.0f;
98 98
      }
99 99
    else if( numPoints==2 )
100 100
      {
101
      tmp1= vc.elementAt(0);
102
      tmp2= vc.elementAt(1);
101
      tmpCache1 = vc.elementAt(0);
102
      tmpCache2 = vc.elementAt(1);
103 103
      curr= vv.elementAt(0);
104 104
      next= vv.elementAt(1);
105 105
          
106
      tmp1.a[0] = tmp1.a[1] = tmp1.a[2] = 0.0f;
107
      tmp1.b[0] = tmp1.b[1] = tmp1.b[2] = 0.0f;
108
      tmp1.c[0] = next.x - curr.x;
109
      tmp1.c[1] = next.y - curr.y;
110
      tmp1.c[2] = next.z - curr.z;
111
      tmp1.d[0] = curr.x;
112
      tmp1.d[1] = curr.y;
113
      tmp1.d[2] = curr.z;
106
      tmpCache1.a[0] = tmpCache1.a[1] = tmpCache1.a[2] = 0.0f;
107
      tmpCache1.b[0] = tmpCache1.b[1] = tmpCache1.b[2] = 0.0f;
108
      tmpCache1.c[0] = next.x - curr.x;
109
      tmpCache1.c[1] = next.y - curr.y;
110
      tmpCache1.c[2] = next.z - curr.z;
111
      tmpCache1.d[0] = curr.x;
112
      tmpCache1.d[1] = curr.y;
113
      tmpCache1.d[2] = curr.z;
114 114
      
115
      tmp2.a[0] = tmp2.a[1] = tmp2.a[2] = 0.0f;
116
      tmp2.b[0] = tmp2.b[1] = tmp2.b[2] = 0.0f;
117
      tmp2.c[0] = curr.x - next.x;
118
      tmp2.c[1] = curr.y - next.y;
119
      tmp2.c[2] = curr.z - next.z;
120
      tmp2.d[0] = next.x;
121
      tmp2.d[1] = next.y;
122
      tmp2.d[2] = next.z;
115
      tmpCache2.a[0] = tmpCache2.a[1] = tmpCache2.a[2] = 0.0f;
116
      tmpCache2.b[0] = tmpCache2.b[1] = tmpCache2.b[2] = 0.0f;
117
      tmpCache2.c[0] = curr.x - next.x;
118
      tmpCache2.c[1] = curr.y - next.y;
119
      tmpCache2.c[2] = curr.z - next.z;
120
      tmpCache2.d[0] = next.x;
121
      tmpCache2.d[1] = next.y;
122
      tmpCache2.d[2] = next.z;
123 123
      }
124 124
    else
125 125
      {
......
131 131
        {
132 132
        n = i<numPoints-1 ? i+1:0;  
133 133
      
134
        tmp1= vc.elementAt(i);
135
        tmp2= vc.elementAt(n);
134
        tmpCache1 = vc.elementAt(i);
135
        tmpCache2 = vc.elementAt(n);
136 136
        curr= vv.elementAt(i);
137 137
        next= vv.elementAt(n);
138 138
      
139
        tmp1.cached[0] = curr.x;
140
        tmp1.cached[1] = curr.y;
141
        tmp1.cached[2] = curr.z;
139
        tmpCache1.cached[0] = curr.x;
140
        tmpCache1.cached[1] = curr.y;
141
        tmpCache1.cached[2] = curr.z;
142 142
        
143
        tmp1.a[0] = mConvexity*( 2*curr.x +   tmp1.tangent[0] - 2*next.x + tmp2.tangent[0]);
144
        tmp1.b[0] = mConvexity*(-3*curr.x - 2*tmp1.tangent[0] + 3*next.x - tmp2.tangent[0]);
145
        tmp1.c[0] = mConvexity*(tmp1.tangent[0]) + (1.0f-mConvexity)*(next.x-curr.x);
146
        tmp1.d[0] = curr.x;
143
        tmpCache1.a[0] = mConvexity*( 2*curr.x +   tmpCache1.velocity[0] - 2*next.x + tmpCache2.velocity[0]);
144
        tmpCache1.b[0] = mConvexity*(-3*curr.x - 2* tmpCache1.velocity[0] + 3*next.x - tmpCache2.velocity[0]);
145
        tmpCache1.c[0] = mConvexity*(tmpCache1.velocity[0]) + (1.0f-mConvexity)*(next.x-curr.x);
146
        tmpCache1.d[0] = curr.x;
147 147
      
148
        tmp1.a[1] = mConvexity*( 2*curr.y +   tmp1.tangent[1] - 2*next.y + tmp2.tangent[1]);
149
        tmp1.b[1] = mConvexity*(-3*curr.y - 2*tmp1.tangent[1] + 3*next.y - tmp2.tangent[1]);
150
        tmp1.c[1] = mConvexity*(tmp1.tangent[1]) + (1.0f-mConvexity)*(next.y-curr.y);
151
        tmp1.d[1] = curr.y;
148
        tmpCache1.a[1] = mConvexity*( 2*curr.y +   tmpCache1.velocity[1] - 2*next.y + tmpCache2.velocity[1]);
149
        tmpCache1.b[1] = mConvexity*(-3*curr.y - 2* tmpCache1.velocity[1] + 3*next.y - tmpCache2.velocity[1]);
150
        tmpCache1.c[1] = mConvexity*(tmpCache1.velocity[1]) + (1.0f-mConvexity)*(next.y-curr.y);
151
        tmpCache1.d[1] = curr.y;
152 152
      
153
        tmp1.a[2] = mConvexity*( 2*curr.z +   tmp1.tangent[2] - 2*next.z + tmp2.tangent[2]);
154
        tmp1.b[2] = mConvexity*(-3*curr.z - 2*tmp1.tangent[2] + 3*next.z - tmp2.tangent[2]);
155
        tmp1.c[2] = mConvexity*(tmp1.tangent[2]) + (1.0f-mConvexity)*(next.z-curr.z);
156
        tmp1.d[2] = curr.z;
153
        tmpCache1.a[2] = mConvexity*( 2*curr.z +   tmpCache1.velocity[2] - 2*next.z + tmpCache2.velocity[2]);
154
        tmpCache1.b[2] = mConvexity*(-3*curr.z - 2* tmpCache1.velocity[2] + 3*next.z - tmpCache2.velocity[2]);
155
        tmpCache1.c[2] = mConvexity*(tmpCache1.velocity[2]) + (1.0f-mConvexity)*(next.z-curr.z);
156
        tmpCache1.d[2] = curr.z;
157

  
158
        if( mSpeedMode==SPEED_MODE_SEGMENT_CONSTANT ) smoothOutSegment(tmpCache1);
157 159
        }
158 160
      }
159 161
   
......
499 501
                  {
500 502
                  int vecNext = getNext(vecCurr,t);
501 503
                  next = vv.elementAt(vecNext);
502
                  tmp2 = vc.elementAt(vecNext);
504
                  tmpCache2 = vc.elementAt(vecNext);
503 505

  
504
                  if( tmp2.cached[0]!=next.x || tmp2.cached[1]!=next.y || tmp2.cached[2]!=next.z ) recomputeCache();
506
                  if( tmpCache2.cached[0]!=next.x || tmpCache2.cached[1]!=next.y || tmpCache2.cached[2]!=next.z ) recomputeCache();
505 507
                  }
506 508

  
507 509
                if( mSegment!= segment && vn!=null ) vn.elementAt(vecCurr).computeNoise();
508 510

  
509 511
                mSegment = segment;
510

  
511 512
                time = time-vecCurr;
512
            
513
                tmp1 = vc.elementAt(vecCurr);
513
                tmpCache1 = vc.elementAt(vecCurr);
514
                if( mSpeedMode==SPEED_MODE_SEGMENT_CONSTANT ) time = smoothSpeed(time, tmpCache1);
514 515

  
515 516
                if( vn!=null )
516 517
                  {
517 518
                  time = noise(time,vecCurr);
518 519
              
519
                  computeOrthonormalBaseMore(time,tmp1);
520
                  computeOrthonormalBaseMore(time, tmpCache1);
520 521
                 
521
                  buffer[offset  ]= ((tmp1.a[0]*time+tmp1.b[0])*time+tmp1.c[0])*time+tmp1.d[0] + (baseV[1][0]*mFactor[0] + baseV[2][0]*mFactor[1]);
522
                  buffer[offset+1]= ((tmp1.a[1]*time+tmp1.b[1])*time+tmp1.c[1])*time+tmp1.d[1] + (baseV[1][1]*mFactor[0] + baseV[2][1]*mFactor[1]);
523
                  buffer[offset+2]= ((tmp1.a[2]*time+tmp1.b[2])*time+tmp1.c[2])*time+tmp1.d[2] + (baseV[1][2]*mFactor[0] + baseV[2][2]*mFactor[1]);
522
                  buffer[offset  ]= ((tmpCache1.a[0]*time+ tmpCache1.b[0])*time+ tmpCache1.c[0])*time+ tmpCache1.d[0] + (baseV[1][0]*mFactor[0] + baseV[2][0]*mFactor[1]);
523
                  buffer[offset+1]= ((tmpCache1.a[1]*time+ tmpCache1.b[1])*time+ tmpCache1.c[1])*time+ tmpCache1.d[1] + (baseV[1][1]*mFactor[0] + baseV[2][1]*mFactor[1]);
524
                  buffer[offset+2]= ((tmpCache1.a[2]*time+ tmpCache1.b[2])*time+ tmpCache1.c[2])*time+ tmpCache1.d[2] + (baseV[1][2]*mFactor[0] + baseV[2][2]*mFactor[1]);
524 525
                  }
525 526
                else
526 527
                  {
527
                  buffer[offset  ]= ((tmp1.a[0]*time+tmp1.b[0])*time+tmp1.c[0])*time+tmp1.d[0];
528
                  buffer[offset+1]= ((tmp1.a[1]*time+tmp1.b[1])*time+tmp1.c[1])*time+tmp1.d[1];
529
                  buffer[offset+2]= ((tmp1.a[2]*time+tmp1.b[2])*time+tmp1.c[2])*time+tmp1.d[2];
528
                  buffer[offset  ]= ((tmpCache1.a[0]*time+ tmpCache1.b[0])*time+ tmpCache1.c[0])*time+ tmpCache1.d[0];
529
                  buffer[offset+1]= ((tmpCache1.a[1]*time+ tmpCache1.b[1])*time+ tmpCache1.c[1])*time+ tmpCache1.d[1];
530
                  buffer[offset+2]= ((tmpCache1.a[2]*time+ tmpCache1.b[2])*time+ tmpCache1.c[2])*time+ tmpCache1.d[2];
530 531
                  }
531 532
               
532 533
                break;
src/main/java/org/distorted/library/type/Dynamic4D.java
44 44
    curr = vv.elementAt(c);
45 45
    next = vv.elementAt(n);
46 46

  
47
    tmp1 = vc.elementAt(c);
47
    tmpCache1 = vc.elementAt(c);
48 48
    
49 49
    float px = curr.x - prev.x;
50 50
    float py = curr.y - prev.y;
......
63 63
      
64 64
      if( q>1 )
65 65
        {
66
        tmp1.tangent[0] = nx+px/q;
67
        tmp1.tangent[1] = ny+py/q;
68
        tmp1.tangent[2] = nz+pz/q;
69
        tmp1.tangent[3] = nw+pw/q;
66
        tmpCache1.velocity[0] = nx+px/q;
67
        tmpCache1.velocity[1] = ny+py/q;
68
        tmpCache1.velocity[2] = nz+pz/q;
69
        tmpCache1.velocity[3] = nw+pw/q;
70 70
        }
71 71
      else
72 72
        {
73
        tmp1.tangent[0] = px+nx*q;
74
        tmp1.tangent[1] = py+ny*q;
75
        tmp1.tangent[2] = pz+nz*q;
76
        tmp1.tangent[3] = pw+nw*q;
73
        tmpCache1.velocity[0] = px+nx*q;
74
        tmpCache1.velocity[1] = py+ny*q;
75
        tmpCache1.velocity[2] = pz+nz*q;
76
        tmpCache1.velocity[3] = pw+nw*q;
77 77
        }
78 78
      }
79 79
    else
80 80
      {
81
      tmp1.tangent[0] = 0.0f;
82
      tmp1.tangent[1] = 0.0f;
83
      tmp1.tangent[2] = 0.0f;
84
      tmp1.tangent[3] = 0.0f;
81
      tmpCache1.velocity[0] = 0.0f;
82
      tmpCache1.velocity[1] = 0.0f;
83
      tmpCache1.velocity[2] = 0.0f;
84
      tmpCache1.velocity[3] = 0.0f;
85 85
      }
86 86
    }
87 87
    
......
91 91
    {  
92 92
    if( numPoints==1 )
93 93
      {
94
      tmp1= vc.elementAt(0);
94
      tmpCache1 = vc.elementAt(0);
95 95
      curr= vv.elementAt(0);
96 96
        
97
      tmp1.a[0] = tmp1.a[1] = tmp1.a[2] = tmp1.a[3] = 0.0f;
98
      tmp1.b[0] = tmp1.b[1] = tmp1.b[2] = tmp1.b[3] = 0.0f;
99
      tmp1.c[0] = curr.x;
100
      tmp1.c[1] = curr.y;
101
      tmp1.c[2] = curr.z;
102
      tmp1.c[3] = curr.w;
103
      tmp1.d[0] = tmp1.d[1] = tmp1.d[3] = tmp1.d[3] = 0.0f;
97
      tmpCache1.a[0] = tmpCache1.a[1] = tmpCache1.a[2] = tmpCache1.a[3] = 0.0f;
98
      tmpCache1.b[0] = tmpCache1.b[1] = tmpCache1.b[2] = tmpCache1.b[3] = 0.0f;
99
      tmpCache1.c[0] = curr.x;
100
      tmpCache1.c[1] = curr.y;
101
      tmpCache1.c[2] = curr.z;
102
      tmpCache1.c[3] = curr.w;
103
      tmpCache1.d[0] = tmpCache1.d[1] = tmpCache1.d[3] = tmpCache1.d[3] = 0.0f;
104 104
      }
105 105
    else if( numPoints==2 )
106 106
      {
107
      tmp1= vc.elementAt(0);
108
      tmp2= vc.elementAt(1);
107
      tmpCache1 = vc.elementAt(0);
108
      tmpCache2 = vc.elementAt(1);
109 109
      curr= vv.elementAt(0);
110 110
      next= vv.elementAt(1);
111 111
      
112
      tmp1.a[0] = tmp1.a[1] = tmp1.a[2] = tmp1.a[3] = 0.0f;
113
      tmp1.b[0] = tmp1.b[1] = tmp1.b[2] = tmp1.b[3] = 0.0f;
114
      tmp1.c[0] = next.x - curr.x;
115
      tmp1.c[1] = next.y - curr.y;
116
      tmp1.c[2] = next.z - curr.z;
117
      tmp1.c[3] = next.w - curr.w;
118
      tmp1.d[0] = curr.x;
119
      tmp1.d[1] = curr.y;
120
      tmp1.d[2] = curr.z;
121
      tmp1.d[3] = curr.w;
112
      tmpCache1.a[0] = tmpCache1.a[1] = tmpCache1.a[2] = tmpCache1.a[3] = 0.0f;
113
      tmpCache1.b[0] = tmpCache1.b[1] = tmpCache1.b[2] = tmpCache1.b[3] = 0.0f;
114
      tmpCache1.c[0] = next.x - curr.x;
115
      tmpCache1.c[1] = next.y - curr.y;
116
      tmpCache1.c[2] = next.z - curr.z;
117
      tmpCache1.c[3] = next.w - curr.w;
118
      tmpCache1.d[0] = curr.x;
119
      tmpCache1.d[1] = curr.y;
120
      tmpCache1.d[2] = curr.z;
121
      tmpCache1.d[3] = curr.w;
122 122
      
123
      tmp2.a[0] = tmp2.a[1] = tmp2.a[2] = tmp2.a[3] = 0.0f;
124
      tmp2.b[0] = tmp2.b[1] = tmp2.b[2] = tmp2.b[3] = 0.0f;
125
      tmp2.c[0] = curr.x - next.x;
126
      tmp2.c[1] = curr.y - next.y;
127
      tmp2.c[2] = curr.z - next.z;
128
      tmp2.c[3] = curr.w - next.w;
129
      tmp2.d[0] = next.x;
130
      tmp2.d[1] = next.y;
131
      tmp2.d[2] = next.z;
132
      tmp2.d[3] = next.w;
123
      tmpCache2.a[0] = tmpCache2.a[1] = tmpCache2.a[2] = tmpCache2.a[3] = 0.0f;
124
      tmpCache2.b[0] = tmpCache2.b[1] = tmpCache2.b[2] = tmpCache2.b[3] = 0.0f;
125
      tmpCache2.c[0] = curr.x - next.x;
126
      tmpCache2.c[1] = curr.y - next.y;
127
      tmpCache2.c[2] = curr.z - next.z;
128
      tmpCache2.c[3] = curr.w - next.w;
129
      tmpCache2.d[0] = next.x;
130
      tmpCache2.d[1] = next.y;
131
      tmpCache2.d[2] = next.z;
132
      tmpCache2.d[3] = next.w;
133 133
      }
134 134
    else
135 135
      {
......
141 141
        {
142 142
        n = i<numPoints-1 ? i+1:0;  
143 143
      
144
        tmp1= vc.elementAt(i);
145
        tmp2= vc.elementAt(n);
144
        tmpCache1 = vc.elementAt(i);
145
        tmpCache2 = vc.elementAt(n);
146 146
        curr= vv.elementAt(i);
147 147
        next= vv.elementAt(n);
148 148
      
149
        tmp1.cached[0] = curr.x;
150
        tmp1.cached[1] = curr.y;
151
        tmp1.cached[2] = curr.z;
152
        tmp1.cached[3] = curr.w;
149
        tmpCache1.cached[0] = curr.x;
150
        tmpCache1.cached[1] = curr.y;
151
        tmpCache1.cached[2] = curr.z;
152
        tmpCache1.cached[3] = curr.w;
153 153
        
154
        tmp1.a[0] = mConvexity*( 2*curr.x +   tmp1.tangent[0] - 2*next.x + tmp2.tangent[0]);
155
        tmp1.b[0] = mConvexity*(-3*curr.x - 2*tmp1.tangent[0] + 3*next.x - tmp2.tangent[0]);
156
        tmp1.c[0] = mConvexity*(tmp1.tangent[0]) + (1.0f-mConvexity)*(next.x-curr.x);
157
        tmp1.d[0] = curr.x;
154
        tmpCache1.a[0] = mConvexity*( 2*curr.x +   tmpCache1.velocity[0] - 2*next.x + tmpCache2.velocity[0]);
155
        tmpCache1.b[0] = mConvexity*(-3*curr.x - 2* tmpCache1.velocity[0] + 3*next.x - tmpCache2.velocity[0]);
156
        tmpCache1.c[0] = mConvexity*(tmpCache1.velocity[0]) + (1.0f-mConvexity)*(next.x-curr.x);
157
        tmpCache1.d[0] = curr.x;
158 158
      
159
        tmp1.a[1] = mConvexity*( 2*curr.y +   tmp1.tangent[1] - 2*next.y + tmp2.tangent[1]);
160
        tmp1.b[1] = mConvexity*(-3*curr.y - 2*tmp1.tangent[1] + 3*next.y - tmp2.tangent[1]);
161
        tmp1.c[1] = mConvexity*(tmp1.tangent[1]) + (1.0f-mConvexity)*(next.y-curr.y);
162
        tmp1.d[1] = curr.y;
159
        tmpCache1.a[1] = mConvexity*( 2*curr.y +   tmpCache1.velocity[1] - 2*next.y + tmpCache2.velocity[1]);
160
        tmpCache1.b[1] = mConvexity*(-3*curr.y - 2* tmpCache1.velocity[1] + 3*next.y - tmpCache2.velocity[1]);
161
        tmpCache1.c[1] = mConvexity*(tmpCache1.velocity[1]) + (1.0f-mConvexity)*(next.y-curr.y);
162
        tmpCache1.d[1] = curr.y;
163 163
      
164
        tmp1.a[2] = mConvexity*( 2*curr.z +   tmp1.tangent[2] - 2*next.z + tmp2.tangent[2]);
165
        tmp1.b[2] = mConvexity*(-3*curr.z - 2*tmp1.tangent[2] + 3*next.z - tmp2.tangent[2]);
166
        tmp1.c[2] = mConvexity*(tmp1.tangent[2]) + (1.0f-mConvexity)*(next.z-curr.z);
167
        tmp1.d[2] = curr.z;
164
        tmpCache1.a[2] = mConvexity*( 2*curr.z +   tmpCache1.velocity[2] - 2*next.z + tmpCache2.velocity[2]);
165
        tmpCache1.b[2] = mConvexity*(-3*curr.z - 2* tmpCache1.velocity[2] + 3*next.z - tmpCache2.velocity[2]);
166
        tmpCache1.c[2] = mConvexity*(tmpCache1.velocity[2]) + (1.0f-mConvexity)*(next.z-curr.z);
167
        tmpCache1.d[2] = curr.z;
168 168
        
169
        tmp1.a[3] = mConvexity*( 2*curr.w +   tmp1.tangent[3] - 2*next.w + tmp2.tangent[3]);
170
        tmp1.b[3] = mConvexity*(-3*curr.w - 2*tmp1.tangent[3] + 3*next.w - tmp2.tangent[3]);
171
        tmp1.c[3] = mConvexity*(tmp1.tangent[3]) + (1.0f-mConvexity)*(next.w-curr.w);
172
        tmp1.d[3] = curr.w;
169
        tmpCache1.a[3] = mConvexity*( 2*curr.w +   tmpCache1.velocity[3] - 2*next.w + tmpCache2.velocity[3]);
170
        tmpCache1.b[3] = mConvexity*(-3*curr.w - 2* tmpCache1.velocity[3] + 3*next.w - tmpCache2.velocity[3]);
171
        tmpCache1.c[3] = mConvexity*(tmpCache1.velocity[3]) + (1.0f-mConvexity)*(next.w-curr.w);
172
        tmpCache1.d[3] = curr.w;
173

  
174
        if( mSpeedMode==SPEED_MODE_SEGMENT_CONSTANT ) smoothOutSegment(tmpCache1);
173 175
        }
174 176
      }
175 177
   
......
522 524
                  {
523 525
                  int vecNext = getNext(vecCurr,t);
524 526
                  next = vv.elementAt(vecNext);
525
                  tmp2 = vc.elementAt(vecNext);
527
                  tmpCache2 = vc.elementAt(vecNext);
526 528

  
527
                  if( tmp2.cached[0]!=next.x || tmp2.cached[1]!=next.y || tmp2.cached[2]!=next.z || tmp2.cached[3]!=next.w ) recomputeCache();
529
                  if( tmpCache2.cached[0]!=next.x || tmpCache2.cached[1]!=next.y || tmpCache2.cached[2]!=next.z || tmpCache2.cached[3]!=next.w ) recomputeCache();
528 530
                  }
529 531

  
530 532
                if( mSegment!= segment && vn!=null ) vn.elementAt(vecCurr).computeNoise();
531 533

  
532 534
                mSegment = segment;
533

  
534 535
                time = time-vecCurr;
535
            
536
                tmp1 = vc.elementAt(vecCurr);
537
               
536
                tmpCache1 = vc.elementAt(vecCurr);
537
                if( mSpeedMode==SPEED_MODE_SEGMENT_CONSTANT ) time = smoothSpeed(time, tmpCache1);
538

  
538 539
                if( vn!=null )
539 540
                  {
540 541
                  time = noise(time,vecCurr);
541 542
              
542
                  computeOrthonormalBaseMore(time,tmp1);
543
                  computeOrthonormalBaseMore(time, tmpCache1);
543 544

  
544
                  buffer[offset  ]= ((tmp1.a[0]*time+tmp1.b[0])*time+tmp1.c[0])*time+tmp1.d[0] + (baseV[1][0]*mFactor[0] + baseV[2][0]*mFactor[1] + baseV[3][0]*mFactor[2]);
545
                  buffer[offset+1]= ((tmp1.a[1]*time+tmp1.b[1])*time+tmp1.c[1])*time+tmp1.d[1] + (baseV[1][1]*mFactor[0] + baseV[2][1]*mFactor[1] + baseV[3][1]*mFactor[2]);
546
                  buffer[offset+2]= ((tmp1.a[2]*time+tmp1.b[2])*time+tmp1.c[2])*time+tmp1.d[2] + (baseV[1][2]*mFactor[0] + baseV[2][2]*mFactor[1] + baseV[3][2]*mFactor[2]);
547
                  buffer[offset+3]= ((tmp1.a[3]*time+tmp1.b[3])*time+tmp1.c[3])*time+tmp1.d[3] + (baseV[1][3]*mFactor[0] + baseV[2][3]*mFactor[1] + baseV[3][3]*mFactor[2]);
545
                  buffer[offset  ]= ((tmpCache1.a[0]*time+ tmpCache1.b[0])*time+ tmpCache1.c[0])*time+ tmpCache1.d[0] + (baseV[1][0]*mFactor[0] + baseV[2][0]*mFactor[1] + baseV[3][0]*mFactor[2]);
546
                  buffer[offset+1]= ((tmpCache1.a[1]*time+ tmpCache1.b[1])*time+ tmpCache1.c[1])*time+ tmpCache1.d[1] + (baseV[1][1]*mFactor[0] + baseV[2][1]*mFactor[1] + baseV[3][1]*mFactor[2]);
547
                  buffer[offset+2]= ((tmpCache1.a[2]*time+ tmpCache1.b[2])*time+ tmpCache1.c[2])*time+ tmpCache1.d[2] + (baseV[1][2]*mFactor[0] + baseV[2][2]*mFactor[1] + baseV[3][2]*mFactor[2]);
548
                  buffer[offset+3]= ((tmpCache1.a[3]*time+ tmpCache1.b[3])*time+ tmpCache1.c[3])*time+ tmpCache1.d[3] + (baseV[1][3]*mFactor[0] + baseV[2][3]*mFactor[1] + baseV[3][3]*mFactor[2]);
548 549
                  }
549 550
                else
550 551
                  {
551
                  buffer[offset  ]= ((tmp1.a[0]*time+tmp1.b[0])*time+tmp1.c[0])*time+tmp1.d[0];
552
                  buffer[offset+1]= ((tmp1.a[1]*time+tmp1.b[1])*time+tmp1.c[1])*time+tmp1.d[1];
553
                  buffer[offset+2]= ((tmp1.a[2]*time+tmp1.b[2])*time+tmp1.c[2])*time+tmp1.d[2];
554
                  buffer[offset+3]= ((tmp1.a[3]*time+tmp1.b[3])*time+tmp1.c[3])*time+tmp1.d[3];
552
                  buffer[offset  ]= ((tmpCache1.a[0]*time+ tmpCache1.b[0])*time+ tmpCache1.c[0])*time+ tmpCache1.d[0];
553
                  buffer[offset+1]= ((tmpCache1.a[1]*time+ tmpCache1.b[1])*time+ tmpCache1.c[1])*time+ tmpCache1.d[1];
554
                  buffer[offset+2]= ((tmpCache1.a[2]*time+ tmpCache1.b[2])*time+ tmpCache1.c[2])*time+ tmpCache1.d[2];
555
                  buffer[offset+3]= ((tmpCache1.a[3]*time+ tmpCache1.b[3])*time+ tmpCache1.c[3])*time+ tmpCache1.d[3];
555 556
                  }
556 557

  
557 558
                break;
src/main/java/org/distorted/library/type/Dynamic5D.java
44 44
    curr = vv.elementAt(c);
45 45
    next = vv.elementAt(n);
46 46

  
47
    tmp1 = vc.elementAt(c);
47
    tmpCache1 = vc.elementAt(c);
48 48
    
49 49
    float px = curr.x - prev.x;
50 50
    float py = curr.y - prev.y;
......
65 65
      
66 66
      if( q>1 )
67 67
        {
68
        tmp1.tangent[0] = nx+px/q;
69
        tmp1.tangent[1] = ny+py/q;
70
        tmp1.tangent[2] = nz+pz/q;
71
        tmp1.tangent[3] = nw+pw/q;
72
        tmp1.tangent[4] = nv+pv/q;
68
        tmpCache1.velocity[0] = nx+px/q;
69
        tmpCache1.velocity[1] = ny+py/q;
70
        tmpCache1.velocity[2] = nz+pz/q;
71
        tmpCache1.velocity[3] = nw+pw/q;
72
        tmpCache1.velocity[4] = nv+pv/q;
73 73
        }
74 74
      else
75 75
        {
76
        tmp1.tangent[0] = px+nx*q;
77
        tmp1.tangent[1] = py+ny*q;
78
        tmp1.tangent[2] = pz+nz*q;
79
        tmp1.tangent[3] = pw+nw*q;
80
        tmp1.tangent[4] = pv+nv*q;
76
        tmpCache1.velocity[0] = px+nx*q;
77
        tmpCache1.velocity[1] = py+ny*q;
78
        tmpCache1.velocity[2] = pz+nz*q;
79
        tmpCache1.velocity[3] = pw+nw*q;
80
        tmpCache1.velocity[4] = pv+nv*q;
81 81
        }
82 82
      }
83 83
    else
84 84
      {
85
      tmp1.tangent[0] = 0.0f;
86
      tmp1.tangent[1] = 0.0f;
87
      tmp1.tangent[2] = 0.0f;
88
      tmp1.tangent[3] = 0.0f;
89
      tmp1.tangent[4] = 0.0f;
85
      tmpCache1.velocity[0] = 0.0f;
86
      tmpCache1.velocity[1] = 0.0f;
87
      tmpCache1.velocity[2] = 0.0f;
88
      tmpCache1.velocity[3] = 0.0f;
89
      tmpCache1.velocity[4] = 0.0f;
90 90
      }
91 91
    }
92 92
    
......
96 96
    {  
97 97
    if( numPoints==1 )
98 98
      {
99
      tmp1= vc.elementAt(0);
99
      tmpCache1 = vc.elementAt(0);
100 100
      curr= vv.elementAt(0);
101 101
        
102
      tmp1.a[0] = tmp1.a[1] = tmp1.a[2] = tmp1.a[3] = tmp1.a[4] = 0.0f;
103
      tmp1.b[0] = tmp1.b[1] = tmp1.b[2] = tmp1.b[3] = tmp1.b[4] = 0.0f;
104
      tmp1.c[0] = curr.x;
105
      tmp1.c[1] = curr.y;
106
      tmp1.c[2] = curr.z;
107
      tmp1.c[3] = curr.w;
108
      tmp1.c[4] = curr.v;
109
      tmp1.d[0] = tmp1.d[1] = tmp1.d[2] = tmp1.d[3] = tmp1.d[4] = 0.0f;
102
      tmpCache1.a[0] = tmpCache1.a[1] = tmpCache1.a[2] = tmpCache1.a[3] = tmpCache1.a[4] = 0.0f;
103
      tmpCache1.b[0] = tmpCache1.b[1] = tmpCache1.b[2] = tmpCache1.b[3] = tmpCache1.b[4] = 0.0f;
104
      tmpCache1.c[0] = curr.x;
105
      tmpCache1.c[1] = curr.y;
106
      tmpCache1.c[2] = curr.z;
107
      tmpCache1.c[3] = curr.w;
108
      tmpCache1.c[4] = curr.v;
109
      tmpCache1.d[0] = tmpCache1.d[1] = tmpCache1.d[2] = tmpCache1.d[3] = tmpCache1.d[4] = 0.0f;
110 110
      }
111 111
    else if( numPoints==2 )
112 112
      {
113
      tmp1= vc.elementAt(0);
114
      tmp2= vc.elementAt(1);
113
      tmpCache1 = vc.elementAt(0);
114
      tmpCache2 = vc.elementAt(1);
115 115
      curr= vv.elementAt(0);
116 116
      next= vv.elementAt(1);
117 117
      
118
      tmp1.a[0] = tmp1.a[1] = tmp1.a[2] = tmp1.a[3] = tmp1.a[4] = 0.0f;
119
      tmp1.b[0] = tmp1.b[1] = tmp1.b[2] = tmp1.b[3] = tmp1.b[4] = 0.0f;
120
      tmp1.c[0] = next.x - curr.x;
121
      tmp1.c[1] = next.y - curr.y;
122
      tmp1.c[2] = next.z - curr.z;
123
      tmp1.c[3] = next.w - curr.w;
124
      tmp1.c[4] = next.v - curr.v;
125
      tmp1.d[0] = curr.x;
126
      tmp1.d[1] = curr.y;
127
      tmp1.d[2] = curr.z;
128
      tmp1.d[3] = curr.w;
129
      tmp1.d[4] = curr.v;
118
      tmpCache1.a[0] = tmpCache1.a[1] = tmpCache1.a[2] = tmpCache1.a[3] = tmpCache1.a[4] = 0.0f;
119
      tmpCache1.b[0] = tmpCache1.b[1] = tmpCache1.b[2] = tmpCache1.b[3] = tmpCache1.b[4] = 0.0f;
120
      tmpCache1.c[0] = next.x - curr.x;
121
      tmpCache1.c[1] = next.y - curr.y;
122
      tmpCache1.c[2] = next.z - curr.z;
123
      tmpCache1.c[3] = next.w - curr.w;
124
      tmpCache1.c[4] = next.v - curr.v;
125
      tmpCache1.d[0] = curr.x;
126
      tmpCache1.d[1] = curr.y;
127
      tmpCache1.d[2] = curr.z;
128
      tmpCache1.d[3] = curr.w;
129
      tmpCache1.d[4] = curr.v;
130 130
      
131
      tmp2.a[0] = tmp2.a[1] = tmp2.a[2] = tmp2.a[3] = tmp2.a[4] = 0.0f;
132
      tmp2.b[0] = tmp2.b[1] = tmp2.b[2] = tmp2.b[3] = tmp2.b[4] = 0.0f;
133
      tmp2.c[0] = curr.x - next.x;
134
      tmp2.c[1] = curr.y - next.y;
135
      tmp2.c[2] = curr.z - next.z;
136
      tmp2.c[3] = curr.w - next.w;
137
      tmp2.c[4] = curr.v - next.v;
138
      tmp2.d[0] = next.x;
139
      tmp2.d[1] = next.y;
140
      tmp2.d[2] = next.z;
141
      tmp2.d[3] = next.w;
142
      tmp2.d[4] = next.v;
131
      tmpCache2.a[0] = tmpCache2.a[1] = tmpCache2.a[2] = tmpCache2.a[3] = tmpCache2.a[4] = 0.0f;
132
      tmpCache2.b[0] = tmpCache2.b[1] = tmpCache2.b[2] = tmpCache2.b[3] = tmpCache2.b[4] = 0.0f;
133
      tmpCache2.c[0] = curr.x - next.x;
134
      tmpCache2.c[1] = curr.y - next.y;
135
      tmpCache2.c[2] = curr.z - next.z;
136
      tmpCache2.c[3] = curr.w - next.w;
137
      tmpCache2.c[4] = curr.v - next.v;
138
      tmpCache2.d[0] = next.x;
139
      tmpCache2.d[1] = next.y;
140
      tmpCache2.d[2] = next.z;
141
      tmpCache2.d[3] = next.w;
142
      tmpCache2.d[4] = next.v;
143 143
      }
144 144
    else
145 145
      {
......
151 151
        {
152 152
        n = i<numPoints-1 ? i+1:0;  
153 153
      
154
        tmp1= vc.elementAt(i);
155
        tmp2= vc.elementAt(n);
154
        tmpCache1 = vc.elementAt(i);
155
        tmpCache2 = vc.elementAt(n);
156 156
        curr= vv.elementAt(i);
157 157
        next= vv.elementAt(n);
158 158
      
159
        tmp1.cached[0] = curr.x;
160
        tmp1.cached[1] = curr.y;
161
        tmp1.cached[2] = curr.z;
162
        tmp1.cached[3] = curr.w;
163
        tmp1.cached[4] = curr.v;
159
        tmpCache1.cached[0] = curr.x;
160
        tmpCache1.cached[1] = curr.y;
161
        tmpCache1.cached[2] = curr.z;
162
        tmpCache1.cached[3] = curr.w;
163
        tmpCache1.cached[4] = curr.v;
164 164
        
165
        tmp1.a[0] = mConvexity*( 2*curr.x +   tmp1.tangent[0] - 2*next.x + tmp2.tangent[0]);
166
        tmp1.b[0] = mConvexity*(-3*curr.x - 2*tmp1.tangent[0] + 3*next.x - tmp2.tangent[0]);
167
        tmp1.c[0] = mConvexity*(tmp1.tangent[0]) + (1.0f-mConvexity)*(next.x-curr.x);
168
        tmp1.d[0] = curr.x;
165
        tmpCache1.a[0] = mConvexity*( 2*curr.x +   tmpCache1.velocity[0] - 2*next.x + tmpCache2.velocity[0]);
166
        tmpCache1.b[0] = mConvexity*(-3*curr.x - 2* tmpCache1.velocity[0] + 3*next.x - tmpCache2.velocity[0]);
167
        tmpCache1.c[0] = mConvexity*(tmpCache1.velocity[0]) + (1.0f-mConvexity)*(next.x-curr.x);
168
        tmpCache1.d[0] = curr.x;
169 169
      
170
        tmp1.a[1] = mConvexity*( 2*curr.y +   tmp1.tangent[1] - 2*next.y + tmp2.tangent[1]);
171
        tmp1.b[1] = mConvexity*(-3*curr.y - 2*tmp1.tangent[1] + 3*next.y - tmp2.tangent[1]);
172
        tmp1.c[1] = mConvexity*(tmp1.tangent[1]) + (1.0f-mConvexity)*(next.y-curr.y);
173
        tmp1.d[1] = curr.y;
170
        tmpCache1.a[1] = mConvexity*( 2*curr.y +   tmpCache1.velocity[1] - 2*next.y + tmpCache2.velocity[1]);
171
        tmpCache1.b[1] = mConvexity*(-3*curr.y - 2* tmpCache1.velocity[1] + 3*next.y - tmpCache2.velocity[1]);
172
        tmpCache1.c[1] = mConvexity*(tmpCache1.velocity[1]) + (1.0f-mConvexity)*(next.y-curr.y);
173
        tmpCache1.d[1] = curr.y;
174 174
      
175
        tmp1.a[2] = mConvexity*( 2*curr.z +   tmp1.tangent[2] - 2*next.z + tmp2.tangent[2]);
176
        tmp1.b[2] = mConvexity*(-3*curr.z - 2*tmp1.tangent[2] + 3*next.z - tmp2.tangent[2]);
177
        tmp1.c[2] = mConvexity*(tmp1.tangent[2]) + (1.0f-mConvexity)*(next.z-curr.z);
178
        tmp1.d[2] = curr.z;
175
        tmpCache1.a[2] = mConvexity*( 2*curr.z +   tmpCache1.velocity[2] - 2*next.z + tmpCache2.velocity[2]);
176
        tmpCache1.b[2] = mConvexity*(-3*curr.z - 2* tmpCache1.velocity[2] + 3*next.z - tmpCache2.velocity[2]);
177
        tmpCache1.c[2] = mConvexity*(tmpCache1.velocity[2]) + (1.0f-mConvexity)*(next.z-curr.z);
178
        tmpCache1.d[2] = curr.z;
179 179
        
180
        tmp1.a[3] = mConvexity*( 2*curr.w +   tmp1.tangent[3] - 2*next.w + tmp2.tangent[3]);
181
        tmp1.b[3] = mConvexity*(-3*curr.w - 2*tmp1.tangent[3] + 3*next.w - tmp2.tangent[3]);
182
        tmp1.c[3] = mConvexity*(tmp1.tangent[3]) + (1.0f-mConvexity)*(next.w-curr.w);
183
        tmp1.d[3] = curr.w;
180
        tmpCache1.a[3] = mConvexity*( 2*curr.w +   tmpCache1.velocity[3] - 2*next.w + tmpCache2.velocity[3]);
181
        tmpCache1.b[3] = mConvexity*(-3*curr.w - 2* tmpCache1.velocity[3] + 3*next.w - tmpCache2.velocity[3]);
182
        tmpCache1.c[3] = mConvexity*(tmpCache1.velocity[3]) + (1.0f-mConvexity)*(next.w-curr.w);
183
        tmpCache1.d[3] = curr.w;
184 184
        
185
        tmp1.a[4] = mConvexity*( 2*curr.v +   tmp1.tangent[4] - 2*next.v + tmp2.tangent[4]);
186
        tmp1.b[4] = mConvexity*(-3*curr.v - 2*tmp1.tangent[4] + 3*next.v - tmp2.tangent[4]);
187
        tmp1.c[4] = mConvexity*(tmp1.tangent[4]) + (1.0f-mConvexity)*(next.v-curr.v);
188
        tmp1.d[4] = curr.v;
185
        tmpCache1.a[4] = mConvexity*( 2*curr.v +   tmpCache1.velocity[4] - 2*next.v + tmpCache2.velocity[4]);
186
        tmpCache1.b[4] = mConvexity*(-3*curr.v - 2* tmpCache1.velocity[4] + 3*next.v - tmpCache2.velocity[4]);
187
        tmpCache1.c[4] = mConvexity*(tmpCache1.velocity[4]) + (1.0f-mConvexity)*(next.v-curr.v);
188
        tmpCache1.d[4] = curr.v;
189

  
190
        if( mSpeedMode==SPEED_MODE_SEGMENT_CONSTANT ) smoothOutSegment(tmpCache1);
189 191
        }
190 192
      }
191 193
   
......
545 547
                  {
546 548
                  int vecNext= getNext(vecCurr,t);
547 549
                  next = vv.elementAt(vecNext);
548
                  tmp2 = vc.elementAt(vecNext);
550
                  tmpCache2 = vc.elementAt(vecNext);
549 551

  
550
                  if( tmp2.cached[0]!=next.x || tmp2.cached[1]!=next.y || tmp2.cached[2]!=next.z || tmp2.cached[3]!=next.w || tmp2.cached[4]!=next.v ) recomputeCache();
552
                  if( tmpCache2.cached[0]!=next.x || tmpCache2.cached[1]!=next.y || tmpCache2.cached[2]!=next.z || tmpCache2.cached[3]!=next.w || tmpCache2.cached[4]!=next.v ) recomputeCache();
551 553
                  }
552 554

  
553 555
                if( mSegment!= segment && vn!=null ) vn.elementAt(vecCurr).computeNoise();
554 556

  
555 557
                mSegment = segment;
556

  
557 558
                time = time-vecCurr;
558
            
559
                tmp1 = vc.elementAt(vecCurr);
560
               
559
                tmpCache1 = vc.elementAt(vecCurr);
560
                if( mSpeedMode==SPEED_MODE_SEGMENT_CONSTANT ) time = smoothSpeed(time, tmpCache1);
561

  
561 562
                if( vn!=null )
562 563
                  {
563 564
                  time = noise(time,vecCurr);
564 565
              
565
                  computeOrthonormalBaseMore(time,tmp1);
566
                  computeOrthonormalBaseMore(time, tmpCache1);
566 567

  
567
                  buffer[offset  ]= ((tmp1.a[0]*time+tmp1.b[0])*time+tmp1.c[0])*time+tmp1.d[0] + (baseV[1][0]*mFactor[0] + baseV[2][0]*mFactor[1] + baseV[3][0]*mFactor[2] + baseV[4][0]*mFactor[3]);
568
                  buffer[offset+1]= ((tmp1.a[1]*time+tmp1.b[1])*time+tmp1.c[1])*time+tmp1.d[1] + (baseV[1][1]*mFactor[0] + baseV[2][1]*mFactor[1] + baseV[3][1]*mFactor[2] + baseV[4][1]*mFactor[3]);
569
                  buffer[offset+2]= ((tmp1.a[2]*time+tmp1.b[2])*time+tmp1.c[2])*time+tmp1.d[2] + (baseV[1][2]*mFactor[0] + baseV[2][2]*mFactor[1] + baseV[3][2]*mFactor[2] + baseV[4][2]*mFactor[3]);
570
                  buffer[offset+3]= ((tmp1.a[3]*time+tmp1.b[3])*time+tmp1.c[3])*time+tmp1.d[3] + (baseV[1][3]*mFactor[0] + baseV[2][3]*mFactor[1] + baseV[3][3]*mFactor[2] + baseV[4][3]*mFactor[3]);
571
                  buffer[offset+4]= ((tmp1.a[4]*time+tmp1.b[4])*time+tmp1.c[4])*time+tmp1.d[4] + (baseV[1][4]*mFactor[0] + baseV[2][4]*mFactor[1] + baseV[3][4]*mFactor[2] + baseV[4][4]*mFactor[3]);
568
                  buffer[offset  ]= ((tmpCache1.a[0]*time+ tmpCache1.b[0])*time+ tmpCache1.c[0])*time+ tmpCache1.d[0] + (baseV[1][0]*mFactor[0] + baseV[2][0]*mFactor[1] + baseV[3][0]*mFactor[2] + baseV[4][0]*mFactor[3]);
569
                  buffer[offset+1]= ((tmpCache1.a[1]*time+ tmpCache1.b[1])*time+ tmpCache1.c[1])*time+ tmpCache1.d[1] + (baseV[1][1]*mFactor[0] + baseV[2][1]*mFactor[1] + baseV[3][1]*mFactor[2] + baseV[4][1]*mFactor[3]);
570
                  buffer[offset+2]= ((tmpCache1.a[2]*time+ tmpCache1.b[2])*time+ tmpCache1.c[2])*time+ tmpCache1.d[2] + (baseV[1][2]*mFactor[0] + baseV[2][2]*mFactor[1] + baseV[3][2]*mFactor[2] + baseV[4][2]*mFactor[3]);
571
                  buffer[offset+3]= ((tmpCache1.a[3]*time+ tmpCache1.b[3])*time+ tmpCache1.c[3])*time+ tmpCache1.d[3] + (baseV[1][3]*mFactor[0] + baseV[2][3]*mFactor[1] + baseV[3][3]*mFactor[2] + baseV[4][3]*mFactor[3]);
572
                  buffer[offset+4]= ((tmpCache1.a[4]*time+ tmpCache1.b[4])*time+ tmpCache1.c[4])*time+ tmpCache1.d[4] + (baseV[1][4]*mFactor[0] + baseV[2][4]*mFactor[1] + baseV[3][4]*mFactor[2] + baseV[4][4]*mFactor[3]);
572 573
                  }
573 574
                else
574 575
                  {
575
                  buffer[offset  ]= ((tmp1.a[0]*time+tmp1.b[0])*time+tmp1.c[0])*time+tmp1.d[0];
576
                  buffer[offset+1]= ((tmp1.a[1]*time+tmp1.b[1])*time+tmp1.c[1])*time+tmp1.d[1];
577
                  buffer[offset+2]= ((tmp1.a[2]*time+tmp1.b[2])*time+tmp1.c[2])*time+tmp1.d[2];
578
                  buffer[offset+3]= ((tmp1.a[3]*time+tmp1.b[3])*time+tmp1.c[3])*time+tmp1.d[3];
579
                  buffer[offset+4]= ((tmp1.a[4]*time+tmp1.b[4])*time+tmp1.c[4])*time+tmp1.d[4];
576
                  buffer[offset  ]= ((tmpCache1.a[0]*time+ tmpCache1.b[0])*time+ tmpCache1.c[0])*time+ tmpCache1.d[0];
577
                  buffer[offset+1]= ((tmpCache1.a[1]*time+ tmpCache1.b[1])*time+ tmpCache1.c[1])*time+ tmpCache1.d[1];
578
                  buffer[offset+2]= ((tmpCache1.a[2]*time+ tmpCache1.b[2])*time+ tmpCache1.c[2])*time+ tmpCache1.d[2];
579
                  buffer[offset+3]= ((tmpCache1.a[3]*time+ tmpCache1.b[3])*time+ tmpCache1.c[3])*time+ tmpCache1.d[3];
580
                  buffer[offset+4]= ((tmpCache1.a[4]*time+ tmpCache1.b[4])*time+ tmpCache1.c[4])*time+ tmpCache1.d[4];
580 581
                  }
581 582
 
582 583
                break;
src/main/java/org/distorted/library/type/DynamicQuat.java
50 50
    float vx,vy,vz,vw;
51 51
    }
52 52
  
53
  private Vector<VectorCacheQuat> vc;
53
  private final Vector<VectorCacheQuat> vc;
54 54
  private VectorCacheQuat tmp1, tmp2;
55 55

  
56
  private Vector<Static4D> vv;
56
  private final Vector<Static4D> vv;
57 57
  private Static4D curr, next;
58 58
 
59 59
///////////////////////////////////////////////////////////////////////////////////////////////////

Also available in: Unified diff