22 #if !defined(__DGCOLLISIONPOLYGONALSOUP_H__) 23 #define __DGCOLLISIONPOLYGONALSOUP_H__ 26 #include "dgCollision.h" 27 #include "dgCollisionConvex.h" 29 #define DG_MAX_COLLIDING_FACES (1024 * 2) 30 #define DG_MAX_COLLIDING_VERTEX (DG_MAX_COLLIDING_FACES * 4) 34 typedef void (*dgCollisionMeshCollisionCallback)(
const dgBody *bodyWithTreeCollision,
const dgBody *
const body, dgInt32 faceID,
35 dgInt32 vertexCount,
const dgFloat32 *vertex, dgInt32 vertexStrideInBytes);
38 DG_MSC_VECTOR_ALIGMENT
44 dgInt32 m_threadNumber;
46 dgInt32 m_vertexStrideInBytes;
49 dgInt32 *m_userAttribute;
50 dgInt32 *m_faceIndexCount;
51 dgInt32 *m_faceVertexIndex;
54 dgFloat32 *m_faceMaxSize;
58 dgInt32 *m_faceNormalIndex;
59 dgInt32 *m_faceAdjencentEdgeNormal;
61 dgInt32 m_globalIndexCount;
62 dgInt32 m_globalUserAttribute[DG_MAX_COLLIDING_FACES];
63 dgInt32 m_globalFaceIndexCount[DG_MAX_COLLIDING_FACES];
64 dgInt32 m_globalFaceNormalIndex[DG_MAX_COLLIDING_FACES];
65 dgFloat32 m_globalFaceMaxSize[DG_MAX_COLLIDING_FACES];
66 dgInt32 m_globalFaceVertexIndex[DG_MAX_COLLIDING_VERTEX];
67 dgInt32 m_globalAdjencentEdgeNormal[DG_MAX_COLLIDING_VERTEX];
70 } DG_GCC_VECTOR_ALIGMENT;
72 DG_MSC_VECTOR_ALIGMENT
76 : m_matrix(dgGetIdentityMatrix()) {
82 dgUnsigned32 m_userId;
84 void *m_altenateUserData;
86 } DG_GCC_VECTOR_ALIGMENT;
96 dgInt32 m_incidentNormal;
97 dgInt32 m_incidentVertex;
100 DG_MSC_VECTOR_ALIGMENT
103 dgInt32 *m_indexList;
104 dgInt32 *m_userDataList;
105 dgFloat32 *m_veterxArray;
106 dgInt32 m_triangleCount;
107 dgInt32 m_maxIndexCount;
108 dgInt32 m_vertexCount;
109 dgInt32 m_vertexStrideInBytes;
110 } DG_GCC_VECTOR_ALIGMENT;
112 DG_MSC_VECTOR_ALIGMENT
118 virtual dgInt32 CalculateSignature()
const;
119 virtual void Serialize(dgSerialize callback,
void *
const userData)
const;
121 virtual dgFloat32 RayCast(
const dgVector &localP0,
const dgVector &localP1,
dgContactPoint &contactOut, OnRayPrecastAction preFilter,
const dgBody *
const body,
void *
const userData)
const;
127 virtual dgInt32 CalculatePlaneIntersection(
const dgVector &normal,
const dgVector &point,
dgVector *
const contactsOut)
const;
128 virtual dgInt32 CalculatePlaneIntersectionSimd(
const dgVector &normal,
const dgVector &point,
dgVector *
const contactsOut)
const;
130 virtual dgFloat32 GetVolume()
const;
131 virtual dgFloat32 GetBoxMinRadius()
const;
132 virtual dgFloat32 GetBoxMaxRadius()
const;
134 virtual bool IsEdgeIntersection()
const;
142 dgInt32 ClipContacts(dgInt32 count,
dgContactPoint *
const contactOut,
const dgMatrix &globalMatrix)
const;
145 bool PointToPolygonDistance(
const dgVector &point, dgFloat32 radius,
dgVector &out,
bool &isEdge);
150 void CalculateNormal();
151 void CalculateNormalSimd();
155 dgVector m_localPolySimd[64 * 3 / 4];
156 dgInt32 m_clippEdgeNormal[64];
158 dgInt32 m_paddedCount;
159 dgInt32 m_normalIndex;
162 dgInt32 *m_adjacentNormalIndex;
164 mutable dgInt32 m_isEdgeIntersection;
166 } DG_GCC_VECTOR_ALIGMENT;
172 void SetCollisionCallback(dgCollisionMeshCollisionCallback debugCallback);
176 virtual void *GetUserData()
const;
177 virtual dgFloat32 GetVolume()
const;
178 virtual dgFloat32 GetBoxMinRadius()
const;
179 virtual dgFloat32 GetBoxMaxRadius()
const;
186 dgCollisionMeshCollisionCallback GetDebugCollisionCallback()
const {
187 return m_debugCallback;
195 virtual dgInt32 CalculateSignature()
const;
202 virtual void DebugCollision(
const dgMatrix &matrix, OnDebugCollisionMeshCallback callback,
void *
const userData)
const;
204 virtual dgVector CalculateVolumeIntegral(
const dgMatrix &globalMatrix, GetBuoyancyPlane bouyancyPlane,
void *
const context)
const;
205 virtual dgFloat32 RayCast(
const dgVector &localP0,
const dgVector &localP1,
dgContactPoint &contactOut, OnRayPrecastAction preFilter,
const dgBody *
const body,
void *
const userData)
const = 0;
206 virtual dgFloat32 RayCastSimd(
const dgVector &localP0,
const dgVector &localP1,
dgContactPoint &contactOut, OnRayPrecastAction preFilter,
const dgBody *
const body,
void *
const userData)
const = 0;
208 dgInt32 CalculatePlaneIntersection(
const dgFloat32 *vertex,
const dgInt32 *index, dgInt32 indexCount, dgInt32 strideInFloat,
213 virtual void Serialize(dgSerialize callback,
void *
const userData)
const;
224 dgCollisionMeshCollisionCallback m_debugCallback;
Definition: dgCollision.h:73
Definition: dgCollisionMesh.h:39
Definition: dgVector.h:86
Definition: dgCollisionMesh.h:92
Graphics::Surface * scale(const Graphics::Surface &srcImage, int xSize, int ySize)
Definition: dgCollisionMesh.h:73
Definition: dgCollisionMesh.h:101
Definition: dgCollisionMesh.h:90
Definition: dgCollisionConvex.h:39
Definition: dgCollisionMesh.h:113
Definition: dgCollision.h:178
Definition: dgMatrix.h:41
Definition: dgMemory.h:80
Definition: dgWorld.h:118