Skip to main content

SceneNodeConfig.ixx File

Configuration for scene graph integration. More...

Included Headers

#include <cassert> #include <memory> #include <helios.math> #include <helios.engine.modules.scene> #include <helios.engine.modules.rendering> #include <helios.scene> #include <helios.engine.ecs.GameObject>

Namespaces Index

namespacehelios
namespaceengine

Main engine module aggregating core infrastructure and game systems. More...

namespacebuilder

Fluent builder pattern for constructing GameObjects. More...

namespacegameObject

Factory and prototype classes for GameObject construction. More...

namespacebuilders

Domain-specific builders for configuring different aspects of GameObjects. More...

namespaceconfigs

Fine-grained configuration classes for component setup. More...

Classes Index

classSceneNodeConfig

Fluent configuration for scene graph integration. More...

Description

Configuration for scene graph integration.

File Listing

The file content with the documentation metadata removed is:

1/**
2 * @file SceneNodeConfig.ixx
3 * @brief Configuration for scene graph integration.
4 */
5module;
6
7#include <cassert>
8#include <memory>
9
10export module helios.engine.builder.gameObject.builders.configs.SceneNodeConfig;
11
12import helios.engine.ecs.GameObject;
13import helios.scene;
14import helios.engine.modules.rendering;
15import helios.engine.modules.scene;
16
17import helios.math;
18
20
21 /**
22 * @brief Fluent configuration for scene graph integration.
23 *
24 * Allows attaching a GameObject's renderable to the scene graph
25 * by creating a SceneNode and setting its parent and inheritance mode.
26 */
28
29 /**
30 * @brief Non-owning pointer to the target GameObject.
31 */
33
34 /**
35 * @brief Validates that a RenderableComponent exists.
36 */
37 void ensureRenderableComponent() {
39 assert(renderableComponent && "Unexpected nullptr for RenderableComponent.");
40 }
41
42 /**
43 * @brief Validates SceneNodeComponent presence.
44 *
45 * @param shouldBeAvailable Whether the component should exist.
46 */
47 void ensureSceneNode(const bool shouldBeAvailable) {
49
50 if (shouldBeAvailable) {
51 assert(snc && "Unexpected nullptr for SceneNodeComponent.");
52 } else {
53 assert(!snc && "Unexpected SceneNodeComponent.");
54 }
55
56 }
57
58 public:
59
60 /**
61 * @brief Constructs a SceneNodeConfig for the given GameObject.
62 *
63 * @param gameObject Target GameObject to configure.
64 */
66
67 /**
68 * @brief Creates a SceneNode and parents it to the given node.
69 *
70 * @param parent Parent SceneNode in the scene graph.
71 *
72 * @return Reference to this config for chaining.
73 */
75 ensureSceneNode(false);
76 ensureRenderableComponent();
77
78 const auto* renderableComponent = gameObject_.get<helios::engine::modules::rendering::renderable::components::RenderableComponent>();
79
80 auto renderable = renderableComponent->shareRenderable();
81
82 auto node = std::make_unique<helios::scene::SceneNode>(renderable);
83 auto node_ptr = parent->addNode(std::move(node));
84
86
87 return *this;
88 }
89
90
91 /**
92 * @brief Creates a SceneNode and parents it to another GameObject's node.
93 *
94 * @param parent Parent GameObject whose SceneNode will be the parent.
95 *
96 * @return Reference to this config for chaining.
97 */
99 ensureSceneNode(false);
100 ensureRenderableComponent();
101
102 const auto* renderableComponent = gameObject_.get<helios::engine::modules::rendering::renderable::components::RenderableComponent>();
103
104 auto renderable = renderableComponent->shareRenderable();
105
106 auto node = std::make_unique<helios::scene::SceneNode>(renderable);
107
109 assert(psn && "Unexpected missing SceneNodeComponent for parent GameObject");
110 assert(psn->sceneNode() && "Unexpected missing SceneNode for parent GameObject");
111
112 auto node_ptr = psn->sceneNode()->addNode(std::move(node));
113
115
116 return *this;
117 }
118
119 /**
120 * @brief Sets the transform inheritance mode.
121 *
122 * @param transformType Which transforms to inherit from parent.
123 *
124 * @return Reference to this config for chaining.
125 */
127 ensureSceneNode(true);
128
130 ->sceneNode()
131 ->setInheritance(transformType) ;
132
133 return *this;
134 }
135
136 };
137
138}
139

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.15.0.