Skip to content

Separate scene#61

Merged
infirit89 merged 51 commits intomainfrom
separate-scene
Mar 4, 2026
Merged

Separate scene#61
infirit89 merged 51 commits intomainfrom
separate-scene

Conversation

@infirit89
Copy link
Copy Markdown
Owner

Closes: #52

Before the macros names were imported from the Terran Engine mono library
and included the CORE keyword in their name (e.g. TR_CORE_TRACE)
this no longer makes sense as these would be called from other libraries
The idea behind this change is to have AssetHandle control the lifetime
of an Asset, i.e. when an asset is added/imported the AssetManager
creates a strong AssetHandle. When all of the references to the
AssetHandle drop, the destructor enqueues the corresponding Asset to be
freed
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

This PR is part of the engine decoupling effort (#52 / #49) and moves the Scene system out of TerranEngine into a standalone LibScene, while also evolving the asset and logging infrastructure to support the new module layout.

Changes:

  • Introduces Libraries/LibScene (Scene/Entity/Components/Serializer/Manager/Events) and wires it into premake + sandbox.
  • Refactors LibAsset to use RefPtr-based assets and typed importer results (AssetLoadResult), adding handle/metadata changes.
  • Adds/expands unit tests for LibScene, LibAsset, and LibCore plus updates CI coverage aggregation.

Reviewed changes

Copilot reviewed 76 out of 78 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
vendor/entt/LICENSE Adds MIT license file for vendored entt.
premake-native.lua Adds LibScene and new test projects to the workspace.
dependecies.lua Adds Dependencies.entt and adjusts include directory usage.
Tests/LibScene/premake5.lua New premake project for LibScene tests.
Tests/LibScene/SceneTests.cpp Adds Scene behavior tests (entities, map, runtime events).
Tests/LibScene/Main.cpp GTest entry point for LibScene tests.
Tests/LibScene/EntityTests.cpp Adds Entity relationship/parenting error-path tests.
Tests/LibCore/RefPtrTests.cpp Adds tests for new Core::RefPtr.
Tests/LibCore/ByteBufferTests.cpp Removes incorrect #pragma once from .cpp.
Tests/LibAsset/premake5.lua New premake project for LibAsset tests.
Tests/LibAsset/Main.cpp GTest entry point for LibAsset tests.
Tests/LibAsset/AssetImporterRegistryTests.cpp Adds registry tests for importer load/save behavior.
TerranEngine/src/Utils/SerializerUtils.cpp Removes old YAML serializer operators (moved/rewritten elsewhere).
TerranEngine/src/Scene/Systems/SceneRenderer.h Removes old engine-integrated scene renderer.
TerranEngine/src/Scene/Systems/SceneRenderer.cpp Removes old engine-integrated scene renderer implementation.
TerranEngine/src/Scene/SceneSerializer.h Removes old engine SceneSerializer API.
TerranEngine/src/Scene/SceneSerializer.cpp Removes old engine SceneSerializer implementation.
TerranEngine/src/Scene/SceneManager.h Removes old engine SceneManager.
TerranEngine/src/Scene/SceneManager.cpp Removes old engine SceneManager implementation.
TerranEngine/src/Scene/Scene.h Removes old engine Scene definition.
TerranEngine/src/Scene/Scene.cpp Removes old engine Scene implementation.
TerranEngine/src/Scene/Entity.h Removes old engine Entity wrapper.
TerranEngine/src/Scene/Components.h Removes old engine Scene component definitions.
TerranEngine/src/Math/Math.h Removes old engine Math API (moved to LibCore).
TerranEngine/src/Math/Math.cpp Removes old engine Math implementation (moved to LibCore).
TerranEngine/src/Events/SceneEvent.h Removes old engine scene events header.
TerranEngine/premake5.lua Switches entt include to Dependencies.entt.include.
Sandbox/src/SandboxLayer.cpp Updates sandbox includes to use new LibScene/LibAsset headers.
Sandbox/premake5.lua Links Sandbox against LibScene and LibAsset, adds yaml include.
Libraries/LibWindow/WindowTypes.h Introduces TR_LOG_WINDOW logger name constant.
Libraries/LibWindow/WindowSystem.h Adds destroy() to remove a window from the system.
Libraries/LibWindow/WindowSystem.cpp Adds window logger + improved GLFW init/terminate logging & error callback.
Libraries/LibWindow/Input.h Moves input logging to the window logger.
Libraries/LibWindow/GLFWWindow.cpp Removes per-window glfwTerminate() and improves window logging.
Libraries/LibScene/premake5.lua New LibScene build configuration and dependencies.
Libraries/LibScene/SceneTypes.h Introduces TR_LOG_SCENE logger name constant.
Libraries/LibScene/SceneSerializerError.h Adds typed error for scene serialization.
Libraries/LibScene/SceneSerializer.h New Scene serializer as an AssetImporter.
Libraries/LibScene/SceneSerializer.cpp Implements YAML-based scene save/load in LibScene.
Libraries/LibScene/SceneManager.h New SceneManager layer integrated with AssetSystem.
Libraries/LibScene/SceneManager.cpp Implements scene creation/copying/transition event triggering.
Libraries/LibScene/SceneEvent.h Adds scene transition + runtime start/stop events.
Libraries/LibScene/Scene.h New LibScene Scene API (entities, hierarchy transforms, runtime state).
Libraries/LibScene/Scene.cpp Implements the new LibScene Scene.
Libraries/LibScene/Entity.inl Defines templated component helpers for Entity.
Libraries/LibScene/Entity.h New LibScene Entity API incl. relationship ops + error results.
Libraries/LibScene/Entity.cpp Implements parent/unparent semantics and error handling.
Libraries/LibScene/Components.h Defines core LibScene components (Tag/Transform/Relationship).
Libraries/LibScene/ComponentSerializer.h Adds ComponentSerializer concept for YAML serializers.
Libraries/LibCore/WeakRef.h Introduces WeakPtr (non-owning pointer wrapper).
Libraries/LibCore/SerializerExtensions.h Reworks YAML serialization helpers and conversion specializations.
Libraries/LibCore/Result.h Fixes union lifetime UB using placement-new and manual destruction.
Libraries/LibCore/RefPtr.h Introduces intrusive ref-counted smart pointer.
Libraries/LibCore/Math.h Adds Core::Math transform matrix decompose/compose API.
Libraries/LibCore/Math.cpp Implements Core::Math functions.
Libraries/LibCore/Log.h Renames core logging macros (core vs non-core) and updates namespaces.
Libraries/LibCore/Log.cpp Updates logging calls to new macros and improves includes.
Libraries/LibCore/LayerStack.h Fixes forwarding in LayerStack::push template args.
Libraries/LibCore/Assert.h Routes assert logging through new TR_ERROR macro.
Libraries/LibAsset/AssetTypes.h Renames AssetHandle -> AssetId and makes TR_LOG_ASSET a constant.
Libraries/LibAsset/AssetSystem.h Registers the asset logger on startup.
Libraries/LibAsset/AssetMetadataRegistry.h Updates registry key types to AssetId.
Libraries/LibAsset/AssetMetadataRegistry.cpp Updates implementation for AssetId and adds error logs.
Libraries/LibAsset/AssetMetadata.h Updates metadata field from Handle to AssetId.
Libraries/LibAsset/AssetManager.h Refactors APIs around AssetId/AssetHandle, RefPtr, and remove/purge flows.
Libraries/LibAsset/AssetManager.cpp Implements updated import/reload/remove/purge logic and event triggers.
Libraries/LibAsset/AssetImporterRegistry.h Updates registry API to return AssetLoadResult and accept RefPtr.
Libraries/LibAsset/AssetImporterRegistry.cpp Implements new load/save behavior and importer-not-found errors.
Libraries/LibAsset/AssetImporterError.h Adds typed error for importer failures.
Libraries/LibAsset/AssetImporter.h Refactors importer interface to return AssetLoadResult.
Libraries/LibAsset/AssetHandle.h Adds ref-counted handle wrapper for asset IDs.
Libraries/LibAsset/AssetHandle.cpp Enqueues assets for deletion when handles are destroyed.
Libraries/LibAsset/AssetEvents.h Updates asset events to use AssetId.
Libraries/LibAsset/AssetError.h Adds a base error type for asset-related failures.
Libraries/LibAsset/Asset.h Makes Asset ref-counted and switches internal id to AssetId.
Libraries/LibAsset/Asset.cpp Removes unused implementation file.
.github/workflows/sonarcloud.yml Updates coverage aggregation to include multiple test binaries correctly.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

WeakPtr was essentially broken, not checks for whether the actual object
is still alive, and the lock tried to create a RefPtr without any
regard, essentially doing an use-after-free is the original object was
dead
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 4, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
52.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@infirit89
Copy link
Copy Markdown
Owner Author

There are more changes/updates that need to be done to LibScene and LibAsset, however the foundational work is done here and in #55.

Thus I'm merging this and logging issues for further improvements.

@infirit89 infirit89 merged commit 0c38116 into main Mar 4, 2026
8 of 9 checks passed
@infirit89 infirit89 deleted the separate-scene branch March 4, 2026 21:45
@infirit89 infirit89 mentioned this pull request Mar 4, 2026
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.

Separate Scene system from core engine

2 participants