Importer.cpp 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173
  1. /*
  2. ---------------------------------------------------------------------------
  3. Open Asset Import Library (assimp)
  4. ---------------------------------------------------------------------------
  5. Copyright (c) 2006-2018, assimp team
  6. All rights reserved.
  7. Redistribution and use of this software in source and binary forms,
  8. with or without modification, are permitted provided that the following
  9. conditions are met:
  10. * Redistributions of source code must retain the above
  11. copyright notice, this list of conditions and the
  12. following disclaimer.
  13. * Redistributions in binary form must reproduce the above
  14. copyright notice, this list of conditions and the
  15. following disclaimer in the documentation and/or other
  16. materials provided with the distribution.
  17. * Neither the name of the assimp team, nor the names of its
  18. contributors may be used to endorse or promote products
  19. derived from this software without specific prior
  20. written permission of the assimp team.
  21. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. ---------------------------------------------------------------------------
  33. */
  34. /** @file Importer.cpp
  35. * @brief Implementation of the CPP-API class #Importer
  36. */
  37. #include <assimp/version.h>
  38. #include <assimp/config.h>
  39. #include <assimp/importerdesc.h>
  40. // ------------------------------------------------------------------------------------------------
  41. /* Uncomment this line to prevent Assimp from catching unknown exceptions.
  42. *
  43. * Note that any Exception except DeadlyImportError may lead to
  44. * undefined behaviour -> loaders could remain in an unusable state and
  45. * further imports with the same Importer instance could fail/crash/burn ...
  46. */
  47. // ------------------------------------------------------------------------------------------------
  48. #ifndef ASSIMP_BUILD_DEBUG
  49. # define ASSIMP_CATCH_GLOBAL_EXCEPTIONS
  50. #endif
  51. // ------------------------------------------------------------------------------------------------
  52. // Internal headers
  53. // ------------------------------------------------------------------------------------------------
  54. #include "Importer.h"
  55. #include <assimp/BaseImporter.h>
  56. #include "BaseProcess.h"
  57. #include "DefaultProgressHandler.h"
  58. #include <assimp/GenericProperty.h>
  59. #include "ProcessHelper.h"
  60. #include "ScenePreprocessor.h"
  61. #include "ScenePrivate.h"
  62. #include <assimp/MemoryIOWrapper.h>
  63. #include <assimp/Profiler.h>
  64. #include <assimp/TinyFormatter.h>
  65. #include <assimp/Exceptional.h>
  66. #include <assimp/Profiler.h>
  67. #include <set>
  68. #include <memory>
  69. #include <cctype>
  70. #include <assimp/DefaultIOStream.h>
  71. #include <assimp/DefaultIOSystem.h>
  72. #ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
  73. # include "ValidateDataStructure.h"
  74. #endif
  75. using namespace Assimp::Profiling;
  76. using namespace Assimp::Formatter;
  77. namespace Assimp {
  78. // ImporterRegistry.cpp
  79. void GetImporterInstanceList(std::vector< BaseImporter* >& out);
  80. void DeleteImporterInstanceList(std::vector< BaseImporter* >& out);
  81. // PostStepRegistry.cpp
  82. void GetPostProcessingStepInstanceList(std::vector< BaseProcess* >& out);
  83. }
  84. using namespace Assimp;
  85. using namespace Assimp::Intern;
  86. // ------------------------------------------------------------------------------------------------
  87. // Intern::AllocateFromAssimpHeap serves as abstract base class. It overrides
  88. // new and delete (and their array counterparts) of public API classes (e.g. Logger) to
  89. // utilize our DLL heap.
  90. // See http://www.gotw.ca/publications/mill15.htm
  91. // ------------------------------------------------------------------------------------------------
  92. void* AllocateFromAssimpHeap::operator new ( size_t num_bytes) {
  93. return ::operator new(num_bytes);
  94. }
  95. void* AllocateFromAssimpHeap::operator new ( size_t num_bytes, const std::nothrow_t& ) throw() {
  96. try {
  97. return AllocateFromAssimpHeap::operator new( num_bytes );
  98. }
  99. catch( ... ) {
  100. return NULL;
  101. }
  102. }
  103. void AllocateFromAssimpHeap::operator delete ( void* data) {
  104. return ::operator delete(data);
  105. }
  106. void* AllocateFromAssimpHeap::operator new[] ( size_t num_bytes) {
  107. return ::operator new[](num_bytes);
  108. }
  109. void* AllocateFromAssimpHeap::operator new[] ( size_t num_bytes, const std::nothrow_t& ) throw() {
  110. try {
  111. return AllocateFromAssimpHeap::operator new[]( num_bytes );
  112. }
  113. catch( ... ) {
  114. return NULL;
  115. }
  116. }
  117. void AllocateFromAssimpHeap::operator delete[] ( void* data) {
  118. return ::operator delete[](data);
  119. }
  120. // ------------------------------------------------------------------------------------------------
  121. // Importer constructor.
  122. Importer::Importer()
  123. : pimpl( new ImporterPimpl ) {
  124. pimpl->mScene = NULL;
  125. pimpl->mErrorString = "";
  126. // Allocate a default IO handler
  127. pimpl->mIOHandler = new DefaultIOSystem;
  128. pimpl->mIsDefaultHandler = true;
  129. pimpl->bExtraVerbose = false; // disable extra verbose mode by default
  130. pimpl->mProgressHandler = new DefaultProgressHandler();
  131. pimpl->mIsDefaultProgressHandler = true;
  132. GetImporterInstanceList(pimpl->mImporter);
  133. GetPostProcessingStepInstanceList(pimpl->mPostProcessingSteps);
  134. // Allocate a SharedPostProcessInfo object and store pointers to it in all post-process steps in the list.
  135. pimpl->mPPShared = new SharedPostProcessInfo();
  136. for (std::vector<BaseProcess*>::iterator it = pimpl->mPostProcessingSteps.begin();
  137. it != pimpl->mPostProcessingSteps.end();
  138. ++it) {
  139. (*it)->SetSharedData(pimpl->mPPShared);
  140. }
  141. }
  142. // ------------------------------------------------------------------------------------------------
  143. // Destructor of Importer
  144. Importer::~Importer()
  145. {
  146. // Delete all import plugins
  147. DeleteImporterInstanceList(pimpl->mImporter);
  148. // Delete all post-processing plug-ins
  149. for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++)
  150. delete pimpl->mPostProcessingSteps[a];
  151. // Delete the assigned IO and progress handler
  152. delete pimpl->mIOHandler;
  153. delete pimpl->mProgressHandler;
  154. // Kill imported scene. Destructor's should do that recursively
  155. delete pimpl->mScene;
  156. // Delete shared post-processing data
  157. delete pimpl->mPPShared;
  158. // and finally the pimpl itself
  159. delete pimpl;
  160. }
  161. // ------------------------------------------------------------------------------------------------
  162. // Register a custom post-processing step
  163. aiReturn Importer::RegisterPPStep(BaseProcess* pImp)
  164. {
  165. ai_assert(NULL != pImp);
  166. ASSIMP_BEGIN_EXCEPTION_REGION();
  167. pimpl->mPostProcessingSteps.push_back(pImp);
  168. ASSIMP_LOG_INFO("Registering custom post-processing step");
  169. ASSIMP_END_EXCEPTION_REGION(aiReturn);
  170. return AI_SUCCESS;
  171. }
  172. // ------------------------------------------------------------------------------------------------
  173. // Register a custom loader plugin
  174. aiReturn Importer::RegisterLoader(BaseImporter* pImp)
  175. {
  176. ai_assert(NULL != pImp);
  177. ASSIMP_BEGIN_EXCEPTION_REGION();
  178. // --------------------------------------------------------------------
  179. // Check whether we would have two loaders for the same file extension
  180. // This is absolutely OK, but we should warn the developer of the new
  181. // loader that his code will probably never be called if the first
  182. // loader is a bit too lazy in his file checking.
  183. // --------------------------------------------------------------------
  184. std::set<std::string> st;
  185. std::string baked;
  186. pImp->GetExtensionList(st);
  187. for(std::set<std::string>::const_iterator it = st.begin(); it != st.end(); ++it) {
  188. #ifdef ASSIMP_BUILD_DEBUG
  189. if (IsExtensionSupported(*it)) {
  190. ASSIMP_LOG_WARN_F("The file extension ", *it, " is already in use");
  191. }
  192. #endif
  193. baked += *it;
  194. }
  195. // add the loader
  196. pimpl->mImporter.push_back(pImp);
  197. ASSIMP_LOG_INFO_F("Registering custom importer for these file extensions: ", baked);
  198. ASSIMP_END_EXCEPTION_REGION(aiReturn);
  199. return AI_SUCCESS;
  200. }
  201. // ------------------------------------------------------------------------------------------------
  202. // Unregister a custom loader plugin
  203. aiReturn Importer::UnregisterLoader(BaseImporter* pImp)
  204. {
  205. if(!pImp) {
  206. // unregistering a NULL importer is no problem for us ... really!
  207. return AI_SUCCESS;
  208. }
  209. ASSIMP_BEGIN_EXCEPTION_REGION();
  210. std::vector<BaseImporter*>::iterator it = std::find(pimpl->mImporter.begin(),
  211. pimpl->mImporter.end(),pImp);
  212. if (it != pimpl->mImporter.end()) {
  213. pimpl->mImporter.erase(it);
  214. ASSIMP_LOG_INFO("Unregistering custom importer: ");
  215. return AI_SUCCESS;
  216. }
  217. ASSIMP_LOG_WARN("Unable to remove custom importer: I can't find you ...");
  218. ASSIMP_END_EXCEPTION_REGION(aiReturn);
  219. return AI_FAILURE;
  220. }
  221. // ------------------------------------------------------------------------------------------------
  222. // Unregister a custom loader plugin
  223. aiReturn Importer::UnregisterPPStep(BaseProcess* pImp)
  224. {
  225. if(!pImp) {
  226. // unregistering a NULL ppstep is no problem for us ... really!
  227. return AI_SUCCESS;
  228. }
  229. ASSIMP_BEGIN_EXCEPTION_REGION();
  230. std::vector<BaseProcess*>::iterator it = std::find(pimpl->mPostProcessingSteps.begin(),
  231. pimpl->mPostProcessingSteps.end(),pImp);
  232. if (it != pimpl->mPostProcessingSteps.end()) {
  233. pimpl->mPostProcessingSteps.erase(it);
  234. ASSIMP_LOG_INFO("Unregistering custom post-processing step");
  235. return AI_SUCCESS;
  236. }
  237. ASSIMP_LOG_WARN("Unable to remove custom post-processing step: I can't find you ..");
  238. ASSIMP_END_EXCEPTION_REGION(aiReturn);
  239. return AI_FAILURE;
  240. }
  241. // ------------------------------------------------------------------------------------------------
  242. // Supplies a custom IO handler to the importer to open and access files.
  243. void Importer::SetIOHandler( IOSystem* pIOHandler)
  244. {
  245. ASSIMP_BEGIN_EXCEPTION_REGION();
  246. // If the new handler is zero, allocate a default IO implementation.
  247. if (!pIOHandler)
  248. {
  249. // Release pointer in the possession of the caller
  250. pimpl->mIOHandler = new DefaultIOSystem();
  251. pimpl->mIsDefaultHandler = true;
  252. }
  253. // Otherwise register the custom handler
  254. else if (pimpl->mIOHandler != pIOHandler)
  255. {
  256. delete pimpl->mIOHandler;
  257. pimpl->mIOHandler = pIOHandler;
  258. pimpl->mIsDefaultHandler = false;
  259. }
  260. ASSIMP_END_EXCEPTION_REGION(void);
  261. }
  262. // ------------------------------------------------------------------------------------------------
  263. // Get the currently set IO handler
  264. IOSystem* Importer::GetIOHandler() const
  265. {
  266. return pimpl->mIOHandler;
  267. }
  268. // ------------------------------------------------------------------------------------------------
  269. // Check whether a custom IO handler is currently set
  270. bool Importer::IsDefaultIOHandler() const
  271. {
  272. return pimpl->mIsDefaultHandler;
  273. }
  274. // ------------------------------------------------------------------------------------------------
  275. // Supplies a custom progress handler to get regular callbacks during importing
  276. void Importer::SetProgressHandler ( ProgressHandler* pHandler )
  277. {
  278. ASSIMP_BEGIN_EXCEPTION_REGION();
  279. // If the new handler is zero, allocate a default implementation.
  280. if (!pHandler)
  281. {
  282. // Release pointer in the possession of the caller
  283. pimpl->mProgressHandler = new DefaultProgressHandler();
  284. pimpl->mIsDefaultProgressHandler = true;
  285. }
  286. // Otherwise register the custom handler
  287. else if (pimpl->mProgressHandler != pHandler)
  288. {
  289. delete pimpl->mProgressHandler;
  290. pimpl->mProgressHandler = pHandler;
  291. pimpl->mIsDefaultProgressHandler = false;
  292. }
  293. ASSIMP_END_EXCEPTION_REGION(void);
  294. }
  295. // ------------------------------------------------------------------------------------------------
  296. // Get the currently set progress handler
  297. ProgressHandler* Importer::GetProgressHandler() const
  298. {
  299. return pimpl->mProgressHandler;
  300. }
  301. // ------------------------------------------------------------------------------------------------
  302. // Check whether a custom progress handler is currently set
  303. bool Importer::IsDefaultProgressHandler() const
  304. {
  305. return pimpl->mIsDefaultProgressHandler;
  306. }
  307. // ------------------------------------------------------------------------------------------------
  308. // Validate post process step flags
  309. bool _ValidateFlags(unsigned int pFlags)
  310. {
  311. if (pFlags & aiProcess_GenSmoothNormals && pFlags & aiProcess_GenNormals) {
  312. ASSIMP_LOG_ERROR("#aiProcess_GenSmoothNormals and #aiProcess_GenNormals are incompatible");
  313. return false;
  314. }
  315. if (pFlags & aiProcess_OptimizeGraph && pFlags & aiProcess_PreTransformVertices) {
  316. ASSIMP_LOG_ERROR("#aiProcess_OptimizeGraph and #aiProcess_PreTransformVertices are incompatible");
  317. return false;
  318. }
  319. return true;
  320. }
  321. // ------------------------------------------------------------------------------------------------
  322. // Free the current scene
  323. void Importer::FreeScene( )
  324. {
  325. ASSIMP_BEGIN_EXCEPTION_REGION();
  326. delete pimpl->mScene;
  327. pimpl->mScene = NULL;
  328. pimpl->mErrorString = "";
  329. ASSIMP_END_EXCEPTION_REGION(void);
  330. }
  331. // ------------------------------------------------------------------------------------------------
  332. // Get the current error string, if any
  333. const char* Importer::GetErrorString() const
  334. {
  335. /* Must remain valid as long as ReadFile() or FreeFile() are not called */
  336. return pimpl->mErrorString.c_str();
  337. }
  338. // ------------------------------------------------------------------------------------------------
  339. // Enable extra-verbose mode
  340. void Importer::SetExtraVerbose(bool bDo)
  341. {
  342. pimpl->bExtraVerbose = bDo;
  343. }
  344. // ------------------------------------------------------------------------------------------------
  345. // Get the current scene
  346. const aiScene* Importer::GetScene() const
  347. {
  348. return pimpl->mScene;
  349. }
  350. // ------------------------------------------------------------------------------------------------
  351. // Orphan the current scene and return it.
  352. aiScene* Importer::GetOrphanedScene()
  353. {
  354. aiScene* s = pimpl->mScene;
  355. ASSIMP_BEGIN_EXCEPTION_REGION();
  356. pimpl->mScene = NULL;
  357. pimpl->mErrorString = ""; /* reset error string */
  358. ASSIMP_END_EXCEPTION_REGION(aiScene*);
  359. return s;
  360. }
  361. // ------------------------------------------------------------------------------------------------
  362. // Validate post-processing flags
  363. bool Importer::ValidateFlags(unsigned int pFlags) const
  364. {
  365. ASSIMP_BEGIN_EXCEPTION_REGION();
  366. // run basic checks for mutually exclusive flags
  367. if(!_ValidateFlags(pFlags)) {
  368. return false;
  369. }
  370. // ValidateDS does not anymore occur in the pp list, it plays an awesome extra role ...
  371. #ifdef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
  372. if (pFlags & aiProcess_ValidateDataStructure) {
  373. return false;
  374. }
  375. #endif
  376. pFlags &= ~aiProcess_ValidateDataStructure;
  377. // Now iterate through all bits which are set in the flags and check whether we find at least
  378. // one pp plugin which handles it.
  379. for (unsigned int mask = 1; mask < (1u << (sizeof(unsigned int)*8-1));mask <<= 1) {
  380. if (pFlags & mask) {
  381. bool have = false;
  382. for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) {
  383. if (pimpl->mPostProcessingSteps[a]-> IsActive(mask) ) {
  384. have = true;
  385. break;
  386. }
  387. }
  388. if (!have) {
  389. return false;
  390. }
  391. }
  392. }
  393. ASSIMP_END_EXCEPTION_REGION(bool);
  394. return true;
  395. }
  396. // ------------------------------------------------------------------------------------------------
  397. const aiScene* Importer::ReadFileFromMemory( const void* pBuffer,
  398. size_t pLength,
  399. unsigned int pFlags,
  400. const char* pHint /*= ""*/)
  401. {
  402. ASSIMP_BEGIN_EXCEPTION_REGION();
  403. if (!pHint) {
  404. pHint = "";
  405. }
  406. if (!pBuffer || !pLength || strlen(pHint) > MaxLenHint ) {
  407. pimpl->mErrorString = "Invalid parameters passed to ReadFileFromMemory()";
  408. return NULL;
  409. }
  410. // prevent deletion of the previous IOHandler
  411. IOSystem* io = pimpl->mIOHandler;
  412. pimpl->mIOHandler = NULL;
  413. SetIOHandler(new MemoryIOSystem((const uint8_t*)pBuffer,pLength));
  414. // read the file and recover the previous IOSystem
  415. static const size_t BufferSize(Importer::MaxLenHint + 28);
  416. char fbuff[ BufferSize ];
  417. ai_snprintf(fbuff, BufferSize, "%s.%s",AI_MEMORYIO_MAGIC_FILENAME,pHint);
  418. ReadFile(fbuff,pFlags);
  419. SetIOHandler(io);
  420. ASSIMP_END_EXCEPTION_REGION(const aiScene*);
  421. return pimpl->mScene;
  422. }
  423. // ------------------------------------------------------------------------------------------------
  424. void WriteLogOpening(const std::string& file)
  425. {
  426. ASSIMP_LOG_INFO_F("Load ", file);
  427. // print a full version dump. This is nice because we don't
  428. // need to ask the authors of incoming bug reports for
  429. // the library version they're using - a log dump is
  430. // sufficient.
  431. const unsigned int flags( aiGetCompileFlags() );
  432. std::stringstream stream;
  433. stream << "Assimp " << aiGetVersionMajor() << "." << aiGetVersionMinor() << "." << aiGetVersionRevision() << " "
  434. #if defined(ASSIMP_BUILD_ARCHITECTURE)
  435. << ASSIMP_BUILD_ARCHITECTURE
  436. #elif defined(_M_IX86) || defined(__x86_32__) || defined(__i386__)
  437. << "x86"
  438. #elif defined(_M_X64) || defined(__x86_64__)
  439. << "amd64"
  440. #elif defined(_M_IA64) || defined(__ia64__)
  441. << "itanium"
  442. #elif defined(__ppc__) || defined(__powerpc__)
  443. << "ppc32"
  444. #elif defined(__powerpc64__)
  445. << "ppc64"
  446. #elif defined(__arm__)
  447. << "arm"
  448. #else
  449. << "<unknown architecture>"
  450. #endif
  451. << " "
  452. #if defined(ASSIMP_BUILD_COMPILER)
  453. << ( ASSIMP_BUILD_COMPILER )
  454. #elif defined(_MSC_VER)
  455. << "msvc"
  456. #elif defined(__GNUC__)
  457. << "gcc"
  458. #else
  459. << "<unknown compiler>"
  460. #endif
  461. #ifdef ASSIMP_BUILD_DEBUG
  462. << " debug"
  463. #endif
  464. << (flags & ASSIMP_CFLAGS_NOBOOST ? " noboost" : "")
  465. << (flags & ASSIMP_CFLAGS_SHARED ? " shared" : "")
  466. << (flags & ASSIMP_CFLAGS_SINGLETHREADED ? " singlethreaded" : "");
  467. ASSIMP_LOG_DEBUG(stream.str());
  468. }
  469. // ------------------------------------------------------------------------------------------------
  470. // Reads the given file and returns its contents if successful.
  471. const aiScene* Importer::ReadFile( const char* _pFile, unsigned int pFlags)
  472. {
  473. ASSIMP_BEGIN_EXCEPTION_REGION();
  474. const std::string pFile(_pFile);
  475. // ----------------------------------------------------------------------
  476. // Put a large try block around everything to catch all std::exception's
  477. // that might be thrown by STL containers or by new().
  478. // ImportErrorException's are throw by ourselves and caught elsewhere.
  479. //-----------------------------------------------------------------------
  480. WriteLogOpening(pFile);
  481. #ifdef ASSIMP_CATCH_GLOBAL_EXCEPTIONS
  482. try
  483. #endif // ! ASSIMP_CATCH_GLOBAL_EXCEPTIONS
  484. {
  485. // Check whether this Importer instance has already loaded
  486. // a scene. In this case we need to delete the old one
  487. if (pimpl->mScene) {
  488. ASSIMP_LOG_DEBUG("(Deleting previous scene)");
  489. FreeScene();
  490. }
  491. // First check if the file is accessible at all
  492. if( !pimpl->mIOHandler->Exists( pFile)) {
  493. pimpl->mErrorString = "Unable to open file \"" + pFile + "\".";
  494. ASSIMP_LOG_ERROR(pimpl->mErrorString);
  495. return NULL;
  496. }
  497. std::unique_ptr<Profiler> profiler(GetPropertyInteger(AI_CONFIG_GLOB_MEASURE_TIME,0)?new Profiler():NULL);
  498. if (profiler) {
  499. profiler->BeginRegion("total");
  500. }
  501. // Find an worker class which can handle the file
  502. BaseImporter* imp = NULL;
  503. for( unsigned int a = 0; a < pimpl->mImporter.size(); a++) {
  504. if( pimpl->mImporter[a]->CanRead( pFile, pimpl->mIOHandler, false)) {
  505. imp = pimpl->mImporter[a];
  506. break;
  507. }
  508. }
  509. if (!imp) {
  510. // not so bad yet ... try format auto detection.
  511. const std::string::size_type s = pFile.find_last_of('.');
  512. if (s != std::string::npos) {
  513. ASSIMP_LOG_INFO("File extension not known, trying signature-based detection");
  514. for( unsigned int a = 0; a < pimpl->mImporter.size(); a++) {
  515. if( pimpl->mImporter[a]->CanRead( pFile, pimpl->mIOHandler, true)) {
  516. imp = pimpl->mImporter[a];
  517. break;
  518. }
  519. }
  520. }
  521. // Put a proper error message if no suitable importer was found
  522. if( !imp) {
  523. pimpl->mErrorString = "No suitable reader found for the file format of file \"" + pFile + "\".";
  524. ASSIMP_LOG_ERROR(pimpl->mErrorString);
  525. return NULL;
  526. }
  527. }
  528. // Get file size for progress handler
  529. IOStream * fileIO = pimpl->mIOHandler->Open( pFile );
  530. uint32_t fileSize = 0;
  531. if (fileIO)
  532. {
  533. fileSize = static_cast<uint32_t>(fileIO->FileSize());
  534. pimpl->mIOHandler->Close( fileIO );
  535. }
  536. // Dispatch the reading to the worker class for this format
  537. const aiImporterDesc *desc( imp->GetInfo() );
  538. std::string ext( "unknown" );
  539. if ( NULL != desc ) {
  540. ext = desc->mName;
  541. }
  542. ASSIMP_LOG_INFO("Found a matching importer for this file format: " + ext + "." );
  543. pimpl->mProgressHandler->UpdateFileRead( 0, fileSize );
  544. if (profiler) {
  545. profiler->BeginRegion("import");
  546. }
  547. pimpl->mScene = imp->ReadFile( this, pFile, pimpl->mIOHandler);
  548. pimpl->mProgressHandler->UpdateFileRead( fileSize, fileSize );
  549. if (profiler) {
  550. profiler->EndRegion("import");
  551. }
  552. SetPropertyString("sourceFilePath", pFile);
  553. // If successful, apply all active post processing steps to the imported data
  554. if( pimpl->mScene) {
  555. #ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
  556. // The ValidateDS process is an exception. It is executed first, even before ScenePreprocessor is called.
  557. if (pFlags & aiProcess_ValidateDataStructure)
  558. {
  559. ValidateDSProcess ds;
  560. ds.ExecuteOnScene (this);
  561. if (!pimpl->mScene) {
  562. return NULL;
  563. }
  564. }
  565. #endif // no validation
  566. // Preprocess the scene and prepare it for post-processing
  567. if (profiler) {
  568. profiler->BeginRegion("preprocess");
  569. }
  570. ScenePreprocessor pre(pimpl->mScene);
  571. pre.ProcessScene();
  572. if (profiler) {
  573. profiler->EndRegion("preprocess");
  574. }
  575. // Ensure that the validation process won't be called twice
  576. ApplyPostProcessing(pFlags & (~aiProcess_ValidateDataStructure));
  577. }
  578. // if failed, extract the error string
  579. else if( !pimpl->mScene) {
  580. pimpl->mErrorString = imp->GetErrorText();
  581. }
  582. // clear any data allocated by post-process steps
  583. pimpl->mPPShared->Clean();
  584. if (profiler) {
  585. profiler->EndRegion("total");
  586. }
  587. }
  588. #ifdef ASSIMP_CATCH_GLOBAL_EXCEPTIONS
  589. catch (std::exception &e)
  590. {
  591. #if (defined _MSC_VER) && (defined _CPPRTTI)
  592. // if we have RTTI get the full name of the exception that occurred
  593. pimpl->mErrorString = std::string(typeid( e ).name()) + ": " + e.what();
  594. #else
  595. pimpl->mErrorString = std::string("std::exception: ") + e.what();
  596. #endif
  597. ASSIMP_LOG_ERROR(pimpl->mErrorString);
  598. delete pimpl->mScene; pimpl->mScene = NULL;
  599. }
  600. #endif // ! ASSIMP_CATCH_GLOBAL_EXCEPTIONS
  601. // either successful or failure - the pointer expresses it anyways
  602. ASSIMP_END_EXCEPTION_REGION(const aiScene*);
  603. return pimpl->mScene;
  604. }
  605. // ------------------------------------------------------------------------------------------------
  606. // Apply post-processing to the currently bound scene
  607. const aiScene* Importer::ApplyPostProcessing(unsigned int pFlags)
  608. {
  609. ASSIMP_BEGIN_EXCEPTION_REGION();
  610. // Return immediately if no scene is active
  611. if (!pimpl->mScene) {
  612. return NULL;
  613. }
  614. // If no flags are given, return the current scene with no further action
  615. if (!pFlags) {
  616. return pimpl->mScene;
  617. }
  618. // In debug builds: run basic flag validation
  619. ai_assert(_ValidateFlags(pFlags));
  620. ASSIMP_LOG_INFO("Entering post processing pipeline");
  621. #ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
  622. // The ValidateDS process plays an exceptional role. It isn't contained in the global
  623. // list of post-processing steps, so we need to call it manually.
  624. if (pFlags & aiProcess_ValidateDataStructure)
  625. {
  626. ValidateDSProcess ds;
  627. ds.ExecuteOnScene (this);
  628. if (!pimpl->mScene) {
  629. return NULL;
  630. }
  631. }
  632. #endif // no validation
  633. #ifdef ASSIMP_BUILD_DEBUG
  634. if (pimpl->bExtraVerbose)
  635. {
  636. #ifdef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
  637. ASSIMP_LOG_ERROR("Verbose Import is not available due to build settings");
  638. #endif // no validation
  639. pFlags |= aiProcess_ValidateDataStructure;
  640. }
  641. #else
  642. if (pimpl->bExtraVerbose) {
  643. ASSIMP_LOG_WARN("Not a debug build, ignoring extra verbose setting");
  644. }
  645. #endif // ! DEBUG
  646. std::unique_ptr<Profiler> profiler(GetPropertyInteger(AI_CONFIG_GLOB_MEASURE_TIME,0)?new Profiler():NULL);
  647. for( unsigned int a = 0; a < pimpl->mPostProcessingSteps.size(); a++) {
  648. BaseProcess* process = pimpl->mPostProcessingSteps[a];
  649. pimpl->mProgressHandler->UpdatePostProcess(static_cast<int>(a), static_cast<int>(pimpl->mPostProcessingSteps.size()) );
  650. if( process->IsActive( pFlags)) {
  651. if (profiler) {
  652. profiler->BeginRegion("postprocess");
  653. }
  654. process->ExecuteOnScene ( this );
  655. if (profiler) {
  656. profiler->EndRegion("postprocess");
  657. }
  658. }
  659. if( !pimpl->mScene) {
  660. break;
  661. }
  662. #ifdef ASSIMP_BUILD_DEBUG
  663. #ifdef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
  664. continue;
  665. #endif // no validation
  666. // If the extra verbose mode is active, execute the ValidateDataStructureStep again - after each step
  667. if (pimpl->bExtraVerbose) {
  668. ASSIMP_LOG_DEBUG("Verbose Import: re-validating data structures");
  669. ValidateDSProcess ds;
  670. ds.ExecuteOnScene (this);
  671. if( !pimpl->mScene) {
  672. ASSIMP_LOG_ERROR("Verbose Import: failed to re-validate data structures");
  673. break;
  674. }
  675. }
  676. #endif // ! DEBUG
  677. }
  678. pimpl->mProgressHandler->UpdatePostProcess( static_cast<int>(pimpl->mPostProcessingSteps.size()),
  679. static_cast<int>(pimpl->mPostProcessingSteps.size()) );
  680. // update private scene flags
  681. if( pimpl->mScene )
  682. ScenePriv(pimpl->mScene)->mPPStepsApplied |= pFlags;
  683. // clear any data allocated by post-process steps
  684. pimpl->mPPShared->Clean();
  685. ASSIMP_LOG_INFO("Leaving post processing pipeline");
  686. ASSIMP_END_EXCEPTION_REGION(const aiScene*);
  687. return pimpl->mScene;
  688. }
  689. // ------------------------------------------------------------------------------------------------
  690. const aiScene* Importer::ApplyCustomizedPostProcessing( BaseProcess *rootProcess, bool requestValidation ) {
  691. ASSIMP_BEGIN_EXCEPTION_REGION();
  692. // Return immediately if no scene is active
  693. if ( NULL == pimpl->mScene ) {
  694. return NULL;
  695. }
  696. // If no flags are given, return the current scene with no further action
  697. if ( NULL == rootProcess ) {
  698. return pimpl->mScene;
  699. }
  700. // In debug builds: run basic flag validation
  701. ASSIMP_LOG_INFO( "Entering customized post processing pipeline" );
  702. #ifndef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
  703. // The ValidateDS process plays an exceptional role. It isn't contained in the global
  704. // list of post-processing steps, so we need to call it manually.
  705. if ( requestValidation )
  706. {
  707. ValidateDSProcess ds;
  708. ds.ExecuteOnScene( this );
  709. if ( !pimpl->mScene ) {
  710. return NULL;
  711. }
  712. }
  713. #endif // no validation
  714. #ifdef ASSIMP_BUILD_DEBUG
  715. if ( pimpl->bExtraVerbose )
  716. {
  717. #ifdef ASSIMP_BUILD_NO_VALIDATEDS_PROCESS
  718. ASSIMP_LOG_ERROR( "Verbose Import is not available due to build settings" );
  719. #endif // no validation
  720. }
  721. #else
  722. if ( pimpl->bExtraVerbose ) {
  723. ASSIMP_LOG_WARN( "Not a debug build, ignoring extra verbose setting" );
  724. }
  725. #endif // ! DEBUG
  726. std::unique_ptr<Profiler> profiler( GetPropertyInteger( AI_CONFIG_GLOB_MEASURE_TIME, 0 ) ? new Profiler() : NULL );
  727. if ( profiler ) {
  728. profiler->BeginRegion( "postprocess" );
  729. }
  730. rootProcess->ExecuteOnScene( this );
  731. if ( profiler ) {
  732. profiler->EndRegion( "postprocess" );
  733. }
  734. // If the extra verbose mode is active, execute the ValidateDataStructureStep again - after each step
  735. if ( pimpl->bExtraVerbose || requestValidation ) {
  736. ASSIMP_LOG_DEBUG( "Verbose Import: revalidating data structures" );
  737. ValidateDSProcess ds;
  738. ds.ExecuteOnScene( this );
  739. if ( !pimpl->mScene ) {
  740. ASSIMP_LOG_ERROR( "Verbose Import: failed to revalidate data structures" );
  741. }
  742. }
  743. // clear any data allocated by post-process steps
  744. pimpl->mPPShared->Clean();
  745. ASSIMP_LOG_INFO( "Leaving customized post processing pipeline" );
  746. ASSIMP_END_EXCEPTION_REGION( const aiScene* );
  747. return pimpl->mScene;
  748. }
  749. // ------------------------------------------------------------------------------------------------
  750. // Helper function to check whether an extension is supported by ASSIMP
  751. bool Importer::IsExtensionSupported(const char* szExtension) const
  752. {
  753. return nullptr != GetImporter(szExtension);
  754. }
  755. // ------------------------------------------------------------------------------------------------
  756. size_t Importer::GetImporterCount() const
  757. {
  758. return pimpl->mImporter.size();
  759. }
  760. // ------------------------------------------------------------------------------------------------
  761. const aiImporterDesc* Importer::GetImporterInfo(size_t index) const
  762. {
  763. if (index >= pimpl->mImporter.size()) {
  764. return NULL;
  765. }
  766. return pimpl->mImporter[index]->GetInfo();
  767. }
  768. // ------------------------------------------------------------------------------------------------
  769. BaseImporter* Importer::GetImporter (size_t index) const
  770. {
  771. if (index >= pimpl->mImporter.size()) {
  772. return NULL;
  773. }
  774. return pimpl->mImporter[index];
  775. }
  776. // ------------------------------------------------------------------------------------------------
  777. // Find a loader plugin for a given file extension
  778. BaseImporter* Importer::GetImporter (const char* szExtension) const
  779. {
  780. return GetImporter(GetImporterIndex(szExtension));
  781. }
  782. // ------------------------------------------------------------------------------------------------
  783. // Find a loader plugin for a given file extension
  784. size_t Importer::GetImporterIndex (const char* szExtension) const
  785. {
  786. ai_assert(szExtension);
  787. ASSIMP_BEGIN_EXCEPTION_REGION();
  788. // skip over wildcard and dot characters at string head --
  789. for(;*szExtension == '*' || *szExtension == '.'; ++szExtension);
  790. std::string ext(szExtension);
  791. if (ext.empty()) {
  792. return static_cast<size_t>(-1);
  793. }
  794. std::transform(ext.begin(),ext.end(), ext.begin(), tolower);
  795. std::set<std::string> str;
  796. for (std::vector<BaseImporter*>::const_iterator i = pimpl->mImporter.begin();i != pimpl->mImporter.end();++i) {
  797. str.clear();
  798. (*i)->GetExtensionList(str);
  799. for (std::set<std::string>::const_iterator it = str.begin(); it != str.end(); ++it) {
  800. if (ext == *it) {
  801. return std::distance(static_cast< std::vector<BaseImporter*>::const_iterator >(pimpl->mImporter.begin()), i);
  802. }
  803. }
  804. }
  805. ASSIMP_END_EXCEPTION_REGION(size_t);
  806. return static_cast<size_t>(-1);
  807. }
  808. // ------------------------------------------------------------------------------------------------
  809. // Helper function to build a list of all file extensions supported by ASSIMP
  810. void Importer::GetExtensionList(aiString& szOut) const
  811. {
  812. ASSIMP_BEGIN_EXCEPTION_REGION();
  813. std::set<std::string> str;
  814. for (std::vector<BaseImporter*>::const_iterator i = pimpl->mImporter.begin();i != pimpl->mImporter.end();++i) {
  815. (*i)->GetExtensionList(str);
  816. }
  817. for (std::set<std::string>::const_iterator it = str.begin();; ) {
  818. szOut.Append("*.");
  819. szOut.Append((*it).c_str());
  820. if (++it == str.end()) {
  821. break;
  822. }
  823. szOut.Append(";");
  824. }
  825. ASSIMP_END_EXCEPTION_REGION(void);
  826. }
  827. // ------------------------------------------------------------------------------------------------
  828. // Set a configuration property
  829. bool Importer::SetPropertyInteger(const char* szName, int iValue)
  830. {
  831. bool existing;
  832. ASSIMP_BEGIN_EXCEPTION_REGION();
  833. existing = SetGenericProperty<int>(pimpl->mIntProperties, szName,iValue);
  834. ASSIMP_END_EXCEPTION_REGION(bool);
  835. return existing;
  836. }
  837. // ------------------------------------------------------------------------------------------------
  838. // Set a configuration property
  839. bool Importer::SetPropertyFloat(const char* szName, ai_real iValue)
  840. {
  841. bool exising;
  842. ASSIMP_BEGIN_EXCEPTION_REGION();
  843. exising = SetGenericProperty<ai_real>(pimpl->mFloatProperties, szName,iValue);
  844. ASSIMP_END_EXCEPTION_REGION(bool);
  845. return exising;
  846. }
  847. // ------------------------------------------------------------------------------------------------
  848. // Set a configuration property
  849. bool Importer::SetPropertyString(const char* szName, const std::string& value)
  850. {
  851. bool exising;
  852. ASSIMP_BEGIN_EXCEPTION_REGION();
  853. exising = SetGenericProperty<std::string>(pimpl->mStringProperties, szName,value);
  854. ASSIMP_END_EXCEPTION_REGION(bool);
  855. return exising;
  856. }
  857. // ------------------------------------------------------------------------------------------------
  858. // Set a configuration property
  859. bool Importer::SetPropertyMatrix(const char* szName, const aiMatrix4x4& value)
  860. {
  861. bool exising;
  862. ASSIMP_BEGIN_EXCEPTION_REGION();
  863. exising = SetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties, szName,value);
  864. ASSIMP_END_EXCEPTION_REGION(bool);
  865. return exising;
  866. }
  867. // ------------------------------------------------------------------------------------------------
  868. // Get a configuration property
  869. int Importer::GetPropertyInteger(const char* szName,
  870. int iErrorReturn /*= 0xffffffff*/) const
  871. {
  872. return GetGenericProperty<int>(pimpl->mIntProperties,szName,iErrorReturn);
  873. }
  874. // ------------------------------------------------------------------------------------------------
  875. // Get a configuration property
  876. ai_real Importer::GetPropertyFloat(const char* szName,
  877. ai_real iErrorReturn /*= 10e10*/) const
  878. {
  879. return GetGenericProperty<ai_real>(pimpl->mFloatProperties,szName,iErrorReturn);
  880. }
  881. // ------------------------------------------------------------------------------------------------
  882. // Get a configuration property
  883. const std::string Importer::GetPropertyString(const char* szName,
  884. const std::string& iErrorReturn /*= ""*/) const
  885. {
  886. return GetGenericProperty<std::string>(pimpl->mStringProperties,szName,iErrorReturn);
  887. }
  888. // ------------------------------------------------------------------------------------------------
  889. // Get a configuration property
  890. const aiMatrix4x4 Importer::GetPropertyMatrix(const char* szName,
  891. const aiMatrix4x4& iErrorReturn /*= aiMatrix4x4()*/) const
  892. {
  893. return GetGenericProperty<aiMatrix4x4>(pimpl->mMatrixProperties,szName,iErrorReturn);
  894. }
  895. // ------------------------------------------------------------------------------------------------
  896. // Get the memory requirements of a single node
  897. inline void AddNodeWeight(unsigned int& iScene,const aiNode* pcNode)
  898. {
  899. iScene += sizeof(aiNode);
  900. iScene += sizeof(unsigned int) * pcNode->mNumMeshes;
  901. iScene += sizeof(void*) * pcNode->mNumChildren;
  902. for (unsigned int i = 0; i < pcNode->mNumChildren;++i) {
  903. AddNodeWeight(iScene,pcNode->mChildren[i]);
  904. }
  905. }
  906. // ------------------------------------------------------------------------------------------------
  907. // Get the memory requirements of the scene
  908. void Importer::GetMemoryRequirements(aiMemoryInfo& in) const
  909. {
  910. in = aiMemoryInfo();
  911. aiScene* mScene = pimpl->mScene;
  912. // return if we have no scene loaded
  913. if (!pimpl->mScene)
  914. return;
  915. in.total = sizeof(aiScene);
  916. // add all meshes
  917. for (unsigned int i = 0; i < mScene->mNumMeshes;++i)
  918. {
  919. in.meshes += sizeof(aiMesh);
  920. if (mScene->mMeshes[i]->HasPositions()) {
  921. in.meshes += sizeof(aiVector3D) * mScene->mMeshes[i]->mNumVertices;
  922. }
  923. if (mScene->mMeshes[i]->HasNormals()) {
  924. in.meshes += sizeof(aiVector3D) * mScene->mMeshes[i]->mNumVertices;
  925. }
  926. if (mScene->mMeshes[i]->HasTangentsAndBitangents()) {
  927. in.meshes += sizeof(aiVector3D) * mScene->mMeshes[i]->mNumVertices * 2;
  928. }
  929. for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_COLOR_SETS;++a) {
  930. if (mScene->mMeshes[i]->HasVertexColors(a)) {
  931. in.meshes += sizeof(aiColor4D) * mScene->mMeshes[i]->mNumVertices;
  932. }
  933. else break;
  934. }
  935. for (unsigned int a = 0; a < AI_MAX_NUMBER_OF_TEXTURECOORDS;++a) {
  936. if (mScene->mMeshes[i]->HasTextureCoords(a)) {
  937. in.meshes += sizeof(aiVector3D) * mScene->mMeshes[i]->mNumVertices;
  938. }
  939. else break;
  940. }
  941. if (mScene->mMeshes[i]->HasBones()) {
  942. in.meshes += sizeof(void*) * mScene->mMeshes[i]->mNumBones;
  943. for (unsigned int p = 0; p < mScene->mMeshes[i]->mNumBones;++p) {
  944. in.meshes += sizeof(aiBone);
  945. in.meshes += mScene->mMeshes[i]->mBones[p]->mNumWeights * sizeof(aiVertexWeight);
  946. }
  947. }
  948. in.meshes += (sizeof(aiFace) + 3 * sizeof(unsigned int))*mScene->mMeshes[i]->mNumFaces;
  949. }
  950. in.total += in.meshes;
  951. // add all embedded textures
  952. for (unsigned int i = 0; i < mScene->mNumTextures;++i) {
  953. const aiTexture* pc = mScene->mTextures[i];
  954. in.textures += sizeof(aiTexture);
  955. if (pc->mHeight) {
  956. in.textures += 4 * pc->mHeight * pc->mWidth;
  957. }
  958. else in.textures += pc->mWidth;
  959. }
  960. in.total += in.textures;
  961. // add all animations
  962. for (unsigned int i = 0; i < mScene->mNumAnimations;++i) {
  963. const aiAnimation* pc = mScene->mAnimations[i];
  964. in.animations += sizeof(aiAnimation);
  965. // add all bone anims
  966. for (unsigned int a = 0; a < pc->mNumChannels; ++a) {
  967. const aiNodeAnim* pc2 = pc->mChannels[i];
  968. in.animations += sizeof(aiNodeAnim);
  969. in.animations += pc2->mNumPositionKeys * sizeof(aiVectorKey);
  970. in.animations += pc2->mNumScalingKeys * sizeof(aiVectorKey);
  971. in.animations += pc2->mNumRotationKeys * sizeof(aiQuatKey);
  972. }
  973. }
  974. in.total += in.animations;
  975. // add all cameras and all lights
  976. in.total += in.cameras = sizeof(aiCamera) * mScene->mNumCameras;
  977. in.total += in.lights = sizeof(aiLight) * mScene->mNumLights;
  978. // add all nodes
  979. AddNodeWeight(in.nodes,mScene->mRootNode);
  980. in.total += in.nodes;
  981. // add all materials
  982. for (unsigned int i = 0; i < mScene->mNumMaterials;++i) {
  983. const aiMaterial* pc = mScene->mMaterials[i];
  984. in.materials += sizeof(aiMaterial);
  985. in.materials += pc->mNumAllocated * sizeof(void*);
  986. for (unsigned int a = 0; a < pc->mNumProperties;++a) {
  987. in.materials += pc->mProperties[a]->mDataLength;
  988. }
  989. }
  990. in.total += in.materials;
  991. }