define([ "Lib/Vendor/Box2D/asmBox2d" ], function () { //Having to type 'Box2D.' in front of everything makes porting //existing C++ code a pain in the butt. This function can be used //to make everything in the Box2D namespace available without //needing to do that. var using = function (ns, pattern) { if (pattern == undefined) { // import all for (var name in ns) { this[name] = ns[name]; } } else { if (typeof(pattern) == 'string') { pattern = new RegExp(pattern); } // import only stuff matching given pattern for (var name in ns) { if (name.match(pattern)) { this[name] = ns[name]; } } } } var e_shapeBit = 0x0001; var e_jointBit = 0x0002; var e_aabbBit = 0x0004; var e_pairBit = 0x0008; var e_centerOfMassBit = 0x0010; //to replace original C++ operator = function copyVec2(vec) { return new b2Vec2(vec.get_x(), vec.get_y()); } //to replace original C++ operator * (float) function scaleVec2(vec, scale) { vec.set_x( scale * vec.get_x() ); vec.set_y( scale * vec.get_y() ); } //to replace original C++ operator *= (float) function scaledVec2(vec, scale) { return new b2Vec2(scale * vec.get_x(), scale * vec.get_y()); } // http://stackoverflow.com/questions/12792486/emscripten-bindings-how-to-create-an-accessible-c-c-array-from-javascript function createChainShape(vertices, closedLoop) { var shape = new b2ChainShape(); var buffer = Box2D.allocate(vertices.length * 8, 'float', Box2D.ALLOC_STACK); var offset = 0; for (var i=0;i