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
00027
00028
00029
00030 #ifndef GU_CONTACTBUFFER_H
00031 #define GU_CONTACTBUFFER_H
00032
00033 #include "PxPhysXConfig.h"
00034 #include "PxContact.h"
00035 #include "GuContactPoint.h"
00036
00037 namespace physx
00038 {
00039 namespace Gu
00040 {
00041
00042 struct NarrowPhaseParams
00043 {
00044 PX_FORCE_INLINE NarrowPhaseParams(PxReal contactDistance, PxReal meshContactMargin, PxReal toleranceLength) :
00045 mContactDistance(contactDistance),
00046 mMeshContactMargin(meshContactMargin),
00047 mToleranceLength(toleranceLength) {}
00048
00049 PxReal mContactDistance;
00050 PxReal mMeshContactMargin;
00051 PxReal mToleranceLength;
00052 };
00053
00054
00055 #define LOCAL_CONTACTS_SIZE 1088
00056
00057 class ContactBuffer
00058 {
00059 public:
00060
00061 static const PxU32 MAX_CONTACTS = 64;
00062
00063 Gu::ContactPoint contacts[MAX_CONTACTS];
00064 PxU32 count;
00065 PxU32 pad;
00066
00067 PX_FORCE_INLINE void reset()
00068 {
00069 count = 0;
00070 }
00071
00072 PX_FORCE_INLINE bool contact(const PxVec3& worldPoint,
00073 const PxVec3& worldNormalIn,
00074 PxReal separation,
00075 PxU32 faceIndex1 = PXC_CONTACT_NO_FACE_INDEX
00076 )
00077 {
00078 PX_ASSERT(PxAbs(worldNormalIn.magnitude()-1)<1e-3f);
00079
00080 if(count>=MAX_CONTACTS)
00081 return false;
00082
00083 Gu::ContactPoint& p = contacts[count++];
00084 p.normal = worldNormalIn;
00085 p.point = worldPoint;
00086 p.separation = separation;
00087 p.internalFaceIndex1= faceIndex1;
00088 return true;
00089 }
00090
00091 PX_FORCE_INLINE bool contact(const PxVec3& worldPoint,
00092 const PxVec3& worldNormalIn,
00093 PxReal separation,
00094 PxU16 internalUsage,
00095 PxU32 faceIndex1 = PXC_CONTACT_NO_FACE_INDEX
00096 )
00097 {
00098 PX_ASSERT(PxAbs(worldNormalIn.magnitude() - 1)<1e-3f);
00099
00100 if (count >= MAX_CONTACTS)
00101 return false;
00102
00103 Gu::ContactPoint& p = contacts[count++];
00104 p.normal = worldNormalIn;
00105 p.point = worldPoint;
00106 p.separation = separation;
00107 p.internalFaceIndex1 = faceIndex1;
00108 p.forInternalUse = internalUsage;
00109 return true;
00110 }
00111
00112 PX_FORCE_INLINE bool contact(const Gu::ContactPoint & pt)
00113 {
00114 if(count>=MAX_CONTACTS)
00115 return false;
00116 contacts[count++] = pt;
00117 return true;
00118 }
00119
00120 PX_FORCE_INLINE Gu::ContactPoint* contact()
00121 {
00122 if(count>=MAX_CONTACTS)
00123 return NULL;
00124 return &contacts[count++];
00125 }
00126 };
00127
00128 }
00129 }
00130
00131 #endif