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

Optimize splash manager system (and maybe explosions?) #254

Open
JonnyOThan opened this issue Sep 30, 2024 · 2 comments
Open

Optimize splash manager system (and maybe explosions?) #254

JonnyOThan opened this issue Sep 30, 2024 · 2 comments
Labels
kspPerformance Possible performance improvement in KSP

Comments

@JonnyOThan
Copy link
Contributor

image

When driving a boat across the water, this gets real expensive. Would pooling help?

@JonnyOThan JonnyOThan added the kspPerformance Possible performance improvement in KSP label Sep 30, 2024
@JonnyOThan JonnyOThan changed the title Optimize endSplashBurst Optimize splash manager system (and maybe explosions?) Jan 30, 2025
@JonnyOThan
Copy link
Contributor Author

JonnyOThan commented Jan 30, 2025

Spent a bit of time on some investigations:

Splashes are created by FXMonger by cloning a prefab from FXMonger.splashes. It manages a queue of splashes to create, and tries to merge ones that are close enough in time and distance. However the splash objects themselves are not pooled. The prefab contains the Splashdown component which self-destructs on a timer, and it's the destruction of the audio source in the cloned object that turns out to be really expensive.

The FXMonger also creates an FXObject and assigns the AudioClip to play in there, but I can't actually see how this gets connected to the AudioSource in the splash object. It follows a similar pattern as explosions, ROC explosions, and debris explosions, but those all have an immediate call to AudioSource.PlayOneShot. It seems like instead, the AudioSource in the prefab already has the clip assigned and plays it on awake. I'm not sure if this has any differences when compared to how PlayOneShot works.

In any case it seems like pooling these effects and re-using them would significantly help here (and maybe for the explosion cases too - need to profile that!). Is there some way that we can leverage AudioMultiPooledFX ?

@JonnyOThan
Copy link
Contributor Author

JonnyOThan commented Feb 1, 2025

Update: this seems to only be this terrible when RSE is installed. Without RSE, instantiating and destroying the splash effects is still pretty expensive but it's not game-breakingly so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kspPerformance Possible performance improvement in KSP
Development

No branches or pull requests

1 participant