//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFGrenadeMirvProjectile::Explode( trace_t *pTrace, int bitsDamageType )
{
	// Pass through.
	BaseClass::Explode( pTrace, bitsDamageType );
// Server specific.
#ifdef GAME_DLL

	// Create the bomblets.
	for ( int iBomb = 0; iBomb < TF_WEAPON_GRENADE_MIRV_BOMB_COUNT; ++iBomb )
	{
		Vector vecSrc = pTrace->endpos + Vector( 0, 0, 1.0f ); 
		Vector vecVelocity( random->RandomFloat( -75.0f, 75.0f ) * 3.0f,
			                random->RandomFloat( -75.0f, 75.0f ) * 3.0f,
							random->RandomFloat( 30.0f, 70.0f ) * 5.0f );
		Vector vecZero( 0,0,0 );
		CTFPlayer *pPlayer = ToTFPlayer( GetThrower() );
		float flTime = 2.0f + random->RandomFloat( 0.0f, 1.0f );

		CTFGrenadeMirvBomb *pBomb = CTFGrenadeMirvBomb::Create( vecSrc, GetAbsAngles(), vecVelocity, vecZero, pPlayer, flTime );
		pBomb->SetDamage( GetDamage() * 0.5f );
		pBomb->SetDamageRadius( GetDamageRadius() );
	}

#endif
}
Пример #2
0
/**
 * Reset the currently integrated spectrum to 0
 */
void TaskCoreFFTW::reset_spectrum()
{
   for (int s=0; s<cfg->num_sources; s++) {
      vecZero(fft_accu_reim[s], cfg->fft_points);
   }
   for (int x=0; x<cfg->num_xpols; x++) {
      // vecZero(fft_accu_reim[s], cfg->fft_points);
   }
   this->num_ffts_accumulated = 0;
}
Пример #3
0
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CFourWheelVehiclePhysics::DisableMotion( void )
{
	Vector vecZero( 0.0f, 0.0f, 0.0f );
	AngularImpulse angNone( 0.0f, 0.0f, 0.0f );

	for( int iWheel = 0; iWheel < m_wheelCount; ++iWheel )
	{
		m_pWheels[iWheel]->SetVelocity( &vecZero, &angNone );
		m_pWheels[iWheel]->EnableMotion( false );
	}
}
Пример #4
0
/* --------------- Platform Class --------------- */
Platform::Platform(int width, int height, int x, int y, int tex)
{
    body.type = RECTANGLE;
    id = PLATFORM;
    tex_id = tex;

    vecMake(x,y,body.center);
    vecCopy(body.center, prevPosition);
    vecZero(velocity);

    body.width = width;
    body.height = height;
    textureWidth = 15;     // !!!!! need to merge with game's texture data !!!!!
    textureHeight = 15;
    horizontalTiles = width / textureWidth;
    verticalTiles = height / textureHeight;
    rgb[0] = 90;
    rgb[1] = 140;
    rgb[2] = 90;
}
//-----------------------------------------------------------------------------
// Purpose:: Convert data to HL2 measurements, and test direction of raycast.
//-----------------------------------------------------------------------------
void CPhysics_Airboat::pre_raycasts_gameside( int nRaycastCount, IVP_Ray_Solver_Template *pRays,
											  Ray_t *pGameRays, IVP_Raycast_Airboat_Impact *pImpacts )
{
	for ( int iRaycast = 0; iRaycast < nRaycastCount; ++iRaycast )
	{
		// Setup the ray.
		Vector vecStart;
		ConvertPositionToHL( pRays[iRaycast].ray_start_point, vecStart );

		Vector vecEnd;
		Vector vecDirection;
		ConvertDirectionToHL( pRays[iRaycast].ray_normized_direction, vecDirection );
		float flRayLength = IVP2HL( pRays[iRaycast].ray_length );

		// Check to see if that point is in water.
		pImpacts[iRaycast].bInWater = IVP_FALSE;
		if ( m_pGameTrace->VehiclePointInWater( vecStart ) )
		{
			vecDirection.Negate();
			pImpacts[iRaycast].bInWater = IVP_TRUE;
		}

		vecEnd = vecStart + ( vecDirection * flRayLength );

		// Shorten the trace.
		if ( m_pGameTrace->VehiclePointInWater( vecEnd ) )
		{
			pRays[iRaycast].ray_length = AIRBOAT_RAYCAST_DIST_WATER;
			flRayLength = IVP2HL( pRays[iRaycast].ray_length );
			vecEnd = vecStart + ( vecDirection * flRayLength );
		}

		Vector vecZero( 0.0f, 0.0f, 0.0f );
		pGameRays[iRaycast].Init( vecStart, vecEnd, vecZero, vecZero );
	}
}
Пример #6
0
/**
 * Reset buffer to 0.0 floats
 * @param buf     Buffer to reset
 */
