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 void Fit(Bounds2 bounds, double scale) { min = new Coord( (int)Math.Floor(bounds.min.x / scale), (int)Math.Floor(bounds.min.y / scale) ); max = new Coord( (int)Math.Floor(bounds.max.x / scale), (int)Math.Floor(bounds.max.y / scale) ); }
public override void Update() { if (transform.altered || radius != lastRadius) { scaleRadius = radius * Math.Max(transform.localScale.x, transform.localScale.y); mass = Math.PI * scaleRadius * scaleRadius; bounds = new Bounds2(transform.localPosition, Vec2.one * scaleRadius * 2); lastRadius = radius; } base.Update(); }
public Bounds2 ToBounds2() { return(Bounds2.MinMax(min.ToVec2(), max.ToVec2() + Vec2.one)); }
public Mesh2() { vertices = new Vec2[0]; bounds = new Bounds2(); }