aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/Manager/IMesher.cs1
-rw-r--r--OpenSim/Region/Physics/Manager/ZeroMesher.cs1
-rw-r--r--OpenSim/Region/Physics/Meshing/Meshmerizer.cs1
-rw-r--r--OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs88
4 files changed, 88 insertions, 3 deletions
diff --git a/OpenSim/Region/Physics/Manager/IMesher.cs b/OpenSim/Region/Physics/Manager/IMesher.cs
index 21a5fa0..ecc2918 100644
--- a/OpenSim/Region/Physics/Manager/IMesher.cs
+++ b/OpenSim/Region/Physics/Manager/IMesher.cs
@@ -41,6 +41,7 @@ namespace OpenSim.Region.Physics.Manager
41 IMesh GetMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex); 41 IMesh GetMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex);
42 void ReleaseMesh(IMesh mesh); 42 void ReleaseMesh(IMesh mesh);
43 void ExpireReleaseMeshs(); 43 void ExpireReleaseMeshs();
44 void ExpireFileCache();
44 } 45 }
45 46
46 // Values for level of detail to be passed to the mesher. 47 // Values for level of detail to be passed to the mesher.
diff --git a/OpenSim/Region/Physics/Manager/ZeroMesher.cs b/OpenSim/Region/Physics/Manager/ZeroMesher.cs
index 1411165..16846e6 100644
--- a/OpenSim/Region/Physics/Manager/ZeroMesher.cs
+++ b/OpenSim/Region/Physics/Manager/ZeroMesher.cs
@@ -87,5 +87,6 @@ namespace OpenSim.Region.Physics.Manager
87 87
88 public void ReleaseMesh(IMesh mesh) { } 88 public void ReleaseMesh(IMesh mesh) { }
89 public void ExpireReleaseMeshs() { } 89 public void ExpireReleaseMeshs() { }
90 public void ExpireFileCache() { }
90 } 91 }
91} 92}
diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
index fd4ac7f..f629c4d 100644
--- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs
@@ -755,5 +755,6 @@ namespace OpenSim.Region.Physics.Meshing
755 755
756 public void ReleaseMesh(IMesh imesh) { } 756 public void ReleaseMesh(IMesh imesh) { }
757 public void ExpireReleaseMeshs() { } 757 public void ExpireReleaseMeshs() { }
758 public void ExpireFileCache() { }
758 } 759 }
759} 760}
diff --git a/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs b/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs
index 35eabd4..6550b66 100644
--- a/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs
+++ b/OpenSim/Region/Physics/UbitMeshing/Meshmerizer.cs
@@ -76,6 +76,8 @@ namespace OpenSim.Region.Physics.Meshing
76 public bool doMeshFileCache = true; 76 public bool doMeshFileCache = true;
77 77
78 public string cachePath = "MeshCache"; 78 public string cachePath = "MeshCache";
79 public TimeSpan CacheExpire;
80 public bool doCacheExpire = true;
79 81
80// const string baseDir = "rawFiles"; 82// const string baseDir = "rawFiles";
81 private const string baseDir = null; //"rawFiles"; 83 private const string baseDir = null; //"rawFiles";
@@ -92,17 +94,29 @@ namespace OpenSim.Region.Physics.Meshing
92 IConfig start_config = config.Configs["Startup"]; 94 IConfig start_config = config.Configs["Startup"];
93 IConfig mesh_config = config.Configs["Mesh"]; 95 IConfig mesh_config = config.Configs["Mesh"];
94 96
97
98 float fcache = 48.0f;
99// float fcache = 0.02f;
100
95 if(mesh_config != null) 101 if(mesh_config != null)
96 { 102 {
97 useMeshiesPhysicsMesh = mesh_config.GetBoolean("UseMeshiesPhysicsMesh", useMeshiesPhysicsMesh); 103 useMeshiesPhysicsMesh = mesh_config.GetBoolean("UseMeshiesPhysicsMesh", useMeshiesPhysicsMesh);
98 if(useMeshiesPhysicsMesh) 104 if (useMeshiesPhysicsMesh)
99 { 105 {
100 doMeshFileCache = mesh_config.GetBoolean("MeshFileCache", doMeshFileCache); 106 doMeshFileCache = mesh_config.GetBoolean("MeshFileCache", doMeshFileCache);
101 cachePath = mesh_config.GetString("MeshFileCachePath", cachePath); 107 cachePath = mesh_config.GetString("MeshFileCachePath", cachePath);
108 fcache = mesh_config.GetFloat("MeshFileCacheExpireHours", fcache);
109 doCacheExpire = mesh_config.GetBoolean("MeshFileCacheDoExpire", doCacheExpire);
102 } 110 }
103 else 111 else
112 {
104 doMeshFileCache = false; 113 doMeshFileCache = false;
114 doCacheExpire = false;
115 }
105 } 116 }
117
118 CacheExpire = TimeSpan.FromHours(fcache);
119
106 } 120 }
107 121
108 /// <summary> 122 /// <summary>
@@ -1273,6 +1287,7 @@ namespace OpenSim.Region.Physics.Meshing
1273 BinaryFormatter bformatter = new BinaryFormatter(); 1287 BinaryFormatter bformatter = new BinaryFormatter();
1274 1288
1275 mesh = Mesh.FromStream(stream, key); 1289 mesh = Mesh.FromStream(stream, key);
1290
1276 } 1291 }
1277 catch (Exception e) 1292 catch (Exception e)
1278 { 1293 {
@@ -1281,11 +1296,14 @@ namespace OpenSim.Region.Physics.Meshing
1281 "[MESH CACHE]: Failed to get file {0}. Exception {1} {2}", 1296 "[MESH CACHE]: Failed to get file {0}. Exception {1} {2}",
1282 filename, e.Message, e.StackTrace); 1297 filename, e.Message, e.StackTrace);
1283 } 1298 }
1299
1284 if (stream != null) 1300 if (stream != null)
1285 stream.Close(); 1301 stream.Close();
1286 1302
1287 if (mesh == null || !ok) 1303 if (mesh == null || !ok)
1288 File.Delete(filename); 1304 File.Delete(filename);
1305 else
1306 File.SetLastAccessTimeUtc(filename, DateTime.UtcNow);
1289 } 1307 }
1290 } 1308 }
1291 1309
@@ -1326,8 +1344,72 @@ namespace OpenSim.Region.Physics.Meshing
1326 if (stream != null) 1344 if (stream != null)
1327 stream.Close(); 1345 stream.Close();
1328 1346
1329 if (!ok && File.Exists(filename)) 1347 if (File.Exists(filename))
1330 File.Delete(filename); 1348 {
1349 if (ok)
1350 File.SetLastAccessTimeUtc(filename, DateTime.UtcNow);
1351 else
1352 File.Delete(filename);
1353 }
1354 }
1355 }
1356
1357 public void ExpireFileCache()
1358 {
1359 if (!doCacheExpire)
1360 return;
1361
1362 string controlfile = System.IO.Path.Combine(cachePath, "cntr");
1363
1364 lock (diskLock)
1365 {
1366 try
1367 {
1368 if (File.Exists(controlfile))
1369 {
1370 int ndeleted = 0;
1371 int totalfiles = 0;
1372 int ndirs = 0;
1373 DateTime OlderTime = File.GetLastAccessTimeUtc(controlfile) - CacheExpire;
1374 File.SetLastAccessTimeUtc(controlfile, DateTime.UtcNow);
1375
1376 foreach (string dir in Directory.GetDirectories(cachePath))
1377 {
1378 try
1379 {
1380 foreach (string file in Directory.GetFiles(dir))
1381 {
1382 try
1383 {
1384 if (File.GetLastAccessTimeUtc(file) < OlderTime)
1385 {
1386 File.Delete(file);
1387 ndeleted++;
1388 }
1389 }
1390 catch { }
1391 totalfiles++;
1392 }
1393 }
1394 catch { }
1395 ndirs++;
1396 }
1397
1398 if (ndeleted == 0)
1399 m_log.InfoFormat("[MESH CACHE]: {0} Files in {1} cache folders, no expires",
1400 totalfiles,ndirs);
1401 else
1402 m_log.InfoFormat("[MESH CACHE]: {0} Files in {1} cache folders, expired {2} files accessed before {3}",
1403 totalfiles,ndirs, ndeleted, OlderTime.ToString());
1404 }
1405 else
1406 {
1407 m_log.Info("[MESH CACHE]: Expire delayed to next startup");
1408 FileStream fs = File.Create(controlfile,4096,FileOptions.WriteThrough);
1409 fs.Close();
1410 }
1411 }
1412 catch { }
1331 } 1413 }
1332 } 1414 }
1333 } 1415 }