FYP  1.0.0
Final Year Project -- Alexander Meuer
collision::Collidable Class Reference
Inheritance diagram for collision::Collidable:
Inheritance graph
Collaboration diagram for collision::Collidable:
Collaboration graph

Public Member Functions

 Collidable (sf::Shape *mask, sf::Vector2f offset)
 
 Collidable (Collidable const &other)
 
 Collidable (tinyxml2::XMLElement *xml)
 Constructs a Collidable from an xml tag. Tag requires pointCoint and type attributes in addition to child tags depending on type specified. More...
 
const sf::Shape * getMask () const
 
void setMask (sf::Shape *mask, sf::Vector2f offset)
 
virtual void onCollide (std::shared_ptr< Collidable > &other, sf::Vector2f const &mtv)
 Called when we collide with something.
 
void setDebugColour (sf::Color const &c)
 
void debug_draw (sf::RenderTarget &target)
 
void getAxies (std::vector< sf::Vector2f > &axiesVector)
 Gets all axies of the mask. Gets all axies of the mask. Currently inefficient due to the fact that it iterates over all points and returns all axies (a duplicate of each axis is included!). More...
 
size_t getPointCount () const
 Gets the number of points in the mask. Calls mask->getPoint() and returns the result.
 
sf::Vector2f projectOntoAxis (sf::Vector2f &axis) const
 Projects the mask onto an axis. Projects each point of the mask onto an axis and returns the min and max points it covers on that axis. More...
 

Protected Member Functions

void updateCollidableMask (sf::Vector2f const &newPosition)
 Updates the position of the mask. Updates the position of the mask to equal newPosition plus the offset. More...
 

Private Attributes

sf::Shape * mMask
 
sf::Vector2f mOffset
 

Constructor & Destructor Documentation

collision::Collidable::Collidable ( tinyxml2::XMLElement *  xml)

Constructs a Collidable from an xml tag. Tag requires pointCoint and type attributes in addition to child tags depending on type specified.

Remarks
<Offset> tag is optional.
Valid types are "Circle" and "Convex" and correspond to the respective sf::Shape derivative.
Parameters
xmlTag in the form <Collidable pointcount="???" type="???">

Member Function Documentation

void collision::Collidable::getAxies ( std::vector< sf::Vector2f > &  axiesVector)

Gets all axies of the mask. Gets all axies of the mask. Currently inefficient due to the fact that it iterates over all points and returns all axies (a duplicate of each axis is included!).

Parameters
axisVector[in,out]The container of axies to add our axies to.
sf::Vector2f collision::Collidable::projectOntoAxis ( sf::Vector2f &  axis) const

Projects the mask onto an axis. Projects each point of the mask onto an axis and returns the min and max points it covers on that axis.

Remarks
May try to normalize zero length vectors.
Parameters
axisThe axis to project onto.
Returns
The shadow of the mask along the axis. i.e. The min and max points it touches on the axis.
void collision::Collidable::updateCollidableMask ( sf::Vector2f const &  newPosition)
protected

Updates the position of the mask. Updates the position of the mask to equal newPosition plus the offset.

Parameters
Thenew position of the mask, before offset is taken into account.

Member Data Documentation

sf::Shape* collision::Collidable::mMask
private

The shape that is used to test collision.


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