TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrains::Math::Unstable::BoundingVolume Class Reference

#include <tbu_bounding_volume.hpp>

Public Member Functions

 BoundingVolume (float radius)
 
 BoundingVolume (float width, float height)
 
 ~BoundingVolume (void)
 
bool IsCircle (void) const
 
bool IsBox (void) const
 
bool CheckCollisionWith (const tbMath::Vector2 &objectPosition, const tbMath::Vector2 &testPoint) const
 
bool CheckCollisionWith (const tbMath::Vector2 &objectPosition, const float objectRotation, const tbMath::Vector2 &testPoint) const
 
bool CheckCollisionWith (const tbMath::Vector2 &objectPosition, const BoundingVolume &testVolume, const tbMath::Vector2 &testVolumePosition) const
 
bool ResolveCollisionWithStatic (tbMath::Vector2 &objectPosition, const BoundingVolume &staticVolume, const tbMath::Vector2 &staticVolumePosition) const
 
float GetRadius (void) const
 
float GetWidth (void) const
 
float GetHeight (void) const
 

Detailed Description

TODO: TurtleBrains: Documentation: Teach the user how to use this.

Constructor & Destructor Documentation

◆ BoundingVolume() [1/2]

TurtleBrains::Math::Unstable::BoundingVolume::BoundingVolume ( float  radius)
explicit

Constructs a Circle shaped bounding volume with the given radius.

Parameters
radiusThe radius of the circle to use for bounding an object, must be greater than 0 or an error will be triggered. The units are technically undetermined but may often correlate with pixels as in with the Entity.

◆ BoundingVolume() [2/2]

TurtleBrains::Math::Unstable::BoundingVolume::BoundingVolume ( float  width,
float  height 
)
explicit

Constructs a Box shaped bounding volume with the given width and height.

Parameters
widthThe horizontal width of the objects bounding box, must be greater than 0 or an error will be triggered. The units are technically undetermined but may often correlate with pixels as in with the Entity.
heightThe vertical height of the objects bounding box, , must be greater than 0 or an error will be triggered. The units are technically undetermined but may often correlate with pixels as in with the Entity.

◆ ~BoundingVolume()

TurtleBrains::Math::Unstable::BoundingVolume::~BoundingVolume ( void  )

Destructs a BoundingVolume object which currently (TurtleBrains v0.2.0) does not have any resources to clean up after.

Member Function Documentation

◆ CheckCollisionWith() [1/2]

bool TurtleBrains::Math::Unstable::BoundingVolume::CheckCollisionWith ( const tbMath::Vector2 objectPosition,
const BoundingVolume testVolume,
const tbMath::Vector2 testVolumePosition 
) const

Checks to see if two bounding volumes are colliding and returns true if the volumes are intersecting, or false if there is no parts intersecting.

Parameters
objectPositionThe position of this bounding volume to check the collision with the other volume.
testVolumeThe other bounding volume to check if any parts are intersecting with this volume.
testVolumePositionThe position of the other bounding volume to check for intersection.

◆ CheckCollisionWith() [2/2]

bool TurtleBrains::Math::Unstable::BoundingVolume::CheckCollisionWith ( const tbMath::Vector2 objectPosition,
const tbMath::Vector2 testPoint 
) const

Checks to see if a point exists in the bounding volume and returns true if the testPoint is found inside the bounding volume, or false if outside.

Parameters
objectPositionThe position of this bounding volume to check the collision with the testPoint.
testPointA single point to check if the position is located within this bounding volume.

◆ GetHeight()

float TurtleBrains::Math::Unstable::BoundingVolume::GetHeight ( void  ) const
inline

Returns the height of a box bounding volume. This will trigger an error condition if the bounding volume is not a box.

◆ GetRadius()

float TurtleBrains::Math::Unstable::BoundingVolume::GetRadius ( void  ) const
inline

Returns the radius of a circular bounding volume. This will trigger an error condition if the bounding volume is not a circle.

◆ GetWidth()

float TurtleBrains::Math::Unstable::BoundingVolume::GetWidth ( void  ) const
inline

Returns the width of a box bounding volume. This will trigger an error condition if the bounding volume is not a box.

◆ IsBox()

bool TurtleBrains::Math::Unstable::BoundingVolume::IsBox ( void  ) const

Returns true if this BoundingVolume is a bounding box, otherwise false is returned.

◆ IsCircle()

bool TurtleBrains::Math::Unstable::BoundingVolume::IsCircle ( void  ) const

Returns true if this BoundingVolume is a bounding circle, otherwise false is returned.

◆ ResolveCollisionWithStatic()

bool TurtleBrains::Math::Unstable::BoundingVolume::ResolveCollisionWithStatic ( tbMath::Vector2 objectPosition,
const BoundingVolume staticVolume,
const tbMath::Vector2 staticVolumePosition 
) const

Attempts to move objectPosition so this bounding volume won't collide with the staticVolume at staticVolumePosition. Currently only works with two box volumes, other volumes will return false. The oobjectPosition will move along the axis with least penetration.

Parameters
objectPositionThe position of this bounding volume to resolve the collision with. It is expected that the collision has already been checked and is in an intersected state with staticVolume. This parameter will be modified internally and returned as the new position of the bounding volume.
staticVolumeThe other bounding volume to resolve collision against, which does NOT move.
staticVolumePositionThe position of the other bounding volume.
Note
This implementation is still very unstable and incomplete. Both bounding volumes must be a box.