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.

92 lines
2.4 KiB

  1. //--------------------------------------------------------------------------------------------------
  2. // qhConvex.inl
  3. //
  4. // Copyright(C) 2011 by D. Gregorius. All rights reserved.
  5. //--------------------------------------------------------------------------------------------------
  6. //--------------------------------------------------------------------------------------------------
  7. // qhConvex
  8. //--------------------------------------------------------------------------------------------------
  9. inline qhVector3 qhConvex::GetCentroid( void ) const
  10. {
  11. qhVector3 Centroid = QH_VEC3_ZERO;
  12. if ( !mVertexList.Empty() )
  13. {
  14. int VertexCount = 0;
  15. for ( const qhVertex* Vertex = mVertexList.Begin(); Vertex != mVertexList.End(); Vertex = Vertex->Next )
  16. {
  17. Centroid += Vertex->Position;
  18. VertexCount++;
  19. }
  20. Centroid /= qhReal( VertexCount );
  21. }
  22. return Centroid;
  23. }
  24. //--------------------------------------------------------------------------------------------------
  25. inline int qhConvex::GetVertexCount( void ) const
  26. {
  27. return mVertexList.Size();
  28. }
  29. //--------------------------------------------------------------------------------------------------
  30. inline int qhConvex::GetEdgeCount( void ) const
  31. {
  32. int Count = 0;
  33. for ( const qhFace* Face = mFaceList.Begin(); Face != mFaceList.End(); Face = Face->Next )
  34. {
  35. qhHalfEdge* Edge = Face->Edge;
  36. QH_ASSERT( Edge != NULL );
  37. do
  38. {
  39. Count += 1;
  40. Edge = Edge->Next;
  41. }
  42. while ( Edge != Face->Edge );
  43. }
  44. return Count;
  45. }
  46. //--------------------------------------------------------------------------------------------------
  47. inline int qhConvex::GetFaceCount( void ) const
  48. {
  49. return mFaceList.Size();
  50. }
  51. //--------------------------------------------------------------------------------------------------
  52. inline const qhList< qhVertex >& qhConvex::GetVertexList( void ) const
  53. {
  54. return mVertexList;
  55. }
  56. //--------------------------------------------------------------------------------------------------
  57. inline const qhList< qhFace >& qhConvex::GetFaceList( void ) const
  58. {
  59. return mFaceList;
  60. }
  61. //--------------------------------------------------------------------------------------------------
  62. inline int qhConvex::GetIterationCount( void ) const
  63. {
  64. return mIterations.Size();
  65. }
  66. //--------------------------------------------------------------------------------------------------
  67. inline const qhIteration& qhConvex::GetIteration( int i ) const
  68. {
  69. return mIterations[ i ];
  70. }