PlayRho  2.0.0
An interactive physics engine & library.
playrho::d2::BodyConf Struct Reference

Configuration for a body. More...

#include <playrho/d2/BodyConf.hpp>

Collaboration diagram for playrho::d2::BodyConf:
[legend]

Public Member Functions

constexpr BodyConfUse (BodyType t) noexcept
 Use the given type.
 
constexpr BodyConfUse (const Position &v) noexcept
 Use the given position for the linear and angular positions.
 
constexpr BodyConfUse (const Sweep &v) noexcept
 Use the given sweep.
 
constexpr BodyConfUse (const Velocity &v) noexcept
 Use the given velocity for the linear and angular velocities.
 
constexpr BodyConfUse (ShapeID v)
 Appends the shape identifier to the collection to attach to the body. More...
 
constexpr BodyConfUse (Span< const ShapeID > v)
 Appends the shape identifiers to the collection to attach to the body. More...
 
constexpr BodyConfUseAllowSleep (bool value) noexcept
 Use the given allow sleep value.
 
constexpr BodyConfUseAngle (Angle a) noexcept
 Use the given angle.
 
constexpr BodyConfUseAngularAcceleration (AngularAcceleration v) noexcept
 Use the given angular acceleration.
 
constexpr BodyConfUseAngularDamping (NonNegative< Frequency > v) noexcept
 Use the given angular damping.
 
constexpr BodyConfUseAngularVelocity (AngularVelocity v) noexcept
 Use the given angular velocity.
 
constexpr BodyConfUseAwake (bool value) noexcept
 Use the given awake value.
 
constexpr BodyConfUseBullet (bool value) noexcept
 Use the given bullet state.
 
constexpr BodyConfUseEnabled (bool value) noexcept
 Use the given enabled state.
 
constexpr BodyConfUseFixedRotation (bool value) noexcept
 Use the given fixed rotation state.
 
constexpr BodyConfUseInvMass (const NonNegative< InvMass > &v) noexcept
 Use the given inverse mass.
 
constexpr BodyConfUseInvRotI (const NonNegative< InvRotInertia > &v) noexcept
 Use the given inverse rotational inertia.
 
constexpr BodyConfUseLinearAcceleration (const LinearAcceleration2 &v) noexcept
 Use the given linear acceleration.
 
constexpr BodyConfUseLinearDamping (NonNegative< Frequency > v) noexcept
 Use the given linear damping.
 
constexpr BodyConfUseLinearVelocity (const LinearVelocity2 &v) noexcept
 Use the given linear velocity.
 
constexpr BodyConfUseLocation (const Length2 &l) noexcept
 Use the given location.
 
constexpr BodyConfUseMassDataDirty (bool v) noexcept
 Use the given mass data dirty state.
 
constexpr BodyConfUseUnderActiveTime (Time v) noexcept
 Use the given under active time.
 

Public Attributes

bool allowSleep = DefaultAllowSleep
 
AngularAcceleration angularAcceleration = DefaultAngularAcceleration
 
NonNegative< FrequencyangularDamping = DefaultAngularDamping
 
AngularVelocity angularVelocity = DefaultAngularVelocity
 The angular velocity of the body.
 
bool awake = DefaultAwake
 Is the body awake or sleeping?
 
bool bullet = DefaultBullet
 
bool enabled = DefaultEnabled
 Whether or not the body is enabled.
 
bool fixedRotation = DefaultFixedRotation
 Should this body be prevented from rotating? Useful for characters.
 
NonNegative< InvMassinvMass = DefaultInvMass
 Inverse mass for the body. More...
 
NonNegative< InvRotInertiainvRotI = DefaultInvRotI
 Inverse rotational inertia for the body. More...
 
LinearAcceleration2 linearAcceleration = DefaultLinearAcceleration
 
NonNegative< FrequencylinearDamping = DefaultLinearDamping
 
LinearVelocity2 linearVelocity = DefaultLinearVelocity
 The linear velocity of the body's origin in world co-ordinates.
 
bool massDataDirty = DefaultMassDataDirty
 Whether mass data is "dirty".
 
ArrayList< ShapeID, MaxShapesshapes
 Shapes to associate a body with.
 
Sweep sweep = DefaultSweep
 The sweep of the body. More...
 
BodyType type = DefaultBodyType
 Type of the body: static, kinematic, or dynamic. More...
 
Time underActiveTime = DefaultUnderActiveTime
 

Static Public Attributes

static constexpr auto DefaultAllowSleep = true
 Default allow sleep.
 
static constexpr auto DefaultAngularAcceleration
 Default angular acceleration. More...
 
static constexpr auto DefaultAngularDamping = NonNegativeFF<Frequency>{0_Hz}
 Default angular damping.
 
static constexpr auto DefaultAngularVelocity = 0_rpm
 Default angular velocity.
 
static constexpr auto DefaultAwake = true
 Default awake value.
 
static constexpr auto DefaultBodyType = BodyType::Static
 Default body type.
 
static constexpr auto DefaultBullet = false
 Default bullet value.
 
static constexpr auto DefaultEnabled = true
 Default enabled value.
 
static constexpr auto DefaultFixedRotation = false
 Default fixed rotation value.
 
static constexpr auto DefaultInvMass
 Default inverse mass. More...
 
static constexpr auto DefaultInvRotI
 Default inverse rotational inertia. More...
 
static constexpr auto DefaultLinearAcceleration = LinearAcceleration2{}
 Default linear acceleration.
 
static constexpr auto DefaultLinearDamping = NonNegativeFF<Frequency>{0_Hz}
 Default linear damping.
 
