Add Nahida model import and preview pipeline
This commit is contained in:
@@ -147,6 +147,48 @@ TEST(MeshFilterComponent_Test, SetMeshPathPreservesPathWithoutLoadedResource) {
|
||||
EXPECT_EQ(component.GetMesh(), nullptr);
|
||||
}
|
||||
|
||||
TEST(MeshFilterComponent_Test, SetMeshAssetRefPreservesProjectSubAssetReference) {
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
ResourceManager& manager = ResourceManager::Get();
|
||||
manager.Initialize();
|
||||
|
||||
const fs::path projectRoot = fs::temp_directory_path() / "xc_mesh_filter_asset_ref_test";
|
||||
const fs::path assetsDir = projectRoot / "Assets";
|
||||
const fs::path meshPath = assetsDir / "runtime.mesh";
|
||||
|
||||
fs::remove_all(projectRoot);
|
||||
fs::create_directories(assetsDir);
|
||||
{
|
||||
std::ofstream meshFile(meshPath);
|
||||
ASSERT_TRUE(meshFile.is_open());
|
||||
meshFile << "placeholder";
|
||||
}
|
||||
|
||||
manager.SetResourceRoot(projectRoot.string().c_str());
|
||||
|
||||
AssetRef meshRef;
|
||||
ASSERT_TRUE(manager.TryGetAssetRef("Assets/runtime.mesh", ResourceType::Mesh, meshRef));
|
||||
|
||||
MeshFilterComponent component;
|
||||
component.SetMeshAssetRef(meshRef);
|
||||
|
||||
EXPECT_TRUE(component.GetMeshAssetRef().IsValid());
|
||||
EXPECT_EQ(component.GetMeshAssetRef().assetGuid, meshRef.assetGuid);
|
||||
EXPECT_EQ(component.GetMeshAssetRef().localID, meshRef.localID);
|
||||
EXPECT_EQ(component.GetMeshAssetRef().resourceType, meshRef.resourceType);
|
||||
EXPECT_EQ(component.GetMeshPath(), "Assets/runtime.mesh");
|
||||
|
||||
std::stringstream stream;
|
||||
component.Serialize(stream);
|
||||
EXPECT_NE(stream.str().find("meshRef="), std::string::npos);
|
||||
EXPECT_EQ(stream.str().find("meshRef=;"), std::string::npos);
|
||||
|
||||
manager.SetResourceRoot("");
|
||||
manager.Shutdown();
|
||||
fs::remove_all(projectRoot);
|
||||
}
|
||||
|
||||
TEST(MeshFilterComponent_Test, DeferredSceneDeserializeLoadsMeshAsyncByPath) {
|
||||
ResourceManager& manager = ResourceManager::Get();
|
||||
manager.Initialize();
|
||||
@@ -276,6 +318,56 @@ TEST(MeshRendererComponent_Test, SetMaterialPathPreservesPathWithoutLoadedResour
|
||||
EXPECT_EQ(component.GetMaterial(1), nullptr);
|
||||
}
|
||||
|
||||
TEST(MeshRendererComponent_Test, SetMaterialAssetRefPreservesProjectSubAssetReference) {
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
ResourceManager& manager = ResourceManager::Get();
|
||||
manager.Initialize();
|
||||
|
||||
const fs::path projectRoot = fs::temp_directory_path() / "xc_mesh_renderer_sub_asset_ref_test";
|
||||
const fs::path assetsDir = projectRoot / "Assets";
|
||||
const fs::path materialPath = assetsDir / "runtime.material";
|
||||
|
||||
fs::remove_all(projectRoot);
|
||||
fs::create_directories(assetsDir);
|
||||
|
||||
{
|
||||
std::ofstream materialFile(materialPath);
|
||||
ASSERT_TRUE(materialFile.is_open());
|
||||
materialFile << "{\n";
|
||||
materialFile << " \"renderQueue\": \"geometry\",\n";
|
||||
materialFile << " \"renderState\": {\n";
|
||||
materialFile << " \"cull\": \"back\"\n";
|
||||
materialFile << " }\n";
|
||||
materialFile << "}";
|
||||
}
|
||||
|
||||
manager.SetResourceRoot(projectRoot.string().c_str());
|
||||
|
||||
AssetRef materialRef;
|
||||
ASSERT_TRUE(manager.TryGetAssetRef("Assets/runtime.material", ResourceType::Material, materialRef));
|
||||
|
||||
MeshRendererComponent component;
|
||||
component.SetMaterialAssetRef(0, materialRef);
|
||||
|
||||
ASSERT_EQ(component.GetMaterialCount(), 1u);
|
||||
EXPECT_TRUE(component.GetMaterialAssetRefs()[0].IsValid());
|
||||
EXPECT_EQ(component.GetMaterialAssetRefs()[0].assetGuid, materialRef.assetGuid);
|
||||
EXPECT_EQ(component.GetMaterialAssetRefs()[0].localID, materialRef.localID);
|
||||
EXPECT_EQ(component.GetMaterialAssetRefs()[0].resourceType, materialRef.resourceType);
|
||||
EXPECT_EQ(component.GetMaterialPath(0), "Assets/runtime.material");
|
||||
ASSERT_NE(component.GetMaterial(0), nullptr);
|
||||
|
||||
std::stringstream stream;
|
||||
component.Serialize(stream);
|
||||
EXPECT_NE(stream.str().find("materialRefs="), std::string::npos);
|
||||
EXPECT_EQ(stream.str().find("materialRefs=;"), std::string::npos);
|
||||
|
||||
manager.SetResourceRoot("");
|
||||
manager.Shutdown();
|
||||
fs::remove_all(projectRoot);
|
||||
}
|
||||
|
||||
TEST(MeshRendererComponent_Test, DeserializeIgnoresPlainMaterialPathsWithoutAssetRefs) {
|
||||
MeshRendererComponent target;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user