//
// Generated by Brutal.Jolt.Generate; do not edit by hand.
#nullable enable
using Brutal.Interop;
using Brutal.Numerics;
namespace Brutal.JoltApi
{
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:15
///
/// class SoftBodySharedSettings : public RefTarget<SoftBodySharedSettings>
///
///
///
///
/// This class defines the setup of all particles and their constraints.
/// It is used during the simulation and can be shared between multiple soft bodies.
///
///
[InteropHandle]
public readonly partial struct SoftBodySharedSettings : IDisposable
{
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:21
///
/// enum class EBendType
///
///
///
///
/// Which type of bend constraint should be created
///
///
public enum EBendType : int
{
///
///
/// No bend constraints will be created
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:23
///
/// None
///
///
None,
///
///
/// A simple distance constraint
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:24
///
/// Distance
///
///
Distance,
///
///
/// A dihedral bend constraint (most expensive, but also supports triangles that are initially not in
/// the same plane)
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:25
///
/// Dihedral
///
///
Dihedral,
}
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:29
///
/// enum class ELRAType
///
///
///
///
/// The type of long range attachment constraint to create
///
///
public enum ELRAType : int
{
///
///
/// Don't create a LRA constraint
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:31
///
/// None
///
///
None,
///
///
/// Create a LRA constraint based on Euclidean distance between the closest kinematic vertex and this
/// vertex
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:32
///
/// EuclideanDistance
///
///
EuclideanDistance,
///
///
/// Create a LRA constraint based on the geodesic distance between the closest kinematic vertex and this
/// vertex (follows the edge constraints)
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:33
///
/// GeodesicDistance
///
///
GeodesicDistance,
}
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:39
///
/// struct VertexAttributes
///
///
///
///
/// Per vertex attributes used during the CreateConstraints function.
/// For an edge or shear constraint, the compliance is averaged between the two attached vertices.
/// For a bend constraint, the compliance is averaged between the two vertices on the shared edge.
///
///
[StructLayout(LayoutKind.Explicit, Size = 20)]
public struct VertexAttributes
{
///
///
/// The compliance of the normal edges. Set to FLT_MAX to disable regular edges for any edge involving
/// this vertex.
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:45
///
/// float mCompliance = 0.0f
///
///
[FieldOffset(0)]
public float mCompliance;
///
///
/// The compliance of the shear edges. Set to FLT_MAX to disable shear edges for any edge involving this
/// vertex.
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:46
///
/// float mShearCompliance = 0.0f
///
///
[FieldOffset(4)]
public float mShearCompliance;
///
///
/// The compliance of the bend edges. Set to FLT_MAX to disable bend edges for any bend constraint
/// involving this vertex.
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:47
///
/// float mBendCompliance = FLT_MAX
///
///
[FieldOffset(8)]
public float mBendCompliance;
///
///
/// The type of long range attachment constraint to create.
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:48
///
/// ELRAType mLRAType = ELRAType::None
///
///
[FieldOffset(12)]
public SoftBodySharedSettings.ELRAType mLRAType;
///
///
/// Multiplier for the max distance of the LRA constraint, e.g. 1.01 means the max distance is 1% longer
/// than the calculated distance in the rest pose.
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:49
///
/// float mLRAMaxDistanceMultiplier = 1.0f
///
///
[FieldOffset(16)]
public float mLRAMaxDistanceMultiplier;
}
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:127
///
/// struct Vertex
///
///
///
///
/// A vertex is a particle, the data in this structure is only used during creation of the soft body and not
/// during simulation
///
///
[StructLayout(LayoutKind.Explicit, Size = 28)]
public struct Vertex
{
///
///
/// Initial position of the vertex
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:135
///
/// Float3 mPosition { 0, 0, 0 }
///
///
[FieldOffset(0)]
public float3 mPosition;
///
///
/// Initial velocity of the vertex
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:136
///
/// Float3 mVelocity { 0, 0, 0 }
///
///
[FieldOffset(12)]
public float3 mVelocity;
///
///
/// Initial inverse of the mass of the vertex
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:137
///
/// float mInvMass = 1.0f
///
///
[FieldOffset(24)]
public float mInvMass;
}
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:141
///
/// struct Face
///
///
///
///
/// A face defines the surface of the body
///
///
[StructLayout(LayoutKind.Explicit, Size = 16)]
public struct Face
{
///
///
/// Indices of the vertices that form the face
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:152
///
/// uint32 mVertex[3]
///
///
[FieldOffset(0)]
public uint_3 mVertex;
///
///
/// Index of the material of the face in SoftBodySharedSettings::mMaterials
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:153
///
/// uint32 mMaterialIndex = 0
///
///
[FieldOffset(12)]
public uint mMaterialIndex;
}
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:157
///
/// struct Edge
///
///
///
///
/// An edge keeps two vertices at a constant distance using a spring: |x1 - x2| = rest length
///
///
[StructLayout(LayoutKind.Explicit, Size = 16)]
public struct Edge
{
///
///
/// Indices of the vertices that form the edge
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:168
///
/// uint32 mVertex[2]
///
///
[FieldOffset(0)]
public uint_2 mVertex;
///
///
/// Rest length of the spring, calculated by CalculateEdgeLengths
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:169
///
/// float mRestLength = 1.0f
///
///
[FieldOffset(8)]
public float mRestLength;
///
///
/// Inverse of the stiffness of the spring
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:170
///
/// float mCompliance = 0.0f
///
///
[FieldOffset(12)]
public float mCompliance;
}
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:191
///
/// struct DihedralBend
///
///
[StructLayout(LayoutKind.Explicit, Size = 24)]
public struct DihedralBend
{
///
///
/// Indices of the vertices of the 2 triangles that share an edge (the first 2 vertices are the shared
/// edge)
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:202
///
/// uint32 mVertex[4]
///
///
[FieldOffset(0)]
public uint_4 mVertex;
///
///
/// Inverse of the stiffness of the constraint
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:203
///
/// float mCompliance = 0.0f
///
///
[FieldOffset(16)]
public float mCompliance;
///
///
/// Initial angle between the normals of the triangles (pi - dihedral angle), calculated by
/// CalculateBendConstraintConstants
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:204
///
/// float mInitialAngle = 0.0f
///
///
[FieldOffset(20)]
public float mInitialAngle;
}
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:208
///
/// struct Volume
///
///
///
///
/// Volume constraint, keeps the volume of a tetrahedron constant
///
///
[StructLayout(LayoutKind.Explicit, Size = 24)]
public struct Volume
{
///
///
/// Indices of the vertices that form the tetrahedron
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:219
///
/// uint32 mVertex[4]
///
///
[FieldOffset(0)]
public uint_4 mVertex;
///
///
/// 6 times the rest volume of the tetrahedron, calculated by CalculateVolumeConstraintVolumes
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:220
///
/// float mSixRestVolume = 1.0f
///
///
[FieldOffset(16)]
public float mSixRestVolume;
///
///
/// Inverse of the stiffness of the constraint
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:221
///
/// float mCompliance = 0.0f
///
///
[FieldOffset(20)]
public float mCompliance;
}
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:312
///
/// struct RodStretchShear
///
///
///
///
/// A discrete Cosserat rod connects two particles with a rigid rod that has fixed length and inertia.
/// A rod can be used instead of an Edge to constraint two vertices. The orientation of the rod can be
/// used to orient geometry attached to the rod (e.g. a plant leaf). Note that each rod needs to be constrained
/// by at least one RodBendTwist constraint in order to constrain the rotation of the rod. If you don't do
/// this then the orientation is likely to rotate around the rod axis with constant velocity.
/// Based on "Position and Orientation Based Cosserat Rods" - Kugelstadt and Schoemer - SIGGRAPH 2016
/// See: https://www.researchgate.net/publication/325597548_Position_and_Orientation_Based_Cosserat_Rods
///
///
[StructLayout(LayoutKind.Explicit, Size = 48)]
public struct RodStretchShear
{
///
///
/// Indices of the vertices that form the rod
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:323
///
/// uint32 mVertex[2]
///
///
[FieldOffset(0)]
public uint_2 mVertex;
///
///
/// Fixed length of the rod, calculated by CalculateRodProperties
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:324
///
/// float mLength = 1.0f
///
///
[FieldOffset(8)]
public float mLength;
///
///
/// Inverse of the mass of the rod (0 for static rods), calculated by CalculateRodProperties but can be
/// overridden afterwards
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:325
///
/// float mInvMass = 1.0f
///
///
[FieldOffset(12)]
public float mInvMass;
///
///
/// Inverse of the stiffness of the rod
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:326
///
/// float mCompliance = 0.0f
///
///
[FieldOffset(16)]
public float mCompliance;
///
///
/// The Bishop frame of the rod (the rotation of the rod in its rest pose so that it has zero twist
/// towards adjacent rods), calculated by CalculateRodProperties
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:327
///
/// Quat mBishop = Quat::sZero()
///
///
[FieldOffset(32)]
public floatQuat mBishop;
}
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:331
///
/// struct RodBendTwist
///
///
///
///
/// A constraint that connects two Cosserat rods and limits bend and twist between the rods.
///
///
[StructLayout(LayoutKind.Explicit, Size = 32)]
public struct RodBendTwist
{
///
///
/// Indices of rods that are constrained (index in mRodStretchShearConstraints)
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:339
///
/// uint32 mRod[2]
///
///
[FieldOffset(0)]
public uint_2 mRod;
///
///
/// Inverse of the stiffness of the rod
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:340
///
/// float mCompliance = 0.0f
///
///
[FieldOffset(8)]
public float mCompliance;
///
///
/// The initial rotation between the rods: rod1.mBishop.Conjugated() * rod2.mBishop, calculated by
/// CalculateRodProperties
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:341
///
/// Quat mOmega0 = Quat::sZero()
///
///
[FieldOffset(16)]
public floatQuat mOmega0;
}
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:366
///
/// struct ClosestKinematic
///
///
///
///
/// Tracks the closest kinematic vertex
///
///
[StructLayout(LayoutKind.Explicit, Size = 12)]
public struct ClosestKinematic
{
///
///
/// Vertex index of closest kinematic vertex
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:368
///
/// uint32 mVertex = 0xffffffff
///
///
[FieldOffset(0)]
public uint mVertex;
///
///
/// Number of hops to the closest kinematic vertex
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:369
///
/// uint32 mHops = 0xffffffff
///
///
[FieldOffset(4)]
public uint mHops;
///
///
/// Distance to the closest kinematic vertex
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:370
///
/// float mDistance = FLT_MAX
///
///
[FieldOffset(8)]
public float mDistance;
}
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:374
///
/// struct UpdateGroup
///
///
///
///
/// Tracks the end indices of the various constraint groups
///
///
[StructLayout(LayoutKind.Explicit, Size = 28)]
public struct UpdateGroup
{
///
///
/// The end index of the edge constraints in this group
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:376
///
/// uint mEdgeEndIndex
///
///
[FieldOffset(0)]
public uint mEdgeEndIndex;
///
///
/// The end index of the LRA constraints in this group
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:377
///
/// uint mLRAEndIndex
///
///
[FieldOffset(4)]
public uint mLRAEndIndex;
///
///
/// The end index of the rod stretch shear constraints in this group
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:378
///
/// uint mRodStretchShearEndIndex
///
///
[FieldOffset(8)]
public uint mRodStretchShearEndIndex;
///
///
/// The end index of the rod bend twist constraints in this group
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:379
///
/// uint mRodBendTwistEndIndex
///
///
[FieldOffset(12)]
public uint mRodBendTwistEndIndex;
///
///
/// The end index of the dihedral bend constraints in this group
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:380
///
/// uint mDihedralBendEndIndex
///
///
[FieldOffset(16)]
public uint mDihedralBendEndIndex;
///
///
/// The end index of the volume constraints in this group
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:381
///
/// uint mVolumeEndIndex
///
///
[FieldOffset(20)]
public uint mVolumeEndIndex;
///
///
/// The end index of the skinned constraints in this group
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:382
///
/// uint mSkinnedEndIndex
///
///
[FieldOffset(24)]
public uint mSkinnedEndIndex;
}
public static SoftBodySharedSettings Create() => Jolt.PInvoke.SoftBodySharedSettings_Create();
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:57
///
/// void CreateConstraints(const VertexAttributes *inVertexAttributes, uint inVertexAttributesLength, EBendType inBendType = EBendType::Distance, float inAngleTolerance = DegreesToRadians(8.0f))
///
///
///
///
/// Automatically create constraints based on the faces of the soft body
/// @param inVertexAttributes A list of attributes for each vertex (1-on-1 with mVertices, note that if the list is smaller than mVertices the last element will be repeated). This defines the properties of the constraints that are created.
/// @param inVertexAttributesLength The length of inVertexAttributes
/// @param inBendType The type of bend constraint to create
/// @param inAngleTolerance Shear edges are created when two connected triangles form a quad (are roughly in the same plane and form a square with roughly 90 degree angles). This defines the tolerance (in radians).
///
///
public unsafe void CreateConstraints(Ptr vertexAttributes, uint vertexAttributesLength, SoftBodySharedSettings.EBendType bendType, float angleTolerance) => Jolt.PInvoke.SoftBodySharedSettings_CreateConstraints(this, vertexAttributes, vertexAttributesLength, bendType, angleTolerance);
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:60
///
/// void CalculateEdgeLengths()
///
///
///
///
/// Calculate the initial lengths of all springs of the edges of this soft body (if you use
/// CreateConstraint, this is already done)
///
///
public void CalculateEdgeLengths() => Jolt.PInvoke.SoftBodySharedSettings_CalculateEdgeLengths(this);
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:64
///
/// void CalculateRodProperties()
///
///
///
///
/// Calculate the properties of the rods
/// Note that this can swap mVertex of the RodStretchShear constraints if two rods are connected through a RodBendTwist constraint but point in opposite directions.
///
///
public void CalculateRodProperties() => Jolt.PInvoke.SoftBodySharedSettings_CalculateRodProperties(this);
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:68
///
/// void CalculateLRALengths(float inMaxDistanceMultiplier = 1.0f)
///
///
///
///
/// Calculate the max lengths for the long range attachment constraints based on Euclidean distance (if you use CreateConstraints, this is already done)
/// @param inMaxDistanceMultiplier Multiplier for the max distance of the LRA constraint, e.g. 1.01 means the max distance is 1% longer than the calculated distance in the rest pose.
///
///
public void CalculateLRALengths(float maxDistanceMultiplier) => Jolt.PInvoke.SoftBodySharedSettings_CalculateLRALengths(this, maxDistanceMultiplier);
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:71
///
/// void CalculateBendConstraintConstants()
///
///
///
///
/// Calculate the constants for the bend constraints (if you use CreateConstraints, this is already done)
///
///
public void CalculateBendConstraintConstants() => Jolt.PInvoke.SoftBodySharedSettings_CalculateBendConstraintConstants(this);
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:74
///
/// void CalculateVolumeConstraintVolumes()
///
///
///
///
/// Calculates the initial volume of all tetrahedra of this soft body
///
///
public void CalculateVolumeConstraintVolumes() => Jolt.PInvoke.SoftBodySharedSettings_CalculateVolumeConstraintVolumes(this);
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:77
///
/// void CalculateSkinnedConstraintNormals()
///
///
///
///
/// Calculate information needed to be able to calculate the skinned constraint normals at run-time
///
///
public void CalculateSkinnedConstraintNormals() => Jolt.PInvoke.SoftBodySharedSettings_CalculateSkinnedConstraintNormals(this);
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:96
///
/// void Optimize()
///
///
///
///
/// Optimize the soft body settings without results
///
///
public void Optimize() => Jolt.PInvoke.SoftBodySharedSettings_Optimize(this);
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:99
///
/// Ref<SoftBodySharedSettings> Clone() const
///
///
///
///
/// Clone this object
///
///
public SoftBodySharedSettings Clone() => Jolt.PInvoke.SoftBodySharedSettings_Clone(this);
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:102
///
/// void SaveBinaryState(StreamOut &inStream) const
///
///
///
///
/// Saves the state of this object in binary form to inStream. Doesn't store the material list.
///
///
public void SaveBinaryState(StreamOut stream) => Jolt.PInvoke.SoftBodySharedSettings_SaveBinaryState(this, stream);
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:105
///
/// void RestoreBinaryState(StreamIn &inStream)
///
///
///
///
/// Restore the state of this object from inStream. Doesn't restore the material list.
///
///
public void RestoreBinaryState(StreamIn stream) => Jolt.PInvoke.SoftBodySharedSettings_RestoreBinaryState(this, stream);
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:124
///
/// static Ref<SoftBodySharedSettings> sCreateCube(uint inGridSize, float inGridSpacing)
///
///
///
///
/// Create a cube. This can be used to create a simple soft body for testing purposes.
/// It will contain edge constraints, volume constraints and faces.
/// @param inGridSize Number of points along each axis
/// @param inGridSpacing Distance between points
///
///
public static SoftBodySharedSettings sCreateCube(uint gridSize, float gridSpacing) => Jolt.PInvoke.SoftBodySharedSettings_sCreateCube(gridSize, gridSpacing);
///
///
/// C++:
/// Jolt/Physics/SoftBody/SoftBodySharedSettings.h:345
///
/// void AddFace(const Face &inFace)
///
///
///
///
/// Add a face to this soft body
///
///
public void AddFace(ref SoftBodySharedSettings.Face face) => Jolt.PInvoke.SoftBodySharedSettings_AddFace(this, ref face);
public void AddRef() => Jolt.PInvoke.SoftBodySharedSettings_AddRef(this);
public void Release() => Jolt.PInvoke.SoftBodySharedSettings_Release(this);
public uint GetRefCount() => Jolt.PInvoke.SoftBodySharedSettings_GetRefCount(this);
public void Dispose()
{
if (IsNull()) return;
Release();
}
}
}