C++ CLR wrapper and weird behaviour

Discuss issues specific to miscellaneous ports of Box2D
HughPH
Posts: 8
Joined: Thu Jul 20, 2017 7:19 am

C++ CLR wrapper and weird behaviour

Postby HughPH » Thu Jul 20, 2017 7:39 am

Hello,

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.

Unfortunately:
  • 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?

HughPH
Posts: 8
Joined: Thu Jul 20, 2017 7:19 am

Re: C++ CLR wrapper and weird behaviour

Postby HughPH » Thu Jul 20, 2017 8:06 am

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: https://youtu.be/h-OqDtJwwjk

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

HughPH
Posts: 8
Joined: Thu Jul 20, 2017 7:19 am

Re: C++ CLR wrapper and weird behaviour

Postby HughPH » Fri Jul 21, 2017 3:35 am

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.


Return to “Miscellaneous”



Who is online

Users browsing this forum: Bing [Bot] and 1 guest