SliderJoint.cs 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. namespace BansheeEngine
  4. {
  5. /** @addtogroup Physics
  6. * @{
  7. */
  8. /// <summary>
  9. /// Joint that removes all but a single translational degree of freedom. Bodies are allowed to move along a single axis.
  10. /// </summary>
  11. public sealed class SliderJoint : Joint
  12. {
  13. [SerializeField]
  14. private SerializableData data = new SerializableData();
  15. /// <summary>
  16. /// Determines the limit that constrains the movement of the joint to a specific minimum and maximum distance. You
  17. /// must enable <see cref="EnableLimit"/> for this to be enforced.
  18. /// </summary>
  19. public LimitLinearRange Limit
  20. {
  21. get { return [email protected]; }
  22. set
  23. {
  24. if ([email protected] == value)
  25. return;
  26. [email protected] = value;
  27. if (Native != null)
  28. Native.Limit = value;
  29. }
  30. }
  31. /// <summary>
  32. /// Enables or disables the limit that clamps the movement of the joint.
  33. /// </summary>
  34. public bool EnableLimit
  35. {
  36. get { return [email protected]; }
  37. set
  38. {
  39. if ([email protected] == value)
  40. return;
  41. [email protected] = value;
  42. if (Native != null)
  43. Native.EnableLimit = value;
  44. }
  45. }
  46. /// <summary>
  47. /// Returns the native joint wrapped by this component.
  48. /// </summary>
  49. private NativeSliderJoint Native
  50. {
  51. get { return (NativeSliderJoint)native; }
  52. }
  53. /// <inheritdoc/>
  54. internal override NativeJoint CreateNative()
  55. {
  56. NativeSliderJoint joint = new NativeSliderJoint(commonData.@internal, data.@internal);
  57. return joint;
  58. }
  59. /// <summary>
  60. /// Holds all data the joint component needs to persist through serialization.
  61. /// </summary>
  62. [SerializeObject]
  63. internal new class SerializableData
  64. {
  65. public ScriptSliderJointData @internal;
  66. public SerializableData()
  67. {
  68. @internal.limit = new LimitLinearRange();
  69. @internal.enableLimit = false;
  70. }
  71. }
  72. }
  73. /** @} */
  74. }