LargestAbsoluteComponentIndex: rename largest to largestAbs to be more obvious

This commit is contained in:
vis2k 2021-08-07 21:27:38 +08:00
parent 2aa791a726
commit 572ce6c751

View File

@ -13,13 +13,13 @@ public static class Compression
// helper function to find largest absolute element
// returns the index of the largest one
public static int LargestAbsoluteComponentIndex(Vector4 value, out float largest, out Vector3 withoutLargest)
public static int LargestAbsoluteComponentIndex(Vector4 value, out float largestAbs, out Vector3 withoutLargest)
{
// convert to abs
Vector4 abs = new Vector4(Mathf.Abs(value.x), Mathf.Abs(value.y), Mathf.Abs(value.z), Mathf.Abs(value.w));
// set largest to first abs (x)
largest = abs.x;
largestAbs = abs.x;
withoutLargest = new Vector3(value.y, value.z, value.w);
int index = 0;
@ -27,22 +27,22 @@ public static int LargestAbsoluteComponentIndex(Vector4 value, out float largest
// performance for 100k calls
// for-loop: 25ms
// manual checks: 22ms
if (abs.y > largest)
if (abs.y > largestAbs)
{
index = 1;
largest = abs.y;
largestAbs = abs.y;
withoutLargest = new Vector3(value.x, value.z, value.w);
}
if (abs.z > largest)
if (abs.z > largestAbs)
{
index = 2;
largest = abs.z;
largestAbs = abs.z;
withoutLargest = new Vector3(value.x, value.y, value.w);
}
if (abs.w > largest)
if (abs.w > largestAbs)
{
index = 3;
largest = abs.w;
largestAbs = abs.w;
withoutLargest = new Vector3(value.x, value.y, value.z);
}