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.0.6.4-rc1
parent
365b5951ff
commit
62eaddbe14
|
@ -45,7 +45,10 @@ namespace OpenSim.Region.CoreModules
|
|||
private Random rndnums = new Random(Environment.TickCount);
|
||||
private Scene m_scene = null;
|
||||
private bool ready = false;
|
||||
|
||||
// Simplified windSpeeds based on the fact that the client protocal tracks at a resolution of 16m
|
||||
private Vector2[] windSpeeds = new Vector2[16 * 16];
|
||||
|
||||
private Dictionary<UUID, ulong> m_rootAgents = new Dictionary<UUID, ulong>();
|
||||
|
||||
public void Initialise(Scene scene, IConfigSource config)
|
||||
|
@ -89,9 +92,32 @@ namespace OpenSim.Region.CoreModules
|
|||
get { return false; }
|
||||
}
|
||||
|
||||
public Vector2[] WindSpeeds
|
||||
/// <summary>
|
||||
/// Retrieve the wind speed at the given region coordinate. This
|
||||
/// implimentation ignores Z.
|
||||
/// </summary>
|
||||
/// <param name="x">0...255</param>
|
||||
/// <param name="y">0...255</param>
|
||||
/// <returns></returns>
|
||||
public Vector3 WindSpeed(int x, int y, int z)
|
||||
{
|
||||
get { return windSpeeds; }
|
||||
Vector3 windVector = new Vector3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
x /= 16;
|
||||
y /= 16;
|
||||
if (x < 0) x = 0;
|
||||
if (x > 15) x = 15;
|
||||
if (y < 0) y = 0;
|
||||
if (y > 15) y = 15;
|
||||
|
||||
if (windSpeeds != null)
|
||||
{
|
||||
windVector.X = windSpeeds[y * 16 + x].X;
|
||||
windVector.Y = windSpeeds[y * 16 + x].Y;
|
||||
}
|
||||
|
||||
|
||||
return windVector;
|
||||
}
|
||||
|
||||
public void WindToClient(IClientAPI client)
|
||||
|
|
|
@ -31,9 +31,10 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
{
|
||||
public interface IWindModule : IRegionModule
|
||||
{
|
||||
Vector2[] WindSpeeds
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the current wind speed at the given Region Coordinates
|
||||
/// </summary>
|
||||
Vector3 WindSpeed(int x, int y, int z);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1031,17 +1031,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
m_host.AddScriptLPS(1);
|
||||
LSL_Vector wind = new LSL_Vector(0, 0, 0);
|
||||
IWindModule module = World.RequestModuleInterface<IWindModule>();
|
||||
if (module != null && module.WindSpeeds != null)
|
||||
if (module != null)
|
||||
{
|
||||
Vector3 pos = m_host.GetWorldPosition();
|
||||
int x = (int)((pos.X + offset.x)/ 16);
|
||||
int y = (int)((pos.Y + offset.y)/ 16);
|
||||
if (x < 0) x = 0;
|
||||
if (x > 15) x = 15;
|
||||
if (y < 0) y = 0;
|
||||
if (y > 15) y = 15;
|
||||
wind.x = module.WindSpeeds[y * 16 + x].X;
|
||||
wind.y = module.WindSpeeds[y * 16 + x].Y;
|
||||
int x = (int)(pos.X + offset.x);
|
||||
int y = (int)(pos.Y + offset.y);
|
||||
|
||||
Vector3 windSpeed = module.WindSpeed(x, y, 0);
|
||||
|
||||
wind.x = windSpeed.X;
|
||||
wind.y = windSpeed.Y;
|
||||
}
|
||||
return wind;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue