Merge branch 'ubitwork' of ssh://3dhosting.de/var/git/careminster into ubitwork
commit
0886d99f1b
|
@ -41,6 +41,7 @@ namespace OpenSim.Region.Physics.Manager
|
||||||
IMesh GetMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex);
|
IMesh GetMesh(String primName, PrimitiveBaseShape primShape, Vector3 size, float lod, bool isPhysical, bool convex);
|
||||||
void ReleaseMesh(IMesh mesh);
|
void ReleaseMesh(IMesh mesh);
|
||||||
void ExpireReleaseMeshs();
|
void ExpireReleaseMeshs();
|
||||||
|
void ExpireFileCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Values for level of detail to be passed to the mesher.
|
// Values for level of detail to be passed to the mesher.
|
||||||
|
|
|
@ -87,5 +87,6 @@ namespace OpenSim.Region.Physics.Manager
|
||||||
|
|
||||||
public void ReleaseMesh(IMesh mesh) { }
|
public void ReleaseMesh(IMesh mesh) { }
|
||||||
public void ExpireReleaseMeshs() { }
|
public void ExpireReleaseMeshs() { }
|
||||||
|
public void ExpireFileCache() { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -755,5 +755,6 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
|
|
||||||
public void ReleaseMesh(IMesh imesh) { }
|
public void ReleaseMesh(IMesh imesh) { }
|
||||||
public void ExpireReleaseMeshs() { }
|
public void ExpireReleaseMeshs() { }
|
||||||
|
public void ExpireFileCache() { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,6 +76,8 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
public bool doMeshFileCache = true;
|
public bool doMeshFileCache = true;
|
||||||
|
|
||||||
public string cachePath = "MeshCache";
|
public string cachePath = "MeshCache";
|
||||||
|
public TimeSpan CacheExpire;
|
||||||
|
public bool doCacheExpire = true;
|
||||||
|
|
||||||
// const string baseDir = "rawFiles";
|
// const string baseDir = "rawFiles";
|
||||||
private const string baseDir = null; //"rawFiles";
|
private const string baseDir = null; //"rawFiles";
|
||||||
|
@ -92,6 +94,10 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
IConfig start_config = config.Configs["Startup"];
|
IConfig start_config = config.Configs["Startup"];
|
||||||
IConfig mesh_config = config.Configs["Mesh"];
|
IConfig mesh_config = config.Configs["Mesh"];
|
||||||
|
|
||||||
|
|
||||||
|
float fcache = 48.0f;
|
||||||
|
// float fcache = 0.02f;
|
||||||
|
|
||||||
if(mesh_config != null)
|
if(mesh_config != null)
|
||||||
{
|
{
|
||||||
useMeshiesPhysicsMesh = mesh_config.GetBoolean("UseMeshiesPhysicsMesh", useMeshiesPhysicsMesh);
|
useMeshiesPhysicsMesh = mesh_config.GetBoolean("UseMeshiesPhysicsMesh", useMeshiesPhysicsMesh);
|
||||||
|
@ -99,12 +105,20 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
{
|
{
|
||||||
doMeshFileCache = mesh_config.GetBoolean("MeshFileCache", doMeshFileCache);
|
doMeshFileCache = mesh_config.GetBoolean("MeshFileCache", doMeshFileCache);
|
||||||
cachePath = mesh_config.GetString("MeshFileCachePath", cachePath);
|
cachePath = mesh_config.GetString("MeshFileCachePath", cachePath);
|
||||||
|
fcache = mesh_config.GetFloat("MeshFileCacheExpireHours", fcache);
|
||||||
|
doCacheExpire = mesh_config.GetBoolean("MeshFileCacheDoExpire", doCacheExpire);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
doMeshFileCache = false;
|
doMeshFileCache = false;
|
||||||
|
doCacheExpire = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CacheExpire = TimeSpan.FromHours(fcache);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// creates a simple box mesh of the specified size. This mesh is of very low vertex count and may
|
/// creates a simple box mesh of the specified size. This mesh is of very low vertex count and may
|
||||||
/// be useful as a backup proxy when level of detail is not needed or when more complex meshes fail
|
/// be useful as a backup proxy when level of detail is not needed or when more complex meshes fail
|
||||||
|
@ -1273,6 +1287,7 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
BinaryFormatter bformatter = new BinaryFormatter();
|
BinaryFormatter bformatter = new BinaryFormatter();
|
||||||
|
|
||||||
mesh = Mesh.FromStream(stream, key);
|
mesh = Mesh.FromStream(stream, key);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -1281,11 +1296,14 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
"[MESH CACHE]: Failed to get file {0}. Exception {1} {2}",
|
"[MESH CACHE]: Failed to get file {0}. Exception {1} {2}",
|
||||||
filename, e.Message, e.StackTrace);
|
filename, e.Message, e.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stream != null)
|
if (stream != null)
|
||||||
stream.Close();
|
stream.Close();
|
||||||
|
|
||||||
if (mesh == null || !ok)
|
if (mesh == null || !ok)
|
||||||
File.Delete(filename);
|
File.Delete(filename);
|
||||||
|
else
|
||||||
|
File.SetLastAccessTimeUtc(filename, DateTime.UtcNow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1326,9 +1344,73 @@ namespace OpenSim.Region.Physics.Meshing
|
||||||
if (stream != null)
|
if (stream != null)
|
||||||
stream.Close();
|
stream.Close();
|
||||||
|
|
||||||
if (!ok && File.Exists(filename))
|
if (File.Exists(filename))
|
||||||
|
{
|
||||||
|
if (ok)
|
||||||
|
File.SetLastAccessTimeUtc(filename, DateTime.UtcNow);
|
||||||
|
else
|
||||||
File.Delete(filename);
|
File.Delete(filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ExpireFileCache()
|
||||||
|
{
|
||||||
|
if (!doCacheExpire)
|
||||||
|
return;
|
||||||
|
|
||||||
|
string controlfile = System.IO.Path.Combine(cachePath, "cntr");
|
||||||
|
|
||||||
|
lock (diskLock)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (File.Exists(controlfile))
|
||||||
|
{
|
||||||
|
int ndeleted = 0;
|
||||||
|
int totalfiles = 0;
|
||||||
|
int ndirs = 0;
|
||||||
|
DateTime OlderTime = File.GetLastAccessTimeUtc(controlfile) - CacheExpire;
|
||||||
|
File.SetLastAccessTimeUtc(controlfile, DateTime.UtcNow);
|
||||||
|
|
||||||
|
foreach (string dir in Directory.GetDirectories(cachePath))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (string file in Directory.GetFiles(dir))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (File.GetLastAccessTimeUtc(file) < OlderTime)
|
||||||
|
{
|
||||||
|
File.Delete(file);
|
||||||
|
ndeleted++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
totalfiles++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
ndirs++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ndeleted == 0)
|
||||||
|
m_log.InfoFormat("[MESH CACHE]: {0} Files in {1} cache folders, no expires",
|
||||||
|
totalfiles,ndirs);
|
||||||
|
else
|
||||||
|
m_log.InfoFormat("[MESH CACHE]: {0} Files in {1} cache folders, expired {2} files accessed before {3}",
|
||||||
|
totalfiles,ndirs, ndeleted, OlderTime.ToString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_log.Info("[MESH CACHE]: Expire delayed to next startup");
|
||||||
|
FileStream fs = File.Create(controlfile,4096,FileOptions.WriteThrough);
|
||||||
|
fs.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue