ezEngine  Milestone 9
RenderData.h
1 #pragma once
2 
3 #include <RendererCore/Pipeline/Declarations.h>
4 #include <Foundation/Math/Transform.h>
5 #include <Foundation/Math/BoundingBoxSphere.h>
6 #include <Foundation/Memory/FrameAllocator.h>
7 #include <Foundation/Strings/HashedString.h>
8 #include <Foundation/Communication/Message.h>
9 
11 class EZ_RENDERERCORE_DLL ezRenderData : public ezReflectedClass
12 {
13  EZ_ADD_DYNAMIC_REFLECTION(ezRenderData, ezReflectedClass);
14 
15 public:
16 
17  struct Category
18  {
19  Category();
20  explicit Category(ezUInt16 uiValue);
21 
22  bool operator==(const Category& other) const;
23  bool operator!=(const Category& other) const;
24 
25  ezUInt16 m_uiValue;
26  };
27 
28  struct Caching
29  {
30  enum Enum
31  {
32  Never,
33  IfStatic
34  };
35  };
36 
39 
40  static Category RegisterCategory(const char* szCategoryName, SortingKeyFunc sortingKeyFunc);
41  static Category FindCategory(const char* szCategoryName);
42 
43  static const char* GetCategoryName(Category category);
44 
46  ezUInt64 GetCategorySortingKey(Category category, ezUInt32 uiRenderDataSortingKey, const ezCamera& camera) const;
47 
48  ezUInt32 m_uiBatchId;
49  ezGameObjectHandle m_hOwner;
50 
51 #if EZ_ENABLED(EZ_COMPILE_FOR_DEVELOPMENT)
52  const ezGameObject* m_pOwner;
53 #endif
54 
55  ezTransform m_GlobalTransform;
56  ezBoundingBoxSphere m_GlobalBounds;
57 
58 private:
59  struct CategoryData
60  {
61  ezHashedString m_sName;
62  SortingKeyFunc m_sortingKeyFunc;
63  };
64 
65  static ezHybridArray<CategoryData, 32> s_CategoryData;
66 };
67 
69 template <typename T>
70 static T* ezCreateRenderDataForThisFrame(const ezGameObject* pOwner, ezUInt32 uiBatchId);
71 
72 struct EZ_RENDERERCORE_DLL ezDefaultRenderDataCategories
73 {
74  static ezRenderData::Category Light;
75  static ezRenderData::Category Decal;
76  static ezRenderData::Category Sky;
77  static ezRenderData::Category LitOpaque;
78  static ezRenderData::Category LitMasked;
79  static ezRenderData::Category LitTransparent;
80  static ezRenderData::Category LitForeground;
81  static ezRenderData::Category SimpleOpaque;
82  static ezRenderData::Category SimpleTransparent;
83  static ezRenderData::Category SimpleForeground;
84  static ezRenderData::Category Selection;
85  static ezRenderData::Category GUI;
86 };
87 
88 #define ezInvalidRenderDataCategory ezRenderData::Category()
89 
90 struct EZ_RENDERERCORE_DLL ezMsgExtractRenderData : public ezMessage
91 {
92  EZ_DECLARE_MESSAGE_TYPE(ezMsgExtractRenderData, ezMessage);
93 
94  const ezView* m_pView = nullptr;
95  ezRenderData::Category m_OverrideCategory = ezInvalidRenderDataCategory;
96 
99  void AddRenderData(ezRenderData* pRenderData, ezRenderData::Category category, ezUInt32 uiSortingKey,
100  ezRenderData::Caching::Enum cachingBehavior);
101 
102 private:
103  friend class ezExtractor;
104 
106 };
107 
108 #include <RendererCore/Pipeline/Implementation/RenderData_inl.h>
109 
A camera class that stores the orientation and some basic camera settings.
Definition: Camera.h:37
Encapsulates a view on the given world through the given camera and rendered with the specified Rende...
Definition: View.h:18
Definition: Extractor.h:6
ezUInt32 m_uiBatchId
BatchId is used to group render data in batches.
Definition: RenderData.h:48
Base class for all message types. Each message type has it&#39;s own id which is used to dispatch message...
Definition: Message.h:21
Definition: RenderData.h:90
Definition: RenderData.h:28
All classes that should be dynamically reflectable, need to be derived from this base class...
Definition: DynamicRTTI.h:67
Base class for all render data. Render data must contain all information that is needed to render the...
Definition: RenderData.h:11
ezDelegate< ezUInt64(const ezRenderData *, ezUInt32, const ezCamera &)> SortingKeyFunc
This function generates a 64bit sorting key for the given render data. Data with lower sorting key is...
Definition: RenderData.h:38
Definition: RenderData.h:72
This class represents an object inside the world.
Definition: GameObject.h:20
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition: HashedString.h:24
A handle to a game object.
Definition: Declarations.h:66
Definition: RenderData.h:17