aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMelanie2013-07-18 10:08:10 +0100
committerMelanie2013-07-18 10:08:10 +0100
commit7830cc995471120892a24a39e86283774fa07c4c (patch)
treed3f46b4f3ce95bb8572511c6f12c9f8ca86922c8 /OpenSim/Region
parentMerge branch 'master' into careminster (diff)
parentDocument obscure Groups config related to the user level required for creatin... (diff)
downloadopensim-SC_OLD-7830cc995471120892a24a39e86283774fa07c4c.zip
opensim-SC_OLD-7830cc995471120892a24a39e86283774fa07c4c.tar.gz
opensim-SC_OLD-7830cc995471120892a24a39e86283774fa07c4c.tar.bz2
opensim-SC_OLD-7830cc995471120892a24a39e86283774fa07c4c.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCaps.cs OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs OpenSim/Region/Framework/Scenes/Scene.cs OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs OpenSim/Region/Framework/Scenes/SceneObjectPart.cs OpenSim/Region/Framework/Scenes/ScenePresence.cs OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs OpenSim/Server/Handlers/Simulation/AgentHandlers.cs OpenSim/Services/Connectors/Asset/AssetServicesConnector.cs OpenSim/Services/Connectors/Simulation/SimulationServiceConnector.cs OpenSim/Services/HypergridService/UserAgentService.cs
Diffstat (limited to 'OpenSim/Region')
-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/UploadBakedTextureModule.cs39
-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.cs3
-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.cs370
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs14
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs13
-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/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs29
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs40
-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.cs84
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs25
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.Inventory.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs33
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCapabilityTests.cs88
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs1
-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.cs7
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs23
65 files changed, 1848 insertions, 936 deletions
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/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
index eca576d..674b451 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
@@ -64,11 +64,18 @@ namespace OpenSim.Region.ClientStack.Linden
64 64
65 private Scene m_scene; 65 private Scene m_scene;
66 private bool m_persistBakedTextures; 66 private bool m_persistBakedTextures;
67 private string m_URL;
67 68
68 private IBakedTextureModule m_BakedTextureModule; 69 private IBakedTextureModule m_BakedTextureModule;
69 70
70 public void Initialise(IConfigSource source) 71 public void Initialise(IConfigSource source)
71 { 72 {
73 IConfig config = source.Configs["ClientStack.LindenCaps"];
74 if (config == null)
75 return;
76
77 m_URL = config.GetString("Cap_UploadBakedTexture", string.Empty);
78
72 IConfig appearanceConfig = source.Configs["Appearance"]; 79 IConfig appearanceConfig = source.Configs["Appearance"];
73 if (appearanceConfig != null) 80 if (appearanceConfig != null)
74 m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); 81 m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
@@ -283,20 +290,26 @@ namespace OpenSim.Region.ClientStack.Linden
283 UploadBakedTextureHandler avatarhandler = new UploadBakedTextureHandler( 290 UploadBakedTextureHandler avatarhandler = new UploadBakedTextureHandler(
284 caps, m_scene.AssetService, m_persistBakedTextures); 291 caps, m_scene.AssetService, m_persistBakedTextures);
285 292
286 293 UUID capID = UUID.Random();
287
288 caps.RegisterHandler(
289 "UploadBakedTexture",
290 new RestStreamHandler(
291 "POST",
292 "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath,
293 avatarhandler.UploadBakedTexture,
294 "UploadBakedTexture",
295 agentID.ToString()));
296 294
297 295 //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture));
298 296 if (m_URL == "localhost")
297 {
298 caps.RegisterHandler(
299 "UploadBakedTexture",
300 new RestStreamHandler(
301 "POST",
302 "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath,
303 avatarhandler.UploadBakedTexture,
304 "UploadBakedTexture",
305 agentID.ToString()));
306
307 }
308 else
309 {
310 caps.RegisterHandler("UploadBakedTexture", m_URL);
311 }
299 312
300 } 313 }
301 } 314 }
302} \ No newline at end of file 315}
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..77b07ed 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -1512,6 +1512,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1512 { 1512 {
1513 AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(uccp.CircuitCode.Code); 1513 AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(uccp.CircuitCode.Code);
1514 bool tp = (aCircuit.teleportFlags > 0); 1514 bool tp = (aCircuit.teleportFlags > 0);
1515 // Let's delay this for TP agents, otherwise the viewer doesn't know where to get resources from
1515 if (!tp) 1516 if (!tp)
1516 client.SceneAgent.SendInitialDataToMe(); 1517 client.SceneAgent.SendInitialDataToMe();
1517 } 1518 }
@@ -1686,6 +1687,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1686 { 1687 {
1687 IncomingPacket incomingPacket = null; 1688 IncomingPacket incomingPacket = null;
1688 1689
1690 /*
1689 // HACK: This is a test to try and rate limit packet handling on Mono. 1691 // 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 1692 // If it works, a more elegant solution can be devised
1691 if (Util.FireAndForgetCount() < 2) 1693 if (Util.FireAndForgetCount() < 2)
@@ -1693,6 +1695,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1693 //m_log.Debug("[LLUDPSERVER]: Incoming packet handler is sleeping"); 1695 //m_log.Debug("[LLUDPSERVER]: Incoming packet handler is sleeping");
1694 Thread.Sleep(30); 1696 Thread.Sleep(30);
1695 } 1697 }
1698 */
1696 1699
1697 if (packetInbox.Dequeue(100, ref incomingPacket)) 1700 if (packetInbox.Dequeue(100, ref incomingPacket))
1698 { 1701 {
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..3d5ed4f 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,35 +124,42 @@ 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 lock (m_capsObjects)
112 { 131 {
113 Caps oldCaps = m_capsObjects[circuitCode]; 132 if (m_capsObjects.ContainsKey(circuitCode))
114 133 {
115 m_log.DebugFormat( 134 Caps oldCaps = m_capsObjects[circuitCode];
116 "[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ", 135
117 agentId, oldCaps.CapsObjectPath, capsObjectPath); 136 m_log.DebugFormat(
118 // This should not happen. The caller code is confused. We need to fix that. 137 "[CAPS]: Recreating caps for agent {0}. Old caps path {1}, new caps path {2}. ",
119 // CAPs can never be reregistered, or the client will be confused. 138 agentId, oldCaps.CapsObjectPath, capsObjectPath);
120 // Hence this return here. 139 // This should not happen. The caller code is confused. We need to fix that.
121 //return; 140 // CAPs can never be reregistered, or the client will be confused.
122 } 141 // Hence this return here.
142 //return;
143 }
123 144
124 Caps caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName, 145 caps = new Caps(MainServer.Instance, m_scene.RegionInfo.ExternalHostName,
125 (MainServer.Instance == null) ? 0: MainServer.Instance.Port, 146 (MainServer.Instance == null) ? 0: MainServer.Instance.Port,
126 capsObjectPath, agentId, m_scene.RegionInfo.RegionName); 147 capsObjectPath, agentId, m_scene.RegionInfo.RegionName);
127 148
128 m_capsObjects[circuitCode] = caps; 149 m_capsObjects[circuitCode] = caps;
150 }
129 151
130 m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps); 152 m_scene.EventManager.TriggerOnRegisterCaps(agentId, caps);
131 } 153 }
132 154
133 public void RemoveCaps(UUID agentId, uint circuitCode) 155 public void RemoveCaps(UUID agentId, uint circuitCode)
134 { 156 {
135 if (childrenSeeds.ContainsKey(agentId)) 157 lock (m_childrenSeeds)
136 { 158 {
137 childrenSeeds.Remove(agentId); 159 if (m_childrenSeeds.ContainsKey(agentId))
160 {
161 m_childrenSeeds.Remove(agentId);
162 }
138 } 163 }
139 164
140 lock (m_capsObjects) 165 lock (m_capsObjects)
@@ -180,16 +205,22 @@ namespace OpenSim.Region.CoreModules.Framework
180 205
181 public void SetAgentCapsSeeds(AgentCircuitData agent) 206 public void SetAgentCapsSeeds(AgentCircuitData agent)
182 { 207 {
183 capsPaths[agent.AgentID] = agent.CapsPath; 208 lock (m_capsPaths)
184 childrenSeeds[agent.AgentID] 209 m_capsPaths[agent.AgentID] = agent.CapsPath;
185 = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds); 210
211 lock (m_childrenSeeds)
212 m_childrenSeeds[agent.AgentID]
213 = ((agent.ChildrenCapSeeds == null) ? new Dictionary<ulong, string>() : agent.ChildrenCapSeeds);
186 } 214 }
187 215
188 public string GetCapsPath(UUID agentId) 216 public string GetCapsPath(UUID agentId)
189 { 217 {
190 if (capsPaths.ContainsKey(agentId)) 218 lock (m_capsPaths)
191 { 219 {
192 return capsPaths[agentId]; 220 if (m_capsPaths.ContainsKey(agentId))
221 {
222 return m_capsPaths[agentId];
223 }
193 } 224 }
194 225
195 return null; 226 return null;
@@ -198,17 +229,24 @@ namespace OpenSim.Region.CoreModules.Framework
198 public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID) 229 public Dictionary<ulong, string> GetChildrenSeeds(UUID agentID)
199 { 230 {
200 Dictionary<ulong, string> seeds = null; 231 Dictionary<ulong, string> seeds = null;
201 if (childrenSeeds.TryGetValue(agentID, out seeds)) 232
202 return seeds; 233 lock (m_childrenSeeds)
234 if (m_childrenSeeds.TryGetValue(agentID, out seeds))
235 return seeds;
236
203 return new Dictionary<ulong, string>(); 237 return new Dictionary<ulong, string>();
204 } 238 }
205 239
206 public void DropChildSeed(UUID agentID, ulong handle) 240 public void DropChildSeed(UUID agentID, ulong handle)
207 { 241 {
208 Dictionary<ulong, string> seeds; 242 Dictionary<ulong, string> seeds;
209 if (childrenSeeds.TryGetValue(agentID, out seeds)) 243
244 lock (m_childrenSeeds)
210 { 245 {
211 seeds.Remove(handle); 246 if (m_childrenSeeds.TryGetValue(agentID, out seeds))
247 {
248 seeds.Remove(handle);
249 }
212 } 250 }
213 } 251 }
214 252
@@ -216,53 +254,285 @@ namespace OpenSim.Region.CoreModules.Framework
216 { 254 {
217 Dictionary<ulong, string> seeds; 255 Dictionary<ulong, string> seeds;
218 string returnval; 256 string returnval;
219 if (childrenSeeds.TryGetValue(agentID, out seeds)) 257
258 lock (m_childrenSeeds)
220 { 259 {
221 if (seeds.TryGetValue(handle, out returnval)) 260 if (m_childrenSeeds.TryGetValue(agentID, out seeds))
222 return returnval; 261 {
262 if (seeds.TryGetValue(handle, out returnval))
263 return returnval;
264 }
223 } 265 }
266
224 return null; 267 return null;
225 } 268 }
226 269
227 public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds) 270 public void SetChildrenSeed(UUID agentID, Dictionary<ulong, string> seeds)
228 { 271 {
229 //m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count); 272 //m_log.DebugFormat(" !!! Setting child seeds in {0} to {1}", m_scene.RegionInfo.RegionName, seeds.Count);
230 childrenSeeds[agentID] = seeds; 273
274 lock (m_childrenSeeds)
275 m_childrenSeeds[agentID] = seeds;
231 } 276 }
232 277
233 public void DumpChildrenSeeds(UUID agentID) 278 public void DumpChildrenSeeds(UUID agentID)
234 { 279 {
235 m_log.Info("================ ChildrenSeed "+m_scene.RegionInfo.RegionName+" ================"); 280 m_log.Info("================ ChildrenSeed "+m_scene.RegionInfo.RegionName+" ================");
236 foreach (KeyValuePair<ulong, string> kvp in childrenSeeds[agentID]) 281
282 lock (m_childrenSeeds)
237 { 283 {
238 uint x, y; 284 foreach (KeyValuePair<ulong, string> kvp in m_childrenSeeds[agentID])
239 Utils.LongToUInts(kvp.Key, out x, out y); 285 {
240 x = x / Constants.RegionSize; 286 uint x, y;
241 y = y / Constants.RegionSize; 287 Utils.LongToUInts(kvp.Key, out x, out y);
242 m_log.Info(" >> "+x+", "+y+": "+kvp.Value); 288 x = x / Constants.RegionSize;
289 y = y / Constants.RegionSize;
290 m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
291 }
243 } 292 }
244 } 293 }
245 294
246 private void HandleShowCapsCommand(string module, string[] cmdparams) 295 private void HandleShowCapsListCommand(string module, string[] cmdParams)
247 { 296 {
297 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
298 return;
299
248 StringBuilder caps = new StringBuilder(); 300 StringBuilder caps = new StringBuilder();
249 caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName); 301 caps.AppendFormat("Region {0}:\n", m_scene.RegionInfo.RegionName);
250 302
251 foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects) 303 lock (m_capsObjects)
252 { 304 {
253 caps.AppendFormat("** Circuit {0}:\n", kvp.Key); 305 foreach (KeyValuePair<uint, Caps> kvp in m_capsObjects)
306 {
307 caps.AppendFormat("** Circuit {0}:\n", kvp.Key);
308
309 for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); )
310 {
311 Uri uri = new Uri(kvp2.Value.ToString());
312 caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery);
313 }
314
315 foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers)
316 caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value);
317 }
318 }
254 319
255 for (IDictionaryEnumerator kvp2 = kvp.Value.CapsHandlers.GetCapsDetails(false, null).GetEnumerator(); kvp2.MoveNext(); ) 320 MainConsole.Instance.Output(caps.ToString());
321 }
322
323 private void HandleShowCapsStatsByCapCommand(string module, string[] cmdParams)
324 {
325 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
326 return;
327
328 if (cmdParams.Length != 5 && cmdParams.Length != 6)
329 {
330 MainConsole.Instance.Output("Usage: show caps stats by cap [<cap-name>]");
331 return;
332 }
333
334 StringBuilder sb = new StringBuilder();
335 sb.AppendFormat("Region {0}:\n", m_scene.Name);
336
337 if (cmdParams.Length == 5)
338 {
339 BuildSummaryStatsByCapReport(sb);
340 }
341 else if (cmdParams.Length == 6)
342 {
343 BuildDetailedStatsByCapReport(sb, cmdParams[5]);
344 }
345
346 MainConsole.Instance.Output(sb.ToString());
347 }
348
349 private void BuildDetailedStatsByCapReport(StringBuilder sb, string capName)
350 {
351 /*
352 sb.AppendFormat("Capability name {0}\n", capName);
353
354 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
355 cdt.AddColumn("User Name", 34);
356 cdt.AddColumn("Req Received", 12);
357 cdt.AddColumn("Req Handled", 12);
358 cdt.Indent = 2;
359
360 Dictionary<string, int> receivedStats = new Dictionary<string, int>();
361 Dictionary<string, int> handledStats = new Dictionary<string, int>();
362
363 m_scene.ForEachScenePresence(
364 sp =>
256 { 365 {
257 Uri uri = new Uri(kvp2.Value.ToString()); 366 Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
258 caps.AppendFormat(m_showCapsCommandFormat, kvp2.Key, uri.PathAndQuery); 367
368 if (caps == null)
369 return;
370
371 Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
372
373 IRequestHandler reqHandler;
374 if (capsHandlers.TryGetValue(capName, out reqHandler))
375 {
376 receivedStats[sp.Name] = reqHandler.RequestsReceived;
377 handledStats[sp.Name] = reqHandler.RequestsHandled;
378 }
259 } 379 }
380 );
260 381
261 foreach (KeyValuePair<string, string> kvp3 in kvp.Value.ExternalCapsHandlers) 382 foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value))
262 caps.AppendFormat(m_showCapsCommandFormat, kvp3.Key, kvp3.Value); 383 {
384 cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]);
263 } 385 }
264 386
265 MainConsole.Instance.Output(caps.ToString()); 387 sb.Append(cdt.ToString());
388 */
389 }
390
391 private void BuildSummaryStatsByCapReport(StringBuilder sb)
392 {
393 /*
394 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
395 cdt.AddColumn("Name", 34);
396 cdt.AddColumn("Req Received", 12);
397 cdt.AddColumn("Req Handled", 12);
398 cdt.Indent = 2;
399
400 Dictionary<string, int> receivedStats = new Dictionary<string, int>();
401 Dictionary<string, int> handledStats = new Dictionary<string, int>();
402
403 m_scene.ForEachScenePresence(
404 sp =>
405 {
406 Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
407
408 if (caps == null)
409 return;
410
411 Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
412
413 foreach (IRequestHandler reqHandler in capsHandlers.Values)
414 {
415 string reqName = reqHandler.Name ?? "";
416
417 if (!receivedStats.ContainsKey(reqName))
418 {
419 receivedStats[reqName] = reqHandler.RequestsReceived;
420 handledStats[reqName] = reqHandler.RequestsHandled;
421 }
422 else
423 {
424 receivedStats[reqName] += reqHandler.RequestsReceived;
425 handledStats[reqName] += reqHandler.RequestsHandled;
426 }
427 }
428 }
429 );
430
431 foreach (KeyValuePair<string, int> kvp in receivedStats.OrderByDescending(kp => kp.Value))
432 cdt.AddRow(kvp.Key, kvp.Value, handledStats[kvp.Key]);
433
434 sb.Append(cdt.ToString());
435 */
436 }
437
438 private void HandleShowCapsStatsByUserCommand(string module, string[] cmdParams)
439 {
440 /*
441 if (SceneManager.Instance.CurrentScene != null && SceneManager.Instance.CurrentScene != m_scene)
442 return;
443
444 if (cmdParams.Length != 5 && cmdParams.Length != 7)
445 {
446 MainConsole.Instance.Output("Usage: show caps stats by user [<first-name> <last-name>]");
447 return;
448 }
449
450 StringBuilder sb = new StringBuilder();
451 sb.AppendFormat("Region {0}:\n", m_scene.Name);
452
453 if (cmdParams.Length == 5)
454 {
455 BuildSummaryStatsByUserReport(sb);
456 }
457 else if (cmdParams.Length == 7)
458 {
459 string firstName = cmdParams[5];
460 string lastName = cmdParams[6];
461
462 ScenePresence sp = m_scene.GetScenePresence(firstName, lastName);
463
464 if (sp == null)
465 return;
466
467 BuildDetailedStatsByUserReport(sb, sp);
468 }
469
470 MainConsole.Instance.Output(sb.ToString());
471 */
472 }
473
474 private void BuildDetailedStatsByUserReport(StringBuilder sb, ScenePresence sp)
475 {
476 /*
477 sb.AppendFormat("Avatar name {0}, type {1}\n", sp.Name, sp.IsChildAgent ? "child" : "root");
478
479 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
480 cdt.AddColumn("Cap Name", 34);
481 cdt.AddColumn("Req Received", 12);
482 cdt.AddColumn("Req Handled", 12);
483 cdt.Indent = 2;
484
485 Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
486
487 if (caps == null)
488 return;
489
490 Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
491
492 foreach (IRequestHandler reqHandler in capsHandlers.Values.OrderByDescending(rh => rh.RequestsReceived))
493 {
494 cdt.AddRow(reqHandler.Name, reqHandler.RequestsReceived, reqHandler.RequestsHandled);
495 }
496
497 sb.Append(cdt.ToString());
498 */
499 }
500
501 private void BuildSummaryStatsByUserReport(StringBuilder sb)
502 {
503 /*
504 ConsoleDisplayTable cdt = new ConsoleDisplayTable();
505 cdt.AddColumn("Name", 32);
506 cdt.AddColumn("Type", 5);
507 cdt.AddColumn("Req Received", 12);
508 cdt.AddColumn("Req Handled", 12);
509 cdt.Indent = 2;
510
511 m_scene.ForEachScenePresence(
512 sp =>
513 {
514 Caps caps = m_scene.CapsModule.GetCapsForUser(sp.UUID);
515
516 if (caps == null)
517 return;
518
519 Dictionary<string, IRequestHandler> capsHandlers = caps.CapsHandlers.GetCapsHandlers();
520
521 int totalRequestsReceived = 0;
522 int totalRequestsHandled = 0;
523
524 foreach (IRequestHandler reqHandler in capsHandlers.Values)
525 {
526 totalRequestsReceived += reqHandler.RequestsReceived;
527 totalRequestsHandled += reqHandler.RequestsHandled;
528 }
529
530 cdt.AddRow(sp.Name, sp.IsChildAgent ? "child" : "root", totalRequestsReceived, totalRequestsHandled);
531 }
532 );
533
534 sb.Append(cdt.ToString());
535 */
266 } 536 }
267 } 537 }
268} 538}
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index b9c88d4..a3c539d 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -822,7 +822,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
822 "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1} from {2}. Keeping avatar in source region.", 822 "[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1} from {2}. Keeping avatar in source region.",
823 sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); 823 sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName);
824 824
825 Fail(sp, finalDestination, logout, "Connection between viewer and destination region could not be established."); 825 Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Connection between viewer and destination region could not be established.");
826 return; 826 return;
827 } 827 }
828 828
@@ -834,7 +834,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
834 "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after UpdateAgent on client request", 834 "[ENTITY TRANSFER MODULE]: Cancelled teleport of {0} to {1} from {2} after UpdateAgent on client request",
835 sp.Name, finalDestination.RegionName, sp.Scene.Name); 835 sp.Name, finalDestination.RegionName, sp.Scene.Name);
836 836
837 CleanupFailedInterRegionTeleport(sp, finalDestination); 837 CleanupFailedInterRegionTeleport(sp, currentAgentCircuit.SessionID.ToString(), finalDestination);
838 838
839 return; 839 return;
840 } 840 }
@@ -878,7 +878,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
878 "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} from {2} failed due to no callback from destination region. Returning avatar to source region.", 878 "[ENTITY TRANSFER MODULE]: Teleport of {0} to {1} from {2} failed due to no callback from destination region. Returning avatar to source region.",
879 sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName); 879 sp.Name, finalDestination.RegionName, sp.Scene.RegionInfo.RegionName);
880 880
881 Fail(sp, finalDestination, logout, "Destination region did not signal teleport completion."); 881 Fail(sp, finalDestination, logout, currentAgentCircuit.SessionID.ToString(), "Destination region did not signal teleport completion.");
882 882
883 return; 883 return;
884 } 884 }
@@ -932,7 +932,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
932 /// <remarks> 932 /// <remarks>
933 /// <param name='sp'> </param> 933 /// <param name='sp'> </param>
934 /// <param name='finalDestination'></param> 934 /// <param name='finalDestination'></param>
935 protected virtual void CleanupFailedInterRegionTeleport(ScenePresence sp, GridRegion finalDestination) 935 protected virtual void CleanupFailedInterRegionTeleport(ScenePresence sp, string auth_token, GridRegion finalDestination)
936 { 936 {
937 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp); 937 m_entityTransferStateMachine.UpdateInTransit(sp.UUID, AgentTransferState.CleaningUp);
938 938
@@ -943,7 +943,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
943 943
944 // Finally, kill the agent we just created at the destination. 944 // Finally, kill the agent we just created at the destination.
945 // XXX: Possibly this should be done asynchronously. 945 // XXX: Possibly this should be done asynchronously.
946 Scene.SimulationService.CloseAgent(finalDestination, sp.UUID); 946 Scene.SimulationService.CloseAgent(finalDestination, sp.UUID, auth_token);
947 } 947 }
948 948
949 /// <summary> 949 /// <summary>
@@ -953,9 +953,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
953 /// <param name='finalDestination'></param> 953 /// <param name='finalDestination'></param>
954 /// <param name='logout'></param> 954 /// <param name='logout'></param>
955 /// <param name='reason'>Human readable reason for teleport failure. Will be sent to client.</param> 955 /// <param name='reason'>Human readable reason for teleport failure. Will be sent to client.</param>
956 protected virtual void Fail(ScenePresence sp, GridRegion finalDestination, bool logout, string reason) 956 protected virtual void Fail(ScenePresence sp, GridRegion finalDestination, bool logout, string auth_code, string reason)
957 { 957 {
958 CleanupFailedInterRegionTeleport(sp, finalDestination); 958 CleanupFailedInterRegionTeleport(sp, auth_code, finalDestination);
959 959
960 m_interRegionTeleportFailures.Value++; 960 m_interRegionTeleportFailures.Value++;
961 961
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs
index 73b3678f..1cf1884 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)
@@ -207,6 +207,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
207 { 207 {
208 m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService); 208 m_GatekeeperConnector = new GatekeeperServiceConnector(scene.AssetService);
209 m_UAS = scene.RequestModuleInterface<IUserAgentService>(); 209 m_UAS = scene.RequestModuleInterface<IUserAgentService>();
210 if (m_UAS == null)
211 m_UAS = new UserAgentServiceConnector(m_ThisHomeURI);
212
210 } 213 }
211 } 214 }
212 215
@@ -571,12 +574,12 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
571 if (uMan != null && uMan.IsLocalGridUser(obj.AgentId)) 574 if (uMan != null && uMan.IsLocalGridUser(obj.AgentId))
572 { 575 {
573 // local grid user 576 // local grid user
577 m_UAS.LogoutAgent(obj.AgentId, obj.SessionId);
574 return; 578 return;
575 } 579 }
576 580
577 AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode); 581 AgentCircuitData aCircuit = ((Scene)(obj.Scene)).AuthenticateHandler.GetAgentCircuitData(obj.CircuitCode);
578 582 if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("HomeURI"))
579 if (aCircuit.ServiceURLs.ContainsKey("HomeURI"))
580 { 583 {
581 string url = aCircuit.ServiceURLs["HomeURI"].ToString(); 584 string url = aCircuit.ServiceURLs["HomeURI"].ToString();
582 IUserAgentService security = new UserAgentServiceConnector(url); 585 IUserAgentService security = new UserAgentServiceConnector(url);
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/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index e4aa7bc..8207fb9 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -250,26 +250,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
250 return true; 250 return true;
251 } 251 }
252 252
253 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
254 {
255 agent = null;
256
257 if (destination == null)
258 return false;
259
260 if (m_scenes.ContainsKey(destination.RegionID))
261 {
262// m_log.DebugFormat(
263// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
264// s.RegionInfo.RegionName, destination.RegionHandle);
265
266 return m_scenes[destination.RegionID].IncomingRetrieveRootAgent(id, out agent);
267 }
268
269 //m_log.Debug("[LOCAL COMMS]: region not found for ChildAgentUpdate");
270 return false;
271 }
272
273 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason) 253 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason)
274 { 254 {
275 reason = "Communications failure"; 255 reason = "Communications failure";
@@ -306,12 +286,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
306 return false; 286 return false;
307 } 287 }
308 288
309 public bool CloseChildAgent(GridRegion destination, UUID id) 289 public bool CloseAgent(GridRegion destination, UUID id, string auth_token)
310 {
311 return CloseAgent(destination, id);
312 }
313
314 public bool CloseAgent(GridRegion destination, UUID id)
315 { 290 {
316 if (destination == null) 291 if (destination == null)
317 return false; 292 return false;
@@ -322,7 +297,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
322// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate", 297// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
323// s.RegionInfo.RegionName, destination.RegionHandle); 298// s.RegionInfo.RegionName, destination.RegionHandle);
324 299
325 m_scenes[destination.RegionID].IncomingCloseAgent(id, false); 300 m_scenes[destination.RegionID].IncomingCloseAgent(id, false, auth_token);
326 return true; 301 return true;
327 } 302 }
328 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); 303 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent");
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
index f7dae59..a1ab3e3 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs
@@ -212,24 +212,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
212 return m_remoteConnector.UpdateAgent(destination, cAgentData); 212 return m_remoteConnector.UpdateAgent(destination, cAgentData);
213 } 213 }
214 214
215 public bool RetrieveAgent(GridRegion destination, UUID id, out IAgentData agent)
216 {
217 agent = null;
218
219 if (destination == null)
220 return false;
221
222 // Try local first
223 if (m_localBackend.RetrieveAgent(destination, id, out agent))
224 return true;
225
226 // else do the remote thing
227 if (!m_localBackend.IsLocalRegion(destination.RegionID))
228 return m_remoteConnector.RetrieveAgent(destination, id, out agent);
229
230 return false;
231 }
232
233 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason) 215 public bool QueryAccess(GridRegion destination, UUID id, Vector3 position, out string version, out string reason)
234 { 216 {
235 reason = "Communications failure"; 217 reason = "Communications failure";
@@ -262,34 +244,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
262 return false; 244 return false;
263 } 245 }
264 246
265 public bool CloseChildAgent(GridRegion destination, UUID id) 247 public bool CloseAgent(GridRegion destination, UUID id, string auth_token)
266 {
267 if (destination == null)
268 return false;
269
270 // Try local first
271 if (m_localBackend.CloseChildAgent(destination, id))
272 return true;
273
274 // else do the remote thing
275 if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
276 return m_remoteConnector.CloseChildAgent(destination, id);
277
278 return false;
279 }
280
281 public bool CloseAgent(GridRegion destination, UUID id)
282 { 248 {
283 if (destination == null) 249 if (destination == null)
284 return false; 250 return false;
285 251
286 // Try local first 252 // Try local first
287 if (m_localBackend.CloseAgent(destination, id)) 253 if (m_localBackend.CloseAgent(destination, id, auth_token))
288 return true; 254 return true;
289 255
290 // else do the remote thing 256 // else do the remote thing
291 if (!m_localBackend.IsLocalRegion(destination.RegionID)) 257 if (!m_localBackend.IsLocalRegion(destination.RegionID))
292 return m_remoteConnector.CloseAgent(destination, id); 258 return m_remoteConnector.CloseAgent(destination, id, auth_token);
293 259
294 return false; 260 return false;
295 } 261 }
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..c132c5d 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)
@@ -3611,7 +3609,7 @@ namespace OpenSim.Region.Framework.Scenes
3611 regions.Remove(RegionInfo.RegionHandle); 3609 regions.Remove(RegionInfo.RegionHandle);
3612 3610
3613 // This ends up being done asynchronously so that a logout isn't held up where there are many present but unresponsive neighbours. 3611 // This ends up being done asynchronously so that a logout isn't held up where there are many present but unresponsive neighbours.
3614 m_sceneGridService.SendCloseChildAgentConnections(agentID, regions); 3612 m_sceneGridService.SendCloseChildAgentConnections(agentID, acd.SessionID.ToString(), regions);
3615 } 3613 }
3616 3614
3617 m_eventManager.TriggerClientClosed(agentID, this); 3615 m_eventManager.TriggerClientClosed(agentID, this);
@@ -3858,8 +3856,10 @@ namespace OpenSim.Region.Framework.Scenes
3858 m_log.WarnFormat( 3856 m_log.WarnFormat(
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);
3859
3860 if (sp.ControllingClient != null)
3861 sp.ControllingClient.Close(true, true);
3861 3862
3862 sp.ControllingClient.Close(true, true);
3863 sp = null; 3863 sp = null;
3864 } 3864 }
3865 } 3865 }
@@ -4394,10 +4394,16 @@ namespace OpenSim.Region.Framework.Scenes
4394 4394
4395 if (childAgentUpdate != null) 4395 if (childAgentUpdate != null)
4396 { 4396 {
4397 if (cAgentData.SessionID != childAgentUpdate.ControllingClient.SessionId)
4398 {
4399 m_log.WarnFormat("[SCENE]: Attempt to update agent {0} with invalid session id {1} (possibly from simulator in older version; tell them to update).", childAgentUpdate.UUID, cAgentData.SessionID);
4400 Console.WriteLine(String.Format("[SCENE]: Attempt to update agent {0} ({1}) with invalid session id {2}",
4401 childAgentUpdate.UUID, childAgentUpdate.ControllingClient.SessionId, cAgentData.SessionID));
4402 }
4403
4397 childAgentUpdate.ChildAgentDataUpdate(cAgentData); 4404 childAgentUpdate.ChildAgentDataUpdate(cAgentData);
4398 return true; 4405 return true;
4399 } 4406 }
4400
4401 return false; 4407 return false;
4402 } 4408 }
4403 4409
@@ -4413,20 +4419,24 @@ namespace OpenSim.Region.Framework.Scenes
4413 ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID); 4419 ScenePresence childAgentUpdate = GetScenePresence(cAgentData.AgentID);
4414 if (childAgentUpdate != null) 4420 if (childAgentUpdate != null)
4415 { 4421 {
4416 // I can't imagine *yet* why we would get an update if the agent is a root agent.. 4422 if (childAgentUpdate.ControllingClient.SessionId == cAgentData.SessionID)
4417 // however to avoid a race condition crossing borders.. 4423 {
4418 if (childAgentUpdate.IsChildAgent) 4424 // I can't imagine *yet* why we would get an update if the agent is a root agent..
4419 { 4425 // however to avoid a race condition crossing borders..
4420 uint rRegionX = (uint)(cAgentData.RegionHandle >> 40); 4426 if (childAgentUpdate.IsChildAgent)
4421 uint rRegionY = (((uint)(cAgentData.RegionHandle)) >> 8); 4427 {
4422 uint tRegionX = RegionInfo.RegionLocX; 4428 uint rRegionX = (uint)(cAgentData.RegionHandle >> 40);
4423 uint tRegionY = RegionInfo.RegionLocY; 4429 uint rRegionY = (((uint)(cAgentData.RegionHandle)) >> 8);
4424 //Send Data to ScenePresence 4430 uint tRegionX = RegionInfo.RegionLocX;
4425 childAgentUpdate.ChildAgentDataUpdate(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY); 4431 uint tRegionY = RegionInfo.RegionLocY;
4426 // Not Implemented: 4432 //Send Data to ScenePresence
4427 //TODO: Do we need to pass the message on to one of our neighbors? 4433 childAgentUpdate.ChildAgentDataUpdate(cAgentData, tRegionX, tRegionY, rRegionX, rRegionY);
4434 // Not Implemented:
4435 //TODO: Do we need to pass the message on to one of our neighbors?
4436 }
4428 } 4437 }
4429 4438 else
4439 m_log.WarnFormat("[SCENE]: Attempt at updating position of agent {0} with invalid session id {1}", childAgentUpdate.UUID, cAgentData.SessionID);
4430 return true; 4440 return true;
4431 } 4441 }
4432 4442
@@ -4469,6 +4479,25 @@ namespace OpenSim.Region.Framework.Scenes
4469 4479
4470 return false; 4480 return false;
4471 } 4481 }
4482 /// <summary>
4483 /// Authenticated close (via network)
4484 /// </summary>
4485 /// <param name="agentID"></param>
4486 /// <param name="force"></param>
4487 /// <param name="auth_token"></param>
4488 /// <returns></returns>
4489 public bool IncomingCloseAgent(UUID agentID, bool force, string auth_token)
4490 {
4491 //m_log.DebugFormat("[SCENE]: Processing incoming close agent {0} in region {1} with auth_token {2}", agentID, RegionInfo.RegionName, auth_token);
4492
4493 // Check that the auth_token is valid
4494 AgentCircuitData acd = AuthenticateHandler.GetAgentCircuitData(agentID);
4495 if (acd != null && acd.SessionID.ToString() == auth_token)
4496 return IncomingCloseAgent(agentID, force);
4497 else
4498 m_log.ErrorFormat("[SCENE]: Request to close agent {0} with invalid authorization token {1}", agentID, auth_token);
4499 return false;
4500 }
4472 4501
4473 public bool IncomingCloseAgent(UUID agentID) 4502 public bool IncomingCloseAgent(UUID agentID)
4474 { 4503 {
@@ -4491,7 +4520,6 @@ namespace OpenSim.Region.Framework.Scenes
4491 public bool IncomingCloseAgent(UUID agentID, bool force) 4520 public bool IncomingCloseAgent(UUID agentID, bool force)
4492 { 4521 {
4493 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 4522 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
4494
4495 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); 4523 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID);
4496 if (presence != null) 4524 if (presence != null)
4497 { 4525 {
@@ -4499,7 +4527,7 @@ namespace OpenSim.Region.Framework.Scenes
4499 return true; 4527 return true;
4500 } 4528 }
4501 4529
4502 // Agent not here 4530 // Agent not here
4503 return false; 4531 return false;
4504 } 4532 }
4505 4533
@@ -5089,22 +5117,6 @@ namespace OpenSim.Region.Framework.Scenes
5089 5117
5090 #endregion 5118 #endregion
5091 5119
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 5120
5109// Commented pending deletion since this method no longer appears to do anything at all 5121// Commented pending deletion since this method no longer appears to do anything at all
5110// public bool NeedSceneCacheClear(UUID agentID) 5122// public bool NeedSceneCacheClear(UUID agentID)
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index df61dde..52f46f2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -200,7 +200,7 @@ namespace OpenSim.Region.Framework.Scenes
200 /// This Closes child agents on neighboring regions 200 /// This Closes child agents on neighboring regions
201 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 201 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
202 /// </summary> 202 /// </summary>
203 protected void SendCloseChildAgentAsync(UUID agentID, ulong regionHandle) 203 protected void SendCloseChildAgent(UUID agentID, ulong regionHandle, string auth_token)
204 { 204 {
205 // let's do our best, but there's not much we can do if the neighbour doesn't accept. 205 // let's do our best, but there's not much we can do if the neighbour doesn't accept.
206 206
@@ -209,24 +209,25 @@ namespace OpenSim.Region.Framework.Scenes
209 Utils.LongToUInts(regionHandle, out x, out y); 209 Utils.LongToUInts(regionHandle, out x, out y);
210 210
211 GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y); 211 GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y);
212 m_scene.SimulationService.CloseChildAgent(destination, agentID);
213 }
214 212
215 private void SendCloseChildAgentCompleted(IAsyncResult iar) 213 m_log.DebugFormat(
216 { 214 "[SCENE COMMUNICATION SERVICE]: Sending close agent ID {0} to {1}", agentID, destination.RegionName);
217 SendCloseChildAgentDelegate icon = (SendCloseChildAgentDelegate)iar.AsyncState; 215
218 icon.EndInvoke(iar); 216 m_scene.SimulationService.CloseAgent(destination, agentID, auth_token);
219 } 217 }
220 218
221 public void SendCloseChildAgentConnections(UUID agentID, List<ulong> regionslst) 219 /// <summary>
220 /// Closes a child agents in a collection of regions. Does so asynchronously
221 /// so that the caller doesn't wait.
222 /// </summary>
223 /// <param name="agentID"></param>
224 /// <param name="regionslst"></param>
225 public void SendCloseChildAgentConnections(UUID agentID, string auth_code, List<ulong> regionslst)
222 { 226 {
223 foreach (ulong handle in regionslst) 227 foreach (ulong handle in regionslst)
224 { 228 {
225 ulong handleCopy = handle; 229 ulong handleCopy = handle;
226 SendCloseChildAgentDelegate d = SendCloseChildAgentAsync; 230 Util.FireAndForget((o) => { SendCloseChildAgent(agentID, handleCopy, auth_code); });
227 d.BeginInvoke(agentID, handleCopy,
228 SendCloseChildAgentCompleted,
229 d);
230 } 231 }
231 } 232 }
232 233
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..95ffc77 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -543,7 +543,11 @@ namespace OpenSim.Region.Framework.Scenes
543 CreatorID = uuid; 543 CreatorID = uuid;
544 } 544 }
545 if (parts.Length >= 2) 545 if (parts.Length >= 2)
546 {
546 CreatorData = parts[1]; 547 CreatorData = parts[1];
548 if (!CreatorData.EndsWith("/"))
549 CreatorData += "/";
550 }
547 if (parts.Length >= 3) 551 if (parts.Length >= 3)
548 name = parts[2]; 552 name = parts[2];
549 553
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/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 4ae0eb1..6e4ac98 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1151,9 +1151,9 @@ namespace OpenSim.Region.Framework.Scenes
1151 1151
1152 MovementFlag = 0; 1152 MovementFlag = 0;
1153 1153
1154 m_scene.EventManager.TriggerOnMakeRootAgent(this); 1154 // DIVA NOTE: I moved TriggerOnMakeRootAgent out of here and into the end of
1155 1155 // CompleteMovement. We don't want modules doing heavy computation before CompleteMovement
1156 m_scene.EventManager.OnRegionHeartbeatEnd += RegionHeartbeatEnd; 1156 // is over.
1157 } 1157 }
1158 1158
1159 public int GetStateSource() 1159 public int GetStateSource()
@@ -1519,10 +1519,15 @@ namespace OpenSim.Region.Framework.Scenes
1519 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1519 bool flying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
1520 MakeRootAgent(AbsolutePosition, flying); 1520 MakeRootAgent(AbsolutePosition, flying);
1521 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look); 1521 ControllingClient.MoveAgentIntoRegion(m_scene.RegionInfo, AbsolutePosition, look);
1522 // Remember in HandleUseCircuitCode, we delayed this to here
1523 // This will also send the initial data to clients when TP to a neighboring region.
1524 // Not ideal, but until we know we're TP-ing from a neighboring region, there's not much we can do
1525 if (m_teleportFlags > 0)
1526 SendInitialDataToMe();
1522 1527
1523// m_log.DebugFormat("[SCENE PRESENCE] Completed movement"); 1528// m_log.DebugFormat("[SCENE PRESENCE] Completed movement");
1524 1529
1525 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1530 if (!string.IsNullOrEmpty(m_callbackURI))
1526 { 1531 {
1527 // We cannot sleep here since this would hold up the inbound packet processing thread, as 1532 // We cannot sleep here since this would hold up the inbound packet processing thread, as
1528 // CompleteMovement() is executed synchronously. However, it might be better to delay the release 1533 // CompleteMovement() is executed synchronously. However, it might be better to delay the release
@@ -1550,9 +1555,6 @@ namespace OpenSim.Region.Framework.Scenes
1550 // Create child agents in neighbouring regions 1555 // Create child agents in neighbouring regions
1551 if (openChildAgents && !IsChildAgent) 1556 if (openChildAgents && !IsChildAgent)
1552 { 1557 {
1553 // Remember in HandleUseCircuitCode, we delayed this to here
1554 SendInitialDataToMe();
1555
1556 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); 1558 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
1557 if (m_agentTransfer != null) 1559 if (m_agentTransfer != null)
1558 m_agentTransfer.EnableChildAgents(this); 1560 m_agentTransfer.EnableChildAgents(this);
@@ -1575,6 +1577,11 @@ namespace OpenSim.Region.Framework.Scenes
1575// m_log.DebugFormat( 1577// m_log.DebugFormat(
1576// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms", 1578// "[SCENE PRESENCE]: Completing movement of {0} into region {1} took {2}ms",
1577// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds); 1579// client.Name, Scene.RegionInfo.RegionName, (DateTime.Now - startTime).Milliseconds);
1580
1581 // DIVA NOTE: moved this here from MakeRoot. We don't want modules making heavy
1582 // computations before CompleteMovement is over
1583 m_scene.EventManager.TriggerOnMakeRootAgent(this);
1584
1578 } 1585 }
1579 1586
1580 /// <summary> 1587 /// <summary>
@@ -2886,11 +2893,12 @@ namespace OpenSim.Region.Framework.Scenes
2886 SendOtherAgentsAppearanceToMe(); 2893 SendOtherAgentsAppearanceToMe();
2887 2894
2888 EntityBase[] entities = Scene.Entities.GetEntities(); 2895 EntityBase[] entities = Scene.Entities.GetEntities();
2889 foreach(EntityBase e in entities) 2896 foreach (EntityBase e in entities)
2890 { 2897 {
2891 if (e != null && e is SceneObjectGroup) 2898 if (e != null && e is SceneObjectGroup)
2892 ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient); 2899 ((SceneObjectGroup)e).SendFullUpdateToClient(ControllingClient);
2893 } 2900 }
2901
2894 }); 2902 });
2895 } 2903 }
2896 2904
@@ -3116,7 +3124,7 @@ namespace OpenSim.Region.Framework.Scenes
3116 cadu.Velocity = Velocity; 3124 cadu.Velocity = Velocity;
3117 3125
3118 AgentPosition agentpos = new AgentPosition(); 3126 AgentPosition agentpos = new AgentPosition();
3119 agentpos.CopyFrom(cadu); 3127 agentpos.CopyFrom(cadu, ControllingClient.SessionId);
3120 3128
3121 // Let's get this out of the update loop 3129 // Let's get this out of the update loop
3122 Util.FireAndForget(delegate { m_scene.SendOutChildAgentUpdates(agentpos, this); }); 3130 Util.FireAndForget(delegate { m_scene.SendOutChildAgentUpdates(agentpos, this); });
@@ -3355,7 +3363,11 @@ namespace OpenSim.Region.Framework.Scenes
3355 { 3363 {
3356 m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents"); 3364 m_log.Debug("[SCENE PRESENCE]: Closing " + byebyeRegions.Count + " child agents");
3357 3365
3358 m_scene.SceneGridService.SendCloseChildAgentConnections(ControllingClient.AgentId, byebyeRegions); 3366 AgentCircuitData acd = Scene.AuthenticateHandler.GetAgentCircuitData(UUID);
3367 string auth = string.Empty;
3368 if (acd != null)
3369 auth = acd.SessionID.ToString();
3370 m_scene.SceneGridService.SendCloseChildAgentConnections(ControllingClient.AgentId, auth, byebyeRegions);
3359 } 3371 }
3360 3372
3361 foreach (ulong handle in byebyeRegions) 3373 foreach (ulong handle in byebyeRegions)
@@ -3456,6 +3468,7 @@ namespace OpenSim.Region.Framework.Scenes
3456 3468
3457 cAgent.AgentID = UUID; 3469 cAgent.AgentID = UUID;
3458 cAgent.RegionID = Scene.RegionInfo.RegionID; 3470 cAgent.RegionID = Scene.RegionInfo.RegionID;
3471 cAgent.SessionID = ControllingClient.SessionId;
3459 3472
3460 cAgent.Position = AbsolutePosition; 3473 cAgent.Position = AbsolutePosition;
3461 cAgent.Velocity = m_velocity; 3474 cAgent.Velocity = m_velocity;
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/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
index 5a72239..5df9aba 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceCrossingTests.cs
@@ -112,6 +112,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
112 //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero); 112 //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
113 moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2))); 113 moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
114 moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS; 114 moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
115 moveArgs.SessionID = acd.SessionID;
115 116
116 originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs); 117 originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs);
117 118
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..44a7c14 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -353,6 +353,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
353 // Position of a sensor in a child prim attached to an avatar 353 // Position of a sensor in a child prim attached to an avatar
354 // will be still wrong. 354 // will be still wrong.
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
357 // Don't proceed if the avatar for this attachment has since been removed from the scene.
358 if (avatar == null)
359 return sensedEntities;
360
356 fromRegionPos = avatar.AbsolutePosition; 361 fromRegionPos = avatar.AbsolutePosition;
357 q = avatar.Rotation; 362 q = avatar.Rotation;
358 } 363 }
@@ -483,6 +488,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
483 // Position of a sensor in a child prim attached to an avatar 488 // Position of a sensor in a child prim attached to an avatar
484 // will be still wrong. 489 // will be still wrong.
485 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar); 490 ScenePresence avatar = m_CmdManager.m_ScriptEngine.World.GetScenePresence(SensePoint.ParentGroup.AttachedAvatar);
491
492 // Don't proceed if the avatar for this attachment has since been removed from the scene.
486 if (avatar == null) 493 if (avatar == null)
487 return sensedEntities; 494 return sensedEntities;
488 fromRegionPos = avatar.AbsolutePosition; 495 fromRegionPos = avatar.AbsolutePosition;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 2260ec8..2ea265d 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,7 @@ 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 llSetAngularVelocity(LSL_Vector angularVelocity, int local);
347 void llSetHoverHeight(double height, int water, double tau); 347 void llSetHoverHeight(double height, int water, double tau);
348 void llSetInventoryPermMask(string item, int mask, int value); 348 void llSetInventoryPermMask(string item, int mask, int value);
349 void llSetLinkAlpha(int linknumber, double alpha, int face); 349 void llSetLinkAlpha(int linknumber, double alpha, int face);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index b58686b..41e585c 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,11 @@ 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 llSetAngularVelocity(LSL_Vector force, int local)
1554 {
1555 m_LSL_Functions.llSetAngularVelocity(force, local);
1556 }
1557
1558 public void llSetHoverHeight(double height, int water, double tau) 1558 public void llSetHoverHeight(double height, int water, double tau)
1559 { 1559 {
1560 m_LSL_Functions.llSetHoverHeight(height, water, tau); 1560 m_LSL_Functions.llSetHoverHeight(height, water, tau);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
index 8da06d1..3646c98 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs
@@ -242,7 +242,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
242 if (Engine.Config.GetString("ScriptStopStrategy", "abort") == "co-op") 242 if (Engine.Config.GetString("ScriptStopStrategy", "abort") == "co-op")
243 { 243 {
244 m_coopTermination = true; 244 m_coopTermination = true;
245 m_coopSleepHandle = new AutoResetEvent(false); 245 m_coopSleepHandle = new XEngineEventWaitHandle(false, EventResetMode.AutoReset);
246 } 246 }
247 } 247 }
248 248
@@ -1221,4 +1221,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
1221 Suspended = false; 1221 Suspended = false;
1222 } 1222 }
1223 } 1223 }
1224} 1224
1225 /// <summary>
1226 /// Xengine event wait handle.
1227 /// </summary>
1228 /// <remarks>
1229 /// This class exists becase XEngineScriptBase gets a reference to this wait handle. We need to make sure that
1230 /// when scripts are running in different AppDomains the lease does not expire.
1231 /// FIXME: Like LSL_Api, etc., this effectively leaks memory since the GC will never collect it. To avoid this,
1232 /// proper remoting sponsorship needs to be implemented across the board.
1233 /// </remarks>
1234 public class XEngineEventWaitHandle : EventWaitHandle
1235 {
1236 public XEngineEventWaitHandle(bool initialState, EventResetMode mode) : base(initialState, mode) {}
1237
1238 public override Object InitializeLifetimeService()
1239 {
1240 return null;
1241 }
1242 }
1243} \ No newline at end of file