aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorMelanie2012-07-06 20:51:18 +0100
committerMelanie2012-07-06 20:51:18 +0100
commit26d89777d88c9abfa35fed0b78bcd8f93c3d0bf2 (patch)
treebf9802d765a4965dd1b42c4b2d3145b5813c0c1f /OpenSim
parentMerge branch 'master' into careminster (diff)
parent added llSetVelocity. will refuse to work on vehicles and on attachments ( th... (diff)
downloadopensim-SC-26d89777d88c9abfa35fed0b78bcd8f93c3d0bf2.zip
opensim-SC-26d89777d88c9abfa35fed0b78bcd8f93c3d0bf2.tar.gz
opensim-SC-26d89777d88c9abfa35fed0b78bcd8f93c3d0bf2.tar.bz2
opensim-SC-26d89777d88c9abfa35fed0b78bcd8f93c3d0bf2.tar.xz
Merge branch 'avination' into careminster
Conflicts: OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
Diffstat (limited to '')
-rw-r--r--OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs4
-rw-r--r--OpenSim/Framework/Console/RemoteConsole.cs2
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs14
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs236
-rw-r--r--OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs3
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs6
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs5
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs5
-rw-r--r--OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Land/LandObject.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs18
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs84
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs23
-rw-r--r--OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs49
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs225
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs10
19 files changed, 587 insertions, 117 deletions
diff --git a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
index ae6c44b..f040ff7 100644
--- a/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/GetTexture/GetTextureHandler.cs
@@ -224,7 +224,9 @@ namespace OpenSim.Capabilities.Handlers
224 // sending back the last byte instead of an error status 224 // sending back the last byte instead of an error status
225 if (start >= texture.Data.Length) 225 if (start >= texture.Data.Length)
226 { 226 {
227 response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable; 227// response.StatusCode = (int)System.Net.HttpStatusCode.RequestedRangeNotSatisfiable;
228 // viewers don't seem to handle RequestedRangeNotSatisfiable and keep retrying with same parameters
229 response.StatusCode = (int)System.Net.HttpStatusCode.NotFound;
228 } 230 }
229 else 231 else
230 { 232 {
diff --git a/OpenSim/Framework/Console/RemoteConsole.cs b/OpenSim/Framework/Console/RemoteConsole.cs
index eabb62d..e04ca1e 100644
--- a/OpenSim/Framework/Console/RemoteConsole.cs
+++ b/OpenSim/Framework/Console/RemoteConsole.cs
@@ -233,7 +233,7 @@ namespace OpenSim.Framework.Console
233 string uri = "/ReadResponses/" + sessionID.ToString() + "/"; 233 string uri = "/ReadResponses/" + sessionID.ToString() + "/";
234 234
235 m_Server.AddPollServiceHTTPHandler( 235 m_Server.AddPollServiceHTTPHandler(
236 uri, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, sessionID)); 236 uri, new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, sessionID,25000)); // 25 secs timeout
237 237
238 XmlDocument xmldoc = new XmlDocument(); 238 XmlDocument xmldoc = new XmlDocument();
239 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration, 239 XmlNode xmlnode = xmldoc.CreateNode(XmlNodeType.XmlDeclaration,
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
index 3089351..bb43cd2 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceEventArgs.cs
@@ -45,17 +45,27 @@ namespace OpenSim.Framework.Servers.HttpServer
45 public NoEventsMethod NoEvents; 45 public NoEventsMethod NoEvents;
46 public RequestMethod Request; 46 public RequestMethod Request;
47 public UUID Id; 47 public UUID Id;
48 public int TimeOutms;
49 public EventType Type;
50
51 public enum EventType : int
52 {
53 Normal = 0,
54 LslHttp = 1
55 }
48 56
49 public PollServiceEventArgs( 57 public PollServiceEventArgs(
50 RequestMethod pRequest, 58 RequestMethod pRequest,
51 HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents, 59 HasEventsMethod pHasEvents, GetEventsMethod pGetEvents, NoEventsMethod pNoEvents,
52 UUID pId) 60 UUID pId, int pTimeOutms)
53 { 61 {
54 Request = pRequest; 62 Request = pRequest;
55 HasEvents = pHasEvents; 63 HasEvents = pHasEvents;
56 GetEvents = pGetEvents; 64 GetEvents = pGetEvents;
57 NoEvents = pNoEvents; 65 NoEvents = pNoEvents;
58 Id = pId; 66 Id = pId;
67 TimeOutms = pTimeOutms;
68 Type = EventType.Normal;
59 } 69 }
60 } 70 }
61} \ No newline at end of file 71}
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
index 5bc85ff..3a14b6f 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs
@@ -33,8 +33,11 @@ using log4net;
33using HttpServer; 33using HttpServer;
34using OpenSim.Framework; 34using OpenSim.Framework;
35 35
36
37/*
36namespace OpenSim.Framework.Servers.HttpServer 38namespace OpenSim.Framework.Servers.HttpServer
37{ 39{
40
38 public class PollServiceRequestManager 41 public class PollServiceRequestManager
39 { 42 {
40// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 43// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -158,3 +161,236 @@ namespace OpenSim.Framework.Servers.HttpServer
158 } 161 }
159 } 162 }
160} 163}
164 */
165
166using System.IO;
167using System.Text;
168using System.Collections.Generic;
169
170namespace OpenSim.Framework.Servers.HttpServer
171{
172 public class PollServiceRequestManager
173 {
174 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
175
176 private readonly BaseHttpServer m_server;
177
178 private BlockingQueue<PollServiceHttpRequest> m_requests = new BlockingQueue<PollServiceHttpRequest>();
179 private static Queue<PollServiceHttpRequest> m_slowRequests = new Queue<PollServiceHttpRequest>();
180 private static Queue<PollServiceHttpRequest> m_retryRequests = new Queue<PollServiceHttpRequest>();
181
182 private uint m_WorkerThreadCount = 0;
183 private Thread[] m_workerThreads;
184 private Thread m_retrysThread;
185
186 private bool m_running = true;
187 private int slowCount = 0;
188
189 // private int m_timeout = 250; // increase timeout 250; now use the event one
190
191 public PollServiceRequestManager(BaseHttpServer pSrv, uint pWorkerThreadCount, int pTimeout)
192 {
193 m_server = pSrv;
194 m_WorkerThreadCount = pWorkerThreadCount;
195 m_workerThreads = new Thread[m_WorkerThreadCount];
196
197 //startup worker threads
198 for (uint i = 0; i < m_WorkerThreadCount; i++)
199 {
200 m_workerThreads[i]
201 = Watchdog.StartThread(
202 PoolWorkerJob,
203 String.Format("PollServiceWorkerThread{0}", i),
204 ThreadPriority.Normal,
205 false,
206 true,
207 null,
208 int.MaxValue);
209 }
210
211 m_retrysThread = Watchdog.StartThread(
212 this.CheckRetries,
213 "PollServiceWatcherThread",
214 ThreadPriority.Normal,
215 false,
216 true,
217 null,
218 1000 * 60 * 10);
219 }
220
221
222 private void ReQueueEvent(PollServiceHttpRequest req)
223 {
224 if (m_running)
225 {
226 lock (m_retryRequests)
227 m_retryRequests.Enqueue(req);
228 }
229 }
230
231 public void Enqueue(PollServiceHttpRequest req)
232 {
233 if (m_running)
234 {
235 if (req.PollServiceArgs.Type == PollServiceEventArgs.EventType.LslHttp)
236 {
237 m_requests.Enqueue(req);
238 }
239 else
240 {
241 lock (m_slowRequests)
242 m_slowRequests.Enqueue(req);
243 }
244 }
245 }
246
247 private void CheckRetries()
248 {
249 while (m_running)
250 {
251 Thread.Sleep(100); // let the world move .. back to faster rate
252 Watchdog.UpdateThread();
253 lock (m_retryRequests)
254 {
255 while (m_retryRequests.Count > 0 && m_running)
256 m_requests.Enqueue(m_retryRequests.Dequeue());
257 }
258 slowCount++;
259 if (slowCount >= 10)
260 {
261 slowCount = 0;
262
263 lock (m_slowRequests)
264 {
265 while (m_slowRequests.Count > 0 && m_running)
266 m_requests.Enqueue(m_slowRequests.Dequeue());
267 }
268 }
269 }
270 }
271
272 ~PollServiceRequestManager()
273 {
274 m_running = false;
275// m_timeout = -10000; // cause all to expire
276 Thread.Sleep(1000); // let the world move
277
278 foreach (Thread t in m_workerThreads)
279 {
280 try
281 {
282 t.Abort();
283 }
284 catch
285 {
286 }
287 }
288
289 try
290 {
291 foreach (PollServiceHttpRequest req in m_retryRequests)
292 {
293 m_server.DoHTTPGruntWork(
294 req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id),
295 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext));
296 }
297 }
298 catch
299 {
300 }
301
302 PollServiceHttpRequest wreq;
303 m_retryRequests.Clear();
304
305 lock (m_slowRequests)
306 {
307 while (m_slowRequests.Count > 0 && m_running)
308 m_requests.Enqueue(m_slowRequests.Dequeue());
309 }
310
311 while (m_requests.Count() > 0)
312 {
313 try
314 {
315 wreq = m_requests.Dequeue(0);
316 m_server.DoHTTPGruntWork(
317 wreq.PollServiceArgs.NoEvents(wreq.RequestID, wreq.PollServiceArgs.Id),
318 new OSHttpResponse(new HttpResponse(wreq.HttpContext, wreq.Request), wreq.HttpContext));
319 }
320 catch
321 {
322 }
323 }
324
325 m_requests.Clear();
326 }
327
328 // work threads
329
330 private void PoolWorkerJob()
331 {
332 PollServiceHttpRequest req;
333 StreamReader str;
334
335// while (true)
336 while (m_running)
337 {
338 req = m_requests.Dequeue(5000);
339
340 Watchdog.UpdateThread();
341 if (req != null)
342 {
343 try
344 {
345 if (req.PollServiceArgs.HasEvents(req.RequestID, req.PollServiceArgs.Id))
346 {
347 try
348 {
349 str = new StreamReader(req.Request.Body);
350 }
351 catch (System.ArgumentException)
352 {
353 // Stream was not readable means a child agent
354 // was closed due to logout, leaving the
355 // Event Queue request orphaned.
356 continue;
357 }
358
359 try
360 {
361 Hashtable responsedata = req.PollServiceArgs.GetEvents(req.RequestID, req.PollServiceArgs.Id, str.ReadToEnd());
362 m_server.DoHTTPGruntWork(responsedata,
363 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext));
364 }
365 catch (ObjectDisposedException) // Browser aborted before we could read body, server closed the stream
366 {
367 // Ignore it, no need to reply
368 }
369
370 str.Close();
371
372 }
373 else
374 {
375 // if ((Environment.TickCount - req.RequestTime) > m_timeout)
376 if ((Environment.TickCount - req.RequestTime) > req.PollServiceArgs.TimeOutms)
377 {
378 m_server.DoHTTPGruntWork(req.PollServiceArgs.NoEvents(req.RequestID, req.PollServiceArgs.Id),
379 new OSHttpResponse(new HttpResponse(req.HttpContext, req.Request), req.HttpContext));
380 }
381 else
382 {
383 ReQueueEvent(req);
384 }
385 }
386 }
387 catch (Exception e)
388 {
389 m_log.ErrorFormat("Exception in poll service thread: " + e.ToString());
390 }
391 }
392 }
393 }
394 }
395}
396
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs
index d305782..1e3fbf0 100644
--- a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs
+++ b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs
@@ -25,6 +25,8 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28/* Ubit work moved to PollServiceRequestManager
29
28using System; 30using System;
29using System.Collections; 31using System.Collections;
30using System.Collections.Generic; 32using System.Collections.Generic;
@@ -169,3 +171,4 @@ namespace OpenSim.Framework.Servers.HttpServer
169 } 171 }
170 } 172 }
171} 173}
174*/ \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
index 0d7390b..ebfe687 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs
@@ -377,7 +377,7 @@ namespace OpenSim.Region.ClientStack.Linden
377 // TODO: Add EventQueueGet name/description for diagnostics 377 // TODO: Add EventQueueGet name/description for diagnostics
378 MainServer.Instance.AddPollServiceHTTPHandler( 378 MainServer.Instance.AddPollServiceHTTPHandler(
379 eventQueueGetPath, 379 eventQueueGetPath,
380 new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID)); 380 new PollServiceEventArgs(null, HasEvents, GetEvents, NoEvents, agentID, 1000));
381 381
382// m_log.DebugFormat( 382// m_log.DebugFormat(
383// "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}", 383// "[EVENT QUEUE GET MODULE]: Registered EQG handler {0} for {1} in {2}",
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 18602f7..3461971 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -5080,10 +5080,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5080 update.TextureEntry = Utils.EmptyBytes; 5080 update.TextureEntry = Utils.EmptyBytes;
5081// update.TextureEntry = (data.Appearance.Texture != null) ? data.Appearance.Texture.GetBytes() : Utils.EmptyBytes; 5081// update.TextureEntry = (data.Appearance.Texture != null) ? data.Appearance.Texture.GetBytes() : Utils.EmptyBytes;
5082 5082
5083/* all this flags seem related to prims and not avatars. This allow for wrong viewer side move of a avatar in prim edition mode (anv mantis 854)
5083 update.UpdateFlags = (uint)( 5084 update.UpdateFlags = (uint)(
5084 PrimFlags.Physics | PrimFlags.ObjectModify | PrimFlags.ObjectCopy | PrimFlags.ObjectAnyOwner | 5085 PrimFlags.Physics | PrimFlags.ObjectModify | PrimFlags.ObjectCopy | PrimFlags.ObjectAnyOwner |
5085 PrimFlags.ObjectYouOwner | PrimFlags.ObjectMove | PrimFlags.InventoryEmpty | PrimFlags.ObjectTransfer | 5086 PrimFlags.ObjectYouOwner | PrimFlags.ObjectMove | PrimFlags.InventoryEmpty | PrimFlags.ObjectTransfer |
5086 PrimFlags.ObjectOwnerModify); 5087 PrimFlags.ObjectOwnerModify);
5088*/
5089 update.UpdateFlags = 0;
5087 5090
5088 return update; 5091 return update;
5089 } 5092 }
@@ -6404,6 +6407,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6404 { 6407 {
6405 handlerCompleteMovementToRegion(sender, true); 6408 handlerCompleteMovementToRegion(sender, true);
6406 } 6409 }
6410 else
6411 m_log.Debug("HandleCompleteAgentMovement NULL handler");
6412
6407 handlerCompleteMovementToRegion = null; 6413 handlerCompleteMovementToRegion = null;
6408 6414
6409 return true; 6415 return true;
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index e55e2c5..754d9d2 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -779,14 +779,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
779 IClientAPI client; 779 IClientAPI client;
780 if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView)) 780 if (!m_scene.TryGetClient(address, out client) || !(client is LLClientView))
781 { 781 {
782 //m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName); 782// m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet from an unrecognized source: " + address + " in " + m_scene.RegionInfo.RegionName);
783 return; 783 return;
784 } 784 }
785 785
786 udpClient = ((LLClientView)client).UDPClient; 786 udpClient = ((LLClientView)client).UDPClient;
787 787
788 if (!udpClient.IsConnected) 788 if (!udpClient.IsConnected)
789 {
790// m_log.Debug("[LLUDPSERVER]: Received a " + packet.Type + " packet for a unConnected client in " + m_scene.RegionInfo.RegionName);
789 return; 791 return;
792 }
790 793
791 #endregion Packet to Client Mapping 794 #endregion Packet to Client Mapping
792 795
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
index bc42fd1..dbbb0ae 100644
--- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs
@@ -351,9 +351,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
351 UUID fromAgentID, string fromName, ChatTypeEnum type, 351 UUID fromAgentID, string fromName, ChatTypeEnum type,
352 string message, ChatSourceType src) 352 string message, ChatSourceType src)
353 { 353 {
354 // don't send llRegionSay to child agents. Send normal chat because you 354 // don't send chat to child agents
355 // can't talk across sim borders if it's not done 355 if (presence.IsChildAgent) return false;
356 if (type == ChatTypeEnum.Broadcast && presence.IsChildAgent) return false;
357 356
358 Vector3 fromRegionPos = fromPos + regionPos; 357 Vector3 fromRegionPos = fromPos + regionPos;
359 Vector3 toRegionPos = presence.AbsolutePosition + 358 Vector3 toRegionPos = presence.AbsolutePosition +
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
index 192b4f6..7f2f147 100644
--- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs
@@ -184,9 +184,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
184 184
185 string uri = "/lslhttp/" + urlcode.ToString(); 185 string uri = "/lslhttp/" + urlcode.ToString();
186 186
187 m_HttpServer.AddPollServiceHTTPHandler( 187 PollServiceEventArgs args = new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode, 25000);
188 uri, 188 args.Type = PollServiceEventArgs.EventType.LslHttp;
189 new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); 189 m_HttpServer.AddPollServiceHTTPHandler(uri, args);
190 190
191 m_log.DebugFormat( 191 m_log.DebugFormat(
192 "[URL MODULE]: Set up incoming request url {0} for {1} in {2} {3}", 192 "[URL MODULE]: Set up incoming request url {0} for {1} in {2} {3}",
@@ -232,7 +232,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
232 232
233 m_HttpsServer.AddPollServiceHTTPHandler( 233 m_HttpsServer.AddPollServiceHTTPHandler(
234 uri, 234 uri,
235 new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode)); 235 new PollServiceEventArgs(HttpRequestHandler, HasEvents, GetEvents, NoEvents, urlcode,25000));
236 236
237 m_log.DebugFormat( 237 m_log.DebugFormat(
238 "[URL MODULE]: Set up incoming secure request url {0} for {1} in {2} {3}", 238 "[URL MODULE]: Set up incoming secure request url {0} for {1} in {2} {3}",
@@ -446,7 +446,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp
446 } 446 }
447 private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) 447 private Hashtable GetEvents(UUID requestID, UUID sessionID, string request)
448 { 448 {
449 UrlData url = null; 449 UrlData url = null;
450 RequestData requestData = null; 450 RequestData requestData = null;
451 451
452 lock (m_RequestMap) 452 lock (m_RequestMap)
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
index b7667b9..4f06737 100644
--- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs
+++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs
@@ -200,7 +200,7 @@ namespace OpenSim.Region.CoreModules.World.Land
200 * (long)m_scene.RegionInfo.ObjectCapacity 200 * (long)m_scene.RegionInfo.ObjectCapacity
201 * (long)m_scene.RegionInfo.RegionSettings.ObjectBonus 201 * (long)m_scene.RegionInfo.RegionSettings.ObjectBonus
202 / 65536L); 202 / 65536L);
203 m_log.DebugFormat("Area: {0}, Capacity {1}, Bonus {2}, Parcel {3}", LandData.Area, m_scene.RegionInfo.ObjectCapacity, m_scene.RegionInfo.RegionSettings.ObjectBonus, parcelMax); 203 //m_log.DebugFormat("Area: {0}, Capacity {1}, Bonus {2}, Parcel {3}", LandData.Area, m_scene.RegionInfo.ObjectCapacity, m_scene.RegionInfo.RegionSettings.ObjectBonus, parcelMax);
204 return parcelMax; 204 return parcelMax;
205 } 205 }
206 } 206 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 4c12496..3390aba 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -592,12 +592,12 @@ namespace OpenSim.Region.Framework.Scenes
592 592
593 protected internal void AddPhysicalPrim(int number) 593 protected internal void AddPhysicalPrim(int number)
594 { 594 {
595 m_physicalPrim++; 595 m_physicalPrim += number;
596 } 596 }
597 597
598 protected internal void RemovePhysicalPrim(int number) 598 protected internal void RemovePhysicalPrim(int number)
599 { 599 {
600 m_physicalPrim--; 600 m_physicalPrim -= number;
601 } 601 }
602 602
603 protected internal void AddToScriptLPS(int number) 603 protected internal void AddToScriptLPS(int number)
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 3db6710..f68a5b3 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -656,6 +656,14 @@ namespace OpenSim.Region.Framework.Scenes
656 if (triggerScriptEvent) 656 if (triggerScriptEvent)
657 part.TriggerScriptChangedEvent(Changed.POSITION); 657 part.TriggerScriptChangedEvent(Changed.POSITION);
658 } 658 }
659
660/*
661 This seems not needed and should not be needed:
662 sp absolute position depends on sit part absolute position fixed above.
663 sp ParentPosition is not used anywhere.
664 Since presence is sitting, viewer considers it 'linked' to root prim, so it will move/rotate it
665 Sending a extra packet with avatar position is not only bandwidth waste, but may cause jitter in viewers due to UPD nature.
666
659 if (!m_dupeInProgress) 667 if (!m_dupeInProgress)
660 { 668 {
661 foreach (ScenePresence av in m_linkedAvatars) 669 foreach (ScenePresence av in m_linkedAvatars)
@@ -665,12 +673,12 @@ namespace OpenSim.Region.Framework.Scenes
665 { 673 {
666 Vector3 offset = p.GetWorldPosition() - av.ParentPosition; 674 Vector3 offset = p.GetWorldPosition() - av.ParentPosition;
667 av.AbsolutePosition += offset; 675 av.AbsolutePosition += offset;
668 av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition 676// av.ParentPosition = p.GetWorldPosition(); //ParentPosition gets cleared by AbsolutePosition
669 av.SendAvatarDataToAllAgents(); 677 av.SendAvatarDataToAllAgents();
670 } 678 }
671 } 679 }
672 } 680 }
673 681*/
674 //if (m_rootPart.PhysActor != null) 682 //if (m_rootPart.PhysActor != null)
675 //{ 683 //{
676 //m_rootPart.PhysActor.Position = 684 //m_rootPart.PhysActor.Position =
@@ -701,8 +709,8 @@ namespace OpenSim.Region.Framework.Scenes
701 if (agent.ParentUUID != UUID.Zero) 709 if (agent.ParentUUID != UUID.Zero)
702 { 710 {
703 agent.ParentPart = null; 711 agent.ParentPart = null;
704 agent.ParentPosition = Vector3.Zero; 712// agent.ParentPosition = Vector3.Zero;
705 // agent.ParentUUID = UUID.Zero; 713// agent.ParentUUID = UUID.Zero;
706 } 714 }
707 } 715 }
708 716
@@ -3815,7 +3823,7 @@ namespace OpenSim.Region.Framework.Scenes
3815 else 3823 else
3816 // ugly rotation update of all parts 3824 // ugly rotation update of all parts
3817 { 3825 {
3818 group.AbsolutePosition = AbsolutePosition; 3826 group.ResetChildPrimPhysicsPositions();
3819 } 3827 }
3820 3828
3821 } 3829 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index f1e781c..7b1f5d2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1856,6 +1856,34 @@ namespace OpenSim.Region.Framework.Scenes
1856 } 1856 }
1857 } 1857 }
1858 1858
1859// SetVelocity for LSL llSetVelocity.. may need revision if having other uses in future
1860 public void SetVelocity(Vector3 pVel, bool localGlobalTF)
1861 {
1862 if (ParentGroup == null || ParentGroup.IsDeleted)
1863 return;
1864
1865 if (ParentGroup.IsAttachment)
1866 return; // don't work on attachments (for now ??)
1867
1868 SceneObjectPart root = ParentGroup.RootPart;
1869
1870 if (root.VehicleType != (int)Vehicle.TYPE_NONE) // don't mess with vehicles
1871 return;
1872
1873 PhysicsActor pa = root.PhysActor;
1874
1875 if (pa == null || !pa.IsPhysical)
1876 return;
1877
1878 if (localGlobalTF)
1879 {
1880 pVel = pVel * GetWorldRotation();
1881 }
1882
1883 ParentGroup.Velocity = pVel;
1884 }
1885
1886
1859 /// <summary> 1887 /// <summary>
1860 /// hook to the physics scene to apply angular impulse 1888 /// hook to the physics scene to apply angular impulse
1861 /// This is sent up to the group, which then finds the root prim 1889 /// This is sent up to the group, which then finds the root prim
@@ -4512,7 +4540,8 @@ namespace OpenSim.Region.Framework.Scenes
4512 { 4540 {
4513 if (pa != null) 4541 if (pa != null)
4514 { 4542 {
4515 ParentGroup.Scene.RemovePhysicalPrim(1); 4543 if(wasUsingPhysics)
4544 ParentGroup.Scene.RemovePhysicalPrim(1);
4516 RemoveFromPhysics(); 4545 RemoveFromPhysics();
4517 } 4546 }
4518 4547
@@ -4529,37 +4558,36 @@ namespace OpenSim.Region.Framework.Scenes
4529 { 4558 {
4530 AddToPhysics(UsePhysics, SetPhantom, building, false); 4559 AddToPhysics(UsePhysics, SetPhantom, building, false);
4531 pa = PhysActor; 4560 pa = PhysActor;
4532 /* 4561/*
4533 if (pa != null) 4562 if (pa != null)
4534 { 4563 {
4535 if ( 4564 if (
4536 // ((AggregateScriptEvents & scriptEvents.collision) != 0) || 4565// ((AggregateScriptEvents & scriptEvents.collision) != 0) ||
4537 // ((AggregateScriptEvents & scriptEvents.collision_end) != 0) || 4566// ((AggregateScriptEvents & scriptEvents.collision_end) != 0) ||
4538 // ((AggregateScriptEvents & scriptEvents.collision_start) != 0) || 4567// ((AggregateScriptEvents & scriptEvents.collision_start) != 0) ||
4539 // ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) || 4568// ((AggregateScriptEvents & scriptEvents.land_collision_start) != 0) ||
4540 // ((AggregateScriptEvents & scriptEvents.land_collision) != 0) || 4569// ((AggregateScriptEvents & scriptEvents.land_collision) != 0) ||
4541 // ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) || 4570// ((AggregateScriptEvents & scriptEvents.land_collision_end) != 0) ||
4542 ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || 4571 ((AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) ||
4543 ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) || 4572 ((ParentGroup.RootPart.AggregateScriptEvents & PhysicsNeededSubsEvents) != 0) ||
4544 (CollisionSound != UUID.Zero) 4573 (CollisionSound != UUID.Zero)
4545 ) 4574 )
4546 { 4575 {
4547 pa.OnCollisionUpdate += PhysicsCollision; 4576 pa.OnCollisionUpdate += PhysicsCollision;
4548 pa.SubscribeEvents(1000); 4577 pa.SubscribeEvents(1000);
4549 } 4578 }
4550 } 4579 }
4551 */ 4580*/
4552 } 4581 }
4553 else // it already has a physical representation 4582 else // it already has a physical representation
4554 { 4583 {
4555 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status. 4584 DoPhysicsPropertyUpdate(UsePhysics, false); // Update physical status.
4556 /* moved into DoPhysicsPropertyUpdate 4585/* moved into DoPhysicsPropertyUpdate
4557 if(VolumeDetectActive) 4586 if(VolumeDetectActive)
4558 pa.SetVolumeDetect(1); 4587 pa.SetVolumeDetect(1);
4559 else 4588 else
4560 pa.SetVolumeDetect(0); 4589 pa.SetVolumeDetect(0);
4561 */ 4590*/
4562
4563 4591
4564 if (pa.Building != building) 4592 if (pa.Building != building)
4565 pa.Building = building; 4593 pa.Building = building;
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 159a92a..f0ceff6 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -439,7 +439,7 @@ namespace OpenSim.Region.Framework.Scenes
439 get { return (IClientCore)ControllingClient; } 439 get { return (IClientCore)ControllingClient; }
440 } 440 }
441 441
442 public Vector3 ParentPosition { get; set; } 442// public Vector3 ParentPosition { get; set; }
443 443
444 /// <summary> 444 /// <summary>
445 /// Position of this avatar relative to the region the avatar is in 445 /// Position of this avatar relative to the region the avatar is in
@@ -497,7 +497,7 @@ namespace OpenSim.Region.Framework.Scenes
497 if (ParentID == 0) 497 if (ParentID == 0)
498 { 498 {
499 m_pos = value; 499 m_pos = value;
500 ParentPosition = Vector3.Zero; 500// ParentPosition = Vector3.Zero;
501 } 501 }
502 502
503 //m_log.DebugFormat( 503 //m_log.DebugFormat(
@@ -865,11 +865,12 @@ namespace OpenSim.Region.Framework.Scenes
865 part.ParentGroup.AddAvatar(UUID); 865 part.ParentGroup.AddAvatar(UUID);
866 if (part.SitTargetPosition != Vector3.Zero) 866 if (part.SitTargetPosition != Vector3.Zero)
867 part.SitTargetAvatar = UUID; 867 part.SitTargetAvatar = UUID;
868 ParentPosition = part.GetWorldPosition(); 868// ParentPosition = part.GetWorldPosition();
869 ParentID = part.LocalId; 869 ParentID = part.LocalId;
870 ParentPart = part; 870 ParentPart = part;
871 m_pos = m_prevSitOffset; 871 m_pos = m_prevSitOffset;
872 pos = ParentPosition; 872// pos = ParentPosition;
873 pos = part.GetWorldPosition();
873 } 874 }
874 ParentUUID = UUID.Zero; 875 ParentUUID = UUID.Zero;
875 876
@@ -1944,11 +1945,12 @@ namespace OpenSim.Region.Framework.Scenes
1944 part.SitTargetAvatar = UUID.Zero; 1945 part.SitTargetAvatar = UUID.Zero;
1945 1946
1946 part.ParentGroup.DeleteAvatar(UUID); 1947 part.ParentGroup.DeleteAvatar(UUID);
1947 ParentPosition = part.GetWorldPosition(); 1948// ParentPosition = part.GetWorldPosition();
1948 ControllingClient.SendClearFollowCamProperties(part.ParentUUID); 1949 ControllingClient.SendClearFollowCamProperties(part.ParentUUID);
1949 1950
1950 m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight); 1951// m_pos += ParentPosition + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
1951 ParentPosition = Vector3.Zero; 1952// ParentPosition = Vector3.Zero;
1953 m_pos += part.GetWorldPosition() + new Vector3(0.0f, 0.0f, 2.0f * m_sitAvatarHeight);
1952 1954
1953 ParentID = 0; 1955 ParentID = 0;
1954 ParentPart = null; 1956 ParentPart = null;
@@ -2399,13 +2401,13 @@ namespace OpenSim.Region.Framework.Scenes
2399 2401
2400// m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset; 2402// m_pos = sitTargetPos + SIT_TARGET_ADJUSTMENT - sitOffset;
2401 Rotation = sitTargetOrient; 2403 Rotation = sitTargetOrient;
2402 ParentPosition = part.AbsolutePosition; 2404// ParentPosition = part.AbsolutePosition;
2403 part.ParentGroup.AddAvatar(UUID); 2405 part.ParentGroup.AddAvatar(UUID);
2404 } 2406 }
2405 else 2407 else
2406 { 2408 {
2407 m_pos -= part.AbsolutePosition; 2409 m_pos -= part.AbsolutePosition;
2408 ParentPosition = part.AbsolutePosition; 2410// ParentPosition = part.AbsolutePosition;
2409 part.ParentGroup.AddAvatar(UUID); 2411 part.ParentGroup.AddAvatar(UUID);
2410 2412
2411// m_log.DebugFormat( 2413// m_log.DebugFormat(
@@ -3587,7 +3589,8 @@ namespace OpenSim.Region.Framework.Scenes
3587 // m_reprioritizationTimer.Dispose(); 3589 // m_reprioritizationTimer.Dispose();
3588 3590
3589 RemoveFromPhysicalScene(); 3591 RemoveFromPhysicalScene();
3590 Animator.Close(); 3592 if(Animator != null)
3593 Animator.Close();
3591 Animator = null; 3594 Animator = null;
3592 } 3595 }
3593 3596
diff --git a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
index 286c7f0..6c72324 100644
--- a/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
+++ b/OpenSim/Region/Physics/UbitOdePlugin/OdeScene.cs
@@ -302,6 +302,7 @@ namespace OpenSim.Region.Physics.OdePlugin
302 302
303 // split static geometry collision into a grid as before 303 // split static geometry collision into a grid as before
304 private IntPtr[,] staticPrimspace; 304 private IntPtr[,] staticPrimspace;
305 private IntPtr[] staticPrimspaceOffRegion;
305 306
306 public Object OdeLock; 307 public Object OdeLock;
307 private static Object SimulationLock; 308 private static Object SimulationLock;
@@ -551,6 +552,7 @@ namespace OpenSim.Region.Physics.OdePlugin
551 // create all spaces now 552 // create all spaces now
552 int i, j; 553 int i, j;
553 IntPtr newspace; 554 IntPtr newspace;
555
554 for (i = 0; i < spaceGridMaxX; i++) 556 for (i = 0; i < spaceGridMaxX; i++)
555 for (j = 0; j < spaceGridMaxY; j++) 557 for (j = 0; j < spaceGridMaxY; j++)
556 { 558 {
@@ -573,6 +575,29 @@ namespace OpenSim.Region.Physics.OdePlugin
573 // let this now be real maximum values 575 // let this now be real maximum values
574 spaceGridMaxX--; 576 spaceGridMaxX--;
575 spaceGridMaxY--; 577 spaceGridMaxY--;
578
579 // create 4 off world spaces (x<0,x>max,y<0,y>max)
580 staticPrimspaceOffRegion = new IntPtr[4];
581
582 for (i = 0; i < 4; i++)
583 {
584 newspace = d.HashSpaceCreate(StaticSpace);
585 d.GeomSetCategoryBits(newspace, (int)CollisionCategories.Space);
586 waitForSpaceUnlock(newspace);
587 d.SpaceSetSublevel(newspace, 2);
588 d.HashSpaceSetLevels(newspace, -2, 8);
589 d.GeomSetCategoryBits(newspace, (uint)(CollisionCategories.Space |
590 CollisionCategories.Geom |
591 CollisionCategories.Land |
592 CollisionCategories.Water |
593 CollisionCategories.Phantom |
594 CollisionCategories.VolumeDtc
595 ));
596 d.GeomSetCollideBits(newspace, 0);
597
598 staticPrimspaceOffRegion[i] = newspace;
599 }
600
576 m_lastframe = DateTime.UtcNow; 601 m_lastframe = DateTime.UtcNow;
577 } 602 }
578 603
@@ -1650,20 +1675,22 @@ namespace OpenSim.Region.Physics.OdePlugin
1650 public IntPtr calculateSpaceForGeom(Vector3 pos) 1675 public IntPtr calculateSpaceForGeom(Vector3 pos)
1651 { 1676 {
1652 int x, y; 1677 int x, y;
1653 x = (int)(pos.X * spacesPerMeter);
1654 if (x < 0)
1655 x = 0;
1656 else if (x > spaceGridMaxX)
1657 x = spaceGridMaxX;
1658 1678
1679 if (pos.X < 0)
1680 return staticPrimspaceOffRegion[0];
1681
1682 if (pos.Y < 0)
1683 return staticPrimspaceOffRegion[2];
1684
1685 x = (int)(pos.X * spacesPerMeter);
1686 if (x > spaceGridMaxX)
1687 return staticPrimspaceOffRegion[1];
1688
1659 y = (int)(pos.Y * spacesPerMeter); 1689 y = (int)(pos.Y * spacesPerMeter);
1660 if (y < 0) 1690 if (y > spaceGridMaxY)
1661 y = 0; 1691 return staticPrimspaceOffRegion[3];
1662 else if (y >spaceGridMaxY)
1663 y = spaceGridMaxY;
1664 1692
1665 IntPtr tmpSpace = staticPrimspace[x, y]; 1693 return staticPrimspace[x, y];
1666 return tmpSpace;
1667 } 1694 }
1668 1695
1669 #endregion 1696 #endregion
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 14dd2ad..b257cd4 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -618,18 +618,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
618 m_host.AddScriptLPS(1); 618 m_host.AddScriptLPS(1);
619 619
620 double x,y,z,s; 620 double x,y,z,s;
621 621 v.x *= 0.5;
622 double c1 = Math.Cos(v.x * 0.5); 622 v.y *= 0.5;
623 double c2 = Math.Cos(v.y * 0.5); 623 v.z *= 0.5;
624 double c3 = Math.Cos(v.z * 0.5); 624 double c1 = Math.Cos(v.x);
625 double s1 = Math.Sin(v.x * 0.5); 625 double c2 = Math.Cos(v.y);
626 double s2 = Math.Sin(v.y * 0.5); 626 double c1c2 = c1 * c2;
627 double s3 = Math.Sin(v.z * 0.5); 627 double s1 = Math.Sin(v.x);
628 628 double s2 = Math.Sin(v.y);
629 x = s1 * c2 * c3 + c1 * s2 * s3; 629 double s1s2 = s1 * s2;
630 y = c1 * s2 * c3 - s1 * c2 * s3; 630 double c1s2 = c1 * s2;
631 z = s1 * s2 * c3 + c1 * c2 * s3; 631 double s1c2 = s1 * c2;
632 s = c1 * c2 * c3 - s1 * s2 * s3; 632 double c3 = Math.Cos(v.z);
633 double s3 = Math.Sin(v.z);
634
635 x = s1c2 * c3 + c1s2 * s3;
636 y = c1s2 * c3 - s1c2 * s3;
637 z = s1s2 * c3 + c1c2 * s3;
638 s = c1c2 * c3 - s1s2 * s3;
633 639
634 return new LSL_Rotation(x, y, z, s); 640 return new LSL_Rotation(x, y, z, s);
635 } 641 }
@@ -1869,11 +1875,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1869 Primitive.TextureEntry tex = part.Shape.Textures; 1875 Primitive.TextureEntry tex = part.Shape.Textures;
1870 Color4 texcolor; 1876 Color4 texcolor;
1871 LSL_Vector rgb = new LSL_Vector(); 1877 LSL_Vector rgb = new LSL_Vector();
1878 int nsides = GetNumberOfSides(part);
1879
1872 if (face == ScriptBaseClass.ALL_SIDES) 1880 if (face == ScriptBaseClass.ALL_SIDES)
1873 { 1881 {
1874 int i; 1882 int i;
1875 1883 for (i = 0; i < nsides; i++)
1876 for (i = 0 ; i < GetNumberOfSides(part); i++)
1877 { 1884 {
1878 texcolor = tex.GetFace((uint)i).RGBA; 1885 texcolor = tex.GetFace((uint)i).RGBA;
1879 rgb.x += texcolor.R; 1886 rgb.x += texcolor.R;
@@ -1881,14 +1888,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1881 rgb.z += texcolor.B; 1888 rgb.z += texcolor.B;
1882 } 1889 }
1883 1890
1884 rgb.x /= (float)GetNumberOfSides(part); 1891 float invnsides = 1.0f / (float)nsides;
1885 rgb.y /= (float)GetNumberOfSides(part); 1892
1886 rgb.z /= (float)GetNumberOfSides(part); 1893 rgb.x *= invnsides;
1894 rgb.y *= invnsides;
1895 rgb.z *= invnsides;
1887 1896
1888 return rgb; 1897 return rgb;
1889 } 1898 }
1890 1899 if (face >= 0 && face < nsides)
1891 if (face >= 0 && face < GetNumberOfSides(part))
1892 { 1900 {
1893 texcolor = tex.GetFace((uint)face).RGBA; 1901 texcolor = tex.GetFace((uint)face).RGBA;
1894 rgb.x = texcolor.R; 1902 rgb.x = texcolor.R;
@@ -2288,15 +2296,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2288 // (root prim). ParentID may be nonzero in attachments and 2296 // (root prim). ParentID may be nonzero in attachments and
2289 // using it would cause attachments and HUDs to rotate 2297 // using it would cause attachments and HUDs to rotate
2290 // to the wrong positions. 2298 // to the wrong positions.
2299
2291 SetRot(m_host, Rot2Quaternion(rot)); 2300 SetRot(m_host, Rot2Quaternion(rot));
2292 } 2301 }
2293 else 2302 else
2294 { 2303 {
2295 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. 2304 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
2296 SceneObjectPart rootPart = m_host.ParentGroup.RootPart; 2305 SceneObjectPart rootPart;
2297 if (rootPart != null) // better safe than sorry 2306 if (m_host.ParentGroup != null) // better safe than sorry
2298 { 2307 {
2299 SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); 2308 rootPart = m_host.ParentGroup.RootPart;
2309 if (rootPart != null)
2310 SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot));
2300 } 2311 }
2301 } 2312 }
2302 2313
@@ -2306,6 +2317,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2306 public void llSetLocalRot(LSL_Rotation rot) 2317 public void llSetLocalRot(LSL_Rotation rot)
2307 { 2318 {
2308 m_host.AddScriptLPS(1); 2319 m_host.AddScriptLPS(1);
2320
2309 SetRot(m_host, Rot2Quaternion(rot)); 2321 SetRot(m_host, Rot2Quaternion(rot));
2310 ScriptSleep(200); 2322 ScriptSleep(200);
2311 } 2323 }
@@ -2315,25 +2327,43 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2315 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted) 2327 if (part == null || part.ParentGroup == null || part.ParentGroup.IsDeleted)
2316 return; 2328 return;
2317 2329
2318 part.UpdateRotation(rot); 2330 bool isroot = (part == part.ParentGroup.RootPart);
2319 // Update rotation does not move the object in the physics scene if it's a linkset. 2331 bool isphys;
2320 2332
2321//KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type
2322// part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition;
2323
2324 // So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line
2325 // is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt
2326 // It's perfectly okay when the object is not an active physical body though.
2327 // So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against
2328 // but only if the object is not physial and active. This is important for rotating doors.
2329 // without the absoluteposition = absoluteposition happening, the doors do not move in the physics
2330 // scene
2331 PhysicsActor pa = part.PhysActor; 2333 PhysicsActor pa = part.PhysActor;
2332 2334
2333 if (pa != null && !pa.IsPhysical && part == part.ParentGroup.RootPart) 2335 // keep using physactor ideia of isphysical
2336 // it should be SOP ideia of that
2337 // not much of a issue with ubitODE
2338 if (pa != null && pa.IsPhysical)
2339 isphys = true;
2340 else
2341 isphys = false;
2342
2343 // SL doesn't let scripts rotate root of physical linksets
2344 if (isroot && isphys)
2345 return;
2346
2347 part.UpdateRotation(rot);
2348
2349 // Update rotation does not move the object in the physics engine if it's a non physical linkset
2350 // so do a nasty update of parts positions if is a root part rotation
2351 if (isroot && pa != null) // with if above implies non physical root part
2334 { 2352 {
2335 part.ParentGroup.ResetChildPrimPhysicsPositions(); 2353 part.ParentGroup.ResetChildPrimPhysicsPositions();
2336 } 2354 }
2355 else // fix sitting avatars. This is only needed bc of how we link avas to child parts, not root part
2356 {
2357 List<ScenePresence> sittingavas = part.ParentGroup.GetLinkedAvatars();
2358 if (sittingavas.Count > 0)
2359 {
2360 foreach (ScenePresence av in sittingavas)
2361 {
2362 if (isroot || part.LocalId == av.ParentID)
2363 av.SendTerseUpdateToAllClients();
2364 }
2365 }
2366 }
2337 } 2367 }
2338 2368
2339 /// <summary> 2369 /// <summary>
@@ -2382,7 +2412,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2382 public LSL_Rotation llGetLocalRot() 2412 public LSL_Rotation llGetLocalRot()
2383 { 2413 {
2384 m_host.AddScriptLPS(1); 2414 m_host.AddScriptLPS(1);
2385 return new LSL_Rotation(m_host.RotationOffset.X, m_host.RotationOffset.Y, m_host.RotationOffset.Z, m_host.RotationOffset.W); 2415 Quaternion rot = m_host.RotationOffset;
2416 return new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W);
2386 } 2417 }
2387 2418
2388 public void llSetForce(LSL_Vector force, int local) 2419 public void llSetForce(LSL_Vector force, int local)
@@ -2466,6 +2497,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2466 m_host.ApplyImpulse(v, local != 0); 2497 m_host.ApplyImpulse(v, local != 0);
2467 } 2498 }
2468 2499
2500
2469 public void llApplyRotationalImpulse(LSL_Vector force, int local) 2501 public void llApplyRotationalImpulse(LSL_Vector force, int local)
2470 { 2502 {
2471 m_host.AddScriptLPS(1); 2503 m_host.AddScriptLPS(1);
@@ -2492,6 +2524,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2492 llSetTorque(torque, local); 2524 llSetTorque(torque, local);
2493 } 2525 }
2494 2526
2527 public void llSetVelocity(LSL_Vector vel, int local)
2528 {
2529 m_host.AddScriptLPS(1);
2530 m_host.SetVelocity(new Vector3((float)vel.x, (float)vel.y, (float)vel.z), local != 0);
2531 }
2532
2495 public LSL_Vector llGetVel() 2533 public LSL_Vector llGetVel()
2496 { 2534 {
2497 m_host.AddScriptLPS(1); 2535 m_host.AddScriptLPS(1);
@@ -2518,10 +2556,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2518 return new LSL_Vector(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z); 2556 return new LSL_Vector(m_host.Acceleration.X, m_host.Acceleration.Y, m_host.Acceleration.Z);
2519 } 2557 }
2520 2558
2559
2560 public void llSetAngularVelocity(LSL_Vector avel, int local)
2561 {
2562 m_host.AddScriptLPS(1);
2563 // Still not done !!!!
2564// m_host.SetAngularVelocity(new Vector3((float)avel.x, (float)avel.y, (float)avel.z), local != 0);
2565 }
2566
2521 public LSL_Vector llGetOmega() 2567 public LSL_Vector llGetOmega()
2522 { 2568 {
2523 m_host.AddScriptLPS(1); 2569 m_host.AddScriptLPS(1);
2524 return new LSL_Vector(m_host.AngularVelocity.X, m_host.AngularVelocity.Y, m_host.AngularVelocity.Z); 2570 Vector3 avel = m_host.AngularVelocity;
2571 return new LSL_Vector(avel.X, avel.Y, avel.Z);
2525 } 2572 }
2526 2573
2527 public LSL_Float llGetTimeOfDay() 2574 public LSL_Float llGetTimeOfDay()
@@ -7740,7 +7787,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7740 Quaternion srot = sitpart.RotationOffset; 7787 Quaternion srot = sitpart.RotationOffset;
7741 rot = Quaternion.Conjugate(srot) * rot; // removed sit part offset rotation 7788 rot = Quaternion.Conjugate(srot) * rot; // removed sit part offset rotation
7742 av.Rotation = rot; 7789 av.Rotation = rot;
7743 av.SendAvatarDataToAllAgents(); 7790// av.SendAvatarDataToAllAgents();
7791 av.SendTerseUpdateToAllClients();
7744 } 7792 }
7745 break; 7793 break;
7746 7794
@@ -7760,7 +7808,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7760 rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation 7808 rot = Quaternion.Conjugate(srot) * rot; // remove sit part offset rotation
7761 } 7809 }
7762 av.Rotation = rot; 7810 av.Rotation = rot;
7763 av.SendAvatarDataToAllAgents(); 7811// av.SendAvatarDataToAllAgents();
7812 av.SendTerseUpdateToAllClients();
7764 } 7813 }
7765 break; 7814 break;
7766 7815
@@ -7855,7 +7904,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7855 { 7904 {
7856 positionChanged = false; 7905 positionChanged = false;
7857 av.OffsetPosition = finalPos; 7906 av.OffsetPosition = finalPos;
7858 av.SendAvatarDataToAllAgents(); 7907// av.SendAvatarDataToAllAgents();
7908 av.SendTerseUpdateToAllClients();
7859 } 7909 }
7860 7910
7861 LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++); 7911 LSL_Integer new_linknumber = rules.GetLSLIntegerItem(idx++);
@@ -7871,7 +7921,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7871 if (positionChanged) 7921 if (positionChanged)
7872 { 7922 {
7873 av.OffsetPosition = finalPos; 7923 av.OffsetPosition = finalPos;
7874 av.SendAvatarDataToAllAgents(); 7924// av.SendAvatarDataToAllAgents();
7925 av.SendTerseUpdateToAllClients();
7875 positionChanged = false; 7926 positionChanged = false;
7876 } 7927 }
7877 } 7928 }
@@ -8280,6 +8331,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8280 case (int)ScriptBaseClass.PRIM_ROT_LOCAL: 8331 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
8281 if (remain < 1) 8332 if (remain < 1)
8282 return; 8333 return;
8334
8283 LSL_Rotation lr = rules.GetQuaternionItem(idx++); 8335 LSL_Rotation lr = rules.GetQuaternionItem(idx++);
8284 SetRot(part, Rot2Quaternion(lr)); 8336 SetRot(part, Rot2Quaternion(lr));
8285 break; 8337 break;
@@ -8379,10 +8431,91 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8379 8431
8380 public LSL_String llXorBase64Strings(string str1, string str2) 8432 public LSL_String llXorBase64Strings(string str1, string str2)
8381 { 8433 {
8382 m_host.AddScriptLPS(1); 8434 string b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
8383 Deprecated("llXorBase64Strings"); 8435
8384 ScriptSleep(300); 8436 ScriptSleep(300);
8385 return String.Empty; 8437 m_host.AddScriptLPS(1);
8438
8439 if (str1 == String.Empty)
8440 return String.Empty;
8441 if (str2 == String.Empty)
8442 return str1;
8443
8444 int len = str2.Length;
8445 if ((len % 4) != 0) // LL is EVIL!!!!
8446 {
8447 while (str2.EndsWith("="))
8448 str2 = str2.Substring(0, str2.Length - 1);
8449
8450 len = str2.Length;
8451 int mod = len % 4;
8452
8453 if (mod == 1)
8454 str2 = str2.Substring(0, str2.Length - 1);
8455 else if (mod == 2)
8456 str2 += "==";
8457 else if (mod == 3)
8458 str2 += "=";
8459 }
8460
8461 byte[] data1;
8462 byte[] data2;
8463 try
8464 {
8465 data1 = Convert.FromBase64String(str1);
8466 data2 = Convert.FromBase64String(str2);
8467 }
8468 catch (Exception)
8469 {
8470 return new LSL_String(String.Empty);
8471 }
8472
8473 // For cases where the decoded length of s2 is greater
8474 // than the decoded length of s1, simply perform a normal
8475 // decode and XOR
8476 //
8477 if (data2.Length >= data1.Length)
8478 {
8479 for (int pos = 0 ; pos < data1.Length ; pos++ )
8480 data1[pos] ^= data2[pos];
8481
8482 return Convert.ToBase64String(data1);
8483 }
8484
8485 // Remove padding
8486 while (str1.EndsWith("="))
8487 str1 = str1.Substring(0, str1.Length - 1);
8488 while (str2.EndsWith("="))
8489 str2 = str2.Substring(0, str2.Length - 1);
8490
8491 byte[] d1 = new byte[str1.Length];
8492 byte[] d2 = new byte[str2.Length];
8493
8494 for (int i = 0 ; i < str1.Length ; i++)
8495 {
8496 int idx = b64.IndexOf(str1.Substring(i, 1));
8497 if (idx == -1)
8498 idx = 0;
8499 d1[i] = (byte)idx;
8500 }
8501
8502 for (int i = 0 ; i < str2.Length ; i++)
8503 {
8504 int idx = b64.IndexOf(str2.Substring(i, 1));
8505 if (idx == -1)
8506 idx = 0;
8507 d2[i] = (byte)idx;
8508 }
8509
8510 string output = String.Empty;
8511
8512 for (int pos = 0 ; pos < d1.Length ; pos++)
8513 output += b64[d1[pos] ^ d2[pos % d2.Length]];
8514
8515 while (output.Length % 3 > 0)
8516 output += "=";
8517
8518 return output;
8386 } 8519 }
8387 8520
8388 public void llRemoteDataSetRegion() 8521 public void llRemoteDataSetRegion()
@@ -12254,7 +12387,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12254 bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL); 12387 bool checkPhysical = !((rejectTypes & ScriptBaseClass.RC_REJECT_PHYSICAL) == ScriptBaseClass.RC_REJECT_PHYSICAL);
12255 12388
12256 12389
12257 if (false)// World.SuportsRayCastFiltered()) 12390 if (World.SuportsRayCastFiltered())
12258 { 12391 {
12259 if (dist == 0) 12392 if (dist == 0)
12260 return list; 12393 return list;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
index 749fc97..af35258 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs
@@ -332,6 +332,7 @@ 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);
335 void llSetBuoyancy(double buoyancy); 336 void llSetBuoyancy(double buoyancy);
336 void llSetCameraAtOffset(LSL_Vector offset); 337 void llSetCameraAtOffset(LSL_Vector offset);
337 void llSetCameraEyeOffset(LSL_Vector offset); 338 void llSetCameraEyeOffset(LSL_Vector offset);
@@ -381,6 +382,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
381 void llSetVehicleRotationParam(int param, LSL_Rotation rot); 382 void llSetVehicleRotationParam(int param, LSL_Rotation rot);
382 void llSetVehicleType(int type); 383 void llSetVehicleType(int type);
383 void llSetVehicleVectorParam(int param, LSL_Vector vec); 384 void llSetVehicleVectorParam(int param, LSL_Vector vec);
385 void llSetVelocity(LSL_Vector velocity, int local);
384 void llShout(int channelID, string text); 386 void llShout(int channelID, string text);
385 LSL_Float llSin(double f); 387 LSL_Float llSin(double f);
386 void llSitTarget(LSL_Vector offset, LSL_Rotation rot); 388 void llSitTarget(LSL_Vector offset, LSL_Rotation rot);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
index 06f2c3c..89b6eff 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs
@@ -1495,6 +1495,11 @@ 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
1498 public void llSetBuoyancy(double buoyancy) 1503 public void llSetBuoyancy(double buoyancy)
1499 { 1504 {
1500 m_LSL_Functions.llSetBuoyancy(buoyancy); 1505 m_LSL_Functions.llSetBuoyancy(buoyancy);
@@ -1730,6 +1735,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
1730 m_LSL_Functions.llSetVehicleVectorParam(param, vec); 1735 m_LSL_Functions.llSetVehicleVectorParam(param, vec);
1731 } 1736 }
1732 1737
1738 public void llSetVelocity(LSL_Vector velocity, int local)
1739 {
1740 m_LSL_Functions.llSetVelocity(velocity, local);
1741 }
1742
1733 public void llShout(int channelID, string text) 1743 public void llShout(int channelID, string text)
1734 { 1744 {
1735 m_LSL_Functions.llShout(channelID, text); 1745 m_LSL_Functions.llShout(channelID, text);