allista / GroundConstruction

Plugin for the Kerbal Space Program. Allows building vessels on any planet in any place.
Other
12 stars 9 forks source link

Alternate DIY Kit Shapes #29

Closed llinard closed 6 years ago

llinard commented 6 years ago

The current and only DIY kit is a box which seems to simply grow/shrink on all axes. This can result in the "square peg in a round container" problem trying to fit the box in a round fairing, structural tube, cargo hold, or whatever.

A cylindrical DIY kit might better fit in many such scenarios. Some additional options to help fit the DIY container to a specific size might be:

So for example, say I want to fit the kit into a 2.5m fairing. I could choose the cylindrical DIY kit and fix its diameter at 2.25m and let only the height grow.

Or say I wanted a box that would fit on a rover bed of a specific size without overhanging or being excessively tall. I could choose a box DIY kit and set the desired maximum length and maximum width to match the size of the rover bed and leave the height unrestricted.

allista commented 6 years ago

There's already an issue #23 that addresses the problem of bulkhead profile selection and answers a part of your proposition. Cylindrical kit, however, is a good idea.

allista commented 6 years ago

@BobPalmer , would you care to make a cylindrical variant of the kit container?

llinard commented 6 years ago

I saw #23 but I had something more specific in mind and there was no specification or description associated with it. Plus I didn't just want to be able to restrict size by the existing bulkhead profiles. I believe my proposal is more flexible that #23 sounds like it would be.

Plus, in the case of the rover bed how would a bulkhead profile apply there?

allista commented 6 years ago

That's #23 in action: https://gfycat.com/gifs/detail/DrearyForsakenChrysalis

Your proposition is indeed more flexible, but also requires considerably more work.

llinard commented 6 years ago

Actually it probably wouldn't. You would just need 1 or two more sliders to individually adjust length, width or height separately instead of just one that adjusts length/width together. Probably a button or two to lock individual dimensions.

allista commented 6 years ago

You're always welcome to try it yourself and make a PR ;)

llinard commented 6 years ago

The branch is control-kit-dimensions? I might give it a go.

allista commented 6 years ago

That's the one. And I would really appreciate it!

llinard commented 6 years ago

I'm having some trouble getting Visual Studio 2017 to target .NET Framework 2.0. The assembly doesn't work with anything 4.0 or later so far. I'm trying to repair it.

allista commented 6 years ago

I'm on linux, so I use Monodevelop and there also were some trials-and-errors before I've figured out the configuration that worked for KSP. You can try to install Unity Editor which has its own version of Monodevelop, and use it. You'll also probably need the master solution that includes all plugins and AT_Utils: AT_KSP_Plugins.sln.zip

llinard commented 6 years ago

Ok, I figured out why Visual Studio 2017 wasn't seeing the older frameworks. I had to install them as a Windows 10 feature like you do with Windows Server.

I have a working update that I think is ready to push, but its very late and I need to sleep. Plus I haven't pushed across forks before...

llinard commented 6 years ago

Ok. I think I got everything. Also supports cylindrical kits, just set KitType = Cylindrical instead of Box. The default KitType = Box with no constraints so it should be backwards compatible.

allista commented 6 years ago

Awesome! I'll check it as soon as I get home.

allista commented 6 years ago

Thanks, your code is excellent! I'll take some time this weekend to make an actual cylinder kit and release the whole thing.

allista commented 6 years ago

Oh boy, I new there was something important I've missed :(

There's a good reason (two, actually) that the kit container is a box. First, it physically represents the bounding volume of a spawned vessel, so that no collisions could occur on spawning. For cylindric container to do this it was have to be √2 times larger than the box. Second is the spawn transform: the box has 6 of them, one on each side, so that the box could be dropped on any and deployed as is. Cylinder has only 2 suitable sides; so in a pretty probable case of dropping it on the side one would have to actually turn it somehow before deployment. So I guess no cylinder containers after all. At least not without mesh switching before deployment... And that is a completely different matter.

llinard commented 6 years ago

When you say the cylinder only has 2 suitable sides are you referring to the mesh or its logical dimensions (height, diameter)? Because a cylinder mesh has 2 ends plus generally 12+ faces.

When you place a kit on the ground it is really just a static game object that represents a part. How hard would it be to create a new box kit internally and copy all of the kit details to it, remove the cylinder kit from the game, and replace it with the new box it? After all, you are eventually removing the box and replacing it with a whole vessel.

allista commented 6 years ago

It's not that simple. Cylinder (ok, dodecagonal prism) has only two faces that are wide enough to stably land on a terrain collider without rolling about. And no, landed vessel is not a static gameobject; to make it feel like static I actually attach it through a rigid joint to an invisible static anchor made inplace. But no matter. The problem with mesh replacement (I'm not talking of spawning of a new vessel, which is indeed a complicated thing) is that the collider of the new mesh should be contained within the collider of the old mesh; otherwise you're faced with the problem of instantly intersecting colliders producing huge (or inf, or even nan) forces. So no matter how we implement this, in the end a cylinder standing on one of its bases should be replaced by a box of greater density and smaller dimensions to fit the cylinder. And here you'll get a not-so-eye-candy looking visuals of instant shape-shifting. Even worse, a cylinder lying on its side should be replaced by a either a somewhat smaller box that hangs in mid-air, or a box no larger than the side-face of its collider.