diff options
Diffstat (limited to 'OpenSim')
61 files changed, 1628 insertions, 632 deletions
diff --git a/OpenSim/Framework/IScene.cs b/OpenSim/Framework/IScene.cs index 2c38e0f..87ec99e 100644 --- a/OpenSim/Framework/IScene.cs +++ b/OpenSim/Framework/IScene.cs | |||
@@ -71,6 +71,14 @@ namespace OpenSim.Framework | |||
71 | /// </summary> | 71 | /// </summary> |
72 | bool LoginsEnabled { get; set; } | 72 | bool LoginsEnabled { get; set; } |
73 | 73 | ||
74 | /// <summary> | ||
75 | /// Is this region ready for use? | ||
76 | /// </summary> | ||
77 | /// <remarks> | ||
78 | /// This does not mean that logins are enabled, merely that they can be. | ||
79 | /// </remarks> | ||
80 | bool Ready { get; set; } | ||
81 | |||
74 | float TimeDilation { get; } | 82 | float TimeDilation { get; } |
75 | 83 | ||
76 | bool AllowScriptCrossings { get; } | 84 | bool AllowScriptCrossings { get; } |
diff --git a/OpenSim/Framework/Statistics/AssetStatsCollector.cs b/OpenSim/Framework/Monitoring/AssetStatsCollector.cs index 7082ef3..2a4d45b 100644 --- a/OpenSim/Framework/Statistics/AssetStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/AssetStatsCollector.cs | |||
@@ -28,7 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Timers; | 29 | using System.Timers; |
30 | 30 | ||
31 | namespace OpenSim.Framework.Statistics | 31 | namespace OpenSim.Framework.Monitoring |
32 | { | 32 | { |
33 | /// <summary> | 33 | /// <summary> |
34 | /// Asset service statistics collection | 34 | /// Asset service statistics collection |
diff --git a/OpenSim/Framework/Statistics/BaseStatsCollector.cs b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs index 3f918f3..9ee0876 100644 --- a/OpenSim/Framework/Statistics/BaseStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/BaseStatsCollector.cs | |||
@@ -31,8 +31,7 @@ using System.Text; | |||
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using OpenMetaverse.StructuredData; | 32 | using OpenMetaverse.StructuredData; |
33 | 33 | ||
34 | 34 | namespace OpenSim.Framework.Monitoring | |
35 | namespace OpenSim.Framework.Statistics | ||
36 | { | 35 | { |
37 | /// <summary> | 36 | /// <summary> |
38 | /// Statistics which all collectors are interested in reporting | 37 | /// Statistics which all collectors are interested in reporting |
diff --git a/OpenSim/Framework/Statistics/Interfaces/IPullStatsProvider.cs b/OpenSim/Framework/Monitoring/Interfaces/IPullStatsProvider.cs index 430e580..86a6620 100644 --- a/OpenSim/Framework/Statistics/Interfaces/IPullStatsProvider.cs +++ b/OpenSim/Framework/Monitoring/Interfaces/IPullStatsProvider.cs | |||
@@ -25,7 +25,7 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | namespace OpenSim.Framework.Statistics.Interfaces | 28 | namespace OpenSim.Framework.Monitoring.Interfaces |
29 | { | 29 | { |
30 | /// <summary> | 30 | /// <summary> |
31 | /// Implemented by objects which allow statistical information to be pulled from them. | 31 | /// Implemented by objects which allow statistical information to be pulled from them. |
diff --git a/OpenSim/Framework/Statistics/Interfaces/IStatsCollector.cs b/OpenSim/Framework/Monitoring/Interfaces/IStatsCollector.cs index 477bbb3..99f75e3 100644 --- a/OpenSim/Framework/Statistics/Interfaces/IStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/Interfaces/IStatsCollector.cs | |||
@@ -25,7 +25,7 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | namespace OpenSim.Framework.Statistics | 28 | namespace OpenSim.Framework.Monitoring |
29 | { | 29 | { |
30 | /// <summary> | 30 | /// <summary> |
31 | /// Implemented by classes which collect up non-viewer statistical information | 31 | /// Implemented by classes which collect up non-viewer statistical information |
diff --git a/OpenSim/Framework/Monitoring/MemoryWatchdog.cs b/OpenSim/Framework/Monitoring/MemoryWatchdog.cs new file mode 100644 index 0000000..a23cf1f --- /dev/null +++ b/OpenSim/Framework/Monitoring/MemoryWatchdog.cs | |||
@@ -0,0 +1,129 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Linq; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | |||
35 | namespace OpenSim.Framework.Monitoring | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Experimental watchdog for memory usage. | ||
39 | /// </summary> | ||
40 | public static class MemoryWatchdog | ||
41 | { | ||
42 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | /// <summary> | ||
45 | /// Is this watchdog active? | ||
46 | /// </summary> | ||
47 | public static bool Enabled | ||
48 | { | ||
49 | get { return m_enabled; } | ||
50 | set | ||
51 | { | ||
52 | // m_log.DebugFormat("[MEMORY WATCHDOG]: Setting MemoryWatchdog.Enabled to {0}", value); | ||
53 | |||
54 | if (value && !m_enabled) | ||
55 | UpdateLastRecord(GC.GetTotalMemory(false), Util.EnvironmentTickCount()); | ||
56 | |||
57 | m_enabled = value; | ||
58 | } | ||
59 | } | ||
60 | private static bool m_enabled; | ||
61 | |||
62 | /// <summary> | ||
63 | /// Average memory churn in bytes per millisecond. | ||
64 | /// </summary> | ||
65 | public static double AverageMemoryChurn | ||
66 | { | ||
67 | get { if (m_samples.Count > 0) return m_samples.Average(); else return 0; } | ||
68 | } | ||
69 | |||
70 | /// <summary> | ||
71 | /// Maximum number of statistical samples. | ||
72 | /// </summary> | ||
73 | /// <remarks> | ||
74 | /// At the moment this corresponds to 1 minute since the sampling rate is every 2.5 seconds as triggered from | ||
75 | /// the main Watchdog. | ||
76 | /// </remarks> | ||
77 | private static int m_maxSamples = 24; | ||
78 | |||
79 | /// <summary> | ||
80 | /// Time when the watchdog was last updated. | ||
81 | /// </summary> | ||
82 | private static int m_lastUpdateTick; | ||
83 | |||
84 | /// <summary> | ||
85 | /// Memory used at time of last watchdog update. | ||
86 | /// </summary> | ||
87 | private static long m_lastUpdateMemory; | ||
88 | |||
89 | /// <summary> | ||
90 | /// Memory churn rate per millisecond. | ||
91 | /// </summary> | ||
92 | // private static double m_churnRatePerMillisecond; | ||
93 | |||
94 | /// <summary> | ||
95 | /// Historical samples for calculating moving average. | ||
96 | /// </summary> | ||
97 | private static Queue<double> m_samples = new Queue<double>(m_maxSamples); | ||
98 | |||
99 | public static void Update() | ||
100 | { | ||
101 | int now = Util.EnvironmentTickCount(); | ||
102 | long memoryNow = GC.GetTotalMemory(false); | ||
103 | long memoryDiff = memoryNow - m_lastUpdateMemory; | ||
104 | |||
105 | if (memoryDiff >= 0) | ||
106 | { | ||
107 | if (m_samples.Count >= m_maxSamples) | ||
108 | m_samples.Dequeue(); | ||
109 | |||
110 | double elapsed = Util.EnvironmentTickCountSubtract(now, m_lastUpdateTick); | ||
111 | |||
112 | // This should never happen since it's not useful for updates to occur with no time elapsed, but | ||
113 | // protect ourselves from a divide-by-zero just in case. | ||
114 | if (elapsed == 0) | ||
115 | return; | ||
116 | |||
117 | m_samples.Enqueue(memoryDiff / (double)elapsed); | ||
118 | } | ||
119 | |||
120 | UpdateLastRecord(memoryNow, now); | ||
121 | } | ||
122 | |||
123 | private static void UpdateLastRecord(long memoryNow, int timeNow) | ||
124 | { | ||
125 | m_lastUpdateMemory = memoryNow; | ||
126 | m_lastUpdateTick = timeNow; | ||
127 | } | ||
128 | } | ||
129 | } \ No newline at end of file | ||
diff --git a/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs index a506e3b..cdd7cc7 100644 --- a/OpenSim/Framework/Statistics/SimExtraStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/SimExtraStatsCollector.cs | |||
@@ -28,12 +28,11 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | using System.Text; |
31 | |||
32 | using OpenMetaverse; | 31 | using OpenMetaverse; |
33 | using OpenSim.Framework.Statistics.Interfaces; | ||
34 | using OpenMetaverse.StructuredData; | 32 | using OpenMetaverse.StructuredData; |
33 | using OpenSim.Framework.Monitoring.Interfaces; | ||
35 | 34 | ||
36 | namespace OpenSim.Framework.Statistics | 35 | namespace OpenSim.Framework.Monitoring |
37 | { | 36 | { |
38 | /// <summary> | 37 | /// <summary> |
39 | /// Collects sim statistics which aren't already being collected for the linden viewer's statistics pane | 38 | /// Collects sim statistics which aren't already being collected for the linden viewer's statistics pane |
diff --git a/OpenSim/Framework/Statistics/StatsManager.cs b/OpenSim/Framework/Monitoring/StatsManager.cs index 436ce2f..d78fa6a 100644 --- a/OpenSim/Framework/Statistics/StatsManager.cs +++ b/OpenSim/Framework/Monitoring/StatsManager.cs | |||
@@ -25,7 +25,7 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | namespace OpenSim.Framework.Statistics | 28 | namespace OpenSim.Framework.Monitoring |
29 | { | 29 | { |
30 | /// <summary> | 30 | /// <summary> |
31 | /// Singleton used to provide access to statistics reporters | 31 | /// Singleton used to provide access to statistics reporters |
diff --git a/OpenSim/Framework/Statistics/UserStatsCollector.cs b/OpenSim/Framework/Monitoring/UserStatsCollector.cs index fd2a9bf..e89c8e6 100644 --- a/OpenSim/Framework/Statistics/UserStatsCollector.cs +++ b/OpenSim/Framework/Monitoring/UserStatsCollector.cs | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | using System.Timers; | 28 | using System.Timers; |
29 | 29 | ||
30 | namespace OpenSim.Framework.Statistics | 30 | namespace OpenSim.Framework.Monitoring |
31 | { | 31 | { |
32 | /// <summary> | 32 | /// <summary> |
33 | /// Collects user service statistics | 33 | /// Collects user service statistics |
diff --git a/OpenSim/Framework/Watchdog.cs b/OpenSim/Framework/Monitoring/Watchdog.cs index 449d014..e4db964 100644 --- a/OpenSim/Framework/Watchdog.cs +++ b/OpenSim/Framework/Monitoring/Watchdog.cs | |||
@@ -31,7 +31,7 @@ using System.Linq; | |||
31 | using System.Threading; | 31 | using System.Threading; |
32 | using log4net; | 32 | using log4net; |
33 | 33 | ||
34 | namespace OpenSim.Framework | 34 | namespace OpenSim.Framework.Monitoring |
35 | { | 35 | { |
36 | /// <summary> | 36 | /// <summary> |
37 | /// Manages launching threads and keeping watch over them for timeouts | 37 | /// Manages launching threads and keeping watch over them for timeouts |
@@ -325,6 +325,9 @@ namespace OpenSim.Framework | |||
325 | callback(callbackInfo); | 325 | callback(callbackInfo); |
326 | } | 326 | } |
327 | 327 | ||
328 | if (MemoryWatchdog.Enabled) | ||
329 | MemoryWatchdog.Update(); | ||
330 | |||
328 | m_watchdogTimer.Start(); | 331 | m_watchdogTimer.Start(); |
329 | } | 332 | } |
330 | } | 333 | } |
diff --git a/OpenSim/Framework/RegionInfo.cs b/OpenSim/Framework/RegionInfo.cs index 1b2f681..4bde7be 100644 --- a/OpenSim/Framework/RegionInfo.cs +++ b/OpenSim/Framework/RegionInfo.cs | |||
@@ -482,9 +482,16 @@ namespace OpenSim.Framework | |||
482 | MainConsole.Instance.Output("=====================================\n"); | 482 | MainConsole.Instance.Output("=====================================\n"); |
483 | 483 | ||
484 | if (name == String.Empty) | 484 | if (name == String.Empty) |
485 | name = MainConsole.Instance.CmdPrompt("New region name", name); | 485 | { |
486 | if (name == String.Empty) | 486 | while (name.Trim() == string.Empty) |
487 | throw new Exception("Cannot interactively create region with no name"); | 487 | { |
488 | name = MainConsole.Instance.CmdPrompt("New region name", name); | ||
489 | if (name.Trim() == string.Empty) | ||
490 | { | ||
491 | MainConsole.Instance.Output("Cannot interactively create region with no name"); | ||
492 | } | ||
493 | } | ||
494 | } | ||
488 | 495 | ||
489 | source.AddConfig(name); | 496 | source.AddConfig(name); |
490 | 497 | ||
@@ -515,15 +522,20 @@ namespace OpenSim.Framework | |||
515 | // | 522 | // |
516 | allKeys.Remove("RegionUUID"); | 523 | allKeys.Remove("RegionUUID"); |
517 | string regionUUID = config.GetString("RegionUUID", string.Empty); | 524 | string regionUUID = config.GetString("RegionUUID", string.Empty); |
518 | if (regionUUID == String.Empty) | 525 | if (!UUID.TryParse(regionUUID.Trim(), out RegionID)) |
519 | { | 526 | { |
520 | UUID newID = UUID.Random(); | 527 | UUID newID = UUID.Random(); |
521 | 528 | while (RegionID == UUID.Zero) | |
522 | regionUUID = MainConsole.Instance.CmdPrompt("RegionUUID", newID.ToString()); | 529 | { |
530 | regionUUID = MainConsole.Instance.CmdPrompt("RegionUUID", newID.ToString()); | ||
531 | if (!UUID.TryParse(regionUUID.Trim(), out RegionID)) | ||
532 | { | ||
533 | MainConsole.Instance.Output("RegionUUID must be a valid UUID"); | ||
534 | } | ||
535 | } | ||
523 | config.Set("RegionUUID", regionUUID); | 536 | config.Set("RegionUUID", regionUUID); |
524 | } | 537 | } |
525 | 538 | ||
526 | RegionID = new UUID(regionUUID); | ||
527 | originRegionID = RegionID; // What IS this?! (Needed for RegionCombinerModule?) | 539 | originRegionID = RegionID; // What IS this?! (Needed for RegionCombinerModule?) |
528 | 540 | ||
529 | // Location | 541 | // Location |
diff --git a/OpenSim/Framework/Servers/BaseOpenSimServer.cs b/OpenSim/Framework/Servers/BaseOpenSimServer.cs index 9a2cd0e..cf19002 100644 --- a/OpenSim/Framework/Servers/BaseOpenSimServer.cs +++ b/OpenSim/Framework/Servers/BaseOpenSimServer.cs | |||
@@ -40,9 +40,9 @@ using log4net.Core; | |||
40 | using log4net.Repository; | 40 | using log4net.Repository; |
41 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
42 | using OpenSim.Framework.Console; | 42 | using OpenSim.Framework.Console; |
43 | using OpenSim.Framework.Monitoring; | ||
43 | using OpenSim.Framework.Servers; | 44 | using OpenSim.Framework.Servers; |
44 | using OpenSim.Framework.Servers.HttpServer; | 45 | using OpenSim.Framework.Servers.HttpServer; |
45 | using OpenSim.Framework.Statistics; | ||
46 | using Timer=System.Timers.Timer; | 46 | using Timer=System.Timers.Timer; |
47 | 47 | ||
48 | using OpenMetaverse; | 48 | using OpenMetaverse; |
diff --git a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs index 24f986a..e45cb89 100644 --- a/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs +++ b/OpenSim/Framework/Servers/HttpServer/BaseHttpServer.cs | |||
@@ -45,6 +45,7 @@ using OpenMetaverse.StructuredData; | |||
45 | using CoolHTTPListener = HttpServer.HttpListener; | 45 | using CoolHTTPListener = HttpServer.HttpListener; |
46 | using HttpListener=System.Net.HttpListener; | 46 | using HttpListener=System.Net.HttpListener; |
47 | using LogPrio=HttpServer.LogPrio; | 47 | using LogPrio=HttpServer.LogPrio; |
48 | using OpenSim.Framework.Monitoring; | ||
48 | 49 | ||
49 | namespace OpenSim.Framework.Servers.HttpServer | 50 | namespace OpenSim.Framework.Servers.HttpServer |
50 | { | 51 | { |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs index a3bd330..a385110 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceRequestManager.cs | |||
@@ -32,6 +32,7 @@ using System.Reflection; | |||
32 | using log4net; | 32 | using log4net; |
33 | using HttpServer; | 33 | using HttpServer; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Monitoring; | ||
35 | 36 | ||
36 | 37 | ||
37 | /* | 38 | /* |
diff --git a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs index 1e3fbf0..1c529b6 100644 --- a/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs +++ b/OpenSim/Framework/Servers/HttpServer/PollServiceWorkerThread.cs | |||
@@ -36,6 +36,7 @@ using HttpServer; | |||
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using System.Reflection; | 37 | using System.Reflection; |
38 | using log4net; | 38 | using log4net; |
39 | using OpenSim.Framework.Monitoring; | ||
39 | 40 | ||
40 | namespace OpenSim.Framework.Servers.HttpServer | 41 | namespace OpenSim.Framework.Servers.HttpServer |
41 | { | 42 | { |
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 8a0b4ab..ba8aa9f 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -40,7 +40,7 @@ using OpenMetaverse; | |||
40 | using OpenSim.Framework; | 40 | using OpenSim.Framework; |
41 | using OpenSim.Framework.Console; | 41 | using OpenSim.Framework.Console; |
42 | using OpenSim.Framework.Servers; | 42 | using OpenSim.Framework.Servers; |
43 | using OpenSim.Framework.Statistics; | 43 | using OpenSim.Framework.Monitoring; |
44 | using OpenSim.Region.Framework.Interfaces; | 44 | using OpenSim.Region.Framework.Interfaces; |
45 | using OpenSim.Region.Framework.Scenes; | 45 | using OpenSim.Region.Framework.Scenes; |
46 | 46 | ||
@@ -200,9 +200,9 @@ namespace OpenSim | |||
200 | PrintFileToConsole("startuplogo.txt"); | 200 | PrintFileToConsole("startuplogo.txt"); |
201 | 201 | ||
202 | // For now, start at the 'root' level by default | 202 | // For now, start at the 'root' level by default |
203 | if (m_sceneManager.Scenes.Count == 1) // If there is only one region, select it | 203 | if (SceneManager.Scenes.Count == 1) // If there is only one region, select it |
204 | ChangeSelectedRegion("region", | 204 | ChangeSelectedRegion("region", |
205 | new string[] {"change", "region", m_sceneManager.Scenes[0].RegionInfo.RegionName}); | 205 | new string[] {"change", "region", SceneManager.Scenes[0].RegionInfo.RegionName}); |
206 | else | 206 | else |
207 | ChangeSelectedRegion("region", new string[] {"change", "region", "root"}); | 207 | ChangeSelectedRegion("region", new string[] {"change", "region", "root"}); |
208 | 208 | ||
@@ -461,7 +461,7 @@ namespace OpenSim | |||
461 | if (cmdparams.Length > 4) | 461 | if (cmdparams.Length > 4) |
462 | alert = String.Format("\n{0}\n", String.Join(" ", cmdparams, 4, cmdparams.Length - 4)); | 462 | alert = String.Format("\n{0}\n", String.Join(" ", cmdparams, 4, cmdparams.Length - 4)); |
463 | 463 | ||
464 | IList agents = m_sceneManager.GetCurrentSceneAvatars(); | 464 | IList agents = SceneManager.GetCurrentSceneAvatars(); |
465 | 465 | ||
466 | foreach (ScenePresence presence in agents) | 466 | foreach (ScenePresence presence in agents) |
467 | { | 467 | { |
@@ -542,7 +542,7 @@ namespace OpenSim | |||
542 | private void HandleForceUpdate(string module, string[] args) | 542 | private void HandleForceUpdate(string module, string[] args) |
543 | { | 543 | { |
544 | MainConsole.Instance.Output("Updating all clients"); | 544 | MainConsole.Instance.Output("Updating all clients"); |
545 | m_sceneManager.ForceCurrentSceneClientUpdate(); | 545 | SceneManager.ForceCurrentSceneClientUpdate(); |
546 | } | 546 | } |
547 | 547 | ||
548 | /// <summary> | 548 | /// <summary> |
@@ -554,7 +554,7 @@ namespace OpenSim | |||
554 | { | 554 | { |
555 | if (args.Length == 6) | 555 | if (args.Length == 6) |
556 | { | 556 | { |
557 | m_sceneManager.HandleEditCommandOnCurrentScene(args); | 557 | SceneManager.HandleEditCommandOnCurrentScene(args); |
558 | } | 558 | } |
559 | else | 559 | else |
560 | { | 560 | { |
@@ -765,7 +765,7 @@ namespace OpenSim | |||
765 | case "load": | 765 | case "load": |
766 | if (cmdparams.Length > 1) | 766 | if (cmdparams.Length > 1) |
767 | { | 767 | { |
768 | foreach (Scene s in new ArrayList(m_sceneManager.Scenes)) | 768 | foreach (Scene s in new ArrayList(SceneManager.Scenes)) |
769 | { | 769 | { |
770 | MainConsole.Instance.Output(String.Format("Loading module: {0}", cmdparams[1])); | 770 | MainConsole.Instance.Output(String.Format("Loading module: {0}", cmdparams[1])); |
771 | m_moduleLoader.LoadRegionModules(cmdparams[1], s); | 771 | m_moduleLoader.LoadRegionModules(cmdparams[1], s); |
@@ -803,14 +803,14 @@ namespace OpenSim | |||
803 | 803 | ||
804 | case "backup": | 804 | case "backup": |
805 | MainConsole.Instance.Output("Triggering save of pending object updates to persistent store"); | 805 | MainConsole.Instance.Output("Triggering save of pending object updates to persistent store"); |
806 | m_sceneManager.BackupCurrentScene(); | 806 | SceneManager.BackupCurrentScene(); |
807 | break; | 807 | break; |
808 | 808 | ||
809 | case "remove-region": | 809 | case "remove-region": |
810 | string regRemoveName = CombineParams(cmdparams, 0); | 810 | string regRemoveName = CombineParams(cmdparams, 0); |
811 | 811 | ||
812 | Scene removeScene; | 812 | Scene removeScene; |
813 | if (m_sceneManager.TryGetScene(regRemoveName, out removeScene)) | 813 | if (SceneManager.TryGetScene(regRemoveName, out removeScene)) |
814 | RemoveRegion(removeScene, false); | 814 | RemoveRegion(removeScene, false); |
815 | else | 815 | else |
816 | MainConsole.Instance.Output("No region with that name"); | 816 | MainConsole.Instance.Output("No region with that name"); |
@@ -820,14 +820,14 @@ namespace OpenSim | |||
820 | string regDeleteName = CombineParams(cmdparams, 0); | 820 | string regDeleteName = CombineParams(cmdparams, 0); |
821 | 821 | ||
822 | Scene killScene; | 822 | Scene killScene; |
823 | if (m_sceneManager.TryGetScene(regDeleteName, out killScene)) | 823 | if (SceneManager.TryGetScene(regDeleteName, out killScene)) |
824 | RemoveRegion(killScene, true); | 824 | RemoveRegion(killScene, true); |
825 | else | 825 | else |
826 | MainConsole.Instance.Output("no region with that name"); | 826 | MainConsole.Instance.Output("no region with that name"); |
827 | break; | 827 | break; |
828 | 828 | ||
829 | case "restart": | 829 | case "restart": |
830 | m_sceneManager.RestartCurrentScene(); | 830 | SceneManager.RestartCurrentScene(); |
831 | break; | 831 | break; |
832 | } | 832 | } |
833 | } | 833 | } |
@@ -842,7 +842,7 @@ namespace OpenSim | |||
842 | { | 842 | { |
843 | string newRegionName = CombineParams(cmdparams, 2); | 843 | string newRegionName = CombineParams(cmdparams, 2); |
844 | 844 | ||
845 | if (!m_sceneManager.TrySetCurrentScene(newRegionName)) | 845 | if (!SceneManager.TrySetCurrentScene(newRegionName)) |
846 | MainConsole.Instance.Output(String.Format("Couldn't select region {0}", newRegionName)); | 846 | MainConsole.Instance.Output(String.Format("Couldn't select region {0}", newRegionName)); |
847 | } | 847 | } |
848 | else | 848 | else |
@@ -850,7 +850,7 @@ namespace OpenSim | |||
850 | MainConsole.Instance.Output("Usage: change region <region name>"); | 850 | MainConsole.Instance.Output("Usage: change region <region name>"); |
851 | } | 851 | } |
852 | 852 | ||
853 | string regionName = (m_sceneManager.CurrentScene == null ? "root" : m_sceneManager.CurrentScene.RegionInfo.RegionName); | 853 | string regionName = (SceneManager.CurrentScene == null ? "root" : SceneManager.CurrentScene.RegionInfo.RegionName); |
854 | MainConsole.Instance.Output(String.Format("Currently selected region is {0}", regionName)); | 854 | MainConsole.Instance.Output(String.Format("Currently selected region is {0}", regionName)); |
855 | 855 | ||
856 | // m_log.DebugFormat("Original prompt is {0}", m_consolePrompt); | 856 | // m_log.DebugFormat("Original prompt is {0}", m_consolePrompt); |
@@ -868,7 +868,7 @@ namespace OpenSim | |||
868 | }); | 868 | }); |
869 | 869 | ||
870 | m_console.DefaultPrompt = prompt; | 870 | m_console.DefaultPrompt = prompt; |
871 | m_console.ConsoleScene = m_sceneManager.CurrentScene; | 871 | m_console.ConsoleScene = SceneManager.CurrentScene; |
872 | } | 872 | } |
873 | 873 | ||
874 | /// <summary> | 874 | /// <summary> |
@@ -892,7 +892,7 @@ namespace OpenSim | |||
892 | int newDebug; | 892 | int newDebug; |
893 | if (int.TryParse(args[2], out newDebug)) | 893 | if (int.TryParse(args[2], out newDebug)) |
894 | { | 894 | { |
895 | m_sceneManager.SetDebugPacketLevelOnCurrentScene(newDebug, name); | 895 | SceneManager.SetDebugPacketLevelOnCurrentScene(newDebug, name); |
896 | // We provide user information elsewhere if any clients had their debug level set. | 896 | // We provide user information elsewhere if any clients had their debug level set. |
897 | // MainConsole.Instance.OutputFormat("Debug packet level set to {0}", newDebug); | 897 | // MainConsole.Instance.OutputFormat("Debug packet level set to {0}", newDebug); |
898 | } | 898 | } |
@@ -907,7 +907,7 @@ namespace OpenSim | |||
907 | case "scene": | 907 | case "scene": |
908 | if (args.Length == 4) | 908 | if (args.Length == 4) |
909 | { | 909 | { |
910 | if (m_sceneManager.CurrentScene == null) | 910 | if (SceneManager.CurrentScene == null) |
911 | { | 911 | { |
912 | MainConsole.Instance.Output("Please use 'change region <regioname>' first"); | 912 | MainConsole.Instance.Output("Please use 'change region <regioname>' first"); |
913 | } | 913 | } |
@@ -915,7 +915,7 @@ namespace OpenSim | |||
915 | { | 915 | { |
916 | string key = args[2]; | 916 | string key = args[2]; |
917 | string value = args[3]; | 917 | string value = args[3]; |
918 | m_sceneManager.CurrentScene.SetSceneCoreDebug( | 918 | SceneManager.CurrentScene.SetSceneCoreDebug( |
919 | new Dictionary<string, string>() { { key, value } }); | 919 | new Dictionary<string, string>() { { key, value } }); |
920 | 920 | ||
921 | MainConsole.Instance.OutputFormat("Set debug scene {0} = {1}", key, value); | 921 | MainConsole.Instance.OutputFormat("Set debug scene {0} = {1}", key, value); |
@@ -954,10 +954,10 @@ namespace OpenSim | |||
954 | IList agents; | 954 | IList agents; |
955 | if (showParams.Length > 1 && showParams[1] == "full") | 955 | if (showParams.Length > 1 && showParams[1] == "full") |
956 | { | 956 | { |
957 | agents = m_sceneManager.GetCurrentScenePresences(); | 957 | agents = SceneManager.GetCurrentScenePresences(); |
958 | } else | 958 | } else |
959 | { | 959 | { |
960 | agents = m_sceneManager.GetCurrentSceneAvatars(); | 960 | agents = SceneManager.GetCurrentSceneAvatars(); |
961 | } | 961 | } |
962 | 962 | ||
963 | MainConsole.Instance.Output(String.Format("\nAgents connected: {0}\n", agents.Count)); | 963 | MainConsole.Instance.Output(String.Format("\nAgents connected: {0}\n", agents.Count)); |
@@ -1037,7 +1037,7 @@ namespace OpenSim | |||
1037 | MainConsole.Instance.Output("Shared Module: " + module.Name); | 1037 | MainConsole.Instance.Output("Shared Module: " + module.Name); |
1038 | } | 1038 | } |
1039 | 1039 | ||
1040 | m_sceneManager.ForEachScene( | 1040 | SceneManager.ForEachScene( |
1041 | delegate(Scene scene) { | 1041 | delegate(Scene scene) { |
1042 | m_log.Error("The currently loaded modules in " + scene.RegionInfo.RegionName + " are:"); | 1042 | m_log.Error("The currently loaded modules in " + scene.RegionInfo.RegionName + " are:"); |
1043 | foreach (IRegionModule module in scene.Modules.Values) | 1043 | foreach (IRegionModule module in scene.Modules.Values) |
@@ -1050,7 +1050,7 @@ namespace OpenSim | |||
1050 | } | 1050 | } |
1051 | ); | 1051 | ); |
1052 | 1052 | ||
1053 | m_sceneManager.ForEachScene( | 1053 | SceneManager.ForEachScene( |
1054 | delegate(Scene scene) { | 1054 | delegate(Scene scene) { |
1055 | MainConsole.Instance.Output("Loaded new region modules in" + scene.RegionInfo.RegionName + " are:"); | 1055 | MainConsole.Instance.Output("Loaded new region modules in" + scene.RegionInfo.RegionName + " are:"); |
1056 | foreach (IRegionModuleBase module in scene.RegionModules.Values) | 1056 | foreach (IRegionModuleBase module in scene.RegionModules.Values) |
@@ -1066,7 +1066,7 @@ namespace OpenSim | |||
1066 | break; | 1066 | break; |
1067 | 1067 | ||
1068 | case "regions": | 1068 | case "regions": |
1069 | m_sceneManager.ForEachScene( | 1069 | SceneManager.ForEachScene( |
1070 | delegate(Scene scene) | 1070 | delegate(Scene scene) |
1071 | { | 1071 | { |
1072 | MainConsole.Instance.Output(String.Format( | 1072 | MainConsole.Instance.Output(String.Format( |
@@ -1080,7 +1080,7 @@ namespace OpenSim | |||
1080 | break; | 1080 | break; |
1081 | 1081 | ||
1082 | case "ratings": | 1082 | case "ratings": |
1083 | m_sceneManager.ForEachScene( | 1083 | SceneManager.ForEachScene( |
1084 | delegate(Scene scene) | 1084 | delegate(Scene scene) |
1085 | { | 1085 | { |
1086 | string rating = ""; | 1086 | string rating = ""; |
@@ -1115,7 +1115,7 @@ namespace OpenSim | |||
1115 | cdt.AddColumn("IP", 16); | 1115 | cdt.AddColumn("IP", 16); |
1116 | cdt.AddColumn("Viewer Name", 24); | 1116 | cdt.AddColumn("Viewer Name", 24); |
1117 | 1117 | ||
1118 | m_sceneManager.ForEachScene( | 1118 | SceneManager.ForEachScene( |
1119 | s => | 1119 | s => |
1120 | { | 1120 | { |
1121 | foreach (AgentCircuitData aCircuit in s.AuthenticateHandler.GetAgentCircuits().Values) | 1121 | foreach (AgentCircuitData aCircuit in s.AuthenticateHandler.GetAgentCircuits().Values) |
@@ -1140,7 +1140,7 @@ namespace OpenSim | |||
1140 | cdt.AddColumn("Endpoint", 23); | 1140 | cdt.AddColumn("Endpoint", 23); |
1141 | cdt.AddColumn("Active?", 7); | 1141 | cdt.AddColumn("Active?", 7); |
1142 | 1142 | ||
1143 | m_sceneManager.ForEachScene( | 1143 | SceneManager.ForEachScene( |
1144 | s => s.ForEachClient( | 1144 | s => s.ForEachClient( |
1145 | c => cdt.AddRow( | 1145 | c => cdt.AddRow( |
1146 | s.Name, | 1146 | s.Name, |
@@ -1161,11 +1161,11 @@ namespace OpenSim | |||
1161 | { | 1161 | { |
1162 | if (cmdparams.Length > 5) | 1162 | if (cmdparams.Length > 5) |
1163 | { | 1163 | { |
1164 | m_sceneManager.SaveNamedPrimsToXml2(cmdparams[3], cmdparams[4]); | 1164 | SceneManager.SaveNamedPrimsToXml2(cmdparams[3], cmdparams[4]); |
1165 | } | 1165 | } |
1166 | else | 1166 | else |
1167 | { | 1167 | { |
1168 | m_sceneManager.SaveNamedPrimsToXml2("Primitive", DEFAULT_PRIM_BACKUP_FILENAME); | 1168 | SceneManager.SaveNamedPrimsToXml2("Primitive", DEFAULT_PRIM_BACKUP_FILENAME); |
1169 | } | 1169 | } |
1170 | } | 1170 | } |
1171 | 1171 | ||
@@ -1180,11 +1180,11 @@ namespace OpenSim | |||
1180 | 1180 | ||
1181 | if (cmdparams.Length > 0) | 1181 | if (cmdparams.Length > 0) |
1182 | { | 1182 | { |
1183 | m_sceneManager.SaveCurrentSceneToXml(cmdparams[2]); | 1183 | SceneManager.SaveCurrentSceneToXml(cmdparams[2]); |
1184 | } | 1184 | } |
1185 | else | 1185 | else |
1186 | { | 1186 | { |
1187 | m_sceneManager.SaveCurrentSceneToXml(DEFAULT_PRIM_BACKUP_FILENAME); | 1187 | SceneManager.SaveCurrentSceneToXml(DEFAULT_PRIM_BACKUP_FILENAME); |
1188 | } | 1188 | } |
1189 | } | 1189 | } |
1190 | 1190 | ||
@@ -1221,13 +1221,13 @@ namespace OpenSim | |||
1221 | MainConsole.Instance.Output(String.Format("loadOffsets <X,Y,Z> = <{0},{1},{2}>",loadOffset.X,loadOffset.Y,loadOffset.Z)); | 1221 | MainConsole.Instance.Output(String.Format("loadOffsets <X,Y,Z> = <{0},{1},{2}>",loadOffset.X,loadOffset.Y,loadOffset.Z)); |
1222 | } | 1222 | } |
1223 | } | 1223 | } |
1224 | m_sceneManager.LoadCurrentSceneFromXml(cmdparams[0], generateNewIDS, loadOffset); | 1224 | SceneManager.LoadCurrentSceneFromXml(cmdparams[2], generateNewIDS, loadOffset); |
1225 | } | 1225 | } |
1226 | else | 1226 | else |
1227 | { | 1227 | { |
1228 | try | 1228 | try |
1229 | { | 1229 | { |
1230 | m_sceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME, false, loadOffset); | 1230 | SceneManager.LoadCurrentSceneFromXml(DEFAULT_PRIM_BACKUP_FILENAME, false, loadOffset); |
1231 | } | 1231 | } |
1232 | catch (FileNotFoundException) | 1232 | catch (FileNotFoundException) |
1233 | { | 1233 | { |
@@ -1244,11 +1244,11 @@ namespace OpenSim | |||
1244 | { | 1244 | { |
1245 | if (cmdparams.Length > 2) | 1245 | if (cmdparams.Length > 2) |
1246 | { | 1246 | { |
1247 | m_sceneManager.SaveCurrentSceneToXml2(cmdparams[2]); | 1247 | SceneManager.SaveCurrentSceneToXml2(cmdparams[2]); |
1248 | } | 1248 | } |
1249 | else | 1249 | else |
1250 | { | 1250 | { |
1251 | m_sceneManager.SaveCurrentSceneToXml2(DEFAULT_PRIM_BACKUP_FILENAME); | 1251 | SceneManager.SaveCurrentSceneToXml2(DEFAULT_PRIM_BACKUP_FILENAME); |
1252 | } | 1252 | } |
1253 | } | 1253 | } |
1254 | 1254 | ||
@@ -1263,7 +1263,7 @@ namespace OpenSim | |||
1263 | { | 1263 | { |
1264 | try | 1264 | try |
1265 | { | 1265 | { |
1266 | m_sceneManager.LoadCurrentSceneFromXml2(cmdparams[2]); | 1266 | SceneManager.LoadCurrentSceneFromXml2(cmdparams[2]); |
1267 | } | 1267 | } |
1268 | catch (FileNotFoundException) | 1268 | catch (FileNotFoundException) |
1269 | { | 1269 | { |
@@ -1274,7 +1274,7 @@ namespace OpenSim | |||
1274 | { | 1274 | { |
1275 | try | 1275 | try |
1276 | { | 1276 | { |
1277 | m_sceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME); | 1277 | SceneManager.LoadCurrentSceneFromXml2(DEFAULT_PRIM_BACKUP_FILENAME); |
1278 | } | 1278 | } |
1279 | catch (FileNotFoundException) | 1279 | catch (FileNotFoundException) |
1280 | { | 1280 | { |
@@ -1291,7 +1291,7 @@ namespace OpenSim | |||
1291 | { | 1291 | { |
1292 | try | 1292 | try |
1293 | { | 1293 | { |
1294 | m_sceneManager.LoadArchiveToCurrentScene(cmdparams); | 1294 | SceneManager.LoadArchiveToCurrentScene(cmdparams); |
1295 | } | 1295 | } |
1296 | catch (Exception e) | 1296 | catch (Exception e) |
1297 | { | 1297 | { |
@@ -1305,7 +1305,7 @@ namespace OpenSim | |||
1305 | /// <param name="cmdparams"></param> | 1305 | /// <param name="cmdparams"></param> |
1306 | protected void SaveOar(string module, string[] cmdparams) | 1306 | protected void SaveOar(string module, string[] cmdparams) |
1307 | { | 1307 | { |
1308 | m_sceneManager.SaveCurrentSceneToArchive(cmdparams); | 1308 | SceneManager.SaveCurrentSceneToArchive(cmdparams); |
1309 | } | 1309 | } |
1310 | 1310 | ||
1311 | private static string CombineParams(string[] commandParams, int pos) | 1311 | private static string CombineParams(string[] commandParams, int pos) |
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 76ac246..f378153 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -40,7 +40,7 @@ using OpenSim.Framework.Communications; | |||
40 | using OpenSim.Framework.Console; | 40 | using OpenSim.Framework.Console; |
41 | using OpenSim.Framework.Servers; | 41 | using OpenSim.Framework.Servers; |
42 | using OpenSim.Framework.Servers.HttpServer; | 42 | using OpenSim.Framework.Servers.HttpServer; |
43 | using OpenSim.Framework.Statistics; | 43 | using OpenSim.Framework.Monitoring; |
44 | using OpenSim.Region.ClientStack; | 44 | using OpenSim.Region.ClientStack; |
45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; | 45 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts; |
46 | using OpenSim.Region.Framework; | 46 | using OpenSim.Region.Framework; |
@@ -300,7 +300,7 @@ namespace OpenSim | |||
300 | 300 | ||
301 | private void HandleCommanderCommand(string module, string[] cmd) | 301 | private void HandleCommanderCommand(string module, string[] cmd) |
302 | { | 302 | { |
303 | m_sceneManager.SendCommandToPluginModules(cmd); | 303 | SceneManager.SendCommandToPluginModules(cmd); |
304 | } | 304 | } |
305 | 305 | ||
306 | private void HandleCommanderHelp(string module, string[] cmd) | 306 | private void HandleCommanderHelp(string module, string[] cmd) |
@@ -318,7 +318,10 @@ namespace OpenSim | |||
318 | // Called from base.StartUp() | 318 | // Called from base.StartUp() |
319 | 319 | ||
320 | m_httpServerPort = m_networkServersInfo.HttpListenerPort; | 320 | m_httpServerPort = m_networkServersInfo.HttpListenerPort; |
321 | m_sceneManager.OnRestartSim += handleRestartRegion; | 321 | SceneManager.OnRestartSim += handleRestartRegion; |
322 | |||
323 | // Only start the memory watchdog once all regions are ready | ||
324 | SceneManager.OnRegionsReadyStatusChange += sm => MemoryWatchdog.Enabled = sm.AllRegionsReady; | ||
322 | } | 325 | } |
323 | 326 | ||
324 | /// <summary> | 327 | /// <summary> |
@@ -480,7 +483,7 @@ namespace OpenSim | |||
480 | scene.SnmpService.BootInfo("ScriptEngine started", scene); | 483 | scene.SnmpService.BootInfo("ScriptEngine started", scene); |
481 | } | 484 | } |
482 | 485 | ||
483 | m_sceneManager.Add(scene); | 486 | SceneManager.Add(scene); |
484 | 487 | ||
485 | if (m_autoCreateClientStack) | 488 | if (m_autoCreateClientStack) |
486 | { | 489 | { |
@@ -510,7 +513,6 @@ namespace OpenSim | |||
510 | } | 513 | } |
511 | 514 | ||
512 | scene.Start(); | 515 | scene.Start(); |
513 | |||
514 | scene.StartScripts(); | 516 | scene.StartScripts(); |
515 | 517 | ||
516 | return clientServer; | 518 | return clientServer; |
@@ -644,14 +646,14 @@ namespace OpenSim | |||
644 | { | 646 | { |
645 | // only need to check this if we are not at the | 647 | // only need to check this if we are not at the |
646 | // root level | 648 | // root level |
647 | if ((m_sceneManager.CurrentScene != null) && | 649 | if ((SceneManager.CurrentScene != null) && |
648 | (m_sceneManager.CurrentScene.RegionInfo.RegionID == scene.RegionInfo.RegionID)) | 650 | (SceneManager.CurrentScene.RegionInfo.RegionID == scene.RegionInfo.RegionID)) |
649 | { | 651 | { |
650 | m_sceneManager.TrySetCurrentScene(".."); | 652 | SceneManager.TrySetCurrentScene(".."); |
651 | } | 653 | } |
652 | 654 | ||
653 | scene.DeleteAllSceneObjects(); | 655 | scene.DeleteAllSceneObjects(); |
654 | m_sceneManager.CloseScene(scene); | 656 | SceneManager.CloseScene(scene); |
655 | ShutdownClientServer(scene.RegionInfo); | 657 | ShutdownClientServer(scene.RegionInfo); |
656 | 658 | ||
657 | if (!cleanup) | 659 | if (!cleanup) |
@@ -693,7 +695,7 @@ namespace OpenSim | |||
693 | public void RemoveRegion(string name, bool cleanUp) | 695 | public void RemoveRegion(string name, bool cleanUp) |
694 | { | 696 | { |
695 | Scene target; | 697 | Scene target; |
696 | if (m_sceneManager.TryGetScene(name, out target)) | 698 | if (SceneManager.TryGetScene(name, out target)) |
697 | RemoveRegion(target, cleanUp); | 699 | RemoveRegion(target, cleanUp); |
698 | } | 700 | } |
699 | 701 | ||
@@ -706,13 +708,13 @@ namespace OpenSim | |||
706 | { | 708 | { |
707 | // only need to check this if we are not at the | 709 | // only need to check this if we are not at the |
708 | // root level | 710 | // root level |
709 | if ((m_sceneManager.CurrentScene != null) && | 711 | if ((SceneManager.CurrentScene != null) && |
710 | (m_sceneManager.CurrentScene.RegionInfo.RegionID == scene.RegionInfo.RegionID)) | 712 | (SceneManager.CurrentScene.RegionInfo.RegionID == scene.RegionInfo.RegionID)) |
711 | { | 713 | { |
712 | m_sceneManager.TrySetCurrentScene(".."); | 714 | SceneManager.TrySetCurrentScene(".."); |
713 | } | 715 | } |
714 | 716 | ||
715 | m_sceneManager.CloseScene(scene); | 717 | SceneManager.CloseScene(scene); |
716 | ShutdownClientServer(scene.RegionInfo); | 718 | ShutdownClientServer(scene.RegionInfo); |
717 | } | 719 | } |
718 | 720 | ||
@@ -724,7 +726,7 @@ namespace OpenSim | |||
724 | public void CloseRegion(string name) | 726 | public void CloseRegion(string name) |
725 | { | 727 | { |
726 | Scene target; | 728 | Scene target; |
727 | if (m_sceneManager.TryGetScene(name, out target)) | 729 | if (SceneManager.TryGetScene(name, out target)) |
728 | CloseRegion(target); | 730 | CloseRegion(target); |
729 | } | 731 | } |
730 | 732 | ||
@@ -980,7 +982,7 @@ namespace OpenSim | |||
980 | 982 | ||
981 | try | 983 | try |
982 | { | 984 | { |
983 | m_sceneManager.Close(); | 985 | SceneManager.Close(); |
984 | } | 986 | } |
985 | catch (Exception e) | 987 | catch (Exception e) |
986 | { | 988 | { |
@@ -1005,7 +1007,7 @@ namespace OpenSim | |||
1005 | /// <param name="usernum">The first out parameter describing the number of all the avatars in the Region server</param> | 1007 | /// <param name="usernum">The first out parameter describing the number of all the avatars in the Region server</param> |
1006 | public void GetAvatarNumber(out int usernum) | 1008 | public void GetAvatarNumber(out int usernum) |
1007 | { | 1009 | { |
1008 | usernum = m_sceneManager.GetCurrentSceneAvatars().Count; | 1010 | usernum = SceneManager.GetCurrentSceneAvatars().Count; |
1009 | } | 1011 | } |
1010 | 1012 | ||
1011 | /// <summary> | 1013 | /// <summary> |
@@ -1014,7 +1016,7 @@ namespace OpenSim | |||
1014 | /// <param name="regionnum">The first out parameter describing the number of regions</param> | 1016 | /// <param name="regionnum">The first out parameter describing the number of regions</param> |
1015 | public void GetRegionNumber(out int regionnum) | 1017 | public void GetRegionNumber(out int regionnum) |
1016 | { | 1018 | { |
1017 | regionnum = m_sceneManager.Scenes.Count; | 1019 | regionnum = SceneManager.Scenes.Count; |
1018 | } | 1020 | } |
1019 | 1021 | ||
1020 | /// <summary> | 1022 | /// <summary> |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 098e4eb..f7bb817 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -41,7 +41,7 @@ using OpenMetaverse.Messages.Linden; | |||
41 | using OpenMetaverse.StructuredData; | 41 | using OpenMetaverse.StructuredData; |
42 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
43 | using OpenSim.Framework.Client; | 43 | using OpenSim.Framework.Client; |
44 | using OpenSim.Framework.Statistics; | 44 | using OpenSim.Framework.Monitoring; |
45 | using OpenSim.Region.Framework.Interfaces; | 45 | using OpenSim.Region.Framework.Interfaces; |
46 | using OpenSim.Region.Framework.Scenes; | 46 | using OpenSim.Region.Framework.Scenes; |
47 | using OpenSim.Services.Interfaces; | 47 | using OpenSim.Services.Interfaces; |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 86d8f62..7042c9a 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -37,7 +37,7 @@ using log4net; | |||
37 | using Nini.Config; | 37 | using Nini.Config; |
38 | using OpenMetaverse.Packets; | 38 | using OpenMetaverse.Packets; |
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Statistics; | 40 | using OpenSim.Framework.Monitoring; |
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenMetaverse; | 42 | using OpenMetaverse; |
43 | 43 | ||
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index c4324e8..4672f8a 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs | |||
@@ -53,9 +53,8 @@ namespace OpenSim.Region.ClientStack | |||
53 | protected ISimulationDataService m_simulationDataService; | 53 | protected ISimulationDataService m_simulationDataService; |
54 | protected IEstateDataService m_estateDataService; | 54 | protected IEstateDataService m_estateDataService; |
55 | protected ClientStackManager m_clientStackManager; | 55 | protected ClientStackManager m_clientStackManager; |
56 | protected SceneManager m_sceneManager = new SceneManager(); | ||
57 | 56 | ||
58 | public SceneManager SceneManager { get { return m_sceneManager; } } | 57 | public SceneManager SceneManager { get; protected set; } |
59 | public NetworkServersInfo NetServersInfo { get { return m_networkServersInfo; } } | 58 | public NetworkServersInfo NetServersInfo { get { return m_networkServersInfo; } } |
60 | public ISimulationDataService SimulationDataService { get { return m_simulationDataService; } } | 59 | public ISimulationDataService SimulationDataService { get { return m_simulationDataService; } } |
61 | public IEstateDataService EstateDataService { get { return m_estateDataService; } } | 60 | public IEstateDataService EstateDataService { get { return m_estateDataService; } } |
@@ -77,6 +76,7 @@ namespace OpenSim.Region.ClientStack | |||
77 | 76 | ||
78 | protected override void StartupSpecific() | 77 | protected override void StartupSpecific() |
79 | { | 78 | { |
79 | SceneManager = new SceneManager(); | ||
80 | m_clientStackManager = CreateClientStackManager(); | 80 | m_clientStackManager = CreateClientStackManager(); |
81 | 81 | ||
82 | Initialize(); | 82 | Initialize(); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Commands/UserCommandsModule.cs b/OpenSim/Region/CoreModules/Avatar/Commands/UserCommandsModule.cs index 4bcd2ac..764adf9 100644 --- a/OpenSim/Region/CoreModules/Avatar/Commands/UserCommandsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Commands/UserCommandsModule.cs | |||
@@ -37,7 +37,7 @@ using Nini.Config; | |||
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Console; | 39 | using OpenSim.Framework.Console; |
40 | using OpenSim.Framework.Statistics; | 40 | using OpenSim.Framework.Monitoring; |
41 | using OpenSim.Region.Framework.Interfaces; | 41 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
43 | 43 | ||
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index d30c2e2..9a56f42 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -204,8 +204,9 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
204 | 204 | ||
205 | AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId); | 205 | AssetBase asset = m_Scene.CreateAsset(name, description, assetType, data, remoteClient.AgentId); |
206 | m_Scene.AssetService.Store(asset); | 206 | m_Scene.AssetService.Store(asset); |
207 | 207 | m_Scene.CreateNewInventoryItem( | |
208 | m_Scene.CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate); | 208 | remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, |
209 | name, description, 0, callbackID, asset, invType, nextOwnerMask, creationDate); | ||
209 | } | 210 | } |
210 | else | 211 | else |
211 | { | 212 | { |
diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs index a6e2548..4a76b00 100644 --- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs +++ b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs | |||
@@ -40,6 +40,7 @@ using OpenMetaverse; | |||
40 | using OpenMetaverse.StructuredData; | 40 | using OpenMetaverse.StructuredData; |
41 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
42 | using OpenSim.Framework.Capabilities; | 42 | using OpenSim.Framework.Capabilities; |
43 | using OpenSim.Framework.Monitoring; | ||
43 | using OpenSim.Framework.Servers; | 44 | using OpenSim.Framework.Servers; |
44 | using OpenSim.Region.Framework.Interfaces; | 45 | using OpenSim.Region.Framework.Interfaces; |
45 | using OpenSim.Region.Framework.Scenes; | 46 | using OpenSim.Region.Framework.Scenes; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs index 990dffb..11e0150 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs | |||
@@ -31,7 +31,7 @@ using System.Collections.Generic; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Statistics; | 34 | using OpenSim.Framework.Monitoring; |
35 | using OpenSim.Services.Connectors; | 35 | using OpenSim.Services.Connectors; |
36 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index 7ed1320..e4c6c1a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | |||
@@ -134,11 +134,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
134 | ///<summary> | 134 | ///<summary> |
135 | /// | 135 | /// |
136 | ///</summary> | 136 | ///</summary> |
137 | |||
138 | |||
139 | ///<summary> | ||
140 | /// | ||
141 | ///</summary> | ||
142 | public void AddRegion(Scene scene) | 137 | public void AddRegion(Scene scene) |
143 | { | 138 | { |
144 | if (! m_enabled) | 139 | if (! m_enabled) |
@@ -149,7 +144,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
149 | lock (m_scenes) | 144 | lock (m_scenes) |
150 | m_scenes[scene.RegionInfo.RegionID] = scene; | 145 | m_scenes[scene.RegionInfo.RegionID] = scene; |
151 | 146 | ||
152 | scene.EventManager.OnRegionReady += s => UploadMapTile(s); | 147 | scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) UploadMapTile(s); }; |
153 | } | 148 | } |
154 | 149 | ||
155 | ///<summary> | 150 | ///<summary> |
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index e5cd3e2..09f6758 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs | |||
@@ -37,7 +37,7 @@ using Nini.Config; | |||
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Console; | 39 | using OpenSim.Framework.Console; |
40 | using OpenSim.Framework.Statistics; | 40 | using OpenSim.Framework.Monitoring; |
41 | using OpenSim.Region.Framework.Interfaces; | 41 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
43 | 43 | ||
diff --git a/OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs b/OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs index 2838e0c..7d35473 100644 --- a/OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Region/RegionCommandsModule.cs | |||
@@ -37,7 +37,7 @@ using Nini.Config; | |||
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Console; | 39 | using OpenSim.Framework.Console; |
40 | using OpenSim.Framework.Statistics; | 40 | using OpenSim.Framework.Monitoring; |
41 | using OpenSim.Region.Framework.Interfaces; | 41 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
43 | 43 | ||
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 309856f..26b406e 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -42,6 +42,7 @@ using OpenMetaverse.Imaging; | |||
42 | using OpenMetaverse.StructuredData; | 42 | using OpenMetaverse.StructuredData; |
43 | using OpenSim.Framework; | 43 | using OpenSim.Framework; |
44 | using OpenSim.Framework.Capabilities; | 44 | using OpenSim.Framework.Capabilities; |
45 | using OpenSim.Framework.Monitoring; | ||
45 | using OpenSim.Framework.Servers; | 46 | using OpenSim.Framework.Servers; |
46 | using OpenSim.Framework.Servers.HttpServer; | 47 | using OpenSim.Framework.Servers.HttpServer; |
47 | using OpenSim.Region.Framework.Interfaces; | 48 | using OpenSim.Region.Framework.Interfaces; |
diff --git a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs index 3f68ee0..0fe681f 100644 --- a/OpenSim/Region/Framework/Interfaces/IScenePresence.cs +++ b/OpenSim/Region/Framework/Interfaces/IScenePresence.cs | |||
@@ -40,8 +40,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
40 | /// </remarks> | 40 | /// </remarks> |
41 | public interface IScenePresence : ISceneAgent | 41 | public interface IScenePresence : ISceneAgent |
42 | { | 42 | { |
43 | PresenceType PresenceType { get; } | ||
44 | |||
45 | /// <summary> | 43 | /// <summary> |
46 | /// Copy of the script states while the agent is in transit. This state may | 44 | /// Copy of the script states while the agent is in transit. This state may |
47 | /// need to be placed back in case of transfer fail. | 45 | /// need to be placed back in case of transfer fail. |
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 418904f..7cb3811 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -517,8 +517,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
517 | /// A region is considered ready when startup operations such as loading of scripts already on the region | 517 | /// A region is considered ready when startup operations such as loading of scripts already on the region |
518 | /// have been completed. | 518 | /// have been completed. |
519 | /// </remarks> | 519 | /// </remarks> |
520 | public event RegionReady OnRegionReady; | 520 | public event Action<IScene> OnRegionReadyStatusChange; |
521 | public delegate void RegionReady(IScene scene); | ||
522 | 521 | ||
523 | public delegate void PrimsLoaded(Scene s); | 522 | public delegate void PrimsLoaded(Scene s); |
524 | public event PrimsLoaded OnPrimsLoaded; | 523 | public event PrimsLoaded OnPrimsLoaded; |
@@ -2533,13 +2532,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
2533 | } | 2532 | } |
2534 | } | 2533 | } |
2535 | 2534 | ||
2536 | public void TriggerRegionReady(IScene scene) | 2535 | public void TriggerRegionReadyStatusChange(IScene scene) |
2537 | { | 2536 | { |
2538 | RegionReady handler = OnRegionReady; | 2537 | Action<IScene> handler = OnRegionReadyStatusChange; |
2539 | 2538 | ||
2540 | if (handler != null) | 2539 | if (handler != null) |
2541 | { | 2540 | { |
2542 | foreach (RegionReady d in handler.GetInvocationList()) | 2541 | foreach (Action<IScene> d in handler.GetInvocationList()) |
2543 | { | 2542 | { |
2544 | try | 2543 | try |
2545 | { | 2544 | { |
@@ -2547,7 +2546,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2547 | } | 2546 | } |
2548 | catch (Exception e) | 2547 | catch (Exception e) |
2549 | { | 2548 | { |
2550 | m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionReady failed - continuing {0} - {1}", | 2549 | m_log.ErrorFormat("[EVENT MANAGER]: Delegate for OnRegionReadyStatusChange failed - continuing {0} - {1}", |
2551 | e.Message, e.StackTrace); | 2550 | e.Message, e.StackTrace); |
2552 | } | 2551 | } |
2553 | } | 2552 | } |
diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs index 1365831..c11174d 100644 --- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs +++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs | |||
@@ -39,7 +39,7 @@ using OpenSim.Framework.Communications; | |||
39 | using OpenSim.Framework.Console; | 39 | using OpenSim.Framework.Console; |
40 | using OpenSim.Framework.Servers; | 40 | using OpenSim.Framework.Servers; |
41 | using OpenSim.Framework.Servers.HttpServer; | 41 | using OpenSim.Framework.Servers.HttpServer; |
42 | using OpenSim.Framework.Statistics; | 42 | using OpenSim.Framework.Monitoring; |
43 | using OpenSim.Region.Framework; | 43 | using OpenSim.Region.Framework; |
44 | using OpenSim.Region.Framework.Interfaces; | 44 | using OpenSim.Region.Framework.Interfaces; |
45 | using OpenSim.Region.Framework.Scenes; | 45 | using OpenSim.Region.Framework.Scenes; |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 98b8fcc..672d95a 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -811,16 +811,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
811 | && oldAgentID == LibraryService.LibraryRootFolder.Owner)) | 811 | && oldAgentID == LibraryService.LibraryRootFolder.Owner)) |
812 | { | 812 | { |
813 | CreateNewInventoryItem( | 813 | CreateNewInventoryItem( |
814 | remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Flags, callbackID, asset, (sbyte)item.InvType, | 814 | remoteClient, item.CreatorId, item.CreatorData, newFolderID, |
815 | item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); | 815 | newName, item.Description, item.Flags, callbackID, asset, (sbyte)item.InvType, |
816 | item.BasePermissions, item.CurrentPermissions, item.EveryOnePermissions, | ||
817 | item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); | ||
816 | } | 818 | } |
817 | else | 819 | else |
818 | { | 820 | { |
819 | // If item is transfer or permissions are off or calling agent is allowed to copy item owner's inventory item. | 821 | // If item is transfer or permissions are off or calling agent is allowed to copy item owner's inventory item. |
820 | if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0) && (m_permissions.BypassPermissions() || m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID))) | 822 | if (((item.CurrentPermissions & (uint)PermissionMask.Transfer) != 0) |
823 | && (m_permissions.BypassPermissions() | ||
824 | || m_permissions.CanCopyUserInventory(remoteClient.AgentId, oldItemID))) | ||
821 | { | 825 | { |
822 | CreateNewInventoryItem( | 826 | CreateNewInventoryItem( |
823 | remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Flags, callbackID, | 827 | remoteClient, item.CreatorId, item.CreatorData, newFolderID, newName, item.Description, item.Flags, callbackID, |
824 | asset, (sbyte) item.InvType, | 828 | asset, (sbyte) item.InvType, |
825 | item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, | 829 | item.NextPermissions, item.NextPermissions, item.EveryOnePermissions & item.NextPermissions, |
826 | item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); | 830 | item.NextPermissions, item.GroupPermissions, Util.UnixTimeSinceEpoch()); |
@@ -885,32 +889,50 @@ namespace OpenSim.Region.Framework.Scenes | |||
885 | /// <summary> | 889 | /// <summary> |
886 | /// Create a new inventory item. | 890 | /// Create a new inventory item. |
887 | /// </summary> | 891 | /// </summary> |
888 | /// <param name="remoteClient"></param> | 892 | /// <param name="remoteClient">Client creating this inventory item.</param> |
889 | /// <param name="folderID"></param> | 893 | /// <param name="creatorID"></param> |
890 | /// <param name="callbackID"></param> | 894 | /// <param name="creatorData"></param> |
891 | /// <param name="asset"></param> | 895 | /// <param name="folderID">UUID of folder in which this item should be placed.</param> |
892 | /// <param name="invType"></param> | 896 | /// <param name="name">Item name.</para> |
893 | /// <param name="nextOwnerMask"></param> | 897 | /// <param name="description">Item description.</param> |
894 | public void CreateNewInventoryItem(IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, uint flags, uint callbackID, | 898 | /// <param name="flags">Item flags</param> |
895 | AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate) | 899 | /// <param name="callbackID">Generated by the client.</para> |
900 | /// <param name="asset">Asset to which this item refers.</param> | ||
901 | /// <param name="invType">Type of inventory item.</param> | ||
902 | /// <param name="nextOwnerMask">Next owner pemrissions mask.</param> | ||
903 | /// <param name="creationDate">Unix timestamp at which this item was created.</param> | ||
904 | public void CreateNewInventoryItem( | ||
905 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, | ||
906 | string name, string description, uint flags, uint callbackID, | ||
907 | AssetBase asset, sbyte invType, uint nextOwnerMask, int creationDate) | ||
896 | { | 908 | { |
897 | CreateNewInventoryItem( | 909 | CreateNewInventoryItem( |
898 | remoteClient, creatorID, creatorData, folderID, name, flags, callbackID, asset, invType, | 910 | remoteClient, creatorID, creatorData, folderID, name, description, flags, callbackID, asset, invType, |
899 | (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate); | 911 | (uint)PermissionMask.All, (uint)PermissionMask.All, 0, nextOwnerMask, 0, creationDate); |
900 | } | 912 | } |
901 | 913 | ||
902 | /// <summary> | 914 | /// <summary> |
903 | /// Create a new Inventory Item | 915 | /// Create a new Inventory Item |
904 | /// </summary> | 916 | /// </summary> |
905 | /// <param name="remoteClient"></param> | 917 | /// <param name="remoteClient">Client creating this inventory item.</param> |
906 | /// <param name="folderID"></param> | 918 | /// <param name="creatorID"></param> |
907 | /// <param name="callbackID"></param> | 919 | /// <param name="creatorData"></param> |
908 | /// <param name="asset"></param> | 920 | /// <param name="folderID">UUID of folder in which this item should be placed.</param> |
909 | /// <param name="invType"></param> | 921 | /// <param name="name">Item name.</para> |
910 | /// <param name="nextOwnerMask"></param> | 922 | /// <param name="description">Item description.</param> |
911 | /// <param name="creationDate"></param> | 923 | /// <param name="flags">Item flags</param> |
924 | /// <param name="callbackID">Generated by the client.</para> | ||
925 | /// <param name="asset">Asset to which this item refers.</param> | ||
926 | /// <param name="invType">Type of inventory item.</param> | ||
927 | /// <param name="baseMask">Base permissions mask.</param> | ||
928 | /// <param name="currentMask">Current permissions mask.</param> | ||
929 | /// <param name="everyoneMask">Everyone permissions mask.</param> | ||
930 | /// <param name="nextOwnerMask">Next owner pemrissions mask.</param> | ||
931 | /// <param name="groupMask">Group permissions mask.</param> | ||
932 | /// <param name="creationDate">Unix timestamp at which this item was created.</param> | ||
912 | private void CreateNewInventoryItem( | 933 | private void CreateNewInventoryItem( |
913 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, string name, uint flags, uint callbackID, AssetBase asset, sbyte invType, | 934 | IClientAPI remoteClient, string creatorID, string creatorData, UUID folderID, |
935 | string name, string description, uint flags, uint callbackID, AssetBase asset, sbyte invType, | ||
914 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) | 936 | uint baseMask, uint currentMask, uint everyoneMask, uint nextOwnerMask, uint groupMask, int creationDate) |
915 | { | 937 | { |
916 | InventoryItemBase item = new InventoryItemBase(); | 938 | InventoryItemBase item = new InventoryItemBase(); |
@@ -919,8 +941,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
919 | item.CreatorData = creatorData; | 941 | item.CreatorData = creatorData; |
920 | item.ID = UUID.Random(); | 942 | item.ID = UUID.Random(); |
921 | item.AssetID = asset.FullID; | 943 | item.AssetID = asset.FullID; |
922 | item.Description = asset.Description; | ||
923 | item.Name = name; | 944 | item.Name = name; |
945 | item.Description = description; | ||
924 | item.Flags = flags; | 946 | item.Flags = flags; |
925 | item.AssetType = asset.Type; | 947 | item.AssetType = asset.Type; |
926 | item.InvType = invType; | 948 | item.InvType = invType; |
@@ -1002,7 +1024,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1002 | asset.Description = description; | 1024 | asset.Description = description; |
1003 | 1025 | ||
1004 | CreateNewInventoryItem( | 1026 | CreateNewInventoryItem( |
1005 | remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, name, 0, callbackID, asset, invType, | 1027 | remoteClient, remoteClient.AgentId.ToString(), string.Empty, folderID, |
1028 | name, description, 0, callbackID, asset, invType, | ||
1006 | (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, | 1029 | (uint)PermissionMask.All, (uint)PermissionMask.All, (uint)PermissionMask.All, |
1007 | (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch()); | 1030 | (uint)PermissionMask.All, (uint)PermissionMask.All, Util.UnixTimeSinceEpoch()); |
1008 | } | 1031 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 0bf2259..f7d74db 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -40,6 +40,7 @@ using OpenMetaverse; | |||
40 | using OpenMetaverse.Packets; | 40 | using OpenMetaverse.Packets; |
41 | using OpenMetaverse.Imaging; | 41 | using OpenMetaverse.Imaging; |
42 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
43 | using OpenSim.Framework.Monitoring; | ||
43 | using OpenSim.Services.Interfaces; | 44 | using OpenSim.Services.Interfaces; |
44 | using OpenSim.Framework.Communications; | 45 | using OpenSim.Framework.Communications; |
45 | using OpenSim.Framework.Console; | 46 | using OpenSim.Framework.Console; |
@@ -1232,15 +1233,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
1232 | avatar.ControllingClient.SendShutdownConnectionNotice(); | 1233 | avatar.ControllingClient.SendShutdownConnectionNotice(); |
1233 | }); | 1234 | }); |
1234 | 1235 | ||
1236 | // Stop updating the scene objects and agents. | ||
1237 | m_shuttingDown = true; | ||
1238 | |||
1235 | // Wait here, or the kick messages won't actually get to the agents before the scene terminates. | 1239 | // Wait here, or the kick messages won't actually get to the agents before the scene terminates. |
1240 | // We also need to wait to avoid a race condition with the scene update loop which might not yet | ||
1241 | // have checked ShuttingDown. | ||
1236 | Thread.Sleep(500); | 1242 | Thread.Sleep(500); |
1237 | 1243 | ||
1238 | // Stop all client threads. | 1244 | // Stop all client threads. |
1239 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); | 1245 | ForEachScenePresence(delegate(ScenePresence avatar) { avatar.ControllingClient.Close(); }); |
1240 | 1246 | ||
1241 | // Stop updating the scene objects and agents. | ||
1242 | m_shuttingDown = true; | ||
1243 | |||
1244 | m_log.Debug("[SCENE]: Persisting changed objects"); | 1247 | m_log.Debug("[SCENE]: Persisting changed objects"); |
1245 | EventManager.TriggerSceneShuttingDown(this); | 1248 | EventManager.TriggerSceneShuttingDown(this); |
1246 | 1249 | ||
@@ -1255,6 +1258,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
1255 | 1258 | ||
1256 | m_sceneGraph.Close(); | 1259 | m_sceneGraph.Close(); |
1257 | 1260 | ||
1261 | if (PhysicsScene != null) | ||
1262 | { | ||
1263 | PhysicsScene phys = PhysicsScene; | ||
1264 | // remove the physics engine from both Scene and SceneGraph | ||
1265 | PhysicsScene = null; | ||
1266 | phys.Dispose(); | ||
1267 | phys = null; | ||
1268 | } | ||
1269 | |||
1258 | if (!GridService.DeregisterRegion(RegionInfo.RegionID)) | 1270 | if (!GridService.DeregisterRegion(RegionInfo.RegionID)) |
1259 | m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name); | 1271 | m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name); |
1260 | 1272 | ||
@@ -1553,8 +1565,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1553 | m_sceneGridService.InformNeighborsThatRegionisUp( | 1565 | m_sceneGridService.InformNeighborsThatRegionisUp( |
1554 | RequestModuleInterface<INeighbourService>(), RegionInfo); | 1566 | RequestModuleInterface<INeighbourService>(), RegionInfo); |
1555 | 1567 | ||
1556 | // Region ready should always be triggered whether logins are immediately enabled or not. | 1568 | // Region ready should always be set |
1557 | EventManager.TriggerRegionReady(this); | 1569 | Ready = true; |
1558 | } | 1570 | } |
1559 | else | 1571 | else |
1560 | { | 1572 | { |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index d55b082..7c8bd88 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -124,6 +124,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
124 | } | 124 | } |
125 | private bool m_loginsEnabled; | 125 | private bool m_loginsEnabled; |
126 | 126 | ||
127 | public bool Ready | ||
128 | { | ||
129 | get | ||
130 | { | ||
131 | return m_ready; | ||
132 | } | ||
133 | |||
134 | set | ||
135 | { | ||
136 | if (m_ready != value) | ||
137 | { | ||
138 | m_ready = value; | ||
139 | EventManager.TriggerRegionReadyStatusChange(this); | ||
140 | } | ||
141 | } | ||
142 | } | ||
143 | private bool m_ready; | ||
144 | |||
127 | public float TimeDilation | 145 | public float TimeDilation |
128 | { | 146 | { |
129 | get { return 1.0f; } | 147 | get { return 1.0f; } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index e3fed49..a412414 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -47,6 +47,48 @@ namespace OpenSim.Region.Framework.Scenes | |||
47 | 47 | ||
48 | public event RestartSim OnRestartSim; | 48 | public event RestartSim OnRestartSim; |
49 | 49 | ||
50 | /// <summary> | ||
51 | /// Fired when either all regions are ready for use or at least one region has become unready for use where | ||
52 | /// previously all regions were ready. | ||
53 | /// </summary> | ||
54 | public event Action<SceneManager> OnRegionsReadyStatusChange; | ||
55 | |||
56 | /// <summary> | ||
57 | /// Are all regions ready for use? | ||
58 | /// </summary> | ||
59 | public bool AllRegionsReady | ||
60 | { | ||
61 | get | ||
62 | { | ||
63 | return m_allRegionsReady; | ||
64 | } | ||
65 | |||
66 | private set | ||
67 | { | ||
68 | if (m_allRegionsReady != value) | ||
69 | { | ||
70 | m_allRegionsReady = value; | ||
71 | Action<SceneManager> handler = OnRegionsReadyStatusChange; | ||
72 | if (handler != null) | ||
73 | { | ||
74 | foreach (Action<SceneManager> d in handler.GetInvocationList()) | ||
75 | { | ||
76 | try | ||
77 | { | ||
78 | d(this); | ||
79 | } | ||
80 | catch (Exception e) | ||
81 | { | ||
82 | m_log.ErrorFormat("[SCENE MANAGER]: Delegate for OnRegionsReadyStatusChange failed - continuing {0} - {1}", | ||
83 | e.Message, e.StackTrace); | ||
84 | } | ||
85 | } | ||
86 | } | ||
87 | } | ||
88 | } | ||
89 | } | ||
90 | private bool m_allRegionsReady; | ||
91 | |||
50 | private static SceneManager m_instance = null; | 92 | private static SceneManager m_instance = null; |
51 | public static SceneManager Instance | 93 | public static SceneManager Instance |
52 | { | 94 | { |
@@ -128,9 +170,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
128 | 170 | ||
129 | public void Add(Scene scene) | 171 | public void Add(Scene scene) |
130 | { | 172 | { |
131 | scene.OnRestart += HandleRestart; | 173 | lock (m_localScenes) |
174 | m_localScenes.Add(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene); | ||
132 | 175 | ||
133 | m_localScenes.Add(scene.RegionInfo.RegionID, scene.RegionInfo.RegionName, scene); | 176 | scene.OnRestart += HandleRestart; |
177 | scene.EventManager.OnRegionReadyStatusChange += HandleRegionReadyStatusChange; | ||
134 | } | 178 | } |
135 | 179 | ||
136 | public void HandleRestart(RegionInfo rdata) | 180 | public void HandleRestart(RegionInfo rdata) |
@@ -138,12 +182,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
138 | m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main"); | 182 | m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main"); |
139 | int RegionSceneElement = -1; | 183 | int RegionSceneElement = -1; |
140 | 184 | ||
141 | m_localScenes.Remove(rdata.RegionID); | 185 | lock (m_localScenes) |
186 | m_localScenes.Remove(rdata.RegionID); | ||
142 | 187 | ||
143 | // Send signal to main that we're restarting this sim. | 188 | // Send signal to main that we're restarting this sim. |
144 | OnRestartSim(rdata); | 189 | OnRestartSim(rdata); |
145 | } | 190 | } |
146 | 191 | ||
192 | private void HandleRegionReadyStatusChange(IScene scene) | ||
193 | { | ||
194 | lock (m_localScenes) | ||
195 | AllRegionsReady = m_localScenes.TrueForAll(s => s.Ready); | ||
196 | } | ||
197 | |||
147 | public void SendSimOnlineNotification(ulong regionHandle) | 198 | public void SendSimOnlineNotification(ulong regionHandle) |
148 | { | 199 | { |
149 | RegionInfo Result = null; | 200 | RegionInfo Result = null; |
@@ -483,7 +534,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
483 | 534 | ||
484 | public void CloseScene(Scene scene) | 535 | public void CloseScene(Scene scene) |
485 | { | 536 | { |
486 | m_localScenes.Remove(scene.RegionInfo.RegionID); | 537 | lock (m_localScenes) |
538 | m_localScenes.Remove(scene.RegionInfo.RegionID); | ||
487 | 539 | ||
488 | scene.Close(); | 540 | scene.Close(); |
489 | } | 541 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index d6ff5a2..20919a1 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | |||
@@ -30,7 +30,7 @@ using System.Collections.Generic; | |||
30 | using System.Timers; | 30 | using System.Timers; |
31 | using OpenMetaverse.Packets; | 31 | using OpenMetaverse.Packets; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Statistics; | 33 | using OpenSim.Framework.Monitoring; |
34 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
35 | 35 | ||
36 | namespace OpenSim.Region.Framework.Scenes | 36 | namespace OpenSim.Region.Framework.Scenes |
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index 86f33eb..3b83e58 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs | |||
@@ -38,6 +38,7 @@ using OpenMetaverse; | |||
38 | using OpenMetaverse.Packets; | 38 | using OpenMetaverse.Packets; |
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Client; | 40 | using OpenSim.Framework.Client; |
41 | using OpenSim.Framework.Monitoring; | ||
41 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
42 | 43 | ||
43 | namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | 44 | namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server |
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCServer.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCServer.cs index a7c5020..9d27386 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCServer.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCServer.cs | |||
@@ -34,6 +34,7 @@ using System.Text; | |||
34 | using System.Threading; | 34 | using System.Threading; |
35 | using log4net; | 35 | using log4net; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Monitoring; | ||
37 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
38 | 39 | ||
39 | namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | 40 | namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server |
diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index ca9bd4a..5fe5948 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | |||
@@ -35,7 +35,7 @@ using Nini.Config; | |||
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Console; | 37 | using OpenSim.Framework.Console; |
38 | using OpenSim.Framework.Statistics; | 38 | using OpenSim.Framework.Monitoring; |
39 | using OpenSim.Region.ClientStack.LindenUDP; | 39 | using OpenSim.Region.ClientStack.LindenUDP; |
40 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs index 6bb6729..d718a2f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs | |||
@@ -36,7 +36,7 @@ using Nini.Config; | |||
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Console; | 38 | using OpenSim.Framework.Console; |
39 | using OpenSim.Framework.Statistics; | 39 | using OpenSim.Framework.Monitoring; |
40 | using OpenSim.Region.ClientStack.LindenUDP; | 40 | using OpenSim.Region.ClientStack.LindenUDP; |
41 | using OpenSim.Region.Framework.Interfaces; | 41 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs index 1b9e3ac..d68aabc 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs | |||
@@ -36,7 +36,7 @@ using Nini.Config; | |||
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Console; | 38 | using OpenSim.Framework.Console; |
39 | using OpenSim.Framework.Statistics; | 39 | using OpenSim.Framework.Monitoring; |
40 | using OpenSim.Region.ClientStack.LindenUDP; | 40 | using OpenSim.Region.ClientStack.LindenUDP; |
41 | using OpenSim.Region.Framework.Interfaces; | 41 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs index cd401a6..ca956fb 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs | |||
@@ -37,6 +37,7 @@ using OpenMetaverse; | |||
37 | using log4net; | 37 | using log4net; |
38 | using Nini.Config; | 38 | using Nini.Config; |
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Monitoring; | ||
40 | using OpenSim.Region.Framework.Interfaces; | 41 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
42 | 43 | ||
diff --git a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs index 2602050..4e84364 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs | |||
@@ -37,7 +37,7 @@ using Nini.Config; | |||
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Console; | 39 | using OpenSim.Framework.Console; |
40 | using OpenSim.Framework.Statistics; | 40 | using OpenSim.Framework.Monitoring; |
41 | using OpenSim.Region.ClientStack.LindenUDP; | 41 | using OpenSim.Region.ClientStack.LindenUDP; |
42 | using OpenSim.Region.CoreModules.Avatar.Friends; | 42 | using OpenSim.Region.CoreModules.Avatar.Friends; |
43 | using OpenSim.Region.Framework.Interfaces; | 43 | using OpenSim.Region.Framework.Interfaces; |
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index f459b8c..fff3a32 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs | |||
@@ -225,7 +225,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady | |||
225 | RRAlert("enabled"); | 225 | RRAlert("enabled"); |
226 | } | 226 | } |
227 | 227 | ||
228 | m_scene.EventManager.TriggerRegionReady(m_scene); | 228 | m_scene.Ready = true; |
229 | } | 229 | } |
230 | 230 | ||
231 | public void OarLoadingAlert(string msg) | 231 | public void OarLoadingAlert(string msg) |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs new file mode 100755 index 0000000..fbb9e21 --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs | |||
@@ -0,0 +1,115 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyrightD | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | using OpenMetaverse; | ||
31 | |||
32 | namespace OpenSim.Region.Physics.BulletSPlugin | ||
33 | { | ||
34 | |||
35 | public class BSConstraint : IDisposable | ||
36 | { | ||
37 | private BulletSim m_world; | ||
38 | private BulletBody m_body1; | ||
39 | private BulletBody m_body2; | ||
40 | private BulletConstraint m_constraint; | ||
41 | private bool m_enabled = false; | ||
42 | |||
43 | public BSConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, | ||
44 | Vector3 frame1, Quaternion frame1rot, | ||
45 | Vector3 frame2, Quaternion frame2rot | ||
46 | ) | ||
47 | { | ||
48 | m_world = world; | ||
49 | m_body1 = obj1; | ||
50 | m_body2 = obj2; | ||
51 | m_constraint = new BulletConstraint(BulletSimAPI.CreateConstraint2(m_world.Ptr, m_body1.Ptr, m_body2.Ptr, | ||
52 | frame1, frame1rot, | ||
53 | frame2, frame2rot)); | ||
54 | m_enabled = true; | ||
55 | } | ||
56 | |||
57 | public void Dispose() | ||
58 | { | ||
59 | if (m_enabled) | ||
60 | { | ||
61 | // BulletSimAPI.RemoveConstraint(m_world.ID, m_body1.ID, m_body2.ID); | ||
62 | BulletSimAPI.DestroyConstraint2(m_world.Ptr, m_constraint.Ptr); | ||
63 | m_enabled = false; | ||
64 | } | ||
65 | } | ||
66 | |||
67 | public BulletBody Body1 { get { return m_body1; } } | ||
68 | public BulletBody Body2 { get { return m_body2; } } | ||
69 | |||
70 | public bool SetLinearLimits(Vector3 low, Vector3 high) | ||
71 | { | ||
72 | bool ret = false; | ||
73 | if (m_enabled) | ||
74 | ret = BulletSimAPI.SetLinearLimits2(m_constraint.Ptr, low, high); | ||
75 | return ret; | ||
76 | } | ||
77 | |||
78 | public bool SetAngularLimits(Vector3 low, Vector3 high) | ||
79 | { | ||
80 | bool ret = false; | ||
81 | if (m_enabled) | ||
82 | ret = BulletSimAPI.SetAngularLimits2(m_constraint.Ptr, low, high); | ||
83 | return ret; | ||
84 | } | ||
85 | |||
86 | public bool UseFrameOffset(bool useOffset) | ||
87 | { | ||
88 | bool ret = false; | ||
89 | float onOff = useOffset ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; | ||
90 | if (m_enabled) | ||
91 | ret = BulletSimAPI.UseFrameOffset2(m_constraint.Ptr, onOff); | ||
92 | return ret; | ||
93 | } | ||
94 | |||
95 | public bool TranslationalLimitMotor(bool enable, float targetVelocity, float maxMotorForce) | ||
96 | { | ||
97 | bool ret = false; | ||
98 | float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; | ||
99 | if (m_enabled) | ||
100 | ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.Ptr, onOff, targetVelocity, maxMotorForce); | ||
101 | return ret; | ||
102 | } | ||
103 | |||
104 | public bool CalculateTransforms() | ||
105 | { | ||
106 | bool ret = false; | ||
107 | if (m_enabled) | ||
108 | { | ||
109 | BulletSimAPI.CalculateTransforms2(m_constraint.Ptr); | ||
110 | ret = true; | ||
111 | } | ||
112 | return ret; | ||
113 | } | ||
114 | } | ||
115 | } | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs new file mode 100755 index 0000000..a2650fb --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs | |||
@@ -0,0 +1,178 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyrightD | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | using log4net; | ||
31 | using OpenMetaverse; | ||
32 | |||
33 | namespace OpenSim.Region.Physics.BulletSPlugin | ||
34 | { | ||
35 | |||
36 | public class BSConstraintCollection : IDisposable | ||
37 | { | ||
38 | // private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
39 | // private static readonly string LogHeader = "[CONSTRAINT COLLECTION]"; | ||
40 | |||
41 | delegate bool ConstraintAction(BSConstraint constrain); | ||
42 | |||
43 | private List<BSConstraint> m_constraints; | ||
44 | private BulletSim m_world; | ||
45 | |||
46 | public BSConstraintCollection(BulletSim world) | ||
47 | { | ||
48 | m_world = world; | ||
49 | m_constraints = new List<BSConstraint>(); | ||
50 | } | ||
51 | |||
52 | public void Dispose() | ||
53 | { | ||
54 | this.Clear(); | ||
55 | } | ||
56 | |||
57 | public void Clear() | ||
58 | { | ||
59 | foreach (BSConstraint cons in m_constraints) | ||
60 | { | ||
61 | cons.Dispose(); | ||
62 | } | ||
63 | m_constraints.Clear(); | ||
64 | } | ||
65 | |||
66 | public BSConstraint CreateConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, | ||
67 | Vector3 frame1, Quaternion frame1rot, | ||
68 | Vector3 frame2, Quaternion frame2rot) | ||
69 | { | ||
70 | BSConstraint constrain = new BSConstraint(world, obj1, obj2, frame1, frame1rot, frame2, frame2rot); | ||
71 | |||
72 | this.AddConstraint(constrain); | ||
73 | return constrain; | ||
74 | } | ||
75 | |||
76 | public bool AddConstraint(BSConstraint cons) | ||
77 | { | ||
78 | // There is only one constraint between any bodies. Remove any old just to make sure. | ||
79 | RemoveAndDestroyConstraint(cons.Body1, cons.Body2); | ||
80 | |||
81 | m_constraints.Add(cons); | ||
82 | |||
83 | return true; | ||
84 | } | ||
85 | |||
86 | // Get the constraint between two bodies. There can be only one the way we're using them. | ||
87 | public bool TryGetConstraint(BulletBody body1, BulletBody body2, out BSConstraint returnConstraint) | ||
88 | { | ||
89 | bool found = false; | ||
90 | BSConstraint foundConstraint = null; | ||
91 | |||
92 | uint lookingID1 = body1.ID; | ||
93 | uint lookingID2 = body2.ID; | ||
94 | ForEachConstraint(delegate(BSConstraint constrain) | ||
95 | { | ||
96 | if ((constrain.Body1.ID == lookingID1 && constrain.Body2.ID == lookingID2) | ||
97 | || (constrain.Body1.ID == lookingID2 && constrain.Body2.ID == lookingID1)) | ||
98 | { | ||
99 | foundConstraint = constrain; | ||
100 | found = true; | ||
101 | } | ||
102 | return found; | ||
103 | }); | ||
104 | returnConstraint = foundConstraint; | ||
105 | return found; | ||
106 | } | ||
107 | |||
108 | public bool RemoveAndDestroyConstraint(BulletBody body1, BulletBody body2) | ||
109 | { | ||
110 | // return BulletSimAPI.RemoveConstraint(m_world.ID, obj1.ID, obj2.ID); | ||
111 | |||
112 | bool ret = false; | ||
113 | BSConstraint constrain; | ||
114 | |||
115 | if (this.TryGetConstraint(body1, body2, out constrain)) | ||
116 | { | ||
117 | // remove the constraint from our collection | ||
118 | m_constraints.Remove(constrain); | ||
119 | // tell the engine that all its structures need to be freed | ||
120 | constrain.Dispose(); | ||
121 | // we destroyed something | ||
122 | ret = true; | ||
123 | } | ||
124 | |||
125 | return ret; | ||
126 | } | ||
127 | |||
128 | public bool RemoveAndDestroyConstraint(BulletBody body1) | ||
129 | { | ||
130 | // return BulletSimAPI.RemoveConstraintByID(m_world.ID, obj.ID); | ||
131 | |||
132 | List<BSConstraint> toRemove = new List<BSConstraint>(); | ||
133 | uint lookingID = body1.ID; | ||
134 | ForEachConstraint(delegate(BSConstraint constrain) | ||
135 | { | ||
136 | if (constrain.Body1.ID == lookingID || constrain.Body2.ID == lookingID) | ||
137 | { | ||
138 | toRemove.Add(constrain); | ||
139 | } | ||
140 | return false; | ||
141 | }); | ||
142 | lock (m_constraints) | ||
143 | { | ||
144 | foreach (BSConstraint constrain in toRemove) | ||
145 | { | ||
146 | m_constraints.Remove(constrain); | ||
147 | constrain.Dispose(); | ||
148 | } | ||
149 | } | ||
150 | return (toRemove.Count > 0); | ||
151 | } | ||
152 | |||
153 | public bool RecalculateAllConstraints() | ||
154 | { | ||
155 | foreach (BSConstraint constrain in m_constraints) | ||
156 | { | ||
157 | constrain.CalculateTransforms(); | ||
158 | } | ||
159 | return true; | ||
160 | } | ||
161 | |||
162 | // Lock the constraint list and loop through it. | ||
163 | // The constraint action returns 'true' if it wants the loop aborted. | ||
164 | private void ForEachConstraint(ConstraintAction action) | ||
165 | { | ||
166 | lock (m_constraints) | ||
167 | { | ||
168 | foreach (BSConstraint constrain in m_constraints) | ||
169 | { | ||
170 | if (action(constrain)) | ||
171 | break; | ||
172 | } | ||
173 | } | ||
174 | } | ||
175 | |||
176 | |||
177 | } | ||
178 | } | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs new file mode 100755 index 0000000..3bc2100 --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | |||
@@ -0,0 +1,308 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyrightD | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | using System; | ||
28 | using System.Collections.Generic; | ||
29 | using System.Text; | ||
30 | |||
31 | using OMV = OpenMetaverse; | ||
32 | |||
33 | namespace OpenSim.Region.Physics.BulletSPlugin | ||
34 | { | ||
35 | public class BSLinkset | ||
36 | { | ||
37 | private static string LogHeader = "[BULLETSIM LINKSET]"; | ||
38 | |||
39 | private BSPrim m_linksetRoot; | ||
40 | public BSPrim Root { get { return m_linksetRoot; } } | ||
41 | |||
42 | private BSScene m_scene; | ||
43 | |||
44 | private List<BSPrim> m_children; | ||
45 | |||
46 | // We lock the diddling of linkset classes to prevent any badness. | ||
47 | // This locks the modification of the instances of this class. Changes | ||
48 | // to the physical representation is done via the tainting mechenism. | ||
49 | private object m_linksetActivityLock = new Object(); | ||
50 | |||
51 | // We keep the prim's mass in the linkset structure since it could be dependent on other prims | ||
52 | private float m_mass; | ||
53 | public float LinksetMass | ||
54 | { | ||
55 | get | ||
56 | { | ||
57 | m_mass = ComputeLinksetMass(); | ||
58 | return m_mass; | ||
59 | } | ||
60 | } | ||
61 | |||
62 | public OMV.Vector3 CenterOfMass | ||
63 | { | ||
64 | get { return ComputeLinksetCenterOfMass(); } | ||
65 | } | ||
66 | |||
67 | public OMV.Vector3 GeometricCenter | ||
68 | { | ||
69 | get { return ComputeLinksetGeometricCenter(); } | ||
70 | } | ||
71 | |||
72 | public BSLinkset(BSScene scene, BSPrim parent) | ||
73 | { | ||
74 | // A simple linkset of one (no children) | ||
75 | m_scene = scene; | ||
76 | m_linksetRoot = parent; | ||
77 | m_children = new List<BSPrim>(); | ||
78 | m_mass = parent.MassRaw; | ||
79 | } | ||
80 | |||
81 | // Link to a linkset where the child knows the parent. | ||
82 | // Parent changing should not happen so do some sanity checking. | ||
83 | // We return the parent's linkset so the child can track it's membership. | ||
84 | public BSLinkset AddMeToLinkset(BSPrim child, BSPrim parent) | ||
85 | { | ||
86 | lock (m_linksetActivityLock) | ||
87 | { | ||
88 | parent.Linkset.AddChildToLinkset(child); | ||
89 | } | ||
90 | return parent.Linkset; | ||
91 | } | ||
92 | |||
93 | public BSLinkset RemoveMeFromLinkset(BSPrim child) | ||
94 | { | ||
95 | lock (m_linksetActivityLock) | ||
96 | { | ||
97 | if (IsRoot(child)) | ||
98 | { | ||
99 | // if root of linkset, take the linkset apart | ||
100 | while (m_children.Count > 0) | ||
101 | { | ||
102 | // Note that we don't do a foreach because the remove routine | ||
103 | // takes it out of the list. | ||
104 | RemoveChildFromLinkset(m_children[0]); | ||
105 | } | ||
106 | m_children.Clear(); // just to make sure | ||
107 | } | ||
108 | else | ||
109 | { | ||
110 | // Just removing a child from an existing linkset | ||
111 | RemoveChildFromLinkset(child); | ||
112 | } | ||
113 | } | ||
114 | |||
115 | // The child is down to a linkset of just itself | ||
116 | return new BSLinkset(m_scene, child); | ||
117 | } | ||
118 | |||
119 | // An existing linkset had one of its members rebuilt or something. | ||
120 | // Undo all the physical linking and rebuild the physical linkset. | ||
121 | public bool RefreshLinkset(BSPrim requestor) | ||
122 | { | ||
123 | return true; | ||
124 | } | ||
125 | |||
126 | |||
127 | // Return 'true' if the passed object is the root object of this linkset | ||
128 | public bool IsRoot(BSPrim requestor) | ||
129 | { | ||
130 | return (requestor.LocalID == m_linksetRoot.LocalID); | ||
131 | } | ||
132 | |||
133 | // Return 'true' if this linkset has any children (more than the root member) | ||
134 | public bool HasAnyChildren { get { return (m_children.Count > 0); } } | ||
135 | |||
136 | // Return 'true' if this child is in this linkset | ||
137 | public bool HasChild(BSPrim child) | ||
138 | { | ||
139 | bool ret = false; | ||
140 | foreach (BSPrim bp in m_children) | ||
141 | { | ||
142 | if (child.LocalID == bp.LocalID) | ||
143 | { | ||
144 | ret = true; | ||
145 | break; | ||
146 | } | ||
147 | } | ||
148 | return ret; | ||
149 | } | ||
150 | |||
151 | private float ComputeLinksetMass() | ||
152 | { | ||
153 | float mass = m_linksetRoot.MassRaw; | ||
154 | foreach (BSPrim bp in m_children) | ||
155 | { | ||
156 | mass += bp.MassRaw; | ||
157 | } | ||
158 | return mass; | ||
159 | } | ||
160 | |||
161 | private OMV.Vector3 ComputeLinksetCenterOfMass() | ||
162 | { | ||
163 | OMV.Vector3 com = m_linksetRoot.Position * m_linksetRoot.MassRaw; | ||
164 | float totalMass = m_linksetRoot.MassRaw; | ||
165 | |||
166 | foreach (BSPrim bp in m_children) | ||
167 | { | ||
168 | com += bp.Position * bp.MassRaw; | ||
169 | totalMass += bp.MassRaw; | ||
170 | } | ||
171 | com /= totalMass; | ||
172 | |||
173 | return com; | ||
174 | } | ||
175 | |||
176 | private OMV.Vector3 ComputeLinksetGeometricCenter() | ||
177 | { | ||
178 | OMV.Vector3 com = m_linksetRoot.Position; | ||
179 | |||
180 | foreach (BSPrim bp in m_children) | ||
181 | { | ||
182 | com += bp.Position * bp.MassRaw; | ||
183 | } | ||
184 | com /= m_children.Count + 1; | ||
185 | |||
186 | return com; | ||
187 | } | ||
188 | |||
189 | // I am the root of a linkset and a new child is being added | ||
190 | public void AddChildToLinkset(BSPrim pchild) | ||
191 | { | ||
192 | BSPrim child = pchild; | ||
193 | if (!HasChild(child)) | ||
194 | { | ||
195 | m_children.Add(child); | ||
196 | |||
197 | m_scene.TaintedObject(delegate() | ||
198 | { | ||
199 | DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, m_linksetRoot.LocalID); | ||
200 | DetailLog("{0},AddChildToLinkset,child={1}", m_linksetRoot.LocalID, pchild.LocalID); | ||
201 | PhysicallyLinkAChildToRoot(pchild); // build the physical binding between me and the child | ||
202 | }); | ||
203 | } | ||
204 | return; | ||
205 | } | ||
206 | |||
207 | // I am the root of a linkset and one of my children is being removed. | ||
208 | // Safe to call even if the child is not really in my linkset. | ||
209 | public void RemoveChildFromLinkset(BSPrim pchild) | ||
210 | { | ||
211 | BSPrim child = pchild; | ||
212 | |||
213 | if (m_children.Remove(child)) | ||
214 | { | ||
215 | m_scene.TaintedObject(delegate() | ||
216 | { | ||
217 | DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); | ||
218 | DetailLog("{0},RemoveChildFromLinkset,child={1}", m_linksetRoot.LocalID, pchild.LocalID); | ||
219 | |||
220 | if (m_children.Count == 0) | ||
221 | { | ||
222 | // if the linkset is empty, make sure all linkages have been removed | ||
223 | PhysicallyUnlinkAllChildrenFromRoot(); | ||
224 | } | ||
225 | else | ||
226 | { | ||
227 | PhysicallyUnlinkAChildFromRoot(pchild); | ||
228 | } | ||
229 | }); | ||
230 | } | ||
231 | else | ||
232 | { | ||
233 | // This will happen if we remove the root of the linkset first. Non-fatal occurance. | ||
234 | // m_scene.Logger.ErrorFormat("{0}: Asked to remove child from linkset that was not in linkset", LogHeader); | ||
235 | } | ||
236 | return; | ||
237 | } | ||
238 | |||
239 | // Create a constraint between me (root of linkset) and the passed prim (the child). | ||
240 | // Called at taint time! | ||
241 | private void PhysicallyLinkAChildToRoot(BSPrim childPrim) | ||
242 | { | ||
243 | // Zero motion for children so they don't interpolate | ||
244 | childPrim.ZeroMotion(); | ||
245 | |||
246 | // relative position normalized to the root prim | ||
247 | OMV.Quaternion invThisOrientation = OMV.Quaternion.Inverse(m_linksetRoot.Orientation); | ||
248 | OMV.Vector3 childRelativePosition = (childPrim.Position - m_linksetRoot.Position) * invThisOrientation; | ||
249 | |||
250 | // relative rotation of the child to the parent | ||
251 | OMV.Quaternion childRelativeRotation = invThisOrientation * childPrim.Orientation; | ||
252 | |||
253 | // create a constraint that allows no freedom of movement between the two objects | ||
254 | // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 | ||
255 | // DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID); | ||
256 | DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID); | ||
257 | BSConstraint constrain = m_scene.Constraints.CreateConstraint( | ||
258 | m_scene.World, m_linksetRoot.Body, childPrim.Body, | ||
259 | childRelativePosition, | ||
260 | childRelativeRotation, | ||
261 | OMV.Vector3.Zero, | ||
262 | OMV.Quaternion.Identity); | ||
263 | constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); | ||
264 | constrain.SetAngularLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); | ||
265 | |||
266 | // tweek the constraint to increase stability | ||
267 | constrain.UseFrameOffset(m_scene.BoolNumeric(m_scene.Params.linkConstraintUseFrameOffset)); | ||
268 | constrain.TranslationalLimitMotor(m_scene.BoolNumeric(m_scene.Params.linkConstraintEnableTransMotor), | ||
269 | m_scene.Params.linkConstraintTransMotorMaxVel, | ||
270 | m_scene.Params.linkConstraintTransMotorMaxForce); | ||
271 | |||
272 | } | ||
273 | |||
274 | // Remove linkage between myself and a particular child | ||
275 | // Called at taint time! | ||
276 | private void PhysicallyUnlinkAChildFromRoot(BSPrim childPrim) | ||
277 | { | ||
278 | DebugLog("{0}: PhysicallyUnlinkAChildFromRoot: RemoveConstraint between root prim {1} and child prim {2}", | ||
279 | LogHeader, m_linksetRoot.LocalID, childPrim.LocalID); | ||
280 | DetailLog("{0},PhysicallyUnlinkAChildFromRoot,taint,root={1},child={2}", m_linksetRoot.LocalID, m_linksetRoot.LocalID, childPrim.LocalID); | ||
281 | // BulletSimAPI.RemoveConstraint(_scene.WorldID, LocalID, childPrim.LocalID); | ||
282 | m_scene.Constraints.RemoveAndDestroyConstraint(m_linksetRoot.Body, childPrim.Body); | ||
283 | } | ||
284 | |||
285 | // Remove linkage between myself and any possible children I might have | ||
286 | // Called at taint time! | ||
287 | private void PhysicallyUnlinkAllChildrenFromRoot() | ||
288 | { | ||
289 | // DebugLog("{0}: PhysicallyUnlinkAllChildren:", LogHeader); | ||
290 | DetailLog("{0},PhysicallyUnlinkAllChildren,taint", m_linksetRoot.LocalID); | ||
291 | m_scene.Constraints.RemoveAndDestroyConstraint(m_linksetRoot.Body); | ||
292 | // BulletSimAPI.RemoveConstraintByID(_scene.WorldID, LocalID); | ||
293 | } | ||
294 | |||
295 | // Invoke the detailed logger and output something if it's enabled. | ||
296 | private void DebugLog(string msg, params Object[] args) | ||
297 | { | ||
298 | m_scene.Logger.DebugFormat(msg, args); | ||
299 | } | ||
300 | |||
301 | // Invoke the detailed logger and output something if it's enabled. | ||
302 | private void DetailLog(string msg, params Object[] args) | ||
303 | { | ||
304 | m_scene.PhysicsLogging.Write(msg, args); | ||
305 | } | ||
306 | |||
307 | } | ||
308 | } | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index a19d6d7..7590d93 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -66,7 +66,7 @@ public sealed class BSPrim : PhysicsActor | |||
66 | private bool _isSelected; | 66 | private bool _isSelected; |
67 | private bool _isVolumeDetect; | 67 | private bool _isVolumeDetect; |
68 | private OMV.Vector3 _position; | 68 | private OMV.Vector3 _position; |
69 | private float _mass; | 69 | private float _mass; // the mass of this object |
70 | private float _density; | 70 | private float _density; |
71 | private OMV.Vector3 _force; | 71 | private OMV.Vector3 _force; |
72 | private OMV.Vector3 _velocity; | 72 | private OMV.Vector3 _velocity; |
@@ -89,14 +89,22 @@ public sealed class BSPrim : PhysicsActor | |||
89 | private bool _kinematic; | 89 | private bool _kinematic; |
90 | private float _buoyancy; | 90 | private float _buoyancy; |
91 | 91 | ||
92 | private BSPrim _parentPrim; | 92 | // Membership in a linkset is controlled by this class. |
93 | private List<BSPrim> _childrenPrims; | 93 | private BSLinkset _linkset; |
94 | public BSLinkset Linkset | ||
95 | { | ||
96 | get { return _linkset; } | ||
97 | set { _linkset = value; } | ||
98 | } | ||
94 | 99 | ||
95 | private int _subscribedEventsMs = 0; | 100 | private int _subscribedEventsMs = 0; |
96 | private int _nextCollisionOkTime = 0; | 101 | private int _nextCollisionOkTime = 0; |
97 | long _collidingStep; | 102 | long _collidingStep; |
98 | long _collidingGroundStep; | 103 | long _collidingGroundStep; |
99 | 104 | ||
105 | private BulletBody m_body; | ||
106 | public BulletBody Body { get { return m_body; } } | ||
107 | |||
100 | private BSDynamics _vehicle; | 108 | private BSDynamics _vehicle; |
101 | 109 | ||
102 | private OMV.Vector3 _PIDTarget; | 110 | private OMV.Vector3 _PIDTarget; |
@@ -130,14 +138,18 @@ public sealed class BSPrim : PhysicsActor | |||
130 | _friction = _scene.Params.defaultFriction; // TODO: compute based on object material | 138 | _friction = _scene.Params.defaultFriction; // TODO: compute based on object material |
131 | _density = _scene.Params.defaultDensity; // TODO: compute based on object material | 139 | _density = _scene.Params.defaultDensity; // TODO: compute based on object material |
132 | _restitution = _scene.Params.defaultRestitution; | 140 | _restitution = _scene.Params.defaultRestitution; |
133 | _parentPrim = null; // not a child or a parent | 141 | _linkset = new BSLinkset(_scene, this); // a linkset of one |
134 | _vehicle = new BSDynamics(this); // add vehicleness | 142 | _vehicle = new BSDynamics(this); // add vehicleness |
135 | _childrenPrims = new List<BSPrim>(); | ||
136 | _mass = CalculateMass(); | 143 | _mass = CalculateMass(); |
137 | // do the actual object creation at taint time | 144 | // do the actual object creation at taint time |
138 | _scene.TaintedObject(delegate() | 145 | _scene.TaintedObject(delegate() |
139 | { | 146 | { |
140 | RecreateGeomAndObject(); | 147 | RecreateGeomAndObject(); |
148 | |||
149 | // Get the pointer to the physical body for this object. | ||
150 | // At the moment, we're still letting BulletSim manage the creation and destruction | ||
151 | // of the object. Someday we'll move that into the C# code. | ||
152 | m_body = new BulletBody(LocalID, BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID)); | ||
141 | }); | 153 | }); |
142 | } | 154 | } |
143 | 155 | ||
@@ -153,16 +165,8 @@ public sealed class BSPrim : PhysicsActor | |||
153 | 165 | ||
154 | _scene.TaintedObject(delegate() | 166 | _scene.TaintedObject(delegate() |
155 | { | 167 | { |
156 | // undo any dependance with/on other objects | 168 | // Undo any links between me and any other object |
157 | if (_parentPrim != null) | 169 | _linkset = _linkset.RemoveMeFromLinkset(this); |
158 | { | ||
159 | // If I'm someone's child, tell them to forget about me. | ||
160 | _parentPrim.RemoveChildFromLinkset(this); | ||
161 | _parentPrim = null; | ||
162 | } | ||
163 | |||
164 | // make sure there are no possible children depending on me | ||
165 | UnlinkAllChildren(); | ||
166 | 170 | ||
167 | // everything in the C# world will get garbage collected. Tell the C++ world to free stuff. | 171 | // everything in the C# world will get garbage collected. Tell the C++ world to free stuff. |
168 | BulletSimAPI.DestroyObject(_scene.WorldID, LocalID); | 172 | BulletSimAPI.DestroyObject(_scene.WorldID, LocalID); |
@@ -179,7 +183,7 @@ public sealed class BSPrim : PhysicsActor | |||
179 | _scene.TaintedObject(delegate() | 183 | _scene.TaintedObject(delegate() |
180 | { | 184 | { |
181 | _mass = CalculateMass(); // changing size changes the mass | 185 | _mass = CalculateMass(); // changing size changes the mass |
182 | BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, Mass, IsPhysical); | 186 | BulletSimAPI.SetObjectScaleMass(_scene.WorldID, _localID, _scale, (IsPhysical ? _mass : 0f), IsPhysical); |
183 | RecreateGeomAndObject(); | 187 | RecreateGeomAndObject(); |
184 | }); | 188 | }); |
185 | } | 189 | } |
@@ -218,32 +222,8 @@ public sealed class BSPrim : PhysicsActor | |||
218 | BSPrim parent = obj as BSPrim; | 222 | BSPrim parent = obj as BSPrim; |
219 | DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, obj.LocalID); | 223 | DebugLog("{0}: link {1}/{2} to {3}", LogHeader, _avName, _localID, obj.LocalID); |
220 | DetailLog("{0},link,parent={1}", LocalID, obj.LocalID); | 224 | DetailLog("{0},link,parent={1}", LocalID, obj.LocalID); |
221 | // TODO: decide if this parent checking needs to happen at taint time | 225 | |
222 | if (_parentPrim == null) | 226 | _linkset = _linkset.AddMeToLinkset(this, parent); |
223 | { | ||
224 | if (parent != null) | ||
225 | { | ||
226 | // I don't have a parent so I am joining a linkset | ||
227 | parent.AddChildToLinkset(this); | ||
228 | } | ||
229 | } | ||
230 | else | ||
231 | { | ||
232 | // I already have a parent, is parenting changing? | ||
233 | if (parent != _parentPrim) | ||
234 | { | ||
235 | if (parent == null) | ||
236 | { | ||
237 | // we are being removed from a linkset | ||
238 | _parentPrim.RemoveChildFromLinkset(this); | ||
239 | } | ||
240 | else | ||
241 | { | ||
242 | // asking to reparent a prim should not happen | ||
243 | m_log.ErrorFormat("{0}: link(): Reparenting a prim. ", LogHeader); | ||
244 | } | ||
245 | } | ||
246 | } | ||
247 | return; | 227 | return; |
248 | } | 228 | } |
249 | 229 | ||
@@ -252,92 +232,28 @@ public sealed class BSPrim : PhysicsActor | |||
252 | // TODO: decide if this parent checking needs to happen at taint time | 232 | // TODO: decide if this parent checking needs to happen at taint time |
253 | // Race condition here: if link() and delink() in same simulation tick, the delink will not happen | 233 | // Race condition here: if link() and delink() in same simulation tick, the delink will not happen |
254 | DebugLog("{0}: delink {1}/{2}. Parent={3}", LogHeader, _avName, _localID, | 234 | DebugLog("{0}: delink {1}/{2}. Parent={3}", LogHeader, _avName, _localID, |
255 | (_parentPrim==null ? "NULL" : _parentPrim._avName+"/"+_parentPrim.LocalID.ToString())); | 235 | _linkset.Root._avName+"/"+_linkset.Root.LocalID.ToString()); |
256 | DetailLog("{0},delink,parent={1}", LocalID, (_parentPrim==null ? "NULL" : _parentPrim.LocalID.ToString())); | 236 | DetailLog("{0},delink,parent={1}", LocalID, _linkset.Root.LocalID.ToString()); |
257 | if (_parentPrim != null) | ||
258 | { | ||
259 | _parentPrim.RemoveChildFromLinkset(this); | ||
260 | } | ||
261 | return; | ||
262 | } | ||
263 | |||
264 | // I am the root of a linkset and a new child is being added | ||
265 | public void AddChildToLinkset(BSPrim pchild) | ||
266 | { | ||
267 | BSPrim child = pchild; | ||
268 | _scene.TaintedObject(delegate() | ||
269 | { | ||
270 | if (!_childrenPrims.Contains(child)) | ||
271 | { | ||
272 | DebugLog("{0}: AddChildToLinkset: adding child {1} to {2}", LogHeader, child.LocalID, this.LocalID); | ||
273 | DetailLog("{0},AddChildToLinkset,child={1}", LocalID, pchild.LocalID); | ||
274 | _childrenPrims.Add(child); | ||
275 | child._parentPrim = this; // the child has gained a parent | ||
276 | // RecreateGeomAndObject(); // rebuild my shape with the new child added | ||
277 | LinkAChildToMe(pchild); // build the physical binding between me and the child | ||
278 | |||
279 | _mass = CalculateMass(); | ||
280 | } | ||
281 | }); | ||
282 | return; | ||
283 | } | ||
284 | |||
285 | // I am the root of a linkset and one of my children is being removed. | ||
286 | // Safe to call even if the child is not really in my linkset. | ||
287 | public void RemoveChildFromLinkset(BSPrim pchild) | ||
288 | { | ||
289 | BSPrim child = pchild; | ||
290 | _scene.TaintedObject(delegate() | ||
291 | { | ||
292 | if (_childrenPrims.Contains(child)) | ||
293 | { | ||
294 | DebugLog("{0}: RemoveChildFromLinkset: Removing constraint to {1}", LogHeader, child.LocalID); | ||
295 | DetailLog("{0},RemoveChildFromLinkset,child={1}", LocalID, pchild.LocalID); | ||
296 | _childrenPrims.Remove(child); | ||
297 | child._parentPrim = null; // the child has lost its parent | ||
298 | if (_childrenPrims.Count == 0) | ||
299 | { | ||
300 | // if the linkset is empty, make sure all linkages have been removed | ||
301 | UnlinkAllChildren(); | ||
302 | } | ||
303 | else | ||
304 | { | ||
305 | // RecreateGeomAndObject(); // rebuild my shape with the child removed | ||
306 | UnlinkAChildFromMe(pchild); | ||
307 | } | ||
308 | |||
309 | _mass = CalculateMass(); | ||
310 | } | ||
311 | else | ||
312 | { | ||
313 | m_log.ErrorFormat("{0}: Asked to remove child from linkset that was not in linkset"); | ||
314 | } | ||
315 | }); | ||
316 | return; | ||
317 | } | ||
318 | 237 | ||
319 | // return true if we are the root of a linkset (there are children to manage) | 238 | _linkset.RemoveMeFromLinkset(this); |
320 | public bool IsRootOfLinkset | 239 | return; |
321 | { | ||
322 | get { return (_parentPrim == null && _childrenPrims.Count != 0); } | ||
323 | } | 240 | } |
324 | 241 | ||
325 | // Set motion values to zero. | 242 | // Set motion values to zero. |
326 | // Do it to the properties so the values get set in the physics engine. | 243 | // Do it to the properties so the values get set in the physics engine. |
327 | // Push the setting of the values to the viewer. | 244 | // Push the setting of the values to the viewer. |
328 | // Called at taint time! | 245 | // Called at taint time! |
329 | private void ZeroMotion() | 246 | public void ZeroMotion() |
330 | { | 247 | { |
331 | _velocity = OMV.Vector3.Zero; | 248 | _velocity = OMV.Vector3.Zero; |
332 | _acceleration = OMV.Vector3.Zero; | 249 | _acceleration = OMV.Vector3.Zero; |
333 | _rotationalVelocity = OMV.Vector3.Zero; | 250 | _rotationalVelocity = OMV.Vector3.Zero; |
334 | 251 | ||
335 | // Zero some other properties directly into the physics engine | 252 | // Zero some other properties directly into the physics engine |
336 | IntPtr obj = BulletSimAPI.GetBodyHandleWorldID2(_scene.WorldID, LocalID); | 253 | BulletSimAPI.SetVelocity2(Body.Ptr, OMV.Vector3.Zero); |
337 | BulletSimAPI.SetVelocity2(obj, OMV.Vector3.Zero); | 254 | BulletSimAPI.SetAngularVelocity2(Body.Ptr, OMV.Vector3.Zero); |
338 | BulletSimAPI.SetAngularVelocity2(obj, OMV.Vector3.Zero); | 255 | BulletSimAPI.SetInterpolation2(Body.Ptr, OMV.Vector3.Zero, OMV.Vector3.Zero); |
339 | BulletSimAPI.SetInterpolation2(obj, OMV.Vector3.Zero, OMV.Vector3.Zero); | 256 | BulletSimAPI.ClearForces2(Body.Ptr); |
340 | BulletSimAPI.ClearForces2(obj); | ||
341 | } | 257 | } |
342 | 258 | ||
343 | public override void LockAngularMotion(OMV.Vector3 axis) | 259 | public override void LockAngularMotion(OMV.Vector3 axis) |
@@ -348,9 +264,10 @@ public sealed class BSPrim : PhysicsActor | |||
348 | 264 | ||
349 | public override OMV.Vector3 Position { | 265 | public override OMV.Vector3 Position { |
350 | get { | 266 | get { |
351 | // child prims move around based on their parent. Need to get the latest location | 267 | if (!_linkset.IsRoot(this)) |
352 | if (_parentPrim != null) | 268 | // child prims move around based on their parent. Need to get the latest location |
353 | _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); | 269 | _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); |
270 | |||
354 | // don't do the GetObjectPosition for root elements because this function is called a zillion times | 271 | // don't do the GetObjectPosition for root elements because this function is called a zillion times |
355 | // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); | 272 | // _position = BulletSimAPI.GetObjectPosition(_scene.WorldID, _localID); |
356 | return _position; | 273 | return _position; |
@@ -366,16 +283,31 @@ public sealed class BSPrim : PhysicsActor | |||
366 | } | 283 | } |
367 | } | 284 | } |
368 | 285 | ||
369 | // Return the effective mass of the object. Non-physical objects do not have mass. | 286 | // Return the effective mass of the object. |
370 | public override float Mass { | 287 | // If there are multiple items in the linkset, add them together for the root |
371 | get { | 288 | public override float Mass |
372 | if (IsPhysical) | 289 | { |
373 | return _mass; | 290 | get |
374 | else | 291 | { |
375 | return 0f; | 292 | return _linkset.LinksetMass; |
376 | } | 293 | } |
377 | } | 294 | } |
378 | 295 | ||
296 | // used when we only want this prim's mass and not the linkset thing | ||
297 | public float MassRaw { get { return _mass; } } | ||
298 | |||
299 | // Is this used? | ||
300 | public override OMV.Vector3 CenterOfMass | ||
301 | { | ||
302 | get { return _linkset.CenterOfMass; } | ||
303 | } | ||
304 | |||
305 | // Is this used? | ||
306 | public override OMV.Vector3 GeometricCenter | ||
307 | { | ||
308 | get { return _linkset.GeometricCenter; } | ||
309 | } | ||
310 | |||
379 | public override OMV.Vector3 Force { | 311 | public override OMV.Vector3 Force { |
380 | get { return _force; } | 312 | get { return _force; } |
381 | set { | 313 | set { |
@@ -383,7 +315,8 @@ public sealed class BSPrim : PhysicsActor | |||
383 | _scene.TaintedObject(delegate() | 315 | _scene.TaintedObject(delegate() |
384 | { | 316 | { |
385 | DetailLog("{0},SetForce,taint,force={1}", LocalID, _force); | 317 | DetailLog("{0},SetForce,taint,force={1}", LocalID, _force); |
386 | BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); | 318 | // BulletSimAPI.SetObjectForce(_scene.WorldID, _localID, _force); |
319 | BulletSimAPI.SetObjectForce2(Body.Ptr, _force); | ||
387 | }); | 320 | }); |
388 | } | 321 | } |
389 | } | 322 | } |
@@ -407,8 +340,7 @@ public sealed class BSPrim : PhysicsActor | |||
407 | _scene.TaintedObject(delegate() | 340 | _scene.TaintedObject(delegate() |
408 | { | 341 | { |
409 | // Tell the physics engine to clear state | 342 | // Tell the physics engine to clear state |
410 | IntPtr obj = BulletSimAPI.GetBodyHandleWorldID2(_scene.WorldID, LocalID); | 343 | BulletSimAPI.ClearForces2(this.Body.Ptr); |
411 | BulletSimAPI.ClearForces2(obj); | ||
412 | }); | 344 | }); |
413 | 345 | ||
414 | // make it so the scene will call us each tick to do vehicle things | 346 | // make it so the scene will call us each tick to do vehicle things |
@@ -420,7 +352,6 @@ public sealed class BSPrim : PhysicsActor | |||
420 | } | 352 | } |
421 | public override void VehicleFloatParam(int param, float value) | 353 | public override void VehicleFloatParam(int param, float value) |
422 | { | 354 | { |
423 | m_log.DebugFormat("{0} VehicleFloatParam. {1} <= {2}", LogHeader, param, value); | ||
424 | _scene.TaintedObject(delegate() | 355 | _scene.TaintedObject(delegate() |
425 | { | 356 | { |
426 | _vehicle.ProcessFloatVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep); | 357 | _vehicle.ProcessFloatVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep); |
@@ -428,7 +359,6 @@ public sealed class BSPrim : PhysicsActor | |||
428 | } | 359 | } |
429 | public override void VehicleVectorParam(int param, OMV.Vector3 value) | 360 | public override void VehicleVectorParam(int param, OMV.Vector3 value) |
430 | { | 361 | { |
431 | m_log.DebugFormat("{0} VehicleVectorParam. {1} <= {2}", LogHeader, param, value); | ||
432 | _scene.TaintedObject(delegate() | 362 | _scene.TaintedObject(delegate() |
433 | { | 363 | { |
434 | _vehicle.ProcessVectorVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep); | 364 | _vehicle.ProcessVectorVehicleParam((Vehicle)param, value, _scene.LastSimulatedTimestep); |
@@ -436,7 +366,6 @@ public sealed class BSPrim : PhysicsActor | |||
436 | } | 366 | } |
437 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) | 367 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) |
438 | { | 368 | { |
439 | m_log.DebugFormat("{0} VehicleRotationParam. {1} <= {2}", LogHeader, param, rotation); | ||
440 | _scene.TaintedObject(delegate() | 369 | _scene.TaintedObject(delegate() |
441 | { | 370 | { |
442 | _vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); | 371 | _vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); |
@@ -444,7 +373,6 @@ public sealed class BSPrim : PhysicsActor | |||
444 | } | 373 | } |
445 | public override void VehicleFlags(int param, bool remove) | 374 | public override void VehicleFlags(int param, bool remove) |
446 | { | 375 | { |
447 | m_log.DebugFormat("{0} VehicleFlags. {1}. Remove={2}", LogHeader, param, remove); | ||
448 | _scene.TaintedObject(delegate() | 376 | _scene.TaintedObject(delegate() |
449 | { | 377 | { |
450 | _vehicle.ProcessVehicleFlags(param, remove); | 378 | _vehicle.ProcessVehicleFlags(param, remove); |
@@ -470,8 +398,6 @@ public sealed class BSPrim : PhysicsActor | |||
470 | return; | 398 | return; |
471 | } | 399 | } |
472 | 400 | ||
473 | public override OMV.Vector3 GeometricCenter { get { return OMV.Vector3.Zero; } } | ||
474 | public override OMV.Vector3 CenterOfMass { get { return OMV.Vector3.Zero; } } | ||
475 | public override OMV.Vector3 Velocity { | 401 | public override OMV.Vector3 Velocity { |
476 | get { return _velocity; } | 402 | get { return _velocity; } |
477 | set { | 403 | set { |
@@ -500,9 +426,9 @@ public sealed class BSPrim : PhysicsActor | |||
500 | } | 426 | } |
501 | public override OMV.Quaternion Orientation { | 427 | public override OMV.Quaternion Orientation { |
502 | get { | 428 | get { |
503 | if (_parentPrim != null) | 429 | if (!_linkset.IsRoot(this)) |
504 | { | 430 | { |
505 | // children move around because tied to parent. Get a fresh value. | 431 | // Children move around because tied to parent. Get a fresh value. |
506 | _orientation = BulletSimAPI.GetObjectOrientation(_scene.WorldID, LocalID); | 432 | _orientation = BulletSimAPI.GetObjectOrientation(_scene.WorldID, LocalID); |
507 | } | 433 | } |
508 | return _orientation; | 434 | return _orientation; |
@@ -552,14 +478,16 @@ public sealed class BSPrim : PhysicsActor | |||
552 | private void SetObjectDynamic() | 478 | private void SetObjectDynamic() |
553 | { | 479 | { |
554 | // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}", LogHeader, _localID, IsStatic, IsSolid); | 480 | // m_log.DebugFormat("{0}: ID={1}, SetObjectDynamic: IsStatic={2}, IsSolid={3}", LogHeader, _localID, IsStatic, IsSolid); |
555 | // non-physical things work best with a mass of zero | 481 | |
556 | if (!IsStatic) | 482 | RecreateGeomAndObject(); |
557 | { | 483 | |
558 | _mass = CalculateMass(); | 484 | float mass = _mass; |
559 | RecreateGeomAndObject(); | 485 | // Bullet wants static objects have a mass of zero |
560 | } | 486 | if (IsStatic) |
561 | DetailLog("{0},SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, Mass); | 487 | mass = 0f; |
562 | BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), Mass); | 488 | |
489 | DetailLog("{0},SetObjectDynamic,taint,static={1},solid={2},mass={3}", LocalID, IsStatic, IsSolid, mass); | ||
490 | BulletSimAPI.SetObjectProperties(_scene.WorldID, LocalID, IsStatic, IsSolid, SubscribedEvents(), mass); | ||
563 | } | 491 | } |
564 | 492 | ||
565 | // prims don't fly | 493 | // prims don't fly |
@@ -1001,6 +929,9 @@ public sealed class BSPrim : PhysicsActor | |||
1001 | 929 | ||
1002 | returnMass = _density * volume; | 930 | returnMass = _density * volume; |
1003 | 931 | ||
932 | /* | ||
933 | * This change means each object keeps its own mass and the Mass property | ||
934 | * will return the sum if we're part of a linkset. | ||
1004 | if (IsRootOfLinkset) | 935 | if (IsRootOfLinkset) |
1005 | { | 936 | { |
1006 | foreach (BSPrim prim in _childrenPrims) | 937 | foreach (BSPrim prim in _childrenPrims) |
@@ -1008,6 +939,7 @@ public sealed class BSPrim : PhysicsActor | |||
1008 | returnMass += prim.CalculateMass(); | 939 | returnMass += prim.CalculateMass(); |
1009 | } | 940 | } |
1010 | } | 941 | } |
942 | */ | ||
1011 | 943 | ||
1012 | if (returnMass <= 0) | 944 | if (returnMass <= 0) |
1013 | returnMass = 0.0001f; | 945 | returnMass = 0.0001f; |
@@ -1023,9 +955,11 @@ public sealed class BSPrim : PhysicsActor | |||
1023 | // The objects needs a hull if it's physical otherwise a mesh is enough | 955 | // The objects needs a hull if it's physical otherwise a mesh is enough |
1024 | // No locking here because this is done when we know physics is not simulating | 956 | // No locking here because this is done when we know physics is not simulating |
1025 | // if 'forceRebuild' is true, the geometry is rebuilt. Otherwise a previously built version is used | 957 | // if 'forceRebuild' is true, the geometry is rebuilt. Otherwise a previously built version is used |
1026 | private void CreateGeom(bool forceRebuild) | 958 | // Returns 'true' if the geometry was rebuilt |
959 | private bool CreateGeom(bool forceRebuild) | ||
1027 | { | 960 | { |
1028 | // the mesher thought this was too simple to mesh. Use a native Bullet collision shape. | 961 | // the mesher thought this was too simple to mesh. Use a native Bullet collision shape. |
962 | bool ret = false; | ||
1029 | if (!_scene.NeedsMeshing(_pbs)) | 963 | if (!_scene.NeedsMeshing(_pbs)) |
1030 | { | 964 | { |
1031 | if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) | 965 | if (_pbs.ProfileShape == ProfileShape.HalfCircle && _pbs.PathCurve == (byte)Extrusion.Curve1) |
@@ -1033,18 +967,26 @@ public sealed class BSPrim : PhysicsActor | |||
1033 | if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) | 967 | if (_size.X == _size.Y && _size.Y == _size.Z && _size.X == _size.Z) |
1034 | { | 968 | { |
1035 | // m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size); | 969 | // m_log.DebugFormat("{0}: CreateGeom: Defaulting to sphere of size {1}", LogHeader, _size); |
1036 | _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE; | 970 | if (_shapeType != ShapeData.PhysicsShapeType.SHAPE_SPHERE) |
1037 | DetailLog("{0},CreateGeom,sphere", LocalID); | 971 | { |
1038 | // Bullet native objects are scaled by the Bullet engine so pass the size in | 972 | DetailLog("{0},CreateGeom,sphere", LocalID); |
1039 | _scale = _size; | 973 | _shapeType = ShapeData.PhysicsShapeType.SHAPE_SPHERE; |
974 | ret = true; | ||
975 | // Bullet native objects are scaled by the Bullet engine so pass the size in | ||
976 | _scale = _size; | ||
977 | } | ||
1040 | } | 978 | } |
1041 | } | 979 | } |
1042 | else | 980 | else |
1043 | { | 981 | { |
1044 | // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, size={2}", LogHeader, LocalID, _size); | 982 | // m_log.DebugFormat("{0}: CreateGeom: Defaulting to box. lid={1}, size={2}", LogHeader, LocalID, _size); |
1045 | DetailLog("{0},CreateGeom,box", LocalID); | 983 | if (_shapeType != ShapeData.PhysicsShapeType.SHAPE_BOX) |
1046 | _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX; | 984 | { |
1047 | _scale = _size; | 985 | DetailLog("{0},CreateGeom,box", LocalID); |
986 | _shapeType = ShapeData.PhysicsShapeType.SHAPE_BOX; | ||
987 | ret = true; | ||
988 | _scale = _size; | ||
989 | } | ||
1048 | } | 990 | } |
1049 | } | 991 | } |
1050 | else | 992 | else |
@@ -1056,6 +998,7 @@ public sealed class BSPrim : PhysicsActor | |||
1056 | // physical objects require a hull for interaction. | 998 | // physical objects require a hull for interaction. |
1057 | // This will create the mesh if it doesn't already exist | 999 | // This will create the mesh if it doesn't already exist |
1058 | CreateGeomHull(); | 1000 | CreateGeomHull(); |
1001 | ret = true; | ||
1059 | } | 1002 | } |
1060 | } | 1003 | } |
1061 | else | 1004 | else |
@@ -1064,9 +1007,11 @@ public sealed class BSPrim : PhysicsActor | |||
1064 | { | 1007 | { |
1065 | // Static (non-physical) objects only need a mesh for bumping into | 1008 | // Static (non-physical) objects only need a mesh for bumping into |
1066 | CreateGeomMesh(); | 1009 | CreateGeomMesh(); |
1010 | ret = true; | ||
1067 | } | 1011 | } |
1068 | } | 1012 | } |
1069 | } | 1013 | } |
1014 | return ret; | ||
1070 | } | 1015 | } |
1071 | 1016 | ||
1072 | // No locking here because this is done when we know physics is not simulating | 1017 | // No locking here because this is done when we know physics is not simulating |
@@ -1251,20 +1196,18 @@ public sealed class BSPrim : PhysicsActor | |||
1251 | // No locking here because this is done when the physics engine is not simulating | 1196 | // No locking here because this is done when the physics engine is not simulating |
1252 | private void CreateObject() | 1197 | private void CreateObject() |
1253 | { | 1198 | { |
1254 | if (IsRootOfLinkset) | 1199 | // this routine is called when objects are rebuilt. |
1255 | { | 1200 | |
1256 | // Create a linkset around this object | 1201 | // the mesh or hull must have already been created in Bullet |
1257 | CreateLinkset(); | 1202 | ShapeData shape; |
1258 | } | 1203 | FillShapeInfo(out shape); |
1259 | else | 1204 | // m_log.DebugFormat("{0}: CreateObject: lID={1}, shape={2}", LogHeader, _localID, shape.Type); |
1260 | { | 1205 | BulletSimAPI.CreateObject(_scene.WorldID, shape); |
1261 | // simple object | 1206 | // the CreateObject() may have recreated the rigid body. Make sure we have the latest. |
1262 | // the mesh or hull must have already been created in Bullet | 1207 | m_body.Ptr = BulletSimAPI.GetBodyHandle2(_scene.World.Ptr, LocalID); |
1263 | ShapeData shape; | 1208 | |
1264 | FillShapeInfo(out shape); | 1209 | // The root object could have been recreated. Make sure everything linksety is up to date. |
1265 | // m_log.DebugFormat("{0}: CreateObject: lID={1}, shape={2}", LogHeader, _localID, shape.Type); | 1210 | _linkset.RefreshLinkset(this); |
1266 | BulletSimAPI.CreateObject(_scene.WorldID, shape); | ||
1267 | } | ||
1268 | } | 1211 | } |
1269 | 1212 | ||
1270 | // Copy prim's info into the BulletSim shape description structure | 1213 | // Copy prim's info into the BulletSim shape description structure |
@@ -1276,7 +1219,7 @@ public sealed class BSPrim : PhysicsActor | |||
1276 | shape.Rotation = _orientation; | 1219 | shape.Rotation = _orientation; |
1277 | shape.Velocity = _velocity; | 1220 | shape.Velocity = _velocity; |
1278 | shape.Scale = _scale; | 1221 | shape.Scale = _scale; |
1279 | shape.Mass = Mass; | 1222 | shape.Mass = _isPhysical ? _mass : 0f; |
1280 | shape.Buoyancy = _buoyancy; | 1223 | shape.Buoyancy = _buoyancy; |
1281 | shape.HullKey = _hullKey; | 1224 | shape.HullKey = _hullKey; |
1282 | shape.MeshKey = _meshKey; | 1225 | shape.MeshKey = _meshKey; |
@@ -1286,72 +1229,6 @@ public sealed class BSPrim : PhysicsActor | |||
1286 | shape.Static = _isPhysical ? ShapeData.numericFalse : ShapeData.numericTrue; | 1229 | shape.Static = _isPhysical ? ShapeData.numericFalse : ShapeData.numericTrue; |
1287 | } | 1230 | } |
1288 | 1231 | ||
1289 | #region Linkset creation and destruction | ||
1290 | |||
1291 | // Create the linkset by putting constraints between the objects of the set so they cannot move | ||
1292 | // relative to each other. | ||
1293 | void CreateLinkset() | ||
1294 | { | ||
1295 | DebugLog("{0}: CreateLinkset. Root prim={1}, prims={2}", LogHeader, LocalID, _childrenPrims.Count+1); | ||
1296 | |||
1297 | // remove any constraints that might be in place | ||
1298 | DebugLog("{0}: CreateLinkset: RemoveConstraints between me and any children", LogHeader, LocalID); | ||
1299 | BulletSimAPI.RemoveConstraintByID(_scene.WorldID, LocalID); | ||
1300 | |||
1301 | // create constraints between the root prim and each of the children | ||
1302 | foreach (BSPrim prim in _childrenPrims) | ||
1303 | { | ||
1304 | LinkAChildToMe(prim); | ||
1305 | } | ||
1306 | } | ||
1307 | |||
1308 | // Create a constraint between me (root of linkset) and the passed prim (the child). | ||
1309 | // Called at taint time! | ||
1310 | private void LinkAChildToMe(BSPrim childPrim) | ||
1311 | { | ||
1312 | // Zero motion for children so they don't interpolate | ||
1313 | childPrim.ZeroMotion(); | ||
1314 | |||
1315 | // relative position normalized to the root prim | ||
1316 | OMV.Quaternion invThisOrientation = OMV.Quaternion.Inverse(this._orientation); | ||
1317 | OMV.Vector3 childRelativePosition = (childPrim._position - this._position) * invThisOrientation; | ||
1318 | |||
1319 | // relative rotation of the child to the parent | ||
1320 | OMV.Quaternion childRelativeRotation = invThisOrientation * childPrim._orientation; | ||
1321 | |||
1322 | // create a constraint that allows no freedom of movement between the two objects | ||
1323 | // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 | ||
1324 | DebugLog("{0}: CreateLinkset: Adding a constraint between root prim {1} and child prim {2}", LogHeader, LocalID, childPrim.LocalID); | ||
1325 | DetailLog("{0},LinkAChildToMe,taint,root={1},child={2}", LocalID, LocalID, childPrim.LocalID); | ||
1326 | BulletSimAPI.AddConstraint(_scene.WorldID, LocalID, childPrim.LocalID, | ||
1327 | childRelativePosition, | ||
1328 | childRelativeRotation, | ||
1329 | OMV.Vector3.Zero, | ||
1330 | OMV.Quaternion.Identity, | ||
1331 | OMV.Vector3.Zero, OMV.Vector3.Zero, | ||
1332 | OMV.Vector3.Zero, OMV.Vector3.Zero); | ||
1333 | } | ||
1334 | |||
1335 | // Remove linkage between myself and a particular child | ||
1336 | // Called at taint time! | ||
1337 | private void UnlinkAChildFromMe(BSPrim childPrim) | ||
1338 | { | ||
1339 | DebugLog("{0}: UnlinkAChildFromMe: RemoveConstraint between root prim {1} and child prim {2}", | ||
1340 | LogHeader, LocalID, childPrim.LocalID); | ||
1341 | DetailLog("{0},UnlinkAChildFromMe,taint,root={1},child={2}", LocalID, LocalID, childPrim.LocalID); | ||
1342 | BulletSimAPI.RemoveConstraint(_scene.WorldID, LocalID, childPrim.LocalID); | ||
1343 | } | ||
1344 | |||
1345 | // Remove linkage between myself and any possible children I might have | ||
1346 | // Called at taint time! | ||
1347 | private void UnlinkAllChildren() | ||
1348 | { | ||
1349 | DebugLog("{0}: UnlinkAllChildren:", LogHeader); | ||
1350 | DetailLog("{0},UnlinkAllChildren,taint", LocalID); | ||
1351 | BulletSimAPI.RemoveConstraintByID(_scene.WorldID, LocalID); | ||
1352 | } | ||
1353 | |||
1354 | #endregion // Linkset creation and destruction | ||
1355 | 1232 | ||
1356 | // Rebuild the geometry and object. | 1233 | // Rebuild the geometry and object. |
1357 | // This is called when the shape changes so we need to recreate the mesh/hull. | 1234 | // This is called when the shape changes so we need to recreate the mesh/hull. |
@@ -1429,7 +1306,7 @@ public sealed class BSPrim : PhysicsActor | |||
1429 | // Don't check for damping here -- it's done in BulletSim and SceneObjectPart. | 1306 | // Don't check for damping here -- it's done in BulletSim and SceneObjectPart. |
1430 | 1307 | ||
1431 | // Updates only for individual prims and for the root object of a linkset. | 1308 | // Updates only for individual prims and for the root object of a linkset. |
1432 | if (_parentPrim == null) | 1309 | if (_linkset.IsRoot(this)) |
1433 | { | 1310 | { |
1434 | // Assign to the local variables so the normal set action does not happen | 1311 | // Assign to the local variables so the normal set action does not happen |
1435 | _position = entprop.Position; | 1312 | _position = entprop.Position; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 7cc3fe3..c6d622b 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -73,7 +73,7 @@ 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 | private void DebugLog(string mm, params Object[] xx) { if (shouldDebugLog) m_log.DebugFormat(mm, xx); } | 76 | public void DebugLog(string mm, params Object[] xx) { if (shouldDebugLog) m_log.DebugFormat(mm, xx); } |
77 | 77 | ||
78 | public string BulletSimVersion = "?"; | 78 | public string BulletSimVersion = "?"; |
79 | 79 | ||
@@ -87,6 +87,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
87 | private uint m_worldID; | 87 | private uint m_worldID; |
88 | public uint WorldID { get { return m_worldID; } } | 88 | public uint WorldID { get { return m_worldID; } } |
89 | 89 | ||
90 | // let my minuions use my logger | ||
91 | public ILog Logger { get { return m_log; } } | ||
92 | |||
90 | private bool m_initialized = false; | 93 | private bool m_initialized = false; |
91 | 94 | ||
92 | private int m_detailedStatsStep = 0; | 95 | private int m_detailedStatsStep = 0; |
@@ -103,6 +106,17 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
103 | get { return m_sculptLOD; } | 106 | get { return m_sculptLOD; } |
104 | } | 107 | } |
105 | 108 | ||
109 | private BulletSim m_worldSim; | ||
110 | public BulletSim World | ||
111 | { | ||
112 | get { return m_worldSim; } | ||
113 | } | ||
114 | private BSConstraintCollection m_constraintCollection; | ||
115 | public BSConstraintCollection Constraints | ||
116 | { | ||
117 | get { return m_constraintCollection; } | ||
118 | } | ||
119 | |||
106 | private int m_maxSubSteps; | 120 | private int m_maxSubSteps; |
107 | private float m_fixedTimeStep; | 121 | private float m_fixedTimeStep; |
108 | private long m_simulationStep = 0; | 122 | private long m_simulationStep = 0; |
@@ -229,6 +243,11 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
229 | m_maxCollisionsPerFrame, m_collisionArrayPinnedHandle.AddrOfPinnedObject(), | 243 | m_maxCollisionsPerFrame, m_collisionArrayPinnedHandle.AddrOfPinnedObject(), |
230 | m_maxUpdatesPerFrame, m_updateArrayPinnedHandle.AddrOfPinnedObject()); | 244 | m_maxUpdatesPerFrame, m_updateArrayPinnedHandle.AddrOfPinnedObject()); |
231 | 245 | ||
246 | // Initialization to support the transition to a new API which puts most of the logic | ||
247 | // into the C# code so it is easier to modify and add to. | ||
248 | m_worldSim = new BulletSim(m_worldID, BulletSimAPI.GetSimHandle2(m_worldID)); | ||
249 | m_constraintCollection = new BSConstraintCollection(World); | ||
250 | |||
232 | m_initialized = true; | 251 | m_initialized = true; |
233 | } | 252 | } |
234 | 253 | ||
@@ -237,116 +256,17 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
237 | private void GetInitialParameterValues(IConfigSource config) | 256 | private void GetInitialParameterValues(IConfigSource config) |
238 | { | 257 | { |
239 | ConfigurationParameters parms = new ConfigurationParameters(); | 258 | ConfigurationParameters parms = new ConfigurationParameters(); |
259 | m_params[0] = parms; | ||
240 | 260 | ||
241 | _meshSculptedPrim = true; // mesh sculpted prims | 261 | SetParameterDefaultValues(); |
242 | _forceSimplePrimMeshing = false; // use complex meshing if called for | ||
243 | |||
244 | m_meshLOD = 8f; | ||
245 | m_sculptLOD = 32f; | ||
246 | |||
247 | shouldDebugLog = false; | ||
248 | m_detailedStatsStep = 0; // disabled | ||
249 | |||
250 | m_maxSubSteps = 10; | ||
251 | m_fixedTimeStep = 1f / 60f; | ||
252 | m_maxCollisionsPerFrame = 2048; | ||
253 | m_maxUpdatesPerFrame = 2048; | ||
254 | m_maximumObjectMass = 10000.01f; | ||
255 | |||
256 | PID_D = 2200f; | ||
257 | PID_P = 900f; | ||
258 | |||
259 | parms.defaultFriction = 0.5f; | ||
260 | parms.defaultDensity = 10.000006836f; // Aluminum g/cm3 | ||
261 | parms.defaultRestitution = 0f; | ||
262 | parms.collisionMargin = 0.0f; | ||
263 | parms.gravity = -9.80665f; | ||
264 | |||
265 | parms.linearDamping = 0.0f; | ||
266 | parms.angularDamping = 0.0f; | ||
267 | parms.deactivationTime = 0.2f; | ||
268 | parms.linearSleepingThreshold = 0.8f; | ||
269 | parms.angularSleepingThreshold = 1.0f; | ||
270 | parms.ccdMotionThreshold = 0.0f; // set to zero to disable | ||
271 | parms.ccdSweptSphereRadius = 0.0f; | ||
272 | parms.contactProcessingThreshold = 0.1f; | ||
273 | |||
274 | parms.terrainFriction = 0.5f; | ||
275 | parms.terrainHitFraction = 0.8f; | ||
276 | parms.terrainRestitution = 0f; | ||
277 | parms.avatarFriction = 0.5f; | ||
278 | parms.avatarRestitution = 0.0f; | ||
279 | parms.avatarDensity = 60f; | ||
280 | parms.avatarCapsuleRadius = 0.37f; | ||
281 | parms.avatarCapsuleHeight = 1.5f; // 2.140599f | ||
282 | parms.avatarContactProcessingThreshold = 0.1f; | ||
283 | |||
284 | parms.maxPersistantManifoldPoolSize = 0f; | ||
285 | parms.shouldDisableContactPoolDynamicAllocation = ConfigurationParameters.numericTrue; | ||
286 | parms.shouldForceUpdateAllAabbs = ConfigurationParameters.numericFalse; | ||
287 | parms.shouldRandomizeSolverOrder = ConfigurationParameters.numericFalse; | ||
288 | parms.shouldSplitSimulationIslands = ConfigurationParameters.numericFalse; | ||
289 | parms.shouldEnableFrictionCaching = ConfigurationParameters.numericFalse; | ||
290 | parms.numberOfSolverIterations = 0f; // means use default | ||
291 | 262 | ||
292 | if (config != null) | 263 | if (config != null) |
293 | { | 264 | { |
294 | // If there are specifications in the ini file, use those values | 265 | // If there are specifications in the ini file, use those values |
295 | // WHEN ADDING OR UPDATING THIS SECTION, BE SURE TO UPDATE OpenSimDefaults.ini | ||
296 | // ALSO REMEMBER TO UPDATE THE RUNTIME SETTING OF THE PARAMETERS. | ||
297 | IConfig pConfig = config.Configs["BulletSim"]; | 266 | IConfig pConfig = config.Configs["BulletSim"]; |
298 | if (pConfig != null) | 267 | if (pConfig != null) |
299 | { | 268 | { |
300 | _meshSculptedPrim = pConfig.GetBoolean("MeshSculptedPrim", _meshSculptedPrim); | 269 | SetParameterConfigurationValues(pConfig); |
301 | _forceSimplePrimMeshing = pConfig.GetBoolean("ForceSimplePrimMeshing", _forceSimplePrimMeshing); | ||
302 | |||
303 | shouldDebugLog = pConfig.GetBoolean("ShouldDebugLog", shouldDebugLog); | ||
304 | m_detailedStatsStep = pConfig.GetInt("DetailedStatsStep", m_detailedStatsStep); | ||
305 | |||
306 | m_meshLOD = pConfig.GetFloat("MeshLevelOfDetail", m_meshLOD); | ||
307 | m_sculptLOD = pConfig.GetFloat("SculptLevelOfDetail", m_sculptLOD); | ||
308 | |||
309 | m_maxSubSteps = pConfig.GetInt("MaxSubSteps", m_maxSubSteps); | ||
310 | m_fixedTimeStep = pConfig.GetFloat("FixedTimeStep", m_fixedTimeStep); | ||
311 | m_maxCollisionsPerFrame = pConfig.GetInt("MaxCollisionsPerFrame", m_maxCollisionsPerFrame); | ||
312 | m_maxUpdatesPerFrame = pConfig.GetInt("MaxUpdatesPerFrame", m_maxUpdatesPerFrame); | ||
313 | m_maximumObjectMass = pConfig.GetFloat("MaxObjectMass", m_maximumObjectMass); | ||
314 | |||
315 | PID_D = pConfig.GetFloat("PIDDerivative", PID_D); | ||
316 | PID_P = pConfig.GetFloat("PIDProportional", PID_P); | ||
317 | |||
318 | parms.defaultFriction = pConfig.GetFloat("DefaultFriction", parms.defaultFriction); | ||
319 | parms.defaultDensity = pConfig.GetFloat("DefaultDensity", parms.defaultDensity); | ||
320 | parms.defaultRestitution = pConfig.GetFloat("DefaultRestitution", parms.defaultRestitution); | ||
321 | parms.collisionMargin = pConfig.GetFloat("CollisionMargin", parms.collisionMargin); | ||
322 | parms.gravity = pConfig.GetFloat("Gravity", parms.gravity); | ||
323 | |||
324 | parms.linearDamping = pConfig.GetFloat("LinearDamping", parms.linearDamping); | ||
325 | parms.angularDamping = pConfig.GetFloat("AngularDamping", parms.angularDamping); | ||
326 | parms.deactivationTime = pConfig.GetFloat("DeactivationTime", parms.deactivationTime); | ||
327 | parms.linearSleepingThreshold = pConfig.GetFloat("LinearSleepingThreshold", parms.linearSleepingThreshold); | ||
328 | parms.angularSleepingThreshold = pConfig.GetFloat("AngularSleepingThreshold", parms.angularSleepingThreshold); | ||
329 | parms.ccdMotionThreshold = pConfig.GetFloat("CcdMotionThreshold", parms.ccdMotionThreshold); | ||
330 | parms.ccdSweptSphereRadius = pConfig.GetFloat("CcdSweptSphereRadius", parms.ccdSweptSphereRadius); | ||
331 | parms.contactProcessingThreshold = pConfig.GetFloat("ContactProcessingThreshold", parms.contactProcessingThreshold); | ||
332 | |||
333 | parms.terrainFriction = pConfig.GetFloat("TerrainFriction", parms.terrainFriction); | ||
334 | parms.terrainHitFraction = pConfig.GetFloat("TerrainHitFraction", parms.terrainHitFraction); | ||
335 | parms.terrainRestitution = pConfig.GetFloat("TerrainRestitution", parms.terrainRestitution); | ||
336 | parms.avatarFriction = pConfig.GetFloat("AvatarFriction", parms.avatarFriction); | ||
337 | parms.avatarRestitution = pConfig.GetFloat("AvatarRestitution", parms.avatarRestitution); | ||
338 | parms.avatarDensity = pConfig.GetFloat("AvatarDensity", parms.avatarDensity); | ||
339 | parms.avatarCapsuleRadius = pConfig.GetFloat("AvatarCapsuleRadius", parms.avatarCapsuleRadius); | ||
340 | parms.avatarCapsuleHeight = pConfig.GetFloat("AvatarCapsuleHeight", parms.avatarCapsuleHeight); | ||
341 | parms.avatarContactProcessingThreshold = pConfig.GetFloat("AvatarContactProcessingThreshold", parms.avatarContactProcessingThreshold); | ||
342 | |||
343 | parms.maxPersistantManifoldPoolSize = pConfig.GetFloat("MaxPersistantManifoldPoolSize", parms.maxPersistantManifoldPoolSize); | ||
344 | parms.shouldDisableContactPoolDynamicAllocation = ParamBoolean(pConfig, "ShouldDisableContactPoolDynamicAllocation", parms.shouldDisableContactPoolDynamicAllocation); | ||
345 | parms.shouldForceUpdateAllAabbs = ParamBoolean(pConfig, "ShouldForceUpdateAllAabbs", parms.shouldForceUpdateAllAabbs); | ||
346 | parms.shouldRandomizeSolverOrder = ParamBoolean(pConfig, "ShouldRandomizeSolverOrder", parms.shouldRandomizeSolverOrder); | ||
347 | parms.shouldSplitSimulationIslands = ParamBoolean(pConfig, "ShouldSplitSimulationIslands", parms.shouldSplitSimulationIslands); | ||
348 | parms.shouldEnableFrictionCaching = ParamBoolean(pConfig, "ShouldEnableFrictionCaching", parms.shouldEnableFrictionCaching); | ||
349 | parms.numberOfSolverIterations = pConfig.GetFloat("NumberOfSolverIterations", parms.numberOfSolverIterations); | ||
350 | 270 | ||
351 | // Very detailed logging for physics debugging | 271 | // Very detailed logging for physics debugging |
352 | m_physicsLoggingEnabled = pConfig.GetBoolean("PhysicsLoggingEnabled", false); | 272 | m_physicsLoggingEnabled = pConfig.GetBoolean("PhysicsLoggingEnabled", false); |
@@ -357,7 +277,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
357 | m_vehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false); | 277 | m_vehicleLoggingEnabled = pConfig.GetBoolean("VehicleLoggingEnabled", false); |
358 | } | 278 | } |
359 | } | 279 | } |
360 | m_params[0] = parms; | ||
361 | } | 280 | } |
362 | 281 | ||
363 | // A helper function that handles a true/false parameter and returns the proper float number encoding | 282 | // A helper function that handles a true/false parameter and returns the proper float number encoding |
@@ -634,6 +553,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
634 | // make sure no stepping happens while we're deleting stuff | 553 | // make sure no stepping happens while we're deleting stuff |
635 | m_initialized = false; | 554 | m_initialized = false; |
636 | 555 | ||
556 | if (m_constraintCollection != null) | ||
557 | { | ||
558 | m_constraintCollection.Dispose(); | ||
559 | m_constraintCollection = null; | ||
560 | } | ||
561 | |||
637 | foreach (KeyValuePair<uint, BSCharacter> kvp in m_avatars) | 562 | foreach (KeyValuePair<uint, BSCharacter> kvp in m_avatars) |
638 | { | 563 | { |
639 | kvp.Value.Destroy(); | 564 | kvp.Value.Destroy(); |
@@ -776,10 +701,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
776 | } | 701 | } |
777 | 702 | ||
778 | // The calls to the PhysicsActors can't directly call into the physics engine | 703 | // The calls to the PhysicsActors can't directly call into the physics engine |
779 | // because it might be busy. We we delay changes to a known time. | 704 | // because it might be busy. We delay changes to a known time. |
780 | // We rely on C#'s closure to save and restore the context for the delegate. | 705 | // We rely on C#'s closure to save and restore the context for the delegate. |
781 | public void TaintedObject(TaintCallback callback) | 706 | public void TaintedObject(TaintCallback callback) |
782 | { | 707 | { |
708 | if (!m_initialized) return; | ||
709 | |||
783 | lock (_taintLock) | 710 | lock (_taintLock) |
784 | _taintedObjects.Add(callback); | 711 | _taintedObjects.Add(callback); |
785 | return; | 712 | return; |
@@ -853,61 +780,371 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
853 | } | 780 | } |
854 | #endregion Vehicles | 781 | #endregion Vehicles |
855 | 782 | ||
856 | #region Runtime settable parameters | 783 | #region Parameters |
857 | public static PhysParameterEntry[] SettableParameters = new PhysParameterEntry[] | 784 | |
785 | delegate void ParamUser(BSScene scene, IConfig conf, string paramName, float val); | ||
786 | delegate float ParamGet(BSScene scene); | ||
787 | delegate void ParamSet(BSScene scene, string paramName, uint localID, float val); | ||
788 | |||
789 | private struct ParameterDefn | ||
790 | { | ||
791 | public string name; | ||
792 | public string desc; | ||
793 | public float defaultValue; | ||
794 | public ParamUser userParam; | ||
795 | public ParamGet getter; | ||
796 | public ParamSet setter; | ||
797 | public ParameterDefn(string n, string d, float v, ParamUser u, ParamGet g, ParamSet s) | ||
798 | { | ||
799 | name = n; | ||
800 | desc = d; | ||
801 | defaultValue = v; | ||
802 | userParam = u; | ||
803 | getter = g; | ||
804 | setter = s; | ||
805 | } | ||
806 | } | ||
807 | |||
808 | // List of all of the externally visible parameters. | ||
809 | // For each parameter, this table maps a text name to getter and setters. | ||
810 | // A ParameterDefn() takes the following parameters: | ||
811 | // -- the text name of the parameter. This is used for console input and ini file. | ||
812 | // -- a short text description of the parameter. This shows up in the console listing. | ||
813 | // -- a delegate for fetching the parameter from the ini file. | ||
814 | // Should handle fetching the right type from the ini file and converting it. | ||
815 | // -- a delegate for getting the value as a float | ||
816 | // -- a delegate for setting the value from a float | ||
817 | // | ||
818 | // To add a new variable, it is best to find an existing definition and copy it. | ||
819 | private ParameterDefn[] ParameterDefinitions = | ||
858 | { | 820 | { |
859 | new PhysParameterEntry("MeshLOD", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)"), | 821 | new ParameterDefn("MeshSculptedPrim", "Whether to create meshes for sculpties", |
860 | new PhysParameterEntry("SculptLOD", "Level of detail to render sculpties (32, 16, 8 or 4. 32=most detailed)"), | 822 | ConfigurationParameters.numericTrue, |
861 | new PhysParameterEntry("MaxSubStep", "In simulation step, maximum number of substeps"), | 823 | (s,cf,p,v) => { s._meshSculptedPrim = cf.GetBoolean(p, s.BoolNumeric(v)); }, |
862 | new PhysParameterEntry("FixedTimeStep", "In simulation step, seconds of one substep (1/60)"), | 824 | (s) => { return s.NumericBool(s._meshSculptedPrim); }, |
863 | new PhysParameterEntry("MaxObjectMass", "Maximum object mass (10000.01)"), | 825 | (s,p,l,v) => { s._meshSculptedPrim = s.BoolNumeric(v); } ), |
864 | new PhysParameterEntry("DetailedStats", "Frames between outputting detailed phys stats. Zero is off"), | 826 | new ParameterDefn("ForceSimplePrimMeshing", "If true, only use primitive meshes for objects", |
865 | 827 | ConfigurationParameters.numericFalse, | |
866 | new PhysParameterEntry("DefaultFriction", "Friction factor used on new objects"), | 828 | (s,cf,p,v) => { s._forceSimplePrimMeshing = cf.GetBoolean(p, s.BoolNumeric(v)); }, |
867 | new PhysParameterEntry("DefaultDensity", "Density for new objects" ), | 829 | (s) => { return s.NumericBool(s._forceSimplePrimMeshing); }, |
868 | new PhysParameterEntry("DefaultRestitution", "Bouncyness of an object" ), | 830 | (s,p,l,v) => { s._forceSimplePrimMeshing = s.BoolNumeric(v); } ), |
869 | // new PhysParameterEntry("CollisionMargin", "Margin around objects before collisions are calculated (must be zero!!)" ), | 831 | |
870 | new PhysParameterEntry("Gravity", "Vertical force of gravity (negative means down)" ), | 832 | new ParameterDefn("MeshLOD", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)", |
871 | 833 | 8f, | |
872 | new PhysParameterEntry("LinearDamping", "Factor to damp linear movement per second (0.0 - 1.0)" ), | 834 | (s,cf,p,v) => { s.m_meshLOD = cf.GetInt(p, (int)v); }, |
873 | new PhysParameterEntry("AngularDamping", "Factor to damp angular movement per second (0.0 - 1.0)" ), | 835 | (s) => { return (float)s.m_meshLOD; }, |
874 | new PhysParameterEntry("DeactivationTime", "Seconds before considering an object potentially static" ), | 836 | (s,p,l,v) => { s.m_meshLOD = (int)v; } ), |
875 | new PhysParameterEntry("LinearSleepingThreshold", "Seconds to measure linear movement before considering static" ), | 837 | new ParameterDefn("SculptLOD", "Level of detail to render sculpties (32, 16, 8 or 4. 32=most detailed)", |
876 | new PhysParameterEntry("AngularSleepingThreshold", "Seconds to measure angular movement before considering static" ), | 838 | 32, |
877 | new PhysParameterEntry("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" ), | 839 | (s,cf,p,v) => { s.m_sculptLOD = cf.GetInt(p, (int)v); }, |
878 | new PhysParameterEntry("CcdSweptSphereRadius", "Continuious collision detection test radius" ), | 840 | (s) => { return (float)s.m_sculptLOD; }, |
879 | new PhysParameterEntry("ContactProcessingThreshold", "Distance between contacts before doing collision check" ), | 841 | (s,p,l,v) => { s.m_sculptLOD = (int)v; } ), |
880 | // Can only change the following at initialization time. Change the INI file and reboot. | 842 | |
881 | new PhysParameterEntry("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default)"), | 843 | new ParameterDefn("MaxSubStep", "In simulation step, maximum number of substeps", |
882 | new PhysParameterEntry("ShouldDisableContactPoolDynamicAllocation", "Enable to allow large changes in object count"), | 844 | 10f, |
883 | new PhysParameterEntry("ShouldForceUpdateAllAabbs", "Enable to recomputer AABBs every simulator step"), | 845 | (s,cf,p,v) => { s.m_maxSubSteps = cf.GetInt(p, (int)v); }, |
884 | new PhysParameterEntry("ShouldRandomizeSolverOrder", "Enable for slightly better stacking interaction"), | 846 | (s) => { return (float)s.m_maxSubSteps; }, |
885 | new PhysParameterEntry("ShouldSplitSimulationIslands", "Enable splitting active object scanning islands"), | 847 | (s,p,l,v) => { s.m_maxSubSteps = (int)v; } ), |
886 | new PhysParameterEntry("ShouldEnableFrictionCaching", "Enable friction computation caching"), | 848 | new ParameterDefn("FixedTimeStep", "In simulation step, seconds of one substep (1/60)", |
887 | new PhysParameterEntry("NumberOfSolverIterations", "Number of internal iterations (0 means default)"), | 849 | 1f / 60f, |
888 | 850 | (s,cf,p,v) => { s.m_fixedTimeStep = cf.GetFloat(p, v); }, | |
889 | new PhysParameterEntry("Friction", "Set friction parameter for a specific object" ), | 851 | (s) => { return (float)s.m_fixedTimeStep; }, |
890 | new PhysParameterEntry("Restitution", "Set restitution parameter for a specific object" ), | 852 | (s,p,l,v) => { s.m_fixedTimeStep = v; } ), |
891 | 853 | new ParameterDefn("MaxCollisionsPerFrame", "Max collisions returned at end of each frame", | |
892 | new PhysParameterEntry("Friction", "Set friction parameter for a specific object" ), | 854 | 2048f, |
893 | new PhysParameterEntry("Restitution", "Set restitution parameter for a specific object" ), | 855 | (s,cf,p,v) => { s.m_maxCollisionsPerFrame = cf.GetInt(p, (int)v); }, |
894 | 856 | (s) => { return (float)s.m_maxCollisionsPerFrame; }, | |
895 | new PhysParameterEntry("TerrainFriction", "Factor to reduce movement against terrain surface" ), | 857 | (s,p,l,v) => { s.m_maxCollisionsPerFrame = (int)v; } ), |
896 | new PhysParameterEntry("TerrainHitFraction", "Distance to measure hit collisions" ), | 858 | new ParameterDefn("MaxUpdatesPerFrame", "Max updates returned at end of each frame", |
897 | new PhysParameterEntry("TerrainRestitution", "Bouncyness" ), | 859 | 8000f, |
898 | new PhysParameterEntry("AvatarFriction", "Factor to reduce movement against an avatar. Changed on avatar recreation." ), | 860 | (s,cf,p,v) => { s.m_maxUpdatesPerFrame = cf.GetInt(p, (int)v); }, |
899 | new PhysParameterEntry("AvatarDensity", "Density of an avatar. Changed on avatar recreation." ), | 861 | (s) => { return (float)s.m_maxUpdatesPerFrame; }, |
900 | new PhysParameterEntry("AvatarRestitution", "Bouncyness. Changed on avatar recreation." ), | 862 | (s,p,l,v) => { s.m_maxUpdatesPerFrame = (int)v; } ), |
901 | new PhysParameterEntry("AvatarCapsuleRadius", "Radius of space around an avatar" ), | 863 | new ParameterDefn("MaxObjectMass", "Maximum object mass (10000.01)", |
902 | new PhysParameterEntry("AvatarCapsuleHeight", "Default height of space around avatar" ), | 864 | 10000.01f, |
903 | new PhysParameterEntry("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions") | 865 | (s,cf,p,v) => { s.m_maximumObjectMass = cf.GetFloat(p, v); }, |
866 | (s) => { return (float)s.m_maximumObjectMass; }, | ||
867 | (s,p,l,v) => { s.m_maximumObjectMass = v; } ), | ||
868 | |||
869 | new ParameterDefn("PID_D", "Derivitive factor for motion smoothing", | ||
870 | 2200f, | ||
871 | (s,cf,p,v) => { s.PID_D = cf.GetFloat(p, v); }, | ||
872 | (s) => { return (float)s.PID_D; }, | ||
873 | (s,p,l,v) => { s.PID_D = v; } ), | ||
874 | new ParameterDefn("PID_P", "Parameteric factor for motion smoothing", | ||
875 | 900f, | ||
876 | (s,cf,p,v) => { s.PID_P = cf.GetFloat(p, v); }, | ||
877 | (s) => { return (float)s.PID_P; }, | ||
878 | (s,p,l,v) => { s.PID_P = v; } ), | ||
879 | |||
880 | new ParameterDefn("DefaultFriction", "Friction factor used on new objects", | ||
881 | 0.5f, | ||
882 | (s,cf,p,v) => { s.m_params[0].defaultFriction = cf.GetFloat(p, v); }, | ||
883 | (s) => { return s.m_params[0].defaultFriction; }, | ||
884 | (s,p,l,v) => { s.m_params[0].defaultFriction = v; } ), | ||
885 | new ParameterDefn("DefaultDensity", "Density for new objects" , | ||
886 | 10.000006836f, // Aluminum g/cm3 | ||
887 | (s,cf,p,v) => { s.m_params[0].defaultDensity = cf.GetFloat(p, v); }, | ||
888 | (s) => { return s.m_params[0].defaultDensity; }, | ||
889 | (s,p,l,v) => { s.m_params[0].defaultDensity = v; } ), | ||
890 | new ParameterDefn("DefaultRestitution", "Bouncyness of an object" , | ||
891 | 0f, | ||
892 | (s,cf,p,v) => { s.m_params[0].defaultRestitution = cf.GetFloat(p, v); }, | ||
893 | (s) => { return s.m_params[0].defaultRestitution; }, | ||
894 | (s,p,l,v) => { s.m_params[0].defaultRestitution = v; } ), | ||
895 | new ParameterDefn("CollisionMargin", "Margin around objects before collisions are calculated (must be zero!)", | ||
896 | 0f, | ||
897 | (s,cf,p,v) => { s.m_params[0].collisionMargin = cf.GetFloat(p, v); }, | ||
898 | (s) => { return s.m_params[0].collisionMargin; }, | ||
899 | (s,p,l,v) => { s.m_params[0].collisionMargin = v; } ), | ||
900 | new ParameterDefn("Gravity", "Vertical force of gravity (negative means down)", | ||
901 | -9.80665f, | ||
902 | (s,cf,p,v) => { s.m_params[0].gravity = cf.GetFloat(p, v); }, | ||
903 | (s) => { return s.m_params[0].gravity; }, | ||
904 | (s,p,l,v) => { s.m_params[0].gravity = v; s.TaintedUpdateParameter(p,l,v); } ), | ||
905 | |||
906 | |||
907 | new ParameterDefn("LinearDamping", "Factor to damp linear movement per second (0.0 - 1.0)", | ||
908 | 0f, | ||
909 | (s,cf,p,v) => { s.m_params[0].linearDamping = cf.GetFloat(p, v); }, | ||
910 | (s) => { return s.m_params[0].linearDamping; }, | ||
911 | (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].linearDamping, p, l, v); } ), | ||
912 | new ParameterDefn("AngularDamping", "Factor to damp angular movement per second (0.0 - 1.0)", | ||
913 | 0f, | ||
914 | (s,cf,p,v) => { s.m_params[0].angularDamping = cf.GetFloat(p, v); }, | ||
915 | (s) => { return s.m_params[0].angularDamping; }, | ||
916 | (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].angularDamping, p, l, v); } ), | ||
917 | new ParameterDefn("DeactivationTime", "Seconds before considering an object potentially static", | ||
918 | 0.2f, | ||
919 | (s,cf,p,v) => { s.m_params[0].deactivationTime = cf.GetFloat(p, v); }, | ||
920 | (s) => { return s.m_params[0].deactivationTime; }, | ||
921 | (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].deactivationTime, p, l, v); } ), | ||
922 | new ParameterDefn("LinearSleepingThreshold", "Seconds to measure linear movement before considering static", | ||
923 | 0.8f, | ||
924 | (s,cf,p,v) => { s.m_params[0].linearSleepingThreshold = cf.GetFloat(p, v); }, | ||
925 | (s) => { return s.m_params[0].linearSleepingThreshold; }, | ||
926 | (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].linearSleepingThreshold, p, l, v); } ), | ||
927 | new ParameterDefn("AngularSleepingThreshold", "Seconds to measure angular movement before considering static", | ||
928 | 1.0f, | ||
929 | (s,cf,p,v) => { s.m_params[0].angularSleepingThreshold = cf.GetFloat(p, v); }, | ||
930 | (s) => { return s.m_params[0].angularSleepingThreshold; }, | ||
931 | (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].angularSleepingThreshold, p, l, v); } ), | ||
932 | new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" , | ||
933 | 0f, // set to zero to disable | ||
934 | (s,cf,p,v) => { s.m_params[0].ccdMotionThreshold = cf.GetFloat(p, v); }, | ||
935 | (s) => { return s.m_params[0].ccdMotionThreshold; }, | ||
936 | (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].ccdMotionThreshold, p, l, v); } ), | ||
937 | new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" , | ||
938 | 0f, | ||
939 | (s,cf,p,v) => { s.m_params[0].ccdSweptSphereRadius = cf.GetFloat(p, v); }, | ||
940 | (s) => { return s.m_params[0].ccdSweptSphereRadius; }, | ||
941 | (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].ccdSweptSphereRadius, p, l, v); } ), | ||
942 | new ParameterDefn("ContactProcessingThreshold", "Distance between contacts before doing collision check" , | ||
943 | 0.1f, | ||
944 | (s,cf,p,v) => { s.m_params[0].contactProcessingThreshold = cf.GetFloat(p, v); }, | ||
945 | (s) => { return s.m_params[0].contactProcessingThreshold; }, | ||
946 | (s,p,l,v) => { s.UpdateParameterPrims(ref s.m_params[0].contactProcessingThreshold, p, l, v); } ), | ||
947 | |||
948 | new ParameterDefn("TerrainFriction", "Factor to reduce movement against terrain surface" , | ||
949 | 0.5f, | ||
950 | (s,cf,p,v) => { s.m_params[0].terrainFriction = cf.GetFloat(p, v); }, | ||
951 | (s) => { return s.m_params[0].terrainFriction; }, | ||
952 | (s,p,l,v) => { s.m_params[0].terrainFriction = v; s.TaintedUpdateParameter(p,l,v); } ), | ||
953 | new ParameterDefn("TerrainHitFraction", "Distance to measure hit collisions" , | ||
954 | 0.8f, | ||
955 | (s,cf,p,v) => { s.m_params[0].terrainHitFraction = cf.GetFloat(p, v); }, | ||
956 | (s) => { return s.m_params[0].terrainHitFraction; }, | ||
957 | (s,p,l,v) => { s.m_params[0].terrainHitFraction = v; s.TaintedUpdateParameter(p,l,v); } ), | ||
958 | new ParameterDefn("TerrainRestitution", "Bouncyness" , | ||
959 | 0f, | ||
960 | (s,cf,p,v) => { s.m_params[0].terrainRestitution = cf.GetFloat(p, v); }, | ||
961 | (s) => { return s.m_params[0].terrainRestitution; }, | ||
962 | (s,p,l,v) => { s.m_params[0].terrainRestitution = v; s.TaintedUpdateParameter(p,l,v); } ), | ||
963 | new ParameterDefn("AvatarFriction", "Factor to reduce movement against an avatar. Changed on avatar recreation.", | ||
964 | 0.5f, | ||
965 | (s,cf,p,v) => { s.m_params[0].avatarFriction = cf.GetFloat(p, v); }, | ||
966 | (s) => { return s.m_params[0].avatarFriction; }, | ||
967 | (s,p,l,v) => { s.UpdateParameterAvatars(ref s.m_params[0].avatarFriction, p, l, v); } ), | ||
968 | new ParameterDefn("AvatarDensity", "Density of an avatar. Changed on avatar recreation.", | ||
969 | 60f, | ||
970 | (s,cf,p,v) => { s.m_params[0].avatarDensity = cf.GetFloat(p, v); }, | ||
971 | (s) => { return s.m_params[0].avatarDensity; }, | ||
972 | (s,p,l,v) => { s.UpdateParameterAvatars(ref s.m_params[0].avatarDensity, p, l, v); } ), | ||
973 | new ParameterDefn("AvatarRestitution", "Bouncyness. Changed on avatar recreation.", | ||
974 | 0f, | ||
975 | (s,cf,p,v) => { s.m_params[0].avatarRestitution = cf.GetFloat(p, v); }, | ||
976 | (s) => { return s.m_params[0].avatarRestitution; }, | ||
977 | (s,p,l,v) => { s.UpdateParameterAvatars(ref s.m_params[0].avatarRestitution, p, l, v); } ), | ||
978 | new ParameterDefn("AvatarCapsuleRadius", "Radius of space around an avatar", | ||
979 | 0.37f, | ||
980 | (s,cf,p,v) => { s.m_params[0].avatarCapsuleRadius = cf.GetFloat(p, v); }, | ||
981 | (s) => { return s.m_params[0].avatarCapsuleRadius; }, | ||
982 | (s,p,l,v) => { s.UpdateParameterAvatars(ref s.m_params[0].avatarCapsuleRadius, p, l, v); } ), | ||
983 | new ParameterDefn("AvatarCapsuleHeight", "Default height of space around avatar", | ||
984 | 1.5f, | ||
985 | (s,cf,p,v) => { s.m_params[0].avatarCapsuleHeight = cf.GetFloat(p, v); }, | ||
986 | (s) => { return s.m_params[0].avatarCapsuleHeight; }, | ||
987 | (s,p,l,v) => { s.UpdateParameterAvatars(ref s.m_params[0].avatarCapsuleHeight, p, l, v); } ), | ||
988 | new ParameterDefn("AvatarContactProcessingThreshold", "Distance from capsule to check for collisions", | ||
989 | 0.1f, | ||
990 | (s,cf,p,v) => { s.m_params[0].avatarContactProcessingThreshold = cf.GetFloat(p, v); }, | ||
991 | (s) => { return s.m_params[0].avatarContactProcessingThreshold; }, | ||
992 | (s,p,l,v) => { s.UpdateParameterAvatars(ref s.m_params[0].avatarContactProcessingThreshold, p, l, v); } ), | ||
993 | |||
994 | |||
995 | new ParameterDefn("MaxPersistantManifoldPoolSize", "Number of manifolds pooled (0 means default)", | ||
996 | 0f, // zero to disable | ||
997 | (s,cf,p,v) => { s.m_params[0].maxPersistantManifoldPoolSize = cf.GetFloat(p, v); }, | ||
998 | (s) => { return s.m_params[0].maxPersistantManifoldPoolSize; }, | ||
999 | (s,p,l,v) => { s.m_params[0].maxPersistantManifoldPoolSize = v; } ), | ||
1000 | new ParameterDefn("ShouldDisableContactPoolDynamicAllocation", "Enable to allow large changes in object count", | ||
1001 | ConfigurationParameters.numericTrue, | ||
1002 | (s,cf,p,v) => { s.m_params[0].maxPersistantManifoldPoolSize = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); }, | ||
1003 | (s) => { return s.m_params[0].shouldDisableContactPoolDynamicAllocation; }, | ||
1004 | (s,p,l,v) => { s.m_params[0].shouldDisableContactPoolDynamicAllocation = v; } ), | ||
1005 | new ParameterDefn("ShouldForceUpdateAllAabbs", "Enable to recomputer AABBs every simulator step", | ||
1006 | ConfigurationParameters.numericFalse, | ||
1007 | (s,cf,p,v) => { s.m_params[0].shouldForceUpdateAllAabbs = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); }, | ||
1008 | (s) => { return s.m_params[0].shouldForceUpdateAllAabbs; }, | ||
1009 | (s,p,l,v) => { s.m_params[0].shouldForceUpdateAllAabbs = v; } ), | ||
1010 | new ParameterDefn("ShouldRandomizeSolverOrder", "Enable for slightly better stacking interaction", | ||
1011 | ConfigurationParameters.numericFalse, | ||
1012 | (s,cf,p,v) => { s.m_params[0].shouldRandomizeSolverOrder = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); }, | ||
1013 | (s) => { return s.m_params[0].shouldRandomizeSolverOrder; }, | ||
1014 | (s,p,l,v) => { s.m_params[0].shouldRandomizeSolverOrder = v; } ), | ||
1015 | new ParameterDefn("ShouldSplitSimulationIslands", "Enable splitting active object scanning islands", | ||
1016 | ConfigurationParameters.numericFalse, | ||
1017 | (s,cf,p,v) => { s.m_params[0].shouldSplitSimulationIslands = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); }, | ||
1018 | (s) => { return s.m_params[0].shouldSplitSimulationIslands; }, | ||
1019 | (s,p,l,v) => { s.m_params[0].shouldSplitSimulationIslands = v; } ), | ||
1020 | new ParameterDefn("ShouldEnableFrictionCaching", "Enable friction computation caching", | ||
1021 | ConfigurationParameters.numericFalse, | ||
1022 | (s,cf,p,v) => { s.m_params[0].shouldEnableFrictionCaching = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); }, | ||
1023 | (s) => { return s.m_params[0].shouldEnableFrictionCaching; }, | ||
1024 | (s,p,l,v) => { s.m_params[0].shouldEnableFrictionCaching = v; } ), | ||
1025 | new ParameterDefn("NumberOfSolverIterations", "Number of internal iterations (0 means default)", | ||
1026 | 0f, // zero says use Bullet default | ||
1027 | (s,cf,p,v) => { s.m_params[0].numberOfSolverIterations = cf.GetFloat(p, v); }, | ||
1028 | (s) => { return s.m_params[0].numberOfSolverIterations; }, | ||
1029 | (s,p,l,v) => { s.m_params[0].numberOfSolverIterations = v; } ), | ||
1030 | |||
1031 | new ParameterDefn("LinkConstraintUseFrameOffset", "For linksets built with constraints, enable frame offsetFor linksets built with constraints, enable frame offset.", | ||
1032 | ConfigurationParameters.numericFalse, | ||
1033 | (s,cf,p,v) => { s.m_params[0].linkConstraintUseFrameOffset = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); }, | ||
1034 | (s) => { return s.m_params[0].linkConstraintUseFrameOffset; }, | ||
1035 | (s,p,l,v) => { s.m_params[0].linkConstraintUseFrameOffset = v; } ), | ||
1036 | new ParameterDefn("LinkConstraintEnableTransMotor", "Whether to enable translational motor on linkset constraints", | ||
1037 | ConfigurationParameters.numericTrue, | ||
1038 | (s,cf,p,v) => { s.m_params[0].linkConstraintEnableTransMotor = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); }, | ||
1039 | (s) => { return s.m_params[0].linkConstraintEnableTransMotor; }, | ||
1040 | (s,p,l,v) => { s.m_params[0].linkConstraintEnableTransMotor = v; } ), | ||
1041 | new ParameterDefn("LinkConstraintTransMotorMaxVel", "Maximum velocity to be applied by translational motor in linkset constraints", | ||
1042 | 5.0f, | ||
1043 | (s,cf,p,v) => { s.m_params[0].linkConstraintTransMotorMaxVel = cf.GetFloat(p, v); }, | ||
1044 | (s) => { return s.m_params[0].linkConstraintTransMotorMaxVel; }, | ||
1045 | (s,p,l,v) => { s.m_params[0].linkConstraintTransMotorMaxVel = v; } ), | ||
1046 | new ParameterDefn("LinkConstraintTransMotorMaxForce", "Maximum force to be applied by translational motor in linkset constraints", | ||
1047 | 0.1f, | ||
1048 | (s,cf,p,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = cf.GetFloat(p, v); }, | ||
1049 | (s) => { return s.m_params[0].linkConstraintTransMotorMaxForce; }, | ||
1050 | (s,p,l,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = v; } ), | ||
1051 | |||
1052 | new ParameterDefn("DetailedStats", "Frames between outputting detailed phys stats. (0 is off)", | ||
1053 | 0f, | ||
1054 | (s,cf,p,v) => { s.m_detailedStatsStep = cf.GetInt(p, (int)v); }, | ||
1055 | (s) => { return (float)s.m_detailedStatsStep; }, | ||
1056 | (s,p,l,v) => { s.m_detailedStatsStep = (int)v; } ), | ||
1057 | new ParameterDefn("ShouldDebugLog", "Enables detailed DEBUG log statements", | ||
1058 | ConfigurationParameters.numericFalse, | ||
1059 | (s,cf,p,v) => { s.shouldDebugLog = cf.GetBoolean(p, s.BoolNumeric(v)); }, | ||
1060 | (s) => { return s.NumericBool(s.shouldDebugLog); }, | ||
1061 | (s,p,l,v) => { s.shouldDebugLog = s.BoolNumeric(v); } ), | ||
904 | 1062 | ||
905 | }; | 1063 | }; |
906 | 1064 | ||
1065 | // Convert a boolean to our numeric true and false values | ||
1066 | public float NumericBool(bool b) | ||
1067 | { | ||
1068 | return (b ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse); | ||
1069 | } | ||
1070 | |||
1071 | // Convert numeric true and false values to a boolean | ||
1072 | public bool BoolNumeric(float b) | ||
1073 | { | ||
1074 | return (b == ConfigurationParameters.numericTrue ? true : false); | ||
1075 | } | ||
1076 | |||
1077 | // Search through the parameter definitions and return the matching | ||
1078 | // ParameterDefn structure. | ||
1079 | // Case does not matter as names are compared after converting to lower case. | ||
1080 | // Returns 'false' if the parameter is not found. | ||
1081 | private bool TryGetParameter(string paramName, out ParameterDefn defn) | ||
1082 | { | ||
1083 | bool ret = false; | ||
1084 | ParameterDefn foundDefn = new ParameterDefn(); | ||
1085 | string pName = paramName.ToLower(); | ||
1086 | |||
1087 | foreach (ParameterDefn parm in ParameterDefinitions) | ||
1088 | { | ||
1089 | if (pName == parm.name.ToLower()) | ||
1090 | { | ||
1091 | foundDefn = parm; | ||
1092 | ret = true; | ||
1093 | break; | ||
1094 | } | ||
1095 | } | ||
1096 | defn = foundDefn; | ||
1097 | return ret; | ||
1098 | } | ||
1099 | |||
1100 | // Pass through the settable parameters and set the default values | ||
1101 | private void SetParameterDefaultValues() | ||
1102 | { | ||
1103 | foreach (ParameterDefn parm in ParameterDefinitions) | ||
1104 | { | ||
1105 | parm.setter(this, parm.name, PhysParameterEntry.APPLY_TO_NONE, parm.defaultValue); | ||
1106 | } | ||
1107 | } | ||
1108 | |||
1109 | // Get user set values out of the ini file. | ||
1110 | private void SetParameterConfigurationValues(IConfig cfg) | ||
1111 | { | ||
1112 | foreach (ParameterDefn parm in ParameterDefinitions) | ||
1113 | { | ||
1114 | parm.userParam(this, cfg, parm.name, parm.defaultValue); | ||
1115 | } | ||
1116 | } | ||
1117 | |||
1118 | private PhysParameterEntry[] SettableParameters = new PhysParameterEntry[1]; | ||
1119 | |||
1120 | private void BuildParameterTable() | ||
1121 | { | ||
1122 | if (SettableParameters.Length < ParameterDefinitions.Length) | ||
1123 | { | ||
1124 | |||
1125 | List<PhysParameterEntry> entries = new List<PhysParameterEntry>(); | ||
1126 | for (int ii = 0; ii < ParameterDefinitions.Length; ii++) | ||
1127 | { | ||
1128 | ParameterDefn pd = ParameterDefinitions[ii]; | ||
1129 | entries.Add(new PhysParameterEntry(pd.name, pd.desc)); | ||
1130 | } | ||
1131 | |||
1132 | // make the list in alphabetical order for estetic reasons | ||
1133 | entries.Sort(delegate(PhysParameterEntry ppe1, PhysParameterEntry ppe2) | ||
1134 | { | ||
1135 | return ppe1.name.CompareTo(ppe2.name); | ||
1136 | }); | ||
1137 | |||
1138 | SettableParameters = entries.ToArray(); | ||
1139 | } | ||
1140 | } | ||
1141 | |||
1142 | |||
907 | #region IPhysicsParameters | 1143 | #region IPhysicsParameters |
908 | // Get the list of parameters this physics engine supports | 1144 | // Get the list of parameters this physics engine supports |
909 | public PhysParameterEntry[] GetParameterList() | 1145 | public PhysParameterEntry[] GetParameterList() |
910 | { | 1146 | { |
1147 | BuildParameterTable(); | ||
911 | return SettableParameters; | 1148 | return SettableParameters; |
912 | } | 1149 | } |
913 | 1150 | ||
@@ -919,63 +1156,18 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
919 | // value activated ('terrainFriction' for instance). | 1156 | // value activated ('terrainFriction' for instance). |
920 | public bool SetPhysicsParameter(string parm, float val, uint localID) | 1157 | public bool SetPhysicsParameter(string parm, float val, uint localID) |
921 | { | 1158 | { |
922 | bool ret = true; | 1159 | bool ret = false; |
923 | string lparm = parm.ToLower(); | 1160 | ParameterDefn theParam; |
924 | switch (lparm) | 1161 | if (TryGetParameter(parm, out theParam)) |
925 | { | 1162 | { |
926 | case "detailedstats": m_detailedStatsStep = (int)val; break; | 1163 | theParam.setter(this, parm, localID, val); |
927 | 1164 | ret = true; | |
928 | case "meshlod": m_meshLOD = (int)val; break; | ||
929 | case "sculptlod": m_sculptLOD = (int)val; break; | ||
930 | case "maxsubstep": m_maxSubSteps = (int)val; break; | ||
931 | case "fixedtimestep": m_fixedTimeStep = val; break; | ||
932 | case "maxobjectmass": m_maximumObjectMass = val; break; | ||
933 | |||
934 | case "defaultfriction": m_params[0].defaultFriction = val; break; | ||
935 | case "defaultdensity": m_params[0].defaultDensity = val; break; | ||
936 | case "defaultrestitution": m_params[0].defaultRestitution = val; break; | ||
937 | case "collisionmargin": m_params[0].collisionMargin = val; break; | ||
938 | case "gravity": m_params[0].gravity = val; TaintedUpdateParameter(lparm, localID, val); break; | ||
939 | |||
940 | case "lineardamping": UpdateParameterPrims(ref m_params[0].linearDamping, lparm, localID, val); break; | ||
941 | case "angulardamping": UpdateParameterPrims(ref m_params[0].angularDamping, lparm, localID, val); break; | ||
942 | case "deactivationtime": UpdateParameterPrims(ref m_params[0].deactivationTime, lparm, localID, val); break; | ||
943 | case "linearsleepingthreshold": UpdateParameterPrims(ref m_params[0].linearSleepingThreshold, lparm, localID, val); break; | ||
944 | case "angularsleepingthreshold": UpdateParameterPrims(ref m_params[0].angularDamping, lparm, localID, val); break; | ||
945 | case "ccdmotionthreshold": UpdateParameterPrims(ref m_params[0].ccdMotionThreshold, lparm, localID, val); break; | ||
946 | case "ccdsweptsphereradius": UpdateParameterPrims(ref m_params[0].ccdSweptSphereRadius, lparm, localID, val); break; | ||
947 | case "contactprocessingthreshold": UpdateParameterPrims(ref m_params[0].contactProcessingThreshold, lparm, localID, val); break; | ||
948 | // the following are used only at initialization time so setting them makes no sense | ||
949 | // case "maxPersistantmanifoldpoolSize": m_params[0].maxPersistantManifoldPoolSize = val; break; | ||
950 | // case "shoulddisablecontactpooldynamicallocation": m_params[0].shouldDisableContactPoolDynamicAllocation = val; break; | ||
951 | // case "shouldforceupdateallaabbs": m_params[0].shouldForceUpdateAllAabbs = val; break; | ||
952 | // case "shouldrandomizesolverorder": m_params[0].shouldRandomizeSolverOrder = val; break; | ||
953 | // case "shouldsplitsimulationislands": m_params[0].shouldSplitSimulationIslands = val; break; | ||
954 | // case "shouldenablefrictioncaching": m_params[0].shouldEnableFrictionCaching = val; break; | ||
955 | // case "numberofsolveriterations": m_params[0].numberOfSolverIterations = val; break; | ||
956 | |||
957 | case "friction": TaintedUpdateParameter(lparm, localID, val); break; | ||
958 | case "restitution": TaintedUpdateParameter(lparm, localID, val); break; | ||
959 | |||
960 | // set a terrain physical feature and cause terrain to be recalculated | ||
961 | case "terrainfriction": m_params[0].terrainFriction = val; TaintedUpdateParameter("terrain", 0, val); break; | ||
962 | case "terrainhitfraction": m_params[0].terrainHitFraction = val; TaintedUpdateParameter("terrain", 0, val); break; | ||
963 | case "terrainrestitution": m_params[0].terrainRestitution = val; TaintedUpdateParameter("terrain", 0, val); break; | ||
964 | // set an avatar physical feature and cause avatar(s) to be recalculated | ||
965 | case "avatarfriction": UpdateParameterAvatars(ref m_params[0].avatarFriction, "avatar", localID, val); break; | ||
966 | case "avatardensity": UpdateParameterAvatars(ref m_params[0].avatarDensity, "avatar", localID, val); break; | ||
967 | case "avatarrestitution": UpdateParameterAvatars(ref m_params[0].avatarRestitution, "avatar", localID, val); break; | ||
968 | case "avatarcapsuleradius": UpdateParameterAvatars(ref m_params[0].avatarCapsuleRadius, "avatar", localID, val); break; | ||
969 | case "avatarcapsuleheight": UpdateParameterAvatars(ref m_params[0].avatarCapsuleHeight, "avatar", localID, val); break; | ||
970 | case "avatarcontactprocessingthreshold": UpdateParameterAvatars(ref m_params[0].avatarContactProcessingThreshold, "avatar", localID, val); break; | ||
971 | |||
972 | default: ret = false; break; | ||
973 | } | 1165 | } |
974 | return ret; | 1166 | return ret; |
975 | } | 1167 | } |
976 | 1168 | ||
977 | // check to see if we are updating a parameter for a particular or all of the prims | 1169 | // check to see if we are updating a parameter for a particular or all of the prims |
978 | private void UpdateParameterPrims(ref float loc, string parm, uint localID, float val) | 1170 | protected void UpdateParameterPrims(ref float loc, string parm, uint localID, float val) |
979 | { | 1171 | { |
980 | List<uint> operateOn; | 1172 | List<uint> operateOn; |
981 | lock (m_prims) operateOn = new List<uint>(m_prims.Keys); | 1173 | lock (m_prims) operateOn = new List<uint>(m_prims.Keys); |
@@ -983,7 +1175,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
983 | } | 1175 | } |
984 | 1176 | ||
985 | // check to see if we are updating a parameter for a particular or all of the avatars | 1177 | // check to see if we are updating a parameter for a particular or all of the avatars |
986 | private void UpdateParameterAvatars(ref float loc, string parm, uint localID, float val) | 1178 | protected void UpdateParameterAvatars(ref float loc, string parm, uint localID, float val) |
987 | { | 1179 | { |
988 | List<uint> operateOn; | 1180 | List<uint> operateOn; |
989 | lock (m_avatars) operateOn = new List<uint>(m_avatars.Keys); | 1181 | lock (m_avatars) operateOn = new List<uint>(m_avatars.Keys); |
@@ -994,7 +1186,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
994 | // If the local ID is APPLY_TO_NONE, just change the default value | 1186 | // If the local ID is APPLY_TO_NONE, just change the default value |
995 | // If the localID is APPLY_TO_ALL change the default value and apply the new value to all the lIDs | 1187 | // If the localID is APPLY_TO_ALL change the default value and apply the new value to all the lIDs |
996 | // If the localID is a specific object, apply the parameter change to only that object | 1188 | // If the localID is a specific object, apply the parameter change to only that object |
997 | private void UpdateParameterSet(List<uint> lIDs, ref float defaultLoc, string parm, uint localID, float val) | 1189 | protected void UpdateParameterSet(List<uint> lIDs, ref float defaultLoc, string parm, uint localID, float val) |
998 | { | 1190 | { |
999 | switch (localID) | 1191 | switch (localID) |
1000 | { | 1192 | { |
@@ -1021,7 +1213,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
1021 | } | 1213 | } |
1022 | 1214 | ||
1023 | // schedule the actual updating of the paramter to when the phys engine is not busy | 1215 | // schedule the actual updating of the paramter to when the phys engine is not busy |
1024 | private void TaintedUpdateParameter(string parm, uint localID, float val) | 1216 | protected void TaintedUpdateParameter(string parm, uint localID, float val) |
1025 | { | 1217 | { |
1026 | uint xlocalID = localID; | 1218 | uint xlocalID = localID; |
1027 | string xparm = parm.ToLower(); | 1219 | string xparm = parm.ToLower(); |
@@ -1036,50 +1228,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
1036 | public bool GetPhysicsParameter(string parm, out float value) | 1228 | public bool GetPhysicsParameter(string parm, out float value) |
1037 | { | 1229 | { |
1038 | float val = 0f; | 1230 | float val = 0f; |
1039 | bool ret = true; | 1231 | bool ret = false; |
1040 | switch (parm.ToLower()) | 1232 | ParameterDefn theParam; |
1233 | if (TryGetParameter(parm, out theParam)) | ||
1041 | { | 1234 | { |
1042 | case "detailedstats": val = (int)m_detailedStatsStep; break; | 1235 | val = theParam.getter(this); |
1043 | case "meshlod": val = (float)m_meshLOD; break; | 1236 | ret = true; |
1044 | case "sculptlod": val = (float)m_sculptLOD; break; | ||
1045 | case "maxsubstep": val = (float)m_maxSubSteps; break; | ||
1046 | case "fixedtimestep": val = m_fixedTimeStep; break; | ||
1047 | case "maxobjectmass": val = m_maximumObjectMass; break; | ||
1048 | |||
1049 | case "defaultfriction": val = m_params[0].defaultFriction; break; | ||
1050 | case "defaultdensity": val = m_params[0].defaultDensity; break; | ||
1051 | case "defaultrestitution": val = m_params[0].defaultRestitution; break; | ||
1052 | case "collisionmargin": val = m_params[0].collisionMargin; break; | ||
1053 | case "gravity": val = m_params[0].gravity; break; | ||
1054 | |||
1055 | case "lineardamping": val = m_params[0].linearDamping; break; | ||
1056 | case "angulardamping": val = m_params[0].angularDamping; break; | ||
1057 | case "deactivationtime": val = m_params[0].deactivationTime; break; | ||
1058 | case "linearsleepingthreshold": val = m_params[0].linearSleepingThreshold; break; | ||
1059 | case "angularsleepingthreshold": val = m_params[0].angularDamping; break; | ||
1060 | case "ccdmotionthreshold": val = m_params[0].ccdMotionThreshold; break; | ||
1061 | case "ccdsweptsphereradius": val = m_params[0].ccdSweptSphereRadius; break; | ||
1062 | case "contactprocessingthreshold": val = m_params[0].contactProcessingThreshold; break; | ||
1063 | case "maxPersistantmanifoldpoolSize": val = m_params[0].maxPersistantManifoldPoolSize; break; | ||
1064 | case "shoulddisablecontactpooldynamicallocation": val = m_params[0].shouldDisableContactPoolDynamicAllocation; break; | ||
1065 | case "shouldforceupdateallaabbs": val = m_params[0].shouldForceUpdateAllAabbs; break; | ||
1066 | case "shouldrandomizesolverorder": val = m_params[0].shouldRandomizeSolverOrder; break; | ||
1067 | case "shouldsplitsimulationislands": val = m_params[0].shouldSplitSimulationIslands; break; | ||
1068 | case "shouldenablefrictioncaching": val = m_params[0].shouldEnableFrictionCaching; break; | ||
1069 | case "numberofsolveriterations": val = m_params[0].numberOfSolverIterations; break; | ||
1070 | |||
1071 | case "terrainfriction": val = m_params[0].terrainFriction; break; | ||
1072 | case "terrainhitfraction": val = m_params[0].terrainHitFraction; break; | ||
1073 | case "terrainrestitution": val = m_params[0].terrainRestitution; break; | ||
1074 | |||
1075 | case "avatarfriction": val = m_params[0].avatarFriction; break; | ||
1076 | case "avatardensity": val = m_params[0].avatarDensity; break; | ||
1077 | case "avatarrestitution": val = m_params[0].avatarRestitution; break; | ||
1078 | case "avatarcapsuleradius": val = m_params[0].avatarCapsuleRadius; break; | ||
1079 | case "avatarcapsuleheight": val = m_params[0].avatarCapsuleHeight; break; | ||
1080 | case "avatarcontactprocessingthreshold": val = m_params[0].avatarContactProcessingThreshold; break; | ||
1081 | default: ret = false; break; | ||
1082 | |||
1083 | } | 1237 | } |
1084 | value = val; | 1238 | value = val; |
1085 | return ret; | 1239 | return ret; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index 54a8cfd..65e3145 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs | |||
@@ -32,6 +32,28 @@ using OpenMetaverse; | |||
32 | 32 | ||
33 | namespace OpenSim.Region.Physics.BulletSPlugin { | 33 | namespace OpenSim.Region.Physics.BulletSPlugin { |
34 | 34 | ||
35 | // Classes to allow some type checking for the API | ||
36 | public struct BulletSim | ||
37 | { | ||
38 | public BulletSim(uint id, IntPtr xx) { ID = id; Ptr = xx; } | ||
39 | public IntPtr Ptr; | ||
40 | public uint ID; | ||
41 | } | ||
42 | |||
43 | public struct BulletBody | ||
44 | { | ||
45 | public BulletBody(uint id, IntPtr xx) { ID = id; Ptr = xx; } | ||
46 | public IntPtr Ptr; | ||
47 | public uint ID; | ||
48 | } | ||
49 | |||
50 | public struct BulletConstraint | ||
51 | { | ||
52 | public BulletConstraint(IntPtr xx) { Ptr = xx; } | ||
53 | public IntPtr Ptr; | ||
54 | } | ||
55 | |||
56 | // =============================================================================== | ||
35 | [StructLayout(LayoutKind.Sequential)] | 57 | [StructLayout(LayoutKind.Sequential)] |
36 | public struct ConvexHull | 58 | public struct ConvexHull |
37 | { | 59 | { |
@@ -142,6 +164,11 @@ public struct ConfigurationParameters | |||
142 | public float shouldEnableFrictionCaching; | 164 | public float shouldEnableFrictionCaching; |
143 | public float numberOfSolverIterations; | 165 | public float numberOfSolverIterations; |
144 | 166 | ||
167 | public float linkConstraintUseFrameOffset; | ||
168 | public float linkConstraintEnableTransMotor; | ||
169 | public float linkConstraintTransMotorMaxVel; | ||
170 | public float linkConstraintTransMotorMaxForce; | ||
171 | |||
145 | public const float numericTrue = 1f; | 172 | public const float numericTrue = 1f; |
146 | public const float numericFalse = 0f; | 173 | public const float numericFalse = 0f; |
147 | } | 174 | } |
@@ -162,6 +189,7 @@ public enum CollisionFlags : uint | |||
162 | PHYSICAL_OBJECT = 1 << 12, | 189 | PHYSICAL_OBJECT = 1 << 12, |
163 | }; | 190 | }; |
164 | 191 | ||
192 | // =============================================================================== | ||
165 | static class BulletSimAPI { | 193 | static class BulletSimAPI { |
166 | 194 | ||
167 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 195 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
@@ -211,6 +239,7 @@ public static extern bool DestroyMesh(uint worldID, System.UInt64 meshKey); | |||
211 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 239 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
212 | public static extern bool CreateObject(uint worldID, ShapeData shapeData); | 240 | public static extern bool CreateObject(uint worldID, ShapeData shapeData); |
213 | 241 | ||
242 | /* Remove old functionality | ||
214 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 243 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
215 | public static extern void CreateLinkset(uint worldID, int objectCount, ShapeData[] shapeDatas); | 244 | public static extern void CreateLinkset(uint worldID, int objectCount, ShapeData[] shapeDatas); |
216 | 245 | ||
@@ -225,6 +254,7 @@ public static extern bool RemoveConstraintByID(uint worldID, uint id1); | |||
225 | 254 | ||
226 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 255 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
227 | public static extern bool RemoveConstraint(uint worldID, uint id1, uint id2); | 256 | public static extern bool RemoveConstraint(uint worldID, uint id1, uint id2); |
257 | */ | ||
228 | 258 | ||
229 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 259 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
230 | public static extern Vector3 GetObjectPosition(uint WorldID, uint id); | 260 | public static extern Vector3 GetObjectPosition(uint WorldID, uint id); |
@@ -350,8 +380,22 @@ public static extern IntPtr CreateObject2(IntPtr sim, ShapeData shapeData); | |||
350 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 380 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
351 | public static extern IntPtr CreateConstraint2(IntPtr sim, IntPtr obj1, IntPtr obj2, | 381 | public static extern IntPtr CreateConstraint2(IntPtr sim, IntPtr obj1, IntPtr obj2, |
352 | Vector3 frame1loc, Quaternion frame1rot, | 382 | Vector3 frame1loc, Quaternion frame1rot, |
353 | Vector3 frame2loc, Quaternion frame2rot, | 383 | Vector3 frame2loc, Quaternion frame2rot); |
354 | Vector3 lowLinear, Vector3 hiLinear, Vector3 lowAngular, Vector3 hiAngular); | 384 | |
385 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
386 | public static extern bool SetLinearLimits2(IntPtr constrain, Vector3 low, Vector3 hi); | ||
387 | |||
388 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
389 | public static extern bool SetAngularLimits2(IntPtr constrain, Vector3 low, Vector3 hi); | ||
390 | |||
391 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
392 | public static extern bool UseFrameOffset2(IntPtr constrain, float enable); | ||
393 | |||
394 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
395 | public static extern bool TranslationalLimitMotor2(IntPtr constrain, float enable, float targetVel, float maxMotorForce); | ||
396 | |||
397 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
398 | public static extern bool CalculateTransforms2(IntPtr constrain); | ||
355 | 399 | ||
356 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 400 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
357 | public static extern bool DestroyConstraint2(IntPtr sim, IntPtr constrain); | 401 | public static extern bool DestroyConstraint2(IntPtr sim, IntPtr constrain); |
diff --git a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs index 32e81e2..929b019 100644 --- a/OpenSim/Region/Physics/OdePlugin/OdeScene.cs +++ b/OpenSim/Region/Physics/OdePlugin/OdeScene.cs | |||
@@ -290,7 +290,6 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
290 | 290 | ||
291 | private readonly IntPtr contactgroup; | 291 | private readonly IntPtr contactgroup; |
292 | 292 | ||
293 | internal IntPtr LandGeom; | ||
294 | internal IntPtr WaterGeom; | 293 | internal IntPtr WaterGeom; |
295 | 294 | ||
296 | private float nmTerrainContactFriction = 255.0f; | 295 | private float nmTerrainContactFriction = 255.0f; |
@@ -489,6 +488,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
489 | /// </summary> | 488 | /// </summary> |
490 | internal Object OdeLock = new Object(); | 489 | internal Object OdeLock = new Object(); |
491 | 490 | ||
491 | private bool _worldInitialized = false; | ||
492 | |||
492 | public IMesher mesher; | 493 | public IMesher mesher; |
493 | 494 | ||
494 | private IConfigSource m_config; | 495 | private IConfigSource m_config; |
@@ -875,6 +876,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
875 | staticPrimspace[i, j] = IntPtr.Zero; | 876 | staticPrimspace[i, j] = IntPtr.Zero; |
876 | } | 877 | } |
877 | } | 878 | } |
879 | |||
880 | _worldInitialized = true; | ||
878 | } | 881 | } |
879 | 882 | ||
880 | // internal void waitForSpaceUnlock(IntPtr space) | 883 | // internal void waitForSpaceUnlock(IntPtr space) |
@@ -1508,8 +1511,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1508 | { | 1511 | { |
1509 | if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) | 1512 | if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) |
1510 | && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) | 1513 | && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) |
1511 | && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) | 1514 | && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f))) |
1512 | && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom) | ||
1513 | { | 1515 | { |
1514 | if (Math.Abs(contact.depth - contactGeom.depth) < 0.052f) | 1516 | if (Math.Abs(contact.depth - contactGeom.depth) < 0.052f) |
1515 | { | 1517 | { |
@@ -1538,7 +1540,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1538 | //d.GeomGetAABB(contactGeom.g2, out aabb2); | 1540 | //d.GeomGetAABB(contactGeom.g2, out aabb2); |
1539 | //d.GeomGetAABB(contactGeom.g1, out aabb1); | 1541 | //d.GeomGetAABB(contactGeom.g1, out aabb1); |
1540 | //aabb1. | 1542 | //aabb1. |
1541 | if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f)) && contactGeom.g1 != LandGeom && contactGeom.g2 != LandGeom) | 1543 | if (((Math.Abs(contactGeom.normal.X - contact.normal.X) < 1.026f) && (Math.Abs(contactGeom.normal.Y - contact.normal.Y) < 0.303f) && (Math.Abs(contactGeom.normal.Z - contact.normal.Z) < 0.065f))) |
1542 | { | 1544 | { |
1543 | if (contactGeom.normal.X == contact.normal.X && contactGeom.normal.Y == contact.normal.Y && contactGeom.normal.Z == contact.normal.Z) | 1545 | if (contactGeom.normal.X == contact.normal.X && contactGeom.normal.Y == contact.normal.Y && contactGeom.normal.Z == contact.normal.Z) |
1544 | { | 1546 | { |
@@ -2896,6 +2898,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
2896 | /// <returns>The number of frames simulated over that period.</returns> | 2898 | /// <returns>The number of frames simulated over that period.</returns> |
2897 | public override float Simulate(float timeStep) | 2899 | public override float Simulate(float timeStep) |
2898 | { | 2900 | { |
2901 | if (!_worldInitialized) return 11f; | ||
2902 | |||
2899 | int startFrameTick = CollectStats ? Util.EnvironmentTickCount() : 0; | 2903 | int startFrameTick = CollectStats ? Util.EnvironmentTickCount() : 0; |
2900 | int tempTick = 0, tempTick2 = 0; | 2904 | int tempTick = 0, tempTick2 = 0; |
2901 | 2905 | ||
@@ -4017,6 +4021,8 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
4017 | 4021 | ||
4018 | public override void Dispose() | 4022 | public override void Dispose() |
4019 | { | 4023 | { |
4024 | _worldInitialized = false; | ||
4025 | |||
4020 | m_rayCastManager.Dispose(); | 4026 | m_rayCastManager.Dispose(); |
4021 | m_rayCastManager = null; | 4027 | m_rayCastManager = null; |
4022 | 4028 | ||
@@ -4037,6 +4043,7 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
4037 | d.WorldDestroy(world); | 4043 | d.WorldDestroy(world); |
4038 | //d.CloseODE(); | 4044 | //d.CloseODE(); |
4039 | } | 4045 | } |
4046 | |||
4040 | } | 4047 | } |
4041 | 4048 | ||
4042 | public override Dictionary<uint, float> GetTopColliders() | 4049 | public override Dictionary<uint, float> GetTopColliders() |
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 204c4ff..3144d76 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs | |||
@@ -99,6 +99,8 @@ namespace OpenSim.Region.RegionCombinerModule | |||
99 | 99 | ||
100 | public void RemoveRegion(Scene scene) | 100 | public void RemoveRegion(Scene scene) |
101 | { | 101 | { |
102 | lock (m_startingScenes) | ||
103 | m_startingScenes.Remove(scene.RegionInfo.originRegionID); | ||
102 | } | 104 | } |
103 | 105 | ||
104 | public void RegionLoaded(Scene scene) | 106 | public void RegionLoaded(Scene scene) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs index 693992a..94fd940 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/AsyncCommandManager.cs | |||
@@ -31,6 +31,7 @@ using System.Collections.Generic; | |||
31 | using System.Threading; | 31 | using System.Threading; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Monitoring; | ||
34 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Region.ScriptEngine.Interfaces; | 36 | using OpenSim.Region.ScriptEngine.Interfaces; |
36 | using OpenSim.Region.ScriptEngine.Shared; | 37 | using OpenSim.Region.ScriptEngine.Shared; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index bf77dc5..1181c10 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -3290,8 +3290,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3290 | ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Unable to attach, item '{0}' is not an object.", itemName)); | 3290 | ((LSL_Api)m_LSL_Api).llSay(0, string.Format("Unable to attach, item '{0}' is not an object.", itemName)); |
3291 | 3291 | ||
3292 | throw new Exception(String.Format("The inventory item '{0}' is not an object", itemName)); | 3292 | throw new Exception(String.Format("The inventory item '{0}' is not an object", itemName)); |
3293 | |||
3294 | return; | ||
3295 | } | 3293 | } |
3296 | 3294 | ||
3297 | ScenePresence sp = World.GetScenePresence(avatarId); | 3295 | ScenePresence sp = World.GetScenePresence(avatarId); |
@@ -3336,5 +3334,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3336 | UUID test; | 3334 | UUID test; |
3337 | return UUID.TryParse(thing, out test) ? 1 : 0; | 3335 | return UUID.TryParse(thing, out test) ? 1 : 0; |
3338 | } | 3336 | } |
3337 | |||
3338 | /// <summary> | ||
3339 | /// Wraps to Math.Min() | ||
3340 | /// </summary> | ||
3341 | /// <param name="a"></param> | ||
3342 | /// <param name="b"></param> | ||
3343 | /// <returns></returns> | ||
3344 | public LSL_Float osMin(double a, double b) | ||
3345 | { | ||
3346 | CheckThreatLevel(ThreatLevel.None, "osMin"); | ||
3347 | m_host.AddScriptLPS(1); | ||
3348 | |||
3349 | return Math.Min(a, b); | ||
3350 | } | ||
3351 | |||
3352 | /// <summary> | ||
3353 | /// Wraps to Math.max() | ||
3354 | /// </summary> | ||
3355 | /// <param name="a"></param> | ||
3356 | /// <param name="b"></param> | ||
3357 | /// <returns></returns> | ||
3358 | public LSL_Float osMax(double a, double b) | ||
3359 | { | ||
3360 | CheckThreatLevel(ThreatLevel.None, "osMax"); | ||
3361 | m_host.AddScriptLPS(1); | ||
3362 | |||
3363 | return Math.Max(a, b); | ||
3364 | } | ||
3339 | } | 3365 | } |
3340 | } | 3366 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 24bdf0c..aba66d3 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -283,5 +283,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
283 | /// <param name="thing"></param> | 283 | /// <param name="thing"></param> |
284 | /// <returns>1 if thing is a valid UUID, 0 otherwise</returns> | 284 | /// <returns>1 if thing is a valid UUID, 0 otherwise</returns> |
285 | LSL_Integer osIsUUID(string thing); | 285 | LSL_Integer osIsUUID(string thing); |
286 | |||
287 | /// <summary> | ||
288 | /// Wraps to Math.Min() | ||
289 | /// </summary> | ||
290 | /// <param name="a"></param> | ||
291 | /// <param name="b"></param> | ||
292 | /// <returns></returns> | ||
293 | LSL_Float osMin(double a, double b); | ||
294 | |||
295 | /// <summary> | ||
296 | /// Wraps to Math.max() | ||
297 | /// </summary> | ||
298 | /// <param name="a"></param> | ||
299 | /// <param name="b"></param> | ||
300 | /// <returns></returns> | ||
301 | LSL_Float osMax(double a, double b); | ||
286 | } | 302 | } |
287 | } | 303 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index 99995a7..53daa13 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -935,5 +935,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
935 | { | 935 | { |
936 | return m_OSSL_Functions.osIsUUID(thing); | 936 | return m_OSSL_Functions.osIsUUID(thing); |
937 | } | 937 | } |
938 | |||
939 | public LSL_Float osMin(double a, double b) | ||
940 | { | ||
941 | return m_OSSL_Functions.osMin(a, b); | ||
942 | } | ||
943 | |||
944 | public LSL_Float osMax(double a, double b) | ||
945 | { | ||
946 | return m_OSSL_Functions.osMax(a, b); | ||
947 | } | ||
938 | } | 948 | } |
939 | } | 949 | } |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 79a6e09..f6cb7df 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | |||
@@ -719,7 +719,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine | |||
719 | 719 | ||
720 | // If region ready has been triggered, then the region had no scripts to compile and completed its other | 720 | // If region ready has been triggered, then the region had no scripts to compile and completed its other |
721 | // work. | 721 | // work. |
722 | m_Scene.EventManager.OnRegionReady += s => m_InitialStartup = false; | 722 | m_Scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) m_InitialStartup = false; }; |
723 | 723 | ||
724 | if (m_SleepTime > 0) | 724 | if (m_SleepTime > 0) |
725 | { | 725 | { |
diff --git a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs index dcbd717..3243a9a 100644 --- a/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs +++ b/OpenSim/Region/UserStatistics/ActiveConnectionsAJAX.cs | |||
@@ -34,7 +34,7 @@ using Mono.Data.SqliteClient; | |||
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Framework.Statistics; | 37 | using OpenSim.Framework.Monitoring; |
38 | 38 | ||
39 | namespace OpenSim.Region.UserStatistics | 39 | namespace OpenSim.Region.UserStatistics |
40 | { | 40 | { |
diff --git a/OpenSim/Region/UserStatistics/Default_Report.cs b/OpenSim/Region/UserStatistics/Default_Report.cs index 0e17630..cdc615c 100644 --- a/OpenSim/Region/UserStatistics/Default_Report.cs +++ b/OpenSim/Region/UserStatistics/Default_Report.cs | |||
@@ -33,7 +33,7 @@ using System.Text; | |||
33 | using Mono.Data.SqliteClient; | 33 | using Mono.Data.SqliteClient; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Framework.Statistics; | 36 | using OpenSim.Framework.Monitoring; |
37 | 37 | ||
38 | 38 | ||
39 | namespace OpenSim.Region.UserStatistics | 39 | namespace OpenSim.Region.UserStatistics |
diff --git a/OpenSim/Region/UserStatistics/LogLinesAJAX.cs b/OpenSim/Region/UserStatistics/LogLinesAJAX.cs index 811baba..74de46b 100644 --- a/OpenSim/Region/UserStatistics/LogLinesAJAX.cs +++ b/OpenSim/Region/UserStatistics/LogLinesAJAX.cs | |||
@@ -34,7 +34,7 @@ using System.Text.RegularExpressions; | |||
34 | using Mono.Data.SqliteClient; | 34 | using Mono.Data.SqliteClient; |
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Framework.Statistics; | 37 | using OpenSim.Framework.Monitoring; |
38 | 38 | ||
39 | namespace OpenSim.Region.UserStatistics | 39 | namespace OpenSim.Region.UserStatistics |
40 | { | 40 | { |
diff --git a/OpenSim/Region/UserStatistics/SimStatsAJAX.cs b/OpenSim/Region/UserStatistics/SimStatsAJAX.cs index 8c04e71..28051fb 100644 --- a/OpenSim/Region/UserStatistics/SimStatsAJAX.cs +++ b/OpenSim/Region/UserStatistics/SimStatsAJAX.cs | |||
@@ -33,7 +33,7 @@ using System.Text; | |||
33 | using Mono.Data.SqliteClient; | 33 | using Mono.Data.SqliteClient; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Framework.Statistics; | 36 | using OpenSim.Framework.Monitoring; |
37 | 37 | ||
38 | namespace OpenSim.Region.UserStatistics | 38 | namespace OpenSim.Region.UserStatistics |
39 | { | 39 | { |