Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
CookedResourceCollection.h
Go to the documentation of this file.
1#pragma once
2
9#include "Utility/traits.h"
10#include "SDL/SdlResourceId.h"
16
17#include <Common/logging.h>
18
19#include <utility>
20
21namespace ph
22{
23
25
31{
32public:
33 std::string getStats() const override;
34
35 template<typename... DeducedArgs>
36 [[nodiscard]]
37 PrimitiveMetadata* makeMetadata(DeducedArgs&&... args)
38 {
40 m_metadatas, std::forward<DeducedArgs>(args)...);
41 }
42
43 template<CDerived<math::Transform> TransformType, typename... DeducedArgs>
44 [[nodiscard]]
45 TransformType* makeTransform(DeducedArgs&&... args)
46 {
48 m_transforms, std::forward<DeducedArgs>(args)...);
49 }
50
51 template<CDerived<Intersectable> IntersectableType, typename... DeducedArgs>
52 [[nodiscard]]
53 IntersectableType* makeIntersectable(DeducedArgs&&... args)
54 {
56 m_intersectables, std::forward<DeducedArgs>(args)...);
57 }
58
59 template<CDerived<Intersectable> IntersectableType>
60 [[nodiscard]]
61 IntersectableType* copyIntersectable(IntersectableType intersectable)
62 {
63 return makeIntersectable<IntersectableType>(std::move(intersectable));
64 }
65
66 template<CDerived<Emitter> EmitterType, typename... DeducedArgs>
67 [[nodiscard]]
68 EmitterType* makeEmitter(DeducedArgs&&... args)
69 {
71 m_emitters, std::forward<DeducedArgs>(args)...);
72 }
73
74 template<typename... DeducedArgs>
75 [[nodiscard]]
77 {
79 m_triangleBuffers, std::forward<DeducedArgs>(args)...);
80 }
81
82 template<typename... DeducedArgs>
83 CookedGeometry* makeGeometry(const SdlResourceId id, DeducedArgs&&... args)
84 {
85 return makeCookedResourceWithID(m_idToGeometry, id, std::forward<DeducedArgs>(args)...);
86 }
87
88 template<typename... DeducedArgs>
89 CookedMotion* makeMotion(const SdlResourceId id, DeducedArgs&&... args)
90 {
91 return makeCookedResourceWithID(m_idToMotion, id, std::forward<DeducedArgs>(args)...);
92 }
93
97 TSynchronized<CookedNamedResource>& getNamed();
98
99 const CookedGeometry* getGeometry(const SdlResourceId id) const;
100 const CookedMotion* getMotion(const SdlResourceId id) const;
101
102private:
103 TSynchronized<TUniquePtrVector<PrimitiveMetadata>> m_metadatas;
104 TSynchronized<TUniquePtrVector<math::Transform>> m_transforms;
105 TSynchronized<TUniquePtrVector<Intersectable>> m_intersectables;
106 TSynchronized<TUniquePtrVector<Emitter>> m_emitters;
107 TSynchronized<TUniquePtrVector<IndexedTriangleBuffer>> m_triangleBuffers;
108 TSynchronized<TSdlResourceIdMap<CookedGeometry>> m_idToGeometry;
109 TSynchronized<TSdlResourceIdMap<CookedMotion>> m_idToMotion;
110 TSynchronized<CookedNamedResource> m_namedResource;
111};
112
113}// end namespace ph
Definition CookedGeometry.h:13
Definition CookedMotion.h:22
Provides thread-safe cooked data creation and storage. All methods are thread-safe to call,...
Definition CookedResourceCollectionBase.h:25
static CookedType * makeCookedResourceWithID(TSynchronized< TSdlResourceIdMap< CookedType > > &syncedIdToResource, const SdlResourceId id, DeducedArgs &&... args)
Definition CookedResourceCollectionBase.h:55
static DerivedType * makeCookedResource(TSynchronized< TUniquePtrVector< BaseType > > &syncedResources, DeducedArgs &&... args)
Definition CookedResourceCollectionBase.h:37
Provides thread-safe cooked data creation and storage. All methods are thread-safe to call,...
Definition CookedResourceCollection.h:31
TSynchronized< CookedNamedResource > & getNamed()
Get the named resource sub-storage.
Definition CookedResourceCollection.cpp:8
CookedGeometry * makeGeometry(const SdlResourceId id, DeducedArgs &&... args)
Definition CookedResourceCollection.h:83
EmitterType * makeEmitter(DeducedArgs &&... args)
Definition CookedResourceCollection.h:68
TransformType * makeTransform(DeducedArgs &&... args)
Definition CookedResourceCollection.h:45
PrimitiveMetadata * makeMetadata(DeducedArgs &&... args)
Definition CookedResourceCollection.h:37
std::string getStats() const override
Definition CookedResourceCollection.cpp:23
IndexedTriangleBuffer * makeTriangleBuffer(DeducedArgs &&... args)
Definition CookedResourceCollection.h:76
const CookedGeometry * getGeometry(const SdlResourceId id) const
Definition CookedResourceCollection.cpp:13
CookedMotion * makeMotion(const SdlResourceId id, DeducedArgs &&... args)
Definition CookedResourceCollection.h:89
IntersectableType * makeIntersectable(DeducedArgs &&... args)
Definition CookedResourceCollection.h:53
const CookedMotion * getMotion(const SdlResourceId id) const
Definition CookedResourceCollection.cpp:18
IntersectableType * copyIntersectable(IntersectableType intersectable)
Definition CookedResourceCollection.h:61
Collection of attached components to a primitive. This type effectively "glues" various components th...
Definition PrimitiveMetadata.h:22
Definition TIndexedPolygonBuffer.h:23
The root for all renderer implementations.
Definition EEngineProject.h:6
std::uint64_t SdlResourceId
Definition SdlResourceId.h:8
PH_DEFINE_EXTERNAL_LOG_GROUP(ApiDatabase, Core)