/// <summary> /// Checks if this PolygonCollider collides with the other PolygonCollider /// </summary> /// <param name="first">The first polygon collider</param> /// <param name="second">The second polygon collider</param> /// <returns></returns> internal static bool CheckPolygonCollision(this IPolygonColliderComponent first, IPolygonColliderComponent second) { var poly1 = first.Polygon?.Transform(first.Entity.Position, first.Origin, first.Entity.Transform.Rotation); //new Polygon(pThisPoly); var poly2 = second.Polygon?.Transform(second.Entity.Position, second.Origin, second.Entity.Transform.Rotation); //new Polygon(pOtherPoly); return((poly1 != null && poly2 != null) && poly1.Overlaps(poly2)); }
/// <summary> /// Draws the polygon collider /// </summary> /// <param name="collider"></param> /// <param name="target"></param> /// <param name="renderColor"></param> public static void DebugRender(this IPolygonColliderComponent collider, RenderTarget target, Color renderColor) { #if DEBUG Entities.Components.Transform transform = collider.Entity.Transform; Polygon polygon = collider.Polygon?.Transform(transform.Position, collider.Origin, transform.Rotation); if (polygon != null) { VertexArray vert = polygon.ToVertexArray(renderColor); vert.PrimitiveType = PrimitiveType.LineStrip; target.Draw(vert); } #endif }