Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Dead horse time: why can't we get more primatives???

Discussion in 'General Discussion' started by Not_Sure, Sep 24, 2020.

  1. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    2,781
    Cylinder
    Wedge
    Cone

    I know this has been posted before again and again, but I'm sitting here making a cylinder in blender and can't help to be a little irked that it's 2020 and someone at unity can't find the couple hours to make this into a built in primative.

    Why exactly has this not been added?

    I know I can just do this and that. But come on, it's 2020. This engine is 15 years old. People are always posting this and it's so unbelievably simple to implement.

    I almost feel like this is getting to be a point of stubborn contempt and is getting a little ridiculous.

    Sorry if I'm being whiney.
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    8,388
    Mostly because game engines do not usually deal with primitives. They deal with polygonal soups. People also are not posting this, you're the first one I see asking about it.

    The engine also is not 15 years old. 15 years old implies that in last 15 years it didn't change in the slightest, which is not the case.

    You also can just grab a brush based or CSG kit, and those usually come with primtiives. SabreCSG is one of the options.
     
  3. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,233
  4. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    2,781
    I know there's work arounds.

    I went ahead and throw one together in blender in a couple minutes.

    That wasn't the point I was trying to make. I'm saying it seems silly that they are omitted from the built in primatives. And I have seen multiple posts about this.

    Personally I run into this multiple times when prototyping. I find it a stretch that others don't as well.
     
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    9,290
  6. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    799
    Cylinder isn't really a primative, it can only be represented by a mesh?
     
  7. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    2,781
    I'm positive that's not true.

    Although, I can't say for certain if it's not cheaper to do it via meshes.
     
  8. Ukounu

    Ukounu

    Joined:
    Nov 2, 2019
    Posts:
    98


    Are you talking about some other "cylinders"?
     
  9. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    16,211
    This. I'm of the opinion they should make ProBuilder a default package and make it so that when you click one of the primitives in the list it generates a ProBuilder asset in that shape. I'm willing to bet though that they can't be removed thanks to the backwards compatibility nonsense that comes with those fifteen years.
     
  10. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    2,781
    That’s not actually a cylinder.

    it’s a cylinder mesh with a capsule collider.
     
  11. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    489
    Just for there record there is no primitive collider for cylinder in physx.
     
  12. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    799
    Just like I thought

    Edit: but it's a convex mesh collider atleast
     
  13. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,368
    As @koirat says, there is no CylinderCollider in PhysX. Either you have to use a CapsuleCollider (fast, but slightly inaccurate to the shape), or a MeshCollider (slower, but accurate). Neither is a clearly superior option so I doubt we'll change it now.
     
  14. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    799
    Are you going to eat your hat now? :)
     
  15. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    489
    There is also an option to have Capsule collider and cylinder (mesh collider) inside. (optionally to have 2 cylinder colliders (mesh collider) on both ends).

    If this mesh collider is slightly smaller than a capsule collider, your cylinder will be able to roll quite nicely, and you can have partial CCD.
     
  16. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    2,781
    With salt and pepper.

    I actually was not thinking of it as a physx, but as a 3D shape being expressed by a formula rather than polygons.

    If physx does not have it, then it’s safe to say that it’s too expensive.

    EDIT: I will also concede that I am hardly an authority on all this.
     
    Last edited: Sep 24, 2020
    MDADigital likes this.
  17. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    799
    Sounds expensive? We use a capsule collider for our spent casing (not particle systme because you can interact with the spent casings, or rather if its unspent). upload_2020-9-24_21-33-2.png

    But it does not behave perfect
     
  18. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    489
    Yes I would not use mesh collider for a bullets casting. But in your case since you got some interaction with it I would try to use two capsule colliders for this long bullet. You could also recalculate center of gravity for this bullets.
     
  19. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    8,388
    PhysX does not support cylinder colliders.

    No, ODE used to have cylinder collider. However, I believe it also didn't support cylinder-cylinder collisions.

    Game engines usually do not deal with pure mathematical primitives outside of collision detection and deal specifically with polygonal soups.

    Building things out of shapes is CSG (constructive solid geometry) appraoch, and usually this one is used in CAD, although first BSP levels were built out of shapes called brushes.
     
  20. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    5,570
    Mathematical cylinder collision shouldn't be hard to implement anyway? it's a non normalized dot product with a range and a radius, I don't know about the physics resolution of it though. I also wish we had cones and also rounded cones (a tapered capsule). I find capsule horrendous for game purpose, especially character controller, a real bane of all existence.
     
    Not_Sure likes this.
  21. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    8,388
    For physics, you need to calculate contact normal for overlapping body, for all combinations of bodies (cylinder->plane, cylinder->box, cylinder->sphere, cylinder->capsule, cylinder->cylinder, cylinder->convex mesh, cylinder->polygonal soup). And most likely physical library developers don't want to deal with two curved edges on a cylinder. Capsules are simpler, because they have spheres as caps.
     
    Not_Sure likes this.
  22. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    489
    As I know there is also problem with CCD for cylinder.
     
  23. Not_Sure

    Not_Sure

    Joined:
    Dec 13, 2011
    Posts:
    2,781
    Okay, correct me if I’m wrong, and I probably am, but isn’t a cylinder a capsule with flat ends?

    why not just do a capsule and ignore collisions past the a certain point?

    I’m completely out of my depth here, but that seems super easy.
     
  24. JohnnyA

    JohnnyA

    Joined:
    Apr 9, 2010
    Posts:
    4,882
    Have a look at the complexities of a 'simple' solution for cylinders: http://larochelle.sdsmt.edu/publica...indrical Rigid Bodies Using Line Geometry.pdf

    This paper compares some different shapes: https://web.archive.org/web/2012091...de/Publications/Theses/2010/Suenkel_BA_10.pdf

    You can see that collision detection for cylinders is much more complex than many other simple shapes.
     
  25. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,368
    Think about it this way: a capsule can be easily defined in terms of a line segment and a distance. It doesn't matter what the orientation of the line segment is relative to your other primitive, you just need those two points and the radius, and you can do everything in world space. The normal vector on the surface - that you need for calculating collision response - is also always just the vector from the nearest point on the line segment, towards the point on the surface you're interested in. No conditional logic, beyond clamping a parameter value that describes how far along the line segment you are.

    A cylinder, by comparison, is way more complicated - you have to do things like transforming the points you're interested in into local space for the cylinder, then have conditional logic based on whether you're interested in points on the 'cap' or points on the curved surface - and of course you're going to need to deal with situations where the contact point is on the boundary between the cap and the curved surface too. It's doable, but it's far more complex and slow than a more easily-defined primitive like a capsule or sphere.
     
  26. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    8,388
    Nope. However, a capsule is two spheres connected by a tube.

    It doesn't work this way. For every possible overlap, you have to determine contact point and contact normal. Those are required, otherwise physics won't resolve, and bodies won't correctly bounce off each other.

    So, you can't "ignore" something.
     
unityunity