Merge branch 'avination' into careminster

avinationmerge
Melanie 2012-08-31 00:34:22 +01:00
commit fd92560649
17 changed files with 761 additions and 231 deletions

View File

@ -51,7 +51,8 @@ namespace OpenSim.Framework.Servers.HttpServer
public enum EventType : int
{
Normal = 0,
LslHttp = 1
LslHttp = 1,
Inventory = 2
}
public PollServiceEventArgs(

View File

@ -231,7 +231,8 @@ namespace OpenSim.Framework.Servers.HttpServer
{
if (m_running)
{
if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LslHttp)
if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LslHttp ||
req.PollServiceArgs.Type == PollServiceEventArgs.EventType.Inventory)
{
m_requests.Enqueue(req);
}

View File

@ -27,12 +27,15 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Threading;
using log4net;
using Nini.Config;
using Mono.Addins;
using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
@ -48,67 +51,49 @@ namespace OpenSim.Region.ClientStack.Linden
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
public class WebFetchInvDescModule : INonSharedRegionModule
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private IInventoryService m_InventoryService;
private ILibraryService m_LibraryService;
private bool m_Enabled;
private string m_fetchInventoryDescendents2Url;
private string m_webFetchInventoryDescendentsUrl;
private WebFetchInvDescHandler m_webFetchHandler;
private ManualResetEvent m_ev = new ManualResetEvent(true);
private object m_lock = new object();
private Dictionary<UUID, string> m_capsDict = new Dictionary<UUID, string>();
private Dictionary<UUID, Hashtable> m_requests = new Dictionary<UUID, Hashtable>();
#region ISharedRegionModule Members
public void Initialise(IConfigSource source)
{
IConfig config = source.Configs["ClientStack.LindenCaps"];
if (config == null)
return;
m_fetchInventoryDescendents2Url = config.GetString("Cap_FetchInventoryDescendents2", string.Empty);
m_webFetchInventoryDescendentsUrl = config.GetString("Cap_WebFetchInventoryDescendents", string.Empty);
if (m_fetchInventoryDescendents2Url != string.Empty || m_webFetchInventoryDescendentsUrl != string.Empty)
{
m_Enabled = true;
}
}
public void AddRegion(Scene s)
{
if (!m_Enabled)
return;
m_scene = s;
}
public void RemoveRegion(Scene s)
{
if (!m_Enabled)
return;
m_scene.EventManager.OnRegisterCaps -= RegisterCaps;
m_scene.EventManager.OnDeregisterCaps -= DeregisterCaps;
m_scene = null;
}
public void RegionLoaded(Scene s)
{
if (!m_Enabled)
return;
m_InventoryService = m_scene.InventoryService;
m_LibraryService = m_scene.LibraryService;
// We'll reuse the same handler for all requests.
if (m_fetchInventoryDescendents2Url == "localhost" || m_webFetchInventoryDescendentsUrl == "localhost")
m_webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService);
m_webFetchHandler = new WebFetchInvDescHandler(m_InventoryService, m_LibraryService);
m_scene.EventManager.OnRegisterCaps += RegisterCaps;
m_scene.EventManager.OnDeregisterCaps += DeregisterCaps;
}
public void PostInitialise()
@ -128,41 +113,110 @@ namespace OpenSim.Region.ClientStack.Linden
private void RegisterCaps(UUID agentID, Caps caps)
{
if (m_webFetchInventoryDescendentsUrl != "")
RegisterFetchCap(agentID, caps, "WebFetchInventoryDescendents", m_webFetchInventoryDescendentsUrl);
string capUrl = "/CAPS/" + UUID.Random() + "/";
if (m_fetchInventoryDescendents2Url != "")
RegisterFetchCap(agentID, caps, "FetchInventoryDescendents2", m_fetchInventoryDescendents2Url);
// Register this as a poll service
PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, agentID, 300000);
args.Type = PollServiceEventArgs.EventType.Inventory;
MainServer.Instance.AddPollServiceHTTPHandler(capUrl, args);
string hostName = m_scene.RegionInfo.ExternalHostName;
uint port = (MainServer.Instance == null) ? 0 : MainServer.Instance.Port;
string protocol = "http";
if (MainServer.Instance.UseSSL)
{
hostName = MainServer.Instance.SSLCommonName;
port = MainServer.Instance.SSLPort;
protocol = "https";
}
caps.RegisterHandler("FetchInventoryDescendents2", String.Format("{0}://{1}:{2}{3}", protocol, hostName, port, capUrl));
m_capsDict[agentID] = capUrl;
}
private void RegisterFetchCap(UUID agentID, Caps caps, string capName, string url)
private void DeregisterCaps(UUID agentID, Caps caps)
{
string capUrl;
if (url == "localhost")
if (m_capsDict.TryGetValue(agentID, out capUrl))
{
capUrl = "/CAPS/" + UUID.Random();
IRequestHandler reqHandler
= new RestStreamHandler(
"POST",
capUrl,
m_webFetchHandler.FetchInventoryDescendentsRequest,
"FetchInventoryDescendents2",
agentID.ToString());
caps.RegisterHandler(capName, reqHandler);
MainServer.Instance.RemoveHTTPHandler("", capUrl);
m_capsDict.Remove(agentID);
}
else
{
capUrl = url;
}
caps.RegisterHandler(capName, capUrl);
public void HttpRequestHandler(UUID requestID, Hashtable request)
{
// m_log.DebugFormat("[FETCH2]: Received request {0}", requestID);
m_requests[requestID] = request;
}
private bool HasEvents(UUID requestID, UUID sessionID)
{
lock (m_lock)
{
if (m_ev.WaitOne(0))
{
m_ev.Reset();
return true;
}
return false;
}
}
private Hashtable NoEvents(UUID requestID, UUID sessionID)
{
m_requests.Remove(requestID);
Hashtable response = new Hashtable();
response["int_response_code"] = 500;
response["str_response_string"] = "Script timeout";
response["content_type"] = "text/plain";
response["keepalive"] = false;
response["reusecontext"] = false;
return response;
}
private Hashtable GetEvents(UUID requestID, UUID sessionID, string request)
{
Hashtable response = new Hashtable();
response["int_response_code"] = 500;
response["str_response_string"] = "Internal error";
response["content_type"] = "text/plain";
response["keepalive"] = false;
response["reusecontext"] = false;
try
{
Hashtable requestHash;
if (!m_requests.TryGetValue(requestID, out requestHash))
{
lock (m_lock)
m_ev.Set();
response["str_response_string"] = "Invalid request";
return response;
}
// m_log.DebugFormat("[FETCH2]: Processed request {0}", requestID);
string reply = m_webFetchHandler.FetchInventoryDescendentsRequest(requestHash["body"].ToString(), String.Empty, String.Empty, null, null);
m_requests.Remove(requestID);
response["int_response_code"] = 200;
response["str_response_string"] = reply;
}
finally
{
lock (m_lock)
m_ev.Set();
}
// m_log.DebugFormat(
// "[WEB FETCH INV DESC MODULE]: Registered capability {0} at {1} in region {2} for {3}",
// capName, capUrl, m_scene.RegionInfo.RegionName, agentID);
return response;
}
}
}
}

