PxConvexMeshDesc.h
Go to the documentation of this file.
1 //
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions
4 // are met:
5 // * Redistributions of source code must retain the above copyright
6 // notice, this list of conditions and the following disclaimer.
7 // * Redistributions in binary form must reproduce the above copyright
8 // notice, this list of conditions and the following disclaimer in the
9 // documentation and/or other materials provided with the distribution.
10 // * Neither the name of NVIDIA CORPORATION nor the names of its
11 // contributors may be used to endorse or promote products derived
12 // from this software without specific prior written permission.
13 //
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
15 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
22 // OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 //
26 // Copyright (c) 2008-2021 NVIDIA Corporation. All rights reserved.
27 // Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
28 // Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
29 
30 
31 #ifndef PX_COLLISION_NXCONVEXMESHDESC
32 #define PX_COLLISION_NXCONVEXMESHDESC
33 
37 #include "foundation/PxVec3.h"
38 #include "foundation/PxFlags.h"
40 #include "geometry/PxConvexMesh.h"
41 
42 #if !PX_DOXYGEN
43 namespace physx
44 {
45 #endif
46 
51 {
52  enum Enum
53  {
59  e16_BIT_INDICES = (1<<0),
60 
68  eCOMPUTE_CONVEX = (1<<1),
69 
78  eCHECK_ZERO_AREA_TRIANGLES = (1<<2),
79 
87  eQUANTIZE_INPUT = (1 << 3),
88 
96  eDISABLE_MESH_VALIDATION = (1 << 4),
97 
115  ePLANE_SHIFTING = (1 << 5),
116 
121  eFAST_INERTIA_COMPUTATION = (1 << 6),
122 
128  eGPU_COMPATIBLE = (1 << 7),
129 
136  eSHIFT_VERTICES = (1 << 8)
137  };
138 };
139 
146 PX_FLAGS_OPERATORS(PxConvexFlag::Enum,PxU16)
147 
148 
156 {
157 public:
158 
165 
175 
187 
194 
209 
220 
228  PX_INLINE void setToDefault();
234  PX_INLINE bool isValid() const;
235 };
236 
237 PX_INLINE PxConvexMeshDesc::PxConvexMeshDesc() //constructor sets to default
238 : vertexLimit(255), quantizedCount(255)
239 {
240 }
241 
243 {
244  *this = PxConvexMeshDesc();
245 }
246 
248 {
249  // Check geometry
250  if(points.count < 3 || //at least 1 trig's worth of points
252  return false;
253  if(!points.data)
254  return false;
255  if(points.stride < sizeof(PxVec3)) //should be at least one point's worth of data
256  return false;
257  if (quantizedCount < 4)
258  return false;
259 
260  // Check topology
261  if(polygons.data)
262  {
263  if(polygons.count < 4) // we require 2 neighbors for each vertex - 4 polygons at least
264  return false;
265 
266  if(!indices.data) // indices must be provided together with polygons
267  return false;
268 
269  PxU32 limit = (flags & PxConvexFlag::e16_BIT_INDICES) ? sizeof(PxU16) : sizeof(PxU32);
270  if(indices.stride < limit)
271  return false;
272 
273  limit = sizeof(PxHullPolygon);
274  if(polygons.stride < limit)
275  return false;
276  }
277  else
278  {
279  // We can compute the hull from the vertices
281  return false; // If the mesh is convex and we're not allowed to compute the hull,
282  // you have to provide it completely (geometry & topology).
283  }
284 
286  {
287  return false;
288  }
289 
291  {
292  return false;
293  }
294 
295  if(vertexLimit > 256)
296  {
297  return false;
298  }
299  return true;
300 }
301 
302 #if !PX_DOXYGEN
303 } // namespace physx
304 #endif
305 
307 #endif
Definition: GuContactBuffer.h:37
Enables plane shifting vertex limit algorithm.
Definition: PxConvexMeshDesc.h:115
Polygon data.
Definition: PxConvexMesh.h:51
Flags which describe the format and behavior of a convex mesh.
Definition: PxConvexMeshDesc.h:50
PxU16 vertexLimit
Limits the number of vertices of the result convex mesh. Hard maximum limit is 256 and minimum limit ...
Definition: PxConvexMeshDesc.h:208
PX_INLINE PxConvexMeshDesc()
constructor sets to default.
Definition: PxConvexMeshDesc.h:237
PxFlags< PxConvexFlag::Enum, PxU16 > PxConvexFlags
collection of set bits defined in PxConvexFlag.
Definition: PxConvexMeshDesc.h:145
Definition: PxConvexMeshDesc.h:68
PX_INLINE bool isValid() const
Returns true if the descriptor is valid.
Definition: PxConvexMeshDesc.h:247
PxBoundedData points
Vertex positions data in PxBoundedData format.
Definition: PxConvexMeshDesc.h:164
Definition: PxConvexMeshDesc.h:59
PxBoundedData indices
Polygon indices data in PxBoundedData format.
Definition: PxConvexMeshDesc.h:186
PxU32 stride
The offset in bytes between consecutive samples in the data.
Definition: PxCoreUtilityTypes.h:53
Enum
Definition: PxConvexMeshDesc.h:52
PxU32 count
Definition: PxCoreUtilityTypes.h:85
const void * data
Definition: PxCoreUtilityTypes.h:54
Descriptor class for PxConvexMesh.
Definition: PxConvexMeshDesc.h:155
PX_INLINE void setToDefault()
(re)sets the structure to the default.
Definition: PxConvexMeshDesc.h:242
PxU16 quantizedCount
Maximum number of vertices after quantization. The quantization is done during the vertex cleaning ph...
Definition: PxConvexMeshDesc.h:219
uint16_t PxU16
Definition: PxSimpleTypes.h:73
uint32_t PxU32
Definition: Px.h:48
#define PX_INLINE
Definition: PxPreprocessor.h:336
Definition: PxCoreUtilityTypes.h:83
PxConvexFlags flags
Flags bits, combined from values of the enum PxConvexFlag.
Definition: PxConvexMeshDesc.h:193
PxBoundedData polygons
Polygons data in PxBoundedData format.
Definition: PxConvexMeshDesc.h:174
3 Element vector class.
Definition: PxVec3.h:49