Table of Contents

Class ChainShape

Namespace
Alis.Core.Physic.Collision.Shapes
Assembly
Alis.dll

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.

public class ChainShape : Shape

Inheritance

Inherited Members

Constructors

ChainShape()

Constructor for ChainShape. By default have 0 in density.

public ChainShape()

ChainShape(Vertices, bool)

Create a new chainshape from the vertices.

public ChainShape(Vertices vertices, bool createLoop = false)

Parameters

vertices Vertices

The vertices to use. Must contain 2 or more vertices.

createLoop bool

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.

Fields

Vertices

The vertices. These are not owned/freed by the chain Shape.

public Vertices Vertices

Field Value

Vertices

_edgeShape

The edge shape

private static readonly EdgeShape _edgeShape

Field Value

EdgeShape

_hasNextVertex

The has next vertex

private bool _hasNextVertex

Field Value

bool

_hasPrevVertex

The has next vertex

private bool _hasPrevVertex

Field Value

bool

_nextVertex

The next vertex

private Vector2 _nextVertex

Field Value

Vector2

_prevVertex

The next vertex

private Vector2 _prevVertex

Field Value

Vector2

Properties

ChildCount

Gets the value of the child count

public override int ChildCount { get; }

Property Value

int

NextVertex

Establish connectivity to a vertex that follows the last vertex. Don't call this for loops.

public Vector2 NextVertex { get; set; }

Property Value

Vector2

PrevVertex

Establish connectivity to a vertex that precedes the first vertex. Don't call this for loops.

public Vector2 PrevVertex { get; set; }

Property Value

Vector2

Methods

Clone()

Clones this instance

public override Shape Clone()

Returns

Shape

The clone

CompareTo(ChainShape)

Compare the chain to another chain

public bool CompareTo(ChainShape shape)

Parameters

shape ChainShape

The other chain

Returns

bool

True if the two chain shapes are the same

ComputeAABB(out AABB, ref Transform, int)

Computes the aabb using the specified aabb

public override void ComputeAABB(out AABB aabb, ref Transform transform, int childIndex)

Parameters

aabb AABB

The aabb

transform Transform

The transform

childIndex int

The child index

ComputeProperties()

Computes the properties

protected override void ComputeProperties()

ComputeSubmergedArea(ref Vector2, float, ref Transform, out Vector2)

Computes the submerged area using the specified normal

public override float ComputeSubmergedArea(ref Vector2 normal, float offset, ref Transform xf, out Vector2 sc)

Parameters

normal Vector2

The normal

offset float

The offset

xf Transform

The xf

sc Vector2

The sc

Returns

float

The float

GetChildEdge(EdgeShape, int)

This method has been optimized to reduce garbage.

internal void GetChildEdge(EdgeShape edge, int index)

Parameters

edge EdgeShape

The cached edge to set properties on.

index int

The index.

GetChildEdge(int)

Get a child edge.

public EdgeShape GetChildEdge(int index)

Parameters

index int

The index.

Returns

EdgeShape

RayCast(out RayCastOutput, ref RayCastInput, ref Transform, int)

Describes whether this instance ray cast

public override bool RayCast(out RayCastOutput output, ref RayCastInput input, ref Transform transform, int childIndex)

Parameters

output RayCastOutput

The output

input RayCastInput

The input

transform Transform

The transform

childIndex int

The child index

Returns

bool

The bool

TestPoint(ref Transform, ref Vector2)

Describes whether this instance test point

public override bool TestPoint(ref Transform transform, ref Vector2 point)

Parameters

transform Transform

The transform

point Vector2

The point

Returns

bool

The bool