RavEngine
Loading...
Searching...
No Matches
DyHairSystemCore.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#ifndef DY_HAIR_SYSTEM_CORE_H
28#define DY_HAIR_SYSTEM_CORE_H
29
30#include "foundation/PxSimpleTypes.h"
31#include "foundation/PxArray.h"
32#include "foundation/PxVec4.h"
33#include "foundation/PxVec2.h"
34#include "PxHairSystemFlag.h"
35#include "PxAttachment.h"
36
37namespace physx
38{
39 struct PxsBodyCore;
40
41 namespace Dy
42 {
43 // These parameters are needed on GPU for simulation and are grouped in a struct
44 // to reduce the number of assignments in update user data.
46 {
47 PX_CUDA_CALLABLE PX_FORCE_INLINE PxReal getCellSize() const { return mSegmentLength + 2.0f * mSegmentRadius; }
48 PX_CUDA_CALLABLE PX_FORCE_INLINE int getGridSize() const { return mGridSize[0] * mGridSize[1] * mGridSize[2]; }
49 PxHairSystemFlags::InternalType mFlags;
50 PxReal mSegmentLength;
51 PxReal mSegmentRadius;
52 PxReal mInterHairRepulsion; // strength of the repulsion field
53 PxReal mInterHairVelocityDamping; // friction based on interpolated vel field
54 PxReal mFrictionCoeff; // coulomb friction coefficient for collisions (internal and external)
55 PxReal mBendingCompliance;
56 PxReal mTwistingCompliance;
57 int mGridSize[3]; // number of cells in x,y,z directions
58 PxVec2 mShapeCompliance; // compliance for shape matching
59 PxReal mSelfCollisionContactDist; // contact distance for self collisions expressed as a multiple of the segment radius
60 PxReal mSelfCollisionRelaxation;
61 PxReal mLraRelaxation;
62 PxReal mShapeMatchingCompliance;
63 PxReal mShapeMatchingBeta; // balance between rigid rotation and linear stretching
64 PxU16 mShapeMatchingNumVertsPerGroup;
65 PxU16 mShapeMatchingNumVertsOverlap;
66 };
67
68 // The struct's defaults are defined in the Sc::HairSystemShapeCore constructor
70 {
71 public:
72 PxU32 mDirtyFlags;
73 PxHairSystemDataFlags mReadRequests;
74
75 PxU32 mNumVertices;
76 PxU32 mNumStrands;
77
78 // Parameters
80 PxReal mSleepThreshold;
81 PxReal mWakeCounter;
82 PxU16 mSolverIterationCounts;
83 PxVec4 mWind;
84
85 // Topology data
86 const PxU32* mStrandPastEndIndices;
87 const PxReal* mBendingRestAngles;
88
89 PxArray<PxU16> mMaterialhandles;
90
91 // Buffers for simulation (device or pinned host mirrors)
92 PxVec4* mPositionInvMass;
93 PxVec4* mVelocity;
94
95 // pointers to PxgHairSystemCore buffers that are exposed to the user
96 PxU32* mStrandPastEndIndicesGpuSim;
97 PxVec4* mPositionInvMassGpuSim;
98 PxReal* mTwistingRestPositionsGpuSim;
99
100 // rest positions
101 PxVec4* mRestPositions; // Gpu buffer
102 PxTransform* mRestPositionsTransform;
103 PxU64 mRestPositionBodyNodeIdx;
104
105 // Attachments
106 PxParticleRigidAttachment* mRigidAttachments; // Gpu buffer
107 PxU32 mNumRigidAttachments;
108
109 // LOD data
110 PxU32 mLodLevel; // the selected level, zero by default meaning full detail
111 PxU32 mLodNumLevels; // number of levels excluding level zero
112 const PxReal* mLodProportionOfStrands;
113 const PxReal* mLodProportionOfVertices;
114
115
116 void setMaterial(PxU16 materialhandle)
117 {
118 mMaterialhandles.pushBack(materialhandle);
119 }
120
121 void clearMaterials() { mMaterialhandles.clear(); }
122 };
123 }
124}
125
126#endif
127
Definition PxArray.h:53
PX_INLINE void clear()
Definition PxArray.h:250
PX_FORCE_INLINE T & pushBack(const T &a)
Definition PxArray.h:296
class representing a rigid euclidean transform as a quaternion and a vector
Definition PxTransform.h:49
2 Element vector class.
Definition PxVec2.h:50
Definition PxVec4.h:50
#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 DyHairSystemCore.h:70
Definition DyHairSystemCore.h:46
Struct to specify attachment between a particle/vertex and a rigid.
Definition PxAttachment.h:49