behdad / box2d

Automatically exported from code.google.com/p/box2d
2 stars 12 forks source link

Sudden offset when setting a body static #85

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Create a dynamic body with non zero local center. Then call
SetType(b2Body::e_staticType). Then call SynchronizeTransform or touch it
with another body.

What is the expected output? What do you see instead?
Expect to fix in place. Instead, body position shifts to where the world
center used to be.

What version of the product are you using? On what operating system?
Box2DFlash 2.1a. I've checked code showing the problem is present in the C++.

Fix:
The problem is that ResetMassData has an early return for nondynamic
bodies, which skips an important step at the end which shifts m_sweep
appropriately for the new center. Using a big if statement instead of an
early return fixes the problem.

Original issue reported on code.google.com by sadwanm...@gmail.com on 13 Feb 2010 at 12:37

GoogleCodeExporter commented 9 years ago
Fixed it. Thanks!

Original comment by erinca...@gmail.com on 7 Mar 2010 at 8:58