refactor: Add update and render functions to Scene, SceneObject and Component classes#19
Open
MichalSzandar wants to merge 3 commits into
Open
refactor: Add update and render functions to Scene, SceneObject and Component classes#19MichalSzandar wants to merge 3 commits into
MichalSzandar wants to merge 3 commits into
Conversation
* add update() function * store weak_ptr to the owner of the object
There was a problem hiding this comment.
Pull request overview
Introduces an update/render lifecycle to the scene graph: Scene, SceneObject, and Component now expose update(const Context&) and render(SDL_Renderer*), with Component storing a weak_ptr back to its owning SceneObject. The component-creation pipeline (Parser → ComponentRegistry → concrete creators like BlinkComponent::createBlinker) is threaded through with the new owner argument, the C++ standard is bumped to 20 (for std::jthread), and the clang-tidy header filter is consolidated into a single regex.
Changes:
- Add virtual
update/rendertoComponent(now non-default-constructible, owns aweak_ptr<SceneObject>) and propagate the corresponding methods throughSceneObjectand the newScene::update/Scene::render. - Thread
std::shared_ptr<SceneObject> ownerthroughComponentRegistry::build,Parser::buildComponent, andBlinkComponent::createBlinker/constructor. - Bump
CMAKE_CXX_STANDARDto 20 and rewrite.clang-tidyheader filtering to a single negative-lookahead regex.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| CMakeLists.txt | Raises C++ standard from 17 to 20. |
| src/CMakeLists.txt | Adds new scene/Scene.cpp to the runtime_core target. |
| include/scene/Scene.hpp / src/scene/Scene.cpp | New Scene::update/Scene::render iterating over objects (render gated on isVisible). |
| include/scene/SceneObject.hpp / src/scene/SceneObject.cpp | Adds update/render forwarding to components; setTransform now takes a const ref. |
| include/scene/components/Component.hpp | Makes Component abstract, removes default ctor, stores weak_ptr owner, adds pure-virtual update/render. |
| include/scene/components/BlinkComponent.hpp / .cpp | Updates ctor to take owner, implements update (TODO) and render (no-op), updates creator signature. |
| include/scene/components/ComponentRegistry.hpp / .cpp | ComponentCreatorFunc and build now take an owner shared_ptr. |
| include/parser/Parser.hpp / src/parser/Parser.cpp | buildComponent accepts and forwards the owner to the registry. |
| .clang-tidy | Replaces HeaderFilterRegex/ExcludeHeaderFilterRegex pair with a single negative-lookahead regex. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| WarningsAsErrors: '' | ||
| HeaderFilterRegex: '.*' | ||
| ExcludeHeaderFilterRegex: '.*\.(pb\.h|pb\.cc)$' | ||
| HeaderFilterRegex: '^(?!.*\.(pb\.h|pb\.cc)$).*$' |
Comment on lines
16
to
19
| Component(const Component&) = default; | ||
| Component(Component&&) = default; | ||
| Component& operator=(const Component&) = default; | ||
| Component& operator=(Component&&) = default; |
Comment on lines
+5
to
+17
| void Scene::update(const Context& ctx) { | ||
| for (const auto& obj : objects) { | ||
| obj->update(ctx); | ||
| } | ||
| } | ||
|
|
||
| void Scene::render(SDL_Renderer* renderer) { | ||
| for (const auto& obj : objects) { | ||
| if (obj->isVisible) { | ||
| obj->render(renderer); | ||
| } | ||
| } | ||
| } No newline at end of file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.