CmRenderQueue.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include "CmPrerequisites.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 CM_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. class CM_EXPORT RenderQueue
  26. {
  27. public:
  28. RenderQueue();
  29. /**
  30. * @brief Adds a new render operation to the rendering queue. These operations will be sorted
  31. * and rendered by the Renderer in sorted order.
  32. *
  33. * @param material The material to use for rendering the object.
  34. * @param mesh The mesh to render.
  35. * @param submeshIdx Sub-mesh index in "mesh" to render.
  36. * @param worldPosForSort The world position used for sorting.
  37. */
  38. void add(const MaterialPtr& material, const MeshBasePtr& mesh, UINT32 submeshIdx, const Vector3& worldPosForSort);
  39. /**
  40. * @brief Clears all render operations from the queue.
  41. */
  42. void clear();
  43. /**
  44. * @brief Sorts all the render operations using user-defined rules.
  45. */
  46. virtual void sort() = 0;
  47. /**
  48. * @brief Returns a list of sorted render operations. Caller must ensure
  49. * "sort" is called before this method.
  50. */
  51. const Vector<SortedRenderOp>& getSortedRenderOps() const;
  52. protected:
  53. Vector<RenderOperation> mRenderOperations;
  54. Vector<SortedRenderOp> mSortedRenderOps;
  55. };
  56. }