combatdazzle.cpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 : Renegade *
  23. * *
  24. * $Archive:: /Commando/Code/Combat/combatdazzle.cpp $*
  25. * *
  26. * Original Author:: Greg Hjelstrom *
  27. * *
  28. * $Author:: Greg_h $*
  29. * *
  30. * $Modtime:: 6/15/01 9:09a $*
  31. * *
  32. * $Revision:: 2 $*
  33. * *
  34. *---------------------------------------------------------------------------------------------*
  35. * Functions: *
  36. * CombatDazzleClass::Compute_Dazzle_Visibility -- Computes visibility of a dazzle object in *
  37. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  38. #include "combatdazzle.h"
  39. #include "rinfo.h"
  40. #include "camera.h"
  41. #include "pscene.h"
  42. #include "physcoltest.h"
  43. #include "phys.h"
  44. #include "combat.h"
  45. #include "soldier.h"
  46. CombatDazzleClass _TheCombatDazzleHandler;
  47. /***********************************************************************************************
  48. * CombatDazzleClass::Compute_Dazzle_Visibility -- Computes visibility of a dazzle object in t *
  49. * *
  50. * This dazzle visibility handler is used for the background and game scene in renegade. *
  51. * *
  52. * INPUT: *
  53. * *
  54. * OUTPUT: *
  55. * *
  56. * WARNINGS: *
  57. * *
  58. * HISTORY: *
  59. * 6/13/2001 gth : Created. *
  60. *=============================================================================================*/
  61. float CombatDazzleClass::Compute_Dazzle_Visibility
  62. (
  63. RenderInfoClass & rinfo,
  64. DazzleRenderObjClass * obj,
  65. const Vector3 & point
  66. ) const
  67. {
  68. /*
  69. ** If we are in first-person mode, don't collide against the star
  70. */
  71. bool ignore_player = CombatManager::Is_First_Person();
  72. if (ignore_player) {
  73. if (COMBAT_STAR != NULL) {
  74. COMBAT_STAR->Peek_Physical_Object()->Inc_Ignore_Counter();
  75. }
  76. }
  77. /*
  78. ** Cast a ray from the camera to the dazzle position
  79. */
  80. CastResultStruct res;
  81. LineSegClass ray(rinfo.Camera.Get_Position(),point);
  82. PhysRayCollisionTestClass raytest(ray,&res,0,COLLISION_TYPE_PROJECTILE);
  83. PhysicsSceneClass * scene = PhysicsSceneClass::Get_Instance();
  84. if (scene != NULL) {
  85. scene->Cast_Ray(raytest);
  86. }
  87. /*
  88. ** Done
  89. */
  90. if (ignore_player) {
  91. if (COMBAT_STAR != NULL) {
  92. COMBAT_STAR->Peek_Physical_Object()->Dec_Ignore_Counter();
  93. }
  94. }
  95. if (res.Fraction == 1.0f) {
  96. return 1.0f;
  97. } else {
  98. return 0.0f;
  99. }
  100. }