Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
SoftBodyCreationSettings.h
Go to the documentation of this file.
1// Jolt Physics Library (https://github.com/jrouwe/JoltPhysics)
2// SPDX-FileCopyrightText: 2023 Jorrit Rouwe
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
12
14
18{
20
21public:
24 SoftBodyCreationSettings(const SoftBodySharedSettings *inSettings, RVec3Arg inPosition, QuatArg inRotation, ObjectLayer inObjectLayer) : mSettings(inSettings), mPosition(inPosition), mRotation(inRotation), mObjectLayer(inObjectLayer) { }
25
27 void SaveBinaryState(StreamOut &inStream) const;
28
30 void RestoreBinaryState(StreamIn &inStream);
31
38
42 void SaveWithChildren(StreamOut &inStream, SharedSettingsToIDMap *ioSharedSettingsMap, MaterialToIDMap *ioMaterialMap, GroupFilterToIDMap *ioGroupFilterMap) const;
43
45
47 static SBCSResult sRestoreWithChildren(StreamIn &inStream, IDToSharedSettingsMap &ioSharedSettingsMap, IDToMaterialMap &ioMaterialMap, IDToGroupFilterMap &ioGroupFilterMap);
48
50
53
56
60
62 float mLinearDamping = 0.1f;
63 float mMaxLinearVelocity = 500.0f;
64 float mRestitution = 0.0f;
65 float mFriction = 0.2f;
66 float mPressure = 0.0f;
67 float mGravityFactor = 1.0f;
68 float mVertexRadius = 0.0f;
69 bool mUpdatePosition = true;
71 bool mAllowSleeping = true;
72 bool mFacesDoubleSided = false;
73};
74
#define JPH_EXPORT
Definition Core.h:275
std::uint64_t uint64
Definition Core.h:504
#define JPH_NAMESPACE_END
Definition Core.h:425
std::uint32_t uint32
Definition Core.h:503
#define JPH_NAMESPACE_BEGIN
Definition Core.h:419
const Quat QuatArg
Definition MathTypes.h:28
uint16 ObjectLayer
Definition ObjectLayer.h:16
Vec3Arg RVec3Arg
Definition Real.h:30
Vec3 RVec3
Definition Real.h:29
#define JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(linkage, class_name)
Definition SerializableObject.h:80
Definition CollisionGroup.h:20
Definition Quat.h:33
static JPH_INLINE Quat sIdentity()
Definition Quat.h:104
Definition Reference.h:163
Helper class that either contains a valid result or an error.
Definition Result.h:12
static SBCSResult sRestoreWithChildren(StreamIn &inStream, IDToSharedSettingsMap &ioSharedSettingsMap, IDToMaterialMap &ioMaterialMap, IDToGroupFilterMap &ioGroupFilterMap)
Restore a shape, all its children and materials. Pass in an empty map in ioSharedSettingsMap / ioMate...
Definition SoftBodyCreationSettings.cpp:93
SoftBodySharedSettings::SharedSettingsToIDMap SharedSettingsToIDMap
Definition SoftBodyCreationSettings.h:34
float mLinearDamping
Linear damping: dv/dt = -mLinearDamping * v. Value should be zero or positive and is usually close to...
Definition SoftBodyCreationSettings.h:62
bool mFacesDoubleSided
If the faces in this soft body should be treated as double sided for the purpose of collision detecti...
Definition SoftBodyCreationSettings.h:72
float mFriction
Friction coefficient when colliding.
Definition SoftBodyCreationSettings.h:65
SoftBodyCreationSettings(const SoftBodySharedSettings *inSettings, RVec3Arg inPosition, QuatArg inRotation, ObjectLayer inObjectLayer)
Definition SoftBodyCreationSettings.h:24
StreamUtils::IDToObjectMap< PhysicsMaterial > IDToMaterialMap
Definition SoftBodyCreationSettings.h:37
Result< SoftBodyCreationSettings > SBCSResult
Definition SoftBodyCreationSettings.h:44
StreamUtils::ObjectToIDMap< GroupFilter > GroupFilterToIDMap
Definition SoftBodyCreationSettings.h:32
uint32 mNumIterations
Number of solver iterations.
Definition SoftBodyCreationSettings.h:61
SoftBodySharedSettings::IDToSharedSettingsMap IDToSharedSettingsMap
Definition SoftBodyCreationSettings.h:35
Quat mRotation
Initial rotation of the soft body.
Definition SoftBodyCreationSettings.h:52
bool mMakeRotationIdentity
Bake specified mRotation in the vertices and set the body rotation to identity (simulation is slightl...
Definition SoftBodyCreationSettings.h:70
StreamUtils::ObjectToIDMap< PhysicsMaterial > MaterialToIDMap
Definition SoftBodyCreationSettings.h:36
float mPressure
n * R * T, amount of substance * ideal gas constant * absolute temperature, see https://en....
Definition SoftBodyCreationSettings.h:66
bool mUpdatePosition
Update the position of the body while simulating (set to false for something that is attached to the ...
Definition SoftBodyCreationSettings.h:69
bool mAllowSleeping
If this body can go to sleep or not.
Definition SoftBodyCreationSettings.h:71
RVec3 mPosition
Initial position of the soft body.
Definition SoftBodyCreationSettings.h:51
float mGravityFactor
Value to multiply gravity with for this body.
Definition SoftBodyCreationSettings.h:67
void SaveWithChildren(StreamOut &inStream, SharedSettingsToIDMap *ioSharedSettingsMap, MaterialToIDMap *ioMaterialMap, GroupFilterToIDMap *ioGroupFilterMap) const
Definition SoftBodyCreationSettings.cpp:78
float mMaxLinearVelocity
Maximum linear velocity that a vertex can reach (m/s).
Definition SoftBodyCreationSettings.h:63
float mVertexRadius
How big the particles are, can be used to push the vertices a little bit away from the surface of oth...
Definition SoftBodyCreationSettings.h:68
float mRestitution
Restitution when colliding.
Definition SoftBodyCreationSettings.h:64
SoftBodyCreationSettings()=default
Constructor.
StreamUtils::IDToObjectMap< GroupFilter > IDToGroupFilterMap
Definition SoftBodyCreationSettings.h:33
RefConst< SoftBodySharedSettings > mSettings
Defines the configuration of this soft body.
Definition SoftBodyCreationSettings.h:49
uint64 mUserData
User data value (can be used by application).
Definition SoftBodyCreationSettings.h:55
CollisionGroup mCollisionGroup
The collision group this body belongs to (determines if two objects can collide).
Definition SoftBodyCreationSettings.h:59
ObjectLayer mObjectLayer
The collision layer this body belongs to (determines if two objects can collide).
Definition SoftBodyCreationSettings.h:58
Definition SoftBodySharedSettings.h:16
StreamUtils::IDToObjectMap< SoftBodySharedSettings > IDToSharedSettingsMap
Definition SoftBodySharedSettings.h:108
StreamUtils::ObjectToIDMap< SoftBodySharedSettings > SharedSettingsToIDMap
Definition SoftBodySharedSettings.h:107
Simple binary input stream.
Definition StreamIn.h:13
Simple binary output stream.
Definition StreamOut.h:13
static JPH_INLINE Vec3 sZero()
Vector with all zeros.
Definition Vec3.inl:103
UnorderedMap< const Type *, uint32 > ObjectToIDMap
Definition StreamUtils.h:18
Array< Ref< Type > > IDToObjectMap
Definition StreamUtils.h:21