This commit is contained in:
David Rose 2005-02-26 00:33:20 +00:00
parent 18d54db4c8
commit 350eafbd02
3 changed files with 57 additions and 46 deletions

View File

@ -282,7 +282,7 @@ get_average_frame_rate_interval() const {
////////////////////////////////////////////////////////////////////
INLINE double ClockObject::
get_average_frame_rate() const {
if (_ticks.empty()) {
if (_ticks.size() <= 1) {
return 0.0;
} else {
return _ticks.size() / (_reported_frame_time - _ticks.front());

View File

@ -42,7 +42,7 @@ ClockObject() {
// Each clock except for the application global clock is created in
// M_normal mode. The application global clock is later reset to
// respect clock_mode, which comes from the Configrc file.
// respect clock_mode, which comes from the Config.prc file.
_mode = M_normal;
_start_short_time = _true_clock->get_short_time();
@ -90,7 +90,7 @@ set_real_time(double time) {
void ClockObject::
set_frame_time(double time) {
#ifdef NOTIFY_DEBUG
if (this == _global_clock) {
if (this == _global_clock && _mode != M_slave) {
express_cat.warning()
<< "Adjusting global clock's frame time by " << time - get_frame_time()
<< " seconds.\n";
@ -110,7 +110,7 @@ set_frame_time(double time) {
void ClockObject::
set_frame_count(int frame_count) {
#ifdef NOTIFY_DEBUG
if (this == _global_clock) {
if (this == _global_clock && _mode != M_slave) {
express_cat.warning()
<< "Adjusting global clock's frame count by "
<< frame_count - get_frame_count() << " frames.\n";
@ -133,6 +133,7 @@ void ClockObject::
tick() {
double old_reported_time = _reported_frame_time;
if (_mode != M_slave) {
double old_time = _actual_frame_time;
_actual_frame_time = get_real_time();
@ -176,9 +177,13 @@ tick() {
break;
case M_slave:
// Handled above.
break;
}
_frame_count++;
}
if (_average_frame_rate_interval > 0.0) {
_ticks.push_back(old_reported_time);
@ -281,6 +286,9 @@ operator << (ostream &out, ClockObject::Mode mode) {
case ClockObject::M_degrade:
return out << "degrade";
case ClockObject::M_slave:
return out << "slave";
};
return out << "**invalid ClockObject::Mode(" << (int)mode << ")**";
@ -303,6 +311,8 @@ operator >> (istream &in, ClockObject::Mode &mode) {
mode = ClockObject::M_forced;
} else if (word == "degrade") {
mode = ClockObject::M_degrade;
} else if (word == "slave") {
mode = ClockObject::M_slave;
} else {
express_cat.error()
<< "Invalid ClockObject::Mode: " << word << "\n";

View File

@ -70,6 +70,7 @@ PUBLISHED:
M_non_real_time,
M_forced,
M_degrade,
M_slave,
};
ClockObject();