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;
        }
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_ - 05-06-2021, 12:56 PM

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

Forum Jump: