Project

General

Profile

« Previous | Next » 

Revision 12ecac18

Added by Leszek Koltunski over 5 years ago

Add the 'convexity' param to Dynamics and the Dynamic app.

View differences:

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

  
151 151
  protected Vector<VectorCache> vc;
152 152
  protected VectorCache tmp1, tmp2;
153
  protected float mConvexity;
153 154

  
154 155
  private float[] buf;
155 156
  private float[] old;
......
181 182
    mDimension = dimension;
182 183
    mSegment   = -1;
183 184
    mLastPos   = -1;
184
    mAccessType = ACCESS_TYPE_RANDOM;
185
    mAccessType= ACCESS_TYPE_RANDOM;
186
    mConvexity = 1.0f;
185 187

  
186
    mTimeOffset = 0;
187
    mSetOffset  = true;
188
    mTimeOffset= 0;
189
    mSetOffset = true;
188 190

  
189 191
    baseV      = new float[mDimension][mDimension];
190 192
    buf        = new float[mDimension];
......
588 590
    return mDuration;
589 591
    }
590 592

  
593

  
594
///////////////////////////////////////////////////////////////////////////////////////////////////
595
/**
596
 * @param convexity If set to the default (1.0f) then interpolation between 4 points
597
 *                  (1,0) (0,1) (-1,0) (0,-1) will be the natural circle centered at (0,0) with radius 1.
598
 *                  The less it is, the less convex the circle becomes, ultimately when convexity=0.0f
599
 *                  then the interpolation shape will be straight lines connecting the four points.
600
 *                  Further setting this to negative values will make the shape concave.
601
 *                  Valid values: all floats. (although probably only something around (0,2) actually
602
 *                  makes sense)
603
 */
604
  public void setConvexity(float convexity)
605
    {
606
    if( mConvexity!=convexity )
607
      {
608
      mConvexity = convexity;
609
      cacheDirty = true;
610
      }
611
    }
612

  
613
///////////////////////////////////////////////////////////////////////////////////////////////////
614
/**
615
 * @return See {@link Dynamic#setConvexity(float)}
616
 */
617
  public float getConvexity()
618
    {
619
    return mConvexity;
620
    }
621

  
591 622
///////////////////////////////////////////////////////////////////////////////////////////////////
592 623
/**
593 624
 * Sets the access type this Dynamic will be working in.
src/main/java/org/distorted/library/type/Dynamic1D.java
57 57
      
58 58
      if( q>1 )
59 59
        {
60
        tmp1.tangent[0] = nx+px/q;
60
        tmp1.tangent[0] = mConvexity*(nx+px/q);
61 61
        }
62 62
      else
63 63
        {
64
        tmp1.tangent[0] = px+nx*q;
64
        tmp1.tangent[0] = mConvexity*(px+nx*q);
65 65
        }
66 66
      }
67 67
    else
src/main/java/org/distorted/library/type/Dynamic2D.java
59 59
      
60 60
      if( q>1 )
61 61
        {
62
        tmp1.tangent[0] = nx+px/q;
63
        tmp1.tangent[1] = ny+py/q;
62
        tmp1.tangent[0] = mConvexity*(nx+px/q);
63
        tmp1.tangent[1] = mConvexity*(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
        tmp1.tangent[0] = mConvexity*(px+nx*q);
68
        tmp1.tangent[1] = mConvexity*(py+ny*q);
69 69
        }
70 70
      }
71 71
    else
src/main/java/org/distorted/library/type/Dynamic3D.java
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
        tmp1.tangent[0] = mConvexity*(nx+px/q);
65
        tmp1.tangent[1] = mConvexity*(ny+py/q);
66
        tmp1.tangent[2] = mConvexity*(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
        tmp1.tangent[0] = mConvexity*(px+nx*q);
71
        tmp1.tangent[1] = mConvexity*(py+ny*q);
72
        tmp1.tangent[2] = mConvexity*(pz+nz*q);
73 73
        }
74 74
      }
75 75
    else
src/main/java/org/distorted/library/type/Dynamic4D.java
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
        tmp1.tangent[0] = mConvexity*(nx+px/q);
67
        tmp1.tangent[1] = mConvexity*(ny+py/q);
68
        tmp1.tangent[2] = mConvexity*(nz+pz/q);
69
        tmp1.tangent[3] = mConvexity*(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
        tmp1.tangent[0] = mConvexity*(px+nx*q);
74
        tmp1.tangent[1] = mConvexity*(py+ny*q);
75
        tmp1.tangent[2] = mConvexity*(pz+nz*q);
76
        tmp1.tangent[3] = mConvexity*(pw+nw*q);
77 77
        }
78 78
      }
79 79
    else
src/main/java/org/distorted/library/type/Dynamic5D.java
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
        tmp1.tangent[0] = mConvexity*(nx+px/q);
69
        tmp1.tangent[1] = mConvexity*(ny+py/q);
70
        tmp1.tangent[2] = mConvexity*(nz+pz/q);
71
        tmp1.tangent[3] = mConvexity*(nw+pw/q);
72
        tmp1.tangent[4] = mConvexity*(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
        tmp1.tangent[0] = mConvexity*(px+nx*q);
77
        tmp1.tangent[1] = mConvexity*(py+ny*q);
78
        tmp1.tangent[2] = mConvexity*(pz+nz*q);
79
        tmp1.tangent[3] = mConvexity*(pw+nw*q);
80
        tmp1.tangent[4] = mConvexity*(pv+nv*q);
81 81
        }
82 82
      }
83 83
    else

Also available in: Unified diff