Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

58 lines
2.7 KiB

  1. //============ Copyright (c) Valve Corporation, All rights reserved. ==========
  2. //
  3. //=============================================================================
  4. #pragma once
  5. //-----------------------------------------------------------------------------
  6. //
  7. //-----------------------------------------------------------------------------
  8. class CCheckUVCmd
  9. {
  10. public:
  11. int m_nOptGutterTexWidth; // Width of texture for gutter check
  12. int m_nOptGutterTexHeight; // Height of texture for gutter check
  13. int m_nOptGutterMin; // Minimum number of pixels between polygon islands in UV space
  14. enum CheckMask_t
  15. {
  16. CHECK_UV_FLAG_NORMALIZED = ( 1 << 0 ),
  17. CHECK_UV_FLAG_OVERLAP = ( 1 << 1 ),
  18. CHECK_UV_FLAG_INVERSE = ( 1 << 2 ),
  19. CHECK_UV_FLAG_GUTTER = ( 1 << 3 ),
  20. CHECK_UV_ALL_FLAGS = ( CHECK_UV_FLAG_NORMALIZED | CHECK_UV_FLAG_OVERLAP | CHECK_UV_FLAG_INVERSE | CHECK_UV_FLAG_GUTTER )
  21. };
  22. int m_nOptChecks;
  23. CCheckUVCmd();
  24. void Clear();
  25. bool DoCheck( CheckMask_t eCheckMask ) const { return ( m_nOptChecks & eCheckMask ) == eCheckMask; }
  26. bool DoAnyCheck() const { return ( m_nOptChecks & CHECK_UV_ALL_FLAGS ) != 0; }
  27. void SetCheck( CheckMask_t eCheckMask ) { m_nOptChecks |= ( CHECK_UV_ALL_FLAGS & eCheckMask ); }
  28. void ClearCheck( CheckMask_t eCheckMask ) { m_nOptChecks &= ( CHECK_UV_ALL_FLAGS & ~eCheckMask ); }
  29. bool CheckUVs( const struct s_source_t *const *pSourceList, int nSourceCount ) const;
  30. // Check that all UVs are in the [0, 1] range
  31. bool CheckNormalized( const struct s_source_t *pSource ) const;
  32. // Check that all polygons in UV do not overlap
  33. bool CheckOverlap( const struct s_source_t *pSource ) const;
  34. // Check that all polygons in UV have the correct winding, i.e. the cross
  35. // product of edge AB x BC points the right direction
  36. bool CheckInverse( const struct s_source_t *pSource ) const;
  37. // Check that the distance between edges in UV islands is a minimum number of pixels for a given texture size
  38. bool CheckGutter( const struct s_source_t *pSource ) const;
  39. // Returns barycentric coordinates Vector( u, v, w ) for point vP with respect to triangle ( vA, vB, vC )
  40. static Vector Barycentric( const Vector2D &vP, const Vector2D &vA, const Vector2D &vB, const Vector2D &vC );
  41. static Vector Barycentric( const Vector &vP, const Vector &vA, const Vector &vB, const Vector &vC );
  42. static int FindMeshIndex( const struct s_source_t *pSource, int nFaceIndex );
  43. static void PrintVertex( const struct s_vertexinfo_t &v, const char *pszPrefix = " " );
  44. static void PrintVertex( const struct s_vertexinfo_t &v, const struct s_texture_t &t, const char *pszPrefix = " " );
  45. static void PrintFace( const s_source_t *pSource, const int nMesh, const int nFace, const char *pszPrefix = " " );
  46. };