BsSelectionRenderer.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 "BsRendererExtension.h"
  6. #include "BsColor.h"
  7. #include "BsMatrix4.h"
  8. #include "BsGpuParam.h"
  9. namespace bs
  10. {
  11. /** @addtogroup Scene-Editor-Internal
  12. * @{
  13. */
  14. class SelectionRendererCore;
  15. /** Handles rendering of the selected SceneObject%s overlay. */
  16. class BS_ED_EXPORT SelectionRenderer
  17. {
  18. public:
  19. SelectionRenderer();
  20. ~SelectionRenderer();
  21. /** Called once per frame. Updates the overlay depending on current selection. */
  22. void update(const SPtr<Camera>& camera);
  23. private:
  24. friend class SelectionRendererCore;
  25. SPtr<SelectionRendererCore> mRenderer;
  26. };
  27. /** Core thread version of the selection renderer, that handles actual rendering. */
  28. class SelectionRendererCore : public RendererExtension
  29. {
  30. friend class SelectionRenderer;
  31. public:
  32. SelectionRendererCore();
  33. private:
  34. /** @copydoc RendererExtension::initialize */
  35. void initialize(const Any& data) override;
  36. /** @copydoc RendererExtension::check */
  37. bool check(const CameraCore& camera) override;
  38. /** @copydoc RendererExtension::render */
  39. void render(const CameraCore& camera) override;
  40. /**
  41. * Updates the internal data that determines what will be rendered on the next render() call.
  42. *
  43. * @param[in] camera Camera to render the selection overlay in.
  44. * @param[in] objects A set of objects to render with the selection overlay.
  45. */
  46. void updateData(const SPtr<CameraCore>& camera, const Vector<SPtr<RenderableCore>>& objects);
  47. Vector<SPtr<RenderableCore>> mObjects;
  48. SPtr<CameraCore> mCamera;
  49. // Immutable
  50. SPtr<MaterialCore> mMaterial;
  51. SPtr<GpuParamsSetCore> mParams[4];
  52. GpuParamMat4Core mMatWorldViewProj[4];
  53. GpuParamColorCore mColor[4];
  54. GpuParamBufferCore mBoneMatrices[4];
  55. UINT32 mTechniqueIndices[4];
  56. static const Color SELECTION_COLOR;
  57. };
  58. /** @} */
  59. }