Project

General

Profile

« Previous | Next » 

Revision 65d5505f

Added by Leszek Koltunski over 7 years ago

2 bugfixes:

- in Dynamics, it has to be t<=0.5 (rather than t<0.5) (see comment in code)
- in EffectQueueVertex, we need to postprocess() the last time, when effect is finished but not removed!

View differences:

src/main/java/org/distorted/library/type/Dynamic3D.java
490 490
                                break;
491 491
                case MODE_PATH: segment = (int)(2*t*(numPoints-1));
492 492

  
493
                                if( t<0.5f )
494
                                  {
493
                                if( t<=0.5f )  // this has to be <= (otherwise when effect ends at t=0.5, then time=1.0
494
                                  {            // and end position is slightly not equal to the end point => might not get autodeleted!
495 495
                                  time = 2*t*(numPoints-1);
496 496
                                  vecCurr = segment;
497 497
                                  }
......
520 520
                    {
521 521
                    case MODE_LOOP: vecNext = vecCurr==numPoints-1 ? 0:vecCurr+1;
522 522
                                    break;
523
                    case MODE_PATH: if( t<0.5f ) vecNext = vecCurr==numPoints-1 ? numPoints-2: vecCurr+1;
524
                                    else         vecNext = vecCurr==0 ? 1 : vecCurr-1;
523
                    case MODE_PATH: if( t<=0.5f ) vecNext = vecCurr==numPoints-1 ? numPoints-2: vecCurr+1;
524
                                    else          vecNext = vecCurr==0 ? 1 : vecCurr-1;
525 525
                                    break;
526 526
                    case MODE_JUMP: vecNext = vecCurr==numPoints-1 ? 1:vecCurr+1;
527 527
                                    break;
......
541 541
                time = time-vecCurr;
542 542
            
543 543
                tmp1 = vc.elementAt(vecCurr);
544
               
544

  
545 545
                if( vn!=null )
546 546
                  {
547 547
                  time = noise(time,vecCurr);
......
551 551
                  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]);
552 552
                  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]);
553 553
                  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]);
554
/*
555
                  float d0 = buffer[offset+0] - a0;
556
                  float d1 = buffer[offset+1] - a1;
557
                  float d2 = buffer[offset+2] - a2;
558

  
559
                  float distSQ = d0*d0+d1*d1+d2*d2;
560

  
561
                  if( distSQ>500.0f )
562
                    {
563
                    android.util.Log.e("dyn3D", "distSQ="+distSQ);
564
                    android.util.Log.e("dyn3D", "factors old0="+f0+" new0="+mFactor[0]+" old1="+f1+" new1="+mFactor[1]);
565
                    android.util.Log.e("dyn3D", "first  base: old ("+b00+","+b01+","+b02+") new ("+baseV[0][0]+","+baseV[0][1]+","+baseV[0][2]+")");
566
                    android.util.Log.e("dyn3D", "second base: old ("+b10+","+b11+","+b12+") new ("+baseV[1][0]+","+baseV[1][1]+","+baseV[1][2]+")");
567
                    android.util.Log.e("dyn3D", "third  base: old ("+b20+","+b21+","+b22+") new ("+baseV[2][0]+","+baseV[2][1]+","+baseV[2][2]+")");
568

  
569
                    String s1= "velocity: old (";
570
                    String s2= "acceleration: old (";
571

  
572
                    for(int i=0; i<mDimension; i++)
573
                      {
574
                      s1 += (((3*tmp1.a[i]*oldTime+2*tmp1.b[i])*oldTime+tmp1.c[i])+(i==mDimension-1 ? ") new (":","));
575
                      s2 += ( (6*tmp1.a[i]*oldTime+2*tmp1.b[i])                   +(i==mDimension-1 ? ") new (":","));
576
                      }
577

  
578
                    for(int i=0; i<mDimension; i++)
579
                      {
580
                      s1 += (((3*tmp1.a[i]*time+2*tmp1.b[i])*time+tmp1.c[i])+(i==mDimension-1 ? ")":","));
581
                      s2 += ( (6*tmp1.a[i]*time+2*tmp1.b[i])                +(i==mDimension-1 ? ")":","));
582
                      }
583

  
584
                    android.util.Log.e("dyn3D", s1);
585
                    android.util.Log.e("dyn3D", s2);
586

  
587
                    computeOrthonormalBaseMoreDebug(oldTime,tmp1);
588
                    computeOrthonormalBaseMoreDebug(   time,tmp1);
589
                    }
590

  
591
                  a0 = buffer[offset+0];
592
                  a1 = buffer[offset+1];
593
                  a2 = buffer[offset+2];
594

  
595
                  f0 = mFactor[0];
596
                  f1 = mFactor[1];
597

  
598
                  b00 = baseV[0][0];
599
                  b01 = baseV[0][1];
600
                  b02 = baseV[0][2];
601

  
602
                  b10 = baseV[1][0];
603
                  b11 = baseV[1][1];
604
                  b12 = baseV[1][2];
605

  
606
                  b20 = baseV[2][0];
607
                  b21 = baseV[2][1];
608
                  b22 = baseV[2][2];
609

  
610
                  oldTime = time;
611
*/
612 554
                  }
613 555
                else
614 556
                  {

Also available in: Unified diff