[possible still very broken] mess around keyframes. timer events
threads overlaps, some null objects exceptions, region crossing...avinationmerge
parent
b1d0fab954
commit
ef6e007a4c
|
@ -1698,7 +1698,7 @@ namespace OpenSim.Data.MySQL
|
||||||
cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl);
|
cmd.Parameters.AddWithValue("MediaURL", prim.MediaUrl);
|
||||||
|
|
||||||
if (prim.KeyframeMotion != null)
|
if (prim.KeyframeMotion != null)
|
||||||
cmd.Parameters.AddWithValue("KeyframeMotion", prim.KeyframeMotion.Serialize());
|
cmd.Parameters.AddWithValue("KeyframeMotion", prim.KeyframeMotion.Serialize(true));
|
||||||
else
|
else
|
||||||
cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]);
|
cmd.Parameters.AddWithValue("KeyframeMotion", new Byte[0]);
|
||||||
|
|
||||||
|
|
|
@ -1855,6 +1855,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
if (grp.RootPart.PhysActor != null)
|
if (grp.RootPart.PhysActor != null)
|
||||||
grp.RootPart.PhysActor.CrossingFailure();
|
grp.RootPart.PhysActor.CrossingFailure();
|
||||||
|
|
||||||
|
if (grp.RootPart.KeyframeMotion != null)
|
||||||
|
grp.RootPart.KeyframeMotion.CrossingFailure();
|
||||||
|
|
||||||
grp.ScheduleGroupForFullUpdate();
|
grp.ScheduleGroupForFullUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1910,8 +1913,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
grp, e);
|
grp, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
* done on caller ( not in attachments crossing for now)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!grp.IsDeleted)
|
if (!grp.IsDeleted)
|
||||||
{
|
{
|
||||||
PhysicsActor pa = grp.RootPart.PhysActor;
|
PhysicsActor pa = grp.RootPart.PhysActor;
|
||||||
|
@ -1920,15 +1926,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
|
||||||
pa.CrossingFailure();
|
pa.CrossingFailure();
|
||||||
if (grp.RootPart.KeyframeMotion != null)
|
if (grp.RootPart.KeyframeMotion != null)
|
||||||
{
|
{
|
||||||
grp.RootPart.Velocity = Vector3.Zero;
|
// moved to KeyframeMotion.CrossingFailure
|
||||||
|
// grp.RootPart.Velocity = Vector3.Zero;
|
||||||
grp.RootPart.KeyframeMotion.CrossingFailure();
|
grp.RootPart.KeyframeMotion.CrossingFailure();
|
||||||
grp.SendGroupRootTerseUpdate();
|
// grp.SendGroupRootTerseUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp);
|
m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -58,12 +58,31 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
private Vector3 m_serializedPosition;
|
private Vector3 m_serializedPosition;
|
||||||
|
|
||||||
private Keyframe m_currentFrame;
|
private Keyframe m_currentFrame;
|
||||||
|
|
||||||
private List<Keyframe> m_frames = new List<Keyframe>();
|
private List<Keyframe> m_frames = new List<Keyframe>();
|
||||||
|
|
||||||
private Keyframe[] m_keyframes;
|
private Keyframe[] m_keyframes;
|
||||||
|
|
||||||
[NonSerialized()]
|
[NonSerialized()]
|
||||||
protected Timer m_timer = new Timer();
|
protected Timer m_timer = null;
|
||||||
|
|
||||||
|
// timer lock
|
||||||
|
[NonSerialized()]
|
||||||
|
private object m_onTimerLock;
|
||||||
|
|
||||||
|
// timer overrun detect
|
||||||
|
// prevents overlap or timer events threads frozen on the lock
|
||||||
|
[NonSerialized()]
|
||||||
|
private bool m_inOnTimer;
|
||||||
|
|
||||||
|
// skip timer events.
|
||||||
|
//timer.stop doesn't assure there aren't event threads still being fired
|
||||||
|
[NonSerialized()]
|
||||||
|
private bool m_skipOnTimer;
|
||||||
|
|
||||||
|
// retry position for cross fail
|
||||||
|
[NonSerialized()]
|
||||||
|
private Vector3 m_nextPosition;
|
||||||
|
|
||||||
[NonSerialized()]
|
[NonSerialized()]
|
||||||
private SceneObjectGroup m_group;
|
private SceneObjectGroup m_group;
|
||||||
|
@ -88,7 +107,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (value)
|
if (!value)
|
||||||
{
|
{
|
||||||
// Once we're let go, recompute positions
|
// Once we're let go, recompute positions
|
||||||
if (m_selected)
|
if (m_selected)
|
||||||
|
@ -100,7 +119,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
if (!m_selected)
|
if (!m_selected)
|
||||||
m_serializedPosition = m_group.AbsolutePosition;
|
m_serializedPosition = m_group.AbsolutePosition;
|
||||||
}
|
}
|
||||||
m_selected = value; }
|
m_selected = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data)
|
public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data)
|
||||||
|
@ -111,31 +131,65 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
KeyframeMotion newMotion = (KeyframeMotion)fmt.Deserialize(ms);
|
KeyframeMotion newMotion = (KeyframeMotion)fmt.Deserialize(ms);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* create timer in start()
|
||||||
|
* this was creating unneeded timers
|
||||||
|
|
||||||
// This will be started when position is updated
|
// This will be started when position is updated
|
||||||
|
|
||||||
newMotion.m_timer = new Timer();
|
newMotion.m_timer = new Timer();
|
||||||
newMotion.m_timer.Interval = (int)timerInterval;
|
newMotion.m_timer.Interval = (int)timerInterval;
|
||||||
newMotion.m_timer.AutoReset = true;
|
newMotion.m_timer.AutoReset = true;
|
||||||
newMotion.m_timer.Elapsed += newMotion.OnTimer;
|
newMotion.m_timer.Elapsed += newMotion.OnTimer;
|
||||||
|
*/
|
||||||
|
newMotion.m_group = grp;
|
||||||
|
|
||||||
|
if (grp != null && grp.IsSelected)
|
||||||
|
newMotion.m_selected = true;
|
||||||
|
|
||||||
|
newMotion.m_onTimerLock = new object();
|
||||||
|
newMotion.m_skipOnTimer = false;
|
||||||
|
newMotion.m_inOnTimer = false;
|
||||||
return newMotion;
|
return newMotion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateSceneObject(SceneObjectGroup grp)
|
public void UpdateSceneObject(SceneObjectGroup grp)
|
||||||
{
|
{
|
||||||
m_group = grp;
|
// lock (m_onTimerLock)
|
||||||
Vector3 offset = grp.AbsolutePosition - m_serializedPosition;
|
|
||||||
|
|
||||||
m_basePosition += offset;
|
|
||||||
m_currentFrame.Position += offset;
|
|
||||||
for (int i = 0 ; i < m_frames.Count ; i++)
|
|
||||||
{
|
{
|
||||||
Keyframe k = m_frames[i];
|
m_skipOnTimer = true;
|
||||||
k.Position += offset;
|
if (m_timer != null)
|
||||||
m_frames[i] = k;
|
m_timer.Stop();
|
||||||
}
|
|
||||||
|
|
||||||
if (m_running)
|
m_group = grp;
|
||||||
Start();
|
Vector3 grppos = grp.AbsolutePosition;
|
||||||
|
Vector3 offset = grppos - m_serializedPosition;
|
||||||
|
// avoid doing it more than once
|
||||||
|
// current this will happen draging a prim to other region
|
||||||
|
m_serializedPosition = grppos;
|
||||||
|
|
||||||
|
m_basePosition += offset;
|
||||||
|
m_currentFrame.Position += offset;
|
||||||
|
|
||||||
|
m_nextPosition += offset;
|
||||||
|
/*
|
||||||
|
for (int i = 0; i < m_frames.Count; i++)
|
||||||
|
{
|
||||||
|
Keyframe k = m_frames[i];
|
||||||
|
k.Position += offset;
|
||||||
|
m_frames[i] = k;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
for (int i = 0; i < m_frames.Count; i++)
|
||||||
|
{
|
||||||
|
Keyframe k = m_frames[i];
|
||||||
|
k.Position += offset;
|
||||||
|
m_frames[i]=k;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_running)
|
||||||
|
Start();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public KeyframeMotion(SceneObjectGroup grp, PlayMode mode, DataFormat data)
|
public KeyframeMotion(SceneObjectGroup grp, PlayMode mode, DataFormat data)
|
||||||
|
@ -143,13 +197,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_mode = mode;
|
m_mode = mode;
|
||||||
m_data = data;
|
m_data = data;
|
||||||
|
|
||||||
|
m_onTimerLock = new object();
|
||||||
|
|
||||||
m_group = grp;
|
m_group = grp;
|
||||||
m_basePosition = grp.AbsolutePosition;
|
m_basePosition = grp.AbsolutePosition;
|
||||||
m_baseRotation = grp.GroupRotation;
|
m_baseRotation = grp.GroupRotation;
|
||||||
|
/*
|
||||||
m_timer.Interval = (int)timerInterval;
|
m_timer.Interval = (int)timerInterval;
|
||||||
m_timer.AutoReset = true;
|
m_timer.AutoReset = true;
|
||||||
m_timer.Elapsed += OnTimer;
|
m_timer.Elapsed += OnTimer;
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetKeyframes(Keyframe[] frames)
|
public void SetKeyframes(Keyframe[] frames)
|
||||||
|
@ -157,19 +214,63 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_keyframes = frames;
|
m_keyframes = frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Delete()
|
||||||
|
{
|
||||||
|
m_skipOnTimer = true;
|
||||||
|
m_frames.Clear();
|
||||||
|
m_keyframes = null;
|
||||||
|
m_running = false;
|
||||||
|
|
||||||
|
if (m_timer == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_timer.Stop();
|
||||||
|
m_timer.Elapsed -= OnTimer;
|
||||||
|
m_timer = null;
|
||||||
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
if (m_keyframes.Length > 0)
|
if (m_keyframes.Length > 0)
|
||||||
|
{
|
||||||
|
if (m_timer == null)
|
||||||
|
{
|
||||||
|
m_timer = new Timer();
|
||||||
|
m_timer.Interval = (int)timerInterval;
|
||||||
|
m_timer.AutoReset = true;
|
||||||
|
m_timer.Elapsed += OnTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_skipOnTimer = false;
|
||||||
|
m_inOnTimer = false;
|
||||||
|
|
||||||
m_timer.Start();
|
m_timer.Start();
|
||||||
m_running = true;
|
m_running = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_running = false;
|
||||||
|
m_skipOnTimer = true;
|
||||||
|
if (m_timer != null)
|
||||||
|
{
|
||||||
|
m_timer.Stop();
|
||||||
|
m_timer.Elapsed -= OnTimer;
|
||||||
|
m_timer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
|
m_skipOnTimer = true;
|
||||||
|
|
||||||
// Failed object creation
|
// Failed object creation
|
||||||
if (m_timer == null)
|
if (m_timer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_timer.Stop();
|
m_timer.Stop();
|
||||||
|
m_timer.Elapsed -= OnTimer;
|
||||||
|
m_timer = null;
|
||||||
|
|
||||||
m_basePosition = m_group.AbsolutePosition;
|
m_basePosition = m_group.AbsolutePosition;
|
||||||
m_baseRotation = m_group.GroupRotation;
|
m_baseRotation = m_group.GroupRotation;
|
||||||
|
@ -184,6 +285,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public void Pause()
|
public void Pause()
|
||||||
{
|
{
|
||||||
|
m_skipOnTimer = true;
|
||||||
|
|
||||||
m_group.RootPart.Velocity = Vector3.Zero;
|
m_group.RootPart.Velocity = Vector3.Zero;
|
||||||
m_group.RootPart.UpdateAngularVelocity(Vector3.Zero);
|
m_group.RootPart.UpdateAngularVelocity(Vector3.Zero);
|
||||||
m_group.SendGroupRootTerseUpdate();
|
m_group.SendGroupRootTerseUpdate();
|
||||||
|
@ -284,138 +387,197 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
protected void OnTimer(object sender, ElapsedEventArgs e)
|
protected void OnTimer(object sender, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
if (m_frames.Count == 0)
|
if (m_inOnTimer)
|
||||||
{
|
{
|
||||||
GetNextList();
|
m_log.Error("[KeyFrame]: timer overrun");
|
||||||
|
|
||||||
if (m_frames.Count == 0)
|
|
||||||
{
|
|
||||||
Stop();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
m_currentFrame = m_frames[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_selected)
|
|
||||||
{
|
|
||||||
if (m_group.RootPart.Velocity != Vector3.Zero)
|
|
||||||
{
|
|
||||||
m_group.RootPart.Velocity = Vector3.Zero;
|
|
||||||
m_group.SendGroupRootTerseUpdate();
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do the frame processing
|
// lock (m_onTimerLock)
|
||||||
double steps = (double)m_currentFrame.TimeMS / timerInterval;
|
|
||||||
float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal;
|
|
||||||
|
|
||||||
if (steps <= 1.0)
|
|
||||||
{
|
{
|
||||||
m_currentFrame.TimeMS = 0;
|
if (m_skipOnTimer)
|
||||||
|
return;
|
||||||
|
|
||||||
m_group.AbsolutePosition = (Vector3)m_currentFrame.Position;
|
m_inOnTimer = true;
|
||||||
m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation);
|
try
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition;
|
|
||||||
Vector3 motionThisFrame = v / (float)steps;
|
|
||||||
v = v * 1000 / m_currentFrame.TimeMS;
|
|
||||||
|
|
||||||
bool update = false;
|
|
||||||
|
|
||||||
if (Vector3.Mag(motionThisFrame) >= 0.05f)
|
|
||||||
{
|
{
|
||||||
m_group.AbsolutePosition += motionThisFrame;
|
if (m_frames.Count == 0)
|
||||||
m_group.RootPart.Velocity = v;
|
|
||||||
update = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((Quaternion)m_currentFrame.Rotation != m_group.GroupRotation)
|
|
||||||
{
|
|
||||||
Quaternion current = m_group.GroupRotation;
|
|
||||||
|
|
||||||
Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete);
|
|
||||||
|
|
||||||
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;
|
|
||||||
float aa_bb = aa * bb;
|
|
||||||
|
|
||||||
if (aa_bb == 0)
|
|
||||||
{
|
{
|
||||||
angle = 0;
|
GetNextList();
|
||||||
|
|
||||||
|
if (m_frames.Count == 0)
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
m_inOnTimer = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_currentFrame = m_frames[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_selected)
|
||||||
|
{
|
||||||
|
if (m_group.RootPart.Velocity != Vector3.Zero)
|
||||||
|
{
|
||||||
|
m_group.RootPart.Velocity = Vector3.Zero;
|
||||||
|
m_group.SendGroupRootTerseUpdate();
|
||||||
|
}
|
||||||
|
m_inOnTimer = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do the frame processing
|
||||||
|
double steps = (double)m_currentFrame.TimeMS / timerInterval;
|
||||||
|
float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal;
|
||||||
|
|
||||||
|
if (steps <= 1.0)
|
||||||
|
{
|
||||||
|
m_currentFrame.TimeMS = 0;
|
||||||
|
|
||||||
|
// m_group.AbsolutePosition = (Vector3)m_currentFrame.Position;
|
||||||
|
m_nextPosition = (Vector3)m_currentFrame.Position;
|
||||||
|
m_group.AbsolutePosition = m_nextPosition;
|
||||||
|
|
||||||
|
m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
float ab = current.X * step.X +
|
Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition;
|
||||||
current.Y * step.Y +
|
Vector3 motionThisFrame = v / (float)steps;
|
||||||
current.Z * step.Z +
|
v = v * 1000 / m_currentFrame.TimeMS;
|
||||||
current.W * step.W;
|
|
||||||
float q = (ab * ab) / aa_bb;
|
|
||||||
|
|
||||||
if (q > 1.0f)
|
bool update = false;
|
||||||
|
|
||||||
|
if (Vector3.Mag(motionThisFrame) >= 0.05f)
|
||||||
{
|
{
|
||||||
angle = 0;
|
// m_group.AbsolutePosition += motionThisFrame;
|
||||||
|
m_nextPosition = m_group.AbsolutePosition + motionThisFrame;
|
||||||
|
m_group.AbsolutePosition = m_nextPosition;
|
||||||
|
|
||||||
|
m_group.RootPart.Velocity = v;
|
||||||
|
update = true;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if ((Quaternion)m_currentFrame.Rotation != m_group.GroupRotation)
|
||||||
{
|
{
|
||||||
angle = (float)Math.Acos(2 * q - 1);
|
Quaternion current = m_group.GroupRotation;
|
||||||
|
|
||||||
|
Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete);
|
||||||
|
|
||||||
|
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;
|
||||||
|
float aa_bb = aa * bb;
|
||||||
|
|
||||||
|
if (aa_bb == 0)
|
||||||
|
{
|
||||||
|
angle = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
float ab = current.X * step.X +
|
||||||
|
current.Y * step.Y +
|
||||||
|
current.Z * step.Z +
|
||||||
|
current.W * step.W;
|
||||||
|
float q = (ab * ab) / aa_bb;
|
||||||
|
|
||||||
|
if (q > 1.0f)
|
||||||
|
{
|
||||||
|
angle = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
angle = (float)Math.Acos(2 * q - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (angle > 0.01f)
|
||||||
|
{
|
||||||
|
m_group.UpdateGroupRotationR(step);
|
||||||
|
//m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2);
|
||||||
|
update = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (update)
|
||||||
|
m_group.SendGroupRootTerseUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (angle > 0.01f)
|
m_currentFrame.TimeMS -= (int)timerInterval;
|
||||||
|
|
||||||
|
if (m_currentFrame.TimeMS <= 0)
|
||||||
{
|
{
|
||||||
m_group.UpdateGroupRotationR(step);
|
m_group.RootPart.Velocity = Vector3.Zero;
|
||||||
//m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2);
|
m_group.RootPart.UpdateAngularVelocity(Vector3.Zero);
|
||||||
update = true;
|
m_group.SendGroupRootTerseUpdate();
|
||||||
|
|
||||||
|
m_frames.RemoveAt(0);
|
||||||
|
if (m_frames.Count > 0)
|
||||||
|
m_currentFrame = m_frames[0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
if (update)
|
{
|
||||||
m_group.SendGroupRootTerseUpdate();
|
m_inOnTimer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentFrame.TimeMS -= (int)timerInterval;
|
|
||||||
|
|
||||||
if (m_currentFrame.TimeMS <= 0)
|
|
||||||
{
|
|
||||||
m_group.RootPart.Velocity = Vector3.Zero;
|
|
||||||
m_group.RootPart.UpdateAngularVelocity(Vector3.Zero);
|
|
||||||
m_group.SendGroupRootTerseUpdate();
|
|
||||||
|
|
||||||
m_frames.RemoveAt(0);
|
|
||||||
if (m_frames.Count > 0)
|
|
||||||
m_currentFrame = m_frames[0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Byte[] Serialize()
|
public Byte[] Serialize(bool StopMoveTimer)
|
||||||
{
|
{
|
||||||
MemoryStream ms = new MemoryStream();
|
MemoryStream ms = new MemoryStream();
|
||||||
m_timer.Stop();
|
if (StopMoveTimer && m_timer != null)
|
||||||
|
{
|
||||||
|
m_skipOnTimer = true;
|
||||||
|
m_timer.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
BinaryFormatter fmt = new BinaryFormatter();
|
// lock (m_onTimerLock)
|
||||||
SceneObjectGroup tmp = m_group;
|
{
|
||||||
m_group = null;
|
BinaryFormatter fmt = new BinaryFormatter();
|
||||||
m_serializedPosition = tmp.AbsolutePosition;
|
SceneObjectGroup tmp = m_group;
|
||||||
fmt.Serialize(ms, this);
|
m_group = null;
|
||||||
m_group = tmp;
|
if(!m_selected)
|
||||||
return ms.ToArray();
|
m_serializedPosition = tmp.AbsolutePosition;
|
||||||
|
fmt.Serialize(ms, this);
|
||||||
|
m_group = tmp;
|
||||||
|
return ms.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartCrossingCheck()
|
||||||
|
{
|
||||||
|
m_skipOnTimer = true;
|
||||||
|
if (m_timer != null)
|
||||||
|
m_timer.Stop();
|
||||||
|
|
||||||
|
if (m_group.RootPart.Velocity != Vector3.Zero)
|
||||||
|
{
|
||||||
|
m_group.RootPart.Velocity = Vector3.Zero;
|
||||||
|
m_group.SendGroupRootTerseUpdate();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CrossingFailure()
|
public void CrossingFailure()
|
||||||
{
|
{
|
||||||
// The serialization has stopped the timer, so let's wait a moment
|
// The serialization has stopped the timer, so let's wait a moment
|
||||||
// then retry the crossing. We'll get back here if it fails.
|
// then retry the crossing. We'll get back here if it fails.
|
||||||
|
// if it is a open border there is no serialization
|
||||||
|
// so make sure timer is actually stopped
|
||||||
|
|
||||||
|
m_group.RootPart.Velocity = Vector3.Zero;
|
||||||
|
m_group.SendGroupRootTerseUpdate();
|
||||||
|
|
||||||
Util.FireAndForget(delegate (object x)
|
Util.FireAndForget(delegate (object x)
|
||||||
{
|
{
|
||||||
Thread.Sleep(60000);
|
Thread.Sleep(60000);
|
||||||
if (m_running)
|
if (m_running)
|
||||||
|
{
|
||||||
|
m_skipOnTimer = false;
|
||||||
m_timer.Start();
|
m_timer.Start();
|
||||||
|
m_group.AbsolutePosition = m_nextPosition;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2346,6 +2346,12 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
foreach (SceneObjectPart part in partList)
|
foreach (SceneObjectPart part in partList)
|
||||||
{
|
{
|
||||||
|
if (part.KeyframeMotion != null)
|
||||||
|
{
|
||||||
|
part.KeyframeMotion.Delete();
|
||||||
|
part.KeyframeMotion = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0))
|
if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0))
|
||||||
{
|
{
|
||||||
PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?
|
PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?
|
||||||
|
|
|
@ -509,6 +509,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
Vector3 newpos = Vector3.Zero;
|
Vector3 newpos = Vector3.Zero;
|
||||||
OpenSim.Services.Interfaces.GridRegion destination = null;
|
OpenSim.Services.Interfaces.GridRegion destination = null;
|
||||||
|
|
||||||
|
if (m_rootPart.KeyframeMotion != null)
|
||||||
|
m_rootPart.KeyframeMotion.StartCrossingCheck();
|
||||||
|
|
||||||
bool canCross = true;
|
bool canCross = true;
|
||||||
foreach (ScenePresence av in m_linkedAvatars)
|
foreach (ScenePresence av in m_linkedAvatars)
|
||||||
{
|
{
|
||||||
|
@ -551,7 +554,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
av.ParentID = 0;
|
av.ParentID = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// m_linkedAvatars.Clear();
|
// m_linkedAvatars.Clear();
|
||||||
m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
|
m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
|
||||||
|
|
||||||
// Normalize
|
// Normalize
|
||||||
|
@ -599,11 +602,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
avsToCross.Clear();
|
avsToCross.Clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (RootPart.PhysActor != null)
|
else
|
||||||
{
|
{
|
||||||
RootPart.PhysActor.CrossingFailure();
|
if (m_rootPart.KeyframeMotion != null)
|
||||||
}
|
m_rootPart.KeyframeMotion.CrossingFailure();
|
||||||
|
|
||||||
|
if (RootPart.PhysActor != null)
|
||||||
|
{
|
||||||
|
RootPart.PhysActor.CrossingFailure();
|
||||||
|
}
|
||||||
|
}
|
||||||
Vector3 oldp = AbsolutePosition;
|
Vector3 oldp = AbsolutePosition;
|
||||||
val.X = Util.Clamp<float>(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f);
|
val.X = Util.Clamp<float>(oldp.X, 0.5f, (float)Constants.RegionSize - 0.5f);
|
||||||
val.Y = Util.Clamp<float>(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f);
|
val.Y = Util.Clamp<float>(oldp.Y, 0.5f, (float)Constants.RegionSize - 0.5f);
|
||||||
|
@ -2058,8 +2066,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
if (part.KeyframeMotion != null)
|
if (part.KeyframeMotion != null)
|
||||||
{
|
{
|
||||||
part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize());
|
part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize(false));
|
||||||
part.KeyframeMotion.UpdateSceneObject(this);
|
// part.KeyframeMotion.UpdateSceneObject(this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4407,6 +4415,15 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public virtual ISceneObject CloneForNewScene()
|
public virtual ISceneObject CloneForNewScene()
|
||||||
{
|
{
|
||||||
SceneObjectGroup sog = Copy(false);
|
SceneObjectGroup sog = Copy(false);
|
||||||
|
sog.ForEachPart(delegate(SceneObjectPart part)
|
||||||
|
{
|
||||||
|
if (part.KeyframeMotion != null)
|
||||||
|
{
|
||||||
|
part.KeyframeMotion = KeyframeMotion.FromData(sog, part.KeyframeMotion.Serialize(true));
|
||||||
|
// this is called later
|
||||||
|
// part.KeyframeMotion.UpdateSceneObject(this);
|
||||||
|
}
|
||||||
|
});
|
||||||
sog.IsDeleted = false;
|
sog.IsDeleted = false;
|
||||||
return sog;
|
return sog;
|
||||||
}
|
}
|
||||||
|
|
|
@ -769,7 +769,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
m_groupPosition = value;
|
m_groupPosition = value;
|
||||||
PhysicsActor actor = PhysActor;
|
PhysicsActor actor = PhysActor;
|
||||||
if (actor != null)
|
if (actor != null && ParentGroup.Scene.PhysicsScene != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -3408,6 +3408,9 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void SendTerseUpdateToAllClients()
|
public void SendTerseUpdateToAllClients()
|
||||||
{
|
{
|
||||||
|
if (ParentGroup == null || ParentGroup.Scene == null)
|
||||||
|
return;
|
||||||
|
|
||||||
ParentGroup.Scene.ForEachClient(delegate(IClientAPI client)
|
ParentGroup.Scene.ForEachClient(delegate(IClientAPI client)
|
||||||
{
|
{
|
||||||
SendTerseUpdateToClient(client);
|
SendTerseUpdateToClient(client);
|
||||||
|
|
|
@ -1241,7 +1241,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
|
|
||||||
if (sog.RootPart.KeyframeMotion != null)
|
if (sog.RootPart.KeyframeMotion != null)
|
||||||
{
|
{
|
||||||
Byte[] data = sog.RootPart.KeyframeMotion.Serialize();
|
Byte[] data = sog.RootPart.KeyframeMotion.Serialize(true);
|
||||||
|
|
||||||
writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty);
|
writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty);
|
||||||
writer.WriteBase64(data, 0, data.Length);
|
writer.WriteBase64(data, 0, data.Length);
|
||||||
|
|
|
@ -12963,7 +12963,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
if (frames.Data.Length > 0) // We are getting a new motion
|
if (frames.Data.Length > 0) // We are getting a new motion
|
||||||
{
|
{
|
||||||
if (group.RootPart.KeyframeMotion != null)
|
if (group.RootPart.KeyframeMotion != null)
|
||||||
group.RootPart.KeyframeMotion.Stop();
|
group.RootPart.KeyframeMotion.Delete();
|
||||||
group.RootPart.KeyframeMotion = null;
|
group.RootPart.KeyframeMotion = null;
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
|
Loading…
Reference in New Issue