Continuous Collision Detection Shell

Topics: Developer Forum
Feb 12, 2011 at 6:30 PM

Hi everyone,

I've been thinking about the CCD shell that is placed around geometries (~2 pixel units, right?) and how that relates to TextureConverter. I understand the need of the collision shell, but shouldn't it be constructed to the inside, instead of to the outside? That is, instead of the shell being an outward extension of the geometry, the actual geometry is reduced to account for the collision shell, so that in the end the limit of the shell will coincide with the actual dimensions passed to the Fixture constructor methods.

It may be just me, but I keep forgetting to create my textures taking into consideration the collision shell, and if I do any dynamic polygon generation using the texture dimensions it's always troublesome to add in the calculations for subtracting the necessary pixels.

I know that maybe in most games this is not an issue, but it really bugs me that if I ask for a rectangle with size [2;2] I actually get a rectangle that behaves like [2,...;2,...].

What do you think?

Feb 12, 2011 at 9:39 PM

In my games, the polygon skin is 0.024 pixels thick.

The thickness of the skin is based on the LinearSlop inside Settings.cs. But that is only a number, the drawn value depends on what scale you use. TextureConverter can't take it into account as it works on pixels only, not meters - that is why you scale the output from the TextureConverter to match your game scale.

And as for the inside skin vs. outside skin:

The CCD solver used to use shrunken shapes and that had some limitations, such as you could not have small or slender shapes (you can't shrink them). It also used a lot of memory as you needed 2 shapes for each shape. Now we just apply a small skin and only need to store a single shape. It is faster (performance wise), simpler and more flexible. The only side-effect being that shapes are not exactly the dimensions you define. It is simply a trade-off and polygon skin seems to be the lesser of two evils.

If you don't need CCD, turn it off. If you can do with a smaller skin, turn down LinearSlop (or change Settings.PolygonRadius directly)