Skip to content

Commit

Permalink
Fix the map exporting deactivating the PQS
Browse files Browse the repository at this point in the history
Setting the PQS object inactive was destroying the SpaceCenter,
along with other side effects. Just disabling the PQS component
archives what we need too.
StollD committed Jun 1, 2018
1 parent 99f8326 commit 71becc4
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/Kopernicus/UI/PlanetTextureExporter.cs
Original file line number Diff line number Diff line change
@@ -73,8 +73,7 @@ public static IEnumerator UpdateTextures(CelestialBody celestialBody, TextureOpt
}

// Tell the PQS that we are going to build maps
pqsVersion.isBuildingMaps = true;
pqsVersion.isFakeBuild = true;
pqsVersion.SetupExternalRender();

// Get the mod building methods from the PQS
Action<PQS.VertexBuildData> modOnVertexBuildHeight =
@@ -88,12 +87,12 @@ public static IEnumerator UpdateTextures(CelestialBody celestialBody, TextureOpt
pqsVersion,
typeof(PQS).GetMethod("Mod_OnVertexBuild", BindingFlags.Instance | BindingFlags.NonPublic));

// Disable the PQS
pqsVersion.gameObject.SetActive(false);

// Get all mods the PQS is connected to
PQSMod[] mods = pqsVersion.GetComponentsInChildren<PQSMod>()
.Where(m => m.sphere == pqsVersion && m.modEnabled).ToArray();
.Where(m => m.sphere == pqsVersion && m.modEnabled).OrderBy(m => m.order).ToArray();

// Prevent the PQS from updating
pqsVersion.enabled = false;

// Create the Textures
Texture2D colorMap = new Texture2D(pqsVersion.mapFilesize, pqsVersion.mapFilesize / 2,
@@ -107,7 +106,6 @@ public static IEnumerator UpdateTextures(CelestialBody celestialBody, TextureOpt
Color[] colorMapValues = new Color[pqsVersion.mapFilesize * (pqsVersion.mapFilesize / 2)];
Color[] heightMapValues = new Color[pqsVersion.mapFilesize * (pqsVersion.mapFilesize / 2)];


// Create a VertexBuildData
PQS.VertexBuildData data = new PQS.VertexBuildData();

@@ -246,8 +244,8 @@ public static IEnumerator UpdateTextures(CelestialBody celestialBody, TextureOpt
}

// Close the Renderer
pqsVersion.isBuildingMaps = false;
pqsVersion.isFakeBuild = false;
pqsVersion.enabled = true;
pqsVersion.CloseExternalRender();

// Declare that we're done
ScreenMessages.RemoveMessage(message);

0 comments on commit 71becc4

Please sign in to comment.