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
15enum class ESpringMode : uint8
16{
19};
20
23{
24public:
26
27
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
44 ESpringMode mMode = ESpringMode::FrequencyAndDamping;
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:440
#define JPH_EXPORT
Definition: Core.h:227
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
#define JPH_DECLARE_SERIALIZABLE_NON_VIRTUAL(linkage, class_name)
Definition: SerializableObject.h:71
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
float mStiffness
Definition: SpringSettings.h:60
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