RavEngine
Loading...
Searching...
No Matches
PxSimpleTriangleMesh.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_SIMPLE_TRIANGLE_MESH_H
30#define PX_SIMPLE_TRIANGLE_MESH_H
35#include "foundation/PxVec3.h"
36#include "foundation/PxFlags.h"
37#include "common/PxCoreUtilityTypes.h"
38#include "common/PxPhysXCommonConfig.h"
39
40#if !PX_DOXYGEN
41namespace physx
42{
43#endif
44
49{
50 enum Enum
51 {
65 eFLIPNORMALS = (1<<0),
66 e16_BIT_INDICES = (1<<1)
67 };
68};
69
76PX_FLAGS_OPERATORS(PxMeshFlag::Enum,PxU16)
77
78
79
83{
84public:
85
90
107
112
120 PX_INLINE void setToDefault();
124 PX_INLINE bool isValid() const;
125};
126
127
131
136
138{
139 // Check geometry
140 if(points.count > 0xffff && flags & PxMeshFlag::e16_BIT_INDICES)
141 return false;
142 if(!points.data)
143 return false;
144 if(points.stride < sizeof(PxVec3)) //should be at least one point's worth of data
145 return false;
146
147 // Check topology
148 // The triangles pointer is not mandatory
149 if(triangles.data)
150 {
151 // Indexed mesh
152 PxU32 limit = (flags & PxMeshFlag::e16_BIT_INDICES) ? sizeof(PxU16)*3 : sizeof(PxU32)*3;
153 if(triangles.stride < limit)
154 return false;
155 }
156 return true;
157}
158
159#if !PX_DOXYGEN
160} // namespace physx
161#endif
162
164#endif
Container for bitfield flag variables associated with a specific enum type.
Definition PxFlags.h:73
A structure describing a triangle mesh.
Definition PxSimpleTriangleMesh.h:83
PX_INLINE PxSimpleTriangleMesh()
constructor sets to default.
Definition PxSimpleTriangleMesh.h:128
PxBoundedData triangles
Pointer to first triangle.
Definition PxSimpleTriangleMesh.h:106
PxBoundedData points
Pointer to first vertex point.
Definition PxSimpleTriangleMesh.h:89
PX_INLINE bool isValid() const
returns true if the current settings are valid
Definition PxSimpleTriangleMesh.h:137
PxMeshFlags flags
Flags bits, combined from values of the enum ::PxMeshFlag.
Definition PxSimpleTriangleMesh.h:111
PX_INLINE void setToDefault()
(re)sets the structure to the default.
Definition PxSimpleTriangleMesh.h:132
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< PxMeshFlag::Enum, PxU16 > PxMeshFlags
collection of set bits defined in PxMeshFlag.
Definition PxSimpleTriangleMesh.h:75
Definition PxCoreUtilityTypes.h:96
Enum with flag values to be used in PxSimpleTriangleMesh::flags.
Definition PxSimpleTriangleMesh.h:49
Enum
Definition PxSimpleTriangleMesh.h:51
@ e16_BIT_INDICES
Denotes the use of 16-bit vertex indices.
Definition PxSimpleTriangleMesh.h:66
@ eFLIPNORMALS
Specifies if the SDK should flip normals.
Definition PxSimpleTriangleMesh.h:65
PxU32 stride
The offset in bytes between consecutive samples in the data.
Definition PxCoreUtilityTypes.h:51