22 #ifndef __ND_CONTACT_SOLVER_H__
23 #define __ND_CONTACT_SOLVER_H__
25 #include "ndCollisionStdafx.h"
27 #include "ndShapeInstance.h"
43 } D_GCC_NEWTON_ALIGN_32 ;
45 #define D_SEPARATION_PLANES_ITERATIONS 8
46 #define D_CONVEX_MINK_STACK_SIZE 64
47 #define D_CONNICS_CONTATS_ITERATIONS 32
48 #define D_CONVEX_MINK_MAX_FACES 512
49 #define D_CONVEX_MINK_MAX_POINTS 256
50 #define D_MAX_EDGE_COUNT 2048
51 #define D_PENETRATION_TOL ndFloat32 (1.0f / 1024.0f)
52 #define D_MINK_VERTEX_ERR ndFloat32 (1.0e-3f)
53 #define D_MINK_VERTEX_ERR2 (D_MINK_VERTEX_ERR * D_MINK_VERTEX_ERR)
56 class dCollisionParamProxy;
67 D_COLLISION_API
void CalculateContacts(
77 ndInt32 CalculateContactsDiscrete();
78 ndInt32 CalculateContactsContinue();
81 ndInt32 ConvexContactsDiscrete();
82 ndInt32 CompoundContactsDiscrete();
83 ndInt32 ConvexToConvexContactsDiscrete();
84 ndInt32 CompoundToStaticProceduralMesh();
85 ndInt32 ConvexToCompoundContactsDiscrete();
86 ndInt32 CompoundToConvexContactsDiscrete();
87 ndInt32 CompoundToCompoundContactsDiscrete();
88 ndInt32 ConvexToStaticMeshContactsDiscrete();
89 ndInt32 CompoundToShapeStaticBvhContactsDiscrete();
90 ndInt32 CompoundToStaticHeightfieldContactsDiscrete();
94 ndInt32 ConvexContactsContinue();
95 ndInt32 CompoundContactsContinue();
96 ndInt32 ConvexToConvexContactsContinue();
97 ndInt32 ConvexToCompoundContactsContinue();
98 ndInt32 ConvexToStaticMeshContactsContinue();
101 class dgPerimenterEdge
105 dgPerimenterEdge* m_next;
106 dgPerimenterEdge* m_prev;
112 dgFaceFreeList* m_next;
117 inline void DeleteFace(
ndMinkFace*
const face);
118 inline ndMinkFace* AddFace(ndInt32 v0, ndInt32 v1, ndInt32 v2);
120 bool CalculateClosestPoints();
121 ndInt32 CalculateClosestSimplex();
123 ndInt32 CalculateIntersectingPlane(ndInt32 count);
124 ndInt32 PruneContacts(ndInt32 count, ndInt32 maxCount)
const;
125 ndInt32 PruneSupport(ndInt32 count,
const ndVector& dir,
const ndVector*
const points)
const;
127 ndInt32 Prune2dContacts(
const ndMatrix& matrix, ndInt32 count,
ndContactPoint*
const contactArray, ndInt32 maxCount)
const;
128 ndInt32 Prune3dContacts(
const ndMatrix& matrix, ndInt32 count,
ndContactPoint*
const contactArray, ndInt32 maxCount)
const;
129 ndInt32 ConvexPolygonsIntersection(
const ndVector& normal, ndInt32 count1,
ndVector*
const shape1, ndInt32 count2,
ndVector*
const shape2,
ndVector*
const contactOut, ndInt32 maxContacts)
const;
130 ndInt32 ConvexPolygonToLineIntersection(
const ndVector& normal, ndInt32 count1,
ndVector*
const shape1, ndInt32 count2,
ndVector*
const shape2,
ndVector*
const contactOut,
ndVector*
const mem)
const;
135 void SupportVertex(
const ndVector& dir, ndInt32 vertexIndex);
137 void TranslateSimplex(
const ndVector& step);
138 void CalculateContactFromFeacture(ndInt32 featureType);
147 ndVector m_buffer[2 * D_CONVEX_MINK_MAX_POINTS];
150 ndVector m_hullDiff[D_CONVEX_MINK_MAX_POINTS];
151 ndVector m_hullSum[D_CONVEX_MINK_MAX_POINTS];
156 dgFaceFreeList* m_freeFace;
159 ndFloat32 m_timestep;
160 ndFloat32 m_skinMargin;
161 ndFloat32 m_separationDistance;
166 ndInt32 m_vertexIndex;
167 ndUnsigned32 m_pruneContacts : 1;
168 ndUnsigned32 m_intersectionTestOnly : 1;
170 ndMinkFace* m_faceStack[D_CONVEX_MINK_STACK_SIZE];
171 ndMinkFace* m_coneFaceList[D_CONVEX_MINK_STACK_SIZE];
172 ndMinkFace* m_deletedFaceList[D_CONVEX_MINK_STACK_SIZE];
173 ndMinkFace m_facePool[D_CONVEX_MINK_MAX_FACES];
174 ndInt8 m_heapBuffer[D_CONVEX_MINK_MAX_FACES * (
sizeof (ndFloat32) +
sizeof (
ndMinkFace *))];
180 static ndInt32 m_rayCastSimplex[4][4];
189 } D_GCC_NEWTON_ALIGN_32;