Problem with making a body static

Hi.

I use this code to make a body static:
Code:
b2MassData md;
md.mass=0.0f;
md.center=b2Vec2();
md.I=0.0f;
body->SetMass(&md);


The problem is that even though the body is made static, during collisions it appears as if it had some speed (the speed that it had when it was last dynamic). This means that if some other very slow dynamic body will now touch this static body, it will gain a lot of speed during collision, just as if the static body had a lot of speed.

Has anybody else noticed this bug?
Change your body type to static in addition.
pTymN wrote:
Change your body type to static in addition.


I analyzed the Box2D's C++ source code and it changes the body type internally when I set the mass like this. Actually, I wanted just to change the body type, as you suggest, without modifying the mass, but it looks impossible. I didn't find in the API any call that allows to change the body type. So I browsed the source and found that setting the mass to 0 like I do results in changing the body type internally, so that's what I do. Is there some other way of changing body type that I don't know of?
Try also setting:

body->SetLinearVelocity(b2Vec2(0.0f, 0.0f));
body->SetAngularVelocity(0.0f);
Should that be before or after setting the mass to 0?

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