Giter Club home page Giter Club logo

box2d.js's Introduction

box2d.js

Demo: http://kripken.github.io/box2d.js/demo/webgl/box2d.html

WebAssembly demo: http://kripken.github.io/box2d.js/demo/webgl/box2d.wasm.html

Example code to give you an idea of the API: https://github.com/kripken/box2d.js/blob/master/demo/webgl/box2d.html#L14

box2d.js is a direct port of the Box2D 2D physics engine to JavaScript, using Emscripten. The source code is translated directly to JavaScript, without human rewriting, so functionality should be identical to the original Box2D.

box2d.js is zlib licensed, just like Box2D.

Discussion takes place on IRC at #emscripten on Mozilla's server (irc.mozilla.org)

Details

The automatically generated bindings have been tested to the extent that can be found in the examples in the 'testbed'. For general notes on using the bindings, see the ammo.js project (a port of Bullet to JavaScript using Emscripten), many of the details of wrapping classes and so forth are identical.

It seems to be running ok on at least the following:

  • Desktop PC (Linux) - Chrome22, Opera12, Firefox16
  • Desktop PC (OSX) - Chrome22, Opera12, Firefox16
  • Desktop PC (Win7) - Chrome22, Opera12, Firefox16
  • iOS 5 - Safari, Chrome, Dolphin
  • Android ICS - Chrome18
  • Android JB - Chrome18, Dolphin9

Testbed

The demo/html5canvas folder contains an example web page and script files to reproduce the original Box2D testbed, with similar controls and features.

Demo: http://www.iforce2d.net/embox2d/testbed.html

Like the original C++ version, the testbed is set up so that adding another test scene is easy. Look in the tests folder and find the template.js file....

  1. Copy template.js and rename it.
  2. In the renamed file, replace all occurrences of 'embox2dTest_template' with your test name.
  3. Fill in the setup function.
  4. Optionally, fill in the other functions.
  5. Include the new file at the beginning of testbed.html with the other tests.
  6. Add the new test option to the "testNumber" select box in test.html

R.U.B.E testbed

The demo/rube_testbed folder contains the testbed with scenes which were exported from the R.U.B.E editor

Building

$ /PATH/TO/EMSCRIPTEN emmake make

To build latest (2.3.1) version:

$ /PATH/TO/EMSCRIPTEN emmake make VERSION=latest 

Also, You can build the debug version of javascript file (with source maps support):

$ /PATH/TO/EMSCRIPTEN emmake make VERSION=latest BUILD=debug

This runs emscripten and uses it to compile a version of the Box2D source code stored within the box2d.js git. This source code has been modified to add constructors to some objects to ensure that emscripten will generate bindings for them.

Currently, you need to use a very recent Emscripten to build, version 1.23.0 or later (master branch as of Aug 21 2014) to build box2d.js. See http://kripken.github.io/emscripten-site/docs/building_from_source/building_emscripten_from_source_using_the_sdk.html#building-emscripten-from-source-using-the-sdk

Usage (WebIDL bindings)

The current bindings are created with the WebIDL binder. Read Box2D_v2.2.1.idl to see the class, methods, and attributes that are bound.

See test.js for a small working example.

Note: To improve readability all code snippets below assume that everything in the 'Box2D' namespace has been made available! (Check the 'using' function in helpers/embox2d-helpers.js for details.)

Class member variable access

The values of public member variables of Box2D classes (mostly the definition classes) can be set and accessed using the generated functions, which will be the variable name prefixed with set_ or get_, eg.

//C++
circleShape.m_radius = 2;
//javascript
circleShape.set_m_radius( 2 );

Vector manipulation

b2Vec2 vectors can be created like:

var myVec = new b2Vec2( 1.2, 3.4 );

As mentioned above, the individual components of vectors can be obtained with the get_x() and get_y() functions.

Vectors can be assigned with the = operator but if you are coming from a C++ background, you may be caught out by the fact that this does not result in two independent variables. To get the same behavior as the original C++ assignment you can copy the components like:

var anotherVec = new b2Vec2( vec.get_x(), vec.get_y() );

Alternatively the assignment, addition and subtraction operators can be replaced with the functions below (however, experience shows these to be somewhat dodgy...)

operator       name in JS
--------       ----------
    =            op_set
    +            op_add
    -            op_sub

Creating a world

A typical world can be created like:

var world = new b2World( new b2Vec2(0.0, -10.0) );

Creating bodies

A static body can be created like:

var groundBody = world.CreateBody( new b2BodyDef() );

... and dynamic/kinematic bodies like:

var bodyDef = new b2BodyDef();
bodyDef.set_type( b2_dynamicBody );
var dynamicBody = world.CreateBody( bodyDef );

Creating fixtures

A circle fixture with density 1 and default values for everything else (friction, restitution etc):

var circleShape = new b2CircleShape();
circleShape.set_m_radius( 0.5 );
body.CreateFixture( circleShape, 1.0 );

A circle fixture with some more specific settings:

var fixtureDef = new b2FixtureDef();
fixtureDef.set_density( 2.5 );
fixtureDef.set_friction( 0.6 );
fixtureDef.set_shape( circleShape );
body.CreateFixture( fixtureDef );

An edge shape:

var edgeShape = new b2EdgeShape();
edgeShape.Set( new b2Vec2( -20, 3 ), new b2Vec2( 20, 7 ) );
fixtureDef.set_shape( edgeShape );
body.CreateFixture( fixtureDef );

Creating polygon shapes seems to be somewhat messy with the current bindings, so the recommended way is to use the createPolygonShape helper function in embox2d-helpers.js:

var verts = [];
verts.push( new b2Vec2( 7,-1 ) );
verts.push( new b2Vec2( 8,-2 ) );
verts.push( new b2Vec2( 9, 3 ) );
verts.push( new b2Vec2( 7, 1 ) );
var polygonShape = createPolygonShape( verts );
fixtureDef.set_shape( polygonShape );
body.CreateFixture( fixtureDef );

Likewise for chain shapes: Edit: seems to be a problem with this, best to avoid chain shapes for now

var chainShape = createChainShape( verts, true ); //true for closed loop, false for open chain
fixtureDef.set_shape( chainShape );
body.CreateFixture( fixtureDef );

Creating joints

Example revolute joint:

var jointDef = new b2RevoluteJointDef();
jointDef.set_bodyA( body1 );
jointDef.set_bodyB( body2 );
jointDef.set_localAnchorA( new b2Vec2( 1, 2 ) );
jointDef.set_localAnchorB( new b2Vec2( 3, 4 ) );
jointDef.set_collideConnected( true );
var revoluteJoint = Box2D.castObject( world.CreateJoint( jointDef ), b2WheelJoint );

Using debug draw

Create a JSDraw object, and supply implementations of the draw methods. (Note: All methods must be implemented even if unused.)

var debugDraw = new Box2D.JSDraw();

debugDraw.DrawSegment = function(vert1Ptr, vert2Ptr, colorPtr ) {
    setColorFromDebugDrawCallback( colorPtr );
    drawSegment( vert1Ptr, vert2Ptr );
}
// Empty implementations for unused methods.
debugDraw.DrawPolygon = function() {};
debugDraw.DrawSolidPolygon = function() {};
debugDraw.DrawCircle = function() {};
debugDraw.DrawSolidCircle = function() {};
debugDraw.DrawTransform = function() {};

world.SetDebugDraw( debugDraw );

The parameters of the draw methods will be pointers to data inside emscripten's innards, so you'll need to wrap them to get the data type you are looking for. Here are the two functions mentioned above, as an example of how you would wrap the passed b2Color and b2Vec2 parameters and use them in your drawing. This example is to draw on a HTML5 canvas:

