Skip to main content

SnapshotItem.ixx File

Snapshot item bundling a Renderable reference and its world matrix. More...

Included Headers

#include <cassert> #include <memory> #include <helios.math.types> #include <helios.rendering.Renderable>

Namespaces Index

namespacehelios
namespacescene

Scene graph and camera management. More...

Classes Index

structSnapshotItem

Structure for representing a snapshot item of a renderable's object state at a specific point in time. More...

Description

Snapshot item bundling a Renderable reference and its world matrix.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file SnapshotItem.ixx
3 * @brief Snapshot item bundling a Renderable reference and its world matrix.
4 */
5module;
6
7#include <cassert>
8#include <memory>
9
10export module helios.scene.SnapshotItem;
11
12import helios.rendering.Renderable;
13import helios.math.types;
14
15export namespace helios::scene {
16
17 /**
18 * @brief Structure for representing a snapshot item of a renderable's object
19 * state at a specific point in time.
20 *
21 * The structure bundles a non-owning raw pointer to a Renderable and a pre-calculated
22 * worldMatrix, serving as a lightweight DTO to be used with a `Snapshot`.
23 *
24 * A SnapshotItem captures the essential information to render an item
25 * without the need to traverse the entire Scene Graph during the
26 * rendering phase.
27 * The worldMatrix is a copy of the SceneNode's worldMatrix at the time of this
28 * creation, ensuring that its value remains constant, even if the transformation
29 * of the SceneNode should change during rendering.
30 *
31 * The caller must ensure that the Renderable remains valid for the lifetime
32 * of this SnapshotItem (typically within a single frame).
33 *
34 * While internal properties of the Renderable might change while this SnapshotItem
35 * is processed, the worldMatrix is immutable and reflects the transformation state
36 * at the moment the Snapshot was taken.
37 */
38 struct SnapshotItem {
39 private:
40 /**
41 * @brief A non-owning raw pointer to the Renderable object.
42 *
43 * The Renderable must remain valid for the lifetime of this SnapshotItem.
44 */
45 const helios::rendering::Renderable* renderable_;
46
47 /**
48 * @brief A copy of the world transformation matrix for the Renderable.
49 */
50 const helios::math::mat4f worldMatrix_;
51
52 public:
53
54
55 /**
56 * @brief Constructs a new SnapshotItem with the specified renderable
57 * and the worldMatrix.
58 *
59 * @param renderable A raw pointer to the Renderable (must remain valid for the lifetime of this item).
60 * @param worldMatrix A const ref to the world transformation matrix, which gets copied.
61 */
65 ) :
66 renderable_(renderable),
67 worldMatrix_(worldMatrix) {
68 assert(renderable_ && "Unexpected nullptr forRenderable");
69 }
70
71 /**
72 * @brief Returns a raw pointer to the Renderable of this SnapshotItem.
73 *
74 * @return A raw pointer to the Renderable of this SnapshotItem.
75 */
76 [[nodiscard]] const helios::rendering::Renderable* renderable() const noexcept {
77 return renderable_;
78 }
79
80 /**
81 * @brief Returns a const ref to the worldMatrix of this SnapshotItem.
82 * The world transformation matrix is a copy from the world transformation matrix
83 * created with this SnapshotItem.
84 *
85 * @return The const ref to the world matrix of this SnapshotItem.
86 */
87 [[nodiscard]] const helios::math::mat4f& worldMatrix() const noexcept {
88 return worldMatrix_;
89 }
90 };
91
92}

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.