Fixes Mantis#3301. Thank you kindly, MaimedLeech for a patch that:
patch allows wind to be enabled/disabled, and wind strength set, from ini file0.6.5-rc1
parent
9e0329f1dc
commit
5bc386c648
|
@ -42,9 +42,11 @@ namespace OpenSim.Region.CoreModules
|
||||||
|
|
||||||
private int m_frame = 0;
|
private int m_frame = 0;
|
||||||
private int m_frame_mod = 150;
|
private int m_frame_mod = 150;
|
||||||
private Random rndnums = new Random(Environment.TickCount);
|
private Random m_rndnums = new Random(Environment.TickCount);
|
||||||
private Scene m_scene = null;
|
private Scene m_scene = null;
|
||||||
private bool ready = false;
|
private bool m_ready = false;
|
||||||
|
private float m_strength = 1.0F;
|
||||||
|
private bool m_enabled = true;
|
||||||
|
|
||||||
// Simplified windSpeeds based on the fact that the client protocal tracks at a resolution of 16m
|
// Simplified windSpeeds based on the fact that the client protocal tracks at a resolution of 16m
|
||||||
private Vector2[] windSpeeds = new Vector2[16 * 16];
|
private Vector2[] windSpeeds = new Vector2[16 * 16];
|
||||||
|
@ -53,18 +55,33 @@ namespace OpenSim.Region.CoreModules
|
||||||
|
|
||||||
public void Initialise(Scene scene, IConfigSource config)
|
public void Initialise(Scene scene, IConfigSource config)
|
||||||
{
|
{
|
||||||
m_scene = scene;
|
IConfig windConfig = config.Configs["Wind"];
|
||||||
m_frame = 0;
|
|
||||||
|
|
||||||
scene.EventManager.OnFrame += WindUpdate;
|
if (windConfig != null)
|
||||||
scene.EventManager.OnMakeChildAgent += MakeChildAgent;
|
{
|
||||||
scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
|
m_enabled = windConfig.GetBoolean("enabled", true);
|
||||||
scene.EventManager.OnClientClosed += ClientLoggedOut;
|
m_strength = windConfig.GetFloat("strength", 1.0F);
|
||||||
scene.RegisterModuleInterface<IWindModule>(this);
|
}
|
||||||
|
|
||||||
GenWindPos();
|
if (m_enabled)
|
||||||
|
{
|
||||||
|
|
||||||
|
m_scene = scene;
|
||||||
|
m_frame = 0;
|
||||||
|
|
||||||
|
|
||||||
|
scene.EventManager.OnFrame += WindUpdate;
|
||||||
|
scene.EventManager.OnMakeChildAgent += MakeChildAgent;
|
||||||
|
scene.EventManager.OnAvatarEnteringNewParcel += AvatarEnteringParcel;
|
||||||
|
scene.EventManager.OnClientClosed += ClientLoggedOut;
|
||||||
|
scene.RegisterModuleInterface<IWindModule>(this);
|
||||||
|
|
||||||
|
GenWindPos();
|
||||||
|
|
||||||
|
m_ready = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ready = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PostInitialise()
|
public void PostInitialise()
|
||||||
|
@ -73,13 +90,16 @@ namespace OpenSim.Region.CoreModules
|
||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
ready = false;
|
if (m_enabled)
|
||||||
// Remove our hooks
|
{
|
||||||
m_scene.EventManager.OnFrame -= WindUpdate;
|
m_ready = false;
|
||||||
// m_scene.EventManager.OnNewClient -= SunToClient;
|
// Remove our hooks
|
||||||
m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent;
|
m_scene.EventManager.OnFrame -= WindUpdate;
|
||||||
m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
|
// m_scene.EventManager.OnNewClient -= SunToClient;
|
||||||
m_scene.EventManager.OnClientClosed -= ClientLoggedOut;
|
m_scene.EventManager.OnMakeChildAgent -= MakeChildAgent;
|
||||||
|
m_scene.EventManager.OnAvatarEnteringNewParcel -= AvatarEnteringParcel;
|
||||||
|
m_scene.EventManager.OnClientClosed -= ClientLoggedOut;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string Name
|
public string Name
|
||||||
|
@ -122,7 +142,7 @@ namespace OpenSim.Region.CoreModules
|
||||||
|
|
||||||
public void WindToClient(IClientAPI client)
|
public void WindToClient(IClientAPI client)
|
||||||
{
|
{
|
||||||
if (ready)
|
if (m_ready)
|
||||||
{
|
{
|
||||||
//if (!sunFixed)
|
//if (!sunFixed)
|
||||||
//GenWindPos(); // Generate shared values once
|
//GenWindPos(); // Generate shared values once
|
||||||
|
@ -132,7 +152,7 @@ namespace OpenSim.Region.CoreModules
|
||||||
|
|
||||||
public void WindUpdate()
|
public void WindUpdate()
|
||||||
{
|
{
|
||||||
if (((m_frame++ % m_frame_mod) != 0) || !ready)
|
if (((m_frame++ % m_frame_mod) != 0) || !m_ready)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -182,8 +202,10 @@ namespace OpenSim.Region.CoreModules
|
||||||
{
|
{
|
||||||
for (int x = 0; x < 16; x++)
|
for (int x = 0; x < 16; x++)
|
||||||
{
|
{
|
||||||
windSpeeds[y * 16 + x].X = (float)(rndnums.NextDouble() * 2d - 1d); // -1 to 1
|
windSpeeds[y * 16 + x].X = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1
|
||||||
windSpeeds[y * 16 + x].Y = (float)(rndnums.NextDouble() * 2d - 1d); // -1 to 1
|
windSpeeds[y * 16 + x].Y = (float)(m_rndnums.NextDouble() * 2d - 1d); // -1 to 1
|
||||||
|
windSpeeds[y * 16 + x].X *= m_strength;
|
||||||
|
windSpeeds[y * 16 + x].Y *= m_strength;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue