BsHandleSliderLine.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
  2. //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
  3. #pragma once
  4. #include "BsEditorPrerequisites.h"
  5. #include "Handles/BsHandleSlider.h"
  6. #include "Math/BsCapsule.h"
  7. #include "Math/BsSphere.h"
  8. namespace bs
  9. {
  10. /** @addtogroup Handles
  11. * @{
  12. */
  13. /**
  14. * Handle slider that returns a delta value as you drag the pointer along a line. For intersection purposes the line
  15. * is internally by a capsule and a sphere at its cap (assuming this will be used for arrow-like handles).
  16. */
  17. class BS_ED_EXPORT HandleSliderLine : public HandleSlider
  18. {
  19. public:
  20. /**
  21. * Constructs a new line slider.
  22. *
  23. * @param[in] direction Direction of the line.
  24. * @param[in] length Length of the slider.
  25. * @param[in] fixedScale If true the handle slider will always try to maintain the same visible area in the
  26. * viewport regardless of distance from camera.
  27. * @param[in] layer Layer that allows filtering of which sliders are interacted with from a specific camera.
  28. */
  29. HandleSliderLine(const Vector3& direction, float length, bool fixedScale, UINT64 layer);
  30. ~HandleSliderLine();
  31. /** @copydoc HandleSlider::intersects */
  32. bool intersects(const Vector2I& screenPos, const Ray& ray, float& t) const override;
  33. /** @copydoc HandleSlider::handleInput */
  34. void handleInput(const SPtr<Camera>& camera, const Vector2I& inputDelta) override;
  35. /**
  36. * Returns a delta value that is the result of dragging/sliding the pointer along the line. This changes every
  37. * frame and will be zero unless the slider is active.
  38. */
  39. float getDelta() const { return mDelta; }
  40. protected:
  41. /** @copydoc HandleSlider::activate */
  42. void activate(const SPtr<Camera>& camera, const Vector2I& pointerPos) override { mStartPosition = getPosition(); }
  43. /** @copydoc HandleSlider::reset */
  44. void reset() override { mDelta = 0.0f; }
  45. static const float CAPSULE_RADIUS;
  46. static const float SPHERE_RADIUS;
  47. Vector3 mDirection;
  48. float mLength;
  49. float mDelta;
  50. Vector3 mStartPosition;
  51. Capsule mCapsuleCollider;
  52. Sphere mSphereCollider;
  53. };
  54. /** @} */
  55. }