ProcessHelper.h 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. /*
  2. Open Asset Import Library (ASSIMP)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2008, ASSIMP Development Team
  5. All rights reserved.
  6. Redistribution and use of this software in source and binary forms,
  7. with or without modification, are permitted provided that the
  8. following conditions are met:
  9. * Redistributions of source code must retain the above
  10. copyright notice, this list of conditions and the
  11. following disclaimer.
  12. * Redistributions in binary form must reproduce the above
  13. copyright notice, this list of conditions and the
  14. following disclaimer in the documentation and/or other
  15. materials provided with the distribution.
  16. * Neither the name of the ASSIMP team, nor the names of its
  17. contributors may be used to endorse or promote products
  18. derived from this software without specific prior
  19. written permission of the ASSIMP Development Team.
  20. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  24. OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  25. SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  26. LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  27. DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  28. THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  29. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  30. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. ----------------------------------------------------------------------
  32. */
  33. #ifndef AI_PROCESS_HELPER_H_INCLUDED
  34. #define AI_PROCESS_HELPER_H_INCLUDED
  35. #include "../include/aiPostProcess.h"
  36. #include "SpatialSort.h"
  37. #include "BaseProcess.h"
  38. #include "ParsingUtils.h"
  39. // -------------------------------------------------------------------------------
  40. // Some extensions to std namespace. Mainly std::min and std::max for all
  41. // flat data types in the aiScene. They're used to quickly determine the
  42. // min/max bounds of data arrays.
  43. #ifdef __cplusplus
  44. namespace std {
  45. // std::min for aiVector3D
  46. inline ::aiVector3D min (const ::aiVector3D& a, const ::aiVector3D& b) {
  47. return ::aiVector3D (min(a.x,b.x),min(a.y,b.y),min(a.z,b.z));
  48. }
  49. // std::max for aiVector3D
  50. inline ::aiVector3D max (const ::aiVector3D& a, const ::aiVector3D& b) {
  51. return ::aiVector3D (max(a.x,b.x),max(a.y,b.y),max(a.z,b.z));
  52. }
  53. // std::min for aiColor4D
  54. inline ::aiColor4D min (const ::aiColor4D& a, const ::aiColor4D& b) {
  55. return ::aiColor4D (min(a.r,b.r),min(a.g,b.g),min(a.b,b.b),min(a.a,b.a));
  56. }
  57. // std::max for aiColor4D
  58. inline ::aiColor4D max (const ::aiColor4D& a, const ::aiColor4D& b) {
  59. return ::aiColor4D (max(a.r,b.r),max(a.g,b.g),max(a.b,b.b),max(a.a,b.a));
  60. }
  61. // std::min for aiQuaternion
  62. inline ::aiQuaternion min (const ::aiQuaternion& a, const ::aiQuaternion& b) {
  63. return ::aiQuaternion (min(a.w,b.w),min(a.x,b.x),min(a.y,b.y),min(a.z,b.z));
  64. }
  65. // std::max for aiQuaternion
  66. inline ::aiQuaternion max (const ::aiQuaternion& a, const ::aiQuaternion& b) {
  67. return ::aiQuaternion (max(a.w,b.w),max(a.x,b.x),max(a.y,b.y),max(a.z,b.z));
  68. }
  69. // std::min for aiVectorKey
  70. inline ::aiVectorKey min (const ::aiVectorKey& a, const ::aiVectorKey& b) {
  71. return ::aiVectorKey (min(a.mTime,b.mTime),min(a.mValue,b.mValue));
  72. }
  73. // std::max for aiVectorKey
  74. inline ::aiVectorKey max (const ::aiVectorKey& a, const ::aiVectorKey& b) {
  75. return ::aiVectorKey (max(a.mTime,b.mTime),max(a.mValue,b.mValue));
  76. }
  77. // std::min for aiQuatKey
  78. inline ::aiQuatKey min (const ::aiQuatKey& a, const ::aiQuatKey& b) {
  79. return ::aiQuatKey (min(a.mTime,b.mTime),min(a.mValue,b.mValue));
  80. }
  81. // std::max for aiQuatKey
  82. inline ::aiQuatKey max (const ::aiQuatKey& a, const ::aiQuatKey& b) {
  83. return ::aiQuatKey (max(a.mTime,b.mTime),max(a.mValue,b.mValue));
  84. }
  85. // std::min for aiVertexWeight
  86. inline ::aiVertexWeight min (const ::aiVertexWeight& a, const ::aiVertexWeight& b) {
  87. return ::aiVertexWeight (min(a.mVertexId,b.mVertexId),min(a.mWeight,b.mWeight));
  88. }
  89. // std::max for aiVertexWeight
  90. inline ::aiVertexWeight max (const ::aiVertexWeight& a, const ::aiVertexWeight& b) {
  91. return ::aiVertexWeight (max(a.mVertexId,b.mVertexId),max(a.mWeight,b.mWeight));
  92. }
  93. } // end namespace std
  94. #endif // !! C++
  95. namespace Assimp {
  96. // -------------------------------------------------------------------------------
  97. // Start points for ArrayBounds<T> for all supported Ts
  98. template <typename T>
  99. struct MinMaxChooser;
  100. template <> struct MinMaxChooser<float> {
  101. void operator ()(float& min,float& max) {
  102. max = -10e10f;
  103. min = 10e10f;
  104. }};
  105. template <> struct MinMaxChooser<double> {
  106. void operator ()(double& min,double& max) {
  107. max = -10e10;
  108. min = 10e10;
  109. }};
  110. template <> struct MinMaxChooser<unsigned int> {
  111. void operator ()(unsigned int& min,unsigned int& max) {
  112. max = 0;
  113. min = (1u<<(sizeof(unsigned int)*8-1));
  114. }};
  115. template <> struct MinMaxChooser<aiVector3D> {
  116. void operator ()(aiVector3D& min,aiVector3D& max) {
  117. max = aiVector3D(-10e10f,-10e10f,-10e10f);
  118. min = aiVector3D( 10e10f, 10e10f, 10e10f);
  119. }};
  120. template <> struct MinMaxChooser<aiColor4D> {
  121. void operator ()(aiColor4D& min,aiColor4D& max) {
  122. max = aiColor4D(-10e10f,-10e10f,-10e10f,-10e10f);
  123. min = aiColor4D( 10e10f, 10e10f, 10e10f, 10e10f);
  124. }};
  125. template <> struct MinMaxChooser<aiQuaternion> {
  126. void operator ()(aiQuaternion& min,aiQuaternion& max) {
  127. max = aiQuaternion(-10e10f,-10e10f,-10e10f,-10e10f);
  128. min = aiQuaternion( 10e10f, 10e10f, 10e10f, 10e10f);
  129. }};
  130. template <> struct MinMaxChooser<aiVectorKey> {
  131. void operator ()(aiVectorKey& min,aiVectorKey& max) {
  132. MinMaxChooser<double>()(min.mTime,max.mTime);
  133. MinMaxChooser<aiVector3D>()(min.mValue,max.mValue);
  134. }};
  135. template <> struct MinMaxChooser<aiQuatKey> {
  136. void operator ()(aiQuatKey& min,aiQuatKey& max) {
  137. MinMaxChooser<double>()(min.mTime,max.mTime);
  138. MinMaxChooser<aiQuaternion>()(min.mValue,max.mValue);
  139. }};
  140. template <> struct MinMaxChooser<aiVertexWeight> {
  141. void operator ()(aiVertexWeight& min,aiVertexWeight& max) {
  142. MinMaxChooser<unsigned int>()(min.mVertexId,max.mVertexId);
  143. MinMaxChooser<float>()(min.mWeight,max.mWeight);
  144. }};
  145. // -------------------------------------------------------------------------------
  146. /** @brief Find the min/max values of an array of Ts
  147. * @param in Input array
  148. * @param size Numebr of elements to process
  149. * @param[out] min minimum value
  150. * @param[out] max maximum value
  151. */
  152. template <typename T>
  153. inline void ArrayBounds(const T* in, unsigned int size, T& min, T& max)
  154. {
  155. MinMaxChooser<T> ()(min,max);
  156. for (unsigned int i = 0; i < size;++i) {
  157. min = std::min(in[i],min);
  158. max = std::max(in[i],max);
  159. }
  160. }
  161. // -------------------------------------------------------------------------------
  162. /** @brief Extract single strings from a list of identifiers
  163. * @param in Input string list.
  164. * @param out Receives a list of clean output strings
  165. * @sdee #AI_CONFIG_PP_OG_EXCLUDE_LIST
  166. */
  167. inline void ConvertListToStrings(const std::string& in, std::list<std::string>& out)
  168. {
  169. const char* s = in.c_str();
  170. while (*s) {
  171. SkipSpacesAndLineEnd(&s);
  172. if (*s == '\'') {
  173. const char* base = ++s;
  174. while (*s != '\'') {
  175. ++s;
  176. if (*s == '\0') {
  177. DefaultLogger::get()->error("ConvertListToString: String list is ill-formatted");
  178. return;
  179. }
  180. }
  181. out.push_back(std::string(base,(size_t)(s-base)));
  182. ++s;
  183. }
  184. else {
  185. out.push_back(GetNextToken(s));
  186. }
  187. }
  188. }
  189. // -------------------------------------------------------------------------------
  190. /** @brief Compute the newell normal of a polygon regardless of its shape
  191. *
  192. * @param out Receives the output normal
  193. * @param num Number of input vertices
  194. * @param x X data source. x[ofs_x*n] is the n'th element.
  195. * @param y Y data source. y[ofs_y*n] is the y'th element
  196. * @param z Z data source. z[ofs_z*n] is the z'th element
  197. *
  198. * @note The data arrays must have storage for at least num+2 elements. Using
  199. * this method is much faster than the 'other' NewellNormal()
  200. */
  201. template <int ofs_x, int ofs_y, int ofs_z>
  202. inline void NewellNormal (aiVector3D& out, int num, float* x, float* y, float* z)
  203. {
  204. // Duplicate the first two vertices at the end
  205. x[(num+0)*ofs_x] = x[0];
  206. x[(num+1)*ofs_x] = x[ofs_x];
  207. y[(num+0)*ofs_y] = y[0];
  208. y[(num+1)*ofs_y] = y[ofs_y];
  209. z[(num+0)*ofs_z] = z[0];
  210. z[(num+1)*ofs_z] = z[ofs_z];
  211. float sum_xy = 0.0, sum_yz = 0.0, sum_zx = 0.0;
  212. float *xptr = x +ofs_x, *xlow = x, *xhigh = x + ofs_x*2;
  213. float *yptr = y +ofs_y, *ylow = y, *yhigh = y + ofs_y*2;
  214. float *zptr = z +ofs_z, *zlow = z, *zhigh = z + ofs_z*2;
  215. for (int tmp=0; tmp < num; tmp++) {
  216. sum_xy += (*xptr) * ( (*yhigh) - (*ylow) );
  217. sum_yz += (*yptr) * ( (*zhigh) - (*zlow) );
  218. sum_zx += (*zptr) * ( (*xhigh) - (*xlow) );
  219. xptr += ofs_x;
  220. xlow += ofs_x;
  221. xhigh += ofs_x;
  222. yptr += ofs_y;
  223. ylow += ofs_y;
  224. yhigh += ofs_y;
  225. zptr += ofs_z;
  226. zlow += ofs_z;
  227. zhigh += ofs_z;
  228. }
  229. out = aiVector3D(sum_yz,sum_zx,sum_xy);
  230. }
  231. #if 0
  232. // -------------------------------------------------------------------------------
  233. /** @brief Compute newell normal of a polgon regardless of its shape
  234. *
  235. * @param out Receives the output normal
  236. * @param data Input vertices
  237. * @param idx Index buffer
  238. * @param num Number of indices
  239. */
  240. inline void NewellNormal (aiVector3D& out, const aiVector3D* data, unsigned int* idx, unsigned int num )
  241. {
  242. // TODO: intended to be used in GenNormals.
  243. }
  244. #endif
  245. // -------------------------------------------------------------------------------
  246. /** Little helper function to calculate the quadratic difference
  247. * of two colours.
  248. * @param pColor1 First color
  249. * @param pColor2 second color
  250. * @return Quadratic color difference
  251. */
  252. inline float GetColorDifference( const aiColor4D& pColor1, const aiColor4D& pColor2)
  253. {
  254. const aiColor4D c (pColor1.r - pColor2.r, pColor1.g - pColor2.g,
  255. pColor1.b - pColor2.b, pColor1.a - pColor2.a);
  256. return c.r*c.r + c.g*c.g + c.b*c.b + c.a*c.a;
  257. }
  258. // -------------------------------------------------------------------------------
  259. /** @brief Compute the AABB of a mesh after applying a given transform
  260. * @param mesh Input mesh
  261. * @param[out] min Receives minimum transformed vertex
  262. * @param[out] max Receives maximum transformed vertex
  263. * @param m Transformation matrix to be applied
  264. */
  265. inline void FindAABBTransformed (const aiMesh* mesh, aiVector3D& min, aiVector3D& max,
  266. const aiMatrix4x4& m)
  267. {
  268. min = aiVector3D (10e10f, 10e10f, 10e10f);
  269. max = aiVector3D (-10e10f,-10e10f,-10e10f);
  270. for (unsigned int i = 0;i < mesh->mNumVertices;++i)
  271. {
  272. const aiVector3D v = m * mesh->mVertices[i];
  273. min = std::min(v,min);
  274. max = std::max(v,max);
  275. }
  276. }
  277. // -------------------------------------------------------------------------------
  278. /** @brief Helper function to determine the 'real' center of a mesh
  279. *
  280. * That is the center of its axis-aligned bounding box.
  281. * @param mesh Input mesh
  282. * @param[out] min Minimum vertex of the mesh
  283. * @param[out] max maximum vertex of the mesh
  284. * @param[out] out Center point
  285. */
  286. inline void FindMeshCenter (aiMesh* mesh, aiVector3D& out, aiVector3D& min, aiVector3D& max)
  287. {
  288. ArrayBounds(mesh->mVertices,mesh->mNumVertices, min,max);
  289. out = min + (max-min)*0.5f;
  290. }
  291. // -------------------------------------------------------------------------------
  292. // Helper function to determine the 'real' center of a mesh after applying a given transform
  293. inline void FindMeshCenterTransformed (aiMesh* mesh, aiVector3D& out, aiVector3D& min,
  294. aiVector3D& max, const aiMatrix4x4& m)
  295. {
  296. FindAABBTransformed(mesh,min,max,m);
  297. out = min + (max-min)*0.5f;
  298. }
  299. // -------------------------------------------------------------------------------
  300. // Helper function to determine the 'real' center of a mesh
  301. inline void FindMeshCenter (aiMesh* mesh, aiVector3D& out)
  302. {
  303. aiVector3D min,max;
  304. FindMeshCenter(mesh,out,min,max);
  305. }
  306. // -------------------------------------------------------------------------------
  307. // Helper function to determine the 'real' center of a mesh after applying a given transform
  308. inline void FindMeshCenterTransformed (aiMesh* mesh, aiVector3D& out,
  309. const aiMatrix4x4& m)
  310. {
  311. aiVector3D min,max;
  312. FindMeshCenterTransformed(mesh,out,min,max,m);
  313. }
  314. // -------------------------------------------------------------------------------
  315. // Compute a good epsilon value for position comparisons on a mesh
  316. inline float ComputePositionEpsilon(const aiMesh* pMesh)
  317. {
  318. const float epsilon = 1e-4f;
  319. // calculate the position bounds so we have a reliable epsilon to check position differences against
  320. aiVector3D minVec, maxVec;
  321. ArrayBounds(pMesh->mVertices,pMesh->mNumVertices,minVec,maxVec);
  322. return (maxVec - minVec).Length() * epsilon;
  323. }
  324. // -------------------------------------------------------------------------------
  325. // Compute a good epsilon value for position comparisons on a array of meshes
  326. inline float ComputePositionEpsilon(const aiMesh* const* pMeshes, size_t num)
  327. {
  328. const float epsilon = 1e-4f;
  329. // calculate the position bounds so we have a reliable epsilon to check position differences against
  330. aiVector3D minVec, maxVec, mi, ma;
  331. MinMaxChooser<aiVector3D>()(minVec,maxVec);
  332. for (size_t a = 0; a < num; ++a) {
  333. const aiMesh* pMesh = pMeshes[a];
  334. ArrayBounds(pMesh->mVertices,pMesh->mNumVertices,mi,ma);
  335. minVec = std::min(minVec,mi);
  336. maxVec = std::max(maxVec,ma);
  337. }
  338. return (maxVec - minVec).Length() * epsilon;
  339. }
  340. // -------------------------------------------------------------------------------
  341. // Compute an unique value for the vertex format of a mesh
  342. inline unsigned int GetMeshVFormatUnique(aiMesh* pcMesh)
  343. {
  344. ai_assert(NULL != pcMesh);
  345. // FIX: the hash may never be 0. Otherwise a comparison against
  346. // nullptr could be successful
  347. unsigned int iRet = 1;
  348. // normals
  349. if (pcMesh->HasNormals())iRet |= 0x2;
  350. // tangents and bitangents
  351. if (pcMesh->HasTangentsAndBitangents())iRet |= 0x4;
  352. #ifdef BOOST_STATIC_ASSERT
  353. BOOST_STATIC_ASSERT(8 >= AI_MAX_NUMBER_OF_COLOR_SETS);
  354. BOOST_STATIC_ASSERT(8 >= AI_MAX_NUMBER_OF_TEXTURECOORDS);
  355. #endif
  356. // texture coordinates
  357. unsigned int p = 0;
  358. while (pcMesh->HasTextureCoords(p))
  359. {
  360. iRet |= (0x100 << p);
  361. if (3 == pcMesh->mNumUVComponents[p])
  362. iRet |= (0x10000 << p);
  363. ++p;
  364. }
  365. // vertex colors
  366. p = 0;
  367. while (pcMesh->HasVertexColors(p))iRet |= (0x1000000 << p++);
  368. return iRet;
  369. }
  370. typedef std::pair <unsigned int,float> PerVertexWeight;
  371. typedef std::vector <PerVertexWeight> VertexWeightTable;
  372. // -------------------------------------------------------------------------------
  373. // Compute a per-vertex bone weight table
  374. // please .... delete result with operator delete[] ...
  375. inline VertexWeightTable* ComputeVertexBoneWeightTable(aiMesh* pMesh)
  376. {
  377. if (!pMesh || !pMesh->mNumVertices || !pMesh->mNumBones)
  378. return NULL;
  379. VertexWeightTable* avPerVertexWeights = new VertexWeightTable[pMesh->mNumVertices];
  380. for (unsigned int i = 0; i < pMesh->mNumBones;++i)
  381. {
  382. aiBone* bone = pMesh->mBones[i];
  383. for (unsigned int a = 0; a < bone->mNumWeights;++a) {
  384. const aiVertexWeight& weight = bone->mWeights[a];
  385. avPerVertexWeights[weight.mVertexId].push_back(
  386. std::pair<unsigned int,float>(i,weight.mWeight));
  387. }
  388. }
  389. return avPerVertexWeights;
  390. }
  391. // -------------------------------------------------------------------------------
  392. // Get a string for a given aiTextureType
  393. inline const char* TextureTypeToString(aiTextureType in)
  394. {
  395. switch (in)
  396. {
  397. case aiTextureType_NONE:
  398. return "n/a";
  399. case aiTextureType_DIFFUSE:
  400. return "Diffuse";
  401. case aiTextureType_SPECULAR:
  402. return "Specular";
  403. case aiTextureType_AMBIENT:
  404. return "Ambient";
  405. case aiTextureType_EMISSIVE:
  406. return "Emissive";
  407. case aiTextureType_OPACITY:
  408. return "Opacity";
  409. case aiTextureType_NORMALS:
  410. return "Normals";
  411. case aiTextureType_HEIGHT:
  412. return "Height";
  413. case aiTextureType_SHININESS:
  414. return "Shininess";
  415. case aiTextureType_DISPLACEMENT:
  416. return "Displacement";
  417. case aiTextureType_LIGHTMAP:
  418. return "Lightmap";
  419. case aiTextureType_REFLECTION:
  420. return "Reflection";
  421. case aiTextureType_UNKNOWN:
  422. return "Unknown";
  423. default:
  424. return "HUGE ERROR. Expect BSOD (linux guys: kernel panic ...).";
  425. }
  426. }
  427. // -------------------------------------------------------------------------------
  428. // Get a string for a given aiTextureMapping
  429. inline const char* MappingTypeToString(aiTextureMapping in)
  430. {
  431. switch (in)
  432. {
  433. case aiTextureMapping_UV:
  434. return "UV";
  435. case aiTextureMapping_BOX:
  436. return "Box";
  437. case aiTextureMapping_SPHERE:
  438. return "Sphere";
  439. case aiTextureMapping_CYLINDER:
  440. return "Cylinder";
  441. case aiTextureMapping_PLANE:
  442. return "Plane";
  443. case aiTextureMapping_OTHER:
  444. return "Other";
  445. default:
  446. return "HUGE ERROR. Expect BSOD (linux guys: kernel panic ...).";
  447. }
  448. }
  449. // -------------------------------------------------------------------------------
  450. // Utility postprocess step to share the spatial sort tree between
  451. // all steps which use it to speedup its computations.
  452. class ComputeSpatialSortProcess : public BaseProcess
  453. {
  454. bool IsActive( unsigned int pFlags) const
  455. {
  456. return NULL != shared && 0 != (pFlags & (aiProcess_CalcTangentSpace |
  457. aiProcess_GenNormals | aiProcess_JoinIdenticalVertices));
  458. }
  459. void Execute( aiScene* pScene)
  460. {
  461. typedef std::pair<SpatialSort, float> _Type;
  462. std::vector<_Type>* p = new std::vector<_Type>(pScene->mNumMeshes);
  463. std::vector<_Type>::iterator it = p->begin();
  464. for (unsigned int i = 0; i < pScene->mNumMeshes; ++i, ++it) {
  465. aiMesh* mesh = pScene->mMeshes[i];
  466. _Type& blubb = *it;
  467. blubb.first.Fill(mesh->mVertices,mesh->mNumVertices,sizeof(aiVector3D));
  468. blubb.second = ComputePositionEpsilon(mesh);
  469. }
  470. shared->AddProperty(AI_SPP_SPATIAL_SORT,p);
  471. }
  472. };
  473. // -------------------------------------------------------------------------------
  474. // ... and the same again to cleanup the whole stuff
  475. class DestroySpatialSortProcess : public BaseProcess
  476. {
  477. bool IsActive( unsigned int pFlags) const
  478. {
  479. return NULL != shared && 0 != (pFlags & (aiProcess_CalcTangentSpace |
  480. aiProcess_GenNormals | aiProcess_JoinIdenticalVertices));
  481. }
  482. void Execute( aiScene* pScene)
  483. {
  484. shared->RemoveProperty(AI_SPP_SPATIAL_SORT);
  485. }
  486. };
  487. } // ! namespace Assimp
  488. #endif // !! AI_PROCESS_HELPER_H_INCLUDED