VisGenProgress.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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/VisGenProgress.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 7/16/00 1:59p $*
  31. * *
  32. * $Revision:: 2 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #ifndef VISGENPROGRESS_H
  38. #define VISGENPROGRESS_H
  39. #include "always.h"
  40. /**
  41. ** VisGenProgressClass
  42. ** This class encapsulates the progress of a vis generation process.
  43. ** During the process, an external thread can read the status of the variables
  44. ** in this object to update a dialog box.
  45. */
  46. class VisGenProgressClass
  47. {
  48. public:
  49. VisGenProgressClass(void);
  50. int Get_Node_Count(void) { return NodeCount; }
  51. int Get_Processed_Node_Count(void) { return ProcessedNodeCount; }
  52. int Get_Total_Edge_Count(void) { return TotalEdgeCount; }
  53. int Get_Total_Sample_Count(void) { return TotalSampleCount; }
  54. int Get_Current_Node_Edge_Count(void) { return CurrentNodeEdgeCount; }
  55. int Get_Current_Node_Sample_Count(void) { return CurrentNodeSampleCount; }
  56. float Get_Average_Samples_Per_Node(void);
  57. void Set_Node_Count(int count) { NodeCount = count; }
  58. void Increment_Processed_Node_Count(void) { ProcessedNodeCount++; CurrentNodeEdgeCount = CurrentNodeSampleCount = 0; }
  59. void Increment_Edge_Count(void) { TotalEdgeCount++; CurrentNodeEdgeCount++; }
  60. void Increment_Sample_Count(void) { TotalSampleCount++; CurrentNodeSampleCount++; }
  61. void Request_Cancel(void) { CancelRequested = true; }
  62. bool Is_Cancel_Requested(void) { return CancelRequested; }
  63. protected:
  64. int NodeCount;
  65. int ProcessedNodeCount;
  66. int TotalEdgeCount;
  67. int TotalSampleCount;
  68. int CurrentNodeEdgeCount;
  69. int CurrentNodeSampleCount;
  70. bool CancelRequested;
  71. };
  72. inline VisGenProgressClass::VisGenProgressClass(void) :
  73. NodeCount(0),
  74. ProcessedNodeCount(0),
  75. TotalEdgeCount(0),
  76. TotalSampleCount(0),
  77. CurrentNodeEdgeCount(0),
  78. CurrentNodeSampleCount(0),
  79. CancelRequested(false)
  80. {
  81. }
  82. inline float VisGenProgressClass::Get_Average_Samples_Per_Node(void)
  83. {
  84. if (ProcessedNodeCount > 0) {
  85. return (float)TotalSampleCount / (float)ProcessedNodeCount;
  86. } else {
  87. return 0.0f;
  88. }
  89. }
  90. #endif //VISGENPROGRESS_H