CollisionInterface Class Reference

#include <collisionInterface.h>

Inheritance diagram for CollisionInterface:
Inheritance graph
[legend]

List of all members.

Public Types

enum  DetectionType { FAST_COLLISION, ALL_COLLISIONS }

Public Member Functions

virtual void activateBody (const Body *body, bool active)=0
 Activates / deactivates a body inside the collision detection system.
virtual void activatePair (const Body *body1, const Body *body2, bool active)=0
 Toggles collision between a particular pair of bodies.
virtual bool addBody (Body *body, bool ExpectEmpty=false)=0
 Add a new body to the collision detection system.
virtual int allCollisions (DetectionType type, CollisionReport *report, const std::vector< Body * > *interestList)=0
virtual int allContacts (CollisionReport *report, double threshold, const std::vector< Body * > *interestList)=0
virtual void bodyRegion (const Body *body, position point, vec3 normal, double radius, Neighborhood *neighborhood)=0
virtual double bodyToBodyDistance (const Body *body1, const Body *body2, position &p1, position &p2)=0
virtual void cloneBody (Body *clone, const Body *original)=0
 CollisionInterface ()
 Initializes the threading mechanism.
virtual int contact (ContactReport *report, double threshold, const Body *body1, const Body *body2)=0
virtual void getBoundingVolumes (const Body *, int, std::vector< BoundingBox > *)
 Returns the bounding box hierarchy at a certin depth for a body.
virtual int getThreadId ()
virtual bool isActive (const Body *body1, const Body *body2=NULL)=0
 Tells us if collisions for a body in general, or a particular pair of bodies, are active.
virtual void newThread ()
virtual double pointToBodyDistance (const Body *body1, position point, position &closestPoint, vec3 &closestNormal)=0
virtual void removeBody (Body *body)=0
 Remove a body from the collision detection system.
virtual void setBodyTransform (Body *body, const transf &t)=0
 Set the position of a body in the collision detection system.
virtual ~CollisionInterface ()
 Stub, does nothing.

Static Public Attributes

static const int CONTACT_DUPLICATE_THRESHOLD = 3.0
 Two contacts that are separated by less than this are considered the same.

Protected Member Functions

void compactContactSet (ContactReport *contacts)
void removeContactDuplicates (ContactReport *contacts, double duplicateThreshold)
 Removes all the duplicate contacts from a contact report.

Static Protected Attributes

static QMutex mMutex
 Mutex for synchronizing access to the threading mechanism.

Private Member Functions

void replaceContactSetWithPerimeter (ContactReport &contactSet)

Private Attributes

QThreadStorage< int * > mThreadIdStorage
 Here we keep the information on what thread we are currently running.

Static Private Attributes

static int mNextThreadId = 1
 The id to be assigned to the next thread who requests one.

Detailed Description

This class provides an interface between the GraspIt core and the collision detection libraries.

Core code should never call collision detection libraries directly, but use this abstract class instead. For any collision detection library you want to use, implement this interface class using that library.

Definition at line 44 of file collisionInterface.h.


Member Enumeration Documentation

FAST_COLLISION is used to ask if any collision exists in the world. ALL_COLLISIONS is used to ask for all the collisions in the world

Enumerator:
FAST_COLLISION 
ALL_COLLISIONS 

Definition at line 99 of file collisionInterface.h.


Constructor & Destructor Documentation

CollisionInterface::CollisionInterface (  ) 

Initializes the threading mechanism.

By definition, any CollisionInterface is created with threadId 0, which is the main thread.

In general, you should not use multiple instances of the CollisionInterface and the one instance should be constructed in the main thread.

Definition at line 50 of file collisionInterface.cpp.

virtual CollisionInterface::~CollisionInterface (  )  [inline, virtual]

Stub, does nothing.

Definition at line 96 of file collisionInterface.h.


Member Function Documentation

virtual void CollisionInterface::activateBody ( const Body body,
bool  active 
) [pure virtual]

Activates / deactivates a body inside the collision detection system.

If a body is deactivated, it is not removed from the system, but it stops producing either collisions or contacts. Can be re-activated any time desired, it is very cheap.

Implemented in GraspitCollision, and PQPCollision.

virtual void CollisionInterface::activatePair ( const Body body1,
const Body body2,
bool  active 
) [pure virtual]

Toggles collision between a particular pair of bodies.

Implemented in GraspitCollision, and PQPCollision.

virtual bool CollisionInterface::addBody ( Body body,
bool  ExpectEmpty = false 
) [pure virtual]

Add a new body to the collision detection system.

Implemented in GraspitCollision, and PQPCollision.

virtual int CollisionInterface::allCollisions ( DetectionType  type,
CollisionReport report,
const std::vector< Body * > *  interestList 
) [pure virtual]

Goes through all the bodies in the world and returns collisions. If type is FAST_COLLISION, returns 1 as soon as any collision is found. If type is ALL_COLLISIONS, returns the total number of collisions in the world.

The list of all colliding bodies is placed in the report.

If an is passed, then it only queries for collisions involving at least one body in the list.

Implemented in GraspitCollision, and PQPCollision.

virtual int CollisionInterface::allContacts ( CollisionReport report,
double  threshold,
const std::vector< Body * > *  interestList 
) [pure virtual]

Finds all the contacts in the world. interestList is used the same way as in allCollisions().

Implemented in GraspitCollision, and PQPCollision.

virtual void CollisionInterface::bodyRegion ( const Body body,
position  point,
vec3  normal,
double  radius,
Neighborhood neighborhood 
) [pure virtual]

