Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 :
IMultipleDragCube
moduleIMultipleDragCube
module is present :Camera.Render()
call from doing useless things on unused renderers)Camera.Render()
callsDragCubeSystem.CalculateAerodynamics()
)As of now, the KSPCF implementation has a few differences with the stock one, resulting in different drag cube values :
DragCubeSystem.CalculateAerodynamics()
re-implementation is more precise when computing the drag coefficient, so the final value will always be slightly different.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.