Monday, February 19, 2018

c++ - Rectangles render with gaps in between them (Box2D)


Right now I create my boxes where 1 meter is 85 pixels. Gravity is 10. And


                        fixtureDef.restitution = 0.1f;
fixtureDef.friction = 0.5f;

fixtureDef.density = 1.0f;

The problem I'm having is illustrated in the image I have provided: http://www.box2d.org/forum/download/file.php?mode=view&id=1044&sid=86e8772dc965cba215f9a16cca2839e4


As you can see, there is a small gap between many, but not all the crates. What could cause this?


Thanks



Answer



I guess that's some issue in box2d, there is such a bug to increase performance. since more accuracy needs much more computational power. to fix that issue I guess you only need reduce box physical sizes (for example you can create a 84px*84px rectangle for a 86px*86px image). you can also fade the pixels in the edges to get better results.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...