5 #include "ISceneElement.h"
8 #include "ISceneElementRemover.h"
9 #include "ISceneElementInGraphObserver.h"
10 #include "MortonKey.h"
11 #include "PackedRenderable.h"
12 #include "TextRenderable.h"
25 template <
class TRenderableType>
26 class SceneElement :
public Resources::IBuiltResource
29 SceneElement(TRenderableType* pRenderable,
const Streaming::MortonKey& key, std::string name)
32 , m_pRenderable(pRenderable)
35 , m_name(std::move(name))
41 Eegeo_ASSERT(m_pRemover != NULL);
42 m_pRemover->Remove(
this);
44 #if !defined(EEGEO_UNITY)
45 Eegeo_ASSERT(m_pRenderable != NULL);
48 Eegeo_DELETE(m_pRenderable);
58 bool IsInSceneGraph()
const
63 void RemovedFromSceneGraph()
66 if(m_pObserver != NULL)
68 m_pObserver->OnRemovedFromSceneGraph(
this);
72 void AddedToSceneGraph()
75 if(m_pObserver != NULL)
77 m_pObserver->OnAddedToSceneGraph(
this);
86 const std::string& GetName()
const
96 void SetRemover(Rendering::Scene::ISceneElementRemover<TRenderableType>* remover)
98 Eegeo_ASSERT(m_pRemover == NULL);
102 void SetObserver(Scene::ISceneElementInGraphObserver<TRenderableType>* pObserver)
104 m_pObserver = pObserver;
107 TRenderableType& GetResource()
const {
return *m_pRenderable; }
109 inline static void Prefetch(
const SceneElement<TRenderableType>* pSceneElement)
112 const int prefetchForRead = 0;
113 const u8* p =
reinterpret_cast<const u8*
>(pSceneElement);
114 __builtin_prefetch(p + 0, prefetchForRead, 0);
118 Scene::ISceneElementRemover<TRenderableType>* m_pRemover;
119 Scene::ISceneElementInGraphObserver<TRenderableType>* m_pObserver;
120 TRenderableType* m_pRenderable;