Jump to content

Can a node_collider mesh be concave?


Yorik

Recommended Posts

I\'m thinking about making a Babylon5-Starfury for KSP, and was wondering whether I\'d need to make the body in 5 separate pieces or whether 1 big piece would suffice. That would require the collision-mesh to be concave.

Link to comment
Share on other sites

I\'ve heard that node_collider must be convex but I\'ve never tried a concave one. Might you test a simple model with concave node_collider and tell here what happens? :)

UPDATE. It\'s strange but I made a part with concave collider -- and it worked just fine. It neither exploded nor fell through the ground nor even became unclickable in the VAB.

Am I doing something wrong? :-X

Link to comment
Share on other sites

Short answer: No.

Long answer: No, the physics engine that Unity runs on (PhysX if I\'m not mistaken) doesn\'t support concave collision meshes. Having a concave collision mesh will result in unpredictable results as the engine will not know how to handle it (although from experience it will attribute it a generic box collider which englobes the model). However, splitting your part in 5 pieces does indeed work. Although as long as it\'s convex, you can wrap it around your part (Such as putting a surface between two beams - since in KSP the likelihood of hitting something that would pass through the space between said beams is very thin, having a hard surface them is a good approximation of the interaction which is going to happen 99.9% of the time.)

Link to comment
Share on other sites

Unity is indeed based off of Phys-X. Concave meshes do not properly solve, so its best to avoid them if at all possible. One of two things will happen with unity, Either it will automatically detect and correct the mesh by creating a box around it (and use that instead of your mesh) or it will just fail completely and your object will explode or fall through things randomly.

I\'m under the impression that its the second option, as when I\'ve tested concave meshes, things just blow up all the time.

That being said there are a few guidelines that are not as obvious. (Not all of these are set in stone, but they work well for me)

The collider has to be under 256 triangles. So only use simple primitives if possible. Its unnecessary to have a complex mesh.

The mesh\'s complexity will determine how much an impact your part has on the physics engine. More complex meshes take much longer to check for collisions then simple ones. So people with weak computers or a lot of parts at once will make the engine chug.

I tend to make the collider just a little bit smaller then the actual part. This allows connections to be made without them turning red (colliding another part). It also seems to help objects randomly being destroyed, and makes it look like things are resting on the ground instead of floating over it slightly.

Additional information to all your questions can be found on these two links.

http://unity3d.com/support/documentation/Manual/Physics.html

http://unity3d.com/support/documentation/Components/class-MeshCollider.html

Link to comment
Share on other sites

Unity is indeed based off of Phys-X. Concave meshes do not properly solve, so its best to avoid them if at all possible. One of two things will happen with unity, Either it will automatically detect and correct the mesh by creating a box around it (and use that instead of your mesh) or it will just fail completely and your object will explode or fall through things randomly.

It seems that I faced the first case. A part I tested behave just as if its collider was completely O.K. Probably Unity auto-corrected it.

UPDATE. C7, thanks a lot for an explanation. I\'ve added a reference to Tips and tricks list.

Link to comment
Share on other sites

  • 1 month later...

Here\'s a image of it in Blender; This is an old SudayPunch part, and the only change I made was a config edit to add stack nodes so they attach to the baseplate I made.

hnhWN.png

The collider is the green cube.

So, as you can see, colliders do not even have to encompass or touch your mesh at all, they\'re pretty unrelated, and you only need to match the mesh shape if you\'re going to be surface-attaching things to it (though its generally better to do so if you can.) Since the fairings are just cosmetic right now, the collider pretty much just serves as the attachment point, so it being small, and moving the visual mesh out to form the '2m' ring of panels worked fine. Of course, the small collider is also what makes it harder to click on.

Since the fairing is concave, Sundaypunch had to do something else. You must remember that this part is probably the 1st fairing in the game, and people have refined how to make thing since then (which is why I converted them into using the base plate, they originally were surface-attach only)

Link to comment
Share on other sites

  • 2 years later...

I have to resurrect this thread because I was about to make a concave collider for my part and might run into some problems.

I'm not exactly sure how what shape the collider would have.

I wanted to make two colliders: one for the folded version(basically a cylinder) and and an additional that comes with toggling to the unfold animation.(hollow tube)

Now I don't know if it would work. The toggled expanded bucket is worrying me. What would be the best solution if I had to split up the collider into multiple parts? Make boxes for the various parts of the mesh?

Here's the animated version I posted a while ago( it's basically still the same model as in the picture, just added some polys to circumvent the z-fighting issue I ran into.polycount is still low)

Tr6Ked7.gif

Link to comment
Share on other sites

I supposed the first question would be what is this and what does it do?

based on pWings... I think you can build your mesh collider at the smallest shape; skin it to your rig that opens the net thing. the collider should change up along with the bucket. a simpler collider for the base cylinder will ensure the part is right-clickable.

