Skip to content

refactor: Add update and render functions to Scene, SceneObject and Component classes#19

Open
MichalSzandar wants to merge 3 commits into
mainfrom
refactor/components
Open

refactor: Add update and render functions to Scene, SceneObject and Component classes#19
MichalSzandar wants to merge 3 commits into
mainfrom
refactor/components

Conversation

@MichalSzandar
Copy link
Copy Markdown
Collaborator

@MichalSzandar MichalSzandar commented Jun 1, 2026

  • add update and render functions
  • store weak_ptr to the owner of the object in Component
  • change c++ standard to 20 (for jthread)

* add update() function
* store weak_ptr to the owner of the object
@MichalSzandar MichalSzandar self-assigned this Jun 1, 2026
@MichalSzandar MichalSzandar changed the title refactor: update Component class refactor: Add update and render functions to Scene, SceneObject and Component classes Jun 2, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 (ParserComponentRegistry → 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/render to Component (now non-default-constructible, owns a weak_ptr<SceneObject>) and propagate the corresponding methods through SceneObject and the new Scene::update/Scene::render.
  • Thread std::shared_ptr<SceneObject> owner through ComponentRegistry::build, Parser::buildComponent, and BlinkComponent::createBlinker/constructor.
  • Bump CMAKE_CXX_STANDARD to 20 and rewrite .clang-tidy header 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.

Comment thread .clang-tidy
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 thread src/scene/Scene.cpp
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants