Dealing with many small clustered items

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
radishhoedown
Posts: 5
Joined: Fri Dec 09, 2011 1:14 pm

Dealing with many small clustered items

Post by radishhoedown »

At the moment I have made a procedural shatter effect which spawns a load of convex hulls into the space of the old plane that they replace. They all appear at the right positions but they explode apart quite violently, and turning up the SolverSettings and TimeStepping just seems to make the problem even worse. It happens all settings modes that can be set from the configuration helper class that you provide with the demos. My algorithm creates geometry objects that have shared face vertices with geometry around them but I was just expecting the physics engine to resolve them since the overlap was.. well, not an overlap as such. Is there any way of disabling their updates, or turning down impulses? I found a minimum impulse setting and tweaked that but it didn't seem to make a difference. At the moment I have managed to mask the problem a bit by scaling the relative hull position by 1.07f to 'spread them out', but I wondered if they was something else I could do?
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Dealing with many small clustered items

Post by Norbo »

The most likely cause is the collision margin. The general case collision detection system, which the ConvexHulls use, expands objects by a spherical margin defined by the shape. It defaults to 0.04.

The purpose of the collision margin is to allow efficient and robust algorithms to be used. To get an idea of what the margin looks like, take a look at this post: http://www.bepu-games.com/forum/viewtopic.php?f=4&t=409. The information in that post is very old but conceptually still true and the picture is still relevant.

By creating convex hulls whose vertices are extremely close, there is an effective overlap of 0.08 units. The penetration resolution system kicks in and pushes the objects apart. For a single pair of objects, this would be a small effect. When it's compounded by dozens of collisions, it can become an explosion.

So here's a few options:
1) Shrink the size of the broken sub-pieces such that when they get expanded, the overlaps will be small or nonexistent. Simply scaling the objects uniformly can get close to the correct effect. A more correct approach is to pull the surface planes inward by the margin width. This is more complicated to implement and long shards will change shape. This idea is similar to how Spheres, Capsules, and Cylinders handle collision margins. Their margins are inside rather than expanded outward.

2) Set the ConvexHullShapes' CollisionMargins to something smaller, possibly even zero. Be careful with this. By making it smaller or 0, the engine will be forced to use the fallback MPR system. It's still robust, but slower.

3) Change the CollisionResponseSettings.MaximumPositionCorrectionSpeed and CollisionResponseSettings.PenetrationRecoveryStiffness to lower values. These are simulation-wide settings, so you might encounter some side effects where objects stay in penetration too long.

You could also use some combination of the above approaches.
radishhoedown
Posts: 5
Joined: Fri Dec 09, 2011 1:14 pm

Re: Dealing with many small clustered items

Post by radishhoedown »

Okay, interesting information, thanks very much. After looking at your advice I managed to mess with some settings and numbers and it doesn't seem to happen very much any more. I had searched for an answer but I couldn't really pin it down to good search term.

Thanks once again,
RH
Post Reply