tile2d
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
WorldBody Class Referenceabstract

The abstract base class of all Rigid Bodies that defines essential methods and members to be used in t2d::World<> More...

#include <body.hpp>

Inheritance diagram for WorldBody:
Body BulletBody TileBody< TileType >

Public Types

enum  FlagIndexes { NEEDS_REINSERT = 0 , IS_STATIC = 1 }
 

Public Member Functions

 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.
 
virtual void integrate (Float dt)=0
 Integerates this body, meaning the linear velocity and angular velocity will be integrated into the position and rotation of this body.
 
bool isStatic () const
 Returns if the body is static, meaning it cannot be moved by forces or other bodies.
 
virtual void setStatic (bool static_)
 Either make the body static or dynamic.
 
virtual vec2 getWorldPoint (const vec2 &localPoint) const
 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
 Gets a world position thats space of this body and transforms into the local space of this body.
 
virtual vec2 getWorldPos ()
 Returns the world position of this body.
 
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

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

template<class TileData >
class World
 
class ResolveMethods
 

Detailed Description

The abstract base class of all Rigid Bodies that defines essential methods and members to be used in t2d::World<>

Constructor & Destructor Documentation

◆ WorldBody()

WorldBody::WorldBody ( uint32_t id,
BodyType bodyType )
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

◆ addLinearVel()

void WorldBody::addLinearVel ( const vec2 & vel)
inline

applies a linear velocity to this body

Parameters
velThe linear velocity to apply to this body

◆ bodyType()

BodyType WorldBody::bodyType ( ) const
inline

Returns the bodyType of this body, see enum BodyType.

Returns
The bodyType of this body, see enum BodyType

◆ getAABB()

virtual AABB< Float > WorldBody::getAABB ( ) const
pure virtual

Returns the AABB of this body.

Returns
The AABB of this body

Implemented in BulletBody, and TileBody< TileType >.

◆ getLocalPoint()

virtual vec2 WorldBody::getLocalPoint ( const vec2 & worldPoint) const
inlinevirtual

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

Parameters
worldPointPosition in world pos

Reimplemented in Body.

◆ getWorldPoint()

virtual vec2 WorldBody::getWorldPoint ( const vec2 & localPoint) const
inlinevirtual

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 in Body.

◆ getWorldPos()

virtual vec2 WorldBody::getWorldPos ( )
inlinevirtual

Returns the world position of this body.

Returns
the world position of this body

Reimplemented in Body.

◆ id()

uint32_t WorldBody::id ( ) const
inline

Returns the id assigned to this body the physics world.

Returns
The id assigned to this body the physics world

◆ integrate()

virtual void WorldBody::integrate ( Float dt)
pure virtual

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

Implemented in Body, BulletBody, and TileBody< TileType >.

◆ inverseMass()

Float WorldBody::inverseMass ( ) const
inline

Returns the inverse mass of this body.

Returns
The inverse mass of this body

◆ isStatic()

bool WorldBody::isStatic ( ) const
inline

Returns if the body is static, meaning it cannot be moved by forces or other bodies.

Returns
True, if static

◆ mass()

Float WorldBody::mass ( ) const
inline

Returns the mass of this body.

Returns
The mass of this body

◆ moveBy()

void WorldBody::moveBy ( const vec2 & amount)
inline

Moves the body by amount.

Parameters
amountThe amount to move this body by

◆ rotateBy()

void WorldBody::rotateBy ( Float amount)
inline

Rotates the body by amount.

Parameters
amountThe amount to rotate this body by

◆ setPos()

void WorldBody::setPos ( const vec2 & pos)
inline

Sets the position of this body to pos.

Parameters
posThe position to set this body to

◆ setRot()

void WorldBody::setRot ( Float rot)
inline

Sets the rotation of this body to rot.

Parameters
rotThe rotation to set this body to

◆ setStatic()

virtual void WorldBody::setStatic ( bool static_)
inlinevirtual

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 in Body.

◆ transform() [1/2]

Transform & WorldBody::transform ( )
inline

Returns the REFERENCE transform of this body.

Returns
The REFERENCE tranfsorm of this body

◆ transform() [2/2]

const Transform & WorldBody::transform ( ) const
inline

Returns the CONST REFERENCE transform of this body.

Returns
The CONST REFERENCE tranfsorm of this body

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