08-26-2019, 04:11 PM
(This post was last modified: 08-26-2019, 04:12 PM by UsernameHed.)
Hello, I have sometime a little IndexOutOfRangeException when i am initalizing things, I have an error at the return of this function:
I have done this extra test to make it work:
My 2 questions ares: In what condition that peace of code can return an idx || idx2 invalid, and secondly, is my patch with return Vector3.zero is safe or not ?
Thanks
Code:
public Vector3 InterpolateFast(float localF)
{
float frag;
int idx = getApproximationIndexINTERNAL(localF, out frag);
int idx2 = Mathf.Min(Approximation.Length - 1, idx + 1);
return (Vector3.LerpUnclamped(Approximation[idx], Approximation[idx2], frag));
}
I have done this extra test to make it work:
Code:
if (idx < 0 || idx >= Approximation.Length || idx2 < 0 || idx2 >= Approximation.Length)
{
return (Vector3.zero);
}
My 2 questions ares: In what condition that peace of code can return an idx || idx2 invalid, and secondly, is my patch with return Vector3.zero is safe or not ?
Thanks