static void EnsureListSize <T>(ref List <T> attribute, int expectedVertexCount, AttributeValidationStrategy strategy = AttributeValidationStrategy.Nullify, T fill = default) { if (attribute == null || attribute.Count == expectedVertexCount) { return; } if (strategy == AttributeValidationStrategy.Nullify) { attribute = null; return; } var prev = attribute.Count; var copy = new List <T>(expectedVertexCount); for (int i = 0, c = Mathf.Min(prev, expectedVertexCount); i < c; i++) { copy.Add(attribute[i]); } for (int i = copy.Count - 1; i < expectedVertexCount; i++) { copy.Add(fill); } attribute = copy; }
static void EnsureArraySize <T>(ref T[] attribute, int expectedVertexCount, AttributeValidationStrategy strategy = AttributeValidationStrategy.Nullify, T fill = default) { if (attribute == null || attribute.Length == expectedVertexCount) { return; } if (strategy == AttributeValidationStrategy.Nullify) { attribute = null; return; } int previous = attribute.Length; Array.Resize(ref attribute, expectedVertexCount); for (int i = previous - 1; i < expectedVertexCount; i++) { attribute[i] = fill; } }