A couple b2EdgeChain problems

So I've got an edge chain set up like in this picture with a circle that's rolling down it:
Image

If an object approaches from the side where the little white lines are, it collides with the edge chain. Approaching from the opposite would cause it to whip across since it's the "wrong" side. Anyways, so the edge chain has a friction value of 0.2 and obviously a density of 0. The circle has a density of 1 and friction of 0.2. Note the circled area in the picture. When the circle hits it, it gets ejected reallllllly quickly. Here's a pic of it along it's trajectory, which appears to be along the normal:

Image

I'm not sure why this happens but it doesn't seem like correct behavior. I tried it with a box shaped object and it didn't freak out. The only thing I can think of is that it's erroneously thinking it's approaching from the wrong side and so it's being whipped across.

Second issue, similar looking setup:
Image

Same physics properties. When the circle smoothly rolls down the slope, once it hits the point where you see it in the picture, it moves substantially slower than the speed it moves at either the previous or next segment in the chain. I'm not doing any extra velocity changes with the circle at all: box2D is handling all the movement (unlike my player in my previous post). What would cause this and how would I avoid it? Thanks for the help.
It's not the ejection effect you are seeing as that doesn't effect velocity.

It's possibly a bug. Ensure that you have updated to the latest version, that the edges are joined together (i.e. created in the same call to CreateShape). If problems persist, try to reproduce the curve in a testbed, so we can take a look at it in detail.
So I did a diff from the 2.0.2 branch to the groundzero one and there's no difference with the edge chains (save some include path chanegs). The edges are all joined together: Depicted in the screenshot is actually just a single edge chain with something like two dozen nodes, all attached to a single body. What would be useful info to provide...I can make an EXE that you can run to check it out. Upping the code isn't doable, but I can provide the code for how the edge chain is constructed, along with all the physical properties involved.
Yes, please. Modify one of the testbed examples to produce the same curve and ball, and try to reproduce. Frankly, this is preferable for debuggers to look at as well as saving you from having to post your own code.
You know what...I think it's entirely my fault. So I'm manually handling gravity, so that I can sometimes not apply it to my player under particular circumstances. Anyways, what I observed was if I didn't do that and just set the world gravity and let box2d handle it, the simulation ran totally as expected. So my question then becomes, what would be the proper way to manually simulate gravity? I presume I'm doing it wrong. Here's what I'm doing:

1. Loop over all my objects and if the mass isn't 0, apply a force like so:
mBody->ApplyForce(b2Vec2(0, 9.8f), b2Vec2(0, 0));

2. Call Step(1/50.0f, 10, 10) on my world object

Am I applying the force incorrectly? I must be since doing it this way causes the error but allowing box2d to handle it doesn't.
psilocyn wrote:
mBody->ApplyForce(b2Vec2(0, 9.8f), b2Vec2(0, 0));

The second parameter to ApplyForce is a world point, not a local point, so you want to do
Code:
mBody->ApplyForce(b2Vec2(0, 9.8f), mBody->GetWorldPoint(b2Vec2(0, 0)));
The force of gravity should be 9.8 times the mass of the body. 9.8 is the desired rate of acceleration, and acceleration = force/mass, so force = acceleration*mass. And the force should be applied at the body's center of mass, rather than at the body's origin. But this might not be the cause of the problem you were seeing.

But if there is some bug in your code that is accidentally applying a force or setting the velocity on a static body, such as the body containing edge shapes, that definitely would produce an effect similar to what you're seeing. Static bodies will never move in Box2D, but a quirk of the engine means that static bodies can still have "velocity" and anything that comes in contact with them will react as if they were moving.
Hoooray, it works. I multiplied the force by the mass (duh) and used the world coord function and all seems as normal. BTW I wasn't moving around any static bodies, just dynamic ones (which in this example is the circle). Thanks for the help, I appreciate it.

Original thread: https://box2d.org/forum/viewtopic.php?t=3089