Page 1 of 1

C++ CLR wrapper and weird behaviour

Posted: Thu Jul 20, 2017 7:39 am
by HughPH

Box2DX is really out of date and has some bugs (I can't find the bodies enclosing a given point, for example, and applying forces or impulses to bodies seems to do nothing) so I've brought Box2D into VS 2017 and written a very straightfoward static wrapper.

  • Everything falls at the same speed. Gravity is 0, -10
  • Nothing bounces. Restitution 0.5f Density 10.0f
  • When I create a 3rd polygon (I'm just using boxes to begin with) b2PolygonShape::ComputeMass fails to assert with area 0 on b2Assert(area > b2_epsilon); (line 431)

Seems like I've got something fundamentally wrong - hopefully the symptoms will speak for themselves, but if not, I'm happy to show you my code.

Does anyone have any ideas what's going on?

Re: C++ CLR wrapper and weird behaviour

Posted: Thu Jul 20, 2017 8:06 am
by HughPH
Prior to this attempt I had more-or-less ported the whole of Box2D to C#, and wound up with everything bouncing like crazy and polygon/polygon collisions causing total chaos:

I've just located the Box2DX source - so maybe I'll instead focus my energy on bringing that up-to-date.

Re: C++ CLR wrapper and weird behaviour

Posted: Fri Jul 21, 2017 3:35 am
by HughPH
Solved: I was passing double instead of float (since I'd seen that it was "float32" in Box2D, and expected that this must be greater than "float" since the number of bits had been specified.)

Regarding stuff falling at the same speed: what I meant was that there didn't appear to be any acceleration. I can now see clearly that objects do accelerate to terminal velocity - probably also a float/double related issue.