RavEngine
Loading...
Searching...
No Matches
NpFEMCloth.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_PHYSICS_NP_FEMCLOTH
30#define PX_PHYSICS_NP_FEMCLOTH
31
32#if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION
33#include "PxFEMCloth.h"
34#endif
35#include "ScFEMClothCore.h"
36#include "NpActorTemplate.h"
37
38namespace physx
39{
40 class NpShape;
41
42#if PX_ENABLE_FEATURES_UNDER_CONSTRUCTION
43 class NpFEMCloth : public NpActorTemplate<PxFEMCloth>
44 {
45 public:
46 NpFEMCloth(PxCudaContextManager& cudaContextManager);
47 NpFEMCloth(PxBaseFlags baseFlags, PxCudaContextManager& cudaContextManager);
48
49 virtual ~NpFEMCloth() {}
50
51 void exportData(PxSerializationContext& /*context*/) const {}
52
53 //external API
54 virtual PxActorType::Enum getType() const { return PxActorType::eFEMCLOTH; }
55
56 virtual PxBounds3 getWorldBounds(float inflation = 1.01f) const;
57
58 virtual void setFEMClothFlag(PxFEMClothFlag::Enum flag, bool val);
59 virtual void setFEMClothFlags(PxFEMClothFlags flags);
60 virtual PxFEMClothFlags getFEMClothFlag() const;
61
62 virtual void setDrag(const PxReal drag);
63 virtual PxReal getDrag() const;
64
65 virtual void setLift(const PxReal lift);
66 virtual PxReal getLift() const;
67
68 virtual void setWind(const PxVec3& wind);
69 virtual PxVec3 getWind() const;
70
71 virtual void setAirDensity(const PxReal wind);
72 virtual PxReal getAirDensity() const;
73
74 virtual void setParameter(const PxFEMParameters& paramters);
75 virtual PxFEMParameters getParameter() const;
76
77 virtual void setRestVolumeScale(const PxReal scale);
78 virtual PxReal getRestVolumeScale() const;
79
80 virtual void setBendingScales(const PxReal* const bendingScale, PxU32 nbElements);
81 virtual const PxReal* getBendingScales() const;
82 virtual PxU32 getNbBendingScales() const;
83
84 virtual void setMaxVelocity(const PxReal v);
85 virtual PxReal getMaxVelocity() const;
86
87 virtual void setBendingActivationAngle(const PxReal angle);
88 virtual PxReal getBendingActivationAngle() const;
89
90 virtual void setNbCollisionPairUpdatesPerTimestep(const PxU32 frequency);
91 virtual PxU32 getNbCollisionPairUpdatesPerTimestep() const;
92
93 virtual void setNbCollisionSubsteps(const PxU32 frequency);
94 virtual PxU32 getNbCollisionSubsteps() const;
95
96 virtual void addRigidFilter(PxRigidActor* actor, PxU32 vertId);
97 virtual void removeRigidFilter(PxRigidActor* actor, PxU32 vertId);
98
99 virtual PxU32 addRigidAttachment(PxRigidActor* actor, PxU32 vertId, const PxVec3& actorSpacePose, PxConeLimitedConstraint* params);
100 virtual void removeRigidAttachment(PxRigidActor* actor, PxU32 handle);
101
102 virtual void addTriRigidFilter(PxRigidActor* actor, PxU32 triangleId);
103 virtual void removeTriRigidFilter(PxRigidActor* actor, PxU32 triangleId);
104
105 virtual PxU32 addTriRigidAttachment(PxRigidActor* actor, PxU32 triangleId, const PxVec4& barycentric, const PxVec3& actorSpacePose, PxConeLimitedConstraint* constraint);
106 virtual void removeTriRigidAttachment(PxRigidActor* actor, PxU32 handle);
107
108 virtual void addClothFilter(PxFEMCloth* otherCloth, PxU32 otherTriIdx, PxU32 triIdx);
109 virtual void removeClothFilter(PxFEMCloth* otherCloth, PxU32 otherTriIdx, PxU32 triIdx);
110
111 virtual PxU32 addClothAttachment(PxFEMCloth* otherCloth, PxU32 otherTriIdx, const PxVec4& otherTriBarycentric, PxU32 triIdx, const PxVec4& triBarycentric);
112 virtual void removeClothAttachment(PxFEMCloth* otherCloth, PxU32 handle);
113
114 virtual void readData(PxFEMClothData::Enum flags, PxBuffer& buffer);
115
116 virtual void writeData(PxFEMClothData::Enum flags, PxBuffer& buffer, bool flush);
117
118 virtual PxCudaContextManager* getCudaContextManager() const;
119 virtual void setCudaContextManager(PxCudaContextManager*);
120
121 virtual void setSolverIterationCounts(PxU32 minPositionIters);
122
123 virtual void getSolverIterationCounts(PxU32& minPositionIters) const;
124
125 virtual PxShape* getShape();
126
127 virtual bool attachShape(PxShape& shape);
128
129 virtual void setClothCore(const PxVec4* const positionInvMass, const PxVec4* const velocityInvMass);
130
131 virtual void detachShape();
132
133 virtual void release();
134
135 PX_FORCE_INLINE const Sc::FEMClothCore& getCore() const { return mCore; }
136 PX_FORCE_INLINE Sc::FEMClothCore& getCore() { return mCore; }
137
138 static PX_FORCE_INLINE size_t getCoreOffset() { return PX_OFFSET_OF_RT(NpFEMCloth, mCore); }
139
140 virtual bool isSleeping() const;
141
142
143 // Debug name
144 void setName(const char*);
145 const char* getName() const;
146
147
148 void updateMaterials();
149
150 private:
151
152 PxBuffer* getBufferFromFlag(PxFEMClothData::Enum flags);
153
154 NpShape* mShape;
155 Sc::FEMClothCore mCore;
156 PxCudaContextManager* mCudaContextManager;
157 };
158#endif
159}
160#endif
#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