//
// Generated by Brutal.Jolt.Generate; do not edit by hand.
#nullable enable
using System.Runtime.CompilerServices;
using Brutal.Interop;
using Brutal.Numerics;
namespace Brutal.JoltApi
{
///
///
/// Settings for a linear or angular spring
///
///
/// C++:
/// Jolt/Physics/Constraints/SpringSettings.h:23
///
/// class SpringSettings
///
///
[InteropHandle]
public readonly partial struct SpringSettings : IDisposable
{
///
///
/// Constructor
///
///
/// C++:
/// Jolt/Physics/Constraints/SpringSettings.h:29
///
/// SpringSettings() = default
///
///
public static SpringSettings Create() => Jolt.PInvoke.SpringSettings_Create();
///
///
/// C++:
/// Jolt/Physics/Constraints/SpringSettings.h:32
///
/// SpringSettings(ESpringMode inMode, float inFrequencyOrStiffness, float inDamping)
///
///
public static SpringSettings Create(SpringMode mode, float frequencyOrStiffness, float damping) =>
Jolt.PInvoke.SpringSettings_Create_2(mode, frequencyOrStiffness, damping);
///
///
/// Saves the contents of the spring settings in binary form to inStream.
///
///
/// C++:
/// Jolt/Physics/Constraints/SpringSettings.h:35
///
/// void SaveBinaryState(StreamOut &inStream) const
///
///
public void SaveBinaryState(StreamOut stream) => Jolt.PInvoke.SpringSettings_SaveBinaryState(this, stream);
///
///
/// Restores contents from the binary stream inStream.
///
///
/// C++:
/// Jolt/Physics/Constraints/SpringSettings.h:38
///
/// void RestoreBinaryState(StreamIn &inStream)
///
///
public void RestoreBinaryState(StreamIn stream) => Jolt.PInvoke.SpringSettings_RestoreBinaryState(this, stream);
///
///
/// Check if the spring has a valid frequency / stiffness, if not the spring will be hard
///
///
/// C++:
/// Jolt/Physics/Constraints/SpringSettings.h:41
///
/// inline bool HasStiffness() const
///
///
public bool HasStiffness() => Jolt.PInvoke.SpringSettings_HasStiffness(this);
///
///
/// Check if this spring has stiffness or damping (making it active), if not the constraint will be hard
///
///
/// C++:
/// Jolt/Physics/Constraints/SpringSettings.h:44
///
/// inline bool HasStiffnessOrDamping() const
///
///
public bool HasStiffnessOrDamping() => Jolt.PInvoke.SpringSettings_HasStiffnessOrDamping(this);
///
///
/// Valid when mMode = ESpringMode::FrequencyAndDamping. If > 0 the constraint will be soft and this
/// specifies the oscillation frequency in Hz. If <= 0, mDamping is ignored and the constraint will have
/// hard limits (as hard as the time step / the number of velocity / position solver steps allows).
///
///
/// C++:
/// Jolt/Physics/Constraints/SpringSettings.h:54
///
/// float mFrequency = 0.0f
///
///
public float GetFrequency() => Jolt.PInvoke.SpringSettings_GetFrequency(this);
///
///
/// Valid when mMode = ESpringMode::FrequencyAndDamping. If > 0 the constraint will be soft and this
/// specifies the oscillation frequency in Hz. If <= 0, mDamping is ignored and the constraint will have
/// hard limits (as hard as the time step / the number of velocity / position solver steps allows).
///
///
/// C++:
/// Jolt/Physics/Constraints/SpringSettings.h:54
///
/// float mFrequency = 0.0f
///
///
public void SetFrequency(float value) => Jolt.PInvoke.SpringSettings_SetFrequency(this, value);
///
///
/// When mMode = ESpringMode::StiffnessAndDamping: Specifies the stiffness (k) in the spring equation F = -k
/// * x - c * v for a linear or T = -k * theta - c * w for an angular spring. Units are N / m for a linear
/// spring and N m / rad for an angular spring.
///
///
/// C++:
/// Jolt/Physics/Constraints/SpringSettings.h:70
///
/// float mStiffness
///
///
///
///
/// When mMode = ESpringMode::StiffnessAndDamping:
/// Specifies the stiffness (k) in the spring equation F = -k * x - c * v for a linear or T = -k * theta - c * w for an angular spring.
/// Units are N / m for a linear spring and N m / rad for an angular spring.
///
/// Note that stiffness values are large numbers. To calculate a ballpark value for the needed stiffness you can use:
/// force = stiffness * delta_spring_length = mass * gravity <=> stiffness = mass * gravity / delta_spring_length.
/// So if your object weighs 1500 kg and the spring compresses by 2 meters, you need a stiffness in the order of 1500 * 9.81 / 2 ~ 7500 N/m.
///
/// When mMode = ESpringMode::MassNormalizedStiffnessAndDamping:
/// Specifies the stiffness (k) in the spring equation F = m_eff * (-k * x - c * v) for a linear or T = i_eff * (-k * theta - c * w) for an angular spring.
/// m_eff / i_eff is the effective mass / inertia of the constraint.
/// Units are 1 / s^2 for a linear spring and 1 / rad s^2 for an angular spring.
///
/// Since the stiffness is multiplied by the effective mass / inertia of the constraint, you can use much smaller stiffness values and they will be mass independent.
///
///
public float GetStiffness() => Jolt.PInvoke.SpringSettings_GetStiffness(this);
///
///
/// When mMode = ESpringMode::StiffnessAndDamping: Specifies the stiffness (k) in the spring equation F = -k
/// * x - c * v for a linear or T = -k * theta - c * w for an angular spring. Units are N / m for a linear
/// spring and N m / rad for an angular spring.
///
///
/// C++:
/// Jolt/Physics/Constraints/SpringSettings.h:70
///
/// float mStiffness
///
///
///
///
/// When mMode = ESpringMode::StiffnessAndDamping:
/// Specifies the stiffness (k) in the spring equation F = -k * x - c * v for a linear or T = -k * theta - c * w for an angular spring.
/// Units are N / m for a linear spring and N m / rad for an angular spring.
///
/// Note that stiffness values are large numbers. To calculate a ballpark value for the needed stiffness you can use:
/// force = stiffness * delta_spring_length = mass * gravity <=> stiffness = mass * gravity / delta_spring_length.
/// So if your object weighs 1500 kg and the spring compresses by 2 meters, you need a stiffness in the order of 1500 * 9.81 / 2 ~ 7500 N/m.
///
/// When mMode = ESpringMode::MassNormalizedStiffnessAndDamping:
/// Specifies the stiffness (k) in the spring equation F = m_eff * (-k * x - c * v) for a linear or T = i_eff * (-k * theta - c * w) for an angular spring.
/// m_eff / i_eff is the effective mass / inertia of the constraint.
/// Units are 1 / s^2 for a linear spring and 1 / rad s^2 for an angular spring.
///
/// Since the stiffness is multiplied by the effective mass / inertia of the constraint, you can use much smaller stiffness values and they will be mass independent.
///
///
public void SetStiffness(float value) => Jolt.PInvoke.SpringSettings_SetStiffness(this, value);
///
///
/// Selects the way in which the spring is defined. See the descriptions of the mFrequency, mStiffness and
/// mDamping properties.
///
///
/// C++:
/// Jolt/Physics/Constraints/SpringSettings.h:47
///
/// ESpringMode mMode = ESpringMode::FrequencyAndDamping
///
///
public SpringMode GetMode() => Jolt.PInvoke.SpringSettings_GetMode(this);
///
///
/// Selects the way in which the spring is defined. See the descriptions of the mFrequency, mStiffness and
/// mDamping properties.
///
///
/// C++:
/// Jolt/Physics/Constraints/SpringSettings.h:47
///
/// ESpringMode mMode = ESpringMode::FrequencyAndDamping
///
///
public void SetMode(SpringMode value) => Jolt.PInvoke.SpringSettings_SetMode(this, value);
///
///
/// When mMode = ESpringMode::FrequencyAndDamping this is the damping ratio (0 = no damping, 1 = critical
/// damping).
///
///
/// C++:
/// Jolt/Physics/Constraints/SpringSettings.h:84
///
/// float mDamping = 0.0f
///
///
///
///
/// When mMode = ESpringMode::FrequencyAndDamping this is the damping ratio (0 = no damping, 1 = critical damping).
///
/// When mMode = ESpringMode::StiffnessAndDamping this is the damping (c) in the spring equation F = -k * x - c * v for a linear or T = -k * theta - c * w for an angular spring.
/// Units are N s / m for a linear spring and N s m / rad for an angular spring.
///
/// When mMode = ESpringMode::MassNormalizedStiffnessAndDamping this is the damping (c) in the spring equation F = m_eff * (-k * x - c * v) for a linear or T = i_eff * (-k * theta - c * w) for an angular spring.
/// m_eff / i_eff is the effective mass / inertia of the constraint.
/// Units are 1 / s for a linear spring and 1 / rad s for an angular spring.
///
/// Note that if you set this to 0, you will not get an infinite oscillation. Because we integrate physics using an explicit Euler scheme, there is always energy loss.
/// This is done to keep the simulation from exploding, because with a damping of 0 and even the slightest rounding error, the oscillation could become bigger and bigger until the simulation explodes.
///
///
public float GetDamping() => Jolt.PInvoke.SpringSettings_GetDamping(this);
///
///
/// When mMode = ESpringMode::FrequencyAndDamping this is the damping ratio (0 = no damping, 1 = critical
/// damping).
///
///
/// C++:
/// Jolt/Physics/Constraints/SpringSettings.h:84
///
/// float mDamping = 0.0f
///
///
///
///
/// When mMode = ESpringMode::FrequencyAndDamping this is the damping ratio (0 = no damping, 1 = critical damping).
///
/// When mMode = ESpringMode::StiffnessAndDamping this is the damping (c) in the spring equation F = -k * x - c * v for a linear or T = -k * theta - c * w for an angular spring.
/// Units are N s / m for a linear spring and N s m / rad for an angular spring.
///
/// When mMode = ESpringMode::MassNormalizedStiffnessAndDamping this is the damping (c) in the spring equation F = m_eff * (-k * x - c * v) for a linear or T = i_eff * (-k * theta - c * w) for an angular spring.
/// m_eff / i_eff is the effective mass / inertia of the constraint.
/// Units are 1 / s for a linear spring and 1 / rad s for an angular spring.
///
/// Note that if you set this to 0, you will not get an infinite oscillation. Because we integrate physics using an explicit Euler scheme, there is always energy loss.
/// This is done to keep the simulation from exploding, because with a damping of 0 and even the slightest rounding error, the oscillation could become bigger and bigger until the simulation explodes.
///
///
public void SetDamping(float value) => Jolt.PInvoke.SpringSettings_SetDamping(this, value);
public void Dispose() => Jolt.PInvoke.SpringSettings_Destroy(this);
}
}