Counter Strike : Global Offensive Source Code
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.

93 lines
2.2 KiB

  1. //--------------------------------------------------------------------------------------------------
  2. /**
  3. @file qhHalfEdge.h
  4. @author Dirk Gregorius
  5. @version 0.1
  6. @date 30/11/2011
  7. Copyright(C) 2011 by D. Gregorius. All rights reserved.
  8. */
  9. //--------------------------------------------------------------------------------------------------
  10. #pragma once
  11. #include "qhTypes.h"
  12. #include "qhMath.h"
  13. #include "qhList.h"
  14. struct qhVertex;
  15. struct qhHalfEdge;
  16. struct qhFace;
  17. #define QH_MARK_VISIBLE 0
  18. #define QH_MARK_DELETE 1
  19. #define QH_MARK_CONCAVE 2
  20. #define QH_MARK_CONFIRM 3
  21. //--------------------------------------------------------------------------------------------------
  22. // qhVertex
  23. //--------------------------------------------------------------------------------------------------
  24. struct qhVertex
  25. {
  26. qhVertex* Prev;
  27. qhVertex* Next;
  28. int Mark;
  29. qhVector3 Position;
  30. qhHalfEdge* Edge;
  31. qhFace* ConflictFace;
  32. };
  33. //--------------------------------------------------------------------------------------------------
  34. // qhHalfEdge
  35. //--------------------------------------------------------------------------------------------------
  36. struct qhHalfEdge
  37. {
  38. qhHalfEdge* Prev;
  39. qhHalfEdge* Next;
  40. qhVertex* Origin;
  41. qhFace* Face;
  42. qhHalfEdge* Twin;
  43. bool IsConvex( qhReal Tolerance ) const;
  44. };
  45. //--------------------------------------------------------------------------------------------------
  46. // qhFace
  47. //--------------------------------------------------------------------------------------------------
  48. struct qhFace
  49. {
  50. qhFace* Prev;
  51. qhFace* Next;
  52. qhHalfEdge* Edge;
  53. int Mark;
  54. qhReal Area;
  55. qhVector3 Centroid;
  56. qhPlane Plane;
  57. bool Flipped;
  58. qhList< qhVertex > ConflictList;
  59. };
  60. //--------------------------------------------------------------------------------------------------
  61. // Utilities
  62. //--------------------------------------------------------------------------------------------------
  63. void qhLinkFace( qhFace* Face, int Index, qhHalfEdge* Twin );
  64. void qhLinkFaces( qhFace* Face1, int Index1, qhFace* Face2, int Index2 );
  65. void qhNewellPlane( qhFace* Face );
  66. int qhVertexCount( const qhFace* Face );
  67. bool qhIsConvex( const qhFace* Face, qhReal Tolerance );
  68. bool qhCheckConsistency( const qhFace* Face );