aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Addons/Groups/GroupsModule.cs2
-rw-r--r--OpenSim/Addons/Groups/Hypergrid/GroupsServiceHGConnectorModule.cs1
-rw-r--r--OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs4
-rw-r--r--OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs6
-rw-r--r--OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs2
-rw-r--r--OpenSim/Capabilities/Caps.cs2
-rw-r--r--OpenSim/Capabilities/CapsHandlers.cs16
-rw-r--r--OpenSim/Capabilities/Handlers/AvatarPickerSearch/AvatarPickerSearchHandler.cs2
-rw-r--r--OpenSim/Capabilities/LLSDStreamHandler.cs2
-rw-r--r--OpenSim/Framework/ClientInfo.cs11
-rw-r--r--OpenSim/Framework/DAMap.cs4
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseOutputStreamHandler.cs60
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs4
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs27
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs15
-rw-r--r--OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs4
-rw-r--r--OpenSim/Framework/Servers/HttpServer/RestSessionService.cs13
-rw-r--r--OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs2
-rw-r--r--OpenSim/Framework/Util.cs7
-rw-r--r--OpenSim/Region/Application/OpenSimBase.cs74
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs10
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs3
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs238
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs27
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs8
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs32
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadPathTests.cs12
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveSaveTests.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs12
-rw-r--r--OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs337
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs6
-rw-r--r--OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs163
-rw-r--r--OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs4
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs71
-rw-r--r--OpenSim/Region/CoreModules/Scripting/HttpRequest/Tests/ScriptsHttpRequestsTests.cs198
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs5
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs27
-rw-r--r--OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/KeyframeMotion.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs26
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs23
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs77
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs88
-rw-r--r--OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs110
-rw-r--r--OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs19
-rw-r--r--OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs2
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs78
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs346
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs103
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSMotors.cs15
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSParam.cs24
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs7
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs95
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs115
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs40
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs5
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt75
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs4
-rw-r--r--OpenSim/Region/Physics/OdePlugin/ODEPrim.cs1
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs4
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs20
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs2
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs2
-rw-r--r--OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs2
-rw-r--r--OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs2
-rw-r--r--OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs30
-rw-r--r--OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs2
-rw-r--r--OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs2
-rw-r--r--OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs2
-rw-r--r--OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs2
-rw-r--r--OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs2
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs2
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs1
-rw-r--r--OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs2
-rw-r--r--OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/Map/MapAddServerConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/Map/MapGetServerConnector.cs2
-rw-r--r--OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs8
-rw-r--r--OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs2
-rw-r--r--OpenSim/Server/Handlers/Simulation/AgentHandlers.cs6
-rw-r--r--OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs2
-rw-r--r--OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs6
-rw-r--r--OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs15
-rw-r--r--OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs6
-rw-r--r--OpenSim/Services/UserAccountService/GridUserService.cs2
-rw-r--r--OpenSim/Tests/Clients/Assets/AssetsClient.cs99
104 files changed, 2034 insertions, 921 deletions
diff --git a/OpenSim/Addons/Groups/GroupsModule.cs b/OpenSim/Addons/Groups/GroupsModule.cs
index 5959bac..82e2d6f 100644
--- a/OpenSim/Addons/Groups/GroupsModule.cs
+++ b/OpenSim/Addons/Groups/GroupsModule.cs
@@ -485,7 +485,7 @@ namespace OpenSim.Groups
485 return; 485 return;
486 486
487 //// 16 bytes are the UUID. Maybe. 487 //// 16 bytes are the UUID. Maybe.
488 UUID folderID = new UUID(im.binaryBucket, 0); 488// UUID folderID = new UUID(im.binaryBucket, 0);
489 UUID noticeID = new UUID(im.imSessionID); 489 UUID noticeID = new UUID(im.imSessionID);
490 490
491 GroupNoticeInfo notice = m_groupData.GetGroupNotice(remoteClient.AgentId.ToString(), noticeID); 491 GroupNoticeInfo notice = m_groupData.GetGroupNotice(remoteClient.AgentId.ToString(), noticeID);
diff --git a/OpenSim/Addons/Groups/Hypergrid/GroupsServiceHGConnectorModule.cs b/OpenSim/Addons/Groups/Hypergrid/GroupsServiceHGConnectorModule.cs
index cff7adf..c3c759e 100644
--- a/OpenSim/Addons/Groups/Hypergrid/GroupsServiceHGConnectorModule.cs
+++ b/OpenSim/Addons/Groups/Hypergrid/GroupsServiceHGConnectorModule.cs
@@ -543,7 +543,6 @@ namespace OpenSim.Groups
543 List<string> urls = new List<string>(); 543 List<string> urls = new List<string>();
544 foreach (GroupMembersData m in members) 544 foreach (GroupMembersData m in members)
545 { 545 {
546 UUID userID = UUID.Zero;
547 if (!m_UserManagement.IsLocalGridUser(m.AgentID)) 546 if (!m_UserManagement.IsLocalGridUser(m.AgentID))
548 { 547 {
549 string gURL = m_UserManagement.GetUserServerURL(m.AgentID, "GroupsServerURI"); 548 string gURL = m_UserManagement.GetUserServerURL(m.AgentID, "GroupsServerURI");
diff --git a/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs
index 3584f78..d2bcba5 100644
--- a/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs
+++ b/OpenSim/Addons/Groups/Hypergrid/HGGroupsServiceRobustConnector.cs
@@ -47,7 +47,6 @@ namespace OpenSim.Groups
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48 48
49 private HGGroupsService m_GroupsService; 49 private HGGroupsService m_GroupsService;
50 private string m_HomeURI = string.Empty;
51 private string m_ConfigName = "Groups"; 50 private string m_ConfigName = "Groups";
52 51
53 // Called by Robust shell 52 // Called by Robust shell
@@ -113,7 +112,7 @@ namespace OpenSim.Groups
113 m_GroupsService = service; 112 m_GroupsService = service;
114 } 113 }
115 114
116 public override byte[] Handle(string path, Stream requestData, 115 protected override byte[] ProcessRequest(string path, Stream requestData,
117 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 116 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
118 { 117 {
119 StreamReader sr = new StreamReader(requestData); 118 StreamReader sr = new StreamReader(requestData);
@@ -209,7 +208,6 @@ namespace OpenSim.Groups
209 UUID groupID = new UUID(request["GroupID"].ToString()); 208 UUID groupID = new UUID(request["GroupID"].ToString());
210 string agentID = request["AgentID"].ToString(); 209 string agentID = request["AgentID"].ToString();
211 string token = request["AccessToken"].ToString(); 210 string token = request["AccessToken"].ToString();
212 string reason = string.Empty;
213 211
214 m_GroupsService.RemoveAgentFromGroup(agentID, agentID, groupID, token); 212 m_GroupsService.RemoveAgentFromGroup(agentID, agentID, groupID, token);
215 } 213 }
diff --git a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
index 28f7acc..106c6c4 100644
--- a/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
+++ b/OpenSim/Addons/Groups/Remote/GroupsServiceRobustConnector.cs
@@ -75,7 +75,7 @@ namespace OpenSim.Groups
75 m_GroupsService = service; 75 m_GroupsService = service;
76 } 76 }
77 77
78 public override byte[] Handle(string path, Stream requestData, 78 protected override byte[] ProcessRequest(string path, Stream requestData,
79 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 79 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
80 { 80 {
81 StreamReader sr = new StreamReader(requestData); 81 StreamReader sr = new StreamReader(requestData);
@@ -269,7 +269,6 @@ namespace OpenSim.Groups
269 UUID groupID = new UUID(request["GroupID"].ToString()); 269 UUID groupID = new UUID(request["GroupID"].ToString());
270 string agentID = request["AgentID"].ToString(); 270 string agentID = request["AgentID"].ToString();
271 string requestingAgentID = request["RequestingAgentID"].ToString(); 271 string requestingAgentID = request["RequestingAgentID"].ToString();
272 string reason = string.Empty;
273 272
274 m_GroupsService.RemoveAgentFromGroup(requestingAgentID, agentID, groupID); 273 m_GroupsService.RemoveAgentFromGroup(requestingAgentID, agentID, groupID);
275 } 274 }
@@ -500,7 +499,6 @@ namespace OpenSim.Groups
500 else 499 else
501 { 500 {
502 string op = request["OP"].ToString(); 501 string op = request["OP"].ToString();
503 string reason = string.Empty;
504 502
505 bool success = false; 503 bool success = false;
506 if (op == "ADD") 504 if (op == "ADD")
@@ -568,7 +566,6 @@ namespace OpenSim.Groups
568 else 566 else
569 { 567 {
570 string op = request["OP"].ToString(); 568 string op = request["OP"].ToString();
571 string reason = string.Empty;
572 569
573 if (op == "GROUP") 570 if (op == "GROUP")
574 { 571 {
@@ -631,7 +628,6 @@ namespace OpenSim.Groups
631 else 628 else
632 { 629 {
633 string op = request["OP"].ToString(); 630 string op = request["OP"].ToString();
634 string reason = string.Empty;
635 631
636 if (op == "ADD" && request.ContainsKey("GroupID") && request.ContainsKey("RoleID") && request.ContainsKey("AgentID")) 632 if (op == "ADD" && request.ContainsKey("GroupID") && request.ContainsKey("RoleID") && request.ContainsKey("AgentID"))
637 { 633 {
diff --git a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs
index 2b3a01d..32c24db 100644
--- a/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs
+++ b/OpenSim/Addons/OfflineIM/Remote/OfflineIMServiceRobustConnector.cs
@@ -75,7 +75,7 @@ namespace OpenSim.OfflineIM
75 m_OfflineIMService = service; 75 m_OfflineIMService = service;
76 } 76 }
77 77
78 public override byte[] Handle(string path, Stream requestData, 78 protected override byte[] ProcessRequest(string path, Stream requestData,
79 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 79 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
80 { 80 {
81 StreamReader sr = new StreamReader(requestData); 81 StreamReader sr = new StreamReader(requestData);
diff --git a/OpenSim/Capabilities/Caps.cs b/OpenSim/Capabilities/Caps.cs
index 241fef3..95fc61b 100644
--- a/OpenSim/Capabilities/Caps.cs
+++ b/OpenSim/Capabilities/Caps.cs
@@ -145,8 +145,8 @@ namespace OpenSim.Framework.Capabilities
145 /// <param name="handler"></param> 145 /// <param name="handler"></param>
146 public void RegisterHandler(string capName, IRequestHandler handler) 146 public void RegisterHandler(string capName, IRequestHandler handler)
147 { 147 {
148 m_capsHandlers[capName] = handler;
149 //m_log.DebugFormat("[CAPS]: Registering handler for \"{0}\": path {1}", capName, handler.Path); 148 //m_log.DebugFormat("[CAPS]: Registering handler for \"{0}\": path {1}", capName, handler.Path);
149 m_capsHandlers[capName] = handler;
150 } 150 }
151 151
152 /// <summary> 152 /// <summary>
diff --git a/OpenSim/Capabilities/CapsHandlers.cs b/OpenSim/Capabilities/CapsHandlers.cs
index 458272d..890df90 100644
--- a/OpenSim/Capabilities/CapsHandlers.cs
+++ b/OpenSim/Capabilities/CapsHandlers.cs
@@ -39,7 +39,7 @@ namespace OpenSim.Framework.Capabilities
39 /// </summary> 39 /// </summary>
40 public class CapsHandlers 40 public class CapsHandlers
41 { 41 {
42 private Dictionary <string, IRequestHandler> m_capsHandlers = new Dictionary<string, IRequestHandler>(); 42 private Dictionary<string, IRequestHandler> m_capsHandlers = new Dictionary<string, IRequestHandler>();
43 private IHttpServer m_httpListener; 43 private IHttpServer m_httpListener;
44 private string m_httpListenerHostName; 44 private string m_httpListenerHostName;
45 private uint m_httpListenerPort; 45 private uint m_httpListenerPort;
@@ -184,5 +184,17 @@ namespace OpenSim.Framework.Capabilities
184 184
185 return caps; 185 return caps;
186 } 186 }
187
188 /// <summary>
189 /// Returns a copy of the dictionary of all the HTTP cap handlers
190 /// </summary>
191 /// <returns>
192 /// The dictionary copy. The key is the capability name, the value is the HTTP handler.
193 /// </returns>
194 public Dictionary<string, IRequestHandler> GetCapsHandlers()
195 {
196 lock (m_capsHandlers)
197 return new Dictionary<string, IRequestHandler>(m_capsHandlers);
198 }
187 } 199 }
188} 200} \ No newline at end of file
diff --git a/OpenSim/Capabilities/Handlers/AvatarPickerSearch/AvatarPickerSearchHandler.cs b/OpenSim/Capabilities/Handlers/AvatarPickerSearch/AvatarPickerSearchHandler.cs
index 4dca592..426174d 100644
--- a/OpenSim/Capabilities/Handlers/AvatarPickerSearch/AvatarPickerSearchHandler.cs
+++ b/OpenSim/Capabilities/Handlers/AvatarPickerSearch/AvatarPickerSearchHandler.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Capabilities.Handlers
56 m_PeopleService = peopleService; 56 m_PeopleService = peopleService;
57 } 57 }
58 58
59 public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 59 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
60 { 60 {
61 // Try to parse the texture ID from the request URL 61 // Try to parse the texture ID from the request URL
62 NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query); 62 NameValueCollection query = HttpUtility.ParseQueryString(httpRequest.Url.Query);
diff --git a/OpenSim/Capabilities/LLSDStreamHandler.cs b/OpenSim/Capabilities/LLSDStreamHandler.cs
index 5df24b2..4fa1153 100644
--- a/OpenSim/Capabilities/LLSDStreamHandler.cs
+++ b/OpenSim/Capabilities/LLSDStreamHandler.cs
@@ -48,7 +48,7 @@ namespace OpenSim.Framework.Capabilities
48 m_method = method; 48 m_method = method;
49 } 49 }
50 50
51 public override byte[] Handle(string path, Stream request, 51 protected override byte[] ProcessRequest(string path, Stream request,
52 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 52 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
53 { 53 {
54 //Encoding encoding = Util.UTF8; 54 //Encoding encoding = Util.UTF8;
diff --git a/OpenSim/Framework/ClientInfo.cs b/OpenSim/Framework/ClientInfo.cs
index 62acb70..9021315 100644
--- a/OpenSim/Framework/ClientInfo.cs
+++ b/OpenSim/Framework/ClientInfo.cs
@@ -33,12 +33,13 @@ namespace OpenSim.Framework
33{ 33{
34 public class ClientInfo 34 public class ClientInfo
35 { 35 {
36 public AgentCircuitData agentcircuit; 36 public readonly DateTime StartedTime = DateTime.Now;
37 public AgentCircuitData agentcircuit = null;
37 38
38 public Dictionary<uint, byte[]> needAck; 39 public Dictionary<uint, byte[]> needAck;
39 40
40 public List<byte[]> out_packets; 41 public List<byte[]> out_packets = new List<byte[]>();
41 public Dictionary<uint, uint> pendingAcks; 42 public Dictionary<uint, uint> pendingAcks = new Dictionary<uint,uint>();
42 public EndPoint proxyEP; 43 public EndPoint proxyEP;
43 44
44 public uint sequence; 45 public uint sequence;
@@ -53,5 +54,9 @@ namespace OpenSim.Framework
53 public int assetThrottle; 54 public int assetThrottle;
54 public int textureThrottle; 55 public int textureThrottle;
55 public int totalThrottle; 56 public int totalThrottle;
57
58 public Dictionary<string, int> SyncRequests = new Dictionary<string,int>();
59 public Dictionary<string, int> AsyncRequests = new Dictionary<string,int>();
60 public Dictionary<string, int> GenericRequests = new Dictionary<string,int>();
56 } 61 }
57} 62}
diff --git a/OpenSim/Framework/DAMap.cs b/OpenSim/Framework/DAMap.cs
index 5c729e8..4995a92 100644
--- a/OpenSim/Framework/DAMap.cs
+++ b/OpenSim/Framework/DAMap.cs
@@ -132,10 +132,6 @@ namespace OpenSim.Framework
132 { 132 {
133 List<string> keysToRemove = null; 133 List<string> keysToRemove = null;
134 134
135 // Hard-coded special case that needs to be removed in the future. Normally, modules themselves should
136 // handle reading data from old locations
137 bool osMaterialsMigrationRequired = false;
138
139 OSDMap namespacesMap = daMap.m_map; 135 OSDMap namespacesMap = daMap.m_map;
140 136
141 foreach (string key in namespacesMap.Keys) 137 foreach (string key in namespacesMap.Keys)
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index 80d1080..0fde42c 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -689,7 +689,7 @@ namespace OpenSim.Framework.Servers.HttpServer
689 689
690 if (buffer != null) 690 if (buffer != null)
691 { 691 {
692 if (!response.SendChunked) 692 if (!response.SendChunked && response.ContentLength64 <= 0)
693 response.ContentLength64 = buffer.LongLength; 693 response.ContentLength64 = buffer.LongLength;
694 694
695 response.OutputStream.Write(buffer, 0, buffer.Length); 695 response.OutputStream.Write(buffer, 0, buffer.Length);
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseOutputStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseOutputStreamHandler.cs
new file mode 100644
index 0000000..72b3065
--- /dev/null
+++ b/OpenSim/Framework/Servers/HttpServer/BaseOutputStreamHandler.cs
@@ -0,0 +1,60 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System.IO;
29
30namespace OpenSim.Framework.Servers.HttpServer
31{
32 /// <summary>
33 /// Base handler for writing to an output stream
34 /// </summary>
35 /// <remarks>
36 /// Inheriting classes should override ProcessRequest() rather than Handle()
37 /// </remarks>
38 public abstract class BaseOutputStreamHandler : BaseRequestHandler, IRequestHandler
39 {
40 protected BaseOutputStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {}
41
42 protected BaseOutputStreamHandler(string httpMethod, string path, string name, string description)
43 : base(httpMethod, path, name, description) {}
44
45 public virtual void Handle(
46 string path, Stream request, Stream response, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
47 {
48 RequestsReceived++;
49
50 ProcessRequest(path, request, response, httpRequest, httpResponse);
51
52 RequestsHandled++;
53 }
54
55 protected virtual void ProcessRequest(
56 string path, Stream request, Stream response, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
57 {
58 }
59 }
60} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs
index ae7aaf2..bbac699 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseRequestHandler.cs
@@ -31,6 +31,10 @@ namespace OpenSim.Framework.Servers.HttpServer
31{ 31{
32 public abstract class BaseRequestHandler 32 public abstract class BaseRequestHandler
33 { 33 {
34 public int RequestsReceived { get; protected set; }
35
36 public int RequestsHandled { get; protected set; }
37
34 public virtual string ContentType 38 public virtual string ContentType
35 { 39 {
36 get { return "application/xml"; } 40 get { return "application/xml"; }
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
index 6342983..252cc2a 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseStreamHandler.cs
@@ -29,14 +29,35 @@ using System.IO;
29 29
30namespace OpenSim.Framework.Servers.HttpServer 30namespace OpenSim.Framework.Servers.HttpServer
31{ 31{
32 /// <summary>
33 /// Base streamed request handler.
34 /// </summary>
35 /// <remarks>
36 /// Inheriting classes should override ProcessRequest() rather than Handle()
37 /// </remarks>
32 public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler 38 public abstract class BaseStreamHandler : BaseRequestHandler, IStreamedRequestHandler
33 { 39 {
34 public abstract byte[] Handle(string path, Stream request,
35 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse);
36
37 protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {} 40 protected BaseStreamHandler(string httpMethod, string path) : this(httpMethod, path, null, null) {}
38 41
39 protected BaseStreamHandler(string httpMethod, string path, string name, string description) 42 protected BaseStreamHandler(string httpMethod, string path, string name, string description)
40 : base(httpMethod, path, name, description) {} 43 : base(httpMethod, path, name, description) {}
44
45 public virtual byte[] Handle(
46 string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
47 {
48 RequestsReceived++;
49
50 byte[] result = ProcessRequest(path, request, httpRequest, httpResponse);
51
52 RequestsHandled++;
53
54 return result;
55 }
56
57 protected virtual byte[] ProcessRequest(
58 string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
59 {
60 return null;
61 }
41 } 62 }
42} \ No newline at end of file 63} \ No newline at end of file
diff --git a/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs
index b94bfb4..1b03f54 100644
--- a/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BinaryStreamHandler.cs
@@ -45,7 +45,7 @@ namespace OpenSim.Framework.Servers.HttpServer
45 m_method = binaryMethod; 45 m_method = binaryMethod;
46 } 46 }
47 47
48 public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 48 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
49 { 49 {
50 byte[] data = ReadFully(request); 50 byte[] data = ReadFully(request);
51 string param = GetParam(path); 51 string param = GetParam(path);
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs
index cb5cce5..b8541cb 100644
--- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IStreamHandler.cs
@@ -32,7 +32,6 @@ namespace OpenSim.Framework.Servers.HttpServer
32{ 32{
33 public interface IRequestHandler 33 public interface IRequestHandler
34 { 34 {
35
36 /// <summary> 35 /// <summary>
37 /// Name for this handler. 36 /// Name for this handler.
38 /// </summary> 37 /// </summary>
@@ -59,6 +58,19 @@ namespace OpenSim.Framework.Servers.HttpServer
59 58
60 // Return path 59 // Return path
61 string Path { get; } 60 string Path { get; }
61
62 /// <summary>
63 /// Number of requests received by this handler
64 /// </summary>
65 int RequestsReceived { get; }
66
67 /// <summary>
68 /// Number of requests handled.
69 /// </summary>
70 /// <remarks>
71 /// Should be equal to RequestsReceived unless requested are being handled slowly or there is deadlock.
72 /// </remarks>
73 int RequestsHandled { get; }
62 } 74 }
63 75
64 public interface IStreamedRequestHandler : IRequestHandler 76 public interface IStreamedRequestHandler : IRequestHandler
@@ -69,7 +81,6 @@ namespace OpenSim.Framework.Servers.HttpServer
69 81
70 public interface IStreamHandler : IRequestHandler 82 public interface IStreamHandler : IRequestHandler
71 { 83 {
72 // Handle request stream, return byte array
73 void Handle(string path, Stream request, Stream response, IOSHttpRequest httpReqbuest, IOSHttpResponse httpResponse); 84 void Handle(string path, Stream request, Stream response, IOSHttpRequest httpReqbuest, IOSHttpResponse httpResponse);
74 } 85 }
75 86
diff --git a/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs
index 07082a8..bd55657 100644
--- a/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/RestDeserialiseHandler.cs
@@ -33,7 +33,7 @@ namespace OpenSim.Framework.Servers.HttpServer
33{ 33{
34 public delegate TResponse RestDeserialiseMethod<TRequest, TResponse>(TRequest request); 34 public delegate TResponse RestDeserialiseMethod<TRequest, TResponse>(TRequest request);
35 35
36 public class RestDeserialiseHandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler 36 public class RestDeserialiseHandler<TRequest, TResponse> : BaseOutputStreamHandler, IStreamHandler
37 where TRequest : new() 37 where TRequest : new()
38 { 38 {
39 private RestDeserialiseMethod<TRequest, TResponse> m_method; 39 private RestDeserialiseMethod<TRequest, TResponse> m_method;
@@ -48,7 +48,7 @@ namespace OpenSim.Framework.Servers.HttpServer
48 m_method = method; 48 m_method = method;
49 } 49 }
50 50
51 public void Handle(string path, Stream request, Stream responseStream, 51 protected override void ProcessRequest(string path, Stream request, Stream responseStream,
52 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 52 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
53 { 53 {
54 TRequest deserial; 54 TRequest deserial;
diff --git a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs
index edcd134..83c9848 100644
--- a/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs
+++ b/OpenSim/Framework/Servers/HttpServer/RestSessionService.cs
@@ -183,7 +183,7 @@ namespace OpenSim.Framework.Servers.HttpServer
183 183
184 public delegate bool CheckIdentityMethod(string sid, string aid); 184 public delegate bool CheckIdentityMethod(string sid, string aid);
185 185
186 public class RestDeserialiseSecureHandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler 186 public class RestDeserialiseSecureHandler<TRequest, TResponse> : BaseOutputStreamHandler, IStreamHandler
187 where TRequest : new() 187 where TRequest : new()
188 { 188 {
189 private static readonly ILog m_log 189 private static readonly ILog m_log
@@ -201,7 +201,7 @@ namespace OpenSim.Framework.Servers.HttpServer
201 m_method = method; 201 m_method = method;
202 } 202 }
203 203
204 public void Handle(string path, Stream request, Stream responseStream, 204 protected override void ProcessRequest(string path, Stream request, Stream responseStream,
205 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 205 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
206 { 206 {
207 RestSessionObject<TRequest> deserial = default(RestSessionObject<TRequest>); 207 RestSessionObject<TRequest> deserial = default(RestSessionObject<TRequest>);
@@ -237,7 +237,7 @@ namespace OpenSim.Framework.Servers.HttpServer
237 237
238 public delegate bool CheckTrustedSourceMethod(IPEndPoint peer); 238 public delegate bool CheckTrustedSourceMethod(IPEndPoint peer);
239 239
240 public class RestDeserialiseTrustedHandler<TRequest, TResponse> : BaseRequestHandler, IStreamHandler 240 public class RestDeserialiseTrustedHandler<TRequest, TResponse> : BaseOutputStreamHandler, IStreamHandler
241 where TRequest : new() 241 where TRequest : new()
242 { 242 {
243 private static readonly ILog m_log 243 private static readonly ILog m_log
@@ -260,7 +260,7 @@ namespace OpenSim.Framework.Servers.HttpServer
260 m_method = method; 260 m_method = method;
261 } 261 }
262 262
263 public void Handle(string path, Stream request, Stream responseStream, 263 protected override void ProcessRequest(string path, Stream request, Stream responseStream,
264 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 264 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
265 { 265 {
266 TRequest deserial = default(TRequest); 266 TRequest deserial = default(TRequest);
@@ -292,6 +292,5 @@ namespace OpenSim.Framework.Servers.HttpServer
292 serializer.Serialize(xmlWriter, response); 292 serializer.Serialize(xmlWriter, response);
293 } 293 }
294 } 294 }
295 } 295 }
296 296} \ No newline at end of file
297}
diff --git a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs
index 1f17fee..0305dee 100644
--- a/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs
+++ b/OpenSim/Framework/Servers/HttpServer/RestStreamHandler.cs
@@ -48,7 +48,7 @@ namespace OpenSim.Framework.Servers.HttpServer
48 m_restMethod = restMethod; 48 m_restMethod = restMethod;
49 } 49 }
50 50
51 public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 51 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
52 { 52 {
53 Encoding encoding = Encoding.UTF8; 53 Encoding encoding = Encoding.UTF8;
54 StreamReader streamReader = new StreamReader(request, encoding); 54 StreamReader streamReader = new StreamReader(request, encoding);
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 7675be8..6c7af12 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -141,6 +141,11 @@ namespace OpenSim.Framework
141 public static FireAndForgetMethod DefaultFireAndForgetMethod = FireAndForgetMethod.SmartThreadPool; 141 public static FireAndForgetMethod DefaultFireAndForgetMethod = FireAndForgetMethod.SmartThreadPool;
142 public static FireAndForgetMethod FireAndForgetMethod = DefaultFireAndForgetMethod; 142 public static FireAndForgetMethod FireAndForgetMethod = DefaultFireAndForgetMethod;
143 143
144 public static bool IsPlatformMono
145 {
146 get { return Type.GetType("Mono.Runtime") != null; }
147 }
148
144 /// <summary> 149 /// <summary>
145 /// Gets the name of the directory where the current running executable 150 /// Gets the name of the directory where the current running executable
146 /// is located 151 /// is located
@@ -1338,7 +1343,7 @@ namespace OpenSim.Framework
1338 ru = "OSX/Mono"; 1343 ru = "OSX/Mono";
1339 else 1344 else
1340 { 1345 {
1341 if (Type.GetType("Mono.Runtime") != null) 1346 if (IsPlatformMono)
1342 ru = "Win/Mono"; 1347 ru = "Win/Mono";
1343 else 1348 else
1344 ru = "Win/.NET"; 1349 ru = "Win/.NET";
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs
index 11cacac..db76529 100644
--- a/OpenSim/Region/Application/OpenSimBase.cs
+++ b/OpenSim/Region/Application/OpenSimBase.cs
@@ -843,73 +843,49 @@ namespace OpenSim
843 /// <summary> 843 /// <summary>
844 /// Handler to supply the current status of this sim 844 /// Handler to supply the current status of this sim
845 /// </summary> 845 /// </summary>
846 /// <remarks>
846 /// Currently this is always OK if the simulator is still listening for connections on its HTTP service 847 /// Currently this is always OK if the simulator is still listening for connections on its HTTP service
847 public class SimStatusHandler : IStreamedRequestHandler 848 /// </remarks>
849 public class SimStatusHandler : BaseStreamHandler
848 { 850 {
849 public byte[] Handle(string path, Stream request, 851 public SimStatusHandler() : base("GET", "/simstatus", "SimStatus", "Simulator Status") {}
852
853 protected override byte[] ProcessRequest(string path, Stream request,
850 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 854 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
851 { 855 {
852 return Util.UTF8.GetBytes("OK"); 856 return Util.UTF8.GetBytes("OK");
853 } 857 }
854 858
855 public string Name { get { return "SimStatus"; } } 859 public override string ContentType
856 public string Description { get { return "Simulator Status"; } }
857
858 public string ContentType
859 { 860 {
860 get { return "text/plain"; } 861 get { return "text/plain"; }
861 } 862 }
862
863 public string HttpMethod
864 {
865 get { return "GET"; }
866 }
867
868 public string Path
869 {
870 get { return "/simstatus"; }
871 }
872 } 863 }
873 864
874 /// <summary> 865 /// <summary>
875 /// Handler to supply the current extended status of this sim 866 /// Handler to supply the current extended status of this sim
876 /// Sends the statistical data in a json serialization 867 /// Sends the statistical data in a json serialization
877 /// </summary> 868 /// </summary>
878 public class XSimStatusHandler : IStreamedRequestHandler 869 public class XSimStatusHandler : BaseStreamHandler
879 { 870 {
880 OpenSimBase m_opensim; 871 OpenSimBase m_opensim;
881 string osXStatsURI = String.Empty;
882
883 public string Name { get { return "XSimStatus"; } }
884 public string Description { get { return "Simulator XStatus"; } }
885 872
886 public XSimStatusHandler(OpenSimBase sim) 873 public XSimStatusHandler(OpenSimBase sim)
874 : base("GET", "/" + Util.SHA1Hash(sim.osSecret), "XSimStatus", "Simulator XStatus")
887 { 875 {
888 m_opensim = sim; 876 m_opensim = sim;
889 osXStatsURI = Util.SHA1Hash(sim.osSecret);
890 } 877 }
891 878
892 public byte[] Handle(string path, Stream request, 879 protected override byte[] ProcessRequest(string path, Stream request,
893 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 880 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
894 { 881 {
895 return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); 882 return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
896 } 883 }
897 884
898 public string ContentType 885 public override string ContentType
899 { 886 {
900 get { return "text/plain"; } 887 get { return "text/plain"; }
901 } 888 }
902
903 public string HttpMethod
904 {
905 get { return "GET"; }
906 }
907
908 public string Path
909 {
910 // This is for the OpenSimulator instance and is the osSecret hashed
911 get { return "/" + osXStatsURI; }
912 }
913 } 889 }
914 890
915 /// <summary> 891 /// <summary>
@@ -918,42 +894,26 @@ namespace OpenSim
918 /// If the request contains a key, "callback" the response will be wrappend in the 894 /// If the request contains a key, "callback" the response will be wrappend in the
919 /// associated value for jsonp used with ajax/javascript 895 /// associated value for jsonp used with ajax/javascript
920 /// </summary> 896 /// </summary>
921 public class UXSimStatusHandler : IStreamedRequestHandler 897 protected class UXSimStatusHandler : BaseStreamHandler
922 { 898 {
923 OpenSimBase m_opensim; 899 OpenSimBase m_opensim;
924 string osUXStatsURI = String.Empty;
925
926 public string Name { get { return "UXSimStatus"; } }
927 public string Description { get { return "Simulator UXStatus"; } }
928 900
929 public UXSimStatusHandler(OpenSimBase sim) 901 public UXSimStatusHandler(OpenSimBase sim)
902 : base("GET", "/" + sim.userStatsURI, "UXSimStatus", "Simulator UXStatus")
930 { 903 {
931 m_opensim = sim; 904 m_opensim = sim;
932 osUXStatsURI = sim.userStatsURI;
933
934 } 905 }
935 906
936 public byte[] Handle(string path, Stream request, 907 protected override byte[] ProcessRequest(string path, Stream request,
937 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 908 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
938 { 909 {
939 return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest)); 910 return Util.UTF8.GetBytes(m_opensim.StatReport(httpRequest));
940 } 911 }
941 912
942 public string ContentType 913 public override string ContentType
943 { 914 {
944 get { return "text/plain"; } 915 get { return "text/plain"; }
945 } 916 }
946
947 public string HttpMethod
948 {
949 get { return "GET"; }
950 }
951
952 public string Path
953 {
954 // This is for the OpenSimulator instance and is the user provided URI
955 get { return "/" + osUXStatsURI; }
956 }
957 } 917 }
958 918
959 #endregion 919 #endregion
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
index 8241e07..98ab433 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs
@@ -282,13 +282,19 @@ namespace OpenSim.Region.ClientStack.Linden
282 m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req); 282 m_HostCapsObj.RegisterHandler("UpdateNotecardAgentInventory", req);
283 m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req); 283 m_HostCapsObj.RegisterHandler("UpdateScriptAgentInventory", req);
284 m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req); 284 m_HostCapsObj.RegisterHandler("UpdateScriptAgent", req);
285 IRequestHandler getObjectPhysicsDataHandler = new RestStreamHandler("POST", capsBase + m_getObjectPhysicsDataPath, GetObjectPhysicsData); 285
286 IRequestHandler getObjectPhysicsDataHandler
287 = new RestStreamHandler(
288 "POST", capsBase + m_getObjectPhysicsDataPath, GetObjectPhysicsData, "GetObjectPhysicsData", null);
286 m_HostCapsObj.RegisterHandler("GetObjectPhysicsData", getObjectPhysicsDataHandler); 289 m_HostCapsObj.RegisterHandler("GetObjectPhysicsData", getObjectPhysicsDataHandler);
287 IRequestHandler getObjectCostHandler = new RestStreamHandler("POST", capsBase + m_getObjectCostPath, GetObjectCost); 290 IRequestHandler getObjectCostHandler = new RestStreamHandler("POST", capsBase + m_getObjectCostPath, GetObjectCost);
288 m_HostCapsObj.RegisterHandler("GetObjectCost", getObjectCostHandler); 291 m_HostCapsObj.RegisterHandler("GetObjectCost", getObjectCostHandler);
289 IRequestHandler ResourceCostSelectedHandler = new RestStreamHandler("POST", capsBase + m_ResourceCostSelectedPath, ResourceCostSelected); 292 IRequestHandler ResourceCostSelectedHandler = new RestStreamHandler("POST", capsBase + m_ResourceCostSelectedPath, ResourceCostSelected);
290 m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler); 293 m_HostCapsObj.RegisterHandler("ResourceCostSelected", ResourceCostSelectedHandler);
291 IRequestHandler UpdateAgentInformationHandler = new RestStreamHandler("POST", capsBase + m_UpdateAgentInformationPath, UpdateAgentInformation); 294
295 IRequestHandler UpdateAgentInformationHandler
296 = new RestStreamHandler(
297 "POST", capsBase + m_UpdateAgentInformationPath, UpdateAgentInformation, "UpdateAgentInformation", null);
292 m_HostCapsObj.RegisterHandler("UpdateAgentInformation", UpdateAgentInformationHandler); 298 m_HostCapsObj.RegisterHandler("UpdateAgentInformation", UpdateAgentInformationHandler);
293 299
294 m_HostCapsObj.RegisterHandler( 300 m_HostCapsObj.RegisterHandler(
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
index eb40eb1..d6689d4 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
@@ -366,7 +366,8 @@ namespace OpenSim.Region.ClientStack.Linden
366 // EventQueueGet when it receive capability information, but then we replace the rest handler immediately 366 // EventQueueGet when it receive capability information, but then we replace the rest handler immediately
367 // afterwards with the poll service. So for now, we'll pass a null instead to simplify code reading, but 367 // afterwards with the poll service. So for now, we'll pass a null instead to simplify code reading, but
368 // really it should be possible to directly register the poll handler as a capability. 368 // really it should be possible to directly register the poll handler as a capability.
369 caps.RegisterHandler("EventQueueGet", new RestHTTPHandler("POST", eventQueueGetPath, null)); 369 caps.RegisterHandler(
370 "EventQueueGet", new RestHTTPHandler("POST", eventQueueGetPath, null, "EventQueueGet", null));
370// delegate(Hashtable m_dhttpMethod) 371// delegate(Hashtable m_dhttpMethod)
371// { 372// {
372// return ProcessQueue(m_dhttpMethod, agentID, caps); 373// return ProcessQueue(m_dhttpMethod, agentID, caps);
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs
index 79d56c4..5196368 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/RegionConsoleModule.cs
@@ -183,7 +183,7 @@ namespace OpenSim.Region.ClientStack.Linden
183 m_isGod = m_scene.Permissions.IsGod(agentID); 183 m_isGod = m_scene.Permissions.IsGod(agentID);
184 } 184 }
185 185
186 public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 186 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
187 { 187 {
188 StreamReader reader = new StreamReader(request); 188 StreamReader reader = new StreamReader(request);
189 string message = reader.ReadToEnd(); 189 string message = reader.ReadToEnd();
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
index bba8ff1..27b09a6 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs
@@ -349,6 +349,8 @@ namespace OpenSim.Region.ClientStack.Linden
349 { 349 {
350 while (true) 350 while (true)
351 { 351 {
352 Watchdog.UpdateThread();
353
352 aPollRequest poolreq = m_queue.Dequeue(); 354 aPollRequest poolreq = m_queue.Dequeue();
353 355
354 poolreq.thepoll.Process(poolreq); 356 poolreq.thepoll.Process(poolreq);
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 45c901e..dfad485 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -710,12 +710,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
710 //there is a local handler for this packet type 710 //there is a local handler for this packet type
711 if (pprocessor.Async) 711 if (pprocessor.Async)
712 { 712 {
713 ClientInfo cinfo = UDPClient.GetClientInfo();
714 if (!cinfo.AsyncRequests.ContainsKey(packet.Type.ToString()))
715 cinfo.AsyncRequests[packet.Type.ToString()] = 0;
716 cinfo.AsyncRequests[packet.Type.ToString()]++;
717
713 object obj = new AsyncPacketProcess(this, pprocessor.method, packet); 718 object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
714 Util.FireAndForget(ProcessSpecificPacketAsync, obj); 719 Util.FireAndForget(ProcessSpecificPacketAsync, obj);
715 result = true; 720 result = true;
716 } 721 }
717 else 722 else
718 { 723 {
724 ClientInfo cinfo = UDPClient.GetClientInfo();
725 if (!cinfo.SyncRequests.ContainsKey(packet.Type.ToString()))
726 cinfo.SyncRequests[packet.Type.ToString()] = 0;
727 cinfo.SyncRequests[packet.Type.ToString()]++;
728
719 result = pprocessor.method(this, packet); 729 result = pprocessor.method(this, packet);
720 } 730 }
721 } 731 }
@@ -730,6 +740,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
730 } 740 }
731 if (found) 741 if (found)
732 { 742 {
743 ClientInfo cinfo = UDPClient.GetClientInfo();
744 if (!cinfo.GenericRequests.ContainsKey(packet.Type.ToString()))
745 cinfo.GenericRequests[packet.Type.ToString()] = 0;
746 cinfo.GenericRequests[packet.Type.ToString()]++;
747
733 result = method(this, packet); 748 result = method(this, packet);
734 } 749 }
735 } 750 }
@@ -5376,7 +5391,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5376 AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject); 5391 AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject);
5377 AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject); 5392 AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject);
5378 AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand); 5393 AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand);
5379 AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply); 5394 AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply, false);
5380 AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest); 5395 AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest);
5381 AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance); 5396 AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance);
5382 AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing); 5397 AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing);
@@ -5437,8 +5452,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5437 AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false); 5452 AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false);
5438 AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false); 5453 AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false);
5439 AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false); 5454 AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false);
5440 AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage); 5455 AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage, false);
5441 AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest); 5456 AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest, false);
5442 AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest); 5457 AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest);
5443 AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer); 5458 AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer);
5444 AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket); 5459 AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket);
@@ -5470,7 +5485,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5470 AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel); 5485 AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel);
5471 AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest); 5486 AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
5472 AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false); 5487 AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false);
5473 AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest); 5488 AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest, false);
5474 AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest); 5489 AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest);
5475 AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false); 5490 AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false);
5476 AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false); 5491 AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false);
@@ -7868,129 +7883,145 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7868 //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request"); 7883 //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
7869 7884
7870 TransferRequestPacket transfer = (TransferRequestPacket)Pack; 7885 TransferRequestPacket transfer = (TransferRequestPacket)Pack;
7871 //m_log.Debug("Transfer Request: " + transfer.ToString());
7872 // Validate inventory transfers
7873 // Has to be done here, because AssetCache can't do it
7874 //
7875 UUID taskID = UUID.Zero; 7886 UUID taskID = UUID.Zero;
7876 if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) 7887 if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
7877 { 7888 {
7878 taskID = new UUID(transfer.TransferInfo.Params, 48);
7879 UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
7880 UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
7881
7882// m_log.DebugFormat(
7883// "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
7884// requestID, itemID, taskID, Name);
7885
7886 if (!(((Scene)m_scene).Permissions.BypassPermissions())) 7889 if (!(((Scene)m_scene).Permissions.BypassPermissions()))
7887 { 7890 {
7888 if (taskID != UUID.Zero) // Prim 7891 // We're spawning a thread because the permissions check can block this thread
7892 Util.FireAndForget(delegate
7889 { 7893 {
7890 SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID); 7894 // This requests the asset if needed
7895 HandleSimInventoryTransferRequestWithPermsCheck(sender, transfer);
7896 });
7897 return true;
7898 }
7899 }
7900 else if (transfer.TransferInfo.SourceType == (int)SourceType.SimEstate)
7901 {
7902 //TransferRequestPacket does not include covenant uuid?
7903 //get scene covenant uuid
7904 taskID = m_scene.RegionInfo.RegionSettings.Covenant;
7905 }
7891 7906
7892 if (part == null) 7907 // This is non-blocking
7893 { 7908 MakeAssetRequest(transfer, taskID);
7894 m_log.WarnFormat(
7895 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
7896 Name, requestID, itemID, taskID);
7897 return true;
7898 }
7899 7909
7900 TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID); 7910 return true;
7901 if (tii == null) 7911 }
7902 {
7903 m_log.WarnFormat(
7904 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
7905 Name, requestID, itemID, taskID);
7906 return true;
7907 }
7908 7912
7909 if (tii.Type == (int)AssetType.LSLText) 7913 private void HandleSimInventoryTransferRequestWithPermsCheck(IClientAPI sender, TransferRequestPacket transfer)
7910 { 7914 {
7911 if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId)) 7915 UUID taskID = new UUID(transfer.TransferInfo.Params, 48);
7912 return true; 7916 UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
7913 } 7917 UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
7914 else if (tii.Type == (int)AssetType.Notecard)
7915 {
7916 if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
7917 return true;
7918 }
7919 else
7920 {
7921 // TODO: Change this code to allow items other than notecards and scripts to be successfully
7922 // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
7923 if (part.OwnerID != AgentId)
7924 {
7925 m_log.WarnFormat(
7926 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
7927 Name, requestID, itemID, taskID, part.OwnerID);
7928 return true;
7929 }
7930 7918
7931 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) 7919 //m_log.DebugFormat(
7932 { 7920 // "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
7933 m_log.WarnFormat( 7921 // requestID, itemID, taskID, Name);
7934 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
7935 Name, requestID, itemID, taskID);
7936 return true;
7937 }
7938 7922
7939 if (tii.OwnerID != AgentId) 7923 //m_log.Debug("Transfer Request: " + transfer.ToString());
7940 { 7924 // Validate inventory transfers
7941 m_log.WarnFormat( 7925 // Has to be done here, because AssetCache can't do it
7942 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}", 7926 //
7943 Name, requestID, itemID, taskID, tii.OwnerID); 7927 if (taskID != UUID.Zero) // Prim
7944 return true; 7928 {
7945 } 7929 SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID);
7946 7930
7947 if (( 7931 if (part == null)
7948 tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) 7932 {
7949 != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) 7933 m_log.WarnFormat(
7950 { 7934 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
7951 m_log.WarnFormat( 7935 Name, requestID, itemID, taskID);
7952 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer", 7936 return;
7953 Name, requestID, itemID, taskID); 7937 }
7954 return true;
7955 }
7956 7938
7957 if (tii.AssetID != requestID) 7939 TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID);
7958 { 7940 if (tii == null)
7959 m_log.WarnFormat( 7941 {
7960 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}", 7942 m_log.WarnFormat(
7961 Name, requestID, itemID, taskID, tii.AssetID); 7943 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
7962 return true; 7944 Name, requestID, itemID, taskID);
7963 } 7945 return;
7964 } 7946 }
7947
7948 if (tii.Type == (int)AssetType.LSLText)
7949 {
7950 if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId))
7951 return;
7952 }
7953 else if (tii.Type == (int)AssetType.Notecard)
7954 {
7955 if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
7956 return;
7957 }
7958 else
7959 {
7960 // TODO: Change this code to allow items other than notecards and scripts to be successfully
7961 // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
7962 if (part.OwnerID != AgentId)
7963 {
7964 m_log.WarnFormat(
7965 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
7966 Name, requestID, itemID, taskID, part.OwnerID);
7967 return;
7965 } 7968 }
7966 else // Agent 7969
7970 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
7967 { 7971 {
7968 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); 7972 m_log.WarnFormat(
7969 if (invAccess != null) 7973 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
7970 { 7974 Name, requestID, itemID, taskID);
7971 if (!invAccess.CanGetAgentInventoryItem(this, itemID, requestID)) 7975 return;
7972 return false; 7976 }
7973 } 7977
7974 else 7978 if (tii.OwnerID != AgentId)
7975 { 7979 {
7976 return false; 7980 m_log.WarnFormat(
7977 } 7981 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}",
7982 Name, requestID, itemID, taskID, tii.OwnerID);
7983 return;
7984 }
7985
7986 if ((
7987 tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
7988 != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
7989 {
7990 m_log.WarnFormat(
7991 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer",
7992 Name, requestID, itemID, taskID);
7993 return;
7994 }
7995
7996 if (tii.AssetID != requestID)
7997 {
7998 m_log.WarnFormat(
7999 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}",
8000 Name, requestID, itemID, taskID, tii.AssetID);
8001 return;
7978 } 8002 }
7979 } 8003 }
7980 } 8004 }
7981 else 8005 else // Agent
7982 if (transfer.TransferInfo.SourceType == (int)SourceType.SimEstate) 8006 {
8007 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
8008 if (invAccess != null)
8009 {
8010 if (!invAccess.CanGetAgentInventoryItem(this, itemID, requestID))
8011 return;
8012 }
8013 else
7983 { 8014 {
7984 //TransferRequestPacket does not include covenant uuid? 8015 return;
7985 //get scene covenant uuid
7986 taskID = m_scene.RegionInfo.RegionSettings.Covenant;
7987 } 8016 }
8017 }
7988 8018
8019 // Permissions out of the way, let's request the asset
7989 MakeAssetRequest(transfer, taskID); 8020 MakeAssetRequest(transfer, taskID);
7990 8021
7991 return true;
7992 } 8022 }
7993 8023
8024
7994 private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack) 8025 private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack)
7995 { 8026 {
7996 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; 8027 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
@@ -12378,7 +12409,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12378 ClientInfo info = m_udpClient.GetClientInfo(); 12409 ClientInfo info = m_udpClient.GetClientInfo();
12379 12410
12380 info.proxyEP = null; 12411 info.proxyEP = null;
12381 info.agentcircuit = RequestClientInfo(); 12412 if (info.agentcircuit == null)
12413 info.agentcircuit = RequestClientInfo();
12382 12414
12383 return info; 12415 return info;
12384 } 12416 }
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
index e52ac37..f7ed14d 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPClient.cs
@@ -160,6 +160,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
160 private int m_maxRTO = 60000; 160 private int m_maxRTO = 60000;
161 public bool m_deliverPackets = true; 161 public bool m_deliverPackets = true;
162 162
163 private ClientInfo m_info = new ClientInfo();
164
163 /// <summary> 165 /// <summary>
164 /// Default constructor 166 /// Default constructor
165 /// </summary> 167 /// </summary>
@@ -241,20 +243,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
241 // TODO: This data structure is wrong in so many ways. Locking and copying the entire lists 243 // TODO: This data structure is wrong in so many ways. Locking and copying the entire lists
242 // of pending and needed ACKs for every client every time some method wants information about 244 // of pending and needed ACKs for every client every time some method wants information about
243 // this connection is a recipe for poor performance 245 // this connection is a recipe for poor performance
244 ClientInfo info = new ClientInfo(); 246
245 info.pendingAcks = new Dictionary<uint, uint>(); 247 m_info.resendThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Resend].DripRate;
246 info.needAck = new Dictionary<uint, byte[]>(); 248 m_info.landThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Land].DripRate;
247 249 m_info.windThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Wind].DripRate;
248 info.resendThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Resend].DripRate; 250 m_info.cloudThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Cloud].DripRate;
249 info.landThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Land].DripRate; 251 m_info.taskThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Task].DripRate;
250 info.windThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Wind].DripRate; 252 m_info.assetThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Asset].DripRate;
251 info.cloudThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Cloud].DripRate; 253 m_info.textureThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Texture].DripRate;
252 info.taskThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Task].DripRate; 254 m_info.totalThrottle = (int)m_throttleCategory.DripRate;
253 info.assetThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Asset].DripRate; 255
254 info.textureThrottle = (int)m_throttleCategories[(int)ThrottleOutPacketType.Texture].DripRate; 256 return m_info;
255 info.totalThrottle = (int)m_throttleCategory.DripRate;
256
257 return info;
258 } 257 }
259 258
260 /// <summary> 259 /// <summary>
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 7f14371..8a1f267 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -1686,6 +1686,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1686 { 1686 {
1687 IncomingPacket incomingPacket = null; 1687 IncomingPacket incomingPacket = null;
1688 1688
1689 /*
1689 // HACK: This is a test to try and rate limit packet handling on Mono. 1690 // HACK: This is a test to try and rate limit packet handling on Mono.
1690 // If it works, a more elegant solution can be devised 1691 // If it works, a more elegant solution can be devised
1691 if (Util.FireAndForgetCount() < 2) 1692 if (Util.FireAndForgetCount() < 2)
@@ -1693,6 +1694,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1693 //m_log.Debug("[LLUDPSERVER]: Incoming packet handler is sleeping"); 1694 //m_log.Debug("[LLUDPSERVER]: Incoming packet handler is sleeping");
1694 Thread.Sleep(30); 1695 Thread.Sleep(30);
1695 } 1696 }
1697 */
1696 1698
1697 if (packetInbox.Dequeue(100, ref incomingPacket)) 1699 if (packetInbox.Dequeue(100, ref incomingPacket))
1698 { 1700 {
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs
index a0e0078..83144e3 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs
@@ -73,7 +73,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
73 } 73 }
74 74
75 [SetUp] 75 [SetUp]
76 public void SetUp() 76 public override void SetUp()
77 { 77 {
78 base.SetUp(); 78 base.SetUp();
79 79
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
index 6d4c65d..b693f2d 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs
@@ -498,7 +498,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
498 498
499 protected virtual void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online) 499 protected virtual void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online)
500 { 500 {
501 m_log.DebugFormat("[FRIENDS]: Entering StatusNotify for {0}", userID); 501 //m_log.DebugFormat("[FRIENDS]: Entering StatusNotify for {0}", userID);
502 502
503 List<string> friendStringIds = friendList.ConvertAll<string>(friend => friend.Friend); 503 List<string> friendStringIds = friendList.ConvertAll<string>(friend => friend.Friend);
504 List<string> remoteFriendStringIds = new List<string>(); 504 List<string> remoteFriendStringIds = new List<string>();
@@ -527,15 +527,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
527 // let's guard against sessions-gone-bad 527 // let's guard against sessions-gone-bad
528 if (friendSession != null && friendSession.RegionID != UUID.Zero) 528 if (friendSession != null && friendSession.RegionID != UUID.Zero)
529 { 529 {
530 m_log.DebugFormat("[FRIENDS]: Get region {0}", friendSession.RegionID); 530 //m_log.DebugFormat("[FRIENDS]: Get region {0}", friendSession.RegionID);
531 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID); 531 GridRegion region = GridService.GetRegionByUUID(m_Scenes[0].RegionInfo.ScopeID, friendSession.RegionID);
532 if (region != null) 532 if (region != null)
533 { 533 {
534 m_FriendsSimConnector.StatusNotify(region, userID, friendSession.UserID, online); 534 m_FriendsSimConnector.StatusNotify(region, userID, friendSession.UserID, online);
535 } 535 }
536 } 536 }
537 else 537 //else
538 m_log.DebugFormat("[FRIENDS]: friend session is null or the region is UUID.Zero"); 538 // m_log.DebugFormat("[FRIENDS]: friend session is null or the region is UUID.Zero");
539 } 539 }
540 } 540 }
541 541
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
index 08196f1..2116605 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsRequestHandler.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
54 m_FriendsModule = fmodule; 54 m_FriendsModule = fmodule;
55 } 55 }
56 56
57 public override byte[] Handle( 57 protected override byte[] ProcessRequest(
58 string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 58 string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
59 { 59 {
60 StreamReader sr = new StreamReader(requestData); 60 StreamReader sr = new StreamReader(requestData);
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
index a456009..d00945e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs
@@ -252,7 +252,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
252 252
253 protected override void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online) 253 protected override void StatusNotify(List<FriendInfo> friendList, UUID userID, bool online)
254 { 254 {
255 m_log.DebugFormat("[HGFRIENDS MODULE]: Entering StatusNotify for {0}", userID); 255 //m_log.DebugFormat("[HGFRIENDS MODULE]: Entering StatusNotify for {0}", userID);
256 256
257 // First, let's divide the friends on a per-domain basis 257 // First, let's divide the friends on a per-domain basis
258 Dictionary<string, List<FriendInfo>> friendsPerDomain = new Dictionary<string, List<FriendInfo>>(); 258 Dictionary<string, List<FriendInfo>> friendsPerDomain = new Dictionary<string, List<FriendInfo>>();
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
index 5b12ecb..6b14fa6 100644
--- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs
@@ -125,9 +125,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods
125 { 125 {
126 string uri = "/CAPS/" + UUID.Random(); 126 string uri = "/CAPS/" + UUID.Random();
127 127
128 caps.RegisterHandler("UntrustedSimulatorMessage", 128 caps.RegisterHandler(
129 new RestStreamHandler("POST", uri, 129 "UntrustedSimulatorMessage",
130 HandleUntrustedSimulatorMessage)); 130 new RestStreamHandler("POST", uri, HandleUntrustedSimulatorMessage, "UntrustedSimulatorMessage", null));
131 } 131 }
132 132
133 private string HandleUntrustedSimulatorMessage(string request, 133 private string HandleUntrustedSimulatorMessage(string request,
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
index 659b178..d56e469 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs
@@ -67,10 +67,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
67 /// </summary> 67 /// </summary>
68 protected bool m_merge; 68 protected bool m_merge;
69 69
70 /// <value> 70 protected IInventoryService m_InventoryService;
71 /// We only use this to request modules 71 protected IAssetService m_AssetService;
72 /// </value> 72 protected IUserAccountService m_UserAccountService;
73 protected Scene m_scene;
74 73
75 /// <value> 74 /// <value>
76 /// The stream from which the inventory archive will be loaded. 75 /// The stream from which the inventory archive will be loaded.
@@ -118,9 +117,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
118 protected Dictionary<UUID, UUID> m_creatorIdForAssetId = new Dictionary<UUID, UUID>(); 117 protected Dictionary<UUID, UUID> m_creatorIdForAssetId = new Dictionary<UUID, UUID>();
119 118
120 public InventoryArchiveReadRequest( 119 public InventoryArchiveReadRequest(
121 Scene scene, UserAccount userInfo, string invPath, string loadPath, bool merge) 120 IInventoryService inv, IAssetService assets, IUserAccountService uacc, UserAccount userInfo, string invPath, string loadPath, bool merge)
122 : this( 121 : this(
123 scene, 122 inv,
123 assets,
124 uacc,
124 userInfo, 125 userInfo,
125 invPath, 126 invPath,
126 new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress), 127 new GZipStream(ArchiveHelpers.GetStream(loadPath), CompressionMode.Decompress),
@@ -129,9 +130,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
129 } 130 }
130 131
131 public InventoryArchiveReadRequest( 132 public InventoryArchiveReadRequest(
132 Scene scene, UserAccount userInfo, string invPath, Stream loadStream, bool merge) 133 IInventoryService inv, IAssetService assets, IUserAccountService uacc, UserAccount userInfo, string invPath, Stream loadStream, bool merge)
133 { 134 {
134 m_scene = scene; 135 m_InventoryService = inv;
136 m_AssetService = assets;
137 m_UserAccountService = uacc;
135 m_merge = merge; 138 m_merge = merge;
136 m_userInfo = userInfo; 139 m_userInfo = userInfo;
137 m_invPath = invPath; 140 m_invPath = invPath;
@@ -162,7 +165,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
162 165
163 List<InventoryFolderBase> folderCandidates 166 List<InventoryFolderBase> folderCandidates
164 = InventoryArchiveUtils.FindFoldersByPath( 167 = InventoryArchiveUtils.FindFoldersByPath(
165 m_scene.InventoryService, m_userInfo.PrincipalID, m_invPath); 168 m_InventoryService, m_userInfo.PrincipalID, m_invPath);
166 169
167 if (folderCandidates.Count == 0) 170 if (folderCandidates.Count == 0)
168 { 171 {
@@ -297,7 +300,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
297 string plainPath = ArchiveConstants.ExtractPlainPathFromIarPath(archivePath); 300 string plainPath = ArchiveConstants.ExtractPlainPathFromIarPath(archivePath);
298 List<InventoryFolderBase> folderCandidates 301 List<InventoryFolderBase> folderCandidates
299 = InventoryArchiveUtils.FindFoldersByPath( 302 = InventoryArchiveUtils.FindFoldersByPath(
300 m_scene.InventoryService, m_userInfo.PrincipalID, plainPath); 303 m_InventoryService, m_userInfo.PrincipalID, plainPath);
301 304
302 if (folderCandidates.Count != 0) 305 if (folderCandidates.Count != 0)
303 { 306 {
@@ -380,7 +383,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
380 = new InventoryFolderBase( 383 = new InventoryFolderBase(
381 newFolderId, newFolderName, m_userInfo.PrincipalID, 384 newFolderId, newFolderName, m_userInfo.PrincipalID,
382 (short)AssetType.Unknown, destFolder.ID, 1); 385 (short)AssetType.Unknown, destFolder.ID, 1);
383 m_scene.InventoryService.AddFolder(destFolder); 386 m_InventoryService.AddFolder(destFolder);
384 387
385 // Record that we have now created this folder 388 // Record that we have now created this folder
386 iarPathExisting += rawDirsToCreate[i] + "/"; 389 iarPathExisting += rawDirsToCreate[i] + "/";
@@ -406,7 +409,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
406 // Don't use the item ID that's in the file 409 // Don't use the item ID that's in the file
407 item.ID = UUID.Random(); 410 item.ID = UUID.Random();
408 411
409 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.UserAccountService); 412 UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_UserAccountService);
410 if (UUID.Zero != ospResolvedId) // The user exists in this grid 413 if (UUID.Zero != ospResolvedId) // The user exists in this grid
411 { 414 {
412// m_log.DebugFormat("[INVENTORY ARCHIVER]: Found creator {0} via OSPA resolution", ospResolvedId); 415// m_log.DebugFormat("[INVENTORY ARCHIVER]: Found creator {0} via OSPA resolution", ospResolvedId);
@@ -436,7 +439,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
436 // relying on native tar tools. 439 // relying on native tar tools.
437 m_creatorIdForAssetId[item.AssetID] = item.CreatorIdAsUuid; 440 m_creatorIdForAssetId[item.AssetID] = item.CreatorIdAsUuid;
438 441
439 m_scene.AddInventoryItem(item); 442 if (!m_InventoryService.AddItem(item))
443 m_log.WarnFormat("[INVENTORY ARCHIVER]: Unable to save item {0} in folder {1}", item.Name, item.Folder);
440 444
441 return item; 445 return item;
442 } 446 }
@@ -533,7 +537,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
533 AssetBase asset = new AssetBase(assetId, "From IAR", assetType, UUID.Zero.ToString()); 537 AssetBase asset = new AssetBase(assetId, "From IAR", assetType, UUID.Zero.ToString());
534 asset.Data = data; 538 asset.Data = data;
535 539
536 m_scene.AssetService.Store(asset); 540 m_AssetService.Store(asset);
537 541
538 return true; 542 return true;
539 } 543 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
index f4f9e2d..cef6177 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs
@@ -294,7 +294,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
294 294
295 try 295 try
296 { 296 {
297 request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadStream, merge); 297 request = new InventoryArchiveReadRequest(m_aScene.InventoryService, m_aScene.AssetService, m_aScene.UserAccountService, userInfo, invPath, loadStream, merge);
298 } 298 }
299 catch (EntryPointNotFoundException e) 299 catch (EntryPointNotFoundException e)
300 { 300 {
@@ -342,7 +342,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
342 342
343 try 343 try
344 { 344 {
345 request = new InventoryArchiveReadRequest(m_aScene, userInfo, invPath, loadPath, merge); 345 request = new InventoryArchiveReadRequest(m_aScene.InventoryService, m_aScene.AssetService, m_aScene.UserAccountService, userInfo, invPath, loadPath, merge);
346 } 346 }
347 catch (EntryPointNotFoundException e) 347 catch (EntryPointNotFoundException e)
348 { 348 {
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadPathTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadPathTests.cs
index 95f562e..08f199a 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadPathTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveLoadPathTests.cs
@@ -229,7 +229,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
229 229
230 { 230 {
231 // Test replication of path1 231 // Test replication of path1
232 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) 232 new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false)
233 .ReplicateArchivePathToUserInventory( 233 .ReplicateArchivePathToUserInventory(
234 iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID), 234 iarPath1, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
235 foldersCreated, nodesLoaded); 235 foldersCreated, nodesLoaded);
@@ -246,7 +246,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
246 246
247 { 247 {
248 // Test replication of path2 248 // Test replication of path2
249 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) 249 new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false)
250 .ReplicateArchivePathToUserInventory( 250 .ReplicateArchivePathToUserInventory(
251 iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID), 251 iarPath2, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
252 foldersCreated, nodesLoaded); 252 foldersCreated, nodesLoaded);
@@ -291,8 +291,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
291 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); 291 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
292 292
293 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); 293 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
294 294
295 new InventoryArchiveReadRequest(scene, ua1, null, (Stream)null, false) 295 new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, null, (Stream)null, false)
296 .ReplicateArchivePathToUserInventory( 296 .ReplicateArchivePathToUserInventory(
297 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), 297 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
298 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>()); 298 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
@@ -342,8 +342,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
342 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random()); 342 string folder2ArchiveName = InventoryArchiveWriteRequest.CreateArchiveFolderName(folder2Name, UUID.Random());
343 343
344 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName }); 344 string itemArchivePath = string.Join("", new string[] { folder1ArchiveName, folder2ArchiveName });
345 345
346 new InventoryArchiveReadRequest(scene, ua1, folder1ExistingName, (Stream)null, true) 346 new InventoryArchiveReadRequest(scene.InventoryService, scene.AssetService, scene.UserAccountService, ua1, folder1ExistingName, (Stream)null, true)
347 .ReplicateArchivePathToUserInventory( 347 .ReplicateArchivePathToUserInventory(
348 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID), 348 itemArchivePath, scene.InventoryService.GetRootFolder(ua1.PrincipalID),
349 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>()); 349 new Dictionary<string, InventoryFolderBase>(), new HashSet<InventoryNodeBase>());
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveSaveTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveSaveTests.cs
index 5e7e24c..b85739e 100644
--- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveSaveTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveSaveTests.cs
@@ -86,7 +86,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
86 Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH)); 86 Assert.That(filePath, Is.EqualTo(ArchiveConstants.CONTROL_FILE_PATH));
87 87
88 InventoryArchiveReadRequest iarr 88 InventoryArchiveReadRequest iarr
89 = new InventoryArchiveReadRequest(null, null, null, (Stream)null, false); 89 = new InventoryArchiveReadRequest(null, null, null, null, null, (Stream)null, false);
90 iarr.LoadControlFile(filePath, data); 90 iarr.LoadControlFile(filePath, data);
91 91
92 Assert.That(iarr.ControlFileLoaded, Is.True); 92 Assert.That(iarr.ControlFileLoaded, Is.True);
diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
index 161f160..c04098c 100644
--- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs
@@ -173,7 +173,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
173 if(obj.PresenceType == PresenceType.Npc) 173 if(obj.PresenceType == PresenceType.Npc)
174 return; 174 return;
175 175
176 GetImageAssets(((IScenePresence)obj).UUID); 176 Util.FireAndForget(delegate
177 {
178 GetImageAssets(((IScenePresence)obj).UUID);
179 });
177 } 180 }
178 181
179 /// <summary> 182 /// <summary>
@@ -1044,12 +1047,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
1044 { 1047 {
1045 OSDString assetId = (OSDString)asset; 1048 OSDString assetId = (OSDString)asset;
1046 1049
1047 Scene.AssetService.Get(string.Format("{0}/{1}",assetServerURI, assetId.AsString()), this, 1050 Scene.AssetService.Get(string.Format("{0}/{1}",assetServerURI, assetId.AsString()));
1048 delegate (string assetID, Object s, AssetBase a)
1049 {
1050 // m_log.DebugFormat("[PROFILES]: Getting Image Assets {0}", assetID);
1051 return;
1052 });
1053 } 1051 }
1054 return true; 1052 return true;
1055 } 1053 }
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
index fff86d5..2fc3b1c 100644
--- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs
@@ -28,6 +28,7 @@
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Linq;
31using System.Reflection; 32using System.Reflection;
32using System.Text; 33using System.Text;
33using log4net; 34using log4net;
@@ -37,6 +38,7 @@ using OpenMetaverse;
37using OpenSim.Framework; 38using OpenSim.Framework;
38using OpenSim.Framework.Console; 39using OpenSim.Framework.Console;
39using OpenSim.Framework.Servers; 40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer;
40using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 43using OpenSim.Region.Framework.Scenes;
42using Caps=OpenSim.Framework.Capabilities.Caps; 44using Caps=OpenSim.Framework.Capabilities.Caps;
@@ -57,8 +59,9 @@ namespace OpenSim.Region.CoreModules.Framework
57 /// </summary> 59 /// </summary>
58 protected Dictionary<uint, Caps> m_capsObjects = new Dictionary<uint, Caps>(); 60 protected Dictionary<uint, Caps> m_capsObjects = new Dictionary<uint, Caps>();
59 61
60 protected Dictionary<UUID, string> capsPaths = new Dictionary<UUID, string>(); 62 protected Dictionary<UUID, string> m_capsPaths = new Dictionary<UUID, string>();
61 protected Dictionary<UUID, Dictionary<ulong, string>> childrenSeeds 63
64 protected Dictionary<UUID, Dictionary<ulong, string>> m_childrenSeeds
62 = new Dictionary<UUID, Dictionary<ulong, string>>(); 65 = new Dictionary<UUID, Dictionary<ulong, string>>();
63 66
64 public void Initialise(IConfigSource source) 67 public void Initialise(IConfigSource source)
@@ -70,9 +73,24 @@ namespace OpenSim.Region.CoreModules.Framework
70 m_scene = scene; 73 m_scene = scene;
71 m_scene.RegisterModuleInterface<ICapabilitiesModule>(this); 74 m_scene.RegisterModuleInterface<ICapabilitiesModule>(this);
72 75
73 MainConsole.Instance.Commands.AddCommand("Comms", false, "show caps", 76 MainConsole.Instance.Commands.AddCommand(
74 "show caps", 77 "Comms", false, "show caps list",
75 "Shows all registered capabilities for users", HandleShowCapsCommand); 78 "show caps list",
79 "Shows list of registered capabilities for users.", HandleShowCapsListCommand);
80
81 MainConsole.Instance.Commands.AddCommand(
82 "Comms", false, "show caps stats by user",
83 "show caps stats [<first-name> <last-name>]",
84 "Shows statistics on capabilities use by user.",
85 "If a user name is given, then prints a detailed breakdown of caps use ordered by number of requests received.",
86 HandleShowCapsStatsByUserCommand);
87
88 MainConsole.Instance.Commands.AddCommand(
89 "Comms", false, "show caps stats by cap",
90 "show caps stats by cap [<cap-name>]",
91 "Shows statistics on capabilities use by capability.",
92 "If a capability name is given, then prints a detailed breakdown of use by each user.",
93 HandleShowCapsStatsByCapCommand);
76 } 94 }
77 95
78 public void RegionLoaded(Scene scene) 96 public void RegionLoaded(Scene scene)
@@ -106,6 +124,7 @@ namespace OpenSim.Region.CoreModules.Framework
106 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags)) 124 if (m_scene.RegionInfo.EstateSettings.IsBanned(agentId, flags))
107 return; 125 return;
108 126
127 Caps caps;
109 String capsObjectPath = GetCapsPath(agentId); 128 String capsObjectPath = GetCapsPath(agentId);
110 129
111 if (m_capsObjects.ContainsKey(circuitCode)) 130 if (m_capsObjects.ContainsKey(circuitCode))
@@ -121,7 +140,7 @@ namespace OpenSim.Region.CoreModules.Framework
121 //return; 140 //return;
122 } 141 }
123 142
124 Caps caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName, 143 caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName,
125 (MainServer.Instance == null) ? 0: MainServer.Instance.Port, 144 (MainServer.Instance == null) ? 0: MainServer.Instance.Port,
126 capsObjectPath, agentId, m_scene.RegionInfo.RegionName); 145 capsObjectPath, agentId, m_scene.RegionInfo.RegionName);
127 146
@@ -132,9 +151,12 @@ namespace OpenSim.Region.CoreModules.Framework
132 151
133 public void RemoveCaps(UUID agentId, uint circuitCode) 152 public void RemoveCaps(UUID agentId, uint circuitCode)
134 { 153 {
135 if (childrenSeeds.ContainsKey(agentId)) 154 lock (m_childrenSeeds)
136 { 155 {
137 childrenSeeds.Remove(agentId); 156 if (m_childrenSeeds.ContainsKey(agentId))
157 {
158 m_childrenSeeds.Remove(agentId);
159 }
138 } 160 }
139 161
140 lock (m_capsObjects) 162 lock (m_capsObjects)
@@ -180,16 +202,22 @@ namespace OpenSim.Region.CoreModules.Framework
180 202
181 public void SetAgentCapsSeeds(AgentCircuitData agent) 203 public void SetAgentCapsSeeds(AgentCircuitData agent)
182 { 204 {
183 capsPaths[agent.AgentID] = agent.CapsPath; 205 lock (m_capsPaths)
184 childrenSeeds[agent.AgentID] 206 m_capsPaths[agent.AgentID] = agent.CapsPath;
185 = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds); 207
208 lock (m_childrenSeeds)
209 m_childrenSeeds[agent.AgentID]
210 = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds);
186 } 211 }
187 212
188 public string GetCapsPath(UUID agentId) 213 public string GetCapsPath(UUID agentId)
189 { 214 {
190 if (capsPaths.ContainsKey(agentId)) 215 lock (m_capsPaths)
191 { 216 {
192 return capsPaths[agentId]; 217 if (m_capsPaths.ContainsKey(agentId))
218 {
219 return m_capsPaths[agentId];
220 }
193 } 221 }
194 222
195 return null; 223 return null;
@@ -198,17 +226,24 @@ namespace OpenSim.Region.CoreModules.Framework
198 public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID) 226 public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID)
199 { 227 {
200 Dictionary<ulong, string> seeds = null; 228 Dictionary<ulong, string> seeds = null;
201 if (childrenSeeds.TryGetValue(agentID, out seeds)) 229
202 return seeds; 230 lock (m_childrenSeeds)
231 if (m_childrenSeeds.TryGetValue(agentID, out seeds))
232 return seeds;
233
203 return new Dictionary<ulong, string>(); 234 return new Dictionary<ulong, string>();
204 } 235 }
205 236
206 public void DropChildSeed(UUID agentID, ulong handle) 237 public void DropChildSeed(UUID agentID, ulong handle)
207 { 238 {
208 Dictionary<ulong, string> seeds; 239 Dictionary<ulong, string> seeds;
209 if (childrenSeeds.TryGetValue(agentID, out seeds)) 240
241 lock (m_childrenSeeds)
210 { 242 {
211 seeds.Remove(handle); 243 if (m_childrenSeeds.TryGetValue(agentID, out seeds))
244 {
245 seeds.Remove(handle);
246 }
212 } 247 }
213 } 248 }
214 249
@@ -216,53 +251,283 @@ namespace OpenSim.Region.CoreModules.Framework
216 { 251 {
217 Dictionary<ulong, string> seeds; 252 Dictionary<ulong, string> seeds;
218 string returnval; 253 string returnval;
219 if (childrenSeeds.TryGetValue(agentID, out seeds)) 254
255 lock (m_childrenSeeds)
220 { 256 {
221 if (seeds.TryGetValue(handle, out returnval)) 257 if (m_childrenSeeds.TryGetValue(agentID, out seeds))
222 return returnval; 258 {
259 if (seeds.TryGetValue(handle, out returnval))
260 return returnval;
261 }
223 } 262 }
263
224 return null; 264 return null;
225 } 265 }
226 266
227 public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds) 267 public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds)
228 { 268 {
229 //m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count); 269 //m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count);
230 childrenSeeds[agentID] = seeds; 270
271 lock (m_childrenSeeds)
272 m_childrenSeeds[agentID] = seeds;
231 } 273 }
232 274
233 public void DumpChildrenSeeds(UUID agentID) 275 public void DumpChildrenSeeds(UUID agentID)
234 { 276 {
235 m_log.Info("================ ChildrenSeed "+m_scene.RegionInfo.RegionName+" ================"); 277 m_log.Info("================ ChildrenSeed "+m_scene.RegionInfo.RegionName+" ================");
236 foreach (KeyValuePair<ulong, string> kvp in childrenSeeds[agentID]) 278
279 lock (m_childrenSeeds)
237 { 280 {
238 uint x, y; 281 foreach (KeyValuePair<ulong, string> kvp in m_childrenSeeds[agentID])
239 Utils.LongToUInts(kvp.Key, out x, out y); 282 {
240 x = x / Constants.RegionSize; 283 uint x, y;
241 y = y / Constants.RegionSize; 284 Utils.LongToUInts(kvp.Key, out x, out y);
242 m_log.Info(" >> "+x+", "+y+": "+kvp.Value); 285 x = x / Constants.RegionSize;
286 y = y / Constants.RegionSize;
287 m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
288 }
243 } 289 }
244 } 290 }
245 291
246 private void HandleShowCapsCommand(string module, string[] cmdparams) 292 private void HandleShowCapsListCommand(string module, string[] cmdParams)
247 { 293 {
294 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
295 return;
296
248 StringBuilder caps = new StringBuilder(); 297 StringBuilder caps = new StringBuilder();
249 caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); 298 caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName);
250 299
251 foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects) 300 lock (m_capsObjects)
252 { 301 {
253 caps.AppendFormat("** Circuit {0}:\n", kvp.Key); 302 foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects)
303 {
304 caps.AppendFormat("** User {0}:\n", kvp.Key);
254 305
255 for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) 306 for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); )
307 {
308 Uri uri = new Uri(kvp2.Value.ToString());
309 caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery);
310 }
311
312 foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers)
313 caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value);
314 }
315 }
316
317 MainConsole.Instance.Output(caps.ToString());
318 }
319
320 private void HandleShowCapsStatsByCapCommand(string module, string[] cmdParams)
321 {
322 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
323 return;
324
325 if (cmdParams.Length != 5 && cmdParams.Length != 6)
326 {
327 MainConsole.Instance.Output("Usage: show caps stats by cap [<cap-name>]");
328 return;
329 }
330
331 StringBuilder sb = new StringBuilder();
332 sb.AppendFormat("Region {0}:\n", m_scene.Name);
333
334 if (cmdParams.Length == 5)
335 {
336 BuildSummaryStatsByCapReport(sb);
337 }
338 else if (cmdParams.Length == 6)
339 {
340 BuildDetailedStatsByCapReport(sb, cmdParams[5]);
341 }
342
343 MainConsole.Instance.Output(sb.ToString());
344 }
345
346 private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName)
347 {
348 /*
349 sb.AppendFormat("Capability name {0}\n", capName);
350
351 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
352 cdt.AddColumn("User Name", 34);
353 cdt.AddColumn("Req Received", 12);
354 cdt.AddColumn("Req Handled", 12);
355 cdt.Indent = 2;
356
357 Dictionary<string, int> receivedStats = new Dictionary<string, int>();
358 Dictionary<string, int> handledStats = new Dictionary<string, int>();
359
360 m_scene.ForEachScenePresence(
361 sp =>
256 { 362 {
257 Uri uri = new Uri(kvp2.Value.ToString()); 363 Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
258 caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); 364
365 if (caps == null)
366 return;
367
368 Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
369
370 IRequestHandler reqHandler;
371 if (capsHandlers.TryGetValue(capName, out reqHandler))
372 {
373 receivedStats[sp.Name] = reqHandler.RequestsReceived;
374 handledStats[sp.Name] = reqHandler.RequestsHandled;
375 }
259 } 376 }
377 );
260 378
261 foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers) 379 foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value))
262 caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value); 380 {
381 cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]);
263 } 382 }
264 383
265 MainConsole.Instance.Output(caps.ToString()); 384 sb.Append(cdt.ToString());
385 */
386 }
387
388 private void BuildSummaryStatsByCapReport(StringBuilder sb)
389 {
390 /*
391 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
392 cdt.AddColumn("Name", 34);
393 cdt.AddColumn("Req Received", 12);
394 cdt.AddColumn("Req Handled", 12);
395 cdt.Indent = 2;
396
397 Dictionary<string, int> receivedStats = new Dictionary<string, int>();
398 Dictionary<string, int> handledStats = new Dictionary<string, int>();
399
400 m_scene.ForEachScenePresence(
401 sp =>
402 {
403 Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
404
405 if (caps == null)
406 return;
407
408 Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
409
410 foreach (IRequestHandler reqHandler in capsHandlers.Values)
411 {
412 string reqName = reqHandler.Name ?? "";
413
414 if (!receivedStats.ContainsKey(reqName))
415 {
416 receivedStats[reqName] = reqHandler.RequestsReceived;
417 handledStats[reqName] = reqHandler.RequestsHandled;
418 }
419 else
420 {
421 receivedStats[reqName] += reqHandler.RequestsReceived;
422 handledStats[reqName] += reqHandler.RequestsHandled;
423 }
424 }
425 }
426 );
427
428 foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value))
429 cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]);
430
431 sb.Append(cdt.ToString());
432 */
433 }
434
435 private void HandleShowCapsStatsByUserCommand(string module, string[] cmdParams)
436 {
437 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
438 return;
439
440 if (cmdParams.Length != 5 && cmdParams.Length != 7)
441 {
442 MainConsole.Instance.Output("Usage: show caps stats by user [<first-name> <last-name>]");
443 return;
444 }
445
446 StringBuilder sb = new StringBuilder();
447 sb.AppendFormat("Region {0}:\n", m_scene.Name);
448
449 if (cmdParams.Length == 5)
450 {
451 BuildSummaryStatsByUserReport(sb);
452 }
453 else if (cmdParams.Length == 7)
454 {
455 string firstName = cmdParams[5];
456 string lastName = cmdParams[6];
457
458 ScenePresence sp = m_scene.GetScenePresence(firstName, lastName);
459
460 if (sp == null)
461 return;
462
463 BuildDetailedStatsByUserReport(sb, sp);
464 }
465
466 MainConsole.Instance.Output(sb.ToString());
467 }
468
469 private void BuildDetailedStatsByUserReport(StringBuilder sb, ScenePresence sp)
470 {
471 /*
472 sb.AppendFormat("Avatar name {0}, type {1}\n", sp.Name, sp.IsChildAgent ? "child" : "root");
473
474 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
475 cdt.AddColumn("Cap Name", 34);
476 cdt.AddColumn("Req Received", 12);
477 cdt.AddColumn("Req Handled", 12);
478 cdt.Indent = 2;
479
480 Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
481
482 if (caps == null)
483 return;
484
485 Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
486
487 foreach (IRequestHandler reqHandler in capsHandlers.Values.OrderByDescending(rh => rh.RequestsReceived))
488 {
489 cdt.AddRow(reqHandler.Name, reqHandler.RequestsReceived, reqHandler.RequestsHandled);
490 }
491
492 sb.Append(cdt.ToString());
493 */
494 }
495
496 private void BuildSummaryStatsByUserReport(StringBuilder sb)
497 {
498 /*
499 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
500 cdt.AddColumn("Name", 32);
501 cdt.AddColumn("Type", 5);
502 cdt.AddColumn("Req Received", 12);
503 cdt.AddColumn("Req Handled", 12);
504 cdt.Indent = 2;
505
506 m_scene.ForEachScenePresence(
507 sp =>
508 {
509 Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
510
511 if (caps == null)
512 return;
513
514 Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
515
516 int totalRequestsReceived = 0;
517 int totalRequestsHandled = 0;
518
519 foreach (IRequestHandler reqHandler in capsHandlers.Values)
520 {
521 totalRequestsReceived += reqHandler.RequestsReceived;
522 totalRequestsHandled += reqHandler.RequestsHandled;
523 }
524
525 cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled);
526 }
527 );
528
529 sb.Append(cdt.ToString());
530 */
266 } 531 }
267 } 532 }
268} 533}
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 73b3678f..975fccf 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
@@ -171,11 +171,11 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
171 if (!so.IsAttachment) 171 if (!so.IsAttachment)
172 return; 172 return;
173 173
174 if (so.Scene.UserManagementModule.IsLocalGridUser(so.AttachedAvatar)) 174 if (so.AttachedAvatar == UUID.Zero || Scene.UserManagementModule.IsLocalGridUser(so.AttachedAvatar))
175 return; 175 return;
176 176
177 // foreign user 177 // foreign user
178 AgentCircuitData aCircuit = so.Scene.AuthenticateHandler.GetAgentCircuitData(so.AttachedAvatar); 178 AgentCircuitData aCircuit = Scene.AuthenticateHandler.GetAgentCircuitData(so.AttachedAvatar);
179 if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) 179 if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
180 { 180 {
181 if (aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI")) 181 if (aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
@@ -183,7 +183,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
183 string url = aCircuit.ServiceURLs["AssetServerURI"].ToString(); 183 string url = aCircuit.ServiceURLs["AssetServerURI"].ToString();
184 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Incoming attachement {0} for HG user {1} with asset server {2}", so.Name, so.AttachedAvatar, url); 184 m_log.DebugFormat("[HG ENTITY TRANSFER MODULE]: Incoming attachement {0} for HG user {1} with asset server {2}", so.Name, so.AttachedAvatar, url);
185 Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>(); 185 Dictionary<UUID, AssetType> ids = new Dictionary<UUID, AssetType>();
186 HGUuidGatherer uuidGatherer = new HGUuidGatherer(so.Scene.AssetService, url); 186 HGUuidGatherer uuidGatherer = new HGUuidGatherer(Scene.AssetService, url);
187 uuidGatherer.GatherAssetUuids(so, ids); 187 uuidGatherer.GatherAssetUuids(so, ids);
188 188
189 foreach (KeyValuePair<UUID, AssetType> kvp in ids) 189 foreach (KeyValuePair<UUID, AssetType> kvp in ids)
diff --git a/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs b/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs
new file mode 100644
index 0000000..f1eb1ad
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Framework/GridServiceThrottle/GridServiceThrottleModule.cs
@@ -0,0 +1,163 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Threading;
32using log4net;
33using Mono.Addins;
34using Nini.Config;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Framework.Monitoring;
39using OpenSim.Region.Framework.Scenes;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41
42namespace OpenSim.Region.CoreModules.Framework
43{
44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GridServiceThrottleModule")]
45 public class GridServiceThrottleModule : ISharedRegionModule
46 {
47 private static readonly ILog m_log = LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 private readonly List<Scene> m_scenes = new List<Scene>();
51
52 private OpenSim.Framework.BlockingQueue<GridRegionRequest> m_RequestQueue = new OpenSim.Framework.BlockingQueue<GridRegionRequest>();
53
54 public void Initialise(IConfigSource config)
55 {
56 Watchdog.StartThread(
57 ProcessQueue,
58 "GridServiceRequestThread",
59 ThreadPriority.BelowNormal,
60 true,
61 false);
62 }
63
64 public void AddRegion(Scene scene)
65 {
66 lock (m_scenes)
67 {
68 m_scenes.Add(scene);
69 scene.EventManager.OnNewClient += OnNewClient;
70 }
71 }
72
73 public void RegionLoaded(Scene scene)
74 {
75 }
76
77 public void RemoveRegion(Scene scene)
78 {
79 lock (m_scenes)
80 {
81 m_scenes.Remove(scene);
82 scene.EventManager.OnNewClient -= OnNewClient;
83 }
84 }
85
86 void OnNewClient(IClientAPI client)
87 {
88 client.OnRegionHandleRequest += OnRegionHandleRequest;
89 }
90
91 public void PostInitialise()
92 {
93 }
94
95 public void Close()
96 {
97 }
98
99 public string Name
100 {
101 get { return "GridServiceThrottleModule"; }
102 }
103
104 public Type ReplaceableInterface
105 {
106 get { return null; }
107 }
108
109 public void OnRegionHandleRequest(IClientAPI client, UUID regionID)
110 {
111 //m_log.DebugFormat("[GRIDSERVICE THROTTLE]: RegionHandleRequest {0}", regionID);
112 ulong handle = 0;
113 if (IsLocalRegionHandle(regionID, out handle))
114 {
115 client.SendRegionHandle(regionID, handle);
116 return;
117 }
118
119 GridRegionRequest request = new GridRegionRequest(client, regionID);
120 m_RequestQueue.Enqueue(request);
121
122 }
123
124 private bool IsLocalRegionHandle(UUID regionID, out ulong regionHandle)
125 {
126 regionHandle = 0;
127 foreach (Scene s in m_scenes)
128 if (s.RegionInfo.RegionID == regionID)
129 {
130 regionHandle = s.RegionInfo.RegionHandle;
131 return true;
132 }
133 return false;
134 }
135
136 private void ProcessQueue()
137 {
138 while (true)
139 {
140 Watchdog.UpdateThread();
141
142 GridRegionRequest request = m_RequestQueue.Dequeue();
143 GridRegion r = m_scenes[0].GridService.GetRegionByUUID(UUID.Zero, request.regionID);
144
145 if (r != null && r.RegionHandle != 0)
146 request.client.SendRegionHandle(request.regionID, r.RegionHandle);
147
148 }
149 }
150 }
151
152 class GridRegionRequest
153 {
154 public IClientAPI client;
155 public UUID regionID;
156
157 public GridRegionRequest(IClientAPI c, UUID r)
158 {
159 client = c;
160 regionID = r;
161 }
162 }
163}
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
index 1eae0ac..e0c8ea6 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs
@@ -135,7 +135,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
135 if (sp is ScenePresence) 135 if (sp is ScenePresence)
136 { 136 {
137 AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId); 137 AgentCircuitData aCircuit = ((ScenePresence)sp).Scene.AuthenticateHandler.GetAgentCircuitData(client.AgentId);
138 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0) 138 if (aCircuit != null && (aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaHGLogin) != 0)
139 { 139 {
140 if (m_RestrictInventoryAccessAbroad) 140 if (m_RestrictInventoryAccessAbroad)
141 { 141 {
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs
index d07cff4..69d7e16 100644
--- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs
@@ -176,7 +176,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library
176 m_log.InfoFormat("[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName); 176 m_log.InfoFormat("[LIBRARY MODULE]: Loading library archive {0} ({1})...", iarFileName, simpleName);
177 simpleName = GetInventoryPathFromName(simpleName); 177 simpleName = GetInventoryPathFromName(simpleName);
178 178
179 InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, simpleName, iarFileName, false); 179 InventoryArchiveReadRequest archread = new InventoryArchiveReadRequest(m_MockScene.InventoryService, m_MockScene.AssetService, m_MockScene.UserAccountService, uinfo, simpleName, iarFileName, false);
180 try 180 try
181 { 181 {
182 HashSet<InventoryNodeBase> nodes = archread.Execute(); 182 HashSet<InventoryNodeBase> nodes = archread.Execute();
@@ -185,7 +185,7 @@ namespace OpenSim.Region.CoreModules.Framework.Library
185 // didn't find the subfolder with the given name; place it on the top 185 // didn't find the subfolder with the given name; place it on the top
186 m_log.InfoFormat("[LIBRARY MODULE]: Didn't find {0} in library. Placing archive on the top level", simpleName); 186 m_log.InfoFormat("[LIBRARY MODULE]: Didn't find {0} in library. Placing archive on the top level", simpleName);
187 archread.Close(); 187 archread.Close();
188 archread = new InventoryArchiveReadRequest(m_MockScene, uinfo, "/", iarFileName, false); 188 archread = new InventoryArchiveReadRequest(m_MockScene.InventoryService, m_MockScene.AssetService, m_MockScene.UserAccountService, uinfo, "/", iarFileName, false);
189 archread.Execute(); 189 archread.Execute();
190 } 190 }
191 191
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs
index ad3cf15..245c808 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
58 if (umanmod == Name) 58 if (umanmod == Name)
59 { 59 {
60 m_Enabled = true; 60 m_Enabled = true;
61 RegisterConsoleCmds(); 61 Init();
62 m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name); 62 m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name);
63 } 63 }
64 } 64 }
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
index a7cbc8f..a528093 100644
--- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs
@@ -28,9 +28,11 @@ using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.IO; 29using System.IO;
30using System.Reflection; 30using System.Reflection;
31using System.Threading;
31 32
32using OpenSim.Framework; 33using OpenSim.Framework;
33using OpenSim.Framework.Console; 34using OpenSim.Framework.Console;
35using OpenSim.Framework.Monitoring;
34using OpenSim.Region.ClientStack.LindenUDP; 36using OpenSim.Region.ClientStack.LindenUDP;
35using OpenSim.Region.Framework; 37using OpenSim.Region.Framework;
36using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
@@ -57,6 +59,10 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
57 // The cache 59 // The cache
58 protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>(); 60 protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>();
59 61
62 // Throttle the name requests
63 private OpenSim.Framework.BlockingQueue<NameRequest> m_RequestQueue = new OpenSim.Framework.BlockingQueue<NameRequest>();
64
65
60 #region ISharedRegionModule 66 #region ISharedRegionModule
61 67
62 public void Initialise(IConfigSource config) 68 public void Initialise(IConfigSource config)
@@ -65,7 +71,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
65 if (umanmod == Name) 71 if (umanmod == Name)
66 { 72 {
67 m_Enabled = true; 73 m_Enabled = true;
68 RegisterConsoleCmds(); 74 Init();
69 m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name); 75 m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name);
70 } 76 }
71 } 77 }
@@ -160,16 +166,9 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
160 } 166 }
161 else 167 else
162 { 168 {
163 string[] names; 169 NameRequest request = new NameRequest(remote_client, uuid);
164 bool foundRealName = TryGetUserNames(uuid, out names); 170 m_RequestQueue.Enqueue(request);
165 171
166 if (names.Length == 2)
167 {
168 if (!foundRealName)
169 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Sending {0} {1} for {2} to {3} since no bound name found", names[0], names[1], uuid, remote_client.Name);
170
171 remote_client.SendNameReply(uuid, names[0], names[1]);
172 }
173 } 172 }
174 } 173 }
175 174
@@ -514,9 +513,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
514 return; 513 return;
515 } 514 }
516 515
517 //try update unknown users 516 //try update unknown users, but don't update anyone else
518 //and creator's home URL's 517 if (oldUser.FirstName == "Unknown" && !creatorData.Contains("Unknown"))
519 if ((oldUser.FirstName == "Unknown" && !creatorData.Contains("Unknown")) || (oldUser.HomeURL != null && !creatorData.StartsWith(oldUser.HomeURL)))
520 { 518 {
521 lock (m_UserCache) 519 lock (m_UserCache)
522 m_UserCache.Remove(id); 520 m_UserCache.Remove(id);
@@ -597,6 +595,18 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
597 595
598 #endregion IUserManagement 596 #endregion IUserManagement
599 597
598 protected void Init()
599 {
600 RegisterConsoleCmds();
601 Watchdog.StartThread(
602 ProcessQueue,
603 "NameRequestThread",
604 ThreadPriority.BelowNormal,
605 true,
606 false);
607
608 }
609
600 protected void RegisterConsoleCmds() 610 protected void RegisterConsoleCmds()
601 { 611 {
602 MainConsole.Instance.Commands.AddCommand("Users", true, 612 MainConsole.Instance.Commands.AddCommand("Users", true,
@@ -663,5 +673,40 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
663 673
664 MainConsole.Instance.Output(cdt.ToString()); 674 MainConsole.Instance.Output(cdt.ToString());
665 } 675 }
676
677 private void ProcessQueue()
678 {
679 while (true)
680 {
681 Watchdog.UpdateThread();
682
683 NameRequest request = m_RequestQueue.Dequeue();
684 string[] names;
685 bool foundRealName = TryGetUserNames(request.uuid, out names);
686
687 if (names.Length == 2)
688 {
689 if (!foundRealName)
690 m_log.DebugFormat("[USER MANAGEMENT MODULE]: Sending {0} {1} for {2} to {3} since no bound name found", names[0], names[1], request.uuid, request.client.Name);
691
692 request.client.SendNameReply(request.uuid, names[0], names[1]);
693 }
694
695 }
696 }
697
698 }
699
700 class NameRequest
701 {
702 public IClientAPI client;
703 public UUID uuid;
704
705 public NameRequest(IClientAPI c, UUID n)
706 {
707 client = c;
708 uuid = n;
709 }
666 } 710 }
711
667} \ No newline at end of file 712} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/Tests/ScriptsHttpRequestsTests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/Tests/ScriptsHttpRequestsTests.cs
new file mode 100644
index 0000000..e812d81
--- /dev/null
+++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/Tests/ScriptsHttpRequestsTests.cs
@@ -0,0 +1,198 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.IO;
31using System.Net;
32using System.Reflection;
33using System.Runtime.Serialization;
34using System.Text;
35using System.Threading;
36using log4net.Config;
37using NUnit.Framework;
38using OpenMetaverse;
39using OpenMetaverse.Assets;
40using OpenSim.Framework;
41using OpenSim.Region.CoreModules.Scripting.HttpRequest;
42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Tests.Common;
44using OpenSim.Tests.Common.Mock;
45
46namespace OpenSim.Region.CoreModules.Scripting.HttpRequest.Tests
47{
48 class TestWebRequestCreate : IWebRequestCreate
49 {
50 public TestWebRequest NextRequest { get; set; }
51
52 public WebRequest Create(Uri uri)
53 {
54// NextRequest.RequestUri = uri;
55
56 return NextRequest;
57
58// return new TestWebRequest(new SerializationInfo(typeof(TestWebRequest), new FormatterConverter()), new StreamingContext());
59 }
60 }
61
62 class TestWebRequest : WebRequest
63 {
64 public override string ContentType { get; set; }
65 public override string Method { get; set; }
66
67 public Func<IAsyncResult, WebResponse> OnEndGetResponse { get; set; }
68
69 public TestWebRequest() : base()
70 {
71// Console.WriteLine("created");
72 }
73
74// public TestWebRequest(SerializationInfo serializationInfo, StreamingContext streamingContext)
75// : base(serializationInfo, streamingContext)
76// {
77// Console.WriteLine("created");
78// }
79
80 public override IAsyncResult BeginGetResponse(AsyncCallback callback, object state)
81 {
82// Console.WriteLine("bish");
83 TestAsyncResult tasr = new TestAsyncResult();
84 callback(tasr);
85
86 return tasr;
87 }
88
89 public override WebResponse EndGetResponse(IAsyncResult asyncResult)
90 {
91// Console.WriteLine("bosh");
92 return OnEndGetResponse(asyncResult);
93 }
94 }
95
96 class TestHttpWebResponse : HttpWebResponse
97 {
98 public string Response { get; set; }
99
100 public TestHttpWebResponse(SerializationInfo serializationInfo, StreamingContext streamingContext)
101 : base(serializationInfo, streamingContext) {}
102
103 public override Stream GetResponseStream()
104 {
105 return new MemoryStream(Encoding.UTF8.GetBytes(Response));
106 }
107 }
108
109 class TestAsyncResult : IAsyncResult
110 {
111 WaitHandle m_wh = new ManualResetEvent(true);
112
113 object IAsyncResult.AsyncState
114 {
115 get {
116 throw new System.NotImplementedException ();
117 }
118 }
119
120 WaitHandle IAsyncResult.AsyncWaitHandle
121 {
122 get { return m_wh; }
123 }
124
125 bool IAsyncResult.CompletedSynchronously
126 {
127 get { return false; }
128 }
129
130 bool IAsyncResult.IsCompleted
131 {
132 get { return true; }
133 }
134 }
135
136 /// <summary>
137 /// Test script http request code.
138 /// </summary>
139 /// <remarks>
140 /// This class uses some very hacky workarounds in order to mock HttpWebResponse which are Mono dependent (though
141 /// alternative code can be written to make this work for Windows). However, the value of being able to
142 /// regression test this kind of code is very high.
143 /// </remarks>
144 [TestFixture]
145 public class ScriptsHttpRequestsTests : OpenSimTestCase
146 {
147 /// <summary>
148 /// Test what happens when we get a 404 response from a call.
149 /// </summary>
150 [Test]
151 public void Test404Response()
152 {
153 TestHelpers.InMethod();
154// TestHelpers.EnableLogging();
155
156 if (!Util.IsPlatformMono)
157 Assert.Ignore("Ignoring test since can only currently run on Mono");
158
159 string rawResponse = "boom";
160
161 TestWebRequestCreate twrc = new TestWebRequestCreate();
162
163 TestWebRequest twr = new TestWebRequest();
164 //twr.OnEndGetResponse += ar => new TestHttpWebResponse(null, new StreamingContext());
165 twr.OnEndGetResponse += ar =>
166 {
167 SerializationInfo si = new SerializationInfo(typeof(HttpWebResponse), new FormatterConverter());
168 StreamingContext sc = new StreamingContext();
169// WebHeaderCollection headers = new WebHeaderCollection();
170// si.AddValue("m_HttpResponseHeaders", headers);
171 si.AddValue("uri", new Uri("test://arrg"));
172// si.AddValue("m_Certificate", null);
173 si.AddValue("version", HttpVersion.Version11);
174 si.AddValue("statusCode", HttpStatusCode.NotFound);
175 si.AddValue("contentLength", 0);
176 si.AddValue("method", "GET");
177 si.AddValue("statusDescription", "Not Found");
178 si.AddValue("contentType", null);
179 si.AddValue("cookieCollection", new CookieCollection());
180
181 TestHttpWebResponse thwr = new TestHttpWebResponse(si, sc);
182 thwr.Response = rawResponse;
183
184 throw new WebException("no message", null, WebExceptionStatus.ProtocolError, thwr);
185 };
186
187 twrc.NextRequest = twr;
188
189 WebRequest.RegisterPrefix("test", twrc);
190 HttpRequestClass hr = new HttpRequestClass();
191 hr.Url = "test://something";
192 hr.SendRequest();
193
194 Assert.That(hr.Status, Is.EqualTo((int)HttpStatusCode.NotFound));
195 Assert.That(hr.ResponseBody, Is.EqualTo(rawResponse));
196 }
197 }
198} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs
index 221f815..e05d186 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/ActivityDetector.cs
@@ -81,6 +81,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser
81 81
82 public void OnConnectionClose(IClientAPI client) 82 public void OnConnectionClose(IClientAPI client)
83 { 83 {
84 if (client == null)
85 return;
86 if (client.SceneAgent == null)
87 return;
88
84 if (client.SceneAgent.IsChildAgent) 89 if (client.SceneAgent.IsChildAgent)
85 return; 90 return;
86 91
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
index 70ba944..7f78076 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs
@@ -195,19 +195,20 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
195 { 195 {
196 InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID); 196 InventoryCollection invCol = m_RemoteConnector.GetFolderContent(userID, folderID);
197 197
198 if (invCol != null && UserManager != null) 198 // Commenting this for now, because it's causing more grief than good
199 { 199 //if (invCol != null && UserManager != null)
200 // Protect ourselves against the caller subsequently modifying the items list 200 //{
201 List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items); 201 // // Protect ourselves against the caller subsequently modifying the items list
202 202 // List<InventoryItemBase> items = new List<InventoryItemBase>(invCol.Items);
203 if (items != null && items.Count > 0) 203
204 Util.FireAndForget(delegate 204 // if (items != null && items.Count > 0)
205 { 205 // //Util.FireAndForget(delegate
206 foreach (InventoryItemBase item in items) 206 // //{
207 if (!string.IsNullOrEmpty(item.CreatorData)) 207 // foreach (InventoryItemBase item in items)
208 UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); 208 // if (!string.IsNullOrEmpty(item.CreatorData))
209 }); 209 // UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
210 } 210 // //});
211 //}
211 212
212 return invCol; 213 return invCol;
213 } 214 }
diff --git a/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs b/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs
index eb74cda..2366767 100644
--- a/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs
+++ b/OpenSim/Region/CoreModules/World/Estate/XEstateRequestHandler.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Region.CoreModules.World.Estate
55 m_EstateModule = fmodule; 55 m_EstateModule = fmodule;
56 } 56 }
57 57
58 public override byte[] Handle(string path, Stream requestData, 58 protected override byte[] ProcessRequest(string path, Stream requestData,
59 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 59 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
60 { 60 {
61 StreamReader sr = new StreamReader(requestData); 61 StreamReader sr = new StreamReader(requestData);
diff --git a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
index 8a40278..29652aa 100644
--- a/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
+++ b/OpenSim/Region/Framework/Scenes/KeyframeMotion.cs
@@ -55,7 +55,6 @@ namespace OpenSim.Region.Framework.Scenes
55 private object m_lockObject = new object(); 55 private object m_lockObject = new object();
56 private object m_timerLock = new object(); 56 private object m_timerLock = new object();
57 private const double m_tickDuration = 50.0; 57 private const double m_tickDuration = 50.0;
58 private Scene m_scene;
59 58
60 public double TickDuration 59 public double TickDuration
61 { 60 {
@@ -69,8 +68,6 @@ namespace OpenSim.Region.Framework.Scenes
69 m_timer.AutoReset = true; 68 m_timer.AutoReset = true;
70 m_timer.Elapsed += OnTimer; 69 m_timer.Elapsed += OnTimer;
71 70
72 m_scene = scene;
73
74 m_timer.Start(); 71 m_timer.Start();
75 } 72 }
76 73
@@ -94,13 +91,13 @@ namespace OpenSim.Region.Framework.Scenes
94 { 91 {
95 m.OnTimer(TickDuration); 92 m.OnTimer(TickDuration);
96 } 93 }
97 catch (Exception inner) 94 catch (Exception)
98 { 95 {
99 // Don't stop processing 96 // Don't stop processing
100 } 97 }
101 } 98 }
102 } 99 }
103 catch (Exception e) 100 catch (Exception)
104 { 101 {
105 // Keep running no matter what 102 // Keep running no matter what
106 } 103 }
@@ -157,7 +154,7 @@ namespace OpenSim.Region.Framework.Scenes
157 [Serializable] 154 [Serializable]
158 public class KeyframeMotion 155 public class KeyframeMotion
159 { 156 {
160 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 157// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
161 158
162 public enum PlayMode : int 159 public enum PlayMode : int
163 { 160 {
diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
index c11174d..f208afb 100644
--- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
+++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
@@ -46,47 +46,33 @@ using OpenSim.Region.Framework.Scenes;
46 46
47namespace OpenSim.Region.Framework.Scenes 47namespace OpenSim.Region.Framework.Scenes
48{ 48{
49 public class RegionStatsHandler : IStreamedRequestHandler 49 public class RegionStatsHandler : BaseStreamHandler
50 { 50 {
51 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 51 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 52
53 private string osRXStatsURI = String.Empty;
54 private string osXStatsURI = String.Empty; 53 private string osXStatsURI = String.Empty;
55 //private string osSecret = String.Empty; 54 //private string osSecret = String.Empty;
56 private OpenSim.Framework.RegionInfo regionInfo; 55 private OpenSim.Framework.RegionInfo regionInfo;
57 public string localZone = TimeZone.CurrentTimeZone.StandardName; 56 public string localZone = TimeZone.CurrentTimeZone.StandardName;
58 public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now); 57 public TimeSpan utcOffset = TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now);
59 58
60 public string Name { get { return "RegionStats"; } } 59 public RegionStatsHandler(RegionInfo region_info)
61 public string Description { get { return "Region Statistics"; } } 60 : base("GET", "/" + Util.SHA1Hash(region_info.regionSecret), "RegionStats", "Region Statistics")
62
63 public RegionStatsHandler(RegionInfo region_info)
64 { 61 {
65 regionInfo = region_info; 62 regionInfo = region_info;
66 osRXStatsURI = Util.SHA1Hash(regionInfo.regionSecret);
67 osXStatsURI = Util.SHA1Hash(regionInfo.osSecret); 63 osXStatsURI = Util.SHA1Hash(regionInfo.osSecret);
68 } 64 }
69 65
70 public byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 66 protected override byte[] ProcessRequest(
67 string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
71 { 68 {
72 return Util.UTF8.GetBytes(Report()); 69 return Util.UTF8.GetBytes(Report());
73 } 70 }
74 71
75 public string ContentType 72 public override string ContentType
76 { 73 {
77 get { return "text/plain"; } 74 get { return "text/plain"; }
78 } 75 }
79
80 public string HttpMethod
81 {
82 get { return "GET"; }
83 }
84
85 public string Path
86 {
87 // This is for the region and is the regionSecret hashed
88 get { return "/" + osRXStatsURI; }
89 }
90 76
91 private string Report() 77 private string Report()
92 { 78 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index c743190..d293a8b 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -3258,7 +3258,6 @@ namespace OpenSim.Region.Framework.Scenes
3258 { 3258 {
3259 //client.OnNameFromUUIDRequest += HandleUUIDNameRequest; 3259 //client.OnNameFromUUIDRequest += HandleUUIDNameRequest;
3260 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; 3260 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
3261 client.OnRegionHandleRequest += RegionHandleRequest;
3262 } 3261 }
3263 3262
3264 public virtual void SubscribeToClientNetworkEvents(IClientAPI client) 3263 public virtual void SubscribeToClientNetworkEvents(IClientAPI client)
@@ -3384,7 +3383,6 @@ namespace OpenSim.Region.Framework.Scenes
3384 { 3383 {
3385 //client.OnNameFromUUIDRequest -= HandleUUIDNameRequest; 3384 //client.OnNameFromUUIDRequest -= HandleUUIDNameRequest;
3386 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; 3385 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest;
3387 client.OnRegionHandleRequest -= RegionHandleRequest;
3388 } 3386 }
3389 3387
3390 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client) 3388 public virtual void UnSubscribeToClientNetworkEvents(IClientAPI client)
@@ -3859,7 +3857,10 @@ namespace OpenSim.Region.Framework.Scenes
3859 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.", 3857 "[SCENE]: Existing root scene presence detected for {0} {1} in {2} when connecting. Removing existing presence.",
3860 sp.Name, sp.UUID, RegionInfo.RegionName); 3858 sp.Name, sp.UUID, RegionInfo.RegionName);
3861 3859
3862 sp.ControllingClient.Close(true, true); 3860
3861 if (sp.ControllingClient != null)
3862 sp.ControllingClient.Close(true, true);
3863
3863 sp = null; 3864 sp = null;
3864 } 3865 }
3865 } 3866 }
@@ -5089,22 +5090,6 @@ namespace OpenSim.Region.Framework.Scenes
5089 5090
5090 #endregion 5091 #endregion
5091 5092
5092 public void RegionHandleRequest(IClientAPI client, UUID regionID)
5093 {
5094 m_log.DebugFormat("[SCENE]: RegionHandleRequest {0}", regionID);
5095 ulong handle = 0;
5096 if (regionID == RegionInfo.RegionID)
5097 handle = RegionInfo.RegionHandle;
5098 else
5099 {
5100 GridRegion r = GridService.GetRegionByUUID(UUID.Zero, regionID);
5101 if (r != null)
5102 handle = r.RegionHandle;
5103 }
5104
5105 if (handle != 0)
5106 client.SendRegionHandle(regionID, handle);
5107 }
5108 5093
5109// Commented pending deletion since this method no longer appears to do anything at all 5094// Commented pending deletion since this method no longer appears to do anything at all
5110// public bool NeedSceneCacheClear(UUID agentID) 5095// public bool NeedSceneCacheClear(UUID agentID)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
index f8624e7..8c50a81 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs
@@ -67,6 +67,12 @@ namespace OpenSim.Region.Framework.Scenes
67 { 67 {
68 int scriptsStarted = 0; 68 int scriptsStarted = 0;
69 69
70 if (m_scene == null)
71 {
72 m_log.DebugFormat("[PRIM INVENTORY]: m_scene is null. Unable to create script instances");
73 return 0;
74 }
75
70 // Don't start scripts if they're turned off in the region! 76 // Don't start scripts if they're turned off in the region!
71 if (!m_scene.RegionInfo.RegionSettings.DisableScripts) 77 if (!m_scene.RegionInfo.RegionSettings.DisableScripts)
72 { 78 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index f13f7ab..389c2c6 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -390,8 +390,6 @@ namespace OpenSim.Region.Framework.Scenes
390 390
391 private SOPVehicle m_vehicleParams = null; 391 private SOPVehicle m_vehicleParams = null;
392 392
393 private KeyframeMotion m_keyframeMotion = null;
394
395 public KeyframeMotion KeyframeMotion 393 public KeyframeMotion KeyframeMotion
396 { 394 {
397 get; set; 395 get; set;
@@ -543,7 +541,11 @@ namespace OpenSim.Region.Framework.Scenes
543 CreatorID = uuid; 541 CreatorID = uuid;
544 } 542 }
545 if (parts.Length >= 2) 543 if (parts.Length >= 2)
544 {
546 CreatorData = parts[1]; 545 CreatorData = parts[1];
546 if (!CreatorData.EndsWith("/"))
547 CreatorData += "/";
548 }
547 if (parts.Length >= 3) 549 if (parts.Length >= 3)
548 name = parts[2]; 550 name = parts[2];
549 551
@@ -4642,6 +4644,11 @@ namespace OpenSim.Region.Framework.Scenes
4642 } 4644 }
4643 } 4645 }
4644*/ 4646*/
4647 if (pa != null)
4648 {
4649 pa.SetMaterial(Material);
4650 DoPhysicsPropertyUpdate(UsePhysics, true);
4651 }
4645 } 4652 }
4646 else // it already has a physical representation 4653 else // it already has a physical representation
4647 { 4654 {
@@ -4696,6 +4703,46 @@ namespace OpenSim.Region.Framework.Scenes
4696// m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags); 4703// m_log.DebugFormat("[SCENE OBJECT PART]: Updated PrimFlags on {0} {1} to {2}", Name, LocalId, Flags);
4697 } 4704 }
4698 4705
4706 // Subscribe for physics collision events if needed for scripts and sounds
4707 public void SubscribeForCollisionEvents()
4708 {
4709 if (PhysActor != null)
4710 {
4711 if (
4712 ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4713 ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4714 ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4715 ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4716 ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4717 ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4718 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision) != 0) ||
4719 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4720 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4721 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4722 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4723 ((ParentGroup.RootPart.AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4724 (CollisionSound != UUID.Zero)
4725 )
4726 {
4727 if (!PhysActor.SubscribedEvents())
4728 {
4729 // If not already subscribed for event, set up for a collision event.
4730 PhysActor.OnCollisionUpdate += PhysicsCollision;
4731 PhysActor.SubscribeEvents(1000);
4732 }
4733 }
4734 else
4735 {
4736 // There is no need to be subscribed to collisions so, if subscribed, remove subscription
4737 if (PhysActor.SubscribedEvents())
4738 {
4739 PhysActor.OnCollisionUpdate -= PhysicsCollision;
4740 PhysActor.UnSubscribeEvents();
4741 }
4742 }
4743 }
4744 }
4745
4699 /// <summary> 4746 /// <summary>
4700 /// Adds this part to the physics scene. 4747 /// Adds this part to the physics scene.
4701 /// and sets the PhysActor property 4748 /// and sets the PhysActor property
@@ -5154,31 +5201,7 @@ namespace OpenSim.Region.Framework.Scenes
5154 { 5201 {
5155 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop; 5202 objectflagupdate |= (uint) PrimFlags.AllowInventoryDrop;
5156 } 5203 }
5157/* 5204
5158 PhysicsActor pa = PhysActor;
5159 if (pa != null)
5160 {
5161 if (
5162// ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
5163// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
5164// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
5165// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
5166// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
5167// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
5168 ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || (CollisionSound != UUID.Zero)
5169 )
5170 {
5171 // subscribe to physics updates.
5172 pa.OnCollisionUpdate += PhysicsCollision;
5173 pa.SubscribeEvents(1000);
5174 }
5175 else
5176 {
5177 pa.UnSubscribeEvents();
5178 pa.OnCollisionUpdate -= PhysicsCollision;
5179 }
5180 }
5181 */
5182 UpdatePhysicsSubscribedEvents(); 5205 UpdatePhysicsSubscribedEvents();
5183 5206
5184 //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0) 5207 //if ((GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index d04d87b..3be0623 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -696,7 +696,8 @@ namespace OpenSim.Region.Framework.Scenes
696 /// </param> 696 /// </param>
697 public void StopScriptInstance(TaskInventoryItem item) 697 public void StopScriptInstance(TaskInventoryItem item)
698 { 698 {
699 m_part.ParentGroup.Scene.EventManager.TriggerStopScript(m_part.LocalId, item.ItemID); 699 if (m_part.ParentGroup.Scene != null)
700 m_part.ParentGroup.Scene.EventManager.TriggerStopScript(m_part.LocalId, item.ItemID);
700 701
701 // At the moment, even stopped scripts are counted as active, which is probably wrong. 702 // At the moment, even stopped scripts are counted as active, which is probably wrong.
702// m_part.ParentGroup.AddActiveScriptCount(-1); 703// m_part.ParentGroup.AddActiveScriptCount(-1);
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs
new file mode 100644
index 0000000..4ae7a8e
--- /dev/null
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs
@@ -0,0 +1,88 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Text;
32using System.Threading;
33using System.Timers;
34using Timer = System.Timers.Timer;
35using Nini.Config;
36using NUnit.Framework;
37using OpenMetaverse;
38using OpenSim.Framework;
39using OpenSim.Framework.Communications;
40using OpenSim.Framework.Servers;
41using OpenSim.Framework.Servers.HttpServer;
42using OpenSim.Region.ClientStack.Linden;
43using OpenSim.Region.CoreModules.Framework;
44using OpenSim.Region.CoreModules.Framework.EntityTransfer;
45using OpenSim.Region.CoreModules.World.Serialiser;
46using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
47using OpenSim.Region.Framework.Scenes;
48using OpenSim.Region.Framework.Interfaces;
49using OpenSim.Tests.Common;
50using OpenSim.Tests.Common.Mock;
51using GridRegion = OpenSim.Services.Interfaces.GridRegion;
52
53namespace OpenSim.Region.Framework.Scenes.Tests
54{
55 [TestFixture]
56 public class ScenePresenceCapabilityTests : OpenSimTestCase
57 {
58 [Test]
59 public void TestChildAgentSingleRegionCapabilities()
60 {
61 TestHelpers.InMethod();
62// TestHelpers.EnableLogging();
63
64 UUID spUuid = TestHelpers.ParseTail(0x1);
65
66 // XXX: This is not great since the use of statics will mean that this has to be manually cleaned up for
67 // any subsequent test.
68 // XXX: May replace with a mock IHttpServer later.
69 BaseHttpServer httpServer = new BaseHttpServer(99999);
70 MainServer.AddHttpServer(httpServer);
71 MainServer.Instance = httpServer;
72
73 CapabilitiesModule capsMod = new CapabilitiesModule();
74 TestScene scene = new SceneHelpers().SetupScene();
75 SceneHelpers.SetupSceneModules(scene, capsMod);
76
77 ScenePresence sp = SceneHelpers.AddChildScenePresence(scene, spUuid);
78 //Assert.That(capsMod.GetCapsForUser(spUuid), Is.Not.Null);
79
80 // TODO: Need to add tests for other ICapabiltiesModule methods.
81
82 scene.IncomingCloseAgent(sp.UUID, false);
83 //Assert.That(capsMod.GetCapsForUser(spUuid), Is.Null);
84
85 // TODO: Need to add tests for other ICapabiltiesModule methods.
86 }
87 }
88}
diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
index 992f38e..79509ab 100644
--- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Linq;
30using System.Reflection; 31using System.Reflection;
31using System.Text; 32using System.Text;
32using log4net; 33using log4net;
@@ -51,7 +52,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
51 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LindenUDPInfoModule")] 52 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LindenUDPInfoModule")]
52 public class LindenUDPInfoModule : ISharedRegionModule 53 public class LindenUDPInfoModule : ISharedRegionModule
53 { 54 {
54// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 56
56 protected Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); 57 protected Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
57 58
@@ -130,6 +131,15 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
130 "Go on/off emergency monitoring mode", 131 "Go on/off emergency monitoring mode",
131 "Go on/off emergency monitoring mode", 132 "Go on/off emergency monitoring mode",
132 HandleEmergencyMonitoring); 133 HandleEmergencyMonitoring);
134
135 scene.AddCommand(
136 "Comms", this, "show client stats",
137 "show client stats [first_name last_name]",
138 "Show client request stats",
139 "Without the 'first_name last_name' option, all clients are shown."
140 + " With the 'first_name last_name' option only a specific client is shown.",
141 (mod, cmd) => MainConsole.Instance.Output(HandleClientStatsReport(cmd)));
142
133 } 143 }
134 144
135 public void RemoveRegion(Scene scene) 145 public void RemoveRegion(Scene scene)
@@ -587,6 +597,102 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
587 (throttleRates.Asset * 8) / 1000); 597 (throttleRates.Asset * 8) / 1000);
588 598
589 return report.ToString(); 599 return report.ToString();
590 } 600 }
601
602 /// <summary>
603 /// Show client stats data
604 /// </summary>
605 /// <param name="showParams"></param>
606 /// <returns></returns>
607 protected string HandleClientStatsReport(string[] showParams)
608 {
609 // NOTE: This writes to m_log on purpose. We want to store this information
610 // in case we need to analyze it later.
611 //
612 if (showParams.Length <= 4)
613 {
614 m_log.InfoFormat("[INFO]: {0,-12} {1,20} {2,6} {3,11} {4, 10}", "Region", "Name", "Root", "Time", "Reqs/min");
615 foreach (Scene scene in m_scenes.Values)
616 {
617 scene.ForEachClient(
618 delegate(IClientAPI client)
619 {
620 if (client is LLClientView)
621 {
622 LLClientView llClient = client as LLClientView;
623 ClientInfo cinfo = llClient.UDPClient.GetClientInfo();
624 int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum();
625 avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1);
626
627 m_log.InfoFormat("[INFO]: {0,-12} {1,20} {2,4} {3,9}min {4,10}",
628 scene.RegionInfo.RegionName, llClient.Name,
629 (llClient.SceneAgent.IsChildAgent ? "N" : "Y"), (DateTime.Now - cinfo.StartedTime).Minutes, avg_reqs);
630 }
631 });
632 }
633 return string.Empty;
634 }
635
636 string fname = "", lname = "";
637
638 if (showParams.Length > 3)
639 fname = showParams[3];
640 if (showParams.Length > 4)
641 lname = showParams[4];
642
643 foreach (Scene scene in m_scenes.Values)
644 {
645 scene.ForEachClient(
646 delegate(IClientAPI client)
647 {
648 if (client is LLClientView)
649 {
650 LLClientView llClient = client as LLClientView;
651
652 if (llClient.Name == fname + " " + lname)
653 {
654
655 ClientInfo cinfo = llClient.GetClientInfo();
656 AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(llClient.CircuitCode);
657 if (aCircuit == null) // create a dummy one
658 aCircuit = new AgentCircuitData();
659
660 if (!llClient.SceneAgent.IsChildAgent)
661 m_log.InfoFormat("[INFO]: {0} # {1} # {2}", llClient.Name, aCircuit.Viewer, aCircuit.Id0);
662
663 int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum();
664 avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1);
665
666 m_log.InfoFormat("[INFO]:");
667 m_log.InfoFormat("[INFO]: {0} # {1} # Time: {2}min # Avg Reqs/min: {3}", scene.RegionInfo.RegionName,
668 (llClient.SceneAgent.IsChildAgent ? "Child" : "Root"), (DateTime.Now - cinfo.StartedTime).Minutes, avg_reqs);
669
670 Dictionary<string, int> sortedDict = (from entry in cinfo.AsyncRequests orderby entry.Value descending select entry)
671 .ToDictionary(pair => pair.Key, pair => pair.Value);
672 PrintRequests("TOP ASYNC", sortedDict, cinfo.AsyncRequests.Values.Sum());
673
674 sortedDict = (from entry in cinfo.SyncRequests orderby entry.Value descending select entry)
675 .ToDictionary(pair => pair.Key, pair => pair.Value);
676 PrintRequests("TOP SYNC", sortedDict, cinfo.SyncRequests.Values.Sum());
677
678 sortedDict = (from entry in cinfo.GenericRequests orderby entry.Value descending select entry)
679 .ToDictionary(pair => pair.Key, pair => pair.Value);
680 PrintRequests("TOP GENERIC", sortedDict, cinfo.GenericRequests.Values.Sum());
681 }
682 }
683 });
684 }
685 return string.Empty;
686 }
687
688 private void PrintRequests(string type, Dictionary<string, int> sortedDict, int sum)
689 {
690 m_log.InfoFormat("[INFO]:");
691 m_log.InfoFormat("[INFO]: {0,25}", type);
692 foreach (KeyValuePair<string, int> kvp in sortedDict.Take(12))
693 m_log.InfoFormat("[INFO]: {0,25} {1,-6}", kvp.Key, kvp.Value);
694 m_log.InfoFormat("[INFO]: {0,25}", "...");
695 m_log.InfoFormat("[INFO]: {0,25} {1,-6}", "Total", sum);
696 }
591 } 697 }
592} \ No newline at end of file 698} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs
index 3a39971..d8f5563 100644
--- a/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs
+++ b/OpenSim/Region/OptionalModules/Materials/MaterialsDemoModule.cs
@@ -139,18 +139,21 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
139 { 139 {
140 string capsBase = "/CAPS/" + caps.CapsObjectPath; 140 string capsBase = "/CAPS/" + caps.CapsObjectPath;
141 141
142 IRequestHandler renderMaterialsPostHandler = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap); 142 IRequestHandler renderMaterialsPostHandler
143 = new RestStreamHandler("POST", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null);
143 caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler); 144 caps.RegisterHandler("RenderMaterials", renderMaterialsPostHandler);
144 145
145 // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET 146 // OpenSimulator CAPs infrastructure seems to be somewhat hostile towards any CAP that requires both GET
146 // and POST handlers, (at least at the time this was originally written), so we first set up a POST 147 // and POST handlers, (at least at the time this was originally written), so we first set up a POST
147 // handler normally and then add a GET handler via MainServer 148 // handler normally and then add a GET handler via MainServer
148 149
149 IRequestHandler renderMaterialsGetHandler = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap); 150 IRequestHandler renderMaterialsGetHandler
151 = new RestStreamHandler("GET", capsBase + "/", RenderMaterialsGetCap, "RenderMaterials", null);
150 MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); 152 MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler);
151 153
152 // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well 154 // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well
153 IRequestHandler renderMaterialsPutHandler = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap); 155 IRequestHandler renderMaterialsPutHandler
156 = new RestStreamHandler("PUT", capsBase + "/", RenderMaterialsPostCap, "RenderMaterials", null);
154 MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); 157 MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler);
155 } 158 }
156 159
@@ -394,7 +397,6 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
394 m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + matLocalID.ToString()); 397 m_log.Debug("[MaterialsDemoModule]: null SOP for localId: " + matLocalID.ToString());
395 else 398 else
396 { 399 {
397 //var te = sop.Shape.Textures;
398 var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); 400 var te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
399 401
400 if (te == null) 402 if (te == null)
@@ -413,14 +415,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
413 if (te.DefaultTexture == null) 415 if (te.DefaultTexture == null)
414 m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture is null"); 416 m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture is null");
415 else 417 else
416 { 418 te.DefaultTexture.MaterialID = id;
417 if (te.DefaultTexture.MaterialID == null)
418 m_log.Debug("[MaterialsDemoModule]: te.DefaultTexture.MaterialID is null");
419 else
420 {
421 te.DefaultTexture.MaterialID = id;
422 }
423 }
424 } 419 }
425 else 420 else
426 { 421 {
diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs
index c68fe99..3b3b300 100644
--- a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs
+++ b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs
@@ -263,7 +263,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
263 m_module = module; 263 m_module = module;
264 } 264 }
265 265
266 public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 266 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
267 { 267 {
268 StreamReader reader = new StreamReader(request); 268 StreamReader reader = new StreamReader(request);
269 string requestBody = reader.ReadToEnd(); 269 string requestBody = reader.ReadToEnd();
diff --git a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs
index 550b5d4..8720cc7 100644
--- a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs
+++ b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewRequestHandler.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.World.WorldView
55 m_WorldViewModule = fmodule; 55 m_WorldViewModule = fmodule;
56 } 56 }
57 57
58 public override byte[] Handle(string path, Stream requestData, 58 protected override byte[] ProcessRequest(string path, Stream requestData,
59 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 59 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
60 { 60 {
61 httpResponse.ContentType = "image/jpeg"; 61 httpResponse.ContentType = "image/jpeg";
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 5ef6992..c9e3ca0 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -43,12 +43,10 @@ public sealed class BSCharacter : BSPhysObject
43 private OMV.Vector3 _size; 43 private OMV.Vector3 _size;
44 private bool _grabbed; 44 private bool _grabbed;
45 private bool _selected; 45 private bool _selected;
46 private OMV.Vector3 _position;
47 private float _mass; 46 private float _mass;
48 private float _avatarVolume; 47 private float _avatarVolume;
49 private float _collisionScore; 48 private float _collisionScore;
50 private OMV.Vector3 _acceleration; 49 private OMV.Vector3 _acceleration;
51 private OMV.Quaternion _orientation;
52 private int _physicsActorType; 50 private int _physicsActorType;
53 private bool _isPhysical; 51 private bool _isPhysical;
54 private bool _flying; 52 private bool _flying;
@@ -70,10 +68,10 @@ public sealed class BSCharacter : BSPhysObject
70 : base(parent_scene, localID, avName, "BSCharacter") 68 : base(parent_scene, localID, avName, "BSCharacter")
71 { 69 {
72 _physicsActorType = (int)ActorTypes.Agent; 70 _physicsActorType = (int)ActorTypes.Agent;
73 _position = pos; 71 RawPosition = pos;
74 72
75 _flying = isFlying; 73 _flying = isFlying;
76 _orientation = OMV.Quaternion.Identity; 74 RawOrientation = OMV.Quaternion.Identity;
77 RawVelocity = OMV.Vector3.Zero; 75 RawVelocity = OMV.Vector3.Zero;
78 _buoyancy = ComputeBuoyancyFromFlying(isFlying); 76 _buoyancy = ComputeBuoyancyFromFlying(isFlying);
79 Friction = BSParam.AvatarStandingFriction; 77 Friction = BSParam.AvatarStandingFriction;
@@ -133,7 +131,7 @@ public sealed class BSCharacter : BSPhysObject
133 PhysScene.PE.RemoveObjectFromWorld(PhysScene.World, PhysBody); 131 PhysScene.PE.RemoveObjectFromWorld(PhysScene.World, PhysBody);
134 132
135 ZeroMotion(true); 133 ZeroMotion(true);
136 ForcePosition = _position; 134 ForcePosition = RawPosition;
137 135
138 // Set the velocity 136 // Set the velocity
139 if (m_moveActor != null) 137 if (m_moveActor != null)
@@ -272,38 +270,33 @@ public sealed class BSCharacter : BSPhysObject
272 270
273 public override void LockAngularMotion(OMV.Vector3 axis) { return; } 271 public override void LockAngularMotion(OMV.Vector3 axis) { return; }
274 272
275 public override OMV.Vector3 RawPosition
276 {
277 get { return _position; }
278 set { _position = value; }
279 }
280 public override OMV.Vector3 Position { 273 public override OMV.Vector3 Position {
281 get { 274 get {
282 // Don't refetch the position because this function is called a zillion times 275 // Don't refetch the position because this function is called a zillion times
283 // _position = PhysicsScene.PE.GetObjectPosition(Scene.World, LocalID); 276 // RawPosition = PhysicsScene.PE.GetObjectPosition(Scene.World, LocalID);
284 return _position; 277 return RawPosition;
285 } 278 }
286 set { 279 set {
287 _position = value; 280 RawPosition = value;
288 281
289 PhysScene.TaintedObject("BSCharacter.setPosition", delegate() 282 PhysScene.TaintedObject("BSCharacter.setPosition", delegate()
290 { 283 {
291 DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); 284 DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation);
292 PositionSanityCheck(); 285 PositionSanityCheck();
293 ForcePosition = _position; 286 ForcePosition = RawPosition;
294 }); 287 });
295 } 288 }
296 } 289 }
297 public override OMV.Vector3 ForcePosition { 290 public override OMV.Vector3 ForcePosition {
298 get { 291 get {
299 _position = PhysScene.PE.GetPosition(PhysBody); 292 RawPosition = PhysScene.PE.GetPosition(PhysBody);
300 return _position; 293 return RawPosition;
301 } 294 }
302 set { 295 set {
303 _position = value; 296 RawPosition = value;
304 if (PhysBody.HasPhysicalBody) 297 if (PhysBody.HasPhysicalBody)
305 { 298 {
306 PhysScene.PE.SetTranslation(PhysBody, _position, _orientation); 299 PhysScene.PE.SetTranslation(PhysBody, RawPosition, RawOrientation);
307 } 300 }
308 } 301 }
309 } 302 }
@@ -331,16 +324,16 @@ public sealed class BSCharacter : BSPhysObject
331 float terrainHeight = PhysScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); 324 float terrainHeight = PhysScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition);
332 if (Position.Z < terrainHeight) 325 if (Position.Z < terrainHeight)
333 { 326 {
334 DetailLog("{0},BSCharacter.PositionSanityCheck,adjustForUnderGround,pos={1},terrain={2}", LocalID, _position, terrainHeight); 327 DetailLog("{0},BSCharacter.PositionSanityCheck,adjustForUnderGround,pos={1},terrain={2}", LocalID, RawPosition, terrainHeight);
335 _position.Z = terrainHeight + BSParam.AvatarBelowGroundUpCorrectionMeters; 328 RawPosition = new OMV.Vector3(RawPosition.X, RawPosition.Y, terrainHeight + BSParam.AvatarBelowGroundUpCorrectionMeters);
336 ret = true; 329 ret = true;
337 } 330 }
338 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) 331 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0)
339 { 332 {
340 float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(_position); 333 float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(RawPosition);
341 if (Position.Z < waterHeight) 334 if (Position.Z < waterHeight)
342 { 335 {
343 _position.Z = waterHeight; 336 RawPosition = new OMV.Vector3(RawPosition.X, RawPosition.Y, waterHeight);
344 ret = true; 337 ret = true;
345 } 338 }
346 } 339 }
@@ -360,8 +353,8 @@ public sealed class BSCharacter : BSPhysObject
360 // just assign to "Position" because of potential call loops. 353 // just assign to "Position" because of potential call loops.
361 PhysScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate() 354 PhysScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate()
362 { 355 {
363 DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); 356 DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation);
364 ForcePosition = _position; 357 ForcePosition = RawPosition;
365 }); 358 });
366 ret = true; 359 ret = true;
367 } 360 }
@@ -466,19 +459,14 @@ public sealed class BSCharacter : BSPhysObject
466 get { return _acceleration; } 459 get { return _acceleration; }
467 set { _acceleration = value; } 460 set { _acceleration = value; }
468 } 461 }
469 public override OMV.Quaternion RawOrientation
470 {
471 get { return _orientation; }
472 set { _orientation = value; }
473 }
474 public override OMV.Quaternion Orientation { 462 public override OMV.Quaternion Orientation {
475 get { return _orientation; } 463 get { return RawOrientation; }
476 set { 464 set {
477 // Orientation is set zillions of times when an avatar is walking. It's like 465 // Orientation is set zillions of times when an avatar is walking. It's like
478 // the viewer doesn't trust us. 466 // the viewer doesn't trust us.
479 if (_orientation != value) 467 if (RawOrientation != value)
480 { 468 {
481 _orientation = value; 469 RawOrientation = value;
482 PhysScene.TaintedObject("BSCharacter.setOrientation", delegate() 470 PhysScene.TaintedObject("BSCharacter.setOrientation", delegate()
483 { 471 {
484 // Bullet assumes we know what we are doing when forcing orientation 472 // Bullet assumes we know what we are doing when forcing orientation
@@ -486,10 +474,10 @@ public sealed class BSCharacter : BSPhysObject
486 // This forces rotation to be only around the Z axis and doesn't change any of the other axis. 474 // This forces rotation to be only around the Z axis and doesn't change any of the other axis.
487 // This keeps us from flipping the capsule over which the veiwer does not understand. 475 // This keeps us from flipping the capsule over which the veiwer does not understand.
488 float oRoll, oPitch, oYaw; 476 float oRoll, oPitch, oYaw;
489 _orientation.GetEulerAngles(out oRoll, out oPitch, out oYaw); 477 RawOrientation.GetEulerAngles(out oRoll, out oPitch, out oYaw);
490 OMV.Quaternion trimmedOrientation = OMV.Quaternion.CreateFromEulers(0f, 0f, oYaw); 478 OMV.Quaternion trimmedOrientation = OMV.Quaternion.CreateFromEulers(0f, 0f, oYaw);
491 // DetailLog("{0},BSCharacter.setOrientation,taint,val={1},valDir={2},conv={3},convDir={4}", 479 // DetailLog("{0},BSCharacter.setOrientation,taint,val={1},valDir={2},conv={3},convDir={4}",
492 // LocalID, _orientation, OMV.Vector3.UnitX * _orientation, 480 // LocalID, RawOrientation, OMV.Vector3.UnitX * RawOrientation,
493 // trimmedOrientation, OMV.Vector3.UnitX * trimmedOrientation); 481 // trimmedOrientation, OMV.Vector3.UnitX * trimmedOrientation);
494 ForceOrientation = trimmedOrientation; 482 ForceOrientation = trimmedOrientation;
495 }); 483 });
@@ -501,16 +489,16 @@ public sealed class BSCharacter : BSPhysObject
501 { 489 {
502 get 490 get
503 { 491 {
504 _orientation = PhysScene.PE.GetOrientation(PhysBody); 492 RawOrientation = PhysScene.PE.GetOrientation(PhysBody);
505 return _orientation; 493 return RawOrientation;
506 } 494 }
507 set 495 set
508 { 496 {
509 _orientation = value; 497 RawOrientation = value;
510 if (PhysBody.HasPhysicalBody) 498 if (PhysBody.HasPhysicalBody)
511 { 499 {
512 // _position = PhysicsScene.PE.GetPosition(BSBody); 500 // RawPosition = PhysicsScene.PE.GetPosition(BSBody);
513 PhysScene.PE.SetTranslation(PhysBody, _position, _orientation); 501 PhysScene.PE.SetTranslation(PhysBody, RawPosition, RawOrientation);
514 } 502 }
515 } 503 }
516 } 504 }
@@ -723,9 +711,9 @@ public sealed class BSCharacter : BSPhysObject
723 { 711 {
724 // Don't change position if standing on a stationary object. 712 // Don't change position if standing on a stationary object.
725 if (!IsStationary) 713 if (!IsStationary)
726 _position = entprop.Position; 714 RawPosition = entprop.Position;
727 715
728 _orientation = entprop.Rotation; 716 RawOrientation = entprop.Rotation;
729 717
730 // Smooth velocity. OpenSimulator is VERY sensitive to changes in velocity of the avatar 718 // Smooth velocity. OpenSimulator is VERY sensitive to changes in velocity of the avatar
731 // and will send agent updates to the clients if velocity changes by more than 719 // and will send agent updates to the clients if velocity changes by more than
@@ -740,8 +728,8 @@ public sealed class BSCharacter : BSPhysObject
740 // Do some sanity checking for the avatar. Make sure it's above ground and inbounds. 728 // Do some sanity checking for the avatar. Make sure it's above ground and inbounds.
741 if (PositionSanityCheck(true)) 729 if (PositionSanityCheck(true))
742 { 730 {
743 DetailLog("{0},BSCharacter.UpdateProperties,updatePosForSanity,pos={1}", LocalID, _position); 731 DetailLog("{0},BSCharacter.UpdateProperties,updatePosForSanity,pos={1}", LocalID, RawPosition);
744 entprop.Position = _position; 732 entprop.Position = RawPosition;
745 } 733 }
746 734
747 // remember the current and last set values 735 // remember the current and last set values
@@ -755,7 +743,7 @@ public sealed class BSCharacter : BSPhysObject
755 // base.RequestPhysicsterseUpdate(); 743 // base.RequestPhysicsterseUpdate();
756 744
757 DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", 745 DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
758 LocalID, _position, _orientation, RawVelocity, _acceleration, _rotationalVelocity); 746 LocalID, RawPosition, RawOrientation, RawVelocity, _acceleration, _rotationalVelocity);
759 } 747 }
760} 748}
761} 749}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index aa247dd..0204967 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -125,33 +125,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
125 static readonly float PIOverFour = ((float)Math.PI) / 4f; 125 static readonly float PIOverFour = ((float)Math.PI) / 4f;
126 static readonly float PIOverTwo = ((float)Math.PI) / 2f; 126 static readonly float PIOverTwo = ((float)Math.PI) / 2f;
127 127
128 // For debugging, flags to turn on and off individual corrections.
129 public bool enableAngularVerticalAttraction;
130 public bool enableAngularDeflection;
131 public bool enableAngularBanking;
132
133 public BSDynamics(BSScene myScene, BSPrim myPrim, string actorName) 128 public BSDynamics(BSScene myScene, BSPrim myPrim, string actorName)
134 : base(myScene, myPrim, actorName) 129 : base(myScene, myPrim, actorName)
135 { 130 {
136 ControllingPrim = myPrim; 131 ControllingPrim = myPrim;
137 Type = Vehicle.TYPE_NONE; 132 Type = Vehicle.TYPE_NONE;
138 m_haveRegisteredForSceneEvents = false; 133 m_haveRegisteredForSceneEvents = false;
139 SetupVehicleDebugging();
140 }
141
142 // Stopgap debugging enablement. Allows source level debugging but still checking
143 // in changes by making enablement of debugging flags from INI file.
144 public void SetupVehicleDebugging()
145 {
146 enableAngularVerticalAttraction = true;
147 enableAngularDeflection = false;
148 enableAngularBanking = true;
149 if (BSParam.VehicleDebuggingEnable)
150 {
151 enableAngularVerticalAttraction = true;
152 enableAngularDeflection = false;
153 enableAngularBanking = false;
154 }
155 } 134 }
156 135
157 // Return 'true' if this vehicle is doing vehicle things 136 // Return 'true' if this vehicle is doing vehicle things
@@ -173,7 +152,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
173 switch (pParam) 152 switch (pParam)
174 { 153 {
175 case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: 154 case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY:
176 m_angularDeflectionEfficiency = Math.Max(pValue, 0.01f); 155 m_angularDeflectionEfficiency = ClampInRange(0f, pValue, 1f);
177 break; 156 break;
178 case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: 157 case Vehicle.ANGULAR_DEFLECTION_TIMESCALE:
179 m_angularDeflectionTimescale = Math.Max(pValue, 0.01f); 158 m_angularDeflectionTimescale = Math.Max(pValue, 0.01f);
@@ -556,10 +535,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
556 } 535 }
557 536
558 m_linearMotor = new BSVMotor("LinearMotor", m_linearMotorTimescale, m_linearMotorDecayTimescale, 1f); 537 m_linearMotor = new BSVMotor("LinearMotor", m_linearMotorTimescale, m_linearMotorDecayTimescale, 1f);
559 m_linearMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG DEBUG (enables detail logging) 538 // m_linearMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG DEBUG (enables detail logging)
560 539
561 m_angularMotor = new BSVMotor("AngularMotor", m_angularMotorTimescale, m_angularMotorDecayTimescale, 1f); 540 m_angularMotor = new BSVMotor("AngularMotor", m_angularMotorTimescale, m_angularMotorDecayTimescale, 1f);
562 m_angularMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG DEBUG (enables detail logging) 541 // m_angularMotor.PhysicsScene = m_physicsScene; // DEBUG DEBUG DEBUG (enables detail logging)
563 542
564 /* Not implemented 543 /* Not implemented
565 m_verticalAttractionMotor = new BSVMotor("VerticalAttraction", m_verticalAttractionTimescale, 544 m_verticalAttractionMotor = new BSVMotor("VerticalAttraction", m_verticalAttractionTimescale,
@@ -774,7 +753,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
774 753
775 // Since the computation of terrain height can be a little involved, this routine 754 // Since the computation of terrain height can be a little involved, this routine
776 // is used to fetch the height only once for each vehicle simulation step. 755 // is used to fetch the height only once for each vehicle simulation step.
777 Vector3 lastRememberedHeightPos; 756 Vector3 lastRememberedHeightPos = new Vector3(-1, -1, -1);
778 private float GetTerrainHeight(Vector3 pos) 757 private float GetTerrainHeight(Vector3 pos)
779 { 758 {
780 if ((m_knownHas & m_knownChangedTerrainHeight) == 0 || pos != lastRememberedHeightPos) 759 if ((m_knownHas & m_knownChangedTerrainHeight) == 0 || pos != lastRememberedHeightPos)
@@ -788,14 +767,16 @@ namespace OpenSim.Region.Physics.BulletSPlugin
788 767
789 // Since the computation of water level can be a little involved, this routine 768 // Since the computation of water level can be a little involved, this routine
790 // is used ot fetch the level only once for each vehicle simulation step. 769 // is used ot fetch the level only once for each vehicle simulation step.
770 Vector3 lastRememberedWaterHeightPos = new Vector3(-1, -1, -1);
791 private float GetWaterLevel(Vector3 pos) 771 private float GetWaterLevel(Vector3 pos)
792 { 772 {
793 if ((m_knownHas & m_knownChangedWaterLevel) == 0) 773 if ((m_knownHas & m_knownChangedWaterLevel) == 0 || pos != lastRememberedWaterHeightPos)
794 { 774 {
775 lastRememberedWaterHeightPos = pos;
795 m_knownWaterLevel = ControllingPrim.PhysScene.TerrainManager.GetWaterLevelAtXYZ(pos); 776 m_knownWaterLevel = ControllingPrim.PhysScene.TerrainManager.GetWaterLevelAtXYZ(pos);
796 m_knownHas |= m_knownChangedWaterLevel; 777 m_knownHas |= m_knownChangedWaterLevel;
797 } 778 }
798 return (float)m_knownWaterLevel; 779 return m_knownWaterLevel;
799 } 780 }
800 781
801 private Vector3 VehiclePosition 782 private Vector3 VehiclePosition
@@ -924,6 +905,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
924 return VehicleVelocity * Quaternion.Inverse(Quaternion.Normalize(VehicleOrientation)); 905 return VehicleVelocity * Quaternion.Inverse(Quaternion.Normalize(VehicleOrientation));
925 } 906 }
926 } 907 }
908
927 private float VehicleForwardSpeed 909 private float VehicleForwardSpeed
928 { 910 {
929 get 911 get
@@ -991,11 +973,17 @@ namespace OpenSim.Region.Physics.BulletSPlugin
991 { 973 {
992 Vector3 vel = VehicleVelocity; 974 Vector3 vel = VehicleVelocity;
993 if ((m_flags & (VehicleFlag.NO_X)) != 0) 975 if ((m_flags & (VehicleFlag.NO_X)) != 0)
976 {
994 vel.X = 0; 977 vel.X = 0;
978 }
995 if ((m_flags & (VehicleFlag.NO_Y)) != 0) 979 if ((m_flags & (VehicleFlag.NO_Y)) != 0)
980 {
996 vel.Y = 0; 981 vel.Y = 0;
982 }
997 if ((m_flags & (VehicleFlag.NO_Z)) != 0) 983 if ((m_flags & (VehicleFlag.NO_Z)) != 0)
984 {
998 vel.Z = 0; 985 vel.Z = 0;
986 }
999 VehicleVelocity = vel; 987 VehicleVelocity = vel;
1000 } 988 }
1001 989
@@ -1053,26 +1041,37 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1053 Vector3 linearDeflectionV = Vector3.Zero; 1041 Vector3 linearDeflectionV = Vector3.Zero;
1054 Vector3 velocityV = VehicleForwardVelocity; 1042 Vector3 velocityV = VehicleForwardVelocity;
1055 1043
1056 // Velocity in Y and Z dimensions is movement to the side or turning. 1044 if (BSParam.VehicleEnableLinearDeflection)
1057 // Compute deflection factor from the to the side and rotational velocity 1045 {
1058 linearDeflectionV.Y = SortedClampInRange(0, (velocityV.Y * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Y); 1046 // Velocity in Y and Z dimensions is movement to the side or turning.
1059 linearDeflectionV.Z = SortedClampInRange(0, (velocityV.Z * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Z); 1047 // Compute deflection factor from the to the side and rotational velocity
1048 linearDeflectionV.Y = SortedClampInRange(0, (velocityV.Y * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Y);
1049 linearDeflectionV.Z = SortedClampInRange(0, (velocityV.Z * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Z);
1060 1050
1061 // Velocity to the side and around is corrected and moved into the forward direction 1051 // Velocity to the side and around is corrected and moved into the forward direction
1062 linearDeflectionV.X += Math.Abs(linearDeflectionV.Y); 1052 linearDeflectionV.X += Math.Abs(linearDeflectionV.Y);
1063 linearDeflectionV.X += Math.Abs(linearDeflectionV.Z); 1053 linearDeflectionV.X += Math.Abs(linearDeflectionV.Z);
1064 1054
1065 // Scale the deflection to the fractional simulation time 1055 // Scale the deflection to the fractional simulation time
1066 linearDeflectionV *= pTimestep; 1056 linearDeflectionV *= pTimestep;
1067 1057
1068 // Subtract the sideways and rotational velocity deflection factors while adding the correction forward 1058 // Subtract the sideways and rotational velocity deflection factors while adding the correction forward
1069 linearDeflectionV *= new Vector3(1,-1,-1); 1059 linearDeflectionV *= new Vector3(1, -1, -1);
1060
1061 // Correction is vehicle relative. Convert to world coordinates.
1062 Vector3 linearDeflectionW = linearDeflectionV * VehicleOrientation;
1063
1064 // Optionally, if not colliding, don't effect world downward velocity. Let falling things fall.
1065 if (BSParam.VehicleLinearDeflectionNotCollidingNoZ && !m_controllingPrim.IsColliding)
1066 {
1067 linearDeflectionW.Z = 0f;
1068 }
1070 1069
1071 // Correciont is vehicle relative. Convert to world coordinates and add to the velocity 1070 VehicleVelocity += linearDeflectionW;
1072 VehicleVelocity += linearDeflectionV * VehicleOrientation;
1073 1071
1074 VDetailLog("{0}, MoveLinear,LinearDeflection,linDefEff={1},linDefTS={2},linDeflectionV={3}", 1072 VDetailLog("{0}, MoveLinear,LinearDeflection,linDefEff={1},linDefTS={2},linDeflectionV={3}",
1075 ControllingPrim.LocalID, m_linearDeflectionEfficiency, m_linearDeflectionTimescale, linearDeflectionV); 1073 ControllingPrim.LocalID, m_linearDeflectionEfficiency, m_linearDeflectionTimescale, linearDeflectionV);
1074 }
1076 } 1075 }
1077 1076
1078 public void ComputeLinearTerrainHeightCorrection(float pTimestep) 1077 public void ComputeLinearTerrainHeightCorrection(float pTimestep)
@@ -1385,116 +1384,134 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1385 { 1384 {
1386 1385
1387 // If vertical attaction timescale is reasonable 1386 // If vertical attaction timescale is reasonable
1388 if (enableAngularVerticalAttraction && m_verticalAttractionTimescale < m_verticalAttractionCutoff) 1387 if (BSParam.VehicleEnableAngularVerticalAttraction && m_verticalAttractionTimescale < m_verticalAttractionCutoff)
1389 { 1388 {
1390 //Another formula to try got from : 1389 Vector3 vehicleUpAxis = Vector3.UnitZ * VehicleOrientation;
1391 //http://answers.unity3d.com/questions/10425/how-to-stabilize-angular-motion-alignment-of-hover.html 1390 switch (BSParam.VehicleAngularVerticalAttractionAlgorithm)
1392
1393 Vector3 VehicleUpAxis = Vector3.UnitZ * VehicleOrientation;
1394
1395 // Flipping what was originally a timescale into a speed variable and then multiplying it by 2
1396 // since only computing half the distance between the angles.
1397 float VerticalAttractionSpeed = (1 / m_verticalAttractionTimescale) * 2.0f;
1398
1399 // Make a prediction of where the up axis will be when this is applied rather then where it is now as
1400 // this makes for a smoother adjustment and less fighting between the various forces.
1401 Vector3 predictedUp = VehicleUpAxis * Quaternion.CreateFromAxisAngle(VehicleRotationalVelocity, 0f);
1402
1403 // This is only half the distance to the target so it will take 2 seconds to complete the turn.
1404 Vector3 torqueVector = Vector3.Cross(predictedUp, Vector3.UnitZ);
1405
1406 // Scale vector by our timescale since it is an acceleration it is r/s^2 or radians a timescale squared
1407 Vector3 vertContributionV = torqueVector * VerticalAttractionSpeed * VerticalAttractionSpeed;
1408
1409 VehicleRotationalVelocity += vertContributionV;
1410
1411 VDetailLog("{0}, MoveAngular,verticalAttraction,UpAxis={1},PredictedUp={2},torqueVector={3},contrib={4}",
1412 ControllingPrim.LocalID,
1413 VehicleUpAxis,
1414 predictedUp,
1415 torqueVector,
1416 vertContributionV);
1417 //=====================================================================
1418 /*
1419 // Possible solution derived from a discussion at:
1420 // http://stackoverflow.com/questions/14939657/computing-vector-from-quaternion-works-computing-quaternion-from-vector-does-no
1421
1422 // Create a rotation that is only the vehicle's rotation around Z
1423 Vector3 currentEuler = Vector3.Zero;
1424 VehicleOrientation.GetEulerAngles(out currentEuler.X, out currentEuler.Y, out currentEuler.Z);
1425 Quaternion justZOrientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, currentEuler.Z);
1426
1427 // Create the axis that is perpendicular to the up vector and the rotated up vector.
1428 Vector3 differenceAxis = Vector3.Cross(Vector3.UnitZ * justZOrientation, Vector3.UnitZ * VehicleOrientation);
1429 // Compute the angle between those to vectors.
1430 double differenceAngle = Math.Acos((double)Vector3.Dot(Vector3.UnitZ, Vector3.Normalize(Vector3.UnitZ * VehicleOrientation)));
1431 // 'differenceAngle' is the angle to rotate and 'differenceAxis' is the plane to rotate in to get the vehicle vertical
1432
1433 // Reduce the change by the time period it is to change in. Timestep is handled when velocity is applied.
1434 // TODO: add 'efficiency'.
1435 differenceAngle /= m_verticalAttractionTimescale;
1436
1437 // Create the quaterian representing the correction angle
1438 Quaternion correctionRotation = Quaternion.CreateFromAxisAngle(differenceAxis, (float)differenceAngle);
1439
1440 // Turn that quaternion into Euler values to make it into velocities to apply.
1441 Vector3 vertContributionV = Vector3.Zero;
1442 correctionRotation.GetEulerAngles(out vertContributionV.X, out vertContributionV.Y, out vertContributionV.Z);
1443 vertContributionV *= -1f;
1444
1445 VehicleRotationalVelocity += vertContributionV;
1446
1447 VDetailLog("{0}, MoveAngular,verticalAttraction,diffAxis={1},diffAng={2},corrRot={3},contrib={4}",
1448 ControllingPrim.LocalID,
1449 differenceAxis,
1450 differenceAngle,
1451 correctionRotation,
1452 vertContributionV);
1453 */
1454
1455 // ===================================================================
1456 /*
1457 Vector3 vertContributionV = Vector3.Zero;
1458 Vector3 origRotVelW = VehicleRotationalVelocity; // DEBUG DEBUG
1459
1460 // Take a vector pointing up and convert it from world to vehicle relative coords.
1461 Vector3 verticalError = Vector3.Normalize(Vector3.UnitZ * VehicleOrientation);
1462
1463 // If vertical attraction correction is needed, the vector that was pointing up (UnitZ)
1464 // is now:
1465 // leaning to one side: rotated around the X axis with the Y value going
1466 // from zero (nearly straight up) to one (completely to the side)) or
1467 // leaning front-to-back: rotated around the Y axis with the value of X being between
1468 // zero and one.
1469 // The value of Z is how far the rotation is off with 1 meaning none and 0 being 90 degrees.
1470
1471 // Y error means needed rotation around X axis and visa versa.
1472 // Since the error goes from zero to one, the asin is the corresponding angle.
1473 vertContributionV.X = (float)Math.Asin(verticalError.Y);
1474 // (Tilt forward (positive X) needs to tilt back (rotate negative) around Y axis.)
1475 vertContributionV.Y = -(float)Math.Asin(verticalError.X);
1476
1477 // If verticalError.Z is negative, the vehicle is upside down. Add additional push.
1478 if (verticalError.Z < 0f)
1479 { 1391 {
1480 vertContributionV.X += Math.Sign(vertContributionV.X) * PIOverFour; 1392 case 0:
1481 // vertContribution.Y -= PIOverFour; 1393 {
1394 //Another formula to try got from :
1395 //http://answers.unity3d.com/questions/10425/how-to-stabilize-angular-motion-alignment-of-hover.html
1396
1397 // Flipping what was originally a timescale into a speed variable and then multiplying it by 2
1398 // since only computing half the distance between the angles.
1399 float VerticalAttractionSpeed = (1 / m_verticalAttractionTimescale) * 2.0f;
1400
1401 // Make a prediction of where the up axis will be when this is applied rather then where it is now as
1402 // this makes for a smoother adjustment and less fighting between the various forces.
1403 Vector3 predictedUp = vehicleUpAxis * Quaternion.CreateFromAxisAngle(VehicleRotationalVelocity, 0f);
1404
1405 // This is only half the distance to the target so it will take 2 seconds to complete the turn.
1406 Vector3 torqueVector = Vector3.Cross(predictedUp, Vector3.UnitZ);
1407
1408 // Scale vector by our timescale since it is an acceleration it is r/s^2 or radians a timescale squared
1409 Vector3 vertContributionV = torqueVector * VerticalAttractionSpeed * VerticalAttractionSpeed;
1410
1411 VehicleRotationalVelocity += vertContributionV;
1412
1413 VDetailLog("{0}, MoveAngular,verticalAttraction,upAxis={1},PredictedUp={2},torqueVector={3},contrib={4}",
1414 ControllingPrim.LocalID,
1415 vehicleUpAxis,
1416 predictedUp,
1417 torqueVector,
1418 vertContributionV);
1419 break;
1420 }
1421 case 1:
1422 {
1423 // Possible solution derived from a discussion at:
1424 // http://stackoverflow.com/questions/14939657/computing-vector-from-quaternion-works-computing-quaternion-from-vector-does-no
1425
1426 // Create a rotation that is only the vehicle's rotation around Z
1427 Vector3 currentEuler = Vector3.Zero;
1428 VehicleOrientation.GetEulerAngles(out currentEuler.X, out currentEuler.Y, out currentEuler.Z);
1429 Quaternion justZOrientation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, currentEuler.Z);
1430
1431 // Create the axis that is perpendicular to the up vector and the rotated up vector.
1432 Vector3 differenceAxis = Vector3.Cross(Vector3.UnitZ * justZOrientation, Vector3.UnitZ * VehicleOrientation);
1433 // Compute the angle between those to vectors.
1434 double differenceAngle = Math.Acos((double)Vector3.Dot(Vector3.UnitZ, Vector3.Normalize(Vector3.UnitZ * VehicleOrientation)));
1435 // 'differenceAngle' is the angle to rotate and 'differenceAxis' is the plane to rotate in to get the vehicle vertical
1436
1437 // Reduce the change by the time period it is to change in. Timestep is handled when velocity is applied.
1438 // TODO: add 'efficiency'.
1439 differenceAngle /= m_verticalAttractionTimescale;
1440
1441 // Create the quaterian representing the correction angle
1442 Quaternion correctionRotation = Quaternion.CreateFromAxisAngle(differenceAxis, (float)differenceAngle);
1443
1444 // Turn that quaternion into Euler values to make it into velocities to apply.
1445 Vector3 vertContributionV = Vector3.Zero;
1446 correctionRotation.GetEulerAngles(out vertContributionV.X, out vertContributionV.Y, out vertContributionV.Z);
1447 vertContributionV *= -1f;
1448
1449 VehicleRotationalVelocity += vertContributionV;
1450
1451 VDetailLog("{0}, MoveAngular,verticalAttraction,upAxis={1},diffAxis={2},diffAng={3},corrRot={4},contrib={5}",
1452 ControllingPrim.LocalID,
1453 vehicleUpAxis,
1454 differenceAxis,
1455 differenceAngle,
1456 correctionRotation,
1457 vertContributionV);
1458 break;
1459 }
1460 case 2:
1461 {
1462 Vector3 vertContributionV = Vector3.Zero;
1463 Vector3 origRotVelW = VehicleRotationalVelocity; // DEBUG DEBUG
1464
1465 // Take a vector pointing up and convert it from world to vehicle relative coords.
1466 Vector3 verticalError = Vector3.Normalize(Vector3.UnitZ * VehicleOrientation);
1467
1468 // If vertical attraction correction is needed, the vector that was pointing up (UnitZ)
1469 // is now:
1470 // leaning to one side: rotated around the X axis with the Y value going
1471 // from zero (nearly straight up) to one (completely to the side)) or
1472 // leaning front-to-back: rotated around the Y axis with the value of X being between
1473 // zero and one.
1474 // The value of Z is how far the rotation is off with 1 meaning none and 0 being 90 degrees.
1475
1476 // Y error means needed rotation around X axis and visa versa.
1477 // Since the error goes from zero to one, the asin is the corresponding angle.
1478 vertContributionV.X = (float)Math.Asin(verticalError.Y);
1479 // (Tilt forward (positive X) needs to tilt back (rotate negative) around Y axis.)
1480 vertContributionV.Y = -(float)Math.Asin(verticalError.X);
1481
1482 // If verticalError.Z is negative, the vehicle is upside down. Add additional push.
1483 if (verticalError.Z < 0f)
1484 {
1485 vertContributionV.X += Math.Sign(vertContributionV.X) * PIOverFour;
1486 // vertContribution.Y -= PIOverFour;
1487 }
1488
1489 // 'vertContrbution' is now the necessary angular correction to correct tilt in one second.
1490 // Correction happens over a number of seconds.
1491 Vector3 unscaledContribVerticalErrorV = vertContributionV; // DEBUG DEBUG
1492
1493 // The correction happens over the user's time period
1494 vertContributionV /= m_verticalAttractionTimescale;
1495
1496 // Rotate the vehicle rotation to the world coordinates.
1497 VehicleRotationalVelocity += (vertContributionV * VehicleOrientation);
1498
1499 VDetailLog("{0}, MoveAngular,verticalAttraction,,upAxis={1},origRotVW={2},vertError={3},unscaledV={4},eff={5},ts={6},vertContribV={7}",
1500 ControllingPrim.LocalID,
1501 vehicleUpAxis,
1502 origRotVelW,
1503 verticalError,
1504 unscaledContribVerticalErrorV,
1505 m_verticalAttractionEfficiency,
1506 m_verticalAttractionTimescale,
1507 vertContributionV);
1508 break;
1509 }
1510 default:
1511 {
1512 break;
1513 }
1482 } 1514 }
1483
1484 // 'vertContrbution' is now the necessary angular correction to correct tilt in one second.
1485 // Correction happens over a number of seconds.
1486 Vector3 unscaledContribVerticalErrorV = vertContributionV; // DEBUG DEBUG
1487
1488 // The correction happens over the user's time period
1489 vertContributionV /= m_verticalAttractionTimescale;
1490
1491 // Rotate the vehicle rotation to the world coordinates.
1492 VehicleRotationalVelocity += (vertContributionV * VehicleOrientation);
1493
1494 VDetailLog("{0}, MoveAngular,verticalAttraction,,origRotVW={1},vertError={2},unscaledV={3},eff={4},ts={5},vertContribV={6}",
1495 Prim.LocalID, origRotVelW, verticalError, unscaledContribVerticalErrorV,
1496 m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContributionV);
1497 */
1498 } 1515 }
1499 } 1516 }
1500 1517
@@ -1504,13 +1521,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1504 // in that direction. 1521 // in that direction.
1505 // TODO: implement reference frame. 1522 // TODO: implement reference frame.
1506 public void ComputeAngularDeflection() 1523 public void ComputeAngularDeflection()
1507 { 1524 {
1508 // Since angularMotorUp and angularDeflection are computed independently, they will calculate
1509 // approximately the same X or Y correction. When added together (when contributions are combined)
1510 // this creates an over-correction and then wabbling as the target is overshot.
1511 // TODO: rethink how the different correction computations inter-relate.
1512 1525
1513 if (enableAngularDeflection && m_angularDeflectionEfficiency != 0 && VehicleForwardSpeed > 0.2) 1526 if (BSParam.VehicleEnableAngularDeflection && m_angularDeflectionEfficiency != 0 && VehicleForwardSpeed > 0.2)
1514 { 1527 {
1515 Vector3 deflectContributionV = Vector3.Zero; 1528 Vector3 deflectContributionV = Vector3.Zero;
1516 1529
@@ -1523,10 +1536,14 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1523 1536
1524 // The direction the vehicle is pointing 1537 // The direction the vehicle is pointing
1525 Vector3 pointingDirection = Vector3.UnitX * VehicleOrientation; 1538 Vector3 pointingDirection = Vector3.UnitX * VehicleOrientation;
1526 pointingDirection.Normalize(); 1539 //Predict where the Vehicle will be pointing after AngularVelocity change is applied. This will keep
1540 // from overshooting and allow this correction to merge with the Vertical Attraction peacefully.
1541 Vector3 predictedPointingDirection = pointingDirection * Quaternion.CreateFromAxisAngle(VehicleRotationalVelocity, 0f);
1542 predictedPointingDirection.Normalize();
1527 1543
1528 // The difference between what is and what should be. 1544 // The difference between what is and what should be.
1529 Vector3 deflectionError = movingDirection - pointingDirection; 1545 // Vector3 deflectionError = movingDirection - predictedPointingDirection;
1546 Vector3 deflectionError = Vector3.Cross(movingDirection, predictedPointingDirection);
1530 1547
1531 // Don't try to correct very large errors (not our job) 1548 // Don't try to correct very large errors (not our job)
1532 // if (Math.Abs(deflectionError.X) > PIOverFour) deflectionError.X = PIOverTwo * Math.Sign(deflectionError.X); 1549 // if (Math.Abs(deflectionError.X) > PIOverFour) deflectionError.X = PIOverTwo * Math.Sign(deflectionError.X);
@@ -1539,15 +1556,16 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1539 // ret = m_angularDeflectionCorrectionMotor(1f, deflectionError); 1556 // ret = m_angularDeflectionCorrectionMotor(1f, deflectionError);
1540 1557
1541 // Scale the correction by recovery timescale and efficiency 1558 // Scale the correction by recovery timescale and efficiency
1542 deflectContributionV = (-deflectionError) * m_angularDeflectionEfficiency; 1559 // Not modeling a spring so clamp the scale to no more then the arc
1543 deflectContributionV /= m_angularDeflectionTimescale; 1560 deflectContributionV = (-deflectionError) * ClampInRange(0, m_angularDeflectionEfficiency/m_angularDeflectionTimescale,1f);
1544 1561 //deflectContributionV /= m_angularDeflectionTimescale;
1545 VehicleRotationalVelocity += deflectContributionV * VehicleOrientation;
1546 1562
1563 // VehicleRotationalVelocity += deflectContributionV * VehicleOrientation;
1564 VehicleRotationalVelocity += deflectContributionV;
1547 VDetailLog("{0}, MoveAngular,Deflection,movingDir={1},pointingDir={2},deflectError={3},ret={4}", 1565 VDetailLog("{0}, MoveAngular,Deflection,movingDir={1},pointingDir={2},deflectError={3},ret={4}",
1548 ControllingPrim.LocalID, movingDirection, pointingDirection, deflectionError, deflectContributionV); 1566 ControllingPrim.LocalID, movingDirection, pointingDirection, deflectionError, deflectContributionV);
1549 VDetailLog("{0}, MoveAngular,Deflection,fwdSpd={1},defEff={2},defTS={3}", 1567 VDetailLog("{0}, MoveAngular,Deflection,fwdSpd={1},defEff={2},defTS={3},PredictedPointingDir={4}",
1550 ControllingPrim.LocalID, VehicleForwardSpeed, m_angularDeflectionEfficiency, m_angularDeflectionTimescale); 1568 ControllingPrim.LocalID, VehicleForwardSpeed, m_angularDeflectionEfficiency, m_angularDeflectionTimescale, predictedPointingDirection);
1551 } 1569 }
1552 } 1570 }
1553 1571
@@ -1584,7 +1602,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1584 // make a sluggish vehicle by giving it a timescale of several seconds. 1602 // make a sluggish vehicle by giving it a timescale of several seconds.
1585 public void ComputeAngularBanking() 1603 public void ComputeAngularBanking()
1586 { 1604 {
1587 if (enableAngularBanking && m_bankingEfficiency != 0 && m_verticalAttractionTimescale < m_verticalAttractionCutoff) 1605 if (BSParam.VehicleEnableAngularBanking && m_bankingEfficiency != 0 && m_verticalAttractionTimescale < m_verticalAttractionCutoff)
1588 { 1606 {
1589 Vector3 bankingContributionV = Vector3.Zero; 1607 Vector3 bankingContributionV = Vector3.Zero;
1590 1608
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 308cf13..1d94142 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -35,62 +35,6 @@ using OMV = OpenMetaverse;
35namespace OpenSim.Region.Physics.BulletSPlugin 35namespace OpenSim.Region.Physics.BulletSPlugin
36{ 36{
37 37
38 /*
39// When a child is linked, the relationship position of the child to the parent
40// is remembered so the child's world position can be recomputed when it is
41// removed from the linkset.
42sealed class BSLinksetCompoundInfo : BSLinksetInfo
43{
44 public int Index;
45 public OMV.Vector3 OffsetFromRoot;
46 public OMV.Vector3 OffsetFromCenterOfMass;
47 public OMV.Quaternion OffsetRot;
48 public BSLinksetCompoundInfo(int indx, OMV.Vector3 p, OMV.Quaternion r)
49 {
50 Index = indx;
51 OffsetFromRoot = p;
52 OffsetFromCenterOfMass = p;
53 OffsetRot = r;
54 }
55 // 'centerDisplacement' is the distance from the root the the center-of-mass (Bullet 'zero' of the shape)
56 public BSLinksetCompoundInfo(int indx, BSPrimLinkable root, BSPrimLinkable child, OMV.Vector3 centerDisplacement)
57 {
58 // Each child position and rotation is given relative to the center-of-mass.
59 OMV.Quaternion invRootOrientation = OMV.Quaternion.Inverse(root.RawOrientation);
60 OMV.Vector3 displacementFromRoot = (child.RawPosition - root.RawPosition) * invRootOrientation;
61 OMV.Vector3 displacementFromCOM = displacementFromRoot - centerDisplacement;
62 OMV.Quaternion displacementRot = child.RawOrientation * invRootOrientation;
63
64 // Save relative position for recomputing child's world position after moving linkset.
65 Index = indx;
66 OffsetFromRoot = displacementFromRoot;
67 OffsetFromCenterOfMass = displacementFromCOM;
68 OffsetRot = displacementRot;
69 }
70 public override void Clear()
71 {
72 Index = 0;
73 OffsetFromRoot = OMV.Vector3.Zero;
74 OffsetFromCenterOfMass = OMV.Vector3.Zero;
75 OffsetRot = OMV.Quaternion.Identity;
76 }
77 public override string ToString()
78 {
79 StringBuilder buff = new StringBuilder();
80 buff.Append("<i=");
81 buff.Append(Index.ToString());
82 buff.Append(",p=");
83 buff.Append(OffsetFromRoot.ToString());
84 buff.Append(",m=");
85 buff.Append(OffsetFromCenterOfMass.ToString());
86 buff.Append(",r=");
87 buff.Append(OffsetRot.ToString());
88 buff.Append(">");
89 return buff.ToString();
90 }
91};
92 */
93
94public sealed class BSLinksetCompound : BSLinkset 38public sealed class BSLinksetCompound : BSLinkset
95{ 39{
96 private static string LogHeader = "[BULLETSIM LINKSET COMPOUND]"; 40 private static string LogHeader = "[BULLETSIM LINKSET COMPOUND]";
@@ -151,7 +95,9 @@ public sealed class BSLinksetCompound : BSLinkset
151 public override bool MakeStatic(BSPrimLinkable child) 95 public override bool MakeStatic(BSPrimLinkable child)
152 { 96 {
153 bool ret = false; 97 bool ret = false;
98
154 DetailLog("{0},BSLinksetCompound.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child)); 99 DetailLog("{0},BSLinksetCompound.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child));
100 child.ClearDisplacement();
155 if (IsRoot(child)) 101 if (IsRoot(child))
156 { 102 {
157 // Schedule a rebuild to verify that the root shape is set to the real shape. 103 // Schedule a rebuild to verify that the root shape is set to the real shape.
@@ -315,7 +261,6 @@ public sealed class BSLinksetCompound : BSLinkset
315 // Note that this works for rebuilding just the root after a linkset is taken apart. 261 // Note that this works for rebuilding just the root after a linkset is taken apart.
316 // Called at taint time!! 262 // Called at taint time!!
317 private bool UseBulletSimRootOffsetHack = false; // Attempt to have Bullet track the coords of root compound shape 263 private bool UseBulletSimRootOffsetHack = false; // Attempt to have Bullet track the coords of root compound shape
318 private bool disableCOM = true; // For basic linkset debugging, turn off the center-of-mass setting
319 private void RecomputeLinksetCompound() 264 private void RecomputeLinksetCompound()
320 { 265 {
321 try 266 try
@@ -326,55 +271,70 @@ public sealed class BSLinksetCompound : BSLinkset
326 // to what they should be as if the root was not in a linkset. 271 // to what they should be as if the root was not in a linkset.
327 // Not that bad since we only get into this routine if there are children in the linkset and 272 // Not that bad since we only get into this routine if there are children in the linkset and
328 // something has been updated/changed. 273 // something has been updated/changed.
274 // Have to do the rebuild before checking for physical because this might be a linkset
275 // being destructed and going non-physical.
329 LinksetRoot.ForceBodyShapeRebuild(true); 276 LinksetRoot.ForceBodyShapeRebuild(true);
330 277
331 // There is no reason to build all this physical stuff for a non-physical linkset. 278 // There is no reason to build all this physical stuff for a non-physical linkset.
332 if (!LinksetRoot.IsPhysicallyActive) 279 if (!LinksetRoot.IsPhysicallyActive)
333 { 280 {
334 // Clean up any old linkset shape and make sure the root shape is set to the root object.
335 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID); 281 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,notPhysical", LinksetRoot.LocalID);
336
337 return; // Note the 'finally' clause at the botton which will get executed. 282 return; // Note the 'finally' clause at the botton which will get executed.
338 } 283 }
339 284
340 // Get a new compound shape to build the linkset shape in. 285 // Get a new compound shape to build the linkset shape in.
341 BSShape linksetShape = BSShapeCompound.GetReference(m_physicsScene); 286 BSShape linksetShape = BSShapeCompound.GetReference(m_physicsScene);
342 287
343 // The center of mass for the linkset is the geometric center of the group.
344 // Compute a displacement for each component so it is relative to the center-of-mass. 288 // Compute a displacement for each component so it is relative to the center-of-mass.
345 // Bullet presumes an object's origin (relative <0,0,0>) is its center-of-mass 289 // Bullet presumes an object's origin (relative <0,0,0>) is its center-of-mass
346 OMV.Vector3 centerOfMassW = ComputeLinksetCenterOfMass(); 290 OMV.Vector3 centerOfMassW = ComputeLinksetCenterOfMass();
347 291
348 OMV.Quaternion invRootOrientation = OMV.Quaternion.Normalize(OMV.Quaternion.Inverse(LinksetRoot.RawOrientation)); 292 OMV.Quaternion invRootOrientation = OMV.Quaternion.Normalize(OMV.Quaternion.Inverse(LinksetRoot.RawOrientation));
293 OMV.Vector3 origRootPosition = LinksetRoot.RawPosition;
349 294
350 // 'centerDisplacement' is the value to subtract from children to give physical offset position 295 // 'centerDisplacementV' is the vehicle relative distance from the simulator root position to the center-of-mass
351 OMV.Vector3 centerDisplacementV = (centerOfMassW - LinksetRoot.RawPosition) * invRootOrientation; 296 OMV.Vector3 centerDisplacementV = (centerOfMassW - LinksetRoot.RawPosition) * invRootOrientation;
352 if (UseBulletSimRootOffsetHack || disableCOM) 297 if (UseBulletSimRootOffsetHack || !BSParam.LinksetOffsetCenterOfMass)
353 { 298 {
299 // Zero everything if center-of-mass displacement is not being done.
354 centerDisplacementV = OMV.Vector3.Zero; 300 centerDisplacementV = OMV.Vector3.Zero;
355 LinksetRoot.ClearDisplacement(); 301 LinksetRoot.ClearDisplacement();
356 } 302 }
357 else 303 else
358 { 304 {
359 LinksetRoot.SetEffectiveCenterOfMassDisplacement(centerDisplacementV); 305 // The actual center-of-mass could have been set by the user.
306 centerDisplacementV = LinksetRoot.SetEffectiveCenterOfMassDisplacement(centerDisplacementV);
360 } 307 }
308
361 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,COM,rootPos={1},com={2},comDisp={3}", 309 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,COM,rootPos={1},com={2},comDisp={3}",
362 LinksetRoot.LocalID, LinksetRoot.RawPosition, centerOfMassW, centerDisplacementV); 310 LinksetRoot.LocalID, origRootPosition, centerOfMassW, centerDisplacementV);
363 311
364 // Add the shapes of all the components of the linkset 312 // Add the shapes of all the components of the linkset
365 int memberIndex = 1; 313 int memberIndex = 1;
366 ForEachMember(delegate(BSPrimLinkable cPrim) 314 ForEachMember(delegate(BSPrimLinkable cPrim)
367 { 315 {
368 // Root shape is always index zero. 316 if (IsRoot(cPrim))
369 cPrim.LinksetChildIndex = IsRoot(cPrim) ? 0 : memberIndex; 317 {
318 // Root shape is always index zero.
319 cPrim.LinksetChildIndex = 0;
320 }
321 else
322 {
323 cPrim.LinksetChildIndex = memberIndex;
324 memberIndex++;
325 }
370 326
371 // Get a reference to the shape of the child and add that shape to the linkset compound shape 327 // Get a reference to the shape of the child for adding of that shape to the linkset compound shape
372 BSShape childShape = cPrim.PhysShape.GetReference(m_physicsScene, cPrim); 328 BSShape childShape = cPrim.PhysShape.GetReference(m_physicsScene, cPrim);
373 OMV.Vector3 offsetPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation - centerDisplacementV; 329
330 // Offset the child shape from the center-of-mass and rotate it to vehicle relative.
331 OMV.Vector3 offsetPos = (cPrim.RawPosition - origRootPosition) * invRootOrientation - centerDisplacementV;
374 OMV.Quaternion offsetRot = OMV.Quaternion.Normalize(cPrim.RawOrientation) * invRootOrientation; 332 OMV.Quaternion offsetRot = OMV.Quaternion.Normalize(cPrim.RawOrientation) * invRootOrientation;
333
334 // Add the child shape to the compound shape being built
375 m_physicsScene.PE.AddChildShapeToCompoundShape(linksetShape.physShapeInfo, childShape.physShapeInfo, offsetPos, offsetRot); 335 m_physicsScene.PE.AddChildShapeToCompoundShape(linksetShape.physShapeInfo, childShape.physShapeInfo, offsetPos, offsetRot);
376 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addChild,indx={1},cShape={2},offPos={3},offRot={4}", 336 DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addChild,indx={1},cShape={2},offPos={3},offRot={4}",
377 LinksetRoot.LocalID, memberIndex, childShape, offsetPos, offsetRot); 337 LinksetRoot.LocalID, cPrim.LinksetChildIndex, childShape, offsetPos, offsetRot);
378 338
379 // Since we are borrowing the shape of the child, disable the origional child body 339 // Since we are borrowing the shape of the child, disable the origional child body
380 if (!IsRoot(cPrim)) 340 if (!IsRoot(cPrim))
@@ -386,8 +346,6 @@ public sealed class BSLinksetCompound : BSLinkset
386 cPrim.PhysBody.collisionType = CollisionType.LinksetChild; 346 cPrim.PhysBody.collisionType = CollisionType.LinksetChild;
387 } 347 }
388 348
389 memberIndex++;
390
391 return false; // 'false' says to move onto the next child in the list 349 return false; // 'false' says to move onto the next child in the list
392 }); 350 });
393 351
@@ -409,8 +367,9 @@ public sealed class BSLinksetCompound : BSLinkset
409 { 367 {
410 // Enable the physical position updator to return the position and rotation of the root shape. 368 // Enable the physical position updator to return the position and rotation of the root shape.
411 // This enables a feature in the C++ code to return the world coordinates of the first shape in the 369 // This enables a feature in the C++ code to return the world coordinates of the first shape in the
412 // compound shape. This eleviates the need to offset the returned physical position by the 370 // compound shape. This aleviates the need to offset the returned physical position by the
413 // center-of-mass offset. 371 // center-of-mass offset.
372 // TODO: either debug this feature or remove it.
414 m_physicsScene.PE.AddToCollisionFlags(LinksetRoot.PhysBody, CollisionFlags.BS_RETURN_ROOT_COMPOUND_SHAPE); 373 m_physicsScene.PE.AddToCollisionFlags(LinksetRoot.PhysBody, CollisionFlags.BS_RETURN_ROOT_COMPOUND_SHAPE);
415 } 374 }
416 } 375 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
index 1214703..7693195 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs
@@ -188,6 +188,8 @@ public class BSVMotor : BSMotor
188 CurrentValue = current; 188 CurrentValue = current;
189 return Step(timeStep); 189 return Step(timeStep);
190 } 190 }
191 // Given and error, computer a correction for this step.
192 // Simple scaling of the error by the timestep.
191 public virtual Vector3 StepError(float timeStep, Vector3 error) 193 public virtual Vector3 StepError(float timeStep, Vector3 error)
192 { 194 {
193 if (!Enabled) return Vector3.Zero; 195 if (!Enabled) return Vector3.Zero;
@@ -221,7 +223,7 @@ public class BSVMotor : BSMotor
221 CurrentValue, TargetValue); 223 CurrentValue, TargetValue);
222 224
223 LastError = BSMotor.InfiniteVector; 225 LastError = BSMotor.InfiniteVector;
224 while (maxOutput-- > 0 && !LastError.ApproxEquals(Vector3.Zero, ErrorZeroThreshold)) 226 while (maxOutput-- > 0 && !ErrorIsZero())
225 { 227 {
226 Vector3 lastStep = Step(timeStep); 228 Vector3 lastStep = Step(timeStep);
227 MDetailLog("{0},BSVMotor.Test,{1},cur={2},tgt={3},lastError={4},lastStep={5}", 229 MDetailLog("{0},BSVMotor.Test,{1},cur={2},tgt={3},lastError={4},lastStep={5}",
@@ -375,7 +377,6 @@ public class BSPIDVMotor : BSVMotor
375 // The factors are vectors for the three dimensions. This is the proportional of each 377 // The factors are vectors for the three dimensions. This is the proportional of each
376 // that is applied. This could be multiplied through the actual factors but it 378 // that is applied. This could be multiplied through the actual factors but it
377 // is sometimes easier to manipulate the factors and their mix separately. 379 // is sometimes easier to manipulate the factors and their mix separately.
378 // to
379 public Vector3 FactorMix; 380 public Vector3 FactorMix;
380 381
381 // Arbritrary factor range. 382 // Arbritrary factor range.
@@ -413,14 +414,14 @@ public class BSPIDVMotor : BSVMotor
413 // If efficiency is high (1f), use a factor value that moves the error value to zero with little overshoot. 414 // If efficiency is high (1f), use a factor value that moves the error value to zero with little overshoot.
414 // If efficiency is low (0f), use a factor value that overcorrects. 415 // If efficiency is low (0f), use a factor value that overcorrects.
415 // TODO: might want to vary contribution of different factor depending on efficiency. 416 // TODO: might want to vary contribution of different factor depending on efficiency.
416 float factor = ((1f - this.Efficiency) * EfficiencyHigh + EfficiencyLow) / 3f; 417 // float factor = ((1f - this.Efficiency) * EfficiencyHigh + EfficiencyLow) / 3f;
417 // float factor = (1f - this.Efficiency) * EfficiencyHigh + EfficiencyLow; 418 float factor = (1f - this.Efficiency) * EfficiencyHigh + EfficiencyLow;
418 419
419 proportionFactor = new Vector3(factor, factor, factor); 420 proportionFactor = new Vector3(factor, factor, factor);
420 integralFactor = new Vector3(factor, factor, factor); 421 integralFactor = new Vector3(factor, factor, factor);
421 derivFactor = new Vector3(factor, factor, factor); 422 derivFactor = new Vector3(factor, factor, factor);
422 423
423 MDetailLog("{0},BSPIDVMotor.setEfficiency,eff={1},factor={2}", BSScene.DetailLogZero, Efficiency, factor); 424 MDetailLog("{0}, BSPIDVMotor.setEfficiency,eff={1},factor={2}", BSScene.DetailLogZero, Efficiency, factor);
424 } 425 }
425 } 426 }
426 427
@@ -441,8 +442,8 @@ public class BSPIDVMotor : BSVMotor
441 + derivitive / TimeScale * derivFactor * FactorMix.Z 442 + derivitive / TimeScale * derivFactor * FactorMix.Z
442 ; 443 ;
443 444
444 MDetailLog("{0}, BSPIDVMotor.step,ts={1},err={2},runnInt={3},deriv={4},ret={5}", 445 MDetailLog("{0}, BSPIDVMotor.step,ts={1},err={2},lerr={3},runnInt={4},deriv={5},ret={6}",
445 BSScene.DetailLogZero, timeStep, error, RunningIntegration, derivitive, ret); 446 BSScene.DetailLogZero, timeStep, error, LastError, RunningIntegration, derivitive, ret);
446 447
447 return ret; 448 return ret;
448 } 449 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
index d17c8e7..dcf1e83 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
@@ -155,7 +155,12 @@ public static class BSParam
155 public static Vector3 VehicleInertiaFactor { get; private set; } 155 public static Vector3 VehicleInertiaFactor { get; private set; }
156 public static float VehicleGroundGravityFudge { get; private set; } 156 public static float VehicleGroundGravityFudge { get; private set; }
157 public static float VehicleAngularBankingTimescaleFudge { get; private set; } 157 public static float VehicleAngularBankingTimescaleFudge { get; private set; }
158 public static bool VehicleDebuggingEnable { get; private set; } 158 public static bool VehicleEnableLinearDeflection { get; private set; }
159 public static bool VehicleLinearDeflectionNotCollidingNoZ { get; private set; }
160 public static bool VehicleEnableAngularVerticalAttraction { get; private set; }
161 public static int VehicleAngularVerticalAttractionAlgorithm { get; private set; }
162 public static bool VehicleEnableAngularDeflection { get; private set; }
163 public static bool VehicleEnableAngularBanking { get; private set; }
159 164
160 // Convex Hulls 165 // Convex Hulls
161 public static int CSHullMaxDepthSplit { get; private set; } 166 public static int CSHullMaxDepthSplit { get; private set; }
@@ -176,6 +181,7 @@ public static class BSParam
176 181
177 // Linkset implementation parameters 182 // Linkset implementation parameters
178 public static float LinksetImplementation { get; private set; } 183 public static float LinksetImplementation { get; private set; }
184 public static bool LinksetOffsetCenterOfMass { get; private set; }
179 public static bool LinkConstraintUseFrameOffset { get; private set; } 185 public static bool LinkConstraintUseFrameOffset { get; private set; }
180 public static bool LinkConstraintEnableTransMotor { get; private set; } 186 public static bool LinkConstraintEnableTransMotor { get; private set; }
181 public static float LinkConstraintTransMotorMaxVel { get; private set; } 187 public static float LinkConstraintTransMotorMaxVel { get; private set; }
@@ -605,8 +611,18 @@ public static class BSParam
605 0.2f ), 611 0.2f ),
606 new ParameterDefn<float>("VehicleAngularBankingTimescaleFudge", "Factor to multiple angular banking timescale. Tune to increase realism.", 612 new ParameterDefn<float>("VehicleAngularBankingTimescaleFudge", "Factor to multiple angular banking timescale. Tune to increase realism.",
607 60.0f ), 613 60.0f ),
608 new ParameterDefn<bool>("VehicleDebuggingEnable", "Turn on/off vehicle debugging", 614 new ParameterDefn<bool>("VehicleEnableLinearDeflection", "Turn on/off vehicle linear deflection effect",
609 false ), 615 true ),
616 new ParameterDefn<bool>("VehicleLinearDeflectionNotCollidingNoZ", "Turn on/off linear deflection Z effect on non-colliding vehicles",
617 true ),
618 new ParameterDefn<bool>("VehicleEnableAngularVerticalAttraction", "Turn on/off vehicle angular vertical attraction effect",
619 true ),
620 new ParameterDefn<int>("VehicleAngularVerticalAttractionAlgorithm", "Select vertical attraction algo. You need to look at the source.",
621 0 ),
622 new ParameterDefn<bool>("VehicleEnableAngularDeflection", "Turn on/off vehicle angular deflection effect",
623 true ),
624 new ParameterDefn<bool>("VehicleEnableAngularBanking", "Turn on/off vehicle angular banking effect",
625 true ),
610 626
611 new ParameterDefn<float>("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default of 4096)", 627 new ParameterDefn<float>("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default of 4096)",
612 0f, 628 0f,
@@ -684,6 +700,8 @@ public static class BSParam
684 700
685 new ParameterDefn<float>("LinksetImplementation", "Type of linkset implementation (0=Constraint, 1=Compound, 2=Manual)", 701 new ParameterDefn<float>("LinksetImplementation", "Type of linkset implementation (0=Constraint, 1=Compound, 2=Manual)",
686 (float)BSLinkset.LinksetImplementation.Compound ), 702 (float)BSLinkset.LinksetImplementation.Compound ),
703 new ParameterDefn<bool>("LinksetOffsetCenterOfMass", "If 'true', compute linkset center-of-mass and offset linkset position to account for same",
704 false ),
687 new ParameterDefn<bool>("LinkConstraintUseFrameOffset", "For linksets built with constraints, enable frame offsetFor linksets built with constraints, enable frame offset.", 705 new ParameterDefn<bool>("LinkConstraintUseFrameOffset", "For linksets built with constraints, enable frame offsetFor linksets built with constraints, enable frame offset.",
688 false ), 706 false ),
689 new ParameterDefn<bool>("LinkConstraintEnableTransMotor", "Whether to enable translational motor on linkset constraints", 707 new ParameterDefn<bool>("LinkConstraintEnableTransMotor", "Whether to enable translational motor on linkset constraints",
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index a0d5c42..a41eaf8 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -90,6 +90,8 @@ public abstract class BSPhysObject : PhysicsActor
90 PhysBody = new BulletBody(localID); 90 PhysBody = new BulletBody(localID);
91 PhysShape = new BSShapeNull(); 91 PhysShape = new BSShapeNull();
92 92
93 UserSetCenterOfMassDisplacement = null;
94
93 PrimAssetState = PrimAssetCondition.Unknown; 95 PrimAssetState = PrimAssetCondition.Unknown;
94 96
95 // Default material type. Also sets Friction, Restitution and Density. 97 // Default material type. Also sets Friction, Restitution and Density.
@@ -180,6 +182,7 @@ public abstract class BSPhysObject : PhysicsActor
180 Material = (MaterialAttributes.Material)material; 182 Material = (MaterialAttributes.Material)material;
181 183
182 // Setting the material sets the material attributes also. 184 // Setting the material sets the material attributes also.
185 // TODO: decide if this is necessary -- the simulator does this.
183 MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false); 186 MaterialAttributes matAttrib = BSMaterials.GetAttributes(Material, false);
184 Friction = matAttrib.friction; 187 Friction = matAttrib.friction;
185 Restitution = matAttrib.restitution; 188 Restitution = matAttrib.restitution;
@@ -194,10 +197,10 @@ public abstract class BSPhysObject : PhysicsActor
194 // Update the physical location and motion of the object. Called with data from Bullet. 197 // Update the physical location and motion of the object. Called with data from Bullet.
195 public abstract void UpdateProperties(EntityProperties entprop); 198 public abstract void UpdateProperties(EntityProperties entprop);
196 199
197 public abstract OMV.Vector3 RawPosition { get; set; } 200 public virtual OMV.Vector3 RawPosition { get; set; }
198 public abstract OMV.Vector3 ForcePosition { get; set; } 201 public abstract OMV.Vector3 ForcePosition { get; set; }
199 202
200 public abstract OMV.Quaternion RawOrientation { get; set; } 203 public virtual OMV.Quaternion RawOrientation { get; set; }
201 public abstract OMV.Quaternion ForceOrientation { get; set; } 204 public abstract OMV.Quaternion ForceOrientation { get; set; }
202 205
203 public OMV.Vector3 RawVelocity { get; set; } 206 public OMV.Vector3 RawVelocity { get; set; }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index b2947c6..d43448e 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -51,12 +51,8 @@ public class BSPrim : BSPhysObject
51 private bool _isSelected; 51 private bool _isSelected;
52 private bool _isVolumeDetect; 52 private bool _isVolumeDetect;
53 53
54 // _position is what the simulator thinks the positions of the prim is.
55 private OMV.Vector3 _position;
56
57 private float _mass; // the mass of this object 54 private float _mass; // the mass of this object
58 private OMV.Vector3 _acceleration; 55 private OMV.Vector3 _acceleration;
59 private OMV.Quaternion _orientation;
60 private int _physicsActorType; 56 private int _physicsActorType;
61 private bool _isPhysical; 57 private bool _isPhysical;
62 private bool _flying; 58 private bool _flying;
@@ -88,10 +84,10 @@ public class BSPrim : BSPhysObject
88 { 84 {
89 // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID); 85 // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID);
90 _physicsActorType = (int)ActorTypes.Prim; 86 _physicsActorType = (int)ActorTypes.Prim;
91 _position = pos; 87 RawPosition = pos;
92 _size = size; 88 _size = size;
93 Scale = size; // prims are the size the user wants them to be (different for BSCharactes). 89 Scale = size; // prims are the size the user wants them to be (different for BSCharactes).
94 _orientation = rotation; 90 RawOrientation = rotation;
95 _buoyancy = 0f; 91 _buoyancy = 0f;
96 RawVelocity = OMV.Vector3.Zero; 92 RawVelocity = OMV.Vector3.Zero;
97 _rotationalVelocity = OMV.Vector3.Zero; 93 _rotationalVelocity = OMV.Vector3.Zero;
@@ -270,46 +266,42 @@ public class BSPrim : BSPhysObject
270 return; 266 return;
271 } 267 }
272 268
273 public override OMV.Vector3 RawPosition
274 {
275 get { return _position; }
276 set { _position = value; }
277 }
278 public override OMV.Vector3 Position { 269 public override OMV.Vector3 Position {
279 get { 270 get {
280 // don't do the GetObjectPosition for root elements because this function is called a zillion times. 271 // don't do the GetObjectPosition for root elements because this function is called a zillion times.
281 // _position = ForcePosition; 272 // RawPosition = ForcePosition;
282 return _position; 273 return RawPosition;
283 } 274 }
284 set { 275 set {
285 // If the position must be forced into the physics engine, use ForcePosition. 276 // If the position must be forced into the physics engine, use ForcePosition.
286 // All positions are given in world positions. 277 // All positions are given in world positions.
287 if (_position == value) 278 if (RawPosition == value)
288 { 279 {
289 DetailLog("{0},BSPrim.setPosition,call,positionNotChanging,pos={1},orient={2}", LocalID, _position, _orientation); 280 DetailLog("{0},BSPrim.setPosition,call,positionNotChanging,pos={1},orient={2}", LocalID, RawPosition, RawOrientation);
290 return; 281 return;
291 } 282 }
292 _position = value; 283 RawPosition = value;
293 PositionSanityCheck(false); 284 PositionSanityCheck(false);
294 285
295 PhysScene.TaintedObject("BSPrim.setPosition", delegate() 286 PhysScene.TaintedObject("BSPrim.setPosition", delegate()
296 { 287 {
297 DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); 288 DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation);
298 ForcePosition = _position; 289 ForcePosition = RawPosition;
299 }); 290 });
300 } 291 }
301 } 292 }
302 293
294 // NOTE: overloaded by BSPrimDisplaced to handle offset for center-of-gravity.
303 public override OMV.Vector3 ForcePosition { 295 public override OMV.Vector3 ForcePosition {
304 get { 296 get {
305 _position = PhysScene.PE.GetPosition(PhysBody); 297 RawPosition = PhysScene.PE.GetPosition(PhysBody);
306 return _position; 298 return RawPosition;
307 } 299 }
308 set { 300 set {
309 _position = value; 301 RawPosition = value;
310 if (PhysBody.HasPhysicalBody) 302 if (PhysBody.HasPhysicalBody)
311 { 303 {
312 PhysScene.PE.SetTranslation(PhysBody, _position, _orientation); 304 PhysScene.PE.SetTranslation(PhysBody, RawPosition, RawOrientation);
313 ActivateIfPhysical(false); 305 ActivateIfPhysical(false);
314 } 306 }
315 } 307 }
@@ -343,10 +335,10 @@ public class BSPrim : BSPhysObject
343 float targetHeight = terrainHeight + (Size.Z / 2f); 335 float targetHeight = terrainHeight + (Size.Z / 2f);
344 // If the object is below ground it just has to be moved up because pushing will 336 // If the object is below ground it just has to be moved up because pushing will
345 // not get it through the terrain 337 // not get it through the terrain
346 _position.Z = targetHeight; 338 RawPosition = new OMV.Vector3(RawPosition.X, RawPosition.Y, targetHeight);
347 if (inTaintTime) 339 if (inTaintTime)
348 { 340 {
349 ForcePosition = _position; 341 ForcePosition = RawPosition;
350 } 342 }
351 // If we are throwing the object around, zero its other forces 343 // If we are throwing the object around, zero its other forces
352 ZeroMotion(inTaintTime); 344 ZeroMotion(inTaintTime);
@@ -355,7 +347,7 @@ public class BSPrim : BSPhysObject
355 347
356 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) 348 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0)
357 { 349 {
358 float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(_position); 350 float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(RawPosition);
359 // TODO: a floating motor so object will bob in the water 351 // TODO: a floating motor so object will bob in the water
360 if (Math.Abs(RawPosition.Z - waterHeight) > 0.1f) 352 if (Math.Abs(RawPosition.Z - waterHeight) > 0.1f)
361 { 353 {
@@ -364,7 +356,7 @@ public class BSPrim : BSPhysObject
364 356
365 // Apply upforce and overcome gravity. 357 // Apply upforce and overcome gravity.
366 OMV.Vector3 correctionForce = upForce - PhysScene.DefaultGravity; 358 OMV.Vector3 correctionForce = upForce - PhysScene.DefaultGravity;
367 DetailLog("{0},BSPrim.PositionSanityCheck,applyForce,pos={1},upForce={2},correctionForce={3}", LocalID, _position, upForce, correctionForce); 359 DetailLog("{0},BSPrim.PositionSanityCheck,applyForce,pos={1},upForce={2},correctionForce={3}", LocalID, RawPosition, upForce, correctionForce);
368 AddForce(correctionForce, false, inTaintTime); 360 AddForce(correctionForce, false, inTaintTime);
369 ret = true; 361 ret = true;
370 } 362 }
@@ -383,11 +375,11 @@ public class BSPrim : BSPhysObject
383 uint wayOutThere = Constants.RegionSize * Constants.RegionSize; 375 uint wayOutThere = Constants.RegionSize * Constants.RegionSize;
384 // There have been instances of objects getting thrown way out of bounds and crashing 376 // There have been instances of objects getting thrown way out of bounds and crashing
385 // the border crossing code. 377 // the border crossing code.
386 if ( _position.X < -Constants.RegionSize || _position.X > wayOutThere 378 if ( RawPosition.X < -Constants.RegionSize || RawPosition.X > wayOutThere
387 || _position.Y < -Constants.RegionSize || _position.Y > wayOutThere 379 || RawPosition.Y < -Constants.RegionSize || RawPosition.Y > wayOutThere
388 || _position.Z < -Constants.RegionSize || _position.Z > wayOutThere) 380 || RawPosition.Z < -Constants.RegionSize || RawPosition.Z > wayOutThere)
389 { 381 {
390 _position = new OMV.Vector3(10, 10, 50); 382 RawPosition = new OMV.Vector3(10, 10, 50);
391 ZeroMotion(inTaintTime); 383 ZeroMotion(inTaintTime);
392 ret = true; 384 ret = true;
393 } 385 }
@@ -713,23 +705,19 @@ public class BSPrim : BSPhysObject
713 get { return _acceleration; } 705 get { return _acceleration; }
714 set { _acceleration = value; } 706 set { _acceleration = value; }
715 } 707 }
716 public override OMV.Quaternion RawOrientation 708
717 {
718 get { return _orientation; }
719 set { _orientation = value; }
720 }
721 public override OMV.Quaternion Orientation { 709 public override OMV.Quaternion Orientation {
722 get { 710 get {
723 return _orientation; 711 return RawOrientation;
724 } 712 }
725 set { 713 set {
726 if (_orientation == value) 714 if (RawOrientation == value)
727 return; 715 return;
728 _orientation = value; 716 RawOrientation = value;
729 717
730 PhysScene.TaintedObject("BSPrim.setOrientation", delegate() 718 PhysScene.TaintedObject("BSPrim.setOrientation", delegate()
731 { 719 {
732 ForceOrientation = _orientation; 720 ForceOrientation = RawOrientation;
733 }); 721 });
734 } 722 }
735 } 723 }
@@ -738,14 +726,14 @@ public class BSPrim : BSPhysObject
738 { 726 {
739 get 727 get
740 { 728 {
741 _orientation = PhysScene.PE.GetOrientation(PhysBody); 729 RawOrientation = PhysScene.PE.GetOrientation(PhysBody);
742 return _orientation; 730 return RawOrientation;
743 } 731 }
744 set 732 set
745 { 733 {
746 _orientation = value; 734 RawOrientation = value;
747 if (PhysBody.HasPhysicalBody) 735 if (PhysBody.HasPhysicalBody)
748 PhysScene.PE.SetTranslation(PhysBody, _position, _orientation); 736 PhysScene.PE.SetTranslation(PhysBody, RawPosition, RawOrientation);
749 } 737 }
750 } 738 }
751 public override int PhysicsActorType { 739 public override int PhysicsActorType {
@@ -802,6 +790,7 @@ public class BSPrim : BSPhysObject
802 // isSolid: other objects bounce off of this object 790 // isSolid: other objects bounce off of this object
803 // isVolumeDetect: other objects pass through but can generate collisions 791 // isVolumeDetect: other objects pass through but can generate collisions
804 // collisionEvents: whether this object returns collision events 792 // collisionEvents: whether this object returns collision events
793 // NOTE: overloaded by BSPrimLinkable to also update linkset physical parameters.
805 public virtual void UpdatePhysicalParameters() 794 public virtual void UpdatePhysicalParameters()
806 { 795 {
807 if (!PhysBody.HasPhysicalBody) 796 if (!PhysBody.HasPhysicalBody)
@@ -888,7 +877,7 @@ public class BSPrim : BSPhysObject
888 // PhysicsScene.PE.ClearAllForces(BSBody); 877 // PhysicsScene.PE.ClearAllForces(BSBody);
889 878
890 // For good measure, make sure the transform is set through to the motion state 879 // For good measure, make sure the transform is set through to the motion state
891 ForcePosition = _position; 880 ForcePosition = RawPosition;
892 ForceVelocity = RawVelocity; 881 ForceVelocity = RawVelocity;
893 ForceRotationalVelocity = _rotationalVelocity; 882 ForceRotationalVelocity = _rotationalVelocity;
894 883
@@ -1125,7 +1114,9 @@ public class BSPrim : BSPhysObject
1125 OMV.Vector3 addForce = force; 1114 OMV.Vector3 addForce = force;
1126 PhysScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() 1115 PhysScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate()
1127 { 1116 {
1128 // Bullet adds this central force to the total force for this tick 1117 // Bullet adds this central force to the total force for this tick.
1118 // Deep down in Bullet:
1119 // linearVelocity += totalForce / mass * timeStep;
1129 DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce); 1120 DetailLog("{0},BSPrim.addForce,taint,force={1}", LocalID, addForce);
1130 if (PhysBody.HasPhysicalBody) 1121 if (PhysBody.HasPhysicalBody)
1131 { 1122 {
@@ -1493,6 +1484,8 @@ public class BSPrim : BSPhysObject
1493 1484
1494 returnMass = Util.Clamp(returnMass, BSParam.MinimumObjectMass, BSParam.MaximumObjectMass); 1485 returnMass = Util.Clamp(returnMass, BSParam.MinimumObjectMass, BSParam.MaximumObjectMass);
1495 // DetailLog("{0},BSPrim.CalculateMass,den={1},vol={2},mass={3}", LocalID, Density, volume, returnMass); 1486 // DetailLog("{0},BSPrim.CalculateMass,den={1},vol={2},mass={3}", LocalID, Density, volume, returnMass);
1487 DetailLog("{0},BSPrim.CalculateMass,den={1},vol={2},mass={3},pathB={4},pathE={5},profB={6},profE={7},siz={8}",
1488 LocalID, Density, volume, returnMass, pathBegin, pathEnd, profileBegin, profileEnd, _size);
1496 1489
1497 return returnMass; 1490 return returnMass;
1498 }// end CalculateMass 1491 }// end CalculateMass
@@ -1528,6 +1521,8 @@ public class BSPrim : BSPhysObject
1528 1521
1529 // The physics engine says that properties have updated. Update same and inform 1522 // The physics engine says that properties have updated. Update same and inform
1530 // the world that things have changed. 1523 // the world that things have changed.
1524 // NOTE: BSPrim.UpdateProperties is overloaded by BSPrimLinkable which modifies updates from root and children prims.
1525 // NOTE: BSPrim.UpdateProperties is overloaded by BSPrimDisplaced which handles mapping physical position to simulator position.
1531 public override void UpdateProperties(EntityProperties entprop) 1526 public override void UpdateProperties(EntityProperties entprop)
1532 { 1527 {
1533 // Let anyone (like the actors) modify the updated properties before they are pushed into the object and the simulator. 1528 // Let anyone (like the actors) modify the updated properties before they are pushed into the object and the simulator.
@@ -1536,8 +1531,8 @@ public class BSPrim : BSPhysObject
1536 // DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG 1531 // DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG
1537 1532
1538 // Assign directly to the local variables so the normal set actions do not happen 1533 // Assign directly to the local variables so the normal set actions do not happen
1539 _position = entprop.Position; 1534 RawPosition = entprop.Position;
1540 _orientation = entprop.Rotation; 1535 RawOrientation = entprop.Rotation;
1541 // DEBUG DEBUG DEBUG -- smooth velocity changes a bit. The simulator seems to be 1536 // DEBUG DEBUG DEBUG -- smooth velocity changes a bit. The simulator seems to be
1542 // very sensitive to velocity changes. 1537 // very sensitive to velocity changes.
1543 if (entprop.Velocity == OMV.Vector3.Zero || !entprop.Velocity.ApproxEquals(RawVelocity, BSParam.UpdateVelocityChangeThreshold)) 1538 if (entprop.Velocity == OMV.Vector3.Zero || !entprop.Velocity.ApproxEquals(RawVelocity, BSParam.UpdateVelocityChangeThreshold))
@@ -1550,21 +1545,19 @@ public class BSPrim : BSPhysObject
1550 // The sanity check can change the velocity and/or position. 1545 // The sanity check can change the velocity and/or position.
1551 if (PositionSanityCheck(true /* inTaintTime */ )) 1546 if (PositionSanityCheck(true /* inTaintTime */ ))
1552 { 1547 {
1553 entprop.Position = _position; 1548 entprop.Position = RawPosition;
1554 entprop.Velocity = RawVelocity; 1549 entprop.Velocity = RawVelocity;
1555 entprop.RotationalVelocity = _rotationalVelocity; 1550 entprop.RotationalVelocity = _rotationalVelocity;
1556 entprop.Acceleration = _acceleration; 1551 entprop.Acceleration = _acceleration;
1557 } 1552 }
1558 1553
1559 OMV.Vector3 direction = OMV.Vector3.UnitX * _orientation; // DEBUG DEBUG DEBUG 1554 OMV.Vector3 direction = OMV.Vector3.UnitX * RawOrientation; // DEBUG DEBUG DEBUG
1560 DetailLog("{0},BSPrim.UpdateProperties,call,entProp={1},dir={2}", LocalID, entprop, direction); 1555 DetailLog("{0},BSPrim.UpdateProperties,call,entProp={1},dir={2}", LocalID, entprop, direction);
1561 1556
1562 // remember the current and last set values 1557 // remember the current and last set values
1563 LastEntityProperties = CurrentEntityProperties; 1558 LastEntityProperties = CurrentEntityProperties;
1564 CurrentEntityProperties = entprop; 1559 CurrentEntityProperties = entprop;
1565 1560
1566 // Note that BSPrim can be overloaded by BSPrimLinkable which controls updates from root and children prims.
1567
1568 PhysScene.PostUpdate(this); 1561 PhysScene.PostUpdate(this);
1569 } 1562 }
1570} 1563}
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs
index f5ee671..2eb1440 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimDisplaced.cs
@@ -23,11 +23,6 @@
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 *
27 * The quotations from http://wiki.secondlife.com/wiki/Linden_Vehicle_Tutorial
28 * are Copyright (c) 2009 Linden Research, Inc and are used under their license
29 * of Creative Commons Attribution-Share Alike 3.0
30 * (http://creativecommons.org/licenses/by-sa/3.0/).
31 */ 26 */
32 27
33using System; 28using System;
@@ -44,14 +39,14 @@ namespace OpenSim.Region.Physics.BulletSPlugin
44{ 39{
45public class BSPrimDisplaced : BSPrim 40public class BSPrimDisplaced : BSPrim
46{ 41{
47 // The purpose of this module is to do any mapping between what the simulator thinks 42 // The purpose of this subclass is to do any mapping between what the simulator thinks
48 // the prim position and orientation is and what the physical position/orientation. 43 // the prim position and orientation is and what the physical position/orientation.
49 // This difference happens because Bullet assumes the center-of-mass is the <0,0,0> 44 // This difference happens because Bullet assumes the center-of-mass is the <0,0,0>
50 // of the prim/linkset. The simulator tracks the location of the prim/linkset by 45 // of the prim/linkset. The simulator, on the other hand, tracks the location of
51 // the location of the root prim. So, if center-of-mass is anywhere but the origin 46 // the prim/linkset by the location of the root prim. So, if center-of-mass is anywhere
52 // of the root prim, the physical origin is displaced from the simulator origin. 47 // but the origin of the root prim, the physical origin is displaced from the simulator origin.
53 // 48 //
54 // This routine works by capturing the Force* setting of position/orientation/... and 49 // This routine works by capturing ForcePosition and
55 // adjusting the simulator values (being set) into the physical values. 50 // adjusting the simulator values (being set) into the physical values.
56 // The conversion is also done in the opposite direction (physical origin -> simulator origin). 51 // The conversion is also done in the opposite direction (physical origin -> simulator origin).
57 // 52 //
@@ -59,8 +54,8 @@ public class BSPrimDisplaced : BSPrim
59 // are converted into simulator origin values before being passed to the base 54 // are converted into simulator origin values before being passed to the base
60 // class. 55 // class.
61 56
57 // PositionDisplacement is the vehicle relative distance from the root prim position to the center-of-mass.
62 public virtual OMV.Vector3 PositionDisplacement { get; set; } 58 public virtual OMV.Vector3 PositionDisplacement { get; set; }
63 public virtual OMV.Quaternion OrientationDisplacement { get; set; }
64 59
65 public BSPrimDisplaced(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, 60 public BSPrimDisplaced(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size,
66 OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) 61 OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical)
@@ -69,50 +64,82 @@ public class BSPrimDisplaced : BSPrim
69 ClearDisplacement(); 64 ClearDisplacement();
70 } 65 }
71 66
67 // Clears any center-of-mass displacement introduced by linksets, etc.
68 // Does not clear the displacement set by the user.
72 public void ClearDisplacement() 69 public void ClearDisplacement()
73 { 70 {
74 PositionDisplacement = OMV.Vector3.Zero; 71 if (UserSetCenterOfMassDisplacement.HasValue)
75 OrientationDisplacement = OMV.Quaternion.Identity; 72 PositionDisplacement = (OMV.Vector3)UserSetCenterOfMassDisplacement;
73 else
74 PositionDisplacement = OMV.Vector3.Zero;
76 } 75 }
77 76
78 // Set this sets and computes the displacement from the passed prim to the center-of-mass. 77 // Set this sets and computes the displacement from the passed prim to the center-of-mass.
79 // A user set value for center-of-mass overrides whatever might be passed in here. 78 // A user set value for center-of-mass overrides whatever might be passed in here.
80 // The displacement is in local coordinates (relative to root prim in linkset oriented coordinates). 79 // The displacement is in local coordinates (relative to root prim in linkset oriented coordinates).
81 public virtual void SetEffectiveCenterOfMassDisplacement(Vector3 centerOfMassDisplacement) 80 // Returns the relative offset from the root position to the center-of-mass.
81 // Called at taint time.
82 public virtual Vector3 SetEffectiveCenterOfMassDisplacement(Vector3 centerOfMassDisplacement)
82 { 83 {
84 PhysScene.AssertInTaintTime("BSPrimDisplaced.SetEffectiveCenterOfMassDisplacement");
83 Vector3 comDisp; 85 Vector3 comDisp;
84 if (UserSetCenterOfMassDisplacement.HasValue) 86 if (UserSetCenterOfMassDisplacement.HasValue)
85 comDisp = (OMV.Vector3)UserSetCenterOfMassDisplacement; 87 comDisp = (OMV.Vector3)UserSetCenterOfMassDisplacement;
86 else 88 else
87 comDisp = centerOfMassDisplacement; 89 comDisp = centerOfMassDisplacement;
88 90
91 // Eliminate any jitter caused be very slight differences in masses and positions
92 if (comDisp.ApproxEquals(Vector3.Zero, 0.01f) )
93 comDisp = Vector3.Zero;
94
89 DetailLog("{0},BSPrimDisplaced.SetEffectiveCenterOfMassDisplacement,userSet={1},comDisp={2}", 95 DetailLog("{0},BSPrimDisplaced.SetEffectiveCenterOfMassDisplacement,userSet={1},comDisp={2}",
90 LocalID, UserSetCenterOfMassDisplacement.HasValue, comDisp); 96 LocalID, UserSetCenterOfMassDisplacement.HasValue, comDisp);
91 if (comDisp == Vector3.Zero) 97 if ( !comDisp.ApproxEquals(PositionDisplacement, 0.01f) )
92 { 98 {
93 // If there is no diplacement. Things get reset. 99 // Displacement setting is changing.
94 PositionDisplacement = OMV.Vector3.Zero; 100 // The relationship between the physical object and simulated object must be aligned.
95 OrientationDisplacement = OMV.Quaternion.Identity;
96 }
97 else
98 {
99 // Remember the displacement from root as well as the origional rotation of the
100 // new center-of-mass.
101 PositionDisplacement = comDisp; 101 PositionDisplacement = comDisp;
102 OrientationDisplacement = OMV.Quaternion.Identity; 102 this.ForcePosition = RawPosition;
103 } 103 }
104
105 return PositionDisplacement;
104 } 106 }
105 107
108 // 'ForcePosition' is the one way to set the physical position of the body in the physics engine.
109 // Displace the simulator idea of position (center of root prim) to the physical position.
106 public override Vector3 ForcePosition 110 public override Vector3 ForcePosition
107 { 111 {
108 get { return base.ForcePosition; } 112 get {
113 OMV.Vector3 physPosition = PhysScene.PE.GetPosition(PhysBody);
114 if (PositionDisplacement != OMV.Vector3.Zero)
115 {
116 // If there is some displacement, return the physical position (center-of-mass)
117 // location minus the displacement to give the center of the root prim.
118 OMV.Vector3 displacement = PositionDisplacement * ForceOrientation;
119 DetailLog("{0},BSPrimDisplaced.ForcePosition,get,physPos={1},disp={2},simPos={3}",
120 LocalID, physPosition, displacement, physPosition - displacement);
121 physPosition -= displacement;
122 }
123 RawPosition = physPosition;
124 return physPosition;
125 }
109 set 126 set
110 { 127 {
111 if (PositionDisplacement != OMV.Vector3.Zero) 128 if (PositionDisplacement != OMV.Vector3.Zero)
112 { 129 {
113 OMV.Vector3 displacedPos = value - (PositionDisplacement * RawOrientation); 130 // This value is the simulator's idea of where the prim is: the center of the root prim
114 DetailLog("{0},BSPrimDisplaced.ForcePosition,val={1},disp={2},newPos={3}", LocalID, value, PositionDisplacement, displacedPos); 131 RawPosition = value;
115 base.ForcePosition = displacedPos; 132
133 // Move the passed root prim postion to the center-of-mass position and set in the physics engine.
134 OMV.Vector3 displacement = PositionDisplacement * RawOrientation;
135 OMV.Vector3 displacedPos = RawPosition + displacement;
136 DetailLog("{0},BSPrimDisplaced.ForcePosition,set,simPos={1},disp={2},physPos={3}",
137 LocalID, RawPosition, displacement, displacedPos);
138 if (PhysBody.HasPhysicalBody)
139 {
140 PhysScene.PE.SetTranslation(PhysBody, displacedPos, RawOrientation);
141 ActivateIfPhysical(false);
142 }
116 } 143 }
117 else 144 else
118 { 145 {
@@ -121,25 +148,12 @@ public class BSPrimDisplaced : BSPrim
121 } 148 }
122 } 149 }
123 150
124 public override Quaternion ForceOrientation 151 // These are also overridden by BSPrimLinkable if the prim can be part of a linkset
125 {
126 get { return base.ForceOrientation; }
127 set
128 {
129 // TODO:
130 base.ForceOrientation = value;
131 }
132 }
133
134 // TODO: decide if this is the right place for these variables.
135 // Somehow incorporate the optional settability by the user.
136 // Is this used?
137 public override OMV.Vector3 CenterOfMass 152 public override OMV.Vector3 CenterOfMass
138 { 153 {
139 get { return RawPosition; } 154 get { return RawPosition; }
140 } 155 }
141 156
142 // Is this used?
143 public override OMV.Vector3 GeometricCenter 157 public override OMV.Vector3 GeometricCenter
144 { 158 {
145 get { return RawPosition; } 159 get { return RawPosition; }
@@ -148,15 +162,18 @@ public class BSPrimDisplaced : BSPrim
148 public override void UpdateProperties(EntityProperties entprop) 162 public override void UpdateProperties(EntityProperties entprop)
149 { 163 {
150 // Undo any center-of-mass displacement that might have been done. 164 // Undo any center-of-mass displacement that might have been done.
151 if (PositionDisplacement != OMV.Vector3.Zero || OrientationDisplacement != OMV.Quaternion.Identity) 165 if (PositionDisplacement != OMV.Vector3.Zero)
152 { 166 {
153 // Correct for any rotation around the center-of-mass 167 // The origional shape was offset from 'zero' by PositionDisplacement.
154 // TODO!!! 168 // These physical location must be back converted to be centered around the displaced
155 169 // root shape.
156 OMV.Vector3 displacedPos = entprop.Position + (PositionDisplacement * entprop.Rotation); 170
157 DetailLog("{0},BSPrimDisplaced.ForcePosition,physPos={1},disp={2},newPos={3}", LocalID, entprop.Position, PositionDisplacement, displacedPos); 171 // Move the returned center-of-mass location to the root prim location.
172 OMV.Vector3 displacement = PositionDisplacement * entprop.Rotation;
173 OMV.Vector3 displacedPos = entprop.Position - displacement;
174 DetailLog("{0},BSPrimDisplaced.UpdateProperties,physPos={1},disp={2},simPos={3}",
175 LocalID, entprop.Position, displacement, displacedPos);
158 entprop.Position = displacedPos; 176 entprop.Position = displacedPos;
159 // entprop.Rotation = something;
160 } 177 }
161 178
162 base.UpdateProperties(entprop); 179 base.UpdateProperties(entprop);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
index 87eed98..1fbcfcc 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrimLinkable.cs
@@ -37,6 +37,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
37{ 37{
38public class BSPrimLinkable : BSPrimDisplaced 38public class BSPrimLinkable : BSPrimDisplaced
39{ 39{
40 // The purpose of this subclass is to add linkset functionality to the prim. This overrides
41 // operations necessary for keeping the linkset created and, additionally, this
42 // calls the linkset implementation for its creation and management.
43
44 // This adds the overrides for link() and delink() so the prim is linkable.
45
40 public BSLinkset Linkset { get; set; } 46 public BSLinkset Linkset { get; set; }
41 // The index of this child prim. 47 // The index of this child prim.
42 public int LinksetChildIndex { get; set; } 48 public int LinksetChildIndex { get; set; }
@@ -69,8 +75,8 @@ public class BSPrimLinkable : BSPrimDisplaced
69 BSPrimLinkable parent = obj as BSPrimLinkable; 75 BSPrimLinkable parent = obj as BSPrimLinkable;
70 if (parent != null) 76 if (parent != null)
71 { 77 {
72 BSPhysObject parentBefore = Linkset.LinksetRoot; 78 BSPhysObject parentBefore = Linkset.LinksetRoot; // DEBUG
73 int childrenBefore = Linkset.NumberOfChildren; 79 int childrenBefore = Linkset.NumberOfChildren; // DEBUG
74 80
75 Linkset = parent.Linkset.AddMeToLinkset(this); 81 Linkset = parent.Linkset.AddMeToLinkset(this);
76 82
@@ -85,8 +91,8 @@ public class BSPrimLinkable : BSPrimDisplaced
85 // TODO: decide if this parent checking needs to happen at taint time 91 // TODO: decide if this parent checking needs to happen at taint time
86 // Race condition here: if link() and delink() in same simulation tick, the delink will not happen 92 // Race condition here: if link() and delink() in same simulation tick, the delink will not happen
87 93
88 BSPhysObject parentBefore = Linkset.LinksetRoot; 94 BSPhysObject parentBefore = Linkset.LinksetRoot; // DEBUG
89 int childrenBefore = Linkset.NumberOfChildren; 95 int childrenBefore = Linkset.NumberOfChildren; // DEBUG
90 96
91 Linkset = Linkset.RemoveMeFromLinkset(this); 97 Linkset = Linkset.RemoveMeFromLinkset(this);
92 98
@@ -128,6 +134,17 @@ public class BSPrimLinkable : BSPrimDisplaced
128 get { return Linkset.LinksetMass; } 134 get { return Linkset.LinksetMass; }
129 } 135 }
130 136
137 public override OMV.Vector3 CenterOfMass
138 {
139 get { return Linkset.CenterOfMass; }
140 }
141
142 public override OMV.Vector3 GeometricCenter
143 {
144 get { return Linkset.GeometricCenter; }
145 }
146
147 // Refresh the linkset structure and parameters when the prim's physical parameters are changed.
131 public override void UpdatePhysicalParameters() 148 public override void UpdatePhysicalParameters()
132 { 149 {
133 base.UpdatePhysicalParameters(); 150 base.UpdatePhysicalParameters();
@@ -139,13 +156,17 @@ public class BSPrimLinkable : BSPrimDisplaced
139 Linkset.Refresh(this); 156 Linkset.Refresh(this);
140 } 157 }
141 158
159 // When the prim is made dynamic or static, the linkset needs to change.
142 protected override void MakeDynamic(bool makeStatic) 160 protected override void MakeDynamic(bool makeStatic)
143 { 161 {
144 base.MakeDynamic(makeStatic); 162 base.MakeDynamic(makeStatic);
145 if (makeStatic) 163 if (Linkset != null) // null can happen during initialization
146 Linkset.MakeStatic(this); 164 {
147 else 165 if (makeStatic)
148 Linkset.MakeDynamic(this); 166 Linkset.MakeStatic(this);
167 else
168 Linkset.MakeDynamic(this);
169 }
149 } 170 }
150 171
151 // Body is being taken apart. Remove physical dependencies and schedule a rebuild. 172 // Body is being taken apart. Remove physical dependencies and schedule a rebuild.
@@ -155,6 +176,8 @@ public class BSPrimLinkable : BSPrimDisplaced
155 base.RemoveDependencies(); 176 base.RemoveDependencies();
156 } 177 }
157 178
179 // Called after a simulation step for the changes in physical object properties.
180 // Do any filtering/modification needed for linksets.
158 public override void UpdateProperties(EntityProperties entprop) 181 public override void UpdateProperties(EntityProperties entprop)
159 { 182 {
160 if (Linkset.IsRoot(this)) 183 if (Linkset.IsRoot(this))
@@ -176,6 +199,7 @@ public class BSPrimLinkable : BSPrimDisplaced
176 Linkset.UpdateProperties(UpdatedProperties.EntPropUpdates, this); 199 Linkset.UpdateProperties(UpdatedProperties.EntPropUpdates, this);
177 } 200 }
178 201
202 // Called after a simulation step to post a collision with this object.
179 public override bool Collide(uint collidingWith, BSPhysObject collidee, 203 public override bool Collide(uint collidingWith, BSPhysObject collidee,
180 OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) 204 OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
181 { 205 {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index 1645c98..214271b 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -1,4 +1,4 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
@@ -648,7 +648,7 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
648 simTime = Util.EnvironmentTickCountSubtract(beforeTime); 648 simTime = Util.EnvironmentTickCountSubtract(beforeTime);
649 if (PhysicsLogging.Enabled) 649 if (PhysicsLogging.Enabled)
650 { 650 {
651 DetailLog("{0},DoPhysicsStep,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}, objWColl={7}", 651 DetailLog("{0},DoPhysicsStep,complete,frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}, objWColl={7}",
652 DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps, 652 DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps,
653 updatedEntityCount, collidersCount, ObjectsWithCollisions.Count); 653 updatedEntityCount, collidersCount, ObjectsWithCollisions.Count);
654 } 654 }
@@ -785,7 +785,6 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
785 { 785 {
786 // The simulation of the time interval took less than realtime. 786 // The simulation of the time interval took less than realtime.
787 // Do a sleep for the rest of realtime. 787 // Do a sleep for the rest of realtime.
788 DetailLog("{0},BulletSPluginPhysicsThread,sleeping={1}", BSScene.DetailLogZero, simulationTimeVsRealtimeDifferenceMS);
789 Thread.Sleep(simulationTimeVsRealtimeDifferenceMS); 788 Thread.Sleep(simulationTimeVsRealtimeDifferenceMS);
790 } 789 }
791 else 790 else
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
index 4357ef1..0453376 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
+++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimTODO.txt
@@ -3,25 +3,21 @@ CURRENT PROBLEMS TO FIX AND/OR LOOK AT
3Vehicle buoyancy. Computed correctly? Possibly creating very large effective mass. 3Vehicle buoyancy. Computed correctly? Possibly creating very large effective mass.
4 Interaction of llSetBuoyancy and vehicle buoyancy. Should be additive? 4 Interaction of llSetBuoyancy and vehicle buoyancy. Should be additive?
5 Negative buoyancy computed correctly 5 Negative buoyancy computed correctly
6Center-of-gravity
6Computation of mesh mass. How done? How should it be done? 7Computation of mesh mass. How done? How should it be done?
7Script changing rotation of child prim while vehicle moving (eg turning wheel) causes
8 the wheel to appear to jump back. Looks like sending position from previous update.
9Enable vehicle border crossings (at least as poorly as ODE) 8Enable vehicle border crossings (at least as poorly as ODE)
10 Terrain skirts 9 Terrain skirts
11 Avatar created in previous region and not new region when crossing border 10 Avatar created in previous region and not new region when crossing border
12 Vehicle recreated in new sim at small Z value (offset from root value?) (DONE) 11 Vehicle recreated in new sim at small Z value (offset from root value?) (DONE)
12User settable terrain mesh
13 Allow specifying as convex or concave and use different getHeight functions depending
14Boats, when turning nose down into the water
15 Acts like rotation around Z is also effecting rotation around X and Y
13Deleting a linkset while standing on the root will leave the physical shape of the root behind. 16Deleting a linkset while standing on the root will leave the physical shape of the root behind.
14 Not sure if it is because standing on it. Done with large prim linksets. 17 Not sure if it is because standing on it. Done with large prim linksets.
15Linkset child rotations. 18Linkset child rotations.
16 Nebadon spiral tube has middle sections which are rotated wrong. 19 Nebadon spiral tube has middle sections which are rotated wrong.
17 Select linked spiral tube. Delink and note where the middle section ends up. 20 Select linked spiral tube. Delink and note where the middle section ends up.
18Refarb compound linkset creation to create a pseudo-root for center-of-mass
19 Let children change their shape to physical indendently and just add shapes to compound
20Vehicle angular vertical attraction
21vehicle angular banking
22Center-of-gravity
23Vehicle angular deflection
24 Preferred orientation angular correction fix
25Teravus llMoveToTarget script debug 21Teravus llMoveToTarget script debug
26 Mixing of hover, buoyancy/gravity, moveToTarget, into one force 22 Mixing of hover, buoyancy/gravity, moveToTarget, into one force
27 Setting hover height to zero disables hover even if hover flags are on (from SL wiki) 23 Setting hover height to zero disables hover even if hover flags are on (from SL wiki)
@@ -33,10 +29,16 @@ Vehicle script tuning/debugging
33 Avanti speed script 29 Avanti speed script
34 Weapon shooter script 30 Weapon shooter script
35Move material definitions (friction, ...) into simulator. 31Move material definitions (friction, ...) into simulator.
32osGetPhysicsEngineVerion() and create a version code for the C++ DLL
36One sided meshes? Should terrain be built into a closed shape? 33One sided meshes? Should terrain be built into a closed shape?
37 When meshes get partially wedged into the terrain, they cannot push themselves out. 34 When meshes get partially wedged into the terrain, they cannot push themselves out.
38 It is possible that Bullet processes collisions whether entering or leaving a mesh. 35 It is possible that Bullet processes collisions whether entering or leaving a mesh.
39 Ref: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4869 36 Ref: http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4869
37Small physical objects do not interact correctly
38 Create chain of .5x.5x.1 torui and make all but top physical so to hang.
39 The chain will fall apart and pairs will dance around on ground
40 Chains of 1x1x.2 will stay connected but will dance.
41 Chains above 2x2x.4 are more stable and get stablier as torui get larger.
40 42
41VEHICLES TODO LIST: 43VEHICLES TODO LIST:
42================================================= 44=================================================
@@ -45,14 +47,12 @@ LINEAR_MOTOR_DIRECTION values should be clamped to reasonable numbers.
45 Same for other velocity settings. 47 Same for other velocity settings.
46UBit improvements to remove rubber-banding of avatars sitting on vehicle child prims: 48UBit improvements to remove rubber-banding of avatars sitting on vehicle child prims:
47 https://github.com/UbitUmarov/Ubit-opensim 49 https://github.com/UbitUmarov/Ubit-opensim
48Vehicles (Move smoothly)
49Some vehicles should not be able to turn if no speed or off ground. 50Some vehicles should not be able to turn if no speed or off ground.
50Cannot edit/move a vehicle being ridden: it jumps back to the origional position. 51Cannot edit/move a vehicle being ridden: it jumps back to the origional position.
51Neb car jiggling left and right 52Neb car jiggling left and right
52 Happens on terrain and any other mesh object. Flat cubes are much smoother. 53 Happens on terrain and any other mesh object. Flat cubes are much smoother.
53 This has been reduced but not eliminated. 54 This has been reduced but not eliminated.
54Implement referenceFrame for all the motion routines. 55Implement referenceFrame for all the motion routines.
55For limitMotorUp, use raycast down to find if vehicle is in the air.
56Verify llGetVel() is returning a smooth and good value for vehicle movement. 56Verify llGetVel() is returning a smooth and good value for vehicle movement.
57llGetVel() should return the root's velocity if requested in a child prim. 57llGetVel() should return the root's velocity if requested in a child prim.
58Implement function efficiency for lineaar and angular motion. 58Implement function efficiency for lineaar and angular motion.
@@ -93,29 +93,15 @@ Revisit CollisionMargin. Builders notice the 0.04 spacing between prims.
93Duplicating a physical prim causes old prim to jump away 93Duplicating a physical prim causes old prim to jump away
94 Dup a phys prim and the original become unselected and thus interacts w/ selected prim. 94 Dup a phys prim and the original become unselected and thus interacts w/ selected prim.
95Scenes with hundred of thousands of static objects take a lot of physics CPU time. 95Scenes with hundred of thousands of static objects take a lot of physics CPU time.
96BSPrim.Force should set a continious force on the prim. The force should be
97 applied each tick. Some limits?
98Gun sending shooter flying. 96Gun sending shooter flying.
99Collision margin (gap between physical objects lying on each other) 97Collision margin (gap between physical objects lying on each other)
100Boundry checking (crashes related to crossing boundry) 98Boundry checking (crashes related to crossing boundry)
101 Add check for border edge position for avatars and objects. 99 Add check for border edge position for avatars and objects.
102 Verify the events are created for border crossings. 100 Verify the events are created for border crossings.
103Avatar rotation (check out changes to ScenePresence for physical rotation)
104Avatar running (what does phys engine need to do?)
105Small physical objects do not interact correctly
106 Create chain of .5x.5x.1 torui and make all but top physical so to hang.
107 The chain will fall apart and pairs will dance around on ground
108 Chains of 1x1x.2 will stay connected but will dance.
109 Chains above 2x2x.4 are more stable and get stablier as torui get larger.
110Add PID motor for avatar movement (slow to stop, ...)
111setForce should set a constant force. Different than AddImpulse.
112Implement raycast.
113Implement ShapeCollection.Dispose() 101Implement ShapeCollection.Dispose()
114Implement water as a plain so raycasting and collisions can happen with same. 102Implement water as a plain or mesh so raycasting and collisions can happen with same.
115Add collision penetration return 103Add collision penetration return
116 Add field passed back by BulletSim.dll and fill with info in ManifoldConstact.GetDistance() 104 Add field passed back by BulletSim.dll and fill with info in ManifoldConstact.GetDistance()
117Add osGetPhysicsEngineName() so scripters can tell whether BulletSim or ODE
118 Also osGetPhysicsEngineVerion() maybe.
119Linkset.Position and Linkset.Orientation requre rewrite to properly return 105Linkset.Position and Linkset.Orientation requre rewrite to properly return
120 child position. LinksetConstraint acts like it's at taint time!! 106 child position. LinksetConstraint acts like it's at taint time!!
121Implement LockAngularMotion -- implements llSetStatus(ROTATE_AXIS_*, T/F) 107Implement LockAngularMotion -- implements llSetStatus(ROTATE_AXIS_*, T/F)
@@ -127,9 +113,6 @@ Selecting and deselecting physical objects causes CPU processing time to jump
127Re-implement buoyancy as a separate force on the object rather than diddling gravity. 113Re-implement buoyancy as a separate force on the object rather than diddling gravity.
128 Register a pre-step event to add the force. 114 Register a pre-step event to add the force.
129More efficient memory usage when passing hull information from BSPrim to BulletSim 115More efficient memory usage when passing hull information from BSPrim to BulletSim
130Avatar movement motor check for zero or small movement. Somehow suppress small movements
131 when avatar has stopped and is just standing. Simple test for near zero has
132 the problem of preventing starting up (increase from zero) especially when falling.
133Physical and phantom will drop through the terrain 116Physical and phantom will drop through the terrain
134 117
135 118
@@ -172,7 +155,6 @@ Do we need to do convex hulls all the time? Can complex meshes be left meshes?
172 There is some problem with meshes and collisions 155 There is some problem with meshes and collisions
173 Hulls are not as detailed as meshes. Hulled vehicles insides are different shape. 156 Hulls are not as detailed as meshes. Hulled vehicles insides are different shape.
174Debounce avatar contact so legs don't keep folding up when standing. 157Debounce avatar contact so legs don't keep folding up when standing.
175Implement LSL physics controls. Like STATUS_ROTATE_X.
176Add border extensions to terrain to help region crossings and objects leaving region. 158Add border extensions to terrain to help region crossings and objects leaving region.
177Use a different capsule shape for avatar when sitting 159Use a different capsule shape for avatar when sitting
178 LL uses a pyrimidal shape scaled by the avatar's bounding box 160 LL uses a pyrimidal shape scaled by the avatar's bounding box
@@ -205,8 +187,6 @@ Keep avatar scaling correct. http://pennycow.blogspot.fr/2011/07/matter-of-scale
205 187
206INTERNAL IMPROVEMENT/CLEANUP 188INTERNAL IMPROVEMENT/CLEANUP
207================================================= 189=================================================
208Can the 'inTaintTime' flag be cleaned up and used? For instance, a call to
209 BSScene.TaintedObject() could immediately execute the callback if already in taint time.
210Create the physical wrapper classes (BulletBody, BulletShape) by methods on 190Create the physical wrapper classes (BulletBody, BulletShape) by methods on
211 BSAPITemplate and make their actual implementation Bullet engine specific. 191 BSAPITemplate and make their actual implementation Bullet engine specific.
212 For the short term, just call the existing functions in ShapeCollection. 192 For the short term, just call the existing functions in ShapeCollection.
@@ -365,4 +345,35 @@ After getting off a vehicle, the root prim is phantom (can be walked through)
365Explore btGImpactMeshShape as alternative to convex hulls for simplified physical objects. 345Explore btGImpactMeshShape as alternative to convex hulls for simplified physical objects.
366 Regular triangle meshes don't do physical collisions. 346 Regular triangle meshes don't do physical collisions.
367 (DONE: discovered GImpact is VERY CPU intensive) 347 (DONE: discovered GImpact is VERY CPU intensive)
348Script changing rotation of child prim while vehicle moving (eg turning wheel) causes
349 the wheel to appear to jump back. Looks like sending position from previous update.
350 (DONE: redo of compound linksets fixed problem)
351Refarb compound linkset creation to create a pseudo-root for center-of-mass
352 Let children change their shape to physical indendently and just add shapes to compound
353 (DONE: redo of compound linkset fixed problem)
354Vehicle angular vertical attraction (DONE: vegaslon code)
355vehicle angular banking (DONE: vegaslon code)
356Vehicle angular deflection (DONE: vegaslon code)
357 Preferred orientation angular correction fix
358Vehicles (Move smoothly)
359For limitMotorUp, use raycast down to find if vehicle is in the air.
360 (WILL NOT BE DONE: gravity does the job well enough)
361BSPrim.Force should set a continious force on the prim. The force should be
362 applied each tick. Some limits?
363 (DONE: added physical actors. Implemented SetForce, SetTorque, ...)
364Implement LSL physics controls. Like STATUS_ROTATE_X. (DONE)
365Add osGetPhysicsEngineName() so scripters can tell whether BulletSim or ODE
366Avatar rotation (check out changes to ScenePresence for physical rotation) (DONE)
367Avatar running (what does phys engine need to do?) (DONE: multiplies run factor by walking force)
368setForce should set a constant force. Different than AddImpulse. (DONE)
369Add PID motor for avatar movement (slow to stop, ...) (WNBD: current works ok)
370Avatar movement motor check for zero or small movement. Somehow suppress small movements
371 when avatar has stopped and is just standing. Simple test for near zero has
372 the problem of preventing starting up (increase from zero) especially when falling.
373 (DONE: avatar movement actor knows if standing on stationary object and zeros motion)
374Can the 'inTaintTime' flag be cleaned up and used? For instance, a call to
375 BSScene.TaintedObject() could immediately execute the callback if already in taint time.
376 (DONE)
377
378
368 379
diff --git a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs
index 583c436..48d3742 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/Tests/BasicVehicles.cs
@@ -57,6 +57,8 @@ public class BasicVehicles : OpenSimTestCase
57 public void Init() 57 public void Init()
58 { 58 {
59 Dictionary<string, string> engineParams = new Dictionary<string, string>(); 59 Dictionary<string, string> engineParams = new Dictionary<string, string>();
60 engineParams.Add("VehicleEnableAngularVerticalAttraction", "true");
61 engineParams.Add("VehicleAngularVerticalAttractionAlgorithm", "1");
60 PhysicsScene = BulletSimTestsUtil.CreateBasicPhysicsEngine(engineParams); 62 PhysicsScene = BulletSimTestsUtil.CreateBasicPhysicsEngine(engineParams);
61 63
62 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateSphere(); 64 PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateSphere();
@@ -119,7 +121,7 @@ public class BasicVehicles : OpenSimTestCase
119 { 121 {
120 vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency); 122 vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_EFFICIENCY, efficiency);
121 vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale); 123 vehicleActor.ProcessFloatVehicleParam(Vehicle.VERTICAL_ATTRACTION_TIMESCALE, timeScale);
122 vehicleActor.enableAngularVerticalAttraction = true; 124 // vehicleActor.enableAngularVerticalAttraction = true;
123 125
124 TestVehicle.IsPhysical = true; 126 TestVehicle.IsPhysical = true;
125 PhysicsScene.ProcessTaints(); 127 PhysicsScene.ProcessTaints();
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
index d09aa62..b4b7e7f 100644
--- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
+++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs
@@ -108,7 +108,6 @@ namespace OpenSim.Region.Physics.OdePlugin
108 private Vector3 m_taintAngularLock = Vector3.One; 108 private Vector3 m_taintAngularLock = Vector3.One;
109 private IntPtr Amotor = IntPtr.Zero; 109 private IntPtr Amotor = IntPtr.Zero;
110 110
111 private object m_assetsLock = new object();
112 private bool m_assetFailed = false; 111 private bool m_assetFailed = false;
113 112
114 private Vector3 m_PIDTarget; 113 private Vector3 m_PIDTarget;
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index 07663b3..7e652fc 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Region.Physics.OdePlugin
46 /// </summary> 46 /// </summary>
47 public class OdePlugin : IPhysicsPlugin 47 public class OdePlugin : IPhysicsPlugin
48 { 48 {
49 private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 49// private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 private OdeScene m_scene; 51 private OdeScene m_scene;
52 52
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index a47e452..a6db2e5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -355,6 +355,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
355 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); 355 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar);
356 fromRegionPos = avatar.AbsolutePosition; 356 fromRegionPos = avatar.AbsolutePosition;
357 q = avatar.Rotation; 357 q = avatar.Rotation;
358
359 // Don't proceed if the avatar for this attachment has since been removed from the scene.
360 if (avatar == null)
361 return sensedEntities;
358 } 362 }
359 363
360 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q); 364 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 2260ec8..b25894a 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -332,7 +332,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
332 void llSensorRemove(); 332 void llSensorRemove();
333 void llSensorRepeat(string name, string id, int type, double range, double arc, double rate); 333 void llSensorRepeat(string name, string id, int type, double range, double arc, double rate);
334 void llSetAlpha(double alpha, int face); 334 void llSetAlpha(double alpha, int face);
335 void llSetAngularVelocity(LSL_Vector angvelocity, int local);
336 void llSetBuoyancy(double buoyancy); 335 void llSetBuoyancy(double buoyancy);
337 void llSetCameraAtOffset(LSL_Vector offset); 336 void llSetCameraAtOffset(LSL_Vector offset);
338 void llSetCameraEyeOffset(LSL_Vector offset); 337 void llSetCameraEyeOffset(LSL_Vector offset);
@@ -344,6 +343,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
344 void llSetDamage(double damage); 343 void llSetDamage(double damage);
345 void llSetForce(LSL_Vector force, int local); 344 void llSetForce(LSL_Vector force, int local);
346 void llSetForceAndTorque(LSL_Vector force, LSL_Vector torque, int local); 345 void llSetForceAndTorque(LSL_Vector force, LSL_Vector torque, int local);
346 void llSetVelocity(LSL_Vector velocity, int local);
347 void llSetAngularVelocity(LSL_Vector angularVelocity, int local);
347 void llSetHoverHeight(double height, int water, double tau); 348 void llSetHoverHeight(double height, int water, double tau);
348 void llSetInventoryPermMask(string item, int mask, int value); 349 void llSetInventoryPermMask(string item, int mask, int value);
349 void llSetLinkAlpha(int linknumber, double alpha, int face); 350 void llSetLinkAlpha(int linknumber, double alpha, int face);
@@ -384,7 +385,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
384 void llSetVehicleRotationParam(int param, LSL_Rotation rot); 385 void llSetVehicleRotationParam(int param, LSL_Rotation rot);
385 void llSetVehicleType(int type); 386 void llSetVehicleType(int type);
386 void llSetVehicleVectorParam(int param, LSL_Vector vec); 387 void llSetVehicleVectorParam(int param, LSL_Vector vec);
387 void llSetVelocity(LSL_Vector velocity, int local);
388 void llShout(int channelID, string text); 388 void llShout(int channelID, string text);
389 LSL_Float llSin(double f); 389 LSL_Float llSin(double f);
390 void llSitTarget(LSL_Vector offset, LSL_Rotation rot); 390 void llSitTarget(LSL_Vector offset, LSL_Rotation rot);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index b58686b..2f528af 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -1495,11 +1495,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1495 m_LSL_Functions.llSetAlpha(alpha, face); 1495 m_LSL_Functions.llSetAlpha(alpha, face);
1496 } 1496 }
1497 1497
1498 public void llSetAngularVelocity(LSL_Vector angvelocity, int local)
1499 {
1500 m_LSL_Functions.llSetAngularVelocity(angvelocity, local);
1501 }
1502
1503 public void llSetBuoyancy(double buoyancy) 1498 public void llSetBuoyancy(double buoyancy)
1504 { 1499 {
1505 m_LSL_Functions.llSetBuoyancy(buoyancy); 1500 m_LSL_Functions.llSetBuoyancy(buoyancy);
@@ -1555,6 +1550,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1555 m_LSL_Functions.llSetForceAndTorque(force, torque, local); 1550 m_LSL_Functions.llSetForceAndTorque(force, torque, local);
1556 } 1551 }
1557 1552
1553 public void llSetVelocity(LSL_Vector force, int local)
1554 {
1555 m_LSL_Functions.llSetVelocity(force, local);
1556 }
1557
1558 public void llSetAngularVelocity(LSL_Vector force, int local)
1559 {
1560 m_LSL_Functions.llSetAngularVelocity(force, local);
1561 }
1562
1558 public void llSetHoverHeight(double height, int water, double tau) 1563 public void llSetHoverHeight(double height, int water, double tau)
1559 { 1564 {
1560 m_LSL_Functions.llSetHoverHeight(height, water, tau); 1565 m_LSL_Functions.llSetHoverHeight(height, water, tau);
@@ -1745,11 +1750,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1745 m_LSL_Functions.llSetVehicleVectorParam(param, vec); 1750 m_LSL_Functions.llSetVehicleVectorParam(param, vec);
1746 } 1751 }
1747 1752
1748 public void llSetVelocity(LSL_Vector velocity, int local)
1749 {
1750 m_LSL_Functions.llSetVelocity(velocity, local);
1751 }
1752
1753 public void llShout(int channelID, string text) 1753 public void llShout(int channelID, string text)
1754 { 1754 {
1755 m_LSL_Functions.llShout(channelID, text); 1755 m_LSL_Functions.llShout(channelID, text);
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs
index 986394b..941b97d 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerDeleteHandler.cs
@@ -70,7 +70,7 @@ namespace OpenSim.Server.Handlers.Asset
70 m_allowedTypes = allowedTypes; 70 m_allowedTypes = allowedTypes;
71 } 71 }
72 72
73 public override byte[] Handle(string path, Stream request, 73 protected override byte[] ProcessRequest(string path, Stream request,
74 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 74 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
75 { 75 {
76 bool result = false; 76 bool result = false;
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs
index 8f7412b..8b23a83 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerGetHandler.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Server.Handlers.Asset
54 m_AssetService = service; 54 m_AssetService = service;
55 } 55 }
56 56
57 public override byte[] Handle(string path, Stream request, 57 protected override byte[] ProcessRequest(string path, Stream request,
58 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 58 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
59 { 59 {
60 byte[] result = new byte[0]; 60 byte[] result = new byte[0];
diff --git a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs
index a006fa8..8eebc61 100644
--- a/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Asset/AssetServerPostHandler.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Server.Handlers.Asset
54 m_AssetService = service; 54 m_AssetService = service;
55 } 55 }
56 56
57 public override byte[] Handle(string path, Stream request, 57 protected override byte[] ProcessRequest(string path, Stream request,
58 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 58 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
59 { 59 {
60 AssetBase asset; 60 AssetBase asset;
diff --git a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
index 6b93cd9..16e011a 100644
--- a/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Authentication/AuthenticationServerPostHandler.cs
@@ -70,7 +70,7 @@ namespace OpenSim.Server.Handlers.Authentication
70 } 70 }
71 } 71 }
72 72
73 public override byte[] Handle(string path, Stream request, 73 protected override byte[] ProcessRequest(string path, Stream request,
74 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 74 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
75 { 75 {
76 string[] p = SplitParams(path); 76 string[] p = SplitParams(path);
diff --git a/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs
index 18cef15..66a26fc 100644
--- a/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs
+++ b/OpenSim/Server/Handlers/Authentication/OpenIdServerHandler.cs
@@ -147,7 +147,7 @@ namespace OpenSim.Server.Handlers.Authentication
147 #endregion 147 #endregion
148 } 148 }
149 149
150 public class OpenIdStreamHandler : IStreamHandler 150 public class OpenIdStreamHandler : BaseOutputStreamHandler
151 { 151 {
152 #region HTML 152 #region HTML
153 153
@@ -191,42 +191,34 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>.
191 191
192 #endregion HTML 192 #endregion HTML
193 193
194 public string Name { get { return "OpenId"; } }
195 public string Description { get { return null; } }
196 public string ContentType { get { return m_contentType; } }
197 public string HttpMethod { get { return m_httpMethod; } }
198 public string Path { get { return m_path; } }
199
200 string m_contentType;
201 string m_httpMethod;
202 string m_path;
203 IAuthenticationService m_authenticationService; 194 IAuthenticationService m_authenticationService;
204 IUserAccountService m_userAccountService; 195 IUserAccountService m_userAccountService;
205 ProviderMemoryStore m_openidStore = new ProviderMemoryStore(); 196 ProviderMemoryStore m_openidStore = new ProviderMemoryStore();
206 197
198 public override string ContentType { get { return "text/html"; } }
199
207 /// <summary> 200 /// <summary>
208 /// Constructor 201 /// Constructor
209 /// </summary> 202 /// </summary>
210 public OpenIdStreamHandler(string httpMethod, string path, IUserAccountService userService, IAuthenticationService authService) 203 public OpenIdStreamHandler(
204 string httpMethod, string path, IUserAccountService userService, IAuthenticationService authService)
205 : base(httpMethod, path, "OpenId", "OpenID stream handler")
211 { 206 {
212 m_authenticationService = authService; 207 m_authenticationService = authService;
213 m_userAccountService = userService; 208 m_userAccountService = userService;
214 m_httpMethod = httpMethod;
215 m_path = path;
216
217 m_contentType = "text/html";
218 } 209 }
219 210
220 /// <summary> 211 /// <summary>
221 /// Handles all GET and POST requests for OpenID identifier pages and endpoint 212 /// Handles all GET and POST requests for OpenID identifier pages and endpoint
222 /// server communication 213 /// server communication
223 /// </summary> 214 /// </summary>
224 public void Handle(string path, Stream request, Stream response, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 215 protected override void ProcessRequest(
216 string path, Stream request, Stream response, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
225 { 217 {
226 Uri providerEndpoint = new Uri(String.Format("{0}://{1}{2}", httpRequest.Url.Scheme, httpRequest.Url.Authority, httpRequest.Url.AbsolutePath)); 218 Uri providerEndpoint = new Uri(String.Format("{0}://{1}{2}", httpRequest.Url.Scheme, httpRequest.Url.Authority, httpRequest.Url.AbsolutePath));
227 219
228 // Defult to returning HTML content 220 // Defult to returning HTML content
229 m_contentType = "text/html"; 221 httpResponse.ContentType = ContentType;
230 222
231 try 223 try
232 { 224 {
@@ -276,7 +268,7 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>.
276 268
277 string[] contentTypeValues = provider.Request.Response.Headers.GetValues("Content-Type"); 269 string[] contentTypeValues = provider.Request.Response.Headers.GetValues("Content-Type");
278 if (contentTypeValues != null && contentTypeValues.Length == 1) 270 if (contentTypeValues != null && contentTypeValues.Length == 1)
279 m_contentType = contentTypeValues[0]; 271 httpResponse.ContentType = contentTypeValues[0];
280 272
281 // Set the response code and document body based on the OpenID result 273 // Set the response code and document body based on the OpenID result
282 httpResponse.StatusCode = (int)provider.Request.Response.Code; 274 httpResponse.StatusCode = (int)provider.Request.Response.Code;
@@ -344,4 +336,4 @@ For more information, see <a href='http://openid.net/'>http://openid.net/</a>.
344 return false; 336 return false;
345 } 337 }
346 } 338 }
347} 339} \ No newline at end of file
diff --git a/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs b/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs
index bcf9d47..c9b4e9b 100644
--- a/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Authorization/AuthorizationServerPostHandler.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Server.Handlers.Authorization
54 m_AuthorizationService = service; 54 m_AuthorizationService = service;
55 } 55 }
56 56
57 public override byte[] Handle(string path, Stream request, 57 protected override byte[] ProcessRequest(string path, Stream request,
58 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 58 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
59 { 59 {
60 XmlSerializer xs = new XmlSerializer(typeof (AuthorizationRequest)); 60 XmlSerializer xs = new XmlSerializer(typeof (AuthorizationRequest));
diff --git a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs
index 8cd747e..d6bbb8f 100644
--- a/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Avatar/AvatarServerPostHandler.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Server.Handlers.Avatar
56 m_AvatarService = service; 56 m_AvatarService = service;
57 } 57 }
58 58
59 public override byte[] Handle(string path, Stream requestData, 59 protected override byte[] ProcessRequest(string path, Stream requestData,
60 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 60 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
61 { 61 {
62 StreamReader sr = new StreamReader(requestData); 62 StreamReader sr = new StreamReader(requestData);
diff --git a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs
index 47a8558..ca0a24c 100644
--- a/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Friends/FriendsServerPostHandler.cs
@@ -57,7 +57,7 @@ namespace OpenSim.Server.Handlers.Friends
57 m_FriendsService = service; 57 m_FriendsService = service;
58 } 58 }
59 59
60 public override byte[] Handle(string path, Stream requestData, 60 protected override byte[] ProcessRequest(string path, Stream requestData,
61 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 61 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
62 { 62 {
63 StreamReader sr = new StreamReader(requestData); 63 StreamReader sr = new StreamReader(requestData);
diff --git a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
index ef5f33e..89cba8a 100644
--- a/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Grid/GridServerPostHandler.cs
@@ -57,7 +57,7 @@ namespace OpenSim.Server.Handlers.Grid
57 m_GridService = service; 57 m_GridService = service;
58 } 58 }
59 59
60 public override byte[] Handle(string path, Stream requestData, 60 protected override byte[] ProcessRequest(string path, Stream requestData,
61 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 61 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
62 { 62 {
63 StreamReader sr = new StreamReader(requestData); 63 StreamReader sr = new StreamReader(requestData);
diff --git a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs
index 7483395..0b98e9a 100644
--- a/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/GridUser/GridUserServerPostHandler.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Server.Handlers.GridUser
56 m_GridUserService = service; 56 m_GridUserService = service;
57 } 57 }
58 58
59 public override byte[] Handle(string path, Stream requestData, 59 protected override byte[] ProcessRequest(string path, Stream requestData,
60 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 60 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
61 { 61 {
62 StreamReader sr = new StreamReader(requestData); 62 StreamReader sr = new StreamReader(requestData);
diff --git a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
index 0aa2729..a2bdadb 100644
--- a/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/HGFriendsServerPostHandler.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
68 m_log.ErrorFormat("[HGFRIENDS HANDLER]: TheService is null!"); 68 m_log.ErrorFormat("[HGFRIENDS HANDLER]: TheService is null!");
69 } 69 }
70 70
71 public override byte[] Handle(string path, Stream requestData, 71 protected override byte[] ProcessRequest(string path, Stream requestData,
72 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 72 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
73 { 73 {
74 StreamReader sr = new StreamReader(requestData); 74 StreamReader sr = new StreamReader(requestData);
diff --git a/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs b/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs
index f306b1c..06eaf2e 100644
--- a/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/HeloServerConnector.cs
@@ -91,7 +91,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
91 m_HandlersType = handlersType; 91 m_HandlersType = handlersType;
92 } 92 }
93 93
94 public override byte[] Handle(string path, Stream requestData, 94 protected override byte[] ProcessRequest(string path, Stream requestData,
95 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 95 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
96 { 96 {
97 return OKResponse(httpResponse); 97 return OKResponse(httpResponse);
diff --git a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs
index df875af..f37f2f1 100644
--- a/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs
+++ b/OpenSim/Server/Handlers/Hypergrid/HomeAgentHandlers.cs
@@ -68,6 +68,7 @@ namespace OpenSim.Server.Handlers.Hypergrid
68 { 68 {
69 return new ExtendedAgentDestinationData(); 69 return new ExtendedAgentDestinationData();
70 } 70 }
71
71 protected override void UnpackData(OSDMap args, AgentDestinationData d, Hashtable request) 72 protected override void UnpackData(OSDMap args, AgentDestinationData d, Hashtable request)
72 { 73 {
73 base.UnpackData(args, d, request); 74 base.UnpackData(args, d, request);
diff --git a/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs b/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs
index 231e32f..e2c50fe 100644
--- a/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs
+++ b/OpenSim/Server/Handlers/Inventory/InventoryServerMoveItemsHandler.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Server.Handlers.Inventory
56 m_InventoryService = service; 56 m_InventoryService = service;
57 } 57 }
58 58
59 public override byte[] Handle(string path, Stream request, 59 protected override byte[] ProcessRequest(string path, Stream request,
60 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 60 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
61 { 61 {
62 XmlSerializer xs = new XmlSerializer(typeof (List<InventoryItemBase>)); 62 XmlSerializer xs = new XmlSerializer(typeof (List<InventoryItemBase>));
diff --git a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
index 9d28dc3..0d7c136 100644
--- a/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
+++ b/OpenSim/Server/Handlers/Inventory/XInventoryInConnector.cs
@@ -87,7 +87,7 @@ namespace OpenSim.Server.Handlers.Asset
87 m_InventoryService = service; 87 m_InventoryService = service;
88 } 88 }
89 89
90 public override byte[] Handle(string path, Stream requestData, 90 protected override byte[] ProcessRequest(string path, Stream requestData,
91 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 91 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
92 { 92 {
93 StreamReader sr = new StreamReader(requestData); 93 StreamReader sr = new StreamReader(requestData);
diff --git a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
index 4a61969..d438fc7 100644
--- a/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
+++ b/OpenSim/Server/Handlers/Map/MapAddServerConnector.cs
@@ -99,7 +99,7 @@ namespace OpenSim.Server.Handlers.MapImage
99 m_Proxy = proxy; 99 m_Proxy = proxy;
100 } 100 }
101 101
102 public override byte[] Handle(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 102 protected override byte[] ProcessRequest(string path, Stream requestData, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
103 { 103 {
104// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path); 104// m_log.DebugFormat("[MAP SERVICE IMAGE HANDLER]: Received {0}", path);
105 StreamReader sr = new StreamReader(requestData); 105 StreamReader sr = new StreamReader(requestData);
diff --git a/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs b/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs
index 4502b7d..bd1ddbd 100644
--- a/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs
+++ b/OpenSim/Server/Handlers/Map/MapGetServerConnector.cs
@@ -83,7 +83,7 @@ namespace OpenSim.Server.Handlers.MapImage
83 m_MapService = service; 83 m_MapService = service;
84 } 84 }
85 85
86 public override byte[] Handle(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 86 protected override byte[] ProcessRequest(string path, Stream request, IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
87 { 87 {
88 ev.WaitOne(); 88 ev.WaitOne();
89 lock (ev) 89 lock (ev)
diff --git a/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs b/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs
index 8a1f824..3525a01 100644
--- a/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs
+++ b/OpenSim/Server/Handlers/Neighbour/NeighbourHandlers.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Server.Handlers.Neighbour
58 // TODO: unused: m_AuthenticationService = authentication; 58 // TODO: unused: m_AuthenticationService = authentication;
59 } 59 }
60 60
61 public override byte[] Handle(string path, Stream request, 61 protected override byte[] ProcessRequest(string path, Stream request,
62 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 62 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
63 { 63 {
64 // Not implemented yet 64 // Not implemented yet
@@ -83,7 +83,7 @@ namespace OpenSim.Server.Handlers.Neighbour
83 // TODO: unused: m_AllowForeignGuests = foreignGuests; 83 // TODO: unused: m_AllowForeignGuests = foreignGuests;
84 } 84 }
85 85
86 public override byte[] Handle(string path, Stream request, 86 protected override byte[] ProcessRequest(string path, Stream request,
87 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 87 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
88 { 88 {
89 byte[] result = new byte[0]; 89 byte[] result = new byte[0];
@@ -176,7 +176,7 @@ namespace OpenSim.Server.Handlers.Neighbour
176 // TODO: unused: m_AuthenticationService = authentication; 176 // TODO: unused: m_AuthenticationService = authentication;
177 } 177 }
178 178
179 public override byte[] Handle(string path, Stream request, 179 protected override byte[] ProcessRequest(string path, Stream request,
180 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 180 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
181 { 181 {
182 // Not implemented yet 182 // Not implemented yet
@@ -197,7 +197,7 @@ namespace OpenSim.Server.Handlers.Neighbour
197 // TODO: unused: m_AuthenticationService = authentication; 197 // TODO: unused: m_AuthenticationService = authentication;
198 } 198 }
199 199
200 public override byte[] Handle(string path, Stream request, 200 protected override byte[] ProcessRequest(string path, Stream request,
201 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 201 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
202 { 202 {
203 // Not implemented yet 203 // Not implemented yet
diff --git a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs
index 2d67c6d..abb4b19 100644
--- a/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/Presence/PresenceServerPostHandler.cs
@@ -56,7 +56,7 @@ namespace OpenSim.Server.Handlers.Presence
56 m_PresenceService = service; 56 m_PresenceService = service;
57 } 57 }
58 58
59 public override byte[] Handle(string path, Stream requestData, 59 protected override byte[] ProcessRequest(string path, Stream requestData,
60 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 60 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
61 { 61 {
62 StreamReader sr = new StreamReader(requestData); 62 StreamReader sr = new StreamReader(requestData);
diff --git a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
index c62f256..3ace9fb 100644
--- a/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
+++ b/OpenSim/Server/Handlers/Simulation/AgentHandlers.cs
@@ -112,7 +112,7 @@ namespace OpenSim.Server.Handlers.Simulation
112 } 112 }
113 else 113 else
114 { 114 {
115 m_log.InfoFormat("[AGENT HANDLER]: method {0} not supported in agent message", method); 115 m_log.InfoFormat("[AGENT HANDLER]: method {0} not supported in agent message (caller is {1})", method, Util.GetCallerIP(request));
116 responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed; 116 responsedata["int_response_code"] = HttpStatusCode.MethodNotAllowed;
117 responsedata["str_response_string"] = "Method not allowed"; 117 responsedata["str_response_string"] = "Method not allowed";
118 118
@@ -274,7 +274,7 @@ namespace OpenSim.Server.Handlers.Simulation
274 m_SimulationService = null; 274 m_SimulationService = null;
275 } 275 }
276 276
277 public override byte[] Handle(string path, Stream request, 277 protected override byte[] ProcessRequest(string path, Stream request,
278 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 278 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
279 { 279 {
280// m_log.DebugFormat("[SIMULATION]: Stream handler called"); 280// m_log.DebugFormat("[SIMULATION]: Stream handler called");
@@ -488,7 +488,7 @@ namespace OpenSim.Server.Handlers.Simulation
488 m_SimulationService = null; 488 m_SimulationService = null;
489 } 489 }
490 490
491 public override byte[] Handle(string path, Stream request, 491 protected override byte[] ProcessRequest(string path, Stream request,
492 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 492 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
493 { 493 {
494// m_log.DebugFormat("[SIMULATION]: Stream handler called"); 494// m_log.DebugFormat("[SIMULATION]: Stream handler called");
diff --git a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
index 72551ef..24c9de6 100644
--- a/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
+++ b/OpenSim/Server/Handlers/UserAccounts/UserAccountServerPostHandler.cs
@@ -68,7 +68,7 @@ namespace OpenSim.Server.Handlers.UserAccounts
68 } 68 }
69 } 69 }
70 70
71 public override byte[] Handle(string path, Stream requestData, 71 protected override byte[] ProcessRequest(string path, Stream requestData,
72 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse) 72 IOSHttpRequest httpRequest, IOSHttpResponse httpResponse)
73 { 73 {
74 StreamReader sr = new StreamReader(requestData); 74 StreamReader sr = new StreamReader(requestData);
diff --git a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
index 4b502b7..3e06cf0 100644
--- a/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
+++ b/OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs
@@ -66,6 +66,12 @@ namespace OpenSim.Services.Connectors
66 66
67 private Thread[] m_fetchThreads; 67 private Thread[] m_fetchThreads;
68 68
69 public int MaxAssetRequestConcurrency
70 {
71 get { return m_maxAssetRequestConcurrency; }
72 set { m_maxAssetRequestConcurrency = value; }
73 }
74
69 public AssetServicesConnector() 75 public AssetServicesConnector()
70 { 76 {
71 } 77 }
diff --git a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
index 7bb06fb..01163aa 100644
--- a/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
+++ b/OpenSim/Services/Connectors/SimianGrid/SimianPresenceServiceConnector.cs
@@ -65,7 +65,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
65 public void PostInitialise() { } 65 public void PostInitialise() { }
66 public void Close() { } 66 public void Close() { }
67 67
68 public SimianPresenceServiceConnector() { m_activityDetector = new SimianActivityDetector(this); } 68 public SimianPresenceServiceConnector() { }
69 public string Name { get { return "SimianPresenceServiceConnector"; } } 69 public string Name { get { return "SimianPresenceServiceConnector"; } }
70 public void AddRegion(Scene scene) 70 public void AddRegion(Scene scene)
71 { 71 {
@@ -121,6 +121,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
121 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("=")) 121 if (!serviceUrl.EndsWith("/") && !serviceUrl.EndsWith("="))
122 serviceUrl = serviceUrl + '/'; 122 serviceUrl = serviceUrl + '/';
123 m_serverUrl = serviceUrl; 123 m_serverUrl = serviceUrl;
124 m_activityDetector = new SimianActivityDetector(this);
124 m_Enabled = true; 125 m_Enabled = true;
125 } 126 }
126 } 127 }
@@ -314,11 +315,15 @@ namespace OpenSim.Services.Connectors.SimianGrid
314 315
315 UUID userID = new UUID(user); 316 UUID userID = new UUID(user);
316 OSDMap userResponse = GetUserData(userID); 317 OSDMap userResponse = GetUserData(userID);
317 if (userResponse != null)
318 return ResponseToGridUserInfo(userResponse);
319 318
320 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}: {1}",userID,userResponse["Message"].AsString()); 319 if (userResponse == null)
321 return null; 320 {
321 m_log.WarnFormat("[SIMIAN PRESENCE CONNECTOR]: Failed to retrieve user data for {0}", userID);
322 }
323
324 // Note that ResponseToGridUserInfo properly checks for and returns a null if passed a null.
325 return ResponseToGridUserInfo(userResponse);
326
322 } 327 }
323 328
324 #endregion 329 #endregion
diff --git a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
index 410916f..2567c8f 100644
--- a/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
+++ b/OpenSim/Services/HypergridService/HGSuitcaseInventoryService.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Services.HypergridService
54 LogManager.GetLogger( 54 LogManager.GetLogger(
55 MethodBase.GetCurrentMethod().DeclaringType); 55 MethodBase.GetCurrentMethod().DeclaringType);
56 56
57 private string m_HomeURL; 57// private string m_HomeURL;
58 private IUserAccountService m_UserAccountService; 58 private IUserAccountService m_UserAccountService;
59 private IAvatarService m_AvatarService; 59 private IAvatarService m_AvatarService;
60 60
@@ -96,8 +96,8 @@ namespace OpenSim.Services.HypergridService
96 if (m_AvatarService == null) 96 if (m_AvatarService == null)
97 throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll)); 97 throw new Exception(String.Format("Unable to create m_AvatarService from {0}", avatarDll));
98 98
99 m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI", 99// m_HomeURL = Util.GetConfigVarFromSections<string>(config, "HomeURI",
100 new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty); 100// new string[] { "Startup", "Hypergrid", m_ConfigName }, String.Empty);
101 101
102// m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService); 102// m_Cache = UserAccountCache.CreateUserAccountCache(m_UserAccountService);
103 } 103 }
diff --git a/OpenSim/Services/UserAccountService/GridUserService.cs b/OpenSim/Services/UserAccountService/GridUserService.cs
index fa9a4a8..b1cdd45 100644
--- a/OpenSim/Services/UserAccountService/GridUserService.cs
+++ b/OpenSim/Services/UserAccountService/GridUserService.cs
@@ -156,7 +156,7 @@ namespace OpenSim.Services.UserAccountService
156 156
157 public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt) 157 public bool SetLastPosition(string userID, UUID sessionID, UUID regionID, Vector3 lastPosition, Vector3 lastLookAt)
158 { 158 {
159 //m_log.DebugFormat("[Grid User Service]: SetLastPosition for {0}", userID); 159 m_log.DebugFormat("[GRID USER SERVICE]: SetLastPosition for {0}", userID);
160 GridUserData d = m_Database.Get(userID); 160 GridUserData d = m_Database.Get(userID);
161 if (d == null) 161 if (d == null)
162 { 162 {
diff --git a/OpenSim/Tests/Clients/Assets/AssetsClient.cs b/OpenSim/Tests/Clients/Assets/AssetsClient.cs
new file mode 100644
index 0000000..dd168a1
--- /dev/null
+++ b/OpenSim/Tests/Clients/Assets/AssetsClient.cs
@@ -0,0 +1,99 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Text;
32using System.Reflection;
33using System.Threading;
34
35using OpenMetaverse;
36using log4net;
37using log4net.Appender;
38using log4net.Layout;
39
40using OpenSim.Framework;
41using OpenSim.Services.Interfaces;
42using OpenSim.Services.Connectors;
43
44namespace OpenSim.Tests.Clients.AssetsClient
45{
46 public class AssetsClient
47 {
48 private static readonly ILog m_log =
49 LogManager.GetLogger(
50 MethodBase.GetCurrentMethod().DeclaringType);
51
52 private static int m_MaxThreadID = 0;
53 private static readonly int NREQS = 150;
54 private static int m_NReceived = 0;
55
56 public static void Main(string[] args)
57 {
58 ConsoleAppender consoleAppender = new ConsoleAppender();
59 consoleAppender.Layout =
60 new PatternLayout("[%thread] - %message%newline");
61 log4net.Config.BasicConfigurator.Configure(consoleAppender);
62
63 string serverURI = "http://127.0.0.1:8003";
64 if (args.Length > 1)
65 serverURI = args[1];
66 int max1, max2;
67 ThreadPool.GetMaxThreads(out max1, out max2);
68 m_log.InfoFormat("[ASSET CLIENT]: Connecting to {0} max threads = {1} - {2}", serverURI, max1, max2);
69 ThreadPool.GetMinThreads(out max1, out max2);
70 m_log.InfoFormat("[ASSET CLIENT]: Connecting to {0} min threads = {1} - {2}", serverURI, max1, max2);
71 ThreadPool.SetMinThreads(1, 1);
72 ThreadPool.SetMaxThreads(10, 3);
73 ServicePointManager.DefaultConnectionLimit = 12;
74
75 AssetServicesConnector m_Connector = new AssetServicesConnector(serverURI);
76 m_Connector.MaxAssetRequestConcurrency = 30;
77
78 for (int i = 0; i < NREQS; i++)
79 {
80 UUID uuid = UUID.Random();
81 m_Connector.Get(uuid.ToString(), null, ResponseReceived);
82 m_log.InfoFormat("[ASSET CLIENT]: [{0}] requested asset {1}", i, uuid);
83 }
84
85 Thread.Sleep(20 * 1000);
86 m_log.InfoFormat("[ASSET CLIENT]: Received responses {0}", m_NReceived);
87 }
88
89 private static void ResponseReceived(string id, Object sender, AssetBase asset)
90 {
91 if (Thread.CurrentThread.ManagedThreadId > m_MaxThreadID)
92 m_MaxThreadID = Thread.CurrentThread.ManagedThreadId;
93 int max1, max2;
94 ThreadPool.GetAvailableThreads(out max1, out max2);
95 m_log.InfoFormat("[ASSET CLIENT]: Received asset {0} ({1}) ({2}-{3})", id, m_MaxThreadID, max1, max2);
96 m_NReceived++;
97 }
98 }
99}