Updated SetPosition

- SetPosition now updates the aircraft's orientation after moving the aircraft
 - This should improve the handling of the aircraft when setting the position while paused and then unpausing
 - Fixes #91
This commit is contained in:
Jason Watkins
2016-06-20 09:57:59 -07:00
parent cdd218e71b
commit 35285cac2f

View File

@@ -680,6 +680,17 @@ namespace XPC
pos[2] = (float)GetDouble(DREF_Elevation, aircraft);
}
// See: http://www.xsquawkbox.net/xpsdk/mediawiki/MovingThePlane
// Need to get the aircraft's current orientation before moving and
// reset the orientation after moving to update the quaternion
float orient[3];
orient[0] = GetFloat(DREF_Pitch, aircraft);
orient[1] = GetFloat(DREF_Roll, aircraft);
orient[2] = GetFloat(DREF_HeadingTrue, aircraft);
// Now set the aircraft's position. Need to set world position for
// "long" moves, but since there isn't an easy way to calculate "long",
// we just set it every time.
double local[3];
XPLMWorldToLocal(pos[0], pos[1], pos[2], &local[0], &local[1], &local[2]);
// If the sim is paused, setting global position won't update the
@@ -691,6 +702,9 @@ namespace XPC
Set(DREF_Latitude, (double)pos[0], aircraft);
Set(DREF_Longitude, (double)pos[1], aircraft);
Set(DREF_Elevation, (double)pos[2], aircraft);
// Now reset orientation to update q
SetOrientation(orient, aircraft);
}
void DataManager::SetOrientation(float orient[3], char aircraft)