GuContactBuffer.h

Go to the documentation of this file.
00001 // This code contains NVIDIA Confidential Information and is disclosed to you
00002 // under a form of NVIDIA software license agreement provided separately to you.
00003 //
00004 // Notice
00005 // NVIDIA Corporation and its licensors retain all intellectual property and
00006 // proprietary rights in and to this software and related documentation and
00007 // any modifications thereto. Any use, reproduction, disclosure, or
00008 // distribution of this software and related documentation without an express
00009 // license agreement from NVIDIA Corporation is strictly prohibited.
00010 //
00011 // ALL NVIDIA DESIGN SPECIFICATIONS, CODE ARE PROVIDED "AS IS.". NVIDIA MAKES
00012 // NO WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
00013 // THE MATERIALS, AND EXPRESSLY DISCLAIMS ALL IMPLIED WARRANTIES OF NONINFRINGEMENT,
00014 // MERCHANTABILITY, AND FITNESS FOR A PARTICULAR PURPOSE.
00015 //
00016 // Information and code furnished is believed to be accurate and reliable.
00017 // However, NVIDIA Corporation assumes no responsibility for the consequences of use of such
00018 // information or for any infringement of patents or other rights of third parties that may
00019 // result from its use. No license is granted by implication or otherwise under any patent
00020 // or patent rights of NVIDIA Corporation. Details are subject to change without notice.
00021 // This code supersedes and replaces all information previously supplied.
00022 // NVIDIA Corporation products are not authorized for use as critical
00023 // components in life support devices or systems without express written approval of
00024 // NVIDIA Corporation.
00025 //
00026 // Copyright (c) 2008-2018 NVIDIA Corporation. All rights reserved.
00027 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
00028 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.  
00029 
00030 #ifndef GU_CONTACTBUFFER_H
00031 #define GU_CONTACTBUFFER_H
00032 
00033 #include "PxPhysXConfig.h"
00034 #include "PxContact.h"
00035 #include "GuContactPoint.h"
00036 
00037 namespace physx
00038 {
00039 namespace Gu
00040 {
00041 
00042     struct NarrowPhaseParams
00043     {
00044         PX_FORCE_INLINE NarrowPhaseParams(PxReal contactDistance, PxReal meshContactMargin, PxReal toleranceLength) :
00045                 mContactDistance(contactDistance),
00046                 mMeshContactMargin(meshContactMargin),
00047                 mToleranceLength(toleranceLength)   {}
00048 
00049         PxReal  mContactDistance;
00050         PxReal  mMeshContactMargin; // PT: Margin used to generate mesh contacts. Temp & unclear, should be removed once GJK is default path.
00051         PxReal  mToleranceLength;   // PT: copy of PxTolerancesScale::length
00052     };
00053 
00054 //sizeof(SavedContactData)/sizeof(PxU32) = 17, 1088/17 = 64 triangles in the local array
00055 #define LOCAL_CONTACTS_SIZE     1088
00056 
00057 class ContactBuffer
00058 {
00059 public:
00060 
00061     static const PxU32 MAX_CONTACTS = 64;
00062 
00063     Gu::ContactPoint    contacts[MAX_CONTACTS];
00064     PxU32               count;
00065     PxU32               pad;
00066 
00067     PX_FORCE_INLINE void reset()
00068     {
00069         count = 0;
00070     }
00071 
00072     PX_FORCE_INLINE bool contact(const PxVec3& worldPoint, 
00073                  const PxVec3& worldNormalIn, 
00074                  PxReal separation, 
00075                  PxU32 faceIndex1 = PXC_CONTACT_NO_FACE_INDEX
00076                  )
00077     {
00078         PX_ASSERT(PxAbs(worldNormalIn.magnitude()-1)<1e-3f);
00079 
00080         if(count>=MAX_CONTACTS)
00081             return false;
00082 
00083         Gu::ContactPoint& p = contacts[count++];
00084         p.normal            = worldNormalIn;
00085         p.point             = worldPoint;
00086         p.separation        = separation;
00087         p.internalFaceIndex1= faceIndex1;
00088         return true;
00089     }
00090 
00091     PX_FORCE_INLINE bool contact(const PxVec3& worldPoint,
00092         const PxVec3& worldNormalIn,
00093         PxReal separation,
00094         PxU16 internalUsage,
00095         PxU32 faceIndex1 = PXC_CONTACT_NO_FACE_INDEX
00096         )
00097     {
00098         PX_ASSERT(PxAbs(worldNormalIn.magnitude() - 1)<1e-3f);
00099 
00100         if (count >= MAX_CONTACTS)
00101             return false;
00102 
00103         Gu::ContactPoint& p = contacts[count++];
00104         p.normal = worldNormalIn;
00105         p.point = worldPoint;
00106         p.separation = separation;
00107         p.internalFaceIndex1 = faceIndex1;
00108         p.forInternalUse = internalUsage;
00109         return true;
00110     }
00111 
00112     PX_FORCE_INLINE bool contact(const Gu::ContactPoint & pt)
00113     {
00114         if(count>=MAX_CONTACTS)
00115             return false;
00116         contacts[count++] = pt;
00117         return true;
00118     }
00119 
00120     PX_FORCE_INLINE Gu::ContactPoint* contact()
00121     {
00122         if(count>=MAX_CONTACTS)
00123             return NULL;
00124         return &contacts[count++];
00125     }
00126 };
00127 
00128 }
00129 }
00130 
00131 #endif


Copyright © 2008-2018 NVIDIA Corporation, 2701 San Tomas Expressway, Santa Clara, CA 95050 U.S.A. All rights reserved. www.nvidia.com