KSPModdingLibs/KSPCommunityFixes

EVAConstruction can alter a part's mass from what it should be when mass modifiers are involved

JonnyOThan opened this issue · 1 comments

Repro steps:

  1. Create a craft that has an inventory container
  2. Add a part that has variants that modify the mass (e.g. RCS block). Change the variant before you add it so that the mass is different from the prefab.
  3. Launch the craft with an engineer on board
  4. In EVA construction, take the part out of inventory and drop it on the ground
  5. Pick the part back up and put it back into an inventory
  6. Note the mass changed

Before removing:
image

After replacing:
image

Separate, but maybe related:

ModuleCargoPart.MakePartSettle changes the mass of the part when it is placed on the ground: changes to 20t on planets with GeeASL < 0.8, and 4t on planets with GeeASL < 1.1. I'm not sure why it does this - it certainly shouldn't affect how fast the part falls. But maybe there were issues with other objects pushing it, or maybe from the effect on the inertia tensor.

In EVAConstructionModeEditor.PickupPart, the stock code sets the selected part's mass to the prefab mass. This effectively undoes the mass increase caused by MakePartSettle, but also has the side effect of getting the mass wrong if there are modules that implement IPartMassModifier (ModulePartVariants, etc). That's the root cause of the above issue.

But, if there are ways to pick up the part or get it into inventory, etc. while it still has the increased mass from MakePartSettle, it could cause a lot of issues. I haven't been able to find one yet, but I have a really strong hunch that #147 might have been caused be that, if not just by #185 directly. Maybe the state machine for surface deployables is different.