Skip to content

ArgumentOutOfRangeException fix #27

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions Plugins/BezierSolution/BezierSpline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -618,11 +618,9 @@ public Vector3 GetPoint( float normalizedT )
}
else
{
// 2nd conditions isn't 'else if' because in rare occasions, floating point precision issues may arise; e.g. for normalizedT = -0.0000000149,
// incrementing the value by 1 results in perfect 1.0000000000 with no mantissa
if( normalizedT < 0f )
while( normalizedT < 0f )
normalizedT += 1f;
if( normalizedT >= 1f )
while( normalizedT >= 1f )
normalizedT -= 1f;
}

Expand Down Expand Up @@ -662,9 +660,9 @@ public Vector3 GetTangent( float normalizedT )
}
else
{
if( normalizedT < 0f )
while( normalizedT < 0f )
normalizedT += 1f;
if( normalizedT >= 1f )
while( normalizedT >= 1f )
normalizedT -= 1f;
}

Expand Down Expand Up @@ -700,9 +698,9 @@ public Vector3 GetNormal( float normalizedT )
}
else
{
if( normalizedT < 0f )
while( normalizedT < 0f )
normalizedT += 1f;
if( normalizedT >= 1f )
while( normalizedT >= 1f )
normalizedT -= 1f;
}

Expand Down Expand Up @@ -756,9 +754,9 @@ public BezierPoint.ExtraData GetExtraData( float normalizedT, ExtraDataLerpFunct
}
else
{
if( normalizedT < 0f )
while( normalizedT < 0f )
normalizedT += 1f;
if( normalizedT >= 1f )
while( normalizedT >= 1f )
normalizedT -= 1f;
}

Expand Down Expand Up @@ -815,9 +813,9 @@ public Segment GetSegmentAt( float normalizedT )
}
else
{
if( normalizedT < 0f )
while( normalizedT < 0f )
normalizedT += 1f;
if( normalizedT >= 1f )
while( normalizedT >= 1f )
normalizedT -= 1f;
}

Expand Down Expand Up @@ -1503,4 +1501,4 @@ internal void Reset()
}
#endif
}
}
}
14 changes: 7 additions & 7 deletions Plugins/BezierSolution/Other/BezierDataStructures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ public float GetPercentageAtNormalizedT( float normalizedT )
}
else
{
if( normalizedT < 0f )
while( normalizedT < 0f )
normalizedT += 1f;
if( normalizedT >= 1f )
while( normalizedT >= 1f )
normalizedT -= 1f;
}

Expand Down Expand Up @@ -228,9 +228,9 @@ public BezierPoint.ExtraData GetExtraData( float percentage, ExtraDataLerpFuncti
}
else
{
if( percentage < 0f )
while( percentage < 0f )
percentage += 1f;
if( percentage >= 1f )
while( percentage >= 1f )
percentage -= 1f;
}

Expand All @@ -256,9 +256,9 @@ private Vector3 LerpArray( Vector3[] array, float percentage )
}
else
{
if( percentage < 0f )
while( percentage < 0f )
percentage += 1f;
if( percentage >= 1f )
while( percentage >= 1f )
percentage -= 1f;
}

Expand Down Expand Up @@ -341,4 +341,4 @@ public static ExtraData LerpUnclamped( ExtraData a, ExtraData b, float t )
public override string ToString() { return ( (Vector4) this ).ToString(); }
}
}
}
}