JoinVerticesProcess.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /** @file Defines a post processing step to join identical vertices on all imported meshes.*/
  2. #ifndef AI_JOINVERTICESPROCESS_H_INC
  3. #define AI_CALCTANGENTSPROCESS_H_INC
  4. #include "BaseProcess.h"
  5. #include "../include/aiTypes.h"
  6. struct aiMesh;
  7. namespace Assimp
  8. {
  9. // ---------------------------------------------------------------------------
  10. /** The JoinVerticesProcess unites identical vertices in all imported meshes.
  11. * By default the importer returns meshes where each face addressed its own
  12. * set of vertices even if that means that identical vertices are stored multiple
  13. * times. The JoinVerticesProcess finds these identical vertices and
  14. * erases all but one of the copies. This usually reduces the number of vertices
  15. * in a mesh by a serious amount and is the standard form to render a mesh.
  16. */
  17. class JoinVerticesProcess : public BaseProcess
  18. {
  19. friend class Importer;
  20. protected:
  21. /** Constructor to be privately used by Importer */
  22. JoinVerticesProcess();
  23. /** Destructor, private as well */
  24. ~JoinVerticesProcess();
  25. public:
  26. // -------------------------------------------------------------------
  27. /** Returns whether the processing step is present in the given flag field.
  28. * @param pFlags The processing flags the importer was called with. A bitwise
  29. * combination of #aiPostProcessSteps.
  30. * @return true if the process is present in this flag fields, false if not.
  31. */
  32. bool IsActive( unsigned int pFlags) const;
  33. // -------------------------------------------------------------------
  34. /** Executes the post processing step on the given imported data.
  35. * At the moment a process is not supposed to fail.
  36. * @param pScene The imported data to work at.
  37. */
  38. void Execute( aiScene* pScene);
  39. protected:
  40. // -------------------------------------------------------------------
  41. /** Unites identical vertices in the given mesh.
  42. * @param pMesh The mesh to process.
  43. */
  44. void ProcessMesh( aiMesh* pMesh);
  45. /** Little helper function to calculate the quadratic difference of two colours. */
  46. float GetColorDifference( const aiColor4D& pColor1, const aiColor4D& pColor2) const
  47. {
  48. aiColor4D c( pColor1.r - pColor2.r, pColor1.g - pColor2.g, pColor1.b - pColor2.b, pColor1.a - pColor2.a);
  49. return c.r*c.r + c.g*c.g + c.b*c.b + c.a*c.a;
  50. }
  51. };
  52. } // end of namespace Assimp
  53. #endif // AI_CALCTANGENTSPROCESS_H_INC