25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 
 

136 satır
4.5 KiB

  1. /*
  2. Open Asset Import Library (assimp)
  3. ----------------------------------------------------------------------
  4. Copyright (c) 2006-2012, assimp 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 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. /** @file FindInstancesProcess.h
  34. * @brief Declares the aiProcess_FindInstances post-process step
  35. */
  36. #ifndef AI_FINDINSTANCES_H_INC
  37. #define AI_FINDINSTANCES_H_INC
  38. #include "BaseProcess.h"
  39. #include "ProcessHelper.h"
  40. class FindInstancesProcessTest;
  41. namespace Assimp {
  42. // -------------------------------------------------------------------------------
  43. /** @brief Get a pseudo(!)-hash representing a mesh.
  44. *
  45. * The hash is built from number of vertices, faces, primitive types,
  46. * .... but *not* from the real mesh data. The funcction is not a perfect hash.
  47. * @param in Input mesh
  48. * @return Hash.
  49. */
  50. inline uint64_t GetMeshHash(aiMesh* in)
  51. {
  52. ai_assert(NULL != in);
  53. // ... get an unique value representing the vertex format of the mesh
  54. const unsigned int fhash = GetMeshVFormatUnique(in);
  55. // and bake it with number of vertices/faces/bones/matidx/ptypes
  56. return ((uint64_t)fhash << 32u) | ((
  57. (in->mNumBones << 16u) ^ (in->mNumVertices) ^
  58. (in->mNumFaces<<4u) ^ (in->mMaterialIndex<<15) ^
  59. (in->mPrimitiveTypes<<28)) & 0xffffffff );
  60. }
  61. // -------------------------------------------------------------------------------
  62. /** @brief Perform a component-wise comparison of two arrays
  63. *
  64. * @param first First array
  65. * @param second Second aray
  66. * @param size Size of both arrays
  67. * @param e Epsilon
  68. * @return true if the arrays are identical
  69. */
  70. inline bool CompareArrays(const aiVector3D* first, const aiVector3D* second,
  71. unsigned int size, float e)
  72. {
  73. for (const aiVector3D* end = first+size; first != end; ++first,++second) {
  74. if ( (*first - *second).SquareLength() >= e)
  75. return false;
  76. }
  77. return true;
  78. }
  79. // and the same for colors ...
  80. inline bool CompareArrays(const aiColor4D* first, const aiColor4D* second,
  81. unsigned int size, float e)
  82. {
  83. for (const aiColor4D* end = first+size; first != end; ++first,++second) {
  84. if ( GetColorDifference(*first,*second) >= e)
  85. return false;
  86. }
  87. return true;
  88. }
  89. // ---------------------------------------------------------------------------
  90. /** @brief A post-processing steps to search for instanced meshes
  91. */
  92. class FindInstancesProcess : public BaseProcess
  93. {
  94. public:
  95. FindInstancesProcess();
  96. ~FindInstancesProcess();
  97. public:
  98. // -------------------------------------------------------------------
  99. // Check whether step is active in given flags combination
  100. bool IsActive( unsigned int pFlags) const;
  101. // -------------------------------------------------------------------
  102. // Execute step on a given scene
  103. void Execute( aiScene* pScene);
  104. // -------------------------------------------------------------------
  105. // Setup properties prior to executing the process
  106. void SetupProperties(const Importer* pImp);
  107. private:
  108. bool configSpeedFlag;
  109. }; // ! end class FindInstancesProcess
  110. } // ! end namespace Assimp
  111. #endif // !! AI_FINDINSTANCES_H_INC