BsHandleSliderLine.h 2.0 KB

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