Photon Editor Library 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
Scene.h
Go to the documentation of this file.
1#pragma once
2
10
11#include <Common/assertion.h>
12#include <Utility/TUniquePtrVector.h>
13#include <Utility/INoCopyAndMove.h>
14#include <Utility/TSortedVector.h>
15#include <Utility/TFunction.h>
16
17#include <memory>
18#include <vector>
19#include <string>
20
21namespace ph { class Path; }
22namespace ph::editor { class GHIThreadCaller; }
23namespace ph::editor { class RenderThreadUpdateContext; }
24namespace ph::editor::ghi { class TextureDesc; }
25
26namespace ph::editor::render
27{
28
29class System;
30
33class Scene final : private INoCopyAndMove
34{
35public:
36 Scene();
37 explicit Scene(std::string debugName);
38 ~Scene();
39
43 [[nodiscard]]
45
46 void createTexture(TextureHandle handle, const ghi::TextureDesc& desc);
48 void removeTexture(TextureHandle handle);
49 void loadPicture(TextureHandle handle, const Path& pictureFile);
50
53
54 void addResource(std::unique_ptr<ISceneResource> resource);
55 void addDynamicResource(std::unique_ptr<IDynamicSceneResource> resource);
56 void removeResource(ISceneResource* resource);
60
62 const std::string& getDebugName() const;
63 void setSystem(System* sys);
64
65 void removeAllContents();
66
67public:
69
70private:
71 System* m_sys;
72 std::string m_debugName;
73
74 template<typename Content, CWeakHandle Handle>
76
78
79 std::vector<TFunction<void(GHIThreadCaller& caller)>> m_pendingSetups;
80 std::vector<TFunction<void(GHIThreadCaller& caller)>> m_pendingCleanups;
81
82 struct DynamicResourceOrderer
83 {
84 bool operator () (const IDynamicSceneResource* a, const IDynamicSceneResource* b) const
85 {
86 return a->getProcessOrder() < b->getProcessOrder();
87 }
88 };
89
90 TUniquePtrVector<ISceneResource> m_resources;
91 std::vector<ISceneResource*> m_resourcesPendingDestroy;
92 TSortedVector<IDynamicSceneResource*, DynamicResourceOrderer> m_dynamicResources;
93};
94
96{
97 PH_ASSERT(m_sys);
98 return *m_sys;
99}
100
101inline const std::string& Scene::getDebugName() const
102{
103 return m_debugName;
104}
105
106}// end namespace ph::editor::render
Thin wrapper for GHI thread interactions from another thread. Mainly to hide unrelated GHI interface ...
Definition GHIThreadCaller.h:16
Definition RenderThreadUpdateContext.h:11
A general item pool.
Definition TItemPool.h:41
Definition ghi_infos.h:101
Definition IDynamicSceneResource.h:20
virtual EProcessOrder getProcessOrder() const
Definition IDynamicSceneResource.h:39
Definition ISceneResource.h:9
Definition ProjectiveView.h:10
A scene for the editor renderer only.
Definition Scene.h:34
void runPendingCleanups(GHIThreadCaller &caller)
Definition Scene.cpp:168
void setSystem(System *sys)
Definition Scene.cpp:254
void createGHICommandsForDynamicResources(GHIThreadCaller &caller)
Definition Scene.cpp:246
void updateDynamicResources(const RenderThreadUpdateContext &ctx)
Definition Scene.cpp:238
void addResource(std::unique_ptr< ISceneResource > resource)
Definition Scene.cpp:177
Texture * getTexture(TextureHandle handle)
Definition Scene.cpp:88
ProjectiveView mainView
Definition Scene.h:68
Scene()
Definition Scene.cpp:24
void removeResource(ISceneResource *resource)
Definition Scene.cpp:209
const std::string & getDebugName() const
Definition Scene.h:101
TextureHandle declareTexture()
Definition Scene.cpp:73
~Scene()
Definition Scene.cpp:44
void runPendingSetups(GHIThreadCaller &caller)
Definition Scene.cpp:159
System & getSystem()
Definition Scene.h:95
void loadPicture(TextureHandle handle, const Path &pictureFile)
Definition Scene.cpp:111
void removeAllContents()
Definition Scene.cpp:260
void removeTexture(TextureHandle handle)
Definition Scene.cpp:93
void createTexture(TextureHandle handle, const ghi::TextureDesc &desc)
Definition Scene.cpp:78
void addDynamicResource(std::unique_ptr< IDynamicSceneResource > resource)
Definition Scene.cpp:192
void destroyRemovedResources()
Definition Scene.cpp:224
Definition System.h:26
Definition Texture.h:11
Definition PlatformDisplay.h:13
Definition DesignerObject.h:19
Definition ph_editor.h:10
Definition ph_editor.h:5