SuperTuxKart
Public Member Functions | Private Attributes | List of all members
Physics::CollisionPair Class Reference

Bullet can report the same collision more than once (up to 4 contact points per collision. More...

Public Member Functions

 CollisionPair (const UserPointer *a, const btVector3 &contact_point_a, const UserPointer *b, const btVector3 &contact_point_b)
 The entries in Collision Pairs are sorted: if a projectile is included, it's always 'a'. More...
 
bool operator== (const CollisionPair &p)
 Tests if two collision pairs involve the same objects. More...
 
const UserPointergetUserPointer (unsigned int n) const
 
const Vec3getContactPointCS (unsigned int n) const
 Returns the contact point of the collision in car (local) coordinates. More...
 

Private Attributes

const UserPointerm_up [2]
 The user pointer of the objects involved in this collision. More...
 
Vec3 m_contact_point [2]
 The contact point for each object (in local coordincates). More...
 

Detailed Description

Bullet can report the same collision more than once (up to 4 contact points per collision.

Additionally, more than one internal substep might be taken, resulting in potentially even more duplicates. To handle this, all collisions (i.e. pair of objects) are stored in a vector, but only one entry per collision pair of objects. While this is a natural application of std::set, the set has some overhead (since it will likely use a tree to sort the entries). Considering that the number of collisions is usually rather small a simple list and linear search is faster is is being used here.

Constructor & Destructor Documentation

◆ CollisionPair()

Physics::CollisionPair::CollisionPair ( const UserPointer a,
const btVector3 &  contact_point_a,
const UserPointer b,
const btVector3 &  contact_point_b 
)
inline

The entries in Collision Pairs are sorted: if a projectile is included, it's always 'a'.

If only two karts are reported the first kart pointer is the smaller one.

Member Function Documentation

◆ getContactPointCS()

const Vec3& Physics::CollisionPair::getContactPointCS ( unsigned int  n) const
inline

Returns the contact point of the collision in car (local) coordinates.

◆ operator==()

bool Physics::CollisionPair::operator== ( const CollisionPair p)
inline

Tests if two collision pairs involve the same objects.

This test is simplified (i.e. no test if p.b==a and p.a==b) since the elements are sorted.

Member Data Documentation

◆ m_contact_point

Vec3 Physics::CollisionPair::m_contact_point[2]
private

The contact point for each object (in local coordincates).

◆ m_up

const UserPointer* Physics::CollisionPair::m_up[2]
private

The user pointer of the objects involved in this collision.


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