NVIDIA(R) PhysX(R) SDK 3.4 API Reference: PxConvexMeshDesc.h Source File

NVIDIA PhysX SDK 3.4 API

PxConvexMeshDesc.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-2017 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 
00031 #ifndef PX_COLLISION_NXCONVEXMESHDESC
00032 #define PX_COLLISION_NXCONVEXMESHDESC
00033 
00037 #include "foundation/PxVec3.h"
00038 #include "foundation/PxFlags.h"
00039 #include "common/PxCoreUtilityTypes.h"
00040 #include "geometry/PxConvexMesh.h"
00041 
00042 #if !PX_DOXYGEN
00043 namespace physx
00044 {
00045 #endif
00046 
00050 struct PxConvexFlag
00051 {
00052     enum Enum
00053     {
00059         e16_BIT_INDICES     =   (1<<0),
00060 
00068         eCOMPUTE_CONVEX     =   (1<<1), 
00069 
00081         eCHECK_ZERO_AREA_TRIANGLES      =   (1<<2),
00082 
00092         PX_DEPRECATED eINFLATE_CONVEX       =   (1<<3),
00093 
00101         eQUANTIZE_INPUT = (1 << 4),
00102 
00110         eDISABLE_MESH_VALIDATION = (1 << 5),
00111 
00129         ePLANE_SHIFTING = (1 << 6),
00130 
00135         eFAST_INERTIA_COMPUTATION = (1 << 7),
00136 
00142         eGPU_COMPATIBLE = (1 << 8),
00143 
00150         eSHIFT_VERTICES = (1 << 9)
00151     };
00152 };
00153 
00159 typedef PxFlags<PxConvexFlag::Enum,PxU16> PxConvexFlags;
00160 PX_FLAGS_OPERATORS(PxConvexFlag::Enum,PxU16)
00161 
00162 
00169 class PxConvexMeshDesc
00170 {
00171 public:
00172 
00178     PxBoundedData points;
00179 
00188     PxBoundedData polygons;
00189 
00200     PxBoundedData indices;
00201 
00207     PxConvexFlags flags;
00208 
00222     PxU16 vertexLimit;  
00223 
00233     PxU16 quantizedCount;
00234 
00238     PX_INLINE PxConvexMeshDesc();
00242     PX_INLINE void setToDefault();
00248     PX_INLINE bool isValid() const;
00249 };
00250 
00251 PX_INLINE PxConvexMeshDesc::PxConvexMeshDesc()  //constructor sets to default
00252 : vertexLimit(255), quantizedCount(255)
00253 {
00254 }
00255 
00256 PX_INLINE void PxConvexMeshDesc::setToDefault()
00257 {
00258     *this = PxConvexMeshDesc();
00259 }
00260 
00261 PX_INLINE bool PxConvexMeshDesc::isValid() const
00262 {
00263     // Check geometry
00264     if(points.count < 3 ||  //at least 1 trig's worth of points
00265         (points.count > 0xffff && flags & PxConvexFlag::e16_BIT_INDICES))
00266         return false;
00267     if(!points.data)
00268         return false;
00269     if(points.stride < sizeof(PxVec3))  //should be at least one point's worth of data
00270         return false;
00271     if (quantizedCount < 4)
00272         return false;
00273 
00274     // Check topology
00275     if(polygons.data)
00276     {
00277         if(polygons.count < 4) // we require 2 neighbors for each vertex - 4 polygons at least
00278             return false;
00279 
00280         if(!indices.data) // indices must be provided together with polygons
00281             return false;
00282 
00283         PxU32 limit = (flags & PxConvexFlag::e16_BIT_INDICES) ? sizeof(PxU16) : sizeof(PxU32);
00284         if(indices.stride < limit) 
00285             return false;
00286 
00287         limit = sizeof(PxHullPolygon);
00288         if(polygons.stride < limit) 
00289             return false;
00290     }
00291     else
00292     {
00293         // We can compute the hull from the vertices
00294         if(!(flags & PxConvexFlag::eCOMPUTE_CONVEX))
00295             return false;   // If the mesh is convex and we're not allowed to compute the hull,
00296                             // you have to provide it completely (geometry & topology).
00297     }
00298 
00299     if((flags & PxConvexFlag::ePLANE_SHIFTING) &&  vertexLimit < 4)
00300     {
00301         return false;
00302     }
00303 
00304     if (!(flags & PxConvexFlag::ePLANE_SHIFTING) && vertexLimit < 8)
00305     {
00306         return false;
00307     }
00308 
00309     if(vertexLimit > 256)
00310     {
00311         return false;
00312     }
00313     return true;
00314 }
00315 
00316 #if !PX_DOXYGEN
00317 } // namespace physx
00318 #endif
00319 
00321 #endif


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