Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
IndexOutOfRangeException in CurvySplineSegment.LocalFToDistance function
#14
Hi
You are absolutely right about the comparison fix. I have been fixing some of those through time in different places, but I need some day to go through all float comparisons in the code base and fix them once and for all.
One thing about Mathf.Approximately to be aware of, is that Mathf.Approximately(0, someVerySmallNonZeroValue) will return false. There are cases where I would like it to return true. For thoses cases, I use the following:
Code:
        public static bool Approximately(this float x, float y)
        {
            bool result;
            const float zeroComparaisonMargin = 0.000001f;

            float nearlyZero = Mathf.Epsilon * 8f;

            float absX = Math.Abs(x);
            float absY = Math.Abs(y);

            if (absY < nearlyZero)
                result = absX < zeroComparaisonMargin;
            else if (absX < nearlyZero)
                result = absY < zeroComparaisonMargin;
            else
                result = Mathf.Approximately(x, y);
            return result;
        }
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Messages In This Thread
RE: IndexOutOfRangeException in CurvySplineSegment.LocalFToDistance function - by _Aka_ - 05-06-2021, 12:56 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Disabling a CurvySplineSegment results in NullRefException Lupos 1 6 10-02-2023, 09:55 AM
Last Post: _Aka_
  Custom CurvySplineSegment prefabs Lupos 1 10 10-02-2023, 09:36 AM
Last Post: _Aka_
  Does Curvy has gameobjects pooling system function? Chanon 7 13 09-07-2023, 12:43 PM
Last Post: _Aka_
  IndexOutOfRangeException in CurvySplineSegment.LocalFToDistance billowe 2 753 09-06-2022, 06:09 AM
Last Post: sambutle

Forum Jump: