Missing Primitives

I know this has come up before, but it never really seems to have been settled. Is there a reason that Unity seems to be missing some basic primitive colliders?

Specifically it seems like the math would be very simple for:
-A Point
-A Line
-A Cylinder
-A Cone
-A Ring
-A Pyramid
-A Wedge

And I know that there are extra primitives available on the store, but don’t all of them just use mesh colliders which defeats the purpose of using a primitive?

How would a point look like? Lines are also do-able with the line renderer component.

Unity uses PhysX for 3D physics, so it depends on what PhysX has support for. The math for performant collision testing isn’t that simple for most of those (e.g. cylinder, ring) and you can just as easily use convex mesh colliders, except for rings. There’s no such thing as a point collision, since that wouldn’t physically exist, being a 0-dimensional object. Lines are also not something that exist in 3D, although edge colliders exist for 2D collision.

–Eric

2 Likes

Those are not basic colliders.

For a physic driven game a collider needs to give you a way to generate contact point, surface normal and possibly penetration depth.

Point, line, ring (did you mean torus here?)would not satisfy those requirements. That’s why you have raycast method instead.

Wedge(prism?) and Pyramid can be represented by a convex mesh collider.

Cylinder collider and Cone collider are missing because they’re not part of PhysX.

You could try Bullet bindings for unity, though. Bullet is supposed to support those.

1 Like

Unity has the primitives it has and to my knowledge has no intention of adding more, which is a pretty solid definition of “settled.”

Now, there are people out there who think Unity should add more primitives, and the matter is not “settled” to them because they do not like the answer.

That’s a pretty strong clue that having a primitive would not be appreciably better or faster than using a well-designed mesh.

2 Likes

Well damn, I was hoping for someone to agree with me. Not counter with a perfectly reasonable explanation. :smile:
.

1 Like

What about using constructive solid geometry with union, intersection, difference? PhysX has a batch mode so it would just be a case of doing the checks in a batch then “and”, “or” or “not” 'ing the hits into a final result. It might even be faster to use a CSG collider than a mesh one?

If it’s so simple, how 'bout trying it and letting us know how it goes? :wink:

1 Like

I don’t think the Unity API surfaces the PhysX batch query api features → http://docs.nvidia.com/gameworks/content/gameworkslibrary/physx/guide/Manual/SceneQueries.html

You could just code it in C# but you would lose the potential batch PhysX performance boost.

There is also a blocking query which improves performance, (checks to see if the LOS is blocked by obstacles) not sure if this surfaces or is used in the Unity API.