13-08-2021, 06:53 PM
Found the root of the problem
So with time.captureframerate set to say 30. FixedUpdate will run on a fixeddeltatime of 0.02 while the standard update loop will run on a deltatime of 0.0333
Which means obiFixedUpdater will be running the simulation approximately twice for some frames and once for some frames.
However when using the slow octane offline renderer fixedupdate effectively was getting run 333 times per update with fixeddeltatime for some reason being set all the way down to 0.0001
Of course if the simulation is running 333 times per frame floating point error etc.. is going to kick in.
So what I did was I fixed the number of times the simulation runs to a fixed number of twice per frame.
This fixes the issue.
So with time.captureframerate set to say 30. FixedUpdate will run on a fixeddeltatime of 0.02 while the standard update loop will run on a deltatime of 0.0333
Which means obiFixedUpdater will be running the simulation approximately twice for some frames and once for some frames.
However when using the slow octane offline renderer fixedupdate effectively was getting run 333 times per update with fixeddeltatime for some reason being set all the way down to 0.0001
Of course if the simulation is running 333 times per frame floating point error etc.. is going to kick in.
So what I did was I fixed the number of times the simulation runs to a fixed number of twice per frame.
This fixes the issue.
Code:
[color=#333333][size=small][font=Tahoma, Verdana, Arial, sans-serif] [/font][/size][/color]public bool UseCustomTime = false;
public float CustomTimeSteps = 2f;
public int LastNumItterations = 0;
public float LastAccumulatedTime = 0f;
public float LastDeltaTime = 0f;
private int NumItterations = 0;
private void FixedUpdate()
{
float TimeStepDelta;
if (UseCustomTime)
{
TimeStepDelta = (1f / Time.captureFramerate) / CustomTimeSteps;
}
else
{
TimeStepDelta = Time.fixedDeltaTime;
}
if (accumulatedTime > 0f)
{
ObiProfiler.EnableProfiler();
float substepDelta;
BeginStep(TimeStepDelta);
substepDelta = TimeStepDelta / (float)substeps;
// Divide the step into multiple smaller substeps:
for (int i = 0; i < substeps; ++i)
{
Substep(TimeStepDelta, substepDelta, substeps - i);
}
EndStep(substepDelta);
ObiProfiler.DisableProfiler();
accumulatedTime -= TimeStepDelta;
NumItterations += 1;
}
}
private void Update()
{
ObiProfiler.EnableProfiler();
Interpolate(Time.fixedDeltaTime, accumulatedTime);
ObiProfiler.DisableProfiler();
accumulatedTime += Time.deltaTime;
LastNumItterations = NumItterations;
LastAccumulatedTime = accumulatedTime;
LastDeltaTime = Time.deltaTime;
NumItterations = 0;
}