Box2D  3.0.0
A Real-Time-Oriented 2-D Physics Engine
Classes | Public Member Functions | Static Public Member Functions | List of all members
box2d::ChainShape Class Reference

Chain shape. More...

#include <ChainShape.hpp>

Inheritance diagram for box2d::ChainShape:
box2d::Shape

Classes

struct  Conf
 

Public Member Functions

 ChainShape (const Conf &conf=GetDefaultConf())
 
 ChainShape (const ChainShape &other)
 
virtual ~ChainShape ()
 The destructor frees the vertices using free. More...
 
child_count_t GetChildCount () const noexcept override
 Gets the number of child primitives. More...
 
DistanceProxy GetChild (child_count_t index) const noexcept override
 Gets the child for the given index. More...
 
bool TestPoint (const Transformation &xf, const Length2D p) const noexcept override
 Tests a point for containment in this shape. More...
 
MassData GetMassData () const noexcept override
 Computes the mass properties of this shape using its dimensions and density. The inertia tensor is computed about the local origin. More...
 
RayCastOutput RayCast (const RayCastInput &input, const Transformation &xf, child_count_t childIndex) const noexcept override
 Cast a ray against a child shape. More...
 
void Accept (Visitor &visitor) const override
 Accepts a visitor. More...
 
ChainShapeoperator= (const ChainShape &other)
 
void Clear ()
 Clear all data. More...
 
void CreateLoop (Span< const Length2D > vertices)
 Create a loop. This automatically adjusts connectivity. More...
 
void CreateChain (Span< const Length2D > vertices)
 Create a chain with isolated end vertices. More...
 
child_count_t GetVertexCount () const noexcept
 Get the vertex count. More...
 
Length2D GetVertex (child_count_t index) const
 Get a vertex by index. More...
 
UnitVec2 GetNormal (child_count_t index) const
 
- Public Member Functions inherited from box2d::Shape
 Shape ()=delete
 Default constructor is deleted. More...
 
 Shape (const Conf &conf) noexcept
 Initializing constructor. More...
 
 Shape (const Shape &)=default
 
virtual ~Shape ()=default
 
Length GetVertexRadius () const noexcept
 Gets the vertex radius. More...
 
void SetVertexRadius (Length vertexRadius)
 
Density GetDensity () const noexcept
 Gets the density of this fixture. More...
 
void SetDensity (Density density) noexcept
 Sets the density of this fixture. More...
 
RealNum GetFriction () const noexcept
 Gets the coefficient of friction. More...
 
void SetFriction (RealNum friction) noexcept
 Sets the coefficient of friction. This will not change the friction of existing contacts. More...
 
RealNum GetRestitution () const noexcept
 Gets the coefficient of restitution. More...
 
void SetRestitution (RealNum restitution) noexcept
 Sets the coefficient of restitution. This will not change the restitution of existing contacts. More...
 

Static Public Member Functions

static constexpr Length GetDefaultVertexRadius () noexcept
 
static constexpr Conf GetDefaultConf () noexcept
 

Detailed Description

Chain shape.

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. Since there may be many vertices, they are allocated using alloc. Connectivity information is used to create smooth collisions.

Warning
The chain will not collide properly if there are self-intersections.

Constructor & Destructor Documentation

◆ ChainShape() [1/2]

box2d::ChainShape::ChainShape ( const Conf conf = GetDefaultConf())
inline

◆ ChainShape() [2/2]

ChainShape::ChainShape ( const ChainShape other)

◆ ~ChainShape()

ChainShape::~ChainShape ( )
virtual

The destructor frees the vertices using free.

Member Function Documentation

◆ Accept()

void box2d::ChainShape::Accept ( Visitor visitor) const
inlineoverridevirtual

Accepts a visitor.

Implements box2d::Shape.

◆ Clear()

void ChainShape::Clear ( )

Clear all data.

◆ CreateChain()

void ChainShape::CreateChain ( Span< const Length2D vertices)

Create a chain with isolated end vertices.

Parameters
verticesan array of vertices, these are copied

◆ CreateLoop()

void ChainShape::CreateLoop ( Span< const Length2D vertices)

Create a loop. This automatically adjusts connectivity.

Note
Behavior is undefined if vertices is null or if count of vertices is less than 3.
Parameters
verticesNon-null array of vertices. These are copied.

◆ GetChild()

DistanceProxy ChainShape::GetChild ( child_count_t  index) const
overridevirtualnoexcept

Gets the child for the given index.

Note
The shape must remain in scope while the proxy is in use.

Implements box2d::Shape.

◆ GetChildCount()

child_count_t ChainShape::GetChildCount ( ) const
overridevirtualnoexcept

Gets the number of child primitives.

Returns
Positive non-zero count.

Implements box2d::Shape.

◆ GetDefaultConf()

static constexpr Conf box2d::ChainShape::GetDefaultConf ( )
inlinestaticnoexcept

◆ GetDefaultVertexRadius()

static constexpr Length box2d::ChainShape::GetDefaultVertexRadius ( )
inlinestaticnoexcept

◆ GetMassData()

MassData ChainShape::GetMassData ( ) const
overridevirtualnoexcept

Computes the mass properties of this shape using its dimensions and density. The inertia tensor is computed about the local origin.

Note
Behavior is undefined if the density is negative.
Returns
Mass data for this shape.

Implements box2d::Shape.

◆ GetNormal()

UnitVec2 box2d::ChainShape::GetNormal ( child_count_t  index) const
inline

◆ GetVertex()

Length2D box2d::ChainShape::GetVertex ( child_count_t  index) const
inline

Get a vertex by index.

◆ GetVertexCount()

child_count_t box2d::ChainShape::GetVertexCount ( ) const
inlinenoexcept

Get the vertex count.

◆ operator=()

ChainShape & ChainShape::operator= ( const ChainShape other)

◆ RayCast()

RayCastOutput ChainShape::RayCast ( const RayCastInput input,
const Transformation xf,
child_count_t  childIndex 
) const
overridevirtualnoexcept

Cast a ray against a child shape.

Parameters
inputthe ray-cast input parameters.
xfthe transform to be applied to the shape.
childIndexthe child shape index

Implements box2d::Shape.

◆ TestPoint()

bool ChainShape::TestPoint ( const Transformation xf,
const Length2D  p 
) const
overridevirtualnoexcept

Tests a point for containment in this shape.

Parameters
xfthe shape world transform.
pa point in world coordinates.
Returns
true if point is contained in this shape, false otherwise.

Implements box2d::Shape.


The documentation for this class was generated from the following files: