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

Shape. More...

#include <Shape.hpp>

Inheritance diagram for box2d::Shape:
box2d::ChainShape box2d::CircleShape box2d::EdgeShape box2d::PolygonShape

Classes

struct  Conf
 
struct  Visitor
 Visitor interface. More...
 

Public Member Functions

 Shape ()=delete
 Default constructor is deleted. More...
 
 Shape (const Conf &conf) noexcept
 Initializing constructor. More...
 
 Shape (const Shape &)=default
 
virtual ~Shape ()=default
 
virtual child_count_t GetChildCount () const noexcept=0
 Gets the number of child primitives of the shape. More...
 
virtual DistanceProxy GetChild (child_count_t index) const noexcept=0
 Gets the child for the given index. More...
 
virtual bool TestPoint (const Transformation &xf, const Length2D p) const noexcept=0
 Tests a point for containment in this shape. More...
 
virtual RayCastOutput RayCast (const RayCastInput &input, const Transformation &xf, child_count_t childIndex) const noexcept=0
 
virtual MassData GetMassData () const noexcept=0
 Gets the mass properties of this shape using its dimensions and density. More...
 
virtual void Accept (Visitor &visitor) const =0
 Accepts a visitor. More...
 
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...
 

Detailed Description

Shape.

Shape is an abstract base class for shapes. A shape is used for collision detection. You can create a shape however you like. Shapes used for simulation in World are created automatically when a Fixture is created. Shapes may encapsulate one or more child shapes.

Note
This data structure is 32-bytes large (on at least one 64-bit platform).

Constructor & Destructor Documentation

◆ Shape() [1/3]

box2d::Shape::Shape ( )
delete

Default constructor is deleted.

This is a base class that shouldn't ever be directly instantiated.

◆ Shape() [2/3]

box2d::Shape::Shape ( const Conf conf)
inlinenoexcept

Initializing constructor.

Warning
Behavior is undefined if the vertex radius is less than zero.
Behavior is undefined if the density is less than zero.
Behavior is undefined if the friction value is less than zero.

◆ Shape() [3/3]

box2d::Shape::Shape ( const Shape )
default

◆ ~Shape()

virtual box2d::Shape::~Shape ( )
virtualdefault

Member Function Documentation

◆ Accept()

virtual void box2d::Shape::Accept ( Visitor visitor) const
pure virtual

Accepts a visitor.

Implemented in box2d::PolygonShape, box2d::ChainShape, box2d::CircleShape, and box2d::EdgeShape.

◆ GetChild()

virtual DistanceProxy box2d::Shape::GetChild ( child_count_t  index) const
pure virtualnoexcept

Gets the child for the given index.

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

Implemented in box2d::PolygonShape, box2d::ChainShape, box2d::CircleShape, and box2d::EdgeShape.

◆ GetChildCount()

virtual child_count_t box2d::Shape::GetChildCount ( ) const
pure virtualnoexcept

Gets the number of child primitives of the shape.

Returns
Positive non-zero count.

Implemented in box2d::PolygonShape, box2d::ChainShape, box2d::CircleShape, and box2d::EdgeShape.

◆ GetDensity()

Density box2d::Shape::GetDensity ( ) const
inlinenoexcept

Gets the density of this fixture.

Returns
Non-negative density in kg/m^2.

◆ GetFriction()

RealNum box2d::Shape::GetFriction ( ) const
inlinenoexcept

Gets the coefficient of friction.

◆ GetMassData()

virtual MassData box2d::Shape::GetMassData ( ) const
pure virtualnoexcept

Gets the mass properties of this shape using its dimensions and density.

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

Implemented in box2d::PolygonShape, box2d::ChainShape, box2d::CircleShape, and box2d::EdgeShape.

◆ GetRestitution()

RealNum box2d::Shape::GetRestitution ( ) const
inlinenoexcept

Gets the coefficient of restitution.

◆ GetVertexRadius()

Length box2d::Shape::GetVertexRadius ( ) const
inlinenoexcept

Gets the vertex radius.

◆ RayCast()

virtual RayCastOutput box2d::Shape::RayCast ( const RayCastInput input,
const Transformation xf,
child_count_t  childIndex 
) const
pure virtualnoexcept

◆ SetDensity()

void box2d::Shape::SetDensity ( Density  density)
inlinenoexcept

Sets the density of this fixture.

Note
This will not automatically adjust the mass of the body. You must call Body::ResetMassData to update the body's mass.
Warning
Behavior is undefined if given a negative value.
Parameters
densityNon-negative density in kg/m^2.

◆ SetFriction()

void box2d::Shape::SetFriction ( RealNum  friction)
inlinenoexcept

Sets the coefficient of friction. This will not change the friction of existing contacts.

◆ SetRestitution()

void box2d::Shape::SetRestitution ( RealNum  restitution)
inlinenoexcept

Sets the coefficient of restitution. This will not change the restitution of existing contacts.

◆ SetVertexRadius()

void box2d::Shape::SetVertexRadius ( Length  vertexRadius)
inline

◆ TestPoint()

virtual bool box2d::Shape::TestPoint ( const Transformation xf,
const Length2D  p 
) const
pure virtualnoexcept

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.

Implemented in box2d::PolygonShape, box2d::ChainShape, box2d::CircleShape, and box2d::EdgeShape.


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