From 63c42d66022ea7f1c2805b8f77980af5d4ba1fb4 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 18 Jul 2013 21:28:36 +0100 Subject: Do some simple queue empty checks in the main outgoing udp loop instead of always performing these on a separate fired thread. This appears to improve cpu usage since launching a new thread is more expensive than performing a small amount of inline logic. However, needs testing at scale. --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 28 +++++++++ .../ClientStack/Linden/UDP/LLImageManager.cs | 7 +++ .../Region/ClientStack/Linden/UDP/LLUDPClient.cs | 69 ++++++++++++++++------ .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 4 +- .../ClientStack/Linden/UDP/OpenSimUDPBase.cs | 6 +- 5 files changed, 92 insertions(+), 22 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 7229d7c..711a574 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -485,6 +485,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_udpServer = udpServer; m_udpClient = udpClient; m_udpClient.OnQueueEmpty += HandleQueueEmpty; + m_udpClient.HasUpdates += HandleHasUpdates; m_udpClient.OnPacketStats += PopulateStats; m_prioritizer = new Prioritizer(m_scene); @@ -4133,8 +4134,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories) { +// if (!m_udpServer.IsRunningOutbound) +// return; + if ((categories & ThrottleOutPacketTypeFlags.Task) != 0) { +// if (!m_udpServer.IsRunningOutbound) +// return; + if (m_maxUpdates == 0 || m_LastQueueFill == 0) { m_maxUpdates = m_udpServer.PrimUpdatesPerCallback; @@ -4160,6 +4167,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit); } + internal bool HandleHasUpdates(ThrottleOutPacketTypeFlags categories) + { + bool hasUpdates = false; + + if ((categories & ThrottleOutPacketTypeFlags.Task) != 0) + { + if (m_entityUpdates.Count > 0) + hasUpdates = true; + else if (m_entityProps.Count > 0) + hasUpdates = true; + } + + if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0) + { + if (ImageManager.HasUpdates()) + hasUpdates = true; + } + + return hasUpdates; + } + public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) { AssetUploadCompletePacket newPack = new AssetUploadCompletePacket(); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs index 073c357..41dd4d1 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLImageManager.cs @@ -206,6 +206,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + public bool HasUpdates() + { + J2KImage image = GetHighestPriorityImage(); + + return image != null && image.IsDecoded; + } + public bool ProcessImageQueue(int packetsToSend) { int packetsSent = 0; diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs index 7749446..202cc62 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs @@ -31,6 +31,7 @@ using System.Net; using System.Threading; using log4net; using OpenSim.Framework; +using OpenSim.Framework.Monitoring; using OpenMetaverse; using OpenMetaverse.Packets; @@ -81,6 +82,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// hooked to put more data on the empty queue public event QueueEmpty OnQueueEmpty; + public event Func HasUpdates; + /// AgentID for this client public readonly UUID AgentID; /// The remote address of the connected client @@ -613,15 +616,38 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Throttle categories to fire the callback for private void BeginFireQueueEmpty(ThrottleOutPacketTypeFlags categories) { - if (m_nextOnQueueEmpty != 0 && (Environment.TickCount & Int32.MaxValue) >= m_nextOnQueueEmpty) +// if (m_nextOnQueueEmpty != 0 && (Environment.TickCount & Int32.MaxValue) >= m_nextOnQueueEmpty) + if (!m_isQueueEmptyRunning && (Environment.TickCount & Int32.MaxValue) >= m_nextOnQueueEmpty) { + m_isQueueEmptyRunning = true; + + int start = Environment.TickCount & Int32.MaxValue; + const int MIN_CALLBACK_MS = 30; + + m_nextOnQueueEmpty = start + MIN_CALLBACK_MS; + if (m_nextOnQueueEmpty == 0) + m_nextOnQueueEmpty = 1; + // Use a value of 0 to signal that FireQueueEmpty is running - m_nextOnQueueEmpty = 0; - // Asynchronously run the callback - Util.FireAndForget(FireQueueEmpty, categories); +// m_nextOnQueueEmpty = 0; + + m_categories = categories; + + if (HasUpdates(m_categories)) + { + // Asynchronously run the callback + Util.FireAndForget(FireQueueEmpty, categories); + } + else + { + m_isQueueEmptyRunning = false; + } } } + private bool m_isQueueEmptyRunning; + private ThrottleOutPacketTypeFlags m_categories = 0; + /// /// Fires the OnQueueEmpty callback and sets the minimum time that it /// can be called again @@ -631,22 +657,31 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// signature private void FireQueueEmpty(object o) { - const int MIN_CALLBACK_MS = 30; +// int start = Environment.TickCount & Int32.MaxValue; +// const int MIN_CALLBACK_MS = 30; - ThrottleOutPacketTypeFlags categories = (ThrottleOutPacketTypeFlags)o; - QueueEmpty callback = OnQueueEmpty; - - int start = Environment.TickCount & Int32.MaxValue; +// if (m_udpServer.IsRunningOutbound) +// { + ThrottleOutPacketTypeFlags categories = (ThrottleOutPacketTypeFlags)o; + QueueEmpty callback = OnQueueEmpty; - if (callback != null) - { - try { callback(categories); } - catch (Exception e) { m_log.Error("[LLUDPCLIENT]: OnQueueEmpty(" + categories + ") threw an exception: " + e.Message, e); } - } + if (callback != null) + { +// if (m_udpServer.IsRunningOutbound) +// { + try { callback(categories); } + catch (Exception e) { m_log.Error("[LLUDPCLIENT]: OnQueueEmpty(" + categories + ") threw an exception: " + e.Message, e); } +// } + } +// } + +// m_nextOnQueueEmpty = start + MIN_CALLBACK_MS; +// if (m_nextOnQueueEmpty == 0) +// m_nextOnQueueEmpty = 1; + +// } - m_nextOnQueueEmpty = start + MIN_CALLBACK_MS; - if (m_nextOnQueueEmpty == 0) - m_nextOnQueueEmpty = 1; + m_isQueueEmptyRunning = false; } /// diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 54cafb2..e871ca2 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -1662,8 +1662,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Action generic every round Action clientPacketHandler = ClientOutgoingPacketHandler; -// while (true) - while (base.IsRunningOutbound) + while (true) +// while (base.IsRunningOutbound) { try { diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index f143c32..512f60d 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs @@ -308,8 +308,8 @@ namespace OpenMetaverse public void AsyncBeginSend(UDPPacketBuffer buf) { - if (IsRunningOutbound) - { +// if (IsRunningOutbound) +// { try { m_udpSocket.BeginSendTo( @@ -323,7 +323,7 @@ namespace OpenMetaverse } catch (SocketException) { } catch (ObjectDisposedException) { } - } +// } } void AsyncEndSend(IAsyncResult result) -- cgit v1.1 From 98d47ea428cd31b302e33dc6015a889d38bcb267 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 18 Jul 2013 17:17:20 -0700 Subject: Delay the enqueueing of non-longpoll requests for 100ms. No need to have these requests actively on the processing queue if it seems they're not ready. --- .../Servers/HttpServer/PollServiceRequestManager.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index e811079..727dbe5 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -96,7 +96,17 @@ namespace OpenSim.Framework.Servers.HttpServer private void ReQueueEvent(PollServiceHttpRequest req) { if (m_running) - m_requests.Enqueue(req); + { + // delay the enqueueing for 100ms. There's no need to have the event + // actively on the queue + Timer t = new Timer(self => { + ((Timer)self).Dispose(); + m_requests.Enqueue(req); + }); + + t.Change(100, Timeout.Infinite); + + } } public void Enqueue(PollServiceHttpRequest req) -- cgit v1.1 From 3a476bf60ce6364f5fd562132625027b73606fea Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 18 Jul 2013 22:42:25 +0100 Subject: Fix up a temporary debugging change from last commit which stopped "lludp stop out" from actually doing anything --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index e871ca2..a1085fa 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -1662,8 +1662,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // Action generic every round Action clientPacketHandler = ClientOutgoingPacketHandler; - while (true) -// while (base.IsRunningOutbound) + while (base.IsRunningOutbound) { try { -- cgit v1.1 From 66048e1a7024f151739fdb0be2309787a76c8403 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 18 Jul 2013 22:54:10 +0100 Subject: minor: provide user feedback in the log for now when udp in/out bound threads are started/stopped --- OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index 512f60d..a919141 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs @@ -111,6 +111,8 @@ namespace OpenMetaverse if (!IsRunningInbound) { + m_log.DebugFormat("[UDPBASE]: Starting inbound UDP loop"); + const int SIO_UDP_CONNRESET = -1744830452; IPEndPoint ipep = new IPEndPoint(m_localBindAddress, m_udpPort); @@ -155,6 +157,8 @@ namespace OpenMetaverse /// public void StartOutbound() { + m_log.DebugFormat("[UDPBASE]: Starting outbound UDP loop"); + IsRunningOutbound = true; } @@ -162,10 +166,8 @@ namespace OpenMetaverse { if (IsRunningInbound) { - // wait indefinitely for a writer lock. Once this is called, the .NET runtime - // will deny any more reader locks, in effect blocking all other send/receive - // threads. Once we have the lock, we set IsRunningInbound = false to inform the other - // threads that the socket is closed. + m_log.DebugFormat("[UDPBASE]: Stopping inbound UDP loop"); + IsRunningInbound = false; m_udpSocket.Close(); } @@ -173,6 +175,8 @@ namespace OpenMetaverse public void StopOutbound() { + m_log.DebugFormat("[UDPBASE]: Stopping outbound UDP loop"); + IsRunningOutbound = false; } -- cgit v1.1 From 5a2d4d888c02bef984f42eecaec62164a1e58b72 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 18 Jul 2013 23:05:45 +0100 Subject: Hack in console command "debug lludp toggle agentupdate" to allow AgentUpdate in packets to be discarded at a very early stage. Enabling this will stop anybody from moving on a sim, though all other updates should be unaffected. Appears to make some cpu difference on very basic testing with a static standing avatar (though not all that much). Need to see the results with much higher av numbers. --- .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index a1085fa..78d4165 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -572,6 +572,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP "debug lludp status", "Return status of LLUDP packet processing.", HandleStatusCommand); + + MainConsole.Instance.Commands.AddCommand( + "Debug", + false, + "debug lludp toggle agentupdate", + "debug lludp toggle agentupdate", + "Toggle whether agentupdate packets are processed or simply discarded.", + HandleAgentUpdateCommand); } private void HandlePacketCommand(string module, string[] args) @@ -706,6 +714,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP } } + bool m_discardAgentUpdates; + + private void HandleAgentUpdateCommand(string module, string[] args) + { + if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) + return; + + m_discardAgentUpdates = !m_discardAgentUpdates; + + MainConsole.Instance.OutputFormat( + "Discard AgentUpdates now {0} for {1}", m_discardAgentUpdates, m_scene.Name); + } + private void HandleStatusCommand(string module, string[] args) { if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene) @@ -1286,6 +1307,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP LogPacketHeader(true, udpClient.CircuitCode, 0, packet.Type, (ushort)packet.Length); #endregion BinaryStats + if (m_discardAgentUpdates && packet.Type == PacketType.AgentUpdate) + return; + #region Ping Check Handling if (packet.Type == PacketType.StartPingCheck) -- cgit v1.1 From e5c677779b8501c245e5399240ffe3ca2519ec72 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 19 Jul 2013 00:16:09 +0100 Subject: Add measure of number of inbound AgentUpdates that were seen as significant to "show client stats" (i.e. sent on for further processing instead of being discarded) Added here since it was the most convenient place Number is in the last column, "Sig. AgentUpdates" along with percentage of all AgentUpdates Percentage largely falls over time, most cpu for processing AgentUpdates may be in UDP processing as turning this off even earlier (with "debug lludp toggle agentupdate" results in a big cpu fall Also tidies up display. --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 3 +++ .../OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 711a574..3145275 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5565,6 +5565,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region Packet Handlers + public int TotalSignificantAgentUpdates { get; private set; } + #region Scene/Avatar private bool HandleAgentUpdate(IClientAPI sener, Packet packet) @@ -5614,6 +5616,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (update) { // m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); + TotalSignificantAgentUpdates++; m_lastAgentUpdateArgs.AgentID = x.AgentID; m_lastAgentUpdateArgs.BodyRotation = x.BodyRotation; diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 79509ab..c208b38 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -611,7 +611,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden // if (showParams.Length <= 4) { - m_log.InfoFormat("[INFO]: {0,-12} {1,20} {2,6} {3,11} {4, 10}", "Region", "Name", "Root", "Time", "Reqs/min"); + m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", "Region", "Name", "Root", "Time", "Reqs/min", "Sig. AgentUpdates"); foreach (Scene scene in m_scenes.Values) { scene.ForEachClient( @@ -624,9 +624,15 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum(); avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1); - m_log.InfoFormat("[INFO]: {0,-12} {1,20} {2,4} {3,9}min {4,10}", + m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11}/min {5,-16}", scene.RegionInfo.RegionName, llClient.Name, - (llClient.SceneAgent.IsChildAgent ? "N" : "Y"), (DateTime.Now - cinfo.StartedTime).Minutes, avg_reqs); + llClient.SceneAgent.IsChildAgent ? "N" : "Y", + (DateTime.Now - cinfo.StartedTime).Minutes, + avg_reqs, + string.Format( + "{0}, {1}%", + llClient.TotalSignificantAgentUpdates, + (float)llClient.TotalSignificantAgentUpdates / cinfo.SyncRequests["AgentUpdate"] * 100)); } }); } -- cgit v1.1 From 61eda1f441092eb12936472de2dc73898e40aa16 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 19 Jul 2013 00:51:13 +0100 Subject: Make the check as to whether any particular inbound AgentUpdate packet is significant much earlier in UDP processing (i.e. before we pointlessly place such packets on internal queues, etc.) Appears to have some impact on cpu but needs testing. --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 170 ++++++++++++++------- .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 17 ++- .../Agent/UDP/Linden/LindenUDPInfoModule.cs | 4 +- 3 files changed, 131 insertions(+), 60 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 3145275..7e5511f 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -357,7 +357,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods /// cannot retain a reference to it outside of that method. /// - private AgentUpdateArgs m_lastAgentUpdateArgs; + private AgentUpdateArgs m_lastAgentUpdateArgs = new AgentUpdateArgs(); + + private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs(); protected Dictionary m_packetHandlers = new Dictionary(); protected Dictionary m_genericPacketHandlers = new Dictionary(); //PauPaw:Local Generic Message handlers @@ -5569,80 +5571,136 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region Scene/Avatar + /// + /// This checks the update significance against the last update made. + /// + /// Can only be called by one thread at a time, and not at the same time as + /// + /// /returns> + /// + public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) + { + bool update = false; + + if (m_lastAgentUpdateArgs != null) + { + // These should be ordered from most-likely to + // least likely to change. I've made an initial + // guess at that. + update = + ( + (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || + (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || + (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || + (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || + (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || + (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || + (x.Far != m_lastAgentUpdateArgs.Far) || + (x.Flags != m_lastAgentUpdateArgs.Flags) || + (x.State != m_lastAgentUpdateArgs.State) || + (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || + (x.SessionID != m_lastAgentUpdateArgs.SessionID) || + (x.AgentID != m_lastAgentUpdateArgs.AgentID) + ); + } + else + { + m_lastAgentUpdateArgs = new AgentUpdateArgs(); + update = true; + } + + if (update) + { +// m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); + TotalSignificantAgentUpdates++; + + m_lastAgentUpdateArgs.AgentID = x.AgentID; + m_lastAgentUpdateArgs.BodyRotation = x.BodyRotation; + m_lastAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; + m_lastAgentUpdateArgs.CameraCenter = x.CameraCenter; + m_lastAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; + m_lastAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; + m_lastAgentUpdateArgs.ControlFlags = x.ControlFlags; + m_lastAgentUpdateArgs.Far = x.Far; + m_lastAgentUpdateArgs.Flags = x.Flags; + m_lastAgentUpdateArgs.HeadRotation = x.HeadRotation; + m_lastAgentUpdateArgs.SessionID = x.SessionID; + m_lastAgentUpdateArgs.State = x.State; + } + + return update; + } + private bool HandleAgentUpdate(IClientAPI sener, Packet packet) { if (OnAgentUpdate != null) { AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; - #region Packet Session and User Check - if (agentUpdate.AgentData.SessionID != SessionId || agentUpdate.AgentData.AgentID != AgentId) - { - PacketPool.Instance.ReturnPacket(packet); - return false; - } - #endregion - - bool update = false; + // Now done earlier +// #region Packet Session and User Check +// if (agentUpdate.AgentData.SessionID != SessionId || agentUpdate.AgentData.AgentID != AgentId) +// { +// PacketPool.Instance.ReturnPacket(packet); +// return false; +// } +// #endregion +// +// bool update = false; AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData; - - if (m_lastAgentUpdateArgs != null) - { - // These should be ordered from most-likely to - // least likely to change. I've made an initial - // guess at that. - update = - ( - (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || - (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || - (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || - (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || - (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || - (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || - (x.Far != m_lastAgentUpdateArgs.Far) || - (x.Flags != m_lastAgentUpdateArgs.Flags) || - (x.State != m_lastAgentUpdateArgs.State) || - (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || - (x.SessionID != m_lastAgentUpdateArgs.SessionID) || - (x.AgentID != m_lastAgentUpdateArgs.AgentID) - ); - } - else - { - m_lastAgentUpdateArgs = new AgentUpdateArgs(); - update = true; - } - - if (update) - { -// m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); +// +// if (m_lastAgentUpdateArgs != null) +// { +// // These should be ordered from most-likely to +// // least likely to change. I've made an initial +// // guess at that. +// update = +// ( +// (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || +// (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || +// (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || +// (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || +// (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || +// (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || +// (x.Far != m_lastAgentUpdateArgs.Far) || +// (x.Flags != m_lastAgentUpdateArgs.Flags) || +// (x.State != m_lastAgentUpdateArgs.State) || +// (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || +// (x.SessionID != m_lastAgentUpdateArgs.SessionID) || +// (x.AgentID != m_lastAgentUpdateArgs.AgentID) +// ); +// } +// +// if (update) +// { +//// m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); TotalSignificantAgentUpdates++; - m_lastAgentUpdateArgs.AgentID = x.AgentID; - m_lastAgentUpdateArgs.BodyRotation = x.BodyRotation; - m_lastAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; - m_lastAgentUpdateArgs.CameraCenter = x.CameraCenter; - m_lastAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; - m_lastAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; - m_lastAgentUpdateArgs.ControlFlags = x.ControlFlags; - m_lastAgentUpdateArgs.Far = x.Far; - m_lastAgentUpdateArgs.Flags = x.Flags; - m_lastAgentUpdateArgs.HeadRotation = x.HeadRotation; - m_lastAgentUpdateArgs.SessionID = x.SessionID; - m_lastAgentUpdateArgs.State = x.State; + m_thisAgentUpdateArgs.AgentID = x.AgentID; + m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation; + m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; + m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter; + m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; + m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; + m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags; + m_thisAgentUpdateArgs.Far = x.Far; + m_thisAgentUpdateArgs.Flags = x.Flags; + m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation; + m_thisAgentUpdateArgs.SessionID = x.SessionID; + m_thisAgentUpdateArgs.State = x.State; UpdateAgent handlerAgentUpdate = OnAgentUpdate; UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate; if (handlerPreAgentUpdate != null) - OnPreAgentUpdate(this, m_lastAgentUpdateArgs); + OnPreAgentUpdate(this, m_thisAgentUpdateArgs); if (handlerAgentUpdate != null) - OnAgentUpdate(this, m_lastAgentUpdateArgs); + OnAgentUpdate(this, m_thisAgentUpdateArgs); handlerAgentUpdate = null; handlerPreAgentUpdate = null; - } +// } } PacketPool.Instance.ReturnPacket(packet); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 78d4165..766c2fe 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -1307,8 +1307,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP LogPacketHeader(true, udpClient.CircuitCode, 0, packet.Type, (ushort)packet.Length); #endregion BinaryStats - if (m_discardAgentUpdates && packet.Type == PacketType.AgentUpdate) - return; + if (packet.Type == PacketType.AgentUpdate) + { + if (m_discardAgentUpdates) + return; + + AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; + + if (agentUpdate.AgentData.SessionID != client.SessionId + || agentUpdate.AgentData.AgentID != client.AgentId + || !((LLClientView)client).CheckAgentUpdateSignificance(agentUpdate.AgentData)) + { + PacketPool.Instance.ReturnPacket(packet); + return; + } + } #region Ping Check Handling diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index c208b38..3e6067d 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -611,7 +611,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden // if (showParams.Length <= 4) { - m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", "Region", "Name", "Root", "Time", "Reqs/min", "Sig. AgentUpdates"); + m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", "Region", "Name", "Root", "Time", "Reqs/min", "Sig. AgentUpdates"); foreach (Scene scene in m_scenes.Values) { scene.ForEachClient( @@ -624,7 +624,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum(); avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1); - m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11}/min {5,-16}", + m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", scene.RegionInfo.RegionName, llClient.Name, llClient.SceneAgent.IsChildAgent ? "N" : "Y", (DateTime.Now - cinfo.StartedTime).Minutes, -- cgit v1.1 From 866de5397890edbc0355b1925bf8537b40bab6a3 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 19 Jul 2013 00:56:45 +0100 Subject: Remove some pointless code in CheckAgentUpdateSignificance() --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 50 +++++++++------------- 1 file changed, 20 insertions(+), 30 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 7e5511f..c5bb697 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5574,40 +5574,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// /// This checks the update significance against the last update made. /// - /// Can only be called by one thread at a time, and not at the same time as - /// + /// Can only be called by one thread at a time /// /returns> /// public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) { - bool update = false; - - if (m_lastAgentUpdateArgs != null) - { - // These should be ordered from most-likely to - // least likely to change. I've made an initial - // guess at that. - update = - ( - (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || - (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || - (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || - (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || - (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || - (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || - (x.Far != m_lastAgentUpdateArgs.Far) || - (x.Flags != m_lastAgentUpdateArgs.Flags) || - (x.State != m_lastAgentUpdateArgs.State) || - (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || - (x.SessionID != m_lastAgentUpdateArgs.SessionID) || - (x.AgentID != m_lastAgentUpdateArgs.AgentID) - ); - } - else - { - m_lastAgentUpdateArgs = new AgentUpdateArgs(); - update = true; - } + // These should be ordered from most-likely to + // least likely to change. I've made an initial + // guess at that. + bool update = + ( + (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || + (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || + (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || + (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || + (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || + (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || + (x.Far != m_lastAgentUpdateArgs.Far) || + (x.Flags != m_lastAgentUpdateArgs.Flags) || + (x.State != m_lastAgentUpdateArgs.State) || + (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || + (x.SessionID != m_lastAgentUpdateArgs.SessionID) || + (x.AgentID != m_lastAgentUpdateArgs.AgentID) + ); + if (update) { -- cgit v1.1 From 3a6acbcc149fb359c2be2ee2c646c9b15809c01e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 19 Jul 2013 01:00:38 +0100 Subject: furhter shorten CheckAgentUpdateSignificance(). No real perf impact. --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index c5bb697..3d085c3 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5582,8 +5582,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP // These should be ordered from most-likely to // least likely to change. I've made an initial // guess at that. - bool update = - ( + if ( (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || @@ -5596,10 +5595,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || (x.SessionID != m_lastAgentUpdateArgs.SessionID) || (x.AgentID != m_lastAgentUpdateArgs.AgentID) - ); - - - if (update) + ) { // m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); TotalSignificantAgentUpdates++; @@ -5616,9 +5612,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_lastAgentUpdateArgs.HeadRotation = x.HeadRotation; m_lastAgentUpdateArgs.SessionID = x.SessionID; m_lastAgentUpdateArgs.State = x.State; + + return true; } - return update; + return false; } private bool HandleAgentUpdate(IClientAPI sener, Packet packet) -- cgit v1.1 From edafea6ae6dd3617520d989fb2fe748e3f0de1b3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 19 Jul 2013 13:17:15 -0700 Subject: PollServiceRequestManager: changed the long poll from a Queue to a List. No need to dequeue and enqueue items every 1sec. --- .../HttpServer/PollServiceRequestManager.cs | 30 ++++++++++++---------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 727dbe5..309b71f 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -47,7 +47,7 @@ namespace OpenSim.Framework.Servers.HttpServer private readonly BaseHttpServer m_server; private BlockingQueue m_requests = new BlockingQueue(); - private static Queue m_longPollRequests = new Queue(); + private static List m_longPollRequests = new List(); private uint m_WorkerThreadCount = 0; private Thread[] m_workerThreads; @@ -116,7 +116,7 @@ namespace OpenSim.Framework.Servers.HttpServer if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LongPoll) { lock (m_longPollRequests) - m_longPollRequests.Enqueue(req); + m_longPollRequests.Add(req); } else m_requests.Enqueue(req); @@ -139,18 +139,21 @@ namespace OpenSim.Framework.Servers.HttpServer List not_ready = new List(); lock (m_longPollRequests) { - while (m_longPollRequests.Count > 0 && m_running) + if (m_longPollRequests.Count > 0 && m_running) { - PollServiceHttpRequest req = m_longPollRequests.Dequeue(); - if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id) || // there are events in this EQ + List ready = m_longPollRequests.FindAll(req => + (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id) || // there are events in this EQ (Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms) // no events, but timeout - m_requests.Enqueue(req); - else - not_ready.Add(req); - } + ); - foreach (PollServiceHttpRequest req in not_ready) - m_longPollRequests.Enqueue(req); + ready.ForEach(req => + { + m_log.DebugFormat("[YYY]: --> Enqueuing"); + m_requests.Enqueue(req); + m_longPollRequests.Remove(req); + }); + + } } } @@ -169,8 +172,8 @@ namespace OpenSim.Framework.Servers.HttpServer lock (m_longPollRequests) { - while (m_longPollRequests.Count > 0 && m_running) - m_requests.Enqueue(m_longPollRequests.Dequeue()); + if (m_longPollRequests.Count > 0 && m_running) + m_longPollRequests.ForEach(req => m_requests.Enqueue(req)); } while (m_requests.Count() > 0) @@ -186,6 +189,7 @@ namespace OpenSim.Framework.Servers.HttpServer } } + m_longPollRequests.Clear(); m_requests.Clear(); } -- cgit v1.1 From 18d5d8f5dd6445e232a571c0e346eb862afcffc3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 19 Jul 2013 13:19:36 -0700 Subject: Removed verbose debug from previous commit --- OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index 309b71f..d83daab 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs @@ -148,7 +148,6 @@ namespace OpenSim.Framework.Servers.HttpServer ready.ForEach(req => { - m_log.DebugFormat("[YYY]: --> Enqueuing"); m_requests.Enqueue(req); m_longPollRequests.Remove(req); }); -- cgit v1.1 From 174105ad028c5ed318850238d97aa7c3b1d7f207 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 19 Jul 2013 22:11:32 -0700 Subject: Fixed the stats in show client stats. Also left some comments with observations about AgentUpdates. --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 18 +++++++++++++----- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 2 ++ .../Agent/UDP/Linden/LindenUDPInfoModule.cs | 8 ++++---- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 3d085c3..66a8ea7 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5567,7 +5567,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region Packet Handlers - public int TotalSignificantAgentUpdates { get; private set; } + public int TotalAgentUpdates { get; set; } #region Scene/Avatar @@ -5583,11 +5583,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP // least likely to change. I've made an initial // guess at that. if ( - (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || + /* These 4 are the worst offenders! We should consider ignoring most of them. + * With Singularity, there is a bug where sometimes the spam on these doesn't stop */ (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || + /* */ + (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || (x.Far != m_lastAgentUpdateArgs.Far) || (x.Flags != m_lastAgentUpdateArgs.Flags) || @@ -5597,8 +5600,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP (x.AgentID != m_lastAgentUpdateArgs.AgentID) ) { -// m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); - TotalSignificantAgentUpdates++; + //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}", + // x.CameraAtAxis, x.CameraCenter); + //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}", + // x.CameraLeftAxis, x.CameraUpAxis); + //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}", + // x.BodyRotation, x.HeadRotation); + //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}", + // x.ControlFlags, x.Flags, x.Far, x.State); m_lastAgentUpdateArgs.AgentID = x.AgentID; m_lastAgentUpdateArgs.BodyRotation = x.BodyRotation; @@ -5662,7 +5671,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP // if (update) // { //// m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); - TotalSignificantAgentUpdates++; m_thisAgentUpdateArgs.AgentID = x.AgentID; m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation; diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 766c2fe..32282af 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -1312,6 +1312,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP if (m_discardAgentUpdates) return; + ((LLClientView)client).TotalAgentUpdates++; + AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; if (agentUpdate.AgentData.SessionID != client.SessionId diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 3e6067d..15dea17 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs @@ -611,7 +611,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden // if (showParams.Length <= 4) { - m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", "Region", "Name", "Root", "Time", "Reqs/min", "Sig. AgentUpdates"); + m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", "Region", "Name", "Root", "Time", "Reqs/min", "AgentUpdates"); foreach (Scene scene in m_scenes.Values) { scene.ForEachClient( @@ -630,9 +630,9 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden (DateTime.Now - cinfo.StartedTime).Minutes, avg_reqs, string.Format( - "{0}, {1}%", - llClient.TotalSignificantAgentUpdates, - (float)llClient.TotalSignificantAgentUpdates / cinfo.SyncRequests["AgentUpdate"] * 100)); + "{0} ({1:0.00}%)", + llClient.TotalAgentUpdates, + (float)cinfo.SyncRequests["AgentUpdate"] / llClient.TotalAgentUpdates * 100)); } }); } -- cgit v1.1 From d5a1779465b6d875ebe5822ce6f15df3378b759f Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 20 Jul 2013 12:20:35 -0700 Subject: Manage AgentUpdates more sanely: - The existing event to scene has been split into 2: OnAgentUpdate and OnAgentCameraUpdate, to better reflect the two types of updates that the viewer sends. We can run one without the other, which is what happens when the avie is still but the user is camming around - Added thresholds (as opposed to equality) to determine whether the update is significant or not. I thin these thresholds are ok, but we can play with them later - Ignore updates of HeadRotation, which were problematic and aren't being used up stream --- OpenSim/Framework/IClientAPI.cs | 2 + .../Region/ClientStack/Linden/UDP/LLClientView.cs | 214 +++++++++++---------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 110 +++++++---- .../Server/IRCClientView.cs | 1 + .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 1 + OpenSim/Tests/Common/Mock/TestClient.cs | 1 + 6 files changed, 183 insertions(+), 146 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index 65f8395..f39eb0c 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -825,6 +825,8 @@ namespace OpenSim.Framework /// event UpdateAgent OnAgentUpdate; + event UpdateAgent OnAgentCameraUpdate; + event AgentRequestSit OnAgentRequestSit; event AgentSit OnAgentSit; event AvatarPickerRequest OnAvatarPickerRequest; diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 66a8ea7..6c58aac 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -96,6 +96,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event Action OnCompleteMovementToRegion; public event UpdateAgent OnPreAgentUpdate; public event UpdateAgent OnAgentUpdate; + public event UpdateAgent OnAgentCameraUpdate; public event AgentRequestSit OnAgentRequestSit; public event AgentSit OnAgentSit; public event AvatarPickerRequest OnAvatarPickerRequest; @@ -357,9 +358,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods /// cannot retain a reference to it outside of that method. /// - private AgentUpdateArgs m_lastAgentUpdateArgs = new AgentUpdateArgs(); - private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs(); + private float qdelta1; + private float qdelta2; + private float vdelta1; + private float vdelta2; + private float vdelta3; + private float vdelta4; protected Dictionary m_packetHandlers = new Dictionary(); protected Dictionary m_genericPacketHandlers = new Dictionary(); //PauPaw:Local Generic Message handlers @@ -5571,57 +5576,75 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region Scene/Avatar + private const float QDELTA = 0.01f; + private const float VDELTA = 0.01f; + /// /// This checks the update significance against the last update made. /// /// Can only be called by one thread at a time - /// /returns> + /// /// public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) { - // These should be ordered from most-likely to - // least likely to change. I've made an initial - // guess at that. + return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x); + } + + /// + /// This checks the movement/state update significance against the last update made. + /// + /// Can only be called by one thread at a time + /// + /// + public bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) + { + qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2); + qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2); + if ( + (qdelta1 > QDELTA) || + // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack + //(qdelta2 > QDELTA * 10) || + (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) || + (x.Far != m_thisAgentUpdateArgs.Far) || + (x.Flags != m_thisAgentUpdateArgs.Flags) || + (x.State != m_thisAgentUpdateArgs.State) + ) + { + //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}", + // qdelta1, qdelta2); + //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3} (Thread {4})", + // x.ControlFlags, x.Flags, x.Far, x.State, Thread.CurrentThread.Name); + return true; + } + + return false; + } + + /// + /// This checks the camera update significance against the last update made. + /// + /// Can only be called by one thread at a time + /// + /// + public bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) + { + vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis); + vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter); + vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis); + vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis); if ( - /* These 4 are the worst offenders! We should consider ignoring most of them. + /* These 4 are the worst offenders! * With Singularity, there is a bug where sometimes the spam on these doesn't stop */ - (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || - (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || - (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || - (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || - /* */ - (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || - (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || - (x.Far != m_lastAgentUpdateArgs.Far) || - (x.Flags != m_lastAgentUpdateArgs.Flags) || - (x.State != m_lastAgentUpdateArgs.State) || - (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || - (x.SessionID != m_lastAgentUpdateArgs.SessionID) || - (x.AgentID != m_lastAgentUpdateArgs.AgentID) + (vdelta1 > VDELTA) || + (vdelta2 > VDELTA) || + (vdelta3 > VDELTA) || + (vdelta4 > VDELTA) ) { //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}", // x.CameraAtAxis, x.CameraCenter); //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}", // x.CameraLeftAxis, x.CameraUpAxis); - //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}", - // x.BodyRotation, x.HeadRotation); - //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}", - // x.ControlFlags, x.Flags, x.Far, x.State); - - m_lastAgentUpdateArgs.AgentID = x.AgentID; - m_lastAgentUpdateArgs.BodyRotation = x.BodyRotation; - m_lastAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; - m_lastAgentUpdateArgs.CameraCenter = x.CameraCenter; - m_lastAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; - m_lastAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; - m_lastAgentUpdateArgs.ControlFlags = x.ControlFlags; - m_lastAgentUpdateArgs.Far = x.Far; - m_lastAgentUpdateArgs.Flags = x.Flags; - m_lastAgentUpdateArgs.HeadRotation = x.HeadRotation; - m_lastAgentUpdateArgs.SessionID = x.SessionID; - m_lastAgentUpdateArgs.State = x.State; - return true; } @@ -5629,75 +5652,54 @@ namespace OpenSim.Region.ClientStack.LindenUDP } private bool HandleAgentUpdate(IClientAPI sener, Packet packet) - { - if (OnAgentUpdate != null) - { - AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; + { + // We got here, which means that something in agent update was significant - // Now done earlier -// #region Packet Session and User Check -// if (agentUpdate.AgentData.SessionID != SessionId || agentUpdate.AgentData.AgentID != AgentId) -// { -// PacketPool.Instance.ReturnPacket(packet); -// return false; -// } -// #endregion -// -// bool update = false; - AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData; -// -// if (m_lastAgentUpdateArgs != null) -// { -// // These should be ordered from most-likely to -// // least likely to change. I've made an initial -// // guess at that. -// update = -// ( -// (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || -// (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || -// (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || -// (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || -// (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || -// (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || -// (x.Far != m_lastAgentUpdateArgs.Far) || -// (x.Flags != m_lastAgentUpdateArgs.Flags) || -// (x.State != m_lastAgentUpdateArgs.State) || -// (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || -// (x.SessionID != m_lastAgentUpdateArgs.SessionID) || -// (x.AgentID != m_lastAgentUpdateArgs.AgentID) -// ); -// } -// -// if (update) -// { -//// m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); - - m_thisAgentUpdateArgs.AgentID = x.AgentID; - m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation; - m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; - m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter; - m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; - m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; - m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags; - m_thisAgentUpdateArgs.Far = x.Far; - m_thisAgentUpdateArgs.Flags = x.Flags; - m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation; - m_thisAgentUpdateArgs.SessionID = x.SessionID; - m_thisAgentUpdateArgs.State = x.State; - - UpdateAgent handlerAgentUpdate = OnAgentUpdate; - UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate; - - if (handlerPreAgentUpdate != null) - OnPreAgentUpdate(this, m_thisAgentUpdateArgs); - - if (handlerAgentUpdate != null) - OnAgentUpdate(this, m_thisAgentUpdateArgs); - - handlerAgentUpdate = null; - handlerPreAgentUpdate = null; -// } - } + AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; + AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData; + + if (x.AgentID != AgentId || x.SessionID != SessionId) + return false; + + // Before we update the current m_thisAgentUpdateArgs, let's check this again + // to see what exactly changed + bool movement = CheckAgentMovementUpdateSignificance(x); + bool camera = CheckAgentCameraUpdateSignificance(x); + + m_thisAgentUpdateArgs.AgentID = x.AgentID; + m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation; + m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; + m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter; + m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; + m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; + m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags; + m_thisAgentUpdateArgs.Far = x.Far; + m_thisAgentUpdateArgs.Flags = x.Flags; + m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation; + m_thisAgentUpdateArgs.SessionID = x.SessionID; + m_thisAgentUpdateArgs.State = x.State; + + UpdateAgent handlerAgentUpdate = OnAgentUpdate; + UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate; + UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate; + + // Was there a significant movement/state change? + if (movement) + { + if (handlerPreAgentUpdate != null) + OnPreAgentUpdate(this, m_thisAgentUpdateArgs); + + if (handlerAgentUpdate != null) + OnAgentUpdate(this, m_thisAgentUpdateArgs); + } + // Was there a significant camera(s) change? + if (camera) + if (handlerAgentCameraUpdate != null) + handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs); + + handlerAgentUpdate = null; + handlerPreAgentUpdate = null; + handlerAgentCameraUpdate = null; PacketPool.Instance.ReturnPacket(packet); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 990ef6e..5543964 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -801,6 +801,7 @@ namespace OpenSim.Region.Framework.Scenes { ControllingClient.OnCompleteMovementToRegion += CompleteMovement; ControllingClient.OnAgentUpdate += HandleAgentUpdate; + ControllingClient.OnAgentCameraUpdate += HandleAgentCamerasUpdate; ControllingClient.OnAgentRequestSit += HandleAgentRequestSit; ControllingClient.OnAgentSit += HandleAgentSit; ControllingClient.OnSetAlwaysRun += HandleSetAlwaysRun; @@ -1438,9 +1439,9 @@ namespace OpenSim.Region.Framework.Scenes /// public void HandleAgentUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) { -// m_log.DebugFormat( -// "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", -// Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags); + //m_log.DebugFormat( + // "[SCENE PRESENCE]: In {0} received agent update from {1}, flags {2}", + // Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags); if (IsChildAgent) { @@ -1448,10 +1449,6 @@ namespace OpenSim.Region.Framework.Scenes return; } - ++m_movementUpdateCount; - if (m_movementUpdateCount < 1) - m_movementUpdateCount = 1; - #region Sanity Checking // This is irritating. Really. @@ -1482,21 +1479,6 @@ namespace OpenSim.Region.Framework.Scenes AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; - // Camera location in world. We'll need to raytrace - // from this location from time to time. - CameraPosition = agentData.CameraCenter; - if (Vector3.Distance(m_lastCameraPosition, CameraPosition) >= Scene.RootReprioritizationDistance) - { - ReprioritizeUpdates(); - m_lastCameraPosition = CameraPosition; - } - - // Use these three vectors to figure out what the agent is looking at - // Convert it to a Matrix and/or Quaternion - CameraAtAxis = agentData.CameraAtAxis; - CameraLeftAxis = agentData.CameraLeftAxis; - CameraUpAxis = agentData.CameraUpAxis; - // The Agent's Draw distance setting // When we get to the point of re-computing neighbors everytime this // changes, then start using the agent's drawdistance rather than the @@ -1504,12 +1486,6 @@ namespace OpenSim.Region.Framework.Scenes // DrawDistance = agentData.Far; DrawDistance = Scene.DefaultDrawDistance; - // Check if Client has camera in 'follow cam' or 'build' mode. - Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); - - m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f) - && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; - m_mouseLook = (flags & AgentManager.ControlFlags.AGENT_CONTROL_MOUSELOOK) != 0; m_leftButtonDown = (flags & AgentManager.ControlFlags.AGENT_CONTROL_LBUTTON_DOWN) != 0; @@ -1529,17 +1505,6 @@ namespace OpenSim.Region.Framework.Scenes StandUp(); } - //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); - // Raycast from the avatar's head to the camera to see if there's anything blocking the view - if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) - { - if (m_followCamAuto) - { - Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; - m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); - } - } - uint flagsForScripts = (uint)flags; flags = RemoveIgnoredControls(flags, IgnoredControls); @@ -1764,9 +1729,74 @@ namespace OpenSim.Region.Framework.Scenes } m_scene.EventManager.TriggerOnClientMovement(this); - TriggerScenePresenceUpdated(); } + + /// + /// This is the event handler for client cameras. If a client is moving, or moving the camera, this event is triggering. + /// + public void HandleAgentCamerasUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) + { + //m_log.DebugFormat( + // "[SCENE PRESENCE]: In {0} received agent camera update from {1}, flags {2}", + // Scene.RegionInfo.RegionName, remoteClient.Name, (AgentManager.ControlFlags)agentData.ControlFlags); + + if (IsChildAgent) + { + // // m_log.Debug("DEBUG: HandleAgentUpdate: child agent"); + return; + } + + ++m_movementUpdateCount; + if (m_movementUpdateCount < 1) + m_movementUpdateCount = 1; + + + AgentManager.ControlFlags flags = (AgentManager.ControlFlags)agentData.ControlFlags; + + // Camera location in world. We'll need to raytrace + // from this location from time to time. + CameraPosition = agentData.CameraCenter; + if (Vector3.Distance(m_lastCameraPosition, CameraPosition) >= Scene.RootReprioritizationDistance) + { + ReprioritizeUpdates(); + m_lastCameraPosition = CameraPosition; + } + + // Use these three vectors to figure out what the agent is looking at + // Convert it to a Matrix and/or Quaternion + CameraAtAxis = agentData.CameraAtAxis; + CameraLeftAxis = agentData.CameraLeftAxis; + CameraUpAxis = agentData.CameraUpAxis; + + // The Agent's Draw distance setting + // When we get to the point of re-computing neighbors everytime this + // changes, then start using the agent's drawdistance rather than the + // region's draw distance. + // DrawDistance = agentData.Far; + DrawDistance = Scene.DefaultDrawDistance; + + // Check if Client has camera in 'follow cam' or 'build' mode. + Vector3 camdif = (Vector3.One * Rotation - Vector3.One * CameraRotation); + + m_followCamAuto = ((CameraUpAxis.Z > 0.959f && CameraUpAxis.Z < 0.98f) + && (Math.Abs(camdif.X) < 0.4f && Math.Abs(camdif.Y) < 0.4f)) ? true : false; + + + //m_log.DebugFormat("[FollowCam]: {0}", m_followCamAuto); + // Raycast from the avatar's head to the camera to see if there's anything blocking the view + if ((m_movementUpdateCount % NumMovementsBetweenRayCast) == 0 && m_scene.PhysicsScene.SupportsRayCast()) + { + if (m_followCamAuto) + { + Vector3 posAdjusted = m_pos + HEAD_ADJUSTMENT; + m_scene.PhysicsScene.RaycastWorld(m_pos, Vector3.Normalize(CameraPosition - posAdjusted), Vector3.Distance(CameraPosition, posAdjusted) + 0.3f, RayCastCameraCallback); + } + } + + TriggerScenePresenceUpdated(); + } + /// /// Calculate an update to move the presence to the set target. /// diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 3726191..9b69da3 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -687,6 +687,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server public event Action OnCompleteMovementToRegion; public event UpdateAgent OnPreAgentUpdate; public event UpdateAgent OnAgentUpdate; + public event UpdateAgent OnAgentCameraUpdate; public event AgentRequestSit OnAgentRequestSit; public event AgentSit OnAgentSit; public event AvatarPickerRequest OnAvatarPickerRequest; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 592e4e1..6c38b65 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -258,6 +258,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event Action OnCompleteMovementToRegion; public event UpdateAgent OnPreAgentUpdate; public event UpdateAgent OnAgentUpdate; + public event UpdateAgent OnAgentCameraUpdate; public event AgentRequestSit OnAgentRequestSit; public event AgentSit OnAgentSit; public event AvatarPickerRequest OnAvatarPickerRequest; diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 2fc3f0b..5d7349a 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -106,6 +106,7 @@ namespace OpenSim.Tests.Common.Mock public event Action OnCompleteMovementToRegion; public event UpdateAgent OnPreAgentUpdate; public event UpdateAgent OnAgentUpdate; + public event UpdateAgent OnAgentCameraUpdate; public event AgentRequestSit OnAgentRequestSit; public event AgentSit OnAgentSit; public event AvatarPickerRequest OnAvatarPickerRequest; -- cgit v1.1 From 3919c805054e6ce240c72436414ecee18a6c2947 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 20 Jul 2013 13:42:39 -0700 Subject: A couple of small optimizations over the previous commit --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 18 ++++++++++-------- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 6c58aac..2907580 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5587,6 +5587,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) { + // Compute these only once, when this function is called from down below + qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2); + //qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2); + vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis); + vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter); + vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis); + vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis); + return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x); } @@ -5596,10 +5604,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Can only be called by one thread at a time /// /// - public bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) + private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) { - qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2); - qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2); if ( (qdelta1 > QDELTA) || // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack @@ -5626,12 +5632,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Can only be called by one thread at a time /// /// - public bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) + private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) { - vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis); - vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter); - vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis); - vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis); if ( /* These 4 are the worst offenders! * With Singularity, there is a bug where sometimes the spam on these doesn't stop */ diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5543964..2359f55 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1735,7 +1735,7 @@ namespace OpenSim.Region.Framework.Scenes /// /// This is the event handler for client cameras. If a client is moving, or moving the camera, this event is triggering. /// - public void HandleAgentCamerasUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) + private void HandleAgentCamerasUpdate(IClientAPI remoteClient, AgentUpdateArgs agentData) { //m_log.DebugFormat( // "[SCENE PRESENCE]: In {0} received agent camera update from {1}, flags {2}", -- cgit v1.1 From 032c637c10ee16f5a3b9b690de812701f3badee6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 20 Jul 2013 15:42:01 -0700 Subject: Filter certain viewer effects depending on distance between the avatar that is generating the effect and the cameras of the observers. In particular, this applies to LookAt (which is really verbose and occurs every time users move the mouse) and Beam (which doesn't occur that often, but that can be extremely noisy (10.sec) when it happens) --- .../Framework/Scenes/Scene.PacketHandlers.cs | 32 +++++++++++++++++----- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index df43271..998c19e 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs @@ -390,6 +390,7 @@ namespace OpenSim.Region.Framework.Scenes void ProcessViewerEffect(IClientAPI remoteClient, List args) { // TODO: don't create new blocks if recycling an old packet + bool discardableEffects = true; ViewerEffectPacket.EffectBlock[] effectBlockArray = new ViewerEffectPacket.EffectBlock[args.Count]; for (int i = 0; i < args.Count; i++) { @@ -401,17 +402,34 @@ namespace OpenSim.Region.Framework.Scenes effect.Type = args[i].Type; effect.TypeData = args[i].TypeData; effectBlockArray[i] = effect; + + if ((EffectType)effect.Type != EffectType.LookAt && (EffectType)effect.Type != EffectType.Beam) + discardableEffects = false; + + //m_log.DebugFormat("[YYY]: VE {0} {1} {2}", effect.AgentID, effect.Duration, (EffectType)effect.Type); } - ForEachClient( - delegate(IClientAPI client) + ForEachScenePresence(sp => { - if (client.AgentId != remoteClient.AgentId) - client.SendViewerEffect(effectBlockArray); - } - ); + if (sp.ControllingClient.AgentId != remoteClient.AgentId) + { + if (!discardableEffects || + (discardableEffects && ShouldSendDiscardableEffect(remoteClient, sp))) + { + //m_log.DebugFormat("[YYY]: Sending to {0}", sp.UUID); + sp.ControllingClient.SendViewerEffect(effectBlockArray); + } + //else + // m_log.DebugFormat("[YYY]: Not sending to {0}", sp.UUID); + } + }); } - + + private bool ShouldSendDiscardableEffect(IClientAPI thisClient, ScenePresence other) + { + return Vector3.Distance(other.CameraPosition, thisClient.SceneAgent.AbsolutePosition) < 10; + } + /// /// Tell the client about the various child items and folders contained in the requested folder. /// -- cgit v1.1 From b5ab0698d6328c90d779c2af29914da840335233 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 20 Jul 2013 17:58:32 -0700 Subject: EDIT BEAMS!!! They had been missing from OpenSim since ever. Thanks to lkalif for telling me how to route the information. The viewer effect is under the distance filter, so only avatars with cameras < 10m away see the beams. --- OpenSim/Framework/IClientAPI.cs | 2 +- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 27 ++++------------------ OpenSim/Region/Framework/Scenes/ScenePresence.cs | 5 +++- .../Server/IRCClientView.cs | 2 +- .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 2 +- OpenSim/Tests/Common/Mock/TestClient.cs | 2 +- 6 files changed, 12 insertions(+), 28 deletions(-) diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index f39eb0c..98358e5 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -1476,7 +1476,7 @@ namespace OpenSim.Framework void SendChangeUserRights(UUID agentID, UUID friendID, int rights); void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId); - void StopFlying(ISceneEntity presence); + void SendAgentTerseUpdate(ISceneEntity presence); void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data); } diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 2907580..a8759ab 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5016,7 +5016,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP { ScenePresence presence = (ScenePresence)entity; - attachPoint = 0; + attachPoint = presence.State; collisionPlane = presence.CollisionPlane; position = presence.OffsetPosition; velocity = presence.Velocity; @@ -5040,7 +5040,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP SceneObjectPart part = (SceneObjectPart)entity; attachPoint = part.ParentGroup.AttachmentPoint; - + attachPoint = ((attachPoint % 16) * 16 + (attachPoint / 16)); // m_log.DebugFormat( // "[LLCLIENTVIEW]: Sending attachPoint {0} for {1} {2} to {3}", // attachPoint, part.Name, part.LocalId, Name); @@ -5068,7 +5068,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP pos += 4; // Avatar/CollisionPlane - data[pos++] = (byte)((attachPoint % 16) * 16 + (attachPoint / 16)); ; + data[pos++] = (byte) attachPoint; if (avatar) { data[pos++] = 1; @@ -12550,7 +12550,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP OutPacket(dialog, ThrottleOutPacketType.Task); } - public void StopFlying(ISceneEntity p) + public void SendAgentTerseUpdate(ISceneEntity p) { if (p is ScenePresence) { @@ -12564,25 +12564,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP Vector3 pos = presence.AbsolutePosition; - if (presence.Appearance.AvatarHeight != 127.0f) - pos += new Vector3(0f, 0f, (presence.Appearance.AvatarHeight/6f)); - else - pos += new Vector3(0f, 0f, (1.56f/6f)); - - presence.AbsolutePosition = pos; - - // attach a suitable collision plane regardless of the actual situation to force the LLClient to land. - // Collision plane below the avatar's position a 6th of the avatar's height is suitable. - // Mind you, that this method doesn't get called if the avatar's velocity magnitude is greater then a - // certain amount.. because the LLClient wouldn't land in that situation anyway. - - // why are we still testing for this really old height value default??? - if (presence.Appearance.AvatarHeight != 127.0f) - presence.CollisionPlane = new Vector4(0, 0, 0, pos.Z - presence.Appearance.AvatarHeight/6f); - else - presence.CollisionPlane = new Vector4(0, 0, 0, pos.Z - (1.56f/6f)); - - ImprovedTerseObjectUpdatePacket.ObjectDataBlock block = CreateImprovedTerseBlock(p, false); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 2359f55..e06cec8 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1125,7 +1125,7 @@ namespace OpenSim.Region.Framework.Scenes public void StopFlying() { - ControllingClient.StopFlying(this); + ControllingClient.SendAgentTerseUpdate(this); } /// @@ -1728,6 +1728,9 @@ namespace OpenSim.Region.Framework.Scenes SendControlsToScripts(flagsForScripts); } + if ((State & 0x10) != 0) + ControllingClient.SendAgentTerseUpdate(this); + m_scene.EventManager.TriggerOnClientMovement(this); } diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 9b69da3..23a435d 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs @@ -1673,7 +1673,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server { } - public void StopFlying(ISceneEntity presence) + public void SendAgentTerseUpdate(ISceneEntity presence) { } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 6c38b65..9a61702 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -1229,7 +1229,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } - public void StopFlying(ISceneEntity presence) + public void SendAgentTerseUpdate(ISceneEntity presence) { } diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs index 5d7349a..f7220d7 100644 --- a/OpenSim/Tests/Common/Mock/TestClient.cs +++ b/OpenSim/Tests/Common/Mock/TestClient.cs @@ -1256,7 +1256,7 @@ namespace OpenSim.Tests.Common.Mock { } - public void StopFlying(ISceneEntity presence) + public void SendAgentTerseUpdate(ISceneEntity presence) { } -- cgit v1.1 From 116a449d8945d1d04013860f952841a71df80be7 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sat, 20 Jul 2013 19:20:20 -0700 Subject: The quaternion delta was a bit to high, now that the head rotation is out of the equation. (head rotation was the problematic one) --- OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index a8759ab..021b7c1 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5576,7 +5576,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region Scene/Avatar - private const float QDELTA = 0.01f; + private const float QDELTA = 0.000001f; private const float VDELTA = 0.01f; /// -- cgit v1.1 From 8d18ad2f6f75320dfb605b960f74531c1921b91b Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Jul 2013 08:50:52 -0700 Subject: Minor aesthetic change to make things more clear. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index e06cec8..33db88b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1728,7 +1728,8 @@ namespace OpenSim.Region.Framework.Scenes SendControlsToScripts(flagsForScripts); } - if ((State & 0x10) != 0) + // We need to send this back to the client in order to see the edit beams + if ((State & (uint)AgentState.Editing) != 0) ControllingClient.SendAgentTerseUpdate(this); m_scene.EventManager.TriggerOnClientMovement(this); -- cgit v1.1 From 99a727600b938383224285d9dad79e2b564cb1fe Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Jul 2013 10:07:35 -0700 Subject: Minor cosmetic changes. --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 50 ++++++++++------------ 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 021b7c1..e23e55b 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -5595,7 +5595,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis); vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis); - return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x); + bool significant = CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x); + + // Emergency debugging + //if (significant) + //{ + //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}", + // x.CameraAtAxis, x.CameraCenter); + //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}", + // x.CameraLeftAxis, x.CameraUpAxis); + //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}", + // qdelta1, qdelta2); + //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}", + // x.ControlFlags, x.Flags, x.Far, x.State); + //} + + return significant; + } /// @@ -5606,24 +5622,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) { - if ( + return ( (qdelta1 > QDELTA) || // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack //(qdelta2 > QDELTA * 10) || (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) || (x.Far != m_thisAgentUpdateArgs.Far) || (x.Flags != m_thisAgentUpdateArgs.Flags) || - (x.State != m_thisAgentUpdateArgs.State) - ) - { - //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}", - // qdelta1, qdelta2); - //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3} (Thread {4})", - // x.ControlFlags, x.Flags, x.Far, x.State, Thread.CurrentThread.Name); - return true; - } - - return false; + (x.State != m_thisAgentUpdateArgs.State) + ); } /// @@ -5634,23 +5641,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) { - if ( - /* These 4 are the worst offenders! - * With Singularity, there is a bug where sometimes the spam on these doesn't stop */ + return ( (vdelta1 > VDELTA) || (vdelta2 > VDELTA) || (vdelta3 > VDELTA) || - (vdelta4 > VDELTA) - ) - { - //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}", - // x.CameraAtAxis, x.CameraCenter); - //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}", - // x.CameraLeftAxis, x.CameraUpAxis); - return true; - } - - return false; + (vdelta4 > VDELTA) + ); } private bool HandleAgentUpdate(IClientAPI sener, Packet packet) -- cgit v1.1 From f81e289a1bc28b85d5e05a8549f9796f72d454ac Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Jul 2013 14:34:43 -0700 Subject: Add the Current Outfit folder as an available folder in the SuitcaseInventory. --- .../HypergridService/HGSuitcaseInventoryService.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index 2567c8f..06c5b89 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs @@ -493,6 +493,18 @@ namespace OpenSim.Services.HypergridService return null; } + private XInventoryFolder GetCurrentOutfitXFolder(UUID userID) + { + XInventoryFolder[] folders = m_Database.GetFolders( + new string[] { "agentID", "type" }, + new string[] { userID.ToString(), ((int)AssetType.CurrentOutfitFolder).ToString() }); + + if (folders.Length == 0) + return null; + + return folders[0]; + } + private XInventoryFolder GetSuitcaseXFolder(UUID principalID) { // Warp! Root folder for travelers @@ -531,6 +543,7 @@ namespace OpenSim.Services.HypergridService if (m_SuitcaseTrees.TryGetValue(principalID, out t)) return t; + // Get the tree of the suitcase folder t = GetFolderTreeRecursive(folder); m_SuitcaseTrees.AddOrUpdate(principalID, t, 5*60); // 5minutes return t; @@ -577,6 +590,9 @@ namespace OpenSim.Services.HypergridService List tree = new List(); tree.Add(suitcase); // Warp! the tree is the real root folder plus the children of the suitcase folder tree.AddRange(GetFolderTree(principalID, suitcase.folderID)); + // Also add the Current Outfit folder to the list of available folders + tree.Add(GetCurrentOutfitXFolder(principalID)); + XInventoryFolder f = tree.Find(delegate(XInventoryFolder fl) { if (fl.folderID == folderID) return true; -- cgit v1.1 From df63bfafefe431faf21ec1c52dbff78977f971e6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Jul 2013 14:39:50 -0700 Subject: Better version of previous commit --- OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs index 06c5b89..0601ece 100644 --- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs +++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs @@ -495,9 +495,13 @@ namespace OpenSim.Services.HypergridService private XInventoryFolder GetCurrentOutfitXFolder(UUID userID) { + XInventoryFolder root = GetRootXFolder(userID); + if (root == null) + return null; + XInventoryFolder[] folders = m_Database.GetFolders( - new string[] { "agentID", "type" }, - new string[] { userID.ToString(), ((int)AssetType.CurrentOutfitFolder).ToString() }); + new string[] { "agentID", "type", "parentFolderID" }, + new string[] { userID.ToString(), ((int)AssetType.CurrentOutfitFolder).ToString(), root.folderID.ToString() }); if (folders.Length == 0) return null; -- cgit v1.1 From 803632f8f32d91bb4aec678d8b45a8430c2703e1 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 9 Jul 2013 16:26:17 -0700 Subject: BulletSim: freshen up the code for constraint based linksets. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 4 +- .../Physics/BulletSPlugin/BSLinksetCompound.cs | 1 + .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 82 ++++++++++++++++------ 3 files changed, 64 insertions(+), 23 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 0204967..4c2c1c1 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -1029,8 +1029,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin // Add this correction to the velocity to make it faster/slower. VehicleVelocity += linearMotorVelocityW; - VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},correctV={3},correctW={4},newVelW={5},fricFact={6}", - ControllingPrim.LocalID, origVelW, currentVelV, linearMotorCorrectionV, + VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},tgt={3},correctV={4},correctW={5},newVelW={6},fricFact={7}", + ControllingPrim.LocalID, origVelW, currentVelV, m_linearMotor.TargetValue, linearMotorCorrectionV, linearMotorVelocityW, VehicleVelocity, frictionFactorV); } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 1d94142..3668456 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs @@ -59,6 +59,7 @@ public sealed class BSLinksetCompound : BSLinkset { DetailLog("{0},BSLinksetCompound.ScheduleRebuild,,rebuilding={1},hasChildren={2},actuallyScheduling={3}", requestor.LocalID, Rebuilding, HasAnyChildren, (!Rebuilding && HasAnyChildren)); + // When rebuilding, it is possible to set properties that would normally require a rebuild. // If already rebuilding, don't request another rebuild. // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding. diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index a06a44d..f17d698 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -48,12 +48,22 @@ public sealed class BSLinksetConstraints : BSLinkset { base.Refresh(requestor); - if (HasAnyChildren && IsRoot(requestor)) + } + + private void ScheduleRebuild(BSPrimLinkable requestor) + { + DetailLog("{0},BSLinksetConstraint.ScheduleRebuild,,rebuilding={1},hasChildren={2},actuallyScheduling={3}", + requestor.LocalID, Rebuilding, HasAnyChildren, (!Rebuilding && HasAnyChildren)); + + // When rebuilding, it is possible to set properties that would normally require a rebuild. + // If already rebuilding, don't request another rebuild. + // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding. + if (!Rebuilding && HasAnyChildren) { // Queue to happen after all the other taint processing m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() { - if (HasAnyChildren && IsRoot(requestor)) + if (HasAnyChildren) RecomputeLinksetConstraints(); }); } @@ -67,8 +77,14 @@ public sealed class BSLinksetConstraints : BSLinkset // Called at taint-time! public override bool MakeDynamic(BSPrimLinkable child) { - // What is done for each object in BSPrim is what we want. - return false; + bool ret = false; + DetailLog("{0},BSLinksetConstraints.MakeDynamic,call,IsRoot={1}", child.LocalID, IsRoot(child)); + if (IsRoot(child)) + { + // The root is going dynamic. Rebuild the linkset so parts and mass get computed properly. + ScheduleRebuild(LinksetRoot); + } + return ret; } // The object is going static (non-physical). Do any setup necessary for a static linkset. @@ -78,8 +94,16 @@ public sealed class BSLinksetConstraints : BSLinkset // Called at taint-time! public override bool MakeStatic(BSPrimLinkable child) { - // What is done for each object in BSPrim is what we want. - return false; + bool ret = false; + + DetailLog("{0},BSLinksetConstraint.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child)); + child.ClearDisplacement(); + if (IsRoot(child)) + { + // Schedule a rebuild to verify that the root shape is set to the real shape. + ScheduleRebuild(LinksetRoot); + } + return ret; } // Called at taint-time!! @@ -105,7 +129,7 @@ public sealed class BSLinksetConstraints : BSLinkset // Just undo all the constraints for this linkset. Rebuild at the end of the step. ret = PhysicallyUnlinkAllChildrenFromRoot(LinksetRoot); // Cause the constraints, et al to be rebuilt before the next simulation step. - Refresh(LinksetRoot); + ScheduleRebuild(LinksetRoot); } return ret; } @@ -123,7 +147,7 @@ public sealed class BSLinksetConstraints : BSLinkset DetailLog("{0},BSLinksetConstraints.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); // Cause constraints and assorted properties to be recomputed before the next simulation step. - Refresh(LinksetRoot); + ScheduleRebuild(LinksetRoot); } return; } @@ -147,7 +171,7 @@ public sealed class BSLinksetConstraints : BSLinkset PhysicallyUnlinkAChildFromRoot(rootx, childx); }); // See that the linkset parameters are recomputed at the end of the taint time. - Refresh(LinksetRoot); + ScheduleRebuild(LinksetRoot); } else { @@ -165,6 +189,7 @@ public sealed class BSLinksetConstraints : BSLinkset Refresh(rootPrim); } + // Create a static constraint between the two passed objects private BSConstraint BuildConstraint(BSPrimLinkable rootPrim, BSPrimLinkable childPrim) { // Zero motion for children so they don't interpolate @@ -281,24 +306,39 @@ public sealed class BSLinksetConstraints : BSLinkset DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}", LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, linksetMass); - foreach (BSPrimLinkable child in m_children) + try { - // A child in the linkset physically shows the mass of the whole linkset. - // This allows Bullet to apply enough force on the child to move the whole linkset. - // (Also do the mass stuff before recomputing the constraint so mass is not zero.) - child.UpdatePhysicalMassProperties(linksetMass, true); + Rebuilding = true; - BSConstraint constrain; - if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) + // There is no reason to build all this physical stuff for a non-physical linkset. + if (!LinksetRoot.IsPhysicallyActive) { - // If constraint doesn't exist yet, create it. - constrain = BuildConstraint(LinksetRoot, child); + DetailLog("{0},BSLinksetConstraint.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID); + return; // Note the 'finally' clause at the botton which will get executed. } - constrain.RecomputeConstraintVariables(linksetMass); - // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG - } + foreach (BSPrimLinkable child in m_children) + { + // A child in the linkset physically shows the mass of the whole linkset. + // This allows Bullet to apply enough force on the child to move the whole linkset. + // (Also do the mass stuff before recomputing the constraint so mass is not zero.) + child.UpdatePhysicalMassProperties(linksetMass, true); + + BSConstraint constrain; + if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) + { + // If constraint doesn't exist yet, create it. + constrain = BuildConstraint(LinksetRoot, child); + } + constrain.RecomputeConstraintVariables(linksetMass); + // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG + } + } + finally + { + Rebuilding = false; + } } } } -- cgit v1.1 From 13a4a80b3893af13ab748c177b731fed813974ca Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Wed, 10 Jul 2013 09:32:26 -0700 Subject: Add experimental stubs for an extension function interface on both PhysicsScene and PhysicsActor. --- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 6 ++++++ OpenSim/Region/Physics/Manager/PhysicsScene.cs | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index bd806eb..2500f27 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -313,6 +313,12 @@ namespace OpenSim.Region.Physics.Manager public abstract void SubscribeEvents(int ms); public abstract void UnSubscribeEvents(); public abstract bool SubscribedEvents(); + + // Extendable interface for new, physics engine specific operations + public virtual object Extension(string pFunct, params object[] pParams) + { + throw new NotImplementedException(); + } } public class NullPhysicsActor : PhysicsActor diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index 290b72e..07a1d36 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -25,10 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.Collections.Generic; using System.Reflection; + using log4net; using Nini.Config; + using OpenSim.Framework; using OpenMetaverse; @@ -331,5 +334,11 @@ namespace OpenSim.Region.Physics.Manager { return false; } + + // Extendable interface for new, physics engine specific operations + public virtual object Extension(string pFunct, params object[] pParams) + { + throw new NotImplementedException(); + } } } -- cgit v1.1 From b4c3a791aa55390bff071b3fe4bbe70c1d252703 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Thu, 11 Jul 2013 14:33:03 -0700 Subject: BulletSim: move collision processing for linksets from BSPrimLinkable into the linkset implementation classes. Add HasSomeCollision attribute that remembers of any component of a linkset has a collision. Update vehicle code (BSDynamic) to use the HasSomeCollision in place of IsColliding to make constraint based linksets properly notice the ground. Add linkset functions to change physical attributes of all the members of a linkset. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 16 ++--- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 75 +++++++++++++++++++++- .../Region/Physics/BulletSPlugin/BSPhysObject.cs | 11 ++++ OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 5 +- .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 32 +++++++-- 5 files changed, 121 insertions(+), 18 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 4c2c1c1..1540df1 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -1001,7 +1001,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin else if (newVelocityLengthSq < 0.001f) VehicleVelocity = Vector3.Zero; - VDetailLog("{0}, MoveLinear,done,isColl={1},newVel={2}", ControllingPrim.LocalID, ControllingPrim.IsColliding, VehicleVelocity ); + VDetailLog("{0}, MoveLinear,done,isColl={1},newVel={2}", ControllingPrim.LocalID, ControllingPrim.HasSomeCollision, VehicleVelocity ); } // end MoveLinear() @@ -1062,7 +1062,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin Vector3 linearDeflectionW = linearDeflectionV * VehicleOrientation; // Optionally, if not colliding, don't effect world downward velocity. Let falling things fall. - if (BSParam.VehicleLinearDeflectionNotCollidingNoZ && !m_controllingPrim.IsColliding) + if (BSParam.VehicleLinearDeflectionNotCollidingNoZ && !m_controllingPrim.HasSomeCollision) { linearDeflectionW.Z = 0f; } @@ -1222,7 +1222,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin float targetHeight = Type == Vehicle.TYPE_BOAT ? GetWaterLevel(VehiclePosition) : GetTerrainHeight(VehiclePosition); distanceAboveGround = VehiclePosition.Z - targetHeight; // Not colliding if the vehicle is off the ground - if (!Prim.IsColliding) + if (!Prim.HasSomeCollision) { // downForce = new Vector3(0, 0, -distanceAboveGround / m_bankingTimescale); VehicleVelocity += new Vector3(0, 0, -distanceAboveGround); @@ -1233,12 +1233,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin // be computed with a motor. // TODO: add interaction with banking. VDetailLog("{0}, MoveLinear,limitMotorUp,distAbove={1},colliding={2},ret={3}", - Prim.LocalID, distanceAboveGround, Prim.IsColliding, ret); + Prim.LocalID, distanceAboveGround, Prim.HasSomeCollision, ret); */ // Another approach is to measure if we're going up. If going up and not colliding, // the vehicle is in the air. Fix that by pushing down. - if (!ControllingPrim.IsColliding && VehicleVelocity.Z > 0.1) + if (!ControllingPrim.HasSomeCollision && VehicleVelocity.Z > 0.1) { // Get rid of any of the velocity vector that is pushing us up. float upVelocity = VehicleVelocity.Z; @@ -1260,7 +1260,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin } */ VDetailLog("{0}, MoveLinear,limitMotorUp,collide={1},upVel={2},newVel={3}", - ControllingPrim.LocalID, ControllingPrim.IsColliding, upVelocity, VehicleVelocity); + ControllingPrim.LocalID, ControllingPrim.HasSomeCollision, upVelocity, VehicleVelocity); } } } @@ -1270,14 +1270,14 @@ namespace OpenSim.Region.Physics.BulletSPlugin Vector3 appliedGravity = m_VehicleGravity * m_vehicleMass; // Hack to reduce downward force if the vehicle is probably sitting on the ground - if (ControllingPrim.IsColliding && IsGroundVehicle) + if (ControllingPrim.HasSomeCollision && IsGroundVehicle) appliedGravity *= BSParam.VehicleGroundGravityFudge; VehicleAddForce(appliedGravity); VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},fudge={3},mass={4},appliedForce={5}", ControllingPrim.LocalID, m_VehicleGravity, - ControllingPrim.IsColliding, BSParam.VehicleGroundGravityFudge, m_vehicleMass, appliedGravity); + ControllingPrim.HasSomeCollision, BSParam.VehicleGroundGravityFudge, m_vehicleMass, appliedGravity); } // ======================================================================= diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index ad8e10f..78c0af7 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -203,6 +203,33 @@ public abstract class BSLinkset return ret; } + // Called after a simulation step to post a collision with this object. + // Return 'true' if linkset processed the collision. 'false' says the linkset didn't have + // anything to add for the collision and it should be passed through normal processing. + // Default processing for a linkset. + public virtual bool HandleCollide(uint collidingWith, BSPhysObject collidee, + OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) + { + bool ret = false; + + // prims in the same linkset cannot collide with each other + BSPrimLinkable convCollidee = collidee as BSPrimLinkable; + if (convCollidee != null && (LinksetID == convCollidee.Linkset.LinksetID)) + { + // By returning 'true', we tell the caller the collision has been 'handled' so it won't + // do anything about this collision and thus, effectivily, ignoring the collision. + ret = true; + } + else + { + // Not a collision between members of the linkset. Must be a real collision. + // So the linkset root can know if there is a collision anywhere in the linkset. + LinksetRoot.SomeCollisionSimulationStep = m_physicsScene.SimulationStep; + } + + return ret; + } + // I am the root of a linkset and a new child is being added // Called while LinkActivity is locked. protected abstract void AddChildToLinkset(BSPrimLinkable child); @@ -251,6 +278,53 @@ public abstract class BSLinkset public abstract bool RemoveDependencies(BSPrimLinkable child); // ================================================================ + // Some physical setting happen to all members of the linkset + public virtual void SetPhysicalFriction(float friction) + { + ForEachMember((member) => + { + if (member.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetFriction(member.PhysBody, friction); + return false; // 'false' says to continue looping + } + ); + } + public virtual void SetPhysicalRestitution(float restitution) + { + ForEachMember((member) => + { + if (member.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetRestitution(member.PhysBody, restitution); + return false; // 'false' says to continue looping + } + ); + } + public virtual void SetPhysicalGravity(OMV.Vector3 gravity) + { + ForEachMember((member) => + { + if (member.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetGravity(member.PhysBody, gravity); + return false; // 'false' says to continue looping + } + ); + } + public virtual void ComputeLocalInertia() + { + ForEachMember((member) => + { + if (member.PhysBody.HasPhysicalBody) + { + OMV.Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(member.PhysShape.physShapeInfo, member.Mass); + member.Inertia = inertia * BSParam.VehicleInertiaFactor; + m_physicsScene.PE.SetMassProps(member.PhysBody, member.Mass, member.Inertia); + m_physicsScene.PE.UpdateInertiaTensor(member.PhysBody); + } + return false; // 'false' says to continue looping + } + ); + } + // ================================================================ protected virtual float ComputeLinksetMass() { float mass = LinksetRoot.RawMass; @@ -311,6 +385,5 @@ public abstract class BSLinkset if (m_physicsScene.PhysicsLogging.Enabled) m_physicsScene.DetailLog(msg, args); } - } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index fc4545f..d34b797 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -353,6 +353,16 @@ public abstract class BSPhysObject : PhysicsActor CollidingStep = BSScene.NotASimulationStep; } } + // Complex objects (like linksets) need to know if there is a collision on any part of + // their shape. 'IsColliding' has an existing definition of reporting a collision on + // only this specific prim or component of linksets. + // 'HasSomeCollision' is defined as reporting if there is a collision on any part of + // the complex body that this prim is the root of. + public virtual bool HasSomeCollision + { + get { return IsColliding; } + set { IsColliding = value; } + } public override bool CollidingGround { get { return (CollidingGroundStep == PhysScene.SimulationStep); } set @@ -386,6 +396,7 @@ public abstract class BSPhysObject : PhysicsActor // Return 'true' if a collision was processed and should be sent up. // Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision. // Called at taint time from within the Step() function + public delegate bool CollideCall(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth); public virtual bool Collide(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index d43448e..4771934 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -495,8 +495,8 @@ public class BSPrim : BSPhysObject } } - // Find and return a handle to the current vehicle actor. - // Return 'null' if there is no vehicle actor. + // Find and return a handle to the current vehicle actor. + // Return 'null' if there is no vehicle actor. public BSDynamics GetVehicleActor() { BSDynamics ret = null; @@ -507,6 +507,7 @@ public class BSPrim : BSPhysObject } return ret; } + public override int VehicleType { get { int ret = (int)Vehicle.TYPE_NONE; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 1fbcfcc..2f392da 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -200,20 +200,38 @@ public class BSPrimLinkable : BSPrimDisplaced } // Called after a simulation step to post a collision with this object. + // This returns 'true' if the collision has been queued and the SendCollisions call must + // be made at the end of the simulation step. public override bool Collide(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) { - // prims in the same linkset cannot collide with each other - BSPrimLinkable convCollidee = collidee as BSPrimLinkable; - if (convCollidee != null && (this.Linkset.LinksetID == convCollidee.Linkset.LinksetID)) + bool ret = false; + // Ask the linkset if it wants to handle the collision + if (!Linkset.HandleCollide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth)) { - return false; + // The linkset didn't handle it so pass the collision through normal processing + ret = base.Collide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth); } + return ret; + } - // TODO: handle collisions of other objects with with children of linkset. - // This is a problem for LinksetCompound since the children are packed into the root. + // A linkset reports any collision on any part of the linkset. + public long SomeCollisionSimulationStep = 0; + public override bool HasSomeCollision + { + get + { + return (SomeCollisionSimulationStep == PhysScene.SimulationStep) || base.IsColliding; + } + set + { + if (value) + SomeCollisionSimulationStep = PhysScene.SimulationStep; + else + SomeCollisionSimulationStep = 0; - return base.Collide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth); + base.HasSomeCollision = value; + } } } } -- cgit v1.1 From acb7b4a09ad564d1dfae3ad12adbb593ca3942c9 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 16 Jul 2013 09:59:52 -0700 Subject: BulletSim: only create vehicle prim actor when vehicles are enabled. --- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 43 ++++++++++++++++------ .../Physics/BulletSPlugin/Tests/BasicVehicles.cs | 2 +- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 4771934..fdb2925 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -96,7 +96,7 @@ public class BSPrim : BSPhysObject _isVolumeDetect = false; // Add a dynamic vehicle to our set of actors that can move this prim. - PhysicalActors.Add(VehicleActorName, new BSDynamics(PhysScene, this, VehicleActorName)); + // PhysicalActors.Add(VehicleActorName, new BSDynamics(PhysScene, this, VehicleActorName)); _mass = CalculateMass(); @@ -497,7 +497,7 @@ public class BSPrim : BSPhysObject // Find and return a handle to the current vehicle actor. // Return 'null' if there is no vehicle actor. - public BSDynamics GetVehicleActor() + public BSDynamics GetVehicleActor(bool createIfNone) { BSDynamics ret = null; BSActor actor; @@ -505,13 +505,21 @@ public class BSPrim : BSPhysObject { ret = actor as BSDynamics; } + else + { + if (createIfNone) + { + ret = new BSDynamics(PhysScene, this, VehicleActorName); + PhysicalActors.Add(ret.ActorName, ret); + } + } return ret; } public override int VehicleType { get { int ret = (int)Vehicle.TYPE_NONE; - BSDynamics vehicleActor = GetVehicleActor(); + BSDynamics vehicleActor = GetVehicleActor(false /* createIfNone */); if (vehicleActor != null) ret = (int)vehicleActor.Type; return ret; @@ -525,11 +533,24 @@ public class BSPrim : BSPhysObject // change all the parameters. Like a plane changing to CAR when on the // ground. In this case, don't want to zero motion. // ZeroMotion(true /* inTaintTime */); - BSDynamics vehicleActor = GetVehicleActor(); - if (vehicleActor != null) + if (type == Vehicle.TYPE_NONE) { - vehicleActor.ProcessTypeChange(type); - ActivateIfPhysical(false); + // Vehicle type is 'none' so get rid of any actor that may have been allocated. + BSDynamics vehicleActor = GetVehicleActor(false /* createIfNone */); + if (vehicleActor != null) + { + PhysicalActors.RemoveAndRelease(vehicleActor.ActorName); + } + } + else + { + // Vehicle type is not 'none' so create an actor and set it running. + BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); + if (vehicleActor != null) + { + vehicleActor.ProcessTypeChange(type); + ActivateIfPhysical(false); + } } }); } @@ -538,7 +559,7 @@ public class BSPrim : BSPhysObject { PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() { - BSDynamics vehicleActor = GetVehicleActor(); + BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); if (vehicleActor != null) { vehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); @@ -550,7 +571,7 @@ public class BSPrim : BSPhysObject { PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() { - BSDynamics vehicleActor = GetVehicleActor(); + BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); if (vehicleActor != null) { vehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); @@ -562,7 +583,7 @@ public class BSPrim : BSPhysObject { PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() { - BSDynamics vehicleActor = GetVehicleActor(); + BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); if (vehicleActor != null) { vehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); @@ -574,7 +595,7 @@ public class BSPrim : BSPhysObject { PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate() { - BSDynamics vehicleActor = GetVehicleActor(); + BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); if (vehicleActor != null) { vehicleActor.ProcessVehicleFlags(param, remove); diff --git a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs index 48d3742..48e74eb 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs @@ -116,7 +116,7 @@ public class BasicVehicles : OpenSimTestCase // Instead the appropriate values are set and calls are made just the parts of the // controller we want to exercise. Stepping the physics engine then applies // the actions of that one feature. - BSDynamics vehicleActor = TestVehicle.GetVehicleActor(); + BSDynamics vehicleActor = TestVehicle.GetVehicleActor(true /* createIfNone */); if (vehicleActor != null) { vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency); -- cgit v1.1 From d0d654e2186c8b81c1150da89a549e4f7162a2b4 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 16 Jul 2013 10:01:03 -0700 Subject: BulletSim: change BSDynamics to expect to be passed a BSPrimLinkable and start changing the logic to handle the base prim as a complex object (ie, a linkset). --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 1540df1..82d7c44 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -45,7 +45,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin private static string LogHeader = "[BULLETSIM VEHICLE]"; // the prim this dynamic controller belongs to - private BSPrim ControllingPrim { get; set; } + private BSPrimLinkable ControllingPrim { get; set; } private bool m_haveRegisteredForSceneEvents; @@ -128,9 +128,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin public BSDynamics(BSScene myScene, BSPrim myPrim, string actorName) : base(myScene, myPrim, actorName) { - ControllingPrim = myPrim; Type = Vehicle.TYPE_NONE; m_haveRegisteredForSceneEvents = false; + + ControllingPrim = myPrim as BSPrimLinkable; + if (ControllingPrim == null) + { + // THIS CANNOT HAPPEN!! + } + VDetailLog("{0},Creation", ControllingPrim.LocalID); } // Return 'true' if this vehicle is doing vehicle things @@ -585,6 +591,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin // Friction affects are handled by this vehicle code m_physicsScene.PE.SetFriction(ControllingPrim.PhysBody, BSParam.VehicleFriction); m_physicsScene.PE.SetRestitution(ControllingPrim.PhysBody, BSParam.VehicleRestitution); + // ControllingPrim.Linkset.SetPhysicalFriction(BSParam.VehicleFriction); + // ControllingPrim.Linkset.SetPhysicalRestitution(BSParam.VehicleRestitution); // Moderate angular movement introduced by Bullet. // TODO: possibly set AngularFactor and LinearFactor for the type of vehicle. @@ -595,17 +603,20 @@ namespace OpenSim.Region.Physics.BulletSPlugin // Vehicles report collision events so we know when it's on the ground m_physicsScene.PE.AddToCollisionFlags(ControllingPrim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); + // ControllingPrim.Linkset.SetPhysicalCollisionFlags(CollisionFlags.BS_VEHICLE_COLLISIONS); Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(ControllingPrim.PhysShape.physShapeInfo, m_vehicleMass); ControllingPrim.Inertia = inertia * BSParam.VehicleInertiaFactor; m_physicsScene.PE.SetMassProps(ControllingPrim.PhysBody, m_vehicleMass, ControllingPrim.Inertia); m_physicsScene.PE.UpdateInertiaTensor(ControllingPrim.PhysBody); + // ControllingPrim.Linkset.ComputeLocalInertia(BSParam.VehicleInertiaFactor); // Set the gravity for the vehicle depending on the buoyancy // TODO: what should be done if prim and vehicle buoyancy differ? m_VehicleGravity = ControllingPrim.ComputeGravity(m_VehicleBuoyancy); // The actual vehicle gravity is set to zero in Bullet so we can do all the application of same. m_physicsScene.PE.SetGravity(ControllingPrim.PhysBody, Vector3.Zero); + // ControllingPrim.Linkset.SetPhysicalGravity(Vector3.Zero); VDetailLog("{0},BSDynamics.SetPhysicalParameters,mass={1},inert={2},vehGrav={3},aDamp={4},frict={5},rest={6},lFact={7},aFact={8}", ControllingPrim.LocalID, m_vehicleMass, ControllingPrim.Inertia, m_VehicleGravity, @@ -617,6 +628,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin { if (ControllingPrim.PhysBody.HasPhysicalBody) m_physicsScene.PE.RemoveFromCollisionFlags(ControllingPrim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); + // ControllingPrim.Linkset.RemoveFromPhysicalCollisionFlags(CollisionFlags.BS_VEHICLE_COLLISIONS); } } @@ -629,6 +641,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin // BSActor.Release() public override void Dispose() { + VDetailLog("{0},Dispose", ControllingPrim.LocalID); UnregisterForSceneEvents(); Type = Vehicle.TYPE_NONE; Enabled = false; -- cgit v1.1 From b44f0e1a00eba7f76401692322e48a3b23a81164 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 16 Jul 2013 10:02:14 -0700 Subject: BulletSim: Add logic to linksets to change physical properties for whole linkset. Override physical property setting for BSLinksetCompound as there are not children to the compound spape. --- OpenSim/Region/Physics/BulletSPlugin/BSActors.cs | 6 +--- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 24 +++++++++++++-- .../Physics/BulletSPlugin/BSLinksetCompound.cs | 36 ++++++++++++++++++++++ 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs index fff63e4..e0ccc50 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs @@ -69,7 +69,7 @@ public class BSActorCollection { lock (m_actors) { - Release(); + ForEachActor(a => a.Dispose()); m_actors.Clear(); } } @@ -98,10 +98,6 @@ public class BSActorCollection { ForEachActor(a => a.SetEnabled(enabl)); } - public void Release() - { - ForEachActor(a => a.Dispose()); - } public void Refresh() { ForEachActor(a => a.Refresh()); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 78c0af7..960c0b4 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -309,14 +309,14 @@ public abstract class BSLinkset } ); } - public virtual void ComputeLocalInertia() + public virtual void ComputeLocalInertia(OMV.Vector3 inertiaFactor) { ForEachMember((member) => { if (member.PhysBody.HasPhysicalBody) { OMV.Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(member.PhysShape.physShapeInfo, member.Mass); - member.Inertia = inertia * BSParam.VehicleInertiaFactor; + member.Inertia = inertia * inertiaFactor; m_physicsScene.PE.SetMassProps(member.PhysBody, member.Mass, member.Inertia); m_physicsScene.PE.UpdateInertiaTensor(member.PhysBody); } @@ -324,6 +324,26 @@ public abstract class BSLinkset } ); } + public virtual void SetPhysicalCollisionFlags(CollisionFlags collFlags) + { + ForEachMember((member) => + { + if (member.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetCollisionFlags(member.PhysBody, collFlags); + return false; // 'false' says to continue looping + } + ); + } + public virtual void RemoveFromPhysicalCollisionFlags(CollisionFlags collFlags) + { + ForEachMember((member) => + { + if (member.PhysBody.HasPhysicalBody) + m_physicsScene.PE.RemoveFromCollisionFlags(member.PhysBody, collFlags); + return false; // 'false' says to continue looping + } + ); + } // ================================================================ protected virtual float ComputeLinksetMass() { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 3668456..33ae5a5 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs @@ -44,6 +44,42 @@ public sealed class BSLinksetCompound : BSLinkset { } + // ================================================================ + // Changing the physical property of the linkset only needs to change the root + public override void SetPhysicalFriction(float friction) + { + if (LinksetRoot.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetFriction(LinksetRoot.PhysBody, friction); + } + public override void SetPhysicalRestitution(float restitution) + { + if (LinksetRoot.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetRestitution(LinksetRoot.PhysBody, restitution); + } + public override void SetPhysicalGravity(OMV.Vector3 gravity) + { + if (LinksetRoot.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetGravity(LinksetRoot.PhysBody, gravity); + } + public override void ComputeLocalInertia(OMV.Vector3 inertiaFactor) + { + OMV.Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(LinksetRoot.PhysShape.physShapeInfo, LinksetRoot.Mass); + LinksetRoot.Inertia = inertia * inertiaFactor; + m_physicsScene.PE.SetMassProps(LinksetRoot.PhysBody, LinksetRoot.Mass, LinksetRoot.Inertia); + m_physicsScene.PE.UpdateInertiaTensor(LinksetRoot.PhysBody); + } + public override void SetPhysicalCollisionFlags(CollisionFlags collFlags) + { + if (LinksetRoot.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetCollisionFlags(LinksetRoot.PhysBody, collFlags); + } + public override void RemoveFromPhysicalCollisionFlags(CollisionFlags collFlags) + { + if (LinksetRoot.PhysBody.HasPhysicalBody) + m_physicsScene.PE.RemoveFromCollisionFlags(LinksetRoot.PhysBody, collFlags); + } + // ================================================================ + // When physical properties are changed the linkset needs to recalculate // its internal properties. public override void Refresh(BSPrimLinkable requestor) -- cgit v1.1 From 84d0699761b8da546f9faef084240d7b15f16321 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 22 Jul 2013 12:07:42 -0700 Subject: Revert "BulletSim: Add logic to linksets to change physical properties for" The changes don't seem to be ready for prime time. This reverts commit b44f0e1a00eba7f76401692322e48a3b23a81164. --- OpenSim/Region/Physics/BulletSPlugin/BSActors.cs | 6 +++- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 24 ++------------- .../Physics/BulletSPlugin/BSLinksetCompound.cs | 36 ---------------------- 3 files changed, 7 insertions(+), 59 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs index e0ccc50..fff63e4 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs @@ -69,7 +69,7 @@ public class BSActorCollection { lock (m_actors) { - ForEachActor(a => a.Dispose()); + Release(); m_actors.Clear(); } } @@ -98,6 +98,10 @@ public class BSActorCollection { ForEachActor(a => a.SetEnabled(enabl)); } + public void Release() + { + ForEachActor(a => a.Dispose()); + } public void Refresh() { ForEachActor(a => a.Refresh()); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 960c0b4..78c0af7 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -309,14 +309,14 @@ public abstract class BSLinkset } ); } - public virtual void ComputeLocalInertia(OMV.Vector3 inertiaFactor) + public virtual void ComputeLocalInertia() { ForEachMember((member) => { if (member.PhysBody.HasPhysicalBody) { OMV.Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(member.PhysShape.physShapeInfo, member.Mass); - member.Inertia = inertia * inertiaFactor; + member.Inertia = inertia * BSParam.VehicleInertiaFactor; m_physicsScene.PE.SetMassProps(member.PhysBody, member.Mass, member.Inertia); m_physicsScene.PE.UpdateInertiaTensor(member.PhysBody); } @@ -324,26 +324,6 @@ public abstract class BSLinkset } ); } - public virtual void SetPhysicalCollisionFlags(CollisionFlags collFlags) - { - ForEachMember((member) => - { - if (member.PhysBody.HasPhysicalBody) - m_physicsScene.PE.SetCollisionFlags(member.PhysBody, collFlags); - return false; // 'false' says to continue looping - } - ); - } - public virtual void RemoveFromPhysicalCollisionFlags(CollisionFlags collFlags) - { - ForEachMember((member) => - { - if (member.PhysBody.HasPhysicalBody) - m_physicsScene.PE.RemoveFromCollisionFlags(member.PhysBody, collFlags); - return false; // 'false' says to continue looping - } - ); - } // ================================================================ protected virtual float ComputeLinksetMass() { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 33ae5a5..3668456 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs @@ -44,42 +44,6 @@ public sealed class BSLinksetCompound : BSLinkset { } - // ================================================================ - // Changing the physical property of the linkset only needs to change the root - public override void SetPhysicalFriction(float friction) - { - if (LinksetRoot.PhysBody.HasPhysicalBody) - m_physicsScene.PE.SetFriction(LinksetRoot.PhysBody, friction); - } - public override void SetPhysicalRestitution(float restitution) - { - if (LinksetRoot.PhysBody.HasPhysicalBody) - m_physicsScene.PE.SetRestitution(LinksetRoot.PhysBody, restitution); - } - public override void SetPhysicalGravity(OMV.Vector3 gravity) - { - if (LinksetRoot.PhysBody.HasPhysicalBody) - m_physicsScene.PE.SetGravity(LinksetRoot.PhysBody, gravity); - } - public override void ComputeLocalInertia(OMV.Vector3 inertiaFactor) - { - OMV.Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(LinksetRoot.PhysShape.physShapeInfo, LinksetRoot.Mass); - LinksetRoot.Inertia = inertia * inertiaFactor; - m_physicsScene.PE.SetMassProps(LinksetRoot.PhysBody, LinksetRoot.Mass, LinksetRoot.Inertia); - m_physicsScene.PE.UpdateInertiaTensor(LinksetRoot.PhysBody); - } - public override void SetPhysicalCollisionFlags(CollisionFlags collFlags) - { - if (LinksetRoot.PhysBody.HasPhysicalBody) - m_physicsScene.PE.SetCollisionFlags(LinksetRoot.PhysBody, collFlags); - } - public override void RemoveFromPhysicalCollisionFlags(CollisionFlags collFlags) - { - if (LinksetRoot.PhysBody.HasPhysicalBody) - m_physicsScene.PE.RemoveFromCollisionFlags(LinksetRoot.PhysBody, collFlags); - } - // ================================================================ - // When physical properties are changed the linkset needs to recalculate // its internal properties. public override void Refresh(BSPrimLinkable requestor) -- cgit v1.1 From 7b187deb19517aa7c880458894643a5448566a94 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 22 Jul 2013 12:08:25 -0700 Subject: Revert "BulletSim: change BSDynamics to expect to be passed a BSPrimLinkable" The changes don't seem to be ready for prime time. This reverts commit d0d654e2186c8b81c1150da89a549e4f7162a2b4. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 82d7c44..1540df1 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -45,7 +45,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin private static string LogHeader = "[BULLETSIM VEHICLE]"; // the prim this dynamic controller belongs to - private BSPrimLinkable ControllingPrim { get; set; } + private BSPrim ControllingPrim { get; set; } private bool m_haveRegisteredForSceneEvents; @@ -128,15 +128,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin public BSDynamics(BSScene myScene, BSPrim myPrim, string actorName) : base(myScene, myPrim, actorName) { + ControllingPrim = myPrim; Type = Vehicle.TYPE_NONE; m_haveRegisteredForSceneEvents = false; - - ControllingPrim = myPrim as BSPrimLinkable; - if (ControllingPrim == null) - { - // THIS CANNOT HAPPEN!! - } - VDetailLog("{0},Creation", ControllingPrim.LocalID); } // Return 'true' if this vehicle is doing vehicle things @@ -591,8 +585,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin // Friction affects are handled by this vehicle code m_physicsScene.PE.SetFriction(ControllingPrim.PhysBody, BSParam.VehicleFriction); m_physicsScene.PE.SetRestitution(ControllingPrim.PhysBody, BSParam.VehicleRestitution); - // ControllingPrim.Linkset.SetPhysicalFriction(BSParam.VehicleFriction); - // ControllingPrim.Linkset.SetPhysicalRestitution(BSParam.VehicleRestitution); // Moderate angular movement introduced by Bullet. // TODO: possibly set AngularFactor and LinearFactor for the type of vehicle. @@ -603,20 +595,17 @@ namespace OpenSim.Region.Physics.BulletSPlugin // Vehicles report collision events so we know when it's on the ground m_physicsScene.PE.AddToCollisionFlags(ControllingPrim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); - // ControllingPrim.Linkset.SetPhysicalCollisionFlags(CollisionFlags.BS_VEHICLE_COLLISIONS); Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(ControllingPrim.PhysShape.physShapeInfo, m_vehicleMass); ControllingPrim.Inertia = inertia * BSParam.VehicleInertiaFactor; m_physicsScene.PE.SetMassProps(ControllingPrim.PhysBody, m_vehicleMass, ControllingPrim.Inertia); m_physicsScene.PE.UpdateInertiaTensor(ControllingPrim.PhysBody); - // ControllingPrim.Linkset.ComputeLocalInertia(BSParam.VehicleInertiaFactor); // Set the gravity for the vehicle depending on the buoyancy // TODO: what should be done if prim and vehicle buoyancy differ? m_VehicleGravity = ControllingPrim.ComputeGravity(m_VehicleBuoyancy); // The actual vehicle gravity is set to zero in Bullet so we can do all the application of same. m_physicsScene.PE.SetGravity(ControllingPrim.PhysBody, Vector3.Zero); - // ControllingPrim.Linkset.SetPhysicalGravity(Vector3.Zero); VDetailLog("{0},BSDynamics.SetPhysicalParameters,mass={1},inert={2},vehGrav={3},aDamp={4},frict={5},rest={6},lFact={7},aFact={8}", ControllingPrim.LocalID, m_vehicleMass, ControllingPrim.Inertia, m_VehicleGravity, @@ -628,7 +617,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin { if (ControllingPrim.PhysBody.HasPhysicalBody) m_physicsScene.PE.RemoveFromCollisionFlags(ControllingPrim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); - // ControllingPrim.Linkset.RemoveFromPhysicalCollisionFlags(CollisionFlags.BS_VEHICLE_COLLISIONS); } } @@ -641,7 +629,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin // BSActor.Release() public override void Dispose() { - VDetailLog("{0},Dispose", ControllingPrim.LocalID); UnregisterForSceneEvents(); Type = Vehicle.TYPE_NONE; Enabled = false; -- cgit v1.1 From 5f7b2ea81b95a60e882bc65b663a2c9fe134f92a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 22 Jul 2013 12:08:49 -0700 Subject: Revert "BulletSim: only create vehicle prim actor when vehicles are enabled." The changes don't seem to be ready for prime time. This reverts commit acb7b4a09ad564d1dfae3ad12adbb593ca3942c9. --- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 43 ++++++---------------- .../Physics/BulletSPlugin/Tests/BasicVehicles.cs | 2 +- 2 files changed, 12 insertions(+), 33 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index fdb2925..4771934 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -96,7 +96,7 @@ public class BSPrim : BSPhysObject _isVolumeDetect = false; // Add a dynamic vehicle to our set of actors that can move this prim. - // PhysicalActors.Add(VehicleActorName, new BSDynamics(PhysScene, this, VehicleActorName)); + PhysicalActors.Add(VehicleActorName, new BSDynamics(PhysScene, this, VehicleActorName)); _mass = CalculateMass(); @@ -497,7 +497,7 @@ public class BSPrim : BSPhysObject // Find and return a handle to the current vehicle actor. // Return 'null' if there is no vehicle actor. - public BSDynamics GetVehicleActor(bool createIfNone) + public BSDynamics GetVehicleActor() { BSDynamics ret = null; BSActor actor; @@ -505,21 +505,13 @@ public class BSPrim : BSPhysObject { ret = actor as BSDynamics; } - else - { - if (createIfNone) - { - ret = new BSDynamics(PhysScene, this, VehicleActorName); - PhysicalActors.Add(ret.ActorName, ret); - } - } return ret; } public override int VehicleType { get { int ret = (int)Vehicle.TYPE_NONE; - BSDynamics vehicleActor = GetVehicleActor(false /* createIfNone */); + BSDynamics vehicleActor = GetVehicleActor(); if (vehicleActor != null) ret = (int)vehicleActor.Type; return ret; @@ -533,24 +525,11 @@ public class BSPrim : BSPhysObject // change all the parameters. Like a plane changing to CAR when on the // ground. In this case, don't want to zero motion. // ZeroMotion(true /* inTaintTime */); - if (type == Vehicle.TYPE_NONE) - { - // Vehicle type is 'none' so get rid of any actor that may have been allocated. - BSDynamics vehicleActor = GetVehicleActor(false /* createIfNone */); - if (vehicleActor != null) - { - PhysicalActors.RemoveAndRelease(vehicleActor.ActorName); - } - } - else + BSDynamics vehicleActor = GetVehicleActor(); + if (vehicleActor != null) { - // Vehicle type is not 'none' so create an actor and set it running. - BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); - if (vehicleActor != null) - { - vehicleActor.ProcessTypeChange(type); - ActivateIfPhysical(false); - } + vehicleActor.ProcessTypeChange(type); + ActivateIfPhysical(false); } }); } @@ -559,7 +538,7 @@ public class BSPrim : BSPhysObject { PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() { - BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); + BSDynamics vehicleActor = GetVehicleActor(); if (vehicleActor != null) { vehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); @@ -571,7 +550,7 @@ public class BSPrim : BSPhysObject { PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() { - BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); + BSDynamics vehicleActor = GetVehicleActor(); if (vehicleActor != null) { vehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); @@ -583,7 +562,7 @@ public class BSPrim : BSPhysObject { PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() { - BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); + BSDynamics vehicleActor = GetVehicleActor(); if (vehicleActor != null) { vehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); @@ -595,7 +574,7 @@ public class BSPrim : BSPhysObject { PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate() { - BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); + BSDynamics vehicleActor = GetVehicleActor(); if (vehicleActor != null) { vehicleActor.ProcessVehicleFlags(param, remove); diff --git a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs index 48e74eb..48d3742 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs @@ -116,7 +116,7 @@ public class BasicVehicles : OpenSimTestCase // Instead the appropriate values are set and calls are made just the parts of the // controller we want to exercise. Stepping the physics engine then applies // the actions of that one feature. - BSDynamics vehicleActor = TestVehicle.GetVehicleActor(true /* createIfNone */); + BSDynamics vehicleActor = TestVehicle.GetVehicleActor(); if (vehicleActor != null) { vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency); -- cgit v1.1 From c45659863d8821a48a32e5b687c7b2a6d90b0300 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 22 Jul 2013 12:09:17 -0700 Subject: Revert "BulletSim: move collision processing for linksets from BSPrimLinkable" The changes don't seem to be ready for prime time. This reverts commit b4c3a791aa55390bff071b3fe4bbe70c1d252703. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 16 ++--- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 75 +--------------------- .../Region/Physics/BulletSPlugin/BSPhysObject.cs | 11 ---- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 5 +- .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 32 ++------- 5 files changed, 18 insertions(+), 121 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 1540df1..4c2c1c1 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -1001,7 +1001,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin else if (newVelocityLengthSq < 0.001f) VehicleVelocity = Vector3.Zero; - VDetailLog("{0}, MoveLinear,done,isColl={1},newVel={2}", ControllingPrim.LocalID, ControllingPrim.HasSomeCollision, VehicleVelocity ); + VDetailLog("{0}, MoveLinear,done,isColl={1},newVel={2}", ControllingPrim.LocalID, ControllingPrim.IsColliding, VehicleVelocity ); } // end MoveLinear() @@ -1062,7 +1062,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin Vector3 linearDeflectionW = linearDeflectionV * VehicleOrientation; // Optionally, if not colliding, don't effect world downward velocity. Let falling things fall. - if (BSParam.VehicleLinearDeflectionNotCollidingNoZ && !m_controllingPrim.HasSomeCollision) + if (BSParam.VehicleLinearDeflectionNotCollidingNoZ && !m_controllingPrim.IsColliding) { linearDeflectionW.Z = 0f; } @@ -1222,7 +1222,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin float targetHeight = Type == Vehicle.TYPE_BOAT ? GetWaterLevel(VehiclePosition) : GetTerrainHeight(VehiclePosition); distanceAboveGround = VehiclePosition.Z - targetHeight; // Not colliding if the vehicle is off the ground - if (!Prim.HasSomeCollision) + if (!Prim.IsColliding) { // downForce = new Vector3(0, 0, -distanceAboveGround / m_bankingTimescale); VehicleVelocity += new Vector3(0, 0, -distanceAboveGround); @@ -1233,12 +1233,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin // be computed with a motor. // TODO: add interaction with banking. VDetailLog("{0}, MoveLinear,limitMotorUp,distAbove={1},colliding={2},ret={3}", - Prim.LocalID, distanceAboveGround, Prim.HasSomeCollision, ret); + Prim.LocalID, distanceAboveGround, Prim.IsColliding, ret); */ // Another approach is to measure if we're going up. If going up and not colliding, // the vehicle is in the air. Fix that by pushing down. - if (!ControllingPrim.HasSomeCollision && VehicleVelocity.Z > 0.1) + if (!ControllingPrim.IsColliding && VehicleVelocity.Z > 0.1) { // Get rid of any of the velocity vector that is pushing us up. float upVelocity = VehicleVelocity.Z; @@ -1260,7 +1260,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin } */ VDetailLog("{0}, MoveLinear,limitMotorUp,collide={1},upVel={2},newVel={3}", - ControllingPrim.LocalID, ControllingPrim.HasSomeCollision, upVelocity, VehicleVelocity); + ControllingPrim.LocalID, ControllingPrim.IsColliding, upVelocity, VehicleVelocity); } } } @@ -1270,14 +1270,14 @@ namespace OpenSim.Region.Physics.BulletSPlugin Vector3 appliedGravity = m_VehicleGravity * m_vehicleMass; // Hack to reduce downward force if the vehicle is probably sitting on the ground - if (ControllingPrim.HasSomeCollision && IsGroundVehicle) + if (ControllingPrim.IsColliding && IsGroundVehicle) appliedGravity *= BSParam.VehicleGroundGravityFudge; VehicleAddForce(appliedGravity); VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},fudge={3},mass={4},appliedForce={5}", ControllingPrim.LocalID, m_VehicleGravity, - ControllingPrim.HasSomeCollision, BSParam.VehicleGroundGravityFudge, m_vehicleMass, appliedGravity); + ControllingPrim.IsColliding, BSParam.VehicleGroundGravityFudge, m_vehicleMass, appliedGravity); } // ======================================================================= diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 78c0af7..ad8e10f 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -203,33 +203,6 @@ public abstract class BSLinkset return ret; } - // Called after a simulation step to post a collision with this object. - // Return 'true' if linkset processed the collision. 'false' says the linkset didn't have - // anything to add for the collision and it should be passed through normal processing. - // Default processing for a linkset. - public virtual bool HandleCollide(uint collidingWith, BSPhysObject collidee, - OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) - { - bool ret = false; - - // prims in the same linkset cannot collide with each other - BSPrimLinkable convCollidee = collidee as BSPrimLinkable; - if (convCollidee != null && (LinksetID == convCollidee.Linkset.LinksetID)) - { - // By returning 'true', we tell the caller the collision has been 'handled' so it won't - // do anything about this collision and thus, effectivily, ignoring the collision. - ret = true; - } - else - { - // Not a collision between members of the linkset. Must be a real collision. - // So the linkset root can know if there is a collision anywhere in the linkset. - LinksetRoot.SomeCollisionSimulationStep = m_physicsScene.SimulationStep; - } - - return ret; - } - // I am the root of a linkset and a new child is being added // Called while LinkActivity is locked. protected abstract void AddChildToLinkset(BSPrimLinkable child); @@ -278,53 +251,6 @@ public abstract class BSLinkset public abstract bool RemoveDependencies(BSPrimLinkable child); // ================================================================ - // Some physical setting happen to all members of the linkset - public virtual void SetPhysicalFriction(float friction) - { - ForEachMember((member) => - { - if (member.PhysBody.HasPhysicalBody) - m_physicsScene.PE.SetFriction(member.PhysBody, friction); - return false; // 'false' says to continue looping - } - ); - } - public virtual void SetPhysicalRestitution(float restitution) - { - ForEachMember((member) => - { - if (member.PhysBody.HasPhysicalBody) - m_physicsScene.PE.SetRestitution(member.PhysBody, restitution); - return false; // 'false' says to continue looping - } - ); - } - public virtual void SetPhysicalGravity(OMV.Vector3 gravity) - { - ForEachMember((member) => - { - if (member.PhysBody.HasPhysicalBody) - m_physicsScene.PE.SetGravity(member.PhysBody, gravity); - return false; // 'false' says to continue looping - } - ); - } - public virtual void ComputeLocalInertia() - { - ForEachMember((member) => - { - if (member.PhysBody.HasPhysicalBody) - { - OMV.Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(member.PhysShape.physShapeInfo, member.Mass); - member.Inertia = inertia * BSParam.VehicleInertiaFactor; - m_physicsScene.PE.SetMassProps(member.PhysBody, member.Mass, member.Inertia); - m_physicsScene.PE.UpdateInertiaTensor(member.PhysBody); - } - return false; // 'false' says to continue looping - } - ); - } - // ================================================================ protected virtual float ComputeLinksetMass() { float mass = LinksetRoot.RawMass; @@ -385,5 +311,6 @@ public abstract class BSLinkset if (m_physicsScene.PhysicsLogging.Enabled) m_physicsScene.DetailLog(msg, args); } + } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index d34b797..fc4545f 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -353,16 +353,6 @@ public abstract class BSPhysObject : PhysicsActor CollidingStep = BSScene.NotASimulationStep; } } - // Complex objects (like linksets) need to know if there is a collision on any part of - // their shape. 'IsColliding' has an existing definition of reporting a collision on - // only this specific prim or component of linksets. - // 'HasSomeCollision' is defined as reporting if there is a collision on any part of - // the complex body that this prim is the root of. - public virtual bool HasSomeCollision - { - get { return IsColliding; } - set { IsColliding = value; } - } public override bool CollidingGround { get { return (CollidingGroundStep == PhysScene.SimulationStep); } set @@ -396,7 +386,6 @@ public abstract class BSPhysObject : PhysicsActor // Return 'true' if a collision was processed and should be sent up. // Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision. // Called at taint time from within the Step() function - public delegate bool CollideCall(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth); public virtual bool Collide(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 4771934..d43448e 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -495,8 +495,8 @@ public class BSPrim : BSPhysObject } } - // Find and return a handle to the current vehicle actor. - // Return 'null' if there is no vehicle actor. + // Find and return a handle to the current vehicle actor. + // Return 'null' if there is no vehicle actor. public BSDynamics GetVehicleActor() { BSDynamics ret = null; @@ -507,7 +507,6 @@ public class BSPrim : BSPhysObject } return ret; } - public override int VehicleType { get { int ret = (int)Vehicle.TYPE_NONE; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 2f392da..1fbcfcc 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -200,38 +200,20 @@ public class BSPrimLinkable : BSPrimDisplaced } // Called after a simulation step to post a collision with this object. - // This returns 'true' if the collision has been queued and the SendCollisions call must - // be made at the end of the simulation step. public override bool Collide(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) { - bool ret = false; - // Ask the linkset if it wants to handle the collision - if (!Linkset.HandleCollide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth)) + // prims in the same linkset cannot collide with each other + BSPrimLinkable convCollidee = collidee as BSPrimLinkable; + if (convCollidee != null && (this.Linkset.LinksetID == convCollidee.Linkset.LinksetID)) { - // The linkset didn't handle it so pass the collision through normal processing - ret = base.Collide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth); + return false; } - return ret; - } - // A linkset reports any collision on any part of the linkset. - public long SomeCollisionSimulationStep = 0; - public override bool HasSomeCollision - { - get - { - return (SomeCollisionSimulationStep == PhysScene.SimulationStep) || base.IsColliding; - } - set - { - if (value) - SomeCollisionSimulationStep = PhysScene.SimulationStep; - else - SomeCollisionSimulationStep = 0; + // TODO: handle collisions of other objects with with children of linkset. + // This is a problem for LinksetCompound since the children are packed into the root. - base.HasSomeCollision = value; - } + return base.Collide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth); } } } -- cgit v1.1 From 89857378ce79f93a265bc1eb151e17742032abfa Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 22 Jul 2013 12:09:55 -0700 Subject: Revert "Add experimental stubs for an extension function interface on both" The changes don't seem to be ready for prime time. This reverts commit 13a4a80b3893af13ab748c177b731fed813974ca. --- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 6 ------ OpenSim/Region/Physics/Manager/PhysicsScene.cs | 9 --------- 2 files changed, 15 deletions(-) diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 2500f27..bd806eb 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -313,12 +313,6 @@ namespace OpenSim.Region.Physics.Manager public abstract void SubscribeEvents(int ms); public abstract void UnSubscribeEvents(); public abstract bool SubscribedEvents(); - - // Extendable interface for new, physics engine specific operations - public virtual object Extension(string pFunct, params object[] pParams) - { - throw new NotImplementedException(); - } } public class NullPhysicsActor : PhysicsActor diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index 07a1d36..290b72e 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -25,13 +25,10 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -using System; using System.Collections.Generic; using System.Reflection; - using log4net; using Nini.Config; - using OpenSim.Framework; using OpenMetaverse; @@ -334,11 +331,5 @@ namespace OpenSim.Region.Physics.Manager { return false; } - - // Extendable interface for new, physics engine specific operations - public virtual object Extension(string pFunct, params object[] pParams) - { - throw new NotImplementedException(); - } } } -- cgit v1.1 From 44543ebe638f391fc1c7ff532fe4470006dec55a Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 22 Jul 2013 12:10:23 -0700 Subject: Revert "BulletSim: freshen up the code for constraint based linksets." The changes don't seem to be ready for prime time. This reverts commit 803632f8f32d91bb4aec678d8b45a8430c2703e1. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 4 +- .../Physics/BulletSPlugin/BSLinksetCompound.cs | 1 - .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 82 ++++++---------------- 3 files changed, 23 insertions(+), 64 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 4c2c1c1..0204967 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -1029,8 +1029,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin // Add this correction to the velocity to make it faster/slower. VehicleVelocity += linearMotorVelocityW; - VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},tgt={3},correctV={4},correctW={5},newVelW={6},fricFact={7}", - ControllingPrim.LocalID, origVelW, currentVelV, m_linearMotor.TargetValue, linearMotorCorrectionV, + VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},correctV={3},correctW={4},newVelW={5},fricFact={6}", + ControllingPrim.LocalID, origVelW, currentVelV, linearMotorCorrectionV, linearMotorVelocityW, VehicleVelocity, frictionFactorV); } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 3668456..1d94142 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs @@ -59,7 +59,6 @@ public sealed class BSLinksetCompound : BSLinkset { DetailLog("{0},BSLinksetCompound.ScheduleRebuild,,rebuilding={1},hasChildren={2},actuallyScheduling={3}", requestor.LocalID, Rebuilding, HasAnyChildren, (!Rebuilding && HasAnyChildren)); - // When rebuilding, it is possible to set properties that would normally require a rebuild. // If already rebuilding, don't request another rebuild. // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding. diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index f17d698..a06a44d 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -48,22 +48,12 @@ public sealed class BSLinksetConstraints : BSLinkset { base.Refresh(requestor); - } - - private void ScheduleRebuild(BSPrimLinkable requestor) - { - DetailLog("{0},BSLinksetConstraint.ScheduleRebuild,,rebuilding={1},hasChildren={2},actuallyScheduling={3}", - requestor.LocalID, Rebuilding, HasAnyChildren, (!Rebuilding && HasAnyChildren)); - - // When rebuilding, it is possible to set properties that would normally require a rebuild. - // If already rebuilding, don't request another rebuild. - // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding. - if (!Rebuilding && HasAnyChildren) + if (HasAnyChildren && IsRoot(requestor)) { // Queue to happen after all the other taint processing m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() { - if (HasAnyChildren) + if (HasAnyChildren && IsRoot(requestor)) RecomputeLinksetConstraints(); }); } @@ -77,14 +67,8 @@ public sealed class BSLinksetConstraints : BSLinkset // Called at taint-time! public override bool MakeDynamic(BSPrimLinkable child) { - bool ret = false; - DetailLog("{0},BSLinksetConstraints.MakeDynamic,call,IsRoot={1}", child.LocalID, IsRoot(child)); - if (IsRoot(child)) - { - // The root is going dynamic. Rebuild the linkset so parts and mass get computed properly. - ScheduleRebuild(LinksetRoot); - } - return ret; + // What is done for each object in BSPrim is what we want. + return false; } // The object is going static (non-physical). Do any setup necessary for a static linkset. @@ -94,16 +78,8 @@ public sealed class BSLinksetConstraints : BSLinkset // Called at taint-time! public override bool MakeStatic(BSPrimLinkable child) { - bool ret = false; - - DetailLog("{0},BSLinksetConstraint.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child)); - child.ClearDisplacement(); - if (IsRoot(child)) - { - // Schedule a rebuild to verify that the root shape is set to the real shape. - ScheduleRebuild(LinksetRoot); - } - return ret; + // What is done for each object in BSPrim is what we want. + return false; } // Called at taint-time!! @@ -129,7 +105,7 @@ public sealed class BSLinksetConstraints : BSLinkset // Just undo all the constraints for this linkset. Rebuild at the end of the step. ret = PhysicallyUnlinkAllChildrenFromRoot(LinksetRoot); // Cause the constraints, et al to be rebuilt before the next simulation step. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } return ret; } @@ -147,7 +123,7 @@ public sealed class BSLinksetConstraints : BSLinkset DetailLog("{0},BSLinksetConstraints.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); // Cause constraints and assorted properties to be recomputed before the next simulation step. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } return; } @@ -171,7 +147,7 @@ public sealed class BSLinksetConstraints : BSLinkset PhysicallyUnlinkAChildFromRoot(rootx, childx); }); // See that the linkset parameters are recomputed at the end of the taint time. - ScheduleRebuild(LinksetRoot); + Refresh(LinksetRoot); } else { @@ -189,7 +165,6 @@ public sealed class BSLinksetConstraints : BSLinkset Refresh(rootPrim); } - // Create a static constraint between the two passed objects private BSConstraint BuildConstraint(BSPrimLinkable rootPrim, BSPrimLinkable childPrim) { // Zero motion for children so they don't interpolate @@ -306,39 +281,24 @@ public sealed class BSLinksetConstraints : BSLinkset DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}", LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, linksetMass); - try + foreach (BSPrimLinkable child in m_children) { - Rebuilding = true; + // A child in the linkset physically shows the mass of the whole linkset. + // This allows Bullet to apply enough force on the child to move the whole linkset. + // (Also do the mass stuff before recomputing the constraint so mass is not zero.) + child.UpdatePhysicalMassProperties(linksetMass, true); - // There is no reason to build all this physical stuff for a non-physical linkset. - if (!LinksetRoot.IsPhysicallyActive) + BSConstraint constrain; + if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) { - DetailLog("{0},BSLinksetConstraint.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID); - return; // Note the 'finally' clause at the botton which will get executed. + // If constraint doesn't exist yet, create it. + constrain = BuildConstraint(LinksetRoot, child); } + constrain.RecomputeConstraintVariables(linksetMass); - foreach (BSPrimLinkable child in m_children) - { - // A child in the linkset physically shows the mass of the whole linkset. - // This allows Bullet to apply enough force on the child to move the whole linkset. - // (Also do the mass stuff before recomputing the constraint so mass is not zero.) - child.UpdatePhysicalMassProperties(linksetMass, true); - - BSConstraint constrain; - if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) - { - // If constraint doesn't exist yet, create it. - constrain = BuildConstraint(LinksetRoot, child); - } - constrain.RecomputeConstraintVariables(linksetMass); - - // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG - } - } - finally - { - Rebuilding = false; + // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG } + } } } -- cgit v1.1 From e6b6af62dd677077664fdc8801b3a7e894a2b8da Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Mon, 22 Jul 2013 15:41:14 -0700 Subject: Added check for user movement specification before discarding an incoming AgentUpdate packet. This fixes the problem with vehicles not moving forward after the first up-arrow. Code to fix a potential exception when using different IClientAPIs. --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 81 +++++++++++----------- .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 3 +- 2 files changed, 42 insertions(+), 42 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index e23e55b..32549c8 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -359,12 +359,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// cannot retain a reference to it outside of that method. /// private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs(); - private float qdelta1; - private float qdelta2; - private float vdelta1; - private float vdelta2; - private float vdelta3; - private float vdelta4; protected Dictionary m_packetHandlers = new Dictionary(); protected Dictionary m_genericPacketHandlers = new Dictionary(); //PauPaw:Local Generic Message handlers @@ -5576,7 +5570,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP #region Scene/Avatar + // Threshold for body rotation to be a significant agent update private const float QDELTA = 0.000001f; + // Threshold for camera rotation to be a significant agent update private const float VDELTA = 0.01f; /// @@ -5587,31 +5583,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) { - // Compute these only once, when this function is called from down below - qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2); - //qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2); - vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis); - vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter); - vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis); - vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis); - - bool significant = CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x); - - // Emergency debugging - //if (significant) - //{ - //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}", - // x.CameraAtAxis, x.CameraCenter); - //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}", - // x.CameraLeftAxis, x.CameraUpAxis); - //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}", - // qdelta1, qdelta2); - //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}", - // x.ControlFlags, x.Flags, x.Far, x.State); - //} - - return significant; - + return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x); } /// @@ -5622,15 +5594,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) { - return ( - (qdelta1 > QDELTA) || + float qdelta1 = 1 - (float)Math.Pow(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation), 2); + //qdelta2 = 1 - (float)Math.Pow(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation), 2); + + bool movementSignificant = + (qdelta1 > QDELTA) // significant if body rotation above threshold // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack - //(qdelta2 > QDELTA * 10) || - (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) || - (x.Far != m_thisAgentUpdateArgs.Far) || - (x.Flags != m_thisAgentUpdateArgs.Flags) || - (x.State != m_thisAgentUpdateArgs.State) - ); + // || (qdelta2 > QDELTA * 10) // significant if head rotation above threshold + || (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed + || (x.ControlFlags != (byte)AgentManager.ControlFlags.NONE) // significant if user supplying any movement update commands + || (x.Far != m_thisAgentUpdateArgs.Far) // significant if far distance changed + || (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed + || (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed + ; + //if (movementSignificant) + //{ + //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}", + // qdelta1, qdelta2); + //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}", + // x.ControlFlags, x.Flags, x.Far, x.State); + //} + return movementSignificant; } /// @@ -5641,12 +5625,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x) { - return ( + float vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis); + float vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter); + float vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis); + float vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis); + + bool cameraSignificant = (vdelta1 > VDELTA) || (vdelta2 > VDELTA) || (vdelta3 > VDELTA) || (vdelta4 > VDELTA) - ); + ; + + //if (cameraSignificant) + //{ + //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}", + // x.CameraAtAxis, x.CameraCenter); + //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}", + // x.CameraLeftAxis, x.CameraUpAxis); + //} + + return cameraSignificant; } private bool HandleAgentUpdate(IClientAPI sener, Packet packet) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 32282af..f5c0b05 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -1316,9 +1316,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; + LLClientView llClient = client as LLClientView; if (agentUpdate.AgentData.SessionID != client.SessionId || agentUpdate.AgentData.AgentID != client.AgentId - || !((LLClientView)client).CheckAgentUpdateSignificance(agentUpdate.AgentData)) + || !(llClient == null || llClient.CheckAgentUpdateSignificance(agentUpdate.AgentData)) ) { PacketPool.Instance.ReturnPacket(packet); return; -- cgit v1.1 From bf517899a7a63278d4ed22d5485c37d61d47bb58 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Jul 2013 23:30:09 +0100 Subject: Add AverageUDPProcessTime stat to try and get a handle on how long we're taking on the initial processing of a UDP packet. If we're not receiving packets with multiple threads (m_asyncPacketHandling) then this is critical since it will limit the number of incoming UDP requests that the region can handle and affects packet loss. If m_asyncPacketHandling then this is less critical though a long process will increase the scope for threads to race. This is an experimental stat which may be changed. --- .../Region/ClientStack/Linden/UDP/LLUDPServer.cs | 19 +++++++++-- .../ClientStack/Linden/UDP/OpenSimUDPBase.cs | 39 ++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index f5c0b05..d3823f3 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -70,8 +70,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP StatsManager.RegisterStat( new Stat( "IncomingPacketsProcessedCount", - "Number of inbound UDP packets processed", - "Number of inbound UDP packets processed", + "Number of inbound LL protocol packets processed", + "Number of inbound LL protocol packets processed", "", "clientstack", scene.Name, @@ -79,6 +79,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP MeasuresOfInterest.AverageChangeOverTime, stat => stat.Value = m_udpServer.IncomingPacketsProcessed, StatVerbosity.Debug)); + + StatsManager.RegisterStat( + new Stat( + "AverageUDPProcessTime", + "Average number of milliseconds taken to process each incoming UDP packet in a sample.", + "This is for initial receive processing which is separate from the later client LL packet processing stage.", + "ms", + "clientstack", + scene.Name, + StatType.Pull, + MeasuresOfInterest.None, + stat => stat.Value = m_udpServer.AverageReceiveTicksForLastSamplePeriod / TimeSpan.TicksPerMillisecond, +// stat => +// stat.Value = Math.Round(m_udpServer.AverageReceiveTicksForLastSamplePeriod / TimeSpan.TicksPerMillisecond, 7), + StatVerbosity.Debug)); } public bool HandlesRegion(Location x) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index a919141..46a3261 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs @@ -78,6 +78,26 @@ namespace OpenMetaverse public bool IsRunningOutbound { get; private set; } /// + /// Number of receives over which to establish a receive time average. + /// + private readonly static int s_receiveTimeSamples = 500; + + /// + /// Current number of samples taken to establish a receive time average. + /// + private int m_currentReceiveTimeSamples; + + /// + /// Cumulative receive time for the sample so far. + /// + private int m_receiveTicksInCurrentSamplePeriod; + + /// + /// The average time taken for each require receive in the last sample. + /// + public float AverageReceiveTicksForLastSamplePeriod { get; private set; } + + /// /// Default constructor /// /// Local IP address to bind the server to @@ -286,6 +306,8 @@ namespace OpenMetaverse try { + int startTick = Util.EnvironmentTickCount(); + // get the length of data actually read from the socket, store it with the // buffer buffer.DataLength = m_udpSocket.EndReceiveFrom(iar, ref buffer.RemoteEndPoint); @@ -293,6 +315,23 @@ namespace OpenMetaverse // call the abstract method PacketReceived(), passing the buffer that // has just been filled from the socket read. PacketReceived(buffer); + + // If more than one thread can be calling AsyncEndReceive() at once (e.g. if m_asyncPacketHandler) + // then a particular stat may be inaccurate due to a race condition. We won't worry about this + // since this should be rare and won't cause a runtime problem. + if (m_currentReceiveTimeSamples >= s_receiveTimeSamples) + { + AverageReceiveTicksForLastSamplePeriod + = (float)m_receiveTicksInCurrentSamplePeriod / s_receiveTimeSamples; + + m_receiveTicksInCurrentSamplePeriod = 0; + m_currentReceiveTimeSamples = 0; + } + else + { + m_receiveTicksInCurrentSamplePeriod += Util.EnvironmentTickCountSubtract(startTick); + m_currentReceiveTimeSamples++; + } } catch (SocketException) { } catch (ObjectDisposedException) { } -- cgit v1.1 From 8396f1bd42cf42d412c09e769c491930aaa8bfea Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 22 Jul 2013 23:58:45 +0100 Subject: Record raw number of UDP receives as clientstack.IncomingUDPReceivesCount --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 13 +++++++++++++ OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index d3823f3..5300b1e 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -69,6 +69,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP StatsManager.RegisterStat( new Stat( + "IncomingUDPReceivesCount", + "Number of inbound LL protocol packets processed", + "Number of inbound LL protocol packets processed", + "", + "clientstack", + scene.Name, + StatType.Pull, + MeasuresOfInterest.AverageChangeOverTime, + stat => stat.Value = m_udpServer.UdpReceives, + StatVerbosity.Debug)); + + StatsManager.RegisterStat( + new Stat( "IncomingPacketsProcessedCount", "Number of inbound LL protocol packets processed", "Number of inbound LL protocol packets processed", diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index 46a3261..b4044b5 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs @@ -78,6 +78,11 @@ namespace OpenMetaverse public bool IsRunningOutbound { get; private set; } /// + /// Number of UDP receives. + /// + public int UdpReceives { get; private set; } + + /// /// Number of receives over which to establish a receive time average. /// private readonly static int s_receiveTimeSamples = 500; @@ -295,6 +300,8 @@ namespace OpenMetaverse // to AsyncBeginReceive if (IsRunningInbound) { + UdpReceives++; + // Asynchronous mode will start another receive before the // callback for this packet is even fired. Very parallel :-) if (m_asyncPacketHandling) @@ -345,7 +352,6 @@ namespace OpenMetaverse if (!m_asyncPacketHandling) AsyncBeginReceive(); } - } } -- cgit v1.1 From 60732c96efd149bbb0484b327b00463dc5b81aff Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Jul 2013 00:15:58 +0100 Subject: Add clientstack.OutgoingUDPSendsCount stat to show number of outbound UDP packets sent by a region per second --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 18 +++++++++++++++--- .../Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | 7 +++++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 5300b1e..cc4de10 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -70,8 +70,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP StatsManager.RegisterStat( new Stat( "IncomingUDPReceivesCount", - "Number of inbound LL protocol packets processed", - "Number of inbound LL protocol packets processed", + "Number of UDP receives performed", + "Number of UDP receives performed", "", "clientstack", scene.Name, @@ -95,6 +95,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP StatsManager.RegisterStat( new Stat( + "OutgoingUDPSendsCount", + "Number of UDP sends performed", + "Number of UDP sends performed", + "", + "clientstack", + scene.Name, + StatType.Pull, + MeasuresOfInterest.AverageChangeOverTime, + stat => stat.Value = m_udpServer.UdpSends, + StatVerbosity.Debug)); + + StatsManager.RegisterStat( + new Stat( "AverageUDPProcessTime", "Average number of milliseconds taken to process each incoming UDP packet in a sample.", "This is for initial receive processing which is separate from the later client LL packet processing stage.", @@ -856,7 +869,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP PacketPool.Instance.ReturnPacket(packet); m_dataPresentEvent.Set(); - } private AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false); diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index b4044b5..d0ed7e8 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs @@ -83,6 +83,11 @@ namespace OpenMetaverse public int UdpReceives { get; private set; } /// + /// Number of UDP sends + /// + public int UdpSends { get; private set; } + + /// /// Number of receives over which to establish a receive time average. /// private readonly static int s_receiveTimeSamples = 500; @@ -381,6 +386,8 @@ namespace OpenMetaverse { // UDPPacketBuffer buf = (UDPPacketBuffer)result.AsyncState; m_udpSocket.EndSendTo(result); + + UdpSends++; } catch (SocketException) { } catch (ObjectDisposedException) { } -- cgit v1.1 From 9fb9da1b6c86e10b229706fe06f2875c8a63a52f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Jul 2013 00:31:57 +0100 Subject: Add clientstack.InboxPacketsCount stat. This records the number of packets waiting to be processed at the second stage (after initial UDP processing) If this consistently increases then this is a problem since it means the simulator is receiving more requests than it can distribute to other parts of the code. --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index cc4de10..0e9f1b7 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -500,6 +500,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP m_scene = (Scene)scene; m_location = new Location(m_scene.RegionInfo.RegionHandle); + StatsManager.RegisterStat( + new Stat( + "InboxPacketsCount", + "Number of LL protocol packets waiting for the second stage of processing after initial receive.", + "Number of LL protocol packets waiting for the second stage of processing after initial receive.", + "", + "clientstack", + scene.Name, + StatType.Pull, + MeasuresOfInterest.AverageChangeOverTime, + stat => stat.Value = packetInbox.Count, + StatVerbosity.Debug)); + // XXX: These stats are also pool stats but we register them separately since they are currently not // turned on and off by EnablePools()/DisablePools() StatsManager.RegisterStat( -- cgit v1.1 From a57a472ab8edf70430a8391909e6078b9ae0f26d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Jul 2013 00:51:59 +0100 Subject: Add proper method doc and comments to m_dataPresentEvent (from d9d9959) --- OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 0e9f1b7..37fd252 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs @@ -223,6 +223,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// Flag to signal when clients should send pings protected bool m_sendPing; + /// + /// Event used to signal when queued packets are available for sending. + /// + /// + /// This allows the outbound loop to only operate when there is data to send rather than continuously polling. + /// Some data is sent immediately and not queued. That data would not trigger this event. + /// + private AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false); + private Pool m_incomingPacketPool; /// @@ -881,11 +890,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP } PacketPool.Instance.ReturnPacket(packet); + m_dataPresentEvent.Set(); } - private AutoResetEvent m_dataPresentEvent = new AutoResetEvent(false); - /// /// Start the process of sending a packet to the client. /// @@ -1817,6 +1825,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP // token bucket could get more tokens //if (!m_packetSent) // Thread.Sleep((int)TickCountResolution); + // + // Instead, now wait for data present to be explicitly signalled. Evidence so far is that with + // modern mono it reduces CPU base load since there is no more continuous polling. m_dataPresentEvent.WaitOne(100); Watchdog.UpdateThread(); -- cgit v1.1 From 90528c23d991cd1fc77823be49e4135cf412b92e Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Jul 2013 01:13:13 +0100 Subject: For stats which can show average change over time, show the last sample as well as the average. This is somewhat cryptic at the moment, need to improve documentation. --- OpenSim/Framework/Monitoring/Stats/Stat.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs index 9629b6e..cc2c947 100644 --- a/OpenSim/Framework/Monitoring/Stats/Stat.cs +++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs @@ -253,6 +253,8 @@ namespace OpenSim.Framework.Monitoring == MeasuresOfInterest.AverageChangeOverTime) { double totalChange = 0; + double lastChangeOverTime = 0; + double? penultimateSample = null; double? lastSample = null; lock (m_samples) @@ -266,13 +268,21 @@ namespace OpenSim.Framework.Monitoring if (lastSample != null) totalChange += s - (double)lastSample; + penultimateSample = lastSample; lastSample = s; } } + if (lastSample != null && penultimateSample != null) + lastChangeOverTime = (double)lastSample - (double)penultimateSample; + int divisor = m_samples.Count <= 1 ? 1 : m_samples.Count - 1; - sb.AppendFormat(", {0:0.##} {1}/s", totalChange / divisor / (Watchdog.WATCHDOG_INTERVAL_MS / 1000), UnitName); + double averageChangeOverTime = totalChange / divisor / (Watchdog.WATCHDOG_INTERVAL_MS / 1000); + + sb.AppendFormat( + ", {0:0.##} {1}/s, {2:0.##} {3}/s", + lastChangeOverTime, UnitName, averageChangeOverTime, UnitName); } } } -- cgit v1.1 From af9deed13593a85aef64205f9ca616a06711963c Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 23 Jul 2013 08:11:21 -0700 Subject: Revert "Revert "BulletSim: freshen up the code for constraint based linksets."" Found that the vehicle movement problem was not caused by these physics changes. This reverts commit 44543ebe638f391fc1c7ff532fe4470006dec55a. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 4 +- .../Physics/BulletSPlugin/BSLinksetCompound.cs | 1 + .../Physics/BulletSPlugin/BSLinksetConstraints.cs | 82 ++++++++++++++++------ 3 files changed, 64 insertions(+), 23 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 0204967..4c2c1c1 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -1029,8 +1029,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin // Add this correction to the velocity to make it faster/slower. VehicleVelocity += linearMotorVelocityW; - VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},correctV={3},correctW={4},newVelW={5},fricFact={6}", - ControllingPrim.LocalID, origVelW, currentVelV, linearMotorCorrectionV, + VDetailLog("{0}, MoveLinear,velocity,origVelW={1},velV={2},tgt={3},correctV={4},correctW={5},newVelW={6},fricFact={7}", + ControllingPrim.LocalID, origVelW, currentVelV, m_linearMotor.TargetValue, linearMotorCorrectionV, linearMotorVelocityW, VehicleVelocity, frictionFactorV); } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 1d94142..3668456 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs @@ -59,6 +59,7 @@ public sealed class BSLinksetCompound : BSLinkset { DetailLog("{0},BSLinksetCompound.ScheduleRebuild,,rebuilding={1},hasChildren={2},actuallyScheduling={3}", requestor.LocalID, Rebuilding, HasAnyChildren, (!Rebuilding && HasAnyChildren)); + // When rebuilding, it is possible to set properties that would normally require a rebuild. // If already rebuilding, don't request another rebuild. // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding. diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs index a06a44d..f17d698 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs @@ -48,12 +48,22 @@ public sealed class BSLinksetConstraints : BSLinkset { base.Refresh(requestor); - if (HasAnyChildren && IsRoot(requestor)) + } + + private void ScheduleRebuild(BSPrimLinkable requestor) + { + DetailLog("{0},BSLinksetConstraint.ScheduleRebuild,,rebuilding={1},hasChildren={2},actuallyScheduling={3}", + requestor.LocalID, Rebuilding, HasAnyChildren, (!Rebuilding && HasAnyChildren)); + + // When rebuilding, it is possible to set properties that would normally require a rebuild. + // If already rebuilding, don't request another rebuild. + // If a linkset with just a root prim (simple non-linked prim) don't bother rebuilding. + if (!Rebuilding && HasAnyChildren) { // Queue to happen after all the other taint processing m_physicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() { - if (HasAnyChildren && IsRoot(requestor)) + if (HasAnyChildren) RecomputeLinksetConstraints(); }); } @@ -67,8 +77,14 @@ public sealed class BSLinksetConstraints : BSLinkset // Called at taint-time! public override bool MakeDynamic(BSPrimLinkable child) { - // What is done for each object in BSPrim is what we want. - return false; + bool ret = false; + DetailLog("{0},BSLinksetConstraints.MakeDynamic,call,IsRoot={1}", child.LocalID, IsRoot(child)); + if (IsRoot(child)) + { + // The root is going dynamic. Rebuild the linkset so parts and mass get computed properly. + ScheduleRebuild(LinksetRoot); + } + return ret; } // The object is going static (non-physical). Do any setup necessary for a static linkset. @@ -78,8 +94,16 @@ public sealed class BSLinksetConstraints : BSLinkset // Called at taint-time! public override bool MakeStatic(BSPrimLinkable child) { - // What is done for each object in BSPrim is what we want. - return false; + bool ret = false; + + DetailLog("{0},BSLinksetConstraint.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child)); + child.ClearDisplacement(); + if (IsRoot(child)) + { + // Schedule a rebuild to verify that the root shape is set to the real shape. + ScheduleRebuild(LinksetRoot); + } + return ret; } // Called at taint-time!! @@ -105,7 +129,7 @@ public sealed class BSLinksetConstraints : BSLinkset // Just undo all the constraints for this linkset. Rebuild at the end of the step. ret = PhysicallyUnlinkAllChildrenFromRoot(LinksetRoot); // Cause the constraints, et al to be rebuilt before the next simulation step. - Refresh(LinksetRoot); + ScheduleRebuild(LinksetRoot); } return ret; } @@ -123,7 +147,7 @@ public sealed class BSLinksetConstraints : BSLinkset DetailLog("{0},BSLinksetConstraints.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); // Cause constraints and assorted properties to be recomputed before the next simulation step. - Refresh(LinksetRoot); + ScheduleRebuild(LinksetRoot); } return; } @@ -147,7 +171,7 @@ public sealed class BSLinksetConstraints : BSLinkset PhysicallyUnlinkAChildFromRoot(rootx, childx); }); // See that the linkset parameters are recomputed at the end of the taint time. - Refresh(LinksetRoot); + ScheduleRebuild(LinksetRoot); } else { @@ -165,6 +189,7 @@ public sealed class BSLinksetConstraints : BSLinkset Refresh(rootPrim); } + // Create a static constraint between the two passed objects private BSConstraint BuildConstraint(BSPrimLinkable rootPrim, BSPrimLinkable childPrim) { // Zero motion for children so they don't interpolate @@ -281,24 +306,39 @@ public sealed class BSLinksetConstraints : BSLinkset DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}", LinksetRoot.LocalID, LinksetRoot.PhysBody.AddrString, linksetMass); - foreach (BSPrimLinkable child in m_children) + try { - // A child in the linkset physically shows the mass of the whole linkset. - // This allows Bullet to apply enough force on the child to move the whole linkset. - // (Also do the mass stuff before recomputing the constraint so mass is not zero.) - child.UpdatePhysicalMassProperties(linksetMass, true); + Rebuilding = true; - BSConstraint constrain; - if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) + // There is no reason to build all this physical stuff for a non-physical linkset. + if (!LinksetRoot.IsPhysicallyActive) { - // If constraint doesn't exist yet, create it. - constrain = BuildConstraint(LinksetRoot, child); + DetailLog("{0},BSLinksetConstraint.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID); + return; // Note the 'finally' clause at the botton which will get executed. } - constrain.RecomputeConstraintVariables(linksetMass); - // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG - } + foreach (BSPrimLinkable child in m_children) + { + // A child in the linkset physically shows the mass of the whole linkset. + // This allows Bullet to apply enough force on the child to move the whole linkset. + // (Also do the mass stuff before recomputing the constraint so mass is not zero.) + child.UpdatePhysicalMassProperties(linksetMass, true); + + BSConstraint constrain; + if (!m_physicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) + { + // If constraint doesn't exist yet, create it. + constrain = BuildConstraint(LinksetRoot, child); + } + constrain.RecomputeConstraintVariables(linksetMass); + // PhysicsScene.PE.DumpConstraint(PhysicsScene.World, constrain.Constraint); // DEBUG DEBUG + } + } + finally + { + Rebuilding = false; + } } } } -- cgit v1.1 From 401c2e2f2ec7c6001387df505665b19477afd4cf Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 23 Jul 2013 08:12:34 -0700 Subject: Revert "Revert "Add experimental stubs for an extension function interface on both"" Found that the vehicle movement problem was not caused by these physics changes. This reverts commit 89857378ce79f93a265bc1eb151e17742032abfa. --- OpenSim/Region/Physics/Manager/PhysicsActor.cs | 6 ++++++ OpenSim/Region/Physics/Manager/PhysicsScene.cs | 9 +++++++++ 2 files changed, 15 insertions(+) diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index bd806eb..2500f27 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs @@ -313,6 +313,12 @@ namespace OpenSim.Region.Physics.Manager public abstract void SubscribeEvents(int ms); public abstract void UnSubscribeEvents(); public abstract bool SubscribedEvents(); + + // Extendable interface for new, physics engine specific operations + public virtual object Extension(string pFunct, params object[] pParams) + { + throw new NotImplementedException(); + } } public class NullPhysicsActor : PhysicsActor diff --git a/OpenSim/Region/Physics/Manager/PhysicsScene.cs b/OpenSim/Region/Physics/Manager/PhysicsScene.cs index 290b72e..07a1d36 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsScene.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsScene.cs @@ -25,10 +25,13 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +using System; using System.Collections.Generic; using System.Reflection; + using log4net; using Nini.Config; + using OpenSim.Framework; using OpenMetaverse; @@ -331,5 +334,11 @@ namespace OpenSim.Region.Physics.Manager { return false; } + + // Extendable interface for new, physics engine specific operations + public virtual object Extension(string pFunct, params object[] pParams) + { + throw new NotImplementedException(); + } } } -- cgit v1.1 From aec8852af793699a4c1093a38b992daf2dbd97f3 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 23 Jul 2013 08:13:01 -0700 Subject: Revert "Revert "BulletSim: move collision processing for linksets from BSPrimLinkable"" Found that the vehicle movement problem was not caused by these physics changes. This reverts commit c45659863d8821a48a32e5b687c7b2a6d90b0300. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 16 ++--- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 75 +++++++++++++++++++++- .../Region/Physics/BulletSPlugin/BSPhysObject.cs | 11 ++++ OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 5 +- .../Region/Physics/BulletSPlugin/BSPrimLinkable.cs | 32 +++++++-- 5 files changed, 121 insertions(+), 18 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 4c2c1c1..1540df1 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -1001,7 +1001,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin else if (newVelocityLengthSq < 0.001f) VehicleVelocity = Vector3.Zero; - VDetailLog("{0}, MoveLinear,done,isColl={1},newVel={2}", ControllingPrim.LocalID, ControllingPrim.IsColliding, VehicleVelocity ); + VDetailLog("{0}, MoveLinear,done,isColl={1},newVel={2}", ControllingPrim.LocalID, ControllingPrim.HasSomeCollision, VehicleVelocity ); } // end MoveLinear() @@ -1062,7 +1062,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin Vector3 linearDeflectionW = linearDeflectionV * VehicleOrientation; // Optionally, if not colliding, don't effect world downward velocity. Let falling things fall. - if (BSParam.VehicleLinearDeflectionNotCollidingNoZ && !m_controllingPrim.IsColliding) + if (BSParam.VehicleLinearDeflectionNotCollidingNoZ && !m_controllingPrim.HasSomeCollision) { linearDeflectionW.Z = 0f; } @@ -1222,7 +1222,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin float targetHeight = Type == Vehicle.TYPE_BOAT ? GetWaterLevel(VehiclePosition) : GetTerrainHeight(VehiclePosition); distanceAboveGround = VehiclePosition.Z - targetHeight; // Not colliding if the vehicle is off the ground - if (!Prim.IsColliding) + if (!Prim.HasSomeCollision) { // downForce = new Vector3(0, 0, -distanceAboveGround / m_bankingTimescale); VehicleVelocity += new Vector3(0, 0, -distanceAboveGround); @@ -1233,12 +1233,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin // be computed with a motor. // TODO: add interaction with banking. VDetailLog("{0}, MoveLinear,limitMotorUp,distAbove={1},colliding={2},ret={3}", - Prim.LocalID, distanceAboveGround, Prim.IsColliding, ret); + Prim.LocalID, distanceAboveGround, Prim.HasSomeCollision, ret); */ // Another approach is to measure if we're going up. If going up and not colliding, // the vehicle is in the air. Fix that by pushing down. - if (!ControllingPrim.IsColliding && VehicleVelocity.Z > 0.1) + if (!ControllingPrim.HasSomeCollision && VehicleVelocity.Z > 0.1) { // Get rid of any of the velocity vector that is pushing us up. float upVelocity = VehicleVelocity.Z; @@ -1260,7 +1260,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin } */ VDetailLog("{0}, MoveLinear,limitMotorUp,collide={1},upVel={2},newVel={3}", - ControllingPrim.LocalID, ControllingPrim.IsColliding, upVelocity, VehicleVelocity); + ControllingPrim.LocalID, ControllingPrim.HasSomeCollision, upVelocity, VehicleVelocity); } } } @@ -1270,14 +1270,14 @@ namespace OpenSim.Region.Physics.BulletSPlugin Vector3 appliedGravity = m_VehicleGravity * m_vehicleMass; // Hack to reduce downward force if the vehicle is probably sitting on the ground - if (ControllingPrim.IsColliding && IsGroundVehicle) + if (ControllingPrim.HasSomeCollision && IsGroundVehicle) appliedGravity *= BSParam.VehicleGroundGravityFudge; VehicleAddForce(appliedGravity); VDetailLog("{0}, MoveLinear,applyGravity,vehGrav={1},collid={2},fudge={3},mass={4},appliedForce={5}", ControllingPrim.LocalID, m_VehicleGravity, - ControllingPrim.IsColliding, BSParam.VehicleGroundGravityFudge, m_vehicleMass, appliedGravity); + ControllingPrim.HasSomeCollision, BSParam.VehicleGroundGravityFudge, m_vehicleMass, appliedGravity); } // ======================================================================= diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index ad8e10f..78c0af7 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -203,6 +203,33 @@ public abstract class BSLinkset return ret; } + // Called after a simulation step to post a collision with this object. + // Return 'true' if linkset processed the collision. 'false' says the linkset didn't have + // anything to add for the collision and it should be passed through normal processing. + // Default processing for a linkset. + public virtual bool HandleCollide(uint collidingWith, BSPhysObject collidee, + OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) + { + bool ret = false; + + // prims in the same linkset cannot collide with each other + BSPrimLinkable convCollidee = collidee as BSPrimLinkable; + if (convCollidee != null && (LinksetID == convCollidee.Linkset.LinksetID)) + { + // By returning 'true', we tell the caller the collision has been 'handled' so it won't + // do anything about this collision and thus, effectivily, ignoring the collision. + ret = true; + } + else + { + // Not a collision between members of the linkset. Must be a real collision. + // So the linkset root can know if there is a collision anywhere in the linkset. + LinksetRoot.SomeCollisionSimulationStep = m_physicsScene.SimulationStep; + } + + return ret; + } + // I am the root of a linkset and a new child is being added // Called while LinkActivity is locked. protected abstract void AddChildToLinkset(BSPrimLinkable child); @@ -251,6 +278,53 @@ public abstract class BSLinkset public abstract bool RemoveDependencies(BSPrimLinkable child); // ================================================================ + // Some physical setting happen to all members of the linkset + public virtual void SetPhysicalFriction(float friction) + { + ForEachMember((member) => + { + if (member.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetFriction(member.PhysBody, friction); + return false; // 'false' says to continue looping + } + ); + } + public virtual void SetPhysicalRestitution(float restitution) + { + ForEachMember((member) => + { + if (member.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetRestitution(member.PhysBody, restitution); + return false; // 'false' says to continue looping + } + ); + } + public virtual void SetPhysicalGravity(OMV.Vector3 gravity) + { + ForEachMember((member) => + { + if (member.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetGravity(member.PhysBody, gravity); + return false; // 'false' says to continue looping + } + ); + } + public virtual void ComputeLocalInertia() + { + ForEachMember((member) => + { + if (member.PhysBody.HasPhysicalBody) + { + OMV.Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(member.PhysShape.physShapeInfo, member.Mass); + member.Inertia = inertia * BSParam.VehicleInertiaFactor; + m_physicsScene.PE.SetMassProps(member.PhysBody, member.Mass, member.Inertia); + m_physicsScene.PE.UpdateInertiaTensor(member.PhysBody); + } + return false; // 'false' says to continue looping + } + ); + } + // ================================================================ protected virtual float ComputeLinksetMass() { float mass = LinksetRoot.RawMass; @@ -311,6 +385,5 @@ public abstract class BSLinkset if (m_physicsScene.PhysicsLogging.Enabled) m_physicsScene.DetailLog(msg, args); } - } } diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index fc4545f..d34b797 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs @@ -353,6 +353,16 @@ public abstract class BSPhysObject : PhysicsActor CollidingStep = BSScene.NotASimulationStep; } } + // Complex objects (like linksets) need to know if there is a collision on any part of + // their shape. 'IsColliding' has an existing definition of reporting a collision on + // only this specific prim or component of linksets. + // 'HasSomeCollision' is defined as reporting if there is a collision on any part of + // the complex body that this prim is the root of. + public virtual bool HasSomeCollision + { + get { return IsColliding; } + set { IsColliding = value; } + } public override bool CollidingGround { get { return (CollidingGroundStep == PhysScene.SimulationStep); } set @@ -386,6 +396,7 @@ public abstract class BSPhysObject : PhysicsActor // Return 'true' if a collision was processed and should be sent up. // Return 'false' if this object is not enabled/subscribed/appropriate for or has already seen this collision. // Called at taint time from within the Step() function + public delegate bool CollideCall(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth); public virtual bool Collide(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index d43448e..4771934 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -495,8 +495,8 @@ public class BSPrim : BSPhysObject } } - // Find and return a handle to the current vehicle actor. - // Return 'null' if there is no vehicle actor. + // Find and return a handle to the current vehicle actor. + // Return 'null' if there is no vehicle actor. public BSDynamics GetVehicleActor() { BSDynamics ret = null; @@ -507,6 +507,7 @@ public class BSPrim : BSPhysObject } return ret; } + public override int VehicleType { get { int ret = (int)Vehicle.TYPE_NONE; diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs index 1fbcfcc..2f392da 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs @@ -200,20 +200,38 @@ public class BSPrimLinkable : BSPrimDisplaced } // Called after a simulation step to post a collision with this object. + // This returns 'true' if the collision has been queued and the SendCollisions call must + // be made at the end of the simulation step. public override bool Collide(uint collidingWith, BSPhysObject collidee, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) { - // prims in the same linkset cannot collide with each other - BSPrimLinkable convCollidee = collidee as BSPrimLinkable; - if (convCollidee != null && (this.Linkset.LinksetID == convCollidee.Linkset.LinksetID)) + bool ret = false; + // Ask the linkset if it wants to handle the collision + if (!Linkset.HandleCollide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth)) { - return false; + // The linkset didn't handle it so pass the collision through normal processing + ret = base.Collide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth); } + return ret; + } - // TODO: handle collisions of other objects with with children of linkset. - // This is a problem for LinksetCompound since the children are packed into the root. + // A linkset reports any collision on any part of the linkset. + public long SomeCollisionSimulationStep = 0; + public override bool HasSomeCollision + { + get + { + return (SomeCollisionSimulationStep == PhysScene.SimulationStep) || base.IsColliding; + } + set + { + if (value) + SomeCollisionSimulationStep = PhysScene.SimulationStep; + else + SomeCollisionSimulationStep = 0; - return base.Collide(collidingWith, collidee, contactPoint, contactNormal, pentrationDepth); + base.HasSomeCollision = value; + } } } } -- cgit v1.1 From b14156aa6317b2c0ca6801730beb7c51eed97244 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 23 Jul 2013 08:13:29 -0700 Subject: Revert "Revert "BulletSim: only create vehicle prim actor when vehicles are enabled."" Found that the vehicle movement problem was not caused by these physics changes. This reverts commit 5f7b2ea81b95a60e882bc65b663a2c9fe134f92a. --- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 43 ++++++++++++++++------ .../Physics/BulletSPlugin/Tests/BasicVehicles.cs | 2 +- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 4771934..fdb2925 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -96,7 +96,7 @@ public class BSPrim : BSPhysObject _isVolumeDetect = false; // Add a dynamic vehicle to our set of actors that can move this prim. - PhysicalActors.Add(VehicleActorName, new BSDynamics(PhysScene, this, VehicleActorName)); + // PhysicalActors.Add(VehicleActorName, new BSDynamics(PhysScene, this, VehicleActorName)); _mass = CalculateMass(); @@ -497,7 +497,7 @@ public class BSPrim : BSPhysObject // Find and return a handle to the current vehicle actor. // Return 'null' if there is no vehicle actor. - public BSDynamics GetVehicleActor() + public BSDynamics GetVehicleActor(bool createIfNone) { BSDynamics ret = null; BSActor actor; @@ -505,13 +505,21 @@ public class BSPrim : BSPhysObject { ret = actor as BSDynamics; } + else + { + if (createIfNone) + { + ret = new BSDynamics(PhysScene, this, VehicleActorName); + PhysicalActors.Add(ret.ActorName, ret); + } + } return ret; } public override int VehicleType { get { int ret = (int)Vehicle.TYPE_NONE; - BSDynamics vehicleActor = GetVehicleActor(); + BSDynamics vehicleActor = GetVehicleActor(false /* createIfNone */); if (vehicleActor != null) ret = (int)vehicleActor.Type; return ret; @@ -525,11 +533,24 @@ public class BSPrim : BSPhysObject // change all the parameters. Like a plane changing to CAR when on the // ground. In this case, don't want to zero motion. // ZeroMotion(true /* inTaintTime */); - BSDynamics vehicleActor = GetVehicleActor(); - if (vehicleActor != null) + if (type == Vehicle.TYPE_NONE) { - vehicleActor.ProcessTypeChange(type); - ActivateIfPhysical(false); + // Vehicle type is 'none' so get rid of any actor that may have been allocated. + BSDynamics vehicleActor = GetVehicleActor(false /* createIfNone */); + if (vehicleActor != null) + { + PhysicalActors.RemoveAndRelease(vehicleActor.ActorName); + } + } + else + { + // Vehicle type is not 'none' so create an actor and set it running. + BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); + if (vehicleActor != null) + { + vehicleActor.ProcessTypeChange(type); + ActivateIfPhysical(false); + } } }); } @@ -538,7 +559,7 @@ public class BSPrim : BSPhysObject { PhysScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() { - BSDynamics vehicleActor = GetVehicleActor(); + BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); if (vehicleActor != null) { vehicleActor.ProcessFloatVehicleParam((Vehicle)param, value); @@ -550,7 +571,7 @@ public class BSPrim : BSPhysObject { PhysScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() { - BSDynamics vehicleActor = GetVehicleActor(); + BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); if (vehicleActor != null) { vehicleActor.ProcessVectorVehicleParam((Vehicle)param, value); @@ -562,7 +583,7 @@ public class BSPrim : BSPhysObject { PhysScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() { - BSDynamics vehicleActor = GetVehicleActor(); + BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); if (vehicleActor != null) { vehicleActor.ProcessRotationVehicleParam((Vehicle)param, rotation); @@ -574,7 +595,7 @@ public class BSPrim : BSPhysObject { PhysScene.TaintedObject("BSPrim.VehicleFlags", delegate() { - BSDynamics vehicleActor = GetVehicleActor(); + BSDynamics vehicleActor = GetVehicleActor(true /* createIfNone */); if (vehicleActor != null) { vehicleActor.ProcessVehicleFlags(param, remove); diff --git a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs index 48d3742..48e74eb 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs @@ -116,7 +116,7 @@ public class BasicVehicles : OpenSimTestCase // Instead the appropriate values are set and calls are made just the parts of the // controller we want to exercise. Stepping the physics engine then applies // the actions of that one feature. - BSDynamics vehicleActor = TestVehicle.GetVehicleActor(); + BSDynamics vehicleActor = TestVehicle.GetVehicleActor(true /* createIfNone */); if (vehicleActor != null) { vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency); -- cgit v1.1 From 75686e0e49308a21ca013d246544f88cd8e90cbd Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 23 Jul 2013 08:13:56 -0700 Subject: Revert "Revert "BulletSim: change BSDynamics to expect to be passed a BSPrimLinkable"" Found that the vehicle movement problem was not caused by these physics changes. This reverts commit 7b187deb19517aa7c880458894643a5448566a94. --- OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 1540df1..82d7c44 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs @@ -45,7 +45,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin private static string LogHeader = "[BULLETSIM VEHICLE]"; // the prim this dynamic controller belongs to - private BSPrim ControllingPrim { get; set; } + private BSPrimLinkable ControllingPrim { get; set; } private bool m_haveRegisteredForSceneEvents; @@ -128,9 +128,15 @@ namespace OpenSim.Region.Physics.BulletSPlugin public BSDynamics(BSScene myScene, BSPrim myPrim, string actorName) : base(myScene, myPrim, actorName) { - ControllingPrim = myPrim; Type = Vehicle.TYPE_NONE; m_haveRegisteredForSceneEvents = false; + + ControllingPrim = myPrim as BSPrimLinkable; + if (ControllingPrim == null) + { + // THIS CANNOT HAPPEN!! + } + VDetailLog("{0},Creation", ControllingPrim.LocalID); } // Return 'true' if this vehicle is doing vehicle things @@ -585,6 +591,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin // Friction affects are handled by this vehicle code m_physicsScene.PE.SetFriction(ControllingPrim.PhysBody, BSParam.VehicleFriction); m_physicsScene.PE.SetRestitution(ControllingPrim.PhysBody, BSParam.VehicleRestitution); + // ControllingPrim.Linkset.SetPhysicalFriction(BSParam.VehicleFriction); + // ControllingPrim.Linkset.SetPhysicalRestitution(BSParam.VehicleRestitution); // Moderate angular movement introduced by Bullet. // TODO: possibly set AngularFactor and LinearFactor for the type of vehicle. @@ -595,17 +603,20 @@ namespace OpenSim.Region.Physics.BulletSPlugin // Vehicles report collision events so we know when it's on the ground m_physicsScene.PE.AddToCollisionFlags(ControllingPrim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); + // ControllingPrim.Linkset.SetPhysicalCollisionFlags(CollisionFlags.BS_VEHICLE_COLLISIONS); Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(ControllingPrim.PhysShape.physShapeInfo, m_vehicleMass); ControllingPrim.Inertia = inertia * BSParam.VehicleInertiaFactor; m_physicsScene.PE.SetMassProps(ControllingPrim.PhysBody, m_vehicleMass, ControllingPrim.Inertia); m_physicsScene.PE.UpdateInertiaTensor(ControllingPrim.PhysBody); + // ControllingPrim.Linkset.ComputeLocalInertia(BSParam.VehicleInertiaFactor); // Set the gravity for the vehicle depending on the buoyancy // TODO: what should be done if prim and vehicle buoyancy differ? m_VehicleGravity = ControllingPrim.ComputeGravity(m_VehicleBuoyancy); // The actual vehicle gravity is set to zero in Bullet so we can do all the application of same. m_physicsScene.PE.SetGravity(ControllingPrim.PhysBody, Vector3.Zero); + // ControllingPrim.Linkset.SetPhysicalGravity(Vector3.Zero); VDetailLog("{0},BSDynamics.SetPhysicalParameters,mass={1},inert={2},vehGrav={3},aDamp={4},frict={5},rest={6},lFact={7},aFact={8}", ControllingPrim.LocalID, m_vehicleMass, ControllingPrim.Inertia, m_VehicleGravity, @@ -617,6 +628,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin { if (ControllingPrim.PhysBody.HasPhysicalBody) m_physicsScene.PE.RemoveFromCollisionFlags(ControllingPrim.PhysBody, CollisionFlags.BS_VEHICLE_COLLISIONS); + // ControllingPrim.Linkset.RemoveFromPhysicalCollisionFlags(CollisionFlags.BS_VEHICLE_COLLISIONS); } } @@ -629,6 +641,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin // BSActor.Release() public override void Dispose() { + VDetailLog("{0},Dispose", ControllingPrim.LocalID); UnregisterForSceneEvents(); Type = Vehicle.TYPE_NONE; Enabled = false; -- cgit v1.1 From f499b328c44ef29d92aa2ef8102aad6ff5cbe336 Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 23 Jul 2013 08:14:20 -0700 Subject: Revert "Revert "BulletSim: Add logic to linksets to change physical properties for"" Found that the vehicle movement problem was not caused by these physics changes. This reverts commit 84d0699761b8da546f9faef084240d7b15f16321. --- OpenSim/Region/Physics/BulletSPlugin/BSActors.cs | 6 +--- OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | 24 +++++++++++++-- .../Physics/BulletSPlugin/BSLinksetCompound.cs | 36 ++++++++++++++++++++++ 3 files changed, 59 insertions(+), 7 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs index fff63e4..e0ccc50 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs @@ -69,7 +69,7 @@ public class BSActorCollection { lock (m_actors) { - Release(); + ForEachActor(a => a.Dispose()); m_actors.Clear(); } } @@ -98,10 +98,6 @@ public class BSActorCollection { ForEachActor(a => a.SetEnabled(enabl)); } - public void Release() - { - ForEachActor(a => a.Dispose()); - } public void Refresh() { ForEachActor(a => a.Refresh()); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 78c0af7..960c0b4 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs @@ -309,14 +309,14 @@ public abstract class BSLinkset } ); } - public virtual void ComputeLocalInertia() + public virtual void ComputeLocalInertia(OMV.Vector3 inertiaFactor) { ForEachMember((member) => { if (member.PhysBody.HasPhysicalBody) { OMV.Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(member.PhysShape.physShapeInfo, member.Mass); - member.Inertia = inertia * BSParam.VehicleInertiaFactor; + member.Inertia = inertia * inertiaFactor; m_physicsScene.PE.SetMassProps(member.PhysBody, member.Mass, member.Inertia); m_physicsScene.PE.UpdateInertiaTensor(member.PhysBody); } @@ -324,6 +324,26 @@ public abstract class BSLinkset } ); } + public virtual void SetPhysicalCollisionFlags(CollisionFlags collFlags) + { + ForEachMember((member) => + { + if (member.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetCollisionFlags(member.PhysBody, collFlags); + return false; // 'false' says to continue looping + } + ); + } + public virtual void RemoveFromPhysicalCollisionFlags(CollisionFlags collFlags) + { + ForEachMember((member) => + { + if (member.PhysBody.HasPhysicalBody) + m_physicsScene.PE.RemoveFromCollisionFlags(member.PhysBody, collFlags); + return false; // 'false' says to continue looping + } + ); + } // ================================================================ protected virtual float ComputeLinksetMass() { diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs index 3668456..33ae5a5 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs @@ -44,6 +44,42 @@ public sealed class BSLinksetCompound : BSLinkset { } + // ================================================================ + // Changing the physical property of the linkset only needs to change the root + public override void SetPhysicalFriction(float friction) + { + if (LinksetRoot.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetFriction(LinksetRoot.PhysBody, friction); + } + public override void SetPhysicalRestitution(float restitution) + { + if (LinksetRoot.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetRestitution(LinksetRoot.PhysBody, restitution); + } + public override void SetPhysicalGravity(OMV.Vector3 gravity) + { + if (LinksetRoot.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetGravity(LinksetRoot.PhysBody, gravity); + } + public override void ComputeLocalInertia(OMV.Vector3 inertiaFactor) + { + OMV.Vector3 inertia = m_physicsScene.PE.CalculateLocalInertia(LinksetRoot.PhysShape.physShapeInfo, LinksetRoot.Mass); + LinksetRoot.Inertia = inertia * inertiaFactor; + m_physicsScene.PE.SetMassProps(LinksetRoot.PhysBody, LinksetRoot.Mass, LinksetRoot.Inertia); + m_physicsScene.PE.UpdateInertiaTensor(LinksetRoot.PhysBody); + } + public override void SetPhysicalCollisionFlags(CollisionFlags collFlags) + { + if (LinksetRoot.PhysBody.HasPhysicalBody) + m_physicsScene.PE.SetCollisionFlags(LinksetRoot.PhysBody, collFlags); + } + public override void RemoveFromPhysicalCollisionFlags(CollisionFlags collFlags) + { + if (LinksetRoot.PhysBody.HasPhysicalBody) + m_physicsScene.PE.RemoveFromCollisionFlags(LinksetRoot.PhysBody, collFlags); + } + // ================================================================ + // When physical properties are changed the linkset needs to recalculate // its internal properties. public override void Refresh(BSPrimLinkable requestor) -- cgit v1.1 From aec8d1e6be43422b0f93de47d6e46cc3e17399cc Mon Sep 17 00:00:00 2001 From: Robert Adams Date: Tue, 23 Jul 2013 09:09:25 -0700 Subject: BulletSim: Turn on center-of-mass calculation by default. Reduce object density by factor of 100 to bring physical mass computations into a range better suited for Bullet. --- OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 8 +++++--- OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index dcf1e83..0bdb5f1 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs @@ -461,8 +461,9 @@ public static class BSParam (s) => { return MaxAddForceMagnitude; }, (s,v) => { MaxAddForceMagnitude = v; MaxAddForceMagnitudeSquared = v * v; } ), // Density is passed around as 100kg/m3. This scales that to 1kg/m3. + // Reduce by power of 100 because Bullet doesn't seem to handle objects with large mass very well new ParameterDefn("DensityScaleFactor", "Conversion for simulator/viewer density (100kg/m3) to physical density (1kg/m3)", - 0.01f ), + 0.0001f ), new ParameterDefn("PID_D", "Derivitive factor for motion smoothing", 2200f ), @@ -607,8 +608,9 @@ public static class BSParam 0.0f ), new ParameterDefn("VehicleRestitution", "Bouncyness factor for vehicles (0.0 - 1.0)", 0.0f ), + // Turn off fudge with DensityScaleFactor = 0.0001. Value used to be 0.2f; new ParameterDefn("VehicleGroundGravityFudge", "Factor to multiply gravity if a ground vehicle is probably on the ground (0.0 - 1.0)", - 0.2f ), + 1.0f ), new ParameterDefn("VehicleAngularBankingTimescaleFudge", "Factor to multiple angular banking timescale. Tune to increase realism.", 60.0f ), new ParameterDefn("VehicleEnableLinearDeflection", "Turn on/off vehicle linear deflection effect", @@ -701,7 +703,7 @@ public static class BSParam new ParameterDefn("LinksetImplementation", "Type of linkset implementation (0=Constraint, 1=Compound, 2=Manual)", (float)BSLinkset.LinksetImplementation.Compound ), new ParameterDefn("LinksetOffsetCenterOfMass", "If 'true', compute linkset center-of-mass and offset linkset position to account for same", - false ), + true ), new ParameterDefn("LinkConstraintUseFrameOffset", "For linksets built with constraints, enable frame offsetFor linksets built with constraints, enable frame offset.", false ), new ParameterDefn("LinkConstraintEnableTransMotor", "Whether to enable translational motor on linkset constraints", diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index fdb2925..e92a1d2 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs @@ -440,8 +440,8 @@ public class BSPrim : BSPhysObject Gravity = ComputeGravity(Buoyancy); PhysScene.PE.SetGravity(PhysBody, Gravity); - OMV.Vector3 currentScale = PhysScene.PE.GetLocalScaling(PhysShape.physShapeInfo); // DEBUG DEBUG - DetailLog("{0},BSPrim.UpdateMassProperties,currentScale{1},shape={2}", LocalID, currentScale, PhysShape.physShapeInfo); // DEBUG DEBUG + // OMV.Vector3 currentScale = PhysScene.PE.GetLocalScaling(PhysShape.physShapeInfo); // DEBUG DEBUG + // DetailLog("{0},BSPrim.UpdateMassProperties,currentScale{1},shape={2}", LocalID, currentScale, PhysShape.physShapeInfo); // DEBUG DEBUG Inertia = PhysScene.PE.CalculateLocalInertia(PhysShape.physShapeInfo, physMass); PhysScene.PE.SetMassProps(PhysBody, physMass, Inertia); -- cgit v1.1 From 76e46d0158461a29e6ef358ba8cb7b7323cc0c05 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Jul 2013 17:23:16 +0100 Subject: Improve spacing between data and units on console stats display --- OpenSim/Framework/Monitoring/Stats/Stat.cs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs index cc2c947..f2329ce 100644 --- a/OpenSim/Framework/Monitoring/Stats/Stat.cs +++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs @@ -225,7 +225,13 @@ namespace OpenSim.Framework.Monitoring public virtual string ToConsoleString() { StringBuilder sb = new StringBuilder(); - sb.AppendFormat("{0}.{1}.{2} : {3} {4}", Category, Container, ShortName, Value, UnitName); + sb.AppendFormat( + "{0}.{1}.{2} : {3}{4}", + Category, + Container, + ShortName, + Value, + UnitName == null || UnitName == "" ? "" : string.Format(" {0}", UnitName)); AppendMeasuresOfInterest(sb); @@ -281,8 +287,11 @@ namespace OpenSim.Framework.Monitoring double averageChangeOverTime = totalChange / divisor / (Watchdog.WATCHDOG_INTERVAL_MS / 1000); sb.AppendFormat( - ", {0:0.##} {1}/s, {2:0.##} {3}/s", - lastChangeOverTime, UnitName, averageChangeOverTime, UnitName); + ", {0:0.##}{1}/s, {2:0.##}{3}/s", + lastChangeOverTime, + UnitName == null || UnitName == "" ? "" : string.Format(" {0}", UnitName), + averageChangeOverTime, + UnitName == null || UnitName == "" ? "" : string.Format(" {0}", UnitName)); } } } -- cgit v1.1 From 7c1eb86c7df2e9c9ccfcf4fe6811af29adbef931 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Sun, 21 Jul 2013 15:46:00 -0700 Subject: Don't post Link asset types back to the home grid --- .../Framework/InventoryAccess/HGInventoryAccessModule.cs | 9 ++++++--- OpenSim/Region/Framework/Scenes/EventManager.cs | 6 +++--- OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 4 ++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index e0c8ea6..460d147 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -185,8 +185,11 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } } - public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) + public void UploadInventoryItem(UUID avatarID, AssetType type, UUID assetID, string name, int userlevel) { + if (type == AssetType.Link) + return; + string userAssetServer = string.Empty; if (IsForeignUser(avatarID, out userAssetServer) && userAssetServer != string.Empty && m_OutboundPermission) { @@ -221,7 +224,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess { UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); - UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0); + UploadInventoryItem(remoteClient.AgentId, AssetType.Unknown, newAssetID, "", 0); return newAssetID; } @@ -232,7 +235,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess protected override void ExportAsset(UUID agentID, UUID assetID) { if (!assetID.Equals(UUID.Zero)) - UploadInventoryItem(agentID, assetID, "", 0); + UploadInventoryItem(agentID, AssetType.Unknown, assetID, "", 0); else m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); } diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 61b0ebd..39d7512 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs @@ -742,7 +742,7 @@ namespace OpenSim.Region.Framework.Scenes public event OnIncomingSceneObjectDelegate OnIncomingSceneObject; public delegate void OnIncomingSceneObjectDelegate(SceneObjectGroup so); - public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel); + public delegate void NewInventoryItemUploadComplete(UUID avatarID, AssetType type, UUID assetID, string name, int userlevel); public event NewInventoryItemUploadComplete OnNewInventoryItemUploadComplete; @@ -2146,7 +2146,7 @@ namespace OpenSim.Region.Framework.Scenes } } - public void TriggerOnNewInventoryItemUploadComplete(UUID agentID, UUID AssetID, String AssetName, int userlevel) + public void TriggerOnNewInventoryItemUploadComplete(UUID agentID, AssetType type, UUID AssetID, String AssetName, int userlevel) { NewInventoryItemUploadComplete handlerNewInventoryItemUpdateComplete = OnNewInventoryItemUploadComplete; if (handlerNewInventoryItemUpdateComplete != null) @@ -2155,7 +2155,7 @@ namespace OpenSim.Region.Framework.Scenes { try { - d(agentID, AssetID, AssetName, userlevel); + d(agentID, type, AssetID, AssetName, userlevel); } catch (Exception e) { diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 1e4d558..58fa18c 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -139,7 +139,7 @@ namespace OpenSim.Region.Framework.Scenes { userlevel = 1; } - EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel); + EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); return true; } @@ -178,7 +178,7 @@ namespace OpenSim.Region.Framework.Scenes { userlevel = 1; } - EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, item.AssetID, item.Name, userlevel); + EventManager.TriggerOnNewInventoryItemUploadComplete(item.Owner, (AssetType)item.AssetType, item.AssetID, item.Name, userlevel); if (originalFolder != UUID.Zero) { -- cgit v1.1 From 42e52f544df5210b41b96176c364d1f1d2d96b00 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 23 Jul 2013 11:29:53 -0700 Subject: Improvement of fetching name in groups --- OpenSim/Addons/Groups/GroupsModule.cs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/OpenSim/Addons/Groups/GroupsModule.cs b/OpenSim/Addons/Groups/GroupsModule.cs index 82e2d6f..69d03a9 100644 --- a/OpenSim/Addons/Groups/GroupsModule.cs +++ b/OpenSim/Addons/Groups/GroupsModule.cs @@ -1402,19 +1402,18 @@ namespace OpenSim.Groups if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff - UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, dataForAgentID); - string firstname, lastname; - if (account != null) - { - firstname = account.FirstName; - lastname = account.LastName; - } - else + string firstname = "Unknown", lastname = "Unknown"; + string name = m_UserManagement.GetUserName(dataForAgentID); + if (!string.IsNullOrEmpty(name)) { - firstname = "Unknown"; - lastname = "Unknown"; + string[] parts = name.Split(new char[] { ' ' }); + if (parts.Length >= 2) + { + firstname = parts[0]; + lastname = parts[1]; + } } - + remoteClient.SendAgentDataUpdate(dataForAgentID, activeGroupID, firstname, lastname, activeGroupPowers, activeGroupName, activeGroupTitle); -- cgit v1.1 From 744276dd50daaaba5b4c54ab37f5a034bd48ca3a Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 23 Jul 2013 14:17:32 -0700 Subject: In renaming the folders for hypergriding, don't rename the Current Outfit folder. The viewer doesn't like that. --- .../CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index 460d147..94ea077 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -384,7 +384,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess foreach (InventoryFolderBase f in content.Folders) { - if (f.Name != "My Suitcase") + if (f.Name != "My Suitcase" && f.Name != "Current Outfit") { f.Name = f.Name + " (Unavailable)"; keep.Add(f); -- cgit v1.1 From 901bdfed4093c4d87c59abfbd576e71b2374b7c3 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 23 Jul 2013 14:23:22 -0700 Subject: Restoring landing on prims, which had been affected by the edit beams commit. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 33db88b..6433878 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1125,6 +1125,25 @@ namespace OpenSim.Region.Framework.Scenes public void StopFlying() { + Vector3 pos = AbsolutePosition; + if (Appearance.AvatarHeight != 127.0f) + pos += new Vector3(0f, 0f, (Appearance.AvatarHeight / 6f)); + else + pos += new Vector3(0f, 0f, (1.56f / 6f)); + + AbsolutePosition = pos; + + // attach a suitable collision plane regardless of the actual situation to force the LLClient to land. + // Collision plane below the avatar's position a 6th of the avatar's height is suitable. + // Mind you, that this method doesn't get called if the avatar's velocity magnitude is greater then a + // certain amount.. because the LLClient wouldn't land in that situation anyway. + + // why are we still testing for this really old height value default??? + if (Appearance.AvatarHeight != 127.0f) + CollisionPlane = new Vector4(0, 0, 0, pos.Z - Appearance.AvatarHeight / 6f); + else + CollisionPlane = new Vector4(0, 0, 0, pos.Z - (1.56f / 6f)); + ControllingClient.SendAgentTerseUpdate(this); } -- cgit v1.1 From 516062ae1fb7417bbd1e206cb412da41094addfb Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 23 Jul 2013 15:04:24 -0700 Subject: Don't touch the Current Outfit folder also on coming back home --- .../Framework/InventoryAccess/HGInventoryAccessModule.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index 94ea077..8f9800f 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs @@ -351,7 +351,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess InventoryFolderBase root = m_Scene.InventoryService.GetRootFolder(client.AgentId); InventoryCollection content = m_Scene.InventoryService.GetFolderContent(client.AgentId, root.ID); - inv.SendBulkUpdateInventory(content.Folders.ToArray(), content.Items.ToArray()); + List keep = new List(); + + foreach (InventoryFolderBase f in content.Folders) + { + if (f.Name != "My Suitcase" && f.Name != "Current Outfit") + keep.Add(f); + } + + inv.SendBulkUpdateInventory(keep.ToArray(), content.Items.ToArray()); } } } -- cgit v1.1 From 9a4a513b5e4e2496b32113dcffbeeae776eabb89 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Jul 2013 23:31:35 +0100 Subject: Correct issue where the last instance of a sampled stat was shown 3x larger than it should have been (though internal use was correct) --- OpenSim/Framework/Monitoring/Stats/Stat.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenSim/Framework/Monitoring/Stats/Stat.cs b/OpenSim/Framework/Monitoring/Stats/Stat.cs index f2329ce..ffd5132 100644 --- a/OpenSim/Framework/Monitoring/Stats/Stat.cs +++ b/OpenSim/Framework/Monitoring/Stats/Stat.cs @@ -280,7 +280,8 @@ namespace OpenSim.Framework.Monitoring } if (lastSample != null && penultimateSample != null) - lastChangeOverTime = (double)lastSample - (double)penultimateSample; + lastChangeOverTime + = ((double)lastSample - (double)penultimateSample) / (Watchdog.WATCHDOG_INTERVAL_MS / 1000); int divisor = m_samples.Count <= 1 ? 1 : m_samples.Count - 1; -- cgit v1.1 From feef9d64a478695aa9721423c818e57bf4e0dff6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 23 Jul 2013 23:42:34 +0100 Subject: For unknown user issue, bump GUN7 to GUN8 and UMMAU3 to UMMAU4 to assess what looks like a very significant reducing in GUN occurrances --- .../CoreModules/Framework/UserManagement/UserManagementModule.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index a91adfa..53bd2e2 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs @@ -389,7 +389,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement } names[0] = "Unknown"; - names[1] = "UserUMMTGUN7"; + names[1] = "UserUMMTGUN8"; return false; } @@ -601,7 +601,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement // TODO: Can be removed when GUN* unknown users have definitely dropped significantly or // disappeared. user.FirstName = "Unknown"; - user.LastName = "UserUMMAU3"; + user.LastName = "UserUMMAU4"; } AddUserInternal(user); -- cgit v1.1