* Commit patch from cmickeyb. #2871. Optimized float array for the terrain heightfield to reduce cpu usage on new client significantly.

Thanks cmickeyb!
0.6.1-post-fixes
Teravus Ovares 2008-12-19 00:06:19 +00:00
parent c6b2ffb734
commit 7bbda6651e
1 changed files with 12 additions and 4 deletions

View File

@ -108,12 +108,20 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain
public float[] GetFloatsSerialised() public float[] GetFloatsSerialised()
{ {
float[] heights = new float[Width * Height]; // Move the member variables into local variables, calling
int i; // member variables 256*256 times gets expensive
int w = Width;
int h = Height;
float[] heights = new float[w * h];
for (i = 0; i < Width * Height; i++) int i, j; // map coordinates
int idx = 0; // index into serialized array
for (i = 0; i < h; i++)
{ {
heights[i] = (float) map[i % Width, i / Width]; for (j = 0; j < w; j++)
{
heights[idx++] = (float)map[j, i];
}
} }
return heights; return heights;