RavEngine
Loading...
Searching...
No Matches
PxSoftBodyExt.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_SOFT_BODY_EXT_H
30#define PX_SOFT_BODY_EXT_H
35#include "foundation/PxTransform.h"
36#include "PxSoftBody.h"
37
38#if !PX_DOXYGEN
39namespace physx
40{
41#endif
42
43struct PxCookingParams;
44class PxSimpleTriangleMesh;
45class PxInsertionCallback;
46class PxSoftBodyMesh;
47
52{
53public:
68 static void updateMass(PxSoftBody& softBody, const PxReal density, const PxReal maxInvMassRatio);
69
84 static void setMass(PxSoftBody& softBody, const PxReal mass, const PxReal maxInvMassRatio);
85
101 static void transform(PxSoftBody& softBody, const PxTransform& transform, const PxReal scale);
102
112 static void updateEmbeddedCollisionMesh(PxSoftBody& softBody);
113
123 static void commit(PxSoftBody& softBody, PxSoftBodyDataFlags flags, bool flush = false);
124
136 static PxSoftBodyMesh* createSoftBodyMesh(const PxCookingParams& params, const PxSimpleTriangleMesh& surfaceMesh, PxU32 numVoxelsAlongLongestAABBAxis, PxInsertionCallback& insertionCallback, const bool validate = true);
137
149 static PxSoftBodyMesh* createSoftBodyMeshNoVoxels(const PxCookingParams& params, const PxSimpleTriangleMesh& surfaceMesh, PxInsertionCallback& insertionCallback, PxReal maxWeightRatioInTet = 1.5f, const bool validate = true);
150
151
167 const PxFEMSoftBodyMaterial& material, PxCudaContextManager& cudaContextManager, PxReal density = 100.0f, PxU32 solverIterationCount = 30,
168 const PxFEMParameters& femParams = PxFEMParameters(), PxReal scale = 1.0f);
169
170
187 static PxSoftBody* createSoftBodyBox(const PxTransform& transform, const PxVec3& boxDimensions, const PxFEMSoftBodyMaterial& material,
188 PxCudaContextManager& cudaContextManager, PxReal maxEdgeLength = -1.0f, PxReal density = 100.0f, PxU32 solverIterationCount = 30,
189 const PxFEMParameters& femParams = PxFEMParameters(), PxU32 numVoxelsAlongLongestAABBAxis = 10, PxReal scale = 1.0f);
190};
191
192#if !PX_DOXYGEN
193} // namespace physx
194#endif
195
197#endif
Material class to represent a set of softbody FEM material properties.
Definition PxFEMSoftBodyMaterial.h:49
Container for bitfield flag variables associated with a specific enum type.
Definition PxFlags.h:73
Callback interface that permits TriangleMesh, Heightfield, ConvexMesh or BVH to be used directly with...
Definition PxInsertionCallback.h:57
A structure describing a triangle mesh.
Definition PxSimpleTriangleMesh.h:83
utility functions for use with PxSoftBody and subclasses
Definition PxSoftBodyExt.h:52
static PxSoftBodyMesh * createSoftBodyMeshNoVoxels(const PxCookingParams &params, const PxSimpleTriangleMesh &surfaceMesh, PxInsertionCallback &insertionCallback, PxReal maxWeightRatioInTet=1.5f, const bool validate=true)
Creates a full SoftBody mesh matching the shape given as input. Uses the same surface-matching mesh f...
Definition ExtSoftBodyExt.cpp:351
static PxSoftBody * createSoftBodyFromMesh(PxSoftBodyMesh *softBodyMesh, const PxTransform &transform, const PxFEMSoftBodyMaterial &material, PxCudaContextManager &cudaContextManager, PxReal density=100.0f, PxU32 solverIterationCount=30, const PxFEMParameters &femParams=PxFEMParameters(), PxReal scale=1.0f)
Creates a SoftBody instance from a SoftBody mesh.
Definition ExtSoftBodyExt.cpp:368
static void commit(PxSoftBody &softBody, PxSoftBodyDataFlags flags, bool flush=false)
Uploads prepared SoftBody data to the GPU. It ensures that the embedded collision mesh matches the si...
Definition ExtSoftBodyExt.cpp:311
static PxSoftBody * createSoftBodyBox(const PxTransform &transform, const PxVec3 &boxDimensions, const PxFEMSoftBodyMaterial &material, PxCudaContextManager &cudaContextManager, PxReal maxEdgeLength=-1.0f, PxReal density=100.0f, PxU32 solverIterationCount=30, const PxFEMParameters &femParams=PxFEMParameters(), PxU32 numVoxelsAlongLongestAABBAxis=10, PxReal scale=1.0f)
Creates a SoftBody instance with a box shape.
Definition ExtSoftBodyExt.cpp:398
static void updateEmbeddedCollisionMesh(PxSoftBody &softBody)
Updates the collision mesh's vertex positions to match the simulation mesh's transformation and scale...
Definition ExtSoftBodyExt.cpp:272
static PxSoftBodyMesh * createSoftBodyMesh(const PxCookingParams &params, const PxSimpleTriangleMesh &surfaceMesh, PxU32 numVoxelsAlongLongestAABBAxis, PxInsertionCallback &insertionCallback, const bool validate=true)
Creates a full SoftBody mesh matching the shape given as input. Uses a voxel mesh for FEM simulation ...
Definition ExtSoftBodyExt.cpp:328
static void setMass(PxSoftBody &softBody, const PxReal mass, const PxReal maxInvMassRatio)
Computes the SoftBody's vertex masses such that the sum of all masses is equal to the provided mass.
Definition ExtSoftBodyExt.cpp:178
static void updateMass(PxSoftBody &softBody, const PxReal density, const PxReal maxInvMassRatio)
Computes the SoftBody's vertex masses from the provided density and the volume of the tetrahedra.
Definition ExtSoftBodyExt.cpp:134
static void transform(PxSoftBody &softBody, const PxTransform &transform, const PxReal scale)
Transforms a SoftBody.
Definition ExtSoftBodyExt.cpp:184
A softbody mesh, containing structures to store collision shape, simulation shape and deformation sta...
Definition PxTetrahedronMesh.h:214
Represents a FEM softbody including everything to calculate its definition like geometry and material...
Definition PxSoftBody.h:104
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
3 Element vector class.
Definition PxVec3.h:50
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Structure describing parameters affecting mesh cooking.
Definition PxCooking.h:185
Set of parameters to control the sleeping and collision behavior of FEM based objects.
Definition PxFEMParameter.h:45