function setColorFromDebugDrawCallback( colorPtr ) {
    var color = Box2D.wrapPointer( colorPtr, b2Color );
    var red = (color.get_r() * 255) | 0;
    var green = (color.get_g() * 255) | 0;
    var blue = (color.get_b() * 255) | 0;

    var colorStr = red + "," + green + "," + blue;
    context.fillStyle = "rgba(" + colorStr + ",0.5)";
    context.strokeStyle = "rgb(" + colorStr + ")";
}

function drawSegment( vert1Ptr, vert2Ptr ) {
    var vert1 = Box2D.wrapPointer( vert1Ptr, b2Vec2 );
    var vert2 = Box2D.wrapPointer( vert2Ptr, b2Vec2 );

    context.beginPath();
    context.moveTo( vert1.get_x(), vert1.get_y() );
    context.lineTo( vert2.get_x(), vert2.get_y() );
    context.stroke();
}

Accessing the vertex arrays passed to other functions such as DrawPolygon are somewhat more tricky - please see the embox2d-html5canvas-debugDraw.js source for an example.

Using collision events

Contact listener callbacks are also implemented with customizeVTable.

listener = new JSContactListener();
listener.BeginContact = function (contactPtr) {
    var contact = Box2D.wrapPointer( contactPtr, b2Contact );
    var fixtureA = contact.GetFixtureA();
    var fixtureB = contact.GetFixtureB();

    // now do what you wish with the fixtures
}

// Empty implementations for unused methods.
listener.EndContact = function() {};
listener.PreSolve = function() {};
listener.PostSolve = function() {};

world.SetContactListener( listener );

Using world callbacks

Callbacks for other uses such as world querying and raycasting can also be implemented with customizeVTable. Here is the callback used in the 'testbed' to find the fixture that the mouse cursor is over when the left button is clicked:

myQueryCallback = new JSQueryCallback();

myQueryCallback.ReportFixture = function(fixturePtr) {
    var fixture = Box2D.wrapPointer( fixturePtr, b2Fixture );
    if ( fixture.GetBody().GetType() != Box2D.b2_dynamicBody ) //mouse cannot drag static bodies around
        return true;
    if ( ! fixture.TestPoint( this.m_point ) )
        return true;
    this.m_fixture = fixture;
    return false;
};

The callback is used like:

myQueryCallback.m_fixture = null;
myQueryCallback.m_point = new b2Vec2( mouseX, mouseY );

world.QueryAABB( myQueryCallback, aabb ); // the AABB is a tiny square around the current mouse position

if ( myQueryCallback.m_fixture ) {
    //do something with the fixture that was clicked
}

Using a Destruction Listener

The standard b2DestructionListener class can't be used directly from javascript, as it has two methods that share the same name (SayGoodbye), and differ only by the type of their single parameter.

To listen for destruction events, do:

var myDestructionListener = new JSDestructionListener()
myDestructionListener.SayGoodbyeJoint = function(joint) {
    var joint = Box2D.wrapPointer( joint, b2Joint );
}
myDestructionListener.SayGoodbyeFixture = function(fixture) {
    var fixture = Box2D.wrapPointer( fixture, b2Fixture );
}

box2d.js's People

Contributors

alperencaliskan avatar assafkr avatar dmagunov avatar geraintwhite avatar huy-nguyen avatar iforce2d avatar insidewhy avatar joncom avatar kripken avatar mlogan avatar nathanhammond avatar relequestual avatar valscion avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

box2d.js's Issues

How to reference a body while drawing with debugdraw

I want to draw a sprite while drawing using debug draw method.
so,I want to reference a body to know whether it is the shape I wanted or not .How can I reference a body in the customizeVTable method.Further I wanted to know what is 'ths' referring to in the following code.How can we use it .

Box2D.customizeVTable(debugDraw, [{
original: Box2D.b2Draw.prototype.DrawSegment,
replacement:
function(ths, vert1, vert2, color) {
alert('called');
}
}]);

can someone help regarding this.

Some bindings are not generated because of missing constructors

Bindings for b2ContactListener and b2Fixture (probably others) are not generated because those classes do not have constructors. Adding trivial constructors to the C++ code and recompiling fixes the problem.

In general it would be cool to auto-generate these constructors for classes that don't have them.

iOS 5.1.1: ReferenceError: Can't find variable: Float64Array

I can verify that iOS 6 (iPhone 5) supports Float64Array and box2d.js runs fantastically there.

But I need to support older systems and my iPad is on 5.1.1.

I know you have emscripten options to build stuff for using different features (typed arrays or not, and so forth), so it looks like at the very least I'll be able to get it working on older browsers by recompiling with a more compatible setting.

My question is... Is there a mechanism that can dynamically choose which version to run based on typed arrays availability? Also iOS 5 appears to support some of typed arrays, just not the Float64Array.

I then attempted to use this TypedArray shim:

https://bitbucket.org/lindenlab/llsd/src/7d2646cd3f9b/js/typedarray.js

The error produced is:

Assertion failed: Cannot fallback to non-typed array case: Code is too specialized: undefined

box2d.js build is missing pretty much all bindings...

  1. Cloned https://github.com/kripken/box2d.js.git
  2. Downloaded Emscripten using git submodule update --init
  3. Ran make within box2d.js directory

When it's compiling I see the following:

box2d_bindings.cpp:42:47: warning: 'emscripten_bind_b2ContactManager__get_m_broadPhase_p0' has C-linkage specified, but returns
      user-defined type 'b2BroadPhase &' which is incompatible with C [-Wreturn-type-c-linkage]
