Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Orbit Icon customization tanks FPS in Planetarium Camera #309

Closed
Poodmund opened this issue Sep 2, 2018 · 4 comments
Closed

New Orbit Icon customization tanks FPS in Planetarium Camera #309

Poodmund opened this issue Sep 2, 2018 · 4 comments

Comments

@Poodmund
Copy link

Poodmund commented Sep 2, 2018

The new custom Orbit Icon feature introduced in 1.4.5-3 seems to tank the FPS when the Planetarium camera is active.

Reproduction steps:

  • Vanilla KSP
  • Go to Tracking Station
  • View FPS

  • Vanilla KSP install + Kopernicus 1.4.5-4 + Dependencies
  • Go to Tracking Station
  • View FPS

See the difference. These are the values I pulled from my tests:

KSP 1.4.5 Stock                                         165fps (monitor limit)
KSP 1.4.5 + Kopernicus 1.4.5-4                          80fps
KSP 1.4.5 + Kopernicus 1.4.5-3                          85fps
KSP 1.4.5 + Kopernicus 1.4.5-2                          165fps (monitor limit)
KSP 1.4.5 + Kopernicus 1.4.5-4 w/ Orbit Icons Removed   165fps (monitor limit)

It seems that the custom Orbit Icon script added to Kopernicus.RuntimeUtility.cs is the cause as when it is removed and recompiled, the issue is not present. The code in question:

// Apply orbit icon customization
foreach (MapNode node in Resources.FindObjectsOfTypeAll<MapNode>())
{
    if (node.mapObject != null && node.mapObject.celestialBody != null && node.mapObject.celestialBody.Has("iconTexture"))
    {
        Texture2D texture = node.mapObject.celestialBody.Get<Texture2D>("iconTexture");
        node.SetIcon(Sprite.Create(texture,
            new Rect(0, 0, texture.width, texture.height),
            new Vector2(0.5f, 0.5f), 100, 1, SpriteMeshType.Tight,
            Vector4.zero));
    }
}

Referenced from this post in the Kopernicus thread: https://forum.kerbalspaceprogram.com/index.php?/topic/140580-145-4-131-13-kopernicus-kittopiatech/&do=findComment&comment=3443919

@marr75
Copy link
Contributor

marr75 commented Sep 3, 2018

Good code-sleuthing. Looking it over, I'd guess that iterating through all resources every time is going to be the cause of the slowdown so I'm trying just the CBs in FlightGlobals. Two problems in testing this: the slowdown wasn't particularly noticeable for me and I don't know of any planet packs released today that use the orbital icon customization. If anyone can try out the replaced loop below and report on whether their performance improved, that would be helpful. If anyone can tell me where to find planet pack with orbital icons, that would be doubly helpful.

Nevermind. I am heavily effected by the map view slowdown, too. It's even worse with a big planet pack like GPP + GEP + OPM installed. My proposed solution threw an exception I don't have time to debug this week so I removed it from this comment.

@Poodmund
Copy link
Author

  • In reference to @marr75 test-release to fix this issue, I installed it and can confirm that I am receiving 165fps in the Tracking Station.
  • I subsequently installed OPM just to test and it was also giving me 165fps in the Tracking Station.
  • I also gave one of the OPM bodies a custom orbit icon and tested again and got 165fps in the Tracking Station: https://i.imgur.com/4TXVjeU.png

So in summary, I can say that this probably solves the issue in a pretty well performing way. If it passes StollD's scrutiny then it looks good.

@marr75
Copy link
Contributor

marr75 commented Sep 13, 2018

Dear diary, today Poodmund, of Skybox and OPMVO fame, QA'ed one of my fixes. :-)

Sorry, something went wrong.

@StollD
Copy link
Member

StollD commented Sep 21, 2018

Should be resolved by merging #310

Thanks @marr75 (and @Poodmund for testing)

Sorry, something went wrong.

@StollD StollD closed this as completed Sep 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants