コード例 #1
0
        public void BuildPoints()
        {
            if (Shape == ColliderType.Polygon)
            {
                int VertLength = Vertices.Length;

                if (RotationChanged)
                {
                    for (int i = 0; i < VertLength; i++)
                    {
                        RotatedPoints[i] = Vertices[i];
                        RotatedPoints[i].Rotate(_rotation.x, _rotation.y);
                    }
                    for (int i = VertLength - 1; i >= 0; i--)
                    {
                        int      nextIndex = i + 1 < VertLength ? i + 1 : 0;
                        Vector2d point     = RotatedPoints[nextIndex];
                        point.Subtract(ref RotatedPoints[i]);
                        point.Normalize();
                        Edges[i] = point;
                        point.RotateRight();
                        EdgeNorms[i] = point;
                    }
                    if (!OutMoreThanSet)
                    {
                        OutMoreThanSet = true;
                        long dot = Edges[0].Cross(Edges[1]);
                        this.OutMoreThan = dot < 0;
                    }
                }

                for (int i = 0; i < VertLength; i++)
                {
                    RealPoints[i].x = RotatedPoints[i].x + _position.x;
                    RealPoints[i].y = RotatedPoints[i].y + _position.y;
                }
            }
        }