![]() |
Jolt Physics
A multi core friendly Game Physics Engine
|
#include <Hair.h>
Classes | |
| struct | DrawSettings |
| struct | LeafShape |
| struct | UpdateContext |
Public Types | |
| enum class | ERenderStrandColor { PerRenderStrand , PerSimulatedStrand , GravityFactor , WorldTransformInfluence , GridVelocityFactor , GlobalPose , SkinGlobalPose } |
| using | RenderPositionsToFloat3 = std::function<void(ComputeBuffer *, Float3 *, uint)> |
| Function that converts the render positions buffer to Float3 vertices for debugging purposes. It maps an application defined format to Float3. Third parameter is the number of vertices. | |
Public Member Functions | |
| Hair (const HairSettings *inSettings, RVec3Arg inPosition, QuatArg inRotation, ObjectLayer inLayer) | |
| Constructor / destructor. | |
| ~Hair () | |
| void | Init (ComputeSystem *inComputeSystem) |
| Initialize. | |
| void | SetPosition (RVec3Arg inPosition) |
| Position and rotation of the hair in world space. | |
| void | SetRotation (QuatArg inRotation) |
| RMat44 | GetWorldTransform () const |
| void | OnTeleported () |
| The hair will be initialized in its default pose with zero velocity at the new position and rotation during the next update. | |
| void | SetScalpVerticesCB (ComputeBuffer *inBuffer) |
| Ability to externally provide the scalp vertices buffer. This allows skipping skinning the scalp during the simulation update. You may need to override JPH_SHADER_BIND_SCALP_VERTICES in HairSkinRootsBindings.h to match the format of the provided buffer. | |
| void | SetScalpTrianglesCB (ComputeBuffer *inBuffer) |
| Ability to externally provide the scalp triangle indices buffer. This allows skipping skinning the scalp in during the simulation update. You may need to override JPH_SHADER_BIND_SCALP_TRIANGLES in HairSkinRootsBindings.h to match the format of the provided buffer. | |
| void | SetScalpToHead (Mat44Arg inMat) |
| When skipping skinning, this allow specifying a transform that transforms the scalp mesh into head space. | |
| void | OverrideRenderPositionsCB (const RenderPositionsToFloat3 &inRenderPositionsToFloat3) |
| Enable externally set render vertices buffer (with potentially different vertex layout). Note that this also requires replacing the HairCalculateRenderPositions shader. | |
| void | SetRenderPositionsCB (ComputeBuffer *inBuffer) |
| Allow setting the render vertices buffer externally in case it has special requirements for the calling application. You may need to override JPH_SHADER_BIND_RENDER_POSITIONS in HairCalculateRenderPositionsBindings.h to match the format of the provided buffer. | |
| void | Update (float inDeltaTime, Mat44Arg inJointToHair, const Mat44 *inJointMatrices, const PhysicsSystem &inSystem, const HairShaders &inShaders, ComputeSystem *inComputeSystem, ComputeQueue *inComputeQueue) |
| ComputeBuffer * | GetScalpVerticesCB () const |
| Access to the resulting simulation data. | |
| ComputeBuffer * | GetScalpTrianglesCB () const |
| Skinned scalp triangle indices. | |
| ComputeBuffer * | GetPositionsCB () const |
| Note transposed for better memory access. | |
| ComputeBuffer * | GetVelocitiesCB () const |
| Note transposed for better memory access. | |
| ComputeBuffer * | GetVelocityAndDensityCB () const |
| Velocity grid. | |
| ComputeBuffer * | GetRenderPositionsCB () const |
| Render positions of the hair strands (see HairSettings::mRenderStrands to see where each strand starts and ends) | |
| void | ReadBackGPUState (ComputeQueue *inComputeQueue) |
| Read back the GPU state so that the functions below can be used. For debugging purposes only, this is slow! | |
| void | LockReadBackBuffers () |
| Lock/unlock the data buffers so that the functions below return valid values. | |
| void | UnlockReadBackBuffers () |
| const Float3 * | GetScalpVertices () const |
| Access to the resulting simulation data (only valid when ReadBackGPUState has been called and the buffers have been locked) | |
| const Float3 * | GetPositions () const |
| const Quat * | GetRotations () const |
| StridedPtr< const Float3 > | GetVelocities () const |
| StridedPtr< const Float3 > | GetAngularVelocities () const |
| const Float4 * | GetGridVelocityAndDensity () const |
| const Float3 * | GetRenderPositions () const |
| void | Draw (const DrawSettings &inSettings, DebugRenderer *inRenderer) |
| Debug functionality to draw the hair and its simulation properties. | |
Public Member Functions inherited from NonCopyable | |
| NonCopyable ()=default | |
| NonCopyable (const NonCopyable &)=delete | |
| void | operator= (const NonCopyable &)=delete |
Protected Types | |
| using | Gradient = HairSettings::Gradient |
| using | GradientSampler = HairSettings::GradientSampler |
Protected Member Functions | |
| void | InitializeContext (UpdateContext &outCtx, float inDeltaTime, const PhysicsSystem &inSystem) |
Hair simulation instance
Note that this system is currently still in development, it is missing important features like:
|
protected |
|
protected |
| using Hair::RenderPositionsToFloat3 = std::function<void(ComputeBuffer *, Float3 *, uint)> |
|
strong |
| JPH_NAMESPACE_BEGIN Hair::Hair | ( | const HairSettings * | inSettings, |
| RVec3Arg | inPosition, | ||
| QuatArg | inRotation, | ||
| ObjectLayer | inLayer ) |
Constructor / destructor.
| Hair::~Hair | ( | ) |
| void Hair::Draw | ( | const DrawSettings & | inSettings, |
| DebugRenderer * | inRenderer ) |
Debug functionality to draw the hair and its simulation properties.
|
inline |
|
inline |
|
inline |
|
inline |
Note transposed for better memory access.
|
inline |
|
inline |
Render positions of the hair strands (see HairSettings::mRenderStrands to see where each strand starts and ends)
|
inline |
|
inline |
Skinned scalp triangle indices.
|
inline |
Access to the resulting simulation data (only valid when ReadBackGPUState has been called and the buffers have been locked)
|
inline |
Access to the resulting simulation data.
Skinned scalp vertices
|
inline |
|
inline |
Note transposed for better memory access.
|
inline |
Velocity grid.
|
inline |
| void Hair::Init | ( | ComputeSystem * | inComputeSystem | ) |
Initialize.
|
protected |
| void Hair::LockReadBackBuffers | ( | ) |
Lock/unlock the data buffers so that the functions below return valid values.
|
inline |
The hair will be initialized in its default pose with zero velocity at the new position and rotation during the next update.
|
inline |
Enable externally set render vertices buffer (with potentially different vertex layout). Note that this also requires replacing the HairCalculateRenderPositions shader.
| void Hair::ReadBackGPUState | ( | ComputeQueue * | inComputeQueue | ) |
Read back the GPU state so that the functions below can be used. For debugging purposes only, this is slow!
|
inline |
Position and rotation of the hair in world space.
|
inline |
Allow setting the render vertices buffer externally in case it has special requirements for the calling application. You may need to override JPH_SHADER_BIND_RENDER_POSITIONS in HairCalculateRenderPositionsBindings.h to match the format of the provided buffer.
|
inline |
|
inline |
When skipping skinning, this allow specifying a transform that transforms the scalp mesh into head space.
|
inline |
Ability to externally provide the scalp triangle indices buffer. This allows skipping skinning the scalp in during the simulation update. You may need to override JPH_SHADER_BIND_SCALP_TRIANGLES in HairSkinRootsBindings.h to match the format of the provided buffer.
|
inline |
Ability to externally provide the scalp vertices buffer. This allows skipping skinning the scalp during the simulation update. You may need to override JPH_SHADER_BIND_SCALP_VERTICES in HairSkinRootsBindings.h to match the format of the provided buffer.
| void Hair::UnlockReadBackBuffers | ( | ) |
| void Hair::Update | ( | float | inDeltaTime, |
| Mat44Arg | inJointToHair, | ||
| const Mat44 * | inJointMatrices, | ||
| const PhysicsSystem & | inSystem, | ||
| const HairShaders & | inShaders, | ||
| ComputeSystem * | inComputeSystem, | ||
| ComputeQueue * | inComputeQueue ) |
Step the hair simulation forward in time
| inDeltaTime | Time step |
| inJointToHair | Transform that transforms from joint space to hair local space (as defined by GetWorldTransform) |
| inJointMatrices | Array of joint matrices in world space, length needs to match HairSettings::mScalpInverseBindPose.size() |
| inSystem | Physics system used for collision detection |
| inShaders | Preloaded hair compute shaders |
| inComputeSystem | Compute system to use |
| inComputeQueue | Compute queue to use |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |