BsHandleSliderLine.cpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include "BsHandleSliderLine.h"
  2. #include "BsHandleManager.h"
  3. #include "BsCapsule.h"
  4. #include "BsLineSegment3.h"
  5. #include "BsSphere.h"
  6. namespace BansheeEngine
  7. {
  8. const float HandleSliderLine::CAPSULE_RADIUS = 0.2f;
  9. const float HandleSliderLine::SPHERE_RADIUS = 0.5f;
  10. HandleSliderLine::HandleSliderLine(const Vector3& direction, float length, float snapValue, bool fixedScale)
  11. :HandleSlider(fixedScale, snapValue), mLength(length)
  12. {
  13. mDirection = Vector3::normalize(direction);
  14. Vector3 start = Vector3::ZERO;
  15. Vector3 end = start + mDirection * length;
  16. Vector3 sphereCenter = start + mDirection * std::max(0.0f, length - SPHERE_RADIUS * 2);
  17. HandleManager::instance()._registerCapsuleCollider(Capsule(LineSegment3(start, end), CAPSULE_RADIUS), this);
  18. HandleManager::instance()._registerSphereCollider(Sphere(sphereCenter, SPHERE_RADIUS), this);
  19. }
  20. HandleSliderLine::~HandleSliderLine()
  21. {
  22. HandleManager::instance()._unregisterSlider(this);
  23. }
  24. Vector3 HandleSliderLine::updateDelta(const Vector3& oldValue) const
  25. {
  26. return oldValue;
  27. // TODO - Don't forget to consider currently active transform (and also custom handle transform)
  28. // - Both position and direction need to consider it
  29. }
  30. }