tile2d
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | Friends | List of all members
Body Class Reference

Extends the functionality of WorldBody to allow for things such as angular velocity. More...

#include <body.hpp>

Inheritance diagram for Body:
WorldBody TileBody< TileType >

Public Member Functions

 Body (uint32_t id, BodyType type)
 constructs a new WorldBody
 
virtual void integrate (Float dt) override
 Integerates this body, meaning the linear velocity and angular velocity will be integrated into the position and rotation of this body.
 
virtual vec2 getWorldPoint (const vec2 &localPoint) const override
 Gets a local position thats within the local space of this body and transforms into the world space.
 
virtual vec2 getLocalPoint (const vec2 &worldPoint) const override
 Gets a world position thats space of this body and transforms into the local space of this body.
 
virtual vec2 getWorldPos () override
 Returns the world position of this body.
 
virtual void setStatic (bool static_) override
 Either make the body static or dynamic.
 
void addAngularVel (const Float &vel)
 Applies an angular velocity to this body.
 
const vec2 & com () const
 Returns the center of mass of this body.
 
const vec2 & centroid () const
 Returns the centroid of this body.
 
Float rotationalInertia () const
 Returns rotational inertia scalar of this body.
 
- Public Member Functions inherited from WorldBody
 WorldBody (uint32_t id, BodyType bodyType)
 constructs a new WorldBody
 
uint32_t id () const
 Returns the id assigned to this body the physics world.
 
BodyType bodyType () const
 Returns the bodyType of this body, see enum BodyType.
 
Transformtransform ()
 Returns the REFERENCE transform of this body.
 
const Transformtransform () const
 Returns the CONST REFERENCE transform of this body.
 
void moveBy (const vec2 &amount)
 Moves the body by amount.
 
void rotateBy (Float amount)
 Rotates the body by amount.
 
void setPos (const vec2 &pos)
 Sets the position of this body to pos.
 
void setRot (Float rot)
 Sets the rotation of this body to rot.
 
bool isStatic () const
 Returns if the body is static, meaning it cannot be moved by forces or other bodies.
 
void addLinearVel (const vec2 &vel)
 applies a linear velocity to this body
 
Float mass () const
 Returns the mass of this body.
 
Float inverseMass () const
 Returns the inverse mass of this body.
 
virtual AABB< Float > getAABB () const =0
 Returns the AABB of this body.
 
AABB< Float > getAABB (const Transform &spaceTransform, const vec2 &localOffset={ Float(0.5f), Float(0.5f) }) const
 
AABB< Float > getAABB (const AABB< Float > &localAABB, const Transform &spaceTransform, const vec2 &localOffset={ Float(0.5f), Float(0.5f) }) const
 

Protected Attributes

Float m_inverseI = 0
 
vec2 m_centroid = { 0.0f, 0.0f }
 
vec2 m_com = { 0.0f, 0.0f }
 
Float m_I = 0.0f
 
vec2 m_unweightedCom = { 0.0f, 0.0f }
 
vec2 m_unweightedCentroid = { 0.0f, 0.0f }
 
vec2 m_force = { 0.0f, 0.0f }
 
Float m_angularVelocity = 0.0f
 
Float m_torque = 0.0f
 
- Protected Attributes inherited from WorldBody
Transform m_transform
 
Float m_mass = 0.0f
 
Float m_inverseMass = 0
 
vec2 m_linearVelocity = { 0.0f, 0.0f }
 
std::bitset< 4 > m_flags
 
BodyType m_bodyType = BodyType::Invalid
 

Friends

class ImpulseMethod
 
template<class TileData >
class World
 

Additional Inherited Members

- Public Types inherited from WorldBody
enum  FlagIndexes { NEEDS_REINSERT = 0 , IS_STATIC = 1 }
 

Detailed Description

Extends the functionality of WorldBody to allow for things such as angular velocity.

Constructor & Destructor Documentation

◆ Body()

Body::Body ( uint32_t id,
BodyType type )
inline

constructs a new WorldBody

Parameters
idThe id assigned by physics world
bodyTypeThe type of body, see enum BodyType. Does not define whether or not the body is static, see setStatic()

Member Function Documentation

◆ addAngularVel()

void Body::addAngularVel ( const Float & vel)
inline

Applies an angular velocity to this body.

Parameters
velThe amount of angular velocity to apply

◆ centroid()

const vec2 & Body::centroid ( ) const
inline

Returns the centroid of this body.

Returns
The centroid of this body

◆ com()

const vec2 & Body::com ( ) const
inline

Returns the center of mass of this body.

Returns
The center of mass of this body

◆ getLocalPoint()

virtual vec2 Body::getLocalPoint ( const vec2 & worldPoint) const
inlineoverridevirtual

Gets a world position thats space of this body and transforms into the local space of this body.

Parameters
worldPointPosition in world pos

Reimplemented from WorldBody.

◆ getWorldPoint()

virtual vec2 Body::getWorldPoint ( const vec2 & localPoint) const
inlineoverridevirtual

Gets a local position thats within the local space of this body and transforms into the world space.

Parameters
localPointPosition in the local space of this body

Reimplemented from WorldBody.

◆ getWorldPos()

virtual vec2 Body::getWorldPos ( )
inlineoverridevirtual

Returns the world position of this body.

Returns
the world position of this body

Reimplemented from WorldBody.

◆ integrate()

virtual void Body::integrate ( Float dt)
inlineoverridevirtual

Integerates this body, meaning the linear velocity and angular velocity will be integrated into the position and rotation of this body.

Parameters
dtThe amount to integrate by; delta time

Implements WorldBody.

Reimplemented in TileBody< TileType >.

◆ rotationalInertia()

Float Body::rotationalInertia ( ) const
inline

Returns rotational inertia scalar of this body.

Returns
The rotational inertia scalar of this body

◆ setStatic()

virtual void Body::setStatic ( bool static_)
inlineoverridevirtual

Either make the body static or dynamic.

Parameters
static_If true the body will be made static. See isStatic(). If false the body will be made dynamic.

Reimplemented from WorldBody.


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