Felipe (HarvesteR): This week was a big one. To add the new gizmos to the editor, I had to delve into one of the most convoluted areas of KSP code, the editor logic. That part of the code is very sensitive to small changes, so poorly-planned tweaks to it usually end up creating a heap of bugs.
This time around though, I decided to put an end to it and take on a complete overhaul of the editor logic code. I undid the mess of switch statements and state logic we had, and replaced it completely by a proper finite state machine setup, using the same FSM system I wrote for the Kerbal EVAs for 0.16. The KerbalFSM system is generic and fully expandable, and allows us to have much more control over what is meant to happen and when.
Of course, this meant chucking out a lot of working editor code, but it was for the best. If we had left it as it was, we wouldn’t be able to add new features without increasing even more the complexity of that already critically complex blob of code. It took a lot of recoding, but I can now say it was definitely worth the effort.
There are now four construction modes when you are building a ship.
Place Mode: This is the standard mode, where you click on parts to pick them up or attach or detach them from the ship.
Offset Mode: In this mode, you can select parts from the ship, and on selecting, a translation gizmo will pop up, allowing you to slide the part freely, without detaching it.
Rotate Mode: In this mode, you can rotate the selected parts using a rotation gizmo. This mode also works on unattached parts, and you can also switch to it while attaching too.
Root Mode: This mode is only available if you have an eligible set of parts selected. Activating root mode will allow you to select another part (from the children of the selected set) to attach by. It will reflow the hierarchy much like docking does, so the selected part becomes the new root of the hierarchy. This one is particularly useful for subassemblies and such.
The last few days were mostly devoted to ironing out issues with the new implementation, and improving the way the editor handles rotating parts and symmetry. It is now possible to switch between Radial and Mirror symmetry modes using the Y key (a UI button will follow shortly), both in the VAB and SPH. This is amazingly useful for building shuttles and hybrid type vessels.
I’ve also revised the attachment rotation maths, which could arguably be said to be the ugliest bit of code in the game at the moment. That impossible chunk of logic was tossed out, and a much more elegant system put in its place.
All in all, it’s been a fair amount of improvements to ship construction. Hopefully it should make building ships much more intuitive and fun.