Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Softbody doesn't collide with some triangles in mesh since 5.5
#1
When I updated to 5.5 I started to get softbodies falling through my meshes at certain triangles (not a bullet through paper issue). I've attached an example mesh where softbodies will consistently fall through one triangle for no reason I can see (rigidbodies collide with it properly and the triangle is rendered one-sided correctly).

Repro:

https://matthewsouth.s3-eu-west-1.amazon...Mesh.asset

1. Add the attached mesh to the Ballpool sample.
2. Add a mesh collider and obi collider to the mesh game object.
3. Drop a softbody (eg the ball from the samples) onto the triangle highlighted below.
4. The ball should fall through.

[Image: BallFallsThrough.png]

Notes:

1. The softbody doesn't fall through other triangles in this mesh.
2. The softbody will always fall through the triangle 100%.
3. Rigidbodies correctly collide with this triangle.
4. This only started happening in 5.5 as far as I know.
5. Optimising the meshes did seem to help a bit, but not in cases like this.

I fully expect this will be some issue with my mesh but I'm just not sure what so any help or advice would be much appreciated!
Reply
#2
Hi Matts,

Will take a look at it asap and get back to you. Keep in mind that for most purposes, using distance fields is both faster and much more robust than using MeshColliders though, as MeshColliders are very prone to tunneling. Always avoid MeshColliders when possible.
Reply
#3
(21-09-2020, 07:36 AM)josemendez Wrote: Hi Matts,

Will take a look at it asap and get back to you. Keep in mind that for most purposes, using distance fields is both faster and much more robust than using MeshColliders though, as MeshColliders are very prone to tunneling. Always avoid MeshColliders when possible.

Thanks!

These are dynamically created meshes so creating distance fields, at least in the development stage, is a bit more involved than just attaching an obi collider and mesh collider component to the object. For release though I will definitely be using distance fields!

Did you get anywhere with your investigation? This definitely isn't a case of tunnelling as speed doesn't matter, it just doesn't seem to generate contacts against certain polygons in the mesh. Anecdotally it seems to be the first or last polygon in the mesh, so maybe something in the way I've generated the mesh is wrong? Also, these are deliberately not convex meshes even though the simplified one I provided technically could be.
Reply
#4
(25-09-2020, 10:19 AM)MattS Wrote: Thanks!

These are dynamically created meshes so creating distance fields, at least in the development stage, is a bit more involved than just attaching an obi collider and mesh collider component to the object. For release though I will definitely be using distance fields!

Did you get anywhere with your investigation? This definitely isn't a case of tunnelling as speed doesn't matter, it just doesn't seem to generate contacts against certain polygons in the mesh. Anecdotally it seems to be the first or last polygon in the mesh, so maybe something in the way I've generated the mesh is wrong? Also, these are deliberately not convex meshes even though the simplified one I provided technically could be.

Hi,

I'm currently looking at a possibly related bug in the bounding interval hierarchy used for collision detection against meshes, will get back to you today.
Reply
#5
There was indeed a bug in the BIH structure. Replace Obi/Scripts/Common/DataStructures/BVH/BIH.cs with the one attached, no triangles should be ignored now.

let me know how it goes,


Attached Files
.cs   BIH.cs (Size: 12.38 KB / Downloads: 2)
Reply
#6
(25-09-2020, 12:27 PM)josemendez Wrote: There was indeed a bug in the BIH structure. Replace Obi/Scripts/Common/DataStructures/BVH/BIH.cs with the one attached, no triangles should be ignored now.

let me know how it goes,

That seems to work, thank you! I will test it some more on other cases but all the ones I've tried so far are fixed now Sonrisa

I had a slight issue with your change indexing out of bounds when all elements are >= to the pivot (--j will iterate below 0) so I added a quick bounds check:

Code:
...
while (bj.center[axis] >= pivot && j > 0);


I'm not sure if this implies a larger issue with the partition not splitting correctly, or just an edge case that needs patching up, but either way it works now. 

Thank you so much for the great support!
Reply
#7
You're right, that hints at deeper problems with the partition algorithm. I'll write new unit tests for the BIH and report back any additional modifications that result from that.
Reply
#8
(25-09-2020, 02:21 PM)josemendez Wrote: You're right, that hints at deeper problems with the partition algorithm. I'll write new unit tests for the BIH and report back any additional modifications that result from that.

Thanks again!

For what it's worth, my current case boiled down to the following situation:

[Image: Screenshot+2020-09-25+152509.png]

https://matthewsouth.s3-eu-west-1.amazonaws.com/PartitionIssueMesh.asset

The axis chosen to split on is X in this case because it spans the largest dimensions, but all the centres of the triangles on X are identical. It might need to consider the spread of the centres instead, I'm not sure.
Reply
#9
(25-09-2020, 03:28 PM)MattS Wrote: [/url]The axis chosen to split on is X in this case because it spans the largest dimensions, but all the centres of the triangles on X are identical. It might need to consider the spread of the centres instead, I'm not sure.

There's several "pathological" cases for BIHs that result in poor partitions, this being one of them. Using aabb centers to calculate the split axis also leads to some (albeit different) worst cases, though, so there's no clear winner in all situations.
Reply
#10
Sonrisa 
Very true! 

Worse case the current solution is slightly sub-optimal, but it works now which is the main thing so I consider this issue fixed.

Thank you for being generous with your time Sonrisa
Reply