1
0
Fork 0

Melchior FRANZ:

The jitter is most likely caused by the irregular frame rate and CPU clock dependent intervals. There's no easy way around that. I tried some fancy interpolation and all that -- to no avail.
This commit is contained in:
ehofman 2003-07-24 15:00:16 +00:00
parent a2b71872ad
commit ae8199be38
3 changed files with 18 additions and 35 deletions

View file

@ -133,7 +133,7 @@ static void MakeVIEW_OFFSET( sgMat4 dst,
// Constructor... // Constructor...
FGViewer::FGViewer( fgViewType Type, bool from_model, int from_model_index, FGViewer::FGViewer( fgViewType Type, bool from_model, int from_model_index,
bool at_model, int at_model_index, bool at_model, int at_model_index,
double damp_alt, double damp_roll, double damp_pitch, double damp_heading, double damp_roll, double damp_pitch, double damp_heading,
double x_offset_m, double y_offset_m, double z_offset_m, double x_offset_m, double y_offset_m, double z_offset_m,
double heading_offset_deg, double pitch_offset_deg, double heading_offset_deg, double pitch_offset_deg,
double roll_offset_deg, double fov_deg, double roll_offset_deg, double fov_deg,
@ -149,7 +149,7 @@ FGViewer::FGViewer( fgViewType Type, bool from_model, int from_model_index,
_roll_deg(0), _roll_deg(0),
_pitch_deg(0), _pitch_deg(0),
_heading_deg(0), _heading_deg(0),
_damp_alt(0), _damp_sync(0),
_damp_roll(0), _damp_roll(0),
_damp_pitch(0), _damp_pitch(0),
_damp_heading(0), _damp_heading(0),
@ -161,14 +161,13 @@ FGViewer::FGViewer( fgViewType Type, bool from_model, int from_model_index,
_from_model_index = from_model_index; _from_model_index = from_model_index;
_at_model = at_model; _at_model = at_model;
_at_model_index = at_model_index; _at_model_index = at_model_index;
if (damp_alt > 0.0)
_damp_alt = 1 - 1.0 / pow(10, fabs(damp_alt));
if (damp_roll > 0.0) if (damp_roll > 0.0)
_damp_roll = 1 - 1.0 / pow(10, fabs(damp_roll)); _damp_roll = 1.0 / pow(10, fabs(damp_roll));
if (damp_pitch > 0.0) if (damp_pitch > 0.0)
_damp_pitch = 1 - 1.0 / pow(10, fabs(damp_pitch)); _damp_pitch = 1.0 / pow(10, fabs(damp_pitch));
if (damp_heading > 0.0) if (damp_heading > 0.0)
_damp_heading = 1 - 1.0 / pow(10, fabs(damp_heading)); _damp_heading = 1.0 / pow(10, fabs(damp_heading));
_x_offset_m = x_offset_m; _x_offset_m = x_offset_m;
_y_offset_m = y_offset_m; _y_offset_m = y_offset_m;
@ -508,7 +507,7 @@ FGViewer::recalcOurOwnLocation (SGLocation * location, double lon_deg, double la
double roll_deg, double pitch_deg, double heading_deg) double roll_deg, double pitch_deg, double heading_deg)
{ {
// update from our own data... // update from our own data...
dampEyeData(alt_ft, roll_deg, pitch_deg, heading_deg); dampEyeData(roll_deg, pitch_deg, heading_deg);
location->setPosition( lon_deg, lat_deg, alt_ft ); location->setPosition( lon_deg, lat_deg, alt_ft );
location->setOrientation( roll_deg, pitch_deg, heading_deg ); location->setOrientation( roll_deg, pitch_deg, heading_deg );
sgCopyMat4(LOCAL, sgCopyMat4(LOCAL,
@ -634,7 +633,6 @@ FGViewer::recalcLookAt ()
updateFromModelLocation(_location); updateFromModelLocation(_location);
} else { } else {
// update from our own data, just the rotation here... // update from our own data, just the rotation here...
recalcOurOwnLocation( _location, _lon_deg, _lat_deg, _alt_ft, recalcOurOwnLocation( _location, _lon_deg, _lat_deg, _alt_ft,
_roll_deg, _pitch_deg, _heading_deg ); _roll_deg, _pitch_deg, _heading_deg );
} }
@ -723,24 +721,21 @@ FGViewer::copyLocationData()
} }
void void
FGViewer::dampEyeData (double &alt_ft, double &roll_deg, double &pitch_deg, double &heading_deg) FGViewer::dampEyeData (double &roll_deg, double &pitch_deg, double &heading_deg)
{ {
const double interval = 0.01; const double interval = 0.01;
static FGViewer *last = 0; static FGViewer *last_view = 0;
if (last != this) { if (last_view != this) {
_damp_sync = 0.0; _damp_sync = 0.0;
_damped_alt_ft = alt_ft;
_damped_roll_deg = roll_deg; _damped_roll_deg = roll_deg;
_damped_pitch_deg = pitch_deg; _damped_pitch_deg = pitch_deg;
_damped_heading_deg = heading_deg; _damped_heading_deg = heading_deg;
last = this; last_view = this;
return; return;
} }
if (_damp_sync < interval) { if (_damp_sync < interval) {
if (_damp_alt > 0.0)
alt_ft = _damped_alt_ft;
if (_damp_roll > 0.0) if (_damp_roll > 0.0)
roll_deg = _damped_roll_deg; roll_deg = _damped_roll_deg;
if (_damp_pitch > 0.0) if (_damp_pitch > 0.0)
@ -754,16 +749,13 @@ FGViewer::dampEyeData (double &alt_ft, double &roll_deg, double &pitch_deg, doub
_damp_sync -= interval; _damp_sync -= interval;
double d; double d;
if (_damp_alt > 0.0)
alt_ft = _damped_alt_ft = alt_ft * (1 - _damp_alt) + _damped_alt_ft * _damp_alt;
if (_damp_roll > 0.0) { if (_damp_roll > 0.0) {
d = _damped_roll_deg - roll_deg; d = _damped_roll_deg - roll_deg;
if (d >= 180.0) if (d >= 180.0)
_damped_roll_deg -= 360.0; _damped_roll_deg -= 360.0;
else if (d < -180.0) else if (d < -180.0)
_damped_roll_deg += 360.0; _damped_roll_deg += 360.0;
roll_deg = _damped_roll_deg = roll_deg * (1 - _damp_roll) + _damped_roll_deg * _damp_roll; roll_deg = _damped_roll_deg = roll_deg * _damp_roll + _damped_roll_deg * (1 - _damp_roll);
} }
if (_damp_pitch > 0.0) { if (_damp_pitch > 0.0) {
@ -772,7 +764,7 @@ FGViewer::dampEyeData (double &alt_ft, double &roll_deg, double &pitch_deg, doub
_damped_pitch_deg -= 360.0; _damped_pitch_deg -= 360.0;
else if (d < -180.0) else if (d < -180.0)
_damped_pitch_deg += 360.0; _damped_pitch_deg += 360.0;
pitch_deg = _damped_pitch_deg = pitch_deg * (1 - _damp_pitch) + _damped_pitch_deg * _damp_pitch; pitch_deg = _damped_pitch_deg = pitch_deg * _damp_pitch + _damped_pitch_deg * (1 - _damp_pitch);
} }
if (_damp_heading > 0.0) { if (_damp_heading > 0.0) {
@ -781,7 +773,7 @@ FGViewer::dampEyeData (double &alt_ft, double &roll_deg, double &pitch_deg, doub
_damped_heading_deg -= 360.0; _damped_heading_deg -= 360.0;
else if (d < -180.0) else if (d < -180.0)
_damped_heading_deg += 360.0; _damped_heading_deg += 360.0;
heading_deg = _damped_heading_deg = heading_deg * (1 - _damp_heading) + _damped_heading_deg * _damp_heading; heading_deg = _damped_heading_deg = heading_deg * _damp_heading + _damped_heading_deg * (1 - _damp_heading);
} }
} }
} }

View file

@ -63,7 +63,7 @@ public:
// Constructor // Constructor
FGViewer( fgViewType Type, bool from_model, int from_model_index, FGViewer( fgViewType Type, bool from_model, int from_model_index,
bool at_model, int at_model_index, bool at_model, int at_model_index,
double damp_alt, double damp_roll, double damp_pitch, double damp_heading, double damp_roll, double damp_pitch, double damp_heading,
double x_offset_m, double y_offset_m, double z_offset_m, double x_offset_m, double y_offset_m, double z_offset_m,
double heading_offset_deg, double pitch_offset_deg, double heading_offset_deg, double pitch_offset_deg,
double roll_offset_deg, double fov_deg, double roll_offset_deg, double fov_deg,
@ -287,12 +287,10 @@ private:
double _target_heading_deg; double _target_heading_deg;
double _damp_sync; double _damp_sync;
double _damp_alt;
double _damp_roll; double _damp_roll;
double _damp_pitch; double _damp_pitch;
double _damp_heading; double _damp_heading;
double _damped_alt_ft;
double _damped_roll_deg; double _damped_roll_deg;
double _damped_pitch_deg; double _damped_pitch_deg;
double _damped_heading_deg; double _damped_heading_deg;
@ -388,7 +386,7 @@ private:
void updateAtModelLocation (SGLocation * location); void updateAtModelLocation (SGLocation * location);
void recalcOurOwnLocation (SGLocation * location, double lon_deg, double lat_deg, double alt_ft, void recalcOurOwnLocation (SGLocation * location, double lon_deg, double lat_deg, double alt_ft,
double roll_deg, double pitch_deg, double heading_deg); double roll_deg, double pitch_deg, double heading_deg);
void dampEyeData (double &alt_ft, double &roll_deg, double &pitch_deg, double &heading_deg); void dampEyeData (double &roll_deg, double &pitch_deg, double &heading_deg);
// add to _heading_offset_deg // add to _heading_offset_deg
inline void incHeadingOffset_deg( double amt ) { inline void incHeadingOffset_deg( double amt ) {

View file

@ -94,19 +94,12 @@ FGViewMgr::init ()
nodepath += "/config/at-model-idx"; nodepath += "/config/at-model-idx";
at_model_index = fgGetInt(nodepath.c_str()); at_model_index = fgGetInt(nodepath.c_str());
// view damping (0.0: no damping; <0.0: all but alt; >0.0: damp all)
nodepath = viewpath;
nodepath += "/config/at-model-alt-damping";
damp_alt = fgGetDouble(nodepath.c_str(), 0.0);
nodepath = viewpath; nodepath = viewpath;
nodepath += "/config/at-model-roll-damping"; nodepath += "/config/at-model-roll-damping";
damp_roll = fgGetDouble(nodepath.c_str(), 0.0); damp_roll = fgGetDouble(nodepath.c_str(), 0.0);
nodepath = viewpath; nodepath = viewpath;
nodepath += "/config/at-model-pitch-damping"; nodepath += "/config/at-model-pitch-damping";
damp_pitch = fgGetDouble(nodepath.c_str(), 0.0); damp_pitch = fgGetDouble(nodepath.c_str(), 0.0);
nodepath = viewpath; nodepath = viewpath;
nodepath += "/config/at-model-heading-damping"; nodepath += "/config/at-model-heading-damping";
damp_heading = fgGetDouble(nodepath.c_str(), 0.0); damp_heading = fgGetDouble(nodepath.c_str(), 0.0);
@ -157,7 +150,7 @@ FGViewMgr::init ()
if ( strcmp("lookat",strdata.c_str()) == 0 ) if ( strcmp("lookat",strdata.c_str()) == 0 )
add_view(new FGViewer ( FG_LOOKAT, from_model, from_model_index, add_view(new FGViewer ( FG_LOOKAT, from_model, from_model_index,
at_model, at_model_index, at_model, at_model_index,
damp_alt, damp_roll, damp_pitch, damp_heading, damp_roll, damp_pitch, damp_heading,
x_offset_m, y_offset_m,z_offset_m, x_offset_m, y_offset_m,z_offset_m,
heading_offset_deg, pitch_offset_deg, heading_offset_deg, pitch_offset_deg,
roll_offset_deg, fov_deg, roll_offset_deg, fov_deg,
@ -165,7 +158,7 @@ FGViewMgr::init ()
target_z_offset_m, near_m )); target_z_offset_m, near_m ));
else else
add_view(new FGViewer ( FG_LOOKFROM, from_model, from_model_index, add_view(new FGViewer ( FG_LOOKFROM, from_model, from_model_index,
false, 0, 0.0, 0.0, 0.0, 0.0, false, 0, 0.0, 0.0, 0.0,
x_offset_m, y_offset_m, z_offset_m, x_offset_m, y_offset_m, z_offset_m,
heading_offset_deg, pitch_offset_deg, heading_offset_deg, pitch_offset_deg,
roll_offset_deg, fov_deg, 0, 0, 0, near_m )); roll_offset_deg, fov_deg, 0, 0, 0, near_m ));