Plasma Engine  2.0
Loading...
Searching...
No Matches
RenderData_inl.h
1#include <Core/World/GameObject.h>
2
3PL_ALWAYS_INLINE plRenderData::Category::Category() = default;
4
5PL_ALWAYS_INLINE plRenderData::Category::Category(plUInt16 uiValue)
6 : m_uiValue(uiValue)
7{
8}
9
10PL_ALWAYS_INLINE bool plRenderData::Category::operator==(const Category& other) const
11{
12 return m_uiValue == other.m_uiValue;
13}
14
15PL_ALWAYS_INLINE bool plRenderData::Category::operator!=(const Category& other) const
16{
17 return m_uiValue != other.m_uiValue;
18}
19
21
22// static
23PL_FORCE_INLINE const plRenderer* plRenderData::GetCategoryRenderer(Category category, const plRTTI* pRenderDataType)
24{
25 if (s_bRendererInstancesDirty)
26 {
27 CreateRendererInstances();
28 }
29
30 auto& categoryData = s_CategoryData[category.m_uiValue];
31
32 plUInt32 uiIndex = 0;
33 if (categoryData.m_TypeToRendererIndex.TryGetValue(pRenderDataType, uiIndex))
34 {
35 return s_RendererInstances[uiIndex].Borrow();
36 }
37
38 return nullptr;
39}
40
41// static
42PL_FORCE_INLINE plHashedString plRenderData::GetCategoryName(Category category)
43{
44 if (category.m_uiValue < s_CategoryData.GetCount())
45 {
46 return s_CategoryData[category.m_uiValue].m_sName;
47 }
48
49 return plHashedString();
50}
51
52PL_FORCE_INLINE plUInt64 plRenderData::GetCategorySortingKey(Category category, const plCamera& camera) const
53{
54 return s_CategoryData[category.m_uiValue].m_sortingKeyFunc(this, camera);
55}
56
58
59template <typename T>
60static T* plCreateRenderDataForThisFrame(const plGameObject* pOwner)
61{
62 static_assert(PL_IS_DERIVED_FROM_STATIC(plRenderData, T));
63
64 T* pRenderData = PL_NEW(plFrameAllocator::GetCurrentAllocator(), T);
65
66 if (pOwner != nullptr)
67 {
68 pRenderData->m_hOwner = pOwner->GetHandle();
69 }
70
71#if PL_ENABLED(PL_COMPILE_FOR_DEVELOPMENT)
72 pRenderData->m_pOwner = pOwner;
73#endif
74
75 return pRenderData;
76}
plUInt32 GetCount() const
Returns the number of active elements in the array.
Definition ArrayBase_inl.h:172
A camera class that stores the orientation and some basic camera settings.
Definition Camera.h:41
This class represents an object inside the world.
Definition GameObject.h:32
plGameObjectHandle GetHandle() const
Returns a handle to this object.
Definition GameObject_inl.h:64
This class is optimized to take nearly no memory (sizeof(void*)) and to allow very fast checks whethe...
Definition HashedString.h:25
This class holds information about reflected types. Each instance represents one type that is known t...
Definition RTTI.h:30
Base class for all render data. Render data must contain all information that is needed to render the...
Definition RenderData.h:14
This is the base class for types that handle rendering of different object types.
Definition Renderer.h:9