I think I've found a bug in v1.4.3 that calculating the center of mass of polygons does not take polyDef.localRotation into account.
I've only tested on the Flash port, but a cursory glance suggests that the problem is in the original C++.
Put the following in the TestBridge function of the Flash testbed to replicate:
This code causes the polygon to stand up unphysically on it's shortest side, while removing both the lines setting rotations leaves the shape unmoved, but now it falls over to the right.
I've only tested on the Flash port, but a cursory glance suggests that the problem is in the original C++.
Put the following in the TestBridge function of the Flash testbed to replicate:
Code:
public function TestBridge(){
var pd:b2PolyDef = new b2PolyDef();
pd.vertexCount=5;
pd.vertices[0].Set(100,0);
pd.vertices[1].Set(0,100);
pd.vertices[2].Set(-30,100);
pd.vertices[3].Set(-30,-30);
pd.vertices[4].Set(100,-30);
pd.localRotation=-Math.PI/2;
pd.density=0.4;
var bd:b2BodyDef = new b2BodyDef();
bd.rotation=Math.PI/2;
bd.position.Set(100, 200);
bd.AddShape(ad);
m_world.CreateBody(bd);
}
var pd:b2PolyDef = new b2PolyDef();
pd.vertexCount=5;
pd.vertices[0].Set(100,0);
pd.vertices[1].Set(0,100);
pd.vertices[2].Set(-30,100);
pd.vertices[3].Set(-30,-30);
pd.vertices[4].Set(100,-30);
pd.localRotation=-Math.PI/2;
pd.density=0.4;
var bd:b2BodyDef = new b2BodyDef();
bd.rotation=Math.PI/2;
bd.position.Set(100, 200);
bd.AddShape(ad);
m_world.CreateBody(bd);
}
This code causes the polygon to stand up unphysically on it's shortest side, while removing both the lines setting rotations leaves the shape unmoved, but now it falls over to the right.