varregion: move the compressed heighmap compression factor from

Constants into TerrainData.
Save compression factor with the terrain blob in the database.
This commit is contained in:
Robert Adams
2013-10-16 07:52:30 -07:00
parent 86bf79aa2b
commit 97bc5263de
5 changed files with 42 additions and 37 deletions

View File

@@ -74,6 +74,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
#endregion
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly string LogHeader = "[TERRAIN MODULE]";
private readonly Commander m_commander = new Commander("terrain");
@@ -712,7 +713,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
private void CheckForTerrainUpdates(bool respectEstateSettings)
{
bool shouldTaint = false;
float[] terrData = m_channel.GetFloatsSerialised();
float[] terrHeights = m_channel.GetFloatsSerialised();
int x;
for (x = 0; x < m_channel.Width; x += Constants.TerrainPatchSize)
{
@@ -727,10 +728,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain
if (respectEstateSettings && LimitChannelChanges(x, y))
{
// Terrain heights were modified. Refetch the terrain info.
terrData = m_channel.GetFloatsSerialised();
terrHeights = m_channel.GetFloatsSerialised();
}
SendToClients(terrData, x, y);
// m_log.DebugFormat("{0} Patch modified. Sending (x,y) = ({1},{2})", LogHeader, x, y);
SendToClients(terrHeights, x, y);
shouldTaint = true;
}
}

View File

@@ -183,21 +183,6 @@ namespace OpenSim.Region.Framework.Scenes
#endregion
/*
// To save space (especially for large regions), keep the height as a short integer
// that is coded as the float height times the compression factor (usually '100'
// to make for two decimal points).
public static short ToCompressedHeight(double pHeight)
{
return (short)(pHeight * Constants.TerrainCompression);
}
public static float FromCompressedHeight(short pHeight)
{
return ((float)pHeight) / Constants.TerrainCompression;
}
*/
public TerrainChannel Copy()
{
TerrainChannel copy = new TerrainChannel();
@@ -280,13 +265,15 @@ namespace OpenSim.Region.Framework.Scenes
public int SizeX;
public int SizeY;
public int SizeZ;
public float CompressionFactor;
public short[] Map;
public TerrainChannelXMLPackage(int pX, int pY, int pZ, short[] pMap)
public TerrainChannelXMLPackage(int pX, int pY, int pZ, float pCompressionFactor, short[] pMap)
{
Version = 1;
SizeX = pX;
SizeY = pY;
SizeZ = pZ;
CompressionFactor = pCompressionFactor;
Map = pMap;
}
}
@@ -294,7 +281,8 @@ namespace OpenSim.Region.Framework.Scenes
// New terrain serialization format that includes the width and length.
private void ToXml2(XmlWriter xmlWriter)
{
TerrainChannelXMLPackage package = new TerrainChannelXMLPackage(Width, Height, Altitude, m_terrainData.GetCompressedMap());
TerrainChannelXMLPackage package = new TerrainChannelXMLPackage(Width, Height, Altitude, m_terrainData.CompressionFactor,
m_terrainData.GetCompressedMap());
XmlSerializer serializer = new XmlSerializer(typeof(TerrainChannelXMLPackage));
serializer.Serialize(xmlWriter, package);
}
@@ -304,7 +292,7 @@ namespace OpenSim.Region.Framework.Scenes
{
XmlSerializer serializer = new XmlSerializer(typeof(TerrainChannelXMLPackage));
TerrainChannelXMLPackage package = (TerrainChannelXMLPackage)serializer.Deserialize(xmlReader);
m_terrainData = new HeightmapTerrainData(package.Map, package.SizeX, package.SizeY, package.SizeZ);
m_terrainData = new HeightmapTerrainData(package.Map, package.CompressionFactor, package.SizeX, package.SizeY, package.SizeZ);
}
// Fill the heightmap with the center bump terrain

View File

@@ -112,7 +112,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
// This is an intermediate step in converting terrain into a variable sized heightmap. Some of the
// routines (like IClientAPI) only pass the float array of heights around. This entry
// converts that legacy representation into the more compact represenation used in
// TerrainChannel. Someday fix the plumbing between here and the scene.
// TerrainData. Someday fix the plumbing between here and the scene.
public static LayerDataPacket CreateLandPacket(TerrainData terrData, int patchX, int patchY)
{
int[] xPieces = new int[1];