visoptimizationcontext.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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 : WWPhys *
  23. * *
  24. * $Archive:: /Commando/Code/wwphys/visoptimizationcontext.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 8/04/00 6:32p $*
  31. * *
  32. * $Revision:: 4 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #ifndef VISOPTIMIZATIONCONTEXT_H
  38. #define VISOPTIMIZATIONCONTEXT_H
  39. #include "always.h"
  40. #include "vector.h"
  41. class PhysicsSceneClass;
  42. class VisTableMgrClass;
  43. class VisTableClass;
  44. class VisOptProgressClass;
  45. class DynamicAABTreeCullClass;
  46. /**
  47. ** VisOptimizationContextClass
  48. ** This class encapsulates information needed to optimize the precalculated visibility data
  49. ** for a level. It is passed into the dynamic culling system for pruning the useless leaf
  50. ** nodes. It also performs merging of both sector and object ids.
  51. */
  52. class VisOptimizationContextClass
  53. {
  54. public:
  55. VisOptimizationContextClass(PhysicsSceneClass * scene,VisOptProgressClass & stats);
  56. ~VisOptimizationContextClass(void);
  57. void Optimize(VisTableMgrClass * vismgr,DynamicAABTreeCullClass * dyn_obj_tree);
  58. VisOptProgressClass & Get_Progress_Object(void);
  59. float Compute_Sector_Table_Match_Fraction(int sector_id_0,int sector_id_1);
  60. float Compute_Object_Table_Match_Fraction(int object_id_0,int object_id_1);
  61. void Combine_Sector_Tables(int sector_id_0,int sector_id_1);
  62. void Combine_Object_Tables(int object_id_0,int object_id_1);
  63. int Get_Vis_Sector_Count(void);
  64. int Get_Vis_Object_Count(void);
  65. void Set_Dyn_Cell_Prune_Match_Fraction(float frac) { if ((frac >= 0.0f) && (frac <= 1.0f)) MinDynCellPruneMatchFraction = frac; }
  66. void Set_Vis_Object_Match_Fraction(float frac) { if ((frac >= 0.0f) && (frac <= 1.0f)) MinVisObjectMatchFraction = frac; }
  67. void Set_Vis_Sector_Match_Fraction(float frac) { if ((frac >= 0.0f) && (frac <= 1.0f)) MinVisSectorMatchFraction = frac; }
  68. float Get_Dyn_Cell_Prune_Match_Fraction(void) { return MinDynCellPruneMatchFraction; }
  69. float Get_Vis_Object_Match_Fraction(void) { return MinVisObjectMatchFraction; }
  70. float Get_Vis_Sector_Match_Fraction(void) { return MinVisSectorMatchFraction; }
  71. protected:
  72. void Build_Object_Tables(VisTableMgrClass * vismgr);
  73. void Combine_Redundant_Objects(void);
  74. void Build_Sector_Tables_From_Object_Tables(VisTableMgrClass * vismgr);
  75. void Combine_Redundant_Sectors(void);
  76. void Install_Results(VisTableMgrClass * vismgr);
  77. PhysicsSceneClass * Scene;
  78. struct PVSInfoStruct
  79. {
  80. PVSInfoStruct(void);
  81. ~PVSInfoStruct(void);
  82. const PVSInfoStruct & operator = (const PVSInfoStruct & that);
  83. bool operator == (const PVSInfoStruct & that) { return false; }
  84. bool operator != (const PVSInfoStruct & that) { return true; }
  85. VisTableClass * Table;
  86. bool UnUsed;
  87. };
  88. float MinDynCellPruneMatchFraction;
  89. float MinVisObjectMatchFraction;
  90. float MinVisSectorMatchFraction;
  91. DynamicVectorClass<PVSInfoStruct> SectorTables; // PVS and info for each sector
  92. DynamicVectorClass<PVSInfoStruct> ObjectTables; // Sector visibility and info for each object
  93. VisOptProgressClass & Stats; // Progress and statistics tracker object.
  94. };
  95. #endif //VISOPTIMIZATIONCONTEXT_H