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/Dynamic5D.java
510 510
                }
511 511
                
512 512
              break;
513
      default:float t = time;
514
              int vecCurr, segment;
513
      default:computeSegmentAndTime(time);
515 514

  
516
              switch(mMode)
517
                {
518
                case MODE_LOOP: time = time*numPoints;
519
                                segment = (int)time;
520
                                vecCurr = segment;
521
                                break;
522
                case MODE_PATH: segment = (int)(2*t*(numPoints-1));
523

  
524
                                if( t<=0.5f )  // this has to be <= (otherwise when effect ends at t=0.5, then time=1.0
525
                                  {            // and end position is slightly not equal to the end point => might not get autodeleted!
526
                                  time = 2*t*(numPoints-1);
527
                                  vecCurr = segment;
528
                                  }
529
                                else
530
                                  {
531
                                  time = 2*(1-t)*(numPoints-1);
532
                                  vecCurr = 2*numPoints-3-segment;
533
                                  }
534
                                break;
535
                case MODE_JUMP: time = time*(numPoints-1);
536
                                segment = (int)time;
537
                                vecCurr = segment;
538
                                break;
539
                default       : vecCurr = 0;
540
                                segment = 0;
541
                }
542

  
543
              if( vecCurr>=0 && vecCurr<numPoints )
515
              if( mTmpVec>=0 && mTmpVec<numPoints )
544 516
                {
545 517
                if( cacheDirty ) recomputeCache();  // recompute cache if we have added or remove vectors since last computation
546
                else if( mSegment!= segment )       // ...or if we have just passed a vector and the vector we are currently flying to has changed
518
                else if( mSegment!= mTmpSeg )       // ...or if we have just passed a vector and the vector we are currently flying to has changed
547 519
                  {
548
                  int vecNext= getNext(vecCurr,t);
520
                  int vecNext = getNext(mTmpVec,time);
549 521
                  next = vv.elementAt(vecNext);
550 522
                  tmpCache2 = vc.elementAt(vecNext);
551 523

  
552 524
                  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();
553 525
                  }
554 526

  
555
                if( mSegment!= segment && vn!=null ) vn.elementAt(vecCurr).computeNoise();
527
                if( mSegment!= mTmpSeg && vn!=null ) vn.elementAt(mTmpVec).computeNoise();
556 528

  
557
                mSegment = segment;
558
                time = time-vecCurr;
559
                tmpCache1 = vc.elementAt(vecCurr);
529
                mSegment = mTmpSeg;
530
                time = mTmpTime-mTmpVec;
531
                tmpCache1 = vc.elementAt(mTmpVec);
560 532
                if( mSpeedMode==SPEED_MODE_SEGMENT_CONSTANT ) time = smoothSpeed(time, tmpCache1);
561 533

  
562 534
                if( vn!=null )
563 535
                  {
564
                  time = noise(time,vecCurr);
536
                  time = noise(time,mTmpVec);
565 537
              
566 538
                  computeOrthonormalBaseMore(time, tmpCache1);
567 539

  

Also available in: Unified diff