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-2016 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     };
00144 };
00145 
00151 typedef PxFlags<PxConvexFlag::Enum,PxU16> PxConvexFlags;
00152 PX_FLAGS_OPERATORS(PxConvexFlag::Enum,PxU16)
00153 
00154 
00161 class PxConvexMeshDesc
00162 {
00163 public:
00164 
00170     PxBoundedData points;
00171 
00180     PxBoundedData polygons;
00181 
00192     PxBoundedData indices;
00193 
00199     PxConvexFlags flags;
00200 
00214     PxU16 vertexLimit;  
00215 
00225     PxU16 quantizedCount;
00226 
00230     PX_INLINE PxConvexMeshDesc();
00234     PX_INLINE void setToDefault();
00240     PX_INLINE bool isValid() const;
00241 };
00242 
00243 PX_INLINE PxConvexMeshDesc::PxConvexMeshDesc()  //constructor sets to default
00244 : vertexLimit(255), quantizedCount(255)
00245 {
00246 }
00247 
00248 PX_INLINE void PxConvexMeshDesc::setToDefault()
00249 {
00250     *this = PxConvexMeshDesc();
00251 }
00252 
00253 PX_INLINE bool PxConvexMeshDesc::isValid() const
00254 {
00255     // Check geometry
00256     if(points.count < 3 ||  //at least 1 trig's worth of points
00257         (points.count > 0xffff && flags & PxConvexFlag::e16_BIT_INDICES))
00258         return false;
00259     if(!points.data)
00260         return false;
00261     if(points.stride < sizeof(PxVec3))  //should be at least one point's worth of data
00262         return false;
00263     if (quantizedCount < 4)
00264         return false;
00265 
00266     // Check topology
00267     if(polygons.data)
00268     {
00269         if(polygons.count < 4) // we require 2 neighbors for each vertex - 4 polygons at least
00270             return false;
00271 
00272         if(!indices.data) // indices must be provided together with polygons
00273             return false;
00274 
00275         PxU32 limit = (flags & PxConvexFlag::e16_BIT_INDICES) ? sizeof(PxU16) : sizeof(PxU32);
00276         if(indices.stride < limit) 
00277             return false;
00278 
00279         limit = sizeof(PxHullPolygon);
00280         if(polygons.stride < limit) 
00281             return false;
00282     }
00283     else
00284     {
00285         // We can compute the hull from the vertices
00286         if(!(flags & PxConvexFlag::eCOMPUTE_CONVEX))
00287             return false;   // If the mesh is convex and we're not allowed to compute the hull,
00288                             // you have to provide it completely (geometry & topology).
00289     }
00290 
00291     if((flags & PxConvexFlag::ePLANE_SHIFTING) &&  vertexLimit < 4)
00292     {
00293         return false;
00294     }
00295 
00296     if (!(flags & PxConvexFlag::ePLANE_SHIFTING) && vertexLimit < 8)
00297     {
00298         return false;
00299     }
00300 
00301     if(vertexLimit > 256)
00302     {
00303         return false;
00304     }
00305     return true;
00306 }
00307 
00308 #if !PX_DOXYGEN
00309 } // namespace physx
00310 #endif
00311 
00313 #endif


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