More checking
parent
894b8e3519
commit
fabfcf3cb0
|
@ -655,8 +655,12 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags)
|
|||
|
||||
// If successful, apply all active post processing steps to the imported data
|
||||
if( pimpl->mScene) {
|
||||
if (!pimpl->mScene->mMetaData->HasKey(AI_METADATA_SOURCE_FORMAT))
|
||||
if (!pimpl->mScene->mMetaData || !pimpl->mScene->mMetaData->HasKey(AI_METADATA_SOURCE_FORMAT))
|
||||
{
|
||||
if (!pimpl->mScene->mMetaData)
|
||||
{
|
||||
pimpl->mScene->mMetaData = new aiMetadata;
|
||||
}
|
||||
pimpl->mScene->mMetaData->Add(AI_METADATA_SOURCE_FORMAT, aiString(ext));
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
||||
#include <assimp/CreateAnimMesh.h>
|
||||
#include <assimp/commonMetaData.h>
|
||||
#include <assimp/StringUtils.h>
|
||||
|
||||
#include <tuple>
|
||||
#include <memory>
|
||||
|
@ -3605,7 +3606,9 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial* out_mat, const PropertyTa
|
|||
return;
|
||||
}
|
||||
|
||||
out->mMetaData = aiMetadata::Alloc(17);
|
||||
const bool hasGenerator = !doc.Creator().empty();
|
||||
|
||||
out->mMetaData = aiMetadata::Alloc(16 + (hasGenerator ? 1 : 0));
|
||||
out->mMetaData->Set(0, "UpAxis", doc.GlobalSettings().UpAxis());
|
||||
out->mMetaData->Set(1, "UpAxisSign", doc.GlobalSettings().UpAxisSign());
|
||||
out->mMetaData->Set(2, "FrontAxis", doc.GlobalSettings().FrontAxis());
|
||||
|
@ -3621,9 +3624,12 @@ void FBXConverter::SetShadingPropertiesRaw(aiMaterial* out_mat, const PropertyTa
|
|||
out->mMetaData->Set(12, "TimeSpanStart", doc.GlobalSettings().TimeSpanStart());
|
||||
out->mMetaData->Set(13, "TimeSpanStop", doc.GlobalSettings().TimeSpanStop());
|
||||
out->mMetaData->Set(14, "CustomFrameRate", doc.GlobalSettings().CustomFrameRate());
|
||||
out->mMetaData->Set(15, AI_METADATA_SOURCE_FORMAT_VERSION, aiString(std::to_string(doc.FBXVersion())));
|
||||
out->mMetaData->Set(15, AI_METADATA_SOURCE_FORMAT_VERSION, aiString(to_string(doc.FBXVersion())));
|
||||
if (hasGenerator)
|
||||
{
|
||||
out->mMetaData->Set(16, AI_METADATA_SOURCE_GENERATOR, aiString(doc.Creator()));
|
||||
}
|
||||
}
|
||||
|
||||
void FBXConverter::TransferDataToScene()
|
||||
{
|
||||
|
|
|
@ -701,9 +701,20 @@ void glTFImporter::ImportEmbeddedTextures(glTF::Asset& r)
|
|||
void glTFImporter::ImportCommonMetadata(glTF::Asset& a)
|
||||
{
|
||||
ai_assert(mScene->mMetaData == nullptr);
|
||||
mScene->mMetaData = aiMetadata::Alloc(2);
|
||||
mScene->mMetaData->Set(0, AI_METADATA_SOURCE_FORMAT_VERSION, aiString(a.asset.version));
|
||||
mScene->mMetaData->Set(1, AI_METADATA_SOURCE_GENERATOR, aiString(a.asset.generator));
|
||||
const bool hasVersion = !a.asset.version.empty();
|
||||
const bool hasGenerator = !a.asset.generator.empty();
|
||||
if (hasVersion || hasGenerator)
|
||||
{
|
||||
mScene->mMetaData = new aiMetadata;
|
||||
if (hasVersion)
|
||||
{
|
||||
mScene->mMetaData->Add(AI_METADATA_SOURCE_FORMAT_VERSION, aiString(a.asset.version));
|
||||
}
|
||||
if (hasGenerator)
|
||||
{
|
||||
mScene->mMetaData->Add(AI_METADATA_SOURCE_GENERATOR, aiString(a.asset.generator));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void glTFImporter::InternReadFile(const std::string& pFile, aiScene* pScene, IOSystem* pIOHandler)
|
||||
|
|
|
@ -1304,9 +1304,20 @@ void glTF2Importer::ImportEmbeddedTextures(glTF2::Asset &r) {
|
|||
|
||||
void glTF2Importer::ImportCommonMetadata(glTF2::Asset& a) {
|
||||
ai_assert(mScene->mMetaData == nullptr);
|
||||
mScene->mMetaData = aiMetadata::Alloc(2);
|
||||
mScene->mMetaData->Set(0, AI_METADATA_SOURCE_FORMAT_VERSION, aiString(a.asset.version));
|
||||
mScene->mMetaData->Set(1, AI_METADATA_SOURCE_GENERATOR, aiString(a.asset.generator));
|
||||
const bool hasVersion = !a.asset.version.empty();
|
||||
const bool hasGenerator = !a.asset.generator.empty();
|
||||
if (hasVersion || hasGenerator)
|
||||
{
|
||||
mScene->mMetaData = new aiMetadata;
|
||||
if (hasVersion)
|
||||
{
|
||||
mScene->mMetaData->Add(AI_METADATA_SOURCE_FORMAT_VERSION, aiString(a.asset.version));
|
||||
}
|
||||
if (hasGenerator)
|
||||
{
|
||||
mScene->mMetaData->Add(AI_METADATA_SOURCE_GENERATOR, aiString(a.asset.generator));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void glTF2Importer::InternReadFile(const std::string &pFile, aiScene *pScene, IOSystem *pIOHandler) {
|
||||
|
|
Loading…
Reference in New Issue