Skip to content

Commit

Permalink
Fix texture deletion. v8.1.1 FINAL
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanKell committed Oct 19, 2014
1 parent cae9339 commit d88785d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 28 deletions.
Binary file modified RealSolarSystem/Plugins/RealSolarSystem.dll
Binary file not shown.
3 changes: 3 additions & 0 deletions RealSolarSystem/Readme_RSS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ Pluto is represented by Vall

===========================
Changelog
v8.1.1
*Fixed stupidity where I deleted textures after loading them.

v8.1
*Completely revised loading system to use coroutines, added GUI. RSS will now load at the main menu, over a period of time to allow garbage collection to run. RAM usage should no longer spike as badly. Many thanks to stupid_chris for getting me set up with coroutines, and to Sarbian for help fixing some remaining issues. While loading may take slightly longer, you should be able to use more textures/parts, and you now get a handy GUI to track status.
*Support calling textures from GameDatabase for the scaled space textures (SSColor, SSBump). This allows use combined with Sarbian's DDSLoader.
Expand Down
4 changes: 2 additions & 2 deletions Source/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.8.1.0")]
[assembly: AssemblyFileVersion("0.8.1.0")]
[assembly: AssemblyVersion("0.8.1.1")]
[assembly: AssemblyFileVersion("0.8.1.1")]
38 changes: 12 additions & 26 deletions Source/RealSolarSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1554,10 +1554,9 @@ private IEnumerator<YieldInstruction> LoadScaledSpace(ConfigNode node, Celestial
{
guiExtra = "Color map";
//Texture2D map = GameDatabase.Instance.GetTexture(path, false);
Texture2D omap = null;
Texture map = null;
Texture[] textures = Resources.FindObjectsOfTypeAll(typeof(Texture)) as Texture[];
foreach (Texture tex in textures)
Texture2D map = null;
Texture2D[] textures = Resources.FindObjectsOfTypeAll(typeof(Texture2D)) as Texture2D[];
foreach (Texture2D tex in textures)
{
if (tex.name.Equals(path))
{
Expand All @@ -1570,16 +1569,17 @@ private IEnumerator<YieldInstruction> LoadScaledSpace(ConfigNode node, Celestial
yield return null;
if ((object)map == null)
{
print("RSS Loading local texture " + path);
localLoad = true;
success = false;
if (File.Exists(KSPUtil.ApplicationRootPath + path))
{
omap = new Texture2D(4, 4, replaceColor == 1 ? TextureFormat.RGB24 : TextureFormat.RGBA32, true);
omap.LoadImage(System.IO.File.ReadAllBytes(path));
map = new Texture2D(4, 4, replaceColor == 1 ? TextureFormat.RGB24 : TextureFormat.RGBA32, true);
map.LoadImage(System.IO.File.ReadAllBytes(path));
yield return null;
omap.Compress(true);
omap.Apply(true, true);
map = (Texture)omap;
map.Compress(true);
yield return null;
map.Apply(true, true);
yield return null;
success = true;
}
Expand All @@ -1600,14 +1600,6 @@ private IEnumerator<YieldInstruction> LoadScaledSpace(ConfigNode node, Celestial
oldColor = null;
yield return null;
}
if(t.gameObject.renderer.material.GetTexture("_MainTex") != map)
t.gameObject.renderer.material.SetTexture("_MainTex", map);
}
if (localLoad)
{
DestroyImmediate(map);
map = null;
yield return null;
}
}
yield return null;
Expand Down Expand Up @@ -1642,6 +1634,7 @@ private IEnumerator<YieldInstruction> LoadScaledSpace(ConfigNode node, Celestial
yield return null;
if (loadInfo.compressNormals)
map.Compress(true);
yield return null;
map.Apply(true, true);
yield return null;
}
Expand All @@ -1651,25 +1644,18 @@ private IEnumerator<YieldInstruction> LoadScaledSpace(ConfigNode node, Celestial
if (success)
{
Texture oldBump = t.gameObject.renderer.material.GetTexture("_BumpMap");
bool replacedOrig = false;
if (oldBump != null)
{
foreach (Material m in Resources.FindObjectsOfTypeAll(typeof(Material)))
{
if (m.GetTexture("_BumpMap") == oldBump)
if (m.GetTexture("_BumpMap") == oldBump || m == t.gameObject.renderer.material)
m.SetTexture("_BumpMap", map);
}
DestroyImmediate(oldBump);
oldBump = null;
yield return null;
}
if(t.gameObject.renderer.material.GetTexture("_BumpMap") != map)
t.gameObject.renderer.material.SetTexture("_BumpMap", map);
}
if (localLoad)
{
DestroyImmediate(map);
map = null;
yield return null;
}
yield return null;
guiExtra = "";
Expand Down

0 comments on commit d88785d

Please sign in to comment.