KFM: changes on update method implies other changes. Still not that good. Note: objects motion timing can't be done using timers. On windows at least, those can have jitter of tens of ms

0.9.0-post-fixes
UbitUmarov 2017-07-17 00:58:35 +01:00
parent 59de8fbba0
commit f921ad005f
1 changed files with 25 additions and 13 deletions

View File

@ -295,6 +295,7 @@ namespace OpenSim.Region.Framework.Scenes
lock (m_frames) lock (m_frames)
{ {
KeyframeTimer.Add(this); KeyframeTimer.Add(this);
m_lasttickMS = Util.GetTimeStampMS();
m_timerStopped = false; m_timerStopped = false;
} }
} }
@ -651,10 +652,11 @@ namespace OpenSim.Region.Framework.Scenes
m_frames.Clear(); m_frames.Clear();
} }
Vector3 m_lastPosUpdate; [NonSerialized()] Vector3 m_lastPosUpdate;
Quaternion m_lastRotationUpdate; [NonSerialized()] Quaternion m_lastRotationUpdate;
Vector3 m_currentVel; [NonSerialized()] Vector3 m_currentVel;
int m_skippedUpdates; [NonSerialized()] int m_skippedUpdates;
[NonSerialized()] double m_lasttickMS;
private void DoOnTimer(double tickDuration) private void DoOnTimer(double tickDuration)
{ {
@ -699,6 +701,8 @@ namespace OpenSim.Region.Framework.Scenes
return; return;
} }
double nowMS = Util.GetTimeStampMS();
if (m_frames.Count == 0) if (m_frames.Count == 0)
{ {
lock (m_frames) lock (m_frames)
@ -719,10 +723,16 @@ namespace OpenSim.Region.Framework.Scenes
m_currentVel /= (m_currentFrame.TimeMS * 0.001f); m_currentVel /= (m_currentFrame.TimeMS * 0.001f);
m_currentFrame.TimeMS += (int)tickDuration; m_currentFrame.TimeMS += (int)tickDuration;
m_lasttickMS = nowMS - 50f;
update = true; update = true;
} }
m_currentFrame.TimeMS -= (int)tickDuration; int elapsed = (int)(nowMS - m_lasttickMS);
if( elapsed > 3 * tickDuration)
elapsed = (int)tickDuration;
m_currentFrame.TimeMS -= elapsed;
m_lasttickMS = nowMS;
// Do the frame processing // Do the frame processing
double remainingSteps = (double)m_currentFrame.TimeMS / tickDuration; double remainingSteps = (double)m_currentFrame.TimeMS / tickDuration;
@ -770,10 +780,12 @@ namespace OpenSim.Region.Framework.Scenes
Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, completed); Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, completed);
step.Normalize(); step.Normalize();
m_group.RootPart.RotationOffset = step; m_group.RootPart.RotationOffset = step;
/*
if (Math.Abs(step.X - m_lastRotationUpdate.X) > 0.001f if (Math.Abs(step.X - m_lastRotationUpdate.X) > 0.001f
|| Math.Abs(step.Y - m_lastRotationUpdate.Y) > 0.001f || Math.Abs(step.Y - m_lastRotationUpdate.Y) > 0.001f
|| Math.Abs(step.Z - m_lastRotationUpdate.Z) > 0.001f) || Math.Abs(step.Z - m_lastRotationUpdate.Z) > 0.001f)
update = true; update = true;
*/
} }
m_group.AbsolutePosition = m_nextPosition; m_group.AbsolutePosition = m_nextPosition;
@ -781,7 +793,7 @@ namespace OpenSim.Region.Framework.Scenes
// m_group.RootPart.Velocity = Vector3.Zero; // m_group.RootPart.Velocity = Vector3.Zero;
// else // else
m_group.RootPart.Velocity = m_currentVel; m_group.RootPart.Velocity = m_currentVel;
/*
if(!update && ( if(!update && (
// lastSteps || // lastSteps ||
m_skippedUpdates * tickDuration > 0.5 || m_skippedUpdates * tickDuration > 0.5 ||
@ -794,16 +806,16 @@ namespace OpenSim.Region.Framework.Scenes
} }
else else
m_skippedUpdates++; m_skippedUpdates++;
*/
} }
if(update) // if(update)
{ // {
m_lastPosUpdate = m_nextPosition; // m_lastPosUpdate = m_nextPosition;
m_lastRotationUpdate = m_group.GroupRotation; // m_lastRotationUpdate = m_group.GroupRotation;
m_skippedUpdates = 0; // m_skippedUpdates = 0;
// m_group.SendGroupRootTerseUpdate(); // m_group.SendGroupRootTerseUpdate();
m_group.RootPart.ScheduleTerseUpdate(); m_group.RootPart.ScheduleTerseUpdate();
} // }
} }
public Byte[] Serialize() public Byte[] Serialize()