Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


PolygonGeometry

The geometry of a closed convex polygon. The geometry has a fixed maximum number of vertices as defined by the constant PhysicsConstants.MaxPolygonVertices. Polygon regions that require a larger quantity of vertices or are concave are defined by multiple polygon geometry using the PhysicsComposer or the PolygonGeometry.CreatePolygons utility. See PhysicsBody.CreateShape.
Read time 3 minutesLast updated 4 days ago

Definition

public struct PolygonGeometry : IEquatable<PolygonGeometry>

Fields

Value

Description

normalsThe geometry normal stored in a PhysicsShape.ShapeArray.
verticesThe geometry vertices stored in a PhysicsShape.ShapeArray.

Static Fields

Value

Description

defaultGeometryGet the default Polygon.

Constructors

Constructor

Description

PolygonGeometry()Create a default Polygon. See _defaultGeometry.

Properties

Property

Description

areEdgesValidWhether every edge of this polygon is far enough apart and no three consecutive vertices are collinear, matching the rules applied when building a polygon from vertices.
centroidThe centroid of the polygon.
countThe number of polygon vertices.
isValidWhether the geometry describes a polygon that can be used.
radiusThe external radius for rounded polygons.

Methods

Method

Description

AsReadOnlySpanGet the polygon vertices as a read-only span.
AsSpanGet the polygon vertices as a span.
CalculateAABBCalculate the AABB of the geometry.
CalculateMassConfigurationCalculate the mass configuration of the geometry.
CastRayCalculate if a world ray intersects the geometry. See PhysicsQuery.CastResult.
CastShapeCalculate if a cast shape intersects the geometry. Initially touching shapes are treated as a miss. You should check for overlap first if initial overlap is required. See PhysicsQuery.CastShapeInput and PhysicsQuery.CastResult.
ClosestPointCalculate the closest point on this geometry to the specified point.
CreateShapeProxyCreate a shape proxy from the geometry.
IntersectCheck the intersection between this geometry and another.
InverseTransformInverse-Transform the geometry.
OverlapPointCalculate if a point overlaps the geometry.
TransformTransform the specified geometry.
ValidateRebuild the polygon from its vertices.

Static Methods

Method

Description

CreateCreate a Polygon from the specified vertices. The number of vertices must be in the range 3 to PhysicsConstants.MaxPolygonVertices.
CreateBoxCreate a Polygon as a four-sided box.
CreatePolygonsCreate multiple PolygonGeometry from a set of vertices. The vertices are assumed to produce a closed loop but can describe a concave shape if required. There must be at least 3 vertices. A limit is imposed on small vertex distances so be aware that this overload uses a vertex scale of _one so consider using the overload which allows you to increase this if required.
DeleteVertexDelete a vertex from the geometry returning a new geometry with updated normals and centroid.
InsertVertexInsert a vertex into the geometry returning a new geometry with updated normals and centroid.
InverseTransformInverse-Transform a batch of geometry in place. A transform that degenerates the geometry hull writes an invalid (zero-vertex) polygon in its place.
TransformTransform a batch of geometry in place. A transform that degenerates the geometry hull writes an invalid (zero-vertex) polygon in its place.

Structs

Struct

Description

PolygonGeometry.ConvexHullA simple convex hull. The hull is not validated by physics so cannot be used directly for shapes.