BsHandleSliderDisc.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #include "BsHandleSliderDisc.h"
  2. #include "BsHandleManager.h"
  3. #include "BsTorus.h"
  4. #include "BsVector3.h"
  5. #include "BsQuaternion.h"
  6. namespace BansheeEngine
  7. {
  8. const float HandleSliderDisc::TORUS_RADIUS = 0.5f;
  9. HandleSliderDisc::HandleSliderDisc(const Vector3& normal, float radius, float snapValue, bool fixedScale)
  10. :HandleSlider(fixedScale, snapValue), mRadius(radius)
  11. {
  12. Vector3 x, z;
  13. mNormal.orthogonalComplement(x, z);
  14. mTorusRotation = (Matrix4)Matrix3(x, mNormal, z); // Our Torus class doesn't allow us to specify a normal so we embed it here
  15. Torus collider(radius, TORUS_RADIUS);
  16. HandleManager::instance()._registerTorusCollider(collider, this);
  17. }
  18. HandleSliderDisc::~HandleSliderDisc()
  19. {
  20. HandleManager::instance()._unregisterSlider(this);
  21. }
  22. Quaternion HandleSliderDisc::updateDelta(const Quaternion& oldValue) const
  23. {
  24. return oldValue;
  25. // TODO - Don't forget to consider currently active transform (and also custom handle transform)
  26. // - Both position and direction need to consider it
  27. }
  28. void HandleSliderDisc::setCustomTransform(const Matrix4& transform)
  29. {
  30. HandleSlider::setCustomTransform(transform * mTorusRotation);
  31. }
  32. }