renderobjectrecycler.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. ** Command & Conquer Generals(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 : ww3d *
  23. * *
  24. * $Archive:: /Commando/Code/ww3d2/renderobjectrecycler.h $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 5/08/01 3:52p $*
  31. * *
  32. * $Revision:: 1 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  37. #ifndef RENDEROBJECTRECYCLER_H
  38. #define RENDEROBJECTRECYCLER_H
  39. #include "always.h"
  40. #include "robjlist.h"
  41. class RenderObjClass;
  42. class Matrix3D;
  43. /**
  44. ** RenderObjectRecyclerClass
  45. ** This class can be used to eliminate dynamic render object allocation. An example usage would be
  46. ** the case where you have a projectile system in a game. Projectiles could be set up to use a
  47. ** variety of render objects and would be rapidly created and destroyed as the players and AI's fire
  48. ** their weapons. If all of your bullet objects request their models from a RenderObjectCache, and
  49. ** return their models to the cache when the bullet is destroyed; the model will get re-used by
  50. ** the next bullet that requests that same model type (highly likely in a game situation).
  51. **
  52. ** Public member functions:
  53. ** Reset - release all of the models in the cache.
  54. ** Get_Render_Object - returns either recycles a model or creates a new one through the asset manager
  55. ** Return_Render_Object - give your model back to the recycler for re-use later.
  56. */
  57. class RenderObjectRecyclerClass
  58. {
  59. public:
  60. void Reset(void);
  61. RenderObjClass* Get_Render_Object(const char * name,const Matrix3D & tm);
  62. void Return_Render_Object(RenderObjClass * obj);
  63. private:
  64. void Insert_Inactive_Model(RenderObjClass * obj);
  65. void Reset_Model(RenderObjClass * model);
  66. RefRenderObjListClass InactiveModels;
  67. };
  68. #endif //RENDEROBJECTRECYCLER_H