Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IndexOutOfRangeException in CurvySplineSegment.LocalFToDistance function
#11
(03-15-2021, 02:58 AM)mchangxe Wrote: Maybe theres some secret connection in between splines im not aware of?

That would highly surprise me, but only the investigation will say for sure. Will hopefully start working on this by the end of the week.
By the way, is "Use Threading" active in your scene's splines? If so, can you test with that option disabled?
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#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
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Adding function to set GameObjecs in InputGameObject.cs Mos Def 2 99 04-01-2021, 03:43 PM
Last Post: Mos Def
  Merge function for two CurvySplines HatraE 4 369 01-29-2021, 12:51 PM
Last Post: HatraE
  IndexOutOfRangeException In InterpolateFast UsernameHed 7 3,616 09-06-2019, 09:44 PM
Last Post: _Aka_
  Some Questions about useful function I need UsernameHed 5 3,420 05-06-2019, 02:22 PM
Last Post: _Aka_

Forum Jump: