BsCSliderJoint.cpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsCSliderJoint.h"
  4. #include "BsSceneObject.h"
  5. #include "BsCSliderJointRTTI.h"
  6. namespace BansheeEngine
  7. {
  8. CSliderJoint::CSliderJoint(const HSceneObject& parent)
  9. : CJoint(parent)
  10. {
  11. setName("SliderJoint");
  12. }
  13. float CSliderJoint::getPosition() const
  14. {
  15. if (mInternal == nullptr)
  16. return 0.0f;
  17. return _getInternal()->getPosition();
  18. }
  19. float CSliderJoint::getSpeed() const
  20. {
  21. if (mInternal == nullptr)
  22. return 0.0f;
  23. return _getInternal()->getSpeed();
  24. }
  25. LimitLinearRange CSliderJoint::getLimit() const
  26. {
  27. return mLimit;
  28. }
  29. void CSliderJoint::setLimit(const LimitLinearRange& limit)
  30. {
  31. if (mLimit == limit)
  32. return;
  33. mLimit = limit;
  34. if (mInternal != nullptr)
  35. _getInternal()->setLimit(limit);
  36. }
  37. void CSliderJoint::setFlag(SliderJoint::Flag flag, bool enabled)
  38. {
  39. bool isEnabled = ((UINT32)mFlag & (UINT32)flag) != 0;
  40. if (isEnabled == enabled)
  41. return;
  42. if (enabled)
  43. mFlag = (SliderJoint::Flag)((UINT32)mFlag | (UINT32)flag);
  44. else
  45. mFlag = (SliderJoint::Flag)((UINT32)mFlag & ~(UINT32)flag);
  46. if (mInternal != nullptr)
  47. _getInternal()->setFlag(flag, enabled);
  48. }
  49. bool CSliderJoint::hasFlag(SliderJoint::Flag flag) const
  50. {
  51. return ((UINT32)mFlag & (UINT32)flag) != 0;
  52. }
  53. SPtr<Joint> CSliderJoint::createInternal()
  54. {
  55. return SliderJoint::create();
  56. }
  57. RTTITypeBase* CSliderJoint::getRTTIStatic()
  58. {
  59. return CSliderJointRTTI::instance();
  60. }
  61. RTTITypeBase* CSliderJoint::getRTTI() const
  62. {
  63. return CSliderJoint::getRTTIStatic();
  64. }
  65. }