CP::Shape::Poly
Inherits Indexable / Enumerable / Iterable / Enumerable / CP::Shape / Reference / Object
A convex polygon shape
Slowest, but most flexible collision shape.
Constructors
Initialize a polygon shape with rounded corners. A convex hull will be created from the vertices.
The parameters are: the body to attach the poly to; the verts (vertices) of the polygon; the transform to apply to every vertex; the radius of the corners.
Adding a small radius will bevel the corners and can significantly reduce problems where the poly gets stuck on seams in your geometry.
Initialize a polygon shape with rounded corners. The vertices must be convex with a counter-clockwise winding.
Class methods
Calculate the signed area of a polygon.
A clockwise winding gives positive area. This is probably backwards from what you expect, but matches Chipmunk's winding for poly shapes.
Calculate the natural centroid of a polygon.
Calculate the convex hull of a given set of points.
tol is the allowed amount to shrink the hull when simplifying it. A tolerance of 0.0 creates an exact hull.
Returns the convex hull and the index where the first vertex
in the hull came from (i.e. verts[first] == result[0])
Instance methods
Unsafe. Set the radius of a poly shape.
This change is only picked up as a change to the position of the shape's surface, but not its velocity. Changing it will not result in realistic physical behavior. Only use if you know what you are doing!
Unsafe. Set the vertices of a poly shape.
This change is only picked up as a change to the position of the shape's surface, but not its velocity. Changing it will not result in realistic physical behavior. Only use if you know what you are doing!