diff options
author | Charles Krinke | 2009-03-15 20:22:07 +0000 |
---|---|---|
committer | Charles Krinke | 2009-03-15 20:22:07 +0000 |
commit | 5bc386c648bc931795c945d424efe914076b88ef (patch) | |
tree | 2eb22ebd257171672de5fd42ecdda91386c97d8c /OpenSim/Region/CoreModules | |
parent | Fixes Mantis #3294. Thank you kindly, Godfrey, for a patch that: (diff) | |
download | opensim-SC-5bc386c648bc931795c945d424efe914076b88ef.zip opensim-SC-5bc386c648bc931795c945d424efe914076b88ef.tar.gz opensim-SC-5bc386c648bc931795c945d424efe914076b88ef.tar.bz2 opensim-SC-5bc386c648bc931795c945d424efe914076b88ef.tar.xz |
Fixes Mantis#3301. Thank you kindly, MaimedLeech for a patch that:
patch allows wind to be enabled/disabled, and wind strength set,
from ini file
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Wind/WindModule.cs | 66 |
1 files changed, 44 insertions, 22 deletions
diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs index a1149ea..87e6fd9 100644 --- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs +++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs | |||
@@ -42,9 +42,11 @@ namespace OpenSim.Region.CoreModules | |||
42 | 42 | ||
43 | private int m_frame = 0; | 43 | private int m_frame = 0; |
44 | private int m_frame_mod = 150; | 44 | private int m_frame_mod = 150; |
45 | private Random rndnums = new Random(Environment.TickCount); | 45 | private Random m_rndnums = new Random(Environment.TickCount); |
46 | private Scene m_scene = null; | 46 | private Scene m_scene = null; |
47 | private bool ready = false; | 47 | private bool m_ready = false; |
48 | private float m_strength = 1.0F; | ||
49 | private bool m_enabled = true; | ||
48 | 50 | ||
49 | // Simplified windSpeeds based on the fact that the client protocal tracks at a resolution of 16m | 51 | // Simplified windSpeeds based on the fact that the client protocal tracks at a resolution of 16m |
50 | private Vector2[] windSpeeds = new Vector2[16 * 16]; | 52 | private Vector2[] windSpeeds = new Vector2[16 * 16]; |
@@ -53,18 +55,33 @@ namespace OpenSim.Region.CoreModules | |||
53 | 55 | ||
54 | public void Initialise(Scene scene, IConfigSource config) | 56 | public void Initialise(Scene scene, IConfigSource config) |
55 | { | 57 | { |
56 | m_scene = scene; | 58 | IConfig windConfig = config.Configs["Wind"]; |
57 | m_frame = 0; | 59 | |
60 | if (windConfig != null) | ||
61 | { | ||
62 | m_enabled = windConfig.GetBoolean("enabled", true); | ||
63 | m_strength = windConfig.GetFloat("strength", 1.0F); | ||
64 | } | ||
65 | |||
66 | if (m_enabled) | ||
67 | { | ||
68 | |||
69 | m_scene = scene; | ||
70 | m_frame = 0; | ||
58 | 71 | ||
59 | scene.EventManager.OnFrame += WindUpdate; | ||
60 | scene.EventManager.OnMakeChildAgent += MakeChildAgent; | ||
61 | scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; | ||
62 | scene.EventManager.OnClientClosed += ClientLoggedOut; | ||
63 | scene.RegisterModuleInterface<IWindModule>(this); | ||
64 | 72 | ||
65 | GenWindPos(); | 73 | scene.EventManager.OnFrame += WindUpdate; |
74 | scene.EventManager.OnMakeChildAgent += MakeChildAgent; | ||
75 | scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; | ||
76 | scene.EventManager.OnClientClosed += ClientLoggedOut; | ||
77 | scene.RegisterModuleInterface<IWindModule>(this); | ||
78 | |||
79 | GenWindPos(); | ||
80 | |||
81 | m_ready = true; | ||
82 | |||
83 | } | ||
66 | 84 | ||
67 | ready = true; | ||
68 | } | 85 | } |
69 | 86 | ||
70 | public void PostInitialise() | 87 | public void PostInitialise() |
@@ -73,13 +90,16 @@ namespace OpenSim.Region.CoreModules | |||
73 | 90 | ||
74 | public void Close() | 91 | public void Close() |
75 | { | 92 | { |
76 | ready = false; | 93 | if (m_enabled) |
77 | // Remove our hooks | 94 | { |
78 | m_scene.EventManager.OnFrame -= WindUpdate; | 95 | m_ready = false; |
79 | // m_scene.EventManager.OnNewClient -= SunToClient; | 96 | // Remove our hooks |
80 | m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent; | 97 | m_scene.EventManager.OnFrame -= WindUpdate; |
81 | m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel; | 98 | // m_scene.EventManager.OnNewClient -= SunToClient; |
82 | m_scene.EventManager.OnClientClosed -= ClientLoggedOut; | 99 | m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent; |
100 | m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel; | ||
101 | m_scene.EventManager.OnClientClosed -= ClientLoggedOut; | ||
102 | } | ||
83 | } | 103 | } |
84 | 104 | ||
85 | public string Name | 105 | public string Name |
@@ -122,7 +142,7 @@ namespace OpenSim.Region.CoreModules | |||
122 | 142 | ||
123 | public void WindToClient(IClientAPI client) | 143 | public void WindToClient(IClientAPI client) |
124 | { | 144 | { |
125 | if (ready) | 145 | if (m_ready) |
126 | { | 146 | { |
127 | //if (!sunFixed) | 147 | //if (!sunFixed) |
128 | //GenWindPos(); // Generate shared values once | 148 | //GenWindPos(); // Generate shared values once |
@@ -132,7 +152,7 @@ namespace OpenSim.Region.CoreModules | |||
132 | 152 | ||
133 | public void WindUpdate() | 153 | public void WindUpdate() |
134 | { | 154 | { |
135 | if (((m_frame++ % m_frame_mod) != 0) || !ready) | 155 | if (((m_frame++ % m_frame_mod) != 0) || !m_ready) |
136 | { | 156 | { |
137 | return; | 157 | return; |
138 | } | 158 | } |
@@ -182,8 +202,10 @@ namespace OpenSim.Region.CoreModules | |||
182 | { | 202 | { |
183 | for (int x = 0; x < 16; x++) | 203 | for (int x = 0; x < 16; x++) |
184 | { | 204 | { |
185 | windSpeeds[y * 16 + x].X = (float)(rndnums.NextDouble() * 2d - 1d); // -1 to 1 | 205 | windSpeeds[y * 16 + x].X = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1 |
186 | windSpeeds[y * 16 + x].Y = (float)(rndnums.NextDouble() * 2d - 1d); // -1 to 1 | 206 | windSpeeds[y * 16 + x].Y = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1 |
207 | windSpeeds[y * 16 + x].X *= m_strength; | ||
208 | windSpeeds[y * 16 + x].Y *= m_strength; | ||
187 | } | 209 | } |
188 | } | 210 | } |
189 | } | 211 | } |