aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Cache.cs83
-rw-r--r--OpenSim/Framework/IClientAPI.cs15
-rw-r--r--OpenSim/Framework/Monitoring/Watchdog.cs15
-rw-r--r--OpenSim/Framework/RegionInfo.cs42
-rw-r--r--OpenSim/Framework/Util.cs6
-rw-r--r--OpenSim/Region/Application/OpenSim.cs25
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs13
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs2
-rw-r--r--OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs2
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs2
-rw-r--r--OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs68
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs6
-rw-r--r--OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs63
-rw-r--r--OpenSim/Region/CoreModules/World/Sound/SoundModule.cs8
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs39
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs60
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs109
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs4
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs6
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs21
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs228
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs29
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs110
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSScene.cs78
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs199
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs14
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs28
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs13
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs1
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Helpers.cs28
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs77
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/EventManager.cs24
-rw-r--r--OpenSim/Region/ScriptEngine/XEngine/XEngine.cs51
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs6
40 files changed, 902 insertions, 611 deletions
diff --git a/OpenSim/Framework/Cache.cs b/OpenSim/Framework/Cache.cs
index 79e20fc..31cab4a 100644
--- a/OpenSim/Framework/Cache.cs
+++ b/OpenSim/Framework/Cache.cs
@@ -199,7 +199,14 @@ namespace OpenSim.Framework
199 // 199 //
200 public class Cache 200 public class Cache
201 { 201 {
202 /// <summary>
203 /// Must only be accessed under lock.
204 /// </summary>
202 private List<CacheItemBase> m_Index = new List<CacheItemBase>(); 205 private List<CacheItemBase> m_Index = new List<CacheItemBase>();
206
207 /// <summary>
208 /// Must only be accessed under m_Index lock.
209 /// </summary>
203 private Dictionary<string, CacheItemBase> m_Lookup = 210 private Dictionary<string, CacheItemBase> m_Lookup =
204 new Dictionary<string, CacheItemBase>(); 211 new Dictionary<string, CacheItemBase>();
205 212
@@ -320,19 +327,19 @@ namespace OpenSim.Framework
320 { 327 {
321 if (m_Lookup.ContainsKey(index)) 328 if (m_Lookup.ContainsKey(index))
322 item = m_Lookup[index]; 329 item = m_Lookup[index];
323 }
324 330
325 if (item == null) 331 if (item == null)
326 { 332 {
333 Expire(true);
334 return null;
335 }
336
337 item.hits++;
338 item.lastUsed = DateTime.Now;
339
327 Expire(true); 340 Expire(true);
328 return null;
329 } 341 }
330 342
331 item.hits++;
332 item.lastUsed = DateTime.Now;
333
334 Expire(true);
335
336 return item; 343 return item;
337 } 344 }
338 345
@@ -385,7 +392,10 @@ namespace OpenSim.Framework
385 // 392 //
386 public Object Find(Predicate<CacheItemBase> d) 393 public Object Find(Predicate<CacheItemBase> d)
387 { 394 {
388 CacheItemBase item = m_Index.Find(d); 395 CacheItemBase item;
396
397 lock (m_Index)
398 item = m_Index.Find(d);
389 399
390 if (item == null) 400 if (item == null)
391 return null; 401 return null;
@@ -419,12 +429,12 @@ namespace OpenSim.Framework
419 public virtual void Store(string index, Object data, Type container, 429 public virtual void Store(string index, Object data, Type container,
420 Object[] parameters) 430 Object[] parameters)
421 { 431 {
422 Expire(false);
423
424 CacheItemBase item; 432 CacheItemBase item;
425 433
426 lock (m_Index) 434 lock (m_Index)
427 { 435 {
436 Expire(false);
437
428 if (m_Index.Contains(new CacheItemBase(index))) 438 if (m_Index.Contains(new CacheItemBase(index)))
429 { 439 {
430 if ((m_Flags & CacheFlags.AllowUpdate) != 0) 440 if ((m_Flags & CacheFlags.AllowUpdate) != 0)
@@ -450,9 +460,17 @@ namespace OpenSim.Framework
450 m_Index.Add(item); 460 m_Index.Add(item);
451 m_Lookup[index] = item; 461 m_Lookup[index] = item;
452 } 462 }
463
453 item.Store(data); 464 item.Store(data);
454 } 465 }
455 466
467 /// <summary>
468 /// Expire items as appropriate.
469 /// </summary>
470 /// <remarks>
471 /// Callers must lock m_Index.
472 /// </remarks>
473 /// <param name='getting'></param>
456 protected virtual void Expire(bool getting) 474 protected virtual void Expire(bool getting)
457 { 475 {
458 if (getting && (m_Strategy == CacheStrategy.Aggressive)) 476 if (getting && (m_Strategy == CacheStrategy.Aggressive))
@@ -475,12 +493,10 @@ namespace OpenSim.Framework
475 493
476 switch (m_Strategy) 494 switch (m_Strategy)
477 { 495 {
478 case CacheStrategy.Aggressive: 496 case CacheStrategy.Aggressive:
479 if (Count < Size) 497 if (Count < Size)
480 return; 498 return;
481 499
482 lock (m_Index)
483 {
484 m_Index.Sort(new SortLRU()); 500 m_Index.Sort(new SortLRU());
485 m_Index.Reverse(); 501 m_Index.Reverse();
486 502
@@ -490,7 +506,7 @@ namespace OpenSim.Framework
490 506
491 ExpireDelegate doExpire = OnExpire; 507 ExpireDelegate doExpire = OnExpire;
492 508
493 if (doExpire != null) 509 if (doExpire != null)
494 { 510 {
495 List<CacheItemBase> candidates = 511 List<CacheItemBase> candidates =
496 m_Index.GetRange(target, Count - target); 512 m_Index.GetRange(target, Count - target);
@@ -513,27 +529,34 @@ namespace OpenSim.Framework
513 foreach (CacheItemBase item in m_Index) 529 foreach (CacheItemBase item in m_Index)
514 m_Lookup[item.uuid] = item; 530 m_Lookup[item.uuid] = item;
515 } 531 }
516 } 532
517 break; 533 break;
518 default: 534
519 break; 535 default:
536 break;
520 } 537 }
521 } 538 }
522 539
523 public void Invalidate(string uuid) 540 public void Invalidate(string uuid)
524 { 541 {
525 if (!m_Lookup.ContainsKey(uuid)) 542 lock (m_Index)
526 return; 543 {
544 if (!m_Lookup.ContainsKey(uuid))
545 return;
527 546
528 CacheItemBase item = m_Lookup[uuid]; 547 CacheItemBase item = m_Lookup[uuid];
529 m_Lookup.Remove(uuid); 548 m_Lookup.Remove(uuid);
530 m_Index.Remove(item); 549 m_Index.Remove(item);
550 }
531 } 551 }
532 552
533 public void Clear() 553 public void Clear()
534 { 554 {
535 m_Index.Clear(); 555 lock (m_Index)
536 m_Lookup.Clear(); 556 {
557 m_Index.Clear();
558 m_Lookup.Clear();
559 }
537 } 560 }
538 } 561 }
539} 562} \ No newline at end of file
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 6be2bd7..91f36a5 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -1046,8 +1046,21 @@ namespace OpenSim.Framework
1046 1046
1047 void InPacket(object NewPack); 1047 void InPacket(object NewPack);
1048 void ProcessInPacket(Packet NewPack); 1048 void ProcessInPacket(Packet NewPack);
1049
1050 /// <summary>
1051 /// Close this client
1052 /// </summary>
1049 void Close(); 1053 void Close();
1050 void Close(bool sendStop); 1054
1055 /// <summary>
1056 /// Close this client
1057 /// </summary>
1058 /// <param name='force'>
1059 /// If true, attempts the close without checking active status. You do not want to try this except as a last
1060 /// ditch attempt where Active == false but the ScenePresence still exists.
1061 /// </param>
1062 void Close(bool sendStop, bool force);
1063
1051 void Kick(string message); 1064 void Kick(string message);
1052 1065
1053 /// <summary> 1066 /// <summary>
diff --git a/OpenSim/Framework/Monitoring/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs
index b709baa..eaddb8c 100644
--- a/OpenSim/Framework/Monitoring/Watchdog.cs
+++ b/OpenSim/Framework/Monitoring/Watchdog.cs
@@ -89,6 +89,17 @@ namespace OpenSim.Framework.Monitoring
89 FirstTick = Environment.TickCount & Int32.MaxValue; 89 FirstTick = Environment.TickCount & Int32.MaxValue;
90 LastTick = FirstTick; 90 LastTick = FirstTick;
91 } 91 }
92
93 public ThreadWatchdogInfo(ThreadWatchdogInfo previousTwi)
94 {
95 Thread = previousTwi.Thread;
96 FirstTick = previousTwi.FirstTick;
97 LastTick = previousTwi.LastTick;
98 Timeout = previousTwi.Timeout;
99 IsTimedOut = previousTwi.IsTimedOut;
100 AlarmIfTimeout = previousTwi.AlarmIfTimeout;
101 AlarmMethod = previousTwi.AlarmMethod;
102 }
92 } 103 }
93 104
94 /// <summary> 105 /// <summary>
@@ -335,7 +346,9 @@ namespace OpenSim.Framework.Monitoring
335 if (callbackInfos == null) 346 if (callbackInfos == null)
336 callbackInfos = new List<ThreadWatchdogInfo>(); 347 callbackInfos = new List<ThreadWatchdogInfo>();
337 348
338 callbackInfos.Add(threadInfo); 349 // Send a copy of the watchdog info to prevent race conditions where the watchdog
350 // thread updates the monitoring info after an alarm has been sent out.
351 callbackInfos.Add(new ThreadWatchdogInfo(threadInfo));
339 } 352 }
340 } 353 }
341 } 354 }
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs
index 4bde7be..fcf1896 100644
--- a/OpenSim/Framework/RegionInfo.cs
+++ b/OpenSim/Framework/RegionInfo.cs
@@ -122,7 +122,9 @@ namespace OpenSim.Framework
122 public UUID lastMapUUID = UUID.Zero; 122 public UUID lastMapUUID = UUID.Zero;
123 public string lastMapRefresh = "0"; 123 public string lastMapRefresh = "0";
124 124
125 private float m_nonphysPrimMin = 0;
125 private int m_nonphysPrimMax = 0; 126 private int m_nonphysPrimMax = 0;
127 private float m_physPrimMin = 0;
126 private int m_physPrimMax = 0; 128 private int m_physPrimMax = 0;
127 private bool m_clampPrimSize = false; 129 private bool m_clampPrimSize = false;
128 private int m_objectCapacity = 0; 130 private int m_objectCapacity = 0;
@@ -287,11 +289,21 @@ namespace OpenSim.Framework
287 set { m_windlight = value; } 289 set { m_windlight = value; }
288 } 290 }
289 291
292 public float NonphysPrimMin
293 {
294 get { return m_nonphysPrimMin; }
295 }
296
290 public int NonphysPrimMax 297 public int NonphysPrimMax
291 { 298 {
292 get { return m_nonphysPrimMax; } 299 get { return m_nonphysPrimMax; }
293 } 300 }
294 301
302 public float PhysPrimMin
303 {
304 get { return m_physPrimMin; }
305 }
306
295 public int PhysPrimMax 307 public int PhysPrimMax
296 { 308 {
297 get { return m_physPrimMax; } 309 get { return m_physPrimMax; }
@@ -625,16 +637,28 @@ namespace OpenSim.Framework
625 m_regionType = config.GetString("RegionType", String.Empty); 637 m_regionType = config.GetString("RegionType", String.Empty);
626 allKeys.Remove("RegionType"); 638 allKeys.Remove("RegionType");
627 639
628 // Prim stuff 640 #region Prim stuff
629 // 641
642 m_nonphysPrimMin = config.GetFloat("NonphysicalPrimMin", 0);
643 allKeys.Remove("NonphysicalPrimMin");
644
630 m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 0); 645 m_nonphysPrimMax = config.GetInt("NonphysicalPrimMax", 0);
631 allKeys.Remove("NonphysicalPrimMax"); 646 allKeys.Remove("NonphysicalPrimMax");
647
648 m_physPrimMin = config.GetFloat("PhysicalPrimMin", 0);
649 allKeys.Remove("PhysicalPrimMin");
650
632 m_physPrimMax = config.GetInt("PhysicalPrimMax", 0); 651 m_physPrimMax = config.GetInt("PhysicalPrimMax", 0);
633 allKeys.Remove("PhysicalPrimMax"); 652 allKeys.Remove("PhysicalPrimMax");
653
634 m_clampPrimSize = config.GetBoolean("ClampPrimSize", false); 654 m_clampPrimSize = config.GetBoolean("ClampPrimSize", false);
635 allKeys.Remove("ClampPrimSize"); 655 allKeys.Remove("ClampPrimSize");
656
636 m_objectCapacity = config.GetInt("MaxPrims", 15000); 657 m_objectCapacity = config.GetInt("MaxPrims", 15000);
637 allKeys.Remove("MaxPrims"); 658 allKeys.Remove("MaxPrims");
659
660 #endregion
661
638 m_agentCapacity = config.GetInt("MaxAgents", 100); 662 m_agentCapacity = config.GetInt("MaxAgents", 100);
639 allKeys.Remove("MaxAgents"); 663 allKeys.Remove("MaxAgents");
640 664
@@ -673,10 +697,18 @@ namespace OpenSim.Framework
673 697
674 config.Set("ExternalHostName", m_externalHostName); 698 config.Set("ExternalHostName", m_externalHostName);
675 699
700 if (m_nonphysPrimMin != 0)
701 config.Set("NonphysicalPrimMax", m_nonphysPrimMin);
702
676 if (m_nonphysPrimMax != 0) 703 if (m_nonphysPrimMax != 0)
677 config.Set("NonphysicalPrimMax", m_nonphysPrimMax); 704 config.Set("NonphysicalPrimMax", m_nonphysPrimMax);
705
706 if (m_physPrimMin != 0)
707 config.Set("PhysicalPrimMax", m_physPrimMin);
708
678 if (m_physPrimMax != 0) 709 if (m_physPrimMax != 0)
679 config.Set("PhysicalPrimMax", m_physPrimMax); 710 config.Set("PhysicalPrimMax", m_physPrimMax);
711
680 config.Set("ClampPrimSize", m_clampPrimSize.ToString()); 712 config.Set("ClampPrimSize", m_clampPrimSize.ToString());
681 713
682 if (m_objectCapacity != 0) 714 if (m_objectCapacity != 0)
@@ -759,9 +791,15 @@ namespace OpenSim.Framework
759 configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY, 791 configMember.addConfigurationOption("lastmap_refresh", ConfigurationOption.ConfigurationTypes.TYPE_STRING_NOT_EMPTY,
760 "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true); 792 "Last Map Refresh", Util.UnixTimeSinceEpoch().ToString(), true);
761 793
794 configMember.addConfigurationOption("nonphysical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT,
795 "Minimum size for nonphysical prims", m_nonphysPrimMin.ToString(), true);
796
762 configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, 797 configMember.addConfigurationOption("nonphysical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
763 "Maximum size for nonphysical prims", m_nonphysPrimMax.ToString(), true); 798 "Maximum size for nonphysical prims", m_nonphysPrimMax.ToString(), true);
764 799
800 configMember.addConfigurationOption("physical_prim_min", ConfigurationOption.ConfigurationTypes.TYPE_FLOAT,
801 "Minimum size for nonphysical prims", m_physPrimMin.ToString(), true);
802
765 configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32, 803 configMember.addConfigurationOption("physical_prim_max", ConfigurationOption.ConfigurationTypes.TYPE_INT32,
766 "Maximum size for physical prims", m_physPrimMax.ToString(), true); 804 "Maximum size for physical prims", m_physPrimMax.ToString(), true);
767 805
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index 384f716..1a383ae 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -862,6 +862,12 @@ namespace OpenSim.Framework
862 return Math.Min(Math.Max(x, min), max); 862 return Math.Min(Math.Max(x, min), max);
863 } 863 }
864 864
865 public static Vector3 Clip(Vector3 vec, float min, float max)
866 {
867 return new Vector3(Clip(vec.X, min, max), Clip(vec.Y, min, max),
868 Clip(vec.Z, min, max));
869 }
870
865 /// <summary> 871 /// <summary>
866 /// Convert an UUID to a raw uuid string. Right now this is a string without hyphens. 872 /// Convert an UUID to a raw uuid string. Right now this is a string without hyphens.
867 /// </summary> 873 /// </summary>
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs
index 6255515..9c7598a 100644
--- a/OpenSim/Region/Application/OpenSim.cs
+++ b/OpenSim/Region/Application/OpenSim.cs
@@ -35,6 +35,7 @@ using System.Text;
35using System.Text.RegularExpressions; 35using System.Text.RegularExpressions;
36using System.Timers; 36using System.Timers;
37using log4net; 37using log4net;
38using NDesk.Options;
38using Nini.Config; 39using Nini.Config;
39using OpenMetaverse; 40using OpenMetaverse;
40using OpenSim.Framework; 41using OpenSim.Framework;
@@ -310,8 +311,11 @@ namespace OpenSim
310 "Change the scale of a named prim", HandleEditScale); 311 "Change the scale of a named prim", HandleEditScale);
311 312
312 m_console.Commands.AddCommand("Users", false, "kick user", 313 m_console.Commands.AddCommand("Users", false, "kick user",
313 "kick user <first> <last> [message]", 314 "kick user <first> <last> [--force] [message]",
314 "Kick a user off the simulator", KickUserCommand); 315 "Kick a user off the simulator",
316 "The --force option will kick the user without any checks to see whether it's already in the process of closing\n"
317 + "Only use this option if you are sure the avatar is inactive and a normal kick user operation does not removed them",
318 KickUserCommand);
315 319
316 m_console.Commands.AddCommand("Users", false, "show users", 320 m_console.Commands.AddCommand("Users", false, "show users",
317 "show users [full]", 321 "show users [full]",
@@ -416,6 +420,7 @@ namespace OpenSim
416 { 420 {
417 RunCommandScript(m_shutdownCommandsFile); 421 RunCommandScript(m_shutdownCommandsFile);
418 } 422 }
423
419 base.ShutdownSpecific(); 424 base.ShutdownSpecific();
420 } 425 }
421 426
@@ -453,11 +458,17 @@ namespace OpenSim
453 /// <param name="cmdparams">name of avatar to kick</param> 458 /// <param name="cmdparams">name of avatar to kick</param>
454 private void KickUserCommand(string module, string[] cmdparams) 459 private void KickUserCommand(string module, string[] cmdparams)
455 { 460 {
456 if (cmdparams.Length < 4) 461 bool force = false;
462
463 OptionSet options = new OptionSet().Add("f|force", delegate (string v) { force = v != null; });
464
465 List<string> mainParams = options.Parse(cmdparams);
466
467 if (mainParams.Count < 4)
457 return; 468 return;
458 469
459 string alert = null; 470 string alert = null;
460 if (cmdparams.Length > 4) 471 if (mainParams.Count > 4)
461 alert = String.Format("\n{0}\n", String.Join(" ", cmdparams, 4, cmdparams.Length - 4)); 472 alert = String.Format("\n{0}\n", String.Join(" ", cmdparams, 4, cmdparams.Length - 4));
462 473
463 IList agents = SceneManager.GetCurrentSceneAvatars(); 474 IList agents = SceneManager.GetCurrentSceneAvatars();
@@ -466,8 +477,8 @@ namespace OpenSim
466 { 477 {
467 RegionInfo regionInfo = presence.Scene.RegionInfo; 478 RegionInfo regionInfo = presence.Scene.RegionInfo;
468 479
469 if (presence.Firstname.ToLower().Contains(cmdparams[2].ToLower()) && 480 if (presence.Firstname.ToLower().Contains(mainParams[2].ToLower()) &&
470 presence.Lastname.ToLower().Contains(cmdparams[3].ToLower())) 481 presence.Lastname.ToLower().Contains(mainParams[3].ToLower()))
471 { 482 {
472 MainConsole.Instance.Output( 483 MainConsole.Instance.Output(
473 String.Format( 484 String.Format(
@@ -480,7 +491,7 @@ namespace OpenSim
480 else 491 else
481 presence.ControllingClient.Kick("\nYou have been logged out by an administrator.\n"); 492 presence.ControllingClient.Kick("\nYou have been logged out by an administrator.\n");
482 493
483 presence.Scene.IncomingCloseAgent(presence.UUID); 494 presence.Scene.IncomingCloseAgent(presence.UUID, force);
484 } 495 }
485 } 496 }
486 497
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs
index cd70410..d604cf6 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs
@@ -94,7 +94,7 @@ namespace OpenSim.Region.ClientStack.Linden.Tests
94 UUID spId = TestHelpers.ParseTail(0x1); 94 UUID spId = TestHelpers.ParseTail(0x1);
95 95
96 SceneHelpers.AddScenePresence(m_scene, spId); 96 SceneHelpers.AddScenePresence(m_scene, spId);
97 m_scene.IncomingCloseAgent(spId); 97 m_scene.IncomingCloseAgent(spId, false);
98 98
99 // TODO: Add more assertions for the other aspects of event queues 99 // TODO: Add more assertions for the other aspects of event queues
100 Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0)); 100 Assert.That(MainServer.Instance.GetPollServiceHandlerKeys().Count, Is.EqualTo(0));
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index ddd8f18..2dcc9cb 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -509,19 +509,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
509 /// </summary> 509 /// </summary>
510 public void Close() 510 public void Close()
511 { 511 {
512 Close(true); 512 Close(true, false);
513 } 513 }
514 514
515 /// <summary> 515 public void Close(bool sendStop, bool force)
516 /// Shut down the client view
517 /// </summary>
518 public void Close(bool sendStop)
519 { 516 {
520 // We lock here to prevent race conditions between two threads calling close simultaneously (e.g. 517 // We lock here to prevent race conditions between two threads calling close simultaneously (e.g.
521 // a simultaneous relog just as a client is being closed out due to no packet ack from the old connection. 518 // a simultaneous relog just as a client is being closed out due to no packet ack from the old connection.
522 lock (CloseSyncLock) 519 lock (CloseSyncLock)
523 { 520 {
524 if (!IsActive) 521 // We still perform a force close inside the sync lock since this is intended to attempt close where
522 // there is some unidentified connection problem, not where we have issues due to deadlock
523 if (!IsActive && !force)
525 return; 524 return;
526 525
527 IsActive = false; 526 IsActive = false;
@@ -12140,7 +12139,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12140 { 12139 {
12141 Kick(reason); 12140 Kick(reason);
12142 Thread.Sleep(1000); 12141 Thread.Sleep(1000);
12143 Close(); 12142 Disconnect();
12144 } 12143 }
12145 12144
12146 public void Disconnect() 12145 public void Disconnect()
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
index 7042c9a..fb73e1d 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs
@@ -1515,7 +1515,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1515 if (!client.IsLoggingOut) 1515 if (!client.IsLoggingOut)
1516 { 1516 {
1517 client.IsLoggingOut = true; 1517 client.IsLoggingOut = true;
1518 client.Close(false); 1518 client.Close(false, false);
1519 } 1519 }
1520 } 1520 }
1521 } 1521 }
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
index d9a619d..48f3a23 100644
--- a/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Avatar/Attachments/Tests/AttachmentsModuleTests.cs
@@ -461,7 +461,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
461 461
462 SceneObjectGroup rezzedAtt = presence.GetAttachments()[0]; 462 SceneObjectGroup rezzedAtt = presence.GetAttachments()[0];
463 463
464 scene.IncomingCloseAgent(presence.UUID); 464 scene.IncomingCloseAgent(presence.UUID, false);
465 465
466 // Check that we can't retrieve this attachment from the scene. 466 // Check that we can't retrieve this attachment from the scene.
467 Assert.That(scene.GetSceneObjectGroup(rezzedAtt.UUID), Is.Null); 467 Assert.That(scene.GetSceneObjectGroup(rezzedAtt.UUID), Is.Null);
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 560f807..c248f95 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -644,7 +644,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
644 // an agent cannot teleport back to this region if it has teleported away. 644 // an agent cannot teleport back to this region if it has teleported away.
645 Thread.Sleep(2000); 645 Thread.Sleep(2000);
646 646
647 sp.Scene.IncomingCloseAgent(sp.UUID); 647 sp.Scene.IncomingCloseAgent(sp.UUID, false);
648 } 648 }
649 else 649 else
650 { 650 {
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
index 8b2f2f8..05eaaec 100644
--- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
+++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs
@@ -308,36 +308,44 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
308 308
309 try 309 try
310 { 310 {
311 if (alpha == 256) 311 // XXX: In testing, it appears that if multiple threads dispose of separate GDI+ objects simultaneously,
312 bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb); 312 // the native malloc heap can become corrupted, possibly due to a double free(). This may be due to
313 else 313 // bugs in the underlying libcairo used by mono's libgdiplus.dll on Linux/OSX. These problems were
314 bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb); 314 // seen with both libcario 1.10.2-6.1ubuntu3 and 1.8.10-2ubuntu1. They go away if disposal is perfomed
315 315 // under lock.
316 graph = Graphics.FromImage(bitmap); 316 lock (this)
317
318 // this is really just to save people filling the
319 // background color in their scripts, only do when fully opaque
320 if (alpha >= 255)
321 { 317 {
322 using (SolidBrush bgFillBrush = new SolidBrush(bgColor)) 318 if (alpha == 256)
319 bitmap = new Bitmap(width, height, PixelFormat.Format32bppRgb);
320 else
321 bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
322
323 graph = Graphics.FromImage(bitmap);
324
325 // this is really just to save people filling the
326 // background color in their scripts, only do when fully opaque
327 if (alpha >= 255)
323 { 328 {
324 graph.FillRectangle(bgFillBrush, 0, 0, width, height); 329 using (SolidBrush bgFillBrush = new SolidBrush(bgColor))
330 {
331 graph.FillRectangle(bgFillBrush, 0, 0, width, height);
332 }
325 } 333 }
326 } 334
327 335 for (int w = 0; w < bitmap.Width; w++)
328 for (int w = 0; w < bitmap.Width; w++)
329 {
330 if (alpha <= 255)
331 { 336 {
332 for (int h = 0; h < bitmap.Height; h++) 337 if (alpha <= 255)
333 { 338 {
334 bitmap.SetPixel(w, h, Color.FromArgb(alpha, bitmap.GetPixel(w, h))); 339 for (int h = 0; h < bitmap.Height; h++)
340 {
341 bitmap.SetPixel(w, h, Color.FromArgb(alpha, bitmap.GetPixel(w, h)));
342 }
335 } 343 }
336 } 344 }
345
346 GDIDraw(data, graph, altDataDelim);
337 } 347 }
338 348
339 GDIDraw(data, graph, altDataDelim);
340
341 byte[] imageJ2000 = new byte[0]; 349 byte[] imageJ2000 = new byte[0];
342 350
343 try 351 try
@@ -355,11 +363,19 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
355 } 363 }
356 finally 364 finally
357 { 365 {
358 if (graph != null) 366 // XXX: In testing, it appears that if multiple threads dispose of separate GDI+ objects simultaneously,
359 graph.Dispose(); 367 // the native malloc heap can become corrupted, possibly due to a double free(). This may be due to
360 368 // bugs in the underlying libcairo used by mono's libgdiplus.dll on Linux/OSX. These problems were
361 if (bitmap != null) 369 // seen with both libcario 1.10.2-6.1ubuntu3 and 1.8.10-2ubuntu1. They go away if disposal is perfomed
362 bitmap.Dispose(); 370 // under lock.
371 lock (this)
372 {
373 if (graph != null)
374 graph.Dispose();
375
376 if (bitmap != null)
377 bitmap.Dispose();
378 }
363 } 379 }
364 } 380 }
365 381
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
index 6eb99ea..8ed1833 100644
--- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
+++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs
@@ -313,7 +313,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation
313 313
314 if (m_scenes.ContainsKey(destination.RegionID)) 314 if (m_scenes.ContainsKey(destination.RegionID))
315 { 315 {
316 Util.FireAndForget(delegate { m_scenes[destination.RegionID].IncomingCloseAgent(id); }); 316// m_log.DebugFormat(
317// "[LOCAL SIMULATION CONNECTOR]: Found region {0} {1} to send AgentUpdate",
318// s.RegionInfo.RegionName, destination.RegionHandle);
319
320 Util.FireAndForget(delegate { m_scenes[destination.RegionID].IncomingCloseAgent(id, false); });
317 return true; 321 return true;
318 } 322 }
319 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent"); 323 //m_log.Debug("[LOCAL COMMS]: region not found in SendCloseAgent");
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
index 619550c..142567b 100644
--- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
+++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs
@@ -97,6 +97,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver
97 } 97 }
98 } 98 }
99 99
100 /// <summary>
101 /// Used to cache lookups for valid groups.
102 /// </summary>
103 private IDictionary<UUID, bool> m_validGroupUuids = new Dictionary<UUID, bool>();
104
105 private IGroupsModule m_groupsModule;
106
100 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId) 107 public ArchiveReadRequest(Scene scene, string loadPath, bool merge, bool skipAssets, Guid requestId)
101 { 108 {
102 m_scene = scene; 109 m_scene = scene;
@@ -120,6 +127,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
120 127
121 // Zero can never be a valid user id 128 // Zero can never be a valid user id
122 m_validUserUuids[UUID.Zero] = false; 129 m_validUserUuids[UUID.Zero] = false;
130
131 m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
123 } 132 }
124 133
125 public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId) 134 public ArchiveReadRequest(Scene scene, Stream loadStream, bool merge, bool skipAssets, Guid requestId)
@@ -132,6 +141,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver
132 141
133 // Zero can never be a valid user id 142 // Zero can never be a valid user id
134 m_validUserUuids[UUID.Zero] = false; 143 m_validUserUuids[UUID.Zero] = false;
144
145 m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>();
135 } 146 }
136 147
137 /// <summary> 148 /// <summary>
@@ -302,6 +313,9 @@ namespace OpenSim.Region.CoreModules.World.Archiver
302 if (!ResolveUserUuid(part.LastOwnerID)) 313 if (!ResolveUserUuid(part.LastOwnerID))
303 part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 314 part.LastOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
304 315
316 if (!ResolveGroupUuid(part.GroupID))
317 part.GroupID = UUID.Zero;
318
305 // And zap any troublesome sit target information 319 // And zap any troublesome sit target information
306// part.SitTargetOrientation = new Quaternion(0, 0, 0, 1); 320// part.SitTargetOrientation = new Quaternion(0, 0, 0, 1);
307// part.SitTargetPosition = new Vector3(0, 0, 0); 321// part.SitTargetPosition = new Vector3(0, 0, 0);
@@ -335,13 +349,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver
335 { 349 {
336 kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 350 kvp.Value.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
337 } 351 }
352
338 if (kvp.Value.CreatorData == null || kvp.Value.CreatorData == string.Empty) 353 if (kvp.Value.CreatorData == null || kvp.Value.CreatorData == string.Empty)
339 { 354 {
340 if (!ResolveUserUuid(kvp.Value.CreatorID)) 355 if (!ResolveUserUuid(kvp.Value.CreatorID))
341 kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner; 356 kvp.Value.CreatorID = m_scene.RegionInfo.EstateSettings.EstateOwner;
342 } 357 }
358
343 if (UserManager != null) 359 if (UserManager != null)
344 UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData); 360 UserManager.AddUser(kvp.Value.CreatorID, kvp.Value.CreatorData);
361
362 if (!ResolveGroupUuid(kvp.Value.GroupID))
363 kvp.Value.GroupID = UUID.Zero;
345 } 364 }
346 part.TaskInventory.LockItemsForRead(false); 365 part.TaskInventory.LockItemsForRead(false);
347 } 366 }
@@ -382,9 +401,27 @@ namespace OpenSim.Region.CoreModules.World.Archiver
382 foreach (string serialisedParcel in serialisedParcels) 401 foreach (string serialisedParcel in serialisedParcels)
383 { 402 {
384 LandData parcel = LandDataSerializer.Deserialize(serialisedParcel); 403 LandData parcel = LandDataSerializer.Deserialize(serialisedParcel);
404
405 // Validate User and Group UUID's
406
385 if (!ResolveUserUuid(parcel.OwnerID)) 407 if (!ResolveUserUuid(parcel.OwnerID))
386 parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner; 408 parcel.OwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
387 409
410 if (!ResolveGroupUuid(parcel.GroupID))
411 {
412 parcel.GroupID = UUID.Zero;
413 parcel.IsGroupOwned = false;
414 }
415
416 List<LandAccessEntry> accessList = new List<LandAccessEntry>();
417 foreach (LandAccessEntry entry in parcel.ParcelAccessList)
418 {
419 if (ResolveUserUuid(entry.AgentID))
420 accessList.Add(entry);
421 // else, drop this access rule
422 }
423 parcel.ParcelAccessList = accessList;
424
388// m_log.DebugFormat( 425// m_log.DebugFormat(
389// "[ARCHIVER]: Adding parcel {0}, local id {1}, area {2}", 426// "[ARCHIVER]: Adding parcel {0}, local id {1}, area {2}",
390// parcel.Name, parcel.LocalID, parcel.Area); 427// parcel.Name, parcel.LocalID, parcel.Area);
@@ -419,6 +456,30 @@ namespace OpenSim.Region.CoreModules.World.Archiver
419 } 456 }
420 457
421 /// <summary> 458 /// <summary>
459 /// Look up the given group id to check whether it's one that is valid for this grid.
460 /// </summary>
461 /// <param name="uuid"></param>
462 /// <returns></returns>
463 private bool ResolveGroupUuid(UUID uuid)
464 {
465 if (uuid == UUID.Zero)
466 return true; // this means the object has no group
467
468 if (!m_validGroupUuids.ContainsKey(uuid))
469 {
470 bool exists;
471
472 if (m_groupsModule == null)
473 exists = false;
474 else
475 exists = (m_groupsModule.GetGroupRecord(uuid) != null);
476
477 m_validGroupUuids.Add(uuid, exists);
478 }
479
480 return m_validGroupUuids[uuid];
481 }
482
422 /// Load an asset 483 /// Load an asset
423 /// </summary> 484 /// </summary>
424 /// <param name="assetFilename"></param> 485 /// <param name="assetFilename"></param>
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
index 14c1a39..a2f0950 100644
--- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
@@ -85,13 +85,15 @@ namespace OpenSim.Region.CoreModules.World.Sound
85 dis = 0; 85 dis = 0;
86 } 86 }
87 87
88 float thisSpGain;
89
88 // Scale by distance 90 // Scale by distance
89 if (radius == 0) 91 if (radius == 0)
90 gain = (float)((double)gain * ((100.0 - dis) / 100.0)); 92 thisSpGain = (float)((double)gain * ((100.0 - dis) / 100.0));
91 else 93 else
92 gain = (float)((double)gain * ((radius - dis) / radius)); 94 thisSpGain = (float)((double)gain * ((radius - dis) / radius));
93 95
94 sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags); 96 sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, thisSpGain, flags);
95 }); 97 });
96 } 98 }
97 99
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 57fcf51..2499460 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -103,8 +103,26 @@ namespace OpenSim.Region.Framework.Scenes
103 /// </summary> 103 /// </summary>
104 public bool CollidablePrims { get; private set; } 104 public bool CollidablePrims { get; private set; }
105 105
106 /// <summary>
107 /// Minimum value of the size of a non-physical prim in each axis
108 /// </summary>
109 public float m_minNonphys = 0.01f;
110
111 /// <summary>
112 /// Maximum value of the size of a non-physical prim in each axis
113 /// </summary>
106 public float m_maxNonphys = 256; 114 public float m_maxNonphys = 256;
115
116 /// <summary>
117 /// Minimum value of the size of a physical prim in each axis
118 /// </summary>
119 public float m_minPhys = 0.01f;
120
121 /// <summary>
122 /// Maximum value of the size of a physical prim in each axis
123 /// </summary>
107 public float m_maxPhys = 10; 124 public float m_maxPhys = 10;
125
108 public bool m_clampPrimSize; 126 public bool m_clampPrimSize;
109 public bool m_trustBinaries; 127 public bool m_trustBinaries;
110 public bool m_allowScriptCrossings; 128 public bool m_allowScriptCrossings;
@@ -746,12 +764,24 @@ namespace OpenSim.Region.Framework.Scenes
746 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true); 764 PhysicalPrims = startupConfig.GetBoolean("physical_prim", true);
747 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true); 765 CollidablePrims = startupConfig.GetBoolean("collidable_prim", true);
748 766
767 m_minNonphys = startupConfig.GetFloat("NonphysicalPrimMin", m_minNonphys);
768 if (RegionInfo.NonphysPrimMin > 0)
769 {
770 m_minNonphys = RegionInfo.NonphysPrimMin;
771 }
772
749 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys); 773 m_maxNonphys = startupConfig.GetFloat("NonphysicalPrimMax", m_maxNonphys);
750 if (RegionInfo.NonphysPrimMax > 0) 774 if (RegionInfo.NonphysPrimMax > 0)
751 { 775 {
752 m_maxNonphys = RegionInfo.NonphysPrimMax; 776 m_maxNonphys = RegionInfo.NonphysPrimMax;
753 } 777 }
754 778
779 m_minPhys = startupConfig.GetFloat("PhysicalPrimMin", m_minPhys);
780 if (RegionInfo.PhysPrimMin > 0)
781 {
782 m_minPhys = RegionInfo.PhysPrimMin;
783 }
784
755 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys); 785 m_maxPhys = startupConfig.GetFloat("PhysicalPrimMax", m_maxPhys);
756 786
757 if (RegionInfo.PhysPrimMax > 0) 787 if (RegionInfo.PhysPrimMax > 0)
@@ -4310,15 +4340,18 @@ namespace OpenSim.Region.Framework.Scenes
4310 /// Tell a single agent to disconnect from the region. 4340 /// Tell a single agent to disconnect from the region.
4311 /// </summary> 4341 /// </summary>
4312 /// <param name="agentID"></param> 4342 /// <param name="agentID"></param>
4313 /// <param name="childOnly"></param> 4343 /// <param name="force">
4314 public bool IncomingCloseAgent(UUID agentID, bool childOnly) 4344 /// Force the agent to close even if it might be in the middle of some other operation. You do not want to
4345 /// force unless you are absolutely sure that the agent is dead and a normal close is not working.
4346 /// </param>
4347 public bool IncomingCloseAgent(UUID agentID, bool force)
4315 { 4348 {
4316 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID); 4349 //m_log.DebugFormat("[SCENE]: Processing incoming close agent for {0}", agentID);
4317 4350
4318 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID); 4351 ScenePresence presence = m_sceneGraph.GetScenePresence(agentID);
4319 if (presence != null) 4352 if (presence != null)
4320 { 4353 {
4321 presence.ControllingClient.Close(); 4354 presence.ControllingClient.Close(true, force);
4322 return true; 4355 return true;
4323 } 4356 }
4324 4357
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index e29b2c1..fa66858 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -421,12 +421,9 @@ namespace OpenSim.Region.Framework.Scenes
421 { 421 {
422 Vector3 scale = part.Shape.Scale; 422 Vector3 scale = part.Shape.Scale;
423 423
424 if (scale.X > m_parentScene.m_maxNonphys) 424 scale.X = Math.Max(m_parentScene.m_minNonphys, Math.Min(m_parentScene.m_maxNonphys, scale.X));
425 scale.X = m_parentScene.m_maxNonphys; 425 scale.Y = Math.Max(m_parentScene.m_minNonphys, Math.Min(m_parentScene.m_maxNonphys, scale.Y));
426 if (scale.Y > m_parentScene.m_maxNonphys) 426 scale.Z = Math.Max(m_parentScene.m_minNonphys, Math.Min(m_parentScene.m_maxNonphys, scale.Z));
427 scale.Y = m_parentScene.m_maxNonphys;
428 if (scale.Z > m_parentScene.m_maxNonphys)
429 scale.Z = m_parentScene.m_maxNonphys;
430 427
431 part.Shape.Scale = scale; 428 part.Shape.Scale = scale;
432 } 429 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index eee53d7..fcb1571 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -3450,17 +3450,17 @@ namespace OpenSim.Region.Framework.Scenes
3450 /// <param name="scale"></param> 3450 /// <param name="scale"></param>
3451 public void GroupResize(Vector3 scale) 3451 public void GroupResize(Vector3 scale)
3452 { 3452 {
3453 scale.X = Math.Min(scale.X, Scene.m_maxNonphys); 3453 scale.X = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.X));
3454 scale.Y = Math.Min(scale.Y, Scene.m_maxNonphys); 3454 scale.Y = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Y));
3455 scale.Z = Math.Min(scale.Z, Scene.m_maxNonphys); 3455 scale.Z = Math.Max(Scene.m_minNonphys, Math.Min(Scene.m_maxNonphys, scale.Z));
3456 3456
3457 PhysicsActor pa = m_rootPart.PhysActor; 3457 PhysicsActor pa = m_rootPart.PhysActor;
3458 3458
3459 if (pa != null && pa.IsPhysical) 3459 if (pa != null && pa.IsPhysical)
3460 { 3460 {
3461 scale.X = Math.Min(scale.X, Scene.m_maxPhys); 3461 scale.X = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.X));
3462 scale.Y = Math.Min(scale.Y, Scene.m_maxPhys); 3462 scale.Y = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Y));
3463 scale.Z = Math.Min(scale.Z, Scene.m_maxPhys); 3463 scale.Z = Math.Max(Scene.m_minPhys, Math.Min(Scene.m_maxPhys, scale.Z));
3464 } 3464 }
3465 3465
3466 float x = (scale.X / RootPart.Scale.X); 3466 float x = (scale.X / RootPart.Scale.X);
@@ -3491,6 +3491,14 @@ namespace OpenSim.Region.Framework.Scenes
3491 y *= a; 3491 y *= a;
3492 z *= a; 3492 z *= a;
3493 } 3493 }
3494 else if (oldSize.X * x < m_scene.m_minPhys)
3495 {
3496 f = m_scene.m_minPhys / oldSize.X;
3497 a = f / x;
3498 x *= a;
3499 y *= a;
3500 z *= a;
3501 }
3494 3502
3495 if (oldSize.Y * y > m_scene.m_maxPhys) 3503 if (oldSize.Y * y > m_scene.m_maxPhys)
3496 { 3504 {
@@ -3500,6 +3508,14 @@ namespace OpenSim.Region.Framework.Scenes
3500 y *= a; 3508 y *= a;
3501 z *= a; 3509 z *= a;
3502 } 3510 }
3511 else if (oldSize.Y * y < m_scene.m_minPhys)
3512 {
3513 f = m_scene.m_minPhys / oldSize.Y;
3514 a = f / y;
3515 x *= a;
3516 y *= a;
3517 z *= a;
3518 }
3503 3519
3504 if (oldSize.Z * z > m_scene.m_maxPhys) 3520 if (oldSize.Z * z > m_scene.m_maxPhys)
3505 { 3521 {
@@ -3509,6 +3525,14 @@ namespace OpenSim.Region.Framework.Scenes
3509 y *= a; 3525 y *= a;
3510 z *= a; 3526 z *= a;
3511 } 3527 }
3528 else if (oldSize.Z * z < m_scene.m_minPhys)
3529 {
3530 f = m_scene.m_minPhys / oldSize.Z;
3531 a = f / z;
3532 x *= a;
3533 y *= a;
3534 z *= a;
3535 }
3512 } 3536 }
3513 else 3537 else
3514 { 3538 {
@@ -3520,6 +3544,14 @@ namespace OpenSim.Region.Framework.Scenes
3520 y *= a; 3544 y *= a;
3521 z *= a; 3545 z *= a;
3522 } 3546 }
3547 else if (oldSize.X * x < m_scene.m_minNonphys)
3548 {
3549 f = m_scene.m_minNonphys / oldSize.X;
3550 a = f / x;
3551 x *= a;
3552 y *= a;
3553 z *= a;
3554 }
3523 3555
3524 if (oldSize.Y * y > m_scene.m_maxNonphys) 3556 if (oldSize.Y * y > m_scene.m_maxNonphys)
3525 { 3557 {
@@ -3529,6 +3561,14 @@ namespace OpenSim.Region.Framework.Scenes
3529 y *= a; 3561 y *= a;
3530 z *= a; 3562 z *= a;
3531 } 3563 }
3564 else if (oldSize.Y * y < m_scene.m_minNonphys)
3565 {
3566 f = m_scene.m_minNonphys / oldSize.Y;
3567 a = f / y;
3568 x *= a;
3569 y *= a;
3570 z *= a;
3571 }
3532 3572
3533 if (oldSize.Z * z > m_scene.m_maxNonphys) 3573 if (oldSize.Z * z > m_scene.m_maxNonphys)
3534 { 3574 {
@@ -3538,6 +3578,14 @@ namespace OpenSim.Region.Framework.Scenes
3538 y *= a; 3578 y *= a;
3539 z *= a; 3579 z *= a;
3540 } 3580 }
3581 else if (oldSize.Z * z < m_scene.m_minNonphys)
3582 {
3583 f = m_scene.m_minNonphys / oldSize.Z;
3584 a = f / z;
3585 x *= a;
3586 y *= a;
3587 z *= a;
3588 }
3541 } 3589 }
3542 } 3590 }
3543 } 3591 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index ed626d0..4ed3413 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -790,7 +790,7 @@ namespace OpenSim.Region.Framework.Scenes
790 } 790 }
791 catch (Exception e) 791 catch (Exception e)
792 { 792 {
793 m_log.Error("[SCENEOBJECTPART]: GROUP POSITION. " + e.Message); 793 m_log.ErrorFormat("[SCENEOBJECTPART]: GROUP POSITION. {0}", e);
794 } 794 }
795 } 795 }
796 } 796 }
@@ -2969,17 +2969,16 @@ namespace OpenSim.Region.Framework.Scenes
2969 /// <param name="scale"></param> 2969 /// <param name="scale"></param>
2970 public void Resize(Vector3 scale) 2970 public void Resize(Vector3 scale)
2971 { 2971 {
2972 scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxNonphys); 2972 scale.X = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.X));
2973 scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxNonphys); 2973 scale.Y = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Y));
2974 scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxNonphys); 2974 scale.Z = Math.Max(ParentGroup.Scene.m_minNonphys, Math.Min(ParentGroup.Scene.m_maxNonphys, scale.Z));
2975 2975
2976 PhysicsActor pa = PhysActor; 2976 PhysicsActor pa = PhysActor;
2977
2978 if (pa != null && pa.IsPhysical) 2977 if (pa != null && pa.IsPhysical)
2979 { 2978 {
2980 scale.X = Math.Min(scale.X, ParentGroup.Scene.m_maxPhys); 2979 scale.X = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.X));
2981 scale.Y = Math.Min(scale.Y, ParentGroup.Scene.m_maxPhys); 2980 scale.Y = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Y));
2982 scale.Z = Math.Min(scale.Z, ParentGroup.Scene.m_maxPhys); 2981 scale.Z = Math.Max(ParentGroup.Scene.m_minPhys, Math.Min(ParentGroup.Scene.m_maxPhys, scale.Z));
2983 } 2982 }
2984 2983
2985// m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale); 2984// m_log.DebugFormat("[SCENE OBJECT PART]: Resizing {0} {1} to {2}", Name, LocalId, scale);
@@ -3561,23 +3560,32 @@ namespace OpenSim.Region.Framework.Scenes
3561 } 3560 }
3562 3561
3563 /// <summary> 3562 /// <summary>
3564 /// Set the color of prim faces 3563 /// Set the color & alpha of prim faces
3565 /// </summary> 3564 /// </summary>
3566 /// <param name="color"></param>
3567 /// <param name="face"></param> 3565 /// <param name="face"></param>
3568 public void SetFaceColor(Vector3 color, int face) 3566 /// <param name="color"></param>
3567 /// <param name="alpha"></param>
3568 public void SetFaceColorAlpha(int face, Vector3 color, double ?alpha)
3569 { 3569 {
3570 Vector3 clippedColor = Util.Clip(color, 0.0f, 1.0f);
3571 float clippedAlpha = alpha.HasValue ?
3572 Util.Clip((float)alpha.Value, 0.0f, 1.0f) : 0;
3573
3570 // The only way to get a deep copy/ If we don't do this, we can 3574 // The only way to get a deep copy/ If we don't do this, we can
3571 // mever detect color changes further down. 3575 // never detect color changes further down.
3572 Byte[] buf = Shape.Textures.GetBytes(); 3576 Byte[] buf = Shape.Textures.GetBytes();
3573 Primitive.TextureEntry tex = new Primitive.TextureEntry(buf, 0, buf.Length); 3577 Primitive.TextureEntry tex = new Primitive.TextureEntry(buf, 0, buf.Length);
3574 Color4 texcolor; 3578 Color4 texcolor;
3575 if (face >= 0 && face < GetNumberOfSides()) 3579 if (face >= 0 && face < GetNumberOfSides())
3576 { 3580 {
3577 texcolor = tex.CreateFace((uint)face).RGBA; 3581 texcolor = tex.CreateFace((uint)face).RGBA;
3578 texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); 3582 texcolor.R = clippedColor.X;
3579 texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); 3583 texcolor.G = clippedColor.Y;
3580 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); 3584 texcolor.B = clippedColor.Z;
3585 if (alpha.HasValue)
3586 {
3587 texcolor.A = clippedAlpha;
3588 }
3581 tex.FaceTextures[face].RGBA = texcolor; 3589 tex.FaceTextures[face].RGBA = texcolor;
3582 UpdateTextureEntry(tex.GetBytes()); 3590 UpdateTextureEntry(tex.GetBytes());
3583 return; 3591 return;
@@ -3589,15 +3597,23 @@ namespace OpenSim.Region.Framework.Scenes
3589 if (tex.FaceTextures[i] != null) 3597 if (tex.FaceTextures[i] != null)
3590 { 3598 {
3591 texcolor = tex.FaceTextures[i].RGBA; 3599 texcolor = tex.FaceTextures[i].RGBA;
3592 texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); 3600 texcolor.R = clippedColor.X;
3593 texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); 3601 texcolor.G = clippedColor.Y;
3594 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); 3602 texcolor.B = clippedColor.Z;
3603 if (alpha.HasValue)
3604 {
3605 texcolor.A = clippedAlpha;
3606 }
3595 tex.FaceTextures[i].RGBA = texcolor; 3607 tex.FaceTextures[i].RGBA = texcolor;
3596 } 3608 }
3597 texcolor = tex.DefaultTexture.RGBA; 3609 texcolor = tex.DefaultTexture.RGBA;
3598 texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); 3610 texcolor.R = clippedColor.X;
3599 texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); 3611 texcolor.G = clippedColor.Y;
3600 texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); 3612 texcolor.B = clippedColor.Z;
3613 if (alpha.HasValue)
3614 {
3615 texcolor.A = clippedAlpha;
3616 }
3601 tex.DefaultTexture.RGBA = texcolor; 3617 tex.DefaultTexture.RGBA = texcolor;
3602 } 3618 }
3603 UpdateTextureEntry(tex.GetBytes()); 3619 UpdateTextureEntry(tex.GetBytes());
@@ -4885,6 +4901,57 @@ namespace OpenSim.Region.Framework.Scenes
4885 ScheduleFullUpdate(); 4901 ScheduleFullUpdate();
4886 } 4902 }
4887 4903
4904 public void UpdateSlice(float begin, float end)
4905 {
4906 if (end < begin)
4907 {
4908 float temp = begin;
4909 begin = end;
4910 end = temp;
4911 }
4912 end = Math.Min(1f, Math.Max(0f, end));
4913 begin = Math.Min(Math.Min(1f, Math.Max(0f, begin)), end - 0.02f);
4914 if (begin < 0.02f && end < 0.02f)
4915 {
4916 begin = 0f;
4917 end = 0.02f;
4918 }
4919
4920 ushort uBegin = (ushort)(50000.0 * begin);
4921 ushort uEnd = (ushort)(50000.0 * (1f - end));
4922 bool updatePossiblyNeeded = false;
4923 PrimType primType = GetPrimType();
4924 if (primType == PrimType.SPHERE || primType == PrimType.TORUS || primType == PrimType.TUBE || primType == PrimType.RING)
4925 {
4926 if (m_shape.ProfileBegin != uBegin || m_shape.ProfileEnd != uEnd)
4927 {
4928 m_shape.ProfileBegin = uBegin;
4929 m_shape.ProfileEnd = uEnd;
4930 updatePossiblyNeeded = true;
4931 }
4932 }
4933 else if (m_shape.PathBegin != uBegin || m_shape.PathEnd != uEnd)
4934 {
4935 m_shape.PathBegin = uBegin;
4936 m_shape.PathEnd = uEnd;
4937 updatePossiblyNeeded = true;
4938 }
4939
4940 if (updatePossiblyNeeded && ParentGroup != null)
4941 {
4942 ParentGroup.HasGroupChanged = true;
4943 }
4944 if (updatePossiblyNeeded && PhysActor != null)
4945 {
4946 PhysActor.Shape = m_shape;
4947 ParentGroup.Scene.PhysicsScene.AddPhysicsActorTaint(PhysActor);
4948 }
4949 if (updatePossiblyNeeded)
4950 {
4951 ScheduleFullUpdate();
4952 }
4953 }
4954
4888 /// <summary> 4955 /// <summary>
4889 /// If the part is a sculpt/mesh, retrieve the mesh data and reinsert it into the shape so that the physics 4956 /// If the part is a sculpt/mesh, retrieve the mesh data and reinsert it into the shape so that the physics
4890 /// engine can use it. 4957 /// engine can use it.
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 47b2ead..cfd4a51 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1527,17 +1527,22 @@ namespace OpenSim.Region.Framework.Scenes
1527 bool DCFlagKeyPressed = false; 1527 bool DCFlagKeyPressed = false;
1528 Vector3 agent_control_v3 = Vector3.Zero; 1528 Vector3 agent_control_v3 = Vector3.Zero;
1529 1529
1530 bool oldflying = Flying; 1530 bool newFlying = actor.Flying;
1531 1531
1532 if (ForceFly) 1532 if (ForceFly)
1533 actor.Flying = true; 1533 newFlying = true;
1534 else if (FlyDisabled) 1534 else if (FlyDisabled)
1535 actor.Flying = false; 1535 newFlying = false;
1536 else 1536 else
1537 actor.Flying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0); 1537 newFlying = ((flags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
1538 1538
1539 if (actor.Flying != oldflying) 1539 if (actor.Flying != newFlying)
1540 {
1541 // Note: ScenePresence.Flying is actually fetched from the physical actor
1542 // so setting PhysActor.Flying here also sets the ScenePresence's value.
1543 actor.Flying = newFlying;
1540 update_movementflag = true; 1544 update_movementflag = true;
1545 }
1541 1546
1542 if (ParentID == 0) 1547 if (ParentID == 0)
1543 { 1548 {
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
index 5758869..5faf131 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAgentTests.cs
@@ -141,7 +141,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
141 TestScene scene = new SceneHelpers().SetupScene(); 141 TestScene scene = new SceneHelpers().SetupScene();
142 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); 142 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
143 143
144 scene.IncomingCloseAgent(sp.UUID); 144 scene.IncomingCloseAgent(sp.UUID, false);
145 145
146 Assert.That(scene.GetScenePresence(sp.UUID), Is.Null); 146 Assert.That(scene.GetScenePresence(sp.UUID), Is.Null);
147 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null); 147 Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(sp.UUID), Is.Null);
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 3b83e58..1660c45 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -890,10 +890,10 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
890 890
891 public void Close() 891 public void Close()
892 { 892 {
893 Close(true); 893 Close(true, false);
894 } 894 }
895 895
896 public void Close(bool sendStop) 896 public void Close(bool sendStop, bool force)
897 { 897 {
898 Disconnect(); 898 Disconnect();
899 } 899 }
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index d00a6c0..625342e 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -905,11 +905,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC
905 905
906 public void Close() 906 public void Close()
907 { 907 {
908 Close(true); 908 Close(true, false);
909 } 909 }
910 910
911 public void Close(bool sendStop) 911 public void Close(bool sendStop, bool force)
912 { 912 {
913 // Remove ourselves from the scene
914 m_scene.RemoveClient(AgentId, false);
913 } 915 }
914 916
915 public void Start() 917 public void Start()
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index e2f7af9..1b23a36 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -124,10 +124,14 @@ public class BSCharacter : PhysicsActor
124 // do actual create at taint time 124 // do actual create at taint time
125 _scene.TaintedObject("BSCharacter.create", delegate() 125 _scene.TaintedObject("BSCharacter.create", delegate()
126 { 126 {
127 DetailLog("{0},BSCharacter.create", _localID);
127 BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData); 128 BulletSimAPI.CreateObject(parent_scene.WorldID, shapeData);
128 129
130 // Set the buoyancy for flying. This will be refactored when all the settings happen in C#
131 BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, LocalID, _buoyancy);
132
129 m_body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID)); 133 m_body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID));
130 // avatars get all collisions no matter what 134 // avatars get all collisions no matter what (makes walking on ground and such work)
131 BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); 135 BulletSimAPI.AddToCollisionFlags2(Body.Ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS);
132 }); 136 });
133 137
@@ -137,7 +141,7 @@ public class BSCharacter : PhysicsActor
137 // called when this character is being destroyed and the resources should be released 141 // called when this character is being destroyed and the resources should be released
138 public void Destroy() 142 public void Destroy()
139 { 143 {
140 // DetailLog("{0},BSCharacter.Destroy", LocalID); 144 DetailLog("{0},BSCharacter.Destroy", LocalID);
141 _scene.TaintedObject("BSCharacter.destroy", delegate() 145 _scene.TaintedObject("BSCharacter.destroy", delegate()
142 { 146 {
143 BulletSimAPI.DestroyObject(_scene.WorldID, _localID); 147 BulletSimAPI.DestroyObject(_scene.WorldID, _localID);
@@ -319,14 +323,13 @@ public class BSCharacter : PhysicsActor
319 public override bool Flying { 323 public override bool Flying {
320 get { return _flying; } 324 get { return _flying; }
321 set { 325 set {
322 if (_flying != value) 326 _flying = value;
323 { 327 // simulate flying by changing the effect of gravity
324 _flying = value; 328 this.Buoyancy = ComputeBuoyancyFromFlying(_flying);
325 // simulate flying by changing the effect of gravity
326 this.Buoyancy = ComputeBuoyancyFromFlying(_flying);
327 }
328 } 329 }
329 } 330 }
331 // Flying is implimented by changing the avatar's buoyancy.
332 // Would this be done better with a vehicle type?
330 private float ComputeBuoyancyFromFlying(bool ifFlying) { 333 private float ComputeBuoyancyFromFlying(bool ifFlying) {
331 return ifFlying ? 1f : 0f; 334 return ifFlying ? 1f : 0f;
332 } 335 }
@@ -488,11 +491,9 @@ public class BSCharacter : PhysicsActor
488 // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. 491 // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop.
489 // base.RequestPhysicsterseUpdate(); 492 // base.RequestPhysicsterseUpdate();
490 493
491 /*
492 DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", 494 DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
493 LocalID, entprop.Position, entprop.Rotation, entprop.Velocity, 495 LocalID, entprop.Position, entprop.Rotation, entprop.Velocity,
494 entprop.Acceleration, entprop.RotationalVelocity); 496 entprop.Acceleration, entprop.RotationalVelocity);
495 */
496 } 497 }
497 498
498 // Called by the scene when a collision with this object is reported 499 // Called by the scene when a collision with this object is reported
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index 5a9f135..d7213fc 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -57,6 +57,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
57 private int frcount = 0; // Used to limit dynamics debug output to 57 private int frcount = 0; // Used to limit dynamics debug output to
58 // every 100th frame 58 // every 100th frame
59 59
60 private BSScene m_physicsScene;
60 private BSPrim m_prim; // the prim this dynamic controller belongs to 61 private BSPrim m_prim; // the prim this dynamic controller belongs to
61 62
62 // Vehicle properties 63 // Vehicle properties
@@ -74,7 +75,6 @@ namespace OpenSim.Region.Physics.BulletSPlugin
74 // HOVER_UP_ONLY 75 // HOVER_UP_ONLY
75 // LIMIT_MOTOR_UP 76 // LIMIT_MOTOR_UP
76 // LIMIT_ROLL_ONLY 77 // LIMIT_ROLL_ONLY
77 private VehicleFlag m_Hoverflags = (VehicleFlag)0;
78 private Vector3 m_BlockingEndPoint = Vector3.Zero; 78 private Vector3 m_BlockingEndPoint = Vector3.Zero;
79 private Quaternion m_RollreferenceFrame = Quaternion.Identity; 79 private Quaternion m_RollreferenceFrame = Quaternion.Identity;
80 // Linear properties 80 // Linear properties
@@ -124,15 +124,16 @@ namespace OpenSim.Region.Physics.BulletSPlugin
124 private float m_verticalAttractionEfficiency = 1.0f; // damped 124 private float m_verticalAttractionEfficiency = 1.0f; // damped
125 private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor. 125 private float m_verticalAttractionTimescale = 500f; // Timescale > 300 means no vert attractor.
126 126
127 public BSDynamics(BSPrim myPrim) 127 public BSDynamics(BSScene myScene, BSPrim myPrim)
128 { 128 {
129 m_physicsScene = myScene;
129 m_prim = myPrim; 130 m_prim = myPrim;
130 m_type = Vehicle.TYPE_NONE; 131 m_type = Vehicle.TYPE_NONE;
131 } 132 }
132 133
133 internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue, float timestep) 134 internal void ProcessFloatVehicleParam(Vehicle pParam, float pValue, float timestep)
134 { 135 {
135 DetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue); 136 VDetailLog("{0},ProcessFloatVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue);
136 switch (pParam) 137 switch (pParam)
137 { 138 {
138 case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: 139 case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY:
@@ -231,7 +232,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
231 232
232 internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue, float timestep) 233 internal void ProcessVectorVehicleParam(Vehicle pParam, Vector3 pValue, float timestep)
233 { 234 {
234 DetailLog("{0},ProcessVectorVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue); 235 VDetailLog("{0},ProcessVectorVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue);
235 switch (pParam) 236 switch (pParam)
236 { 237 {
237 case Vehicle.ANGULAR_FRICTION_TIMESCALE: 238 case Vehicle.ANGULAR_FRICTION_TIMESCALE:
@@ -266,7 +267,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
266 267
267 internal void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue) 268 internal void ProcessRotationVehicleParam(Vehicle pParam, Quaternion pValue)
268 { 269 {
269 DetailLog("{0},ProcessRotationalVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue); 270 VDetailLog("{0},ProcessRotationalVehicleParam,param={1},val={2}", m_prim.LocalID, pParam, pValue);
270 switch (pParam) 271 switch (pParam)
271 { 272 {
272 case Vehicle.REFERENCE_FRAME: 273 case Vehicle.REFERENCE_FRAME:
@@ -280,164 +281,27 @@ namespace OpenSim.Region.Physics.BulletSPlugin
280 281
281 internal void ProcessVehicleFlags(int pParam, bool remove) 282 internal void ProcessVehicleFlags(int pParam, bool remove)
282 { 283 {
283 DetailLog("{0},ProcessVehicleFlags,param={1},remove={2}", m_prim.LocalID, pParam, remove); 284 VDetailLog("{0},ProcessVehicleFlags,param={1},remove={2}", m_prim.LocalID, pParam, remove);
285 VehicleFlag parm = (VehicleFlag)pParam;
284 if (remove) 286 if (remove)
285 { 287 {
286 if (pParam == -1) 288 if (pParam == -1)
287 { 289 {
288 m_flags = (VehicleFlag)0; 290 m_flags = (VehicleFlag)0;
289 m_Hoverflags = (VehicleFlag)0;
290 return;
291 } 291 }
292 if ((pParam & (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) == (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) 292 else
293 {
294 if ((m_Hoverflags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != (VehicleFlag)0)
295 m_Hoverflags &= ~(VehicleFlag.HOVER_GLOBAL_HEIGHT);
296 }
297 if ((pParam & (int)VehicleFlag.HOVER_TERRAIN_ONLY) == (int)VehicleFlag.HOVER_TERRAIN_ONLY)
298 {
299 if ((m_Hoverflags & VehicleFlag.HOVER_TERRAIN_ONLY) != (VehicleFlag)0)
300 m_Hoverflags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY);
301 }
302 if ((pParam & (int)VehicleFlag.HOVER_UP_ONLY) == (int)VehicleFlag.HOVER_UP_ONLY)
303 {
304 if ((m_Hoverflags & VehicleFlag.HOVER_UP_ONLY) != (VehicleFlag)0)
305 m_Hoverflags &= ~(VehicleFlag.HOVER_UP_ONLY);
306 }
307 if ((pParam & (int)VehicleFlag.HOVER_WATER_ONLY) == (int)VehicleFlag.HOVER_WATER_ONLY)
308 {
309 if ((m_Hoverflags & VehicleFlag.HOVER_WATER_ONLY) != (VehicleFlag)0)
310 m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY);
311 }
312 if ((pParam & (int)VehicleFlag.LIMIT_MOTOR_UP) == (int)VehicleFlag.LIMIT_MOTOR_UP)
313 {
314 if ((m_flags & VehicleFlag.LIMIT_MOTOR_UP) != (VehicleFlag)0)
315 m_flags &= ~(VehicleFlag.LIMIT_MOTOR_UP);
316 }
317 if ((pParam & (int)VehicleFlag.LIMIT_ROLL_ONLY) == (int)VehicleFlag.LIMIT_ROLL_ONLY)
318 {
319 if ((m_flags & VehicleFlag.LIMIT_ROLL_ONLY) != (VehicleFlag)0)
320 m_flags &= ~(VehicleFlag.LIMIT_ROLL_ONLY);
321 }
322 if ((pParam & (int)VehicleFlag.MOUSELOOK_BANK) == (int)VehicleFlag.MOUSELOOK_BANK)
323 {
324 if ((m_flags & VehicleFlag.MOUSELOOK_BANK) != (VehicleFlag)0)
325 m_flags &= ~(VehicleFlag.MOUSELOOK_BANK);
326 }
327 if ((pParam & (int)VehicleFlag.MOUSELOOK_STEER) == (int)VehicleFlag.MOUSELOOK_STEER)
328 {
329 if ((m_flags & VehicleFlag.MOUSELOOK_STEER) != (VehicleFlag)0)
330 m_flags &= ~(VehicleFlag.MOUSELOOK_STEER);
331 }
332 if ((pParam & (int)VehicleFlag.NO_DEFLECTION_UP) == (int)VehicleFlag.NO_DEFLECTION_UP)
333 {
334 if ((m_flags & VehicleFlag.NO_DEFLECTION_UP) != (VehicleFlag)0)
335 m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP);
336 }
337 if ((pParam & (int)VehicleFlag.CAMERA_DECOUPLED) == (int)VehicleFlag.CAMERA_DECOUPLED)
338 {
339 if ((m_flags & VehicleFlag.CAMERA_DECOUPLED) != (VehicleFlag)0)
340 m_flags &= ~(VehicleFlag.CAMERA_DECOUPLED);
341 }
342 if ((pParam & (int)VehicleFlag.NO_X) == (int)VehicleFlag.NO_X)
343 {
344 if ((m_flags & VehicleFlag.NO_X) != (VehicleFlag)0)
345 m_flags &= ~(VehicleFlag.NO_X);
346 }
347 if ((pParam & (int)VehicleFlag.NO_Y) == (int)VehicleFlag.NO_Y)
348 {
349 if ((m_flags & VehicleFlag.NO_Y) != (VehicleFlag)0)
350 m_flags &= ~(VehicleFlag.NO_Y);
351 }
352 if ((pParam & (int)VehicleFlag.NO_Z) == (int)VehicleFlag.NO_Z)
353 {
354 if ((m_flags & VehicleFlag.NO_Z) != (VehicleFlag)0)
355 m_flags &= ~(VehicleFlag.NO_Z);
356 }
357 if ((pParam & (int)VehicleFlag.LOCK_HOVER_HEIGHT) == (int)VehicleFlag.LOCK_HOVER_HEIGHT)
358 {
359 if ((m_Hoverflags & VehicleFlag.LOCK_HOVER_HEIGHT) != (VehicleFlag)0)
360 m_Hoverflags &= ~(VehicleFlag.LOCK_HOVER_HEIGHT);
361 }
362 if ((pParam & (int)VehicleFlag.NO_DEFLECTION) == (int)VehicleFlag.NO_DEFLECTION)
363 {
364 if ((m_flags & VehicleFlag.NO_DEFLECTION) != (VehicleFlag)0)
365 m_flags &= ~(VehicleFlag.NO_DEFLECTION);
366 }
367 if ((pParam & (int)VehicleFlag.LOCK_ROTATION) == (int)VehicleFlag.LOCK_ROTATION)
368 { 293 {
369 if ((m_flags & VehicleFlag.LOCK_ROTATION) != (VehicleFlag)0) 294 m_flags &= ~parm;
370 m_flags &= ~(VehicleFlag.LOCK_ROTATION);
371 } 295 }
372 } 296 }
373 else 297 else {
374 { 298 m_flags |= parm;
375 if ((pParam & (int)VehicleFlag.HOVER_GLOBAL_HEIGHT) == (int)VehicleFlag.HOVER_GLOBAL_HEIGHT)
376 {
377 m_Hoverflags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT | m_flags);
378 }
379 if ((pParam & (int)VehicleFlag.HOVER_TERRAIN_ONLY) == (int)VehicleFlag.HOVER_TERRAIN_ONLY)
380 {
381 m_Hoverflags |= (VehicleFlag.HOVER_TERRAIN_ONLY | m_flags);
382 }
383 if ((pParam & (int)VehicleFlag.HOVER_UP_ONLY) == (int)VehicleFlag.HOVER_UP_ONLY)
384 {
385 m_Hoverflags |= (VehicleFlag.HOVER_UP_ONLY | m_flags);
386 }
387 if ((pParam & (int)VehicleFlag.HOVER_WATER_ONLY) == (int)VehicleFlag.HOVER_WATER_ONLY)
388 {
389 m_Hoverflags |= (VehicleFlag.HOVER_WATER_ONLY | m_flags);
390 }
391 if ((pParam & (int)VehicleFlag.LIMIT_MOTOR_UP) == (int)VehicleFlag.LIMIT_MOTOR_UP)
392 {
393 m_flags |= (VehicleFlag.LIMIT_MOTOR_UP | m_flags);
394 }
395 if ((pParam & (int)VehicleFlag.MOUSELOOK_BANK) == (int)VehicleFlag.MOUSELOOK_BANK)
396 {
397 m_flags |= (VehicleFlag.MOUSELOOK_BANK | m_flags);
398 }
399 if ((pParam & (int)VehicleFlag.MOUSELOOK_STEER) == (int)VehicleFlag.MOUSELOOK_STEER)
400 {
401 m_flags |= (VehicleFlag.MOUSELOOK_STEER | m_flags);
402 }
403 if ((pParam & (int)VehicleFlag.NO_DEFLECTION_UP) == (int)VehicleFlag.NO_DEFLECTION_UP)
404 {
405 m_flags |= (VehicleFlag.NO_DEFLECTION_UP | m_flags);
406 }
407 if ((pParam & (int)VehicleFlag.CAMERA_DECOUPLED) == (int)VehicleFlag.CAMERA_DECOUPLED)
408 {
409 m_flags |= (VehicleFlag.CAMERA_DECOUPLED | m_flags);
410 }
411 if ((pParam & (int)VehicleFlag.NO_X) == (int)VehicleFlag.NO_X)
412 {
413 m_flags |= (VehicleFlag.NO_X);
414 }
415 if ((pParam & (int)VehicleFlag.NO_Y) == (int)VehicleFlag.NO_Y)
416 {
417 m_flags |= (VehicleFlag.NO_Y);
418 }
419 if ((pParam & (int)VehicleFlag.NO_Z) == (int)VehicleFlag.NO_Z)
420 {
421 m_flags |= (VehicleFlag.NO_Z);
422 }
423 if ((pParam & (int)VehicleFlag.LOCK_HOVER_HEIGHT) == (int)VehicleFlag.LOCK_HOVER_HEIGHT)
424 {
425 m_Hoverflags |= (VehicleFlag.LOCK_HOVER_HEIGHT);
426 }
427 if ((pParam & (int)VehicleFlag.NO_DEFLECTION) == (int)VehicleFlag.NO_DEFLECTION)
428 {
429 m_flags |= (VehicleFlag.NO_DEFLECTION);
430 }
431 if ((pParam & (int)VehicleFlag.LOCK_ROTATION) == (int)VehicleFlag.LOCK_ROTATION)
432 {
433 m_flags |= (VehicleFlag.LOCK_ROTATION);
434 }
435 } 299 }
436 }//end ProcessVehicleFlags 300 }//end ProcessVehicleFlags
437 301
438 internal void ProcessTypeChange(Vehicle pType) 302 internal void ProcessTypeChange(Vehicle pType, float stepSize)
439 { 303 {
440 DetailLog("{0},ProcessTypeChange,type={1}", m_prim.LocalID, pType); 304 VDetailLog("{0},ProcessTypeChange,type={1}", m_prim.LocalID, pType);
441 // Set Defaults For Type 305 // Set Defaults For Type
442 m_type = pType; 306 m_type = pType;
443 switch (pType) 307 switch (pType)
@@ -478,10 +342,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
478 // m_bankingMix = 1; 342 // m_bankingMix = 1;
479 // m_bankingTimescale = 10; 343 // m_bankingTimescale = 10;
480 // m_referenceFrame = Quaternion.Identity; 344 // m_referenceFrame = Quaternion.Identity;
481 m_Hoverflags &= 345 m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP);
346 m_flags &=
482 ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | 347 ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY |
483 VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); 348 VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY);
484 m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP);
485 break; 349 break;
486 case Vehicle.TYPE_CAR: 350 case Vehicle.TYPE_CAR:
487 m_linearFrictionTimescale = new Vector3(100, 2, 1000); 351 m_linearFrictionTimescale = new Vector3(100, 2, 1000);
@@ -506,10 +370,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin
506 // m_bankingMix = 1; 370 // m_bankingMix = 1;
507 // m_bankingTimescale = 1; 371 // m_bankingTimescale = 1;
508 // m_referenceFrame = Quaternion.Identity; 372 // m_referenceFrame = Quaternion.Identity;
509 m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT);
510 m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | 373 m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY |
511 VehicleFlag.LIMIT_MOTOR_UP); 374 VehicleFlag.LIMIT_MOTOR_UP);
512 m_Hoverflags |= (VehicleFlag.HOVER_UP_ONLY); 375 m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT);
376 m_flags |= (VehicleFlag.HOVER_UP_ONLY);
513 break; 377 break;
514 case Vehicle.TYPE_BOAT: 378 case Vehicle.TYPE_BOAT:
515 m_linearFrictionTimescale = new Vector3(10, 3, 2); 379 m_linearFrictionTimescale = new Vector3(10, 3, 2);
@@ -534,12 +398,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin
534 // m_bankingMix = 0.8f; 398 // m_bankingMix = 0.8f;
535 // m_bankingTimescale = 1; 399 // m_bankingTimescale = 1;
536 // m_referenceFrame = Quaternion.Identity; 400 // m_referenceFrame = Quaternion.Identity;
537 m_Hoverflags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | 401 m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY |
538 VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); 402 VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY);
539 m_flags &= ~(VehicleFlag.LIMIT_ROLL_ONLY); 403 m_flags &= ~(VehicleFlag.LIMIT_ROLL_ONLY);
540 m_flags |= (VehicleFlag.NO_DEFLECTION_UP | 404 m_flags |= (VehicleFlag.NO_DEFLECTION_UP |
541 VehicleFlag.LIMIT_MOTOR_UP); 405 VehicleFlag.LIMIT_MOTOR_UP);
542 m_Hoverflags |= (VehicleFlag.HOVER_WATER_ONLY); 406 m_flags |= (VehicleFlag.HOVER_WATER_ONLY);
543 break; 407 break;
544 case Vehicle.TYPE_AIRPLANE: 408 case Vehicle.TYPE_AIRPLANE:
545 m_linearFrictionTimescale = new Vector3(200, 10, 5); 409 m_linearFrictionTimescale = new Vector3(200, 10, 5);
@@ -564,7 +428,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
564 // m_bankingMix = 0.7f; 428 // m_bankingMix = 0.7f;
565 // m_bankingTimescale = 2; 429 // m_bankingTimescale = 2;
566 // m_referenceFrame = Quaternion.Identity; 430 // m_referenceFrame = Quaternion.Identity;
567 m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | 431 m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY |
568 VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); 432 VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY);
569 m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); 433 m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP);
570 m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); 434 m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY);
@@ -592,11 +456,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
592 // m_bankingMix = 0.7f; 456 // m_bankingMix = 0.7f;
593 // m_bankingTimescale = 5; 457 // m_bankingTimescale = 5;
594 // m_referenceFrame = Quaternion.Identity; 458 // m_referenceFrame = Quaternion.Identity;
595 m_Hoverflags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | 459 m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY |
596 VehicleFlag.HOVER_UP_ONLY); 460 VehicleFlag.HOVER_UP_ONLY);
597 m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP); 461 m_flags &= ~(VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_MOTOR_UP);
598 m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); 462 m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY);
599 m_Hoverflags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT); 463 m_flags |= (VehicleFlag.HOVER_GLOBAL_HEIGHT);
600 break; 464 break;
601 } 465 }
602 }//end SetDefaultsForType 466 }//end SetDefaultsForType
@@ -613,7 +477,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
613 MoveAngular(pTimestep); 477 MoveAngular(pTimestep);
614 LimitRotation(pTimestep); 478 LimitRotation(pTimestep);
615 479
616 DetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", 480 VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}",
617 m_prim.LocalID, m_prim.Position, m_prim.Force, m_prim.Velocity, m_prim.RotationalVelocity); 481 m_prim.LocalID, m_prim.Position, m_prim.Force, m_prim.Velocity, m_prim.RotationalVelocity);
618 }// end Step 482 }// end Step
619 483
@@ -657,7 +521,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
657 521
658 */ 522 */
659 523
660 DetailLog("{0},MoveLinear,nonZero,origdir={1},origvel={2},add={3},decay={4},dir={5},vel={6}", 524 VDetailLog("{0},MoveLinear,nonZero,origdir={1},origvel={2},add={3},decay={4},dir={5},vel={6}",
661 m_prim.LocalID, origDir, origVel, addAmount, decayfraction, m_linearMotorDirection, m_lastLinearVelocityVector); 525 m_prim.LocalID, origDir, origVel, addAmount, decayfraction, m_linearMotorDirection, m_lastLinearVelocityVector);
662 } 526 }
663 else 527 else
@@ -669,7 +533,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
669 m_lastLinearVelocityVector = Vector3.Zero; 533 m_lastLinearVelocityVector = Vector3.Zero;
670 } 534 }
671 535
672 // convert requested object velocity to world-referenced vector 536 // convert requested object velocity to object relative vector
673 Quaternion rotq = m_prim.Orientation; 537 Quaternion rotq = m_prim.Orientation;
674 m_dir = m_lastLinearVelocityVector * rotq; 538 m_dir = m_lastLinearVelocityVector * rotq;
675 539
@@ -722,7 +586,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
722 if (changed) 586 if (changed)
723 { 587 {
724 m_prim.Position = pos; 588 m_prim.Position = pos;
725 DetailLog("{0},MoveLinear,blockingEndPoint,block={1},origPos={2},pos={3}", 589 VDetailLog("{0},MoveLinear,blockingEndPoint,block={1},origPos={2},pos={3}",
726 m_prim.LocalID, m_BlockingEndPoint, posChange, pos); 590 m_prim.LocalID, m_BlockingEndPoint, posChange, pos);
727 } 591 }
728 } 592 }
@@ -732,32 +596,32 @@ namespace OpenSim.Region.Physics.BulletSPlugin
732 { 596 {
733 pos.Z = m_prim.Scene.GetTerrainHeightAtXYZ(pos) + 2; 597 pos.Z = m_prim.Scene.GetTerrainHeightAtXYZ(pos) + 2;
734 m_prim.Position = pos; 598 m_prim.Position = pos;
735 DetailLog("{0},MoveLinear,terrainHeight,pos={1}", m_prim.LocalID, pos); 599 VDetailLog("{0},MoveLinear,terrainHeight,pos={1}", m_prim.LocalID, pos);
736 } 600 }
737 601
738 // Check if hovering 602 // Check if hovering
739 if ((m_Hoverflags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0) 603 if ((m_flags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0)
740 { 604 {
741 // We should hover, get the target height 605 // We should hover, get the target height
742 if ((m_Hoverflags & VehicleFlag.HOVER_WATER_ONLY) != 0) 606 if ((m_flags & VehicleFlag.HOVER_WATER_ONLY) != 0)
743 { 607 {
744 m_VhoverTargetHeight = m_prim.Scene.GetWaterLevel() + m_VhoverHeight; 608 m_VhoverTargetHeight = m_prim.Scene.GetWaterLevel() + m_VhoverHeight;
745 } 609 }
746 if ((m_Hoverflags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0) 610 if ((m_flags & VehicleFlag.HOVER_TERRAIN_ONLY) != 0)
747 { 611 {
748 m_VhoverTargetHeight = m_prim.Scene.GetTerrainHeightAtXY(pos.X, pos.Y) + m_VhoverHeight; 612 m_VhoverTargetHeight = m_prim.Scene.GetTerrainHeightAtXY(pos.X, pos.Y) + m_VhoverHeight;
749 } 613 }
750 if ((m_Hoverflags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != 0) 614 if ((m_flags & VehicleFlag.HOVER_GLOBAL_HEIGHT) != 0)
751 { 615 {
752 m_VhoverTargetHeight = m_VhoverHeight; 616 m_VhoverTargetHeight = m_VhoverHeight;
753 } 617 }
754 618
755 if ((m_Hoverflags & VehicleFlag.HOVER_UP_ONLY) != 0) 619 if ((m_flags & VehicleFlag.HOVER_UP_ONLY) != 0)
756 { 620 {
757 // If body is aready heigher, use its height as target height 621 // If body is aready heigher, use its height as target height
758 if (pos.Z > m_VhoverTargetHeight) m_VhoverTargetHeight = pos.Z; 622 if (pos.Z > m_VhoverTargetHeight) m_VhoverTargetHeight = pos.Z;
759 } 623 }
760 if ((m_Hoverflags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0) 624 if ((m_flags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0)
761 { 625 {
762 if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2) 626 if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2)
763 { 627 {
@@ -779,7 +643,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
779 } 643 }
780 } 644 }
781 645
782 DetailLog("{0},MoveLinear,hover,pos={1},dir={2},height={3},target={4}", m_prim.LocalID, pos, m_dir, m_VhoverHeight, m_VhoverTargetHeight); 646 VDetailLog("{0},MoveLinear,hover,pos={1},dir={2},height={3},target={4}", m_prim.LocalID, pos, m_dir, m_VhoverHeight, m_VhoverTargetHeight);
783 647
784// m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped 648// m_VhoverEfficiency = 0f; // 0=boucy, 1=Crit.damped
785// m_VhoverTimescale = 0f; // time to acheive height 649// m_VhoverTimescale = 0f; // time to acheive height
@@ -815,7 +679,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
815 { 679 {
816 grav.Z = (float)(grav.Z * 1.037125); 680 grav.Z = (float)(grav.Z * 1.037125);
817 } 681 }
818 DetailLog("{0},MoveLinear,limitMotorUp,grav={1}", m_prim.LocalID, grav); 682 VDetailLog("{0},MoveLinear,limitMotorUp,grav={1}", m_prim.LocalID, grav);
819 //End Experimental Values 683 //End Experimental Values
820 } 684 }
821 if ((m_flags & (VehicleFlag.NO_X)) != 0) 685 if ((m_flags & (VehicleFlag.NO_X)) != 0)
@@ -844,7 +708,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
844 Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep); 708 Vector3 decayamount = Vector3.One / (m_linearFrictionTimescale / pTimestep);
845 m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount; 709 m_lastLinearVelocityVector -= m_lastLinearVelocityVector * decayamount;
846 710
847 DetailLog("{0},MoveLinear,done,pos={1},vel={2},force={3},decay={4}", 711 VDetailLog("{0},MoveLinear,done,pos={1},vel={2},force={3},decay={4}",
848 m_prim.LocalID, m_lastPositionVector, m_dir, grav, decayamount); 712 m_prim.LocalID, m_lastPositionVector, m_dir, grav, decayamount);
849 713
850 } // end MoveLinear() 714 } // end MoveLinear()
@@ -870,13 +734,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
870 // There are m_angularMotorApply steps. 734 // There are m_angularMotorApply steps.
871 Vector3 origAngularVelocity = m_angularMotorVelocity; 735 Vector3 origAngularVelocity = m_angularMotorVelocity;
872 // ramp up to new value 736 // ramp up to new value
873 // current velocity += error / (time to get there / step interval) 737 // current velocity += error / (time to get there / step interval)
874 // requested speed - last motor speed 738 // requested speed - last motor speed
875 m_angularMotorVelocity.X += (m_angularMotorDirection.X - m_angularMotorVelocity.X) / (m_angularMotorTimescale / pTimestep); 739 m_angularMotorVelocity.X += (m_angularMotorDirection.X - m_angularMotorVelocity.X) / (m_angularMotorTimescale / pTimestep);
876 m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep); 740 m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep);
877 m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep); 741 m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep);
878 742
879 DetailLog("{0},MoveAngular,angularMotorApply,apply={1},origvel={2},dir={3},vel={4}", 743 VDetailLog("{0},MoveAngular,angularMotorApply,apply={1},origvel={2},dir={3},vel={4}",
880 m_prim.LocalID,m_angularMotorApply,origAngularVelocity, m_angularMotorDirection, m_angularMotorVelocity); 744 m_prim.LocalID,m_angularMotorApply,origAngularVelocity, m_angularMotorDirection, m_angularMotorVelocity);
881 745
882 m_angularMotorApply--; // This is done so that if script request rate is less than phys frame rate the expected 746 m_angularMotorApply--; // This is done so that if script request rate is less than phys frame rate the expected
@@ -887,6 +751,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin
887 // No motor recently applied, keep the body velocity 751 // No motor recently applied, keep the body velocity
888 // and decay the velocity 752 // and decay the velocity
889 m_angularMotorVelocity -= m_angularMotorVelocity / (m_angularMotorDecayTimescale / pTimestep); 753 m_angularMotorVelocity -= m_angularMotorVelocity / (m_angularMotorDecayTimescale / pTimestep);
754 if (m_angularMotorVelocity.LengthSquared() < 0.00001)
755 m_angularMotorVelocity = Vector3.Zero;
890 } // end motor section 756 } // end motor section
891 757
892 // Vertical attractor section 758 // Vertical attractor section
@@ -924,7 +790,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
924 vertattr.X += bounce * angularVelocity.X; 790 vertattr.X += bounce * angularVelocity.X;
925 vertattr.Y += bounce * angularVelocity.Y; 791 vertattr.Y += bounce * angularVelocity.Y;
926 792
927 DetailLog("{0},MoveAngular,verticalAttraction,verterr={1},bounce={2},vertattr={3}", 793 VDetailLog("{0},MoveAngular,verticalAttraction,verterr={1},bounce={2},vertattr={3}",
928 m_prim.LocalID, verterr, bounce, vertattr); 794 m_prim.LocalID, verterr, bounce, vertattr);
929 795
930 } // else vertical attractor is off 796 } // else vertical attractor is off
@@ -942,13 +808,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin
942 { 808 {
943 m_lastAngularVelocity.X = 0; 809 m_lastAngularVelocity.X = 0;
944 m_lastAngularVelocity.Y = 0; 810 m_lastAngularVelocity.Y = 0;
945 DetailLog("{0},MoveAngular,noDeflectionUp,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity); 811 VDetailLog("{0},MoveAngular,noDeflectionUp,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity);
946 } 812 }
947 813
948 if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) 814 if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f))
949 { 815 {
950 m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero. 816 m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero.
951 DetailLog("{0},MoveAngular,zeroSmallValues,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity); 817 VDetailLog("{0},MoveAngular,zeroSmallValues,lastAngular={1}", m_prim.LocalID, m_lastAngularVelocity);
952 } 818 }
953 819
954 // apply friction 820 // apply friction
@@ -958,7 +824,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
958 // Apply to the body 824 // Apply to the body
959 m_prim.RotationalVelocity = m_lastAngularVelocity; 825 m_prim.RotationalVelocity = m_lastAngularVelocity;
960 826
961 DetailLog("{0},MoveAngular,done,decay={1},lastAngular={2}", m_prim.LocalID, decayamount, m_lastAngularVelocity); 827 VDetailLog("{0},MoveAngular,done,decay={1},lastAngular={2}", m_prim.LocalID, decayamount, m_lastAngularVelocity);
962 } //end MoveAngular 828 } //end MoveAngular
963 829
964 internal void LimitRotation(float timestep) 830 internal void LimitRotation(float timestep)
@@ -1005,11 +871,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1005 if (changed) 871 if (changed)
1006 m_prim.Orientation = m_rot; 872 m_prim.Orientation = m_rot;
1007 873
1008 DetailLog("{0},LimitRotation,done,changed={1},orig={2},new={3}", m_prim.LocalID, changed, rotq, m_rot); 874 VDetailLog("{0},LimitRotation,done,changed={1},orig={2},new={3}", m_prim.LocalID, changed, rotq, m_rot);
1009 } 875 }
1010 876
1011 // Invoke the detailed logger and output something if it's enabled. 877 // Invoke the detailed logger and output something if it's enabled.
1012 private void DetailLog(string msg, params Object[] args) 878 private void VDetailLog(string msg, params Object[] args)
1013 { 879 {
1014 if (m_prim.Scene.VehicleLoggingEnabled) 880 if (m_prim.Scene.VehicleLoggingEnabled)
1015 m_prim.Scene.PhysicsLogging.Write(msg, args); 881 m_prim.Scene.PhysicsLogging.Write(msg, args);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
index 087b9bb..9e3f0db 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs
@@ -42,6 +42,9 @@ public class BSLinkset
42 private BSScene m_physicsScene; 42 private BSScene m_physicsScene;
43 public BSScene PhysicsScene { get { return m_physicsScene; } } 43 public BSScene PhysicsScene { get { return m_physicsScene; } }
44 44
45 static int m_nextLinksetID = 1;
46 public int LinksetID { get; private set; }
47
45 // The children under the root in this linkset 48 // The children under the root in this linkset
46 private List<BSPrim> m_children; 49 private List<BSPrim> m_children;
47 50
@@ -74,6 +77,10 @@ public class BSLinkset
74 public BSLinkset(BSScene scene, BSPrim parent) 77 public BSLinkset(BSScene scene, BSPrim parent)
75 { 78 {
76 // A simple linkset of one (no children) 79 // A simple linkset of one (no children)
80 LinksetID = m_nextLinksetID++;
81 // We create LOTS of linksets.
82 if (m_nextLinksetID < 0)
83 m_nextLinksetID = 1;
77 m_physicsScene = scene; 84 m_physicsScene = scene;
78 m_linksetRoot = parent; 85 m_linksetRoot = parent;
79 m_children = new List<BSPrim>(); 86 m_children = new List<BSPrim>();
@@ -258,8 +265,7 @@ public class BSLinkset
258 BSPrim childx = child; 265 BSPrim childx = child;
259 m_physicsScene.TaintedObject("AddChildToLinkset", delegate() 266 m_physicsScene.TaintedObject("AddChildToLinkset", delegate()
260 { 267 {
261 // DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, m_linksetRoot.LocalID); 268 DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID);
262 // DetailLog("{0},AddChildToLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID);
263 PhysicallyLinkAChildToRoot(rootx, childx); // build the physical binding between me and the child 269 PhysicallyLinkAChildToRoot(rootx, childx); // build the physical binding between me and the child
264 }); 270 });
265 } 271 }
@@ -287,8 +293,7 @@ public class BSLinkset
287 BSPrim childx = child; 293 BSPrim childx = child;
288 m_physicsScene.TaintedObject("RemoveChildFromLinkset", delegate() 294 m_physicsScene.TaintedObject("RemoveChildFromLinkset", delegate()
289 { 295 {
290 // DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); 296 DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID);
291 // DetailLog("{0},RemoveChildFromLinkset,taint,child={1}", m_linksetRoot.LocalID, child.LocalID);
292 297
293 PhysicallyUnlinkAChildFromRoot(rootx, childx); 298 PhysicallyUnlinkAChildFromRoot(rootx, childx);
294 }); 299 });
@@ -319,7 +324,6 @@ public class BSLinkset
319 324
320 // create a constraint that allows no freedom of movement between the two objects 325 // create a constraint that allows no freedom of movement between the two objects
321 // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 326 // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818
322 // DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID);
323 DetailLog("{0},PhysicallyLinkAChildToRoot,taint,root={1},child={2},rLoc={3},cLoc={4},midLoc={5}", 327 DetailLog("{0},PhysicallyLinkAChildToRoot,taint,root={1},child={2},rLoc={3},cLoc={4},midLoc={5}",
324 rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID, rootPrim.Position, childPrim.Position, midPoint); 328 rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID, rootPrim.Position, childPrim.Position, midPoint);
325 BS6DofConstraint constrain = new BS6DofConstraint( 329 BS6DofConstraint constrain = new BS6DofConstraint(
@@ -328,10 +332,10 @@ public class BSLinkset
328 true, 332 true,
329 true 333 true
330 ); 334 );
331 /* NOTE: attempt to build constraint with full frame computation, etc. 335 /* NOTE: below is an attempt to build constraint with full frame computation, etc.
332 * Using the midpoint is easier since it lets the Bullet code use the transforms 336 * Using the midpoint is easier since it lets the Bullet code use the transforms
333 * of the objects. 337 * of the objects.
334 * Code left here as an example. 338 * Code left as a warning to future programmers.
335 // ================================================================================== 339 // ==================================================================================
336 // relative position normalized to the root prim 340 // relative position normalized to the root prim
337 OMV.Quaternion invThisOrientation = OMV.Quaternion.Inverse(rootPrim.Orientation); 341 OMV.Quaternion invThisOrientation = OMV.Quaternion.Inverse(rootPrim.Orientation);
@@ -343,7 +347,6 @@ public class BSLinkset
343 347
344 // create a constraint that allows no freedom of movement between the two objects 348 // create a constraint that allows no freedom of movement between the two objects
345 // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 349 // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818
346 // DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID);
347 DetailLog("{0},PhysicallyLinkAChildToRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID); 350 DetailLog("{0},PhysicallyLinkAChildToRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID);
348 BS6DofConstraint constrain = new BS6DofConstraint( 351 BS6DofConstraint constrain = new BS6DofConstraint(
349 PhysicsScene.World, rootPrim.Body, childPrim.Body, 352 PhysicsScene.World, rootPrim.Body, childPrim.Body,
@@ -382,8 +385,6 @@ public class BSLinkset
382 // Called at taint time! 385 // Called at taint time!
383 private void PhysicallyUnlinkAChildFromRoot(BSPrim rootPrim, BSPrim childPrim) 386 private void PhysicallyUnlinkAChildFromRoot(BSPrim rootPrim, BSPrim childPrim)
384 { 387 {
385 // DebugLog("{0}: PhysicallyUnlinkAChildFromRoot: RemoveConstraint between root prim {1} and child prim {2}",
386 // LogHeader, rootPrim.LocalID, childPrim.LocalID);
387 DetailLog("{0},PhysicallyUnlinkAChildFromRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID); 388 DetailLog("{0},PhysicallyUnlinkAChildFromRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID);
388 389
389 // Find the constraint for this link and get rid of it from the overall collection and from my list 390 // Find the constraint for this link and get rid of it from the overall collection and from my list
@@ -397,20 +398,12 @@ public class BSLinkset
397 // Called at taint time! 398 // Called at taint time!
398 private void PhysicallyUnlinkAllChildrenFromRoot(BSPrim rootPrim) 399 private void PhysicallyUnlinkAllChildrenFromRoot(BSPrim rootPrim)
399 { 400 {
400 // DebugLog("{0}: PhysicallyUnlinkAllChildren:", LogHeader);
401 DetailLog("{0},PhysicallyUnlinkAllChildren,taint", rootPrim.LocalID); 401 DetailLog("{0},PhysicallyUnlinkAllChildren,taint", rootPrim.LocalID);
402 402
403 m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.Body); 403 m_physicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.Body);
404 } 404 }
405 405
406 // Invoke the detailed logger and output something if it's enabled. 406 // Invoke the detailed logger and output something if it's enabled.
407 private void DebugLog(string msg, params Object[] args)
408 {
409 if (m_physicsScene.ShouldDebugLog)
410 m_physicsScene.Logger.DebugFormat(msg, args);
411 }
412
413 // Invoke the detailed logger and output something if it's enabled.
414 private void DetailLog(string msg, params Object[] args) 407 private void DetailLog(string msg, params Object[] args)
415 { 408 {
416 m_physicsScene.PhysicsLogging.Write(msg, args); 409 m_physicsScene.PhysicsLogging.Write(msg, args);
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 9c20004..d3f1e9c 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -42,8 +42,6 @@ public sealed class BSPrim : PhysicsActor
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43 private static readonly string LogHeader = "[BULLETS PRIM]"; 43 private static readonly string LogHeader = "[BULLETS PRIM]";
44 44
45 private void DebugLog(string mm, params Object[] xx) { if (_scene.ShouldDebugLog) m_log.DebugFormat(mm, xx); }
46
47 private IMesh _mesh; 45 private IMesh _mesh;
48 private PrimitiveBaseShape _pbs; 46 private PrimitiveBaseShape _pbs;
49 private ShapeData.PhysicsShapeType _shapeType; 47 private ShapeData.PhysicsShapeType _shapeType;
@@ -141,8 +139,8 @@ public sealed class BSPrim : PhysicsActor
141 _friction = _scene.Params.defaultFriction; // TODO: compute based on object material 139 _friction = _scene.Params.defaultFriction; // TODO: compute based on object material
142 _density = _scene.Params.defaultDensity; // TODO: compute based on object material 140 _density = _scene.Params.defaultDensity; // TODO: compute based on object material
143 _restitution = _scene.Params.defaultRestitution; 141 _restitution = _scene.Params.defaultRestitution;
144 _linkset = new BSLinkset(_scene, this); // a linkset of one 142 _linkset = new BSLinkset(Scene, this); // a linkset of one
145 _vehicle = new BSDynamics(this); // add vehicleness 143 _vehicle = new BSDynamics(Scene, this); // add vehicleness
146 _mass = CalculateMass(); 144 _mass = CalculateMass();
147 // do the actual object creation at taint time 145 // do the actual object creation at taint time
148 DetailLog("{0},BSPrim.constructor,call", LocalID); 146 DetailLog("{0},BSPrim.constructor,call", LocalID);
@@ -193,7 +191,7 @@ public sealed class BSPrim : PhysicsActor
193 { 191 {
194 _mass = CalculateMass(); // changing size changes the mass 192 _mass = CalculateMass(); // changing size changes the mass
195 BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, (IsPhysical ? _mass : 0f), IsPhysical); 193 BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, (IsPhysical ? _mass : 0f), IsPhysical);
196 // DetailLog("{0}: BSPrim.setSize: size={1}, mass={2}, physical={3}", LocalID, _size, _mass, IsPhysical); 194 DetailLog("{0}: BSPrim.setSize: size={1}, mass={2}, physical={3}", LocalID, _size, _mass, IsPhysical);
197 RecreateGeomAndObject(); 195 RecreateGeomAndObject();
198 }); 196 });
199 } 197 }
@@ -232,7 +230,6 @@ public sealed class BSPrim : PhysicsActor
232 BSPrim parent = obj as BSPrim; 230 BSPrim parent = obj as BSPrim;
233 if (parent != null) 231 if (parent != null)
234 { 232 {
235 DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, parent.LocalID);
236 BSPrim parentBefore = _linkset.LinksetRoot; 233 BSPrim parentBefore = _linkset.LinksetRoot;
237 int childrenBefore = _linkset.NumberOfChildren; 234 int childrenBefore = _linkset.NumberOfChildren;
238 235
@@ -248,8 +245,6 @@ public sealed class BSPrim : PhysicsActor
248 public override void delink() { 245 public override void delink() {
249 // TODO: decide if this parent checking needs to happen at taint time 246 // TODO: decide if this parent checking needs to happen at taint time
250 // Race condition here: if link() and delink() in same simulation tick, the delink will not happen 247 // Race condition here: if link() and delink() in same simulation tick, the delink will not happen
251 DebugLog("{0}: delink {1}/{2}. Parent={3}", LogHeader, _avName, _localID,
252 _linkset.LinksetRoot._avName+"/"+_linkset.LinksetRoot.LocalID.ToString());
253 248
254 BSPrim parentBefore = _linkset.LinksetRoot; 249 BSPrim parentBefore = _linkset.LinksetRoot;
255 int childrenBefore = _linkset.NumberOfChildren; 250 int childrenBefore = _linkset.NumberOfChildren;
@@ -280,7 +275,7 @@ public sealed class BSPrim : PhysicsActor
280 275
281 public override void LockAngularMotion(OMV.Vector3 axis) 276 public override void LockAngularMotion(OMV.Vector3 axis)
282 { 277 {
283 // DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis); 278 DetailLog("{0},BSPrim.LockAngularMotion,call,axis={1}", LocalID, axis);
284 return; 279 return;
285 } 280 }
286 281
@@ -299,7 +294,7 @@ public sealed class BSPrim : PhysicsActor
299 // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint? 294 // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint?
300 _scene.TaintedObject("BSPrim.setPosition", delegate() 295 _scene.TaintedObject("BSPrim.setPosition", delegate()
301 { 296 {
302 // DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); 297 DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation);
303 BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); 298 BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
304 }); 299 });
305 } 300 }
@@ -336,7 +331,7 @@ public sealed class BSPrim : PhysicsActor
336 _force = value; 331 _force = value;
337 _scene.TaintedObject("BSPrim.setForce", delegate() 332 _scene.TaintedObject("BSPrim.setForce", delegate()
338 { 333 {
339 // DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force); 334 DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force);
340 // BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); 335 // BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force);
341 BulletSimAPI.SetObjectForce2(Body.Ptr, _force); 336 BulletSimAPI.SetObjectForce2(Body.Ptr, _force);
342 }); 337 });
@@ -354,7 +349,7 @@ public sealed class BSPrim : PhysicsActor
354 { 349 {
355 // Done at taint time so we're sure the physics engine is not using the variables 350 // Done at taint time so we're sure the physics engine is not using the variables
356 // Vehicle code changes the parameters for this vehicle type. 351 // Vehicle code changes the parameters for this vehicle type.
357 _vehicle.ProcessTypeChange(type); 352 _vehicle.ProcessTypeChange(type, Scene.LastSimulatedTimestep);
358 // Tell the scene about the vehicle so it will get processing each frame. 353 // Tell the scene about the vehicle so it will get processing each frame.
359 _scene.VehicleInSceneTypeChanged(this, type); 354 _scene.VehicleInSceneTypeChanged(this, type);
360 }); 355 });
@@ -414,7 +409,7 @@ public sealed class BSPrim : PhysicsActor
414 _velocity = value; 409 _velocity = value;
415 _scene.TaintedObject("BSPrim.setVelocity", delegate() 410 _scene.TaintedObject("BSPrim.setVelocity", delegate()
416 { 411 {
417 // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity); 412 DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity);
418 BulletSimAPI.SetObjectVelocity(_scene.WorldID, LocalID, _velocity); 413 BulletSimAPI.SetObjectVelocity(_scene.WorldID, LocalID, _velocity);
419 }); 414 });
420 } 415 }
@@ -422,7 +417,7 @@ public sealed class BSPrim : PhysicsActor
422 public override OMV.Vector3 Torque { 417 public override OMV.Vector3 Torque {
423 get { return _torque; } 418 get { return _torque; }
424 set { _torque = value; 419 set { _torque = value;
425 // DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque); 420 DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque);
426 } 421 }
427 } 422 }
428 public override float CollisionScore { 423 public override float CollisionScore {
@@ -449,7 +444,7 @@ public sealed class BSPrim : PhysicsActor
449 _scene.TaintedObject("BSPrim.setOrientation", delegate() 444 _scene.TaintedObject("BSPrim.setOrientation", delegate()
450 { 445 {
451 // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); 446 // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID);
452 // DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); 447 DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation);
453 BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation); 448 BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
454 }); 449 });
455 } 450 }
@@ -486,11 +481,8 @@ public sealed class BSPrim : PhysicsActor
486 // No locking here because only called when it is safe 481 // No locking here because only called when it is safe
487 private void SetObjectDynamic() 482 private void SetObjectDynamic()
488 { 483 {
489 // RA: remove this for the moment. 484 // If it's becoming dynamic, it will need hullness
490 // The problem is that dynamic objects are hulls so if we are becoming physical 485 VerifyCorrectPhysicalShape();
491 // the shape has to be checked and possibly built.
492 // Maybe a VerifyCorrectPhysicalShape() routine?
493 // RecreateGeomAndObject();
494 486
495 // Bullet wants static objects to have a mass of zero 487 // Bullet wants static objects to have a mass of zero
496 float mass = IsStatic ? 0f : _mass; 488 float mass = IsStatic ? 0f : _mass;
@@ -501,13 +493,15 @@ public sealed class BSPrim : PhysicsActor
501 _linkset.Refresh(this); 493 _linkset.Refresh(this);
502 494
503 CollisionFlags cf = BulletSimAPI.GetCollisionFlags2(Body.Ptr); 495 CollisionFlags cf = BulletSimAPI.GetCollisionFlags2(Body.Ptr);
504 // DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}, cf={4}", LocalID, IsStatic, IsSolid, mass, cf); 496 DetailLog("{0},BSPrim.SetObjectDynamic,taint,static={1},solid={2},mass={3}, cf={4}", LocalID, IsStatic, IsSolid, mass, cf);
505 } 497 }
506 498
507 // prims don't fly 499 // prims don't fly
508 public override bool Flying { 500 public override bool Flying {
509 get { return _flying; } 501 get { return _flying; }
510 set { _flying = value; } 502 set {
503 _flying = value;
504 }
511 } 505 }
512 public override bool SetAlwaysRun { 506 public override bool SetAlwaysRun {
513 get { return _setAlwaysRun; } 507 get { return _setAlwaysRun; }
@@ -558,7 +552,7 @@ public sealed class BSPrim : PhysicsActor
558 // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); 552 // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity);
559 _scene.TaintedObject("BSPrim.setRotationalVelocity", delegate() 553 _scene.TaintedObject("BSPrim.setRotationalVelocity", delegate()
560 { 554 {
561 // DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); 555 DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
562 BulletSimAPI.SetObjectAngularVelocity(_scene.WorldID, LocalID, _rotationalVelocity); 556 BulletSimAPI.SetObjectAngularVelocity(_scene.WorldID, LocalID, _rotationalVelocity);
563 }); 557 });
564 } 558 }
@@ -575,7 +569,7 @@ public sealed class BSPrim : PhysicsActor
575 _buoyancy = value; 569 _buoyancy = value;
576 _scene.TaintedObject("BSPrim.setBuoyancy", delegate() 570 _scene.TaintedObject("BSPrim.setBuoyancy", delegate()
577 { 571 {
578 // DetailLog("{0},BSPrim.SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy); 572 DetailLog("{0},BSPrim.SetBuoyancy,taint,buoy={1}", LocalID, _buoyancy);
579 BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy); 573 BulletSimAPI.SetObjectBuoyancy(_scene.WorldID, _localID, _buoyancy);
580 }); 574 });
581 } 575 }
@@ -638,17 +632,17 @@ public sealed class BSPrim : PhysicsActor
638 } 632 }
639 m_accumulatedForces.Clear(); 633 m_accumulatedForces.Clear();
640 } 634 }
641 // DetailLog("{0},BSPrim.AddObjectForce,taint,force={1}", LocalID, _force); 635 DetailLog("{0},BSPrim.AddObjectForce,taint,force={1}", LocalID, _force);
642 BulletSimAPI.AddObjectForce2(Body.Ptr, fSum); 636 BulletSimAPI.AddObjectForce2(Body.Ptr, fSum);
643 }); 637 });
644 } 638 }
645 639
646 public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { 640 public override void AddAngularForce(OMV.Vector3 force, bool pushforce) {
647 // DetailLog("{0},BSPrim.AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce); 641 DetailLog("{0},BSPrim.AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce);
648 // m_log.DebugFormat("{0}: AddAngularForce. f={1}, push={2}", LogHeader, force, pushforce); 642 // m_log.DebugFormat("{0}: AddAngularForce. f={1}, push={2}", LogHeader, force, pushforce);
649 } 643 }
650 public override void SetMomentum(OMV.Vector3 momentum) { 644 public override void SetMomentum(OMV.Vector3 momentum) {
651 // DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum); 645 DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum);
652 } 646 }
653 public override void SubscribeEvents(int ms) { 647 public override void SubscribeEvents(int ms) {
654 _subscribedEventsMs = ms; 648 _subscribedEventsMs = ms;
@@ -992,7 +986,7 @@ public sealed class BSPrim : PhysicsActor
992 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size); 986 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size);
993 if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_SPHERE)) 987 if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_SPHERE))
994 { 988 {
995 // DetailLog("{0},BSPrim.CreateGeom,sphere (force={1}", LocalID, forceRebuild); 989 DetailLog("{0},BSPrim.CreateGeom,sphere (force={1}", LocalID, forceRebuild);
996 _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE; 990 _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE;
997 // Bullet native objects are scaled by the Bullet engine so pass the size in 991 // Bullet native objects are scaled by the Bullet engine so pass the size in
998 _scale = _size; 992 _scale = _size;
@@ -1006,7 +1000,7 @@ public sealed class BSPrim : PhysicsActor
1006 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, type={2}, size={3}", LogHeader, LocalID, _shapeType, _size); 1000 // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, type={2}, size={3}", LogHeader, LocalID, _shapeType, _size);
1007 if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_BOX)) 1001 if (forceRebuild || (_shapeType != ShapeData.PhysicsShapeType.SHAPE_BOX))
1008 { 1002 {
1009 // DetailLog("{0},BSPrim.CreateGeom,box (force={1})", LocalID, forceRebuild); 1003 DetailLog("{0},BSPrim.CreateGeom,box (force={1})", LocalID, forceRebuild);
1010 _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX; 1004 _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX;
1011 _scale = _size; 1005 _scale = _size;
1012 // TODO: do we need to check for and destroy a mesh or hull that might have been left from before? 1006 // TODO: do we need to check for and destroy a mesh or hull that might have been left from before?
@@ -1042,19 +1036,26 @@ public sealed class BSPrim : PhysicsActor
1042 // No locking here because this is done when we know physics is not simulating 1036 // No locking here because this is done when we know physics is not simulating
1043 private void CreateGeomMesh() 1037 private void CreateGeomMesh()
1044 { 1038 {
1045 float lod = _pbs.SculptEntry ? _scene.SculptLOD : _scene.MeshLOD; 1039 // level of detail based on size and type of the object
1040 float lod = _scene.MeshLOD;
1041 if (_pbs.SculptEntry)
1042 lod = _scene.SculptLOD;
1043 float maxAxis = Math.Max(_size.X, Math.Max(_size.Y, _size.Z));
1044 if (maxAxis > _scene.MeshMegaPrimThreshold)
1045 lod = _scene.MeshMegaPrimLOD;
1046
1046 ulong newMeshKey = (ulong)_pbs.GetMeshKey(_size, lod); 1047 ulong newMeshKey = (ulong)_pbs.GetMeshKey(_size, lod);
1047 // m_log.DebugFormat("{0}: CreateGeomMesh: lID={1}, oldKey={2}, newKey={3}", LogHeader, _localID, _meshKey, newMeshKey); 1048 // m_log.DebugFormat("{0}: CreateGeomMesh: lID={1}, oldKey={2}, newKey={3}", LogHeader, _localID, _meshKey, newMeshKey);
1048 1049
1049 // if this new shape is the same as last time, don't recreate the mesh 1050 // if this new shape is the same as last time, don't recreate the mesh
1050 if (_meshKey == newMeshKey) return; 1051 if (_meshKey == newMeshKey) return;
1051 1052
1052 // DetailLog("{0},BSPrim.CreateGeomMesh,create,key={1}", LocalID, newMeshKey); 1053 DetailLog("{0},BSPrim.CreateGeomMesh,create,key={1}", LocalID, newMeshKey);
1053 // Since we're recreating new, get rid of any previously generated shape 1054 // Since we're recreating new, get rid of any previously generated shape
1054 if (_meshKey != 0) 1055 if (_meshKey != 0)
1055 { 1056 {
1056 // m_log.DebugFormat("{0}: CreateGeom: deleting old mesh. lID={1}, Key={2}", LogHeader, _localID, _meshKey); 1057 // m_log.DebugFormat("{0}: CreateGeom: deleting old mesh. lID={1}, Key={2}", LogHeader, _localID, _meshKey);
1057 // DetailLog("{0},BSPrim.CreateGeomMesh,deleteOld,key={1}", LocalID, _meshKey); 1058 DetailLog("{0},BSPrim.CreateGeomMesh,deleteOld,key={1}", LocalID, _meshKey);
1058 BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey); 1059 BulletSimAPI.DestroyMesh(_scene.WorldID, _meshKey);
1059 _mesh = null; 1060 _mesh = null;
1060 _meshKey = 0; 1061 _meshKey = 0;
@@ -1084,7 +1085,7 @@ public sealed class BSPrim : PhysicsActor
1084 _shapeType = ShapeData.PhysicsShapeType.SHAPE_MESH; 1085 _shapeType = ShapeData.PhysicsShapeType.SHAPE_MESH;
1085 // meshes are already scaled by the meshmerizer 1086 // meshes are already scaled by the meshmerizer
1086 _scale = new OMV.Vector3(1f, 1f, 1f); 1087 _scale = new OMV.Vector3(1f, 1f, 1f);
1087 // DetailLog("{0},BSPrim.CreateGeomMesh,done", LocalID); 1088 DetailLog("{0},BSPrim.CreateGeomMesh,done", LocalID);
1088 return; 1089 return;
1089 } 1090 }
1090 1091
@@ -1098,13 +1099,13 @@ public sealed class BSPrim : PhysicsActor
1098 // if the hull hasn't changed, don't rebuild it 1099 // if the hull hasn't changed, don't rebuild it
1099 if (newHullKey == _hullKey) return; 1100 if (newHullKey == _hullKey) return;
1100 1101
1101 // DetailLog("{0},BSPrim.CreateGeomHull,create,oldKey={1},newKey={2}", LocalID, _hullKey, newHullKey); 1102 DetailLog("{0},BSPrim.CreateGeomHull,create,oldKey={1},newKey={2}", LocalID, _hullKey, newHullKey);
1102 1103
1103 // Since we're recreating new, get rid of any previously generated shape 1104 // Since we're recreating new, get rid of any previously generated shape
1104 if (_hullKey != 0) 1105 if (_hullKey != 0)
1105 { 1106 {
1106 // m_log.DebugFormat("{0}: CreateGeom: deleting old hull. Key={1}", LogHeader, _hullKey); 1107 // m_log.DebugFormat("{0}: CreateGeom: deleting old hull. Key={1}", LogHeader, _hullKey);
1107 // DetailLog("{0},BSPrim.CreateGeomHull,deleteOldHull,key={1}", LocalID, _hullKey); 1108 DetailLog("{0},BSPrim.CreateGeomHull,deleteOldHull,key={1}", LocalID, _hullKey);
1108 BulletSimAPI.DestroyHull(_scene.WorldID, _hullKey); 1109 BulletSimAPI.DestroyHull(_scene.WorldID, _hullKey);
1109 _hullKey = 0; 1110 _hullKey = 0;
1110 } 1111 }
@@ -1198,7 +1199,7 @@ public sealed class BSPrim : PhysicsActor
1198 _shapeType = ShapeData.PhysicsShapeType.SHAPE_HULL; 1199 _shapeType = ShapeData.PhysicsShapeType.SHAPE_HULL;
1199 // meshes are already scaled by the meshmerizer 1200 // meshes are already scaled by the meshmerizer
1200 _scale = new OMV.Vector3(1f, 1f, 1f); 1201 _scale = new OMV.Vector3(1f, 1f, 1f);
1201 // DetailLog("{0},BSPrim.CreateGeomHull,done", LocalID); 1202 DetailLog("{0},BSPrim.CreateGeomHull,done", LocalID);
1202 return; 1203 return;
1203 } 1204 }
1204 1205
@@ -1210,6 +1211,27 @@ public sealed class BSPrim : PhysicsActor
1210 return; 1211 return;
1211 } 1212 }
1212 1213
1214 private void VerifyCorrectPhysicalShape()
1215 {
1216 if (IsStatic)
1217 {
1218 // if static, we don't need a hull so, if there is one, rebuild without it
1219 if (_hullKey != 0)
1220 {
1221 RecreateGeomAndObject();
1222 }
1223 }
1224 else
1225 {
1226 // if not static, it will need a hull to efficiently collide with things
1227 if (_hullKey == 0)
1228 {
1229 RecreateGeomAndObject();
1230 }
1231
1232 }
1233 }
1234
1213 // Create an object in Bullet if it has not already been created 1235 // Create an object in Bullet if it has not already been created
1214 // No locking here because this is done when the physics engine is not simulating 1236 // No locking here because this is done when the physics engine is not simulating
1215 // Returns 'true' if an object was actually created. 1237 // Returns 'true' if an object was actually created.
@@ -1334,10 +1356,8 @@ public sealed class BSPrim : PhysicsActor
1334 _acceleration = entprop.Acceleration; 1356 _acceleration = entprop.Acceleration;
1335 _rotationalVelocity = entprop.RotationalVelocity; 1357 _rotationalVelocity = entprop.RotationalVelocity;
1336 1358
1337 // m_log.DebugFormat("{0}: RequestTerseUpdate. id={1}, ch={2}, pos={3}, rot={4}, vel={5}, acc={6}, rvel={7}", 1359 DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
1338 // LogHeader, LocalID, changed, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); 1360 LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity);
1339 // DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
1340 // LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity);
1341 1361
1342 base.RequestPhysicsterseUpdate(); 1362 base.RequestPhysicsterseUpdate();
1343 } 1363 }
@@ -1353,6 +1373,7 @@ public sealed class BSPrim : PhysicsActor
1353 } 1373 }
1354 1374
1355 // I've collided with something 1375 // I've collided with something
1376 // Called at taint time from within the Step() function
1356 CollisionEventUpdate collisionCollection; 1377 CollisionEventUpdate collisionCollection;
1357 public void Collide(uint collidingWith, ActorTypes type, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth) 1378 public void Collide(uint collidingWith, ActorTypes type, OMV.Vector3 contactPoint, OMV.Vector3 contactNormal, float pentrationDepth)
1358 { 1379 {
@@ -1366,6 +1387,15 @@ public sealed class BSPrim : PhysicsActor
1366 } 1387 }
1367 1388
1368 // DetailLog("{0},BSPrim.Collison,call,with={1}", LocalID, collidingWith); 1389 // DetailLog("{0},BSPrim.Collison,call,with={1}", LocalID, collidingWith);
1390 BSPrim collidingWithPrim;
1391 if (_scene.Prims.TryGetValue(collidingWith, out collidingWithPrim))
1392 {
1393 // prims in the same linkset cannot collide with each other
1394 if (this.Linkset.LinksetID == collidingWithPrim.Linkset.LinksetID)
1395 {
1396 return;
1397 }
1398 }
1369 1399
1370 // if someone is subscribed to collision events.... 1400 // if someone is subscribed to collision events....
1371 if (_subscribedEventsMs != 0) { 1401 if (_subscribedEventsMs != 0) {
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
index a31c578..56924aa 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs
@@ -73,15 +73,22 @@ public class BSScene : PhysicsScene, IPhysicsParameters
73 private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 73 private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
74 private static readonly string LogHeader = "[BULLETS SCENE]"; 74 private static readonly string LogHeader = "[BULLETS SCENE]";
75 75
76 public void DebugLog(string mm, params Object[] xx) { if (ShouldDebugLog) m_log.DebugFormat(mm, xx); } 76 // The name of the region we're working for.
77 public string RegionName { get; private set; }
77 78
78 public string BulletSimVersion = "?"; 79 public string BulletSimVersion = "?";
79 80
80 private Dictionary<uint, BSCharacter> m_avatars = new Dictionary<uint, BSCharacter>(); 81 private Dictionary<uint, BSCharacter> m_avatars = new Dictionary<uint, BSCharacter>();
82 public Dictionary<uint, BSCharacter> Characters { get { return m_avatars; } }
83
81 private Dictionary<uint, BSPrim> m_prims = new Dictionary<uint, BSPrim>(); 84 private Dictionary<uint, BSPrim> m_prims = new Dictionary<uint, BSPrim>();
85 public Dictionary<uint, BSPrim> Prims { get { return m_prims; } }
86
82 private HashSet<BSCharacter> m_avatarsWithCollisions = new HashSet<BSCharacter>(); 87 private HashSet<BSCharacter> m_avatarsWithCollisions = new HashSet<BSCharacter>();
83 private HashSet<BSPrim> m_primsWithCollisions = new HashSet<BSPrim>(); 88 private HashSet<BSPrim> m_primsWithCollisions = new HashSet<BSPrim>();
89
84 private List<BSPrim> m_vehicles = new List<BSPrim>(); 90 private List<BSPrim> m_vehicles = new List<BSPrim>();
91
85 private float[] m_heightMap; 92 private float[] m_heightMap;
86 private float m_waterLevel; 93 private float m_waterLevel;
87 private uint m_worldID; 94 private uint m_worldID;
@@ -95,16 +102,11 @@ public class BSScene : PhysicsScene, IPhysicsParameters
95 private int m_detailedStatsStep = 0; 102 private int m_detailedStatsStep = 0;
96 103
97 public IMesher mesher; 104 public IMesher mesher;
98 private float m_meshLOD; 105 // Level of Detail values kept as float because that's what the Meshmerizer wants
99 public float MeshLOD 106 public float MeshLOD { get; private set; }
100 { 107 public float MeshMegaPrimLOD { get; private set; }
101 get { return m_meshLOD; } 108 public float MeshMegaPrimThreshold { get; private set; }
102 } 109 public float SculptLOD { get; private set; }
103 private float m_sculptLOD;
104 public float SculptLOD
105 {
106 get { return m_sculptLOD; }
107 }
108 110
109 private BulletSim m_worldSim; 111 private BulletSim m_worldSim;
110 public BulletSim World 112 public BulletSim World
@@ -179,8 +181,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters
179 ConfigurationParameters[] m_params; 181 ConfigurationParameters[] m_params;
180 GCHandle m_paramsHandle; 182 GCHandle m_paramsHandle;
181 183
182 public bool ShouldDebugLog { get; private set; } 184 // Handle to the callback used by the unmanaged code to call into the managed code.
183 185 // Used for debug logging.
186 // Need to store the handle in a persistant variable so it won't be freed.
184 private BulletSimAPI.DebugLogCallback m_DebugLogCallbackHandle; 187 private BulletSimAPI.DebugLogCallback m_DebugLogCallbackHandle;
185 188
186 // Sometimes you just have to log everything. 189 // Sometimes you just have to log everything.
@@ -196,6 +199,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
196 public BSScene(string identifier) 199 public BSScene(string identifier)
197 { 200 {
198 m_initialized = false; 201 m_initialized = false;
202 // we are passed the name of the region we're working for.
203 RegionName = identifier;
199 } 204 }
200 205
201 public override void Initialise(IMesher meshmerizer, IConfigSource config) 206 public override void Initialise(IMesher meshmerizer, IConfigSource config)
@@ -281,10 +286,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters
281 // Very detailed logging for physics debugging 286 // Very detailed logging for physics debugging
282 m_physicsLoggingEnabled = pConfig.GetBoolean("PhysicsLoggingEnabled", false); 287 m_physicsLoggingEnabled = pConfig.GetBoolean("PhysicsLoggingEnabled", false);
283 m_physicsLoggingDir = pConfig.GetString("PhysicsLoggingDir", "."); 288 m_physicsLoggingDir = pConfig.GetString("PhysicsLoggingDir", ".");
284 m_physicsLoggingPrefix = pConfig.GetString("PhysicsLoggingPrefix", "physics-"); 289 m_physicsLoggingPrefix = pConfig.GetString("PhysicsLoggingPrefix", "physics-%REGIONNAME%-");
285 m_physicsLoggingFileMinutes = pConfig.GetInt("PhysicsLoggingFileMinutes", 5); 290 m_physicsLoggingFileMinutes = pConfig.GetInt("PhysicsLoggingFileMinutes", 5);
286 // Very detailed logging for vehicle debugging 291 // Very detailed logging for vehicle debugging
287 m_vehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false); 292 m_vehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false);
293
294 // Do any replacements in the parameters
295 m_physicsLoggingPrefix = m_physicsLoggingPrefix.Replace("%REGIONNAME%", RegionName);
288 } 296 }
289 } 297 }
290 } 298 }
@@ -362,7 +370,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
362 BSPrim bsprim = prim as BSPrim; 370 BSPrim bsprim = prim as BSPrim;
363 if (bsprim != null) 371 if (bsprim != null)
364 { 372 {
365 // DetailLog("{0},RemovePrim,call", bsprim.LocalID); 373 DetailLog("{0},RemovePrim,call", bsprim.LocalID);
366 // m_log.DebugFormat("{0}: RemovePrim. id={1}/{2}", LogHeader, bsprim.Name, bsprim.LocalID); 374 // m_log.DebugFormat("{0}: RemovePrim. id={1}/{2}", LogHeader, bsprim.Name, bsprim.LocalID);
367 try 375 try
368 { 376 {
@@ -388,7 +396,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters
388 396
389 if (!m_initialized) return null; 397 if (!m_initialized) return null;
390 398
391 // DetailLog("{0},AddPrimShape,call", localID); 399 DetailLog("{0},AddPrimShape,call", localID);
392 400
393 BSPrim prim = new BSPrim(localID, primName, this, position, size, rotation, pbs, isPhysical); 401 BSPrim prim = new BSPrim(localID, primName, this, position, size, rotation, pbs, isPhysical);
394 lock (m_prims) m_prims.Add(localID, prim); 402 lock (m_prims) m_prims.Add(localID, prim);
@@ -429,13 +437,13 @@ public class BSScene : PhysicsScene, IPhysicsParameters
429 { 437 {
430 numSubSteps = BulletSimAPI.PhysicsStep(m_worldID, timeStep, m_maxSubSteps, m_fixedTimeStep, 438 numSubSteps = BulletSimAPI.PhysicsStep(m_worldID, timeStep, m_maxSubSteps, m_fixedTimeStep,
431 out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr); 439 out updatedEntityCount, out updatedEntitiesPtr, out collidersCount, out collidersPtr);
432 // DetailLog("{0},Simulate,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount); 440 DetailLog("{0},Simulate,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount);
433 } 441 }
434 catch (Exception e) 442 catch (Exception e)
435 { 443 {
436 m_log.WarnFormat("{0},PhysicsStep Exception: substeps={1}, updates={2}, colliders={3}, e={4}", LogHeader, numSubSteps, updatedEntityCount, collidersCount, e); 444 m_log.WarnFormat("{0},PhysicsStep Exception: substeps={1}, updates={2}, colliders={3}, e={4}", LogHeader, numSubSteps, updatedEntityCount, collidersCount, e);
437 // DetailLog("{0},PhysicsStepException,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount); 445 // DetailLog("{0},PhysicsStepException,call, substeps={1}, updates={2}, colliders={3}", DetailLogZero, numSubSteps, updatedEntityCount, collidersCount);
438 // updatedEntityCount = 0; 446 updatedEntityCount = 0;
439 collidersCount = 0; 447 collidersCount = 0;
440 } 448 }
441 449
@@ -534,6 +542,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters
534 else if (m_avatars.ContainsKey(collidingWith)) 542 else if (m_avatars.ContainsKey(collidingWith))
535 type = ActorTypes.Agent; 543 type = ActorTypes.Agent;
536 544
545 // DetailLog("{0},BSScene.SendCollision,collide,id={1},with={2}", DetailLogZero, localID, collidingWith);
546
537 BSPrim prim; 547 BSPrim prim;
538 if (m_prims.TryGetValue(localID, out prim)) { 548 if (m_prims.TryGetValue(localID, out prim)) {
539 prim.Collide(collidingWith, type, collidePoint, collideNormal, penitration); 549 prim.Collide(collidingWith, type, collidePoint, collideNormal, penitration);
@@ -897,16 +907,26 @@ public class BSScene : PhysicsScene, IPhysicsParameters
897 (s) => { return s.NumericBool(s._forceSimplePrimMeshing); }, 907 (s) => { return s.NumericBool(s._forceSimplePrimMeshing); },
898 (s,p,l,v) => { s._forceSimplePrimMeshing = s.BoolNumeric(v); } ), 908 (s,p,l,v) => { s._forceSimplePrimMeshing = s.BoolNumeric(v); } ),
899 909
900 new ParameterDefn("MeshLOD", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)", 910 new ParameterDefn("MeshLevelOfDetail", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)",
901 8f, 911 8f,
902 (s,cf,p,v) => { s.m_meshLOD = cf.GetInt(p, (int)v); }, 912 (s,cf,p,v) => { s.MeshLOD = (float)cf.GetInt(p, (int)v); },
903 (s) => { return (float)s.m_meshLOD; }, 913 (s) => { return s.MeshLOD; },
904 (s,p,l,v) => { s.m_meshLOD = (int)v; } ), 914 (s,p,l,v) => { s.MeshLOD = v; } ),
905 new ParameterDefn("SculptLOD", "Level of detail to render sculpties (32, 16, 8 or 4. 32=most detailed)", 915 new ParameterDefn("MeshLevelOfDetailMegaPrim", "Level of detail to render meshes larger than threshold meters",
916 16f,
917 (s,cf,p,v) => { s.MeshMegaPrimLOD = (float)cf.GetInt(p, (int)v); },
918 (s) => { return s.MeshMegaPrimLOD; },
919 (s,p,l,v) => { s.MeshMegaPrimLOD = v; } ),
920 new ParameterDefn("MeshLevelOfDetailMegaPrimThreshold", "Size (in meters) of a mesh before using MeshMegaPrimLOD",
921 10f,
922 (s,cf,p,v) => { s.MeshMegaPrimThreshold = (float)cf.GetInt(p, (int)v); },
923 (s) => { return s.MeshMegaPrimThreshold; },
924 (s,p,l,v) => { s.MeshMegaPrimThreshold = v; } ),
925 new ParameterDefn("SculptLevelOfDetail", "Level of detail to render sculpties (32, 16, 8 or 4. 32=most detailed)",
906 32f, 926 32f,
907 (s,cf,p,v) => { s.m_sculptLOD = cf.GetInt(p, (int)v); }, 927 (s,cf,p,v) => { s.SculptLOD = (float)cf.GetInt(p, (int)v); },
908 (s) => { return (float)s.m_sculptLOD; }, 928 (s) => { return s.SculptLOD; },
909 (s,p,l,v) => { s.m_sculptLOD = (int)v; } ), 929 (s,p,l,v) => { s.SculptLOD = v; } ),
910 930
911 new ParameterDefn("MaxSubStep", "In simulation step, maximum number of substeps", 931 new ParameterDefn("MaxSubStep", "In simulation step, maximum number of substeps",
912 10f, 932 10f,
@@ -1137,12 +1157,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters
1137 (s,cf,p,v) => { s.m_detailedStatsStep = cf.GetInt(p, (int)v); }, 1157 (s,cf,p,v) => { s.m_detailedStatsStep = cf.GetInt(p, (int)v); },
1138 (s) => { return (float)s.m_detailedStatsStep; }, 1158 (s) => { return (float)s.m_detailedStatsStep; },
1139 (s,p,l,v) => { s.m_detailedStatsStep = (int)v; } ), 1159 (s,p,l,v) => { s.m_detailedStatsStep = (int)v; } ),
1140 new ParameterDefn("ShouldDebugLog", "Enables detailed DEBUG log statements",
1141 ConfigurationParameters.numericFalse,
1142 (s,cf,p,v) => { s.ShouldDebugLog = cf.GetBoolean(p, s.BoolNumeric(v)); },
1143 (s) => { return s.NumericBool(s.ShouldDebugLog); },
1144 (s,p,l,v) => { s.ShouldDebugLog = s.BoolNumeric(v); } ),
1145
1146 }; 1160 };
1147 1161
1148 // Convert a boolean to our numeric true and false values 1162 // Convert a boolean to our numeric true and false values
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 3e1b43e..0c7f49b 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -426,14 +426,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
426 return key; 426 return key;
427 } 427 }
428 428
429 // convert a LSL_Rotation to a Quaternion
430 public static Quaternion Rot2Quaternion(LSL_Rotation r)
431 {
432 Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
433 q.Normalize();
434 return q;
435 }
436
437 //These are the implementations of the various ll-functions used by the LSL scripts. 429 //These are the implementations of the various ll-functions used by the LSL scripts.
438 public LSL_Float llSin(double f) 430 public LSL_Float llSin(double f)
439 { 431 {
@@ -1240,9 +1232,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1240 public LSL_Float llGround(LSL_Vector offset) 1232 public LSL_Float llGround(LSL_Vector offset)
1241 { 1233 {
1242 m_host.AddScriptLPS(1); 1234 m_host.AddScriptLPS(1);
1243 Vector3 pos = m_host.GetWorldPosition() + new Vector3((float)offset.x, 1235 Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset;
1244 (float)offset.y,
1245 (float)offset.z);
1246 1236
1247 //Get the slope normal. This gives us the equation of the plane tangent to the slope. 1237 //Get the slope normal. This gives us the equation of the plane tangent to the slope.
1248 LSL_Vector vsn = llGroundNormal(offset); 1238 LSL_Vector vsn = llGroundNormal(offset);
@@ -1492,31 +1482,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1492 if (part == null || part.ParentGroup.IsDeleted) 1482 if (part == null || part.ParentGroup.IsDeleted)
1493 return; 1483 return;
1494 1484
1495 if (scale.x < 0.01) 1485 // First we need to check whether or not we need to clamp the size of a physics-enabled prim
1496 scale.x = 0.01;
1497 if (scale.y < 0.01)
1498 scale.y = 0.01;
1499 if (scale.z < 0.01)
1500 scale.z = 0.01;
1501
1502 PhysicsActor pa = part.ParentGroup.RootPart.PhysActor; 1486 PhysicsActor pa = part.ParentGroup.RootPart.PhysActor;
1503
1504 if (pa != null && pa.IsPhysical) 1487 if (pa != null && pa.IsPhysical)
1505 { 1488 {
1506 if (scale.x > World.m_maxPhys) 1489 scale.x = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.x));
1507 scale.x = World.m_maxPhys; 1490 scale.y = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.y));
1508 if (scale.y > World.m_maxPhys) 1491 scale.z = Math.Max(World.m_minPhys, Math.Min(World.m_maxPhys, scale.z));
1509 scale.y = World.m_maxPhys; 1492 }
1510 if (scale.z > World.m_maxPhys) 1493 else
1511 scale.z = World.m_maxPhys; 1494 {
1495 // If not physical, then we clamp the scale to the non-physical min/max
1496 scale.x = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.x));
1497 scale.y = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.y));
1498 scale.z = Math.Max(World.m_minNonphys, Math.Min(World.m_maxNonphys, scale.z));
1512 } 1499 }
1513
1514 if (scale.x > World.m_maxNonphys)
1515 scale.x = World.m_maxNonphys;
1516 if (scale.y > World.m_maxNonphys)
1517 scale.y = World.m_maxNonphys;
1518 if (scale.z > World.m_maxNonphys)
1519 scale.z = World.m_maxNonphys;
1520 1500
1521 Vector3 tmp = part.Scale; 1501 Vector3 tmp = part.Scale;
1522 tmp.X = (float)scale.x; 1502 tmp.X = (float)scale.x;
@@ -1590,7 +1570,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1590 if (face == ScriptBaseClass.ALL_SIDES) 1570 if (face == ScriptBaseClass.ALL_SIDES)
1591 face = SceneObjectPart.ALL_SIDES; 1571 face = SceneObjectPart.ALL_SIDES;
1592 1572
1593 m_host.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); 1573 m_host.SetFaceColorAlpha(face, color, null);
1594 } 1574 }
1595 1575
1596 public void SetTexGen(SceneObjectPart part, int face,int style) 1576 public void SetTexGen(SceneObjectPart part, int face,int style)
@@ -2220,7 +2200,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2220 2200
2221 bool sameParcel = here.GlobalID == there.GlobalID; 2201 bool sameParcel = here.GlobalID == there.GlobalID;
2222 2202
2223 if (!sameParcel && !World.Permissions.CanObjectEntry(m_host.UUID, false, new Vector3((float)pos.x, (float)pos.y, (float)pos.z))) 2203 if (!sameParcel && !World.Permissions.CanRezObject(
2204 m_host.ParentGroup.PrimCount, m_host.ParentGroup.OwnerID, pos))
2224 { 2205 {
2225 return 0; 2206 return 0;
2226 } 2207 }
@@ -2279,16 +2260,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2279 if (part.ParentGroup.RootPart == part) 2260 if (part.ParentGroup.RootPart == part)
2280 { 2261 {
2281 SceneObjectGroup parent = part.ParentGroup; 2262 SceneObjectGroup parent = part.ParentGroup;
2282 Vector3 dest = new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z); 2263 if (!World.Permissions.CanObjectEntry(parent.UUID, false, (Vector3)toPos))
2283 if (!World.Permissions.CanObjectEntry(parent.UUID, false, dest))
2284 return; 2264 return;
2285 Util.FireAndForget(delegate(object x) { 2265 Util.FireAndForget(delegate(object x) {
2286 parent.UpdateGroupPosition(dest); 2266 parent.UpdateGroupPosition((Vector3)toPos);
2287 }); 2267 });
2288 } 2268 }
2289 else 2269 else
2290 { 2270 {
2291 part.OffsetPosition = new Vector3((float)toPos.x, (float)toPos.y, (float)toPos.z); 2271 part.OffsetPosition = (Vector3)toPos;
2292 SceneObjectGroup parent = part.ParentGroup; 2272 SceneObjectGroup parent = part.ParentGroup;
2293 parent.HasGroupChanged = true; 2273 parent.HasGroupChanged = true;
2294 parent.ScheduleGroupForTerseUpdate(); 2274 parent.ScheduleGroupForTerseUpdate();
@@ -2326,7 +2306,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2326 pos = part.AbsolutePosition; 2306 pos = part.AbsolutePosition;
2327 } 2307 }
2328 2308
2329 return new LSL_Vector(pos.X, pos.Y, pos.Z); 2309// m_log.DebugFormat("[LSL API]: Returning {0} in GetPartLocalPos()", pos);
2310
2311 return new LSL_Vector(pos);
2330 } 2312 }
2331 2313
2332 public void llSetRot(LSL_Rotation rot) 2314 public void llSetRot(LSL_Rotation rot)
@@ -2343,7 +2325,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2343 // using it would cause attachments and HUDs to rotate 2325 // using it would cause attachments and HUDs to rotate
2344 // to the wrong positions. 2326 // to the wrong positions.
2345 2327
2346 SetRot(m_host, Rot2Quaternion(rot)); 2328 SetRot(m_host, rot);
2347 } 2329 }
2348 else 2330 else
2349 { 2331 {
@@ -2353,7 +2335,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2353 { 2335 {
2354 rootPart = m_host.ParentGroup.RootPart; 2336 rootPart = m_host.ParentGroup.RootPart;
2355 if (rootPart != null) 2337 if (rootPart != null)
2356 SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot)); 2338 SetRot(m_host, rootPart.RotationOffset * (Quaternion)rot);
2357 } 2339 }
2358 } 2340 }
2359 2341
@@ -2363,8 +2345,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2363 public void llSetLocalRot(LSL_Rotation rot) 2345 public void llSetLocalRot(LSL_Rotation rot)
2364 { 2346 {
2365 m_host.AddScriptLPS(1); 2347 m_host.AddScriptLPS(1);
2366 2348 SetRot(m_host, rot);
2367 SetRot(m_host, Rot2Quaternion(rot));
2368 ScriptSleep(200); 2349 ScriptSleep(200);
2369 } 2350 }
2370 2351
@@ -2476,7 +2457,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2476 if (local != 0) 2457 if (local != 0)
2477 force *= llGetRot(); 2458 force *= llGetRot();
2478 2459
2479 m_host.ParentGroup.RootPart.SetForce(new Vector3((float)force.x, (float)force.y, (float)force.z)); 2460 m_host.ParentGroup.RootPart.SetForce(force);
2480 } 2461 }
2481 } 2462 }
2482 2463
@@ -2488,10 +2469,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2488 2469
2489 if (!m_host.ParentGroup.IsDeleted) 2470 if (!m_host.ParentGroup.IsDeleted)
2490 { 2471 {
2491 Vector3 tmpForce = m_host.ParentGroup.RootPart.GetForce(); 2472 force = m_host.ParentGroup.RootPart.GetForce();
2492 force.x = tmpForce.X;
2493 force.y = tmpForce.Y;
2494 force.z = tmpForce.Z;
2495 } 2473 }
2496 2474
2497 return force; 2475 return force;
@@ -2500,8 +2478,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2500 public LSL_Integer llTarget(LSL_Vector position, double range) 2478 public LSL_Integer llTarget(LSL_Vector position, double range)
2501 { 2479 {
2502 m_host.AddScriptLPS(1); 2480 m_host.AddScriptLPS(1);
2503 return m_host.ParentGroup.registerTargetWaypoint( 2481 return m_host.ParentGroup.registerTargetWaypoint(position,
2504 new Vector3((float)position.x, (float)position.y, (float)position.z), (float)range); 2482 (float)range);
2505 } 2483 }
2506 2484
2507 public void llTargetRemove(int number) 2485 public void llTargetRemove(int number)
@@ -2513,8 +2491,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2513 public LSL_Integer llRotTarget(LSL_Rotation rot, double error) 2491 public LSL_Integer llRotTarget(LSL_Rotation rot, double error)
2514 { 2492 {
2515 m_host.AddScriptLPS(1); 2493 m_host.AddScriptLPS(1);
2516 return m_host.ParentGroup.registerRotTargetWaypoint( 2494 return m_host.ParentGroup.registerRotTargetWaypoint(rot, (float)error);
2517 new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), (float)error);
2518 } 2495 }
2519 2496
2520 public void llRotTargetRemove(int number) 2497 public void llRotTargetRemove(int number)
@@ -2526,7 +2503,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2526 public void llMoveToTarget(LSL_Vector target, double tau) 2503 public void llMoveToTarget(LSL_Vector target, double tau)
2527 { 2504 {
2528 m_host.AddScriptLPS(1); 2505 m_host.AddScriptLPS(1);
2529 m_host.MoveToTarget(new Vector3((float)target.x, (float)target.y, (float)target.z), (float)tau); 2506 m_host.MoveToTarget(target, (float)tau);
2530 } 2507 }
2531 2508
2532 public void llStopMoveToTarget() 2509 public void llStopMoveToTarget()
@@ -2539,7 +2516,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2539 { 2516 {
2540 m_host.AddScriptLPS(1); 2517 m_host.AddScriptLPS(1);
2541 //No energy force yet 2518 //No energy force yet
2542 Vector3 v = new Vector3((float)force.x, (float)force.y, (float)force.z); 2519 Vector3 v = force;
2543 if (v.Length() > 20000.0f) 2520 if (v.Length() > 20000.0f)
2544 { 2521 {
2545 v.Normalize(); 2522 v.Normalize();
@@ -2552,13 +2529,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2552 public void llApplyRotationalImpulse(LSL_Vector force, int local) 2529 public void llApplyRotationalImpulse(LSL_Vector force, int local)
2553 { 2530 {
2554 m_host.AddScriptLPS(1); 2531 m_host.AddScriptLPS(1);
2555 m_host.ParentGroup.RootPart.ApplyAngularImpulse(new Vector3((float)force.x, (float)force.y, (float)force.z), local != 0); 2532 m_host.ParentGroup.RootPart.ApplyAngularImpulse(force, local != 0);
2556 } 2533 }
2557 2534
2558 public void llSetTorque(LSL_Vector torque, int local) 2535 public void llSetTorque(LSL_Vector torque, int local)
2559 { 2536 {
2560 m_host.AddScriptLPS(1); 2537 m_host.AddScriptLPS(1);
2561 m_host.ParentGroup.RootPart.SetAngularImpulse(new Vector3((float)torque.x, (float)torque.y, (float)torque.z), local != 0); 2538 m_host.ParentGroup.RootPart.SetAngularImpulse(torque, local != 0);
2562 } 2539 }
2563 2540
2564 public LSL_Vector llGetTorque() 2541 public LSL_Vector llGetTorque()
@@ -3123,13 +3100,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3123 return; 3100 return;
3124 } 3101 }
3125 3102
3126 Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
3127 Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z);
3128
3129 // need the magnitude later 3103 // need the magnitude later
3130 // float velmag = (float)Util.GetMagnitude(llvel); 3104 // float velmag = (float)Util.GetMagnitude(llvel);
3131 3105
3132 SceneObjectGroup new_group = World.RezObject(m_host, item, llpos, Rot2Quaternion(rot), llvel, param); 3106 SceneObjectGroup new_group = World.RezObject(m_host, item, pos, rot, vel, param);
3133 3107
3134 // If either of these are null, then there was an unknown error. 3108 // If either of these are null, then there was an unknown error.
3135 if (new_group == null) 3109 if (new_group == null)
@@ -3156,11 +3130,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3156 3130
3157 PhysicsActor pa = new_group.RootPart.PhysActor; 3131 PhysicsActor pa = new_group.RootPart.PhysActor;
3158 3132
3159 if (pa != null && pa.IsPhysical && llvel != Vector3.Zero) 3133 if (pa != null && pa.IsPhysical && (Vector3)vel != Vector3.Zero)
3160 { 3134 {
3161 float groupmass = new_group.GetMass(); 3135 float groupmass = new_group.GetMass();
3162 llvel *= -groupmass; 3136 vel *= -groupmass;
3163 llApplyImpulse(new LSL_Vector(llvel.X, llvel.Y,llvel.Z), 0); 3137 llApplyImpulse(vel, 0);
3164 } 3138 }
3165 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay) 3139 // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
3166 return; 3140 return;
@@ -3211,7 +3185,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3211 return; 3185 return;
3212 } 3186 }
3213 3187
3214 m_host.StartLookAt(Rot2Quaternion(r3 * r2 * r1), (float)strength, (float)damping); 3188 m_host.StartLookAt((Quaternion)(r3 * r2 * r1), (float)strength, (float)damping);
3215 } 3189 }
3216 } 3190 }
3217 3191
@@ -3637,7 +3611,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3637 } 3611 }
3638 else 3612 else
3639 { 3613 {
3640 m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping); 3614 m_host.RotLookAt(target, (float)strength, (float)damping);
3641 } 3615 }
3642 } 3616 }
3643 3617
@@ -3718,7 +3692,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3718 3692
3719 protected void TargetOmega(SceneObjectPart part, LSL_Vector axis, double spinrate, double gain) 3693 protected void TargetOmega(SceneObjectPart part, LSL_Vector axis, double spinrate, double gain)
3720 { 3694 {
3721 part.UpdateAngularVelocity(new Vector3((float)(axis.x * spinrate), (float)(axis.y * spinrate), (float)(axis.z * spinrate))); 3695 part.UpdateAngularVelocity(axis * spinrate);
3722 } 3696 }
3723 3697
3724 public LSL_Integer llGetStartParameter() 3698 public LSL_Integer llGetStartParameter()
@@ -3928,7 +3902,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
3928 try 3902 try
3929 { 3903 {
3930 foreach (SceneObjectPart part in parts) 3904 foreach (SceneObjectPart part in parts)
3931 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); 3905 part.SetFaceColorAlpha(face, color, null);
3932 } 3906 }
3933 finally 3907 finally
3934 { 3908 {
@@ -4398,9 +4372,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4398 public void llSetText(string text, LSL_Vector color, double alpha) 4372 public void llSetText(string text, LSL_Vector color, double alpha)
4399 { 4373 {
4400 m_host.AddScriptLPS(1); 4374 m_host.AddScriptLPS(1);
4401 Vector3 av3 = new Vector3(Util.Clip((float)color.x, 0.0f, 1.0f), 4375 Vector3 av3 = Util.Clip(color, 0.0f, 1.0f);
4402 Util.Clip((float)color.y, 0.0f, 1.0f),
4403 Util.Clip((float)color.z, 0.0f, 1.0f));
4404 m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); 4376 m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f));
4405 //m_host.ParentGroup.HasGroupChanged = true; 4377 //m_host.ParentGroup.HasGroupChanged = true;
4406 //m_host.ParentGroup.ScheduleGroupForFullUpdate(); 4378 //m_host.ParentGroup.ScheduleGroupForFullUpdate();
@@ -4616,14 +4588,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4616 ScriptSleep(5000); 4588 ScriptSleep(5000);
4617 } 4589 }
4618 4590
4619 public void llTeleportAgent(string agent, string destination, LSL_Vector pos, LSL_Vector lookAt) 4591 public void llTeleportAgent(string agent, string destination, LSL_Vector targetPos, LSL_Vector targetLookAt)
4620 { 4592 {
4621 m_host.AddScriptLPS(1); 4593 m_host.AddScriptLPS(1);
4622 UUID agentId = new UUID(); 4594 UUID agentId = new UUID();
4623 4595
4624 Vector3 targetPos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
4625 Vector3 targetLookAt = new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z);
4626
4627 if (UUID.TryParse(agent, out agentId)) 4596 if (UUID.TryParse(agent, out agentId))
4628 { 4597 {
4629 ScenePresence presence = World.GetScenePresence(agentId); 4598 ScenePresence presence = World.GetScenePresence(agentId);
@@ -4652,15 +4621,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4652 } 4621 }
4653 } 4622 }
4654 4623
4655 public void llTeleportAgentGlobalCoords(string agent, LSL_Vector global_coords, LSL_Vector pos, LSL_Vector lookAt) 4624 public void llTeleportAgentGlobalCoords(string agent, LSL_Vector global_coords, LSL_Vector targetPos, LSL_Vector targetLookAt)
4656 { 4625 {
4657 m_host.AddScriptLPS(1); 4626 m_host.AddScriptLPS(1);
4658 UUID agentId = new UUID(); 4627 UUID agentId = new UUID();
4659 4628
4660 ulong regionHandle = Utils.UIntsToLong((uint)global_coords.x, (uint)global_coords.y); 4629 ulong regionHandle = Utils.UIntsToLong((uint)global_coords.x, (uint)global_coords.y);
4661 4630
4662 Vector3 targetPos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
4663 Vector3 targetLookAt = new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z);
4664 if (UUID.TryParse(agent, out agentId)) 4631 if (UUID.TryParse(agent, out agentId))
4665 { 4632 {
4666 ScenePresence presence = World.GetScenePresence(agentId); 4633 ScenePresence presence = World.GetScenePresence(agentId);
@@ -4957,7 +4924,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
4957 distance_attenuation = 1f / normalized_units; 4924 distance_attenuation = 1f / normalized_units;
4958 } 4925 }
4959 4926
4960 Vector3 applied_linear_impulse = new Vector3((float)impulse.x, (float)impulse.y, (float)impulse.z); 4927 Vector3 applied_linear_impulse = impulse;
4961 { 4928 {
4962 float impulse_length = applied_linear_impulse.Length(); 4929 float impulse_length = applied_linear_impulse.Length();
4963 4930
@@ -6525,9 +6492,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6525 6492
6526 //Plug the x,y coordinates of the slope normal into the equation of the plane to get 6493 //Plug the x,y coordinates of the slope normal into the equation of the plane to get
6527 //the height of that point on the plane. The resulting vector gives the slope. 6494 //the height of that point on the plane. The resulting vector gives the slope.
6528 Vector3 vsl = new Vector3(); 6495 Vector3 vsl = vsn;
6529 vsl.X = (float)vsn.x;
6530 vsl.Y = (float)vsn.y;
6531 vsl.Z = (float)(((vsn.x * vsn.x) + (vsn.y * vsn.y)) / (-1 * vsn.z)); 6496 vsl.Z = (float)(((vsn.x * vsn.x) + (vsn.y * vsn.y)) / (-1 * vsn.z));
6532 vsl.Normalize(); 6497 vsl.Normalize();
6533 //Normalization might be overkill here 6498 //Normalization might be overkill here
@@ -6538,9 +6503,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6538 public LSL_Vector llGroundNormal(LSL_Vector offset) 6503 public LSL_Vector llGroundNormal(LSL_Vector offset)
6539 { 6504 {
6540 m_host.AddScriptLPS(1); 6505 m_host.AddScriptLPS(1);
6541 Vector3 pos = m_host.GetWorldPosition() + new Vector3((float)offset.x, 6506 Vector3 pos = m_host.GetWorldPosition() + (Vector3)offset;
6542 (float)offset.y,
6543 (float)offset.z);
6544 // Clamp to valid position 6507 // Clamp to valid position
6545 if (pos.X < 0) 6508 if (pos.X < 0)
6546 pos.X = 0; 6509 pos.X = 0;
@@ -6994,8 +6957,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
6994 6957
6995 if (!m_host.ParentGroup.IsDeleted) 6958 if (!m_host.ParentGroup.IsDeleted)
6996 { 6959 {
6997 m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, 6960 m_host.ParentGroup.RootPart.SetVehicleVectorParam(param, vec);
6998 new Vector3((float)vec.x, (float)vec.y, (float)vec.z));
6999 } 6961 }
7000 } 6962 }
7001 6963
@@ -7007,7 +6969,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7007 6969
7008 if (!m_host.ParentGroup.IsDeleted) 6970 if (!m_host.ParentGroup.IsDeleted)
7009 { 6971 {
7010 m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, Rot2Quaternion(rot)); 6972 m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, rot);
7011 } 6973 }
7012 } 6974 }
7013 6975
@@ -7037,8 +6999,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7037 if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0) 6999 if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
7038 rot.s = 1; // ZERO_ROTATION = 0,0,0,1 7000 rot.s = 1; // ZERO_ROTATION = 0,0,0,1
7039 7001
7040 part.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z); 7002 part.SitTargetPosition = offset;
7041 part.SitTargetOrientation = Rot2Quaternion(rot); 7003 part.SitTargetOrientation = rot;
7042 part.ParentGroup.HasGroupChanged = true; 7004 part.ParentGroup.HasGroupChanged = true;
7043 } 7005 }
7044 7006
@@ -7141,13 +7103,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7141 public void llSetCameraEyeOffset(LSL_Vector offset) 7103 public void llSetCameraEyeOffset(LSL_Vector offset)
7142 { 7104 {
7143 m_host.AddScriptLPS(1); 7105 m_host.AddScriptLPS(1);
7144 m_host.SetCameraEyeOffset(new Vector3((float)offset.x, (float)offset.y, (float)offset.z)); 7106 m_host.SetCameraEyeOffset(offset);
7145 } 7107 }
7146 7108
7147 public void llSetCameraAtOffset(LSL_Vector offset) 7109 public void llSetCameraAtOffset(LSL_Vector offset)
7148 { 7110 {
7149 m_host.AddScriptLPS(1); 7111 m_host.AddScriptLPS(1);
7150 m_host.SetCameraAtOffset(new Vector3((float)offset.x, (float)offset.y, (float)offset.z)); 7112 m_host.SetCameraAtOffset(offset);
7151 } 7113 }
7152 7114
7153 public LSL_String llDumpList2String(LSL_List src, string seperator) 7115 public LSL_String llDumpList2String(LSL_List src, string seperator)
@@ -7169,7 +7131,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
7169 public LSL_Integer llScriptDanger(LSL_Vector pos) 7131 public LSL_Integer llScriptDanger(LSL_Vector pos)
7170 { 7132 {
7171 m_host.AddScriptLPS(1); 7133 m_host.AddScriptLPS(1);
7172 bool result = World.ScriptDanger(m_host.LocalId, new Vector3((float)pos.x, (float)pos.y, (float)pos.z)); 7134 bool result = World.ScriptDanger(m_host.LocalId, pos);
7173 if (result) 7135 if (result)
7174 { 7136 {
7175 return 1; 7137 return 1;
@@ -8103,13 +8065,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8103 if (rootPart == part) 8065 if (rootPart == part)
8104 { 8066 {
8105 // special case: If we are root, rotate complete SOG to new rotation 8067 // special case: If we are root, rotate complete SOG to new rotation
8106 SetRot(part, Rot2Quaternion(q)); 8068 SetRot(part, q);
8107 } 8069 }
8108 else 8070 else
8109 { 8071 {
8110 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask. 8072 // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
8111 // sounds like sl bug that we need to replicate 8073 // sounds like sl bug that we need to replicate
8112 SetRot(part, rootPart.RotationOffset * Rot2Quaternion(q)); 8074 SetRot(part, rootPart.RotationOffset * (Quaternion)q);
8113 } 8075 }
8114 8076
8115 break; 8077 break;
@@ -8283,8 +8245,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8283 LSL_Vector color=rules.GetVector3Item(idx++); 8245 LSL_Vector color=rules.GetVector3Item(idx++);
8284 double alpha=(double)rules.GetLSLFloatItem(idx++); 8246 double alpha=(double)rules.GetLSLFloatItem(idx++);
8285 8247
8286 part.SetFaceColor(new Vector3((float)color.x, (float)color.y, (float)color.z), face); 8248 part.SetFaceColorAlpha(face, color, alpha);
8287 SetAlpha(part, alpha, face);
8288 8249
8289 break; 8250 break;
8290 8251
@@ -8432,9 +8393,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8432 string primText = rules.GetLSLStringItem(idx++); 8393 string primText = rules.GetLSLStringItem(idx++);
8433 LSL_Vector primTextColor = rules.GetVector3Item(idx++); 8394 LSL_Vector primTextColor = rules.GetVector3Item(idx++);
8434 LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); 8395 LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++);
8435 Vector3 av3 = new Vector3(Util.Clip((float)primTextColor.x, 0.0f, 1.0f), 8396 Vector3 av3 = Util.Clip(primTextColor, 0.0f, 1.0f);
8436 Util.Clip((float)primTextColor.y, 0.0f, 1.0f),
8437 Util.Clip((float)primTextColor.z, 0.0f, 1.0f));
8438 part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f)); 8397 part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f));
8439 8398
8440 break; 8399 break;
@@ -8453,8 +8412,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8453 case (int)ScriptBaseClass.PRIM_ROT_LOCAL: 8412 case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
8454 if (remain < 1) 8413 if (remain < 1)
8455 return null; 8414 return null;
8456 LSL_Rotation lr = rules.GetQuaternionItem(idx++); 8415 SetRot(part, rules.GetQuaternionItem(idx++));
8457 SetRot(part, Rot2Quaternion(lr));
8458 break; 8416 break;
8459 case (int)ScriptBaseClass.PRIM_OMEGA: 8417 case (int)ScriptBaseClass.PRIM_OMEGA:
8460 if (remain < 3) 8418 if (remain < 3)
@@ -8464,7 +8422,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8464 LSL_Float gain = rules.GetLSLFloatItem(idx++); 8422 LSL_Float gain = rules.GetLSLFloatItem(idx++);
8465 TargetOmega(part, axis, (double)spinrate, (double)gain); 8423 TargetOmega(part, axis, (double)spinrate, (double)gain);
8466 break; 8424 break;
8467 8425 case (int)ScriptBaseClass.PRIM_SLICE:
8426 if (remain < 1)
8427 return null;
8428 LSL_Vector slice = rules.GetVector3Item(idx++);
8429 part.UpdateSlice((float)slice.x, (float)slice.y);
8430 break;
8468 case (int)ScriptBaseClass.PRIM_LINK_TARGET: 8431 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
8469 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. 8432 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
8470 return null; 8433 return null;
@@ -8473,6 +8436,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8473 } 8436 }
8474 } 8437 }
8475 } 8438 }
8439 catch (InvalidCastException e)
8440 {
8441 ShoutError(e.Message);
8442 }
8476 finally 8443 finally
8477 { 8444 {
8478 if (positionChanged) 8445 if (positionChanged)
@@ -8481,12 +8448,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
8481 { 8448 {
8482 SceneObjectGroup parent = part.ParentGroup; 8449 SceneObjectGroup parent = part.ParentGroup;
8483 Util.FireAndForget(delegate(object x) { 8450 Util.FireAndForget(delegate(object x) {
8484 parent.UpdateGroupPosition(new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z)); 8451 parent.UpdateGroupPosition(currentPosition);
8485 }); 8452 });
8486 } 8453 }
8487 else 8454 else
8488 { 8455 {
8489 part.OffsetPosition = new Vector3((float)currentPosition.x, (float)currentPosition.y, (float)currentPosition.z); 8456 part.OffsetPosition = currentPosition;
8490 SceneObjectGroup parent = part.ParentGroup; 8457 SceneObjectGroup parent = part.ParentGroup;
8491 parent.HasGroupChanged = true; 8458 parent.HasGroupChanged = true;
8492 parent.ScheduleGroupForTerseUpdate(); 8459 parent.ScheduleGroupForTerseUpdate();
@@ -9570,7 +9537,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9570 case (int)ScriptBaseClass.PRIM_POS_LOCAL: 9537 case (int)ScriptBaseClass.PRIM_POS_LOCAL:
9571 res.Add(new LSL_Vector(GetPartLocalPos(part))); 9538 res.Add(new LSL_Vector(GetPartLocalPos(part)));
9572 break; 9539 break;
9573
9574 case (int)ScriptBaseClass.PRIM_LINK_TARGET: 9540 case (int)ScriptBaseClass.PRIM_LINK_TARGET:
9575 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless. 9541 if (remain < 3) // setting to 3 on the basis that parsing any usage of PRIM_LINK_TARGET that has nothing following it is pointless.
9576 return res; 9542 return res;
@@ -9579,6 +9545,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9579 LSL_List tres = llGetLinkPrimitiveParams((int)new_linknumber, new_rules); 9545 LSL_List tres = llGetLinkPrimitiveParams((int)new_linknumber, new_rules);
9580 res += tres; 9546 res += tres;
9581 return res; 9547 return res;
9548 case (int)ScriptBaseClass.PRIM_SLICE:
9549 PrimType prim_type = part.GetPrimType();
9550 bool useProfileBeginEnd = (prim_type == PrimType.SPHERE || prim_type == PrimType.TORUS || prim_type == PrimType.TUBE || prim_type == PrimType.RING);
9551 res.Add(new LSL_Vector(
9552 (useProfileBeginEnd ? part.Shape.ProfileBegin : part.Shape.PathBegin) / 50000.0,
9553 1 - (useProfileBeginEnd ? part.Shape.ProfileEnd : part.Shape.PathEnd) / 50000.0,
9554 0
9555 ));
9556 break;
9582 } 9557 }
9583 } 9558 }
9584 return res; 9559 return res;
@@ -11164,9 +11139,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11164 ScenePresence avatar = World.GetScenePresence(detectedParams.Key); 11139 ScenePresence avatar = World.GetScenePresence(detectedParams.Key);
11165 if (avatar != null) 11140 if (avatar != null)
11166 { 11141 {
11167 avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name, simname, 11142 avatar.ControllingClient.SendScriptTeleportRequest(m_host.Name,
11168 new Vector3((float)pos.x, (float)pos.y, (float)pos.z), 11143 simname, pos, lookAt);
11169 new Vector3((float)lookAt.x, (float)lookAt.y, (float)lookAt.z));
11170 } 11144 }
11171 11145
11172 ScriptSleep(1000); 11146 ScriptSleep(1000);
@@ -11901,13 +11875,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
11901 else 11875 else
11902 rot = obj.GetWorldRotation(); 11876 rot = obj.GetWorldRotation();
11903 11877
11904 LSL_Rotation objrot = new LSL_Rotation(rot.X, rot.Y, rot.Z, rot.W); 11878 LSL_Rotation objrot = new LSL_Rotation(rot);
11905 ret.Add(objrot); 11879 ret.Add(objrot);
11906 } 11880 }
11907 break; 11881 break;
11908 case ScriptBaseClass.OBJECT_VELOCITY: 11882 case ScriptBaseClass.OBJECT_VELOCITY:
11909 Vector3 ovel = obj.Velocity; 11883 ret.Add(new LSL_Vector(obj.Velocity));
11910 ret.Add(new LSL_Vector(ovel.X, ovel.Y, ovel.Z));
11911 break; 11884 break;
11912 case ScriptBaseClass.OBJECT_OWNER: 11885 case ScriptBaseClass.OBJECT_OWNER:
11913 ret.Add(new LSL_String(obj.OwnerID.ToString())); 11886 ret.Add(new LSL_String(obj.OwnerID.ToString()));
@@ -12513,8 +12486,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
12513 12486
12514 m_host.AddScriptLPS(1); 12487 m_host.AddScriptLPS(1);
12515 12488
12516 Vector3 rayStart = new Vector3((float)start.x, (float)start.y, (float)start.z); 12489 Vector3 rayStart = start;
12517 Vector3 rayEnd = new Vector3((float)end.x, (float)end.y, (float)end.z); 12490 Vector3 rayEnd = end;
12518 Vector3 dir = rayEnd - rayStart; 12491 Vector3 dir = rayEnd - rayStart;
12519 12492
12520 float dist = Vector3.Mag(dir); 12493 float dist = Vector3.Mag(dir);
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
index 795de80..ceb4660 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LS_Api.cs
@@ -304,7 +304,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
304 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY: 304 case (int)ScriptBaseClass.WL_CLOUD_DETAIL_XY_DENSITY:
305 idx++; 305 idx++;
306 iV = rules.GetVector3Item(idx); 306 iV = rules.GetVector3Item(idx);
307 wl.cloudDetailXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); 307 wl.cloudDetailXYDensity = iV;
308 break; 308 break;
309 case (int)ScriptBaseClass.WL_CLOUD_SCALE: 309 case (int)ScriptBaseClass.WL_CLOUD_SCALE:
310 idx++; 310 idx++;
@@ -329,7 +329,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
329 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY: 329 case (int)ScriptBaseClass.WL_CLOUD_XY_DENSITY:
330 idx++; 330 idx++;
331 iV = rules.GetVector3Item(idx); 331 iV = rules.GetVector3Item(idx);
332 wl.cloudXYDensity = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); 332 wl.cloudXYDensity = iV;
333 break; 333 break;
334 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER: 334 case (int)ScriptBaseClass.WL_DENSITY_MULTIPLIER:
335 idx++; 335 idx++;
@@ -384,7 +384,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
384 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE: 384 case (int)ScriptBaseClass.WL_REFLECTION_WAVELET_SCALE:
385 idx++; 385 idx++;
386 iV = rules.GetVector3Item(idx); 386 iV = rules.GetVector3Item(idx);
387 wl.reflectionWaveletScale = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); 387 wl.reflectionWaveletScale = iV;
388 break; 388 break;
389 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE: 389 case (int)ScriptBaseClass.WL_REFRACT_SCALE_ABOVE:
390 idx++; 390 idx++;
@@ -422,7 +422,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
422 case (int)ScriptBaseClass.WL_WATER_COLOR: 422 case (int)ScriptBaseClass.WL_WATER_COLOR:
423 idx++; 423 idx++;
424 iV = rules.GetVector3Item(idx); 424 iV = rules.GetVector3Item(idx);
425 wl.waterColor = new Vector3((float)iV.x, (float)iV.y, (float)iV.z); 425 wl.waterColor = iV;
426 break; 426 break;
427 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT: 427 case (int)ScriptBaseClass.WL_WATER_FOG_DENSITY_EXPONENT:
428 idx++; 428 idx++;
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
index 7844c75..84cf6ca 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs
@@ -333,8 +333,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
333 { 333 {
334 if (type == typeof(OpenMetaverse.Quaternion)) 334 if (type == typeof(OpenMetaverse.Quaternion))
335 { 335 {
336 LSL_Rotation rot = (LSL_Rotation)lslparm; 336 return (OpenMetaverse.Quaternion)((LSL_Rotation)lslparm);
337 return new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s);
338 } 337 }
339 } 338 }
340 339
@@ -343,8 +342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
343 { 342 {
344 if (type == typeof(OpenMetaverse.Vector3)) 343 if (type == typeof(OpenMetaverse.Vector3))
345 { 344 {
346 LSL_Vector vect = (LSL_Vector)lslparm; 345 return (OpenMetaverse.Vector3)((LSL_Vector)lslparm);
347 return new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z);
348 } 346 }
349 } 347 }
350 348
@@ -367,13 +365,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
367 result[i] = new UUID((LSL_Key)plist[i]); 365 result[i] = new UUID((LSL_Key)plist[i]);
368 else if (plist[i] is LSL_Rotation) 366 else if (plist[i] is LSL_Rotation)
369 { 367 {
370 LSL_Rotation rot = (LSL_Rotation)plist[i]; 368 result[i] = (OpenMetaverse.Quaternion)(
371 result[i] = new OpenMetaverse.Quaternion((float)rot.x,(float)rot.y,(float)rot.z,(float)rot.s); 369 (LSL_Rotation)plist[i]);
372 } 370 }
373 else if (plist[i] is LSL_Vector) 371 else if (plist[i] is LSL_Vector)
374 { 372 {
375 LSL_Vector vect = (LSL_Vector)plist[i]; 373 result[i] = (OpenMetaverse.Vector3)(
376 result[i] = new OpenMetaverse.Vector3((float)vect.x,(float)vect.y,(float)vect.z); 374 (LSL_Vector)plist[i]);
377 } 375 }
378 else 376 else
379 MODError("unknown LSL list element type"); 377 MODError("unknown LSL list element type");
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
index 2f02f1f..04c3184 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs
@@ -782,10 +782,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
782 782
783 // We will launch the teleport on a new thread so that when the script threads are terminated 783 // We will launch the teleport on a new thread so that when the script threads are terminated
784 // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. 784 // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
785 Util.FireAndForget( 785 Util.FireAndForget(o => World.RequestTeleportLocation(
786 o => World.RequestTeleportLocation(presence.ControllingClient, regionName, 786 presence.ControllingClient, regionName, position,
787 new Vector3((float)position.x, (float)position.y, (float)position.z), 787 lookat, (uint)TPFlags.ViaLocation));
788 new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation));
789 788
790 ScriptSleep(5000); 789 ScriptSleep(5000);
791 790
@@ -828,10 +827,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
828 827
829 // We will launch the teleport on a new thread so that when the script threads are terminated 828 // We will launch the teleport on a new thread so that when the script threads are terminated
830 // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting. 829 // before teleport in ScriptInstance.GetXMLState(), we don't end up aborting the one doing the teleporting.
831 Util.FireAndForget( 830 Util.FireAndForget(o => World.RequestTeleportLocation(
832 o => World.RequestTeleportLocation(presence.ControllingClient, regionHandle, 831 presence.ControllingClient, regionHandle,
833 new Vector3((float)position.x, (float)position.y, (float)position.z), 832 position, lookat, (uint)TPFlags.ViaLocation));
834 new Vector3((float)lookat.x, (float)lookat.y, (float)lookat.z), (uint)TPFlags.ViaLocation));
835 833
836 ScriptSleep(5000); 834 ScriptSleep(5000);
837 835
@@ -2355,7 +2353,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2355 ownerID = m_host.OwnerID; 2353 ownerID = m_host.OwnerID;
2356 UUID x = module.CreateNPC(firstname, 2354 UUID x = module.CreateNPC(firstname,
2357 lastname, 2355 lastname,
2358 new Vector3((float) position.x, (float) position.y, (float) position.z), 2356 position,
2359 ownerID, 2357 ownerID,
2360 senseAsAgent, 2358 senseAsAgent,
2361 World, 2359 World,
@@ -2478,7 +2476,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2478 return new LSL_Vector(0, 0, 0); 2476 return new LSL_Vector(0, 0, 0);
2479 } 2477 }
2480 2478
2481 public void osNpcMoveTo(LSL_Key npc, LSL_Vector position) 2479 public void osNpcMoveTo(LSL_Key npc, LSL_Vector pos)
2482 { 2480 {
2483 CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo"); 2481 CheckThreatLevel(ThreatLevel.High, "osNpcMoveTo");
2484 m_host.AddScriptLPS(1); 2482 m_host.AddScriptLPS(1);
@@ -2493,7 +2491,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2493 if (!module.CheckPermissions(npcId, m_host.OwnerID)) 2491 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2494 return; 2492 return;
2495 2493
2496 Vector3 pos = new Vector3((float) position.x, (float) position.y, (float) position.z);
2497 module.MoveToTarget(npcId, World, pos, false, true, false); 2494 module.MoveToTarget(npcId, World, pos, false, true, false);
2498 } 2495 }
2499 } 2496 }
@@ -2513,11 +2510,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2513 if (!module.CheckPermissions(npcId, m_host.OwnerID)) 2510 if (!module.CheckPermissions(npcId, m_host.OwnerID))
2514 return; 2511 return;
2515 2512
2516 Vector3 pos = new Vector3((float)target.x, (float)target.y, (float)target.z);
2517 module.MoveToTarget( 2513 module.MoveToTarget(
2518 new UUID(npc.m_string), 2514 new UUID(npc.m_string),
2519 World, 2515 World,
2520 pos, 2516 target,
2521 (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0, 2517 (options & ScriptBaseClass.OS_NPC_NO_FLY) != 0,
2522 (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0, 2518 (options & ScriptBaseClass.OS_NPC_LAND_AT_TARGET) != 0,
2523 (options & ScriptBaseClass.OS_NPC_RUNNING) != 0); 2519 (options & ScriptBaseClass.OS_NPC_RUNNING) != 0);
@@ -2569,7 +2565,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2569 ScenePresence sp = World.GetScenePresence(npcId); 2565 ScenePresence sp = World.GetScenePresence(npcId);
2570 2566
2571 if (sp != null) 2567 if (sp != null)
2572 sp.Rotation = LSL_Api.Rot2Quaternion(rotation); 2568 sp.Rotation = rotation;
2573 } 2569 }
2574 } 2570 }
2575 2571
@@ -2929,7 +2925,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2929 avatar.SpeedModifier = (float)SpeedModifier; 2925 avatar.SpeedModifier = (float)SpeedModifier;
2930 } 2926 }
2931 2927
2932 public void osKickAvatar(string FirstName,string SurName,string alert) 2928 public void osKickAvatar(string FirstName, string SurName, string alert)
2933 { 2929 {
2934 CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); 2930 CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar");
2935 m_host.AddScriptLPS(1); 2931 m_host.AddScriptLPS(1);
@@ -2943,7 +2939,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2943 sp.ControllingClient.Kick(alert); 2939 sp.ControllingClient.Kick(alert);
2944 2940
2945 // ...and close on our side 2941 // ...and close on our side
2946 sp.Scene.IncomingCloseAgent(sp.UUID); 2942 sp.Scene.IncomingCloseAgent(sp.UUID, false);
2947 } 2943 }
2948 }); 2944 });
2949 } 2945 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
index 678f9d5..4dd795d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Plugins/SensorRepeat.cs
@@ -352,7 +352,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
352 q = avatar.Rotation; 352 q = avatar.Rotation;
353 } 353 }
354 354
355 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 355 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q);
356 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); 356 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
357 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); 357 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
358 358
@@ -429,9 +429,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
429 try 429 try
430 { 430 {
431 Vector3 diff = toRegionPos - fromRegionPos; 431 Vector3 diff = toRegionPos - fromRegionPos;
432 LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z); 432 double dot = LSL_Types.Vector3.Dot(forward_dir, diff);
433 double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir); 433 double mag_obj = LSL_Types.Vector3.Mag(diff);
434 double mag_obj = LSL_Types.Vector3.Mag(obj_dir);
435 ang_obj = Math.Acos(dot / (mag_fwd * mag_obj)); 434 ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));
436 } 435 }
437 catch 436 catch
@@ -483,7 +482,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
483 q = avatar.Rotation; 482 q = avatar.Rotation;
484 } 483 }
485 484
486 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q.X, q.Y, q.Z, q.W); 485 LSL_Types.Quaternion r = new LSL_Types.Quaternion(q);
487 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r); 486 LSL_Types.Vector3 forward_dir = (new LSL_Types.Vector3(1, 0, 0) * r);
488 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir); 487 double mag_fwd = LSL_Types.Vector3.Mag(forward_dir);
489 bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0); 488 bool attached = (SensePoint.ParentGroup.AttachmentPoint != 0);
@@ -564,8 +563,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Plugins
564 double ang_obj = 0; 563 double ang_obj = 0;
565 try 564 try
566 { 565 {
567 Vector3 diff = toRegionPos - fromRegionPos; 566 LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(
568 LSL_Types.Vector3 obj_dir = new LSL_Types.Vector3(diff.X, diff.Y, diff.Z); 567 toRegionPos - fromRegionPos);
569 double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir); 568 double dot = LSL_Types.Vector3.Dot(forward_dir, obj_dir);
570 double mag_obj = LSL_Types.Vector3.Mag(obj_dir); 569 double mag_obj = LSL_Types.Vector3.Mag(obj_dir);
571 ang_obj = Math.Acos(dot / (mag_fwd * mag_obj)); 570 ang_obj = Math.Acos(dot / (mag_fwd * mag_obj));
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
index f989cc6..05ba222 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs
@@ -329,6 +329,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
329 public const int PRIM_OMEGA = 32; 329 public const int PRIM_OMEGA = 32;
330 public const int PRIM_POS_LOCAL = 33; 330 public const int PRIM_POS_LOCAL = 33;
331 public const int PRIM_LINK_TARGET = 34; 331 public const int PRIM_LINK_TARGET = 34;
332 public const int PRIM_SLICE = 35;
332 public const int PRIM_TEXGEN_DEFAULT = 0; 333 public const int PRIM_TEXGEN_DEFAULT = 0;
333 public const int PRIM_TEXGEN_PLANAR = 1; 334 public const int PRIM_TEXGEN_PLANAR = 1;
334 335
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index 17a0d69..03be2ab 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -546,6 +546,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
546 "OpenSim.Region.ScriptEngine.Shared.dll")); 546 "OpenSim.Region.ScriptEngine.Shared.dll"));
547 parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, 547 parameters.ReferencedAssemblies.Add(Path.Combine(rootPath,
548 "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll")); 548 "OpenSim.Region.ScriptEngine.Shared.Api.Runtime.dll"));
549 parameters.ReferencedAssemblies.Add(Path.Combine(rootPath,
550 "OpenMetaverseTypes.dll"));
549 551
550 if (lang == enumCompileType.yp) 552 if (lang == enumCompileType.yp)
551 { 553 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
index 9e5fb24..22804f5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
@@ -164,11 +164,11 @@ namespace OpenSim.Region.ScriptEngine.Shared
164 else 164 else
165 { 165 {
166 // Set the values from the touch data provided by the client 166 // Set the values from the touch data provided by the client
167 touchST = new LSL_Types.Vector3(value.STCoord.X, value.STCoord.Y, value.STCoord.Z); 167 touchST = new LSL_Types.Vector3(value.STCoord);
168 touchUV = new LSL_Types.Vector3(value.UVCoord.X, value.UVCoord.Y, value.UVCoord.Z); 168 touchUV = new LSL_Types.Vector3(value.UVCoord);
169 touchNormal = new LSL_Types.Vector3(value.Normal.X, value.Normal.Y, value.Normal.Z); 169 touchNormal = new LSL_Types.Vector3(value.Normal);
170 touchBinormal = new LSL_Types.Vector3(value.Binormal.X, value.Binormal.Y, value.Binormal.Z); 170 touchBinormal = new LSL_Types.Vector3(value.Binormal);
171 touchPos = new LSL_Types.Vector3(value.Position.X, value.Position.Y, value.Position.Z); 171 touchPos = new LSL_Types.Vector3(value.Position);
172 touchFace = value.FaceIndex; 172 touchFace = value.FaceIndex;
173 } 173 }
174 } 174 }
@@ -189,19 +189,13 @@ namespace OpenSim.Region.ScriptEngine.Shared
189 Country = account.UserCountry; 189 Country = account.UserCountry;
190 190
191 Owner = Key; 191 Owner = Key;
192 Position = new LSL_Types.Vector3( 192 Position = new LSL_Types.Vector3(presence.AbsolutePosition);
193 presence.AbsolutePosition.X,
194 presence.AbsolutePosition.Y,
195 presence.AbsolutePosition.Z);
196 Rotation = new LSL_Types.Quaternion( 193 Rotation = new LSL_Types.Quaternion(
197 presence.Rotation.X, 194 presence.Rotation.X,
198 presence.Rotation.Y, 195 presence.Rotation.Y,
199 presence.Rotation.Z, 196 presence.Rotation.Z,
200 presence.Rotation.W); 197 presence.Rotation.W);
201 Velocity = new LSL_Types.Vector3( 198 Velocity = new LSL_Types.Vector3(presence.Velocity);
202 presence.Velocity.X,
203 presence.Velocity.Y,
204 presence.Velocity.Z);
205 199
206 Type = 0x01; // Avatar 200 Type = 0x01; // Avatar
207 if (presence.PresenceType == PresenceType.Npc) 201 if (presence.PresenceType == PresenceType.Npc)
@@ -254,16 +248,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
254 } 248 }
255 } 249 }
256 250
257 Position = new LSL_Types.Vector3(part.AbsolutePosition.X, 251 Position = new LSL_Types.Vector3(part.AbsolutePosition);
258 part.AbsolutePosition.Y,
259 part.AbsolutePosition.Z);
260 252
261 Quaternion wr = part.ParentGroup.GroupRotation; 253 Quaternion wr = part.ParentGroup.GroupRotation;
262 Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W); 254 Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W);
263 255
264 Velocity = new LSL_Types.Vector3(part.Velocity.X, 256 Velocity = new LSL_Types.Vector3(part.Velocity);
265 part.Velocity.Y,
266 part.Velocity.Z);
267 } 257 }
268 } 258 }
269 259
diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
index 8adf4c5..c9c4753 100644
--- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs
@@ -31,6 +31,11 @@ using System.Globalization;
31using System.Text.RegularExpressions; 31using System.Text.RegularExpressions;
32using OpenSim.Framework; 32using OpenSim.Framework;
33 33
34using OpenMetaverse;
35using OMV_Vector3 = OpenMetaverse.Vector3;
36using OMV_Vector3d = OpenMetaverse.Vector3d;
37using OMV_Quaternion = OpenMetaverse.Quaternion;
38
34namespace OpenSim.Region.ScriptEngine.Shared 39namespace OpenSim.Region.ScriptEngine.Shared
35{ 40{
36 [Serializable] 41 [Serializable]
@@ -54,6 +59,20 @@ namespace OpenSim.Region.ScriptEngine.Shared
54 z = (float)vector.z; 59 z = (float)vector.z;
55 } 60 }
56 61
62 public Vector3(OMV_Vector3 vector)
63 {
64 x = vector.X;
65 y = vector.Y;
66 z = vector.Z;
67 }
68
69 public Vector3(OMV_Vector3d vector)
70 {
71 x = vector.X;
72 y = vector.Y;
73 z = vector.Z;
74 }
75
57 public Vector3(double X, double Y, double Z) 76 public Vector3(double X, double Y, double Z)
58 { 77 {
59 x = X; 78 x = X;
@@ -109,6 +128,26 @@ namespace OpenSim.Region.ScriptEngine.Shared
109 return new list(new object[] { vec }); 128 return new list(new object[] { vec });
110 } 129 }
111 130
131 public static implicit operator OMV_Vector3(Vector3 vec)
132 {
133 return new OMV_Vector3((float)vec.x, (float)vec.y, (float)vec.z);
134 }
135
136 public static implicit operator Vector3(OMV_Vector3 vec)
137 {
138 return new Vector3(vec);
139 }
140
141 public static implicit operator OMV_Vector3d(Vector3 vec)
142 {
143 return new OMV_Vector3d(vec.x, vec.y, vec.z);
144 }
145
146 public static implicit operator Vector3(OMV_Vector3d vec)
147 {
148 return new Vector3(vec);
149 }
150
112 public static bool operator ==(Vector3 lhs, Vector3 rhs) 151 public static bool operator ==(Vector3 lhs, Vector3 rhs)
113 { 152 {
114 return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z); 153 return (lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z);
@@ -322,6 +361,14 @@ namespace OpenSim.Region.ScriptEngine.Shared
322 s = 1; 361 s = 1;
323 } 362 }
324 363
364 public Quaternion(OMV_Quaternion rot)
365 {
366 x = rot.X;
367 y = rot.Y;
368 z = rot.Z;
369 s = rot.W;
370 }
371
325 #endregion 372 #endregion
326 373
327 #region Overriders 374 #region Overriders
@@ -368,6 +415,21 @@ namespace OpenSim.Region.ScriptEngine.Shared
368 return new list(new object[] { r }); 415 return new list(new object[] { r });
369 } 416 }
370 417
418 public static implicit operator OMV_Quaternion(Quaternion rot)
419 {
420 // LSL quaternions can normalize to 0, normal Quaternions can't.
421 if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
422 rot.z = 1; // ZERO_ROTATION = 0,0,0,1
423 OMV_Quaternion omvrot = new OMV_Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
424 omvrot.Normalize();
425 return omvrot;
426 }
427
428 public static implicit operator Quaternion(OMV_Quaternion rot)
429 {
430 return new Quaternion(rot);
431 }
432
371 public static bool operator ==(Quaternion lhs, Quaternion rhs) 433 public static bool operator ==(Quaternion lhs, Quaternion rhs)
372 { 434 {
373 // Return true if the fields match: 435 // Return true if the fields match:
@@ -562,12 +624,23 @@ namespace OpenSim.Region.ScriptEngine.Shared
562 else if (m_data[itemIndex] is LSL_Types.LSLString) 624 else if (m_data[itemIndex] is LSL_Types.LSLString)
563 return new LSLInteger(m_data[itemIndex].ToString()); 625 return new LSLInteger(m_data[itemIndex].ToString());
564 else 626 else
565 throw new InvalidCastException(); 627 throw new InvalidCastException(string.Format(
628 "{0} expected but {1} given",
629 typeof(LSL_Types.LSLInteger).Name,
630 m_data[itemIndex] != null ?
631 m_data[itemIndex].GetType().Name : "null"));
566 } 632 }
567 633
568 public LSL_Types.Vector3 GetVector3Item(int itemIndex) 634 public LSL_Types.Vector3 GetVector3Item(int itemIndex)
569 { 635 {
570 return (LSL_Types.Vector3)m_data[itemIndex]; 636 if(m_data[itemIndex] is LSL_Types.Vector3)
637 return (LSL_Types.Vector3)m_data[itemIndex];
638 else
639 throw new InvalidCastException(string.Format(
640 "{0} expected but {1} given",
641 typeof(LSL_Types.Vector3).Name,
642 m_data[itemIndex] != null ?
643 m_data[itemIndex].GetType().Name : "null"));
571 } 644 }
572 645
573 public LSL_Types.Quaternion GetQuaternionItem(int itemIndex) 646 public LSL_Types.Quaternion GetQuaternionItem(int itemIndex)
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
index 5c4174e..cee10df 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs
@@ -152,9 +152,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
152 det[0] = new DetectParams(); 152 det[0] = new DetectParams();
153 det[0].Key = remoteClient.AgentId; 153 det[0].Key = remoteClient.AgentId;
154 det[0].Populate(myScriptEngine.World); 154 det[0].Populate(myScriptEngine.World);
155 det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X, 155 det[0].OffsetPos = offsetPos;
156 offsetPos.Y,
157 offsetPos.Z);
158 156
159 if (originalID == 0) 157 if (originalID == 0)
160 { 158 {
@@ -298,9 +296,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
298 foreach (DetectedObject detobj in col.Colliders) 296 foreach (DetectedObject detobj in col.Colliders)
299 { 297 {
300 DetectParams d = new DetectParams(); 298 DetectParams d = new DetectParams();
301 d.Position = new LSL_Types.Vector3(detobj.posVector.X, 299 d.Position = detobj.posVector;
302 detobj.posVector.Y,
303 detobj.posVector.Z);
304 d.Populate(myScriptEngine.World); 300 d.Populate(myScriptEngine.World);
305 det.Add(d); 301 det.Add(d);
306 myScriptEngine.PostObjectEvent(localID, new EventParams( 302 myScriptEngine.PostObjectEvent(localID, new EventParams(
@@ -318,9 +314,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
318 foreach (DetectedObject detobj in col.Colliders) 314 foreach (DetectedObject detobj in col.Colliders)
319 { 315 {
320 DetectParams d = new DetectParams(); 316 DetectParams d = new DetectParams();
321 d.Position = new LSL_Types.Vector3(detobj.posVector.X, 317 d.Position = detobj.posVector;
322 detobj.posVector.Y,
323 detobj.posVector.Z);
324 d.Populate(myScriptEngine.World); 318 d.Populate(myScriptEngine.World);
325 det.Add(d); 319 det.Add(d);
326 myScriptEngine.PostObjectEvent(localID, new EventParams( 320 myScriptEngine.PostObjectEvent(localID, new EventParams(
@@ -337,9 +331,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
337 foreach (DetectedObject detobj in col.Colliders) 331 foreach (DetectedObject detobj in col.Colliders)
338 { 332 {
339 DetectParams d = new DetectParams(); 333 DetectParams d = new DetectParams();
340 d.Position = new LSL_Types.Vector3(detobj.posVector.X, 334 d.Position = detobj.posVector;
341 detobj.posVector.Y,
342 detobj.posVector.Z);
343 d.Populate(myScriptEngine.World); 335 d.Populate(myScriptEngine.World);
344 det.Add(d); 336 det.Add(d);
345 myScriptEngine.PostObjectEvent(localID, new EventParams( 337 myScriptEngine.PostObjectEvent(localID, new EventParams(
@@ -381,8 +373,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
381 myScriptEngine.PostObjectEvent(localID, new EventParams( 373 myScriptEngine.PostObjectEvent(localID, new EventParams(
382 "at_target", new object[] { 374 "at_target", new object[] {
383 new LSL_Types.LSLInteger(handle), 375 new LSL_Types.LSLInteger(handle),
384 new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z), 376 new LSL_Types.Vector3(targetpos),
385 new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) }, 377 new LSL_Types.Vector3(atpos) },
386 new DetectParams[0])); 378 new DetectParams[0]));
387 } 379 }
388 380
@@ -399,8 +391,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
399 myScriptEngine.PostObjectEvent(localID, new EventParams( 391 myScriptEngine.PostObjectEvent(localID, new EventParams(
400 "at_rot_target", new object[] { 392 "at_rot_target", new object[] {
401 new LSL_Types.LSLInteger(handle), 393 new LSL_Types.LSLInteger(handle),
402 new LSL_Types.Quaternion(targetrot.X,targetrot.Y,targetrot.Z,targetrot.W), 394 new LSL_Types.Quaternion(targetrot),
403 new LSL_Types.Quaternion(atrot.X,atrot.Y,atrot.Z,atrot.W) }, 395 new LSL_Types.Quaternion(atrot) },
404 new DetectParams[0])); 396 new DetectParams[0]));
405 } 397 }
406 398
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
index f6cb7df..2d17977 100644
--- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
+++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs
@@ -656,7 +656,19 @@ namespace OpenSim.Region.ScriptEngine.XEngine
656 if (m_Assemblies.ContainsKey(instance.AssetID)) 656 if (m_Assemblies.ContainsKey(instance.AssetID))
657 { 657 {
658 string assembly = m_Assemblies[instance.AssetID]; 658 string assembly = m_Assemblies[instance.AssetID];
659 instance.SaveState(assembly); 659
660 try
661 {
662 instance.SaveState(assembly);
663 }
664 catch (Exception e)
665 {
666 m_log.Error(
667 string.Format(
668 "[XEngine]: Failed final state save for script {0}.{1}, item UUID {2}, prim UUID {3} in {4}. Exception ",
669 instance.PrimName, instance.ScriptName, instance.ItemID, instance.ObjectID, World.Name)
670 , e);
671 }
660 } 672 }
661 673
662 // Clear the event queue and abort the instance thread 674 // Clear the event queue and abort the instance thread
@@ -778,7 +790,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine
778 assembly = m_Assemblies[i.AssetID]; 790 assembly = m_Assemblies[i.AssetID];
779 791
780 792
781 i.SaveState(assembly); 793 try
794 {
795 i.SaveState(assembly);
796 }
797 catch (Exception e)
798 {
799 m_log.Error(
800 string.Format(
801 "[XEngine]: Failed to save state of script {0}.{1}, item UUID {2}, prim UUID {3} in {4}. Exception ",
802 i.PrimName, i.ScriptName, i.ItemID, i.ObjectID, World.Name)
803 , e);
804 }
782 } 805 }
783 806
784 instances.Clear(); 807 instances.Clear();
@@ -1053,10 +1076,12 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1053 return false; 1076 return false;
1054 } 1077 }
1055 1078
1056 UUID assetID = item.AssetID; 1079 m_log.DebugFormat(
1080 "[XEngine] Loading script {0}.{1}, item UUID {2}, prim UUID {3} @ {4}.{5}",
1081 part.ParentGroup.RootPart.Name, item.Name, itemID, part.UUID,
1082 part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName);
1057 1083
1058 //m_log.DebugFormat("[XEngine] Compiling script {0} ({1} on object {2})", 1084 UUID assetID = item.AssetID;
1059 // item.Name, itemID.ToString(), part.ParentGroup.RootPart.Name);
1060 1085
1061 ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID); 1086 ScenePresence presence = m_Scene.GetScenePresence(item.OwnerID);
1062 1087
@@ -1235,10 +1260,10 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1235 item.Name, startParam, postOnRez, 1260 item.Name, startParam, postOnRez,
1236 stateSource, m_MaxScriptQueue); 1261 stateSource, m_MaxScriptQueue);
1237 1262
1238 m_log.DebugFormat( 1263// m_log.DebugFormat(
1239 "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}", 1264// "[XEngine] Loaded script {0}.{1}, script UUID {2}, prim UUID {3} @ {4}.{5}",
1240 part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID, 1265// part.ParentGroup.RootPart.Name, item.Name, assetID, part.UUID,
1241 part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName); 1266// part.ParentGroup.RootPart.AbsolutePosition, part.ParentGroup.Scene.RegionInfo.RegionName);
1242 1267
1243 if (presence != null) 1268 if (presence != null)
1244 { 1269 {
@@ -1554,9 +1579,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1554 else if (p[i] is string) 1579 else if (p[i] is string)
1555 lsl_p[i] = new LSL_Types.LSLString((string)p[i]); 1580 lsl_p[i] = new LSL_Types.LSLString((string)p[i]);
1556 else if (p[i] is Vector3) 1581 else if (p[i] is Vector3)
1557 lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z); 1582 lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]);
1558 else if (p[i] is Quaternion) 1583 else if (p[i] is Quaternion)
1559 lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W); 1584 lsl_p[i] = new LSL_Types.Quaternion((Quaternion)p[i]);
1560 else if (p[i] is float) 1585 else if (p[i] is float)
1561 lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); 1586 lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]);
1562 else 1587 else
@@ -1580,9 +1605,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
1580 else if (p[i] is string) 1605 else if (p[i] is string)
1581 lsl_p[i] = new LSL_Types.LSLString((string)p[i]); 1606 lsl_p[i] = new LSL_Types.LSLString((string)p[i]);
1582 else if (p[i] is Vector3) 1607 else if (p[i] is Vector3)
1583 lsl_p[i] = new LSL_Types.Vector3(((Vector3)p[i]).X, ((Vector3)p[i]).Y, ((Vector3)p[i]).Z); 1608 lsl_p[i] = new LSL_Types.Vector3((Vector3)p[i]);
1584 else if (p[i] is Quaternion) 1609 else if (p[i] is Quaternion)
1585 lsl_p[i] = new LSL_Types.Quaternion(((Quaternion)p[i]).X, ((Quaternion)p[i]).Y, ((Quaternion)p[i]).Z, ((Quaternion)p[i]).W); 1610 lsl_p[i] = new LSL_Types.Quaternion((Quaternion)p[i]);
1586 else if (p[i] is float) 1611 else if (p[i] is float)
1587 lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]); 1612 lsl_p[i] = new LSL_Types.LSLFloat((float)p[i]);
1588 else 1613 else
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 6add130..4e3bc67 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -935,12 +935,12 @@ namespace OpenSim.Tests.Common.Mock
935 Close(); 935 Close();
936 } 936 }
937 937
938 public void Close(bool c) 938 public void Close()
939 { 939 {
940 Close(); 940 Close(true, false);
941 } 941 }
942 942
943 public void Close() 943 public void Close(bool sendStop, bool force)
944 { 944 {
945 // Fire the callback for this connection closing 945 // Fire the callback for this connection closing
946 // This is necesary to get the presence detector to notice that a client has logged out. 946 // This is necesary to get the presence detector to notice that a client has logged out.