diff options
author | UbitUmarov | 2016-09-17 16:42:40 +0100 |
---|---|---|
committer | UbitUmarov | 2016-09-17 16:42:40 +0100 |
commit | 71bd3ce49f1159251ec4339d098d93c2119729f0 (patch) | |
tree | b9d73349600abc18b63ee5201fc60b8a1d810334 | |
parent | add to databases a table to store baked terrain. (diff) | |
download | opensim-SC-71bd3ce49f1159251ec4339d098d93c2119729f0.zip opensim-SC-71bd3ce49f1159251ec4339d098d93c2119729f0.tar.gz opensim-SC-71bd3ce49f1159251ec4339d098d93c2119729f0.tar.bz2 opensim-SC-71bd3ce49f1159251ec4339d098d93c2119729f0.tar.xz |
add load baked terrain methods
-rw-r--r-- | OpenSim/Data/MySQL/MySQLSimulationData.cs | 35 | ||||
-rw-r--r-- | OpenSim/Data/Null/NullSimulationData.cs | 9 | ||||
-rwxr-xr-x | OpenSim/Data/PGSQL/PGSQLSimulationData.cs | 33 | ||||
-rw-r--r-- | OpenSim/Data/SQLite/SQLiteSimulationData.cs | 28 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs | 3 | ||||
-rw-r--r-- | OpenSim/Services/SimulationService/SimulationDataService.cs | 5 | ||||
-rw-r--r-- | OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs | 13 |
7 files changed, 125 insertions, 1 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index 1a57199..ab24b76 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -733,6 +733,41 @@ namespace OpenSim.Data.MySQL | |||
733 | return terrData; | 733 | return terrData; |
734 | } | 734 | } |
735 | 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 | |||
736 | public virtual void RemoveLandObject(UUID globalID) | 771 | public virtual void RemoveLandObject(UUID globalID) |
737 | { | 772 | { |
738 | lock (m_dbLock) | 773 | lock (m_dbLock) |
diff --git a/OpenSim/Data/Null/NullSimulationData.cs b/OpenSim/Data/Null/NullSimulationData.cs index 5ea8bfa..7bb6da3 100644 --- a/OpenSim/Data/Null/NullSimulationData.cs +++ b/OpenSim/Data/Null/NullSimulationData.cs | |||
@@ -175,6 +175,15 @@ namespace OpenSim.Data.Null | |||
175 | return null; | 175 | return null; |
176 | } | 176 | } |
177 | 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 | |||
178 | public void RemoveLandObject(UUID globalID) | 187 | public void RemoveLandObject(UUID globalID) |
179 | { | 188 | { |
180 | } | 189 | } |
diff --git a/OpenSim/Data/PGSQL/PGSQLSimulationData.cs b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs index e6161a2..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 | { |
diff --git a/OpenSim/Data/SQLite/SQLiteSimulationData.cs b/OpenSim/Data/SQLite/SQLiteSimulationData.cs index 76b367a..0d565f7 100644 --- a/OpenSim/Data/SQLite/SQLiteSimulationData.cs +++ b/OpenSim/Data/SQLite/SQLiteSimulationData.cs | |||
@@ -950,6 +950,34 @@ namespace OpenSim.Data.SQLite | |||
950 | return terrData; | 950 | return terrData; |
951 | } | 951 | } |
952 | 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 backedterrain" + | ||
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 | |||
953 | public void RemoveLandObject(UUID globalID) | 981 | public void RemoveLandObject(UUID globalID) |
954 | { | 982 | { |
955 | lock (ds) | 983 | lock (ds) |
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs index 4940a28..8536db0 100644 --- a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs +++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs | |||
@@ -93,7 +93,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
93 | void StoreTerrain(double[,] terrain, UUID regionID); | 93 | void StoreTerrain(double[,] terrain, UUID regionID); |
94 | 94 | ||
95 | /// <summary> | 95 | /// <summary> |
96 | /// Load the latest terrain revision from region storage | 96 | /// Load terrain from region storage |
97 | /// </summary> | 97 | /// </summary> |
98 | /// <param name="regionID">the region UUID</param> | 98 | /// <param name="regionID">the region UUID</param> |
99 | /// <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> |
@@ -101,6 +101,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
101 | /// <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> |
102 | /// <returns>Heightfield data</returns> | 102 | /// <returns>Heightfield data</returns> |
103 | 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); | ||
104 | 105 | ||
105 | // Legacy version kept for downward compabibility | 106 | // Legacy version kept for downward compabibility |
106 | double[,] LoadTerrain(UUID regionID); | 107 | double[,] LoadTerrain(UUID regionID); |
diff --git a/OpenSim/Services/SimulationService/SimulationDataService.cs b/OpenSim/Services/SimulationService/SimulationDataService.cs index 4ec8293..eef958a 100644 --- a/OpenSim/Services/SimulationService/SimulationDataService.cs +++ b/OpenSim/Services/SimulationService/SimulationDataService.cs | |||
@@ -124,6 +124,11 @@ namespace OpenSim.Services.SimulationService | |||
124 | return m_database.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ); | 124 | return m_database.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ); |
125 | } | 125 | } |
126 | 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 | |||
127 | public void StoreLandObject(ILandObject Parcel) | 132 | public void StoreLandObject(ILandObject Parcel) |
128 | { | 133 | { |
129 | 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 61fee4b..8daa19d 100644 --- a/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs +++ b/OpenSim/Tests/Common/Mock/MockRegionDataPlugin.cs | |||
@@ -89,6 +89,11 @@ namespace OpenSim.Data.Null | |||
89 | return m_store.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ); | 89 | return m_store.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ); |
90 | } | 90 | } |
91 | 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 | |||
92 | public void StoreLandObject(ILandObject Parcel) | 97 | public void StoreLandObject(ILandObject Parcel) |
93 | { | 98 | { |
94 | m_store.StoreLandObject(Parcel); | 99 | m_store.StoreLandObject(Parcel); |
@@ -343,6 +348,14 @@ namespace OpenSim.Data.Null | |||
343 | return null; | 348 | return null; |
344 | } | 349 | } |
345 | 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 | |||
346 | public double[,] LoadTerrain(UUID regionID) | 359 | public double[,] LoadTerrain(UUID regionID) |
347 | { | 360 | { |
348 | if (m_terrains.ContainsKey(regionID)) | 361 | if (m_terrains.ContainsKey(regionID)) |