using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; namespace BansheeEngine { /** @addtogroup Physics * @{ */ /// /// Represents a joint limit between two distance values. Lower value must be less than the upper value. /// [StructLayout(LayoutKind.Sequential), SerializeObject] public partial struct LimitLinearRange { /// Initializes the struct with default values. public static LimitLinearRange Default() { LimitLinearRange value = new LimitLinearRange(); value.lower = 0f; value.upper = 0f; value.contactDist = -1f; value.restitution = 0f; value.spring = new Spring(); return value; } /// /// Constructs a hard limit. Once the limit is reached the movement of the attached bodies will come to a stop. /// /// Lower distance of the limit. Must be less than . /// Upper distance of the limit. Must be more than . /// /// Distance from the limit at which it becomes active. Allows the solver to activate earlier than the limit is reached /// to avoid breaking the limit. Specify -1 for the default. /// public LimitLinearRange(float lower, float upper, float contactDist = -1f) { this.lower = lower; this.upper = upper; this.contactDist = -1f; this.restitution = 0f; this.spring = new Spring(); } /// /// Constructs a soft limit. Once the limit is reached the bodies will bounce back according to the resitution parameter /// and will be pulled back towards the limit by the provided spring. /// /// Lower distance of the limit. Must be less than . /// Upper distance of the limit. Must be more than . /// /// Spring that controls how are the bodies pulled back towards the limit when they breach it. /// /// /// Controls how do objects react when the limit is reached, values closer to zero specify non-ellastic collision, while /// those closer to one specify more ellastic (i.e bouncy) collision. Must be in [0, 1] range. /// public LimitLinearRange(float lower, float upper, Spring spring, float restitution = 0f) { this.lower = lower; this.upper = upper; this.contactDist = -1f; this.restitution = 0f; this.spring = new Spring(); } /// /// Returns a subset of this struct. This subset usually contains common fields shared with another struct. /// public LimitCommon GetBase() { LimitCommon value; value.contactDist = contactDist; value.restitution = restitution; value.spring = spring; return value; } /// /// Assigns values to a subset of fields of this struct. This subset usually contains common field shared with /// another struct. /// public void SetBase(LimitCommon value) { contactDist = value.contactDist; restitution = value.restitution; spring = value.spring; } /// Lower distance of the limit. Must be less than #upper. public float lower; /// Upper distance of the limit. Must be more than #lower. public float upper; /// /// Distance from the limit at which it becomes active. Allows the solver to activate earlier than the limit is reached /// to avoid breaking the limit. /// public float contactDist; /// /// Controls how do objects react when the limit is reached, values closer to zero specify non-ellastic collision, while /// those closer to one specify more ellastic (i.e bouncy) collision. Must be in [0, 1] range. /// public float restitution; /// Spring that controls how are the bodies pulled back towards the limit when they breach it. public Spring spring; } /** @} */ }