public void Update() { _surfaceAxes.Clear(); var min = Vec2.positiveInfinity; var max = Vec2.negativeInfinity; for (var a = 0; a < vertices.Length; a++) { var b = (a + 1) % vertices.Length; var vert = vertices[a]; var axis = (vert - vertices[b]).CounterPerpendicular().Normalized(); if (axis.x < 0) { axis *= -1; } _surfaceAxes.Add(axis); min = min.Min(vert); max = max.Max(vert); } bounds = Bounds2.MinMax(min, max); }
public Bounds2 ToBounds2() { return(Bounds2.MinMax(min.ToVec2(), max.ToVec2() + Vec2.one)); }