From 3f9f10529548599d1810ca8a630734586ed3fa9d Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 17 Sep 2016 15:45:11 +0100
Subject: add to databases a table to store baked terrain.
---
OpenSim/Data/PGSQL/PGSQLSimulationData.cs | 43 ++++++++++++++++++++++
.../Data/PGSQL/Resources/RegionStore.migrations | 13 +++++++
2 files changed, 56 insertions(+)
(limited to 'OpenSim/Data/PGSQL')
diff --git a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
index 25e1a7f..e6161a2 100755
--- a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
@@ -624,6 +624,49 @@ namespace OpenSim.Data.PGSQL
}
///
+ /// Stores the baked terrain map to DB.
+ ///
+ /// terrain map data.
+ /// regionID.
+ public void StoreBakedTerrain(TerrainData terrData, UUID regionID)
+ {
+ //Delete old terrain map
+ string sql = @"delete from bakedterrain where ""RegionUUID""=:RegionUUID";
+ using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
+ {
+ using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
+ {
+ cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
+ conn.Open();
+ cmd.ExecuteNonQuery();
+
+ _Log.InfoFormat("{0} Deleted bakedterrain id = {1}", LogHeader, regionID);
+ }
+ }
+
+ int terrainDBRevision;
+ Array terrainDBblob;
+ terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
+
+ sql = @"insert into bakedterrain(""RegionUUID"", ""Revision"", ""Heightfield"") values(:RegionUUID, :Revision, :Heightfield)";
+
+ using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
+ {
+ using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
+ {
+ cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
+ cmd.Parameters.Add(_Database.CreateParameter("Revision", terrainDBRevision));
+ cmd.Parameters.Add(_Database.CreateParameter("Heightfield", terrainDBblob));
+ conn.Open();
+ cmd.ExecuteNonQuery();
+
+ _Log.InfoFormat("{0} Stored bakedterrain id = {1}, terrainSize = <{2},{3}>",
+ LogHeader, regionID, terrData.SizeX, terrData.SizeY);
+ }
+ }
+ }
+
+ ///
/// Loads all the land objects of a region.
///
/// The region UUID.
diff --git a/OpenSim/Data/PGSQL/Resources/RegionStore.migrations b/OpenSim/Data/PGSQL/Resources/RegionStore.migrations
index 9a2c19b..c085939 100644
--- a/OpenSim/Data/PGSQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/PGSQL/Resources/RegionStore.migrations
@@ -1182,3 +1182,16 @@ BEGIN TRANSACTION;
ALTER TABLE prims ADD "RotationAxisLocks" smallint NOT NULL DEFAULT (0);
COMMIT;
+
+:VERSION 44 #---- add baked terrain store
+
+BEGIN TRANSACTION;
+
+CREATE TABLE bakedterrain
+ (
+ "RegionUUID" uuid NULL,
+ "Revision" int NULL,
+ "Heightfield" bytea NULL
+ );
+
+COMMIT;
--
cgit v1.1