public static void createDefaultBodyWithFixture(float x, float y, float w, float h, float density, float friction, float restitution) { System.out.println("\nparameters: x:" + x + " y: "+ y + " [ f: " + density + " d: " + friction + " r: " + restitution + " ] "); BodyDef bodyDef = new BodyDef(); bodyDef.type = BodyType.DYNAMIC; bodyDef.position.set(x, y); Body dynamicBody = m_world.createBody(bodyDef); PolygonShape dynamicBox = new PolygonShape(); dynamicBox.setAsBox(w, h); FixtureDef dynamicFixture = new FixtureDef(); dynamicFixture.shape = dynamicBox; dynamicFixture.density = density; dynamicFixture.friction = friction; dynamicFixture.restitution = 0.001f;
Fixture fix = dynamicBody.createFixture(dynamicFixture); System.out.println("params from body: x:" + dynamicBody.getPosition().x + " y:" + dynamicBody.getPosition().y + " [ f: " + fix.getFriction() + " d: " + fix.getDensity() + " r: " + fix.getRestitution() + " ] \n --------"); }
parameters: x:1.0 y: 2.0 [ f: 0.1 d: 0.1 r: 0.01 ] params from body: x:1.0 y:2.0 [ f: 0.1 d: 0.1 r: 0.01 ] --------
parameters: x:3.0 y: 2.0 [ f: 0.2 d: 0.1 r: 0.11 ] params from body: x:3.0 y:2.0 [ f: 0.1 d: 0.2 r: 0.11 ] --------
parameters: x:5.0 y: 2.0 [ f: 0.3 d: 0.1 r: 0.21000001 ] params from body: x:5.0 y:2.0 [ f: 0.1 d: 0.3 r: 0.21000001 ] --------
parameters: x:7.0 y: 2.0 [ f: 0.4 d: 0.1 r: 0.31 ] params from body: x:7.0 y:2.0 [ f: 0.1 d: 0.4 r: 0.31 ] --------
parameters: x:9.0 y: 2.0 [ f: 0.5 d: 0.1 r: 0.41 ] params from body: x:9.0 y:2.0 [ f: 0.1 d: 0.5 r: 0.41 ] --------
parameters: x:11.0 y: 2.0 [ f: 0.6 d: 0.1 r: 0.51 ] params from body: x:11.0 y:2.0 [ f: 0.1 d: 0.6 r: 0.51 ] --------
parameters: x:13.0 y: 2.0 [ f: 0.70000005 d: 0.1 r: 0.61 ] params from body: x:13.0 y:2.0 [ f: 0.1 d: 0.70000005 r: 0.61 ] --------
parameters: x:15.0 y: 2.0 [ f: 0.8 d: 0.1 r: 0.71 ] params from body: x:15.0 y:2.0 [ f: 0.1 d: 0.8 r: 0.71 ] --------
parameters: x:17.0 y: 2.0 [ f: 0.90000004 d: 0.1 r: 0.81 ] params from body: x:17.0 y:2.0 [ f: 0.1 d: 0.90000004 r: 0.81 ] --------
parameters: x:19.0 y: 2.0 [ f: 1.0 d: 0.1 r: 0.90999997 ] params from body: x:19.0 y:2.0 [ f: 0.1 d: 1.0 r: 0.90999997 ]
body->ResetMassData();
float32 restitution;
restitution = b2Max(shape1->restitution, shape2->restitution);
I realized that bumping change is visible between 0.8 to 1 restitution value.
The same restitution range for bodies bout ground restitution 1.0f affects that:
Thanks for figure out this "issue", I just need next time think about relations between bodies :).