BsSelectionRenderer.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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 "BsColor.h"
  6. #include "BsMatrix4.h"
  7. #include "BsGpuParam.h"
  8. namespace BansheeEngine
  9. {
  10. /** @addtogroup Scene-Editor-Internal
  11. * @{
  12. */
  13. class SelectionRendererCore;
  14. /** Handles rendering of the selected SceneObject%s overlay. */
  15. class BS_ED_EXPORT SelectionRenderer
  16. {
  17. public:
  18. SelectionRenderer();
  19. ~SelectionRenderer();
  20. /** Called once per frame. Updates the overlay depending on current selection. */
  21. void update(const SPtr<Camera>& camera);
  22. private:
  23. friend class SelectionRendererCore;
  24. /**
  25. * Initializes the core thread counterpart of the selection renderer.
  26. *
  27. * @param[in] mat Material used for selection rendering.
  28. */
  29. void initializeCore(const SPtr<MaterialCore>& mat);
  30. /**
  31. * Destroys the core thread counterpart of the selection renderer.
  32. *
  33. * @param[in] core Previously constructed core thread selection renderer instance.
  34. */
  35. void destroyCore(SelectionRendererCore* core);
  36. std::atomic<SelectionRendererCore*> mCore;
  37. };
  38. /** Core thread version of the selection renderer, that handles actual rendering. */
  39. class SelectionRendererCore
  40. {
  41. friend class SelectionRenderer;
  42. struct PrivatelyConstuct { };
  43. public:
  44. SelectionRendererCore(const PrivatelyConstuct& dummy);
  45. ~SelectionRendererCore();
  46. private:
  47. /**
  48. * Initializes the selection renderer. Should be called right after construction.
  49. *
  50. * @param[in] mat Material used for selection rendering.
  51. */
  52. void initialize(const SPtr<MaterialCore>& mat);
  53. /** Triggered by the Renderer when the overlay should be rendered. */
  54. void render();
  55. /**
  56. * Updates the internal data that determines what will be rendered on the next render() call.
  57. *
  58. * @param[in] camera Camera to render the selection overlay in.
  59. * @param[in] objects A set of objects to render with the selection overlay.
  60. */
  61. void updateData(const SPtr<CameraCore>& camera, const Vector<SPtr<RenderableCore>>& objects);
  62. Vector<SPtr<RenderableCore>> mObjects;
  63. SPtr<CameraCore> mCamera;
  64. // Immutable
  65. SPtr<MaterialCore> mMaterial;
  66. SPtr<GpuParamsSetCore> mParams[2];
  67. GpuParamMat4Core mMatWorldViewProj[2];
  68. GpuParamColorCore mColor[2];
  69. GpuParamBufferCore mBoneMatrices;
  70. UINT32 mDefaultTechniqueIdx;
  71. UINT32 mAnimatedTechniqueIdx;
  72. static const Color SELECTION_COLOR;
  73. };
  74. /** @} */
  75. }