Example #1
0
        /// <summary>
        /// Creates a breakable body. You would want to remove collinear points before using this.
        /// </summary>
        /// <param name="world">The world.</param>
        /// <param name="vertices">The vertices.</param>
        /// <param name="density">The density.</param>
        /// <param name="position">The position.</param>
        /// <returns></returns>
        public static PhysicsBreakableBody CreateBreakableBody(PhysicsWorld world, Vertices vertices, float density, Vector2 position,
            object userData)
        {
            List<Vertices> triangles = EarclipDecomposer.ConvexPartition(vertices);

            PhysicsBreakableBody breakableBody = new PhysicsBreakableBody(triangles, world, density, userData);
            breakableBody.MainBody.Position = position;
            world.AddBreakableBody(breakableBody);

            return breakableBody;
        }