add load baked terrain methods

LSLKeyTest
UbitUmarov 2016-09-17 16:42:40 +01:00
parent 3f9f105295
commit 71bd3ce49f
7 changed files with 125 additions and 1 deletions

View File

@ -733,6 +733,41 @@ namespace OpenSim.Data.MySQL
return terrData;
}
public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
{
TerrainData terrData = null;
lock (m_dbLock)
{
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{
dbcon.Open();
using (MySqlCommand cmd = dbcon.CreateCommand())
{
cmd.CommandText = "select RegionUUID, Revision, Heightfield " +
"from bakedterrain where RegionUUID = ?RegionUUID ";
cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
using (IDataReader reader = ExecuteReader(cmd))
{
while (reader.Read())
{
int rev = Convert.ToInt32(reader["Revision"]);
if ((reader["Heightfield"] != DBNull.Value))
{
byte[] blob = (byte[])reader["Heightfield"];
terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
}
}
}
}
}
}
return terrData;
}
public virtual void RemoveLandObject(UUID globalID)
{
lock (m_dbLock)

View File

@ -175,6 +175,15 @@ namespace OpenSim.Data.Null
return null;
}
public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
{
if (m_bakedterrains.ContainsKey(regionID))
{
return m_bakedterrains[regionID];
}
return null;
}
public void RemoveLandObject(UUID globalID)
{
}

View File

@ -573,6 +573,39 @@ namespace OpenSim.Data.PGSQL
return terrData;
}
public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
{
TerrainData terrData = null;
string sql = @"select ""RegionUUID"", ""Revision"", ""Heightfield"" from bakedterrain
where ""RegionUUID"" = :RegionUUID; ";
using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
{
using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
{
// PGSqlParameter param = new PGSqlParameter();
cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
conn.Open();
using (NpgsqlDataReader reader = cmd.ExecuteReader())
{
int rev;
if (reader.Read())
{
rev = Convert.ToInt32(reader["Revision"]);
if ((reader["Heightfield"] != DBNull.Value))
{
byte[] blob = (byte[])reader["Heightfield"];
terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
}
}
}
}
}
return terrData;
}
// Legacy entry point for when terrain was always a 256x256 heightmap
public void StoreTerrain(double[,] terrain, UUID regionID)
{

View File

@ -950,6 +950,34 @@ namespace OpenSim.Data.SQLite
return terrData;
}
public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
{
TerrainData terrData = null;
lock (ds)
{
String sql = "select RegionUUID, Revision, Heightfield from backedterrain" +
" where RegionUUID=:RegionUUID";
using (SqliteCommand cmd = new SqliteCommand(sql, m_conn))
{
cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
using (IDataReader row = cmd.ExecuteReader())
{
int rev = 0;
if (row.Read())
{
rev = Convert.ToInt32(row["Revision"]);
byte[] blob = (byte[])row["Heightfield"];
terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
}
}
}
}
return terrData;
}
public void RemoveLandObject(UUID globalID)
{
lock (ds)

View File

@ -93,7 +93,7 @@ namespace OpenSim.Region.Framework.Interfaces
void StoreTerrain(double[,] terrain, UUID regionID);
/// <summary>
/// Load the latest terrain revision from region storage
/// Load terrain from region storage
/// </summary>
/// <param name="regionID">the region UUID</param>
/// <param name="pSizeX">the X dimension of the terrain being filled</param>
@ -101,6 +101,7 @@ namespace OpenSim.Region.Framework.Interfaces
/// <param name="pSizeZ">the Z dimension of the terrain being filled</param>
/// <returns>Heightfield data</returns>
TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
// Legacy version kept for downward compabibility
double[,] LoadTerrain(UUID regionID);

View File

@ -124,6 +124,11 @@ namespace OpenSim.Services.SimulationService
return m_database.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ);
}
public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
{
return m_database.LoadBakedTerrain(regionID, pSizeX, pSizeY, pSizeZ);
}
public void StoreLandObject(ILandObject Parcel)
{
m_database.StoreLandObject(Parcel);

View File

@ -89,6 +89,11 @@ namespace OpenSim.Data.Null
return m_store.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ);
}
public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
{
return m_store.LoadBakedTerrain(regionID, pSizeX, pSizeY, pSizeZ);
}
public void StoreLandObject(ILandObject Parcel)
{
m_store.StoreLandObject(Parcel);
@ -343,6 +348,14 @@ namespace OpenSim.Data.Null
return null;
}
public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
{
if (m_bakedterrains.ContainsKey(regionID))
return m_bakedterrains[regionID];
else
return null;
}
public double[,] LoadTerrain(UUID regionID)
{
if (m_terrains.ContainsKey(regionID))