Honestly I recommend redesigning the part. As it is now, you either have to settle with a "solid" center; or a high number of individual colliders that may eat up frame rate in VAB/SPH, and potentially nightmarish collision calculations if something gets caught in the netting.

Edited by nli2work
Link to comment
Share on other sites

The prior discussion of this thread does not apply any more, node_collider has been obsolete since PartTools was introduced in 0.18

Concave colliders are permissible but they are much more expensive, orders of magnetudes of magnetudes more expensive, and if two concave colliders touch each other weird things happen up to and including the heat death of the universe. Keep in mind that terrain is a concave collider.

The better option would be for you to section the hollow collider into a bunch of fingers, this can be done via duplication and rotation once a single one is configured properly. As mentioned, concave colliders are very expensive to compute collisions against, so a large number of concave colliders will likely still be cheaper; and if you can built and animate it using cube primitive colliders then it will be almost free.

However, if this part is to be any of the normal stack diameters we're used to in KSP, having that many colliders in a small space may very likely result in krakens, and if something were in the mouth of it when it closed, they would likely both explode.

Finally, I know of no way without a plugin to toggle the collideability of colliders, I also haven't really ever seen anyone try so you'll have to test; but you may just have to live with all of these colliders being active at all times.

I recommend you start a new thread on the matter once you get to trying things, this thread will only confuse people trying to help you and won't appropriately attract people with applicable knowledge

Link to comment
Share on other sites

You know, there's a really easy way to make a concave box collider though I don't know if Unity can handle it.

Have one collider inside another with the top surfaces flush with each other, if something is intersecting the outer collider you have a collision, if it's intersecting the inner collider as well it is ignored, a negative collider in effect.

It's just two cubes, light on resources and gives you four sides and a base, great for a cargo bay :)

Link to comment
Share on other sites

Are you sure guys about concave colliders, according to this:

There are some limitations when using the Mesh Collider. Usually, two Mesh Colliders cannot collide with each other. All Mesh Colliders can collide with any primitive Collider. If your mesh is marked as Convex, then it can collide with other Mesh Colliders.

(colliders which can't collide ? :huh:)

What I've done with my part is split concave mesh into convex sub-meshes, ex: a V shape is just split into the two V arms, so I can put small parts like z-100 battery inside the V (impossible if one single convex collider used).

Link to comment
Share on other sites

Are you sure guys about concave colliders, according to this:

(colliders which can't collide ? :huh:)

What I've done with my part is split concave mesh into convex sub-meshes, ex: a V shape is just split into the two V arms, so I can put small parts like z-100 battery inside the V (impossible if one single convex collider used).

read a few lines down. or the end of that sentence.

Convex If enabled, this Mesh Collider will collide with other Mesh Colliders. Convex Mesh Colliders are limited to 255 triangles.

And no, no such thing as concave colliders in Unity. anything that appears concave in game is a collection of overlapping colliders to approximate a concavity.

Link to comment
Share on other sites

read a few lines down. or the end of that sentence.

And no, no such thing as concave colliders in Unity. anything that appears concave in game is a collection of overlapping colliders to approximate a concavity.

Of course, still a non-convex (checkbox not checked) collider won't collide (why call this collider ?)

If you look at Squad parts, they have never made concave shape, never, and all "concave looking" shapes (like NASA mission engines cluster for example) are a big convex thing. And hollow cylinders like the 2.5 SAS module is not hollow, you can't put parts inside, the same as others parts, holes/concavity are filled by convex colliders.

Link to comment
Share on other sites

The thing is part of an air-to-air refueling system.(where the fuel boom gets into to suck fuel)

My latest idea was to basically use 2 collider set-ups.

One for the base,where a cylinder might be enough and a few flat boxes scattered around the net(should be ~18).

No animation for those colliders, just a switch to enable the flat boxes(cylinder stays the same)after the net has expanded.(not very elegant but ok for an alpha release)

The hole in the middle should still be accessible.

Would that eat up too much resources?

Edited by ximrm
Link to comment
Share on other sites

I'm able to approximate concave colliders by using convex mesh colliders. Basically, I split the collision mesh into four 90-degree sections and use those, rather than a single one. That's how I'm able to get my active-passive docking port working correctly.

iOdEisP.jpg

It does require a bit of wizardy besides the collider setup to work but I'd say that the collider setup is the coolest part of this docking port. It's very finicky but that's likely because the drogue (where the orange probe goes when docking) is so small, but it works as a proof-of-concept.

I'll post a Unity Package here later today so everyone can take a look at it. It may be what you're looking for to get that air-to-air refueling working, ximrm.

Edited by OrbitusII
Link to comment
Share on other sites

Here's the Unity Package, and apparently the thing isn't set up the way I thought, but it still works.

DockingPortUnity.zip (DropBox)

I'd recommend observing some of its behavior in KSP so you have an idea of what it does, here's the link to my mod with the functional version.

One-Eye Industries

Also, 1000 posts. :D

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...