Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
VisualWorld.h
Go to the documentation of this file.
1#pragma once
2
5#include "Actor/Actor.h"
6#include "World/Scene.h"
10#include "Math/TVector3.h"
11#include "Utility/IMoveOnly.h"
15#include "Utility/TSpan.h"
16
17#include <Common/assertion.h>
18#include <Common/primitive_type.h>
19
20#include <vector>
21#include <memory>
22
23namespace ph { class SceneDescription; }
24namespace ph { class CoreCookingContext; }
25namespace ph { class CookingContext; }
26namespace ph { class Primitive; }
27
28namespace ph
29{
30
33class VisualWorld final : private IMoveOnly
34{
35public:
37
38 void cook(const SceneDescription& rawScene, const CoreCookingContext& coreCtx);
39
40 // HACK
41 void setReceiverPosition(const math::Vector3R& receiverPos);
42
46 const Intersector* getTLAS() const;
47
48 const EmitterSampler* getEmitterSampler() const;
49 const Scene* getScene() const;
52
57
63
64private:
65 struct SceneActor
66 {
67 std::shared_ptr<Actor> actor;
68 bool isPhantom = false;
69 };
70
71 std::unique_ptr<CookedResourceCollection> m_cookedResources;
72 std::unique_ptr<TransientResourceCache> m_cache;
73 std::vector<TransientVisualElement> m_cookedUnits;
74 math::Vector3R m_receiverPos;
75 math::AABB3D m_rootActorsBound;
76 math::AABB3D m_leafActorsBound;
77
78 std::unique_ptr<Intersector> m_tlas;
79 std::unique_ptr<EmitterSampler> m_emitterSampler;
80 std::unique_ptr<Scene> m_scene;
81 const Primitive* m_backgroundPrimitive;
82
83 void cookActors(
84 TSpan<SceneActor> sceneActors,
85 CookingContext& ctx,
86 std::vector<TransientVisualElement>& out_elements);
87
88 static std::unique_ptr<Intersector> createTopLevelAccelerator(
89 EAccelerator acceleratorType,
90 TSpanView<const Intersectable*> intersectables);
91
92 static math::AABB3D calcElementBound(TSpanView<TransientVisualElement> elements);
93};
94
95// In-header Implementations:
96
97inline void VisualWorld::setReceiverPosition(const math::Vector3R& receiverPos)
98{
99 m_receiverPos = receiverPos;
100}
101
103{
104 return m_tlas.get();
105}
106
108{
109 return m_emitterSampler.get();
110}
111
112inline const Scene* VisualWorld::getScene() const
113{
114 return m_scene.get();
115}
116
117}// end namespace ph
Provides thread-safe cooked data creation and storage. All methods are thread-safe to call,...
Definition CookedResourceCollection.h:31
Information about the world being cooked.
Definition CookingContext.h:24
Definition CoreCookingContext.h:15
Definition EmitterSampler.h:22
Marks the derived class as move only.
Definition IMoveOnly.h:23
Definition Intersector.h:14
A physical shape in the scene.
Definition Primitive.h:23
Data that describe a scene. Represents the result of running SDL commands.
Definition SceneDescription.h:14
A unified interface for accessing cooked content in a visual world.
Definition Scene.h:27
Provides thread-safe cooked data creation and storage. Similar to TransientVisualElement,...
Definition TransientResourceCache.h:25
A virtual world for image synthesis.
Definition VisualWorld.h:34
void setReceiverPosition(const math::Vector3R &receiverPos)
Definition VisualWorld.h:97
void cook(const SceneDescription &rawScene, const CoreCookingContext &coreCtx)
Definition VisualWorld.cpp:66
math::AABB3D getRootActorsBound() const
Bounds actors cooked in the first level. The bound is only available after the first level has done c...
Definition VisualWorld.cpp:380
const Scene * getScene() const
Definition VisualWorld.h:112
VisualWorld()
Definition VisualWorld.cpp:39
TransientResourceCache * getCache() const
Definition VisualWorld.cpp:375
const EmitterSampler * getEmitterSampler() const
Definition VisualWorld.h:107
math::AABB3D getLeafActorsBound() const
Bounds actors from levels finished cooking. The bound is updated every time a level has done cooking....
Definition VisualWorld.cpp:385
const Intersector * getTLAS() const
Definition VisualWorld.h:102
CookedResourceCollection * getCookedResources() const
Definition VisualWorld.cpp:370
The root for all renderer implementations.
Definition EEngineProject.h:6
std::span< const T, EXTENT > TSpanView
Same as TSpan, except that the objects are const-qualified. Note that for pointer types,...
Definition TSpan.h:19
std::span< T, EXTENT > TSpan
A contiguous sequence of objects of type T. Effectively the same as std::span.
Definition TSpan.h:12
EAccelerator
Definition EAccelerator.h:7