protected override void DoAddCollider(FarseerPhysics.Dynamics.Body body, float mass) { switch (plane2d) { case Plane2d.XY: to2dMode = Physics.To2dMode.DropZ; break; case Plane2d.XZ: to2dMode = Physics.To2dMode.DropY; break; case Plane2d.YZ: to2dMode = Physics.To2dMode.DropX; break; } connectedBody = body; Vector2 scale = VectorConverter.Convert(transform.lossyScale, to2dMode); Vertices v = new Vertices(); for (int i = 0; i < relativePoints.Length; i++) { v.Add(relativePoints[i] * scale); } Physics.AddMesh(body, isTrigger, EarclipDecomposer.ConvexPartition(v), mass); }
protected override void DoAddCollider(Body body, float mass) { Microsoft.Xna.Framework.Vector2 scale = VectorConverter.Convert(transform.lossyScale, to2dMode); for (int i = 0; i < vertices.Count; i++) { Vertices v = vertices[i]; for (int j = 0; j < v.Count; j++) { v[j] = v[j] * scale; } } connectedBody = body; Physics.AddMesh(body, isTrigger, vertices, mass); }