LimitConeRange.generated.cs 4.3 KB

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