widgetuser.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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/widgetuser.h $*
  25. * *
  26. * Author:: Greg Hjelstrom *
  27. * *
  28. * $Modtime:: 10/11/01 2:26p $*
  29. * *
  30. * $Revision:: 5 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef WIDGETUSER_H
  39. #define WIDGETUSER_H
  40. class Vector3;
  41. class Matrix3D;
  42. class AABoxClass;
  43. class OBBoxClass;
  44. class RenderInfoClass;
  45. class WidgetRenderOpClass;
  46. /**
  47. ** WidgetUserClass
  48. ** This class contains the functions needed to embed a list of debug widgets into
  49. ** a class. Just call Render_Debug_Widgets inside of your class's render function.
  50. ** It is important that all of the runtime cost of using this system goes away in
  51. ** a release build. When you derive a class from this class, if you are overriding
  52. ** the Add_xxx methods bracket your implementations and declarations with #ifdef WWDEBUG
  53. **
  54. ** Notes:
  55. ** Most of my current uses for this class are for "transient" things so I reset the list each
  56. ** time I render. In addition, I override the 'Add' functions and add filters which
  57. ** check if debugging for that particular system is turned on. Use the macros below the
  58. ** class definition so that all of your calls automatically disappear in the release build.
  59. */
  60. class WidgetUserClass
  61. {
  62. public:
  63. WidgetUserClass(void);
  64. ~WidgetUserClass(void);
  65. /*
  66. ** Debug rendering of vectors, points, boxes, etc etc. Each frame, these objects
  67. ** will be rendered during PhysClass::Render and then deleted.
  68. */
  69. #ifdef WWDEBUG
  70. void Reset_Debug_Widget_List(void);
  71. virtual void Add_Debug_Point(const Vector3 & p,const Vector3 & color);
  72. virtual void Add_Debug_Vector(const Vector3 & p,const Vector3 & v,const Vector3 & color);
  73. virtual void Add_Debug_AABox(const AABoxClass & box,const Vector3 & color,float opacity = 0.25f);
  74. virtual void Add_Debug_OBBox(const OBBoxClass & box,const Vector3 & color,float opacity = 0.25f);
  75. virtual void Add_Debug_Axes(const Matrix3D & transform,const Vector3 & color);
  76. void Render_Debug_Widgets(RenderInfoClass & rinfo);
  77. #else
  78. void Reset_Debug_Widget_List(void) {}
  79. void Add_Debug_Point(const Vector3 & p,const Vector3 & color) {}
  80. void Add_Debug_Vector(const Vector3 & p,const Vector3 & v,const Vector3 & color) {}
  81. void Add_Debug_AABox(const AABoxClass & box,const Vector3 & color,float opacity = 0.25f) {}
  82. void Add_Debug_OBBox(const OBBoxClass & box,const Vector3 & color,float opacity = 0.25f) {}
  83. void Add_Debug_Axes(const Matrix3D & transform,const Vector3 & color) {}
  84. void Render_Debug_Widgets(RenderInfoClass & rinfo) {}
  85. #endif
  86. protected:
  87. #ifdef WWDEBUG
  88. void Add_Debug_Widget(WidgetRenderOpClass * op);
  89. #else
  90. void Add_Debug_Widget(WidgetRenderOpClass * op) {}
  91. #endif
  92. /*
  93. ** Debug widget rendering list
  94. ** This member, which only exists when WWDEBUG is enabled, handles the rendering
  95. ** of any debug widgets that this object needs.
  96. */
  97. #ifdef WWDEBUG
  98. WidgetRenderOpClass * WidgetRenderOpList;
  99. #endif
  100. };
  101. #endif