summaryrefslogtreecommitdiff
path: root/thirdparty/assimp/code/Common/Importer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'thirdparty/assimp/code/Common/Importer.cpp')
-rw-r--r--thirdparty/assimp/code/Common/Importer.cpp292
1 files changed, 130 insertions, 162 deletions
diff --git a/thirdparty/assimp/code/Common/Importer.cpp b/thirdparty/assimp/code/Common/Importer.cpp
index a59ec98122..91b50859a0 100644
--- a/thirdparty/assimp/code/Common/Importer.cpp
+++ b/thirdparty/assimp/code/Common/Importer.cpp
@@ -3,7 +3,9 @@
Open Asset Import Library (assimp)
---------------------------------------------------------------------------
-Copyright (c) 2006-2020, assimp team
+Copyright (c) 2006-2019, assimp team
+
+
All rights reserved.
@@ -76,8 +78,6 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <assimp/TinyFormatter.h>
#include <assimp/Exceptional.h>
#include <assimp/Profiler.h>
-#include <assimp/commonMetaData.h>
-
#include <set>
#include <memory>
#include <cctype>
@@ -119,7 +119,7 @@ void* AllocateFromAssimpHeap::operator new ( size_t num_bytes, const std::nothro
return AllocateFromAssimpHeap::operator new( num_bytes );
}
catch( ... ) {
- return nullptr;
+ return NULL;
}
}
@@ -134,8 +134,9 @@ void* AllocateFromAssimpHeap::operator new[] ( size_t num_bytes) {
void* AllocateFromAssimpHeap::operator new[] ( size_t num_bytes, const std::nothrow_t& ) throw() {
try {
return AllocateFromAssimpHeap::operator new[]( num_bytes );
- } catch( ... ) {
- return nullptr;
+ }
+ catch( ... ) {
+ return NULL;
}
}
@@ -147,7 +148,7 @@ void AllocateFromAssimpHeap::operator delete[] ( void* data) {
// Importer constructor.
Importer::Importer()
: pimpl( new ImporterPimpl ) {
- pimpl->mScene = nullptr;
+ pimpl->mScene = NULL;
pimpl->mErrorString = "";
// Allocate a default IO handler
@@ -173,14 +174,14 @@ Importer::Importer()
// ------------------------------------------------------------------------------------------------
// Destructor of Importer
-Importer::~Importer() {
+Importer::~Importer()
+{
// Delete all import plugins
DeleteImporterInstanceList(pimpl->mImporter);
// Delete all post-processing plug-ins
- for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); ++a ) {
+ for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++)
delete pimpl->mPostProcessingSteps[a];
- }
// Delete the assigned IO and progress handler
delete pimpl->mIOHandler;
@@ -198,9 +199,9 @@ Importer::~Importer() {
// ------------------------------------------------------------------------------------------------
// Register a custom post-processing step
-aiReturn Importer::RegisterPPStep(BaseProcess* pImp) {
- ai_assert( nullptr != pImp );
-
+aiReturn Importer::RegisterPPStep(BaseProcess* pImp)
+{
+ ai_assert(NULL != pImp);
ASSIMP_BEGIN_EXCEPTION_REGION();
pimpl->mPostProcessingSteps.push_back(pImp);
@@ -212,9 +213,9 @@ aiReturn Importer::RegisterPPStep(BaseProcess* pImp) {
// ------------------------------------------------------------------------------------------------
// Register a custom loader plugin
-aiReturn Importer::RegisterLoader(BaseImporter* pImp) {
- ai_assert(nullptr != pImp);
-
+aiReturn Importer::RegisterLoader(BaseImporter* pImp)
+{
+ ai_assert(NULL != pImp);
ASSIMP_BEGIN_EXCEPTION_REGION();
// --------------------------------------------------------------------
@@ -241,13 +242,13 @@ aiReturn Importer::RegisterLoader(BaseImporter* pImp) {
pimpl->mImporter.push_back(pImp);
ASSIMP_LOG_INFO_F("Registering custom importer for these file extensions: ", baked);
ASSIMP_END_EXCEPTION_REGION(aiReturn);
-
return AI_SUCCESS;
}
// ------------------------------------------------------------------------------------------------
// Unregister a custom loader plugin
-aiReturn Importer::UnregisterLoader(BaseImporter* pImp) {
+aiReturn Importer::UnregisterLoader(BaseImporter* pImp)
+{
if(!pImp) {
// unregistering a NULL importer is no problem for us ... really!
return AI_SUCCESS;
@@ -264,13 +265,13 @@ aiReturn Importer::UnregisterLoader(BaseImporter* pImp) {
}
ASSIMP_LOG_WARN("Unable to remove custom importer: I can't find you ...");
ASSIMP_END_EXCEPTION_REGION(aiReturn);
-
return AI_FAILURE;
}
// ------------------------------------------------------------------------------------------------
// Unregister a custom loader plugin
-aiReturn Importer::UnregisterPPStep(BaseProcess* pImp) {
+aiReturn Importer::UnregisterPPStep(BaseProcess* pImp)
+{
if(!pImp) {
// unregistering a NULL ppstep is no problem for us ... really!
return AI_SUCCESS;
@@ -287,22 +288,24 @@ aiReturn Importer::UnregisterPPStep(BaseProcess* pImp) {
}
ASSIMP_LOG_WARN("Unable to remove custom post-processing step: I can't find you ..");
ASSIMP_END_EXCEPTION_REGION(aiReturn);
-
return AI_FAILURE;
}
// ------------------------------------------------------------------------------------------------
// Supplies a custom IO handler to the importer to open and access files.
-void Importer::SetIOHandler( IOSystem* pIOHandler) {
- ai_assert(nullptr != pimpl);
-
+void Importer::SetIOHandler( IOSystem* pIOHandler)
+{
ASSIMP_BEGIN_EXCEPTION_REGION();
// If the new handler is zero, allocate a default IO implementation.
- if (!pIOHandler) {
+ if (!pIOHandler)
+ {
// Release pointer in the possession of the caller
pimpl->mIOHandler = new DefaultIOSystem();
pimpl->mIsDefaultHandler = true;
- } else if (pimpl->mIOHandler != pIOHandler) { // Otherwise register the custom handler
+ }
+ // Otherwise register the custom handler
+ else if (pimpl->mIOHandler != pIOHandler)
+ {
delete pimpl->mIOHandler;
pimpl->mIOHandler = pIOHandler;
pimpl->mIsDefaultHandler = false;
@@ -313,32 +316,29 @@ void Importer::SetIOHandler( IOSystem* pIOHandler) {
// ------------------------------------------------------------------------------------------------
// Get the currently set IO handler
IOSystem* Importer::GetIOHandler() const {
- ai_assert(nullptr != pimpl);
-
return pimpl->mIOHandler;
}
// ------------------------------------------------------------------------------------------------
// Check whether a custom IO handler is currently set
bool Importer::IsDefaultIOHandler() const {
- ai_assert(nullptr != pimpl);
-
return pimpl->mIsDefaultHandler;
}
// ------------------------------------------------------------------------------------------------
// Supplies a custom progress handler to get regular callbacks during importing
void Importer::SetProgressHandler ( ProgressHandler* pHandler ) {
- ai_assert(nullptr != pimpl);
-
ASSIMP_BEGIN_EXCEPTION_REGION();
-
// If the new handler is zero, allocate a default implementation.
- if (!pHandler) {
+ if (!pHandler)
+ {
// Release pointer in the possession of the caller
pimpl->mProgressHandler = new DefaultProgressHandler();
pimpl->mIsDefaultProgressHandler = true;
- } else if (pimpl->mProgressHandler != pHandler) { // Otherwise register the custom handler
+ }
+ // Otherwise register the custom handler
+ else if (pimpl->mProgressHandler != pHandler)
+ {
delete pimpl->mProgressHandler;
pimpl->mProgressHandler = pHandler;
pimpl->mIsDefaultProgressHandler = false;
@@ -349,22 +349,19 @@ void Importer::SetProgressHandler ( ProgressHandler* pHandler ) {
// ------------------------------------------------------------------------------------------------
// Get the currently set progress handler
ProgressHandler* Importer::GetProgressHandler() const {
- ai_assert(nullptr != pimpl);
-
return pimpl->mProgressHandler;
}
// ------------------------------------------------------------------------------------------------
// Check whether a custom progress handler is currently set
bool Importer::IsDefaultProgressHandler() const {
- ai_assert(nullptr != pimpl);
-
return pimpl->mIsDefaultProgressHandler;
}
// ------------------------------------------------------------------------------------------------
// Validate post process step flags
-bool _ValidateFlags(unsigned int pFlags) {
+bool _ValidateFlags(unsigned int pFlags)
+{
if (pFlags & aiProcess_GenSmoothNormals && pFlags & aiProcess_GenNormals) {
ASSIMP_LOG_ERROR("#aiProcess_GenSmoothNormals and #aiProcess_GenNormals are incompatible");
return false;
@@ -378,13 +375,12 @@ bool _ValidateFlags(unsigned int pFlags) {
// ------------------------------------------------------------------------------------------------
// Free the current scene
-void Importer::FreeScene( ) {
- ai_assert(nullptr != pimpl);
-
+void Importer::FreeScene( )
+{
ASSIMP_BEGIN_EXCEPTION_REGION();
delete pimpl->mScene;
- pimpl->mScene = nullptr;
+ pimpl->mScene = NULL;
pimpl->mErrorString = "";
ASSIMP_END_EXCEPTION_REGION(void);
@@ -392,48 +388,44 @@ void Importer::FreeScene( ) {
// ------------------------------------------------------------------------------------------------
// Get the current error string, if any
-const char* Importer::GetErrorString() const {
- ai_assert(nullptr != pimpl);
-
- // Must remain valid as long as ReadFile() or FreeFile() are not called
+const char* Importer::GetErrorString() const
+{
+ /* Must remain valid as long as ReadFile() or FreeFile() are not called */
return pimpl->mErrorString.c_str();
}
// ------------------------------------------------------------------------------------------------
// Enable extra-verbose mode
-void Importer::SetExtraVerbose(bool bDo) {
- ai_assert(nullptr != pimpl);
-
+void Importer::SetExtraVerbose(bool bDo)
+{
pimpl->bExtraVerbose = bDo;
}
// ------------------------------------------------------------------------------------------------
// Get the current scene
-const aiScene* Importer::GetScene() const {
- ai_assert(nullptr != pimpl);
-
+const aiScene* Importer::GetScene() const
+{
return pimpl->mScene;
}
// ------------------------------------------------------------------------------------------------
// Orphan the current scene and return it.
-aiScene* Importer::GetOrphanedScene() {
- ai_assert(nullptr != pimpl);
-
+aiScene* Importer::GetOrphanedScene()
+{
aiScene* s = pimpl->mScene;
ASSIMP_BEGIN_EXCEPTION_REGION();
- pimpl->mScene = nullptr;
+ pimpl->mScene = NULL;
- pimpl->mErrorString = ""; // reset error string
+ pimpl->mErrorString = ""; /* reset error string */
ASSIMP_END_EXCEPTION_REGION(aiScene*);
-
return s;
}
// ------------------------------------------------------------------------------------------------
// Validate post-processing flags
-bool Importer::ValidateFlags(unsigned int pFlags) const {
+bool Importer::ValidateFlags(unsigned int pFlags) const
+{
ASSIMP_BEGIN_EXCEPTION_REGION();
// run basic checks for mutually exclusive flags
if(!_ValidateFlags(pFlags)) {
@@ -475,9 +467,8 @@ bool Importer::ValidateFlags(unsigned int pFlags) const {
const aiScene* Importer::ReadFileFromMemory( const void* pBuffer,
size_t pLength,
unsigned int pFlags,
- const char* pHint /*= ""*/) {
- ai_assert(nullptr != pimpl);
-
+ const char* pHint /*= ""*/)
+{
ASSIMP_BEGIN_EXCEPTION_REGION();
if (!pHint) {
pHint = "";
@@ -485,12 +476,12 @@ const aiScene* Importer::ReadFileFromMemory( const void* pBuffer,
if (!pBuffer || !pLength || strlen(pHint) > MaxLenHint ) {
pimpl->mErrorString = "Invalid parameters passed to ReadFileFromMemory()";
- return nullptr;
+ return NULL;
}
// prevent deletion of the previous IOHandler
IOSystem* io = pimpl->mIOHandler;
- pimpl->mIOHandler = nullptr;
+ pimpl->mIOHandler = NULL;
SetIOHandler(new MemoryIOSystem((const uint8_t*)pBuffer,pLength,io));
@@ -502,13 +493,13 @@ const aiScene* Importer::ReadFileFromMemory( const void* pBuffer,
ReadFile(fbuff,pFlags);
SetIOHandler(io);
- ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(const aiScene*, pimpl->mErrorString);
+ ASSIMP_END_EXCEPTION_REGION(const aiScene*);
return pimpl->mScene;
}
// ------------------------------------------------------------------------------------------------
-void WriteLogOpening(const std::string& file) {
-
+void WriteLogOpening(const std::string& file)
+{
ASSIMP_LOG_INFO_F("Load ", file);
// print a full version dump. This is nice because we don't
@@ -559,9 +550,8 @@ void WriteLogOpening(const std::string& file) {
// ------------------------------------------------------------------------------------------------
// Reads the given file and returns its contents if successful.
-const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
- ai_assert(nullptr != pimpl);
-
+const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags)
+{
ASSIMP_BEGIN_EXCEPTION_REGION();
const std::string pFile(_pFile);
@@ -590,7 +580,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
pimpl->mErrorString = "Unable to open file \"" + pFile + "\".";
ASSIMP_LOG_ERROR(pimpl->mErrorString);
- return nullptr;
+ return NULL;
}
std::unique_ptr<Profiler> profiler(GetPropertyInteger(AI_CONFIG_GLOB_MEASURE_TIME,0)?new Profiler():NULL);
@@ -599,7 +589,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
}
// Find an worker class which can handle the file
- BaseImporter* imp = nullptr;
+ BaseImporter* imp = NULL;
SetPropertyInteger("importerIndex", -1);
for( unsigned int a = 0; a < pimpl->mImporter.size(); a++) {
@@ -627,7 +617,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
if( !imp) {
pimpl->mErrorString = "No suitable reader found for the file format of file \"" + pFile + "\".";
ASSIMP_LOG_ERROR(pimpl->mErrorString);
- return nullptr;
+ return NULL;
}
}
@@ -643,7 +633,7 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
// Dispatch the reading to the worker class for this format
const aiImporterDesc *desc( imp->GetInfo() );
std::string ext( "unknown" );
- if ( nullptr != desc ) {
+ if ( NULL != desc ) {
ext = desc->mName;
}
ASSIMP_LOG_INFO("Found a matching importer for this file format: " + ext + "." );
@@ -664,20 +654,15 @@ 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 || !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));
- }
#ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
// The ValidateDS process is an exception. It is executed first, even before ScenePreprocessor is called.
- if (pFlags & aiProcess_ValidateDataStructure) {
+ if (pFlags & aiProcess_ValidateDataStructure)
+ {
ValidateDSProcess ds;
ds.ExecuteOnScene (this);
if (!pimpl->mScene) {
- return nullptr;
+ return NULL;
}
}
#endif // no validation
@@ -710,7 +695,8 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
}
}
#ifdef ASSIMP_CATCH_GLOBAL_EXCEPTIONS
- catch (std::exception &e) {
+ catch (std::exception &e)
+ {
#if (defined _MSC_VER) && (defined _CPPRTTI)
// if we have RTTI get the full name of the exception that occurred
pimpl->mErrorString = std::string(typeid( e ).name()) + ": " + e.what();
@@ -719,26 +705,24 @@ const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags) {
#endif
ASSIMP_LOG_ERROR(pimpl->mErrorString);
- delete pimpl->mScene; pimpl->mScene = nullptr;
+ delete pimpl->mScene; pimpl->mScene = NULL;
}
#endif // ! ASSIMP_CATCH_GLOBAL_EXCEPTIONS
// either successful or failure - the pointer expresses it anyways
- ASSIMP_END_EXCEPTION_REGION_WITH_ERROR_STRING(const aiScene*, pimpl->mErrorString);
-
+ ASSIMP_END_EXCEPTION_REGION(const aiScene*);
return pimpl->mScene;
}
// ------------------------------------------------------------------------------------------------
// Apply post-processing to the currently bound scene
-const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) {
- ai_assert(nullptr != pimpl);
-
+const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags)
+{
ASSIMP_BEGIN_EXCEPTION_REGION();
// Return immediately if no scene is active
if (!pimpl->mScene) {
- return nullptr;
+ return NULL;
}
// If no flags are given, return the current scene with no further action
@@ -753,11 +737,12 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) {
#ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
// The ValidateDS process plays an exceptional role. It isn't contained in the global
// list of post-processing steps, so we need to call it manually.
- if (pFlags & aiProcess_ValidateDataStructure) {
+ if (pFlags & aiProcess_ValidateDataStructure)
+ {
ValidateDSProcess ds;
ds.ExecuteOnScene (this);
if (!pimpl->mScene) {
- return nullptr;
+ return NULL;
}
}
#endif // no validation
@@ -777,9 +762,11 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) {
std::unique_ptr<Profiler> profiler(GetPropertyInteger(AI_CONFIG_GLOB_MEASURE_TIME,0)?new Profiler():NULL);
for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) {
+
BaseProcess* process = pimpl->mPostProcessingSteps[a];
pimpl->mProgressHandler->UpdatePostProcess(static_cast<int>(a), static_cast<int>(pimpl->mPostProcessingSteps.size()) );
if( process->IsActive( pFlags)) {
+
if (profiler) {
profiler->BeginRegion("postprocess");
}
@@ -816,28 +803,24 @@ const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags) {
static_cast<int>(pimpl->mPostProcessingSteps.size()) );
// update private scene flags
- if( pimpl->mScene ) {
+ if( pimpl->mScene )
ScenePriv(pimpl->mScene)->mPPStepsApplied |= pFlags;
- }
// clear any data allocated by post-process steps
pimpl->mPPShared->Clean();
ASSIMP_LOG_INFO("Leaving post processing pipeline");
ASSIMP_END_EXCEPTION_REGION(const aiScene*);
-
return pimpl->mScene;
}
// ------------------------------------------------------------------------------------------------
const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess, bool requestValidation ) {
- ai_assert(nullptr != pimpl);
-
ASSIMP_BEGIN_EXCEPTION_REGION();
// Return immediately if no scene is active
- if ( nullptr == pimpl->mScene ) {
- return nullptr;
+ if ( NULL == pimpl->mScene ) {
+ return NULL;
}
// If no flags are given, return the current scene with no further action
@@ -856,7 +839,7 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess
ValidateDSProcess ds;
ds.ExecuteOnScene( this );
if ( !pimpl->mScene ) {
- return nullptr;
+ return NULL;
}
}
#endif // no validation
@@ -907,50 +890,46 @@ const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess
// ------------------------------------------------------------------------------------------------
// Helper function to check whether an extension is supported by ASSIMP
-bool Importer::IsExtensionSupported(const char* szExtension) const {
+bool Importer::IsExtensionSupported(const char* szExtension) const
+{
return nullptr != GetImporter(szExtension);
}
// ------------------------------------------------------------------------------------------------
-size_t Importer::GetImporterCount() const {
- ai_assert(nullptr != pimpl);
-
+size_t Importer::GetImporterCount() const
+{
return pimpl->mImporter.size();
}
// ------------------------------------------------------------------------------------------------
-const aiImporterDesc* Importer::GetImporterInfo(size_t index) const {
- ai_assert(nullptr != pimpl);
-
+const aiImporterDesc* Importer::GetImporterInfo(size_t index) const
+{
if (index >= pimpl->mImporter.size()) {
- return nullptr;
+ return NULL;
}
return pimpl->mImporter[index]->GetInfo();
}
// ------------------------------------------------------------------------------------------------
-BaseImporter* Importer::GetImporter (size_t index) const {
- ai_assert(nullptr != pimpl);
-
+BaseImporter* Importer::GetImporter (size_t index) const
+{
if (index >= pimpl->mImporter.size()) {
- return nullptr;
+ return NULL;
}
return pimpl->mImporter[index];
}
// ------------------------------------------------------------------------------------------------
// Find a loader plugin for a given file extension
-BaseImporter* Importer::GetImporter (const char* szExtension) const {
- ai_assert(nullptr != pimpl);
-
+BaseImporter* Importer::GetImporter (const char* szExtension) const
+{
return GetImporter(GetImporterIndex(szExtension));
}
// ------------------------------------------------------------------------------------------------
// Find a loader plugin for a given file extension
size_t Importer::GetImporterIndex (const char* szExtension) const {
- ai_assert(nullptr != pimpl);
ai_assert(nullptr != szExtension);
ASSIMP_BEGIN_EXCEPTION_REGION();
@@ -981,9 +960,8 @@ size_t Importer::GetImporterIndex (const char* szExtension) const {
// ------------------------------------------------------------------------------------------------
// Helper function to build a list of all file extensions supported by ASSIMP
-void Importer::GetExtensionList(aiString& szOut) const {
- ai_assert(nullptr != pimpl);
-
+void Importer::GetExtensionList(aiString& szOut) const
+{
ASSIMP_BEGIN_EXCEPTION_REGION();
std::set<std::string> str;
for (std::vector<BaseImporter*>::const_iterator i = pimpl->mImporter.begin();i != pimpl->mImporter.end();++i) {
@@ -1007,9 +985,8 @@ void Importer::GetExtensionList(aiString& szOut) const {
// ------------------------------------------------------------------------------------------------
// Set a configuration property
-bool Importer::SetPropertyInteger(const char* szName, int iValue) {
- ai_assert(nullptr != pimpl);
-
+bool Importer::SetPropertyInteger(const char* szName, int iValue)
+{
bool existing;
ASSIMP_BEGIN_EXCEPTION_REGION();
existing = SetGenericProperty<int>(pimpl->mIntProperties, szName,iValue);
@@ -1019,9 +996,8 @@ bool Importer::SetPropertyInteger(const char* szName, int iValue) {
// ------------------------------------------------------------------------------------------------
// Set a configuration property
-bool Importer::SetPropertyFloat(const char* szName, ai_real iValue) {
- ai_assert(nullptr != pimpl);
-
+bool Importer::SetPropertyFloat(const char* szName, ai_real iValue)
+{
bool existing;
ASSIMP_BEGIN_EXCEPTION_REGION();
existing = SetGenericProperty<ai_real>(pimpl->mFloatProperties, szName,iValue);
@@ -1031,9 +1007,8 @@ bool Importer::SetPropertyFloat(const char* szName, ai_real iValue) {
// ------------------------------------------------------------------------------------------------
// Set a configuration property
-bool Importer::SetPropertyString(const char* szName, const std::string& value) {
- ai_assert(nullptr != pimpl);
-
+bool Importer::SetPropertyString(const char* szName, const std::string& value)
+{
bool existing;
ASSIMP_BEGIN_EXCEPTION_REGION();
existing = SetGenericProperty<std::string>(pimpl->mStringProperties, szName,value);
@@ -1043,9 +1018,8 @@ bool Importer::SetPropertyString(const char* szName, const std::string& value) {
// ------------------------------------------------------------------------------------------------
// Set a configuration property
-bool Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value) {
- ai_assert(nullptr != pimpl);
-
+bool Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value)
+{
bool existing;
ASSIMP_BEGIN_EXCEPTION_REGION();
existing = SetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties, szName,value);
@@ -1055,43 +1029,40 @@ bool Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value) {
// ------------------------------------------------------------------------------------------------
// Get a configuration property
-int Importer::GetPropertyInteger(const char* szName, int iErrorReturn /*= 0xffffffff*/) const {
- ai_assert(nullptr != pimpl);
-
+int Importer::GetPropertyInteger(const char* szName,
+ int iErrorReturn /*= 0xffffffff*/) const
+{
return GetGenericProperty<int>(pimpl->mIntProperties,szName,iErrorReturn);
}
// ------------------------------------------------------------------------------------------------
// Get a configuration property
-ai_real Importer::GetPropertyFloat(const char* szName, ai_real iErrorReturn /*= 10e10*/) const {
- ai_assert(nullptr != pimpl);
-
+ai_real Importer::GetPropertyFloat(const char* szName,
+ ai_real iErrorReturn /*= 10e10*/) const
+{
return GetGenericProperty<ai_real>(pimpl->mFloatProperties,szName,iErrorReturn);
}
// ------------------------------------------------------------------------------------------------
// Get a configuration property
-std::string Importer::GetPropertyString(const char* szName, const std::string& iErrorReturn /*= ""*/) const {
- ai_assert(nullptr != pimpl);
-
+const std::string Importer::GetPropertyString(const char* szName,
+ const std::string& iErrorReturn /*= ""*/) const
+{
return GetGenericProperty<std::string>(pimpl->mStringProperties,szName,iErrorReturn);
}
// ------------------------------------------------------------------------------------------------
// Get a configuration property
-aiMatrix4x4 Importer::GetPropertyMatrix(const char* szName, const aiMatrix4x4& iErrorReturn /*= aiMatrix4x4()*/) const {
- ai_assert(nullptr != pimpl);
-
+const aiMatrix4x4 Importer::GetPropertyMatrix(const char* szName,
+ const aiMatrix4x4& iErrorReturn /*= aiMatrix4x4()*/) const
+{
return GetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties,szName,iErrorReturn);
}
// ------------------------------------------------------------------------------------------------
// Get the memory requirements of a single node
-inline
-void AddNodeWeight(unsigned int& iScene,const aiNode* pcNode) {
- if ( nullptr == pcNode ) {
- return;
- }
+inline void AddNodeWeight(unsigned int& iScene,const aiNode* pcNode)
+{
iScene += sizeof(aiNode);
iScene += sizeof(unsigned int) * pcNode->mNumMeshes;
iScene += sizeof(void*) * pcNode->mNumChildren;
@@ -1103,20 +1074,21 @@ void AddNodeWeight(unsigned int& iScene,const aiNode* pcNode) {
// ------------------------------------------------------------------------------------------------
// Get the memory requirements of the scene
-void Importer::GetMemoryRequirements(aiMemoryInfo& in) const {
- ai_assert(nullptr != pimpl);
-
+void Importer::GetMemoryRequirements(aiMemoryInfo& in) const
+{
in = aiMemoryInfo();
aiScene* mScene = pimpl->mScene;
// return if we have no scene loaded
- if (!mScene)
+ if (!pimpl->mScene)
return;
+
in.total = sizeof(aiScene);
// add all meshes
- for (unsigned int i = 0; i < mScene->mNumMeshes;++i) {
+ for (unsigned int i = 0; i < mScene->mNumMeshes;++i)
+ {
in.meshes += sizeof(aiMesh);
if (mScene->mMeshes[i]->HasPositions()) {
in.meshes += sizeof(aiVector3D) * mScene->mMeshes[i]->mNumVertices;
@@ -1133,16 +1105,14 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const {
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS;++a) {
if (mScene->mMeshes[i]->HasVertexColors(a)) {
in.meshes += sizeof(aiColor4D) * mScene->mMeshes[i]->mNumVertices;
- } else {
- break;
}
+ else break;
}
for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a) {
if (mScene->mMeshes[i]->HasTextureCoords(a)) {
in.meshes += sizeof(aiVector3D) * mScene->mMeshes[i]->mNumVertices;
- } else {
- break;
}
+ else break;
}
if (mScene->mMeshes[i]->HasBones()) {
in.meshes += sizeof(void*) * mScene->mMeshes[i]->mNumBones;
@@ -1161,9 +1131,8 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const {
in.textures += sizeof(aiTexture);
if (pc->mHeight) {
in.textures += 4 * pc->mHeight * pc->mWidth;
- } else {
- in.textures += pc->mWidth;
}
+ else in.textures += pc->mWidth;
}
in.total += in.textures;
@@ -1201,6 +1170,5 @@ void Importer::GetMemoryRequirements(aiMemoryInfo& in) const {
in.materials += pc->mProperties[a]->mDataLength;
}
}
-
in.total += in.materials;
}