BsRenderQueue.h 1.5 KB

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