aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs72
-rw-r--r--bin/OpenSim.ini.example3
2 files changed, 74 insertions, 1 deletions
diff --git a/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs
index 98f31f6..b9c716f 100644
--- a/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs
+++ b/OpenSim/Region/CoreModules/World/Cloud/CloudModule.cs
@@ -39,7 +39,8 @@ namespace OpenSim.Region.CoreModules
39 { 39 {
40// private static readonly log4net.ILog m_log 40// private static readonly log4net.ILog m_log
41// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 41// = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
42 42 private uint m_frame = 0;
43 private int m_frameUpdateRate = 1000;
43 private Random m_rndnums = new Random(Environment.TickCount); 44 private Random m_rndnums = new Random(Environment.TickCount);
44 private Scene m_scene = null; 45 private Scene m_scene = null;
45 private bool m_ready = false; 46 private bool m_ready = false;
@@ -57,6 +58,7 @@ namespace OpenSim.Region.CoreModules
57 { 58 {
58 m_enabled = cloudConfig.GetBoolean("enabled", false); 59 m_enabled = cloudConfig.GetBoolean("enabled", false);
59 m_cloudDensity = cloudConfig.GetFloat("density", 0.5F); 60 m_cloudDensity = cloudConfig.GetFloat("density", 0.5F);
61 m_frameUpdateRate = cloudConfig.GetInt("cloud_update_rate", 1000);
60 } 62 }
61 63
62 if (m_enabled) 64 if (m_enabled)
@@ -68,6 +70,7 @@ namespace OpenSim.Region.CoreModules
68 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel; 70 scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
69 scene.EventManager.OnClientClosed += ClientLoggedOut; 71 scene.EventManager.OnClientClosed += ClientLoggedOut;
70 scene.RegisterModuleInterface<ICloudModule>(this); 72 scene.RegisterModuleInterface<ICloudModule>(this);
73 scene.EventManager.OnFrame += CloudUpdate;
71 74
72 GenerateCloudCover(); 75 GenerateCloudCover();
73 76
@@ -90,6 +93,7 @@ namespace OpenSim.Region.CoreModules
90 m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent; 93 m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent;
91 m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel; 94 m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
92 m_scene.EventManager.OnClientClosed -= ClientLoggedOut; 95 m_scene.EventManager.OnClientClosed -= ClientLoggedOut;
96 m_scene.EventManager.OnFrame -= CloudUpdate;
93 } 97 }
94 } 98 }
95 99
@@ -122,6 +126,72 @@ namespace OpenSim.Region.CoreModules
122 return cover; 126 return cover;
123 } 127 }
124 128
129 private void UpdateCloudCover()
130 {
131 float[] newCover = new float[16 * 16];
132 int rowAbove = new int();
133 int rowBelow = new int();
134 int columnLeft = new int();
135 int columnRight = new int();
136 for (int x = 0; x < 16; x++)
137 {
138 if (x == 0)
139 {
140 columnRight = x + 1;
141 columnLeft = 15;
142 }
143 else if (x == 15)
144 {
145 columnRight = 0;
146 columnLeft = x - 1;
147 }
148 else
149 {
150 columnRight = x + 1;
151 columnLeft = x - 1;
152 }
153 for (int y = 0; y< 16; y++)
154 {
155 if (y == 0)
156 {
157 rowAbove = y + 1;
158 rowBelow = 15;
159 }
160 else if (y == 15)
161 {
162 rowAbove = 0;
163 rowBelow = y - 1;
164 }
165 else
166 {
167 rowAbove = y + 1;
168 rowBelow = y - 1;
169 }
170 float neighborAverage = (cloudCover[rowBelow * 16 + columnLeft] +
171 cloudCover[y * 16 + columnLeft] +
172 cloudCover[rowAbove * 16 + columnLeft] +
173 cloudCover[rowBelow * 16 + x] +
174 cloudCover[rowAbove * 16 + x] +
175 cloudCover[rowBelow * 16 + columnRight] +
176 cloudCover[y * 16 + columnRight] +
177 cloudCover[rowAbove * 16 + columnRight] +
178 cloudCover[y * 16 + x]) / 9;
179 newCover[y * 16 + x] = ((neighborAverage / m_cloudDensity) + 0.175f) % 1.0f;
180 newCover[y * 16 + x] *= m_cloudDensity;
181 }
182 }
183 Array.Copy(newCover, cloudCover, 16 * 16);
184 }
185
186 private void CloudUpdate()
187 {
188 if (((m_frame++ % m_frameUpdateRate) != 0) || !m_ready || (m_cloudDensity == 0))
189 {
190 return;
191 }
192 UpdateCloudCover();
193 }
194
125 public void CloudsToClient(IClientAPI client) 195 public void CloudsToClient(IClientAPI client)
126 { 196 {
127 if (m_ready) 197 if (m_ready)
diff --git a/bin/OpenSim.ini.example b/bin/OpenSim.ini.example
index 51dd7ff..a49035d 100644
--- a/bin/OpenSim.ini.example
+++ b/bin/OpenSim.ini.example
@@ -746,6 +746,9 @@
746 ; Density of cloud cover 0.0 to 1.0 746 ; Density of cloud cover 0.0 to 1.0
747 density = 0.5 747 density = 0.5
748 748
749 ; update interval for the cloud cover data returned by llCloud().
750 ; default is 1000
751 cloud_update_rate = 1000
749 752
750[Trees] 753[Trees]
751 ; Enable this to allow the tree module to manage your sim trees, including growing, reproducing and dying 754 ; Enable this to allow the tree module to manage your sim trees, including growing, reproducing and dying