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.

195 lines
6.4 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. #ifndef DISPNODE_H
  8. #define DISPNODE_H
  9. #ifdef _WIN32
  10. #pragma once
  11. #endif
  12. //=========== (C) Copyright 2000 Valve, L.L.C. All rights reserved. ===========
  13. //
  14. // The copyright to the contents herein is the property of Valve, L.L.C.
  15. // The contents may be used and/or copied only with the written permission of
  16. // Valve, L.L.C., or in accordance with the terms and conditions stipulated in
  17. // the agreement/contract under which the contents have been supplied.
  18. //
  19. // $Revision: $
  20. // $NoKeywords: $
  21. //=============================================================================
  22. //=============================================================================
  23. //
  24. // Displacement Node Class
  25. //
  26. // "Neighbor Nodes" "Node Vert Indices"
  27. // 1 6----1----7
  28. // | | \ | / |
  29. // 0 --+-- 2 | \|/ | "Corner {SW, SE, NW, NE} : {4, 5, 6, 7}"
  30. // | 0 -Orig-- 2
  31. // 3 | /|\ | "Edge {W, N, E, S} : {0, 1, 2, 3}"
  32. // | / | \ |
  33. // 4----3----5
  34. //
  35. class CDispNode
  36. {
  37. public:
  38. enum{ W = 0, N, E, S, SW, SE, NW, NE };
  39. //=========================================================================
  40. //
  41. // Construction/Decontruction
  42. //
  43. CDispNode() {};
  44. ~CDispNode() {};
  45. //=========================================================================
  46. //
  47. //
  48. //
  49. inline void SetBoundingBox( const Vector& bbMin, const Vector& bbMax );
  50. inline void GetBoundingBox( Vector& bbMin, Vector& bbMax );
  51. inline void SetErrorTerm( float error );
  52. inline float GetErrorTerm( void );
  53. inline void SetNeighborNodeIndex( int direction, int nodeIndex );
  54. inline int GetNeighborNodeIndex( int direction );
  55. inline void SetOrigVertexIndex( int vertIndex );
  56. inline int GetOrigVertexIndex( void );
  57. inline void SetVertexIndex( int direction, int vertIndex );
  58. inline int GetVertexIndex( int direction );
  59. inline void SetTouched( bool bTouched );
  60. inline bool IsTouched( void );
  61. inline void SetActivity( bool bActive );
  62. inline bool IsActive( void );
  63. private:
  64. Vector m_BBox[2]; // axial-aligned bounding box
  65. float m_ErrorTerm; // LOD error term
  66. int m_NeighborNodeIndices[4]; // neighbor node indices
  67. int m_OrigVertIndex; // origin vertex index
  68. int m_VertIndices[8]; // neighboring vertex indices
  69. bool m_bTouched; // "touched" flag
  70. bool m_bActive; // "active" flag -- rendering
  71. };
  72. //-----------------------------------------------------------------------------
  73. //-----------------------------------------------------------------------------
  74. inline void CDispNode::SetBoundingBox( const Vector& bbMin, const Vector& bbMax )
  75. {
  76. VectorCopy( bbMin, m_BBox[0] );
  77. VectorCopy( bbMax, m_BBox[1] );
  78. }
  79. //-----------------------------------------------------------------------------
  80. //-----------------------------------------------------------------------------
  81. inline void CDispNode::GetBoundingBox( Vector& bbMin, Vector& bbMax )
  82. {
  83. VectorCopy( m_BBox[0], bbMin );
  84. VectorCopy( m_BBox[1], bbMax );
  85. }
  86. //-----------------------------------------------------------------------------
  87. //-----------------------------------------------------------------------------
  88. inline void CDispNode::SetErrorTerm( float error )
  89. {
  90. m_ErrorTerm = error;
  91. }
  92. //-----------------------------------------------------------------------------
  93. //-----------------------------------------------------------------------------
  94. inline float CDispNode::GetErrorTerm( void )
  95. {
  96. return m_ErrorTerm;
  97. }
  98. //-----------------------------------------------------------------------------
  99. //-----------------------------------------------------------------------------
  100. inline void CDispNode::SetNeighborNodeIndex( int direction, int nodeIndex )
  101. {
  102. m_NeighborNodeIndices[direction] = nodeIndex;
  103. }
  104. //-----------------------------------------------------------------------------
  105. //-----------------------------------------------------------------------------
  106. inline int CDispNode::GetNeighborNodeIndex( int direction )
  107. {
  108. return m_NeighborNodeIndices[direction];
  109. }
  110. //-----------------------------------------------------------------------------
  111. //-----------------------------------------------------------------------------
  112. inline void CDispNode::SetOrigVertexIndex( int vertIndex )
  113. {
  114. m_OrigVertIndex = vertIndex;
  115. }
  116. //-----------------------------------------------------------------------------
  117. //-----------------------------------------------------------------------------
  118. inline int CDispNode::GetOrigVertexIndex( void )
  119. {
  120. return m_OrigVertIndex;
  121. }
  122. //-----------------------------------------------------------------------------
  123. //-----------------------------------------------------------------------------
  124. inline void CDispNode::SetVertexIndex( int direction, int vertIndex )
  125. {
  126. m_VertIndices[direction] = vertIndex;
  127. }
  128. //-----------------------------------------------------------------------------
  129. //-----------------------------------------------------------------------------
  130. inline int CDispNode::GetVertexIndex( int direction )
  131. {
  132. return m_VertIndices[direction];
  133. }
  134. //-----------------------------------------------------------------------------
  135. //-----------------------------------------------------------------------------
  136. inline void CDispNode::SetTouched( bool bTouched )
  137. {
  138. m_bTouched = bTouched;
  139. }
  140. //-----------------------------------------------------------------------------
  141. //-----------------------------------------------------------------------------
  142. inline bool CDispNode::IsTouched( void )
  143. {
  144. return m_bTouched;
  145. }
  146. //-----------------------------------------------------------------------------
  147. //-----------------------------------------------------------------------------
  148. inline void CDispNode::SetActivity( bool bActive )
  149. {
  150. m_bActive = bActive;
  151. }
  152. //-----------------------------------------------------------------------------
  153. //-----------------------------------------------------------------------------
  154. inline bool CDispNode::IsActive( void )
  155. {
  156. return m_bActive;
  157. }
  158. #endif // DISPNODE_H