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
00105 virtual bool updateBodyGeometry(Body* body, bool ExpectEmpty = false) = 0;
00107 virtual void removeBody(Body *body) = 0;
00114 virtual void cloneBody(Body *clone, const Body *original) = 0;
00116 virtual void setBodyTransform(Body *body, const transf &t) = 0;
00117
00119
00123 virtual void activateBody(const Body *body, bool active) = 0;
00125 virtual void activatePair(const Body *body1, const Body *body2, bool active) = 0;
00127
00131 virtual bool isActive(const Body *body1, const Body *body2 = NULL) = 0;
00132
00141 virtual int allCollisions(DetectionType type, CollisionReport *report,
00142 const std::vector<Body*> *interestList) = 0;
00143
00146 virtual int allContacts(CollisionReport *report, double threshold,
00147 const std::vector<Body*> *interestList) = 0;
00149 virtual int contact(ContactReport *report, double threshold,
00150 const Body *body1, const Body *body2) = 0;
00151
00156 virtual double pointToBodyDistance(const Body *body1, position point,
00157 position &closestPoint, vec3 &closestNormal) = 0;
00161 virtual double bodyToBodyDistance(const Body *body1, const Body *body2,
00162 position &p1, position &p2) = 0;
00163
00171 virtual void bodyRegion(const Body *body, position point, vec3 normal,
00172 double radius, Neighborhood *neighborhood)=0;
00173
00175 virtual void getBoundingVolumes(const Body*, int, std::vector<BoundingBox>*){}
00176
00181 virtual void newThread();
00184 virtual int getThreadId();
00185 };
00186
00187 #endif