RavEngine
Loading...
Searching...
No Matches
ScFEMClothCore.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
30#ifndef PX_PHYSICS_SCP_FEMCLOTH_CORE
31#define PX_PHYSICS_SCP_FEMCLOTH_CORE
32
33#include "foundation/PxPreprocessor.h"
34#if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION
35#include "PxFEMCloth.h"
36#endif
37#include "PxFEMParameter.h"
38#include "../../lowleveldynamics/include/DyFEMClothCore.h"
39#include "foundation/PxAssert.h"
40#include "ScActorCore.h"
41#include "ScShapeCore.h"
42#include "PxFiltering.h"
43#include "ScRigidCore.h" //KS - required for ShapeChangeNotifyFlags. Ideally, we should move that to a separate shared file
44#include "PxConeLimitedConstraint.h"
45
46namespace physx
47{
48 namespace Sc
49 {
50 class FEMClothSim;
51 //class BodyCore;
52
53 class FEMClothCore : public ActorCore
54 {
55 //= ATTENTION! =====================================================================================
56 // Changing the data layout of this class breaks the binary serialization format. See comments for
57 // PX_BINARY_SERIAL_VERSION. If a modification is required, please adjust the getBinaryMetaData
58 // function. If the modification is made on a custom branch, please change PX_BINARY_SERIAL_VERSION
59 // accordingly.
60 //==================================================================================================
61
62 //---------------------------------------------------------------------------------
63 // Construction, destruction & initialization
64 //---------------------------------------------------------------------------------
65
66 // PX_SERIALIZATION
67 public:
68 FEMClothCore(const PxEMPTY) : ActorCore(PxEmpty) {}
69 //static void getBinaryMetaData(PxOutputStream& stream);
70
71 //~PX_SERIALIZATION
74
75 //---------------------------------------------------------------------------------
76 // External API
77 //---------------------------------------------------------------------------------
78 //void commit(PxBuffer& positionInvMassBuf, const PxTransform& transform, const PxReal density, const PxReal scale, const PxReal maxInvMass);
79
80 PxFEMParameters getParameter() const;
81 void setParameter(const PxFEMParameters& paramters);
82
83 void addRigidFilter(Sc::BodyCore* core, PxU32 vertId);
84 void removeRigidFilter(Sc::BodyCore* core, PxU32 vertId);
85
86 PxU32 addRigidAttachment(Sc::BodyCore* core, PxU32 vertId, const PxVec3& actorSpacePose, PxConeLimitedConstraint* constraint);
87 void removeRigidAttachment(Sc::BodyCore* core, PxU32 handle);
88
89 void addTriRigidFilter(Sc::BodyCore* core, PxU32 triIdx);
90 void removeTriRigidFilter(Sc::BodyCore* core, PxU32 triIdx);
91
92 PxU32 addTriRigidAttachment(Sc::BodyCore* core, PxU32 triIdx, const PxVec4& barycentric,
93 const PxVec3& actorSpacePose, PxConeLimitedConstraint* constraint);
94 void removeTriRigidAttachment(Sc::BodyCore* core, PxU32 handle);
95
96 void addClothFilter(Sc::FEMClothCore* otherCore, PxU32 otherTriIdx, PxU32 triIdx);
97 void removeClothFilter(Sc::FEMClothCore* otherCore, PxU32 otherTriIdx0, PxU32 triIdx);
98
99 PxU32 addClothAttachment(Sc::FEMClothCore* otherCore, PxU32 otherTriIdx, const PxVec4& otherTriBarycentric, PxU32 triIdx,
100 const PxVec4& triBarycentric);
101 void removeClothAttachment(Sc::FEMClothCore* otherCore, PxU32 handle);
102
103 void setDrag(const PxReal v) { mCore.drag = v; }
104 PxReal getDrag() const { return mCore.drag; }
105
106 void setLift(const PxReal v) { mCore.lift = v; }
107 PxReal getLift() const { return mCore.lift; }
108
109 void setWind(const PxVec3& wind) { mCore.wind = wind; }
110 PxVec3 getWind() const { return mCore.wind; }
111
112 void setAirDensity(const float airDensity) { mCore.airDensity = airDensity; }
113 PxReal getAirDensity() const { return mCore.airDensity; }
114
115 void setBendingScales(const PxReal* const bendingScales, PxU32 nbElements);
116 const PxReal* getBendingScales() const;
117 PxU32 getNbBendingScales() const { return mCore.mBendingScales.size(); }
118
119 void setMaxVelocity(const float maxVelocity) { mCore.maxVelocity = maxVelocity; }
120 PxReal getMaxVelocity() const { return mCore.maxVelocity; }
121
122 void setBendingActivationAngle(const PxReal angle) { mCore.mBendingActivationAngle = angle; }
123 PxReal getBendingActivationAngle() const { return mCore.mBendingActivationAngle; }
124
125 void setNbCollisionPairUpdatesPerTimestep(const PxU32 frequency) { mCore.NbCollisionPairUpdatesPerTimestep = frequency; }
126 PxU32 getNbCollisionPairUpdatesPerTimestep() const { return mCore.NbCollisionPairUpdatesPerTimestep; }
127
128 void setNbCollisionSubsteps(const PxU32 frequency) { mCore.nbCollisionSubsteps = frequency; }
129 PxU32 getNbCollisionSubsteps() const { return mCore.nbCollisionSubsteps; }
130
131 PxU16 getSolverIterationCounts() const { return mCore.solverIterationCounts; }
132 void setSolverIterationCounts(PxU16 c);
133 PxActor* getPxActor() const;
134
135 void attachShapeCore(ShapeCore* shapeCore);
136
137 PxReal getWakeCounter() const;
138 void setWakeCounter(const PxReal v);
139 void setWakeCounterInternal(const PxReal v);
140
141 //---------------------------------------------------------------------------------
142 // Internal API
143 //---------------------------------------------------------------------------------
144 public:
145
146 FEMClothSim* getSim() const;
147
148 PX_FORCE_INLINE const Dy::FEMClothCore& getCore() const { return mCore; }
149
150 PX_FORCE_INLINE Dy::FEMClothCore& getCore() { return mCore; }
151
152 static PX_FORCE_INLINE FEMClothCore& getFEMClothCore(FEMClothCore& core)
153 {
154 size_t offset = PX_OFFSET_OF_RT(FEMClothCore, mCore);
155 return *reinterpret_cast<FEMClothCore*>(reinterpret_cast<PxU8*>(&core) - offset);
156 }
157
158 void setSimulationFilterData(const PxFilterData& data);
159
160 PxFilterData getSimulationFilterData() const;
161
162#if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION
163 PxFEMClothFlags getFlags() const { return mCore.mFlags; }
164
165 void setFlags(PxFEMClothFlags flags) { mCore.mFlags = flags; }
166#endif
167
168 PxReal getRestVolumeScale() const { return mCore.mRestVolumeScale; }
169
170 void setRestVolumeScale(PxReal scale) { mCore.mRestVolumeScale = scale; }
171
172 PX_FORCE_INLINE PxU64& getGpuMemStat() { return mGpuMemStat; }
173
174 void onShapeChange(ShapeCore& shape, ShapeChangeNotifyFlags notifyFlags);
175
176 private:
177 Dy::FEMClothCore mCore;
178 PxFilterData mFilterData;
179 PxU64 mGpuMemStat;
180 };
181
182 } // namespace Sc
183}
184
185#endif
PxActor is the base class for the main simulation objects in the physics SDK.
Definition PxActor.h:201
PX_FORCE_INLINE uint32_t size() const
Definition PxArray.h:242
3 Element vector class.
Definition PxVec3.h:50
Definition PxVec4.h:50
Definition ScActorCore.h:48
Definition ScBodyCore.h:49
Definition ScFEMClothCore.h:54
Definition ScFEMClothSim.h:42
Definition ScShapeCore.h:46
#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
PxEMPTY
Definition Px.h:87
Definition DyFEMClothCore.h:47
A constraint descriptor for limiting movement to a conical region.
Definition PxConeLimitedConstraint.h:48
Set of parameters to control the sleeping and collision behavior of FEM based objects.
Definition PxFEMParameter.h:45
PxFilterData is user-definable data which gets passed into the collision filtering shader and/or call...
Definition PxFiltering.h:365