* Wind updates. Still random.. but in 4 directions instead of two!

* It seems kind of silly to be building a 256x256 array just to use two 16 float blocks..  but for now the layerdata routine requires it so we'll go along with that.
* We only fill a 32x16 area of the 256x256 float array with data.
* We use patches 0,0 and 0,1 for the first and second patch to determine the direction and magnitude of the wind.
0.6.0-stable
Teravus Ovares 2008-09-26 12:56:17 +00:00
parent 92ebbd1420
commit 6b13730bc7
5 changed files with 58 additions and 52 deletions

View File

@ -559,7 +559,7 @@ namespace OpenSim.Framework
void SendLayerData(int px, int py, float[] map); void SendLayerData(int px, int py, float[] map);
void SendWindData(float[] map); void SendWindData(float[] map);
void SendWindData(int px, int py, float[] map); void SendWindData(int p1x, int p1y, int p2x, int p2y, float[] map);
void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look); void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look);
void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint); void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint);

View File

@ -1235,7 +1235,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="map">heightmap</param> /// <param name="map">heightmap</param>
public virtual void SendWindData(float[] map) public virtual void SendWindData(float[] map)
{ {
ThreadPool.QueueUserWorkItem(new WaitCallback(DoSendWindData), (object)map); //ThreadPool.QueueUserWorkItem(new WaitCallback(DoSendWindData), (object)map);
} }
/// <summary> /// <summary>
@ -1244,12 +1244,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="o"></param> /// <param name="o"></param>
private void DoSendWindData(object o) private void DoSendWindData(object o)
{ {
float[] map = (float[])o; //float[] map = (float[])o;
try //try
{ //{
for (int y = 0; y < 16; y++) //for (int y = 0; y < 16; y++)
{ //{
// For some terrains, sending more than one terrain patch at once results in a libsecondlife exception // For some terrains, sending more than one terrain patch at once results in a libsecondlife exception
// see http://opensimulator.org/mantis/view.php?id=1662 // see http://opensimulator.org/mantis/view.php?id=1662
//for (int x = 0; x < 16; x += 4) //for (int x = 0; x < 16; x += 4)
@ -1257,17 +1257,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// SendLayerPacket(map, y, x); // SendLayerPacket(map, y, x);
// Thread.Sleep(150); // Thread.Sleep(150);
//} //}
for (int x = 0; x < 16; x++) // for (int x = 0; x < 16; x++)
{ //{
SendWindData(x, y, map); //SendWindData(x, y, map);
Thread.Sleep(35); //Thread.Sleep(35);
} //}
} //}
} //}
catch (Exception e) //catch (Exception e)
{ //{
m_log.Warn("[CLIENT]: ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); // m_log.Warn("[CLIENT]: ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString());
} // }
} }
/// <summary> /// <summary>
@ -1294,16 +1294,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
/// <param name="px">Patch coordinate (x) 0..15</param> /// <param name="px">Patch coordinate (x) 0..15</param>
/// <param name="py">Patch coordinate (y) 0..15</param> /// <param name="py">Patch coordinate (y) 0..15</param>
/// <param name="map">heightmap</param> /// <param name="map">heightmap</param>
public void SendWindData(int px, int py, float[] map) public void SendWindData(int p1x, int p1y, int p2x, int p2y, float[] map)
{ {
try try
{ {
int[] patches = new int[1]; int[] patches = new int[2];
int patchx, patchy; int patch1x, patch1y, patch2x, patch2y;
patchx = px; patch1x = p1x;
patchy = py; patch1y = p1y;
patch2x = p2x;
patch2y = p2y;
patches[0] = patchx + 0 + patchy * 16;
patches[0] = patch1x + 0 + patch1y * 16;
patches[1] = patch2x + 0 + patch2y * 16;
LayerDataPacket layerpack = TerrainCompressor.CreateWindPacket(map, patches); LayerDataPacket layerpack = TerrainCompressor.CreateWindPacket(map, patches);
layerpack.Header.Zerocoded = true; layerpack.Header.Zerocoded = true;

View File

@ -483,7 +483,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC
} }
public virtual void SendWindData(float[] map) { } public virtual void SendWindData(float[] map) { }
public virtual void SendWindData(int px, int py, float[] map) { } public virtual void SendWindData(int p1x, int p1y, int p2x, int p2y, float[] map) { }
public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
{ {

View File

@ -149,28 +149,11 @@ namespace OpenSim.Region.Environment.Modules
{ {
if (!avatar.IsChildAgent) if (!avatar.IsChildAgent)
{ {
spotxp = (int)avatar.CameraPosition.X + 3;
spotxm = (int)avatar.CameraPosition.X - 3; avatar.ControllingClient.SendWindData(
spotyp = (int)avatar.CameraPosition.Y + 3; 0,
spotym = (int)avatar.CameraPosition.Y - 3; 0,0,1,
if (spotxm < 0) windarr);
spotxm = 0;
if (spotym < 0)
spotym = 0;
if (spotxp > 255)
spotxp = 255;
if (spotyp > 255)
spotyp = 255;
for (int x = spotxm; x<spotxp; x++)
{
for (int y = spotym; y<spotyp; y++)
{
avatar.ControllingClient.SendWindData(
x / Constants.TerrainPatchSize,
y / Constants.TerrainPatchSize,
windarr);
}
}
} }
} }
@ -199,14 +182,33 @@ namespace OpenSim.Region.Environment.Modules
private void GenWindPos() private void GenWindPos()
{ {
windarr = new float[256*256]; //windarr = new float[256*256];
for (int x = 0; x < 256; x++)
Array.Clear(windarr, 0, 256 * 256);
//float i = 0f;
//float i2 = 2f;
for (int x = 0; x < 16; x++)
{ {
for (int y = 0; y < 256; y++) for (int y = 0; y < 16; y++)
{ {
windarr[y*256 + x]= (float)(rndnums.NextDouble()* 2d - 1d);
windarr[x * 256 + y] = (float)(rndnums.NextDouble() * 2d - 1d);
} }
} }
for (int x = 16; x < 32; x++)
{
for (int y = 0; y < 16; y++)
{
windarr[x * 256 + y] = (float)(rndnums.NextDouble() * 2d - 1d);
}
}
// m_log.Debug("[SUN] Velocity("+Velocity.X+","+Velocity.Y+","+Velocity.Z+")"); // m_log.Debug("[SUN] Velocity("+Velocity.X+","+Velocity.Y+","+Velocity.Z+")");
} }

View File

@ -397,7 +397,7 @@ namespace OpenSim.Region.Examples.SimpleModule
} }
public virtual void SendWindData(float[] map) { } public virtual void SendWindData(float[] map) { }
public virtual void SendWindData(int px, int py, float[] map) { } public virtual void SendWindData(int p1x, int p1y, int p2x, int p2y, float[] map) { }
public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
{ {