コード例 #1
0
ファイル: Mesh2.cs プロジェクト: zon/cell
        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);
        }
コード例 #2
0
ファイル: Area.cs プロジェクト: zon/cell
 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)
         );
 }
コード例 #3
0
        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();
        }
コード例 #4
0
ファイル: Area.cs プロジェクト: zon/cell
 public Bounds2 ToBounds2()
 {
     return(Bounds2.MinMax(min.ToVec2(), max.ToVec2() + Vec2.one));
 }
コード例 #5
0
ファイル: Mesh2.cs プロジェクト: zon/cell
 public Mesh2()
 {
     vertices = new Vec2[0];
     bounds   = new Bounds2();
 }