| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #include "Components/BsCDistanceJoint.h"
- #include "Scene/BsSceneObject.h"
- #include "RTTI/BsCDistanceJointRTTI.h"
- namespace bs
- {
- CDistanceJoint::CDistanceJoint()
- : CJoint(mDesc)
- { }
- CDistanceJoint::CDistanceJoint(const HSceneObject& parent)
- : CJoint(parent, mDesc)
- {
- setName("DistanceJoint");
- }
- float CDistanceJoint::getDistance() const
- {
- if (mInternal == nullptr)
- return 0.0f;
- return _getInternal()->getDistance();
- }
- float CDistanceJoint::getMinDistance() const
- {
- return mDesc.minDistance;
- }
- void CDistanceJoint::setMinDistance(float value)
- {
- if (mDesc.minDistance == value)
- return;
- mDesc.minDistance = value;
- if (mInternal != nullptr)
- _getInternal()->setMinDistance(value);
- }
- float CDistanceJoint::getMaxDistance() const
- {
- return mDesc.maxDistance;
- }
- void CDistanceJoint::setMaxDistance(float value)
- {
- if (mDesc.maxDistance == value)
- return;
- mDesc.maxDistance = value;
- if (mInternal != nullptr)
- _getInternal()->setMaxDistance(value);
- }
- float CDistanceJoint::getTolerance() const
- {
- return mDesc.tolerance;
- }
- void CDistanceJoint::setTolerance(float value)
- {
- if (mDesc.tolerance == value)
- return;
- mDesc.tolerance = value;
- if (mInternal != nullptr)
- _getInternal()->setTolerance(value);
- }
- Spring CDistanceJoint::getSpring() const
- {
- return mDesc.spring;
- }
- void CDistanceJoint::setSpring(const Spring& value)
- {
- if (mDesc.spring == value)
- return;
- mDesc.spring = value;
- if(mInternal != nullptr)
- _getInternal()->setSpring(value);
- }
- void CDistanceJoint::setFlag(DistanceJointFlag flag, bool enabled)
- {
- bool isEnabled = ((UINT32)mDesc.flag & (UINT32)flag) != 0;
- if (isEnabled == enabled)
- return;
- if (enabled)
- mDesc.flag = (DistanceJointFlag)((UINT32)mDesc.flag | (UINT32)flag);
- else
- mDesc.flag = (DistanceJointFlag)((UINT32)mDesc.flag & ~(UINT32)flag);
- if (mInternal != nullptr)
- _getInternal()->setFlag(flag, enabled);
- }
- bool CDistanceJoint::hasFlag(DistanceJointFlag flag) const
- {
- return ((UINT32)mDesc.flag & (UINT32)flag) != 0;
- }
- SPtr<Joint> CDistanceJoint::createInternal()
- {
- SPtr<Joint> joint = DistanceJoint::create(mDesc);
- joint->_setOwner(PhysicsOwnerType::Component, this);
- return joint;
- }
- RTTITypeBase* CDistanceJoint::getRTTIStatic()
- {
- return CDistanceJointRTTI::instance();
- }
- RTTITypeBase* CDistanceJoint::getRTTI() const
- {
- return CDistanceJoint::getRTTIStatic();
- }
- }
|