/**
         *  @brief Create the internal shape used to represent a PolygonCollider.
         **/
        public override SyncFrame.Physics2D.Shape[] CreateShapes()
        {
            if (_points == null || _points.Length == 0)
            {
                return(null);
            }


            TSVector2 lossy2D = new TSVector2(lossyScale.x, lossyScale.y);

            SyncFrame.Physics2D.Vertices v = new Physics2D.Vertices();
            for (int index = 0, length = _points.Length; index < length; index++)
            {
                v.Add(TSVector2.Scale(_points[index], lossy2D));
            }

            List <SyncFrame.Physics2D.Vertices> convexShapeVs = SyncFrame.Physics2D.BayazitDecomposer.ConvexPartition(v);

            SyncFrame.Physics2D.Shape[] result = new Physics2D.Shape[convexShapeVs.Count];
            for (int index = 0, length = result.Length; index < length; index++)
            {
                result[index] = new SyncFrame.Physics2D.PolygonShape(convexShapeVs[index], 1);
            }

            return(result);
        }
        /**
         *  @brief Returns the first {@link TSCollider2D} within a rectangular area. Returns null if there is none.
         *
         *  @param pointA Top-left corner of the rectangle.
         *  @param radius Bottom-right corner of the rectangle.
         *  @param layerMask Unity's layer mask to filter objects.
         **/
        public static object _OverlapArea(TSVector2 pointA, TSVector2 pointB, Physics2D.BodySpecialSensor sensorType, int layerMask = UnityEngine.Physics.DefaultRaycastLayers)
        {
            TSVector2 center;

            center.x = (pointA.x + pointB.x) * FP.Half;
            center.y = (pointA.y + pointB.y) * FP.Half;

            Physics2D.Vertices vertices = new Physics2D.Vertices(4);
            vertices.Add(new TSVector2(pointA.x, pointA.y) - center);
            vertices.Add(new TSVector2(pointB.x, pointA.y) - center);
            vertices.Add(new TSVector2(pointB.x, pointB.y) - center);
            vertices.Add(new TSVector2(pointA.x, pointB.y) - center);

            return(OverlapGeneric(new Physics2D.PolygonShape(vertices, 1), center, sensorType, layerMask));
        }
        private static object _OverlapCapsule(TSVector2 point, TSVector2 size, TSCapsuleDirection2D direction, FP angle, Physics2D.BodySpecialSensor sensorType, int layerMask = UnityEngine.Physics.DefaultRaycastLayers)
        {
            if (direction == TSCapsuleDirection2D.HORIZONTAL)
            {
                FP aux = size.y;
                size.y = size.x;
                size.x = aux;

                angle += 90;
            }

            FP radius = size.x * FP.Half;

            Physics2D.Vertices capVerts = Physics2D.PolygonTools.CreateCapsule(size.y, radius, 8, radius, 8);

            Physics2D.PolygonTools.TransformVertices(capVerts, point, angle * FP.Deg2Rad * -1);

            return(OverlapGeneric(new Physics2D.PolygonShape(capVerts, 1), point, sensorType, layerMask));
        }