support set_dt(0) in M_slave mode

This commit is contained in:
David Rose 2009-09-01 18:50:42 +00:00
parent 58555a2895
commit 8a30b5fae0
3 changed files with 29 additions and 18 deletions

View File

@ -146,23 +146,6 @@ get_dt(Thread *current_thread) const {
return cdata->_dt;
}
////////////////////////////////////////////////////////////////////
// Function: ClockObject::set_dt
// Access: Published
// Description: In non-real-time mode, sets the number of seconds
// that should appear to elapse between frames. In
// forced mode or limited mode, sets our target dt. In
// normal mode, this has no effect.
//
// Also see set_frame_rate(), which is a different way
// to specify the same quantity.
////////////////////////////////////////////////////////////////////
INLINE void ClockObject::
set_dt(double dt) {
nassertv(dt != 0.0);
set_frame_rate(1.0 / dt);
}
////////////////////////////////////////////////////////////////////
// Function: ClockObject::get_max_dt
// Access: Published

View File

@ -224,6 +224,34 @@ set_frame_count(int frame_count, Thread *current_thread) {
cdata->_frame_count / _user_frame_rate;
}
////////////////////////////////////////////////////////////////////
// Function: ClockObject::set_dt
// Access: Published
// Description: In non-real-time mode, sets the number of seconds
// that should appear to elapse between frames. In
// forced mode or limited mode, sets our target dt. In
// normal mode, this has no effect.
//
// Also see set_frame_rate(), which is a different way
// to specify the same quantity.
////////////////////////////////////////////////////////////////////
void ClockObject::
set_dt(double dt) {
if (_mode == M_slave) {
// In M_slave mode, we can set any dt we like.
CDWriter cdata(_cycler, Thread::get_current_thread());
cdata->_dt = dt;
if (dt != 0.0) {
set_frame_rate(1.0 / dt);
}
} else {
// In any other mode, we can only set non-zero dt.
nassertv(dt != 0.0);
set_frame_rate(1.0 / dt);
}
}
////////////////////////////////////////////////////////////////////
// Function: ClockObject::set_frame_rate
// Access: Published

View File

@ -94,7 +94,7 @@ PUBLISHED:
INLINE double get_net_frame_rate(Thread *current_thread = Thread::get_current_thread()) const;
INLINE double get_dt(Thread *current_thread = Thread::get_current_thread()) const;
INLINE void set_dt(double dt);
void set_dt(double dt);
void set_frame_rate(double frame_rate);
INLINE double get_max_dt() const;