Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork
commit
f671e446bf
|
@ -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
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,17 +53,42 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public Vector3 AngularVelocity;
|
public Vector3 AngularVelocity;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private Vector3 m_serializedPosition;
|
||||||
private Vector3 m_basePosition;
|
private Vector3 m_basePosition;
|
||||||
private Quaternion m_baseRotation;
|
private Quaternion m_baseRotation;
|
||||||
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_timerStopped;
|
||||||
|
|
||||||
|
[NonSerialized()]
|
||||||
|
private bool m_isCrossing;
|
||||||
|
|
||||||
|
[NonSerialized()]
|
||||||
|
private bool m_waitingCrossing;
|
||||||
|
|
||||||
|
// retry position for cross fail
|
||||||
|
[NonSerialized()]
|
||||||
|
private Vector3 m_nextPosition;
|
||||||
|
|
||||||
[NonSerialized()]
|
[NonSerialized()]
|
||||||
private SceneObjectGroup m_group;
|
private SceneObjectGroup m_group;
|
||||||
|
@ -88,7 +113,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)
|
||||||
|
@ -98,35 +123,94 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
{
|
{
|
||||||
// Save selection position in case we get moved
|
// Save selection position in case we get moved
|
||||||
if (!m_selected)
|
if (!m_selected)
|
||||||
|
{
|
||||||
|
StopTimer();
|
||||||
m_serializedPosition = m_group.AbsolutePosition;
|
m_serializedPosition = m_group.AbsolutePosition;
|
||||||
}
|
}
|
||||||
m_selected = value; }
|
|
||||||
}
|
}
|
||||||
|
m_isCrossing = false;
|
||||||
|
m_waitingCrossing = false;
|
||||||
|
m_selected = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StartTimer()
|
||||||
|
{
|
||||||
|
if (m_timer == null)
|
||||||
|
return;
|
||||||
|
m_timerStopped = false;
|
||||||
|
m_timer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void StopTimer()
|
||||||
|
{
|
||||||
|
if (m_timer == null || m_timerStopped)
|
||||||
|
return;
|
||||||
|
m_timerStopped = true;
|
||||||
|
m_timer.Stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void RemoveTimer()
|
||||||
|
{
|
||||||
|
if (m_timer == null)
|
||||||
|
return;
|
||||||
|
m_timerStopped = true;
|
||||||
|
m_timer.Stop();
|
||||||
|
m_timer.Elapsed -= OnTimer;
|
||||||
|
m_timer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data)
|
public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data)
|
||||||
{
|
{
|
||||||
MemoryStream ms = new MemoryStream(data);
|
KeyframeMotion newMotion = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MemoryStream ms = new MemoryStream(data);
|
||||||
BinaryFormatter fmt = new BinaryFormatter();
|
BinaryFormatter fmt = new BinaryFormatter();
|
||||||
|
|
||||||
KeyframeMotion newMotion = (KeyframeMotion)fmt.Deserialize(ms);
|
newMotion = (KeyframeMotion)fmt.Deserialize(ms);
|
||||||
|
|
||||||
// This will be started when position is updated
|
newMotion.m_group = grp;
|
||||||
newMotion.m_timer = new Timer();
|
|
||||||
newMotion.m_timer.Interval = (int)timerInterval;
|
if (grp != null && grp.IsSelected)
|
||||||
newMotion.m_timer.AutoReset = true;
|
newMotion.m_selected = true;
|
||||||
newMotion.m_timer.Elapsed += newMotion.OnTimer;
|
|
||||||
|
newMotion.m_onTimerLock = new object();
|
||||||
|
newMotion.m_timerStopped = false;
|
||||||
|
newMotion.m_inOnTimer = false;
|
||||||
|
newMotion.m_isCrossing = false;
|
||||||
|
newMotion.m_waitingCrossing = false;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
newMotion = null;
|
||||||
|
}
|
||||||
|
|
||||||
return newMotion;
|
return newMotion;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateSceneObject(SceneObjectGroup grp)
|
public void UpdateSceneObject(SceneObjectGroup grp)
|
||||||
{
|
{
|
||||||
|
// lock (m_onTimerLock)
|
||||||
|
{
|
||||||
|
m_isCrossing = false;
|
||||||
|
m_waitingCrossing = false;
|
||||||
|
StopTimer();
|
||||||
|
|
||||||
m_group = grp;
|
m_group = grp;
|
||||||
Vector3 offset = grp.AbsolutePosition - m_serializedPosition;
|
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_basePosition += offset;
|
||||||
m_currentFrame.Position += offset;
|
m_currentFrame.Position += offset;
|
||||||
|
|
||||||
|
m_nextPosition += offset;
|
||||||
|
|
||||||
for (int i = 0; i < m_frames.Count; i++)
|
for (int i = 0; i < m_frames.Count; i++)
|
||||||
{
|
{
|
||||||
Keyframe k = m_frames[i];
|
Keyframe k = m_frames[i];
|
||||||
|
@ -137,19 +221,23 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
if (m_running)
|
if (m_running)
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public KeyframeMotion(SceneObjectGroup grp, PlayMode mode, DataFormat data)
|
public KeyframeMotion(SceneObjectGroup grp, PlayMode mode, DataFormat data)
|
||||||
{
|
{
|
||||||
m_mode = mode;
|
m_mode = mode;
|
||||||
m_data = data;
|
m_data = data;
|
||||||
|
|
||||||
|
m_onTimerLock = new object();
|
||||||
|
|
||||||
m_group = grp;
|
m_group = grp;
|
||||||
|
if (grp != null)
|
||||||
|
{
|
||||||
m_basePosition = grp.AbsolutePosition;
|
m_basePosition = grp.AbsolutePosition;
|
||||||
m_baseRotation = grp.GroupRotation;
|
m_baseRotation = grp.GroupRotation;
|
||||||
|
}
|
||||||
m_timer.Interval = (int)timerInterval;
|
m_isCrossing = false;
|
||||||
m_timer.AutoReset = true;
|
m_waitingCrossing = false;
|
||||||
m_timer.Elapsed += OnTimer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetKeyframes(Keyframe[] frames)
|
public void SetKeyframes(Keyframe[] frames)
|
||||||
|
@ -157,19 +245,93 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_keyframes = frames;
|
m_keyframes = frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public KeyframeMotion Copy(SceneObjectGroup newgrp)
|
||||||
|
{
|
||||||
|
StopTimer();
|
||||||
|
|
||||||
|
KeyframeMotion newmotion = new KeyframeMotion(newgrp, m_mode, m_data);
|
||||||
|
|
||||||
|
if (newgrp != null && newgrp.IsSelected)
|
||||||
|
newmotion.m_selected = true;
|
||||||
|
|
||||||
|
if (m_keyframes != null)
|
||||||
|
m_keyframes.CopyTo(newmotion.m_keyframes, 0);
|
||||||
|
|
||||||
|
newmotion.m_frames = new List<Keyframe>(m_frames);
|
||||||
|
newmotion.m_currentFrame = m_currentFrame;
|
||||||
|
|
||||||
|
newmotion.m_nextPosition = m_nextPosition;
|
||||||
|
if (m_selected)
|
||||||
|
newmotion.m_serializedPosition = m_serializedPosition;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (m_group != null)
|
||||||
|
newmotion.m_serializedPosition = m_group.AbsolutePosition;
|
||||||
|
else
|
||||||
|
newmotion.m_serializedPosition = m_serializedPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
newmotion.m_iterations = m_iterations;
|
||||||
|
|
||||||
|
newmotion.m_onTimerLock = new object();
|
||||||
|
newmotion.m_timerStopped = false;
|
||||||
|
newmotion.m_inOnTimer = false;
|
||||||
|
newmotion.m_isCrossing = false;
|
||||||
|
newmotion.m_waitingCrossing = false;
|
||||||
|
|
||||||
|
if (m_running && !m_waitingCrossing)
|
||||||
|
StartTimer();
|
||||||
|
|
||||||
|
return newmotion;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Delete()
|
||||||
|
{
|
||||||
|
m_running = false;
|
||||||
|
RemoveTimer();
|
||||||
|
m_isCrossing = false;
|
||||||
|
m_waitingCrossing = false;
|
||||||
|
m_frames.Clear();
|
||||||
|
m_keyframes = null;
|
||||||
|
}
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
|
m_isCrossing = false;
|
||||||
|
m_waitingCrossing = false;
|
||||||
if (m_keyframes.Length > 0)
|
if (m_keyframes.Length > 0)
|
||||||
m_timer.Start();
|
{
|
||||||
|
if (m_timer == null)
|
||||||
|
{
|
||||||
|
m_timer = new Timer();
|
||||||
|
m_timer.Interval = timerInterval;
|
||||||
|
m_timer.AutoReset = true;
|
||||||
|
m_timer.Elapsed += OnTimer;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StopTimer();
|
||||||
|
m_timer.Interval = timerInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_inOnTimer = false;
|
||||||
|
StartTimer();
|
||||||
m_running = true;
|
m_running = true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_running = false;
|
||||||
|
RemoveTimer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void Stop()
|
public void Stop()
|
||||||
{
|
{
|
||||||
// Failed object creation
|
m_running = false;
|
||||||
if (m_timer == null)
|
m_isCrossing = false;
|
||||||
return;
|
m_waitingCrossing = false;
|
||||||
m_timer.Stop();
|
|
||||||
|
RemoveTimer();
|
||||||
|
|
||||||
m_basePosition = m_group.AbsolutePosition;
|
m_basePosition = m_group.AbsolutePosition;
|
||||||
m_baseRotation = m_group.GroupRotation;
|
m_baseRotation = m_group.GroupRotation;
|
||||||
|
@ -179,17 +341,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_group.SendGroupRootTerseUpdate();
|
m_group.SendGroupRootTerseUpdate();
|
||||||
|
|
||||||
m_frames.Clear();
|
m_frames.Clear();
|
||||||
m_running = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Pause()
|
public void Pause()
|
||||||
{
|
{
|
||||||
|
m_running = false;
|
||||||
|
RemoveTimer();
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
m_timer.Stop();
|
|
||||||
m_running = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GetNextList()
|
private void GetNextList()
|
||||||
|
@ -222,9 +383,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
Keyframe k = m_keyframes[i];
|
Keyframe k = m_keyframes[i];
|
||||||
|
|
||||||
if (k.Position.HasValue)
|
if (k.Position.HasValue)
|
||||||
k.Position = (k.Position * direction) + pos;
|
{
|
||||||
|
k.Position = (k.Position * direction);
|
||||||
|
// k.Velocity = (Vector3)k.Position / (k.TimeMS / 1000.0f);
|
||||||
|
k.Position += pos;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
k.Position = pos;
|
k.Position = pos;
|
||||||
|
// k.Velocity = Vector3.Zero;
|
||||||
|
}
|
||||||
|
|
||||||
k.StartRotation = rot;
|
k.StartRotation = rot;
|
||||||
if (k.Rotation.HasValue)
|
if (k.Rotation.HasValue)
|
||||||
|
@ -238,6 +406,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
k.Rotation = rot;
|
k.Rotation = rot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ang vel not in use for now
|
||||||
|
|
||||||
float angle = 0;
|
float angle = 0;
|
||||||
|
|
||||||
float aa = k.StartRotation.X * k.StartRotation.X + k.StartRotation.Y * k.StartRotation.Y + k.StartRotation.Z * k.StartRotation.Z + k.StartRotation.W * k.StartRotation.W;
|
float aa = k.StartRotation.X * k.StartRotation.X + k.StartRotation.Y * k.StartRotation.Y + k.StartRotation.Z * k.StartRotation.Z + k.StartRotation.W * k.StartRotation.W;
|
||||||
|
@ -267,6 +437,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
|
|
||||||
k.AngularVelocity = (new Vector3(0, 0, 1) * (Quaternion)k.Rotation) * (angle / (k.TimeMS / 1000));
|
k.AngularVelocity = (new Vector3(0, 0, 1) * (Quaternion)k.Rotation) * (angle / (k.TimeMS / 1000));
|
||||||
|
*/
|
||||||
k.TimeTotal = k.TimeMS;
|
k.TimeTotal = k.TimeMS;
|
||||||
|
|
||||||
m_frames.Add(k);
|
m_frames.Add(k);
|
||||||
|
@ -284,19 +455,27 @@ 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_timerStopped) // trap events still in air even after a timer.stop
|
||||||
{
|
return;
|
||||||
GetNextList();
|
|
||||||
|
|
||||||
if (m_frames.Count == 0)
|
if (m_inOnTimer) // don't let overruns to happen
|
||||||
{
|
{
|
||||||
Stop();
|
m_log.Warn("[KeyFrame]: timer overrun");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentFrame = m_frames[0];
|
if (m_group == null)
|
||||||
}
|
return;
|
||||||
|
|
||||||
|
lock (m_onTimerLock)
|
||||||
|
{
|
||||||
|
|
||||||
|
m_inOnTimer = true;
|
||||||
|
|
||||||
|
bool update = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (m_selected)
|
if (m_selected)
|
||||||
{
|
{
|
||||||
if (m_group.RootPart.Velocity != Vector3.Zero)
|
if (m_group.RootPart.Velocity != Vector3.Zero)
|
||||||
|
@ -304,31 +483,81 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_group.RootPart.Velocity = Vector3.Zero;
|
m_group.RootPart.Velocity = Vector3.Zero;
|
||||||
m_group.SendGroupRootTerseUpdate();
|
m_group.SendGroupRootTerseUpdate();
|
||||||
}
|
}
|
||||||
|
m_inOnTimer = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_isCrossing)
|
||||||
|
{
|
||||||
|
// if crossing and timer running then cross failed
|
||||||
|
// wait some time then
|
||||||
|
// retry to set the position that evtually caused the outbound
|
||||||
|
// if still outside region this will call startCrossing below
|
||||||
|
m_isCrossing = false;
|
||||||
|
m_group.AbsolutePosition = m_nextPosition;
|
||||||
|
if (!m_isCrossing)
|
||||||
|
{
|
||||||
|
StopTimer();
|
||||||
|
m_timer.Interval = timerInterval;
|
||||||
|
StartTimer();
|
||||||
|
}
|
||||||
|
m_inOnTimer = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_frames.Count == 0)
|
||||||
|
{
|
||||||
|
GetNextList();
|
||||||
|
|
||||||
|
if (m_frames.Count == 0)
|
||||||
|
{
|
||||||
|
Stop();
|
||||||
|
m_inOnTimer = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_currentFrame = m_frames[0];
|
||||||
|
m_currentFrame.TimeMS += (int)timerInterval;
|
||||||
|
|
||||||
|
//force a update on a keyframe transition
|
||||||
|
update = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
m_currentFrame.TimeMS -= (int)timerInterval;
|
||||||
|
|
||||||
// Do the frame processing
|
// Do the frame processing
|
||||||
double steps = (double)m_currentFrame.TimeMS / timerInterval;
|
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)
|
if (steps <= 0.0)
|
||||||
{
|
{
|
||||||
m_currentFrame.TimeMS = 0;
|
m_group.RootPart.Velocity = Vector3.Zero;
|
||||||
|
m_group.RootPart.UpdateAngularVelocity(Vector3.Zero);
|
||||||
|
|
||||||
|
m_nextPosition = (Vector3)m_currentFrame.Position;
|
||||||
|
m_group.AbsolutePosition = m_nextPosition;
|
||||||
|
|
||||||
m_group.AbsolutePosition = (Vector3)m_currentFrame.Position;
|
|
||||||
m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation);
|
m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation);
|
||||||
|
|
||||||
|
m_frames.RemoveAt(0);
|
||||||
|
if (m_frames.Count > 0)
|
||||||
|
m_currentFrame = m_frames[0];
|
||||||
|
|
||||||
|
update = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal;
|
||||||
|
|
||||||
Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition;
|
Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition;
|
||||||
Vector3 motionThisFrame = v / (float)steps;
|
Vector3 motionThisFrame = v / (float)steps;
|
||||||
v = v * 1000 / m_currentFrame.TimeMS;
|
v = v * 1000 / m_currentFrame.TimeMS;
|
||||||
|
|
||||||
bool update = false;
|
|
||||||
|
|
||||||
if (Vector3.Mag(motionThisFrame) >= 0.05f)
|
if (Vector3.Mag(motionThisFrame) >= 0.05f)
|
||||||
{
|
{
|
||||||
m_group.AbsolutePosition += motionThisFrame;
|
// m_group.AbsolutePosition += motionThisFrame;
|
||||||
|
m_nextPosition = m_group.AbsolutePosition + motionThisFrame;
|
||||||
|
m_group.AbsolutePosition = m_nextPosition;
|
||||||
|
|
||||||
m_group.RootPart.Velocity = v;
|
m_group.RootPart.Velocity = v;
|
||||||
update = true;
|
update = true;
|
||||||
}
|
}
|
||||||
|
@ -338,8 +567,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
Quaternion current = m_group.GroupRotation;
|
Quaternion current = m_group.GroupRotation;
|
||||||
|
|
||||||
Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete);
|
Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, complete);
|
||||||
|
/* use simpler change detection
|
||||||
float angle = 0;
|
* float angle = 0;
|
||||||
|
|
||||||
float aa = current.X * current.X + current.Y * current.Y + current.Z * current.Z + current.W * current.W;
|
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 bb = step.X * step.X + step.Y * step.Y + step.Z * step.Z + step.W * step.W;
|
||||||
|
@ -368,55 +597,90 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
}
|
}
|
||||||
|
|
||||||
if (angle > 0.01f)
|
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.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2);
|
//m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2);
|
||||||
update = true;
|
update = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (update)
|
if (update)
|
||||||
m_group.SendGroupRootTerseUpdate();
|
m_group.SendGroupRootTerseUpdate();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch ( Exception ex)
|
||||||
|
{
|
||||||
|
// still happening sometimes
|
||||||
|
// lets try to see where
|
||||||
|
m_log.Warn("[KeyFrame]: timer overrun" + ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_currentFrame.TimeMS -= (int)timerInterval;
|
finally
|
||||||
|
|
||||||
if (m_currentFrame.TimeMS <= 0)
|
|
||||||
{
|
{
|
||||||
m_group.RootPart.Velocity = Vector3.Zero;
|
// make sure we do not let this frozen
|
||||||
m_group.RootPart.UpdateAngularVelocity(Vector3.Zero);
|
m_inOnTimer = false;
|
||||||
m_group.SendGroupRootTerseUpdate();
|
}
|
||||||
|
|
||||||
m_frames.RemoveAt(0);
|
|
||||||
if (m_frames.Count > 0)
|
|
||||||
m_currentFrame = m_frames[0];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Byte[] Serialize()
|
public Byte[] Serialize()
|
||||||
{
|
{
|
||||||
|
StopTimer();
|
||||||
MemoryStream ms = new MemoryStream();
|
MemoryStream ms = new MemoryStream();
|
||||||
m_timer.Stop();
|
|
||||||
|
|
||||||
BinaryFormatter fmt = new BinaryFormatter();
|
BinaryFormatter fmt = new BinaryFormatter();
|
||||||
SceneObjectGroup tmp = m_group;
|
SceneObjectGroup tmp = m_group;
|
||||||
m_group = null;
|
m_group = null;
|
||||||
|
if (!m_selected && tmp != null)
|
||||||
m_serializedPosition = tmp.AbsolutePosition;
|
m_serializedPosition = tmp.AbsolutePosition;
|
||||||
fmt.Serialize(ms, this);
|
fmt.Serialize(ms, this);
|
||||||
m_group = tmp;
|
m_group = tmp;
|
||||||
|
if (m_running && !m_waitingCrossing)
|
||||||
|
StartTimer();
|
||||||
|
|
||||||
return ms.ToArray();
|
return ms.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void StartCrossingCheck()
|
||||||
|
{
|
||||||
|
// timer will be restart by crossingFailure
|
||||||
|
// or never since crossing worked and this
|
||||||
|
// should be deleted
|
||||||
|
StopTimer();
|
||||||
|
|
||||||
|
m_isCrossing = true;
|
||||||
|
m_waitingCrossing = true;
|
||||||
|
|
||||||
|
// to remove / retune to smoth crossings
|
||||||
|
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
|
m_waitingCrossing = false;
|
||||||
// then retry the crossing. We'll get back here if it fails.
|
|
||||||
Util.FireAndForget(delegate (object x)
|
if (m_group != null)
|
||||||
{
|
{
|
||||||
Thread.Sleep(60000);
|
m_group.RootPart.Velocity = Vector3.Zero;
|
||||||
if (m_running)
|
m_group.SendGroupRootTerseUpdate();
|
||||||
m_timer.Start();
|
|
||||||
});
|
if (m_running && m_timer != null)
|
||||||
|
{
|
||||||
|
m_timer.Interval = 60000;
|
||||||
|
StartTimer();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
{
|
{
|
||||||
|
@ -599,11 +602,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
avsToCross.Clear();
|
avsToCross.Clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (RootPart.PhysActor != null)
|
else
|
||||||
|
{
|
||||||
|
if (m_rootPart.KeyframeMotion != null)
|
||||||
|
m_rootPart.KeyframeMotion.CrossingFailure();
|
||||||
|
|
||||||
|
if (RootPart.PhysActor != null)
|
||||||
{
|
{
|
||||||
RootPart.PhysActor.CrossingFailure();
|
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);
|
||||||
|
@ -2059,7 +2067,7 @@ 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());
|
||||||
part.KeyframeMotion.UpdateSceneObject(this);
|
// part.KeyframeMotion.UpdateSceneObject(this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4408,6 +4416,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());
|
||||||
|
// 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);
|
||||||
|
|
|
@ -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