Obi Official Forum
Error when using mesh colliders - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Rope (https://obi.virtualmethodstudio.com/forum/forum-4.html)
+--- Thread: Error when using mesh colliders (/thread-2604.html)



Error when using mesh colliders - SkyDash - 02-12-2020

I'm getting this error when trying to use a mesh collider with an obi collider. It's just a simple cylinder. The error disappears if I use the primitive colliders. Why is this? (Obi rope 5.6.1)

Code:
IndexOutOfRangeException: Index was outside the bounds of the array.
Obi.BIH.Build (Obi.IBounded[]& elements, System.Int32 maxDepth, System.Single maxOverlap) (at Assets/Obi/Scripts/Common/DataStructures/BVH/BIH.cs:63)
Obi.ObiTriangleMeshContainer.GetOrCreateTriangleMesh (UnityEngine.Mesh source) (at Assets/Obi/Scripts/Common/Collisions/ObiTriangleMeshContainer.cs:92)
Obi.ObiColliderWorld.GetOrCreateTriangleMesh (UnityEngine.Mesh mesh) (at Assets/Obi/Scripts/Common/Collisions/ObiColliderWorld.cs:229)
Obi.ObiMeshShapeTracker.UpdateIfNeeded () (at Assets/Obi/Scripts/Common/Collisions/ColliderTrackers/Trackers3D/ObiMeshShapeTracker.cs:38)
Obi.ObiColliderBase.UpdateIfNeeded () (at Assets/Obi/Scripts/Common/Collisions/ObiColliderBase.cs:189)
Obi.ObiColliderWorld.UpdateWorld () (at Assets/Obi/Scripts/Common/Collisions/ObiColliderWorld.cs:362)
Obi.ObiUpdater.BeginStep (System.Single stepDeltaTime) (at Assets/Obi/Scripts/Common/Updaters/ObiUpdater.cs:40)
Obi.ObiFixedUpdater.FixedUpdate () (at Assets/Obi/Scripts/Common/Updaters/ObiFixedUpdater.cs:54)



RE: Error when using mesh colliders - josemendez - 02-12-2020

(02-12-2020, 07:10 AM)SkyDash Wrote: I'm getting this error when trying to use a mesh collider with an obi collider. It's just a simple cylinder. The error disappears if I use the primitive colliders. Why is this? (Obi rope 5.6.1)

Code:
IndexOutOfRangeException: Index was outside the bounds of the array.
Obi.BIH.Build (Obi.IBounded[]& elements, System.Int32 maxDepth, System.Single maxOverlap) (at Assets/Obi/Scripts/Common/DataStructures/BVH/BIH.cs:63)
Obi.ObiTriangleMeshContainer.GetOrCreateTriangleMesh (UnityEngine.Mesh source) (at Assets/Obi/Scripts/Common/Collisions/ObiTriangleMeshContainer.cs:92)
Obi.ObiColliderWorld.GetOrCreateTriangleMesh (UnityEngine.Mesh mesh) (at Assets/Obi/Scripts/Common/Collisions/ObiColliderWorld.cs:229)
Obi.ObiMeshShapeTracker.UpdateIfNeeded () (at Assets/Obi/Scripts/Common/Collisions/ColliderTrackers/Trackers3D/ObiMeshShapeTracker.cs:38)
Obi.ObiColliderBase.UpdateIfNeeded () (at Assets/Obi/Scripts/Common/Collisions/ObiColliderBase.cs:189)
Obi.ObiColliderWorld.UpdateWorld () (at Assets/Obi/Scripts/Common/Collisions/ObiColliderWorld.cs:362)
Obi.ObiUpdater.BeginStep (System.Single stepDeltaTime) (at Assets/Obi/Scripts/Common/Updaters/ObiUpdater.cs:40)
Obi.ObiFixedUpdater.FixedUpdate () (at Assets/Obi/Scripts/Common/Updaters/ObiFixedUpdater.cs:54)

It's a known bug, the fix will be included in 5.6.2 (not yet approved by the store).

To fix it, replace BIH.cs with the one you'll find in this thread:
http://obi.virtualmethodstudio.com/forum/thread-2592.html


RE: Error when using mesh colliders - SkyDash - 02-12-2020

(02-12-2020, 08:33 AM)josemendez Wrote: It's a known bug, the fix will be included in 5.6.2 (not yet approved by the store).

To fix it, replace BIH.cs with the one you'll find in this thread:
http://obi.virtualmethodstudio.com/forum/thread-2592.html

That fixed the problem but when I use mesh colliders the simulation is not as good as using primitive colliders. I'm getting some extreme tunnelling. Any solution to this?


RE: Error when using mesh colliders - josemendez - 02-12-2020

(02-12-2020, 10:29 AM)SkyDash Wrote: That fixed the problem but when I use mesh colliders the simulation is not as good as using primitive colliders. I'm getting some extreme tunnelling. Any solution to this?

MeshColliders are quite costly. They're also hollow: only their surface is considered for collision detection. So if an object (in Obi's case, particles) gets completely inside of them, it won't be projected out. This applies both to Unity physics as well as Obi. Increasing ObiCollider's thickness and/or using a shorter timestep you could improve this a bit, but unfortunately it's just how MeshColliders work.

Obi provides a better alternative to MeshColliders: distance fields. They're much faster and considerably more robust to tunneling, both convex and concave shapes are supported. You can read more about them here:
http://obi.virtualmethodstudio.com/tutorials/distancefields.html