Shapes wont bounce of static shapes

Official forum for the Chipmunk2D Physics Library.

Shapes wont bounce of static shapes

Hi,

I will be using chimpunk for a university project and I am now playing a little bit with the library. It seems pretty cool for now.
Now, my problem

I have a static body with 4 static shapes (for the 4 walls around the window), in that box I put a lot of moving objects (balls). The balls bounce of each other very well, but they don't of walls, when they touch the wall, they stick to it.
I tried a lot of elasticity and friction combos, but neither did what I want.

Here's some relevant code :

This is the function that is called in order to add another ball in the world:
Code: Select all
`  cpFloat moment = cpMomentForPoly(mass, 4, verts, cpvzero);  body = cpBodyNew(mass, moment);  body->p = position;  body->v = velocity;  cpSpaceAddBody(space, body);    shape = cpCircleShapeNew(body, 10.0f, cpvzero);  shape->e = 0.8f;  shape->u = 1.5f;  shape->collision_type = 0;  cpSpaceAddShape(space, shape);`

The wall stuff :
Code: Select all
`  cpBody *staticBody = cpBodyNew(INFINITY, INFINITY);  shape = cpSegmentShapeNew(staticBody, cpv(0,0), cpv(0,600), 0.0f);  shape->e = 0.0f; shape->u = 1.5f;  shape->collision_type = 0;  cpSpaceAddStaticShape(space, shape);    //shape = cpSegmentShapeNew(staticBody, cpv(0,600), cpv(800,600), 0.0f);  // This was a test to be sure that it isn't because of the Segment shape.  shape = cpPolyShapeNew(staticBody, 4, ground, cpvzero);  shape->e = 0.6f; shape->u = 1.5f;  shape->collision_type = 0;  cpSpaceAddStaticShape(space, shape);    shape = cpSegmentShapeNew(staticBody, cpv(800,600), cpv(800,0), 0.0f);  shape->e = 0.0f; shape->u = 1.0f;  shape->collision_type = 0;  cpSpaceAddStaticShape(space, shape);    shape = cpSegmentShapeNew(staticBody, cpv(0,0), cpv(800,0), 0.0f);  shape->e = 0.0f; shape->u = 1.0f;  shape->collision_type = 0;  cpSpaceAddStaticShape(space, shape);`

I have a collision pair function that just returns 1, if that is of any importance.

As you can see, I am stealing a lot of code from the demos and tutorials, gotta learn somehow

So, can anyone help me get those balls start to bounce like a real ball should ?

Thanks.
rumpl

Posts: 1
Joined: Tue Nov 11, 2008 6:48 pm

Re: Shapes wont bounce of static shapes

I am having this issue too,

shapes do not bounce on static segments but they do bounce on each other
debug

Posts: 19
Joined: Sun Nov 23, 2008 4:42 pm

Re: Shapes wont bounce of static shapes

I'm still very new to the workings of chipmunks, so may be wrong, but would giving your static shapes an elacticity ('e' property I think) value of more than 0.0 (i.e. 0.5) solve it?

In my test environment I have balls bouncing of static shapes, both the static and active objects have an 'e' value of more than 0.0.

Hope (but doubt) this helps.

---edit---
had a look and if one object has a 0.0 elasticity then no bounce occurs (in my project at least), but it looks like 1 of your static shapes does have an elasticity of 0.6 so you should be bouncing off of that wall.
nirwin

Posts: 2
Joined: Fri Aug 29, 2008 11:00 am

Re: Shapes wont bounce of static shapes

Elasticity works by multiplying the two elasticity values from the colliding shapes and using that for the elasticity value.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/

slembcke

Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Shapes wont bounce of static shapes

Same problem, nothing bounces on static shapes.

This is for dynamic shapes:
Code: Select all
`shape->e = 11250.0; `

Not even a little bounce with that. Everything should jump off-screen with that value.

The static shapes have elasticity of 1.2.

Maybe it's a bug in chipmunk?
sickman

Posts: 19
Joined: Mon Oct 06, 2008 7:50 am

Re: Shapes wont bounce of static shapes

Is this with 4.1.0 or trunk? I'm not sure why that would be happening in either.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/

slembcke

Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: Shapes wont bounce of static shapes

slembcke wrote:Is this with 4.1.0 or trunk? I'm not sure why that would be happening in either.

4.1.0.

I don't even know what's trunk so I'm probably not using it.

But I noticed the body gets really jumpy when it has tons of mass (1000 or so).
sickman

Posts: 19
Joined: Mon Oct 06, 2008 7:50 am

Re: Shapes wont bounce of static shapes

I had the same problem and found the solution in this thread:

viewtopic.php?f=3&t=304&p=1421&hilit=bounce#p1437
vegard

Posts: 1
Joined: Fri Jan 30, 2009 12:18 pm