PxConvexMeshDesc.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2015, NVIDIA CORPORATION. All rights reserved.
3  *
4  * NVIDIA CORPORATION and its licensors retain all intellectual property
5  * and proprietary rights in and to this software, related documentation
6  * and any modifications thereto. Any use, reproduction, disclosure or
7  * distribution of this software and related documentation without an express
8  * license agreement from NVIDIA CORPORATION is strictly prohibited.
9  */
10 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
11 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
12 
13 
14 #ifndef PX_COLLISION_NXCONVEXMESHDESC
15 #define PX_COLLISION_NXCONVEXMESHDESC
16 
20 #include "foundation/PxVec3.h"
21 #include "foundation/PxFlags.h"
23 #include "geometry/PxConvexMesh.h"
24 
25 #ifndef PX_DOXYGEN
26 namespace physx
27 {
28 #endif
29 
34 {
35  enum Enum
36  {
51  PX_DEPRECATED eFLIPNORMALS = (1<<0),
52 
58  e16_BIT_INDICES = (1<<1),
59 
63  eCOMPUTE_CONVEX = (1<<2),
64 
72  eINFLATE_CONVEX = (1<<3),
73 
85  eCHECK_ZERO_AREA_TRIANGLES = (1<<4)
86  };
87 };
88 
96 
97 
98 typedef PxVec3 PxPoint;
99 
108 {
109 public:
110 
117 
137 
147 
159 
166 
176 
180  PX_INLINE PxConvexMeshDesc();
184  PX_INLINE void setToDefault();
190  PX_INLINE bool isValid() const;
191 };
192 
193 PX_INLINE PxConvexMeshDesc::PxConvexMeshDesc() //constructor sets to default
194  : vertexLimit(256)
195 {
196 }
197 
199 {
200  *this = PxConvexMeshDesc();
201 }
202 
204 {
205  // Check geometry
206  if(points.count < 3 || //at least 1 trig's worth of points
208  return false;
209  if(!points.data)
210  return false;
211  if(points.stride < sizeof(PxPoint)) //should be at least one point's worth of data
212  return false;
213 
214  // Check topology
215  // The triangles pointer is not mandatory: the vertex cloud is enough to define the convex hull.
216  if(triangles.data)
217  {
218  // Indexed mesh
219  if(triangles.count < 2) //some algos require at least 2 trigs
220  return false;
221 
222  PxU32 limit = (flags & PxConvexFlag::e16_BIT_INDICES) ? sizeof(PxU16)*3 : sizeof(PxU32)*3;
223  if(triangles.stride < limit)
224  return false;
225  }
226  else
227  {
228  if(polygons.data)
229  {
230  if(polygons.count < 4) // we require 2 neighbours for each vertex - 4 polygons at least
231  return false;
232 
233  if(!indices.data) // indices must be provided together with polygons
234  return false;
235 
236  PxU32 limit = (flags & PxConvexFlag::e16_BIT_INDICES) ? sizeof(PxU16) : sizeof(PxU32);
237  if(indices.stride < limit)
238  return false;
239 
240  limit = sizeof(PxHullPolygon);
241  if(polygons.stride < limit)
242  return false;
243  }
244  else
245  {
246  // We can compute the hull from the vertices
248  return false; // If the mesh is convex and we're not allowed to compute the hull,
249  // you have to provide it completely (geometry & topology).
250  }
251  }
252 
253  if(vertexLimit < 4 || vertexLimit > 256)
254  {
255  return false;
256  }
257  return true;
258 }
259 
260 #ifndef PX_DOXYGEN
261 } // namespace physx
262 #endif
263 
265 #endif


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