| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #include "BsCCapsuleCollider.h"
- #include "BsSceneObject.h"
- #include "BsCRigidbody.h"
- #include "BsCCapsuleColliderRTTI.h"
- namespace BansheeEngine
- {
- CCapsuleCollider::CCapsuleCollider(const HSceneObject& parent, float radius, float halfHeight)
- : CCollider(parent), mRadius(radius), mHalfHeight(halfHeight)
- {
- setName("CapsuleCollider");
- }
- void CCapsuleCollider::setNormal(const Vector3& normal)
- {
- if (mNormal == normal)
- return;
- mNormal = normal;
- mNormal.normalize();
- mLocalRotation = Quaternion::getRotationFromTo(Vector3::UNIT_X, normal);
- if (mInternal != nullptr)
- updateTransform();
- }
- void CCapsuleCollider::setCenter(const Vector3& center)
- {
- if (mLocalPosition == center)
- return;
- mLocalPosition = center;
- if (mInternal != nullptr)
- updateTransform();
- }
- void CCapsuleCollider::setHalfHeight(float halfHeight)
- {
- if (mHalfHeight == halfHeight)
- return;
- mHalfHeight = halfHeight;
- if (mInternal != nullptr)
- {
- _getInternal()->setHalfHeight(halfHeight);
- if (mParent != nullptr)
- mParent->_updateMassDistribution();
- }
- }
- void CCapsuleCollider::setRadius(float radius)
- {
- if (mRadius == radius)
- return;
- mRadius = radius;
- if (mInternal != nullptr)
- {
- _getInternal()->setRadius(radius);
- if (mParent != nullptr)
- mParent->_updateMassDistribution();
- }
- }
- SPtr<Collider> CCapsuleCollider::createInternal()
- {
- return CapsuleCollider::create(mRadius, mHalfHeight, SO()->getWorldPosition(), SO()->getWorldRotation());
- }
- RTTITypeBase* CCapsuleCollider::getRTTIStatic()
- {
- return CCapsuleColliderRTTI::instance();
- }
- RTTITypeBase* CCapsuleCollider::getRTTI() const
- {
- return CCapsuleCollider::getRTTIStatic();
- }
- }
|