ChainShape
Declaration
public class tainicom.Aether.Physics2D.Collision.Shapes.ChainShape
A chain shape is a free form sequence of line segments. The chain has two-sided collision, so you can use inside and outside collision. Therefore, you may use any winding order. Connectivity information is used to create smooth collisions. WARNING: The chain will not collide properly if there are self-intersections.
Inherits: tainicom.Aether.Physics2D.Collision.Shapes.Shape
Constructors
ChainShape
Constructor for ChainShape. By default have 0 in density.
void ChainShape()
ChainShape
Create a new chainshape from the vertices.
void ChainShape(Vertices vertices, bool createLoop = false)
Parameters:
| Name | Type | Description |
|---|---|---|
vertices |
tainicom.Aether.Physics2D.Common.Vertices |
The vertices to use. Must contain 2 or more vertices. |
createLoop |
System.Boolean = false |
Set to true to create a closed loop. It connects the first vertice to the last, and automatically adjusts connectivity to create smooth collisions along the chain. |
Properties
ChildCount override
int ChildCount { get }
PrevVertex
Establish connectivity to a vertex that precedes the first vertex. Don't call this for loops.
Vector2 PrevVertex { get set }
NextVertex
Establish connectivity to a vertex that follows the last vertex. Don't call this for loops.
Vector2 NextVertex { get set }
Fields
Vertices
The vertices. These are not owned/freed by the chain Shape.
Vertices Vertices
Methods
GetChildEdge
Get a child edge.
EdgeShape GetChildEdge(int index)
Parameters:
| Name | Type | Description |
|---|---|---|
index |
System.Int32 |
The index. |
TestPoint override
bool TestPoint(ref Transform transform, ref Vector2 point)
Parameters:
| Name | Type | Description |
|---|---|---|
transform |
ref tainicom.Aether.Physics2D.Common.Transform |
|
point |
ref Strawberry.Math.Vector2 |
RayCast override
bool RayCast(out RayCastOutput output, ref RayCastInput input, ref Transform transform, int childIndex)
Parameters:
| Name | Type | Description |
|---|---|---|
output |
out tainicom.Aether.Physics2D.Collision.RayCastOutput |
|
input |
ref tainicom.Aether.Physics2D.Collision.RayCastInput |
|
transform |
ref tainicom.Aether.Physics2D.Common.Transform |
|
childIndex |
System.Int32 |
ComputeAABB override
void ComputeAABB(out AABB aabb, ref Transform transform, int childIndex)
Parameters:
| Name | Type | Description |
|---|---|---|
aabb |
out tainicom.Aether.Physics2D.Collision.AABB |
|
transform |
ref tainicom.Aether.Physics2D.Common.Transform |
|
childIndex |
System.Int32 |
ComputeProperties protected override
void ComputeProperties()
ComputeSubmergedArea override
float ComputeSubmergedArea(ref Vector2 normal, float offset, ref Transform xf, out Vector2 sc)
Parameters:
| Name | Type | Description |
|---|---|---|
normal |
ref Strawberry.Math.Vector2 |
|
offset |
System.Single |
|
xf |
ref tainicom.Aether.Physics2D.Common.Transform |
|
sc |
out Strawberry.Math.Vector2 |
CompareTo
Compare the chain to another chain
bool CompareTo(ChainShape shape)
Parameters:
| Name | Type | Description |
|---|---|---|
shape |
tainicom.Aether.Physics2D.Collision.Shapes.ChainShape |
The other chain |
Returns: True if the two chain shapes are the same
Clone override
Shape Clone()