A solid convex polygon. It is assumed that the interior of the polygon is to the left of each edge. Polygons have a maximum number of vertices equal to B2_MAX_POLYGON_VERTICES. In most cases you should not need many vertices for a convex polygon. Warning: DO NOT fill this out manually, instead use a helper function like MakePolygon or MakeBox.
More...
|
| Polygon (ReadOnlySpan< Vec2 > points, float radius=0f) |
| Construct a polygon shape with a set of vertices and an optional radius.
|
|
MassData | ComputeMass (float density) |
| Compute mass properties of this polygon.
|
|
AABB | ComputeAABB (in Transform transform) |
| Compute the bounding box of this transformed polygon.
|
|
bool | TestPoint (in Vec2 point) |
| Test this point for overlap with a convex polygon in local space.
|
|
CastOutput | RayCast (in RayCastInput input) |
| Ray cast versus this polygon shape in local space. Initial overlap is treated as a miss.
|
|
CastOutput | ShapeCast (in ShapeCastInput input) |
| Shape cast versus this convex polygon. Initial overlap is treated as a miss.
|
|
|
static Polygon | MakePolygon (ReadOnlySpan< Vec2 > points, float radius) |
| Make a convex polygon from a set of points. This will create a hull and assert if it is not valid.
|
|
static Polygon | MakePolygon (in Hull hull, float radius) |
| Make a convex polygon from a convex hull. This will assert if the hull is not valid.
|
|
static Polygon | MakeOffsetPolygon (Span< Vec2 > points, Vec2 position, Rotation rotation) |
| Make an offset convex polygon from a set of points. This will create a hull and assert if it is not valid.
|
|
static Polygon | MakeOffsetPolygon (in Hull hull, Vec2 position, Rotation rotation) |
| Make an offset convex polygon from a convex hull. This will assert if the hull is not valid.
|
|
static Polygon | MakeOffsetRoundedPolygon (Span< Vec2 > points, Vec2 position, Rotation rotation, float radius) |
| Make an offset convex polygon from a set of points. This will create a hull and assert if it is not valid.
|
|
static Polygon | MakeSquare (float halfWidth) |
| Make a square polygon, bypassing the need for a convex hull.
|
|
static Polygon | MakeBox (float halfWidth, float halfHeight) |
| Make a box (rectangle) polygon, bypassing the need for a convex hull.
|
|
static Polygon | MakeRoundedBox (float halfWidth, float halfHeight, float radius) |
| Make a rounded box, bypassing the need for a convex hull.
|
|
static Polygon | MakeOffsetBox (float halfWidth, float halfHeight, Vec2 center, Rotation rotation) |
| Make an offset box, bypassing the need for a convex hull.
|
|
static Polygon | MakeOffsetRoundedBox (float halfWidth, float halfHeight, Vec2 center, Rotation rotation, float radius) |
| Make an offset rounded box, bypassing the need for a convex hull.
|
|
static Polygon | MakeOffsetRoundedPolygon (in Hull hull, Vec2 position, Rotation rotation, float radius) |
| Make an offset convex polygon from a convex hull. This will assert if the hull is not valid.
|
|
|
Vec2 | Centroid |
| The centroid of the polygon.
|
|
float | Radius |
| The external radius for rounded polygons.
|
|
|
ReadOnlySpan< Vec2 > | Vertices [get] |
| The polygon vertices.
|
|
ReadOnlySpan< Vec2 > | Normals [get] |
| The outward normal vectors of the polygon sides.
|
|
A solid convex polygon. It is assumed that the interior of the polygon is to the left of each edge. Polygons have a maximum number of vertices equal to B2_MAX_POLYGON_VERTICES. In most cases you should not need many vertices for a convex polygon. Warning: DO NOT fill this out manually, instead use a helper function like MakePolygon or MakeBox.
◆ Polygon()
Box2D.Polygon.Polygon |
( |
ReadOnlySpan< Vec2 > |
points, |
|
|
float |
radius = 0f |
|
) |
| |
|
inline |
Construct a polygon shape with a set of vertices and an optional radius.
This constructor implicitly creates a Hull from the points. The hull is computed in the order of the points. The hull is assumed to be convex.
A radius greater than 0 will create a rounded polygon. A negative radius is invalid.
◆ MakeBox()
static Polygon Box2D.Polygon.MakeBox |
( |
float |
halfWidth, |
|
|
float |
halfHeight |
|
) |
| |
|
static |
Make a box (rectangle) polygon, bypassing the need for a convex hull.
- Parameters
-
halfWidth | the half-width (x-axis) |
halfHeight | the half-height (y-axis) |
◆ MakeOffsetBox()
static Polygon Box2D.Polygon.MakeOffsetBox |
( |
float |
halfWidth, |
|
|
float |
halfHeight, |
|
|
Vec2 |
center, |
|
|
Rotation |
rotation |
|
) |
| |
|
static |
Make an offset box, bypassing the need for a convex hull.
- Parameters
-
halfWidth | the half-width (x-axis) |
halfHeight | the half-height (y-axis) |
center | the local center of the box |
rotation | the local rotation of the box |
◆ MakeOffsetPolygon()
static Polygon Box2D.Polygon.MakeOffsetPolygon |
( |
in Hull |
hull, |
|
|
Vec2 |
position, |
|
|
Rotation |
rotation |
|
) |
| |
|
static |
Make an offset convex polygon from a convex hull. This will assert if the hull is not valid.
Warning: Do not manually fill in the hull data, it must come directly from b2ComputeHull
◆ MakeOffsetRoundedBox()
static Polygon Box2D.Polygon.MakeOffsetRoundedBox |
( |
float |
halfWidth, |
|
|
float |
halfHeight, |
|
|
Vec2 |
center, |
|
|
Rotation |
rotation, |
|
|
float |
radius |
|
) |
| |
|
static |
Make an offset rounded box, bypassing the need for a convex hull.
- Parameters
-
halfWidth | the half-width (x-axis) |
halfHeight | the half-height (y-axis) |
center | the local center of the box |
rotation | the local rotation of the box |
radius | the radius of the rounded extension |
◆ MakeOffsetRoundedPolygon()
static Polygon Box2D.Polygon.MakeOffsetRoundedPolygon |
( |
in Hull |
hull, |
|
|
Vec2 |
position, |
|
|
Rotation |
rotation, |
|
|
float |
radius |
|
) |
| |
|
static |
Make an offset convex polygon from a convex hull. This will assert if the hull is not valid.
Warning: Do not manually fill in the hull data, it must come directly from b2ComputeHull
◆ MakePolygon()
static Polygon Box2D.Polygon.MakePolygon |
( |
in Hull |
hull, |
|
|
float |
radius |
|
) |
| |
|
static |
Make a convex polygon from a convex hull. This will assert if the hull is not valid.
Warning: Do not manually fill in the hull data, it must come directly from b2ComputeHull
◆ MakeRoundedBox()
static Polygon Box2D.Polygon.MakeRoundedBox |
( |
float |
halfWidth, |
|
|
float |
halfHeight, |
|
|
float |
radius |
|
) |
| |
|
static |
Make a rounded box, bypassing the need for a convex hull.
- Parameters
-
halfWidth | the half-width (x-axis) |
halfHeight | the half-height (y-axis) |
radius | the radius of the rounded extension |
◆ MakeSquare()
static Polygon Box2D.Polygon.MakeSquare |
( |
float |
halfWidth | ) |
|
|
static |
Make a square polygon, bypassing the need for a convex hull.
- Parameters
-
The documentation for this struct was generated from the following files:
- src/Box2DBindings/Shapes/Polygon.cs
- src/Box2DBindings/Shapes/Polygon_Externs.cs