Selaa lähdekoodia

Merge pull request #1124 from eightyeight/forest-wind-emitter

Forest wind emitter rendering improvement
Daniel Buckmaster 10 vuotta sitten
vanhempi
commit
70d2ec6718
1 muutettua tiedostoa jossa 15 lisäystä ja 1 poistoa
  1. 15 1
      Engine/source/forest/forestWindEmitter.cpp

+ 15 - 1
Engine/source/forest/forestWindEmitter.cpp

@@ -39,6 +39,8 @@
 #include "T3D/gameBase/processList.h"
 #include "console/engineAPI.h"
 
+#include "T3D/gameBase/gameConnection.h"
+
 ConsoleDocClass( ForestWindEmitter,
    "@brief Object responsible for simulating wind in a level.\n\n"
 
@@ -513,9 +515,21 @@ void ForestWindEmitter::_renderEmitterInfo( ObjectRenderInst *ri, SceneRenderSta
    drawer->drawArrow( desc, pos, pos + (windVec * mWindStrength), ColorI( 0, 0, 255, 255 ) );//Point3F( -235.214, 219.589, 34.0991 ), Point3F( -218.814, 244.731, 37.5587 ), ColorI( 255, 255, 0, 255 ) );//
    drawer->drawArrow( desc, pos, pos + (mWind->getTarget() * mWindStrength ), ColorI( 255, 0, 0, 85 ) );
 
+   S32 useRadius = mWindRadius;
    // Draw a 2D circle for the wind radius.
    if ( isRadialEmitter() )
-      drawer->drawSphere( desc, mWindRadius, pos, ColorI( 255, 0, 0, 80 ) );
+   {
+      // If the camera is close to the sphere, shrink the sphere so it remains visible.
+      GameConnection* gc = GameConnection::getConnectionToServer();
+      GameBase* gb;
+      if ( gc && (gb = gc->getCameraObject()) )
+      {
+         F32 camDist = (gb->getPosition() - getPosition()).len();
+         if ( camDist < mWindRadius )
+            useRadius = camDist;
+      }
+      drawer->drawSphere( desc, useRadius, pos, ColorI( 255, 0, 0, 80 ) );
+   }
 }
 
 F32 ForestWindEmitter::getStrength() const