LimitLinear.generated.cs 3.5 KB

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