More setting up for testing of gltf loading

This commit is contained in:
Xiao Qi 2022-09-24 16:07:51 +08:00
parent 78a20173e0
commit a39230ce42
2 changed files with 27 additions and 10 deletions

View File

@ -25,10 +25,11 @@ namespace SHADE
(void)scene;
SHMeshAsset result
{
.compiled = false,
.changed = false
};
{
.compiled { false},
.changed { false },
.meshName { mesh.mName.C_Str() }
};
for (size_t i{0}; i < mesh.mNumVertices; ++i)
{

View File

@ -31,15 +31,19 @@ namespace SHADE
/****************************************************************************
* \brief Static function to generate asset ID.
****************************************************************************/
AssetID SHAssetManager::GenerateAssetID() noexcept
AssetID SHAssetManager::GenerateAssetID(AssetType type) noexcept
{
std::default_random_engine randEngine{
static_cast<unsigned int>(std::chrono::system_clock::now().time_since_epoch().count()) };
std::mt19937 idGen{ randEngine() };
AssetID result{ idGen() };
AssetID result{ static_cast<AssetID>(type) << 24};
AssetID unique{ idGen() & ((1 << 24) - 1) };
result |= unique;
while (result == 0)
{
result = idGen();
result = GenerateAssetID(type);
}
return result;
}
@ -95,7 +99,7 @@ namespace SHADE
****************************************************************************/
AssetID SHAssetManager::CreateNewAsset(AssetType type, AssetName name) noexcept
{
AssetID id{ GenerateAssetID() };
AssetID id{ GenerateAssetID(type) };
SHAsset meta;
meta.id = id;
meta.type = type;
@ -204,6 +208,8 @@ namespace SHADE
.location {0}
}
);
SHLOG_INFO("Loaded meshes\n");
}
/****************************************************************************
@ -228,8 +234,8 @@ namespace SHADE
SHAsset SHAssetManager::RegisterAssetNew(AssetPath const& asset) noexcept
{
SHAsset meta;
meta.id = GenerateAssetID();
meta.type = SHAssetMetaHandler::GetTypeFromExtension(asset.extension().string());
meta.id = GenerateAssetID(meta.type);
assetCollection.push_back(meta);
@ -260,7 +266,17 @@ namespace SHADE
SHDDSLoader::LoadImageAsset(imagePaths, images);
//TODO Recognise new meshes as asset as well and write mesh into binary
//TODO
//TODO
for (auto const& mesh : meshes)
{
meshCollection.emplace(GenerateAssetID(AssetType::MESH), mesh);
}
for (auto const& image : images)
{
ddsCollection.emplace(GenerateAssetID(AssetType::DDS), image);
}
}
/****************************************************************************