1
\$\begingroup\$

I've ported my engine to iOS and have been using the C++ version of Box2D. Everything runs fine except on collisions, it seems Box2D and Farseer handle collisions somewhat differently.

Anyone know what these differences are exactly and if I can disable the difference and make them mimic one another?

Initial behaviours tend to be fine, for example falling speeds and the first moment of impact both cases exhibit the exact same behaviour, velocities etc.

Just after the first impact is resolved however the second impact (which occurs as a result of bodies being bumped around) is different. box2d records a higher velocity on a second collision than the first and shows less 'bounce back' from the collision.

Velocity, position iterations are the same, as are the bodies masses, densities etc. Pretty sure everything in Farseer.Settings matches up with Box2Ds settings.

\$\endgroup\$
5
  • \$\begingroup\$ How big is the difference between the two? Could it be a floating point rounding error? Maybe have a look at floating point determinism... \$\endgroup\$
    – Riki
    Aug 21 '11 at 3:29
  • \$\begingroup\$ My first suspicion was that, but tbh the differences are fairly large to be put down to rounding errors... \$\endgroup\$
    – meds
    Aug 21 '11 at 7:09
  • \$\begingroup\$ I'd not rule rounding errors out because of that. Even small errors can accumulate to huge values if given enough time / enough calculations. See the butterfly effect. en.wikipedia.org/wiki/Butterfly_effect \$\endgroup\$
    – Riki
    Aug 21 '11 at 23:07
  • \$\begingroup\$ There isn't enough time given, the values match up perfectly but after the first contact they end up differing by large values. \$\endgroup\$
    – meds
    Aug 21 '11 at 23:45
  • \$\begingroup\$ Both librarys are open source. Single step trough both of them. \$\endgroup\$
    – Riki
    Aug 21 '11 at 23:56
1
\$\begingroup\$

You cannot really expect two different physics engines to get binary identical results. They all do their computations differently, and thus they will come up with different results.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Farseer is a Box2D port ;) \$\endgroup\$
    – meds
    Aug 21 '11 at 7:09
  • \$\begingroup\$ @meds: Apparently, Farseer is based on Box2D.XNA, which itself is based on Box2D. So that's two degrees of separation between them. It's not entirely clear whether Box2D.XNA is a rewrite of Box2D in C#, or is simply a CLI interface to the Box2D library. If it's actually a real port, rather than just an interface wrapper, then there is no reason to expect identical behavior. And with physics systems, it doesn't take much difference to cause a visible effect. Even changing the order of operations in the integrator can have real problems. \$\endgroup\$ Aug 21 '11 at 7:47
  • \$\begingroup\$ From what I've seen of Farseer it mostly keeps to Box2Ds way of doing things, handling collisions and all that. Really all it does is add some extra functionality to Box2D but doesn't modify Box2Ds behavior as far as i'm aware. \$\endgroup\$
    – meds
    Aug 21 '11 at 8:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .