Zero gravity, Circle shape gets stuck to wall

General Box2D issues or C++ specific issues
skrekkur
Posts: 10
Joined: Thu Oct 29, 2009 7:58 am

Zero gravity, Circle shape gets stuck to wall

Postby skrekkur » Wed Dec 16, 2009 1:05 pm

Hi I have a slight problem with box2d
I am not sure if this is a bug, or a property of newtonian physics but it would be really nice if you could help me get this to work.

My problem is basically when a circleShape is as close to a wall (2 polygon edge) as possible and another circle shape hits it, it does not move from the wall.
This effect can be seen in the varying restitution example, when gravity is disabled and you put 1.0 restitution ball on the ground and throw the others at it.

The effect I want is similar to when in pool, and one ball lies and touches an edge, and another ball hits it hard enough the both leave the edge.

I have tried a few things like increasing the restitution above 1 on the edge but when there is exactly no space between the circle and edge, the ball just moves along the same axis as the edge.

Any help would be greatly appreciated.


Update: I fixed this with a small "hack", by applying a small impulse on this particular object on collisions, this of course applies to all collisions with this particular object but seems to work for my case. Further comments are well appreciated though.

iasonf
Posts: 2
Joined: Thu Apr 08, 2010 9:33 am

Re: Zero gravity, Circle shape gets stuck to wall

Postby iasonf » Thu Apr 08, 2010 9:57 am

hello everyone,
im having the same problem. i found this in the documentation:
Box2D also uses inelastic collisions when the collision velocity is small. This is done to prevent jitter.


this causes my ball-objects to get stuck on one of the four borders after some minutes.

<EDIT>
Problem solved
Last edited by iasonf on Thu Apr 08, 2010 1:05 pm, edited 1 time in total.

iasonf
Posts: 2
Joined: Thu Apr 08, 2010 9:33 am

Re: Zero gravity, Circle shape gets stuck to wall

Postby iasonf » Thu Apr 08, 2010 1:04 pm

i searched the forum again and found the solution
http://box2d.org/forum/viewtopic.php?f=8&t=2630&p=13522&hilit=sticking+to+walls#p13522.

Just Change b2_velocityThreshold to 0 in b2Settings

Chrysostom
Posts: 3
Joined: Mon May 07, 2012 8:39 pm

Re: Zero gravity, Circle shape gets stuck to wall

Postby Chrysostom » Tue May 08, 2012 5:30 am

I'm having a similar problem.

Setting b2_velocityThreshold does help, but does not fix the issue, especially when the collision's overlap is too great: the circle actually begins tunneling through the polygon. Going to try the impulse method. (I have to admit to being a little disappointed though - setting up a contact listener and retrieving normal vectors... I got into Box2D to avoid dealing with the details physics implementation like this.)

Chrysostom
Posts: 3
Joined: Mon May 07, 2012 8:39 pm

Re: Zero gravity, Circle shape gets stuck to wall

Postby Chrysostom » Tue May 08, 2012 6:54 am

Just wanted to share a solution I found to this problem: make sure you define polygon regions by vertices in the same order across your world. I used all clockwise orientations for most of them, except 2 which were done counterclockwise, and invariably the balls would stick into and eventually tunnel through them. No changes to restitution, density, velocityThreshold, mass, v_init, etc. would fix the problem. I'm not sure if counter- vs. clockwise will matter in all cases (it shouldn't in your case, since the walls are static) but you should probably be consistent and see if the problem goes away.

By the way, I am using Box2DWeb, a Box2DFlash port.

jayther
Posts: 266
Joined: Sun Oct 25, 2009 3:28 am
Contact:

Re: Zero gravity, Circle shape gets stuck to wall

Postby jayther » Tue May 08, 2012 3:31 pm

I don't think Box2DWeb is up to date with the original C++ port. Before 2.2.0, all vertices had to be specified in a clockwise fashion (in the right-handed coordinate system), regardless if they're static or not.

kalterkrieg
Posts: 1
Joined: Wed Dec 23, 2015 5:40 am

Re: Zero gravity, Circle shape gets stuck to wall

Postby kalterkrieg » Wed Dec 23, 2015 9:14 am

I have the same problem and I didn't find where I have to change b2_velocitythreshold, I am using c++.
I tried redefining it at the beginning of my .h, changing it in /usr/local/include/Box2D/Common/, changing it in the source folder and then recompiling the lib, but neither worked.
What can I do?


Return to “Bugs, Requests, and Feedback”



Who is online

Users browsing this forum: No registered users and 2 guests