Search Unity

Mesh Collider incorrectly generating convex collider

Discussion in 'Physics' started by cloui, Jan 31, 2019.

  1. cloui

    cloui

    Joined:
    Oct 24, 2018
    Posts:
    9
    Hi

    When i enable convex for my mesh collider the collider is not aligned with the mesh or generated correctly. Is my model wrong?

    This was working in unity 2017
     

    Attached Files:

  2. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It could be that the object is badly made, with split faces or flipped normals, so perhaps a new routine failed to care for those edge cases. Can you submit a bug report with the object so Unity can look at it please :) post number in here.
     
  3. cloui

    cloui

    Joined:
    Oct 24, 2018
    Posts:
    9

    Attached Files:

  4. yant

    yant

    Unity Technologies

    Joined:
    Jul 24, 2013
    Posts:
    596
    As far as I can see here, the resulting convex for this segment looks like the initial tetrahedron generated by Quickhull. It should have expanded the hull starting from that and following outside of the tetrahedron's faces, however that didn't happen. I would imagine that's connected to the fact that the torus is actually rather tiny so the precision issues creep in here. I see that the you scale the torus x100 in Unity, but that won't help with precision since we first bake and only then supply scale. Would it help if you apply at least some of the scaling to vertices in the 3d editor (Blender/Maya/etc)
     
    cloui, AlanMattano and hippocoder like this.
  5. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    To add to what was said I would suggest everyone adopt a 1 meter = 1 unit measurement and test that's working for them with a cube imported aligned with a Unity cube.
     
    cloui and yant like this.
  6. RichardCulver

    RichardCulver

    Joined:
    Nov 19, 2013
    Posts:
    6
    I am the graphics artist working on this project. This is an issue with the fbx import in Unity as well as export settings in the source app. If the source app is 1 to 1 (such as Maya) then there is never a visible issue. If you change the scale settings in Maya or use something like Blender, I see this every time. I have checked all of the options in Blender and Maya for Export as well as all of the settings for Model Import in Unity and have not found a way to correct this other than to simply port everything over to Maya and export from there. But for the projects I am working on here with rigs, bones and 100's of collision objects this will mean possibly weeks worth of work that will have to be redone in Maya.

    It would be real nice if there was a setting in Unity that would actually truly apply the scale of the object on Import. I have not found the setting that does this in Model Import Settings.

    In Blender I can do this with a simple object. There is an experimental "apply scale" feature. But it does not work with parenting and rigs, and other more real case scenario situations.

    Am I missing a setting in Unity?
     
    Last edited: Feb 21, 2019
  7. JVimes

    JVimes

    Joined:
    Jan 3, 2022
    Posts:
    10
    It still happens, and seems to be a bug when "Convert Units" is enabled in import settings. Edit: That scaling text box also seems to play a part.
    2022-12-26_21h41_29.png
     
    Last edited: Dec 27, 2022
  8. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    Oldschool Maya user here, moved to Blender a few years ago. I've never had any issues exporting assets from Blender (or Maya) to Unity, afaik there isn't any bug. This is just how units and transform scaling works in 3D: you just need to be careful with your export/import settings, making sure that units and scaling are preserved.

    Applying transform scale (or position/rotation) to an object is a basic operation in 3D graphics. In Blender, you can do it using Object->Apply->Scale (In Maya, you do this using Modify->Freeze Transformations->Scale). If you opt to use the "Apply scale" option of Blender's FBX exporter, it will *try* to apply the scale of all objects right before exporting, but this is just a last resort and often not possible: if you have linear blend skinned meshes and/or complex transform hierarchies -both of which are used in armatures- this will break because it would require recalculating all bind poses and re-biding the mesh to the armature, since transform matrices have had their scales reset. Ideally, scaling should be applied to transforms before creating the armature and binding meshes to it, you should not wait to the very last minute to fix scaling issues in your work because it's often too late by then.

    Recipe to follow: make sure your transform scales are all set to 1 in Blender by applying scales while you're working, and then export your fbx using proper units (check "Apply Unit") and axis (Forward axis is -Z, up axis is Y).
     
    Last edited: Jan 2, 2023
  9. arkano22

    arkano22

    Joined:
    Sep 20, 2012
    Posts:
    1,924
    "Convert units" will convert from the units specified in the file being imported to meters. So for instance if your file contains a cube that's 100x100x100 units and the units specified in the file are centimeters, the cube will be 1x1x1 meters when imported in Unity. Then, all values are multiplied by the "scale factor": a scale factor of 2 will yield a cube that's 2x2x2 meters instead.

    As far as I know, this works as intended (and has been for years).