remove creative hack and try to fix

avinationmerge
UbitUmarov 2014-08-13 18:52:13 +01:00
parent 3f0138c967
commit 483afe6867
1 changed files with 92 additions and 100 deletions

View File

@ -323,6 +323,8 @@ namespace OpenSim.Region.Framework.Scenes
m_group = grp;
m_scene = grp.Scene;
lock (m_frames)
{
Vector3 grppos = grp.AbsolutePosition;
Vector3 offset = grppos - m_serializedPosition;
// avoid doing it more than once
@ -338,7 +340,8 @@ namespace OpenSim.Region.Framework.Scenes
{
Keyframe k = m_frames[i];
k.Position += offset;
m_frames[i]=k;
m_frames[i] = k;
}
}
if (m_running)
@ -383,6 +386,8 @@ namespace OpenSim.Region.Framework.Scenes
m_keyframes.CopyTo(newmotion.m_keyframes, 0);
}
lock (m_frames)
{
newmotion.m_frames = new List<Keyframe>(m_frames);
newmotion.m_basePosition = m_basePosition;
@ -402,6 +407,7 @@ namespace OpenSim.Region.Framework.Scenes
newmotion.m_iterations = m_iterations;
newmotion.m_running = m_running;
}
if (m_running && !m_waitingCrossing)
StartTimer();
@ -520,7 +526,6 @@ namespace OpenSim.Region.Framework.Scenes
k.Position = pos;
// k.Velocity = Vector3.Zero;
}
k.AngularVelocity = (Vector3)k.Position;
k.StartRotation = rot;
if (k.Rotation.HasValue)
@ -653,6 +658,8 @@ namespace OpenSim.Region.Framework.Scenes
}
if (m_frames.Count == 0)
{
lock (m_frames)
{
GetNextList();
@ -674,7 +681,7 @@ namespace OpenSim.Region.Framework.Scenes
m_currentFrame = m_frames[0];
m_currentFrame.TimeMS += (int)tickDuration;
}
//force a update on a keyframe transition
update = true;
}
@ -689,16 +696,20 @@ namespace OpenSim.Region.Framework.Scenes
m_group.RootPart.Velocity = Vector3.Zero;
m_group.RootPart.AngularVelocity = Vector3.Zero;
m_nextPosition = NormalizeVector(m_currentFrame.AngularVelocity);
m_nextPosition = (Vector3)m_currentFrame.Position;
m_group.AbsolutePosition = m_nextPosition;
// we are sending imediate updates, no doing force a extra terseUpdate
// m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation);
m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation;
lock (m_frames)
{
m_frames.RemoveAt(0);
if (m_frames.Count > 0)
m_currentFrame = m_frames[0];
}
update = true;
}
@ -714,7 +725,6 @@ namespace OpenSim.Region.Framework.Scenes
{
// m_group.AbsolutePosition += motionThisFrame;
m_nextPosition = m_group.AbsolutePosition + motionThisFrame;
m_group.AbsolutePosition = m_nextPosition;
//m_group.RootPart.Velocity = v;
update = true;
@ -726,8 +736,8 @@ namespace OpenSim.Region.Framework.Scenes
Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete);
step.Normalize();
/* use simpler change detection
* float angle = 0;
/* use simpler change detection
* float angle = 0;
float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W;
float bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W;
@ -756,13 +766,13 @@ namespace OpenSim.Region.Framework.Scenes
}
if (angle > 0.01f)
*/
*/
if (Math.Abs(step.X - current.X) > 0.001f
|| Math.Abs(step.Y - current.Y) > 0.001f
|| Math.Abs(step.Z - current.Z) > 0.001f)
// assuming w is a dependente var
{
// m_group.UpdateGroupRotationR(step);
// m_group.UpdateGroupRotationR(step);
m_group.RootPart.RotationOffset = step;
//m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2);
@ -773,29 +783,11 @@ namespace OpenSim.Region.Framework.Scenes
if (update)
{
m_group.AbsolutePosition = m_nextPosition;
m_group.SendGroupRootTerseUpdate();
}
}
private Vector3 NormalizeVector(Vector3? pPosition)
{
if (pPosition == null)
return Vector3.Zero;
Vector3 tmp = (Vector3) pPosition;
while (tmp.X > Constants.RegionSize)
tmp.X -= Constants.RegionSize;
while (tmp.X < 0)
tmp.X += Constants.RegionSize;
while (tmp.Y > Constants.RegionSize)
tmp.Y -= Constants.RegionSize;
while (tmp.Y < 0)
tmp.Y += Constants.RegionSize;
return tmp;
}
public Byte[] Serialize()
{
StopTimer();