aboutsummaryrefslogtreecommitdiff
path: root/PhysX_3.4/Source/GeomUtils/headers
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/headers
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/headers')
-rw-r--r--PhysX_3.4/Source/GeomUtils/headers/GuAxes.h81
-rw-r--r--PhysX_3.4/Source/GeomUtils/headers/GuBox.h246
-rw-r--r--PhysX_3.4/Source/GeomUtils/headers/GuDistanceSegmentBox.h57
-rw-r--r--PhysX_3.4/Source/GeomUtils/headers/GuDistanceSegmentSegment.h65
-rw-r--r--PhysX_3.4/Source/GeomUtils/headers/GuIntersectionBoxBox.h54
-rw-r--r--PhysX_3.4/Source/GeomUtils/headers/GuIntersectionTriangleBox.h91
-rw-r--r--PhysX_3.4/Source/GeomUtils/headers/GuRaycastTests.h72
-rw-r--r--PhysX_3.4/Source/GeomUtils/headers/GuSIMDHelpers.h98
-rw-r--r--PhysX_3.4/Source/GeomUtils/headers/GuSegment.h182
9 files changed, 946 insertions, 0 deletions
diff --git a/PhysX_3.4/Source/GeomUtils/headers/GuAxes.h b/PhysX_3.4/Source/GeomUtils/headers/GuAxes.h
new file mode 100644
index 00000000..b39d4d3b
--- /dev/null
+++ b/PhysX_3.4/Source/GeomUtils/headers/GuAxes.h
@@ -0,0 +1,81 @@
+// 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.
+
+#ifndef GU_AXES_H
+#define GU_AXES_H
+
+#include "foundation/PxSimpleTypes.h"
+
+namespace physx
+{
+namespace Gu
+{
+ enum PointComponent
+ {
+ X_ = 0,
+ Y_ = 1,
+ Z_ = 2,
+ W_ = 3,
+
+ PC_FORCE_DWORD = 0x7fffffff
+ };
+
+ enum AxisOrder
+ {
+ AXES_XYZ = (X_)|(Y_<<2)|(Z_<<4),
+ AXES_XZY = (X_)|(Z_<<2)|(Y_<<4),
+ AXES_YXZ = (Y_)|(X_<<2)|(Z_<<4),
+ AXES_YZX = (Y_)|(Z_<<2)|(X_<<4),
+ AXES_ZXY = (Z_)|(X_<<2)|(Y_<<4),
+ AXES_ZYX = (Z_)|(Y_<<2)|(X_<<4),
+
+ AXES_FORCE_DWORD = 0x7fffffff
+ };
+
+ class Axes
+ {
+ public:
+
+ PX_FORCE_INLINE Axes(AxisOrder order)
+ {
+ mAxis0 = PxU32((order ) & 3);
+ mAxis1 = PxU32((order>>2) & 3);
+ mAxis2 = PxU32((order>>4) & 3);
+ }
+ PX_FORCE_INLINE ~Axes() {}
+
+ PxU32 mAxis0;
+ PxU32 mAxis1;
+ PxU32 mAxis2;
+ };
+}
+
+}
+
+#endif
diff --git a/PhysX_3.4/Source/GeomUtils/headers/GuBox.h b/PhysX_3.4/Source/GeomUtils/headers/GuBox.h
new file mode 100644
index 00000000..36e7ef13
--- /dev/null
+++ b/PhysX_3.4/Source/GeomUtils/headers/GuBox.h
@@ -0,0 +1,246 @@
+// 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.
+
+#ifndef GU_BOX_H
+#define GU_BOX_H
+
+/** \addtogroup geomutils
+@{
+*/
+
+#include "PxPhysXCommonConfig.h"
+#include "CmPhysXCommon.h"
+#include "CmScaling.h"
+#include "foundation/PxTransform.h"
+#include "foundation/PxMat33.h"
+
+namespace physx
+{
+namespace Gu
+{
+ class Capsule;
+
+ PX_PHYSX_COMMON_API void computeOBBPoints(PxVec3* PX_RESTRICT pts, const PxVec3& center, const PxVec3& extents, const PxVec3& base0, const PxVec3& base1, const PxVec3& base2);
+
+
+ /**
+ \brief Represents an oriented bounding box.
+
+ As a center point, extents(radii) and a rotation. i.e. the center of the box is at the center point,
+ the box is rotated around this point with the rotation and it is 2*extents in width, height and depth.
+ */
+
+ /**
+ Box geometry
+
+ The rot member describes the world space orientation of the box.
+ The center member gives the world space position of the box.
+ The extents give the local space coordinates of the box corner in the positive octant.
+ Dimensions of the box are: 2*extent.
+ Transformation to world space is: worldPoint = rot * localPoint + center
+ Transformation to local space is: localPoint = T(rot) * (worldPoint - center)
+ Where T(M) denotes the transpose of M.
+ */
+#if PX_VC
+ #pragma warning(push)
+ #pragma warning( disable : 4251 ) // class needs to have dll-interface to be used by clients of class
+#endif
+ class PX_PHYSX_COMMON_API Box
+ {
+ public:
+ /**
+ \brief Constructor
+ */
+ PX_FORCE_INLINE Box()
+ {
+ }
+
+ /**
+ \brief Constructor
+
+ \param origin Center of the OBB
+ \param extent Extents/radii of the obb.
+ \param base rotation to apply to the obb.
+ */
+ //! Construct from center, extent and rotation
+ PX_FORCE_INLINE Box(const PxVec3& origin, const PxVec3& extent, const PxMat33& base) : rot(base), center(origin), extents(extent)
+ {}
+
+ //! Copy constructor
+ PX_FORCE_INLINE Box(const Box& other) : rot(other.rot), center(other.center), extents(other.extents)
+ {}
+
+ /**
+ \brief Destructor
+ */
+ PX_FORCE_INLINE ~Box()
+ {
+ }
+
+ //! Assignment operator
+ PX_FORCE_INLINE const Box& operator=(const Box& other)
+ {
+ rot = other.rot;
+ center = other.center;
+ extents = other.extents;
+ return *this;
+ }
+
+ /**
+ \brief Setups an empty box.
+ */
+ PX_INLINE void setEmpty()
+ {
+ center = PxVec3(0);
+ extents = PxVec3(-PX_MAX_REAL, -PX_MAX_REAL, -PX_MAX_REAL);
+ rot = PxMat33(PxIdentity);
+ }
+
+ /**
+ \brief Checks the box is valid.
+
+ \return true if the box is valid
+ */
+ PX_INLINE bool isValid() const
+ {
+ // Consistency condition for (Center, Extents) boxes: Extents >= 0.0f
+ if(extents.x < 0.0f) return false;
+ if(extents.y < 0.0f) return false;
+ if(extents.z < 0.0f) return false;
+ return true;
+ }
+
+/////////////
+ PX_FORCE_INLINE void setAxes(const PxVec3& axis0, const PxVec3& axis1, const PxVec3& axis2)
+ {
+ rot.column0 = axis0;
+ rot.column1 = axis1;
+ rot.column2 = axis2;
+ }
+
+ PX_FORCE_INLINE PxVec3 rotate(const PxVec3& src) const
+ {
+ return rot * src;
+ }
+
+ PX_FORCE_INLINE PxVec3 rotateInv(const PxVec3& src) const
+ {
+ return rot.transformTranspose(src);
+ }
+
+ PX_FORCE_INLINE PxVec3 transform(const PxVec3& src) const
+ {
+ return rot * src + center;
+ }
+
+ PX_FORCE_INLINE PxTransform getTransform() const
+ {
+ return PxTransform(center, PxQuat(rot));
+ }
+
+ PX_INLINE PxVec3 computeAABBExtent() const
+ {
+ const PxReal a00 = PxAbs(rot[0][0]);
+ const PxReal a01 = PxAbs(rot[0][1]);
+ const PxReal a02 = PxAbs(rot[0][2]);
+
+ const PxReal a10 = PxAbs(rot[1][0]);
+ const PxReal a11 = PxAbs(rot[1][1]);
+ const PxReal a12 = PxAbs(rot[1][2]);
+
+ const PxReal a20 = PxAbs(rot[2][0]);
+ const PxReal a21 = PxAbs(rot[2][1]);
+ const PxReal a22 = PxAbs(rot[2][2]);
+
+ const PxReal ex = extents.x;
+ const PxReal ey = extents.y;
+ const PxReal ez = extents.z;
+
+ return PxVec3( a00 * ex + a10 * ey + a20 * ez,
+ a01 * ex + a11 * ey + a21 * ez,
+ a02 * ex + a12 * ey + a22 * ez);
+ }
+
+ /**
+ Computes the obb points.
+ \param pts [out] 8 box points
+ */
+ PX_FORCE_INLINE void computeBoxPoints(PxVec3* PX_RESTRICT pts) const
+ {
+ Gu::computeOBBPoints(pts, center, extents, rot.column0, rot.column1, rot.column2);
+ }
+
+ void create(const Gu::Capsule& capsule);
+
+ PxMat33 rot;
+ PxVec3 center;
+ PxVec3 extents;
+ };
+ PX_COMPILE_TIME_ASSERT(sizeof(Gu::Box) == 60);
+
+ //! A padded version of Gu::Box, to safely load its data using SIMD
+ class BoxPadded : public Box
+ {
+ public:
+ PX_FORCE_INLINE BoxPadded() {}
+ PX_FORCE_INLINE ~BoxPadded() {}
+ PxU32 padding;
+ };
+ PX_COMPILE_TIME_ASSERT(sizeof(Gu::BoxPadded) == 64);
+
+ //! Transforms a shape space AABB to a vertex space AABB (conservative).
+ PX_FORCE_INLINE void computeVertexSpaceAABB(Gu::Box& vertexSpaceOBB, const PxBounds3& worldBounds, const PxTransform& world2Shape, const Cm::FastVertex2ShapeScaling& scaling, bool idtScaleMesh)
+ {
+ PX_ASSERT(!worldBounds.isEmpty());
+ const PxBounds3 boundsInMesh = PxBounds3::transformFast(world2Shape, worldBounds); // transform bounds from world to shape (excluding mesh scale)
+
+ vertexSpaceOBB.rot = PxMat33(PxIdentity);
+ if(idtScaleMesh)
+ {
+ vertexSpaceOBB.center = boundsInMesh.getCenter();
+ vertexSpaceOBB.extents = boundsInMesh.getExtents();
+ }
+ else
+ {
+ const PxBounds3 bounds = PxBounds3::basisExtent(scaling.getShape2VertexSkew() * boundsInMesh.getCenter(), scaling.getShape2VertexSkew(), boundsInMesh.getExtents());
+ vertexSpaceOBB.center = bounds.getCenter();
+ vertexSpaceOBB.extents = bounds.getExtents();
+ }
+ }
+
+#if PX_VC
+ #pragma warning(pop)
+#endif
+
+}
+
+}
+
+/** @} */
+#endif
diff --git a/PhysX_3.4/Source/GeomUtils/headers/GuDistanceSegmentBox.h b/PhysX_3.4/Source/GeomUtils/headers/GuDistanceSegmentBox.h
new file mode 100644
index 00000000..6f648d23
--- /dev/null
+++ b/PhysX_3.4/Source/GeomUtils/headers/GuDistanceSegmentBox.h
@@ -0,0 +1,57 @@
+// 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.
+
+#ifndef GU_DISTANCE_SEGMENT_BOX_H
+#define GU_DISTANCE_SEGMENT_BOX_H
+
+#include "foundation/PxMat33.h"
+#include "GuSegment.h"
+#include "GuBox.h"
+
+namespace physx
+{
+namespace Gu
+{
+
+ //! Compute the smallest distance from the (finite) line segment to the box.
+ PX_PHYSX_COMMON_API PxReal distanceSegmentBoxSquared( const PxVec3& segmentPoint0, const PxVec3& segmentPoint1,
+ const PxVec3& boxOrigin, const PxVec3& boxExtent, const PxMat33& boxBase,
+ PxReal* segmentParam = NULL,
+ PxVec3* boxParam = NULL);
+
+ PX_FORCE_INLINE PxReal distanceSegmentBoxSquared(const Gu::Segment& segment, const Gu::Box& box, PxReal* t = NULL, PxVec3* p = NULL)
+ {
+ return distanceSegmentBoxSquared(segment.p0, segment.p1, box.center, box.extents, box.rot, t, p);
+ }
+
+} // namespace Gu
+
+}
+
+#endif
diff --git a/PhysX_3.4/Source/GeomUtils/headers/GuDistanceSegmentSegment.h b/PhysX_3.4/Source/GeomUtils/headers/GuDistanceSegmentSegment.h
new file mode 100644
index 00000000..5e729ca7
--- /dev/null
+++ b/PhysX_3.4/Source/GeomUtils/headers/GuDistanceSegmentSegment.h
@@ -0,0 +1,65 @@
+// 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.
+
+#ifndef GU_DISTANCE_SEGMENT_SEGMENT_H
+#define GU_DISTANCE_SEGMENT_SEGMENT_H
+
+#include "common/PxPhysXCommonConfig.h"
+#include "GuSegment.h"
+
+namespace physx
+{
+namespace Gu
+{
+ // This version fixes accuracy issues (e.g. TTP 4617), but needs to do 2 square roots in order
+ // to find the normalized direction and length of the segments, and then
+ // a division in order to renormalize the output
+
+ PX_PHYSX_COMMON_API PxReal distanceSegmentSegmentSquared( const PxVec3& origin0, const PxVec3& dir0, PxReal extent0,
+ const PxVec3& origin1, const PxVec3& dir1, PxReal extent1,
+ PxReal* s=NULL, PxReal* t=NULL);
+
+ PX_PHYSX_COMMON_API PxReal distanceSegmentSegmentSquared( const PxVec3& origin0, const PxVec3& extent0,
+ const PxVec3& origin1, const PxVec3& extent1,
+ PxReal* s=NULL, PxReal* t=NULL);
+
+ PX_FORCE_INLINE PxReal distanceSegmentSegmentSquared( const Gu::Segment& segment0,
+ const Gu::Segment& segment1,
+ PxReal* s=NULL, PxReal* t=NULL)
+ {
+ return distanceSegmentSegmentSquared( segment0.p0, segment0.computeDirection(),
+ segment1.p0, segment1.computeDirection(),
+ s, t);
+ }
+
+} // namespace Gu
+
+}
+
+#endif
diff --git a/PhysX_3.4/Source/GeomUtils/headers/GuIntersectionBoxBox.h b/PhysX_3.4/Source/GeomUtils/headers/GuIntersectionBoxBox.h
new file mode 100644
index 00000000..6b318061
--- /dev/null
+++ b/PhysX_3.4/Source/GeomUtils/headers/GuIntersectionBoxBox.h
@@ -0,0 +1,54 @@
+// 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.
+
+#ifndef GU_INTERSECTION_BOX_BOX_H
+#define GU_INTERSECTION_BOX_BOX_H
+
+#include "foundation/PxMat33.h"
+#include "foundation/PxBounds3.h"
+#include "GuBox.h"
+
+namespace physx
+{
+namespace Gu
+{
+ PX_PHYSX_COMMON_API bool intersectOBBOBB(const PxVec3& e0, const PxVec3& c0, const PxMat33& r0, const PxVec3& e1, const PxVec3& c1, const PxMat33& r1, bool full_test);
+
+ PX_FORCE_INLINE bool intersectOBBAABB(const Gu::Box& obb, const PxBounds3& aabb)
+ {
+ PxVec3 center = aabb.getCenter();
+ PxVec3 extents = aabb.getExtents();
+ return intersectOBBOBB(obb.extents, obb.center, obb.rot, extents, center, PxMat33(PxIdentity), true);
+ }
+
+} // namespace Gu
+
+}
+
+#endif
diff --git a/PhysX_3.4/Source/GeomUtils/headers/GuIntersectionTriangleBox.h b/PhysX_3.4/Source/GeomUtils/headers/GuIntersectionTriangleBox.h
new file mode 100644
index 00000000..4eb4e068
--- /dev/null
+++ b/PhysX_3.4/Source/GeomUtils/headers/GuIntersectionTriangleBox.h
@@ -0,0 +1,91 @@
+// 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.
+
+#ifndef GU_INTERSECTION_TRIANGLE_BOX_H
+#define GU_INTERSECTION_TRIANGLE_BOX_H
+
+#include "PxPhysXCommonConfig.h"
+#include "CmPhysXCommon.h"
+#include "foundation/PxMat33.h"
+
+namespace physx
+{
+namespace Gu
+{
+ class Box;
+ class BoxPadded;
+
+ /**
+ Tests if a triangle overlaps a box (AABB). This is the reference non-SIMD code.
+
+ \param center [in] the box center
+ \param extents [in] the box extents
+ \param p0 [in] triangle's first point
+ \param p1 [in] triangle's second point
+ \param p2 [in] triangle's third point
+ \return true if triangle overlaps box
+ */
+ PX_PHYSX_COMMON_API Ps::IntBool intersectTriangleBox_ReferenceCode(const PxVec3& center, const PxVec3& extents, const PxVec3& p0, const PxVec3& p1, const PxVec3& p2);
+
+ /**
+ Tests if a triangle overlaps a box (AABB). This is the optimized SIMD code.
+
+ WARNING: the function has various SIMD requirements, left to the calling code:
+ - function will load 4 bytes after 'center'. Make sure it's safe to load from there.
+ - function will load 4 bytes after 'extents'. Make sure it's safe to load from there.
+ - function will load 4 bytes after 'p0'. Make sure it's safe to load from there.
+ - function will load 4 bytes after 'p1'. Make sure it's safe to load from there.
+ - function will load 4 bytes after 'p2'. Make sure it's safe to load from there.
+ If you can't guarantee these requirements, please use the non-SIMD reference code instead.
+
+ \param center [in] the box center.
+ \param extents [in] the box extents
+ \param p0 [in] triangle's first point
+ \param p1 [in] triangle's second point
+ \param p2 [in] triangle's third point
+ \return true if triangle overlaps box
+ */
+ PX_PHYSX_COMMON_API Ps::IntBool intersectTriangleBox_Unsafe(const PxVec3& center, const PxVec3& extents, const PxVec3& p0, const PxVec3& p1, const PxVec3& p2);
+
+ /**
+ Tests if a triangle overlaps a box (OBB).
+
+ There are currently no SIMD-related requirements for p0, p1, p2.
+
+ \param box [in] the box
+ \param p0 [in] triangle's first point
+ \param p1 [in] triangle's second point
+ \param p2 [in] triangle's third point
+ \return true if triangle overlaps box
+ */
+ PX_PHYSX_COMMON_API Ps::IntBool intersectTriangleBox(const BoxPadded& box, const PxVec3& p0, const PxVec3& p1, const PxVec3& p2);
+} // namespace Gu
+}
+
+#endif
diff --git a/PhysX_3.4/Source/GeomUtils/headers/GuRaycastTests.h b/PhysX_3.4/Source/GeomUtils/headers/GuRaycastTests.h
new file mode 100644
index 00000000..86d70caf
--- /dev/null
+++ b/PhysX_3.4/Source/GeomUtils/headers/GuRaycastTests.h
@@ -0,0 +1,72 @@
+// 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.
+
+#ifndef GU_RAYCAST_TESTS_H
+#define GU_RAYCAST_TESTS_H
+
+#include "CmPhysXCommon.h"
+#include "foundation/PxSimpleTypes.h"
+#include "PxQueryReport.h"
+#include "PxGeometry.h"
+
+namespace physx
+{
+ // PT: TODO: why is PxHitFlag::eMESH_MULTIPLE used in the ray-vs-hf function, but not in the ray-vs-mesh function?
+
+ // PT: we use a define to be able to quickly change the signature of all raycast functions.
+ // (this also ensures they all use consistent names for passed parameters).
+ // \param[in] geom geometry object to raycast against
+ // \param[in] pose pose of geometry object
+ // \param[in] rayOrigin ray's origin
+ // \param[in] rayDir ray's unit dir
+ // \param[in] maxDist ray's length/max distance
+ // \param[in] hitFlags query behavior flags
+ // \param[in] maxHits max number of hits = size of 'hits' buffer
+ // \param[out] hits result buffer where to write raycast hits
+ #define GU_RAY_FUNC_PARAMS const PxGeometry& geom, const PxTransform& pose, \
+ const PxVec3& rayOrigin, const PxVec3& rayDir, PxReal maxDist, \
+ PxHitFlags hitFlags, PxU32 maxHits, PxRaycastHit* PX_RESTRICT hits
+ namespace Gu
+ {
+ // PT: function pointer for Geom-indexed raycast functions
+ // See GU_RAY_FUNC_PARAMS for function parameters details.
+ // \return number of hits written to 'hits' result buffer
+ // \note there's no mechanism to report overflow. Returned number of hits is just clamped to maxHits.
+ typedef PxU32 (*RaycastFunc) (GU_RAY_FUNC_PARAMS);
+
+ // PT: typedef for a bundle of all raycast functions, i.e. the function table itself (indexed by geom-type).
+ typedef RaycastFunc GeomRaycastTable[PxGeometryType::eGEOMETRY_COUNT];
+
+ // PT: retrieves the raycast function table (for access by external non-Gu modules)
+ PX_PHYSX_COMMON_API const GeomRaycastTable& getRaycastFuncTable();
+
+ } // namespace Gu
+}
+
+#endif
diff --git a/PhysX_3.4/Source/GeomUtils/headers/GuSIMDHelpers.h b/PhysX_3.4/Source/GeomUtils/headers/GuSIMDHelpers.h
new file mode 100644
index 00000000..2aada303
--- /dev/null
+++ b/PhysX_3.4/Source/GeomUtils/headers/GuSIMDHelpers.h
@@ -0,0 +1,98 @@
+// 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.
+
+#ifndef GU_SIMD_HELPERS_H
+#define GU_SIMD_HELPERS_H
+
+#include "PxPhysXCommonConfig.h"
+#include "CmPhysXCommon.h"
+#include "geometry/PxTriangle.h"
+#include "foundation/PxMat33.h"
+#include "PsVecMath.h"
+
+namespace physx
+{
+namespace Gu
+{
+ //! A padded version of PxTriangle, to safely load its data using SIMD
+ class TrianglePadded : public PxTriangle
+ {
+ public:
+ PX_FORCE_INLINE TrianglePadded() {}
+ PX_FORCE_INLINE ~TrianglePadded() {}
+ PxU32 padding;
+ };
+
+ // PT: wrapper helper class to make sure we can safely load a PxVec3 using SIMD loads
+ // PT: TODO: refactor with PxVec3Pad
+ class Vec3p : public PxVec3
+ {
+ public:
+ PX_FORCE_INLINE Vec3p() {}
+ PX_FORCE_INLINE ~Vec3p() {}
+ PX_FORCE_INLINE Vec3p(const PxVec3& p) : PxVec3(p) {}
+ PX_FORCE_INLINE Vec3p(float f) : PxVec3(f) {}
+ PxU32 padding;
+ };
+ PX_COMPILE_TIME_ASSERT(sizeof(Vec3p) == 16);
+
+ //! A padded version of PxMat33, to safely load its data using SIMD
+ class PxMat33Padded : public PxMat33
+ {
+ public:
+ explicit PX_FORCE_INLINE PxMat33Padded(const PxQuat& q)
+ {
+ using namespace Ps::aos;
+ const QuatV qV = V4LoadU(&q.x);
+ Vec3V column0V, column1V, column2V;
+ QuatGetMat33V(qV, column0V, column1V, column2V);
+#if PX_ANDROID || (PX_LINUX && PX_ARM)
+ V3StoreU(column0V, column0);
+ V3StoreU(column1V, column1);
+ V3StoreU(column2V, column2);
+#else
+ V4StoreU(column0V, &column0.x);
+ V4StoreU(column1V, &column1.x);
+ V4StoreU(column2V, &column2.x);
+#endif
+ }
+ PX_FORCE_INLINE ~PxMat33Padded() {}
+ PX_FORCE_INLINE void operator=(const PxMat33& other)
+ {
+ column0 = other.column0;
+ column1 = other.column1;
+ column2 = other.column2;
+ }
+ PxU32 padding;
+ };
+
+} // namespace Gu
+}
+
+#endif
diff --git a/PhysX_3.4/Source/GeomUtils/headers/GuSegment.h b/PhysX_3.4/Source/GeomUtils/headers/GuSegment.h
new file mode 100644
index 00000000..d5f62122
--- /dev/null
+++ b/PhysX_3.4/Source/GeomUtils/headers/GuSegment.h
@@ -0,0 +1,182 @@
+// 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.
+
+#ifndef GU_SEGMENT_H
+#define GU_SEGMENT_H
+/** \addtogroup geomutils
+@{
+*/
+
+#include "foundation/PxVec3.h"
+#include "Ps.h"
+#include "CmPhysXCommon.h"
+
+namespace physx
+{
+namespace Gu
+{
+
+ /**
+ \brief Represents a line segment.
+
+ Line segment geometry
+ In some cases this structure will be used to represent the infinite line that passes point0 and point1.
+ */
+ class Segment
+ {
+ public:
+ /**
+ \brief Constructor
+ */
+ PX_INLINE Segment()
+ {
+ }
+
+ /**
+ \brief Constructor
+ */
+ PX_INLINE Segment(const PxVec3& _p0, const PxVec3& _p1) : p0(_p0), p1(_p1)
+ {
+ }
+
+ /**
+ \brief Copy constructor
+ */
+ PX_INLINE Segment(const Segment& seg) : p0(seg.p0), p1(seg.p1)
+ {
+ }
+
+ /**
+ \brief Destructor
+ */
+ PX_INLINE ~Segment()
+ {
+ }
+
+ //! Assignment operator
+ PX_INLINE Segment& operator=(const Segment& other)
+ {
+ p0 = other.p0;
+ p1 = other.p1;
+ return *this;
+ }
+
+ //! Equality operator
+ PX_INLINE bool operator==(const Segment& other) const
+ {
+ return (p0==other.p0 && p1==other.p1);
+ }
+
+ //! Inequality operator
+ PX_INLINE bool operator!=(const Segment& other) const
+ {
+ return (p0!=other.p0 || p1!=other.p1);
+ }
+
+ PX_INLINE const PxVec3& getOrigin() const
+ {
+ return p0;
+ }
+
+ //! Return the vector from point0 to point1
+ PX_INLINE PxVec3 computeDirection() const
+ {
+ return p1 - p0;
+ }
+
+ //! Return the vector from point0 to point1
+ PX_INLINE void computeDirection(PxVec3& dir) const
+ {
+ dir = p1 - p0;
+ }
+
+ //! Return the center of the segment segment
+ PX_INLINE PxVec3 computeCenter() const
+ {
+ return (p0 + p1)*0.5f;
+ }
+
+ PX_INLINE PxF32 computeLength() const
+ {
+ return (p1-p0).magnitude();
+ }
+
+ PX_INLINE PxF32 computeSquareLength() const
+ {
+ return (p1-p0).magnitudeSquared();
+ }
+
+ // PT: TODO: remove this one
+ //! Return the square of the length of vector from point0 to point1
+ PX_INLINE PxReal lengthSquared() const
+ {
+ return ((p1 - p0).magnitudeSquared());
+ }
+
+ // PT: TODO: remove this one
+ //! Return the length of vector from point0 to point1
+ PX_INLINE PxReal length() const
+ {
+ return ((p1 - p0).magnitude());
+ }
+
+ /* PX_INLINE void setOriginDirection(const PxVec3& origin, const PxVec3& direction)
+ {
+ p0 = p1 = origin;
+ p1 += direction;
+ }*/
+
+ /**
+ \brief Computes a point on the segment
+
+ \param[out] pt point on segment
+ \param[in] t point's parameter [t=0 => pt = mP0, t=1 => pt = mP1]
+ */
+ PX_INLINE void computePoint(PxVec3& pt, PxF32 t) const
+ {
+ pt = p0 + t * (p1 - p0);
+ }
+
+ // PT: TODO: remove this one
+ //! Return the point at parameter t along the line: point0 + t*(point1-point0)
+ PX_INLINE PxVec3 getPointAt(PxReal t) const
+ {
+ return (p1 - p0)*t + p0;
+ }
+
+ PxVec3 p0; //!< Start of segment
+ PxVec3 p1; //!< End of segment
+ };
+ PX_COMPILE_TIME_ASSERT(sizeof(Gu::Segment) == 24);
+}
+
+}
+
+/** @} */
+#endif