aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Wind
diff options
context:
space:
mode:
authorBlueWall2012-11-25 17:03:14 -0500
committerBlueWall2012-11-25 17:03:14 -0500
commitc754003944d0166bf50b4f94b0c0eea642503bb0 (patch)
treedfa1c2020d5500d510519d5b2b3236600692f277 /OpenSim/Region/CoreModules/World/Wind
parentMerge branch 'master' into connector_plugin (diff)
parentCombine TestDeleteSceneObjectAsync() with TestDeRezSceneObject() as they are ... (diff)
downloadopensim-SC-c754003944d0166bf50b4f94b0c0eea642503bb0.zip
opensim-SC-c754003944d0166bf50b4f94b0c0eea642503bb0.tar.gz
opensim-SC-c754003944d0166bf50b4f94b0c0eea642503bb0.tar.bz2
opensim-SC-c754003944d0166bf50b4f94b0c0eea642503bb0.tar.xz
Merge branch 'master' into connector_plugin
Conflicts: OpenSim/Server/Base/ServicesServerBase.cs
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Wind')
-rw-r--r--OpenSim/Region/CoreModules/World/Wind/Plugins/ConfigurableWind.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Wind/Plugins/SimpleRandomWind.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Wind/WindModule.cs185
3 files changed, 102 insertions, 87 deletions
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
32using log4net; 32using log4net;
33using OpenMetaverse; 33using OpenMetaverse;
34using Mono.Addins;
34 35
35using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.CoreModules.World.Wind; 37using OpenSim.Region.CoreModules.World.Wind;
37 38
38namespace OpenSim.Region.CoreModules.World.Wind.Plugins 39namespace 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;
29using System.Collections.Generic; 29using System.Collections.Generic;
30 30
31using OpenMetaverse; 31using OpenMetaverse;
32using Mono.Addins;
32 33
33using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
34 35
35namespace OpenSim.Region.CoreModules.World.Wind.Plugins 36namespace 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
41namespace OpenSim.Region.CoreModules 41namespace 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