feat: move editor to project / add post processing etc

This commit is contained in:
2026-10-23 20:54:12 +02:00
parent f7e7c56392
commit a3d3da4a67
104 changed files with 11750 additions and 2675 deletions
+73
View File
@@ -5,7 +5,9 @@
#include <string>
#include <glm/gtc/packing.hpp>
#include <destrum/Assets/AssetDatabase.h>
#include <destrum/Assets/AssetManager.h>
#include <destrum/Assets/AssetTypes.h>
#include <destrum/Assets/AssetReference.h>
#include <destrum/Assets/ModelFile.h>
#include <destrum/Assets/TextureFile.h>
@@ -16,6 +18,8 @@
#include <destrum/Components/Animator.h>
#include <destrum/Graphics/Material.h>
#include <destrum/Graphics/imageLoader.h>
#include <destrum/Serialization/MaterialSerialization.h>
#include <destrum/Serialization/ObjectSerialization.h>
#include "TestUtils.h"
@@ -447,6 +451,71 @@ namespace {
check(!AssetReference::fromCacheKey("CharacterMedium.fbx").has_value(),
"plain cache names must not be treated as file-backed assets");
}
void testAssetGuids()
{
const AssetGuid first = AssetGuid::Generate();
const AssetGuid second = AssetGuid::Generate();
check(first.IsValid() && second.IsValid() && first != second, "generated asset ids must be valid and unique");
const std::string text = first.ToString();
check(text.size() == 32 && AssetGuid::Parse(text) == first, "asset ids must round-trip through their text form");
check(!AssetGuid::Parse("1234").has_value() && !AssetGuid::Parse(std::string(32, 'z')).has_value() &&
!AssetGuid::Parse(std::string(32, '0')).has_value(),
"malformed or empty asset ids must be rejected");
}
void testAssetDatabaseFollowsMovedAssets()
{
auto& database = AssetDatabase::GetInstance();
database.Clear();
const AssetGuid guid = AssetGuid::Generate();
database.Register("game://models/crate.glb", guid);
check(database.FindGuid("game://models/crate.glb") == guid && database.FindPath(guid) == "game://models/crate.glb",
"registered assets must be found by path and by id");
const nlohmann::json reference = database.WriteReference("game://models/crate.glb", "mesh:0");
check(reference.at("guid") == guid.ToString() && reference.at("sub") == "mesh:0",
"references to known assets must carry the id and subresource");
check(!database.WriteReference("game://unknown.png").contains("guid"),
"assets without a meta file must not get an id outside a save");
database.Clear();
database.Register("game://props/crate.glb", guid);
const auto moved = database.ReadReference(reference);
check(moved.has_value() && moved->path == "game://props/crate.glb" && moved->subresource == "mesh:0",
"references must follow their id when the asset moved");
const auto byPath = database.ReadReference(nlohmann::json{{"path", "game://other.png"}});
check(byPath.has_value() && byPath->path == "game://other.png", "references without a known id must keep their path");
check(!database.ReadReference(nlohmann::json{{"guid", guid.ToString()}}).has_value(),
"a reference needs a path to fall back on");
database.Clear();
}
void testAssetTypes()
{
check(AssetTypes::IsModel("game://a/B.GLB") && AssetTypes::IsImage("x.Png") && AssetTypes::IsMaterial("m.dmat") &&
AssetTypes::IsScene("game://scenes/main.scene") && AssetTypes::IsPrefab("p.prefab") && AssetTypes::IsMeta("a.glb.meta"),
"asset types must be recognised by extension, ignoring case");
check(!AssetTypes::IsModel("model.glb.meta") && !AssetTypes::IsScene("scene.json"),
"only the last extension decides the asset type");
check(MaterialSerialization::IsFileKey("game://materials/a.dmat") && !MaterialSerialization::IsFileKey("local:3:1") &&
!MaterialSerialization::IsFileKey("game://a.glb#material:0"),
"only .dmat paths are material files");
}
void testMainSceneFileIsValid()
{
std::ifstream file{std::filesystem::path{LIGHTKEEPER_ASSETS_SRC_DIR} / "scenes" / "main.scene"};
const auto root = nlohmann::json::parse(file, nullptr, false);
check(!root.is_discarded() && root.at("version") == ObjectSerialization::CurrentObjectVersion &&
root.at("objects").size() > 100,
"the main scene must be saved in the current format with the whole level");
check(!MaterialSerialization::Validate(root.at("materials")).has_value(),
"the main scene's local materials must be valid");
}
}
void RunAssetsTests()
@@ -460,4 +529,8 @@ void RunAssetsTests()
testTextureFileRoundTrip();
testImageLoaderReadsCookedTextures();
testAssetReferenceCacheKeys();
testAssetGuids();
testAssetDatabaseFollowsMovedAssets();
testAssetTypes();
testMainSceneFileIsValid();
}