Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


PhysicsComposer

Provides the ability to compose geometry using specific operations on layers in a specific order.
Read time 3 minutesLast updated 6 days ago

Definition

public readonly struct PhysicsComposer : IEquatable<PhysicsComposer>, IDisposable

Static Fields

Value

Description

DefaultCurveStrideThe default curve stride used when composing geometry that has a non-zero radius.
MinCurveStrideThe minimum curve stride allowed when composing geometry that has a non-zero radius.

Properties

Property

Description

isValidCheck if a Physics Composer is valid.
layerCountGet the number of layers currently added to the Physics Composer.
layerHandlesGet the layer handles added to the Physics Composer.
maxPolygonVerticesGet/Set the maximum number of polygon vertices to be used when composing polygon output. This should be in the range of 3 to PhysicsConstants.MaxPolygonVertices. The default is PhysicsConstants.MaxPolygonVertices.
rejectedGeometryCountGet the number of geometries that were rejected during the last Geometry Composition. Geometry can be rejected for a number of reasons such as vertices being collinear or too close etc. Whilst "pure" geometry is always valid, this geometry is meant to be used by physics which has constraints on what it can accept. All geometry successfully created will always be valid when used by physics. If you notice thin/small gaps in the composition, this is likely to be rejected geometry. Checking this property will help determine that.
useDelaunayGet/Set if Delaunay tessellation is to be used. Delaunay tessellation is enabled by default and produces far superior results. When Delaunay tessellation is disabled, curved areas can produce invalid geometry which is rejected therefore increase the _rejectedGeometryCount.

Methods

Method

Description

AddLayerAdd multiple Capsule Geometry layer to the Physics Composer.
ClearLayersRemove all layers from the Physics Composer.
CreateChainGeometryCreate ChainGeometry from the composition by iterating all the layers added to the composition in the layer order specified, applying each operation specified. 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.
CreateConvexHullsCreate PolygonGeometry.ConvexHull from the composition by iterating all the layers added to the composition in the layer order specified, applying each operation specified. A default vertex scale of _one is used here.
CreatePolygonGeometryCreate PolygonGeometry from the composition by iterating all the layers added to the composition in the layer order specified, applying each operation specified. 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.
DestroyDestroy the Physics Composer.
DisposeDispose of the composer. This simply calls PhysicsComposer.Destroy.
GetGeometryIslandsGet the geometry islands from a previous polygon geometry composition i.e. a call to PhysicsComposer.CreatePolygonGeometry or PhysicsComposer.CreateConvexHulls. Each generated polygon or convex-hull belongs to a unique island defining a set of polygons that are connected together as they share edges. The array returned contains a series of ranges where each range is a unique connected island where the range indicates both the start index and length of the original polygon indices. The number of discovered unique islands is defined by the size of the returned array.
RemoveLayerRemove a layer from the Physics Composer.

Static Methods

Method

Description

CreateCreate a Physics Composer.
DestroyAllDestroy all active Physics Composer.
GetComposersGet all the currently active composers.
ToPolygonsCreates multiple PolygonGeometry from the specified geometry. A limit is imposed on small vertex distances so it is recommended that the geometry is scaled appropriately rather than on the returned geometry so geometry is not discarded due to it being invalid.

Structs

Struct

Description

PhysicsComposer.LayerHandleA composer layer handle.

Enums

Enum

Description

PhysicsComposer.OperationA composer operation.