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.

Inheritance

Constructors

PolygonShape()

Properties

centroid Vector2
Local position of the shape centroid in parent body frame.
final
count int
Number of active vertices in the shape.
read / write
normals List<Vector2>
The normals of the shape. Note: use getVertexCount(), not _normals.length, to get number of active normals.
final
vertices List<Vector2>
The vertices of the shape. Note: use getVertexCount(), not _vertices.length, to get number of active vertices.
final
hashCode int
The hash code for this object. [...]
read-only, inherited
radius double
read / write, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
shapeType ShapeType
final, inherited

Methods

applyToCentroid(Transform xf) Vector2
Get the centroid and apply the supplied transform.
centroidToOut(Transform xf, Vector2 out) Vector2
Get the centroid and apply the supplied transform.
clone() Shape
override
computeAABB(AABB aabb, Transform xf, int childIndex) → void
Given a transform, compute the associated axis aligned bounding box for a child shape. [...]
override
computeCentroidToOut(List<Vector2> vs, int count, Vector2 out) → 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. [...]
override
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. [...]
override
getChildCount() int
Get the number of child primitives [...]
override
getVertex(int index) Vector2
Get a vertex by index. [...]
getVertexCount() int
Get the vertex count. [...]
raycast(RayCastOutput output, RayCastInput input, Transform xf, int childIndex) bool
Cast a ray against a child shape. [...]
override
set(List<Vector2> vertices, int count) → void
Create a convex hull from the given array of points. The count must be in the range 3, Settings.maxPolygonVertices. [...]
setAsBox(double hx, double hy, Vector2 center, double angle) → void
Build vertices to represent an oriented box. [...]
setAsBoxXY(double hx, double hy) → void
Build vertices to represent an axis-aligned box. [...]
setAsEdge(Vector2 v1, Vector2 v2) → void
Set this as a single edge.
setWithPools(List<Vector2> verts, int num, Vec2Array vecPool, IntArray intPool) → void
Create a convex hull from the given array of points. The count must be in the range 3, Settings.maxPolygonVertices. This method takes an arraypool for pooling. [...]
testPoint(Transform xf, Vector2 p) bool
Test a point for containment in this shape. This only works for convex shapes. [...]
override
validate() bool
Validate convexity. This is a very time consuming operation. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(dynamic other) bool
The equality operator. [...]
inherited