Files
sbox-public/engine/Sandbox.Engine/Systems/Physics/PhysicsSpring.cs
s&box team 71f266059a Open source release
This commit imports the C# engine code and game files, excluding C++ source code.

[Source-Commit: ceb3d758046e50faa6258bc3b658a30c97743268]
2025-11-24 09:05:18 +00:00

41 lines
980 B
C#

namespace Sandbox.Physics;
/// <summary>
/// Spring related settings for joints such as <see cref="FixedJoint"/>.
/// </summary>
[Expose]
public record struct PhysicsSpring
{
/// <summary>
/// The stiffness of the spring
/// </summary>
public float Frequency { get; set; }
/// <summary>
/// The damping ratio of the spring, usually between 0 and 1
/// </summary>
public float Damping { get; set; }
/// <summary>
/// For weld joints only, maximum force. Not for breaking.
/// </summary>
public float Maximum { get; set; }
public PhysicsSpring( float frequency = 0.0f, float damping = 0.0f, float maximum = -1.0f )
{
Frequency = frequency;
Damping = damping;
Maximum = maximum < 0.0f ? float.MaxValue : maximum;
}
public static implicit operator Vector3( PhysicsSpring s )
{
return new Vector3( s.Frequency, s.Damping, s.Maximum );
}
public static implicit operator PhysicsSpring( Vector3 s )
{
return new PhysicsSpring( s.x, s.y, s.z );
}
}