Shape

expect class Shape

A shape attached to a body. Shapes define the collision geometry and physical properties.

Properties

Link copied to clipboard
expect val aabb: AABB

Get the axis-aligned bounding box of this shape in world coordinates.

Link copied to clipboard

Are contact events enabled for this shape?

Link copied to clipboard

Are hit events enabled for this shape?

Link copied to clipboard

Are pre-solve events enabled for this shape?

Link copied to clipboard

Are sensor events enabled for this shape?

Link copied to clipboard
expect val body: Body

Get the body that this shape is attached to.

Link copied to clipboard
expect val contactCount: Int

Get the contact capacity for this shape.

Link copied to clipboard
expect var density: Float

The density of this shape.

Link copied to clipboard
expect var filter: Filter

The collision filter.

Link copied to clipboard
expect var friction: Float

The friction of this shape.

Link copied to clipboard
expect val isSensor: Boolean

Check if this shape is a sensor.

Link copied to clipboard
expect val isValid: Boolean

Check if this shape reference is valid. Shapes may be destroyed by the user or during world destruction.

Link copied to clipboard
expect var material: Int

The material identifier for this shape.

Link copied to clipboard
expect var restitution: Float

The restitution (bounciness) of this shape.

Link copied to clipboard
expect val sensorCount: Int

Get the sensor overlap capacity.

Link copied to clipboard

The surface material properties.

Link copied to clipboard
expect val type: ShapeType

Get the type of this shape.

Link copied to clipboard
expect var userData: Long

User data stored as a Long. Can be used as a key in a Map for associating arbitrary objects with this shape.

Link copied to clipboard
expect val world: World

Get the world that owns this shape.

Functions

Link copied to clipboard
expect fun destroy(updateBodyMass: Boolean = true)

Destroy this shape.

Link copied to clipboard
expect fun enableContactEvents(enabled: Boolean)

Enable or disable contact events for this shape.

Link copied to clipboard
expect fun enableHitEvents(enabled: Boolean)

Enable or disable hit events for this shape.

Link copied to clipboard
expect fun enablePreSolveEvents(enabled: Boolean)

Enable or disable pre-solve events for this shape.

Link copied to clipboard
expect fun enableSensorEvents(enabled: Boolean)

Enable or disable sensor events for this shape.

Link copied to clipboard
expect fun getCapsule(): Capsule

Get the capsule geometry. Only valid if type is Capsule.

Link copied to clipboard

Get the chain segment for this shape. Only valid if type is ChainSegment.

Link copied to clipboard
expect fun getCircle(): Circle

Get the circle geometry. Only valid if type is Circle.

Link copied to clipboard
expect fun getClosestPoint(target: Vec2): Vec2

Get the closest point on this shape to the given target point.

Link copied to clipboard

Get contact data for this shape.

Link copied to clipboard
expect fun getMassData(): MassData

Get the mass data for this shape based on its geometry and density.

Link copied to clipboard
expect fun getParentChain(): Chain?

Get the parent chain for this shape, or null if not part of a chain.

Link copied to clipboard
expect fun getPolygon(): Polygon

Get the polygon geometry. Only valid if type is Polygon.

Link copied to clipboard
expect fun getSegment(): Segment

Get the segment geometry. Only valid if type is Segment.

Link copied to clipboard

Get the shapes overlapping with this sensor. Only valid for sensors.

Link copied to clipboard
expect fun rayCast(origin: Vec2, translation: Vec2): CastOutput

Cast a ray against this shape.

Link copied to clipboard
expect fun setCapsule(capsule: Capsule)

Set the capsule geometry. Only valid if type is Capsule.

Link copied to clipboard
expect fun setCircle(circle: Circle)

Set the circle geometry. Only valid if type is Circle.

Link copied to clipboard
expect fun setDensity(density: Float, updateBodyMass: Boolean = true)

Set the density with control over body mass update.

Link copied to clipboard
expect fun setPolygon(polygon: Polygon)

Set the polygon geometry. Only valid if type is Polygon.

Link copied to clipboard
expect fun setSegment(segment: Segment)

Set the segment geometry. Only valid if type is Segment.

Link copied to clipboard
expect fun testPoint(point: Vec2): Boolean

Test a point for overlap with this shape.