Hi everyone!
I am working on TerraBuilder’s Kennedy Space Center scenery update, which will feature on-demand rocket launches. Everything is falling into place nicely, except I have an odd problem when I dynamically update and set Lat,Lon,Alt of my rocket. Everything starts nice and smooth on the ground, but as the rocket climbs higher and higher, there are visible an annoying positional shifts and jitters, as if the higher I go, I am losing more and more precision. I’ve made 2 videos to illustrate the problem: In this one, the jitters start at about 1:10 into the launch and get worse and worse (sorry about crappy tracking, it is really hard to do it from the ground straight up)
And this next video (only 10 sec long) shows it more pronounced at higher altitudes: (again, sorry about the tracking all over the place )
Can anyone explain what is going on here? I am using a fairly simple SimConnect_SetDataOnSimObject call to set the Lat,Lon,Alt (after I compute the velocity vector) and I use doubles everywhere. It looks like a precision problem, but I can’t believe that the sim couldn’t handle a float value that represents values below a 100, and to a precision of a fraction of milimeter. Here are relevant code snippets:
struct Def_SimObject
{
double Latitude;
double Longitude;
double Altitude;
double Pitch;
double Bank;
double Heading;
};
...
hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_SIMOBJECT, "PLANE LATITUDE", "degrees latitude");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_SIMOBJECT, "PLANE LONGITUDE", "degrees longitude");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_SIMOBJECT, "PLANE ALTITUDE", "meters");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_SIMOBJECT, "PLANE PITCH DEGREES", "degrees");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_SIMOBJECT, "PLANE BANK DEGREES", "degrees");
hr = SimConnect_AddToDataDefinition(hSimConnect, DEF_SIMOBJECT, "PLANE HEADING DEGREES TRUE", "degrees");
...
Def_SimObject RocketInit;
RocketInit.Latitude = (double);
RocketInit.Longitude = (double);
RocketInit.Altitude = (double);
RocketInit.Bank = (double);
RocketInit.Heading = (double);
RocketInit.Pitch = (double);
hr = SimConnect_SetDataOnSimObject(hSimConnect, DEF_SIMOBJECT, LaunchData.LaunchObjectID, 0, 0, sizeof(RocketInit), &RocketInit);
The values I am setting (for example, RocketInit.Altitude) are absolute, not per-frame distance updates. That is, I am not obtaining the current position and attitude of the rocket and adding per-frame distance values. That was going to be the next thing I try, but it requires a bit of code reshuffle, and I thought I ask first, perhaps there is a simple solution. This is all in MSFS2020 (I came across a post that described a similar problem, but it was observed in MSFS2024, while MSFS2020 was working fine).
Oh, and if it matters - the object is viewed from a dev-mode developer camera, not sure if that makes a difference.
Thanks for any and all feedback or suggestions,
Mitch
TerraBuilder