SliderJoint.cs 2.2 KB

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