示例#1
0
/**
 * A little nasty because we want to ensure that the main clock dt is
 * set intelligently from the assignment here.
 */
void Clock::setTickDt( unsigned int i, double v )
{
    unsigned int numUsed = 0;
    if ( v < minimumDt )
    {
        cout << "Warning: Clock::setTickDt: " << v <<
             " is smaller than minimum allowed timestep " <<
             minimumDt << endl;
        cout << "dt not set\n";
        return;
    }
    for ( unsigned int j = 0; j < numTicks; ++j )
        numUsed += ( ticks_[j] != 0 );

    if ( numUsed == 0 )
    {
        dt_ = v;
    }
    else if ( dt_ > v )
    {
        for ( unsigned int j = 0; j < numTicks; ++j )
            if ( ticks_[j] != 0 )
                ticks_[j] = round( ( ticks_[j] * dt_ ) / v );
        dt_ = v;
    }

    if ( checkTickNum( "setTickDt", i ) )
        ticks_[i] = round( v / dt_ );
}
示例#2
0
/**
 * A little nasty because we want to ensure that the main clock dt is
 * set intelligently from the assignment here.
 */
void Clock::setTickDt( unsigned int i, double v )
{
	unsigned int numUsed = 0;
	for ( unsigned int j = 0; j < numTicks; ++j )
		numUsed += ( ticks_[j] != 0 );
	if ( numUsed == 0 ) {
		dt_ = v;
	} else if ( dt_ > v ) {
		for ( unsigned int j = 0; j < numTicks; ++j )
			if ( ticks_[j] != 0 )
				ticks_[j] = round( ( ticks_[j] * dt_ ) / v );
		dt_ = v;
	}

	if ( checkTickNum( "setTickDt", i ) )
		ticks_[i] = round( v / dt_ );
}
示例#3
0
void Clock::setTickStep( unsigned int i, unsigned int v )
{
    if ( checkTickNum( "setTickStep", i ) )
        ticks_[i] = v;
}