PathfindSector.h 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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/wwphys/PathfindSector.h $*
  25. * *
  26. * Author:: Patrick Smith *
  27. * *
  28. * $Modtime:: 1/04/01 2:48p $*
  29. * *
  30. * $Revision:: 5 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef __PATHFIND_SECTOR_H
  39. #define __PATHFIND_SECTOR_H
  40. #include "refcount.h"
  41. #include "vector.h"
  42. #include "aabox.h"
  43. #include "cullsys.h"
  44. //////////////////////////////////////////////////////////////////////////
  45. // Forward declarations
  46. //////////////////////////////////////////////////////////////////////////
  47. class PhysClass;
  48. class ChunkSaveClass;
  49. class ChunkLoadClass;
  50. class PathfindPortalClass;
  51. class PathfindWaypathSectorClass;
  52. //////////////////////////////////////////////////////////////////////////
  53. //
  54. // PathfindSectorClass
  55. //
  56. //////////////////////////////////////////////////////////////////////////
  57. class PathfindSectorClass : public CullableClass
  58. {
  59. public:
  60. ////////////////////////////////////////////////////////////////////
  61. // Public constructors/destructors
  62. ////////////////////////////////////////////////////////////////////
  63. PathfindSectorClass (void)
  64. : m_IsValid (true) {}
  65. PathfindSectorClass (const AABoxClass &box)
  66. : m_IsValid (true) {}
  67. virtual ~PathfindSectorClass (void);
  68. ////////////////////////////////////////////////////////////////////
  69. // RTTI
  70. ////////////////////////////////////////////////////////////////////
  71. virtual PathfindWaypathSectorClass * As_PathfindWaypathSectorClass (void) { return NULL; }
  72. virtual const PathfindWaypathSectorClass * As_PathfindWaypathSectorClass (void) const { return NULL; }
  73. ////////////////////////////////////////////////////////////////////
  74. // Public methods
  75. ////////////////////////////////////////////////////////////////////
  76. //
  77. // Bounding box access
  78. //
  79. const AABoxClass & Get_Bounding_Box (void) const;
  80. void Set_Bounding_Box (const AABoxClass &box);
  81. //
  82. // Portal managment
  83. //
  84. void Add_Portal (uint32 portal_id);
  85. void Remove_Portal (uint32 portal_id);
  86. void Reset_Portal_List (void);
  87. //
  88. // Portal access
  89. //
  90. int Get_Portal_Count (void);
  91. PathfindPortalClass *Peek_Portal (int index);
  92. //
  93. // Validity managment
  94. //
  95. bool Is_Valid (void) { return m_IsValid; }
  96. void Set_Valid (bool is_valid) { m_IsValid = is_valid; }
  97. //
  98. // Portal testing methods
  99. //
  100. virtual bool Can_Access_Portal (PathfindPortalClass *last_portal, PathfindPortalClass *test_portal);
  101. //
  102. // Serialization methods
  103. //
  104. virtual bool Save (ChunkSaveClass &csave);
  105. virtual bool Load (ChunkLoadClass &cload);
  106. protected:
  107. ////////////////////////////////////////////////////////////////////
  108. // Protected member data
  109. ////////////////////////////////////////////////////////////////////
  110. DynamicVectorClass<uint32> m_PortalList;
  111. bool m_IsValid;
  112. private:
  113. //////////////////////////////////////////////////////////////////////
  114. // Private methods
  115. //////////////////////////////////////////////////////////////////////
  116. bool Load_Variables (ChunkLoadClass &cload);
  117. };
  118. //////////////////////////////////////////////////////////////////////////
  119. // Inlines
  120. //////////////////////////////////////////////////////////////////////////
  121. inline const AABoxClass &
  122. PathfindSectorClass::Get_Bounding_Box (void) const
  123. {
  124. return Get_Cull_Box ();
  125. }
  126. inline void
  127. PathfindSectorClass::Set_Bounding_Box (const AABoxClass &box)
  128. {
  129. Set_Cull_Box (box);
  130. return ;
  131. }
  132. inline void
  133. PathfindSectorClass::Add_Portal (uint32 portal_id)
  134. {
  135. m_PortalList.Add (portal_id);
  136. return ;
  137. }
  138. inline int
  139. PathfindSectorClass::Get_Portal_Count (void)
  140. {
  141. return m_PortalList.Count ();
  142. }
  143. inline bool
  144. PathfindSectorClass::Can_Access_Portal
  145. (
  146. PathfindPortalClass *last_portal,
  147. PathfindPortalClass *test_portal
  148. )
  149. {
  150. return (test_portal != last_portal);
  151. }
  152. //////////////////////////////////////////////////////////////////////////
  153. //
  154. // PathfindWaypathSectorClass
  155. //
  156. // This class is used to represent a logical sector that is solely
  157. // comprised of enter and exit portals. These portals are sorted by
  158. // occurance on the waypath.
  159. //
  160. //////////////////////////////////////////////////////////////////////////
  161. class PathfindWaypathSectorClass : public PathfindSectorClass
  162. {
  163. public:
  164. ////////////////////////////////////////////////////////////////////
  165. // Public constructors/destructors
  166. ////////////////////////////////////////////////////////////////////
  167. PathfindWaypathSectorClass (void)
  168. : WaypathID (-1) {}
  169. ~PathfindWaypathSectorClass (void) {}
  170. ////////////////////////////////////////////////////////////////////
  171. // RTTI
  172. ////////////////////////////////////////////////////////////////////
  173. PathfindWaypathSectorClass * As_PathfindWaypathSectorClass (void) { return this; }
  174. const PathfindWaypathSectorClass * As_PathfindWaypathSectorClass (void) const { return this; }
  175. ////////////////////////////////////////////////////////////////////
  176. // Public methods
  177. ////////////////////////////////////////////////////////////////////
  178. //
  179. // Waypath access
  180. //
  181. void Set_Waypath_ID (int waypath_id) { WaypathID = waypath_id; }
  182. int Get_Waypath_ID (void) { return WaypathID; }
  183. //
  184. // From PathfindSectorClass
  185. //
  186. bool Can_Access_Portal (PathfindPortalClass *last_portal, PathfindPortalClass *test_portal);
  187. bool Save (ChunkSaveClass &csave);
  188. bool Load (ChunkLoadClass &cload);
  189. protected:
  190. ////////////////////////////////////////////////////////////////////
  191. // Protected methods
  192. ////////////////////////////////////////////////////////////////////
  193. ////////////////////////////////////////////////////////////////////
  194. // Protected member data
  195. ////////////////////////////////////////////////////////////////////
  196. int WaypathID;
  197. private:
  198. //////////////////////////////////////////////////////////////////////
  199. // Private methods
  200. //////////////////////////////////////////////////////////////////////
  201. bool Load_Variables (ChunkLoadClass &cload);
  202. };
  203. #endif //__PATHFIND_SECTOR_H