RenderableCache performance improvement, Unknown scenario class types included, Multi-export XML fix

This commit is contained in:
dexyfex 2017-11-25 16:01:56 +11:00
parent 8ea169cee2
commit d9247de1c4
3 changed files with 10 additions and 9 deletions

View File

@ -504,7 +504,7 @@ namespace CodeWalker
isitem = true; isitem = true;
isfile = isfile || (file.Folder == null); isfile = isfile || (file.Folder == null);
canview = canview || CanViewFile(file); canview = canview || CanViewFile(file);
canexportxml = canexportxml || CanExportXml(file);
} }
} }
str += ", " + sc.ToString() + " selected"; str += ", " + sc.ToString() + " selected";

View File

@ -16,8 +16,8 @@ namespace CodeWalker.Rendering
{ {
public class RenderableCache public class RenderableCache
{ {
public DateTime LastUpdate = DateTime.Now; public DateTime LastUpdate = DateTime.UtcNow;
public DateTime LastUnload = DateTime.Now; public DateTime LastUnload = DateTime.UtcNow;
public double CacheTime = Settings.Default.GPUCacheTime;// 10.0; //seconds to keep something that's not used public double CacheTime = Settings.Default.GPUCacheTime;// 10.0; //seconds to keep something that's not used
public double UnloadTime = Settings.Default.GPUCacheFlushTime;// 0.1; //seconds between running unload cycles public double UnloadTime = Settings.Default.GPUCacheFlushTime;// 0.1; //seconds between running unload cycles
public int MaxItemsPerLoop = 1; //to keep things flowing public int MaxItemsPerLoop = 1; //to keep things flowing
@ -119,7 +119,7 @@ namespace CodeWalker.Rendering
//todo: change this to unload only when necessary (ie when something is loaded) //todo: change this to unload only when necessary (ie when something is loaded)
var now = DateTime.Now; var now = DateTime.UtcNow;
var deltat = (now - LastUpdate).TotalSeconds; var deltat = (now - LastUpdate).TotalSeconds;
var unloadt = (now - LastUnload).TotalSeconds; var unloadt = (now - LastUnload).TotalSeconds;
if ((unloadt > UnloadTime) && (deltat < 0.25)) //don't try the unload on every loop... or when really busy if ((unloadt > UnloadTime) && (deltat < 0.25)) //don't try the unload on every loop... or when really busy
@ -134,11 +134,11 @@ namespace CodeWalker.Rendering
pathbatches.UnloadProc(); pathbatches.UnloadProc();
waterquads.UnloadProc(); waterquads.UnloadProc();
LastUnload = DateTime.Now; LastUnload = DateTime.UtcNow;
} }
LastUpdate = DateTime.Now; LastUpdate = DateTime.UtcNow;
Monitor.Exit(updateSyncRoot); Monitor.Exit(updateSyncRoot);
} }
@ -293,7 +293,7 @@ namespace CodeWalker.Rendering
public void UnloadProc() public void UnloadProc()
{ {
//unload items that haven't been used in longer than the cache period. //unload items that haven't been used in longer than the cache period.
var now = DateTime.Now; var now = DateTime.UtcNow;
var rnode = loadeditems.First; var rnode = loadeditems.First;
while (rnode != null) while (rnode != null)
{ {
@ -339,7 +339,7 @@ namespace CodeWalker.Rendering
item.Init(key); item.Init(key);
cacheitems.Add(key, item); cacheitems.Add(key, item);
} }
Interlocked.Exchange(ref item.LastUseTime, DateTime.Now.ToBinary()); Interlocked.Exchange(ref item.LastUseTime, DateTime.UtcNow.ToBinary());
if ((!item.IsLoaded) && (!item.LoadQueued))// || if ((!item.IsLoaded) && (!item.LoadQueued))// ||
{ {
item.LoadQueued = true; item.LoadQueued = true;
@ -364,7 +364,7 @@ namespace CodeWalker.Rendering
item.Unload(); item.Unload();
item.LoadQueued = false; item.LoadQueued = false;
Interlocked.Add(ref CacheUse, -item.DataSize); Interlocked.Add(ref CacheUse, -item.DataSize);
Interlocked.Exchange(ref item.LastUseTime, DateTime.Now.AddHours(-1).ToBinary()); Interlocked.Exchange(ref item.LastUseTime, DateTime.UtcNow.AddHours(-1).ToBinary());
loadeditems.Remove(item);//slow... loadeditems.Remove(item);//slow...
} }

View File

@ -1570,6 +1570,7 @@ namespace CodeWalker.World
typeobj.IsVehicle = true; typeobj.IsVehicle = true;
break; break;
default: default:
typeobj = new ScenarioType();
break; break;
} }