KSPModdingLibs / KSPCommunityFixes

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

[DragCubeGeneration] Fix for in editor detached parts can cause incorrect drag cubes with modded shaders #150

Closed gotmachine closed 1 year ago

gotmachine commented 1 year ago

Stock rules for drag cube generation is to ignore any renderer on layer 1 (TransparentFX). But when a part is detached in the editor, all renderers are set to this layer, resulting in no drag cube being generated at all. To fix that, KSPCF uses the underlying stock logic to determine what was the original layer, which is that a renderer whose shader name contain the substring "Translucent" should be on the TransparentFX layer.

But not following that arcane and fragile stock rule doesn't have much side effects in practice, and consequently there are mods using shaders with the "Translucent" substring on renderers that are on the regular 0 layer. In combination with the KSPCF fix, this result in those renderers to always be ignored, causing wrong drag cubes to be generated.

As of writing, this notably result in parachutes and solar panels having wholly incorrect drag cubes when the Shaddy + TU mods are installed.

I can't think of any reliable way to both fix the in editor issue and prevent the deviation from the stock drag cube generation rules. Given that the editor issue is pretty minor while the fix has much more dramatic consequences, reverting to the stock behavior seems the best course of action.

This being said, it is possible to keep the stock behavior while adding some partial mitigation for the stock bug, ignoring the stock "ignore stuff on TransparentFX" rule when the Part.frozen flag is true. This is imperfect because :