physaabtreecull.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 : TileCull *
  23. * *
  24. * $Archive:: /Commando/Code/wwphys/physaabtreecull.h $*
  25. * *
  26. * Author:: Greg Hjelstrom *
  27. * *
  28. * $Modtime:: 9/28/00 10:51a $*
  29. * *
  30. * $Revision:: 13 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. #if defined(_MSC_VER)
  36. #pragma once
  37. #endif
  38. #ifndef PHYSAABTREECULL_H
  39. #define PHYSAABTREECULL_H
  40. #include "always.h"
  41. #include "aabtreecull.h"
  42. #include "phys.h"
  43. #include "wwdebug.h"
  44. class PhysicsSceneClass;
  45. class StringClass;
  46. /*
  47. ** PhysAABTreeCullClass
  48. ** This is a derived axis-aligned bounding box tree for use with the physics library.
  49. ** It adds collision detection queries to the base AABTree
  50. */
  51. class PhysAABTreeCullClass : public TypedAABTreeCullSystemClass<PhysClass>
  52. {
  53. public:
  54. PhysAABTreeCullClass(PhysicsSceneClass * pscene);
  55. ~PhysAABTreeCullClass(void);
  56. /*
  57. ** Verify that the tree is valid, (all boxes contain their children, all objects contained in their node)
  58. */
  59. bool Verify(StringClass & set_error_report);
  60. /*
  61. ** Collision detection
  62. */
  63. bool Cast_Ray(PhysRayCollisionTestClass & raytest);
  64. bool Cast_AABox(PhysAABoxCollisionTestClass & boxtest);
  65. bool Cast_OBBox(PhysOBBoxCollisionTestClass & boxtest);
  66. bool Intersection_Test(PhysAABoxIntersectionTestClass & boxtest);
  67. bool Intersection_Test(PhysOBBoxIntersectionTestClass & boxtest);
  68. bool Intersection_Test(PhysMeshIntersectionTestClass & meshtest);
  69. /*
  70. ** Debugging options, disable hierarchical vis culling
  71. */
  72. static void Enable_Hierarchical_Vis_Culling(bool onoff) { _HierarchicalVisCullingEnabled = onoff; }
  73. static bool Is_Hierarchical_Vis_Culling_Enabled(void) { return _HierarchicalVisCullingEnabled; }
  74. protected:
  75. /*
  76. ** Internal functions
  77. */
  78. bool Verify_Recursive(AABTreeNodeClass * node,StringClass & error_report);
  79. bool Cast_Ray_Recursive(AABTreeNodeClass * node,PhysRayCollisionTestClass & raytest);
  80. bool Cast_AABox_Recursive(AABTreeNodeClass * node,PhysAABoxCollisionTestClass & boxtest);
  81. bool Cast_OBBox_Recursive(AABTreeNodeClass * node,PhysOBBoxCollisionTestClass & boxtest);
  82. /*
  83. ** Members
  84. */
  85. PhysicsSceneClass * Scene; // scene that we are a member of
  86. static bool _HierarchicalVisCullingEnabled;
  87. };
  88. inline bool PhysAABTreeCullClass::Cast_Ray(PhysRayCollisionTestClass & raytest)
  89. {
  90. WWASSERT(RootNode != NULL);
  91. return Cast_Ray_Recursive(RootNode,raytest);
  92. }
  93. inline bool PhysAABTreeCullClass::Cast_AABox(PhysAABoxCollisionTestClass & boxtest)
  94. {
  95. WWASSERT(RootNode != NULL);
  96. return Cast_AABox_Recursive(RootNode,boxtest);
  97. }
  98. inline bool PhysAABTreeCullClass::Cast_OBBox(PhysOBBoxCollisionTestClass & boxtest)
  99. {
  100. WWASSERT(RootNode != NULL);
  101. return Cast_OBBox_Recursive(RootNode,boxtest);
  102. }
  103. #endif // PHYSAABTREECULL_H