Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Alembic Cache Mesh as Collider?
#1
Hello,

I have an animation in Maya that I exported out as an alembic cache, and have successfully imported into Unity as a GameObject.  I was hoping to use that animated GameObject as a collider for a ObiRope.  Basically, it's an animation of a horse, and I was looking to create the reins and sim them using ObiRope.  I can get the child mesh to act as a collider, but only the first frame mesh of the alembic cache.  It's not the entire animated GameObject.  Any advice for what I'm trying to achieve?
Reply
#2
(31-10-2020, 08:04 PM)mattstrangio Wrote: Hello,

I have an animation in Maya that I exported out as an alembic cache, and have successfully imported into Unity as a GameObject.  I was hoping to use that animated GameObject as a collider for a ObiRope.  Basically, it's an animation of a horse, and I was looking to create the reins and sim them using ObiRope.  I can get the child mesh to act as a collider, but only the first frame mesh of the alembic cache.  It's not the entire animated GameObject.  Any advice for what I'm trying to achieve?

animated MeshColliders are not supported by Unity, or at the very least, not intended to be used like this. (and as a consequence, not supported by Obi either). Same goes for pretty much any realtime game engine.

There's some workarounds, but they universally result in terrible performance as MeshColliders rely on pre-processing the mesh to allow for fast collision queries. The mesh is inserted into a spatial subdivision structure (BVH, BIH, KD-Tree, or similar) when the MeshCollider is created, then this structure is used to quickly find the closes triangle(s) to a certain position during collision detection. If you change the shared mesh every frame, then this structure needs to be recreated from scratch every frame which pretty much defeats the purpose of using it (as generating the entire structure can be slower than brute-forcing collision detection by iterating trough all triangles).

For one such workaround, see:
https://answers.unity.com/questions/1197...inned.html

This updates the collider in sync with a SkinnedMeshRenderer. You should be able to adapt the code to update the collider in sync with the alembic cache.
Reply
#3
(03-11-2020, 09:35 AM)josemendez Wrote: animated MeshColliders are not supported by Unity, or at the very least, not intended to be used like this. (and as a consequence, not supported by Obi either). Same goes for pretty much any realtime game engine.

There's some workarounds, but they universally result in terrible performance as MeshColliders rely on pre-processing the mesh to allow for fast collision queries. The mesh is inserted into a spatial subdivision structure (BVH, BIH, KD-Tree, or similar) when the MeshCollider is created, then this structure is used to quickly find the closes triangle(s) to a certain position during collision detection. If you change the shared mesh every frame, then this structure needs to be recreated from scratch every frame which pretty much defeats the purpose of using it (as generating the entire structure can be slower than brute-forcing collision detection by iterating trough all triangles).

For one such workaround, see:
https://answers.unity.com/questions/1197...inned.html

This updates the collider in sync with a SkinnedMeshRenderer. You should be able to adapt the code to update the collider in sync with the alembic cache.

Thank you Jose, this is very informative, much appreciated!  For this particular project, I'm aiming to use Unity as an "offline" renderer for a film-type project rather than real-time, so I'm not quite as concerned with the speed performance.  I just like your sim tools more, as they're more effective and easier to use than I find Maya's sim tools.  Anyhow...  Thanks again!

-Matt
Reply