void CSheetSimulator::Simulate( float dt, int steps ) { ComputeControlPoints(); // Initialize positions if necessary dt /= steps; for (int i = 0; i < steps; ++i) { // Each step, we want to re-select the best collision planes to constrain // the movement by DetermineBestCollisionPlane(); EulerStep(dt); } }
void CSheetSimulator::SetPosition( const Vector& origin, const QAngle& angles ) { // FIXME: Need a better metric for position reset if (m_Origin.DistToSqr(origin) > 1e3) { for ( int i = 0; i < NumParticles(); ++i ) { m_Particle[i].m_Position = origin; m_Particle[i].m_Velocity = Vector(0,0,0); } } m_Origin = origin; m_Angles = angles; ComputeControlPoints(); }
//----------------------------------------------------------------------------- // Update the shield position: //----------------------------------------------------------------------------- void CShieldEffect::Simulate( float dt ) { // We're gonna basically assume a spring connected to the center control point Vector forward; AngleVectors(m_angDesiredAngles, &forward, 0, 0); // We've got two springs: a spring connected to the origin // and a torsional spring connected to the view direction. // Stiff spring, subdivide time.... dt /= SHIELD_TIME_SUBVISIBIONS; for (int i = 0; i < SHIELD_TIME_SUBVISIBIONS; ++i) { SimulateTranslation( dt ); SimulateRotation( dt, forward ); } ComputeControlPoints(); }