8 #ifndef NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP 9 #define NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP 11 #include <Nazara/Graphics/CullingList.hpp> 12 #include <Nazara/Graphics/InstancedRenderable.hpp> 13 #include <Nazara/Utility/Node.hpp> 14 #include <NDK/Component.hpp> 15 #include <unordered_map> 19 class GraphicsComponent;
21 using GraphicsComponentCullingList = Nz::CullingList<GraphicsComponent>;
24 class NDK_API
GraphicsComponent :
public Component<GraphicsComponent>,
public Nz::HandledObject<GraphicsComponent>
29 using RenderableList = std::vector<Nz::InstancedRenderableRef>;
35 inline void AddToCullingList(GraphicsComponentCullingList* cullingList)
const;
45 inline bool DoesRequireRealTimeReflections()
const;
47 inline void EnsureBoundingVolumeUpdate()
const;
48 inline void EnsureTransformMatrixUpdate()
const;
50 inline void GetAttachedRenderables(RenderableList* renderables)
const;
51 inline std::size_t GetAttachedRenderableCount()
const;
55 inline void RemoveFromCullingList(GraphicsComponentCullingList* cullingList)
const;
60 static ComponentIndex componentIndex;
65 void ConnectInstancedRenderableSignals(Renderable& renderable);
67 inline void InvalidateBoundingVolume()
const;
70 inline void InvalidateRenderables();
71 void InvalidateReflectionMap();
72 inline void InvalidateTransformMatrix();
74 void RegisterMaterial(
Nz::Material* material, std::size_t count = 1);
76 void OnAttached()
override;
79 void OnDetached()
override;
81 void OnInstancedRenderableResetMaterials(
const Nz::InstancedRenderable* renderable, std::size_t newMaterialCount);
83 void OnMaterialReflectionChange(
const Nz::Material* material, Nz::ReflectionMode reflectionMode);
84 void OnNodeInvalidated(
const Nz::Node* node);
88 void UpdateBoundingVolume()
const;
89 void UpdateTransformMatrix()
const;
91 NazaraSlot(Nz::Node, OnNodeInvalidation, m_nodeInvalidationSlot);
95 NazaraSlot(
Nz::Material, OnMaterialReflectionModeChange, reflectionModelChangeSlot);
97 std::size_t renderableCounter;
103 data(transformMatrix),
108 Renderable(
const Renderable&) =
delete;
109 Renderable(Renderable&& rhs) noexcept =
default;
114 renderableReleaseSlot.Disconnect();
117 Renderable& operator=(
const Renderable&) =
delete;
118 Renderable& operator=(Renderable&& r) noexcept =
default;
120 NazaraSlot(
Nz::InstancedRenderable, OnInstancedRenderableInvalidateBoundingVolume, renderableBoundingVolumeInvalidationSlot);
122 NazaraSlot(
Nz::InstancedRenderable, OnInstancedRenderableInvalidateMaterial, renderableMaterialInvalidationSlot);
127 mutable Nz::InstancedRenderable::InstanceData data;
129 mutable bool dataUpdated;
132 using VolumeCullingListEntry = GraphicsComponentCullingList::VolumeEntry;
134 struct VolumeCullingEntry
136 VolumeCullingListEntry listEntry;
138 NazaraSlot(GraphicsComponentCullingList, OnCullingListRelease, cullingListReleaseSlot);
141 std::size_t m_reflectiveMaterialCount;
142 mutable std::vector<VolumeCullingEntry> m_volumeCullingEntries;
143 std::vector<Renderable> m_renderables;
144 std::unordered_map<const Nz::Material*, MaterialEntry> m_materialEntries;
148 mutable bool m_boundingVolumeUpdated;
149 mutable bool m_transformMatrixUpdated;
150 unsigned int m_reflectionMapSize;
154 #include <NDK/Components/GraphicsComponent.inl> 156 #endif // NDK_COMPONENTS_GRAPHICSCOMPONENT_HPP TODO: For now is unable to display different color in the history, it needs a RichTextDrawer to do so...
Definition: Algorithm.hpp:12
Graphics class that represents the rendering queue for our scene.
Definition: AbstractRenderQueue.hpp:26
Graphics class that represents an instancer renderable.
Definition: InstancedRenderable.hpp:30
Core class that represents a reference to an object.
Definition: ObjectRef.hpp:18
NDK class that represents the rendering system.
Definition: RenderSystem.hpp:24
Graphics class that represents a material.
Definition: Material.hpp:51
NDK class that represents the component for graphics.
Definition: GraphicsComponent.hpp:24
NDK class that represents the common base of all components.
Definition: BaseComponent.hpp:17