aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/Wind/WindModule.cs30
-rw-r--r--OpenSim/Region/Framework/Interfaces/IWindModule.cs9
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs17
3 files changed, 41 insertions, 15 deletions
diff --git a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs
index 0b2062b..b761c13 100644
--- a/OpenSim/Region/CoreModules/World/Wind/WindModule.cs
+++ b/OpenSim/Region/CoreModules/World/Wind/WindModule.cs
@@ -45,7 +45,10 @@ namespace OpenSim.Region.CoreModules
45 private Random rndnums = new Random(Environment.TickCount); 45 private Random 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 ready = false;
48
49 // Simplified windSpeeds based on the fact that the client protocal tracks at a resolution of 16m
48 private Vector2[] windSpeeds = new Vector2[16 * 16]; 50 private Vector2[] windSpeeds = new Vector2[16 * 16];
51
49 private Dictionary<UUID, ulong> m_rootAgents = new Dictionary<UUID, ulong>(); 52 private Dictionary<UUID, ulong> m_rootAgents = new Dictionary<UUID, ulong>();
50 53
51 public void Initialise(Scene scene, IConfigSource config) 54 public void Initialise(Scene scene, IConfigSource config)
@@ -89,9 +92,32 @@ namespace OpenSim.Region.CoreModules
89 get { return false; } 92 get { return false; }
90 } 93 }
91 94
92 public Vector2[] WindSpeeds 95 /// <summary>
96 /// Retrieve the wind speed at the given region coordinate. This
97 /// implimentation ignores Z.
98 /// </summary>
99 /// <param name="x">0...255</param>
100 /// <param name="y">0...255</param>
101 /// <returns></returns>
102 public Vector3 WindSpeed(int x, int y, int z)
93 { 103 {
94 get { return windSpeeds; } 104 Vector3 windVector = new Vector3(0.0f, 0.0f, 0.0f);
105
106 x /= 16;
107 y /= 16;
108 if (x < 0) x = 0;
109 if (x > 15) x = 15;
110 if (y < 0) y = 0;
111 if (y > 15) y = 15;
112
113 if (windSpeeds != null)
114 {
115 windVector.X = windSpeeds[y * 16 + x].X;
116 windVector.Y = windSpeeds[y * 16 + x].Y;
117 }
118
119
120 return windVector;
95 } 121 }
96 122
97 public void WindToClient(IClientAPI client) 123 public void WindToClient(IClientAPI client)
diff --git a/OpenSim/Region/Framework/Interfaces/IWindModule.cs b/OpenSim/Region/Framework/Interfaces/IWindModule.cs
index 5b8b0ce..84effd0 100644
--- a/OpenSim/Region/Framework/Interfaces/IWindModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/IWindModule.cs
@@ -31,9 +31,10 @@ namespace OpenSim.Region.Framework.Interfaces
31{ 31{
32 public interface IWindModule : IRegionModule 32 public interface IWindModule : IRegionModule
33 { 33 {
34 Vector2[] WindSpeeds 34
35 { 35 /// <summary>
36 get; 36 /// Retrieves the current wind speed at the given Region Coordinates
37 } 37 /// </summary>
38 Vector3 WindSpeed(int x, int y, int z);
38 } 39 }
39} 40}
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index fcd94a4..32ebc37 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -1031,17 +1031,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
1031 m_host.AddScriptLPS(1); 1031 m_host.AddScriptLPS(1);
1032 LSL_Vector wind = new LSL_Vector(0, 0, 0); 1032 LSL_Vector wind = new LSL_Vector(0, 0, 0);
1033 IWindModule module = World.RequestModuleInterface<IWindModule>(); 1033 IWindModule module = World.RequestModuleInterface<IWindModule>();
1034 if (module != null && module.WindSpeeds != null) 1034 if (module != null)
1035 { 1035 {
1036 Vector3 pos = m_host.GetWorldPosition(); 1036 Vector3 pos = m_host.GetWorldPosition();
1037 int x = (int)((pos.X + offset.x)/ 16); 1037 int x = (int)(pos.X + offset.x);
1038 int y = (int)((pos.Y + offset.y)/ 16); 1038 int y = (int)(pos.Y + offset.y);
1039 if (x < 0) x = 0; 1039
1040 if (x > 15) x = 15; 1040 Vector3 windSpeed = module.WindSpeed(x, y, 0);
1041 if (y < 0) y = 0; 1041
1042 if (y > 15) y = 15; 1042 wind.x = windSpeed.X;
1043 wind.x = module.WindSpeeds[y * 16 + x].X; 1043 wind.y = windSpeed.Y;
1044 wind.y = module.WindSpeeds[y * 16 + x].Y;
1045 } 1044 }
1046 return wind; 1045 return wind;
1047 } 1046 }