SuperTuxKart
Loading...
Searching...
No Matches
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'.
 
bool operator== (const CollisionPair &p) const
 Tests if two collision pairs involve the same objects.
 
const UserPointergetUserPointer (unsigned int n) const
 
const Vec3getContactPointCS (unsigned int n) const
 Returns the contact point of the collision in car (local) coordinates.
 

Private Attributes

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

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

◆ operator==()

bool Physics::CollisionPair::operator== ( const CollisionPair p) const
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.


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