BsRenderQueue.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #pragma once
  2. #include "BsCorePrerequisites.h"
  3. #include "BsMaterial.h"
  4. namespace BansheeEngine
  5. {
  6. /**
  7. * @brief Slightly more fine grained version of RenderOperation, as each pass
  8. * is specified as an individual operation. Used for sorting within the RenderQueue.
  9. */
  10. struct BS_CORE_EXPORT SortedRenderOp
  11. {
  12. SortedRenderOp()
  13. :baseOperation(nullptr), passIdx(0)
  14. { }
  15. const RenderOperation* baseOperation;
  16. UINT32 passIdx;
  17. };
  18. /**
  19. * @brief Render objects determines rendering order of objects contained within it. Normally the rendering
  20. * order is determined by object material, and can influence rendering of transparent or opaque objects,
  21. * or be used to improve performance by grouping similar objects together.
  22. *
  23. * You need to provide your own implementation of the render queue sorting method. Likely the sorting method
  24. * will need to be closely tied to the renderer used.
  25. */
  26. // TODO UNDOCUMENTED
  27. class BS_CORE_EXPORT RenderQueue
  28. {
  29. public:
  30. RenderQueue();
  31. void add(const Material::CoreProxyPtr& material, const MeshRenderDataPtr& mesh, const Vector3& worldPosForSort);
  32. /**
  33. * @brief Clears all render operations from the queue.
  34. */
  35. void clear();
  36. /**
  37. * @brief Sorts all the render operations using user-defined rules.
  38. */
  39. virtual void sort() = 0;
  40. /**
  41. * @brief Returns a list of sorted render operations. Caller must ensure
  42. * "sort" is called before this method.
  43. */
  44. const Vector<SortedRenderOp>& getSortedRenderOps() const;
  45. protected:
  46. Vector<RenderOperation> mRenderOperations;
  47. Vector<SortedRenderOp> mSortedRenderOps;
  48. };
  49. }