aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/GeomUtils/src/intersection/GuIntersectionBoxBox.cpp
diff options
context:
space:
mode:
authorgit perforce import user <a@b>2016-10-25 12:29:14 -0600
committerSheikh Dawood Abdul Ajees <Sheikh Dawood Abdul Ajees>2016-10-25 18:56:37 -0500
commit3dfe2108cfab31ba3ee5527e217d0d8e99a51162 (patch)
treefa6485c169e50d7415a651bf838f5bcd0fd3bfbd /PhysX_3.4/Source/GeomUtils/src/intersection/GuIntersectionBoxBox.cpp
downloadphysx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.tar.xz
physx-3.4-3dfe2108cfab31ba3ee5527e217d0d8e99a51162.zip
Initial commit:
PhysX 3.4.0 Update @ 21294896 APEX 1.4.0 Update @ 21275617 [CL 21300167]
Diffstat (limited to 'PhysX_3.4/Source/GeomUtils/src/intersection/GuIntersectionBoxBox.cpp')
-rw-r--r--PhysX_3.4/Source/GeomUtils/src/intersection/GuIntersectionBoxBox.cpp139
1 files changed, 139 insertions, 0 deletions
diff --git a/PhysX_3.4/Source/GeomUtils/src/intersection/GuIntersectionBoxBox.cpp b/PhysX_3.4/Source/GeomUtils/src/intersection/GuIntersectionBoxBox.cpp
new file mode 100644
index 00000000..19c8c1d0
--- /dev/null
+++ b/PhysX_3.4/Source/GeomUtils/src/intersection/GuIntersectionBoxBox.cpp
@@ -0,0 +1,139 @@
+// This code contains NVIDIA Confidential Information and is disclosed to you
+// under a form of NVIDIA software license agreement provided separately to you.
+//
+// Notice
+// NVIDIA Corporation and its licensors retain all intellectual property and
+// proprietary rights in and to this software and related documentation and
+// any modifications thereto. Any use, reproduction, disclosure, or
+// distribution of this software and related documentation without an express
+// license agreement from NVIDIA Corporation is strictly prohibited.
+//
+// ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
+// NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
+// THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
+// MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
+//
+// Information and code furnished is believed to be accurate and reliable.
+// However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
+// information or for any infringement of patents or other rights of third parties that may
+// result from its use. No license is granted by implication or otherwise under any patent
+// or patent rights of NVIDIA Corporation. Details are subject to change without notice.
+// This code supersedes and replaces all information previously supplied.
+// NVIDIA Corporation products are not authorized for use as critical
+// components in life support devices or systems without express written approval of
+// NVIDIA Corporation.
+//
+// Copyright (c) 2008-2016 NVIDIA Corporation. All rights reserved.
+// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
+// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
+
+#include "GuIntersectionBoxBox.h"
+
+using namespace physx;
+
+bool Gu::intersectOBBOBB(const PxVec3& e0, const PxVec3& c0, const PxMat33& r0, const PxVec3& e1, const PxVec3& c1, const PxMat33& r1, bool full_test)
+{
+ // Translation, in parent frame
+ const PxVec3 v = c1 - c0;
+ // Translation, in A's frame
+ const PxVec3 T(v.dot(r0[0]), v.dot(r0[1]), v.dot(r0[2]));
+
+ // B's basis with respect to A's local frame
+ PxReal R[3][3];
+ PxReal FR[3][3];
+ PxReal ra, rb, t;
+
+ // Calculate rotation matrix
+ for(PxU32 i=0;i<3;i++)
+ {
+ for(PxU32 k=0;k<3;k++)
+ {
+ R[i][k] = r0[i].dot(r1[k]);
+ FR[i][k] = 1e-6f + PxAbs(R[i][k]); // Precompute fabs matrix
+ }
+ }
+
+ // A's basis vectors
+ for(PxU32 i=0;i<3;i++)
+ {
+ ra = e0[i];
+
+ rb = e1[0]*FR[i][0] + e1[1]*FR[i][1] + e1[2]*FR[i][2];
+
+ t = PxAbs(T[i]);
+
+ if(t > ra + rb) return false;
+ }
+
+ // B's basis vectors
+ for(PxU32 k=0;k<3;k++)
+ {
+ ra = e0[0]*FR[0][k] + e0[1]*FR[1][k] + e0[2]*FR[2][k];
+
+ rb = e1[k];
+
+ t = PxAbs(T[0]*R[0][k] + T[1]*R[1][k] + T[2]*R[2][k]);
+
+ if( t > ra + rb ) return false;
+ }
+
+ if(full_test)
+ {
+ //9 cross products
+
+ //L = A0 x B0
+ ra = e0[1]*FR[2][0] + e0[2]*FR[1][0];
+ rb = e1[1]*FR[0][2] + e1[2]*FR[0][1];
+ t = PxAbs(T[2]*R[1][0] - T[1]*R[2][0]);
+ if(t > ra + rb) return false;
+
+ //L = A0 x B1
+ ra = e0[1]*FR[2][1] + e0[2]*FR[1][1];
+ rb = e1[0]*FR[0][2] + e1[2]*FR[0][0];
+ t = PxAbs(T[2]*R[1][1] - T[1]*R[2][1]);
+ if(t > ra + rb) return false;
+
+ //L = A0 x B2
+ ra = e0[1]*FR[2][2] + e0[2]*FR[1][2];
+ rb = e1[0]*FR[0][1] + e1[1]*FR[0][0];
+ t = PxAbs(T[2]*R[1][2] - T[1]*R[2][2]);
+ if(t > ra + rb) return false;
+
+ //L = A1 x B0
+ ra = e0[0]*FR[2][0] + e0[2]*FR[0][0];
+ rb = e1[1]*FR[1][2] + e1[2]*FR[1][1];
+ t = PxAbs(T[0]*R[2][0] - T[2]*R[0][0]);
+ if(t > ra + rb) return false;
+
+ //L = A1 x B1
+ ra = e0[0]*FR[2][1] + e0[2]*FR[0][1];
+ rb = e1[0]*FR[1][2] + e1[2]*FR[1][0];
+ t = PxAbs(T[0]*R[2][1] - T[2]*R[0][1]);
+ if(t > ra + rb) return false;
+
+ //L = A1 x B2
+ ra = e0[0]*FR[2][2] + e0[2]*FR[0][2];
+ rb = e1[0]*FR[1][1] + e1[1]*FR[1][0];
+ t = PxAbs(T[0]*R[2][2] - T[2]*R[0][2]);
+ if(t > ra + rb) return false;
+
+ //L = A2 x B0
+ ra = e0[0]*FR[1][0] + e0[1]*FR[0][0];
+ rb = e1[1]*FR[2][2] + e1[2]*FR[2][1];
+ t = PxAbs(T[1]*R[0][0] - T[0]*R[1][0]);
+ if(t > ra + rb) return false;
+
+ //L = A2 x B1
+ ra = e0[0]*FR[1][1] + e0[1]*FR[0][1];
+ rb = e1[0] *FR[2][2] + e1[2]*FR[2][0];
+ t = PxAbs(T[1]*R[0][1] - T[0]*R[1][1]);
+ if(t > ra + rb) return false;
+
+ //L = A2 x B2
+ ra = e0[0]*FR[1][2] + e0[1]*FR[0][2];
+ rb = e1[0]*FR[2][1] + e1[1]*FR[2][0];
+ t = PxAbs(T[1]*R[0][2] - T[0]*R[1][2]);
+ if(t > ra + rb) return false;
+ }
+ return true;
+}