KSPModdingLibs / KSPCommunityFixes

Community patches for bugs in the KSP codebase.
https://github.com/KSPModdingLibs/KSPCommunityFixes/releases/latest
57 stars 19 forks source link

New patch : DragCubeGeneration #139

Closed gotmachine closed 1 year ago

gotmachine commented 1 year ago

So after much fiddling around, I got a prototype re-implementation working. This is intended to address issue #137

Here is a preview release : KSPCommunityFixes_DragCubeGeneration_RC3.zip

Some profiling stats, for loading a stock + DLCs install :

So KSPCF drag cube generation is taking ~2.5s instead of ~10s. This was tested with a 6700XT GPU, it's probable the gains won't be as good with a low end GPU where the bulk of the time is spent doing the render and texture readback.

Aside from loading time (which are only relevant when the part database is regenerated), this also provide a significant in-game speedup for everything that generate drag cubes on the fly. In stock, this only affect fairings, but there are many mods making heavy use of runtime drag cube generation (either manually, or by using the stock "procedural" drag cubes system). Popular examples include B9PartSwitch, SimpleAdjustableFairings, SSTU, Procedural Parts, ProceduralWings, DecouplerShroud...

All optimizations are done by avoiding some pointless CPU overhead, and massively reducing GC allocations :

As of now, the KSPCF implementation has a few differences with the stock one, resulting in different drag cube values :

The patch also fix two stock issues :

As a bonus feature, the patch also implements a visual "drag cube debugger" available from the "physics" tab of the stock debug window.