From dd3b8bdab4b5e73b1f2cecc0e3ed734c0dccb348 Mon Sep 17 00:00:00 2001 From: dexy Date: Wed, 9 Jan 2019 16:55:11 +1100 Subject: [PATCH] Waiting for textures to load before rendering --- App.config | 5 ++-- Properties/Settings.Designer.cs | 4 +-- Properties/Settings.settings | 2 +- Rendering/Renderer.cs | 50 ++++++++++++++------------------- 4 files changed, 27 insertions(+), 34 deletions(-) diff --git a/App.config b/App.config index 11bc587..b4b2dcc 100644 --- a/App.config +++ b/App.config @@ -92,7 +92,7 @@ True - False + True 2147483648 @@ -153,7 +153,8 @@ - + Move Forwards: W Move Backwards: S Move Left: A diff --git a/Properties/Settings.Designer.cs b/Properties/Settings.Designer.cs index 96d1489..17a998e 100644 --- a/Properties/Settings.Designer.cs +++ b/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace CodeWalker.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.5.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); @@ -349,7 +349,7 @@ namespace CodeWalker.Properties { [global::System.Configuration.UserScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("False")] + [global::System.Configuration.DefaultSettingValueAttribute("True")] public bool WaitForChildren { get { return ((bool)(this["WaitForChildren"])); diff --git a/Properties/Settings.settings b/Properties/Settings.settings index 8ce42d8..0e1a98f 100644 --- a/Properties/Settings.settings +++ b/Properties/Settings.settings @@ -84,7 +84,7 @@ True - False + True 2147483648 diff --git a/Rendering/Renderer.cs b/Rendering/Renderer.cs index 144164a..011fc59 100644 --- a/Rendering/Renderer.cs +++ b/Rendering/Renderer.cs @@ -1585,10 +1585,6 @@ namespace CodeWalker.Rendering if (renderentities) { - //go through the render list, and try ensure renderables and textures for all. - //if an entity is not fully loaded, set a flag for its parent, then traverse to root - //until found an entity that is fully loaded. - //on a second loop, build a final render list based on the flags. for (int i = 0; i < renderworldentities.Count; i++) { var ent = renderworldentities[i]; @@ -2741,7 +2737,7 @@ namespace CodeWalker.Rendering - //bool alltexsloaded = true; + bool alltexsloaded = true; for (int mi = 0; mi < rndbl.AllModels.Length; mi++) @@ -2774,7 +2770,7 @@ namespace CodeWalker.Rendering if (dtex == null) //else //if (texDict != 0) { - var waitingforload = false; + bool waitingforload = false; if (rndbl.SDtxds != null) { //check the SD texture hierarchy @@ -2792,16 +2788,32 @@ namespace CodeWalker.Rendering } if (dtex != null) break; } + + if (waitingforload) + { + alltexsloaded = false; + } } if ((dtex == null) && (!waitingforload)) { //not present in dictionary... check already loaded texture dicts... (maybe resident?) var ytd2 = gameFileCache.TryGetTextureDictForTexture(tex.NameHash); - if ((ytd2 != null) && (ytd2.Loaded) && (ytd2.TextureDict != null)) + if (ytd2 != null) { - dtex = ytd2.TextureDict.Lookup(tex.NameHash); + if (ytd2.Loaded) + { + if (ytd2.TextureDict != null) + { + dtex = ytd2.TextureDict.Lookup(tex.NameHash); + } + } + else + { + alltexsloaded = false; + } } + //else { } //couldn't find texture dict? if ((dtex == null) && (ytd2 == null))// rndbl.SDtxds.Length == 0)//texture not found.. @@ -2879,28 +2891,8 @@ namespace CodeWalker.Rendering } } - //if (rndbl.SDtxds != null) - //{ - // for (int i = 0; i < rndbl.SDtxds.Length; i++) - // { - // if (!rndbl.SDtxds[i].Loaded) - // { - // alltexsloaded = false; - // } - // } - //} - //if (rndbl.HDtxds != null) - //{ - // for (int i = 0; i < rndbl.HDtxds.Length; i++) - // { - // if (!rndbl.HDtxds[i].Loaded) - // { - // rndbl.AllTexturesLoaded = false; - // } - // } - //} - rndbl.AllTexturesLoaded = true;// alltexsloaded;// || (missingtexcount < 2); + rndbl.AllTexturesLoaded = alltexsloaded; return rndbl;