RavEngine
Loading...
Searching...
No Matches
PxTetrahedronMeshDesc.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_TETRAHEDRON_MESH_DESC_H
30#define PX_TETRAHEDRON_MESH_DESC_H
35#include "PxPhysXConfig.h"
36#include "foundation/PxVec3.h"
37#include "foundation/PxFlags.h"
38#include "common/PxCoreUtilityTypes.h"
39#include "geometry/PxSimpleTriangleMesh.h"
40#include "foundation/PxArray.h"
41
42#if !PX_DOXYGEN
43namespace physx
44{
45#endif
52 {
53 public:
54
63
64
82
87
104
105
110
117
122 {
123 points.count = 0;
124 points.stride = 0;
125 points.data = NULL;
126
127 tetrahedrons.count = 0;
129 tetrahedrons.data = NULL;
130
131 tetsPerElement = 1;
132 }
133
138 {
139 points.count = meshVertices.size();
140 points.stride = sizeof(float) * 3;
141 points.data = meshVertices.begin();
142
143 tetrahedrons.count = meshTetIndices.size() / 4;
144 tetrahedrons.stride = sizeof(int) * 4;
145 tetrahedrons.data = meshTetIndices.begin();
146
147 if (meshFormat == eTET_MESH)
148 tetsPerElement = 1;
149 else
150 tetsPerElement = 6;
151 }
152
153 PX_INLINE bool isValid() const
154 {
155 // Check geometry of the collision mesh
156 if (points.count < 4) //at least 1 tetrahedron's worth of points
157 return false;
158 if ((!tetrahedrons.data) && (points.count % 4)) // Non-indexed mesh => we must ensure the geometry defines an implicit number of tetrahedrons // i.e. numVertices can't be divided by 4
159 return false;
160 if (points.count > 0xffff && flags & PxMeshFlag::e16_BIT_INDICES)
161 return false;
162 if (!points.data)
163 return false;
164 if (points.stride < sizeof(PxVec3)) //should be at least one point's worth of data
165 return false;
166
167 //add more validity checks here
168 if (materialIndices.data && materialIndices.stride < sizeof(PxFEMMaterialTableIndex))
169 return false;
170
171 // The tetrahedrons pointer is not mandatory
172 if (tetrahedrons.data)
173 {
174 // Indexed collision mesh
175 PxU32 limit = (flags & PxMeshFlag::e16_BIT_INDICES) ? sizeof(PxU16) * 4 : sizeof(PxU32) * 4;
176 if (tetrahedrons.stride < limit)
177 return false;
178 }
179
180 //The model can only be either a tetmesh (1 tet per element), or have 5 or 6 tets per hex element, otherwise invalid.
181 if (tetsPerElement != 1 && tetsPerElement != 6)
182 return false;
183
184 return true;
185 }
186 };
187
189 //\brief Descriptor class for #PxSoftBodyMesh (contains only additional data used for softbody simulation).
190
191 //@see PxSoftBodyMesh PxShape
192 //*/
194 {
195 public:
201
206 {
207 vertexToTet.count = 0;
209 vertexToTet.data = NULL;
210 }
211
216 {
217 vertexToTet.count = vertToTet.size();
218 vertexToTet.stride = sizeof(PxI32);
219 vertexToTet.data = vertToTet.begin();
220 }
221
222 PX_INLINE bool isValid() const
223 {
224 return true;
225 }
226 };
227
228#if !PX_DOXYGEN
229} // namespace physx
230#endif
231
233#endif
Definition PxArray.h:53
PX_FORCE_INLINE uint32_t size() const
Definition PxArray.h:242
PX_FORCE_INLINE ConstIterator begin() const
Definition PxArray.h:176
‍**
Definition PxTetrahedronMeshDesc.h:194
PxSoftBodySimulationDataDesc(physx::PxArray< physx::PxI32 > &vertToTet)
Constructor to build a simulation description with a defined vertex to tetrahedron mapping.
Definition PxTetrahedronMeshDesc.h:215
PxSoftBodySimulationDataDesc()
Constructor to build an empty simulation description.
Definition PxTetrahedronMeshDesc.h:205
PxBoundedData vertexToTet
Pointer to first index of tetrahedron that contains the vertex at the same location in the vertex buf...
Definition PxTetrahedronMeshDesc.h:200
Descriptor class for #PxTetrahedronMesh (contains only pure geometric data).
Definition PxTetrahedronMeshDesc.h:52
PxMeshFormat
Defines the tetrahedron structure of a mesh.
Definition PxTetrahedronMeshDesc.h:59
@ eTET_MESH
Normal tetmesh with arbitrary tetrahedra.
Definition PxTetrahedronMeshDesc.h:60
@ eHEX_MESH
6 tetrahedra in a row will form a hexahedron
Definition PxTetrahedronMeshDesc.h:61
PxBoundedData points
Pointer to first vertex point.
Definition PxTetrahedronMeshDesc.h:86
PxTetrahedronMeshDesc()
Constructor to build an empty tetmesh description.
Definition PxTetrahedronMeshDesc.h:121
PxMeshFlags flags
Flags bits, combined from values of the enum ::PxMeshFlag.
Definition PxTetrahedronMeshDesc.h:109
PxTypedStridedData< PxFEMMaterialTableIndex > materialIndices
Definition PxTetrahedronMeshDesc.h:81
PxU16 tetsPerElement
Used for simulation meshes only. Defines if this tet mesh should be simulated as a tet mesh,...
Definition PxTetrahedronMeshDesc.h:116
PxBoundedData tetrahedrons
Pointer to first tetrahedron.
Definition PxTetrahedronMeshDesc.h:103
PxTetrahedronMeshDesc(physx::PxArray< physx::PxVec3 > &meshVertices, physx::PxArray< physx::PxU32 > &meshTetIndices, const PxTetrahedronMeshDesc::PxMeshFormat meshFormat=eTET_MESH)
Constructor to build a tetmeshdescription that links to the vertices and indices provided.
Definition PxTetrahedronMeshDesc.h:137
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
Definition PxCoreUtilityTypes.h:96
@ e16_BIT_INDICES
Denotes the use of 16-bit vertex indices.
Definition PxSimpleTriangleMesh.h:66
PxU32 stride
The offset in bytes between consecutive samples in the data.
Definition PxCoreUtilityTypes.h:51
Definition PxCoreUtilityTypes.h:69