17 #ifndef AGX_PHYSICS_HIERARCHICALGRID_BOXBOXOVERLAP_TEST_H 18 #define AGX_PHYSICS_HIERARCHICALGRID_BOXBOXOVERLAP_TEST_H 44 const int i,
const int iIncr1,
const int iIncr2,
45 const int j,
const int jIncr1,
const int jIncr2,
48 const agx::Real length2 = trans2To1Abs(j,iIncr1) * trans2To1Abs(j,iIncr1) + trans2To1Abs(j,iIncr2) * trans2To1Abs(j,iIncr2);
54 depth = (he1[iIncr1] * trans2To1Abs(j, iIncr2) + he1[iIncr2] * trans2To1Abs(j, iIncr1) +
55 he2[jIncr1] * trans2To1Abs(jIncr2, i) + he2[jIncr2] * trans2To1Abs(jIncr1, i) -
56 std::abs( midP2In1[iIncr2] * trans2To1(j, iIncr1) - midP2In1[iIncr1] * trans2To1(j, iIncr2)) );
64 const int i,
const int iIncr1,
const int iIncr2,
const int j,
69 const agx::Real length2 = trans2To1(j, iIncr1) * trans2To1(j, iIncr1) + trans2To1(j, iIncr2) * trans2To1(j, iIncr2);
71 if (depth * depth < minDepth * minDepth * length2) {
72 const int dim = 3 * i + j;
73 minDepth = depth / std::sqrt(length2);
82 bool boxBoxOverlapTest
94 for (
int i = 0; i < 3; ++i)
95 for (
int j = 0; j < 3; ++j)
96 trans2To1Abs( i, j ) = std::abs( trans2To1Abs( i, j ) );
109 for (
unsigned i = 0; i < 3; ++i) {
110 const agx::Real depth = he1[i] + he2 *
agx::Vec3( trans2To1Abs( 0, i ), trans2To1Abs( 1, i ), trans2To1Abs( 2, i )) - std::abs( midP2In1[i] );
126 int numParallels = 0;
128 for (
int i = 0; i < 3; ++i) {
130 for (
int j = 0; j < 3; ++j) {
131 length2[0] += trans2To1(i, j) * trans2To1(i, j);
132 length2[1] += trans2To1(j, i) * trans2To1(j, i);
134 for (
int j = 0; j < 2; ++j) {
135 if (std::abs(length2[j] - 1) > maxRotError2)
136 maxRotError2 = std::abs(length2[j] - 1);
141 if (maxRotError2 > rotationError)
142 rotationError = std::sqrt( maxRotError2 );
143 for (
int i = 0; i < 3; ++i) {
144 if (trans2To1Abs( i, i ) > 1.0 - 0.0001 + rotationError) {
155 if (numParallels < 2) {
157 for (
unsigned i = 0; i < 3; ++i) {
158 const agx::Real depth = he2[i] + he1 *
agx::Vec3( trans2To1Abs( i, 0 ), trans2To1Abs( i, 1 ), trans2To1Abs( i, 2 )) - std::abs( midP1In2[i] );
165 for (
unsigned int i = 0; i < depthsFace.
size(); ++i) {
166 if (depthsFace[i] < minDepth) {
167 minDepth = depthsFace[i];
175 if (numParallels < 1) {
180 bool testEdges =
true;
185 if (!calculateDepthEdgeProv( he1, he2, trans2To1Abs, trans2To1, midP2In1, 0, 1, 2, 0, 1, 2, testEdges, depths[0][0] ))
return false;
186 if (!calculateDepthEdgeProv( he1, he2, trans2To1Abs, trans2To1, midP2In1, 0, 1, 2, 1, 2, 0, testEdges, depths[0][1] ))
return false;
187 if (!calculateDepthEdgeProv( he1, he2, trans2To1Abs, trans2To1, midP2In1, 0, 1, 2, 2, 0, 1, testEdges, depths[0][2] ))
return false;
188 if (!calculateDepthEdgeProv( he1, he2, trans2To1Abs, trans2To1, midP2In1, 1, 2, 0, 0, 1, 2, testEdges, depths[1][0] ))
return false;
189 if (!calculateDepthEdgeProv( he1, he2, trans2To1Abs, trans2To1, midP2In1, 1, 2, 0, 1, 2, 0, testEdges, depths[1][1] ))
return false;
190 if (!calculateDepthEdgeProv( he1, he2, trans2To1Abs, trans2To1, midP2In1, 1, 2, 0, 2, 0, 1, testEdges, depths[1][2] ))
return false;
191 if (!calculateDepthEdgeProv( he1, he2, trans2To1Abs, trans2To1, midP2In1, 2, 0, 1, 0, 1, 2, testEdges, depths[2][0] ))
return false;
192 if (!calculateDepthEdgeProv( he1, he2, trans2To1Abs, trans2To1, midP2In1, 2, 0, 1, 1, 2, 0, testEdges, depths[2][1] ))
return false;
193 if (!calculateDepthEdgeProv( he1, he2, trans2To1Abs, trans2To1, midP2In1, 2, 0, 1, 2, 0, 1, testEdges, depths[2][2] ))
return false;
203 calculateDepthEdge( trans2To1, 0, 1, 2, 0, depths[0][0], depthIndex, minDepth );
204 calculateDepthEdge( trans2To1, 0, 1, 2, 1, depths[0][1], depthIndex, minDepth );
205 calculateDepthEdge( trans2To1, 0, 1, 2, 2, depths[0][2], depthIndex, minDepth );
206 calculateDepthEdge( trans2To1, 1, 2, 0, 0, depths[1][0], depthIndex, minDepth );
207 calculateDepthEdge( trans2To1, 1, 2, 0, 1, depths[1][1], depthIndex, minDepth );
208 calculateDepthEdge( trans2To1, 1, 2, 0, 2, depths[1][2], depthIndex, minDepth );
209 calculateDepthEdge( trans2To1, 2, 0, 1, 0, depths[2][0], depthIndex, minDepth );
210 calculateDepthEdge( trans2To1, 2, 0, 1, 1, depths[2][1], depthIndex, minDepth );
211 calculateDepthEdge( trans2To1, 2, 0, 1, 2, depths[2][2], depthIndex, minDepth );
226 if (depthIndex > 5) {
227 if (createEdgeContact) {
228 ShapeCollider::addContactPoint( result, (closestPoints.pointOn1 + closestPoints.pointOn2) *
agx::Real(0.5), (trans1.transform3x3( normalIn1 )), minDepth );
232 depthIndex = depthIndexFace;
234 solveFaceCaseAgX( depthIndex, -1, signIn1, trans1, trans2To1, trans1To2, he1, he2, epsilon, result );
236 solveFaceCaseAgX( depthIndex - 3, 1, signIn2, trans2, trans1To2, trans2To1, he2, he1, epsilon, result );
241 depthIndex = depthIndexFace;
243 solveFaceCaseAgX( depthIndex, -1,
sign(midP2In1[depthIndex]), trans1, trans2To1, trans1To2, he1, he2, epsilon, result );
245 solveFaceCaseAgX( depthIndex - 3, 1,
sign(midP1In2[depthIndex - 3]), trans2, trans1To2, trans2To1, he2, he1, epsilon, result );
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
AGXCORE_EXPORT const Real RealEpsilon
Templated stack array class.
void push_back(const T &value)
size_t size() const
Get the size of the array (number of filled slots).
AffineMatrix4x4T< T > inverse() const
Quick inverse, transpose rotation part, and change sign of translation part.
Vec3T< T > getInvTranslate() const
AGXCORE_EXPORT const Real RealMax
AGXPHYSICS_EXPORT agx::Bool equalsZero(const agx::AddedMassInteraction::Matrix6x6 &matrix, agx::Real eps=agx::RealEpsilon)