View File

@ -110,7 +110,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <summary>Handlers for incoming packets</summary>
//PacketEventDictionary packetEvents = new PacketEventDictionary();
/// <summary>Incoming packets that are awaiting handling</summary>
private OpenMetaverse.BlockingQueue<IncomingPacket> packetInbox = new OpenMetaverse.BlockingQueue<IncomingPacket>();
//private OpenMetaverse.BlockingQueue<IncomingPacket> packetInbox = new OpenMetaverse.BlockingQueue<IncomingPacket>();
private DoubleQueue<IncomingPacket> packetInbox = new DoubleQueue<IncomingPacket>();
/// <summary></summary>
//private UDPClientCollection m_clients = new UDPClientCollection();
/// <summary>Bandwidth throttle for this UDP server</summary>
@ -919,7 +922,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
#endregion Ping Check Handling
// Inbox insertion
packetInbox.Enqueue(new IncomingPacket((LLClientView)client, packet));
if (packet.Type == PacketType.AgentUpdate ||
packet.Type == PacketType.ChatFromViewer)
packetInbox.EnqueueHigh(new IncomingPacket((LLClientView)client, packet));
else
packetInbox.EnqueueLow(new IncomingPacket((LLClientView)client, packet));
// packetInbox.Enqueue(new IncomingPacket((LLClientView)client, packet));
}
#region BinaryStats
@ -1471,8 +1479,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
Packet packet = incomingPacket.Packet;
LLClientView client = incomingPacket.Client;
if (client.IsActive)
{
// if (client.IsActive)
// {
m_currentIncomingClient = client;
try
@ -1499,13 +1507,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
m_currentIncomingClient = null;
}
}
else
{
m_log.DebugFormat(
"[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}",
packet.Type, client.Name, m_scene.RegionInfo.RegionName);
}
// }
// else
// {
// m_log.DebugFormat(
// "[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}",
// packet.Type, client.Name, m_scene.RegionInfo.RegionName);
// }
}
protected void LogoutHandler(IClientAPI client)
@ -1519,4 +1527,112 @@ namespace OpenSim.Region.ClientStack.LindenUDP
}
}
}
internal class DoubleQueue<T> where T:class
{
private Queue<T> m_lowQueue = new Queue<T>();
private Queue<T> m_highQueue = new Queue<T>();
private object m_syncRoot = new object();
private Semaphore m_s = new Semaphore(0, 1);
public DoubleQueue()
{
}
public virtual int Count
{
get { return m_highQueue.Count + m_lowQueue.Count; }
}
public virtual void Enqueue(T data)
{
Enqueue(m_lowQueue, data);
}
public virtual void EnqueueLow(T data)
{
Enqueue(m_lowQueue, data);
}
public virtual void EnqueueHigh(T data)
{
Enqueue(m_highQueue, data);
}
private void Enqueue(Queue<T> q, T data)
{
lock (m_syncRoot)
{
m_lowQueue.Enqueue(data);
m_s.WaitOne(0);
m_s.Release();
}
}
public virtual T Dequeue()
{
return Dequeue(Timeout.Infinite);
}
public virtual T Dequeue(int tmo)
{
return Dequeue(TimeSpan.FromMilliseconds(tmo));
}
public virtual T Dequeue(TimeSpan wait)
{
T res = null;
if (!Dequeue(wait, ref res))
return null;
return res;
}
public bool Dequeue(int timeout, ref T res)
{
return Dequeue(TimeSpan.FromMilliseconds(timeout), ref res);
}
public bool Dequeue(TimeSpan wait, ref T res)
{
if (!m_s.WaitOne(wait))
return false;
lock (m_syncRoot)
{
if (m_highQueue.Count > 0)
res = m_highQueue.Dequeue();
else
res = m_lowQueue.Dequeue();
if (m_highQueue.Count == 0 && m_lowQueue.Count == 0)
return true;
try
{
m_s.Release();
}
catch
{
}
return true;
}
}
public virtual void Clear()
{
lock (m_syncRoot)
{
// Make sure sem count is 0
m_s.WaitOne(0);
m_lowQueue.Clear();
m_highQueue.Clear();
}
}
}
}

