I am having big problems with RTU and his IHP replacement, if dgatsoulis can bring me the changes to the code, I'll see if I can compile a custom version of the DLL.
I thought of an even simpler way to fix the time-accel problem. It should work in exactly the same way the IronHill.dll works -the one the others are already using- but with less lines of code.
In the Orbitersdk\Samples\RealTimeUpdate\main.cpp find these lines:
Code:
DLLCLBK void opcPreStep(double SimT, double SimDT, double mjd)
{
if(TimeWarp == true )
{
sprintf(oapiDebugString(), "Accelerating, Please Wait...");
double DeltaT = TargetMJD - mjd;
// Convert DeltaT to seconds
DeltaT *= 60*60*24;
if(DeltaT < 0.1)
{
TimeWarp = false;
oapiSetTimeAcceleration(1.0);
return;
}
oapiSetTimeAcceleration(DeltaT + 1);
} else sprintf(oapiDebugString(), "");
}
DeltaT is the difference in seconds from the last time the scenario was run to the current date.
The source of the problem is that oapiSetTimeAcceleration(DeltaT + 1) instantaniously sets the timewarp to whatever value the DeltaT has (+1) and this tends to fling landed ships into space, especially on medium/slow PCs with slow framerate.
To fix that, I introduced another timer that starts counting the SimTime when you run the scenario and changed the TimeAccel function into something that has a smooth curve, instead of a straight line that starts high and then drops as DeltaT gets smaller :
If we call the DeltaT (a) and the SimTime (b), we can see that (a) has a big value that gets smaller as the TimeAccel progresses, while the opposite happens for (b).
During time T from previous scenario:
(a) = big number→small number
(b) = small number→big number
We can use this function to get a smooth TimeAccel:
So the code turns into:
Code:
DLLCLBK void opcPreStep(double SimT, double SimDT, double mjd)
{
if(TimeWarp == true )
{
sprintf(oapiDebugString(), "Accelerating, Please Wait...");
double DeltaT = TargetMJD - mjd;
double DT = oapiGetSimTime();
// Convert DeltaT to seconds
DeltaT *= 60*60*24;
if(DeltaT > 0.1)
{
oapiSetTimeAcceleration((DeltaT*DT/(DeltaT+DT))+1);
}
if(DeltaT < 0.1)
{
TimeWarp = false;
oapiSetTimeAcceleration(1.0);
return;
}
} else sprintf(oapiDebugString(), "");
}
Compile it and run a test scenario. It should produce a smooth timewarp that goes like this: normal→big→bigger→biggest→bigger→big→normal.