LimitAngularRange.generated.cs 3.9 KB

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