aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorUbitUmarov2016-09-18 20:02:59 +0100
committerUbitUmarov2016-09-18 20:02:59 +0100
commit82997c5907bcb0591b815ed9343e9d2c56ba5710 (patch)
tree699c875eb48f6efa3ca2c8b5d22315df20b5130f /OpenSim
parentMerge branch 'master' into httptests (diff)
parentfix typo in table name, thx tglion (diff)
downloadopensim-SC-82997c5907bcb0591b815ed9343e9d2c56ba5710.zip
opensim-SC-82997c5907bcb0591b815ed9343e9d2c56ba5710.tar.gz
opensim-SC-82997c5907bcb0591b815ed9343e9d2c56ba5710.tar.bz2
opensim-SC-82997c5907bcb0591b815ed9343e9d2c56ba5710.tar.xz
Merge branch 'master' into httptests
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/MySQL/MySQLSimulationData.cs82
-rw-r--r--OpenSim/Data/MySQL/Resources/RegionStore.migrations11
-rw-r--r--OpenSim/Data/Null/NullSimulationData.cs17
-rwxr-xr-xOpenSim/Data/PGSQL/PGSQLSimulationData.cs76
-rw-r--r--OpenSim/Data/PGSQL/Resources/RegionStore.migrations13
-rw-r--r--OpenSim/Data/SQLite/Resources/RegionStore.migrations11
-rw-r--r--OpenSim/Data/SQLite/SQLiteSimulationData.cs74
-rw-r--r--OpenSim/Framework/TerrainData.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs21
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs10
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs13
-rwxr-xr-xOpenSim/Region/Framework/Scenes/Scene.cs62
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs1
-rw-r--r--OpenSim/Services/SimulationService/SimulationDataService.cs10
-rw-r--r--OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs24
15 files changed, 403 insertions, 26 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs
index 46364a5..ab24b76 100644
--- a/OpenSim/Data/MySQL/MySQLSimulationData.cs
+++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs
@@ -639,6 +639,53 @@ namespace OpenSim.Data.MySQL
639 }); 639 });
640 } 640 }
641 641
642 public void StoreBakedTerrain(TerrainData terrData, UUID regionID)
643 {
644 Util.FireAndForget(delegate(object x)
645 {
646 m_log.Info("[REGION DB]: Storing Baked terrain");
647
648 lock (m_dbLock)
649 {
650 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
651 {
652 dbcon.Open();
653
654 using (MySqlCommand cmd = dbcon.CreateCommand())
655 {
656 cmd.CommandText = "delete from bakedterrain where RegionUUID = ?RegionUUID";
657 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
658
659 using (MySqlCommand cmd2 = dbcon.CreateCommand())
660 {
661 try
662 {
663 cmd2.CommandText = "insert into bakedterrain (RegionUUID, " +
664 "Revision, Heightfield) values (?RegionUUID, " +
665 "?Revision, ?Heightfield)";
666
667 int terrainDBRevision;
668 Array terrainDBblob;
669 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
670
671 cmd2.Parameters.AddWithValue("RegionUUID", regionID.ToString());
672 cmd2.Parameters.AddWithValue("Revision", terrainDBRevision);
673 cmd2.Parameters.AddWithValue("Heightfield", terrainDBblob);
674
675 ExecuteNonQuery(cmd);
676 ExecuteNonQuery(cmd2);
677 }
678 catch (Exception e)
679 {
680 m_log.ErrorFormat(e.ToString());
681 }
682 }
683 }
684 }
685 }
686 });
687 }
688
642 // Legacy region loading 689 // Legacy region loading
643 public virtual double[,] LoadTerrain(UUID regionID) 690 public virtual double[,] LoadTerrain(UUID regionID)
644 { 691 {
@@ -686,6 +733,41 @@ namespace OpenSim.Data.MySQL
686 return terrData; 733 return terrData;
687 } 734 }
688 735
736 public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
737 {
738 TerrainData terrData = null;
739
740 lock (m_dbLock)
741 {
742 using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
743 {
744 dbcon.Open();
745
746 using (MySqlCommand cmd = dbcon.CreateCommand())
747 {
748 cmd.CommandText = "select RegionUUID, Revision, Heightfield " +
749 "from bakedterrain where RegionUUID = ?RegionUUID ";
750 cmd.Parameters.AddWithValue("RegionUUID", regionID.ToString());
751
752 using (IDataReader reader = ExecuteReader(cmd))
753 {
754 while (reader.Read())
755 {
756 int rev = Convert.ToInt32(reader["Revision"]);
757 if ((reader["Heightfield"] != DBNull.Value))
758 {
759 byte[] blob = (byte[])reader["Heightfield"];
760 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
761 }
762 }
763 }
764 }
765 }
766 }
767
768 return terrData;
769 }
770
689 public virtual void RemoveLandObject(UUID globalID) 771 public virtual void RemoveLandObject(UUID globalID)
690 { 772 {
691 lock (m_dbLock) 773 lock (m_dbLock)
diff --git a/OpenSim/Data/MySQL/Resources/RegionStore.migrations b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
index c32f645..1de5a01 100644
--- a/OpenSim/Data/MySQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/MySQL/Resources/RegionStore.migrations
@@ -379,3 +379,14 @@ ALTER TABLE `prims` ADD COLUMN `RotationAxisLocks` tinyint(4) NOT NULL default '
379 379
380COMMIT; 380COMMIT;
381 381
382:VERSION 54 #----- add baked terrain store
383
384BEGIN;
385
386CREATE TABLE IF NOT EXISTS `bakedterrain` (
387 `RegionUUID` varchar(255) DEFAULT NULL,
388 `Revision` int(11) DEFAULT NULL,
389 `Heightfield` longblob
390) ENGINE=InnoDB DEFAULT CHARSET=utf8;
391
392COMMIT;
diff --git a/OpenSim/Data/Null/NullSimulationData.cs b/OpenSim/Data/Null/NullSimulationData.cs
index 339e7f4..7bb6da3 100644
--- a/OpenSim/Data/Null/NullSimulationData.cs
+++ b/OpenSim/Data/Null/NullSimulationData.cs
@@ -133,6 +133,7 @@ namespace OpenSim.Data.Null
133 } 133 }
134 134
135 Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>(); 135 Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>();
136 Dictionary<UUID, TerrainData> m_bakedterrains = new Dictionary<UUID, TerrainData>();
136 public void StoreTerrain(TerrainData ter, UUID regionID) 137 public void StoreTerrain(TerrainData ter, UUID regionID)
137 { 138 {
138 if (m_terrains.ContainsKey(regionID)) 139 if (m_terrains.ContainsKey(regionID))
@@ -140,6 +141,13 @@ namespace OpenSim.Data.Null
140 m_terrains.Add(regionID, ter); 141 m_terrains.Add(regionID, ter);
141 } 142 }
142 143
144 public void StoreBakedTerrain(TerrainData ter, UUID regionID)
145 {
146 if (m_bakedterrains.ContainsKey(regionID))
147 m_bakedterrains.Remove(regionID);
148 m_bakedterrains.Add(regionID, ter);
149 }
150
143 // Legacy. Just don't do this. 151 // Legacy. Just don't do this.
144 public void StoreTerrain(double[,] ter, UUID regionID) 152 public void StoreTerrain(double[,] ter, UUID regionID)
145 { 153 {
@@ -167,6 +175,15 @@ namespace OpenSim.Data.Null
167 return null; 175 return null;
168 } 176 }
169 177
178 public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
179 {
180 if (m_bakedterrains.ContainsKey(regionID))
181 {
182 return m_bakedterrains[regionID];
183 }
184 return null;
185 }
186
170 public void RemoveLandObject(UUID globalID) 187 public void RemoveLandObject(UUID globalID)
171 { 188 {
172 } 189 }
diff --git a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
index 25e1a7f..902aae0 100755
--- a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
+++ b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs
@@ -573,6 +573,39 @@ namespace OpenSim.Data.PGSQL
573 return terrData; 573 return terrData;
574 } 574 }
575 575
576 public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
577 {
578 TerrainData terrData = null;
579
580 string sql = @"select ""RegionUUID"", ""Revision"", ""Heightfield"" from bakedterrain
581 where ""RegionUUID"" = :RegionUUID; ";
582
583 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
584 {
585 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
586 {
587 // PGSqlParameter param = new PGSqlParameter();
588 cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
589 conn.Open();
590 using (NpgsqlDataReader reader = cmd.ExecuteReader())
591 {
592 int rev;
593 if (reader.Read())
594 {
595 rev = Convert.ToInt32(reader["Revision"]);
596 if ((reader["Heightfield"] != DBNull.Value))
597 {
598 byte[] blob = (byte[])reader["Heightfield"];
599 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
600 }
601 }
602 }
603 }
604 }
605
606 return terrData;
607 }
608
576 // Legacy entry point for when terrain was always a 256x256 heightmap 609 // Legacy entry point for when terrain was always a 256x256 heightmap
577 public void StoreTerrain(double[,] terrain, UUID regionID) 610 public void StoreTerrain(double[,] terrain, UUID regionID)
578 { 611 {
@@ -624,6 +657,49 @@ namespace OpenSim.Data.PGSQL
624 } 657 }
625 658
626 /// <summary> 659 /// <summary>
660 /// Stores the baked terrain map to DB.
661 /// </summary>
662 /// <param name="terrain">terrain map data.</param>
663 /// <param name="regionID">regionID.</param>
664 public void StoreBakedTerrain(TerrainData terrData, UUID regionID)
665 {
666 //Delete old terrain map
667 string sql = @"delete from bakedterrain where ""RegionUUID""=:RegionUUID";
668 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
669 {
670 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
671 {
672 cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
673 conn.Open();
674 cmd.ExecuteNonQuery();
675
676 _Log.InfoFormat("{0} Deleted bakedterrain id = {1}", LogHeader, regionID);
677 }
678 }
679
680 int terrainDBRevision;
681 Array terrainDBblob;
682 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
683
684 sql = @"insert into bakedterrain(""RegionUUID"", ""Revision"", ""Heightfield"") values(:RegionUUID, :Revision, :Heightfield)";
685
686 using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString))
687 {
688 using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn))
689 {
690 cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID));
691 cmd.Parameters.Add(_Database.CreateParameter("Revision", terrainDBRevision));
692 cmd.Parameters.Add(_Database.CreateParameter("Heightfield", terrainDBblob));
693 conn.Open();
694 cmd.ExecuteNonQuery();
695
696 _Log.InfoFormat("{0} Stored bakedterrain id = {1}, terrainSize = <{2},{3}>",
697 LogHeader, regionID, terrData.SizeX, terrData.SizeY);
698 }
699 }
700 }
701
702 /// <summary>
627 /// Loads all the land objects of a region. 703 /// Loads all the land objects of a region.
628 /// </summary> 704 /// </summary>
629 /// <param name="regionUUID">The region UUID.</param> 705 /// <param name="regionUUID">The region UUID.</param>
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;
1182ALTER TABLE prims ADD "RotationAxisLocks" smallint NOT NULL DEFAULT (0); 1182ALTER TABLE prims ADD "RotationAxisLocks" smallint NOT NULL DEFAULT (0);
1183 1183
1184COMMIT; 1184COMMIT;
1185
1186:VERSION 44 #---- add baked terrain store
1187
1188BEGIN TRANSACTION;
1189
1190CREATE TABLE bakedterrain
1191 (
1192 "RegionUUID" uuid NULL,
1193 "Revision" int NULL,
1194 "Heightfield" bytea NULL
1195 );
1196
1197COMMIT;
diff --git a/OpenSim/Data/SQLite/Resources/RegionStore.migrations b/OpenSim/Data/SQLite/Resources/RegionStore.migrations
index 25f3ad9..64624db 100644
--- a/OpenSim/Data/SQLite/Resources/RegionStore.migrations
+++ b/OpenSim/Data/SQLite/Resources/RegionStore.migrations
@@ -352,3 +352,14 @@ BEGIN;
352ALTER TABLE prims ADD COLUMN `RotationAxisLocks` tinyint(4) NOT NULL default '0'; 352ALTER TABLE prims ADD COLUMN `RotationAxisLocks` tinyint(4) NOT NULL default '0';
353 353
354COMMIT; 354COMMIT;
355
356:VERSION 34 #---- add baked terrain store
357
358BEGIN;
359
360CREATE TABLE IF NOT EXISTS bakedterrain(
361 RegionUUID varchar(255),
362 Revision integer,
363 Heightfield blob);
364
365COMMIT;
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
index cd20c4e..c1c7b7e 100644
--- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs
+++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs
@@ -827,7 +827,7 @@ namespace OpenSim.Data.SQLite
827 } 827 }
828 828
829 /// <summary> 829 /// <summary>
830 /// Store a terrain revision in region storage 830 /// Store a terrain in region storage
831 /// </summary> 831 /// </summary>
832 /// <param name="ter">terrain heightfield</param> 832 /// <param name="ter">terrain heightfield</param>
833 /// <param name="regionID">region UUID</param> 833 /// <param name="regionID">region UUID</param>
@@ -851,7 +851,44 @@ namespace OpenSim.Data.SQLite
851 Array terrainDBblob; 851 Array terrainDBblob;
852 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); 852 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
853 853
854 m_log.DebugFormat("{0} Storing terrain revision r {1}", LogHeader, terrainDBRevision); 854 m_log.DebugFormat("{0} Storing terrain format {1}", LogHeader, terrainDBRevision);
855
856 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn))
857 {
858 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
859 cmd.Parameters.Add(new SqliteParameter(":Revision", terrainDBRevision));
860 cmd.Parameters.Add(new SqliteParameter(":Heightfield", terrainDBblob));
861 cmd.ExecuteNonQuery();
862 }
863 }
864 }
865
866 /// <summary>
867 /// Store baked terrain in region storage
868 /// </summary>
869 /// <param name="ter">terrain heightfield</param>
870 /// <param name="regionID">region UUID</param>
871 public void StoreBakedTerrain(TerrainData terrData, UUID regionID)
872 {
873 lock (ds)
874 {
875 using (
876 SqliteCommand cmd = new SqliteCommand("delete from bakedterrain where RegionUUID=:RegionUUID", m_conn))
877 {
878 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
879 cmd.ExecuteNonQuery();
880 }
881
882 // the following is an work around for .NET. The perf
883 // issues associated with it aren't as bad as you think.
884 String sql = "insert into bakedterrain(RegionUUID, Revision, Heightfield)" +
885 " values(:RegionUUID, :Revision, :Heightfield)";
886
887 int terrainDBRevision;
888 Array terrainDBblob;
889 terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob);
890
891 m_log.DebugFormat("{0} Storing bakedterrain format {1}", LogHeader, terrainDBRevision);
855 892
856 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn)) 893 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn))
857 { 894 {
@@ -913,6 +950,34 @@ namespace OpenSim.Data.SQLite
913 return terrData; 950 return terrData;
914 } 951 }
915 952
953 public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
954 {
955 TerrainData terrData = null;
956
957 lock (ds)
958 {
959 String sql = "select RegionUUID, Revision, Heightfield from bakedterrain" +
960 " where RegionUUID=:RegionUUID";
961
962 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn))
963 {
964 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", regionID.ToString()));
965
966 using (IDataReader row = cmd.ExecuteReader())
967 {
968 int rev = 0;
969 if (row.Read())
970 {
971 rev = Convert.ToInt32(row["Revision"]);
972 byte[] blob = (byte[])row["Heightfield"];
973 terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob);
974 }
975 }
976 }
977 }
978 return terrData;
979 }
980
916 public void RemoveLandObject(UUID globalID) 981 public void RemoveLandObject(UUID globalID)
917 { 982 {
918 lock (ds) 983 lock (ds)
@@ -1354,7 +1419,7 @@ namespace OpenSim.Data.SQLite
1354 createCol(land, "Name", typeof(String)); 1419 createCol(land, "Name", typeof(String));
1355 createCol(land, "Desc", typeof(String)); 1420 createCol(land, "Desc", typeof(String));
1356 createCol(land, "OwnerUUID", typeof(String)); 1421 createCol(land, "OwnerUUID", typeof(String));
1357 createCol(land, "IsGroupOwned", typeof(String)); 1422 createCol(land, "IsGroupOwned", typeof(string));
1358 createCol(land, "Area", typeof(Int32)); 1423 createCol(land, "Area", typeof(Int32));
1359 createCol(land, "AuctionID", typeof(Int32)); //Unemplemented 1424 createCol(land, "AuctionID", typeof(Int32)); //Unemplemented
1360 createCol(land, "Category", typeof(Int32)); //Enum OpenMetaverse.Parcel.ParcelCategory 1425 createCol(land, "Category", typeof(Int32)); //Enum OpenMetaverse.Parcel.ParcelCategory
@@ -2942,7 +3007,8 @@ namespace OpenSim.Data.SQLite
2942 { 3007 {
2943 return DbType.Binary; 3008 return DbType.Binary;
2944 } 3009 }
2945 else if (type == typeof(Boolean)) { 3010 else if (type == typeof(Boolean))
3011 {
2946 return DbType.Boolean; 3012 return DbType.Boolean;
2947 } 3013 }
2948 else 3014 else
diff --git a/OpenSim/Framework/TerrainData.cs b/OpenSim/Framework/TerrainData.cs
index d2e1c6a..5cec2b5 100644
--- a/OpenSim/Framework/TerrainData.cs
+++ b/OpenSim/Framework/TerrainData.cs
@@ -201,6 +201,7 @@ namespace OpenSim.Framework
201 public override bool GetDatabaseBlob(out int DBRevisionCode, out Array blob) 201 public override bool GetDatabaseBlob(out int DBRevisionCode, out Array blob)
202 { 202 {
203 bool ret = false; 203 bool ret = false;
204/* save all as Variable2DGzip
204 if (SizeX == Constants.RegionSize && SizeY == Constants.RegionSize) 205 if (SizeX == Constants.RegionSize && SizeY == Constants.RegionSize)
205 { 206 {
206 DBRevisionCode = (int)DBTerrainRevision.Legacy256; 207 DBRevisionCode = (int)DBTerrainRevision.Legacy256;
@@ -209,12 +210,13 @@ namespace OpenSim.Framework
209 } 210 }
210 else 211 else
211 { 212 {
213*/
212 DBRevisionCode = (int)DBTerrainRevision.Variable2DGzip; 214 DBRevisionCode = (int)DBTerrainRevision.Variable2DGzip;
213// DBRevisionCode = (int)DBTerrainRevision.Variable2D; 215// DBRevisionCode = (int)DBTerrainRevision.Variable2D;
214 blob = ToCompressedTerrainSerializationV2DGzip(); 216 blob = ToCompressedTerrainSerializationV2DGzip();
215// blob = ToCompressedTerrainSerializationV2D(); 217// blob = ToCompressedTerrainSerializationV2D();
216 ret = true; 218 ret = true;
217 } 219// }
218 return ret; 220 return ret;
219 } 221 }
220 222
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 69fa5f6..e21681d 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -231,20 +231,27 @@ namespace OpenSim.Region.CoreModules.World.Terrain
231 // Install terrain module in the simulator 231 // Install terrain module in the simulator
232 lock(m_scene) 232 lock(m_scene)
233 { 233 {
234 if(m_scene.Bakedmap != null)
235 {
236 m_baked = m_scene.Bakedmap;
237 }
234 if (m_scene.Heightmap == null) 238 if (m_scene.Heightmap == null)
235 { 239 {
236 m_channel = new TerrainChannel(m_InitialTerrain, (int)m_scene.RegionInfo.RegionSizeX, 240 if(m_baked != null)
237 (int)m_scene.RegionInfo.RegionSizeY, 241 m_channel = m_baked.MakeCopy();
238 (int)m_scene.RegionInfo.RegionSizeZ); 242 else
243 m_channel = new TerrainChannel(m_InitialTerrain,
244 (int)m_scene.RegionInfo.RegionSizeX,
245 (int)m_scene.RegionInfo.RegionSizeY,
246 (int)m_scene.RegionInfo.RegionSizeZ);
239 m_scene.Heightmap = m_channel; 247 m_scene.Heightmap = m_channel;
240
241 UpdateBakedMap();
242 } 248 }
243 else 249 else
244 { 250 {
245 m_channel = m_scene.Heightmap; 251 m_channel = m_scene.Heightmap;
246 UpdateBakedMap();
247 } 252 }
253 if(m_baked == null)
254 UpdateBakedMap();
248 255
249 m_scene.RegisterModuleInterface<ITerrainModule>(this); 256 m_scene.RegisterModuleInterface<ITerrainModule>(this);
250 m_scene.EventManager.OnNewClient += EventManager_OnNewClient; 257 m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
@@ -724,6 +731,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
724 m_baked = m_channel.MakeCopy(); 731 m_baked = m_channel.MakeCopy();
725 m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_baked); 732 m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_baked);
726 m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_baked); 733 m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_baked);
734 m_scene.Bakedmap = m_baked;
735 m_scene.SaveBakedTerrain();
727 } 736 }
728 737
729 /// <summary> 738 /// <summary>
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
index 13358cb..f8a6b53 100644
--- a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
@@ -64,12 +64,19 @@ namespace OpenSim.Region.Framework.Interfaces
64 List<SceneObjectGroup> LoadObjects(UUID regionUUID); 64 List<SceneObjectGroup> LoadObjects(UUID regionUUID);
65 65
66 /// <summary> 66 /// <summary>
67 /// Store a terrain revision in region storage 67 /// Store terrain in region storage
68 /// </summary> 68 /// </summary>
69 /// <param name="ter">HeightField data</param> 69 /// <param name="ter">HeightField data</param>
70 /// <param name="regionID">region UUID</param> 70 /// <param name="regionID">region UUID</param>
71 void StoreTerrain(TerrainData terrain, UUID regionID); 71 void StoreTerrain(TerrainData terrain, UUID regionID);
72 72
73 /// <summary>
74 /// Store baked terrain in region storage
75 /// </summary>
76 /// <param name="ter">HeightField data</param>
77 /// <param name="regionID">region UUID</param>
78 void StoreBakedTerrain(TerrainData terrain, UUID regionID);
79
73 // Legacy version kept for downward compabibility 80 // Legacy version kept for downward compabibility
74 void StoreTerrain(double[,] terrain, UUID regionID); 81 void StoreTerrain(double[,] terrain, UUID regionID);
75 82
@@ -82,6 +89,7 @@ namespace OpenSim.Region.Framework.Interfaces
82 /// <param name="sizeZ">the Z dimension of the region being filled</param> 89 /// <param name="sizeZ">the Z dimension of the region being filled</param>
83 /// <returns>Heightfield data</returns> 90 /// <returns>Heightfield data</returns>
84 TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ); 91 TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
92 TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
85 93
86 // Legacy version kept for downward compabibility 94 // Legacy version kept for downward compabibility
87 double[,] LoadTerrain(UUID regionID); 95 double[,] LoadTerrain(UUID regionID);
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
index e09f775..8536db0 100644
--- a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
@@ -75,17 +75,25 @@ namespace OpenSim.Region.Framework.Interfaces
75 List<SceneObjectGroup> LoadObjects(UUID regionUUID); 75 List<SceneObjectGroup> LoadObjects(UUID regionUUID);
76 76
77 /// <summary> 77 /// <summary>
78 /// Store a terrain revision in region storage 78 /// Store a terrain in region storage
79 /// </summary> 79 /// </summary>
80 /// <param name="ter">HeightField data</param> 80 /// <param name="ter">HeightField data</param>
81 /// <param name="regionID">region UUID</param> 81 /// <param name="regionID">region UUID</param>
82 void StoreTerrain(TerrainData terrain, UUID regionID); 82 void StoreTerrain(TerrainData terrain, UUID regionID);
83 83
84 /// <summary>
85 /// Store baked terrain in region storage
86 /// </summary>
87 /// <param name="ter">HeightField data</param>
88 /// <param name="regionID">region UUID</param>
89 void StoreBakedTerrain(TerrainData terrain, UUID regionID);
90
91
84 // Legacy version kept for downward compabibility 92 // Legacy version kept for downward compabibility
85 void StoreTerrain(double[,] terrain, UUID regionID); 93 void StoreTerrain(double[,] terrain, UUID regionID);
86 94
87 /// <summary> 95 /// <summary>
88 /// Load the latest terrain revision from region storage 96 /// Load terrain from region storage
89 /// </summary> 97 /// </summary>
90 /// <param name="regionID">the region UUID</param> 98 /// <param name="regionID">the region UUID</param>
91 /// <param name="pSizeX">the X dimension of the terrain being filled</param> 99 /// <param name="pSizeX">the X dimension of the terrain being filled</param>
@@ -93,6 +101,7 @@ namespace OpenSim.Region.Framework.Interfaces
93 /// <param name="pSizeZ">the Z dimension of the terrain being filled</param> 101 /// <param name="pSizeZ">the Z dimension of the terrain being filled</param>
94 /// <returns>Heightfield data</returns> 102 /// <returns>Heightfield data</returns>
95 TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ); 103 TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
104 TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
96 105
97 // Legacy version kept for downward compabibility 106 // Legacy version kept for downward compabibility
98 double[,] LoadTerrain(UUID regionID); 107 double[,] LoadTerrain(UUID regionID);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d77b8ae..168080f 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2172,7 +2172,16 @@ namespace OpenSim.Region.Framework.Scenes
2172 /// </summary> 2172 /// </summary>
2173 public void SaveTerrain() 2173 public void SaveTerrain()
2174 { 2174 {
2175 SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); 2175 SimulationDataService.StoreTerrain(Heightmap.GetTerrainData(), RegionInfo.RegionID);
2176 }
2177
2178 /// <summary>
2179 /// Store the terrain in the persistant data store
2180 /// </summary>
2181 public void SaveBakedTerrain()
2182 {
2183 if(Bakedmap != null)
2184 SimulationDataService.StoreBakedTerrain(Bakedmap.GetTerrainData(), RegionInfo.RegionID);
2176 } 2185 }
2177 2186
2178 public void StoreWindlightProfile(RegionLightShareData wl) 2187 public void StoreWindlightProfile(RegionLightShareData wl)
@@ -2195,20 +2204,44 @@ namespace OpenSim.Region.Framework.Scenes
2195 { 2204 {
2196 try 2205 try
2197 { 2206 {
2207 Bakedmap = null;
2208 TerrainData map = SimulationDataService.LoadBakedTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
2209 if (map != null)
2210 {
2211 Bakedmap = new TerrainChannel(map);
2212 }
2213 }
2214 catch (Exception e)
2215 {
2216 m_log.WarnFormat(
2217 "[TERRAIN]: Scene.cs: LoadWorldMap() baked terrain - Failed with exception {0}{1}", e.Message, e.StackTrace);
2218 }
2219
2220 try
2221 {
2198 TerrainData map = SimulationDataService.LoadTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ); 2222 TerrainData map = SimulationDataService.LoadTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
2199 if (map == null) 2223 if (map == null)
2200 { 2224 {
2201 // This should be in the Terrain module, but it isn't because 2225 if(Bakedmap != null)
2202 // the heightmap is needed _way_ before the modules are initialized... 2226 {
2203 IConfig terrainConfig = m_config.Configs["Terrain"]; 2227 m_log.Warn("[TERRAIN]: terrain not found. Used stored baked terrain.");
2204 String m_InitialTerrain = "pinhead-island"; 2228 Heightmap = Bakedmap.MakeCopy();
2205 if (terrainConfig != null) 2229 SimulationDataService.StoreTerrain(Heightmap.GetTerrainData(), RegionInfo.RegionID);
2206 m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain); 2230 }
2231 else
2232 {
2233 // This should be in the Terrain module, but it isn't because
2234 // the heightmap is needed _way_ before the modules are initialized...
2235 IConfig terrainConfig = m_config.Configs["Terrain"];
2236 String m_InitialTerrain = "pinhead-island";
2237 if (terrainConfig != null)
2238 m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain);
2207 2239
2208 m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain); 2240 m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain);
2209 Heightmap = new TerrainChannel(m_InitialTerrain, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ); 2241 Heightmap = new TerrainChannel(m_InitialTerrain, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
2210 2242
2211 SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); 2243 SimulationDataService.StoreTerrain(Heightmap.GetTerrainData(), RegionInfo.RegionID);
2244 }
2212 } 2245 }
2213 else 2246 else
2214 { 2247 {
@@ -2221,13 +2254,12 @@ namespace OpenSim.Region.Framework.Scenes
2221 "[TERRAIN]: Scene.cs: LoadWorldMap() - Regenerating as failed with exception {0}{1}", 2254 "[TERRAIN]: Scene.cs: LoadWorldMap() - Regenerating as failed with exception {0}{1}",
2222 e.Message, e.StackTrace); 2255 e.Message, e.StackTrace);
2223 2256
2224 // Non standard region size. If there's an old terrain in the database, it might read past the buffer
2225#pragma warning disable 0162 2257#pragma warning disable 0162
2226 if ((int)Constants.RegionSize != 256) 2258 if ((int)Constants.RegionSize != 256)
2227 { 2259 {
2228 Heightmap = new TerrainChannel(); 2260 Heightmap = new TerrainChannel();
2229 2261
2230 SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); 2262 SimulationDataService.StoreTerrain(Heightmap.GetTerrainData(), RegionInfo.RegionID);
2231 } 2263 }
2232 } 2264 }
2233 catch (Exception e) 2265 catch (Exception e)
@@ -2235,6 +2267,12 @@ namespace OpenSim.Region.Framework.Scenes
2235 m_log.WarnFormat( 2267 m_log.WarnFormat(
2236 "[TERRAIN]: Scene.cs: LoadWorldMap() - Failed with exception {0}{1}", e.Message, e.StackTrace); 2268 "[TERRAIN]: Scene.cs: LoadWorldMap() - Failed with exception {0}{1}", e.Message, e.StackTrace);
2237 } 2269 }
2270
2271 if(Bakedmap == null && Heightmap != null)
2272 {
2273 Bakedmap = Heightmap.MakeCopy();
2274 SimulationDataService.StoreBakedTerrain(Bakedmap.GetTerrainData(), RegionInfo.RegionID);
2275 }
2238 } 2276 }
2239 2277
2240 /// <summary> 2278 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index f420f69..1de55ec 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -153,6 +153,7 @@ namespace OpenSim.Region.Framework.Scenes
153 } 153 }
154 154
155 public ITerrainChannel Heightmap; 155 public ITerrainChannel Heightmap;
156 public ITerrainChannel Bakedmap;
156 157
157 /// <value> 158 /// <value>
158 /// Allows retrieval of land information for this scene. 159 /// Allows retrieval of land information for this scene.
diff --git a/OpenSim/Services/SimulationService/SimulationDataService.cs b/OpenSim/Services/SimulationService/SimulationDataService.cs
index 7a544fa..eef958a 100644
--- a/OpenSim/Services/SimulationService/SimulationDataService.cs
+++ b/OpenSim/Services/SimulationService/SimulationDataService.cs
@@ -104,6 +104,11 @@ namespace OpenSim.Services.SimulationService
104 m_database.StoreTerrain(terrain, regionID); 104 m_database.StoreTerrain(terrain, regionID);
105 } 105 }
106 106
107 public void StoreBakedTerrain(TerrainData terrain, UUID regionID)
108 {
109 m_database.StoreBakedTerrain(terrain, regionID);
110 }
111
107 public void StoreTerrain(double[,] terrain, UUID regionID) 112 public void StoreTerrain(double[,] terrain, UUID regionID)
108 { 113 {
109 m_database.StoreTerrain(terrain, regionID); 114 m_database.StoreTerrain(terrain, regionID);
@@ -119,6 +124,11 @@ namespace OpenSim.Services.SimulationService
119 return m_database.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ); 124 return m_database.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ);
120 } 125 }
121 126
127 public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
128 {
129 return m_database.LoadBakedTerrain(regionID, pSizeX, pSizeY, pSizeZ);
130 }
131
122 public void StoreLandObject(ILandObject Parcel) 132 public void StoreLandObject(ILandObject Parcel)
123 { 133 {
124 m_database.StoreLandObject(Parcel); 134 m_database.StoreLandObject(Parcel);
diff --git a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
index 3ab9020..8daa19d 100644
--- a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
+++ b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs
@@ -74,6 +74,11 @@ namespace OpenSim.Data.Null
74 m_store.StoreTerrain(terrain, regionID); 74 m_store.StoreTerrain(terrain, regionID);
75 } 75 }
76 76
77 public void StoreBakedTerrain(TerrainData terrain, UUID regionID)
78 {
79 m_store.StoreBakedTerrain(terrain, regionID);
80 }
81
77 public double[,] LoadTerrain(UUID regionID) 82 public double[,] LoadTerrain(UUID regionID)
78 { 83 {
79 return m_store.LoadTerrain(regionID); 84 return m_store.LoadTerrain(regionID);
@@ -84,6 +89,11 @@ namespace OpenSim.Data.Null
84 return m_store.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ); 89 return m_store.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ);
85 } 90 }
86 91
92 public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
93 {
94 return m_store.LoadBakedTerrain(regionID, pSizeX, pSizeY, pSizeZ);
95 }
96
87 public void StoreLandObject(ILandObject Parcel) 97 public void StoreLandObject(ILandObject Parcel)
88 { 98 {
89 m_store.StoreLandObject(Parcel); 99 m_store.StoreLandObject(Parcel);
@@ -170,6 +180,7 @@ namespace OpenSim.Data.Null
170 protected Dictionary<UUID, ICollection<TaskInventoryItem>> m_primItems 180 protected Dictionary<UUID, ICollection<TaskInventoryItem>> m_primItems
171 = new Dictionary<UUID, ICollection<TaskInventoryItem>>(); 181 = new Dictionary<UUID, ICollection<TaskInventoryItem>>();
172 protected Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>(); 182 protected Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>();
183 protected Dictionary<UUID, TerrainData> m_bakedterrains = new Dictionary<UUID, TerrainData>();
173 protected Dictionary<UUID, LandData> m_landData = new Dictionary<UUID, LandData>(); 184 protected Dictionary<UUID, LandData> m_landData = new Dictionary<UUID, LandData>();
174 185
175 public void Initialise(string dbfile) 186 public void Initialise(string dbfile)
@@ -319,6 +330,11 @@ namespace OpenSim.Data.Null
319 m_terrains[regionID] = ter; 330 m_terrains[regionID] = ter;
320 } 331 }
321 332
333 public void StoreBakedTerrain(TerrainData ter, UUID regionID)
334 {
335 m_bakedterrains[regionID] = ter;
336 }
337
322 public void StoreTerrain(double[,] ter, UUID regionID) 338 public void StoreTerrain(double[,] ter, UUID regionID)
323 { 339 {
324 m_terrains[regionID] = new HeightmapTerrainData(ter); 340 m_terrains[regionID] = new HeightmapTerrainData(ter);
@@ -332,6 +348,14 @@ namespace OpenSim.Data.Null
332 return null; 348 return null;
333 } 349 }
334 350
351 public TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ)
352 {
353 if (m_bakedterrains.ContainsKey(regionID))
354 return m_bakedterrains[regionID];
355 else
356 return null;
357 }
358
335 public double[,] LoadTerrain(UUID regionID) 359 public double[,] LoadTerrain(UUID regionID)
336 { 360 {
337 if (m_terrains.ContainsKey(regionID)) 361 if (m_terrains.ContainsKey(regionID))