VisPointGenerator.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : LevelEdit *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/LevelEdit/VisPointGenerator.h $Modtime:: $*
  25. * *
  26. * $Revision:: 10 $*
  27. * *
  28. *---------------------------------------------------------------------------------------------*
  29. * Functions: *
  30. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  31. #if defined(_MSC_VER)
  32. #pragma once
  33. #endif
  34. #ifndef __VIS_POINT_GENERATOR_H
  35. #define __VIS_POINT_GENERATOR_H
  36. #include "vector.h"
  37. #include "vector3.h"
  38. #include "grid3d.h"
  39. #include "matrix3d.h"
  40. // Forward declarations
  41. class RenderObjClass;
  42. class MeshClass;
  43. class NodeClass;
  44. //////////////////////////////////////////////////////////////////////////
  45. //
  46. // Typdefs
  47. //
  48. //////////////////////////////////////////////////////////////////////////
  49. class VisPointListClass : public DynamicVectorClass<Matrix3D>
  50. {
  51. public:
  52. VisPointListClass (void)
  53. : DynamicVectorClass<Matrix3D> () {}
  54. virtual ~VisPointListClass (void) {}
  55. Matrix3D transform;
  56. Vector3 sample_point;
  57. };
  58. class VisPointInfo
  59. {
  60. public:
  61. VisPointInfo (void)
  62. : m_DoCameraRing (true),
  63. m_Transform (1) { }
  64. virtual ~VisPointInfo (void) { }
  65. Matrix3D m_Transform;
  66. bool m_DoCameraRing;
  67. };
  68. typedef DynamicVectorClass<VisPointListClass *> VIS_POINT_LIST;
  69. //////////////////////////////////////////////////////////////////////////
  70. //
  71. // VisPointGeneratorClass
  72. //
  73. //////////////////////////////////////////////////////////////////////////
  74. class VisPointGeneratorClass
  75. {
  76. public:
  77. ////////////////////////////////////////////////////////////////////
  78. // Public constructors/destructors
  79. ////////////////////////////////////////////////////////////////////
  80. VisPointGeneratorClass (float granularity = 16.0F);
  81. ~VisPointGeneratorClass (void);
  82. ////////////////////////////////////////////////////////////////////
  83. // Public methods
  84. ////////////////////////////////////////////////////////////////////
  85. void Submit_Mesh (MeshClass &mesh);
  86. VIS_POINT_LIST & Peek_Point_List (void) { return m_PointList; }
  87. ////////////////////////////////////////////////////////////////////
  88. // Public methods
  89. ////////////////////////////////////////////////////////////////////
  90. int Get_Polys_Processed (void) { return m_PolygonsProcessed; }
  91. int Get_Total_Points (void) { return m_TotalPoints; }
  92. void Set_Stats_Window (HWND hwnd) { m_StatWindow = hwnd; }
  93. // Node methods
  94. NodeClass * Peek_Current_Node (void) const { return m_CurrentNode; }
  95. void Set_Current_Node (NodeClass *node);
  96. void Post_Process_Nodes (void);
  97. void Add_Manual_Nodes (void);
  98. // Bias methods
  99. void Set_Ignore_Bias (bool onoff) { m_IgnoreBias = onoff; }
  100. // Sampling height control
  101. void Set_Vis_Sample_Height (float height) { m_VisSampleHeight = height; }
  102. float Get_Vis_Sample_Height (void) { return m_VisSampleHeight; }
  103. private:
  104. ////////////////////////////////////////////////////////////////////
  105. // Private methods
  106. ////////////////////////////////////////////////////////////////////
  107. void Subdivide_And_Submit_Centers(const Vector3 & point1,const Vector3 & point2,const Vector3 & point3);
  108. bool Find_Valid_Points (const Vector3 &start, const Vector3 &end, const Matrix3 &orientation, bool do_camera_ring);
  109. bool Submit_Point (const Matrix3D &vis_transform, bool do_camera_ring);
  110. void Generate_Camera_Locations (const Matrix3D &camera_tm);
  111. void Initialize_Camera_Sim (void);
  112. NodeClass *Find_Floor_Node (const Vector3 &start_point);
  113. bool Test_Camera_Sim_Point (const Vector3 &start_point, const Vector3 &end_point, Matrix3D *transform_result, NodeClass **node_result);
  114. // Point validation methods
  115. bool Do_View_Planes_Pass (const Matrix3D &vis_transform);
  116. bool Check_Ceiling (const Vector3 &position, float *ceiling_dist);
  117. bool Is_Object_Invalid_Roof (RenderObjClass *render_obj);
  118. // Grid methods
  119. bool Is_Grid_Cell_Empty (const Vector3 &position);
  120. // Misc
  121. void Determine_Granularity (MeshClass &mesh);
  122. ////////////////////////////////////////////////////////////////////
  123. // Private member data
  124. ////////////////////////////////////////////////////////////////////
  125. bool m_IgnoreBias;
  126. float m_Granularity;
  127. float m_BaseGranularity;
  128. VIS_POINT_LIST m_PointList;
  129. Grid3DClass<VisPointInfo *> m_Grid;
  130. Vector3 m_ViewPlaneExtent;
  131. // Current state information
  132. VisPointListClass * m_CurrentPointList;
  133. NodeClass * m_CurrentNode;
  134. float m_CurrentCeilingHeight;
  135. // Camera simulation variables
  136. int m_CameraSimPointCount;
  137. Vector3 * m_pCameraSimOffsets;
  138. // For conversion from world-space to grid-space
  139. Matrix3D m_WorldToGridTM;
  140. // Statistical information
  141. int m_PolygonsProcessed;
  142. int m_TotalPoints;
  143. HWND m_StatWindow;
  144. // How high above the sector to sample
  145. float m_VisSampleHeight;
  146. };
  147. #endif //__VIS_POINT_GENERATOR_H