00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef _collisioninterface_h_
00027 #define _collisioninterface_h_
00028
00029 #include "collisionStructures.h"
00030
00031 #include <QMutex>
00032 #include <QThreadStorage>
00033
00034 class BoundingBox;
00035
00044 class CollisionInterface
00045 {
00046 public:
00048
00056 static const int CONTACT_DUPLICATE_THRESHOLD;
00057 protected:
00058
00059
00063 void compactContactSet(ContactReport *contacts);
00064
00066
00077 void removeContactDuplicates(ContactReport *contacts, double duplicateThreshold);
00079 static QMutex mMutex;
00080 private:
00082
00085 QThreadStorage<int*> mThreadIdStorage;
00087 static int mNextThreadId;
00091 void replaceContactSetWithPerimeter(ContactReport &contactSet);
00092 public:
00094 CollisionInterface();
00096 virtual ~CollisionInterface(){}
00099 enum DetectionType{FAST_COLLISION, ALL_COLLISIONS};
00100
00102 virtual bool addBody(Body *body, bool ExpectEmpty = false) = 0;
00104 virtual void removeBody(Body *body) = 0;
00111 virtual void cloneBody(Body *clone, const Body *original) = 0;
00113 virtual void setBodyTransform(Body *body, const transf &t) = 0;
00114
00116
00120 virtual void activateBody(const Body *body, bool active) = 0;
00122 virtual void activatePair(const Body *body1, const Body *body2, bool active) = 0;
00124
00128 virtual bool isActive(const Body *body1, const Body *body2 = NULL) = 0;
00129
00138 virtual int allCollisions(DetectionType type, CollisionReport *report,
00139 const std::vector<Body*> *interestList) = 0;
00140
00143 virtual int allContacts(CollisionReport *report, double threshold,
00144 const std::vector<Body*> *interestList) = 0;
00146 virtual int contact(ContactReport *report, double threshold,
00147 const Body *body1, const Body *body2) = 0;
00148
00153 virtual double pointToBodyDistance(const Body *body1, position point,
00154 position &closestPoint, vec3 &closestNormal) = 0;
00158 virtual double bodyToBodyDistance(const Body *body1, const Body *body2,
00159 position &p1, position &p2) = 0;
00160
00168 virtual void bodyRegion(const Body *body, position point, vec3 normal,
00169 double radius, Neighborhood *neighborhood)=0;
00170
00172 virtual void getBoundingVolumes(const Body*, int, std::vector<BoundingBox>*){}
00173
00178 virtual void newThread();
00181 virtual int getThreadId();
00182 };
00183
00184 #endif