mirror of
https://github.com/opensim/opensim.git
synced 2026-08-09 02:36:00 +08:00
bad merge?
This commit is contained in:
@@ -292,14 +292,17 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
private void StartTimer()
|
||||
{
|
||||
KeyframeTimer.Add(this);
|
||||
m_timerStopped = false;
|
||||
lock (m_frames)
|
||||
{
|
||||
KeyframeTimer.Add(this);
|
||||
m_timerStopped = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void StopTimer()
|
||||
{
|
||||
m_timerStopped = true;
|
||||
KeyframeTimer.Remove(this);
|
||||
lock (m_frames)
|
||||
m_timerStopped = true;
|
||||
}
|
||||
|
||||
public static KeyframeMotion FromData(SceneObjectGroup grp, Byte[] data)
|
||||
@@ -348,6 +351,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_group = grp;
|
||||
m_scene = grp.Scene;
|
||||
|
||||
<<<<<<< HEAD
|
||||
Vector3 grppos = grp.AbsolutePosition;
|
||||
Vector3 offset = grppos - m_serializedPosition;
|
||||
// avoid doing it more than once
|
||||
@@ -366,6 +370,27 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
k.StartPosition += offset;
|
||||
k.Position += offset;
|
||||
m_frames[i]=k;
|
||||
=======
|
||||
lock (m_frames)
|
||||
{
|
||||
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;
|
||||
}
|
||||
>>>>>>> avn/ubitvar
|
||||
}
|
||||
|
||||
if (m_running)
|
||||
@@ -410,26 +435,29 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
m_keyframes.CopyTo(newmotion.m_keyframes, 0);
|
||||
}
|
||||
|
||||
newmotion.m_frames = new List<Keyframe>(m_frames);
|
||||
|
||||
newmotion.m_basePosition = m_basePosition;
|
||||
newmotion.m_baseRotation = m_baseRotation;
|
||||
|
||||
if (m_selected)
|
||||
newmotion.m_serializedPosition = m_serializedPosition;
|
||||
else
|
||||
lock (m_frames)
|
||||
{
|
||||
if (m_group != null)
|
||||
newmotion.m_serializedPosition = m_group.AbsolutePosition;
|
||||
else
|
||||
newmotion.m_frames = new List<Keyframe>(m_frames);
|
||||
|
||||
newmotion.m_basePosition = m_basePosition;
|
||||
newmotion.m_baseRotation = m_baseRotation;
|
||||
|
||||
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_currentFrame = m_currentFrame;
|
||||
|
||||
newmotion.m_iterations = m_iterations;
|
||||
newmotion.m_running = m_running;
|
||||
}
|
||||
|
||||
newmotion.m_currentFrame = m_currentFrame;
|
||||
|
||||
newmotion.m_iterations = m_iterations;
|
||||
newmotion.m_running = m_running;
|
||||
|
||||
if (m_running && !m_waitingCrossing)
|
||||
StartTimer();
|
||||
|
||||
@@ -458,19 +486,18 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
else
|
||||
{
|
||||
m_running = false;
|
||||
StopTimer();
|
||||
m_running = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
StopTimer();
|
||||
m_running = false;
|
||||
m_isCrossing = false;
|
||||
m_waitingCrossing = false;
|
||||
|
||||
StopTimer();
|
||||
|
||||
m_basePosition = m_group.AbsolutePosition;
|
||||
m_baseRotation = m_group.GroupRotation;
|
||||
|
||||
@@ -483,14 +510,34 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
public void Pause()
|
||||
{
|
||||
m_running = false;
|
||||
StopTimer();
|
||||
m_running = false;
|
||||
|
||||
m_group.RootPart.Velocity = Vector3.Zero;
|
||||
m_group.RootPart.AngularVelocity = Vector3.Zero;
|
||||
m_group.SendGroupRootTerseUpdate();
|
||||
// m_group.RootPart.ScheduleTerseUpdate();
|
||||
}
|
||||
|
||||
public void Suspend()
|
||||
{
|
||||
lock (m_frames)
|
||||
{
|
||||
if (m_timerStopped)
|
||||
return;
|
||||
m_timerStopped = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Resume()
|
||||
{
|
||||
lock (m_frames)
|
||||
{
|
||||
if (!m_timerStopped)
|
||||
return;
|
||||
if (m_running && !m_waitingCrossing)
|
||||
StartTimer();
|
||||
}
|
||||
}
|
||||
|
||||
private void GetNextList()
|
||||
@@ -581,6 +628,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
pos = (Vector3)k.Position;
|
||||
rot = (Quaternion)k.Rotation;
|
||||
|
||||
}
|
||||
|
||||
m_basePosition = pos;
|
||||
@@ -591,6 +639,35 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
public void OnTimer(double tickDuration)
|
||||
{
|
||||
if (!Monitor.TryEnter(m_frames))
|
||||
return;
|
||||
if (m_timerStopped)
|
||||
KeyframeTimer.Remove(this);
|
||||
else
|
||||
DoOnTimer(tickDuration);
|
||||
Monitor.Exit(m_frames);
|
||||
}
|
||||
|
||||
private void Done()
|
||||
{
|
||||
KeyframeTimer.Remove(this);
|
||||
m_timerStopped = true;
|
||||
m_running = false;
|
||||
m_isCrossing = false;
|
||||
m_waitingCrossing = false;
|
||||
|
||||
m_basePosition = m_group.AbsolutePosition;
|
||||
m_baseRotation = m_group.GroupRotation;
|
||||
|
||||
m_group.RootPart.Velocity = Vector3.Zero;
|
||||
m_group.RootPart.AngularVelocity = Vector3.Zero;
|
||||
m_group.SendGroupRootTerseUpdate();
|
||||
// m_group.RootPart.ScheduleTerseUpdate();
|
||||
m_frames.Clear();
|
||||
}
|
||||
|
||||
private void DoOnTimer(double tickDuration)
|
||||
{
|
||||
if (m_skipLoops > 0)
|
||||
{
|
||||
@@ -598,9 +675,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_timerStopped) // trap events still in air even after a timer.stop
|
||||
return;
|
||||
|
||||
if (m_group == null)
|
||||
return;
|
||||
|
||||
@@ -612,7 +686,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
{
|
||||
m_group.RootPart.Velocity = Vector3.Zero;
|
||||
m_group.SendGroupRootTerseUpdate();
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -635,6 +708,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
if (m_frames.Count == 0)
|
||||
{
|
||||
<<<<<<< HEAD
|
||||
if (!m_running) return;
|
||||
|
||||
GetNextList();
|
||||
@@ -656,11 +730,33 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
return;
|
||||
}
|
||||
=======
|
||||
lock (m_frames)
|
||||
{
|
||||
GetNextList();
|
||||
|
||||
m_currentFrame = m_frames[0];
|
||||
m_currentFrame.TimeMS += (int)tickDuration;
|
||||
if (m_frames.Count == 0)
|
||||
{
|
||||
Done();
|
||||
Scene scene = m_group.Scene;
|
||||
|
||||
IScriptModule[] scriptModules = scene.RequestModuleInterfaces<IScriptModule>();
|
||||
foreach (IScriptModule m in scriptModules)
|
||||
{
|
||||
if (m == null)
|
||||
continue;
|
||||
m.PostObjectEvent(m_group.RootPart.UUID, "moving_end", new object[0]);
|
||||
}
|
||||
>>>>>>> avn/ubitvar
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
m_currentFrame = m_frames[0];
|
||||
m_currentFrame.TimeMS += (int)tickDuration;
|
||||
}
|
||||
//force a update on a keyframe transition
|
||||
m_nextPosition = m_group.AbsolutePosition;
|
||||
update = true;
|
||||
}
|
||||
|
||||
@@ -681,9 +777,13 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
// m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation);
|
||||
|
||||
m_group.RootPart.RotationOffset = (Quaternion)m_currentFrame.Rotation;
|
||||
m_frames.RemoveAt(0);
|
||||
if (m_frames.Count > 0)
|
||||
m_currentFrame = m_frames[0];
|
||||
|
||||
lock (m_frames)
|
||||
{
|
||||
m_frames.RemoveAt(0);
|
||||
if (m_frames.Count > 0)
|
||||
m_currentFrame = m_frames[0];
|
||||
}
|
||||
|
||||
update = true;
|
||||
}
|
||||
@@ -695,14 +795,19 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
Vector3 positionThisStep = m_currentFrame.StartPosition + (m_currentFrame.Position.Value - m_currentFrame.StartPosition) * completed;
|
||||
Vector3 motionThisStep = positionThisStep - m_group.AbsolutePosition;
|
||||
|
||||
<<<<<<< HEAD
|
||||
float mag = Vector3.Mag(motionThisStep);
|
||||
|
||||
if ((mag >= 0.02f) || lastStep)
|
||||
{
|
||||
m_nextPosition = m_group.AbsolutePosition + motionThisStep;
|
||||
m_group.AbsolutePosition = m_nextPosition;
|
||||
=======
|
||||
m_nextPosition = m_group.AbsolutePosition + motionThisFrame;
|
||||
|
||||
if (Vector3.Mag(motionThisFrame) >= 0.05f)
|
||||
>>>>>>> avn/ubitvar
|
||||
update = true;
|
||||
}
|
||||
|
||||
//int totalSteps = m_currentFrame.TimeTotal / (int)tickDuration;
|
||||
//m_log.DebugFormat("KeyframeMotion.OnTimer: step {0}/{1}, curPosition={2}, finalPosition={3}, motionThisStep={4} (scene {5})",
|
||||
@@ -714,6 +819,7 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
Quaternion step = Quaternion.Slerp(m_currentFrame.StartRotation, (Quaternion)m_currentFrame.Rotation, completed);
|
||||
step.Normalize();
|
||||
<<<<<<< HEAD
|
||||
/* use simpler change detection
|
||||
* float angle = 0;
|
||||
|
||||
@@ -751,8 +857,45 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|| lastStep)
|
||||
// assuming w is a dependente var
|
||||
|
||||
=======
|
||||
/* 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;
|
||||
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)
|
||||
*/
|
||||
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
|
||||
>>>>>>> avn/ubitvar
|
||||
{
|
||||
// m_group.UpdateGroupRotationR(step);
|
||||
// m_group.UpdateGroupRotationR(step);
|
||||
m_group.RootPart.RotationOffset = step;
|
||||
|
||||
//m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2);
|
||||
@@ -763,18 +906,31 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
|
||||
if (update)
|
||||
{
|
||||
m_group.AbsolutePosition = m_nextPosition;
|
||||
m_group.SendGroupRootTerseUpdate();
|
||||
}
|
||||
}
|
||||
|
||||
public Byte[] Serialize()
|
||||
{
|
||||
bool timerWasStopped;
|
||||
lock (m_frames)
|
||||
{
|
||||
timerWasStopped = m_timerStopped;
|
||||
}
|
||||
StopTimer();
|
||||
|
||||
SceneObjectGroup tmp = m_group;
|
||||
m_group = null;
|
||||
if (!m_selected && tmp != null)
|
||||
m_serializedPosition = tmp.AbsolutePosition;
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
fmt.Serialize(ms, this);
|
||||
m_group = tmp;
|
||||
if (!timerWasStopped && m_running && !m_waitingCrossing)
|
||||
StartTimer();
|
||||
>>>>>>> avn/ubitvar
|
||||
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user