b2BroadPhase& __attribute__((used, noinline)) emscripten_bind_b2ContactManager__get_m_broadPhase_p0(b2ContactManager * self) {
                                              ^
box2d_bindings.cpp:72:41: warning: 'emscripten_bind_b2DistanceJoint__GetAnchorB_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2DistanceJoint__GetAnchorB_p0(b2DistanceJoint * self) {
                                        ^
box2d_bindings.cpp:76:41: warning: 'emscripten_bind_b2DistanceJoint__GetAnchorA_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2DistanceJoint__GetAnchorA_p0(b2DistanceJoint * self) {
                                        ^
box2d_bindings.cpp:83:47: warning: 'emscripten_bind_b2DistanceJoint__GetLocalAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2DistanceJoint__GetLocalAnchorA_p0(b2DistanceJoint * self) {
                                              ^
box2d_bindings.cpp:86:47: warning: 'emscripten_bind_b2DistanceJoint__GetLocalAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2DistanceJoint__GetLocalAnchorB_p0(b2DistanceJoint * self) {
                                              ^
box2d_bindings.cpp:92:41: warning: 'emscripten_bind_b2DistanceJoint__GetReactionForce_p1' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2DistanceJoint__GetReactionForce_p1(b2DistanceJoint * self, float arg0) {
                                        ^
box2d_bindings.cpp:168:47: warning: 'emscripten_bind_b2Fixture__GetAABB_p1' has C-linkage specified, but returns user-defined type
      'const b2AABB &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2AABB& __attribute__((used, noinline)) emscripten_bind_b2Fixture__GetAABB_p1(b2Fixture * self, signed int arg0) {
                                              ^
box2d_bindings.cpp:189:49: warning: 'emscripten_bind_b2Fixture__GetFilterData_p0' has C-linkage specified, but returns user-defined
      type 'const b2Filter &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Filter& __attribute__((used, noinline)) emscripten_bind_b2Fixture__GetFilterData_p0(b2Fixture * self) {
                                                ^
box2d_bindings.cpp:219:41: warning: 'emscripten_bind_b2MouseJoint__GetAnchorB_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2MouseJoint__GetAnchorB_p0(b2MouseJoint * self) {
                                        ^
box2d_bindings.cpp:223:41: warning: 'emscripten_bind_b2MouseJoint__GetAnchorA_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2MouseJoint__GetAnchorA_p0(b2MouseJoint * self) {
                                        ^
box2d_bindings.cpp:236:47: warning: 'emscripten_bind_b2MouseJoint__GetTarget_p0' has C-linkage specified, but returns user-defined
      type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2MouseJoint__GetTarget_p0(b2MouseJoint * self) {
                                              ^
box2d_bindings.cpp:242:41: warning: 'emscripten_bind_b2MouseJoint__GetReactionForce_p1' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2MouseJoint__GetReactionForce_p1(b2MouseJoint * self, float arg0) {
                                        ^
box2d_bindings.cpp:279:41: warning: 'emscripten_bind_b2PulleyJoint__GetAnchorA_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PulleyJoint__GetAnchorA_p0(b2PulleyJoint * self) {
                                        ^
box2d_bindings.cpp:286:41: warning: 'emscripten_bind_b2PulleyJoint__GetGroundAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PulleyJoint__GetGroundAnchorB_p0(b2PulleyJoint * self) {
                                        ^
box2d_bindings.cpp:296:41: warning: 'emscripten_bind_b2PulleyJoint__GetGroundAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PulleyJoint__GetGroundAnchorA_p0(b2PulleyJoint * self) {
                                        ^
box2d_bindings.cpp:318:41: warning: 'emscripten_bind_b2PulleyJoint__GetAnchorB_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PulleyJoint__GetAnchorB_p0(b2PulleyJoint * self) {
                                        ^
box2d_bindings.cpp:322:41: warning: 'emscripten_bind_b2PulleyJoint__GetReactionForce_p1' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PulleyJoint__GetReactionForce_p1(b2PulleyJoint * self, float arg0) {
                                        ^
box2d_bindings.cpp:341:47: warning: 'emscripten_bind_b2BroadPhase__GetFatAABB_p1' has C-linkage specified, but returns user-defined
      type 'const b2AABB &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2AABB& __attribute__((used, noinline)) emscripten_bind_b2BroadPhase__GetFatAABB_p1(b2BroadPhase * self, signed int arg0) {
                                              ^
box2d_bindings.cpp:389:50: warning: 'emscripten_bind_b2World__GetProfile_p0' has C-linkage specified, but returns user-defined type
      'const b2Profile &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Profile& __attribute__((used, noinline)) emscripten_bind_b2World__GetProfile_p0(b2World * self) {
                                                 ^
box2d_bindings.cpp:398:57: warning: 'emscripten_bind_b2World__GetContactManager_p0' has C-linkage specified, but returns user-defined
      type 'const b2ContactManager &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2ContactManager& __attribute__((used, noinline)) emscripten_bind_b2World__GetContactManager_p0(b2World * self) {
                                                        ^
box2d_bindings.cpp:488:41: warning: 'emscripten_bind_b2World__GetGravity_p0' has C-linkage specified, but returns user-defined type
      'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2World__GetGravity_p0(b2World * self) {
                                        ^
box2d_bindings.cpp:510:47: warning: 'emscripten_bind_b2PrismaticJoint__GetLocalAxisA_p0' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PrismaticJoint__GetLocalAxisA_p0(b2PrismaticJoint * self) {
                                              ^
box2d_bindings.cpp:516:41: warning: 'emscripten_bind_b2PrismaticJoint__GetAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PrismaticJoint__GetAnchorA_p0(b2PrismaticJoint * self) {
                                        ^
box2d_bindings.cpp:526:47: warning: 'emscripten_bind_b2PrismaticJoint__GetLocalAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PrismaticJoint__GetLocalAnchorA_p0(b2PrismaticJoint * self) {
                                              ^
box2d_bindings.cpp:532:47: warning: 'emscripten_bind_b2PrismaticJoint__GetLocalAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PrismaticJoint__GetLocalAnchorB_p0(b2PrismaticJoint * self) {
                                              ^
box2d_bindings.cpp:550:41: warning: 'emscripten_bind_b2PrismaticJoint__GetReactionForce_p1' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PrismaticJoint__GetReactionForce_p1(b2PrismaticJoint * self, float arg0) {
                                        ^
box2d_bindings.cpp:599:41: warning: 'emscripten_bind_b2PrismaticJoint__GetAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PrismaticJoint__GetAnchorB_p0(b2PrismaticJoint * self) {
                                        ^
box2d_bindings.cpp:618:47: warning: 'emscripten_bind_b2CircleShape__GetVertex_p1' has C-linkage specified, but returns user-defined
      type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2CircleShape__GetVertex_p1(b2CircleShape * self, signed int arg0) {
                                              ^
box2d_bindings.cpp:624:47: warning: 'emscripten_bind_b2CircleShape__GetSupportVertex_p1' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2CircleShape__GetSupportVertex_p1(b2CircleShape * self, const...
                                              ^
box2d_bindings.cpp:651:41: warning: 'emscripten_bind_b2CircleShape__get_m_p_p0' has C-linkage specified, but returns user-defined type
      'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2CircleShape__get_m_p_p0(b2CircleShape * self) {
                                        ^
box2d_bindings.cpp:666:47: warning: 'emscripten_bind_b2WheelJoint__GetLocalAxisA_p0' has C-linkage specified, but returns user-defined
      type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WheelJoint__GetLocalAxisA_p0(b2WheelJoint * self) {
                                              ^
box2d_bindings.cpp:672:41: warning: 'emscripten_bind_b2WheelJoint__GetAnchorB_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WheelJoint__GetAnchorB_p0(b2WheelJoint * self) {
                                        ^
box2d_bindings.cpp:676:41: warning: 'emscripten_bind_b2WheelJoint__GetAnchorA_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WheelJoint__GetAnchorA_p0(b2WheelJoint * self) {
                                        ^
box2d_bindings.cpp:686:47: warning: 'emscripten_bind_b2WheelJoint__GetLocalAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WheelJoint__GetLocalAnchorA_p0(b2WheelJoint * self) {
                                              ^
box2d_bindings.cpp:692:47: warning: 'emscripten_bind_b2WheelJoint__GetLocalAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WheelJoint__GetLocalAnchorB_p0(b2WheelJoint * self) {
                                              ^
box2d_bindings.cpp:713:41: warning: 'emscripten_bind_b2WheelJoint__GetReactionForce_p1' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WheelJoint__GetReactionForce_p1(b2WheelJoint * self, float arg0) {
                                        ^
box2d_bindings.cpp:801:41: warning: 'emscripten_bind_b2Joint__GetAnchorA_p0' has C-linkage specified, but returns user-defined type
      'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Joint__GetAnchorA_p0(b2Joint * self) {
                                        ^
box2d_bindings.cpp:820:41: warning: 'emscripten_bind_b2Joint__GetAnchorB_p0' has C-linkage specified, but returns user-defined type
      'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Joint__GetAnchorB_p0(b2Joint * self) {
                                        ^
box2d_bindings.cpp:824:41: warning: 'emscripten_bind_b2Joint__GetReactionForce_p1' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Joint__GetReactionForce_p1(b2Joint * self, float arg0) {
                                        ^
box2d_bindings.cpp:837:41: warning: 'emscripten_bind_b2GearJoint__GetAnchorA_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2GearJoint__GetAnchorA_p0(b2GearJoint * self) {
                                        ^
box2d_bindings.cpp:871:41: warning: 'emscripten_bind_b2GearJoint__GetAnchorB_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2GearJoint__GetAnchorB_p0(b2GearJoint * self) {
                                        ^
box2d_bindings.cpp:875:41: warning: 'emscripten_bind_b2GearJoint__GetReactionForce_p1' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2GearJoint__GetReactionForce_p1(b2GearJoint * self, float arg0) {
                                        ^
box2d_bindings.cpp:906:47: warning: 'emscripten_bind_b2DynamicTree__GetFatAABB_p1' has C-linkage specified, but returns user-defined
      type 'const b2AABB &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2AABB& __attribute__((used, noinline)) emscripten_bind_b2DynamicTree__GetFatAABB_p1(b2DynamicTree * self, signed int arg0) {
                                              ^
box2d_bindings.cpp:951:41: warning: 'emscripten_bind_b2WeldJoint__GetAnchorB_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WeldJoint__GetAnchorB_p0(b2WeldJoint * self) {
                                        ^
box2d_bindings.cpp:955:41: warning: 'emscripten_bind_b2WeldJoint__GetAnchorA_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WeldJoint__GetAnchorA_p0(b2WeldJoint * self) {
                                        ^
box2d_bindings.cpp:962:47: warning: 'emscripten_bind_b2WeldJoint__GetLocalAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WeldJoint__GetLocalAnchorA_p0(b2WeldJoint * self) {
                                              ^
box2d_bindings.cpp:965:47: warning: 'emscripten_bind_b2WeldJoint__GetLocalAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WeldJoint__GetLocalAnchorB_p0(b2WeldJoint * self) {
                                              ^
box2d_bindings.cpp:974:41: warning: 'emscripten_bind_b2WeldJoint__GetReactionForce_p1' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WeldJoint__GetReactionForce_p1(b2WeldJoint * self, float arg0) {
                                        ^
box2d_bindings.cpp:1017:41: warning: 'emscripten_bind_b2RevoluteJoint__GetAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2RevoluteJoint__GetAnchorA_p0(b2RevoluteJoint * self) {
                                        ^
box2d_bindings.cpp:1027:47: warning: 'emscripten_bind_b2RevoluteJoint__GetLocalAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2RevoluteJoint__GetLocalAnchorA_p0(b2RevoluteJoint * self) {
                                              ^
box2d_bindings.cpp:1033:47: warning: 'emscripten_bind_b2RevoluteJoint__GetLocalAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2RevoluteJoint__GetLocalAnchorB_p0(b2RevoluteJoint * self) {
                                              ^
box2d_bindings.cpp:1057:41: warning: 'emscripten_bind_b2RevoluteJoint__GetReactionForce_p1' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2RevoluteJoint__GetReactionForce_p1(b2RevoluteJoint * self, float arg0) {
                                        ^
box2d_bindings.cpp:1100:41: warning: 'emscripten_bind_b2RevoluteJoint__GetAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2RevoluteJoint__GetAnchorB_p0(b2RevoluteJoint * self) {
                                        ^
box2d_bindings.cpp:1224:41: warning: 'emscripten_bind_b2RopeJoint__GetAnchorA_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2RopeJoint__GetAnchorA_p0(b2RopeJoint * self) {
                                        ^
box2d_bindings.cpp:1249:47: warning: 'emscripten_bind_b2RopeJoint__GetLocalAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2RopeJoint__GetLocalAnchorA_p0(b2RopeJoint * self) {
                                              ^
box2d_bindings.cpp:1258:47: warning: 'emscripten_bind_b2RopeJoint__GetLocalAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2RopeJoint__GetLocalAnchorB_p0(b2RopeJoint * self) {
                                              ^
box2d_bindings.cpp:1264:41: warning: 'emscripten_bind_b2RopeJoint__GetAnchorB_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2RopeJoint__GetAnchorB_p0(b2RopeJoint * self) {
                                        ^
box2d_bindings.cpp:1268:41: warning: 'emscripten_bind_b2RopeJoint__GetReactionForce_p1' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2RopeJoint__GetReactionForce_p1(b2RopeJoint * self, float arg0) {
                                        ^
box2d_bindings.cpp:1299:47: warning: 'emscripten_bind_b2PolygonShape__GetVertex_p1' has C-linkage specified, but returns user-defined
      type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PolygonShape__GetVertex_p1(b2PolygonShape * self, signed int arg0) {
                                              ^
box2d_bindings.cpp:1338:41: warning: 'emscripten_bind_b2PolygonShape__get_m_centroid_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PolygonShape__get_m_centroid_p0(b2PolygonShape * self) {
                                        ^
box2d_bindings.cpp:1485:41: warning: 'emscripten_bind_b2Body__GetLocalPoint_p1' has C-linkage specified, but returns user-defined type
      'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Body__GetLocalPoint_p1(b2Body * self, const b2Vec2 & arg0) {
                                        ^
box2d_bindings.cpp:1495:41: warning: 'emscripten_bind_b2Body__GetLinearVelocity_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Body__GetLinearVelocity_p0(b2Body * self) {
                                        ^
box2d_bindings.cpp:1517:41: warning: 'emscripten_bind_b2Body__GetLinearVelocityFromWorldPoint_p1' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Body__GetLinearVelocityFromWorldPoint_p1(b2Body * self, const b2Vec2...
                                        ^
box2d_bindings.cpp:1545:52: warning: 'emscripten_bind_b2Body__GetTransform_p0' has C-linkage specified, but returns user-defined type
      'const b2Transform &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Transform& __attribute__((used, noinline)) emscripten_bind_b2Body__GetTransform_p0(b2Body * self) {
                                                   ^
box2d_bindings.cpp:1548:47: warning: 'emscripten_bind_b2Body__GetWorldCenter_p0' has C-linkage specified, but returns user-defined
      type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Body__GetWorldCenter_p0(b2Body * self) {
                                              ^
box2d_bindings.cpp:1560:47: warning: 'emscripten_bind_b2Body__GetLocalCenter_p0' has C-linkage specified, but returns user-defined
      type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Body__GetLocalCenter_p0(b2Body * self) {
                                              ^
box2d_bindings.cpp:1563:41: warning: 'emscripten_bind_b2Body__GetWorldVector_p1' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Body__GetWorldVector_p1(b2Body * self, const b2Vec2 & arg0) {
                                        ^
box2d_bindings.cpp:1567:41: warning: 'emscripten_bind_b2Body__GetLinearVelocityFromLocalPoint_p1' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Body__GetLinearVelocityFromLocalPoint_p1(b2Body * self, const b2Vec2...
                                        ^
box2d_bindings.cpp:1574:41: warning: 'emscripten_bind_b2Body__GetWorldPoint_p1' has C-linkage specified, but returns user-defined type
      'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Body__GetWorldPoint_p1(b2Body * self, const b2Vec2 & arg0) {
                                        ^
box2d_bindings.cpp:1590:41: warning: 'emscripten_bind_b2Body__GetLocalVector_p1' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Body__GetLocalVector_p1(b2Body * self, const b2Vec2 & arg0) {
                                        ^
box2d_bindings.cpp:1624:47: warning: 'emscripten_bind_b2Body__GetPosition_p0' has C-linkage specified, but returns user-defined type
      'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Body__GetPosition_p0(b2Body * self) {
                                              ^
box2d_bindings.cpp:1633:41: warning: 'emscripten_bind_b2FrictionJoint__GetAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2FrictionJoint__GetAnchorA_p0(b2FrictionJoint * self) {
                                        ^
box2d_bindings.cpp:1661:47: warning: 'emscripten_bind_b2FrictionJoint__GetLocalAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2FrictionJoint__GetLocalAnchorA_p0(b2FrictionJoint * self) {
                                              ^
box2d_bindings.cpp:1667:47: warning: 'emscripten_bind_b2FrictionJoint__GetLocalAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2FrictionJoint__GetLocalAnchorB_p0(b2FrictionJoint * self) {
                                              ^
box2d_bindings.cpp:1673:41: warning: 'emscripten_bind_b2FrictionJoint__GetAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2FrictionJoint__GetAnchorB_p0(b2FrictionJoint * self) {
                                        ^
box2d_bindings.cpp:1677:41: warning: 'emscripten_bind_b2FrictionJoint__GetReactionForce_p1' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2FrictionJoint__GetReactionForce_p1(b2FrictionJoint * self, float arg0) {
                                        ^
box2d_bindings.cpp:1768:41: warning: 'emscripten_bind_b2FrictionJointDef__get_localAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2FrictionJointDef__get_localAnchorA_p0(b2FrictionJointDef * self) {
                                        ^
box2d_bindings.cpp:1774:41: warning: 'emscripten_bind_b2FrictionJointDef__get_localAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2FrictionJointDef__get_localAnchorB_p0(b2FrictionJointDef * self) {
                                        ^
box2d_bindings.cpp:1837:41: warning: 'emscripten_bind_b2BodyDef__get_position_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2BodyDef__get_position_p0(b2BodyDef * self) {
                                        ^
box2d_bindings.cpp:1867:41: warning: 'emscripten_bind_b2BodyDef__get_linearVelocity_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2BodyDef__get_linearVelocity_p0(b2BodyDef * self) {
                                        ^
box2d_bindings.cpp:1909:41: warning: 'emscripten_bind_b2Vec2__Skew_p0' has C-linkage specified, but returns user-defined type
      'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Vec2__Skew_p0(b2Vec2 * self) {
                                        ^
box2d_bindings.cpp:1931:41: warning: 'emscripten_bind_b2Vec2__op_sub_p0' has C-linkage specified, but returns user-defined type
      'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Vec2__op_sub_p0(b2Vec2 * self) {
                                        ^
box2d_bindings.cpp:1961:41: warning: 'emscripten_bind_b2Vec3__op_sub_p0' has C-linkage specified, but returns user-defined type
      'b2Vec3 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec3& __attribute__((used, noinline)) emscripten_bind_b2Vec3__op_sub_p0(b2Vec3 * self) {
                                        ^
box2d_bindings.cpp:1982:47: warning: 'emscripten_bind_b2DistanceProxy__GetSupportVertex_p1' has C-linkage specified, but returns
      user-defined type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2DistanceProxy__GetSupportVertex_p1(b2DistanceProxy * self,...
                                              ^
box2d_bindings.cpp:1991:47: warning: 'emscripten_bind_b2DistanceProxy__GetVertex_p1' has C-linkage specified, but returns user-defined
      type 'const b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
const b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2DistanceProxy__GetVertex_p1(b2DistanceProxy * self, signed int arg0) {
                                              ^
box2d_bindings.cpp:2036:43: warning: 'emscripten_bind_b2FixtureDef__get_filter_p0' has C-linkage specified, but returns user-defined
      type 'b2Filter &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Filter& __attribute__((used, noinline)) emscripten_bind_b2FixtureDef__get_filter_p0(b2FixtureDef * self) {
                                          ^
box2d_bindings.cpp:2072:41: warning: 'emscripten_bind_b2PrismaticJointDef__get_localAxisA_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PrismaticJointDef__get_localAxisA_p0(b2PrismaticJointDef * self) {
                                        ^
box2d_bindings.cpp:2102:41: warning: 'emscripten_bind_b2PrismaticJointDef__get_localAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PrismaticJointDef__get_localAnchorA_p0(b2PrismaticJointDef * self) {
                                        ^
box2d_bindings.cpp:2105:41: warning: 'emscripten_bind_b2PrismaticJointDef__get_localAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PrismaticJointDef__get_localAnchorB_p0(b2PrismaticJointDef * self) {
                                        ^
box2d_bindings.cpp:2147:41: warning: 'emscripten_bind_b2Rot__GetYAxis_p0' has C-linkage specified, but returns user-defined type
      'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Rot__GetYAxis_p0(b2Rot * self) {
                                        ^
box2d_bindings.cpp:2151:41: warning: 'emscripten_bind_b2Rot__GetXAxis_p0' has C-linkage specified, but returns user-defined type
      'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Rot__GetXAxis_p0(b2Rot * self) {
                                        ^
box2d_bindings.cpp:2188:41: warning: 'emscripten_bind_b2WheelJointDef__get_localAxisA_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WheelJointDef__get_localAxisA_p0(b2WheelJointDef * self) {
                                        ^
box2d_bindings.cpp:2212:41: warning: 'emscripten_bind_b2WheelJointDef__get_localAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WheelJointDef__get_localAnchorA_p0(b2WheelJointDef * self) {
                                        ^
box2d_bindings.cpp:2218:41: warning: 'emscripten_bind_b2WheelJointDef__get_localAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WheelJointDef__get_localAnchorB_p0(b2WheelJointDef * self) {
                                        ^
box2d_bindings.cpp:2302:41: warning: 'emscripten_bind_b2RevoluteJointDef__get_localAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2RevoluteJointDef__get_localAnchorA_p0(b2RevoluteJointDef * self) {
                                        ^
box2d_bindings.cpp:2305:41: warning: 'emscripten_bind_b2RevoluteJointDef__get_localAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2RevoluteJointDef__get_localAnchorB_p0(b2RevoluteJointDef * self) {
                                        ^
box2d_bindings.cpp:2341:41: warning: 'emscripten_bind_b2PulleyJointDef__get_groundAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PulleyJointDef__get_groundAnchorB_p0(b2PulleyJointDef * self) {
                                        ^
box2d_bindings.cpp:2344:41: warning: 'emscripten_bind_b2PulleyJointDef__get_groundAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PulleyJointDef__get_groundAnchorA_p0(b2PulleyJointDef * self) {
                                        ^
box2d_bindings.cpp:2362:41: warning: 'emscripten_bind_b2PulleyJointDef__get_localAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PulleyJointDef__get_localAnchorA_p0(b2PulleyJointDef * self) {
                                        ^
box2d_bindings.cpp:2365:41: warning: 'emscripten_bind_b2PulleyJointDef__get_localAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2PulleyJointDef__get_localAnchorB_p0(b2PulleyJointDef * self) {
                                        ^
box2d_bindings.cpp:2443:41: warning: 'emscripten_bind_b2Transform__get_p_p0' has C-linkage specified, but returns user-defined type
      'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2Transform__get_p_p0(b2Transform * self) {
                                        ^
box2d_bindings.cpp:2446:40: warning: 'emscripten_bind_b2Transform__get_q_p0' has C-linkage specified, but returns user-defined type
      'b2Rot &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Rot& __attribute__((used, noinline)) emscripten_bind_b2Transform__get_q_p0(b2Transform * self) {
                                       ^
box2d_bindings.cpp:2503:41: warning: 'emscripten_bind_b2AABB__GetExtents_p0' has C-linkage specified, but returns user-defined type
      'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2AABB__GetExtents_p0(b2AABB * self) {
                                        ^
box2d_bindings.cpp:2507:41: warning: 'emscripten_bind_b2AABB__GetCenter_p0' has C-linkage specified, but returns user-defined type
      'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2AABB__GetCenter_p0(b2AABB * self) {
                                        ^
box2d_bindings.cpp:2511:41: warning: 'emscripten_bind_b2AABB__get_upperBound_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2AABB__get_upperBound_p0(b2AABB * self) {
                                        ^
box2d_bindings.cpp:2529:41: warning: 'emscripten_bind_b2AABB__get_lowerBound_p0' has C-linkage specified, but returns user-defined
      type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2AABB__get_lowerBound_p0(b2AABB * self) {
                                        ^
box2d_bindings.cpp:2559:41: warning: 'emscripten_bind_b2WeldJointDef__get_localAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WeldJointDef__get_localAnchorA_p0(b2WeldJointDef * self) {
                                        ^
box2d_bindings.cpp:2565:41: warning: 'emscripten_bind_b2WeldJointDef__get_localAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2WeldJointDef__get_localAnchorB_p0(b2WeldJointDef * self) {
                                        ^
box2d_bindings.cpp:2619:41: warning: 'emscripten_bind_b2MouseJointDef__get_target_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2MouseJointDef__get_target_p0(b2MouseJointDef * self) {
                                        ^
box2d_bindings.cpp:2661:41: warning: 'emscripten_bind_b2DistanceJointDef__get_localAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2DistanceJointDef__get_localAnchorA_p0(b2DistanceJointDef * self) {
                                        ^
box2d_bindings.cpp:2667:41: warning: 'emscripten_bind_b2DistanceJointDef__get_localAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2DistanceJointDef__get_localAnchorB_p0(b2DistanceJointDef * self) {
                                        ^
box2d_bindings.cpp:2787:41: warning: 'emscripten_bind_b2RopeJointDef__get_localAnchorA_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2RopeJointDef__get_localAnchorA_p0(b2RopeJointDef * self) {
                                        ^
box2d_bindings.cpp:2793:41: warning: 'emscripten_bind_b2RopeJointDef__get_localAnchorB_p0' has C-linkage specified, but returns
      user-defined type 'b2Vec2 &' which is incompatible with C [-Wreturn-type-c-linkage]
b2Vec2& __attribute__((used, noinline)) emscripten_bind_b2RopeJointDef__get_localAnchorB_p0(b2RopeJointDef * self) {

And then the resulting box2d.js is about half the size of the one that comes with the repo.
And it's missing every single Box2d.b2* class.

Broken Makefile as of June 10, 2013

A recent commit has broken the Makefile, by removing the EMSCRIPTEN variable, which is still being used by the following line:

$(PYTHON) $(EMSCRIPTEN)/tools/bindings_generator.py box2d_bindings box2d.clean.h ...*truncated*

Resulting in the following error message on compile:

python: can't open file '1/tools/bindings_generator.py': [Errno 2] No such file or directory

Edit

Made a pull request with a fix for this.

Hosted webgl_demo fails for me.

http://kripken.github.io/box2d.js/webgl_demo/box2d.html isn't working for me on Chrome 31.0.1612.0 dev. I see no rendering but get this on the console:

Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Math.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Shader.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Material.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Utility.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.MainLoop.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Mesh.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Texture.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.UVMapper.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Renderer.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Light.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Camera.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Scene.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.PostProcess.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Motion.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Layout.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Primitives.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.COLLADA.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.GML.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Particles.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Landscape.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Octree.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Worker.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.CVRXML.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.Polygon.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.CollisionMap.js
Failed to load resource: the server responded with a status of 404 (Not Found) http://kripken.github.io/source/CubicVR.ScenePhysics.js
CubicVR Log: Calibrated maximum lights per pass to: 1 CubicVR.min.js:13
50
Uncaught Error: Could not initialise shader vert(#define loopCount 1

The last error repeats.

I get the same thing when I self-host (the html5_canvas demo works fine for me).

FUNCTION_TABLE not declared

With the latest box2d.js, it looks like there is a bug with adding collisions.

I used the method mentioned in the README to implement the Collision events. But I get an error because FUNCTION_TABLE is not defined. I went through a bit and realized that FUNCTION_TABLE is not declared anywhere.

Allocating an array

How can I allocate an array in order to specify geometry (e.g. for a chain shape or polygon shape)?

Doesn't look like box2d.js was compiled with malloc.

Calling GetNext on fixture always return some object

The next code snippet results in an infinte loop:

var fixture = body.GetFixtureList();
while (fixture) {
    aabb.Combine(aabb, fixture.GetAABB());
    fixture = fixture.GetNext();
}

As I understand, it happens because GetNext() and similar functions in turn calls some wrapping function, that always create some object (if none) to return:

function Z(b, d) {
    var e = d ? d.prototype.b : cW,
    f = e[b];
    if (f) {
        return f
    }
    d = d || Object;
    f = Object.create(d.prototype);
    f.a = b;
    f.c = d;
    return e[b] = f
}
Module.wrapPointer = Z;

Re-building on mac os makes testbed fail

I tried to rebuild box2d.js in order to see more useful error messages while trying to port an application from box2dweb and to actually be able to read the code that I'm using. I'm on OSX.
After installing llvm and clang 3.1 (with macports), I changed the llvm path in the makefile and removed the -O2 parameter (later, I also tried building with the original parameter set). I also set -xc++ as the comment suggested. Now, running make results in a new box2d.js file, which I copied into html5canvas_demo as embox2d.js, which results in a very long error message that starts with
Uncaught TypeError: Property '0' of object 0,0,function __ZN15b2ContactFilterD1Ev($this) {

(lots of function calls in libcxx in between)
and ends in },0 is not a function. This is on chrome 24. I get a similar output in Firefox.
Going back to 23b2a7903505c69f0252fa891c8fc7cac08a58bc of emscripten yields the same behaviour.

Using the box2d.js from git, it runs fine. What is wrong?

Non-minified source?

Any chance you could include a non-minified javascript file? Debugging into the minified javascript is not any fun.

b2Body missing SetPosition/SetAngle

As far as I can tell the bindings for b2Body are missing the SetPosition and SetAngle functions. Can support for these be added? Is there a workaround?

Finding vertices of an edge shape

I want to draw bodies by other rendering methods instead of debug draw. so,to draw an edge shape we have to know the vertices comprising the edgeshape.

can someone let me know how to know these vertices.

"Assertion: 20" Error

This code results in an Assertion: 20 error message.
Not sure what I'm doing wrong, and the error message does not give much information.

var gravity = new Box2D.b2Vec2( 0, 0 );
var world = new Box2D.b2World( gravity );

var bodyDef = new Box2D.b2BodyDef();
bodyDef.type = Box2D.b2_staticBody;
bodyDef.position = new Box2D.b2Vec2(0,0);
var body = world.CreateBody( bodyDef );

var shape = new Box2D.b2PolygonShape();
shape.SetAsBox(1,1);

var fixture = new Box2D.b2FixtureDef();
fixture.shape = shape;

body.CreateFixture( fixture );

Box2D.js does not work in strict mode

I need to use Box2D.js in a strict-mode environment. Put "use strict"; at the top of box2d.js and it fails with "cannot set property 'Module' of undefined", due to the use of "this" to refer to global namespace which is not allowed in strict mode.

To work around this I have to remove a weird try/catch which tries to assign this.Module (why?) and remove the assignment of this.Box2D at the end. Then I add "var Module = {};" to the top.

Further the script proceeds to clobber pretty much every two-letter global variable, which causes random weird errors if incorporated in to a large existing JS codebase. It really ought to go in its own closure.

"b2MassData" is not bound / is not accessible.

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 massData = new Box2D.b2MassData(); in console.

Error:
TypeError: undefined is not a function

why get_ and set_ when js has getter/setter definitions?

JS supports automatic code execution on get/set by defining an object property explicitly (using Object.defineProperty). Why is the port using the non-box2d get_ and set_ API rather than taking advantage of JS getter/setter functionality to preserve the "universal" Box2d API?

On document translation

Hi, I'm a uni student from China, and I thought of helping translate the document into Chinese. And I found that it's a large folder with many html files. I have not done a document translation before. Do anyone have a advise? Or where could I start ? Thanks.

EdgeShape

Hi,
Wanted to create a b2EdgeShape, but I see that a few properties are not exposed through the JS api. I investigated it like this:

var edge = new b2EdgeShape();
console.log(edge)

There are no functions for setting m_vertex1, m_vertex2, m_hasVertex0, m_hasVertex3. These are the properties I need for now...

They are defined in the Box2D C++ code here:
https://github.com/kripken/box2d.js/blob/master/Box2D_v2.2.1/Box2D/Collision/Shapes/b2EdgeShape.h#L57

Thanks for an otherwise great port, it's been working nicely for me so far!

Stefan

Fails to set mass and inertia when using b2FixtureDef

There seems to be a problem when using b2FixtureDef to create a fixture. With the following code

function createBody(x, y, rot, dynamic) {
    var bodyDef = new Box2D.b2BodyDef();
    bodyDef.set_position(new Box2D.b2Vec2(x, y));
    bodyDef.set_angle(rot);
    bodyDef.set_type(dynamic ? Box2D.b2_dynamicBody : Box2D.b2_staticBody);
    var body = world.CreateBody(bodyDef);
    var shape = new Box2D.b2PolygonShape();
    shape.SetAsBox(1, 0.1);
    var fixtureDef = new Box2D.b2FixtureDef();
    fixtureDef.set_density(1);
    fixtureDef.set_shape(shape);
    body.CreateFixture(fixtureDef);
    return body;
  }

I get the error "Uncaught Assertion failed: m_I > 0.0f, at Box2D_v2.2.1/Box2D/Dynamics/b2Body.cpp, 319, void b2Body::ResetMassData()".
What I was also wondering about is why the b2MassData is not available as javascript class in the Box2D namespace.

Error while trying to destroy body

var embox2dTest_joints = function() {
//constructor
}

embox2dTest_joints.prototype.setNiceViewCenter = function() {
//called once when the user changes to this test from another test
PTM = 30;
setViewCenterWorld( new b2Vec2(0,0), true );
}
embox2dTest_joints.prototype.setup = function() {
//set up the Box2D scene here - the world is already created
//setting up the base

body=new b2BodyDef();
body.set_position(new b2Vec2(0,0));
body.set_angle(0);
body.set_type(b2_staticBody);
ground=world.CreateBody(body);
shape=new b2PolygonShape();
shape.SetAsBox(25,0.25);
fixture=new b2FixtureDef();
fixture.set_shape(shape);
fixture.set_density(10.0);
fixture.set_restitution(0.5);
ground.CreateFixture(fixture);
//setting up body1
body=new b2BodyDef();
body.set_position(new b2Vec2(-15,5));
body.set_angle(-Math.PI/6);
body.set_type(b2_dynamicBody);
body1=world.CreateBody(body);
shape=new b2CircleShape();
shape.set_m_radius(1.5);
fixture=new b2FixtureDef();
fixture.set_shape(shape);
fixture.set_density(5.0);
fixture.set_restitution(0.5);
body1.CreateFixture(fixture);
}
embox2dTest_joints.prototype.step = function() {
//this function will be called at the beginning of every time step
if(body1.GetPosition().get_x()-1.5>=20)
{
world.DestroyBody(body1);
}
}
In the above code Iam trying to destroy the body if it exceeds the limits(x-cordinate>20).But I was getting an error:
Uncaught # box2d.js :1
please help me regarding this issue.

using customizeVTable

Box2D.customizeVTable(debugDraw, [{
original: Box2D.b2Draw.prototype.DrawSegment,
replacement:
function(ths, vert1, vert2, color) {
alert('called');
}
}]);
In the above code I'm not knowing how the parameters "ths" is a pointer .I want to know to what "ths" parameter is pointing to.

Uncaught "Finished up all reserved function pointers."

Error message: "Uncaught Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS."

This occurs when calling the following function:

function getCanvasDebugDraw() {
    var debugDraw = new Box2D.b2Draw();

    Box2D.customizeVTable(debugDraw, [{
    original: Box2D.b2Draw.prototype.DrawSegment,
    replacement:
        function(ths, vert1, vert2, color) {
            alert('called');
        }
    }]);

    Box2D.customizeVTable(debugDraw, [{
    original: Box2D.b2Draw.prototype.DrawPolygon,
    replacement:
        function(ths, vertices, vertexCount, color) {
            alert('called');
        }
    }]);

    Box2D.customizeVTable(debugDraw, [{
    original: Box2D.b2Draw.prototype.DrawSolidPolygon,
    replacement:
        function(ths, vertices, vertexCount, color) {
            alert('called');
        }
    }]);

    Box2D.customizeVTable(debugDraw, [{
    original: Box2D.b2Draw.prototype.DrawCircle,
    replacement:
        function(ths, center, radius, color) {
            alert('called');
        }
    }]);

    Box2D.customizeVTable(debugDraw, [{
    original: Box2D.b2Draw.prototype.DrawSolidCircle,
    replacement:
        function(ths, center, radius, axis, color) {
            alert('called');
        }
    }]);

    Box2D.customizeVTable(debugDraw, [{
    original: Box2D.b2Draw.prototype.DrawTransform,
    replacement:
        function(ths, transform) {
            alert('called');
        }
    }]);

    return debugDraw;
}

Do I need to recompile Box2D to change this setting?

Edit: Yes, it appears I do.

Upgrade plans

We should upgrade box2d like bullet is ( kripken/ammo.js#60 ), by moving to the latest box2d code, latest emscripten, and the new bindings approach (the WebIDL binder). See details in that link, the situation is very parallel here in box2d. Basically if you want to help, start a branch with an update of box2d, and start to write the IDL stuff we need.

Odd results from op_add/op_sub

This:

var a = new b2Vec2( 9, 6 );
var b = new b2Vec2( 2, 3 );
a.op_add(b);
console.log( a.get_x() + ", " + a.get_y() );

... prints "11, 9" -> correct

Changing the third line to

a.op_sub(b);

... prints "9, 6" -> incorrect

Interestingly, assigning the return value like:

var c = a.op_sub(b);
console.log( c.get_x() + ", " + c.get_y() );

... prints "-9, -6" while:

var c = a.op_add(b);
console.log( c.get_x() + ", " + c.get_y() );

... gives: Uncaught TypeError: Cannot call method 'get_x' of undefined

On a related note:

 a.op_set(b);

... gives: Uncaught TypeError: Object # has no method 'op_set'

Given that embind will replace these bindings I guess this is very low priority, but I just thought I would point out that there is something weird going on here :)

testbed car demo broken

the current testbed car demo is broken:

Uncaught TypeError: Object 300 has no method 'stackAlloc' box2d.js:414
Uncaught TypeError: Cannot call method 'SetMotorSpeed' of null car.js:212

b2BodyDef.set_position does not work.

These all create a body at 0, 0

 _bodyDef.set_position(0, 0)
 _bodyDef.set_position(200 , -9000)
 _bodyDef.set_position(40, 50)
 _bodyDef.set_position(-60, -20)
 _bodyDef.set_position(x, y)

Rebuilt box2d.js much larger than checked in box2d.js

I rebuilt box2d.js with emscripten 1.21.0 (installed via the SDK instructions at https://github.com/kripken/emscripten/wiki/Emscripten%20SDK), and the output file was about 893k. If I manually minify it with closure, it drops down to about 843k. The build checked in to this repository is 741k.

Any idea why my final build is so much larger? I don't really care much about the size of the file per se, I just want to make sure I'm not missing any optimizations in the build process.

Thanks.

Raycast Bindings

I have had no luck getting RayCasting to work. There does not appear to be bindings for b2RayCastInput and b2RayCastOutput. In the ReadMe it says that you can use customizeVTable for RayCasting but without those bindings I am completely lost on how to make it work. Can someone point me in the right direction?

Errors in Node.js environment

There are some issues with using box2d.js in a Node.js environment:

  • it's not exported as Node.js module
  • Mocha detects Error: global leak detected: Module

The fixes are easy, but I have no idea where to put them:

  • replace Module; with var Module; somewhere
  • add module.exports = Module; at the end of the file

Cheers,
Chris

"b2Manifold" is not bound / is not accessible.

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 the following code in console:
var body = world.GetBodyList(); // returns b2Body instance
var edge = body.GetContactList(); // returns b2ContactEdge instance
var contact = edge.get_contact(); // returns b2Contact instance
var manifold = contact.GetManifold(); // returns Object (should be b2Manifold!)
var localNormal = manifold.get_localNormal();
// ^ TypeError: Object #<Object> has no method 'get_localNormal'

localNormal is a public attribute of b2Manifold and should be accessible via get_localNormal().

build with box2d v2.3

on macosx, with emscripten 1.7.8

I got to replace CppHeaderParser with v2.4, had to remove a few '$'s in box2d.clean.h since CppHeaderParser cannot parse them, until I encountered this result:

python emsdk_portable/emscripten/1.7.8//tools/bindings_generator.py box2d_bindings box2d.clean.h -- '{ "ignored": "b2Shape::m_type,b2BroadPhase::RayCast,b2BroadPhase::UpdatePairs,b2BroadPhase::Query,b2DynamicTree::RayCast,b2DynamicTree::Query,b2ChainShape::m_nextVertex,b2ChainShape::m_hasNextVertex,b2EdgeShape::m_hasVertex3,b2EdgeShape::m_vertex2,b2EdgeShape::m_vertex3,b2Mat22,b2Mat33" }' > bindings.out
Traceback (most recent call last):
File "emsdk_portable/emscripten/1.7.8//tools/bindings_generator.py", line 404, in
explore(clazz)
File "emsdk_portable/emscripten/1.7.8//tools/bindings_generator.py", line 394, in explore
template_name = classes[parent]['template_typename']
KeyError: 'template_typename'
make: *** [box2d_bindings.cpp] Error 1

Memory Leak

I'm working on a Box2D.js plugin for the ImpactJS game engine. Ever since I made this commit, I've been getting this error message:

Uncaught Assertion: Cannot enlarge memory arrays in asm.js. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value, or (2) set Module.TOTAL_MEMORY before the program runs.

It happens consistently after 2 minutes of running with about 250 entities. After doubling TOTAL_MEMORY, the error continues to occur, but after 7.5 minutes instead.

Before this commit, I could run the simulation for hours without any issue.

I suspect what's happening here is that instances of b2Vec2 are being created but not destroyed properly, and eventually all the memory is used up. What am I doing wrong here?


Here is the new troublesome method being called once per update by every entity:

limitVelocity: function() {
    var velocity = this.body.GetLinearVelocity();
    var x = velocity.get_x() / Box2D.b2SCALE;
    var y = velocity.get_y() / Box2D.b2SCALE;
    if(x < -this.maxVel.x)     x = -this.maxVel.x;
    else if(x > this.maxVel.x) x = this.maxVel.x;
    if(y < -this.maxVel.y)     y = -this.maxVel.y;
    else if(y > this.maxVel.y) y = this.maxVel.y;
    x *= Box2D.b2SCALE;
    y *= Box2D.b2SCALE;
    this.body.SetLinearVelocity( new Box2D.b2Vec2(x, y), this.body.GetPosition() );
}

userData dont work

body.set_userData(x);

it only appears to accept numeric parameters, which is not useful, it should be able to accept js objects

inconsistent performance on first run

Hello

I was previously using the box2D Javascript version found here:
http://box2d-js.sourceforge.net/

I ported my code to your emscripten generated version. However, I am getting completely inconsistent performance on the first run. I noticed you have the same problem in the demo:

http://syntensity.com/static/box2d.html

On the first run, as soon as the cubes start touching, the framerate goes down to 15fps or so. Then it is back to 60fps on the next runs.

My probem is that the first run is the only run people see (at least in my demo).

Is there any way to fix this ?

I am using Chrome 22 on a mac book pro.

Thanks
Martin

make problem on macosx

On MaxOSX, I get the following when trying to emmake make this project.
Does anyone else encounter this?

cpp -x c++ -DEM_NO_LIBCPP -IBox2D_v2.2.1 root.h > box2d.clean.h
i686-apple-darwin11-llvm-gcc-4.2: c: No such file or directory
i686-apple-darwin11-llvm-gcc-4.2: c++: No such file or directory
i686-apple-darwin11-llvm-gcc-4.2: warning: '-x -x' after last input file has no effect
i686-apple-darwin11-llvm-gcc-4.2: no input files
make: *** [box2d.clean.h] Error 1

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

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

Can't set (or get) user data

The following (inside a constructor):

var body_def = new b2BodyDef();
body_def.set_type(Box2D.b2_dynamicBody);
body_def.get_position().Set(0,0);

var shape_def = new b2CircleShape();
shape_def.set_m_radius(7/30);

var fixture_def = new b2FixtureDef();
fixture_def.set_density(0.0);
fixture_def.set_friction(0.0);
fixture_def.set_shape(shape_def);

this._body = this._world.CreateBody(body_def);
this._body.CreateFixture(fixture_def);

this._body.SetUserData(this);
console.log(this._body.GetUserData());

Prints 0 on the console. I'm trying to detect collision between two objects but without the user data I can't see the difference between them.

Incorrect code generated in current released build (likely emscripten bug)

Hi again,

I was debugging some apparently impossible behavior - basically, my contact listener was getting BeginContact called continuously while two fixtures were in contact, and then I would get only one EndContact call when the contact ceased.

Rebuilding with -profiling, I found that the first contact event came from the expected code path (b2Contact::Update), while subsequent events came from bogus code paths that made no sense.

It appears that the culprit is the -O3 in the LINK_OPTS variable in the Makefile. If I remove that, I get a working build.

Steps to reproduce:

  1. Use the current box2d.js build at https://github.com/kripken/box2d.js/blob/master/box2d.js.
  2. Run the following coffee-script: https://gist.github.com/mlogan/086c0b29ba5eafcd3af6 (javascript available at: https://gist.github.com/mlogan/04a7de8d5e3792b398ab)
  3. Observe that the begin event is triggered many times, the end event only once.
  4. Rebuild box2d.js with LINK_OPTS = (remove the -O3), rerun the reproduction script.
  5. Observe that the behavior is now correct.

Hope this is enough to go on.

Variable name shadowing causing random failures

The naming scheme used by the asm.js compilation uses functions and variables with the same name. This is an error in strict mode (see also issue #42). Evne if you're not using strict mode, surely this will cause bugs and crashes? How can the script possibly call the right function or reference the right variable if they both have the same names?

An example:

Line 8 defines 'xa' as:

function xa(a){var c=ka;ka=ka+a|0;ka=ka+7>>3<<3;return c}

Line 414 defines 'xa' (same case) as:

var xa=function(a){return x.stackAlloc(a)}

We seem to be hitting an issue that is associated with this: in strict mode it fails with "variable name 'xa' already defined", and when not in strict mode, we randomly hit "uncaught assertion: 3".

Box2D.js will not compile on Windows 7 using the 'make' command.

Here is a dump of the command prompt along with the error message:

D:\wamp\www\box2d.js>make
/emscripten/emcc -IBox2D_v2.2.1 Box2D_v2.2.1/Box2D/Collision/b2BroadPhase.cpp -o
 Box2D_v2.2.1/Box2D/Collision/b2BroadPhase.bc
Fatal Python error: Py_Initialize: can't initialize sys standard streams
ImportError: No module named encodings.utf_8

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
make: *** [Box2D_v2.2.1/Box2D/Collision/b2BroadPhase.bc] Error 3

(Using Python 2.7.5, Node.js 0.8.15, gcc 4.6.2 and Clang 3.2)

Generating box2d.clean.h

I'm in need of a compiled box2d.js which uses no typed arrays (because of lack of Float64Array support).

So I am attempting to use emcc with the makefile provided with box2d.js project. I have been able to get emcc working (follow the emscripten Tutorial)

Currently failing here:

box2d.clean.h:
    cpp -x c++ -DEM_NO_LIBCPP -IBox2D_v2.2.1 root.h > box2d.clean.h
$ cpp -x c++ -DEM_NO_LIBCPP -IBox2D_v2.2.1 root.h > box2d.clean.h
i686-apple-darwin11-llvm-gcc-4.2: c: No such file or directory
i686-apple-darwin11-llvm-gcc-4.2: c++: No such file or directory
i686-apple-darwin11-llvm-gcc-4.2: warning: '-x -x' after last input file has no effect
i686-apple-darwin11-llvm-gcc-4.2: no input files

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.