diff options
author | Charles Krinke | 2009-03-05 04:24:22 +0000 |
---|---|---|
committer | Charles Krinke | 2009-03-05 04:24:22 +0000 |
commit | 62eaddbe14e0bf5098808294502c14a7ed4063c3 (patch) | |
tree | 66f40f6c448d4f8fd1700160aee2c0cfe2e3ab79 /OpenSim | |
parent | Fixes Mantis #3194. Thank you kindly, Godfrey for a patch that: (diff) | |
download | opensim-SC-62eaddbe14e0bf5098808294502c14a7ed4063c3.zip opensim-SC-62eaddbe14e0bf5098808294502c14a7ed4063c3.tar.gz opensim-SC-62eaddbe14e0bf5098808294502c14a7ed4063c3.tar.bz2 opensim-SC-62eaddbe14e0bf5098808294502c14a7ed4063c3.tar.xz |
Fixes Mantis #3255. Thank you kindly, MCortez, for a patch that:
Changes to IWindModule interface: Change from assuming a single array of
256 Vector2 values to a lookup function that takes region x, y, z and returns a Vector3
* Changed llWind() to use new lookup method of IWindModule
* Moved logic for determining the wind at a given point in the data array from
llWind() to the Wind Module itself.
Diffstat (limited to 'OpenSim')
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 | } |