BsRenderQueue.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsMaterialProxy.h"
  4. #include "BsMeshProxy.h"
  5. namespace BansheeEngine
  6. {
  7. /**
  8. * @brief Contains data needed for performing a single rendering pass.
  9. */
  10. struct BS_CORE_EXPORT RenderQueueElement
  11. {
  12. RenderQueueElement()
  13. :passIdx(0)
  14. { }
  15. MaterialProxyPtr material;
  16. MeshProxyPtr mesh;
  17. Vector3 worldPosition;
  18. UINT32 passIdx;
  19. };
  20. /**
  21. * @brief Render objects determines rendering order of objects contained within it. Normally the rendering
  22. * order is determined by object material, and can influence rendering of transparent or opaque objects,
  23. * or be used to improve performance by grouping similar objects together.
  24. *
  25. * You need to provide your own implementation of the render queue sorting method. Likely the sorting method
  26. * will need to be closely tied to the renderer used.
  27. */
  28. // TODO UNDOCUMENTED
  29. class BS_CORE_EXPORT RenderQueue
  30. {
  31. public:
  32. RenderQueue();
  33. void add(const MaterialProxyPtr& material, const MeshProxyPtr& mesh, const Vector3& worldPosForSort);
  34. /**
  35. * @brief Clears all render operations from the queue.
  36. */
  37. void clear();
  38. /**
  39. * @brief Sorts all the render operations using user-defined rules.
  40. */
  41. virtual void sort();
  42. /**
  43. * @brief Returns a list of sorted render elements. Caller must ensure
  44. * "sort" is called before this method.
  45. */
  46. const Vector<RenderQueueElement>& getSortedElements() const;
  47. protected:
  48. Vector<RenderQueueElement> mRenderElements;
  49. Vector<RenderQueueElement> mSortedRenderElements;
  50. };
  51. }