static constexpr auto DefaultLinearVelocity = LinearVelocity2{}
 Default linear velocity.
 
static constexpr auto DefaultMassDataDirty = true
 Default mass data dirty value.
 
static constexpr auto DefaultSweep = Sweep{}
 Default sweep.
 
static constexpr auto DefaultUnderActiveTime = 0_s
 Default under active time.
 
static constexpr auto MaxShapes = std::size_t(128)
 Max associable shapes.
 

Related Functions

(Note that these are not member functions.)

constexpr auto GetAngle (const BodyConf &conf) noexcept -> Angle
 Gets the angle of the given configuration.
 
constexpr BodyConf GetDefaultBodyConf () noexcept
 Gets the default body definition.
 
constexpr auto GetLocation (const BodyConf &conf) noexcept -> Length2
 Gets the location of the given configuration.
 
constexpr bool operator!= (const BodyConf &lhs, const BodyConf &rhs) noexcept
 Operator not-equals.
 
constexpr bool operator== (const BodyConf &lhs, const BodyConf &rhs) noexcept
 Operator equals.
 

Detailed Description

Configuration for a body.

A body configuration holds all the data needed to construct a rigid body. You can safely re-use body configurations.

Note
Value class meant for passing in for Body construction.
See also
World, Body.
Examples
World.cpp.

Member Function Documentation

◆ Use() [1/2]

constexpr BodyConf & playrho::d2::BodyConf::Use ( ShapeID  v)
constexpr

Appends the shape identifier to the collection to attach to the body.

Exceptions
LengthErrorif operation would exceed MaxShapes. Provides the strong exception guarantee - i.e. state is as it was before this was called.
Postcondition
shapes holds the given value.

◆ Use() [2/2]

constexpr BodyConf & playrho::d2::BodyConf::Use ( Span< const ShapeID v)
constexpr

Appends the shape identifiers to the collection to attach to the body.

Exceptions
LengthErrorif operation would exceed MaxShapes. Provides the strong exception guarantee - i.e. state is as it was before this was called.
Postcondition
shapes holds the given values in the same order as given.

Member Data Documentation

◆ allowSleep

bool playrho::d2::BodyConf::allowSleep = DefaultAllowSleep

Set this flag to false if this body should never fall asleep. Note that this increases CPU usage.

◆ angularAcceleration

AngularAcceleration playrho::d2::BodyConf::angularAcceleration = DefaultAngularAcceleration

Initial angular acceleration of the body.

Note
Usually this should be 0.

◆ angularDamping

NonNegative<Frequency> playrho::d2::BodyConf::angularDamping = DefaultAngularDamping

Angular damping is use to reduce the angular velocity. The damping parameter can be larger than 1 but the damping effect becomes sensitive to the time step when the damping parameter is large.

◆ bullet

bool playrho::d2::BodyConf::bullet = DefaultBullet

Is this a fast moving body that should be prevented from tunneling through other moving bodies? Note that all bodies are prevented from tunneling through kinematic and static bodies. This setting is only considered on dynamic bodies.

Note
Use this flag sparingly since it increases processing time.

◆ DefaultAngularAcceleration

constexpr auto playrho::d2::BodyConf::DefaultAngularAcceleration
staticconstexpr
Initial value:
=
detail::angular_acceleration AngularAcceleration
Angular acceleration quantity.
Definition: Units.hpp:321
constexpr auto RadianPerSquareSecond
Radian per square second unit of angular acceleration.
Definition: Units.hpp:478

Default angular acceleration.

◆ DefaultInvMass

constexpr auto playrho::d2::BodyConf::DefaultInvMass
staticconstexpr
Initial value:
=
NonNegativeFF<InvMass>{Real(1) / Kilogram}
constexpr auto Kilogram
Kilogram unit of mass.
Definition: Units.hpp:437
float Real
Real-number type.
Definition: Real.hpp:69

Default inverse mass.

◆ DefaultInvRotI

constexpr auto playrho::d2::BodyConf::DefaultInvRotI
staticconstexpr
Initial value:
=
NonNegativeFF<InvRotInertia>{}

Default inverse rotational inertia.

◆ invMass

NonNegative<InvMass> playrho::d2::BodyConf::invMass = DefaultInvMass

Inverse mass for the body.

Note
Only applies if type is dynamic.

◆ invRotI

NonNegative<InvRotInertia> playrho::d2::BodyConf::invRotI = DefaultInvRotI

Inverse rotational inertia for the body.

Note
Only applies if type is dynamic.

◆ linearAcceleration

LinearAcceleration2 playrho::d2::BodyConf::linearAcceleration = DefaultLinearAcceleration

Initial linear acceleration of the body.

Note
Usually this should be 0.

◆ linearDamping

NonNegative<Frequency> playrho::d2::BodyConf::linearDamping = DefaultLinearDamping

Linear damping is use to reduce the linear velocity. The damping parameter can be larger than 1 but the damping effect becomes sensitive to the time step when the damping parameter is large.

◆ sweep

Sweep playrho::d2::BodyConf::sweep = DefaultSweep

The sweep of the body.

This establishes a body's location and angle.

Note
Avoid creating bodies at the origin since this can lead to many overlapping shapes.

◆ type

BodyType playrho::d2::BodyConf::type = DefaultBodyType

Type of the body: static, kinematic, or dynamic.

Note
If a dynamic body would have zero mass, the mass is set to one.

Referenced by playrho::d2::Body::GetBodyConf().

◆ underActiveTime

Time playrho::d2::BodyConf::underActiveTime = DefaultUnderActiveTime

Under-active time.

Set this to the value retrieved from Body::GetUnderActiveTime or leave it as 0.


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