B9PartSwitch
B9PartSwitch copied to clipboard
Improper handling of nodes when rescaleFactor is used.
When a part that uses B9PS to move stack node positions (such as an engine with multiple mount options) is rescaled using rescaleFactor, the nodes defined in moduleB9PS get offset much further than they should be, as if the offset was being applied twice.
An example issue here, where Cryoengines parts that use B9PS to handle node positions have their attach nodes broken by rescaleFactor being applied: https://github.com/KSP-RO/RealismOverhaul/pull/2627
The same issue happened with RO and my Modular Launch Pads; the top nodes of the modular tower sections moved up by twice (well, rescaleFactor squared) what they should have as taller variants were selected. NathanKell wrote patches for RO that corrected the wrong values.
I investigated this line of code: https://github.com/blowfishpro/B9PartSwitch/blame/e282eb138340aa0ea2c2926cb48e9c6a1e408d93/B9PartSwitch/PartSwitch/AttachNodeModifierInfo.cs#L49
And it does seem to be doing the right thing AS LONG AS the rescale factor in the prefab is correct. I had initially misread this as cubing the rescale factor but the comment above tries to explain it. We want to scale the node position by scale * rescaleFactor
to match stock part loader behavior. But we don't have the scale
value from the config - we have scaleFactor
which is scale / rescaleFactor
. So then you mutiply by rescaleFactor * rescaleFactor
to end up with scale * rescaleFactor
.
However I think there are other bugs in the actual node moving logic, so maybe that was the problem. Looking there next.