void TaskCoreFFTW::resetBuffer(Buffer* buf) 
{ 
   vecZero((fftw_real*) buf->getData(), buf->getLength() / sizeof(fftw_real));
}
Пример #7
0
int main(){

  PARTICLE *p,*pn;
  p=malloc(sizeof(PARTICLE)); //need to allocate memory to pointer
  pn=malloc(sizeof(PARTICLE));
  FILE *fp;

	double dDelta,t,tmax;
  double CnPreFac, CtPreFac, dLnEpsN, dLnEpsT, dLnEpsNsq, dLnEpsTsq, a;;
  int i;
  int nSteps,iStep=0;
  int iOutFreq;
  int bOverlap=0;
  char achOutFile[20];

  //Need to initialize dKn for each particle
  p->dKn = 1.06e-15;
  p->dKt = 2.*p->dKn/7.;
  p->dEpsN = 0.8;
  p->dEpsT = 0.8;
  p->dMuS = 0.4;
  
  pn->dKn = p->dKn;
  pn->dKt = p->dKt;
  pn->dEpsN = p->dEpsN;
  pn->dEpsT = p->dEpsT;
  pn->dMuS = p->dMuS;
  
  dDelta=1.47e-10;
  nSteps = 40000;
  iOutFreq = nSteps / 50;
  t=0;
  tmax=dDelta * nSteps;
 
 
  const double pi_sq = M_PI*M_PI;
  static int bCnCtPreFacCalculated = 0; /* since dEpsN and dEpsT are identical for all particles in sim */

  if (!bCnCtPreFacCalculated) {
    /* damping term: normal */
    dLnEpsN = log(p->dEpsN);
    dLnEpsNsq = dLnEpsN*dLnEpsN;
    a = pi_sq + dLnEpsNsq;
    CnPreFac = -sign(dLnEpsN)*sqrt(dLnEpsNsq*p->dKn/a);
    CnPreFac += CnPreFac;

    /* damping term: tangential */
    dLnEpsT = log(p->dEpsT);
    dLnEpsTsq = dLnEpsT*dLnEpsT;
    a = pi_sq + dLnEpsTsq;
    CtPreFac = -sign(dLnEpsT)*sqrt(dLnEpsTsq*p->dKt/a);
    CtPreFac += CtPreFac;
    bCnCtPreFacCalculated = 1;
    }

  /*Take input from FILE here - Initialization*/
  FileInput(p, pn);

  
  /*Simulation loop here*/
  while (t<tmax){
  
    /* Output to file Here*/
    if ((t == 0) || (iStep % iOutFreq == 0)){
      /*Define File Name based on time step*/
      sprintf(achOutFile,"ss.%09d.bt",iStep);
      /*Output function*/
		  FileOutput(p, pn, achOutFile);
    }
    /* Output-Function Ends Here*/
    

    /* LeapFrog */
    for (i=0;i<3;i++){
      p->v[i]=p->v[i]+(0.5*dDelta*p->a[i]); //kick
      pn->v[i]=pn->v[i]+(0.5*dDelta*pn->a[i]);
    }

    for (i=0;i<3;i++){
  	  p->r[i]=p->r[i]+(dDelta*p->v[i]); //drift
  	  pn->r[i]=pn->r[i]+(dDelta*pn->v[i]); //
    }

    //Overlap Test
        bOverlap = bOverlapTest(p,pn);
    if (bOverlap){
      DoDEM(p, pn, dDelta, CnPreFac, CtPreFac);
      printf("%d\n",bOverlap);
    }
    else{
      vecZero(p->a); //Is this correct?
      vecZero(pn->a);
    }
    
    for (i=0;i<3;i++){
      p->v[i]=p->v[i]+(0.5*dDelta*p->a[i]); //kick
      pn->v[i]=pn->v[i]+(0.5*dDelta*pn->a[i]);
    }
    /* LeapFrog ENDS*/


    t+=dDelta;
    iStep++;
  }
  
  return 0;
}