kripken / box2d.js

Port of Box2D to JavaScript using Emscripten
1.32k stars 198 forks source link

body.GetMassData(); // results in an error #36

Closed Joncom closed 11 years ago

Joncom commented 11 years ago

Test case:

  1. Open up box2d.js/html5canvas_demo/testbed.html in browser.
  2. You should now be looking at the "dominos" test.
  3. Type world.GetBodyList().GetMassData(); in console.

This error is returned: TypeError: Cannot read property 'ptr' of undefined

kripken commented 11 years ago

When I open that page, it says Box2D is not defined, and http requests fail to embox2d.js

Joncom commented 11 years ago

That is because you need to copy box2d.js into that folder first and rename it to embox2d.js

On 2013-07-15, at 10:38 AM, Alon Zakai notifications@github.com wrote:

When I open that page, it says Box2D is not defined, and http requests fail to embox2d.js

— Reply to this email directly or view it on GitHub.

kripken commented 11 years ago

Oh, right. Was there a reason not to just use box2d.js from the parent dir?

Joncom commented 11 years ago

None that I can think of.

On Jul 15, 2013, at 12:42 PM, Alon Zakai notifications@github.com wrote:

Oh, right. Was there a reason not to just use box2d.js from the parent dir?

— Reply to this email directly or view it on GitHub.

kripken commented 11 years ago

Ok, pushed that.

Back to the main topic, it looks like GetMassData excepts a parameter: void GetMassData(b2MassData* massData) const;. Buliding a debug build, the error is that we try to use the parameter and fail. So we should either create an alternative version that returns a value, or pass in the right parameter I think.

Joncom commented 11 years ago

Apologies, you are correct. That's what I get for posting the issue from memory long after experiencing it. So the real issue is that body.GetMassData(massData) fails because b2MassData is unbound.