BsHandleSliderLine.h 2.3 KB

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