RavEngine
Loading...
Searching...
No Matches
DyFEMCloth.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
27
28#ifndef PXD_FEMCLOTH_H
29#define PXD_FEMCLOTH_H
30
31#include "foundation/PxSimpleTypes.h"
32#include "DyFEMClothCore.h"
33#include "PxvGeometry.h"
34
35namespace physx
36{
37 namespace Sc
38 {
39 class FEMClothSim;
40 }
41
42 namespace Dy
43 {
44
45 typedef size_t FEMClothHandle;
46
47 struct FEMClothCore;
48
50 {
51 PX_NOCOPY(FEMCloth)
52
53 public:
55 mSim(sim), mCore(core), mElementId(0xffffffff), mGpuRemapId(0xffffffff)
56 {}
57
58 ~FEMCloth() {}
59
60 //PX_FORCE_INLINE PxReal getMaxPenetrationBias() const { return mCore.maxPenBias; }
61
62 PX_FORCE_INLINE Sc::FEMClothSim* getFEMClothSim() const { return mSim; }
63
64 PX_FORCE_INLINE void setGpuRemapId(const PxU32 remapId)
65 {
66 mGpuRemapId = remapId;
67 PxTriangleMeshGeometryLL& geom = mShapeCore->mGeometry.get<PxTriangleMeshGeometryLL>();
68 geom.materialsLL.gpuRemapId = remapId;
69 }
70
71 PX_FORCE_INLINE PxTriangleMesh* getTriangleMesh()
72 {
73 PxTriangleMeshGeometryLL& geom = mShapeCore->mGeometry.get<PxTriangleMeshGeometryLL>();
74 return geom.triangleMesh;
75 }
76
77 PX_FORCE_INLINE PxU32 getGpuRemapId() { return mGpuRemapId; }
78
79 PX_FORCE_INLINE void setElementId(const PxU32 elementId) { mElementId = elementId; }
80 PX_FORCE_INLINE PxU32 getElementId() { return mElementId; }
81
82 PX_FORCE_INLINE PxsShapeCore& getShapeCore() { return *mShapeCore; }
83 PX_FORCE_INLINE void setShapeCore(PxsShapeCore* shapeCore) { mShapeCore = shapeCore; }
84
85
86 PX_FORCE_INLINE const FEMClothCore& getCore() const { return mCore; }
87 PX_FORCE_INLINE FEMClothCore& getCore() { return mCore; }
88
89 PX_FORCE_INLINE PxU16 getIterationCounts() const { return mCore.solverIterationCounts; }
90
91 void addAttachmentHandle(PxU32 handle);
92 void removeAttachmentHandle(PxU32 handle);
93
94 //These variables are used in the constraint partition
95 PxU16 maxSolverFrictionProgress;
96 PxU16 maxSolverNormalProgress;
97 PxU32 solverProgress;
98 PxU8 numTotalConstraints;
99
100 PxArray<PxU32> mAttachmentHandles;
101 PxArray<PxU32> mClothClothAttachments;
102 private:
103
104 Sc::FEMClothSim* mSim;
105 FEMClothCore& mCore;
106 PxsShapeCore* mShapeCore;
107 PxU32 mElementId; //this is used for the bound array, contactDist
108 PxU32 mGpuRemapId;
109 };
110
112 {
113 FEMCloth* femCloth;
114 };
115
116 PX_FORCE_INLINE FEMCloth* getFEMCloth(FEMClothHandle handle)
117 {
118 return reinterpret_cast<FEMCloth*>(handle);
119 }
120
121 PX_FORCE_INLINE void FEMCloth::addAttachmentHandle(PxU32 handle)
122 {
123 mAttachmentHandles.pushBack(handle);
124 }
125 PX_FORCE_INLINE void FEMCloth::removeAttachmentHandle(PxU32 handle)
126 {
127 for (PxU32 i = 0; i < mAttachmentHandles.size(); ++i)
128 {
129 if (mAttachmentHandles[i] == handle)
130 {
131 mAttachmentHandles.replaceWithLast(i);
132 }
133 }
134 }
135 }
136}
137
138#endif
Definition DyFEMCloth.h:50
Definition PxArray.h:53
PX_FORCE_INLINE uint32_t size() const
Definition PxArray.h:242
PX_FORCE_INLINE T & pushBack(const T &a)
Definition PxArray.h:296
PX_INLINE void replaceWithLast(uint32_t i)
Definition PxArray.h:345
PxTriangleMesh * triangleMesh
A reference to the mesh object.
Definition PxTriangleMeshGeometry.h:138
A triangle mesh, also called a 'polygon soup'.
Definition PxTriangleMesh.h:118
Definition ScFEMClothSim.h:42
#define PX_FORCE_INLINE
Definition PxPreprocessor.h:335
Sorts an array of objects in ascending order, assuming that the predicate implements the < operator:
Definition PxBoxController.h:39
Definition DyFEMClothCore.h:47
Definition DyFEMCloth.h:112
Definition PxvGeometry.h:115
Definition PxvGeometry.h:221