BsHandleSliderLine.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 we'll use this for
  12. * 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. */
  25. HandleSliderLine(const Vector3& direction, float length, bool fixedScale);
  26. ~HandleSliderLine();
  27. /**
  28. * @copydoc HandleSlider::intersects
  29. */
  30. bool intersects(const Ray& ray, float& t) const override;
  31. /**
  32. * @copydoc HandleSlider::handleInput
  33. */
  34. void handleInput(const CameraHandlerPtr& camera, const Vector2I& inputDelta) override;
  35. /**
  36. * @brief Returns a delta value that is the result of dragging/sliding the pointer
  37. * along the line. This changes every frame and will be zero unless the slider is active.
  38. */
  39. float getDelta() const { return mDelta; }
  40. protected:
  41. /**
  42. * @copydoc HandleSlider::activate
  43. */
  44. void activate(const CameraHandlerPtr& camera, const Vector2I& pointerPos) override { mStartPosition = getPosition(); }
  45. /**
  46. * @copydoc HandleSlider::reset
  47. */
  48. void reset() override { mDelta = 0.0f; }
  49. static const float CAPSULE_RADIUS;
  50. static const float SPHERE_RADIUS;
  51. Vector3 mDirection;
  52. float mLength;
  53. float mDelta;
  54. Vector3 mStartPosition;
  55. Capsule mCapsuleCollider;
  56. Sphere mSphereCollider;
  57. };
  58. }