Radial attached parts -- attach node oddities -- flicker between attach and not attach
shadowmage45 opened this issue ยท 4 comments
Noticed while attempting to attach some engines to radially attached fuel tanks that they did not want to attach to the nodes very well.
Attempting to attach a part to the bottom node of a radially attached MFT-D fuel tank will result in the part flickering between attached and not attached; attempting to click to attach the part will result in it either attaching properly or not attaching depending on how it is currently flickering.
Makes it extremely hard to add engines to radially attached tanks.
Unsure if this is related to the engine parts or the tank parts, though likely it will manifest on any resizable part as they all share the same attach-node position updating code.
Was being caused by drag-cube updates in the editor for not-yet-attached parts with symmetry counterparts.
Drag cube updating has been disabled for all parts while in the editor; not needed for any stock or mod function that I'm aware of.
From a bit more investigation this appears to be caused by something in the changed symmetry-part code as the issue only manifests when symmetry is involved.
May need to move some of the initialization code to later in the startup process or somehow test if it is a symmetry part and skip some of the init code.
This 'bug' effects all procedural/modular parts that I have tested; tanks, engines, etc.
It will even occur when the modular part is placed onto a -stock- tank that has been attached using symmetry.
In case there is ever a use case for having drag cubes updated in the editor, I found a way to defer drag cube rendering (abbreviated somewhat for clarity):
public void UpdateSubtype()
{
// ...
if (affectDragCubes)
{
if (HighLogic.LoadedSceneIsEditor && part.parent == null && EditorLogic.RootPart != part)
part.OnEditorAttach += UpdateDragCubesOnAttach;
else
RenderProceduralDragCubes();
}
}
private void UpdateDragCubesOnAttach()
{
part.OnEditorAttach -= UpdateDragCubesOnAttach;
RenderProceduralDragCubes();
}
private void RenderProceduralDragCubes()
{
DragCube newCube = DragCubeSystem.Instance.RenderProceduralDragCube(part);
part.DragCubes.ClearCubes();
part.DragCubes.Cubes.Add(newCube);
part.DragCubes.ResetCubeWeights();
}