LimitLinearRange.generated.cs 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using System;
  2. using System.Runtime.CompilerServices;
  3. using System.Runtime.InteropServices;
  4. namespace BansheeEngine
  5. {
  6. /** @addtogroup Physics
  7. * @{
  8. */
  9. /// <summary>
  10. /// Represents a joint limit between two distance values. Lower value must be less than the upper value.
  11. /// </summary>
  12. [StructLayout(LayoutKind.Sequential), SerializeObject]
  13. public partial struct LimitLinearRange
  14. {
  15. /// <summary>Initializes the struct with default values.</summary>
  16. public static LimitLinearRange Default()
  17. {
  18. LimitLinearRange value = new LimitLinearRange();
  19. value.lower = 0f;
  20. value.upper = 0f;
  21. value.contactDist = -1f;
  22. value.restitution = 0f;
  23. value.spring = new Spring();
  24. return value;
  25. }
  26. /// <summary>
  27. /// Constructs a hard limit. Once the limit is reached the movement of the attached bodies will come to a stop.
  28. /// </summary>
  29. /// <param name="lower">Lower distance of the limit. Must be less than <paramref name="upper"/>.</param>
  30. /// <param name="upper">Upper distance of the limit. Must be more than <paramref name="lower"/>.</param>
  31. /// <param name="contactDist">
  32. /// Distance from the limit at which it becomes active. Allows the solver to activate earlier than the limit is reached
  33. /// to avoid breaking the limit. Specify -1 for the default.
  34. /// </param>
  35. public LimitLinearRange(float lower, float upper, float contactDist = -1f)
  36. {
  37. this.lower = lower;
  38. this.upper = upper;
  39. this.contactDist = -1f;
  40. this.restitution = 0f;
  41. this.spring = new Spring();
  42. }
  43. /// <summary>
  44. /// Constructs a soft limit. Once the limit is reached the bodies will bounce back according to the resitution parameter
  45. /// and will be pulled back towards the limit by the provided spring.
  46. /// </summary>
  47. /// <param name="lower">Lower distance of the limit. Must be less than <paramref name="upper"/>.</param>
  48. /// <param name="upper">Upper distance of the limit. Must be more than <paramref name="lower"/>.</param>
  49. /// <param name="spring">
  50. /// Spring that controls how are the bodies pulled back towards the limit when they breach it.
  51. /// </param>
  52. /// <param name="restitution">
  53. /// Controls how do objects react when the limit is reached, values closer to zero specify non-ellastic collision, while
  54. /// those closer to one specify more ellastic (i.e bouncy) collision. Must be in [0, 1] range.
  55. /// </param>
  56. public LimitLinearRange(float lower, float upper, Spring spring, float restitution = 0f)
  57. {
  58. this.lower = lower;
  59. this.upper = upper;
  60. this.contactDist = -1f;
  61. this.restitution = 0f;
  62. this.spring = new Spring();
  63. }
  64. ///<summary>
  65. /// Returns a subset of this struct. This subset usually contains common fields shared with another struct.
  66. ///</summary>
  67. public LimitCommon GetBase()
  68. {
  69. LimitCommon value;
  70. value.contactDist = contactDist;
  71. value.restitution = restitution;
  72. value.spring = spring;
  73. return value;
  74. }
  75. ///<summary>
  76. /// Assigns values to a subset of fields of this struct. This subset usually contains common field shared with
  77. /// another struct.
  78. ///</summary>
  79. public void SetBase(LimitCommon value)
  80. {
  81. contactDist = value.contactDist;
  82. restitution = value.restitution;
  83. spring = value.spring;
  84. }
  85. /// <summary>Lower distance of the limit. Must be less than #upper.</summary>
  86. public float lower;
  87. /// <summary>Upper distance of the limit. Must be more than #lower.</summary>
  88. public float upper;
  89. /// <summary>
  90. /// Distance from the limit at which it becomes active. Allows the solver to activate earlier than the limit is reached
  91. /// to avoid breaking the limit.
  92. /// </summary>
  93. public float contactDist;
  94. /// <summary>
  95. /// Controls how do objects react when the limit is reached, values closer to zero specify non-ellastic collision, while
  96. /// those closer to one specify more ellastic (i.e bouncy) collision. Must be in [0, 1] range.
  97. /// </summary>
  98. public float restitution;
  99. /// <summary>Spring that controls how are the bodies pulled back towards the limit when they breach it.</summary>
  100. public Spring spring;
  101. }
  102. /** @} */
  103. }