BsCDistanceJoint.cpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsCDistanceJoint.h"
  4. #include "BsSceneObject.h"
  5. #include "BsCDistanceJointRTTI.h"
  6. namespace BansheeEngine
  7. {
  8. CDistanceJoint::CDistanceJoint(const HSceneObject& parent)
  9. : CJoint(parent)
  10. {
  11. setName("DistanceJoint");
  12. }
  13. float CDistanceJoint::getDistance() const
  14. {
  15. if (mInternal == nullptr)
  16. return 0.0f;
  17. return _getInternal()->getDistance();
  18. }
  19. float CDistanceJoint::getMinDistance() const
  20. {
  21. return mMinDistance;
  22. }
  23. void CDistanceJoint::setMinDistance(float value)
  24. {
  25. if (mMinDistance == value)
  26. return;
  27. mMinDistance = value;
  28. if (mInternal != nullptr)
  29. _getInternal()->setMinDistance(value);
  30. }
  31. float CDistanceJoint::getMaxDistance() const
  32. {
  33. return mMaxDistance;
  34. }
  35. void CDistanceJoint::setMaxDistance(float value)
  36. {
  37. if (mMaxDistance == value)
  38. return;
  39. mMaxDistance = value;
  40. if (mInternal != nullptr)
  41. _getInternal()->setMaxDistance(value);
  42. }
  43. float CDistanceJoint::getTolerance() const
  44. {
  45. return mTolerance;
  46. }
  47. void CDistanceJoint::setTolerance(float value)
  48. {
  49. if (mTolerance == value)
  50. return;
  51. mTolerance = value;
  52. if (mInternal != nullptr)
  53. _getInternal()->setTolerance(value);
  54. }
  55. Spring CDistanceJoint::getSpring() const
  56. {
  57. return mSpring;
  58. }
  59. void CDistanceJoint::setSpring(const Spring& value)
  60. {
  61. if (mSpring == value)
  62. return;
  63. mSpring = value;
  64. if(mInternal != nullptr)
  65. _getInternal()->setSpring(value);
  66. }
  67. void CDistanceJoint::setFlag(DistanceJoint::Flag flag, bool enabled)
  68. {
  69. bool isEnabled = ((UINT32)mFlag & (UINT32)flag) != 0;
  70. if (isEnabled == enabled)
  71. return;
  72. if (enabled)
  73. mFlag = (DistanceJoint::Flag)((UINT32)mFlag | (UINT32)flag);
  74. else
  75. mFlag = (DistanceJoint::Flag)((UINT32)mFlag & ~(UINT32)flag);
  76. if (mInternal != nullptr)
  77. _getInternal()->setFlag(flag, enabled);
  78. }
  79. bool CDistanceJoint::hasFlag(DistanceJoint::Flag flag) const
  80. {
  81. return ((UINT32)mFlag & (UINT32)flag) != 0;
  82. }
  83. SPtr<Joint> CDistanceJoint::createInternal()
  84. {
  85. SPtr<Joint> joint = DistanceJoint::create();
  86. joint->_setOwner(PhysicsOwnerType::Component, this);
  87. return joint;
  88. }
  89. RTTITypeBase* CDistanceJoint::getRTTIStatic()
  90. {
  91. return CDistanceJointRTTI::instance();
  92. }
  93. RTTITypeBase* CDistanceJoint::getRTTI() const
  94. {
  95. return CDistanceJoint::getRTTIStatic();
  96. }
  97. }