2
0

BsCPlaneCollider.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #include "BsCPlaneCollider.h"
  4. #include "BsSceneObject.h"
  5. #include "BsCPlaneColliderRTTI.h"
  6. namespace BansheeEngine
  7. {
  8. CPlaneCollider::CPlaneCollider(const HSceneObject& parent)
  9. : CCollider(parent)
  10. {
  11. setName("PlaneCollider");
  12. }
  13. void CPlaneCollider::setNormal(const Vector3& normal)
  14. {
  15. if (mNormal == normal)
  16. return;
  17. mNormal = normal;
  18. mNormal.normalize();
  19. mLocalRotation = Quaternion::getRotationFromTo(Vector3::UNIT_X, normal);
  20. mLocalPosition = mNormal * mDistance;
  21. if(mInternal != nullptr)
  22. updateTransform();
  23. }
  24. void CPlaneCollider::setDistance(float distance)
  25. {
  26. if (mDistance == distance)
  27. return;
  28. mDistance = distance;
  29. mLocalPosition = mNormal * distance;
  30. if (mInternal != nullptr)
  31. updateTransform();
  32. }
  33. SPtr<Collider> CPlaneCollider::createInternal()
  34. {
  35. return PlaneCollider::create(SO()->getWorldPosition(), SO()->getWorldRotation());
  36. }
  37. RTTITypeBase* CPlaneCollider::getRTTIStatic()
  38. {
  39. return CPlaneColliderRTTI::instance();
  40. }
  41. RTTITypeBase* CPlaneCollider::getRTTI() const
  42. {
  43. return CPlaneCollider::getRTTIStatic();
  44. }
  45. }