When using a physics engine in a game (such as Bullet), you usually need to define a collision margin for each object. I'm a beginner to game development, and I don't understand the purpose of a collision margin.
My basic understanding is that if you were to have two objects, each with a collision margin set to 0.01, then a collision would be detected when the two collision margins touch each other, such that the gap between the two objects is actually 0.02.
But why not just set the collision margin to 0, and cause a collision to be detected when the actual surfaces of the two objects collide? This is how physics works in reality.
One guess is the following. If a cube has a margin of 0.01, then a collision will be detected whenever a part of another object exists between 0 and 0.01 from the object's surface. This gives the simulation room for error, such that if it "misses" the point when the object passes the cube's collision margin (because the simulation step is long), then it still has time to detect a collision as the object then moves closer towards the cube's surface, within the 0.01 margin. Otherwise, if the margins are zero and a collision is missed by the simulation, you might get a situation where two solid bodies occupy the same space, which could cause problems.
Is this guess correct? Or is there another reason?