BsSceneViewHandler.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #pragma once
  2. #include "BsEditorPrerequisites.h"
  3. #include "BsVector2I.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Handles various operations specific to the scene view, like updating,
  8. * selecting and rendering handles, selecting objects, rendering scene grid, etc.
  9. *
  10. * @note Internal class.
  11. */
  12. class BS_ED_EXPORT SceneViewHandler
  13. {
  14. public:
  15. SceneViewHandler(EditorWidgetBase* parentWidget, const SPtr<Camera>& camera);
  16. virtual ~SceneViewHandler();
  17. /**
  18. * @brief Called once per frame. Updates gizmos and the scene grid.
  19. */
  20. void update();
  21. /**
  22. * @brief Updates currently active handles.
  23. *
  24. * @param position Position of the pointer relative to the scene camera viewport.
  25. * @param delta Movement of the pointer since last frame.
  26. */
  27. void updateHandle(const Vector2I& position, const Vector2I& delta);
  28. /**
  29. * @brief Updates the selection overlay for currently selected object(s).
  30. */
  31. void updateSelection();
  32. /**
  33. * @brief Selects a handle under the pointer position.
  34. *
  35. * @param position Position of the pointer relative to the scene camera viewport.
  36. */
  37. void trySelectHandle(const Vector2I& position);
  38. /**
  39. * @brief Checks is any handle currently active.
  40. */
  41. bool isHandleActive() const;
  42. /**
  43. * @brief Deselects any currently active handles.
  44. */
  45. void clearHandleSelection();
  46. /**
  47. * @brief Attempts to select a scene object under the pointer position.
  48. *
  49. * @param position Position of the pointer relative to the scene camera viewport.
  50. * @param additive Should this selection add to the existing selection, or replace it.
  51. */
  52. void pickObject(const Vector2I& position, bool additive);
  53. protected:
  54. /**
  55. * @brief Checks is the pointer currently within the provided window, and if it is not
  56. * the cursor is wrapped in such a way so that it is returned to within the window bounds.
  57. *
  58. * @return How far was the cursor moved due to wrapping. This will be (0, 0) if the cursor is within
  59. * window bounds initially.
  60. */
  61. Vector2I wrapCursorToWindow();
  62. private:
  63. EditorWidgetBase* mParentWidget;
  64. SPtr<Camera> mCamera;
  65. SceneGrid* mSceneGrid;
  66. SelectionRenderer* mSelectionRenderer;
  67. Vector2I mMouseDeltaCompensate;
  68. };
  69. }