PolygonShape class

A convex polygon shape. Polygons have a maximum number of vertices equal to _maxPolygonVertices. In most cases you should not need many vertices for a convex polygon.





centroid Vector2
Local position of the shape centroid in parent body frame.
childCount int
Get the number of child primitives
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
normals List<Vector2>
The normals of the shape. Note: use vertexCount, not _normals.length, to get number of active normals.
radius double
getter/setter pairinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shapeType ShapeType
vertices List<Vector2>
The vertices of the shape. Note: use vertexCount, not _vertices.length, to get number of active vertices.


applyToCentroid(Transform xf) Vector2
Get the centroid and apply the supplied transform.
clone() Shape
computeAABB(AABB aabb, Transform xf, int childIndex) → void
Given a transform, compute the associated axis aligned bounding box for a child shape.
computeCentroid(List<Vector2> vs, int count) → void
computeDistanceToOut(Transform xf, Vector2 p, int childIndex, Vector2 normalOut) double
Compute the distance from the current shape to the specified point. This only works for convex shapes.
computeMass(MassData massData, double density) → void
Compute the mass properties of this shape using its dimensions and density. The inertia tensor is computed about the local origin. density should be in kilograms per meter squared.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
raycast(RayCastOutput output, RayCastInput input, Transform xf, int childIndex) bool
Cast a ray against a child shape.
set(List<Vector2> updatedVertices) → void
Create a convex hull from the given array of points. The length of the list must be in the range 3, Settings.maxPolygonVertices. Warning: the points may be re-ordered, even if they form a convex polygon. Warning: collinear points are removed.
setAsBox(double halfWidth, double halfHeight, Vector2 center, double angle) → void
Build vertices to represent an oriented box. center and angle should be in local coordinates.
setAsBoxXY(double halfWidth, double halfHeight) → void
Build vertices to represent an axis-aligned box.
setAsEdge(Vector2 v1, Vector2 v2) → void
Set this as a single edge.
testPoint(Transform xf, Vector2 p) bool
Test a point for containment in this shape. This only works for convex shapes.
toString() String
A string representation of this object.
validate() bool
Validate convexity. This is a very time consuming operation.


operator ==(Object other) bool
The equality operator.