KSPModdingLibs/KSPCommunityFixes

[DragCubeGeneration] Incorrect drag cubes generated for stock fairings

gotmachine opened this issue · 0 comments

See forum report

Basically, the generated drag cubes don't account for the procedural meshes, only the fairing base, obviously causing large drag values.

This is due to my attempt at optimizing getting the part renderers by relying on the stock modelRenderersCache mechanism.

When the stock fairings are loaded, meshes are generated in SpawnMeshes(), which also update the drag cubes (AssumeClosedDragCube() > RenderProceduralDragCube()), but only after that calls ResetModelRenderersCache(), meaning we can't rely on the cache being up-to-date.

In hindsight, the likeliness of such issues is quite high, aside from this specific issue with the stock fairings code we probably can't assume that mods are correctly keeping that cache up to date. Reverting to a plain GetComponentsInChildren() call is a lot safer and the perf hit will still be much lower than what the stock code does.