diff --git a/Plugins/BezierSolution/BezierSpline.cs b/Plugins/BezierSolution/BezierSpline.cs index f4b3ee5..be7f6b4 100644 --- a/Plugins/BezierSolution/BezierSpline.cs +++ b/Plugins/BezierSolution/BezierSpline.cs @@ -621,12 +621,7 @@ public Vector3 GetPoint( float normalizedT ) return endPoints[endPoints.Count - 1].position; } else - { - while( normalizedT < 0f ) - normalizedT += 1f; - while( normalizedT >= 1f ) - normalizedT -= 1f; - } + normalizedT = ( ( normalizedT % 1f ) + 1f ) % 1f; float t = normalizedT * ( m_loop ? endPoints.Count : ( endPoints.Count - 1 ) ); @@ -663,12 +658,7 @@ public Vector3 GetTangent( float normalizedT ) } } else - { - while( normalizedT < 0f ) - normalizedT += 1f; - while( normalizedT >= 1f ) - normalizedT -= 1f; - } + normalizedT = ( ( normalizedT % 1f ) + 1f ) % 1f; float t = normalizedT * ( m_loop ? endPoints.Count : ( endPoints.Count - 1 ) ); @@ -701,12 +691,7 @@ public Vector3 GetNormal( float normalizedT ) return endPoints[endPoints.Count - 1].normal; } else - { - while( normalizedT < 0f ) - normalizedT += 1f; - while( normalizedT >= 1f ) - normalizedT -= 1f; - } + normalizedT = ( ( normalizedT % 1f ) + 1f ) % 1f; float t = normalizedT * ( m_loop ? endPoints.Count : ( endPoints.Count - 1 ) ); @@ -757,12 +742,7 @@ public BezierPoint.ExtraData GetExtraData( float normalizedT, ExtraDataLerpFunct return endPoints[endPoints.Count - 1].extraData; } else - { - while( normalizedT < 0f ) - normalizedT += 1f; - while( normalizedT >= 1f ) - normalizedT -= 1f; - } + normalizedT = ( ( normalizedT % 1f ) + 1f ) % 1f; float t = normalizedT * ( m_loop ? endPoints.Count : ( endPoints.Count - 1 ) ); @@ -816,12 +796,7 @@ public Segment GetSegmentAt( float normalizedT ) return new Segment( endPoints[endPoints.Count - 2], endPoints[endPoints.Count - 1], 1f ); } else - { - while( normalizedT < 0f ) - normalizedT += 1f; - while( normalizedT >= 1f ) - normalizedT -= 1f; - } + normalizedT = ( ( normalizedT % 1f ) + 1f ) % 1f; float t = normalizedT * ( m_loop ? endPoints.Count : ( endPoints.Count - 1 ) ); diff --git a/Plugins/BezierSolution/Other/BezierDataStructures.cs b/Plugins/BezierSolution/Other/BezierDataStructures.cs index d7f4392..6f47027 100644 --- a/Plugins/BezierSolution/Other/BezierDataStructures.cs +++ b/Plugins/BezierSolution/Other/BezierDataStructures.cs @@ -146,12 +146,7 @@ public float GetNormalizedTAtPercentage( float percentage ) return 1f; } else - { - while( percentage < 0f ) - percentage += 1f; - while( percentage >= 1f ) - percentage -= 1f; - } + percentage = ( ( percentage % 1f ) + 1f ) % 1f; float indexRaw = ( uniformNormalizedTs.Length - 1 ) * percentage; int index = (int) indexRaw; @@ -168,12 +163,7 @@ public float GetPercentageAtNormalizedT( float normalizedT ) return 1f; } else - { - while( normalizedT < 0f ) - normalizedT += 1f; - while( normalizedT >= 1f ) - normalizedT -= 1f; - } + normalizedT = ( ( normalizedT % 1f ) + 1f ) % 1f; // Perform binary search int lowerBound = 0; @@ -227,12 +217,7 @@ public BezierPoint.ExtraData GetExtraData( float percentage, ExtraDataLerpFuncti return extraDatas[extraDatas.Length - 1]; } else - { - while( percentage < 0f ) - percentage += 1f; - while( percentage >= 1f ) - percentage -= 1f; - } + percentage = ( ( percentage % 1f ) + 1f ) % 1f; float t = percentage * ( loop ? extraDatas.Length : ( extraDatas.Length - 1 ) ); @@ -255,12 +240,7 @@ private Vector3 LerpArray( Vector3[] array, float percentage ) return array[array.Length - 1]; } else - { - while( percentage < 0f ) - percentage += 1f; - while( percentage >= 1f ) - percentage -= 1f; - } + percentage = ( ( percentage % 1f ) + 1f ) % 1f; float t = percentage * ( loop ? array.Length : ( array.Length - 1 ) ); diff --git a/Plugins/BezierSolution/README.txt b/Plugins/BezierSolution/README.txt index 09260a5..69c3745 100644 --- a/Plugins/BezierSolution/README.txt +++ b/Plugins/BezierSolution/README.txt @@ -1,4 +1,4 @@ -= Bezier Solution = += Bezier Solution (v2.3.3) = Online documentation & example code available at: https://github.com/yasirkula/UnityBezierSolution E-mail: yasirkula@gmail.com diff --git a/package.json b/package.json index 446bf4b..8827f51 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.yasirkula.beziersolution", "displayName": "Bezier Solution", - "version": "2.3.2", + "version": "2.3.3", "documentationUrl": "https://github.com/yasirkula/UnityBezierSolution", "changelogUrl": "https://github.com/yasirkula/UnityBezierSolution/releases", "licensesUrl": "https://github.com/yasirkula/UnityBezierSolution/blob/master/LICENSE.txt",