View File

@ -1855,6 +1855,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
if (grp.RootPart.PhysActor != null)
grp.RootPart.PhysActor.CrossingFailure();
if (grp.RootPart.KeyframeMotion != null)
grp.RootPart.KeyframeMotion.CrossingFailure();
grp.ScheduleGroupForFullUpdate();
}
@ -1910,8 +1913,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
grp, e);
}
}
/*
* done on caller ( not in attachments crossing for now)
else
{
if (!grp.IsDeleted)
{
PhysicsActor pa = grp.RootPart.PhysActor;
@ -1920,15 +1926,17 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
pa.CrossingFailure();
if (grp.RootPart.KeyframeMotion != null)
{
grp.RootPart.Velocity = Vector3.Zero;
// moved to KeyframeMotion.CrossingFailure
// grp.RootPart.Velocity = Vector3.Zero;
grp.RootPart.KeyframeMotion.CrossingFailure();
grp.SendGroupRootTerseUpdate();
// grp.SendGroupRootTerseUpdate();
}
}
}
m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: Prim crossing failed for {0}", grp);
}
*/
}
else
{

View File

@ -140,6 +140,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication
public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
{
// Not implemented at the regions
realID = UUID.Zero;
return string.Empty;
}

View File

@ -38,8 +38,8 @@ namespace OpenSim.Region.Framework.Scenes
[Flags]
public enum DataFormat : int
{
Translation = 1,
Rotation = 2
Translation = 2,
Rotation = 1
}
[Serializable]
@ -53,17 +53,42 @@ namespace OpenSim.Region.Framework.Scenes
public Vector3 AngularVelocity;
};
private Vector3 m_serializedPosition;
private Vector3 m_basePosition;
private Quaternion m_baseRotation;
private Vector3 m_serializedPosition;
private Keyframe m_currentFrame;
private List<Keyframe> m_frames = new List<Keyframe>();
private Keyframe[] m_keyframes;
[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()]
private SceneObjectGroup m_group;
@ -88,54 +113,120 @@ namespace OpenSim.Region.Framework.Scenes
{
set
{
if (value)
if (m_group != null)
{
// Once we're let go, recompute positions
if (m_selected)
UpdateSceneObject(m_group);
if (!value)
{
// Once we're let go, recompute positions
if (m_selected)
UpdateSceneObject(m_group);
}
else
{
// Save selection position in case we get moved
if (!m_selected)
{
StopTimer();
m_serializedPosition = m_group.AbsolutePosition;
}
}
}
else
{
// Save selection position in case we get moved
if (!m_selected)
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)
{
MemoryStream ms = new MemoryStream(data);
KeyframeMotion newMotion = null;
BinaryFormatter fmt = new BinaryFormatter();
try
{
MemoryStream ms = new MemoryStream(data);
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_timer = new Timer();
newMotion.m_timer.Interval = (int)timerInterval;
newMotion.m_timer.AutoReset = true;
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_timerStopped = false;
newMotion.m_inOnTimer = false;
newMotion.m_isCrossing = false;
newMotion.m_waitingCrossing = false;
}
catch
{
newMotion = null;
}
return newMotion;
}
public void UpdateSceneObject(SceneObjectGroup grp)
{
m_group = grp;
Vector3 offset = grp.AbsolutePosition - m_serializedPosition;
m_basePosition += offset;
m_currentFrame.Position += offset;
for (int i = 0 ; i < m_frames.Count ; i++)
// lock (m_onTimerLock)
{
Keyframe k = m_frames[i];
k.Position += offset;
m_frames[i] = k;
}
m_isCrossing = false;
m_waitingCrossing = false;
StopTimer();
if (m_running)
Start();
if (grp == null)
return;
m_group = grp;
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;
}
if (m_running)
Start();
}
}
public KeyframeMotion(SceneObjectGroup grp, PlayMode mode, DataFormat data)
@ -144,12 +235,17 @@ namespace OpenSim.Region.Framework.Scenes
m_data = data;
m_group = grp;
m_basePosition = grp.AbsolutePosition;
m_baseRotation = grp.GroupRotation;
if (grp != null)
{
m_basePosition = grp.AbsolutePosition;
m_baseRotation = grp.GroupRotation;
}
m_timer.Interval = (int)timerInterval;
m_timer.AutoReset = true;
m_timer.Elapsed += OnTimer;
m_onTimerLock = new object();
m_timerStopped = true;
m_inOnTimer = false;
m_isCrossing = false;
m_waitingCrossing = false;
}
public void SetKeyframes(Keyframe[] frames)
@ -157,19 +253,93 @@ namespace OpenSim.Region.Framework.Scenes
m_keyframes = frames;
}
public KeyframeMotion Copy(SceneObjectGroup newgrp)
{
StopTimer();
KeyframeMotion newmotion = new KeyframeMotion(null, m_mode, m_data);
newmotion.m_group = newgrp;
if (m_keyframes != null)
{
newmotion.m_keyframes = new Keyframe[m_keyframes.Length];
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;
newmotion.m_currentFrame = m_currentFrame;
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_running = m_running;
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()
{
if (m_keyframes.Length > 0)
m_timer.Start();
m_running = true;
m_isCrossing = false;
m_waitingCrossing = false;
if (m_keyframes != null && m_group != null && m_keyframes.Length > 0)
{
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;
}
else
{
m_running = false;
RemoveTimer();
}
}
public void Stop()
{
// Failed object creation
if (m_timer == null)
return;
m_timer.Stop();
m_running = false;
m_isCrossing = false;
m_waitingCrossing = false;
RemoveTimer();
m_basePosition = m_group.AbsolutePosition;
m_baseRotation = m_group.GroupRotation;
@ -179,17 +349,16 @@ namespace OpenSim.Region.Framework.Scenes
m_group.SendGroupRootTerseUpdate();
m_frames.Clear();
m_running = false;
}
public void Pause()
{
m_running = false;
RemoveTimer();
m_group.RootPart.Velocity = Vector3.Zero;
m_group.RootPart.UpdateAngularVelocity(Vector3.Zero);
m_group.SendGroupRootTerseUpdate();
m_timer.Stop();
m_running = false;
}
private void GetNextList()
@ -222,9 +391,16 @@ namespace OpenSim.Region.Framework.Scenes
Keyframe k = m_keyframes[i];
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
{
k.Position = pos;
// k.Velocity = Vector3.Zero;
}
k.StartRotation = rot;
if (k.Rotation.HasValue)
@ -238,6 +414,8 @@ namespace OpenSim.Region.Framework.Scenes
k.Rotation = rot;
}
/* ang vel not in use for now
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;
@ -267,6 +445,7 @@ namespace OpenSim.Region.Framework.Scenes
}
k.AngularVelocity = (new Vector3(0, 0, 1) * (Quaternion)k.Rotation) * (angle / (k.TimeMS / 1000));
*/
k.TimeTotal = k.TimeMS;
m_frames.Add(k);
@ -284,139 +463,232 @@ namespace OpenSim.Region.Framework.Scenes
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;
if (m_inOnTimer) // don't let overruns to happen
{
GetNextList();
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();
}
m_log.Warn("[KeyFrame]: timer overrun");
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 (m_group == null)
return;
if (steps <= 1.0)
lock (m_onTimerLock)
{
m_currentFrame.TimeMS = 0;
m_group.AbsolutePosition = (Vector3)m_currentFrame.Position;
m_group.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation);
}
else
{
Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition;
Vector3 motionThisFrame = v / (float)steps;
v = v * 1000 / m_currentFrame.TimeMS;
m_inOnTimer = true;
bool update = false;
if (Vector3.Mag(motionThisFrame) >= 0.05f)
try
{
m_group.AbsolutePosition += motionThisFrame;
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)
if (m_selected)
{
angle = 0;
if (m_group.RootPart.Velocity != Vector3.Zero)
{
m_group.RootPart.Velocity = Vector3.Zero;
m_group.SendGroupRootTerseUpdate();
}
m_inOnTimer = false;
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
double steps = (double)m_currentFrame.TimeMS / timerInterval;
if (steps <= 0.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.UpdateGroupRotationR((Quaternion)m_currentFrame.Rotation);
m_frames.RemoveAt(0);
if (m_frames.Count > 0)
m_currentFrame = m_frames[0];
update = true;
}
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;
float complete = ((float)m_currentFrame.TimeTotal - (float)m_currentFrame.TimeMS) / (float)m_currentFrame.TimeTotal;
if (q > 1.0f)
Vector3 v = (Vector3)m_currentFrame.Position - m_group.AbsolutePosition;
Vector3 motionThisFrame = v / (float)steps;
v = v * 1000 / m_currentFrame.TimeMS;
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);
/* 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
{
m_group.UpdateGroupRotationR(step);
//m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2);
update = true;
}
}
}
if (angle > 0.01f)
{
m_group.UpdateGroupRotationR(step);
//m_group.RootPart.UpdateAngularVelocity(m_currentFrame.AngularVelocity / 2);
update = true;
}
if (update)
m_group.SendGroupRootTerseUpdate();
}
catch ( Exception ex)
{
// still happening sometimes
// lets try to see where
m_log.Warn("[KeyFrame]: timer overrun" + ex.Message);
}
if (update)
m_group.SendGroupRootTerseUpdate();
}
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];
finally
{
// make sure we do not let this frozen
m_inOnTimer = false;
}
}
}
public Byte[] Serialize()
{
StopTimer();
MemoryStream ms = new MemoryStream();
m_timer.Stop();
BinaryFormatter fmt = new BinaryFormatter();
SceneObjectGroup tmp = m_group;
m_group = null;
m_serializedPosition = tmp.AbsolutePosition;
if (!m_selected && tmp != null)
m_serializedPosition = tmp.AbsolutePosition;
fmt.Serialize(ms, this);
m_group = tmp;
if (m_running && !m_waitingCrossing)
StartTimer();
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()
{
// The serialization has stopped the timer, so let's wait a moment
// then retry the crossing. We'll get back here if it fails.
Util.FireAndForget(delegate (object x)
m_waitingCrossing = false;
if (m_group != null)
{
Thread.Sleep(60000);
if (m_running)
m_timer.Start();
});
m_group.RootPart.Velocity = Vector3.Zero;
m_group.SendGroupRootTerseUpdate();
if (m_running && m_timer != null)
{
m_timer.Interval = 60000;
StartTimer();
}
}
}
}
}

View File

@ -422,6 +422,20 @@ namespace OpenSim.Region.Framework.Scenes
);
}
private class DescendentsRequestData
{
public IClientAPI RemoteClient;
public UUID FolderID;
public UUID OwnerID;
public bool FetchFolders;
public bool FetchItems;
public int SortOrder;
}
private Queue<DescendentsRequestData> m_descendentsRequestQueue = new Queue<DescendentsRequestData>();
private Object m_descendentsRequestLock = new Object();
private bool m_descendentsRequestProcessing = false;
/// <summary>
/// Tell the client about the various child items and folders contained in the requested folder.
/// </summary>
@ -458,17 +472,38 @@ namespace OpenSim.Region.Framework.Scenes
}
}
// We're going to send the reply async, because there may be
// an enormous quantity of packets -- basically the entire inventory!
// We don't want to block the client thread while all that is happening.
SendInventoryDelegate d = SendInventoryAsync;
d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d);
lock (m_descendentsRequestLock)
{
if (!m_descendentsRequestProcessing)
{
m_descendentsRequestProcessing = true;
// We're going to send the reply async, because there may be
// an enormous quantity of packets -- basically the entire inventory!
// We don't want to block the client thread while all that is happening.
SendInventoryDelegate d = SendInventoryAsync;
d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d);
return;
}
DescendentsRequestData req = new DescendentsRequestData();
req.RemoteClient = remoteClient;
req.FolderID = folderID;
req.OwnerID = ownerID;
req.FetchFolders = fetchFolders;
req.FetchItems = fetchItems;
req.SortOrder = sortOrder;
m_descendentsRequestQueue.Enqueue(req);
}
}
delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder);
void SendInventoryAsync(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder)
{
Thread.Sleep(20);
SendInventoryUpdate(remoteClient, new InventoryFolderBase(folderID), fetchFolders, fetchItems);
}
@ -476,6 +511,21 @@ namespace OpenSim.Region.Framework.Scenes
{
SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState;
d.EndInvoke(iar);
lock (m_descendentsRequestLock)
{
if (m_descendentsRequestQueue.Count > 0)
{
DescendentsRequestData req = m_descendentsRequestQueue.Dequeue();
d = SendInventoryAsync;
d.BeginInvoke(req.RemoteClient, req.FolderID, req.OwnerID, req.FetchFolders, req.FetchItems, req.SortOrder, SendInventoryComplete, d);
return;
}
m_descendentsRequestProcessing = false;
}
}
/// <summary>

View File

@ -2376,6 +2376,12 @@ namespace OpenSim.Region.Framework.Scenes
foreach (SceneObjectPart part in partList)
{
if (part.KeyframeMotion != null)
{
part.KeyframeMotion.Delete();
part.KeyframeMotion = null;
}
if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0))
{
PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?

View File

@ -509,6 +509,9 @@ namespace OpenSim.Region.Framework.Scenes
Vector3 newpos = Vector3.Zero;
OpenSim.Services.Interfaces.GridRegion destination = null;
if (m_rootPart.KeyframeMotion != null)
m_rootPart.KeyframeMotion.StartCrossingCheck();
bool canCross = true;
foreach (ScenePresence av in m_linkedAvatars)
{
@ -551,7 +554,7 @@ namespace OpenSim.Region.Framework.Scenes
av.ParentID = 0;
}
// m_linkedAvatars.Clear();
// m_linkedAvatars.Clear();
m_scene.CrossPrimGroupIntoNewRegion(val, this, true);
// Normalize
@ -599,11 +602,16 @@ namespace OpenSim.Region.Framework.Scenes
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;
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);
@ -2054,15 +2062,16 @@ namespace OpenSim.Region.Framework.Scenes
HasGroupChangedDueToDelink = false;
m_scene.EventManager.TriggerOnSceneObjectPreSave(backup_group, this);
/*
backup_group.ForEachPart(delegate(SceneObjectPart part)
{
if (part.KeyframeMotion != null)
{
part.KeyframeMotion = KeyframeMotion.FromData(backup_group, part.KeyframeMotion.Serialize());
part.KeyframeMotion.UpdateSceneObject(this);
// part.KeyframeMotion.UpdateSceneObject(this);
}
});
*/
datastore.StoreObject(backup_group, m_scene.RegionInfo.RegionID);
backup_group.ForEachPart(delegate(SceneObjectPart part)
@ -3025,7 +3034,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="objectGroup"></param>
public virtual void DetachFromBackup()
{
m_scene.SceneGraph.FireDetachFromBackup(this);
if (m_scene != null)
m_scene.SceneGraph.FireDetachFromBackup(this);
if (m_isBackedUp && Scene != null)
m_scene.EventManager.OnBackup -= ProcessBackup;

View File

@ -769,7 +769,7 @@ namespace OpenSim.Region.Framework.Scenes
{
m_groupPosition = value;
PhysicsActor actor = PhysActor;
if (actor != null)
if (actor != null && ParentGroup.Scene.PhysicsScene != null)
{
try
{
@ -2110,6 +2110,9 @@ namespace OpenSim.Region.Framework.Scenes
Array.Copy(Shape.ExtraParams, extraP, extraP.Length);
dupe.Shape.ExtraParams = extraP;
if (KeyframeMotion != null)
dupe.KeyframeMotion = KeyframeMotion.Copy(null);
if (userExposed)
{
if (dupe.m_shape.SculptEntry && dupe.m_shape.SculptTexture != UUID.Zero)
@ -3407,6 +3410,9 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public void SendTerseUpdateToAllClients()
{
if (ParentGroup == null || ParentGroup.Scene == null)
return;
ParentGroup.Scene.ForEachClient(delegate(IClientAPI client)
{
SendTerseUpdateToClient(client);

View File

@ -1241,7 +1241,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
if (sog.RootPart.KeyframeMotion != null)
{
Byte[] data = sog.RootPart.KeyframeMotion.Serialize();
Byte[] data = sog.RootPart.KeyframeMotion.Serialize();
writer.WriteStartElement(String.Empty, "KeyframeMotion", String.Empty);
writer.WriteBase64(data, 0, data.Length);

View File

@ -5442,7 +5442,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// for completion and should LSL_Key ever be implemented
// as it's own struct
else if (!(src.Data[index] is LSL_String ||
src.Data[index] is LSL_Key))
src.Data[index] is LSL_Key ||
src.Data[index] is String))
{
return "";
}
@ -7750,6 +7751,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
foreach (ScenePresence p in avatars)
parts.Add(p);
remaining = null;
foreach (object part in parts)
{
if (part is SceneObjectPart)
@ -12379,7 +12381,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llCollisionSprite(string impact_sprite)
{
m_host.AddScriptLPS(1);
NotImplemented("llCollisionSprite");
// Viewer 2.0 broke this and it's likely LL has no intention
// of fixing it. Therefore, letting this be a NOP seems appropriate.
}
public void llGodLikeRezObject(string inventory, LSL_Vector pos)
@ -12524,7 +12527,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (frames.Data.Length > 0) // We are getting a new motion
{
if (group.RootPart.KeyframeMotion != null)
group.RootPart.KeyframeMotion.Stop();
group.RootPart.KeyframeMotion.Delete();
group.RootPart.KeyframeMotion = null;
int idx = 0;

View File

@ -65,7 +65,6 @@ namespace OpenSim.Services.AuthenticationService
public string Authenticate(UUID principalID, string password, int lifetime)
{
UUID realID;
return Authenticate(principalID, password, lifetime, out realID);
}

View File

@ -63,7 +63,6 @@ namespace OpenSim.Services.AuthenticationService
public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
{
realID = UUID.Zero;
return Authenticate(principalID, password, lifetime);
}

View File

@ -64,6 +64,7 @@ namespace OpenSim.Services.AuthenticationService
{
AuthenticationData data = m_Database.Get(principalID);
string result = String.Empty;
realID = UUID.Zero;
if (data != null && data.Data != null)
{
if (data.Data.ContainsKey("webLoginKey"))
@ -85,7 +86,7 @@ namespace OpenSim.Services.AuthenticationService
}
}
realID = UUID.Zero;
if (result == string.Empty)
{
@ -96,6 +97,8 @@ namespace OpenSim.Services.AuthenticationService
{
m_log.DebugFormat("[AUTH SERVICE]: PrincipalID {0} or its data not found", principalID);
}
return result;
}
}

View File

@ -104,6 +104,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
public string Authenticate(UUID principalID, string password, int lifetime, out UUID realID)
{
realID = UUID.Zero;
return Authenticate(principalID, password, lifetime);
}