RavEngine
Loading...
Searching...
No Matches
PxConvexMeshDesc.h
1// Redistribution and use in source and binary forms, with or without
2// modification, are permitted provided that the following conditions
3// are met:
4// * Redistributions of source code must retain the above copyright
5// notice, this list of conditions and the following disclaimer.
6// * Redistributions in binary form must reproduce the above copyright
7// notice, this list of conditions and the following disclaimer in the
8// documentation and/or other materials provided with the distribution.
9// * Neither the name of NVIDIA CORPORATION nor the names of its
10// contributors may be used to endorse or promote products derived
11// from this software without specific prior written permission.
12//
13// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
14// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
17// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24//
25// Copyright (c) 2008-2022 NVIDIA Corporation. All rights reserved.
26// Copyright (c) 2004-2008 AGEIA Technologies, Inc. All rights reserved.
27// Copyright (c) 2001-2004 NovodeX AG. All rights reserved.
28
29#ifndef PX_CONVEX_MESH_DESC_H
30#define PX_CONVEX_MESH_DESC_H
35#include "foundation/PxVec3.h"
36#include "foundation/PxFlags.h"
37#include "common/PxCoreUtilityTypes.h"
38#include "geometry/PxConvexMesh.h"
39#include "PxSDFDesc.h"
40
41#if !PX_DOXYGEN
42namespace physx
43{
44#endif
49{
50 enum Enum
51 {
58
66 eCOMPUTE_CONVEX = (1<<1),
67
77
85 eQUANTIZE_INPUT = (1 << 3),
86
95
113 ePLANE_SHIFTING = (1 << 5),
114
120
126 eGPU_COMPATIBLE = (1 << 7),
127
134 eSHIFT_VERTICES = (1 << 8)
135 };
136};
137
144PX_FLAGS_OPERATORS(PxConvexFlag::Enum,PxU16)
145
146
156{
157public:
158
165
175
187
194
210
221
232
239
247 PX_INLINE void setToDefault();
248
249
255 PX_INLINE bool isValid() const;
256};
257
258PX_INLINE PxConvexMeshDesc::PxConvexMeshDesc() //constructor sets to default
259: vertexLimit(255), polygonLimit(255), quantizedCount(255), sdfDesc(NULL)
260{
261
262}
263
268
270{
271 // Check geometry
272 if(points.count < 3 || //at least 1 trig's worth of points
273 (points.count > 0xffff && flags & PxConvexFlag::e16_BIT_INDICES))
274 return false;
275 if(!points.data)
276 return false;
277 if(points.stride < sizeof(PxVec3)) //should be at least one point's worth of data
278 return false;
279 if (quantizedCount < 4)
280 return false;
281
282 // Check topology
283 if(polygons.data)
284 {
285 if(polygons.count < 4) // we require 2 neighbors for each vertex - 4 polygons at least
286 return false;
287
288 if(!indices.data) // indices must be provided together with polygons
289 return false;
290
291 PxU32 limit = (flags & PxConvexFlag::e16_BIT_INDICES) ? sizeof(PxU16) : sizeof(PxU32);
292 if(indices.stride < limit)
293 return false;
294
295 limit = sizeof(PxHullPolygon);
296 if(polygons.stride < limit)
297 return false;
298 }
299 else
300 {
301 // We can compute the hull from the vertices
303 return false; // If the mesh is convex and we're not allowed to compute the hull,
304 // you have to provide it completely (geometry & topology).
305 }
306
308 {
309 return false;
310 }
311
313 {
314 return false;
315 }
316
317 if(vertexLimit > 255)
318 {
319 return false;
320 }
321
322 if (polygonLimit < 4)
323 {
324 return false;
325 }
326
327 if (polygonLimit > 255)
328 {
329 return false;
330 }
331
332 if (sdfDesc && !sdfDesc->isValid())
333 {
334 return false;
335 }
336
337 return true;
338}
339
340#if !PX_DOXYGEN
341} // namespace physx
342#endif
343
345#endif
Descriptor class for #PxConvexMesh.
Definition PxConvexMeshDesc.h:156
PxConvexFlags flags
Flags bits, combined from values of the enum ::PxConvexFlag.
Definition PxConvexMeshDesc.h:193
PX_INLINE PxConvexMeshDesc()
constructor sets to default.
Definition PxConvexMeshDesc.h:258
PxU16 vertexLimit
Limits the number of vertices of the result convex mesh. Hard maximum limit is 255 and minimum limit ...
Definition PxConvexMeshDesc.h:209
PX_INLINE void setToDefault()
(re)sets the structure to the default.
Definition PxConvexMeshDesc.h:264
PxU16 quantizedCount
Maximum number of vertices after quantization. The quantization is done during the vertex cleaning ph...
Definition PxConvexMeshDesc.h:231
PxSDFDesc * sdfDesc
SDF descriptor. When this descriptor is set, signed distance field is calculated for this convex mesh...
Definition PxConvexMeshDesc.h:238
PX_INLINE bool isValid() const
Returns true if the descriptor is valid.
Definition PxConvexMeshDesc.h:269
PxBoundedData indices
Polygon indices data in PxBoundedData format.
Definition PxConvexMeshDesc.h:186
PxBoundedData polygons
Polygons data in PxBoundedData format.
Definition PxConvexMeshDesc.h:174
PxU16 polygonLimit
Limits the number of polygons of the result convex mesh. Hard maximum limit is 255 and minimum limit ...
Definition PxConvexMeshDesc.h:220
PxBoundedData points
Vertex positions data in PxBoundedData format.
Definition PxConvexMeshDesc.h:164
Container for bitfield flag variables associated with a specific enum type.
Definition PxFlags.h:73
A structure describing signed distance field for mesh.
Definition PxSDFDesc.h:70
PX_INLINE bool isValid() const
Returns true if the descriptor is valid.
Definition PxSDFDesc.h:175
3 Element vector class.
Definition PxVec3.h:50
#define PX_INLINE
Definition PxPreprocessor.h:320
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
PxFlags< PxConvexFlag::Enum, PxU16 > PxConvexFlags
collection of set bits defined in PxConvexFlag.
Definition PxConvexMeshDesc.h:143
Definition PxCoreUtilityTypes.h:96
Flags which describe the format and behavior of a convex mesh.
Definition PxConvexMeshDesc.h:49
Enum
Definition PxConvexMeshDesc.h:51
@ eCOMPUTE_CONVEX
Definition PxConvexMeshDesc.h:66
@ ePLANE_SHIFTING
Enables plane shifting vertex limit algorithm.
Definition PxConvexMeshDesc.h:113
@ eSHIFT_VERTICES
Convex hull input vertices are shifted to be around origin to provide better computation stability....
Definition PxConvexMeshDesc.h:134
@ eDISABLE_MESH_VALIDATION
Disables the convex mesh validation to speed-up hull creation. Please use separate validation functio...
Definition PxConvexMeshDesc.h:94
@ eFAST_INERTIA_COMPUTATION
Inertia tensor computation is faster using SIMD code, but the precision is lower, which may result in...
Definition PxConvexMeshDesc.h:119
@ e16_BIT_INDICES
Definition PxConvexMeshDesc.h:57
@ eCHECK_ZERO_AREA_TRIANGLES
Checks and removes almost zero-area triangles during convex hull computation. The rejected area size ...
Definition PxConvexMeshDesc.h:76
@ eQUANTIZE_INPUT
Quantizes the input vertices using the k-means clustering.
Definition PxConvexMeshDesc.h:85
@ eGPU_COMPATIBLE
Convex hulls are created with respect to GPU simulation limitations. Vertex limit and polygon limit i...
Definition PxConvexMeshDesc.h:126
Polygon data.
Definition PxConvexMesh.h:50
PxU32 stride
The offset in bytes between consecutive samples in the data.
Definition PxCoreUtilityTypes.h:51