Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[UPDATED] K-DOP Collision Hull Generator

Discussion in 'Assets and Asset Store' started by Daerst, Oct 7, 2016.

  1. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    Generate collision hulls for your meshes with only a few clicks!

    upload_2020-7-15_15-49-6.png

    ► Asset store link

    Feature overview

    • K-DOPs: popular from other big Game Engines
    • Automatic collision hulls without manual effort
    • High-performance collision with a good approximation of the object's shape
    • Works with simple meshes, compound objects and prefabs
    What is this?
    A K-DOP is a k-dimensional discrete oriented polytope, i.e. a set of intersecting plane pairs that together form a simple hull for your object. This asset allows you to quickly (as in one click) generate simple-enough collision geometry for your objects. The generated colliders are convex and thus can be used for rigid bodies.

    Why should I use it?
    Instead of using an artist-created simplified mesh collider or a high-poly mesh at costly performance, K-DOPs are a quick solution that doesn't require manual work. They fit most objects better than the primitive colliders and are considerably faster than detailed mesh colliders. Check out the video below for a quick performance comparison.

    How do I use it?
    Select one or more objects in the editor. In the context menu (right click on windows), find K-DOP Collision and select the desired complexity. This will create a K-DOP collision mesh, store it in your Assets folder (you can change the folder in the same menu) and add a convex MeshCollider to your object with this mesh. A box can be thought of as a 6DOP, since it has 6 planes (or 3 plane pairs) that bound an object. Next in line is the 10DOP, which is a plane with the edges beveled in one direction (X, Y or Z). If all edges are beveled, you end up with an 18DOP. If the corners of the box are beveled too, you get a 26DOP.

    Peformance comparison
     
    Last edited: Jul 15, 2020
  2. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    Update 1.1 is currently being reviewed by the Unity folks and will be available very soon, bringing a huge update in K-DOP generation performance. Check out the video below to see a 26-DOP being generated for a mesh with 871k triangles in a split-second.

     
  3. potatojin

    potatojin

    Joined:
    Apr 11, 2012
    Posts:
    23
    This tool seems very useful, so I purchased it as soon as I found it. It seems to be creating more triangles than I expected on my collision meshes, however.

    I've attached a screenshot of an 18DOP I just created. As you can see, it has 60 triangles. I was expecting 36, for an 18DOP. It seems like some of the triangles are very skinny and unnecessary. What do you think? Is this a bug?

    Thanks!
     

    Attached Files:

  4. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    @potatojin Thank you for your feedback. Would you mind sending over the generated K-DOP and, if possible, the mesh used to create it?

    I think that the number of triangles is not as important as the number of planar surface, since the physics engine will optmize multiple planar triangles to polygons, so this should not be an issue. Very skinny triangles can happen if your mesh is only slightly beveled, and can only be countered by selecting a simpler DOP. Only degenerate triangles are deleted by the algorithm.
     
  5. potatojin

    potatojin

    Joined:
    Apr 11, 2012
    Posts:
    23
    Sure thing. Where should I send it?
     
    Daerst likes this.
  6. VadymIgnatiev

    VadymIgnatiev

    Joined:
    Aug 9, 2017
    Posts:
    1
    Hi, will your plugin work in the runtime on the phone(android or ios) for dynamically generated objects? As I understand, no, and it can be used only in the editor mode.
     
  7. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    The asset is made for editor use only right now, but you will get the complete source code and could modify it to work in runtime. Depending on your performance constraints, optimization might be a challenge though.
     
  8. sefaenes

    sefaenes

    Joined:
    Jul 12, 2019
    Posts:
    22
    @Daerst hey, does it support Unity 2019.3?
     
  9. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    Yep, should be no problem.

    // EDIT: Just tested it in 2019.3, works just fine :)
    upload_2020-7-15_15-56-7.png
     
    Last edited: Jul 15, 2020
  10. sefaenes

    sefaenes

    Joined:
    Jul 12, 2019
    Posts:
    22
    @Daerst I want to ask you something.

    Is there any way to create piecemeal hulls for combined meshes? I have a combined mesh of mountains and all rocks are separated from themselves. how can I create hulls?
     
  11. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    Not possible out of the box. You would need to separate your mesh into individual objects using a 3D mesh editing application (e.g. Blender), and then bake individual K-DOPs for the pieces.
     
  12. bvonline

    bvonline

    Joined:
    Feb 27, 2021
    Posts:
    75
    Does this still work in Unity 2020.x or even 2021? Want to buy it

    For Ragdolls - does it work (several Colliders for one object)? Don't know if this has been answered above directly.
     
  13. Daerst

    Daerst

    Joined:
    Jun 16, 2016
    Posts:
    275
    @bvonline Yes, the asset still works fine in latest Unity versions. It is meant for static meshes however and won't out of the box give you individual shapes for your ragdoll'd characters. You'd have to split the character up into individual parts to get this working.
     
  14. bvonline

    bvonline

    Joined:
    Feb 27, 2021
    Posts:
    75
    Errors in Unity 2020.3.43f1:

    Assets\KDOPCollision\Editor\KDOPMenu.cs(49,9): warning CS0618: 'PrefabType' is obsolete: 'PrefabType no longer tells everything about Prefab instance.'

    Assets\KDOPCollision\Editor\KDOPMenu.cs(49,31): warning CS0618: 'PrefabUtility.GetPrefabType(Object)' is obsolete: 'Use GetPrefabAssetType and GetPrefabInstanceStatus to get the full picture about Prefab types.'

    Assets\KDOPCollision\Editor\KDOPMenu.cs(50,38): warning CS0618: 'PrefabType' is obsolete: 'PrefabType no longer tells everything about Prefab instance.'

    Assets\KDOPCollision\Editor\KDOPMenu.cs(51,38): warning CS0618: 'PrefabType' is obsolete: 'PrefabType no longer tells everything about Prefab instance.'

    Assets\KDOPCollision\Editor\KDOPMenu.cs(52,38): warning CS0618: 'PrefabType' is obsolete: 'PrefabType no longer tells everything about Prefab instance.'

    Assets\KDOPCollision\Editor\KDOPMenu.cs(53,25): warning CS0618: 'PrefabUtility.GetPrefabParent(Object)' is obsolete: 'Use GetCorrespondingObjectFromSource.'

    Assets\dearVR\dear_importer\dataModel\Editor\AnimatedSourcePrefabBuilder.cs(46,13): warning CS0618: 'PrefabUtility.CreatePrefab(string, GameObject)' is obsolete: 'Use SaveAsPrefabAsset instead.'

    EDIT: I changed the code with the help of chat GPT. I can send it to you, if you whish.
     
    Last edited: Jul 16, 2023