Finds the neighborhood of a given point on the surface of a body. Given the point point, it will find all the vertices of the body that are with radius of this point, as long as they belong to triangles that do not have normals pointing in the opposite direction. This is done in order not to return vertices that are on the other side of a thin body.

Assumes both point and normal are in the coordinate frame of body

Implemented in GraspitCollision, and PQPCollision.

virtual double CollisionInterface::bodyToBodyDistance ( const Body body1,
const Body body2,
position p1,
position p2 
) [pure virtual]

Distance between two bodies, or -1 if the bodies interpenetrate. On exit, p1 and p2 are the two points on the bodies that are closest to each other, each in its own body coordinate frame

Implemented in GraspitCollision, and PQPCollision.

virtual void CollisionInterface::cloneBody ( Body clone,
const Body original 
) [pure virtual]

Creates a clone of a body that shares the collision geometry hierarchy but has its own transform and can be moved and queried for collision independently. WARNING: there are still problems with the cloning mechanism. If the original is deleted, ot if its collision structures are changed, the lingering clone is almost certain to cause a crash.

Implemented in GraspitCollision, and PQPCollision.

void CollisionInterface::compactContactSet ( ContactReport contacts  )  [protected]

Finds all the groups of contacts that have the same normal and replaces them with the contacts on the convex hull of the perimeter that they define. According to theory on contact areas, this has no effect on quality metric computations.

Definition at line 75 of file collisionInterface.cpp.

virtual int CollisionInterface::contact ( ContactReport report,
double  threshold,
const Body body1,
const Body body2 
) [pure virtual]

Finds the contacts between two specified bodies

Implemented in GraspitCollision, and PQPCollision.

virtual void CollisionInterface::getBoundingVolumes ( const Body ,
int  ,
std::vector< BoundingBox > *   
) [inline, virtual]

Returns the bounding box hierarchy at a certin depth for a body.

Reimplemented in GraspitCollision, and PQPCollision.

Definition at line 172 of file collisionInterface.h.

int CollisionInterface::getThreadId (  )  [virtual]

Returns the id of this thread. The master (original) thread has ID 0. If threads are not used, this will always return 0

Definition at line 67 of file collisionInterface.cpp.

virtual bool CollisionInterface::isActive ( const Body body1,
const Body body2 = NULL 
) [pure virtual]

Tells us if collisions for a body in general, or a particular pair of bodies, are active.

If body2 is NULL, it returns whether body1 is active in the collision detection system. Otherwise, it returns whether collisions between this particular pair of bodies are active.

Implemented in GraspitCollision, and PQPCollision.

void CollisionInterface::newThread (  )  [virtual]

Informs the collision detection system that this is now a new thread. All bodies or clones added from now on are specific to this thread. Bodies from a given thread can collide ONLY with bodies from the same thread, or with bodies from the master thread, which has ID 0.

Reimplemented in GraspitCollision, and PQPCollision.

Definition at line 57 of file collisionInterface.cpp.

virtual double CollisionInterface::pointToBodyDistance ( const Body body1,
position  point,
position closestPoint,
vec3 closestNormal 
) [pure virtual]

Distance from a point point specified in world coordinates to a body. On exit, closestPoint is the point on the body that is closest to the given point, and closestNormal is the body normal at that point. Both closestPoint and closestNormal are in world coordinates

Implemented in GraspitCollision, and PQPCollision.

virtual void CollisionInterface::removeBody ( Body body  )  [pure virtual]

Remove a body from the collision detection system.

Implemented in GraspitCollision, and PQPCollision.

void CollisionInterface::removeContactDuplicates ( ContactReport contacts,
double  duplicateThreshold 
) [protected]

Removes all the duplicate contacts from a contact report.

Two contacts where both contact points are separated by less than the duplicateThreshold are considered to be the same contact; only on of them is kept. We currently keep the one where the two bodies are closer together.

Do not confuse this duplicateThreshold (usually on the order of millimeters) with the contact threshold (usually 0.1mm).

This is not done when using VCollide, which has a more intelligent method of pruning contacts itself.

Definition at line 254 of file collisionInterface.cpp.

void CollisionInterface::replaceContactSetWithPerimeter ( ContactReport contactSet  )  [private]

Helper function for compactContactSet(). Given a single group of contacts that have the same normal, computed the perimeter that they define and keeps only those contacts that are on the perimeter.

Definition at line 124 of file collisionInterface.cpp.

virtual void CollisionInterface::setBodyTransform ( Body body,
const transf t 
) [pure virtual]

Set the position of a body in the collision detection system.

Implemented in GraspitCollision, and PQPCollision.


Member Data Documentation

Two contacts that are separated by less than this are considered the same.

Do not confuse this with the contact threshold itself, which is usually on the order of 0.1mm. We generally use this one on the order of 3mm. Arguably, there should be a better spot to define this, maybe where the contact threshold itself is defined as well.

Not all implementations of the collision interface use this. Some do a clever removal of contact duplicates themselves and don't need it.

Definition at line 56 of file collisionInterface.h.

QMutex CollisionInterface::mMutex [static, protected]

Mutex for synchronizing access to the threading mechanism.

Definition at line 79 of file collisionInterface.h.

int CollisionInterface::mNextThreadId = 1 [static, private]

The id to be assigned to the next thread who requests one.

Definition at line 87 of file collisionInterface.h.

QThreadStorage<int*> CollisionInterface::mThreadIdStorage [private]

Here we keep the information on what thread we are currently running.

This is used so that bodies in a given thread only collide with bodies from the same thread, or from the master thread (with id=0).

Definition at line 85 of file collisionInterface.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


graspit
Author(s):
autogenerated on Wed Jan 25 11:00:20 2012