aabox.cpp 4.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. ** Command & Conquer Generals Zero Hour(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 : WWMath *
  23. * *
  24. * $Archive:: /Commando/Code/wwmath/aabox.cpp $*
  25. * *
  26. * Author:: Greg_h *
  27. * *
  28. * $Modtime:: 5/08/01 6:33p $*
  29. * *
  30. * $Revision:: 18 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * AABoxClass::Init_Random -- initializes this box to a random state *
  35. * AABoxClass::Contains -- test whether this box contains the given point *
  36. * AABoxClass::Contains -- Test whether this box contains the given box *
  37. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  38. #include "aabox.h"
  39. #include "colmath.h"
  40. #include "colmathinlines.h"
  41. #include <float.h>
  42. /***********************************************************************************************
  43. * AABoxClass::Init_Random -- initializes this box to a random state *
  44. * *
  45. * INPUT: *
  46. * *
  47. * OUTPUT: *
  48. * *
  49. * WARNINGS: *
  50. * *
  51. * HISTORY: *
  52. * 3/17/2000 gth : Created. *
  53. *=============================================================================================*/
  54. void AABoxClass::Init_Random(float min_center,float max_center,float min_extent,float max_extent)
  55. {
  56. Center.X = min_center + WWMath::Random_Float() * (max_center - min_center);
  57. Center.Y = min_center + WWMath::Random_Float() * (max_center - min_center);
  58. Center.Z = min_center + WWMath::Random_Float() * (max_center - min_center);
  59. Extent.X = min_extent + WWMath::Random_Float() * (max_extent - min_extent);
  60. Extent.Y = min_extent + WWMath::Random_Float() * (max_extent - min_extent);
  61. Extent.Z = min_extent + WWMath::Random_Float() * (max_extent - min_extent);
  62. }
  63. void AABoxClass::Transform(const Matrix3D & tm,const AABoxClass & in,AABoxClass * out)
  64. {
  65. tm.Transform_Center_Extent_AABox(in.Center,in.Extent,&(out->Center),&(out->Extent));
  66. }
  67. void MinMaxAABoxClass::Init_Empty(void)
  68. {
  69. MinCorner.Set(FLT_MAX,FLT_MAX,FLT_MAX);
  70. MaxCorner.Set(-FLT_MAX,-FLT_MAX,-FLT_MAX);
  71. }