More setting up for testing of gltf loading
This commit is contained in:
parent
78a20173e0
commit
a39230ce42
|
@ -25,10 +25,11 @@ namespace SHADE
|
||||||
(void)scene;
|
(void)scene;
|
||||||
|
|
||||||
SHMeshAsset result
|
SHMeshAsset result
|
||||||
{
|
{
|
||||||
.compiled = false,
|
.compiled { false},
|
||||||
.changed = false
|
.changed { false },
|
||||||
};
|
.meshName { mesh.mName.C_Str() }
|
||||||
|
};
|
||||||
|
|
||||||
for (size_t i{0}; i < mesh.mNumVertices; ++i)
|
for (size_t i{0}; i < mesh.mNumVertices; ++i)
|
||||||
{
|
{
|
||||||
|
|
|
@ -31,15 +31,19 @@ namespace SHADE
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* \brief Static function to generate asset ID.
|
* \brief Static function to generate asset ID.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
AssetID SHAssetManager::GenerateAssetID() noexcept
|
AssetID SHAssetManager::GenerateAssetID(AssetType type) noexcept
|
||||||
{
|
{
|
||||||
std::default_random_engine randEngine{
|
std::default_random_engine randEngine{
|
||||||
static_cast<unsigned int>(std::chrono::system_clock::now().time_since_epoch().count()) };
|
static_cast<unsigned int>(std::chrono::system_clock::now().time_since_epoch().count()) };
|
||||||
std::mt19937 idGen{ randEngine() };
|
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)
|
while (result == 0)
|
||||||
{
|
{
|
||||||
result = idGen();
|
result = GenerateAssetID(type);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -95,7 +99,7 @@ namespace SHADE
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
AssetID SHAssetManager::CreateNewAsset(AssetType type, AssetName name) noexcept
|
AssetID SHAssetManager::CreateNewAsset(AssetType type, AssetName name) noexcept
|
||||||
{
|
{
|
||||||
AssetID id{ GenerateAssetID() };
|
AssetID id{ GenerateAssetID(type) };
|
||||||
SHAsset meta;
|
SHAsset meta;
|
||||||
meta.id = id;
|
meta.id = id;
|
||||||
meta.type = type;
|
meta.type = type;
|
||||||
|
@ -204,6 +208,8 @@ namespace SHADE
|
||||||
.location {0}
|
.location {0}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
SHLOG_INFO("Loaded meshes\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
@ -228,8 +234,8 @@ namespace SHADE
|
||||||
SHAsset SHAssetManager::RegisterAssetNew(AssetPath const& asset) noexcept
|
SHAsset SHAssetManager::RegisterAssetNew(AssetPath const& asset) noexcept
|
||||||
{
|
{
|
||||||
SHAsset meta;
|
SHAsset meta;
|
||||||
meta.id = GenerateAssetID();
|
|
||||||
meta.type = SHAssetMetaHandler::GetTypeFromExtension(asset.extension().string());
|
meta.type = SHAssetMetaHandler::GetTypeFromExtension(asset.extension().string());
|
||||||
|
meta.id = GenerateAssetID(meta.type);
|
||||||
|
|
||||||
assetCollection.push_back(meta);
|
assetCollection.push_back(meta);
|
||||||
|
|
||||||
|
@ -260,7 +266,17 @@ namespace SHADE
|
||||||
SHDDSLoader::LoadImageAsset(imagePaths, images);
|
SHDDSLoader::LoadImageAsset(imagePaths, images);
|
||||||
|
|
||||||
//TODO Recognise new meshes as asset as well and write mesh into binary
|
//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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|
Loading…
Reference in New Issue