* It turns out that Physics heightmap values were being stored in managed memory in _heightmap and using multiple heightmaps caused them all to overwrite each other and the last one was the heightmap for all of the regions. This fixes that. It also reduces the terrain resolution to half.

remotes/origin/0.6.7-post-fixes
Teravus Ovares (Dan Olivares) 2009-08-21 13:22:49 -04:00
parent 64dcb71c14
commit e1b38ff001
3 changed files with 98 additions and 67 deletions

View File

@ -549,6 +549,8 @@ namespace OpenSim.Region.CoreModules.World.Land
int x;
int y;
if (x_float > Constants.RegionSize || x_float <= 0 || y_float > Constants.RegionSize || y_float <= 0)
return null;
try
{
x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / 4.0));

View File

@ -23,6 +23,7 @@ namespace OpenSim.Region.CoreModules.World.Land
public Type ReplacableInterface { get { return null; } }
private Dictionary<UUID, RegionConnections> m_regions = new Dictionary<UUID, RegionConnections>();
private bool enabledYN = true;
public void Initialise(IConfigSource source)
{
@ -35,12 +36,9 @@ namespace OpenSim.Region.CoreModules.World.Land
public void AddRegion(Scene scene)
{
/*
RegionData regionData = new RegionData();
regionData.Offset = Vector3.Zero;
regionData.RegionId = scene.RegionInfo.originRegionID;
regionData.RegionScene = scene;
*/
if (!enabledYN)
return;
RegionConnections regionConnections = new RegionConnections();
regionConnections.ConnectedRegions = new List<RegionData>();
regionConnections.RegionScene = scene;
@ -55,12 +53,12 @@ namespace OpenSim.Region.CoreModules.World.Land
foreach (RegionConnections conn in m_regions.Values)
{
#region commented
/*
// If we're one region over +x +y
//xxx
//xxx
//xxy
//xxx
//xxx
if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd
== (regionConnections.X * (int)Constants.RegionSize))
&& (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd
@ -181,6 +179,38 @@ namespace OpenSim.Region.CoreModules.World.Land
}
*/
/*
// If we're one region over -x -y
//yxx
//xxx
//xxx
if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd
== (regionConnections.X * (int)Constants.RegionSize))
&& (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd
== (regionConnections.Y * (int)Constants.RegionSize)))
{
Vector3 offset = Vector3.Zero;
offset.X = (((regionConnections.X * (int)Constants.RegionSize)) -
((conn.X * (int)Constants.RegionSize)));
offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) -
((conn.Y * (int)Constants.RegionSize)));
Vector3 extents = Vector3.Zero;
extents.Y = regionConnections.YEnd + conn.YEnd;
extents.X = conn.XEnd + conn.XEnd;
m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}",
conn.RegionScene.RegionInfo.RegionName,
regionConnections.RegionScene.RegionInfo.RegionName, offset, extents);
scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents);
connectedYN = true;
break;
}
*/
#endregion
// If we're one region over +x y
//xxx
//xxy
@ -197,49 +227,37 @@ namespace OpenSim.Region.CoreModules.World.Land
((conn.Y * (int)Constants.RegionSize)));
Vector3 extents = Vector3.Zero;
extents.Y = regionConnections.YEnd;
extents.X = conn.XEnd + conn.XEnd;
extents.Y = conn.YEnd;
extents.X = conn.XEnd + regionConnections.XEnd;
conn.UpdateExtents(extents);
m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}",
conn.RegionScene.RegionInfo.RegionName,
regionConnections.RegionScene.RegionInfo.RegionName, offset, extents);
scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents);
conn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents);
scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero);
conn.RegionScene.EastBorders[0].BorderLine.Z += (int)Constants.RegionSize;
conn.RegionScene.NorthBorders[0].BorderLine.Y += (int)Constants.RegionSize;
conn.RegionScene.SouthBorders[0].BorderLine.Y += (int)Constants.RegionSize;
scene.WestBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport West
// Reset Terrain.. since terrain normally loads first.
//
scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
//conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
connectedYN = true;
break;
}
// If we're one region over -x -y
//yxx
//xxx
//xxx
if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd
== (regionConnections.X * (int)Constants.RegionSize))
&& (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd
== (regionConnections.Y * (int)Constants.RegionSize)))
{
Vector3 offset = Vector3.Zero;
offset.X = (((regionConnections.X * (int)Constants.RegionSize)) -
((conn.X * (int)Constants.RegionSize)));
offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) -
((conn.Y * (int)Constants.RegionSize)));
Vector3 extents = Vector3.Zero;
extents.Y = regionConnections.YEnd + conn.YEnd;
extents.X = conn.XEnd + conn.XEnd;
m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}",
conn.RegionScene.RegionInfo.RegionName,
regionConnections.RegionScene.RegionInfo.RegionName, offset, extents);
scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents);
connectedYN = true;
break;
}
// If we're one region over x -y
// If we're one region over x +y
//xyx
//xxx
//xxx
@ -257,12 +275,12 @@ namespace OpenSim.Region.CoreModules.World.Land
Vector3 extents = Vector3.Zero;
extents.Y = regionConnections.YEnd + conn.YEnd;
extents.X = conn.XEnd;
conn.UpdateExtents(extents);
m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}",
conn.RegionScene.RegionInfo.RegionName,
regionConnections.RegionScene.RegionInfo.RegionName, offset, extents);
conn.RegionScene.PhysicsScene.Combine(scene.PhysicsScene,Vector3.Zero,extents);
conn.RegionScene.PhysicsScene.Combine(null,Vector3.Zero,extents);
scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero);
conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize;
@ -272,14 +290,15 @@ namespace OpenSim.Region.CoreModules.World.Land
scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south
// Reset Terrain.. since terrain normally loads first.
conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
//conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
//conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
connectedYN = true;
break;
}
// If we're one region over +x -y
// If we're one region over +x +y
//xxy
//xxx
//xxx
@ -334,7 +353,7 @@ namespace OpenSim.Region.CoreModules.World.Land
}
}
public struct RegionConnections
public class RegionConnections
{
public UUID RegionId;
public Scene RegionScene;
@ -343,6 +362,11 @@ namespace OpenSim.Region.CoreModules.World.Land
public int XEnd;
public int YEnd;
public List<RegionData> ConnectedRegions;
public void UpdateExtents(Vector3 extents)
{
XEnd = (int)extents.X;
YEnd = (int)extents.Y;
}
}

View File

@ -227,7 +227,7 @@ namespace OpenSim.Region.Physics.OdePlugin
public int bodyFramesAutoDisable = 20;
private float[] _heightmap;
private float[] _watermap;
private bool m_filterCollisions = true;
@ -351,11 +351,7 @@ namespace OpenSim.Region.Physics.OdePlugin
#endif
}
// zero out a heightmap array float array (single dimension [flattened]))
if ((int)Constants.RegionSize == 256)
_heightmap = new float[514*514];
else
_heightmap = new float[(((int)WorldExtents.Y + 2) * ((int)WorldExtents.X + 2))];
_watermap = new float[258 * 258];
// Zero out the prim spaces array (we split our space into smaller spaces so
@ -3334,6 +3330,15 @@ namespace OpenSim.Region.Physics.OdePlugin
// this._heightmap[i] = (double)heightMap[i];
// dbm (danx0r) -- creating a buffer zone of one extra sample all around
//_origheightmap = heightMap;
float[] _heightmap;
// zero out a heightmap array float array (single dimension [flattened]))
//if ((int)Constants.RegionSize == 256)
// _heightmap = new float[514 * 514];
//else
_heightmap = new float[(((int)Constants.RegionSize + 2) * ((int)Constants.RegionSize + 2))];
uint heightmapWidth = Constants.RegionSize + 1;
uint heightmapHeight = Constants.RegionSize + 1;
@ -3342,19 +3347,19 @@ namespace OpenSim.Region.Physics.OdePlugin
uint heightmapHeightSamples;
if (((int)Constants.RegionSize) == 256)
{
heightmapWidthSamples = 2 * (uint)Constants.RegionSize + 2;
heightmapHeightSamples = 2 * (uint)Constants.RegionSize + 2;
heightmapWidth++;
heightmapHeight++;
}
else
{
//if (((int)Constants.RegionSize) == 256)
//{
// heightmapWidthSamples = 2 * (uint)Constants.RegionSize + 2;
// heightmapHeightSamples = 2 * (uint)Constants.RegionSize + 2;
// heightmapWidth++;
// heightmapHeight++;
//}
//else
//{
heightmapWidthSamples = (uint)Constants.RegionSize + 1;
heightmapHeightSamples = (uint)Constants.RegionSize + 1;
}
//}
const float scale = 1.0f;
const float offset = 0.0f;
@ -3363,12 +3368,12 @@ namespace OpenSim.Region.Physics.OdePlugin
int regionsize = (int) Constants.RegionSize;
//Double resolution
if (((int)Constants.RegionSize) == 256)
heightMap = ResizeTerrain512Interpolation(heightMap);
//if (((int)Constants.RegionSize) == 256)
// heightMap = ResizeTerrain512Interpolation(heightMap);
if (((int)Constants.RegionSize) == 256 && (int)Constants.RegionSize == 256)
regionsize = 512;
// if (((int)Constants.RegionSize) == 256 && (int)Constants.RegionSize == 256)
// regionsize = 512;
float hfmin = 2000;
float hfmax = -2000;
@ -3431,14 +3436,14 @@ namespace OpenSim.Region.Physics.OdePlugin
d.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
d.GeomSetRotation(GroundGeom, ref R);
d.GeomSetPosition(GroundGeom, pOffset.X + ((int)Constants.RegionSize * 0.5f), (pOffset.Y + (int)Constants.RegionSize * 0.5f), 0);
d.GeomSetPosition(GroundGeom, pOffset.X + ((int)Constants.RegionSize * 0.5f), pOffset.Y + ((int)Constants.RegionSize * 0.5f), 0);
IntPtr testGround = IntPtr.Zero;
if (RegionTerrain.TryGetValue(pOffset, out testGround))
{
RegionTerrain.Remove(pOffset);
}
RegionTerrain.Add(pOffset, GroundGeom, GroundGeom);
TerrainHeightFieldHeights.Add(GroundGeom,heightMap);
TerrainHeightFieldHeights.Add(GroundGeom,_heightmap);
}
}