dynamicphys.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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/dynamicphys.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 8/17/01 8:43p $*
  31. * *
  32. * $Revision:: 9 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #ifndef DYNAMICPHYS_H
  38. #define DYNAMICPHYS_H
  39. #include "always.h"
  40. #include "phys.h"
  41. class DynamicPhysDefClass;
  42. /**
  43. ** DynamicPhysClass
  44. ** This class adds some behavior that will be common to all dynamic physics objects. It tracks
  45. ** the current vis-ID for the object and has a method to automatically update it which should
  46. ** be called whenever the object moves. This class is not a concrete derived class.
  47. */
  48. class DynamicPhysClass : public PhysClass
  49. {
  50. public:
  51. DynamicPhysClass(void);
  52. ~DynamicPhysClass(void);
  53. virtual DynamicPhysClass * As_DynamicPhysClass(void) { return this; }
  54. void Init(const DynamicPhysDefClass & definition);
  55. virtual void Set_Model(RenderObjClass * model);
  56. /*
  57. ** Call this whenever the object moves to update its visibility status
  58. */
  59. void Update_Visibility_Status(void);
  60. virtual int Get_Vis_Object_ID(void);
  61. /*
  62. ** Simulation and rendering toggles for all dynamic physics objects
  63. */
  64. virtual bool Is_Simulation_Disabled(void) { return _DisableDynamicPhysSimulation; }
  65. virtual bool Is_Rendering_Disabled(void) { return _DisableDynamicPhysRendering; }
  66. static void Disable_All_Simulation(bool onoff) { _DisableDynamicPhysSimulation = onoff; }
  67. static void Disable_All_Rendering(bool onoff) { _DisableDynamicPhysRendering = onoff; }
  68. static bool Is_All_Simulation_Disabled(void) { return _DisableDynamicPhysSimulation; }
  69. static bool Is_All_Rendering_Disabled(void) { return _DisableDynamicPhysRendering; }
  70. /*
  71. ** Save-Load System
  72. */
  73. virtual bool Save (ChunkSaveClass &csave);
  74. virtual bool Load (ChunkLoadClass &cload);
  75. virtual void On_Post_Load(void);
  76. protected:
  77. void Internal_Update_Visibility_Status(void);
  78. bool DirtyVisObjectID; // dirty flag for the vis object id
  79. int VisNodeID; // ID of the node this object is in for temporal coherence
  80. unsigned int VisStatusLastUpdated; // tickcount of last vis update
  81. private:
  82. static bool _DisableDynamicPhysSimulation;
  83. static bool _DisableDynamicPhysRendering;
  84. /*
  85. ** Not implemented...
  86. */
  87. DynamicPhysClass(const DynamicPhysClass &);
  88. DynamicPhysClass & operator = (const DynamicPhysClass &);
  89. };
  90. /**
  91. ** DynamicPhysDefClass
  92. ** Definition data structure for DynamicPhysClass
  93. */
  94. class DynamicPhysDefClass : public PhysDefClass
  95. {
  96. public:
  97. DynamicPhysDefClass(void);
  98. // From PersistClass
  99. virtual bool Save(ChunkSaveClass &csave);
  100. virtual bool Load(ChunkLoadClass &cload);
  101. // From PhysDefClass
  102. virtual const char * Get_Type_Name(void) { return "DynamicPhysDef"; }
  103. virtual bool Is_Type(const char *);
  104. // Validation methods
  105. virtual bool Is_Valid_Config (StringClass &message);
  106. // Editable interface requirements
  107. DECLARE_EDITABLE(DynamicPhysDefClass,PhysDefClass);
  108. protected:
  109. friend class DynamicPhysClass;
  110. };
  111. #endif //DYNAMICPHYS_H