Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.95 KB | None | 0 0
  1. inline const Vector &CShotManipulator::ApplySpread( const Vector &vecSpread, float bias )
  2. {
  3.     // get circular gaussian spread
  4.     float x, y, z;
  5.  
  6.     if ( bias > 1.0 )
  7.         bias = 1.0;
  8.     else if ( bias < 0.0 )
  9.         bias = 0.0;
  10.  
  11.     float shotBiasMin = ai_shot_bias_min.GetFloat();
  12.     float shotBiasMax = ai_shot_bias_max.GetFloat();
  13.  
  14.     // 1.0 gaussian, 0.0 is flat, -1.0 is inverse gaussian
  15.     float shotBias = ( ( shotBiasMax - shotBiasMin ) * bias ) + shotBiasMin;
  16.  
  17.     float flatness = ( fabsf(shotBias) * 0.5 );
  18.  
  19.     do
  20.     {
  21.         x = random->RandomFloat(-1,1) * flatness + random->RandomFloat(-1,1) * (1 - flatness);
  22.         y = random->RandomFloat(-1,1) * flatness + random->RandomFloat(-1,1) * (1 - flatness);
  23.         if ( shotBias < 0 )
  24.         {
  25.             x = ( x >= 0 ) ? 1.0 - x : -1.0 - x;
  26.             y = ( y >= 0 ) ? 1.0 - y : -1.0 - y;
  27.         }
  28.         z = x*x+y*y;
  29.     } while (z > 1);
  30.  
  31.     m_vecResult = m_vecShotDirection + x * vecSpread.x * m_vecRight + y * vecSpread.y * m_vecUp;
  32.  
  33.     return m_vecResult;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement