aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs108
-rw-r--r--OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/JsonRPCMethod.cs34
-rw-r--r--OpenSim/Framework/Servers/HttpServer/JsonRpcResponse.cs150
-rw-r--r--OpenSim/Framework/Servers/MainServer.cs4
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs4
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs17
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs4
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs58
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs7
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSParam.cs6
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs29
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs2
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs17
-rw-r--r--OpenSim/Server/Base/ServerUtils.cs7
16 files changed, 413 insertions, 51 deletions
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
index eefcdad..bfbc480 100644
--- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs
@@ -77,6 +77,7 @@ namespace OpenSim.Framework.Servers.HttpServer
77 // protected HttpListener m_httpListener; 77 // protected HttpListener m_httpListener;
78 protected CoolHTTPListener m_httpListener2; 78 protected CoolHTTPListener m_httpListener2;
79 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>(); 79 protected Dictionary<string, XmlRpcMethod> m_rpcHandlers = new Dictionary<string, XmlRpcMethod>();
80 protected Dictionary<string, JsonRPCMethod> jsonRpcHandlers = new Dictionary<string, JsonRPCMethod>();
80 protected Dictionary<string, bool> m_rpcHandlersKeepAlive = new Dictionary<string, bool>(); 81 protected Dictionary<string, bool> m_rpcHandlersKeepAlive = new Dictionary<string, bool>();
81 protected DefaultLLSDMethod m_defaultLlsdHandler = null; // <-- Moving away from the monolithic.. and going to /registered/ 82 protected DefaultLLSDMethod m_defaultLlsdHandler = null; // <-- Moving away from the monolithic.. and going to /registered/
82 protected Dictionary<string, LLSDMethod> m_llsdHandlers = new Dictionary<string, LLSDMethod>(); 83 protected Dictionary<string, LLSDMethod> m_llsdHandlers = new Dictionary<string, LLSDMethod>();
@@ -217,6 +218,37 @@ namespace OpenSim.Framework.Servers.HttpServer
217 return new List<string>(m_rpcHandlers.Keys); 218 return new List<string>(m_rpcHandlers.Keys);
218 } 219 }
219 220
221 // JsonRPC
222 public bool AddJsonRPCHandler(string method, JsonRPCMethod handler)
223 {
224 lock(jsonRpcHandlers)
225 {
226 jsonRpcHandlers.Add(method, handler);
227 }
228 return true;
229 }
230
231 public JsonRPCMethod GetJsonRPCHandler(string method)
232 {
233 lock (jsonRpcHandlers)
234 {
235 if (jsonRpcHandlers.ContainsKey(method))
236 {
237 return jsonRpcHandlers[method];
238 }
239 else
240 {
241 return null;
242 }
243 }
244 }
245
246 public List<string> GetJsonRpcHandlerKeys()
247 {
248 lock (jsonRpcHandlers)
249 return new List<string>(jsonRpcHandlers.Keys);
250 }
251
220 public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler) 252 public bool AddHTTPHandler(string methodName, GenericHTTPMethod handler)
221 { 253 {
222 //m_log.DebugFormat("[BASE HTTP SERVER]: Registering {0}", methodName); 254 //m_log.DebugFormat("[BASE HTTP SERVER]: Registering {0}", methodName);
@@ -557,10 +589,18 @@ namespace OpenSim.Framework.Servers.HttpServer
557 589
558 buffer = HandleLLSDRequests(request, response); 590 buffer = HandleLLSDRequests(request, response);
559 break; 591 break;
592
593 case "application/json-rpc":
594 if (DebugLevel >= 3)
595 LogIncomingToContentTypeHandler(request);
596
597 buffer = HandleJsonRpcRequests(request, response);
598 break;
560 599
561 case "text/xml": 600 case "text/xml":
562 case "application/xml": 601 case "application/xml":
563 case "application/json": 602 case "application/json":
603
564 default: 604 default:
565 //m_log.Info("[Debug BASE HTTP SERVER]: in default handler"); 605 //m_log.Info("[Debug BASE HTTP SERVER]: in default handler");
566 // Point of note.. the DoWeHaveA methods check for an EXACT path 606 // Point of note.. the DoWeHaveA methods check for an EXACT path
@@ -986,6 +1026,74 @@ namespace OpenSim.Framework.Servers.HttpServer
986 return buffer; 1026 return buffer;
987 } 1027 }
988 1028
1029 // JsonRpc (v2.0 only)
1030 private byte[] HandleJsonRpcRequests(OSHttpRequest request, OSHttpResponse response)
1031 {
1032 Stream requestStream = request.InputStream;
1033 JsonRpcResponse jsonRpcResponse = new JsonRpcResponse();
1034 OSDMap jsonRpcRequest = null;
1035
1036 try
1037 {
1038 jsonRpcRequest = (OSDMap)OSDParser.DeserializeJson(requestStream);
1039 }
1040 catch (LitJson.JsonException e)
1041 {
1042 jsonRpcResponse.Error.Code = ErrorCode.InternalError;
1043 jsonRpcResponse.Error.Message = e.Message;
1044 }
1045
1046 requestStream.Close();
1047
1048 if (jsonRpcRequest != null)
1049 {
1050 if (jsonRpcRequest.ContainsKey("jsonrpc") || jsonRpcRequest["jsonrpc"].AsString() == "2.0")
1051 {
1052 jsonRpcResponse.JsonRpc = "2.0";
1053
1054 // If we have no id, then it's a "notification"
1055 if (jsonRpcRequest.ContainsKey("id"))
1056 {
1057 jsonRpcResponse.Id = jsonRpcRequest["id"].AsString();
1058 }
1059
1060 string methodname = jsonRpcRequest["method"];
1061 JsonRPCMethod method;
1062
1063 if (jsonRpcHandlers.ContainsKey(methodname))
1064 {
1065 lock(jsonRpcHandlers)
1066 {
1067 jsonRpcHandlers.TryGetValue(methodname, out method);
1068 }
1069
1070 method(jsonRpcRequest, ref jsonRpcResponse);
1071 }
1072 else // Error no hanlder defined for requested method
1073 {
1074 jsonRpcResponse.Error.Code = ErrorCode.InvalidRequest;
1075 jsonRpcResponse.Error.Message = string.Format ("No handler defined for {0}", methodname);
1076 }
1077 }
1078 else // not json-rpc 2.0 could be v1
1079 {
1080 jsonRpcResponse.Error.Code = ErrorCode.InvalidRequest;
1081 jsonRpcResponse.Error.Message = "Must be valid json-rpc 2.0 see: http://www.jsonrpc.org/specification";
1082
1083 if (jsonRpcRequest.ContainsKey("id"))
1084 jsonRpcResponse.Id = jsonRpcRequest["id"].AsString();
1085 }
1086 }
1087
1088 response.KeepAlive = true;
1089 string responseData = string.Empty;
1090
1091 responseData = jsonRpcResponse.Serialize();
1092
1093 byte[] buffer = Encoding.UTF8.GetBytes(responseData);
1094 return buffer;
1095 }
1096
989 private byte[] HandleLLSDRequests(OSHttpRequest request, OSHttpResponse response) 1097 private byte[] HandleLLSDRequests(OSHttpRequest request, OSHttpResponse response)
990 { 1098 {
991 //m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request"); 1099 //m_log.Warn("[BASE HTTP SERVER]: We've figured out it's a LLSD Request");
diff --git a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs
index 0bd3aae..13b5dd3 100644
--- a/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs
+++ b/OpenSim/Framework/Servers/HttpServer/Interfaces/IHttpServer.cs
@@ -97,6 +97,8 @@ namespace OpenSim.Framework.Servers.HttpServer
97 bool AddXmlRPCHandler(string method, XmlRpcMethod handler); 97 bool AddXmlRPCHandler(string method, XmlRpcMethod handler);
98 bool AddXmlRPCHandler(string method, XmlRpcMethod handler, bool keepAlive); 98 bool AddXmlRPCHandler(string method, XmlRpcMethod handler, bool keepAlive);
99 99
100 bool AddJsonRPCHandler(string method, JsonRPCMethod handler);
101
100 /// <summary> 102 /// <summary>
101 /// Gets the XML RPC handler for given method name 103 /// Gets the XML RPC handler for given method name
102 /// </summary> 104 /// </summary>
diff --git a/OpenSim/Framework/Servers/HttpServer/JsonRPCMethod.cs b/OpenSim/Framework/Servers/HttpServer/JsonRPCMethod.cs
new file mode 100644
index 0000000..7334049
--- /dev/null
+++ b/OpenSim/Framework/Servers/HttpServer/JsonRPCMethod.cs
@@ -0,0 +1,34 @@
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.Net;
29using OpenMetaverse.StructuredData;
30
31namespace OpenSim.Framework.Servers.HttpServer
32{
33 public delegate void JsonRPCMethod(OSDMap jsonRpcRequest, ref JsonRpcResponse response);
34}
diff --git a/OpenSim/Framework/Servers/HttpServer/JsonRpcResponse.cs b/OpenSim/Framework/Servers/HttpServer/JsonRpcResponse.cs
new file mode 100644
index 0000000..2c50587
--- /dev/null
+++ b/OpenSim/Framework/Servers/HttpServer/JsonRpcResponse.cs
@@ -0,0 +1,150 @@
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 */
27using System;
28using System.Net;
29using OpenMetaverse.StructuredData;
30
31namespace OpenSim.Framework.Servers.HttpServer
32{
33 public sealed class ErrorCode
34 {
35 private ErrorCode() {}
36
37 public const int ParseError = -32700;
38 public const int InvalidRequest = -32600;
39 public const int MethodNotFound = -32601;
40 public const int InvalidParams = -32602;
41 public const int InternalError = -32604;
42
43 }
44
45 public class JsonRpcError
46 {
47 internal OSDMap Error = new OSDMap();
48
49 public int Code
50 {
51 get
52 {
53 if (Error.ContainsKey("code"))
54 return Error["code"].AsInteger();
55 else
56 return 0;
57 }
58 set
59 {
60 Error["code"] = OSD.FromInteger(value);
61 }
62 }
63
64 public string Message
65 {
66 get
67 {
68 if (Error.ContainsKey("message"))
69 return Error["message"].AsString();
70 else
71 return null;
72 }
73 set
74 {
75 Error["message"] = OSD.FromString(value);
76 }
77 }
78
79 public OSD Data
80 {
81 get; set;
82 }
83 }
84
85 public class JsonRpcResponse
86 {
87 public string JsonRpc
88 {
89 get
90 {
91 return Reply["jsonrpc"].AsString();
92 }
93 set
94 {
95 Reply["jsonrpc"] = OSD.FromString(value);
96 }
97 }
98
99 public string Id
100 {
101 get
102 {
103 return Reply["id"].AsString();
104 }
105 set
106 {
107 Reply["id"] = OSD.FromString(value);
108 }
109 }
110
111 public OSD Result
112 {
113 get; set;
114 }
115
116 public JsonRpcError Error
117 {
118 get; set;
119 }
120
121 public OSDMap Reply = new OSDMap();
122
123 public JsonRpcResponse()
124 {
125 Error = new JsonRpcError();
126 }
127
128 public string Serialize()
129 {
130 if (Result != null)
131 Reply["result"] = Result;
132
133 if (Error.Code != 0)
134 {
135 Reply["error"] = (OSD)Error.Error;
136 }
137
138 string result = string.Empty;
139 try
140 {
141 result = OSDParser.SerializeJsonString(Reply);
142 }
143 catch
144 {
145
146 }
147 return result;
148 }
149 }
150}
diff --git a/OpenSim/Framework/Servers/MainServer.cs b/OpenSim/Framework/Servers/MainServer.cs
index ae7d515..293887f 100644
--- a/OpenSim/Framework/Servers/MainServer.cs
+++ b/OpenSim/Framework/Servers/MainServer.cs
@@ -230,6 +230,10 @@ namespace OpenSim.Framework.Servers
230 List<String> poll = httpServer.GetPollServiceHandlerKeys(); 230 List<String> poll = httpServer.GetPollServiceHandlerKeys();
231 foreach (String s in httpServer.GetHTTPHandlerKeys()) 231 foreach (String s in httpServer.GetHTTPHandlerKeys())
232 handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty)); 232 handlers.AppendFormat("\t{0} {1}\n", s, (poll.Contains(s) ? "(poll service)" : string.Empty));
233
234 handlers.AppendFormat("* JSONRPC:\n");
235 foreach (String s in httpServer.GetJsonRpcHandlerKeys())
236 handlers.AppendFormat("\t{0}\n", s);
233 237
234// handlers.AppendFormat("* Agent:\n"); 238// handlers.AppendFormat("* Agent:\n");
235// foreach (String s in httpServer.GetAgentHandlerKeys()) 239// foreach (String s in httpServer.GetAgentHandlerKeys())
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index ddbd677..6428b86 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -6600,19 +6600,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6600 #endregion 6600 #endregion
6601 6601
6602 AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit; 6602 AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit;
6603 if (handlerAgentRequestSit != null)
6604 if (!(agentRequestSit.AgentData == null
6605 || agentRequestSit.TargetObject == null
6606 || agentRequestSit.TargetObject.TargetID == null
6607 || agentRequestSit.TargetObject.Offset == null))
6608 {
6609 var sp = m_scene.GetScenePresence(agentRequestSit.AgentData.AgentID);
6610 if (sp == null || sp.ParentID != 0) // ignore packet if agent is already sitting
6611 return true;
6612 6603
6613 handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID, 6604 if (handlerAgentRequestSit != null)
6614 agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); 6605 handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID,
6615 } 6606 agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
6616 } 6607 }
6617 return true; 6608 return true;
6618 } 6609 }
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 1d6898b..c2ff110 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2197,6 +2197,10 @@ namespace OpenSim.Region.Framework.Scenes
2197 2197
2198 if (ParentID != 0) 2198 if (ParentID != 0)
2199 { 2199 {
2200 var targetPart = m_scene.GetSceneObjectPart(targetID);
2201 if (targetPart != null && targetPart.LocalId == ParentID)
2202 return; // already sitting here, ignore
2203
2200 StandUp(); 2204 StandUp();
2201 } 2205 }
2202 2206
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
index 0fef67c..ae54499 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSAPIUnman.cs
@@ -166,7 +166,7 @@ public override BulletWorld Initialize(Vector3 maxPosition, ConfigurationParamet
166 166
167 // If Debug logging level, enable logging from the unmanaged code 167 // If Debug logging level, enable logging from the unmanaged code
168 m_DebugLogCallbackHandle = null; 168 m_DebugLogCallbackHandle = null;
169 if (BSScene.m_log.IsDebugEnabled || PhysicsScene.PhysicsLogging.Enabled) 169 if (BSScene.m_log.IsDebugEnabled && PhysicsScene.PhysicsLogging.Enabled)
170 { 170 {
171 BSScene.m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", BSScene.LogHeader); 171 BSScene.m_log.DebugFormat("{0}: Initialize: Setting debug callback for unmanaged code", BSScene.LogHeader);
172 if (PhysicsScene.PhysicsLogging.Enabled) 172 if (PhysicsScene.PhysicsLogging.Enabled)
@@ -202,7 +202,7 @@ private void BulletLoggerPhysLog(string msg)
202} 202}
203 203
204public override int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep, 204public override int PhysicsStep(BulletWorld world, float timeStep, int maxSubSteps, float fixedTimeStep,
205 out int updatedEntityCount, out int collidersCount) 205 out int updatedEntityCount, out int collidersCount)
206{ 206{
207 BulletWorldUnman worldu = world as BulletWorldUnman; 207 BulletWorldUnman worldu = world as BulletWorldUnman;
208 return BSAPICPP.PhysicsStep2(worldu.ptr, timeStep, maxSubSteps, fixedTimeStep, out updatedEntityCount, out collidersCount); 208 return BSAPICPP.PhysicsStep2(worldu.ptr, timeStep, maxSubSteps, fixedTimeStep, out updatedEntityCount, out collidersCount);
@@ -212,6 +212,19 @@ public override void Shutdown(BulletWorld world)
212{ 212{
213 BulletWorldUnman worldu = world as BulletWorldUnman; 213 BulletWorldUnman worldu = world as BulletWorldUnman;
214 BSAPICPP.Shutdown2(worldu.ptr); 214 BSAPICPP.Shutdown2(worldu.ptr);
215
216 if (m_paramsHandle.IsAllocated)
217 {
218 m_paramsHandle.Free();
219 }
220 if (m_collisionArrayPinnedHandle.IsAllocated)
221 {
222 m_collisionArrayPinnedHandle.Free();
223 }
224 if (m_updateArrayPinnedHandle.IsAllocated)
225 {
226 m_updateArrayPinnedHandle.Free();
227 }
215} 228}
216 229
217public override bool PushUpdate(BulletBody obj) 230public override bool PushUpdate(BulletBody obj)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index aadb583..a5fec87 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -126,9 +126,9 @@ public sealed class BSCharacter : BSPhysObject
126 DetailLog("{0},BSCharacter.Destroy", LocalID); 126 DetailLog("{0},BSCharacter.Destroy", LocalID);
127 PhysicsScene.TaintedObject("BSCharacter.destroy", delegate() 127 PhysicsScene.TaintedObject("BSCharacter.destroy", delegate()
128 { 128 {
129 PhysicsScene.Shapes.DereferenceBody(PhysBody, true, null); 129 PhysicsScene.Shapes.DereferenceBody(PhysBody, true /* inTaintTime */, null /* bodyCallback */);
130 PhysBody.Clear(); 130 PhysBody.Clear();
131 PhysicsScene.Shapes.DereferenceShape(PhysShape, true, null); 131 PhysicsScene.Shapes.DereferenceShape(PhysShape, true /* inTaintTime */, null /* bodyCallback */);
132 PhysShape.Clear(); 132 PhysShape.Clear();
133 }); 133 });
134 } 134 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index bcebaec..e434412 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -124,9 +124,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
124 static readonly float PIOverTwo = ((float)Math.PI) / 2f; 124 static readonly float PIOverTwo = ((float)Math.PI) / 2f;
125 125
126 // For debugging, flags to turn on and off individual corrections. 126 // For debugging, flags to turn on and off individual corrections.
127 private bool enableAngularVerticalAttraction = true; 127 private bool enableAngularVerticalAttraction;
128 private bool enableAngularDeflection = true; 128 private bool enableAngularDeflection;
129 private bool enableAngularBanking = true; 129 private bool enableAngularBanking;
130 130
131 public BSDynamics(BSScene myScene, BSPrim myPrim) 131 public BSDynamics(BSScene myScene, BSPrim myPrim)
132 { 132 {
@@ -141,8 +141,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
141 public void SetupVehicleDebugging() 141 public void SetupVehicleDebugging()
142 { 142 {
143 enableAngularVerticalAttraction = true; 143 enableAngularVerticalAttraction = true;
144 enableAngularDeflection = true; 144 enableAngularDeflection = false;
145 enableAngularBanking = true; 145 enableAngularBanking = false;
146 if (BSParam.VehicleDebuggingEnabled != ConfigurationParameters.numericFalse) 146 if (BSParam.VehicleDebuggingEnabled != ConfigurationParameters.numericFalse)
147 { 147 {
148 enableAngularVerticalAttraction = false; 148 enableAngularVerticalAttraction = false;
@@ -649,6 +649,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
649 private Quaternion m_knownOrientation; 649 private Quaternion m_knownOrientation;
650 private Vector3 m_knownRotationalVelocity; 650 private Vector3 m_knownRotationalVelocity;
651 private Vector3 m_knownRotationalForce; 651 private Vector3 m_knownRotationalForce;
652 private Vector3 m_knownRotationalImpulse;
652 private Vector3 m_knownForwardVelocity; // vehicle relative forward speed 653 private Vector3 m_knownForwardVelocity; // vehicle relative forward speed
653 654
654 private const int m_knownChangedPosition = 1 << 0; 655 private const int m_knownChangedPosition = 1 << 0;
@@ -658,9 +659,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
658 private const int m_knownChangedOrientation = 1 << 4; 659 private const int m_knownChangedOrientation = 1 << 4;
659 private const int m_knownChangedRotationalVelocity = 1 << 5; 660 private const int m_knownChangedRotationalVelocity = 1 << 5;
660 private const int m_knownChangedRotationalForce = 1 << 6; 661 private const int m_knownChangedRotationalForce = 1 << 6;
661 private const int m_knownChangedTerrainHeight = 1 << 7; 662 private const int m_knownChangedRotationalImpulse = 1 << 7;
662 private const int m_knownChangedWaterLevel = 1 << 8; 663 private const int m_knownChangedTerrainHeight = 1 << 8;
663 private const int m_knownChangedForwardVelocity = 1 << 9; 664 private const int m_knownChangedWaterLevel = 1 << 9;
665 private const int m_knownChangedForwardVelocity = 1 <<10;
664 666
665 private void ForgetKnownVehicleProperties() 667 private void ForgetKnownVehicleProperties()
666 { 668 {
@@ -700,6 +702,9 @@ namespace OpenSim.Region.Physics.BulletSPlugin
700 PhysicsScene.PE.SetInterpolationAngularVelocity(Prim.PhysBody, m_knownRotationalVelocity); 702 PhysicsScene.PE.SetInterpolationAngularVelocity(Prim.PhysBody, m_knownRotationalVelocity);
701 } 703 }
702 704
705 if ((m_knownChanged & m_knownChangedRotationalImpulse) != 0)
706 Prim.ApplyTorqueImpulse((Vector3)m_knownRotationalImpulse, true /*inTaintTime*/);
707
703 if ((m_knownChanged & m_knownChangedRotationalForce) != 0) 708 if ((m_knownChanged & m_knownChangedRotationalForce) != 0)
704 { 709 {
705 Prim.AddAngularForce((Vector3)m_knownRotationalForce, false /*pushForce*/, true /*inTaintTime*/); 710 Prim.AddAngularForce((Vector3)m_knownRotationalForce, false /*pushForce*/, true /*inTaintTime*/);
@@ -843,6 +848,17 @@ namespace OpenSim.Region.Physics.BulletSPlugin
843 m_knownChanged |= m_knownChangedRotationalForce; 848 m_knownChanged |= m_knownChangedRotationalForce;
844 m_knownHas |= m_knownChangedRotationalForce; 849 m_knownHas |= m_knownChangedRotationalForce;
845 } 850 }
851 private void VehicleAddRotationalImpulse(Vector3 pImpulse)
852 {
853 if ((m_knownHas & m_knownChangedRotationalImpulse) == 0)
854 {
855 m_knownRotationalImpulse = Vector3.Zero;
856 m_knownHas |= m_knownChangedRotationalImpulse;
857 }
858 m_knownRotationalImpulse += pImpulse;
859 m_knownChanged |= m_knownChangedRotationalImpulse;
860 }
861
846 // Vehicle relative forward velocity 862 // Vehicle relative forward velocity
847 private Vector3 VehicleForwardVelocity 863 private Vector3 VehicleForwardVelocity
848 { 864 {
@@ -1031,16 +1047,32 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1031 else 1047 else
1032 { 1048 {
1033 // Error is positive if below the target and negative if above. 1049 // Error is positive if below the target and negative if above.
1034 float verticalError = m_VhoverTargetHeight - VehiclePosition.Z; 1050 Vector3 hpos = VehiclePosition;
1035 float verticalCorrectionVelocity = verticalError / m_VhoverTimescale * pTimestep; 1051 float verticalError = m_VhoverTargetHeight - hpos.Z;
1052 float verticalCorrection = verticalError / m_VhoverTimescale;
1053 verticalCorrection *= m_VhoverEfficiency;
1054
1055 hpos.Z += verticalCorrection;
1056 VehiclePosition = hpos;
1057
1058 // Since we are hovering, we need to do the opposite of falling -- get rid of world Z
1059 Vector3 vel = VehicleVelocity;
1060 vel.Z = 0f;
1061 VehicleVelocity = vel;
1062
1063 /*
1064 float verticalCorrectionVelocity = verticalError / m_VhoverTimescale;
1065 Vector3 verticalCorrection = new Vector3(0f, 0f, verticalCorrectionVelocity);
1066 verticalCorrection *= m_vehicleMass;
1036 1067
1037 // TODO: implement m_VhoverEfficiency correctly 1068 // TODO: implement m_VhoverEfficiency correctly
1038 VehicleAddForceImpulse(new Vector3(0f, 0f, verticalCorrectionVelocity)); 1069 VehicleAddForceImpulse(verticalCorrection);
1070 */
1039 1071
1040 VDetailLog("{0}, MoveLinear,hover,pos={1},eff={2},hoverTS={3},height={4},target={5},err={6},corrVel={7}", 1072 VDetailLog("{0}, MoveLinear,hover,pos={1},eff={2},hoverTS={3},height={4},target={5},err={6},corr={7}",
1041 Prim.LocalID, VehiclePosition, m_VhoverEfficiency, 1073 Prim.LocalID, VehiclePosition, m_VhoverEfficiency,
1042 m_VhoverTimescale, m_VhoverHeight, m_VhoverTargetHeight, 1074 m_VhoverTimescale, m_VhoverHeight, m_VhoverTargetHeight,
1043 verticalError, verticalCorrectionVelocity); 1075 verticalError, verticalCorrection);
1044 } 1076 }
1045 1077
1046 } 1078 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
index 5a1b5c7..2dc89b5 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs
@@ -195,8 +195,11 @@ public sealed class BSLinksetCompound : BSLinkset
195 && PhysicsScene.TerrainManager.IsWithinKnownTerrain(LinksetRoot.RawPosition)) 195 && PhysicsScene.TerrainManager.IsWithinKnownTerrain(LinksetRoot.RawPosition))
196 { 196 {
197 // TODO: replace this with are calculation of the child prim's orientation and pos. 197 // TODO: replace this with are calculation of the child prim's orientation and pos.
198 updated.LinksetInfo = null; 198 // TODO: for the moment, don't rebuild the compound shape.
199 ScheduleRebuild(updated); 199 // This is often just the car turning its wheels. When we can just reorient the one
200 // member shape of the compound shape, the overhead of rebuilding won't be a problem.
201 // updated.LinksetInfo = null;
202 // ScheduleRebuild(updated);
200 } 203 }
201 } 204 }
202 205
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
index 27ff047..862dbf6 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
@@ -318,13 +318,13 @@ public static class BSParam
318 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularSleepingThreshold=x;}, p, l, v); }, 318 (s,p,l,v) => { s.UpdateParameterObject((x)=>{AngularSleepingThreshold=x;}, p, l, v); },
319 (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ), 319 (s,o,v) => { s.PE.SetSleepingThresholds(o.PhysBody, v, v); } ),
320 new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" , 320 new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" ,
321 0f, // set to zero to disable 321 0.3f, // set to zero to disable
322 (s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); }, 322 (s,cf,p,v) => { CcdMotionThreshold = cf.GetFloat(p, v); },
323 (s) => { return CcdMotionThreshold; }, 323 (s) => { return CcdMotionThreshold; },
324 (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdMotionThreshold=x;}, p, l, v); }, 324 (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdMotionThreshold=x;}, p, l, v); },
325 (s,o,v) => { s.PE.SetCcdMotionThreshold(o.PhysBody, v); } ), 325 (s,o,v) => { s.PE.SetCcdMotionThreshold(o.PhysBody, v); } ),
326 new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" , 326 new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" ,
327 0f, 327 0.2f,
328 (s,cf,p,v) => { CcdSweptSphereRadius = cf.GetFloat(p, v); }, 328 (s,cf,p,v) => { CcdSweptSphereRadius = cf.GetFloat(p, v); },
329 (s) => { return CcdSweptSphereRadius; }, 329 (s) => { return CcdSweptSphereRadius; },
330 (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdSweptSphereRadius=x;}, p, l, v); }, 330 (s,p,l,v) => { s.UpdateParameterObject((x)=>{CcdSweptSphereRadius=x;}, p, l, v); },
@@ -465,7 +465,7 @@ public static class BSParam
465 (s) => { return s.UnmanagedParams[0].shouldSplitSimulationIslands; }, 465 (s) => { return s.UnmanagedParams[0].shouldSplitSimulationIslands; },
466 (s,p,l,v) => { s.UnmanagedParams[0].shouldSplitSimulationIslands = v; } ), 466 (s,p,l,v) => { s.UnmanagedParams[0].shouldSplitSimulationIslands = v; } ),
467 new ParameterDefn("ShouldEnableFrictionCaching", "Enable friction computation caching", 467 new ParameterDefn("ShouldEnableFrictionCaching", "Enable friction computation caching",
468 ConfigurationParameters.numericFalse, 468 ConfigurationParameters.numericTrue,
469 (s,cf,p,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); }, 469 (s,cf,p,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = BSParam.NumericBool(cf.GetBoolean(p, BSParam.BoolNumeric(v))); },
470 (s) => { return s.UnmanagedParams[0].shouldEnableFrictionCaching; }, 470 (s) => { return s.UnmanagedParams[0].shouldEnableFrictionCaching; },
471 (s,p,l,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = v; } ), 471 (s,p,l,v) => { s.UnmanagedParams[0].shouldEnableFrictionCaching = v; } ),
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
index 185f111..821f470 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs
@@ -382,10 +382,13 @@ public abstract class BSPhysObject : PhysicsActor
382 { 382 {
383 string identifier = op + "-" + id.ToString(); 383 string identifier = op + "-" + id.ToString();
384 384
385 // Clean out any existing action 385 lock (RegisteredActions)
386 UnRegisterPreStepAction(op, id); 386 {
387 // Clean out any existing action
388 UnRegisterPreStepAction(op, id);
387 389
388 RegisteredActions[identifier] = actn; 390 RegisteredActions[identifier] = actn;
391 }
389 PhysicsScene.BeforeStep += actn; 392 PhysicsScene.BeforeStep += actn;
390 DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier); 393 DetailLog("{0},BSPhysObject.RegisterPreStepAction,id={1}", LocalID, identifier);
391 } 394 }
@@ -395,22 +398,28 @@ public abstract class BSPhysObject : PhysicsActor
395 { 398 {
396 string identifier = op + "-" + id.ToString(); 399 string identifier = op + "-" + id.ToString();
397 bool removed = false; 400 bool removed = false;
398 if (RegisteredActions.ContainsKey(identifier)) 401 lock (RegisteredActions)
399 { 402 {
400 PhysicsScene.BeforeStep -= RegisteredActions[identifier]; 403 if (RegisteredActions.ContainsKey(identifier))
401 RegisteredActions.Remove(identifier); 404 {
402 removed = true; 405 PhysicsScene.BeforeStep -= RegisteredActions[identifier];
406 RegisteredActions.Remove(identifier);
407 removed = true;
408 }
403 } 409 }
404 DetailLog("{0},BSPhysObject.UnRegisterPreStepAction,id={1},removed={2}", LocalID, identifier, removed); 410 DetailLog("{0},BSPhysObject.UnRegisterPreStepAction,id={1},removed={2}", LocalID, identifier, removed);
405 } 411 }
406 412
407 protected void UnRegisterAllPreStepActions() 413 protected void UnRegisterAllPreStepActions()
408 { 414 {
409 foreach (KeyValuePair<string, BSScene.PreStepAction> kvp in RegisteredActions) 415 lock (RegisteredActions)
410 { 416 {
411 PhysicsScene.BeforeStep -= kvp.Value; 417 foreach (KeyValuePair<string, BSScene.PreStepAction> kvp in RegisteredActions)
418 {
419 PhysicsScene.BeforeStep -= kvp.Value;
420 }
421 RegisteredActions.Clear();
412 } 422 }
413 RegisteredActions.Clear();
414 DetailLog("{0},BSPhysObject.UnRegisterAllPreStepActions,", LocalID); 423 DetailLog("{0},BSPhysObject.UnRegisterAllPreStepActions,", LocalID);
415 } 424 }
416 425
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index e5f7ab7..79fe632 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -379,7 +379,7 @@ public sealed class BSPrim : BSPhysObject
379 // If the object is below ground it just has to be moved up because pushing will 379 // If the object is below ground it just has to be moved up because pushing will
380 // not get it through the terrain 380 // not get it through the terrain
381 _position.Z = targetHeight; 381 _position.Z = targetHeight;
382 if (!inTaintTime) 382 if (inTaintTime)
383 ForcePosition = _position; 383 ForcePosition = _position;
384 ret = true; 384 ret = true;
385 } 385 }
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index a5bdc07..e0b4992 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -387,12 +387,14 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
387 if (!m_initialized) return null; 387 if (!m_initialized) return null;
388 388
389 BSCharacter actor = new BSCharacter(localID, avName, this, position, size, isFlying); 389 BSCharacter actor = new BSCharacter(localID, avName, this, position, size, isFlying);
390 lock (PhysObjects) PhysObjects.Add(localID, actor); 390 lock (PhysObjects)
391 PhysObjects.Add(localID, actor);
391 392
392 // TODO: Remove kludge someday. 393 // TODO: Remove kludge someday.
393 // We must generate a collision for avatars whether they collide or not. 394 // We must generate a collision for avatars whether they collide or not.
394 // This is required by OpenSim to update avatar animations, etc. 395 // This is required by OpenSim to update avatar animations, etc.
395 lock (m_avatars) m_avatars.Add(actor); 396 lock (m_avatars)
397 m_avatars.Add(actor);
396 398
397 return actor; 399 return actor;
398 } 400 }
@@ -408,9 +410,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
408 { 410 {
409 try 411 try
410 { 412 {
411 lock (PhysObjects) PhysObjects.Remove(actor.LocalID); 413 lock (PhysObjects)
414 PhysObjects.Remove(bsactor.LocalID);
412 // Remove kludge someday 415 // Remove kludge someday
413 lock (m_avatars) m_avatars.Remove(bsactor); 416 lock (m_avatars)
417 m_avatars.Remove(bsactor);
414 } 418 }
415 catch (Exception e) 419 catch (Exception e)
416 { 420 {
@@ -419,6 +423,11 @@ public sealed class BSScene : PhysicsScene, IPhysicsParameters
419 bsactor.Destroy(); 423 bsactor.Destroy();
420 // bsactor.dispose(); 424 // bsactor.dispose();
421 } 425 }
426 else
427 {
428 m_log.ErrorFormat("{0}: Requested to remove avatar that is not a BSCharacter. ID={1}, type={2}",
429 LogHeader, actor.LocalID, actor.GetType().Name);
430 }
422 } 431 }
423 432
424 public override void RemovePrim(PhysicsActor prim) 433 public override void RemovePrim(PhysicsActor prim)
diff --git a/OpenSim/Server/Base/ServerUtils.cs b/OpenSim/Server/Base/ServerUtils.cs
index 3f208bf..2e6d279 100644
--- a/OpenSim/Server/Base/ServerUtils.cs
+++ b/OpenSim/Server/Base/ServerUtils.cs
@@ -280,8 +280,11 @@ namespace OpenSim.Server.Base
280 { 280 {
281 if (!(e is System.MissingMethodException)) 281 if (!(e is System.MissingMethodException))
282 { 282 {
283 m_log.ErrorFormat("Error loading plugin {0} from {1}. Exception: {2}", 283 m_log.ErrorFormat("Error loading plugin {0} from {1}. Exception: {2}, {3}",
284 interfaceName, dllName, e.InnerException == null ? e.Message : e.InnerException.Message); 284 interfaceName,
285 dllName,
286 e.InnerException == null ? e.Message : e.InnerException.Message,
287 e.StackTrace);
285 } 288 }
286 return null; 289 return null;
287 } 290 }