Jolt Physics
A multi core friendly Game Physics Engine
Loading...
Searching...
No Matches
SpringSettings.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
8
10
11class StreamIn;
12class StreamOut;
13
20
23{
25
26public:
28 SpringSettings() = default;
29 SpringSettings(const SpringSettings &) = default;
30 SpringSettings & operator = (const SpringSettings &) = default;
31 SpringSettings(ESpringMode inMode, float inFrequencyOrStiffness, float inDamping) : mMode(inMode), mFrequency(inFrequencyOrStiffness), mDamping(inDamping) { }
32
34 void SaveBinaryState(StreamOut &inStream) const;
35
37 void RestoreBinaryState(StreamIn &inStream);
38
40 inline bool HasStiffness() const { return mFrequency > 0.0f; }
41
45
46 union
47 {
51 float mFrequency = 0.0f;
52
61 };
62
67 float mDamping = 0.0f;
68};
69
std::uint8_t uint8
Definition Core.h:482
#define JPH_EXPORT
Definition Core.h:271
#define JPH_NAMESPACE_END
Definition Core.h:414
#define JPH_NAMESPACE_BEGIN
Definition Core.h:408
#define JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(linkage, class_name)
Definition SerializableObject.h:80
ESpringMode
Enum used by constraints to specify how the spring is defined.
Definition SpringSettings.h:16
@ FrequencyAndDamping
Frequency and damping are specified.
@ StiffnessAndDamping
Stiffness and damping are specified.
Settings for a linear or angular spring.
Definition SpringSettings.h:23
SpringSettings(ESpringMode inMode, float inFrequencyOrStiffness, float inDamping)
Definition SpringSettings.h:31
float mStiffness
Definition SpringSettings.h:60
SpringSettings(const SpringSettings &)=default
SpringSettings()=default
Constructor.
bool HasStiffness() const
Check if the spring has a valid frequency / stiffness, if not the spring will be hard.
Definition SpringSettings.h:40
Simple binary input stream.
Definition StreamIn.h:13
Simple binary output stream.
Definition StreamOut.h:13