diff options
author | BlueWall | 2012-11-25 17:03:14 -0500 |
---|---|---|
committer | BlueWall | 2012-11-25 17:03:14 -0500 |
commit | c754003944d0166bf50b4f94b0c0eea642503bb0 (patch) | |
tree | dfa1c2020d5500d510519d5b2b3236600692f277 /OpenSim/Region | |
parent | Merge branch 'master' into connector_plugin (diff) | |
parent | Combine TestDeleteSceneObjectAsync() with TestDeRezSceneObject() as they are ... (diff) | |
download | opensim-SC_OLD-c754003944d0166bf50b4f94b0c0eea642503bb0.zip opensim-SC_OLD-c754003944d0166bf50b4f94b0c0eea642503bb0.tar.gz opensim-SC_OLD-c754003944d0166bf50b4f94b0c0eea642503bb0.tar.bz2 opensim-SC_OLD-c754003944d0166bf50b4f94b0c0eea642503bb0.tar.xz |
Merge branch 'master' into connector_plugin
Conflicts:
OpenSim/Server/Base/ServicesServerBase.cs
Diffstat (limited to 'OpenSim/Region')
297 files changed, 9107 insertions, 6507 deletions
diff --git a/OpenSim/Region/Application/ConfigurationLoader.cs b/OpenSim/Region/Application/ConfigurationLoader.cs index 8d95c41..fc3999f 100644 --- a/OpenSim/Region/Application/ConfigurationLoader.cs +++ b/OpenSim/Region/Application/ConfigurationLoader.cs | |||
@@ -188,7 +188,6 @@ namespace OpenSim | |||
188 | // Make sure command line options take precedence | 188 | // Make sure command line options take precedence |
189 | m_config.Source.Merge(argvSource); | 189 | m_config.Source.Merge(argvSource); |
190 | 190 | ||
191 | |||
192 | IConfig enVars = m_config.Source.Configs["Environment"]; | 191 | IConfig enVars = m_config.Source.Configs["Environment"]; |
193 | 192 | ||
194 | if( enVars != null ) | 193 | if( enVars != null ) |
diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index b24641a..cffbb3b 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs | |||
@@ -82,8 +82,8 @@ namespace OpenSim | |||
82 | { | 82 | { |
83 | base.ReadExtraConfigSettings(); | 83 | base.ReadExtraConfigSettings(); |
84 | 84 | ||
85 | IConfig startupConfig = m_config.Source.Configs["Startup"]; | 85 | IConfig startupConfig = Config.Configs["Startup"]; |
86 | IConfig networkConfig = m_config.Source.Configs["Network"]; | 86 | IConfig networkConfig = Config.Configs["Network"]; |
87 | 87 | ||
88 | int stpMaxThreads = 15; | 88 | int stpMaxThreads = 15; |
89 | 89 | ||
@@ -106,22 +106,6 @@ namespace OpenSim | |||
106 | m_timeInterval = startupConfig.GetInt("timer_Interval", 1200); | 106 | m_timeInterval = startupConfig.GetInt("timer_Interval", 1200); |
107 | } | 107 | } |
108 | 108 | ||
109 | if (m_logFileAppender != null) | ||
110 | { | ||
111 | if (m_logFileAppender is log4net.Appender.FileAppender) | ||
112 | { | ||
113 | log4net.Appender.FileAppender appender = | ||
114 | (log4net.Appender.FileAppender)m_logFileAppender; | ||
115 | string fileName = startupConfig.GetString("LogFile", String.Empty); | ||
116 | if (fileName != String.Empty) | ||
117 | { | ||
118 | appender.File = fileName; | ||
119 | appender.ActivateOptions(); | ||
120 | } | ||
121 | m_log.InfoFormat("[LOGGING]: Logging started to file {0}", appender.File); | ||
122 | } | ||
123 | } | ||
124 | |||
125 | string asyncCallMethodStr = startupConfig.GetString("async_call_method", String.Empty); | 109 | string asyncCallMethodStr = startupConfig.GetString("async_call_method", String.Empty); |
126 | FireAndForgetMethod asyncCallMethod; | 110 | FireAndForgetMethod asyncCallMethod; |
127 | if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse<FireAndForgetMethod>(asyncCallMethodStr, out asyncCallMethod)) | 111 | if (!String.IsNullOrEmpty(asyncCallMethodStr) && Utils.EnumTryParse<FireAndForgetMethod>(asyncCallMethodStr, out asyncCallMethod)) |
@@ -164,7 +148,7 @@ namespace OpenSim | |||
164 | break; | 148 | break; |
165 | case "rest": | 149 | case "rest": |
166 | m_console = new RemoteConsole("Region"); | 150 | m_console = new RemoteConsole("Region"); |
167 | ((RemoteConsole)m_console).ReadConfig(m_config.Source); | 151 | ((RemoteConsole)m_console).ReadConfig(Config); |
168 | break; | 152 | break; |
169 | default: | 153 | default: |
170 | m_console = new LocalConsole("Region"); | 154 | m_console = new LocalConsole("Region"); |
@@ -174,6 +158,7 @@ namespace OpenSim | |||
174 | 158 | ||
175 | MainConsole.Instance = m_console; | 159 | MainConsole.Instance = m_console; |
176 | 160 | ||
161 | RegisterCommonAppenders(Config.Configs["Startup"]); | ||
177 | RegisterConsoleCommands(); | 162 | RegisterConsoleCommands(); |
178 | 163 | ||
179 | base.StartupSpecific(); | 164 | base.StartupSpecific(); |
@@ -372,26 +357,6 @@ namespace OpenSim | |||
372 | "restart", | 357 | "restart", |
373 | "Restart all sims in this instance", RunCommand); | 358 | "Restart all sims in this instance", RunCommand); |
374 | 359 | ||
375 | m_console.Commands.AddCommand("General", false, "config set", | ||
376 | "config set <section> <key> <value>", | ||
377 | "Set a config option. In most cases this is not useful since changed parameters are not dynamically reloaded. Neither do changed parameters persist - you will have to change a config file manually and restart.", HandleConfig); | ||
378 | |||
379 | m_console.Commands.AddCommand("General", false, "config get", | ||
380 | "config get [<section>] [<key>]", | ||
381 | "Synonym for config show", | ||
382 | HandleConfig); | ||
383 | |||
384 | m_console.Commands.AddCommand("General", false, "config show", | ||
385 | "config show [<section>] [<key>]", | ||
386 | "Show config information", | ||
387 | "If neither section nor field are specified, then the whole current configuration is printed." + Environment.NewLine | ||
388 | + "If a section is given but not a field, then all fields in that section are printed.", | ||
389 | HandleConfig); | ||
390 | |||
391 | m_console.Commands.AddCommand("General", false, "config save", | ||
392 | "config save <path>", | ||
393 | "Save current configuration to a file at the given path", HandleConfig); | ||
394 | |||
395 | m_console.Commands.AddCommand("General", false, "command-script", | 360 | m_console.Commands.AddCommand("General", false, "command-script", |
396 | "command-script <script>", | 361 | "command-script <script>", |
397 | "Run a command script from file", RunCommand); | 362 | "Run a command script from file", RunCommand); |
@@ -502,35 +467,6 @@ namespace OpenSim | |||
502 | } | 467 | } |
503 | 468 | ||
504 | /// <summary> | 469 | /// <summary> |
505 | /// Run an optional startup list of commands | ||
506 | /// </summary> | ||
507 | /// <param name="fileName"></param> | ||
508 | private void RunCommandScript(string fileName) | ||
509 | { | ||
510 | if (File.Exists(fileName)) | ||
511 | { | ||
512 | m_log.Info("[COMMANDFILE]: Running " + fileName); | ||
513 | |||
514 | using (StreamReader readFile = File.OpenText(fileName)) | ||
515 | { | ||
516 | string currentCommand; | ||
517 | while ((currentCommand = readFile.ReadLine()) != null) | ||
518 | { | ||
519 | currentCommand = currentCommand.Trim(); | ||
520 | if (!(currentCommand == "" | ||
521 | || currentCommand.StartsWith(";") | ||
522 | || currentCommand.StartsWith("//") | ||
523 | || currentCommand.StartsWith("#"))) | ||
524 | { | ||
525 | m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'"); | ||
526 | m_console.RunCommand(currentCommand); | ||
527 | } | ||
528 | } | ||
529 | } | ||
530 | } | ||
531 | } | ||
532 | |||
533 | /// <summary> | ||
534 | /// Opens a file and uses it as input to the console command parser. | 470 | /// Opens a file and uses it as input to the console command parser. |
535 | /// </summary> | 471 | /// </summary> |
536 | /// <param name="fileName">name of file to use as input to the console</param> | 472 | /// <param name="fileName">name of file to use as input to the console</param> |
@@ -634,111 +570,9 @@ namespace OpenSim | |||
634 | bool changed = PopulateRegionEstateInfo(regInfo); | 570 | bool changed = PopulateRegionEstateInfo(regInfo); |
635 | IScene scene; | 571 | IScene scene; |
636 | CreateRegion(regInfo, true, out scene); | 572 | CreateRegion(regInfo, true, out scene); |
637 | if (changed) | ||
638 | regInfo.EstateSettings.Save(); | ||
639 | } | ||
640 | |||
641 | /// <summary> | ||
642 | /// Change and load configuration file data. | ||
643 | /// </summary> | ||
644 | /// <param name="module"></param> | ||
645 | /// <param name="cmd"></param> | ||
646 | private void HandleConfig(string module, string[] cmd) | ||
647 | { | ||
648 | List<string> args = new List<string>(cmd); | ||
649 | args.RemoveAt(0); | ||
650 | string[] cmdparams = args.ToArray(); | ||
651 | |||
652 | if (cmdparams.Length > 0) | ||
653 | { | ||
654 | string firstParam = cmdparams[0].ToLower(); | ||
655 | |||
656 | switch (firstParam) | ||
657 | { | ||
658 | case "set": | ||
659 | if (cmdparams.Length < 4) | ||
660 | { | ||
661 | Notice("Syntax: config set <section> <key> <value>"); | ||
662 | Notice("Example: config set ScriptEngine.DotNetEngine NumberOfScriptThreads 5"); | ||
663 | } | ||
664 | else | ||
665 | { | ||
666 | IConfig c; | ||
667 | IConfigSource source = new IniConfigSource(); | ||
668 | c = source.AddConfig(cmdparams[1]); | ||
669 | if (c != null) | ||
670 | { | ||
671 | string _value = String.Join(" ", cmdparams, 3, cmdparams.Length - 3); | ||
672 | c.Set(cmdparams[2], _value); | ||
673 | m_config.Source.Merge(source); | ||
674 | |||
675 | Notice("In section [{0}], set {1} = {2}", c.Name, cmdparams[2], _value); | ||
676 | } | ||
677 | } | ||
678 | break; | ||
679 | |||
680 | case "get": | ||
681 | case "show": | ||
682 | if (cmdparams.Length == 1) | ||
683 | { | ||
684 | foreach (IConfig config in m_config.Source.Configs) | ||
685 | { | ||
686 | Notice("[{0}]", config.Name); | ||
687 | string[] keys = config.GetKeys(); | ||
688 | foreach (string key in keys) | ||
689 | Notice(" {0} = {1}", key, config.GetString(key)); | ||
690 | } | ||
691 | } | ||
692 | else if (cmdparams.Length == 2 || cmdparams.Length == 3) | ||
693 | { | ||
694 | IConfig config = m_config.Source.Configs[cmdparams[1]]; | ||
695 | if (config == null) | ||
696 | { | ||
697 | Notice("Section \"{0}\" does not exist.",cmdparams[1]); | ||
698 | break; | ||
699 | } | ||
700 | else | ||
701 | { | ||
702 | if (cmdparams.Length == 2) | ||
703 | { | ||
704 | Notice("[{0}]", config.Name); | ||
705 | foreach (string key in config.GetKeys()) | ||
706 | Notice(" {0} = {1}", key, config.GetString(key)); | ||
707 | } | ||
708 | else | ||
709 | { | ||
710 | Notice( | ||
711 | "config get {0} {1} : {2}", | ||
712 | cmdparams[1], cmdparams[2], config.GetString(cmdparams[2])); | ||
713 | } | ||
714 | } | ||
715 | } | ||
716 | else | ||
717 | { | ||
718 | Notice("Syntax: config {0} [<section>] [<key>]", firstParam); | ||
719 | Notice("Example: config {0} ScriptEngine.DotNetEngine NumberOfScriptThreads", firstParam); | ||
720 | } | ||
721 | |||
722 | break; | ||
723 | |||
724 | case "save": | ||
725 | if (cmdparams.Length < 2) | ||
726 | { | ||
727 | Notice("Syntax: config save <path>"); | ||
728 | return; | ||
729 | } | ||
730 | |||
731 | if (Application.iniFilePath == cmdparams[1]) | ||
732 | { | ||
733 | Notice("Path can not be " + Application.iniFilePath); | ||
734 | return; | ||
735 | } | ||
736 | 573 | ||
737 | Notice("Saving configuration file: " + cmdparams[1]); | 574 | if (changed) |
738 | m_config.Save(cmdparams[1]); | 575 | regInfo.EstateSettings.Save(); |
739 | break; | ||
740 | } | ||
741 | } | ||
742 | } | 576 | } |
743 | 577 | ||
744 | /// <summary> | 578 | /// <summary> |
@@ -757,33 +591,13 @@ namespace OpenSim | |||
757 | switch (cmdparams[0].ToLower()) | 591 | switch (cmdparams[0].ToLower()) |
758 | { | 592 | { |
759 | case "list": | 593 | case "list": |
760 | foreach (IRegionModule irm in m_moduleLoader.GetLoadedSharedModules) | 594 | //TODO: Convert to new region modules |
761 | { | ||
762 | MainConsole.Instance.Output(String.Format("Shared region module: {0}", irm.Name)); | ||
763 | } | ||
764 | break; | 595 | break; |
765 | case "unload": | 596 | case "unload": |
766 | if (cmdparams.Length > 1) | 597 | //TODO: Convert to new region modules |
767 | { | ||
768 | foreach (IRegionModule rm in new ArrayList(m_moduleLoader.GetLoadedSharedModules)) | ||
769 | { | ||
770 | if (rm.Name.ToLower() == cmdparams[1].ToLower()) | ||
771 | { | ||
772 | MainConsole.Instance.Output(String.Format("Unloading module: {0}", rm.Name)); | ||
773 | m_moduleLoader.UnloadModule(rm); | ||
774 | } | ||
775 | } | ||
776 | } | ||
777 | break; | 598 | break; |
778 | case "load": | 599 | case "load": |
779 | if (cmdparams.Length > 1) | 600 | //TODO: Convert to new region modules |
780 | { | ||
781 | foreach (Scene s in new ArrayList(SceneManager.Scenes)) | ||
782 | { | ||
783 | MainConsole.Instance.Output(String.Format("Loading module: {0}", cmdparams[1])); | ||
784 | m_moduleLoader.LoadRegionModules(cmdparams[1], s); | ||
785 | } | ||
786 | } | ||
787 | break; | 601 | break; |
788 | } | 602 | } |
789 | } | 603 | } |
@@ -807,13 +621,6 @@ namespace OpenSim | |||
807 | 621 | ||
808 | switch (command) | 622 | switch (command) |
809 | { | 623 | { |
810 | case "command-script": | ||
811 | if (cmdparams.Length > 0) | ||
812 | { | ||
813 | RunCommandScript(cmdparams[0]); | ||
814 | } | ||
815 | break; | ||
816 | |||
817 | case "backup": | 624 | case "backup": |
818 | MainConsole.Instance.Output("Triggering save of pending object updates to persistent store"); | 625 | MainConsole.Instance.Output("Triggering save of pending object updates to persistent store"); |
819 | SceneManager.BackupCurrentScene(); | 626 | SceneManager.BackupCurrentScene(); |
@@ -857,12 +664,20 @@ namespace OpenSim | |||
857 | 664 | ||
858 | if (!SceneManager.TrySetCurrentScene(newRegionName)) | 665 | if (!SceneManager.TrySetCurrentScene(newRegionName)) |
859 | MainConsole.Instance.Output(String.Format("Couldn't select region {0}", newRegionName)); | 666 | MainConsole.Instance.Output(String.Format("Couldn't select region {0}", newRegionName)); |
667 | else | ||
668 | RefreshPrompt(); | ||
860 | } | 669 | } |
861 | else | 670 | else |
862 | { | 671 | { |
863 | MainConsole.Instance.Output("Usage: change region <region name>"); | 672 | MainConsole.Instance.Output("Usage: change region <region name>"); |
864 | } | 673 | } |
674 | } | ||
865 | 675 | ||
676 | /// <summary> | ||
677 | /// Refreshs prompt with the current selection details. | ||
678 | /// </summary> | ||
679 | private void RefreshPrompt() | ||
680 | { | ||
866 | string regionName = (SceneManager.CurrentScene == null ? "root" : SceneManager.CurrentScene.RegionInfo.RegionName); | 681 | string regionName = (SceneManager.CurrentScene == null ? "root" : SceneManager.CurrentScene.RegionInfo.RegionName); |
867 | MainConsole.Instance.Output(String.Format("Currently selected region is {0}", regionName)); | 682 | MainConsole.Instance.Output(String.Format("Currently selected region is {0}", regionName)); |
868 | 683 | ||
@@ -884,6 +699,18 @@ namespace OpenSim | |||
884 | m_console.ConsoleScene = SceneManager.CurrentScene; | 699 | m_console.ConsoleScene = SceneManager.CurrentScene; |
885 | } | 700 | } |
886 | 701 | ||
702 | protected override void HandleRestartRegion(RegionInfo whichRegion) | ||
703 | { | ||
704 | base.HandleRestartRegion(whichRegion); | ||
705 | |||
706 | // Where we are restarting multiple scenes at once, a previous call to RefreshPrompt may have set the | ||
707 | // m_console.ConsoleScene to null (indicating all scenes). | ||
708 | if (m_console.ConsoleScene != null && whichRegion.RegionName == ((Scene)m_console.ConsoleScene).Name) | ||
709 | SceneManager.TrySetCurrentScene(whichRegion.RegionName); | ||
710 | |||
711 | RefreshPrompt(); | ||
712 | } | ||
713 | |||
887 | /// <summary> | 714 | /// <summary> |
888 | /// Turn on some debugging values for OpenSim. | 715 | /// Turn on some debugging values for OpenSim. |
889 | /// </summary> | 716 | /// </summary> |
@@ -1018,28 +845,9 @@ namespace OpenSim | |||
1018 | break; | 845 | break; |
1019 | 846 | ||
1020 | case "modules": | 847 | case "modules": |
1021 | MainConsole.Instance.Output("The currently loaded shared modules are:"); | ||
1022 | foreach (IRegionModule module in m_moduleLoader.GetLoadedSharedModules) | ||
1023 | { | ||
1024 | MainConsole.Instance.Output("Shared Module: " + module.Name); | ||
1025 | } | ||
1026 | |||
1027 | SceneManager.ForEachScene( | ||
1028 | delegate(Scene scene) { | ||
1029 | m_log.Error("The currently loaded modules in " + scene.RegionInfo.RegionName + " are:"); | ||
1030 | foreach (IRegionModule module in scene.Modules.Values) | ||
1031 | { | ||
1032 | if (!module.IsSharedModule) | ||
1033 | { | ||
1034 | m_log.Error("Region Module: " + module.Name); | ||
1035 | } | ||
1036 | } | ||
1037 | } | ||
1038 | ); | ||
1039 | |||
1040 | SceneManager.ForEachScene( | 848 | SceneManager.ForEachScene( |
1041 | delegate(Scene scene) { | 849 | delegate(Scene scene) { |
1042 | MainConsole.Instance.Output("Loaded new region modules in" + scene.RegionInfo.RegionName + " are:"); | 850 | MainConsole.Instance.Output("Loaded region modules in" + scene.RegionInfo.RegionName + " are:"); |
1043 | foreach (IRegionModuleBase module in scene.RegionModules.Values) | 851 | foreach (IRegionModuleBase module in scene.RegionModules.Values) |
1044 | { | 852 | { |
1045 | Type type = module.GetType().GetInterface("ISharedRegionModule"); | 853 | Type type = module.GetType().GetInterface("ISharedRegionModule"); |
@@ -1111,7 +919,7 @@ namespace OpenSim | |||
1111 | aCircuit.Name, | 919 | aCircuit.Name, |
1112 | aCircuit.child ? "child" : "root", | 920 | aCircuit.child ? "child" : "root", |
1113 | aCircuit.circuitcode.ToString(), | 921 | aCircuit.circuitcode.ToString(), |
1114 | aCircuit.IPAddress.ToString(), | 922 | aCircuit.IPAddress != null ? aCircuit.IPAddress.ToString() : "not set", |
1115 | aCircuit.Viewer); | 923 | aCircuit.Viewer); |
1116 | }); | 924 | }); |
1117 | 925 | ||
diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 4f1b439..c3c87e7 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs | |||
@@ -100,13 +100,7 @@ namespace OpenSim | |||
100 | /// <value> | 100 | /// <value> |
101 | /// The config information passed into the OpenSimulator region server. | 101 | /// The config information passed into the OpenSimulator region server. |
102 | /// </value> | 102 | /// </value> |
103 | public OpenSimConfigSource ConfigSource | 103 | public OpenSimConfigSource ConfigSource { get; private set; } |
104 | { | ||
105 | get { return m_config; } | ||
106 | set { m_config = value; } | ||
107 | } | ||
108 | |||
109 | protected OpenSimConfigSource m_config; | ||
110 | 104 | ||
111 | public List<IClientNetworkServer> ClientServers | 105 | public List<IClientNetworkServer> ClientServers |
112 | { | 106 | { |
@@ -127,14 +121,6 @@ namespace OpenSim | |||
127 | get { return m_httpServerPort; } | 121 | get { return m_httpServerPort; } |
128 | } | 122 | } |
129 | 123 | ||
130 | public ModuleLoader ModuleLoader | ||
131 | { | ||
132 | get { return m_moduleLoader; } | ||
133 | set { m_moduleLoader = value; } | ||
134 | } | ||
135 | |||
136 | protected ModuleLoader m_moduleLoader; | ||
137 | |||
138 | protected IRegistryCore m_applicationRegistry = new RegistryCore(); | 124 | protected IRegistryCore m_applicationRegistry = new RegistryCore(); |
139 | 125 | ||
140 | public IRegistryCore ApplicationRegistry | 126 | public IRegistryCore ApplicationRegistry |
@@ -154,13 +140,14 @@ namespace OpenSim | |||
154 | protected virtual void LoadConfigSettings(IConfigSource configSource) | 140 | protected virtual void LoadConfigSettings(IConfigSource configSource) |
155 | { | 141 | { |
156 | m_configLoader = new ConfigurationLoader(); | 142 | m_configLoader = new ConfigurationLoader(); |
157 | m_config = m_configLoader.LoadConfigSettings(configSource, envConfigSource, out m_configSettings, out m_networkServersInfo); | 143 | ConfigSource = m_configLoader.LoadConfigSettings(configSource, envConfigSource, out m_configSettings, out m_networkServersInfo); |
144 | Config = ConfigSource.Source; | ||
158 | ReadExtraConfigSettings(); | 145 | ReadExtraConfigSettings(); |
159 | } | 146 | } |
160 | 147 | ||
161 | protected virtual void ReadExtraConfigSettings() | 148 | protected virtual void ReadExtraConfigSettings() |
162 | { | 149 | { |
163 | IConfig networkConfig = m_config.Source.Configs["Network"]; | 150 | IConfig networkConfig = Config.Configs["Network"]; |
164 | if (networkConfig != null) | 151 | if (networkConfig != null) |
165 | { | 152 | { |
166 | proxyUrl = networkConfig.GetString("proxy_url", ""); | 153 | proxyUrl = networkConfig.GetString("proxy_url", ""); |
@@ -193,7 +180,7 @@ namespace OpenSim | |||
193 | /// </summary> | 180 | /// </summary> |
194 | protected override void StartupSpecific() | 181 | protected override void StartupSpecific() |
195 | { | 182 | { |
196 | IConfig startupConfig = m_config.Source.Configs["Startup"]; | 183 | IConfig startupConfig = Config.Configs["Startup"]; |
197 | if (startupConfig != null) | 184 | if (startupConfig != null) |
198 | { | 185 | { |
199 | string pidFile = startupConfig.GetString("PIDFile", String.Empty); | 186 | string pidFile = startupConfig.GetString("PIDFile", String.Empty); |
@@ -204,27 +191,38 @@ namespace OpenSim | |||
204 | } | 191 | } |
205 | 192 | ||
206 | // Load the simulation data service | 193 | // Load the simulation data service |
207 | IConfig simDataConfig = m_config.Source.Configs["SimulationDataStore"]; | 194 | IConfig simDataConfig = Config.Configs["SimulationDataStore"]; |
208 | if (simDataConfig == null) | 195 | if (simDataConfig == null) |
209 | throw new Exception("Configuration file is missing the [SimulationDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?"); | 196 | throw new Exception("Configuration file is missing the [SimulationDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?"); |
197 | |||
210 | string module = simDataConfig.GetString("LocalServiceModule", String.Empty); | 198 | string module = simDataConfig.GetString("LocalServiceModule", String.Empty); |
211 | if (String.IsNullOrEmpty(module)) | 199 | if (String.IsNullOrEmpty(module)) |
212 | throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [SimulationDataStore] section."); | 200 | throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [SimulationDataStore] section."); |
213 | m_simulationDataService = ServerUtils.LoadPlugin<ISimulationDataService>(module, new object[] { m_config.Source }); | 201 | |
202 | m_simulationDataService = ServerUtils.LoadPlugin<ISimulationDataService>(module, new object[] { Config }); | ||
203 | if (m_simulationDataService == null) | ||
204 | throw new Exception( | ||
205 | string.Format( | ||
206 | "Could not load an ISimulationDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [SimulationDataStore] config section.", | ||
207 | module)); | ||
214 | 208 | ||
215 | // Load the estate data service | 209 | // Load the estate data service |
216 | IConfig estateDataConfig = m_config.Source.Configs["EstateDataStore"]; | 210 | IConfig estateDataConfig = Config.Configs["EstateDataStore"]; |
217 | if (estateDataConfig == null) | 211 | if (estateDataConfig == null) |
218 | throw new Exception("Configuration file is missing the [EstateDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?"); | 212 | throw new Exception("Configuration file is missing the [EstateDataStore] section. Have you copied OpenSim.ini.example to OpenSim.ini to reference config-include/ files?"); |
213 | |||
219 | module = estateDataConfig.GetString("LocalServiceModule", String.Empty); | 214 | module = estateDataConfig.GetString("LocalServiceModule", String.Empty); |
220 | if (String.IsNullOrEmpty(module)) | 215 | if (String.IsNullOrEmpty(module)) |
221 | throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section"); | 216 | throw new Exception("Configuration file is missing the LocalServiceModule parameter in the [EstateDataStore] section"); |
222 | m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { m_config.Source }); | ||
223 | 217 | ||
224 | base.StartupSpecific(); | 218 | m_estateDataService = ServerUtils.LoadPlugin<IEstateDataService>(module, new object[] { Config }); |
219 | if (m_estateDataService == null) | ||
220 | throw new Exception( | ||
221 | string.Format( | ||
222 | "Could not load an IEstateDataService implementation from {0}, as configured in the LocalServiceModule parameter of the [EstateDataStore] config section.", | ||
223 | module)); | ||
225 | 224 | ||
226 | // Create a ModuleLoader instance | 225 | base.StartupSpecific(); |
227 | m_moduleLoader = new ModuleLoader(m_config.Source); | ||
228 | 226 | ||
229 | LoadPlugins(); | 227 | LoadPlugins(); |
230 | foreach (IApplicationPlugin plugin in m_plugins) | 228 | foreach (IApplicationPlugin plugin in m_plugins) |
@@ -239,7 +237,7 @@ namespace OpenSim | |||
239 | } | 237 | } |
240 | } | 238 | } |
241 | 239 | ||
242 | protected virtual void AddPluginCommands(CommandConsole console) | 240 | protected virtual void AddPluginCommands(ICommandConsole console) |
243 | { | 241 | { |
244 | List<string> topics = GetHelpTopics(); | 242 | List<string> topics = GetHelpTopics(); |
245 | 243 | ||
@@ -301,7 +299,7 @@ namespace OpenSim | |||
301 | // Called from base.StartUp() | 299 | // Called from base.StartUp() |
302 | 300 | ||
303 | m_httpServerPort = m_networkServersInfo.HttpListenerPort; | 301 | m_httpServerPort = m_networkServersInfo.HttpListenerPort; |
304 | SceneManager.OnRestartSim += handleRestartRegion; | 302 | SceneManager.OnRestartSim += HandleRestartRegion; |
305 | 303 | ||
306 | // Only enable the watchdogs when all regions are ready. Otherwise we get false positives when cpu is | 304 | // Only enable the watchdogs when all regions are ready. Otherwise we get false positives when cpu is |
307 | // heavily used during initial startup. | 305 | // heavily used during initial startup. |
@@ -366,16 +364,10 @@ namespace OpenSim | |||
366 | } | 364 | } |
367 | 365 | ||
368 | IClientNetworkServer clientServer; | 366 | IClientNetworkServer clientServer; |
369 | Scene scene = SetupScene(regionInfo, proxyOffset, m_config.Source, out clientServer); | 367 | Scene scene = SetupScene(regionInfo, proxyOffset, Config, out clientServer); |
370 | 368 | ||
371 | m_log.Info("[MODULES]: Loading Region's modules (old style)"); | 369 | m_log.Info("[MODULES]: Loading Region's modules (old style)"); |
372 | 370 | ||
373 | List<IRegionModule> modules = m_moduleLoader.PickupModules(scene, "."); | ||
374 | |||
375 | // This needs to be ahead of the script engine load, so the | ||
376 | // script module can pick up events exposed by a module | ||
377 | m_moduleLoader.InitialiseSharedModules(scene); | ||
378 | |||
379 | // Use this in the future, the line above will be deprecated soon | 371 | // Use this in the future, the line above will be deprecated soon |
380 | m_log.Info("[REGIONMODULES]: Loading Region's modules (new style)"); | 372 | m_log.Info("[REGIONMODULES]: Loading Region's modules (new style)"); |
381 | IRegionModulesController controller; | 373 | IRegionModulesController controller; |
@@ -426,13 +418,6 @@ namespace OpenSim | |||
426 | clientServer.Start(); | 418 | clientServer.Start(); |
427 | } | 419 | } |
428 | 420 | ||
429 | if (do_post_init) | ||
430 | { | ||
431 | foreach (IRegionModule module in modules) | ||
432 | { | ||
433 | module.PostInitialise(); | ||
434 | } | ||
435 | } | ||
436 | scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); }; | 421 | scene.EventManager.OnShutdown += delegate() { ShutdownRegion(scene); }; |
437 | 422 | ||
438 | mscene = scene; | 423 | mscene = scene; |
@@ -461,10 +446,10 @@ namespace OpenSim | |||
461 | string estateOwnerPassword = null; | 446 | string estateOwnerPassword = null; |
462 | string rawEstateOwnerUuid = null; | 447 | string rawEstateOwnerUuid = null; |
463 | 448 | ||
464 | if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null) | 449 | if (Config.Configs[ESTATE_SECTION_NAME] != null) |
465 | { | 450 | { |
466 | string defaultEstateOwnerName | 451 | string defaultEstateOwnerName |
467 | = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerName", "").Trim(); | 452 | = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerName", "").Trim(); |
468 | string[] ownerNames = defaultEstateOwnerName.Split(' '); | 453 | string[] ownerNames = defaultEstateOwnerName.Split(' '); |
469 | 454 | ||
470 | if (ownerNames.Length >= 2) | 455 | if (ownerNames.Length >= 2) |
@@ -474,9 +459,9 @@ namespace OpenSim | |||
474 | } | 459 | } |
475 | 460 | ||
476 | // Info to be used only on Standalone Mode | 461 | // Info to be used only on Standalone Mode |
477 | rawEstateOwnerUuid = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerUUID", null); | 462 | rawEstateOwnerUuid = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerUUID", null); |
478 | estateOwnerEMail = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerEMail", null); | 463 | estateOwnerEMail = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerEMail", null); |
479 | estateOwnerPassword = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerPassword", null); | 464 | estateOwnerPassword = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateOwnerPassword", null); |
480 | } | 465 | } |
481 | 466 | ||
482 | MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName); | 467 | MainConsole.Instance.OutputFormat("Estate {0} has no owner set.", regionInfo.EstateSettings.EstateName); |
@@ -543,7 +528,7 @@ namespace OpenSim | |||
543 | if (account == null) | 528 | if (account == null) |
544 | { | 529 | { |
545 | m_log.ErrorFormat( | 530 | m_log.ErrorFormat( |
546 | "[OPENSIM]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first."); | 531 | "[OPENSIM]: Unable to store account. If this simulator is connected to a grid, you must create the estate owner account first at the grid level."); |
547 | } | 532 | } |
548 | else | 533 | else |
549 | { | 534 | { |
@@ -722,8 +707,8 @@ namespace OpenSim | |||
722 | 707 | ||
723 | return new Scene( | 708 | return new Scene( |
724 | regionInfo, circuitManager, sceneGridService, | 709 | regionInfo, circuitManager, sceneGridService, |
725 | simDataService, estateDataService, m_moduleLoader, false, | 710 | simDataService, estateDataService, false, |
726 | m_config.Source, m_version); | 711 | Config, m_version); |
727 | } | 712 | } |
728 | 713 | ||
729 | protected void ShutdownClientServer(RegionInfo whichRegion) | 714 | protected void ShutdownClientServer(RegionInfo whichRegion) |
@@ -750,9 +735,11 @@ namespace OpenSim | |||
750 | } | 735 | } |
751 | } | 736 | } |
752 | 737 | ||
753 | public void handleRestartRegion(RegionInfo whichRegion) | 738 | protected virtual void HandleRestartRegion(RegionInfo whichRegion) |
754 | { | 739 | { |
755 | m_log.Info("[OPENSIM]: Got restart signal from SceneManager"); | 740 | m_log.InfoFormat( |
741 | "[OPENSIM]: Got restart signal from SceneManager for region {0} ({1},{2})", | ||
742 | whichRegion.RegionName, whichRegion.RegionLocX, whichRegion.RegionLocY); | ||
756 | 743 | ||
757 | ShutdownClientServer(whichRegion); | 744 | ShutdownClientServer(whichRegion); |
758 | IScene scene; | 745 | IScene scene; |
@@ -764,7 +751,7 @@ namespace OpenSim | |||
764 | protected override PhysicsScene GetPhysicsScene(string osSceneIdentifier) | 751 | protected override PhysicsScene GetPhysicsScene(string osSceneIdentifier) |
765 | { | 752 | { |
766 | return GetPhysicsScene( | 753 | return GetPhysicsScene( |
767 | m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, m_config.Source, osSceneIdentifier); | 754 | m_configSettings.PhysicsEngine, m_configSettings.MeshEngineName, Config, osSceneIdentifier); |
768 | } | 755 | } |
769 | 756 | ||
770 | /// <summary> | 757 | /// <summary> |
@@ -898,7 +885,6 @@ namespace OpenSim | |||
898 | m_log.Info("[SHUTDOWN]: Closing all threads"); | 885 | m_log.Info("[SHUTDOWN]: Closing all threads"); |
899 | m_log.Info("[SHUTDOWN]: Killing listener thread"); | 886 | m_log.Info("[SHUTDOWN]: Killing listener thread"); |
900 | m_log.Info("[SHUTDOWN]: Killing clients"); | 887 | m_log.Info("[SHUTDOWN]: Killing clients"); |
901 | // TODO: implement this | ||
902 | m_log.Info("[SHUTDOWN]: Closing console and terminating"); | 888 | m_log.Info("[SHUTDOWN]: Closing console and terminating"); |
903 | 889 | ||
904 | try | 890 | try |
@@ -907,7 +893,7 @@ namespace OpenSim | |||
907 | } | 893 | } |
908 | catch (Exception e) | 894 | catch (Exception e) |
909 | { | 895 | { |
910 | m_log.ErrorFormat("[SHUTDOWN]: Ignoring failure during shutdown - {0}", e); | 896 | m_log.Error("[SHUTDOWN]: Ignoring failure during shutdown - ", e); |
911 | } | 897 | } |
912 | } | 898 | } |
913 | 899 | ||
@@ -1001,9 +987,9 @@ namespace OpenSim | |||
1001 | 987 | ||
1002 | string defaultEstateName = null; | 988 | string defaultEstateName = null; |
1003 | 989 | ||
1004 | if (m_config.Source.Configs[ESTATE_SECTION_NAME] != null) | 990 | if (Config.Configs[ESTATE_SECTION_NAME] != null) |
1005 | { | 991 | { |
1006 | defaultEstateName = m_config.Source.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateName", null); | 992 | defaultEstateName = Config.Configs[ESTATE_SECTION_NAME].GetString("DefaultEstateName", null); |
1007 | 993 | ||
1008 | if (defaultEstateName != null) | 994 | if (defaultEstateName != null) |
1009 | { | 995 | { |
@@ -1086,28 +1072,14 @@ namespace OpenSim | |||
1086 | MainConsole.Instance.Output("Joining the estate failed. Please try again."); | 1072 | MainConsole.Instance.Output("Joining the estate failed. Please try again."); |
1087 | } | 1073 | } |
1088 | } | 1074 | } |
1089 | } | 1075 | } |
1090 | 1076 | ||
1091 | return true; // need to update the database | 1077 | return true; // need to update the database |
1092 | } | 1078 | } |
1093 | } | 1079 | } |
1094 | 1080 | ||
1095 | public class OpenSimConfigSource | 1081 | public class OpenSimConfigSource |
1096 | { | 1082 | { |
1097 | public IConfigSource Source; | 1083 | public IConfigSource Source; |
1098 | |||
1099 | public void Save(string path) | ||
1100 | { | ||
1101 | if (Source is IniConfigSource) | ||
1102 | { | ||
1103 | IniConfigSource iniCon = (IniConfigSource) Source; | ||
1104 | iniCon.Save(path); | ||
1105 | } | ||
1106 | else if (Source is XmlConfigSource) | ||
1107 | { | ||
1108 | XmlConfigSource xmlCon = (XmlConfigSource) Source; | ||
1109 | xmlCon.Save(path); | ||
1110 | } | ||
1111 | } | ||
1112 | } | 1084 | } |
1113 | } | 1085 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs index 66b865f..b735dfa 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/BunchOfCaps/BunchOfCapsModule.cs | |||
@@ -45,7 +45,7 @@ using Caps = OpenSim.Framework.Capabilities.Caps; | |||
45 | namespace OpenSim.Region.ClientStack.Linden | 45 | namespace OpenSim.Region.ClientStack.Linden |
46 | { | 46 | { |
47 | 47 | ||
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BunchOfCapsModule")] |
49 | public class BunchOfCapsModule : INonSharedRegionModule | 49 | public class BunchOfCapsModule : INonSharedRegionModule |
50 | { | 50 | { |
51 | // private static readonly ILog m_log = | 51 | // private static readonly ILog m_log = |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs index 47cb049..4d2c0f2 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/EventQueueGetModule.cs | |||
@@ -55,8 +55,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
55 | public OSDMap body; | 55 | public OSDMap body; |
56 | } | 56 | } |
57 | 57 | ||
58 | //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 58 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EventQueueGetModule")] |
59 | public class EventQueueGetModule : IEventQueue, IRegionModule | 59 | public class EventQueueGetModule : IEventQueue, INonSharedRegionModule |
60 | { | 60 | { |
61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
62 | 62 | ||
@@ -66,8 +66,6 @@ namespace OpenSim.Region.ClientStack.Linden | |||
66 | public int DebugLevel { get; set; } | 66 | public int DebugLevel { get; set; } |
67 | 67 | ||
68 | protected Scene m_scene; | 68 | protected Scene m_scene; |
69 | private IConfigSource m_gConfig; | ||
70 | bool enabledYN; | ||
71 | 69 | ||
72 | private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>(); | 70 | private Dictionary<UUID, int> m_ids = new Dictionary<UUID, int>(); |
73 | 71 | ||
@@ -75,60 +73,46 @@ namespace OpenSim.Region.ClientStack.Linden | |||
75 | private Dictionary<UUID, UUID> m_QueueUUIDAvatarMapping = new Dictionary<UUID, UUID>(); | 73 | private Dictionary<UUID, UUID> m_QueueUUIDAvatarMapping = new Dictionary<UUID, UUID>(); |
76 | private Dictionary<UUID, UUID> m_AvatarQueueUUIDMapping = new Dictionary<UUID, UUID>(); | 74 | private Dictionary<UUID, UUID> m_AvatarQueueUUIDMapping = new Dictionary<UUID, UUID>(); |
77 | 75 | ||
78 | #region IRegionModule methods | 76 | #region INonSharedRegionModule methods |
79 | public virtual void Initialise(Scene scene, IConfigSource config) | 77 | public virtual void Initialise(IConfigSource config) |
80 | { | 78 | { |
81 | m_gConfig = config; | 79 | } |
82 | |||
83 | IConfig startupConfig = m_gConfig.Configs["Startup"]; | ||
84 | |||
85 | ReadConfigAndPopulate(scene, startupConfig, "Startup"); | ||
86 | |||
87 | if (enabledYN) | ||
88 | { | ||
89 | m_scene = scene; | ||
90 | scene.RegisterModuleInterface<IEventQueue>(this); | ||
91 | |||
92 | // Register fallback handler | ||
93 | // Why does EQG Fail on region crossings! | ||
94 | |||
95 | //scene.CommsManager.HttpServer.AddLLSDHandler("/CAPS/EQG/", EventQueueFallBack); | ||
96 | |||
97 | // scene.EventManager.OnNewClient += OnNewClient; | ||
98 | |||
99 | // TODO: Leaving these open, or closing them when we | ||
100 | // become a child is incorrect. It messes up TP in a big | ||
101 | // way. CAPS/EQ need to be active as long as the UDP | ||
102 | // circuit is there. | ||
103 | 80 | ||
104 | scene.EventManager.OnClientClosed += ClientClosed; | 81 | public void AddRegion(Scene scene) |
105 | 82 | { | |
106 | scene.EventManager.OnMakeChildAgent += MakeChildAgent; | 83 | m_scene = scene; |
107 | scene.EventManager.OnRegisterCaps += OnRegisterCaps; | 84 | scene.RegisterModuleInterface<IEventQueue>(this); |
108 | 85 | ||
109 | MainConsole.Instance.Commands.AddCommand( | 86 | scene.EventManager.OnClientClosed += ClientClosed; |
110 | "Debug", | 87 | scene.EventManager.OnMakeChildAgent += MakeChildAgent; |
111 | false, | 88 | scene.EventManager.OnRegisterCaps += OnRegisterCaps; |
112 | "debug eq", | 89 | |
113 | "debug eq [0|1|2]", | 90 | MainConsole.Instance.Commands.AddCommand( |
114 | "Turn on event queue debugging\n" | 91 | "Debug", |
115 | + " <= 0 - turns off all event queue logging\n" | 92 | false, |
116 | + " >= 1 - turns on outgoing event logging\n" | 93 | "debug eq", |
117 | + " >= 2 - turns on poll notification", | 94 | "debug eq [0|1|2]", |
118 | HandleDebugEq); | 95 | "Turn on event queue debugging\n" |
119 | } | 96 | + " <= 0 - turns off all event queue logging\n" |
120 | else | 97 | + " >= 1 - turns on outgoing event logging\n" |
121 | { | 98 | + " >= 2 - turns on poll notification", |
122 | m_gConfig = null; | 99 | HandleDebugEq); |
123 | } | ||
124 | } | 100 | } |
125 | 101 | ||
126 | private void ReadConfigAndPopulate(Scene scene, IConfig startupConfig, string p) | 102 | public void RemoveRegion(Scene scene) |
127 | { | 103 | { |
128 | enabledYN = startupConfig.GetBoolean("EventQueue", true); | 104 | if (m_scene != scene) |
105 | return; | ||
106 | |||
107 | scene.EventManager.OnClientClosed -= ClientClosed; | ||
108 | scene.EventManager.OnMakeChildAgent -= MakeChildAgent; | ||
109 | scene.EventManager.OnRegisterCaps -= OnRegisterCaps; | ||
110 | |||
111 | scene.UnregisterModuleInterface<IEventQueue>(this); | ||
112 | m_scene = null; | ||
129 | } | 113 | } |
130 | 114 | ||
131 | public void PostInitialise() | 115 | public void RegionLoaded(Scene scene) |
132 | { | 116 | { |
133 | } | 117 | } |
134 | 118 | ||
@@ -141,10 +125,11 @@ namespace OpenSim.Region.ClientStack.Linden | |||
141 | get { return "EventQueueGetModule"; } | 125 | get { return "EventQueueGetModule"; } |
142 | } | 126 | } |
143 | 127 | ||
144 | public bool IsSharedModule | 128 | public Type ReplaceableInterface |
145 | { | 129 | { |
146 | get { return false; } | 130 | get { return null; } |
147 | } | 131 | } |
132 | |||
148 | #endregion | 133 | #endregion |
149 | 134 | ||
150 | protected void HandleDebugEq(string module, string[] args) | 135 | protected void HandleDebugEq(string module, string[] args) |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs index d604cf6..ed8ec16 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/EventQueue/Tests/EventQueueTests.cs | |||
@@ -44,7 +44,7 @@ using OpenSim.Tests.Common.Mock; | |||
44 | namespace OpenSim.Region.ClientStack.Linden.Tests | 44 | namespace OpenSim.Region.ClientStack.Linden.Tests |
45 | { | 45 | { |
46 | [TestFixture] | 46 | [TestFixture] |
47 | public class EventQueueTests | 47 | public class EventQueueTests : OpenSimTestCase |
48 | { | 48 | { |
49 | private TestScene m_scene; | 49 | private TestScene m_scene; |
50 | 50 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs b/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs index cb5afcc..87d3d1c 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/FetchInventory2Module.cs | |||
@@ -45,7 +45,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
45 | /// <summary> | 45 | /// <summary> |
46 | /// This module implements both WebFetchInventoryDescendents and FetchInventoryDescendents2 capabilities. | 46 | /// This module implements both WebFetchInventoryDescendents and FetchInventoryDescendents2 capabilities. |
47 | /// </summary> | 47 | /// </summary> |
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "FetchInventory2Module")] |
49 | public class FetchInventory2Module : INonSharedRegionModule | 49 | public class FetchInventory2Module : INonSharedRegionModule |
50 | { | 50 | { |
51 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs index 0d7b1fc..8e1f63a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetMeshModule.cs | |||
@@ -47,7 +47,7 @@ using Caps = OpenSim.Framework.Capabilities.Caps; | |||
47 | 47 | ||
48 | namespace OpenSim.Region.ClientStack.Linden | 48 | namespace OpenSim.Region.ClientStack.Linden |
49 | { | 49 | { |
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GetMeshModule")] |
51 | public class GetMeshModule : INonSharedRegionModule | 51 | public class GetMeshModule : INonSharedRegionModule |
52 | { | 52 | { |
53 | // private static readonly ILog m_log = | 53 | // private static readonly ILog m_log = |
@@ -58,7 +58,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
58 | private bool m_Enabled = true; | 58 | private bool m_Enabled = true; |
59 | private string m_URL; | 59 | private string m_URL; |
60 | 60 | ||
61 | #region IRegionModuleBase Members | 61 | #region Region Module interfaceBase Members |
62 | 62 | ||
63 | public Type ReplaceableInterface | 63 | public Type ReplaceableInterface |
64 | { | 64 | { |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs index 5ae9cc3..13415f8 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/GetTextureModule.cs | |||
@@ -51,7 +51,7 @@ using OpenSim.Capabilities.Handlers; | |||
51 | namespace OpenSim.Region.ClientStack.Linden | 51 | namespace OpenSim.Region.ClientStack.Linden |
52 | { | 52 | { |
53 | 53 | ||
54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GetTextureModule")] |
55 | public class GetTextureModule : INonSharedRegionModule | 55 | public class GetTextureModule : INonSharedRegionModule |
56 | { | 56 | { |
57 | // private static readonly ILog m_log = | 57 | // private static readonly ILog m_log = |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs index 44a6883..33b1f77 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/MeshUploadFlagModule.cs | |||
@@ -45,7 +45,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
45 | /// <summary> | 45 | /// <summary> |
46 | /// MeshUploadFlag capability. This is required for uploading Mesh. | 46 | /// MeshUploadFlag capability. This is required for uploading Mesh. |
47 | /// </summary> | 47 | /// </summary> |
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MeshUploadFlagModule")] |
49 | public class MeshUploadFlagModule : INonSharedRegionModule | 49 | public class MeshUploadFlagModule : INonSharedRegionModule |
50 | { | 50 | { |
51 | // private static readonly ILog m_log = | 51 | // private static readonly ILog m_log = |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs index 52c4f44..5529550 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/NewFileAgentInventoryVariablePriceModule.cs | |||
@@ -47,7 +47,7 @@ using OpenSim.Framework.Capabilities; | |||
47 | 47 | ||
48 | namespace OpenSim.Region.ClientStack.Linden | 48 | namespace OpenSim.Region.ClientStack.Linden |
49 | { | 49 | { |
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "NewFileAgentInventoryVariablePriceModule")] |
51 | public class NewFileAgentInventoryVariablePriceModule : INonSharedRegionModule | 51 | public class NewFileAgentInventoryVariablePriceModule : INonSharedRegionModule |
52 | { | 52 | { |
53 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 53 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -58,7 +58,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
58 | private bool m_enabled = true; | 58 | private bool m_enabled = true; |
59 | private int m_levelUpload = 0; | 59 | private int m_levelUpload = 0; |
60 | 60 | ||
61 | #region IRegionModuleBase Members | 61 | #region Region Module interfaceBase Members |
62 | 62 | ||
63 | 63 | ||
64 | public Type ReplaceableInterface | 64 | public Type ReplaceableInterface |
@@ -98,7 +98,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
98 | #endregion | 98 | #endregion |
99 | 99 | ||
100 | 100 | ||
101 | #region IRegionModule Members | 101 | #region Region Module interface |
102 | 102 | ||
103 | 103 | ||
104 | 104 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs index 4ccfc43..92805e2 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/ObjectAdd.cs | |||
@@ -32,6 +32,7 @@ using log4net; | |||
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenMetaverse.StructuredData; | 34 | using OpenMetaverse.StructuredData; |
35 | using Mono.Addins; | ||
35 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Servers; | 37 | using OpenSim.Framework.Servers; |
37 | using OpenSim.Framework.Servers.HttpServer; | 38 | using OpenSim.Framework.Servers.HttpServer; |
@@ -41,30 +42,60 @@ using Caps=OpenSim.Framework.Capabilities.Caps; | |||
41 | 42 | ||
42 | namespace OpenSim.Region.ClientStack.Linden | 43 | namespace OpenSim.Region.ClientStack.Linden |
43 | { | 44 | { |
44 | public class ObjectAdd : IRegionModule | 45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ObjectAdd")] |
46 | public class ObjectAdd : INonSharedRegionModule | ||
45 | { | 47 | { |
46 | // private static readonly ILog m_log = | 48 | // private static readonly ILog m_log = |
47 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
48 | 50 | ||
49 | private Scene m_scene; | 51 | private Scene m_scene; |
50 | #region IRegionModule Members | ||
51 | 52 | ||
52 | public void Initialise(Scene pScene, IConfigSource pSource) | 53 | #region INonSharedRegionModule Members |
54 | |||
55 | public void Initialise(IConfigSource pSource) | ||
56 | { | ||
57 | } | ||
58 | |||
59 | public void AddRegion(Scene scene) | ||
53 | { | 60 | { |
54 | m_scene = pScene; | 61 | m_scene = scene; |
55 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; | 62 | m_scene.EventManager.OnRegisterCaps += RegisterCaps; |
56 | } | 63 | } |
57 | 64 | ||
58 | public void PostInitialise() | 65 | public void RemoveRegion(Scene scene) |
59 | { | 66 | { |
60 | 67 | if (m_scene == scene) | |
68 | { | ||
69 | m_scene.EventManager.OnRegisterCaps -= RegisterCaps; | ||
70 | m_scene = null; | ||
71 | } | ||
61 | } | 72 | } |
62 | 73 | ||
74 | public void RegionLoaded(Scene scene) | ||
75 | { | ||
76 | } | ||
77 | |||
78 | public void Close() | ||
79 | { | ||
80 | } | ||
81 | |||
82 | public string Name | ||
83 | { | ||
84 | get { return "ObjectAddModule"; } | ||
85 | } | ||
86 | |||
87 | public Type ReplaceableInterface | ||
88 | { | ||
89 | get { return null; } | ||
90 | } | ||
91 | |||
92 | #endregion | ||
93 | |||
63 | public void RegisterCaps(UUID agentID, Caps caps) | 94 | public void RegisterCaps(UUID agentID, Caps caps) |
64 | { | 95 | { |
65 | UUID capuuid = UUID.Random(); | 96 | UUID capuuid = UUID.Random(); |
66 | 97 | ||
67 | // m_log.InfoFormat("[OBJECTADD]: {0}", "/CAPS/OA/" + capuuid + "/"); | 98 | // m_log.InfoFormat("[OBJECTADD]: {0}", "/CAPS/OA/" + capuuid + "/"); |
68 | 99 | ||
69 | caps.RegisterHandler( | 100 | caps.RegisterHandler( |
70 | "ObjectAdd", | 101 | "ObjectAdd", |
@@ -73,7 +104,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
73 | "/CAPS/OA/" + capuuid + "/", | 104 | "/CAPS/OA/" + capuuid + "/", |
74 | httpMethod => ProcessAdd(httpMethod, agentID, caps), | 105 | httpMethod => ProcessAdd(httpMethod, agentID, caps), |
75 | "ObjectAdd", | 106 | "ObjectAdd", |
76 | agentID.ToString()));; | 107 | agentID.ToString())); ; |
77 | } | 108 | } |
78 | 109 | ||
79 | public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap) | 110 | public Hashtable ProcessAdd(Hashtable request, UUID AgentId, Caps cap) |
@@ -84,7 +115,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
84 | responsedata["keepalive"] = false; | 115 | responsedata["keepalive"] = false; |
85 | responsedata["str_response_string"] = "Request wasn't what was expected"; | 116 | responsedata["str_response_string"] = "Request wasn't what was expected"; |
86 | ScenePresence avatar; | 117 | ScenePresence avatar; |
87 | 118 | ||
88 | if (!m_scene.TryGetScenePresence(AgentId, out avatar)) | 119 | if (!m_scene.TryGetScenePresence(AgentId, out avatar)) |
89 | return responsedata; | 120 | return responsedata; |
90 | 121 | ||
@@ -127,7 +158,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
127 | 158 | ||
128 | if (r.Type != OSDType.Map) // not a proper req | 159 | if (r.Type != OSDType.Map) // not a proper req |
129 | return responsedata; | 160 | return responsedata; |
130 | 161 | ||
131 | OSDMap rm = (OSDMap)r; | 162 | OSDMap rm = (OSDMap)r; |
132 | 163 | ||
133 | if (rm.ContainsKey("ObjectData")) //v2 | 164 | if (rm.ContainsKey("ObjectData")) //v2 |
@@ -138,7 +169,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
138 | return responsedata; | 169 | return responsedata; |
139 | } | 170 | } |
140 | 171 | ||
141 | OSDMap ObjMap = (OSDMap) rm["ObjectData"]; | 172 | OSDMap ObjMap = (OSDMap)rm["ObjectData"]; |
142 | 173 | ||
143 | bypass_raycast = ObjMap["BypassRaycast"].AsBoolean(); | 174 | bypass_raycast = ObjMap["BypassRaycast"].AsBoolean(); |
144 | everyone_mask = readuintval(ObjMap["EveryoneMask"]); | 175 | everyone_mask = readuintval(ObjMap["EveryoneMask"]); |
@@ -181,7 +212,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
181 | responsedata["str_response_string"] = "Has Profile key, but data not in expected format"; | 212 | responsedata["str_response_string"] = "Has Profile key, but data not in expected format"; |
182 | return responsedata; | 213 | return responsedata; |
183 | } | 214 | } |
184 | 215 | ||
185 | OSDMap ProfileMap = (OSDMap)ObjMap["Profile"]; | 216 | OSDMap ProfileMap = (OSDMap)ObjMap["Profile"]; |
186 | 217 | ||
187 | profile_begin = ProfileMap["Begin"].AsInteger(); | 218 | profile_begin = ProfileMap["Begin"].AsInteger(); |
@@ -190,14 +221,14 @@ namespace OpenSim.Region.ClientStack.Linden | |||
190 | hollow = ProfileMap["Hollow"].AsInteger(); | 221 | hollow = ProfileMap["Hollow"].AsInteger(); |
191 | } | 222 | } |
192 | ray_end_is_intersection = ObjMap["RayEndIsIntersection"].AsBoolean(); | 223 | ray_end_is_intersection = ObjMap["RayEndIsIntersection"].AsBoolean(); |
193 | 224 | ||
194 | ray_target_id = ObjMap["RayTargetId"].AsUUID(); | 225 | ray_target_id = ObjMap["RayTargetId"].AsUUID(); |
195 | state = ObjMap["State"].AsInteger(); | 226 | state = ObjMap["State"].AsInteger(); |
196 | try | 227 | try |
197 | { | 228 | { |
198 | ray_end = ((OSDArray) ObjMap["RayEnd"]).AsVector3(); | 229 | ray_end = ((OSDArray)ObjMap["RayEnd"]).AsVector3(); |
199 | ray_start = ((OSDArray) ObjMap["RayStart"]).AsVector3(); | 230 | ray_start = ((OSDArray)ObjMap["RayStart"]).AsVector3(); |
200 | scale = ((OSDArray) ObjMap["Scale"]).AsVector3(); | 231 | scale = ((OSDArray)ObjMap["Scale"]).AsVector3(); |
201 | rotation = ((OSDArray)ObjMap["Rotation"]).AsQuaternion(); | 232 | rotation = ((OSDArray)ObjMap["Rotation"]).AsQuaternion(); |
202 | } | 233 | } |
203 | catch (Exception) | 234 | catch (Exception) |
@@ -214,7 +245,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
214 | return responsedata; | 245 | return responsedata; |
215 | } | 246 | } |
216 | 247 | ||
217 | OSDMap AgentDataMap = (OSDMap) rm["AgentData"]; | 248 | OSDMap AgentDataMap = (OSDMap)rm["AgentData"]; |
218 | 249 | ||
219 | //session_id = AgentDataMap["SessionId"].AsUUID(); | 250 | //session_id = AgentDataMap["SessionId"].AsUUID(); |
220 | group_id = AgentDataMap["GroupId"].AsUUID(); | 251 | group_id = AgentDataMap["GroupId"].AsUUID(); |
@@ -251,21 +282,21 @@ namespace OpenSim.Region.ClientStack.Linden | |||
251 | profile_begin = rm["profile_begin"].AsInteger(); | 282 | profile_begin = rm["profile_begin"].AsInteger(); |
252 | profile_curve = rm["profile_curve"].AsInteger(); | 283 | profile_curve = rm["profile_curve"].AsInteger(); |
253 | profile_end = rm["profile_end"].AsInteger(); | 284 | profile_end = rm["profile_end"].AsInteger(); |
254 | 285 | ||
255 | ray_end_is_intersection = rm["ray_end_is_intersection"].AsBoolean(); | 286 | ray_end_is_intersection = rm["ray_end_is_intersection"].AsBoolean(); |
256 | 287 | ||
257 | ray_target_id = rm["ray_target_id"].AsUUID(); | 288 | ray_target_id = rm["ray_target_id"].AsUUID(); |
258 | 289 | ||
259 | 290 | ||
260 | //session_id = rm["session_id"].AsUUID(); | 291 | //session_id = rm["session_id"].AsUUID(); |
261 | state = rm["state"].AsInteger(); | 292 | state = rm["state"].AsInteger(); |
262 | try | 293 | try |
263 | { | 294 | { |
264 | ray_end = ((OSDArray)rm["ray_end"]).AsVector3(); | 295 | ray_end = ((OSDArray)rm["ray_end"]).AsVector3(); |
265 | ray_start = ((OSDArray)rm["ray_start"]).AsVector3(); | 296 | ray_start = ((OSDArray)rm["ray_start"]).AsVector3(); |
266 | rotation = ((OSDArray)rm["rotation"]).AsQuaternion(); | 297 | rotation = ((OSDArray)rm["rotation"]).AsQuaternion(); |
267 | scale = ((OSDArray)rm["scale"]).AsVector3(); | 298 | scale = ((OSDArray)rm["scale"]).AsVector3(); |
268 | } | 299 | } |
269 | catch (Exception) | 300 | catch (Exception) |
270 | { | 301 | { |
271 | responsedata["str_response_string"] = "RayEnd, RayStart, Scale or Rotation wasn't in the expected format"; | 302 | responsedata["str_response_string"] = "RayEnd, RayStart, Scale or Rotation wasn't in the expected format"; |
@@ -273,9 +304,9 @@ namespace OpenSim.Region.ClientStack.Linden | |||
273 | } | 304 | } |
274 | } | 305 | } |
275 | 306 | ||
276 | |||
277 | 307 | ||
278 | Vector3 pos = m_scene.GetNewRezLocation(ray_start, ray_end, ray_target_id, rotation, (bypass_raycast) ? (byte)1 : (byte)0, (ray_end_is_intersection) ? (byte)1 : (byte)0, true, scale, false); | 308 | |
309 | Vector3 pos = m_scene.GetNewRezLocation(ray_start, ray_end, ray_target_id, rotation, (bypass_raycast) ? (byte)1 : (byte)0, (ray_end_is_intersection) ? (byte)1 : (byte)0, true, scale, false); | ||
279 | 310 | ||
280 | PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); | 311 | PrimitiveBaseShape pbs = PrimitiveBaseShape.CreateBox(); |
281 | 312 | ||
@@ -286,17 +317,17 @@ namespace OpenSim.Region.ClientStack.Linden | |||
286 | pbs.PathRevolutions = (byte)path_revolutions; | 317 | pbs.PathRevolutions = (byte)path_revolutions; |
287 | pbs.PathScaleX = (byte)path_scale_x; | 318 | pbs.PathScaleX = (byte)path_scale_x; |
288 | pbs.PathScaleY = (byte)path_scale_y; | 319 | pbs.PathScaleY = (byte)path_scale_y; |
289 | pbs.PathShearX = (byte) path_shear_x; | 320 | pbs.PathShearX = (byte)path_shear_x; |
290 | pbs.PathShearY = (byte)path_shear_y; | 321 | pbs.PathShearY = (byte)path_shear_y; |
291 | pbs.PathSkew = (sbyte)path_skew; | 322 | pbs.PathSkew = (sbyte)path_skew; |
292 | pbs.PathTaperX = (sbyte)path_taper_x; | 323 | pbs.PathTaperX = (sbyte)path_taper_x; |
293 | pbs.PathTaperY = (sbyte)path_taper_y; | 324 | pbs.PathTaperY = (sbyte)path_taper_y; |
294 | pbs.PathTwist = (sbyte)path_twist; | 325 | pbs.PathTwist = (sbyte)path_twist; |
295 | pbs.PathTwistBegin = (sbyte)path_twist_begin; | 326 | pbs.PathTwistBegin = (sbyte)path_twist_begin; |
296 | pbs.HollowShape = (HollowShape) hollow; | 327 | pbs.HollowShape = (HollowShape)hollow; |
297 | pbs.PCode = (byte)p_code; | 328 | pbs.PCode = (byte)p_code; |
298 | pbs.ProfileBegin = (ushort) profile_begin; | 329 | pbs.ProfileBegin = (ushort)profile_begin; |
299 | pbs.ProfileCurve = (byte) profile_curve; | 330 | pbs.ProfileCurve = (byte)profile_curve; |
300 | pbs.ProfileEnd = (ushort)profile_end; | 331 | pbs.ProfileEnd = (ushort)profile_end; |
301 | pbs.Scale = scale; | 332 | pbs.Scale = scale; |
302 | pbs.State = (byte)state; | 333 | pbs.State = (byte)state; |
@@ -306,7 +337,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
306 | if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos)) | 337 | if (m_scene.Permissions.CanRezObject(1, avatar.UUID, pos)) |
307 | { | 338 | { |
308 | // rez ON the ground, not IN the ground | 339 | // rez ON the ground, not IN the ground |
309 | // pos.Z += 0.25F; | 340 | // pos.Z += 0.25F; |
310 | 341 | ||
311 | obj = m_scene.AddNewPrim(avatar.UUID, group_id, pos, rotation, pbs); | 342 | obj = m_scene.AddNewPrim(avatar.UUID, group_id, pos, rotation, pbs); |
312 | } | 343 | } |
@@ -323,13 +354,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
323 | rootpart.GroupMask = group_mask; | 354 | rootpart.GroupMask = group_mask; |
324 | rootpart.NextOwnerMask = next_owner_mask; | 355 | rootpart.NextOwnerMask = next_owner_mask; |
325 | rootpart.Material = (byte)material; | 356 | rootpart.Material = (byte)material; |
326 | 357 | ||
327 | m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); | 358 | m_scene.PhysicsScene.AddPhysicsActorTaint(rootpart.PhysActor); |
328 | 359 | ||
329 | responsedata["int_response_code"] = 200; //501; //410; //404; | 360 | responsedata["int_response_code"] = 200; //501; //410; //404; |
330 | responsedata["content_type"] = "text/plain"; | 361 | responsedata["content_type"] = "text/plain"; |
331 | responsedata["keepalive"] = false; | 362 | responsedata["keepalive"] = false; |
332 | responsedata["str_response_string"] = String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>",ConvertUintToBytes(obj.LocalId)); | 363 | responsedata["str_response_string"] = String.Format("<llsd><map><key>local_id</key>{0}</map></llsd>", ConvertUintToBytes(obj.LocalId)); |
333 | 364 | ||
334 | return responsedata; | 365 | return responsedata; |
335 | } | 366 | } |
@@ -347,24 +378,8 @@ namespace OpenSim.Region.ClientStack.Linden | |||
347 | byte[] resultbytes = Utils.UIntToBytes(val); | 378 | byte[] resultbytes = Utils.UIntToBytes(val); |
348 | if (BitConverter.IsLittleEndian) | 379 | if (BitConverter.IsLittleEndian) |
349 | Array.Reverse(resultbytes); | 380 | Array.Reverse(resultbytes); |
350 | return String.Format("<binary encoding=\"base64\">{0}</binary>",Convert.ToBase64String(resultbytes)); | 381 | return String.Format("<binary encoding=\"base64\">{0}</binary>", Convert.ToBase64String(resultbytes)); |
351 | } | ||
352 | |||
353 | public void Close() | ||
354 | { | ||
355 | |||
356 | } | ||
357 | |||
358 | public string Name | ||
359 | { | ||
360 | get { return "ObjectAddModule"; } | ||
361 | } | ||
362 | |||
363 | public bool IsSharedModule | ||
364 | { | ||
365 | get { return false; } | ||
366 | } | 382 | } |
367 | 383 | ||
368 | #endregion | ||
369 | } | 384 | } |
370 | } | 385 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs index ba902b2..55a503e 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/ObjectCaps/UploadObjectAssetModule.cs | |||
@@ -51,14 +51,14 @@ using ExtraParamType = OpenMetaverse.ExtraParamType; | |||
51 | 51 | ||
52 | namespace OpenSim.Region.ClientStack.Linden | 52 | namespace OpenSim.Region.ClientStack.Linden |
53 | { | 53 | { |
54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UploadObjectAssetModule")] |
55 | public class UploadObjectAssetModule : INonSharedRegionModule | 55 | public class UploadObjectAssetModule : INonSharedRegionModule |
56 | { | 56 | { |
57 | private static readonly ILog m_log = | 57 | private static readonly ILog m_log = |
58 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 58 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
59 | private Scene m_scene; | 59 | private Scene m_scene; |
60 | 60 | ||
61 | #region IRegionModuleBase Members | 61 | #region Region Module interfaceBase Members |
62 | 62 | ||
63 | 63 | ||
64 | public Type ReplaceableInterface | 64 | public Type ReplaceableInterface |
@@ -92,7 +92,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
92 | #endregion | 92 | #endregion |
93 | 93 | ||
94 | 94 | ||
95 | #region IRegionModule Members | 95 | #region Region Module interface |
96 | 96 | ||
97 | 97 | ||
98 | 98 | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/Properties/AssemblyInfo.cs b/OpenSim/Region/ClientStack/Linden/Caps/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..060a61c --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/Caps/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.ClientStack.LindenCaps")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("1ae76353-f37f-4fe3-b6df-d11cedf01f2c")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs index 8ed0fb3..191bccf 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs | |||
@@ -53,7 +53,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
53 | /// NOTE: Part of this code was adapted from the Aurora project, specifically | 53 | /// NOTE: Part of this code was adapted from the Aurora project, specifically |
54 | /// the normal part of the response in the capability handler. | 54 | /// the normal part of the response in the capability handler. |
55 | /// </remarks> | 55 | /// </remarks> |
56 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 56 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimulatorFeaturesModule")] |
57 | public class SimulatorFeaturesModule : ISharedRegionModule, ISimulatorFeaturesModule | 57 | public class SimulatorFeaturesModule : ISharedRegionModule, ISimulatorFeaturesModule |
58 | { | 58 | { |
59 | // private static readonly ILog m_log = | 59 | // private static readonly ILog m_log = |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs index 6aac591..3b0ccd7 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs | |||
@@ -50,7 +50,7 @@ using OpenSim.Capabilities.Handlers; | |||
50 | 50 | ||
51 | namespace OpenSim.Region.ClientStack.Linden | 51 | namespace OpenSim.Region.ClientStack.Linden |
52 | { | 52 | { |
53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UploadBakedTextureModule")] |
54 | public class UploadBakedTextureModule : INonSharedRegionModule | 54 | public class UploadBakedTextureModule : INonSharedRegionModule |
55 | { | 55 | { |
56 | // private static readonly ILog m_log = | 56 | // private static readonly ILog m_log = |
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs index 2359bd6..6890f4a 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/WebFetchInvDescModule.cs | |||
@@ -45,7 +45,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
45 | /// <summary> | 45 | /// <summary> |
46 | /// This module implements both WebFetchInventoryDescendents and FetchInventoryDescendents2 capabilities. | 46 | /// This module implements both WebFetchInventoryDescendents and FetchInventoryDescendents2 capabilities. |
47 | /// </summary> | 47 | /// </summary> |
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebFetchInvDescModule")] |
49 | public class WebFetchInvDescModule : INonSharedRegionModule | 49 | public class WebFetchInvDescModule : INonSharedRegionModule |
50 | { | 50 | { |
51 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 7427c59..4fd81fa 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -817,8 +817,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
817 | OutPacket(mov, ThrottleOutPacketType.Unknown); | 817 | OutPacket(mov, ThrottleOutPacketType.Unknown); |
818 | } | 818 | } |
819 | 819 | ||
820 | public void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, | 820 | public void SendChatMessage( |
821 | UUID fromAgentID, byte source, byte audible) | 821 | string message, byte type, Vector3 fromPos, string fromName, |
822 | UUID fromAgentID, UUID ownerID, byte source, byte audible) | ||
822 | { | 823 | { |
823 | ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator); | 824 | ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator); |
824 | reply.ChatData.Audible = audible; | 825 | reply.ChatData.Audible = audible; |
@@ -827,7 +828,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
827 | reply.ChatData.SourceType = source; | 828 | reply.ChatData.SourceType = source; |
828 | reply.ChatData.Position = fromPos; | 829 | reply.ChatData.Position = fromPos; |
829 | reply.ChatData.FromName = Util.StringToBytes256(fromName); | 830 | reply.ChatData.FromName = Util.StringToBytes256(fromName); |
830 | reply.ChatData.OwnerID = fromAgentID; | 831 | reply.ChatData.OwnerID = ownerID; |
831 | reply.ChatData.SourceID = fromAgentID; | 832 | reply.ChatData.SourceID = fromAgentID; |
832 | 833 | ||
833 | OutPacket(reply, ThrottleOutPacketType.Task); | 834 | OutPacket(reply, ThrottleOutPacketType.Task); |
@@ -5218,8 +5219,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5218 | AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false); | 5219 | AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false); |
5219 | AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false); | 5220 | AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false); |
5220 | AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false); | 5221 | AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false); |
5221 | AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest, false); | 5222 | AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest); |
5222 | AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest, false); | 5223 | AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest); |
5223 | AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage); | 5224 | AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage); |
5224 | AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest); | 5225 | AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest); |
5225 | AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); | 5226 | AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer); |
@@ -5319,9 +5320,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5319 | AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory); | 5320 | AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory); |
5320 | AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory); | 5321 | AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory); |
5321 | AddLocalPacketHandler(PacketType.RezScript, HandleRezScript); | 5322 | AddLocalPacketHandler(PacketType.RezScript, HandleRezScript); |
5322 | AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest, false); | 5323 | AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest); |
5323 | AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest, false); | 5324 | AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest); |
5324 | AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest, false); | 5325 | AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest); |
5325 | AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest); | 5326 | AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest); |
5326 | AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel); | 5327 | AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel); |
5327 | AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest); | 5328 | AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest); |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs index 419de66..a7628d2 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLUDPServer.cs | |||
@@ -70,6 +70,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
70 | public void AddScene(IScene scene) | 70 | public void AddScene(IScene scene) |
71 | { | 71 | { |
72 | m_udpServer.AddScene(scene); | 72 | m_udpServer.AddScene(scene); |
73 | |||
74 | StatsManager.RegisterStat( | ||
75 | new Stat( | ||
76 | "IncomingPacketsProcessedCount", | ||
77 | "Number of inbound UDP packets processed", | ||
78 | "Number of inbound UDP packets processed", | ||
79 | "", | ||
80 | "clientstack", | ||
81 | scene.Name, | ||
82 | StatType.Pull, | ||
83 | MeasuresOfInterest.AverageChangeOverTime, | ||
84 | stat => stat.Value = m_udpServer.IncomingPacketsProcessed, | ||
85 | StatVerbosity.Debug)); | ||
73 | } | 86 | } |
74 | 87 | ||
75 | public bool HandlesRegion(Location x) | 88 | public bool HandlesRegion(Location x) |
@@ -170,6 +183,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
170 | 183 | ||
171 | private Pool<IncomingPacket> m_incomingPacketPool; | 184 | private Pool<IncomingPacket> m_incomingPacketPool; |
172 | 185 | ||
186 | /// <summary> | ||
187 | /// Stat for number of packets in the main pool awaiting use. | ||
188 | /// </summary> | ||
189 | private Stat m_poolCountStat; | ||
190 | |||
191 | /// <summary> | ||
192 | /// Stat for number of packets in the inbound packet pool awaiting use. | ||
193 | /// </summary> | ||
194 | private Stat m_incomingPacketPoolStat; | ||
195 | |||
173 | private int m_defaultRTO = 0; | 196 | private int m_defaultRTO = 0; |
174 | private int m_maxRTO = 0; | 197 | private int m_maxRTO = 0; |
175 | private int m_ackTimeout = 0; | 198 | private int m_ackTimeout = 0; |
@@ -214,6 +237,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
214 | 237 | ||
215 | m_circuitManager = circuitManager; | 238 | m_circuitManager = circuitManager; |
216 | int sceneThrottleBps = 0; | 239 | int sceneThrottleBps = 0; |
240 | bool usePools = false; | ||
217 | 241 | ||
218 | IConfig config = configSource.Configs["ClientStack.LindenUDP"]; | 242 | IConfig config = configSource.Configs["ClientStack.LindenUDP"]; |
219 | if (config != null) | 243 | if (config != null) |
@@ -246,7 +270,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
246 | { | 270 | { |
247 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); | 271 | PacketPool.Instance.RecyclePackets = packetConfig.GetBoolean("RecyclePackets", true); |
248 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); | 272 | PacketPool.Instance.RecycleDataBlocks = packetConfig.GetBoolean("RecycleDataBlocks", true); |
249 | UsePools = packetConfig.GetBoolean("RecycleBaseUDPPackets", false); | 273 | usePools = packetConfig.GetBoolean("RecycleBaseUDPPackets", usePools); |
250 | } | 274 | } |
251 | 275 | ||
252 | #region BinaryStats | 276 | #region BinaryStats |
@@ -277,8 +301,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
277 | m_throttle = new TokenBucket(null, sceneThrottleBps); | 301 | m_throttle = new TokenBucket(null, sceneThrottleBps); |
278 | ThrottleRates = new ThrottleRates(configSource); | 302 | ThrottleRates = new ThrottleRates(configSource); |
279 | 303 | ||
280 | if (UsePools) | 304 | if (usePools) |
281 | m_incomingPacketPool = new Pool<IncomingPacket>(() => new IncomingPacket(), 500); | 305 | EnablePools(); |
282 | } | 306 | } |
283 | 307 | ||
284 | public void Start() | 308 | public void Start() |
@@ -331,6 +355,83 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
331 | base.StopInbound(); | 355 | base.StopInbound(); |
332 | } | 356 | } |
333 | 357 | ||
358 | protected override bool EnablePools() | ||
359 | { | ||
360 | if (!UsePools) | ||
361 | { | ||
362 | base.EnablePools(); | ||
363 | |||
364 | m_incomingPacketPool = new Pool<IncomingPacket>(() => new IncomingPacket(), 500); | ||
365 | |||
366 | return true; | ||
367 | } | ||
368 | |||
369 | return false; | ||
370 | } | ||
371 | |||
372 | protected override bool DisablePools() | ||
373 | { | ||
374 | if (UsePools) | ||
375 | { | ||
376 | base.DisablePools(); | ||
377 | |||
378 | StatsManager.DeregisterStat(m_incomingPacketPoolStat); | ||
379 | |||
380 | // We won't null out the pool to avoid a race condition with code that may be in the middle of using it. | ||
381 | |||
382 | return true; | ||
383 | } | ||
384 | |||
385 | return false; | ||
386 | } | ||
387 | |||
388 | /// <summary> | ||
389 | /// This is a seperate method so that it can be called once we have an m_scene to distinguish different scene | ||
390 | /// stats. | ||
391 | /// </summary> | ||
392 | private void EnablePoolStats() | ||
393 | { | ||
394 | m_poolCountStat | ||
395 | = new Stat( | ||
396 | "UDPPacketBufferPoolCount", | ||
397 | "Objects within the UDPPacketBuffer pool", | ||
398 | "The number of objects currently stored within the UDPPacketBuffer pool", | ||
399 | "", | ||
400 | "clientstack", | ||
401 | m_scene.Name, | ||
402 | StatType.Pull, | ||
403 | stat => stat.Value = Pool.Count, | ||
404 | StatVerbosity.Debug); | ||
405 | |||
406 | StatsManager.RegisterStat(m_poolCountStat); | ||
407 | |||
408 | m_incomingPacketPoolStat | ||
409 | = new Stat( | ||
410 | "IncomingPacketPoolCount", | ||
411 | "Objects within incoming packet pool", | ||
412 | "The number of objects currently stored within the incoming packet pool", | ||
413 | "", | ||
414 | "clientstack", | ||
415 | m_scene.Name, | ||
416 | StatType.Pull, | ||
417 | stat => stat.Value = m_incomingPacketPool.Count, | ||
418 | StatVerbosity.Debug); | ||
419 | |||
420 | StatsManager.RegisterStat(m_incomingPacketPoolStat); | ||
421 | } | ||
422 | |||
423 | /// <summary> | ||
424 | /// Disables pool stats. | ||
425 | /// </summary> | ||
426 | private void DisablePoolStats() | ||
427 | { | ||
428 | StatsManager.DeregisterStat(m_poolCountStat); | ||
429 | m_poolCountStat = null; | ||
430 | |||
431 | StatsManager.DeregisterStat(m_incomingPacketPoolStat); | ||
432 | m_incomingPacketPoolStat = null; | ||
433 | } | ||
434 | |||
334 | /// <summary> | 435 | /// <summary> |
335 | /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging. | 436 | /// If the outgoing UDP thread times out, then return client that was being processed to help with debugging. |
336 | /// </summary> | 437 | /// </summary> |
@@ -370,6 +471,65 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
370 | m_scene = (Scene)scene; | 471 | m_scene = (Scene)scene; |
371 | m_location = new Location(m_scene.RegionInfo.RegionHandle); | 472 | m_location = new Location(m_scene.RegionInfo.RegionHandle); |
372 | 473 | ||
474 | // XXX: These stats are also pool stats but we register them separately since they are currently not | ||
475 | // turned on and off by EnablePools()/DisablePools() | ||
476 | StatsManager.RegisterStat( | ||
477 | new PercentageStat( | ||
478 | "PacketsReused", | ||
479 | "Packets reused", | ||
480 | "Number of packets reused out of all requests to the packet pool", | ||
481 | "clientstack", | ||
482 | m_scene.Name, | ||
483 | StatType.Pull, | ||
484 | stat => | ||
485 | { PercentageStat pstat = (PercentageStat)stat; | ||
486 | pstat.Consequent = PacketPool.Instance.PacketsRequested; | ||
487 | pstat.Antecedent = PacketPool.Instance.PacketsReused; }, | ||
488 | StatVerbosity.Debug)); | ||
489 | |||
490 | StatsManager.RegisterStat( | ||
491 | new PercentageStat( | ||
492 | "PacketDataBlocksReused", | ||
493 | "Packet data blocks reused", | ||
494 | "Number of data blocks reused out of all requests to the packet pool", | ||
495 | "clientstack", | ||
496 | m_scene.Name, | ||
497 | StatType.Pull, | ||
498 | stat => | ||
499 | { PercentageStat pstat = (PercentageStat)stat; | ||
500 | pstat.Consequent = PacketPool.Instance.BlocksRequested; | ||
501 | pstat.Antecedent = PacketPool.Instance.BlocksReused; }, | ||
502 | StatVerbosity.Debug)); | ||
503 | |||
504 | StatsManager.RegisterStat( | ||
505 | new Stat( | ||
506 | "PacketsPoolCount", | ||
507 | "Objects within the packet pool", | ||
508 | "The number of objects currently stored within the packet pool", | ||
509 | "", | ||
510 | "clientstack", | ||
511 | m_scene.Name, | ||
512 | StatType.Pull, | ||
513 | stat => stat.Value = PacketPool.Instance.PacketsPooled, | ||
514 | StatVerbosity.Debug)); | ||
515 | |||
516 | StatsManager.RegisterStat( | ||
517 | new Stat( | ||
518 | "PacketDataBlocksPoolCount", | ||
519 | "Objects within the packet data block pool", | ||
520 | "The number of objects currently stored within the packet data block pool", | ||
521 | "", | ||
522 | "clientstack", | ||
523 | m_scene.Name, | ||
524 | StatType.Pull, | ||
525 | stat => stat.Value = PacketPool.Instance.BlocksPooled, | ||
526 | StatVerbosity.Debug)); | ||
527 | |||
528 | // We delay enabling pool stats to AddScene() instead of Initialize() so that we can distinguish pool stats by | ||
529 | // scene name | ||
530 | if (UsePools) | ||
531 | EnablePoolStats(); | ||
532 | |||
373 | MainConsole.Instance.Commands.AddCommand( | 533 | MainConsole.Instance.Commands.AddCommand( |
374 | "Debug", | 534 | "Debug", |
375 | false, | 535 | false, |
@@ -397,6 +557,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
397 | MainConsole.Instance.Commands.AddCommand( | 557 | MainConsole.Instance.Commands.AddCommand( |
398 | "Debug", | 558 | "Debug", |
399 | false, | 559 | false, |
560 | "debug lludp pool", | ||
561 | "debug lludp pool <on|off>", | ||
562 | "Turn object pooling within the lludp component on or off.", | ||
563 | HandlePoolCommand); | ||
564 | |||
565 | MainConsole.Instance.Commands.AddCommand( | ||
566 | "Debug", | ||
567 | false, | ||
400 | "debug lludp status", | 568 | "debug lludp status", |
401 | "debug lludp status", | 569 | "debug lludp status", |
402 | "Return status of LLUDP packet processing.", | 570 | "Return status of LLUDP packet processing.", |
@@ -437,6 +605,38 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
437 | StopOutbound(); | 605 | StopOutbound(); |
438 | } | 606 | } |
439 | 607 | ||
608 | private void HandlePoolCommand(string module, string[] args) | ||
609 | { | ||
610 | if (args.Length != 4) | ||
611 | { | ||
612 | MainConsole.Instance.Output("Usage: debug lludp pool <on|off>"); | ||
613 | return; | ||
614 | } | ||
615 | |||
616 | string enabled = args[3]; | ||
617 | |||
618 | if (enabled == "on") | ||
619 | { | ||
620 | if (EnablePools()) | ||
621 | { | ||
622 | EnablePoolStats(); | ||
623 | MainConsole.Instance.OutputFormat("Packet pools enabled on {0}", m_scene.Name); | ||
624 | } | ||
625 | } | ||
626 | else if (enabled == "off") | ||
627 | { | ||
628 | if (DisablePools()) | ||
629 | { | ||
630 | DisablePoolStats(); | ||
631 | MainConsole.Instance.OutputFormat("Packet pools disabled on {0}", m_scene.Name); | ||
632 | } | ||
633 | } | ||
634 | else | ||
635 | { | ||
636 | MainConsole.Instance.Output("Usage: debug lludp pool <on|off>"); | ||
637 | } | ||
638 | } | ||
639 | |||
440 | private void HandleStatusCommand(string module, string[] args) | 640 | private void HandleStatusCommand(string module, string[] args) |
441 | { | 641 | { |
442 | MainConsole.Instance.OutputFormat( | 642 | MainConsole.Instance.OutputFormat( |
@@ -444,6 +644,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
444 | 644 | ||
445 | MainConsole.Instance.OutputFormat( | 645 | MainConsole.Instance.OutputFormat( |
446 | "OUT LLUDP packet processing for {0} is {1}", m_scene.Name, IsRunningOutbound ? "enabled" : "disabled"); | 646 | "OUT LLUDP packet processing for {0} is {1}", m_scene.Name, IsRunningOutbound ? "enabled" : "disabled"); |
647 | |||
648 | MainConsole.Instance.OutputFormat("LLUDP pools in {0} are {1}", m_scene.Name, UsePools ? "on" : "off"); | ||
447 | } | 649 | } |
448 | 650 | ||
449 | public bool HandlesRegion(Location x) | 651 | public bool HandlesRegion(Location x) |
@@ -1473,6 +1675,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1473 | private int npacksSent = 0; | 1675 | private int npacksSent = 0; |
1474 | private int npackNotSent = 0; | 1676 | private int npackNotSent = 0; |
1475 | 1677 | ||
1678 | /// <summary> | ||
1679 | /// Number of inbound packets processed since startup. | ||
1680 | /// </summary> | ||
1681 | public long IncomingPacketsProcessed { get; private set; } | ||
1682 | |||
1476 | private void MonitoredClientOutgoingPacketHandler(IClientAPI client) | 1683 | private void MonitoredClientOutgoingPacketHandler(IClientAPI client) |
1477 | { | 1684 | { |
1478 | nticks++; | 1685 | nticks++; |
@@ -1532,7 +1739,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1532 | npacksSent++; | 1739 | npacksSent++; |
1533 | } | 1740 | } |
1534 | else | 1741 | else |
1742 | { | ||
1535 | npackNotSent++; | 1743 | npackNotSent++; |
1744 | } | ||
1536 | 1745 | ||
1537 | watch2.Stop(); | 1746 | watch2.Stop(); |
1538 | avgDequeueTicks = (nticks - 1) / (float)nticks * avgDequeueTicks + (watch2.ElapsedTicks / (float)nticks); | 1747 | avgDequeueTicks = (nticks - 1) / (float)nticks * avgDequeueTicks + (watch2.ElapsedTicks / (float)nticks); |
@@ -1540,7 +1749,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1540 | 1749 | ||
1541 | } | 1750 | } |
1542 | else | 1751 | else |
1752 | { | ||
1543 | m_log.WarnFormat("[LLUDPSERVER]: Client is not connected"); | 1753 | m_log.WarnFormat("[LLUDPSERVER]: Client is not connected"); |
1754 | } | ||
1544 | } | 1755 | } |
1545 | } | 1756 | } |
1546 | catch (Exception ex) | 1757 | catch (Exception ex) |
@@ -1604,6 +1815,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
1604 | "[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}", | 1815 | "[LLUDPSERVER]: Dropped incoming {0} for dead client {1} in {2}", |
1605 | packet.Type, client.Name, m_scene.RegionInfo.RegionName); | 1816 | packet.Type, client.Name, m_scene.RegionInfo.RegionName); |
1606 | } | 1817 | } |
1818 | |||
1819 | IncomingPacketsProcessed++; | ||
1607 | } | 1820 | } |
1608 | 1821 | ||
1609 | protected void LogoutHandler(IClientAPI client) | 1822 | protected void LogoutHandler(IClientAPI client) |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs index 6e6b3ef..3f7ca2b 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/OpenSimUDPBase.cs | |||
@@ -31,6 +31,7 @@ using System.Net.Sockets; | |||
31 | using System.Threading; | 31 | using System.Threading; |
32 | using log4net; | 32 | using log4net; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Monitoring; | ||
34 | 35 | ||
35 | namespace OpenMetaverse | 36 | namespace OpenMetaverse |
36 | { | 37 | { |
@@ -60,14 +61,14 @@ namespace OpenMetaverse | |||
60 | private bool m_asyncPacketHandling; | 61 | private bool m_asyncPacketHandling; |
61 | 62 | ||
62 | /// <summary> | 63 | /// <summary> |
63 | /// Pool to use for handling data. May be null if UsePools = false; | 64 | /// Are we to use object pool(s) to reduce memory churn when receiving data? |
64 | /// </summary> | 65 | /// </summary> |
65 | protected OpenSim.Framework.Pool<UDPPacketBuffer> m_pool; | 66 | public bool UsePools { get; protected set; } |
66 | 67 | ||
67 | /// <summary> | 68 | /// <summary> |
68 | /// Are we to use object pool(s) to reduce memory churn when receiving data? | 69 | /// Pool to use for handling data. May be null if UsePools = false; |
69 | /// </summary> | 70 | /// </summary> |
70 | public bool UsePools { get; protected set; } | 71 | protected OpenSim.Framework.Pool<UDPPacketBuffer> Pool { get; private set; } |
71 | 72 | ||
72 | /// <summary>Returns true if the server is currently listening for inbound packets, otherwise false</summary> | 73 | /// <summary>Returns true if the server is currently listening for inbound packets, otherwise false</summary> |
73 | public bool IsRunningInbound { get; private set; } | 74 | public bool IsRunningInbound { get; private set; } |
@@ -106,11 +107,6 @@ namespace OpenMetaverse | |||
106 | /// necessary</remarks> | 107 | /// necessary</remarks> |
107 | public void StartInbound(int recvBufferSize, bool asyncPacketHandling) | 108 | public void StartInbound(int recvBufferSize, bool asyncPacketHandling) |
108 | { | 109 | { |
109 | if (UsePools) | ||
110 | m_pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500); | ||
111 | else | ||
112 | m_pool = null; | ||
113 | |||
114 | m_asyncPacketHandling = asyncPacketHandling; | 110 | m_asyncPacketHandling = asyncPacketHandling; |
115 | 111 | ||
116 | if (!IsRunningInbound) | 112 | if (!IsRunningInbound) |
@@ -180,12 +176,40 @@ namespace OpenMetaverse | |||
180 | IsRunningOutbound = false; | 176 | IsRunningOutbound = false; |
181 | } | 177 | } |
182 | 178 | ||
179 | protected virtual bool EnablePools() | ||
180 | { | ||
181 | if (!UsePools) | ||
182 | { | ||
183 | Pool = new Pool<UDPPacketBuffer>(() => new UDPPacketBuffer(), 500); | ||
184 | |||
185 | UsePools = true; | ||
186 | |||
187 | return true; | ||
188 | } | ||
189 | |||
190 | return false; | ||
191 | } | ||
192 | |||
193 | protected virtual bool DisablePools() | ||
194 | { | ||
195 | if (UsePools) | ||
196 | { | ||
197 | UsePools = false; | ||
198 | |||
199 | // We won't null out the pool to avoid a race condition with code that may be in the middle of using it. | ||
200 | |||
201 | return true; | ||
202 | } | ||
203 | |||
204 | return false; | ||
205 | } | ||
206 | |||
183 | private void AsyncBeginReceive() | 207 | private void AsyncBeginReceive() |
184 | { | 208 | { |
185 | UDPPacketBuffer buf; | 209 | UDPPacketBuffer buf; |
186 | 210 | ||
187 | if (UsePools) | 211 | if (UsePools) |
188 | buf = m_pool.GetObject(); | 212 | buf = Pool.GetObject(); |
189 | else | 213 | else |
190 | buf = new UDPPacketBuffer(); | 214 | buf = new UDPPacketBuffer(); |
191 | 215 | ||
@@ -268,7 +292,7 @@ namespace OpenMetaverse | |||
268 | finally | 292 | finally |
269 | { | 293 | { |
270 | if (UsePools) | 294 | if (UsePools) |
271 | m_pool.ReturnObject(buffer); | 295 | Pool.ReturnObject(buffer); |
272 | 296 | ||
273 | // Synchronous mode waits until the packet callback completes | 297 | // Synchronous mode waits until the packet callback completes |
274 | // before starting the receive to fetch another packet | 298 | // before starting the receive to fetch another packet |
@@ -310,4 +334,4 @@ namespace OpenMetaverse | |||
310 | catch (ObjectDisposedException) { } | 334 | catch (ObjectDisposedException) { } |
311 | } | 335 | } |
312 | } | 336 | } |
313 | } | 337 | } \ No newline at end of file |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs index 2a3d14f..1fdc410 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/PacketPool.cs | |||
@@ -41,25 +41,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
41 | 41 | ||
42 | private static readonly PacketPool instance = new PacketPool(); | 42 | private static readonly PacketPool instance = new PacketPool(); |
43 | 43 | ||
44 | private bool packetPoolEnabled = true; | ||
45 | private bool dataBlockPoolEnabled = true; | ||
46 | |||
47 | private PercentageStat m_packetsReusedStat = new PercentageStat( | ||
48 | "PacketsReused", | ||
49 | "Packets reused", | ||
50 | "clientstack", | ||
51 | "packetpool", | ||
52 | StatVerbosity.Debug, | ||
53 | "Number of packets reused out of all requests to the packet pool"); | ||
54 | |||
55 | private PercentageStat m_blocksReusedStat = new PercentageStat( | ||
56 | "BlocksReused", | ||
57 | "Blocks reused", | ||
58 | "clientstack", | ||
59 | "packetpool", | ||
60 | StatVerbosity.Debug, | ||
61 | "Number of data blocks reused out of all requests to the packet pool"); | ||
62 | |||
63 | /// <summary> | 44 | /// <summary> |
64 | /// Pool of packets available for reuse. | 45 | /// Pool of packets available for reuse. |
65 | /// </summary> | 46 | /// </summary> |
@@ -72,22 +53,59 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
72 | get { return instance; } | 53 | get { return instance; } |
73 | } | 54 | } |
74 | 55 | ||
75 | public bool RecyclePackets | 56 | public bool RecyclePackets { get; set; } |
57 | |||
58 | public bool RecycleDataBlocks { get; set; } | ||
59 | |||
60 | /// <summary> | ||
61 | /// The number of packets pooled | ||
62 | /// </summary> | ||
63 | public int PacketsPooled | ||
76 | { | 64 | { |
77 | set { packetPoolEnabled = value; } | 65 | get |
78 | get { return packetPoolEnabled; } | 66 | { |
67 | lock (pool) | ||
68 | return pool.Count; | ||
69 | } | ||
79 | } | 70 | } |
80 | 71 | ||
81 | public bool RecycleDataBlocks | 72 | /// <summary> |
73 | /// The number of blocks pooled. | ||
74 | /// </summary> | ||
75 | public int BlocksPooled | ||
82 | { | 76 | { |
83 | set { dataBlockPoolEnabled = value; } | 77 | get |
84 | get { return dataBlockPoolEnabled; } | 78 | { |
79 | lock (DataBlocks) | ||
80 | return DataBlocks.Count; | ||
81 | } | ||
85 | } | 82 | } |
86 | 83 | ||
84 | /// <summary> | ||
85 | /// Number of packets requested. | ||
86 | /// </summary> | ||
87 | public long PacketsRequested { get; private set; } | ||
88 | |||
89 | /// <summary> | ||
90 | /// Number of packets reused. | ||
91 | /// </summary> | ||
92 | public long PacketsReused { get; private set; } | ||
93 | |||
94 | /// <summary> | ||
95 | /// Number of packet blocks requested. | ||
96 | /// </summary> | ||
97 | public long BlocksRequested { get; private set; } | ||
98 | |||
99 | /// <summary> | ||
100 | /// Number of packet blocks reused. | ||
101 | /// </summary> | ||
102 | public long BlocksReused { get; private set; } | ||
103 | |||
87 | private PacketPool() | 104 | private PacketPool() |
88 | { | 105 | { |
89 | StatsManager.RegisterStat(m_packetsReusedStat); | 106 | // defaults |
90 | StatsManager.RegisterStat(m_blocksReusedStat); | 107 | RecyclePackets = true; |
108 | RecycleDataBlocks = true; | ||
91 | } | 109 | } |
92 | 110 | ||
93 | /// <summary> | 111 | /// <summary> |
@@ -97,11 +115,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
97 | /// <returns>Guaranteed to always return a packet, whether from the pool or newly constructed.</returns> | 115 | /// <returns>Guaranteed to always return a packet, whether from the pool or newly constructed.</returns> |
98 | public Packet GetPacket(PacketType type) | 116 | public Packet GetPacket(PacketType type) |
99 | { | 117 | { |
100 | m_packetsReusedStat.Consequent++; | 118 | PacketsRequested++; |
101 | 119 | ||
102 | Packet packet; | 120 | Packet packet; |
103 | 121 | ||
104 | if (!packetPoolEnabled) | 122 | if (!RecyclePackets) |
105 | return Packet.BuildPacket(type); | 123 | return Packet.BuildPacket(type); |
106 | 124 | ||
107 | lock (pool) | 125 | lock (pool) |
@@ -118,7 +136,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
118 | // m_log.DebugFormat("[PACKETPOOL]: Pulling {0} packet", type); | 136 | // m_log.DebugFormat("[PACKETPOOL]: Pulling {0} packet", type); |
119 | 137 | ||
120 | // Recycle old packages | 138 | // Recycle old packages |
121 | m_packetsReusedStat.Antecedent++; | 139 | PacketsReused++; |
122 | 140 | ||
123 | packet = pool[type].Pop(); | 141 | packet = pool[type].Pop(); |
124 | } | 142 | } |
@@ -187,7 +205,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
187 | /// <param name="packet"></param> | 205 | /// <param name="packet"></param> |
188 | public void ReturnPacket(Packet packet) | 206 | public void ReturnPacket(Packet packet) |
189 | { | 207 | { |
190 | if (dataBlockPoolEnabled) | 208 | if (RecycleDataBlocks) |
191 | { | 209 | { |
192 | switch (packet.Type) | 210 | switch (packet.Type) |
193 | { | 211 | { |
@@ -211,7 +229,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
211 | } | 229 | } |
212 | } | 230 | } |
213 | 231 | ||
214 | if (packetPoolEnabled) | 232 | if (RecyclePackets) |
215 | { | 233 | { |
216 | switch (packet.Type) | 234 | switch (packet.Type) |
217 | { | 235 | { |
@@ -249,7 +267,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
249 | { | 267 | { |
250 | lock (DataBlocks) | 268 | lock (DataBlocks) |
251 | { | 269 | { |
252 | m_blocksReusedStat.Consequent++; | 270 | BlocksRequested++; |
253 | 271 | ||
254 | Stack<Object> s; | 272 | Stack<Object> s; |
255 | 273 | ||
@@ -257,7 +275,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
257 | { | 275 | { |
258 | if (s.Count > 0) | 276 | if (s.Count > 0) |
259 | { | 277 | { |
260 | m_blocksReusedStat.Antecedent++; | 278 | BlocksReused++; |
261 | return (T)s.Pop(); | 279 | return (T)s.Pop(); |
262 | } | 280 | } |
263 | } | 281 | } |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Properties/AssemblyInfo.cs b/OpenSim/Region/ClientStack/Linden/UDP/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..af2f6f8 --- /dev/null +++ b/OpenSim/Region/ClientStack/Linden/UDP/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.ClientStack.LindenUDP")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("9d3dbc6b-9d85-483b-af48-c1dfc261b7ac")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs index 5fcf376..7d9f581 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/LLImageManagerTests.cs | |||
@@ -43,7 +43,7 @@ using OpenSim.Tests.Common.Mock; | |||
43 | namespace OpenSim.Region.ClientStack.LindenUDP.Tests | 43 | namespace OpenSim.Region.ClientStack.LindenUDP.Tests |
44 | { | 44 | { |
45 | [TestFixture] | 45 | [TestFixture] |
46 | public class LLImageManagerTests | 46 | public class LLImageManagerTests : OpenSimTestCase |
47 | { | 47 | { |
48 | private AssetBase m_testImageAsset; | 48 | private AssetBase m_testImageAsset; |
49 | private Scene scene; | 49 | private Scene scene; |
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/PacketHandlerTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/PacketHandlerTests.cs index 0f88ec6..5f73a94 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/PacketHandlerTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/PacketHandlerTests.cs | |||
@@ -39,7 +39,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
39 | /// Tests for the LL packet handler | 39 | /// Tests for the LL packet handler |
40 | /// </summary> | 40 | /// </summary> |
41 | [TestFixture] | 41 | [TestFixture] |
42 | public class PacketHandlerTests | 42 | public class PacketHandlerTests : OpenSimTestCase |
43 | { | 43 | { |
44 | // [Test] | 44 | // [Test] |
45 | // /// <summary> | 45 | // /// <summary> |
diff --git a/OpenSim/Region/ClientStack/Properties/AssemblyInfo.cs b/OpenSim/Region/ClientStack/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e72bd86 --- /dev/null +++ b/OpenSim/Region/ClientStack/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.ClientStack")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSIm")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("02ced54a-a802-4474-9e94-f03a44fde922")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs index 73d1f72..e973652 100644 --- a/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs +++ b/OpenSim/Region/CoreModules/Agent/AssetTransaction/AssetTransactionModule.cs | |||
@@ -54,7 +54,7 @@ namespace OpenSim.Region.CoreModules.Agent.AssetTransaction | |||
54 | private Dictionary<UUID, AgentAssetTransactions> AgentTransactions = | 54 | private Dictionary<UUID, AgentAssetTransactions> AgentTransactions = |
55 | new Dictionary<UUID, AgentAssetTransactions>(); | 55 | new Dictionary<UUID, AgentAssetTransactions>(); |
56 | 56 | ||
57 | #region IRegionModule Members | 57 | #region Region Module interface |
58 | 58 | ||
59 | public void Initialise(IConfigSource source) | 59 | public void Initialise(IConfigSource source) |
60 | { | 60 | { |
diff --git a/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs b/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs index bfe2a71..4b457b1 100644 --- a/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs +++ b/OpenSim/Region/CoreModules/Agent/IPBan/IPBanModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Text; | 31 | using System.Text; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
@@ -36,13 +37,18 @@ using OpenSim.Region.Framework.Scenes; | |||
36 | 37 | ||
37 | namespace OpenSim.Region.CoreModules.Agent.IPBan | 38 | namespace OpenSim.Region.CoreModules.Agent.IPBan |
38 | { | 39 | { |
39 | public class IPBanModule : IRegionModule | 40 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "IPBanModule")] |
41 | public class IPBanModule : ISharedRegionModule | ||
40 | { | 42 | { |
41 | #region Implementation of IRegionModule | 43 | #region Implementation of ISharedRegionModule |
42 | 44 | ||
43 | private List<string> m_bans = new List<string>(); | 45 | private List<string> m_bans = new List<string>(); |
44 | 46 | ||
45 | public void Initialise(Scene scene, IConfigSource source) | 47 | public void Initialise(IConfigSource source) |
48 | { | ||
49 | } | ||
50 | |||
51 | public void AddRegion(Scene scene) | ||
46 | { | 52 | { |
47 | new SceneBanner(scene, m_bans); | 53 | new SceneBanner(scene, m_bans); |
48 | 54 | ||
@@ -50,7 +56,7 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan | |||
50 | { | 56 | { |
51 | foreach (EstateBan ban in scene.RegionInfo.EstateSettings.EstateBans) | 57 | foreach (EstateBan ban in scene.RegionInfo.EstateSettings.EstateBans) |
52 | { | 58 | { |
53 | if (!String.IsNullOrEmpty(ban.BannedHostIPMask)) | 59 | if (!String.IsNullOrEmpty(ban.BannedHostIPMask)) |
54 | m_bans.Add(ban.BannedHostIPMask); | 60 | m_bans.Add(ban.BannedHostIPMask); |
55 | if (!String.IsNullOrEmpty(ban.BannedHostNameMask)) | 61 | if (!String.IsNullOrEmpty(ban.BannedHostNameMask)) |
56 | m_bans.Add(ban.BannedHostNameMask); | 62 | m_bans.Add(ban.BannedHostNameMask); |
@@ -58,6 +64,14 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan | |||
58 | } | 64 | } |
59 | } | 65 | } |
60 | 66 | ||
67 | public void RemoveRegion(Scene scene) | ||
68 | { | ||
69 | } | ||
70 | |||
71 | public void RegionLoaded(Scene scene) | ||
72 | { | ||
73 | } | ||
74 | |||
61 | public void PostInitialise() | 75 | public void PostInitialise() |
62 | { | 76 | { |
63 | if (File.Exists("bans.txt")) | 77 | if (File.Exists("bans.txt")) |
@@ -80,9 +94,9 @@ namespace OpenSim.Region.CoreModules.Agent.IPBan | |||
80 | get { return "IPBanModule"; } | 94 | get { return "IPBanModule"; } |
81 | } | 95 | } |
82 | 96 | ||
83 | public bool IsSharedModule | 97 | public Type ReplaceableInterface |
84 | { | 98 | { |
85 | get { return true; } | 99 | get { return null; } |
86 | } | 100 | } |
87 | 101 | ||
88 | #endregion | 102 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs index a1a2501..3764685 100644 --- a/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs +++ b/OpenSim/Region/CoreModules/Agent/TextureSender/J2KDecoderModule.cs | |||
@@ -32,6 +32,7 @@ using System.Reflection; | |||
32 | using System.Text; | 32 | using System.Text; |
33 | using System.Threading; | 33 | using System.Threading; |
34 | using log4net; | 34 | using log4net; |
35 | using Mono.Addins; | ||
35 | using Nini.Config; | 36 | using Nini.Config; |
36 | using OpenMetaverse; | 37 | using OpenMetaverse; |
37 | using OpenMetaverse.Imaging; | 38 | using OpenMetaverse.Imaging; |
@@ -45,7 +46,8 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
45 | { | 46 | { |
46 | public delegate void J2KDecodeDelegate(UUID assetID); | 47 | public delegate void J2KDecodeDelegate(UUID assetID); |
47 | 48 | ||
48 | public class J2KDecoderModule : IRegionModule, IJ2KDecoder | 49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "J2KDecoderModule")] |
50 | public class J2KDecoderModule : ISharedRegionModule, IJ2KDecoder | ||
49 | { | 51 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
51 | 53 | ||
@@ -55,27 +57,32 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
55 | private readonly Dictionary<UUID, List<DecodedCallback>> m_notifyList = new Dictionary<UUID, List<DecodedCallback>>(); | 57 | private readonly Dictionary<UUID, List<DecodedCallback>> m_notifyList = new Dictionary<UUID, List<DecodedCallback>>(); |
56 | /// <summary>Cache that will store decoded JPEG2000 layer boundary data</summary> | 58 | /// <summary>Cache that will store decoded JPEG2000 layer boundary data</summary> |
57 | private IImprovedAssetCache m_cache; | 59 | private IImprovedAssetCache m_cache; |
60 | private IImprovedAssetCache Cache | ||
61 | { | ||
62 | get | ||
63 | { | ||
64 | if (m_cache == null) | ||
65 | m_cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); | ||
66 | |||
67 | return m_cache; | ||
68 | } | ||
69 | } | ||
58 | /// <summary>Reference to a scene (doesn't matter which one as long as it can load the cache module)</summary> | 70 | /// <summary>Reference to a scene (doesn't matter which one as long as it can load the cache module)</summary> |
71 | private UUID m_CreatorID = UUID.Zero; | ||
59 | private Scene m_scene; | 72 | private Scene m_scene; |
60 | 73 | ||
61 | #region IRegionModule | 74 | #region ISharedRegionModule |
62 | 75 | ||
63 | private bool m_useCSJ2K = true; | 76 | private bool m_useCSJ2K = true; |
64 | 77 | ||
65 | public string Name { get { return "J2KDecoderModule"; } } | 78 | public string Name { get { return "J2KDecoderModule"; } } |
66 | public bool IsSharedModule { get { return true; } } | ||
67 | 79 | ||
68 | public J2KDecoderModule() | 80 | public J2KDecoderModule() |
69 | { | 81 | { |
70 | } | 82 | } |
71 | 83 | ||
72 | public void Initialise(Scene scene, IConfigSource source) | 84 | public void Initialise(IConfigSource source) |
73 | { | 85 | { |
74 | if (m_scene == null) | ||
75 | m_scene = scene; | ||
76 | |||
77 | scene.RegisterModuleInterface<IJ2KDecoder>(this); | ||
78 | |||
79 | IConfig startupConfig = source.Configs["Startup"]; | 86 | IConfig startupConfig = source.Configs["Startup"]; |
80 | if (startupConfig != null) | 87 | if (startupConfig != null) |
81 | { | 88 | { |
@@ -83,16 +90,42 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
83 | } | 90 | } |
84 | } | 91 | } |
85 | 92 | ||
93 | public void AddRegion(Scene scene) | ||
94 | { | ||
95 | if (m_scene == null) | ||
96 | { | ||
97 | m_scene = scene; | ||
98 | m_CreatorID = scene.RegionInfo.RegionID; | ||
99 | } | ||
100 | |||
101 | scene.RegisterModuleInterface<IJ2KDecoder>(this); | ||
102 | |||
103 | } | ||
104 | |||
105 | public void RemoveRegion(Scene scene) | ||
106 | { | ||
107 | if (m_scene == scene) | ||
108 | m_scene = null; | ||
109 | } | ||
110 | |||
86 | public void PostInitialise() | 111 | public void PostInitialise() |
87 | { | 112 | { |
88 | m_cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); | ||
89 | } | 113 | } |
90 | 114 | ||
91 | public void Close() | 115 | public void Close() |
92 | { | 116 | { |
93 | } | 117 | } |
94 | 118 | ||
95 | #endregion IRegionModule | 119 | public void RegionLoaded(Scene scene) |
120 | { | ||
121 | } | ||
122 | |||
123 | public Type ReplaceableInterface | ||
124 | { | ||
125 | get { return null; } | ||
126 | } | ||
127 | |||
128 | #endregion Region Module interface | ||
96 | 129 | ||
97 | #region IJ2KDecoder | 130 | #region IJ2KDecoder |
98 | 131 | ||
@@ -275,11 +308,11 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
275 | { | 308 | { |
276 | m_decodedCache.AddOrUpdate(AssetId, Layers, TimeSpan.FromMinutes(10)); | 309 | m_decodedCache.AddOrUpdate(AssetId, Layers, TimeSpan.FromMinutes(10)); |
277 | 310 | ||
278 | if (m_cache != null) | 311 | if (Cache != null) |
279 | { | 312 | { |
280 | string assetID = "j2kCache_" + AssetId.ToString(); | 313 | string assetID = "j2kCache_" + AssetId.ToString(); |
281 | 314 | ||
282 | AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard, m_scene.RegionInfo.RegionID.ToString()); | 315 | AssetBase layerDecodeAsset = new AssetBase(assetID, assetID, (sbyte)AssetType.Notecard, m_CreatorID.ToString()); |
283 | layerDecodeAsset.Local = true; | 316 | layerDecodeAsset.Local = true; |
284 | layerDecodeAsset.Temporary = true; | 317 | layerDecodeAsset.Temporary = true; |
285 | 318 | ||
@@ -299,7 +332,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
299 | 332 | ||
300 | #endregion Serialize Layer Data | 333 | #endregion Serialize Layer Data |
301 | 334 | ||
302 | m_cache.Cache(layerDecodeAsset); | 335 | Cache.Cache(layerDecodeAsset); |
303 | } | 336 | } |
304 | } | 337 | } |
305 | 338 | ||
@@ -309,10 +342,10 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
309 | { | 342 | { |
310 | return true; | 343 | return true; |
311 | } | 344 | } |
312 | else if (m_cache != null) | 345 | else if (Cache != null) |
313 | { | 346 | { |
314 | string assetName = "j2kCache_" + AssetId.ToString(); | 347 | string assetName = "j2kCache_" + AssetId.ToString(); |
315 | AssetBase layerDecodeAsset = m_cache.Get(assetName); | 348 | AssetBase layerDecodeAsset = Cache.Get(assetName); |
316 | 349 | ||
317 | if (layerDecodeAsset != null) | 350 | if (layerDecodeAsset != null) |
318 | { | 351 | { |
@@ -324,7 +357,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
324 | if (lines.Length == 0) | 357 | if (lines.Length == 0) |
325 | { | 358 | { |
326 | m_log.Warn("[J2KDecodeCache]: Expiring corrupted layer data (empty) " + assetName); | 359 | m_log.Warn("[J2KDecodeCache]: Expiring corrupted layer data (empty) " + assetName); |
327 | m_cache.Expire(assetName); | 360 | Cache.Expire(assetName); |
328 | return false; | 361 | return false; |
329 | } | 362 | } |
330 | 363 | ||
@@ -345,7 +378,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
345 | catch (FormatException) | 378 | catch (FormatException) |
346 | { | 379 | { |
347 | m_log.Warn("[J2KDecodeCache]: Expiring corrupted layer data (format) " + assetName); | 380 | m_log.Warn("[J2KDecodeCache]: Expiring corrupted layer data (format) " + assetName); |
348 | m_cache.Expire(assetName); | 381 | Cache.Expire(assetName); |
349 | return false; | 382 | return false; |
350 | } | 383 | } |
351 | 384 | ||
@@ -356,7 +389,7 @@ namespace OpenSim.Region.CoreModules.Agent.TextureSender | |||
356 | else | 389 | else |
357 | { | 390 | { |
358 | m_log.Warn("[J2KDecodeCache]: Expiring corrupted layer data (layout) " + assetName); | 391 | m_log.Warn("[J2KDecodeCache]: Expiring corrupted layer data (layout) " + assetName); |
359 | m_cache.Expire(assetName); | 392 | Cache.Expire(assetName); |
360 | return false; | 393 | return false; |
361 | } | 394 | } |
362 | } | 395 | } |
diff --git a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs index b8e2820..4299726 100644 --- a/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs +++ b/OpenSim/Region/CoreModules/Agent/Xfer/XferModule.cs | |||
@@ -35,9 +35,12 @@ using OpenSim.Framework; | |||
35 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
37 | 37 | ||
38 | using Mono.Addins; | ||
39 | |||
38 | namespace OpenSim.Region.CoreModules.Agent.Xfer | 40 | namespace OpenSim.Region.CoreModules.Agent.Xfer |
39 | { | 41 | { |
40 | public class XferModule : IRegionModule, IXfer | 42 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XferModule")] |
43 | public class XferModule : INonSharedRegionModule, IXfer | ||
41 | { | 44 | { |
42 | private Scene m_scene; | 45 | private Scene m_scene; |
43 | private Dictionary<string, FileData> NewFiles = new Dictionary<string, FileData>(); | 46 | private Dictionary<string, FileData> NewFiles = new Dictionary<string, FileData>(); |
@@ -59,9 +62,13 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
59 | public int Count; | 62 | public int Count; |
60 | } | 63 | } |
61 | 64 | ||
62 | #region IRegionModule Members | 65 | #region INonSharedRegionModule Members |
66 | |||
67 | public void Initialise(IConfigSource config) | ||
68 | { | ||
69 | } | ||
63 | 70 | ||
64 | public void Initialise(Scene scene, IConfigSource config) | 71 | public void AddRegion(Scene scene) |
65 | { | 72 | { |
66 | m_scene = scene; | 73 | m_scene = scene; |
67 | m_scene.EventManager.OnNewClient += NewClient; | 74 | m_scene.EventManager.OnNewClient += NewClient; |
@@ -69,22 +76,30 @@ namespace OpenSim.Region.CoreModules.Agent.Xfer | |||
69 | m_scene.RegisterModuleInterface<IXfer>(this); | 76 | m_scene.RegisterModuleInterface<IXfer>(this); |
70 | } | 77 | } |
71 | 78 | ||
72 | public void PostInitialise() | 79 | public void RemoveRegion(Scene scene) |
73 | { | 80 | { |
81 | m_scene.EventManager.OnNewClient -= NewClient; | ||
82 | |||
83 | m_scene.UnregisterModuleInterface<IXfer>(this); | ||
84 | m_scene = null; | ||
74 | } | 85 | } |
75 | 86 | ||
76 | public void Close() | 87 | public void RegionLoaded(Scene scene) |
77 | { | 88 | { |
78 | } | 89 | } |
79 | 90 | ||
80 | public string Name | 91 | public Type ReplaceableInterface |
81 | { | 92 | { |
82 | get { return "XferModule"; } | 93 | get { return null; } |
83 | } | 94 | } |
84 | 95 | ||
85 | public bool IsSharedModule | 96 | public void Close() |
86 | { | 97 | { |
87 | get { return false; } | 98 | } |
99 | |||
100 | public string Name | ||
101 | { | ||
102 | get { return "XferModule"; } | ||
88 | } | 103 | } |
89 | 104 | ||
90 | #endregion | 105 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs index b1b7b27..e40caec 100644 --- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using log4net; | 30 | using log4net; |
31 | using Mono.Addins; | ||
31 | using Nini.Config; | 32 | using Nini.Config; |
32 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
33 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
@@ -89,6 +90,7 @@ namespace OpenSim.Region.CoreModules.Asset | |||
89 | /// ExpirationTime = 60 | 90 | /// ExpirationTime = 60 |
90 | /// </code> | 91 | /// </code> |
91 | /// </example> | 92 | /// </example> |
93 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "CenomeMemoryAssetCache")] | ||
92 | public class CenomeMemoryAssetCache : IImprovedAssetCache, ISharedRegionModule | 94 | public class CenomeMemoryAssetCache : IImprovedAssetCache, ISharedRegionModule |
93 | { | 95 | { |
94 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 96 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs index 7da5e7a..9742a5c 100644 --- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs | |||
@@ -30,6 +30,7 @@ using System; | |||
30 | using System.IO; | 30 | using System.IO; |
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using Mono.Addins; | ||
33 | using Nini.Config; | 34 | using Nini.Config; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
35 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
@@ -38,6 +39,7 @@ using OpenSim.Services.Interfaces; | |||
38 | 39 | ||
39 | namespace OpenSim.Region.CoreModules.Asset | 40 | namespace OpenSim.Region.CoreModules.Asset |
40 | { | 41 | { |
42 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "CoreAssetCache")] | ||
41 | public class CoreAssetCache : ISharedRegionModule, IImprovedAssetCache | 43 | public class CoreAssetCache : ISharedRegionModule, IImprovedAssetCache |
42 | { | 44 | { |
43 | private static readonly ILog m_log = | 45 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 8aa173a..8e800cb 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -49,12 +49,12 @@ using OpenSim.Region.Framework.Scenes; | |||
49 | using OpenSim.Services.Interfaces; | 49 | using OpenSim.Services.Interfaces; |
50 | 50 | ||
51 | 51 | ||
52 | [assembly: Addin("FlotsamAssetCache", "1.1")] | 52 | //[assembly: Addin("FlotsamAssetCache", "1.1")] |
53 | [assembly: AddinDependency("OpenSim", "0.5")] | 53 | //[assembly: AddinDependency("OpenSim", "0.5")] |
54 | 54 | ||
55 | namespace OpenSim.Region.CoreModules.Asset | 55 | namespace OpenSim.Region.CoreModules.Asset |
56 | { | 56 | { |
57 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 57 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "FlotsamAssetCache")] |
58 | public class FlotsamAssetCache : ISharedRegionModule, IImprovedAssetCache, IAssetService | 58 | public class FlotsamAssetCache : ISharedRegionModule, IImprovedAssetCache, IAssetService |
59 | { | 59 | { |
60 | private static readonly ILog m_log = | 60 | private static readonly ILog m_log = |
@@ -222,10 +222,6 @@ namespace OpenSim.Region.CoreModules.Asset | |||
222 | scene.RegisterModuleInterface<IImprovedAssetCache>(this); | 222 | scene.RegisterModuleInterface<IImprovedAssetCache>(this); |
223 | m_Scenes.Add(scene); | 223 | m_Scenes.Add(scene); |
224 | 224 | ||
225 | if (m_AssetService == null) | ||
226 | { | ||
227 | m_AssetService = scene.RequestModuleInterface<IAssetService>(); | ||
228 | } | ||
229 | } | 225 | } |
230 | } | 226 | } |
231 | 227 | ||
@@ -240,6 +236,8 @@ namespace OpenSim.Region.CoreModules.Asset | |||
240 | 236 | ||
241 | public void RegionLoaded(Scene scene) | 237 | public void RegionLoaded(Scene scene) |
242 | { | 238 | { |
239 | if (m_Enabled && m_AssetService == null) | ||
240 | m_AssetService = scene.RequestModuleInterface<IAssetService>(); | ||
243 | } | 241 | } |
244 | 242 | ||
245 | //////////////////////////////////////////////////////////// | 243 | //////////////////////////////////////////////////////////// |
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs index 1365e69..9592ca0 100644 --- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs | |||
@@ -31,6 +31,7 @@ using System.IO; | |||
31 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using GlynnTucker.Cache; | 33 | using GlynnTucker.Cache; |
34 | using Mono.Addins; | ||
34 | using Nini.Config; | 35 | using Nini.Config; |
35 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
@@ -39,6 +40,7 @@ using OpenSim.Services.Interfaces; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.Asset | 41 | namespace OpenSim.Region.CoreModules.Asset |
41 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GlynnTuckerAssetCache")] | ||
42 | public class GlynnTuckerAssetCache : ISharedRegionModule, IImprovedAssetCache | 44 | public class GlynnTuckerAssetCache : ISharedRegionModule, IImprovedAssetCache |
43 | { | 45 | { |
44 | private static readonly ILog m_log = | 46 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs index 1c2bfd0..0872cc8 100644 --- a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs +++ b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs | |||
@@ -47,7 +47,7 @@ namespace OpenSim.Region.CoreModules.Asset.Tests | |||
47 | /// At the moment we're only test the in-memory part of the FlotsamAssetCache. This is a considerable weakness. | 47 | /// At the moment we're only test the in-memory part of the FlotsamAssetCache. This is a considerable weakness. |
48 | /// </summary> | 48 | /// </summary> |
49 | [TestFixture] | 49 | [TestFixture] |
50 | public class FlotsamAssetCacheTests | 50 | public class FlotsamAssetCacheTests : OpenSimTestCase |
51 | { | 51 | { |
52 | protected TestScene m_scene; | 52 | protected TestScene m_scene; |
53 | protected FlotsamAssetCache m_cache; | 53 | protected FlotsamAssetCache m_cache; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs index 2a513e9..24170fc 100644 --- a/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs | |||
@@ -571,9 +571,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments | |||
571 | 571 | ||
572 | if (grp.HasGroupChanged) | 572 | if (grp.HasGroupChanged) |
573 | { | 573 | { |
574 | // m_log.DebugFormat( | 574 | m_log.DebugFormat( |
575 | // "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", | 575 | "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}", |
576 | // grp.UUID, grp.AttachmentPoint); | 576 | grp.UUID, grp.AttachmentPoint); |
577 | 577 | ||
578 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, scriptedState); | 578 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp, scriptedState); |
579 | 579 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index b5b0082..0a69979 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -39,9 +39,12 @@ using OpenSim.Region.Framework.Interfaces; | |||
39 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | 41 | ||
42 | using Mono.Addins; | ||
43 | |||
42 | namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | 44 | namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory |
43 | { | 45 | { |
44 | public class AvatarFactoryModule : IAvatarFactoryModule, IRegionModule | 46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AvatarFactoryModule")] |
47 | public class AvatarFactoryModule : IAvatarFactoryModule, INonSharedRegionModule | ||
45 | { | 48 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 50 | ||
@@ -59,12 +62,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
59 | 62 | ||
60 | private object m_setAppearanceLock = new object(); | 63 | private object m_setAppearanceLock = new object(); |
61 | 64 | ||
62 | #region IRegionModule | 65 | #region Region Module interface |
63 | 66 | ||
64 | public void Initialise(Scene scene, IConfigSource config) | 67 | public void Initialise(IConfigSource config) |
65 | { | 68 | { |
66 | scene.RegisterModuleInterface<IAvatarFactoryModule>(this); | ||
67 | scene.EventManager.OnNewClient += SubscribeToClientEvents; | ||
68 | 69 | ||
69 | IConfig appearanceConfig = config.Configs["Appearance"]; | 70 | IConfig appearanceConfig = config.Configs["Appearance"]; |
70 | if (appearanceConfig != null) | 71 | if (appearanceConfig != null) |
@@ -74,11 +75,29 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
74 | // m_log.InfoFormat("[AVFACTORY] configured for {0} save and {1} send",m_savetime,m_sendtime); | 75 | // m_log.InfoFormat("[AVFACTORY] configured for {0} save and {1} send",m_savetime,m_sendtime); |
75 | } | 76 | } |
76 | 77 | ||
78 | } | ||
79 | |||
80 | public void AddRegion(Scene scene) | ||
81 | { | ||
77 | if (m_scene == null) | 82 | if (m_scene == null) |
78 | m_scene = scene; | 83 | m_scene = scene; |
84 | |||
85 | scene.RegisterModuleInterface<IAvatarFactoryModule>(this); | ||
86 | scene.EventManager.OnNewClient += SubscribeToClientEvents; | ||
79 | } | 87 | } |
80 | 88 | ||
81 | public void PostInitialise() | 89 | public void RemoveRegion(Scene scene) |
90 | { | ||
91 | if (scene == m_scene) | ||
92 | { | ||
93 | scene.UnregisterModuleInterface<IAvatarFactoryModule>(this); | ||
94 | scene.EventManager.OnNewClient -= SubscribeToClientEvents; | ||
95 | } | ||
96 | |||
97 | m_scene = null; | ||
98 | } | ||
99 | |||
100 | public void RegionLoaded(Scene scene) | ||
82 | { | 101 | { |
83 | m_updateTimer.Enabled = false; | 102 | m_updateTimer.Enabled = false; |
84 | m_updateTimer.AutoReset = true; | 103 | m_updateTimer.AutoReset = true; |
@@ -100,6 +119,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
100 | get { return false; } | 119 | get { return false; } |
101 | } | 120 | } |
102 | 121 | ||
122 | public Type ReplaceableInterface | ||
123 | { | ||
124 | get { return null; } | ||
125 | } | ||
126 | |||
127 | |||
103 | private void SubscribeToClientEvents(IClientAPI client) | 128 | private void SubscribeToClientEvents(IClientAPI client) |
104 | { | 129 | { |
105 | client.OnRequestWearables += Client_OnRequestWearables; | 130 | client.OnRequestWearables += Client_OnRequestWearables; |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs index 848b3bf..1830d41 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/Tests/AvatarFactoryModuleTests.cs | |||
@@ -39,7 +39,7 @@ using OpenSim.Tests.Common.Mock; | |||
39 | namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | 39 | namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory |
40 | { | 40 | { |
41 | [TestFixture] | 41 | [TestFixture] |
42 | public class AvatarFactoryModuleTests | 42 | public class AvatarFactoryModuleTests : OpenSimTestCase |
43 | { | 43 | { |
44 | /// <summary> | 44 | /// <summary> |
45 | /// Only partial right now since we don't yet test that it's ended up in the avatar appearance service. | 45 | /// Only partial right now since we don't yet test that it's ended up in the avatar appearance service. |
diff --git a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs index e4452fb..6d62ff0 100644 --- a/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Chat/ChatModule.cs | |||
@@ -30,6 +30,7 @@ using System.Collections.Generic; | |||
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using Mono.Addins; | ||
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
35 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
@@ -37,6 +38,7 @@ using OpenSim.Region.Framework.Scenes; | |||
37 | 38 | ||
38 | namespace OpenSim.Region.CoreModules.Avatar.Chat | 39 | namespace OpenSim.Region.CoreModules.Avatar.Chat |
39 | { | 40 | { |
41 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ChatModule")] | ||
40 | public class ChatModule : ISharedRegionModule | 42 | public class ChatModule : ISharedRegionModule |
41 | { | 43 | { |
42 | private static readonly ILog m_log = | 44 | private static readonly ILog m_log = |
@@ -186,6 +188,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
186 | { | 188 | { |
187 | string fromName = c.From; | 189 | string fromName = c.From; |
188 | UUID fromID = UUID.Zero; | 190 | UUID fromID = UUID.Zero; |
191 | UUID ownerID = UUID.Zero; | ||
189 | UUID targetID = c.TargetUUID; | 192 | UUID targetID = c.TargetUUID; |
190 | string message = c.Message; | 193 | string message = c.Message; |
191 | IScene scene = c.Scene; | 194 | IScene scene = c.Scene; |
@@ -208,12 +211,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
208 | fromPos = avatar.AbsolutePosition; | 211 | fromPos = avatar.AbsolutePosition; |
209 | fromName = avatar.Name; | 212 | fromName = avatar.Name; |
210 | fromID = c.Sender.AgentId; | 213 | fromID = c.Sender.AgentId; |
214 | ownerID = c.Sender.AgentId; | ||
211 | 215 | ||
212 | break; | 216 | break; |
213 | 217 | ||
214 | case ChatSourceType.Object: | 218 | case ChatSourceType.Object: |
215 | fromID = c.SenderUUID; | 219 | fromID = c.SenderUUID; |
216 | 220 | ||
221 | if (c.SenderObject != null && c.SenderObject is SceneObjectPart) | ||
222 | ownerID = ((SceneObjectPart)c.SenderObject).OwnerID; | ||
223 | |||
217 | break; | 224 | break; |
218 | } | 225 | } |
219 | 226 | ||
@@ -236,7 +243,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
236 | s.ForEachRootScenePresence( | 243 | s.ForEachRootScenePresence( |
237 | delegate(ScenePresence presence) | 244 | delegate(ScenePresence presence) |
238 | { | 245 | { |
239 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType, false)) | 246 | if (TrySendChatMessage( |
247 | presence, fromPos, regionPos, fromID, ownerID, fromName, c.Type, message, sourceType, false)) | ||
240 | receiverIDs.Add(presence.UUID); | 248 | receiverIDs.Add(presence.UUID); |
241 | } | 249 | } |
242 | ); | 250 | ); |
@@ -248,8 +256,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
248 | ScenePresence presence = s.GetScenePresence(targetID); | 256 | ScenePresence presence = s.GetScenePresence(targetID); |
249 | if (presence != null && !presence.IsChildAgent) | 257 | if (presence != null && !presence.IsChildAgent) |
250 | { | 258 | { |
251 | if (TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, ChatTypeEnum.Say, message, sourceType, true)) | 259 | if (TrySendChatMessage( |
252 | receiverIDs.Add(presence.UUID); | 260 | presence, fromPos, regionPos, fromID, ownerID, fromName, ChatTypeEnum.Say, message, sourceType, true)) |
261 | receiverIDs.Add(presence.UUID); | ||
253 | } | 262 | } |
254 | } | 263 | } |
255 | } | 264 | } |
@@ -305,9 +314,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
305 | (null != c.SenderObject) && | 314 | (null != c.SenderObject) && |
306 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) | 315 | (((SceneObjectPart)c.SenderObject).OwnerID != client.AgentId)) |
307 | return; | 316 | return; |
308 | 317 | ||
309 | client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID, | 318 | client.SendChatMessage( |
310 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | 319 | c.Message, (byte)cType, CenterOfRegion, fromName, fromID, fromID, |
320 | (byte)sourceType, (byte)ChatAudibleLevel.Fully); | ||
321 | |||
311 | receiverIDs.Add(client.AgentId); | 322 | receiverIDs.Add(client.AgentId); |
312 | }); | 323 | }); |
313 | 324 | ||
@@ -322,15 +333,20 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
322 | /// <param name="fromPos"></param> | 333 | /// <param name="fromPos"></param> |
323 | /// <param name="regionPos">/param> | 334 | /// <param name="regionPos">/param> |
324 | /// <param name="fromAgentID"></param> | 335 | /// <param name="fromAgentID"></param> |
336 | /// <param name='ownerID'> | ||
337 | /// Owner of the message. For at least some messages from objects, this has to be correctly filled with the owner's UUID. | ||
338 | /// This is the case for script error messages in viewer 3 since LLViewer change EXT-7762 | ||
339 | /// </param> | ||
325 | /// <param name="fromName"></param> | 340 | /// <param name="fromName"></param> |
326 | /// <param name="type"></param> | 341 | /// <param name="type"></param> |
327 | /// <param name="message"></param> | 342 | /// <param name="message"></param> |
328 | /// <param name="src"></param> | 343 | /// <param name="src"></param> |
329 | /// <returns>true if the message was sent to the receiver, false if it was not sent due to failing a | 344 | /// <returns>true if the message was sent to the receiver, false if it was not sent due to failing a |
330 | /// precondition</returns> | 345 | /// precondition</returns> |
331 | protected virtual bool TrySendChatMessage(ScenePresence presence, Vector3 fromPos, Vector3 regionPos, | 346 | protected virtual bool TrySendChatMessage( |
332 | UUID fromAgentID, string fromName, ChatTypeEnum type, | 347 | ScenePresence presence, Vector3 fromPos, Vector3 regionPos, |
333 | string message, ChatSourceType src, bool ignoreDistance) | 348 | UUID fromAgentID, UUID ownerID, string fromName, ChatTypeEnum type, |
349 | string message, ChatSourceType src, bool ignoreDistance) | ||
334 | { | 350 | { |
335 | // don't send stuff to child agents | 351 | // don't send stuff to child agents |
336 | if (presence.IsChildAgent) return false; | 352 | if (presence.IsChildAgent) return false; |
@@ -353,10 +369,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat | |||
353 | } | 369 | } |
354 | 370 | ||
355 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView | 371 | // TODO: should change so the message is sent through the avatar rather than direct to the ClientView |
356 | presence.ControllingClient.SendChatMessage(message, (byte) type, fromPos, fromName, | 372 | presence.ControllingClient.SendChatMessage( |
357 | fromAgentID, (byte)src, (byte)ChatAudibleLevel.Fully); | 373 | message, (byte) type, fromPos, fromName, |
374 | fromAgentID, ownerID, (byte)src, (byte)ChatAudibleLevel.Fully); | ||
358 | 375 | ||
359 | return true; | 376 | return true; |
360 | } | 377 | } |
361 | } | 378 | } |
362 | } | 379 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs index 3a91465..343cdb5 100644 --- a/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Combat/CombatModule.cs | |||
@@ -33,9 +33,12 @@ using OpenSim.Region.Framework.Interfaces; | |||
33 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | 35 | ||
36 | using Mono.Addins; | ||
37 | |||
36 | namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule | 38 | namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule |
37 | { | 39 | { |
38 | public class CombatModule : IRegionModule | 40 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "CombatModule")] |
41 | public class CombatModule : ISharedRegionModule | ||
39 | { | 42 | { |
40 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 43 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 44 | ||
@@ -54,7 +57,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule | |||
54 | /// </summary> | 57 | /// </summary> |
55 | /// <param name="scene"></param> | 58 | /// <param name="scene"></param> |
56 | /// <param name="config"></param> | 59 | /// <param name="config"></param> |
57 | public void Initialise(Scene scene, IConfigSource config) | 60 | public void Initialise(IConfigSource config) |
61 | { | ||
62 | } | ||
63 | |||
64 | public void AddRegion(Scene scene) | ||
58 | { | 65 | { |
59 | lock (m_scenel) | 66 | lock (m_scenel) |
60 | { | 67 | { |
@@ -72,6 +79,19 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule | |||
72 | scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; | 79 | scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; |
73 | } | 80 | } |
74 | 81 | ||
82 | public void RemoveRegion(Scene scene) | ||
83 | { | ||
84 | if (m_scenel.ContainsKey(scene.RegionInfo.RegionHandle)) | ||
85 | m_scenel.Remove(scene.RegionInfo.RegionHandle); | ||
86 | |||
87 | scene.EventManager.OnAvatarKilled -= KillAvatar; | ||
88 | scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel; | ||
89 | } | ||
90 | |||
91 | public void RegionLoaded(Scene scene) | ||
92 | { | ||
93 | } | ||
94 | |||
75 | public void PostInitialise() | 95 | public void PostInitialise() |
76 | { | 96 | { |
77 | } | 97 | } |
@@ -85,11 +105,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Combat.CombatModule | |||
85 | get { return "CombatModule"; } | 105 | get { return "CombatModule"; } |
86 | } | 106 | } |
87 | 107 | ||
88 | public bool IsSharedModule | 108 | public Type ReplaceableInterface |
89 | { | 109 | { |
90 | get { return true; } | 110 | get { return null; } |
91 | } | 111 | } |
92 | 112 | ||
113 | |||
93 | private void KillAvatar(uint killerObjectLocalID, ScenePresence deadAvatar) | 114 | private void KillAvatar(uint killerObjectLocalID, ScenePresence deadAvatar) |
94 | { | 115 | { |
95 | string deadAvatarMessage; | 116 | string deadAvatarMessage; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs index 325067c..d26907b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Dialog/DialogModule.cs | |||
@@ -32,6 +32,7 @@ using log4net; | |||
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using Mono.Addins; | ||
35 | 36 | ||
36 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
@@ -39,16 +40,27 @@ using OpenSim.Services.Interfaces; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.Avatar.Dialog | 41 | namespace OpenSim.Region.CoreModules.Avatar.Dialog |
41 | { | 42 | { |
42 | public class DialogModule : IRegionModule, IDialogModule | 43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DialogModule")] |
43 | { | 44 | public class DialogModule : IDialogModule, INonSharedRegionModule |
45 | { | ||
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 47 | ||
46 | protected Scene m_scene; | 48 | protected Scene m_scene; |
47 | 49 | ||
48 | public void Initialise(Scene scene, IConfigSource source) | 50 | public void Initialise(IConfigSource source) { } |
51 | |||
52 | public Type ReplaceableInterface { get { return null; } } | ||
53 | |||
54 | public void AddRegion(Scene scene) | ||
49 | { | 55 | { |
50 | m_scene = scene; | 56 | m_scene = scene; |
51 | m_scene.RegisterModuleInterface<IDialogModule>(this); | 57 | m_scene.RegisterModuleInterface<IDialogModule>(this); |
58 | } | ||
59 | |||
60 | public void RegionLoaded(Scene scene) | ||
61 | { | ||
62 | if (scene != m_scene) | ||
63 | return; | ||
52 | 64 | ||
53 | m_scene.AddCommand( | 65 | m_scene.AddCommand( |
54 | "Users", this, "alert", "alert <message>", | 66 | "Users", this, "alert", "alert <message>", |
@@ -56,46 +68,59 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
56 | HandleAlertConsoleCommand); | 68 | HandleAlertConsoleCommand); |
57 | 69 | ||
58 | m_scene.AddCommand( | 70 | m_scene.AddCommand( |
59 | "Users", this, "alert-user", "alert-user <first> <last> <message>", | 71 | "Users", this, "alert-user", |
72 | "alert-user <first> <last> <message>", | ||
60 | "Send an alert to a user", | 73 | "Send an alert to a user", |
61 | HandleAlertConsoleCommand); | 74 | HandleAlertConsoleCommand); |
62 | } | 75 | } |
63 | 76 | ||
64 | public void PostInitialise() {} | 77 | public void RemoveRegion(Scene scene) |
65 | public void Close() {} | 78 | { |
79 | if (scene != m_scene) | ||
80 | return; | ||
81 | |||
82 | m_scene.UnregisterModuleInterface<IDialogModule>(this); | ||
83 | } | ||
84 | |||
85 | public void Close() { } | ||
66 | public string Name { get { return "Dialog Module"; } } | 86 | public string Name { get { return "Dialog Module"; } } |
67 | public bool IsSharedModule { get { return false; } } | 87 | |
68 | |||
69 | public void SendAlertToUser(IClientAPI client, string message) | 88 | public void SendAlertToUser(IClientAPI client, string message) |
70 | { | 89 | { |
71 | SendAlertToUser(client, message, false); | 90 | SendAlertToUser(client, message, false); |
72 | } | 91 | } |
73 | 92 | ||
74 | public void SendAlertToUser(IClientAPI client, string message, bool modal) | 93 | public void SendAlertToUser(IClientAPI client, string message, |
94 | bool modal) | ||
75 | { | 95 | { |
76 | client.SendAgentAlertMessage(message, modal); | 96 | client.SendAgentAlertMessage(message, modal); |
77 | } | 97 | } |
78 | 98 | ||
79 | public void SendAlertToUser(UUID agentID, string message) | 99 | public void SendAlertToUser(UUID agentID, string message) |
80 | { | 100 | { |
81 | SendAlertToUser(agentID, message, false); | 101 | SendAlertToUser(agentID, message, false); |
82 | } | 102 | } |
83 | 103 | ||
84 | public void SendAlertToUser(UUID agentID, string message, bool modal) | 104 | public void SendAlertToUser(UUID agentID, string message, bool modal) |
85 | { | 105 | { |
86 | ScenePresence sp = m_scene.GetScenePresence(agentID); | 106 | ScenePresence sp = m_scene.GetScenePresence(agentID); |
87 | 107 | ||
88 | if (sp != null) | 108 | if (sp != null) |
89 | sp.ControllingClient.SendAgentAlertMessage(message, modal); | 109 | sp.ControllingClient.SendAgentAlertMessage(message, modal); |
90 | } | 110 | } |
91 | 111 | ||
92 | public void SendAlertToUser(string firstName, string lastName, string message, bool modal) | 112 | public void SendAlertToUser(string firstName, string lastName, |
113 | string message, bool modal) | ||
93 | { | 114 | { |
94 | ScenePresence presence = m_scene.GetScenePresence(firstName, lastName); | 115 | ScenePresence presence = m_scene.GetScenePresence(firstName, |
116 | lastName); | ||
95 | if (presence != null) | 117 | if (presence != null) |
96 | presence.ControllingClient.SendAgentAlertMessage(message, modal); | 118 | { |
119 | presence.ControllingClient.SendAgentAlertMessage(message, | ||
120 | modal); | ||
121 | } | ||
97 | } | 122 | } |
98 | 123 | ||
99 | public void SendGeneralAlert(string message) | 124 | public void SendGeneralAlert(string message) |
100 | { | 125 | { |
101 | m_scene.ForEachRootClient(delegate(IClientAPI client) | 126 | m_scene.ForEachRootClient(delegate(IClientAPI client) |
@@ -104,11 +129,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
104 | }); | 129 | }); |
105 | } | 130 | } |
106 | 131 | ||
107 | public void SendDialogToUser( | 132 | public void SendDialogToUser(UUID avatarID, string objectName, |
108 | UUID avatarID, string objectName, UUID objectID, UUID ownerID, | 133 | UUID objectID, UUID ownerID, string message, UUID textureID, |
109 | string message, UUID textureID, int ch, string[] buttonlabels) | 134 | int ch, string[] buttonlabels) |
110 | { | 135 | { |
111 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerID); | 136 | UserAccount account = m_scene.UserAccountService.GetUserAccount( |
137 | m_scene.RegionInfo.ScopeID, ownerID); | ||
112 | string ownerFirstName, ownerLastName; | 138 | string ownerFirstName, ownerLastName; |
113 | if (account != null) | 139 | if (account != null) |
114 | { | 140 | { |
@@ -123,29 +149,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
123 | 149 | ||
124 | ScenePresence sp = m_scene.GetScenePresence(avatarID); | 150 | ScenePresence sp = m_scene.GetScenePresence(avatarID); |
125 | if (sp != null) | 151 | if (sp != null) |
126 | sp.ControllingClient.SendDialog( | 152 | { |
127 | objectName, objectID, ownerID, ownerFirstName, ownerLastName, message, textureID, ch, buttonlabels); | 153 | sp.ControllingClient.SendDialog(objectName, objectID, ownerID, |
154 | ownerFirstName, ownerLastName, message, textureID, ch, | ||
155 | buttonlabels); | ||
156 | } | ||
128 | } | 157 | } |
129 | 158 | ||
130 | public void SendUrlToUser( | 159 | public void SendUrlToUser(UUID avatarID, string objectName, |
131 | UUID avatarID, string objectName, UUID objectID, UUID ownerID, bool groupOwned, string message, string url) | 160 | UUID objectID, UUID ownerID, bool groupOwned, string message, |
161 | string url) | ||
132 | { | 162 | { |
133 | ScenePresence sp = m_scene.GetScenePresence(avatarID); | 163 | ScenePresence sp = m_scene.GetScenePresence(avatarID); |
134 | 164 | ||
135 | if (sp != null) | 165 | if (sp != null) |
136 | sp.ControllingClient.SendLoadURL(objectName, objectID, ownerID, groupOwned, message, url); | 166 | { |
167 | sp.ControllingClient.SendLoadURL(objectName, objectID, | ||
168 | ownerID, groupOwned, message, url); | ||
169 | } | ||
137 | } | 170 | } |
138 | 171 | ||
139 | public void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid) | 172 | public void SendTextBoxToUser(UUID avatarid, string message, |
173 | int chatChannel, string name, UUID objectid, UUID ownerid) | ||
140 | { | 174 | { |
141 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, ownerid); | 175 | UserAccount account = m_scene.UserAccountService.GetUserAccount( |
176 | m_scene.RegionInfo.ScopeID, ownerid); | ||
142 | string ownerFirstName, ownerLastName; | 177 | string ownerFirstName, ownerLastName; |
143 | UUID ownerID = UUID.Zero; | 178 | UUID ownerID = UUID.Zero; |
144 | if (account != null) | 179 | if (account != null) |
145 | { | 180 | { |
146 | ownerFirstName = account.FirstName; | 181 | ownerFirstName = account.FirstName; |
147 | ownerLastName = account.LastName; | 182 | ownerLastName = account.LastName; |
148 | ownerID = account.PrincipalID; | 183 | ownerID = account.PrincipalID; |
149 | } | 184 | } |
150 | else | 185 | else |
151 | { | 186 | { |
@@ -154,29 +189,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
154 | } | 189 | } |
155 | 190 | ||
156 | ScenePresence sp = m_scene.GetScenePresence(avatarid); | 191 | ScenePresence sp = m_scene.GetScenePresence(avatarid); |
157 | 192 | ||
158 | if (sp != null) | 193 | if (sp != null) |
159 | sp.ControllingClient.SendTextBoxRequest(message, chatChannel, name, ownerID, ownerFirstName, ownerLastName, objectid); | 194 | { |
195 | sp.ControllingClient.SendTextBoxRequest(message, chatChannel, | ||
196 | name, ownerID, ownerFirstName, ownerLastName, | ||
197 | objectid); | ||
198 | } | ||
160 | } | 199 | } |
161 | 200 | ||
162 | public void SendNotificationToUsersInRegion( | 201 | public void SendNotificationToUsersInRegion(UUID fromAvatarID, |
163 | UUID fromAvatarID, string fromAvatarName, string message) | 202 | string fromAvatarName, string message) |
164 | { | 203 | { |
165 | m_scene.ForEachRootClient(delegate(IClientAPI client) | 204 | m_scene.ForEachRootClient(delegate(IClientAPI client) |
166 | { | 205 | { |
167 | client.SendBlueBoxMessage(fromAvatarID, fromAvatarName, message); | 206 | client.SendBlueBoxMessage(fromAvatarID, fromAvatarName, |
207 | message); | ||
168 | }); | 208 | }); |
169 | } | 209 | } |
170 | 210 | ||
171 | /// <summary> | 211 | /// <summary> |
172 | /// Handle an alert command from the console. | 212 | /// Handle an alert command from the console. |
173 | /// </summary> | 213 | /// </summary> |
174 | /// <param name="module"></param> | 214 | /// <param name="module"></param> |
175 | /// <param name="cmdparams"></param> | 215 | /// <param name="cmdparams"></param> |
176 | public void HandleAlertConsoleCommand(string module, string[] cmdparams) | 216 | public void HandleAlertConsoleCommand(string module, |
217 | string[] cmdparams) | ||
177 | { | 218 | { |
178 | if (m_scene.ConsoleScene() != null && m_scene.ConsoleScene() != m_scene) | 219 | if (m_scene.ConsoleScene() != null && |
220 | m_scene.ConsoleScene() != m_scene) | ||
221 | { | ||
179 | return; | 222 | return; |
223 | } | ||
180 | 224 | ||
181 | string message = string.Empty; | 225 | string message = string.Empty; |
182 | 226 | ||
@@ -184,7 +228,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
184 | { | 228 | { |
185 | message = CombineParams(cmdparams, 1); | 229 | message = CombineParams(cmdparams, 1); |
186 | m_log.InfoFormat("[DIALOG]: Sending general alert in region {0} with message {1}", | 230 | m_log.InfoFormat("[DIALOG]: Sending general alert in region {0} with message {1}", |
187 | m_scene.RegionInfo.RegionName, message); | 231 | m_scene.RegionInfo.RegionName, message); |
188 | SendGeneralAlert(message); | 232 | SendGeneralAlert(message); |
189 | } | 233 | } |
190 | else if (cmdparams.Length > 3) | 234 | else if (cmdparams.Length > 3) |
@@ -192,9 +236,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
192 | string firstName = cmdparams[1]; | 236 | string firstName = cmdparams[1]; |
193 | string lastName = cmdparams[2]; | 237 | string lastName = cmdparams[2]; |
194 | message = CombineParams(cmdparams, 3); | 238 | message = CombineParams(cmdparams, 3); |
195 | m_log.InfoFormat( | 239 | m_log.InfoFormat("[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}", |
196 | "[DIALOG]: Sending alert in region {0} to {1} {2} with message {3}", | 240 | m_scene.RegionInfo.RegionName, firstName, lastName, |
197 | m_scene.RegionInfo.RegionName, firstName, lastName, message); | 241 | message); |
198 | SendAlertToUser(firstName, lastName, message, false); | 242 | SendAlertToUser(firstName, lastName, message, false); |
199 | } | 243 | } |
200 | else | 244 | else |
@@ -212,7 +256,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Dialog | |||
212 | { | 256 | { |
213 | result += commandParams[i] + " "; | 257 | result += commandParams[i] + " "; |
214 | } | 258 | } |
215 | 259 | ||
216 | return result; | 260 | return result; |
217 | } | 261 | } |
218 | } | 262 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs index f1903c3..8056030 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/FriendsModule.cs | |||
@@ -35,6 +35,7 @@ using log4net; | |||
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | using Nwc.XmlRpc; | 36 | using Nwc.XmlRpc; |
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using Mono.Addins; | ||
38 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Servers.HttpServer; | 40 | using OpenSim.Framework.Servers.HttpServer; |
40 | using OpenSim.Framework.Communications; | 41 | using OpenSim.Framework.Communications; |
@@ -50,6 +51,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
50 | 51 | ||
51 | namespace OpenSim.Region.CoreModules.Avatar.Friends | 52 | namespace OpenSim.Region.CoreModules.Avatar.Friends |
52 | { | 53 | { |
54 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "FriendsModule")] | ||
53 | public class FriendsModule : ISharedRegionModule, IFriendsModule | 55 | public class FriendsModule : ISharedRegionModule, IFriendsModule |
54 | { | 56 | { |
55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 57 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs index 06f27e2..bf5c0bb 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/HGFriendsModule.cs | |||
@@ -46,6 +46,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
46 | 46 | ||
47 | namespace OpenSim.Region.CoreModules.Avatar.Friends | 47 | namespace OpenSim.Region.CoreModules.Avatar.Friends |
48 | { | 48 | { |
49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGFriendsModule")] | ||
49 | public class HGFriendsModule : FriendsModule, ISharedRegionModule, IFriendsModule, IFriendsSimConnector | 50 | public class HGFriendsModule : FriendsModule, ISharedRegionModule, IFriendsModule, IFriendsSimConnector |
50 | { | 51 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs index 7a197f7..961117e 100644 --- a/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Friends/Tests/FriendModuleTests.cs | |||
@@ -40,7 +40,7 @@ using OpenSim.Tests.Common.Mock; | |||
40 | namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests | 40 | namespace OpenSim.Region.CoreModules.Avatar.Friends.Tests |
41 | { | 41 | { |
42 | [TestFixture] | 42 | [TestFixture] |
43 | public class FriendsModuleTests | 43 | public class FriendsModuleTests : OpenSimTestCase |
44 | { | 44 | { |
45 | private FriendsModule m_fm; | 45 | private FriendsModule m_fm; |
46 | private TestScene m_scene; | 46 | private TestScene m_scene; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs index 7df2beb..095c57b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gestures/GesturesModule.cs | |||
@@ -25,6 +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 | using System; | ||
28 | using System.Reflection; | 29 | using System.Reflection; |
29 | using log4net; | 30 | using log4net; |
30 | using Nini.Config; | 31 | using Nini.Config; |
@@ -35,26 +36,46 @@ using OpenSim.Region.Framework.Interfaces; | |||
35 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
36 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
37 | 38 | ||
39 | using Mono.Addins; | ||
40 | |||
38 | namespace OpenSim.Region.CoreModules.Avatar.Gestures | 41 | namespace OpenSim.Region.CoreModules.Avatar.Gestures |
39 | { | 42 | { |
40 | public class GesturesModule : IRegionModule | 43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GesturesModule")] |
44 | public class GesturesModule : INonSharedRegionModule | ||
41 | { | 45 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 47 | ||
44 | protected Scene m_scene; | 48 | protected Scene m_scene; |
45 | 49 | ||
46 | public void Initialise(Scene scene, IConfigSource source) | 50 | public void Initialise(IConfigSource source) |
51 | { | ||
52 | } | ||
53 | |||
54 | public void AddRegion(Scene scene) | ||
47 | { | 55 | { |
48 | m_scene = scene; | 56 | m_scene = scene; |
49 | 57 | ||
50 | m_scene.EventManager.OnNewClient += OnNewClient; | 58 | m_scene.EventManager.OnNewClient += OnNewClient; |
51 | } | 59 | } |
60 | |||
61 | public void RegionLoaded(Scene scene) | ||
62 | { | ||
63 | } | ||
64 | |||
65 | public void RemoveRegion(Scene scene) | ||
66 | { | ||
67 | m_scene.EventManager.OnNewClient -= OnNewClient; | ||
68 | m_scene = null; | ||
69 | } | ||
52 | 70 | ||
53 | public void PostInitialise() {} | ||
54 | public void Close() {} | 71 | public void Close() {} |
55 | public string Name { get { return "Gestures Module"; } } | 72 | public string Name { get { return "Gestures Module"; } } |
56 | public bool IsSharedModule { get { return false; } } | 73 | |
57 | 74 | public Type ReplaceableInterface | |
75 | { | ||
76 | get { return null; } | ||
77 | } | ||
78 | |||
58 | private void OnNewClient(IClientAPI client) | 79 | private void OnNewClient(IClientAPI client) |
59 | { | 80 | { |
60 | client.OnActivateGesture += ActivateGesture; | 81 | client.OnActivateGesture += ActivateGesture; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs index 2e3312f..5a7446f 100644 --- a/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Gods/GodsModule.cs | |||
@@ -25,6 +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 | using System; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using Nini.Config; | 30 | using Nini.Config; |
30 | using OpenMetaverse; | 31 | using OpenMetaverse; |
@@ -32,29 +33,59 @@ using OpenSim.Framework; | |||
32 | using OpenSim.Region.Framework.Scenes; | 33 | using OpenSim.Region.Framework.Scenes; |
33 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
34 | 35 | ||
36 | using Mono.Addins; | ||
37 | |||
35 | namespace OpenSim.Region.CoreModules.Avatar.Gods | 38 | namespace OpenSim.Region.CoreModules.Avatar.Gods |
36 | { | 39 | { |
37 | public class GodsModule : IRegionModule, IGodsModule | 40 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GodsModule")] |
41 | public class GodsModule : INonSharedRegionModule, IGodsModule | ||
38 | { | 42 | { |
39 | /// <summary>Special UUID for actions that apply to all agents</summary> | 43 | /// <summary>Special UUID for actions that apply to all agents</summary> |
40 | private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); | 44 | private static readonly UUID ALL_AGENTS = new UUID("44e87126-e794-4ded-05b3-7c42da3d5cdb"); |
41 | 45 | ||
42 | protected Scene m_scene; | 46 | protected Scene m_scene; |
43 | protected IDialogModule m_dialogModule; | 47 | protected IDialogModule m_dialogModule; |
44 | 48 | protected IDialogModule DialogModule | |
45 | public void Initialise(Scene scene, IConfigSource source) | 49 | { |
50 | get | ||
51 | { | ||
52 | if (m_dialogModule == null) | ||
53 | m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>(); | ||
54 | |||
55 | return m_dialogModule; | ||
56 | } | ||
57 | } | ||
58 | |||
59 | public void Initialise(IConfigSource source) | ||
60 | { | ||
61 | } | ||
62 | |||
63 | public void AddRegion(Scene scene) | ||
46 | { | 64 | { |
47 | m_scene = scene; | 65 | m_scene = scene; |
48 | m_dialogModule = m_scene.RequestModuleInterface<IDialogModule>(); | ||
49 | m_scene.RegisterModuleInterface<IGodsModule>(this); | 66 | m_scene.RegisterModuleInterface<IGodsModule>(this); |
50 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; | 67 | m_scene.EventManager.OnNewClient += SubscribeToClientEvents; |
51 | } | 68 | } |
52 | 69 | ||
53 | public void PostInitialise() {} | 70 | public void RemoveRegion(Scene scene) |
71 | { | ||
72 | m_scene.UnregisterModuleInterface<IGodsModule>(this); | ||
73 | m_scene.EventManager.OnNewClient -= SubscribeToClientEvents; | ||
74 | m_scene = null; | ||
75 | } | ||
76 | |||
77 | public void RegionLoaded(Scene scene) | ||
78 | { | ||
79 | } | ||
80 | |||
54 | public void Close() {} | 81 | public void Close() {} |
55 | public string Name { get { return "Gods Module"; } } | 82 | public string Name { get { return "Gods Module"; } } |
56 | public bool IsSharedModule { get { return false; } } | 83 | |
57 | 84 | public Type ReplaceableInterface | |
85 | { | ||
86 | get { return null; } | ||
87 | } | ||
88 | |||
58 | public void SubscribeToClientEvents(IClientAPI client) | 89 | public void SubscribeToClientEvents(IClientAPI client) |
59 | { | 90 | { |
60 | client.OnGodKickUser += KickUser; | 91 | client.OnGodKickUser += KickUser; |
@@ -96,8 +127,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
96 | } | 127 | } |
97 | else | 128 | else |
98 | { | 129 | { |
99 | if (m_dialogModule != null) | 130 | if (DialogModule != null) |
100 | m_dialogModule.SendAlertToUser(agentID, "Request for god powers denied"); | 131 | DialogModule.SendAlertToUser(agentID, "Request for god powers denied"); |
101 | } | 132 | } |
102 | } | 133 | } |
103 | } | 134 | } |
@@ -162,20 +193,27 @@ namespace OpenSim.Region.CoreModules.Avatar.Gods | |||
162 | if (kickflags == 1) | 193 | if (kickflags == 1) |
163 | { | 194 | { |
164 | sp.AllowMovement = false; | 195 | sp.AllowMovement = false; |
165 | m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | 196 | if (DialogModule != null) |
166 | m_dialogModule.SendAlertToUser(godID, "User Frozen"); | 197 | { |
198 | DialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | ||
199 | DialogModule.SendAlertToUser(godID, "User Frozen"); | ||
200 | } | ||
167 | } | 201 | } |
168 | 202 | ||
169 | if (kickflags == 2) | 203 | if (kickflags == 2) |
170 | { | 204 | { |
171 | sp.AllowMovement = true; | 205 | sp.AllowMovement = true; |
172 | m_dialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | 206 | if (DialogModule != null) |
173 | m_dialogModule.SendAlertToUser(godID, "User Unfrozen"); | 207 | { |
208 | DialogModule.SendAlertToUser(agentID, Utils.BytesToString(reason)); | ||
209 | DialogModule.SendAlertToUser(godID, "User Unfrozen"); | ||
210 | } | ||
174 | } | 211 | } |
175 | } | 212 | } |
176 | else | 213 | else |
177 | { | 214 | { |
178 | m_dialogModule.SendAlertToUser(godID, "Kick request denied"); | 215 | if (DialogModule != null) |
216 | DialogModule.SendAlertToUser(godID, "Kick request denied"); | ||
179 | } | 217 | } |
180 | } | 218 | } |
181 | } | 219 | } |
diff --git a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs index b258e13..af54c1a 100644 --- a/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Groups/GroupsModule.cs | |||
@@ -25,6 +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 | using System; | ||
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using log4net; | 31 | using log4net; |
@@ -34,9 +35,12 @@ using OpenSim.Framework; | |||
34 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
36 | 37 | ||
38 | using Mono.Addins; | ||
39 | |||
37 | namespace OpenSim.Region.CoreModules.Avatar.Groups | 40 | namespace OpenSim.Region.CoreModules.Avatar.Groups |
38 | { | 41 | { |
39 | public class GroupsModule : IRegionModule | 42 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GroupsModule")] |
43 | public class GroupsModule : ISharedRegionModule | ||
40 | { | 44 | { |
41 | private static readonly ILog m_log = | 45 | private static readonly ILog m_log = |
42 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -55,9 +59,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups | |||
55 | private static GroupMembershipData osGroup = | 59 | private static GroupMembershipData osGroup = |
56 | new GroupMembershipData(); | 60 | new GroupMembershipData(); |
57 | 61 | ||
58 | #region IRegionModule Members | 62 | private bool m_Enabled = false; |
63 | |||
64 | #region ISharedRegionModule Members | ||
59 | 65 | ||
60 | public void Initialise(Scene scene, IConfigSource config) | 66 | public void Initialise(IConfigSource config) |
61 | { | 67 | { |
62 | IConfig groupsConfig = config.Configs["Groups"]; | 68 | IConfig groupsConfig = config.Configs["Groups"]; |
63 | 69 | ||
@@ -67,7 +73,8 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups | |||
67 | } | 73 | } |
68 | else | 74 | else |
69 | { | 75 | { |
70 | if (!groupsConfig.GetBoolean("Enabled", false)) | 76 | m_Enabled = groupsConfig.GetBoolean("Enabled", false); |
77 | if (!m_Enabled) | ||
71 | { | 78 | { |
72 | m_log.Info("[GROUPS]: Groups disabled in configuration"); | 79 | m_log.Info("[GROUPS]: Groups disabled in configuration"); |
73 | return; | 80 | return; |
@@ -77,6 +84,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups | |||
77 | return; | 84 | return; |
78 | } | 85 | } |
79 | 86 | ||
87 | } | ||
88 | |||
89 | public void AddRegion(Scene scene) | ||
90 | { | ||
91 | if (!m_Enabled) | ||
92 | return; | ||
93 | |||
80 | lock (m_SceneList) | 94 | lock (m_SceneList) |
81 | { | 95 | { |
82 | if (!m_SceneList.Contains(scene)) | 96 | if (!m_SceneList.Contains(scene)) |
@@ -96,7 +110,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups | |||
96 | 110 | ||
97 | scene.EventManager.OnNewClient += OnNewClient; | 111 | scene.EventManager.OnNewClient += OnNewClient; |
98 | scene.EventManager.OnClientClosed += OnClientClosed; | 112 | scene.EventManager.OnClientClosed += OnClientClosed; |
99 | // scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | 113 | // scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; |
114 | } | ||
115 | |||
116 | public void RemoveRegion(Scene scene) | ||
117 | { | ||
118 | if (!m_Enabled) | ||
119 | return; | ||
120 | |||
121 | lock (m_SceneList) | ||
122 | { | ||
123 | if (m_SceneList.Contains(scene)) | ||
124 | m_SceneList.Remove(scene); | ||
125 | } | ||
126 | |||
127 | scene.EventManager.OnNewClient -= OnNewClient; | ||
128 | scene.EventManager.OnClientClosed -= OnClientClosed; | ||
129 | } | ||
130 | |||
131 | public void RegionLoaded(Scene scene) | ||
132 | { | ||
100 | } | 133 | } |
101 | 134 | ||
102 | public void PostInitialise() | 135 | public void PostInitialise() |
@@ -105,6 +138,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups | |||
105 | 138 | ||
106 | public void Close() | 139 | public void Close() |
107 | { | 140 | { |
141 | if (!m_Enabled) | ||
142 | return; | ||
143 | |||
108 | // m_log.Debug("[GROUPS]: Shutting down group module."); | 144 | // m_log.Debug("[GROUPS]: Shutting down group module."); |
109 | 145 | ||
110 | lock (m_ClientMap) | 146 | lock (m_ClientMap) |
@@ -123,9 +159,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Groups | |||
123 | get { return "GroupsModule"; } | 159 | get { return "GroupsModule"; } |
124 | } | 160 | } |
125 | 161 | ||
126 | public bool IsSharedModule | 162 | public Type ReplaceableInterface |
127 | { | 163 | { |
128 | get { return true; } | 164 | get { return null; } |
129 | } | 165 | } |
130 | 166 | ||
131 | #endregion | 167 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs index bf1d787..7bf19c2 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/HGMessageTransferModule.cs | |||
@@ -48,7 +48,7 @@ using OpenSim.Server.Handlers.Hypergrid; | |||
48 | 48 | ||
49 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 49 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
50 | { | 50 | { |
51 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 51 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGMessageTransferModule")] |
52 | public class HGMessageTransferModule : ISharedRegionModule, IMessageTransferModule, IInstantMessageSimConnector | 52 | public class HGMessageTransferModule : ISharedRegionModule, IMessageTransferModule, IInstantMessageSimConnector |
53 | { | 53 | { |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs index ca5d485..c33a296 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/InstantMessageModule.cs | |||
@@ -28,6 +28,7 @@ using System; | |||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using log4net; | 30 | using log4net; |
31 | using Mono.Addins; | ||
31 | using Nini.Config; | 32 | using Nini.Config; |
32 | using OpenMetaverse; | 33 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
@@ -37,6 +38,7 @@ using OpenSim.Region.Framework.Scenes; | |||
37 | 38 | ||
38 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 39 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
39 | { | 40 | { |
41 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "InstantMessageModule")] | ||
40 | public class InstantMessageModule : ISharedRegionModule | 42 | public class InstantMessageModule : ISharedRegionModule |
41 | { | 43 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger( | 44 | private static readonly ILog m_log = LogManager.GetLogger( |
@@ -49,7 +51,7 @@ namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | |||
49 | 51 | ||
50 | private readonly List<Scene> m_scenes = new List<Scene>(); | 52 | private readonly List<Scene> m_scenes = new List<Scene>(); |
51 | 53 | ||
52 | #region IRegionModule Members | 54 | #region Region Module interface |
53 | 55 | ||
54 | private IMessageTransferModule m_TransferModule = null; | 56 | private IMessageTransferModule m_TransferModule = null; |
55 | 57 | ||
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs index 596174b..3983369 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MessageTransferModule.cs | |||
@@ -30,6 +30,7 @@ using System.Collections.Generic; | |||
30 | using System.Net; | 30 | using System.Net; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using log4net; | 32 | using log4net; |
33 | using Mono.Addins; | ||
33 | using Nini.Config; | 34 | using Nini.Config; |
34 | using Nwc.XmlRpc; | 35 | using Nwc.XmlRpc; |
35 | using OpenMetaverse; | 36 | using OpenMetaverse; |
@@ -43,6 +44,7 @@ using OpenSim.Services.Interfaces; | |||
43 | 44 | ||
44 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 45 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
45 | { | 46 | { |
47 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MessageTransferModule")] | ||
46 | public class MessageTransferModule : ISharedRegionModule, IMessageTransferModule | 48 | public class MessageTransferModule : ISharedRegionModule, IMessageTransferModule |
47 | { | 49 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs index 24cbaeb..7ce2813 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/MuteListModule.cs | |||
@@ -29,6 +29,7 @@ using System.Collections.Generic; | |||
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using log4net; | 30 | using log4net; |
31 | using Nini.Config; | 31 | using Nini.Config; |
32 | using Mono.Addins; | ||
32 | using OpenMetaverse; | 33 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
@@ -39,6 +40,7 @@ using OpenSim.Region.Framework.Scenes; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
41 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MuteListModule")] | ||
42 | public class MuteListModule : ISharedRegionModule | 44 | public class MuteListModule : ISharedRegionModule |
43 | { | 45 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs index de25048..4aaf1fe 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/OfflineMessageModule.cs | |||
@@ -28,6 +28,7 @@ using System; | |||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using log4net; | 30 | using log4net; |
31 | using Mono.Addins; | ||
31 | using Nini.Config; | 32 | using Nini.Config; |
32 | using OpenMetaverse; | 33 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
@@ -39,6 +40,7 @@ using OpenSim.Region.Framework.Scenes; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 41 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
41 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "OfflineMessageModule")] | ||
42 | public class OfflineMessageModule : ISharedRegionModule | 44 | public class OfflineMessageModule : ISharedRegionModule |
43 | { | 45 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs index dd17f3c..4c678c2 100644 --- a/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/InstantMessage/PresenceModule.cs | |||
@@ -33,6 +33,7 @@ using log4net; | |||
33 | using Nini.Config; | 33 | using Nini.Config; |
34 | using Nwc.XmlRpc; | 34 | using Nwc.XmlRpc; |
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using Mono.Addins; | ||
36 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
37 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
@@ -42,6 +43,7 @@ using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | |||
42 | 43 | ||
43 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage | 44 | namespace OpenSim.Region.CoreModules.Avatar.InstantMessage |
44 | { | 45 | { |
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "PresenceModule")] | ||
45 | public class PresenceModule : ISharedRegionModule, IPresenceModule | 47 | public class PresenceModule : ISharedRegionModule, IPresenceModule |
46 | { | 48 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger( | 49 | private static readonly ILog m_log = LogManager.GetLogger( |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs index ee10d04..5069803 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveReadRequest.cs | |||
@@ -411,18 +411,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
411 | { | 411 | { |
412 | // m_log.DebugFormat("[INVENTORY ARCHIVER]: Found creator {0} via OSPA resolution", ospResolvedId); | 412 | // m_log.DebugFormat("[INVENTORY ARCHIVER]: Found creator {0} via OSPA resolution", ospResolvedId); |
413 | 413 | ||
414 | item.CreatorIdAsUuid = ospResolvedId; | 414 | // item.CreatorIdAsUuid = ospResolvedId; |
415 | 415 | ||
416 | // Don't preserve the OSPA in the creator id (which actually gets persisted to the | 416 | // Don't preserve the OSPA in the creator id (which actually gets persisted to the |
417 | // database). Instead, replace with the UUID that we found. | 417 | // database). Instead, replace with the UUID that we found. |
418 | item.CreatorId = ospResolvedId.ToString(); | 418 | item.CreatorId = ospResolvedId.ToString(); |
419 | |||
420 | item.CreatorData = string.Empty; | 419 | item.CreatorData = string.Empty; |
421 | } | 420 | } |
422 | else if (item.CreatorData == null || item.CreatorData == String.Empty) | 421 | else if (item.CreatorData == null || item.CreatorData == String.Empty) |
423 | { | 422 | { |
424 | item.CreatorId = m_userInfo.PrincipalID.ToString(); | 423 | item.CreatorId = m_userInfo.PrincipalID.ToString(); |
425 | item.CreatorIdAsUuid = new UUID(item.CreatorId); | 424 | // item.CreatorIdAsUuid = new UUID(item.CreatorId); |
426 | } | 425 | } |
427 | 426 | ||
428 | item.Owner = m_userInfo.PrincipalID; | 427 | item.Owner = m_userInfo.PrincipalID; |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 6587ead..d0e88f6 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | |||
@@ -166,7 +166,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
166 | 166 | ||
167 | if (options.ContainsKey("verbose")) | 167 | if (options.ContainsKey("verbose")) |
168 | m_log.InfoFormat( | 168 | m_log.InfoFormat( |
169 | "[INVENTORY ARCHIVER]: Saving item {0} {1} with asset {2}", | 169 | "[INVENTORY ARCHIVER]: Saving item {0} {1} (asset UUID {2})", |
170 | inventoryItem.ID, inventoryItem.Name, inventoryItem.AssetID); | 170 | inventoryItem.ID, inventoryItem.Name, inventoryItem.AssetID); |
171 | 171 | ||
172 | string filename = path + CreateArchiveItemName(inventoryItem); | 172 | string filename = path + CreateArchiveItemName(inventoryItem); |
@@ -337,11 +337,14 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
337 | { | 337 | { |
338 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Saving {0} assets for items", m_assetUuids.Count); | 338 | m_log.DebugFormat("[INVENTORY ARCHIVER]: Saving {0} assets for items", m_assetUuids.Count); |
339 | 339 | ||
340 | new AssetsRequest( | 340 | AssetsRequest ar |
341 | new AssetsArchiver(m_archiveWriter), | 341 | = new AssetsRequest( |
342 | m_assetUuids, m_scene.AssetService, | 342 | new AssetsArchiver(m_archiveWriter), |
343 | m_scene.UserAccountService, m_scene.RegionInfo.ScopeID, | 343 | m_assetUuids, m_scene.AssetService, |
344 | options, ReceivedAllAssets).Execute(); | 344 | m_scene.UserAccountService, m_scene.RegionInfo.ScopeID, |
345 | options, ReceivedAllAssets); | ||
346 | |||
347 | Util.FireAndForget(o => ar.Execute()); | ||
345 | } | 348 | } |
346 | else | 349 | else |
347 | { | 350 | { |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index cf87010..849449b 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs | |||
@@ -35,23 +35,22 @@ using Nini.Config; | |||
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Communications; | 37 | using OpenSim.Framework.Communications; |
38 | using OpenSim.Framework.Console; | ||
38 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
40 | using OpenSim.Services.Interfaces; | 41 | using OpenSim.Services.Interfaces; |
42 | using Mono.Addins; | ||
41 | 43 | ||
42 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | 44 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver |
43 | { | 45 | { |
44 | /// <summary> | 46 | /// <summary> |
45 | /// This module loads and saves OpenSimulator inventory archives | 47 | /// This module loads and saves OpenSimulator inventory archives |
46 | /// </summary> | 48 | /// </summary> |
47 | public class InventoryArchiverModule : IRegionModule, IInventoryArchiverModule | 49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "InventoryArchiverModule")] |
50 | public class InventoryArchiverModule : ISharedRegionModule, IInventoryArchiverModule | ||
48 | { | 51 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 53 | ||
51 | public string Name { get { return "Inventory Archiver Module"; } } | ||
52 | |||
53 | public bool IsSharedModule { get { return true; } } | ||
54 | |||
55 | /// <value> | 54 | /// <value> |
56 | /// Enable or disable checking whether the iar user is actually logged in | 55 | /// Enable or disable checking whether the iar user is actually logged in |
57 | /// </value> | 56 | /// </value> |
@@ -98,9 +97,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
98 | // public InventoryArchiverModule(bool disablePresenceChecks) | 97 | // public InventoryArchiverModule(bool disablePresenceChecks) |
99 | // { | 98 | // { |
100 | // DisablePresenceChecks = disablePresenceChecks; | 99 | // DisablePresenceChecks = disablePresenceChecks; |
101 | // } | 100 | // } |
101 | |||
102 | #region ISharedRegionModule | ||
103 | |||
104 | public void Initialise(IConfigSource source) | ||
105 | { | ||
106 | } | ||
102 | 107 | ||
103 | public void Initialise(Scene scene, IConfigSource source) | 108 | public void AddRegion(Scene scene) |
104 | { | 109 | { |
105 | if (m_scenes.Count == 0) | 110 | if (m_scenes.Count == 0) |
106 | { | 111 | { |
@@ -143,10 +148,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
143 | m_scenes[scene.RegionInfo.RegionID] = scene; | 148 | m_scenes[scene.RegionInfo.RegionID] = scene; |
144 | } | 149 | } |
145 | 150 | ||
146 | public void PostInitialise() {} | 151 | public void RemoveRegion(Scene scene) |
152 | { | ||
153 | } | ||
147 | 154 | ||
148 | public void Close() {} | 155 | public void Close() {} |
149 | 156 | ||
157 | public void RegionLoaded(Scene scene) | ||
158 | { | ||
159 | } | ||
160 | |||
161 | public void PostInitialise() | ||
162 | { | ||
163 | } | ||
164 | |||
165 | public Type ReplaceableInterface | ||
166 | { | ||
167 | get { return null; } | ||
168 | } | ||
169 | |||
170 | public string Name { get { return "Inventory Archiver Module"; } } | ||
171 | |||
172 | #endregion | ||
173 | |||
150 | /// <summary> | 174 | /// <summary> |
151 | /// Trigger the inventory archive saved event. | 175 | /// Trigger the inventory archive saved event. |
152 | /// </summary> | 176 | /// </summary> |
@@ -209,6 +233,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver | |||
209 | Guid id, string firstName, string lastName, string invPath, string pass, string savePath, | 233 | Guid id, string firstName, string lastName, string invPath, string pass, string savePath, |
210 | Dictionary<string, object> options) | 234 | Dictionary<string, object> options) |
211 | { | 235 | { |
236 | // if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, savePath)) | ||
237 | // return false; | ||
238 | |||
212 | if (m_scenes.Count > 0) | 239 | if (m_scenes.Count > 0) |
213 | { | 240 | { |
214 | UserAccount userInfo = GetUserInfo(firstName, lastName, pass); | 241 | UserAccount userInfo = GetUserInfo(firstName, lastName, pass); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs index 1056865..db78da9 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiveTestCase.cs | |||
@@ -82,7 +82,25 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
82 | 82 | ||
83 | protected string m_item1Name = "Ray Gun Item"; | 83 | protected string m_item1Name = "Ray Gun Item"; |
84 | protected string m_coaItemName = "Coalesced Item"; | 84 | protected string m_coaItemName = "Coalesced Item"; |
85 | 85 | ||
86 | [TestFixtureSetUp] | ||
87 | public void FixtureSetup() | ||
88 | { | ||
89 | // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread. | ||
90 | Util.FireAndForgetMethod = FireAndForgetMethod.RegressionTest; | ||
91 | |||
92 | ConstructDefaultIarBytesForTestLoad(); | ||
93 | } | ||
94 | |||
95 | [TestFixtureTearDown] | ||
96 | public void TearDown() | ||
97 | { | ||
98 | // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple | ||
99 | // threads. Possibly, later tests should be rewritten so none of them require async stuff (which regression | ||
100 | // tests really shouldn't). | ||
101 | Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod; | ||
102 | } | ||
103 | |||
86 | [SetUp] | 104 | [SetUp] |
87 | public override void SetUp() | 105 | public override void SetUp() |
88 | { | 106 | { |
@@ -90,12 +108,6 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
90 | m_iarStream = new MemoryStream(m_iarStreamBytes); | 108 | m_iarStream = new MemoryStream(m_iarStreamBytes); |
91 | } | 109 | } |
92 | 110 | ||
93 | [TestFixtureSetUp] | ||
94 | public void FixtureSetup() | ||
95 | { | ||
96 | ConstructDefaultIarBytesForTestLoad(); | ||
97 | } | ||
98 | |||
99 | protected void ConstructDefaultIarBytesForTestLoad() | 111 | protected void ConstructDefaultIarBytesForTestLoad() |
100 | { | 112 | { |
101 | // log4net.Config.XmlConfigurator.Configure(); | 113 | // log4net.Config.XmlConfigurator.Configure(); |
@@ -122,7 +134,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
122 | item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020"); | 134 | item1.ID = UUID.Parse("00000000-0000-0000-0000-000000000020"); |
123 | item1.AssetID = asset1.FullID; | 135 | item1.AssetID = asset1.FullID; |
124 | item1.GroupID = UUID.Random(); | 136 | item1.GroupID = UUID.Random(); |
125 | item1.CreatorIdAsUuid = m_uaLL1.PrincipalID; | 137 | item1.CreatorId = m_uaLL1.PrincipalID.ToString(); |
126 | item1.Owner = m_uaLL1.PrincipalID; | 138 | item1.Owner = m_uaLL1.PrincipalID; |
127 | item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID; | 139 | item1.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID; |
128 | scene.AddInventoryItem(item1); | 140 | scene.AddInventoryItem(item1); |
@@ -145,7 +157,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
145 | coaItem.ID = UUID.Parse("00000000-0000-0000-0000-000000000180"); | 157 | coaItem.ID = UUID.Parse("00000000-0000-0000-0000-000000000180"); |
146 | coaItem.AssetID = coaAsset.FullID; | 158 | coaItem.AssetID = coaAsset.FullID; |
147 | coaItem.GroupID = UUID.Random(); | 159 | coaItem.GroupID = UUID.Random(); |
148 | coaItem.CreatorIdAsUuid = m_uaLL1.PrincipalID; | 160 | coaItem.CreatorId = m_uaLL1.PrincipalID.ToString(); |
149 | coaItem.Owner = m_uaLL1.PrincipalID; | 161 | coaItem.Owner = m_uaLL1.PrincipalID; |
150 | coaItem.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID; | 162 | coaItem.Folder = scene.InventoryService.GetRootFolder(m_uaLL1.PrincipalID).ID; |
151 | scene.AddInventoryItem(coaItem); | 163 | scene.AddInventoryItem(coaItem); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs index 12a05b3..06f6e49 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/Tests/InventoryArchiverTests.cs | |||
@@ -49,7 +49,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
49 | { | 49 | { |
50 | [TestFixture] | 50 | [TestFixture] |
51 | public class InventoryArchiverTests : InventoryArchiveTestCase | 51 | public class InventoryArchiverTests : InventoryArchiveTestCase |
52 | { | 52 | { |
53 | protected TestScene m_scene; | 53 | protected TestScene m_scene; |
54 | protected InventoryArchiverModule m_archiverModule; | 54 | protected InventoryArchiverModule m_archiverModule; |
55 | 55 | ||
@@ -69,7 +69,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests | |||
69 | public void TestLoadCoalesecedItem() | 69 | public void TestLoadCoalesecedItem() |
70 | { | 70 | { |
71 | TestHelpers.InMethod(); | 71 | TestHelpers.InMethod(); |
72 | // log4net.Config.XmlConfigurator.Configure(); | 72 | // TestHelpers.EnableLogging(); |
73 | 73 | ||
74 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "password"); | 74 | UserAccountHelpers.CreateUserWithInventory(m_scene, m_uaLL1, "password"); |
75 | m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "password", m_iarStream); | 75 | m_archiverModule.DearchiveInventory(m_uaLL1.FirstName, m_uaLL1.LastName, "/", "password", m_iarStream); |
diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs index 33b4839..582aac4 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Transfer/InventoryTransferModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
@@ -38,20 +39,21 @@ using OpenSim.Services.Interfaces; | |||
38 | 39 | ||
39 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | 40 | namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer |
40 | { | 41 | { |
41 | public class InventoryTransferModule : IInventoryTransferModule, ISharedRegionModule | 42 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "InventoryTransferModule")] |
43 | public class InventoryTransferModule : ISharedRegionModule | ||
42 | { | 44 | { |
43 | private static readonly ILog m_log | 45 | private static readonly ILog m_log |
44 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 47 | ||
46 | /// <summary> | 48 | /// <summary> |
47 | private List<Scene> m_Scenelist = new List<Scene>(); | 49 | private List<Scene> m_Scenelist = new List<Scene>(); |
48 | private Dictionary<UUID, Scene> m_AgentRegions = | 50 | // private Dictionary<UUID, Scene> m_AgentRegions = |
49 | new Dictionary<UUID, Scene>(); | 51 | // new Dictionary<UUID, Scene>(); |
50 | 52 | ||
51 | private IMessageTransferModule m_TransferModule = null; | 53 | private IMessageTransferModule m_TransferModule = null; |
52 | private bool m_Enabled = true; | 54 | private bool m_Enabled = true; |
53 | 55 | ||
54 | #region IRegionModule Members | 56 | #region Region Module interface |
55 | 57 | ||
56 | public void Initialise(IConfigSource config) | 58 | public void Initialise(IConfigSource config) |
57 | { | 59 | { |
@@ -76,12 +78,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
76 | 78 | ||
77 | m_Scenelist.Add(scene); | 79 | m_Scenelist.Add(scene); |
78 | 80 | ||
79 | scene.RegisterModuleInterface<IInventoryTransferModule>(this); | 81 | // scene.RegisterModuleInterface<IInventoryTransferModule>(this); |
80 | 82 | ||
81 | scene.EventManager.OnNewClient += OnNewClient; | 83 | scene.EventManager.OnNewClient += OnNewClient; |
82 | scene.EventManager.OnClientClosed += ClientLoggedOut; | 84 | // scene.EventManager.OnClientClosed += ClientLoggedOut; |
83 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; | 85 | scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; |
84 | scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene; | 86 | // scene.EventManager.OnSetRootAgentScene += OnSetRootAgentScene; |
85 | } | 87 | } |
86 | 88 | ||
87 | public void RegionLoaded(Scene scene) | 89 | public void RegionLoaded(Scene scene) |
@@ -96,9 +98,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
96 | 98 | ||
97 | m_Scenelist.Clear(); | 99 | m_Scenelist.Clear(); |
98 | scene.EventManager.OnNewClient -= OnNewClient; | 100 | scene.EventManager.OnNewClient -= OnNewClient; |
99 | scene.EventManager.OnClientClosed -= ClientLoggedOut; | 101 | // scene.EventManager.OnClientClosed -= ClientLoggedOut; |
100 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | 102 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; |
101 | scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene; | 103 | // scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene; |
102 | } | 104 | } |
103 | } | 105 | } |
104 | } | 106 | } |
@@ -106,9 +108,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
106 | public void RemoveRegion(Scene scene) | 108 | public void RemoveRegion(Scene scene) |
107 | { | 109 | { |
108 | scene.EventManager.OnNewClient -= OnNewClient; | 110 | scene.EventManager.OnNewClient -= OnNewClient; |
109 | scene.EventManager.OnClientClosed -= ClientLoggedOut; | 111 | // scene.EventManager.OnClientClosed -= ClientLoggedOut; |
110 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; | 112 | scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage; |
111 | scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene; | 113 | // scene.EventManager.OnSetRootAgentScene -= OnSetRootAgentScene; |
112 | m_Scenelist.Remove(scene); | 114 | m_Scenelist.Remove(scene); |
113 | } | 115 | } |
114 | 116 | ||
@@ -138,10 +140,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
138 | client.OnInstantMessage += OnInstantMessage; | 140 | client.OnInstantMessage += OnInstantMessage; |
139 | } | 141 | } |
140 | 142 | ||
141 | protected void OnSetRootAgentScene(UUID id, Scene scene) | 143 | // protected void OnSetRootAgentScene(UUID id, Scene scene) |
142 | { | 144 | // { |
143 | m_AgentRegions[id] = scene; | 145 | // m_AgentRegions[id] = scene; |
144 | } | 146 | // } |
145 | 147 | ||
146 | private Scene FindClientScene(UUID agentId) | 148 | private Scene FindClientScene(UUID agentId) |
147 | { | 149 | { |
@@ -298,73 +300,76 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
298 | } | 300 | } |
299 | } | 301 | } |
300 | 302 | ||
301 | // XXX: This code was placed here to try and accomdate RLV which moves given folders named #RLV/~<name> | 303 | // Disabled for now as it looks like http://opensimulator.org/mantis/view.php?id=6311 was fixed by fixes |
302 | // to a folder called name in #RLV. However, this approach may not be ultimately correct - from analysis | 304 | // to inventory folder versioning allowing the viewer to move the received folder itself as happens on the |
303 | // of Firestorm 4.2.2 on sending an InventoryOffered instead of TaskInventoryOffered (as was previously | 305 | // LL grid. Doing it again server-side then wrongly does a second create and move |
304 | // done), the viewer itself would appear to move and rename the folder, rather than the simulator doing it here. | 306 | // // XXX: This code was placed here to try and accomdate RLV which moves given folders named #RLV/~<name> |
305 | else if (im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | 307 | // // to a folder called name in #RLV. However, this approach may not be ultimately correct - from analysis |
306 | { | 308 | // // of Firestorm 4.2.2 on sending an InventoryOffered instead of TaskInventoryOffered (as was previously |
307 | UUID destinationFolderID = UUID.Zero; | 309 | // // done), the viewer itself would appear to move and rename the folder, rather than the simulator doing it here. |
308 | 310 | // else if (im.dialog == (byte) InstantMessageDialog.TaskInventoryAccepted) | |
309 | if (im.binaryBucket != null && im.binaryBucket.Length >= 16) | 311 | // { |
310 | { | 312 | // UUID destinationFolderID = UUID.Zero; |
311 | destinationFolderID = new UUID(im.binaryBucket, 0); | 313 | // |
312 | } | 314 | // if (im.binaryBucket != null && im.binaryBucket.Length >= 16) |
313 | 315 | // { | |
314 | if (destinationFolderID != UUID.Zero) | 316 | // destinationFolderID = new UUID(im.binaryBucket, 0); |
315 | { | 317 | // } |
316 | InventoryFolderBase destinationFolder = new InventoryFolderBase(destinationFolderID, client.AgentId); | 318 | // |
317 | if (destinationFolder == null) | 319 | // if (destinationFolderID != UUID.Zero) |
318 | { | 320 | // { |
319 | m_log.WarnFormat( | 321 | // InventoryFolderBase destinationFolder = new InventoryFolderBase(destinationFolderID, client.AgentId); |
320 | "[INVENTORY TRANSFER]: TaskInventoryAccepted message from {0} in {1} specified folder {2} which does not exist", | 322 | // if (destinationFolder == null) |
321 | client.Name, scene.Name, destinationFolderID); | 323 | // { |
322 | 324 | // m_log.WarnFormat( | |
323 | return; | 325 | // "[INVENTORY TRANSFER]: TaskInventoryAccepted message from {0} in {1} specified folder {2} which does not exist", |
324 | } | 326 | // client.Name, scene.Name, destinationFolderID); |
325 | 327 | // | |
326 | IInventoryService invService = scene.InventoryService; | 328 | // return; |
327 | 329 | // } | |
328 | UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip | 330 | // |
329 | 331 | // IInventoryService invService = scene.InventoryService; | |
330 | InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId); | 332 | // |
331 | item = invService.GetItem(item); | 333 | // UUID inventoryID = new UUID(im.imSessionID); // The inventory item/folder, back from it's trip |
332 | InventoryFolderBase folder = null; | 334 | // |
333 | UUID? previousParentFolderID = null; | 335 | // InventoryItemBase item = new InventoryItemBase(inventoryID, client.AgentId); |
334 | 336 | // item = invService.GetItem(item); | |
335 | if (item != null) // It's an item | 337 | // InventoryFolderBase folder = null; |
336 | { | 338 | // UUID? previousParentFolderID = null; |
337 | previousParentFolderID = item.Folder; | 339 | // |
338 | item.Folder = destinationFolderID; | 340 | // if (item != null) // It's an item |
339 | 341 | // { | |
340 | invService.DeleteItems(item.Owner, new List<UUID>() { item.ID }); | 342 | // previousParentFolderID = item.Folder; |
341 | scene.AddInventoryItem(client, item); | 343 | // item.Folder = destinationFolderID; |
342 | } | 344 | // |
343 | else | 345 | // invService.DeleteItems(item.Owner, new List<UUID>() { item.ID }); |
344 | { | 346 | // scene.AddInventoryItem(client, item); |
345 | folder = new InventoryFolderBase(inventoryID, client.AgentId); | 347 | // } |
346 | folder = invService.GetFolder(folder); | 348 | // else |
347 | 349 | // { | |
348 | if (folder != null) // It's a folder | 350 | // folder = new InventoryFolderBase(inventoryID, client.AgentId); |
349 | { | 351 | // folder = invService.GetFolder(folder); |
350 | previousParentFolderID = folder.ParentID; | 352 | // |
351 | folder.ParentID = destinationFolderID; | 353 | // if (folder != null) // It's a folder |
352 | invService.MoveFolder(folder); | 354 | // { |
353 | } | 355 | // previousParentFolderID = folder.ParentID; |
354 | } | 356 | // folder.ParentID = destinationFolderID; |
355 | 357 | // invService.MoveFolder(folder); | |
356 | // Tell client about updates to original parent and new parent (this should probably be factored with existing move item/folder code). | 358 | // } |
357 | if (previousParentFolderID != null) | 359 | // } |
358 | { | 360 | // |
359 | InventoryFolderBase previousParentFolder | 361 | // // Tell client about updates to original parent and new parent (this should probably be factored with existing move item/folder code). |
360 | = new InventoryFolderBase((UUID)previousParentFolderID, client.AgentId); | 362 | // if (previousParentFolderID != null) |
361 | previousParentFolder = invService.GetFolder(previousParentFolder); | 363 | // { |
362 | scene.SendInventoryUpdate(client, previousParentFolder, true, true); | 364 | // InventoryFolderBase previousParentFolder |
363 | 365 | // = new InventoryFolderBase((UUID)previousParentFolderID, client.AgentId); | |
364 | scene.SendInventoryUpdate(client, destinationFolder, true, true); | 366 | // previousParentFolder = invService.GetFolder(previousParentFolder); |
365 | } | 367 | // scene.SendInventoryUpdate(client, previousParentFolder, true, true); |
366 | } | 368 | // |
367 | } | 369 | // scene.SendInventoryUpdate(client, destinationFolder, true, true); |
370 | // } | ||
371 | // } | ||
372 | // } | ||
368 | else if ( | 373 | else if ( |
369 | im.dialog == (byte)InstantMessageDialog.InventoryDeclined | 374 | im.dialog == (byte)InstantMessageDialog.InventoryDeclined |
370 | || im.dialog == (byte)InstantMessageDialog.TaskInventoryDeclined) | 375 | || im.dialog == (byte)InstantMessageDialog.TaskInventoryDeclined) |
@@ -434,83 +439,86 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer | |||
434 | scene.SendInventoryUpdate(client, trashFolder, true, true); | 439 | scene.SendInventoryUpdate(client, trashFolder, true, true); |
435 | } | 440 | } |
436 | 441 | ||
437 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); | 442 | if (im.dialog == (byte)InstantMessageDialog.InventoryDeclined) |
438 | |||
439 | if (user != null) // Local | ||
440 | { | ||
441 | user.ControllingClient.SendInstantMessage(im); | ||
442 | } | ||
443 | else | ||
444 | { | ||
445 | if (m_TransferModule != null) | ||
446 | m_TransferModule.SendInstantMessage(im, delegate(bool success) {}); | ||
447 | } | ||
448 | } | ||
449 | } | ||
450 | |||
451 | public bool NeedSceneCacheClear(UUID agentID, Scene scene) | ||
452 | { | ||
453 | if (!m_AgentRegions.ContainsKey(agentID)) | ||
454 | { | ||
455 | // Since we can get here two ways, we need to scan | ||
456 | // the scenes here. This is somewhat more expensive | ||
457 | // but helps avoid a nasty bug | ||
458 | // | ||
459 | |||
460 | foreach (Scene s in m_Scenelist) | ||
461 | { | 443 | { |
462 | ScenePresence presence; | 444 | ScenePresence user = scene.GetScenePresence(new UUID(im.toAgentID)); |
463 | 445 | ||
464 | if (s.TryGetScenePresence(agentID, out presence)) | 446 | if (user != null) // Local |
465 | { | 447 | { |
466 | // If the agent is in this scene, then we | 448 | user.ControllingClient.SendInstantMessage(im); |
467 | // are being called twice in a single | 449 | } |
468 | // teleport. This is wasteful of cycles | 450 | else |
469 | // but harmless due to this 2nd level check | 451 | { |
470 | // | 452 | if (m_TransferModule != null) |
471 | // If the agent is found in another scene | 453 | m_TransferModule.SendInstantMessage(im, delegate(bool success) { }); |
472 | // then the list wasn't current | ||
473 | // | ||
474 | // If the agent is totally unknown, then what | ||
475 | // are we even doing here?? | ||
476 | // | ||
477 | if (s == scene) | ||
478 | { | ||
479 | //m_log.Debug("[INVTRANSFERMOD]: s == scene. Returning true in " + scene.RegionInfo.RegionName); | ||
480 | return true; | ||
481 | } | ||
482 | else | ||
483 | { | ||
484 | //m_log.Debug("[INVTRANSFERMOD]: s != scene. Returning false in " + scene.RegionInfo.RegionName); | ||
485 | return false; | ||
486 | } | ||
487 | } | 454 | } |
488 | } | 455 | } |
489 | //m_log.Debug("[INVTRANSFERMOD]: agent not in scene. Returning true in " + scene.RegionInfo.RegionName); | ||
490 | return true; | ||
491 | } | ||
492 | |||
493 | // The agent is left in current Scene, so we must be | ||
494 | // going to another instance | ||
495 | // | ||
496 | if (m_AgentRegions[agentID] == scene) | ||
497 | { | ||
498 | //m_log.Debug("[INVTRANSFERMOD]: m_AgentRegions[agentID] == scene. Returning true in " + scene.RegionInfo.RegionName); | ||
499 | m_AgentRegions.Remove(agentID); | ||
500 | return true; | ||
501 | } | 456 | } |
502 | |||
503 | // Another region has claimed the agent | ||
504 | // | ||
505 | //m_log.Debug("[INVTRANSFERMOD]: last resort. Returning false in " + scene.RegionInfo.RegionName); | ||
506 | return false; | ||
507 | } | 457 | } |
508 | 458 | ||
509 | public void ClientLoggedOut(UUID agentID, Scene scene) | 459 | // public bool NeedSceneCacheClear(UUID agentID, Scene scene) |
510 | { | 460 | // { |
511 | if (m_AgentRegions.ContainsKey(agentID)) | 461 | // if (!m_AgentRegions.ContainsKey(agentID)) |
512 | m_AgentRegions.Remove(agentID); | 462 | // { |
513 | } | 463 | // // Since we can get here two ways, we need to scan |
464 | // // the scenes here. This is somewhat more expensive | ||
465 | // // but helps avoid a nasty bug | ||
466 | // // | ||
467 | // | ||
468 | // foreach (Scene s in m_Scenelist) | ||
469 | // { | ||
470 | // ScenePresence presence; | ||
471 | // | ||
472 | // if (s.TryGetScenePresence(agentID, out presence)) | ||
473 | // { | ||
474 | // // If the agent is in this scene, then we | ||
475 | // // are being called twice in a single | ||
476 | // // teleport. This is wasteful of cycles | ||
477 | // // but harmless due to this 2nd level check | ||
478 | // // | ||
479 | // // If the agent is found in another scene | ||
480 | // // then the list wasn't current | ||
481 | // // | ||
482 | // // If the agent is totally unknown, then what | ||
483 | // // are we even doing here?? | ||
484 | // // | ||
485 | // if (s == scene) | ||
486 | // { | ||
487 | // //m_log.Debug("[INVTRANSFERMOD]: s == scene. Returning true in " + scene.RegionInfo.RegionName); | ||
488 | // return true; | ||
489 | // } | ||
490 | // else | ||
491 | // { | ||
492 | // //m_log.Debug("[INVTRANSFERMOD]: s != scene. Returning false in " + scene.RegionInfo.RegionName); | ||
493 | // return false; | ||
494 | // } | ||
495 | // } | ||
496 | // } | ||
497 | // //m_log.Debug("[INVTRANSFERMOD]: agent not in scene. Returning true in " + scene.RegionInfo.RegionName); | ||
498 | // return true; | ||
499 | // } | ||
500 | // | ||
501 | // // The agent is left in current Scene, so we must be | ||
502 | // // going to another instance | ||
503 | // // | ||
504 | // if (m_AgentRegions[agentID] == scene) | ||
505 | // { | ||
506 | // //m_log.Debug("[INVTRANSFERMOD]: m_AgentRegions[agentID] == scene. Returning true in " + scene.RegionInfo.RegionName); | ||
507 | // m_AgentRegions.Remove(agentID); | ||
508 | // return true; | ||
509 | // } | ||
510 | // | ||
511 | // // Another region has claimed the agent | ||
512 | // // | ||
513 | // //m_log.Debug("[INVTRANSFERMOD]: last resort. Returning false in " + scene.RegionInfo.RegionName); | ||
514 | // return false; | ||
515 | // } | ||
516 | // | ||
517 | // public void ClientLoggedOut(UUID agentID, Scene scene) | ||
518 | // { | ||
519 | // if (m_AgentRegions.ContainsKey(agentID)) | ||
520 | // m_AgentRegions.Remove(agentID); | ||
521 | // } | ||
514 | 522 | ||
515 | /// <summary> | 523 | /// <summary> |
516 | /// | 524 | /// |
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs index 9c369f6..232a4fe 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/HGLureModule.cs | |||
@@ -42,7 +42,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
42 | 42 | ||
43 | namespace OpenSim.Region.CoreModules.Avatar.Lure | 43 | namespace OpenSim.Region.CoreModules.Avatar.Lure |
44 | { | 44 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGLureModule")] |
46 | public class HGLureModule : ISharedRegionModule | 46 | public class HGLureModule : ISharedRegionModule |
47 | { | 47 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger( | 48 | private static readonly ILog m_log = LogManager.GetLogger( |
diff --git a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs index 6ce9556..e4b0cfa 100644 --- a/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Lure/LureModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
@@ -37,6 +38,7 @@ using OpenSim.Region.Framework.Scenes; | |||
37 | 38 | ||
38 | namespace OpenSim.Region.CoreModules.Avatar.Lure | 39 | namespace OpenSim.Region.CoreModules.Avatar.Lure |
39 | { | 40 | { |
41 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LureModule")] | ||
40 | public class LureModule : ISharedRegionModule | 42 | public class LureModule : ISharedRegionModule |
41 | { | 43 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger( | 44 | private static readonly ILog m_log = LogManager.GetLogger( |
diff --git a/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs index 87ca327..bf24030 100644 --- a/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Profile/BasicProfileModule.cs | |||
@@ -42,7 +42,7 @@ using OpenSim.Services.Interfaces; | |||
42 | 42 | ||
43 | namespace OpenSim.Region.CoreModules.Avatar.Profile | 43 | namespace OpenSim.Region.CoreModules.Avatar.Profile |
44 | { | 44 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BasicProfileModule")] |
46 | public class BasicProfileModule : IProfileModule, ISharedRegionModule | 46 | public class BasicProfileModule : IProfileModule, ISharedRegionModule |
47 | { | 47 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs index 4ea85a8..8329af0 100644 --- a/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Caps/CapabilitiesModule.cs | |||
@@ -43,7 +43,7 @@ using Caps=OpenSim.Framework.Capabilities.Caps; | |||
43 | 43 | ||
44 | namespace OpenSim.Region.CoreModules.Framework | 44 | namespace OpenSim.Region.CoreModules.Framework |
45 | { | 45 | { |
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "CapabilitiesModule")] |
47 | public class CapabilitiesModule : INonSharedRegionModule, ICapabilitiesModule | 47 | public class CapabilitiesModule : INonSharedRegionModule, ICapabilitiesModule |
48 | { | 48 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs index 90fe430..3cb1901 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs | |||
@@ -43,9 +43,11 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
43 | using OpenMetaverse; | 43 | using OpenMetaverse; |
44 | using log4net; | 44 | using log4net; |
45 | using Nini.Config; | 45 | using Nini.Config; |
46 | using Mono.Addins; | ||
46 | 47 | ||
47 | namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | 48 | namespace OpenSim.Region.CoreModules.Framework.EntityTransfer |
48 | { | 49 | { |
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EntityTransferModule")] | ||
49 | public class EntityTransferModule : INonSharedRegionModule, IEntityTransferModule | 51 | public class EntityTransferModule : INonSharedRegionModule, IEntityTransferModule |
50 | { | 52 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -672,13 +674,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
672 | sp.Reset(); | 674 | sp.Reset(); |
673 | } | 675 | } |
674 | 676 | ||
675 | // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! | 677 | // Commented pending deletion since this method no longer appears to do anything at all |
676 | if (sp.Scene.NeedSceneCacheClear(sp.UUID)) | 678 | // // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! |
677 | { | 679 | // if (sp.Scene.NeedSceneCacheClear(sp.UUID)) |
678 | m_log.DebugFormat( | 680 | // { |
679 | "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed", | 681 | // m_log.DebugFormat( |
680 | sp.UUID); | 682 | // "[ENTITY TRANSFER MODULE]: User {0} is going to another region, profile cache removed", |
681 | } | 683 | // sp.UUID); |
684 | // } | ||
682 | 685 | ||
683 | m_entityTransferStateMachine.ResetFromTransit(sp.UUID); | 686 | m_entityTransferStateMachine.ResetFromTransit(sp.UUID); |
684 | } | 687 | } |
@@ -1237,14 +1240,14 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
1237 | 1240 | ||
1238 | AgentHasMovedAway(agent, false); | 1241 | AgentHasMovedAway(agent, false); |
1239 | 1242 | ||
1240 | // the user may change their profile information in other region, | 1243 | // // the user may change their profile information in other region, |
1241 | // so the userinfo in UserProfileCache is not reliable any more, delete it | 1244 | // // so the userinfo in UserProfileCache is not reliable any more, delete it |
1242 | // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! | 1245 | // // REFACTORING PROBLEM. Well, not a problem, but this method is HORRIBLE! |
1243 | if (agent.Scene.NeedSceneCacheClear(agent.UUID)) | 1246 | // if (agent.Scene.NeedSceneCacheClear(agent.UUID)) |
1244 | { | 1247 | // { |
1245 | m_log.DebugFormat( | 1248 | // m_log.DebugFormat( |
1246 | "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID); | 1249 | // "[ENTITY TRANSFER MODULE]: User {0} is going to another region", agent.UUID); |
1247 | } | 1250 | // } |
1248 | 1251 | ||
1249 | //m_log.Debug("AFTER CROSS"); | 1252 | //m_log.Debug("AFTER CROSS"); |
1250 | //Scene.DumpChildrenSeeds(UUID); | 1253 | //Scene.DumpChildrenSeeds(UUID); |
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs index 679be18..41ca13b 100644 --- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs +++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/HGEntityTransferModule.cs | |||
@@ -42,9 +42,11 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
42 | using OpenMetaverse; | 42 | using OpenMetaverse; |
43 | using log4net; | 43 | using log4net; |
44 | using Nini.Config; | 44 | using Nini.Config; |
45 | using Mono.Addins; | ||
45 | 46 | ||
46 | namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | 47 | namespace OpenSim.Region.CoreModules.Framework.EntityTransfer |
47 | { | 48 | { |
49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGEntityTransferModule")] | ||
48 | public class HGEntityTransferModule | 50 | public class HGEntityTransferModule |
49 | : EntityTransferModule, INonSharedRegionModule, IEntityTransferModule, IUserAgentVerificationModule | 51 | : EntityTransferModule, INonSharedRegionModule, IEntityTransferModule, IUserAgentVerificationModule |
50 | { | 52 | { |
@@ -259,8 +261,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer | |||
259 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0) | 261 | if (flags == -1 /* no region in DB */ || (flags & (int)OpenSim.Framework.RegionFlags.Hyperlink) != 0) |
260 | { | 262 | { |
261 | // this user is going to another grid | 263 | // this user is going to another grid |
262 | // check if HyperGrid teleport is allowed, based on user level | 264 | // for local users, check if HyperGrid teleport is allowed, based on user level |
263 | if (sp.UserLevel < m_levelHGTeleport) | 265 | if (Scene.UserManagementModule.IsLocalGridUser(sp.UUID) && sp.UserLevel < m_levelHGTeleport) |
264 | { | 266 | { |
265 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to HG teleport agent due to insufficient UserLevel."); | 267 | m_log.WarnFormat("[HG ENTITY TRANSFER MODULE]: Unable to HG teleport agent due to insufficient UserLevel."); |
266 | reason = "Hypergrid teleport not allowed"; | 268 | reason = "Hypergrid teleport not allowed"; |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs index 80257bd..964efda 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGInventoryAccessModule.cs | |||
@@ -42,9 +42,11 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
42 | using OpenMetaverse; | 42 | using OpenMetaverse; |
43 | using log4net; | 43 | using log4net; |
44 | using Nini.Config; | 44 | using Nini.Config; |
45 | using Mono.Addins; | ||
45 | 46 | ||
46 | namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | 47 | namespace OpenSim.Region.CoreModules.Framework.InventoryAccess |
47 | { | 48 | { |
49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGInventoryAccessModule")] | ||
48 | public class HGInventoryAccessModule : BasicInventoryAccessModule, INonSharedRegionModule, IInventoryAccessModule | 50 | public class HGInventoryAccessModule : BasicInventoryAccessModule, INonSharedRegionModule, IInventoryAccessModule |
49 | { | 51 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -92,7 +94,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
92 | m_HomeURI = thisModuleConfig.GetString("HomeURI", m_HomeURI); | 94 | m_HomeURI = thisModuleConfig.GetString("HomeURI", m_HomeURI); |
93 | m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); | 95 | m_OutboundPermission = thisModuleConfig.GetBoolean("OutboundPermission", true); |
94 | m_ThisGatekeeper = thisModuleConfig.GetString("Gatekeeper", string.Empty); | 96 | m_ThisGatekeeper = thisModuleConfig.GetString("Gatekeeper", string.Empty); |
95 | m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", false); | 97 | m_RestrictInventoryAccessAbroad = thisModuleConfig.GetBoolean("RestrictInventoryAccessAbroad", true); |
96 | } | 98 | } |
97 | else | 99 | else |
98 | m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); | 100 | m_log.Warn("[HG INVENTORY ACCESS MODULE]: HGInventoryAccessModule configs not found. ProfileServerURI not set!"); |
@@ -351,6 +353,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
351 | 353 | ||
352 | private void ProcessInventoryForArriving(IClientAPI client) | 354 | private void ProcessInventoryForArriving(IClientAPI client) |
353 | { | 355 | { |
356 | // No-op for now, but we may need to do something for freign users inventory | ||
354 | } | 357 | } |
355 | 358 | ||
356 | // | 359 | // |
@@ -397,6 +400,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
397 | 400 | ||
398 | private void ProcessInventoryForLeaving(IClientAPI client) | 401 | private void ProcessInventoryForLeaving(IClientAPI client) |
399 | { | 402 | { |
403 | // No-op for now | ||
400 | } | 404 | } |
401 | 405 | ||
402 | #endregion | 406 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 8b34c28..8b7c16e 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -46,9 +46,11 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
46 | using OpenMetaverse; | 46 | using OpenMetaverse; |
47 | using log4net; | 47 | using log4net; |
48 | using Nini.Config; | 48 | using Nini.Config; |
49 | using Mono.Addins; | ||
49 | 50 | ||
50 | namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | 51 | namespace OpenSim.Region.CoreModules.Framework.InventoryAccess |
51 | { | 52 | { |
53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BasicInventoryAccessModule")] | ||
52 | public class BasicInventoryAccessModule : INonSharedRegionModule, IInventoryAccessModule | 54 | public class BasicInventoryAccessModule : INonSharedRegionModule, IInventoryAccessModule |
53 | { | 55 | { |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 56 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -180,12 +182,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
180 | if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) | 182 | if (!m_Scene.Permissions.CanCreateUserInventory(invType, remoteClient.AgentId)) |
181 | return; | 183 | return; |
182 | 184 | ||
183 | InventoryFolderBase f = new InventoryFolderBase(folderID, remoteClient.AgentId); | ||
184 | InventoryFolderBase folder = m_Scene.InventoryService.GetFolder(f); | ||
185 | |||
186 | if (folder == null || folder.Owner != remoteClient.AgentId) | ||
187 | return; | ||
188 | |||
189 | if (transactionID == UUID.Zero) | 185 | if (transactionID == UUID.Zero) |
190 | { | 186 | { |
191 | ScenePresence presence; | 187 | ScenePresence presence; |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs index 21d8bd7..b768257 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs | |||
@@ -49,7 +49,7 @@ using OpenSim.Tests.Common.Mock; | |||
49 | namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | 49 | namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests |
50 | { | 50 | { |
51 | [TestFixture] | 51 | [TestFixture] |
52 | public class InventoryAccessModuleTests | 52 | public class InventoryAccessModuleTests : OpenSimTestCase |
53 | { | 53 | { |
54 | protected TestScene m_scene; | 54 | protected TestScene m_scene; |
55 | protected BasicInventoryAccessModule m_iam; | 55 | protected BasicInventoryAccessModule m_iam; |
diff --git a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs index 3155ce7..ec22146 100644 --- a/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Library/LibraryModule.cs | |||
@@ -41,10 +41,12 @@ using OpenSim.Server.Base; | |||
41 | 41 | ||
42 | using OpenMetaverse; | 42 | using OpenMetaverse; |
43 | using log4net; | 43 | using log4net; |
44 | using Mono.Addins; | ||
44 | using Nini.Config; | 45 | using Nini.Config; |
45 | 46 | ||
46 | namespace OpenSim.Region.CoreModules.Framework.Library | 47 | namespace OpenSim.Region.CoreModules.Framework.Library |
47 | { | 48 | { |
49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LibraryModule")] | ||
48 | public class LibraryModule : ISharedRegionModule | 50 | public class LibraryModule : ISharedRegionModule |
49 | { | 51 | { |
50 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs index e411585..d84460a 100644 --- a/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs +++ b/OpenSim/Region/CoreModules/Framework/Monitoring/MonitorModule.cs | |||
@@ -38,10 +38,12 @@ using OpenSim.Region.CoreModules.Framework.Monitoring.Alerts; | |||
38 | using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors; | 38 | using OpenSim.Region.CoreModules.Framework.Monitoring.Monitors; |
39 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
40 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
41 | using Mono.Addins; | ||
41 | 42 | ||
42 | namespace OpenSim.Region.CoreModules.Framework.Monitoring | 43 | namespace OpenSim.Region.CoreModules.Framework.Monitoring |
43 | { | 44 | { |
44 | public class MonitorModule : IRegionModule | 45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MonitorModule")] |
46 | public class MonitorModule : INonSharedRegionModule | ||
45 | { | 47 | { |
46 | /// <summary> | 48 | /// <summary> |
47 | /// Is this module enabled? | 49 | /// Is this module enabled? |
@@ -62,14 +64,14 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
62 | private readonly List<IAlert> m_alerts = new List<IAlert>(); | 64 | private readonly List<IAlert> m_alerts = new List<IAlert>(); |
63 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 65 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
64 | 66 | ||
65 | #region Implementation of IRegionModule | ||
66 | |||
67 | public MonitorModule() | 67 | public MonitorModule() |
68 | { | 68 | { |
69 | Enabled = true; | 69 | Enabled = true; |
70 | } | 70 | } |
71 | 71 | ||
72 | public void Initialise(Scene scene, IConfigSource source) | 72 | #region Implementation of INonSharedRegionModule |
73 | |||
74 | public void Initialise(IConfigSource source) | ||
73 | { | 75 | { |
74 | IConfig cnfg = source.Configs["Monitoring"]; | 76 | IConfig cnfg = source.Configs["Monitoring"]; |
75 | 77 | ||
@@ -79,6 +81,13 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
79 | if (!Enabled) | 81 | if (!Enabled) |
80 | return; | 82 | return; |
81 | 83 | ||
84 | } | ||
85 | |||
86 | public void AddRegion(Scene scene) | ||
87 | { | ||
88 | if (!Enabled) | ||
89 | return; | ||
90 | |||
82 | m_scene = scene; | 91 | m_scene = scene; |
83 | 92 | ||
84 | m_scene.AddCommand("General", this, "monitor report", | 93 | m_scene.AddCommand("General", this, "monitor report", |
@@ -89,101 +98,42 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
89 | MainServer.Instance.AddHTTPHandler("/monitorstats/" + m_scene.RegionInfo.RegionID, StatsPage); | 98 | MainServer.Instance.AddHTTPHandler("/monitorstats/" + m_scene.RegionInfo.RegionID, StatsPage); |
90 | MainServer.Instance.AddHTTPHandler( | 99 | MainServer.Instance.AddHTTPHandler( |
91 | "/monitorstats/" + Uri.EscapeDataString(m_scene.RegionInfo.RegionName), StatsPage); | 100 | "/monitorstats/" + Uri.EscapeDataString(m_scene.RegionInfo.RegionName), StatsPage); |
101 | |||
102 | AddMonitors(); | ||
92 | } | 103 | } |
93 | 104 | ||
94 | public void DebugMonitors(string module, string[] args) | 105 | public void RemoveRegion(Scene scene) |
95 | { | 106 | { |
96 | foreach (IMonitor monitor in m_staticMonitors) | 107 | if (!Enabled) |
97 | { | 108 | return; |
98 | MainConsole.Instance.OutputFormat( | ||
99 | "[MONITOR MODULE]: {0} reports {1} = {2}", | ||
100 | m_scene.RegionInfo.RegionName, monitor.GetFriendlyName(), monitor.GetFriendlyValue()); | ||
101 | } | ||
102 | 109 | ||
103 | foreach (KeyValuePair<string, float> tuple in m_scene.StatsReporter.GetExtraSimStats()) | 110 | MainServer.Instance.RemoveHTTPHandler("GET", "/monitorstats/" + m_scene.RegionInfo.RegionID); |
104 | { | 111 | MainServer.Instance.RemoveHTTPHandler("GET", "/monitorstats/" + Uri.EscapeDataString(m_scene.RegionInfo.RegionName)); |
105 | MainConsole.Instance.OutputFormat( | 112 | m_scene = null; |
106 | "[MONITOR MODULE]: {0} reports {1} = {2}", | ||
107 | m_scene.RegionInfo.RegionName, tuple.Key, tuple.Value); | ||
108 | } | ||
109 | } | 113 | } |
110 | 114 | ||
111 | public void TestAlerts() | 115 | public void Close() |
112 | { | 116 | { |
113 | foreach (IAlert alert in m_alerts) | ||
114 | { | ||
115 | alert.Test(); | ||
116 | } | ||
117 | } | 117 | } |
118 | 118 | ||
119 | public Hashtable StatsPage(Hashtable request) | 119 | public string Name |
120 | { | 120 | { |
121 | // If request was for a specific monitor | 121 | get { return "Region Health Monitoring Module"; } |
122 | // eg url/?monitor=Monitor.Name | 122 | } |
123 | if (request.ContainsKey("monitor")) | ||
124 | { | ||
125 | string monID = (string) request["monitor"]; | ||
126 | |||
127 | foreach (IMonitor monitor in m_staticMonitors) | ||
128 | { | ||
129 | string elemName = monitor.ToString(); | ||
130 | if (elemName.StartsWith(monitor.GetType().Namespace)) | ||
131 | elemName = elemName.Substring(monitor.GetType().Namespace.Length + 1); | ||
132 | |||
133 | if (elemName == monID || monitor.ToString() == monID) | ||
134 | { | ||
135 | Hashtable ereply3 = new Hashtable(); | ||
136 | |||
137 | ereply3["int_response_code"] = 404; // 200 OK | ||
138 | ereply3["str_response_string"] = monitor.GetValue().ToString(); | ||
139 | ereply3["content_type"] = "text/plain"; | ||
140 | |||
141 | return ereply3; | ||
142 | } | ||
143 | } | ||
144 | |||
145 | // FIXME: Arguably this should also be done with dynamic monitors but I'm not sure what the above code | ||
146 | // is even doing. Why are we inspecting the type of the monitor??? | ||
147 | |||
148 | // No monitor with that name | ||
149 | Hashtable ereply2 = new Hashtable(); | ||
150 | |||
151 | ereply2["int_response_code"] = 404; // 200 OK | ||
152 | ereply2["str_response_string"] = "No such monitor"; | ||
153 | ereply2["content_type"] = "text/plain"; | ||
154 | |||
155 | return ereply2; | ||
156 | } | ||
157 | |||
158 | string xml = "<data>"; | ||
159 | foreach (IMonitor monitor in m_staticMonitors) | ||
160 | { | ||
161 | string elemName = monitor.GetName(); | ||
162 | xml += "<" + elemName + ">" + monitor.GetValue().ToString() + "</" + elemName + ">"; | ||
163 | // m_log.DebugFormat("[MONITOR MODULE]: {0} = {1}", elemName, monitor.GetValue()); | ||
164 | } | ||
165 | |||
166 | foreach (KeyValuePair<string, float> tuple in m_scene.StatsReporter.GetExtraSimStats()) | ||
167 | { | ||
168 | xml += "<" + tuple.Key + ">" + tuple.Value + "</" + tuple.Key + ">"; | ||
169 | } | ||
170 | |||
171 | xml += "</data>"; | ||
172 | |||
173 | Hashtable ereply = new Hashtable(); | ||
174 | |||
175 | ereply["int_response_code"] = 200; // 200 OK | ||
176 | ereply["str_response_string"] = xml; | ||
177 | ereply["content_type"] = "text/xml"; | ||
178 | 123 | ||
179 | return ereply; | 124 | public void RegionLoaded(Scene scene) |
125 | { | ||
180 | } | 126 | } |
181 | 127 | ||
182 | public void PostInitialise() | 128 | public Type ReplaceableInterface |
183 | { | 129 | { |
184 | if (!Enabled) | 130 | get { return null; } |
185 | return; | 131 | } |
132 | |||
133 | #endregion | ||
186 | 134 | ||
135 | public void AddMonitors() | ||
136 | { | ||
187 | m_staticMonitors.Add(new AgentCountMonitor(m_scene)); | 137 | m_staticMonitors.Add(new AgentCountMonitor(m_scene)); |
188 | m_staticMonitors.Add(new ChildAgentCountMonitor(m_scene)); | 138 | m_staticMonitors.Add(new ChildAgentCountMonitor(m_scene)); |
189 | m_staticMonitors.Add(new GCMemoryMonitor()); | 139 | m_staticMonitors.Add(new GCMemoryMonitor()); |
@@ -196,7 +146,7 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
196 | m_staticMonitors.Add(new EventFrameMonitor(m_scene)); | 146 | m_staticMonitors.Add(new EventFrameMonitor(m_scene)); |
197 | m_staticMonitors.Add(new LandFrameMonitor(m_scene)); | 147 | m_staticMonitors.Add(new LandFrameMonitor(m_scene)); |
198 | m_staticMonitors.Add(new LastFrameTimeMonitor(m_scene)); | 148 | m_staticMonitors.Add(new LastFrameTimeMonitor(m_scene)); |
199 | 149 | ||
200 | m_staticMonitors.Add( | 150 | m_staticMonitors.Add( |
201 | new GenericMonitor( | 151 | new GenericMonitor( |
202 | m_scene, | 152 | m_scene, |
@@ -357,25 +307,98 @@ namespace OpenSim.Region.CoreModules.Framework.Monitoring | |||
357 | } | 307 | } |
358 | } | 308 | } |
359 | 309 | ||
360 | void OnTriggerAlert(System.Type reporter, string reason, bool fatal) | 310 | public void DebugMonitors(string module, string[] args) |
361 | { | 311 | { |
362 | m_log.Error("[Monitor] " + reporter.Name + " for " + m_scene.RegionInfo.RegionName + " reports " + reason + " (Fatal: " + fatal + ")"); | 312 | foreach (IMonitor monitor in m_staticMonitors) |
313 | { | ||
314 | MainConsole.Instance.OutputFormat( | ||
315 | "[MONITOR MODULE]: {0} reports {1} = {2}", | ||
316 | m_scene.RegionInfo.RegionName, monitor.GetFriendlyName(), monitor.GetFriendlyValue()); | ||
317 | } | ||
318 | |||
319 | foreach (KeyValuePair<string, float> tuple in m_scene.StatsReporter.GetExtraSimStats()) | ||
320 | { | ||
321 | MainConsole.Instance.OutputFormat( | ||
322 | "[MONITOR MODULE]: {0} reports {1} = {2}", | ||
323 | m_scene.RegionInfo.RegionName, tuple.Key, tuple.Value); | ||
324 | } | ||
363 | } | 325 | } |
364 | 326 | ||
365 | public void Close() | 327 | public void TestAlerts() |
366 | { | 328 | { |
329 | foreach (IAlert alert in m_alerts) | ||
330 | { | ||
331 | alert.Test(); | ||
332 | } | ||
367 | } | 333 | } |
368 | 334 | ||
369 | public string Name | 335 | public Hashtable StatsPage(Hashtable request) |
370 | { | 336 | { |
371 | get { return "Region Health Monitoring Module"; } | 337 | // If request was for a specific monitor |
338 | // eg url/?monitor=Monitor.Name | ||
339 | if (request.ContainsKey("monitor")) | ||
340 | { | ||
341 | string monID = (string) request["monitor"]; | ||
342 | |||
343 | foreach (IMonitor monitor in m_staticMonitors) | ||
344 | { | ||
345 | string elemName = monitor.ToString(); | ||
346 | if (elemName.StartsWith(monitor.GetType().Namespace)) | ||
347 | elemName = elemName.Substring(monitor.GetType().Namespace.Length + 1); | ||
348 | |||
349 | if (elemName == monID || monitor.ToString() == monID) | ||
350 | { | ||
351 | Hashtable ereply3 = new Hashtable(); | ||
352 | |||
353 | ereply3["int_response_code"] = 404; // 200 OK | ||
354 | ereply3["str_response_string"] = monitor.GetValue().ToString(); | ||
355 | ereply3["content_type"] = "text/plain"; | ||
356 | |||
357 | return ereply3; | ||
358 | } | ||
359 | } | ||
360 | |||
361 | // FIXME: Arguably this should also be done with dynamic monitors but I'm not sure what the above code | ||
362 | // is even doing. Why are we inspecting the type of the monitor??? | ||
363 | |||
364 | // No monitor with that name | ||
365 | Hashtable ereply2 = new Hashtable(); | ||
366 | |||
367 | ereply2["int_response_code"] = 404; // 200 OK | ||
368 | ereply2["str_response_string"] = "No such monitor"; | ||
369 | ereply2["content_type"] = "text/plain"; | ||
370 | |||
371 | return ereply2; | ||
372 | } | ||
373 | |||
374 | string xml = "<data>"; | ||
375 | foreach (IMonitor monitor in m_staticMonitors) | ||
376 | { | ||
377 | string elemName = monitor.GetName(); | ||
378 | xml += "<" + elemName + ">" + monitor.GetValue().ToString() + "</" + elemName + ">"; | ||
379 | // m_log.DebugFormat("[MONITOR MODULE]: {0} = {1}", elemName, monitor.GetValue()); | ||
380 | } | ||
381 | |||
382 | foreach (KeyValuePair<string, float> tuple in m_scene.StatsReporter.GetExtraSimStats()) | ||
383 | { | ||
384 | xml += "<" + tuple.Key + ">" + tuple.Value + "</" + tuple.Key + ">"; | ||
385 | } | ||
386 | |||
387 | xml += "</data>"; | ||
388 | |||
389 | Hashtable ereply = new Hashtable(); | ||
390 | |||
391 | ereply["int_response_code"] = 200; // 200 OK | ||
392 | ereply["str_response_string"] = xml; | ||
393 | ereply["content_type"] = "text/xml"; | ||
394 | |||
395 | return ereply; | ||
372 | } | 396 | } |
373 | 397 | ||
374 | public bool IsSharedModule | 398 | void OnTriggerAlert(System.Type reporter, string reason, bool fatal) |
375 | { | 399 | { |
376 | get { return false; } | 400 | m_log.Error("[Monitor] " + reporter.Name + " for " + m_scene.RegionInfo.RegionName + " reports " + reason + " (Fatal: " + fatal + ")"); |
377 | } | 401 | } |
378 | 402 | ||
379 | #endregion | ||
380 | } | 403 | } |
381 | } | 404 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs index acefc97..4ef57fe 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/HGUserManagementModule.cs | |||
@@ -41,9 +41,11 @@ using OpenMetaverse; | |||
41 | using OpenMetaverse.Packets; | 41 | using OpenMetaverse.Packets; |
42 | using log4net; | 42 | using log4net; |
43 | using Nini.Config; | 43 | using Nini.Config; |
44 | using Mono.Addins; | ||
44 | 45 | ||
45 | namespace OpenSim.Region.CoreModules.Framework.UserManagement | 46 | namespace OpenSim.Region.CoreModules.Framework.UserManagement |
46 | { | 47 | { |
48 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGUserManagementModule")] | ||
47 | public class HGUserManagementModule : UserManagementModule, ISharedRegionModule, IUserManagement | 49 | public class HGUserManagementModule : UserManagementModule, ISharedRegionModule, IUserManagement |
48 | { | 50 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs index b4811da..86e7004 100644 --- a/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs +++ b/OpenSim/Region/CoreModules/Framework/UserManagement/UserManagementModule.cs | |||
@@ -42,6 +42,7 @@ using OpenMetaverse; | |||
42 | using OpenMetaverse.Packets; | 42 | using OpenMetaverse.Packets; |
43 | using log4net; | 43 | using log4net; |
44 | using Nini.Config; | 44 | using Nini.Config; |
45 | using Mono.Addins; | ||
45 | 46 | ||
46 | namespace OpenSim.Region.CoreModules.Framework.UserManagement | 47 | namespace OpenSim.Region.CoreModules.Framework.UserManagement |
47 | { | 48 | { |
@@ -54,6 +55,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement | |||
54 | public Dictionary<string, object> ServerURLs { get; set; } | 55 | public Dictionary<string, object> ServerURLs { get; set; } |
55 | } | 56 | } |
56 | 57 | ||
58 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UserManagementModule")] | ||
57 | public class UserManagementModule : ISharedRegionModule, IUserManagement | 59 | public class UserManagementModule : ISharedRegionModule, IUserManagement |
58 | { | 60 | { |
59 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs index 0c60391..e0921ad 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGWorldMapModule.cs | |||
@@ -31,6 +31,7 @@ using System.Reflection; | |||
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using Mono.Addins; | ||
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
35 | using OpenSim.Region.CoreModules.World.WorldMap; | 36 | using OpenSim.Region.CoreModules.World.WorldMap; |
36 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
@@ -39,6 +40,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.Hypergrid | 41 | namespace OpenSim.Region.CoreModules.Hypergrid |
41 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGWorldMapModule")] | ||
42 | public class HGWorldMapModule : WorldMapModule | 44 | public class HGWorldMapModule : WorldMapModule |
43 | { | 45 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs b/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs deleted file mode 100644 index 2cc0a07..0000000 --- a/OpenSim/Region/CoreModules/InterGrid/OGSRadmin.cs +++ /dev/null | |||
@@ -1,150 +0,0 @@ | |||
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; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Net; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using Nwc.XmlRpc; | ||
37 | using OpenMetaverse; | ||
38 | using OpenSim.Framework; | ||
39 | using OpenSim.Framework.Communications; | ||
40 | using OpenSim.Framework.Servers; | ||
41 | using OpenSim.Region.Framework.Interfaces; | ||
42 | using OpenSim.Region.Framework.Scenes; | ||
43 | |||
44 | namespace OpenSim.Region.CoreModules.InterGrid | ||
45 | { | ||
46 | public class OGSRadmin : IRegionModule | ||
47 | { | ||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | private readonly List<Scene> m_scenes = new List<Scene>(); | ||
50 | private IConfigSource m_settings; | ||
51 | |||
52 | #region Implementation of IRegionModuleBase | ||
53 | |||
54 | public string Name | ||
55 | { | ||
56 | get { return "OGS Supporting RAdmin"; } | ||
57 | } | ||
58 | |||
59 | |||
60 | public void Initialise(IConfigSource source) | ||
61 | { | ||
62 | m_settings = source; | ||
63 | } | ||
64 | |||
65 | public void Close() | ||
66 | { | ||
67 | |||
68 | } | ||
69 | |||
70 | public void AddRegion(Scene scene) | ||
71 | { | ||
72 | lock (m_scenes) | ||
73 | m_scenes.Add(scene); | ||
74 | } | ||
75 | |||
76 | public void RemoveRegion(Scene scene) | ||
77 | { | ||
78 | lock (m_scenes) | ||
79 | m_scenes.Remove(scene); | ||
80 | } | ||
81 | |||
82 | public void RegionLoaded(Scene scene) | ||
83 | { | ||
84 | |||
85 | } | ||
86 | |||
87 | public void PostInitialise() | ||
88 | { | ||
89 | if (m_settings.Configs["Startup"].GetBoolean("gridmode", false)) | ||
90 | { | ||
91 | MainServer.Instance.AddXmlRPCHandler("grid_message", GridWideMessage); | ||
92 | } | ||
93 | } | ||
94 | |||
95 | #endregion | ||
96 | |||
97 | #region IRegionModule | ||
98 | |||
99 | public void Initialise(Scene scene, IConfigSource source) | ||
100 | { | ||
101 | m_settings = source; | ||
102 | |||
103 | lock (m_scenes) | ||
104 | m_scenes.Add(scene); | ||
105 | } | ||
106 | |||
107 | public bool IsSharedModule | ||
108 | { | ||
109 | get { return true; } | ||
110 | } | ||
111 | |||
112 | #endregion | ||
113 | |||
114 | public XmlRpcResponse GridWideMessage(XmlRpcRequest req, IPEndPoint remoteClient) | ||
115 | { | ||
116 | XmlRpcResponse response = new XmlRpcResponse(); | ||
117 | Hashtable responseData = new Hashtable(); | ||
118 | |||
119 | Hashtable requestData = (Hashtable)req.Params[0]; | ||
120 | |||
121 | // REFACTORING PROBLEM. This authorization needs to be replaced with some other | ||
122 | //if ((!requestData.Contains("password") || (string)requestData["password"] != m_com.NetworkServersInfo.GridRecvKey)) | ||
123 | //{ | ||
124 | // responseData["accepted"] = false; | ||
125 | // responseData["success"] = false; | ||
126 | // responseData["error"] = "Invalid Key"; | ||
127 | // response.Value = responseData; | ||
128 | // return response; | ||
129 | //} | ||
130 | |||
131 | string message = (string)requestData["message"]; | ||
132 | string user = (string)requestData["user"]; | ||
133 | m_log.InfoFormat("[RADMIN]: Broadcasting: {0}", message); | ||
134 | |||
135 | lock (m_scenes) | ||
136 | foreach (Scene scene in m_scenes) | ||
137 | { | ||
138 | IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>(); | ||
139 | if (dialogModule != null) | ||
140 | dialogModule.SendNotificationToUsersInRegion(UUID.Random(), user, message); | ||
141 | } | ||
142 | |||
143 | responseData["accepted"] = true; | ||
144 | responseData["success"] = true; | ||
145 | response.Value = responseData; | ||
146 | |||
147 | return response; | ||
148 | } | ||
149 | } | ||
150 | } | ||
diff --git a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs b/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs deleted file mode 100644 index 4a76b00..0000000 --- a/OpenSim/Region/CoreModules/InterGrid/OpenGridProtocolModule.cs +++ /dev/null | |||
@@ -1,1297 +0,0 @@ | |||
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.IO; | ||
31 | using System.Net; | ||
32 | using System.Net.Security; | ||
33 | using System.Reflection; | ||
34 | using System.Security.Cryptography.X509Certificates; | ||
35 | using System.Threading; | ||
36 | using System.Web; | ||
37 | using log4net; | ||
38 | using Nini.Config; | ||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.StructuredData; | ||
41 | using OpenSim.Framework; | ||
42 | using OpenSim.Framework.Capabilities; | ||
43 | using OpenSim.Framework.Monitoring; | ||
44 | using OpenSim.Framework.Servers; | ||
45 | using OpenSim.Region.Framework.Interfaces; | ||
46 | using OpenSim.Region.Framework.Scenes; | ||
47 | using Caps=OpenSim.Framework.Capabilities.Caps; | ||
48 | using OSDArray=OpenMetaverse.StructuredData.OSDArray; | ||
49 | using OSDMap=OpenMetaverse.StructuredData.OSDMap; | ||
50 | |||
51 | namespace OpenSim.Region.CoreModules.InterGrid | ||
52 | { | ||
53 | public struct OGPState | ||
54 | { | ||
55 | public string first_name; | ||
56 | public string last_name; | ||
57 | public UUID agent_id; | ||
58 | public UUID local_agent_id; | ||
59 | public UUID region_id; | ||
60 | public uint circuit_code; | ||
61 | public UUID secure_session_id; | ||
62 | public UUID session_id; | ||
63 | public bool agent_access; | ||
64 | public string sim_access; | ||
65 | public uint god_level; | ||
66 | public bool god_overide; | ||
67 | public bool identified; | ||
68 | public bool transacted; | ||
69 | public bool age_verified; | ||
70 | public bool allow_redirect; | ||
71 | public int limited_to_estate; | ||
72 | public string inventory_host; | ||
73 | public bool src_can_see_mainland; | ||
74 | public int src_estate_id; | ||
75 | public int src_version; | ||
76 | public int src_parent_estate_id; | ||
77 | public bool visible_to_parent; | ||
78 | public string teleported_into_region; | ||
79 | } | ||
80 | |||
81 | public class OpenGridProtocolModule : IRegionModule | ||
82 | { | ||
83 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
84 | private List<Scene> m_scene = new List<Scene>(); | ||
85 | |||
86 | private Dictionary<string, AgentCircuitData> CapsLoginID = new Dictionary<string, AgentCircuitData>(); | ||
87 | private Dictionary<UUID, OGPState> m_OGPState = new Dictionary<UUID, OGPState>(); | ||
88 | private Dictionary<string, string> m_loginToRegionState = new Dictionary<string, string>(); | ||
89 | |||
90 | |||
91 | private string LastNameSuffix = "_EXTERNAL"; | ||
92 | private string FirstNamePrefix = ""; | ||
93 | private string httpsCN = ""; | ||
94 | private bool httpSSL = false; | ||
95 | private uint httpsslport = 0; | ||
96 | // private bool GridMode = false; | ||
97 | |||
98 | #region IRegionModule Members | ||
99 | |||
100 | public void Initialise(Scene scene, IConfigSource config) | ||
101 | { | ||
102 | bool enabled = false; | ||
103 | IConfig cfg = null; | ||
104 | IConfig httpcfg = null; | ||
105 | // IConfig startupcfg = null; | ||
106 | try | ||
107 | { | ||
108 | cfg = config.Configs["OpenGridProtocol"]; | ||
109 | } catch (NullReferenceException) | ||
110 | { | ||
111 | enabled = false; | ||
112 | } | ||
113 | |||
114 | try | ||
115 | { | ||
116 | httpcfg = config.Configs["Network"]; | ||
117 | } | ||
118 | catch (NullReferenceException) | ||
119 | { | ||
120 | |||
121 | } | ||
122 | // try | ||
123 | // { | ||
124 | // startupcfg = config.Configs["Startup"]; | ||
125 | // } | ||
126 | // catch (NullReferenceException) | ||
127 | // { | ||
128 | // | ||
129 | // } | ||
130 | |||
131 | // if (startupcfg != null) | ||
132 | // { | ||
133 | // GridMode = enabled = startupcfg.GetBoolean("gridmode", false); | ||
134 | // } | ||
135 | |||
136 | if (cfg != null) | ||
137 | { | ||
138 | enabled = cfg.GetBoolean("ogp_enabled", false); | ||
139 | LastNameSuffix = cfg.GetString("ogp_lastname_suffix", "_EXTERNAL"); | ||
140 | FirstNamePrefix = cfg.GetString("ogp_firstname_prefix", ""); | ||
141 | if (enabled) | ||
142 | { | ||
143 | m_log.Warn("[OGP]: Open Grid Protocol is on, Listening for Clients on /agent/"); | ||
144 | lock (m_scene) | ||
145 | { | ||
146 | if (m_scene.Count == 0) | ||
147 | { | ||
148 | MainServer.Instance.AddLLSDHandler("/agent/", ProcessAgentDomainMessage); | ||
149 | MainServer.Instance.AddLLSDHandler("/", ProcessRegionDomainSeed); | ||
150 | try | ||
151 | { | ||
152 | ServicePointManager.ServerCertificateValidationCallback += customXertificateValidation; | ||
153 | } | ||
154 | catch (NotImplementedException) | ||
155 | { | ||
156 | try | ||
157 | { | ||
158 | #pragma warning disable 0612, 0618 | ||
159 | // Mono does not implement the ServicePointManager.ServerCertificateValidationCallback yet! Don't remove this! | ||
160 | ServicePointManager.CertificatePolicy = new MonoCert(); | ||
161 | #pragma warning restore 0612, 0618 | ||
162 | } | ||
163 | catch (Exception) | ||
164 | { | ||
165 | m_log.Error("[OGP]: Certificate validation handler change not supported. You may get ssl certificate validation errors teleporting from your region to some SSL regions."); | ||
166 | } | ||
167 | } | ||
168 | |||
169 | } | ||
170 | // can't pick the region 'agent' because it would conflict with our agent domain handler | ||
171 | // a zero length region name would conflict with are base region seed cap | ||
172 | if (!SceneListDuplicateCheck(scene.RegionInfo.RegionName) && scene.RegionInfo.RegionName.ToLower() != "agent" && scene.RegionInfo.RegionName.Length > 0) | ||
173 | { | ||
174 | MainServer.Instance.AddLLSDHandler( | ||
175 | "/" + HttpUtility.UrlPathEncode(scene.RegionInfo.RegionName.ToLower()), | ||
176 | ProcessRegionDomainSeed); | ||
177 | } | ||
178 | |||
179 | if (!m_scene.Contains(scene)) | ||
180 | m_scene.Add(scene); | ||
181 | } | ||
182 | } | ||
183 | } | ||
184 | lock (m_scene) | ||
185 | { | ||
186 | if (m_scene.Count == 1) | ||
187 | { | ||
188 | if (httpcfg != null) | ||
189 | { | ||
190 | httpSSL = httpcfg.GetBoolean("http_listener_ssl", false); | ||
191 | httpsCN = httpcfg.GetString("http_listener_cn", scene.RegionInfo.ExternalHostName); | ||
192 | if (httpsCN.Length == 0) | ||
193 | httpsCN = scene.RegionInfo.ExternalHostName; | ||
194 | httpsslport = (uint)httpcfg.GetInt("http_listener_sslport",((int)scene.RegionInfo.HttpPort + 1)); | ||
195 | } | ||
196 | } | ||
197 | } | ||
198 | } | ||
199 | |||
200 | public void PostInitialise() | ||
201 | { | ||
202 | } | ||
203 | |||
204 | public void Close() | ||
205 | { | ||
206 | //scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel; | ||
207 | } | ||
208 | |||
209 | public string Name | ||
210 | { | ||
211 | get { return "OpenGridProtocolModule"; } | ||
212 | } | ||
213 | |||
214 | public bool IsSharedModule | ||
215 | { | ||
216 | get { return true; } | ||
217 | } | ||
218 | |||
219 | #endregion | ||
220 | |||
221 | public OSD ProcessRegionDomainSeed(string path, OSD request, string endpoint) | ||
222 | { | ||
223 | string[] pathSegments = path.Split('/'); | ||
224 | |||
225 | if (pathSegments.Length <= 1) | ||
226 | { | ||
227 | return GenerateNoHandlerMessage(); | ||
228 | |||
229 | } | ||
230 | |||
231 | return GenerateRezAvatarRequestMessage(pathSegments[1]); | ||
232 | |||
233 | |||
234 | |||
235 | //m_log.InfoFormat("[OGP]: path {0}, segments {1} segment[1] {2} Last segment {3}", | ||
236 | // path, pathSegments.Length, pathSegments[1], pathSegments[pathSegments.Length - 1]); | ||
237 | //return new OSDMap(); | ||
238 | |||
239 | } | ||
240 | |||
241 | public OSD ProcessAgentDomainMessage(string path, OSD request, string endpoint) | ||
242 | { | ||
243 | // /agent/* | ||
244 | |||
245 | string[] pathSegments = path.Split('/'); | ||
246 | if (pathSegments.Length <= 1) | ||
247 | { | ||
248 | return GenerateNoHandlerMessage(); | ||
249 | |||
250 | } | ||
251 | if (pathSegments[0].Length == 0 && pathSegments[1].Length == 0) | ||
252 | { | ||
253 | return GenerateRezAvatarRequestMessage(""); | ||
254 | } | ||
255 | m_log.InfoFormat("[OGP]: path {0}, segments {1} segment[1] {2} Last segment {3}", | ||
256 | path, pathSegments.Length, pathSegments[1], pathSegments[pathSegments.Length - 1]); | ||
257 | |||
258 | switch (pathSegments[pathSegments.Length - 1]) | ||
259 | { | ||
260 | case "rez_avatar": | ||
261 | return RezAvatarMethod(path, request); | ||
262 | //break; | ||
263 | case "derez_avatar": | ||
264 | return DerezAvatarMethod(path, request); | ||
265 | //break; | ||
266 | |||
267 | } | ||
268 | if (path.Length < 2) | ||
269 | { | ||
270 | return GenerateNoHandlerMessage(); | ||
271 | } | ||
272 | |||
273 | switch (pathSegments[pathSegments.Length - 2] + "/" + pathSegments[pathSegments.Length - 1]) | ||
274 | { | ||
275 | case "rez_avatar/rez": | ||
276 | return RezAvatarMethod(path, request); | ||
277 | //break; | ||
278 | case "rez_avatar/request": | ||
279 | return RequestRezAvatarMethod(path, request); | ||
280 | case "rez_avatar/place": | ||
281 | return RequestRezAvatarMethod(path, request); | ||
282 | case "rez_avatar/derez": | ||
283 | return DerezAvatarMethod(path, request); | ||
284 | //break; | ||
285 | default: | ||
286 | return GenerateNoHandlerMessage(); | ||
287 | } | ||
288 | //return null; | ||
289 | } | ||
290 | |||
291 | private OSD GenerateRezAvatarRequestMessage(string regionname) | ||
292 | { | ||
293 | Scene region = null; | ||
294 | bool usedroot = false; | ||
295 | |||
296 | if (regionname.Length == 0) | ||
297 | { | ||
298 | region = GetRootScene(); | ||
299 | usedroot = true; | ||
300 | } | ||
301 | else | ||
302 | { | ||
303 | region = GetScene(HttpUtility.UrlDecode(regionname).ToLower()); | ||
304 | } | ||
305 | |||
306 | // this shouldn't happen since we don't listen for a region that is down.. but | ||
307 | // it might if the region was taken down or is in the middle of restarting | ||
308 | |||
309 | if (region == null) | ||
310 | { | ||
311 | region = GetRootScene(); | ||
312 | usedroot = true; | ||
313 | } | ||
314 | |||
315 | UUID statekeeper = UUID.Random(); | ||
316 | |||
317 | |||
318 | |||
319 | |||
320 | RegionInfo reg = region.RegionInfo; | ||
321 | |||
322 | OSDMap responseMap = new OSDMap(); | ||
323 | string rezHttpProtocol = "http://"; | ||
324 | //string regionCapsHttpProtocol = "http://"; | ||
325 | string httpaddr = reg.ExternalHostName; | ||
326 | string urlport = reg.HttpPort.ToString(); | ||
327 | string requestpath = "/agent/" + statekeeper + "/rez_avatar/request"; | ||
328 | |||
329 | if (!usedroot) | ||
330 | { | ||
331 | lock (m_loginToRegionState) | ||
332 | { | ||
333 | if (!m_loginToRegionState.ContainsKey(requestpath)) | ||
334 | { | ||
335 | m_loginToRegionState.Add(requestpath, region.RegionInfo.RegionName.ToLower()); | ||
336 | } | ||
337 | } | ||
338 | } | ||
339 | |||
340 | if (httpSSL) | ||
341 | { | ||
342 | rezHttpProtocol = "https://"; | ||
343 | //regionCapsHttpProtocol = "https://"; | ||
344 | urlport = httpsslport.ToString(); | ||
345 | |||
346 | if (httpsCN.Length > 0) | ||
347 | httpaddr = httpsCN; | ||
348 | } | ||
349 | |||
350 | responseMap["connect"] = OSD.FromBoolean(true); | ||
351 | OSDMap capabilitiesMap = new OSDMap(); | ||
352 | capabilitiesMap["rez_avatar/request"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + requestpath); | ||
353 | responseMap["capabilities"] = capabilitiesMap; | ||
354 | |||
355 | return responseMap; | ||
356 | } | ||
357 | |||
358 | // Using OpenSim.Framework.Capabilities.Caps here one time.. | ||
359 | // so the long name is probably better then a using statement | ||
360 | public void OnRegisterCaps(UUID agentID, Caps caps) | ||
361 | { | ||
362 | /* If we ever want to register our own caps here.... | ||
363 | * | ||
364 | string capsBase = "/CAPS/" + caps.CapsObjectPath; | ||
365 | caps.RegisterHandler("CAPNAME", | ||
366 | new RestStreamHandler("POST", capsBase + CAPSPOSTFIX!, | ||
367 | delegate(string request, string path, string param, | ||
368 | OSHttpRequest httpRequest, OSHttpResponse httpResponse) | ||
369 | { | ||
370 | return METHODHANDLER(request, path, param, | ||
371 | agentID, caps); | ||
372 | })); | ||
373 | |||
374 | * | ||
375 | */ | ||
376 | } | ||
377 | |||
378 | public OSD RequestRezAvatarMethod(string path, OSD request) | ||
379 | { | ||
380 | //m_log.Debug("[REQUESTREZAVATAR]: " + request.ToString()); | ||
381 | |||
382 | OSDMap requestMap = (OSDMap)request; | ||
383 | |||
384 | |||
385 | Scene homeScene = null; | ||
386 | |||
387 | lock (m_loginToRegionState) | ||
388 | { | ||
389 | if (m_loginToRegionState.ContainsKey(path)) | ||
390 | { | ||
391 | homeScene = GetScene(m_loginToRegionState[path]); | ||
392 | m_loginToRegionState.Remove(path); | ||
393 | |||
394 | if (homeScene == null) | ||
395 | homeScene = GetRootScene(); | ||
396 | } | ||
397 | else | ||
398 | { | ||
399 | homeScene = GetRootScene(); | ||
400 | } | ||
401 | } | ||
402 | |||
403 | // Homescene is still null, we must have no regions that are up | ||
404 | if (homeScene == null) | ||
405 | return GenerateNoHandlerMessage(); | ||
406 | |||
407 | RegionInfo reg = homeScene.RegionInfo; | ||
408 | ulong regionhandle = GetOSCompatibleRegionHandle(reg); | ||
409 | //string RegionURI = reg.ServerURI; | ||
410 | //int RegionPort = (int)reg.HttpPort; | ||
411 | |||
412 | UUID RemoteAgentID = requestMap["agent_id"].AsUUID(); | ||
413 | |||
414 | // will be used in the future. The client always connects with the aditi agentid currently | ||
415 | UUID LocalAgentID = RemoteAgentID; | ||
416 | |||
417 | string FirstName = requestMap["first_name"].AsString(); | ||
418 | string LastName = requestMap["last_name"].AsString(); | ||
419 | |||
420 | FirstName = FirstNamePrefix + FirstName; | ||
421 | LastName = LastName + LastNameSuffix; | ||
422 | |||
423 | OGPState userState = GetOGPState(LocalAgentID); | ||
424 | |||
425 | userState.first_name = requestMap["first_name"].AsString(); | ||
426 | userState.last_name = requestMap["last_name"].AsString(); | ||
427 | userState.age_verified = requestMap["age_verified"].AsBoolean(); | ||
428 | userState.transacted = requestMap["transacted"].AsBoolean(); | ||
429 | userState.agent_access = requestMap["agent_access"].AsBoolean(); | ||
430 | userState.allow_redirect = requestMap["allow_redirect"].AsBoolean(); | ||
431 | userState.identified = requestMap["identified"].AsBoolean(); | ||
432 | userState.god_level = (uint)requestMap["god_level"].AsInteger(); | ||
433 | userState.sim_access = requestMap["sim_access"].AsString(); | ||
434 | userState.agent_id = RemoteAgentID; | ||
435 | userState.limited_to_estate = requestMap["limited_to_estate"].AsInteger(); | ||
436 | userState.src_can_see_mainland = requestMap["src_can_see_mainland"].AsBoolean(); | ||
437 | userState.src_estate_id = requestMap["src_estate_id"].AsInteger(); | ||
438 | userState.local_agent_id = LocalAgentID; | ||
439 | userState.teleported_into_region = reg.RegionName.ToLower(); | ||
440 | |||
441 | UpdateOGPState(LocalAgentID, userState); | ||
442 | |||
443 | OSDMap responseMap = new OSDMap(); | ||
444 | |||
445 | if (RemoteAgentID == UUID.Zero) | ||
446 | { | ||
447 | responseMap["connect"] = OSD.FromBoolean(false); | ||
448 | responseMap["message"] = OSD.FromString("No agent ID was specified in rez_avatar/request"); | ||
449 | m_log.Error("[OGP]: rez_avatar/request failed because no avatar UUID was provided in the request body"); | ||
450 | return responseMap; | ||
451 | } | ||
452 | |||
453 | responseMap["sim_host"] = OSD.FromString(reg.ExternalHostName); | ||
454 | |||
455 | // DEPRECATED | ||
456 | responseMap["sim_ip"] = OSD.FromString(Util.GetHostFromDNS(reg.ExternalHostName).ToString()); | ||
457 | |||
458 | responseMap["connect"] = OSD.FromBoolean(true); | ||
459 | responseMap["sim_port"] = OSD.FromInteger(reg.InternalEndPoint.Port); | ||
460 | responseMap["region_x"] = OSD.FromInteger(reg.RegionLocX * (uint)Constants.RegionSize); // LLX | ||
461 | responseMap["region_y"] = OSD.FromInteger(reg.RegionLocY * (uint)Constants.RegionSize); // LLY | ||
462 | responseMap["region_id"] = OSD.FromUUID(reg.originRegionID); | ||
463 | |||
464 | if (reg.RegionSettings.Maturity == 1) | ||
465 | { | ||
466 | responseMap["sim_access"] = OSD.FromString("Mature"); | ||
467 | } | ||
468 | else if (reg.RegionSettings.Maturity == 2) | ||
469 | { | ||
470 | responseMap["sim_access"] = OSD.FromString("Adult"); | ||
471 | } | ||
472 | else | ||
473 | { | ||
474 | responseMap["sim_access"] = OSD.FromString("PG"); | ||
475 | } | ||
476 | |||
477 | // Generate a dummy agent for the user so we can get back a CAPS path | ||
478 | AgentCircuitData agentData = new AgentCircuitData(); | ||
479 | agentData.AgentID = LocalAgentID; | ||
480 | agentData.BaseFolder = UUID.Zero; | ||
481 | agentData.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
482 | agentData.child = false; | ||
483 | agentData.circuitcode = (uint)(Util.RandomClass.Next()); | ||
484 | agentData.firstname = FirstName; | ||
485 | agentData.lastname = LastName; | ||
486 | agentData.SecureSessionID = UUID.Random(); | ||
487 | agentData.SessionID = UUID.Random(); | ||
488 | agentData.startpos = new Vector3(128f, 128f, 100f); | ||
489 | |||
490 | // Pre-Fill our region cache with information on the agent. | ||
491 | UserAgentData useragent = new UserAgentData(); | ||
492 | useragent.AgentIP = "unknown"; | ||
493 | useragent.AgentOnline = true; | ||
494 | useragent.AgentPort = (uint)0; | ||
495 | useragent.Handle = regionhandle; | ||
496 | useragent.InitialRegion = reg.originRegionID; | ||
497 | useragent.LoginTime = Util.UnixTimeSinceEpoch(); | ||
498 | useragent.LogoutTime = 0; | ||
499 | useragent.Position = agentData.startpos; | ||
500 | useragent.Region = reg.originRegionID; | ||
501 | useragent.SecureSessionID = agentData.SecureSessionID; | ||
502 | useragent.SessionID = agentData.SessionID; | ||
503 | |||
504 | UserProfileData userProfile = new UserProfileData(); | ||
505 | userProfile.AboutText = "OGP User"; | ||
506 | userProfile.CanDoMask = (uint)0; | ||
507 | userProfile.Created = Util.UnixTimeSinceEpoch(); | ||
508 | userProfile.CurrentAgent = useragent; | ||
509 | userProfile.CustomType = "OGP"; | ||
510 | userProfile.FirstLifeAboutText = "I'm testing OpenGrid Protocol"; | ||
511 | userProfile.FirstLifeImage = UUID.Zero; | ||
512 | userProfile.FirstName = agentData.firstname; | ||
513 | userProfile.GodLevel = 0; | ||
514 | userProfile.HomeLocation = agentData.startpos; | ||
515 | userProfile.HomeLocationX = agentData.startpos.X; | ||
516 | userProfile.HomeLocationY = agentData.startpos.Y; | ||
517 | userProfile.HomeLocationZ = agentData.startpos.Z; | ||
518 | userProfile.HomeLookAt = Vector3.Zero; | ||
519 | userProfile.HomeLookAtX = userProfile.HomeLookAt.X; | ||
520 | userProfile.HomeLookAtY = userProfile.HomeLookAt.Y; | ||
521 | userProfile.HomeLookAtZ = userProfile.HomeLookAt.Z; | ||
522 | userProfile.HomeRegion = reg.RegionHandle; | ||
523 | userProfile.HomeRegionID = reg.originRegionID; | ||
524 | userProfile.HomeRegionX = reg.RegionLocX; | ||
525 | userProfile.HomeRegionY = reg.RegionLocY; | ||
526 | userProfile.ID = agentData.AgentID; | ||
527 | userProfile.Image = UUID.Zero; | ||
528 | userProfile.LastLogin = Util.UnixTimeSinceEpoch(); | ||
529 | userProfile.Partner = UUID.Zero; | ||
530 | userProfile.PasswordHash = "$1$"; | ||
531 | userProfile.PasswordSalt = ""; | ||
532 | userProfile.SurName = agentData.lastname; | ||
533 | //userProfile.UserAssetURI = homeScene.CommsManager.NetworkServersInfo.AssetURL; | ||
534 | userProfile.UserFlags = 0; | ||
535 | //userProfile.UserInventoryURI = homeScene.CommsManager.NetworkServersInfo.InventoryURL; | ||
536 | userProfile.WantDoMask = 0; | ||
537 | userProfile.WebLoginKey = UUID.Random(); | ||
538 | |||
539 | // !!! REFACTORING PROBLEM. This needs to be changed for 0.7 | ||
540 | // | ||
541 | //// Do caps registration | ||
542 | //// get seed capagentData.firstname = FirstName;agentData.lastname = LastName; | ||
543 | //if (homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID) == null && !GridMode) | ||
544 | //{ | ||
545 | // homeScene.CommsManager.UserAdminService.AddUser( | ||
546 | // agentData.firstname, agentData.lastname, CreateRandomStr(7), "", | ||
547 | // homeScene.RegionInfo.RegionLocX, homeScene.RegionInfo.RegionLocY, agentData.AgentID); | ||
548 | |||
549 | // UserProfileData userProfile2 = homeScene.CommsManager.UserService.GetUserProfile(agentData.AgentID); | ||
550 | // if (userProfile2 != null) | ||
551 | // { | ||
552 | // userProfile = userProfile2; | ||
553 | // userProfile.AboutText = "OGP USER"; | ||
554 | // userProfile.FirstLifeAboutText = "OGP USER"; | ||
555 | // homeScene.CommsManager.UserService.UpdateUserProfile(userProfile); | ||
556 | // } | ||
557 | //} | ||
558 | |||
559 | //// Stick our data in the cache so the region will know something about us | ||
560 | //homeScene.CommsManager.UserProfileCacheService.PreloadUserCache(userProfile); | ||
561 | |||
562 | // Call 'new user' event handler | ||
563 | string reason; | ||
564 | if (!homeScene.NewUserConnection(agentData, (uint)TeleportFlags.ViaLogin, out reason)) | ||
565 | { | ||
566 | responseMap["connect"] = OSD.FromBoolean(false); | ||
567 | responseMap["message"] = OSD.FromString(String.Format("Connection refused: {0}", reason)); | ||
568 | m_log.ErrorFormat("[OGP]: rez_avatar/request failed: {0}", reason); | ||
569 | return responseMap; | ||
570 | } | ||
571 | |||
572 | |||
573 | //string raCap = string.Empty; | ||
574 | |||
575 | UUID AvatarRezCapUUID = LocalAgentID; | ||
576 | string rezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/rez"; | ||
577 | string derezAvatarPath = "/agent/" + AvatarRezCapUUID + "/rez_avatar/derez"; | ||
578 | // Get a reference to the user's cap so we can pull out the Caps Object Path | ||
579 | Caps userCap | ||
580 | = homeScene.CapsModule.GetCapsForUser(agentData.AgentID); | ||
581 | |||
582 | string rezHttpProtocol = "http://"; | ||
583 | string regionCapsHttpProtocol = "http://"; | ||
584 | string httpaddr = reg.ExternalHostName; | ||
585 | string urlport = reg.HttpPort.ToString(); | ||
586 | |||
587 | if (httpSSL) | ||
588 | { | ||
589 | rezHttpProtocol = "https://"; | ||
590 | regionCapsHttpProtocol = "https://"; | ||
591 | urlport = httpsslport.ToString(); | ||
592 | |||
593 | if (httpsCN.Length > 0) | ||
594 | httpaddr = httpsCN; | ||
595 | } | ||
596 | |||
597 | // DEPRECATED | ||
598 | responseMap["seed_capability"] | ||
599 | = OSD.FromString( | ||
600 | regionCapsHttpProtocol + httpaddr + ":" + reg.HttpPort + "/" + CapsUtil.GetCapsSeedPath(userCap.CapsObjectPath)); | ||
601 | |||
602 | // REPLACEMENT | ||
603 | responseMap["region_seed_capability"] | ||
604 | = OSD.FromString( | ||
605 | regionCapsHttpProtocol + httpaddr + ":" + reg.HttpPort + "/" + CapsUtil.GetCapsSeedPath(userCap.CapsObjectPath)); | ||
606 | |||
607 | responseMap["rez_avatar"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + rezAvatarPath); | ||
608 | responseMap["rez_avatar/rez"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + rezAvatarPath); | ||
609 | responseMap["rez_avatar/derez"] = OSD.FromString(rezHttpProtocol + httpaddr + ":" + urlport + derezAvatarPath); | ||
610 | |||
611 | // Add the user to the list of CAPS that are outstanding. | ||
612 | // well allow the caps hosts in this dictionary | ||
613 | lock (CapsLoginID) | ||
614 | { | ||
615 | if (CapsLoginID.ContainsKey(rezAvatarPath)) | ||
616 | { | ||
617 | CapsLoginID[rezAvatarPath] = agentData; | ||
618 | |||
619 | // This is a joke, if you didn't notice... It's so unlikely to happen, that I'll print this message if it does occur! | ||
620 | m_log.Error("[OGP]: Holy anomoly batman! Caps path already existed! All the UUID Duplication worries were founded!"); | ||
621 | } | ||
622 | else | ||
623 | { | ||
624 | CapsLoginID.Add(rezAvatarPath, agentData); | ||
625 | } | ||
626 | } | ||
627 | |||
628 | //m_log.Debug("Response:" + responseMap.ToString()); | ||
629 | return responseMap; | ||
630 | } | ||
631 | |||
632 | public OSD RezAvatarMethod(string path, OSD request) | ||
633 | { | ||
634 | m_log.WarnFormat("[REZAVATAR]: {0}", request.ToString()); | ||
635 | |||
636 | OSDMap responseMap = new OSDMap(); | ||
637 | |||
638 | AgentCircuitData userData = null; | ||
639 | |||
640 | // Only people we've issued a cap can go further | ||
641 | if (TryGetAgentCircuitData(path,out userData)) | ||
642 | { | ||
643 | OSDMap requestMap = (OSDMap)request; | ||
644 | |||
645 | // take these values to start. There's a few more | ||
646 | UUID SecureSessionID=requestMap["secure_session_id"].AsUUID(); | ||
647 | UUID SessionID = requestMap["session_id"].AsUUID(); | ||
648 | int circuitcode = requestMap["circuit_code"].AsInteger(); | ||
649 | OSDArray Parameter = new OSDArray(); | ||
650 | if (requestMap.ContainsKey("parameter")) | ||
651 | { | ||
652 | Parameter = (OSDArray)requestMap["parameter"]; | ||
653 | } | ||
654 | |||
655 | //int version = 1; | ||
656 | int estateID = 1; | ||
657 | int parentEstateID = 1; | ||
658 | UUID regionID = UUID.Zero; | ||
659 | bool visibleToParent = true; | ||
660 | |||
661 | for (int i = 0; i < Parameter.Count; i++) | ||
662 | { | ||
663 | OSDMap item = (OSDMap)Parameter[i]; | ||
664 | // if (item.ContainsKey("version")) | ||
665 | // { | ||
666 | // version = item["version"].AsInteger(); | ||
667 | // } | ||
668 | if (item.ContainsKey("estate_id")) | ||
669 | { | ||
670 | estateID = item["estate_id"].AsInteger(); | ||
671 | } | ||
672 | if (item.ContainsKey("parent_estate_id")) | ||
673 | { | ||
674 | parentEstateID = item["parent_estate_id"].AsInteger(); | ||
675 | |||
676 | } | ||
677 | if (item.ContainsKey("region_id")) | ||
678 | { | ||
679 | regionID = item["region_id"].AsUUID(); | ||
680 | |||
681 | } | ||
682 | if (item.ContainsKey("visible_to_parent")) | ||
683 | { | ||
684 | visibleToParent = item["visible_to_parent"].AsBoolean(); | ||
685 | } | ||
686 | } | ||
687 | //Update our Circuit data with the real values | ||
688 | userData.SecureSessionID = SecureSessionID; | ||
689 | userData.SessionID = SessionID; | ||
690 | |||
691 | OGPState userState = GetOGPState(userData.AgentID); | ||
692 | |||
693 | // Locate a home scene suitable for the user. | ||
694 | Scene homeScene = null; | ||
695 | |||
696 | homeScene = GetScene(userState.teleported_into_region); | ||
697 | |||
698 | if (homeScene == null) | ||
699 | homeScene = GetRootScene(); | ||
700 | |||
701 | if (homeScene != null) | ||
702 | { | ||
703 | // Get a referenceokay - to their Cap object so we can pull out the capobjectroot | ||
704 | Caps userCap | ||
705 | = homeScene.CapsModule.GetCapsForUser(userData.AgentID); | ||
706 | |||
707 | //Update the circuit data in the region so this user is authorized | ||
708 | homeScene.UpdateCircuitData(userData); | ||
709 | homeScene.ChangeCircuitCode(userData.circuitcode,(uint)circuitcode); | ||
710 | |||
711 | // Load state | ||
712 | |||
713 | |||
714 | // Keep state changes | ||
715 | userState.first_name = requestMap["first_name"].AsString(); | ||
716 | userState.secure_session_id = requestMap["secure_session_id"].AsUUID(); | ||
717 | userState.age_verified = requestMap["age_verified"].AsBoolean(); | ||
718 | userState.region_id = homeScene.RegionInfo.originRegionID; // replace 0000000 with our regionid | ||
719 | userState.transacted = requestMap["transacted"].AsBoolean(); | ||
720 | userState.agent_access = requestMap["agent_access"].AsBoolean(); | ||
721 | userState.inventory_host = requestMap["inventory_host"].AsString(); | ||
722 | userState.identified = requestMap["identified"].AsBoolean(); | ||
723 | userState.session_id = requestMap["session_id"].AsUUID(); | ||
724 | userState.god_level = (uint)requestMap["god_level"].AsInteger(); | ||
725 | userState.last_name = requestMap["last_name"].AsString(); | ||
726 | userState.god_overide = requestMap["god_override"].AsBoolean(); | ||
727 | userState.circuit_code = (uint)requestMap["circuit_code"].AsInteger(); | ||
728 | userState.limited_to_estate = requestMap["limited_to_estate"].AsInteger(); | ||
729 | userState.src_estate_id = estateID; | ||
730 | userState.region_id = regionID; | ||
731 | userState.src_parent_estate_id = parentEstateID; | ||
732 | userState.visible_to_parent = visibleToParent; | ||
733 | |||
734 | // Save state changes | ||
735 | UpdateOGPState(userData.AgentID, userState); | ||
736 | |||
737 | // Get the region information for the home region. | ||
738 | RegionInfo reg = homeScene.RegionInfo; | ||
739 | |||
740 | // Dummy positional and look at info.. we don't have it. | ||
741 | OSDArray PositionArray = new OSDArray(); | ||
742 | PositionArray.Add(OSD.FromInteger(128)); | ||
743 | PositionArray.Add(OSD.FromInteger(128)); | ||
744 | PositionArray.Add(OSD.FromInteger(40)); | ||
745 | |||
746 | OSDArray LookAtArray = new OSDArray(); | ||
747 | LookAtArray.Add(OSD.FromInteger(1)); | ||
748 | LookAtArray.Add(OSD.FromInteger(1)); | ||
749 | LookAtArray.Add(OSD.FromInteger(1)); | ||
750 | |||
751 | // Our region's X and Y position in OpenSimulator space. | ||
752 | uint fooX = reg.RegionLocX; | ||
753 | uint fooY = reg.RegionLocY; | ||
754 | m_log.InfoFormat("[OGP]: region x({0}) region y({1})", fooX, fooY); | ||
755 | m_log.InfoFormat("[OGP]: region http {0} {1}", reg.ServerURI, reg.HttpPort); | ||
756 | m_log.InfoFormat("[OGO]: region UUID {0} ", reg.RegionID); | ||
757 | |||
758 | // Convert the X and Y position to LL space | ||
759 | responseMap["region_x"] = OSD.FromInteger(fooX * (uint)Constants.RegionSize); // convert it to LL X | ||
760 | responseMap["region_y"] = OSD.FromInteger(fooY * (uint)Constants.RegionSize); // convert it to LL Y | ||
761 | |||
762 | // Give em a new seed capability | ||
763 | responseMap["seed_capability"] = OSD.FromString("http://" + reg.ExternalHostName + ":" + reg.HttpPort + "/CAPS/" + userCap.CapsObjectPath + "0000/"); | ||
764 | responseMap["region"] = OSD.FromUUID(reg.originRegionID); | ||
765 | responseMap["look_at"] = LookAtArray; | ||
766 | |||
767 | responseMap["sim_port"] = OSD.FromInteger(reg.InternalEndPoint.Port); | ||
768 | responseMap["sim_host"] = OSD.FromString(reg.ExternalHostName);// + ":" + reg.InternalEndPoint.Port.ToString()); | ||
769 | |||
770 | // DEPRECATED | ||
771 | responseMap["sim_ip"] = OSD.FromString(Util.GetHostFromDNS(reg.ExternalHostName).ToString()); | ||
772 | |||
773 | responseMap["session_id"] = OSD.FromUUID(SessionID); | ||
774 | responseMap["secure_session_id"] = OSD.FromUUID(SecureSessionID); | ||
775 | responseMap["circuit_code"] = OSD.FromInteger(circuitcode); | ||
776 | |||
777 | responseMap["position"] = PositionArray; | ||
778 | |||
779 | responseMap["region_id"] = OSD.FromUUID(reg.originRegionID); | ||
780 | |||
781 | responseMap["sim_access"] = OSD.FromString("Mature"); | ||
782 | |||
783 | responseMap["connect"] = OSD.FromBoolean(true); | ||
784 | |||
785 | |||
786 | |||
787 | m_log.InfoFormat("[OGP]: host: {0}, IP {1}", responseMap["sim_host"].ToString(), responseMap["sim_ip"].ToString()); | ||
788 | } | ||
789 | } | ||
790 | |||
791 | return responseMap; | ||
792 | } | ||
793 | |||
794 | public OSD DerezAvatarMethod(string path, OSD request) | ||
795 | { | ||
796 | m_log.ErrorFormat("DerezPath: {0}, Request: {1}", path, request.ToString()); | ||
797 | |||
798 | //LLSD llsdResponse = null; | ||
799 | OSDMap responseMap = new OSDMap(); | ||
800 | |||
801 | string[] PathArray = path.Split('/'); | ||
802 | m_log.InfoFormat("[OGP]: prefix {0}, uuid {1}, suffix {2}", PathArray[1], PathArray[2], PathArray[3]); | ||
803 | string uuidString = PathArray[2]; | ||
804 | m_log.InfoFormat("[OGP]: Request to Derez avatar with UUID {0}", uuidString); | ||
805 | UUID userUUID = UUID.Zero; | ||
806 | if (UUID.TryParse(uuidString, out userUUID)) | ||
807 | { | ||
808 | UUID RemoteID = (UUID)uuidString; | ||
809 | UUID LocalID = RemoteID; | ||
810 | // FIXME: TODO: Routine to map RemoteUUIDs to LocalUUIds | ||
811 | // would be done already.. but the client connects with the Aditi UUID | ||
812 | // regardless over the UDP stack | ||
813 | |||
814 | OGPState userState = GetOGPState(LocalID); | ||
815 | if (userState.agent_id != UUID.Zero) | ||
816 | { | ||
817 | //OSDMap outboundRequestMap = new OSDMap(); | ||
818 | OSDMap inboundRequestMap = (OSDMap)request; | ||
819 | string rezAvatarString = inboundRequestMap["rez_avatar"].AsString(); | ||
820 | if (rezAvatarString.Length == 0) | ||
821 | { | ||
822 | rezAvatarString = inboundRequestMap["rez_avatar/rez"].AsString(); | ||
823 | } | ||
824 | OSDArray LookAtArray = new OSDArray(); | ||
825 | LookAtArray.Add(OSD.FromInteger(1)); | ||
826 | LookAtArray.Add(OSD.FromInteger(1)); | ||
827 | LookAtArray.Add(OSD.FromInteger(1)); | ||
828 | |||
829 | OSDArray PositionArray = new OSDArray(); | ||
830 | PositionArray.Add(OSD.FromInteger(128)); | ||
831 | PositionArray.Add(OSD.FromInteger(128)); | ||
832 | PositionArray.Add(OSD.FromInteger(40)); | ||
833 | |||
834 | OSDArray lookArray = new OSDArray(); | ||
835 | lookArray.Add(OSD.FromInteger(128)); | ||
836 | lookArray.Add(OSD.FromInteger(128)); | ||
837 | lookArray.Add(OSD.FromInteger(40)); | ||
838 | |||
839 | responseMap["connect"] = OSD.FromBoolean(true);// it's okay to give this user up | ||
840 | responseMap["look_at"] = LookAtArray; | ||
841 | |||
842 | m_log.WarnFormat("[OGP]: Invoking rez_avatar on host:{0} for avatar: {1} {2}", rezAvatarString, userState.first_name, userState.last_name); | ||
843 | |||
844 | OSDMap rezResponseMap = invokeRezAvatarCap(responseMap, rezAvatarString,userState); | ||
845 | |||
846 | // If invoking it returned an error, parse and end | ||
847 | if (rezResponseMap.ContainsKey("connect")) | ||
848 | { | ||
849 | if (rezResponseMap["connect"].AsBoolean() == false) | ||
850 | { | ||
851 | return responseMap; | ||
852 | } | ||
853 | } | ||
854 | |||
855 | string rezRespSeedCap = ""; | ||
856 | |||
857 | // DEPRECATED | ||
858 | if (rezResponseMap.ContainsKey("seed_capability")) | ||
859 | rezRespSeedCap = rezResponseMap["seed_capability"].AsString(); | ||
860 | |||
861 | // REPLACEMENT | ||
862 | if (rezResponseMap.ContainsKey("region_seed_capability")) | ||
863 | rezRespSeedCap = rezResponseMap["region_seed_capability"].AsString(); | ||
864 | |||
865 | // REPLACEMENT | ||
866 | if (rezResponseMap.ContainsKey("rez_avatar/rez")) | ||
867 | rezRespSeedCap = rezResponseMap["rez_avatar/rez"].AsString(); | ||
868 | |||
869 | // DEPRECATED | ||
870 | string rezRespSim_ip = rezResponseMap["sim_ip"].AsString(); | ||
871 | |||
872 | string rezRespSim_host = rezResponseMap["sim_host"].AsString(); | ||
873 | |||
874 | int rrPort = rezResponseMap["sim_port"].AsInteger(); | ||
875 | int rrX = rezResponseMap["region_x"].AsInteger(); | ||
876 | int rrY = rezResponseMap["region_y"].AsInteger(); | ||
877 | m_log.ErrorFormat("X:{0}, Y:{1}", rrX, rrY); | ||
878 | UUID rrRID = rezResponseMap["region_id"].AsUUID(); | ||
879 | OSDArray RezResponsePositionArray = null; | ||
880 | string rrAccess = rezResponseMap["sim_access"].AsString(); | ||
881 | if (rezResponseMap.ContainsKey("position")) | ||
882 | { | ||
883 | RezResponsePositionArray = (OSDArray)rezResponseMap["position"]; | ||
884 | } | ||
885 | // DEPRECATED | ||
886 | responseMap["seed_capability"] = OSD.FromString(rezRespSeedCap); | ||
887 | |||
888 | // REPLACEMENT r3 | ||
889 | responseMap["region_seed_capability"] = OSD.FromString(rezRespSeedCap); | ||
890 | |||
891 | // DEPRECATED | ||
892 | responseMap["sim_ip"] = OSD.FromString(Util.GetHostFromDNS(rezRespSim_ip).ToString()); | ||
893 | |||
894 | responseMap["sim_host"] = OSD.FromString(rezRespSim_host); | ||
895 | responseMap["sim_port"] = OSD.FromInteger(rrPort); | ||
896 | responseMap["region_x"] = OSD.FromInteger(rrX); | ||
897 | responseMap["region_y"] = OSD.FromInteger(rrY); | ||
898 | responseMap["region_id"] = OSD.FromUUID(rrRID); | ||
899 | responseMap["sim_access"] = OSD.FromString(rrAccess); | ||
900 | |||
901 | if (RezResponsePositionArray != null) | ||
902 | { | ||
903 | responseMap["position"] = RezResponsePositionArray; | ||
904 | } | ||
905 | responseMap["look_at"] = lookArray; | ||
906 | responseMap["connect"] = OSD.FromBoolean(true); | ||
907 | |||
908 | ShutdownConnection(LocalID,this); | ||
909 | // PLEASE STOP CHANGING THIS TO an M_LOG, M_LOG DOESN'T WORK ON MULTILINE .TOSTRINGS | ||
910 | Console.WriteLine("RESPONSEDEREZ: " + responseMap.ToString()); | ||
911 | return responseMap; | ||
912 | } | ||
913 | else | ||
914 | { | ||
915 | return GenerateNoStateMessage(LocalID); | ||
916 | } | ||
917 | } | ||
918 | else | ||
919 | { | ||
920 | return GenerateNoHandlerMessage(); | ||
921 | } | ||
922 | |||
923 | //return responseMap; | ||
924 | } | ||
925 | |||
926 | private OSDMap invokeRezAvatarCap(OSDMap responseMap, string CapAddress, OGPState userState) | ||
927 | { | ||
928 | Scene reg = GetRootScene(); | ||
929 | |||
930 | WebRequest DeRezRequest = WebRequest.Create(CapAddress); | ||
931 | DeRezRequest.Method = "POST"; | ||
932 | DeRezRequest.ContentType = "application/xml+llsd"; | ||
933 | |||
934 | OSDMap RAMap = new OSDMap(); | ||
935 | OSDMap AgentParms = new OSDMap(); | ||
936 | OSDMap RegionParms = new OSDMap(); | ||
937 | |||
938 | OSDArray Parameter = new OSDArray(2); | ||
939 | |||
940 | OSDMap version = new OSDMap(); | ||
941 | version["version"] = OSD.FromInteger(userState.src_version); | ||
942 | Parameter.Add(version); | ||
943 | |||
944 | OSDMap SrcData = new OSDMap(); | ||
945 | SrcData["estate_id"] = OSD.FromInteger(reg.RegionInfo.EstateSettings.EstateID); | ||
946 | SrcData["parent_estate_id"] = OSD.FromInteger((reg.RegionInfo.EstateSettings.ParentEstateID == 100 ? 1 : reg.RegionInfo.EstateSettings.ParentEstateID)); | ||
947 | SrcData["region_id"] = OSD.FromUUID(reg.RegionInfo.originRegionID); | ||
948 | SrcData["visible_to_parent"] = OSD.FromBoolean(userState.visible_to_parent); | ||
949 | Parameter.Add(SrcData); | ||
950 | |||
951 | AgentParms["first_name"] = OSD.FromString(userState.first_name); | ||
952 | AgentParms["last_name"] = OSD.FromString(userState.last_name); | ||
953 | AgentParms["agent_id"] = OSD.FromUUID(userState.agent_id); | ||
954 | RegionParms["region_id"] = OSD.FromUUID(userState.region_id); | ||
955 | AgentParms["circuit_code"] = OSD.FromInteger(userState.circuit_code); | ||
956 | AgentParms["secure_session_id"] = OSD.FromUUID(userState.secure_session_id); | ||
957 | AgentParms["session_id"] = OSD.FromUUID(userState.session_id); | ||
958 | AgentParms["agent_access"] = OSD.FromBoolean(userState.agent_access); | ||
959 | AgentParms["god_level"] = OSD.FromInteger(userState.god_level); | ||
960 | AgentParms["god_overide"] = OSD.FromBoolean(userState.god_overide); | ||
961 | AgentParms["identified"] = OSD.FromBoolean(userState.identified); | ||
962 | AgentParms["transacted"] = OSD.FromBoolean(userState.transacted); | ||
963 | AgentParms["age_verified"] = OSD.FromBoolean(userState.age_verified); | ||
964 | AgentParms["limited_to_estate"] = OSD.FromInteger(userState.limited_to_estate); | ||
965 | AgentParms["inventory_host"] = OSD.FromString(userState.inventory_host); | ||
966 | |||
967 | // version 1 | ||
968 | RAMap = AgentParms; | ||
969 | |||
970 | // Planned for version 2 | ||
971 | // RAMap["agent_params"] = AgentParms; | ||
972 | |||
973 | RAMap["region_params"] = RegionParms; | ||
974 | RAMap["parameter"] = Parameter; | ||
975 | |||
976 | string RAMapString = RAMap.ToString(); | ||
977 | m_log.InfoFormat("[OGP] RAMap string {0}", RAMapString); | ||
978 | OSD LLSDofRAMap = RAMap; // RENAME if this works | ||
979 | |||
980 | m_log.InfoFormat("[OGP]: LLSD of map as string was {0}", LLSDofRAMap.ToString()); | ||
981 | //m_log.InfoFormat("[OGP]: LLSD+XML: {0}", LLSDParser.SerializeXmlString(LLSDofRAMap)); | ||
982 | byte[] buffer = OSDParser.SerializeLLSDXmlBytes(LLSDofRAMap); | ||
983 | |||
984 | //string bufferDump = System.Text.Encoding.ASCII.GetString(buffer); | ||
985 | //m_log.InfoFormat("[OGP]: buffer form is {0}",bufferDump); | ||
986 | //m_log.InfoFormat("[OGP]: LLSD of map was {0}",buffer.Length); | ||
987 | |||
988 | Stream os = null; | ||
989 | try | ||
990 | { // send the Post | ||
991 | DeRezRequest.ContentLength = buffer.Length; //Count bytes to send | ||
992 | os = DeRezRequest.GetRequestStream(); | ||
993 | os.Write(buffer, 0, buffer.Length); //Send it | ||
994 | os.Close(); | ||
995 | m_log.InfoFormat("[OGP]: Derez Avatar Posted Rez Avatar request to remote sim {0}", CapAddress); | ||
996 | } | ||
997 | catch (WebException ex) | ||
998 | { | ||
999 | m_log.InfoFormat("[OGP] Bad send on de_rez_avatar {0}", ex.Message); | ||
1000 | responseMap["connect"] = OSD.FromBoolean(false); | ||
1001 | |||
1002 | return responseMap; | ||
1003 | } | ||
1004 | |||
1005 | m_log.Info("[OGP] waiting for a reply after rez avatar send"); | ||
1006 | string rez_avatar_reply = null; | ||
1007 | { // get the response | ||
1008 | try | ||
1009 | { | ||
1010 | WebResponse webResponse = DeRezRequest.GetResponse(); | ||
1011 | if (webResponse == null) | ||
1012 | { | ||
1013 | m_log.Info("[OGP:] Null reply on rez_avatar post"); | ||
1014 | } | ||
1015 | |||
1016 | StreamReader sr = new StreamReader(webResponse.GetResponseStream()); | ||
1017 | rez_avatar_reply = sr.ReadToEnd().Trim(); | ||
1018 | m_log.InfoFormat("[OGP]: rez_avatar reply was {0} ", rez_avatar_reply); | ||
1019 | |||
1020 | } | ||
1021 | catch (WebException ex) | ||
1022 | { | ||
1023 | m_log.InfoFormat("[OGP]: exception on read after send of rez avatar {0}", ex.Message); | ||
1024 | responseMap["connect"] = OSD.FromBoolean(false); | ||
1025 | |||
1026 | return responseMap; | ||
1027 | } | ||
1028 | OSD rezResponse = null; | ||
1029 | try | ||
1030 | { | ||
1031 | rezResponse = OSDParser.DeserializeLLSDXml(rez_avatar_reply); | ||
1032 | |||
1033 | responseMap = (OSDMap)rezResponse; | ||
1034 | } | ||
1035 | catch (Exception ex) | ||
1036 | { | ||
1037 | m_log.InfoFormat("[OGP]: exception on parse of rez reply {0}", ex.Message); | ||
1038 | responseMap["connect"] = OSD.FromBoolean(false); | ||
1039 | |||
1040 | return responseMap; | ||
1041 | } | ||
1042 | } | ||
1043 | return responseMap; | ||
1044 | } | ||
1045 | |||
1046 | public OSD GenerateNoHandlerMessage() | ||
1047 | { | ||
1048 | OSDMap map = new OSDMap(); | ||
1049 | map["reason"] = OSD.FromString("LLSDRequest"); | ||
1050 | map["message"] = OSD.FromString("No handler registered for LLSD Requests"); | ||
1051 | map["login"] = OSD.FromString("false"); | ||
1052 | map["connect"] = OSD.FromString("false"); | ||
1053 | return map; | ||
1054 | } | ||
1055 | public OSD GenerateNoStateMessage(UUID passedAvatar) | ||
1056 | { | ||
1057 | OSDMap map = new OSDMap(); | ||
1058 | map["reason"] = OSD.FromString("derez failed"); | ||
1059 | map["message"] = OSD.FromString("Unable to locate OGP state for avatar " + passedAvatar.ToString()); | ||
1060 | map["login"] = OSD.FromString("false"); | ||
1061 | map["connect"] = OSD.FromString("false"); | ||
1062 | return map; | ||
1063 | } | ||
1064 | private bool TryGetAgentCircuitData(string path, out AgentCircuitData userdata) | ||
1065 | { | ||
1066 | userdata = null; | ||
1067 | lock (CapsLoginID) | ||
1068 | { | ||
1069 | if (CapsLoginID.ContainsKey(path)) | ||
1070 | { | ||
1071 | userdata = CapsLoginID[path]; | ||
1072 | DiscardUsedCap(path); | ||
1073 | return true; | ||
1074 | } | ||
1075 | } | ||
1076 | return false; | ||
1077 | } | ||
1078 | |||
1079 | private void DiscardUsedCap(string path) | ||
1080 | { | ||
1081 | CapsLoginID.Remove(path); | ||
1082 | } | ||
1083 | |||
1084 | private Scene GetRootScene() | ||
1085 | { | ||
1086 | Scene ReturnScene = null; | ||
1087 | lock (m_scene) | ||
1088 | { | ||
1089 | if (m_scene.Count > 0) | ||
1090 | { | ||
1091 | ReturnScene = m_scene[0]; | ||
1092 | } | ||
1093 | } | ||
1094 | |||
1095 | return ReturnScene; | ||
1096 | } | ||
1097 | |||
1098 | private Scene GetScene(string scenename) | ||
1099 | { | ||
1100 | Scene ReturnScene = null; | ||
1101 | lock (m_scene) | ||
1102 | { | ||
1103 | foreach (Scene s in m_scene) | ||
1104 | { | ||
1105 | if (s.RegionInfo.RegionName.ToLower() == scenename) | ||
1106 | { | ||
1107 | ReturnScene = s; | ||
1108 | break; | ||
1109 | } | ||
1110 | } | ||
1111 | } | ||
1112 | |||
1113 | return ReturnScene; | ||
1114 | } | ||
1115 | |||
1116 | private ulong GetOSCompatibleRegionHandle(RegionInfo reg) | ||
1117 | { | ||
1118 | return Util.UIntsToLong(reg.RegionLocX, reg.RegionLocY); | ||
1119 | } | ||
1120 | |||
1121 | private OGPState InitializeNewState() | ||
1122 | { | ||
1123 | OGPState returnState = new OGPState(); | ||
1124 | returnState.first_name = ""; | ||
1125 | returnState.last_name = ""; | ||
1126 | returnState.agent_id = UUID.Zero; | ||
1127 | returnState.local_agent_id = UUID.Zero; | ||
1128 | returnState.region_id = UUID.Zero; | ||
1129 | returnState.circuit_code = 0; | ||
1130 | returnState.secure_session_id = UUID.Zero; | ||
1131 | returnState.session_id = UUID.Zero; | ||
1132 | returnState.agent_access = true; | ||
1133 | returnState.god_level = 0; | ||
1134 | returnState.god_overide = false; | ||
1135 | returnState.identified = false; | ||
1136 | returnState.transacted = false; | ||
1137 | returnState.age_verified = false; | ||
1138 | returnState.limited_to_estate = 1; | ||
1139 | returnState.inventory_host = "http://inv4.mysql.aditi.lindenlab.com"; | ||
1140 | returnState.allow_redirect = true; | ||
1141 | returnState.sim_access = ""; | ||
1142 | returnState.src_can_see_mainland = true; | ||
1143 | returnState.src_estate_id = 1; | ||
1144 | returnState.src_version = 1; | ||
1145 | returnState.src_parent_estate_id = 1; | ||
1146 | returnState.visible_to_parent = true; | ||
1147 | returnState.teleported_into_region = ""; | ||
1148 | |||
1149 | return returnState; | ||
1150 | } | ||
1151 | |||
1152 | private OGPState GetOGPState(UUID agentId) | ||
1153 | { | ||
1154 | lock (m_OGPState) | ||
1155 | { | ||
1156 | if (m_OGPState.ContainsKey(agentId)) | ||
1157 | { | ||
1158 | return m_OGPState[agentId]; | ||
1159 | } | ||
1160 | else | ||
1161 | { | ||
1162 | return InitializeNewState(); | ||
1163 | } | ||
1164 | } | ||
1165 | } | ||
1166 | |||
1167 | public void DeleteOGPState(UUID agentId) | ||
1168 | { | ||
1169 | lock (m_OGPState) | ||
1170 | { | ||
1171 | if (m_OGPState.ContainsKey(agentId)) | ||
1172 | m_OGPState.Remove(agentId); | ||
1173 | } | ||
1174 | } | ||
1175 | |||
1176 | private void UpdateOGPState(UUID agentId, OGPState state) | ||
1177 | { | ||
1178 | lock (m_OGPState) | ||
1179 | { | ||
1180 | if (m_OGPState.ContainsKey(agentId)) | ||
1181 | { | ||
1182 | m_OGPState[agentId] = state; | ||
1183 | } | ||
1184 | else | ||
1185 | { | ||
1186 | m_OGPState.Add(agentId,state); | ||
1187 | } | ||
1188 | } | ||
1189 | } | ||
1190 | private bool SceneListDuplicateCheck(string str) | ||
1191 | { | ||
1192 | // no lock, called from locked space! | ||
1193 | bool found = false; | ||
1194 | |||
1195 | foreach (Scene s in m_scene) | ||
1196 | { | ||
1197 | if (s.RegionInfo.RegionName == str) | ||
1198 | { | ||
1199 | found = true; | ||
1200 | break; | ||
1201 | } | ||
1202 | } | ||
1203 | |||
1204 | return found; | ||
1205 | } | ||
1206 | |||
1207 | public void ShutdownConnection(UUID avatarId, OpenGridProtocolModule mod) | ||
1208 | { | ||
1209 | Scene homeScene = GetRootScene(); | ||
1210 | ScenePresence avatar = null; | ||
1211 | if (homeScene.TryGetScenePresence(avatarId,out avatar)) | ||
1212 | { | ||
1213 | KillAUser ku = new KillAUser(avatar,mod); | ||
1214 | Watchdog.StartThread(ku.ShutdownNoLogout, "OGPShutdown", ThreadPriority.Normal, true, true); | ||
1215 | } | ||
1216 | } | ||
1217 | |||
1218 | // private string CreateRandomStr(int len) | ||
1219 | // { | ||
1220 | // Random rnd = new Random(Environment.TickCount); | ||
1221 | // string returnstring = ""; | ||
1222 | // string chars = "abcdefghijklmnopqrstuvwxyz0123456789"; | ||
1223 | // | ||
1224 | // for (int i = 0; i < len; i++) | ||
1225 | // { | ||
1226 | // returnstring += chars.Substring(rnd.Next(chars.Length), 1); | ||
1227 | // } | ||
1228 | // return returnstring; | ||
1229 | // } | ||
1230 | |||
1231 | // Temporary hack to allow teleporting to and from Vaak | ||
1232 | private static bool customXertificateValidation(object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error) | ||
1233 | { | ||
1234 | //if (cert.Subject == "E=root@lindenlab.com, CN=*.vaak.lindenlab.com, O=\"Linden Lab, Inc.\", L=San Francisco, S=California, C=US") | ||
1235 | //{ | ||
1236 | return true; | ||
1237 | //} | ||
1238 | |||
1239 | //return false; | ||
1240 | } | ||
1241 | } | ||
1242 | |||
1243 | public class KillAUser | ||
1244 | { | ||
1245 | private ScenePresence avToBeKilled = null; | ||
1246 | private OpenGridProtocolModule m_mod = null; | ||
1247 | |||
1248 | public KillAUser(ScenePresence avatar, OpenGridProtocolModule mod) | ||
1249 | { | ||
1250 | avToBeKilled = avatar; | ||
1251 | m_mod = mod; | ||
1252 | } | ||
1253 | |||
1254 | public void ShutdownNoLogout() | ||
1255 | { | ||
1256 | UUID avUUID = UUID.Zero; | ||
1257 | |||
1258 | if (avToBeKilled != null) | ||
1259 | { | ||
1260 | avUUID = avToBeKilled.UUID; | ||
1261 | avToBeKilled.MakeChildAgent(); | ||
1262 | |||
1263 | avToBeKilled.ControllingClient.SendLogoutPacketWhenClosing = false; | ||
1264 | |||
1265 | int sleepMS = 30000; | ||
1266 | while (sleepMS > 0) | ||
1267 | { | ||
1268 | Watchdog.UpdateThread(); | ||
1269 | Thread.Sleep(1000); | ||
1270 | sleepMS -= 1000; | ||
1271 | } | ||
1272 | |||
1273 | // test for child agent because they might have come back | ||
1274 | if (avToBeKilled.IsChildAgent) | ||
1275 | { | ||
1276 | m_mod.DeleteOGPState(avUUID); | ||
1277 | avToBeKilled.ControllingClient.Close(); | ||
1278 | } | ||
1279 | } | ||
1280 | |||
1281 | Watchdog.RemoveThread(); | ||
1282 | } | ||
1283 | |||
1284 | } | ||
1285 | |||
1286 | public class MonoCert : ICertificatePolicy | ||
1287 | { | ||
1288 | #region ICertificatePolicy Members | ||
1289 | |||
1290 | public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem) | ||
1291 | { | ||
1292 | return true; | ||
1293 | } | ||
1294 | |||
1295 | #endregion | ||
1296 | } | ||
1297 | } | ||
diff --git a/OpenSim/Region/CoreModules/Properties/AssemblyInfo.cs b/OpenSim/Region/CoreModules/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5a8c4a2 --- /dev/null +++ b/OpenSim/Region/CoreModules/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,38 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | using Mono.Addins; | ||
5 | |||
6 | // General Information about an assembly is controlled through the following | ||
7 | // set of attributes. Change these attribute values to modify the information | ||
8 | // associated with an assembly. | ||
9 | [assembly: AssemblyTitle("OpenSim.Region.CoreModules")] | ||
10 | [assembly: AssemblyDescription("Core modules for OpenSim")] | ||
11 | [assembly: AssemblyConfiguration("")] | ||
12 | [assembly: AssemblyCompany("")] | ||
13 | [assembly: AssemblyProduct("OpenSim.Region.CoreModules.Properties")] | ||
14 | [assembly: AssemblyCopyright("Copyright © 2012")] | ||
15 | [assembly: AssemblyTrademark("")] | ||
16 | [assembly: AssemblyCulture("")] | ||
17 | |||
18 | // Setting ComVisible to false makes the types in this assembly not visible | ||
19 | // to COM components. If you need to access a type in this assembly from | ||
20 | // COM, set the ComVisible attribute to true on that type. | ||
21 | [assembly: ComVisible(false)] | ||
22 | |||
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
24 | [assembly: Guid("94f62dd1-bcf3-4218-9844-9a3996286e3e")] | ||
25 | |||
26 | // Version information for an assembly consists of the following four values: | ||
27 | // | ||
28 | // Major Version | ||
29 | // Minor Version | ||
30 | // Build Number | ||
31 | // Revision | ||
32 | // | ||
33 | [assembly: AssemblyVersion("0.7.5.*")] | ||
34 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
35 | |||
36 | [assembly: Addin("OpenSim.Region.CoreModules", "0.1")] | ||
37 | [assembly: AddinDependency("OpenSim", "0.5")] | ||
38 | |||
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml deleted file mode 100644 index 424e0ab..0000000 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ /dev/null | |||
@@ -1,90 +0,0 @@ | |||
1 | <Addin id="OpenSim.Region.CoreModules" version="0.3"> | ||
2 | <Runtime> | ||
3 | <Import assembly="OpenSim.Region.CoreModules.dll"/> | ||
4 | </Runtime> | ||
5 | |||
6 | <Dependencies> | ||
7 | <Addin id="OpenSim" version="0.5" /> | ||
8 | </Dependencies> | ||
9 | |||
10 | <Extension path = "/OpenSim/RegionModules"> | ||
11 | <RegionModule id="UserManagementModule" type="OpenSim.Region.CoreModules.Framework.UserManagement.UserManagementModule" /> | ||
12 | <RegionModule id="HGUserManagementModule" type="OpenSim.Region.CoreModules.Framework.UserManagement.HGUserManagementModule" /> | ||
13 | <RegionModule id="EntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule" /> | ||
14 | <RegionModule id="HGEntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.HGEntityTransferModule" /> | ||
15 | <RegionModule id="InventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.BasicInventoryAccessModule" /> | ||
16 | <RegionModule id="HGInventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.HGInventoryAccessModule" /> | ||
17 | <RegionModule id="LandManagementModule" type="OpenSim.Region.CoreModules.World.Land.LandManagementModule" /> | ||
18 | <RegionModule id="PrimCountModule" type="OpenSim.Region.CoreModules.World.Land.PrimCountModule" /> | ||
19 | <RegionModule id="ExportSerialisationModule" type="OpenSim.Region.CoreModules.World.Serialiser.SerialiserModule" /> | ||
20 | <RegionModule id="ArchiverModule" type="OpenSim.Region.CoreModules.World.Archiver.ArchiverModule" /> | ||
21 | <RegionModule id="TerrainModule" type="OpenSim.Region.CoreModules.World.Terrain.TerrainModule" /> | ||
22 | <RegionModule id="WorldMapModule" type="OpenSim.Region.CoreModules.World.WorldMap.WorldMapModule" /> | ||
23 | <RegionModule id="Warp3DImageModule" type="OpenSim.Region.CoreModules.World.Warp3DMap.Warp3DImageModule" /> | ||
24 | <RegionModule id="HGWorldMapModule" type="OpenSim.Region.CoreModules.Hypergrid.HGWorldMapModule" /> | ||
25 | <RegionModule id="UrlModule" type="OpenSim.Region.CoreModules.Scripting.LSLHttp.UrlModule" /> | ||
26 | <RegionModule id="Chat" type="OpenSim.Region.CoreModules.Avatar.Chat.ChatModule" /> | ||
27 | <RegionModule id="FriendsModule" type="OpenSim.Region.CoreModules.Avatar.Friends.FriendsModule" /> | ||
28 | <RegionModule id="HGFriendsModule" type="OpenSim.Region.CoreModules.Avatar.Friends.HGFriendsModule" /> | ||
29 | <RegionModule id="PresenceModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.PresenceModule" /> | ||
30 | <RegionModule id="MuteListModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.MuteListModule" /> | ||
31 | <RegionModule id="OfflineMessageModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.OfflineMessageModule" /> | ||
32 | <RegionModule id="InstantMessageModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.InstantMessageModule" /> | ||
33 | <RegionModule id="MessageTransferModule" type="OpenSim.Region.CoreModules.Avatar.InstantMessage.MessageTransferModule" /> | ||
34 | <RegionModule id="LureModule" type="OpenSim.Region.CoreModules.Avatar.Lure.LureModule" /> | ||
35 | <RegionModule id="InventoryTransferModule" type="OpenSim.Region.CoreModules.Avatar.Inventory.Transfer.InventoryTransferModule" /> | ||
36 | <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" /> | ||
37 | <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" /> | ||
38 | <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/> | ||
39 | <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/> | ||
40 | <!-- Service connectors OUT modules --> | ||
41 | <RegionModule id="LocalAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.LocalAssetServicesConnector" /> | ||
42 | <RegionModule id="RemoteAssetServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.RemoteAssetServicesConnector" /> | ||
43 | <RegionModule id="LocalAvatarServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar.LocalAvatarServicesConnector" /> | ||
44 | <RegionModule id="RemoteAvatarServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar.RemoteAvatarServicesConnector" /> | ||
45 | <RegionModule id="LocalAuthenticationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication.LocalAuthenticationServicesConnector" /> | ||
46 | <RegionModule id="RemoteAuthenticationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication.RemoteAuthenticationServicesConnector" /> | ||
47 | <RegionModule id="LocalAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.LocalAuthorizationServicesConnector" /> | ||
48 | <RegionModule id="RemoteAuthorizationServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization.RemoteAuthorizationServicesConnector" /> | ||
49 | <RegionModule id="HGAssetBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset.HGAssetBroker" /> | ||
50 | <RegionModule id="LocalInventoryServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.LocalInventoryServicesConnector" /> | ||
51 | <RegionModule id="RemoteXInventoryServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.RemoteXInventoryServicesConnector" /> | ||
52 | <RegionModule id="HGInventoryBroker" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory.HGInventoryBroker" /> | ||
53 | <RegionModule id="LocalNeighbourServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour.LocalNeighbourServicesConnector" /> | ||
54 | <RegionModule id="RemoteNeighbourServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour.RemoteNeighbourServicesConnector" /> | ||
55 | <RegionModule id="LocalLandServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Land.LocalLandServicesConnector" /> | ||
56 | <RegionModule id="RemoteLandServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Land.RemoteLandServicesConnector" /> | ||
57 | <RegionModule id="LocalGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.LocalGridServicesConnector" /> | ||
58 | <RegionModule id="RemoteGridServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.RemoteGridServicesConnector" /> | ||
59 | <RegionModule id="LocalPresenceServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.LocalPresenceServicesConnector" /> | ||
60 | <RegionModule id="RemotePresenceServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.RemotePresenceServicesConnector" /> | ||
61 | <RegionModule id="LocalUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.LocalUserAccountServicesConnector" /> | ||
62 | <RegionModule id="RemoteUserAccountServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts.RemoteUserAccountServicesConnector" /> | ||
63 | |||
64 | <RegionModule id="LocalGridUserServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser.LocalGridUserServicesConnector" /> | ||
65 | <RegionModule id="RemoteGridUserServicesConnector" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser.RemoteGridUserServicesConnector" /> | ||
66 | |||
67 | <RegionModule id="LocalSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.LocalSimulationConnectorModule" /> | ||
68 | <RegionModule id="RemoteSimulationConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation.RemoteSimulationConnectorModule" /> | ||
69 | |||
70 | <!-- Service connectors IN modules --> | ||
71 | <RegionModule id="AssetServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset.AssetServiceInConnectorModule" /> | ||
72 | <RegionModule id="InventoryServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory.InventoryServiceInConnectorModule" /> | ||
73 | <RegionModule id="LandServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Land.LandServiceInConnectorModule" /> | ||
74 | <RegionModule id="NeighbourServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour.NeighbourServiceInConnectorModule" /> \ | ||
75 | <RegionModule id="HypergridServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid.HypergridServiceInConnectorModule" /> \ | ||
76 | <RegionModule id="LLLoginServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Login.LLLoginServiceInConnectorModule" /> \ | ||
77 | <RegionModule id="SimulationServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation.SimulationServiceInConnectorModule" /> \ | ||
78 | <RegionModule id="GridInfoServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid.GridInfoServiceInConnectorModule" /> \ | ||
79 | <RegionModule id="AuthenticationServiceInConnectorModule" type="OpenSim.Region.CoreModules.ServiceConnectorsIn.Authentication.AuthenticationServiceInConnectorModule" /> | ||
80 | <RegionModule id="AccessModule" type="OpenSim.Region.CoreModules.World.AccessModule" /> \ | ||
81 | <RegionModule id="MapImageModule" type="OpenSim.Region.CoreModules.World.LegacyMap.MapImageModule" /> \ | ||
82 | |||
83 | </Extension> | ||
84 | |||
85 | <Extension path = "/OpenSim/WindModule"> | ||
86 | <WindModel id="ConfigurableWind" type="OpenSim.Region.CoreModules.World.Wind.Plugins.ConfigurableWind" /> | ||
87 | <WindModel id="SimpleRandomWind" type="OpenSim.Region.CoreModules.World.Wind.Plugins.SimpleRandomWind" /> | ||
88 | </Extension> | ||
89 | |||
90 | </Addin> | ||
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 93a045e..9d77b19 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | |||
@@ -37,10 +37,12 @@ using OpenSim.Region.Framework.Interfaces; | |||
37 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
38 | using log4net; | 38 | using log4net; |
39 | using System.Reflection; | 39 | using System.Reflection; |
40 | using Mono.Addins; | ||
40 | 41 | ||
41 | namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | 42 | namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture |
42 | { | 43 | { |
43 | public class DynamicTextureModule : IRegionModule, IDynamicTextureManager | 44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DynamicTextureModule")] |
45 | public class DynamicTextureModule : ISharedRegionModule, IDynamicTextureManager | ||
44 | { | 46 | { |
45 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 48 | ||
@@ -81,6 +83,16 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
81 | /// </remarks> | 83 | /// </remarks> |
82 | private Cache m_reuseableDynamicTextures; | 84 | private Cache m_reuseableDynamicTextures; |
83 | 85 | ||
86 | /// <summary> | ||
87 | /// This constructor is only here because of the Unit Tests... | ||
88 | /// Don't use it. | ||
89 | /// </summary> | ||
90 | public DynamicTextureModule() | ||
91 | { | ||
92 | m_reuseableDynamicTextures = new Cache(CacheMedium.Memory, CacheStrategy.Conservative); | ||
93 | m_reuseableDynamicTextures.DefaultTTL = new TimeSpan(24, 0, 0); | ||
94 | } | ||
95 | |||
84 | #region IDynamicTextureManager Members | 96 | #region IDynamicTextureManager Members |
85 | 97 | ||
86 | public void RegisterRender(string handleType, IDynamicTextureRender render) | 98 | public void RegisterRender(string handleType, IDynamicTextureRender render) |
@@ -323,17 +335,30 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
323 | 335 | ||
324 | #endregion | 336 | #endregion |
325 | 337 | ||
326 | #region IRegionModule Members | 338 | #region ISharedRegionModule Members |
327 | 339 | ||
328 | public void Initialise(Scene scene, IConfigSource config) | 340 | public void Initialise(IConfigSource config) |
329 | { | 341 | { |
330 | IConfig texturesConfig = config.Configs["Textures"]; | 342 | IConfig texturesConfig = config.Configs["Textures"]; |
331 | if (texturesConfig != null) | 343 | if (texturesConfig != null) |
332 | { | 344 | { |
333 | ReuseTextures = texturesConfig.GetBoolean("ReuseDynamicTextures", false); | 345 | ReuseTextures = texturesConfig.GetBoolean("ReuseDynamicTextures", false); |
334 | ReuseLowDataTextures = texturesConfig.GetBoolean("ReuseDynamicLowDataTextures", false); | 346 | ReuseLowDataTextures = texturesConfig.GetBoolean("ReuseDynamicLowDataTextures", false); |
347 | |||
348 | if (ReuseTextures) | ||
349 | { | ||
350 | m_reuseableDynamicTextures = new Cache(CacheMedium.Memory, CacheStrategy.Conservative); | ||
351 | m_reuseableDynamicTextures.DefaultTTL = new TimeSpan(24, 0, 0); | ||
352 | } | ||
335 | } | 353 | } |
354 | } | ||
336 | 355 | ||
356 | public void PostInitialise() | ||
357 | { | ||
358 | } | ||
359 | |||
360 | public void AddRegion(Scene scene) | ||
361 | { | ||
337 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) | 362 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) |
338 | { | 363 | { |
339 | RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); | 364 | RegisteredScenes.Add(scene.RegionInfo.RegionID, scene); |
@@ -341,13 +366,14 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
341 | } | 366 | } |
342 | } | 367 | } |
343 | 368 | ||
344 | public void PostInitialise() | 369 | public void RegionLoaded(Scene scene) |
345 | { | 370 | { |
346 | if (ReuseTextures) | 371 | } |
347 | { | 372 | |
348 | m_reuseableDynamicTextures = new Cache(CacheMedium.Memory, CacheStrategy.Conservative); | 373 | public void RemoveRegion(Scene scene) |
349 | m_reuseableDynamicTextures.DefaultTTL = new TimeSpan(24, 0, 0); | 374 | { |
350 | } | 375 | if (RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) |
376 | RegisteredScenes.Remove(scene.RegionInfo.RegionID); | ||
351 | } | 377 | } |
352 | 378 | ||
353 | public void Close() | 379 | public void Close() |
@@ -359,9 +385,9 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
359 | get { return "DynamicTextureModule"; } | 385 | get { return "DynamicTextureModule"; } |
360 | } | 386 | } |
361 | 387 | ||
362 | public bool IsSharedModule | 388 | public Type ReplaceableInterface |
363 | { | 389 | { |
364 | get { return true; } | 390 | get { return null; } |
365 | } | 391 | } |
366 | 392 | ||
367 | #endregion | 393 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs index e91e8b9..d943b20 100644 --- a/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/EMailModules/EmailModule.cs | |||
@@ -37,10 +37,12 @@ using OpenMetaverse; | |||
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
40 | using Mono.Addins; | ||
40 | 41 | ||
41 | namespace OpenSim.Region.CoreModules.Scripting.EmailModules | 42 | namespace OpenSim.Region.CoreModules.Scripting.EmailModules |
42 | { | 43 | { |
43 | public class EmailModule : IRegionModule, IEmailModule | 44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EmailModule")] |
45 | public class EmailModule : ISharedRegionModule, IEmailModule | ||
44 | { | 46 | { |
45 | // | 47 | // |
46 | // Log | 48 | // Log |
@@ -72,31 +74,9 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
72 | 74 | ||
73 | private bool m_Enabled = false; | 75 | private bool m_Enabled = false; |
74 | 76 | ||
75 | public void InsertEmail(UUID to, Email email) | 77 | #region ISharedRegionModule |
76 | { | ||
77 | // It's tempting to create the queue here. Don't; objects which have | ||
78 | // not yet called GetNextEmail should have no queue, and emails to them | ||
79 | // should be silently dropped. | ||
80 | |||
81 | lock (m_MailQueues) | ||
82 | { | ||
83 | if (m_MailQueues.ContainsKey(to)) | ||
84 | { | ||
85 | if (m_MailQueues[to].Count >= m_MaxQueueSize) | ||
86 | { | ||
87 | // fail silently | ||
88 | return; | ||
89 | } | ||
90 | |||
91 | lock (m_MailQueues[to]) | ||
92 | { | ||
93 | m_MailQueues[to].Add(email); | ||
94 | } | ||
95 | } | ||
96 | } | ||
97 | } | ||
98 | 78 | ||
99 | public void Initialise(Scene scene, IConfigSource config) | 79 | public void Initialise(IConfigSource config) |
100 | { | 80 | { |
101 | m_Config = config; | 81 | m_Config = config; |
102 | IConfig SMTPConfig; | 82 | IConfig SMTPConfig; |
@@ -129,36 +109,44 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
129 | SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT); | 109 | SMTP_SERVER_PORT = SMTPConfig.GetInt("SMTP_SERVER_PORT", SMTP_SERVER_PORT); |
130 | SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN); | 110 | SMTP_SERVER_LOGIN = SMTPConfig.GetString("SMTP_SERVER_LOGIN", SMTP_SERVER_LOGIN); |
131 | SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD); | 111 | SMTP_SERVER_PASSWORD = SMTPConfig.GetString("SMTP_SERVER_PASSWORD", SMTP_SERVER_PASSWORD); |
132 | m_MaxEmailSize = SMTPConfig.GetInt("email_max_size", m_MaxEmailSize); | 112 | m_MaxEmailSize = SMTPConfig.GetInt("email_max_size", m_MaxEmailSize); |
133 | } | 113 | } |
134 | catch (Exception e) | 114 | catch (Exception e) |
135 | { | 115 | { |
136 | m_log.Error("[EMAIL] DefaultEmailModule not configured: "+ e.Message); | 116 | m_log.Error("[EMAIL] DefaultEmailModule not configured: " + e.Message); |
137 | m_Enabled = false; | 117 | m_Enabled = false; |
138 | return; | 118 | return; |
139 | } | 119 | } |
140 | 120 | ||
141 | // It's a go! | 121 | } |
142 | if (m_Enabled) | 122 | |
123 | public void AddRegion(Scene scene) | ||
124 | { | ||
125 | if (!m_Enabled) | ||
126 | return; | ||
127 | |||
128 | // It's a go! | ||
129 | lock (m_Scenes) | ||
143 | { | 130 | { |
144 | lock (m_Scenes) | 131 | // Claim the interface slot |
145 | { | 132 | scene.RegisterModuleInterface<IEmailModule>(this); |
146 | // Claim the interface slot | ||
147 | scene.RegisterModuleInterface<IEmailModule>(this); | ||
148 | 133 | ||
149 | // Add to scene list | 134 | // Add to scene list |
150 | if (m_Scenes.ContainsKey(scene.RegionInfo.RegionHandle)) | 135 | if (m_Scenes.ContainsKey(scene.RegionInfo.RegionHandle)) |
151 | { | 136 | { |
152 | m_Scenes[scene.RegionInfo.RegionHandle] = scene; | 137 | m_Scenes[scene.RegionInfo.RegionHandle] = scene; |
153 | } | 138 | } |
154 | else | 139 | else |
155 | { | 140 | { |
156 | m_Scenes.Add(scene.RegionInfo.RegionHandle, scene); | 141 | m_Scenes.Add(scene.RegionInfo.RegionHandle, scene); |
157 | } | ||
158 | } | 142 | } |
159 | |||
160 | m_log.Info("[EMAIL] Activated DefaultEmailModule"); | ||
161 | } | 143 | } |
144 | |||
145 | m_log.Info("[EMAIL] Activated DefaultEmailModule"); | ||
146 | } | ||
147 | |||
148 | public void RemoveRegion(Scene scene) | ||
149 | { | ||
162 | } | 150 | } |
163 | 151 | ||
164 | public void PostInitialise() | 152 | public void PostInitialise() |
@@ -174,9 +162,39 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules | |||
174 | get { return "DefaultEmailModule"; } | 162 | get { return "DefaultEmailModule"; } |
175 | } | 163 | } |
176 | 164 | ||
177 | public bool IsSharedModule | 165 | public Type ReplaceableInterface |
166 | { | ||
167 | get { return null; } | ||
168 | } | ||
169 | |||
170 | public void RegionLoaded(Scene scene) | ||
178 | { | 171 | { |
179 | get { return true; } | 172 | } |
173 | |||
174 | #endregion | ||
175 | |||
176 | public void InsertEmail(UUID to, Email email) | ||
177 | { | ||
178 | // It's tempting to create the queue here. Don't; objects which have | ||
179 | // not yet called GetNextEmail should have no queue, and emails to them | ||
180 | // should be silently dropped. | ||
181 | |||
182 | lock (m_MailQueues) | ||
183 | { | ||
184 | if (m_MailQueues.ContainsKey(to)) | ||
185 | { | ||
186 | if (m_MailQueues[to].Count >= m_MaxQueueSize) | ||
187 | { | ||
188 | // fail silently | ||
189 | return; | ||
190 | } | ||
191 | |||
192 | lock (m_MailQueues[to]) | ||
193 | { | ||
194 | m_MailQueues[to].Add(email); | ||
195 | } | ||
196 | } | ||
197 | } | ||
180 | } | 198 | } |
181 | 199 | ||
182 | private bool IsLocal(UUID objectID) | 200 | private bool IsLocal(UUID objectID) |
diff --git a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs index d328eb3..a676971 100644 --- a/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs +++ b/OpenSim/Region/CoreModules/Scripting/HttpRequest/ScriptsHttpRequests.cs | |||
@@ -41,6 +41,7 @@ using OpenSim.Framework.Servers; | |||
41 | using OpenSim.Framework.Servers.HttpServer; | 41 | using OpenSim.Framework.Servers.HttpServer; |
42 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
44 | using Mono.Addins; | ||
44 | 45 | ||
45 | /***************************************************** | 46 | /***************************************************** |
46 | * | 47 | * |
@@ -87,7 +88,8 @@ using OpenSim.Region.Framework.Scenes; | |||
87 | 88 | ||
88 | namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | 89 | namespace OpenSim.Region.CoreModules.Scripting.HttpRequest |
89 | { | 90 | { |
90 | public class HttpRequestModule : IRegionModule, IHttpRequestModule | 91 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HttpRequestModule")] |
92 | public class HttpRequestModule : ISharedRegionModule, IHttpRequestModule | ||
91 | { | 93 | { |
92 | private object HttpListLock = new object(); | 94 | private object HttpListLock = new object(); |
93 | private int httpTimeout = 30000; | 95 | private int httpTimeout = 30000; |
@@ -270,24 +272,38 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
270 | 272 | ||
271 | #endregion | 273 | #endregion |
272 | 274 | ||
273 | #region IRegionModule Members | 275 | #region ISharedRegionModule Members |
274 | 276 | ||
275 | public void Initialise(Scene scene, IConfigSource config) | 277 | public void Initialise(IConfigSource config) |
276 | { | 278 | { |
277 | m_scene = scene; | ||
278 | |||
279 | m_scene.RegisterModuleInterface<IHttpRequestModule>(this); | ||
280 | |||
281 | m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); | 279 | m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); |
282 | m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); | 280 | m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); |
283 | 281 | ||
284 | m_pendingRequests = new Dictionary<UUID, HttpRequestClass>(); | 282 | m_pendingRequests = new Dictionary<UUID, HttpRequestClass>(); |
285 | } | 283 | } |
286 | 284 | ||
285 | public void AddRegion(Scene scene) | ||
286 | { | ||
287 | m_scene = scene; | ||
288 | |||
289 | m_scene.RegisterModuleInterface<IHttpRequestModule>(this); | ||
290 | } | ||
291 | |||
292 | public void RemoveRegion(Scene scene) | ||
293 | { | ||
294 | scene.UnregisterModuleInterface<IHttpRequestModule>(this); | ||
295 | if (scene == m_scene) | ||
296 | m_scene = null; | ||
297 | } | ||
298 | |||
287 | public void PostInitialise() | 299 | public void PostInitialise() |
288 | { | 300 | { |
289 | } | 301 | } |
290 | 302 | ||
303 | public void RegionLoaded(Scene scene) | ||
304 | { | ||
305 | } | ||
306 | |||
291 | public void Close() | 307 | public void Close() |
292 | { | 308 | { |
293 | } | 309 | } |
@@ -297,9 +313,9 @@ namespace OpenSim.Region.CoreModules.Scripting.HttpRequest | |||
297 | get { return m_name; } | 313 | get { return m_name; } |
298 | } | 314 | } |
299 | 315 | ||
300 | public bool IsSharedModule | 316 | public Type ReplaceableInterface |
301 | { | 317 | { |
302 | get { return true; } | 318 | get { return null; } |
303 | } | 319 | } |
304 | 320 | ||
305 | #endregion | 321 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 53a9679..a654477 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | |||
@@ -31,6 +31,7 @@ using System.Collections.Generic; | |||
31 | using System.Collections; | 31 | using System.Collections; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using log4net; | 33 | using log4net; |
34 | using Mono.Addins; | ||
34 | using Nini.Config; | 35 | using Nini.Config; |
35 | using OpenMetaverse; | 36 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
@@ -94,6 +95,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp | |||
94 | /// <summary> | 95 | /// <summary> |
95 | /// This module provides external URLs for in-world scripts. | 96 | /// This module provides external URLs for in-world scripts. |
96 | /// </summary> | 97 | /// </summary> |
98 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UrlModule")] | ||
97 | public class UrlModule : ISharedRegionModule, IUrlModule | 99 | public class UrlModule : ISharedRegionModule, IUrlModule |
98 | { | 100 | { |
99 | private static readonly ILog m_log = | 101 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs index 45e6527..65737fa 100644 --- a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs | |||
@@ -37,10 +37,12 @@ using OpenSim.Region.Framework.Interfaces; | |||
37 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
38 | using log4net; | 38 | using log4net; |
39 | using System.Reflection; | 39 | using System.Reflection; |
40 | using Mono.Addins; | ||
40 | 41 | ||
41 | namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | 42 | namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL |
42 | { | 43 | { |
43 | public class LoadImageURLModule : IRegionModule, IDynamicTextureRender | 44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LoadImageURLModule")] |
45 | public class LoadImageURLModule : ISharedRegionModule, IDynamicTextureRender | ||
44 | { | 46 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 48 | ||
@@ -104,22 +106,32 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
104 | 106 | ||
105 | #endregion | 107 | #endregion |
106 | 108 | ||
107 | #region IRegionModule Members | 109 | #region ISharedRegionModule Members |
108 | 110 | ||
109 | public void Initialise(Scene scene, IConfigSource config) | 111 | public void Initialise(IConfigSource config) |
110 | { | 112 | { |
111 | if (m_scene == null) | ||
112 | { | ||
113 | m_scene = scene; | ||
114 | } | ||
115 | |||
116 | m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); | 113 | m_proxyurl = config.Configs["Startup"].GetString("HttpProxy"); |
117 | m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); | 114 | m_proxyexcepts = config.Configs["Startup"].GetString("HttpProxyExceptions"); |
118 | } | 115 | } |
119 | 116 | ||
120 | public void PostInitialise() | 117 | public void PostInitialise() |
121 | { | 118 | { |
122 | if (m_scene != null) | 119 | } |
120 | |||
121 | public void AddRegion(Scene scene) | ||
122 | { | ||
123 | if (m_scene == null) | ||
124 | m_scene = scene; | ||
125 | |||
126 | } | ||
127 | |||
128 | public void RemoveRegion(Scene scene) | ||
129 | { | ||
130 | } | ||
131 | |||
132 | public void RegionLoaded(Scene scene) | ||
133 | { | ||
134 | if (m_textureManager == null && m_scene == scene) | ||
123 | { | 135 | { |
124 | m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>(); | 136 | m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>(); |
125 | if (m_textureManager != null) | 137 | if (m_textureManager != null) |
@@ -138,9 +150,9 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
138 | get { return m_name; } | 150 | get { return m_name; } |
139 | } | 151 | } |
140 | 152 | ||
141 | public bool IsSharedModule | 153 | public Type ReplaceableInterface |
142 | { | 154 | { |
143 | get { return true; } | 155 | get { return null; } |
144 | } | 156 | } |
145 | 157 | ||
146 | #endregion | 158 | #endregion |
@@ -172,6 +184,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
172 | 184 | ||
173 | private void HttpRequestReturn(IAsyncResult result) | 185 | private void HttpRequestReturn(IAsyncResult result) |
174 | { | 186 | { |
187 | if (m_textureManager == null) | ||
188 | { | ||
189 | m_log.WarnFormat("[LOADIMAGEURLMODULE]: No texture manager. Can't function."); | ||
190 | return; | ||
191 | } | ||
192 | |||
175 | RequestState state = (RequestState) result.AsyncState; | 193 | RequestState state = (RequestState) result.AsyncState; |
176 | WebRequest request = (WebRequest) state.Request; | 194 | WebRequest request = (WebRequest) state.Request; |
177 | Stream stream = null; | 195 | Stream stream = null; |
diff --git a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs index 98396ff..f6e1d39 100644 --- a/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs | |||
@@ -38,7 +38,7 @@ using OpenMetaverse; | |||
38 | using System.Linq; | 38 | using System.Linq; |
39 | using System.Linq.Expressions; | 39 | using System.Linq.Expressions; |
40 | 40 | ||
41 | namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms | 41 | namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms |
42 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] | 43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] |
44 | class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms | 44 | class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms |
@@ -361,6 +361,22 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms | |||
361 | return null; | 361 | return null; |
362 | } | 362 | } |
363 | 363 | ||
364 | /// <summary> | ||
365 | /// Get all registered constants | ||
366 | /// </summary> | ||
367 | public Dictionary<string, object> GetConstants() | ||
368 | { | ||
369 | Dictionary<string, object> ret = new Dictionary<string, object>(); | ||
370 | |||
371 | lock (m_constants) | ||
372 | { | ||
373 | foreach (KeyValuePair<string, object> kvp in m_constants) | ||
374 | ret[kvp.Key] = kvp.Value; | ||
375 | } | ||
376 | |||
377 | return ret; | ||
378 | } | ||
379 | |||
364 | #endregion | 380 | #endregion |
365 | 381 | ||
366 | } | 382 | } |
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index b4e3d77..689e8a7 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs | |||
@@ -40,12 +40,14 @@ using OpenSim.Region.Framework.Interfaces; | |||
40 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
41 | using log4net; | 41 | using log4net; |
42 | using System.Reflection; | 42 | using System.Reflection; |
43 | using Mono.Addins; | ||
43 | 44 | ||
44 | //using Cairo; | 45 | //using Cairo; |
45 | 46 | ||
46 | namespace OpenSim.Region.CoreModules.Scripting.VectorRender | 47 | namespace OpenSim.Region.CoreModules.Scripting.VectorRender |
47 | { | 48 | { |
48 | public class VectorRenderModule : IRegionModule, IDynamicTextureRender | 49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "VectorRenderModule")] |
50 | public class VectorRenderModule : ISharedRegionModule, IDynamicTextureRender | ||
49 | { | 51 | { |
50 | // These fields exist for testing purposes, please do not remove. | 52 | // These fields exist for testing purposes, please do not remove. |
51 | // private static bool s_flipper; | 53 | // private static bool s_flipper; |
@@ -56,6 +58,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
56 | 58 | ||
57 | private Scene m_scene; | 59 | private Scene m_scene; |
58 | private IDynamicTextureManager m_textureManager; | 60 | private IDynamicTextureManager m_textureManager; |
61 | |||
59 | private Graphics m_graph; | 62 | private Graphics m_graph; |
60 | private string m_fontName = "Arial"; | 63 | private string m_fontName = "Arial"; |
61 | 64 | ||
@@ -103,6 +106,11 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
103 | 106 | ||
104 | public bool AsyncConvertData(UUID id, string bodyData, string extraParams) | 107 | public bool AsyncConvertData(UUID id, string bodyData, string extraParams) |
105 | { | 108 | { |
109 | if (m_textureManager == null) | ||
110 | { | ||
111 | m_log.Warn("[VECTORRENDERMODULE]: No texture manager. Can't function"); | ||
112 | return false; | ||
113 | } | ||
106 | // XXX: This isn't actually being done asynchronously! | 114 | // XXX: This isn't actually being done asynchronously! |
107 | m_textureManager.ReturnData(id, ConvertData(bodyData, extraParams)); | 115 | m_textureManager.ReturnData(id, ConvertData(bodyData, extraParams)); |
108 | 116 | ||
@@ -131,45 +139,49 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
131 | 139 | ||
132 | #endregion | 140 | #endregion |
133 | 141 | ||
134 | #region IRegionModule Members | 142 | #region ISharedRegionModule Members |
135 | 143 | ||
136 | public void Initialise(Scene scene, IConfigSource config) | 144 | public void Initialise(IConfigSource config) |
137 | { | 145 | { |
138 | if (m_scene == null) | ||
139 | { | ||
140 | m_scene = scene; | ||
141 | } | ||
142 | |||
143 | if (m_graph == null) | ||
144 | { | ||
145 | // We won't dispose of these explicitly since this module is only removed when the entire simulator | ||
146 | // is shut down. | ||
147 | Bitmap bitmap = new Bitmap(1024, 1024, PixelFormat.Format32bppArgb); | ||
148 | m_graph = Graphics.FromImage(bitmap); | ||
149 | } | ||
150 | |||
151 | IConfig cfg = config.Configs["VectorRender"]; | 146 | IConfig cfg = config.Configs["VectorRender"]; |
152 | if (null != cfg) | 147 | if (null != cfg) |
153 | { | 148 | { |
154 | m_fontName = cfg.GetString("font_name", m_fontName); | 149 | m_fontName = cfg.GetString("font_name", m_fontName); |
155 | } | 150 | } |
156 | m_log.DebugFormat("[VECTORRENDERMODULE]: using font \"{0}\" for text rendering.", m_fontName); | 151 | m_log.DebugFormat("[VECTORRENDERMODULE]: using font \"{0}\" for text rendering.", m_fontName); |
152 | |||
153 | // We won't dispose of these explicitly since this module is only removed when the entire simulator | ||
154 | // is shut down. | ||
155 | Bitmap bitmap = new Bitmap(1024, 1024, PixelFormat.Format32bppArgb); | ||
156 | m_graph = Graphics.FromImage(bitmap); | ||
157 | } | 157 | } |
158 | 158 | ||
159 | public void PostInitialise() | 159 | public void PostInitialise() |
160 | { | 160 | { |
161 | m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>(); | 161 | } |
162 | if (m_textureManager != null) | 162 | |
163 | public void AddRegion(Scene scene) | ||
164 | { | ||
165 | if (m_scene == null) | ||
163 | { | 166 | { |
164 | m_textureManager.RegisterRender(GetContentType(), this); | 167 | m_scene = scene; |
165 | } | 168 | } |
169 | } | ||
166 | 170 | ||
167 | // This code exists for testing purposes, please do not remove. | 171 | public void RegionLoaded(Scene scene) |
168 | // s_asset1Data = m_scene.AssetService.Get("00000000-0000-1111-9999-000000000001").Data; | 172 | { |
169 | // s_asset1Data = m_scene.AssetService.Get("9f4acf0d-1841-4e15-bdb8-3a12efc9dd8f").Data; | 173 | if (m_textureManager == null && m_scene == scene) |
174 | { | ||
175 | m_textureManager = m_scene.RequestModuleInterface<IDynamicTextureManager>(); | ||
176 | if (m_textureManager != null) | ||
177 | { | ||
178 | m_textureManager.RegisterRender(GetContentType(), this); | ||
179 | } | ||
180 | } | ||
181 | } | ||
170 | 182 | ||
171 | // Terrain dirt - smallest bin/assets file (6004 bytes) | 183 | public void RemoveRegion(Scene scene) |
172 | // s_asset2Data = m_scene.AssetService.Get("b8d3965a-ad78-bf43-699b-bff8eca6c975").Data; | 184 | { |
173 | } | 185 | } |
174 | 186 | ||
175 | public void Close() | 187 | public void Close() |
@@ -181,9 +193,9 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
181 | get { return "VectorRenderModule"; } | 193 | get { return "VectorRenderModule"; } |
182 | } | 194 | } |
183 | 195 | ||
184 | public bool IsSharedModule | 196 | public Type ReplaceableInterface |
185 | { | 197 | { |
186 | get { return true; } | 198 | get { return null; } |
187 | } | 199 | } |
188 | 200 | ||
189 | #endregion | 201 | #endregion |
diff --git a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs index 8358bc0..2c2c99c 100644 --- a/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/WorldComm/WorldCommModule.cs | |||
@@ -28,8 +28,13 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections; | 29 | using System.Collections; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Text.RegularExpressions; | ||
32 | |||
31 | using Nini.Config; | 33 | using Nini.Config; |
34 | using Mono.Addins; | ||
35 | |||
32 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | |||
33 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
34 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
@@ -85,7 +90,8 @@ using OpenSim.Region.Framework.Scenes; | |||
85 | 90 | ||
86 | namespace OpenSim.Region.CoreModules.Scripting.WorldComm | 91 | namespace OpenSim.Region.CoreModules.Scripting.WorldComm |
87 | { | 92 | { |
88 | public class WorldCommModule : IRegionModule, IWorldComm | 93 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WorldCommModule")] |
94 | public class WorldCommModule : IWorldComm, INonSharedRegionModule | ||
89 | { | 95 | { |
90 | // private static readonly ILog m_log = | 96 | // private static readonly ILog m_log = |
91 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 97 | // LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -98,9 +104,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
98 | private int m_saydistance = 20; | 104 | private int m_saydistance = 20; |
99 | private int m_shoutdistance = 100; | 105 | private int m_shoutdistance = 100; |
100 | 106 | ||
101 | #region IRegionModule Members | 107 | #region INonSharedRegionModule Members |
102 | 108 | ||
103 | public void Initialise(Scene scene, IConfigSource config) | 109 | public void Initialise(IConfigSource config) |
104 | { | 110 | { |
105 | // wrap this in a try block so that defaults will work if | 111 | // wrap this in a try block so that defaults will work if |
106 | // the config file doesn't specify otherwise. | 112 | // the config file doesn't specify otherwise. |
@@ -108,29 +114,49 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
108 | int maxhandles = 64; | 114 | int maxhandles = 64; |
109 | try | 115 | try |
110 | { | 116 | { |
111 | m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance); | 117 | m_whisperdistance = config.Configs["Chat"].GetInt( |
112 | m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance); | 118 | "whisper_distance", m_whisperdistance); |
113 | m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance); | 119 | m_saydistance = config.Configs["Chat"].GetInt( |
114 | maxlisteners = config.Configs["LL-Functions"].GetInt("max_listens_per_region", maxlisteners); | 120 | "say_distance", m_saydistance); |
115 | maxhandles = config.Configs["LL-Functions"].GetInt("max_listens_per_script", maxhandles); | 121 | m_shoutdistance = config.Configs["Chat"].GetInt( |
122 | "shout_distance", m_shoutdistance); | ||
123 | maxlisteners = config.Configs["LL-Functions"].GetInt( | ||
124 | "max_listens_per_region", maxlisteners); | ||
125 | maxhandles = config.Configs["LL-Functions"].GetInt( | ||
126 | "max_listens_per_script", maxhandles); | ||
116 | } | 127 | } |
117 | catch (Exception) | 128 | catch (Exception) |
118 | { | 129 | { |
119 | } | 130 | } |
120 | if (maxlisteners < 1) maxlisteners = int.MaxValue; | 131 | if (maxlisteners < 1) maxlisteners = int.MaxValue; |
121 | if (maxhandles < 1) maxhandles = int.MaxValue; | 132 | if (maxhandles < 1) maxhandles = int.MaxValue; |
133 | m_listenerManager = new ListenerManager(maxlisteners, maxhandles); | ||
134 | m_pendingQ = new Queue(); | ||
135 | m_pending = Queue.Synchronized(m_pendingQ); | ||
136 | } | ||
122 | 137 | ||
138 | public void PostInitialise() | ||
139 | { | ||
140 | } | ||
141 | |||
142 | public void AddRegion(Scene scene) | ||
143 | { | ||
123 | m_scene = scene; | 144 | m_scene = scene; |
124 | m_scene.RegisterModuleInterface<IWorldComm>(this); | 145 | m_scene.RegisterModuleInterface<IWorldComm>(this); |
125 | m_listenerManager = new ListenerManager(maxlisteners, maxhandles); | ||
126 | m_scene.EventManager.OnChatFromClient += DeliverClientMessage; | 146 | m_scene.EventManager.OnChatFromClient += DeliverClientMessage; |
127 | m_scene.EventManager.OnChatBroadcast += DeliverClientMessage; | 147 | m_scene.EventManager.OnChatBroadcast += DeliverClientMessage; |
128 | m_pendingQ = new Queue(); | ||
129 | m_pending = Queue.Synchronized(m_pendingQ); | ||
130 | } | 148 | } |
131 | 149 | ||
132 | public void PostInitialise() | 150 | public void RegionLoaded(Scene scene) { } |
151 | |||
152 | public void RemoveRegion(Scene scene) | ||
133 | { | 153 | { |
154 | if (scene != m_scene) | ||
155 | return; | ||
156 | |||
157 | m_scene.UnregisterModuleInterface<IWorldComm>(this); | ||
158 | m_scene.EventManager.OnChatBroadcast -= DeliverClientMessage; | ||
159 | m_scene.EventManager.OnChatBroadcast -= DeliverClientMessage; | ||
134 | } | 160 | } |
135 | 161 | ||
136 | public void Close() | 162 | public void Close() |
@@ -142,10 +168,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
142 | get { return "WorldCommModule"; } | 168 | get { return "WorldCommModule"; } |
143 | } | 169 | } |
144 | 170 | ||
145 | public bool IsSharedModule | 171 | public Type ReplaceableInterface { get { return null; } } |
146 | { | ||
147 | get { return false; } | ||
148 | } | ||
149 | 172 | ||
150 | #endregion | 173 | #endregion |
151 | 174 | ||
@@ -170,12 +193,42 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
170 | /// <param name="hostID">UUID of the SceneObjectPart</param> | 193 | /// <param name="hostID">UUID of the SceneObjectPart</param> |
171 | /// <param name="channel">channel to listen on</param> | 194 | /// <param name="channel">channel to listen on</param> |
172 | /// <param name="name">name to filter on</param> | 195 | /// <param name="name">name to filter on</param> |
173 | /// <param name="id">key to filter on (user given, could be totally faked)</param> | 196 | /// <param name="id"> |
197 | /// key to filter on (user given, could be totally faked) | ||
198 | /// </param> | ||
174 | /// <param name="msg">msg to filter on</param> | 199 | /// <param name="msg">msg to filter on</param> |
175 | /// <returns>number of the scripts handle</returns> | 200 | /// <returns>number of the scripts handle</returns> |
176 | public int Listen(uint localID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg) | 201 | public int Listen(uint localID, UUID itemID, UUID hostID, int channel, |
202 | string name, UUID id, string msg) | ||
177 | { | 203 | { |
178 | return m_listenerManager.AddListener(localID, itemID, hostID, channel, name, id, msg); | 204 | return m_listenerManager.AddListener(localID, itemID, hostID, |
205 | channel, name, id, msg); | ||
206 | } | ||
207 | |||
208 | /// <summary> | ||
209 | /// Create a listen event callback with the specified filters. | ||
210 | /// The parameters localID,itemID are needed to uniquely identify | ||
211 | /// the script during 'peek' time. Parameter hostID is needed to | ||
212 | /// determine the position of the script. | ||
213 | /// </summary> | ||
214 | /// <param name="localID">localID of the script engine</param> | ||
215 | /// <param name="itemID">UUID of the script engine</param> | ||
216 | /// <param name="hostID">UUID of the SceneObjectPart</param> | ||
217 | /// <param name="channel">channel to listen on</param> | ||
218 | /// <param name="name">name to filter on</param> | ||
219 | /// <param name="id"> | ||
220 | /// key to filter on (user given, could be totally faked) | ||
221 | /// </param> | ||
222 | /// <param name="msg">msg to filter on</param> | ||
223 | /// <param name="regexBitfield"> | ||
224 | /// Bitfield indicating which strings should be processed as regex. | ||
225 | /// </param> | ||
226 | /// <returns>number of the scripts handle</returns> | ||
227 | public int Listen(uint localID, UUID itemID, UUID hostID, int channel, | ||
228 | string name, UUID id, string msg, int regexBitfield) | ||
229 | { | ||
230 | return m_listenerManager.AddListener(localID, itemID, hostID, | ||
231 | channel, name, id, msg, regexBitfield); | ||
179 | } | 232 | } |
180 | 233 | ||
181 | /// <summary> | 234 | /// <summary> |
@@ -224,7 +277,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
224 | 277 | ||
225 | if ((source = m_scene.GetSceneObjectPart(id)) != null) | 278 | if ((source = m_scene.GetSceneObjectPart(id)) != null) |
226 | position = source.AbsolutePosition; | 279 | position = source.AbsolutePosition; |
227 | else if ((avatar = m_scene.GetScenePresence(id)) != null) | 280 | else if ((avatar = m_scene.GetScenePresence(id)) != null) |
228 | position = avatar.AbsolutePosition; | 281 | position = avatar.AbsolutePosition; |
229 | else if (ChatTypeEnum.Region == type) | 282 | else if (ChatTypeEnum.Region == type) |
230 | position = CenterOfRegion; | 283 | position = CenterOfRegion; |
@@ -247,7 +300,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
247 | /// <param name="name">name of sender (object or avatar)</param> | 300 | /// <param name="name">name of sender (object or avatar)</param> |
248 | /// <param name="id">key of sender (object or avatar)</param> | 301 | /// <param name="id">key of sender (object or avatar)</param> |
249 | /// <param name="msg">msg to sent</param> | 302 | /// <param name="msg">msg to sent</param> |
250 | public void DeliverMessage(ChatTypeEnum type, int channel, string name, UUID id, string msg, Vector3 position) | 303 | public void DeliverMessage(ChatTypeEnum type, int channel, |
304 | string name, UUID id, string msg, Vector3 position) | ||
251 | { | 305 | { |
252 | // m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}", | 306 | // m_log.DebugFormat("[WorldComm] got[2] type {0}, channel {1}, name {2}, id {3}, msg {4}", |
253 | // type, channel, name, id, msg); | 307 | // type, channel, name, id, msg); |
@@ -255,17 +309,21 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
255 | // Determine which listen event filters match the given set of arguments, this results | 309 | // Determine which listen event filters match the given set of arguments, this results |
256 | // in a limited set of listeners, each belonging a host. If the host is in range, add them | 310 | // in a limited set of listeners, each belonging a host. If the host is in range, add them |
257 | // to the pending queue. | 311 | // to the pending queue. |
258 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | 312 | foreach (ListenerInfo li |
313 | in m_listenerManager.GetListeners(UUID.Zero, channel, | ||
314 | name, id, msg)) | ||
259 | { | 315 | { |
260 | // Dont process if this message is from yourself! | 316 | // Dont process if this message is from yourself! |
261 | if (li.GetHostID().Equals(id)) | 317 | if (li.GetHostID().Equals(id)) |
262 | continue; | 318 | continue; |
263 | 319 | ||
264 | SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID()); | 320 | SceneObjectPart sPart = m_scene.GetSceneObjectPart( |
321 | li.GetHostID()); | ||
265 | if (sPart == null) | 322 | if (sPart == null) |
266 | continue; | 323 | continue; |
267 | 324 | ||
268 | double dis = Util.GetDistanceTo(sPart.AbsolutePosition, position); | 325 | double dis = Util.GetDistanceTo(sPart.AbsolutePosition, |
326 | position); | ||
269 | switch (type) | 327 | switch (type) |
270 | { | 328 | { |
271 | case ChatTypeEnum.Whisper: | 329 | case ChatTypeEnum.Whisper: |
@@ -308,14 +366,16 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
308 | /// <param name='msg'> | 366 | /// <param name='msg'> |
309 | /// Message. | 367 | /// Message. |
310 | /// </param> | 368 | /// </param> |
311 | public void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg) | 369 | public void DeliverMessageTo(UUID target, int channel, Vector3 pos, |
370 | string name, UUID id, string msg) | ||
312 | { | 371 | { |
313 | // Is id an avatar? | 372 | // Is id an avatar? |
314 | ScenePresence sp = m_scene.GetScenePresence(target); | 373 | ScenePresence sp = m_scene.GetScenePresence(target); |
315 | 374 | ||
316 | if (sp != null) | 375 | if (sp != null) |
317 | { | 376 | { |
318 | // ignore if a child agent this is restricted to inside one region | 377 | // ignore if a child agent this is restricted to inside one |
378 | // region | ||
319 | if (sp.IsChildAgent) | 379 | if (sp.IsChildAgent) |
320 | return; | 380 | return; |
321 | 381 | ||
@@ -324,8 +384,9 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
324 | // non zero channel messages only go to the attachments | 384 | // non zero channel messages only go to the attachments |
325 | if (channel == 0) | 385 | if (channel == 0) |
326 | { | 386 | { |
327 | m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), pos, name, id, false); | 387 | m_scene.SimChatToAgent(target, Utils.StringToBytes(msg), |
328 | } | 388 | pos, name, id, false); |
389 | } | ||
329 | else | 390 | else |
330 | { | 391 | { |
331 | List<SceneObjectGroup> attachments = sp.GetAttachments(); | 392 | List<SceneObjectGroup> attachments = sp.GetAttachments(); |
@@ -341,13 +402,18 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
341 | } | 402 | } |
342 | 403 | ||
343 | // Need to check each attachment | 404 | // Need to check each attachment |
344 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | 405 | foreach (ListenerInfo li |
406 | in m_listenerManager.GetListeners(UUID.Zero, | ||
407 | channel, name, id, msg)) | ||
345 | { | 408 | { |
346 | if (li.GetHostID().Equals(id)) | 409 | if (li.GetHostID().Equals(id)) |
347 | continue; | 410 | continue; |
348 | 411 | ||
349 | if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) | 412 | if (m_scene.GetSceneObjectPart( |
413 | li.GetHostID()) == null) | ||
414 | { | ||
350 | continue; | 415 | continue; |
416 | } | ||
351 | 417 | ||
352 | if (targets.Contains(li.GetHostID())) | 418 | if (targets.Contains(li.GetHostID())) |
353 | QueueMessage(new ListenerInfo(li, name, id, msg)); | 419 | QueueMessage(new ListenerInfo(li, name, id, msg)); |
@@ -358,17 +424,20 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
358 | } | 424 | } |
359 | 425 | ||
360 | // No avatar found so look for an object | 426 | // No avatar found so look for an object |
361 | foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) | 427 | foreach (ListenerInfo li |
428 | in m_listenerManager.GetListeners(UUID.Zero, channel, | ||
429 | name, id, msg)) | ||
362 | { | 430 | { |
363 | // Dont process if this message is from yourself! | 431 | // Dont process if this message is from yourself! |
364 | if (li.GetHostID().Equals(id)) | 432 | if (li.GetHostID().Equals(id)) |
365 | continue; | 433 | continue; |
366 | 434 | ||
367 | SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID()); | 435 | SceneObjectPart sPart = m_scene.GetSceneObjectPart( |
436 | li.GetHostID()); | ||
368 | if (sPart == null) | 437 | if (sPart == null) |
369 | continue; | 438 | continue; |
370 | 439 | ||
371 | if ( li.GetHostID().Equals(target)) | 440 | if (li.GetHostID().Equals(target)) |
372 | { | 441 | { |
373 | QueueMessage(new ListenerInfo(li, name, id, msg)); | 442 | QueueMessage(new ListenerInfo(li, name, id, msg)); |
374 | break; | 443 | break; |
@@ -422,9 +491,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
422 | private void DeliverClientMessage(Object sender, OSChatMessage e) | 491 | private void DeliverClientMessage(Object sender, OSChatMessage e) |
423 | { | 492 | { |
424 | if (null != e.Sender) | 493 | if (null != e.Sender) |
425 | DeliverMessage(e.Type, e.Channel, e.Sender.Name, e.Sender.AgentId, e.Message, e.Position); | 494 | { |
495 | DeliverMessage(e.Type, e.Channel, e.Sender.Name, | ||
496 | e.Sender.AgentId, e.Message, e.Position); | ||
497 | } | ||
426 | else | 498 | else |
427 | DeliverMessage(e.Type, e.Channel, e.From, UUID.Zero, e.Message, e.Position); | 499 | { |
500 | DeliverMessage(e.Type, e.Channel, e.From, UUID.Zero, | ||
501 | e.Message, e.Position); | ||
502 | } | ||
428 | } | 503 | } |
429 | 504 | ||
430 | public Object[] GetSerializationData(UUID itemID) | 505 | public Object[] GetSerializationData(UUID itemID) |
@@ -441,7 +516,8 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
441 | 516 | ||
442 | public class ListenerManager | 517 | public class ListenerManager |
443 | { | 518 | { |
444 | private Dictionary<int, List<ListenerInfo>> m_listeners = new Dictionary<int, List<ListenerInfo>>(); | 519 | private Dictionary<int, List<ListenerInfo>> m_listeners = |
520 | new Dictionary<int, List<ListenerInfo>>(); | ||
445 | private int m_maxlisteners; | 521 | private int m_maxlisteners; |
446 | private int m_maxhandles; | 522 | private int m_maxhandles; |
447 | private int m_curlisteners; | 523 | private int m_curlisteners; |
@@ -465,15 +541,25 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
465 | m_curlisteners = 0; | 541 | m_curlisteners = 0; |
466 | } | 542 | } |
467 | 543 | ||
468 | public int AddListener(uint localID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg) | 544 | public int AddListener(uint localID, UUID itemID, UUID hostID, |
545 | int channel, string name, UUID id, string msg) | ||
546 | { | ||
547 | return AddListener(localID, itemID, hostID, channel, name, id, | ||
548 | msg, 0); | ||
549 | } | ||
550 | |||
551 | public int AddListener(uint localID, UUID itemID, UUID hostID, | ||
552 | int channel, string name, UUID id, string msg, | ||
553 | int regexBitfield) | ||
469 | { | 554 | { |
470 | // do we already have a match on this particular filter event? | 555 | // do we already have a match on this particular filter event? |
471 | List<ListenerInfo> coll = GetListeners(itemID, channel, name, id, msg); | 556 | List<ListenerInfo> coll = GetListeners(itemID, channel, name, id, |
557 | msg); | ||
472 | 558 | ||
473 | if (coll.Count > 0) | 559 | if (coll.Count > 0) |
474 | { | 560 | { |
475 | // special case, called with same filter settings, return same handle | 561 | // special case, called with same filter settings, return same |
476 | // (2008-05-02, tested on 1.21.1 server, still holds) | 562 | // handle (2008-05-02, tested on 1.21.1 server, still holds) |
477 | return coll[0].GetHandle(); | 563 | return coll[0].GetHandle(); |
478 | } | 564 | } |
479 | 565 | ||
@@ -485,16 +571,19 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
485 | 571 | ||
486 | if (newHandle > 0) | 572 | if (newHandle > 0) |
487 | { | 573 | { |
488 | ListenerInfo li = new ListenerInfo(newHandle, localID, itemID, hostID, channel, name, id, msg); | 574 | ListenerInfo li = new ListenerInfo(newHandle, localID, |
575 | itemID, hostID, channel, name, id, msg, | ||
576 | regexBitfield); | ||
489 | 577 | ||
490 | List<ListenerInfo> listeners; | 578 | List<ListenerInfo> listeners; |
491 | if (!m_listeners.TryGetValue(channel,out listeners)) | 579 | if (!m_listeners.TryGetValue( |
492 | { | 580 | channel, out listeners)) |
493 | listeners = new List<ListenerInfo>(); | 581 | { |
494 | m_listeners.Add(channel, listeners); | 582 | listeners = new List<ListenerInfo>(); |
495 | } | 583 | m_listeners.Add(channel, listeners); |
496 | listeners.Add(li); | 584 | } |
497 | m_curlisteners++; | 585 | listeners.Add(li); |
586 | m_curlisteners++; | ||
498 | 587 | ||
499 | return newHandle; | 588 | return newHandle; |
500 | } | 589 | } |
@@ -507,11 +596,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
507 | { | 596 | { |
508 | lock (m_listeners) | 597 | lock (m_listeners) |
509 | { | 598 | { |
510 | foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) | 599 | foreach (KeyValuePair<int, List<ListenerInfo>> lis |
600 | in m_listeners) | ||
511 | { | 601 | { |
512 | foreach (ListenerInfo li in lis.Value) | 602 | foreach (ListenerInfo li in lis.Value) |
513 | { | 603 | { |
514 | if (li.GetItemID().Equals(itemID) && li.GetHandle().Equals(handle)) | 604 | if (li.GetItemID().Equals(itemID) && |
605 | li.GetHandle().Equals(handle)) | ||
515 | { | 606 | { |
516 | lis.Value.Remove(li); | 607 | lis.Value.Remove(li); |
517 | if (lis.Value.Count == 0) | 608 | if (lis.Value.Count == 0) |
@@ -534,13 +625,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
534 | 625 | ||
535 | lock (m_listeners) | 626 | lock (m_listeners) |
536 | { | 627 | { |
537 | foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) | 628 | foreach (KeyValuePair<int, List<ListenerInfo>> lis |
629 | in m_listeners) | ||
538 | { | 630 | { |
539 | foreach (ListenerInfo li in lis.Value) | 631 | foreach (ListenerInfo li in lis.Value) |
540 | { | 632 | { |
541 | if (li.GetItemID().Equals(itemID)) | 633 | if (li.GetItemID().Equals(itemID)) |
542 | { | 634 | { |
543 | // store them first, else the enumerated bails on us | 635 | // store them first, else the enumerated bails on |
636 | // us | ||
544 | removedListeners.Add(li); | 637 | removedListeners.Add(li); |
545 | } | 638 | } |
546 | } | 639 | } |
@@ -567,11 +660,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
567 | { | 660 | { |
568 | lock (m_listeners) | 661 | lock (m_listeners) |
569 | { | 662 | { |
570 | foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) | 663 | foreach (KeyValuePair<int, List<ListenerInfo>> lis |
664 | in m_listeners) | ||
571 | { | 665 | { |
572 | foreach (ListenerInfo li in lis.Value) | 666 | foreach (ListenerInfo li in lis.Value) |
573 | { | 667 | { |
574 | if (li.GetItemID().Equals(itemID) && li.GetHandle() == handle) | 668 | if (li.GetItemID().Equals(itemID) && |
669 | li.GetHandle() == handle) | ||
575 | { | 670 | { |
576 | li.Activate(); | 671 | li.Activate(); |
577 | // only one, bail out | 672 | // only one, bail out |
@@ -586,11 +681,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
586 | { | 681 | { |
587 | lock (m_listeners) | 682 | lock (m_listeners) |
588 | { | 683 | { |
589 | foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) | 684 | foreach (KeyValuePair<int, List<ListenerInfo>> lis |
685 | in m_listeners) | ||
590 | { | 686 | { |
591 | foreach (ListenerInfo li in lis.Value) | 687 | foreach (ListenerInfo li in lis.Value) |
592 | { | 688 | { |
593 | if (li.GetItemID().Equals(itemID) && li.GetHandle() == handle) | 689 | if (li.GetItemID().Equals(itemID) && |
690 | li.GetHandle() == handle) | ||
594 | { | 691 | { |
595 | li.Deactivate(); | 692 | li.Deactivate(); |
596 | // only one, bail out | 693 | // only one, bail out |
@@ -601,19 +698,24 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
601 | } | 698 | } |
602 | } | 699 | } |
603 | 700 | ||
604 | // non-locked access, since its always called in the context of the lock | 701 | /// <summary> |
702 | /// non-locked access, since its always called in the context of the | ||
703 | /// lock | ||
704 | /// </summary> | ||
705 | /// <param name="itemID"></param> | ||
706 | /// <returns></returns> | ||
605 | private int GetNewHandle(UUID itemID) | 707 | private int GetNewHandle(UUID itemID) |
606 | { | 708 | { |
607 | List<int> handles = new List<int>(); | 709 | List<int> handles = new List<int>(); |
608 | 710 | ||
609 | // build a list of used keys for this specific itemID... | 711 | // build a list of used keys for this specific itemID... |
610 | foreach (KeyValuePair<int,List<ListenerInfo>> lis in m_listeners) | 712 | foreach (KeyValuePair<int, List<ListenerInfo>> lis in m_listeners) |
611 | { | 713 | { |
612 | foreach (ListenerInfo li in lis.Value) | 714 | foreach (ListenerInfo li in lis.Value) |
613 | { | 715 | { |
614 | if (li.GetItemID().Equals(itemID)) | 716 | if (li.GetItemID().Equals(itemID)) |
615 | handles.Add(li.GetHandle()); | 717 | handles.Add(li.GetHandle()); |
616 | } | 718 | } |
617 | } | 719 | } |
618 | 720 | ||
619 | // Note: 0 is NOT a valid handle for llListen() to return | 721 | // Note: 0 is NOT a valid handle for llListen() to return |
@@ -626,17 +728,46 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
626 | return -1; | 728 | return -1; |
627 | } | 729 | } |
628 | 730 | ||
629 | // Theres probably a more clever and efficient way to | 731 | /// These are duplicated from ScriptBaseClass |
630 | // do this, maybe with regex. | 732 | /// http://opensimulator.org/mantis/view.php?id=6106#c21945 |
631 | // PM2008: Ha, one could even be smart and define a specialized Enumerator. | 733 | #region Constants for the bitfield parameter of osListenRegex |
632 | public List<ListenerInfo> GetListeners(UUID itemID, int channel, string name, UUID id, string msg) | 734 | |
735 | /// <summary> | ||
736 | /// process name parameter as regex | ||
737 | /// </summary> | ||
738 | public const int OS_LISTEN_REGEX_NAME = 0x1; | ||
739 | |||
740 | /// <summary> | ||
741 | /// process message parameter as regex | ||
742 | /// </summary> | ||
743 | public const int OS_LISTEN_REGEX_MESSAGE = 0x2; | ||
744 | |||
745 | #endregion | ||
746 | |||
747 | /// <summary> | ||
748 | /// Get listeners matching the input parameters. | ||
749 | /// </summary> | ||
750 | /// <remarks> | ||
751 | /// Theres probably a more clever and efficient way to do this, maybe | ||
752 | /// with regex. | ||
753 | /// PM2008: Ha, one could even be smart and define a specialized | ||
754 | /// Enumerator. | ||
755 | /// </remarks> | ||
756 | /// <param name="itemID"></param> | ||
757 | /// <param name="channel"></param> | ||
758 | /// <param name="name"></param> | ||
759 | /// <param name="id"></param> | ||
760 | /// <param name="msg"></param> | ||
761 | /// <returns></returns> | ||
762 | public List<ListenerInfo> GetListeners(UUID itemID, int channel, | ||
763 | string name, UUID id, string msg) | ||
633 | { | 764 | { |
634 | List<ListenerInfo> collection = new List<ListenerInfo>(); | 765 | List<ListenerInfo> collection = new List<ListenerInfo>(); |
635 | 766 | ||
636 | lock (m_listeners) | 767 | lock (m_listeners) |
637 | { | 768 | { |
638 | List<ListenerInfo> listeners; | 769 | List<ListenerInfo> listeners; |
639 | if (!m_listeners.TryGetValue(channel,out listeners)) | 770 | if (!m_listeners.TryGetValue(channel, out listeners)) |
640 | { | 771 | { |
641 | return collection; | 772 | return collection; |
642 | } | 773 | } |
@@ -647,11 +778,15 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
647 | { | 778 | { |
648 | continue; | 779 | continue; |
649 | } | 780 | } |
650 | if (!itemID.Equals(UUID.Zero) && !li.GetItemID().Equals(itemID)) | 781 | if (!itemID.Equals(UUID.Zero) && |
782 | !li.GetItemID().Equals(itemID)) | ||
651 | { | 783 | { |
652 | continue; | 784 | continue; |
653 | } | 785 | } |
654 | if (li.GetName().Length > 0 && !li.GetName().Equals(name)) | 786 | if (li.GetName().Length > 0 && ( |
787 | ((li.RegexBitfield & OS_LISTEN_REGEX_NAME) != OS_LISTEN_REGEX_NAME && !li.GetName().Equals(name)) || | ||
788 | ((li.RegexBitfield & OS_LISTEN_REGEX_NAME) == OS_LISTEN_REGEX_NAME && !Regex.IsMatch(name, li.GetName())) | ||
789 | )) | ||
655 | { | 790 | { |
656 | continue; | 791 | continue; |
657 | } | 792 | } |
@@ -659,7 +794,10 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
659 | { | 794 | { |
660 | continue; | 795 | continue; |
661 | } | 796 | } |
662 | if (li.GetMessage().Length > 0 && !li.GetMessage().Equals(msg)) | 797 | if (li.GetMessage().Length > 0 && ( |
798 | ((li.RegexBitfield & OS_LISTEN_REGEX_MESSAGE) != OS_LISTEN_REGEX_MESSAGE && !li.GetMessage().Equals(msg)) || | ||
799 | ((li.RegexBitfield & OS_LISTEN_REGEX_MESSAGE) == OS_LISTEN_REGEX_MESSAGE && !Regex.IsMatch(msg, li.GetMessage())) | ||
800 | )) | ||
663 | { | 801 | { |
664 | continue; | 802 | continue; |
665 | } | 803 | } |
@@ -692,10 +830,13 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
692 | { | 830 | { |
693 | int idx = 0; | 831 | int idx = 0; |
694 | Object[] item = new Object[6]; | 832 | Object[] item = new Object[6]; |
833 | int dataItemLength = 6; | ||
695 | 834 | ||
696 | while (idx < data.Length) | 835 | while (idx < data.Length) |
697 | { | 836 | { |
698 | Array.Copy(data, idx, item, 0, 6); | 837 | dataItemLength = (idx + 7 == data.Length || (idx + 7 < data.Length && data[idx + 7] is bool)) ? 7 : 6; |
838 | item = new Object[dataItemLength]; | ||
839 | Array.Copy(data, idx, item, 0, dataItemLength); | ||
699 | 840 | ||
700 | ListenerInfo info = | 841 | ListenerInfo info = |
701 | ListenerInfo.FromData(localID, itemID, hostID, item); | 842 | ListenerInfo.FromData(localID, itemID, hostID, item); |
@@ -703,39 +844,98 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
703 | lock (m_listeners) | 844 | lock (m_listeners) |
704 | { | 845 | { |
705 | if (!m_listeners.ContainsKey((int)item[2])) | 846 | if (!m_listeners.ContainsKey((int)item[2])) |
706 | m_listeners.Add((int)item[2], new List<ListenerInfo>()); | 847 | { |
848 | m_listeners.Add((int)item[2], | ||
849 | new List<ListenerInfo>()); | ||
850 | } | ||
707 | m_listeners[(int)item[2]].Add(info); | 851 | m_listeners[(int)item[2]].Add(info); |
708 | } | 852 | } |
709 | 853 | ||
710 | idx+=6; | 854 | idx += dataItemLength; |
711 | } | 855 | } |
712 | } | 856 | } |
713 | } | 857 | } |
714 | 858 | ||
715 | public class ListenerInfo: IWorldCommListenerInfo | 859 | public class ListenerInfo : IWorldCommListenerInfo |
716 | { | 860 | { |
717 | private bool m_active; // Listener is active or not | 861 | /// <summary> |
718 | private int m_handle; // Assigned handle of this listener | 862 | /// Listener is active or not |
719 | private uint m_localID; // Local ID from script engine | 863 | /// </summary> |
720 | private UUID m_itemID; // ID of the host script engine | 864 | private bool m_active; |
721 | private UUID m_hostID; // ID of the host/scene part | ||
722 | private int m_channel; // Channel | ||
723 | private UUID m_id; // ID to filter messages from | ||
724 | private string m_name; // Object name to filter messages from | ||
725 | private string m_message; // The message | ||
726 | 865 | ||
727 | public ListenerInfo(int handle, uint localID, UUID ItemID, UUID hostID, int channel, string name, UUID id, string message) | 866 | /// <summary> |
867 | /// Assigned handle of this listener | ||
868 | /// </summary> | ||
869 | private int m_handle; | ||
870 | |||
871 | /// <summary> | ||
872 | /// Local ID from script engine | ||
873 | /// </summary> | ||
874 | private uint m_localID; | ||
875 | |||
876 | /// <summary> | ||
877 | /// ID of the host script engine | ||
878 | /// </summary> | ||
879 | private UUID m_itemID; | ||
880 | |||
881 | /// <summary> | ||
882 | /// ID of the host/scene part | ||
883 | /// </summary> | ||
884 | private UUID m_hostID; | ||
885 | |||
886 | /// <summary> | ||
887 | /// Channel | ||
888 | /// </summary> | ||
889 | private int m_channel; | ||
890 | |||
891 | /// <summary> | ||
892 | /// ID to filter messages from | ||
893 | /// </summary> | ||
894 | private UUID m_id; | ||
895 | |||
896 | /// <summary> | ||
897 | /// Object name to filter messages from | ||
898 | /// </summary> | ||
899 | private string m_name; | ||
900 | |||
901 | /// <summary> | ||
902 | /// The message | ||
903 | /// </summary> | ||
904 | private string m_message; | ||
905 | |||
906 | public ListenerInfo(int handle, uint localID, UUID ItemID, | ||
907 | UUID hostID, int channel, string name, UUID id, | ||
908 | string message) | ||
909 | { | ||
910 | Initialise(handle, localID, ItemID, hostID, channel, name, id, | ||
911 | message, 0); | ||
912 | } | ||
913 | |||
914 | public ListenerInfo(int handle, uint localID, UUID ItemID, | ||
915 | UUID hostID, int channel, string name, UUID id, | ||
916 | string message, int regexBitfield) | ||
728 | { | 917 | { |
729 | Initialise(handle, localID, ItemID, hostID, channel, name, id, message); | 918 | Initialise(handle, localID, ItemID, hostID, channel, name, id, |
919 | message, regexBitfield); | ||
730 | } | 920 | } |
731 | 921 | ||
732 | public ListenerInfo(ListenerInfo li, string name, UUID id, string message) | 922 | public ListenerInfo(ListenerInfo li, string name, UUID id, |
923 | string message) | ||
733 | { | 924 | { |
734 | Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, li.m_channel, name, id, message); | 925 | Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, |
926 | li.m_channel, name, id, message, 0); | ||
735 | } | 927 | } |
736 | 928 | ||
737 | private void Initialise(int handle, uint localID, UUID ItemID, UUID hostID, int channel, string name, | 929 | public ListenerInfo(ListenerInfo li, string name, UUID id, |
738 | UUID id, string message) | 930 | string message, int regexBitfield) |
931 | { | ||
932 | Initialise(li.m_handle, li.m_localID, li.m_itemID, li.m_hostID, | ||
933 | li.m_channel, name, id, message, regexBitfield); | ||
934 | } | ||
935 | |||
936 | private void Initialise(int handle, uint localID, UUID ItemID, | ||
937 | UUID hostID, int channel, string name, UUID id, | ||
938 | string message, int regexBitfield) | ||
739 | { | 939 | { |
740 | m_active = true; | 940 | m_active = true; |
741 | m_handle = handle; | 941 | m_handle = handle; |
@@ -746,11 +946,12 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
746 | m_name = name; | 946 | m_name = name; |
747 | m_id = id; | 947 | m_id = id; |
748 | m_message = message; | 948 | m_message = message; |
949 | RegexBitfield = regexBitfield; | ||
749 | } | 950 | } |
750 | 951 | ||
751 | public Object[] GetSerializationData() | 952 | public Object[] GetSerializationData() |
752 | { | 953 | { |
753 | Object[] data = new Object[6]; | 954 | Object[] data = new Object[7]; |
754 | 955 | ||
755 | data[0] = m_active; | 956 | data[0] = m_active; |
756 | data[1] = m_handle; | 957 | data[1] = m_handle; |
@@ -758,16 +959,22 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
758 | data[3] = m_name; | 959 | data[3] = m_name; |
759 | data[4] = m_id; | 960 | data[4] = m_id; |
760 | data[5] = m_message; | 961 | data[5] = m_message; |
962 | data[6] = RegexBitfield; | ||
761 | 963 | ||
762 | return data; | 964 | return data; |
763 | } | 965 | } |
764 | 966 | ||
765 | public static ListenerInfo FromData(uint localID, UUID ItemID, UUID hostID, Object[] data) | 967 | public static ListenerInfo FromData(uint localID, UUID ItemID, |
968 | UUID hostID, Object[] data) | ||
766 | { | 969 | { |
767 | ListenerInfo linfo = new ListenerInfo((int)data[1], localID, | 970 | ListenerInfo linfo = new ListenerInfo((int)data[1], localID, |
768 | ItemID, hostID, (int)data[2], (string)data[3], | 971 | ItemID, hostID, (int)data[2], (string)data[3], |
769 | (UUID)data[4], (string)data[5]); | 972 | (UUID)data[4], (string)data[5]); |
770 | linfo.m_active=(bool)data[0]; | 973 | linfo.m_active = (bool)data[0]; |
974 | if (data.Length >= 7) | ||
975 | { | ||
976 | linfo.RegexBitfield = (int)data[6]; | ||
977 | } | ||
771 | 978 | ||
772 | return linfo; | 979 | return linfo; |
773 | } | 980 | } |
@@ -826,5 +1033,7 @@ namespace OpenSim.Region.CoreModules.Scripting.WorldComm | |||
826 | { | 1033 | { |
827 | return m_id; | 1034 | return m_id; |
828 | } | 1035 | } |
1036 | |||
1037 | public int RegexBitfield { get; private set; } | ||
829 | } | 1038 | } |
830 | } | 1039 | } |
diff --git a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs index 0003af2..385f5ad 100644 --- a/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/XMLRPC/XMLRPCModule.cs | |||
@@ -40,6 +40,7 @@ using OpenSim.Framework.Servers; | |||
40 | using OpenSim.Framework.Servers.HttpServer; | 40 | using OpenSim.Framework.Servers.HttpServer; |
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 | using Mono.Addins; | ||
43 | 44 | ||
44 | /***************************************************** | 45 | /***************************************************** |
45 | * | 46 | * |
@@ -76,7 +77,8 @@ using OpenSim.Region.Framework.Scenes; | |||
76 | 77 | ||
77 | namespace OpenSim.Region.CoreModules.Scripting.XMLRPC | 78 | namespace OpenSim.Region.CoreModules.Scripting.XMLRPC |
78 | { | 79 | { |
79 | public class XMLRPCModule : IRegionModule, IXMLRPC | 80 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XMLRPCModule")] |
81 | public class XMLRPCModule : ISharedRegionModule, IXMLRPC | ||
80 | { | 82 | { |
81 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 83 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
82 | 84 | ||
@@ -86,6 +88,10 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC | |||
86 | private Dictionary<UUID, RPCChannelInfo> m_openChannels; | 88 | private Dictionary<UUID, RPCChannelInfo> m_openChannels; |
87 | private Dictionary<UUID, SendRemoteDataRequest> m_pendingSRDResponses; | 89 | private Dictionary<UUID, SendRemoteDataRequest> m_pendingSRDResponses; |
88 | private int m_remoteDataPort = 0; | 90 | private int m_remoteDataPort = 0; |
91 | public int Port | ||
92 | { | ||
93 | get { return m_remoteDataPort; } | ||
94 | } | ||
89 | 95 | ||
90 | private Dictionary<UUID, RPCRequestInfo> m_rpcPending; | 96 | private Dictionary<UUID, RPCRequestInfo> m_rpcPending; |
91 | private Dictionary<UUID, RPCRequestInfo> m_rpcPendingResponses; | 97 | private Dictionary<UUID, RPCRequestInfo> m_rpcPendingResponses; |
@@ -94,34 +100,24 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC | |||
94 | private int RemoteReplyScriptWait = 300; | 100 | private int RemoteReplyScriptWait = 300; |
95 | private object XMLRPCListLock = new object(); | 101 | private object XMLRPCListLock = new object(); |
96 | 102 | ||
97 | #region IRegionModule Members | 103 | #region ISharedRegionModule Members |
98 | 104 | ||
99 | public void Initialise(Scene scene, IConfigSource config) | 105 | public void Initialise(IConfigSource config) |
100 | { | 106 | { |
101 | // We need to create these early because the scripts might be calling | 107 | // We need to create these early because the scripts might be calling |
102 | // But since this gets called for every region, we need to make sure they | 108 | // But since this gets called for every region, we need to make sure they |
103 | // get called only one time (or we lose any open channels) | 109 | // get called only one time (or we lose any open channels) |
104 | if (null == m_openChannels) | 110 | m_openChannels = new Dictionary<UUID, RPCChannelInfo>(); |
105 | { | 111 | m_rpcPending = new Dictionary<UUID, RPCRequestInfo>(); |
106 | m_openChannels = new Dictionary<UUID, RPCChannelInfo>(); | 112 | m_rpcPendingResponses = new Dictionary<UUID, RPCRequestInfo>(); |
107 | m_rpcPending = new Dictionary<UUID, RPCRequestInfo>(); | 113 | m_pendingSRDResponses = new Dictionary<UUID, SendRemoteDataRequest>(); |
108 | m_rpcPendingResponses = new Dictionary<UUID, RPCRequestInfo>(); | ||
109 | m_pendingSRDResponses = new Dictionary<UUID, SendRemoteDataRequest>(); | ||
110 | 114 | ||
111 | try | 115 | try |
112 | { | 116 | { |
113 | m_remoteDataPort = config.Configs["XMLRPC"].GetInt("XmlRpcPort", m_remoteDataPort); | 117 | m_remoteDataPort = config.Configs["XMLRPC"].GetInt("XmlRpcPort", m_remoteDataPort); |
114 | } | ||
115 | catch (Exception) | ||
116 | { | ||
117 | } | ||
118 | } | 118 | } |
119 | 119 | catch (Exception) | |
120 | if (!m_scenes.Contains(scene)) | ||
121 | { | 120 | { |
122 | m_scenes.Add(scene); | ||
123 | |||
124 | scene.RegisterModuleInterface<IXMLRPC>(this); | ||
125 | } | 121 | } |
126 | } | 122 | } |
127 | 123 | ||
@@ -131,32 +127,56 @@ namespace OpenSim.Region.CoreModules.Scripting.XMLRPC | |||
131 | { | 127 | { |
132 | // Start http server | 128 | // Start http server |
133 | // Attach xmlrpc handlers | 129 | // Attach xmlrpc handlers |
134 | // m_log.InfoFormat( | 130 | // m_log.InfoFormat( |
135 | // "[XML RPC MODULE]: Starting up XMLRPC Server on port {0} for llRemoteData commands.", | 131 | // "[XML RPC MODULE]: Starting up XMLRPC Server on port {0} for llRemoteData commands.", |
136 | // m_remoteDataPort); | 132 | // m_remoteDataPort); |
137 | 133 | ||
138 | IHttpServer httpServer = MainServer.GetHttpServer((uint)m_remoteDataPort); | 134 | IHttpServer httpServer = MainServer.GetHttpServer((uint)m_remoteDataPort); |
139 | httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); | 135 | httpServer.AddXmlRPCHandler("llRemoteData", XmlRpcRemoteData); |
140 | } | 136 | } |
141 | } | 137 | } |
142 | 138 | ||
143 | public void Close() | 139 | public void AddRegion(Scene scene) |
140 | { | ||
141 | if (!IsEnabled()) | ||
142 | return; | ||
143 | |||
144 | if (!m_scenes.Contains(scene)) | ||
145 | { | ||
146 | m_scenes.Add(scene); | ||
147 | |||
148 | scene.RegisterModuleInterface<IXMLRPC>(this); | ||
149 | } | ||
150 | } | ||
151 | |||
152 | public void RegionLoaded(Scene scene) | ||
144 | { | 153 | { |
145 | } | 154 | } |
146 | 155 | ||
147 | public string Name | 156 | public void RemoveRegion(Scene scene) |
148 | { | 157 | { |
149 | get { return m_name; } | 158 | if (!IsEnabled()) |
159 | return; | ||
160 | |||
161 | if (m_scenes.Contains(scene)) | ||
162 | { | ||
163 | scene.UnregisterModuleInterface<IXMLRPC>(this); | ||
164 | m_scenes.Remove(scene); | ||
165 | } | ||
150 | } | 166 | } |
151 | 167 | ||
152 | public bool IsSharedModule | 168 | public void Close() |
153 | { | 169 | { |
154 | get { return true; } | ||
155 | } | 170 | } |
156 | 171 | ||
157 | public int Port | 172 | public string Name |
158 | { | 173 | { |
159 | get { return m_remoteDataPort; } | 174 | get { return m_name; } |
175 | } | ||
176 | |||
177 | public Type ReplaceableInterface | ||
178 | { | ||
179 | get { return null; } | ||
160 | } | 180 | } |
161 | 181 | ||
162 | #endregion | 182 | #endregion |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs index 5541684..7b4668a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Asset/AssetServiceInConnectorModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
@@ -39,6 +40,7 @@ using OpenSim.Server.Handlers.Base; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset | 41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset |
41 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AssetServiceInConnectorModule")] | ||
42 | public class AssetServiceInConnectorModule : ISharedRegionModule | 44 | public class AssetServiceInConnectorModule : ISharedRegionModule |
43 | { | 45 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -47,7 +49,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Asset | |||
47 | private IConfigSource m_Config; | 49 | private IConfigSource m_Config; |
48 | bool m_Registered = false; | 50 | bool m_Registered = false; |
49 | 51 | ||
50 | #region IRegionModule interface | 52 | #region Region Module interface |
51 | 53 | ||
52 | public void Initialise(IConfigSource config) | 54 | public void Initialise(IConfigSource config) |
53 | { | 55 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs index ccf2275..2cdffe6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Authentication/AuthenticationServiceInConnectorModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
@@ -41,6 +42,7 @@ using OpenSim.Services.Interfaces; | |||
41 | 42 | ||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Authentication | 43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Authentication |
43 | { | 44 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AuthenticationServiceInConnectorModule")] | ||
44 | public class AuthenticationServiceInConnectorModule : ISharedRegionModule | 46 | public class AuthenticationServiceInConnectorModule : ISharedRegionModule |
45 | { | 47 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -49,7 +51,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Authentication | |||
49 | private IConfigSource m_Config; | 51 | private IConfigSource m_Config; |
50 | bool m_Registered = false; | 52 | bool m_Registered = false; |
51 | 53 | ||
52 | #region IRegionModule interface | 54 | #region Region Module interface |
53 | 55 | ||
54 | public void Initialise(IConfigSource config) | 56 | public void Initialise(IConfigSource config) |
55 | { | 57 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs index 0e16e5a..22857d0 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/GridInfoServiceInConnectorModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
@@ -41,6 +42,7 @@ using OpenSim.Services.Interfaces; | |||
41 | 42 | ||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid | 43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid |
43 | { | 44 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GridInfoServiceInConnectorModule")] | ||
44 | public class GridInfoServiceInConnectorModule : ISharedRegionModule | 46 | public class GridInfoServiceInConnectorModule : ISharedRegionModule |
45 | { | 47 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -49,7 +51,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid | |||
49 | private IConfigSource m_Config; | 51 | private IConfigSource m_Config; |
50 | bool m_Registered = false; | 52 | bool m_Registered = false; |
51 | 53 | ||
52 | #region IRegionModule interface | 54 | #region Region Module interface |
53 | 55 | ||
54 | public void Initialise(IConfigSource config) | 56 | public void Initialise(IConfigSource config) |
55 | { | 57 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs index a7dd0dd..f749295 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Hypergrid/HypergridServiceInConnectorModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
@@ -42,6 +43,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
42 | 43 | ||
43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid | 44 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid |
44 | { | 45 | { |
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HypergridServiceInConnectorModule")] | ||
45 | public class HypergridServiceInConnectorModule : ISharedRegionModule | 47 | public class HypergridServiceInConnectorModule : ISharedRegionModule |
46 | { | 48 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -53,7 +55,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Hypergrid | |||
53 | private GatekeeperServiceInConnector m_HypergridHandler; | 55 | private GatekeeperServiceInConnector m_HypergridHandler; |
54 | private UserAgentServerConnector m_UASHandler; | 56 | private UserAgentServerConnector m_UASHandler; |
55 | 57 | ||
56 | #region IRegionModule interface | 58 | #region Region Module interface |
57 | 59 | ||
58 | public void Initialise(IConfigSource config) | 60 | public void Initialise(IConfigSource config) |
59 | { | 61 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs index 831ea27..0a4e736 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Inventory/InventoryServiceInConnectorModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
@@ -39,6 +40,7 @@ using OpenSim.Server.Handlers.Base; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory | 41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory |
41 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "InventoryServiceInConnectorModule")] | ||
42 | public class InventoryServiceInConnectorModule : ISharedRegionModule | 44 | public class InventoryServiceInConnectorModule : ISharedRegionModule |
43 | { | 45 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -47,7 +49,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Inventory | |||
47 | private IConfigSource m_Config; | 49 | private IConfigSource m_Config; |
48 | bool m_Registered = false; | 50 | bool m_Registered = false; |
49 | 51 | ||
50 | #region IRegionModule interface | 52 | #region Region Module interface |
51 | 53 | ||
52 | public void Initialise(IConfigSource config) | 54 | public void Initialise(IConfigSource config) |
53 | { | 55 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs index 2f3c350..2fd21be 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Land/LandServiceInConnectorModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
@@ -42,6 +43,7 @@ using OpenMetaverse; | |||
42 | 43 | ||
43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Land | 44 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Land |
44 | { | 45 | { |
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LandServiceInConnectorModule")] | ||
45 | public class LandServiceInConnectorModule : ISharedRegionModule, ILandService | 47 | public class LandServiceInConnectorModule : ISharedRegionModule, ILandService |
46 | { | 48 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -51,7 +53,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Land | |||
51 | private IConfigSource m_Config; | 53 | private IConfigSource m_Config; |
52 | private List<Scene> m_Scenes = new List<Scene>(); | 54 | private List<Scene> m_Scenes = new List<Scene>(); |
53 | 55 | ||
54 | #region IRegionModule interface | 56 | #region Region Module interface |
55 | 57 | ||
56 | public void Initialise(IConfigSource config) | 58 | public void Initialise(IConfigSource config) |
57 | { | 59 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs index ecdb380..425febd 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Login/LLLoginServiceInConnectorModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
@@ -42,6 +43,7 @@ using OpenSim.Services.Interfaces; | |||
42 | 43 | ||
43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Login | 44 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Login |
44 | { | 45 | { |
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LLLoginServiceInConnectorModule")] | ||
45 | public class LLLoginServiceInConnectorModule : ISharedRegionModule | 47 | public class LLLoginServiceInConnectorModule : ISharedRegionModule |
46 | { | 48 | { |
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -51,7 +53,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Login | |||
51 | private IConfigSource m_Config; | 53 | private IConfigSource m_Config; |
52 | private List<Scene> m_Scenes = new List<Scene>(); | 54 | private List<Scene> m_Scenes = new List<Scene>(); |
53 | 55 | ||
54 | #region IRegionModule interface | 56 | #region Region Module interface |
55 | 57 | ||
56 | public void Initialise(IConfigSource config) | 58 | public void Initialise(IConfigSource config) |
57 | { | 59 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs index d38af23..c14bce7 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/MapImage/MapImageServiceInConnectorModule.cs | |||
@@ -42,7 +42,7 @@ using OpenSim.Services.Interfaces; | |||
42 | 42 | ||
43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.MapImage | 43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.MapImage |
44 | { | 44 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapImageServiceInConnectorModule")] |
46 | public class MapImageServiceInConnectorModule : ISharedRegionModule | 46 | public class MapImageServiceInConnectorModule : ISharedRegionModule |
47 | { | 47 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -50,7 +50,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.MapImage | |||
50 | 50 | ||
51 | private IConfigSource m_Config; | 51 | private IConfigSource m_Config; |
52 | 52 | ||
53 | #region IRegionModule interface | 53 | #region Region Module interface |
54 | 54 | ||
55 | public void Initialise(IConfigSource config) | 55 | public void Initialise(IConfigSource config) |
56 | { | 56 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs index b544ab3..6bf47cb 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Neighbour/NeighbourServiceInConnectorModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
@@ -41,6 +42,7 @@ using OpenSim.Services.Interfaces; | |||
41 | 42 | ||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour | 43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour |
43 | { | 44 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "NeighbourServiceInConnectorModule")] | ||
44 | public class NeighbourServiceInConnectorModule : ISharedRegionModule, INeighbourService | 46 | public class NeighbourServiceInConnectorModule : ISharedRegionModule, INeighbourService |
45 | { | 47 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -50,7 +52,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Neighbour | |||
50 | private IConfigSource m_Config; | 52 | private IConfigSource m_Config; |
51 | private List<Scene> m_Scenes = new List<Scene>(); | 53 | private List<Scene> m_Scenes = new List<Scene>(); |
52 | 54 | ||
53 | #region IRegionModule interface | 55 | #region Region Module interface |
54 | 56 | ||
55 | public void Initialise(IConfigSource config) | 57 | public void Initialise(IConfigSource config) |
56 | { | 58 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs index 0a5275d..57d1132 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Simulation/SimulationServiceInConnectorModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Servers; | 35 | using OpenSim.Framework.Servers; |
@@ -40,7 +41,7 @@ using OpenSim.Server.Handlers.Base; | |||
40 | 41 | ||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation | 42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation |
42 | { | 43 | { |
43 | // Under construction | 44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimulationServiceInConnectorModule")] |
44 | public class SimulationServiceInConnectorModule : ISharedRegionModule | 45 | public class SimulationServiceInConnectorModule : ISharedRegionModule |
45 | { | 46 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -49,7 +50,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Simulation | |||
49 | private IConfigSource m_Config; | 50 | private IConfigSource m_Config; |
50 | bool m_Registered = false; | 51 | bool m_Registered = false; |
51 | 52 | ||
52 | #region IRegionModule interface | 53 | #region Region Module interface |
53 | 54 | ||
54 | public void Initialise(IConfigSource config) | 55 | public void Initialise(IConfigSource config) |
55 | { | 56 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs index 1e1c7d0..d221d68 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using log4net; | 28 | using log4net; |
29 | using Mono.Addins; | ||
29 | using Nini.Config; | 30 | using Nini.Config; |
30 | using System; | 31 | using System; |
31 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
@@ -40,8 +41,8 @@ using OpenMetaverse; | |||
40 | 41 | ||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | 42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset |
42 | { | 43 | { |
43 | public class HGAssetBroker : | 44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGAssetBroker")] |
44 | ISharedRegionModule, IAssetService | 45 | public class HGAssetBroker : ISharedRegionModule, IAssetService |
45 | { | 46 | { |
46 | private static readonly ILog m_log = | 47 | private static readonly ILog m_log = |
47 | LogManager.GetLogger( | 48 | LogManager.GetLogger( |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs index 449c1f1..480cd69 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using log4net; | 28 | using log4net; |
29 | using Mono.Addins; | ||
29 | using Nini.Config; | 30 | using Nini.Config; |
30 | using System; | 31 | using System; |
31 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
@@ -38,6 +39,7 @@ using OpenSim.Services.Interfaces; | |||
38 | 39 | ||
39 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | 40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset |
40 | { | 41 | { |
42 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalAssetServicesConnector")] | ||
41 | public class LocalAssetServicesConnector : ISharedRegionModule, IAssetService | 43 | public class LocalAssetServicesConnector : ISharedRegionModule, IAssetService |
42 | { | 44 | { |
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RemoteAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RemoteAssetServiceConnector.cs index 8a22cfc..e6eeacf 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RemoteAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RemoteAssetServiceConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using log4net; | 28 | using log4net; |
29 | using Mono.Addins; | ||
29 | using System; | 30 | using System; |
30 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -38,6 +39,7 @@ using OpenSim.Services.Interfaces; | |||
38 | 39 | ||
39 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset | 40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset |
40 | { | 41 | { |
42 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteAssetServicesConnector")] | ||
41 | public class RemoteAssetServicesConnector : | 43 | public class RemoteAssetServicesConnector : |
42 | AssetServicesConnector, ISharedRegionModule, IAssetService | 44 | AssetServicesConnector, ISharedRegionModule, IAssetService |
43 | { | 45 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs index 9484a5a..16f42a7 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/LocalAuthenticationServiceConnector.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
34 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
@@ -39,6 +40,7 @@ using OpenMetaverse; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication | 41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication |
41 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalAuthenticationServicesConnector")] | ||
42 | public class LocalAuthenticationServicesConnector : ISharedRegionModule, IAuthenticationService | 44 | public class LocalAuthenticationServicesConnector : ISharedRegionModule, IAuthenticationService |
43 | { | 45 | { |
44 | private static readonly ILog m_log = | 46 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs index a053bc2..7cb8b22 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authentication/RemoteAuthenticationServiceConnector.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using Nini.Config; | 29 | using Nini.Config; |
30 | using log4net; | 30 | using log4net; |
31 | using Mono.Addins; | ||
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using OpenSim.Region.Framework.Interfaces; | 33 | using OpenSim.Region.Framework.Interfaces; |
33 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
@@ -36,6 +37,7 @@ using OpenSim.Services.Connectors; | |||
36 | 37 | ||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication | 38 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authentication |
38 | { | 39 | { |
40 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteAuthenticationServicesConnector")] | ||
39 | public class RemoteAuthenticationServicesConnector : AuthenticationServicesConnector, | 41 | public class RemoteAuthenticationServicesConnector : AuthenticationServicesConnector, |
40 | ISharedRegionModule, IAuthenticationService | 42 | ISharedRegionModule, IAuthenticationService |
41 | { | 43 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs index 267fb9e..1acb695 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/LocalAuthorizationServiceConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using log4net; | 28 | using log4net; |
29 | using Mono.Addins; | ||
29 | using Nini.Config; | 30 | using Nini.Config; |
30 | using System; | 31 | using System; |
31 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
@@ -39,6 +40,7 @@ using OpenMetaverse; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | 41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization |
41 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalAuthorizationServicesConnector")] | ||
42 | public class LocalAuthorizationServicesConnector : INonSharedRegionModule, IAuthorizationService | 44 | public class LocalAuthorizationServicesConnector : INonSharedRegionModule, IAuthorizationService |
43 | { | 45 | { |
44 | private static readonly ILog m_log = | 46 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs index 86c0099..b8d409d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Authorization/RemoteAuthorizationServiceConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using log4net; | 28 | using log4net; |
29 | using Mono.Addins; | ||
29 | using System; | 30 | using System; |
30 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -39,6 +40,7 @@ using OpenMetaverse; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization | 41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization |
41 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteAuthorizationServicesConnector")] | ||
42 | public class RemoteAuthorizationServicesConnector : | 44 | public class RemoteAuthorizationServicesConnector : |
43 | AuthorizationServicesConnector, ISharedRegionModule, IAuthorizationService | 45 | AuthorizationServicesConnector, ISharedRegionModule, IAuthorizationService |
44 | { | 46 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs index 9ee19f8..c3ef588 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/LocalAvatarServiceConnector.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
@@ -40,6 +41,7 @@ using OpenMetaverse; | |||
40 | 41 | ||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar | 42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar |
42 | { | 43 | { |
44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalAvatarServicesConnector")] | ||
43 | public class LocalAvatarServicesConnector : ISharedRegionModule, IAvatarService | 45 | public class LocalAvatarServicesConnector : ISharedRegionModule, IAvatarService |
44 | { | 46 | { |
45 | private static readonly ILog m_log = | 47 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs index d665a54..a087aea 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Avatar/RemoteAvatarServiceConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using Mono.Addins; | ||
29 | using Nini.Config; | 30 | using Nini.Config; |
30 | using log4net; | 31 | using log4net; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -36,6 +37,7 @@ using OpenSim.Services.Connectors; | |||
36 | 37 | ||
37 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar | 38 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar |
38 | { | 39 | { |
40 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteAvatarServicesConnector")] | ||
39 | public class RemoteAvatarServicesConnector : AvatarServicesConnector, | 41 | public class RemoteAvatarServicesConnector : AvatarServicesConnector, |
40 | ISharedRegionModule, IAvatarService | 42 | ISharedRegionModule, IAvatarService |
41 | { | 43 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 3c6e381..c0c2ca7 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using log4net; | 28 | using log4net; |
29 | using Mono.Addins; | ||
29 | using Nini.Config; | 30 | using Nini.Config; |
30 | using System; | 31 | using System; |
31 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
@@ -41,6 +42,7 @@ using OpenMetaverse; | |||
41 | 42 | ||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | 43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid |
43 | { | 44 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalGridServicesConnector")] | ||
44 | public class LocalGridServicesConnector : ISharedRegionModule, IGridService | 46 | public class LocalGridServicesConnector : ISharedRegionModule, IGridService |
45 | { | 47 | { |
46 | private static readonly ILog m_log = | 48 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index e6c89d7..b2646ba 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using log4net; | 28 | using log4net; |
29 | using Mono.Addins; | ||
29 | using System; | 30 | using System; |
30 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -42,6 +43,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
42 | 43 | ||
43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid | 44 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid |
44 | { | 45 | { |
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteGridServicesConnector")] | ||
45 | public class RemoteGridServicesConnector : ISharedRegionModule, IGridService | 47 | public class RemoteGridServicesConnector : ISharedRegionModule, IGridService |
46 | { | 48 | { |
47 | private static readonly ILog m_log = | 49 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs index 90fe69e..5734334 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/LocalGridUserServiceConnector.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
34 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
@@ -39,6 +40,7 @@ using OpenMetaverse; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser | 41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser |
41 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalGridUserServicesConnector")] | ||
42 | public class LocalGridUserServicesConnector : ISharedRegionModule, IGridUserService | 44 | public class LocalGridUserServicesConnector : ISharedRegionModule, IGridUserService |
43 | { | 45 | { |
44 | private static readonly ILog m_log = | 46 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs index 04acf67..f7e6eb8 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/GridUser/RemoteGridUserServiceConnector.cs | |||
@@ -36,10 +36,12 @@ using OpenSim.Services.Connectors; | |||
36 | 36 | ||
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using log4net; | 38 | using log4net; |
39 | using Mono.Addins; | ||
39 | using Nini.Config; | 40 | using Nini.Config; |
40 | 41 | ||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser | 42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.GridUser |
42 | { | 43 | { |
44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteGridUserServicesConnector")] | ||
43 | public class RemoteGridUserServicesConnector : ISharedRegionModule, IGridUserService | 45 | public class RemoteGridUserServicesConnector : ISharedRegionModule, IGridUserService |
44 | { | 46 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs index cf6d2f7..e474ef6 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/HGInventoryBroker.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using log4net; | 28 | using log4net; |
29 | using Mono.Addins; | ||
29 | using Nini.Config; | 30 | using Nini.Config; |
30 | using System; | 31 | using System; |
31 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
@@ -42,6 +43,7 @@ using OpenMetaverse; | |||
42 | 43 | ||
43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | 44 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory |
44 | { | 45 | { |
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "HGInventoryBroker")] | ||
45 | public class HGInventoryBroker : ISharedRegionModule, IInventoryService | 47 | public class HGInventoryBroker : ISharedRegionModule, IInventoryService |
46 | { | 48 | { |
47 | private static readonly ILog m_log = | 49 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs index 097ff1a..ec5751d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/LocalInventoryServiceConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using log4net; | 28 | using log4net; |
29 | using Mono.Addins; | ||
29 | using Nini.Config; | 30 | using Nini.Config; |
30 | 31 | ||
31 | using System; | 32 | using System; |
@@ -41,6 +42,7 @@ using OpenMetaverse; | |||
41 | 42 | ||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | 43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory |
43 | { | 44 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalInventoryServicesConnector")] | ||
44 | public class LocalInventoryServicesConnector : ISharedRegionModule, IInventoryService | 46 | public class LocalInventoryServicesConnector : ISharedRegionModule, IInventoryService |
45 | { | 47 | { |
46 | private static readonly ILog m_log = | 48 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs index 11e0150..2d3ba82 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/RemoteXInventoryServiceConnector.cs | |||
@@ -29,6 +29,7 @@ using log4net; | |||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Monitoring; | 35 | using OpenSim.Framework.Monitoring; |
@@ -40,6 +41,7 @@ using OpenMetaverse; | |||
40 | 41 | ||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | 42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory |
42 | { | 43 | { |
44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteXInventoryServicesConnector")] | ||
43 | public class RemoteXInventoryServicesConnector : ISharedRegionModule, IInventoryService | 45 | public class RemoteXInventoryServicesConnector : ISharedRegionModule, IInventoryService |
44 | { | 46 | { |
45 | private static readonly ILog m_log = | 47 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/LocalLandServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/LocalLandServiceConnector.cs index 86c0b85..5329933 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/LocalLandServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/LocalLandServiceConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using log4net; | 28 | using log4net; |
29 | using Mono.Addins; | ||
29 | using Nini.Config; | 30 | using Nini.Config; |
30 | using System; | 31 | using System; |
31 | using System.Collections.Generic; | 32 | using System.Collections.Generic; |
@@ -39,8 +40,8 @@ using OpenMetaverse; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land | 41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land |
41 | { | 42 | { |
42 | public class LocalLandServicesConnector : | 43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalLandServicesConnector")] |
43 | ISharedRegionModule, ILandService | 44 | public class LocalLandServicesConnector : ISharedRegionModule, ILandService |
44 | { | 45 | { |
45 | private static readonly ILog m_log = | 46 | private static readonly ILog m_log = |
46 | LogManager.GetLogger( | 47 | LogManager.GetLogger( |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs index 766ef81..77dfa4a 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Land/RemoteLandServiceConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using log4net; | 28 | using log4net; |
29 | using Mono.Addins; | ||
29 | using System; | 30 | using System; |
30 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -41,6 +42,7 @@ using OpenMetaverse; | |||
41 | 42 | ||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land | 43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Land |
43 | { | 44 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteLandServicesConnector")] | ||
44 | public class RemoteLandServicesConnector : | 46 | public class RemoteLandServicesConnector : |
45 | LandServicesConnector, ISharedRegionModule, ILandService | 47 | LandServicesConnector, ISharedRegionModule, ILandService |
46 | { | 48 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index 9d282b8..a839086 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | |||
@@ -52,7 +52,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
52 | /// <remarks> | 52 | /// <remarks> |
53 | /// </remarks> | 53 | /// </remarks> |
54 | 54 | ||
55 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 55 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapImageServiceModule")] |
56 | public class MapImageServiceModule : ISharedRegionModule | 56 | public class MapImageServiceModule : ISharedRegionModule |
57 | { | 57 | { |
58 | private static readonly ILog m_log = | 58 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs index 7a90686..fd89428 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/LocalNeighbourServiceConnector.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
@@ -39,6 +40,7 @@ using OpenSim.Services.Interfaces; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour | 41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour |
41 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalNeighbourServicesConnector")] | ||
42 | public class LocalNeighbourServicesConnector : | 44 | public class LocalNeighbourServicesConnector : |
43 | ISharedRegionModule, INeighbourService | 45 | ISharedRegionModule, INeighbourService |
44 | { | 46 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs index c6fc2a1..e6772f3 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Neighbour/RemoteNeighourServiceConnector.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using log4net; | 28 | using log4net; |
29 | using Mono.Addins; | ||
29 | using System; | 30 | using System; |
30 | using System.Collections.Generic; | 31 | using System.Collections.Generic; |
31 | using System.Reflection; | 32 | using System.Reflection; |
@@ -39,6 +40,7 @@ using OpenSim.Server.Base; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour | 41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour |
41 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteNeighbourServicesConnector")] | ||
42 | public class RemoteNeighbourServicesConnector : | 44 | public class RemoteNeighbourServicesConnector : |
43 | NeighbourServicesConnector, ISharedRegionModule, INeighbourService | 45 | NeighbourServicesConnector, ISharedRegionModule, INeighbourService |
44 | { | 46 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/BasePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/BasePresenceServiceConnector.cs new file mode 100644 index 0000000..fdbe10a --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/BasePresenceServiceConnector.cs | |||
@@ -0,0 +1,137 @@ | |||
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.Reflection; | ||
31 | using log4net; | ||
32 | using Mono.Addins; | ||
33 | using Nini.Config; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | using OpenSim.Region.Framework.Scenes; | ||
37 | using OpenSim.Server.Base; | ||
38 | using OpenSim.Services.Interfaces; | ||
39 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | ||
40 | |||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | ||
42 | { | ||
43 | public class BasePresenceServiceConnector : IPresenceService | ||
44 | { | ||
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
46 | |||
47 | protected bool m_Enabled; | ||
48 | |||
49 | protected PresenceDetector m_PresenceDetector; | ||
50 | |||
51 | /// <summary> | ||
52 | /// Underlying presence service. Do not use directly. | ||
53 | /// </summary> | ||
54 | public IPresenceService m_PresenceService; | ||
55 | |||
56 | public Type ReplaceableInterface | ||
57 | { | ||
58 | get { return null; } | ||
59 | } | ||
60 | |||
61 | public void AddRegion(Scene scene) | ||
62 | { | ||
63 | if (!m_Enabled) | ||
64 | return; | ||
65 | |||
66 | // m_log.DebugFormat( | ||
67 | // "[LOCAL PRESENCE CONNECTOR]: Registering IPresenceService to scene {0}", scene.RegionInfo.RegionName); | ||
68 | |||
69 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
70 | m_PresenceDetector.AddRegion(scene); | ||
71 | |||
72 | m_log.InfoFormat("[BASE PRESENCE SERVICE CONNECTOR]: Enabled for region {0}", scene.Name); | ||
73 | } | ||
74 | |||
75 | public void RemoveRegion(Scene scene) | ||
76 | { | ||
77 | if (!m_Enabled) | ||
78 | return; | ||
79 | |||
80 | m_PresenceDetector.RemoveRegion(scene); | ||
81 | } | ||
82 | |||
83 | public void RegionLoaded(Scene scene) | ||
84 | { | ||
85 | if (!m_Enabled) | ||
86 | return; | ||
87 | |||
88 | } | ||
89 | |||
90 | public void PostInitialise() | ||
91 | { | ||
92 | } | ||
93 | |||
94 | public void Close() | ||
95 | { | ||
96 | } | ||
97 | |||
98 | #region IPresenceService | ||
99 | |||
100 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
101 | { | ||
102 | m_log.Warn("[BASE PRESENCE SERVICE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
103 | return false; | ||
104 | } | ||
105 | |||
106 | public bool LogoutAgent(UUID sessionID) | ||
107 | { | ||
108 | return m_PresenceService.LogoutAgent(sessionID); | ||
109 | } | ||
110 | |||
111 | public bool LogoutRegionAgents(UUID regionID) | ||
112 | { | ||
113 | return m_PresenceService.LogoutRegionAgents(regionID); | ||
114 | } | ||
115 | |||
116 | public bool ReportAgent(UUID sessionID, UUID regionID) | ||
117 | { | ||
118 | return m_PresenceService.ReportAgent(sessionID, regionID); | ||
119 | } | ||
120 | |||
121 | public PresenceInfo GetAgent(UUID sessionID) | ||
122 | { | ||
123 | return m_PresenceService.GetAgent(sessionID); | ||
124 | } | ||
125 | |||
126 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
127 | { | ||
128 | // Don't bother potentially making a useless network call if we not going to ask for any users anyway. | ||
129 | if (userIDs.Length == 0) | ||
130 | return new PresenceInfo[0]; | ||
131 | |||
132 | return m_PresenceService.GetAgents(userIDs); | ||
133 | } | ||
134 | |||
135 | #endregion | ||
136 | } | ||
137 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs index 49dd633..db5c520 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/LocalPresenceServiceConnector.cs | |||
@@ -24,51 +24,29 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | |||
27 | using System; | 28 | using System; |
28 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | 31 | using log4net; | |
32 | using Mono.Addins; | ||
33 | using Nini.Config; | ||
34 | using OpenMetaverse; | ||
31 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
32 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
33 | using OpenSim.Server.Base; | 37 | using OpenSim.Server.Base; |
34 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
35 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | 39 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; |
36 | 40 | ||
37 | using OpenMetaverse; | ||
38 | using log4net; | ||
39 | using Nini.Config; | ||
40 | |||
41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | 41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence |
42 | { | 42 | { |
43 | public class LocalPresenceServicesConnector : ISharedRegionModule, IPresenceService | 43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalPresenceServicesConnector")] |
44 | public class LocalPresenceServicesConnector : BasePresenceServiceConnector, ISharedRegionModule, IPresenceService | ||
44 | { | 45 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 47 | ||
47 | private bool m_Enabled = false; | ||
48 | |||
49 | private PresenceDetector m_PresenceDetector; | ||
50 | |||
51 | /// <summary> | ||
52 | /// Underlying presence service. Do not use directly. | ||
53 | /// </summary> | ||
54 | public IPresenceService m_PresenceService; | ||
55 | |||
56 | public LocalPresenceServicesConnector() | ||
57 | { | ||
58 | } | ||
59 | |||
60 | public LocalPresenceServicesConnector(IConfigSource source) | ||
61 | { | ||
62 | Initialise(source); | ||
63 | } | ||
64 | |||
65 | #region ISharedRegionModule | 48 | #region ISharedRegionModule |
66 | 49 | ||
67 | public Type ReplaceableInterface | ||
68 | { | ||
69 | get { return null; } | ||
70 | } | ||
71 | |||
72 | public string Name | 50 | public string Name |
73 | { | 51 | { |
74 | get { return "LocalPresenceServicesConnector"; } | 52 | get { return "LocalPresenceServicesConnector"; } |
@@ -119,81 +97,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | |||
119 | } | 97 | } |
120 | } | 98 | } |
121 | 99 | ||
122 | public void PostInitialise() | ||
123 | { | ||
124 | } | ||
125 | |||
126 | public void Close() | ||
127 | { | ||
128 | } | ||
129 | |||
130 | public void AddRegion(Scene scene) | ||
131 | { | ||
132 | if (!m_Enabled) | ||
133 | return; | ||
134 | |||
135 | // m_log.DebugFormat( | ||
136 | // "[LOCAL PRESENCE CONNECTOR]: Registering IPresenceService to scene {0}", scene.RegionInfo.RegionName); | ||
137 | |||
138 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
139 | m_PresenceDetector.AddRegion(scene); | ||
140 | |||
141 | m_log.InfoFormat("[LOCAL PRESENCE CONNECTOR]: Enabled local presence for region {0}", scene.RegionInfo.RegionName); | ||
142 | |||
143 | } | ||
144 | |||
145 | public void RemoveRegion(Scene scene) | ||
146 | { | ||
147 | if (!m_Enabled) | ||
148 | return; | ||
149 | |||
150 | m_PresenceDetector.RemoveRegion(scene); | ||
151 | } | ||
152 | |||
153 | public void RegionLoaded(Scene scene) | ||
154 | { | ||
155 | if (!m_Enabled) | ||
156 | return; | ||
157 | |||
158 | } | ||
159 | |||
160 | #endregion | ||
161 | |||
162 | #region IPresenceService | ||
163 | |||
164 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
165 | { | ||
166 | m_log.Warn("[LOCAL PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
167 | return false; | ||
168 | } | ||
169 | |||
170 | public bool LogoutAgent(UUID sessionID) | ||
171 | { | ||
172 | return m_PresenceService.LogoutAgent(sessionID); | ||
173 | } | ||
174 | |||
175 | |||
176 | public bool LogoutRegionAgents(UUID regionID) | ||
177 | { | ||
178 | return m_PresenceService.LogoutRegionAgents(regionID); | ||
179 | } | ||
180 | |||
181 | public bool ReportAgent(UUID sessionID, UUID regionID) | ||
182 | { | ||
183 | return m_PresenceService.ReportAgent(sessionID, regionID); | ||
184 | } | ||
185 | |||
186 | public PresenceInfo GetAgent(UUID sessionID) | ||
187 | { | ||
188 | return m_PresenceService.GetAgent(sessionID); | ||
189 | } | ||
190 | |||
191 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
192 | { | ||
193 | return m_PresenceService.GetAgents(userIDs); | ||
194 | } | ||
195 | |||
196 | #endregion | 100 | #endregion |
197 | |||
198 | } | 101 | } |
199 | } | 102 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs index bf4e9ab..6ca5c28 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/RemotePresenceServiceConnector.cs | |||
@@ -37,26 +37,18 @@ using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | |||
37 | 37 | ||
38 | using OpenMetaverse; | 38 | using OpenMetaverse; |
39 | using log4net; | 39 | using log4net; |
40 | using Mono.Addins; | ||
40 | using Nini.Config; | 41 | using Nini.Config; |
41 | 42 | ||
42 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | 43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence |
43 | { | 44 | { |
44 | public class RemotePresenceServicesConnector : ISharedRegionModule, IPresenceService | 45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemotePresenceServicesConnector")] |
46 | public class RemotePresenceServicesConnector : BasePresenceServiceConnector, ISharedRegionModule | ||
45 | { | 47 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | 49 | ||
48 | #region ISharedRegionModule | 50 | #region ISharedRegionModule |
49 | 51 | ||
50 | private bool m_Enabled = false; | ||
51 | |||
52 | private PresenceDetector m_PresenceDetector; | ||
53 | private IPresenceService m_RemoteConnector; | ||
54 | |||
55 | public Type ReplaceableInterface | ||
56 | { | ||
57 | get { return null; } | ||
58 | } | ||
59 | |||
60 | public string Name | 52 | public string Name |
61 | { | 53 | { |
62 | get { return "RemotePresenceServicesConnector"; } | 54 | get { return "RemotePresenceServicesConnector"; } |
@@ -70,7 +62,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | |||
70 | string name = moduleConfig.GetString("PresenceServices", ""); | 62 | string name = moduleConfig.GetString("PresenceServices", ""); |
71 | if (name == Name) | 63 | if (name == Name) |
72 | { | 64 | { |
73 | m_RemoteConnector = new PresenceServicesConnector(source); | 65 | m_PresenceService = new PresenceServicesConnector(source); |
74 | 66 | ||
75 | m_Enabled = true; | 67 | m_Enabled = true; |
76 | 68 | ||
@@ -79,81 +71,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence | |||
79 | m_log.Info("[REMOTE PRESENCE CONNECTOR]: Remote presence enabled"); | 71 | m_log.Info("[REMOTE PRESENCE CONNECTOR]: Remote presence enabled"); |
80 | } | 72 | } |
81 | } | 73 | } |
82 | |||
83 | } | ||
84 | |||
85 | public void PostInitialise() | ||
86 | { | ||
87 | } | ||
88 | |||
89 | public void Close() | ||
90 | { | ||
91 | } | ||
92 | |||
93 | public void AddRegion(Scene scene) | ||
94 | { | ||
95 | if (!m_Enabled) | ||
96 | return; | ||
97 | |||
98 | scene.RegisterModuleInterface<IPresenceService>(this); | ||
99 | m_PresenceDetector.AddRegion(scene); | ||
100 | |||
101 | m_log.InfoFormat("[REMOTE PRESENCE CONNECTOR]: Enabled remote presence for region {0}", scene.RegionInfo.RegionName); | ||
102 | |||
103 | } | ||
104 | |||
105 | public void RemoveRegion(Scene scene) | ||
106 | { | ||
107 | if (!m_Enabled) | ||
108 | return; | ||
109 | |||
110 | m_PresenceDetector.RemoveRegion(scene); | ||
111 | } | ||
112 | |||
113 | public void RegionLoaded(Scene scene) | ||
114 | { | ||
115 | if (!m_Enabled) | ||
116 | return; | ||
117 | |||
118 | } | ||
119 | |||
120 | #endregion | ||
121 | |||
122 | #region IPresenceService | ||
123 | |||
124 | public bool LoginAgent(string userID, UUID sessionID, UUID secureSessionID) | ||
125 | { | ||
126 | m_log.Warn("[REMOTE PRESENCE CONNECTOR]: LoginAgent connector not implemented at the simulators"); | ||
127 | return false; | ||
128 | } | ||
129 | |||
130 | public bool LogoutAgent(UUID sessionID) | ||
131 | { | ||
132 | return m_RemoteConnector.LogoutAgent(sessionID); | ||
133 | } | ||
134 | |||
135 | |||
136 | public bool LogoutRegionAgents(UUID regionID) | ||
137 | { | ||
138 | return m_RemoteConnector.LogoutRegionAgents(regionID); | ||
139 | } | ||
140 | |||
141 | public bool ReportAgent(UUID sessionID, UUID regionID) | ||
142 | { | ||
143 | return m_RemoteConnector.ReportAgent(sessionID, regionID); | ||
144 | } | ||
145 | |||
146 | public PresenceInfo GetAgent(UUID sessionID) | ||
147 | { | ||
148 | return m_RemoteConnector.GetAgent(sessionID); | ||
149 | } | ||
150 | |||
151 | public PresenceInfo[] GetAgents(string[] userIDs) | ||
152 | { | ||
153 | return m_RemoteConnector.GetAgents(userIDs); | ||
154 | } | 74 | } |
155 | 75 | ||
156 | #endregion | 76 | #endregion |
157 | |||
158 | } | 77 | } |
159 | } | 78 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs index 4556df3..7e365ca 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Presence/Tests/PresenceConnectorsTests.cs | |||
@@ -35,7 +35,6 @@ using NUnit.Framework; | |||
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using Nini.Config; | 37 | using Nini.Config; |
38 | |||
39 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; | 38 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence; |
40 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
41 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | 40 | using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; |
@@ -44,7 +43,7 @@ using OpenSim.Tests.Common; | |||
44 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests | 43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests |
45 | { | 44 | { |
46 | [TestFixture] | 45 | [TestFixture] |
47 | public class PresenceConnectorsTests | 46 | public class PresenceConnectorsTests : OpenSimTestCase |
48 | { | 47 | { |
49 | LocalPresenceServicesConnector m_LocalConnector; | 48 | LocalPresenceServicesConnector m_LocalConnector; |
50 | private void SetUp() | 49 | private void SetUp() |
@@ -56,7 +55,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Presence.Tests | |||
56 | config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); | 55 | config.Configs["PresenceService"].Set("LocalServiceModule", "OpenSim.Services.PresenceService.dll:PresenceService"); |
57 | config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); | 56 | config.Configs["PresenceService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); |
58 | 57 | ||
59 | m_LocalConnector = new LocalPresenceServicesConnector(config); | 58 | m_LocalConnector = new LocalPresenceServicesConnector(); |
59 | m_LocalConnector.Initialise(config); | ||
60 | 60 | ||
61 | // Let's stick in a test presence | 61 | // Let's stick in a test presence |
62 | m_LocalConnector.m_PresenceService.LoginAgent(UUID.Zero.ToString(), UUID.Zero, UUID.Zero); | 62 | m_LocalConnector.m_PresenceService.LoginAgent(UUID.Zero.ToString(), UUID.Zero, UUID.Zero); |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs index 1e52d37..3c18074 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/LocalSimulationConnector.cs | |||
@@ -29,6 +29,7 @@ using System.Collections.Generic; | |||
29 | using System.Linq; | 29 | using System.Linq; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
@@ -39,6 +40,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | 41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation |
41 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalSimulationConnectorModule")] | ||
42 | public class LocalSimulationConnectorModule : ISharedRegionModule, ISimulationService | 44 | public class LocalSimulationConnectorModule : ISharedRegionModule, ISimulationService |
43 | { | 45 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -58,7 +60,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
58 | /// </summary> | 60 | /// </summary> |
59 | private bool m_ModuleEnabled = false; | 61 | private bool m_ModuleEnabled = false; |
60 | 62 | ||
61 | #region IRegionModule | 63 | #region Region Module interface |
62 | 64 | ||
63 | public void Initialise(IConfigSource config) | 65 | public void Initialise(IConfigSource config) |
64 | { | 66 | { |
@@ -156,7 +158,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
156 | } | 158 | } |
157 | } | 159 | } |
158 | 160 | ||
159 | #endregion /* IRegionModule */ | 161 | #endregion |
160 | 162 | ||
161 | #region ISimulation | 163 | #region ISimulation |
162 | 164 | ||
@@ -374,4 +376,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
374 | 376 | ||
375 | #endregion | 377 | #endregion |
376 | } | 378 | } |
377 | } \ No newline at end of file | 379 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs index bd4a23b..b2a1b23 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Simulation/RemoteSimulationConnector.cs | |||
@@ -32,6 +32,7 @@ using System.Net; | |||
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.Text; | 33 | using System.Text; |
34 | using log4net; | 34 | using log4net; |
35 | using Mono.Addins; | ||
35 | using Nini.Config; | 36 | using Nini.Config; |
36 | using OpenMetaverse; | 37 | using OpenMetaverse; |
37 | using OpenMetaverse.StructuredData; | 38 | using OpenMetaverse.StructuredData; |
@@ -46,6 +47,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
46 | 47 | ||
47 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | 48 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation |
48 | { | 49 | { |
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteSimulationConnectorModule")] | ||
49 | public class RemoteSimulationConnectorModule : ISharedRegionModule, ISimulationService | 51 | public class RemoteSimulationConnectorModule : ISharedRegionModule, ISimulationService |
50 | { | 52 | { |
51 | private bool initialized = false; | 53 | private bool initialized = false; |
@@ -60,7 +62,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
60 | protected bool m_safemode; | 62 | protected bool m_safemode; |
61 | protected IPAddress m_thisIP; | 63 | protected IPAddress m_thisIP; |
62 | 64 | ||
63 | #region IRegionModule | 65 | #region Region Module interface |
64 | 66 | ||
65 | public virtual void Initialise(IConfigSource config) | 67 | public virtual void Initialise(IConfigSource config) |
66 | { | 68 | { |
@@ -147,7 +149,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
147 | m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); | 149 | m_thisIP = Util.GetHostFromDNS(scene.RegionInfo.ExternalHostName); |
148 | } | 150 | } |
149 | 151 | ||
150 | #endregion /* IRegionModule */ | 152 | #endregion |
151 | 153 | ||
152 | #region IInterregionComms | 154 | #region IInterregionComms |
153 | 155 | ||
@@ -302,4 +304,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation | |||
302 | 304 | ||
303 | #endregion /* IInterregionComms */ | 305 | #endregion /* IInterregionComms */ |
304 | } | 306 | } |
305 | } \ No newline at end of file | 307 | } |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs index 0a0ce3c..529bfd7 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/LocalUserAccountServiceConnector.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
34 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
@@ -39,6 +40,7 @@ using OpenMetaverse; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | 41 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts |
41 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LocalUserAccountServicesConnector")] | ||
42 | public class LocalUserAccountServicesConnector : ISharedRegionModule, IUserAccountService | 44 | public class LocalUserAccountServicesConnector : ISharedRegionModule, IUserAccountService |
43 | { | 45 | { |
44 | private static readonly ILog m_log = | 46 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs index 3321b38..5aa87d3 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/UserAccounts/RemoteUserAccountServiceConnector.cs | |||
@@ -28,6 +28,7 @@ | |||
28 | using System; | 28 | using System; |
29 | using Nini.Config; | 29 | using Nini.Config; |
30 | using log4net; | 30 | using log4net; |
31 | using Mono.Addins; | ||
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using OpenSim.Region.Framework.Interfaces; | 33 | using OpenSim.Region.Framework.Interfaces; |
33 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
@@ -38,6 +39,7 @@ using OpenMetaverse; | |||
38 | 39 | ||
39 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts | 40 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.UserAccounts |
40 | { | 41 | { |
42 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RemoteUserAccountServicesConnector")] | ||
41 | public class RemoteUserAccountServicesConnector : UserAccountServicesConnector, | 43 | public class RemoteUserAccountServicesConnector : UserAccountServicesConnector, |
42 | ISharedRegionModule, IUserAccountService | 44 | ISharedRegionModule, IUserAccountService |
43 | { | 45 | { |
diff --git a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs index e7b1454..1599f15 100644 --- a/OpenSim/Region/CoreModules/World/Access/AccessModule.cs +++ b/OpenSim/Region/CoreModules/World/Access/AccessModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
@@ -39,6 +40,7 @@ using OpenSim.Services.Interfaces; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.CoreModules.World | 41 | namespace OpenSim.Region.CoreModules.World |
41 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AccessModule")] | ||
42 | public class AccessModule : ISharedRegionModule | 44 | public class AccessModule : ISharedRegionModule |
43 | { | 45 | { |
44 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index ea806ec..c810242 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs | |||
@@ -552,13 +552,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
552 | 552 | ||
553 | // Validate User and Group UUID's | 553 | // Validate User and Group UUID's |
554 | 554 | ||
555 | if (!ResolveUserUuid(scene, parcel.OwnerID)) | 555 | if (parcel.IsGroupOwned) |
556 | parcel.OwnerID = m_rootScene.RegionInfo.EstateSettings.EstateOwner; | ||
557 | |||
558 | if (!ResolveGroupUuid(parcel.GroupID)) | ||
559 | { | 556 | { |
560 | parcel.GroupID = UUID.Zero; | 557 | if (!ResolveGroupUuid(parcel.GroupID)) |
561 | parcel.IsGroupOwned = false; | 558 | { |
559 | parcel.OwnerID = m_rootScene.RegionInfo.EstateSettings.EstateOwner; | ||
560 | parcel.GroupID = UUID.Zero; | ||
561 | parcel.IsGroupOwned = false; | ||
562 | } | ||
563 | } | ||
564 | else | ||
565 | { | ||
566 | if (!ResolveUserUuid(scene, parcel.OwnerID)) | ||
567 | parcel.OwnerID = m_rootScene.RegionInfo.EstateSettings.EstateOwner; | ||
568 | |||
569 | if (!ResolveGroupUuid(parcel.GroupID)) | ||
570 | parcel.GroupID = UUID.Zero; | ||
562 | } | 571 | } |
563 | 572 | ||
564 | List<LandAccessEntry> accessList = new List<LandAccessEntry>(); | 573 | List<LandAccessEntry> accessList = new List<LandAccessEntry>(); |
@@ -571,8 +580,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
571 | parcel.ParcelAccessList = accessList; | 580 | parcel.ParcelAccessList = accessList; |
572 | 581 | ||
573 | // m_log.DebugFormat( | 582 | // m_log.DebugFormat( |
574 | // "[ARCHIVER]: Adding parcel {0}, local id {1}, area {2}", | 583 | // "[ARCHIVER]: Adding parcel {0}, local id {1}, owner {2}, group {3}, isGroupOwned {4}, area {5}", |
575 | // parcel.Name, parcel.LocalID, parcel.Area); | 584 | // parcel.Name, parcel.LocalID, parcel.OwnerID, parcel.GroupID, parcel.IsGroupOwned, parcel.Area); |
576 | 585 | ||
577 | landData.Add(parcel); | 586 | landData.Add(parcel); |
578 | } | 587 | } |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs index a66ed88..d8dace2 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveScenesGroup.cs | |||
@@ -110,7 +110,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
110 | lastX = (lastX == null) ? curLastX : (lastX > curLastX) ? lastX : curLastX; | 110 | lastX = (lastX == null) ? curLastX : (lastX > curLastX) ? lastX : curLastX; |
111 | } | 111 | } |
112 | 112 | ||
113 | Rect = new Rectangle((int)firstX, (int)firstY, (int)(lastY - firstY + 1), (int)(lastX - firstX + 1)); | 113 | Rect = new Rectangle((int)firstX, (int)firstY, (int)(lastX - firstX + 1), (int)(lastY - firstY + 1)); |
114 | 114 | ||
115 | 115 | ||
116 | // Calculate the subdirectory in which each region will be stored in the archive | 116 | // Calculate the subdirectory in which each region will be stored in the archive |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index d751b1c..7bdd65c 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs | |||
@@ -167,7 +167,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
167 | } | 167 | } |
168 | scenesGroup.CalcSceneLocations(); | 168 | scenesGroup.CalcSceneLocations(); |
169 | 169 | ||
170 | |||
171 | m_archiveWriter = new TarArchiveWriter(m_saveStream); | 170 | m_archiveWriter = new TarArchiveWriter(m_saveStream); |
172 | 171 | ||
173 | try | 172 | try |
@@ -216,7 +215,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
216 | } | 215 | } |
217 | } | 216 | } |
218 | 217 | ||
219 | |||
220 | private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, AssetType> assetUuids) | 218 | private void ArchiveOneRegion(Scene scene, string regionDir, Dictionary<UUID, AssetType> assetUuids) |
221 | { | 219 | { |
222 | m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.RegionInfo.RegionName); | 220 | m_log.InfoFormat("[ARCHIVER]: Writing region {0}", scene.RegionInfo.RegionName); |
@@ -540,7 +538,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
540 | xtw.WriteElementString("size_in_meters", string.Format("{0},{1}", size.X, size.Y)); | 538 | xtw.WriteElementString("size_in_meters", string.Format("{0},{1}", size.X, size.Y)); |
541 | } | 539 | } |
542 | 540 | ||
543 | |||
544 | protected void Save(Scene scene, List<SceneObjectGroup> sceneObjects, string regionDir) | 541 | protected void Save(Scene scene, List<SceneObjectGroup> sceneObjects, string regionDir) |
545 | { | 542 | { |
546 | if (regionDir != string.Empty) | 543 | if (regionDir != string.Empty) |
@@ -560,8 +557,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
560 | foreach (ILandObject lo in landObjects) | 557 | foreach (ILandObject lo in landObjects) |
561 | { | 558 | { |
562 | LandData landData = lo.LandData; | 559 | LandData landData = lo.LandData; |
563 | string landDataPath = String.Format("{0}{1}{2}.xml", | 560 | string landDataPath |
564 | regionDir, ArchiveConstants.LANDDATA_PATH, landData.GlobalID.ToString()); | 561 | = String.Format("{0}{1}", regionDir, ArchiveConstants.CreateOarLandDataPath(landData)); |
565 | m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData, m_options)); | 562 | m_archiveWriter.WriteFile(landDataPath, LandDataSerializer.Serialize(landData, m_options)); |
566 | } | 563 | } |
567 | 564 | ||
@@ -604,7 +601,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
604 | 601 | ||
605 | CloseArchive(String.Empty); | 602 | CloseArchive(String.Empty); |
606 | } | 603 | } |
607 | |||
608 | 604 | ||
609 | /// <summary> | 605 | /// <summary> |
610 | /// Closes the archive and notifies that we're done. | 606 | /// Closes the archive and notifies that we're done. |
@@ -629,6 +625,5 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
629 | 625 | ||
630 | m_rootScene.EventManager.TriggerOarFileSaved(m_requestId, errorMessage); | 626 | m_rootScene.EventManager.TriggerOarFileSaved(m_requestId, errorMessage); |
631 | } | 627 | } |
632 | |||
633 | } | 628 | } |
634 | } | 629 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs index 2a87dc2..1be6386 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiverModule.cs | |||
@@ -32,6 +32,9 @@ using System.Reflection; | |||
32 | using log4net; | 32 | using log4net; |
33 | using NDesk.Options; | 33 | using NDesk.Options; |
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using Mono.Addins; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Framework.Console; | ||
35 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
37 | 40 | ||
@@ -40,6 +43,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
40 | /// <summary> | 43 | /// <summary> |
41 | /// This module loads and saves OpenSimulator region archives | 44 | /// This module loads and saves OpenSimulator region archives |
42 | /// </summary> | 45 | /// </summary> |
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ArchiverModule")] | ||
43 | public class ArchiverModule : INonSharedRegionModule, IRegionArchiverModule | 47 | public class ArchiverModule : INonSharedRegionModule, IRegionArchiverModule |
44 | { | 48 | { |
45 | private static readonly ILog m_log = | 49 | private static readonly ILog m_log = |
@@ -117,7 +121,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
117 | // | 121 | // |
118 | // foreach (string param in mainParams) | 122 | // foreach (string param in mainParams) |
119 | // m_log.DebugFormat("GOT PARAM [{0}]", param); | 123 | // m_log.DebugFormat("GOT PARAM [{0}]", param); |
120 | 124 | ||
121 | if (mainParams.Count > 2) | 125 | if (mainParams.Count > 2) |
122 | { | 126 | { |
123 | DearchiveRegion(mainParams[2], mergeOar, skipAssets, Guid.Empty); | 127 | DearchiveRegion(mainParams[2], mergeOar, skipAssets, Guid.Empty); |
@@ -150,14 +154,18 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
150 | 154 | ||
151 | List<string> mainParams = ops.Parse(cmdparams); | 155 | List<string> mainParams = ops.Parse(cmdparams); |
152 | 156 | ||
157 | string path; | ||
153 | if (mainParams.Count > 2) | 158 | if (mainParams.Count > 2) |
154 | { | 159 | path = mainParams[2]; |
155 | ArchiveRegion(mainParams[2], options); | ||
156 | } | ||
157 | else | 160 | else |
158 | { | 161 | path = DEFAULT_OAR_BACKUP_FILENAME; |
159 | ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, options); | 162 | |
160 | } | 163 | // Not doing this right now as this causes some problems with auto-backup systems. Maybe a force flag is |
164 | // needed | ||
165 | // if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, path)) | ||
166 | // return; | ||
167 | |||
168 | ArchiveRegion(path, options); | ||
161 | } | 169 | } |
162 | 170 | ||
163 | public void ArchiveRegion(string savePath, Dictionary<string, object> options) | 171 | public void ArchiveRegion(string savePath, Dictionary<string, object> options) |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs index 5787279..103eb47 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/AssetsRequest.cs | |||
@@ -129,6 +129,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
129 | m_options = options; | 129 | m_options = options; |
130 | m_repliesRequired = uuids.Count; | 130 | m_repliesRequired = uuids.Count; |
131 | 131 | ||
132 | // FIXME: This is a really poor way of handling the timeout since it will always leave the original requesting thread | ||
133 | // hanging. Need to restructure so an original request thread waits for a ManualResetEvent on asset received | ||
134 | // so we can properly abort that thread. Or request all assets synchronously, though that would be a more | ||
135 | // radical change | ||
132 | m_requestCallbackTimer = new System.Timers.Timer(TIMEOUT); | 136 | m_requestCallbackTimer = new System.Timers.Timer(TIMEOUT); |
133 | m_requestCallbackTimer.AutoReset = false; | 137 | m_requestCallbackTimer.AutoReset = false; |
134 | m_requestCallbackTimer.Elapsed += new ElapsedEventHandler(OnRequestCallbackTimeout); | 138 | m_requestCallbackTimer.Elapsed += new ElapsedEventHandler(OnRequestCallbackTimeout); |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 82f49b0..eec1cec 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | |||
@@ -31,16 +31,19 @@ using System.IO; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Threading; | 32 | using System.Threading; |
33 | using log4net.Config; | 33 | using log4net.Config; |
34 | using Nini.Config; | ||
34 | using NUnit.Framework; | 35 | using NUnit.Framework; |
35 | using OpenMetaverse; | 36 | using OpenMetaverse; |
36 | using OpenMetaverse.Assets; | 37 | using OpenMetaverse.Assets; |
37 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Serialization; | 39 | using OpenSim.Framework.Serialization; |
39 | using OpenSim.Framework.Serialization.External; | 40 | using OpenSim.Framework.Serialization.External; |
41 | using OpenSim.Region.CoreModules.World.Land; | ||
40 | using OpenSim.Region.CoreModules.World.Serialiser; | 42 | using OpenSim.Region.CoreModules.World.Serialiser; |
41 | using OpenSim.Region.CoreModules.World.Terrain; | 43 | using OpenSim.Region.CoreModules.World.Terrain; |
42 | using OpenSim.Region.Framework.Scenes; | 44 | using OpenSim.Region.Framework.Scenes; |
43 | using OpenSim.Region.Framework.Scenes.Serialization; | 45 | using OpenSim.Region.Framework.Scenes.Serialization; |
46 | using OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups; | ||
44 | using OpenSim.Tests.Common; | 47 | using OpenSim.Tests.Common; |
45 | using OpenSim.Tests.Common.Mock; | 48 | using OpenSim.Tests.Common.Mock; |
46 | using ArchiveConstants = OpenSim.Framework.Serialization.ArchiveConstants; | 49 | using ArchiveConstants = OpenSim.Framework.Serialization.ArchiveConstants; |
@@ -69,9 +72,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
69 | { | 72 | { |
70 | base.SetUp(); | 73 | base.SetUp(); |
71 | 74 | ||
72 | // FIXME: Do something about this - relying on statics in unit tests causes trouble sooner or later | ||
73 | new SceneManager(); | ||
74 | |||
75 | m_archiverModule = new ArchiverModule(); | 75 | m_archiverModule = new ArchiverModule(); |
76 | m_serialiserModule = new SerialiserModule(); | 76 | m_serialiserModule = new SerialiserModule(); |
77 | TerrainModule terrainModule = new TerrainModule(); | 77 | TerrainModule terrainModule = new TerrainModule(); |
@@ -127,6 +127,53 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
127 | 127 | ||
128 | return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; | 128 | return new SceneObjectPart(ownerId, shape, groupPosition, rotationOffset, offsetPosition) { Name = partName }; |
129 | } | 129 | } |
130 | |||
131 | private void CreateTestObjects(Scene scene, out SceneObjectGroup sog1, out SceneObjectGroup sog2, out UUID ncAssetUuid) | ||
132 | { | ||
133 | SceneObjectPart part1 = CreateSceneObjectPart1(); | ||
134 | sog1 = new SceneObjectGroup(part1); | ||
135 | scene.AddNewSceneObject(sog1, false); | ||
136 | |||
137 | AssetNotecard nc = new AssetNotecard(); | ||
138 | nc.BodyText = "Hello World!"; | ||
139 | nc.Encode(); | ||
140 | ncAssetUuid = UUID.Random(); | ||
141 | UUID ncItemUuid = UUID.Random(); | ||
142 | AssetBase ncAsset | ||
143 | = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); | ||
144 | m_scene.AssetService.Store(ncAsset); | ||
145 | |||
146 | TaskInventoryItem ncItem | ||
147 | = new TaskInventoryItem { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid }; | ||
148 | SceneObjectPart part2 = CreateSceneObjectPart2(); | ||
149 | sog2 = new SceneObjectGroup(part2); | ||
150 | part2.Inventory.AddInventoryItem(ncItem, true); | ||
151 | |||
152 | scene.AddNewSceneObject(sog2, false); | ||
153 | } | ||
154 | |||
155 | private static void CreateSoundAsset(TarArchiveWriter tar, Assembly assembly, string soundDataResourceName, out byte[] soundData, out UUID soundUuid) | ||
156 | { | ||
157 | using (Stream resource = assembly.GetManifestResourceStream(soundDataResourceName)) | ||
158 | { | ||
159 | using (BinaryReader br = new BinaryReader(resource)) | ||
160 | { | ||
161 | // FIXME: Use the inspector instead | ||
162 | soundData = br.ReadBytes(99999999); | ||
163 | soundUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); | ||
164 | string soundAssetFileName | ||
165 | = ArchiveConstants.ASSETS_PATH + soundUuid | ||
166 | + ArchiveConstants.ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV]; | ||
167 | tar.WriteFile(soundAssetFileName, soundData); | ||
168 | |||
169 | /* | ||
170 | AssetBase soundAsset = AssetHelpers.CreateAsset(soundUuid, soundData); | ||
171 | scene.AssetService.Store(soundAsset); | ||
172 | asset1FileName = ArchiveConstants.ASSETS_PATH + soundUuid + ".wav"; | ||
173 | */ | ||
174 | } | ||
175 | } | ||
176 | } | ||
130 | 177 | ||
131 | /// <summary> | 178 | /// <summary> |
132 | /// Test saving an OpenSim Region Archive. | 179 | /// Test saving an OpenSim Region Archive. |
@@ -204,30 +251,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
204 | // TODO: Test presence of more files and contents of files. | 251 | // TODO: Test presence of more files and contents of files. |
205 | } | 252 | } |
206 | 253 | ||
207 | private void CreateTestObjects(Scene scene, out SceneObjectGroup sog1, out SceneObjectGroup sog2, out UUID ncAssetUuid) | ||
208 | { | ||
209 | SceneObjectPart part1 = CreateSceneObjectPart1(); | ||
210 | sog1 = new SceneObjectGroup(part1); | ||
211 | scene.AddNewSceneObject(sog1, false); | ||
212 | |||
213 | AssetNotecard nc = new AssetNotecard(); | ||
214 | nc.BodyText = "Hello World!"; | ||
215 | nc.Encode(); | ||
216 | ncAssetUuid = UUID.Random(); | ||
217 | UUID ncItemUuid = UUID.Random(); | ||
218 | AssetBase ncAsset | ||
219 | = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero); | ||
220 | m_scene.AssetService.Store(ncAsset); | ||
221 | |||
222 | TaskInventoryItem ncItem | ||
223 | = new TaskInventoryItem { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid }; | ||
224 | SceneObjectPart part2 = CreateSceneObjectPart2(); | ||
225 | sog2 = new SceneObjectGroup(part2); | ||
226 | part2.Inventory.AddInventoryItem(ncItem, true); | ||
227 | |||
228 | scene.AddNewSceneObject(sog2, false); | ||
229 | } | ||
230 | |||
231 | /// <summary> | 254 | /// <summary> |
232 | /// Test saving an OpenSim Region Archive with the no assets option | 255 | /// Test saving an OpenSim Region Archive with the no assets option |
233 | /// </summary> | 256 | /// </summary> |
@@ -309,59 +332,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
309 | } | 332 | } |
310 | 333 | ||
311 | /// <summary> | 334 | /// <summary> |
312 | /// Test loading an OpenSim Region Archive where the scene object parts are not ordered by link number (e.g. | ||
313 | /// 2 can come after 3). | ||
314 | /// </summary> | ||
315 | [Test] | ||
316 | public void TestLoadOarUnorderedParts() | ||
317 | { | ||
318 | TestHelpers.InMethod(); | ||
319 | |||
320 | UUID ownerId = TestHelpers.ParseTail(0xaaaa); | ||
321 | |||
322 | MemoryStream archiveWriteStream = new MemoryStream(); | ||
323 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); | ||
324 | |||
325 | tar.WriteFile( | ||
326 | ArchiveConstants.CONTROL_FILE_PATH, | ||
327 | new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup())); | ||
328 | |||
329 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ownerId, "obj1-", 0x11); | ||
330 | SceneObjectPart sop2 | ||
331 | = SceneHelpers.CreateSceneObjectPart("obj1-Part2", TestHelpers.ParseTail(0x12), ownerId); | ||
332 | SceneObjectPart sop3 | ||
333 | = SceneHelpers.CreateSceneObjectPart("obj1-Part3", TestHelpers.ParseTail(0x13), ownerId); | ||
334 | |||
335 | // Add the parts so they will be written out in reverse order to the oar | ||
336 | sog1.AddPart(sop3); | ||
337 | sop3.LinkNum = 3; | ||
338 | sog1.AddPart(sop2); | ||
339 | sop2.LinkNum = 2; | ||
340 | |||
341 | tar.WriteFile( | ||
342 | ArchiveConstants.CreateOarObjectPath(sog1.Name, sog1.UUID, sog1.AbsolutePosition), | ||
343 | SceneObjectSerializer.ToXml2Format(sog1)); | ||
344 | |||
345 | tar.Close(); | ||
346 | |||
347 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
348 | |||
349 | lock (this) | ||
350 | { | ||
351 | m_scene.EventManager.OnOarFileLoaded += LoadCompleted; | ||
352 | m_archiverModule.DearchiveRegion(archiveReadStream); | ||
353 | } | ||
354 | |||
355 | Assert.That(m_lastErrorMessage, Is.Null); | ||
356 | |||
357 | SceneObjectPart part2 = m_scene.GetSceneObjectPart("obj1-Part2"); | ||
358 | Assert.That(part2.LinkNum, Is.EqualTo(2)); | ||
359 | |||
360 | SceneObjectPart part3 = m_scene.GetSceneObjectPart("obj1-Part3"); | ||
361 | Assert.That(part3.LinkNum, Is.EqualTo(3)); | ||
362 | } | ||
363 | |||
364 | /// <summary> | ||
365 | /// Test loading an OpenSim Region Archive. | 335 | /// Test loading an OpenSim Region Archive. |
366 | /// </summary> | 336 | /// </summary> |
367 | [Test] | 337 | [Test] |
@@ -435,50 +405,57 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
435 | TestLoadedRegion(part1, soundItemName, soundData); | 405 | TestLoadedRegion(part1, soundItemName, soundData); |
436 | } | 406 | } |
437 | 407 | ||
438 | private static void CreateSoundAsset(TarArchiveWriter tar, Assembly assembly, string soundDataResourceName, out byte[] soundData, out UUID soundUuid) | 408 | /// <summary> |
409 | /// Test loading an OpenSim Region Archive where the scene object parts are not ordered by link number (e.g. | ||
410 | /// 2 can come after 3). | ||
411 | /// </summary> | ||
412 | [Test] | ||
413 | public void TestLoadOarUnorderedParts() | ||
439 | { | 414 | { |
440 | using (Stream resource = assembly.GetManifestResourceStream(soundDataResourceName)) | 415 | TestHelpers.InMethod(); |
441 | { | ||
442 | using (BinaryReader br = new BinaryReader(resource)) | ||
443 | { | ||
444 | // FIXME: Use the inspector instead | ||
445 | soundData = br.ReadBytes(99999999); | ||
446 | soundUuid = UUID.Parse("00000000-0000-0000-0000-000000000001"); | ||
447 | string soundAssetFileName | ||
448 | = ArchiveConstants.ASSETS_PATH + soundUuid | ||
449 | + ArchiveConstants.ASSET_TYPE_TO_EXTENSION[(sbyte)AssetType.SoundWAV]; | ||
450 | tar.WriteFile(soundAssetFileName, soundData); | ||
451 | 416 | ||
452 | /* | 417 | UUID ownerId = TestHelpers.ParseTail(0xaaaa); |
453 | AssetBase soundAsset = AssetHelpers.CreateAsset(soundUuid, soundData); | ||
454 | scene.AssetService.Store(soundAsset); | ||
455 | asset1FileName = ArchiveConstants.ASSETS_PATH + soundUuid + ".wav"; | ||
456 | */ | ||
457 | } | ||
458 | } | ||
459 | } | ||
460 | 418 | ||
461 | private void TestLoadedRegion(SceneObjectPart part1, string soundItemName, byte[] soundData) | 419 | MemoryStream archiveWriteStream = new MemoryStream(); |
462 | { | 420 | TarArchiveWriter tar = new TarArchiveWriter(archiveWriteStream); |
463 | SceneObjectPart object1PartLoaded = m_scene.GetSceneObjectPart(part1.Name); | ||
464 | 421 | ||
465 | Assert.That(object1PartLoaded, Is.Not.Null, "object1 was not loaded"); | 422 | tar.WriteFile( |
466 | Assert.That(object1PartLoaded.Name, Is.EqualTo(part1.Name), "object1 names not identical"); | 423 | ArchiveConstants.CONTROL_FILE_PATH, |
467 | Assert.That(object1PartLoaded.GroupPosition, Is.EqualTo(part1.GroupPosition), "object1 group position not equal"); | 424 | new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup())); |
468 | Assert.That( | ||
469 | object1PartLoaded.RotationOffset, Is.EqualTo(part1.RotationOffset), "object1 rotation offset not equal"); | ||
470 | Assert.That( | ||
471 | object1PartLoaded.OffsetPosition, Is.EqualTo(part1.OffsetPosition), "object1 offset position not equal"); | ||
472 | Assert.That(object1PartLoaded.SitTargetOrientation, Is.EqualTo(part1.SitTargetOrientation)); | ||
473 | Assert.That(object1PartLoaded.SitTargetPosition, Is.EqualTo(part1.SitTargetPosition)); | ||
474 | 425 | ||
475 | TaskInventoryItem loadedSoundItem = object1PartLoaded.Inventory.GetInventoryItems(soundItemName)[0]; | 426 | SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ownerId, "obj1-", 0x11); |
476 | Assert.That(loadedSoundItem, Is.Not.Null, "loaded sound item was null"); | 427 | SceneObjectPart sop2 |
477 | AssetBase loadedSoundAsset = m_scene.AssetService.Get(loadedSoundItem.AssetID.ToString()); | 428 | = SceneHelpers.CreateSceneObjectPart("obj1-Part2", TestHelpers.ParseTail(0x12), ownerId); |
478 | Assert.That(loadedSoundAsset, Is.Not.Null, "loaded sound asset was null"); | 429 | SceneObjectPart sop3 |
479 | Assert.That(loadedSoundAsset.Data, Is.EqualTo(soundData), "saved and loaded sound data do not match"); | 430 | = SceneHelpers.CreateSceneObjectPart("obj1-Part3", TestHelpers.ParseTail(0x13), ownerId); |
480 | 431 | ||
481 | Assert.Greater(m_scene.LandChannel.AllParcels().Count, 0, "incorrect number of parcels"); | 432 | // Add the parts so they will be written out in reverse order to the oar |
433 | sog1.AddPart(sop3); | ||
434 | sop3.LinkNum = 3; | ||
435 | sog1.AddPart(sop2); | ||
436 | sop2.LinkNum = 2; | ||
437 | |||
438 | tar.WriteFile( | ||
439 | ArchiveConstants.CreateOarObjectPath(sog1.Name, sog1.UUID, sog1.AbsolutePosition), | ||
440 | SceneObjectSerializer.ToXml2Format(sog1)); | ||
441 | |||
442 | tar.Close(); | ||
443 | |||
444 | MemoryStream archiveReadStream = new MemoryStream(archiveWriteStream.ToArray()); | ||
445 | |||
446 | lock (this) | ||
447 | { | ||
448 | m_scene.EventManager.OnOarFileLoaded += LoadCompleted; | ||
449 | m_archiverModule.DearchiveRegion(archiveReadStream); | ||
450 | } | ||
451 | |||
452 | Assert.That(m_lastErrorMessage, Is.Null); | ||
453 | |||
454 | SceneObjectPart part2 = m_scene.GetSceneObjectPart("obj1-Part2"); | ||
455 | Assert.That(part2.LinkNum, Is.EqualTo(2)); | ||
456 | |||
457 | SceneObjectPart part3 = m_scene.GetSceneObjectPart("obj1-Part3"); | ||
458 | Assert.That(part3.LinkNum, Is.EqualTo(3)); | ||
482 | } | 459 | } |
483 | 460 | ||
484 | /// <summary> | 461 | /// <summary> |
@@ -538,8 +515,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
538 | SerialiserModule serialiserModule = new SerialiserModule(); | 515 | SerialiserModule serialiserModule = new SerialiserModule(); |
539 | TerrainModule terrainModule = new TerrainModule(); | 516 | TerrainModule terrainModule = new TerrainModule(); |
540 | 517 | ||
541 | m_sceneHelpers = new SceneHelpers(); | 518 | SceneHelpers m_sceneHelpers2 = new SceneHelpers(); |
542 | TestScene scene2 = m_sceneHelpers.SetupScene(); | 519 | TestScene scene2 = m_sceneHelpers2.SetupScene(); |
543 | SceneHelpers.SetupSceneModules(scene2, archiverModule, serialiserModule, terrainModule); | 520 | SceneHelpers.SetupSceneModules(scene2, archiverModule, serialiserModule, terrainModule); |
544 | 521 | ||
545 | // Make sure there's a valid owner for the owner we saved (this should have been wiped if the code is | 522 | // Make sure there's a valid owner for the owner we saved (this should have been wiped if the code is |
@@ -563,6 +540,71 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
563 | } | 540 | } |
564 | 541 | ||
565 | /// <summary> | 542 | /// <summary> |
543 | /// Test OAR loading where the land parcel is group deeded. | ||
544 | /// </summary> | ||
545 | /// <remarks> | ||
546 | /// In this situation, the owner ID is set to the group ID. | ||
547 | /// </remarks> | ||
548 | [Test] | ||
549 | public void TestLoadOarDeededLand() | ||
550 | { | ||
551 | TestHelpers.InMethod(); | ||
552 | // TestHelpers.EnableLogging(); | ||
553 | |||
554 | UUID landID = TestHelpers.ParseTail(0x10); | ||
555 | |||
556 | MockGroupsServicesConnector groupsService = new MockGroupsServicesConnector(); | ||
557 | |||
558 | IConfigSource configSource = new IniConfigSource(); | ||
559 | IConfig config = configSource.AddConfig("Groups"); | ||
560 | config.Set("Enabled", true); | ||
561 | config.Set("Module", "GroupsModule"); | ||
562 | config.Set("DebugEnabled", true); | ||
563 | SceneHelpers.SetupSceneModules( | ||
564 | m_scene, configSource, new object[] { new GroupsModule(), groupsService, new LandManagementModule() }); | ||
565 | |||
566 | // Create group in scene for loading | ||
567 | // FIXME: For now we'll put up with the issue that we'll get a group ID that varies across tests. | ||
568 | UUID groupID | ||
569 | = groupsService.CreateGroup(UUID.Zero, "group1", "", true, UUID.Zero, 3, true, true, true, UUID.Zero); | ||
570 | |||
571 | // Construct OAR | ||
572 | MemoryStream oarStream = new MemoryStream(); | ||
573 | TarArchiveWriter tar = new TarArchiveWriter(oarStream); | ||
574 | |||
575 | tar.WriteDir(ArchiveConstants.LANDDATA_PATH); | ||
576 | tar.WriteFile( | ||
577 | ArchiveConstants.CONTROL_FILE_PATH, | ||
578 | new ArchiveWriteRequest(m_scene, (Stream)null, Guid.Empty).CreateControlFile(new ArchiveScenesGroup())); | ||
579 | |||
580 | LandObject lo = new LandObject(groupID, true, null); | ||
581 | lo.SetLandBitmap(lo.BasicFullRegionLandBitmap()); | ||
582 | LandData ld = lo.LandData; | ||
583 | ld.GlobalID = landID; | ||
584 | |||
585 | string ldPath = ArchiveConstants.CreateOarLandDataPath(ld); | ||
586 | tar.WriteFile(ldPath, LandDataSerializer.Serialize(ld, null)); | ||
587 | tar.Close(); | ||
588 | |||
589 | oarStream = new MemoryStream(oarStream.ToArray()); | ||
590 | |||
591 | // Load OAR | ||
592 | lock (this) | ||
593 | { | ||
594 | m_scene.EventManager.OnOarFileLoaded += LoadCompleted; | ||
595 | m_archiverModule.DearchiveRegion(oarStream); | ||
596 | } | ||
597 | |||
598 | ILandObject rLo = m_scene.LandChannel.GetLandObject(16, 16); | ||
599 | LandData rLd = rLo.LandData; | ||
600 | |||
601 | Assert.That(rLd.GlobalID, Is.EqualTo(landID)); | ||
602 | Assert.That(rLd.OwnerID, Is.EqualTo(groupID)); | ||
603 | Assert.That(rLd.GroupID, Is.EqualTo(groupID)); | ||
604 | Assert.That(rLd.IsGroupOwned, Is.EqualTo(true)); | ||
605 | } | ||
606 | |||
607 | /// <summary> | ||
566 | /// Test loading the region settings of an OpenSim Region Archive. | 608 | /// Test loading the region settings of an OpenSim Region Archive. |
567 | /// </summary> | 609 | /// </summary> |
568 | [Test] | 610 | [Test] |
@@ -781,9 +823,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
781 | } | 823 | } |
782 | } | 824 | } |
783 | 825 | ||
784 | |||
785 | // Save OAR | 826 | // Save OAR |
786 | |||
787 | MemoryStream archiveWriteStream = new MemoryStream(); | 827 | MemoryStream archiveWriteStream = new MemoryStream(); |
788 | m_scene.EventManager.OnOarFileSaved += SaveCompleted; | 828 | m_scene.EventManager.OnOarFileSaved += SaveCompleted; |
789 | 829 | ||
@@ -800,7 +840,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
800 | 840 | ||
801 | 841 | ||
802 | // Check that the OAR contains the expected data | 842 | // Check that the OAR contains the expected data |
803 | |||
804 | Assert.That(m_lastRequestId, Is.EqualTo(requestId)); | 843 | Assert.That(m_lastRequestId, Is.EqualTo(requestId)); |
805 | 844 | ||
806 | byte[] archive = archiveWriteStream.ToArray(); | 845 | byte[] archive = archiveWriteStream.ToArray(); |
@@ -892,7 +931,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
892 | } | 931 | } |
893 | 932 | ||
894 | ArchiveScenesGroup scenesGroup = new ArchiveScenesGroup(); | 933 | ArchiveScenesGroup scenesGroup = new ArchiveScenesGroup(); |
895 | SceneManager.Instance.ForEachScene(delegate(Scene scene) | 934 | m_sceneHelpers.SceneManager.ForEachScene(delegate(Scene scene) |
896 | { | 935 | { |
897 | scenesGroup.AddScene(scene); | 936 | scenesGroup.AddScene(scene); |
898 | }); | 937 | }); |
@@ -950,13 +989,13 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
950 | 989 | ||
951 | // Delete the current objects, to test that they're loaded from the OAR and didn't | 990 | // Delete the current objects, to test that they're loaded from the OAR and didn't |
952 | // just remain in the scene. | 991 | // just remain in the scene. |
953 | SceneManager.Instance.ForEachScene(delegate(Scene scene) | 992 | m_sceneHelpers.SceneManager.ForEachScene(delegate(Scene scene) |
954 | { | 993 | { |
955 | scene.DeleteAllSceneObjects(); | 994 | scene.DeleteAllSceneObjects(); |
956 | }); | 995 | }); |
957 | 996 | ||
958 | // Create a "hole", to test that that the corresponding region isn't loaded from the OAR | 997 | // Create a "hole", to test that that the corresponding region isn't loaded from the OAR |
959 | SceneManager.Instance.CloseScene(SceneManager.Instance.Scenes[1]); | 998 | m_sceneHelpers.SceneManager.CloseScene(SceneManager.Instance.Scenes[1]); |
960 | 999 | ||
961 | 1000 | ||
962 | // Check thay the OAR file contains the expected data | 1001 | // Check thay the OAR file contains the expected data |
@@ -971,10 +1010,32 @@ namespace OpenSim.Region.CoreModules.World.Archiver.Tests | |||
971 | 1010 | ||
972 | Assert.That(m_lastErrorMessage, Is.Null); | 1011 | Assert.That(m_lastErrorMessage, Is.Null); |
973 | 1012 | ||
974 | Assert.AreEqual(3, SceneManager.Instance.Scenes.Count); | 1013 | Assert.AreEqual(3, m_sceneHelpers.SceneManager.Scenes.Count); |
975 | 1014 | ||
976 | TestLoadedRegion(part1, soundItemName, soundData); | 1015 | TestLoadedRegion(part1, soundItemName, soundData); |
977 | } | 1016 | } |
978 | 1017 | ||
1018 | private void TestLoadedRegion(SceneObjectPart part1, string soundItemName, byte[] soundData) | ||
1019 | { | ||
1020 | SceneObjectPart object1PartLoaded = m_scene.GetSceneObjectPart(part1.Name); | ||
1021 | |||
1022 | Assert.That(object1PartLoaded, Is.Not.Null, "object1 was not loaded"); | ||
1023 | Assert.That(object1PartLoaded.Name, Is.EqualTo(part1.Name), "object1 names not identical"); | ||
1024 | Assert.That(object1PartLoaded.GroupPosition, Is.EqualTo(part1.GroupPosition), "object1 group position not equal"); | ||
1025 | Assert.That( | ||
1026 | object1PartLoaded.RotationOffset, Is.EqualTo(part1.RotationOffset), "object1 rotation offset not equal"); | ||
1027 | Assert.That( | ||
1028 | object1PartLoaded.OffsetPosition, Is.EqualTo(part1.OffsetPosition), "object1 offset position not equal"); | ||
1029 | Assert.That(object1PartLoaded.SitTargetOrientation, Is.EqualTo(part1.SitTargetOrientation)); | ||
1030 | Assert.That(object1PartLoaded.SitTargetPosition, Is.EqualTo(part1.SitTargetPosition)); | ||
1031 | |||
1032 | TaskInventoryItem loadedSoundItem = object1PartLoaded.Inventory.GetInventoryItems(soundItemName)[0]; | ||
1033 | Assert.That(loadedSoundItem, Is.Not.Null, "loaded sound item was null"); | ||
1034 | AssetBase loadedSoundAsset = m_scene.AssetService.Get(loadedSoundItem.AssetID.ToString()); | ||
1035 | Assert.That(loadedSoundAsset, Is.Not.Null, "loaded sound asset was null"); | ||
1036 | Assert.That(loadedSoundAsset.Data, Is.EqualTo(soundData), "saved and loaded sound data do not match"); | ||
1037 | |||
1038 | Assert.Greater(m_scene.LandChannel.AllParcels().Count, 0, "incorrect number of parcels"); | ||
1039 | } | ||
979 | } | 1040 | } |
980 | } | 1041 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs index 5fa3dc2..d217f36 100644 --- a/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs +++ b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs | |||
@@ -27,15 +27,17 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using Mono.Addins; | ||
30 | using Nini.Config; | 31 | using Nini.Config; |
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
32 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
33 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
34 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
35 | 36 | ||
36 | namespace OpenSim.Region.CoreModules | 37 | namespace OpenSim.Region.CoreModules.World |
37 | { | 38 | { |
38 | public class CloudModule : ICloudModule | 39 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "CloudModule")] |
40 | public class CloudModule : ICloudModule, INonSharedRegionModule | ||
39 | { | 41 | { |
40 | // private static readonly log4net.ILog m_log | 42 | // private static readonly log4net.ILog m_log |
41 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 43 | // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
@@ -48,7 +50,7 @@ namespace OpenSim.Region.CoreModules | |||
48 | private float m_cloudDensity = 1.0F; | 50 | private float m_cloudDensity = 1.0F; |
49 | private float[] cloudCover = new float[16 * 16]; | 51 | private float[] cloudCover = new float[16 * 16]; |
50 | 52 | ||
51 | public void Initialise(Scene scene, IConfigSource config) | 53 | public void Initialise(IConfigSource config) |
52 | { | 54 | { |
53 | IConfig cloudConfig = config.Configs["Cloud"]; | 55 | IConfig cloudConfig = config.Configs["Cloud"]; |
54 | 56 | ||
@@ -59,21 +61,40 @@ namespace OpenSim.Region.CoreModules | |||
59 | m_frameUpdateRate = cloudConfig.GetInt("cloud_update_rate", 1000); | 61 | m_frameUpdateRate = cloudConfig.GetInt("cloud_update_rate", 1000); |
60 | } | 62 | } |
61 | 63 | ||
62 | if (m_enabled) | 64 | } |
63 | { | ||
64 | 65 | ||
65 | m_scene = scene; | 66 | public void AddRegion(Scene scene) |
67 | { | ||
68 | if (!m_enabled) | ||
69 | return; | ||
66 | 70 | ||
67 | scene.EventManager.OnNewClient += CloudsToClient; | 71 | m_scene = scene; |
68 | scene.RegisterModuleInterface<ICloudModule>(this); | ||
69 | scene.EventManager.OnFrame += CloudUpdate; | ||
70 | 72 | ||
71 | GenerateCloudCover(); | 73 | scene.EventManager.OnNewClient += CloudsToClient; |
74 | scene.RegisterModuleInterface<ICloudModule>(this); | ||
75 | scene.EventManager.OnFrame += CloudUpdate; | ||
72 | 76 | ||
73 | m_ready = true; | 77 | GenerateCloudCover(); |
74 | 78 | ||
75 | } | 79 | m_ready = true; |
80 | } | ||
81 | |||
82 | public void RemoveRegion(Scene scene) | ||
83 | { | ||
84 | if (!m_enabled) | ||
85 | return; | ||
76 | 86 | ||
87 | m_ready = false; | ||
88 | // Remove our hooks | ||
89 | m_scene.EventManager.OnNewClient -= CloudsToClient; | ||
90 | m_scene.EventManager.OnFrame -= CloudUpdate; | ||
91 | m_scene.UnregisterModuleInterface<ICloudModule>(this); | ||
92 | |||
93 | m_scene = null; | ||
94 | } | ||
95 | |||
96 | public void RegionLoaded(Scene scene) | ||
97 | { | ||
77 | } | 98 | } |
78 | 99 | ||
79 | public void PostInitialise() | 100 | public void PostInitialise() |
@@ -82,13 +103,6 @@ namespace OpenSim.Region.CoreModules | |||
82 | 103 | ||
83 | public void Close() | 104 | public void Close() |
84 | { | 105 | { |
85 | if (m_enabled) | ||
86 | { | ||
87 | m_ready = false; | ||
88 | // Remove our hooks | ||
89 | m_scene.EventManager.OnNewClient -= CloudsToClient; | ||
90 | m_scene.EventManager.OnFrame -= CloudUpdate; | ||
91 | } | ||
92 | } | 106 | } |
93 | 107 | ||
94 | public string Name | 108 | public string Name |
@@ -96,12 +110,11 @@ namespace OpenSim.Region.CoreModules | |||
96 | get { return "CloudModule"; } | 110 | get { return "CloudModule"; } |
97 | } | 111 | } |
98 | 112 | ||
99 | public bool IsSharedModule | 113 | public Type ReplaceableInterface |
100 | { | 114 | { |
101 | get { return false; } | 115 | get { return null; } |
102 | } | 116 | } |
103 | 117 | ||
104 | |||
105 | public float CloudCover(int x, int y, int z) | 118 | public float CloudCover(int x, int y, int z) |
106 | { | 119 | { |
107 | float cover = 0f; | 120 | float cover = 0f; |
diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 0e6d663..eb06fcc 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | |||
@@ -53,6 +53,11 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
53 | 53 | ||
54 | protected EstateManagementCommands m_commands; | 54 | protected EstateManagementCommands m_commands; |
55 | 55 | ||
56 | /// <summary> | ||
57 | /// If false, region restart requests from the client are blocked even if they are otherwise legitimate. | ||
58 | /// </summary> | ||
59 | public bool AllowRegionRestartFromClient { get; set; } | ||
60 | |||
56 | private EstateTerrainXferHandler TerrainUploader; | 61 | private EstateTerrainXferHandler TerrainUploader; |
57 | public TelehubManager m_Telehub; | 62 | public TelehubManager m_Telehub; |
58 | 63 | ||
@@ -60,6 +65,53 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
60 | public event ChangeDelegate OnEstateInfoChange; | 65 | public event ChangeDelegate OnEstateInfoChange; |
61 | public event MessageDelegate OnEstateMessage; | 66 | public event MessageDelegate OnEstateMessage; |
62 | 67 | ||
68 | #region Region Module interface | ||
69 | |||
70 | public string Name { get { return "EstateManagementModule"; } } | ||
71 | |||
72 | public Type ReplaceableInterface { get { return null; } } | ||
73 | |||
74 | public void Initialise(IConfigSource source) | ||
75 | { | ||
76 | AllowRegionRestartFromClient = true; | ||
77 | |||
78 | IConfig config = source.Configs["EstateManagement"]; | ||
79 | |||
80 | if (config != null) | ||
81 | AllowRegionRestartFromClient = config.GetBoolean("AllowRegionRestartFromClient", true); | ||
82 | } | ||
83 | |||
84 | public void AddRegion(Scene scene) | ||
85 | { | ||
86 | Scene = scene; | ||
87 | Scene.RegisterModuleInterface<IEstateModule>(this); | ||
88 | Scene.EventManager.OnNewClient += EventManager_OnNewClient; | ||
89 | Scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight; | ||
90 | |||
91 | m_Telehub = new TelehubManager(scene); | ||
92 | |||
93 | m_commands = new EstateManagementCommands(this); | ||
94 | m_commands.Initialise(); | ||
95 | } | ||
96 | |||
97 | public void RemoveRegion(Scene scene) {} | ||
98 | |||
99 | public void RegionLoaded(Scene scene) | ||
100 | { | ||
101 | // Sets up the sun module based no the saved Estate and Region Settings | ||
102 | // DO NOT REMOVE or the sun will stop working | ||
103 | scene.TriggerEstateSunUpdate(); | ||
104 | |||
105 | UserManager = scene.RequestModuleInterface<IUserManagement>(); | ||
106 | } | ||
107 | |||
108 | public void Close() | ||
109 | { | ||
110 | m_commands.Close(); | ||
111 | } | ||
112 | |||
113 | #endregion | ||
114 | |||
63 | #region Packet Data Responders | 115 | #region Packet Data Responders |
64 | 116 | ||
65 | private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice) | 117 | private void sendDetailedEstateData(IClientAPI remote_client, UUID invoice) |
@@ -184,6 +236,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
184 | Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture; | 236 | Scene.RegionInfo.RegionSettings.TerrainTexture4 = texture; |
185 | break; | 237 | break; |
186 | } | 238 | } |
239 | |||
187 | Scene.RegionInfo.RegionSettings.Save(); | 240 | Scene.RegionInfo.RegionSettings.Save(); |
188 | TriggerRegionInfoChange(); | 241 | TriggerRegionInfoChange(); |
189 | sendRegionInfoPacketToAll(); | 242 | sendRegionInfoPacketToAll(); |
@@ -215,6 +268,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
215 | Scene.RegionInfo.RegionSettings.Elevation2NE = highValue; | 268 | Scene.RegionInfo.RegionSettings.Elevation2NE = highValue; |
216 | break; | 269 | break; |
217 | } | 270 | } |
271 | |||
218 | Scene.RegionInfo.RegionSettings.Save(); | 272 | Scene.RegionInfo.RegionSettings.Save(); |
219 | TriggerRegionInfoChange(); | 273 | TriggerRegionInfoChange(); |
220 | sendRegionHandshakeToAll(); | 274 | sendRegionHandshakeToAll(); |
@@ -255,6 +309,12 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
255 | 309 | ||
256 | private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds) | 310 | private void handleEstateRestartSimRequest(IClientAPI remoteClient, int timeInSeconds) |
257 | { | 311 | { |
312 | if (!AllowRegionRestartFromClient) | ||
313 | { | ||
314 | remoteClient.SendAlertMessage("Region restart has been disabled on this simulator."); | ||
315 | return; | ||
316 | } | ||
317 | |||
258 | IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>(); | 318 | IRestartModule restartModule = Scene.RequestModuleInterface<IRestartModule>(); |
259 | if (restartModule != null) | 319 | if (restartModule != null) |
260 | { | 320 | { |
@@ -271,6 +331,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
271 | } | 331 | } |
272 | 332 | ||
273 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); | 333 | restartModule.ScheduleRestart(UUID.Zero, "Region will restart in {0}", times.ToArray(), true); |
334 | |||
335 | m_log.InfoFormat( | ||
336 | "User {0} requested restart of region {1} in {2} seconds", | ||
337 | remoteClient.Name, Scene.Name, times.Count != 0 ? times[0] : 0); | ||
274 | } | 338 | } |
275 | } | 339 | } |
276 | 340 | ||
@@ -295,7 +359,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
295 | 359 | ||
296 | if ((estateAccessType & 4) != 0) // User add | 360 | if ((estateAccessType & 4) != 0) // User add |
297 | { | 361 | { |
298 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) | 362 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true)) |
299 | { | 363 | { |
300 | if ((estateAccessType & 1) != 0) // All estates | 364 | if ((estateAccessType & 1) != 0) // All estates |
301 | { | 365 | { |
@@ -325,9 +389,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
325 | } | 389 | } |
326 | 390 | ||
327 | } | 391 | } |
392 | |||
328 | if ((estateAccessType & 8) != 0) // User remove | 393 | if ((estateAccessType & 8) != 0) // User remove |
329 | { | 394 | { |
330 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) | 395 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true)) |
331 | { | 396 | { |
332 | if ((estateAccessType & 1) != 0) // All estates | 397 | if ((estateAccessType & 1) != 0) // All estates |
333 | { | 398 | { |
@@ -356,9 +421,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
356 | remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); | 421 | remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); |
357 | } | 422 | } |
358 | } | 423 | } |
424 | |||
359 | if ((estateAccessType & 16) != 0) // Group add | 425 | if ((estateAccessType & 16) != 0) // Group add |
360 | { | 426 | { |
361 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) | 427 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true)) |
362 | { | 428 | { |
363 | if ((estateAccessType & 1) != 0) // All estates | 429 | if ((estateAccessType & 1) != 0) // All estates |
364 | { | 430 | { |
@@ -387,9 +453,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
387 | remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); | 453 | remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); |
388 | } | 454 | } |
389 | } | 455 | } |
456 | |||
390 | if ((estateAccessType & 32) != 0) // Group remove | 457 | if ((estateAccessType & 32) != 0) // Group remove |
391 | { | 458 | { |
392 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) | 459 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true)) |
393 | { | 460 | { |
394 | if ((estateAccessType & 1) != 0) // All estates | 461 | if ((estateAccessType & 1) != 0) // All estates |
395 | { | 462 | { |
@@ -418,9 +485,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
418 | remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); | 485 | remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); |
419 | } | 486 | } |
420 | } | 487 | } |
488 | |||
421 | if ((estateAccessType & 64) != 0) // Ban add | 489 | if ((estateAccessType & 64) != 0) // Ban add |
422 | { | 490 | { |
423 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || Scene.Permissions.BypassPermissions()) | 491 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false)) |
424 | { | 492 | { |
425 | EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans; | 493 | EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans; |
426 | 494 | ||
@@ -495,9 +563,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
495 | remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); | 563 | remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); |
496 | } | 564 | } |
497 | } | 565 | } |
566 | |||
498 | if ((estateAccessType & 128) != 0) // Ban remove | 567 | if ((estateAccessType & 128) != 0) // Ban remove |
499 | { | 568 | { |
500 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false) || Scene.Permissions.BypassPermissions()) | 569 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, false)) |
501 | { | 570 | { |
502 | EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans; | 571 | EstateBan[] banlistcheck = Scene.RegionInfo.EstateSettings.EstateBans; |
503 | 572 | ||
@@ -550,9 +619,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
550 | remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); | 619 | remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); |
551 | } | 620 | } |
552 | } | 621 | } |
622 | |||
553 | if ((estateAccessType & 256) != 0) // Manager add | 623 | if ((estateAccessType & 256) != 0) // Manager add |
554 | { | 624 | { |
555 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) | 625 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true)) |
556 | { | 626 | { |
557 | if ((estateAccessType & 1) != 0) // All estates | 627 | if ((estateAccessType & 1) != 0) // All estates |
558 | { | 628 | { |
@@ -581,9 +651,10 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
581 | remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); | 651 | remote_client.SendAlertMessage("Method EstateAccessDelta Failed, you don't have permissions"); |
582 | } | 652 | } |
583 | } | 653 | } |
654 | |||
584 | if ((estateAccessType & 512) != 0) // Manager remove | 655 | if ((estateAccessType & 512) != 0) // Manager remove |
585 | { | 656 | { |
586 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true) || Scene.Permissions.BypassPermissions()) | 657 | if (Scene.Permissions.CanIssueEstateCommand(remote_client.AgentId, true)) |
587 | { | 658 | { |
588 | if ((estateAccessType & 1) != 0) // All estates | 659 | if ((estateAccessType & 1) != 0) // All estates |
589 | { | 660 | { |
@@ -614,7 +685,7 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
614 | } | 685 | } |
615 | } | 686 | } |
616 | 687 | ||
617 | public void handleOnEstateManageTelehub (IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1) | 688 | public void handleOnEstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, uint param1) |
618 | { | 689 | { |
619 | SceneObjectPart part; | 690 | SceneObjectPart part; |
620 | 691 | ||
@@ -1072,45 +1143,6 @@ namespace OpenSim.Region.CoreModules.World.Estate | |||
1072 | 1143 | ||
1073 | #endregion | 1144 | #endregion |
1074 | 1145 | ||
1075 | #region IRegionModule Members | ||
1076 | |||
1077 | public string Name { get { return "EstateManagementModule"; } } | ||
1078 | |||
1079 | public Type ReplaceableInterface { get { return null; } } | ||
1080 | |||
1081 | public void Initialise(IConfigSource source) {} | ||
1082 | |||
1083 | public void AddRegion(Scene scene) | ||
1084 | { | ||
1085 | Scene = scene; | ||
1086 | Scene.RegisterModuleInterface<IEstateModule>(this); | ||
1087 | Scene.EventManager.OnNewClient += EventManager_OnNewClient; | ||
1088 | Scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight; | ||
1089 | |||
1090 | m_Telehub = new TelehubManager(scene); | ||
1091 | |||
1092 | m_commands = new EstateManagementCommands(this); | ||
1093 | m_commands.Initialise(); | ||
1094 | } | ||
1095 | |||
1096 | public void RemoveRegion(Scene scene) {} | ||
1097 | |||
1098 | public void RegionLoaded(Scene scene) | ||
1099 | { | ||
1100 | // Sets up the sun module based no the saved Estate and Region Settings | ||
1101 | // DO NOT REMOVE or the sun will stop working | ||
1102 | scene.TriggerEstateSunUpdate(); | ||
1103 | |||
1104 | UserManager = scene.RequestModuleInterface<IUserManagement>(); | ||
1105 | } | ||
1106 | |||
1107 | public void Close() | ||
1108 | { | ||
1109 | m_commands.Close(); | ||
1110 | } | ||
1111 | |||
1112 | #endregion | ||
1113 | |||
1114 | #region Other Functions | 1146 | #region Other Functions |
1115 | 1147 | ||
1116 | public void changeWaterHeight(float height) | 1148 | public void changeWaterHeight(float height) |
diff --git a/OpenSim/Region/CoreModules/World/Land/DwellModule.cs b/OpenSim/Region/CoreModules/World/Land/DwellModule.cs new file mode 100644 index 0000000..bd22155 --- /dev/null +++ b/OpenSim/Region/CoreModules/World/Land/DwellModule.cs | |||
@@ -0,0 +1,112 @@ | |||
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; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Diagnostics; | ||
32 | using System.Reflection; | ||
33 | using System.Text; | ||
34 | using log4net; | ||
35 | using Nini.Config; | ||
36 | using OpenMetaverse; | ||
37 | using OpenMetaverse.StructuredData; | ||
38 | using OpenMetaverse.Messages.Linden; | ||
39 | using Mono.Addins; | ||
40 | using OpenSim.Framework; | ||
41 | using OpenSim.Framework.Capabilities; | ||
42 | using OpenSim.Framework.Console; | ||
43 | using OpenSim.Framework.Servers; | ||
44 | using OpenSim.Framework.Servers.HttpServer; | ||
45 | using OpenSim.Region.CoreModules.Framework.InterfaceCommander; | ||
46 | using OpenSim.Region.Framework.Interfaces; | ||
47 | using OpenSim.Region.Framework.Scenes; | ||
48 | using OpenSim.Region.Physics.Manager; | ||
49 | using OpenSim.Services.Interfaces; | ||
50 | using Caps = OpenSim.Framework.Capabilities.Caps; | ||
51 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
52 | |||
53 | namespace OpenSim.Region.CoreModules.World.Land | ||
54 | { | ||
55 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DwellModule")] | ||
56 | public class DwellModule : IDwellModule, INonSharedRegionModule | ||
57 | { | ||
58 | private Scene m_scene; | ||
59 | |||
60 | public Type ReplaceableInterface | ||
61 | { | ||
62 | get { return typeof(IDwellModule); } | ||
63 | } | ||
64 | |||
65 | public string Name | ||
66 | { | ||
67 | get { return "DwellModule"; } | ||
68 | } | ||
69 | |||
70 | public void Initialise(IConfigSource source) | ||
71 | { | ||
72 | } | ||
73 | |||
74 | public void AddRegion(Scene scene) | ||
75 | { | ||
76 | m_scene = scene; | ||
77 | |||
78 | m_scene.EventManager.OnNewClient += OnNewClient; | ||
79 | } | ||
80 | |||
81 | public void RegionLoaded(Scene scene) | ||
82 | { | ||
83 | } | ||
84 | |||
85 | public void RemoveRegion(Scene scene) | ||
86 | { | ||
87 | } | ||
88 | |||
89 | public void Close() | ||
90 | { | ||
91 | } | ||
92 | |||
93 | public void OnNewClient(IClientAPI client) | ||
94 | { | ||
95 | client.OnParcelDwellRequest += ClientOnParcelDwellRequest; | ||
96 | } | ||
97 | |||
98 | private void ClientOnParcelDwellRequest(int localID, IClientAPI client) | ||
99 | { | ||
100 | ILandObject parcel = m_scene.LandChannel.GetLandObject(localID); | ||
101 | if (parcel == null) | ||
102 | return; | ||
103 | |||
104 | client.SendParcelDwellReply(localID, parcel.LandData.GlobalID, parcel.LandData.Dwell); | ||
105 | } | ||
106 | |||
107 | public int GetDwell(UUID parcelID) | ||
108 | { | ||
109 | return 0; | ||
110 | } | ||
111 | } | ||
112 | } | ||
diff --git a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs index 95edf62..7149aad 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandManagementModule.cs | |||
@@ -36,6 +36,7 @@ using Nini.Config; | |||
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using OpenMetaverse.StructuredData; | 37 | using OpenMetaverse.StructuredData; |
38 | using OpenMetaverse.Messages.Linden; | 38 | using OpenMetaverse.Messages.Linden; |
39 | using Mono.Addins; | ||
39 | using OpenSim.Framework; | 40 | using OpenSim.Framework; |
40 | using OpenSim.Framework.Capabilities; | 41 | using OpenSim.Framework.Capabilities; |
41 | using OpenSim.Framework.Console; | 42 | using OpenSim.Framework.Console; |
@@ -60,6 +61,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
60 | public byte RegionAccess; | 61 | public byte RegionAccess; |
61 | } | 62 | } |
62 | 63 | ||
64 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LandManagementModule")] | ||
63 | public class LandManagementModule : INonSharedRegionModule | 65 | public class LandManagementModule : INonSharedRegionModule |
64 | { | 66 | { |
65 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 67 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -207,7 +209,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
207 | client.OnParcelInfoRequest += ClientOnParcelInfoRequest; | 209 | client.OnParcelInfoRequest += ClientOnParcelInfoRequest; |
208 | client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup; | 210 | client.OnParcelDeedToGroup += ClientOnParcelDeedToGroup; |
209 | client.OnPreAgentUpdate += ClientOnPreAgentUpdate; | 211 | client.OnPreAgentUpdate += ClientOnPreAgentUpdate; |
210 | client.OnParcelDwellRequest += ClientOnParcelDwellRequest; | ||
211 | 212 | ||
212 | EntityBase presenceEntity; | 213 | EntityBase presenceEntity; |
213 | if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) | 214 | if (m_scene.Entities.TryGetValue(client.AgentId, out presenceEntity) && presenceEntity is ScenePresence) |
@@ -799,17 +800,6 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
799 | } | 800 | } |
800 | } | 801 | } |
801 | 802 | ||
802 | private void ClientOnParcelDwellRequest(int localID, IClientAPI client) | ||
803 | { | ||
804 | ILandObject parcel = null; | ||
805 | lock (m_landList) | ||
806 | { | ||
807 | if (!m_landList.TryGetValue(localID, out parcel)) | ||
808 | return; | ||
809 | } | ||
810 | client.SendParcelDwellReply(localID, parcel.LandData.GlobalID, parcel.LandData.Dwell); | ||
811 | } | ||
812 | |||
813 | #endregion | 803 | #endregion |
814 | 804 | ||
815 | #region Parcel Modification | 805 | #region Parcel Modification |
@@ -962,6 +952,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
962 | ILandObject newLand = startLandObject.Copy(); | 952 | ILandObject newLand = startLandObject.Copy(); |
963 | newLand.LandData.Name = newLand.LandData.Name; | 953 | newLand.LandData.Name = newLand.LandData.Name; |
964 | newLand.LandData.GlobalID = UUID.Random(); | 954 | newLand.LandData.GlobalID = UUID.Random(); |
955 | newLand.LandData.Dwell = 0; | ||
965 | 956 | ||
966 | newLand.SetLandBitmap(newLand.GetSquareLandBitmap(start_x, start_y, end_x, end_y)); | 957 | newLand.SetLandBitmap(newLand.GetSquareLandBitmap(start_x, start_y, end_x, end_y)); |
967 | 958 | ||
@@ -1387,10 +1378,11 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
1387 | 1378 | ||
1388 | public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) | 1379 | public void EventManagerOnIncomingLandDataFromStorage(List<LandData> data) |
1389 | { | 1380 | { |
1381 | // m_log.DebugFormat( | ||
1382 | // "[LAND MANAGMENT MODULE]: Processing {0} incoming parcels on {1}", data.Count, m_scene.Name); | ||
1383 | |||
1390 | for (int i = 0; i < data.Count; i++) | 1384 | for (int i = 0; i < data.Count; i++) |
1391 | { | ||
1392 | IncomingLandObjectFromStorage(data[i]); | 1385 | IncomingLandObjectFromStorage(data[i]); |
1393 | } | ||
1394 | } | 1386 | } |
1395 | 1387 | ||
1396 | public void IncomingLandObjectFromStorage(LandData data) | 1388 | public void IncomingLandObjectFromStorage(LandData data) |
diff --git a/OpenSim/Region/CoreModules/World/Land/LandObject.cs b/OpenSim/Region/CoreModules/World/Land/LandObject.cs index 8829f27..5969d45 100644 --- a/OpenSim/Region/CoreModules/World/Land/LandObject.cs +++ b/OpenSim/Region/CoreModules/World/Land/LandObject.cs | |||
@@ -727,9 +727,10 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
727 | int ty = min_y * 4; | 727 | int ty = min_y * 4; |
728 | if (ty > ((int)Constants.RegionSize - 1)) | 728 | if (ty > ((int)Constants.RegionSize - 1)) |
729 | ty = ((int)Constants.RegionSize - 1); | 729 | ty = ((int)Constants.RegionSize - 1); |
730 | |||
730 | LandData.AABBMin = | 731 | LandData.AABBMin = |
731 | new Vector3((float) (min_x * 4), (float) (min_y * 4), | 732 | new Vector3( |
732 | (float) m_scene.Heightmap[tx, ty]); | 733 | (float)(min_x * 4), (float)(min_y * 4), m_scene != null ? (float)m_scene.Heightmap[tx, ty] : 0); |
733 | 734 | ||
734 | tx = max_x * 4; | 735 | tx = max_x * 4; |
735 | if (tx > ((int)Constants.RegionSize - 1)) | 736 | if (tx > ((int)Constants.RegionSize - 1)) |
@@ -737,9 +738,11 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
737 | ty = max_y * 4; | 738 | ty = max_y * 4; |
738 | if (ty > ((int)Constants.RegionSize - 1)) | 739 | if (ty > ((int)Constants.RegionSize - 1)) |
739 | ty = ((int)Constants.RegionSize - 1); | 740 | ty = ((int)Constants.RegionSize - 1); |
740 | LandData.AABBMax = | 741 | |
741 | new Vector3((float) (max_x * 4), (float) (max_y * 4), | 742 | LandData.AABBMax |
742 | (float) m_scene.Heightmap[tx, ty]); | 743 | = new Vector3( |
744 | (float)(max_x * 4), (float)(max_y * 4), m_scene != null ? (float)m_scene.Heightmap[tx, ty] : 0); | ||
745 | |||
743 | LandData.Area = tempArea; | 746 | LandData.Area = tempArea; |
744 | } | 747 | } |
745 | 748 | ||
diff --git a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs index 665875f..f9cc0cf 100644 --- a/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/PrimCountModule.cs | |||
@@ -34,6 +34,7 @@ using log4net; | |||
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using Mono.Addins; | ||
37 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
39 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
@@ -49,6 +50,7 @@ namespace OpenSim.Region.CoreModules.World.Land | |||
49 | public Dictionary <UUID, int> Users = new Dictionary <UUID, int>(); | 50 | public Dictionary <UUID, int> Users = new Dictionary <UUID, int>(); |
50 | } | 51 | } |
51 | 52 | ||
53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "PrimCountModule")] | ||
52 | public class PrimCountModule : IPrimCountModule, INonSharedRegionModule | 54 | public class PrimCountModule : IPrimCountModule, INonSharedRegionModule |
53 | { | 55 | { |
54 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 56 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs index b5ee4d2..14eca42 100644 --- a/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs +++ b/OpenSim/Region/CoreModules/World/Land/Tests/PrimCountModuleTests.cs | |||
@@ -41,7 +41,7 @@ using OpenSim.Tests.Common.Mock; | |||
41 | namespace OpenSim.Region.CoreModules.World.Land.Tests | 41 | namespace OpenSim.Region.CoreModules.World.Land.Tests |
42 | { | 42 | { |
43 | [TestFixture] | 43 | [TestFixture] |
44 | public class PrimCountModuleTests | 44 | public class PrimCountModuleTests : OpenSimTestCase |
45 | { | 45 | { |
46 | protected UUID m_userId = new UUID("00000000-0000-0000-0000-100000000000"); | 46 | protected UUID m_userId = new UUID("00000000-0000-0000-0000-100000000000"); |
47 | protected UUID m_groupId = new UUID("00000000-0000-0000-8888-000000000000"); | 47 | protected UUID m_groupId = new UUID("00000000-0000-0000-8888-000000000000"); |
diff --git a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs index aa306c7..8a422b0 100644 --- a/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/LegacyMap/MapImageModule.cs | |||
@@ -30,6 +30,7 @@ using System.Collections.Generic; | |||
30 | using System.Drawing; | 30 | using System.Drawing; |
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using log4net; | 32 | using log4net; |
33 | using Mono.Addins; | ||
33 | using Nini.Config; | 34 | using Nini.Config; |
34 | using OpenMetaverse; | 35 | using OpenMetaverse; |
35 | using OpenMetaverse.Imaging; | 36 | using OpenMetaverse.Imaging; |
@@ -59,6 +60,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
59 | public face[] trns; | 60 | public face[] trns; |
60 | } | 61 | } |
61 | 62 | ||
63 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapImageModule")] | ||
62 | public class MapImageModule : IMapImageGenerator, INonSharedRegionModule | 64 | public class MapImageModule : IMapImageGenerator, INonSharedRegionModule |
63 | { | 65 | { |
64 | private static readonly ILog m_log = | 66 | private static readonly ILog m_log = |
@@ -131,7 +133,7 @@ namespace OpenSim.Region.CoreModules.World.LegacyMap | |||
131 | 133 | ||
132 | #endregion | 134 | #endregion |
133 | 135 | ||
134 | #region IRegionModule Members | 136 | #region Region Module interface |
135 | 137 | ||
136 | public void Initialise(IConfigSource source) | 138 | public void Initialise(IConfigSource source) |
137 | { | 139 | { |
diff --git a/OpenSim/Region/CoreModules/LightShare/EnvironmentModule.cs b/OpenSim/Region/CoreModules/World/LightShare/EnvironmentModule.cs index 1526886..c3cea7a 100644 --- a/OpenSim/Region/CoreModules/LightShare/EnvironmentModule.cs +++ b/OpenSim/Region/CoreModules/World/LightShare/EnvironmentModule.cs | |||
@@ -51,10 +51,10 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
51 | private Scene m_scene = null; | 51 | private Scene m_scene = null; |
52 | private UUID regionID = UUID.Zero; | 52 | private UUID regionID = UUID.Zero; |
53 | private static bool Enabled = false; | 53 | private static bool Enabled = false; |
54 | 54 | ||
55 | private static readonly string capsName = "EnvironmentSettings"; | 55 | private static readonly string capsName = "EnvironmentSettings"; |
56 | private static readonly string capsBase = "/CAPS/0020/"; | 56 | private static readonly string capsBase = "/CAPS/0020/"; |
57 | 57 | ||
58 | private LLSDEnvironmentSetResponse setResponse = null; | 58 | private LLSDEnvironmentSetResponse setResponse = null; |
59 | 59 | ||
60 | #region INonSharedRegionModule | 60 | #region INonSharedRegionModule |
@@ -72,7 +72,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
72 | } | 72 | } |
73 | 73 | ||
74 | Enabled = true; | 74 | Enabled = true; |
75 | 75 | ||
76 | m_log.InfoFormat("[{0}]: Module is enabled.", Name); | 76 | m_log.InfoFormat("[{0}]: Module is enabled.", Name); |
77 | } | 77 | } |
78 | 78 | ||
@@ -132,8 +132,8 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
132 | #region Events | 132 | #region Events |
133 | private void OnRegisterCaps(UUID agentID, Caps caps) | 133 | private void OnRegisterCaps(UUID agentID, Caps caps) |
134 | { | 134 | { |
135 | // m_log.DebugFormat("[{0}]: Register capability for agentID {1} in region {2}", | 135 | // m_log.DebugFormat("[{0}]: Register capability for agentID {1} in region {2}", |
136 | // Name, agentID, caps.RegionName); | 136 | // Name, agentID, caps.RegionName); |
137 | 137 | ||
138 | string capsPath = capsBase + UUID.Random(); | 138 | string capsPath = capsBase + UUID.Random(); |
139 | 139 | ||
@@ -163,8 +163,8 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
163 | private string GetEnvironmentSettings(string request, string path, string param, | 163 | private string GetEnvironmentSettings(string request, string path, string param, |
164 | UUID agentID, Caps caps) | 164 | UUID agentID, Caps caps) |
165 | { | 165 | { |
166 | // m_log.DebugFormat("[{0}]: Environment GET handle for agentID {1} in region {2}", | 166 | // m_log.DebugFormat("[{0}]: Environment GET handle for agentID {1} in region {2}", |
167 | // Name, agentID, caps.RegionName); | 167 | // Name, agentID, caps.RegionName); |
168 | 168 | ||
169 | string env = String.Empty; | 169 | string env = String.Empty; |
170 | 170 | ||
@@ -188,8 +188,8 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
188 | UUID agentID, Caps caps) | 188 | UUID agentID, Caps caps) |
189 | { | 189 | { |
190 | 190 | ||
191 | // m_log.DebugFormat("[{0}]: Environment SET handle from agentID {1} in region {2}", | 191 | // m_log.DebugFormat("[{0}]: Environment SET handle from agentID {1} in region {2}", |
192 | // Name, agentID, caps.RegionName); | 192 | // Name, agentID, caps.RegionName); |
193 | 193 | ||
194 | setResponse.regionID = regionID; | 194 | setResponse.regionID = regionID; |
195 | setResponse.success = false; | 195 | setResponse.success = false; |
@@ -204,7 +204,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
204 | { | 204 | { |
205 | m_scene.SimulationDataService.StoreRegionEnvironmentSettings(regionID, request); | 205 | m_scene.SimulationDataService.StoreRegionEnvironmentSettings(regionID, request); |
206 | setResponse.success = true; | 206 | setResponse.success = true; |
207 | 207 | ||
208 | m_log.InfoFormat("[{0}]: New Environment settings has been saved from agentID {1} in region {2}", | 208 | m_log.InfoFormat("[{0}]: New Environment settings has been saved from agentID {1} in region {2}", |
209 | Name, agentID, caps.RegionName); | 209 | Name, agentID, caps.RegionName); |
210 | } | 210 | } |
diff --git a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs index 16cbbf5..4e20196 100644 --- a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs +++ b/OpenSim/Region/CoreModules/World/LightShare/LightShareModule.cs | |||
@@ -27,21 +27,20 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | ||
31 | using System.Reflection; | 30 | using System.Reflection; |
32 | using OpenMetaverse; | 31 | using OpenMetaverse; |
33 | using log4net; | ||
34 | using Nini.Config; | ||
35 | using OpenSim.Data; | ||
36 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
37 | using OpenSim.Region.CoreModules.Framework.InterfaceCommander; | 33 | using OpenSim.Region.CoreModules.Framework.InterfaceCommander; |
38 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 35 | using OpenSim.Region.Framework.Scenes; |
40 | 36 | using log4net; | |
37 | using Nini.Config; | ||
38 | using Mono.Addins; | ||
41 | 39 | ||
42 | namespace OpenSim.Region.CoreModules.World.LightShare | 40 | namespace OpenSim.Region.CoreModules.World.LightShare |
43 | { | 41 | { |
44 | public class LightShareModule : IRegionModule, ICommandableModule | 42 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LightShareModule")] |
43 | public class LightShareModule : INonSharedRegionModule, ILightShareModule, ICommandableModule | ||
45 | { | 44 | { |
46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
47 | private readonly Commander m_commander = new Commander("windlight"); | 46 | private readonly Commander m_commander = new Commander("windlight"); |
@@ -57,48 +56,86 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
57 | 56 | ||
58 | #endregion | 57 | #endregion |
59 | 58 | ||
60 | #region IRegionModule Members | 59 | #region INonSharedRegionModule Members |
61 | 60 | ||
62 | public static bool EnableWindlight | 61 | public void Initialise(IConfigSource config) |
63 | { | 62 | { |
64 | get | 63 | try |
65 | { | 64 | { |
66 | return m_enableWindlight; | 65 | m_enableWindlight = config.Configs["LightShare"].GetBoolean("enable_windlight", false); |
67 | } | 66 | } |
68 | set | 67 | catch (Exception) |
69 | { | 68 | { |
69 | m_log.Debug("[WINDLIGHT]: ini failure for enable_windlight - using default"); | ||
70 | } | 70 | } |
71 | |||
72 | m_log.DebugFormat("[WINDLIGHT]: windlight module {0}", (m_enableWindlight ? "enabled" : "disabled")); | ||
71 | } | 73 | } |
72 | 74 | ||
73 | public void Initialise(Scene scene, IConfigSource config) | 75 | public void AddRegion(Scene scene) |
74 | { | 76 | { |
77 | if (!m_enableWindlight) | ||
78 | return; | ||
79 | |||
75 | m_scene = scene; | 80 | m_scene = scene; |
76 | m_scene.RegisterModuleInterface<IRegionModule>(this); | 81 | m_scene.RegisterModuleInterface<ILightShareModule>(this); |
77 | m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; | 82 | m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; |
78 | 83 | ||
79 | // ini file settings | 84 | m_scene.EventManager.OnMakeRootAgent += EventManager_OnMakeRootAgent; |
80 | try | 85 | m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile; |
81 | { | 86 | m_scene.EventManager.OnSendNewWindlightProfileTargeted += EventManager_OnSendNewWindlightProfileTargeted; |
82 | m_enableWindlight = config.Configs["LightShare"].GetBoolean("enable_windlight", false); | 87 | m_scene.LoadWindlightProfile(); |
83 | } | 88 | |
84 | catch (Exception) | 89 | InstallCommands(); |
90 | } | ||
91 | |||
92 | public void RemoveRegion(Scene scene) | ||
93 | { | ||
94 | if (!m_enableWindlight) | ||
95 | return; | ||
96 | |||
97 | m_scene.EventManager.OnPluginConsole -= EventManager_OnPluginConsole; | ||
98 | |||
99 | m_scene.EventManager.OnMakeRootAgent -= EventManager_OnMakeRootAgent; | ||
100 | m_scene.EventManager.OnSaveNewWindlightProfile -= EventManager_OnSaveNewWindlightProfile; | ||
101 | m_scene.EventManager.OnSendNewWindlightProfileTargeted -= EventManager_OnSendNewWindlightProfileTargeted; | ||
102 | |||
103 | m_scene = null; | ||
104 | } | ||
105 | |||
106 | public void Close() | ||
107 | { | ||
108 | } | ||
109 | |||
110 | public string Name | ||
111 | { | ||
112 | get { return "LightShareModule"; } | ||
113 | } | ||
114 | |||
115 | public void RegionLoaded(Scene scene) | ||
116 | { | ||
117 | } | ||
118 | |||
119 | public Type ReplaceableInterface | ||
120 | { | ||
121 | get { return null; } | ||
122 | } | ||
123 | |||
124 | #endregion | ||
125 | |||
126 | public static bool EnableWindlight | ||
127 | { | ||
128 | get | ||
85 | { | 129 | { |
86 | m_log.Debug("[WINDLIGHT]: ini failure for enable_windlight - using default"); | 130 | return m_enableWindlight; |
87 | } | 131 | } |
88 | 132 | set | |
89 | if (m_enableWindlight) | ||
90 | { | 133 | { |
91 | m_scene.EventManager.OnMakeRootAgent += EventManager_OnMakeRootAgent; | ||
92 | m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile; | ||
93 | m_scene.EventManager.OnSendNewWindlightProfileTargeted += EventManager_OnSendNewWindlightProfileTargeted; | ||
94 | m_scene.LoadWindlightProfile(); | ||
95 | } | 134 | } |
96 | |||
97 | InstallCommands(); | ||
98 | |||
99 | m_log.Debug("[WINDLIGHT]: Initialised windlight module"); | ||
100 | } | 135 | } |
101 | 136 | ||
137 | #region events | ||
138 | |||
102 | private List<byte[]> compileWindlightSettings(RegionLightShareData wl) | 139 | private List<byte[]> compileWindlightSettings(RegionLightShareData wl) |
103 | { | 140 | { |
104 | byte[] mBlock = new Byte[249]; | 141 | byte[] mBlock = new Byte[249]; |
@@ -186,29 +223,6 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
186 | m_scene.ForEachRootClient(SendProfileToClient); | 223 | m_scene.ForEachRootClient(SendProfileToClient); |
187 | } | 224 | } |
188 | 225 | ||
189 | public void PostInitialise() | ||
190 | { | ||
191 | |||
192 | } | ||
193 | |||
194 | public void Close() | ||
195 | { | ||
196 | } | ||
197 | |||
198 | public string Name | ||
199 | { | ||
200 | get { return "LightShareModule"; } | ||
201 | } | ||
202 | |||
203 | public bool IsSharedModule | ||
204 | { | ||
205 | get { return false; } | ||
206 | } | ||
207 | |||
208 | #endregion | ||
209 | |||
210 | #region events | ||
211 | |||
212 | #endregion | 226 | #endregion |
213 | 227 | ||
214 | #region ICommandableModule Members | 228 | #region ICommandableModule Members |
@@ -243,7 +257,7 @@ namespace OpenSim.Region.CoreModules.World.LightShare | |||
243 | private void HandleDisable(Object[] args) | 257 | private void HandleDisable(Object[] args) |
244 | { | 258 | { |
245 | m_log.InfoFormat("[WINDLIGHT]: Plugin now disabled"); | 259 | m_log.InfoFormat("[WINDLIGHT]: Plugin now disabled"); |
246 | m_enableWindlight=false; | 260 | m_enableWindlight = false; |
247 | } | 261 | } |
248 | 262 | ||
249 | private void HandleEnable(Object[] args) | 263 | private void HandleEnable(Object[] args) |
diff --git a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs index 396095a..ba4b041 100644 --- a/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs +++ b/OpenSim/Region/CoreModules/World/Media/Moap/Tests/MoapTests.cs | |||
@@ -44,7 +44,7 @@ using OpenSim.Tests.Common.Mock; | |||
44 | namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests | 44 | namespace OpenSim.Region.CoreModules.World.Media.Moap.Tests |
45 | { | 45 | { |
46 | [TestFixture] | 46 | [TestFixture] |
47 | public class MoapTests | 47 | public class MoapTests : OpenSimTestCase |
48 | { | 48 | { |
49 | protected TestScene m_scene; | 49 | protected TestScene m_scene; |
50 | protected MoapModule m_module; | 50 | protected MoapModule m_module; |
diff --git a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs index 87241e1..ab8f143 100644 --- a/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/Commands/ObjectCommandsModule.cs | |||
@@ -27,10 +27,12 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.IO; | ||
30 | using System.Linq; | 31 | using System.Linq; |
31 | using System.Reflection; | 32 | using System.Reflection; |
32 | using System.Text; | 33 | using System.Text; |
33 | using System.Text.RegularExpressions; | 34 | using System.Text.RegularExpressions; |
35 | using System.Xml; | ||
34 | using log4net; | 36 | using log4net; |
35 | using Mono.Addins; | 37 | using Mono.Addins; |
36 | using NDesk.Options; | 38 | using NDesk.Options; |
@@ -41,6 +43,7 @@ using OpenSim.Framework.Console; | |||
41 | using OpenSim.Framework.Monitoring; | 43 | using OpenSim.Framework.Monitoring; |
42 | using OpenSim.Region.Framework.Interfaces; | 44 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.Framework.Scenes; | 45 | using OpenSim.Region.Framework.Scenes; |
46 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
44 | 47 | ||
45 | namespace OpenSim.Region.CoreModules.World.Objects.Commands | 48 | namespace OpenSim.Region.CoreModules.World.Objects.Commands |
46 | { | 49 | { |
@@ -96,9 +99,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
96 | HandleDeleteObject); | 99 | HandleDeleteObject); |
97 | 100 | ||
98 | m_console.Commands.AddCommand( | 101 | m_console.Commands.AddCommand( |
99 | "Objects", false, "delete object uuid", | 102 | "Objects", false, "delete object id", |
100 | "delete object uuid <UUID>", | 103 | "delete object id <UUID-or-localID>", |
101 | "Delete a scene object by uuid", | 104 | "Delete a scene object by uuid or localID", |
102 | HandleDeleteObject); | 105 | HandleDeleteObject); |
103 | 106 | ||
104 | m_console.Commands.AddCommand( | 107 | m_console.Commands.AddCommand( |
@@ -122,28 +125,18 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
122 | "delete object pos", | 125 | "delete object pos", |
123 | "delete object pos <start-coord> to <end-coord>", | 126 | "delete object pos <start-coord> to <end-coord>", |
124 | "Delete scene objects within the given area.", | 127 | "Delete scene objects within the given area.", |
125 | "Each component of the coord is comma separated. There must be no spaces between the commas.\n" | 128 | ConsoleUtil.CoordHelp, |
126 | + "If you don't care about the z component you can simply omit it.\n" | ||
127 | + "If you don't care about the x or y components then you can leave them blank (though a comma is still required)\n" | ||
128 | + "If you want to specify the maxmimum value of a component then you can use ~ instead of a number\n" | ||
129 | + "If you want to specify the minimum value of a component then you can use -~ instead of a number\n" | ||
130 | + "e.g.\n" | ||
131 | + "delete object pos 20,20,20 to 40,40,40\n" | ||
132 | + "delete object pos 20,20 to 40,40\n" | ||
133 | + "delete object pos ,20,20 to ,40,40\n" | ||
134 | + "delete object pos ,,30 to ,,~\n" | ||
135 | + "delete object pos ,,-~ to ,,30", | ||
136 | HandleDeleteObject); | 129 | HandleDeleteObject); |
137 | 130 | ||
138 | m_console.Commands.AddCommand( | 131 | m_console.Commands.AddCommand( |
139 | "Objects", | 132 | "Objects", |
140 | false, | 133 | false, |
141 | "show object uuid", | 134 | "show object id", |
142 | "show object uuid [--full] <UUID>", | 135 | "show object id [--full] <UUID-or-localID>", |
143 | "Show details of a scene object with the given UUID", | 136 | "Show details of a scene object with the given UUID or localID", |
144 | "The --full option will print out information on all the parts of the object.\n" | 137 | "The --full option will print out information on all the parts of the object.\n" |
145 | + "For yet more detailed part information, use the \"show part\" commands.", | 138 | + "For yet more detailed part information, use the \"show part\" commands.", |
146 | HandleShowObjectByUuid); | 139 | HandleShowObjectById); |
147 | 140 | ||
148 | m_console.Commands.AddCommand( | 141 | m_console.Commands.AddCommand( |
149 | "Objects", | 142 | "Objects", |
@@ -164,25 +157,15 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
164 | "Show details of scene objects within the given area.", | 157 | "Show details of scene objects within the given area.", |
165 | "The --full option will print out information on all the parts of the object.\n" | 158 | "The --full option will print out information on all the parts of the object.\n" |
166 | + "For yet more detailed part information, use the \"show part\" commands.\n" | 159 | + "For yet more detailed part information, use the \"show part\" commands.\n" |
167 | + "Each component of the coord is comma separated. There must be no spaces between the commas.\n" | 160 | + ConsoleUtil.CoordHelp, |
168 | + "If you don't care about the z component you can simply omit it.\n" | ||
169 | + "If you don't care about the x or y components then you can leave them blank (though a comma is still required)\n" | ||
170 | + "If you want to specify the maxmimum value of a component then you can use ~ instead of a number\n" | ||
171 | + "If you want to specify the minimum value of a component then you can use -~ instead of a number\n" | ||
172 | + "e.g.\n" | ||
173 | + "show object pos 20,20,20 to 40,40,40\n" | ||
174 | + "show object pos 20,20 to 40,40\n" | ||
175 | + "show object pos ,20,20 to ,40,40\n" | ||
176 | + "show object pos ,,30 to ,,~\n" | ||
177 | + "show object pos ,,-~ to ,,30", | ||
178 | HandleShowObjectByPos); | 161 | HandleShowObjectByPos); |
179 | 162 | ||
180 | m_console.Commands.AddCommand( | 163 | m_console.Commands.AddCommand( |
181 | "Objects", | 164 | "Objects", |
182 | false, | 165 | false, |
183 | "show part uuid", | 166 | "show part id", |
184 | "show part uuid <UUID>", | 167 | "show part id <UUID-or-localID>", |
185 | "Show details of a scene object parts with the given UUID", HandleShowPartByUuid); | 168 | "Show details of a scene object part with the given UUID or localID", HandleShowPartById); |
186 | 169 | ||
187 | m_console.Commands.AddCommand( | 170 | m_console.Commands.AddCommand( |
188 | "Objects", | 171 | "Objects", |
@@ -190,7 +173,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
190 | "show part name", | 173 | "show part name", |
191 | "show part name [--regex] <name>", | 174 | "show part name [--regex] <name>", |
192 | "Show details of scene object parts with the given name.", | 175 | "Show details of scene object parts with the given name.", |
193 | "If --regex is specified then the name is treatead as a regular expression", | 176 | "If --regex is specified then the name is treated as a regular expression", |
194 | HandleShowPartByName); | 177 | HandleShowPartByName); |
195 | 178 | ||
196 | m_console.Commands.AddCommand( | 179 | m_console.Commands.AddCommand( |
@@ -199,18 +182,19 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
199 | "show part pos", | 182 | "show part pos", |
200 | "show part pos <start-coord> to <end-coord>", | 183 | "show part pos <start-coord> to <end-coord>", |
201 | "Show details of scene object parts within the given area.", | 184 | "Show details of scene object parts within the given area.", |
202 | "Each component of the coord is comma separated. There must be no spaces between the commas.\n" | 185 | ConsoleUtil.CoordHelp, |
203 | + "If you don't care about the z component you can simply omit it.\n" | ||
204 | + "If you don't care about the x or y components then you can leave them blank (though a comma is still required)\n" | ||
205 | + "If you want to specify the maxmimum value of a component then you can use ~ instead of a number\n" | ||
206 | + "If you want to specify the minimum value of a component then you can use -~ instead of a number\n" | ||
207 | + "e.g.\n" | ||
208 | + "show object pos 20,20,20 to 40,40,40\n" | ||
209 | + "show object pos 20,20 to 40,40\n" | ||
210 | + "show object pos ,20,20 to ,40,40\n" | ||
211 | + "show object pos ,,30 to ,,~\n" | ||
212 | + "show object pos ,,-~ to ,,30", | ||
213 | HandleShowPartByPos); | 186 | HandleShowPartByPos); |
187 | |||
188 | m_console.Commands.AddCommand( | ||
189 | "Objects", | ||
190 | false, | ||
191 | "dump object id", | ||
192 | "dump object id <UUID-or-localID>", | ||
193 | "Dump the formatted serialization of the given object to the file <UUID>.xml", | ||
194 | "e.g. dump object uuid c1ed6809-cc24-4061-a4c2-93082a2d1f1d will dump serialization to c1ed6809-cc24-4061-a4c2-93082a2d1f1d.xml\n" | ||
195 | + "To locate the UUID or localID in the first place, you need to use the other show object commands.\n" | ||
196 | + "If a local ID is given then the filename used is still that for the UUID", | ||
197 | HandleDumpObjectById); | ||
214 | } | 198 | } |
215 | 199 | ||
216 | public void RemoveRegion(Scene scene) | 200 | public void RemoveRegion(Scene scene) |
@@ -265,7 +249,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
265 | m_console.OutputFormat(sb.ToString()); | 249 | m_console.OutputFormat(sb.ToString()); |
266 | } | 250 | } |
267 | 251 | ||
268 | private void HandleShowObjectByUuid(string module, string[] cmdparams) | 252 | private void HandleShowObjectById(string module, string[] cmdparams) |
269 | { | 253 | { |
270 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) | 254 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) |
271 | return; | 255 | return; |
@@ -281,14 +265,17 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
281 | return; | 265 | return; |
282 | } | 266 | } |
283 | 267 | ||
284 | UUID objectUuid; | 268 | UUID uuid; |
285 | if (!UUID.TryParse(mainParams[3], out objectUuid)) | 269 | uint localId; |
286 | { | 270 | if (!ConsoleUtil.TryParseConsoleId(m_console, mainParams[3], out uuid, out localId)) |
287 | m_console.OutputFormat("{0} is not a valid uuid", mainParams[3]); | ||
288 | return; | 271 | return; |
289 | } | ||
290 | 272 | ||
291 | SceneObjectGroup so = m_scene.GetSceneObjectGroup(objectUuid); | 273 | SceneObjectGroup so; |
274 | |||
275 | if (localId != ConsoleUtil.LocalIdNotFound) | ||
276 | so = m_scene.GetSceneObjectGroup(localId); | ||
277 | else | ||
278 | so = m_scene.GetSceneObjectGroup(uuid); | ||
292 | 279 | ||
293 | if (so == null) | 280 | if (so == null) |
294 | { | 281 | { |
@@ -365,7 +352,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
365 | OutputSogsToConsole(searchPredicate, showFull); | 352 | OutputSogsToConsole(searchPredicate, showFull); |
366 | } | 353 | } |
367 | 354 | ||
368 | private void HandleShowPartByUuid(string module, string[] cmdparams) | 355 | private void HandleShowPartById(string module, string[] cmdparams) |
369 | { | 356 | { |
370 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) | 357 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) |
371 | return; | 358 | return; |
@@ -378,18 +365,20 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
378 | 365 | ||
379 | if (mainParams.Count < 4) | 366 | if (mainParams.Count < 4) |
380 | { | 367 | { |
381 | m_console.OutputFormat("Usage: show part uuid [--full] <uuid>"); | 368 | m_console.OutputFormat("Usage: show part id [--full] <UUID-or-localID>"); |
382 | return; | 369 | return; |
383 | } | 370 | } |
384 | 371 | ||
385 | UUID objectUuid; | 372 | UUID objectUuid; |
386 | if (!UUID.TryParse(mainParams[3], out objectUuid)) | 373 | uint localId; |
387 | { | 374 | if (!ConsoleUtil.TryParseConsoleId(m_console, mainParams[3], out objectUuid, out localId)) |
388 | m_console.OutputFormat("{0} is not a valid uuid", mainParams[3]); | ||
389 | return; | 375 | return; |
390 | } | ||
391 | 376 | ||
392 | SceneObjectPart sop = m_scene.GetSceneObjectPart(objectUuid); | 377 | SceneObjectPart sop; |
378 | if (localId == ConsoleUtil.LocalIdNotFound) | ||
379 | sop = m_scene.GetSceneObjectPart(objectUuid); | ||
380 | else | ||
381 | sop = m_scene.GetSceneObjectPart(localId); | ||
393 | 382 | ||
394 | if (sop == null) | 383 | if (sop == null) |
395 | { | 384 | { |
@@ -477,6 +466,51 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
477 | OutputSopsToConsole(searchPredicate, true); | 466 | OutputSopsToConsole(searchPredicate, true); |
478 | } | 467 | } |
479 | 468 | ||
469 | private void HandleDumpObjectById(string module, string[] cmdparams) | ||
470 | { | ||
471 | if (!(m_console.ConsoleScene == null || m_console.ConsoleScene == m_scene)) | ||
472 | return; | ||
473 | |||
474 | if (cmdparams.Length < 4) | ||
475 | { | ||
476 | m_console.OutputFormat("Usage: dump object id <UUID-or-localID>"); | ||
477 | return; | ||
478 | } | ||
479 | |||
480 | UUID objectUuid; | ||
481 | uint localId; | ||
482 | if (!ConsoleUtil.TryParseConsoleId(m_console, cmdparams[3], out objectUuid, out localId)) | ||
483 | return; | ||
484 | |||
485 | SceneObjectGroup so; | ||
486 | if (localId == ConsoleUtil.LocalIdNotFound) | ||
487 | so = m_scene.GetSceneObjectGroup(objectUuid); | ||
488 | else | ||
489 | so = m_scene.GetSceneObjectGroup(localId); | ||
490 | |||
491 | if (so == null) | ||
492 | { | ||
493 | // m_console.OutputFormat("No part found with uuid {0}", objectUuid); | ||
494 | return; | ||
495 | } | ||
496 | |||
497 | // In case we found it via local ID. | ||
498 | objectUuid = so.UUID; | ||
499 | |||
500 | string fileName = string.Format("{0}.xml", objectUuid); | ||
501 | |||
502 | if (!ConsoleUtil.CheckFileDoesNotExist(m_console, fileName)) | ||
503 | return; | ||
504 | |||
505 | using (XmlTextWriter xtw = new XmlTextWriter(fileName, Encoding.UTF8)) | ||
506 | { | ||
507 | xtw.Formatting = Formatting.Indented; | ||
508 | SceneObjectSerializer.ToOriginalXmlFormat(so, xtw, true); | ||
509 | } | ||
510 | |||
511 | m_console.OutputFormat("Object dumped to file {0}", fileName); | ||
512 | } | ||
513 | |||
480 | /// <summary> | 514 | /// <summary> |
481 | /// Append a scene object report to an input StringBuilder | 515 | /// Append a scene object report to an input StringBuilder |
482 | /// </summary> | 516 | /// </summary> |
@@ -572,12 +606,18 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
572 | cdt.AddColumn("Asset UUID", 36); | 606 | cdt.AddColumn("Asset UUID", 36); |
573 | 607 | ||
574 | foreach (TaskInventoryItem item in inv.GetInventoryItems()) | 608 | foreach (TaskInventoryItem item in inv.GetInventoryItems()) |
609 | { | ||
610 | bool foundScriptInstance, scriptRunning; | ||
611 | foundScriptInstance | ||
612 | = SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, item, out scriptRunning); | ||
613 | |||
575 | cdt.AddRow( | 614 | cdt.AddRow( |
576 | item.Name, | 615 | item.Name, |
577 | ((InventoryType)item.InvType).ToString(), | 616 | ((InventoryType)item.InvType).ToString(), |
578 | (InventoryType)item.InvType == InventoryType.LSL ? item.ScriptRunning.ToString() : "n/a", | 617 | foundScriptInstance ? scriptRunning.ToString() : "n/a", |
579 | item.ItemID.ToString(), | 618 | item.ItemID.ToString(), |
580 | item.AssetID.ToString()); | 619 | item.AssetID.ToString()); |
620 | } | ||
581 | 621 | ||
582 | return sb.Append(cdt.ToString()); | 622 | return sb.Append(cdt.ToString()); |
583 | } | 623 | } |
@@ -641,19 +681,24 @@ namespace OpenSim.Region.CoreModules.World.Objects.Commands | |||
641 | 681 | ||
642 | break; | 682 | break; |
643 | 683 | ||
644 | case "uuid": | 684 | case "id": |
645 | if (!UUID.TryParse(o, out match)) | 685 | UUID uuid; |
686 | uint localId; | ||
687 | if (!ConsoleUtil.TryParseConsoleId(m_console, o, out uuid, out localId)) | ||
646 | return; | 688 | return; |
647 | 689 | ||
648 | requireConfirmation = false; | 690 | requireConfirmation = false; |
649 | deletes = new List<SceneObjectGroup>(); | 691 | deletes = new List<SceneObjectGroup>(); |
650 | 692 | ||
651 | m_scene.ForEachSOG(delegate (SceneObjectGroup g) | 693 | SceneObjectGroup so; |
652 | { | 694 | if (localId == ConsoleUtil.LocalIdNotFound) |
653 | if (g.UUID == match && !g.IsAttachment) | 695 | so = m_scene.GetSceneObjectGroup(uuid); |
654 | deletes.Add(g); | 696 | else |
655 | }); | 697 | so = m_scene.GetSceneObjectGroup(localId); |
656 | 698 | ||
699 | if (!so.IsAttachment) | ||
700 | deletes.Add(so); | ||
701 | |||
657 | // if (deletes.Count == 0) | 702 | // if (deletes.Count == 0) |
658 | // m_console.OutputFormat("No objects were found with uuid {0}", match); | 703 | // m_console.OutputFormat("No objects were found with uuid {0}", match); |
659 | 704 | ||
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 7a8a57c..ddaa227 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -37,13 +37,17 @@ using OpenSim.Region.Framework.Interfaces; | |||
37 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Services.Interfaces; | 38 | using OpenSim.Services.Interfaces; |
39 | 39 | ||
40 | using Mono.Addins; | ||
41 | |||
40 | namespace OpenSim.Region.CoreModules.World.Permissions | 42 | namespace OpenSim.Region.CoreModules.World.Permissions |
41 | { | 43 | { |
42 | public class PermissionsModule : IRegionModule, IPermissionsModule | 44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "PermissionsModule")] |
45 | public class PermissionsModule : INonSharedRegionModule, IPermissionsModule | ||
43 | { | 46 | { |
44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 48 | ||
46 | protected Scene m_scene; | 49 | protected Scene m_scene; |
50 | protected bool m_Enabled; | ||
47 | 51 | ||
48 | private InventoryFolderImpl m_libraryRootFolder; | 52 | private InventoryFolderImpl m_libraryRootFolder; |
49 | protected InventoryFolderImpl LibraryRootFolder | 53 | protected InventoryFolderImpl LibraryRootFolder |
@@ -114,18 +118,44 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
114 | private Dictionary<string, bool> GrantVB = new Dictionary<string, bool>(); | 118 | private Dictionary<string, bool> GrantVB = new Dictionary<string, bool>(); |
115 | private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>(); | 119 | private Dictionary<string, bool> GrantJS = new Dictionary<string, bool>(); |
116 | private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>(); | 120 | private Dictionary<string, bool> GrantYP = new Dictionary<string, bool>(); |
121 | |||
117 | private IFriendsModule m_friendsModule; | 122 | private IFriendsModule m_friendsModule; |
123 | private IFriendsModule FriendsModule | ||
124 | { | ||
125 | get | ||
126 | { | ||
127 | if (m_friendsModule == null) | ||
128 | m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | ||
129 | return m_friendsModule; | ||
130 | } | ||
131 | } | ||
118 | private IGroupsModule m_groupsModule; | 132 | private IGroupsModule m_groupsModule; |
119 | private IMoapModule m_moapModule; | 133 | private IGroupsModule GroupsModule |
134 | { | ||
135 | get | ||
136 | { | ||
137 | if (m_groupsModule == null) | ||
138 | m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>(); | ||
139 | return m_groupsModule; | ||
140 | } | ||
141 | } | ||
120 | 142 | ||
143 | private IMoapModule m_moapModule; | ||
144 | private IMoapModule MoapModule | ||
145 | { | ||
146 | get | ||
147 | { | ||
148 | if (m_moapModule == null) | ||
149 | m_moapModule = m_scene.RequestModuleInterface<IMoapModule>(); | ||
150 | return m_moapModule; | ||
151 | } | ||
152 | } | ||
121 | #endregion | 153 | #endregion |
122 | 154 | ||
123 | #region IRegionModule Members | 155 | #region INonSharedRegionModule Members |
124 | 156 | ||
125 | public void Initialise(Scene scene, IConfigSource config) | 157 | public void Initialise(IConfigSource config) |
126 | { | 158 | { |
127 | m_scene = scene; | ||
128 | |||
129 | IConfig myConfig = config.Configs["Startup"]; | 159 | IConfig myConfig = config.Configs["Startup"]; |
130 | 160 | ||
131 | string permissionModules = myConfig.GetString("permissionmodules", "DefaultPermissionsModule"); | 161 | string permissionModules = myConfig.GetString("permissionmodules", "DefaultPermissionsModule"); |
@@ -135,6 +165,8 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
135 | if (!modules.Contains("DefaultPermissionsModule")) | 165 | if (!modules.Contains("DefaultPermissionsModule")) |
136 | return; | 166 | return; |
137 | 167 | ||
168 | m_Enabled = true; | ||
169 | |||
138 | m_allowGridGods = myConfig.GetBoolean("allow_grid_gods", false); | 170 | m_allowGridGods = myConfig.GetBoolean("allow_grid_gods", false); |
139 | m_bypassPermissions = !myConfig.GetBoolean("serverside_object_permissions", true); | 171 | m_bypassPermissions = !myConfig.GetBoolean("serverside_object_permissions", true); |
140 | m_propagatePermissions = myConfig.GetBoolean("propagate_permissions", true); | 172 | m_propagatePermissions = myConfig.GetBoolean("propagate_permissions", true); |
@@ -144,7 +176,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
144 | 176 | ||
145 | m_SimpleBuildPermissions = myConfig.GetBoolean("simple_build_permissions", false); | 177 | m_SimpleBuildPermissions = myConfig.GetBoolean("simple_build_permissions", false); |
146 | 178 | ||
147 | m_allowedScriptCreators | 179 | m_allowedScriptCreators |
148 | = ParseUserSetConfigSetting(myConfig, "allowed_script_creators", m_allowedScriptCreators); | 180 | = ParseUserSetConfigSetting(myConfig, "allowed_script_creators", m_allowedScriptCreators); |
149 | m_allowedScriptEditors | 181 | m_allowedScriptEditors |
150 | = ParseUserSetConfigSetting(myConfig, "allowed_script_editors", m_allowedScriptEditors); | 182 | = ParseUserSetConfigSetting(myConfig, "allowed_script_editors", m_allowedScriptEditors); |
@@ -154,6 +186,64 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
154 | else | 186 | else |
155 | m_log.Debug("[PERMISSIONS]: Enabling all region service permission checks"); | 187 | m_log.Debug("[PERMISSIONS]: Enabling all region service permission checks"); |
156 | 188 | ||
189 | string grant = myConfig.GetString("GrantLSL", ""); | ||
190 | if (grant.Length > 0) | ||
191 | { | ||
192 | foreach (string uuidl in grant.Split(',')) | ||
193 | { | ||
194 | string uuid = uuidl.Trim(" \t".ToCharArray()); | ||
195 | GrantLSL.Add(uuid, true); | ||
196 | } | ||
197 | } | ||
198 | |||
199 | grant = myConfig.GetString("GrantCS", ""); | ||
200 | if (grant.Length > 0) | ||
201 | { | ||
202 | foreach (string uuidl in grant.Split(',')) | ||
203 | { | ||
204 | string uuid = uuidl.Trim(" \t".ToCharArray()); | ||
205 | GrantCS.Add(uuid, true); | ||
206 | } | ||
207 | } | ||
208 | |||
209 | grant = myConfig.GetString("GrantVB", ""); | ||
210 | if (grant.Length > 0) | ||
211 | { | ||
212 | foreach (string uuidl in grant.Split(',')) | ||
213 | { | ||
214 | string uuid = uuidl.Trim(" \t".ToCharArray()); | ||
215 | GrantVB.Add(uuid, true); | ||
216 | } | ||
217 | } | ||
218 | |||
219 | grant = myConfig.GetString("GrantJS", ""); | ||
220 | if (grant.Length > 0) | ||
221 | { | ||
222 | foreach (string uuidl in grant.Split(',')) | ||
223 | { | ||
224 | string uuid = uuidl.Trim(" \t".ToCharArray()); | ||
225 | GrantJS.Add(uuid, true); | ||
226 | } | ||
227 | } | ||
228 | |||
229 | grant = myConfig.GetString("GrantYP", ""); | ||
230 | if (grant.Length > 0) | ||
231 | { | ||
232 | foreach (string uuidl in grant.Split(',')) | ||
233 | { | ||
234 | string uuid = uuidl.Trim(" \t".ToCharArray()); | ||
235 | GrantYP.Add(uuid, true); | ||
236 | } | ||
237 | } | ||
238 | } | ||
239 | |||
240 | public void AddRegion(Scene scene) | ||
241 | { | ||
242 | if (!m_Enabled) | ||
243 | return; | ||
244 | |||
245 | m_scene = scene; | ||
246 | |||
157 | scene.RegisterModuleInterface<IPermissionsModule>(this); | 247 | scene.RegisterModuleInterface<IPermissionsModule>(this); |
158 | 248 | ||
159 | //Register functions with Scene External Checks! | 249 | //Register functions with Scene External Checks! |
@@ -169,44 +259,44 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
169 | m_scene.Permissions.OnIsGridGod += IsGridGod; | 259 | m_scene.Permissions.OnIsGridGod += IsGridGod; |
170 | m_scene.Permissions.OnIsAdministrator += IsAdministrator; | 260 | m_scene.Permissions.OnIsAdministrator += IsAdministrator; |
171 | m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; | 261 | m_scene.Permissions.OnDuplicateObject += CanDuplicateObject; |
172 | m_scene.Permissions.OnDeleteObject += CanDeleteObject; //MAYBE FULLY IMPLEMENTED | 262 | m_scene.Permissions.OnDeleteObject += CanDeleteObject; |
173 | m_scene.Permissions.OnEditObject += CanEditObject; //MAYBE FULLY IMPLEMENTED | 263 | m_scene.Permissions.OnEditObject += CanEditObject; |
174 | m_scene.Permissions.OnEditParcelProperties += CanEditParcelProperties; //MAYBE FULLY IMPLEMENTED | 264 | m_scene.Permissions.OnEditParcelProperties += CanEditParcelProperties; |
175 | m_scene.Permissions.OnInstantMessage += CanInstantMessage; | 265 | m_scene.Permissions.OnInstantMessage += CanInstantMessage; |
176 | m_scene.Permissions.OnInventoryTransfer += CanInventoryTransfer; //NOT YET IMPLEMENTED | 266 | m_scene.Permissions.OnInventoryTransfer += CanInventoryTransfer; |
177 | m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; //FULLY IMPLEMENTED | 267 | m_scene.Permissions.OnIssueEstateCommand += CanIssueEstateCommand; |
178 | m_scene.Permissions.OnMoveObject += CanMoveObject; //MAYBE FULLY IMPLEMENTED | 268 | m_scene.Permissions.OnMoveObject += CanMoveObject; |
179 | m_scene.Permissions.OnObjectEntry += CanObjectEntry; | 269 | m_scene.Permissions.OnObjectEntry += CanObjectEntry; |
180 | m_scene.Permissions.OnReturnObjects += CanReturnObjects; //NOT YET IMPLEMENTED | 270 | m_scene.Permissions.OnReturnObjects += CanReturnObjects; |
181 | m_scene.Permissions.OnRezObject += CanRezObject; //MAYBE FULLY IMPLEMENTED | 271 | m_scene.Permissions.OnRezObject += CanRezObject; |
182 | m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand; | 272 | m_scene.Permissions.OnRunConsoleCommand += CanRunConsoleCommand; |
183 | m_scene.Permissions.OnRunScript += CanRunScript; //NOT YET IMPLEMENTED | 273 | m_scene.Permissions.OnRunScript += CanRunScript; |
184 | m_scene.Permissions.OnCompileScript += CanCompileScript; | 274 | m_scene.Permissions.OnCompileScript += CanCompileScript; |
185 | m_scene.Permissions.OnSellParcel += CanSellParcel; | 275 | m_scene.Permissions.OnSellParcel += CanSellParcel; |
186 | m_scene.Permissions.OnTakeObject += CanTakeObject; | 276 | m_scene.Permissions.OnTakeObject += CanTakeObject; |
187 | m_scene.Permissions.OnTakeCopyObject += CanTakeCopyObject; | 277 | m_scene.Permissions.OnTakeCopyObject += CanTakeCopyObject; |
188 | m_scene.Permissions.OnTerraformLand += CanTerraformLand; | 278 | m_scene.Permissions.OnTerraformLand += CanTerraformLand; |
189 | m_scene.Permissions.OnLinkObject += CanLinkObject; //NOT YET IMPLEMENTED | 279 | m_scene.Permissions.OnLinkObject += CanLinkObject; |
190 | m_scene.Permissions.OnDelinkObject += CanDelinkObject; //NOT YET IMPLEMENTED | 280 | m_scene.Permissions.OnDelinkObject += CanDelinkObject; |
191 | m_scene.Permissions.OnBuyLand += CanBuyLand; //NOT YET IMPLEMENTED | 281 | m_scene.Permissions.OnBuyLand += CanBuyLand; |
192 | 282 | ||
193 | m_scene.Permissions.OnViewNotecard += CanViewNotecard; //NOT YET IMPLEMENTED | 283 | m_scene.Permissions.OnViewNotecard += CanViewNotecard; |
194 | m_scene.Permissions.OnViewScript += CanViewScript; //NOT YET IMPLEMENTED | 284 | m_scene.Permissions.OnViewScript += CanViewScript; |
195 | m_scene.Permissions.OnEditNotecard += CanEditNotecard; //NOT YET IMPLEMENTED | 285 | m_scene.Permissions.OnEditNotecard += CanEditNotecard; |
196 | m_scene.Permissions.OnEditScript += CanEditScript; //NOT YET IMPLEMENTED | 286 | m_scene.Permissions.OnEditScript += CanEditScript; |
197 | 287 | ||
198 | m_scene.Permissions.OnCreateObjectInventory += CanCreateObjectInventory; | 288 | m_scene.Permissions.OnCreateObjectInventory += CanCreateObjectInventory; |
199 | m_scene.Permissions.OnEditObjectInventory += CanEditObjectInventory;//MAYBE FULLY IMPLEMENTED | 289 | m_scene.Permissions.OnEditObjectInventory += CanEditObjectInventory; |
200 | m_scene.Permissions.OnCopyObjectInventory += CanCopyObjectInventory; //NOT YET IMPLEMENTED | 290 | m_scene.Permissions.OnCopyObjectInventory += CanCopyObjectInventory; |
201 | m_scene.Permissions.OnDeleteObjectInventory += CanDeleteObjectInventory; //NOT YET IMPLEMENTED | 291 | m_scene.Permissions.OnDeleteObjectInventory += CanDeleteObjectInventory; |
202 | m_scene.Permissions.OnResetScript += CanResetScript; | 292 | m_scene.Permissions.OnResetScript += CanResetScript; |
203 | 293 | ||
204 | m_scene.Permissions.OnCreateUserInventory += CanCreateUserInventory; //NOT YET IMPLEMENTED | 294 | m_scene.Permissions.OnCreateUserInventory += CanCreateUserInventory; |
205 | m_scene.Permissions.OnCopyUserInventory += CanCopyUserInventory; //NOT YET IMPLEMENTED | 295 | m_scene.Permissions.OnCopyUserInventory += CanCopyUserInventory; |
206 | m_scene.Permissions.OnEditUserInventory += CanEditUserInventory; //NOT YET IMPLEMENTED | 296 | m_scene.Permissions.OnEditUserInventory += CanEditUserInventory; |
207 | m_scene.Permissions.OnDeleteUserInventory += CanDeleteUserInventory; //NOT YET IMPLEMENTED | 297 | m_scene.Permissions.OnDeleteUserInventory += CanDeleteUserInventory; |
208 | 298 | ||
209 | m_scene.Permissions.OnTeleport += CanTeleport; //NOT YET IMPLEMENTED | 299 | m_scene.Permissions.OnTeleport += CanTeleport; |
210 | 300 | ||
211 | m_scene.Permissions.OnControlPrimMedia += CanControlPrimMedia; | 301 | m_scene.Permissions.OnControlPrimMedia += CanControlPrimMedia; |
212 | m_scene.Permissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia; | 302 | m_scene.Permissions.OnInteractWithPrimMedia += CanInteractWithPrimMedia; |
@@ -226,52 +316,38 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
226 | "Turn on permissions debugging", | 316 | "Turn on permissions debugging", |
227 | HandleDebugPermissions); | 317 | HandleDebugPermissions); |
228 | 318 | ||
229 | string grant = myConfig.GetString("GrantLSL",""); | 319 | } |
230 | if (grant.Length > 0) { | ||
231 | foreach (string uuidl in grant.Split(',')) { | ||
232 | string uuid = uuidl.Trim(" \t".ToCharArray()); | ||
233 | GrantLSL.Add(uuid, true); | ||
234 | } | ||
235 | } | ||
236 | 320 | ||
237 | grant = myConfig.GetString("GrantCS",""); | 321 | public void RegionLoaded(Scene scene) |
238 | if (grant.Length > 0) { | 322 | { |
239 | foreach (string uuidl in grant.Split(',')) { | 323 | } |
240 | string uuid = uuidl.Trim(" \t".ToCharArray()); | ||
241 | GrantCS.Add(uuid, true); | ||
242 | } | ||
243 | } | ||
244 | 324 | ||
245 | grant = myConfig.GetString("GrantVB",""); | 325 | public void RemoveRegion(Scene scene) |
246 | if (grant.Length > 0) { | 326 | { |
247 | foreach (string uuidl in grant.Split(',')) { | 327 | if (!m_Enabled) |
248 | string uuid = uuidl.Trim(" \t".ToCharArray()); | 328 | return; |
249 | GrantVB.Add(uuid, true); | ||
250 | } | ||
251 | } | ||
252 | 329 | ||
253 | grant = myConfig.GetString("GrantJS", ""); | 330 | m_scene.UnregisterModuleInterface<IPermissionsModule>(this); |
254 | if (grant.Length > 0) | 331 | } |
255 | { | ||
256 | foreach (string uuidl in grant.Split(',')) | ||
257 | { | ||
258 | string uuid = uuidl.Trim(" \t".ToCharArray()); | ||
259 | GrantJS.Add(uuid, true); | ||
260 | } | ||
261 | } | ||
262 | 332 | ||
263 | grant = myConfig.GetString("GrantYP", ""); | 333 | public void Close() |
264 | if (grant.Length > 0) | 334 | { |
265 | { | 335 | } |
266 | foreach (string uuidl in grant.Split(',')) | 336 | |
267 | { | 337 | public string Name |
268 | string uuid = uuidl.Trim(" \t".ToCharArray()); | 338 | { |
269 | GrantYP.Add(uuid, true); | 339 | get { return "PermissionsModule"; } |
270 | } | 340 | } |
271 | } | ||
272 | 341 | ||
342 | public Type ReplaceableInterface | ||
343 | { | ||
344 | get { return null; } | ||
273 | } | 345 | } |
274 | 346 | ||
347 | #endregion | ||
348 | |||
349 | #region Console command handlers | ||
350 | |||
275 | public void HandleBypassPermissions(string module, string[] args) | 351 | public void HandleBypassPermissions(string module, string[] args) |
276 | { | 352 | { |
277 | if (m_scene.ConsoleScene() != null && | 353 | if (m_scene.ConsoleScene() != null && |
@@ -290,7 +366,7 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
290 | m_bypassPermissions = val; | 366 | m_bypassPermissions = val; |
291 | 367 | ||
292 | m_log.InfoFormat( | 368 | m_log.InfoFormat( |
293 | "[PERMISSIONS]: Set permissions bypass to {0} for {1}", | 369 | "[PERMISSIONS]: Set permissions bypass to {0} for {1}", |
294 | m_bypassPermissions, m_scene.RegionInfo.RegionName); | 370 | m_bypassPermissions, m_scene.RegionInfo.RegionName); |
295 | } | 371 | } |
296 | } | 372 | } |
@@ -343,39 +419,6 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
343 | } | 419 | } |
344 | } | 420 | } |
345 | 421 | ||
346 | public void PostInitialise() | ||
347 | { | ||
348 | m_friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | ||
349 | |||
350 | if (m_friendsModule == null) | ||
351 | m_log.Debug("[PERMISSIONS]: Friends module not found, friend permissions will not work"); | ||
352 | |||
353 | m_groupsModule = m_scene.RequestModuleInterface<IGroupsModule>(); | ||
354 | |||
355 | if (m_groupsModule == null) | ||
356 | m_log.Debug("[PERMISSIONS]: Groups module not found, group permissions will not work"); | ||
357 | |||
358 | m_moapModule = m_scene.RequestModuleInterface<IMoapModule>(); | ||
359 | |||
360 | // This log line will be commented out when no longer required for debugging | ||
361 | // if (m_moapModule == null) | ||
362 | // m_log.Warn("[PERMISSIONS]: Media on a prim module not found, media on a prim permissions will not work"); | ||
363 | } | ||
364 | |||
365 | public void Close() | ||
366 | { | ||
367 | } | ||
368 | |||
369 | public string Name | ||
370 | { | ||
371 | get { return "PermissionsModule"; } | ||
372 | } | ||
373 | |||
374 | public bool IsSharedModule | ||
375 | { | ||
376 | get { return false; } | ||
377 | } | ||
378 | |||
379 | #endregion | 422 | #endregion |
380 | 423 | ||
381 | #region Helper Functions | 424 | #region Helper Functions |
@@ -400,10 +443,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
400 | /// <returns></returns> | 443 | /// <returns></returns> |
401 | protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers) | 444 | protected bool IsGroupMember(UUID groupID, UUID userID, ulong powers) |
402 | { | 445 | { |
403 | if (null == m_groupsModule) | 446 | if (null == GroupsModule) |
404 | return false; | 447 | return false; |
405 | 448 | ||
406 | GroupMembershipData gmd = m_groupsModule.GetMembershipData(groupID, userID); | 449 | GroupMembershipData gmd = GroupsModule.GetMembershipData(groupID, userID); |
407 | 450 | ||
408 | if (gmd != null) | 451 | if (gmd != null) |
409 | { | 452 | { |
@@ -503,10 +546,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
503 | if (user == UUID.Zero) | 546 | if (user == UUID.Zero) |
504 | return false; | 547 | return false; |
505 | 548 | ||
506 | if (m_friendsModule == null) | 549 | if (FriendsModule == null) |
507 | return false; | 550 | return false; |
508 | 551 | ||
509 | int friendPerms = m_friendsModule.GetRightsGrantedByFriend(user, objectOwner); | 552 | int friendPerms = FriendsModule.GetRightsGrantedByFriend(user, objectOwner); |
510 | return (friendPerms & (int)FriendRights.CanModifyObjects) != 0; | 553 | return (friendPerms & (int)FriendRights.CanModifyObjects) != 0; |
511 | } | 554 | } |
512 | 555 | ||
@@ -1915,14 +1958,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1915 | // "[PERMISSONS]: Performing CanControlPrimMedia check with agentID {0}, primID {1}, face {2}", | 1958 | // "[PERMISSONS]: Performing CanControlPrimMedia check with agentID {0}, primID {1}, face {2}", |
1916 | // agentID, primID, face); | 1959 | // agentID, primID, face); |
1917 | 1960 | ||
1918 | if (null == m_moapModule) | 1961 | if (null == MoapModule) |
1919 | return false; | 1962 | return false; |
1920 | 1963 | ||
1921 | SceneObjectPart part = m_scene.GetSceneObjectPart(primID); | 1964 | SceneObjectPart part = m_scene.GetSceneObjectPart(primID); |
1922 | if (null == part) | 1965 | if (null == part) |
1923 | return false; | 1966 | return false; |
1924 | 1967 | ||
1925 | MediaEntry me = m_moapModule.GetMediaEntry(part, face); | 1968 | MediaEntry me = MoapModule.GetMediaEntry(part, face); |
1926 | 1969 | ||
1927 | // If there is no existing media entry then it can be controlled (in this context, created). | 1970 | // If there is no existing media entry then it can be controlled (in this context, created). |
1928 | if (null == me) | 1971 | if (null == me) |
@@ -1941,14 +1984,14 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1941 | // "[PERMISSONS]: Performing CanInteractWithPrimMedia check with agentID {0}, primID {1}, face {2}", | 1984 | // "[PERMISSONS]: Performing CanInteractWithPrimMedia check with agentID {0}, primID {1}, face {2}", |
1942 | // agentID, primID, face); | 1985 | // agentID, primID, face); |
1943 | 1986 | ||
1944 | if (null == m_moapModule) | 1987 | if (null == MoapModule) |
1945 | return false; | 1988 | return false; |
1946 | 1989 | ||
1947 | SceneObjectPart part = m_scene.GetSceneObjectPart(primID); | 1990 | SceneObjectPart part = m_scene.GetSceneObjectPart(primID); |
1948 | if (null == part) | 1991 | if (null == part) |
1949 | return false; | 1992 | return false; |
1950 | 1993 | ||
1951 | MediaEntry me = m_moapModule.GetMediaEntry(part, face); | 1994 | MediaEntry me = MoapModule.GetMediaEntry(part, face); |
1952 | 1995 | ||
1953 | // If there is no existing media entry then it can be controlled (in this context, created). | 1996 | // If there is no existing media entry then it can be controlled (in this context, created). |
1954 | if (null == me) | 1997 | if (null == me) |
diff --git a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs index fea4de0..249a40d 100644 --- a/OpenSim/Region/CoreModules/World/Region/RestartModule.cs +++ b/OpenSim/Region/CoreModules/World/Region/RestartModule.cs | |||
@@ -26,6 +26,7 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Linq; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using System.Timers; | 31 | using System.Timers; |
31 | using System.Threading; | 32 | using System.Threading; |
@@ -264,7 +265,10 @@ namespace OpenSim.Region.CoreModules.World.Region | |||
264 | for (int i = 4 ; i < args.Length ; i++) | 265 | for (int i = 4 ; i < args.Length ; i++) |
265 | times.Add(Convert.ToInt32(args[i])); | 266 | times.Add(Convert.ToInt32(args[i])); |
266 | 267 | ||
268 | MainConsole.Instance.OutputFormat( | ||
269 | "Region {0} scheduled for restart in {1} seconds", m_Scene.Name, times.Sum()); | ||
270 | |||
267 | ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); | 271 | ScheduleRestart(UUID.Zero, args[3], times.ToArray(), notice); |
268 | } | 272 | } |
269 | } | 273 | } |
270 | } | 274 | } \ No newline at end of file |
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs b/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs index 0e861a1..e0247d9 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/SerialiserModule.cs | |||
@@ -32,6 +32,7 @@ using System.Reflection; | |||
32 | 32 | ||
33 | using log4net; | 33 | using log4net; |
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using Mono.Addins; | ||
35 | 36 | ||
36 | using OpenMetaverse; | 37 | using OpenMetaverse; |
37 | using OpenSim.Region.CoreModules.Framework.InterfaceCommander; | 38 | using OpenSim.Region.CoreModules.Framework.InterfaceCommander; |
@@ -41,6 +42,7 @@ using OpenSim.Region.Framework.Scenes.Serialization; | |||
41 | 42 | ||
42 | namespace OpenSim.Region.CoreModules.World.Serialiser | 43 | namespace OpenSim.Region.CoreModules.World.Serialiser |
43 | { | 44 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SerialiserModule")] | ||
44 | public class SerialiserModule : ISharedRegionModule, IRegionSerialiserModule | 46 | public class SerialiserModule : ISharedRegionModule, IRegionSerialiserModule |
45 | { | 47 | { |
46 | private static readonly ILog m_log = | 48 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs index 7825e3e..bcb8e2f 100644 --- a/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs +++ b/OpenSim/Region/CoreModules/World/Serialiser/Tests/SerialiserTests.cs | |||
@@ -39,7 +39,7 @@ using OpenSim.Tests.Common; | |||
39 | namespace OpenSim.Region.CoreModules.World.Serialiser.Tests | 39 | namespace OpenSim.Region.CoreModules.World.Serialiser.Tests |
40 | { | 40 | { |
41 | [TestFixture] | 41 | [TestFixture] |
42 | public class SerialiserTests | 42 | public class SerialiserTests : OpenSimTestCase |
43 | { | 43 | { |
44 | private string xml = @" | 44 | private string xml = @" |
45 | <SceneObjectGroup> | 45 | <SceneObjectGroup> |
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index a2f0950..089fcda 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -24,56 +24,110 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | |||
28 | using System; | 27 | using System; |
28 | using System.IO; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | |||
29 | using Nini.Config; | 32 | using Nini.Config; |
30 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using log4net; | ||
35 | using Mono.Addins; | ||
36 | |||
31 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
32 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
33 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
34 | using System.Reflection; | ||
35 | using log4net; | ||
36 | 40 | ||
37 | namespace OpenSim.Region.CoreModules.World.Sound | 41 | namespace OpenSim.Region.CoreModules.World.Sound |
38 | { | 42 | { |
39 | public class SoundModule : IRegionModule, ISoundModule | 43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SoundModule")] |
44 | public class SoundModule : INonSharedRegionModule, ISoundModule | ||
40 | { | 45 | { |
41 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | // private static readonly ILog m_log = LogManager.GetLogger( |
42 | 47 | // MethodBase.GetCurrentMethod().DeclaringType); | |
43 | protected Scene m_scene; | 48 | |
44 | 49 | private Scene m_scene; | |
45 | public void Initialise(Scene scene, IConfigSource source) | 50 | |
51 | public bool Enabled { get; private set; } | ||
52 | |||
53 | public float MaxDistance { get; private set; } | ||
54 | |||
55 | #region INonSharedRegionModule | ||
56 | |||
57 | public void Initialise(IConfigSource configSource) | ||
58 | { | ||
59 | IConfig config = configSource.Configs["Sounds"]; | ||
60 | |||
61 | if (config == null) | ||
62 | { | ||
63 | Enabled = true; | ||
64 | MaxDistance = 100.0f; | ||
65 | } | ||
66 | else | ||
67 | { | ||
68 | Enabled = config.GetString("Module", "OpenSim.Region.CoreModules.dll:SoundModule") == | ||
69 | Path.GetFileName(Assembly.GetExecutingAssembly().Location) | ||
70 | + ":" + MethodBase.GetCurrentMethod().DeclaringType.Name; | ||
71 | MaxDistance = config.GetFloat("MaxDistance", 100.0f); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | public void AddRegion(Scene scene) { } | ||
76 | |||
77 | public void RemoveRegion(Scene scene) | ||
46 | { | 78 | { |
79 | m_scene.EventManager.OnClientLogin -= OnNewClient; | ||
80 | } | ||
81 | |||
82 | public void RegionLoaded(Scene scene) | ||
83 | { | ||
84 | if (!Enabled) | ||
85 | return; | ||
86 | |||
47 | m_scene = scene; | 87 | m_scene = scene; |
48 | 88 | m_scene.EventManager.OnClientLogin += OnNewClient; | |
49 | m_scene.EventManager.OnNewClient += OnNewClient; | 89 | |
50 | |||
51 | m_scene.RegisterModuleInterface<ISoundModule>(this); | 90 | m_scene.RegisterModuleInterface<ISoundModule>(this); |
52 | } | 91 | } |
53 | 92 | ||
54 | public void PostInitialise() {} | 93 | public void Close() { } |
55 | public void Close() {} | 94 | |
95 | public Type ReplaceableInterface | ||
96 | { | ||
97 | get { return typeof(ISoundModule); } | ||
98 | } | ||
99 | |||
56 | public string Name { get { return "Sound Module"; } } | 100 | public string Name { get { return "Sound Module"; } } |
57 | public bool IsSharedModule { get { return false; } } | 101 | |
58 | 102 | #endregion | |
103 | |||
104 | #region Event Handlers | ||
105 | |||
59 | private void OnNewClient(IClientAPI client) | 106 | private void OnNewClient(IClientAPI client) |
60 | { | 107 | { |
61 | client.OnSoundTrigger += TriggerSound; | 108 | client.OnSoundTrigger += TriggerSound; |
62 | } | 109 | } |
63 | 110 | ||
111 | #endregion | ||
112 | |||
113 | #region ISoundModule | ||
114 | |||
64 | public virtual void PlayAttachedSound( | 115 | public virtual void PlayAttachedSound( |
65 | UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius) | 116 | UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius) |
66 | { | 117 | { |
67 | SceneObjectPart part = m_scene.GetSceneObjectPart(objectID); | 118 | SceneObjectPart part; |
68 | if (part == null) | 119 | if (!m_scene.TryGetSceneObjectPart(objectID, out part)) |
69 | return; | 120 | return; |
70 | 121 | ||
71 | SceneObjectGroup grp = part.ParentGroup; | 122 | SceneObjectGroup grp = part.ParentGroup; |
72 | 123 | ||
124 | if (radius == 0) | ||
125 | radius = MaxDistance; | ||
126 | |||
73 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 127 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) |
74 | { | 128 | { |
75 | double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); | 129 | double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); |
76 | if (dis > 100.0) // Max audio distance | 130 | if (dis > MaxDistance) // Max audio distance |
77 | return; | 131 | return; |
78 | 132 | ||
79 | if (grp.IsAttachment) | 133 | if (grp.IsAttachment) |
@@ -85,26 +139,22 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
85 | dis = 0; | 139 | dis = 0; |
86 | } | 140 | } |
87 | 141 | ||
88 | float thisSpGain; | ||
89 | |||
90 | // Scale by distance | 142 | // Scale by distance |
91 | if (radius == 0) | 143 | double thisSpGain = gain * ((radius - dis) / radius); |
92 | thisSpGain = (float)((double)gain * ((100.0 - dis) / 100.0)); | ||
93 | else | ||
94 | thisSpGain = (float)((double)gain * ((radius - dis) / radius)); | ||
95 | 144 | ||
96 | sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, thisSpGain, flags); | 145 | sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, |
146 | ownerID, (float)thisSpGain, flags); | ||
97 | }); | 147 | }); |
98 | } | 148 | } |
99 | 149 | ||
100 | public virtual void TriggerSound( | 150 | public virtual void TriggerSound( |
101 | UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius) | 151 | UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius) |
102 | { | 152 | { |
103 | SceneObjectPart part = m_scene.GetSceneObjectPart(objectID); | 153 | SceneObjectPart part; |
104 | if (part == null) | 154 | if (!m_scene.TryGetSceneObjectPart(objectID, out part)) |
105 | { | 155 | { |
106 | ScenePresence sp; | 156 | ScenePresence sp; |
107 | if (!m_scene.TryGetScenePresence(objectID, out sp)) | 157 | if (!m_scene.TryGetScenePresence(ownerID, out sp)) |
108 | return; | 158 | return; |
109 | } | 159 | } |
110 | else | 160 | else |
@@ -118,24 +168,207 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
118 | } | 168 | } |
119 | } | 169 | } |
120 | 170 | ||
171 | if (radius == 0) | ||
172 | radius = MaxDistance; | ||
173 | |||
121 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 174 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) |
122 | { | 175 | { |
123 | double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); | 176 | double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); |
124 | 177 | ||
125 | if (dis > 100.0) // Max audio distance | 178 | if (dis > MaxDistance) // Max audio distance |
126 | return; | 179 | return; |
127 | 180 | ||
128 | float thisSpGain; | ||
129 | |||
130 | // Scale by distance | 181 | // Scale by distance |
131 | if (radius == 0) | 182 | double thisSpGain = gain * ((radius - dis) / radius); |
132 | thisSpGain = (float)((double)gain * ((100.0 - dis) / 100.0)); | 183 | |
184 | sp.ControllingClient.SendTriggeredSound(soundId, ownerID, | ||
185 | objectID, parentID, handle, position, | ||
186 | (float)thisSpGain); | ||
187 | }); | ||
188 | } | ||
189 | |||
190 | public virtual void StopSound(UUID objectID) | ||
191 | { | ||
192 | SceneObjectPart m_host; | ||
193 | if (!m_scene.TryGetSceneObjectPart(objectID, out m_host)) | ||
194 | return; | ||
195 | |||
196 | StopSound(m_host); | ||
197 | } | ||
198 | |||
199 | private static void StopSound(SceneObjectPart m_host) | ||
200 | { | ||
201 | m_host.AdjustSoundGain(0); | ||
202 | // Xantor 20080528: Clear prim data of sound instead | ||
203 | if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host)) | ||
204 | { | ||
205 | if (m_host.ParentGroup.LoopSoundMasterPrim == m_host) | ||
206 | { | ||
207 | foreach (SceneObjectPart part in m_host.ParentGroup.LoopSoundSlavePrims) | ||
208 | { | ||
209 | part.Sound = UUID.Zero; | ||
210 | part.SoundFlags = 1 << 5; | ||
211 | part.SoundRadius = 0; | ||
212 | part.ScheduleFullUpdate(); | ||
213 | part.SendFullUpdateToAllClients(); | ||
214 | } | ||
215 | m_host.ParentGroup.LoopSoundMasterPrim = null; | ||
216 | m_host.ParentGroup.LoopSoundSlavePrims.Clear(); | ||
217 | } | ||
133 | else | 218 | else |
134 | thisSpGain = (float)((double)gain * ((radius - dis) / radius)); | 219 | { |
220 | m_host.Sound = UUID.Zero; | ||
221 | m_host.SoundFlags = 1 << 5; | ||
222 | m_host.SoundRadius = 0; | ||
223 | m_host.ScheduleFullUpdate(); | ||
224 | m_host.SendFullUpdateToAllClients(); | ||
225 | } | ||
226 | } | ||
227 | else | ||
228 | { | ||
229 | m_host.Sound = UUID.Zero; | ||
230 | m_host.SoundFlags = 1 << 5; | ||
231 | m_host.SoundRadius = 0; | ||
232 | m_host.ScheduleFullUpdate(); | ||
233 | m_host.SendFullUpdateToAllClients(); | ||
234 | } | ||
235 | } | ||
135 | 236 | ||
136 | sp.ControllingClient.SendTriggeredSound( | 237 | public virtual void PreloadSound(UUID objectID, UUID soundID, float radius) |
137 | soundId, ownerID, objectID, parentID, handle, position, thisSpGain); | 238 | { |
239 | SceneObjectPart part; | ||
240 | if (soundID == UUID.Zero | ||
241 | || !m_scene.TryGetSceneObjectPart(objectID, out part)) | ||
242 | { | ||
243 | return; | ||
244 | } | ||
245 | |||
246 | if (radius == 0) | ||
247 | radius = MaxDistance; | ||
248 | |||
249 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | ||
250 | { | ||
251 | if (!(Util.GetDistanceTo(sp.AbsolutePosition, part.AbsolutePosition) >= MaxDistance)) | ||
252 | sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); | ||
138 | }); | 253 | }); |
139 | } | 254 | } |
255 | |||
256 | // Xantor 20080528 we should do this differently. | ||
257 | // 1) apply the sound to the object | ||
258 | // 2) schedule full update | ||
259 | // just sending the sound out once doesn't work so well when other avatars come in view later on | ||
260 | // or when the prim gets moved, changed, sat on, whatever | ||
261 | // see large number of mantises (mantes?) | ||
262 | // 20080530 Updated to remove code duplication | ||
263 | // 20080530 Stop sound if there is one, otherwise volume only changes don't work | ||
264 | public void LoopSound(UUID objectID, UUID soundID, | ||
265 | double volume, double radius, bool isMaster) | ||
266 | { | ||
267 | SceneObjectPart m_host; | ||
268 | if (!m_scene.TryGetSceneObjectPart(objectID, out m_host)) | ||
269 | return; | ||
270 | |||
271 | if (isMaster) | ||
272 | m_host.ParentGroup.LoopSoundMasterPrim = m_host; | ||
273 | |||
274 | if (m_host.Sound != UUID.Zero) | ||
275 | StopSound(m_host); | ||
276 | |||
277 | m_host.Sound = soundID; | ||
278 | m_host.SoundGain = volume; | ||
279 | m_host.SoundFlags = 1; // looping | ||
280 | m_host.SoundRadius = radius; | ||
281 | |||
282 | m_host.ScheduleFullUpdate(); | ||
283 | m_host.SendFullUpdateToAllClients(); | ||
284 | } | ||
285 | |||
286 | public void SendSound(UUID objectID, UUID soundID, double volume, | ||
287 | bool triggered, byte flags, float radius, bool useMaster, | ||
288 | bool isMaster) | ||
289 | { | ||
290 | if (soundID == UUID.Zero) | ||
291 | return; | ||
292 | |||
293 | SceneObjectPart part; | ||
294 | if (!m_scene.TryGetSceneObjectPart(objectID, out part)) | ||
295 | return; | ||
296 | |||
297 | volume = Util.Clip((float)volume, 0, 1); | ||
298 | |||
299 | UUID parentID = part.ParentGroup.UUID; | ||
300 | |||
301 | Vector3 position = part.AbsolutePosition; // region local | ||
302 | ulong regionHandle = m_scene.RegionInfo.RegionHandle; | ||
303 | |||
304 | if (useMaster) | ||
305 | { | ||
306 | if (isMaster) | ||
307 | { | ||
308 | if (triggered) | ||
309 | TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius); | ||
310 | else | ||
311 | PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius); | ||
312 | part.ParentGroup.PlaySoundMasterPrim = part; | ||
313 | if (triggered) | ||
314 | TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius); | ||
315 | else | ||
316 | PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius); | ||
317 | foreach (SceneObjectPart prim in part.ParentGroup.PlaySoundSlavePrims) | ||
318 | { | ||
319 | position = prim.AbsolutePosition; // region local | ||
320 | if (triggered) | ||
321 | TriggerSound(soundID, part.OwnerID, prim.UUID, parentID, volume, position, regionHandle, radius); | ||
322 | else | ||
323 | PlayAttachedSound(soundID, part.OwnerID, prim.UUID, volume, position, flags, radius); | ||
324 | } | ||
325 | part.ParentGroup.PlaySoundSlavePrims.Clear(); | ||
326 | part.ParentGroup.PlaySoundMasterPrim = null; | ||
327 | } | ||
328 | else | ||
329 | { | ||
330 | part.ParentGroup.PlaySoundSlavePrims.Add(part); | ||
331 | } | ||
332 | } | ||
333 | else | ||
334 | { | ||
335 | if (triggered) | ||
336 | TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius); | ||
337 | else | ||
338 | PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius); | ||
339 | } | ||
340 | } | ||
341 | |||
342 | public void TriggerSoundLimited(UUID objectID, UUID sound, | ||
343 | double volume, Vector3 min, Vector3 max) | ||
344 | { | ||
345 | if (sound == UUID.Zero) | ||
346 | return; | ||
347 | |||
348 | SceneObjectPart part; | ||
349 | if (!m_scene.TryGetSceneObjectPart(objectID, out part)) | ||
350 | return; | ||
351 | |||
352 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | ||
353 | { | ||
354 | double dis = Util.GetDistanceTo(sp.AbsolutePosition, | ||
355 | part.AbsolutePosition); | ||
356 | |||
357 | if (dis > MaxDistance) // Max audio distance | ||
358 | return; | ||
359 | else if (!Util.IsInsideBox(sp.AbsolutePosition, min, max)) | ||
360 | return; | ||
361 | |||
362 | // Scale by distance | ||
363 | double thisSpGain = volume * ((MaxDistance - dis) / MaxDistance); | ||
364 | |||
365 | sp.ControllingClient.SendTriggeredSound(sound, part.OwnerID, | ||
366 | part.UUID, part.ParentGroup.UUID, | ||
367 | m_scene.RegionInfo.RegionHandle, | ||
368 | part.AbsolutePosition, (float)thisSpGain); | ||
369 | }); | ||
370 | } | ||
371 | |||
372 | #endregion | ||
140 | } | 373 | } |
141 | } | 374 | } |
diff --git a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs index 9a954b8..a321c09 100644 --- a/OpenSim/Region/CoreModules/World/Sun/SunModule.cs +++ b/OpenSim/Region/CoreModules/World/Sun/SunModule.cs | |||
@@ -29,6 +29,7 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using log4net; | 31 | using log4net; |
32 | using Mono.Addins; | ||
32 | using Nini.Config; | 33 | using Nini.Config; |
33 | using OpenMetaverse; | 34 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
@@ -37,6 +38,7 @@ using OpenSim.Region.Framework.Scenes; | |||
37 | 38 | ||
38 | namespace OpenSim.Region.CoreModules | 39 | namespace OpenSim.Region.CoreModules |
39 | { | 40 | { |
41 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SunModule")] | ||
40 | public class SunModule : ISunModule | 42 | public class SunModule : ISunModule |
41 | { | 43 | { |
42 | /// <summary> | 44 | /// <summary> |
@@ -267,26 +269,17 @@ namespace OpenSim.Region.CoreModules | |||
267 | return GetCurrentSunHour() + 6.0f; | 269 | return GetCurrentSunHour() + 6.0f; |
268 | } | 270 | } |
269 | 271 | ||
270 | #region IRegion Methods | 272 | #region INonSharedRegion Methods |
271 | 273 | ||
272 | // Called immediately after the module is loaded for a given region | 274 | // Called immediately after the module is loaded for a given region |
273 | // i.e. Immediately after instance creation. | 275 | // i.e. Immediately after instance creation. |
274 | public void Initialise(Scene scene, IConfigSource config) | 276 | public void Initialise(IConfigSource config) |
275 | { | 277 | { |
276 | m_scene = scene; | ||
277 | m_frame = 0; | 278 | m_frame = 0; |
278 | 279 | ||
279 | // This one puts an entry in the main help screen | 280 | // This one puts an entry in the main help screen |
280 | // m_scene.AddCommand("Regions", this, "sun", "sun", "Usage: sun [param] [value] - Get or Update Sun module paramater", null); | 281 | // m_scene.AddCommand("Regions", this, "sun", "sun", "Usage: sun [param] [value] - Get or Update Sun module paramater", null); |
281 | 282 | ||
282 | // This one enables the ability to type just "sun" without any parameters | ||
283 | // m_scene.AddCommand("Regions", this, "sun", "", "", HandleSunConsoleCommand); | ||
284 | foreach (KeyValuePair<string, string> kvp in GetParamList()) | ||
285 | { | ||
286 | string sunCommand = string.Format("sun {0}", kvp.Key); | ||
287 | m_scene.AddCommand("Regions", this, sunCommand, string.Format("{0} [<value>]", sunCommand), kvp.Value, "", HandleSunConsoleCommand); | ||
288 | } | ||
289 | |||
290 | TimeZone local = TimeZone.CurrentTimeZone; | 283 | TimeZone local = TimeZone.CurrentTimeZone; |
291 | TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; | 284 | TicksUTCOffset = local.GetUtcOffset(local.ToLocalTime(DateTime.Now)).Ticks; |
292 | m_log.DebugFormat("[SUN]: localtime offset is {0}", TicksUTCOffset); | 285 | m_log.DebugFormat("[SUN]: localtime offset is {0}", TicksUTCOffset); |
@@ -358,15 +351,6 @@ namespace OpenSim.Region.CoreModules | |||
358 | HorizonShift = m_HorizonShift; // Z axis translation | 351 | HorizonShift = m_HorizonShift; // Z axis translation |
359 | // HoursToRadians = (SunCycle/24)*VWTimeRatio; | 352 | // HoursToRadians = (SunCycle/24)*VWTimeRatio; |
360 | 353 | ||
361 | // Insert our event handling hooks | ||
362 | |||
363 | scene.EventManager.OnFrame += SunUpdate; | ||
364 | scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; | ||
365 | scene.EventManager.OnEstateToolsSunUpdate += EstateToolsSunUpdate; | ||
366 | scene.EventManager.OnGetCurrentTimeAsLindenSunHour += GetCurrentTimeAsLindenSunHour; | ||
367 | |||
368 | ready = true; | ||
369 | |||
370 | m_log.Debug("[SUN]: Mode is " + m_RegionMode); | 354 | m_log.Debug("[SUN]: Mode is " + m_RegionMode); |
371 | m_log.Debug("[SUN]: Initialization completed. Day is " + SecondsPerSunCycle + " seconds, and year is " + m_YearLengthDays + " days"); | 355 | m_log.Debug("[SUN]: Initialization completed. Day is " + SecondsPerSunCycle + " seconds, and year is " + m_YearLengthDays + " days"); |
372 | m_log.Debug("[SUN]: Axis offset is " + m_HorizonShift); | 356 | m_log.Debug("[SUN]: Axis offset is " + m_HorizonShift); |
@@ -376,14 +360,37 @@ namespace OpenSim.Region.CoreModules | |||
376 | break; | 360 | break; |
377 | } | 361 | } |
378 | 362 | ||
379 | scene.RegisterModuleInterface<ISunModule>(this); | ||
380 | } | 363 | } |
381 | 364 | ||
382 | public void PostInitialise() | 365 | public Type ReplaceableInterface |
383 | { | 366 | { |
367 | get { return null; } | ||
384 | } | 368 | } |
385 | 369 | ||
386 | public void Close() | 370 | public void AddRegion(Scene scene) |
371 | { | ||
372 | m_scene = scene; | ||
373 | // Insert our event handling hooks | ||
374 | |||
375 | scene.EventManager.OnFrame += SunUpdate; | ||
376 | scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; | ||
377 | scene.EventManager.OnEstateToolsSunUpdate += EstateToolsSunUpdate; | ||
378 | scene.EventManager.OnGetCurrentTimeAsLindenSunHour += GetCurrentTimeAsLindenSunHour; | ||
379 | |||
380 | scene.RegisterModuleInterface<ISunModule>(this); | ||
381 | |||
382 | // This one enables the ability to type just "sun" without any parameters | ||
383 | // m_scene.AddCommand("Regions", this, "sun", "", "", HandleSunConsoleCommand); | ||
384 | foreach (KeyValuePair<string, string> kvp in GetParamList()) | ||
385 | { | ||
386 | string sunCommand = string.Format("sun {0}", kvp.Key); | ||
387 | m_scene.AddCommand("Regions", this, sunCommand, string.Format("{0} [<value>]", sunCommand), kvp.Value, "", HandleSunConsoleCommand); | ||
388 | } | ||
389 | |||
390 | ready = true; | ||
391 | } | ||
392 | |||
393 | public void RemoveRegion(Scene scene) | ||
387 | { | 394 | { |
388 | ready = false; | 395 | ready = false; |
389 | 396 | ||
@@ -394,14 +401,17 @@ namespace OpenSim.Region.CoreModules | |||
394 | m_scene.EventManager.OnGetCurrentTimeAsLindenSunHour -= GetCurrentTimeAsLindenSunHour; | 401 | m_scene.EventManager.OnGetCurrentTimeAsLindenSunHour -= GetCurrentTimeAsLindenSunHour; |
395 | } | 402 | } |
396 | 403 | ||
397 | public string Name | 404 | public void RegionLoaded(Scene scene) |
398 | { | 405 | { |
399 | get { return "SunModule"; } | ||
400 | } | 406 | } |
401 | 407 | ||
402 | public bool IsSharedModule | 408 | public void Close() |
403 | { | 409 | { |
404 | get { return false; } | 410 | } |
411 | |||
412 | public string Name | ||
413 | { | ||
414 | get { return "SunModule"; } | ||
405 | } | 415 | } |
406 | 416 | ||
407 | #endregion | 417 | #endregion |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs index 4694b14..52b4313 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs | |||
@@ -33,6 +33,7 @@ using System.Net; | |||
33 | using log4net; | 33 | using log4net; |
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenMetaverse; | 35 | using OpenMetaverse; |
36 | using Mono.Addins; | ||
36 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
37 | using OpenSim.Region.CoreModules.Framework.InterfaceCommander; | 38 | using OpenSim.Region.CoreModules.Framework.InterfaceCommander; |
38 | using OpenSim.Region.CoreModules.World.Terrain.FileLoaders; | 39 | using OpenSim.Region.CoreModules.World.Terrain.FileLoaders; |
@@ -43,6 +44,7 @@ using OpenSim.Region.Framework.Scenes; | |||
43 | 44 | ||
44 | namespace OpenSim.Region.CoreModules.World.Terrain | 45 | namespace OpenSim.Region.CoreModules.World.Terrain |
45 | { | 46 | { |
47 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "TerrainModule")] | ||
46 | public class TerrainModule : INonSharedRegionModule, ICommandableModule, ITerrainModule | 48 | public class TerrainModule : INonSharedRegionModule, ICommandableModule, ITerrainModule |
47 | { | 49 | { |
48 | #region StandardTerrainEffects enum | 50 | #region StandardTerrainEffects enum |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs index 3d4f762..be719ea 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs | |||
@@ -30,11 +30,12 @@ using NUnit.Framework; | |||
30 | using OpenSim.Framework; | 30 | using OpenSim.Framework; |
31 | using OpenSim.Region.CoreModules.World.Terrain.PaintBrushes; | 31 | using OpenSim.Region.CoreModules.World.Terrain.PaintBrushes; |
32 | using OpenSim.Region.Framework.Scenes; | 32 | using OpenSim.Region.Framework.Scenes; |
33 | using OpenSim.Tests.Common; | ||
33 | 34 | ||
34 | namespace OpenSim.Region.CoreModules.World.Terrain.Tests | 35 | namespace OpenSim.Region.CoreModules.World.Terrain.Tests |
35 | { | 36 | { |
36 | [TestFixture] | 37 | [TestFixture] |
37 | public class TerrainTest | 38 | public class TerrainTest : OpenSimTestCase |
38 | { | 39 | { |
39 | [Test] | 40 | [Test] |
40 | public void BrushTest() | 41 | public void BrushTest() |
diff --git a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs index f5f35bb..3f5d375 100644 --- a/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs +++ b/OpenSim/Region/CoreModules/World/Vegetation/VegetationModule.cs | |||
@@ -28,15 +28,17 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using log4net; | 30 | using log4net; |
31 | using Mono.Addins; | ||
31 | using Nini.Config; | 32 | using Nini.Config; |
32 | using OpenMetaverse; | 33 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
35 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
36 | 37 | ||
37 | namespace OpenSim.Region.CoreModules.Avatar.Vegetation | 38 | namespace OpenSim.Region.CoreModules.World.Vegetation |
38 | { | 39 | { |
39 | public class VegetationModule : IRegionModule, IVegetationModule | 40 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "VegetationModule")] |
41 | public class VegetationModule : INonSharedRegionModule, IVegetationModule | ||
40 | { | 42 | { |
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
42 | 44 | ||
@@ -45,16 +47,32 @@ namespace OpenSim.Region.CoreModules.Avatar.Vegetation | |||
45 | protected static readonly PCode[] creationCapabilities = new PCode[] { PCode.Grass, PCode.NewTree, PCode.Tree }; | 47 | protected static readonly PCode[] creationCapabilities = new PCode[] { PCode.Grass, PCode.NewTree, PCode.Tree }; |
46 | public PCode[] CreationCapabilities { get { return creationCapabilities; } } | 48 | public PCode[] CreationCapabilities { get { return creationCapabilities; } } |
47 | 49 | ||
48 | public void Initialise(Scene scene, IConfigSource source) | 50 | public void Initialise(IConfigSource source) |
51 | { | ||
52 | } | ||
53 | |||
54 | public void AddRegion(Scene scene) | ||
49 | { | 55 | { |
50 | m_scene = scene; | 56 | m_scene = scene; |
51 | m_scene.RegisterModuleInterface<IVegetationModule>(this); | 57 | m_scene.RegisterModuleInterface<IVegetationModule>(this); |
52 | } | 58 | } |
53 | 59 | ||
54 | public void PostInitialise() {} | 60 | public void RemoveRegion(Scene scene) |
61 | { | ||
62 | m_scene.UnregisterModuleInterface<IVegetationModule>(this); | ||
63 | } | ||
64 | |||
55 | public void Close() {} | 65 | public void Close() {} |
56 | public string Name { get { return "Vegetation Module"; } } | 66 | public string Name { get { return "Vegetation Module"; } } |
57 | public bool IsSharedModule { get { return false; } } | 67 | |
68 | public Type ReplaceableInterface | ||
69 | { | ||
70 | get { return null; } | ||
71 | } | ||
72 | |||
73 | public void RegionLoaded(Scene scene) | ||
74 | { | ||
75 | } | ||
58 | 76 | ||
59 | public SceneObjectGroup AddTree( | 77 | public SceneObjectGroup AddTree( |
60 | UUID uuid, UUID groupID, Vector3 scale, Quaternion rotation, Vector3 position, Tree treeType, bool newTree) | 78 | UUID uuid, UUID groupID, Vector3 scale, Quaternion rotation, Vector3 position, Tree treeType, bool newTree) |
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs index 2d762fb..5e0dfa7 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs | |||
@@ -35,6 +35,7 @@ using CSJ2K; | |||
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | using log4net; | 36 | using log4net; |
37 | using Rednettle.Warp3D; | 37 | using Rednettle.Warp3D; |
38 | using Mono.Addins; | ||
38 | using OpenMetaverse; | 39 | using OpenMetaverse; |
39 | using OpenMetaverse.Imaging; | 40 | using OpenMetaverse.Imaging; |
40 | using OpenMetaverse.Rendering; | 41 | using OpenMetaverse.Rendering; |
@@ -49,6 +50,7 @@ using WarpRenderer = global::Warp3D.Warp3D; | |||
49 | 50 | ||
50 | namespace OpenSim.Region.CoreModules.World.Warp3DMap | 51 | namespace OpenSim.Region.CoreModules.World.Warp3DMap |
51 | { | 52 | { |
53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "Warp3DImageModule")] | ||
52 | public class Warp3DImageModule : IMapImageGenerator, INonSharedRegionModule | 54 | public class Warp3DImageModule : IMapImageGenerator, INonSharedRegionModule |
53 | { | 55 | { |
54 | private static readonly UUID TEXTURE_METADATA_MAGIC = new UUID("802dc0e0-f080-4931-8b57-d1be8611c4f3"); | 56 | private static readonly UUID TEXTURE_METADATA_MAGIC = new UUID("802dc0e0-f080-4931-8b57-d1be8611c4f3"); |
@@ -63,7 +65,7 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
63 | private bool m_useAntiAliasing = false; // TODO: Make this a config option | 65 | private bool m_useAntiAliasing = false; // TODO: Make this a config option |
64 | private bool m_Enabled = false; | 66 | private bool m_Enabled = false; |
65 | 67 | ||
66 | #region IRegionModule Members | 68 | #region Region Module interface |
67 | 69 | ||
68 | public void Initialise(IConfigSource source) | 70 | public void Initialise(IConfigSource source) |
69 | { | 71 | { |
diff --git a/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs b/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs index 9d47e19..6af4050 100644 --- a/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs +++ b/OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs | |||
@@ -31,12 +31,14 @@ using System.Reflection; | |||
31 | 31 | ||
32 | using log4net; | 32 | using log4net; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using Mono.Addins; | ||
34 | 35 | ||
35 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.CoreModules.World.Wind; | 37 | using OpenSim.Region.CoreModules.World.Wind; |
37 | 38 | ||
38 | namespace OpenSim.Region.CoreModules.World.Wind.Plugins | 39 | namespace OpenSim.Region.CoreModules.World.Wind.Plugins |
39 | { | 40 | { |
41 | [Extension(Path = "/OpenSim/WindModule", NodeName = "WindModel", Id = "ConfigurableWind")] | ||
40 | class ConfigurableWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin | 42 | class ConfigurableWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin |
41 | { | 43 | { |
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs b/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs index 071e20b..fcb0c10 100644 --- a/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs +++ b/OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs | |||
@@ -29,11 +29,13 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | 30 | ||
31 | using OpenMetaverse; | 31 | using OpenMetaverse; |
32 | using Mono.Addins; | ||
32 | 33 | ||
33 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
34 | 35 | ||
35 | namespace OpenSim.Region.CoreModules.World.Wind.Plugins | 36 | namespace OpenSim.Region.CoreModules.World.Wind.Plugins |
36 | { | 37 | { |
38 | [Extension(Path = "/OpenSim/WindModule", NodeName = "WindModel", Id = "SimpleRandomWind")] | ||
37 | class SimpleRandomWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin | 39 | class SimpleRandomWind : Mono.Addins.TypeExtensionNode, IWindModelPlugin |
38 | { | 40 | { |
39 | private Vector2[] m_windSpeeds = new Vector2[16 * 16]; | 41 | private Vector2[] m_windSpeeds = new Vector2[16 * 16]; |
diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs index 7b6fbda..9de588c 100644 --- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs +++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs | |||
@@ -40,6 +40,7 @@ using OpenSim.Region.CoreModules.World.Wind; | |||
40 | 40 | ||
41 | namespace OpenSim.Region.CoreModules | 41 | namespace OpenSim.Region.CoreModules |
42 | { | 42 | { |
43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WindModule")] | ||
43 | public class WindModule : IWindModule | 44 | public class WindModule : IWindModule |
44 | { | 45 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -52,31 +53,31 @@ namespace OpenSim.Region.CoreModules | |||
52 | private bool m_ready = false; | 53 | private bool m_ready = false; |
53 | 54 | ||
54 | private bool m_enabled = false; | 55 | private bool m_enabled = false; |
55 | 56 | private IConfig m_windConfig; | |
56 | private IWindModelPlugin m_activeWindPlugin = null; | 57 | private IWindModelPlugin m_activeWindPlugin = null; |
57 | private const string m_dWindPluginName = "SimpleRandomWind"; | 58 | private string m_dWindPluginName = "SimpleRandomWind"; |
58 | private Dictionary<string, IWindModelPlugin> m_availableWindPlugins = new Dictionary<string, IWindModelPlugin>(); | 59 | private Dictionary<string, IWindModelPlugin> m_availableWindPlugins = new Dictionary<string, IWindModelPlugin>(); |
59 | 60 | ||
60 | // Simplified windSpeeds based on the fact that the client protocal tracks at a resolution of 16m | 61 | // Simplified windSpeeds based on the fact that the client protocal tracks at a resolution of 16m |
61 | private Vector2[] windSpeeds = new Vector2[16 * 16]; | 62 | private Vector2[] windSpeeds = new Vector2[16 * 16]; |
62 | 63 | ||
63 | #region IRegion Methods | 64 | #region INonSharedRegionModule Methods |
64 | 65 | ||
65 | public void Initialise(Scene scene, IConfigSource config) | 66 | public void Initialise(IConfigSource config) |
66 | { | 67 | { |
67 | IConfig windConfig = config.Configs["Wind"]; | 68 | m_windConfig = config.Configs["Wind"]; |
68 | string desiredWindPlugin = m_dWindPluginName; | 69 | // string desiredWindPlugin = m_dWindPluginName; |
69 | 70 | ||
70 | if (windConfig != null) | 71 | if (m_windConfig != null) |
71 | { | 72 | { |
72 | m_enabled = windConfig.GetBoolean("enabled", true); | 73 | m_enabled = m_windConfig.GetBoolean("enabled", true); |
73 | 74 | ||
74 | m_frameUpdateRate = windConfig.GetInt("wind_update_rate", 150); | 75 | m_frameUpdateRate = m_windConfig.GetInt("wind_update_rate", 150); |
75 | 76 | ||
76 | // Determine which wind model plugin is desired | 77 | // Determine which wind model plugin is desired |
77 | if (windConfig.Contains("wind_plugin")) | 78 | if (m_windConfig.Contains("wind_plugin")) |
78 | { | 79 | { |
79 | desiredWindPlugin = windConfig.GetString("wind_plugin"); | 80 | m_dWindPluginName = m_windConfig.GetString("wind_plugin", m_dWindPluginName); |
80 | } | 81 | } |
81 | } | 82 | } |
82 | 83 | ||
@@ -84,104 +85,111 @@ namespace OpenSim.Region.CoreModules | |||
84 | { | 85 | { |
85 | m_log.InfoFormat("[WIND] Enabled with an update rate of {0} frames.", m_frameUpdateRate); | 86 | m_log.InfoFormat("[WIND] Enabled with an update rate of {0} frames.", m_frameUpdateRate); |
86 | 87 | ||
87 | m_scene = scene; | 88 | } |
88 | m_frame = 0; | ||
89 | |||
90 | // Register all the Wind Model Plug-ins | ||
91 | foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false)) | ||
92 | { | ||
93 | m_log.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name); | ||
94 | m_availableWindPlugins.Add(windPlugin.Name, windPlugin); | ||
95 | } | ||
96 | 89 | ||
97 | // Check for desired plugin | 90 | } |
98 | if (m_availableWindPlugins.ContainsKey(desiredWindPlugin)) | ||
99 | { | ||
100 | m_activeWindPlugin = m_availableWindPlugins[desiredWindPlugin]; | ||
101 | 91 | ||
102 | m_log.InfoFormat("[WIND] {0} plugin found, initializing.", desiredWindPlugin); | 92 | public void AddRegion(Scene scene) |
93 | { | ||
94 | if (!m_enabled) | ||
95 | return; | ||
103 | 96 | ||
104 | if (windConfig != null) | 97 | m_scene = scene; |
105 | { | 98 | m_frame = 0; |
106 | m_activeWindPlugin.Initialise(); | ||
107 | m_activeWindPlugin.WindConfig(m_scene, windConfig); | ||
108 | } | ||
109 | } | ||
110 | 99 | ||
100 | // Register all the Wind Model Plug-ins | ||
101 | foreach (IWindModelPlugin windPlugin in AddinManager.GetExtensionObjects("/OpenSim/WindModule", false)) | ||
102 | { | ||
103 | m_log.InfoFormat("[WIND] Found Plugin: {0}", windPlugin.Name); | ||
104 | m_availableWindPlugins.Add(windPlugin.Name, windPlugin); | ||
105 | } | ||
111 | 106 | ||
112 | // if the plug-in wasn't found, default to no wind. | 107 | // Check for desired plugin |
113 | if (m_activeWindPlugin == null) | 108 | if (m_availableWindPlugins.ContainsKey(m_dWindPluginName)) |
114 | { | 109 | { |
115 | m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", desiredWindPlugin); | 110 | m_activeWindPlugin = m_availableWindPlugins[m_dWindPluginName]; |
116 | m_log.ErrorFormat("[WIND] Defaulting to no wind."); | ||
117 | } | ||
118 | 111 | ||
119 | // This one puts an entry in the main help screen | 112 | m_log.InfoFormat("[WIND] {0} plugin found, initializing.", m_dWindPluginName); |
120 | // m_scene.AddCommand("Regions", this, "wind", "wind", "Usage: wind <plugin> <param> [value] - Get or Update Wind paramaters", null); | ||
121 | |||
122 | // This one enables the ability to type just the base command without any parameters | ||
123 | // m_scene.AddCommand("Regions", this, "wind", "", "", HandleConsoleCommand); | ||
124 | 113 | ||
125 | // Get a list of the parameters for each plugin | 114 | if (m_windConfig != null) |
126 | foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values) | ||
127 | { | 115 | { |
128 | // m_scene.AddCommand("Regions", this, String.Format("wind base wind_plugin {0}", windPlugin.Name), String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "", HandleConsoleBaseCommand); | 116 | m_activeWindPlugin.Initialise(); |
129 | m_scene.AddCommand( | 117 | m_activeWindPlugin.WindConfig(m_scene, m_windConfig); |
130 | "Regions", | ||
131 | this, | ||
132 | "wind base wind_update_rate", | ||
133 | "wind base wind_update_rate [<value>]", | ||
134 | "Get or set the wind update rate.", | ||
135 | "", | ||
136 | HandleConsoleBaseCommand); | ||
137 | |||
138 | foreach (KeyValuePair<string, string> kvp in windPlugin.WindParams()) | ||
139 | { | ||
140 | string windCommand = String.Format("wind {0} {1}", windPlugin.Name, kvp.Key); | ||
141 | m_scene.AddCommand("Regions", this, windCommand, string.Format("{0} [<value>]", windCommand), kvp.Value, "", HandleConsoleParamCommand); | ||
142 | } | ||
143 | } | 118 | } |
119 | } | ||
144 | 120 | ||
145 | // Register event handlers for when Avatars enter the region, and frame ticks | ||
146 | m_scene.EventManager.OnFrame += WindUpdate; | ||
147 | m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion; | ||
148 | 121 | ||
149 | // Register the wind module | 122 | // if the plug-in wasn't found, default to no wind. |
150 | m_scene.RegisterModuleInterface<IWindModule>(this); | 123 | if (m_activeWindPlugin == null) |
124 | { | ||
125 | m_log.ErrorFormat("[WIND] Could not find specified wind plug-in: {0}", m_dWindPluginName); | ||
126 | m_log.ErrorFormat("[WIND] Defaulting to no wind."); | ||
127 | } | ||
151 | 128 | ||
152 | // Generate initial wind values | 129 | // This one puts an entry in the main help screen |
153 | GenWindPos(); | 130 | // m_scene.AddCommand("Regions", this, "wind", "wind", "Usage: wind <plugin> <param> [value] - Get or Update Wind paramaters", null); |
154 | 131 | ||
155 | // Mark Module Ready for duty | 132 | // This one enables the ability to type just the base command without any parameters |
156 | m_ready = true; | 133 | // m_scene.AddCommand("Regions", this, "wind", "", "", HandleConsoleCommand); |
157 | 134 | ||
135 | // Get a list of the parameters for each plugin | ||
136 | foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values) | ||
137 | { | ||
138 | // m_scene.AddCommand("Regions", this, String.Format("wind base wind_plugin {0}", windPlugin.Name), String.Format("{0} - {1}", windPlugin.Name, windPlugin.Description), "", HandleConsoleBaseCommand); | ||
139 | m_scene.AddCommand( | ||
140 | "Regions", | ||
141 | this, | ||
142 | "wind base wind_update_rate", | ||
143 | "wind base wind_update_rate [<value>]", | ||
144 | "Get or set the wind update rate.", | ||
145 | "", | ||
146 | HandleConsoleBaseCommand); | ||
147 | |||
148 | foreach (KeyValuePair<string, string> kvp in windPlugin.WindParams()) | ||
149 | { | ||
150 | string windCommand = String.Format("wind {0} {1}", windPlugin.Name, kvp.Key); | ||
151 | m_scene.AddCommand("Regions", this, windCommand, string.Format("{0} [<value>]", windCommand), kvp.Value, "", HandleConsoleParamCommand); | ||
152 | } | ||
158 | } | 153 | } |
159 | 154 | ||
160 | } | 155 | // Register event handlers for when Avatars enter the region, and frame ticks |
156 | m_scene.EventManager.OnFrame += WindUpdate; | ||
157 | m_scene.EventManager.OnMakeRootAgent += OnAgentEnteredRegion; | ||
161 | 158 | ||
162 | public void PostInitialise() | 159 | // Register the wind module |
163 | { | 160 | m_scene.RegisterModuleInterface<IWindModule>(this); |
161 | |||
162 | // Generate initial wind values | ||
163 | GenWindPos(); | ||
164 | |||
165 | // Mark Module Ready for duty | ||
166 | m_ready = true; | ||
164 | } | 167 | } |
165 | 168 | ||
166 | public void Close() | 169 | public void RemoveRegion(Scene scene) |
167 | { | 170 | { |
168 | if (m_enabled) | 171 | if (!m_enabled) |
172 | return; | ||
173 | |||
174 | m_ready = false; | ||
175 | |||
176 | // REVIEW: If a region module is closed, is there a possibility that it'll re-open/initialize ?? | ||
177 | m_activeWindPlugin = null; | ||
178 | foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values) | ||
169 | { | 179 | { |
170 | m_ready = false; | 180 | windPlugin.Dispose(); |
181 | } | ||
171 | 182 | ||
172 | // REVIEW: If a region module is closed, is there a possibility that it'll re-open/initialize ?? | 183 | m_availableWindPlugins.Clear(); |
173 | m_activeWindPlugin = null; | ||
174 | foreach (IWindModelPlugin windPlugin in m_availableWindPlugins.Values) | ||
175 | { | ||
176 | windPlugin.Dispose(); | ||
177 | } | ||
178 | 184 | ||
179 | m_availableWindPlugins.Clear(); | 185 | // Remove our hooks |
186 | m_scene.EventManager.OnFrame -= WindUpdate; | ||
187 | m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion; | ||
180 | 188 | ||
181 | // Remove our hooks | 189 | } |
182 | m_scene.EventManager.OnFrame -= WindUpdate; | 190 | |
183 | m_scene.EventManager.OnMakeRootAgent -= OnAgentEnteredRegion; | 191 | public void Close() |
184 | } | 192 | { |
185 | } | 193 | } |
186 | 194 | ||
187 | public string Name | 195 | public string Name |
@@ -189,11 +197,14 @@ namespace OpenSim.Region.CoreModules | |||
189 | get { return "WindModule"; } | 197 | get { return "WindModule"; } |
190 | } | 198 | } |
191 | 199 | ||
192 | public bool IsSharedModule | 200 | public Type ReplaceableInterface |
193 | { | 201 | { |
194 | get { return false; } | 202 | get { return null; } |
195 | } | 203 | } |
196 | 204 | ||
205 | public void RegionLoaded(Scene scene) | ||
206 | { | ||
207 | } | ||
197 | 208 | ||
198 | #endregion | 209 | #endregion |
199 | 210 | ||
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs index f37dd94..708a9a2 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/MapSearchModule.cs | |||
@@ -24,11 +24,13 @@ | |||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | using System; | ||
27 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
28 | using System.Reflection; | 29 | using System.Reflection; |
29 | using log4net; | 30 | using log4net; |
30 | using Nini.Config; | 31 | using Nini.Config; |
31 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using Mono.Addins; | ||
32 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
33 | using OpenSim.Region.Framework.Interfaces; | 35 | using OpenSim.Region.Framework.Interfaces; |
34 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
@@ -37,16 +39,22 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
37 | 39 | ||
38 | namespace OpenSim.Region.CoreModules.World.WorldMap | 40 | namespace OpenSim.Region.CoreModules.World.WorldMap |
39 | { | 41 | { |
40 | public class MapSearchModule : IRegionModule | 42 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapSearchModule")] |
43 | public class MapSearchModule : ISharedRegionModule | ||
41 | { | 44 | { |
42 | private static readonly ILog m_log = | 45 | private static readonly ILog m_log = |
43 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 47 | ||
45 | Scene m_scene = null; // only need one for communication with GridService | 48 | Scene m_scene = null; // only need one for communication with GridService |
46 | List<Scene> m_scenes = new List<Scene>(); | 49 | List<Scene> m_scenes = new List<Scene>(); |
50 | List<UUID> m_Clients; | ||
47 | 51 | ||
48 | #region IRegionModule Members | 52 | #region ISharedRegionModule Members |
49 | public void Initialise(Scene scene, IConfigSource source) | 53 | public void Initialise(IConfigSource source) |
54 | { | ||
55 | } | ||
56 | |||
57 | public void AddRegion(Scene scene) | ||
50 | { | 58 | { |
51 | if (m_scene == null) | 59 | if (m_scene == null) |
52 | { | 60 | { |
@@ -55,6 +63,16 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
55 | 63 | ||
56 | m_scenes.Add(scene); | 64 | m_scenes.Add(scene); |
57 | scene.EventManager.OnNewClient += OnNewClient; | 65 | scene.EventManager.OnNewClient += OnNewClient; |
66 | m_Clients = new List<UUID>(); | ||
67 | } | ||
68 | |||
69 | public void RemoveRegion(Scene scene) | ||
70 | { | ||
71 | m_scenes.Remove(scene); | ||
72 | if (m_scene == scene && m_scenes.Count > 0) | ||
73 | m_scene = m_scenes[0]; | ||
74 | |||
75 | scene.EventManager.OnNewClient -= OnNewClient; | ||
58 | } | 76 | } |
59 | 77 | ||
60 | public void PostInitialise() | 78 | public void PostInitialise() |
@@ -72,26 +90,59 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
72 | get { return "MapSearchModule"; } | 90 | get { return "MapSearchModule"; } |
73 | } | 91 | } |
74 | 92 | ||
75 | public bool IsSharedModule | 93 | public Type ReplaceableInterface |
76 | { | 94 | { |
77 | get { return true; } | 95 | get { return null; } |
78 | } | 96 | } |
79 | 97 | ||
98 | public void RegionLoaded(Scene scene) | ||
99 | { | ||
100 | } | ||
80 | #endregion | 101 | #endregion |
81 | 102 | ||
82 | private void OnNewClient(IClientAPI client) | 103 | private void OnNewClient(IClientAPI client) |
83 | { | 104 | { |
84 | client.OnMapNameRequest += OnMapNameRequest; | 105 | client.OnMapNameRequest += OnMapNameRequestHandler; |
106 | } | ||
107 | |||
108 | private void OnMapNameRequestHandler(IClientAPI remoteClient, string mapName, uint flags) | ||
109 | { | ||
110 | lock (m_Clients) | ||
111 | { | ||
112 | if (m_Clients.Contains(remoteClient.AgentId)) | ||
113 | return; | ||
114 | |||
115 | m_Clients.Add(remoteClient.AgentId); | ||
116 | } | ||
117 | |||
118 | try | ||
119 | { | ||
120 | OnMapNameRequest(remoteClient, mapName, flags); | ||
121 | } | ||
122 | finally | ||
123 | { | ||
124 | lock (m_Clients) | ||
125 | m_Clients.Remove(remoteClient.AgentId); | ||
126 | } | ||
85 | } | 127 | } |
86 | 128 | ||
87 | private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) | 129 | private void OnMapNameRequest(IClientAPI remoteClient, string mapName, uint flags) |
88 | { | 130 | { |
89 | if (mapName.Length < 3) | 131 | List<MapBlockData> blocks = new List<MapBlockData>(); |
132 | MapBlockData data; | ||
133 | if (mapName.Length < 3 || (mapName.EndsWith("#") && mapName.Length < 4)) | ||
90 | { | 134 | { |
135 | // final block, closing the search result | ||
136 | AddFinalBlock(blocks); | ||
137 | |||
138 | // flags are agent flags sent from the viewer. | ||
139 | // they have different values depending on different viewers, apparently | ||
140 | remoteClient.SendMapBlock(blocks, flags); | ||
91 | remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); | 141 | remoteClient.SendAlertMessage("Use a search string with at least 3 characters"); |
92 | return; | 142 | return; |
93 | } | 143 | } |
94 | 144 | ||
145 | |||
95 | //m_log.DebugFormat("MAP NAME=({0})", mapName); | 146 | //m_log.DebugFormat("MAP NAME=({0})", mapName); |
96 | 147 | ||
97 | // Hack to get around the fact that ll V3 now drops the port from the | 148 | // Hack to get around the fact that ll V3 now drops the port from the |
@@ -112,13 +163,8 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
112 | 163 | ||
113 | // try to fetch from GridServer | 164 | // try to fetch from GridServer |
114 | List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); | 165 | List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); |
115 | if (regionInfos.Count == 0) | ||
116 | remoteClient.SendAlertMessage("Hyperlink could not be established."); | ||
117 | 166 | ||
118 | m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags); | 167 | m_log.DebugFormat("[MAPSEARCHMODULE]: search {0} returned {1} regions. Flags={2}", mapName, regionInfos.Count, flags); |
119 | List<MapBlockData> blocks = new List<MapBlockData>(); | ||
120 | |||
121 | MapBlockData data; | ||
122 | if (regionInfos.Count > 0) | 168 | if (regionInfos.Count > 0) |
123 | { | 169 | { |
124 | foreach (GridRegion info in regionInfos) | 170 | foreach (GridRegion info in regionInfos) |
@@ -145,16 +191,7 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
145 | } | 191 | } |
146 | 192 | ||
147 | // final block, closing the search result | 193 | // final block, closing the search result |
148 | data = new MapBlockData(); | 194 | AddFinalBlock(blocks); |
149 | data.Agents = 0; | ||
150 | data.Access = 255; | ||
151 | data.MapImageId = UUID.Zero; | ||
152 | data.Name = ""; // mapName; | ||
153 | data.RegionFlags = 0; | ||
154 | data.WaterHeight = 0; // not used | ||
155 | data.X = 0; | ||
156 | data.Y = 0; | ||
157 | blocks.Add(data); | ||
158 | 195 | ||
159 | // flags are agent flags sent from the viewer. | 196 | // flags are agent flags sent from the viewer. |
160 | // they have different values depending on different viewers, apparently | 197 | // they have different values depending on different viewers, apparently |
@@ -166,12 +203,26 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
166 | if (flags == 2) | 203 | if (flags == 2) |
167 | { | 204 | { |
168 | if (regionInfos.Count == 0) | 205 | if (regionInfos.Count == 0) |
169 | remoteClient.SendAgentAlertMessage("No regions found with that name.", true); | 206 | remoteClient.SendAlertMessage("No regions found with that name."); |
170 | else if (regionInfos.Count == 1) | 207 | else if (regionInfos.Count == 1) |
171 | remoteClient.SendAgentAlertMessage("Region found!", false); | 208 | remoteClient.SendAlertMessage("Region found!"); |
172 | } | 209 | } |
173 | } | 210 | } |
174 | 211 | ||
212 | private void AddFinalBlock(List<MapBlockData> blocks) | ||
213 | { | ||
214 | // final block, closing the search result | ||
215 | MapBlockData data = new MapBlockData(); | ||
216 | data.Agents = 0; | ||
217 | data.Access = 255; | ||
218 | data.MapImageId = UUID.Zero; | ||
219 | data.Name = ""; | ||
220 | data.RegionFlags = 0; | ||
221 | data.WaterHeight = 0; // not used | ||
222 | data.X = 0; | ||
223 | data.Y = 0; | ||
224 | blocks.Add(data); | ||
225 | } | ||
175 | // private Scene GetClientScene(IClientAPI client) | 226 | // private Scene GetClientScene(IClientAPI client) |
176 | // { | 227 | // { |
177 | // foreach (Scene s in m_scenes) | 228 | // foreach (Scene s in m_scenes) |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index dfba3ff..e2f525c 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -40,6 +40,7 @@ using Nini.Config; | |||
40 | using OpenMetaverse; | 40 | using OpenMetaverse; |
41 | using OpenMetaverse.Imaging; | 41 | using OpenMetaverse.Imaging; |
42 | using OpenMetaverse.StructuredData; | 42 | using OpenMetaverse.StructuredData; |
43 | using Mono.Addins; | ||
43 | using OpenSim.Framework; | 44 | using OpenSim.Framework; |
44 | using OpenSim.Framework.Capabilities; | 45 | using OpenSim.Framework.Capabilities; |
45 | using OpenSim.Framework.Monitoring; | 46 | using OpenSim.Framework.Monitoring; |
@@ -55,6 +56,7 @@ using GridRegion = OpenSim.Services.Interfaces.GridRegion; | |||
55 | 56 | ||
56 | namespace OpenSim.Region.CoreModules.World.WorldMap | 57 | namespace OpenSim.Region.CoreModules.World.WorldMap |
57 | { | 58 | { |
59 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WorldMapModule")] | ||
58 | public class WorldMapModule : INonSharedRegionModule, IWorldMapModule | 60 | public class WorldMapModule : INonSharedRegionModule, IWorldMapModule |
59 | { | 61 | { |
60 | private static readonly ILog m_log = | 62 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs index 5540656..5e62f23 100644 --- a/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs +++ b/OpenSim/Region/DataSnapshot/DataSnapshotManager.cs | |||
@@ -35,15 +35,20 @@ using System.Xml; | |||
35 | using log4net; | 35 | using log4net; |
36 | using Nini.Config; | 36 | using Nini.Config; |
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using Mono.Addins; | ||
38 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
39 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
40 | using OpenSim.Region.DataSnapshot.Interfaces; | 41 | using OpenSim.Region.DataSnapshot.Interfaces; |
41 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Region.Framework.Scenes; | 43 | using OpenSim.Region.Framework.Scenes; |
43 | 44 | ||
45 | [assembly: Addin("DataSnapshot", "0.1")] | ||
46 | [assembly: AddinDependency("OpenSim", "0.5")] | ||
47 | |||
44 | namespace OpenSim.Region.DataSnapshot | 48 | namespace OpenSim.Region.DataSnapshot |
45 | { | 49 | { |
46 | public class DataSnapshotManager : IRegionModule, IDataSnapshot | 50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DataSnapshotManager")] |
51 | public class DataSnapshotManager : ISharedRegionModule, IDataSnapshot | ||
47 | { | 52 | { |
48 | #region Class members | 53 | #region Class members |
49 | //Information from config | 54 | //Information from config |
@@ -67,6 +72,7 @@ namespace OpenSim.Region.DataSnapshot | |||
67 | public string m_listener_port = ConfigSettings.DefaultRegionHttpPort.ToString(); | 72 | public string m_listener_port = ConfigSettings.DefaultRegionHttpPort.ToString(); |
68 | public string m_hostname = "127.0.0.1"; | 73 | public string m_hostname = "127.0.0.1"; |
69 | private UUID m_Secret = UUID.Random(); | 74 | private UUID m_Secret = UUID.Random(); |
75 | private bool m_servicesNotified = false; | ||
70 | 76 | ||
71 | //Update timers | 77 | //Update timers |
72 | private int m_period = 20; // in seconds | 78 | private int m_period = 20; // in seconds |
@@ -93,9 +99,9 @@ namespace OpenSim.Region.DataSnapshot | |||
93 | 99 | ||
94 | #endregion | 100 | #endregion |
95 | 101 | ||
96 | #region IRegionModule | 102 | #region Region Module interface |
97 | 103 | ||
98 | public void Initialise(Scene scene, IConfigSource config) | 104 | public void Initialise(IConfigSource config) |
99 | { | 105 | { |
100 | if (!m_configLoaded) | 106 | if (!m_configLoaded) |
101 | { | 107 | { |
@@ -133,82 +139,128 @@ namespace OpenSim.Region.DataSnapshot | |||
133 | m_enabled = false; | 139 | m_enabled = false; |
134 | return; | 140 | return; |
135 | } | 141 | } |
136 | } | ||
137 | 142 | ||
138 | if (m_enabled) | 143 | if (m_enabled) |
139 | { | 144 | m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); |
140 | //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer | 145 | } |
141 | new DataRequestHandler(scene, this); | ||
142 | 146 | ||
143 | m_hostname = scene.RegionInfo.ExternalHostName; | 147 | } |
144 | m_snapStore = new SnapshotStore(m_snapsDir, m_gridinfo, m_listener_port, m_hostname); | ||
145 | 148 | ||
146 | MakeEverythingStale(); | 149 | } |
147 | 150 | ||
148 | if (m_dataServices != "" && m_dataServices != "noservices") | 151 | public void AddRegion(Scene scene) |
149 | NotifyDataServices(m_dataServices, "online"); | 152 | { |
150 | } | 153 | if (!m_enabled) |
151 | } | 154 | return; |
152 | 155 | ||
153 | if (m_enabled) | 156 | m_log.DebugFormat("[DATASNAPSHOT]: Module added to Scene {0}.", scene.RegionInfo.RegionName); |
154 | { | ||
155 | m_log.Info("[DATASNAPSHOT]: Scene added to module."); | ||
156 | 157 | ||
157 | m_snapStore.AddScene(scene); | 158 | m_snapStore.AddScene(scene); |
158 | m_scenes.Add(scene); | 159 | m_scenes.Add(scene); |
159 | 160 | ||
160 | Assembly currentasm = Assembly.GetExecutingAssembly(); | 161 | Assembly currentasm = Assembly.GetExecutingAssembly(); |
161 | 162 | ||
162 | foreach (Type pluginType in currentasm.GetTypes()) | 163 | foreach (Type pluginType in currentasm.GetTypes()) |
164 | { | ||
165 | if (pluginType.IsPublic) | ||
163 | { | 166 | { |
164 | if (pluginType.IsPublic) | 167 | if (!pluginType.IsAbstract) |
165 | { | 168 | { |
166 | if (!pluginType.IsAbstract) | 169 | if (pluginType.GetInterface("IDataSnapshotProvider") != null) |
167 | { | 170 | { |
168 | if (pluginType.GetInterface("IDataSnapshotProvider") != null) | 171 | IDataSnapshotProvider module = (IDataSnapshotProvider)Activator.CreateInstance(pluginType); |
169 | { | 172 | module.Initialize(scene, this); |
170 | IDataSnapshotProvider module = (IDataSnapshotProvider)Activator.CreateInstance(pluginType); | 173 | module.OnStale += MarkDataStale; |
171 | module.Initialize(scene, this); | ||
172 | module.OnStale += MarkDataStale; | ||
173 | 174 | ||
174 | m_dataproviders.Add(module); | 175 | m_dataproviders.Add(module); |
175 | m_snapStore.AddProvider(module); | 176 | m_snapStore.AddProvider(module); |
176 | 177 | ||
177 | m_log.Info("[DATASNAPSHOT]: Added new data provider type: " + pluginType.Name); | 178 | m_log.Debug("[DATASNAPSHOT]: Added new data provider type: " + pluginType.Name); |
178 | } | ||
179 | } | 179 | } |
180 | } | 180 | } |
181 | } | 181 | } |
182 | } | ||
183 | |||
184 | // Must be done here because on shared modules, PostInitialise() will run | ||
185 | // BEFORE any scenes are registered. There is no "all scenes have been loaded" | ||
186 | // kind of callback because scenes may be created dynamically, so we cannot | ||
187 | // have that info, ever. | ||
188 | if (!m_servicesNotified) | ||
189 | { | ||
190 | //Hand it the first scene, assuming that all scenes have the same BaseHTTPServer | ||
191 | new DataRequestHandler(m_scenes[0], this); | ||
192 | |||
193 | m_hostname = m_scenes[0].RegionInfo.ExternalHostName; | ||
182 | 194 | ||
183 | //scene.OnRestart += OnSimRestart; | 195 | if (m_dataServices != "" && m_dataServices != "noservices") |
184 | scene.EventManager.OnShutdown += delegate() { OnSimRestart(scene.RegionInfo); }; | 196 | NotifyDataServices(m_dataServices, "online"); |
197 | |||
198 | m_servicesNotified = true; | ||
185 | } | 199 | } |
186 | else | 200 | } |
201 | |||
202 | public void RemoveRegion(Scene scene) | ||
203 | { | ||
204 | if (!m_enabled) | ||
205 | return; | ||
206 | |||
207 | m_log.Info("[DATASNAPSHOT]: Region " + scene.RegionInfo.RegionName + " is being removed, removing from indexing"); | ||
208 | Scene restartedScene = SceneForUUID(scene.RegionInfo.RegionID); | ||
209 | |||
210 | m_scenes.Remove(restartedScene); | ||
211 | m_snapStore.RemoveScene(restartedScene); | ||
212 | |||
213 | //Getting around the fact that we can't remove objects from a collection we are enumerating over | ||
214 | List<IDataSnapshotProvider> providersToRemove = new List<IDataSnapshotProvider>(); | ||
215 | |||
216 | foreach (IDataSnapshotProvider provider in m_dataproviders) | ||
217 | { | ||
218 | if (provider.GetParentScene == restartedScene) | ||
219 | { | ||
220 | providersToRemove.Add(provider); | ||
221 | } | ||
222 | } | ||
223 | |||
224 | foreach (IDataSnapshotProvider provider in providersToRemove) | ||
187 | { | 225 | { |
188 | //m_log.Debug("[DATASNAPSHOT]: Data snapshot disabled, not adding scene to module (or anything else)."); | 226 | m_dataproviders.Remove(provider); |
227 | m_snapStore.RemoveProvider(provider); | ||
189 | } | 228 | } |
229 | |||
230 | m_snapStore.RemoveScene(restartedScene); | ||
190 | } | 231 | } |
191 | 232 | ||
192 | public void Close() | 233 | public void PostInitialise() |
193 | { | 234 | { |
194 | if (m_enabled && m_dataServices != "" && m_dataServices != "noservices") | ||
195 | NotifyDataServices(m_dataServices, "offline"); | ||
196 | } | 235 | } |
197 | 236 | ||
237 | public void RegionLoaded(Scene scene) | ||
238 | { | ||
239 | if (!m_enabled) | ||
240 | return; | ||
241 | |||
242 | m_log.DebugFormat("[DATASNAPSHOT]: Marking scene {0} as stale.", scene.RegionInfo.RegionName); | ||
243 | m_snapStore.ForceSceneStale(scene); | ||
244 | } | ||
198 | 245 | ||
199 | public bool IsSharedModule | 246 | public void Close() |
200 | { | 247 | { |
201 | get { return true; } | 248 | if (!m_enabled) |
249 | return; | ||
250 | |||
251 | if (m_enabled && m_dataServices != "" && m_dataServices != "noservices") | ||
252 | NotifyDataServices(m_dataServices, "offline"); | ||
202 | } | 253 | } |
203 | 254 | ||
255 | |||
204 | public string Name | 256 | public string Name |
205 | { | 257 | { |
206 | get { return "External Data Generator"; } | 258 | get { return "External Data Generator"; } |
207 | } | 259 | } |
208 | 260 | ||
209 | public void PostInitialise() | 261 | public Type ReplaceableInterface |
210 | { | 262 | { |
211 | 263 | get { return null; } | |
212 | } | 264 | } |
213 | 265 | ||
214 | #endregion | 266 | #endregion |
@@ -399,35 +451,7 @@ namespace OpenSim.Region.DataSnapshot | |||
399 | m_snapStore.ForceSceneStale(scene); | 451 | m_snapStore.ForceSceneStale(scene); |
400 | } | 452 | } |
401 | } | 453 | } |
402 | |||
403 | #endregion | 454 | #endregion |
404 | 455 | ||
405 | public void OnSimRestart(RegionInfo thisRegion) | ||
406 | { | ||
407 | m_log.Info("[DATASNAPSHOT]: Region " + thisRegion.RegionName + " is restarting, removing from indexing"); | ||
408 | Scene restartedScene = SceneForUUID(thisRegion.RegionID); | ||
409 | |||
410 | m_scenes.Remove(restartedScene); | ||
411 | m_snapStore.RemoveScene(restartedScene); | ||
412 | |||
413 | //Getting around the fact that we can't remove objects from a collection we are enumerating over | ||
414 | List<IDataSnapshotProvider> providersToRemove = new List<IDataSnapshotProvider>(); | ||
415 | |||
416 | foreach (IDataSnapshotProvider provider in m_dataproviders) | ||
417 | { | ||
418 | if (provider.GetParentScene == restartedScene) | ||
419 | { | ||
420 | providersToRemove.Add(provider); | ||
421 | } | ||
422 | } | ||
423 | |||
424 | foreach (IDataSnapshotProvider provider in providersToRemove) | ||
425 | { | ||
426 | m_dataproviders.Remove(provider); | ||
427 | m_snapStore.RemoveProvider(provider); | ||
428 | } | ||
429 | |||
430 | m_snapStore.RemoveScene(restartedScene); | ||
431 | } | ||
432 | } | 456 | } |
433 | } | 457 | } |
diff --git a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs b/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs index 59cdab9..3b3db65 100644 --- a/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs +++ b/OpenSim/Region/DataSnapshot/Interfaces/IDataSnapshot.cs | |||
@@ -32,6 +32,5 @@ namespace OpenSim.Region.DataSnapshot.Interfaces | |||
32 | public interface IDataSnapshot | 32 | public interface IDataSnapshot |
33 | { | 33 | { |
34 | XmlDocument GetSnapshot(string regionName); | 34 | XmlDocument GetSnapshot(string regionName); |
35 | void MakeEverythingStale(); | ||
36 | } | 35 | } |
37 | } | 36 | } |
diff --git a/OpenSim/Region/DataSnapshot/Properties/AssemblyInfo.cs b/OpenSim/Region/DataSnapshot/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b926264 --- /dev/null +++ b/OpenSim/Region/DataSnapshot/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.DataSnapshot")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("06c36944-a28d-470e-912c-654c3edaba6b")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/Framework/Interfaces/ICloudModule.cs b/OpenSim/Region/Framework/Interfaces/ICloudModule.cs index 7296ac3..54172bd 100644 --- a/OpenSim/Region/Framework/Interfaces/ICloudModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ICloudModule.cs | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | namespace OpenSim.Region.Framework.Interfaces | 28 | namespace OpenSim.Region.Framework.Interfaces |
29 | { | 29 | { |
30 | public interface ICloudModule : IRegionModule | 30 | public interface ICloudModule |
31 | { | 31 | { |
32 | /// <summary> | 32 | /// <summary> |
33 | /// Retrieves the cloud density at the given region coordinates | 33 | /// Retrieves the cloud density at the given region coordinates |
diff --git a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs index be9764a..4d35c1c 100644 --- a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs | |||
@@ -33,95 +33,140 @@ namespace OpenSim.Region.Framework.Interfaces | |||
33 | public interface IDialogModule | 33 | public interface IDialogModule |
34 | { | 34 | { |
35 | /// <summary> | 35 | /// <summary> |
36 | /// Send a non-modal alert message to a particular user. This can disappear from the user's view after a | 36 | /// Send a non-modal alert message to a particular user. This can |
37 | /// small interval. | 37 | /// disappear from the user's view after a small interval. |
38 | /// </summary> | 38 | /// </summary> |
39 | /// <param name="client"></param> | 39 | /// <param name="client"> |
40 | /// <param name="message"></param> | 40 | /// IClientAPI object representing the user. |
41 | /// </param> | ||
42 | /// <param name="message">Message text to send to the user.</param> | ||
41 | void SendAlertToUser(IClientAPI client, string message); | 43 | void SendAlertToUser(IClientAPI client, string message); |
42 | 44 | ||
43 | /// <summary> | 45 | /// <summary> |
44 | /// Send an alert message to a particular user. | 46 | /// Send an alert message to a particular user. |
45 | /// </summary> | 47 | /// </summary> |
46 | /// <param name="client"></param> | 48 | /// <param name="client"> |
47 | /// <param name="message"></param> | 49 | /// IClientAPI object representing the user. |
48 | /// <param name="modal"></param> | 50 | /// </param> |
51 | /// <param name="message">Message text to send to the user.</param> | ||
52 | /// <param name="modal">Flag to control modality.</param> | ||
49 | void SendAlertToUser(IClientAPI client, string message, bool modal); | 53 | void SendAlertToUser(IClientAPI client, string message, bool modal); |
50 | 54 | ||
51 | /// <summary> | 55 | /// <summary> |
52 | /// Send a non-modal alert message to a particular user. | 56 | /// Send a non-modal alert message to a particular user. |
53 | /// </summary> | 57 | /// </summary> |
54 | /// <param name="agentID"></param> | 58 | /// <param name="agentID">UUID of agent representing the user.</param> |
55 | /// <param name="message"></param> | 59 | /// <param name="message">Message text to send to the user.</param> |
56 | void SendAlertToUser(UUID agentID, string message); | 60 | void SendAlertToUser(UUID agentID, string message); |
57 | 61 | ||
58 | /// <summary> | 62 | /// <summary> |
59 | /// Send an alert message to a particular user. | 63 | /// Send an alert message to a particular user. |
60 | /// </summary> | 64 | /// </summary> |
61 | /// <param name="agentID"></param> | 65 | /// <param name="agentID">UUID of agent representing the user.</param> |
62 | /// <param name="message"></param> | 66 | /// <param name="message">Message text to send to the user.</param> |
63 | /// <param name="modal"></param> | 67 | /// <param name="modal">Flag to control modality.</param> |
64 | void SendAlertToUser(UUID agentID, string message, bool modal); | 68 | void SendAlertToUser(UUID agentID, string message, bool modal); |
65 | 69 | ||
66 | /// <summary> | 70 | /// <summary> |
67 | /// Send an alert message to a particular user. | 71 | /// Send an alert message to a particular user. |
68 | /// </summary> | 72 | /// </summary> |
69 | /// <param name="firstName"></param> | 73 | /// <param name="firstName">Account first name</param> |
70 | /// <param name="lastName"></param> | 74 | /// <param name="lastName">Account last name</param> |
71 | /// <param name="message"></param> | 75 | /// <param name="message">Message text to send to the user.</param> |
72 | /// <param name="modal"></param> | 76 | /// <param name="modal">Flag to control modality.</param> |
73 | void SendAlertToUser(string firstName, string lastName, string message, bool modal); | 77 | void SendAlertToUser(string firstName, string lastName, |
74 | 78 | string message, bool modal); | |
79 | |||
75 | /// <summary> | 80 | /// <summary> |
76 | /// Send an alert message to all users in the scene. | 81 | /// Send an alert message to all users in the scene. |
77 | /// </summary> | 82 | /// </summary> |
78 | /// <param name="message"></param> | 83 | /// <param name="message">Message text to send to all users.</param> |
79 | void SendGeneralAlert(string message); | 84 | void SendGeneralAlert(string message); |
80 | 85 | ||
81 | /// <summary> | 86 | /// <summary> |
82 | /// Send a dialog box to a particular user. | 87 | /// Send a dialog box to a particular user. |
83 | /// </summary> | 88 | /// </summary> |
84 | /// <param name="avatarID"></param> | 89 | /// <param name="avatarID"> |
85 | /// <param name="objectName"></param> | 90 | /// UUID of the avatar representing the user. |
86 | /// <param name="objectID"></param> | 91 | /// </param> |
87 | /// <param name="ownerID"></param> | 92 | /// <param name="objectName"> |
88 | /// <param name="message"></param> | 93 | /// Name of the object sending the dialog. |
89 | /// <param name="textureID"></param> | 94 | /// </param> |
90 | /// <param name="ch"></param> | 95 | /// <param name="objectID"> |
91 | /// <param name="buttonlabels"></param> | 96 | /// UUID of the object sending the dialog. |
92 | void SendDialogToUser( | 97 | /// </param> |
93 | UUID avatarID, string objectName, UUID objectID, UUID ownerID, | 98 | /// <param name="ownerID"> |
94 | string message, UUID textureID, int ch, string[] buttonlabels); | 99 | /// UUID of the user that owns the object. |
95 | 100 | /// </param> | |
101 | /// <param name="message">Message text to send to the user.</param> | ||
102 | /// <param name="textureID"> | ||
103 | /// Texture UUID to pass along with the dialog. | ||
104 | /// </param> | ||
105 | /// <param name="ch"> | ||
106 | /// Channel on which the selected button text should be broadcast. | ||
107 | /// </param> | ||
108 | /// <param name="buttonlabels">Dialog button text.</param> | ||
109 | void SendDialogToUser(UUID avatarID, string objectName, UUID objectID, | ||
110 | UUID ownerID, string message, UUID textureID, int ch, | ||
111 | string[] buttonlabels); | ||
112 | |||
96 | /// <summary> | 113 | /// <summary> |
97 | /// Send a url to a particular user. | 114 | /// Send a url to a particular user. |
98 | /// </summary> | 115 | /// </summary> |
99 | /// <param name="avatarID"></param> | 116 | /// <param name="avatarID"> |
100 | /// <param name="objectName"></param> | 117 | /// UUID of the avatar representing the user. |
101 | /// <param name="objectID"></param> | 118 | /// </param> |
102 | /// <param name="ownerID"></param> | 119 | /// <param name="objectName"> |
103 | /// <param name="groupOwned"></param> | 120 | /// Name of the object sending the dialog. |
104 | /// <param name="message"></param> | 121 | /// </param> |
105 | /// <param name="url"></param> | 122 | /// <param name="objectID"> |
106 | void SendUrlToUser( | 123 | /// UUID of the object sending the dialog. |
107 | UUID avatarID, string objectName, UUID objectID, UUID ownerID, bool groupOwned, string message, string url); | 124 | /// </param> |
108 | 125 | /// <param name="ownerID"> | |
126 | /// UUID of the user that owns the object. | ||
127 | /// </param> | ||
128 | /// <param name="groupOwned"> | ||
129 | /// Flag indicating whether or not the object is group-owned. | ||
130 | /// </param> | ||
131 | /// <param name="message">Message text to send to the user.</param> | ||
132 | /// <param name="url">Url to send to the user.</param> | ||
133 | void SendUrlToUser(UUID avatarID, string objectName, UUID objectID, | ||
134 | UUID ownerID, bool groupOwned, string message, string url); | ||
135 | |||
109 | /// <summary> | 136 | /// <summary> |
110 | /// Send a notification to all users in the scene. This notification should remain around until the | 137 | /// Send a notification to all users in the scene. This notification |
111 | /// user explicitly dismisses it. | 138 | /// should remain around until the user explicitly dismisses it. |
112 | /// </summary> | 139 | /// </summary> |
113 | /// | 140 | /// <remarks> |
114 | /// On the Linden Labs Second Client (as of 1.21), this is a big blue box message on the upper right of the | 141 | /// On the Linden Labs Second Client (as of 1.21), this is a big blue |
115 | /// screen. | 142 | /// box message on the upper right of the screen. |
116 | /// | 143 | /// </remarks> |
117 | /// <param name="fromAvatarID">The user sending the message</param> | 144 | /// <param name="fromAvatarID">The user sending the message</param> |
118 | /// <param name="fromAvatarName">The name of the user doing the sending</param> | 145 | /// <param name="fromAvatarName"> |
146 | /// The name of the user doing the sending | ||
147 | /// </param> | ||
119 | /// <param name="message">The message being sent to the user</param> | 148 | /// <param name="message">The message being sent to the user</param> |
120 | void SendNotificationToUsersInRegion(UUID fromAvatarID, string fromAvatarName, string message); | 149 | void SendNotificationToUsersInRegion(UUID fromAvatarID, |
121 | 150 | string fromAvatarName, string message); | |
151 | |||
122 | /// <summary> | 152 | /// <summary> |
123 | /// Send a textbox entry for the client to respond to | 153 | /// Send a textbox entry for the client to respond to |
124 | /// </summary> | 154 | /// </summary> |
125 | void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid); | 155 | /// <param name="avatarID"> |
156 | /// UUID of the avatar representing the user. | ||
157 | /// </param> | ||
158 | /// <param name="message">Message text to send to the user.</param> | ||
159 | /// <param name="chatChannel"> | ||
160 | /// Chat channel that the user's input should be broadcast on. | ||
161 | /// </param> | ||
162 | /// <param name="name">Name of the object sending the dialog.</param> | ||
163 | /// <param name="objectid"> | ||
164 | /// UUID of the object sending the dialog. | ||
165 | /// </param> | ||
166 | /// <param name="ownerid"> | ||
167 | /// UUID of the user that owns the object. | ||
168 | /// </param> | ||
169 | void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, | ||
170 | string name, UUID objectid, UUID ownerid); | ||
126 | } | 171 | } |
127 | } | 172 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs index c457b2f..150193d 100644 --- a/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityInventory.cs | |||
@@ -150,6 +150,19 @@ namespace OpenSim.Region.Framework.Interfaces | |||
150 | void StopScriptInstance(UUID itemId); | 150 | void StopScriptInstance(UUID itemId); |
151 | 151 | ||
152 | /// <summary> | 152 | /// <summary> |
153 | /// Try to get the script running status. | ||
154 | /// </summary> | ||
155 | /// <returns> | ||
156 | /// Returns true if a script for the item was found in one of the simulator's script engines. In this case, | ||
157 | /// the running parameter will reflect the running status. | ||
158 | /// Returns false if the item could not be found, if the item is not a script or if a script instance for the | ||
159 | /// item was not found in any of the script engines. In this case, running status is irrelevant. | ||
160 | /// </returns> | ||
161 | /// <param name='itemId'></param> | ||
162 | /// <param name='running'></param> | ||
163 | bool TryGetScriptInstanceRunning(UUID itemId, out bool running); | ||
164 | |||
165 | /// <summary> | ||
153 | /// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative | 166 | /// Add an item to this entity's inventory. If an item with the same name already exists, then an alternative |
154 | /// name is chosen. | 167 | /// name is chosen. |
155 | /// </summary> | 168 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Interfaces/IRegionModule.cs b/OpenSim/Region/Framework/Interfaces/ILightShareModule.cs index 2bb0c75..b5fd24f 100644 --- a/OpenSim/Region/Framework/Interfaces/IRegionModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ILightShareModule.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -25,29 +25,9 @@ | |||
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 | using Nini.Config; | ||
29 | using OpenSim.Region.Framework.Scenes; | ||
30 | |||
31 | namespace OpenSim.Region.Framework.Interfaces | 28 | namespace OpenSim.Region.Framework.Interfaces |
32 | { | 29 | { |
33 | /// <summary> | 30 | public interface ILightShareModule |
34 | /// DEPRECATED! Use INonSharedRegionModule or ISharedRegionModule instead | ||
35 | /// </summary> | ||
36 | public interface IRegionModule | ||
37 | { | 31 | { |
38 | /// <summary> | ||
39 | /// Initialize the module. | ||
40 | /// </summary> | ||
41 | /// <remarks> | ||
42 | /// For a shared module this can be called multiple times - once per scene. | ||
43 | /// </remarks> | ||
44 | /// <param name="scene"></param> | ||
45 | /// <param name="source">Configuration information. For a shared module this will be identical on every scene call</param> | ||
46 | void Initialise(Scene scene, IConfigSource source); | ||
47 | |||
48 | void PostInitialise(); | ||
49 | void Close(); | ||
50 | string Name { get; } | ||
51 | bool IsSharedModule { get; } | ||
52 | } | 32 | } |
53 | } | 33 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Interfaces/INPCModule.cs b/OpenSim/Region/Framework/Interfaces/INPCModule.cs index d582149..9817cf7 100644 --- a/OpenSim/Region/Framework/Interfaces/INPCModule.cs +++ b/OpenSim/Region/Framework/Interfaces/INPCModule.cs | |||
@@ -32,14 +32,16 @@ using OpenSim.Region.Framework.Scenes; | |||
32 | namespace OpenSim.Region.Framework.Interfaces | 32 | namespace OpenSim.Region.Framework.Interfaces |
33 | { | 33 | { |
34 | /// <summary> | 34 | /// <summary> |
35 | /// Temporary interface. More methods to come at some point to make NPCs more object oriented rather than | 35 | /// Temporary interface. More methods to come at some point to make NPCs |
36 | /// controlling purely through module level interface calls (e.g. sit/stand). | 36 | /// more object oriented rather than controlling purely through module |
37 | /// level interface calls (e.g. sit/stand). | ||
37 | /// </summary> | 38 | /// </summary> |
38 | public interface INPC | 39 | public interface INPC |
39 | { | 40 | { |
40 | /// <summary> | 41 | /// <summary> |
41 | /// Should this NPC be sensed by LSL sensors as an 'agent' (interpreted here to mean a normal user) | 42 | /// Should this NPC be sensed by LSL sensors as an 'agent' |
42 | /// rather than an OpenSim specific NPC extension? | 43 | /// (interpreted here to mean a normal user) rather than an OpenSim |
44 | /// specific NPC extension? | ||
43 | /// </summary> | 45 | /// </summary> |
44 | bool SenseAsAgent { get; } | 46 | bool SenseAsAgent { get; } |
45 | } | 47 | } |
@@ -53,35 +55,42 @@ namespace OpenSim.Region.Framework.Interfaces | |||
53 | /// <param name="lastname"></param> | 55 | /// <param name="lastname"></param> |
54 | /// <param name="position"></param> | 56 | /// <param name="position"></param> |
55 | /// <param name="senseAsAgent"> | 57 | /// <param name="senseAsAgent"> |
56 | /// Make the NPC show up as an agent on LSL sensors. The default is that they | 58 | /// Make the NPC show up as an agent on LSL sensors. The default is |
57 | /// show up as the NPC type instead, but this is currently an OpenSim-only extension. | 59 | /// that they show up as the NPC type instead, but this is currently |
60 | /// an OpenSim-only extension. | ||
58 | /// </param> | 61 | /// </param> |
59 | /// <param name="scene"></param> | 62 | /// <param name="scene"></param> |
60 | /// <param name="appearance">The avatar appearance to use for the new NPC.</param> | 63 | /// <param name="appearance"> |
61 | /// <returns>The UUID of the ScenePresence created. UUID.Zero if there was a failure.</returns> | 64 | /// The avatar appearance to use for the new NPC. |
62 | UUID CreateNPC( | 65 | /// </param> |
63 | string firstname, | 66 | /// <returns> |
64 | string lastname, | 67 | /// The UUID of the ScenePresence created. UUID.Zero if there was a |
65 | Vector3 position, | 68 | /// failure. |
66 | UUID owner, | 69 | /// </returns> |
67 | bool senseAsAgent, | 70 | UUID CreateNPC(string firstname, string lastname, Vector3 position, |
68 | Scene scene, | 71 | UUID owner, bool senseAsAgent, Scene scene, |
69 | AvatarAppearance appearance); | 72 | AvatarAppearance appearance); |
70 | 73 | ||
71 | /// <summary> | 74 | /// <summary> |
72 | /// Check if the agent is an NPC. | 75 | /// Check if the agent is an NPC. |
73 | /// </summary> | 76 | /// </summary> |
74 | /// <param name="agentID"></param> | 77 | /// <param name="agentID"></param> |
75 | /// <param name="scene"></param> | 78 | /// <param name="scene"></param> |
76 | /// <returns>True if the agent is an NPC in the given scene. False otherwise.</returns> | 79 | /// <returns> |
80 | /// True if the agent is an NPC in the given scene. False otherwise. | ||
81 | /// </returns> | ||
77 | bool IsNPC(UUID agentID, Scene scene); | 82 | bool IsNPC(UUID agentID, Scene scene); |
78 | 83 | ||
79 | /// <summary> | 84 | /// <summary> |
80 | /// Get the NPC. This is not currently complete - manipulation of NPCs still occurs through the region interface | 85 | /// Get the NPC. |
81 | /// </summary> | 86 | /// </summary> |
87 | /// <remarks> | ||
88 | /// This is not currently complete - manipulation of NPCs still occurs | ||
89 | /// through the region interface. | ||
90 | /// </remarks> | ||
82 | /// <param name="agentID"></param> | 91 | /// <param name="agentID"></param> |
83 | /// <param name="scene"></param> | 92 | /// <param name="scene"></param> |
84 | /// <returns>The NPC. null if it does not exist.</returns> | 93 | /// <returns>The NPC. null if it does not exist.</returns> |
85 | INPC GetNPC(UUID agentID, Scene scene); | 94 | INPC GetNPC(UUID agentID, Scene scene); |
86 | 95 | ||
87 | /// <summary> | 96 | /// <summary> |
@@ -89,7 +98,10 @@ namespace OpenSim.Region.Framework.Interfaces | |||
89 | /// </summary> | 98 | /// </summary> |
90 | /// <param name="npcID"></param> | 99 | /// <param name="npcID"></param> |
91 | /// <param name="callerID"></param> | 100 | /// <param name="callerID"></param> |
92 | /// <returns>true if they do, false if they don't or if there's no NPC with the given ID.</returns> | 101 | /// <returns> |
102 | /// true if they do, false if they don't or if there's no NPC with the | ||
103 | /// given ID. | ||
104 | /// </returns> | ||
93 | bool CheckPermissions(UUID npcID, UUID callerID); | 105 | bool CheckPermissions(UUID npcID, UUID callerID); |
94 | 106 | ||
95 | /// <summary> | 107 | /// <summary> |
@@ -98,8 +110,12 @@ namespace OpenSim.Region.Framework.Interfaces | |||
98 | /// <param name="agentID"></param> | 110 | /// <param name="agentID"></param> |
99 | /// <param name="appearance"></param> | 111 | /// <param name="appearance"></param> |
100 | /// <param name="scene"></param> | 112 | /// <param name="scene"></param> |
101 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | 113 | /// <returns> |
102 | bool SetNPCAppearance(UUID agentID, AvatarAppearance appearance, Scene scene); | 114 | /// True if the operation succeeded, false if there was no such agent |
115 | /// or the agent was not an NPC. | ||
116 | /// </returns> | ||
117 | bool SetNPCAppearance(UUID agentID, AvatarAppearance appearance, | ||
118 | Scene scene); | ||
103 | 119 | ||
104 | /// <summary> | 120 | /// <summary> |
105 | /// Move an NPC to a target over time. | 121 | /// Move an NPC to a target over time. |
@@ -108,23 +124,29 @@ namespace OpenSim.Region.Framework.Interfaces | |||
108 | /// <param name="scene"></param> | 124 | /// <param name="scene"></param> |
109 | /// <param name="pos"></param> | 125 | /// <param name="pos"></param> |
110 | /// <param name="noFly"> | 126 | /// <param name="noFly"> |
111 | /// If true, then the avatar will attempt to walk to the location even if it's up in the air. | 127 | /// If true, then the avatar will attempt to walk to the location even |
112 | /// This is to allow walking on prims. | 128 | /// if it's up in the air. This is to allow walking on prims. |
113 | /// </param> | 129 | /// </param> |
114 | /// <param name="landAtTarget"> | 130 | /// <param name="landAtTarget"> |
115 | /// If true and the avatar is flying when it reaches the target, land. | 131 | /// If true and the avatar is flying when it reaches the target, land. |
116 | /// </param> name="running"> | 132 | /// </param> name="running"> |
117 | /// If true, NPC moves with running speed. | 133 | /// If true, NPC moves with running speed. |
118 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | 134 | /// <returns> |
119 | /// | 135 | /// True if the operation succeeded, false if there was no such agent |
120 | bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget, bool running); | 136 | /// or the agent was not an NPC. |
137 | /// </returns> | ||
138 | bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, | ||
139 | bool landAtTarget, bool running); | ||
121 | 140 | ||
122 | /// <summary> | 141 | /// <summary> |
123 | /// Stop the NPC's current movement. | 142 | /// Stop the NPC's current movement. |
124 | /// </summary> | 143 | /// </summary> |
125 | /// <param name="agentID">The UUID of the NPC</param> | 144 | /// <param name="agentID">The UUID of the NPC</param> |
126 | /// <param name="scene"></param> | 145 | /// <param name="scene"></param> |
127 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | 146 | /// <returns> |
147 | /// True if the operation succeeded, false if there was no such agent | ||
148 | /// or the agent was not an NPC. | ||
149 | /// </returns> | ||
128 | bool StopMoveToTarget(UUID agentID, Scene scene); | 150 | bool StopMoveToTarget(UUID agentID, Scene scene); |
129 | 151 | ||
130 | /// <summary> | 152 | /// <summary> |
@@ -133,7 +155,10 @@ namespace OpenSim.Region.Framework.Interfaces | |||
133 | /// <param name="agentID">The UUID of the NPC</param> | 155 | /// <param name="agentID">The UUID of the NPC</param> |
134 | /// <param name="scene"></param> | 156 | /// <param name="scene"></param> |
135 | /// <param name="text"></param> | 157 | /// <param name="text"></param> |
136 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | 158 | /// <returns> |
159 | /// True if the operation succeeded, false if there was no such agent | ||
160 | /// or the agent was not an NPC. | ||
161 | /// </returns> | ||
137 | bool Say(UUID agentID, Scene scene, string text); | 162 | bool Say(UUID agentID, Scene scene, string text); |
138 | 163 | ||
139 | /// <summary> | 164 | /// <summary> |
@@ -143,7 +168,10 @@ namespace OpenSim.Region.Framework.Interfaces | |||
143 | /// <param name="scene"></param> | 168 | /// <param name="scene"></param> |
144 | /// <param name="text"></param> | 169 | /// <param name="text"></param> |
145 | /// <param name="channel"></param> | 170 | /// <param name="channel"></param> |
146 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | 171 | /// <returns> |
172 | /// True if the operation succeeded, false if there was no such agent | ||
173 | /// or the agent was not an NPC. | ||
174 | /// </returns> | ||
147 | bool Say(UUID agentID, Scene scene, string text, int channel); | 175 | bool Say(UUID agentID, Scene scene, string text, int channel); |
148 | 176 | ||
149 | /// <summary> | 177 | /// <summary> |
@@ -153,7 +181,10 @@ namespace OpenSim.Region.Framework.Interfaces | |||
153 | /// <param name="scene"></param> | 181 | /// <param name="scene"></param> |
154 | /// <param name="text"></param> | 182 | /// <param name="text"></param> |
155 | /// <param name="channel"></param> | 183 | /// <param name="channel"></param> |
156 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | 184 | /// <returns> |
185 | /// True if the operation succeeded, false if there was no such agent | ||
186 | /// or the agent was not an NPC. | ||
187 | /// </returns> | ||
157 | bool Shout(UUID agentID, Scene scene, string text, int channel); | 188 | bool Shout(UUID agentID, Scene scene, string text, int channel); |
158 | 189 | ||
159 | /// <summary> | 190 | /// <summary> |
@@ -163,7 +194,10 @@ namespace OpenSim.Region.Framework.Interfaces | |||
163 | /// <param name="scene"></param> | 194 | /// <param name="scene"></param> |
164 | /// <param name="text"></param> | 195 | /// <param name="text"></param> |
165 | /// <param name="channel"></param> | 196 | /// <param name="channel"></param> |
166 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | 197 | /// <returns> |
198 | /// True if the operation succeeded, false if there was no such agent | ||
199 | /// or the agent was not an NPC. | ||
200 | /// </returns> | ||
167 | bool Whisper(UUID agentID, Scene scene, string text, int channel); | 201 | bool Whisper(UUID agentID, Scene scene, string text, int channel); |
168 | 202 | ||
169 | /// <summary> | 203 | /// <summary> |
@@ -188,7 +222,9 @@ namespace OpenSim.Region.Framework.Interfaces | |||
188 | /// </summary> | 222 | /// </summary> |
189 | /// <param name="agentID"></param> | 223 | /// <param name="agentID"></param> |
190 | /// <param name="partID"></param> | 224 | /// <param name="partID"></param> |
191 | /// <returns>true if the touch is actually attempted, false if not</returns> | 225 | /// <returns> |
226 | /// true if the touch is actually attempted, false if not. | ||
227 | /// </returns> | ||
192 | bool Touch(UUID agentID, UUID partID); | 228 | bool Touch(UUID agentID, UUID partID); |
193 | 229 | ||
194 | /// <summary> | 230 | /// <summary> |
@@ -196,14 +232,20 @@ namespace OpenSim.Region.Framework.Interfaces | |||
196 | /// </summary> | 232 | /// </summary> |
197 | /// <param name="agentID">The UUID of the NPC</param> | 233 | /// <param name="agentID">The UUID of the NPC</param> |
198 | /// <param name="scene"></param> | 234 | /// <param name="scene"></param> |
199 | /// <returns>True if the operation succeeded, false if there was no such agent or the agent was not an NPC</returns> | 235 | /// <returns> |
236 | /// True if the operation succeeded, false if there was no such agent | ||
237 | /// or the agent was not an NPC. | ||
238 | /// </returns> | ||
200 | bool DeleteNPC(UUID agentID, Scene scene); | 239 | bool DeleteNPC(UUID agentID, Scene scene); |
201 | 240 | ||
202 | /// <summary> | 241 | /// <summary> |
203 | /// Get the owner of a NPC | 242 | /// Get the owner of a NPC |
204 | /// </summary> | 243 | /// </summary> |
205 | /// <param name="agentID">The UUID of the NPC</param> | 244 | /// <param name="agentID">The UUID of the NPC</param> |
206 | /// <returns>UUID of owner if the NPC exists, UUID.Zero if there was no such agent, the agent is unowned or the agent was not an NPC</returns> | 245 | /// <returns> |
246 | /// UUID of owner if the NPC exists, UUID.Zero if there was no such | ||
247 | /// agent, the agent is unowned or the agent was not an NPC. | ||
248 | /// </returns> | ||
207 | UUID GetOwner(UUID agentID); | 249 | UUID GetOwner(UUID agentID); |
208 | } | 250 | } |
209 | } \ No newline at end of file | 251 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs index 93930ce..70ff954 100644 --- a/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs +++ b/OpenSim/Region/Framework/Interfaces/IScriptModuleComms.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using System.Collections.Generic; | ||
30 | using OpenMetaverse; | 31 | using OpenMetaverse; |
31 | 32 | ||
32 | namespace OpenSim.Region.Framework.Interfaces | 33 | namespace OpenSim.Region.Framework.Interfaces |
@@ -131,6 +132,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
131 | /// <param name="cname">Name of constant</param> | 132 | /// <param name="cname">Name of constant</param> |
132 | /// <returns>Value of constant or null if none found.</returns> | 133 | /// <returns>Value of constant or null if none found.</returns> |
133 | object LookupModConstant(string cname); | 134 | object LookupModConstant(string cname); |
135 | Dictionary<string, object> GetConstants(); | ||
134 | 136 | ||
135 | // For use ONLY by the script API | 137 | // For use ONLY by the script API |
136 | void RaiseEvent(UUID script, string id, string module, string command, string key); | 138 | void RaiseEvent(UUID script, string id, string module, string command, string key); |
diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index 6117a80..68af492 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs | |||
@@ -32,9 +32,96 @@ namespace OpenSim.Region.Framework.Interfaces | |||
32 | { | 32 | { |
33 | public interface ISoundModule | 33 | public interface ISoundModule |
34 | { | 34 | { |
35 | void PlayAttachedSound(UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius); | 35 | /// <summary> |
36 | 36 | /// Maximum distance between a sound source and a recipient. | |
37 | /// </summary> | ||
38 | float MaxDistance { get; } | ||
39 | |||
40 | /// <summary> | ||
41 | /// Play a sound from an object. | ||
42 | /// </summary> | ||
43 | /// <param name="soundID">Sound asset ID</param> | ||
44 | /// <param name="ownerID">Sound source owner</param> | ||
45 | /// <param name="objectID">Sound source ID</param> | ||
46 | /// <param name="gain">Sound volume</param> | ||
47 | /// <param name="position">Sound source position</param> | ||
48 | /// <param name="flags">Sound flags</param> | ||
49 | /// <param name="radius"> | ||
50 | /// Radius used to affect gain over distance. | ||
51 | /// </param> | ||
52 | void PlayAttachedSound(UUID soundID, UUID ownerID, UUID objectID, | ||
53 | double gain, Vector3 position, byte flags, float radius); | ||
54 | |||
55 | /// <summary> | ||
56 | /// Trigger a sound in the scene. | ||
57 | /// </summary> | ||
58 | /// <param name="soundId">Sound asset ID</param> | ||
59 | /// <param name="ownerID">Sound source owner</param> | ||
60 | /// <param name="objectID">Sound source ID</param> | ||
61 | /// <param name="parentID">Sound source parent.</param> | ||
62 | /// <param name="gain">Sound volume</param> | ||
63 | /// <param name="position">Sound source position</param> | ||
64 | /// <param name="handle"></param> | ||
65 | /// <param name="radius"> | ||
66 | /// Radius used to affect gain over distance. | ||
67 | /// </param> | ||
37 | void TriggerSound( | 68 | void TriggerSound( |
38 | UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius); | 69 | UUID soundId, UUID ownerID, UUID objectID, UUID parentID, |
70 | double gain, Vector3 position, UInt64 handle, float radius); | ||
71 | |||
72 | /// <summary> | ||
73 | /// Stop sounds eminating from an object. | ||
74 | /// </summary> | ||
75 | /// <param name="objectID">Sound source ID</param> | ||
76 | void StopSound(UUID objectID); | ||
77 | |||
78 | /// <summary> | ||
79 | /// Preload sound to viewers within range. | ||
80 | /// </summary> | ||
81 | /// <param name="objectID">Sound source ID</param> | ||
82 | /// <param name="soundID">Sound asset ID</param> | ||
83 | /// <param name="radius"> | ||
84 | /// Radius used to determine which viewers should preload the sound. | ||
85 | /// </param> | ||
86 | void PreloadSound(UUID objectID, UUID soundID, float radius); | ||
87 | |||
88 | /// <summary> | ||
89 | /// Loop specified sound at specified volume with specified radius, | ||
90 | /// optionally declaring object as new sync master. | ||
91 | /// </summary> | ||
92 | /// <param name="objectID">Sound source ID</param> | ||
93 | /// <param name="soundID">Sound asset ID</param> | ||
94 | /// <param name="gain">Sound volume</param> | ||
95 | /// <param name="radius">Sound radius</param> | ||
96 | /// <param name="isMaster">Set object to sync master if true</param> | ||
97 | void LoopSound(UUID objectID, UUID soundID, double gain, | ||
98 | double radius, bool isMaster); | ||
99 | |||
100 | /// <summary> | ||
101 | /// Trigger or play an attached sound in this part's inventory. | ||
102 | /// </summary> | ||
103 | /// <param name="objectID">Sound source ID</param> | ||
104 | /// <param name="sound">Sound asset ID</param> | ||
105 | /// <param name="volume">Sound volume</param> | ||
106 | /// <param name="triggered">Triggered or not.</param> | ||
107 | /// <param name="flags"></param> | ||
108 | /// <param name="radius">Sound radius</param> | ||
109 | /// <param name="useMaster">Play using sound master</param> | ||
110 | /// <param name="isMaster">Play as sound master</param> | ||
111 | void SendSound(UUID objectID, UUID sound, double volume, | ||
112 | bool triggered, byte flags, float radius, bool useMaster, | ||
113 | bool isMaster); | ||
114 | |||
115 | /// <summary> | ||
116 | /// Trigger a sound to be played to all agents within an axis-aligned | ||
117 | /// bounding box. | ||
118 | /// </summary> | ||
119 | /// <param name="objectID">Sound source ID</param> | ||
120 | /// <param name="sound">Sound asset ID</param> | ||
121 | /// <param name="volume">Sound volume</param> | ||
122 | /// <param name="min">AABB bottom south-west corner</param> | ||
123 | /// <param name="max">AABB top north-east corner</param> | ||
124 | void TriggerSoundLimited(UUID objectID, UUID sound, double volume, | ||
125 | Vector3 min, Vector3 max); | ||
39 | } | 126 | } |
40 | } \ No newline at end of file | 127 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Interfaces/ISunModule.cs b/OpenSim/Region/Framework/Interfaces/ISunModule.cs index 819ae11..8231716 100644 --- a/OpenSim/Region/Framework/Interfaces/ISunModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISunModule.cs | |||
@@ -29,7 +29,7 @@ using OpenMetaverse; | |||
29 | 29 | ||
30 | namespace OpenSim.Region.Framework.Interfaces | 30 | namespace OpenSim.Region.Framework.Interfaces |
31 | { | 31 | { |
32 | public interface ISunModule : IRegionModule | 32 | public interface ISunModule : INonSharedRegionModule |
33 | { | 33 | { |
34 | double GetSunParameter(string param); | 34 | double GetSunParameter(string param); |
35 | 35 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IWindModule.cs b/OpenSim/Region/Framework/Interfaces/IWindModule.cs index 10ecc32..4a26a71 100644 --- a/OpenSim/Region/Framework/Interfaces/IWindModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IWindModule.cs | |||
@@ -29,7 +29,7 @@ using OpenMetaverse; | |||
29 | 29 | ||
30 | namespace OpenSim.Region.Framework.Interfaces | 30 | namespace OpenSim.Region.Framework.Interfaces |
31 | { | 31 | { |
32 | public interface IWindModule : IRegionModule | 32 | public interface IWindModule : INonSharedRegionModule |
33 | { | 33 | { |
34 | 34 | ||
35 | /// <summary> | 35 | /// <summary> |
diff --git a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs index 4e74781..d76a0d7 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldComm.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldComm.cs | |||
@@ -45,6 +45,13 @@ namespace OpenSim.Region.Framework.Interfaces | |||
45 | void Deactivate(); | 45 | void Deactivate(); |
46 | void Activate(); | 46 | void Activate(); |
47 | UUID GetID(); | 47 | UUID GetID(); |
48 | |||
49 | /// <summary> | ||
50 | /// Bitfield indicating which strings should be processed as regex. | ||
51 | /// 1 corresponds to IWorldCommListenerInfo::GetName() | ||
52 | /// 2 corresponds to IWorldCommListenerInfo::GetMessage() | ||
53 | /// </summary> | ||
54 | int RegexBitfield { get; } | ||
48 | } | 55 | } |
49 | 56 | ||
50 | public interface IWorldComm | 57 | public interface IWorldComm |
@@ -60,7 +67,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
60 | /// the script during 'peek' time. Parameter hostID is needed to | 67 | /// the script during 'peek' time. Parameter hostID is needed to |
61 | /// determine the position of the script. | 68 | /// determine the position of the script. |
62 | /// </summary> | 69 | /// </summary> |
63 | /// <param name="localID">localID of the script engine</param> | 70 | /// <param name="LocalID">localID of the script engine</param> |
64 | /// <param name="itemID">UUID of the script engine</param> | 71 | /// <param name="itemID">UUID of the script engine</param> |
65 | /// <param name="hostID">UUID of the SceneObjectPart</param> | 72 | /// <param name="hostID">UUID of the SceneObjectPart</param> |
66 | /// <param name="channel">channel to listen on</param> | 73 | /// <param name="channel">channel to listen on</param> |
@@ -70,6 +77,23 @@ namespace OpenSim.Region.Framework.Interfaces | |||
70 | /// <returns>number of the scripts handle</returns> | 77 | /// <returns>number of the scripts handle</returns> |
71 | int Listen(uint LocalID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg); | 78 | int Listen(uint LocalID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg); |
72 | 79 | ||
80 | /// <summary> | ||
81 | /// Create a listen event callback with the specified filters. | ||
82 | /// The parameters localID,itemID are needed to uniquely identify | ||
83 | /// the script during 'peek' time. Parameter hostID is needed to | ||
84 | /// determine the position of the script. | ||
85 | /// </summary> | ||
86 | /// <param name="LocalID">localID of the script engine</param> | ||
87 | /// <param name="itemID">UUID of the script engine</param> | ||
88 | /// <param name="hostID">UUID of the SceneObjectPart</param> | ||
89 | /// <param name="channel">channel to listen on</param> | ||
90 | /// <param name="name">name to filter on</param> | ||
91 | /// <param name="id">key to filter on (user given, could be totally faked)</param> | ||
92 | /// <param name="msg">msg to filter on</param> | ||
93 | /// <param name="regexBitfield">Bitfield indicating which strings should be processed as regex.</param> | ||
94 | /// <returns>number of the scripts handle</returns> | ||
95 | int Listen(uint LocalID, UUID itemID, UUID hostID, int channel, string name, UUID id, string msg, int regexBitfield); | ||
96 | |||
73 | /// <summary> | 97 | /// <summary> |
74 | /// This method scans over the objects which registered an interest in listen callbacks. | 98 | /// This method scans over the objects which registered an interest in listen callbacks. |
75 | /// For everyone it finds, it checks if it fits the given filter. If it does, then | 99 | /// For everyone it finds, it checks if it fits the given filter. If it does, then |
diff --git a/OpenSim/Region/Framework/ModuleLoader.cs b/OpenSim/Region/Framework/ModuleLoader.cs deleted file mode 100644 index 14ecd44..0000000 --- a/OpenSim/Region/Framework/ModuleLoader.cs +++ /dev/null | |||
@@ -1,262 +0,0 @@ | |||
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.IO; | ||
31 | using System.Reflection; | ||
32 | using log4net; | ||
33 | using Nini.Config; | ||
34 | using OpenSim.Region.Framework.Interfaces; | ||
35 | using OpenSim.Region.Framework.Scenes; | ||
36 | |||
37 | namespace OpenSim.Region.Framework | ||
38 | { | ||
39 | public class ModuleLoader | ||
40 | { | ||
41 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
42 | |||
43 | public Dictionary<string, Assembly> LoadedAssemblys = new Dictionary<string, Assembly>(); | ||
44 | |||
45 | private readonly List<IRegionModule> m_loadedModules = new List<IRegionModule>(); | ||
46 | private readonly Dictionary<string, IRegionModule> m_loadedSharedModules = new Dictionary<string, IRegionModule>(); | ||
47 | private readonly IConfigSource m_config; | ||
48 | |||
49 | public ModuleLoader(IConfigSource config) | ||
50 | { | ||
51 | m_config = config; | ||
52 | } | ||
53 | |||
54 | public IRegionModule[] GetLoadedSharedModules | ||
55 | { | ||
56 | get | ||
57 | { | ||
58 | IRegionModule[] regionModules = new IRegionModule[m_loadedSharedModules.Count]; | ||
59 | m_loadedSharedModules.Values.CopyTo(regionModules, 0); | ||
60 | return regionModules; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | public List<IRegionModule> PickupModules(Scene scene, string moduleDir) | ||
65 | { | ||
66 | DirectoryInfo dir = new DirectoryInfo(moduleDir); | ||
67 | List<IRegionModule> modules = new List<IRegionModule>(); | ||
68 | |||
69 | foreach (FileInfo fileInfo in dir.GetFiles("*.dll")) | ||
70 | { | ||
71 | modules.AddRange(LoadRegionModules(fileInfo.FullName, scene)); | ||
72 | } | ||
73 | return modules; | ||
74 | } | ||
75 | |||
76 | public void LoadDefaultSharedModule(IRegionModule module) | ||
77 | { | ||
78 | if (m_loadedSharedModules.ContainsKey(module.Name)) | ||
79 | { | ||
80 | m_log.ErrorFormat("[MODULES]: Module name \"{0}\" already exists in module list. Module not added!", module.Name); | ||
81 | } | ||
82 | else | ||
83 | { | ||
84 | m_loadedSharedModules.Add(module.Name, module); | ||
85 | } | ||
86 | } | ||
87 | |||
88 | |||
89 | public void InitialiseSharedModules(Scene scene) | ||
90 | { | ||
91 | foreach (IRegionModule module in m_loadedSharedModules.Values) | ||
92 | { | ||
93 | module.Initialise(scene, m_config); | ||
94 | scene.AddModule(module.Name, module); //should be doing this? | ||
95 | } | ||
96 | } | ||
97 | |||
98 | public void InitializeModule(IRegionModule module, Scene scene) | ||
99 | { | ||
100 | module.Initialise(scene, m_config); | ||
101 | scene.AddModule(module.Name, module); | ||
102 | m_loadedModules.Add(module); | ||
103 | } | ||
104 | |||
105 | /// <summary> | ||
106 | /// Loads/initialises a Module instance that can be used by multiple Regions | ||
107 | /// </summary> | ||
108 | /// <param name="dllName"></param> | ||
109 | /// <param name="moduleName"></param> | ||
110 | public void LoadSharedModule(string dllName, string moduleName) | ||
111 | { | ||
112 | IRegionModule module = LoadModule(dllName, moduleName); | ||
113 | |||
114 | if (module != null) | ||
115 | LoadSharedModule(module); | ||
116 | } | ||
117 | |||
118 | /// <summary> | ||
119 | /// Loads/initialises a Module instance that can be used by multiple Regions | ||
120 | /// </summary> | ||
121 | /// <param name="module"></param> | ||
122 | public void LoadSharedModule(IRegionModule module) | ||
123 | { | ||
124 | if (!m_loadedSharedModules.ContainsKey(module.Name)) | ||
125 | { | ||
126 | m_loadedSharedModules.Add(module.Name, module); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | public List<IRegionModule> LoadRegionModules(string dllName, Scene scene) | ||
131 | { | ||
132 | IRegionModule[] modules = LoadModules(dllName); | ||
133 | List<IRegionModule> initializedModules = new List<IRegionModule>(); | ||
134 | |||
135 | if (modules.Length > 0) | ||
136 | { | ||
137 | m_log.InfoFormat("[MODULES]: Found Module Library [{0}]", dllName); | ||
138 | foreach (IRegionModule module in modules) | ||
139 | { | ||
140 | if (!module.IsSharedModule) | ||
141 | { | ||
142 | m_log.InfoFormat("[MODULES]: [{0}]: Initializing.", module.Name); | ||
143 | InitializeModule(module, scene); | ||
144 | initializedModules.Add(module); | ||
145 | } | ||
146 | else | ||
147 | { | ||
148 | m_log.InfoFormat("[MODULES]: [{0}]: Loading Shared Module.", module.Name); | ||
149 | LoadSharedModule(module); | ||
150 | } | ||
151 | } | ||
152 | } | ||
153 | return initializedModules; | ||
154 | } | ||
155 | |||
156 | public void LoadRegionModule(string dllName, string moduleName, Scene scene) | ||
157 | { | ||
158 | IRegionModule module = LoadModule(dllName, moduleName); | ||
159 | if (module != null) | ||
160 | { | ||
161 | InitializeModule(module, scene); | ||
162 | } | ||
163 | } | ||
164 | |||
165 | /// <summary> | ||
166 | /// Loads a external Module (if not already loaded) and creates a new instance of it. | ||
167 | /// </summary> | ||
168 | /// <param name="dllName"></param> | ||
169 | /// <param name="moduleName"></param> | ||
170 | public IRegionModule LoadModule(string dllName, string moduleName) | ||
171 | { | ||
172 | IRegionModule[] modules = LoadModules(dllName); | ||
173 | |||
174 | foreach (IRegionModule module in modules) | ||
175 | { | ||
176 | if ((module != null) && (module.Name == moduleName)) | ||
177 | { | ||
178 | return module; | ||
179 | } | ||
180 | } | ||
181 | |||
182 | return null; | ||
183 | } | ||
184 | |||
185 | public IRegionModule[] LoadModules(string dllName) | ||
186 | { | ||
187 | //m_log.DebugFormat("[MODULES]: Looking for modules in {0}", dllName); | ||
188 | |||
189 | List<IRegionModule> modules = new List<IRegionModule>(); | ||
190 | |||
191 | Assembly pluginAssembly; | ||
192 | if (!LoadedAssemblys.TryGetValue(dllName, out pluginAssembly)) | ||
193 | { | ||
194 | try | ||
195 | { | ||
196 | pluginAssembly = Assembly.LoadFrom(dllName); | ||
197 | LoadedAssemblys.Add(dllName, pluginAssembly); | ||
198 | } | ||
199 | catch (BadImageFormatException) | ||
200 | { | ||
201 | //m_log.InfoFormat("[MODULES]: The file [{0}] is not a module assembly.", e.FileName); | ||
202 | } | ||
203 | } | ||
204 | |||
205 | if (pluginAssembly != null) | ||
206 | { | ||
207 | try | ||
208 | { | ||
209 | foreach (Type pluginType in pluginAssembly.GetTypes()) | ||
210 | { | ||
211 | if (pluginType.IsPublic) | ||
212 | { | ||
213 | if (!pluginType.IsAbstract) | ||
214 | { | ||
215 | if (pluginType.GetInterface("IRegionModule") != null) | ||
216 | { | ||
217 | modules.Add((IRegionModule)Activator.CreateInstance(pluginType)); | ||
218 | } | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | } | ||
223 | catch (Exception e) | ||
224 | { | ||
225 | m_log.ErrorFormat( | ||
226 | "[MODULES]: Could not load types for plugin DLL {0}. Exception {1} {2}", | ||
227 | pluginAssembly.FullName, e.Message, e.StackTrace); | ||
228 | |||
229 | // justincc: Right now this is fatal to really get the user's attention | ||
230 | throw e; | ||
231 | } | ||
232 | } | ||
233 | |||
234 | return modules.ToArray(); | ||
235 | } | ||
236 | |||
237 | public void PostInitialise() | ||
238 | { | ||
239 | foreach (IRegionModule module in m_loadedSharedModules.Values) | ||
240 | { | ||
241 | module.PostInitialise(); | ||
242 | } | ||
243 | |||
244 | foreach (IRegionModule module in m_loadedModules) | ||
245 | { | ||
246 | module.PostInitialise(); | ||
247 | } | ||
248 | } | ||
249 | |||
250 | public void ClearCache() | ||
251 | { | ||
252 | LoadedAssemblys.Clear(); | ||
253 | } | ||
254 | |||
255 | public void UnloadModule(IRegionModule rm) | ||
256 | { | ||
257 | rm.Close(); | ||
258 | |||
259 | m_loadedModules.Remove(rm); | ||
260 | } | ||
261 | } | ||
262 | } | ||
diff --git a/OpenSim/Region/Framework/Properties/AssemblyInfo.cs b/OpenSim/Region/Framework/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9b504c0 --- /dev/null +++ b/OpenSim/Region/Framework/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.Framework")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("d25e7aed-7f55-4bb8-9970-0d7d978ea8a5")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs index ad421ee..65ae445 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/AnimationSet.cs | |||
@@ -41,6 +41,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
41 | { | 41 | { |
42 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 42 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
43 | 43 | ||
44 | private OpenSim.Framework.Animation m_implicitDefaultAnimation = new OpenSim.Framework.Animation(); | ||
44 | private OpenSim.Framework.Animation m_defaultAnimation = new OpenSim.Framework.Animation(); | 45 | private OpenSim.Framework.Animation m_defaultAnimation = new OpenSim.Framework.Animation(); |
45 | private List<OpenSim.Framework.Animation> m_animations = new List<OpenSim.Framework.Animation>(); | 46 | private List<OpenSim.Framework.Animation> m_animations = new List<OpenSim.Framework.Animation>(); |
46 | 47 | ||
@@ -49,6 +50,11 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
49 | get { return m_defaultAnimation; } | 50 | get { return m_defaultAnimation; } |
50 | } | 51 | } |
51 | 52 | ||
53 | public OpenSim.Framework.Animation ImplicitDefaultAnimation | ||
54 | { | ||
55 | get { return m_implicitDefaultAnimation; } | ||
56 | } | ||
57 | |||
52 | public AnimationSet() | 58 | public AnimationSet() |
53 | { | 59 | { |
54 | ResetDefaultAnimation(); | 60 | ResetDefaultAnimation(); |
@@ -119,11 +125,18 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
119 | if (m_defaultAnimation.AnimID != animID) | 125 | if (m_defaultAnimation.AnimID != animID) |
120 | { | 126 | { |
121 | m_defaultAnimation = new OpenSim.Framework.Animation(animID, sequenceNum, objectID); | 127 | m_defaultAnimation = new OpenSim.Framework.Animation(animID, sequenceNum, objectID); |
128 | m_implicitDefaultAnimation = m_defaultAnimation; | ||
122 | return true; | 129 | return true; |
123 | } | 130 | } |
124 | return false; | 131 | return false; |
125 | } | 132 | } |
126 | 133 | ||
134 | // Called from serialization only | ||
135 | public void SetImplicitDefaultAnimation(UUID animID, int sequenceNum, UUID objectID) | ||
136 | { | ||
137 | m_implicitDefaultAnimation = new OpenSim.Framework.Animation(animID, sequenceNum, objectID); | ||
138 | } | ||
139 | |||
127 | protected bool ResetDefaultAnimation() | 140 | protected bool ResetDefaultAnimation() |
128 | { | 141 | { |
129 | return TrySetDefaultAnimation("STAND", 1, UUID.Zero); | 142 | return TrySetDefaultAnimation("STAND", 1, UUID.Zero); |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index b23ddb4..ad40d6b 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -1909,8 +1909,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1909 | } | 1909 | } |
1910 | } | 1910 | } |
1911 | 1911 | ||
1912 | public virtual void DeRezObjects(IClientAPI remoteClient, List<uint> localIDs, | 1912 | /// <summary> |
1913 | UUID groupID, DeRezAction action, UUID destinationID) | 1913 | /// Derez one or more objects from the scene. |
1914 | /// </summary> | ||
1915 | /// <remarks> | ||
1916 | /// Won't actually remove the scene object in the case where the object is being copied to a user inventory. | ||
1917 | /// </remarks> | ||
1918 | /// <param name='remoteClient'>Client requesting derez</param> | ||
1919 | /// <param name='localIDs'>Local ids of root parts of objects to delete.</param> | ||
1920 | /// <param name='groupID'>Not currently used. Here because the client passes this to us.</param> | ||
1921 | /// <param name='action'>DeRezAction</param> | ||
1922 | /// <param name='destinationID'>User folder ID to place derezzed object</param> | ||
1923 | public virtual void DeRezObjects( | ||
1924 | IClientAPI remoteClient, List<uint> localIDs, UUID groupID, DeRezAction action, UUID destinationID) | ||
1914 | { | 1925 | { |
1915 | // First, see of we can perform the requested action and | 1926 | // First, see of we can perform the requested action and |
1916 | // build a list of eligible objects | 1927 | // build a list of eligible objects |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 6e53951..df43271 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -38,7 +38,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
38 | { | 38 | { |
39 | public partial class Scene | 39 | public partial class Scene |
40 | { | 40 | { |
41 | 41 | /// <summary> | |
42 | /// Send chat to listeners. | ||
43 | /// </summary> | ||
44 | /// <param name='message'></param> | ||
45 | /// <param name='type'>/param> | ||
46 | /// <param name='channel'></param> | ||
47 | /// <param name='fromPos'></param> | ||
48 | /// <param name='fromName'></param> | ||
49 | /// <param name='fromID'></param> | ||
50 | /// <param name='targetID'></param> | ||
51 | /// <param name='fromAgent'></param> | ||
52 | /// <param name='broadcast'></param> | ||
42 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, | 53 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, |
43 | UUID fromID, UUID targetID, bool fromAgent, bool broadcast) | 54 | UUID fromID, UUID targetID, bool fromAgent, bool broadcast) |
44 | { | 55 | { |
@@ -66,6 +77,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
66 | args.From = fromName; | 77 | args.From = fromName; |
67 | args.TargetUUID = targetID; | 78 | args.TargetUUID = targetID; |
68 | 79 | ||
80 | // m_log.DebugFormat( | ||
81 | // "[SCENE]: Sending message {0} on channel {1}, type {2} from {3}, broadcast {4}", | ||
82 | // args.Message.Replace("\n", "\\n"), args.Channel, args.Type, fromName, broadcast); | ||
83 | |||
69 | if (broadcast) | 84 | if (broadcast) |
70 | EventManager.TriggerOnChatBroadcast(this, args); | 85 | EventManager.TriggerOnChatBroadcast(this, args); |
71 | else | 86 | else |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 5f45529..1ad5edd 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -176,7 +176,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
176 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); | 176 | protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); |
177 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); | 177 | protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); |
178 | protected string m_simulatorVersion = "OpenSimulator Server"; | 178 | protected string m_simulatorVersion = "OpenSimulator Server"; |
179 | protected ModuleLoader m_moduleLoader; | ||
180 | protected AgentCircuitManager m_authenticateHandler; | 179 | protected AgentCircuitManager m_authenticateHandler; |
181 | protected SceneCommunicationService m_sceneGridService; | 180 | protected SceneCommunicationService m_sceneGridService; |
182 | 181 | ||
@@ -659,7 +658,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
659 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, | 658 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, |
660 | SceneCommunicationService sceneGridService, | 659 | SceneCommunicationService sceneGridService, |
661 | ISimulationDataService simDataService, IEstateDataService estateDataService, | 660 | ISimulationDataService simDataService, IEstateDataService estateDataService, |
662 | ModuleLoader moduleLoader, bool dumpAssetsToFile, | 661 | bool dumpAssetsToFile, |
663 | IConfigSource config, string simulatorVersion) | 662 | IConfigSource config, string simulatorVersion) |
664 | : this(regInfo) | 663 | : this(regInfo) |
665 | { | 664 | { |
@@ -670,7 +669,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
670 | Random random = new Random(); | 669 | Random random = new Random(); |
671 | 670 | ||
672 | m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4); | 671 | m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue / 2)) + (uint)(uint.MaxValue / 4); |
673 | m_moduleLoader = moduleLoader; | ||
674 | m_authenticateHandler = authen; | 672 | m_authenticateHandler = authen; |
675 | m_sceneGridService = sceneGridService; | 673 | m_sceneGridService = sceneGridService; |
676 | m_SimulationDataService = simDataService; | 674 | m_SimulationDataService = simDataService; |
@@ -742,7 +740,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
742 | // | 740 | // |
743 | // Out of memory | 741 | // Out of memory |
744 | // Operating system has killed the plugin | 742 | // Operating system has killed the plugin |
745 | m_sceneGraph.UnRecoverableError += RestartNow; | 743 | m_sceneGraph.UnRecoverableError |
744 | += () => | ||
745 | { | ||
746 | m_log.ErrorFormat("[SCENE]: Restarting region {0} due to unrecoverable physics crash", Name); | ||
747 | RestartNow(); | ||
748 | }; | ||
746 | 749 | ||
747 | RegisterDefaultSceneEvents(); | 750 | RegisterDefaultSceneEvents(); |
748 | 751 | ||
@@ -1136,15 +1139,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1136 | } | 1139 | } |
1137 | } | 1140 | } |
1138 | 1141 | ||
1139 | m_log.Error("[REGION]: Closing"); | 1142 | m_log.InfoFormat("[REGION]: Restarting region {0}", Name); |
1140 | Close(); | ||
1141 | 1143 | ||
1142 | if (PhysicsScene != null) | 1144 | Close(); |
1143 | { | ||
1144 | PhysicsScene.Dispose(); | ||
1145 | } | ||
1146 | |||
1147 | m_log.Error("[REGION]: Firing Region Restart Message"); | ||
1148 | 1145 | ||
1149 | base.Restart(); | 1146 | base.Restart(); |
1150 | } | 1147 | } |
@@ -1267,6 +1264,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1267 | // This is the method that shuts down the scene. | 1264 | // This is the method that shuts down the scene. |
1268 | public override void Close() | 1265 | public override void Close() |
1269 | { | 1266 | { |
1267 | if (m_shuttingDown) | ||
1268 | { | ||
1269 | m_log.WarnFormat("[SCENE]: Ignoring close request because already closing {0}", Name); | ||
1270 | return; | ||
1271 | } | ||
1272 | |||
1270 | m_log.InfoFormat("[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName); | 1273 | m_log.InfoFormat("[SCENE]: Closing down the single simulator: {0}", RegionInfo.RegionName); |
1271 | 1274 | ||
1272 | StatsReporter.Close(); | 1275 | StatsReporter.Close(); |
@@ -1310,6 +1313,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1310 | 1313 | ||
1311 | m_sceneGraph.Close(); | 1314 | m_sceneGraph.Close(); |
1312 | 1315 | ||
1316 | if (!GridService.DeregisterRegion(RegionInfo.RegionID)) | ||
1317 | m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name); | ||
1318 | |||
1319 | base.Close(); | ||
1320 | |||
1321 | // XEngine currently listens to the EventManager.OnShutdown event to trigger script stop and persistence. | ||
1322 | // Therefore. we must dispose of the PhysicsScene after this to prevent a window where script code can | ||
1323 | // attempt to reference a null or disposed physics scene. | ||
1313 | if (PhysicsScene != null) | 1324 | if (PhysicsScene != null) |
1314 | { | 1325 | { |
1315 | PhysicsScene phys = PhysicsScene; | 1326 | PhysicsScene phys = PhysicsScene; |
@@ -1318,12 +1329,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1318 | phys.Dispose(); | 1329 | phys.Dispose(); |
1319 | phys = null; | 1330 | phys = null; |
1320 | } | 1331 | } |
1321 | |||
1322 | if (!GridService.DeregisterRegion(RegionInfo.RegionID)) | ||
1323 | m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", Name); | ||
1324 | |||
1325 | // call the base class Close method. | ||
1326 | base.Close(); | ||
1327 | } | 1332 | } |
1328 | 1333 | ||
1329 | /// <summary> | 1334 | /// <summary> |
@@ -1684,12 +1689,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
1684 | 1689 | ||
1685 | private void CheckAtTargets() | 1690 | private void CheckAtTargets() |
1686 | { | 1691 | { |
1687 | Dictionary<UUID, SceneObjectGroup>.ValueCollection objs; | 1692 | List<SceneObjectGroup> objs = null; |
1693 | |||
1688 | lock (m_groupsWithTargets) | 1694 | lock (m_groupsWithTargets) |
1689 | objs = m_groupsWithTargets.Values; | 1695 | { |
1696 | if (m_groupsWithTargets.Count != 0) | ||
1697 | objs = new List<SceneObjectGroup>(m_groupsWithTargets.Values); | ||
1698 | } | ||
1690 | 1699 | ||
1691 | foreach (SceneObjectGroup entry in objs) | 1700 | if (objs != null) |
1692 | entry.checkAtTargets(); | 1701 | { |
1702 | foreach (SceneObjectGroup entry in objs) | ||
1703 | entry.checkAtTargets(); | ||
1704 | } | ||
1693 | } | 1705 | } |
1694 | 1706 | ||
1695 | /// <summary> | 1707 | /// <summary> |
@@ -3373,9 +3385,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3373 | } | 3385 | } |
3374 | else | 3386 | else |
3375 | { | 3387 | { |
3376 | // We remove the acd up here to avoid later raec conditions if two RemoveClient() calls occurred | 3388 | // We remove the acd up here to avoid later race conditions if two RemoveClient() calls occurred |
3377 | // simultaneously. | 3389 | // simultaneously. |
3378 | m_authenticateHandler.RemoveCircuit(acd.circuitcode); | 3390 | // We also need to remove by agent ID since NPCs will have no circuit code. |
3391 | m_authenticateHandler.RemoveCircuit(agentID); | ||
3379 | } | 3392 | } |
3380 | } | 3393 | } |
3381 | 3394 | ||
@@ -3427,9 +3440,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3427 | if (closeChildAgents && CapsModule != null) | 3440 | if (closeChildAgents && CapsModule != null) |
3428 | CapsModule.RemoveCaps(agentID); | 3441 | CapsModule.RemoveCaps(agentID); |
3429 | 3442 | ||
3430 | // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever | 3443 | // // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever |
3431 | // this method is doing is HORRIBLE!!! | 3444 | // // this method is doing is HORRIBLE!!! |
3432 | avatar.Scene.NeedSceneCacheClear(avatar.UUID); | 3445 | // Commented pending deletion since this method no longer appears to do anything at all |
3446 | // avatar.Scene.NeedSceneCacheClear(avatar.UUID); | ||
3433 | 3447 | ||
3434 | if (closeChildAgents && !isChildAgent) | 3448 | if (closeChildAgents && !isChildAgent) |
3435 | { | 3449 | { |
@@ -4688,13 +4702,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
4688 | /// Get a group via its UUID | 4702 | /// Get a group via its UUID |
4689 | /// </summary> | 4703 | /// </summary> |
4690 | /// <param name="fullID"></param> | 4704 | /// <param name="fullID"></param> |
4691 | /// <returns>null if no group with that name exists</returns> | 4705 | /// <returns>null if no group with that id exists</returns> |
4692 | public SceneObjectGroup GetSceneObjectGroup(UUID fullID) | 4706 | public SceneObjectGroup GetSceneObjectGroup(UUID fullID) |
4693 | { | 4707 | { |
4694 | return m_sceneGraph.GetSceneObjectGroup(fullID); | 4708 | return m_sceneGraph.GetSceneObjectGroup(fullID); |
4695 | } | 4709 | } |
4696 | 4710 | ||
4697 | /// <summary> | 4711 | /// <summary> |
4712 | /// Get a group via its local ID | ||
4713 | /// </summary> | ||
4714 | /// <remarks>This will only return a group if the local ID matches a root part</remarks> | ||
4715 | /// <param name="localID"></param> | ||
4716 | /// <returns>null if no group with that id exists</returns> | ||
4717 | public SceneObjectGroup GetSceneObjectGroup(uint localID) | ||
4718 | { | ||
4719 | return m_sceneGraph.GetSceneObjectGroup(localID); | ||
4720 | } | ||
4721 | |||
4722 | /// <summary> | ||
4698 | /// Get a group by name from the scene (will return the first | 4723 | /// Get a group by name from the scene (will return the first |
4699 | /// found, if there are more than one prim with the same name) | 4724 | /// found, if there are more than one prim with the same name) |
4700 | /// </summary> | 4725 | /// </summary> |
@@ -4854,14 +4879,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
4854 | client.SendRegionHandle(regionID, handle); | 4879 | client.SendRegionHandle(regionID, handle); |
4855 | } | 4880 | } |
4856 | 4881 | ||
4857 | public bool NeedSceneCacheClear(UUID agentID) | 4882 | // Commented pending deletion since this method no longer appears to do anything at all |
4858 | { | 4883 | // public bool NeedSceneCacheClear(UUID agentID) |
4859 | IInventoryTransferModule inv = RequestModuleInterface<IInventoryTransferModule>(); | 4884 | // { |
4860 | if (inv == null) | 4885 | // IInventoryTransferModule inv = RequestModuleInterface<IInventoryTransferModule>(); |
4861 | return true; | 4886 | // if (inv == null) |
4862 | 4887 | // return true; | |
4863 | return inv.NeedSceneCacheClear(agentID, this); | 4888 | // |
4864 | } | 4889 | // return inv.NeedSceneCacheClear(agentID, this); |
4890 | // } | ||
4865 | 4891 | ||
4866 | public void CleanTempObjects() | 4892 | public void CleanTempObjects() |
4867 | { | 4893 | { |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index b87a38a..d3e968e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -67,12 +67,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
67 | /// <value> | 67 | /// <value> |
68 | /// All the region modules attached to this scene. | 68 | /// All the region modules attached to this scene. |
69 | /// </value> | 69 | /// </value> |
70 | public Dictionary<string, IRegionModule> Modules | ||
71 | { | ||
72 | get { return m_modules; } | ||
73 | } | ||
74 | protected Dictionary<string, IRegionModule> m_modules = new Dictionary<string, IRegionModule>(); | ||
75 | |||
76 | public Dictionary<string, IRegionModuleBase> RegionModules | 70 | public Dictionary<string, IRegionModuleBase> RegionModules |
77 | { | 71 | { |
78 | get { return m_regionModules; } | 72 | get { return m_regionModules; } |
@@ -272,16 +266,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
272 | /// </summary> | 266 | /// </summary> |
273 | public virtual void Close() | 267 | public virtual void Close() |
274 | { | 268 | { |
275 | // Shut down all non shared modules. | ||
276 | foreach (IRegionModule module in Modules.Values) | ||
277 | { | ||
278 | if (!module.IsSharedModule) | ||
279 | { | ||
280 | module.Close(); | ||
281 | } | ||
282 | } | ||
283 | Modules.Clear(); | ||
284 | |||
285 | try | 269 | try |
286 | { | 270 | { |
287 | EventManager.TriggerShutdown(); | 271 | EventManager.TriggerShutdown(); |
@@ -312,19 +296,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
312 | #region Module Methods | 296 | #region Module Methods |
313 | 297 | ||
314 | /// <summary> | 298 | /// <summary> |
315 | /// Add a module to this scene. | ||
316 | /// </summary> | ||
317 | /// <param name="name"></param> | ||
318 | /// <param name="module"></param> | ||
319 | public void AddModule(string name, IRegionModule module) | ||
320 | { | ||
321 | if (!Modules.ContainsKey(name)) | ||
322 | { | ||
323 | Modules.Add(name, module); | ||
324 | } | ||
325 | } | ||
326 | |||
327 | /// <summary> | ||
328 | /// Add a region-module to this scene. TODO: This will replace AddModule in the future. | 299 | /// Add a region-module to this scene. TODO: This will replace AddModule in the future. |
329 | /// </summary> | 300 | /// </summary> |
330 | /// <param name="name"></param> | 301 | /// <param name="name"></param> |
@@ -508,9 +479,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
508 | /// <param name="shorthelp"></param> | 479 | /// <param name="shorthelp"></param> |
509 | /// <param name="longhelp"></param> | 480 | /// <param name="longhelp"></param> |
510 | /// <param name="callback"></param> | 481 | /// <param name="callback"></param> |
511 | public void AddCommand(object mod, string command, string shorthelp, string longhelp, CommandDelegate callback) | 482 | public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) |
512 | { | 483 | { |
513 | AddCommand(mod, command, shorthelp, longhelp, string.Empty, callback); | 484 | AddCommand(module, command, shorthelp, longhelp, string.Empty, callback); |
514 | } | 485 | } |
515 | 486 | ||
516 | /// <summary> | 487 | /// <summary> |
@@ -528,9 +499,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
528 | /// <param name="longhelp"></param> | 499 | /// <param name="longhelp"></param> |
529 | /// <param name="callback"></param> | 500 | /// <param name="callback"></param> |
530 | public void AddCommand( | 501 | public void AddCommand( |
531 | string category, object mod, string command, string shorthelp, string longhelp, CommandDelegate callback) | 502 | string category, IRegionModuleBase module, string command, string shorthelp, string longhelp, CommandDelegate callback) |
532 | { | 503 | { |
533 | AddCommand(category, mod, command, shorthelp, longhelp, string.Empty, callback); | 504 | AddCommand(category, module, command, shorthelp, longhelp, string.Empty, callback); |
534 | } | 505 | } |
535 | 506 | ||
536 | /// <summary> | 507 | /// <summary> |
@@ -542,29 +513,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
542 | /// <param name="longhelp"></param> | 513 | /// <param name="longhelp"></param> |
543 | /// <param name="descriptivehelp"></param> | 514 | /// <param name="descriptivehelp"></param> |
544 | /// <param name="callback"></param> | 515 | /// <param name="callback"></param> |
545 | public void AddCommand(object mod, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) | 516 | public void AddCommand(IRegionModuleBase module, string command, string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) |
546 | { | 517 | { |
547 | string moduleName = ""; | 518 | string moduleName = ""; |
548 | 519 | ||
549 | if (mod != null) | 520 | if (module != null) |
550 | { | 521 | moduleName = module.Name; |
551 | if (mod is IRegionModule) | ||
552 | { | ||
553 | IRegionModule module = (IRegionModule)mod; | ||
554 | moduleName = module.Name; | ||
555 | } | ||
556 | else if (mod is IRegionModuleBase) | ||
557 | { | ||
558 | IRegionModuleBase module = (IRegionModuleBase)mod; | ||
559 | moduleName = module.Name; | ||
560 | } | ||
561 | else | ||
562 | { | ||
563 | throw new Exception("AddCommand module parameter must be IRegionModule or IRegionModuleBase"); | ||
564 | } | ||
565 | } | ||
566 | 522 | ||
567 | AddCommand(moduleName, mod, command, shorthelp, longhelp, descriptivehelp, callback); | 523 | AddCommand(moduleName, module, command, shorthelp, longhelp, descriptivehelp, callback); |
568 | } | 524 | } |
569 | 525 | ||
570 | /// <summary> | 526 | /// <summary> |
@@ -580,7 +536,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
580 | /// <param name="descriptivehelp"></param> | 536 | /// <param name="descriptivehelp"></param> |
581 | /// <param name="callback"></param> | 537 | /// <param name="callback"></param> |
582 | public void AddCommand( | 538 | public void AddCommand( |
583 | string category, object mod, string command, | 539 | string category, IRegionModuleBase module, string command, |
584 | string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) | 540 | string shorthelp, string longhelp, string descriptivehelp, CommandDelegate callback) |
585 | { | 541 | { |
586 | if (MainConsole.Instance == null) | 542 | if (MainConsole.Instance == null) |
@@ -588,22 +544,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
588 | 544 | ||
589 | bool shared = false; | 545 | bool shared = false; |
590 | 546 | ||
591 | if (mod != null) | 547 | if (module != null) |
592 | { | 548 | shared = module is ISharedRegionModule; |
593 | if (mod is IRegionModule) | ||
594 | { | ||
595 | IRegionModule module = (IRegionModule)mod; | ||
596 | shared = module.IsSharedModule; | ||
597 | } | ||
598 | else if (mod is IRegionModuleBase) | ||
599 | { | ||
600 | shared = mod is ISharedRegionModule; | ||
601 | } | ||
602 | else | ||
603 | { | ||
604 | throw new Exception("AddCommand module parameter must be IRegionModule or IRegionModuleBase"); | ||
605 | } | ||
606 | } | ||
607 | 549 | ||
608 | MainConsole.Instance.Commands.AddCommand( | 550 | MainConsole.Instance.Commands.AddCommand( |
609 | category, shared, command, shorthelp, longhelp, descriptivehelp, callback); | 551 | category, shared, command, shorthelp, longhelp, descriptivehelp, callback); |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 209a770..a4383fd 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -983,6 +983,30 @@ namespace OpenSim.Region.Framework.Scenes | |||
983 | } | 983 | } |
984 | 984 | ||
985 | /// <summary> | 985 | /// <summary> |
986 | /// Get a group in the scene | ||
987 | /// </summary> | ||
988 | /// <remarks> | ||
989 | /// This will only return a group if the local ID matches the root part, not other parts. | ||
990 | /// </remarks> | ||
991 | /// <param name="localID">Local id of the root part of the group</param> | ||
992 | /// <returns>null if no such group was found</returns> | ||
993 | protected internal SceneObjectGroup GetSceneObjectGroup(uint localID) | ||
994 | { | ||
995 | lock (SceneObjectGroupsByLocalPartID) | ||
996 | { | ||
997 | if (SceneObjectGroupsByLocalPartID.ContainsKey(localID)) | ||
998 | { | ||
999 | SceneObjectGroup so = SceneObjectGroupsByLocalPartID[localID]; | ||
1000 | |||
1001 | if (so.LocalId == localID) | ||
1002 | return so; | ||
1003 | } | ||
1004 | } | ||
1005 | |||
1006 | return null; | ||
1007 | } | ||
1008 | |||
1009 | /// <summary> | ||
986 | /// Get a group by name from the scene (will return the first | 1010 | /// Get a group by name from the scene (will return the first |
987 | /// found, if there are more than one prim with the same name) | 1011 | /// found, if there are more than one prim with the same name) |
988 | /// </summary> | 1012 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index cb5b2ba..1e2e973 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -100,23 +100,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
100 | } | 100 | } |
101 | 101 | ||
102 | private readonly List<Scene> m_localScenes = new List<Scene>(); | 102 | private readonly List<Scene> m_localScenes = new List<Scene>(); |
103 | private Scene m_currentScene = null; | ||
104 | 103 | ||
105 | public List<Scene> Scenes | 104 | public List<Scene> Scenes |
106 | { | 105 | { |
107 | get { return new List<Scene>(m_localScenes); } | 106 | get { return new List<Scene>(m_localScenes); } |
108 | } | 107 | } |
109 | 108 | ||
110 | public Scene CurrentScene | 109 | /// <summary> |
111 | { | 110 | /// Scene selected from the console. |
112 | get { return m_currentScene; } | 111 | /// </summary> |
113 | } | 112 | /// <value> |
113 | /// If null, then all scenes are considered selected (signalled as "Root" on the console). | ||
114 | /// </value> | ||
115 | public Scene CurrentScene { get; private set; } | ||
114 | 116 | ||
115 | public Scene CurrentOrFirstScene | 117 | public Scene CurrentOrFirstScene |
116 | { | 118 | { |
117 | get | 119 | get |
118 | { | 120 | { |
119 | if (m_currentScene == null) | 121 | if (CurrentScene == null) |
120 | { | 122 | { |
121 | lock (m_localScenes) | 123 | lock (m_localScenes) |
122 | { | 124 | { |
@@ -128,7 +130,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
128 | } | 130 | } |
129 | else | 131 | else |
130 | { | 132 | { |
131 | return m_currentScene; | 133 | return CurrentScene; |
132 | } | 134 | } |
133 | } | 135 | } |
134 | } | 136 | } |
@@ -141,31 +143,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
141 | 143 | ||
142 | public void Close() | 144 | public void Close() |
143 | { | 145 | { |
144 | // collect known shared modules in sharedModules | ||
145 | Dictionary<string, IRegionModule> sharedModules = new Dictionary<string, IRegionModule>(); | ||
146 | |||
147 | lock (m_localScenes) | 146 | lock (m_localScenes) |
148 | { | 147 | { |
149 | for (int i = 0; i < m_localScenes.Count; i++) | 148 | for (int i = 0; i < m_localScenes.Count; i++) |
150 | { | 149 | { |
151 | // extract known shared modules from scene | ||
152 | foreach (string k in m_localScenes[i].Modules.Keys) | ||
153 | { | ||
154 | if (m_localScenes[i].Modules[k].IsSharedModule && | ||
155 | !sharedModules.ContainsKey(k)) | ||
156 | sharedModules[k] = m_localScenes[i].Modules[k]; | ||
157 | } | ||
158 | // close scene/region | ||
159 | m_localScenes[i].Close(); | 150 | m_localScenes[i].Close(); |
160 | } | 151 | } |
161 | } | 152 | } |
162 | |||
163 | // all regions/scenes are now closed, we can now safely | ||
164 | // close all shared modules | ||
165 | foreach (IRegionModule mod in sharedModules.Values) | ||
166 | { | ||
167 | mod.Close(); | ||
168 | } | ||
169 | } | 153 | } |
170 | 154 | ||
171 | public void Close(Scene cscene) | 155 | public void Close(Scene cscene) |
@@ -196,8 +180,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
196 | 180 | ||
197 | public void HandleRestart(RegionInfo rdata) | 181 | public void HandleRestart(RegionInfo rdata) |
198 | { | 182 | { |
199 | m_log.Error("[SCENEMANAGER]: Got Restart message for region:" + rdata.RegionName + " Sending up to main"); | 183 | Scene restartedScene = null; |
200 | int RegionSceneElement = -1; | ||
201 | 184 | ||
202 | lock (m_localScenes) | 185 | lock (m_localScenes) |
203 | { | 186 | { |
@@ -205,19 +188,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
205 | { | 188 | { |
206 | if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) | 189 | if (rdata.RegionName == m_localScenes[i].RegionInfo.RegionName) |
207 | { | 190 | { |
208 | RegionSceneElement = i; | 191 | restartedScene = m_localScenes[i]; |
192 | m_localScenes.RemoveAt(i); | ||
193 | break; | ||
209 | } | 194 | } |
210 | } | 195 | } |
211 | |||
212 | // Now we make sure the region is no longer known about by the SceneManager | ||
213 | // Prevents duplicates. | ||
214 | |||
215 | if (RegionSceneElement >= 0) | ||
216 | { | ||
217 | m_localScenes.RemoveAt(RegionSceneElement); | ||
218 | } | ||
219 | } | 196 | } |
220 | 197 | ||
198 | // If the currently selected scene has been restarted, then we can't reselect here since we the scene | ||
199 | // hasn't yet been recreated. We will have to leave this to the caller. | ||
200 | if (CurrentScene == restartedScene) | ||
201 | CurrentScene = null; | ||
202 | |||
221 | // Send signal to main that we're restarting this sim. | 203 | // Send signal to main that we're restarting this sim. |
222 | OnRestartSim(rdata); | 204 | OnRestartSim(rdata); |
223 | } | 205 | } |
@@ -359,14 +341,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
359 | 341 | ||
360 | private void ForEachCurrentScene(Action<Scene> func) | 342 | private void ForEachCurrentScene(Action<Scene> func) |
361 | { | 343 | { |
362 | if (m_currentScene == null) | 344 | if (CurrentScene == null) |
363 | { | 345 | { |
364 | lock (m_localScenes) | 346 | lock (m_localScenes) |
365 | m_localScenes.ForEach(func); | 347 | m_localScenes.ForEach(func); |
366 | } | 348 | } |
367 | else | 349 | else |
368 | { | 350 | { |
369 | func(m_currentScene); | 351 | func(CurrentScene); |
370 | } | 352 | } |
371 | } | 353 | } |
372 | 354 | ||
@@ -386,7 +368,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
386 | || (String.Compare(regionName, "..") == 0) | 368 | || (String.Compare(regionName, "..") == 0) |
387 | || (String.Compare(regionName, "/") == 0)) | 369 | || (String.Compare(regionName, "/") == 0)) |
388 | { | 370 | { |
389 | m_currentScene = null; | 371 | CurrentScene = null; |
390 | return true; | 372 | return true; |
391 | } | 373 | } |
392 | else | 374 | else |
@@ -397,7 +379,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
397 | { | 379 | { |
398 | if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) | 380 | if (String.Compare(scene.RegionInfo.RegionName, regionName, true) == 0) |
399 | { | 381 | { |
400 | m_currentScene = scene; | 382 | CurrentScene = scene; |
401 | return true; | 383 | return true; |
402 | } | 384 | } |
403 | } | 385 | } |
@@ -417,7 +399,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
417 | { | 399 | { |
418 | if (scene.RegionInfo.RegionID == regionID) | 400 | if (scene.RegionInfo.RegionID == regionID) |
419 | { | 401 | { |
420 | m_currentScene = scene; | 402 | CurrentScene = scene; |
421 | return true; | 403 | return true; |
422 | } | 404 | } |
423 | } | 405 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 27ef4c9..f79ac96 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -2239,7 +2239,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2239 | 2239 | ||
2240 | // play the sound. | 2240 | // play the sound. |
2241 | if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) | 2241 | if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) |
2242 | SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false); | 2242 | { |
2243 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | ||
2244 | if (soundModule != null) | ||
2245 | { | ||
2246 | soundModule.SendSound(UUID, CollisionSound, | ||
2247 | CollisionSoundVolume, true, (byte)0, 0, false, | ||
2248 | false); | ||
2249 | } | ||
2250 | } | ||
2243 | 2251 | ||
2244 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); | 2252 | SendCollisionEvent(scriptEvents.collision_start, startedColliders, ParentGroup.Scene.EventManager.TriggerScriptCollidingStart); |
2245 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); | 2253 | SendCollisionEvent(scriptEvents.collision , m_lastColliders , ParentGroup.Scene.EventManager.TriggerScriptColliding); |
@@ -2287,37 +2295,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2287 | ScheduleTerseUpdate(); | 2295 | ScheduleTerseUpdate(); |
2288 | } | 2296 | } |
2289 | 2297 | ||
2290 | public void PreloadSound(string sound) | ||
2291 | { | ||
2292 | // UUID ownerID = OwnerID; | ||
2293 | UUID objectID = ParentGroup.RootPart.UUID; | ||
2294 | UUID soundID = UUID.Zero; | ||
2295 | |||
2296 | if (!UUID.TryParse(sound, out soundID)) | ||
2297 | { | ||
2298 | //Trys to fetch sound id from prim's inventory. | ||
2299 | //Prim's inventory doesn't support non script items yet | ||
2300 | |||
2301 | lock (TaskInventory) | ||
2302 | { | ||
2303 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | ||
2304 | { | ||
2305 | if (item.Value.Name == sound) | ||
2306 | { | ||
2307 | soundID = item.Value.ItemID; | ||
2308 | break; | ||
2309 | } | ||
2310 | } | ||
2311 | } | ||
2312 | } | ||
2313 | |||
2314 | ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) | ||
2315 | { | ||
2316 | if (!(Util.GetDistanceTo(sp.AbsolutePosition, AbsolutePosition) >= 100)) | ||
2317 | sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); | ||
2318 | }); | ||
2319 | } | ||
2320 | |||
2321 | public void RemFlag(PrimFlags flag) | 2298 | public void RemFlag(PrimFlags flag) |
2322 | { | 2299 | { |
2323 | // PrimFlags prevflag = Flags; | 2300 | // PrimFlags prevflag = Flags; |
@@ -2676,98 +2653,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2676 | } | 2653 | } |
2677 | 2654 | ||
2678 | /// <summary> | 2655 | /// <summary> |
2679 | /// Trigger or play an attached sound in this part's inventory. | ||
2680 | /// </summary> | ||
2681 | /// <param name="sound"></param> | ||
2682 | /// <param name="volume"></param> | ||
2683 | /// <param name="triggered"></param> | ||
2684 | /// <param name="flags"></param> | ||
2685 | public void SendSound(string sound, double volume, bool triggered, byte flags, float radius, bool useMaster, bool isMaster) | ||
2686 | { | ||
2687 | if (volume > 1) | ||
2688 | volume = 1; | ||
2689 | if (volume < 0) | ||
2690 | volume = 0; | ||
2691 | |||
2692 | UUID ownerID = OwnerID; | ||
2693 | UUID objectID = ParentGroup.RootPart.UUID; | ||
2694 | UUID parentID = ParentGroup.UUID; | ||
2695 | |||
2696 | UUID soundID = UUID.Zero; | ||
2697 | Vector3 position = AbsolutePosition; // region local | ||
2698 | ulong regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; | ||
2699 | |||
2700 | if (!UUID.TryParse(sound, out soundID)) | ||
2701 | { | ||
2702 | // search sound file from inventory | ||
2703 | lock (TaskInventory) | ||
2704 | { | ||
2705 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory) | ||
2706 | { | ||
2707 | if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound) | ||
2708 | { | ||
2709 | soundID = item.Value.ItemID; | ||
2710 | break; | ||
2711 | } | ||
2712 | } | ||
2713 | } | ||
2714 | } | ||
2715 | |||
2716 | if (soundID == UUID.Zero) | ||
2717 | return; | ||
2718 | |||
2719 | ISoundModule soundModule = ParentGroup.Scene.RequestModuleInterface<ISoundModule>(); | ||
2720 | if (soundModule != null) | ||
2721 | { | ||
2722 | if (useMaster) | ||
2723 | { | ||
2724 | if (isMaster) | ||
2725 | { | ||
2726 | if (triggered) | ||
2727 | soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); | ||
2728 | else | ||
2729 | soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); | ||
2730 | ParentGroup.PlaySoundMasterPrim = this; | ||
2731 | ownerID = OwnerID; | ||
2732 | objectID = ParentGroup.RootPart.UUID; | ||
2733 | parentID = ParentGroup.UUID; | ||
2734 | position = AbsolutePosition; // region local | ||
2735 | regionHandle = ParentGroup.Scene.RegionInfo.RegionHandle; | ||
2736 | if (triggered) | ||
2737 | soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); | ||
2738 | else | ||
2739 | soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); | ||
2740 | foreach (SceneObjectPart prim in ParentGroup.PlaySoundSlavePrims) | ||
2741 | { | ||
2742 | ownerID = prim.OwnerID; | ||
2743 | objectID = prim.ParentGroup.RootPart.UUID; | ||
2744 | parentID = prim.ParentGroup.UUID; | ||
2745 | position = prim.AbsolutePosition; // region local | ||
2746 | regionHandle = prim.ParentGroup.Scene.RegionInfo.RegionHandle; | ||
2747 | if (triggered) | ||
2748 | soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); | ||
2749 | else | ||
2750 | soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); | ||
2751 | } | ||
2752 | ParentGroup.PlaySoundSlavePrims.Clear(); | ||
2753 | ParentGroup.PlaySoundMasterPrim = null; | ||
2754 | } | ||
2755 | else | ||
2756 | { | ||
2757 | ParentGroup.PlaySoundSlavePrims.Add(this); | ||
2758 | } | ||
2759 | } | ||
2760 | else | ||
2761 | { | ||
2762 | if (triggered) | ||
2763 | soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius); | ||
2764 | else | ||
2765 | soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius); | ||
2766 | } | ||
2767 | } | ||
2768 | } | ||
2769 | |||
2770 | /// <summary> | ||
2771 | /// Send a terse update to all clients | 2656 | /// Send a terse update to all clients |
2772 | /// </summary> | 2657 | /// </summary> |
2773 | public void SendTerseUpdateToAllClients() | 2658 | public void SendTerseUpdateToAllClients() |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index bdb0446..db723fa 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -232,31 +232,49 @@ namespace OpenSim.Region.Framework.Scenes | |||
232 | if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null) | 232 | if (m_part == null || m_part.ParentGroup == null || m_part.ParentGroup.Scene == null) |
233 | return; | 233 | return; |
234 | 234 | ||
235 | IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); | ||
236 | if (engines == null) // No engine at all | ||
237 | return; | ||
238 | |||
239 | lock (Items) | 235 | lock (Items) |
240 | { | 236 | { |
241 | foreach (TaskInventoryItem item in Items.Values) | 237 | foreach (TaskInventoryItem item in Items.Values) |
242 | { | 238 | { |
243 | if (item.InvType == (int)InventoryType.LSL) | 239 | bool running; |
244 | { | 240 | if (TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running)) |
245 | foreach (IScriptModule e in engines) | 241 | item.ScriptRunning = running; |
246 | { | ||
247 | bool running; | ||
248 | |||
249 | if (e.HasScript(item.ItemID, out running)) | ||
250 | { | ||
251 | item.ScriptRunning = running; | ||
252 | break; | ||
253 | } | ||
254 | } | ||
255 | } | ||
256 | } | 242 | } |
257 | } | 243 | } |
258 | } | 244 | } |
259 | 245 | ||
246 | public bool TryGetScriptInstanceRunning(UUID itemId, out bool running) | ||
247 | { | ||
248 | running = false; | ||
249 | |||
250 | TaskInventoryItem item = GetInventoryItem(itemId); | ||
251 | |||
252 | if (item == null) | ||
253 | return false; | ||
254 | |||
255 | return TryGetScriptInstanceRunning(m_part.ParentGroup.Scene, item, out running); | ||
256 | } | ||
257 | |||
258 | public static bool TryGetScriptInstanceRunning(Scene scene, TaskInventoryItem item, out bool running) | ||
259 | { | ||
260 | running = false; | ||
261 | |||
262 | if (item.InvType != (int)InventoryType.LSL) | ||
263 | return false; | ||
264 | |||
265 | IScriptModule[] engines = scene.RequestModuleInterfaces<IScriptModule>(); | ||
266 | if (engines == null) // No engine at all | ||
267 | return false; | ||
268 | |||
269 | foreach (IScriptModule e in engines) | ||
270 | { | ||
271 | if (e.HasScript(item.ItemID, out running)) | ||
272 | return true; | ||
273 | } | ||
274 | |||
275 | return false; | ||
276 | } | ||
277 | |||
260 | public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) | 278 | public int CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource) |
261 | { | 279 | { |
262 | int scriptsValidForStarting = 0; | 280 | int scriptsValidForStarting = 0; |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 1222ac6..6f36c0b 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -1,4 +1,4 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
@@ -68,14 +68,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
68 | public ScriptControlled eventControls; | 68 | public ScriptControlled eventControls; |
69 | } | 69 | } |
70 | 70 | ||
71 | public delegate void SendCourseLocationsMethod(UUID scene, ScenePresence presence, List<Vector3> coarseLocations, List<UUID> avatarUUIDs); | 71 | public delegate void SendCoarseLocationsMethod(UUID scene, ScenePresence presence, List<Vector3> coarseLocations, List<UUID> avatarUUIDs); |
72 | 72 | ||
73 | public class ScenePresence : EntityBase, IScenePresence | 73 | public class ScenePresence : EntityBase, IScenePresence |
74 | { | 74 | { |
75 | // ~ScenePresence() | 75 | // ~ScenePresence() |
76 | // { | 76 | // { |
77 | // m_log.Debug("[SCENE PRESENCE] Destructor called"); | 77 | // m_log.DebugFormat("[SCENE PRESENCE]: Destructor called on {0}", Name); |
78 | // } | 78 | // } |
79 | |||
79 | private void TriggerScenePresenceUpdated() | 80 | private void TriggerScenePresenceUpdated() |
80 | { | 81 | { |
81 | if (m_scene != null) | 82 | if (m_scene != null) |
@@ -186,7 +187,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
186 | /// </summary> | 187 | /// </summary> |
187 | public bool SitGround { get; private set; } | 188 | public bool SitGround { get; private set; } |
188 | 189 | ||
189 | private SendCourseLocationsMethod m_sendCourseLocationsMethod; | 190 | private SendCoarseLocationsMethod m_sendCoarseLocationsMethod; |
190 | 191 | ||
191 | //private Vector3 m_requestedSitOffset = new Vector3(); | 192 | //private Vector3 m_requestedSitOffset = new Vector3(); |
192 | 193 | ||
@@ -537,7 +538,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
537 | { | 538 | { |
538 | try | 539 | try |
539 | { | 540 | { |
540 | PhysicsActor.Velocity = value; | 541 | PhysicsActor.TargetVelocity = value; |
541 | } | 542 | } |
542 | catch (Exception e) | 543 | catch (Exception e) |
543 | { | 544 | { |
@@ -695,7 +696,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
695 | AttachmentsSyncLock = new Object(); | 696 | AttachmentsSyncLock = new Object(); |
696 | AllowMovement = true; | 697 | AllowMovement = true; |
697 | IsChildAgent = true; | 698 | IsChildAgent = true; |
698 | m_sendCourseLocationsMethod = SendCoarseLocationsDefault; | 699 | m_sendCoarseLocationsMethod = SendCoarseLocationsDefault; |
699 | Animator = new ScenePresenceAnimator(this); | 700 | Animator = new ScenePresenceAnimator(this); |
700 | PresenceType = type; | 701 | PresenceType = type; |
701 | DrawDistance = world.DefaultDrawDistance; | 702 | DrawDistance = world.DefaultDrawDistance; |
@@ -1697,8 +1698,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1697 | // "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", | 1698 | // "[SCENE PRESENCE]: Avatar {0} received request to move to position {1} in {2}", |
1698 | // Name, pos, m_scene.RegionInfo.RegionName); | 1699 | // Name, pos, m_scene.RegionInfo.RegionName); |
1699 | 1700 | ||
1700 | if (pos.X < 0 || pos.X >= Constants.RegionSize | 1701 | // Allow move to another sub-region within a megaregion |
1701 | || pos.Y < 0 || pos.Y >= Constants.RegionSize | 1702 | Vector2 regionSize; |
1703 | IRegionCombinerModule regionCombinerModule = m_scene.RequestModuleInterface<IRegionCombinerModule>(); | ||
1704 | if (regionCombinerModule != null) | ||
1705 | regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID); | ||
1706 | else | ||
1707 | regionSize = new Vector2(Constants.RegionSize); | ||
1708 | |||
1709 | if (pos.X < 0 || pos.X >= regionSize.X | ||
1710 | || pos.Y < 0 || pos.Y >= regionSize.Y | ||
1702 | || pos.Z < 0) | 1711 | || pos.Z < 0) |
1703 | return; | 1712 | return; |
1704 | 1713 | ||
@@ -1712,7 +1721,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1712 | // pos.Z = AbsolutePosition.Z; | 1721 | // pos.Z = AbsolutePosition.Z; |
1713 | // } | 1722 | // } |
1714 | 1723 | ||
1715 | float terrainHeight = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 1724 | // Get terrain height for sub-region in a megaregion if necessary |
1725 | int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X); | ||
1726 | int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y); | ||
1727 | UUID target_regionID = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y).RegionID; | ||
1728 | Scene targetScene = m_scene; | ||
1729 | |||
1730 | if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene)) | ||
1731 | targetScene = m_scene; | ||
1732 | |||
1733 | float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % Constants.RegionSize), (int)(pos.Y % Constants.RegionSize)]; | ||
1716 | pos.Z = Math.Max(terrainHeight, pos.Z); | 1734 | pos.Z = Math.Max(terrainHeight, pos.Z); |
1717 | 1735 | ||
1718 | // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is | 1736 | // Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is |
@@ -2432,17 +2450,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2432 | 2450 | ||
2433 | public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) | 2451 | public void SendCoarseLocations(List<Vector3> coarseLocations, List<UUID> avatarUUIDs) |
2434 | { | 2452 | { |
2435 | SendCourseLocationsMethod d = m_sendCourseLocationsMethod; | 2453 | SendCoarseLocationsMethod d = m_sendCoarseLocationsMethod; |
2436 | if (d != null) | 2454 | if (d != null) |
2437 | { | 2455 | { |
2438 | d.Invoke(m_scene.RegionInfo.originRegionID, this, coarseLocations, avatarUUIDs); | 2456 | d.Invoke(m_scene.RegionInfo.originRegionID, this, coarseLocations, avatarUUIDs); |
2439 | } | 2457 | } |
2440 | } | 2458 | } |
2441 | 2459 | ||
2442 | public void SetSendCourseLocationMethod(SendCourseLocationsMethod d) | 2460 | public void SetSendCoarseLocationMethod(SendCoarseLocationsMethod d) |
2443 | { | 2461 | { |
2444 | if (d != null) | 2462 | if (d != null) |
2445 | m_sendCourseLocationsMethod = d; | 2463 | m_sendCoarseLocationsMethod = d; |
2446 | } | 2464 | } |
2447 | 2465 | ||
2448 | public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List<Vector3> coarseLocations, List<UUID> avatarUUIDs) | 2466 | public void SendCoarseLocationsDefault(UUID sceneId, ScenePresence p, List<Vector3> coarseLocations, List<UUID> avatarUUIDs) |
@@ -2646,7 +2664,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2646 | #region Significant Movement Method | 2664 | #region Significant Movement Method |
2647 | 2665 | ||
2648 | /// <summary> | 2666 | /// <summary> |
2649 | /// This checks for a significant movement and sends a courselocationchange update | 2667 | /// This checks for a significant movement and sends a coarselocationchange update |
2650 | /// </summary> | 2668 | /// </summary> |
2651 | protected void CheckForSignificantMovement() | 2669 | protected void CheckForSignificantMovement() |
2652 | { | 2670 | { |
@@ -3074,6 +3092,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3074 | cAgent.Anims = Animator.Animations.ToArray(); | 3092 | cAgent.Anims = Animator.Animations.ToArray(); |
3075 | } | 3093 | } |
3076 | catch { } | 3094 | catch { } |
3095 | cAgent.DefaultAnim = Animator.Animations.DefaultAnimation; | ||
3096 | cAgent.AnimState = Animator.Animations.ImplicitDefaultAnimation; | ||
3077 | 3097 | ||
3078 | if (Scene.AttachmentsModule != null) | 3098 | if (Scene.AttachmentsModule != null) |
3079 | Scene.AttachmentsModule.CopyAttachments(this, cAgent); | 3099 | Scene.AttachmentsModule.CopyAttachments(this, cAgent); |
@@ -3145,6 +3165,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3145 | // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? | 3165 | // FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object? |
3146 | if (cAgent.Anims != null) | 3166 | if (cAgent.Anims != null) |
3147 | Animator.Animations.FromArray(cAgent.Anims); | 3167 | Animator.Animations.FromArray(cAgent.Anims); |
3168 | if (cAgent.DefaultAnim != null) | ||
3169 | Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero); | ||
3170 | if (cAgent.AnimState != null) | ||
3171 | Animator.Animations.SetImplicitDefaultAnimation(cAgent.AnimState.AnimID, cAgent.AnimState.SequenceNum, UUID.Zero); | ||
3148 | 3172 | ||
3149 | if (Scene.AttachmentsModule != null) | 3173 | if (Scene.AttachmentsModule != null) |
3150 | Scene.AttachmentsModule.CopyAttachments(cAgent, this); | 3174 | Scene.AttachmentsModule.CopyAttachments(cAgent, this); |
diff --git a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs index 2addb5b..b9d615e 100644 --- a/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs +++ b/OpenSim/Region/Framework/Scenes/SimStatsReporter.cs | |||
@@ -245,11 +245,13 @@ namespace OpenSim.Region.Framework.Scenes | |||
245 | = new Stat( | 245 | = new Stat( |
246 | "SlowFrames", | 246 | "SlowFrames", |
247 | "Slow Frames", | 247 | "Slow Frames", |
248 | "Number of frames where frame time has been significantly longer than the desired frame time.", | ||
248 | " frames", | 249 | " frames", |
249 | "scene", | 250 | "scene", |
250 | m_scene.Name, | 251 | m_scene.Name, |
251 | StatVerbosity.Info, | 252 | StatType.Push, |
252 | "Number of frames where frame time has been significantly longer than the desired frame time."); | 253 | null, |
254 | StatVerbosity.Info); | ||
253 | 255 | ||
254 | StatsManager.RegisterStat(SlowFramesStat); | 256 | StatsManager.RegisterStat(SlowFramesStat); |
255 | } | 257 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs index 4a21dc9..e209221 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs | |||
@@ -37,7 +37,7 @@ using OpenSim.Tests.Common; | |||
37 | namespace OpenSim.Region.Framework.Scenes.Tests | 37 | namespace OpenSim.Region.Framework.Scenes.Tests |
38 | { | 38 | { |
39 | [TestFixture] | 39 | [TestFixture] |
40 | public class BorderTests | 40 | public class BorderTests : OpenSimTestCase |
41 | { | 41 | { |
42 | [Test] | 42 | [Test] |
43 | public void TestCross() | 43 | public void TestCross() |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs index ea9fc93..766ce83 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/EntityManagerTests.cs | |||
@@ -41,7 +41,7 @@ using OpenSim.Tests.Common; | |||
41 | namespace OpenSim.Region.Framework.Scenes.Tests | 41 | namespace OpenSim.Region.Framework.Scenes.Tests |
42 | { | 42 | { |
43 | [TestFixture, LongRunning] | 43 | [TestFixture, LongRunning] |
44 | public class EntityManagerTests | 44 | public class EntityManagerTests : OpenSimTestCase |
45 | { | 45 | { |
46 | static public Random random; | 46 | static public Random random; |
47 | SceneObjectGroup found; | 47 | SceneObjectGroup found; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs index d23c965..575a081 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneGraphTests.cs | |||
@@ -40,7 +40,7 @@ using OpenSim.Tests.Common.Mock; | |||
40 | namespace OpenSim.Region.Framework.Scenes.Tests | 40 | namespace OpenSim.Region.Framework.Scenes.Tests |
41 | { | 41 | { |
42 | [TestFixture] | 42 | [TestFixture] |
43 | public class SceneGraphTests | 43 | public class SceneGraphTests : OpenSimTestCase |
44 | { | 44 | { |
45 | [Test] | 45 | [Test] |
46 | public void TestDuplicateObject() | 46 | public void TestDuplicateObject() |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs new file mode 100644 index 0000000..2d831fa --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneManagerTests.cs | |||
@@ -0,0 +1,58 @@ | |||
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.Reflection; | ||
31 | using System.Threading; | ||
32 | using NUnit.Framework; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications; | ||
36 | using OpenSim.Region.Framework.Scenes; | ||
37 | using OpenSim.Services.Interfaces; | ||
38 | using OpenSim.Tests.Common; | ||
39 | using OpenSim.Tests.Common.Mock; | ||
40 | |||
41 | namespace OpenSim.Region.Framework.Scenes.Tests | ||
42 | { | ||
43 | [TestFixture] | ||
44 | public class SceneManagerTests : OpenSimTestCase | ||
45 | { | ||
46 | [Test] | ||
47 | public void TestClose() | ||
48 | { | ||
49 | TestHelpers.InMethod(); | ||
50 | |||
51 | SceneHelpers sh = new SceneHelpers(); | ||
52 | Scene scene = sh.SetupScene(); | ||
53 | |||
54 | sh.SceneManager.Close(); | ||
55 | Assert.That(scene.ShuttingDown, Is.True); | ||
56 | } | ||
57 | } | ||
58 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index 3398a53..a07d64c 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs | |||
@@ -26,13 +26,16 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using System.Threading; | 31 | using System.Threading; |
32 | using Nini.Config; | ||
31 | using NUnit.Framework; | 33 | using NUnit.Framework; |
32 | using OpenMetaverse; | 34 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 36 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Services.Interfaces; | ||
36 | using OpenSim.Tests.Common; | 39 | using OpenSim.Tests.Common; |
37 | using OpenSim.Tests.Common.Mock; | 40 | using OpenSim.Tests.Common.Mock; |
38 | 41 | ||
@@ -42,7 +45,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
42 | /// Basic scene object tests (create, read and delete but not update). | 45 | /// Basic scene object tests (create, read and delete but not update). |
43 | /// </summary> | 46 | /// </summary> |
44 | [TestFixture] | 47 | [TestFixture] |
45 | public class SceneObjectBasicTests | 48 | public class SceneObjectBasicTests : OpenSimTestCase |
46 | { | 49 | { |
47 | // [TearDown] | 50 | // [TearDown] |
48 | // public void TearDown() | 51 | // public void TearDown() |
@@ -180,6 +183,10 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
180 | /// <summary> | 183 | /// <summary> |
181 | /// Test deleting an object from a scene. | 184 | /// Test deleting an object from a scene. |
182 | /// </summary> | 185 | /// </summary> |
186 | /// <remarks> | ||
187 | /// This is the most basic form of delete. For all more sophisticated forms of derez (done asynchrnously | ||
188 | /// and where object can be taken to user inventory, etc.), see SceneObjectDeRezTests. | ||
189 | /// </remarks> | ||
183 | [Test] | 190 | [Test] |
184 | public void TestDeleteSceneObject() | 191 | public void TestDeleteSceneObject() |
185 | { | 192 | { |
@@ -199,78 +206,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
199 | } | 206 | } |
200 | 207 | ||
201 | /// <summary> | 208 | /// <summary> |
202 | /// Test deleting an object asynchronously | ||
203 | /// </summary> | ||
204 | [Test] | ||
205 | public void TestDeleteSceneObjectAsync() | ||
206 | { | ||
207 | TestHelpers.InMethod(); | ||
208 | //log4net.Config.XmlConfigurator.Configure(); | ||
209 | |||
210 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); | ||
211 | |||
212 | TestScene scene = new SceneHelpers().SetupScene(); | ||
213 | |||
214 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | ||
215 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | ||
216 | sogd.Enabled = false; | ||
217 | |||
218 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene); | ||
219 | |||
220 | IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient; | ||
221 | scene.DeRezObjects(client, new System.Collections.Generic.List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Delete, UUID.Zero); | ||
222 | |||
223 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); | ||
224 | |||
225 | Assert.That(retrievedPart, Is.Not.Null); | ||
226 | |||
227 | Assert.That(so.IsDeleted, Is.False); | ||
228 | |||
229 | sogd.InventoryDeQueueAndDelete(); | ||
230 | |||
231 | Assert.That(so.IsDeleted, Is.True); | ||
232 | |||
233 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | ||
234 | Assert.That(retrievedPart2, Is.Null); | ||
235 | } | ||
236 | |||
237 | /// <summary> | ||
238 | /// Test deleting an object asynchronously to user inventory. | ||
239 | /// </summary> | ||
240 | //[Test] | ||
241 | //public void TestDeleteSceneObjectAsyncToUserInventory() | ||
242 | //{ | ||
243 | // TestHelper.InMethod(); | ||
244 | // //log4net.Config.XmlConfigurator.Configure(); | ||
245 | |||
246 | // UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); | ||
247 | // string myObjectName = "Fred"; | ||
248 | |||
249 | // TestScene scene = SceneSetupHelpers.SetupScene(); | ||
250 | // SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene, myObjectName); | ||
251 | |||
252 | // Assert.That( | ||
253 | // scene.CommsManager.UserAdminService.AddUser( | ||
254 | // "Bob", "Hoskins", "test", "test@test.com", 1000, 1000, agentId), | ||
255 | // Is.EqualTo(agentId)); | ||
256 | |||
257 | // IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId); | ||
258 | |||
259 | // CachedUserInfo userInfo = scene.CommsManager.UserProfileCacheService.GetUserDetails(agentId); | ||
260 | // Assert.That(userInfo, Is.Not.Null); | ||
261 | // Assert.That(userInfo.RootFolder, Is.Not.Null); | ||
262 | |||
263 | // SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client); | ||
264 | |||
265 | // // Check that we now have the taken part in our inventory | ||
266 | // Assert.That(myObjectName, Is.EqualTo(userInfo.RootFolder.FindItemByPath(myObjectName).Name)); | ||
267 | |||
268 | // // Check that the taken part has actually disappeared | ||
269 | // SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | ||
270 | // Assert.That(retrievedPart, Is.Null); | ||
271 | //} | ||
272 | |||
273 | /// <summary> | ||
274 | /// Changing a scene object uuid changes the root part uuid. This is a valid operation if the object is not | 209 | /// Changing a scene object uuid changes the root part uuid. This is a valid operation if the object is not |
275 | /// in a scene and is useful if one wants to supply a UUID directly rather than use the one generated by | 210 | /// in a scene and is useful if one wants to supply a UUID directly rather than use the one generated by |
276 | /// OpenSim. | 211 | /// OpenSim. |
@@ -305,4 +240,4 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
305 | Assert.That(sog.Parts.Length, Is.EqualTo(2)); | 240 | Assert.That(sog.Parts.Length, Is.EqualTo(2)); |
306 | } | 241 | } |
307 | } | 242 | } |
308 | } | 243 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs index 0076f41..c1522e7 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectDeRezTests.cs | |||
@@ -33,22 +33,24 @@ using NUnit.Framework; | |||
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
36 | using OpenSim.Region.CoreModules.Framework.InventoryAccess; | ||
36 | using OpenSim.Region.CoreModules.World.Permissions; | 37 | using OpenSim.Region.CoreModules.World.Permissions; |
37 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
39 | using OpenSim.Services.Interfaces; | ||
38 | using OpenSim.Tests.Common; | 40 | using OpenSim.Tests.Common; |
39 | using OpenSim.Tests.Common.Mock; | 41 | using OpenSim.Tests.Common.Mock; |
40 | 42 | ||
41 | namespace OpenSim.Region.Framework.Scenes.Tests | 43 | namespace OpenSim.Region.Framework.Scenes.Tests |
42 | { | 44 | { |
43 | /// <summary> | 45 | /// <summary> |
44 | /// Tests derez of scene objects by users. | 46 | /// Tests derez of scene objects. |
45 | /// </summary> | 47 | /// </summary> |
46 | /// <remarks> | 48 | /// <remarks> |
47 | /// This is at a level above the SceneObjectBasicTests, which act on the scene directly. | 49 | /// This is at a level above the SceneObjectBasicTests, which act on the scene directly. |
48 | /// TODO: These tests are very incomplete - they only test for a few conditions. | 50 | /// TODO: These tests are incomplete - need to test more kinds of derez (e.g. return object). |
49 | /// </remarks> | 51 | /// </remarks> |
50 | [TestFixture] | 52 | [TestFixture] |
51 | public class SceneObjectDeRezTests | 53 | public class SceneObjectDeRezTests : OpenSimTestCase |
52 | { | 54 | { |
53 | /// <summary> | 55 | /// <summary> |
54 | /// Test deleting an object from a scene. | 56 | /// Test deleting an object from a scene. |
@@ -76,14 +78,20 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
76 | = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero); | 78 | = new SceneObjectPart(userId, PrimitiveBaseShape.Default, Vector3.Zero, Quaternion.Identity, Vector3.Zero); |
77 | part.Name = "obj1"; | 79 | part.Name = "obj1"; |
78 | scene.AddNewSceneObject(new SceneObjectGroup(part), false); | 80 | scene.AddNewSceneObject(new SceneObjectGroup(part), false); |
81 | |||
79 | List<uint> localIds = new List<uint>(); | 82 | List<uint> localIds = new List<uint>(); |
80 | localIds.Add(part.LocalId); | 83 | localIds.Add(part.LocalId); |
81 | |||
82 | scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero); | 84 | scene.DeRezObjects(client, localIds, UUID.Zero, DeRezAction.Delete, UUID.Zero); |
85 | |||
86 | // Check that object isn't deleted until we crank the sogd handle. | ||
87 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | ||
88 | Assert.That(retrievedPart, Is.Not.Null); | ||
89 | Assert.That(retrievedPart.ParentGroup.IsDeleted, Is.False); | ||
90 | |||
83 | sogd.InventoryDeQueueAndDelete(); | 91 | sogd.InventoryDeQueueAndDelete(); |
84 | 92 | ||
85 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | 93 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); |
86 | Assert.That(retrievedPart, Is.Null); | 94 | Assert.That(retrievedPart2, Is.Null); |
87 | } | 95 | } |
88 | 96 | ||
89 | /// <summary> | 97 | /// <summary> |
@@ -124,6 +132,67 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
124 | // Object should still be in the scene. | 132 | // Object should still be in the scene. |
125 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | 133 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); |
126 | Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID)); | 134 | Assert.That(retrievedPart.UUID, Is.EqualTo(part.UUID)); |
127 | } | 135 | } |
136 | |||
137 | /// <summary> | ||
138 | /// Test deleting an object asynchronously to user inventory. | ||
139 | /// </summary> | ||
140 | [Test] | ||
141 | public void TestDeleteSceneObjectAsyncToUserInventory() | ||
142 | { | ||
143 | TestHelpers.InMethod(); | ||
144 | // TestHelpers.EnableLogging(); | ||
145 | |||
146 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); | ||
147 | string myObjectName = "Fred"; | ||
148 | |||
149 | TestScene scene = new SceneHelpers().SetupScene(); | ||
150 | |||
151 | IConfigSource configSource = new IniConfigSource(); | ||
152 | IConfig config = configSource.AddConfig("Modules"); | ||
153 | config.Set("InventoryAccessModule", "BasicInventoryAccessModule"); | ||
154 | SceneHelpers.SetupSceneModules( | ||
155 | scene, configSource, new object[] { new BasicInventoryAccessModule() }); | ||
156 | |||
157 | SceneHelpers.SetupSceneModules(scene, new object[] { }); | ||
158 | |||
159 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | ||
160 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | ||
161 | sogd.Enabled = false; | ||
162 | |||
163 | SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, myObjectName, agentId); | ||
164 | |||
165 | UserAccount ua = UserAccountHelpers.CreateUserWithInventory(scene, agentId); | ||
166 | InventoryFolderBase folder1 | ||
167 | = UserInventoryHelpers.CreateInventoryFolder(scene.InventoryService, ua.PrincipalID, "folder1"); | ||
168 | |||
169 | IClientAPI client = SceneHelpers.AddScenePresence(scene, agentId).ControllingClient; | ||
170 | scene.DeRezObjects(client, new List<uint>() { so.LocalId }, UUID.Zero, DeRezAction.Take, folder1.ID); | ||
171 | |||
172 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(so.LocalId); | ||
173 | |||
174 | Assert.That(retrievedPart, Is.Not.Null); | ||
175 | Assert.That(so.IsDeleted, Is.False); | ||
176 | |||
177 | sogd.InventoryDeQueueAndDelete(); | ||
178 | |||
179 | Assert.That(so.IsDeleted, Is.True); | ||
180 | |||
181 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(so.LocalId); | ||
182 | Assert.That(retrievedPart2, Is.Null); | ||
183 | |||
184 | // SceneSetupHelpers.DeleteSceneObjectAsync(scene, part, DeRezAction.Take, userInfo.RootFolder.ID, client); | ||
185 | |||
186 | InventoryItemBase retrievedItem | ||
187 | = UserInventoryHelpers.GetInventoryItem( | ||
188 | scene.InventoryService, ua.PrincipalID, "folder1/" + myObjectName); | ||
189 | |||
190 | // Check that we now have the taken part in our inventory | ||
191 | Assert.That(retrievedItem, Is.Not.Null); | ||
192 | |||
193 | // Check that the taken part has actually disappeared | ||
194 | // SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | ||
195 | // Assert.That(retrievedPart, Is.Null); | ||
196 | } | ||
128 | } | 197 | } |
129 | } \ No newline at end of file | 198 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs index 0e525c9..9378e20 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs | |||
@@ -40,7 +40,7 @@ using log4net; | |||
40 | namespace OpenSim.Region.Framework.Scenes.Tests | 40 | namespace OpenSim.Region.Framework.Scenes.Tests |
41 | { | 41 | { |
42 | [TestFixture] | 42 | [TestFixture] |
43 | public class SceneObjectLinkingTests | 43 | public class SceneObjectLinkingTests : OpenSimTestCase |
44 | { | 44 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs index 89647d6..c264433 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectResizeTests.cs | |||
@@ -41,7 +41,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
41 | /// Basic scene object resize tests | 41 | /// Basic scene object resize tests |
42 | /// </summary> | 42 | /// </summary> |
43 | [TestFixture] | 43 | [TestFixture] |
44 | public class SceneObjectResizeTests | 44 | public class SceneObjectResizeTests : OpenSimTestCase |
45 | { | 45 | { |
46 | /// <summary> | 46 | /// <summary> |
47 | /// Test resizing an object | 47 | /// Test resizing an object |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs index d2361f8..a58e735 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectScriptTests.cs | |||
@@ -40,7 +40,7 @@ using OpenSim.Tests.Common.Mock; | |||
40 | namespace OpenSim.Region.Framework.Scenes.Tests | 40 | namespace OpenSim.Region.Framework.Scenes.Tests |
41 | { | 41 | { |
42 | [TestFixture] | 42 | [TestFixture] |
43 | public class SceneObjectScriptTests | 43 | public class SceneObjectScriptTests : OpenSimTestCase |
44 | { | 44 | { |
45 | [Test] | 45 | [Test] |
46 | public void TestAddScript() | 46 | public void TestAddScript() |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs index 6d255aa..abaa1d1 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectSpatialTests.cs | |||
@@ -42,14 +42,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
42 | /// Spatial scene object tests (will eventually cover root and child part position, rotation properties, etc.) | 42 | /// Spatial scene object tests (will eventually cover root and child part position, rotation properties, etc.) |
43 | /// </summary> | 43 | /// </summary> |
44 | [TestFixture] | 44 | [TestFixture] |
45 | public class SceneObjectSpatialTests | 45 | public class SceneObjectSpatialTests : OpenSimTestCase |
46 | { | 46 | { |
47 | TestScene m_scene; | 47 | TestScene m_scene; |
48 | UUID m_ownerId = TestHelpers.ParseTail(0x1); | 48 | UUID m_ownerId = TestHelpers.ParseTail(0x1); |
49 | 49 | ||
50 | [SetUp] | 50 | [SetUp] |
51 | public void SetUp() | 51 | public override void SetUp() |
52 | { | 52 | { |
53 | base.SetUp(); | ||
54 | |||
53 | m_scene = new SceneHelpers().SetupScene(); | 55 | m_scene = new SceneHelpers().SetupScene(); |
54 | } | 56 | } |
55 | 57 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs index 742c769..093cbd2 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectStatusTests.cs | |||
@@ -42,7 +42,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
42 | /// Basic scene object status tests | 42 | /// Basic scene object status tests |
43 | /// </summary> | 43 | /// </summary> |
44 | [TestFixture] | 44 | [TestFixture] |
45 | public class SceneObjectStatusTests | 45 | public class SceneObjectStatusTests : OpenSimTestCase |
46 | { | 46 | { |
47 | private TestScene m_scene; | 47 | private TestScene m_scene; |
48 | private UUID m_ownerId = TestHelpers.ParseTail(0x1); | 48 | private UUID m_ownerId = TestHelpers.ParseTail(0x1); |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs index 646e5fa..1cd8ae9 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAnimationTests.cs | |||
@@ -51,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
51 | /// Scene presence animation tests | 51 | /// Scene presence animation tests |
52 | /// </summary> | 52 | /// </summary> |
53 | [TestFixture] | 53 | [TestFixture] |
54 | public class ScenePresenceAnimationTests | 54 | public class ScenePresenceAnimationTests : OpenSimTestCase |
55 | { | 55 | { |
56 | [Test] | 56 | [Test] |
57 | public void TestFlyingAnimation() | 57 | public void TestFlyingAnimation() |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs index 1d1ff88..d80afd3 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceAutopilotTests.cs | |||
@@ -42,7 +42,7 @@ using OpenSim.Tests.Common.Mock; | |||
42 | namespace OpenSim.Region.Framework.Scenes.Tests | 42 | namespace OpenSim.Region.Framework.Scenes.Tests |
43 | { | 43 | { |
44 | [TestFixture] | 44 | [TestFixture] |
45 | public class ScenePresenceAutopilotTests | 45 | public class ScenePresenceAutopilotTests : OpenSimTestCase |
46 | { | 46 | { |
47 | private TestScene m_scene; | 47 | private TestScene m_scene; |
48 | 48 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs index 493ab70..acaeb90 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceSitTests.cs | |||
@@ -43,7 +43,7 @@ using System.Threading; | |||
43 | namespace OpenSim.Region.Framework.Scenes.Tests | 43 | namespace OpenSim.Region.Framework.Scenes.Tests |
44 | { | 44 | { |
45 | [TestFixture] | 45 | [TestFixture] |
46 | public class ScenePresenceSitTests | 46 | public class ScenePresenceSitTests : OpenSimTestCase |
47 | { | 47 | { |
48 | private TestScene m_scene; | 48 | private TestScene m_scene; |
49 | private ScenePresence m_sp; | 49 | private ScenePresence m_sp; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs index 37b5184..8dd1f3d 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTeleportTests.cs | |||
@@ -49,7 +49,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
49 | /// Teleport tests in a standalone OpenSim | 49 | /// Teleport tests in a standalone OpenSim |
50 | /// </summary> | 50 | /// </summary> |
51 | [TestFixture] | 51 | [TestFixture] |
52 | public class ScenePresenceTeleportTests | 52 | public class ScenePresenceTeleportTests : OpenSimTestCase |
53 | { | 53 | { |
54 | [TestFixtureSetUp] | 54 | [TestFixtureSetUp] |
55 | public void FixtureInit() | 55 | public void FixtureInit() |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs index d722a09..9d8eb0b 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | |||
@@ -50,7 +50,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
50 | /// Scene presence tests | 50 | /// Scene presence tests |
51 | /// </summary> | 51 | /// </summary> |
52 | [TestFixture] | 52 | [TestFixture] |
53 | public class SceneTests | 53 | public class SceneTests : OpenSimTestCase |
54 | { | 54 | { |
55 | /// <summary> | 55 | /// <summary> |
56 | /// Very basic scene update test. Should become more elaborate with time. | 56 | /// Very basic scene update test. Should become more elaborate with time. |
@@ -65,5 +65,22 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
65 | 65 | ||
66 | Assert.That(scene.Frame, Is.EqualTo(1)); | 66 | Assert.That(scene.Frame, Is.EqualTo(1)); |
67 | } | 67 | } |
68 | |||
69 | [Test] | ||
70 | public void TestShutdownScene() | ||
71 | { | ||
72 | TestHelpers.InMethod(); | ||
73 | |||
74 | Scene scene = new SceneHelpers().SetupScene(); | ||
75 | scene.Close(); | ||
76 | |||
77 | Assert.That(scene.ShuttingDown, Is.True); | ||
78 | Assert.That(scene.Active, Is.False); | ||
79 | |||
80 | // Trying to update a shutdown scene should result in no update | ||
81 | scene.Update(1); | ||
82 | |||
83 | Assert.That(scene.Frame, Is.EqualTo(0)); | ||
84 | } | ||
68 | } | 85 | } |
69 | } \ No newline at end of file | 86 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs index a51e4e3..0b461f5 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/TaskInventoryTests.cs | |||
@@ -50,7 +50,7 @@ using OpenSim.Tests.Common.Mock; | |||
50 | namespace OpenSim.Region.Framework.Tests | 50 | namespace OpenSim.Region.Framework.Tests |
51 | { | 51 | { |
52 | [TestFixture] | 52 | [TestFixture] |
53 | public class TaskInventoryTests | 53 | public class TaskInventoryTests : OpenSimTestCase |
54 | { | 54 | { |
55 | [Test] | 55 | [Test] |
56 | public void TestAddTaskInventoryItem() | 56 | public void TestAddTaskInventoryItem() |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index 198e487..dd27294 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | |||
@@ -38,7 +38,7 @@ using OpenSim.Tests.Common.Mock; | |||
38 | namespace OpenSim.Region.Framework.Scenes.Tests | 38 | namespace OpenSim.Region.Framework.Scenes.Tests |
39 | { | 39 | { |
40 | [TestFixture] | 40 | [TestFixture] |
41 | public class UuidGathererTests | 41 | public class UuidGathererTests : OpenSimTestCase |
42 | { | 42 | { |
43 | protected IAssetService m_assetService; | 43 | protected IAssetService m_assetService; |
44 | protected UuidGatherer m_uuidGatherer; | 44 | protected UuidGatherer m_uuidGatherer; |
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs index cfe1278..406b715 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs | |||
@@ -25,6 +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 | using System; | ||
28 | using System.Net; | 29 | using System.Net; |
29 | using System.Reflection; | 30 | using System.Reflection; |
30 | using log4net; | 31 | using log4net; |
@@ -33,49 +34,51 @@ using OpenSim.Region.Framework.Interfaces; | |||
33 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
34 | using OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server; | 35 | using OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server; |
35 | 36 | ||
37 | using Mono.Addins; | ||
38 | |||
36 | namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView | 39 | namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView |
37 | { | 40 | { |
38 | public class IRCStackModule : IRegionModule | 41 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "IRCStackModule")] |
42 | public class IRCStackModule : INonSharedRegionModule | ||
39 | { | 43 | { |
40 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
41 | 45 | ||
42 | private IRCServer m_server; | 46 | private IRCServer m_server; |
47 | private int m_Port; | ||
43 | // private Scene m_scene; | 48 | // private Scene m_scene; |
49 | private bool m_Enabled; | ||
44 | 50 | ||
45 | #region Implementation of IRegionModule | 51 | #region Implementation of INonSharedRegionModule |
46 | 52 | ||
47 | public void Initialise(Scene scene, IConfigSource source) | 53 | public void Initialise(IConfigSource source) |
48 | { | 54 | { |
49 | if (null != source.Configs["IRCd"] && | 55 | if (null != source.Configs["IRCd"] && |
50 | source.Configs["IRCd"].GetBoolean("Enabled",false)) | 56 | source.Configs["IRCd"].GetBoolean("Enabled", false)) |
51 | { | 57 | { |
52 | int portNo = source.Configs["IRCd"].GetInt("Port",6666); | 58 | m_Enabled = true; |
53 | // m_scene = scene; | 59 | m_Port = source.Configs["IRCd"].GetInt("Port", 6666); |
54 | m_server = new IRCServer(IPAddress.Parse("0.0.0.0"), portNo, scene); | ||
55 | m_server.OnNewIRCClient += m_server_OnNewIRCClient; | ||
56 | } | 60 | } |
57 | } | 61 | } |
58 | 62 | ||
59 | void m_server_OnNewIRCClient(IRCClientView user) | 63 | public void AddRegion(Scene scene) |
60 | { | 64 | { |
61 | user.OnIRCReady += user_OnIRCReady; | 65 | if (!m_Enabled) |
66 | return; | ||
67 | |||
68 | m_server = new IRCServer(IPAddress.Parse("0.0.0.0"), m_Port, scene); | ||
69 | m_server.OnNewIRCClient += m_server_OnNewIRCClient; | ||
62 | } | 70 | } |
63 | 71 | ||
64 | void user_OnIRCReady(IRCClientView cv) | 72 | public void RegionLoaded(Scene scene) |
65 | { | 73 | { |
66 | m_log.Info("[IRCd] Adding user..."); | ||
67 | cv.Start(); | ||
68 | m_log.Info("[IRCd] Added user to Scene"); | ||
69 | } | 74 | } |
70 | 75 | ||
71 | public void PostInitialise() | 76 | public void RemoveRegion(Scene scene) |
72 | { | 77 | { |
73 | |||
74 | } | 78 | } |
75 | 79 | ||
76 | public void Close() | 80 | public void Close() |
77 | { | 81 | { |
78 | |||
79 | } | 82 | } |
80 | 83 | ||
81 | public string Name | 84 | public string Name |
@@ -83,11 +86,24 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView | |||
83 | get { return "IRCClientStackModule"; } | 86 | get { return "IRCClientStackModule"; } |
84 | } | 87 | } |
85 | 88 | ||
86 | public bool IsSharedModule | 89 | public Type ReplaceableInterface |
87 | { | 90 | { |
88 | get { return false; } | 91 | get { return null; } |
89 | } | 92 | } |
90 | 93 | ||
91 | #endregion | 94 | #endregion |
95 | |||
96 | void m_server_OnNewIRCClient(IRCClientView user) | ||
97 | { | ||
98 | user.OnIRCReady += user_OnIRCReady; | ||
99 | } | ||
100 | |||
101 | void user_OnIRCReady(IRCClientView cv) | ||
102 | { | ||
103 | m_log.Info("[IRCd] Adding user..."); | ||
104 | cv.Start(); | ||
105 | m_log.Info("[IRCd] Added user to Scene"); | ||
106 | } | ||
107 | |||
92 | } | 108 | } |
93 | } | 109 | } |
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs index e93bd7c..781539a 100644 --- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs +++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs | |||
@@ -954,7 +954,8 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server | |||
954 | 954 | ||
955 | } | 955 | } |
956 | 956 | ||
957 | public void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, byte source, byte audible) | 957 | public void SendChatMessage( |
958 | string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, byte audible) | ||
958 | { | 959 | { |
959 | if (audible > 0 && message.Length > 0) | 960 | if (audible > 0 && message.Length > 0) |
960 | IRC_SendChannelPrivmsg(fromName, message); | 961 | IRC_SendChannelPrivmsg(fromName, message); |
diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs index 5fe5948..992f38e 100644 --- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs | |||
@@ -40,7 +40,7 @@ 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; |
42 | 42 | ||
43 | namespace OpenSim.Region.CoreModules.UDP.Linden | 43 | namespace OpenSim.Region.OptionalModules.UDP.Linden |
44 | { | 44 | { |
45 | /// <summary> | 45 | /// <summary> |
46 | /// A module that just holds commands for inspecting the current state of the Linden UDP stack. | 46 | /// A module that just holds commands for inspecting the current state of the Linden UDP stack. |
diff --git a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs index 41ec14f..7639c6c 100644 --- a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs +++ b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs | |||
@@ -127,6 +127,9 @@ namespace OpenSim.Region.OptionalModules.Asset | |||
127 | } | 127 | } |
128 | 128 | ||
129 | string fileName = rawAssetId; | 129 | string fileName = rawAssetId; |
130 | |||
131 | if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, fileName)) | ||
132 | return; | ||
130 | 133 | ||
131 | using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) | 134 | using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) |
132 | { | 135 | { |
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs index 913d934..2e1d03d 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs | |||
@@ -31,6 +31,7 @@ using System.Collections.Generic; | |||
31 | using System.Net; | 31 | using System.Net; |
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using log4net; | 33 | using log4net; |
34 | using Mono.Addins; | ||
34 | using Nini.Config; | 35 | using Nini.Config; |
35 | using Nwc.XmlRpc; | 36 | using Nwc.XmlRpc; |
36 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
@@ -40,6 +41,7 @@ using OpenSim.Region.Framework.Scenes; | |||
40 | 41 | ||
41 | namespace OpenSim.Region.OptionalModules.Avatar.Chat | 42 | namespace OpenSim.Region.OptionalModules.Avatar.Chat |
42 | { | 43 | { |
44 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "IRCBridgeModule")] | ||
43 | public class IRCBridgeModule : INonSharedRegionModule | 45 | public class IRCBridgeModule : INonSharedRegionModule |
44 | { | 46 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs index e22618d..018357a 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs | |||
@@ -36,6 +36,7 @@ using System.Text; | |||
36 | using System.Text.RegularExpressions; | 36 | using System.Text.RegularExpressions; |
37 | using System.Threading; | 37 | using System.Threading; |
38 | using log4net; | 38 | using log4net; |
39 | using Mono.Addins; | ||
39 | using Nini.Config; | 40 | using Nini.Config; |
40 | using Nwc.XmlRpc; | 41 | using Nwc.XmlRpc; |
41 | using OpenMetaverse; | 42 | using OpenMetaverse; |
@@ -47,6 +48,7 @@ using OpenSim.Region.CoreModules.Avatar.Chat; | |||
47 | 48 | ||
48 | namespace OpenSim.Region.OptionalModules.Avatar.Concierge | 49 | namespace OpenSim.Region.OptionalModules.Avatar.Concierge |
49 | { | 50 | { |
51 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ConciergeModule")] | ||
50 | public class ConciergeModule : ChatModule, ISharedRegionModule | 52 | public class ConciergeModule : ChatModule, ISharedRegionModule |
51 | { | 53 | { |
52 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -546,8 +548,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge | |||
546 | c.SenderUUID = UUID.Zero; | 548 | c.SenderUUID = UUID.Zero; |
547 | c.Scene = agent.Scene; | 549 | c.Scene = agent.Scene; |
548 | 550 | ||
549 | agent.ControllingClient.SendChatMessage(msg, (byte) ChatTypeEnum.Say, PosOfGod, m_whoami, UUID.Zero, | 551 | agent.ControllingClient.SendChatMessage( |
550 | (byte)ChatSourceType.Object, (byte)ChatAudibleLevel.Fully); | 552 | msg, (byte) ChatTypeEnum.Say, PosOfGod, m_whoami, UUID.Zero, UUID.Zero, |
553 | (byte)ChatSourceType.Object, (byte)ChatAudibleLevel.Fully); | ||
551 | } | 554 | } |
552 | 555 | ||
553 | private static void checkStringParameters(XmlRpcRequest request, string[] param) | 556 | private static void checkStringParameters(XmlRpcRequest request, string[] param) |
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs index c5fcef4..881807a 100644 --- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs | |||
@@ -36,6 +36,7 @@ using System.Reflection; | |||
36 | using System.Threading; | 36 | using System.Threading; |
37 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | using log4net; | 38 | using log4net; |
39 | using Mono.Addins; | ||
39 | using Nini.Config; | 40 | using Nini.Config; |
40 | using Nwc.XmlRpc; | 41 | using Nwc.XmlRpc; |
41 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
@@ -49,6 +50,7 @@ using Caps = OpenSim.Framework.Capabilities.Caps; | |||
49 | 50 | ||
50 | namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice | 51 | namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice |
51 | { | 52 | { |
53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "VivoxVoiceModule")] | ||
52 | public class VivoxVoiceModule : ISharedRegionModule | 54 | public class VivoxVoiceModule : ISharedRegionModule |
53 | { | 55 | { |
54 | 56 | ||
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs index 1528330..2802e2f 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs | |||
@@ -42,7 +42,7 @@ using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo; | |||
42 | 42 | ||
43 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | 43 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups |
44 | { | 44 | { |
45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 45 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GroupsMessagingModule")] |
46 | public class GroupsMessagingModule : ISharedRegionModule, IGroupsMessagingModule | 46 | public class GroupsMessagingModule : ISharedRegionModule, IGroupsMessagingModule |
47 | { | 47 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -79,7 +79,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
79 | 79 | ||
80 | private int m_usersOnlineCacheExpirySeconds = 20; | 80 | private int m_usersOnlineCacheExpirySeconds = 20; |
81 | 81 | ||
82 | #region IRegionModuleBase Members | 82 | #region Region Module interfaceBase Members |
83 | 83 | ||
84 | public void Initialise(IConfigSource config) | 84 | public void Initialise(IConfigSource config) |
85 | { | 85 | { |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs index b9b4413..193d1db 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs | |||
@@ -43,7 +43,7 @@ using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags; | |||
43 | 43 | ||
44 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | 44 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups |
45 | { | 45 | { |
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GroupsModule")] |
47 | public class GroupsModule : ISharedRegionModule, IGroupsModule | 47 | public class GroupsModule : ISharedRegionModule, IGroupsModule |
48 | { | 48 | { |
49 | /// <summary> | 49 | /// <summary> |
@@ -86,7 +86,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
86 | private bool m_debugEnabled = false; | 86 | private bool m_debugEnabled = false; |
87 | private int m_levelGroupCreate = 0; | 87 | private int m_levelGroupCreate = 0; |
88 | 88 | ||
89 | #region IRegionModuleBase Members | 89 | #region Region Module interfaceBase Members |
90 | 90 | ||
91 | public void Initialise(IConfigSource config) | 91 | public void Initialise(IConfigSource config) |
92 | { | 92 | { |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs index 6d26075..6b5b40a 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs | |||
@@ -36,7 +36,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
36 | { | 36 | { |
37 | UUID CreateGroup(UUID RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID); | 37 | UUID CreateGroup(UUID RequestingAgentID, string name, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish, UUID founderID); |
38 | void UpdateGroup(UUID RequestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish); | 38 | void UpdateGroup(UUID RequestingAgentID, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish); |
39 | |||
40 | /// <summary> | ||
41 | /// Get the group record. | ||
42 | /// </summary> | ||
43 | /// <returns></returns> | ||
44 | /// <param name='RequestingAgentID'>The UUID of the user making the request.</param> | ||
45 | /// <param name='GroupID'> | ||
46 | /// The ID of the record to retrieve. | ||
47 | /// GroupName may be specified instead, in which case this parameter will be UUID.Zero | ||
48 | /// </param> | ||
49 | /// <param name='GroupName'> | ||
50 | /// The name of the group to retrieve. | ||
51 | /// GroupID may be specified instead, in which case this parmeter will be null. | ||
52 | /// </param> | ||
39 | GroupRecord GetGroupRecord(UUID RequestingAgentID, UUID GroupID, string GroupName); | 53 | GroupRecord GetGroupRecord(UUID RequestingAgentID, UUID GroupID, string GroupName); |
54 | |||
40 | List<DirGroupsReplyData> FindGroups(UUID RequestingAgentID, string search); | 55 | List<DirGroupsReplyData> FindGroups(UUID RequestingAgentID, string search); |
41 | List<GroupMembersData> GetGroupMembers(UUID RequestingAgentID, UUID GroupID); | 56 | List<GroupMembersData> GetGroupMembers(UUID RequestingAgentID, UUID GroupID); |
42 | 57 | ||
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs index 5d57f70..7bae8f7 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs | |||
@@ -102,7 +102,7 @@ using OpenSim.Services.Interfaces; | |||
102 | 102 | ||
103 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | 103 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups |
104 | { | 104 | { |
105 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 105 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianGroupsServicesConnectorModule")] |
106 | public class SimianGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector | 106 | public class SimianGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector |
107 | { | 107 | { |
108 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 108 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -176,7 +176,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
176 | // private IUserAccountService m_accountService = null; | 176 | // private IUserAccountService m_accountService = null; |
177 | 177 | ||
178 | 178 | ||
179 | #region IRegionModuleBase Members | 179 | #region Region Module interfaceBase Members |
180 | 180 | ||
181 | public string Name | 181 | public string Name |
182 | { | 182 | { |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs index ac638f1..c1bdacb 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs | |||
@@ -42,7 +42,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests | |||
42 | /// Basic groups module tests | 42 | /// Basic groups module tests |
43 | /// </summary> | 43 | /// </summary> |
44 | [TestFixture] | 44 | [TestFixture] |
45 | public class GroupsModuleTests | 45 | public class GroupsModuleTests : OpenSimTestCase |
46 | { | 46 | { |
47 | [Test] | 47 | [Test] |
48 | public void TestBasic() | 48 | public void TestBasic() |
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs index d412cd1..1101851 100644 --- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs | |||
@@ -47,20 +47,69 @@ using OpenSim.Services.Interfaces; | |||
47 | 47 | ||
48 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | 48 | namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups |
49 | { | 49 | { |
50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XmlRpcGroupsServicesConnectorModule")] |
51 | public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector | 51 | public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector |
52 | { | 52 | { |
53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
54 | 54 | ||
55 | private bool m_debugEnabled = false; | 55 | private bool m_debugEnabled = false; |
56 | 56 | ||
57 | public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome | | 57 | public const GroupPowers DefaultEveryonePowers |
58 | GroupPowers.Accountable | | 58 | = GroupPowers.AllowSetHome |
59 | GroupPowers.JoinChat | | 59 | | GroupPowers.Accountable |
60 | GroupPowers.AllowVoiceChat | | 60 | | GroupPowers.JoinChat |
61 | GroupPowers.ReceiveNotices | | 61 | | GroupPowers.AllowVoiceChat |
62 | GroupPowers.StartProposal | | 62 | | GroupPowers.ReceiveNotices |
63 | GroupPowers.VoteOnProposal; | 63 | | GroupPowers.StartProposal |
64 | | GroupPowers.VoteOnProposal; | ||
65 | |||
66 | // Would this be cleaner as (GroupPowers)ulong.MaxValue? | ||
67 | public const GroupPowers DefaultOwnerPowers | ||
68 | = GroupPowers.Accountable | ||
69 | | GroupPowers.AllowEditLand | ||
70 | | GroupPowers.AllowFly | ||
71 | | GroupPowers.AllowLandmark | ||
72 | | GroupPowers.AllowRez | ||
73 | | GroupPowers.AllowSetHome | ||
74 | | GroupPowers.AllowVoiceChat | ||
75 | | GroupPowers.AssignMember | ||
76 | | GroupPowers.AssignMemberLimited | ||
77 | | GroupPowers.ChangeActions | ||
78 | | GroupPowers.ChangeIdentity | ||
79 | | GroupPowers.ChangeMedia | ||
80 | | GroupPowers.ChangeOptions | ||
81 | | GroupPowers.CreateRole | ||
82 | | GroupPowers.DeedObject | ||
83 | | GroupPowers.DeleteRole | ||
84 | | GroupPowers.Eject | ||
85 | | GroupPowers.FindPlaces | ||
86 | | GroupPowers.Invite | ||
87 | | GroupPowers.JoinChat | ||
88 | | GroupPowers.LandChangeIdentity | ||
89 | | GroupPowers.LandDeed | ||
90 | | GroupPowers.LandDivideJoin | ||
91 | | GroupPowers.LandEdit | ||
92 | | GroupPowers.LandEjectAndFreeze | ||
93 | | GroupPowers.LandGardening | ||
94 | | GroupPowers.LandManageAllowed | ||
95 | | GroupPowers.LandManageBanned | ||
96 | | GroupPowers.LandManagePasses | ||
97 | | GroupPowers.LandOptions | ||
98 | | GroupPowers.LandRelease | ||
99 | | GroupPowers.LandSetSale | ||
100 | | GroupPowers.ModerateChat | ||
101 | | GroupPowers.ObjectManipulate | ||
102 | | GroupPowers.ObjectSetForSale | ||
103 | | GroupPowers.ReceiveNotices | ||
104 | | GroupPowers.RemoveMember | ||
105 | | GroupPowers.ReturnGroupOwned | ||
106 | | GroupPowers.ReturnGroupSet | ||
107 | | GroupPowers.ReturnNonGroup | ||
108 | | GroupPowers.RoleProperties | ||
109 | | GroupPowers.SendNotices | ||
110 | | GroupPowers.SetLandingPoint | ||
111 | | GroupPowers.StartProposal | ||
112 | | GroupPowers.VoteOnProposal; | ||
64 | 113 | ||
65 | private bool m_connectorEnabled = false; | 114 | private bool m_connectorEnabled = false; |
66 | 115 | ||
@@ -83,7 +132,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
83 | private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>(); | 132 | private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>(); |
84 | private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>(); | 133 | private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>(); |
85 | 134 | ||
86 | #region IRegionModuleBase Members | 135 | #region Region Module interfaceBase Members |
87 | 136 | ||
88 | public string Name | 137 | public string Name |
89 | { | 138 | { |
@@ -219,59 +268,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
219 | param["AllowPublish"] = allowPublish == true ? 1 : 0; | 268 | param["AllowPublish"] = allowPublish == true ? 1 : 0; |
220 | param["MaturePublish"] = maturePublish == true ? 1 : 0; | 269 | param["MaturePublish"] = maturePublish == true ? 1 : 0; |
221 | param["FounderID"] = founderID.ToString(); | 270 | param["FounderID"] = founderID.ToString(); |
222 | param["EveryonePowers"] = ((ulong)m_DefaultEveryonePowers).ToString(); | 271 | param["EveryonePowers"] = ((ulong)DefaultEveryonePowers).ToString(); |
223 | param["OwnerRoleID"] = OwnerRoleID.ToString(); | 272 | param["OwnerRoleID"] = OwnerRoleID.ToString(); |
224 | 273 | param["OwnersPowers"] = ((ulong)DefaultOwnerPowers).ToString(); | |
225 | // Would this be cleaner as (GroupPowers)ulong.MaxValue; | ||
226 | GroupPowers OwnerPowers = GroupPowers.Accountable | ||
227 | | GroupPowers.AllowEditLand | ||
228 | | GroupPowers.AllowFly | ||
229 | | GroupPowers.AllowLandmark | ||
230 | | GroupPowers.AllowRez | ||
231 | | GroupPowers.AllowSetHome | ||
232 | | GroupPowers.AllowVoiceChat | ||
233 | | GroupPowers.AssignMember | ||
234 | | GroupPowers.AssignMemberLimited | ||
235 | | GroupPowers.ChangeActions | ||
236 | | GroupPowers.ChangeIdentity | ||
237 | | GroupPowers.ChangeMedia | ||
238 | | GroupPowers.ChangeOptions | ||
239 | | GroupPowers.CreateRole | ||
240 | | GroupPowers.DeedObject | ||
241 | | GroupPowers.DeleteRole | ||
242 | | GroupPowers.Eject | ||
243 | | GroupPowers.FindPlaces | ||
244 | | GroupPowers.Invite | ||
245 | | GroupPowers.JoinChat | ||
246 | | GroupPowers.LandChangeIdentity | ||
247 | | GroupPowers.LandDeed | ||
248 | | GroupPowers.LandDivideJoin | ||
249 | | GroupPowers.LandEdit | ||
250 | | GroupPowers.LandEjectAndFreeze | ||
251 | | GroupPowers.LandGardening | ||
252 | | GroupPowers.LandManageAllowed | ||
253 | | GroupPowers.LandManageBanned | ||
254 | | GroupPowers.LandManagePasses | ||
255 | | GroupPowers.LandOptions | ||
256 | | GroupPowers.LandRelease | ||
257 | | GroupPowers.LandSetSale | ||
258 | | GroupPowers.ModerateChat | ||
259 | | GroupPowers.ObjectManipulate | ||
260 | | GroupPowers.ObjectSetForSale | ||
261 | | GroupPowers.ReceiveNotices | ||
262 | | GroupPowers.RemoveMember | ||
263 | | GroupPowers.ReturnGroupOwned | ||
264 | | GroupPowers.ReturnGroupSet | ||
265 | | GroupPowers.ReturnNonGroup | ||
266 | | GroupPowers.RoleProperties | ||
267 | | GroupPowers.SendNotices | ||
268 | | GroupPowers.SetLandingPoint | ||
269 | | GroupPowers.StartProposal | ||
270 | | GroupPowers.VoteOnProposal; | ||
271 | param["OwnersPowers"] = ((ulong)OwnerPowers).ToString(); | ||
272 | |||
273 | |||
274 | |||
275 | 274 | ||
276 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.createGroup", param); | 275 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.createGroup", param); |
277 | 276 | ||
@@ -612,8 +611,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
612 | } | 611 | } |
613 | 612 | ||
614 | return Roles; | 613 | return Roles; |
615 | |||
616 | |||
617 | } | 614 | } |
618 | 615 | ||
619 | public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID) | 616 | public List<GroupRolesData> GetGroupRoles(UUID requestingAgentID, UUID GroupID) |
@@ -676,7 +673,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
676 | } | 673 | } |
677 | 674 | ||
678 | return members; | 675 | return members; |
679 | |||
680 | } | 676 | } |
681 | 677 | ||
682 | public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID) | 678 | public List<GroupRoleMembersData> GetGroupRoleMembers(UUID requestingAgentID, UUID GroupID) |
@@ -727,9 +723,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
727 | values.Add(data); | 723 | values.Add(data); |
728 | } | 724 | } |
729 | } | 725 | } |
730 | return values; | ||
731 | 726 | ||
727 | return values; | ||
732 | } | 728 | } |
729 | |||
733 | public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) | 730 | public GroupNoticeInfo GetGroupNotice(UUID requestingAgentID, UUID noticeID) |
734 | { | 731 | { |
735 | Hashtable param = new Hashtable(); | 732 | Hashtable param = new Hashtable(); |
@@ -737,7 +734,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
737 | 734 | ||
738 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotice", param); | 735 | Hashtable respData = XmlRpcCall(requestingAgentID, "groups.getGroupNotice", param); |
739 | 736 | ||
740 | |||
741 | if (respData.Contains("error")) | 737 | if (respData.Contains("error")) |
742 | { | 738 | { |
743 | return null; | 739 | return null; |
@@ -761,6 +757,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
761 | 757 | ||
762 | return data; | 758 | return data; |
763 | } | 759 | } |
760 | |||
764 | public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) | 761 | public void AddGroupNotice(UUID requestingAgentID, UUID groupID, UUID noticeID, string fromName, string subject, string message, byte[] binaryBucket) |
765 | { | 762 | { |
766 | string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, ""); | 763 | string binBucket = OpenMetaverse.Utils.BytesToHexString(binaryBucket, ""); |
@@ -777,8 +774,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups | |||
777 | XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param); | 774 | XmlRpcCall(requestingAgentID, "groups.addGroupNotice", param); |
778 | } | 775 | } |
779 | 776 | ||
780 | |||
781 | |||
782 | #endregion | 777 | #endregion |
783 | 778 | ||
784 | #region GroupSessionTracking | 779 | #region GroupSessionTracking |
diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs index dddea3e..781fe95 100644 --- a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs +++ b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs | |||
@@ -33,9 +33,6 @@ using Nini.Config; | |||
33 | using OpenSim.Region.Framework.Interfaces; | 33 | using OpenSim.Region.Framework.Interfaces; |
34 | using OpenSim.Region.Framework.Scenes; | 34 | using OpenSim.Region.Framework.Scenes; |
35 | 35 | ||
36 | [assembly: Addin("BareBonesSharedModule", "0.1")] | ||
37 | [assembly: AddinDependency("OpenSim", "0.5")] | ||
38 | |||
39 | namespace OpenSim.Region.OptionalModules.Example.BareBonesShared | 36 | namespace OpenSim.Region.OptionalModules.Example.BareBonesShared |
40 | { | 37 | { |
41 | /// <summary> | 38 | /// <summary> |
diff --git a/OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs b/OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..217b2d5 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,37 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | using Mono.Addins; | ||
5 | |||
6 | // General Information about an assembly is controlled through the following | ||
7 | // set of attributes. Change these attribute values to modify the information | ||
8 | // associated with an assembly. | ||
9 | [assembly: AssemblyTitle("OpenSim.Region.OptionalModules")] | ||
10 | [assembly: AssemblyDescription("Optional modules for OpenSim")] | ||
11 | [assembly: AssemblyConfiguration("")] | ||
12 | [assembly: AssemblyCompany("")] | ||
13 | [assembly: AssemblyProduct("OpenSim.Region.OptionalModules.Properties")] | ||
14 | [assembly: AssemblyCopyright("Copyright © 2012")] | ||
15 | [assembly: AssemblyTrademark("")] | ||
16 | [assembly: AssemblyCulture("")] | ||
17 | |||
18 | // Setting ComVisible to false makes the types in this assembly not visible | ||
19 | // to COM components. If you need to access a type in this assembly from | ||
20 | // COM, set the ComVisible attribute to true on that type. | ||
21 | [assembly: ComVisible(false)] | ||
22 | |||
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
24 | [assembly: Guid("84a3082d-3011-4c13-835c-c7d93f97ac79")] | ||
25 | |||
26 | // Version information for an assembly consists of the following four values: | ||
27 | // | ||
28 | // Major Version | ||
29 | // Minor Version | ||
30 | // Build Number | ||
31 | // Revision | ||
32 | // | ||
33 | [assembly: AssemblyVersion("0.7.5.*")] | ||
34 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
35 | |||
36 | [assembly: Addin("OpenSim.Region.OptionalModules", "0.1")] | ||
37 | [assembly: AddinDependency("OpenSim", "0.5")] | ||
diff --git a/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml b/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml deleted file mode 100644 index 8691343..0000000 --- a/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml +++ /dev/null | |||
@@ -1,18 +0,0 @@ | |||
1 | <Addin id="OpenSim.Region.OptionalModules" version="0.2"> | ||
2 | <Runtime> | ||
3 | <Import assembly="OpenSim.Region.OptionalModules.dll"/> | ||
4 | </Runtime> | ||
5 | |||
6 | <Dependencies> | ||
7 | <Addin id="OpenSim" version="0.5" /> | ||
8 | </Dependencies> | ||
9 | |||
10 | <Extension path = "/OpenSim/RegionModules"> | ||
11 | <RegionModule id="RegionReady" type="OpenSim.Region.OptionalModules.Scripting.RegionReady.RegionReadyModule" /> | ||
12 | <RegionModule id="IRCBridge" type="OpenSim.Region.OptionalModules.Avatar.Chat.IRCBridgeModule" /> | ||
13 | <RegionModule id="Concierge" type="OpenSim.Region.OptionalModules.Avatar.Concierge.ConciergeModule" /> | ||
14 | <RegionModule id="VivoxVoice" type="OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice.VivoxVoiceModule" /> | ||
15 | <RegionModule id="WorldViewModule" type="OpenSim.Region.OptionalModules.World.WorldView.WorldViewModule" /> | ||
16 | <RegionModule id="AutoBackupModule" type="OpenSim.Region.OptionalModules.World.AutoBackup.AutoBackupModule" /> | ||
17 | </Extension> | ||
18 | </Addin> | ||
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs index 732c28f..e68764a 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs | |||
@@ -59,7 +59,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
59 | private Dictionary<UUID,JsonStore> m_JsonValueStore; | 59 | private Dictionary<UUID,JsonStore> m_JsonValueStore; |
60 | private UUID m_sharedStore; | 60 | private UUID m_sharedStore; |
61 | 61 | ||
62 | #region IRegionModule Members | 62 | #region Region Module interface |
63 | 63 | ||
64 | // ----------------------------------------------------------------- | 64 | // ----------------------------------------------------------------- |
65 | /// <summary> | 65 | /// <summary> |
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs index 6910d14..0c175ca 100644 --- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore | |||
58 | private IScriptModuleComms m_comms; | 58 | private IScriptModuleComms m_comms; |
59 | private IJsonStoreModule m_store; | 59 | private IJsonStoreModule m_store; |
60 | 60 | ||
61 | #region IRegionModule Members | 61 | #region Region Module interface |
62 | 62 | ||
63 | // ----------------------------------------------------------------- | 63 | // ----------------------------------------------------------------- |
64 | /// <summary> | 64 | /// <summary> |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs index 03481d2..6fb28e2 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs | |||
@@ -43,13 +43,17 @@ using OpenMetaverse; | |||
43 | using OpenSim.Framework; | 43 | using OpenSim.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; |
46 | using Mono.Addins; | ||
46 | 47 | ||
47 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | 48 | namespace OpenSim.Region.OptionalModules.Scripting.Minimodule |
48 | { | 49 | { |
49 | public class MRMModule : IRegionModule, IMRMModule | 50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MRMModule")] |
51 | public class MRMModule : INonSharedRegionModule, IMRMModule | ||
50 | { | 52 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | private Scene m_scene; | 54 | private Scene m_scene; |
55 | private bool m_Enabled; | ||
56 | private bool m_Hidden; | ||
53 | 57 | ||
54 | private readonly Dictionary<UUID,MRMBase> m_scripts = new Dictionary<UUID, MRMBase>(); | 58 | private readonly Dictionary<UUID,MRMBase> m_scripts = new Dictionary<UUID, MRMBase>(); |
55 | 59 | ||
@@ -67,7 +71,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
67 | m_extensions[typeof (T)] = instance; | 71 | m_extensions[typeof (T)] = instance; |
68 | } | 72 | } |
69 | 73 | ||
70 | public void Initialise(Scene scene, IConfigSource source) | 74 | #region INonSharedRegionModule |
75 | |||
76 | public void Initialise(IConfigSource source) | ||
71 | { | 77 | { |
72 | if (source.Configs["MRM"] != null) | 78 | if (source.Configs["MRM"] != null) |
73 | { | 79 | { |
@@ -76,23 +82,60 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
76 | if (source.Configs["MRM"].GetBoolean("Enabled", false)) | 82 | if (source.Configs["MRM"].GetBoolean("Enabled", false)) |
77 | { | 83 | { |
78 | m_log.Info("[MRM]: Enabling MRM Module"); | 84 | m_log.Info("[MRM]: Enabling MRM Module"); |
79 | m_scene = scene; | 85 | m_Enabled = true; |
86 | m_Hidden = source.Configs["MRM"].GetBoolean("Hidden", false); | ||
87 | } | ||
88 | } | ||
89 | } | ||
80 | 90 | ||
81 | // when hidden, we don't listen for client initiated script events | 91 | public void AddRegion(Scene scene) |
82 | // only making the MRM engine available for region modules | 92 | { |
83 | if (!source.Configs["MRM"].GetBoolean("Hidden", false)) | 93 | if (!m_Enabled) |
84 | { | 94 | return; |
85 | scene.EventManager.OnRezScript += EventManager_OnRezScript; | ||
86 | scene.EventManager.OnStopScript += EventManager_OnStopScript; | ||
87 | } | ||
88 | 95 | ||
89 | scene.EventManager.OnFrame += EventManager_OnFrame; | 96 | m_scene = scene; |
90 | 97 | ||
91 | scene.RegisterModuleInterface<IMRMModule>(this); | 98 | // when hidden, we don't listen for client initiated script events |
92 | } | 99 | // only making the MRM engine available for region modules |
100 | if (!m_Hidden) | ||
101 | { | ||
102 | scene.EventManager.OnRezScript += EventManager_OnRezScript; | ||
103 | scene.EventManager.OnStopScript += EventManager_OnStopScript; | ||
93 | } | 104 | } |
105 | |||
106 | scene.EventManager.OnFrame += EventManager_OnFrame; | ||
107 | |||
108 | scene.RegisterModuleInterface<IMRMModule>(this); | ||
109 | } | ||
110 | |||
111 | public void RegionLoaded(Scene scene) | ||
112 | { | ||
94 | } | 113 | } |
95 | 114 | ||
115 | public void RemoveRegion(Scene scene) | ||
116 | { | ||
117 | } | ||
118 | |||
119 | public void Close() | ||
120 | { | ||
121 | foreach (KeyValuePair<UUID, MRMBase> pair in m_scripts) | ||
122 | { | ||
123 | pair.Value.Stop(); | ||
124 | } | ||
125 | } | ||
126 | |||
127 | public string Name | ||
128 | { | ||
129 | get { return "MiniRegionModule"; } | ||
130 | } | ||
131 | |||
132 | public Type ReplaceableInterface | ||
133 | { | ||
134 | get { return null; } | ||
135 | } | ||
136 | |||
137 | #endregion | ||
138 | |||
96 | void EventManager_OnStopScript(uint localID, UUID itemID) | 139 | void EventManager_OnStopScript(uint localID, UUID itemID) |
97 | { | 140 | { |
98 | if (m_scripts.ContainsKey(itemID)) | 141 | if (m_scripts.ContainsKey(itemID)) |
@@ -293,28 +336,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
293 | mmb.InitMiniModule(world, host, itemID); | 336 | mmb.InitMiniModule(world, host, itemID); |
294 | } | 337 | } |
295 | 338 | ||
296 | public void PostInitialise() | ||
297 | { | ||
298 | } | ||
299 | |||
300 | public void Close() | ||
301 | { | ||
302 | foreach (KeyValuePair<UUID, MRMBase> pair in m_scripts) | ||
303 | { | ||
304 | pair.Value.Stop(); | ||
305 | } | ||
306 | } | ||
307 | |||
308 | public string Name | ||
309 | { | ||
310 | get { return "MiniRegionModule"; } | ||
311 | } | ||
312 | |||
313 | public bool IsSharedModule | ||
314 | { | ||
315 | get { return false; } | ||
316 | } | ||
317 | |||
318 | /// <summary> | 339 | /// <summary> |
319 | /// Stolen from ScriptEngine Common | 340 | /// Stolen from ScriptEngine Common |
320 | /// </summary> | 341 | /// </summary> |
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs index aa23fee..5ed1514 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs | |||
@@ -821,8 +821,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule | |||
821 | { | 821 | { |
822 | if (!CanEdit()) | 822 | if (!CanEdit()) |
823 | return; | 823 | return; |
824 | 824 | ISoundModule module = m_rootScene.RequestModuleInterface<ISoundModule>(); | |
825 | GetSOP().SendSound(asset.ToString(), volume, true, 0, 0, false, false); | 825 | if (module != null) |
826 | { | ||
827 | module.SendSound(GetSOP().UUID, asset, volume, true, 0, 0, false, false); | ||
828 | } | ||
826 | } | 829 | } |
827 | 830 | ||
828 | #endregion | 831 | #endregion |
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs index bad75f7..c550c44 100644 --- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs | |||
@@ -32,6 +32,7 @@ using System.Net; | |||
32 | using System.IO; | 32 | using System.IO; |
33 | using System.Text; | 33 | using System.Text; |
34 | using log4net; | 34 | using log4net; |
35 | using Mono.Addins; | ||
35 | using Nini.Config; | 36 | using Nini.Config; |
36 | using OpenMetaverse; | 37 | using OpenMetaverse; |
37 | using OpenMetaverse.StructuredData; | 38 | using OpenMetaverse.StructuredData; |
@@ -42,6 +43,7 @@ using OpenSim.Services.Interfaces; | |||
42 | 43 | ||
43 | namespace OpenSim.Region.OptionalModules.Scripting.RegionReady | 44 | namespace OpenSim.Region.OptionalModules.Scripting.RegionReady |
44 | { | 45 | { |
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RegionReadyModule")] | ||
45 | public class RegionReadyModule : IRegionReadyModule, INonSharedRegionModule | 47 | public class RegionReadyModule : IRegionReadyModule, INonSharedRegionModule |
46 | { | 48 | { |
47 | private static readonly ILog m_log = | 49 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs index 2187449..6120a81 100644 --- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs | |||
@@ -32,6 +32,7 @@ using System.Reflection; | |||
32 | using log4net; | 32 | using log4net; |
33 | using Nini.Config; | 33 | using Nini.Config; |
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using Mono.Addins; | ||
35 | 36 | ||
36 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
@@ -49,7 +50,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
49 | public string uri; | 50 | public string uri; |
50 | } | 51 | } |
51 | 52 | ||
52 | public class XmlRpcGridRouter : IRegionModule, IXmlRpcRouter | 53 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XmlRpcGridRouter")] |
54 | public class XmlRpcGridRouter : INonSharedRegionModule, IXmlRpcRouter | ||
53 | { | 55 | { |
54 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 56 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
55 | 57 | ||
@@ -59,9 +61,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
59 | private bool m_Enabled = false; | 61 | private bool m_Enabled = false; |
60 | private string m_ServerURI = String.Empty; | 62 | private string m_ServerURI = String.Empty; |
61 | 63 | ||
62 | public void Initialise(Scene scene, IConfigSource config) | 64 | #region INonSharedRegionModule |
65 | |||
66 | public void Initialise(IConfigSource config) | ||
63 | { | 67 | { |
64 | IConfig startupConfig = config.Configs["Startup"]; | 68 | IConfig startupConfig = config.Configs["XMLRPC"]; |
65 | if (startupConfig == null) | 69 | if (startupConfig == null) |
66 | return; | 70 | return; |
67 | 71 | ||
@@ -74,16 +78,30 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
74 | m_log.Error("[XMLRPC GRID ROUTER] Module configured but no URI given. Disabling"); | 78 | m_log.Error("[XMLRPC GRID ROUTER] Module configured but no URI given. Disabling"); |
75 | return; | 79 | return; |
76 | } | 80 | } |
77 | |||
78 | scene.RegisterModuleInterface<IXmlRpcRouter>(this); | ||
79 | m_Enabled = true; | 81 | m_Enabled = true; |
80 | } | 82 | } |
81 | } | 83 | } |
82 | 84 | ||
83 | public void PostInitialise() | 85 | public void AddRegion(Scene scene) |
86 | { | ||
87 | if (!m_Enabled) | ||
88 | return; | ||
89 | |||
90 | scene.RegisterModuleInterface<IXmlRpcRouter>(this); | ||
91 | } | ||
92 | |||
93 | public void RegionLoaded(Scene scene) | ||
84 | { | 94 | { |
85 | } | 95 | } |
86 | 96 | ||
97 | public void RemoveRegion(Scene scene) | ||
98 | { | ||
99 | if (!m_Enabled) | ||
100 | return; | ||
101 | |||
102 | scene.UnregisterModuleInterface<IXmlRpcRouter>(this); | ||
103 | } | ||
104 | |||
87 | public void Close() | 105 | public void Close() |
88 | { | 106 | { |
89 | } | 107 | } |
@@ -93,11 +111,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule | |||
93 | get { return "XmlRpcGridRouterModule"; } | 111 | get { return "XmlRpcGridRouterModule"; } |
94 | } | 112 | } |
95 | 113 | ||
96 | public bool IsSharedModule | 114 | public Type ReplaceableInterface |
97 | { | 115 | { |
98 | get { return false; } | 116 | get { return null; } |
99 | } | 117 | } |
100 | 118 | ||
119 | #endregion | ||
120 | |||
101 | public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) | 121 | public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) |
102 | { | 122 | { |
103 | if (!m_Channels.ContainsKey(itemID)) | 123 | if (!m_Channels.ContainsKey(itemID)) |
diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs index 32659c8..4783f4c 100644 --- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs +++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs | |||
@@ -31,6 +31,7 @@ using System.Reflection; | |||
31 | using log4net; | 31 | using log4net; |
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using Mono.Addins; | ||
34 | 35 | ||
35 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
@@ -39,27 +40,46 @@ using OpenSim.Region.Framework.Scenes; | |||
39 | 40 | ||
40 | namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule | 41 | namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule |
41 | { | 42 | { |
42 | public class XmlRpcRouter : IRegionModule, IXmlRpcRouter | 43 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XmlRpcRouter")] |
44 | public class XmlRpcRouter : INonSharedRegionModule, IXmlRpcRouter | ||
43 | { | 45 | { |
44 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
45 | 47 | ||
46 | public void Initialise(Scene scene, IConfigSource config) | 48 | private bool m_Enabled; |
49 | |||
50 | #region INonSharedRegionModule | ||
51 | |||
52 | public void Initialise(IConfigSource config) | ||
47 | { | 53 | { |
48 | IConfig startupConfig = config.Configs["Startup"]; | 54 | IConfig startupConfig = config.Configs["XMLRPC"]; |
49 | if (startupConfig == null) | 55 | if (startupConfig == null) |
50 | return; | 56 | return; |
51 | 57 | ||
52 | if (startupConfig.GetString("XmlRpcRouterModule", | 58 | if (startupConfig.GetString("XmlRpcRouterModule", |
53 | "XmlRpcRouterModule") == "XmlRpcRouterModule") | 59 | "XmlRpcRouterModule") == "XmlRpcRouterModule") |
54 | { | 60 | m_Enabled = true; |
55 | scene.RegisterModuleInterface<IXmlRpcRouter>(this); | 61 | } |
56 | } | 62 | |
63 | public void AddRegion(Scene scene) | ||
64 | { | ||
65 | if (!m_Enabled) | ||
66 | return; | ||
67 | |||
68 | scene.RegisterModuleInterface<IXmlRpcRouter>(this); | ||
57 | } | 69 | } |
58 | 70 | ||
59 | public void PostInitialise() | 71 | public void RegionLoaded(Scene scene) |
60 | { | 72 | { |
61 | } | 73 | } |
62 | 74 | ||
75 | public void RemoveRegion(Scene scene) | ||
76 | { | ||
77 | if (!m_Enabled) | ||
78 | return; | ||
79 | |||
80 | scene.UnregisterModuleInterface<IXmlRpcRouter>(this); | ||
81 | } | ||
82 | |||
63 | public void Close() | 83 | public void Close() |
64 | { | 84 | { |
65 | } | 85 | } |
@@ -69,11 +89,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule | |||
69 | get { return "XmlRpcRouterModule"; } | 89 | get { return "XmlRpcRouterModule"; } |
70 | } | 90 | } |
71 | 91 | ||
72 | public bool IsSharedModule | 92 | public Type ReplaceableInterface |
73 | { | 93 | { |
74 | get { return false; } | 94 | get { return null; } |
75 | } | 95 | } |
76 | 96 | ||
97 | #endregion | ||
98 | |||
77 | public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) | 99 | public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) |
78 | { | 100 | { |
79 | scriptEngine.PostScriptEvent(itemID, "xmlrpc_uri", new Object[] {uri}); | 101 | scriptEngine.PostScriptEvent(itemID, "xmlrpc_uri", new Object[] {uri}); |
diff --git a/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs b/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs index 74c5139..78c870a 100644 --- a/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs +++ b/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs | |||
@@ -48,7 +48,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Freeswitch | |||
48 | private IConfigSource m_Config; | 48 | private IConfigSource m_Config; |
49 | bool m_Registered = false; | 49 | bool m_Registered = false; |
50 | 50 | ||
51 | #region IRegionModule interface | 51 | #region Region Module interface |
52 | 52 | ||
53 | public void Initialise(IConfigSource config) | 53 | public void Initialise(IConfigSource config) |
54 | { | 54 | { |
diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs index ec9f157..1d35c54 100644 --- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs +++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs | |||
@@ -33,6 +33,7 @@ using System.Reflection; | |||
33 | using System.Timers; | 33 | using System.Timers; |
34 | using System.Text.RegularExpressions; | 34 | using System.Text.RegularExpressions; |
35 | using log4net; | 35 | using log4net; |
36 | using Mono.Addins; | ||
36 | using Nini.Config; | 37 | using Nini.Config; |
37 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
38 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
@@ -95,6 +96,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup | |||
95 | /// Save memory by setting low initial capacities. Minimizes impact in common cases of all regions using same interval, and instances hosting 1 ~ 4 regions. | 96 | /// Save memory by setting low initial capacities. Minimizes impact in common cases of all regions using same interval, and instances hosting 1 ~ 4 regions. |
96 | /// Also helps if you don't want AutoBackup at all. | 97 | /// Also helps if you don't want AutoBackup at all. |
97 | /// </remarks> | 98 | /// </remarks> |
99 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AutoBackupModule")] | ||
98 | public class AutoBackupModule : ISharedRegionModule | 100 | public class AutoBackupModule : ISharedRegionModule |
99 | { | 101 | { |
100 | private static readonly ILog m_log = | 102 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs index 9c838d0..8f04ede 100644 --- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs +++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs | |||
@@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule | |||
55 | /// | 55 | /// |
56 | /// </summary> | 56 | /// </summary> |
57 | 57 | ||
58 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | 58 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SampleMoneyModule")] |
59 | public class SampleMoneyModule : IMoneyModule, ISharedRegionModule | 59 | public class SampleMoneyModule : IMoneyModule, ISharedRegionModule |
60 | { | 60 | { |
61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 61 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index ffd4222..5ea2bcd 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | |||
@@ -603,13 +603,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
603 | { | 603 | { |
604 | } | 604 | } |
605 | 605 | ||
606 | public virtual void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, | 606 | public virtual void SendChatMessage( |
607 | UUID fromAgentID, byte source, byte audible) | 607 | string message, byte type, Vector3 fromPos, string fromName, |
608 | UUID fromAgentID, UUID ownerID, byte source, byte audible) | ||
608 | { | 609 | { |
609 | } | 610 | } |
610 | 611 | ||
611 | public virtual void SendChatMessage(byte[] message, byte type, Vector3 fromPos, string fromName, | 612 | public virtual void SendChatMessage( |
612 | UUID fromAgentID, byte source, byte audible) | 613 | byte[] message, byte type, Vector3 fromPos, string fromName, |
614 | UUID fromAgentID, UUID ownerID, byte source, byte audible) | ||
613 | { | 615 | { |
614 | } | 616 | } |
615 | 617 | ||
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 3f25bcf..7d46d92 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -29,37 +29,57 @@ using System; | |||
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Reflection; | 30 | using System.Reflection; |
31 | using System.Threading; | 31 | using System.Threading; |
32 | using Timer = System.Timers.Timer; | ||
33 | |||
32 | using log4net; | 34 | using log4net; |
33 | using Nini.Config; | 35 | using Nini.Config; |
36 | using Mono.Addins; | ||
34 | using OpenMetaverse; | 37 | using OpenMetaverse; |
38 | |||
35 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Framework; | 41 | using OpenSim.Framework; |
38 | using Timer=System.Timers.Timer; | ||
39 | using OpenSim.Services.Interfaces; | 42 | using OpenSim.Services.Interfaces; |
40 | 43 | ||
41 | namespace OpenSim.Region.OptionalModules.World.NPC | 44 | namespace OpenSim.Region.OptionalModules.World.NPC |
42 | { | 45 | { |
43 | public class NPCModule : IRegionModule, INPCModule | 46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "NPCModule")] |
47 | public class NPCModule : INPCModule, ISharedRegionModule | ||
44 | { | 48 | { |
45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 49 | private static readonly ILog m_log = LogManager.GetLogger( |
50 | MethodBase.GetCurrentMethod().DeclaringType); | ||
51 | |||
52 | private Dictionary<UUID, NPCAvatar> m_avatars = | ||
53 | new Dictionary<UUID, NPCAvatar>(); | ||
46 | 54 | ||
47 | private Dictionary<UUID, NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>(); | 55 | public bool Enabled { get; private set; } |
48 | 56 | ||
49 | public void Initialise(Scene scene, IConfigSource source) | 57 | public void Initialise(IConfigSource source) |
50 | { | 58 | { |
51 | IConfig config = source.Configs["NPC"]; | 59 | IConfig config = source.Configs["NPC"]; |
52 | 60 | ||
53 | if (config != null && config.GetBoolean("Enabled", false)) | 61 | Enabled = (config != null && config.GetBoolean("Enabled", false)); |
54 | { | 62 | } |
63 | |||
64 | public void AddRegion(Scene scene) | ||
65 | { | ||
66 | if (Enabled) | ||
55 | scene.RegisterModuleInterface<INPCModule>(this); | 67 | scene.RegisterModuleInterface<INPCModule>(this); |
56 | } | 68 | } |
69 | |||
70 | public void RegionLoaded(Scene scene) | ||
71 | { | ||
57 | } | 72 | } |
58 | 73 | ||
59 | public void PostInitialise() | 74 | public void PostInitialise() |
60 | { | 75 | { |
61 | } | 76 | } |
62 | 77 | ||
78 | public void RemoveRegion(Scene scene) | ||
79 | { | ||
80 | scene.UnregisterModuleInterface<INPCModule>(this); | ||
81 | } | ||
82 | |||
63 | public void Close() | 83 | public void Close() |
64 | { | 84 | { |
65 | } | 85 | } |
@@ -69,15 +89,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
69 | get { return "NPCModule"; } | 89 | get { return "NPCModule"; } |
70 | } | 90 | } |
71 | 91 | ||
72 | public bool IsSharedModule | 92 | public Type ReplaceableInterface { get { return null; } } |
73 | { | ||
74 | get { return true; } | ||
75 | } | ||
76 | 93 | ||
77 | public bool IsNPC(UUID agentId, Scene scene) | 94 | public bool IsNPC(UUID agentId, Scene scene) |
78 | { | 95 | { |
79 | // FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect | 96 | // FIXME: This implementation could not just use the |
80 | // that directly). | 97 | // ScenePresence.PresenceType (and callers could inspect that |
98 | // directly). | ||
81 | ScenePresence sp = scene.GetScenePresence(agentId); | 99 | ScenePresence sp = scene.GetScenePresence(agentId); |
82 | if (sp == null || sp.IsChildAgent) | 100 | if (sp == null || sp.IsChildAgent) |
83 | return false; | 101 | return false; |
@@ -86,7 +104,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
86 | return m_avatars.ContainsKey(agentId); | 104 | return m_avatars.ContainsKey(agentId); |
87 | } | 105 | } |
88 | 106 | ||
89 | public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene) | 107 | public bool SetNPCAppearance(UUID agentId, |
108 | AvatarAppearance appearance, Scene scene) | ||
90 | { | 109 | { |
91 | ScenePresence npc = scene.GetScenePresence(agentId); | 110 | ScenePresence npc = scene.GetScenePresence(agentId); |
92 | if (npc == null || npc.IsChildAgent) | 111 | if (npc == null || npc.IsChildAgent) |
@@ -99,34 +118,35 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
99 | // Delete existing npc attachments | 118 | // Delete existing npc attachments |
100 | scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false); | 119 | scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false); |
101 | 120 | ||
102 | // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet since it doesn't transfer attachments | 121 | // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet |
103 | AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); | 122 | // since it doesn't transfer attachments |
123 | AvatarAppearance npcAppearance = new AvatarAppearance(appearance, | ||
124 | true); | ||
104 | npc.Appearance = npcAppearance; | 125 | npc.Appearance = npcAppearance; |
105 | 126 | ||
106 | // Rez needed npc attachments | 127 | // Rez needed npc attachments |
107 | scene.AttachmentsModule.RezAttachments(npc); | 128 | scene.AttachmentsModule.RezAttachments(npc); |
108 | 129 | ||
109 | IAvatarFactoryModule module = scene.RequestModuleInterface<IAvatarFactoryModule>(); | 130 | IAvatarFactoryModule module = |
131 | scene.RequestModuleInterface<IAvatarFactoryModule>(); | ||
110 | module.SendAppearance(npc.UUID); | 132 | module.SendAppearance(npc.UUID); |
111 | 133 | ||
112 | return true; | 134 | return true; |
113 | } | 135 | } |
114 | 136 | ||
115 | public UUID CreateNPC( | 137 | public UUID CreateNPC(string firstname, string lastname, |
116 | string firstname, | 138 | Vector3 position, UUID owner, bool senseAsAgent, Scene scene, |
117 | string lastname, | 139 | AvatarAppearance appearance) |
118 | Vector3 position, | ||
119 | UUID owner, | ||
120 | bool senseAsAgent, | ||
121 | Scene scene, | ||
122 | AvatarAppearance appearance) | ||
123 | { | 140 | { |
124 | NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene); | 141 | NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, |
125 | npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); | 142 | owner, senseAsAgent, scene); |
143 | npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, | ||
144 | int.MaxValue); | ||
126 | 145 | ||
127 | m_log.DebugFormat( | 146 | m_log.DebugFormat( |
128 | "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", | 147 | "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", |
129 | firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName); | 148 | firstname, lastname, npcAvatar.AgentId, owner, |
149 | senseAsAgent, position, scene.RegionInfo.RegionName); | ||
130 | 150 | ||
131 | AgentCircuitData acd = new AgentCircuitData(); | 151 | AgentCircuitData acd = new AgentCircuitData(); |
132 | acd.AgentID = npcAvatar.AgentId; | 152 | acd.AgentID = npcAvatar.AgentId; |
@@ -134,42 +154,55 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
134 | acd.lastname = lastname; | 154 | acd.lastname = lastname; |
135 | acd.ServiceURLs = new Dictionary<string, object>(); | 155 | acd.ServiceURLs = new Dictionary<string, object>(); |
136 | 156 | ||
137 | AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); | 157 | AvatarAppearance npcAppearance = new AvatarAppearance(appearance, |
158 | true); | ||
138 | acd.Appearance = npcAppearance; | 159 | acd.Appearance = npcAppearance; |
139 | 160 | ||
140 | // for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++) | 161 | /* |
141 | // { | 162 | for (int i = 0; |
142 | // m_log.DebugFormat( | 163 | i < acd.Appearance.Texture.FaceTextures.Length; i++) |
143 | // "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}", | 164 | { |
144 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); | 165 | m_log.DebugFormat( |
145 | // } | 166 | "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}", |
167 | acd.AgentID, i, | ||
168 | acd.Appearance.Texture.FaceTextures[i]); | ||
169 | } | ||
170 | */ | ||
146 | 171 | ||
147 | lock (m_avatars) | 172 | lock (m_avatars) |
148 | { | 173 | { |
149 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); | 174 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, |
175 | acd); | ||
150 | scene.AddNewClient(npcAvatar, PresenceType.Npc); | 176 | scene.AddNewClient(npcAvatar, PresenceType.Npc); |
151 | 177 | ||
152 | ScenePresence sp; | 178 | ScenePresence sp; |
153 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) | 179 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) |
154 | { | 180 | { |
155 | // m_log.DebugFormat( | 181 | /* |
156 | // "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); | 182 | m_log.DebugFormat( |
183 | "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", | ||
184 | sp.Name, sp.UUID); | ||
185 | */ | ||
157 | 186 | ||
158 | sp.CompleteMovement(npcAvatar, false); | 187 | sp.CompleteMovement(npcAvatar, false); |
159 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); | 188 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); |
160 | m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); | 189 | m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", |
190 | npcAvatar.AgentId, sp.Name); | ||
161 | 191 | ||
162 | return npcAvatar.AgentId; | 192 | return npcAvatar.AgentId; |
163 | } | 193 | } |
164 | else | 194 | else |
165 | { | 195 | { |
166 | m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID); | 196 | m_log.WarnFormat( |
197 | "[NPC MODULE]: Could not find scene presence for NPC {0} {1}", | ||
198 | sp.Name, sp.UUID); | ||
167 | return UUID.Zero; | 199 | return UUID.Zero; |
168 | } | 200 | } |
169 | } | 201 | } |
170 | } | 202 | } |
171 | 203 | ||
172 | public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget, bool running) | 204 | public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, |
205 | bool noFly, bool landAtTarget, bool running) | ||
173 | { | 206 | { |
174 | lock (m_avatars) | 207 | lock (m_avatars) |
175 | { | 208 | { |
@@ -179,12 +212,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
179 | if (scene.TryGetScenePresence(agentID, out sp)) | 212 | if (scene.TryGetScenePresence(agentID, out sp)) |
180 | { | 213 | { |
181 | m_log.DebugFormat( | 214 | m_log.DebugFormat( |
182 | "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", | 215 | "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", |
183 | sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); | 216 | sp.Name, pos, scene.RegionInfo.RegionName, |
217 | noFly, landAtTarget); | ||
184 | 218 | ||
185 | sp.MoveToTarget(pos, noFly, landAtTarget); | 219 | sp.MoveToTarget(pos, noFly, landAtTarget); |
186 | sp.SetAlwaysRun = running; | 220 | sp.SetAlwaysRun = running; |
187 | 221 | ||
188 | return true; | 222 | return true; |
189 | } | 223 | } |
190 | } | 224 | } |
@@ -257,9 +291,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
257 | ScenePresence sp; | 291 | ScenePresence sp; |
258 | if (scene.TryGetScenePresence(agentID, out sp)) | 292 | if (scene.TryGetScenePresence(agentID, out sp)) |
259 | { | 293 | { |
260 | sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero); | 294 | sp.HandleAgentRequestSit(m_avatars[agentID], agentID, |
261 | // sp.HandleAgentSit(m_avatars[agentID], agentID); | 295 | partID, Vector3.Zero); |
262 | 296 | //sp.HandleAgentSit(m_avatars[agentID], agentID); | |
297 | |||
263 | return true; | 298 | return true; |
264 | } | 299 | } |
265 | } | 300 | } |
@@ -268,7 +303,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
268 | return false; | 303 | return false; |
269 | } | 304 | } |
270 | 305 | ||
271 | public bool Whisper(UUID agentID, Scene scene, string text, int channel) | 306 | public bool Whisper(UUID agentID, Scene scene, string text, |
307 | int channel) | ||
272 | { | 308 | { |
273 | lock (m_avatars) | 309 | lock (m_avatars) |
274 | { | 310 | { |
@@ -343,16 +379,23 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
343 | NPCAvatar av; | 379 | NPCAvatar av; |
344 | if (m_avatars.TryGetValue(agentID, out av)) | 380 | if (m_avatars.TryGetValue(agentID, out av)) |
345 | { | 381 | { |
346 | // m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove", agentID, av.Name); | 382 | /* |
383 | m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove", | ||
384 | agentID, av.Name); | ||
385 | */ | ||
347 | scene.RemoveClient(agentID, false); | 386 | scene.RemoveClient(agentID, false); |
348 | m_avatars.Remove(agentID); | 387 | m_avatars.Remove(agentID); |
349 | 388 | /* | |
350 | m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name); | 389 | m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", |
390 | agentID, av.Name); | ||
391 | */ | ||
351 | return true; | 392 | return true; |
352 | } | 393 | } |
353 | } | 394 | } |
354 | 395 | /* | |
355 | // m_log.DebugFormat("[NPC MODULE]: Could not find {0} to remove", agentID); | 396 | m_log.DebugFormat("[NPC MODULE]: Could not find {0} to remove", |
397 | agentID); | ||
398 | */ | ||
356 | return false; | 399 | return false; |
357 | } | 400 | } |
358 | 401 | ||
@@ -376,7 +419,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
376 | /// <returns>true if they do, false if they don't.</returns> | 419 | /// <returns>true if they do, false if they don't.</returns> |
377 | private bool CheckPermissions(NPCAvatar av, UUID callerID) | 420 | private bool CheckPermissions(NPCAvatar av, UUID callerID) |
378 | { | 421 | { |
379 | return callerID == UUID.Zero || av.OwnerID == UUID.Zero || av.OwnerID == callerID; | 422 | return callerID == UUID.Zero || av.OwnerID == UUID.Zero || |
423 | av.OwnerID == callerID; | ||
380 | } | 424 | } |
381 | } | 425 | } |
382 | } | 426 | } |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 9179966..a522277 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | |||
@@ -48,7 +48,7 @@ using OpenSim.Tests.Common.Mock; | |||
48 | namespace OpenSim.Region.OptionalModules.World.NPC.Tests | 48 | namespace OpenSim.Region.OptionalModules.World.NPC.Tests |
49 | { | 49 | { |
50 | [TestFixture] | 50 | [TestFixture] |
51 | public class NPCModuleTests | 51 | public class NPCModuleTests : OpenSimTestCase |
52 | { | 52 | { |
53 | private TestScene m_scene; | 53 | private TestScene m_scene; |
54 | private AvatarFactoryModule m_afMod; | 54 | private AvatarFactoryModule m_afMod; |
@@ -117,6 +117,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
117 | Assert.That(npc, Is.Not.Null); | 117 | Assert.That(npc, Is.Not.Null); |
118 | Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); | 118 | Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); |
119 | Assert.That(m_umMod.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname))); | 119 | Assert.That(m_umMod.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname))); |
120 | |||
121 | IClientAPI client; | ||
122 | Assert.That(m_scene.TryGetClient(npcId, out client), Is.True); | ||
123 | |||
124 | // Have to account for both SP and NPC. | ||
125 | Assert.That(m_scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(2)); | ||
120 | } | 126 | } |
121 | 127 | ||
122 | [Test] | 128 | [Test] |
@@ -136,6 +142,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
136 | ScenePresence deletedNpc = m_scene.GetScenePresence(npcId); | 142 | ScenePresence deletedNpc = m_scene.GetScenePresence(npcId); |
137 | 143 | ||
138 | Assert.That(deletedNpc, Is.Null); | 144 | Assert.That(deletedNpc, Is.Null); |
145 | IClientAPI client; | ||
146 | Assert.That(m_scene.TryGetClient(npcId, out client), Is.False); | ||
147 | |||
148 | // Have to account for SP still present. | ||
149 | Assert.That(m_scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1)); | ||
139 | } | 150 | } |
140 | 151 | ||
141 | [Test] | 152 | [Test] |
diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs index 51b0592..8144870 100644 --- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs +++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs | |||
@@ -31,6 +31,7 @@ using System.Reflection; | |||
31 | using System.Timers; | 31 | using System.Timers; |
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using log4net; | 33 | using log4net; |
34 | using Mono.Addins; | ||
34 | using Nini.Config; | 35 | using Nini.Config; |
35 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
36 | using OpenSim.Region.CoreModules.Framework.InterfaceCommander; | 37 | using OpenSim.Region.CoreModules.Framework.InterfaceCommander; |
@@ -46,7 +47,8 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator | |||
46 | /// <summary> | 47 | /// <summary> |
47 | /// Version 2.02 - Still hacky | 48 | /// Version 2.02 - Still hacky |
48 | /// </summary> | 49 | /// </summary> |
49 | public class TreePopulatorModule : IRegionModule, ICommandableModule, IVegetationModule | 50 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "TreePopulatorModule")] |
51 | public class TreePopulatorModule : INonSharedRegionModule, ICommandableModule, IVegetationModule | ||
50 | { | 52 | { |
51 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 53 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
52 | private readonly Commander m_commander = new Commander("tree"); | 54 | private readonly Commander m_commander = new Commander("tree"); |
@@ -168,15 +170,11 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator | |||
168 | 170 | ||
169 | #endregion | 171 | #endregion |
170 | 172 | ||
171 | #region IRegionModule Members | 173 | #region Region Module interface |
172 | 174 | ||
173 | public void Initialise(Scene scene, IConfigSource config) | 175 | public void Initialise(IConfigSource config) |
174 | { | 176 | { |
175 | 177 | ||
176 | m_scene = scene; | ||
177 | m_scene.RegisterModuleInterface<IRegionModule>(this); | ||
178 | m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; | ||
179 | |||
180 | // ini file settings | 178 | // ini file settings |
181 | try | 179 | try |
182 | { | 180 | { |
@@ -201,7 +199,19 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator | |||
201 | m_log.Debug("[TREES]: Initialised tree module"); | 199 | m_log.Debug("[TREES]: Initialised tree module"); |
202 | } | 200 | } |
203 | 201 | ||
204 | public void PostInitialise() | 202 | public void AddRegion(Scene scene) |
203 | { | ||
204 | m_scene = scene; | ||
205 | m_scene.RegisterModuleCommander(m_commander); | ||
206 | m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; | ||
207 | |||
208 | } | ||
209 | |||
210 | public void RemoveRegion(Scene scene) | ||
211 | { | ||
212 | } | ||
213 | |||
214 | public void RegionLoaded(Scene scene) | ||
205 | { | 215 | { |
206 | ReloadCopse(); | 216 | ReloadCopse(); |
207 | if (m_copse.Count > 0) | 217 | if (m_copse.Count > 0) |
@@ -220,11 +230,12 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator | |||
220 | get { return "TreePopulatorModule"; } | 230 | get { return "TreePopulatorModule"; } |
221 | } | 231 | } |
222 | 232 | ||
223 | public bool IsSharedModule | 233 | public Type ReplaceableInterface |
224 | { | 234 | { |
225 | get { return false; } | 235 | get { return null; } |
226 | } | 236 | } |
227 | 237 | ||
238 | |||
228 | #endregion | 239 | #endregion |
229 | 240 | ||
230 | //-------------------------------------------------------------- | 241 | //-------------------------------------------------------------- |
@@ -448,8 +459,6 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator | |||
448 | m_commander.RegisterCommand("reload", treeReloadCommand); | 459 | m_commander.RegisterCommand("reload", treeReloadCommand); |
449 | m_commander.RegisterCommand("remove", treeRemoveCommand); | 460 | m_commander.RegisterCommand("remove", treeRemoveCommand); |
450 | m_commander.RegisterCommand("statistics", treeStatisticsCommand); | 461 | m_commander.RegisterCommand("statistics", treeStatisticsCommand); |
451 | |||
452 | m_scene.RegisterModuleCommander(m_commander); | ||
453 | } | 462 | } |
454 | 463 | ||
455 | /// <summary> | 464 | /// <summary> |
diff --git a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs index 1aee39a..baf55c3 100644 --- a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs +++ b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs | |||
@@ -32,6 +32,7 @@ using System.Drawing.Imaging; | |||
32 | using System.Reflection; | 32 | using System.Reflection; |
33 | using System.IO; | 33 | using System.IO; |
34 | using log4net; | 34 | using log4net; |
35 | using Mono.Addins; | ||
35 | using Nini.Config; | 36 | using Nini.Config; |
36 | using OpenMetaverse; | 37 | using OpenMetaverse; |
37 | using OpenMetaverse.Imaging; | 38 | using OpenMetaverse.Imaging; |
@@ -45,6 +46,7 @@ using OpenSim.Services.Interfaces; | |||
45 | 46 | ||
46 | namespace OpenSim.Region.OptionalModules.World.WorldView | 47 | namespace OpenSim.Region.OptionalModules.World.WorldView |
47 | { | 48 | { |
49 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WorldViewModule")] | ||
48 | public class WorldViewModule : INonSharedRegionModule | 50 | public class WorldViewModule : INonSharedRegionModule |
49 | { | 51 | { |
50 | private static readonly ILog m_log = | 52 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs index 063eb54..fb9cb66 100644 --- a/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/BasicPhysicsPlugin/AssemblyInfo.cs | |||
@@ -39,7 +39,7 @@ using System.Runtime.InteropServices; | |||
39 | [assembly : AssemblyConfiguration("")] | 39 | [assembly : AssemblyConfiguration("")] |
40 | [assembly : AssemblyCompany("http://opensimulator.org")] | 40 | [assembly : AssemblyCompany("http://opensimulator.org")] |
41 | [assembly : AssemblyProduct("BasicPhysicsPlugin")] | 41 | [assembly : AssemblyProduct("BasicPhysicsPlugin")] |
42 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] | 42 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")] |
43 | [assembly : AssemblyTrademark("")] | 43 | [assembly : AssemblyTrademark("")] |
44 | [assembly : AssemblyCulture("")] | 44 | [assembly : AssemblyCulture("")] |
45 | 45 | ||
@@ -55,4 +55,4 @@ using System.Runtime.InteropServices; | |||
55 | // You can specify all values by your own or you can build default build and revision | 55 | // You can specify all values by your own or you can build default build and revision |
56 | // numbers with the '*' character (the default): | 56 | // numbers with the '*' character (the default): |
57 | 57 | ||
58 | [assembly : AssemblyVersion("0.6.5.*")] | 58 | [assembly : AssemblyVersion("0.7.5.*")] |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 623ac8f..4c195e1 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -34,7 +34,7 @@ using OpenSim.Region.Physics.Manager; | |||
34 | 34 | ||
35 | namespace OpenSim.Region.Physics.BulletSPlugin | 35 | namespace OpenSim.Region.Physics.BulletSPlugin |
36 | { | 36 | { |
37 | public class BSCharacter : BSPhysObject | 37 | public sealed class BSCharacter : BSPhysObject |
38 | { | 38 | { |
39 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 39 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
40 | private static readonly string LogHeader = "[BULLETS CHAR]"; | 40 | private static readonly string LogHeader = "[BULLETS CHAR]"; |
@@ -78,11 +78,17 @@ public class BSCharacter : BSPhysObject | |||
78 | private float _PIDHoverTao; | 78 | private float _PIDHoverTao; |
79 | 79 | ||
80 | public BSCharacter(uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, bool isFlying) | 80 | public BSCharacter(uint localID, String avName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, bool isFlying) |
81 | : base(parent_scene, localID, avName, "BSCharacter") | ||
81 | { | 82 | { |
82 | base.BaseInitialize(parent_scene, localID, avName, "BSCharacter"); | ||
83 | _physicsActorType = (int)ActorTypes.Agent; | 83 | _physicsActorType = (int)ActorTypes.Agent; |
84 | _position = pos; | 84 | _position = pos; |
85 | |||
86 | // Old versions of ScenePresence passed only the height. If width and/or depth are zero, | ||
87 | // replace with the default values. | ||
85 | _size = size; | 88 | _size = size; |
89 | if (_size.X == 0f) _size.X = PhysicsScene.Params.avatarCapsuleDepth; | ||
90 | if (_size.Y == 0f) _size.Y = PhysicsScene.Params.avatarCapsuleWidth; | ||
91 | |||
86 | _flying = isFlying; | 92 | _flying = isFlying; |
87 | _orientation = OMV.Quaternion.Identity; | 93 | _orientation = OMV.Quaternion.Identity; |
88 | _velocity = OMV.Vector3.Zero; | 94 | _velocity = OMV.Vector3.Zero; |
@@ -97,28 +103,14 @@ public class BSCharacter : BSPhysObject | |||
97 | // set _avatarVolume and _mass based on capsule size, _density and Scale | 103 | // set _avatarVolume and _mass based on capsule size, _density and Scale |
98 | ComputeAvatarVolumeAndMass(); | 104 | ComputeAvatarVolumeAndMass(); |
99 | DetailLog("{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5}", | 105 | DetailLog("{0},BSCharacter.create,call,size={1},scale={2},density={3},volume={4},mass={5}", |
100 | LocalID, _size, Scale, _avatarDensity, _avatarVolume, MassRaw); | 106 | LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass); |
101 | |||
102 | ShapeData shapeData = new ShapeData(); | ||
103 | shapeData.ID = LocalID; | ||
104 | shapeData.Type = ShapeData.PhysicsShapeType.SHAPE_AVATAR; | ||
105 | shapeData.Position = _position; | ||
106 | shapeData.Rotation = _orientation; | ||
107 | shapeData.Velocity = _velocity; | ||
108 | shapeData.Size = Scale; | ||
109 | shapeData.Scale = Scale; | ||
110 | shapeData.Mass = _mass; | ||
111 | shapeData.Buoyancy = _buoyancy; | ||
112 | shapeData.Static = ShapeData.numericFalse; | ||
113 | shapeData.Friction = PhysicsScene.Params.avatarStandingFriction; | ||
114 | shapeData.Restitution = PhysicsScene.Params.avatarRestitution; | ||
115 | 107 | ||
116 | // do actual create at taint time | 108 | // do actual create at taint time |
117 | PhysicsScene.TaintedObject("BSCharacter.create", delegate() | 109 | PhysicsScene.TaintedObject("BSCharacter.create", delegate() |
118 | { | 110 | { |
119 | DetailLog("{0},BSCharacter.create,taint", LocalID); | 111 | DetailLog("{0},BSCharacter.create,taint", LocalID); |
120 | // New body and shape into BSBody and BSShape | 112 | // New body and shape into PhysBody and PhysShape |
121 | PhysicsScene.Shapes.GetBodyAndShape(true, PhysicsScene.World, this, shapeData, null, null, null); | 113 | PhysicsScene.Shapes.GetBodyAndShape(true, PhysicsScene.World, this, null, null); |
122 | 114 | ||
123 | SetPhysicalProperties(); | 115 | SetPhysicalProperties(); |
124 | }); | 116 | }); |
@@ -131,41 +123,50 @@ public class BSCharacter : BSPhysObject | |||
131 | DetailLog("{0},BSCharacter.Destroy", LocalID); | 123 | DetailLog("{0},BSCharacter.Destroy", LocalID); |
132 | PhysicsScene.TaintedObject("BSCharacter.destroy", delegate() | 124 | PhysicsScene.TaintedObject("BSCharacter.destroy", delegate() |
133 | { | 125 | { |
134 | PhysicsScene.Shapes.DereferenceBody(BSBody, true, null); | 126 | PhysicsScene.Shapes.DereferenceBody(PhysBody, true, null); |
135 | PhysicsScene.Shapes.DereferenceShape(BSShape, true, null); | 127 | PhysicsScene.Shapes.DereferenceShape(PhysShape, true, null); |
136 | }); | 128 | }); |
137 | } | 129 | } |
138 | 130 | ||
139 | private void SetPhysicalProperties() | 131 | private void SetPhysicalProperties() |
140 | { | 132 | { |
141 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, BSBody.ptr); | 133 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr); |
142 | 134 | ||
143 | ZeroMotion(); | 135 | ZeroMotion(true); |
144 | ForcePosition = _position; | 136 | ForcePosition = _position; |
145 | // Set the velocity and compute the proper friction | 137 | // Set the velocity and compute the proper friction |
146 | ForceVelocity = _velocity; | 138 | ForceVelocity = _velocity; |
147 | BulletSimAPI.SetRestitution2(BSBody.ptr, PhysicsScene.Params.avatarRestitution); | 139 | |
148 | BulletSimAPI.SetLocalScaling2(BSShape.ptr, Scale); | 140 | // This will enable or disable the flying buoyancy of the avatar. |
149 | BulletSimAPI.SetContactProcessingThreshold2(BSBody.ptr, PhysicsScene.Params.contactProcessingThreshold); | 141 | // Needs to be reset especially when an avatar is recreated after crossing a region boundry. |
142 | Flying = _flying; | ||
143 | |||
144 | BulletSimAPI.SetRestitution2(PhysBody.ptr, PhysicsScene.Params.avatarRestitution); | ||
145 | BulletSimAPI.SetMargin2(PhysShape.ptr, PhysicsScene.Params.collisionMargin); | ||
146 | BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale); | ||
147 | BulletSimAPI.SetContactProcessingThreshold2(PhysBody.ptr, PhysicsScene.Params.contactProcessingThreshold); | ||
150 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) | 148 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) |
151 | { | 149 | { |
152 | BulletSimAPI.SetCcdMotionThreshold2(BSBody.ptr, PhysicsScene.Params.ccdMotionThreshold); | 150 | BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, PhysicsScene.Params.ccdMotionThreshold); |
153 | BulletSimAPI.SetCcdSweepSphereRadius2(BSBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); | 151 | BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); |
154 | } | 152 | } |
155 | 153 | ||
156 | OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, MassRaw); | 154 | UpdatePhysicalMassProperties(RawMass); |
157 | BulletSimAPI.SetMassProps2(BSBody.ptr, MassRaw, localInertia); | 155 | |
156 | // Make so capsule does not fall over | ||
157 | BulletSimAPI.SetAngularFactorV2(PhysBody.ptr, OMV.Vector3.Zero); | ||
158 | 158 | ||
159 | BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.CF_CHARACTER_OBJECT); | 159 | BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_CHARACTER_OBJECT); |
160 | 160 | ||
161 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, BSBody.ptr); | 161 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, PhysBody.ptr); |
162 | 162 | ||
163 | BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ACTIVE_TAG); | 163 | // BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ACTIVE_TAG); |
164 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, BSBody.ptr); | 164 | BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.DISABLE_DEACTIVATION); |
165 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr); | ||
165 | 166 | ||
166 | // Do this after the object has been added to the world | 167 | // Do this after the object has been added to the world |
167 | BulletSimAPI.SetCollisionFilterMask2(BSBody.ptr, | 168 | BulletSimAPI.SetCollisionFilterMask2(PhysBody.ptr, |
168 | (uint)CollisionFilterGroups.AvatarFilter, | 169 | (uint)CollisionFilterGroups.AvatarFilter, |
169 | (uint)CollisionFilterGroups.AvatarMask); | 170 | (uint)CollisionFilterGroups.AvatarMask); |
170 | } | 171 | } |
171 | 172 | ||
@@ -175,6 +176,7 @@ public class BSCharacter : BSPhysObject | |||
175 | } | 176 | } |
176 | // No one calls this method so I don't know what it could possibly mean | 177 | // No one calls this method so I don't know what it could possibly mean |
177 | public override bool Stopped { get { return false; } } | 178 | public override bool Stopped { get { return false; } } |
179 | |||
178 | public override OMV.Vector3 Size { | 180 | public override OMV.Vector3 Size { |
179 | get | 181 | get |
180 | { | 182 | { |
@@ -187,23 +189,29 @@ public class BSCharacter : BSPhysObject | |||
187 | _size = value; | 189 | _size = value; |
188 | ComputeAvatarScale(_size); | 190 | ComputeAvatarScale(_size); |
189 | ComputeAvatarVolumeAndMass(); | 191 | ComputeAvatarVolumeAndMass(); |
190 | DetailLog("{0},BSCharacter.setSize,call,scale={1},density={2},volume={3},mass={4}", | 192 | DetailLog("{0},BSCharacter.setSize,call,size={1},scale={2},density={3},volume={4},mass={5}", |
191 | LocalID, Scale, _avatarDensity, _avatarVolume, MassRaw); | 193 | LocalID, _size, Scale, _avatarDensity, _avatarVolume, RawMass); |
192 | 194 | ||
193 | PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() | 195 | PhysicsScene.TaintedObject("BSCharacter.setSize", delegate() |
194 | { | 196 | { |
195 | BulletSimAPI.SetLocalScaling2(BSShape.ptr, Scale); | 197 | BulletSimAPI.SetLocalScaling2(PhysShape.ptr, Scale); |
196 | OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, MassRaw); | 198 | UpdatePhysicalMassProperties(RawMass); |
197 | BulletSimAPI.SetMassProps2(BSBody.ptr, MassRaw, localInertia); | ||
198 | }); | 199 | }); |
199 | 200 | ||
200 | } | 201 | } |
201 | } | 202 | } |
203 | |||
202 | public override OMV.Vector3 Scale { get; set; } | 204 | public override OMV.Vector3 Scale { get; set; } |
205 | |||
203 | public override PrimitiveBaseShape Shape | 206 | public override PrimitiveBaseShape Shape |
204 | { | 207 | { |
205 | set { BaseShape = value; } | 208 | set { BaseShape = value; } |
206 | } | 209 | } |
210 | // I want the physics engine to make an avatar capsule | ||
211 | public override BSPhysicsShapeType PreferredPhysicalShape | ||
212 | { | ||
213 | get {return BSPhysicsShapeType.SHAPE_CAPSULE; } | ||
214 | } | ||
207 | 215 | ||
208 | public override bool Grabbed { | 216 | public override bool Grabbed { |
209 | set { _grabbed = value; } | 217 | set { _grabbed = value; } |
@@ -219,23 +227,42 @@ public class BSCharacter : BSPhysObject | |||
219 | // Do it to the properties so the values get set in the physics engine. | 227 | // Do it to the properties so the values get set in the physics engine. |
220 | // Push the setting of the values to the viewer. | 228 | // Push the setting of the values to the viewer. |
221 | // Called at taint time! | 229 | // Called at taint time! |
222 | public override void ZeroMotion() | 230 | public override void ZeroMotion(bool inTaintTime) |
223 | { | 231 | { |
224 | _velocity = OMV.Vector3.Zero; | 232 | _velocity = OMV.Vector3.Zero; |
225 | _acceleration = OMV.Vector3.Zero; | 233 | _acceleration = OMV.Vector3.Zero; |
226 | _rotationalVelocity = OMV.Vector3.Zero; | 234 | _rotationalVelocity = OMV.Vector3.Zero; |
227 | 235 | ||
228 | // Zero some other properties directly into the physics engine | 236 | // Zero some other properties directly into the physics engine |
229 | BulletSimAPI.SetLinearVelocity2(BSBody.ptr, OMV.Vector3.Zero); | 237 | PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate() |
230 | BulletSimAPI.SetAngularVelocity2(BSBody.ptr, OMV.Vector3.Zero); | 238 | { |
231 | BulletSimAPI.SetInterpolationVelocity2(BSBody.ptr, OMV.Vector3.Zero, OMV.Vector3.Zero); | 239 | BulletSimAPI.ClearAllForces2(PhysBody.ptr); |
232 | BulletSimAPI.ClearForces2(BSBody.ptr); | 240 | }); |
233 | } | 241 | } |
242 | public override void ZeroAngularMotion(bool inTaintTime) | ||
243 | { | ||
244 | _rotationalVelocity = OMV.Vector3.Zero; | ||
245 | |||
246 | PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.ZeroMotion", delegate() | ||
247 | { | ||
248 | BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero); | ||
249 | BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero); | ||
250 | // The next also get rid of applied linear force but the linear velocity is untouched. | ||
251 | BulletSimAPI.ClearForces2(PhysBody.ptr); | ||
252 | }); | ||
253 | } | ||
254 | |||
234 | 255 | ||
235 | public override void LockAngularMotion(OMV.Vector3 axis) { return; } | 256 | public override void LockAngularMotion(OMV.Vector3 axis) { return; } |
236 | 257 | ||
258 | public override OMV.Vector3 RawPosition | ||
259 | { | ||
260 | get { return _position; } | ||
261 | set { _position = value; } | ||
262 | } | ||
237 | public override OMV.Vector3 Position { | 263 | public override OMV.Vector3 Position { |
238 | get { | 264 | get { |
265 | // Don't refetch the position because this function is called a zillion times | ||
239 | // _position = BulletSimAPI.GetObjectPosition2(Scene.World.ptr, LocalID); | 266 | // _position = BulletSimAPI.GetObjectPosition2(Scene.World.ptr, LocalID); |
240 | return _position; | 267 | return _position; |
241 | } | 268 | } |
@@ -246,30 +273,30 @@ public class BSCharacter : BSPhysObject | |||
246 | PhysicsScene.TaintedObject("BSCharacter.setPosition", delegate() | 273 | PhysicsScene.TaintedObject("BSCharacter.setPosition", delegate() |
247 | { | 274 | { |
248 | DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 275 | DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
249 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | 276 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); |
250 | }); | 277 | }); |
251 | } | 278 | } |
252 | } | 279 | } |
253 | public override OMV.Vector3 ForcePosition { | 280 | public override OMV.Vector3 ForcePosition { |
254 | get { | 281 | get { |
255 | _position = BulletSimAPI.GetPosition2(BSBody.ptr); | 282 | _position = BulletSimAPI.GetPosition2(PhysBody.ptr); |
256 | return _position; | 283 | return _position; |
257 | } | 284 | } |
258 | set { | 285 | set { |
259 | _position = value; | 286 | _position = value; |
260 | PositionSanityCheck(); | 287 | PositionSanityCheck(); |
261 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | 288 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); |
262 | } | 289 | } |
263 | } | 290 | } |
264 | 291 | ||
265 | 292 | ||
266 | // Check that the current position is sane and, if not, modify the position to make it so. | 293 | // Check that the current position is sane and, if not, modify the position to make it so. |
267 | // Check for being below terrain and being out of bounds. | 294 | // Check for being below terrain or on water. |
268 | // Returns 'true' of the position was made sane by some action. | 295 | // Returns 'true' of the position was made sane by some action. |
269 | private bool PositionSanityCheck() | 296 | private bool PositionSanityCheck() |
270 | { | 297 | { |
271 | bool ret = false; | 298 | bool ret = false; |
272 | 299 | ||
273 | // If below the ground, move the avatar up | 300 | // If below the ground, move the avatar up |
274 | float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position); | 301 | float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position); |
275 | if (Position.Z < terrainHeight) | 302 | if (Position.Z < terrainHeight) |
@@ -302,15 +329,11 @@ public class BSCharacter : BSPhysObject | |||
302 | { | 329 | { |
303 | // The new position value must be pushed into the physics engine but we can't | 330 | // The new position value must be pushed into the physics engine but we can't |
304 | // just assign to "Position" because of potential call loops. | 331 | // just assign to "Position" because of potential call loops. |
305 | BSScene.TaintCallback sanityOperation = delegate() | 332 | PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate() |
306 | { | 333 | { |
307 | DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 334 | DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
308 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | 335 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); |
309 | }; | 336 | }); |
310 | if (inTaintTime) | ||
311 | sanityOperation(); | ||
312 | else | ||
313 | PhysicsScene.TaintedObject("BSCharacter.PositionSanityCheck", sanityOperation); | ||
314 | ret = true; | 337 | ret = true; |
315 | } | 338 | } |
316 | return ret; | 339 | return ret; |
@@ -319,7 +342,14 @@ public class BSCharacter : BSPhysObject | |||
319 | public override float Mass { get { return _mass; } } | 342 | public override float Mass { get { return _mass; } } |
320 | 343 | ||
321 | // used when we only want this prim's mass and not the linkset thing | 344 | // used when we only want this prim's mass and not the linkset thing |
322 | public override float MassRaw { get {return _mass; } } | 345 | public override float RawMass { |
346 | get {return _mass; } | ||
347 | } | ||
348 | public override void UpdatePhysicalMassProperties(float physMass) | ||
349 | { | ||
350 | OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass); | ||
351 | BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, localInertia); | ||
352 | } | ||
323 | 353 | ||
324 | public override OMV.Vector3 Force { | 354 | public override OMV.Vector3 Force { |
325 | get { return _force; } | 355 | get { return _force; } |
@@ -329,13 +359,13 @@ public class BSCharacter : BSPhysObject | |||
329 | PhysicsScene.TaintedObject("BSCharacter.SetForce", delegate() | 359 | PhysicsScene.TaintedObject("BSCharacter.SetForce", delegate() |
330 | { | 360 | { |
331 | DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force); | 361 | DetailLog("{0},BSCharacter.setForce,taint,force={1}", LocalID, _force); |
332 | BulletSimAPI.SetObjectForce2(BSBody.ptr, _force); | 362 | BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force); |
333 | }); | 363 | }); |
334 | } | 364 | } |
335 | } | 365 | } |
336 | 366 | ||
337 | // Avatars don't do vehicles | 367 | // Avatars don't do vehicles |
338 | public override int VehicleType { get { return 0; } set { return; } } | 368 | public override int VehicleType { get { return (int)Vehicle.TYPE_NONE; } set { return; } } |
339 | public override void VehicleFloatParam(int param, float value) { } | 369 | public override void VehicleFloatParam(int param, float value) { } |
340 | public override void VehicleVectorParam(int param, OMV.Vector3 value) {} | 370 | public override void VehicleVectorParam(int param, OMV.Vector3 value) {} |
341 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) { } | 371 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) { } |
@@ -368,7 +398,7 @@ public class BSCharacter : BSPhysObject | |||
368 | if (_currentFriction != PhysicsScene.Params.avatarStandingFriction) | 398 | if (_currentFriction != PhysicsScene.Params.avatarStandingFriction) |
369 | { | 399 | { |
370 | _currentFriction = PhysicsScene.Params.avatarStandingFriction; | 400 | _currentFriction = PhysicsScene.Params.avatarStandingFriction; |
371 | BulletSimAPI.SetFriction2(BSBody.ptr, _currentFriction); | 401 | BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction); |
372 | } | 402 | } |
373 | } | 403 | } |
374 | else | 404 | else |
@@ -376,15 +406,15 @@ public class BSCharacter : BSPhysObject | |||
376 | if (_currentFriction != PhysicsScene.Params.avatarFriction) | 406 | if (_currentFriction != PhysicsScene.Params.avatarFriction) |
377 | { | 407 | { |
378 | _currentFriction = PhysicsScene.Params.avatarFriction; | 408 | _currentFriction = PhysicsScene.Params.avatarFriction; |
379 | BulletSimAPI.SetFriction2(BSBody.ptr, _currentFriction); | 409 | BulletSimAPI.SetFriction2(PhysBody.ptr, _currentFriction); |
380 | } | 410 | } |
381 | } | 411 | } |
382 | _velocity = value; | 412 | _velocity = value; |
383 | // Remember the set velocity so we can suppress the reduction by friction, ... | 413 | // Remember the set velocity so we can suppress the reduction by friction, ... |
384 | _appliedVelocity = value; | 414 | _appliedVelocity = value; |
385 | 415 | ||
386 | BulletSimAPI.SetLinearVelocity2(BSBody.ptr, _velocity); | 416 | BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity); |
387 | BulletSimAPI.Activate2(BSBody.ptr, true); | 417 | BulletSimAPI.Activate2(PhysBody.ptr, true); |
388 | } | 418 | } |
389 | } | 419 | } |
390 | public override OMV.Vector3 Torque { | 420 | public override OMV.Vector3 Torque { |
@@ -401,6 +431,11 @@ public class BSCharacter : BSPhysObject | |||
401 | get { return _acceleration; } | 431 | get { return _acceleration; } |
402 | set { _acceleration = value; } | 432 | set { _acceleration = value; } |
403 | } | 433 | } |
434 | public override OMV.Quaternion RawOrientation | ||
435 | { | ||
436 | get { return _orientation; } | ||
437 | set { _orientation = value; } | ||
438 | } | ||
404 | public override OMV.Quaternion Orientation { | 439 | public override OMV.Quaternion Orientation { |
405 | get { return _orientation; } | 440 | get { return _orientation; } |
406 | set { | 441 | set { |
@@ -409,22 +444,22 @@ public class BSCharacter : BSPhysObject | |||
409 | PhysicsScene.TaintedObject("BSCharacter.setOrientation", delegate() | 444 | PhysicsScene.TaintedObject("BSCharacter.setOrientation", delegate() |
410 | { | 445 | { |
411 | // _position = BulletSimAPI.GetPosition2(BSBody.ptr); | 446 | // _position = BulletSimAPI.GetPosition2(BSBody.ptr); |
412 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | 447 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); |
413 | }); | 448 | }); |
414 | } | 449 | } |
415 | } | 450 | } |
416 | // Go directly to Bullet to get/set the value. | 451 | // Go directly to Bullet to get/set the value. |
417 | public override OMV.Quaternion ForceOrientation | 452 | public override OMV.Quaternion ForceOrientation |
418 | { | 453 | { |
419 | get | 454 | get |
420 | { | 455 | { |
421 | _orientation = BulletSimAPI.GetOrientation2(BSBody.ptr); | 456 | _orientation = BulletSimAPI.GetOrientation2(PhysBody.ptr); |
422 | return _orientation; | 457 | return _orientation; |
423 | } | 458 | } |
424 | set | 459 | set |
425 | { | 460 | { |
426 | _orientation = value; | 461 | _orientation = value; |
427 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | 462 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); |
428 | } | 463 | } |
429 | } | 464 | } |
430 | public override int PhysicsActorType { | 465 | public override int PhysicsActorType { |
@@ -478,14 +513,14 @@ public class BSCharacter : BSPhysObject | |||
478 | set { _collidingObj = value; } | 513 | set { _collidingObj = value; } |
479 | } | 514 | } |
480 | public override bool FloatOnWater { | 515 | public override bool FloatOnWater { |
481 | set { | 516 | set { |
482 | _floatOnWater = value; | 517 | _floatOnWater = value; |
483 | PhysicsScene.TaintedObject("BSCharacter.setFloatOnWater", delegate() | 518 | PhysicsScene.TaintedObject("BSCharacter.setFloatOnWater", delegate() |
484 | { | 519 | { |
485 | if (_floatOnWater) | 520 | if (_floatOnWater) |
486 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); | 521 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); |
487 | else | 522 | else |
488 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); | 523 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); |
489 | }); | 524 | }); |
490 | } | 525 | } |
491 | } | 526 | } |
@@ -518,7 +553,7 @@ public class BSCharacter : BSPhysObject | |||
518 | DetailLog("{0},BSCharacter.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy); | 553 | DetailLog("{0},BSCharacter.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy); |
519 | // Buoyancy is faked by changing the gravity applied to the object | 554 | // Buoyancy is faked by changing the gravity applied to the object |
520 | float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); | 555 | float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); |
521 | BulletSimAPI.SetGravity2(BSBody.ptr, new OMV.Vector3(0f, 0f, grav)); | 556 | BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav)); |
522 | } | 557 | } |
523 | } | 558 | } |
524 | 559 | ||
@@ -564,7 +599,7 @@ public class BSCharacter : BSPhysObject | |||
564 | PhysicsScene.TaintedObject("BSCharacter.AddForce", delegate() | 599 | PhysicsScene.TaintedObject("BSCharacter.AddForce", delegate() |
565 | { | 600 | { |
566 | DetailLog("{0},BSCharacter.setAddForce,taint,addedForce={1}", LocalID, _force); | 601 | DetailLog("{0},BSCharacter.setAddForce,taint,addedForce={1}", LocalID, _force); |
567 | BulletSimAPI.SetObjectForce2(BSBody.ptr, _force); | 602 | BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force); |
568 | }); | 603 | }); |
569 | } | 604 | } |
570 | else | 605 | else |
@@ -584,14 +619,19 @@ public class BSCharacter : BSPhysObject | |||
584 | // The 'size' given by the simulator is the mid-point of the avatar | 619 | // The 'size' given by the simulator is the mid-point of the avatar |
585 | // and X and Y are unspecified. | 620 | // and X and Y are unspecified. |
586 | 621 | ||
587 | OMV.Vector3 newScale = OMV.Vector3.Zero; | 622 | OMV.Vector3 newScale = size; |
588 | newScale.X = PhysicsScene.Params.avatarCapsuleRadius; | 623 | // newScale.X = PhysicsScene.Params.avatarCapsuleWidth; |
589 | newScale.Y = PhysicsScene.Params.avatarCapsuleRadius; | 624 | // newScale.Y = PhysicsScene.Params.avatarCapsuleDepth; |
625 | |||
626 | // From the total height, remove the capsule half spheres that are at each end | ||
627 | // The 1.15f came from ODE. Not sure what this factors in. | ||
628 | // newScale.Z = (size.Z * 1.15f) - (newScale.X + newScale.Y); | ||
629 | |||
630 | // The total scale height is the central cylindar plus the caps on the two ends. | ||
631 | newScale.Z = size.Z + (Math.Min(size.X, size.Y) * 2f); | ||
590 | 632 | ||
591 | // From the total height, remote the capsule half spheres that are at each end | 633 | // Convert diameters to radii and height to half height -- the way Bullet expects it. |
592 | newScale.Z = (size.Z * 2f) - Math.Min(newScale.X, newScale.Y); | 634 | Scale = newScale / 2f; |
593 | // newScale.Z = (size.Z * 2f); | ||
594 | Scale = newScale; | ||
595 | } | 635 | } |
596 | 636 | ||
597 | // set _avatarVolume and _mass based on capsule size, _density and Scale | 637 | // set _avatarVolume and _mass based on capsule size, _density and Scale |
@@ -633,10 +673,10 @@ public class BSCharacter : BSPhysObject | |||
633 | // That's just the way they are defined. | 673 | // That's just the way they are defined. |
634 | OMV.Vector3 avVel = new OMV.Vector3(_appliedVelocity.X, _appliedVelocity.Y, entprop.Velocity.Z); | 674 | OMV.Vector3 avVel = new OMV.Vector3(_appliedVelocity.X, _appliedVelocity.Y, entprop.Velocity.Z); |
635 | _velocity = avVel; | 675 | _velocity = avVel; |
636 | BulletSimAPI.SetLinearVelocity2(BSBody.ptr, avVel); | 676 | BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, avVel); |
637 | } | 677 | } |
638 | 678 | ||
639 | // Tell the linkset about this | 679 | // Tell the linkset about value changes |
640 | Linkset.UpdateProperties(this); | 680 | Linkset.UpdateProperties(this); |
641 | 681 | ||
642 | // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. | 682 | // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs index a20be3a..65fac00 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs | |||
@@ -34,12 +34,20 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
34 | 34 | ||
35 | public abstract class BSConstraint : IDisposable | 35 | public abstract class BSConstraint : IDisposable |
36 | { | 36 | { |
37 | private static string LogHeader = "[BULLETSIM CONSTRAINT]"; | ||
38 | |||
37 | protected BulletSim m_world; | 39 | protected BulletSim m_world; |
38 | protected BulletBody m_body1; | 40 | protected BulletBody m_body1; |
39 | protected BulletBody m_body2; | 41 | protected BulletBody m_body2; |
40 | protected BulletConstraint m_constraint; | 42 | protected BulletConstraint m_constraint; |
41 | protected bool m_enabled = false; | 43 | protected bool m_enabled = false; |
42 | 44 | ||
45 | public BulletBody Body1 { get { return m_body1; } } | ||
46 | public BulletBody Body2 { get { return m_body2; } } | ||
47 | public BulletConstraint Constraint { get { return m_constraint; } } | ||
48 | public abstract ConstraintType Type { get; } | ||
49 | public bool IsEnabled { get { return m_enabled; } } | ||
50 | |||
43 | public BSConstraint() | 51 | public BSConstraint() |
44 | { | 52 | { |
45 | } | 53 | } |
@@ -53,7 +61,7 @@ public abstract class BSConstraint : IDisposable | |||
53 | { | 61 | { |
54 | bool success = BulletSimAPI.DestroyConstraint2(m_world.ptr, m_constraint.ptr); | 62 | bool success = BulletSimAPI.DestroyConstraint2(m_world.ptr, m_constraint.ptr); |
55 | m_world.physicsScene.DetailLog("{0},BSConstraint.Dispose,taint,id1={1},body1={2},id2={3},body2={4},success={5}", | 63 | m_world.physicsScene.DetailLog("{0},BSConstraint.Dispose,taint,id1={1},body1={2},id2={3},body2={4},success={5}", |
56 | BSScene.DetailLogZero, | 64 | BSScene.DetailLogZero, |
57 | m_body1.ID, m_body1.ptr.ToString("X"), | 65 | m_body1.ID, m_body1.ptr.ToString("X"), |
58 | m_body2.ID, m_body2.ptr.ToString("X"), | 66 | m_body2.ID, m_body2.ptr.ToString("X"), |
59 | success); | 67 | success); |
@@ -62,12 +70,6 @@ public abstract class BSConstraint : IDisposable | |||
62 | } | 70 | } |
63 | } | 71 | } |
64 | 72 | ||
65 | public BulletBody Body1 { get { return m_body1; } } | ||
66 | public BulletBody Body2 { get { return m_body2; } } | ||
67 | public BulletConstraint Constraint { get { return m_constraint; } } | ||
68 | public abstract ConstraintType Type { get; } | ||
69 | |||
70 | |||
71 | public virtual bool SetLinearLimits(Vector3 low, Vector3 high) | 73 | public virtual bool SetLinearLimits(Vector3 low, Vector3 high) |
72 | { | 74 | { |
73 | bool ret = false; | 75 | bool ret = false; |
@@ -124,7 +126,7 @@ public abstract class BSConstraint : IDisposable | |||
124 | } | 126 | } |
125 | else | 127 | else |
126 | { | 128 | { |
127 | m_world.physicsScene.Logger.ErrorFormat("[BULLETSIM CONSTRAINT] CalculateTransforms failed. A={0}, B={1}", Body1.ID, Body2.ID); | 129 | m_world.physicsScene.Logger.ErrorFormat("{0} CalculateTransforms failed. A={1}, B={2}", LogHeader, Body1.ID, Body2.ID); |
128 | } | 130 | } |
129 | } | 131 | } |
130 | return ret; | 132 | return ret; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs index 3306a97..23ef052 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BS6DofConstraint.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs | |||
@@ -32,14 +32,14 @@ using OpenMetaverse; | |||
32 | namespace OpenSim.Region.Physics.BulletSPlugin | 32 | namespace OpenSim.Region.Physics.BulletSPlugin |
33 | { | 33 | { |
34 | 34 | ||
35 | public class BS6DofConstraint : BSConstraint | 35 | public sealed class BSConstraint6Dof : BSConstraint |
36 | { | 36 | { |
37 | private static string LogHeader = "[BULLETSIM 6DOF CONSTRAINT]"; | 37 | private static string LogHeader = "[BULLETSIM 6DOF CONSTRAINT]"; |
38 | 38 | ||
39 | public override ConstraintType Type { get { return ConstraintType.D6_CONSTRAINT_TYPE; } } | 39 | public override ConstraintType Type { get { return ConstraintType.D6_CONSTRAINT_TYPE; } } |
40 | 40 | ||
41 | // Create a btGeneric6DofConstraint | 41 | // Create a btGeneric6DofConstraint |
42 | public BS6DofConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, | 42 | public BSConstraint6Dof(BulletSim world, BulletBody obj1, BulletBody obj2, |
43 | Vector3 frame1, Quaternion frame1rot, | 43 | Vector3 frame1, Quaternion frame1rot, |
44 | Vector3 frame2, Quaternion frame2rot, | 44 | Vector3 frame2, Quaternion frame2rot, |
45 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | 45 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) |
@@ -58,7 +58,7 @@ public class BS6DofConstraint : BSConstraint | |||
58 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | 58 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); |
59 | } | 59 | } |
60 | 60 | ||
61 | public BS6DofConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, | 61 | public BSConstraint6Dof(BulletSim world, BulletBody obj1, BulletBody obj2, |
62 | Vector3 joinPoint, | 62 | Vector3 joinPoint, |
63 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | 63 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) |
64 | { | 64 | { |
@@ -71,8 +71,7 @@ public class BS6DofConstraint : BSConstraint | |||
71 | BSScene.DetailLogZero, world.worldID, | 71 | BSScene.DetailLogZero, world.worldID, |
72 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | 72 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); |
73 | world.physicsScene.Logger.ErrorFormat("{0} Attempt to build 6DOF constraint with missing bodies: wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", | 73 | world.physicsScene.Logger.ErrorFormat("{0} Attempt to build 6DOF constraint with missing bodies: wID={1}, rID={2}, rBody={3}, cID={4}, cBody={5}", |
74 | "[BULLETSIM 6DOF CONSTRAINT]", world.worldID, | 74 | LogHeader, world.worldID, obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); |
75 | obj1.ID, obj1.ptr.ToString("X"), obj2.ID, obj2.ptr.ToString("X")); | ||
76 | m_enabled = false; | 75 | m_enabled = false; |
77 | } | 76 | } |
78 | else | 77 | else |
@@ -135,7 +134,11 @@ public class BS6DofConstraint : BSConstraint | |||
135 | bool ret = false; | 134 | bool ret = false; |
136 | float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; | 135 | float onOff = enable ? ConfigurationParameters.numericTrue : ConfigurationParameters.numericFalse; |
137 | if (m_enabled) | 136 | if (m_enabled) |
137 | { | ||
138 | ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.ptr, onOff, targetVelocity, maxMotorForce); | 138 | ret = BulletSimAPI.TranslationalLimitMotor2(m_constraint.ptr, onOff, targetVelocity, maxMotorForce); |
139 | m_world.physicsScene.DetailLog("{0},BS6DOFConstraint,TransLimitMotor,enable={1},vel={2},maxForce={3}", | ||
140 | BSScene.DetailLogZero, enable, targetVelocity, maxMotorForce); | ||
141 | } | ||
139 | return ret; | 142 | return ret; |
140 | } | 143 | } |
141 | 144 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs index 22ea367..a9fd826 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintCollection.cs | |||
@@ -33,7 +33,7 @@ using OpenMetaverse; | |||
33 | namespace OpenSim.Region.Physics.BulletSPlugin | 33 | namespace OpenSim.Region.Physics.BulletSPlugin |
34 | { | 34 | { |
35 | 35 | ||
36 | public class BSConstraintCollection : IDisposable | 36 | public sealed class BSConstraintCollection : IDisposable |
37 | { | 37 | { |
38 | // private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 38 | // private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
39 | // private static readonly string LogHeader = "[CONSTRAINT COLLECTION]"; | 39 | // private static readonly string LogHeader = "[CONSTRAINT COLLECTION]"; |
@@ -143,8 +143,6 @@ public class BSConstraintCollection : IDisposable | |||
143 | // Return 'true' if any constraints were destroyed. | 143 | // Return 'true' if any constraints were destroyed. |
144 | public bool RemoveAndDestroyConstraint(BulletBody body1) | 144 | public bool RemoveAndDestroyConstraint(BulletBody body1) |
145 | { | 145 | { |
146 | // return BulletSimAPI.RemoveConstraintByID(m_world.ID, obj.ID); | ||
147 | |||
148 | List<BSConstraint> toRemove = new List<BSConstraint>(); | 146 | List<BSConstraint> toRemove = new List<BSConstraint>(); |
149 | uint lookingID = body1.ID; | 147 | uint lookingID = body1.ID; |
150 | lock (m_constraints) | 148 | lock (m_constraints) |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSHingeConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintHinge.cs index 7c8a215..ed3ffa7 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSHingeConstraint.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraintHinge.cs | |||
@@ -32,11 +32,11 @@ using OpenMetaverse; | |||
32 | namespace OpenSim.Region.Physics.BulletSPlugin | 32 | namespace OpenSim.Region.Physics.BulletSPlugin |
33 | { | 33 | { |
34 | 34 | ||
35 | class BSHingeConstraint : BSConstraint | 35 | public sealed class BSConstraintHinge : BSConstraint |
36 | { | 36 | { |
37 | public override ConstraintType Type { get { return ConstraintType.HINGE_CONSTRAINT_TYPE; } } | 37 | public override ConstraintType Type { get { return ConstraintType.HINGE_CONSTRAINT_TYPE; } } |
38 | 38 | ||
39 | public BSHingeConstraint(BulletSim world, BulletBody obj1, BulletBody obj2, | 39 | public BSConstraintHinge(BulletSim world, BulletBody obj1, BulletBody obj2, |
40 | Vector3 pivotInA, Vector3 pivotInB, | 40 | Vector3 pivotInA, Vector3 pivotInB, |
41 | Vector3 axisInA, Vector3 axisInB, | 41 | Vector3 axisInA, Vector3 axisInB, |
42 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | 42 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 56342b8..dbc9039 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -23,7 +23,7 @@ | |||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | 24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | * |
27 | 27 | ||
28 | /* RA: June 14, 2011. Copied from ODEDynamics.cs and converted to | 28 | /* RA: June 14, 2011. Copied from ODEDynamics.cs and converted to |
29 | * call the BulletSim system. | 29 | * call the BulletSim system. |
@@ -52,12 +52,17 @@ using OpenSim.Region.Physics.Manager; | |||
52 | 52 | ||
53 | namespace OpenSim.Region.Physics.BulletSPlugin | 53 | namespace OpenSim.Region.Physics.BulletSPlugin |
54 | { | 54 | { |
55 | public class BSDynamics | 55 | public sealed class BSDynamics |
56 | { | 56 | { |
57 | private static string LogHeader = "[BULLETSIM VEHICLE]"; | ||
58 | |||
57 | private BSScene PhysicsScene { get; set; } | 59 | private BSScene PhysicsScene { get; set; } |
58 | // the prim this dynamic controller belongs to | 60 | // the prim this dynamic controller belongs to |
59 | private BSPrim Prim { get; set; } | 61 | private BSPrim Prim { get; set; } |
60 | 62 | ||
63 | // mass of the vehicle fetched each time we're calles | ||
64 | private float m_vehicleMass; | ||
65 | |||
61 | // Vehicle properties | 66 | // Vehicle properties |
62 | public Vehicle Type { get; set; } | 67 | public Vehicle Type { get; set; } |
63 | 68 | ||
@@ -72,8 +77,11 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
72 | // LIMIT_ROLL_ONLY | 77 | // LIMIT_ROLL_ONLY |
73 | private Vector3 m_BlockingEndPoint = Vector3.Zero; | 78 | private Vector3 m_BlockingEndPoint = Vector3.Zero; |
74 | private Quaternion m_RollreferenceFrame = Quaternion.Identity; | 79 | private Quaternion m_RollreferenceFrame = Quaternion.Identity; |
80 | private Quaternion m_referenceFrame = Quaternion.Identity; | ||
81 | |||
75 | // Linear properties | 82 | // Linear properties |
76 | private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time | 83 | private Vector3 m_linearMotorDirection = Vector3.Zero; // velocity requested by LSL, decayed by time |
84 | private Vector3 m_linearMotorOffset = Vector3.Zero; // the point of force can be offset from the center | ||
77 | private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL | 85 | private Vector3 m_linearMotorDirectionLASTSET = Vector3.Zero; // velocity requested by LSL |
78 | private Vector3 m_newVelocity = Vector3.Zero; // velocity computed to be applied to body | 86 | private Vector3 m_newVelocity = Vector3.Zero; // velocity computed to be applied to body |
79 | private Vector3 m_linearFrictionTimescale = Vector3.Zero; | 87 | private Vector3 m_linearFrictionTimescale = Vector3.Zero; |
@@ -86,7 +94,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
86 | 94 | ||
87 | //Angular properties | 95 | //Angular properties |
88 | private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor | 96 | private Vector3 m_angularMotorDirection = Vector3.Zero; // angular velocity requested by LSL motor |
89 | private int m_angularMotorApply = 0; // application frame counter | 97 | // private int m_angularMotorApply = 0; // application frame counter |
90 | private Vector3 m_angularMotorVelocity = Vector3.Zero; // current angular motor velocity | 98 | private Vector3 m_angularMotorVelocity = Vector3.Zero; // current angular motor velocity |
91 | private float m_angularMotorTimescale = 0; // motor angular velocity ramp up rate | 99 | private float m_angularMotorTimescale = 0; // motor angular velocity ramp up rate |
92 | private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate | 100 | private float m_angularMotorDecayTimescale = 0; // motor angular velocity decay rate |
@@ -95,19 +103,19 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
95 | private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body | 103 | private Vector3 m_lastVertAttractor = Vector3.Zero; // what VA was last applied to body |
96 | 104 | ||
97 | //Deflection properties | 105 | //Deflection properties |
98 | // private float m_angularDeflectionEfficiency = 0; | 106 | private float m_angularDeflectionEfficiency = 0; |
99 | // private float m_angularDeflectionTimescale = 0; | 107 | private float m_angularDeflectionTimescale = 0; |
100 | // private float m_linearDeflectionEfficiency = 0; | 108 | private float m_linearDeflectionEfficiency = 0; |
101 | // private float m_linearDeflectionTimescale = 0; | 109 | private float m_linearDeflectionTimescale = 0; |
102 | 110 | ||
103 | //Banking properties | 111 | //Banking properties |
104 | // private float m_bankingEfficiency = 0; | 112 | private float m_bankingEfficiency = 0; |
105 | // private float m_bankingMix = 0; | 113 | private float m_bankingMix = 0; |
106 | // private float m_bankingTimescale = 0; | 114 | private float m_bankingTimescale = 0; |
107 | 115 | ||
108 | //Hover and Buoyancy properties | 116 | //Hover and Buoyancy properties |
109 | private float m_VhoverHeight = 0f; | 117 | private float m_VhoverHeight = 0f; |
110 | // private float m_VhoverEfficiency = 0f; | 118 | private float m_VhoverEfficiency = 0f; |
111 | private float m_VhoverTimescale = 0f; | 119 | private float m_VhoverTimescale = 0f; |
112 | private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height | 120 | private float m_VhoverTargetHeight = -1.0f; // if <0 then no hover, else its the current target height |
113 | private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle. | 121 | private float m_VehicleBuoyancy = 0f; //KF: m_VehicleBuoyancy is set by VEHICLE_BUOYANCY for a vehicle. |
@@ -138,10 +146,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
138 | switch (pParam) | 146 | switch (pParam) |
139 | { | 147 | { |
140 | case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: | 148 | case Vehicle.ANGULAR_DEFLECTION_EFFICIENCY: |
141 | // m_angularDeflectionEfficiency = Math.Max(pValue, 0.01f); | 149 | m_angularDeflectionEfficiency = Math.Max(pValue, 0.01f); |
142 | break; | 150 | break; |
143 | case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: | 151 | case Vehicle.ANGULAR_DEFLECTION_TIMESCALE: |
144 | // m_angularDeflectionTimescale = Math.Max(pValue, 0.01f); | 152 | m_angularDeflectionTimescale = Math.Max(pValue, 0.01f); |
145 | break; | 153 | break; |
146 | case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE: | 154 | case Vehicle.ANGULAR_MOTOR_DECAY_TIMESCALE: |
147 | m_angularMotorDecayTimescale = Math.Max(pValue, 0.01f); | 155 | m_angularMotorDecayTimescale = Math.Max(pValue, 0.01f); |
@@ -150,20 +158,20 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
150 | m_angularMotorTimescale = Math.Max(pValue, 0.01f); | 158 | m_angularMotorTimescale = Math.Max(pValue, 0.01f); |
151 | break; | 159 | break; |
152 | case Vehicle.BANKING_EFFICIENCY: | 160 | case Vehicle.BANKING_EFFICIENCY: |
153 | // m_bankingEfficiency = Math.Max(pValue, 0.01f); | 161 | m_bankingEfficiency = Math.Max(-1f, Math.Min(pValue, 1f)); |
154 | break; | 162 | break; |
155 | case Vehicle.BANKING_MIX: | 163 | case Vehicle.BANKING_MIX: |
156 | // m_bankingMix = Math.Max(pValue, 0.01f); | 164 | m_bankingMix = Math.Max(pValue, 0.01f); |
157 | break; | 165 | break; |
158 | case Vehicle.BANKING_TIMESCALE: | 166 | case Vehicle.BANKING_TIMESCALE: |
159 | // m_bankingTimescale = Math.Max(pValue, 0.01f); | 167 | m_bankingTimescale = Math.Max(pValue, 0.01f); |
160 | break; | 168 | break; |
161 | case Vehicle.BUOYANCY: | 169 | case Vehicle.BUOYANCY: |
162 | m_VehicleBuoyancy = Math.Max(-1f, Math.Min(pValue, 1f)); | 170 | m_VehicleBuoyancy = Math.Max(-1f, Math.Min(pValue, 1f)); |
163 | break; | 171 | break; |
164 | // case Vehicle.HOVER_EFFICIENCY: | 172 | case Vehicle.HOVER_EFFICIENCY: |
165 | // m_VhoverEfficiency = Math.Max(0f, Math.Min(pValue, 1f)); | 173 | m_VhoverEfficiency = Math.Max(0f, Math.Min(pValue, 1f)); |
166 | // break; | 174 | break; |
167 | case Vehicle.HOVER_HEIGHT: | 175 | case Vehicle.HOVER_HEIGHT: |
168 | m_VhoverHeight = pValue; | 176 | m_VhoverHeight = pValue; |
169 | break; | 177 | break; |
@@ -171,10 +179,10 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
171 | m_VhoverTimescale = Math.Max(pValue, 0.01f); | 179 | m_VhoverTimescale = Math.Max(pValue, 0.01f); |
172 | break; | 180 | break; |
173 | case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: | 181 | case Vehicle.LINEAR_DEFLECTION_EFFICIENCY: |
174 | // m_linearDeflectionEfficiency = Math.Max(pValue, 0.01f); | 182 | m_linearDeflectionEfficiency = Math.Max(pValue, 0.01f); |
175 | break; | 183 | break; |
176 | case Vehicle.LINEAR_DEFLECTION_TIMESCALE: | 184 | case Vehicle.LINEAR_DEFLECTION_TIMESCALE: |
177 | // m_linearDeflectionTimescale = Math.Max(pValue, 0.01f); | 185 | m_linearDeflectionTimescale = Math.Max(pValue, 0.01f); |
178 | break; | 186 | break; |
179 | case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: | 187 | case Vehicle.LINEAR_MOTOR_DECAY_TIMESCALE: |
180 | m_linearMotorDecayTimescale = Math.Max(pValue, 0.01f); | 188 | m_linearMotorDecayTimescale = Math.Max(pValue, 0.01f); |
@@ -196,7 +204,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
196 | break; | 204 | break; |
197 | case Vehicle.ANGULAR_MOTOR_DIRECTION: | 205 | case Vehicle.ANGULAR_MOTOR_DIRECTION: |
198 | m_angularMotorDirection = new Vector3(pValue, pValue, pValue); | 206 | m_angularMotorDirection = new Vector3(pValue, pValue, pValue); |
199 | m_angularMotorApply = 10; | 207 | // m_angularMotorApply = 100; |
200 | break; | 208 | break; |
201 | case Vehicle.LINEAR_FRICTION_TIMESCALE: | 209 | case Vehicle.LINEAR_FRICTION_TIMESCALE: |
202 | m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue); | 210 | m_linearFrictionTimescale = new Vector3(pValue, pValue, pValue); |
@@ -206,7 +214,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
206 | m_linearMotorDirectionLASTSET = new Vector3(pValue, pValue, pValue); | 214 | m_linearMotorDirectionLASTSET = new Vector3(pValue, pValue, pValue); |
207 | break; | 215 | break; |
208 | case Vehicle.LINEAR_MOTOR_OFFSET: | 216 | case Vehicle.LINEAR_MOTOR_OFFSET: |
209 | // m_linearMotorOffset = new Vector3(pValue, pValue, pValue); | 217 | m_linearMotorOffset = new Vector3(pValue, pValue, pValue); |
210 | break; | 218 | break; |
211 | 219 | ||
212 | } | 220 | } |
@@ -221,15 +229,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
221 | m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); | 229 | m_angularFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); |
222 | break; | 230 | break; |
223 | case Vehicle.ANGULAR_MOTOR_DIRECTION: | 231 | case Vehicle.ANGULAR_MOTOR_DIRECTION: |
224 | m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); | ||
225 | // Limit requested angular speed to 2 rps= 4 pi rads/sec | 232 | // Limit requested angular speed to 2 rps= 4 pi rads/sec |
226 | if (m_angularMotorDirection.X > 12.56f) m_angularMotorDirection.X = 12.56f; | 233 | pValue.X = Math.Max(-12.56f, Math.Min(pValue.X, 12.56f)); |
227 | if (m_angularMotorDirection.X < - 12.56f) m_angularMotorDirection.X = - 12.56f; | 234 | pValue.Y = Math.Max(-12.56f, Math.Min(pValue.Y, 12.56f)); |
228 | if (m_angularMotorDirection.Y > 12.56f) m_angularMotorDirection.Y = 12.56f; | 235 | pValue.Z = Math.Max(-12.56f, Math.Min(pValue.Z, 12.56f)); |
229 | if (m_angularMotorDirection.Y < - 12.56f) m_angularMotorDirection.Y = - 12.56f; | 236 | m_angularMotorDirection = new Vector3(pValue.X, pValue.Y, pValue.Z); |
230 | if (m_angularMotorDirection.Z > 12.56f) m_angularMotorDirection.Z = 12.56f; | 237 | // m_angularMotorApply = 100; |
231 | if (m_angularMotorDirection.Z < - 12.56f) m_angularMotorDirection.Z = - 12.56f; | ||
232 | m_angularMotorApply = 10; | ||
233 | break; | 238 | break; |
234 | case Vehicle.LINEAR_FRICTION_TIMESCALE: | 239 | case Vehicle.LINEAR_FRICTION_TIMESCALE: |
235 | m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); | 240 | m_linearFrictionTimescale = new Vector3(pValue.X, pValue.Y, pValue.Z); |
@@ -239,7 +244,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
239 | m_linearMotorDirectionLASTSET = new Vector3(pValue.X, pValue.Y, pValue.Z); | 244 | m_linearMotorDirectionLASTSET = new Vector3(pValue.X, pValue.Y, pValue.Z); |
240 | break; | 245 | break; |
241 | case Vehicle.LINEAR_MOTOR_OFFSET: | 246 | case Vehicle.LINEAR_MOTOR_OFFSET: |
242 | // m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); | 247 | m_linearMotorOffset = new Vector3(pValue.X, pValue.Y, pValue.Z); |
243 | break; | 248 | break; |
244 | case Vehicle.BLOCK_EXIT: | 249 | case Vehicle.BLOCK_EXIT: |
245 | m_BlockingEndPoint = new Vector3(pValue.X, pValue.Y, pValue.Z); | 250 | m_BlockingEndPoint = new Vector3(pValue.X, pValue.Y, pValue.Z); |
@@ -253,7 +258,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
253 | switch (pParam) | 258 | switch (pParam) |
254 | { | 259 | { |
255 | case Vehicle.REFERENCE_FRAME: | 260 | case Vehicle.REFERENCE_FRAME: |
256 | // m_referenceFrame = pValue; | 261 | m_referenceFrame = pValue; |
257 | break; | 262 | break; |
258 | case Vehicle.ROLL_FRAME: | 263 | case Vehicle.ROLL_FRAME: |
259 | m_RollreferenceFrame = pValue; | 264 | m_RollreferenceFrame = pValue; |
@@ -265,21 +270,16 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
265 | { | 270 | { |
266 | VDetailLog("{0},ProcessVehicleFlags,param={1},remove={2}", Prim.LocalID, pParam, remove); | 271 | VDetailLog("{0},ProcessVehicleFlags,param={1},remove={2}", Prim.LocalID, pParam, remove); |
267 | VehicleFlag parm = (VehicleFlag)pParam; | 272 | VehicleFlag parm = (VehicleFlag)pParam; |
268 | if (remove) | 273 | if (pParam == -1) |
274 | m_flags = (VehicleFlag)0; | ||
275 | else | ||
269 | { | 276 | { |
270 | if (pParam == -1) | 277 | if (remove) |
271 | { | ||
272 | m_flags = (VehicleFlag)0; | ||
273 | } | ||
274 | else | ||
275 | { | ||
276 | m_flags &= ~parm; | 278 | m_flags &= ~parm; |
277 | } | 279 | else |
278 | } | 280 | m_flags |= parm; |
279 | else { | ||
280 | m_flags |= parm; | ||
281 | } | 281 | } |
282 | }//end ProcessVehicleFlags | 282 | } |
283 | 283 | ||
284 | internal void ProcessTypeChange(Vehicle pType) | 284 | internal void ProcessTypeChange(Vehicle pType) |
285 | { | 285 | { |
@@ -288,101 +288,144 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
288 | Type = pType; | 288 | Type = pType; |
289 | switch (pType) | 289 | switch (pType) |
290 | { | 290 | { |
291 | case Vehicle.TYPE_NONE: | 291 | case Vehicle.TYPE_NONE: |
292 | m_linearFrictionTimescale = new Vector3(0, 0, 0); | ||
293 | m_angularFrictionTimescale = new Vector3(0, 0, 0); | ||
294 | m_linearMotorDirection = Vector3.Zero; | 292 | m_linearMotorDirection = Vector3.Zero; |
295 | m_linearMotorTimescale = 0; | 293 | m_linearMotorTimescale = 0; |
296 | m_linearMotorDecayTimescale = 0; | 294 | m_linearMotorDecayTimescale = 0; |
295 | m_linearFrictionTimescale = new Vector3(0, 0, 0); | ||
296 | |||
297 | m_angularMotorDirection = Vector3.Zero; | 297 | m_angularMotorDirection = Vector3.Zero; |
298 | m_angularMotorTimescale = 0; | ||
299 | m_angularMotorDecayTimescale = 0; | 298 | m_angularMotorDecayTimescale = 0; |
299 | m_angularMotorTimescale = 0; | ||
300 | m_angularFrictionTimescale = new Vector3(0, 0, 0); | ||
301 | |||
300 | m_VhoverHeight = 0; | 302 | m_VhoverHeight = 0; |
303 | m_VhoverEfficiency = 0; | ||
301 | m_VhoverTimescale = 0; | 304 | m_VhoverTimescale = 0; |
302 | m_VehicleBuoyancy = 0; | 305 | m_VehicleBuoyancy = 0; |
306 | |||
307 | m_linearDeflectionEfficiency = 1; | ||
308 | m_linearDeflectionTimescale = 1; | ||
309 | |||
310 | m_angularDeflectionEfficiency = 0; | ||
311 | m_angularDeflectionTimescale = 1000; | ||
312 | |||
313 | m_verticalAttractionEfficiency = 0; | ||
314 | m_verticalAttractionTimescale = 0; | ||
315 | |||
316 | m_bankingEfficiency = 0; | ||
317 | m_bankingTimescale = 1000; | ||
318 | m_bankingMix = 1; | ||
319 | |||
320 | m_referenceFrame = Quaternion.Identity; | ||
303 | m_flags = (VehicleFlag)0; | 321 | m_flags = (VehicleFlag)0; |
304 | break; | 322 | break; |
305 | 323 | ||
306 | case Vehicle.TYPE_SLED: | 324 | case Vehicle.TYPE_SLED: |
307 | m_linearFrictionTimescale = new Vector3(30, 1, 1000); | ||
308 | m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); | ||
309 | m_linearMotorDirection = Vector3.Zero; | 325 | m_linearMotorDirection = Vector3.Zero; |
310 | m_linearMotorTimescale = 1000; | 326 | m_linearMotorTimescale = 1000; |
311 | m_linearMotorDecayTimescale = 120; | 327 | m_linearMotorDecayTimescale = 120; |
328 | m_linearFrictionTimescale = new Vector3(30, 1, 1000); | ||
329 | |||
312 | m_angularMotorDirection = Vector3.Zero; | 330 | m_angularMotorDirection = Vector3.Zero; |
313 | m_angularMotorTimescale = 1000; | 331 | m_angularMotorTimescale = 1000; |
314 | m_angularMotorDecayTimescale = 120; | 332 | m_angularMotorDecayTimescale = 120; |
333 | m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); | ||
334 | |||
315 | m_VhoverHeight = 0; | 335 | m_VhoverHeight = 0; |
316 | // m_VhoverEfficiency = 1; | 336 | m_VhoverEfficiency = 10; // TODO: this looks wrong!! |
317 | m_VhoverTimescale = 10; | 337 | m_VhoverTimescale = 10; |
318 | m_VehicleBuoyancy = 0; | 338 | m_VehicleBuoyancy = 0; |
319 | // m_linearDeflectionEfficiency = 1; | 339 | |
320 | // m_linearDeflectionTimescale = 1; | 340 | m_linearDeflectionEfficiency = 1; |
321 | // m_angularDeflectionEfficiency = 1; | 341 | m_linearDeflectionTimescale = 1; |
322 | // m_angularDeflectionTimescale = 1000; | 342 | |
323 | // m_bankingEfficiency = 0; | 343 | m_angularDeflectionEfficiency = 1; |
324 | // m_bankingMix = 1; | 344 | m_angularDeflectionTimescale = 1000; |
325 | // m_bankingTimescale = 10; | 345 | |
326 | // m_referenceFrame = Quaternion.Identity; | 346 | m_verticalAttractionEfficiency = 0; |
347 | m_verticalAttractionTimescale = 0; | ||
348 | |||
349 | m_bankingEfficiency = 0; | ||
350 | m_bankingTimescale = 10; | ||
351 | m_bankingMix = 1; | ||
352 | |||
353 | m_referenceFrame = Quaternion.Identity; | ||
327 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); | 354 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | VehicleFlag.LIMIT_ROLL_ONLY | VehicleFlag.LIMIT_MOTOR_UP); |
328 | m_flags &= | 355 | m_flags &= |
329 | ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | | 356 | ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | |
330 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); | 357 | VehicleFlag.HOVER_GLOBAL_HEIGHT | VehicleFlag.HOVER_UP_ONLY); |
331 | break; | 358 | break; |
332 | case Vehicle.TYPE_CAR: | 359 | case Vehicle.TYPE_CAR: |
333 | m_linearFrictionTimescale = new Vector3(100, 2, 1000); | ||
334 | m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); | ||
335 | m_linearMotorDirection = Vector3.Zero; | 360 | m_linearMotorDirection = Vector3.Zero; |
336 | m_linearMotorTimescale = 1; | 361 | m_linearMotorTimescale = 1; |
337 | m_linearMotorDecayTimescale = 60; | 362 | m_linearMotorDecayTimescale = 60; |
363 | m_linearFrictionTimescale = new Vector3(100, 2, 1000); | ||
364 | |||
338 | m_angularMotorDirection = Vector3.Zero; | 365 | m_angularMotorDirection = Vector3.Zero; |
339 | m_angularMotorTimescale = 1; | 366 | m_angularMotorTimescale = 1; |
340 | m_angularMotorDecayTimescale = 0.8f; | 367 | m_angularMotorDecayTimescale = 0.8f; |
368 | m_angularFrictionTimescale = new Vector3(1000, 1000, 1000); | ||
369 | |||
341 | m_VhoverHeight = 0; | 370 | m_VhoverHeight = 0; |
342 | // m_VhoverEfficiency = 0; | 371 | m_VhoverEfficiency = 0; |
343 | m_VhoverTimescale = 1000; | 372 | m_VhoverTimescale = 1000; |
344 | m_VehicleBuoyancy = 0; | 373 | m_VehicleBuoyancy = 0; |
345 | // // m_linearDeflectionEfficiency = 1; | 374 | |
346 | // // m_linearDeflectionTimescale = 2; | 375 | m_linearDeflectionEfficiency = 1; |
347 | // // m_angularDeflectionEfficiency = 0; | 376 | m_linearDeflectionTimescale = 2; |
348 | // m_angularDeflectionTimescale = 10; | 377 | |
378 | m_angularDeflectionEfficiency = 0; | ||
379 | m_angularDeflectionTimescale = 10; | ||
380 | |||
349 | m_verticalAttractionEfficiency = 1f; | 381 | m_verticalAttractionEfficiency = 1f; |
350 | m_verticalAttractionTimescale = 10f; | 382 | m_verticalAttractionTimescale = 10f; |
351 | // m_bankingEfficiency = -0.2f; | 383 | |
352 | // m_bankingMix = 1; | 384 | m_bankingEfficiency = -0.2f; |
353 | // m_bankingTimescale = 1; | 385 | m_bankingMix = 1; |
354 | // m_referenceFrame = Quaternion.Identity; | 386 | m_bankingTimescale = 1; |
355 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | 387 | |
388 | m_referenceFrame = Quaternion.Identity; | ||
389 | m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | ||
390 | | VehicleFlag.HOVER_TERRAIN_ONLY | ||
391 | | VehicleFlag.HOVER_GLOBAL_HEIGHT); | ||
392 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | ||
356 | | VehicleFlag.LIMIT_ROLL_ONLY | 393 | | VehicleFlag.LIMIT_ROLL_ONLY |
357 | | VehicleFlag.LIMIT_MOTOR_UP); | 394 | | VehicleFlag.LIMIT_MOTOR_UP |
358 | m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT); | 395 | | VehicleFlag.HOVER_UP_ONLY); |
359 | m_flags |= (VehicleFlag.HOVER_UP_ONLY); | ||
360 | break; | 396 | break; |
361 | case Vehicle.TYPE_BOAT: | 397 | case Vehicle.TYPE_BOAT: |
362 | m_linearFrictionTimescale = new Vector3(10, 3, 2); | ||
363 | m_angularFrictionTimescale = new Vector3(10,10,10); | ||
364 | m_linearMotorDirection = Vector3.Zero; | 398 | m_linearMotorDirection = Vector3.Zero; |
365 | m_linearMotorTimescale = 5; | 399 | m_linearMotorTimescale = 5; |
366 | m_linearMotorDecayTimescale = 60; | 400 | m_linearMotorDecayTimescale = 60; |
401 | m_linearFrictionTimescale = new Vector3(10, 3, 2); | ||
402 | |||
367 | m_angularMotorDirection = Vector3.Zero; | 403 | m_angularMotorDirection = Vector3.Zero; |
368 | m_angularMotorTimescale = 4; | 404 | m_angularMotorTimescale = 4; |
369 | m_angularMotorDecayTimescale = 4; | 405 | m_angularMotorDecayTimescale = 4; |
406 | m_angularFrictionTimescale = new Vector3(10,10,10); | ||
407 | |||
370 | m_VhoverHeight = 0; | 408 | m_VhoverHeight = 0; |
371 | // m_VhoverEfficiency = 0.5f; | 409 | m_VhoverEfficiency = 0.5f; |
372 | m_VhoverTimescale = 2; | 410 | m_VhoverTimescale = 2; |
373 | m_VehicleBuoyancy = 1; | 411 | m_VehicleBuoyancy = 1; |
374 | // m_linearDeflectionEfficiency = 0.5f; | 412 | |
375 | // m_linearDeflectionTimescale = 3; | 413 | m_linearDeflectionEfficiency = 0.5f; |
376 | // m_angularDeflectionEfficiency = 0.5f; | 414 | m_linearDeflectionTimescale = 3; |
377 | // m_angularDeflectionTimescale = 5; | 415 | |
416 | m_angularDeflectionEfficiency = 0.5f; | ||
417 | m_angularDeflectionTimescale = 5; | ||
418 | |||
378 | m_verticalAttractionEfficiency = 0.5f; | 419 | m_verticalAttractionEfficiency = 0.5f; |
379 | m_verticalAttractionTimescale = 5f; | 420 | m_verticalAttractionTimescale = 5f; |
380 | // m_bankingEfficiency = -0.3f; | 421 | |
381 | // m_bankingMix = 0.8f; | 422 | m_bankingEfficiency = -0.3f; |
382 | // m_bankingTimescale = 1; | 423 | m_bankingMix = 0.8f; |
383 | // m_referenceFrame = Quaternion.Identity; | 424 | m_bankingTimescale = 1; |
425 | |||
426 | m_referenceFrame = Quaternion.Identity; | ||
384 | m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY | 427 | m_flags &= ~(VehicleFlag.HOVER_TERRAIN_ONLY |
385 | | VehicleFlag.HOVER_GLOBAL_HEIGHT | 428 | | VehicleFlag.HOVER_GLOBAL_HEIGHT |
386 | | VehicleFlag.LIMIT_ROLL_ONLY | 429 | | VehicleFlag.LIMIT_ROLL_ONLY |
387 | | VehicleFlag.HOVER_UP_ONLY); | 430 | | VehicleFlag.HOVER_UP_ONLY); |
388 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP | 431 | m_flags |= (VehicleFlag.NO_DEFLECTION_UP |
@@ -390,28 +433,35 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
390 | | VehicleFlag.HOVER_WATER_ONLY); | 433 | | VehicleFlag.HOVER_WATER_ONLY); |
391 | break; | 434 | break; |
392 | case Vehicle.TYPE_AIRPLANE: | 435 | case Vehicle.TYPE_AIRPLANE: |
393 | m_linearFrictionTimescale = new Vector3(200, 10, 5); | ||
394 | m_angularFrictionTimescale = new Vector3(20, 20, 20); | ||
395 | m_linearMotorDirection = Vector3.Zero; | 436 | m_linearMotorDirection = Vector3.Zero; |
396 | m_linearMotorTimescale = 2; | 437 | m_linearMotorTimescale = 2; |
397 | m_linearMotorDecayTimescale = 60; | 438 | m_linearMotorDecayTimescale = 60; |
439 | m_linearFrictionTimescale = new Vector3(200, 10, 5); | ||
440 | |||
398 | m_angularMotorDirection = Vector3.Zero; | 441 | m_angularMotorDirection = Vector3.Zero; |
399 | m_angularMotorTimescale = 4; | 442 | m_angularMotorTimescale = 4; |
400 | m_angularMotorDecayTimescale = 4; | 443 | m_angularMotorDecayTimescale = 4; |
444 | m_angularFrictionTimescale = new Vector3(20, 20, 20); | ||
445 | |||
401 | m_VhoverHeight = 0; | 446 | m_VhoverHeight = 0; |
402 | // m_VhoverEfficiency = 0.5f; | 447 | m_VhoverEfficiency = 0.5f; |
403 | m_VhoverTimescale = 1000; | 448 | m_VhoverTimescale = 1000; |
404 | m_VehicleBuoyancy = 0; | 449 | m_VehicleBuoyancy = 0; |
405 | // m_linearDeflectionEfficiency = 0.5f; | 450 | |
406 | // m_linearDeflectionTimescale = 3; | 451 | m_linearDeflectionEfficiency = 0.5f; |
407 | // m_angularDeflectionEfficiency = 1; | 452 | m_linearDeflectionTimescale = 3; |
408 | // m_angularDeflectionTimescale = 2; | 453 | |
454 | m_angularDeflectionEfficiency = 1; | ||
455 | m_angularDeflectionTimescale = 2; | ||
456 | |||
409 | m_verticalAttractionEfficiency = 0.9f; | 457 | m_verticalAttractionEfficiency = 0.9f; |
410 | m_verticalAttractionTimescale = 2f; | 458 | m_verticalAttractionTimescale = 2f; |
411 | // m_bankingEfficiency = 1; | 459 | |
412 | // m_bankingMix = 0.7f; | 460 | m_bankingEfficiency = 1; |
413 | // m_bankingTimescale = 2; | 461 | m_bankingMix = 0.7f; |
414 | // m_referenceFrame = Quaternion.Identity; | 462 | m_bankingTimescale = 2; |
463 | |||
464 | m_referenceFrame = Quaternion.Identity; | ||
415 | m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | 465 | m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY |
416 | | VehicleFlag.HOVER_TERRAIN_ONLY | 466 | | VehicleFlag.HOVER_TERRAIN_ONLY |
417 | | VehicleFlag.HOVER_GLOBAL_HEIGHT | 467 | | VehicleFlag.HOVER_GLOBAL_HEIGHT |
@@ -421,28 +471,36 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
421 | m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); | 471 | m_flags |= (VehicleFlag.LIMIT_ROLL_ONLY); |
422 | break; | 472 | break; |
423 | case Vehicle.TYPE_BALLOON: | 473 | case Vehicle.TYPE_BALLOON: |
424 | m_linearFrictionTimescale = new Vector3(5, 5, 5); | ||
425 | m_angularFrictionTimescale = new Vector3(10, 10, 10); | ||
426 | m_linearMotorDirection = Vector3.Zero; | 474 | m_linearMotorDirection = Vector3.Zero; |
427 | m_linearMotorTimescale = 5; | 475 | m_linearMotorTimescale = 5; |
476 | m_linearFrictionTimescale = new Vector3(5, 5, 5); | ||
428 | m_linearMotorDecayTimescale = 60; | 477 | m_linearMotorDecayTimescale = 60; |
478 | |||
429 | m_angularMotorDirection = Vector3.Zero; | 479 | m_angularMotorDirection = Vector3.Zero; |
430 | m_angularMotorTimescale = 6; | 480 | m_angularMotorTimescale = 6; |
481 | m_angularFrictionTimescale = new Vector3(10, 10, 10); | ||
431 | m_angularMotorDecayTimescale = 10; | 482 | m_angularMotorDecayTimescale = 10; |
483 | |||
432 | m_VhoverHeight = 5; | 484 | m_VhoverHeight = 5; |
433 | // m_VhoverEfficiency = 0.8f; | 485 | m_VhoverEfficiency = 0.8f; |
434 | m_VhoverTimescale = 10; | 486 | m_VhoverTimescale = 10; |
435 | m_VehicleBuoyancy = 1; | 487 | m_VehicleBuoyancy = 1; |
436 | // m_linearDeflectionEfficiency = 0; | 488 | |
437 | // m_linearDeflectionTimescale = 5; | 489 | m_linearDeflectionEfficiency = 0; |
438 | // m_angularDeflectionEfficiency = 0; | 490 | m_linearDeflectionTimescale = 5; |
439 | // m_angularDeflectionTimescale = 5; | 491 | |
492 | m_angularDeflectionEfficiency = 0; | ||
493 | m_angularDeflectionTimescale = 5; | ||
494 | |||
440 | m_verticalAttractionEfficiency = 1f; | 495 | m_verticalAttractionEfficiency = 1f; |
441 | m_verticalAttractionTimescale = 100f; | 496 | m_verticalAttractionTimescale = 100f; |
442 | // m_bankingEfficiency = 0; | 497 | |
443 | // m_bankingMix = 0.7f; | 498 | m_bankingEfficiency = 0; |
444 | // m_bankingTimescale = 5; | 499 | m_bankingMix = 0.7f; |
445 | // m_referenceFrame = Quaternion.Identity; | 500 | m_bankingTimescale = 5; |
501 | m_referenceFrame = Quaternion.Identity; | ||
502 | |||
503 | m_referenceFrame = Quaternion.Identity; | ||
446 | m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY | 504 | m_flags &= ~(VehicleFlag.HOVER_WATER_ONLY |
447 | | VehicleFlag.HOVER_TERRAIN_ONLY | 505 | | VehicleFlag.HOVER_TERRAIN_ONLY |
448 | | VehicleFlag.HOVER_UP_ONLY | 506 | | VehicleFlag.HOVER_UP_ONLY |
@@ -452,20 +510,40 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
452 | | VehicleFlag.HOVER_GLOBAL_HEIGHT); | 510 | | VehicleFlag.HOVER_GLOBAL_HEIGHT); |
453 | break; | 511 | break; |
454 | } | 512 | } |
455 | }//end SetDefaultsForType | 513 | } |
456 | 514 | ||
457 | // Some of the properties of this prim may have changed. | 515 | // Some of the properties of this prim may have changed. |
458 | // Do any updating needed for a vehicle | 516 | // Do any updating needed for a vehicle |
459 | public void Refresh() | 517 | public void Refresh() |
460 | { | 518 | { |
461 | if (!IsActive) | 519 | if (IsActive) |
462 | return; | 520 | { |
521 | // Friction effects are handled by this vehicle code | ||
522 | BulletSimAPI.SetFriction2(Prim.PhysBody.ptr, 0f); | ||
523 | BulletSimAPI.SetHitFraction2(Prim.PhysBody.ptr, 0f); | ||
524 | |||
525 | // BulletSimAPI.SetAngularDamping2(Prim.PhysBody.ptr, 0.8f); | ||
463 | 526 | ||
464 | // Set the prim's inertia to zero. The vehicle code handles that and this | 527 | VDetailLog("{0},BSDynamics.Refresh,zeroingFriction and adding damping", Prim.LocalID); |
465 | // removes the motion and torque actions introduced by Bullet. | 528 | } |
466 | Vector3 inertia = Vector3.Zero; | 529 | } |
467 | BulletSimAPI.SetMassProps2(Prim.BSBody.ptr, Prim.MassRaw, inertia); | 530 | |
468 | BulletSimAPI.UpdateInertiaTensor2(Prim.BSBody.ptr); | 531 | public bool RemoveBodyDependencies(BSPhysObject prim) |
532 | { | ||
533 | // If active, we need to add our properties back when the body is rebuilt. | ||
534 | return IsActive; | ||
535 | } | ||
536 | |||
537 | public void RestoreBodyDependencies(BSPhysObject prim) | ||
538 | { | ||
539 | if (Prim.LocalID != prim.LocalID) | ||
540 | { | ||
541 | // The call should be on us by our prim. Error if not. | ||
542 | PhysicsScene.Logger.ErrorFormat("{0} RestoreBodyDependencies: called by not my prim. passedLocalID={1}, vehiclePrimLocalID={2}", | ||
543 | LogHeader, prim.LocalID, Prim.LocalID); | ||
544 | return; | ||
545 | } | ||
546 | Refresh(); | ||
469 | } | 547 | } |
470 | 548 | ||
471 | // One step of the vehicle properties for the next 'pTimestep' seconds. | 549 | // One step of the vehicle properties for the next 'pTimestep' seconds. |
@@ -473,13 +551,35 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
473 | { | 551 | { |
474 | if (!IsActive) return; | 552 | if (!IsActive) return; |
475 | 553 | ||
554 | // DEBUG | ||
555 | // Because Bullet does apply forces to the vehicle, our last computed | ||
556 | // linear and angular velocities are not what is happening now. | ||
557 | // Vector3 externalAngularVelocity = Prim.ForceRotationalVelocity - m_lastAngularVelocity; | ||
558 | // m_lastAngularVelocity += (externalAngularVelocity * 0.5f) * pTimestep; | ||
559 | // m_lastAngularVelocity = Prim.ForceRotationalVelocity; // DEBUG: account for what Bullet did last time | ||
560 | // m_lastLinearVelocityVector = Prim.ForceVelocity * Quaternion.Inverse(Prim.ForceOrientation); // DEBUG: | ||
561 | // END DEBUG | ||
562 | |||
563 | m_vehicleMass = Prim.Linkset.LinksetMass; | ||
564 | |||
476 | MoveLinear(pTimestep); | 565 | MoveLinear(pTimestep); |
566 | // Commented out for debug | ||
477 | MoveAngular(pTimestep); | 567 | MoveAngular(pTimestep); |
568 | // Prim.ApplyTorqueImpulse(-Prim.RotationalVelocity * m_vehicleMass, false); // DEBUG DEBUG | ||
569 | // Prim.ForceRotationalVelocity = -Prim.RotationalVelocity; // DEBUG DEBUG | ||
570 | |||
478 | LimitRotation(pTimestep); | 571 | LimitRotation(pTimestep); |
479 | 572 | ||
480 | // remember the position so next step we can limit absolute movement effects | 573 | // remember the position so next step we can limit absolute movement effects |
481 | m_lastPositionVector = Prim.ForcePosition; | 574 | m_lastPositionVector = Prim.ForcePosition; |
482 | 575 | ||
576 | VDetailLog("{0},BSDynamics.Step,frict={1},grav={2},inertia={3},mass={4}", // DEBUG DEBUG | ||
577 | Prim.LocalID, | ||
578 | BulletSimAPI.GetFriction2(Prim.PhysBody.ptr), | ||
579 | BulletSimAPI.GetGravity2(Prim.PhysBody.ptr), | ||
580 | Prim.Inertia, | ||
581 | m_vehicleMass | ||
582 | ); | ||
483 | VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", | 583 | VDetailLog("{0},BSDynamics.Step,done,pos={1},force={2},velocity={3},angvel={4}", |
484 | Prim.LocalID, Prim.ForcePosition, Prim.Force, Prim.ForceVelocity, Prim.RotationalVelocity); | 584 | Prim.LocalID, Prim.ForcePosition, Prim.Force, Prim.ForceVelocity, Prim.RotationalVelocity); |
485 | }// end Step | 585 | }// end Step |
@@ -488,62 +588,52 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
488 | // Also does hover and float. | 588 | // Also does hover and float. |
489 | private void MoveLinear(float pTimestep) | 589 | private void MoveLinear(float pTimestep) |
490 | { | 590 | { |
491 | // m_linearMotorDirection is the direction we are moving relative to the vehicle coordinates | 591 | // m_linearMotorDirection is the target direction we are moving relative to the vehicle coordinates |
492 | // m_lastLinearVelocityVector is the speed we are moving in that direction | 592 | // m_lastLinearVelocityVector is the current speed we are moving in that direction |
493 | if (m_linearMotorDirection.LengthSquared() > 0.001f) | 593 | if (m_linearMotorDirection.LengthSquared() > 0.001f) |
494 | { | 594 | { |
495 | Vector3 origDir = m_linearMotorDirection; | 595 | Vector3 origDir = m_linearMotorDirection; // DEBUG |
496 | Vector3 origVel = m_lastLinearVelocityVector; | 596 | Vector3 origVel = m_lastLinearVelocityVector; // DEBUG |
497 | 597 | // DEBUG: the vehicle velocity rotated to be relative to vehicle coordinates for comparison | |
498 | // add drive to body | 598 | Vector3 vehicleVelocity = Prim.ForceVelocity * Quaternion.Inverse(Prim.ForceOrientation); // DEBUG |
499 | // Vector3 addAmount = m_linearMotorDirection/(m_linearMotorTimescale / pTimestep); | 599 | |
500 | Vector3 addAmount = (m_linearMotorDirection - m_lastLinearVelocityVector)/(m_linearMotorTimescale / pTimestep); | 600 | // Add (desiredVelocity - lastAppliedVelocity) / howLongItShouldTakeToComplete |
501 | // lastLinearVelocityVector is the current body velocity vector | 601 | Vector3 addAmount = (m_linearMotorDirection - m_lastLinearVelocityVector)/(m_linearMotorTimescale) * pTimestep; |
502 | // RA: Not sure what the *10 is for. A correction for pTimestep? | ||
503 | // m_lastLinearVelocityVector += (addAmount*10); | ||
504 | m_lastLinearVelocityVector += addAmount; | 602 | m_lastLinearVelocityVector += addAmount; |
505 | 603 | ||
506 | // Limit the velocity vector to less than the last set linear motor direction | 604 | float decayFactor = (1.0f / m_linearMotorDecayTimescale) * pTimestep; |
507 | if (Math.Abs(m_lastLinearVelocityVector.X) > Math.Abs(m_linearMotorDirectionLASTSET.X)) | 605 | m_linearMotorDirection *= (1f - decayFactor); |
508 | m_lastLinearVelocityVector.X = m_linearMotorDirectionLASTSET.X; | 606 | |
509 | if (Math.Abs(m_lastLinearVelocityVector.Y) > Math.Abs(m_linearMotorDirectionLASTSET.Y)) | 607 | // Rotate new object velocity from vehicle relative to world coordinates |
510 | m_lastLinearVelocityVector.Y = m_linearMotorDirectionLASTSET.Y; | 608 | m_newVelocity = m_lastLinearVelocityVector * Prim.ForceOrientation; |
511 | if (Math.Abs(m_lastLinearVelocityVector.Z) > Math.Abs(m_linearMotorDirectionLASTSET.Z)) | 609 | |
512 | m_lastLinearVelocityVector.Z = m_linearMotorDirectionLASTSET.Z; | 610 | // Apply friction for next time |
513 | 611 | Vector3 frictionFactor = (Vector3.One / m_linearFrictionTimescale) * pTimestep; | |
514 | /* | 612 | m_lastLinearVelocityVector *= (Vector3.One - frictionFactor); |
515 | // decay applied velocity | 613 | |
516 | Vector3 decayfraction = Vector3.One/(m_linearMotorDecayTimescale / pTimestep); | 614 | VDetailLog("{0},MoveLinear,nonZero,origlmDir={1},origlvVel={2},vehVel={3},add={4},decay={5},frict={6},lmDir={7},lvVec={8},newVel={9}", |
517 | // (RA: do not know where the 0.5f comes from) | 615 | Prim.LocalID, origDir, origVel, vehicleVelocity, addAmount, decayFactor, frictionFactor, |
518 | m_linearMotorDirection -= m_linearMotorDirection * decayfraction * 0.5f; | 616 | m_linearMotorDirection, m_lastLinearVelocityVector, m_newVelocity); |
519 | */ | ||
520 | float keepfraction = 1.0f - (1.0f / (m_linearMotorDecayTimescale / pTimestep)); | ||
521 | m_linearMotorDirection *= keepfraction; | ||
522 | |||
523 | VDetailLog("{0},MoveLinear,nonZero,origdir={1},origvel={2},add={3},notDecay={4},dir={5},vel={6}", | ||
524 | Prim.LocalID, origDir, origVel, addAmount, keepfraction, m_linearMotorDirection, m_lastLinearVelocityVector); | ||
525 | } | 617 | } |
526 | else | 618 | else |
527 | { | 619 | { |
528 | // if what remains of direction is very small, zero it. | 620 | // if what remains of direction is very small, zero it. |
529 | m_linearMotorDirection = Vector3.Zero; | 621 | m_linearMotorDirection = Vector3.Zero; |
530 | m_lastLinearVelocityVector = Vector3.Zero; | 622 | m_lastLinearVelocityVector = Vector3.Zero; |
623 | m_newVelocity = Vector3.Zero; | ||
624 | |||
531 | VDetailLog("{0},MoveLinear,zeroed", Prim.LocalID); | 625 | VDetailLog("{0},MoveLinear,zeroed", Prim.LocalID); |
532 | } | 626 | } |
533 | 627 | ||
534 | // convert requested object velocity to object relative vector | 628 | // m_newVelocity is velocity computed from linear motor in world coordinates |
535 | Quaternion rotq = Prim.ForceOrientation; | ||
536 | m_newVelocity = m_lastLinearVelocityVector * rotq; | ||
537 | |||
538 | // Add the various forces into m_dir which will be our new direction vector (velocity) | ||
539 | 629 | ||
540 | // add Gravity and Buoyancy | 630 | // Gravity and Buoyancy |
541 | // There is some gravity, make a gravity force vector that is applied after object velocity. | 631 | // There is some gravity, make a gravity force vector that is applied after object velocity. |
542 | // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g; | 632 | // m_VehicleBuoyancy: -1=2g; 0=1g; 1=0g; |
543 | Vector3 grav = Prim.PhysicsScene.DefaultGravity * (Prim.Linkset.LinksetMass * (1f - m_VehicleBuoyancy)); | 633 | Vector3 grav = Prim.PhysicsScene.DefaultGravity * (1f - m_VehicleBuoyancy); |
544 | 634 | ||
545 | /* | 635 | /* |
546 | * RA: Not sure why one would do this | 636 | * RA: Not sure why one would do this unless we are hoping external forces are doing gravity, ... |
547 | // Preserve the current Z velocity | 637 | // Preserve the current Z velocity |
548 | Vector3 vel_now = m_prim.Velocity; | 638 | Vector3 vel_now = m_prim.Velocity; |
549 | m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity | 639 | m_dir.Z = vel_now.Z; // Preserve the accumulated falling velocity |
@@ -555,7 +645,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
555 | // If below the terrain, move us above the ground a little. | 645 | // If below the terrain, move us above the ground a little. |
556 | float terrainHeight = Prim.PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos); | 646 | float terrainHeight = Prim.PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(pos); |
557 | // Taking the rotated size doesn't work here because m_prim.Size is the size of the root prim and not the linkset. | 647 | // Taking the rotated size doesn't work here because m_prim.Size is the size of the root prim and not the linkset. |
558 | // Need to add a m_prim.LinkSet.Size similar to m_prim.LinkSet.Mass. | 648 | // TODO: Add a m_prim.LinkSet.Size similar to m_prim.LinkSet.Mass. |
559 | // Vector3 rotatedSize = m_prim.Size * m_prim.ForceOrientation; | 649 | // Vector3 rotatedSize = m_prim.Size * m_prim.ForceOrientation; |
560 | // if (rotatedSize.Z < terrainHeight) | 650 | // if (rotatedSize.Z < terrainHeight) |
561 | if (pos.Z < terrainHeight) | 651 | if (pos.Z < terrainHeight) |
@@ -566,6 +656,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
566 | } | 656 | } |
567 | 657 | ||
568 | // Check if hovering | 658 | // Check if hovering |
659 | // m_VhoverEfficiency: 0=bouncy, 1=totally damped | ||
660 | // m_VhoverTimescale: time to achieve height | ||
569 | if ((m_flags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0) | 661 | if ((m_flags & (VehicleFlag.HOVER_WATER_ONLY | VehicleFlag.HOVER_TERRAIN_ONLY | VehicleFlag.HOVER_GLOBAL_HEIGHT)) != 0) |
570 | { | 662 | { |
571 | // We should hover, get the target height | 663 | // We should hover, get the target height |
@@ -584,25 +676,33 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
584 | 676 | ||
585 | if ((m_flags & VehicleFlag.HOVER_UP_ONLY) != 0) | 677 | if ((m_flags & VehicleFlag.HOVER_UP_ONLY) != 0) |
586 | { | 678 | { |
587 | // If body is aready heigher, use its height as target height | 679 | // If body is already heigher, use its height as target height |
588 | if (pos.Z > m_VhoverTargetHeight) m_VhoverTargetHeight = pos.Z; | 680 | if (pos.Z > m_VhoverTargetHeight) |
681 | m_VhoverTargetHeight = pos.Z; | ||
589 | } | 682 | } |
590 | if ((m_flags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0) | 683 | if ((m_flags & VehicleFlag.LOCK_HOVER_HEIGHT) != 0) |
591 | { | 684 | { |
592 | if ((pos.Z - m_VhoverTargetHeight) > .2 || (pos.Z - m_VhoverTargetHeight) < -.2) | 685 | if (Math.Abs(pos.Z - m_VhoverTargetHeight) > 0.2f) |
593 | { | 686 | { |
687 | pos.Z = m_VhoverTargetHeight; | ||
594 | Prim.ForcePosition = pos; | 688 | Prim.ForcePosition = pos; |
595 | } | 689 | } |
596 | } | 690 | } |
597 | else | 691 | else |
598 | { | 692 | { |
599 | float herr0 = pos.Z - m_VhoverTargetHeight; | 693 | float verticalError = pos.Z - m_VhoverTargetHeight; |
694 | // RA: where does the 50 come from? | ||
695 | float verticalCorrectionVelocity = pTimestep * ((verticalError * 50.0f) / m_VhoverTimescale); | ||
600 | // Replace Vertical speed with correction figure if significant | 696 | // Replace Vertical speed with correction figure if significant |
601 | if (Math.Abs(herr0) > 0.01f) | 697 | if (Math.Abs(verticalError) > 0.01f) |
602 | { | 698 | { |
603 | m_newVelocity.Z = -((herr0 * pTimestep * 50.0f) / m_VhoverTimescale); | 699 | m_newVelocity.Z += verticalCorrectionVelocity; |
604 | //KF: m_VhoverEfficiency is not yet implemented | 700 | //KF: m_VhoverEfficiency is not yet implemented |
605 | } | 701 | } |
702 | else if (verticalError < -0.01) | ||
703 | { | ||
704 | m_newVelocity.Z -= verticalCorrectionVelocity; | ||
705 | } | ||
606 | else | 706 | else |
607 | { | 707 | { |
608 | m_newVelocity.Z = 0f; | 708 | m_newVelocity.Z = 0f; |
@@ -649,25 +749,28 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
649 | } | 749 | } |
650 | } | 750 | } |
651 | 751 | ||
652 | // Limit absolute vertical change | 752 | #region downForce |
653 | float Zchange = Math.Abs(posChange.Z); | 753 | Vector3 downForce = Vector3.Zero; |
754 | |||
654 | if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0) | 755 | if ((m_flags & (VehicleFlag.LIMIT_MOTOR_UP)) != 0) |
655 | { | 756 | { |
656 | if (Zchange > .3) | 757 | // If the vehicle is motoring into the sky, get it going back down. |
657 | grav.Z = (float)(grav.Z * 3); | 758 | // Is this an angular force or both linear and angular?? |
658 | if (Zchange > .15) | 759 | float distanceAboveGround = pos.Z - terrainHeight; |
659 | grav.Z = (float)(grav.Z * 2); | 760 | if (distanceAboveGround > 2f) |
660 | if (Zchange > .75) | 761 | { |
661 | grav.Z = (float)(grav.Z * 1.5); | 762 | // downForce = new Vector3(0, 0, (-distanceAboveGround / m_bankingTimescale) * pTimestep); |
662 | if (Zchange > .05) | 763 | // downForce = new Vector3(0, 0, -distanceAboveGround / m_bankingTimescale); |
663 | grav.Z = (float)(grav.Z * 1.25); | 764 | downForce = new Vector3(0, 0, -distanceAboveGround); |
664 | if (Zchange > .025) | 765 | } |
665 | grav.Z = (float)(grav.Z * 1.125); | 766 | // TODO: this calculation is all wrong. From the description at |
666 | float postemp = (pos.Z - terrainHeight); | 767 | // (http://wiki.secondlife.com/wiki/Category:LSL_Vehicle), the downForce |
667 | if (postemp > 2.5f) | 768 | // has a decay factor. This says this force should |
668 | grav.Z = (float)(grav.Z * 1.037125); | 769 | // be computed with a motor. |
669 | VDetailLog("{0},MoveLinear,limitMotorUp,grav={1}", Prim.LocalID, grav); | 770 | VDetailLog("{0},MoveLinear,limitMotorUp,distAbove={1},downForce={2}", |
771 | Prim.LocalID, distanceAboveGround, downForce); | ||
670 | } | 772 | } |
773 | #endregion // downForce | ||
671 | 774 | ||
672 | // If not changing some axis, reduce out velocity | 775 | // If not changing some axis, reduce out velocity |
673 | if ((m_flags & (VehicleFlag.NO_X)) != 0) | 776 | if ((m_flags & (VehicleFlag.NO_X)) != 0) |
@@ -677,21 +780,32 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
677 | if ((m_flags & (VehicleFlag.NO_Z)) != 0) | 780 | if ((m_flags & (VehicleFlag.NO_Z)) != 0) |
678 | m_newVelocity.Z = 0; | 781 | m_newVelocity.Z = 0; |
679 | 782 | ||
680 | // Apply velocity | 783 | // Clamp REALLY high or low velocities |
784 | if (m_newVelocity.LengthSquared() > 1e6f) | ||
785 | { | ||
786 | m_newVelocity /= m_newVelocity.Length(); | ||
787 | m_newVelocity *= 1000f; | ||
788 | } | ||
789 | else if (m_newVelocity.LengthSquared() < 1e-6f) | ||
790 | m_newVelocity = Vector3.Zero; | ||
791 | |||
792 | // Stuff new linear velocity into the vehicle | ||
681 | Prim.ForceVelocity = m_newVelocity; | 793 | Prim.ForceVelocity = m_newVelocity; |
682 | // apply gravity force | 794 | // Prim.ApplyForceImpulse((m_newVelocity - Prim.Velocity) * m_vehicleMass, false); // DEBUG DEBUG |
683 | // Why is this set here? The physics engine already does gravity. | ||
684 | Prim.AddForce(grav, false, true); | ||
685 | 795 | ||
686 | // Apply friction | 796 | Vector3 totalDownForce = downForce + grav; |
687 | Vector3 keepFraction = Vector3.One - (Vector3.One / (m_linearFrictionTimescale / pTimestep)); | 797 | if (totalDownForce != Vector3.Zero) |
688 | m_lastLinearVelocityVector *= keepFraction; | 798 | { |
799 | Prim.AddForce(totalDownForce * m_vehicleMass, false); | ||
800 | // Prim.ApplyForceImpulse(totalDownForce * m_vehicleMass, false); | ||
801 | } | ||
689 | 802 | ||
690 | VDetailLog("{0},MoveLinear,done,lmDir={1},lmVel={2},newVel={3},grav={4},1Mdecay={5}", | 803 | VDetailLog("{0},MoveLinear,done,lmDir={1},lmVel={2},newVel={3},primVel={4},totalDown={5}", |
691 | Prim.LocalID, m_linearMotorDirection, m_lastLinearVelocityVector, m_newVelocity, grav, keepFraction); | 804 | Prim.LocalID, m_linearMotorDirection, m_lastLinearVelocityVector, m_newVelocity, Prim.Velocity, totalDownForce); |
692 | 805 | ||
693 | } // end MoveLinear() | 806 | } // end MoveLinear() |
694 | 807 | ||
808 | // ======================================================================= | ||
695 | // Apply the effect of the angular motor. | 809 | // Apply the effect of the angular motor. |
696 | private void MoveAngular(float pTimestep) | 810 | private void MoveAngular(float pTimestep) |
697 | { | 811 | { |
@@ -703,95 +817,191 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
703 | // m_angularFrictionTimescale // body angular velocity decay rate | 817 | // m_angularFrictionTimescale // body angular velocity decay rate |
704 | // m_lastAngularVelocity // what was last applied to body | 818 | // m_lastAngularVelocity // what was last applied to body |
705 | 819 | ||
706 | // Get what the body is doing, this includes 'external' influences | 820 | if (m_angularMotorDirection.LengthSquared() > 0.0001) |
707 | Vector3 angularVelocity = Prim.ForceRotationalVelocity; | ||
708 | |||
709 | if (m_angularMotorApply > 0) | ||
710 | { | 821 | { |
711 | // Rather than snapping the angular motor velocity from the old value to | ||
712 | // a newly set velocity, this routine steps the value from the previous | ||
713 | // value (m_angularMotorVelocity) to the requested value (m_angularMotorDirection). | ||
714 | // There are m_angularMotorApply steps. | ||
715 | Vector3 origVel = m_angularMotorVelocity; | 822 | Vector3 origVel = m_angularMotorVelocity; |
716 | Vector3 origDir = m_angularMotorDirection; | 823 | Vector3 origDir = m_angularMotorDirection; |
717 | 824 | ||
718 | // ramp up to new value | 825 | // new velocity += error / ( time to get there / step interval) |
719 | // new velocity += error / ( time to get there / step interval) | 826 | // requested direction - current vehicle direction |
720 | // requested speed - last motor speed | 827 | m_angularMotorVelocity += (m_angularMotorDirection - m_angularMotorVelocity) / (m_angularMotorTimescale / pTimestep); |
721 | m_angularMotorVelocity.X += (m_angularMotorDirection.X - m_angularMotorVelocity.X) / (m_angularMotorTimescale / pTimestep); | 828 | // decay requested direction |
722 | m_angularMotorVelocity.Y += (m_angularMotorDirection.Y - m_angularMotorVelocity.Y) / (m_angularMotorTimescale / pTimestep); | 829 | m_angularMotorDirection *= (1.0f - (pTimestep * 1.0f/m_angularMotorDecayTimescale)); |
723 | m_angularMotorVelocity.Z += (m_angularMotorDirection.Z - m_angularMotorVelocity.Z) / (m_angularMotorTimescale / pTimestep); | ||
724 | |||
725 | VDetailLog("{0},MoveAngular,angularMotorApply,apply={1},angTScale={2},timeStep={3},origvel={4},origDir={5},vel={6}", | ||
726 | Prim.LocalID, m_angularMotorApply, m_angularMotorTimescale, pTimestep, origVel, origDir, m_angularMotorVelocity); | ||
727 | 830 | ||
728 | m_angularMotorApply--; | 831 | VDetailLog("{0},MoveAngular,angularMotorApply,angTScale={1},timeStep={2},origvel={3},origDir={4},vel={5}", |
832 | Prim.LocalID, m_angularMotorTimescale, pTimestep, origVel, origDir, m_angularMotorVelocity); | ||
729 | } | 833 | } |
730 | else | 834 | else |
731 | { | 835 | { |
732 | // No motor recently applied, keep the body velocity | 836 | m_angularMotorVelocity = Vector3.Zero; |
733 | // and decay the velocity | 837 | } |
734 | m_angularMotorVelocity -= m_angularMotorVelocity / (m_angularMotorDecayTimescale / pTimestep); | 838 | |
735 | if (m_angularMotorVelocity.LengthSquared() < 0.00001) | 839 | #region Vertical attactor |
736 | m_angularMotorVelocity = Vector3.Zero; | 840 | |
737 | } // end motor section | ||
738 | |||
739 | // Vertical attractor section | ||
740 | Vector3 vertattr = Vector3.Zero; | 841 | Vector3 vertattr = Vector3.Zero; |
741 | Vector3 deflection = Vector3.Zero; | 842 | Vector3 deflection = Vector3.Zero; |
742 | Vector3 banking = Vector3.Zero; | 843 | Vector3 banking = Vector3.Zero; |
743 | 844 | ||
845 | // If vertical attaction timescale is reasonable and we applied an angular force last time... | ||
744 | if (m_verticalAttractionTimescale < 300 && m_lastAngularVelocity != Vector3.Zero) | 846 | if (m_verticalAttractionTimescale < 300 && m_lastAngularVelocity != Vector3.Zero) |
745 | { | 847 | { |
746 | float VAservo = 0.2f / (m_verticalAttractionTimescale / pTimestep); | 848 | float VAservo = pTimestep * 0.2f / m_verticalAttractionTimescale; |
747 | VAservo *= (m_verticalAttractionEfficiency * m_verticalAttractionEfficiency); | 849 | if (Prim.IsColliding) |
850 | VAservo = pTimestep * 0.05f / (m_verticalAttractionTimescale); | ||
748 | 851 | ||
749 | // get present body rotation | 852 | VAservo *= (m_verticalAttractionEfficiency * m_verticalAttractionEfficiency); |
750 | Quaternion rotq = Prim.ForceOrientation; | ||
751 | // vector pointing up | ||
752 | Vector3 verterr = Vector3.Zero; | ||
753 | verterr.Z = 1.0f; | ||
754 | 853 | ||
755 | // rotate it to Body Angle | 854 | // Create a vector of the vehicle "up" in world coordinates |
756 | verterr = verterr * rotq; | 855 | Vector3 verticalError = Vector3.UnitZ * Prim.ForceOrientation; |
757 | // verterr.X and .Y are the World error amounts. They are 0 when there is no error (Vehicle Body is 'vertical'), and .Z will be 1. | 856 | // verticalError.X and .Y are the World error amounts. They are 0 when there is no |
758 | // As the body leans to its side |.X| will increase to 1 and .Z fall to 0. As body inverts |.X| will fall and .Z will go | 857 | // error (Vehicle Body is 'vertical'), and .Z will be 1. As the body leans to its |
759 | // negative. Similar for tilt and |.Y|. .X and .Y must be modulated to prevent a stable inverted body. | 858 | // side |.X| will increase to 1 and .Z fall to 0. As body inverts |.X| will fall |
859 | // and .Z will go // negative. Similar for tilt and |.Y|. .X and .Y must be | ||
860 | // modulated to prevent a stable inverted body. | ||
760 | 861 | ||
761 | // Error is 0 (no error) to +/- 2 (max error) | 862 | // Error is 0 (no error) to +/- 2 (max error) |
762 | if (verterr.Z < 0.0f) | 863 | if (verticalError.Z < 0.0f) |
763 | { | 864 | { |
764 | verterr.X = 2.0f - verterr.X; | 865 | verticalError.X = 2.0f - verticalError.X; |
765 | verterr.Y = 2.0f - verterr.Y; | 866 | verticalError.Y = 2.0f - verticalError.Y; |
766 | } | 867 | } |
767 | // scale it by VAservo | 868 | // scale it by VAservo (timestep and timescale) |
768 | verterr = verterr * VAservo; | 869 | verticalError = verticalError * VAservo; |
769 | 870 | ||
770 | // As the body rotates around the X axis, then verterr.Y increases; Rotated around Y then .X increases, so | 871 | // As the body rotates around the X axis, then verticalError.Y increases; Rotated around Y |
771 | // Change Body angular velocity X based on Y, and Y based on X. Z is not changed. | 872 | // then .X increases, so change Body angular velocity X based on Y, and Y based on X. |
772 | vertattr.X = verterr.Y; | 873 | // Z is not changed. |
773 | vertattr.Y = - verterr.X; | 874 | vertattr.X = verticalError.Y; |
875 | vertattr.Y = - verticalError.X; | ||
774 | vertattr.Z = 0f; | 876 | vertattr.Z = 0f; |
775 | 877 | ||
776 | // scaling appears better usingsquare-law | 878 | // scaling appears better usingsquare-law |
879 | Vector3 angularVelocity = Prim.ForceRotationalVelocity; | ||
777 | float bounce = 1.0f - (m_verticalAttractionEfficiency * m_verticalAttractionEfficiency); | 880 | float bounce = 1.0f - (m_verticalAttractionEfficiency * m_verticalAttractionEfficiency); |
778 | vertattr.X += bounce * angularVelocity.X; | 881 | vertattr.X += bounce * angularVelocity.X; |
779 | vertattr.Y += bounce * angularVelocity.Y; | 882 | vertattr.Y += bounce * angularVelocity.Y; |
780 | 883 | ||
781 | VDetailLog("{0},MoveAngular,verticalAttraction,verterr={1},bounce={2},vertattr={3}", | 884 | VDetailLog("{0},MoveAngular,verticalAttraction,VAservo={1},effic={2},verticalError={3},bounce={4},vertattr={5}", |
782 | Prim.LocalID, verterr, bounce, vertattr); | 885 | Prim.LocalID, VAservo, m_verticalAttractionEfficiency, verticalError, bounce, vertattr); |
783 | 886 | ||
784 | } // else vertical attractor is off | 887 | } |
888 | #endregion // Vertical attactor | ||
785 | 889 | ||
786 | m_lastVertAttractor = vertattr; | 890 | #region Deflection |
891 | |||
892 | if (m_angularDeflectionEfficiency != 0) | ||
893 | { | ||
894 | // Compute a scaled vector that points in the preferred axis (X direction) | ||
895 | Vector3 scaledDefaultDirection = | ||
896 | new Vector3((pTimestep * 10 * (m_angularDeflectionEfficiency / m_angularDeflectionTimescale)), 0, 0); | ||
897 | // Adding the current vehicle orientation and reference frame displaces the orientation to the frame. | ||
898 | // Rotate the scaled default axix relative to the actual vehicle direction giving where it should point. | ||
899 | Vector3 preferredAxisOfMotion = scaledDefaultDirection * Quaternion.Add(Prim.ForceOrientation, m_referenceFrame); | ||
900 | |||
901 | // Scale by efficiency and timescale | ||
902 | deflection = (preferredAxisOfMotion * (m_angularDeflectionEfficiency) / m_angularDeflectionTimescale) * pTimestep; | ||
903 | |||
904 | VDetailLog("{0},MoveAngular,Deflection,perfAxis={1},deflection={2}", | ||
905 | Prim.LocalID, preferredAxisOfMotion, deflection); | ||
906 | // This deflection computation is not correct. | ||
907 | deflection = Vector3.Zero; | ||
908 | } | ||
787 | 909 | ||
788 | // Bank section tba | 910 | #endregion |
789 | 911 | ||
790 | // Deflection section tba | 912 | #region Banking |
913 | |||
914 | if (m_bankingEfficiency != 0) | ||
915 | { | ||
916 | Vector3 dir = Vector3.One * Prim.ForceOrientation; | ||
917 | float mult = (m_bankingMix*m_bankingMix)*-1*(m_bankingMix < 0 ? -1 : 1); | ||
918 | //Changes which way it banks in and out of turns | ||
919 | |||
920 | //Use the square of the efficiency, as it looks much more how SL banking works | ||
921 | float effSquared = (m_bankingEfficiency*m_bankingEfficiency); | ||
922 | if (m_bankingEfficiency < 0) | ||
923 | effSquared *= -1; //Keep the negative! | ||
924 | |||
925 | float mix = Math.Abs(m_bankingMix); | ||
926 | if (m_angularMotorVelocity.X == 0) | ||
927 | { | ||
928 | /*if (!parent.Orientation.ApproxEquals(this.m_referenceFrame, 0.25f)) | ||
929 | { | ||
930 | Vector3 axisAngle; | ||
931 | float angle; | ||
932 | parent.Orientation.GetAxisAngle(out axisAngle, out angle); | ||
933 | Vector3 rotatedVel = parent.Velocity * parent.Orientation; | ||
934 | if ((rotatedVel.X < 0 && axisAngle.Y > 0) || (rotatedVel.X > 0 && axisAngle.Y < 0)) | ||
935 | m_angularMotorVelocity.X += (effSquared * (mult * mix)) * (1f) * 10; | ||
936 | else | ||
937 | m_angularMotorVelocity.X += (effSquared * (mult * mix)) * (-1f) * 10; | ||
938 | }*/ | ||
939 | } | ||
940 | else | ||
941 | banking.Z += (effSquared*(mult*mix))*(m_angularMotorVelocity.X) * 4; | ||
942 | if (!Prim.IsColliding && Math.Abs(m_angularMotorVelocity.X) > mix) | ||
943 | //If they are colliding, we probably shouldn't shove the prim around... probably | ||
944 | { | ||
945 | float angVelZ = m_angularMotorVelocity.X*-1; | ||
946 | /*if(angVelZ > mix) | ||
947 | angVelZ = mix; | ||
948 | else if(angVelZ < -mix) | ||
949 | angVelZ = -mix;*/ | ||
950 | //This controls how fast and how far the banking occurs | ||
951 | Vector3 bankingRot = new Vector3(angVelZ*(effSquared*mult), 0, 0); | ||
952 | if (bankingRot.X > 3) | ||
953 | bankingRot.X = 3; | ||
954 | else if (bankingRot.X < -3) | ||
955 | bankingRot.X = -3; | ||
956 | bankingRot *= Prim.ForceOrientation; | ||
957 | banking += bankingRot; | ||
958 | } | ||
959 | m_angularMotorVelocity.X *= m_bankingEfficiency == 1 ? 0.0f : 1 - m_bankingEfficiency; | ||
960 | VDetailLog("{0},MoveAngular,Banking,bEff={1},angMotVel={2},banking={3}", | ||
961 | Prim.LocalID, m_bankingEfficiency, m_angularMotorVelocity, banking); | ||
962 | } | ||
963 | |||
964 | #endregion | ||
965 | |||
966 | m_lastVertAttractor = vertattr; | ||
791 | 967 | ||
792 | // Sum velocities | 968 | // Sum velocities |
793 | m_lastAngularVelocity = m_angularMotorVelocity + vertattr; // + bank + deflection | 969 | m_lastAngularVelocity = m_angularMotorVelocity + vertattr + banking + deflection; |
794 | 970 | ||
971 | #region Linear Motor Offset | ||
972 | |||
973 | //Offset section | ||
974 | if (m_linearMotorOffset != Vector3.Zero) | ||
975 | { | ||
976 | //Offset of linear velocity doesn't change the linear velocity, | ||
977 | // but causes a torque to be applied, for example... | ||
978 | // | ||
979 | // IIIII >>> IIIII | ||
980 | // IIIII >>> IIIII | ||
981 | // IIIII >>> IIIII | ||
982 | // ^ | ||
983 | // | Applying a force at the arrow will cause the object to move forward, but also rotate | ||
984 | // | ||
985 | // | ||
986 | // The torque created is the linear velocity crossed with the offset | ||
987 | |||
988 | // NOTE: this computation does should be in the linear section | ||
989 | // because there we know the impulse being applied. | ||
990 | Vector3 torqueFromOffset = Vector3.Zero; | ||
991 | // torqueFromOffset = Vector3.Cross(m_linearMotorOffset, appliedImpulse); | ||
992 | if (float.IsNaN(torqueFromOffset.X)) | ||
993 | torqueFromOffset.X = 0; | ||
994 | if (float.IsNaN(torqueFromOffset.Y)) | ||
995 | torqueFromOffset.Y = 0; | ||
996 | if (float.IsNaN(torqueFromOffset.Z)) | ||
997 | torqueFromOffset.Z = 0; | ||
998 | torqueFromOffset *= m_vehicleMass; | ||
999 | Prim.ApplyTorqueImpulse(torqueFromOffset, true); | ||
1000 | VDetailLog("{0},BSDynamic.MoveAngular,motorOffset,applyTorqueImpulse={1}", Prim.LocalID, torqueFromOffset); | ||
1001 | } | ||
1002 | |||
1003 | #endregion | ||
1004 | |||
795 | if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0) | 1005 | if ((m_flags & (VehicleFlag.NO_DEFLECTION_UP)) != 0) |
796 | { | 1006 | { |
797 | m_lastAngularVelocity.X = 0; | 1007 | m_lastAngularVelocity.X = 0; |
@@ -802,55 +1012,56 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
802 | if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) | 1012 | if (m_lastAngularVelocity.ApproxEquals(Vector3.Zero, 0.01f)) |
803 | { | 1013 | { |
804 | m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero. | 1014 | m_lastAngularVelocity = Vector3.Zero; // Reduce small value to zero. |
805 | VDetailLog("{0},MoveAngular,zeroSmallValues,lastAngular={1}", Prim.LocalID, m_lastAngularVelocity); | 1015 | Prim.ZeroAngularMotion(true); |
1016 | VDetailLog("{0},MoveAngular,zeroAngularMotion,lastAngular={1}", Prim.LocalID, m_lastAngularVelocity); | ||
1017 | } | ||
1018 | else | ||
1019 | { | ||
1020 | // Apply to the body. | ||
1021 | // The above calculates the absolute angular velocity needed. Angular velocity is massless. | ||
1022 | // Since we are stuffing the angular velocity directly into the object, the computed | ||
1023 | // velocity needs to be scaled by the timestep. | ||
1024 | Vector3 applyAngularForce = ((m_lastAngularVelocity * pTimestep) - Prim.ForceRotationalVelocity); | ||
1025 | Prim.ForceRotationalVelocity = applyAngularForce; | ||
1026 | |||
1027 | // Decay the angular movement for next time | ||
1028 | Vector3 decayamount = (Vector3.One / m_angularFrictionTimescale) * pTimestep; | ||
1029 | m_lastAngularVelocity *= Vector3.One - decayamount; | ||
1030 | |||
1031 | VDetailLog("{0},MoveAngular,done,newRotVel={1},decay={2},lastAngular={3}", | ||
1032 | Prim.LocalID, applyAngularForce, decayamount, m_lastAngularVelocity); | ||
806 | } | 1033 | } |
807 | |||
808 | // apply friction | ||
809 | Vector3 decayamount = Vector3.One / (m_angularFrictionTimescale / pTimestep); | ||
810 | m_lastAngularVelocity -= m_lastAngularVelocity * decayamount; | ||
811 | |||
812 | // Apply to the body | ||
813 | Prim.ForceRotationalVelocity = m_lastAngularVelocity; | ||
814 | |||
815 | VDetailLog("{0},MoveAngular,done,decay={1},lastAngular={2}", Prim.LocalID, decayamount, m_lastAngularVelocity); | ||
816 | } //end MoveAngular | 1034 | } //end MoveAngular |
817 | 1035 | ||
818 | internal void LimitRotation(float timestep) | 1036 | internal void LimitRotation(float timestep) |
819 | { | 1037 | { |
820 | Quaternion rotq = Prim.ForceOrientation; | 1038 | Quaternion rotq = Prim.ForceOrientation; |
821 | Quaternion m_rot = rotq; | 1039 | Quaternion m_rot = rotq; |
822 | bool changed = false; | ||
823 | if (m_RollreferenceFrame != Quaternion.Identity) | 1040 | if (m_RollreferenceFrame != Quaternion.Identity) |
824 | { | 1041 | { |
825 | if (rotq.X >= m_RollreferenceFrame.X) | 1042 | if (rotq.X >= m_RollreferenceFrame.X) |
826 | { | 1043 | { |
827 | m_rot.X = rotq.X - (m_RollreferenceFrame.X / 2); | 1044 | m_rot.X = rotq.X - (m_RollreferenceFrame.X / 2); |
828 | changed = true; | ||
829 | } | 1045 | } |
830 | if (rotq.Y >= m_RollreferenceFrame.Y) | 1046 | if (rotq.Y >= m_RollreferenceFrame.Y) |
831 | { | 1047 | { |
832 | m_rot.Y = rotq.Y - (m_RollreferenceFrame.Y / 2); | 1048 | m_rot.Y = rotq.Y - (m_RollreferenceFrame.Y / 2); |
833 | changed = true; | ||
834 | } | 1049 | } |
835 | if (rotq.X <= -m_RollreferenceFrame.X) | 1050 | if (rotq.X <= -m_RollreferenceFrame.X) |
836 | { | 1051 | { |
837 | m_rot.X = rotq.X + (m_RollreferenceFrame.X / 2); | 1052 | m_rot.X = rotq.X + (m_RollreferenceFrame.X / 2); |
838 | changed = true; | ||
839 | } | 1053 | } |
840 | if (rotq.Y <= -m_RollreferenceFrame.Y) | 1054 | if (rotq.Y <= -m_RollreferenceFrame.Y) |
841 | { | 1055 | { |
842 | m_rot.Y = rotq.Y + (m_RollreferenceFrame.Y / 2); | 1056 | m_rot.Y = rotq.Y + (m_RollreferenceFrame.Y / 2); |
843 | changed = true; | ||
844 | } | 1057 | } |
845 | changed = true; | ||
846 | } | 1058 | } |
847 | if ((m_flags & VehicleFlag.LOCK_ROTATION) != 0) | 1059 | if ((m_flags & VehicleFlag.LOCK_ROTATION) != 0) |
848 | { | 1060 | { |
849 | m_rot.X = 0; | 1061 | m_rot.X = 0; |
850 | m_rot.Y = 0; | 1062 | m_rot.Y = 0; |
851 | changed = true; | ||
852 | } | 1063 | } |
853 | if (changed) | 1064 | if (rotq != m_rot) |
854 | { | 1065 | { |
855 | Prim.ForceOrientation = m_rot; | 1066 | Prim.ForceOrientation = m_rot; |
856 | VDetailLog("{0},LimitRotation,done,orig={1},new={2}", Prim.LocalID, rotq, m_rot); | 1067 | VDetailLog("{0},LimitRotation,done,orig={1},new={2}", Prim.LocalID, rotq, m_rot); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs index 43b1262..0df4310 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinkset.cs | |||
@@ -32,10 +32,39 @@ using OMV = OpenMetaverse; | |||
32 | 32 | ||
33 | namespace OpenSim.Region.Physics.BulletSPlugin | 33 | namespace OpenSim.Region.Physics.BulletSPlugin |
34 | { | 34 | { |
35 | public class BSLinkset | 35 | public abstract class BSLinkset |
36 | { | 36 | { |
37 | // private static string LogHeader = "[BULLETSIM LINKSET]"; | 37 | // private static string LogHeader = "[BULLETSIM LINKSET]"; |
38 | 38 | ||
39 | public enum LinksetImplementation | ||
40 | { | ||
41 | Constraint = 0, // linkset tied together with constraints | ||
42 | Compound = 1, // linkset tied together as a compound object | ||
43 | Manual = 2 // linkset tied together manually (code moves all the pieces) | ||
44 | } | ||
45 | // Create the correct type of linkset for this child | ||
46 | public static BSLinkset Factory(BSScene physScene, BSPhysObject parent) | ||
47 | { | ||
48 | BSLinkset ret = null; | ||
49 | |||
50 | switch ((int)physScene.Params.linksetImplementation) | ||
51 | { | ||
52 | case (int)LinksetImplementation.Constraint: | ||
53 | ret = new BSLinksetConstraints(physScene, parent); | ||
54 | break; | ||
55 | case (int)LinksetImplementation.Compound: | ||
56 | ret = new BSLinksetCompound(physScene, parent); | ||
57 | break; | ||
58 | case (int)LinksetImplementation.Manual: | ||
59 | // ret = new BSLinksetManual(physScene, parent); | ||
60 | break; | ||
61 | default: | ||
62 | ret = new BSLinksetCompound(physScene, parent); | ||
63 | break; | ||
64 | } | ||
65 | return ret; | ||
66 | } | ||
67 | |||
39 | public BSPhysObject LinksetRoot { get; protected set; } | 68 | public BSPhysObject LinksetRoot { get; protected set; } |
40 | 69 | ||
41 | public BSScene PhysicsScene { get; private set; } | 70 | public BSScene PhysicsScene { get; private set; } |
@@ -44,33 +73,39 @@ public class BSLinkset | |||
44 | public int LinksetID { get; private set; } | 73 | public int LinksetID { get; private set; } |
45 | 74 | ||
46 | // The children under the root in this linkset. | 75 | // The children under the root in this linkset. |
47 | // There are two lists of children: the current children at runtime | 76 | protected HashSet<BSPhysObject> m_children; |
48 | // and the children at taint-time. For instance, if you delink a | ||
49 | // child from the linkset, the child is removed from m_children | ||
50 | // but the constraint won't be removed until taint time. | ||
51 | // Two lists lets this track the 'current' children and | ||
52 | // the physical 'taint' children separately. | ||
53 | // After taint processing and before the simulation step, these | ||
54 | // two lists must be the same. | ||
55 | private HashSet<BSPhysObject> m_children; | ||
56 | private HashSet<BSPhysObject> m_taintChildren; | ||
57 | 77 | ||
58 | // We lock the diddling of linkset classes to prevent any badness. | 78 | // We lock the diddling of linkset classes to prevent any badness. |
59 | // This locks the modification of the instances of this class. Changes | 79 | // This locks the modification of the instances of this class. Changes |
60 | // to the physical representation is done via the tainting mechenism. | 80 | // to the physical representation is done via the tainting mechenism. |
61 | private object m_linksetActivityLock = new Object(); | 81 | protected object m_linksetActivityLock = new Object(); |
62 | 82 | ||
83 | // Some linksets have a preferred physical shape. | ||
84 | // Returns SHAPE_UNKNOWN if there is no preference. Causes the correct shape to be selected. | ||
85 | public virtual BSPhysicsShapeType PreferredPhysicalShape(BSPhysObject requestor) | ||
86 | { | ||
87 | return BSPhysicsShapeType.SHAPE_UNKNOWN; | ||
88 | } | ||
89 | |||
90 | // Linksets move around the children so the linkset might need to compute the child position | ||
91 | public virtual OMV.Vector3 Position(BSPhysObject member) | ||
92 | { return member.RawPosition; } | ||
93 | public virtual OMV.Quaternion Orientation(BSPhysObject member) | ||
94 | { return member.RawOrientation; } | ||
95 | // TODO: does this need to be done for Velocity and RotationalVelocityy? | ||
96 | |||
63 | // We keep the prim's mass in the linkset structure since it could be dependent on other prims | 97 | // We keep the prim's mass in the linkset structure since it could be dependent on other prims |
64 | private float m_mass; | 98 | protected float m_mass; |
65 | public float LinksetMass | 99 | public float LinksetMass |
66 | { | 100 | { |
67 | get | 101 | get |
68 | { | 102 | { |
69 | m_mass = ComputeLinksetMass(); | ||
70 | return m_mass; | 103 | return m_mass; |
71 | } | 104 | } |
72 | } | 105 | } |
73 | 106 | ||
107 | public virtual bool LinksetIsColliding { get { return false; } } | ||
108 | |||
74 | public OMV.Vector3 CenterOfMass | 109 | public OMV.Vector3 CenterOfMass |
75 | { | 110 | { |
76 | get { return ComputeLinksetCenterOfMass(); } | 111 | get { return ComputeLinksetCenterOfMass(); } |
@@ -81,7 +116,7 @@ public class BSLinkset | |||
81 | get { return ComputeLinksetGeometricCenter(); } | 116 | get { return ComputeLinksetGeometricCenter(); } |
82 | } | 117 | } |
83 | 118 | ||
84 | public BSLinkset(BSScene scene, BSPhysObject parent) | 119 | protected void Initialize(BSScene scene, BSPhysObject parent) |
85 | { | 120 | { |
86 | // A simple linkset of one (no children) | 121 | // A simple linkset of one (no children) |
87 | LinksetID = m_nextLinksetID++; | 122 | LinksetID = m_nextLinksetID++; |
@@ -91,8 +126,7 @@ public class BSLinkset | |||
91 | PhysicsScene = scene; | 126 | PhysicsScene = scene; |
92 | LinksetRoot = parent; | 127 | LinksetRoot = parent; |
93 | m_children = new HashSet<BSPhysObject>(); | 128 | m_children = new HashSet<BSPhysObject>(); |
94 | m_taintChildren = new HashSet<BSPhysObject>(); | 129 | m_mass = parent.RawMass; |
95 | m_mass = parent.MassRaw; | ||
96 | } | 130 | } |
97 | 131 | ||
98 | // Link to a linkset where the child knows the parent. | 132 | // Link to a linkset where the child knows the parent. |
@@ -106,6 +140,7 @@ public class BSLinkset | |||
106 | // Don't add the root to its own linkset | 140 | // Don't add the root to its own linkset |
107 | if (!IsRoot(child)) | 141 | if (!IsRoot(child)) |
108 | AddChildToLinkset(child); | 142 | AddChildToLinkset(child); |
143 | m_mass = ComputeLinksetMass(); | ||
109 | } | 144 | } |
110 | return this; | 145 | return this; |
111 | } | 146 | } |
@@ -123,12 +158,12 @@ public class BSLinkset | |||
123 | // Cannot remove the root from a linkset. | 158 | // Cannot remove the root from a linkset. |
124 | return this; | 159 | return this; |
125 | } | 160 | } |
126 | |||
127 | RemoveChildFromLinkset(child); | 161 | RemoveChildFromLinkset(child); |
162 | m_mass = ComputeLinksetMass(); | ||
128 | } | 163 | } |
129 | 164 | ||
130 | // The child is down to a linkset of just itself | 165 | // The child is down to a linkset of just itself |
131 | return new BSLinkset(PhysicsScene, child); | 166 | return BSLinkset.Factory(PhysicsScene, child); |
132 | } | 167 | } |
133 | 168 | ||
134 | // Return 'true' if the passed object is the root object of this linkset | 169 | // Return 'true' if the passed object is the root object of this linkset |
@@ -148,6 +183,8 @@ public class BSLinkset | |||
148 | bool ret = false; | 183 | bool ret = false; |
149 | lock (m_linksetActivityLock) | 184 | lock (m_linksetActivityLock) |
150 | { | 185 | { |
186 | ret = m_children.Contains(child); | ||
187 | /* Safer version but the above should work | ||
151 | foreach (BSPhysObject bp in m_children) | 188 | foreach (BSPhysObject bp in m_children) |
152 | { | 189 | { |
153 | if (child.LocalID == bp.LocalID) | 190 | if (child.LocalID == bp.LocalID) |
@@ -156,159 +193,102 @@ public class BSLinkset | |||
156 | break; | 193 | break; |
157 | } | 194 | } |
158 | } | 195 | } |
196 | */ | ||
159 | } | 197 | } |
160 | return ret; | 198 | return ret; |
161 | } | 199 | } |
162 | 200 | ||
163 | // When physical properties are changed the linkset needs to recalculate | 201 | // Perform an action on each member of the linkset including root prim. |
164 | // its internal properties. | 202 | // Depends on the action on whether this should be done at taint time. |
165 | // May be called at runtime or taint-time (just pass the appropriate flag). | 203 | public delegate bool ForEachMemberAction(BSPhysObject obj); |
166 | public void Refresh(BSPhysObject requestor, bool inTaintTime) | 204 | public virtual bool ForEachMember(ForEachMemberAction action) |
167 | { | 205 | { |
168 | // If there are no children, not physical or not root, I am not the one that recomputes the constraints | 206 | bool ret = false; |
169 | // (For the moment, static linksets do create constraints so remove the test for physical.) | 207 | lock (m_linksetActivityLock) |
170 | if (!HasAnyChildren || /*!requestor.IsPhysical ||*/ !IsRoot(requestor)) | 208 | { |
171 | return; | 209 | action(LinksetRoot); |
172 | 210 | foreach (BSPhysObject po in m_children) | |
173 | BSScene.TaintCallback refreshOperation = delegate() | ||
174 | { | 211 | { |
175 | RecomputeLinksetConstraintVariables(); | 212 | if (action(po)) |
176 | DetailLog("{0},BSLinkset.Refresh,complete,rBody={1}", | 213 | break; |
177 | LinksetRoot.LocalID, LinksetRoot.BSBody.ptr.ToString("X")); | 214 | } |
178 | }; | 215 | } |
179 | if (inTaintTime) | 216 | return ret; |
180 | refreshOperation(); | ||
181 | else | ||
182 | PhysicsScene.TaintedObject("BSLinkSet.Refresh", refreshOperation); | ||
183 | } | 217 | } |
184 | 218 | ||
219 | // I am the root of a linkset and a new child is being added | ||
220 | // Called while LinkActivity is locked. | ||
221 | protected abstract void AddChildToLinkset(BSPhysObject child); | ||
222 | |||
223 | // I am the root of a linkset and one of my children is being removed. | ||
224 | // Safe to call even if the child is not really in my linkset. | ||
225 | protected abstract void RemoveChildFromLinkset(BSPhysObject child); | ||
226 | |||
227 | // When physical properties are changed the linkset needs to recalculate | ||
228 | // its internal properties. | ||
229 | // May be called at runtime or taint-time. | ||
230 | public abstract void Refresh(BSPhysObject requestor); | ||
231 | |||
185 | // The object is going dynamic (physical). Do any setup necessary | 232 | // The object is going dynamic (physical). Do any setup necessary |
186 | // for a dynamic linkset. | 233 | // for a dynamic linkset. |
187 | // Only the state of the passed object can be modified. The rest of the linkset | 234 | // Only the state of the passed object can be modified. The rest of the linkset |
188 | // has not yet been fully constructed. | 235 | // has not yet been fully constructed. |
189 | // Return 'true' if any properties updated on the passed object. | 236 | // Return 'true' if any properties updated on the passed object. |
190 | // Called at taint-time! | 237 | // Called at taint-time! |
191 | public bool MakeDynamic(BSPhysObject child) | 238 | public abstract bool MakeDynamic(BSPhysObject child); |
192 | { | ||
193 | // What is done for each object in BSPrim is what we want. | ||
194 | return false; | ||
195 | } | ||
196 | 239 | ||
197 | // The object is going static (non-physical). Do any setup necessary | 240 | // The object is going static (non-physical). Do any setup necessary |
198 | // for a static linkset. | 241 | // for a static linkset. |
199 | // Return 'true' if any properties updated on the passed object. | 242 | // Return 'true' if any properties updated on the passed object. |
200 | // Called at taint-time! | 243 | // Called at taint-time! |
201 | public bool MakeStatic(BSPhysObject child) | 244 | public abstract bool MakeStatic(BSPhysObject child); |
202 | { | ||
203 | // What is done for each object in BSPrim is what we want. | ||
204 | return false; | ||
205 | } | ||
206 | 245 | ||
207 | // If the software is handling the movement of all the objects in a linkset | 246 | // Called when a parameter update comes from the physics engine for any object |
208 | // (like if one doesn't use constraints for static linksets), this is called | 247 | // of the linkset is received. |
209 | // when an update for the root of the linkset is received. | ||
210 | // Called at taint-time!! | 248 | // Called at taint-time!! |
211 | public void UpdateProperties(BSPhysObject physObject) | 249 | public abstract void UpdateProperties(BSPhysObject physObject); |
212 | { | ||
213 | // The root local properties have been updated. Apply to the children if appropriate. | ||
214 | if (IsRoot(physObject) && HasAnyChildren) | ||
215 | { | ||
216 | if (!physObject.IsPhysical) | ||
217 | { | ||
218 | // TODO: implement software linkset update for static object linksets | ||
219 | } | ||
220 | } | ||
221 | } | ||
222 | 250 | ||
223 | // Routine used when rebuilding the body of the root of the linkset | 251 | // Routine used when rebuilding the body of the root of the linkset |
224 | // Destroy all the constraints have have been made to root. | 252 | // Destroy all the constraints have have been made to root. |
225 | // This is called when the root body is changing. | 253 | // This is called when the root body is changing. |
226 | // Returns 'true' of something eas actually removed and would need restoring | 254 | // Returns 'true' of something was actually removed and would need restoring |
227 | // Called at taint-time!! | 255 | // Called at taint-time!! |
228 | public bool RemoveBodyDependencies(BSPrim child) | 256 | public abstract bool RemoveBodyDependencies(BSPrim child); |
229 | { | ||
230 | bool ret = false; | ||
231 | |||
232 | lock (m_linksetActivityLock) | ||
233 | { | ||
234 | if (IsRoot(child)) | ||
235 | { | ||
236 | // If the one with the dependency is root, must undo all children | ||
237 | DetailLog("{0},BSLinkset.RemoveBodyDependencies,removeChildrenForRoot,rID={1},rBody={2}", | ||
238 | child.LocalID, LinksetRoot.LocalID, LinksetRoot.BSBody.ptr.ToString("X")); | ||
239 | |||
240 | ret = PhysicallyUnlinkAllChildrenFromRoot(LinksetRoot); | ||
241 | } | ||
242 | else | ||
243 | { | ||
244 | DetailLog("{0},BSLinkset.RemoveBodyDependencies,removeSingleChild,rID={1},rBody={2},cID={3},cBody={4}", | ||
245 | child.LocalID, | ||
246 | LinksetRoot.LocalID, LinksetRoot.BSBody.ptr.ToString("X"), | ||
247 | child.LocalID, child.BSBody.ptr.ToString("X")); | ||
248 | // ret = PhysicallyUnlinkAChildFromRoot(LinksetRoot, child); | ||
249 | // Despite the function name, this removes any link to the specified object. | ||
250 | ret = PhysicallyUnlinkAllChildrenFromRoot(child); | ||
251 | } | ||
252 | } | ||
253 | return ret; | ||
254 | } | ||
255 | 257 | ||
256 | // Companion to RemoveBodyDependencies(). If RemoveBodyDependencies() returns 'true', | 258 | // Companion to RemoveBodyDependencies(). If RemoveBodyDependencies() returns 'true', |
257 | // this routine will restore the removed constraints. | 259 | // this routine will restore the removed constraints. |
258 | // Called at taint-time!! | 260 | // Called at taint-time!! |
259 | public void RestoreBodyDependencies(BSPrim child) | 261 | public abstract void RestoreBodyDependencies(BSPrim child); |
260 | { | ||
261 | lock (m_linksetActivityLock) | ||
262 | { | ||
263 | if (IsRoot(child)) | ||
264 | { | ||
265 | DetailLog("{0},BSLinkset.RestoreBodyDependencies,restoreChildrenForRoot,rID={1},numChild={2}", | ||
266 | child.LocalID, LinksetRoot.LocalID, m_taintChildren.Count); | ||
267 | foreach (BSPhysObject bpo in m_taintChildren) | ||
268 | { | ||
269 | PhysicallyLinkAChildToRoot(LinksetRoot, bpo); | ||
270 | } | ||
271 | } | ||
272 | else | ||
273 | { | ||
274 | DetailLog("{0},BSLinkset.RestoreBodyDependencies,restoreSingleChild,rID={1},rBody={2},cID={3},cBody={4}", | ||
275 | LinksetRoot.LocalID, | ||
276 | LinksetRoot.LocalID, LinksetRoot.BSBody.ptr.ToString("X"), | ||
277 | child.LocalID, child.BSBody.ptr.ToString("X")); | ||
278 | PhysicallyLinkAChildToRoot(LinksetRoot, child); | ||
279 | } | ||
280 | } | ||
281 | } | ||
282 | 262 | ||
283 | // ================================================================ | 263 | // ================================================================ |
284 | // Below this point is internal magic | 264 | protected virtual float ComputeLinksetMass() |
285 | |||
286 | private float ComputeLinksetMass() | ||
287 | { | 265 | { |
288 | float mass; | 266 | float mass = LinksetRoot.RawMass; |
289 | lock (m_linksetActivityLock) | 267 | if (HasAnyChildren) |
290 | { | 268 | { |
291 | mass = LinksetRoot.MassRaw; | 269 | lock (m_linksetActivityLock) |
292 | foreach (BSPhysObject bp in m_taintChildren) | ||
293 | { | 270 | { |
294 | mass += bp.MassRaw; | 271 | foreach (BSPhysObject bp in m_children) |
272 | { | ||
273 | mass += bp.RawMass; | ||
274 | } | ||
295 | } | 275 | } |
296 | } | 276 | } |
297 | return mass; | 277 | return mass; |
298 | } | 278 | } |
299 | 279 | ||
300 | private OMV.Vector3 ComputeLinksetCenterOfMass() | 280 | protected virtual OMV.Vector3 ComputeLinksetCenterOfMass() |
301 | { | 281 | { |
302 | OMV.Vector3 com; | 282 | OMV.Vector3 com; |
303 | lock (m_linksetActivityLock) | 283 | lock (m_linksetActivityLock) |
304 | { | 284 | { |
305 | com = LinksetRoot.Position * LinksetRoot.MassRaw; | 285 | com = LinksetRoot.Position * LinksetRoot.RawMass; |
306 | float totalMass = LinksetRoot.MassRaw; | 286 | float totalMass = LinksetRoot.RawMass; |
307 | 287 | ||
308 | foreach (BSPhysObject bp in m_taintChildren) | 288 | foreach (BSPhysObject bp in m_children) |
309 | { | 289 | { |
310 | com += bp.Position * bp.MassRaw; | 290 | com += bp.Position * bp.RawMass; |
311 | totalMass += bp.MassRaw; | 291 | totalMass += bp.RawMass; |
312 | } | 292 | } |
313 | if (totalMass != 0f) | 293 | if (totalMass != 0f) |
314 | com /= totalMass; | 294 | com /= totalMass; |
@@ -317,255 +297,25 @@ public class BSLinkset | |||
317 | return com; | 297 | return com; |
318 | } | 298 | } |
319 | 299 | ||
320 | private OMV.Vector3 ComputeLinksetGeometricCenter() | 300 | protected virtual OMV.Vector3 ComputeLinksetGeometricCenter() |
321 | { | 301 | { |
322 | OMV.Vector3 com; | 302 | OMV.Vector3 com; |
323 | lock (m_linksetActivityLock) | 303 | lock (m_linksetActivityLock) |
324 | { | 304 | { |
325 | com = LinksetRoot.Position; | 305 | com = LinksetRoot.Position; |
326 | 306 | ||
327 | foreach (BSPhysObject bp in m_taintChildren) | 307 | foreach (BSPhysObject bp in m_children) |
328 | { | 308 | { |
329 | com += bp.Position * bp.MassRaw; | 309 | com += bp.Position * bp.RawMass; |
330 | } | 310 | } |
331 | com /= (m_taintChildren.Count + 1); | 311 | com /= (m_children.Count + 1); |
332 | } | 312 | } |
333 | 313 | ||
334 | return com; | 314 | return com; |
335 | } | 315 | } |
336 | 316 | ||
337 | // I am the root of a linkset and a new child is being added | ||
338 | // Called while LinkActivity is locked. | ||
339 | private void AddChildToLinkset(BSPhysObject child) | ||
340 | { | ||
341 | if (!HasChild(child)) | ||
342 | { | ||
343 | m_children.Add(child); | ||
344 | |||
345 | BSPhysObject rootx = LinksetRoot; // capture the root as of now | ||
346 | BSPhysObject childx = child; | ||
347 | |||
348 | DetailLog("{0},AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); | ||
349 | |||
350 | PhysicsScene.TaintedObject("AddChildToLinkset", delegate() | ||
351 | { | ||
352 | DetailLog("{0},AddChildToLinkset,taint,rID={1},rBody={2},cID={3},cBody={4}", | ||
353 | rootx.LocalID, | ||
354 | rootx.LocalID, rootx.BSBody.ptr.ToString("X"), | ||
355 | childx.LocalID, childx.BSBody.ptr.ToString("X")); | ||
356 | // Since this is taint-time, the body and shape could have changed for the child | ||
357 | rootx.ForcePosition = rootx.Position; // DEBUG | ||
358 | childx.ForcePosition = childx.Position; // DEBUG | ||
359 | PhysicallyLinkAChildToRoot(rootx, childx); | ||
360 | m_taintChildren.Add(child); | ||
361 | }); | ||
362 | } | ||
363 | return; | ||
364 | } | ||
365 | |||
366 | // Forcefully removing a child from a linkset. | ||
367 | // This is not being called by the child so we have to make sure the child doesn't think | ||
368 | // it's still connected to the linkset. | ||
369 | // Normal OpenSimulator operation will never do this because other SceneObjectPart information | ||
370 | // also has to be updated (like pointer to prim's parent). | ||
371 | private void RemoveChildFromOtherLinkset(BSPhysObject pchild) | ||
372 | { | ||
373 | pchild.Linkset = new BSLinkset(PhysicsScene, pchild); | ||
374 | RemoveChildFromLinkset(pchild); | ||
375 | } | ||
376 | |||
377 | // I am the root of a linkset and one of my children is being removed. | ||
378 | // Safe to call even if the child is not really in my linkset. | ||
379 | private void RemoveChildFromLinkset(BSPhysObject child) | ||
380 | { | ||
381 | if (m_children.Remove(child)) | ||
382 | { | ||
383 | BSPhysObject rootx = LinksetRoot; // capture the root and body as of now | ||
384 | BSPhysObject childx = child; | ||
385 | |||
386 | DetailLog("{0},RemoveChildFromLinkset,call,rID={1},rBody={2},cID={3},cBody={4}", | ||
387 | childx.LocalID, | ||
388 | rootx.LocalID, rootx.BSBody.ptr.ToString("X"), | ||
389 | childx.LocalID, childx.BSBody.ptr.ToString("X")); | ||
390 | |||
391 | PhysicsScene.TaintedObject("RemoveChildFromLinkset", delegate() | ||
392 | { | ||
393 | m_taintChildren.Remove(child); | ||
394 | PhysicallyUnlinkAChildFromRoot(rootx, childx); | ||
395 | RecomputeLinksetConstraintVariables(); | ||
396 | }); | ||
397 | |||
398 | } | ||
399 | else | ||
400 | { | ||
401 | // This will happen if we remove the root of the linkset first. Non-fatal occurance. | ||
402 | // PhysicsScene.Logger.ErrorFormat("{0}: Asked to remove child from linkset that was not in linkset", LogHeader); | ||
403 | } | ||
404 | return; | ||
405 | } | ||
406 | |||
407 | // Create a constraint between me (root of linkset) and the passed prim (the child). | ||
408 | // Called at taint time! | ||
409 | private void PhysicallyLinkAChildToRoot(BSPhysObject rootPrim, BSPhysObject childPrim) | ||
410 | { | ||
411 | // Zero motion for children so they don't interpolate | ||
412 | childPrim.ZeroMotion(); | ||
413 | |||
414 | // Relative position normalized to the root prim | ||
415 | // Essentually a vector pointing from center of rootPrim to center of childPrim | ||
416 | OMV.Vector3 childRelativePosition = childPrim.Position - rootPrim.Position; | ||
417 | |||
418 | // real world coordinate of midpoint between the two objects | ||
419 | OMV.Vector3 midPoint = rootPrim.Position + (childRelativePosition / 2); | ||
420 | |||
421 | DetailLog("{0},BSLinkset.PhysicallyLinkAChildToRoot,taint,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}", | ||
422 | rootPrim.LocalID, | ||
423 | rootPrim.LocalID, rootPrim.BSBody.ptr.ToString("X"), | ||
424 | childPrim.LocalID, childPrim.BSBody.ptr.ToString("X"), | ||
425 | rootPrim.Position, childPrim.Position, midPoint); | ||
426 | |||
427 | // create a constraint that allows no freedom of movement between the two objects | ||
428 | // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 | ||
429 | |||
430 | BS6DofConstraint constrain = new BS6DofConstraint( | ||
431 | PhysicsScene.World, rootPrim.BSBody, childPrim.BSBody, midPoint, true, true ); | ||
432 | |||
433 | /* NOTE: below is an attempt to build constraint with full frame computation, etc. | ||
434 | * Using the midpoint is easier since it lets the Bullet code manipulate the transforms | ||
435 | * of the objects. | ||
436 | * Code left as a warning to future programmers. | ||
437 | // ================================================================================== | ||
438 | // relative position normalized to the root prim | ||
439 | OMV.Quaternion invThisOrientation = OMV.Quaternion.Inverse(rootPrim.Orientation); | ||
440 | OMV.Vector3 childRelativePosition = (childPrim.Position - rootPrim.Position) * invThisOrientation; | ||
441 | |||
442 | // relative rotation of the child to the parent | ||
443 | OMV.Quaternion childRelativeRotation = invThisOrientation * childPrim.Orientation; | ||
444 | OMV.Quaternion inverseChildRelativeRotation = OMV.Quaternion.Inverse(childRelativeRotation); | ||
445 | |||
446 | // create a constraint that allows no freedom of movement between the two objects | ||
447 | // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 | ||
448 | DetailLog("{0},BSLinkset.PhysicallyLinkAChildToRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID); | ||
449 | BS6DofConstraint constrain = new BS6DofConstraint( | ||
450 | PhysicsScene.World, rootPrim.Body, childPrim.Body, | ||
451 | OMV.Vector3.Zero, | ||
452 | OMV.Quaternion.Inverse(rootPrim.Orientation), | ||
453 | OMV.Vector3.Zero, | ||
454 | OMV.Quaternion.Inverse(childPrim.Orientation), | ||
455 | // A point half way between the parent and child | ||
456 | // childRelativePosition/2, | ||
457 | // childRelativeRotation, | ||
458 | // childRelativePosition/2, | ||
459 | // inverseChildRelativeRotation, | ||
460 | true, | ||
461 | true | ||
462 | ); | ||
463 | // ================================================================================== | ||
464 | */ | ||
465 | |||
466 | PhysicsScene.Constraints.AddConstraint(constrain); | ||
467 | |||
468 | // zero linear and angular limits makes the objects unable to move in relation to each other | ||
469 | constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); | ||
470 | constrain.SetAngularLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); | ||
471 | |||
472 | // tweek the constraint to increase stability | ||
473 | constrain.UseFrameOffset(PhysicsScene.BoolNumeric(PhysicsScene.Params.linkConstraintUseFrameOffset)); | ||
474 | constrain.TranslationalLimitMotor(PhysicsScene.BoolNumeric(PhysicsScene.Params.linkConstraintEnableTransMotor), | ||
475 | PhysicsScene.Params.linkConstraintTransMotorMaxVel, | ||
476 | PhysicsScene.Params.linkConstraintTransMotorMaxForce); | ||
477 | constrain.SetCFMAndERP(PhysicsScene.Params.linkConstraintCFM, PhysicsScene.Params.linkConstraintERP); | ||
478 | if (PhysicsScene.Params.linkConstraintSolverIterations != 0f) | ||
479 | { | ||
480 | constrain.SetSolverIterations(PhysicsScene.Params.linkConstraintSolverIterations); | ||
481 | } | ||
482 | } | ||
483 | |||
484 | // Remove linkage between myself and a particular child | ||
485 | // The root and child bodies are passed in because we need to remove the constraint between | ||
486 | // the bodies that were at unlink time. | ||
487 | // Called at taint time! | ||
488 | private bool PhysicallyUnlinkAChildFromRoot(BSPhysObject rootPrim, BSPhysObject childPrim) | ||
489 | { | ||
490 | bool ret = false; | ||
491 | DetailLog("{0},BSLinkset.PhysicallyUnlinkAChildFromRoot,taint,root={1},rBody={2},child={3},cBody={4}", | ||
492 | rootPrim.LocalID, | ||
493 | rootPrim.LocalID, rootPrim.BSBody.ptr.ToString("X"), | ||
494 | childPrim.LocalID, childPrim.BSBody.ptr.ToString("X")); | ||
495 | |||
496 | // Find the constraint for this link and get rid of it from the overall collection and from my list | ||
497 | if (PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.BSBody, childPrim.BSBody)) | ||
498 | { | ||
499 | // Make the child refresh its location | ||
500 | BulletSimAPI.PushUpdate2(childPrim.BSBody.ptr); | ||
501 | ret = true; | ||
502 | } | ||
503 | |||
504 | return ret; | ||
505 | } | ||
506 | |||
507 | // Remove linkage between myself and any possible children I might have. | ||
508 | // Called at taint time! | ||
509 | private bool PhysicallyUnlinkAllChildrenFromRoot(BSPhysObject rootPrim) | ||
510 | { | ||
511 | DetailLog("{0},BSLinkset.PhysicallyUnlinkAllChildren,taint", rootPrim.LocalID); | ||
512 | bool ret = false; | ||
513 | |||
514 | if (PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.BSBody)) | ||
515 | { | ||
516 | ret = true; | ||
517 | } | ||
518 | return ret; | ||
519 | } | ||
520 | |||
521 | // Call each of the constraints that make up this linkset and recompute the | ||
522 | // various transforms and variables. Used when objects are added or removed | ||
523 | // from a linkset to make sure the constraints know about the new mass and | ||
524 | // geometry. | ||
525 | // Must only be called at taint time!! | ||
526 | private void RecomputeLinksetConstraintVariables() | ||
527 | { | ||
528 | float linksetMass = LinksetMass; | ||
529 | foreach (BSPhysObject child in m_taintChildren) | ||
530 | { | ||
531 | BSConstraint constrain; | ||
532 | if (PhysicsScene.Constraints.TryGetConstraint(LinksetRoot.BSBody, child.BSBody, out constrain)) | ||
533 | { | ||
534 | // DetailLog("{0},BSLinkset.RecomputeLinksetConstraintVariables,taint,child={1},mass={2},A={3},B={4}", | ||
535 | // LinksetRoot.LocalID, child.LocalID, linksetMass, constrain.Body1.ID, constrain.Body2.ID); | ||
536 | constrain.RecomputeConstraintVariables(linksetMass); | ||
537 | } | ||
538 | else | ||
539 | { | ||
540 | // Non-fatal error that happens when children are being added to the linkset but | ||
541 | // their constraints have not been created yet. | ||
542 | break; | ||
543 | } | ||
544 | } | ||
545 | |||
546 | // If the whole linkset is not here, doesn't make sense to recompute linkset wide values | ||
547 | if (m_children.Count == m_taintChildren.Count) | ||
548 | { | ||
549 | // If this is a multiple object linkset, set everybody's center of mass to the set's center of mass | ||
550 | OMV.Vector3 centerOfMass = ComputeLinksetCenterOfMass(); | ||
551 | BulletSimAPI.SetCenterOfMassByPosRot2(LinksetRoot.BSBody.ptr, | ||
552 | centerOfMass, OMV.Quaternion.Identity); | ||
553 | DetailLog("{0},BSLinkset.RecomputeLinksetConstraintVariables,setCenterOfMass,COM={1},rBody={2}", | ||
554 | LinksetRoot.LocalID, centerOfMass, LinksetRoot.BSBody.ptr.ToString("X")); | ||
555 | foreach (BSPhysObject child in m_taintChildren) | ||
556 | { | ||
557 | BulletSimAPI.SetCenterOfMassByPosRot2(child.BSBody.ptr, | ||
558 | centerOfMass, OMV.Quaternion.Identity); | ||
559 | } | ||
560 | |||
561 | // BulletSimAPI.DumpAllInfo2(PhysicsScene.World.ptr); // DEBUG DEBUG DEBUG | ||
562 | } | ||
563 | return; | ||
564 | } | ||
565 | |||
566 | |||
567 | // Invoke the detailed logger and output something if it's enabled. | 317 | // Invoke the detailed logger and output something if it's enabled. |
568 | private void DetailLog(string msg, params Object[] args) | 318 | protected void DetailLog(string msg, params Object[] args) |
569 | { | 319 | { |
570 | if (PhysicsScene.PhysicsLogging.Enabled) | 320 | if (PhysicsScene.PhysicsLogging.Enabled) |
571 | PhysicsScene.DetailLog(msg, args); | 321 | PhysicsScene.DetailLog(msg, args); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs new file mode 100755 index 0000000..b9c2cf9 --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetCompound.cs | |||
@@ -0,0 +1,275 @@ | |||
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 sealed class BSLinksetCompound : BSLinkset | ||
36 | { | ||
37 | private static string LogHeader = "[BULLETSIM LINKSET COMPOUND]"; | ||
38 | |||
39 | public BSLinksetCompound(BSScene scene, BSPhysObject parent) | ||
40 | { | ||
41 | base.Initialize(scene, parent); | ||
42 | } | ||
43 | |||
44 | // For compound implimented linksets, if there are children, use compound shape for the root. | ||
45 | public override BSPhysicsShapeType PreferredPhysicalShape(BSPhysObject requestor) | ||
46 | { | ||
47 | BSPhysicsShapeType ret = BSPhysicsShapeType.SHAPE_UNKNOWN; | ||
48 | if (IsRoot(requestor) && HasAnyChildren) | ||
49 | { | ||
50 | ret = BSPhysicsShapeType.SHAPE_COMPOUND; | ||
51 | } | ||
52 | // DetailLog("{0},BSLinksetCompound.PreferredPhysicalShape,call,shape={1}", LinksetRoot.LocalID, ret); | ||
53 | return ret; | ||
54 | } | ||
55 | |||
56 | // When physical properties are changed the linkset needs to recalculate | ||
57 | // its internal properties. | ||
58 | // This is queued in the 'post taint' queue so the | ||
59 | // refresh will happen once after all the other taints are applied. | ||
60 | public override void Refresh(BSPhysObject requestor) | ||
61 | { | ||
62 | // External request for Refresh (from BSPrim) is not necessary | ||
63 | // InternalRefresh(requestor); | ||
64 | } | ||
65 | |||
66 | private void InternalRefresh(BSPhysObject requestor) | ||
67 | { | ||
68 | DetailLog("{0},BSLinksetCompound.Refresh,schedulingRefresh,requestor={1}", LinksetRoot.LocalID, requestor.LocalID); | ||
69 | // Queue to happen after all the other taint processing | ||
70 | PhysicsScene.PostTaintObject("BSLinksetCompound.Refresh", requestor.LocalID, delegate() | ||
71 | { | ||
72 | if (IsRoot(requestor) && HasAnyChildren) | ||
73 | RecomputeLinksetCompound(); | ||
74 | }); | ||
75 | } | ||
76 | |||
77 | // The object is going dynamic (physical). Do any setup necessary | ||
78 | // for a dynamic linkset. | ||
79 | // Only the state of the passed object can be modified. The rest of the linkset | ||
80 | // has not yet been fully constructed. | ||
81 | // Return 'true' if any properties updated on the passed object. | ||
82 | // Called at taint-time! | ||
83 | public override bool MakeDynamic(BSPhysObject child) | ||
84 | { | ||
85 | bool ret = false; | ||
86 | DetailLog("{0},BSLinksetCompound.MakeDynamic,call,IsRoot={1}", child.LocalID, IsRoot(child)); | ||
87 | if (!IsRoot(child)) | ||
88 | { | ||
89 | // Physical children are removed from the world as the shape ofthe root compound | ||
90 | // shape takes over. | ||
91 | BulletSimAPI.AddToCollisionFlags2(child.PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); | ||
92 | BulletSimAPI.ForceActivationState2(child.PhysBody.ptr, ActivationState.DISABLE_SIMULATION); | ||
93 | ret = true; | ||
94 | } | ||
95 | return ret; | ||
96 | } | ||
97 | |||
98 | // The object is going static (non-physical). Do any setup necessary for a static linkset. | ||
99 | // Return 'true' if any properties updated on the passed object. | ||
100 | // This doesn't normally happen -- OpenSim removes the objects from the physical | ||
101 | // world if it is a static linkset. | ||
102 | // Called at taint-time! | ||
103 | public override bool MakeStatic(BSPhysObject child) | ||
104 | { | ||
105 | bool ret = false; | ||
106 | DetailLog("{0},BSLinksetCompound.MakeStatic,call,IsRoot={1}", child.LocalID, IsRoot(child)); | ||
107 | if (!IsRoot(child)) | ||
108 | { | ||
109 | // The non-physical children can come back to life. | ||
110 | BulletSimAPI.RemoveFromCollisionFlags2(child.PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); | ||
111 | // Don't force activation so setting of DISABLE_SIMULATION can stay. | ||
112 | BulletSimAPI.Activate2(child.PhysBody.ptr, false); | ||
113 | ret = true; | ||
114 | } | ||
115 | return ret; | ||
116 | } | ||
117 | |||
118 | // Called at taint-time!! | ||
119 | public override void UpdateProperties(BSPhysObject updated) | ||
120 | { | ||
121 | // Nothing to do for constraints on property updates | ||
122 | } | ||
123 | |||
124 | // The children move around in relationship to the root. | ||
125 | // Just grab the current values of wherever it is right now. | ||
126 | public override OMV.Vector3 Position(BSPhysObject member) | ||
127 | { | ||
128 | return BulletSimAPI.GetPosition2(member.PhysBody.ptr); | ||
129 | } | ||
130 | |||
131 | public override OMV.Quaternion Orientation(BSPhysObject member) | ||
132 | { | ||
133 | return BulletSimAPI.GetOrientation2(member.PhysBody.ptr); | ||
134 | } | ||
135 | |||
136 | // Routine called when rebuilding the body of some member of the linkset. | ||
137 | // Since we don't keep in world relationships, do nothing unless it's a child changing. | ||
138 | // Returns 'true' of something was actually removed and would need restoring | ||
139 | // Called at taint-time!! | ||
140 | public override bool RemoveBodyDependencies(BSPrim child) | ||
141 | { | ||
142 | bool ret = false; | ||
143 | |||
144 | DetailLog("{0},BSLinksetCompound.RemoveBodyDependencies,refreshIfChild,rID={1},rBody={2},isRoot={3}", | ||
145 | child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), IsRoot(child)); | ||
146 | |||
147 | if (!IsRoot(child)) | ||
148 | { | ||
149 | // Cause the current shape to be freed and the new one to be built. | ||
150 | InternalRefresh(LinksetRoot); | ||
151 | ret = true; | ||
152 | } | ||
153 | |||
154 | return ret; | ||
155 | } | ||
156 | |||
157 | // Companion to RemoveBodyDependencies(). If RemoveBodyDependencies() returns 'true', | ||
158 | // this routine will restore the removed constraints. | ||
159 | // Called at taint-time!! | ||
160 | public override void RestoreBodyDependencies(BSPrim child) | ||
161 | { | ||
162 | // The Refresh operation queued by RemoveBodyDependencies() will build any missing constraints. | ||
163 | } | ||
164 | |||
165 | // ================================================================ | ||
166 | |||
167 | // Add a new child to the linkset. | ||
168 | // Called while LinkActivity is locked. | ||
169 | protected override void AddChildToLinkset(BSPhysObject child) | ||
170 | { | ||
171 | if (!HasChild(child)) | ||
172 | { | ||
173 | m_children.Add(child); | ||
174 | |||
175 | DetailLog("{0},BSLinksetCompound.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); | ||
176 | |||
177 | // Cause constraints and assorted properties to be recomputed before the next simulation step. | ||
178 | InternalRefresh(LinksetRoot); | ||
179 | } | ||
180 | return; | ||
181 | } | ||
182 | |||
183 | // Remove the specified child from the linkset. | ||
184 | // Safe to call even if the child is not really in my linkset. | ||
185 | protected override void RemoveChildFromLinkset(BSPhysObject child) | ||
186 | { | ||
187 | if (m_children.Remove(child)) | ||
188 | { | ||
189 | DetailLog("{0},BSLinksetCompound.RemoveChildFromLinkset,call,rID={1},rBody={2},cID={3},cBody={4}", | ||
190 | child.LocalID, | ||
191 | LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), | ||
192 | child.LocalID, child.PhysBody.ptr.ToString("X")); | ||
193 | |||
194 | // Cause the child's body to be rebuilt and thus restored to normal operation | ||
195 | child.ForceBodyShapeRebuild(false); | ||
196 | |||
197 | if (!HasAnyChildren) | ||
198 | { | ||
199 | // The linkset is now empty. The root needs rebuilding. | ||
200 | LinksetRoot.ForceBodyShapeRebuild(false); | ||
201 | } | ||
202 | else | ||
203 | { | ||
204 | // Schedule a rebuild of the linkset before the next simulation tick. | ||
205 | InternalRefresh(LinksetRoot); | ||
206 | } | ||
207 | } | ||
208 | return; | ||
209 | } | ||
210 | |||
211 | // Called before the simulation step to make sure the compound based linkset | ||
212 | // is all initialized. | ||
213 | // Constraint linksets are rebuilt every time. | ||
214 | // Note that this works for rebuilding just the root after a linkset is taken apart. | ||
215 | // Called at taint time!! | ||
216 | private void RecomputeLinksetCompound() | ||
217 | { | ||
218 | // Cause the root shape to be rebuilt as a compound object with just the root in it | ||
219 | LinksetRoot.ForceBodyShapeRebuild(true); | ||
220 | |||
221 | DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,start,rBody={1},rShape={2},numChildren={3}", | ||
222 | LinksetRoot.LocalID, LinksetRoot.PhysBody, LinksetRoot.PhysShape, NumberOfChildren); | ||
223 | |||
224 | // Add a shape for each of the other children in the linkset | ||
225 | ForEachMember(delegate(BSPhysObject cPrim) | ||
226 | { | ||
227 | if (!IsRoot(cPrim)) | ||
228 | { | ||
229 | // Each child position and rotation is given relative to the root. | ||
230 | OMV.Quaternion invRootOrientation = OMV.Quaternion.Inverse(LinksetRoot.RawOrientation); | ||
231 | OMV.Vector3 displacementPos = (cPrim.RawPosition - LinksetRoot.RawPosition) * invRootOrientation; | ||
232 | OMV.Quaternion displacementRot = cPrim.RawOrientation * invRootOrientation; | ||
233 | |||
234 | DetailLog("{0},BSLinksetCompound.RecomputeLinksetCompound,addMemberToShape,mID={1},mShape={2},dispPos={3},dispRot={4}", | ||
235 | LinksetRoot.LocalID, cPrim.LocalID, cPrim.PhysShape, displacementPos, displacementRot); | ||
236 | |||
237 | if (cPrim.PhysShape.isNativeShape) | ||
238 | { | ||
239 | // Native shapes are not shared so we need to create a new one. | ||
240 | // A mesh or hull is created because scale is not available on a native shape. | ||
241 | // (TODO: Bullet does have a btScaledCollisionShape. Can that be used?) | ||
242 | BulletShape saveShape = cPrim.PhysShape; | ||
243 | cPrim.PhysShape.ptr = IntPtr.Zero; // Don't let the create free the child's shape | ||
244 | PhysicsScene.Shapes.CreateGeomMeshOrHull(cPrim, null); | ||
245 | BulletShape newShape = cPrim.PhysShape; | ||
246 | cPrim.PhysShape = saveShape; | ||
247 | BulletSimAPI.AddChildShapeToCompoundShape2(LinksetRoot.PhysShape.ptr, newShape.ptr, displacementPos, displacementRot); | ||
248 | } | ||
249 | else | ||
250 | { | ||
251 | // For the shared shapes (meshes and hulls), just use the shape in the child. | ||
252 | if (PhysicsScene.Shapes.ReferenceShape(cPrim.PhysShape)) | ||
253 | { | ||
254 | PhysicsScene.Logger.ErrorFormat("{0} Rebuilt sharable shape when building linkset! Region={1}, primID={2}, shape={3}", | ||
255 | LogHeader, PhysicsScene.RegionName, cPrim.LocalID, cPrim.PhysShape); | ||
256 | } | ||
257 | BulletSimAPI.AddChildShapeToCompoundShape2(LinksetRoot.PhysShape.ptr, cPrim.PhysShape.ptr, displacementPos, displacementRot); | ||
258 | } | ||
259 | } | ||
260 | return false; // 'false' says to move onto the next child in the list | ||
261 | }); | ||
262 | |||
263 | // With all of the linkset packed into the root prim, it has the mass of everyone. | ||
264 | float linksetMass = LinksetMass; | ||
265 | LinksetRoot.UpdatePhysicalMassProperties(linksetMass); | ||
266 | |||
267 | BulletSimAPI.RecalculateCompoundShapeLocalAabb2(LinksetRoot.PhysShape.ptr); | ||
268 | |||
269 | // DEBUG: see of inter-linkset collisions are causing problems for constraint linksets. | ||
270 | // BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr, | ||
271 | // (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask); | ||
272 | |||
273 | } | ||
274 | } | ||
275 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs new file mode 100755 index 0000000..c855fda --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSLinksetConstraints.cs | |||
@@ -0,0 +1,327 @@ | |||
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 sealed class BSLinksetConstraints : BSLinkset | ||
36 | { | ||
37 | // private static string LogHeader = "[BULLETSIM LINKSET CONSTRAINTS]"; | ||
38 | |||
39 | public BSLinksetConstraints(BSScene scene, BSPhysObject parent) | ||
40 | { | ||
41 | base.Initialize(scene, parent); | ||
42 | } | ||
43 | |||
44 | // When physical properties are changed the linkset needs to recalculate | ||
45 | // its internal properties. | ||
46 | // This is queued in the 'post taint' queue so the | ||
47 | // refresh will happen once after all the other taints are applied. | ||
48 | public override void Refresh(BSPhysObject requestor) | ||
49 | { | ||
50 | // Queue to happen after all the other taint processing | ||
51 | PhysicsScene.PostTaintObject("BSLinksetContraints.Refresh", requestor.LocalID, delegate() | ||
52 | { | ||
53 | if (HasAnyChildren && IsRoot(requestor)) | ||
54 | RecomputeLinksetConstraints(); | ||
55 | }); | ||
56 | } | ||
57 | |||
58 | // The object is going dynamic (physical). Do any setup necessary | ||
59 | // for a dynamic linkset. | ||
60 | // Only the state of the passed object can be modified. The rest of the linkset | ||
61 | // has not yet been fully constructed. | ||
62 | // Return 'true' if any properties updated on the passed object. | ||
63 | // Called at taint-time! | ||
64 | public override bool MakeDynamic(BSPhysObject child) | ||
65 | { | ||
66 | // What is done for each object in BSPrim is what we want. | ||
67 | return false; | ||
68 | } | ||
69 | |||
70 | // The object is going static (non-physical). Do any setup necessary for a static linkset. | ||
71 | // Return 'true' if any properties updated on the passed object. | ||
72 | // This doesn't normally happen -- OpenSim removes the objects from the physical | ||
73 | // world if it is a static linkset. | ||
74 | // Called at taint-time! | ||
75 | public override bool MakeStatic(BSPhysObject child) | ||
76 | { | ||
77 | // What is done for each object in BSPrim is what we want. | ||
78 | return false; | ||
79 | } | ||
80 | |||
81 | // Called at taint-time!! | ||
82 | public override void UpdateProperties(BSPhysObject updated) | ||
83 | { | ||
84 | // Nothing to do for constraints on property updates | ||
85 | } | ||
86 | |||
87 | // The children of the linkset are moved around by the constraints. | ||
88 | // Just grab the current values of wherever it is right now. | ||
89 | public override OMV.Vector3 Position(BSPhysObject member) | ||
90 | { | ||
91 | return BulletSimAPI.GetPosition2(member.PhysBody.ptr); | ||
92 | } | ||
93 | |||
94 | public override OMV.Quaternion Orientation(BSPhysObject member) | ||
95 | { | ||
96 | return BulletSimAPI.GetOrientation2(member.PhysBody.ptr); | ||
97 | } | ||
98 | |||
99 | // Routine called when rebuilding the body of some member of the linkset. | ||
100 | // Destroy all the constraints have have been made to root and set | ||
101 | // up to rebuild the constraints before the next simulation step. | ||
102 | // Returns 'true' of something was actually removed and would need restoring | ||
103 | // Called at taint-time!! | ||
104 | public override bool RemoveBodyDependencies(BSPrim child) | ||
105 | { | ||
106 | bool ret = false; | ||
107 | |||
108 | DetailLog("{0},BSLinksetConstraint.RemoveBodyDependencies,removeChildrenForRoot,rID={1},rBody={2}", | ||
109 | child.LocalID, LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X")); | ||
110 | |||
111 | lock (m_linksetActivityLock) | ||
112 | { | ||
113 | // Just undo all the constraints for this linkset. Rebuild at the end of the step. | ||
114 | ret = PhysicallyUnlinkAllChildrenFromRoot(LinksetRoot); | ||
115 | // Cause the constraints, et al to be rebuilt before the next simulation step. | ||
116 | Refresh(LinksetRoot); | ||
117 | } | ||
118 | return ret; | ||
119 | } | ||
120 | |||
121 | // Companion to RemoveBodyDependencies(). If RemoveBodyDependencies() returns 'true', | ||
122 | // this routine will restore the removed constraints. | ||
123 | // Called at taint-time!! | ||
124 | public override void RestoreBodyDependencies(BSPrim child) | ||
125 | { | ||
126 | // The Refresh operation queued by RemoveBodyDependencies() will build any missing constraints. | ||
127 | } | ||
128 | |||
129 | // ================================================================ | ||
130 | |||
131 | // Add a new child to the linkset. | ||
132 | // Called while LinkActivity is locked. | ||
133 | protected override void AddChildToLinkset(BSPhysObject child) | ||
134 | { | ||
135 | if (!HasChild(child)) | ||
136 | { | ||
137 | m_children.Add(child); | ||
138 | |||
139 | DetailLog("{0},BSLinksetConstraints.AddChildToLinkset,call,child={1}", LinksetRoot.LocalID, child.LocalID); | ||
140 | |||
141 | // Cause constraints and assorted properties to be recomputed before the next simulation step. | ||
142 | Refresh(LinksetRoot); | ||
143 | } | ||
144 | return; | ||
145 | } | ||
146 | |||
147 | // Remove the specified child from the linkset. | ||
148 | // Safe to call even if the child is not really in my linkset. | ||
149 | protected override void RemoveChildFromLinkset(BSPhysObject child) | ||
150 | { | ||
151 | if (m_children.Remove(child)) | ||
152 | { | ||
153 | BSPhysObject rootx = LinksetRoot; // capture the root and body as of now | ||
154 | BSPhysObject childx = child; | ||
155 | |||
156 | DetailLog("{0},BSLinksetConstraints.RemoveChildFromLinkset,call,rID={1},rBody={2},cID={3},cBody={4}", | ||
157 | childx.LocalID, | ||
158 | rootx.LocalID, rootx.PhysBody.ptr.ToString("X"), | ||
159 | childx.LocalID, childx.PhysBody.ptr.ToString("X")); | ||
160 | |||
161 | PhysicsScene.TaintedObject("BSLinksetConstraints.RemoveChildFromLinkset", delegate() | ||
162 | { | ||
163 | PhysicallyUnlinkAChildFromRoot(rootx, childx); | ||
164 | }); | ||
165 | // See that the linkset parameters are recomputed at the end of the taint time. | ||
166 | Refresh(LinksetRoot); | ||
167 | } | ||
168 | else | ||
169 | { | ||
170 | // Non-fatal occurance. | ||
171 | // PhysicsScene.Logger.ErrorFormat("{0}: Asked to remove child from linkset that was not in linkset", LogHeader); | ||
172 | } | ||
173 | return; | ||
174 | } | ||
175 | |||
176 | // Create a constraint between me (root of linkset) and the passed prim (the child). | ||
177 | // Called at taint time! | ||
178 | private void PhysicallyLinkAChildToRoot(BSPhysObject rootPrim, BSPhysObject childPrim) | ||
179 | { | ||
180 | // Don't build the constraint when asked. Put it off until just before the simulation step. | ||
181 | Refresh(rootPrim); | ||
182 | } | ||
183 | |||
184 | private BSConstraint BuildConstraint(BSPhysObject rootPrim, BSPhysObject childPrim) | ||
185 | { | ||
186 | // Zero motion for children so they don't interpolate | ||
187 | childPrim.ZeroMotion(true); | ||
188 | |||
189 | // Relative position normalized to the root prim | ||
190 | // Essentually a vector pointing from center of rootPrim to center of childPrim | ||
191 | OMV.Vector3 childRelativePosition = childPrim.Position - rootPrim.Position; | ||
192 | |||
193 | // real world coordinate of midpoint between the two objects | ||
194 | OMV.Vector3 midPoint = rootPrim.Position + (childRelativePosition / 2); | ||
195 | |||
196 | DetailLog("{0},BSLinksetConstraint.BuildConstraint,taint,root={1},rBody={2},child={3},cBody={4},rLoc={5},cLoc={6},midLoc={7}", | ||
197 | rootPrim.LocalID, | ||
198 | rootPrim.LocalID, rootPrim.PhysBody.ptr.ToString("X"), | ||
199 | childPrim.LocalID, childPrim.PhysBody.ptr.ToString("X"), | ||
200 | rootPrim.Position, childPrim.Position, midPoint); | ||
201 | |||
202 | // create a constraint that allows no freedom of movement between the two objects | ||
203 | // http://bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=4818 | ||
204 | |||
205 | BSConstraint6Dof constrain = new BSConstraint6Dof( | ||
206 | PhysicsScene.World, rootPrim.PhysBody, childPrim.PhysBody, midPoint, true, true ); | ||
207 | // PhysicsScene.World, childPrim.BSBody, rootPrim.BSBody, midPoint, true, true ); | ||
208 | |||
209 | /* NOTE: below is an attempt to build constraint with full frame computation, etc. | ||
210 | * Using the midpoint is easier since it lets the Bullet code manipulate the transforms | ||
211 | * of the objects. | ||
212 | * Code left for future programmers. | ||
213 | // ================================================================================== | ||
214 | // relative position normalized to the root prim | ||
215 | OMV.Quaternion invThisOrientation = OMV.Quaternion.Inverse(rootPrim.Orientation); | ||
216 | OMV.Vector3 childRelativePosition = (childPrim.Position - rootPrim.Position) * invThisOrientation; | ||
217 | |||
218 | // relative rotation of the child to the parent | ||
219 | OMV.Quaternion childRelativeRotation = invThisOrientation * childPrim.Orientation; | ||
220 | OMV.Quaternion inverseChildRelativeRotation = OMV.Quaternion.Inverse(childRelativeRotation); | ||
221 | |||
222 | DetailLog("{0},BSLinksetConstraint.PhysicallyLinkAChildToRoot,taint,root={1},child={2}", rootPrim.LocalID, rootPrim.LocalID, childPrim.LocalID); | ||
223 | BS6DofConstraint constrain = new BS6DofConstraint( | ||
224 | PhysicsScene.World, rootPrim.Body, childPrim.Body, | ||
225 | OMV.Vector3.Zero, | ||
226 | OMV.Quaternion.Inverse(rootPrim.Orientation), | ||
227 | OMV.Vector3.Zero, | ||
228 | OMV.Quaternion.Inverse(childPrim.Orientation), | ||
229 | true, | ||
230 | true | ||
231 | ); | ||
232 | // ================================================================================== | ||
233 | */ | ||
234 | |||
235 | PhysicsScene.Constraints.AddConstraint(constrain); | ||
236 | |||
237 | // zero linear and angular limits makes the objects unable to move in relation to each other | ||
238 | constrain.SetLinearLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); | ||
239 | constrain.SetAngularLimits(OMV.Vector3.Zero, OMV.Vector3.Zero); | ||
240 | |||
241 | // tweek the constraint to increase stability | ||
242 | constrain.UseFrameOffset(PhysicsScene.BoolNumeric(PhysicsScene.Params.linkConstraintUseFrameOffset)); | ||
243 | constrain.TranslationalLimitMotor(PhysicsScene.BoolNumeric(PhysicsScene.Params.linkConstraintEnableTransMotor), | ||
244 | PhysicsScene.Params.linkConstraintTransMotorMaxVel, | ||
245 | PhysicsScene.Params.linkConstraintTransMotorMaxForce); | ||
246 | constrain.SetCFMAndERP(PhysicsScene.Params.linkConstraintCFM, PhysicsScene.Params.linkConstraintERP); | ||
247 | if (PhysicsScene.Params.linkConstraintSolverIterations != 0f) | ||
248 | { | ||
249 | constrain.SetSolverIterations(PhysicsScene.Params.linkConstraintSolverIterations); | ||
250 | } | ||
251 | return constrain; | ||
252 | } | ||
253 | |||
254 | // Remove linkage between the linkset root and a particular child | ||
255 | // The root and child bodies are passed in because we need to remove the constraint between | ||
256 | // the bodies that were present at unlink time. | ||
257 | // Called at taint time! | ||
258 | private bool PhysicallyUnlinkAChildFromRoot(BSPhysObject rootPrim, BSPhysObject childPrim) | ||
259 | { | ||
260 | bool ret = false; | ||
261 | DetailLog("{0},BSLinksetConstraint.PhysicallyUnlinkAChildFromRoot,taint,root={1},rBody={2},child={3},cBody={4}", | ||
262 | rootPrim.LocalID, | ||
263 | rootPrim.LocalID, rootPrim.PhysBody.ptr.ToString("X"), | ||
264 | childPrim.LocalID, childPrim.PhysBody.ptr.ToString("X")); | ||
265 | |||
266 | // Find the constraint for this link and get rid of it from the overall collection and from my list | ||
267 | if (PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody, childPrim.PhysBody)) | ||
268 | { | ||
269 | // Make the child refresh its location | ||
270 | BulletSimAPI.PushUpdate2(childPrim.PhysBody.ptr); | ||
271 | ret = true; | ||
272 | } | ||
273 | |||
274 | return ret; | ||
275 | } | ||
276 | |||
277 | // Remove linkage between myself and any possible children I might have. | ||
278 | // Returns 'true' of any constraints were destroyed. | ||
279 | // Called at taint time! | ||
280 | private bool PhysicallyUnlinkAllChildrenFromRoot(BSPhysObject rootPrim) | ||
281 | { | ||
282 | DetailLog("{0},BSLinksetConstraint.PhysicallyUnlinkAllChildren,taint", rootPrim.LocalID); | ||
283 | |||
284 | return PhysicsScene.Constraints.RemoveAndDestroyConstraint(rootPrim.PhysBody); | ||
285 | } | ||
286 | |||
287 | // Call each of the constraints that make up this linkset and recompute the | ||
288 | // various transforms and variables. Create constraints of not created yet. | ||
289 | // Called before the simulation step to make sure the constraint based linkset | ||
290 | // is all initialized. | ||
291 | // Called at taint time!! | ||
292 | private void RecomputeLinksetConstraints() | ||
293 | { | ||
294 | float linksetMass = LinksetMass; | ||
295 | LinksetRoot.UpdatePhysicalMassProperties(linksetMass); | ||
296 | |||
297 | // DEBUG: see of inter-linkset collisions are causing problems | ||
298 | // BulletSimAPI.SetCollisionFilterMask2(LinksetRoot.BSBody.ptr, | ||
299 | // (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask); | ||
300 | DetailLog("{0},BSLinksetConstraint.RecomputeLinksetConstraints,set,rBody={1},linksetMass={2}", | ||
301 | LinksetRoot.LocalID, LinksetRoot.PhysBody.ptr.ToString("X"), linksetMass); | ||
302 | |||
303 | foreach (BSPhysObject child in m_children) | ||
304 | { | ||
305 | // A child in the linkset physically shows the mass of the whole linkset. | ||
306 | // This allows Bullet to apply enough force on the child to move the whole linkset. | ||
307 | // (Also do the mass stuff before recomputing the constraint so mass is not zero.) | ||
308 | child.UpdatePhysicalMassProperties(linksetMass); | ||
309 | |||
310 | BSConstraint constrain; | ||
311 | if (!PhysicsScene.Constraints.TryGetConstraint(LinksetRoot.PhysBody, child.PhysBody, out constrain)) | ||
312 | { | ||
313 | // If constraint doesn't exist yet, create it. | ||
314 | constrain = BuildConstraint(LinksetRoot, child); | ||
315 | } | ||
316 | constrain.RecomputeConstraintVariables(linksetMass); | ||
317 | |||
318 | // DEBUG: see of inter-linkset collisions are causing problems | ||
319 | // BulletSimAPI.SetCollisionFilterMask2(child.BSBody.ptr, | ||
320 | // (uint)CollisionFilterGroups.LinksetFilter, (uint)CollisionFilterGroups.LinksetMask); | ||
321 | |||
322 | // BulletSimAPI.DumpConstraint2(PhysicsScene.World.ptr, constrain.Constraint.ptr); // DEBUG DEBUG | ||
323 | } | ||
324 | |||
325 | } | ||
326 | } | ||
327 | } | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs new file mode 100755 index 0000000..bc6e4c4 --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSMotors.cs | |||
@@ -0,0 +1,104 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | using System.Text; | ||
4 | using OpenMetaverse; | ||
5 | |||
6 | namespace OpenSim.Region.Physics.BulletSPlugin | ||
7 | { | ||
8 | public abstract class BSMotor | ||
9 | { | ||
10 | public virtual void Reset() { } | ||
11 | public virtual void Zero() { } | ||
12 | } | ||
13 | // Can all the incremental stepping be replaced with motor classes? | ||
14 | public class BSVMotor : BSMotor | ||
15 | { | ||
16 | public Vector3 FrameOfReference { get; set; } | ||
17 | public Vector3 Offset { get; set; } | ||
18 | |||
19 | public float TimeScale { get; set; } | ||
20 | public float TargetValueDecayTimeScale { get; set; } | ||
21 | public Vector3 CurrentValueReductionTimescale { get; set; } | ||
22 | public float Efficiency { get; set; } | ||
23 | |||
24 | public Vector3 TargetValue { get; private set; } | ||
25 | public Vector3 CurrentValue { get; private set; } | ||
26 | |||
27 | |||
28 | |||
29 | BSVMotor(float timeScale, float decayTimeScale, Vector3 frictionTimeScale, float efficiency) | ||
30 | { | ||
31 | TimeScale = timeScale; | ||
32 | TargetValueDecayTimeScale = decayTimeScale; | ||
33 | CurrentValueReductionTimescale = frictionTimeScale; | ||
34 | Efficiency = efficiency; | ||
35 | } | ||
36 | public void SetCurrent(Vector3 current) | ||
37 | { | ||
38 | CurrentValue = current; | ||
39 | } | ||
40 | public void SetTarget(Vector3 target) | ||
41 | { | ||
42 | TargetValue = target; | ||
43 | } | ||
44 | public Vector3 Step(float timeStep) | ||
45 | { | ||
46 | if (CurrentValue.LengthSquared() > 0.001f) | ||
47 | { | ||
48 | // Vector3 origDir = Target; // DEBUG | ||
49 | // Vector3 origVel = CurrentValue; // DEBUG | ||
50 | |||
51 | // Add (desiredVelocity - currentAppliedVelocity) / howLongItShouldTakeToComplete | ||
52 | Vector3 addAmount = (TargetValue - CurrentValue)/(TargetValue) * timeStep; | ||
53 | CurrentValue += addAmount; | ||
54 | |||
55 | float decayFactor = (1.0f / TargetValueDecayTimeScale) * timeStep; | ||
56 | TargetValue *= (1f - decayFactor); | ||
57 | |||
58 | Vector3 frictionFactor = (Vector3.One / CurrentValueReductionTimescale) * timeStep; | ||
59 | CurrentValue *= (Vector3.One - frictionFactor); | ||
60 | } | ||
61 | else | ||
62 | { | ||
63 | // if what remains of direction is very small, zero it. | ||
64 | TargetValue = Vector3.Zero; | ||
65 | CurrentValue = Vector3.Zero; | ||
66 | |||
67 | // VDetailLog("{0},MoveLinear,zeroed", Prim.LocalID); | ||
68 | } | ||
69 | return CurrentValue; | ||
70 | } | ||
71 | } | ||
72 | |||
73 | public class BSFMotor : BSMotor | ||
74 | { | ||
75 | public float TimeScale { get; set; } | ||
76 | public float DecayTimeScale { get; set; } | ||
77 | public float Friction { get; set; } | ||
78 | public float Efficiency { get; set; } | ||
79 | |||
80 | public float Target { get; private set; } | ||
81 | public float CurrentValue { get; private set; } | ||
82 | |||
83 | BSFMotor(float timeScale, float decayTimescale, float friction, float efficiency) | ||
84 | { | ||
85 | } | ||
86 | public void SetCurrent(float target) | ||
87 | { | ||
88 | } | ||
89 | public void SetTarget(float target) | ||
90 | { | ||
91 | } | ||
92 | public float Step(float timeStep) | ||
93 | { | ||
94 | return 0f; | ||
95 | } | ||
96 | } | ||
97 | public class BSPIDMotor : BSMotor | ||
98 | { | ||
99 | // TODO: write and use this one | ||
100 | BSPIDMotor() | ||
101 | { | ||
102 | } | ||
103 | } | ||
104 | } | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs index ead6a08..f6a890e 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPhysObject.cs | |||
@@ -34,19 +34,30 @@ using OpenSim.Region.Physics.Manager; | |||
34 | 34 | ||
35 | namespace OpenSim.Region.Physics.BulletSPlugin | 35 | namespace OpenSim.Region.Physics.BulletSPlugin |
36 | { | 36 | { |
37 | // Class to wrap all objects. | 37 | /* |
38 | // The rest of BulletSim doesn't need to keep checking for avatars or prims | 38 | * Class to wrap all objects. |
39 | // unless the difference is significant. | 39 | * The rest of BulletSim doesn't need to keep checking for avatars or prims |
40 | * unless the difference is significant. | ||
41 | * | ||
42 | * Variables in the physicsl objects are in three forms: | ||
43 | * VariableName: used by the simulator and performs taint operations, etc | ||
44 | * RawVariableName: direct reference to the BulletSim storage for the variable value | ||
45 | * ForceVariableName: direct reference (store and fetch) to the value in the physics engine. | ||
46 | * The last two (and certainly the last one) should be referenced only in taint-time. | ||
47 | */ | ||
40 | public abstract class BSPhysObject : PhysicsActor | 48 | public abstract class BSPhysObject : PhysicsActor |
41 | { | 49 | { |
42 | protected void BaseInitialize(BSScene parentScene, uint localID, string name, string typeName) | 50 | protected BSPhysObject() |
51 | { | ||
52 | } | ||
53 | protected BSPhysObject(BSScene parentScene, uint localID, string name, string typeName) | ||
43 | { | 54 | { |
44 | PhysicsScene = parentScene; | 55 | PhysicsScene = parentScene; |
45 | LocalID = localID; | 56 | LocalID = localID; |
46 | PhysObjectName = name; | 57 | PhysObjectName = name; |
47 | TypeName = typeName; | 58 | TypeName = typeName; |
48 | 59 | ||
49 | Linkset = new BSLinkset(PhysicsScene, this); | 60 | Linkset = BSLinkset.Factory(PhysicsScene, this); |
50 | LastAssetBuildFailed = false; | 61 | LastAssetBuildFailed = false; |
51 | 62 | ||
52 | CollisionCollection = new CollisionEventUpdate(); | 63 | CollisionCollection = new CollisionEventUpdate(); |
@@ -63,12 +74,17 @@ public abstract class BSPhysObject : PhysicsActor | |||
63 | public BSLinkset Linkset { get; set; } | 74 | public BSLinkset Linkset { get; set; } |
64 | 75 | ||
65 | // Return the object mass without calculating it or having side effects | 76 | // Return the object mass without calculating it or having side effects |
66 | public abstract float MassRaw { get; } | 77 | public abstract float RawMass { get; } |
78 | // Set the raw mass but also update physical mass properties (inertia, ...) | ||
79 | public abstract void UpdatePhysicalMassProperties(float mass); | ||
80 | |||
81 | // The last value calculated for the prim's inertia | ||
82 | public OMV.Vector3 Inertia { get; set; } | ||
67 | 83 | ||
68 | // Reference to the physical body (btCollisionObject) of this object | 84 | // Reference to the physical body (btCollisionObject) of this object |
69 | public BulletBody BSBody; | 85 | public BulletBody PhysBody; |
70 | // Reference to the physical shape (btCollisionShape) of this object | 86 | // Reference to the physical shape (btCollisionShape) of this object |
71 | public BulletShape BSShape; | 87 | public BulletShape PhysShape; |
72 | 88 | ||
73 | // 'true' if the mesh's underlying asset failed to build. | 89 | // 'true' if the mesh's underlying asset failed to build. |
74 | // This will keep us from looping after the first time the build failed. | 90 | // This will keep us from looping after the first time the build failed. |
@@ -76,9 +92,15 @@ public abstract class BSPhysObject : PhysicsActor | |||
76 | 92 | ||
77 | // The objects base shape information. Null if not a prim type shape. | 93 | // The objects base shape information. Null if not a prim type shape. |
78 | public PrimitiveBaseShape BaseShape { get; protected set; } | 94 | public PrimitiveBaseShape BaseShape { get; protected set; } |
95 | // Some types of objects have preferred physical representations. | ||
96 | // Returns SHAPE_UNKNOWN if there is no preference. | ||
97 | public virtual BSPhysicsShapeType PreferredPhysicalShape | ||
98 | { | ||
99 | get { return BSPhysicsShapeType.SHAPE_UNKNOWN; } | ||
100 | } | ||
79 | 101 | ||
80 | // When the physical properties are updated, an EntityProperty holds the update values. | 102 | // When the physical properties are updated, an EntityProperty holds the update values. |
81 | // Keep the current and last EntityProperties to enable computation of differences | 103 | // Keep the current and last EntityProperties to enable computation of differences |
82 | // between the current update and the previous values. | 104 | // between the current update and the previous values. |
83 | public EntityProperties CurrentEntityProperties { get; set; } | 105 | public EntityProperties CurrentEntityProperties { get; set; } |
84 | public EntityProperties LastEntityProperties { get; set; } | 106 | public EntityProperties LastEntityProperties { get; set; } |
@@ -88,7 +110,8 @@ public abstract class BSPhysObject : PhysicsActor | |||
88 | public abstract bool IsStatic { get; } | 110 | public abstract bool IsStatic { get; } |
89 | 111 | ||
90 | // Stop all physical motion. | 112 | // Stop all physical motion. |
91 | public abstract void ZeroMotion(); | 113 | public abstract void ZeroMotion(bool inTaintTime); |
114 | public abstract void ZeroAngularMotion(bool inTaintTime); | ||
92 | 115 | ||
93 | // Step the vehicle simulation for this object. A NOOP if the vehicle was not configured. | 116 | // Step the vehicle simulation for this object. A NOOP if the vehicle was not configured. |
94 | public virtual void StepVehicle(float timeStep) { } | 117 | public virtual void StepVehicle(float timeStep) { } |
@@ -99,8 +122,10 @@ public abstract class BSPhysObject : PhysicsActor | |||
99 | // Tell the object to clean up. | 122 | // Tell the object to clean up. |
100 | public abstract void Destroy(); | 123 | public abstract void Destroy(); |
101 | 124 | ||
125 | public abstract OMV.Vector3 RawPosition { get; set; } | ||
102 | public abstract OMV.Vector3 ForcePosition { get; set; } | 126 | public abstract OMV.Vector3 ForcePosition { get; set; } |
103 | 127 | ||
128 | public abstract OMV.Quaternion RawOrientation { get; set; } | ||
104 | public abstract OMV.Quaternion ForceOrientation { get; set; } | 129 | public abstract OMV.Quaternion ForceOrientation { get; set; } |
105 | 130 | ||
106 | public abstract OMV.Vector3 ForceVelocity { get; set; } | 131 | public abstract OMV.Vector3 ForceVelocity { get; set; } |
@@ -204,7 +229,7 @@ public abstract class BSPhysObject : PhysicsActor | |||
204 | 229 | ||
205 | PhysicsScene.TaintedObject(TypeName+".SubscribeEvents", delegate() | 230 | PhysicsScene.TaintedObject(TypeName+".SubscribeEvents", delegate() |
206 | { | 231 | { |
207 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 232 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
208 | }); | 233 | }); |
209 | } | 234 | } |
210 | else | 235 | else |
@@ -213,16 +238,16 @@ public abstract class BSPhysObject : PhysicsActor | |||
213 | UnSubscribeEvents(); | 238 | UnSubscribeEvents(); |
214 | } | 239 | } |
215 | } | 240 | } |
216 | public override void UnSubscribeEvents() { | 241 | public override void UnSubscribeEvents() { |
217 | // DetailLog("{0},{1}.UnSubscribeEvents,unsubscribing", LocalID, TypeName); | 242 | // DetailLog("{0},{1}.UnSubscribeEvents,unsubscribing", LocalID, TypeName); |
218 | SubscribedEventsMs = 0; | 243 | SubscribedEventsMs = 0; |
219 | PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate() | 244 | PhysicsScene.TaintedObject(TypeName+".UnSubscribeEvents", delegate() |
220 | { | 245 | { |
221 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 246 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
222 | }); | 247 | }); |
223 | } | 248 | } |
224 | // Return 'true' if the simulator wants collision events | 249 | // Return 'true' if the simulator wants collision events |
225 | public override bool SubscribedEvents() { | 250 | public override bool SubscribedEvents() { |
226 | return (SubscribedEventsMs > 0); | 251 | return (SubscribedEventsMs > 0); |
227 | } | 252 | } |
228 | 253 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index aeeb4dd..2b3fa25 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -25,8 +25,6 @@ | |||
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 | // Uncomment this it enable code to do all shape an body memory management | ||
29 | // in the C# code. | ||
30 | using System; | 28 | using System; |
31 | using System.Reflection; | 29 | using System.Reflection; |
32 | using System.Collections.Generic; | 30 | using System.Collections.Generic; |
@@ -49,7 +47,6 @@ public sealed class BSPrim : BSPhysObject | |||
49 | // _size is what the user passed. Scale is what we pass to the physics engine with the mesh. | 47 | // _size is what the user passed. Scale is what we pass to the physics engine with the mesh. |
50 | // Often Scale is unity because the meshmerizer will apply _size when creating the mesh. | 48 | // Often Scale is unity because the meshmerizer will apply _size when creating the mesh. |
51 | private OMV.Vector3 _size; // the multiplier for each mesh dimension as passed by the user | 49 | private OMV.Vector3 _size; // the multiplier for each mesh dimension as passed by the user |
52 | // private OMV.Vector3 _scale; // the multiplier for each mesh dimension for the mesh as created by the meshmerizer | ||
53 | 50 | ||
54 | private bool _grabbed; | 51 | private bool _grabbed; |
55 | private bool _isSelected; | 52 | private bool _isSelected; |
@@ -90,13 +87,13 @@ public sealed class BSPrim : BSPhysObject | |||
90 | 87 | ||
91 | public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, | 88 | public BSPrim(uint localID, String primName, BSScene parent_scene, OMV.Vector3 pos, OMV.Vector3 size, |
92 | OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) | 89 | OMV.Quaternion rotation, PrimitiveBaseShape pbs, bool pisPhysical) |
90 | : base(parent_scene, localID, primName, "BSPrim") | ||
93 | { | 91 | { |
94 | // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID); | 92 | // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID); |
95 | base.BaseInitialize(parent_scene, localID, primName, "BSPrim"); | ||
96 | _physicsActorType = (int)ActorTypes.Prim; | 93 | _physicsActorType = (int)ActorTypes.Prim; |
97 | _position = pos; | 94 | _position = pos; |
98 | _size = size; | 95 | _size = size; |
99 | Scale = new OMV.Vector3(1f, 1f, 1f); // the scale will be set by CreateGeom depending on object type | 96 | Scale = size; // the scale will be set by CreateGeom depending on object type |
100 | _orientation = rotation; | 97 | _orientation = rotation; |
101 | _buoyancy = 1f; | 98 | _buoyancy = 1f; |
102 | _velocity = OMV.Vector3.Zero; | 99 | _velocity = OMV.Vector3.Zero; |
@@ -111,8 +108,8 @@ public sealed class BSPrim : BSPhysObject | |||
111 | _mass = CalculateMass(); | 108 | _mass = CalculateMass(); |
112 | 109 | ||
113 | // No body or shape yet | 110 | // No body or shape yet |
114 | BSBody = new BulletBody(LocalID, IntPtr.Zero); | 111 | PhysBody = new BulletBody(LocalID, IntPtr.Zero); |
115 | BSShape = new BulletShape(IntPtr.Zero); | 112 | PhysShape = new BulletShape(IntPtr.Zero); |
116 | 113 | ||
117 | DetailLog("{0},BSPrim.constructor,call", LocalID); | 114 | DetailLog("{0},BSPrim.constructor,call", LocalID); |
118 | // do the actual object creation at taint time | 115 | // do the actual object creation at taint time |
@@ -120,7 +117,7 @@ public sealed class BSPrim : BSPhysObject | |||
120 | { | 117 | { |
121 | CreateGeomAndObject(true); | 118 | CreateGeomAndObject(true); |
122 | 119 | ||
123 | CurrentCollisionFlags = BulletSimAPI.GetCollisionFlags2(BSBody.ptr); | 120 | CurrentCollisionFlags = BulletSimAPI.GetCollisionFlags2(PhysBody.ptr); |
124 | }); | 121 | }); |
125 | } | 122 | } |
126 | 123 | ||
@@ -145,8 +142,8 @@ public sealed class BSPrim : BSPhysObject | |||
145 | { | 142 | { |
146 | DetailLog("{0},BSPrim.Destroy,taint,", LocalID); | 143 | DetailLog("{0},BSPrim.Destroy,taint,", LocalID); |
147 | // If there are physical body and shape, release my use of same. | 144 | // If there are physical body and shape, release my use of same. |
148 | PhysicsScene.Shapes.DereferenceBody(BSBody, true, null); | 145 | PhysicsScene.Shapes.DereferenceBody(PhysBody, true, null); |
149 | PhysicsScene.Shapes.DereferenceShape(BSShape, true, null); | 146 | PhysicsScene.Shapes.DereferenceShape(PhysShape, true, null); |
150 | }); | 147 | }); |
151 | } | 148 | } |
152 | 149 | ||
@@ -157,6 +154,8 @@ public sealed class BSPrim : BSPhysObject | |||
157 | public override OMV.Vector3 Size { | 154 | public override OMV.Vector3 Size { |
158 | get { return _size; } | 155 | get { return _size; } |
159 | set { | 156 | set { |
157 | // We presume the scale and size are the same. If scale must be changed for | ||
158 | // the physical shape, that is done when the geometry is built. | ||
160 | _size = value; | 159 | _size = value; |
161 | ForceBodyShapeRebuild(false); | 160 | ForceBodyShapeRebuild(false); |
162 | } | 161 | } |
@@ -171,17 +170,18 @@ public sealed class BSPrim : BSPhysObject | |||
171 | ForceBodyShapeRebuild(false); | 170 | ForceBodyShapeRebuild(false); |
172 | } | 171 | } |
173 | } | 172 | } |
173 | // Whatever the linkset wants is what I want. | ||
174 | public override BSPhysicsShapeType PreferredPhysicalShape | ||
175 | { get { return Linkset.PreferredPhysicalShape(this); } } | ||
176 | |||
174 | public override bool ForceBodyShapeRebuild(bool inTaintTime) | 177 | public override bool ForceBodyShapeRebuild(bool inTaintTime) |
175 | { | 178 | { |
176 | BSScene.TaintCallback rebuildOperation = delegate() | 179 | LastAssetBuildFailed = false; |
180 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ForceBodyShapeRebuild", delegate() | ||
177 | { | 181 | { |
178 | _mass = CalculateMass(); // changing the shape changes the mass | 182 | _mass = CalculateMass(); // changing the shape changes the mass |
179 | CreateGeomAndObject(true); | 183 | CreateGeomAndObject(true); |
180 | }; | 184 | }); |
181 | if (inTaintTime) | ||
182 | rebuildOperation(); | ||
183 | else | ||
184 | PhysicsScene.TaintedObject("BSPrim.ForceBodyShapeRebuild", rebuildOperation); | ||
185 | return true; | 185 | return true; |
186 | } | 186 | } |
187 | public override bool Grabbed { | 187 | public override bool Grabbed { |
@@ -235,14 +235,27 @@ public sealed class BSPrim : BSPhysObject | |||
235 | // Do it to the properties so the values get set in the physics engine. | 235 | // Do it to the properties so the values get set in the physics engine. |
236 | // Push the setting of the values to the viewer. | 236 | // Push the setting of the values to the viewer. |
237 | // Called at taint time! | 237 | // Called at taint time! |
238 | public override void ZeroMotion() | 238 | public override void ZeroMotion(bool inTaintTime) |
239 | { | 239 | { |
240 | _velocity = OMV.Vector3.Zero; | 240 | _velocity = OMV.Vector3.Zero; |
241 | _acceleration = OMV.Vector3.Zero; | 241 | _acceleration = OMV.Vector3.Zero; |
242 | _rotationalVelocity = OMV.Vector3.Zero; | 242 | _rotationalVelocity = OMV.Vector3.Zero; |
243 | 243 | ||
244 | // Zero some other properties directly into the physics engine | 244 | // Zero some other properties in the physics engine |
245 | BulletSimAPI.ClearForces2(BSBody.ptr); | 245 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() |
246 | { | ||
247 | BulletSimAPI.ClearAllForces2(PhysBody.ptr); | ||
248 | }); | ||
249 | } | ||
250 | public override void ZeroAngularMotion(bool inTaintTime) | ||
251 | { | ||
252 | _rotationalVelocity = OMV.Vector3.Zero; | ||
253 | // Zero some other properties in the physics engine | ||
254 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ZeroMotion", delegate() | ||
255 | { | ||
256 | BulletSimAPI.SetInterpolationAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero); | ||
257 | BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, OMV.Vector3.Zero); | ||
258 | }); | ||
246 | } | 259 | } |
247 | 260 | ||
248 | public override void LockAngularMotion(OMV.Vector3 axis) | 261 | public override void LockAngularMotion(OMV.Vector3 axis) |
@@ -251,97 +264,91 @@ public sealed class BSPrim : BSPhysObject | |||
251 | return; | 264 | return; |
252 | } | 265 | } |
253 | 266 | ||
267 | public override OMV.Vector3 RawPosition | ||
268 | { | ||
269 | get { return _position; } | ||
270 | set { _position = value; } | ||
271 | } | ||
254 | public override OMV.Vector3 Position { | 272 | public override OMV.Vector3 Position { |
255 | get { | 273 | get { |
274 | // child prims move around based on their parent. Need to get the latest location | ||
256 | if (!Linkset.IsRoot(this)) | 275 | if (!Linkset.IsRoot(this)) |
257 | // child prims move around based on their parent. Need to get the latest location | 276 | _position = Linkset.Position(this); |
258 | _position = BulletSimAPI.GetPosition2(BSBody.ptr); | ||
259 | 277 | ||
260 | // don't do the GetObjectPosition for root elements because this function is called a zillion times | 278 | // don't do the GetObjectPosition for root elements because this function is called a zillion times. |
261 | // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); | 279 | // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); |
262 | return _position; | 280 | return _position; |
263 | } | 281 | } |
264 | set { | 282 | set { |
265 | // If you must push the position into the physics engine, use ForcePosition. | 283 | // If the position must be forced into the physics engine, use ForcePosition. |
266 | if (_position == value) | 284 | if (_position == value) |
267 | { | 285 | { |
268 | return; | 286 | return; |
269 | } | 287 | } |
270 | _position = value; | 288 | _position = value; |
271 | // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint? | 289 | // TODO: what does it mean to set the position of a child prim?? Rebuild the constraint? |
272 | PositionSanityCheck(); | 290 | PositionSanityCheck(false); |
273 | PhysicsScene.TaintedObject("BSPrim.setPosition", delegate() | 291 | PhysicsScene.TaintedObject("BSPrim.setPosition", delegate() |
274 | { | 292 | { |
275 | // DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 293 | // DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
276 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | 294 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); |
295 | ActivateIfPhysical(false); | ||
277 | }); | 296 | }); |
278 | } | 297 | } |
279 | } | 298 | } |
280 | public override OMV.Vector3 ForcePosition { | 299 | public override OMV.Vector3 ForcePosition { |
281 | get { | 300 | get { |
282 | _position = BulletSimAPI.GetPosition2(BSBody.ptr); | 301 | _position = BulletSimAPI.GetPosition2(PhysBody.ptr); |
283 | return _position; | 302 | return _position; |
284 | } | 303 | } |
285 | set { | 304 | set { |
286 | _position = value; | 305 | _position = value; |
287 | PositionSanityCheck(); | 306 | // PositionSanityCheck(); // Don't do this! Causes a loop and caller should know better. |
288 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | 307 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); |
308 | ActivateIfPhysical(false); | ||
289 | } | 309 | } |
290 | } | 310 | } |
291 | 311 | ||
292 | // Check that the current position is sane and, if not, modify the position to make it so. | 312 | // Check that the current position is sane and, if not, modify the position to make it so. |
293 | // Check for being below terrain and being out of bounds. | 313 | // Check for being below terrain and being out of bounds. |
294 | // Returns 'true' of the position was made sane by some action. | 314 | // Returns 'true' of the position was made sane by some action. |
295 | private bool PositionSanityCheck() | 315 | private bool PositionSanityCheck(bool inTaintTime) |
296 | { | 316 | { |
297 | bool ret = false; | 317 | bool ret = false; |
298 | 318 | ||
299 | // If totally below the ground, move the prim up | ||
300 | // TODO: figure out the right solution for this... only for dynamic objects? | ||
301 | /* | ||
302 | float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position); | 319 | float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position); |
320 | OMV.Vector3 upForce = OMV.Vector3.Zero; | ||
303 | if (Position.Z < terrainHeight) | 321 | if (Position.Z < terrainHeight) |
304 | { | 322 | { |
305 | DetailLog("{0},BSPrim.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, _position, terrainHeight); | 323 | DetailLog("{0},BSPrim.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, _position, terrainHeight); |
306 | _position.Z = terrainHeight + 2.0f; | 324 | float targetHeight = terrainHeight + (Size.Z / 2f); |
325 | // Upforce proportional to the distance away from the terrain. Correct the error in 1 sec. | ||
326 | upForce.Z = (terrainHeight - Position.Z) * 1f; | ||
307 | ret = true; | 327 | ret = true; |
308 | } | 328 | } |
309 | */ | 329 | |
310 | if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) | 330 | if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) |
311 | { | 331 | { |
312 | float waterHeight = PhysicsScene.GetWaterLevelAtXYZ(_position); | 332 | float waterHeight = PhysicsScene.GetWaterLevelAtXYZ(_position); |
313 | if (Position.Z < waterHeight) | 333 | // TODO: a floating motor so object will bob in the water |
334 | if (Math.Abs(Position.Z - waterHeight) > 0.1f) | ||
314 | { | 335 | { |
315 | _position.Z = waterHeight; | 336 | // Upforce proportional to the distance away from the water. Correct the error in 1 sec. |
337 | upForce.Z = (waterHeight - Position.Z) * 1f; | ||
316 | ret = true; | 338 | ret = true; |
317 | } | 339 | } |
318 | } | 340 | } |
319 | 341 | ||
320 | // TODO: check for out of bounds | 342 | // TODO: check for out of bounds |
321 | return ret; | ||
322 | } | ||
323 | 343 | ||
324 | // A version of the sanity check that also makes sure a new position value is | 344 | // The above code computes a force to apply to correct any out-of-bounds problems. Apply same. |
325 | // pushed to the physics engine. This routine would be used by anyone | 345 | if (ret) |
326 | // who is not already pushing the value. | ||
327 | private bool PositionSanityCheck(bool inTaintTime) | ||
328 | { | ||
329 | bool ret = false; | ||
330 | if (PositionSanityCheck()) | ||
331 | { | 346 | { |
332 | // The new position value must be pushed into the physics engine but we can't | 347 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.PositionSanityCheck:belowTerrain", delegate() |
333 | // just assign to "Position" because of potential call loops. | ||
334 | BSScene.TaintCallback sanityOperation = delegate() | ||
335 | { | 348 | { |
336 | DetailLog("{0},BSPrim.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 349 | // Apply upforce and overcome gravity. |
337 | ForcePosition = _position; | 350 | ForceVelocity = ForceVelocity + upForce - PhysicsScene.DefaultGravity; |
338 | }; | 351 | }); |
339 | if (inTaintTime) | ||
340 | sanityOperation(); | ||
341 | else | ||
342 | PhysicsScene.TaintedObject("BSPrim.PositionSanityCheck", sanityOperation); | ||
343 | |||
344 | ret = true; | ||
345 | } | 352 | } |
346 | return ret; | 353 | return ret; |
347 | } | 354 | } |
@@ -352,13 +359,35 @@ public sealed class BSPrim : BSPhysObject | |||
352 | { | 359 | { |
353 | get | 360 | get |
354 | { | 361 | { |
355 | // return Linkset.LinksetMass; | 362 | return Linkset.LinksetMass; |
356 | return _mass; | 363 | // return _mass; |
357 | } | 364 | } |
358 | } | 365 | } |
359 | 366 | ||
360 | // used when we only want this prim's mass and not the linkset thing | 367 | // used when we only want this prim's mass and not the linkset thing |
361 | public override float MassRaw { get { return _mass; } } | 368 | public override float RawMass { |
369 | get { return _mass; } | ||
370 | } | ||
371 | // Set the physical mass to the passed mass. | ||
372 | // Note that this does not change _mass! | ||
373 | public override void UpdatePhysicalMassProperties(float physMass) | ||
374 | { | ||
375 | if (IsStatic) | ||
376 | { | ||
377 | Inertia = OMV.Vector3.Zero; | ||
378 | BulletSimAPI.SetMassProps2(PhysBody.ptr, 0f, Inertia); | ||
379 | BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr); | ||
380 | } | ||
381 | else | ||
382 | { | ||
383 | Inertia = BulletSimAPI.CalculateLocalInertia2(PhysShape.ptr, physMass); | ||
384 | BulletSimAPI.SetMassProps2(PhysBody.ptr, physMass, Inertia); | ||
385 | BulletSimAPI.UpdateInertiaTensor2(PhysBody.ptr); | ||
386 | // center of mass is at the zero of the object | ||
387 | // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(PhysBody.ptr, ForcePosition, ForceOrientation); | ||
388 | DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2}", LocalID, physMass, Inertia); | ||
389 | } | ||
390 | } | ||
362 | 391 | ||
363 | // Is this used? | 392 | // Is this used? |
364 | public override OMV.Vector3 CenterOfMass | 393 | public override OMV.Vector3 CenterOfMass |
@@ -379,7 +408,7 @@ public sealed class BSPrim : BSPhysObject | |||
379 | PhysicsScene.TaintedObject("BSPrim.setForce", delegate() | 408 | PhysicsScene.TaintedObject("BSPrim.setForce", delegate() |
380 | { | 409 | { |
381 | // DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force); | 410 | // DetailLog("{0},BSPrim.setForce,taint,force={1}", LocalID, _force); |
382 | BulletSimAPI.SetObjectForce2(BSBody.ptr, _force); | 411 | BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force); |
383 | }); | 412 | }); |
384 | } | 413 | } |
385 | } | 414 | } |
@@ -398,7 +427,8 @@ public sealed class BSPrim : BSPhysObject | |||
398 | { | 427 | { |
399 | // Done at taint time so we're sure the physics engine is not using the variables | 428 | // Done at taint time so we're sure the physics engine is not using the variables |
400 | // Vehicle code changes the parameters for this vehicle type. | 429 | // Vehicle code changes the parameters for this vehicle type. |
401 | this._vehicle.ProcessTypeChange(type); | 430 | _vehicle.ProcessTypeChange(type); |
431 | ActivateIfPhysical(false); | ||
402 | }); | 432 | }); |
403 | } | 433 | } |
404 | } | 434 | } |
@@ -407,6 +437,7 @@ public sealed class BSPrim : BSPhysObject | |||
407 | PhysicsScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() | 437 | PhysicsScene.TaintedObject("BSPrim.VehicleFloatParam", delegate() |
408 | { | 438 | { |
409 | _vehicle.ProcessFloatVehicleParam((Vehicle)param, value); | 439 | _vehicle.ProcessFloatVehicleParam((Vehicle)param, value); |
440 | ActivateIfPhysical(false); | ||
410 | }); | 441 | }); |
411 | } | 442 | } |
412 | public override void VehicleVectorParam(int param, OMV.Vector3 value) | 443 | public override void VehicleVectorParam(int param, OMV.Vector3 value) |
@@ -414,6 +445,7 @@ public sealed class BSPrim : BSPhysObject | |||
414 | PhysicsScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() | 445 | PhysicsScene.TaintedObject("BSPrim.VehicleVectorParam", delegate() |
415 | { | 446 | { |
416 | _vehicle.ProcessVectorVehicleParam((Vehicle)param, value); | 447 | _vehicle.ProcessVectorVehicleParam((Vehicle)param, value); |
448 | ActivateIfPhysical(false); | ||
417 | }); | 449 | }); |
418 | } | 450 | } |
419 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) | 451 | public override void VehicleRotationParam(int param, OMV.Quaternion rotation) |
@@ -421,6 +453,7 @@ public sealed class BSPrim : BSPhysObject | |||
421 | PhysicsScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() | 453 | PhysicsScene.TaintedObject("BSPrim.VehicleRotationParam", delegate() |
422 | { | 454 | { |
423 | _vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); | 455 | _vehicle.ProcessRotationVehicleParam((Vehicle)param, rotation); |
456 | ActivateIfPhysical(false); | ||
424 | }); | 457 | }); |
425 | } | 458 | } |
426 | public override void VehicleFlags(int param, bool remove) | 459 | public override void VehicleFlags(int param, bool remove) |
@@ -435,9 +468,16 @@ public sealed class BSPrim : BSPhysObject | |||
435 | // Called from Scene when doing simulation step so we're in taint processing time. | 468 | // Called from Scene when doing simulation step so we're in taint processing time. |
436 | public override void StepVehicle(float timeStep) | 469 | public override void StepVehicle(float timeStep) |
437 | { | 470 | { |
438 | if (IsPhysical) | 471 | if (IsPhysical && _vehicle.IsActive) |
439 | { | 472 | { |
440 | _vehicle.Step(timeStep); | 473 | _vehicle.Step(timeStep); |
474 | /* // TEST TEST DEBUG DEBUG -- trying to reduce the extra action of Bullet simulation step | ||
475 | PhysicsScene.PostTaintObject("BSPrim.StepVehicles", LocalID, delegate() | ||
476 | { | ||
477 | // This resets the interpolation values and recomputes the tensor variables | ||
478 | BulletSimAPI.SetCenterOfMassByPosRot2(BSBody.ptr, ForcePosition, ForceOrientation); | ||
479 | }); | ||
480 | */ | ||
441 | } | 481 | } |
442 | } | 482 | } |
443 | 483 | ||
@@ -462,7 +502,7 @@ public sealed class BSPrim : BSPhysObject | |||
462 | PhysicsScene.TaintedObject("BSPrim.setVelocity", delegate() | 502 | PhysicsScene.TaintedObject("BSPrim.setVelocity", delegate() |
463 | { | 503 | { |
464 | // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity); | 504 | // DetailLog("{0},BSPrim.SetVelocity,taint,vel={1}", LocalID, _velocity); |
465 | BulletSimAPI.SetLinearVelocity2(BSBody.ptr, _velocity); | 505 | BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity); |
466 | }); | 506 | }); |
467 | } | 507 | } |
468 | } | 508 | } |
@@ -470,12 +510,14 @@ public sealed class BSPrim : BSPhysObject | |||
470 | get { return _velocity; } | 510 | get { return _velocity; } |
471 | set { | 511 | set { |
472 | _velocity = value; | 512 | _velocity = value; |
473 | BulletSimAPI.SetLinearVelocity2(BSBody.ptr, _velocity); | 513 | BulletSimAPI.SetLinearVelocity2(PhysBody.ptr, _velocity); |
474 | } | 514 | } |
475 | } | 515 | } |
476 | public override OMV.Vector3 Torque { | 516 | public override OMV.Vector3 Torque { |
477 | get { return _torque; } | 517 | get { return _torque; } |
478 | set { _torque = value; | 518 | set { |
519 | _torque = value; | ||
520 | AddAngularForce(_torque, false, false); | ||
479 | // DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque); | 521 | // DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque); |
480 | } | 522 | } |
481 | } | 523 | } |
@@ -488,12 +530,17 @@ public sealed class BSPrim : BSPhysObject | |||
488 | get { return _acceleration; } | 530 | get { return _acceleration; } |
489 | set { _acceleration = value; } | 531 | set { _acceleration = value; } |
490 | } | 532 | } |
533 | public override OMV.Quaternion RawOrientation | ||
534 | { | ||
535 | get { return _orientation; } | ||
536 | set { _orientation = value; } | ||
537 | } | ||
491 | public override OMV.Quaternion Orientation { | 538 | public override OMV.Quaternion Orientation { |
492 | get { | 539 | get { |
540 | // Children move around because tied to parent. Get a fresh value. | ||
493 | if (!Linkset.IsRoot(this)) | 541 | if (!Linkset.IsRoot(this)) |
494 | { | 542 | { |
495 | // Children move around because tied to parent. Get a fresh value. | 543 | _orientation = Linkset.Orientation(this); |
496 | _orientation = BulletSimAPI.GetOrientation2(BSBody.ptr); | ||
497 | } | 544 | } |
498 | return _orientation; | 545 | return _orientation; |
499 | } | 546 | } |
@@ -506,22 +553,22 @@ public sealed class BSPrim : BSPhysObject | |||
506 | { | 553 | { |
507 | // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); | 554 | // _position = BulletSimAPI.GetObjectPosition2(PhysicsScene.World.ptr, BSBody.ptr); |
508 | // DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); | 555 | // DetailLog("{0},BSPrim.setOrientation,taint,pos={1},orient={2}", LocalID, _position, _orientation); |
509 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | 556 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); |
510 | }); | 557 | }); |
511 | } | 558 | } |
512 | } | 559 | } |
513 | // Go directly to Bullet to get/set the value. | 560 | // Go directly to Bullet to get/set the value. |
514 | public override OMV.Quaternion ForceOrientation | 561 | public override OMV.Quaternion ForceOrientation |
515 | { | 562 | { |
516 | get | 563 | get |
517 | { | 564 | { |
518 | _orientation = BulletSimAPI.GetOrientation2(BSBody.ptr); | 565 | _orientation = BulletSimAPI.GetOrientation2(PhysBody.ptr); |
519 | return _orientation; | 566 | return _orientation; |
520 | } | 567 | } |
521 | set | 568 | set |
522 | { | 569 | { |
523 | _orientation = value; | 570 | _orientation = value; |
524 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | 571 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); |
525 | } | 572 | } |
526 | } | 573 | } |
527 | public override int PhysicsActorType { | 574 | public override int PhysicsActorType { |
@@ -538,6 +585,8 @@ public sealed class BSPrim : BSPhysObject | |||
538 | { | 585 | { |
539 | // DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical); | 586 | // DetailLog("{0},setIsPhysical,taint,isPhys={1}", LocalID, _isPhysical); |
540 | SetObjectDynamic(true); | 587 | SetObjectDynamic(true); |
588 | // whether phys-to-static or static-to-phys, the object is not moving. | ||
589 | ZeroMotion(true); | ||
541 | }); | 590 | }); |
542 | } | 591 | } |
543 | } | 592 | } |
@@ -575,7 +624,7 @@ public sealed class BSPrim : BSPhysObject | |||
575 | 624 | ||
576 | // Mangling all the physical properties requires the object not be in the physical world. | 625 | // Mangling all the physical properties requires the object not be in the physical world. |
577 | // This is a NOOP if the object is not in the world (BulletSim and Bullet ignore objects not found). | 626 | // This is a NOOP if the object is not in the world (BulletSim and Bullet ignore objects not found). |
578 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, BSBody.ptr); | 627 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, PhysBody.ptr); |
579 | 628 | ||
580 | // Set up the object physicalness (does gravity and collisions move this object) | 629 | // Set up the object physicalness (does gravity and collisions move this object) |
581 | MakeDynamic(IsStatic); | 630 | MakeDynamic(IsStatic); |
@@ -589,24 +638,25 @@ public sealed class BSPrim : BSPhysObject | |||
589 | // Make solid or not (do things bounce off or pass through this object). | 638 | // Make solid or not (do things bounce off or pass through this object). |
590 | MakeSolid(IsSolid); | 639 | MakeSolid(IsSolid); |
591 | 640 | ||
592 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, BSBody.ptr); | 641 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, PhysBody.ptr); |
593 | 642 | ||
594 | // Rebuild its shape | 643 | // Rebuild its shape |
595 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, BSBody.ptr); | 644 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, PhysBody.ptr); |
596 | 645 | ||
597 | // Collision filter can be set only when the object is in the world | 646 | // Collision filter can be set only when the object is in the world |
598 | if (BSBody.collisionFilter != 0 || BSBody.collisionMask != 0) | 647 | if (PhysBody.collisionFilter != 0 || PhysBody.collisionMask != 0) |
599 | { | 648 | { |
600 | BulletSimAPI.SetCollisionFilterMask2(BSBody.ptr, (uint)BSBody.collisionFilter, (uint)BSBody.collisionMask); | 649 | BulletSimAPI.SetCollisionFilterMask2(PhysBody.ptr, (uint)PhysBody.collisionFilter, (uint)PhysBody.collisionMask); |
601 | } | 650 | } |
602 | 651 | ||
603 | // Recompute any linkset parameters. | 652 | // Recompute any linkset parameters. |
604 | // When going from non-physical to physical, this re-enables the constraints that | 653 | // When going from non-physical to physical, this re-enables the constraints that |
605 | // had been automatically disabled when the mass was set to zero. | 654 | // had been automatically disabled when the mass was set to zero. |
606 | Linkset.Refresh(this, true); | 655 | // For compound based linksets, this enables and disables interactions of the children. |
656 | Linkset.Refresh(this); | ||
607 | 657 | ||
608 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,exit,static={1},solid={2},mass={3},collide={4},cf={5:X},body={6},shape={7}", | 658 | DetailLog("{0},BSPrim.UpdatePhysicalParameters,taintExit,static={1},solid={2},mass={3},collide={4},cf={5:X},body={6},shape={7}", |
609 | LocalID, IsStatic, IsSolid, _mass, SubscribedEvents(), CurrentCollisionFlags, BSBody, BSShape); | 659 | LocalID, IsStatic, IsSolid, _mass, SubscribedEvents(), CurrentCollisionFlags, PhysBody, PhysShape); |
610 | } | 660 | } |
611 | 661 | ||
612 | // "Making dynamic" means changing to and from static. | 662 | // "Making dynamic" means changing to and from static. |
@@ -619,75 +669,74 @@ public sealed class BSPrim : BSPhysObject | |||
619 | if (makeStatic) | 669 | if (makeStatic) |
620 | { | 670 | { |
621 | // Become a Bullet 'static' object type | 671 | // Become a Bullet 'static' object type |
622 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.CF_STATIC_OBJECT); | 672 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT); |
623 | // Stop all movement | 673 | // Stop all movement |
624 | BulletSimAPI.ClearAllForces2(BSBody.ptr); | 674 | ZeroMotion(true); |
625 | // Center of mass is at the center of the object | 675 | // Center of mass is at the center of the object |
626 | BulletSimAPI.SetCenterOfMassByPosRot2(Linkset.LinksetRoot.BSBody.ptr, _position, _orientation); | 676 | // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(Linkset.LinksetRoot.PhysBody.ptr, _position, _orientation); |
627 | // Mass is zero which disables a bunch of physics stuff in Bullet | 677 | // Mass is zero which disables a bunch of physics stuff in Bullet |
628 | BulletSimAPI.SetMassProps2(BSBody.ptr, 0f, OMV.Vector3.Zero); | 678 | UpdatePhysicalMassProperties(0f); |
629 | // There is no inertia in a static object | ||
630 | BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr); | ||
631 | // Set collision detection parameters | 679 | // Set collision detection parameters |
632 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) | 680 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) |
633 | { | 681 | { |
634 | BulletSimAPI.SetCcdMotionThreshold2(BSBody.ptr, PhysicsScene.Params.ccdMotionThreshold); | 682 | BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, PhysicsScene.Params.ccdMotionThreshold); |
635 | BulletSimAPI.SetCcdSweepSphereRadius2(BSBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); | 683 | BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); |
636 | } | 684 | } |
637 | // There can be special things needed for implementing linksets | 685 | // There can be special things needed for implementing linksets |
638 | Linkset.MakeStatic(this); | 686 | Linkset.MakeStatic(this); |
639 | // The activation state is 'disabled' so Bullet will not try to act on it. | 687 | // The activation state is 'disabled' so Bullet will not try to act on it. |
640 | BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.DISABLE_SIMULATION); | 688 | BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.DISABLE_SIMULATION); |
641 | // Start it out sleeping and physical actions could wake it up. | 689 | // Start it out sleeping and physical actions could wake it up. |
642 | // BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ISLAND_SLEEPING); | 690 | // BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ISLAND_SLEEPING); |
643 | 691 | ||
644 | BSBody.collisionFilter = CollisionFilterGroups.StaticObjectFilter; | 692 | PhysBody.collisionFilter = CollisionFilterGroups.StaticObjectFilter; |
645 | BSBody.collisionMask = CollisionFilterGroups.StaticObjectMask; | 693 | PhysBody.collisionMask = CollisionFilterGroups.StaticObjectMask; |
646 | } | 694 | } |
647 | else | 695 | else |
648 | { | 696 | { |
649 | // Not a Bullet static object | 697 | // Not a Bullet static object |
650 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.ptr, CollisionFlags.CF_STATIC_OBJECT); | 698 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_STATIC_OBJECT); |
651 | 699 | ||
652 | // Set various physical properties so internal dynamic properties will get computed correctly as they are set | 700 | // Set various physical properties so internal dynamic properties will get computed correctly as they are set |
653 | BulletSimAPI.SetFriction2(BSBody.ptr, PhysicsScene.Params.defaultFriction); | 701 | BulletSimAPI.SetFriction2(PhysBody.ptr, PhysicsScene.Params.defaultFriction); |
654 | BulletSimAPI.SetRestitution2(BSBody.ptr, PhysicsScene.Params.defaultRestitution); | 702 | BulletSimAPI.SetRestitution2(PhysBody.ptr, PhysicsScene.Params.defaultRestitution); |
655 | 703 | ||
656 | // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382 | 704 | // per http://www.bulletphysics.org/Bullet/phpBB3/viewtopic.php?t=3382 |
657 | BulletSimAPI.ClearAllForces2(BSBody.ptr); | 705 | // Since this can be called multiple times, only zero forces when becoming physical |
706 | // BulletSimAPI.ClearAllForces2(BSBody.ptr); | ||
658 | 707 | ||
659 | // For good measure, make sure the transform is set through to the motion state | 708 | // For good measure, make sure the transform is set through to the motion state |
660 | BulletSimAPI.SetTranslation2(BSBody.ptr, _position, _orientation); | 709 | BulletSimAPI.SetTranslation2(PhysBody.ptr, _position, _orientation); |
710 | |||
711 | // Center of mass is at the center of the object | ||
712 | // DEBUG DEBUG BulletSimAPI.SetCenterOfMassByPosRot2(Linkset.LinksetRoot.PhysBody.ptr, _position, _orientation); | ||
661 | 713 | ||
662 | // A dynamic object has mass | 714 | // A dynamic object has mass |
663 | IntPtr collisionShapePtr = BulletSimAPI.GetCollisionShape2(BSBody.ptr); | 715 | UpdatePhysicalMassProperties(RawMass); |
664 | OMV.Vector3 inertia = BulletSimAPI.CalculateLocalInertia2(collisionShapePtr, Mass); | ||
665 | BulletSimAPI.SetMassProps2(BSBody.ptr, _mass, inertia); | ||
666 | BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr); | ||
667 | 716 | ||
668 | // Set collision detection parameters | 717 | // Set collision detection parameters |
669 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) | 718 | if (PhysicsScene.Params.ccdMotionThreshold > 0f) |
670 | { | 719 | { |
671 | BulletSimAPI.SetCcdMotionThreshold2(BSBody.ptr, PhysicsScene.Params.ccdMotionThreshold); | 720 | BulletSimAPI.SetCcdMotionThreshold2(PhysBody.ptr, PhysicsScene.Params.ccdMotionThreshold); |
672 | BulletSimAPI.SetCcdSweepSphereRadius2(BSBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); | 721 | BulletSimAPI.SetCcdSweptSphereRadius2(PhysBody.ptr, PhysicsScene.Params.ccdSweptSphereRadius); |
673 | } | 722 | } |
674 | 723 | ||
675 | // Various values for simulation limits | 724 | // Various values for simulation limits |
676 | BulletSimAPI.SetDamping2(BSBody.ptr, PhysicsScene.Params.linearDamping, PhysicsScene.Params.angularDamping); | 725 | BulletSimAPI.SetDamping2(PhysBody.ptr, PhysicsScene.Params.linearDamping, PhysicsScene.Params.angularDamping); |
677 | BulletSimAPI.SetDeactivationTime2(BSBody.ptr, PhysicsScene.Params.deactivationTime); | 726 | BulletSimAPI.SetDeactivationTime2(PhysBody.ptr, PhysicsScene.Params.deactivationTime); |
678 | BulletSimAPI.SetSleepingThresholds2(BSBody.ptr, PhysicsScene.Params.linearSleepingThreshold, PhysicsScene.Params.angularSleepingThreshold); | 727 | BulletSimAPI.SetSleepingThresholds2(PhysBody.ptr, PhysicsScene.Params.linearSleepingThreshold, PhysicsScene.Params.angularSleepingThreshold); |
679 | BulletSimAPI.SetContactProcessingThreshold2(BSBody.ptr, PhysicsScene.Params.contactProcessingThreshold); | 728 | BulletSimAPI.SetContactProcessingThreshold2(PhysBody.ptr, PhysicsScene.Params.contactProcessingThreshold); |
680 | 729 | ||
681 | // There might be special things needed for implementing linksets. | 730 | // There might be special things needed for implementing linksets. |
682 | Linkset.MakeDynamic(this); | 731 | Linkset.MakeDynamic(this); |
683 | 732 | ||
684 | // Force activation of the object so Bullet will act on it. | 733 | // Force activation of the object so Bullet will act on it. |
685 | // Must do the ForceActivationState2() to overcome the DISABLE_SIMULATION from static objects. | 734 | // Must do the ForceActivationState2() to overcome the DISABLE_SIMULATION from static objects. |
686 | BulletSimAPI.ForceActivationState2(BSBody.ptr, ActivationState.ACTIVE_TAG); | 735 | BulletSimAPI.ForceActivationState2(PhysBody.ptr, ActivationState.ACTIVE_TAG); |
687 | // BulletSimAPI.Activate2(BSBody.ptr, true); | 736 | // BulletSimAPI.Activate2(BSBody.ptr, true); |
688 | 737 | ||
689 | BSBody.collisionFilter = CollisionFilterGroups.ObjectFilter; | 738 | PhysBody.collisionFilter = CollisionFilterGroups.ObjectFilter; |
690 | BSBody.collisionMask = CollisionFilterGroups.ObjectMask; | 739 | PhysBody.collisionMask = CollisionFilterGroups.ObjectMask; |
691 | } | 740 | } |
692 | } | 741 | } |
693 | 742 | ||
@@ -697,7 +746,7 @@ public sealed class BSPrim : BSPhysObject | |||
697 | // the functions after this one set up the state of a possibly newly created collision body. | 746 | // the functions after this one set up the state of a possibly newly created collision body. |
698 | private void MakeSolid(bool makeSolid) | 747 | private void MakeSolid(bool makeSolid) |
699 | { | 748 | { |
700 | CollisionObjectTypes bodyType = (CollisionObjectTypes)BulletSimAPI.GetBodyType2(BSBody.ptr); | 749 | CollisionObjectTypes bodyType = (CollisionObjectTypes)BulletSimAPI.GetBodyType2(PhysBody.ptr); |
701 | if (makeSolid) | 750 | if (makeSolid) |
702 | { | 751 | { |
703 | // Verify the previous code created the correct shape for this type of thing. | 752 | // Verify the previous code created the correct shape for this type of thing. |
@@ -705,7 +754,7 @@ public sealed class BSPrim : BSPhysObject | |||
705 | { | 754 | { |
706 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for solidity. id={1}, type={2}", LogHeader, LocalID, bodyType); | 755 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for solidity. id={1}, type={2}", LogHeader, LocalID, bodyType); |
707 | } | 756 | } |
708 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); | 757 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); |
709 | } | 758 | } |
710 | else | 759 | else |
711 | { | 760 | { |
@@ -713,22 +762,31 @@ public sealed class BSPrim : BSPhysObject | |||
713 | { | 762 | { |
714 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType); | 763 | m_log.ErrorFormat("{0} MakeSolid: physical body of wrong type for non-solidness. id={1}, type={2}", LogHeader, LocalID, bodyType); |
715 | } | 764 | } |
716 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); | 765 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.CF_NO_CONTACT_RESPONSE); |
717 | BSBody.collisionFilter = CollisionFilterGroups.VolumeDetectFilter; | 766 | PhysBody.collisionFilter = CollisionFilterGroups.VolumeDetectFilter; |
718 | BSBody.collisionMask = CollisionFilterGroups.VolumeDetectMask; | 767 | PhysBody.collisionMask = CollisionFilterGroups.VolumeDetectMask; |
719 | } | 768 | } |
720 | } | 769 | } |
721 | 770 | ||
771 | // Enable physical actions. Bullet will keep sleeping non-moving physical objects so | ||
772 | // they need waking up when parameters are changed. | ||
773 | // Called in taint-time!! | ||
774 | private void ActivateIfPhysical(bool forceIt) | ||
775 | { | ||
776 | if (IsPhysical) | ||
777 | BulletSimAPI.Activate2(PhysBody.ptr, forceIt); | ||
778 | } | ||
779 | |||
722 | // Turn on or off the flag controlling whether collision events are returned to the simulator. | 780 | // Turn on or off the flag controlling whether collision events are returned to the simulator. |
723 | private void EnableCollisions(bool wantsCollisionEvents) | 781 | private void EnableCollisions(bool wantsCollisionEvents) |
724 | { | 782 | { |
725 | if (wantsCollisionEvents) | 783 | if (wantsCollisionEvents) |
726 | { | 784 | { |
727 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 785 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
728 | } | 786 | } |
729 | else | 787 | else |
730 | { | 788 | { |
731 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); | 789 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_SUBSCRIBE_COLLISION_EVENTS); |
732 | } | 790 | } |
733 | } | 791 | } |
734 | 792 | ||
@@ -768,14 +826,14 @@ public sealed class BSPrim : BSPhysObject | |||
768 | } | 826 | } |
769 | } | 827 | } |
770 | public override bool FloatOnWater { | 828 | public override bool FloatOnWater { |
771 | set { | 829 | set { |
772 | _floatOnWater = value; | 830 | _floatOnWater = value; |
773 | PhysicsScene.TaintedObject("BSPrim.setFloatOnWater", delegate() | 831 | PhysicsScene.TaintedObject("BSPrim.setFloatOnWater", delegate() |
774 | { | 832 | { |
775 | if (_floatOnWater) | 833 | if (_floatOnWater) |
776 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); | 834 | CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); |
777 | else | 835 | else |
778 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); | 836 | CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(PhysBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER); |
779 | }); | 837 | }); |
780 | } | 838 | } |
781 | } | 839 | } |
@@ -797,8 +855,8 @@ public sealed class BSPrim : BSPhysObject | |||
797 | // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); | 855 | // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); |
798 | PhysicsScene.TaintedObject("BSPrim.setRotationalVelocity", delegate() | 856 | PhysicsScene.TaintedObject("BSPrim.setRotationalVelocity", delegate() |
799 | { | 857 | { |
800 | // DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); | 858 | DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); |
801 | BulletSimAPI.SetAngularVelocity2(BSBody.ptr, _rotationalVelocity); | 859 | BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity); |
802 | }); | 860 | }); |
803 | } | 861 | } |
804 | } | 862 | } |
@@ -808,7 +866,7 @@ public sealed class BSPrim : BSPhysObject | |||
808 | } | 866 | } |
809 | set { | 867 | set { |
810 | _rotationalVelocity = value; | 868 | _rotationalVelocity = value; |
811 | BulletSimAPI.SetAngularVelocity2(BSBody.ptr, _rotationalVelocity); | 869 | BulletSimAPI.SetAngularVelocity2(PhysBody.ptr, _rotationalVelocity); |
812 | } | 870 | } |
813 | } | 871 | } |
814 | public override bool Kinematic { | 872 | public override bool Kinematic { |
@@ -834,7 +892,7 @@ public sealed class BSPrim : BSPhysObject | |||
834 | // DetailLog("{0},BSPrim.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy); | 892 | // DetailLog("{0},BSPrim.setForceBuoyancy,taint,buoy={1}", LocalID, _buoyancy); |
835 | // Buoyancy is faked by changing the gravity applied to the object | 893 | // Buoyancy is faked by changing the gravity applied to the object |
836 | float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); | 894 | float grav = PhysicsScene.Params.gravity * (1f - _buoyancy); |
837 | BulletSimAPI.SetGravity2(BSBody.ptr, new OMV.Vector3(0f, 0f, grav)); | 895 | BulletSimAPI.SetGravity2(PhysBody.ptr, new OMV.Vector3(0f, 0f, grav)); |
838 | } | 896 | } |
839 | } | 897 | } |
840 | 898 | ||
@@ -874,6 +932,7 @@ public sealed class BSPrim : BSPhysObject | |||
874 | public override void AddForce(OMV.Vector3 force, bool pushforce) { | 932 | public override void AddForce(OMV.Vector3 force, bool pushforce) { |
875 | AddForce(force, pushforce, false); | 933 | AddForce(force, pushforce, false); |
876 | } | 934 | } |
935 | // Applying a force just adds this to the total force on the object. | ||
877 | public void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { | 936 | public void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { |
878 | // for an object, doesn't matter if force is a pushforce or not | 937 | // for an object, doesn't matter if force is a pushforce or not |
879 | if (force.IsFinite()) | 938 | if (force.IsFinite()) |
@@ -887,7 +946,7 @@ public sealed class BSPrim : BSPhysObject | |||
887 | m_log.WarnFormat("{0}: Got a NaN force applied to a prim. LocalID={1}", LogHeader, LocalID); | 946 | m_log.WarnFormat("{0}: Got a NaN force applied to a prim. LocalID={1}", LogHeader, LocalID); |
888 | return; | 947 | return; |
889 | } | 948 | } |
890 | BSScene.TaintCallback addForceOperation = delegate() | 949 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddForce", delegate() |
891 | { | 950 | { |
892 | OMV.Vector3 fSum = OMV.Vector3.Zero; | 951 | OMV.Vector3 fSum = OMV.Vector3.Zero; |
893 | lock (m_accumulatedForces) | 952 | lock (m_accumulatedForces) |
@@ -899,20 +958,70 @@ public sealed class BSPrim : BSPhysObject | |||
899 | } | 958 | } |
900 | m_accumulatedForces.Clear(); | 959 | m_accumulatedForces.Clear(); |
901 | } | 960 | } |
902 | // DetailLog("{0},BSPrim.AddObjectForce,taint,force={1}", LocalID, fSum); | 961 | DetailLog("{0},BSPrim.AddForce,taint,force={1}", LocalID, fSum); |
903 | // For unknown reasons, "ApplyCentralForce" adds this force to the total force on the object. | 962 | if (fSum != OMV.Vector3.Zero) |
904 | BulletSimAPI.ApplyCentralForce2(BSBody.ptr, fSum); | 963 | BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, fSum); |
905 | }; | 964 | }); |
906 | if (inTaintTime) | 965 | } |
907 | addForceOperation(); | 966 | |
908 | else | 967 | // An impulse force is scaled by the mass of the object. |
909 | PhysicsScene.TaintedObject("BSPrim.AddForce", addForceOperation); | 968 | public void ApplyForceImpulse(OMV.Vector3 impulse, bool inTaintTime) |
969 | { | ||
970 | OMV.Vector3 applyImpulse = impulse; | ||
971 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ApplyForceImpulse", delegate() | ||
972 | { | ||
973 | DetailLog("{0},BSPrim.ApplyForceImpulse,taint,tImpulse={1}", LocalID, applyImpulse); | ||
974 | BulletSimAPI.ApplyCentralImpulse2(PhysBody.ptr, applyImpulse); | ||
975 | }); | ||
910 | } | 976 | } |
911 | 977 | ||
978 | private List<OMV.Vector3> m_accumulatedAngularForces = new List<OMV.Vector3>(); | ||
912 | public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { | 979 | public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { |
913 | // DetailLog("{0},BSPrim.AddAngularForce,call,angForce={1},push={2}", LocalID, force, pushforce); | 980 | AddAngularForce(force, pushforce, false); |
914 | // m_log.DebugFormat("{0}: AddAngularForce. f={1}, push={2}", LogHeader, force, pushforce); | ||
915 | } | 981 | } |
982 | public void AddAngularForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) | ||
983 | { | ||
984 | if (force.IsFinite()) | ||
985 | { | ||
986 | // _force += force; | ||
987 | lock (m_accumulatedAngularForces) | ||
988 | m_accumulatedAngularForces.Add(new OMV.Vector3(force)); | ||
989 | } | ||
990 | else | ||
991 | { | ||
992 | m_log.WarnFormat("{0}: Got a NaN force applied to a prim. LocalID={1}", LogHeader, LocalID); | ||
993 | return; | ||
994 | } | ||
995 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.AddAngularForce", delegate() | ||
996 | { | ||
997 | OMV.Vector3 fSum = OMV.Vector3.Zero; | ||
998 | lock (m_accumulatedAngularForces) | ||
999 | { | ||
1000 | // Sum the accumulated additional forces for one big force to apply once. | ||
1001 | foreach (OMV.Vector3 v in m_accumulatedAngularForces) | ||
1002 | { | ||
1003 | fSum += v; | ||
1004 | } | ||
1005 | m_accumulatedAngularForces.Clear(); | ||
1006 | } | ||
1007 | DetailLog("{0},BSPrim.AddAngularForce,taint,aForce={1}", LocalID, fSum); | ||
1008 | if (fSum != OMV.Vector3.Zero) | ||
1009 | { | ||
1010 | BulletSimAPI.ApplyTorque2(PhysBody.ptr, fSum); | ||
1011 | _torque = fSum; | ||
1012 | } | ||
1013 | }); | ||
1014 | } | ||
1015 | // A torque impulse. | ||
1016 | public void ApplyTorqueImpulse(OMV.Vector3 impulse, bool inTaintTime) | ||
1017 | { | ||
1018 | OMV.Vector3 applyImpulse = impulse; | ||
1019 | PhysicsScene.TaintedObject(inTaintTime, "BSPrim.ApplyTorqueImpulse", delegate() | ||
1020 | { | ||
1021 | BulletSimAPI.ApplyTorqueImpulse2(PhysBody.ptr, applyImpulse); | ||
1022 | }); | ||
1023 | } | ||
1024 | |||
916 | public override void SetMomentum(OMV.Vector3 momentum) { | 1025 | public override void SetMomentum(OMV.Vector3 momentum) { |
917 | // DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum); | 1026 | // DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum); |
918 | } | 1027 | } |
@@ -971,7 +1080,7 @@ public sealed class BSPrim : BSPhysObject | |||
971 | if (hollowAmount > 0.0) | 1080 | if (hollowAmount > 0.0) |
972 | { | 1081 | { |
973 | hollowVolume *= hollowAmount; | 1082 | hollowVolume *= hollowAmount; |
974 | 1083 | ||
975 | switch (BaseShape.HollowShape) | 1084 | switch (BaseShape.HollowShape) |
976 | { | 1085 | { |
977 | case HollowShape.Square: | 1086 | case HollowShape.Square: |
@@ -1194,9 +1303,7 @@ public sealed class BSPrim : BSPhysObject | |||
1194 | 1303 | ||
1195 | returnMass = _density * volume; | 1304 | returnMass = _density * volume; |
1196 | 1305 | ||
1197 | /* | 1306 | /* Comment out code that computes the mass of the linkset. That is done in the Linkset class. |
1198 | * This change means each object keeps its own mass and the Mass property | ||
1199 | * will return the sum if we're part of a linkset. | ||
1200 | if (IsRootOfLinkset) | 1307 | if (IsRootOfLinkset) |
1201 | { | 1308 | { |
1202 | foreach (BSPrim prim in _childrenPrims) | 1309 | foreach (BSPrim prim in _childrenPrims) |
@@ -1216,48 +1323,27 @@ public sealed class BSPrim : BSPhysObject | |||
1216 | }// end CalculateMass | 1323 | }// end CalculateMass |
1217 | #endregion Mass Calculation | 1324 | #endregion Mass Calculation |
1218 | 1325 | ||
1219 | // Copy prim's info into the BulletSim shape description structure | ||
1220 | public void FillShapeInfo(out ShapeData shape) | ||
1221 | { | ||
1222 | shape.ID = LocalID; | ||
1223 | shape.Type = ShapeData.PhysicsShapeType.SHAPE_UNKNOWN; | ||
1224 | shape.Position = _position; | ||
1225 | shape.Rotation = _orientation; | ||
1226 | shape.Velocity = _velocity; | ||
1227 | shape.Size = _size; | ||
1228 | shape.Scale = Scale; | ||
1229 | shape.Mass = _isPhysical ? _mass : 0f; | ||
1230 | shape.Buoyancy = _buoyancy; | ||
1231 | shape.HullKey = 0; | ||
1232 | shape.MeshKey = 0; | ||
1233 | shape.Friction = _friction; | ||
1234 | shape.Restitution = _restitution; | ||
1235 | shape.Collidable = (!IsPhantom) ? ShapeData.numericTrue : ShapeData.numericFalse; | ||
1236 | shape.Static = _isPhysical ? ShapeData.numericFalse : ShapeData.numericTrue; | ||
1237 | shape.Solid = IsSolid ? ShapeData.numericFalse : ShapeData.numericTrue; | ||
1238 | } | ||
1239 | // Rebuild the geometry and object. | 1326 | // Rebuild the geometry and object. |
1240 | // This is called when the shape changes so we need to recreate the mesh/hull. | 1327 | // This is called when the shape changes so we need to recreate the mesh/hull. |
1241 | // Called at taint-time!!! | 1328 | // Called at taint-time!!! |
1242 | private void CreateGeomAndObject(bool forceRebuild) | 1329 | private void CreateGeomAndObject(bool forceRebuild) |
1243 | { | 1330 | { |
1244 | ShapeData shapeData; | ||
1245 | FillShapeInfo(out shapeData); | ||
1246 | |||
1247 | // If this prim is part of a linkset, we must remove and restore the physical | 1331 | // If this prim is part of a linkset, we must remove and restore the physical |
1248 | // links of the body is rebuilt. | 1332 | // links if the body is rebuilt. |
1249 | bool needToRestoreLinkset = false; | 1333 | bool needToRestoreLinkset = false; |
1334 | bool needToRestoreVehicle = false; | ||
1250 | 1335 | ||
1251 | // Create the correct physical representation for this type of object. | 1336 | // Create the correct physical representation for this type of object. |
1252 | // Updates BSBody and BSShape with the new information. | 1337 | // Updates PhysBody and PhysShape with the new information. |
1253 | // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary. | 1338 | // Ignore 'forceRebuild'. This routine makes the right choices and changes of necessary. |
1254 | PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, shapeData, BaseShape, | 1339 | // Returns 'true' if either the body or the shape was changed. |
1255 | null, delegate(BulletBody dBody) | 1340 | PhysicsScene.Shapes.GetBodyAndShape(false, PhysicsScene.World, this, null, delegate(BulletBody dBody) |
1256 | { | 1341 | { |
1257 | // Called if the current prim body is about to be destroyed. | 1342 | // Called if the current prim body is about to be destroyed. |
1258 | // Remove all the physical dependencies on the old body. | 1343 | // Remove all the physical dependencies on the old body. |
1259 | // (Maybe someday make the changing of BSShape an event handled by BSLinkset.) | 1344 | // (Maybe someday make the changing of BSShape an event handled by BSLinkset.) |
1260 | needToRestoreLinkset = Linkset.RemoveBodyDependencies(this); | 1345 | needToRestoreLinkset = Linkset.RemoveBodyDependencies(this); |
1346 | needToRestoreVehicle = _vehicle.RemoveBodyDependencies(this); | ||
1261 | }); | 1347 | }); |
1262 | 1348 | ||
1263 | if (needToRestoreLinkset) | 1349 | if (needToRestoreLinkset) |
@@ -1265,6 +1351,11 @@ public sealed class BSPrim : BSPhysObject | |||
1265 | // If physical body dependencies were removed, restore them | 1351 | // If physical body dependencies were removed, restore them |
1266 | Linkset.RestoreBodyDependencies(this); | 1352 | Linkset.RestoreBodyDependencies(this); |
1267 | } | 1353 | } |
1354 | if (needToRestoreVehicle) | ||
1355 | { | ||
1356 | // If physical body dependencies were removed, restore them | ||
1357 | _vehicle.RestoreBodyDependencies(this); | ||
1358 | } | ||
1268 | 1359 | ||
1269 | // Make sure the properties are set on the new object | 1360 | // Make sure the properties are set on the new object |
1270 | UpdatePhysicalParameters(); | 1361 | UpdatePhysicalParameters(); |
@@ -1326,7 +1417,7 @@ public sealed class BSPrim : BSPhysObject | |||
1326 | if (changed != 0) | 1417 | if (changed != 0) |
1327 | { | 1418 | { |
1328 | // Only update the position of single objects and linkset roots | 1419 | // Only update the position of single objects and linkset roots |
1329 | if (this._parentPrim == null) | 1420 | if (Linkset.IsRoot(this)) |
1330 | { | 1421 | { |
1331 | base.RequestPhysicsterseUpdate(); | 1422 | base.RequestPhysicsterseUpdate(); |
1332 | } | 1423 | } |
@@ -1338,23 +1429,29 @@ public sealed class BSPrim : BSPhysObject | |||
1338 | // Updates only for individual prims and for the root object of a linkset. | 1429 | // Updates only for individual prims and for the root object of a linkset. |
1339 | if (Linkset.IsRoot(this)) | 1430 | if (Linkset.IsRoot(this)) |
1340 | { | 1431 | { |
1341 | // Assign to the local variables so the normal set action does not happen | 1432 | // Assign directly to the local variables so the normal set action does not happen |
1342 | _position = entprop.Position; | 1433 | _position = entprop.Position; |
1343 | _orientation = entprop.Rotation; | 1434 | _orientation = entprop.Rotation; |
1344 | _velocity = entprop.Velocity; | 1435 | _velocity = entprop.Velocity; |
1345 | _acceleration = entprop.Acceleration; | 1436 | _acceleration = entprop.Acceleration; |
1346 | _rotationalVelocity = entprop.RotationalVelocity; | 1437 | _rotationalVelocity = entprop.RotationalVelocity; |
1347 | 1438 | ||
1439 | // The sanity check can change the velocity and/or position. | ||
1440 | if (PositionSanityCheck(true)) | ||
1441 | { | ||
1442 | entprop.Position = _position; | ||
1443 | entprop.Velocity = _velocity; | ||
1444 | } | ||
1445 | |||
1348 | // remember the current and last set values | 1446 | // remember the current and last set values |
1349 | LastEntityProperties = CurrentEntityProperties; | 1447 | LastEntityProperties = CurrentEntityProperties; |
1350 | CurrentEntityProperties = entprop; | 1448 | CurrentEntityProperties = entprop; |
1351 | 1449 | ||
1352 | PositionSanityCheck(true); | 1450 | OMV.Vector3 direction = OMV.Vector3.UnitX * _orientation; |
1353 | 1451 | DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},dir={3},vel={4},rotVel={5}", | |
1354 | DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", | 1452 | LocalID, _position, _orientation, direction, _velocity, _rotationalVelocity); |
1355 | LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); | ||
1356 | 1453 | ||
1357 | // BulletSimAPI.DumpRigidBody2(Scene.World.Ptr, BSBody.Ptr); | 1454 | // BulletSimAPI.DumpRigidBody2(PhysicsScene.World.ptr, BSBody.ptr); // DEBUG DEBUG DEBUG |
1358 | 1455 | ||
1359 | base.RequestPhysicsterseUpdate(); | 1456 | base.RequestPhysicsterseUpdate(); |
1360 | } | 1457 | } |
@@ -1367,8 +1464,8 @@ public sealed class BSPrim : BSPhysObject | |||
1367 | entprop.Acceleration, entprop.RotationalVelocity); | 1464 | entprop.Acceleration, entprop.RotationalVelocity); |
1368 | } | 1465 | } |
1369 | */ | 1466 | */ |
1370 | // The linkset implimentation might want to know about this. | ||
1371 | 1467 | ||
1468 | // The linkset implimentation might want to know about this. | ||
1372 | Linkset.UpdateProperties(this); | 1469 | Linkset.UpdateProperties(this); |
1373 | } | 1470 | } |
1374 | } | 1471 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs index 6621d39..27a78d1 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSScene.cs | |||
@@ -62,7 +62,7 @@ using OpenMetaverse; | |||
62 | // | 62 | // |
63 | namespace OpenSim.Region.Physics.BulletSPlugin | 63 | namespace OpenSim.Region.Physics.BulletSPlugin |
64 | { | 64 | { |
65 | public class BSScene : PhysicsScene, IPhysicsParameters | 65 | public sealed class BSScene : PhysicsScene, IPhysicsParameters |
66 | { | 66 | { |
67 | private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | 67 | private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); |
68 | private static readonly string LogHeader = "[BULLETS SCENE]"; | 68 | private static readonly string LogHeader = "[BULLETS SCENE]"; |
@@ -116,6 +116,10 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
116 | // True if initialized and ready to do simulation steps | 116 | // True if initialized and ready to do simulation steps |
117 | private bool m_initialized = false; | 117 | private bool m_initialized = false; |
118 | 118 | ||
119 | // Flag which is true when processing taints. | ||
120 | // Not guaranteed to be correct all the time (don't depend on this) but good for debugging. | ||
121 | public bool InTaintTime { get; private set; } | ||
122 | |||
119 | // Pinned memory used to pass step information between managed and unmanaged | 123 | // Pinned memory used to pass step information between managed and unmanaged |
120 | private int m_maxCollisionsPerFrame; | 124 | private int m_maxCollisionsPerFrame; |
121 | private CollisionDesc[] m_collisionArray; | 125 | private CollisionDesc[] m_collisionArray; |
@@ -171,7 +175,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
171 | } | 175 | } |
172 | } | 176 | } |
173 | private Object _taintLock = new Object(); // lock for using the next object | 177 | private Object _taintLock = new Object(); // lock for using the next object |
174 | private List<TaintCallbackEntry> _taintedObjects; | 178 | private List<TaintCallbackEntry> _taintOperations; |
179 | private Dictionary<string, TaintCallbackEntry> _postTaintOperations; | ||
180 | private List<TaintCallbackEntry> _postStepOperations; | ||
175 | 181 | ||
176 | // A pointer to an instance if this structure is passed to the C++ code | 182 | // A pointer to an instance if this structure is passed to the C++ code |
177 | // Used to pass basic configuration values to the unmanaged code. | 183 | // Used to pass basic configuration values to the unmanaged code. |
@@ -203,7 +209,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
203 | public override void Initialise(IMesher meshmerizer, IConfigSource config) | 209 | public override void Initialise(IMesher meshmerizer, IConfigSource config) |
204 | { | 210 | { |
205 | mesher = meshmerizer; | 211 | mesher = meshmerizer; |
206 | _taintedObjects = new List<TaintCallbackEntry>(); | 212 | _taintOperations = new List<TaintCallbackEntry>(); |
213 | _postTaintOperations = new Dictionary<string, TaintCallbackEntry>(); | ||
214 | _postStepOperations = new List<TaintCallbackEntry>(); | ||
207 | PhysObjects = new Dictionary<uint, BSPhysObject>(); | 215 | PhysObjects = new Dictionary<uint, BSPhysObject>(); |
208 | Shapes = new BSShapeCollection(this); | 216 | Shapes = new BSShapeCollection(this); |
209 | 217 | ||
@@ -266,6 +274,9 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
266 | TerrainManager = new BSTerrainManager(this); | 274 | TerrainManager = new BSTerrainManager(this); |
267 | TerrainManager.CreateInitialGroundPlaneAndTerrain(); | 275 | TerrainManager.CreateInitialGroundPlaneAndTerrain(); |
268 | 276 | ||
277 | m_log.WarnFormat("{0} Linksets implemented with {1}", LogHeader, (BSLinkset.LinksetImplementation)Params.linksetImplementation); | ||
278 | |||
279 | InTaintTime = false; | ||
269 | m_initialized = true; | 280 | m_initialized = true; |
270 | } | 281 | } |
271 | 282 | ||
@@ -320,7 +331,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
320 | { | 331 | { |
321 | m_log.Debug("[BULLETS UNMANAGED]:" + msg); | 332 | m_log.Debug("[BULLETS UNMANAGED]:" + msg); |
322 | } | 333 | } |
323 | 334 | ||
324 | // Called directly from unmanaged code so don't do much | 335 | // Called directly from unmanaged code so don't do much |
325 | private void BulletLoggerPhysLog(string msg) | 336 | private void BulletLoggerPhysLog(string msg) |
326 | { | 337 | { |
@@ -475,23 +486,20 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
475 | if (!m_initialized) return 5.0f; | 486 | if (!m_initialized) return 5.0f; |
476 | 487 | ||
477 | // update the prim states while we know the physics engine is not busy | 488 | // update the prim states while we know the physics engine is not busy |
478 | int numTaints = _taintedObjects.Count; | 489 | int numTaints = _taintOperations.Count; |
479 | ProcessTaints(); | 490 | ProcessTaints(); |
480 | 491 | ||
481 | // Some of the prims operate with special vehicle properties | 492 | // Some of the prims operate with special vehicle properties |
482 | ProcessVehicles(timeStep); | 493 | ProcessVehicles(timeStep); |
483 | numTaints += _taintedObjects.Count; | ||
484 | ProcessTaints(); // the vehicles might have added taints | 494 | ProcessTaints(); // the vehicles might have added taints |
485 | 495 | ||
486 | // step the physical world one interval | 496 | // step the physical world one interval |
487 | m_simulationStep++; | 497 | m_simulationStep++; |
488 | int numSubSteps = 0; | 498 | int numSubSteps = 0; |
489 | 499 | ||
490 | // DEBUG | ||
491 | // DetailLog("{0},BSScene.Simulate,beforeStep,ntaimts={1},step={2}", DetailLogZero, numTaints, m_simulationStep); | ||
492 | |||
493 | try | 500 | try |
494 | { | 501 | { |
502 | if (VehicleLoggingEnabled) DumpVehicles(); // DEBUG | ||
495 | if (PhysicsLogging.Enabled) beforeTime = Util.EnvironmentTickCount(); | 503 | if (PhysicsLogging.Enabled) beforeTime = Util.EnvironmentTickCount(); |
496 | 504 | ||
497 | numSubSteps = BulletSimAPI.PhysicsStep2(World.ptr, timeStep, m_maxSubSteps, m_fixedTimeStep, | 505 | numSubSteps = BulletSimAPI.PhysicsStep2(World.ptr, timeStep, m_maxSubSteps, m_fixedTimeStep, |
@@ -500,6 +508,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
500 | if (PhysicsLogging.Enabled) simTime = Util.EnvironmentTickCountSubtract(beforeTime); | 508 | if (PhysicsLogging.Enabled) simTime = Util.EnvironmentTickCountSubtract(beforeTime); |
501 | DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}", | 509 | DetailLog("{0},Simulate,call, frame={1}, nTaints={2}, simTime={3}, substeps={4}, updates={5}, colliders={6}", |
502 | DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps, updatedEntityCount, collidersCount); | 510 | DetailLogZero, m_simulationStep, numTaints, simTime, numSubSteps, updatedEntityCount, collidersCount); |
511 | if (VehicleLoggingEnabled) DumpVehicles(); // DEBUG | ||
503 | } | 512 | } |
504 | catch (Exception e) | 513 | catch (Exception e) |
505 | { | 514 | { |
@@ -511,7 +520,6 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
511 | collidersCount = 0; | 520 | collidersCount = 0; |
512 | } | 521 | } |
513 | 522 | ||
514 | |||
515 | // Don't have to use the pointers passed back since we know it is the same pinned memory we passed in | 523 | // Don't have to use the pointers passed back since we know it is the same pinned memory we passed in |
516 | 524 | ||
517 | // Get a value for 'now' so all the collision and update routines don't have to get their own | 525 | // Get a value for 'now' so all the collision and update routines don't have to get their own |
@@ -545,7 +553,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
545 | } | 553 | } |
546 | 554 | ||
547 | // This is a kludge to get avatar movement updates. | 555 | // This is a kludge to get avatar movement updates. |
548 | // The simulator expects collisions for avatars even if there are have been no collisions. | 556 | // The simulator expects collisions for avatars even if there are have been no collisions. |
549 | // The event updates avatar animations and stuff. | 557 | // The event updates avatar animations and stuff. |
550 | // If you fix avatar animation updates, remove this overhead and let normal collision processing happen. | 558 | // If you fix avatar animation updates, remove this overhead and let normal collision processing happen. |
551 | foreach (BSPhysObject bsp in m_avatars) | 559 | foreach (BSPhysObject bsp in m_avatars) |
@@ -575,6 +583,8 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
575 | } | 583 | } |
576 | } | 584 | } |
577 | 585 | ||
586 | ProcessPostStepTaints(); | ||
587 | |||
578 | // This causes the unmanaged code to output ALL the values found in ALL the objects in the world. | 588 | // This causes the unmanaged code to output ALL the values found in ALL the objects in the world. |
579 | // Only enable this in a limited test world with few objects. | 589 | // Only enable this in a limited test world with few objects. |
580 | // BulletSimAPI.DumpAllInfo2(World.ptr); // DEBUG DEBUG DEBUG | 590 | // BulletSimAPI.DumpAllInfo2(World.ptr); // DEBUG DEBUG DEBUG |
@@ -670,8 +680,10 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
670 | 680 | ||
671 | public override bool IsThreaded { get { return false; } } | 681 | public override bool IsThreaded { get { return false; } } |
672 | 682 | ||
683 | #region Taints | ||
684 | |||
673 | // Calls to the PhysicsActors can't directly call into the physics engine | 685 | // Calls to the PhysicsActors can't directly call into the physics engine |
674 | // because it might be busy. We delay changes to a known time. | 686 | // because it might be busy. We delay changes to a known time. |
675 | // We rely on C#'s closure to save and restore the context for the delegate. | 687 | // We rely on C#'s closure to save and restore the context for the delegate. |
676 | public void TaintedObject(String ident, TaintCallback callback) | 688 | public void TaintedObject(String ident, TaintCallback callback) |
677 | { | 689 | { |
@@ -679,31 +691,51 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
679 | 691 | ||
680 | lock (_taintLock) | 692 | lock (_taintLock) |
681 | { | 693 | { |
682 | _taintedObjects.Add(new TaintCallbackEntry(ident, callback)); | 694 | _taintOperations.Add(new TaintCallbackEntry(ident, callback)); |
683 | } | 695 | } |
684 | 696 | ||
685 | return; | 697 | return; |
686 | } | 698 | } |
687 | 699 | ||
700 | // Sometimes a potentially tainted operation can be used in and out of taint time. | ||
701 | // This routine executes the command immediately if in taint-time otherwise it is queued. | ||
702 | public void TaintedObject(bool inTaintTime, string ident, TaintCallback callback) | ||
703 | { | ||
704 | if (inTaintTime) | ||
705 | callback(); | ||
706 | else | ||
707 | TaintedObject(ident, callback); | ||
708 | } | ||
709 | |||
688 | // When someone tries to change a property on a BSPrim or BSCharacter, the object queues | 710 | // When someone tries to change a property on a BSPrim or BSCharacter, the object queues |
689 | // a callback into itself to do the actual property change. That callback is called | 711 | // a callback into itself to do the actual property change. That callback is called |
690 | // here just before the physics engine is called to step the simulation. | 712 | // here just before the physics engine is called to step the simulation. |
691 | public void ProcessTaints() | 713 | public void ProcessTaints() |
692 | { | 714 | { |
693 | if (_taintedObjects.Count > 0) // save allocating new list if there is nothing to process | 715 | InTaintTime = true; // Only used for debugging so locking is not necessary. |
716 | ProcessRegularTaints(); | ||
717 | ProcessPostTaintTaints(); | ||
718 | InTaintTime = false; | ||
719 | } | ||
720 | |||
721 | private void ProcessRegularTaints() | ||
722 | { | ||
723 | if (_taintOperations.Count > 0) // save allocating new list if there is nothing to process | ||
694 | { | 724 | { |
695 | // swizzle a new list into the list location so we can process what's there | 725 | /* |
726 | // Code to limit the number of taints processed per step. Meant to limit step time. | ||
727 | // Unsure if a good idea as code assumes that taints are done before the step. | ||
696 | int taintCount = m_taintsToProcessPerStep; | 728 | int taintCount = m_taintsToProcessPerStep; |
697 | TaintCallbackEntry oneCallback = new TaintCallbackEntry(); | 729 | TaintCallbackEntry oneCallback = new TaintCallbackEntry(); |
698 | while (_taintedObjects.Count > 0 && taintCount-- > 0) | 730 | while (_taintOperations.Count > 0 && taintCount-- > 0) |
699 | { | 731 | { |
700 | bool gotOne = false; | 732 | bool gotOne = false; |
701 | lock (_taintLock) | 733 | lock (_taintLock) |
702 | { | 734 | { |
703 | if (_taintedObjects.Count > 0) | 735 | if (_taintOperations.Count > 0) |
704 | { | 736 | { |
705 | oneCallback = _taintedObjects[0]; | 737 | oneCallback = _taintOperations[0]; |
706 | _taintedObjects.RemoveAt(0); | 738 | _taintOperations.RemoveAt(0); |
707 | gotOne = true; | 739 | gotOne = true; |
708 | } | 740 | } |
709 | } | 741 | } |
@@ -711,22 +743,28 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
711 | { | 743 | { |
712 | try | 744 | try |
713 | { | 745 | { |
714 | DetailLog("{0},BSScene.ProcessTaints,doTaint,id={1}", DetailLogZero, oneCallback.ident); // DEBUG DEBUG DEBUG | 746 | DetailLog("{0},BSScene.ProcessTaints,doTaint,id={1}", DetailLogZero, oneCallback.ident); |
715 | oneCallback.callback(); | 747 | oneCallback.callback(); |
716 | } | 748 | } |
717 | catch (Exception e) | 749 | catch (Exception e) |
718 | { | 750 | { |
751 | DetailLog("{0},BSScene.ProcessTaints,doTaintException,id={1}", DetailLogZero, oneCallback.ident); // DEBUG DEBUG DEBUG | ||
719 | m_log.ErrorFormat("{0}: ProcessTaints: {1}: Exception: {2}", LogHeader, oneCallback.ident, e); | 752 | m_log.ErrorFormat("{0}: ProcessTaints: {1}: Exception: {2}", LogHeader, oneCallback.ident, e); |
720 | } | 753 | } |
721 | } | 754 | } |
722 | } | 755 | } |
723 | /* | 756 | if (_taintOperations.Count > 0) |
757 | { | ||
758 | DetailLog("{0},BSScene.ProcessTaints,leftTaintsOnList,numNotProcessed={1}", DetailLogZero, _taintOperations.Count); | ||
759 | } | ||
760 | */ | ||
761 | |||
724 | // swizzle a new list into the list location so we can process what's there | 762 | // swizzle a new list into the list location so we can process what's there |
725 | List<TaintCallbackEntry> oldList; | 763 | List<TaintCallbackEntry> oldList; |
726 | lock (_taintLock) | 764 | lock (_taintLock) |
727 | { | 765 | { |
728 | oldList = _taintedObjects; | 766 | oldList = _taintOperations; |
729 | _taintedObjects = new List<TaintCallbackEntry>(); | 767 | _taintOperations = new List<TaintCallbackEntry>(); |
730 | } | 768 | } |
731 | 769 | ||
732 | foreach (TaintCallbackEntry tcbe in oldList) | 770 | foreach (TaintCallbackEntry tcbe in oldList) |
@@ -742,10 +780,103 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
742 | } | 780 | } |
743 | } | 781 | } |
744 | oldList.Clear(); | 782 | oldList.Clear(); |
745 | */ | ||
746 | } | 783 | } |
747 | } | 784 | } |
748 | 785 | ||
786 | // Schedule an update to happen after all the regular taints are processed. | ||
787 | // Note that new requests for the same operation ("ident") for the same object ("ID") | ||
788 | // will replace any previous operation by the same object. | ||
789 | public void PostTaintObject(String ident, uint ID, TaintCallback callback) | ||
790 | { | ||
791 | string uniqueIdent = ident + "-" + ID.ToString(); | ||
792 | lock (_taintLock) | ||
793 | { | ||
794 | _postTaintOperations[uniqueIdent] = new TaintCallbackEntry(uniqueIdent, callback); | ||
795 | } | ||
796 | |||
797 | return; | ||
798 | } | ||
799 | |||
800 | private void ProcessPostTaintTaints() | ||
801 | { | ||
802 | if (_postTaintOperations.Count > 0) | ||
803 | { | ||
804 | Dictionary<string, TaintCallbackEntry> oldList; | ||
805 | lock (_taintLock) | ||
806 | { | ||
807 | oldList = _postTaintOperations; | ||
808 | _postTaintOperations = new Dictionary<string, TaintCallbackEntry>(); | ||
809 | } | ||
810 | |||
811 | foreach (KeyValuePair<string,TaintCallbackEntry> kvp in oldList) | ||
812 | { | ||
813 | try | ||
814 | { | ||
815 | DetailLog("{0},BSScene.ProcessPostTaintTaints,doTaint,id={1}", DetailLogZero, kvp.Key); // DEBUG DEBUG DEBUG | ||
816 | kvp.Value.callback(); | ||
817 | } | ||
818 | catch (Exception e) | ||
819 | { | ||
820 | m_log.ErrorFormat("{0}: ProcessPostTaintTaints: {1}: Exception: {2}", LogHeader, kvp.Key, e); | ||
821 | } | ||
822 | } | ||
823 | oldList.Clear(); | ||
824 | } | ||
825 | } | ||
826 | |||
827 | public void PostStepTaintObject(String ident, TaintCallback callback) | ||
828 | { | ||
829 | if (!m_initialized) return; | ||
830 | |||
831 | lock (_taintLock) | ||
832 | { | ||
833 | _postStepOperations.Add(new TaintCallbackEntry(ident, callback)); | ||
834 | } | ||
835 | |||
836 | return; | ||
837 | } | ||
838 | |||
839 | private void ProcessPostStepTaints() | ||
840 | { | ||
841 | if (_postStepOperations.Count > 0) | ||
842 | { | ||
843 | List<TaintCallbackEntry> oldList; | ||
844 | lock (_taintLock) | ||
845 | { | ||
846 | oldList = _postStepOperations; | ||
847 | _postStepOperations = new List<TaintCallbackEntry>(); | ||
848 | } | ||
849 | |||
850 | foreach (TaintCallbackEntry tcbe in oldList) | ||
851 | { | ||
852 | try | ||
853 | { | ||
854 | DetailLog("{0},BSScene.ProcessPostStepTaints,doTaint,id={1}", DetailLogZero, tcbe.ident); // DEBUG DEBUG DEBUG | ||
855 | tcbe.callback(); | ||
856 | } | ||
857 | catch (Exception e) | ||
858 | { | ||
859 | m_log.ErrorFormat("{0}: ProcessPostStepTaints: {1}: Exception: {2}", LogHeader, tcbe.ident, e); | ||
860 | } | ||
861 | } | ||
862 | oldList.Clear(); | ||
863 | } | ||
864 | } | ||
865 | |||
866 | // Only used for debugging. Does not change state of anything so locking is not necessary. | ||
867 | public bool AssertInTaintTime(string whereFrom) | ||
868 | { | ||
869 | if (!InTaintTime) | ||
870 | { | ||
871 | DetailLog("{0},BSScene.AssertInTaintTime,NOT IN TAINT TIME,Region={1},Where={2}", DetailLogZero, RegionName, whereFrom); | ||
872 | m_log.ErrorFormat("{0} NOT IN TAINT TIME!! Region={1}, Where={2}", LogHeader, RegionName, whereFrom); | ||
873 | Util.PrintCallStack(); // Prints the stack into the DEBUG log file. | ||
874 | } | ||
875 | return InTaintTime; | ||
876 | } | ||
877 | |||
878 | #endregion // Taints | ||
879 | |||
749 | #region Vehicles | 880 | #region Vehicles |
750 | 881 | ||
751 | public void VehicleInSceneTypeChanged(BSPrim vehic, Vehicle newType) | 882 | public void VehicleInSceneTypeChanged(BSPrim vehic, Vehicle newType) |
@@ -916,7 +1047,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
916 | (s) => { return (float)s.m_maxUpdatesPerFrame; }, | 1047 | (s) => { return (float)s.m_maxUpdatesPerFrame; }, |
917 | (s,p,l,v) => { s.m_maxUpdatesPerFrame = (int)v; } ), | 1048 | (s,p,l,v) => { s.m_maxUpdatesPerFrame = (int)v; } ), |
918 | new ParameterDefn("MaxTaintsToProcessPerStep", "Number of update taints to process before each simulation step", | 1049 | new ParameterDefn("MaxTaintsToProcessPerStep", "Number of update taints to process before each simulation step", |
919 | 100f, | 1050 | 500f, |
920 | (s,cf,p,v) => { s.m_taintsToProcessPerStep = cf.GetInt(p, (int)v); }, | 1051 | (s,cf,p,v) => { s.m_taintsToProcessPerStep = cf.GetInt(p, (int)v); }, |
921 | (s) => { return (float)s.m_taintsToProcessPerStep; }, | 1052 | (s) => { return (float)s.m_taintsToProcessPerStep; }, |
922 | (s,p,l,v) => { s.m_taintsToProcessPerStep = (int)v; } ), | 1053 | (s,p,l,v) => { s.m_taintsToProcessPerStep = (int)v; } ), |
@@ -970,50 +1101,55 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
970 | (s,cf,p,v) => { s.m_params[0].linearDamping = cf.GetFloat(p, v); }, | 1101 | (s,cf,p,v) => { s.m_params[0].linearDamping = cf.GetFloat(p, v); }, |
971 | (s) => { return s.m_params[0].linearDamping; }, | 1102 | (s) => { return s.m_params[0].linearDamping; }, |
972 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].linearDamping, p, l, v); }, | 1103 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].linearDamping, p, l, v); }, |
973 | (s,o,v) => { BulletSimAPI.SetDamping2(o.BSBody.ptr, v, v); } ), | 1104 | (s,o,v) => { BulletSimAPI.SetDamping2(o.PhysBody.ptr, v, s.m_params[0].angularDamping); } ), |
974 | new ParameterDefn("AngularDamping", "Factor to damp angular movement per second (0.0 - 1.0)", | 1105 | new ParameterDefn("AngularDamping", "Factor to damp angular movement per second (0.0 - 1.0)", |
975 | 0f, | 1106 | 0f, |
976 | (s,cf,p,v) => { s.m_params[0].angularDamping = cf.GetFloat(p, v); }, | 1107 | (s,cf,p,v) => { s.m_params[0].angularDamping = cf.GetFloat(p, v); }, |
977 | (s) => { return s.m_params[0].angularDamping; }, | 1108 | (s) => { return s.m_params[0].angularDamping; }, |
978 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].angularDamping, p, l, v); }, | 1109 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].angularDamping, p, l, v); }, |
979 | (s,o,v) => { BulletSimAPI.SetDamping2(o.BSBody.ptr, v, v); } ), | 1110 | (s,o,v) => { BulletSimAPI.SetDamping2(o.PhysBody.ptr, s.m_params[0].linearDamping, v); } ), |
980 | new ParameterDefn("DeactivationTime", "Seconds before considering an object potentially static", | 1111 | new ParameterDefn("DeactivationTime", "Seconds before considering an object potentially static", |
981 | 0.2f, | 1112 | 0.2f, |
982 | (s,cf,p,v) => { s.m_params[0].deactivationTime = cf.GetFloat(p, v); }, | 1113 | (s,cf,p,v) => { s.m_params[0].deactivationTime = cf.GetFloat(p, v); }, |
983 | (s) => { return s.m_params[0].deactivationTime; }, | 1114 | (s) => { return s.m_params[0].deactivationTime; }, |
984 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].deactivationTime, p, l, v); }, | 1115 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].deactivationTime, p, l, v); }, |
985 | (s,o,v) => { BulletSimAPI.SetDeactivationTime2(o.BSBody.ptr, v); } ), | 1116 | (s,o,v) => { BulletSimAPI.SetDeactivationTime2(o.PhysBody.ptr, v); } ), |
986 | new ParameterDefn("LinearSleepingThreshold", "Seconds to measure linear movement before considering static", | 1117 | new ParameterDefn("LinearSleepingThreshold", "Seconds to measure linear movement before considering static", |
987 | 0.8f, | 1118 | 0.8f, |
988 | (s,cf,p,v) => { s.m_params[0].linearSleepingThreshold = cf.GetFloat(p, v); }, | 1119 | (s,cf,p,v) => { s.m_params[0].linearSleepingThreshold = cf.GetFloat(p, v); }, |
989 | (s) => { return s.m_params[0].linearSleepingThreshold; }, | 1120 | (s) => { return s.m_params[0].linearSleepingThreshold; }, |
990 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].linearSleepingThreshold, p, l, v); }, | 1121 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].linearSleepingThreshold, p, l, v); }, |
991 | (s,o,v) => { BulletSimAPI.SetSleepingThresholds2(o.BSBody.ptr, v, v); } ), | 1122 | (s,o,v) => { BulletSimAPI.SetSleepingThresholds2(o.PhysBody.ptr, v, v); } ), |
992 | new ParameterDefn("AngularSleepingThreshold", "Seconds to measure angular movement before considering static", | 1123 | new ParameterDefn("AngularSleepingThreshold", "Seconds to measure angular movement before considering static", |
993 | 1.0f, | 1124 | 1.0f, |
994 | (s,cf,p,v) => { s.m_params[0].angularSleepingThreshold = cf.GetFloat(p, v); }, | 1125 | (s,cf,p,v) => { s.m_params[0].angularSleepingThreshold = cf.GetFloat(p, v); }, |
995 | (s) => { return s.m_params[0].angularSleepingThreshold; }, | 1126 | (s) => { return s.m_params[0].angularSleepingThreshold; }, |
996 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].angularSleepingThreshold, p, l, v); }, | 1127 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].angularSleepingThreshold, p, l, v); }, |
997 | (s,o,v) => { BulletSimAPI.SetSleepingThresholds2(o.BSBody.ptr, v, v); } ), | 1128 | (s,o,v) => { BulletSimAPI.SetSleepingThresholds2(o.PhysBody.ptr, v, v); } ), |
998 | new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" , | 1129 | new ParameterDefn("CcdMotionThreshold", "Continuious collision detection threshold (0 means no CCD)" , |
999 | 0f, // set to zero to disable | 1130 | 0f, // set to zero to disable |
1000 | (s,cf,p,v) => { s.m_params[0].ccdMotionThreshold = cf.GetFloat(p, v); }, | 1131 | (s,cf,p,v) => { s.m_params[0].ccdMotionThreshold = cf.GetFloat(p, v); }, |
1001 | (s) => { return s.m_params[0].ccdMotionThreshold; }, | 1132 | (s) => { return s.m_params[0].ccdMotionThreshold; }, |
1002 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].ccdMotionThreshold, p, l, v); }, | 1133 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].ccdMotionThreshold, p, l, v); }, |
1003 | (s,o,v) => { BulletSimAPI.SetCcdMotionThreshold2(o.BSBody.ptr, v); } ), | 1134 | (s,o,v) => { BulletSimAPI.SetCcdMotionThreshold2(o.PhysBody.ptr, v); } ), |
1004 | new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" , | 1135 | new ParameterDefn("CcdSweptSphereRadius", "Continuious collision detection test radius" , |
1005 | 0f, | 1136 | 0f, |
1006 | (s,cf,p,v) => { s.m_params[0].ccdSweptSphereRadius = cf.GetFloat(p, v); }, | 1137 | (s,cf,p,v) => { s.m_params[0].ccdSweptSphereRadius = cf.GetFloat(p, v); }, |
1007 | (s) => { return s.m_params[0].ccdSweptSphereRadius; }, | 1138 | (s) => { return s.m_params[0].ccdSweptSphereRadius; }, |
1008 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].ccdSweptSphereRadius, p, l, v); }, | 1139 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].ccdSweptSphereRadius, p, l, v); }, |
1009 | (s,o,v) => { BulletSimAPI.SetCcdSweepSphereRadius2(o.BSBody.ptr, v); } ), | 1140 | (s,o,v) => { BulletSimAPI.SetCcdSweptSphereRadius2(o.PhysBody.ptr, v); } ), |
1010 | new ParameterDefn("ContactProcessingThreshold", "Distance between contacts before doing collision check" , | 1141 | new ParameterDefn("ContactProcessingThreshold", "Distance between contacts before doing collision check" , |
1011 | 0.1f, | 1142 | 0.1f, |
1012 | (s,cf,p,v) => { s.m_params[0].contactProcessingThreshold = cf.GetFloat(p, v); }, | 1143 | (s,cf,p,v) => { s.m_params[0].contactProcessingThreshold = cf.GetFloat(p, v); }, |
1013 | (s) => { return s.m_params[0].contactProcessingThreshold; }, | 1144 | (s) => { return s.m_params[0].contactProcessingThreshold; }, |
1014 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].contactProcessingThreshold, p, l, v); }, | 1145 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].contactProcessingThreshold, p, l, v); }, |
1015 | (s,o,v) => { BulletSimAPI.SetContactProcessingThreshold2(o.BSBody.ptr, v); } ), | 1146 | (s,o,v) => { BulletSimAPI.SetContactProcessingThreshold2(o.PhysBody.ptr, v); } ), |
1016 | 1147 | ||
1148 | new ParameterDefn("TerrainImplementation", "Type of shape to use for terrain (0=heightmap, 1=mesh)", | ||
1149 | (float)BSTerrainPhys.TerrainImplementation.Mesh, | ||
1150 | (s,cf,p,v) => { s.m_params[0].terrainImplementation = cf.GetFloat(p,v); }, | ||
1151 | (s) => { return s.m_params[0].terrainImplementation; }, | ||
1152 | (s,p,l,v) => { s.m_params[0].terrainImplementation = v; } ), | ||
1017 | new ParameterDefn("TerrainFriction", "Factor to reduce movement against terrain surface" , | 1153 | new ParameterDefn("TerrainFriction", "Factor to reduce movement against terrain surface" , |
1018 | 0.5f, | 1154 | 0.5f, |
1019 | (s,cf,p,v) => { s.m_params[0].terrainFriction = cf.GetFloat(p, v); }, | 1155 | (s,cf,p,v) => { s.m_params[0].terrainFriction = cf.GetFloat(p, v); }, |
@@ -1049,11 +1185,16 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
1049 | (s,cf,p,v) => { s.m_params[0].avatarRestitution = cf.GetFloat(p, v); }, | 1185 | (s,cf,p,v) => { s.m_params[0].avatarRestitution = cf.GetFloat(p, v); }, |
1050 | (s) => { return s.m_params[0].avatarRestitution; }, | 1186 | (s) => { return s.m_params[0].avatarRestitution; }, |
1051 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarRestitution, p, l, v); } ), | 1187 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarRestitution, p, l, v); } ), |
1052 | new ParameterDefn("AvatarCapsuleRadius", "Radius of space around an avatar", | 1188 | new ParameterDefn("AvatarCapsuleWidth", "The distance between the sides of the avatar capsule", |
1053 | 0.37f, | 1189 | 0.6f, |
1054 | (s,cf,p,v) => { s.m_params[0].avatarCapsuleRadius = cf.GetFloat(p, v); }, | 1190 | (s,cf,p,v) => { s.m_params[0].avatarCapsuleWidth = cf.GetFloat(p, v); }, |
1055 | (s) => { return s.m_params[0].avatarCapsuleRadius; }, | 1191 | (s) => { return s.m_params[0].avatarCapsuleWidth; }, |
1056 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarCapsuleRadius, p, l, v); } ), | 1192 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarCapsuleWidth, p, l, v); } ), |
1193 | new ParameterDefn("AvatarCapsuleDepth", "The distance between the front and back of the avatar capsule", | ||
1194 | 0.45f, | ||
1195 | (s,cf,p,v) => { s.m_params[0].avatarCapsuleDepth = cf.GetFloat(p, v); }, | ||
1196 | (s) => { return s.m_params[0].avatarCapsuleDepth; }, | ||
1197 | (s,p,l,v) => { s.UpdateParameterObject(ref s.m_params[0].avatarCapsuleDepth, p, l, v); } ), | ||
1057 | new ParameterDefn("AvatarCapsuleHeight", "Default height of space around avatar", | 1198 | new ParameterDefn("AvatarCapsuleHeight", "Default height of space around avatar", |
1058 | 1.5f, | 1199 | 1.5f, |
1059 | (s,cf,p,v) => { s.m_params[0].avatarCapsuleHeight = cf.GetFloat(p, v); }, | 1200 | (s,cf,p,v) => { s.m_params[0].avatarCapsuleHeight = cf.GetFloat(p, v); }, |
@@ -1107,6 +1248,11 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
1107 | (s) => { return s.m_params[0].numberOfSolverIterations; }, | 1248 | (s) => { return s.m_params[0].numberOfSolverIterations; }, |
1108 | (s,p,l,v) => { s.m_params[0].numberOfSolverIterations = v; } ), | 1249 | (s,p,l,v) => { s.m_params[0].numberOfSolverIterations = v; } ), |
1109 | 1250 | ||
1251 | new ParameterDefn("LinksetImplementation", "Type of linkset implementation (0=Constraint, 1=Compound, 2=Manual)", | ||
1252 | (float)BSLinkset.LinksetImplementation.Compound, | ||
1253 | (s,cf,p,v) => { s.m_params[0].linksetImplementation = cf.GetFloat(p,v); }, | ||
1254 | (s) => { return s.m_params[0].linksetImplementation; }, | ||
1255 | (s,p,l,v) => { s.m_params[0].linksetImplementation = v; } ), | ||
1110 | new ParameterDefn("LinkConstraintUseFrameOffset", "For linksets built with constraints, enable frame offsetFor linksets built with constraints, enable frame offset.", | 1256 | new ParameterDefn("LinkConstraintUseFrameOffset", "For linksets built with constraints, enable frame offsetFor linksets built with constraints, enable frame offset.", |
1111 | ConfigurationParameters.numericFalse, | 1257 | ConfigurationParameters.numericFalse, |
1112 | (s,cf,p,v) => { s.m_params[0].linkConstraintUseFrameOffset = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); }, | 1258 | (s,cf,p,v) => { s.m_params[0].linkConstraintUseFrameOffset = s.NumericBool(cf.GetBoolean(p, s.BoolNumeric(v))); }, |
@@ -1128,12 +1274,12 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
1128 | (s) => { return s.m_params[0].linkConstraintTransMotorMaxForce; }, | 1274 | (s) => { return s.m_params[0].linkConstraintTransMotorMaxForce; }, |
1129 | (s,p,l,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = v; } ), | 1275 | (s,p,l,v) => { s.m_params[0].linkConstraintTransMotorMaxForce = v; } ), |
1130 | new ParameterDefn("LinkConstraintCFM", "Amount constraint can be violated. 0=no violation, 1=infinite. Default=0.1", | 1276 | new ParameterDefn("LinkConstraintCFM", "Amount constraint can be violated. 0=no violation, 1=infinite. Default=0.1", |
1131 | 0.001f, | 1277 | 0.1f, |
1132 | (s,cf,p,v) => { s.m_params[0].linkConstraintCFM = cf.GetFloat(p, v); }, | 1278 | (s,cf,p,v) => { s.m_params[0].linkConstraintCFM = cf.GetFloat(p, v); }, |
1133 | (s) => { return s.m_params[0].linkConstraintCFM; }, | 1279 | (s) => { return s.m_params[0].linkConstraintCFM; }, |
1134 | (s,p,l,v) => { s.m_params[0].linkConstraintCFM = v; } ), | 1280 | (s,p,l,v) => { s.m_params[0].linkConstraintCFM = v; } ), |
1135 | new ParameterDefn("LinkConstraintERP", "Amount constraint is corrected each tick. 0=none, 1=all. Default = 0.2", | 1281 | new ParameterDefn("LinkConstraintERP", "Amount constraint is corrected each tick. 0=none, 1=all. Default = 0.2", |
1136 | 0.8f, | 1282 | 0.1f, |
1137 | (s,cf,p,v) => { s.m_params[0].linkConstraintERP = cf.GetFloat(p, v); }, | 1283 | (s,cf,p,v) => { s.m_params[0].linkConstraintERP = cf.GetFloat(p, v); }, |
1138 | (s) => { return s.m_params[0].linkConstraintERP; }, | 1284 | (s) => { return s.m_params[0].linkConstraintERP; }, |
1139 | (s,p,l,v) => { s.m_params[0].linkConstraintERP = v; } ), | 1285 | (s,p,l,v) => { s.m_params[0].linkConstraintERP = v; } ), |
@@ -1259,7 +1405,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
1259 | // If the local ID is APPLY_TO_NONE, just change the default value | 1405 | // If the local ID is APPLY_TO_NONE, just change the default value |
1260 | // If the localID is APPLY_TO_ALL change the default value and apply the new value to all the lIDs | 1406 | // If the localID is APPLY_TO_ALL change the default value and apply the new value to all the lIDs |
1261 | // If the localID is a specific object, apply the parameter change to only that object | 1407 | // If the localID is a specific object, apply the parameter change to only that object |
1262 | protected void UpdateParameterObject(ref float defaultLoc, string parm, uint localID, float val) | 1408 | private void UpdateParameterObject(ref float defaultLoc, string parm, uint localID, float val) |
1263 | { | 1409 | { |
1264 | List<uint> objectIDs = new List<uint>(); | 1410 | List<uint> objectIDs = new List<uint>(); |
1265 | switch (localID) | 1411 | switch (localID) |
@@ -1284,7 +1430,7 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
1284 | } | 1430 | } |
1285 | 1431 | ||
1286 | // schedule the actual updating of the paramter to when the phys engine is not busy | 1432 | // schedule the actual updating of the paramter to when the phys engine is not busy |
1287 | protected void TaintedUpdateParameter(string parm, List<uint> lIDs, float val) | 1433 | private void TaintedUpdateParameter(string parm, List<uint> lIDs, float val) |
1288 | { | 1434 | { |
1289 | float xval = val; | 1435 | float xval = val; |
1290 | List<uint> xlIDs = lIDs; | 1436 | List<uint> xlIDs = lIDs; |
@@ -1326,14 +1472,24 @@ public class BSScene : PhysicsScene, IPhysicsParameters | |||
1326 | 1472 | ||
1327 | #endregion Runtime settable parameters | 1473 | #endregion Runtime settable parameters |
1328 | 1474 | ||
1475 | // Debugging routine for dumping detailed physical information for vehicle prims | ||
1476 | private void DumpVehicles() | ||
1477 | { | ||
1478 | foreach (BSPrim prim in m_vehicles) | ||
1479 | { | ||
1480 | BulletSimAPI.DumpRigidBody2(World.ptr, prim.PhysBody.ptr); | ||
1481 | BulletSimAPI.DumpCollisionShape2(World.ptr, prim.PhysShape.ptr); | ||
1482 | } | ||
1483 | } | ||
1484 | |||
1329 | // Invoke the detailed logger and output something if it's enabled. | 1485 | // Invoke the detailed logger and output something if it's enabled. |
1330 | public void DetailLog(string msg, params Object[] args) | 1486 | public void DetailLog(string msg, params Object[] args) |
1331 | { | 1487 | { |
1332 | PhysicsLogging.Write(msg, args); | 1488 | PhysicsLogging.Write(msg, args); |
1333 | // Add the Flush() if debugging crashes to get all the messages written out. | 1489 | // Add the Flush() if debugging crashes. Gets all the messages written out. |
1334 | // PhysicsLogging.Flush(); | 1490 | // PhysicsLogging.Flush(); |
1335 | } | 1491 | } |
1336 | // used to fill in the LocalID when there isn't one | 1492 | // Used to fill in the LocalID when there isn't one. It's the correct number of characters. |
1337 | public const string DetailLogZero = "0000000000"; | 1493 | public const string DetailLogZero = "0000000000"; |
1338 | 1494 | ||
1339 | } | 1495 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs index d3ba273..892c34b 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapeCollection.cs | |||
@@ -34,11 +34,11 @@ using OpenSim.Region.Physics.ConvexDecompositionDotNet; | |||
34 | 34 | ||
35 | namespace OpenSim.Region.Physics.BulletSPlugin | 35 | namespace OpenSim.Region.Physics.BulletSPlugin |
36 | { | 36 | { |
37 | public class BSShapeCollection : IDisposable | 37 | public sealed class BSShapeCollection : IDisposable |
38 | { | 38 | { |
39 | // private static string LogHeader = "[BULLETSIM SHAPE COLLECTION]"; | 39 | private static string LogHeader = "[BULLETSIM SHAPE COLLECTION]"; |
40 | 40 | ||
41 | protected BSScene PhysicsScene { get; set; } | 41 | private BSScene PhysicsScene { get; set; } |
42 | 42 | ||
43 | private Object m_collectionActivityLock = new Object(); | 43 | private Object m_collectionActivityLock = new Object(); |
44 | 44 | ||
@@ -48,6 +48,7 @@ public class BSShapeCollection : IDisposable | |||
48 | public IntPtr ptr; | 48 | public IntPtr ptr; |
49 | public int referenceCount; | 49 | public int referenceCount; |
50 | public DateTime lastReferenced; | 50 | public DateTime lastReferenced; |
51 | public UInt64 shapeKey; | ||
51 | } | 52 | } |
52 | 53 | ||
53 | // Description of a hull. | 54 | // Description of a hull. |
@@ -57,6 +58,7 @@ public class BSShapeCollection : IDisposable | |||
57 | public IntPtr ptr; | 58 | public IntPtr ptr; |
58 | public int referenceCount; | 59 | public int referenceCount; |
59 | public DateTime lastReferenced; | 60 | public DateTime lastReferenced; |
61 | public UInt64 shapeKey; | ||
60 | } | 62 | } |
61 | 63 | ||
62 | // The sharable set of meshes and hulls. Indexed by their shape hash. | 64 | // The sharable set of meshes and hulls. Indexed by their shape hash. |
@@ -89,10 +91,11 @@ public class BSShapeCollection : IDisposable | |||
89 | // higher level dependencies on the shape or body. Mostly used for LinkSets to | 91 | // higher level dependencies on the shape or body. Mostly used for LinkSets to |
90 | // remove the physical constraints before the body is destroyed. | 92 | // remove the physical constraints before the body is destroyed. |
91 | // Called at taint-time!! | 93 | // Called at taint-time!! |
92 | public bool GetBodyAndShape(bool forceRebuild, BulletSim sim, BSPhysObject prim, | 94 | public bool GetBodyAndShape(bool forceRebuild, BulletSim sim, BSPhysObject prim, |
93 | ShapeData shapeData, PrimitiveBaseShape pbs, | ||
94 | ShapeDestructionCallback shapeCallback, BodyDestructionCallback bodyCallback) | 95 | ShapeDestructionCallback shapeCallback, BodyDestructionCallback bodyCallback) |
95 | { | 96 | { |
97 | PhysicsScene.AssertInTaintTime("BSShapeCollection.GetBodyAndShape"); | ||
98 | |||
96 | bool ret = false; | 99 | bool ret = false; |
97 | 100 | ||
98 | // This lock could probably be pushed down lower but building shouldn't take long | 101 | // This lock could probably be pushed down lower but building shouldn't take long |
@@ -100,41 +103,38 @@ public class BSShapeCollection : IDisposable | |||
100 | { | 103 | { |
101 | // Do we have the correct geometry for this type of object? | 104 | // Do we have the correct geometry for this type of object? |
102 | // Updates prim.BSShape with information/pointers to shape. | 105 | // Updates prim.BSShape with information/pointers to shape. |
103 | // CreateGeom returns 'true' of BSShape as changed to a new shape. | 106 | // Returns 'true' of BSShape is changed to a new shape. |
104 | bool newGeom = CreateGeom(forceRebuild, prim, shapeData, pbs, shapeCallback); | 107 | bool newGeom = CreateGeom(forceRebuild, prim, shapeCallback); |
105 | // If we had to select a new shape geometry for the object, | 108 | // If we had to select a new shape geometry for the object, |
106 | // rebuild the body around it. | 109 | // rebuild the body around it. |
107 | // Updates prim.BSBody with information/pointers to requested body | 110 | // Updates prim.BSBody with information/pointers to requested body |
108 | bool newBody = CreateBody((newGeom || forceRebuild), prim, PhysicsScene.World, | 111 | // Returns 'true' if BSBody was changed. |
109 | prim.BSShape, shapeData, bodyCallback); | 112 | bool newBody = CreateBody((newGeom || forceRebuild), prim, PhysicsScene.World, |
113 | prim.PhysShape, bodyCallback); | ||
110 | ret = newGeom || newBody; | 114 | ret = newGeom || newBody; |
111 | } | 115 | } |
112 | DetailLog("{0},BSShapeCollection.GetBodyAndShape,force={1},ret={2},body={3},shape={4}", | 116 | DetailLog("{0},BSShapeCollection.GetBodyAndShape,taintExit,force={1},ret={2},body={3},shape={4}", |
113 | prim.LocalID, forceRebuild, ret, prim.BSBody, prim.BSShape); | 117 | prim.LocalID, forceRebuild, ret, prim.PhysBody, prim.PhysShape); |
114 | 118 | ||
115 | return ret; | 119 | return ret; |
116 | } | 120 | } |
117 | 121 | ||
118 | // Track another user of a body | 122 | // Track another user of a body. |
119 | // We presume the caller has allocated the body. | 123 | // We presume the caller has allocated the body. |
120 | // Bodies only have one user so the body is just put into the world if not already there. | 124 | // Bodies only have one user so the body is just put into the world if not already there. |
121 | public void ReferenceBody(BulletBody body, bool inTaintTime) | 125 | public void ReferenceBody(BulletBody body, bool inTaintTime) |
122 | { | 126 | { |
123 | lock (m_collectionActivityLock) | 127 | lock (m_collectionActivityLock) |
124 | { | 128 | { |
125 | DetailLog("{0},BSShapeCollection.ReferenceBody,newBody", body.ID, body); | 129 | DetailLog("{0},BSShapeCollection.ReferenceBody,newBody,body={1}", body.ID, body); |
126 | BSScene.TaintCallback createOperation = delegate() | 130 | PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.ReferenceBody", delegate() |
127 | { | 131 | { |
128 | if (!BulletSimAPI.IsInWorld2(body.ptr)) | 132 | if (!BulletSimAPI.IsInWorld2(body.ptr)) |
129 | { | 133 | { |
130 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, body.ptr); | 134 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, body.ptr); |
131 | DetailLog("{0},BSShapeCollection.ReferenceBody,addedToWorld,ref={1}", body.ID, body); | 135 | DetailLog("{0},BSShapeCollection.ReferenceBody,addedToWorld,ref={1}", body.ID, body); |
132 | } | 136 | } |
133 | }; | 137 | }); |
134 | if (inTaintTime) | ||
135 | createOperation(); | ||
136 | else | ||
137 | PhysicsScene.TaintedObject("BSShapeCollection.ReferenceBody", createOperation); | ||
138 | } | 138 | } |
139 | } | 139 | } |
140 | 140 | ||
@@ -147,25 +147,23 @@ public class BSShapeCollection : IDisposable | |||
147 | 147 | ||
148 | lock (m_collectionActivityLock) | 148 | lock (m_collectionActivityLock) |
149 | { | 149 | { |
150 | BSScene.TaintCallback removeOperation = delegate() | 150 | PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.DereferenceBody", delegate() |
151 | { | 151 | { |
152 | DetailLog("{0},BSShapeCollection.DereferenceBody,DestroyingBody. ptr={1}, inTaintTime={2}", | 152 | DetailLog("{0},BSShapeCollection.DereferenceBody,DestroyingBody,body={1},inTaintTime={2}", |
153 | body.ID, body.ptr.ToString("X"), inTaintTime); | 153 | body.ID, body, inTaintTime); |
154 | // If the caller needs to know the old body is going away, pass the event up. | 154 | // If the caller needs to know the old body is going away, pass the event up. |
155 | if (bodyCallback != null) bodyCallback(body); | 155 | if (bodyCallback != null) bodyCallback(body); |
156 | 156 | ||
157 | // It may have already been removed from the world in which case the next is a NOOP. | 157 | if (BulletSimAPI.IsInWorld2(body.ptr)) |
158 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, body.ptr); | 158 | { |
159 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, body.ptr); | ||
160 | DetailLog("{0},BSShapeCollection.DereferenceBody,removingFromWorld. Body={1}", body.ID, body); | ||
161 | } | ||
159 | 162 | ||
160 | // Zero any reference to the shape so it is not freed when the body is deleted. | 163 | // Zero any reference to the shape so it is not freed when the body is deleted. |
161 | BulletSimAPI.SetCollisionShape2(PhysicsScene.World.ptr, body.ptr, IntPtr.Zero); | 164 | BulletSimAPI.SetCollisionShape2(PhysicsScene.World.ptr, body.ptr, IntPtr.Zero); |
162 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, body.ptr); | 165 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, body.ptr); |
163 | }; | 166 | }); |
164 | // If already in taint-time, do the operations now. Otherwise queue for later. | ||
165 | if (inTaintTime) | ||
166 | removeOperation(); | ||
167 | else | ||
168 | PhysicsScene.TaintedObject("BSShapeCollection.DereferenceBody", removeOperation); | ||
169 | } | 167 | } |
170 | } | 168 | } |
171 | 169 | ||
@@ -175,12 +173,12 @@ public class BSShapeCollection : IDisposable | |||
175 | // Meshes and hulls for the same shape have the same hash key. | 173 | // Meshes and hulls for the same shape have the same hash key. |
176 | // NOTE that native shapes are not added to the mesh list or removed. | 174 | // NOTE that native shapes are not added to the mesh list or removed. |
177 | // Returns 'true' if this is the initial reference to the shape. Otherwise reused. | 175 | // Returns 'true' if this is the initial reference to the shape. Otherwise reused. |
178 | private bool ReferenceShape(BulletShape shape) | 176 | public bool ReferenceShape(BulletShape shape) |
179 | { | 177 | { |
180 | bool ret = false; | 178 | bool ret = false; |
181 | switch (shape.type) | 179 | switch (shape.type) |
182 | { | 180 | { |
183 | case ShapeData.PhysicsShapeType.SHAPE_MESH: | 181 | case BSPhysicsShapeType.SHAPE_MESH: |
184 | MeshDesc meshDesc; | 182 | MeshDesc meshDesc; |
185 | if (Meshes.TryGetValue(shape.shapeKey, out meshDesc)) | 183 | if (Meshes.TryGetValue(shape.shapeKey, out meshDesc)) |
186 | { | 184 | { |
@@ -193,6 +191,7 @@ public class BSShapeCollection : IDisposable | |||
193 | { | 191 | { |
194 | // This is a new reference to a mesh | 192 | // This is a new reference to a mesh |
195 | meshDesc.ptr = shape.ptr; | 193 | meshDesc.ptr = shape.ptr; |
194 | meshDesc.shapeKey = shape.shapeKey; | ||
196 | // We keep a reference to the underlying IMesh data so a hull can be built | 195 | // We keep a reference to the underlying IMesh data so a hull can be built |
197 | meshDesc.referenceCount = 1; | 196 | meshDesc.referenceCount = 1; |
198 | DetailLog("{0},BSShapeCollection.ReferenceShape,newMesh,key={1},cnt={2}", | 197 | DetailLog("{0},BSShapeCollection.ReferenceShape,newMesh,key={1},cnt={2}", |
@@ -202,7 +201,7 @@ public class BSShapeCollection : IDisposable | |||
202 | meshDesc.lastReferenced = System.DateTime.Now; | 201 | meshDesc.lastReferenced = System.DateTime.Now; |
203 | Meshes[shape.shapeKey] = meshDesc; | 202 | Meshes[shape.shapeKey] = meshDesc; |
204 | break; | 203 | break; |
205 | case ShapeData.PhysicsShapeType.SHAPE_HULL: | 204 | case BSPhysicsShapeType.SHAPE_HULL: |
206 | HullDesc hullDesc; | 205 | HullDesc hullDesc; |
207 | if (Hulls.TryGetValue(shape.shapeKey, out hullDesc)) | 206 | if (Hulls.TryGetValue(shape.shapeKey, out hullDesc)) |
208 | { | 207 | { |
@@ -215,6 +214,7 @@ public class BSShapeCollection : IDisposable | |||
215 | { | 214 | { |
216 | // This is a new reference to a hull | 215 | // This is a new reference to a hull |
217 | hullDesc.ptr = shape.ptr; | 216 | hullDesc.ptr = shape.ptr; |
217 | hullDesc.shapeKey = shape.shapeKey; | ||
218 | hullDesc.referenceCount = 1; | 218 | hullDesc.referenceCount = 1; |
219 | DetailLog("{0},BSShapeCollection.ReferenceShape,newHull,key={1},cnt={2}", | 219 | DetailLog("{0},BSShapeCollection.ReferenceShape,newHull,key={1},cnt={2}", |
220 | BSScene.DetailLogZero, shape.shapeKey.ToString("X"), hullDesc.referenceCount); | 220 | BSScene.DetailLogZero, shape.shapeKey.ToString("X"), hullDesc.referenceCount); |
@@ -224,7 +224,7 @@ public class BSShapeCollection : IDisposable | |||
224 | hullDesc.lastReferenced = System.DateTime.Now; | 224 | hullDesc.lastReferenced = System.DateTime.Now; |
225 | Hulls[shape.shapeKey] = hullDesc; | 225 | Hulls[shape.shapeKey] = hullDesc; |
226 | break; | 226 | break; |
227 | case ShapeData.PhysicsShapeType.SHAPE_UNKNOWN: | 227 | case BSPhysicsShapeType.SHAPE_UNKNOWN: |
228 | break; | 228 | break; |
229 | default: | 229 | default: |
230 | // Native shapes are not tracked and they don't go into any list | 230 | // Native shapes are not tracked and they don't go into any list |
@@ -239,7 +239,7 @@ public class BSShapeCollection : IDisposable | |||
239 | if (shape.ptr == IntPtr.Zero) | 239 | if (shape.ptr == IntPtr.Zero) |
240 | return; | 240 | return; |
241 | 241 | ||
242 | BSScene.TaintCallback dereferenceOperation = delegate() | 242 | PhysicsScene.TaintedObject(inTaintTime, "BSShapeCollection.DereferenceShape", delegate() |
243 | { | 243 | { |
244 | if (shape.ptr != IntPtr.Zero) | 244 | if (shape.ptr != IntPtr.Zero) |
245 | { | 245 | { |
@@ -255,31 +255,23 @@ public class BSShapeCollection : IDisposable | |||
255 | { | 255 | { |
256 | switch (shape.type) | 256 | switch (shape.type) |
257 | { | 257 | { |
258 | case ShapeData.PhysicsShapeType.SHAPE_HULL: | 258 | case BSPhysicsShapeType.SHAPE_HULL: |
259 | DereferenceHull(shape, shapeCallback); | 259 | DereferenceHull(shape, shapeCallback); |
260 | break; | 260 | break; |
261 | case ShapeData.PhysicsShapeType.SHAPE_MESH: | 261 | case BSPhysicsShapeType.SHAPE_MESH: |
262 | DereferenceMesh(shape, shapeCallback); | 262 | DereferenceMesh(shape, shapeCallback); |
263 | break; | 263 | break; |
264 | case ShapeData.PhysicsShapeType.SHAPE_UNKNOWN: | 264 | case BSPhysicsShapeType.SHAPE_COMPOUND: |
265 | DereferenceCompound(shape, shapeCallback); | ||
266 | break; | ||
267 | case BSPhysicsShapeType.SHAPE_UNKNOWN: | ||
265 | break; | 268 | break; |
266 | default: | 269 | default: |
267 | break; | 270 | break; |
268 | } | 271 | } |
269 | } | 272 | } |
270 | } | 273 | } |
271 | }; | 274 | }); |
272 | if (inTaintTime) | ||
273 | { | ||
274 | lock (m_collectionActivityLock) | ||
275 | { | ||
276 | dereferenceOperation(); | ||
277 | } | ||
278 | } | ||
279 | else | ||
280 | { | ||
281 | PhysicsScene.TaintedObject("BSShapeCollection.DereferenceShape", dereferenceOperation); | ||
282 | } | ||
283 | } | 275 | } |
284 | 276 | ||
285 | // Count down the reference count for a mesh shape | 277 | // Count down the reference count for a mesh shape |
@@ -294,8 +286,8 @@ public class BSShapeCollection : IDisposable | |||
294 | if (shapeCallback != null) shapeCallback(shape); | 286 | if (shapeCallback != null) shapeCallback(shape); |
295 | meshDesc.lastReferenced = System.DateTime.Now; | 287 | meshDesc.lastReferenced = System.DateTime.Now; |
296 | Meshes[shape.shapeKey] = meshDesc; | 288 | Meshes[shape.shapeKey] = meshDesc; |
297 | DetailLog("{0},BSShapeCollection.DereferenceMesh,key={1},refCnt={2}", | 289 | DetailLog("{0},BSShapeCollection.DereferenceMesh,shape={1},refCnt={2}", |
298 | BSScene.DetailLogZero, shape.shapeKey.ToString("X"), meshDesc.referenceCount); | 290 | BSScene.DetailLogZero, shape, meshDesc.referenceCount); |
299 | 291 | ||
300 | } | 292 | } |
301 | } | 293 | } |
@@ -309,11 +301,94 @@ public class BSShapeCollection : IDisposable | |||
309 | { | 301 | { |
310 | hullDesc.referenceCount--; | 302 | hullDesc.referenceCount--; |
311 | // TODO: release the Bullet storage (aging old entries?) | 303 | // TODO: release the Bullet storage (aging old entries?) |
304 | |||
305 | // Tell upper layers that, if they have dependencies on this shape, this link is going away | ||
312 | if (shapeCallback != null) shapeCallback(shape); | 306 | if (shapeCallback != null) shapeCallback(shape); |
307 | |||
313 | hullDesc.lastReferenced = System.DateTime.Now; | 308 | hullDesc.lastReferenced = System.DateTime.Now; |
314 | Hulls[shape.shapeKey] = hullDesc; | 309 | Hulls[shape.shapeKey] = hullDesc; |
315 | DetailLog("{0},BSShapeCollection.DereferenceHull,key={1},refCnt={2}", | 310 | DetailLog("{0},BSShapeCollection.DereferenceHull,shape={1},refCnt={2}", |
316 | BSScene.DetailLogZero, shape.shapeKey.ToString("X"), hullDesc.referenceCount); | 311 | BSScene.DetailLogZero, shape, hullDesc.referenceCount); |
312 | } | ||
313 | } | ||
314 | |||
315 | // Remove a reference to a compound shape. | ||
316 | // Taking a compound shape apart is a little tricky because if you just delete the | ||
317 | // physical shape, it will free all the underlying children. We can't do that because | ||
318 | // they could be shared. So, this removes each of the children from the compound and | ||
319 | // dereferences them separately before destroying the compound collision object itself. | ||
320 | // Called at taint-time. | ||
321 | private void DereferenceCompound(BulletShape shape, ShapeDestructionCallback shapeCallback) | ||
322 | { | ||
323 | if (!BulletSimAPI.IsCompound2(shape.ptr)) | ||
324 | { | ||
325 | // Failed the sanity check!! | ||
326 | PhysicsScene.Logger.ErrorFormat("{0} Attempt to free a compound shape that is not compound!! type={1}, ptr={2}", | ||
327 | LogHeader, shape.type, shape.ptr.ToString("X")); | ||
328 | DetailLog("{0},BSShapeCollection.DereferenceCompound,notACompoundShape,type={1},ptr={2}", | ||
329 | BSScene.DetailLogZero, shape.type, shape.ptr.ToString("X")); | ||
330 | return; | ||
331 | } | ||
332 | |||
333 | int numChildren = BulletSimAPI.GetNumberOfCompoundChildren2(shape.ptr); | ||
334 | DetailLog("{0},BSShapeCollection.DereferenceCompound,shape={1},children={2}", BSScene.DetailLogZero, shape, numChildren); | ||
335 | |||
336 | for (int ii = numChildren - 1; ii >= 0; ii--) | ||
337 | { | ||
338 | IntPtr childShape = BulletSimAPI.RemoveChildShapeFromCompoundShapeIndex2(shape.ptr, ii); | ||
339 | DereferenceAnonCollisionShape(childShape); | ||
340 | } | ||
341 | BulletSimAPI.DeleteCollisionShape2(PhysicsScene.World.ptr, shape.ptr); | ||
342 | } | ||
343 | |||
344 | // Sometimes we have a pointer to a collision shape but don't know what type it is. | ||
345 | // Figure out type and call the correct dereference routine. | ||
346 | // Called at taint-time. | ||
347 | private void DereferenceAnonCollisionShape(IntPtr cShape) | ||
348 | { | ||
349 | MeshDesc meshDesc; | ||
350 | HullDesc hullDesc; | ||
351 | |||
352 | BulletShape shapeInfo = new BulletShape(cShape); | ||
353 | if (TryGetMeshByPtr(cShape, out meshDesc)) | ||
354 | { | ||
355 | shapeInfo.type = BSPhysicsShapeType.SHAPE_MESH; | ||
356 | shapeInfo.shapeKey = meshDesc.shapeKey; | ||
357 | } | ||
358 | else | ||
359 | { | ||
360 | if (TryGetHullByPtr(cShape, out hullDesc)) | ||
361 | { | ||
362 | shapeInfo.type = BSPhysicsShapeType.SHAPE_HULL; | ||
363 | shapeInfo.shapeKey = hullDesc.shapeKey; | ||
364 | } | ||
365 | else | ||
366 | { | ||
367 | if (BulletSimAPI.IsCompound2(cShape)) | ||
368 | { | ||
369 | shapeInfo.type = BSPhysicsShapeType.SHAPE_COMPOUND; | ||
370 | } | ||
371 | else | ||
372 | { | ||
373 | if (BulletSimAPI.IsNativeShape2(cShape)) | ||
374 | { | ||
375 | shapeInfo.isNativeShape = true; | ||
376 | shapeInfo.type = BSPhysicsShapeType.SHAPE_BOX; // (technically, type doesn't matter) | ||
377 | } | ||
378 | } | ||
379 | } | ||
380 | } | ||
381 | |||
382 | DetailLog("{0},BSShapeCollection.DereferenceAnonCollisionShape,shape={1}", BSScene.DetailLogZero, shapeInfo); | ||
383 | |||
384 | if (shapeInfo.type != BSPhysicsShapeType.SHAPE_UNKNOWN) | ||
385 | { | ||
386 | DereferenceShape(shapeInfo, true, null); | ||
387 | } | ||
388 | else | ||
389 | { | ||
390 | PhysicsScene.Logger.ErrorFormat("{0} Could not decypher shape type. Region={1}, addr={2}", | ||
391 | LogHeader, PhysicsScene.RegionName, cShape.ToString("X")); | ||
317 | } | 392 | } |
318 | } | 393 | } |
319 | 394 | ||
@@ -325,21 +400,46 @@ public class BSShapeCollection : IDisposable | |||
325 | // Info in prim.BSShape is updated to the new shape. | 400 | // Info in prim.BSShape is updated to the new shape. |
326 | // Returns 'true' if the geometry was rebuilt. | 401 | // Returns 'true' if the geometry was rebuilt. |
327 | // Called at taint-time! | 402 | // Called at taint-time! |
328 | private bool CreateGeom(bool forceRebuild, BSPhysObject prim, ShapeData shapeData, | 403 | private bool CreateGeom(bool forceRebuild, BSPhysObject prim, ShapeDestructionCallback shapeCallback) |
329 | PrimitiveBaseShape pbs, ShapeDestructionCallback shapeCallback) | ||
330 | { | 404 | { |
331 | bool ret = false; | 405 | bool ret = false; |
332 | bool haveShape = false; | 406 | bool haveShape = false; |
333 | bool nativeShapePossible = true; | ||
334 | 407 | ||
335 | if (shapeData.Type == ShapeData.PhysicsShapeType.SHAPE_AVATAR) | 408 | if (!haveShape && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_CAPSULE) |
336 | { | 409 | { |
337 | // an avatar capsule is close to a native shape (it is not shared) | 410 | // an avatar capsule is close to a native shape (it is not shared) |
338 | ret = GetReferenceToNativeShape(prim, shapeData, ShapeData.PhysicsShapeType.SHAPE_AVATAR, | 411 | ret = GetReferenceToNativeShape(prim, BSPhysicsShapeType.SHAPE_CAPSULE, |
339 | ShapeData.FixedShapeKey.KEY_CAPSULE, shapeCallback); | 412 | FixedShapeKey.KEY_CAPSULE, shapeCallback); |
340 | DetailLog("{0},BSShapeCollection.CreateGeom,avatarCapsule,shape={1}", prim.LocalID, prim.BSShape); | 413 | DetailLog("{0},BSShapeCollection.CreateGeom,avatarCapsule,shape={1}", prim.LocalID, prim.PhysShape); |
414 | ret = true; | ||
341 | haveShape = true; | 415 | haveShape = true; |
342 | } | 416 | } |
417 | |||
418 | // Compound shapes are handled special as they are rebuilt from scratch. | ||
419 | // This isn't too great a hardship since most of the child shapes will already been created. | ||
420 | if (!haveShape && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_COMPOUND) | ||
421 | { | ||
422 | ret = GetReferenceToCompoundShape(prim, shapeCallback); | ||
423 | DetailLog("{0},BSShapeCollection.CreateGeom,compoundShape,shape={1}", prim.LocalID, prim.PhysShape); | ||
424 | haveShape = true; | ||
425 | } | ||
426 | |||
427 | if (!haveShape) | ||
428 | { | ||
429 | ret = CreateGeomNonSpecial(forceRebuild, prim, shapeCallback); | ||
430 | } | ||
431 | |||
432 | return ret; | ||
433 | } | ||
434 | |||
435 | // Create a mesh/hull shape or a native shape if 'nativeShapePossible' is 'true'. | ||
436 | private bool CreateGeomNonSpecial(bool forceRebuild, BSPhysObject prim, ShapeDestructionCallback shapeCallback) | ||
437 | { | ||
438 | bool ret = false; | ||
439 | bool haveShape = false; | ||
440 | bool nativeShapePossible = true; | ||
441 | PrimitiveBaseShape pbs = prim.BaseShape; | ||
442 | |||
343 | // If the prim attributes are simple, this could be a simple Bullet native shape | 443 | // If the prim attributes are simple, this could be a simple Bullet native shape |
344 | if (!haveShape | 444 | if (!haveShape |
345 | && pbs != null | 445 | && pbs != null |
@@ -353,97 +453,120 @@ public class BSShapeCollection : IDisposable | |||
353 | && pbs.PathScaleX == 100 && pbs.PathScaleY == 100 | 453 | && pbs.PathScaleX == 100 && pbs.PathScaleY == 100 |
354 | && pbs.PathShearX == 0 && pbs.PathShearY == 0) ) ) | 454 | && pbs.PathShearX == 0 && pbs.PathShearY == 0) ) ) |
355 | { | 455 | { |
456 | // It doesn't look like Bullet scales spheres so make sure the scales are all equal | ||
356 | if ((pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1) | 457 | if ((pbs.ProfileShape == ProfileShape.HalfCircle && pbs.PathCurve == (byte)Extrusion.Curve1) |
357 | && pbs.Scale.X == pbs.Scale.Y && pbs.Scale.Y == pbs.Scale.Z) | 458 | && pbs.Scale.X == pbs.Scale.Y && pbs.Scale.Y == pbs.Scale.Z) |
358 | { | 459 | { |
359 | haveShape = true; | 460 | haveShape = true; |
360 | if (forceRebuild | 461 | if (forceRebuild |
361 | || prim.Scale != shapeData.Size | 462 | || prim.Scale != prim.Size |
362 | || prim.BSShape.type != ShapeData.PhysicsShapeType.SHAPE_SPHERE | 463 | || prim.PhysShape.type != BSPhysicsShapeType.SHAPE_SPHERE |
363 | ) | 464 | ) |
364 | { | 465 | { |
365 | ret = GetReferenceToNativeShape(prim, shapeData, ShapeData.PhysicsShapeType.SHAPE_SPHERE, | 466 | ret = GetReferenceToNativeShape(prim, BSPhysicsShapeType.SHAPE_SPHERE, |
366 | ShapeData.FixedShapeKey.KEY_SPHERE, shapeCallback); | 467 | FixedShapeKey.KEY_SPHERE, shapeCallback); |
367 | DetailLog("{0},BSShapeCollection.CreateGeom,sphere,force={1},shape={2}", | 468 | DetailLog("{0},BSShapeCollection.CreateGeom,sphere,force={1},shape={2}", |
368 | prim.LocalID, forceRebuild, prim.BSShape); | 469 | prim.LocalID, forceRebuild, prim.PhysShape); |
369 | } | 470 | } |
370 | } | 471 | } |
371 | if (pbs.ProfileShape == ProfileShape.Square && pbs.PathCurve == (byte)Extrusion.Straight) | 472 | if (!haveShape && pbs.ProfileShape == ProfileShape.Square && pbs.PathCurve == (byte)Extrusion.Straight) |
372 | { | 473 | { |
373 | haveShape = true; | 474 | haveShape = true; |
374 | if (forceRebuild | 475 | if (forceRebuild |
375 | || prim.Scale != shapeData.Size | 476 | || prim.Scale != prim.Size |
376 | || prim.BSShape.type != ShapeData.PhysicsShapeType.SHAPE_BOX | 477 | || prim.PhysShape.type != BSPhysicsShapeType.SHAPE_BOX |
377 | ) | 478 | ) |
378 | { | 479 | { |
379 | ret = GetReferenceToNativeShape( prim, shapeData, ShapeData.PhysicsShapeType.SHAPE_BOX, | 480 | ret = GetReferenceToNativeShape( prim, BSPhysicsShapeType.SHAPE_BOX, |
380 | ShapeData.FixedShapeKey.KEY_BOX, shapeCallback); | 481 | FixedShapeKey.KEY_BOX, shapeCallback); |
381 | DetailLog("{0},BSShapeCollection.CreateGeom,box,force={1},shape={2}", | 482 | DetailLog("{0},BSShapeCollection.CreateGeom,box,force={1},shape={2}", |
382 | prim.LocalID, forceRebuild, prim.BSShape); | 483 | prim.LocalID, forceRebuild, prim.PhysShape); |
383 | } | 484 | } |
384 | } | 485 | } |
385 | } | 486 | } |
487 | |||
386 | // If a simple shape is not happening, create a mesh and possibly a hull. | 488 | // If a simple shape is not happening, create a mesh and possibly a hull. |
387 | // Note that if it's a native shape, the check for physical/non-physical is not | ||
388 | // made. Native shapes are best used in either case. | ||
389 | if (!haveShape && pbs != null) | 489 | if (!haveShape && pbs != null) |
390 | { | 490 | { |
391 | if (prim.IsPhysical && PhysicsScene.ShouldUseHullsForPhysicalObjects) | 491 | ret = CreateGeomMeshOrHull(prim, shapeCallback); |
392 | { | 492 | } |
393 | // Update prim.BSShape to reference a hull of this shape. | 493 | |
394 | ret = GetReferenceToHull(prim, shapeData, pbs, shapeCallback); | 494 | return ret; |
395 | DetailLog("{0},BSShapeCollection.CreateGeom,hull,shape={1},key={2}", | 495 | } |
396 | shapeData.ID, prim.BSShape, prim.BSShape.shapeKey.ToString("X")); | 496 | |
397 | } | 497 | public bool CreateGeomMeshOrHull(BSPhysObject prim, ShapeDestructionCallback shapeCallback) |
398 | else | 498 | { |
399 | { | 499 | |
400 | ret = GetReferenceToMesh(prim, shapeData, pbs, shapeCallback); | 500 | bool ret = false; |
401 | DetailLog("{0},BSShapeCollection.CreateGeom,mesh,shape={1},key={2}", | 501 | // Note that if it's a native shape, the check for physical/non-physical is not |
402 | shapeData.ID, prim.BSShape, prim.BSShape.shapeKey.ToString("X")); | 502 | // made. Native shapes work in either case. |
403 | } | 503 | if (prim.IsPhysical && PhysicsScene.ShouldUseHullsForPhysicalObjects) |
504 | { | ||
505 | // Update prim.BSShape to reference a hull of this shape. | ||
506 | ret = GetReferenceToHull(prim,shapeCallback); | ||
507 | DetailLog("{0},BSShapeCollection.CreateGeom,hull,shape={1},key={2}", | ||
508 | prim.LocalID, prim.PhysShape, prim.PhysShape.shapeKey.ToString("X")); | ||
509 | } | ||
510 | else | ||
511 | { | ||
512 | ret = GetReferenceToMesh(prim, shapeCallback); | ||
513 | DetailLog("{0},BSShapeCollection.CreateGeom,mesh,shape={1},key={2}", | ||
514 | prim.LocalID, prim.PhysShape, prim.PhysShape.shapeKey.ToString("X")); | ||
404 | } | 515 | } |
405 | return ret; | 516 | return ret; |
406 | } | 517 | } |
407 | 518 | ||
408 | // Creates a native shape and assignes it to prim.BSShape. | 519 | // Creates a native shape and assignes it to prim.BSShape. |
409 | // "Native" shapes are never shared. they are created here and destroyed in DereferenceShape(). | 520 | // "Native" shapes are never shared. they are created here and destroyed in DereferenceShape(). |
410 | private bool GetReferenceToNativeShape(BSPhysObject prim, ShapeData shapeData, | 521 | private bool GetReferenceToNativeShape(BSPhysObject prim, |
411 | ShapeData.PhysicsShapeType shapeType, ShapeData.FixedShapeKey shapeKey, | 522 | BSPhysicsShapeType shapeType, FixedShapeKey shapeKey, |
412 | ShapeDestructionCallback shapeCallback) | 523 | ShapeDestructionCallback shapeCallback) |
413 | { | 524 | { |
414 | |||
415 | shapeData.Type = shapeType; | ||
416 | // Bullet native objects are scaled by the Bullet engine so pass the size in | ||
417 | prim.Scale = shapeData.Size; | ||
418 | shapeData.Scale = shapeData.Size; | ||
419 | |||
420 | // release any previous shape | 525 | // release any previous shape |
421 | DereferenceShape(prim.BSShape, true, shapeCallback); | 526 | DereferenceShape(prim.PhysShape, true, shapeCallback); |
422 | 527 | ||
423 | BulletShape newShape = BuildPhysicalNativeShape(shapeType, shapeData, shapeKey); | 528 | BulletShape newShape = BuildPhysicalNativeShape(prim, shapeType, shapeKey); |
424 | 529 | ||
425 | // Don't need to do a 'ReferenceShape()' here because native shapes are not shared. | 530 | // Don't need to do a 'ReferenceShape()' here because native shapes are not shared. |
426 | DetailLog("{0},BSShapeCollection.AddNativeShapeToPrim,create,newshape={1},scale={2}", | 531 | DetailLog("{0},BSShapeCollection.AddNativeShapeToPrim,create,newshape={1},scale={2}", |
427 | shapeData.ID, newShape, shapeData.Scale); | 532 | prim.LocalID, newShape, prim.Scale); |
428 | 533 | ||
429 | prim.BSShape = newShape; | 534 | prim.PhysShape = newShape; |
430 | return true; | 535 | return true; |
431 | } | 536 | } |
432 | 537 | ||
433 | private BulletShape BuildPhysicalNativeShape(ShapeData.PhysicsShapeType shapeType, | 538 | private BulletShape BuildPhysicalNativeShape(BSPhysObject prim, BSPhysicsShapeType shapeType, |
434 | ShapeData shapeData, ShapeData.FixedShapeKey shapeKey) | 539 | FixedShapeKey shapeKey) |
435 | { | 540 | { |
436 | BulletShape newShape; | 541 | BulletShape newShape; |
437 | 542 | // Need to make sure the passed shape information is for the native type. | |
438 | if (shapeType == ShapeData.PhysicsShapeType.SHAPE_AVATAR) | 543 | ShapeData nativeShapeData = new ShapeData(); |
544 | nativeShapeData.Type = shapeType; | ||
545 | nativeShapeData.ID = prim.LocalID; | ||
546 | nativeShapeData.Scale = prim.Scale; | ||
547 | nativeShapeData.Size = prim.Scale; // unneeded, I think. | ||
548 | nativeShapeData.MeshKey = (ulong)shapeKey; | ||
549 | nativeShapeData.HullKey = (ulong)shapeKey; | ||
550 | |||
551 | if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE) | ||
439 | { | 552 | { |
553 | // The proper scale has been calculated in the prim. | ||
440 | newShape = new BulletShape( | 554 | newShape = new BulletShape( |
441 | BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1.0f, 1.0f, shapeData.Scale), | 555 | BulletSimAPI.BuildCapsuleShape2(PhysicsScene.World.ptr, 1f, 1f, prim.Scale) |
442 | shapeType); | 556 | , shapeType); |
557 | DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale); | ||
443 | } | 558 | } |
444 | else | 559 | else |
445 | { | 560 | { |
446 | newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, shapeData), shapeType); | 561 | // Native shapes are scaled in Bullet so set the scaling to the size |
562 | prim.Scale = prim.Size; | ||
563 | nativeShapeData.Scale = prim.Scale; | ||
564 | newShape = new BulletShape(BulletSimAPI.BuildNativeShape2(PhysicsScene.World.ptr, nativeShapeData), shapeType); | ||
565 | } | ||
566 | if (newShape.ptr == IntPtr.Zero) | ||
567 | { | ||
568 | PhysicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}", | ||
569 | LogHeader, prim.LocalID, shapeType); | ||
447 | } | 570 | } |
448 | newShape.shapeKey = (System.UInt64)shapeKey; | 571 | newShape.shapeKey = (System.UInt64)shapeKey; |
449 | newShape.isNativeShape = true; | 572 | newShape.isNativeShape = true; |
@@ -455,33 +578,32 @@ public class BSShapeCollection : IDisposable | |||
455 | // Dereferences previous shape in BSShape and adds a reference for this new shape. | 578 | // Dereferences previous shape in BSShape and adds a reference for this new shape. |
456 | // Returns 'true' of a mesh was actually built. Otherwise . | 579 | // Returns 'true' of a mesh was actually built. Otherwise . |
457 | // Called at taint-time! | 580 | // Called at taint-time! |
458 | private bool GetReferenceToMesh(BSPhysObject prim, ShapeData shapeData, PrimitiveBaseShape pbs, | 581 | private bool GetReferenceToMesh(BSPhysObject prim, ShapeDestructionCallback shapeCallback) |
459 | ShapeDestructionCallback shapeCallback) | ||
460 | { | 582 | { |
461 | BulletShape newShape = new BulletShape(IntPtr.Zero); | 583 | BulletShape newShape = new BulletShape(IntPtr.Zero); |
462 | 584 | ||
463 | float lod; | 585 | float lod; |
464 | System.UInt64 newMeshKey = ComputeShapeKey(shapeData, pbs, out lod); | 586 | System.UInt64 newMeshKey = ComputeShapeKey(prim.Size, prim.BaseShape, out lod); |
465 | 587 | ||
466 | // if this new shape is the same as last time, don't recreate the mesh | 588 | // if this new shape is the same as last time, don't recreate the mesh |
467 | if (newMeshKey == prim.BSShape.shapeKey && prim.BSShape.type == ShapeData.PhysicsShapeType.SHAPE_MESH) | 589 | if (newMeshKey == prim.PhysShape.shapeKey && prim.PhysShape.type == BSPhysicsShapeType.SHAPE_MESH) |
468 | return false; | 590 | return false; |
469 | 591 | ||
470 | DetailLog("{0},BSShapeCollection.CreateGeomMesh,create,oldKey={1},newKey={2}", | 592 | DetailLog("{0},BSShapeCollection.GetReferenceToMesh,create,oldKey={1},newKey={2}", |
471 | prim.LocalID, prim.BSShape.shapeKey.ToString("X"), newMeshKey.ToString("X")); | 593 | prim.LocalID, prim.PhysShape.shapeKey.ToString("X"), newMeshKey.ToString("X")); |
472 | 594 | ||
473 | // Since we're recreating new, get rid of the reference to the previous shape | 595 | // Since we're recreating new, get rid of the reference to the previous shape |
474 | DereferenceShape(prim.BSShape, true, shapeCallback); | 596 | DereferenceShape(prim.PhysShape, true, shapeCallback); |
475 | 597 | ||
476 | newShape = CreatePhysicalMesh(prim.PhysObjectName, newMeshKey, pbs, shapeData.Size, lod); | 598 | newShape = CreatePhysicalMesh(prim.PhysObjectName, newMeshKey, prim.BaseShape, prim.Size, lod); |
477 | // Take evasive action if the mesh was not constructed. | 599 | // Take evasive action if the mesh was not constructed. |
478 | newShape = VerifyMeshCreated(newShape, prim, shapeData, pbs); | 600 | newShape = VerifyMeshCreated(newShape, prim); |
479 | 601 | ||
480 | ReferenceShape(newShape); | 602 | ReferenceShape(newShape); |
481 | 603 | ||
482 | // meshes are already scaled by the meshmerizer | 604 | // meshes are already scaled by the meshmerizer |
483 | prim.Scale = new OMV.Vector3(1f, 1f, 1f); | 605 | prim.Scale = new OMV.Vector3(1f, 1f, 1f); |
484 | prim.BSShape = newShape; | 606 | prim.PhysShape = newShape; |
485 | 607 | ||
486 | return true; // 'true' means a new shape has been added to this prim | 608 | return true; // 'true' means a new shape has been added to this prim |
487 | } | 609 | } |
@@ -515,14 +637,14 @@ public class BSShapeCollection : IDisposable | |||
515 | verticesAsFloats[vi++] = vv.Z; | 637 | verticesAsFloats[vi++] = vv.Z; |
516 | } | 638 | } |
517 | 639 | ||
518 | // m_log.DebugFormat("{0}: CreateGeomMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}", | 640 | // m_log.DebugFormat("{0}: BSShapeCollection.CreatePhysicalMesh: calling CreateMesh. lid={1}, key={2}, indices={3}, vertices={4}", |
519 | // LogHeader, prim.LocalID, newMeshKey, indices.Length, vertices.Count); | 641 | // LogHeader, prim.LocalID, newMeshKey, indices.Length, vertices.Count); |
520 | 642 | ||
521 | meshPtr = BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr, | 643 | meshPtr = BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr, |
522 | indices.GetLength(0), indices, vertices.Count, verticesAsFloats); | 644 | indices.GetLength(0), indices, vertices.Count, verticesAsFloats); |
523 | } | 645 | } |
524 | } | 646 | } |
525 | BulletShape newShape = new BulletShape(meshPtr, ShapeData.PhysicsShapeType.SHAPE_MESH); | 647 | BulletShape newShape = new BulletShape(meshPtr, BSPhysicsShapeType.SHAPE_MESH); |
526 | newShape.shapeKey = newMeshKey; | 648 | newShape.shapeKey = newMeshKey; |
527 | 649 | ||
528 | return newShape; | 650 | return newShape; |
@@ -530,32 +652,31 @@ public class BSShapeCollection : IDisposable | |||
530 | 652 | ||
531 | // See that hull shape exists in the physical world and update prim.BSShape. | 653 | // See that hull shape exists in the physical world and update prim.BSShape. |
532 | // We could be creating the hull because scale changed or whatever. | 654 | // We could be creating the hull because scale changed or whatever. |
533 | private bool GetReferenceToHull(BSPhysObject prim, ShapeData shapeData, PrimitiveBaseShape pbs, | 655 | private bool GetReferenceToHull(BSPhysObject prim, ShapeDestructionCallback shapeCallback) |
534 | ShapeDestructionCallback shapeCallback) | ||
535 | { | 656 | { |
536 | BulletShape newShape; | 657 | BulletShape newShape; |
537 | 658 | ||
538 | float lod; | 659 | float lod; |
539 | System.UInt64 newHullKey = ComputeShapeKey(shapeData, pbs, out lod); | 660 | System.UInt64 newHullKey = ComputeShapeKey(prim.Size, prim.BaseShape, out lod); |
540 | 661 | ||
541 | // if the hull hasn't changed, don't rebuild it | 662 | // if the hull hasn't changed, don't rebuild it |
542 | if (newHullKey == prim.BSShape.shapeKey && prim.BSShape.type == ShapeData.PhysicsShapeType.SHAPE_HULL) | 663 | if (newHullKey == prim.PhysShape.shapeKey && prim.PhysShape.type == BSPhysicsShapeType.SHAPE_HULL) |
543 | return false; | 664 | return false; |
544 | 665 | ||
545 | DetailLog("{0},BSShapeCollection.CreateGeomHull,create,oldKey={1},newKey={2}", | 666 | DetailLog("{0},BSShapeCollection.GetReferenceToHull,create,oldKey={1},newKey={2}", |
546 | prim.LocalID, prim.BSShape.shapeKey.ToString("X"), newHullKey.ToString("X")); | 667 | prim.LocalID, prim.PhysShape.shapeKey.ToString("X"), newHullKey.ToString("X")); |
547 | 668 | ||
548 | // Remove usage of the previous shape. | 669 | // Remove usage of the previous shape. |
549 | DereferenceShape(prim.BSShape, true, shapeCallback); | 670 | DereferenceShape(prim.PhysShape, true, shapeCallback); |
550 | 671 | ||
551 | newShape = CreatePhysicalHull(prim.PhysObjectName, newHullKey, pbs, shapeData.Size, lod); | 672 | newShape = CreatePhysicalHull(prim.PhysObjectName, newHullKey, prim.BaseShape, prim.Size, lod); |
552 | newShape = VerifyMeshCreated(newShape, prim, shapeData, pbs); | 673 | newShape = VerifyMeshCreated(newShape, prim); |
553 | 674 | ||
554 | ReferenceShape(newShape); | 675 | ReferenceShape(newShape); |
555 | 676 | ||
556 | // hulls are already scaled by the meshmerizer | 677 | // hulls are already scaled by the meshmerizer |
557 | prim.Scale = new OMV.Vector3(1f, 1f, 1f); | 678 | prim.Scale = new OMV.Vector3(1f, 1f, 1f); |
558 | prim.BSShape = newShape; | 679 | prim.PhysShape = newShape; |
559 | return true; // 'true' means a new shape has been added to this prim | 680 | return true; // 'true' means a new shape has been added to this prim |
560 | } | 681 | } |
561 | 682 | ||
@@ -660,7 +781,7 @@ public class BSShapeCollection : IDisposable | |||
660 | } | 781 | } |
661 | } | 782 | } |
662 | 783 | ||
663 | BulletShape newShape = new BulletShape(hullPtr, ShapeData.PhysicsShapeType.SHAPE_HULL); | 784 | BulletShape newShape = new BulletShape(hullPtr, BSPhysicsShapeType.SHAPE_HULL); |
664 | newShape.shapeKey = newHullKey; | 785 | newShape.shapeKey = newHullKey; |
665 | 786 | ||
666 | return newShape; // 'true' means a new shape has been added to this prim | 787 | return newShape; // 'true' means a new shape has been added to this prim |
@@ -674,9 +795,31 @@ public class BSShapeCollection : IDisposable | |||
674 | return; | 795 | return; |
675 | } | 796 | } |
676 | 797 | ||
798 | // Compound shapes are always built from scratch. | ||
799 | // This shouldn't be to bad since most of the parts will be meshes that had been built previously. | ||
800 | private bool GetReferenceToCompoundShape(BSPhysObject prim, ShapeDestructionCallback shapeCallback) | ||
801 | { | ||
802 | // Remove reference to the old shape | ||
803 | // Don't need to do this as the shape is freed when the new root shape is created below. | ||
804 | // DereferenceShape(prim.PhysShape, true, shapeCallback); | ||
805 | |||
806 | BulletShape cShape = new BulletShape( | ||
807 | BulletSimAPI.CreateCompoundShape2(PhysicsScene.World.ptr, false), BSPhysicsShapeType.SHAPE_COMPOUND); | ||
808 | |||
809 | // Create the shape for the root prim and add it to the compound shape. Cannot be a native shape. | ||
810 | CreateGeomMeshOrHull(prim, shapeCallback); | ||
811 | BulletSimAPI.AddChildShapeToCompoundShape2(cShape.ptr, prim.PhysShape.ptr, OMV.Vector3.Zero, OMV.Quaternion.Identity); | ||
812 | DetailLog("{0},BSShapeCollection.GetReferenceToCompoundShape,addRootPrim,compShape={1},rootShape={2}", | ||
813 | prim.LocalID, cShape, prim.PhysShape); | ||
814 | |||
815 | prim.PhysShape = cShape; | ||
816 | |||
817 | return true; | ||
818 | } | ||
819 | |||
677 | // Create a hash of all the shape parameters to be used as a key | 820 | // Create a hash of all the shape parameters to be used as a key |
678 | // for this particular shape. | 821 | // for this particular shape. |
679 | private System.UInt64 ComputeShapeKey(ShapeData shapeData, PrimitiveBaseShape pbs, out float retLod) | 822 | private System.UInt64 ComputeShapeKey(OMV.Vector3 size, PrimitiveBaseShape pbs, out float retLod) |
680 | { | 823 | { |
681 | // level of detail based on size and type of the object | 824 | // level of detail based on size and type of the object |
682 | float lod = PhysicsScene.MeshLOD; | 825 | float lod = PhysicsScene.MeshLOD; |
@@ -684,33 +827,40 @@ public class BSShapeCollection : IDisposable | |||
684 | lod = PhysicsScene.SculptLOD; | 827 | lod = PhysicsScene.SculptLOD; |
685 | 828 | ||
686 | // Mega prims usually get more detail because one can interact with shape approximations at this size. | 829 | // Mega prims usually get more detail because one can interact with shape approximations at this size. |
687 | float maxAxis = Math.Max(shapeData.Size.X, Math.Max(shapeData.Size.Y, shapeData.Size.Z)); | 830 | float maxAxis = Math.Max(size.X, Math.Max(size.Y, size.Z)); |
688 | if (maxAxis > PhysicsScene.MeshMegaPrimThreshold) | 831 | if (maxAxis > PhysicsScene.MeshMegaPrimThreshold) |
689 | lod = PhysicsScene.MeshMegaPrimLOD; | 832 | lod = PhysicsScene.MeshMegaPrimLOD; |
690 | 833 | ||
691 | retLod = lod; | 834 | retLod = lod; |
692 | return pbs.GetMeshKey(shapeData.Size, lod); | 835 | return pbs.GetMeshKey(size, lod); |
693 | } | 836 | } |
694 | // For those who don't want the LOD | 837 | // For those who don't want the LOD |
695 | private System.UInt64 ComputeShapeKey(ShapeData shapeData, PrimitiveBaseShape pbs) | 838 | private System.UInt64 ComputeShapeKey(OMV.Vector3 size, PrimitiveBaseShape pbs) |
696 | { | 839 | { |
697 | float lod; | 840 | float lod; |
698 | return ComputeShapeKey(shapeData, pbs, out lod); | 841 | return ComputeShapeKey(size, pbs, out lod); |
699 | } | 842 | } |
700 | 843 | ||
701 | private BulletShape VerifyMeshCreated(BulletShape newShape, BSPhysObject prim, ShapeData shapeData, PrimitiveBaseShape pbs) | 844 | // The creation of a mesh or hull can fail if an underlying asset is not available. |
845 | // There are two cases: 1) the asset is not in the cache and it needs to be fetched; | ||
846 | // and 2) the asset cannot be converted (like failed decompression of JPEG2000s). | ||
847 | // The first case causes the asset to be fetched. The second case requires | ||
848 | // us to not loop forever. | ||
849 | // Called after creating a physical mesh or hull. If the physical shape was created, | ||
850 | // just return. | ||
851 | private BulletShape VerifyMeshCreated(BulletShape newShape, BSPhysObject prim) | ||
702 | { | 852 | { |
703 | // If the shape was successfully created, nothing more to do | 853 | // If the shape was successfully created, nothing more to do |
704 | if (newShape.ptr != IntPtr.Zero) | 854 | if (newShape.ptr != IntPtr.Zero) |
705 | return newShape; | 855 | return newShape; |
706 | 856 | ||
707 | // The most common reason for failure is that an underlying asset is not available | ||
708 | |||
709 | // If this mesh has an underlying asset and we have not failed getting it before, fetch the asset | 857 | // If this mesh has an underlying asset and we have not failed getting it before, fetch the asset |
710 | if (pbs.SculptEntry && !prim.LastAssetBuildFailed && pbs.SculptTexture != OMV.UUID.Zero) | 858 | if (prim.BaseShape.SculptEntry && !prim.LastAssetBuildFailed && prim.BaseShape.SculptTexture != OMV.UUID.Zero) |
711 | { | 859 | { |
712 | prim.LastAssetBuildFailed = true; | 860 | prim.LastAssetBuildFailed = true; |
713 | BSPhysObject xprim = prim; | 861 | BSPhysObject xprim = prim; |
862 | DetailLog("{0},BSShapeCollection.VerifyMeshCreated,fetchAsset,lID={1},lastFailed={2}", | ||
863 | LogHeader, prim.LocalID, prim.LastAssetBuildFailed); | ||
714 | Util.FireAndForget(delegate | 864 | Util.FireAndForget(delegate |
715 | { | 865 | { |
716 | RequestAssetDelegate assetProvider = PhysicsScene.RequestAssetMethod; | 866 | RequestAssetDelegate assetProvider = PhysicsScene.RequestAssetMethod; |
@@ -724,20 +874,28 @@ public class BSShapeCollection : IDisposable | |||
724 | if (yprim.BaseShape.SculptTexture.ToString() != asset.ID) | 874 | if (yprim.BaseShape.SculptTexture.ToString() != asset.ID) |
725 | return; | 875 | return; |
726 | 876 | ||
727 | yprim.BaseShape.SculptData = new byte[asset.Data.Length]; | 877 | yprim.BaseShape.SculptData = asset.Data; |
728 | asset.Data.CopyTo(yprim.BaseShape.SculptData, 0); | ||
729 | // This will cause the prim to see that the filler shape is not the right | 878 | // This will cause the prim to see that the filler shape is not the right |
730 | // one and try again to build the object. | 879 | // one and try again to build the object. |
880 | // No race condition with the normal shape setting since the rebuild is at taint time. | ||
731 | yprim.ForceBodyShapeRebuild(false); | 881 | yprim.ForceBodyShapeRebuild(false); |
732 | 882 | ||
733 | }); | 883 | }); |
734 | } | 884 | } |
735 | }); | 885 | }); |
736 | } | 886 | } |
887 | else | ||
888 | { | ||
889 | if (prim.LastAssetBuildFailed) | ||
890 | { | ||
891 | PhysicsScene.Logger.ErrorFormat("{0} Mesh failed to fetch asset. lID={1}, texture={2}", | ||
892 | LogHeader, prim.LocalID, prim.BaseShape.SculptTexture); | ||
893 | } | ||
894 | } | ||
737 | 895 | ||
738 | // While we figure out the real problem, stick a simple native shape on the object. | 896 | // While we figure out the real problem, stick a simple native shape on the object. |
739 | BulletShape fillinShape = | 897 | BulletShape fillinShape = |
740 | BuildPhysicalNativeShape(ShapeData.PhysicsShapeType.SHAPE_SPHERE, shapeData, ShapeData.FixedShapeKey.KEY_SPHERE); | 898 | BuildPhysicalNativeShape(prim, BSPhysicsShapeType.SHAPE_BOX, FixedShapeKey.KEY_BOX); |
741 | 899 | ||
742 | return fillinShape; | 900 | return fillinShape; |
743 | } | 901 | } |
@@ -746,52 +904,51 @@ public class BSShapeCollection : IDisposable | |||
746 | // Updates prim.BSBody with the information about the new body if one is created. | 904 | // Updates prim.BSBody with the information about the new body if one is created. |
747 | // Returns 'true' if an object was actually created. | 905 | // Returns 'true' if an object was actually created. |
748 | // Called at taint-time. | 906 | // Called at taint-time. |
749 | private bool CreateBody(bool forceRebuild, BSPhysObject prim, BulletSim sim, BulletShape shape, | 907 | private bool CreateBody(bool forceRebuild, BSPhysObject prim, BulletSim sim, BulletShape shape, |
750 | ShapeData shapeData, BodyDestructionCallback bodyCallback) | 908 | BodyDestructionCallback bodyCallback) |
751 | { | 909 | { |
752 | bool ret = false; | 910 | bool ret = false; |
753 | 911 | ||
754 | // the mesh, hull or native shape must have already been created in Bullet | 912 | // the mesh, hull or native shape must have already been created in Bullet |
755 | bool mustRebuild = (prim.BSBody.ptr == IntPtr.Zero); | 913 | bool mustRebuild = (prim.PhysBody.ptr == IntPtr.Zero); |
756 | 914 | ||
757 | // If there is an existing body, verify it's of an acceptable type. | 915 | // If there is an existing body, verify it's of an acceptable type. |
758 | // If not a solid object, body is a GhostObject. Otherwise a RigidBody. | 916 | // If not a solid object, body is a GhostObject. Otherwise a RigidBody. |
759 | if (!mustRebuild) | 917 | if (!mustRebuild) |
760 | { | 918 | { |
761 | CollisionObjectTypes bodyType = (CollisionObjectTypes)BulletSimAPI.GetBodyType2(prim.BSBody.ptr); | 919 | CollisionObjectTypes bodyType = (CollisionObjectTypes)BulletSimAPI.GetBodyType2(prim.PhysBody.ptr); |
762 | if (prim.IsSolid && bodyType != CollisionObjectTypes.CO_RIGID_BODY | 920 | if (prim.IsSolid && bodyType != CollisionObjectTypes.CO_RIGID_BODY |
763 | || !prim.IsSolid && bodyType != CollisionObjectTypes.CO_GHOST_OBJECT) | 921 | || !prim.IsSolid && bodyType != CollisionObjectTypes.CO_GHOST_OBJECT) |
764 | { | 922 | { |
765 | // If the collisionObject is not the correct type for solidness, rebuild what's there | 923 | // If the collisionObject is not the correct type for solidness, rebuild what's there |
766 | mustRebuild = true; | 924 | mustRebuild = true; |
767 | } | 925 | } |
768 | |||
769 | } | 926 | } |
770 | 927 | ||
771 | if (mustRebuild || forceRebuild) | 928 | if (mustRebuild || forceRebuild) |
772 | { | 929 | { |
773 | // Free any old body | 930 | // Free any old body |
774 | DereferenceBody(prim.BSBody, true, bodyCallback); | 931 | DereferenceBody(prim.PhysBody, true, bodyCallback); |
775 | 932 | ||
776 | BulletBody aBody; | 933 | BulletBody aBody; |
777 | IntPtr bodyPtr = IntPtr.Zero; | 934 | IntPtr bodyPtr = IntPtr.Zero; |
778 | if (prim.IsSolid) | 935 | if (prim.IsSolid) |
779 | { | 936 | { |
780 | bodyPtr = BulletSimAPI.CreateBodyFromShape2(sim.ptr, shape.ptr, | 937 | bodyPtr = BulletSimAPI.CreateBodyFromShape2(sim.ptr, shape.ptr, |
781 | shapeData.ID, shapeData.Position, shapeData.Rotation); | 938 | prim.LocalID, prim.RawPosition, prim.RawOrientation); |
782 | DetailLog("{0},BSShapeCollection.CreateBody,mesh,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); | 939 | DetailLog("{0},BSShapeCollection.CreateBody,mesh,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); |
783 | } | 940 | } |
784 | else | 941 | else |
785 | { | 942 | { |
786 | bodyPtr = BulletSimAPI.CreateGhostFromShape2(sim.ptr, shape.ptr, | 943 | bodyPtr = BulletSimAPI.CreateGhostFromShape2(sim.ptr, shape.ptr, |
787 | shapeData.ID, shapeData.Position, shapeData.Rotation); | 944 | prim.LocalID, prim.RawPosition, prim.RawOrientation); |
788 | DetailLog("{0},BSShapeCollection.CreateBody,ghost,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); | 945 | DetailLog("{0},BSShapeCollection.CreateBody,ghost,ptr={1}", prim.LocalID, bodyPtr.ToString("X")); |
789 | } | 946 | } |
790 | aBody = new BulletBody(shapeData.ID, bodyPtr); | 947 | aBody = new BulletBody(prim.LocalID, bodyPtr); |
791 | 948 | ||
792 | ReferenceBody(aBody, true); | 949 | ReferenceBody(aBody, true); |
793 | 950 | ||
794 | prim.BSBody = aBody; | 951 | prim.PhysBody = aBody; |
795 | 952 | ||
796 | ret = true; | 953 | ret = true; |
797 | } | 954 | } |
@@ -799,6 +956,42 @@ public class BSShapeCollection : IDisposable | |||
799 | return ret; | 956 | return ret; |
800 | } | 957 | } |
801 | 958 | ||
959 | private bool TryGetMeshByPtr(IntPtr addr, out MeshDesc outDesc) | ||
960 | { | ||
961 | bool ret = false; | ||
962 | MeshDesc foundDesc = new MeshDesc(); | ||
963 | foreach (MeshDesc md in Meshes.Values) | ||
964 | { | ||
965 | if (md.ptr == addr) | ||
966 | { | ||
967 | foundDesc = md; | ||
968 | ret = true; | ||
969 | break; | ||
970 | } | ||
971 | |||
972 | } | ||
973 | outDesc = foundDesc; | ||
974 | return ret; | ||
975 | } | ||
976 | |||
977 | private bool TryGetHullByPtr(IntPtr addr, out HullDesc outDesc) | ||
978 | { | ||
979 | bool ret = false; | ||
980 | HullDesc foundDesc = new HullDesc(); | ||
981 | foreach (HullDesc hd in Hulls.Values) | ||
982 | { | ||
983 | if (hd.ptr == addr) | ||
984 | { | ||
985 | foundDesc = hd; | ||
986 | ret = true; | ||
987 | break; | ||
988 | } | ||
989 | |||
990 | } | ||
991 | outDesc = foundDesc; | ||
992 | return ret; | ||
993 | } | ||
994 | |||
802 | private void DetailLog(string msg, params Object[] args) | 995 | private void DetailLog(string msg, params Object[] args) |
803 | { | 996 | { |
804 | if (PhysicsScene.PhysicsLogging.Enabled) | 997 | if (PhysicsScene.PhysicsLogging.Enabled) |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs new file mode 100755 index 0000000..96cd55e --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs | |||
@@ -0,0 +1,208 @@ | |||
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 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Linq; | ||
31 | using System.Text; | ||
32 | |||
33 | namespace OpenSim.Region.Physics.BulletSPlugin | ||
34 | { | ||
35 | public abstract class BSShape | ||
36 | { | ||
37 | public IntPtr ptr { get; set; } | ||
38 | public BSPhysicsShapeType type { get; set; } | ||
39 | public System.UInt64 key { get; set; } | ||
40 | public int referenceCount { get; set; } | ||
41 | public DateTime lastReferenced { get; set; } | ||
42 | |||
43 | public BSShape() | ||
44 | { | ||
45 | ptr = IntPtr.Zero; | ||
46 | type = BSPhysicsShapeType.SHAPE_UNKNOWN; | ||
47 | key = 0; | ||
48 | referenceCount = 0; | ||
49 | lastReferenced = DateTime.Now; | ||
50 | } | ||
51 | |||
52 | // Get a reference to a physical shape. Create if it doesn't exist | ||
53 | public static BSShape GetShapeReference(BSScene physicsScene, bool forceRebuild, BSPhysObject prim) | ||
54 | { | ||
55 | BSShape ret = null; | ||
56 | |||
57 | if (prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_CAPSULE) | ||
58 | { | ||
59 | // an avatar capsule is close to a native shape (it is not shared) | ||
60 | ret = BSShapeNative.GetReference(physicsScene, prim, BSPhysicsShapeType.SHAPE_CAPSULE, | ||
61 | FixedShapeKey.KEY_CAPSULE); | ||
62 | physicsScene.DetailLog("{0},BSShape.GetShapeReference,avatarCapsule,shape={1}", prim.LocalID, ret); | ||
63 | } | ||
64 | |||
65 | // Compound shapes are handled special as they are rebuilt from scratch. | ||
66 | // This isn't too great a hardship since most of the child shapes will already been created. | ||
67 | if (ret == null && prim.PreferredPhysicalShape == BSPhysicsShapeType.SHAPE_COMPOUND) | ||
68 | { | ||
69 | // Getting a reference to a compound shape gets you the compound shape with the root prim shape added | ||
70 | ret = BSShapeCompound.GetReference(prim); | ||
71 | physicsScene.DetailLog("{0},BSShapeCollection.CreateGeom,compoundShape,shape={1}", prim.LocalID, ret); | ||
72 | } | ||
73 | |||
74 | if (ret == null) | ||
75 | ret = GetShapeReferenceNonSpecial(physicsScene, forceRebuild, prim); | ||
76 | |||
77 | return ret; | ||
78 | } | ||
79 | public static BSShape GetShapeReferenceNonSpecial(BSScene physicsScene, bool forceRebuild, BSPhysObject prim) | ||
80 | { | ||
81 | return null; | ||
82 | } | ||
83 | public static BSShape GetShapeReferenceNonNative(BSScene physicsScene, bool forceRebuild, BSPhysObject prim) | ||
84 | { | ||
85 | return null; | ||
86 | } | ||
87 | |||
88 | // Release the use of a physical shape. | ||
89 | public abstract void Dereference(BSScene physicsScene); | ||
90 | |||
91 | // All shapes have a static call to get a reference to the physical shape | ||
92 | // protected abstract static BSShape GetReference(); | ||
93 | |||
94 | public override string ToString() | ||
95 | { | ||
96 | StringBuilder buff = new StringBuilder(); | ||
97 | buff.Append("<p="); | ||
98 | buff.Append(ptr.ToString("X")); | ||
99 | buff.Append(",s="); | ||
100 | buff.Append(type.ToString()); | ||
101 | buff.Append(",k="); | ||
102 | buff.Append(key.ToString("X")); | ||
103 | buff.Append(",c="); | ||
104 | buff.Append(referenceCount.ToString()); | ||
105 | buff.Append(">"); | ||
106 | return buff.ToString(); | ||
107 | } | ||
108 | } | ||
109 | |||
110 | public class BSShapeNull : BSShape | ||
111 | { | ||
112 | public BSShapeNull() : base() | ||
113 | { | ||
114 | } | ||
115 | public static BSShape GetReference() { return new BSShapeNull(); } | ||
116 | public override void Dereference(BSScene physicsScene) { /* The magic of garbage collection will make this go away */ } | ||
117 | } | ||
118 | |||
119 | public class BSShapeNative : BSShape | ||
120 | { | ||
121 | private static string LogHeader = "[BULLETSIM SHAPE NATIVE]"; | ||
122 | public BSShapeNative() : base() | ||
123 | { | ||
124 | } | ||
125 | public static BSShape GetReference(BSScene physicsScene, BSPhysObject prim, | ||
126 | BSPhysicsShapeType shapeType, FixedShapeKey shapeKey) | ||
127 | { | ||
128 | // Native shapes are not shared and are always built anew. | ||
129 | return new BSShapeNative(physicsScene, prim, shapeType, shapeKey); | ||
130 | } | ||
131 | |||
132 | private BSShapeNative(BSScene physicsScene, BSPhysObject prim, | ||
133 | BSPhysicsShapeType shapeType, FixedShapeKey shapeKey) | ||
134 | { | ||
135 | ShapeData nativeShapeData = new ShapeData(); | ||
136 | nativeShapeData.Type = shapeType; | ||
137 | nativeShapeData.ID = prim.LocalID; | ||
138 | nativeShapeData.Scale = prim.Scale; | ||
139 | nativeShapeData.Size = prim.Scale; | ||
140 | nativeShapeData.MeshKey = (ulong)shapeKey; | ||
141 | nativeShapeData.HullKey = (ulong)shapeKey; | ||
142 | |||
143 | |||
144 | if (shapeType == BSPhysicsShapeType.SHAPE_CAPSULE) | ||
145 | { | ||
146 | ptr = BulletSimAPI.BuildCapsuleShape2(physicsScene.World.ptr, 1f, 1f, prim.Scale); | ||
147 | physicsScene.DetailLog("{0},BSShapeCollection.BuiletPhysicalNativeShape,capsule,scale={1}", prim.LocalID, prim.Scale); | ||
148 | } | ||
149 | else | ||
150 | { | ||
151 | ptr = BulletSimAPI.BuildNativeShape2(physicsScene.World.ptr, nativeShapeData); | ||
152 | } | ||
153 | if (ptr == IntPtr.Zero) | ||
154 | { | ||
155 | physicsScene.Logger.ErrorFormat("{0} BuildPhysicalNativeShape failed. ID={1}, shape={2}", | ||
156 | LogHeader, prim.LocalID, shapeType); | ||
157 | } | ||
158 | type = shapeType; | ||
159 | key = (UInt64)shapeKey; | ||
160 | } | ||
161 | // Make this reference to the physical shape go away since native shapes are not shared. | ||
162 | public override void Dereference(BSScene physicsScene) | ||
163 | { | ||
164 | // Native shapes are not tracked and are released immediately | ||
165 | physicsScene.DetailLog("{0},BSShapeCollection.DereferenceShape,deleteNativeShape,shape={1}", BSScene.DetailLogZero, this); | ||
166 | BulletSimAPI.DeleteCollisionShape2(physicsScene.World.ptr, ptr); | ||
167 | ptr = IntPtr.Zero; | ||
168 | // Garbage collection will free up this instance. | ||
169 | } | ||
170 | } | ||
171 | |||
172 | public class BSShapeMesh : BSShape | ||
173 | { | ||
174 | private static string LogHeader = "[BULLETSIM SHAPE MESH]"; | ||
175 | private static Dictionary<System.UInt64, BSShapeMesh> Meshes = new Dictionary<System.UInt64, BSShapeMesh>(); | ||
176 | |||
177 | public BSShapeMesh() : base() | ||
178 | { | ||
179 | } | ||
180 | public static BSShape GetReference() { return new BSShapeNull(); } | ||
181 | public override void Dereference(BSScene physicsScene) { } | ||
182 | } | ||
183 | |||
184 | public class BSShapeHull : BSShape | ||
185 | { | ||
186 | private static string LogHeader = "[BULLETSIM SHAPE HULL]"; | ||
187 | private static Dictionary<System.UInt64, BSShapeHull> Hulls = new Dictionary<System.UInt64, BSShapeHull>(); | ||
188 | |||
189 | public BSShapeHull() : base() | ||
190 | { | ||
191 | } | ||
192 | public static BSShape GetReference() { return new BSShapeNull(); } | ||
193 | public override void Dereference(BSScene physicsScene) { } | ||
194 | } | ||
195 | |||
196 | public class BSShapeCompound : BSShape | ||
197 | { | ||
198 | private static string LogHeader = "[BULLETSIM SHAPE COMPOUND]"; | ||
199 | public BSShapeCompound() : base() | ||
200 | { | ||
201 | } | ||
202 | public static BSShape GetReference(BSPhysObject prim) | ||
203 | { | ||
204 | return new BSShapeNull(); | ||
205 | } | ||
206 | public override void Dereference(BSScene physicsScene) { } | ||
207 | } | ||
208 | } | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs new file mode 100755 index 0000000..3ca756c --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainHeightmap.cs | |||
@@ -0,0 +1,170 @@ | |||
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 OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework; | ||
33 | using OpenSim.Region.CoreModules; | ||
34 | using OpenSim.Region.Physics.Manager; | ||
35 | |||
36 | using Nini.Config; | ||
37 | using log4net; | ||
38 | |||
39 | using OpenMetaverse; | ||
40 | |||
41 | namespace OpenSim.Region.Physics.BulletSPlugin | ||
42 | { | ||
43 | public sealed class BSTerrainHeightmap : BSTerrainPhys | ||
44 | { | ||
45 | static string LogHeader = "[BULLETSIM TERRAIN HEIGHTMAP]"; | ||
46 | |||
47 | BulletHeightMapInfo m_mapInfo = null; | ||
48 | |||
49 | // Constructor to build a default, flat heightmap terrain. | ||
50 | public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, Vector3 regionSize) | ||
51 | : base(physicsScene, regionBase, id) | ||
52 | { | ||
53 | Vector3 minTerrainCoords = new Vector3(0f, 0f, BSTerrainManager.HEIGHT_INITIALIZATION - BSTerrainManager.HEIGHT_EQUAL_FUDGE); | ||
54 | Vector3 maxTerrainCoords = new Vector3(regionSize.X, regionSize.Y, BSTerrainManager.HEIGHT_INITIALIZATION); | ||
55 | int totalHeights = (int)maxTerrainCoords.X * (int)maxTerrainCoords.Y; | ||
56 | float[] initialMap = new float[totalHeights]; | ||
57 | for (int ii = 0; ii < totalHeights; ii++) | ||
58 | { | ||
59 | initialMap[ii] = BSTerrainManager.HEIGHT_INITIALIZATION; | ||
60 | } | ||
61 | m_mapInfo = new BulletHeightMapInfo(id, initialMap, IntPtr.Zero); | ||
62 | m_mapInfo.minCoords = minTerrainCoords; | ||
63 | m_mapInfo.maxCoords = maxTerrainCoords; | ||
64 | m_mapInfo.terrainRegionBase = TerrainBase; | ||
65 | // Don't have to free any previous since we just got here. | ||
66 | BuildHeightmapTerrain(); | ||
67 | } | ||
68 | |||
69 | // This minCoords and maxCoords passed in give the size of the terrain (min and max Z | ||
70 | // are the high and low points of the heightmap). | ||
71 | public BSTerrainHeightmap(BSScene physicsScene, Vector3 regionBase, uint id, float[] initialMap, | ||
72 | Vector3 minCoords, Vector3 maxCoords) | ||
73 | : base(physicsScene, regionBase, id) | ||
74 | { | ||
75 | m_mapInfo = new BulletHeightMapInfo(id, initialMap, IntPtr.Zero); | ||
76 | m_mapInfo.minCoords = minCoords; | ||
77 | m_mapInfo.maxCoords = maxCoords; | ||
78 | m_mapInfo.minZ = minCoords.Z; | ||
79 | m_mapInfo.maxZ = maxCoords.Z; | ||
80 | m_mapInfo.terrainRegionBase = TerrainBase; | ||
81 | |||
82 | // Don't have to free any previous since we just got here. | ||
83 | BuildHeightmapTerrain(); | ||
84 | } | ||
85 | |||
86 | public override void Dispose() | ||
87 | { | ||
88 | ReleaseHeightMapTerrain(); | ||
89 | } | ||
90 | |||
91 | // Using the information in m_mapInfo, create the physical representation of the heightmap. | ||
92 | private void BuildHeightmapTerrain() | ||
93 | { | ||
94 | m_mapInfo.Ptr = BulletSimAPI.CreateHeightMapInfo2(PhysicsScene.World.ptr, m_mapInfo.ID, | ||
95 | m_mapInfo.minCoords, m_mapInfo.maxCoords, | ||
96 | m_mapInfo.heightMap, BSTerrainManager.TERRAIN_COLLISION_MARGIN); | ||
97 | |||
98 | // Create the terrain shape from the mapInfo | ||
99 | m_mapInfo.terrainShape = new BulletShape(BulletSimAPI.CreateTerrainShape2(m_mapInfo.Ptr), | ||
100 | BSPhysicsShapeType.SHAPE_TERRAIN); | ||
101 | |||
102 | // The terrain object initial position is at the center of the object | ||
103 | Vector3 centerPos; | ||
104 | centerPos.X = m_mapInfo.minCoords.X + (m_mapInfo.sizeX / 2f); | ||
105 | centerPos.Y = m_mapInfo.minCoords.Y + (m_mapInfo.sizeY / 2f); | ||
106 | centerPos.Z = m_mapInfo.minZ + ((m_mapInfo.maxZ - m_mapInfo.minZ) / 2f); | ||
107 | |||
108 | m_mapInfo.terrainBody = new BulletBody(m_mapInfo.ID, | ||
109 | BulletSimAPI.CreateBodyWithDefaultMotionState2(m_mapInfo.terrainShape.ptr, | ||
110 | m_mapInfo.ID, centerPos, Quaternion.Identity)); | ||
111 | |||
112 | // Set current terrain attributes | ||
113 | BulletSimAPI.SetFriction2(m_mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainFriction); | ||
114 | BulletSimAPI.SetHitFraction2(m_mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainHitFraction); | ||
115 | BulletSimAPI.SetRestitution2(m_mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainRestitution); | ||
116 | BulletSimAPI.SetCollisionFlags2(m_mapInfo.terrainBody.ptr, CollisionFlags.CF_STATIC_OBJECT); | ||
117 | |||
118 | // Return the new terrain to the world of physical objects | ||
119 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr); | ||
120 | |||
121 | // redo its bounding box now that it is in the world | ||
122 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr); | ||
123 | |||
124 | BulletSimAPI.SetCollisionFilterMask2(m_mapInfo.terrainBody.ptr, | ||
125 | (uint)CollisionFilterGroups.TerrainFilter, | ||
126 | (uint)CollisionFilterGroups.TerrainMask); | ||
127 | |||
128 | // Make it so the terrain will not move or be considered for movement. | ||
129 | BulletSimAPI.ForceActivationState2(m_mapInfo.terrainBody.ptr, ActivationState.DISABLE_SIMULATION); | ||
130 | |||
131 | return; | ||
132 | } | ||
133 | |||
134 | // If there is information in m_mapInfo pointing to physical structures, release same. | ||
135 | private void ReleaseHeightMapTerrain() | ||
136 | { | ||
137 | if (m_mapInfo != null) | ||
138 | { | ||
139 | if (m_mapInfo.terrainBody.ptr != IntPtr.Zero) | ||
140 | { | ||
141 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr); | ||
142 | // Frees both the body and the shape. | ||
143 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_mapInfo.terrainBody.ptr); | ||
144 | BulletSimAPI.ReleaseHeightMapInfo2(m_mapInfo.Ptr); | ||
145 | } | ||
146 | } | ||
147 | m_mapInfo = null; | ||
148 | } | ||
149 | |||
150 | // The passed position is relative to the base of the region. | ||
151 | public override float GetHeightAtXYZ(Vector3 pos) | ||
152 | { | ||
153 | float ret = BSTerrainManager.HEIGHT_GETHEIGHT_RET; | ||
154 | |||
155 | int mapIndex = (int)pos.Y * (int)m_mapInfo.sizeY + (int)pos.X; | ||
156 | try | ||
157 | { | ||
158 | ret = m_mapInfo.heightMap[mapIndex]; | ||
159 | } | ||
160 | catch | ||
161 | { | ||
162 | // Sometimes they give us wonky values of X and Y. Give a warning and return something. | ||
163 | PhysicsScene.Logger.WarnFormat("{0} Bad request for terrain height. terrainBase={1}, pos={2}", | ||
164 | LogHeader, m_mapInfo.terrainRegionBase, pos); | ||
165 | ret = BSTerrainManager.HEIGHT_GETHEIGHT_RET; | ||
166 | } | ||
167 | return ret; | ||
168 | } | ||
169 | } | ||
170 | } | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs index 4106534..23fcfd3 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainManager.cs | |||
@@ -40,7 +40,33 @@ using OpenMetaverse; | |||
40 | 40 | ||
41 | namespace OpenSim.Region.Physics.BulletSPlugin | 41 | namespace OpenSim.Region.Physics.BulletSPlugin |
42 | { | 42 | { |
43 | public class BSTerrainManager | 43 | |
44 | // The physical implementation of the terrain is wrapped in this class. | ||
45 | public abstract class BSTerrainPhys : IDisposable | ||
46 | { | ||
47 | public enum TerrainImplementation | ||
48 | { | ||
49 | Heightmap = 0, | ||
50 | Mesh = 1 | ||
51 | } | ||
52 | |||
53 | public BSScene PhysicsScene { get; private set; } | ||
54 | // Base of the region in world coordinates. Coordinates inside the region are relative to this. | ||
55 | public Vector3 TerrainBase { get; private set; } | ||
56 | public uint ID { get; private set; } | ||
57 | |||
58 | public BSTerrainPhys(BSScene physicsScene, Vector3 regionBase, uint id) | ||
59 | { | ||
60 | PhysicsScene = physicsScene; | ||
61 | TerrainBase = regionBase; | ||
62 | ID = id; | ||
63 | } | ||
64 | public abstract void Dispose(); | ||
65 | public abstract float GetHeightAtXYZ(Vector3 pos); | ||
66 | } | ||
67 | |||
68 | // ========================================================================================== | ||
69 | public sealed class BSTerrainManager | ||
44 | { | 70 | { |
45 | static string LogHeader = "[BULLETSIM TERRAIN MANAGER]"; | 71 | static string LogHeader = "[BULLETSIM TERRAIN MANAGER]"; |
46 | 72 | ||
@@ -67,11 +93,10 @@ public class BSTerrainManager | |||
67 | 93 | ||
68 | // If doing mega-regions, if we're region zero we will be managing multiple | 94 | // If doing mega-regions, if we're region zero we will be managing multiple |
69 | // region terrains since region zero does the physics for the whole mega-region. | 95 | // region terrains since region zero does the physics for the whole mega-region. |
70 | private Dictionary<Vector2, BulletHeightMapInfo> m_heightMaps; | 96 | private Dictionary<Vector3, BSTerrainPhys> m_terrains; |
71 | 97 | ||
72 | // True of the terrain has been modified. | 98 | // Flags used to know when to recalculate the height. |
73 | // Used to force recalculation of terrain height after terrain has been modified | 99 | private bool m_terrainModified = false; |
74 | private bool m_terrainModified; | ||
75 | 100 | ||
76 | // If we are doing mega-regions, terrains are added from TERRAIN_ID to m_terrainCount. | 101 | // If we are doing mega-regions, terrains are added from TERRAIN_ID to m_terrainCount. |
77 | // This is incremented before assigning to new region so it is the last ID allocated. | 102 | // This is incremented before assigning to new region so it is the last ID allocated. |
@@ -89,8 +114,7 @@ public class BSTerrainManager | |||
89 | public BSTerrainManager(BSScene physicsScene) | 114 | public BSTerrainManager(BSScene physicsScene) |
90 | { | 115 | { |
91 | PhysicsScene = physicsScene; | 116 | PhysicsScene = physicsScene; |
92 | m_heightMaps = new Dictionary<Vector2,BulletHeightMapInfo>(); | 117 | m_terrains = new Dictionary<Vector3,BSTerrainPhys>(); |
93 | m_terrainModified = false; | ||
94 | 118 | ||
95 | // Assume one region of default size | 119 | // Assume one region of default size |
96 | m_worldOffset = Vector3.Zero; | 120 | m_worldOffset = Vector3.Zero; |
@@ -99,9 +123,6 @@ public class BSTerrainManager | |||
99 | } | 123 | } |
100 | 124 | ||
101 | // Create the initial instance of terrain and the underlying ground plane. | 125 | // Create the initial instance of terrain and the underlying ground plane. |
102 | // The objects are allocated in the unmanaged space and the pointers are tracked | ||
103 | // by the managed code. | ||
104 | // The terrains and the groundPlane are not added to the list of PhysObjects. | ||
105 | // This is called from the initialization routine so we presume it is | 126 | // This is called from the initialization routine so we presume it is |
106 | // safe to call Bullet in real time. We hope no one is moving prims around yet. | 127 | // safe to call Bullet in real time. We hope no one is moving prims around yet. |
107 | public void CreateInitialGroundPlaneAndTerrain() | 128 | public void CreateInitialGroundPlaneAndTerrain() |
@@ -109,7 +130,7 @@ public class BSTerrainManager | |||
109 | // The ground plane is here to catch things that are trying to drop to negative infinity | 130 | // The ground plane is here to catch things that are trying to drop to negative infinity |
110 | BulletShape groundPlaneShape = new BulletShape( | 131 | BulletShape groundPlaneShape = new BulletShape( |
111 | BulletSimAPI.CreateGroundPlaneShape2(BSScene.GROUNDPLANE_ID, 1f, TERRAIN_COLLISION_MARGIN), | 132 | BulletSimAPI.CreateGroundPlaneShape2(BSScene.GROUNDPLANE_ID, 1f, TERRAIN_COLLISION_MARGIN), |
112 | ShapeData.PhysicsShapeType.SHAPE_GROUNDPLANE); | 133 | BSPhysicsShapeType.SHAPE_GROUNDPLANE); |
113 | m_groundPlane = new BulletBody(BSScene.GROUNDPLANE_ID, | 134 | m_groundPlane = new BulletBody(BSScene.GROUNDPLANE_ID, |
114 | BulletSimAPI.CreateBodyWithDefaultMotionState2(groundPlaneShape.ptr, BSScene.GROUNDPLANE_ID, | 135 | BulletSimAPI.CreateBodyWithDefaultMotionState2(groundPlaneShape.ptr, BSScene.GROUNDPLANE_ID, |
115 | Vector3.Zero, Quaternion.Identity)); | 136 | Vector3.Zero, Quaternion.Identity)); |
@@ -121,15 +142,9 @@ public class BSTerrainManager | |||
121 | BulletSimAPI.SetCollisionFilterMask2(m_groundPlane.ptr, | 142 | BulletSimAPI.SetCollisionFilterMask2(m_groundPlane.ptr, |
122 | (uint)CollisionFilterGroups.GroundPlaneFilter, (uint)CollisionFilterGroups.GroundPlaneMask); | 143 | (uint)CollisionFilterGroups.GroundPlaneFilter, (uint)CollisionFilterGroups.GroundPlaneMask); |
123 | 144 | ||
124 | Vector3 minTerrainCoords = new Vector3(0f, 0f, HEIGHT_INITIALIZATION - HEIGHT_EQUAL_FUDGE); | 145 | // Build an initial terrain and put it in the world. This quickly gets replaced by the real region terrain. |
125 | Vector3 maxTerrainCoords = new Vector3(DefaultRegionSize.X, DefaultRegionSize.Y, HEIGHT_INITIALIZATION); | 146 | BSTerrainPhys initialTerrain = new BSTerrainHeightmap(PhysicsScene, Vector3.Zero, BSScene.TERRAIN_ID, DefaultRegionSize); |
126 | int totalHeights = (int)maxTerrainCoords.X * (int)maxTerrainCoords.Y; | 147 | m_terrains.Add(Vector3.Zero, initialTerrain); |
127 | float[] initialMap = new float[totalHeights]; | ||
128 | for (int ii = 0; ii < totalHeights; ii++) | ||
129 | { | ||
130 | initialMap[ii] = HEIGHT_INITIALIZATION; | ||
131 | } | ||
132 | UpdateOrCreateTerrain(BSScene.TERRAIN_ID, initialMap, minTerrainCoords, maxTerrainCoords, true); | ||
133 | } | 148 | } |
134 | 149 | ||
135 | // Release all the terrain structures we might have allocated | 150 | // Release all the terrain structures we might have allocated |
@@ -150,15 +165,11 @@ public class BSTerrainManager | |||
150 | // Release all the terrain we have allocated | 165 | // Release all the terrain we have allocated |
151 | public void ReleaseTerrain() | 166 | public void ReleaseTerrain() |
152 | { | 167 | { |
153 | foreach (KeyValuePair<Vector2, BulletHeightMapInfo> kvp in m_heightMaps) | 168 | foreach (KeyValuePair<Vector3, BSTerrainPhys> kvp in m_terrains) |
154 | { | 169 | { |
155 | if (BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, kvp.Value.terrainBody.ptr)) | 170 | kvp.Value.Dispose(); |
156 | { | ||
157 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, kvp.Value.terrainBody.ptr); | ||
158 | BulletSimAPI.ReleaseHeightMapInfo2(kvp.Value.Ptr); | ||
159 | } | ||
160 | } | 171 | } |
161 | m_heightMaps.Clear(); | 172 | m_terrains.Clear(); |
162 | } | 173 | } |
163 | 174 | ||
164 | // The simulator wants to set a new heightmap for the terrain. | 175 | // The simulator wants to set a new heightmap for the terrain. |
@@ -176,8 +187,9 @@ public class BSTerrainManager | |||
176 | { | 187 | { |
177 | DetailLog("{0},SetTerrain.ToParent,offset={1},worldMax={2}", | 188 | DetailLog("{0},SetTerrain.ToParent,offset={1},worldMax={2}", |
178 | BSScene.DetailLogZero, m_worldOffset, m_worldMax); | 189 | BSScene.DetailLogZero, m_worldOffset, m_worldMax); |
179 | ((BSScene)MegaRegionParentPhysicsScene).TerrainManager.UpdateOrCreateTerrain(BSScene.CHILDTERRAIN_ID, | 190 | ((BSScene)MegaRegionParentPhysicsScene).TerrainManager.UpdateTerrain( |
180 | localHeightMap, m_worldOffset, m_worldOffset + DefaultRegionSize, true); | 191 | BSScene.CHILDTERRAIN_ID, localHeightMap, |
192 | m_worldOffset, m_worldOffset + DefaultRegionSize, true); | ||
181 | } | 193 | } |
182 | } | 194 | } |
183 | else | 195 | else |
@@ -185,7 +197,7 @@ public class BSTerrainManager | |||
185 | // If not doing the mega-prim thing, just change the terrain | 197 | // If not doing the mega-prim thing, just change the terrain |
186 | DetailLog("{0},SetTerrain.Existing", BSScene.DetailLogZero); | 198 | DetailLog("{0},SetTerrain.Existing", BSScene.DetailLogZero); |
187 | 199 | ||
188 | UpdateOrCreateTerrain(BSScene.TERRAIN_ID, localHeightMap, | 200 | UpdateTerrain(BSScene.TERRAIN_ID, localHeightMap, |
189 | m_worldOffset, m_worldOffset + DefaultRegionSize, true); | 201 | m_worldOffset, m_worldOffset + DefaultRegionSize, true); |
190 | } | 202 | } |
191 | }); | 203 | }); |
@@ -195,58 +207,63 @@ public class BSTerrainManager | |||
195 | // based on the passed information. The 'id' should be either the terrain id or | 207 | // based on the passed information. The 'id' should be either the terrain id or |
196 | // BSScene.CHILDTERRAIN_ID. If the latter, a new child terrain ID will be allocated and used. | 208 | // BSScene.CHILDTERRAIN_ID. If the latter, a new child terrain ID will be allocated and used. |
197 | // The latter feature is for creating child terrains for mega-regions. | 209 | // The latter feature is for creating child terrains for mega-regions. |
198 | // If called with a mapInfo in m_heightMaps but the terrain has no body yet (mapInfo.terrainBody.Ptr == 0) | ||
199 | // then a new body and shape is created and the mapInfo is filled. | ||
200 | // This call is used for doing the initial terrain creation. | ||
201 | // If called with a mapInfo in m_heightMaps and there is an existing terrain body, a new | 210 | // If called with a mapInfo in m_heightMaps and there is an existing terrain body, a new |
202 | // terrain shape is created and added to the body. | 211 | // terrain shape is created and added to the body. |
203 | // This call is most often used to update the heightMap and parameters of the terrain. | 212 | // This call is most often used to update the heightMap and parameters of the terrain. |
204 | // The 'doNow' boolean says whether to do all the unmanaged activities right now (like when | 213 | // (The above does suggest that some simplification/refactoring is in order.) |
205 | // calling this routine from initialization or taint-time routines) or whether to delay | 214 | private void UpdateTerrain(uint id, float[] heightMap, |
206 | // all the unmanaged activities to taint-time. | 215 | Vector3 minCoords, Vector3 maxCoords, bool inTaintTime) |
207 | private void UpdateOrCreateTerrain(uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords, bool inTaintTime) | ||
208 | { | 216 | { |
209 | DetailLog("{0},BSTerrainManager.UpdateOrCreateTerrain,call,minC={1},maxC={2},inTaintTime={3}", | 217 | DetailLog("{0},BSTerrainManager.UpdateTerrain,call,minC={1},maxC={2},inTaintTime={3}", |
210 | BSScene.DetailLogZero, minCoords, maxCoords, inTaintTime); | 218 | BSScene.DetailLogZero, minCoords, maxCoords, inTaintTime); |
211 | 219 | ||
220 | // Find high and low points of passed heightmap. | ||
221 | // The min and max passed in is usually the area objects can be in (maximum | ||
222 | // object height, for instance). The terrain wants the bounding box for the | ||
223 | // terrain so we replace passed min and max Z with the actual terrain min/max Z. | ||
212 | float minZ = float.MaxValue; | 224 | float minZ = float.MaxValue; |
213 | float maxZ = float.MinValue; | 225 | float maxZ = float.MinValue; |
214 | Vector2 terrainRegionBase = new Vector2(minCoords.X, minCoords.Y); | 226 | foreach (float height in heightMap) |
215 | |||
216 | int heightMapSize = heightMap.Length; | ||
217 | for (int ii = 0; ii < heightMapSize; ii++) | ||
218 | { | 227 | { |
219 | float height = heightMap[ii]; | ||
220 | if (height < minZ) minZ = height; | 228 | if (height < minZ) minZ = height; |
221 | if (height > maxZ) maxZ = height; | 229 | if (height > maxZ) maxZ = height; |
222 | } | 230 | } |
223 | 231 | if (minZ == maxZ) | |
224 | // The shape of the terrain is from its base to its extents. | 232 | { |
233 | // If min and max are the same, reduce min a little bit so a good bounding box is created. | ||
234 | minZ -= BSTerrainManager.HEIGHT_EQUAL_FUDGE; | ||
235 | } | ||
225 | minCoords.Z = minZ; | 236 | minCoords.Z = minZ; |
226 | maxCoords.Z = maxZ; | 237 | maxCoords.Z = maxZ; |
227 | 238 | ||
228 | BulletHeightMapInfo mapInfo; | 239 | Vector3 terrainRegionBase = new Vector3(minCoords.X, minCoords.Y, 0f); |
229 | if (m_heightMaps.TryGetValue(terrainRegionBase, out mapInfo)) | 240 | |
241 | BSTerrainPhys terrainPhys; | ||
242 | if (m_terrains.TryGetValue(terrainRegionBase, out terrainPhys)) | ||
230 | { | 243 | { |
231 | // If this is terrain we know about, it's easy to update | 244 | // There is already a terrain in this spot. Free the old and build the new. |
232 | 245 | DetailLog("{0},UpdateTerrain:UpdateExisting,call,id={1},base={2},minC={3},maxC={4}", | |
233 | mapInfo.heightMap = heightMap; | 246 | BSScene.DetailLogZero, id, terrainRegionBase, minCoords, minCoords); |
234 | mapInfo.minCoords = minCoords; | 247 | |
235 | mapInfo.maxCoords = maxCoords; | 248 | PhysicsScene.TaintedObject(inTaintTime, "BSScene.UpdateTerrain:UpdateExisting", delegate() |
236 | mapInfo.minZ = minZ; | ||
237 | mapInfo.maxZ = maxZ; | ||
238 | mapInfo.sizeX = maxCoords.X - minCoords.X; | ||
239 | mapInfo.sizeY = maxCoords.Y - minCoords.Y; | ||
240 | DetailLog("{0},UpdateOrCreateTerrain:UpdateExisting,call,terrainBase={1},minC={2}, maxC={3}, szX={4}, szY={5}", | ||
241 | BSScene.DetailLogZero, terrainRegionBase, mapInfo.minCoords, mapInfo.maxCoords, mapInfo.sizeX, mapInfo.sizeY); | ||
242 | |||
243 | BSScene.TaintCallback rebuildOperation = delegate() | ||
244 | { | 249 | { |
245 | if (MegaRegionParentPhysicsScene != null) | 250 | // Remove old terrain from the collection |
251 | m_terrains.Remove(terrainRegionBase); | ||
252 | // Release any physical memory it may be using. | ||
253 | terrainPhys.Dispose(); | ||
254 | |||
255 | if (MegaRegionParentPhysicsScene == null) | ||
256 | { | ||
257 | BSTerrainPhys newTerrainPhys = BuildPhysicalTerrain(terrainRegionBase, id, heightMap, minCoords, maxCoords); | ||
258 | m_terrains.Add(terrainRegionBase, newTerrainPhys); | ||
259 | |||
260 | m_terrainModified = true; | ||
261 | } | ||
262 | else | ||
246 | { | 263 | { |
247 | // It's possible that Combine() was called after this code was queued. | 264 | // It's possible that Combine() was called after this code was queued. |
248 | // If we are a child of combined regions, we don't create any terrain for us. | 265 | // If we are a child of combined regions, we don't create any terrain for us. |
249 | DetailLog("{0},UpdateOrCreateTerrain:AmACombineChild,taint", BSScene.DetailLogZero); | 266 | DetailLog("{0},BSTerrainManager.UpdateTerrain:AmACombineChild,taint", BSScene.DetailLogZero); |
250 | 267 | ||
251 | // Get rid of any terrain that may have been allocated for us. | 268 | // Get rid of any terrain that may have been allocated for us. |
252 | ReleaseGroundPlaneAndTerrain(); | 269 | ReleaseGroundPlaneAndTerrain(); |
@@ -254,99 +271,7 @@ public class BSTerrainManager | |||
254 | // I hate doing this, but just bail | 271 | // I hate doing this, but just bail |
255 | return; | 272 | return; |
256 | } | 273 | } |
257 | 274 | }); | |
258 | if (mapInfo.terrainBody.ptr != IntPtr.Zero) | ||
259 | { | ||
260 | // Updating an existing terrain. | ||
261 | DetailLog("{0},UpdateOrCreateTerrain:UpdateExisting,taint,terrainBase={1},minC={2}, maxC={3}, szX={4}, szY={5}", | ||
262 | BSScene.DetailLogZero, terrainRegionBase, mapInfo.minCoords, mapInfo.maxCoords, mapInfo.sizeX, mapInfo.sizeY); | ||
263 | |||
264 | // Remove from the dynamics world because we're going to mangle this object | ||
265 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr); | ||
266 | |||
267 | // Get rid of the old terrain | ||
268 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr); | ||
269 | BulletSimAPI.ReleaseHeightMapInfo2(mapInfo.Ptr); | ||
270 | mapInfo.Ptr = IntPtr.Zero; | ||
271 | |||
272 | /* | ||
273 | // NOTE: This routine is half here because I can't get the terrain shape replacement | ||
274 | // to work. In the short term, the above three lines completely delete the old | ||
275 | // terrain and the code below recreates one from scratch. | ||
276 | // Hopefully the Bullet community will help me out on this one. | ||
277 | |||
278 | // First, release the old collision shape (there is only one terrain) | ||
279 | BulletSimAPI.DeleteCollisionShape2(m_physicsScene.World.Ptr, mapInfo.terrainShape.Ptr); | ||
280 | |||
281 | // Fill the existing height map info with the new location and size information | ||
282 | BulletSimAPI.FillHeightMapInfo2(m_physicsScene.World.Ptr, mapInfo.Ptr, mapInfo.ID, | ||
283 | mapInfo.minCoords, mapInfo.maxCoords, mapInfo.heightMap, TERRAIN_COLLISION_MARGIN); | ||
284 | |||
285 | // Create a terrain shape based on the new info | ||
286 | mapInfo.terrainShape = new BulletShape(BulletSimAPI.CreateTerrainShape2(mapInfo.Ptr)); | ||
287 | |||
288 | // Stuff the shape into the existing terrain body | ||
289 | BulletSimAPI.SetBodyShape2(m_physicsScene.World.Ptr, mapInfo.terrainBody.Ptr, mapInfo.terrainShape.Ptr); | ||
290 | */ | ||
291 | } | ||
292 | // else | ||
293 | { | ||
294 | // Creating a new terrain. | ||
295 | DetailLog("{0},UpdateOrCreateTerrain:CreateNewTerrain,taint,baseX={1},baseY={2},minZ={3},maxZ={4}", | ||
296 | BSScene.DetailLogZero, mapInfo.minCoords.X, mapInfo.minCoords.Y, minZ, maxZ); | ||
297 | |||
298 | mapInfo.ID = id; | ||
299 | mapInfo.Ptr = BulletSimAPI.CreateHeightMapInfo2(PhysicsScene.World.ptr, mapInfo.ID, | ||
300 | mapInfo.minCoords, mapInfo.maxCoords, mapInfo.heightMap, TERRAIN_COLLISION_MARGIN); | ||
301 | |||
302 | // Create the terrain shape from the mapInfo | ||
303 | mapInfo.terrainShape = new BulletShape(BulletSimAPI.CreateTerrainShape2(mapInfo.Ptr), | ||
304 | ShapeData.PhysicsShapeType.SHAPE_TERRAIN); | ||
305 | |||
306 | // The terrain object initial position is at the center of the object | ||
307 | Vector3 centerPos; | ||
308 | centerPos.X = minCoords.X + (mapInfo.sizeX / 2f); | ||
309 | centerPos.Y = minCoords.Y + (mapInfo.sizeY / 2f); | ||
310 | centerPos.Z = minZ + ((maxZ - minZ) / 2f); | ||
311 | |||
312 | mapInfo.terrainBody = new BulletBody(mapInfo.ID, | ||
313 | BulletSimAPI.CreateBodyWithDefaultMotionState2(mapInfo.terrainShape.ptr, | ||
314 | id, centerPos, Quaternion.Identity)); | ||
315 | } | ||
316 | |||
317 | // Make sure the entry is in the heightmap table | ||
318 | m_heightMaps[terrainRegionBase] = mapInfo; | ||
319 | |||
320 | // Set current terrain attributes | ||
321 | BulletSimAPI.SetFriction2(mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainFriction); | ||
322 | BulletSimAPI.SetHitFraction2(mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainHitFraction); | ||
323 | BulletSimAPI.SetRestitution2(mapInfo.terrainBody.ptr, PhysicsScene.Params.terrainRestitution); | ||
324 | BulletSimAPI.SetCollisionFlags2(mapInfo.terrainBody.ptr, CollisionFlags.CF_STATIC_OBJECT); | ||
325 | |||
326 | // Return the new terrain to the world of physical objects | ||
327 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr); | ||
328 | |||
329 | // redo its bounding box now that it is in the world | ||
330 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, mapInfo.terrainBody.ptr); | ||
331 | |||
332 | BulletSimAPI.SetCollisionFilterMask2(mapInfo.terrainBody.ptr, | ||
333 | (uint)CollisionFilterGroups.TerrainFilter, | ||
334 | (uint)CollisionFilterGroups.TerrainMask); | ||
335 | |||
336 | // Make sure the new shape is processed. | ||
337 | // BulletSimAPI.Activate2(mapInfo.terrainBody.ptr, true); | ||
338 | BulletSimAPI.ForceActivationState2(mapInfo.terrainBody.ptr, ActivationState.ISLAND_SLEEPING); | ||
339 | // BulletSimAPI.ForceActivationState2(mapInfo.terrainBody.ptr, ActivationState.DISABLE_SIMULATION); | ||
340 | |||
341 | m_terrainModified = true; | ||
342 | }; | ||
343 | |||
344 | // There is the option to do the changes now (we're already in 'taint time'), or | ||
345 | // to do the Bullet operations later. | ||
346 | if (inTaintTime) | ||
347 | rebuildOperation(); | ||
348 | else | ||
349 | PhysicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:UpdateExisting", rebuildOperation); | ||
350 | } | 275 | } |
351 | else | 276 | else |
352 | { | 277 | { |
@@ -362,40 +287,51 @@ public class BSTerrainManager | |||
362 | Vector3 minCoordsX = minCoords; | 287 | Vector3 minCoordsX = minCoords; |
363 | Vector3 maxCoordsX = maxCoords; | 288 | Vector3 maxCoordsX = maxCoords; |
364 | 289 | ||
365 | DetailLog("{0},UpdateOrCreateTerrain:NewTerrain,call,id={1}, minC={2}, maxC={3}", | 290 | DetailLog("{0},UpdateTerrain:NewTerrain,call,id={1}, minC={2}, maxC={3}", |
366 | BSScene.DetailLogZero, newTerrainID, minCoords, minCoords); | 291 | BSScene.DetailLogZero, newTerrainID, minCoords, minCoords); |
367 | 292 | ||
368 | // Code that must happen at taint-time | 293 | // Code that must happen at taint-time |
369 | BSScene.TaintCallback createOperation = delegate() | 294 | PhysicsScene.TaintedObject(inTaintTime, "BSScene.UpdateTerrain:NewTerrain", delegate() |
370 | { | 295 | { |
371 | DetailLog("{0},UpdateOrCreateTerrain:NewTerrain,taint,baseX={1},baseY={2}", BSScene.DetailLogZero, minCoords.X, minCoords.Y); | 296 | DetailLog("{0},UpdateTerrain:NewTerrain,taint,baseX={1},baseY={2}", |
372 | // Create a new mapInfo that will be filled with the new info | 297 | BSScene.DetailLogZero, minCoordsX.X, minCoordsX.Y); |
373 | mapInfo = new BulletHeightMapInfo(id, heightMapX, | 298 | BSTerrainPhys newTerrainPhys = BuildPhysicalTerrain(terrainRegionBase, id, heightMap, minCoords, maxCoords); |
374 | BulletSimAPI.CreateHeightMapInfo2(PhysicsScene.World.ptr, newTerrainID, | 299 | m_terrains.Add(terrainRegionBase, newTerrainPhys); |
375 | minCoordsX, maxCoordsX, heightMapX, TERRAIN_COLLISION_MARGIN)); | ||
376 | // Put the unfilled heightmap info into the collection of same | ||
377 | m_heightMaps.Add(terrainRegionBase, mapInfo); | ||
378 | // Build the terrain | ||
379 | UpdateOrCreateTerrain(newTerrainID, heightMap, minCoords, maxCoords, true); | ||
380 | 300 | ||
381 | m_terrainModified = true; | 301 | m_terrainModified = true; |
382 | }; | 302 | }); |
383 | |||
384 | // If already in taint-time, just call Bullet. Otherwise queue the operations for the safe time. | ||
385 | if (inTaintTime) | ||
386 | createOperation(); | ||
387 | else | ||
388 | PhysicsScene.TaintedObject("BSScene.UpdateOrCreateTerrain:NewTerrain", createOperation); | ||
389 | } | 303 | } |
390 | } | 304 | } |
391 | 305 | ||
392 | // Someday we will have complex terrain with caves and tunnels | 306 | // TODO: redo terrain implementation selection to allow other base types than heightMap. |
393 | public float GetTerrainHeightAtXYZ(Vector3 loc) | 307 | private BSTerrainPhys BuildPhysicalTerrain(Vector3 terrainRegionBase, uint id, float[] heightMap, Vector3 minCoords, Vector3 maxCoords) |
394 | { | 308 | { |
395 | // For the moment, it's flat and convex | 309 | PhysicsScene.Logger.DebugFormat("{0} Terrain for {1}/{2} created with {3}", |
396 | return GetTerrainHeightAtXY(loc.X, loc.Y); | 310 | LogHeader, PhysicsScene.RegionName, terrainRegionBase, |
311 | (BSTerrainPhys.TerrainImplementation)PhysicsScene.Params.terrainImplementation); | ||
312 | BSTerrainPhys newTerrainPhys = null; | ||
313 | switch ((int)PhysicsScene.Params.terrainImplementation) | ||
314 | { | ||
315 | case (int)BSTerrainPhys.TerrainImplementation.Heightmap: | ||
316 | newTerrainPhys = new BSTerrainHeightmap(PhysicsScene, terrainRegionBase, id, | ||
317 | heightMap, minCoords, maxCoords); | ||
318 | break; | ||
319 | case (int)BSTerrainPhys.TerrainImplementation.Mesh: | ||
320 | newTerrainPhys = new BSTerrainMesh(PhysicsScene, terrainRegionBase, id, | ||
321 | heightMap, minCoords, maxCoords); | ||
322 | break; | ||
323 | default: | ||
324 | PhysicsScene.Logger.ErrorFormat("{0} Bad terrain implementation specified. Type={1}/{2},Region={3}/{4}", | ||
325 | LogHeader, | ||
326 | (int)PhysicsScene.Params.terrainImplementation, | ||
327 | PhysicsScene.Params.terrainImplementation, | ||
328 | PhysicsScene.RegionName, terrainRegionBase); | ||
329 | break; | ||
330 | } | ||
331 | return newTerrainPhys; | ||
397 | } | 332 | } |
398 | 333 | ||
334 | |||
399 | // Given an X and Y, find the height of the terrain. | 335 | // Given an X and Y, find the height of the terrain. |
400 | // Since we could be handling multiple terrains for a mega-region, | 336 | // Since we could be handling multiple terrains for a mega-region, |
401 | // the base of the region is calcuated assuming all regions are | 337 | // the base of the region is calcuated assuming all regions are |
@@ -405,8 +341,10 @@ public class BSTerrainManager | |||
405 | private float lastHeightTX = 999999f; | 341 | private float lastHeightTX = 999999f; |
406 | private float lastHeightTY = 999999f; | 342 | private float lastHeightTY = 999999f; |
407 | private float lastHeight = HEIGHT_INITIAL_LASTHEIGHT; | 343 | private float lastHeight = HEIGHT_INITIAL_LASTHEIGHT; |
408 | private float GetTerrainHeightAtXY(float tX, float tY) | 344 | public float GetTerrainHeightAtXYZ(Vector3 loc) |
409 | { | 345 | { |
346 | float tX = loc.X; | ||
347 | float tY = loc.Y; | ||
410 | // You'd be surprized at the number of times this routine is called | 348 | // You'd be surprized at the number of times this routine is called |
411 | // with the same parameters as last time. | 349 | // with the same parameters as last time. |
412 | if (!m_terrainModified && lastHeightTX == tX && lastHeightTY == tY) | 350 | if (!m_terrainModified && lastHeightTX == tX && lastHeightTY == tY) |
@@ -418,27 +356,14 @@ public class BSTerrainManager | |||
418 | 356 | ||
419 | int offsetX = ((int)(tX / (int)DefaultRegionSize.X)) * (int)DefaultRegionSize.X; | 357 | int offsetX = ((int)(tX / (int)DefaultRegionSize.X)) * (int)DefaultRegionSize.X; |
420 | int offsetY = ((int)(tY / (int)DefaultRegionSize.Y)) * (int)DefaultRegionSize.Y; | 358 | int offsetY = ((int)(tY / (int)DefaultRegionSize.Y)) * (int)DefaultRegionSize.Y; |
421 | Vector2 terrainBaseXY = new Vector2(offsetX, offsetY); | 359 | Vector3 terrainBaseXYZ = new Vector3(offsetX, offsetY, 0f); |
422 | 360 | ||
423 | BulletHeightMapInfo mapInfo; | 361 | BSTerrainPhys physTerrain; |
424 | if (m_heightMaps.TryGetValue(terrainBaseXY, out mapInfo)) | 362 | if (m_terrains.TryGetValue(terrainBaseXYZ, out physTerrain)) |
425 | { | 363 | { |
426 | float regionX = tX - offsetX; | 364 | ret = physTerrain.GetHeightAtXYZ(loc - terrainBaseXYZ); |
427 | float regionY = tY - offsetY; | 365 | DetailLog("{0},BSTerrainManager.GetTerrainHeightAtXYZ,loc={1},base={2},height={3}", |
428 | int mapIndex = (int)regionY * (int)mapInfo.sizeY + (int)regionX; | 366 | BSScene.DetailLogZero, loc, terrainBaseXYZ, ret); |
429 | try | ||
430 | { | ||
431 | ret = mapInfo.heightMap[mapIndex]; | ||
432 | } | ||
433 | catch | ||
434 | { | ||
435 | // Sometimes they give us wonky values of X and Y. Give a warning and return something. | ||
436 | PhysicsScene.Logger.WarnFormat("{0} Bad request for terrain height. terrainBase={1}, x={2}, y={3}", | ||
437 | LogHeader, terrainBaseXY, regionX, regionY); | ||
438 | ret = HEIGHT_GETHEIGHT_RET; | ||
439 | } | ||
440 | // DetailLog("{0},BSTerrainManager.GetTerrainHeightAtXY,bX={1},baseY={2},szX={3},szY={4},regX={5},regY={6},index={7},ht={8}", | ||
441 | // BSScene.DetailLogZero, offsetX, offsetY, mapInfo.sizeX, mapInfo.sizeY, regionX, regionY, mapIndex, ret); | ||
442 | } | 367 | } |
443 | else | 368 | else |
444 | { | 369 | { |
@@ -481,7 +406,7 @@ public class BSTerrainManager | |||
481 | // Unhook all the combining that I know about. | 406 | // Unhook all the combining that I know about. |
482 | public void UnCombine(PhysicsScene pScene) | 407 | public void UnCombine(PhysicsScene pScene) |
483 | { | 408 | { |
484 | // Just like ODE, for the moment a NOP | 409 | // Just like ODE, we don't do anything yet. |
485 | DetailLog("{0},BSTerrainManager.UnCombine", BSScene.DetailLogZero); | 410 | DetailLog("{0},BSTerrainManager.UnCombine", BSScene.DetailLogZero); |
486 | } | 411 | } |
487 | 412 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs new file mode 100755 index 0000000..dca7150 --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/BSTerrainMesh.cs | |||
@@ -0,0 +1,256 @@ | |||
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 OpenSim.Framework; | ||
32 | using OpenSim.Region.Framework; | ||
33 | using OpenSim.Region.CoreModules; | ||
34 | using OpenSim.Region.Physics.Manager; | ||
35 | |||
36 | using Nini.Config; | ||
37 | using log4net; | ||
38 | |||
39 | using OpenMetaverse; | ||
40 | |||
41 | namespace OpenSim.Region.Physics.BulletSPlugin | ||
42 | { | ||
43 | public sealed class BSTerrainMesh : BSTerrainPhys | ||
44 | { | ||
45 | static string LogHeader = "[BULLETSIM TERRAIN MESH]"; | ||
46 | |||
47 | private float[] m_savedHeightMap; | ||
48 | int m_sizeX; | ||
49 | int m_sizeY; | ||
50 | |||
51 | BulletShape m_terrainShape; | ||
52 | BulletBody m_terrainBody; | ||
53 | |||
54 | public BSTerrainMesh(BSScene physicsScene, Vector3 regionBase, uint id, Vector3 regionSize) | ||
55 | : base(physicsScene, regionBase, id) | ||
56 | { | ||
57 | } | ||
58 | |||
59 | public BSTerrainMesh(BSScene physicsScene, Vector3 regionBase, uint id /* parameters for making mesh */) | ||
60 | : base(physicsScene, regionBase, id) | ||
61 | { | ||
62 | } | ||
63 | |||
64 | // Create terrain mesh from a heightmap. | ||
65 | public BSTerrainMesh(BSScene physicsScene, Vector3 regionBase, uint id, float[] initialMap, | ||
66 | Vector3 minCoords, Vector3 maxCoords) | ||
67 | : base(physicsScene, regionBase, id) | ||
68 | { | ||
69 | int indicesCount; | ||
70 | int[] indices; | ||
71 | int verticesCount; | ||
72 | float[] vertices; | ||
73 | |||
74 | m_savedHeightMap = initialMap; | ||
75 | |||
76 | m_sizeX = (int)(maxCoords.X - minCoords.X); | ||
77 | m_sizeY = (int)(maxCoords.Y - minCoords.Y); | ||
78 | |||
79 | if (!BSTerrainMesh.ConvertHeightmapToMesh(PhysicsScene, initialMap, | ||
80 | m_sizeX, m_sizeY, | ||
81 | (float)m_sizeX, (float)m_sizeY, | ||
82 | Vector3.Zero, 1.0f, | ||
83 | out indicesCount, out indices, out verticesCount, out vertices)) | ||
84 | { | ||
85 | // DISASTER!! | ||
86 | PhysicsScene.DetailLog("{0},BSTerrainMesh.create,failedConversionOfHeightmap", ID); | ||
87 | PhysicsScene.Logger.ErrorFormat("{0} Failed conversion of heightmap to mesh! base={1}", LogHeader, TerrainBase); | ||
88 | // Something is very messed up and a crash is in our future. | ||
89 | return; | ||
90 | } | ||
91 | |||
92 | m_terrainShape = new BulletShape(BulletSimAPI.CreateMeshShape2(PhysicsScene.World.ptr, | ||
93 | indicesCount, indices, verticesCount, vertices), | ||
94 | BSPhysicsShapeType.SHAPE_MESH); | ||
95 | if (m_terrainShape.ptr == IntPtr.Zero) | ||
96 | { | ||
97 | // DISASTER!! | ||
98 | PhysicsScene.DetailLog("{0},BSTerrainMesh.create,failedCreationOfShape", ID); | ||
99 | physicsScene.Logger.ErrorFormat("{0} Failed creation of terrain mesh! base={1}", LogHeader, TerrainBase); | ||
100 | // Something is very messed up and a crash is in our future. | ||
101 | return; | ||
102 | } | ||
103 | |||
104 | Vector3 pos = regionBase; | ||
105 | Quaternion rot = Quaternion.Identity; | ||
106 | |||
107 | m_terrainBody = new BulletBody(id, BulletSimAPI.CreateBodyWithDefaultMotionState2( m_terrainShape.ptr, ID, pos, rot)); | ||
108 | if (m_terrainBody.ptr == IntPtr.Zero) | ||
109 | { | ||
110 | // DISASTER!! | ||
111 | physicsScene.Logger.ErrorFormat("{0} Failed creation of terrain body! base={1}", LogHeader, TerrainBase); | ||
112 | // Something is very messed up and a crash is in our future. | ||
113 | return; | ||
114 | } | ||
115 | |||
116 | // Set current terrain attributes | ||
117 | BulletSimAPI.SetFriction2(m_terrainBody.ptr, PhysicsScene.Params.terrainFriction); | ||
118 | BulletSimAPI.SetHitFraction2(m_terrainBody.ptr, PhysicsScene.Params.terrainHitFraction); | ||
119 | BulletSimAPI.SetRestitution2(m_terrainBody.ptr, PhysicsScene.Params.terrainRestitution); | ||
120 | BulletSimAPI.SetCollisionFlags2(m_terrainBody.ptr, CollisionFlags.CF_STATIC_OBJECT); | ||
121 | |||
122 | // Static objects are not very massive. | ||
123 | BulletSimAPI.SetMassProps2(m_terrainBody.ptr, 0f, Vector3.Zero); | ||
124 | |||
125 | // Return the new terrain to the world of physical objects | ||
126 | BulletSimAPI.AddObjectToWorld2(PhysicsScene.World.ptr, m_terrainBody.ptr); | ||
127 | |||
128 | // redo its bounding box now that it is in the world | ||
129 | BulletSimAPI.UpdateSingleAabb2(PhysicsScene.World.ptr, m_terrainBody.ptr); | ||
130 | |||
131 | BulletSimAPI.SetCollisionFilterMask2(m_terrainBody.ptr, | ||
132 | (uint)CollisionFilterGroups.TerrainFilter, | ||
133 | (uint)CollisionFilterGroups.TerrainMask); | ||
134 | |||
135 | // Make it so the terrain will not move or be considered for movement. | ||
136 | BulletSimAPI.ForceActivationState2(m_terrainBody.ptr, ActivationState.DISABLE_SIMULATION); | ||
137 | } | ||
138 | |||
139 | public override void Dispose() | ||
140 | { | ||
141 | if (m_terrainBody.ptr != IntPtr.Zero) | ||
142 | { | ||
143 | BulletSimAPI.RemoveObjectFromWorld2(PhysicsScene.World.ptr, m_terrainBody.ptr); | ||
144 | // Frees both the body and the shape. | ||
145 | BulletSimAPI.DestroyObject2(PhysicsScene.World.ptr, m_terrainBody.ptr); | ||
146 | } | ||
147 | } | ||
148 | |||
149 | public override float GetHeightAtXYZ(Vector3 pos) | ||
150 | { | ||
151 | // For the moment use the saved heightmap to get the terrain height. | ||
152 | // TODO: raycast downward to find the true terrain below the position. | ||
153 | float ret = BSTerrainManager.HEIGHT_GETHEIGHT_RET; | ||
154 | |||
155 | int mapIndex = (int)pos.Y * m_sizeY + (int)pos.X; | ||
156 | try | ||
157 | { | ||
158 | ret = m_savedHeightMap[mapIndex]; | ||
159 | } | ||
160 | catch | ||
161 | { | ||
162 | // Sometimes they give us wonky values of X and Y. Give a warning and return something. | ||
163 | PhysicsScene.Logger.WarnFormat("{0} Bad request for terrain height. terrainBase={1}, pos={2}", | ||
164 | LogHeader, TerrainBase, pos); | ||
165 | ret = BSTerrainManager.HEIGHT_GETHEIGHT_RET; | ||
166 | } | ||
167 | return ret; | ||
168 | } | ||
169 | |||
170 | // Convert the passed heightmap to mesh information suitable for CreateMeshShape2(). | ||
171 | // Return 'true' if successfully created. | ||
172 | public static bool ConvertHeightmapToMesh( | ||
173 | BSScene physicsScene, | ||
174 | float[] heightMap, int sizeX, int sizeY, // parameters of incoming heightmap | ||
175 | float extentX, float extentY, // zero based range for output vertices | ||
176 | Vector3 extentBase, // base to be added to all vertices | ||
177 | float magnification, // number of vertices to create between heightMap coords | ||
178 | out int indicesCountO, out int[] indicesO, | ||
179 | out int verticesCountO, out float[] verticesO) | ||
180 | { | ||
181 | bool ret = false; | ||
182 | |||
183 | int indicesCount = 0; | ||
184 | int verticesCount = 0; | ||
185 | int[] indices = new int[0]; | ||
186 | float[] vertices = new float[0]; | ||
187 | |||
188 | // Simple mesh creation which assumes magnification == 1. | ||
189 | // TODO: do a more general solution that scales, adds new vertices and smoothes the result. | ||
190 | |||
191 | try | ||
192 | { | ||
193 | // One vertice per heightmap value plus the vertices off the top and bottom edge. | ||
194 | int totalVertices = (sizeX + 1) * (sizeY + 1); | ||
195 | vertices = new float[totalVertices * 3]; | ||
196 | int totalIndices = sizeX * sizeY * 6; | ||
197 | indices = new int[totalIndices]; | ||
198 | |||
199 | float magX = (float)sizeX / extentX; | ||
200 | float magY = (float)sizeY / extentY; | ||
201 | physicsScene.DetailLog("{0},BSTerrainMesh.ConvertHeightMapToMesh,totVert={1},totInd={2},extentBase={3},magX={4},magY={5}", | ||
202 | BSScene.DetailLogZero, totalVertices, totalIndices, extentBase, magX, magY); | ||
203 | // Note that sizeX+1 vertices are created since there is land between this and the next region. | ||
204 | for (int yy = 0; yy <= sizeY; yy++) | ||
205 | { | ||
206 | for (int xx = 0; xx <= sizeX; xx++) // Hint: the "<=" means we got through sizeX + 1 times | ||
207 | { | ||
208 | int offset = yy * sizeX + xx; | ||
209 | // Extend the height from the height from the last row or column | ||
210 | if (yy == sizeY) offset -= sizeX; | ||
211 | if (xx == sizeX) offset -= 1; | ||
212 | float height = heightMap[offset]; | ||
213 | vertices[verticesCount + 0] = (float)xx * magX + extentBase.X; | ||
214 | vertices[verticesCount + 1] = (float)yy * magY + extentBase.Y; | ||
215 | vertices[verticesCount + 2] = height + extentBase.Z; | ||
216 | verticesCount += 3; | ||
217 | } | ||
218 | } | ||
219 | verticesCount = verticesCount / 3; | ||
220 | physicsScene.DetailLog("{0},BSTerrainMesh.ConvertHeightMapToMesh,completeVerts,verCount={1}", | ||
221 | BSScene.DetailLogZero, verticesCount); | ||
222 | |||
223 | for (int yy = 0; yy < sizeY; yy++) | ||
224 | { | ||
225 | for (int xx = 0; xx < sizeX; xx++) | ||
226 | { | ||
227 | int offset = yy * sizeX + xx; | ||
228 | // Each vertices is presumed to be the upper left corner of a box of two triangles | ||
229 | indices[indicesCount + 0] = offset; | ||
230 | indices[indicesCount + 1] = offset + 1; | ||
231 | indices[indicesCount + 2] = offset + sizeX + 1; // accounting for the extra column | ||
232 | indices[indicesCount + 3] = offset + 1; | ||
233 | indices[indicesCount + 4] = offset + sizeX + 2; | ||
234 | indices[indicesCount + 5] = offset + sizeX + 1; | ||
235 | indicesCount += 6; | ||
236 | } | ||
237 | } | ||
238 | physicsScene.DetailLog("{0},BSTerrainMesh.ConvertHeightMapToMesh,completeIndices,indCount={1}", // DEEBUG DEBUG DEBUG | ||
239 | LogHeader, indicesCount); // DEBUG | ||
240 | ret = true; | ||
241 | } | ||
242 | catch (Exception e) | ||
243 | { | ||
244 | physicsScene.Logger.ErrorFormat("{0} Failed conversion of heightmap to mesh. For={1}/{2}, e={3}", | ||
245 | LogHeader, physicsScene.RegionName, extentBase, e); | ||
246 | } | ||
247 | |||
248 | indicesCountO = indicesCount; | ||
249 | indicesO = indices; | ||
250 | verticesCountO = verticesCount; | ||
251 | verticesO = vertices; | ||
252 | |||
253 | return ret; | ||
254 | } | ||
255 | } | ||
256 | } | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs index 5ffd591..e60a760 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BulletSimAPI.cs | |||
@@ -88,11 +88,11 @@ public struct BulletShape | |||
88 | public BulletShape(IntPtr xx) | 88 | public BulletShape(IntPtr xx) |
89 | { | 89 | { |
90 | ptr = xx; | 90 | ptr = xx; |
91 | type=ShapeData.PhysicsShapeType.SHAPE_UNKNOWN; | 91 | type=BSPhysicsShapeType.SHAPE_UNKNOWN; |
92 | shapeKey = 0; | 92 | shapeKey = (System.UInt64)FixedShapeKey.KEY_NONE; |
93 | isNativeShape = false; | 93 | isNativeShape = false; |
94 | } | 94 | } |
95 | public BulletShape(IntPtr xx, ShapeData.PhysicsShapeType typ) | 95 | public BulletShape(IntPtr xx, BSPhysicsShapeType typ) |
96 | { | 96 | { |
97 | ptr = xx; | 97 | ptr = xx; |
98 | type = typ; | 98 | type = typ; |
@@ -100,7 +100,7 @@ public struct BulletShape | |||
100 | isNativeShape = false; | 100 | isNativeShape = false; |
101 | } | 101 | } |
102 | public IntPtr ptr; | 102 | public IntPtr ptr; |
103 | public ShapeData.PhysicsShapeType type; | 103 | public BSPhysicsShapeType type; |
104 | public System.UInt64 shapeKey; | 104 | public System.UInt64 shapeKey; |
105 | public bool isNativeShape; | 105 | public bool isNativeShape; |
106 | public override string ToString() | 106 | public override string ToString() |
@@ -152,7 +152,7 @@ public class BulletHeightMapInfo | |||
152 | ID = id; | 152 | ID = id; |
153 | Ptr = xx; | 153 | Ptr = xx; |
154 | heightMap = hm; | 154 | heightMap = hm; |
155 | terrainRegionBase = new Vector2(0f, 0f); | 155 | terrainRegionBase = Vector3.Zero; |
156 | minCoords = new Vector3(100f, 100f, 25f); | 156 | minCoords = new Vector3(100f, 100f, 25f); |
157 | maxCoords = new Vector3(101f, 101f, 26f); | 157 | maxCoords = new Vector3(101f, 101f, 26f); |
158 | minZ = maxZ = 0f; | 158 | minZ = maxZ = 0f; |
@@ -161,7 +161,7 @@ public class BulletHeightMapInfo | |||
161 | public uint ID; | 161 | public uint ID; |
162 | public IntPtr Ptr; | 162 | public IntPtr Ptr; |
163 | public float[] heightMap; | 163 | public float[] heightMap; |
164 | public Vector2 terrainRegionBase; | 164 | public Vector3 terrainRegionBase; |
165 | public Vector3 minCoords; | 165 | public Vector3 minCoords; |
166 | public Vector3 maxCoords; | 166 | public Vector3 maxCoords; |
167 | public float sizeX, sizeY; | 167 | public float sizeX, sizeY; |
@@ -178,25 +178,39 @@ public struct ConvexHull | |||
178 | int VertexCount; | 178 | int VertexCount; |
179 | Vector3[] Vertices; | 179 | Vector3[] Vertices; |
180 | } | 180 | } |
181 | public enum BSPhysicsShapeType | ||
182 | { | ||
183 | SHAPE_UNKNOWN = 0, | ||
184 | SHAPE_CAPSULE = 1, | ||
185 | SHAPE_BOX = 2, | ||
186 | SHAPE_CONE = 3, | ||
187 | SHAPE_CYLINDER = 4, | ||
188 | SHAPE_SPHERE = 5, | ||
189 | SHAPE_MESH = 6, | ||
190 | SHAPE_HULL = 7, | ||
191 | // following defined by BulletSim | ||
192 | SHAPE_GROUNDPLANE = 20, | ||
193 | SHAPE_TERRAIN = 21, | ||
194 | SHAPE_COMPOUND = 22, | ||
195 | SHAPE_HEIGHTMAP = 23, | ||
196 | }; | ||
197 | |||
198 | // The native shapes have predefined shape hash keys | ||
199 | public enum FixedShapeKey : ulong | ||
200 | { | ||
201 | KEY_NONE = 0, | ||
202 | KEY_BOX = 1, | ||
203 | KEY_SPHERE = 2, | ||
204 | KEY_CONE = 3, | ||
205 | KEY_CYLINDER = 4, | ||
206 | KEY_CAPSULE = 5, | ||
207 | } | ||
208 | |||
181 | [StructLayout(LayoutKind.Sequential)] | 209 | [StructLayout(LayoutKind.Sequential)] |
182 | public struct ShapeData | 210 | public struct ShapeData |
183 | { | 211 | { |
184 | public enum PhysicsShapeType | ||
185 | { | ||
186 | SHAPE_UNKNOWN = 0, | ||
187 | SHAPE_AVATAR = 1, | ||
188 | SHAPE_BOX = 2, | ||
189 | SHAPE_CONE = 3, | ||
190 | SHAPE_CYLINDER = 4, | ||
191 | SHAPE_SPHERE = 5, | ||
192 | SHAPE_MESH = 6, | ||
193 | SHAPE_HULL = 7, | ||
194 | // following defined by BulletSim | ||
195 | SHAPE_GROUNDPLANE = 20, | ||
196 | SHAPE_TERRAIN = 21, | ||
197 | }; | ||
198 | public uint ID; | 212 | public uint ID; |
199 | public PhysicsShapeType Type; | 213 | public BSPhysicsShapeType Type; |
200 | public Vector3 Position; | 214 | public Vector3 Position; |
201 | public Quaternion Rotation; | 215 | public Quaternion Rotation; |
202 | public Vector3 Velocity; | 216 | public Vector3 Velocity; |
@@ -215,16 +229,6 @@ public struct ShapeData | |||
215 | // note that bools are passed as floats since bool size changes by language and architecture | 229 | // note that bools are passed as floats since bool size changes by language and architecture |
216 | public const float numericTrue = 1f; | 230 | public const float numericTrue = 1f; |
217 | public const float numericFalse = 0f; | 231 | public const float numericFalse = 0f; |
218 | |||
219 | // The native shapes have predefined shape hash keys | ||
220 | public enum FixedShapeKey : ulong | ||
221 | { | ||
222 | KEY_BOX = 1, | ||
223 | KEY_SPHERE = 2, | ||
224 | KEY_CONE = 3, | ||
225 | KEY_CYLINDER = 4, | ||
226 | KEY_CAPSULE = 5, | ||
227 | } | ||
228 | } | 232 | } |
229 | [StructLayout(LayoutKind.Sequential)] | 233 | [StructLayout(LayoutKind.Sequential)] |
230 | public struct SweepHit | 234 | public struct SweepHit |
@@ -279,6 +283,7 @@ public struct ConfigurationParameters | |||
279 | public float ccdSweptSphereRadius; | 283 | public float ccdSweptSphereRadius; |
280 | public float contactProcessingThreshold; | 284 | public float contactProcessingThreshold; |
281 | 285 | ||
286 | public float terrainImplementation; | ||
282 | public float terrainFriction; | 287 | public float terrainFriction; |
283 | public float terrainHitFraction; | 288 | public float terrainHitFraction; |
284 | public float terrainRestitution; | 289 | public float terrainRestitution; |
@@ -286,7 +291,8 @@ public struct ConfigurationParameters | |||
286 | public float avatarStandingFriction; | 291 | public float avatarStandingFriction; |
287 | public float avatarDensity; | 292 | public float avatarDensity; |
288 | public float avatarRestitution; | 293 | public float avatarRestitution; |
289 | public float avatarCapsuleRadius; | 294 | public float avatarCapsuleWidth; |
295 | public float avatarCapsuleDepth; | ||
290 | public float avatarCapsuleHeight; | 296 | public float avatarCapsuleHeight; |
291 | public float avatarContactProcessingThreshold; | 297 | public float avatarContactProcessingThreshold; |
292 | 298 | ||
@@ -299,6 +305,7 @@ public struct ConfigurationParameters | |||
299 | public float shouldEnableFrictionCaching; | 305 | public float shouldEnableFrictionCaching; |
300 | public float numberOfSolverIterations; | 306 | public float numberOfSolverIterations; |
301 | 307 | ||
308 | public float linksetImplementation; | ||
302 | public float linkConstraintUseFrameOffset; | 309 | public float linkConstraintUseFrameOffset; |
303 | public float linkConstraintEnableTransMotor; | 310 | public float linkConstraintEnableTransMotor; |
304 | public float linkConstraintTransMotorMaxVel; | 311 | public float linkConstraintTransMotorMaxVel; |
@@ -378,6 +385,7 @@ public enum CollisionFilterGroups : uint | |||
378 | BTerrainFilter = 1 << 11, | 385 | BTerrainFilter = 1 << 11, |
379 | BRaycastFilter = 1 << 12, | 386 | BRaycastFilter = 1 << 12, |
380 | BSolidFilter = 1 << 13, | 387 | BSolidFilter = 1 << 13, |
388 | BLinksetFilter = 1 << 14, | ||
381 | 389 | ||
382 | // The collsion filters and masked are defined in one place -- don't want them scattered | 390 | // The collsion filters and masked are defined in one place -- don't want them scattered |
383 | AvatarFilter = BCharacterFilter, | 391 | AvatarFilter = BCharacterFilter, |
@@ -385,18 +393,18 @@ public enum CollisionFilterGroups : uint | |||
385 | ObjectFilter = BSolidFilter, | 393 | ObjectFilter = BSolidFilter, |
386 | ObjectMask = BAllFilter, | 394 | ObjectMask = BAllFilter, |
387 | StaticObjectFilter = BStaticFilter, | 395 | StaticObjectFilter = BStaticFilter, |
388 | StaticObjectMask = BAllFilter, | 396 | StaticObjectMask = BAllFilter & ~BStaticFilter, // static objects don't collide with each other |
397 | LinksetFilter = BLinksetFilter, | ||
398 | LinksetMask = BAllFilter & ~BLinksetFilter, // linkset objects don't collide with each other | ||
389 | VolumeDetectFilter = BSensorTrigger, | 399 | VolumeDetectFilter = BSensorTrigger, |
390 | VolumeDetectMask = ~BSensorTrigger, | 400 | VolumeDetectMask = ~BSensorTrigger, |
391 | TerrainFilter = BTerrainFilter, | 401 | TerrainFilter = BTerrainFilter, |
392 | TerrainMask = BAllFilter & ~BStaticFilter, | 402 | TerrainMask = BAllFilter & ~BStaticFilter, // static objects on the ground don't collide |
393 | GroundPlaneFilter = BGroundPlaneFilter, | 403 | GroundPlaneFilter = BGroundPlaneFilter, |
394 | GroundPlaneMask = BAllFilter | 404 | GroundPlaneMask = BAllFilter |
395 | 405 | ||
396 | }; | 406 | }; |
397 | 407 | ||
398 | |||
399 | |||
400 | // CFM controls the 'hardness' of the constraint. 0=fixed, 0..1=violatable. Default=0 | 408 | // CFM controls the 'hardness' of the constraint. 0=fixed, 0..1=violatable. Default=0 |
401 | // ERP controls amount of correction per tick. Usable range=0.1..0.8. Default=0.2. | 409 | // ERP controls amount of correction per tick. Usable range=0.1..0.8. Default=0.2. |
402 | public enum ConstraintParams : int | 410 | public enum ConstraintParams : int |
@@ -426,140 +434,6 @@ static class BulletSimAPI { | |||
426 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] | 434 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] |
427 | public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg); | 435 | public delegate void DebugLogCallback([MarshalAs(UnmanagedType.LPStr)]string msg); |
428 | 436 | ||
429 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
430 | [return: MarshalAs(UnmanagedType.LPStr)] | ||
431 | public static extern string GetVersion(); | ||
432 | |||
433 | /* Remove the linkage to the old api methods | ||
434 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
435 | public static extern uint Initialize(Vector3 maxPosition, IntPtr parms, | ||
436 | int maxCollisions, IntPtr collisionArray, | ||
437 | int maxUpdates, IntPtr updateArray, | ||
438 | DebugLogCallback logRoutine); | ||
439 | |||
440 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
441 | public static extern void CreateInitialGroundPlaneAndTerrain(uint worldID); | ||
442 | |||
443 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
444 | public static extern void SetHeightmap(uint worldID, [MarshalAs(UnmanagedType.LPArray)] float[] heightMap); | ||
445 | |||
446 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
447 | public static extern void Shutdown(uint worldID); | ||
448 | |||
449 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
450 | public static extern bool UpdateParameter(uint worldID, uint localID, | ||
451 | [MarshalAs(UnmanagedType.LPStr)]string paramCode, float value); | ||
452 | |||
453 | // =============================================================================== | ||
454 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
455 | public static extern int PhysicsStep(uint worldID, float timeStep, int maxSubSteps, float fixedTimeStep, | ||
456 | out int updatedEntityCount, | ||
457 | out IntPtr updatedEntitiesPtr, | ||
458 | out int collidersCount, | ||
459 | out IntPtr collidersPtr); | ||
460 | |||
461 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
462 | public static extern bool CreateHull(uint worldID, System.UInt64 meshKey, | ||
463 | int hullCount, [MarshalAs(UnmanagedType.LPArray)] float[] hulls | ||
464 | ); | ||
465 | |||
466 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
467 | public static extern bool CreateMesh(uint worldID, System.UInt64 meshKey, | ||
468 | int indexCount, [MarshalAs(UnmanagedType.LPArray)] int[] indices, | ||
469 | int verticesCount, [MarshalAs(UnmanagedType.LPArray)] float[] vertices | ||
470 | ); | ||
471 | |||
472 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
473 | public static extern bool DestroyHull(uint worldID, System.UInt64 meshKey); | ||
474 | |||
475 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
476 | public static extern bool DestroyMesh(uint worldID, System.UInt64 meshKey); | ||
477 | |||
478 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
479 | public static extern bool CreateObject(uint worldID, ShapeData shapeData); | ||
480 | |||
481 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
482 | public static extern Vector3 GetObjectPosition(uint WorldID, uint id); | ||
483 | |||
484 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
485 | public static extern Quaternion GetObjectOrientation(uint WorldID, uint id); | ||
486 | |||
487 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
488 | public static extern bool SetObjectTranslation(uint worldID, uint id, Vector3 position, Quaternion rotation); | ||
489 | |||
490 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
491 | public static extern bool SetObjectVelocity(uint worldID, uint id, Vector3 velocity); | ||
492 | |||
493 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
494 | public static extern bool SetObjectAngularVelocity(uint worldID, uint id, Vector3 angularVelocity); | ||
495 | |||
496 | // Set the current force acting on the object | ||
497 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
498 | public static extern bool SetObjectForce(uint worldID, uint id, Vector3 force); | ||
499 | |||
500 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
501 | public static extern bool SetObjectScaleMass(uint worldID, uint id, Vector3 scale, float mass, bool isDynamic); | ||
502 | |||
503 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
504 | public static extern bool SetObjectCollidable(uint worldID, uint id, bool phantom); | ||
505 | |||
506 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
507 | public static extern bool SetObjectDynamic(uint worldID, uint id, bool isDynamic, float mass); | ||
508 | |||
509 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
510 | public static extern bool SetObjectGhost(uint worldID, uint id, bool ghostly); | ||
511 | |||
512 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
513 | public static extern bool SetObjectProperties(uint worldID, uint id, bool isStatic, bool isSolid, bool genCollisions, float mass); | ||
514 | |||
515 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
516 | public static extern bool SetObjectBuoyancy(uint worldID, uint id, float buoyancy); | ||
517 | |||
518 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
519 | public static extern bool HasObject(uint worldID, uint id); | ||
520 | |||
521 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
522 | public static extern bool DestroyObject(uint worldID, uint id); | ||
523 | |||
524 | // =============================================================================== | ||
525 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
526 | public static extern SweepHit ConvexSweepTest(uint worldID, uint id, Vector3 to, float extraMargin); | ||
527 | |||
528 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
529 | public static extern RaycastHit RayTest(uint worldID, uint id, Vector3 from, Vector3 to); | ||
530 | |||
531 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
532 | public static extern Vector3 RecoverFromPenetration(uint worldID, uint id); | ||
533 | |||
534 | // =============================================================================== | ||
535 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
536 | public static extern void DumpBulletStatistics(); | ||
537 | */ | ||
538 | // Log a debug message | ||
539 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
540 | public static extern void SetDebugLogCallback(DebugLogCallback callback); | ||
541 | |||
542 | // =============================================================================== | ||
543 | // =============================================================================== | ||
544 | // =============================================================================== | ||
545 | // A new version of the API that enables moving all the logic out of the C++ code and into | ||
546 | // the C# code. This will make modifications easier for the next person. | ||
547 | // This interface passes the actual pointers to the objects in the unmanaged | ||
548 | // address space. All the management (calls for creation/destruction/lookup) | ||
549 | // is done in the C# code. | ||
550 | // The names have a "2" tacked on. This will be removed as the C# code gets rebuilt | ||
551 | // and the old code is removed. | ||
552 | |||
553 | // Functions use while converting from API1 to API2. Can be removed when totally converted. | ||
554 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
555 | public static extern IntPtr GetSimHandle2(uint worldID); | ||
556 | |||
557 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
558 | public static extern IntPtr GetBodyHandleWorldID2(uint worldID, uint id); | ||
559 | |||
560 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
561 | public static extern IntPtr GetBodyHandle2(IntPtr world, uint id); | ||
562 | |||
563 | // =============================================================================== | 437 | // =============================================================================== |
564 | // Initialization and simulation | 438 | // Initialization and simulation |
565 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 439 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
@@ -611,13 +485,25 @@ public static extern bool IsNativeShape2(IntPtr shape); | |||
611 | public static extern IntPtr BuildCapsuleShape2(IntPtr world, float radius, float height, Vector3 scale); | 485 | public static extern IntPtr BuildCapsuleShape2(IntPtr world, float radius, float height, Vector3 scale); |
612 | 486 | ||
613 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 487 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
614 | public static extern IntPtr CreateCompoundShape2(IntPtr sim); | 488 | public static extern IntPtr CreateCompoundShape2(IntPtr sim, bool enableDynamicAabbTree); |
615 | 489 | ||
616 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 490 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
617 | public static extern void AddChildToCompoundShape2(IntPtr cShape, IntPtr addShape, Vector3 pos, Quaternion rot); | 491 | public static extern int GetNumberOfCompoundChildren2(IntPtr cShape); |
618 | 492 | ||
619 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 493 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
620 | public static extern void RemoveChildFromCompoundShape2(IntPtr cShape, IntPtr removeShape); | 494 | public static extern void AddChildShapeToCompoundShape2(IntPtr cShape, IntPtr addShape, Vector3 pos, Quaternion rot); |
495 | |||
496 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
497 | public static extern IntPtr GetChildShapeFromCompoundShapeIndex2(IntPtr cShape, int indx); | ||
498 | |||
499 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
500 | public static extern IntPtr RemoveChildShapeFromCompoundShapeIndex2(IntPtr cShape, int indx); | ||
501 | |||
502 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
503 | public static extern void RemoveChildShapeFromCompoundShape2(IntPtr cShape, IntPtr removeShape); | ||
504 | |||
505 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
506 | public static extern void RecalculateCompoundShapeLocalAabb2(IntPtr cShape); | ||
621 | 507 | ||
622 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 508 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
623 | public static extern IntPtr DuplicateCollisionShape2(IntPtr sim, IntPtr srcShape, uint id); | 509 | public static extern IntPtr DuplicateCollisionShape2(IntPtr sim, IntPtr srcShape, uint id); |
@@ -881,10 +767,10 @@ public static extern float GetCcdMotionThreshold2(IntPtr obj); | |||
881 | public static extern void SetCcdMotionThreshold2(IntPtr obj, float val); | 767 | public static extern void SetCcdMotionThreshold2(IntPtr obj, float val); |
882 | 768 | ||
883 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 769 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
884 | public static extern float GetCcdSweepSphereRadius2(IntPtr obj); | 770 | public static extern float GetCcdSweptSphereRadius2(IntPtr obj); |
885 | 771 | ||
886 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 772 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
887 | public static extern void SetCcdSweepSphereRadius2(IntPtr obj, float val); | 773 | public static extern void SetCcdSweptSphereRadius2(IntPtr obj, float val); |
888 | 774 | ||
889 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 775 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
890 | public static extern IntPtr GetUserPointer2(IntPtr obj); | 776 | public static extern IntPtr GetUserPointer2(IntPtr obj); |
@@ -907,6 +793,12 @@ public static extern Vector3 GetGravity2(IntPtr obj); | |||
907 | public static extern void SetDamping2(IntPtr obj, float lin_damping, float ang_damping); | 793 | public static extern void SetDamping2(IntPtr obj, float lin_damping, float ang_damping); |
908 | 794 | ||
909 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 795 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
796 | public static extern void SetLinearDamping2(IntPtr obj, float lin_damping); | ||
797 | |||
798 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
799 | public static extern void SetAngularDamping2(IntPtr obj, float ang_damping); | ||
800 | |||
801 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | ||
910 | public static extern float GetLinearDamping2(IntPtr obj); | 802 | public static extern float GetLinearDamping2(IntPtr obj); |
911 | 803 | ||
912 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] | 804 | [DllImport("BulletSim", CallingConvention = CallingConvention.Cdecl), SuppressUnmanagedCodeSecurity] |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/Properties/AssemblyInfo.cs b/OpenSim/Region/Physics/BulletSPlugin/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0d1db3b --- /dev/null +++ b/OpenSim/Region/Physics/BulletSPlugin/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.Physics.BulletSPlugin")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("520ea11b-20cb-449d-ba05-c01015fed841")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/Physics/ConvexDecompositionDotNet/Properties/AssemblyInfo.cs b/OpenSim/Region/Physics/ConvexDecompositionDotNet/Properties/AssemblyInfo.cs index 4285e8c..5ff945d 100644 --- a/OpenSim/Region/Physics/ConvexDecompositionDotNet/Properties/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/ConvexDecompositionDotNet/Properties/AssemblyInfo.cs | |||
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices; | |||
32 | // You can specify all the values or you can default the Build and Revision Numbers | 32 | // You can specify all the values or you can default the Build and Revision Numbers |
33 | // by using the '*' as shown below: | 33 | // by using the '*' as shown below: |
34 | // [assembly: AssemblyVersion("1.0.*")] | 34 | // [assembly: AssemblyVersion("1.0.*")] |
35 | [assembly: AssemblyVersion("1.0.0.0")] | 35 | [assembly: AssemblyVersion("0.7.5.*")] |
36 | [assembly: AssemblyFileVersion("1.0.0.0")] | 36 | [assembly: AssemblyFileVersion("1.0.0.0")] |
diff --git a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs index 1f9bf03..36b4235 100644 --- a/OpenSim/Region/Physics/Manager/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/Manager/AssemblyInfo.cs | |||
@@ -39,7 +39,7 @@ using System.Runtime.InteropServices; | |||
39 | [assembly : AssemblyConfiguration("")] | 39 | [assembly : AssemblyConfiguration("")] |
40 | [assembly : AssemblyCompany("http://opensimulator.org")] | 40 | [assembly : AssemblyCompany("http://opensimulator.org")] |
41 | [assembly : AssemblyProduct("PhysicsManager")] | 41 | [assembly : AssemblyProduct("PhysicsManager")] |
42 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] | 42 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")] |
43 | [assembly : AssemblyTrademark("")] | 43 | [assembly : AssemblyTrademark("")] |
44 | [assembly : AssemblyCulture("")] | 44 | [assembly : AssemblyCulture("")] |
45 | 45 | ||
@@ -55,4 +55,4 @@ using System.Runtime.InteropServices; | |||
55 | // You can specify all values by your own or you can build default build and revision | 55 | // You can specify all values by your own or you can build default build and revision |
56 | // numbers with the '*' character (the default): | 56 | // numbers with the '*' character (the default): |
57 | 57 | ||
58 | [assembly : AssemblyVersion("0.6.5.*")] | 58 | [assembly : AssemblyVersion("0.7.5.*")] |
diff --git a/OpenSim/Region/Physics/Manager/PhysicsActor.cs b/OpenSim/Region/Physics/Manager/PhysicsActor.cs index 0587054..34413e5 100644 --- a/OpenSim/Region/Physics/Manager/PhysicsActor.cs +++ b/OpenSim/Region/Physics/Manager/PhysicsActor.cs | |||
@@ -257,6 +257,12 @@ namespace OpenSim.Region.Physics.Manager | |||
257 | /// Getting this returns the velocity calculated by physics scene updates, using factors such as target velocity, | 257 | /// Getting this returns the velocity calculated by physics scene updates, using factors such as target velocity, |
258 | /// time to accelerate and collisions. | 258 | /// time to accelerate and collisions. |
259 | /// </remarks> | 259 | /// </remarks> |
260 | public virtual Vector3 TargetVelocity | ||
261 | { | ||
262 | get { return Velocity; } | ||
263 | set { Velocity = value; } | ||
264 | } | ||
265 | |||
260 | public abstract Vector3 Velocity { get; set; } | 266 | public abstract Vector3 Velocity { get; set; } |
261 | 267 | ||
262 | public abstract Vector3 Torque { get; set; } | 268 | public abstract Vector3 Torque { get; set; } |
diff --git a/OpenSim/Region/Physics/Meshing/Properties/AssemblyInfo.cs b/OpenSim/Region/Physics/Meshing/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..4cc1731 --- /dev/null +++ b/OpenSim/Region/Physics/Meshing/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.Physics.Meshing")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("4b7e35c2-a9dd-4b10-b778-eb417f4f6884")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs index d65929a..3c4f06a 100644 --- a/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/OdePlugin/AssemblyInfo.cs | |||
@@ -39,7 +39,7 @@ using System.Runtime.InteropServices; | |||
39 | [assembly : AssemblyConfiguration("")] | 39 | [assembly : AssemblyConfiguration("")] |
40 | [assembly : AssemblyCompany("http://opensimulator.org")] | 40 | [assembly : AssemblyCompany("http://opensimulator.org")] |
41 | [assembly : AssemblyProduct("OdePlugin")] | 41 | [assembly : AssemblyProduct("OdePlugin")] |
42 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] | 42 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")] |
43 | [assembly : AssemblyTrademark("")] | 43 | [assembly : AssemblyTrademark("")] |
44 | [assembly : AssemblyCulture("")] | 44 | [assembly : AssemblyCulture("")] |
45 | 45 | ||
@@ -55,4 +55,4 @@ using System.Runtime.InteropServices; | |||
55 | // You can specify all values by your own or you can build default build and revision | 55 | // You can specify all values by your own or you can build default build and revision |
56 | // numbers with the '*' character (the default): | 56 | // numbers with the '*' character (the default): |
57 | 57 | ||
58 | [assembly : AssemblyVersion("0.6.5.*")] | 58 | [assembly : AssemblyVersion("0.7.5.*")] |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs index c736557..319f6ab 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODECharacter.cs | |||
@@ -661,6 +661,20 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
661 | set { return; } | 661 | set { return; } |
662 | } | 662 | } |
663 | 663 | ||
664 | public override Vector3 TargetVelocity | ||
665 | { | ||
666 | get | ||
667 | { | ||
668 | return m_taintTargetVelocity; | ||
669 | } | ||
670 | |||
671 | set | ||
672 | { | ||
673 | Velocity = value; | ||
674 | } | ||
675 | } | ||
676 | |||
677 | |||
664 | public override Vector3 Velocity | 678 | public override Vector3 Velocity |
665 | { | 679 | { |
666 | get | 680 | get |
@@ -1394,4 +1408,4 @@ namespace OpenSim.Region.Physics.OdePlugin | |||
1394 | m_eventsubscription += p; | 1408 | m_eventsubscription += p; |
1395 | } | 1409 | } |
1396 | } | 1410 | } |
1397 | } \ No newline at end of file | 1411 | } |
diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 2548648..5a0b8d1 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | |||
@@ -3335,7 +3335,6 @@ Console.WriteLine(" JointCreateFixed"); | |||
3335 | m_material = pMaterial; | 3335 | m_material = pMaterial; |
3336 | } | 3336 | } |
3337 | 3337 | ||
3338 | |||
3339 | private void CheckMeshAsset() | 3338 | private void CheckMeshAsset() |
3340 | { | 3339 | { |
3341 | if (_pbs.SculptEntry && !m_assetFailed && _pbs.SculptTexture != UUID.Zero) | 3340 | if (_pbs.SculptEntry && !m_assetFailed && _pbs.SculptTexture != UUID.Zero) |
@@ -3345,14 +3344,14 @@ Console.WriteLine(" JointCreateFixed"); | |||
3345 | { | 3344 | { |
3346 | RequestAssetDelegate assetProvider = _parent_scene.RequestAssetMethod; | 3345 | RequestAssetDelegate assetProvider = _parent_scene.RequestAssetMethod; |
3347 | if (assetProvider != null) | 3346 | if (assetProvider != null) |
3348 | assetProvider(_pbs.SculptTexture, MeshAssetReveived); | 3347 | assetProvider(_pbs.SculptTexture, MeshAssetReceived); |
3349 | }); | 3348 | }); |
3350 | } | 3349 | } |
3351 | } | 3350 | } |
3352 | 3351 | ||
3353 | void MeshAssetReveived(AssetBase asset) | 3352 | private void MeshAssetReceived(AssetBase asset) |
3354 | { | 3353 | { |
3355 | if (asset.Data != null && asset.Data.Length > 0) | 3354 | if (asset != null && asset.Data != null && asset.Data.Length > 0) |
3356 | { | 3355 | { |
3357 | if (!_pbs.SculptEntry) | 3356 | if (!_pbs.SculptEntry) |
3358 | return; | 3357 | return; |
@@ -3365,6 +3364,12 @@ Console.WriteLine(" JointCreateFixed"); | |||
3365 | m_taintshape = true; | 3364 | m_taintshape = true; |
3366 | _parent_scene.AddPhysicsActorTaint(this); | 3365 | _parent_scene.AddPhysicsActorTaint(this); |
3367 | } | 3366 | } |
3367 | else | ||
3368 | { | ||
3369 | m_log.WarnFormat( | ||
3370 | "[ODE PRIM]: Could not get mesh/sculpt asset {0} for {1} at {2} in {3}", | ||
3371 | _pbs.SculptTexture, Name, _position, _parent_scene.Name); | ||
3372 | } | ||
3368 | } | 3373 | } |
3369 | } | 3374 | } |
3370 | } \ No newline at end of file | 3375 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs b/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs index cbc6b95..16404c6 100644 --- a/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs +++ b/OpenSim/Region/Physics/OdePlugin/Tests/ODETestClass.cs | |||
@@ -32,13 +32,14 @@ using OpenMetaverse; | |||
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Region.Physics.Manager; | 33 | using OpenSim.Region.Physics.Manager; |
34 | using OpenSim.Region.Physics.OdePlugin; | 34 | using OpenSim.Region.Physics.OdePlugin; |
35 | using OpenSim.Tests.Common; | ||
35 | using log4net; | 36 | using log4net; |
36 | using System.Reflection; | 37 | using System.Reflection; |
37 | 38 | ||
38 | namespace OpenSim.Region.Physics.OdePlugin.Tests | 39 | namespace OpenSim.Region.Physics.OdePlugin.Tests |
39 | { | 40 | { |
40 | [TestFixture] | 41 | [TestFixture] |
41 | public class ODETestClass | 42 | public class ODETestClass : OpenSimTestCase |
42 | { | 43 | { |
43 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 44 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
44 | 45 | ||
diff --git a/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs b/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs index af24567..d07df02 100644 --- a/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs +++ b/OpenSim/Region/Physics/POSPlugin/AssemblyInfo.cs | |||
@@ -39,7 +39,7 @@ using System.Runtime.InteropServices; | |||
39 | [assembly : AssemblyConfiguration("")] | 39 | [assembly : AssemblyConfiguration("")] |
40 | [assembly : AssemblyCompany("http://opensimulator.org")] | 40 | [assembly : AssemblyCompany("http://opensimulator.org")] |
41 | [assembly : AssemblyProduct("POSPlugin")] | 41 | [assembly : AssemblyProduct("POSPlugin")] |
42 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers 2007-2009")] | 42 | [assembly : AssemblyCopyright("Copyright (c) OpenSimulator.org Developers")] |
43 | [assembly : AssemblyTrademark("")] | 43 | [assembly : AssemblyTrademark("")] |
44 | [assembly : AssemblyCulture("")] | 44 | [assembly : AssemblyCulture("")] |
45 | 45 | ||
@@ -55,4 +55,4 @@ using System.Runtime.InteropServices; | |||
55 | // You can specify all values by your own or you can build default build and revision | 55 | // You can specify all values by your own or you can build default build and revision |
56 | // numbers with the '*' character (the default): | 56 | // numbers with the '*' character (the default): |
57 | 57 | ||
58 | [assembly : AssemblyVersion("0.6.5.*")] | 58 | [assembly : AssemblyVersion("0.7.5.*")] |
diff --git a/OpenSim/Region/RegionCombinerModule/Properties/AssemblyInfo.cs b/OpenSim/Region/RegionCombinerModule/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..085eb59 --- /dev/null +++ b/OpenSim/Region/RegionCombinerModule/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.RegionCombinerModule")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("73c166d2-c9d8-4ab8-af4e-89c41b4b58a9")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 190fca0..905540d 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs | |||
@@ -719,21 +719,21 @@ namespace OpenSim.Region.RegionCombinerModule | |||
719 | rootConn.ClientEventForwarder = new RegionCombinerClientEventForwarder(rootConn); | 719 | rootConn.ClientEventForwarder = new RegionCombinerClientEventForwarder(rootConn); |
720 | 720 | ||
721 | // Sets up the CoarseLocationUpdate forwarder for this root region | 721 | // Sets up the CoarseLocationUpdate forwarder for this root region |
722 | scene.EventManager.OnNewPresence += SetCourseLocationDelegate; | 722 | scene.EventManager.OnNewPresence += SetCoarseLocationDelegate; |
723 | 723 | ||
724 | // Adds this root region to a dictionary of regions that are connectable | 724 | // Adds this root region to a dictionary of regions that are connectable |
725 | m_regions.Add(scene.RegionInfo.originRegionID, rootConn); | 725 | m_regions.Add(scene.RegionInfo.originRegionID, rootConn); |
726 | } | 726 | } |
727 | } | 727 | } |
728 | 728 | ||
729 | private void SetCourseLocationDelegate(ScenePresence presence) | 729 | private void SetCoarseLocationDelegate(ScenePresence presence) |
730 | { | 730 | { |
731 | presence.SetSendCourseLocationMethod(SendCourseLocationUpdates); | 731 | presence.SetSendCoarseLocationMethod(SendCoarseLocationUpdates); |
732 | } | 732 | } |
733 | 733 | ||
734 | // This delegate was refactored for non-combined regions. | 734 | // This delegate was refactored for non-combined regions. |
735 | // This combined region version will not use the pre-compiled lists of locations and ids | 735 | // This combined region version will not use the pre-compiled lists of locations and ids |
736 | private void SendCourseLocationUpdates(UUID sceneId, ScenePresence presence, List<Vector3> coarseLocations, List<UUID> avatarUUIDs) | 736 | private void SendCoarseLocationUpdates(UUID sceneId, ScenePresence presence, List<Vector3> coarseLocations, List<UUID> avatarUUIDs) |
737 | { | 737 | { |
738 | RegionConnections connectiondata = null; | 738 | RegionConnections connectiondata = null; |
739 | lock (m_regions) | 739 | lock (m_regions) |
@@ -756,18 +756,18 @@ namespace OpenSim.Region.RegionCombinerModule | |||
756 | } | 756 | } |
757 | }); | 757 | }); |
758 | 758 | ||
759 | DistributeCourseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence); | 759 | DistributeCoarseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence); |
760 | } | 760 | } |
761 | 761 | ||
762 | private void DistributeCourseLocationUpdates(List<Vector3> locations, List<UUID> uuids, | 762 | private void DistributeCoarseLocationUpdates(List<Vector3> locations, List<UUID> uuids, |
763 | RegionConnections connectiondata, ScenePresence rootPresence) | 763 | RegionConnections connectiondata, ScenePresence rootPresence) |
764 | { | 764 | { |
765 | RegionData[] rdata = connectiondata.ConnectedRegions.ToArray(); | 765 | RegionData[] rdata = connectiondata.ConnectedRegions.ToArray(); |
766 | //List<IClientAPI> clients = new List<IClientAPI>(); | 766 | //List<IClientAPI> clients = new List<IClientAPI>(); |
767 | Dictionary<Vector2, RegionCourseLocationStruct> updates = new Dictionary<Vector2, RegionCourseLocationStruct>(); | 767 | Dictionary<Vector2, RegionCoarseLocationStruct> updates = new Dictionary<Vector2, RegionCoarseLocationStruct>(); |
768 | 768 | ||
769 | // Root Region entry | 769 | // Root Region entry |
770 | RegionCourseLocationStruct rootupdatedata = new RegionCourseLocationStruct(); | 770 | RegionCoarseLocationStruct rootupdatedata = new RegionCoarseLocationStruct(); |
771 | rootupdatedata.Locations = new List<Vector3>(); | 771 | rootupdatedata.Locations = new List<Vector3>(); |
772 | rootupdatedata.Uuids = new List<UUID>(); | 772 | rootupdatedata.Uuids = new List<UUID>(); |
773 | rootupdatedata.Offset = Vector2.Zero; | 773 | rootupdatedata.Offset = Vector2.Zero; |
@@ -781,7 +781,7 @@ namespace OpenSim.Region.RegionCombinerModule | |||
781 | foreach (RegionData regiondata in rdata) | 781 | foreach (RegionData regiondata in rdata) |
782 | { | 782 | { |
783 | Vector2 offset = new Vector2(regiondata.Offset.X, regiondata.Offset.Y); | 783 | Vector2 offset = new Vector2(regiondata.Offset.X, regiondata.Offset.Y); |
784 | RegionCourseLocationStruct updatedata = new RegionCourseLocationStruct(); | 784 | RegionCoarseLocationStruct updatedata = new RegionCoarseLocationStruct(); |
785 | updatedata.Locations = new List<Vector3>(); | 785 | updatedata.Locations = new List<Vector3>(); |
786 | updatedata.Uuids = new List<UUID>(); | 786 | updatedata.Uuids = new List<UUID>(); |
787 | updatedata.Offset = offset; | 787 | updatedata.Offset = offset; |
@@ -807,7 +807,7 @@ namespace OpenSim.Region.RegionCombinerModule | |||
807 | if (!updates.ContainsKey(offset)) | 807 | if (!updates.ContainsKey(offset)) |
808 | { | 808 | { |
809 | // This shouldn't happen | 809 | // This shouldn't happen |
810 | RegionCourseLocationStruct updatedata = new RegionCourseLocationStruct(); | 810 | RegionCoarseLocationStruct updatedata = new RegionCoarseLocationStruct(); |
811 | updatedata.Locations = new List<Vector3>(); | 811 | updatedata.Locations = new List<Vector3>(); |
812 | updatedata.Uuids = new List<UUID>(); | 812 | updatedata.Uuids = new List<UUID>(); |
813 | updatedata.Offset = offset; | 813 | updatedata.Offset = offset; |
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs b/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs index 53a678f..224ac99 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCourseLocation.cs | |||
@@ -33,7 +33,7 @@ using OpenSim.Framework; | |||
33 | namespace OpenSim.Region.RegionCombinerModule | 33 | namespace OpenSim.Region.RegionCombinerModule |
34 | { | 34 | { |
35 | 35 | ||
36 | struct RegionCourseLocationStruct | 36 | struct RegionCoarseLocationStruct |
37 | { | 37 | { |
38 | public List<Vector3> Locations; | 38 | public List<Vector3> Locations; |
39 | public List<UUID> Uuids; | 39 | public List<UUID> Uuids; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index cf801ba..acf4d8c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -107,6 +107,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
107 | protected IUrlModule m_UrlModule = null; | 107 | protected IUrlModule m_UrlModule = null; |
108 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = new Dictionary<UUID, UserInfoCacheEntry>(); | 108 | protected Dictionary<UUID, UserInfoCacheEntry> m_userInfoCache = new Dictionary<UUID, UserInfoCacheEntry>(); |
109 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. | 109 | protected int EMAIL_PAUSE_TIME = 20; // documented delay value for smtp. |
110 | protected ISoundModule m_SoundModule = null; | ||
110 | 111 | ||
111 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) | 112 | public void Initialize(IScriptEngine ScriptEngine, SceneObjectPart host, TaskInventoryItem item) |
112 | { | 113 | { |
@@ -119,6 +120,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
119 | m_TransferModule = | 120 | m_TransferModule = |
120 | m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); | 121 | m_ScriptEngine.World.RequestModuleInterface<IMessageTransferModule>(); |
121 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); | 122 | m_UrlModule = m_ScriptEngine.World.RequestModuleInterface<IUrlModule>(); |
123 | m_SoundModule = m_ScriptEngine.World.RequestModuleInterface<ISoundModule>(); | ||
122 | 124 | ||
123 | AsyncCommands = new AsyncCommandManager(ScriptEngine); | 125 | AsyncCommands = new AsyncCommandManager(ScriptEngine); |
124 | } | 126 | } |
@@ -331,6 +333,42 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
331 | return key; | 333 | return key; |
332 | } | 334 | } |
333 | 335 | ||
336 | /// <summary> | ||
337 | /// Return the UUID of the asset matching the specified key or name | ||
338 | /// and asset type. | ||
339 | /// </summary> | ||
340 | /// <param name="k"></param> | ||
341 | /// <param name="type"></param> | ||
342 | /// <returns></returns> | ||
343 | protected UUID KeyOrName(string k, AssetType type) | ||
344 | { | ||
345 | UUID key; | ||
346 | |||
347 | if (!UUID.TryParse(k, out key)) | ||
348 | { | ||
349 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(k); | ||
350 | if (item != null && item.Type == (int)type) | ||
351 | key = item.AssetID; | ||
352 | } | ||
353 | else | ||
354 | { | ||
355 | lock (m_host.TaskInventory) | ||
356 | { | ||
357 | foreach (KeyValuePair<UUID, TaskInventoryItem> item in m_host.TaskInventory) | ||
358 | { | ||
359 | if (item.Value.Type == (int)type && item.Value.Name == k) | ||
360 | { | ||
361 | key = item.Value.ItemID; | ||
362 | break; | ||
363 | } | ||
364 | } | ||
365 | } | ||
366 | } | ||
367 | |||
368 | |||
369 | return key; | ||
370 | } | ||
371 | |||
334 | //These are the implementations of the various ll-functions used by the LSL scripts. | 372 | //These are the implementations of the various ll-functions used by the LSL scripts. |
335 | public LSL_Float llSin(double f) | 373 | public LSL_Float llSin(double f) |
336 | { | 374 | { |
@@ -2044,8 +2082,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2044 | public LSL_Vector llGetPos() | 2082 | public LSL_Vector llGetPos() |
2045 | { | 2083 | { |
2046 | m_host.AddScriptLPS(1); | 2084 | m_host.AddScriptLPS(1); |
2047 | Vector3 pos = m_host.GetWorldPosition(); | 2085 | return m_host.GetWorldPosition(); |
2048 | return new LSL_Vector(pos.X, pos.Y, pos.Z); | ||
2049 | } | 2086 | } |
2050 | 2087 | ||
2051 | public LSL_Vector llGetLocalPos() | 2088 | public LSL_Vector llGetLocalPos() |
@@ -2365,63 +2402,32 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2365 | m_host.AddScriptLPS(1); | 2402 | m_host.AddScriptLPS(1); |
2366 | 2403 | ||
2367 | // send the sound, once, to all clients in range | 2404 | // send the sound, once, to all clients in range |
2368 | m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, false, false); | 2405 | if (m_SoundModule != null) |
2406 | { | ||
2407 | m_SoundModule.SendSound(m_host.UUID, | ||
2408 | KeyOrName(sound, AssetType.Sound), volume, false, 0, | ||
2409 | 0, false, false); | ||
2410 | } | ||
2369 | } | 2411 | } |
2370 | 2412 | ||
2371 | // Xantor 20080528 we should do this differently. | ||
2372 | // 1) apply the sound to the object | ||
2373 | // 2) schedule full update | ||
2374 | // just sending the sound out once doesn't work so well when other avatars come in view later on | ||
2375 | // or when the prim gets moved, changed, sat on, whatever | ||
2376 | // see large number of mantises (mantes?) | ||
2377 | // 20080530 Updated to remove code duplication | ||
2378 | // 20080530 Stop sound if there is one, otherwise volume only changes don't work | ||
2379 | public void llLoopSound(string sound, double volume) | 2413 | public void llLoopSound(string sound, double volume) |
2380 | { | 2414 | { |
2381 | m_host.AddScriptLPS(1); | 2415 | m_host.AddScriptLPS(1); |
2382 | 2416 | if (m_SoundModule != null) | |
2383 | if (m_host.Sound != UUID.Zero) | 2417 | { |
2384 | llStopSound(); | 2418 | m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound), |
2385 | 2419 | volume, 20, false); | |
2386 | m_host.Sound = KeyOrName(sound); | 2420 | } |
2387 | m_host.SoundGain = volume; | ||
2388 | m_host.SoundFlags = 1; // looping | ||
2389 | m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? | ||
2390 | |||
2391 | m_host.ScheduleFullUpdate(); | ||
2392 | m_host.SendFullUpdateToAllClients(); | ||
2393 | } | 2421 | } |
2394 | 2422 | ||
2395 | public void llLoopSoundMaster(string sound, double volume) | 2423 | public void llLoopSoundMaster(string sound, double volume) |
2396 | { | 2424 | { |
2397 | m_host.AddScriptLPS(1); | 2425 | m_host.AddScriptLPS(1); |
2398 | m_host.ParentGroup.LoopSoundMasterPrim = m_host; | 2426 | if (m_SoundModule != null) |
2399 | lock (m_host.ParentGroup.LoopSoundSlavePrims) | ||
2400 | { | 2427 | { |
2401 | foreach (SceneObjectPart prim in m_host.ParentGroup.LoopSoundSlavePrims) | 2428 | m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound), |
2402 | { | 2429 | volume, 20, true); |
2403 | if (prim.Sound != UUID.Zero) | ||
2404 | llStopSound(); | ||
2405 | |||
2406 | prim.Sound = KeyOrName(sound); | ||
2407 | prim.SoundGain = volume; | ||
2408 | prim.SoundFlags = 1; // looping | ||
2409 | prim.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? | ||
2410 | |||
2411 | prim.ScheduleFullUpdate(); | ||
2412 | prim.SendFullUpdateToAllClients(); | ||
2413 | } | ||
2414 | } | 2430 | } |
2415 | if (m_host.Sound != UUID.Zero) | ||
2416 | llStopSound(); | ||
2417 | |||
2418 | m_host.Sound = KeyOrName(sound); | ||
2419 | m_host.SoundGain = volume; | ||
2420 | m_host.SoundFlags = 1; // looping | ||
2421 | m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? | ||
2422 | |||
2423 | m_host.ScheduleFullUpdate(); | ||
2424 | m_host.SendFullUpdateToAllClients(); | ||
2425 | } | 2431 | } |
2426 | 2432 | ||
2427 | public void llLoopSoundSlave(string sound, double volume) | 2433 | public void llLoopSoundSlave(string sound, double volume) |
@@ -2438,61 +2444,39 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2438 | m_host.AddScriptLPS(1); | 2444 | m_host.AddScriptLPS(1); |
2439 | 2445 | ||
2440 | // send the sound, once, to all clients in range | 2446 | // send the sound, once, to all clients in range |
2441 | m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, true, false); | 2447 | if (m_SoundModule != null) |
2448 | { | ||
2449 | m_SoundModule.SendSound(m_host.UUID, | ||
2450 | KeyOrName(sound, AssetType.Sound), volume, false, 0, | ||
2451 | 0, true, false); | ||
2452 | } | ||
2442 | } | 2453 | } |
2443 | 2454 | ||
2444 | public void llTriggerSound(string sound, double volume) | 2455 | public void llTriggerSound(string sound, double volume) |
2445 | { | 2456 | { |
2446 | m_host.AddScriptLPS(1); | 2457 | m_host.AddScriptLPS(1); |
2447 | // send the sound, once, to all clients in range | 2458 | // send the sound, once, to all clients in rangeTrigger or play an attached sound in this part's inventory. |
2448 | m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0, 0, false, false); | 2459 | if (m_SoundModule != null) |
2460 | { | ||
2461 | m_SoundModule.SendSound(m_host.UUID, | ||
2462 | KeyOrName(sound, AssetType.Sound), volume, true, 0, 0, | ||
2463 | false, false); | ||
2464 | } | ||
2449 | } | 2465 | } |
2450 | 2466 | ||
2451 | // Xantor 20080528: Clear prim data of sound instead | ||
2452 | public void llStopSound() | 2467 | public void llStopSound() |
2453 | { | 2468 | { |
2454 | m_host.AddScriptLPS(1); | 2469 | m_host.AddScriptLPS(1); |
2455 | if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host)) | 2470 | |
2456 | { | 2471 | if (m_SoundModule != null) |
2457 | if (m_host.ParentGroup.LoopSoundMasterPrim == m_host) | 2472 | m_SoundModule.StopSound(m_host.UUID); |
2458 | { | ||
2459 | foreach (SceneObjectPart part in m_host.ParentGroup.LoopSoundSlavePrims) | ||
2460 | { | ||
2461 | part.Sound = UUID.Zero; | ||
2462 | part.SoundGain = 0; | ||
2463 | part.SoundFlags = 0; | ||
2464 | part.SoundRadius = 0; | ||
2465 | part.ScheduleFullUpdate(); | ||
2466 | part.SendFullUpdateToAllClients(); | ||
2467 | } | ||
2468 | m_host.ParentGroup.LoopSoundMasterPrim = null; | ||
2469 | m_host.ParentGroup.LoopSoundSlavePrims.Clear(); | ||
2470 | } | ||
2471 | else | ||
2472 | { | ||
2473 | m_host.Sound = UUID.Zero; | ||
2474 | m_host.SoundGain = 0; | ||
2475 | m_host.SoundFlags = 0; | ||
2476 | m_host.SoundRadius = 0; | ||
2477 | m_host.ScheduleFullUpdate(); | ||
2478 | m_host.SendFullUpdateToAllClients(); | ||
2479 | } | ||
2480 | } | ||
2481 | else | ||
2482 | { | ||
2483 | m_host.Sound = UUID.Zero; | ||
2484 | m_host.SoundGain = 0; | ||
2485 | m_host.SoundFlags = 0; | ||
2486 | m_host.SoundRadius = 0; | ||
2487 | m_host.ScheduleFullUpdate(); | ||
2488 | m_host.SendFullUpdateToAllClients(); | ||
2489 | } | ||
2490 | } | 2473 | } |
2491 | 2474 | ||
2492 | public void llPreloadSound(string sound) | 2475 | public void llPreloadSound(string sound) |
2493 | { | 2476 | { |
2494 | m_host.AddScriptLPS(1); | 2477 | m_host.AddScriptLPS(1); |
2495 | m_host.PreloadSound(sound); | 2478 | if (m_SoundModule != null) |
2479 | m_SoundModule.PreloadSound(m_host.UUID, KeyOrName(sound), 0); | ||
2496 | ScriptSleep(1000); | 2480 | ScriptSleep(1000); |
2497 | } | 2481 | } |
2498 | 2482 | ||
@@ -3979,17 +3963,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3979 | 3963 | ||
3980 | if (m_TransferModule != null) | 3964 | if (m_TransferModule != null) |
3981 | { | 3965 | { |
3982 | byte[] bucket = new byte[] { (byte)item.Type }; | 3966 | byte[] bucket = new byte[1]; |
3967 | bucket[0] = (byte)item.Type; | ||
3983 | 3968 | ||
3984 | GridInstantMessage msg = new GridInstantMessage(World, | 3969 | GridInstantMessage msg = new GridInstantMessage(World, |
3985 | m_host.UUID, m_host.Name + ", an object owned by " + | 3970 | m_host.OwnerID, m_host.Name, destId, |
3986 | resolveName(m_host.OwnerID) + ",", destId, | ||
3987 | (byte)InstantMessageDialog.TaskInventoryOffered, | 3971 | (byte)InstantMessageDialog.TaskInventoryOffered, |
3988 | false, item.Name + "\n" + m_host.Name + " is located at " + | 3972 | false, item.Name+". "+m_host.Name+" is located at "+ |
3989 | World.RegionInfo.RegionName+" "+ | 3973 | World.RegionInfo.RegionName+" "+ |
3990 | m_host.AbsolutePosition.ToString(), | 3974 | m_host.AbsolutePosition.ToString(), |
3991 | agentItem.ID, true, m_host.AbsolutePosition, | 3975 | agentItem.ID, true, m_host.AbsolutePosition, |
3992 | bucket, true); // TODO: May actually send no timestamp | 3976 | bucket, true); |
3993 | 3977 | ||
3994 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); | 3978 | m_TransferModule.SendInstantMessage(msg, delegate(bool success) {}); |
3995 | } | 3979 | } |
@@ -4358,16 +4342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4358 | m_host.AddScriptLPS(1); | 4342 | m_host.AddScriptLPS(1); |
4359 | 4343 | ||
4360 | // TODO: Parameter check logic required. | 4344 | // TODO: Parameter check logic required. |
4361 | UUID soundId = UUID.Zero; | 4345 | m_host.CollisionSound = KeyOrName(impact_sound, AssetType.Sound); |
4362 | if (!UUID.TryParse(impact_sound, out soundId)) | ||
4363 | { | ||
4364 | TaskInventoryItem item = m_host.Inventory.GetInventoryItem(impact_sound); | ||
4365 | |||
4366 | if (item != null && item.Type == (int)AssetType.Sound) | ||
4367 | soundId = item.AssetID; | ||
4368 | } | ||
4369 | |||
4370 | m_host.CollisionSound = soundId; | ||
4371 | m_host.CollisionSoundVolume = (float)impact_volume; | 4346 | m_host.CollisionSoundVolume = (float)impact_volume; |
4372 | } | 4347 | } |
4373 | 4348 | ||
@@ -4388,7 +4363,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
4388 | { | 4363 | { |
4389 | AnimationSet currentAnims = presence.Animator.Animations; | 4364 | AnimationSet currentAnims = presence.Animator.Animations; |
4390 | string currentAnimationState = String.Empty; | 4365 | string currentAnimationState = String.Empty; |
4391 | if (animationstateNames.TryGetValue(currentAnims.DefaultAnimation.AnimID, out currentAnimationState)) | 4366 | if (animationstateNames.TryGetValue(currentAnims.ImplicitDefaultAnimation.AnimID, out currentAnimationState)) |
4392 | return currentAnimationState; | 4367 | return currentAnimationState; |
4393 | } | 4368 | } |
4394 | } | 4369 | } |
@@ -5705,7 +5680,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5705 | flags |= ScriptBaseClass.AGENT_SITTING; | 5680 | flags |= ScriptBaseClass.AGENT_SITTING; |
5706 | } | 5681 | } |
5707 | 5682 | ||
5708 | if (agent.Animator.Animations.DefaultAnimation.AnimID | 5683 | if (agent.Animator.Animations.ImplicitDefaultAnimation.AnimID |
5709 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | 5684 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) |
5710 | { | 5685 | { |
5711 | flags |= ScriptBaseClass.AGENT_SITTING; | 5686 | flags |= ScriptBaseClass.AGENT_SITTING; |
@@ -5890,10 +5865,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
5890 | LSL_Vector bottom_south_west) | 5865 | LSL_Vector bottom_south_west) |
5891 | { | 5866 | { |
5892 | m_host.AddScriptLPS(1); | 5867 | m_host.AddScriptLPS(1); |
5893 | float radius1 = (float)llVecDist(llGetPos(), top_north_east); | 5868 | if (m_SoundModule != null) |
5894 | float radius2 = (float)llVecDist(llGetPos(), bottom_south_west); | 5869 | { |
5895 | float radius = Math.Abs(radius1 - radius2); | 5870 | m_SoundModule.TriggerSoundLimited(m_host.UUID, |
5896 | m_host.SendSound(KeyOrName(sound).ToString(), volume, true, 0, radius, false, false); | 5871 | KeyOrName(sound, AssetType.Sound), volume, |
5872 | bottom_south_west, top_north_east); | ||
5873 | } | ||
5897 | } | 5874 | } |
5898 | 5875 | ||
5899 | public void llEjectFromLand(string pest) | 5876 | public void llEjectFromLand(string pest) |
@@ -6660,6 +6637,36 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
6660 | m_host.SetCameraAtOffset(offset); | 6637 | m_host.SetCameraAtOffset(offset); |
6661 | } | 6638 | } |
6662 | 6639 | ||
6640 | public void llSetLinkCamera(LSL_Integer link, LSL_Vector eye, LSL_Vector at) | ||
6641 | { | ||
6642 | m_host.AddScriptLPS(1); | ||
6643 | |||
6644 | if (link == ScriptBaseClass.LINK_SET || | ||
6645 | link == ScriptBaseClass.LINK_ALL_CHILDREN || | ||
6646 | link == ScriptBaseClass.LINK_ALL_OTHERS) return; | ||
6647 | |||
6648 | SceneObjectPart part = null; | ||
6649 | |||
6650 | switch (link) | ||
6651 | { | ||
6652 | case ScriptBaseClass.LINK_ROOT: | ||
6653 | part = m_host.ParentGroup.RootPart; | ||
6654 | break; | ||
6655 | case ScriptBaseClass.LINK_THIS: | ||
6656 | part = m_host; | ||
6657 | break; | ||
6658 | default: | ||
6659 | part = m_host.ParentGroup.GetLinkNumPart(link); | ||
6660 | break; | ||
6661 | } | ||
6662 | |||
6663 | if (null != part) | ||
6664 | { | ||
6665 | part.SetCameraEyeOffset(eye); | ||
6666 | part.SetCameraAtOffset(at); | ||
6667 | } | ||
6668 | } | ||
6669 | |||
6663 | public LSL_String llDumpList2String(LSL_List src, string seperator) | 6670 | public LSL_String llDumpList2String(LSL_List src, string seperator) |
6664 | { | 6671 | { |
6665 | m_host.AddScriptLPS(1); | 6672 | m_host.AddScriptLPS(1); |
@@ -7892,7 +7899,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7892 | { | 7899 | { |
7893 | LSL_Vector lower; | 7900 | LSL_Vector lower; |
7894 | LSL_Vector upper; | 7901 | LSL_Vector upper; |
7895 | if (presence.Animator.Animations.DefaultAnimation.AnimID | 7902 | if (presence.Animator.Animations.ImplicitDefaultAnimation.AnimID |
7896 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) | 7903 | == DefaultAvatarAnimations.AnimsUUID["SIT_GROUND_CONSTRAINED"]) |
7897 | { | 7904 | { |
7898 | // This is for ground sitting avatars | 7905 | // This is for ground sitting avatars |
@@ -10685,12 +10692,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
10685 | 10692 | ||
10686 | internal void Deprecated(string command) | 10693 | internal void Deprecated(string command) |
10687 | { | 10694 | { |
10688 | throw new Exception("Command deprecated: " + command); | 10695 | throw new ScriptException("Command deprecated: " + command); |
10689 | } | 10696 | } |
10690 | 10697 | ||
10691 | internal void LSLError(string msg) | 10698 | internal void LSLError(string msg) |
10692 | { | 10699 | { |
10693 | throw new Exception("LSL Runtime Error: " + msg); | 10700 | throw new ScriptException("LSL Runtime Error: " + msg); |
10694 | } | 10701 | } |
10695 | 10702 | ||
10696 | public delegate void AssetRequestCallback(UUID assetID, AssetBase asset); | 10703 | public delegate void AssetRequestCallback(UUID assetID, AssetBase asset); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 6809c09..8f34833 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |||
@@ -95,13 +95,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
95 | 95 | ||
96 | internal void MODError(string msg) | 96 | internal void MODError(string msg) |
97 | { | 97 | { |
98 | throw new Exception("MOD Runtime Error: " + msg); | 98 | throw new ScriptException("MOD Runtime Error: " + msg); |
99 | } | 99 | } |
100 | 100 | ||
101 | // | 101 | /// <summary> |
102 | //Dumps an error message on the debug console. | 102 | /// Dumps an error message on the debug console. |
103 | // | 103 | /// </summary> |
104 | 104 | /// <param name='message'></param> | |
105 | internal void MODShoutError(string message) | 105 | internal void MODShoutError(string message) |
106 | { | 106 | { |
107 | if (message.Length > 1023) | 107 | if (message.Length > 1023) |
@@ -359,20 +359,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
359 | result[i] = (string)(LSL_String)plist[i]; | 359 | result[i] = (string)(LSL_String)plist[i]; |
360 | else if (plist[i] is LSL_Integer) | 360 | else if (plist[i] is LSL_Integer) |
361 | result[i] = (int)(LSL_Integer)plist[i]; | 361 | result[i] = (int)(LSL_Integer)plist[i]; |
362 | // The int check exists because of the many plain old int script constants in ScriptBase which | ||
363 | // are not LSL_Integers. | ||
364 | else if (plist[i] is int) | ||
365 | result[i] = plist[i]; | ||
362 | else if (plist[i] is LSL_Float) | 366 | else if (plist[i] is LSL_Float) |
363 | result[i] = (float)(LSL_Float)plist[i]; | 367 | result[i] = (float)(LSL_Float)plist[i]; |
364 | else if (plist[i] is LSL_Key) | 368 | else if (plist[i] is LSL_Key) |
365 | result[i] = new UUID((LSL_Key)plist[i]); | 369 | result[i] = new UUID((LSL_Key)plist[i]); |
366 | else if (plist[i] is LSL_Rotation) | 370 | else if (plist[i] is LSL_Rotation) |
367 | { | 371 | result[i] = (Quaternion)((LSL_Rotation)plist[i]); |
368 | result[i] = (OpenMetaverse.Quaternion)( | ||
369 | (LSL_Rotation)plist[i]); | ||
370 | } | ||
371 | else if (plist[i] is LSL_Vector) | 372 | else if (plist[i] is LSL_Vector) |
372 | { | 373 | result[i] = (Vector3)((LSL_Vector)plist[i]); |
373 | result[i] = (OpenMetaverse.Vector3)( | ||
374 | (LSL_Vector)plist[i]); | ||
375 | } | ||
376 | else | 374 | else |
377 | MODError(String.Format("{0}: unknown LSL list element type", fname)); | 375 | MODError(String.Format("{0}: unknown LSL list element type", fname)); |
378 | } | 376 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 29bc163..828288d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -210,7 +210,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
210 | 210 | ||
211 | internal void OSSLError(string msg) | 211 | internal void OSSLError(string msg) |
212 | { | 212 | { |
213 | throw new Exception("OSSL Runtime Error: " + msg); | 213 | throw new ScriptException("OSSL Runtime Error: " + msg); |
214 | } | 214 | } |
215 | 215 | ||
216 | /// <summary> | 216 | /// <summary> |
@@ -1780,18 +1780,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1780 | protected string LoadNotecard(string notecardNameOrUuid) | 1780 | protected string LoadNotecard(string notecardNameOrUuid) |
1781 | { | 1781 | { |
1782 | UUID assetID = CacheNotecard(notecardNameOrUuid); | 1782 | UUID assetID = CacheNotecard(notecardNameOrUuid); |
1783 | StringBuilder notecardData = new StringBuilder(); | ||
1784 | 1783 | ||
1785 | for (int count = 0; count < NotecardCache.GetLines(assetID); count++) | 1784 | if (assetID != UUID.Zero) |
1786 | { | 1785 | { |
1787 | string line = NotecardCache.GetLine(assetID, count) + "\n"; | 1786 | StringBuilder notecardData = new StringBuilder(); |
1788 | 1787 | ||
1789 | // m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line); | 1788 | for (int count = 0; count < NotecardCache.GetLines(assetID); count++) |
1790 | 1789 | { | |
1791 | notecardData.Append(line); | 1790 | string line = NotecardCache.GetLine(assetID, count) + "\n"; |
1791 | |||
1792 | // m_log.DebugFormat("[OSSL]: From notecard {0} loading line {1}", notecardNameOrUuid, line); | ||
1793 | |||
1794 | notecardData.Append(line); | ||
1795 | } | ||
1796 | |||
1797 | return notecardData.ToString(); | ||
1792 | } | 1798 | } |
1793 | 1799 | ||
1794 | return notecardData.ToString(); | 1800 | return null; |
1795 | } | 1801 | } |
1796 | 1802 | ||
1797 | /// <summary> | 1803 | /// <summary> |
@@ -2340,11 +2346,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2340 | appearance = new AvatarAppearance(); | 2346 | appearance = new AvatarAppearance(); |
2341 | appearance.Unpack(appearanceOsd); | 2347 | appearance.Unpack(appearanceOsd); |
2342 | } | 2348 | } |
2349 | else | ||
2350 | { | ||
2351 | OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard)); | ||
2352 | } | ||
2343 | } | 2353 | } |
2344 | 2354 | ||
2345 | if (appearance == null) | ||
2346 | return new LSL_Key(UUID.Zero.ToString()); | ||
2347 | |||
2348 | UUID ownerID = UUID.Zero; | 2355 | UUID ownerID = UUID.Zero; |
2349 | if (owned) | 2356 | if (owned) |
2350 | ownerID = m_host.OwnerID; | 2357 | ownerID = m_host.OwnerID; |
@@ -2407,6 +2414,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
2407 | return; | 2414 | return; |
2408 | 2415 | ||
2409 | string appearanceSerialized = LoadNotecard(notecard); | 2416 | string appearanceSerialized = LoadNotecard(notecard); |
2417 | |||
2418 | if (appearanceSerialized == null) | ||
2419 | OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard)); | ||
2420 | |||
2410 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); | 2421 | OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized); |
2411 | // OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized); | 2422 | // OSD a = OSDParser.DeserializeLLSDXml(appearanceSerialized); |
2412 | // Console.WriteLine("appearanceSerialized {0}", appearanceSerialized); | 2423 | // Console.WriteLine("appearanceSerialized {0}", appearanceSerialized); |
@@ -3636,5 +3647,68 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3636 | 3647 | ||
3637 | DropAttachmentAt(false, pos, rot); | 3648 | DropAttachmentAt(false, pos, rot); |
3638 | } | 3649 | } |
3650 | |||
3651 | public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield) | ||
3652 | { | ||
3653 | CheckThreatLevel(ThreatLevel.Low, "osListenRegex"); | ||
3654 | m_host.AddScriptLPS(1); | ||
3655 | UUID keyID; | ||
3656 | UUID.TryParse(ID, out keyID); | ||
3657 | |||
3658 | // if we want the name to be used as a regular expression, ensure it is valid first. | ||
3659 | if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_NAME) == ScriptBaseClass.OS_LISTEN_REGEX_NAME) | ||
3660 | { | ||
3661 | try | ||
3662 | { | ||
3663 | Regex.IsMatch("", name); | ||
3664 | } | ||
3665 | catch (Exception) | ||
3666 | { | ||
3667 | OSSLShoutError("Name regex is invalid."); | ||
3668 | return -1; | ||
3669 | } | ||
3670 | } | ||
3671 | |||
3672 | // if we want the msg to be used as a regular expression, ensure it is valid first. | ||
3673 | if ((regexBitfield & ScriptBaseClass.OS_LISTEN_REGEX_MESSAGE) == ScriptBaseClass.OS_LISTEN_REGEX_MESSAGE) | ||
3674 | { | ||
3675 | try | ||
3676 | { | ||
3677 | Regex.IsMatch("", msg); | ||
3678 | } | ||
3679 | catch (Exception) | ||
3680 | { | ||
3681 | OSSLShoutError("Message regex is invalid."); | ||
3682 | return -1; | ||
3683 | } | ||
3684 | } | ||
3685 | |||
3686 | IWorldComm wComm = m_ScriptEngine.World.RequestModuleInterface<IWorldComm>(); | ||
3687 | return (wComm == null) ? -1 : wComm.Listen( | ||
3688 | m_host.LocalId, | ||
3689 | m_item.ItemID, | ||
3690 | m_host.UUID, | ||
3691 | channelID, | ||
3692 | name, | ||
3693 | keyID, | ||
3694 | msg, | ||
3695 | regexBitfield | ||
3696 | ); | ||
3697 | } | ||
3698 | |||
3699 | public LSL_Integer osRegexIsMatch(string input, string pattern) | ||
3700 | { | ||
3701 | CheckThreatLevel(ThreatLevel.Low, "osRegexIsMatch"); | ||
3702 | m_host.AddScriptLPS(1); | ||
3703 | try | ||
3704 | { | ||
3705 | return Regex.IsMatch(input, pattern) ? 1 : 0; | ||
3706 | } | ||
3707 | catch (Exception) | ||
3708 | { | ||
3709 | OSSLShoutError("Possible invalid regular expression detected."); | ||
3710 | return 0; | ||
3711 | } | ||
3712 | } | ||
3639 | } | 3713 | } |
3640 | } \ No newline at end of file | 3714 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d173db0 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.Shared.Api")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("369ed06e-a3ca-40f0-98e3-3cd3ec1443c3")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs index e97ff9d..98f8be7 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/ILSL_Api.cs | |||
@@ -333,6 +333,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
333 | void llSetBuoyancy(double buoyancy); | 333 | void llSetBuoyancy(double buoyancy); |
334 | void llSetCameraAtOffset(LSL_Vector offset); | 334 | void llSetCameraAtOffset(LSL_Vector offset); |
335 | void llSetCameraEyeOffset(LSL_Vector offset); | 335 | void llSetCameraEyeOffset(LSL_Vector offset); |
336 | void llSetLinkCamera(LSL_Integer link, LSL_Vector eye, LSL_Vector at); | ||
336 | void llSetCameraParams(LSL_List rules); | 337 | void llSetCameraParams(LSL_List rules); |
337 | void llSetClickAction(int action); | 338 | void llSetClickAction(int action); |
338 | void llSetColor(LSL_Vector color, int face); | 339 | void llSetColor(LSL_Vector color, int face); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 93188c9..cdd9ea8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -418,5 +418,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
418 | /// <param name="pos"></param> | 418 | /// <param name="pos"></param> |
419 | /// <param name="rot"></param> | 419 | /// <param name="rot"></param> |
420 | void osForceDropAttachmentAt(vector pos, rotation rot); | 420 | void osForceDropAttachmentAt(vector pos, rotation rot); |
421 | |||
422 | /// <summary> | ||
423 | /// Identical to llListen except for a bitfield which indicates which | ||
424 | /// string parameters should be parsed as regex patterns. | ||
425 | /// </summary> | ||
426 | /// <param name="channelID"></param> | ||
427 | /// <param name="name"></param> | ||
428 | /// <param name="ID"></param> | ||
429 | /// <param name="msg"></param> | ||
430 | /// <param name="regexBitfield"> | ||
431 | /// OS_LISTEN_REGEX_NAME | ||
432 | /// OS_LISTEN_REGEX_MESSAGE | ||
433 | /// </param> | ||
434 | /// <returns></returns> | ||
435 | LSL_Integer osListenRegex(int channelID, string name, string ID, | ||
436 | string msg, int regexBitfield); | ||
437 | |||
438 | /// <summary> | ||
439 | /// Wraps to bool Regex.IsMatch(string input, string pattern) | ||
440 | /// </summary> | ||
441 | /// <param name="input">string to test for match</param> | ||
442 | /// <param name="regex">string to use as pattern</param> | ||
443 | /// <returns>boolean</returns> | ||
444 | LSL_Integer osRegexIsMatch(string input, string pattern); | ||
421 | } | 445 | } |
422 | } | 446 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 62bd6b8..880841b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -716,5 +716,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
716 | public static readonly LSLInteger RCERR_UNKNOWN = -1; | 716 | public static readonly LSLInteger RCERR_UNKNOWN = -1; |
717 | public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2; | 717 | public static readonly LSLInteger RCERR_SIM_PERF_LOW = -2; |
718 | public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 3; | 718 | public static readonly LSLInteger RCERR_CAST_TIME_EXCEEDED = 3; |
719 | |||
720 | /// <summary> | ||
721 | /// process name parameter as regex | ||
722 | /// </summary> | ||
723 | public const int OS_LISTEN_REGEX_NAME = 0x1; | ||
724 | |||
725 | /// <summary> | ||
726 | /// process message parameter as regex | ||
727 | /// </summary> | ||
728 | public const int OS_LISTEN_REGEX_MESSAGE = 0x2; | ||
719 | } | 729 | } |
720 | } | 730 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs index c457880..36803a4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Stub.cs | |||
@@ -1498,6 +1498,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
1498 | m_LSL_Functions.llSetCameraEyeOffset(offset); | 1498 | m_LSL_Functions.llSetCameraEyeOffset(offset); |
1499 | } | 1499 | } |
1500 | 1500 | ||
1501 | public void llSetLinkCamera(LSL_Integer link, LSL_Vector eye, LSL_Vector at) | ||
1502 | { | ||
1503 | m_LSL_Functions.llSetLinkCamera(link, eye, at); | ||
1504 | } | ||
1505 | |||
1501 | public void llSetCameraParams(LSL_List rules) | 1506 | public void llSetCameraParams(LSL_List rules) |
1502 | { | 1507 | { |
1503 | m_LSL_Functions.llSetCameraParams(rules); | 1508 | m_LSL_Functions.llSetCameraParams(rules); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index dee1b28..afa9ae0 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -992,5 +992,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
992 | { | 992 | { |
993 | m_OSSL_Functions.osForceDropAttachmentAt(pos, rot); | 993 | m_OSSL_Functions.osForceDropAttachmentAt(pos, rot); |
994 | } | 994 | } |
995 | |||
996 | public LSL_Integer osListenRegex(int channelID, string name, string ID, string msg, int regexBitfield) | ||
997 | { | ||
998 | return m_OSSL_Functions.osListenRegex(channelID, name, ID, msg, regexBitfield); | ||
999 | } | ||
1000 | |||
1001 | public LSL_Integer osRegexIsMatch(string input, string pattern) | ||
1002 | { | ||
1003 | return m_OSSL_Functions.osRegexIsMatch(input, pattern); | ||
1004 | } | ||
995 | } | 1005 | } |
996 | } | 1006 | } |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..573a803 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.Shared.Api.Runtime")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("ac60ce7e-7c35-4431-b294-fe6ca26b5b50")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f6d5d41 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/YieldProlog/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.Shared.YieldProlog")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("8df98e6b-0425-44d6-8d91-2b3b4c56acdf")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..c65caa8 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.Shared.CodeTools")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("fd446fb3-3a21-471b-951c-68b9eb6ef8e5")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs index 7763619..77e087c 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs | |||
@@ -39,7 +39,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests | |||
39 | /// The generated C# code is compared against the expected C# code. | 39 | /// The generated C# code is compared against the expected C# code. |
40 | /// </summary> | 40 | /// </summary> |
41 | [TestFixture] | 41 | [TestFixture] |
42 | public class CSCodeGeneratorTest | 42 | public class CSCodeGeneratorTest : OpenSimTestCase |
43 | { | 43 | { |
44 | [Test] | 44 | [Test] |
45 | public void TestDefaultState() | 45 | public void TestDefaultState() |
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs index 1fa6954..05a8756 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs | |||
@@ -41,7 +41,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests | |||
41 | /// the LSL source. | 41 | /// the LSL source. |
42 | /// </summary> | 42 | /// </summary> |
43 | [TestFixture] | 43 | [TestFixture] |
44 | public class CompilerTest | 44 | public class CompilerTest : OpenSimTestCase |
45 | { | 45 | { |
46 | private string m_testDir; | 46 | private string m_testDir; |
47 | private CSharpCodeProvider m_CSCodeProvider; | 47 | private CSharpCodeProvider m_CSCodeProvider; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..470e1a1 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.Shared.Instance")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("b776d846-68c1-43a2-9e72-9bd1fe20fd41")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/Shared/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e6e8777 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.Shared")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("5fe331de-bc53-4ca7-b080-2a5a5ce2d380")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs b/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs new file mode 100644 index 0000000..f55ba7e --- /dev/null +++ b/OpenSim/Region/ScriptEngine/Shared/ScriptException.cs | |||
@@ -0,0 +1,44 @@ | |||
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.Runtime.Serialization; | ||
30 | |||
31 | namespace OpenSim.Region.ScriptEngine.Shared | ||
32 | { | ||
33 | [Serializable] | ||
34 | public class ScriptException : Exception | ||
35 | { | ||
36 | public ScriptException() : base() {} | ||
37 | |||
38 | public ScriptException(string message) : base(message) {} | ||
39 | |||
40 | public ScriptException(string message, Exception innerException) : base(message, innerException) {} | ||
41 | |||
42 | public ScriptException(SerializationInfo info, StreamingContext context) :base(info, context) {} | ||
43 | } | ||
44 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs index c73e22f..2c9d9e8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiInventoryTests.cs | |||
@@ -51,7 +51,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
51 | /// Tests for inventory functions in LSL | 51 | /// Tests for inventory functions in LSL |
52 | /// </summary> | 52 | /// </summary> |
53 | [TestFixture] | 53 | [TestFixture] |
54 | public class LSL_ApiInventoryTests | 54 | public class LSL_ApiInventoryTests : OpenSimTestCase |
55 | { | 55 | { |
56 | protected Scene m_scene; | 56 | protected Scene m_scene; |
57 | protected XEngine.XEngine m_engine; | 57 | protected XEngine.XEngine m_engine; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs index 2565ae7..57f19b9 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiLinkingTests.cs | |||
@@ -56,7 +56,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
56 | /// OpenSim.Region.Framework.Scenes.Tests.SceneObjectLinkingTests. | 56 | /// OpenSim.Region.Framework.Scenes.Tests.SceneObjectLinkingTests. |
57 | /// </remarks> | 57 | /// </remarks> |
58 | [TestFixture] | 58 | [TestFixture] |
59 | public class LSL_ApiLinkingTests | 59 | public class LSL_ApiLinkingTests : OpenSimTestCase |
60 | { | 60 | { |
61 | protected Scene m_scene; | 61 | protected Scene m_scene; |
62 | protected XEngine.XEngine m_engine; | 62 | protected XEngine.XEngine m_engine; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs index dd23be8..182b07b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiListTests.cs | |||
@@ -46,7 +46,7 @@ using LSL_String = OpenSim.Region.ScriptEngine.Shared.LSL_Types.LSLString; | |||
46 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | 46 | namespace OpenSim.Region.ScriptEngine.Shared.Tests |
47 | { | 47 | { |
48 | [TestFixture] | 48 | [TestFixture] |
49 | public class LSL_ApiListTests | 49 | public class LSL_ApiListTests : OpenSimTestCase |
50 | { | 50 | { |
51 | private LSL_Api m_lslApi; | 51 | private LSL_Api m_lslApi; |
52 | 52 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs index 3ed2562..c8c7f82 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLFloat.cs | |||
@@ -33,7 +33,7 @@ using OpenSim.Region.ScriptEngine.Shared; | |||
33 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | 33 | namespace OpenSim.Region.ScriptEngine.Shared.Tests |
34 | { | 34 | { |
35 | [TestFixture] | 35 | [TestFixture] |
36 | public class LSL_TypesTestLSLFloat | 36 | public class LSL_TypesTestLSLFloat : OpenSimTestCase |
37 | { | 37 | { |
38 | // Used for testing equality of two floats. | 38 | // Used for testing equality of two floats. |
39 | private double _lowPrecisionTolerance = 0.000001; | 39 | private double _lowPrecisionTolerance = 0.000001; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs index 8d1169a..c664108 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLInteger.cs | |||
@@ -33,7 +33,7 @@ using OpenSim.Region.ScriptEngine.Shared; | |||
33 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | 33 | namespace OpenSim.Region.ScriptEngine.Shared.Tests |
34 | { | 34 | { |
35 | [TestFixture] | 35 | [TestFixture] |
36 | public class LSL_TypesTestLSLInteger | 36 | public class LSL_TypesTestLSLInteger : OpenSimTestCase |
37 | { | 37 | { |
38 | private Dictionary<double, int> m_doubleIntSet; | 38 | private Dictionary<double, int> m_doubleIntSet; |
39 | private Dictionary<string, int> m_stringIntSet; | 39 | private Dictionary<string, int> m_stringIntSet; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs index c4ca1a8..8550f2d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestLSLString.cs | |||
@@ -33,7 +33,7 @@ using OpenSim.Region.ScriptEngine.Shared; | |||
33 | namespace OpenSim.Region.ScriptEngine.Shared.Tests | 33 | namespace OpenSim.Region.ScriptEngine.Shared.Tests |
34 | { | 34 | { |
35 | [TestFixture] | 35 | [TestFixture] |
36 | public class LSL_TypesTestLSLString | 36 | public class LSL_TypesTestLSLString : OpenSimTestCase |
37 | { | 37 | { |
38 | private Dictionary<double, string> m_doubleStringSet; | 38 | private Dictionary<double, string> m_doubleStringSet; |
39 | 39 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs index b81225f..71b88bc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestList.cs | |||
@@ -36,7 +36,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
36 | /// Tests the LSL_Types.list class. | 36 | /// Tests the LSL_Types.list class. |
37 | /// </summary> | 37 | /// </summary> |
38 | [TestFixture] | 38 | [TestFixture] |
39 | public class LSL_TypesTestList | 39 | public class LSL_TypesTestList : OpenSimTestCase |
40 | { | 40 | { |
41 | /// <summary> | 41 | /// <summary> |
42 | /// Tests concatenating a string to a list. | 42 | /// Tests concatenating a string to a list. |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs index ebf8001..0c838af 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_TypesTestVector3.cs | |||
@@ -36,7 +36,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
36 | /// Tests for Vector3 | 36 | /// Tests for Vector3 |
37 | /// </summary> | 37 | /// </summary> |
38 | [TestFixture] | 38 | [TestFixture] |
39 | public class LSL_TypesTestVector3 | 39 | public class LSL_TypesTestVector3 : OpenSimTestCase |
40 | { | 40 | { |
41 | [Test] | 41 | [Test] |
42 | public void TestDotProduct() | 42 | public void TestDotProduct() |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs index c8718d9..213f33f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiAppearanceTest.cs | |||
@@ -51,7 +51,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
51 | /// Tests for OSSL_Api | 51 | /// Tests for OSSL_Api |
52 | /// </summary> | 52 | /// </summary> |
53 | [TestFixture] | 53 | [TestFixture] |
54 | public class OSSL_ApiAppearanceTest | 54 | public class OSSL_ApiAppearanceTest : OpenSimTestCase |
55 | { | 55 | { |
56 | protected Scene m_scene; | 56 | protected Scene m_scene; |
57 | protected XEngine.XEngine m_engine; | 57 | protected XEngine.XEngine m_engine; |
@@ -75,76 +75,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
75 | m_engine.AddRegion(m_scene); | 75 | m_engine.AddRegion(m_scene); |
76 | } | 76 | } |
77 | 77 | ||
78 | /// <summary> | ||
79 | /// Test creation of an NPC where the appearance data comes from a notecard | ||
80 | /// </summary> | ||
81 | [Test] | ||
82 | public void TestOsNpcCreateUsingAppearanceFromNotecard() | ||
83 | { | ||
84 | TestHelpers.InMethod(); | ||
85 | // log4net.Config.XmlConfigurator.Configure(); | ||
86 | |||
87 | // Store an avatar with a different height from default in a notecard. | ||
88 | UUID userId = TestHelpers.ParseTail(0x1); | ||
89 | float newHeight = 1.9f; | ||
90 | |||
91 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | ||
92 | sp.Appearance.AvatarHeight = newHeight; | ||
93 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); | ||
94 | SceneObjectPart part = so.RootPart; | ||
95 | m_scene.AddSceneObject(so); | ||
96 | |||
97 | OSSL_Api osslApi = new OSSL_Api(); | ||
98 | osslApi.Initialize(m_engine, part, null); | ||
99 | |||
100 | string notecardName = "appearanceNc"; | ||
101 | osslApi.osOwnerSaveAppearance(notecardName); | ||
102 | |||
103 | // Try creating a bot using the appearance in the notecard. | ||
104 | string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName); | ||
105 | Assert.That(npcRaw, Is.Not.Null); | ||
106 | |||
107 | UUID npcId = new UUID(npcRaw); | ||
108 | ScenePresence npc = m_scene.GetScenePresence(npcId); | ||
109 | Assert.That(npc, Is.Not.Null); | ||
110 | Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight)); | ||
111 | } | ||
112 | |||
113 | /// <summary> | ||
114 | /// Test creation of an NPC where the appearance data comes from an avatar already in the region. | ||
115 | /// </summary> | ||
116 | [Test] | ||
117 | public void TestOsNpcCreateUsingAppearanceFromAvatar() | ||
118 | { | ||
119 | TestHelpers.InMethod(); | ||
120 | // TestHelpers.EnableLogging(); | ||
121 | |||
122 | // Store an avatar with a different height from default in a notecard. | ||
123 | UUID userId = TestHelpers.ParseTail(0x1); | ||
124 | float newHeight = 1.9f; | ||
125 | |||
126 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | ||
127 | sp.Appearance.AvatarHeight = newHeight; | ||
128 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); | ||
129 | SceneObjectPart part = so.RootPart; | ||
130 | m_scene.AddSceneObject(so); | ||
131 | |||
132 | OSSL_Api osslApi = new OSSL_Api(); | ||
133 | osslApi.Initialize(m_engine, part, null); | ||
134 | |||
135 | string notecardName = "appearanceNc"; | ||
136 | osslApi.osOwnerSaveAppearance(notecardName); | ||
137 | |||
138 | // Try creating a bot using the existing avatar's appearance | ||
139 | string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), sp.UUID.ToString()); | ||
140 | Assert.That(npcRaw, Is.Not.Null); | ||
141 | |||
142 | UUID npcId = new UUID(npcRaw); | ||
143 | ScenePresence npc = m_scene.GetScenePresence(npcId); | ||
144 | Assert.That(npc, Is.Not.Null); | ||
145 | Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight)); | ||
146 | } | ||
147 | |||
148 | [Test] | 78 | [Test] |
149 | public void TestOsOwnerSaveAppearance() | 79 | public void TestOsOwnerSaveAppearance() |
150 | { | 80 | { |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs index 25679a6..b49bcc2 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/OSSL_ApiNpcTests.cs | |||
@@ -36,6 +36,7 @@ using OpenMetaverse; | |||
36 | using OpenMetaverse.Assets; | 36 | using OpenMetaverse.Assets; |
37 | using OpenMetaverse.StructuredData; | 37 | using OpenMetaverse.StructuredData; |
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Region.CoreModules.Avatar.Attachments; | ||
39 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | 40 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; |
40 | using OpenSim.Region.OptionalModules.World.NPC; | 41 | using OpenSim.Region.OptionalModules.World.NPC; |
41 | using OpenSim.Region.Framework.Scenes; | 42 | using OpenSim.Region.Framework.Scenes; |
@@ -71,7 +72,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
71 | config.Set("Enabled", "true"); | 72 | config.Set("Enabled", "true"); |
72 | 73 | ||
73 | m_scene = new SceneHelpers().SetupScene(); | 74 | m_scene = new SceneHelpers().SetupScene(); |
74 | SceneHelpers.SetupSceneModules(m_scene, initConfigSource, new AvatarFactoryModule(), new NPCModule()); | 75 | SceneHelpers.SetupSceneModules( |
76 | m_scene, initConfigSource, new AvatarFactoryModule(), new AttachmentsModule(), new NPCModule()); | ||
75 | 77 | ||
76 | m_engine = new XEngine.XEngine(); | 78 | m_engine = new XEngine.XEngine(); |
77 | m_engine.Initialise(initConfigSource); | 79 | m_engine.Initialise(initConfigSource); |
@@ -79,13 +81,191 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests | |||
79 | } | 81 | } |
80 | 82 | ||
81 | /// <summary> | 83 | /// <summary> |
84 | /// Test creation of an NPC where the appearance data comes from a notecard | ||
85 | /// </summary> | ||
86 | [Test] | ||
87 | public void TestOsNpcCreateUsingAppearanceFromNotecard() | ||
88 | { | ||
89 | TestHelpers.InMethod(); | ||
90 | |||
91 | // Store an avatar with a different height from default in a notecard. | ||
92 | UUID userId = TestHelpers.ParseTail(0x1); | ||
93 | float newHeight = 1.9f; | ||
94 | |||
95 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | ||
96 | sp.Appearance.AvatarHeight = newHeight; | ||
97 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); | ||
98 | SceneObjectPart part = so.RootPart; | ||
99 | m_scene.AddSceneObject(so); | ||
100 | |||
101 | OSSL_Api osslApi = new OSSL_Api(); | ||
102 | osslApi.Initialize(m_engine, part, null); | ||
103 | |||
104 | string notecardName = "appearanceNc"; | ||
105 | osslApi.osOwnerSaveAppearance(notecardName); | ||
106 | |||
107 | // Try creating a bot using the appearance in the notecard. | ||
108 | string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName); | ||
109 | Assert.That(npcRaw, Is.Not.Null); | ||
110 | |||
111 | UUID npcId = new UUID(npcRaw); | ||
112 | ScenePresence npc = m_scene.GetScenePresence(npcId); | ||
113 | Assert.That(npc, Is.Not.Null); | ||
114 | Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight)); | ||
115 | } | ||
116 | |||
117 | [Test] | ||
118 | public void TestOsNpcCreateNotExistingNotecard() | ||
119 | { | ||
120 | TestHelpers.InMethod(); | ||
121 | |||
122 | UUID userId = TestHelpers.ParseTail(0x1); | ||
123 | |||
124 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); | ||
125 | m_scene.AddSceneObject(so); | ||
126 | |||
127 | OSSL_Api osslApi = new OSSL_Api(); | ||
128 | osslApi.Initialize(m_engine, so.RootPart, null); | ||
129 | |||
130 | string npcRaw; | ||
131 | bool gotExpectedException = false; | ||
132 | try | ||
133 | { | ||
134 | npcRaw | ||
135 | = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name"); | ||
136 | } | ||
137 | catch (ScriptException) | ||
138 | { | ||
139 | gotExpectedException = true; | ||
140 | } | ||
141 | |||
142 | Assert.That(gotExpectedException, Is.True); | ||
143 | } | ||
144 | |||
145 | /// <summary> | ||
146 | /// Test creation of an NPC where the appearance data comes from an avatar already in the region. | ||
147 | /// </summary> | ||
148 | [Test] | ||
149 | public void TestOsNpcCreateUsingAppearanceFromAvatar() | ||
150 | { | ||
151 | TestHelpers.InMethod(); | ||
152 | // TestHelpers.EnableLogging(); | ||
153 | |||
154 | // Store an avatar with a different height from default in a notecard. | ||
155 | UUID userId = TestHelpers.ParseTail(0x1); | ||
156 | float newHeight = 1.9f; | ||
157 | |||
158 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | ||
159 | sp.Appearance.AvatarHeight = newHeight; | ||
160 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); | ||
161 | SceneObjectPart part = so.RootPart; | ||
162 | m_scene.AddSceneObject(so); | ||
163 | |||
164 | OSSL_Api osslApi = new OSSL_Api(); | ||
165 | osslApi.Initialize(m_engine, part, null); | ||
166 | |||
167 | string notecardName = "appearanceNc"; | ||
168 | osslApi.osOwnerSaveAppearance(notecardName); | ||
169 | |||
170 | // Try creating a bot using the existing avatar's appearance | ||
171 | string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), sp.UUID.ToString()); | ||
172 | Assert.That(npcRaw, Is.Not.Null); | ||
173 | |||
174 | UUID npcId = new UUID(npcRaw); | ||
175 | ScenePresence npc = m_scene.GetScenePresence(npcId); | ||
176 | Assert.That(npc, Is.Not.Null); | ||
177 | Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight)); | ||
178 | } | ||
179 | |||
180 | [Test] | ||
181 | public void TestOsNpcLoadAppearance() | ||
182 | { | ||
183 | TestHelpers.InMethod(); | ||
184 | |||
185 | // Store an avatar with a different height from default in a notecard. | ||
186 | UUID userId = TestHelpers.ParseTail(0x1); | ||
187 | float firstHeight = 1.9f; | ||
188 | float secondHeight = 2.1f; | ||
189 | string firstAppearanceNcName = "appearanceNc1"; | ||
190 | string secondAppearanceNcName = "appearanceNc2"; | ||
191 | |||
192 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | ||
193 | sp.Appearance.AvatarHeight = firstHeight; | ||
194 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); | ||
195 | SceneObjectPart part = so.RootPart; | ||
196 | m_scene.AddSceneObject(so); | ||
197 | |||
198 | OSSL_Api osslApi = new OSSL_Api(); | ||
199 | osslApi.Initialize(m_engine, part, null); | ||
200 | |||
201 | osslApi.osOwnerSaveAppearance(firstAppearanceNcName); | ||
202 | |||
203 | string npcRaw | ||
204 | = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName); | ||
205 | |||
206 | // Create a second appearance notecard with a different height | ||
207 | sp.Appearance.AvatarHeight = secondHeight; | ||
208 | osslApi.osOwnerSaveAppearance(secondAppearanceNcName); | ||
209 | |||
210 | osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName); | ||
211 | |||
212 | UUID npcId = new UUID(npcRaw); | ||
213 | ScenePresence npc = m_scene.GetScenePresence(npcId); | ||
214 | Assert.That(npc, Is.Not.Null); | ||
215 | Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(secondHeight)); | ||
216 | } | ||
217 | |||
218 | [Test] | ||
219 | public void TestOsNpcLoadAppearanceNotExistingNotecard() | ||
220 | { | ||
221 | TestHelpers.InMethod(); | ||
222 | |||
223 | // Store an avatar with a different height from default in a notecard. | ||
224 | UUID userId = TestHelpers.ParseTail(0x1); | ||
225 | float firstHeight = 1.9f; | ||
226 | float secondHeight = 2.1f; | ||
227 | string firstAppearanceNcName = "appearanceNc1"; | ||
228 | string secondAppearanceNcName = "appearanceNc2"; | ||
229 | |||
230 | ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); | ||
231 | sp.Appearance.AvatarHeight = firstHeight; | ||
232 | SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); | ||
233 | SceneObjectPart part = so.RootPart; | ||
234 | m_scene.AddSceneObject(so); | ||
235 | |||
236 | OSSL_Api osslApi = new OSSL_Api(); | ||
237 | osslApi.Initialize(m_engine, part, null); | ||
238 | |||
239 | osslApi.osOwnerSaveAppearance(firstAppearanceNcName); | ||
240 | |||
241 | string npcRaw | ||
242 | = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName); | ||
243 | |||
244 | bool gotExpectedException = false; | ||
245 | try | ||
246 | { | ||
247 | osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName); | ||
248 | } | ||
249 | catch (ScriptException) | ||
250 | { | ||
251 | gotExpectedException = true; | ||
252 | } | ||
253 | |||
254 | Assert.That(gotExpectedException, Is.True); | ||
255 | |||
256 | UUID npcId = new UUID(npcRaw); | ||
257 | ScenePresence npc = m_scene.GetScenePresence(npcId); | ||
258 | Assert.That(npc, Is.Not.Null); | ||
259 | Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(firstHeight)); | ||
260 | } | ||
261 | |||
262 | /// <summary> | ||
82 | /// Test removal of an owned NPC. | 263 | /// Test removal of an owned NPC. |
83 | /// </summary> | 264 | /// </summary> |
84 | [Test] | 265 | [Test] |
85 | public void TestOsNpcRemoveOwned() | 266 | public void TestOsNpcRemoveOwned() |
86 | { | 267 | { |
87 | TestHelpers.InMethod(); | 268 | TestHelpers.InMethod(); |
88 | // log4net.Config.XmlConfigurator.Configure(); | ||
89 | 269 | ||
90 | // Store an avatar with a different height from default in a notecard. | 270 | // Store an avatar with a different height from default in a notecard. |
91 | UUID userId = TestHelpers.ParseTail(0x1); | 271 | UUID userId = TestHelpers.ParseTail(0x1); |
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Properties/AssemblyInfo.cs b/OpenSim/Region/ScriptEngine/XEngine/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..bd26a8b --- /dev/null +++ b/OpenSim/Region/ScriptEngine/XEngine/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.ScriptEngine.XEngine")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("1feed7de-3d45-4d3d-80e2-b57566284df5")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs index f247a0b..5abfe9a 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/Tests/XEngineTest.cs | |||
@@ -44,7 +44,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests | |||
44 | /// XEngine tests. | 44 | /// XEngine tests. |
45 | /// </summary> | 45 | /// </summary> |
46 | [TestFixture] | 46 | [TestFixture] |
47 | public class XEngineTest | 47 | public class XEngineTest : OpenSimTestCase |
48 | { | 48 | { |
49 | private TestScene m_scene; | 49 | private TestScene m_scene; |
50 | private XEngine m_xEngine; | 50 | private XEngine m_xEngine; |
@@ -90,7 +90,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests | |||
90 | // log4net.Config.XmlConfigurator.Configure(); | 90 | // log4net.Config.XmlConfigurator.Configure(); |
91 | 91 | ||
92 | UUID userId = TestHelpers.ParseTail(0x1); | 92 | UUID userId = TestHelpers.ParseTail(0x1); |
93 | // UUID objectId = TestHelpers.ParseTail(0x2); | 93 | // UUID objectId = TestHelpers.ParseTail(0x100); |
94 | // UUID itemId = TestHelpers.ParseTail(0x3); | 94 | // UUID itemId = TestHelpers.ParseTail(0x3); |
95 | string itemName = "TestStartScript() Item"; | 95 | string itemName = "TestStartScript() Item"; |
96 | 96 | ||
@@ -105,12 +105,18 @@ namespace OpenSim.Region.ScriptEngine.XEngine.Tests | |||
105 | 105 | ||
106 | m_scene.EventManager.OnChatFromWorld += OnChatFromWorld; | 106 | m_scene.EventManager.OnChatFromWorld += OnChatFromWorld; |
107 | 107 | ||
108 | m_scene.RezNewScript(userId, itemTemplate); | 108 | SceneObjectPart partWhereRezzed = m_scene.RezNewScript(userId, itemTemplate); |
109 | 109 | ||
110 | m_chatEvent.WaitOne(60000); | 110 | m_chatEvent.WaitOne(60000); |
111 | 111 | ||
112 | Assert.That(m_osChatMessageReceived, Is.Not.Null, "No chat message received in TestStartScript()"); | 112 | Assert.That(m_osChatMessageReceived, Is.Not.Null, "No chat message received in TestStartScript()"); |
113 | Assert.That(m_osChatMessageReceived.Message, Is.EqualTo("Script running")); | 113 | Assert.That(m_osChatMessageReceived.Message, Is.EqualTo("Script running")); |
114 | |||
115 | bool running; | ||
116 | TaskInventoryItem scriptItem = partWhereRezzed.Inventory.GetInventoryItem(itemName); | ||
117 | Assert.That( | ||
118 | SceneObjectPartInventory.TryGetScriptInstanceRunning(m_scene, scriptItem, out running), Is.True); | ||
119 | Assert.That(running, Is.True); | ||
114 | } | 120 | } |
115 | 121 | ||
116 | private void OnChatFromWorld(object sender, OSChatMessage oscm) | 122 | private void OnChatFromWorld(object sender, OSChatMessage oscm) |
diff --git a/OpenSim/Region/UserStatistics/Properties/AssemblyInfo.cs b/OpenSim/Region/UserStatistics/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..100cf99 --- /dev/null +++ b/OpenSim/Region/UserStatistics/Properties/AssemblyInfo.cs | |||
@@ -0,0 +1,33 @@ | |||
1 | using System.Reflection; | ||
2 | using System.Runtime.CompilerServices; | ||
3 | using System.Runtime.InteropServices; | ||
4 | |||
5 | // General Information about an assembly is controlled through the following | ||
6 | // set of attributes. Change these attribute values to modify the information | ||
7 | // associated with an assembly. | ||
8 | [assembly: AssemblyTitle("OpenSim.Region.UserStatistics")] | ||
9 | [assembly: AssemblyDescription("")] | ||
10 | [assembly: AssemblyConfiguration("")] | ||
11 | [assembly: AssemblyCompany("http://opensimulator.org")] | ||
12 | [assembly: AssemblyProduct("OpenSim")] | ||
13 | [assembly: AssemblyCopyright("OpenSimulator developers")] | ||
14 | [assembly: AssemblyTrademark("")] | ||
15 | [assembly: AssemblyCulture("")] | ||
16 | |||
17 | // Setting ComVisible to false makes the types in this assembly not visible | ||
18 | // to COM components. If you need to access a type in this assembly from | ||
19 | // COM, set the ComVisible attribute to true on that type. | ||
20 | [assembly: ComVisible(false)] | ||
21 | |||
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM | ||
23 | [assembly: Guid("42b28288-5fdd-478f-8903-8dccbbb2d5f9")] | ||
24 | |||
25 | // Version information for an assembly consists of the following four values: | ||
26 | // | ||
27 | // Major Version | ||
28 | // Minor Version | ||
29 | // Build Number | ||
30 | // Revision | ||
31 | // | ||
32 | [assembly: AssemblyVersion("0.7.5.*")] | ||
33 | [assembly: AssemblyFileVersion("1.0.0.0")] | ||
diff --git a/OpenSim/Region/UserStatistics/WebStatsModule.cs b/OpenSim/Region/UserStatistics/WebStatsModule.cs index 625eba4..b08233c 100644 --- a/OpenSim/Region/UserStatistics/WebStatsModule.cs +++ b/OpenSim/Region/UserStatistics/WebStatsModule.cs | |||
@@ -43,15 +43,20 @@ using OpenSim.Framework.Servers.HttpServer; | |||
43 | using OpenSim.Region.Framework.Interfaces; | 43 | using OpenSim.Region.Framework.Interfaces; |
44 | using OpenSim.Region.Framework.Scenes; | 44 | using OpenSim.Region.Framework.Scenes; |
45 | using Mono.Data.SqliteClient; | 45 | using Mono.Data.SqliteClient; |
46 | using Mono.Addins; | ||
46 | 47 | ||
47 | using Caps = OpenSim.Framework.Capabilities.Caps; | 48 | using Caps = OpenSim.Framework.Capabilities.Caps; |
48 | 49 | ||
49 | using OSD = OpenMetaverse.StructuredData.OSD; | 50 | using OSD = OpenMetaverse.StructuredData.OSD; |
50 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; | 51 | using OSDMap = OpenMetaverse.StructuredData.OSDMap; |
51 | 52 | ||
53 | [assembly: Addin("WebStats", "1.0")] | ||
54 | [assembly: AddinDependency("OpenSim", "0.5")] | ||
55 | |||
52 | namespace OpenSim.Region.UserStatistics | 56 | namespace OpenSim.Region.UserStatistics |
53 | { | 57 | { |
54 | public class WebStatsModule : IRegionModule | 58 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebStatsModule")] |
59 | public class WebStatsModule : ISharedRegionModule | ||
55 | { | 60 | { |
56 | private static readonly ILog m_log = | 61 | private static readonly ILog m_log = |
57 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 62 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -74,59 +79,69 @@ namespace OpenSim.Region.UserStatistics | |||
74 | private string m_loglines = String.Empty; | 79 | private string m_loglines = String.Empty; |
75 | private volatile int lastHit = 12000; | 80 | private volatile int lastHit = 12000; |
76 | 81 | ||
77 | public virtual void Initialise(Scene scene, IConfigSource config) | 82 | #region ISharedRegionModule |
83 | |||
84 | public virtual void Initialise(IConfigSource config) | ||
78 | { | 85 | { |
79 | IConfig cnfg = config.Configs["WebStats"]; | 86 | IConfig cnfg = config.Configs["WebStats"]; |
80 | 87 | ||
81 | if (cnfg != null) | 88 | if (cnfg != null) |
82 | enabled = cnfg.GetBoolean("enabled", false); | 89 | enabled = cnfg.GetBoolean("enabled", false); |
83 | 90 | } | |
91 | |||
92 | public virtual void PostInitialise() | ||
93 | { | ||
94 | if (!enabled) | ||
95 | return; | ||
96 | |||
97 | AddEventHandlers(); | ||
98 | |||
99 | if (Util.IsWindows()) | ||
100 | Util.LoadArchSpecificWindowsDll("sqlite3.dll"); | ||
101 | |||
102 | //IConfig startupConfig = config.Configs["Startup"]; | ||
103 | |||
104 | dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3"); | ||
105 | dbConn.Open(); | ||
106 | CreateTables(dbConn); | ||
107 | |||
108 | Prototype_distributor protodep = new Prototype_distributor(); | ||
109 | Updater_distributor updatedep = new Updater_distributor(); | ||
110 | ActiveConnectionsAJAX ajConnections = new ActiveConnectionsAJAX(); | ||
111 | SimStatsAJAX ajSimStats = new SimStatsAJAX(); | ||
112 | LogLinesAJAX ajLogLines = new LogLinesAJAX(); | ||
113 | Default_Report defaultReport = new Default_Report(); | ||
114 | Clients_report clientReport = new Clients_report(); | ||
115 | Sessions_Report sessionsReport = new Sessions_Report(); | ||
116 | |||
117 | reports.Add("prototype.js", protodep); | ||
118 | reports.Add("updater.js", updatedep); | ||
119 | reports.Add("activeconnectionsajax.html", ajConnections); | ||
120 | reports.Add("simstatsajax.html", ajSimStats); | ||
121 | reports.Add("activelogajax.html", ajLogLines); | ||
122 | reports.Add("default.report", defaultReport); | ||
123 | reports.Add("clients.report", clientReport); | ||
124 | reports.Add("sessions.report", sessionsReport); | ||
125 | |||
126 | //// | ||
127 | // Add Your own Reports here (Do Not Modify Lines here Devs!) | ||
128 | //// | ||
129 | |||
130 | //// | ||
131 | // End Own reports section | ||
132 | //// | ||
133 | |||
134 | MainServer.Instance.AddHTTPHandler("/SStats/", HandleStatsRequest); | ||
135 | MainServer.Instance.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest); | ||
136 | } | ||
137 | |||
138 | public virtual void AddRegion(Scene scene) | ||
139 | { | ||
84 | if (!enabled) | 140 | if (!enabled) |
85 | return; | 141 | return; |
86 | 142 | ||
87 | lock (m_scenes) | 143 | lock (m_scenes) |
88 | { | 144 | { |
89 | if (m_scenes.Count == 0) | ||
90 | { | ||
91 | if (Util.IsWindows()) | ||
92 | Util.LoadArchSpecificWindowsDll("sqlite3.dll"); | ||
93 | |||
94 | //IConfig startupConfig = config.Configs["Startup"]; | ||
95 | |||
96 | dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3"); | ||
97 | dbConn.Open(); | ||
98 | CreateTables(dbConn); | ||
99 | |||
100 | Prototype_distributor protodep = new Prototype_distributor(); | ||
101 | Updater_distributor updatedep = new Updater_distributor(); | ||
102 | ActiveConnectionsAJAX ajConnections = new ActiveConnectionsAJAX(); | ||
103 | SimStatsAJAX ajSimStats = new SimStatsAJAX(); | ||
104 | LogLinesAJAX ajLogLines = new LogLinesAJAX(); | ||
105 | Default_Report defaultReport = new Default_Report(); | ||
106 | Clients_report clientReport = new Clients_report(); | ||
107 | Sessions_Report sessionsReport = new Sessions_Report(); | ||
108 | |||
109 | reports.Add("prototype.js", protodep); | ||
110 | reports.Add("updater.js", updatedep); | ||
111 | reports.Add("activeconnectionsajax.html", ajConnections); | ||
112 | reports.Add("simstatsajax.html", ajSimStats); | ||
113 | reports.Add("activelogajax.html", ajLogLines); | ||
114 | reports.Add("default.report", defaultReport); | ||
115 | reports.Add("clients.report", clientReport); | ||
116 | reports.Add("sessions.report", sessionsReport); | ||
117 | |||
118 | //// | ||
119 | // Add Your own Reports here (Do Not Modify Lines here Devs!) | ||
120 | //// | ||
121 | |||
122 | //// | ||
123 | // End Own reports section | ||
124 | //// | ||
125 | |||
126 | MainServer.Instance.AddHTTPHandler("/SStats/", HandleStatsRequest); | ||
127 | MainServer.Instance.AddHTTPHandler("/CAPS/VS/", HandleUnknownCAPSRequest); | ||
128 | } | ||
129 | |||
130 | m_scenes.Add(scene); | 145 | m_scenes.Add(scene); |
131 | if (m_simstatsCounters.ContainsKey(scene.RegionInfo.RegionID)) | 146 | if (m_simstatsCounters.ContainsKey(scene.RegionInfo.RegionID)) |
132 | m_simstatsCounters.Remove(scene.RegionInfo.RegionID); | 147 | m_simstatsCounters.Remove(scene.RegionInfo.RegionID); |
@@ -136,6 +151,39 @@ namespace OpenSim.Region.UserStatistics | |||
136 | } | 151 | } |
137 | } | 152 | } |
138 | 153 | ||
154 | public void RegionLoaded(Scene scene) | ||
155 | { | ||
156 | } | ||
157 | |||
158 | public void RemoveRegion(Scene scene) | ||
159 | { | ||
160 | } | ||
161 | |||
162 | public virtual void Close() | ||
163 | { | ||
164 | if (!enabled) | ||
165 | return; | ||
166 | |||
167 | dbConn.Close(); | ||
168 | dbConn.Dispose(); | ||
169 | m_sessions.Clear(); | ||
170 | m_scenes.Clear(); | ||
171 | reports.Clear(); | ||
172 | m_simstatsCounters.Clear(); | ||
173 | } | ||
174 | |||
175 | public virtual string Name | ||
176 | { | ||
177 | get { return "ViewerStatsModule"; } | ||
178 | } | ||
179 | |||
180 | public Type ReplaceableInterface | ||
181 | { | ||
182 | get { return null; } | ||
183 | } | ||
184 | |||
185 | #endregion | ||
186 | |||
139 | private void ReceiveClassicSimStatsPacket(SimStats stats) | 187 | private void ReceiveClassicSimStatsPacket(SimStats stats) |
140 | { | 188 | { |
141 | if (!enabled) | 189 | if (!enabled) |
@@ -251,37 +299,6 @@ namespace OpenSim.Region.UserStatistics | |||
251 | } | 299 | } |
252 | } | 300 | } |
253 | 301 | ||
254 | public virtual void PostInitialise() | ||
255 | { | ||
256 | if (!enabled) | ||
257 | return; | ||
258 | |||
259 | AddHandlers(); | ||
260 | } | ||
261 | |||
262 | public virtual void Close() | ||
263 | { | ||
264 | if (!enabled) | ||
265 | return; | ||
266 | |||
267 | dbConn.Close(); | ||
268 | dbConn.Dispose(); | ||
269 | m_sessions.Clear(); | ||
270 | m_scenes.Clear(); | ||
271 | reports.Clear(); | ||
272 | m_simstatsCounters.Clear(); | ||
273 | } | ||
274 | |||
275 | public virtual string Name | ||
276 | { | ||
277 | get { return "ViewerStatsModule"; } | ||
278 | } | ||
279 | |||
280 | public bool IsSharedModule | ||
281 | { | ||
282 | get { return true; } | ||
283 | } | ||
284 | |||
285 | private void OnRegisterCaps(UUID agentID, Caps caps) | 302 | private void OnRegisterCaps(UUID agentID, Caps caps) |
286 | { | 303 | { |
287 | // m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); | 304 | // m_log.DebugFormat("[WEB STATS MODULE]: OnRegisterCaps: agentID {0} caps {1}", agentID, caps); |
@@ -302,7 +319,7 @@ namespace OpenSim.Region.UserStatistics | |||
302 | { | 319 | { |
303 | } | 320 | } |
304 | 321 | ||
305 | protected virtual void AddHandlers() | 322 | protected virtual void AddEventHandlers() |
306 | { | 323 | { |
307 | lock (m_scenes) | 324 | lock (m_scenes) |
308 | { | 325 | { |