chore: checkpoint current workspace changes

This commit is contained in:
2026-04-11 22:14:02 +08:00
parent 3e55f8c204
commit 8848cfd958
227 changed files with 34027 additions and 6711 deletions

View File

@@ -1,6 +1,8 @@
#include <gtest/gtest.h>
#include <XCEngine/Core/Asset/AssetDatabase.h>
#include <XCEngine/Core/Asset/ArtifactContainer.h>
#include <XCEngine/Core/Asset/ArtifactFormats.h>
#include <XCEngine/Core/Asset/AssetRef.h>
#include <XCEngine/Core/Asset/ResourceManager.h>
#include <XCEngine/Core/Math/Bounds.h>
@@ -159,40 +161,58 @@ TEST(VolumeFieldLoader, AssetDatabaseCreatesVolumeArtifactAndReusesItWithoutReim
fs::copy_file(fixturePath, volumePath, fs::copy_options::overwrite_existing);
const GeneratedNanoVDBVolume generated = ReadTestNanoVDBFileMetadata(fixturePath);
AssetDatabase database;
database.Initialize(projectRoot.string().c_str());
{
AssetDatabase database;
database.Initialize(projectRoot.string().c_str());
AssetDatabase::ResolvedAsset firstResolve;
ASSERT_TRUE(database.EnsureArtifact("Assets/cloud.nvdb", ResourceType::VolumeField, firstResolve));
ASSERT_TRUE(firstResolve.exists);
ASSERT_TRUE(firstResolve.artifactReady);
EXPECT_TRUE(fs::exists(firstResolve.artifactMainPath.CStr()));
EXPECT_EQ(fs::path(firstResolve.artifactMainPath.CStr()).extension().generic_string(), ".xcvol");
AssetDatabase::ResolvedAsset firstResolve;
ASSERT_TRUE(database.EnsureArtifact("Assets/cloud.nvdb", ResourceType::VolumeField, firstResolve));
ASSERT_TRUE(firstResolve.exists);
ASSERT_TRUE(firstResolve.artifactReady);
EXPECT_TRUE(fs::exists(firstResolve.artifactMainPath.CStr()));
EXPECT_FALSE(firstResolve.artifactMainEntryPath.Empty());
EXPECT_NE(firstResolve.artifactMainEntryPath, firstResolve.artifactMainPath);
EXPECT_EQ(fs::path(firstResolve.artifactMainPath.CStr()).extension().generic_string(), ".xcvol");
XCEngine::Containers::Array<XCEngine::Core::uint8> artifactPayload;
EXPECT_TRUE(ReadArtifactContainerMainEntryPayload(
firstResolve.artifactMainPath,
ResourceType::VolumeField,
artifactPayload));
ASSERT_GE(artifactPayload.Size(), sizeof(VolumeFieldArtifactHeader));
VolumeFieldArtifactHeader artifactHeader = {};
std::memcpy(&artifactHeader, artifactPayload.Data(), sizeof(artifactHeader));
EXPECT_EQ(std::memcmp(artifactHeader.magic, "XCVOL02", 7), 0);
VolumeFieldLoader loader;
LoadResult artifactLoad = loader.Load(firstResolve.artifactMainPath);
ASSERT_TRUE(artifactLoad);
ASSERT_NE(artifactLoad.resource, nullptr);
auto* artifactVolume = static_cast<VolumeField*>(artifactLoad.resource);
EXPECT_EQ(artifactVolume->GetStorageKind(), VolumeStorageKind::NanoVDB);
EXPECT_EQ(artifactVolume->GetPayloadSize(), generated.payloadSize);
ExpectVector3Near(artifactVolume->GetBounds().GetMin(), generated.bounds.GetMin());
ExpectVector3Near(artifactVolume->GetBounds().GetMax(), generated.bounds.GetMax());
ExpectVector3Near(artifactVolume->GetVoxelSize(), generated.voxelSize);
ExpectIndexBoundsEq(artifactVolume->GetIndexBounds(), generated.indexBounds);
EXPECT_EQ(artifactVolume->GetGridType(), generated.gridType);
EXPECT_EQ(artifactVolume->GetGridClass(), generated.gridClass);
delete artifactVolume;
VolumeFieldLoader loader;
LoadResult artifactLoad = loader.Load(firstResolve.artifactMainPath);
ASSERT_TRUE(artifactLoad);
ASSERT_NE(artifactLoad.resource, nullptr);
auto* artifactVolume = static_cast<VolumeField*>(artifactLoad.resource);
EXPECT_EQ(artifactVolume->GetStorageKind(), VolumeStorageKind::NanoVDB);
EXPECT_EQ(artifactVolume->GetPayloadSize(), generated.payloadSize);
ExpectVector3Near(artifactVolume->GetBounds().GetMin(), generated.bounds.GetMin());
ExpectVector3Near(artifactVolume->GetBounds().GetMax(), generated.bounds.GetMax());
ExpectVector3Near(artifactVolume->GetVoxelSize(), generated.voxelSize);
ExpectIndexBoundsEq(artifactVolume->GetIndexBounds(), generated.indexBounds);
EXPECT_EQ(artifactVolume->GetGridType(), generated.gridType);
EXPECT_EQ(artifactVolume->GetGridClass(), generated.gridClass);
delete artifactVolume;
const auto originalArtifactWriteTime = fs::last_write_time(firstResolve.artifactMainPath.CStr());
std::this_thread::sleep_for(50ms);
LoadResult entryLoad = loader.Load(firstResolve.artifactMainEntryPath);
ASSERT_TRUE(entryLoad);
ASSERT_NE(entryLoad.resource, nullptr);
delete entryLoad.resource;
AssetDatabase::ResolvedAsset secondResolve;
ASSERT_TRUE(database.EnsureArtifact("Assets/cloud.nvdb", ResourceType::VolumeField, secondResolve));
EXPECT_EQ(firstResolve.artifactMainPath, secondResolve.artifactMainPath);
EXPECT_EQ(originalArtifactWriteTime, fs::last_write_time(secondResolve.artifactMainPath.CStr()));
const auto originalArtifactWriteTime = fs::last_write_time(firstResolve.artifactMainPath.CStr());
std::this_thread::sleep_for(50ms);
database.Shutdown();
AssetDatabase::ResolvedAsset secondResolve;
ASSERT_TRUE(database.EnsureArtifact("Assets/cloud.nvdb", ResourceType::VolumeField, secondResolve));
EXPECT_EQ(firstResolve.artifactMainPath, secondResolve.artifactMainPath);
EXPECT_EQ(originalArtifactWriteTime, fs::last_write_time(secondResolve.artifactMainPath.CStr()));
database.Shutdown();
}
fs::remove_all(projectRoot);
}
#else