Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IndexOutOfRangeException in CurvySplineSegment.LocalFToDistance function
#12
Hi
Sorry for taking this long.
Please replace the implementation of getApproximationIndexINTERNAL with this:

Code:
public int getApproximationIndexINTERNAL(float localF, out float frag)
        {
            {
                float testFrag;
                float testIndex;
                float clampedLocalF = Mathf.Clamp01(localF);
                if (clampedLocalF == 1)
                {
                    testFrag = 1;
                    testIndex = Mathf.Max(0, Approximation.Length - 2);
                }
                else
                {
                    float testf = clampedLocalF * (Approximation.Length - 1);
                    testIndex = (int)testf;
                    testFrag = testf - testIndex;

                    if (testIndex > Approximation.Length - 2)
                        Debug.LogError($"input: {localF:R} clamped: {clampedLocalF:R} f: {testf:R} frag:{testFrag:R} index: {testIndex:R}");
                }
            }

            float f = localF / mStepSize;
            int idx = Math.Max(0, Math.Min((int)f, Approximation.Length - 2));
            frag = Mathf.Max(0, Mathf.Min(f - idx, 1));
            return idx;
        }
If my guess of what caused the bug is right, this code should do 2 things:
  • Avoid the exception. Please let me know if you still have exceptions
  • log an error message when the conditions previously leading to the exception happen. Please send me the error logs when they appear.
Thanks for your patience
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply


Messages In This Thread
RE: IndexOutOfRangeException in CurvySplineSegment.LocalFToDistance function - by _Aka_ - 03-22-2021, 07:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Errors in Built Application in CurvySplineSegment TdayMFG 7 3,342 04-13-2025, 09:24 AM
Last Post: _Aka_
  Disabling a CurvySplineSegment results in NullRefException Lupos 1 1,427 10-02-2023, 09:55 AM
Last Post: _Aka_
  Custom CurvySplineSegment prefabs Lupos 1 1,512 10-02-2023, 09:36 AM
Last Post: _Aka_
  Does Curvy has gameobjects pooling system function? Chanon 7 3,893 09-07-2023, 12:43 PM
Last Post: _Aka_

Forum Jump: