* 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.
parent
64dcb71c14
commit
e1b38ff001
|
@ -549,6 +549,8 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
|
|
||||||
|
if (x_float > Constants.RegionSize || x_float <= 0 || y_float > Constants.RegionSize || y_float <= 0)
|
||||||
|
return null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / 4.0));
|
x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / 4.0));
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
public Type ReplacableInterface { get { return null; } }
|
public Type ReplacableInterface { get { return null; } }
|
||||||
|
|
||||||
private Dictionary<UUID, RegionConnections> m_regions = new Dictionary<UUID, RegionConnections>();
|
private Dictionary<UUID, RegionConnections> m_regions = new Dictionary<UUID, RegionConnections>();
|
||||||
|
private bool enabledYN = true;
|
||||||
public void Initialise(IConfigSource source)
|
public void Initialise(IConfigSource source)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -35,12 +36,9 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
|
|
||||||
public void AddRegion(Scene scene)
|
public void AddRegion(Scene scene)
|
||||||
{
|
{
|
||||||
/*
|
if (!enabledYN)
|
||||||
RegionData regionData = new RegionData();
|
return;
|
||||||
regionData.Offset = Vector3.Zero;
|
|
||||||
regionData.RegionId = scene.RegionInfo.originRegionID;
|
|
||||||
regionData.RegionScene = scene;
|
|
||||||
*/
|
|
||||||
RegionConnections regionConnections = new RegionConnections();
|
RegionConnections regionConnections = new RegionConnections();
|
||||||
regionConnections.ConnectedRegions = new List<RegionData>();
|
regionConnections.ConnectedRegions = new List<RegionData>();
|
||||||
regionConnections.RegionScene = scene;
|
regionConnections.RegionScene = scene;
|
||||||
|
@ -55,12 +53,12 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
|
|
||||||
foreach (RegionConnections conn in m_regions.Values)
|
foreach (RegionConnections conn in m_regions.Values)
|
||||||
{
|
{
|
||||||
|
#region commented
|
||||||
/*
|
/*
|
||||||
// If we're one region over +x +y
|
// If we're one region over +x +y
|
||||||
//xxx
|
|
||||||
//xxx
|
|
||||||
//xxy
|
//xxy
|
||||||
|
//xxx
|
||||||
|
//xxx
|
||||||
if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd
|
if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd
|
||||||
== (regionConnections.X * (int)Constants.RegionSize))
|
== (regionConnections.X * (int)Constants.RegionSize))
|
||||||
&& (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd
|
&& (((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
|
// If we're one region over +x y
|
||||||
//xxx
|
//xxx
|
||||||
//xxy
|
//xxy
|
||||||
|
@ -197,49 +227,37 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
((conn.Y * (int)Constants.RegionSize)));
|
((conn.Y * (int)Constants.RegionSize)));
|
||||||
|
|
||||||
Vector3 extents = Vector3.Zero;
|
Vector3 extents = Vector3.Zero;
|
||||||
extents.Y = regionConnections.YEnd;
|
extents.Y = conn.YEnd;
|
||||||
extents.X = conn.XEnd + conn.XEnd;
|
extents.X = conn.XEnd + regionConnections.XEnd;
|
||||||
|
|
||||||
|
conn.UpdateExtents(extents);
|
||||||
|
|
||||||
|
|
||||||
m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}",
|
m_log.DebugFormat("Scene: {0} to the west of Scene{1} Offset: {2}. Extents:{3}",
|
||||||
conn.RegionScene.RegionInfo.RegionName,
|
conn.RegionScene.RegionInfo.RegionName,
|
||||||
regionConnections.RegionScene.RegionInfo.RegionName, offset, extents);
|
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;
|
connectedYN = true;
|
||||||
break;
|
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}",
|
// If we're one region over x +y
|
||||||
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
|
|
||||||
//xyx
|
//xyx
|
||||||
//xxx
|
//xxx
|
||||||
//xxx
|
//xxx
|
||||||
|
@ -257,12 +275,12 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
Vector3 extents = Vector3.Zero;
|
Vector3 extents = Vector3.Zero;
|
||||||
extents.Y = regionConnections.YEnd + conn.YEnd;
|
extents.Y = regionConnections.YEnd + conn.YEnd;
|
||||||
extents.X = conn.XEnd;
|
extents.X = conn.XEnd;
|
||||||
|
conn.UpdateExtents(extents);
|
||||||
|
|
||||||
m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}",
|
m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}",
|
||||||
conn.RegionScene.RegionInfo.RegionName,
|
conn.RegionScene.RegionInfo.RegionName,
|
||||||
regionConnections.RegionScene.RegionInfo.RegionName, offset, extents);
|
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);
|
scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, Vector3.Zero);
|
||||||
|
|
||||||
conn.RegionScene.NorthBorders[0].BorderLine.Z += (int)Constants.RegionSize;
|
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
|
scene.SouthBorders[0].BorderLine.Z += (int)Constants.RegionSize; //auto teleport south
|
||||||
|
|
||||||
// Reset Terrain.. since terrain normally loads first.
|
// 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());
|
scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
|
||||||
|
//conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
|
||||||
|
|
||||||
connectedYN = true;
|
connectedYN = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're one region over +x -y
|
// If we're one region over +x +y
|
||||||
//xxy
|
//xxy
|
||||||
//xxx
|
//xxx
|
||||||
//xxx
|
//xxx
|
||||||
|
@ -334,7 +353,7 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct RegionConnections
|
public class RegionConnections
|
||||||
{
|
{
|
||||||
public UUID RegionId;
|
public UUID RegionId;
|
||||||
public Scene RegionScene;
|
public Scene RegionScene;
|
||||||
|
@ -343,6 +362,11 @@ namespace OpenSim.Region.CoreModules.World.Land
|
||||||
public int XEnd;
|
public int XEnd;
|
||||||
public int YEnd;
|
public int YEnd;
|
||||||
public List<RegionData> ConnectedRegions;
|
public List<RegionData> ConnectedRegions;
|
||||||
|
public void UpdateExtents(Vector3 extents)
|
||||||
|
{
|
||||||
|
XEnd = (int)extents.X;
|
||||||
|
YEnd = (int)extents.Y;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -227,7 +227,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
public int bodyFramesAutoDisable = 20;
|
public int bodyFramesAutoDisable = 20;
|
||||||
|
|
||||||
private float[] _heightmap;
|
|
||||||
|
|
||||||
private float[] _watermap;
|
private float[] _watermap;
|
||||||
private bool m_filterCollisions = true;
|
private bool m_filterCollisions = true;
|
||||||
|
@ -351,11 +351,7 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
#endif
|
#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];
|
_watermap = new float[258 * 258];
|
||||||
|
|
||||||
// Zero out the prim spaces array (we split our space into smaller spaces so
|
// Zero out the prim spaces array (we split our space into smaller spaces so
|
||||||
|
@ -3335,6 +3331,15 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
// dbm (danx0r) -- creating a buffer zone of one extra sample all around
|
// dbm (danx0r) -- creating a buffer zone of one extra sample all around
|
||||||
//_origheightmap = heightMap;
|
//_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 heightmapWidth = Constants.RegionSize + 1;
|
||||||
uint heightmapHeight = Constants.RegionSize + 1;
|
uint heightmapHeight = Constants.RegionSize + 1;
|
||||||
|
|
||||||
|
@ -3342,19 +3347,19 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
uint heightmapHeightSamples;
|
uint heightmapHeightSamples;
|
||||||
|
|
||||||
if (((int)Constants.RegionSize) == 256)
|
//if (((int)Constants.RegionSize) == 256)
|
||||||
{
|
//{
|
||||||
heightmapWidthSamples = 2 * (uint)Constants.RegionSize + 2;
|
// heightmapWidthSamples = 2 * (uint)Constants.RegionSize + 2;
|
||||||
heightmapHeightSamples = 2 * (uint)Constants.RegionSize + 2;
|
// heightmapHeightSamples = 2 * (uint)Constants.RegionSize + 2;
|
||||||
heightmapWidth++;
|
// heightmapWidth++;
|
||||||
heightmapHeight++;
|
// heightmapHeight++;
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
|
|
||||||
heightmapWidthSamples = (uint)Constants.RegionSize + 1;
|
heightmapWidthSamples = (uint)Constants.RegionSize + 1;
|
||||||
heightmapHeightSamples = (uint)Constants.RegionSize + 1;
|
heightmapHeightSamples = (uint)Constants.RegionSize + 1;
|
||||||
}
|
//}
|
||||||
|
|
||||||
const float scale = 1.0f;
|
const float scale = 1.0f;
|
||||||
const float offset = 0.0f;
|
const float offset = 0.0f;
|
||||||
|
@ -3363,12 +3368,12 @@ namespace OpenSim.Region.Physics.OdePlugin
|
||||||
|
|
||||||
int regionsize = (int) Constants.RegionSize;
|
int regionsize = (int) Constants.RegionSize;
|
||||||
//Double resolution
|
//Double resolution
|
||||||
if (((int)Constants.RegionSize) == 256)
|
//if (((int)Constants.RegionSize) == 256)
|
||||||
heightMap = ResizeTerrain512Interpolation(heightMap);
|
// heightMap = ResizeTerrain512Interpolation(heightMap);
|
||||||
|
|
||||||
|
|
||||||
if (((int)Constants.RegionSize) == 256 && (int)Constants.RegionSize == 256)
|
// if (((int)Constants.RegionSize) == 256 && (int)Constants.RegionSize == 256)
|
||||||
regionsize = 512;
|
// regionsize = 512;
|
||||||
|
|
||||||
float hfmin = 2000;
|
float hfmin = 2000;
|
||||||
float hfmax = -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.RFromAxisAndAngle(out R, v3.X, v3.Y, v3.Z, angle);
|
||||||
d.GeomSetRotation(GroundGeom, ref R);
|
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;
|
IntPtr testGround = IntPtr.Zero;
|
||||||
if (RegionTerrain.TryGetValue(pOffset, out testGround))
|
if (RegionTerrain.TryGetValue(pOffset, out testGround))
|
||||||
{
|
{
|
||||||
RegionTerrain.Remove(pOffset);
|
RegionTerrain.Remove(pOffset);
|
||||||
}
|
}
|
||||||
RegionTerrain.Add(pOffset, GroundGeom, GroundGeom);
|
RegionTerrain.Add(pOffset, GroundGeom, GroundGeom);
|
||||||
TerrainHeightFieldHeights.Add(GroundGeom,heightMap);
|
TerrainHeightFieldHeights.Add(GroundGeom,_heightmap);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue