HughPH.Box2D
Organised dotnet bindings for Box2D 3.1.1
|
A shape is a geometric object used for collision detection. More...
Inherits IEquatable< Shape >, and IComparable< Shape >.
Public Member Functions | |
Shape (Body body, in ShapeDef def, in Circle circle) | |
Create a shape on the specified body with the specified definition. | |
Shape (Body body, in ShapeDef def, in Segment segment) | |
Create a shape on the specified body with the specified definition. | |
Shape (Body body, in ShapeDef def, in Capsule capsule) | |
Create a shape on the specified body with the specified definition. | |
Shape (Body body, in ShapeDef def, in Polygon polygon) | |
Create a shape on the specified body with the specified definition. | |
bool | Equals (Shape other) |
Checks if this Shape and another Shape refer to the same shape. | |
override bool | Equals (object? obj) |
Checks if this Shape and another Shape refer to the same shape. | |
override int | GetHashCode () |
Returns a hash code for this shape. | |
unsafe void | Destroy (bool updateBodyMass) |
Destroys this shape. | |
unsafe void | SetDensity (float density, bool updateBodyMass) |
Sets the mass density of this shape. | |
unsafe bool | TestPoint (Vec2 point) |
Tests a point for overlap with this shape. | |
unsafe CastOutput | RayCast (in RayCastInput input) |
Ray casts this shape directly. | |
unsafe Circle | GetCircle () |
Gets a copy of the shape's circle. | |
unsafe Segment | GetSegment () |
Gets a copy of the shape's line segment. | |
unsafe ChainSegment | GetChainSegment () |
Gets a copy of the shape's chain segment. | |
unsafe Capsule | GetCapsule () |
Gets a copy of the shape's capsule. | |
unsafe Polygon | GetPolygon () |
Gets a copy of the shape's convex polygon. | |
unsafe void | SetCircle (in Circle circle) |
Allows you to change this shape to be a circle or update the current circle. | |
unsafe void | SetCapsule (in Capsule capsule) |
Allows you to change this shape to be a capsule or update the current capsule. | |
unsafe void | SetSegment (in Segment segment) |
Allows you to change this shape to be a segment or update the current segment. | |
unsafe void | SetPolygon (in Polygon polygon) |
Allows you to change this shape to be a polygon or update the current polygon. | |
unsafe ChainShape | GetParentChain () |
Gets the parent chain id if the shape type is a chain segment. | |
unsafe Vec2 | GetClosestPoint (Vec2 target) |
Gets the closest point on this shape to a target point. | |
Static Public Member Functions | |
static bool | operator== (Shape left, Shape right) |
Checks if this shape and another shape refer to the same shape. | |
static bool | operator!= (Shape left, Shape right) |
Checks if this shape and another shape refer to different shapes. | |
Properties | |
static IComparer< Shape > | DefaultComparer = ShapeComparer.Instance [get] |
Default comparer for Shape instances. This is used for sorting and comparing shapes. Using the default comparer is recommended to avoid boxing and unboxing overhead. | |
static IEqualityComparer< Shape > | DefaultEqualityComparer = ShapeComparer.Instance [get] |
Default equality comparer for Shape instances. This is used for comparing shapes. Using the default equality comparer is recommended to avoid boxing and unboxing overhead. | |
unsafe bool | Valid [get] |
Checks if this shape is valid. | |
unsafe ShapeType | Type [get] |
Gets the type of this shape. | |
unsafe Body | Body [get] |
Gets the body that this shape is attached to. | |
unsafe World | World [get] |
Gets the world that this shape belongs to. | |
unsafe bool | Sensor [get] |
Checks if this shape is a sensor. | |
unsafe? object | UserData [get, set] |
The user data object for this shape. | |
unsafe float | Density [get, set] |
The mass density of this shape. | |
unsafe float | Friction [get, set] |
The friction on this shape. | |
unsafe float | Restitution [get, set] |
Restitution of this shape. | |
unsafe int | Material [get, set] |
Gets/sets the material ID for this shape - this does not affect the shape's physical properties. | |
unsafe SurfaceMaterial | SurfaceMaterial [get, set] |
Gets/sets the surface material for this shape. | |
unsafe Filter | Filter [get, set] |
The filter for this shape. | |
unsafe bool | ContactEventsEnabled [get, set] |
Contact enabled state for this shape. | |
unsafe bool | PreSolveEventsEnabled [get, set] |
The pre-solve contact enabled state for this shape. | |
unsafe bool | HitEventsEnabled [get, set] |
Hit events enabled state for this shape. | |
unsafe ReadOnlySpan< ContactData > | ContactData [get] |
Gets the contact data for this shape. | |
unsafe ReadOnlySpan< Shape > | SensorOverlaps [get] |
Gets the overlapped shapes for this sensor shape. | |
unsafe AABB | AABB [get] |
Gets the current world AABB. | |
unsafe MassData | MassData [get] |
Gets the mass data for this shape. | |
ReadOnlySpan< Vec2 > | LocalVertices [get] |
Gets the local vertices of this shape. | |
ReadOnlySpan< Vec2 > | WorldVertices [get] |
Gets the world vertices of this shape. | |
A shape is a geometric object used for collision detection.
Create a shape on the specified body with the specified definition.
body | The body on which to create the shape |
def | The shape definition |
circle | The shape to create |
Create a shape on the specified body with the specified definition.
body | The body on which to create the shape |
def | The shape definition |
segment | The shape to create |
Create a shape on the specified body with the specified definition.
body | The body on which to create the shape |
def | The shape definition |
capsule | The shape to create |
Create a shape on the specified body with the specified definition.
body | The body on which to create the shape |
def | The shape definition |
polygon | The shape to create |
|
inline |
Destroys this shape.
updateBodyMass | Option to defer the body mass update |
You may defer the body mass update which can improve performance if several shapes on a body are destroyed at once
unsafe Capsule Box2D.Shape.GetCapsule | ( | ) |
Gets a copy of the shape's capsule.
Asserts the type is correct
unsafe ChainSegment Box2D.Shape.GetChainSegment | ( | ) |
Gets a copy of the shape's chain segment.
These come from chain shapes. Asserts the type is correct
unsafe Circle Box2D.Shape.GetCircle | ( | ) |
Gets a copy of the shape's circle.
Asserts the type is correct
|
inline |
Gets the closest point on this shape to a target point.
target | The target point |
Target and result are in world space
unsafe ChainShape Box2D.Shape.GetParentChain | ( | ) |
Gets the parent chain id if the shape type is a chain segment.
unsafe Polygon Box2D.Shape.GetPolygon | ( | ) |
Gets a copy of the shape's convex polygon.
Asserts the type is correct
unsafe Segment Box2D.Shape.GetSegment | ( | ) |
Gets a copy of the shape's line segment.
Asserts the type is correct
Checks if this shape and another shape refer to different shapes.
Checks if this shape and another shape refer to the same shape.
unsafe CastOutput Box2D.Shape.RayCast | ( | in RayCastInput | input | ) |
Ray casts this shape directly.
input | The ray cast input |
unsafe void Box2D.Shape.SetCapsule | ( | in Capsule | capsule | ) |
Allows you to change this shape to be a capsule or update the current capsule.
capsule | The capsule |
This does not modify the mass properties
unsafe void Box2D.Shape.SetCircle | ( | in Circle | circle | ) |
Allows you to change this shape to be a circle or update the current circle.
circle | The circle |
This does not modify the mass properties
unsafe void Box2D.Shape.SetDensity | ( | float | density, |
bool | updateBodyMass | ||
) |
Sets the mass density of this shape.
density | The mass density |
updateBodyMass | Option to update the mass properties on the parent body |
This will optionally update the mass properties on the parent body
unsafe void Box2D.Shape.SetPolygon | ( | in Polygon | polygon | ) |
Allows you to change this shape to be a polygon or update the current polygon.
polygon | The polygon |
This does not modify the mass properties
unsafe void Box2D.Shape.SetSegment | ( | in Segment | segment | ) |
Allows you to change this shape to be a segment or update the current segment.
segment | The segment |
unsafe bool Box2D.Shape.TestPoint | ( | Vec2 | point | ) |
Tests a point for overlap with this shape.
point | The point |
|
get |
Gets the current world AABB.
This is the axis-aligned bounding box in world coordinates
|
get |
Gets the body that this shape is attached to.
|
getset |
The mass density of this shape.
This will update the mass properties on the parent body. To avoid this, use SetDensity(float,bool)
|
getset |
The filter for this shape.
This may cause contacts to be immediately destroyed. However contacts are not created until the next world step. Sensor overlap state is also not updated until the next world step.
|
getset |
Gets/sets the material ID for this shape - this does not affect the shape's physical properties.
This is just for convenience. It is not used in the Box2D engine. There is no register of materials, and modifying this property does not modify the behaviour of the shape.
|
getset |
The pre-solve contact enabled state for this shape.
Only applies to dynamic bodies.
Warning: These are expensive and must be carefully handled due to multithreading.
Ignored for sensors
|
getset |
Restitution of this shape.
This is the coefficient of restitution (bounce) usually in the range [0,1].
|
get |
Checks if this shape is a sensor.
It is not possible to change a shape from sensor to solid dynamically because this breaks the contract for sensor events.
|
get |
Gets the overlapped shapes for this sensor shape.
Overlaps may contain destroyed shapes so use Valid to confirm each overlap.
Warning: Do not fetch this property during the contact callbacks
|
get |
Gets the type of this shape.
|
get |
Checks if this shape is valid.
Provides validation for up to 64K allocations