diff --git a/app/Game/Channel/Control/PlayerController.js b/app/Game/Channel/Control/PlayerController.js index c8e5c6e..2c8c0c0 100755 --- a/app/Game/Channel/Control/PlayerController.js +++ b/app/Game/Channel/Control/PlayerController.js @@ -57,13 +57,13 @@ function(Parent, Nc, Parser, Settings) { this.player.doll.updatePositionState(update); } else { // HARD UPDATE FOR SELF - console.log(this.player.user.options.nickname + ' is cheating.') + console.log(this.player.user.options.nickname + ' is cheating. difference:', difference); var body = this.player.doll.body; var options = { - p: body.GetPosition(), - lv: body.GetLinearVelocity() + p: body.GetPosition().Copy(), + lv: body.GetLinearVelocity().Copy() }; Nc.trigger(Nc.ns.channel.to.client.user.gameCommand.send + this.player.id, 'positionStateReset', options); diff --git a/app/Game/Channel/GameController.js b/app/Game/Channel/GameController.js index eb7e013..3554b5b 100755 --- a/app/Game/Channel/GameController.js +++ b/app/Game/Channel/GameController.js @@ -50,7 +50,9 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N } GameController.prototype.onLevelLoaded = function() { + console.log("onLevelLoaded updateWorld pre") this.updateWorld(); + console.log("onLevelLoaded updateWorld post") }; GameController.prototype.onUserJoined = function (user) { @@ -115,20 +117,22 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N getSleeping = getSleeping || false; var update = {}; - var body = this.physicsEngine.world.GetBodyList(); + do { + if((getSleeping || body.IsAwake()) && body.GetType() === Box2D.Dynamics.b2Body.b2_dynamicBody) { var userData = body.GetUserData(); + if (userData instanceof GameObject) { var gameObject = userData; update[gameObject.uid] = { - p: body.GetPosition(), + p: body.GetPosition().Copy(), a: body.GetAngle(), - lv: body.GetLinearVelocity(), - av: body.GetAngularVelocity() + lv: body.GetLinearVelocity().Copy(), + av: body.GetAngularVelocity().Copy() }; if(gameObject instanceof Doll) { @@ -138,6 +142,12 @@ function (Parent, PhysicsEngine, Settings, PlayerController, requestAnimFrame, N } } + if(Settings.USE_ASM) { + if(body.GetNext() == body) { + break; + } + } + } while (body = body.GetNext()); return update; diff --git a/app/Game/Client/GameController.js b/app/Game/Client/GameController.js index 9cb1ca6..614691c 100755 --- a/app/Game/Client/GameController.js +++ b/app/Game/Client/GameController.js @@ -135,6 +135,12 @@ function (Parent, Box2D, PhysicsEngine, ViewManager, PlayerController, Nc, reque body.SetAngularVelocity(update.av); } } + + if(Settings.USE_ASM) { + if(body.GetNext() == body) { + break; + } + } } while (body = body.GetNext()); diff --git a/app/Game/Config/Settings.js b/app/Game/Config/Settings.js index d856841..07ff94f 100755 --- a/app/Game/Config/Settings.js +++ b/app/Game/Config/Settings.js @@ -59,11 +59,12 @@ define(function() { CANVAS_DOM_ID: 'canvasContainer', IS_BROWSER_ENVIRONMENT: typeof window !== 'undefined', USE_WEBGL: true, + USE_ASM: true, // NETWORKING NETWORK_UPDATE_INTERVAL: 70, CHANNEL_DESTRUCTION_TIME: 30, - NETWORK_LOG_INCOMING: false, + NETWORK_LOG_INCOMING: true, NETWORK_LOG_OUTGOING: false, NETWORK_LOG_FILTER: ['ping', 'pong', 'worldUpdate', 'lookAt'], diff --git a/app/Game/Core/GameObjects/Tile.js b/app/Game/Core/GameObjects/Tile.js index 2f483db..9208d71 100755 --- a/app/Game/Core/GameObjects/Tile.js +++ b/app/Game/Core/GameObjects/Tile.js @@ -22,8 +22,11 @@ function (Parent, Box2D, Settings, Exception, Nc) { var bodyDef = new Box2D.Dynamics.b2BodyDef(); bodyDef.type = Box2D.Dynamics.b2Body.b2_staticBody; - bodyDef.position.x = (this.options.x * Settings.TILE_SIZE + Settings.TILE_SIZE / 2) / Settings.RATIO; - bodyDef.position.y = (this.options.y * Settings.TILE_SIZE + Settings.TILE_SIZE / 2) / Settings.RATIO; + + var x = (this.options.x * Settings.TILE_SIZE + Settings.TILE_SIZE / 2) / Settings.RATIO; + var y = (this.options.y * Settings.TILE_SIZE + Settings.TILE_SIZE / 2) / Settings.RATIO; + + bodyDef.position = new Box2D.Common.Math.b2Vec2(x, y); bodyDef.angle = (this.options.r || 0) * 90 * Math.PI / 180; return bodyDef; @@ -31,8 +34,14 @@ function (Parent, Box2D, Settings, Exception, Nc) { Tile.prototype.createPhysicTile = function (tile) { var vertices = this.createVertices(tile); - var tileShape = new Box2D.Collision.Shapes.b2PolygonShape(); - tileShape.SetAsArray(vertices, vertices.length); + + var tileShape; + if(Settings.USE_ASM) { + tileShape = Box2D.createPolygonShape(vertices); + } else { + tileShape = new Box2D.Collision.Shapes.b2PolygonShape(); + tileShape.SetAsArray(vertices, vertices.length); + } var fixtureDef = new Box2D.Dynamics.b2FixtureDef(); fixtureDef.shape = tileShape; diff --git a/app/Lib/Vendor/Box2D.js b/app/Lib/Vendor/Box2D.js index c059918..4ce1c77 100755 --- a/app/Lib/Vendor/Box2D.js +++ b/app/Lib/Vendor/Box2D.js @@ -1,10866 +1,148 @@ -define(function() { +define([ + "Game/Config/Settings", + //"Lib/Vendor/Box2D/Box2D", + "Lib/Vendor/Box2D/asmBox2d", + //"Lib/Vendor/Box2D/helpers" +], + +function (Settings, /*Box2dWeb, */AsmBox2d) { + + if(Settings.USE_ASM) { + + Box2D.Dynamics = { + Controllers: { + b2ControllerEdge: Module.b2ControllerEdge + }, + Contacts: { + b2CircleContact: Module.b2CircleContact + }, + Joints: { + b2DistanceJoint: Module.b2CircleContact + }, + b2World: Module.b2World, + b2ContactListener: Module.b2ContactListener, + b2BodyDef: Module.b2BodyDef, + b2FixtureDef: Module.b2FixtureDef, + b2Body: Module.b2Body + }; + Box2D.Common = { + b2Color: Module.b2Color, + Math: { + b2Mat22: Module.b2Mat22, + b2Vec2: Module.b2Vec2 + } + } + Box2D.Collision = { + Shapes: { + b2CircleShape: Module.b2CircleShape, + b2PolygonShape: Module.b2PolygonShape + } + } + + Box2D.Dynamics.b2Body.b2_dynamicBody = Module.b2_dynamicBody; + Box2D.Dynamics.b2Body.b2_staticBody = Module.b2_staticBody; + + + // ---------------- ---------------- ---------------- ---------------- + + function augmentProperties(object) { + + var properties = {}; + + for(var key in object.prototype) { + + (function(){ + + var setterMatches = key.match(/^set_(.*)/); + var getterMatches = key.match(/^get_(.*)/); + + if(setterMatches || getterMatches) { + var name = setterMatches ? setterMatches[1] : getterMatches[1]; + + if(typeof properties[name] !== 'object') { + properties[name] = { + setter: undefined, + getter: undefined + }; + } + + if(setterMatches) { + properties[name].setter = function(x){ + //console.trace("here i am ", x, name); + this["set_" + name](x); + }; + } + + if(getterMatches) { + properties[name].getter = function(){ + return this["get_" + name]() + }; + } + } + })(); + } + + for(var name in properties) { + Object.defineProperty(object.prototype, name, { + set: properties[name].setter, + get: properties[name].getter + }); + } + } + + augmentProperties(Box2D.Dynamics.b2BodyDef); + augmentProperties(Box2D.Dynamics.b2FixtureDef); + augmentProperties(Box2D.Common.Math.b2Vec2); + + // Merge helper functions + /*for(var key in Helpers) { + Box2D[key] = Helpers[key]; + }*/ + + Box2D.createPolygonShape = function (vertices) { + var shape = new Box2D.Collision.Shapes.b2PolygonShape(); + var buffer = Box2D.allocate(vertices.length * 8, 'float', Box2D.ALLOC_STACK); + var offset = 0; + for (var i=0;i= 0.0 && dY >= 0.0; - valid = valid && this.lowerBound.IsValid() && this.upperBound.IsValid(); - return valid; - } - b2AABB.prototype.GetCenter = function () { - return new b2Vec2((this.lowerBound.x + this.upperBound.x) / 2, (this.lowerBound.y + this.upperBound.y) / 2); - } - b2AABB.prototype.GetExtents = function () { - return new b2Vec2((this.upperBound.x - this.lowerBound.x) / 2, (this.upperBound.y - this.lowerBound.y) / 2); - } - b2AABB.prototype.Contains = function (aabb) { - var result = true; - result = result && this.lowerBound.x <= aabb.lowerBound.x; - result = result && this.lowerBound.y <= aabb.lowerBound.y; - result = result && aabb.upperBound.x <= this.upperBound.x; - result = result && aabb.upperBound.y <= this.upperBound.y; - return result; - } - b2AABB.prototype.RayCast = function (output, input) { - var tmin = (-Number.MAX_VALUE); - var tmax = Number.MAX_VALUE; - var pX = input.p1.x; - var pY = input.p1.y; - var dX = input.p2.x - input.p1.x; - var dY = input.p2.y - input.p1.y; - var absDX = Math.abs(dX); - var absDY = Math.abs(dY); - var normal = output.normal; - var inv_d = 0; - var t1 = 0; - var t2 = 0; - var t3 = 0; - var s = 0; { - if (absDX < Number.MIN_VALUE) { - if (pX < this.lowerBound.x || this.upperBound.x < pX) return false; - } - else { - inv_d = 1.0 / dX; - t1 = (this.lowerBound.x - pX) * inv_d; - t2 = (this.upperBound.x - pX) * inv_d; - s = (-1.0); - if (t1 > t2) { - t3 = t1; - t1 = t2; - t2 = t3; - s = 1.0; - } - if (t1 > tmin) { - normal.x = s; - normal.y = 0; - tmin = t1; - } - tmax = Math.min(tmax, t2); - if (tmin > tmax) return false; - } - } { - if (absDY < Number.MIN_VALUE) { - if (pY < this.lowerBound.y || this.upperBound.y < pY) return false; - } - else { - inv_d = 1.0 / dY; - t1 = (this.lowerBound.y - pY) * inv_d; - t2 = (this.upperBound.y - pY) * inv_d; - s = (-1.0); - if (t1 > t2) { - t3 = t1; - t1 = t2; - t2 = t3; - s = 1.0; - } - if (t1 > tmin) { - normal.y = s; - normal.x = 0; - tmin = t1; - } - tmax = Math.min(tmax, t2); - if (tmin > tmax) return false; - } - } - output.fraction = tmin; - return true; - } - b2AABB.prototype.TestOverlap = function (other) { - var d1X = other.lowerBound.x - this.upperBound.x; - var d1Y = other.lowerBound.y - this.upperBound.y; - var d2X = this.lowerBound.x - other.upperBound.x; - var d2Y = this.lowerBound.y - other.upperBound.y; - if (d1X > 0.0 || d1Y > 0.0) return false; - if (d2X > 0.0 || d2Y > 0.0) return false; - return true; - } - b2AABB.Combine = function (aabb1, aabb2) { - var aabb = new b2AABB(); - aabb.Combine(aabb1, aabb2); - return aabb; - } - b2AABB.prototype.Combine = function (aabb1, aabb2) { - this.lowerBound.x = Math.min(aabb1.lowerBound.x, aabb2.lowerBound.x); - this.lowerBound.y = Math.min(aabb1.lowerBound.y, aabb2.lowerBound.y); - this.upperBound.x = Math.max(aabb1.upperBound.x, aabb2.upperBound.x); - this.upperBound.y = Math.max(aabb1.upperBound.y, aabb2.upperBound.y); - } - b2Bound.b2Bound = function () {}; - b2Bound.prototype.IsLower = function () { - return (this.value & 1) == 0; - } - b2Bound.prototype.IsUpper = function () { - return (this.value & 1) == 1; - } - b2Bound.prototype.Swap = function (b) { - var tempValue = this.value; - var tempProxy = this.proxy; - var tempStabbingCount = this.stabbingCount; - this.value = b.value; - this.proxy = b.proxy; - this.stabbingCount = b.stabbingCount; - b.value = tempValue; - b.proxy = tempProxy; - b.stabbingCount = tempStabbingCount; - } - b2BoundValues.b2BoundValues = function () {}; - b2BoundValues.prototype.b2BoundValues = function () { - this.lowerValues = new Vector_a2j_Number(); - this.lowerValues[0] = 0.0; - this.lowerValues[1] = 0.0; - this.upperValues = new Vector_a2j_Number(); - this.upperValues[0] = 0.0; - this.upperValues[1] = 0.0; - } - b2Collision.b2Collision = function () {}; - b2Collision.ClipSegmentToLine = function (vOut, vIn, normal, offset) { - if (offset === undefined) offset = 0; - var cv; - var numOut = 0; - cv = vIn[0]; - var vIn0 = cv.v; - cv = vIn[1]; - var vIn1 = cv.v; - var distance0 = normal.x * vIn0.x + normal.y * vIn0.y - offset; - var distance1 = normal.x * vIn1.x + normal.y * vIn1.y - offset; - if (distance0 <= 0.0) vOut[numOut++].Set(vIn[0]); - if (distance1 <= 0.0) vOut[numOut++].Set(vIn[1]); - if (distance0 * distance1 < 0.0) { - var interp = distance0 / (distance0 - distance1); - cv = vOut[numOut]; - var tVec = cv.v; - tVec.x = vIn0.x + interp * (vIn1.x - vIn0.x); - tVec.y = vIn0.y + interp * (vIn1.y - vIn0.y); - cv = vOut[numOut]; - var cv2; - if (distance0 > 0.0) { - cv2 = vIn[0]; - cv.id = cv2.id; - } - else { - cv2 = vIn[1]; - cv.id = cv2.id; - }++numOut; - } - return numOut; - } - b2Collision.EdgeSeparation = function (poly1, xf1, edge1, poly2, xf2) { - if (edge1 === undefined) edge1 = 0; - var count1 = parseInt(poly1.m_vertexCount); - var vertices1 = poly1.m_vertices; - var normals1 = poly1.m_normals; - var count2 = parseInt(poly2.m_vertexCount); - var vertices2 = poly2.m_vertices; - var tMat; - var tVec; - tMat = xf1.R; - tVec = normals1[edge1]; - var normal1WorldX = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - var normal1WorldY = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - tMat = xf2.R; - var normal1X = (tMat.col1.x * normal1WorldX + tMat.col1.y * normal1WorldY); - var normal1Y = (tMat.col2.x * normal1WorldX + tMat.col2.y * normal1WorldY); - var index = 0; - var minDot = Number.MAX_VALUE; - for (var i = 0; i < count2; ++i) { - tVec = vertices2[i]; - var dot = tVec.x * normal1X + tVec.y * normal1Y; - if (dot < minDot) { - minDot = dot; - index = i; - } - } - tVec = vertices1[edge1]; - tMat = xf1.R; - var v1X = xf1.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - var v1Y = xf1.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - tVec = vertices2[index]; - tMat = xf2.R; - var v2X = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - var v2Y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - v2X -= v1X; - v2Y -= v1Y; - var separation = v2X * normal1WorldX + v2Y * normal1WorldY; - return separation; - } - b2Collision.FindMaxSeparation = function (edgeIndex, poly1, xf1, poly2, xf2) { - var count1 = parseInt(poly1.m_vertexCount); - var normals1 = poly1.m_normals; - var tVec; - var tMat; - tMat = xf2.R; - tVec = poly2.m_centroid; - var dX = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - var dY = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - tMat = xf1.R; - tVec = poly1.m_centroid; - dX -= xf1.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - dY -= xf1.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - var dLocal1X = (dX * xf1.R.col1.x + dY * xf1.R.col1.y); - var dLocal1Y = (dX * xf1.R.col2.x + dY * xf1.R.col2.y); - var edge = 0; - var maxDot = (-Number.MAX_VALUE); - for (var i = 0; i < count1; ++i) { - tVec = normals1[i]; - var dot = (tVec.x * dLocal1X + tVec.y * dLocal1Y); - if (dot > maxDot) { - maxDot = dot; - edge = i; - } - } - var s = b2Collision.EdgeSeparation(poly1, xf1, edge, poly2, xf2); - var prevEdge = parseInt(edge - 1 >= 0 ? edge - 1 : count1 - 1); - var sPrev = b2Collision.EdgeSeparation(poly1, xf1, prevEdge, poly2, xf2); - var nextEdge = parseInt(edge + 1 < count1 ? edge + 1 : 0); - var sNext = b2Collision.EdgeSeparation(poly1, xf1, nextEdge, poly2, xf2); - var bestEdge = 0; - var bestSeparation = 0; - var increment = 0; - if (sPrev > s && sPrev > sNext) { - increment = (-1); - bestEdge = prevEdge; - bestSeparation = sPrev; - } - else if (sNext > s) { - increment = 1; - bestEdge = nextEdge; - bestSeparation = sNext; - } - else { - edgeIndex[0] = edge; - return s; - } - while (true) { - if (increment == (-1)) edge = bestEdge - 1 >= 0 ? bestEdge - 1 : count1 - 1; - else edge = bestEdge + 1 < count1 ? bestEdge + 1 : 0;s = b2Collision.EdgeSeparation(poly1, xf1, edge, poly2, xf2); - if (s > bestSeparation) { - bestEdge = edge; - bestSeparation = s; - } - else { - break; - } - } - edgeIndex[0] = bestEdge; - return bestSeparation; - } - b2Collision.FindIncidentEdge = function (c, poly1, xf1, edge1, poly2, xf2) { - if (edge1 === undefined) edge1 = 0; - var count1 = parseInt(poly1.m_vertexCount); - var normals1 = poly1.m_normals; - var count2 = parseInt(poly2.m_vertexCount); - var vertices2 = poly2.m_vertices; - var normals2 = poly2.m_normals; - var tMat; - var tVec; - tMat = xf1.R; - tVec = normals1[edge1]; - var normal1X = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - var normal1Y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - tMat = xf2.R; - var tX = (tMat.col1.x * normal1X + tMat.col1.y * normal1Y); - normal1Y = (tMat.col2.x * normal1X + tMat.col2.y * normal1Y); - normal1X = tX; - var index = 0; - var minDot = Number.MAX_VALUE; - for (var i = 0; i < count2; ++i) { - tVec = normals2[i]; - var dot = (normal1X * tVec.x + normal1Y * tVec.y); - if (dot < minDot) { - minDot = dot; - index = i; - } - } - var tClip; - var i1 = parseInt(index); - var i2 = parseInt(i1 + 1 < count2 ? i1 + 1 : 0); - tClip = c[0]; - tVec = vertices2[i1]; - tMat = xf2.R; - tClip.v.x = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - tClip.v.y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - tClip.id.features.referenceEdge = edge1; - tClip.id.features.incidentEdge = i1; - tClip.id.features.incidentVertex = 0; - tClip = c[1]; - tVec = vertices2[i2]; - tMat = xf2.R; - tClip.v.x = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - tClip.v.y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - tClip.id.features.referenceEdge = edge1; - tClip.id.features.incidentEdge = i2; - tClip.id.features.incidentVertex = 1; - } - b2Collision.MakeClipPointVector = function () { - var r = new Vector(2); - r[0] = new ClipVertex(); - r[1] = new ClipVertex(); - return r; - } - b2Collision.CollidePolygons = function (manifold, polyA, xfA, polyB, xfB) { - var cv; - manifold.m_pointCount = 0; - var totalRadius = polyA.m_radius + polyB.m_radius; - var edgeA = 0; - b2Collision.s_edgeAO[0] = edgeA; - var separationA = b2Collision.FindMaxSeparation(b2Collision.s_edgeAO, polyA, xfA, polyB, xfB); - edgeA = b2Collision.s_edgeAO[0]; - if (separationA > totalRadius) return; - var edgeB = 0; - b2Collision.s_edgeBO[0] = edgeB; - var separationB = b2Collision.FindMaxSeparation(b2Collision.s_edgeBO, polyB, xfB, polyA, xfA); - edgeB = b2Collision.s_edgeBO[0]; - if (separationB > totalRadius) return; - var poly1; - var poly2; - var xf1; - var xf2; - var edge1 = 0; - var flip = 0; - var k_relativeTol = 0.98; - var k_absoluteTol = 0.001; - var tMat; - if (separationB > k_relativeTol * separationA + k_absoluteTol) { - poly1 = polyB; - poly2 = polyA; - xf1 = xfB; - xf2 = xfA; - edge1 = edgeB; - manifold.m_type = b2Manifold.e_faceB; - flip = 1; - } - else { - poly1 = polyA; - poly2 = polyB; - xf1 = xfA; - xf2 = xfB; - edge1 = edgeA; - manifold.m_type = b2Manifold.e_faceA; - flip = 0; - } - var incidentEdge = b2Collision.s_incidentEdge; - b2Collision.FindIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2); - var count1 = parseInt(poly1.m_vertexCount); - var vertices1 = poly1.m_vertices; - var local_v11 = vertices1[edge1]; - var local_v12; - if (edge1 + 1 < count1) { - local_v12 = vertices1[parseInt(edge1 + 1)]; - } - else { - local_v12 = vertices1[0]; - } - var localTangent = b2Collision.s_localTangent; - localTangent.Set(local_v12.x - local_v11.x, local_v12.y - local_v11.y); - localTangent.Normalize(); - var localNormal = b2Collision.s_localNormal; - localNormal.x = localTangent.y; - localNormal.y = (-localTangent.x); - var planePoint = b2Collision.s_planePoint; - planePoint.Set(0.5 * (local_v11.x + local_v12.x), 0.5 * (local_v11.y + local_v12.y)); - var tangent = b2Collision.s_tangent; - tMat = xf1.R; - tangent.x = (tMat.col1.x * localTangent.x + tMat.col2.x * localTangent.y); - tangent.y = (tMat.col1.y * localTangent.x + tMat.col2.y * localTangent.y); - var tangent2 = b2Collision.s_tangent2; - tangent2.x = (-tangent.x); - tangent2.y = (-tangent.y); - var normal = b2Collision.s_normal; - normal.x = tangent.y; - normal.y = (-tangent.x); - var v11 = b2Collision.s_v11; - var v12 = b2Collision.s_v12; - v11.x = xf1.position.x + (tMat.col1.x * local_v11.x + tMat.col2.x * local_v11.y); - v11.y = xf1.position.y + (tMat.col1.y * local_v11.x + tMat.col2.y * local_v11.y); - v12.x = xf1.position.x + (tMat.col1.x * local_v12.x + tMat.col2.x * local_v12.y); - v12.y = xf1.position.y + (tMat.col1.y * local_v12.x + tMat.col2.y * local_v12.y); - var frontOffset = normal.x * v11.x + normal.y * v11.y; - var sideOffset1 = (-tangent.x * v11.x) - tangent.y * v11.y + totalRadius; - var sideOffset2 = tangent.x * v12.x + tangent.y * v12.y + totalRadius; - var clipPoints1 = b2Collision.s_clipPoints1; - var clipPoints2 = b2Collision.s_clipPoints2; - var np = 0; - np = b2Collision.ClipSegmentToLine(clipPoints1, incidentEdge, tangent2, sideOffset1); - if (np < 2) return; - np = b2Collision.ClipSegmentToLine(clipPoints2, clipPoints1, tangent, sideOffset2); - if (np < 2) return; - manifold.m_localPlaneNormal.SetV(localNormal); - manifold.m_localPoint.SetV(planePoint); - var pointCount = 0; - for (var i = 0; i < b2Settings.b2_maxManifoldPoints; ++i) { - cv = clipPoints2[i]; - var separation = normal.x * cv.v.x + normal.y * cv.v.y - frontOffset; - if (separation <= totalRadius) { - var cp = manifold.m_points[pointCount]; - tMat = xf2.R; - var tX = cv.v.x - xf2.position.x; - var tY = cv.v.y - xf2.position.y; - cp.m_localPoint.x = (tX * tMat.col1.x + tY * tMat.col1.y); - cp.m_localPoint.y = (tX * tMat.col2.x + tY * tMat.col2.y); - cp.m_id.Set(cv.id); - cp.m_id.features.flip = flip; - ++pointCount; - } - } - manifold.m_pointCount = pointCount; - } - b2Collision.CollideCircles = function (manifold, circle1, xf1, circle2, xf2) { - manifold.m_pointCount = 0; - var tMat; - var tVec; - tMat = xf1.R; - tVec = circle1.m_p; - var p1X = xf1.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - var p1Y = xf1.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - tMat = xf2.R; - tVec = circle2.m_p; - var p2X = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - var p2Y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - var dX = p2X - p1X; - var dY = p2Y - p1Y; - var distSqr = dX * dX + dY * dY; - var radius = circle1.m_radius + circle2.m_radius; - if (distSqr > radius * radius) { - return; - } - manifold.m_type = b2Manifold.e_circles; - manifold.m_localPoint.SetV(circle1.m_p); - manifold.m_localPlaneNormal.SetZero(); - manifold.m_pointCount = 1; - manifold.m_points[0].m_localPoint.SetV(circle2.m_p); - manifold.m_points[0].m_id.key = 0; - } - b2Collision.CollidePolygonAndCircle = function (manifold, polygon, xf1, circle, xf2) { - manifold.m_pointCount = 0; - var tPoint; - var dX = 0; - var dY = 0; - var positionX = 0; - var positionY = 0; - var tVec; - var tMat; - tMat = xf2.R; - tVec = circle.m_p; - var cX = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - var cY = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - dX = cX - xf1.position.x; - dY = cY - xf1.position.y; - tMat = xf1.R; - var cLocalX = (dX * tMat.col1.x + dY * tMat.col1.y); - var cLocalY = (dX * tMat.col2.x + dY * tMat.col2.y); - var dist = 0; - var normalIndex = 0; - var separation = (-Number.MAX_VALUE); - var radius = polygon.m_radius + circle.m_radius; - var vertexCount = parseInt(polygon.m_vertexCount); - var vertices = polygon.m_vertices; - var normals = polygon.m_normals; - for (var i = 0; i < vertexCount; ++i) { - tVec = vertices[i]; - dX = cLocalX - tVec.x; - dY = cLocalY - tVec.y; - tVec = normals[i]; - var s = tVec.x * dX + tVec.y * dY; - if (s > radius) { - return; - } - if (s > separation) { - separation = s; - normalIndex = i; - } - } - var vertIndex1 = parseInt(normalIndex); - var vertIndex2 = parseInt(vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0); - var v1 = vertices[vertIndex1]; - var v2 = vertices[vertIndex2]; - if (separation < Number.MIN_VALUE) { - manifold.m_pointCount = 1; - manifold.m_type = b2Manifold.e_faceA; - manifold.m_localPlaneNormal.SetV(normals[normalIndex]); - manifold.m_localPoint.x = 0.5 * (v1.x + v2.x); - manifold.m_localPoint.y = 0.5 * (v1.y + v2.y); - manifold.m_points[0].m_localPoint.SetV(circle.m_p); - manifold.m_points[0].m_id.key = 0; - return; - } - var u1 = (cLocalX - v1.x) * (v2.x - v1.x) + (cLocalY - v1.y) * (v2.y - v1.y); - var u2 = (cLocalX - v2.x) * (v1.x - v2.x) + (cLocalY - v2.y) * (v1.y - v2.y); - if (u1 <= 0.0) { - if ((cLocalX - v1.x) * (cLocalX - v1.x) + (cLocalY - v1.y) * (cLocalY - v1.y) > radius * radius) return; - manifold.m_pointCount = 1; - manifold.m_type = b2Manifold.e_faceA; - manifold.m_localPlaneNormal.x = cLocalX - v1.x; - manifold.m_localPlaneNormal.y = cLocalY - v1.y; - manifold.m_localPlaneNormal.Normalize(); - manifold.m_localPoint.SetV(v1); - manifold.m_points[0].m_localPoint.SetV(circle.m_p); - manifold.m_points[0].m_id.key = 0; - } - else if (u2 <= 0) { - if ((cLocalX - v2.x) * (cLocalX - v2.x) + (cLocalY - v2.y) * (cLocalY - v2.y) > radius * radius) return; - manifold.m_pointCount = 1; - manifold.m_type = b2Manifold.e_faceA; - manifold.m_localPlaneNormal.x = cLocalX - v2.x; - manifold.m_localPlaneNormal.y = cLocalY - v2.y; - manifold.m_localPlaneNormal.Normalize(); - manifold.m_localPoint.SetV(v2); - manifold.m_points[0].m_localPoint.SetV(circle.m_p); - manifold.m_points[0].m_id.key = 0; - } - else { - var faceCenterX = 0.5 * (v1.x + v2.x); - var faceCenterY = 0.5 * (v1.y + v2.y); - separation = (cLocalX - faceCenterX) * normals[vertIndex1].x + (cLocalY - faceCenterY) * normals[vertIndex1].y; - if (separation > radius) return; - manifold.m_pointCount = 1; - manifold.m_type = b2Manifold.e_faceA; - manifold.m_localPlaneNormal.x = normals[vertIndex1].x; - manifold.m_localPlaneNormal.y = normals[vertIndex1].y; - manifold.m_localPlaneNormal.Normalize(); - manifold.m_localPoint.Set(faceCenterX, faceCenterY); - manifold.m_points[0].m_localPoint.SetV(circle.m_p); - manifold.m_points[0].m_id.key = 0; - } - } - b2Collision.TestOverlap = function (a, b) { - var t1 = b.lowerBound; - var t2 = a.upperBound; - var d1X = t1.x - t2.x; - var d1Y = t1.y - t2.y; - t1 = a.lowerBound; - t2 = b.upperBound; - var d2X = t1.x - t2.x; - var d2Y = t1.y - t2.y; - if (d1X > 0.0 || d1Y > 0.0) return false; - if (d2X > 0.0 || d2Y > 0.0) return false; - return true; - } - Box2D.postDefs.push(function () { - Box2D.Collision.b2Collision.s_incidentEdge = b2Collision.MakeClipPointVector(); - Box2D.Collision.b2Collision.s_clipPoints1 = b2Collision.MakeClipPointVector(); - Box2D.Collision.b2Collision.s_clipPoints2 = b2Collision.MakeClipPointVector(); - Box2D.Collision.b2Collision.s_edgeAO = new Vector_a2j_Number(1); - Box2D.Collision.b2Collision.s_edgeBO = new Vector_a2j_Number(1); - Box2D.Collision.b2Collision.s_localTangent = new b2Vec2(); - Box2D.Collision.b2Collision.s_localNormal = new b2Vec2(); - Box2D.Collision.b2Collision.s_planePoint = new b2Vec2(); - Box2D.Collision.b2Collision.s_normal = new b2Vec2(); - Box2D.Collision.b2Collision.s_tangent = new b2Vec2(); - Box2D.Collision.b2Collision.s_tangent2 = new b2Vec2(); - Box2D.Collision.b2Collision.s_v11 = new b2Vec2(); - Box2D.Collision.b2Collision.s_v12 = new b2Vec2(); - Box2D.Collision.b2Collision.b2CollidePolyTempVec = new b2Vec2(); - Box2D.Collision.b2Collision.b2_nullFeature = 0x000000ff; - }); - b2ContactID.b2ContactID = function () { - this.features = new Features(); - }; - b2ContactID.prototype.b2ContactID = function () { - this.features._m_id = this; - } - b2ContactID.prototype.Set = function (id) { - this.key = id._key; - } - b2ContactID.prototype.Copy = function () { - var id = new b2ContactID(); - id.key = this.key; - return id; - } - Object.defineProperty(b2ContactID.prototype, 'key', { - enumerable: false, - configurable: true, - get: function () { - return this._key; - } - }); - Object.defineProperty(b2ContactID.prototype, 'key', { - enumerable: false, - configurable: true, - set: function (value) { - if (value === undefined) value = 0; - this._key = value; - this.features._referenceEdge = this._key & 0x000000ff; - this.features._incidentEdge = ((this._key & 0x0000ff00) >> 8) & 0x000000ff; - this.features._incidentVertex = ((this._key & 0x00ff0000) >> 16) & 0x000000ff; - this.features._flip = ((this._key & 0xff000000) >> 24) & 0x000000ff; - } - }); - b2ContactPoint.b2ContactPoint = function () { - this.position = new b2Vec2(); - this.velocity = new b2Vec2(); - this.normal = new b2Vec2(); - this.id = new b2ContactID(); - }; - b2Distance.b2Distance = function () {}; - b2Distance.Distance = function (output, cache, input) { - ++b2Distance.b2_gjkCalls; - var proxyA = input.proxyA; - var proxyB = input.proxyB; - var transformA = input.transformA; - var transformB = input.transformB; - var simplex = b2Distance.s_simplex; - simplex.ReadCache(cache, proxyA, transformA, proxyB, transformB); - var vertices = simplex.m_vertices; - var k_maxIters = 20; - var saveA = b2Distance.s_saveA; - var saveB = b2Distance.s_saveB; - var saveCount = 0; - var closestPoint = simplex.GetClosestPoint(); - var distanceSqr1 = closestPoint.LengthSquared(); - var distanceSqr2 = distanceSqr1; - var i = 0; - var p; - var iter = 0; - while (iter < k_maxIters) { - saveCount = simplex.m_count; - for (i = 0; - i < saveCount; i++) { - saveA[i] = vertices[i].indexA; - saveB[i] = vertices[i].indexB; - } - switch (simplex.m_count) { - case 1: - break; - case 2: - simplex.Solve2(); - break; - case 3: - simplex.Solve3(); - break; - default: - b2Settings.b2Assert(false); - } - if (simplex.m_count == 3) { - break; - } - p = simplex.GetClosestPoint(); - distanceSqr2 = p.LengthSquared(); - if (distanceSqr2 > distanceSqr1) {} - distanceSqr1 = distanceSqr2; - var d = simplex.GetSearchDirection(); - if (d.LengthSquared() < Number.MIN_VALUE * Number.MIN_VALUE) { - break; - } - var vertex = vertices[simplex.m_count]; - vertex.indexA = proxyA.GetSupport(b2Math.MulTMV(transformA.R, d.GetNegative())); - vertex.wA = b2Math.MulX(transformA, proxyA.GetVertex(vertex.indexA)); - vertex.indexB = proxyB.GetSupport(b2Math.MulTMV(transformB.R, d)); - vertex.wB = b2Math.MulX(transformB, proxyB.GetVertex(vertex.indexB)); - vertex.w = b2Math.SubtractVV(vertex.wB, vertex.wA); - ++iter; - ++b2Distance.b2_gjkIters; - var duplicate = false; - for (i = 0; - i < saveCount; i++) { - if (vertex.indexA == saveA[i] && vertex.indexB == saveB[i]) { - duplicate = true; - break; - } - } - if (duplicate) { - break; - }++simplex.m_count; - } - b2Distance.b2_gjkMaxIters = b2Math.Max(b2Distance.b2_gjkMaxIters, iter); - simplex.GetWitnessPoints(output.pointA, output.pointB); - output.distance = b2Math.SubtractVV(output.pointA, output.pointB).Length(); - output.iterations = iter; - simplex.WriteCache(cache); - if (input.useRadii) { - var rA = proxyA.m_radius; - var rB = proxyB.m_radius; - if (output.distance > rA + rB && output.distance > Number.MIN_VALUE) { - output.distance -= rA + rB; - var normal = b2Math.SubtractVV(output.pointB, output.pointA); - normal.Normalize(); - output.pointA.x += rA * normal.x; - output.pointA.y += rA * normal.y; - output.pointB.x -= rB * normal.x; - output.pointB.y -= rB * normal.y; - } - else { - p = new b2Vec2(); - p.x = .5 * (output.pointA.x + output.pointB.x); - p.y = .5 * (output.pointA.y + output.pointB.y); - output.pointA.x = output.pointB.x = p.x; - output.pointA.y = output.pointB.y = p.y; - output.distance = 0.0; - } - } - } - Box2D.postDefs.push(function () { - Box2D.Collision.b2Distance.s_simplex = new b2Simplex(); - Box2D.Collision.b2Distance.s_saveA = new Vector_a2j_Number(3); - Box2D.Collision.b2Distance.s_saveB = new Vector_a2j_Number(3); - }); - b2DistanceInput.b2DistanceInput = function () {}; - b2DistanceOutput.b2DistanceOutput = function () { - this.pointA = new b2Vec2(); - this.pointB = new b2Vec2(); - }; - b2DistanceProxy.b2DistanceProxy = function () {}; - b2DistanceProxy.prototype.Set = function (shape) { - switch (shape.GetType()) { - case b2Shape.e_circleShape: - { - var circle = (shape instanceof b2CircleShape ? shape : null); - this.m_vertices = new Vector(1, true); - this.m_vertices[0] = circle.m_p; - this.m_count = 1; - this.m_radius = circle.m_radius; - } - break; - case b2Shape.e_polygonShape: - { - var polygon = (shape instanceof b2PolygonShape ? shape : null); - this.m_vertices = polygon.m_vertices; - this.m_count = polygon.m_vertexCount; - this.m_radius = polygon.m_radius; - } - break; - default: - b2Settings.b2Assert(false); - } - } - b2DistanceProxy.prototype.GetSupport = function (d) { - var bestIndex = 0; - var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y; - for (var i = 1; i < this.m_count; ++i) { - var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y; - if (value > bestValue) { - bestIndex = i; - bestValue = value; - } - } - return bestIndex; - } - b2DistanceProxy.prototype.GetSupportVertex = function (d) { - var bestIndex = 0; - var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y; - for (var i = 1; i < this.m_count; ++i) { - var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y; - if (value > bestValue) { - bestIndex = i; - bestValue = value; - } - } - return this.m_vertices[bestIndex]; - } - b2DistanceProxy.prototype.GetVertexCount = function () { - return this.m_count; - } - b2DistanceProxy.prototype.GetVertex = function (index) { - if (index === undefined) index = 0; - b2Settings.b2Assert(0 <= index && index < this.m_count); - return this.m_vertices[index]; - } - b2DynamicTree.b2DynamicTree = function () {}; - b2DynamicTree.prototype.b2DynamicTree = function () { - this.m_root = null; - this.m_freeList = null; - this.m_path = 0; - this.m_insertionCount = 0; - } - b2DynamicTree.prototype.CreateProxy = function (aabb, userData) { - var node = this.AllocateNode(); - var extendX = b2Settings.b2_aabbExtension; - var extendY = b2Settings.b2_aabbExtension; - node.aabb.lowerBound.x = aabb.lowerBound.x - extendX; - node.aabb.lowerBound.y = aabb.lowerBound.y - extendY; - node.aabb.upperBound.x = aabb.upperBound.x + extendX; - node.aabb.upperBound.y = aabb.upperBound.y + extendY; - node.userData = userData; - this.InsertLeaf(node); - return node; - } - b2DynamicTree.prototype.DestroyProxy = function (proxy) { - this.RemoveLeaf(proxy); - this.FreeNode(proxy); - } - b2DynamicTree.prototype.MoveProxy = function (proxy, aabb, displacement) { - b2Settings.b2Assert(proxy.IsLeaf()); - if (proxy.aabb.Contains(aabb)) { - return false; - } - this.RemoveLeaf(proxy); - var extendX = b2Settings.b2_aabbExtension + b2Settings.b2_aabbMultiplier * (displacement.x > 0 ? displacement.x : (-displacement.x)); - var extendY = b2Settings.b2_aabbExtension + b2Settings.b2_aabbMultiplier * (displacement.y > 0 ? displacement.y : (-displacement.y)); - proxy.aabb.lowerBound.x = aabb.lowerBound.x - extendX; - proxy.aabb.lowerBound.y = aabb.lowerBound.y - extendY; - proxy.aabb.upperBound.x = aabb.upperBound.x + extendX; - proxy.aabb.upperBound.y = aabb.upperBound.y + extendY; - this.InsertLeaf(proxy); - return true; - } - b2DynamicTree.prototype.Rebalance = function (iterations) { - if (iterations === undefined) iterations = 0; - if (this.m_root == null) return; - for (var i = 0; i < iterations; i++) { - var node = this.m_root; - var bit = 0; - while (node.IsLeaf() == false) { - node = (this.m_path >> bit) & 1 ? node.child2 : node.child1; - bit = (bit + 1) & 31; - }++this.m_path; - this.RemoveLeaf(node); - this.InsertLeaf(node); - } - } - b2DynamicTree.prototype.GetFatAABB = function (proxy) { - return proxy.aabb; - } - b2DynamicTree.prototype.GetUserData = function (proxy) { - return proxy.userData; - } - b2DynamicTree.prototype.Query = function (callback, aabb) { - if (this.m_root == null) return; - var stack = new Vector(); - var count = 0; - stack[count++] = this.m_root; - while (count > 0) { - var node = stack[--count]; - if (node.aabb.TestOverlap(aabb)) { - if (node.IsLeaf()) { - var proceed = callback(node); - if (!proceed) return; - } - else { - stack[count++] = node.child1; - stack[count++] = node.child2; - } - } - } - } - b2DynamicTree.prototype.RayCast = function (callback, input) { - if (this.m_root == null) return; - var p1 = input.p1; - var p2 = input.p2; - var r = b2Math.SubtractVV(p1, p2); - r.Normalize(); - var v = b2Math.CrossFV(1.0, r); - var abs_v = b2Math.AbsV(v); - var maxFraction = input.maxFraction; - var segmentAABB = new b2AABB(); - var tX = 0; - var tY = 0; { - tX = p1.x + maxFraction * (p2.x - p1.x); - tY = p1.y + maxFraction * (p2.y - p1.y); - segmentAABB.lowerBound.x = Math.min(p1.x, tX); - segmentAABB.lowerBound.y = Math.min(p1.y, tY); - segmentAABB.upperBound.x = Math.max(p1.x, tX); - segmentAABB.upperBound.y = Math.max(p1.y, tY); - } - var stack = new Vector(); - var count = 0; - stack[count++] = this.m_root; - while (count > 0) { - var node = stack[--count]; - if (node.aabb.TestOverlap(segmentAABB) == false) { - continue; - } - var c = node.aabb.GetCenter(); - var h = node.aabb.GetExtents(); - var separation = Math.abs(v.x * (p1.x - c.x) + v.y * (p1.y - c.y)) - abs_v.x * h.x - abs_v.y * h.y; - if (separation > 0.0) continue; - if (node.IsLeaf()) { - var subInput = new b2RayCastInput(); - subInput.p1 = input.p1; - subInput.p2 = input.p2; - subInput.maxFraction = input.maxFraction; - maxFraction = callback(subInput, node); - if (maxFraction == 0.0) return; - if (maxFraction > 0.0) { - tX = p1.x + maxFraction * (p2.x - p1.x); - tY = p1.y + maxFraction * (p2.y - p1.y); - segmentAABB.lowerBound.x = Math.min(p1.x, tX); - segmentAABB.lowerBound.y = Math.min(p1.y, tY); - segmentAABB.upperBound.x = Math.max(p1.x, tX); - segmentAABB.upperBound.y = Math.max(p1.y, tY); - } - } - else { - stack[count++] = node.child1; - stack[count++] = node.child2; - } - } - } - b2DynamicTree.prototype.AllocateNode = function () { - if (this.m_freeList) { - var node = this.m_freeList; - this.m_freeList = node.parent; - node.parent = null; - node.child1 = null; - node.child2 = null; - return node; - } - return new b2DynamicTreeNode(); - } - b2DynamicTree.prototype.FreeNode = function (node) { - node.parent = this.m_freeList; - this.m_freeList = node; - } - b2DynamicTree.prototype.InsertLeaf = function (leaf) { - ++this.m_insertionCount; - if (this.m_root == null) { - this.m_root = leaf; - this.m_root.parent = null; - return; - } - var center = leaf.aabb.GetCenter(); - var sibling = this.m_root; - if (sibling.IsLeaf() == false) { - do { - var child1 = sibling.child1; - var child2 = sibling.child2; - var norm1 = Math.abs((child1.aabb.lowerBound.x + child1.aabb.upperBound.x) / 2 - center.x) + Math.abs((child1.aabb.lowerBound.y + child1.aabb.upperBound.y) / 2 - center.y); - var norm2 = Math.abs((child2.aabb.lowerBound.x + child2.aabb.upperBound.x) / 2 - center.x) + Math.abs((child2.aabb.lowerBound.y + child2.aabb.upperBound.y) / 2 - center.y); - if (norm1 < norm2) { - sibling = child1; - } - else { - sibling = child2; - } - } - while (sibling.IsLeaf() == false) - } - var node1 = sibling.parent; - var node2 = this.AllocateNode(); - node2.parent = node1; - node2.userData = null; - node2.aabb.Combine(leaf.aabb, sibling.aabb); - if (node1) { - if (sibling.parent.child1 == sibling) { - node1.child1 = node2; - } - else { - node1.child2 = node2; - } - node2.child1 = sibling; - node2.child2 = leaf; - sibling.parent = node2; - leaf.parent = node2; - do { - if (node1.aabb.Contains(node2.aabb)) break; - node1.aabb.Combine(node1.child1.aabb, node1.child2.aabb); - node2 = node1; - node1 = node1.parent; - } - while (node1) - } - else { - node2.child1 = sibling; - node2.child2 = leaf; - sibling.parent = node2; - leaf.parent = node2; - this.m_root = node2; - } - } - b2DynamicTree.prototype.RemoveLeaf = function (leaf) { - if (leaf == this.m_root) { - this.m_root = null; - return; - } - var node2 = leaf.parent; - var node1 = node2.parent; - var sibling; - if (node2.child1 == leaf) { - sibling = node2.child2; - } - else { - sibling = node2.child1; - } - if (node1) { - if (node1.child1 == node2) { - node1.child1 = sibling; - } - else { - node1.child2 = sibling; - } - sibling.parent = node1; - this.FreeNode(node2); - while (node1) { - var oldAABB = node1.aabb; - node1.aabb = b2AABB.Combine(node1.child1.aabb, node1.child2.aabb); - if (oldAABB.Contains(node1.aabb)) break; - node1 = node1.parent; - } - } - else { - this.m_root = sibling; - sibling.parent = null; - this.FreeNode(node2); - } - } - b2DynamicTreeBroadPhase.b2DynamicTreeBroadPhase = function () { - this.m_tree = new b2DynamicTree(); - this.m_moveBuffer = new Vector(); - this.m_pairBuffer = new Vector(); - this.m_pairCount = 0; - }; - b2DynamicTreeBroadPhase.prototype.CreateProxy = function (aabb, userData) { - var proxy = this.m_tree.CreateProxy(aabb, userData); - ++this.m_proxyCount; - this.BufferMove(proxy); - return proxy; - } - b2DynamicTreeBroadPhase.prototype.DestroyProxy = function (proxy) { - this.UnBufferMove(proxy); - --this.m_proxyCount; - this.m_tree.DestroyProxy(proxy); - } - b2DynamicTreeBroadPhase.prototype.MoveProxy = function (proxy, aabb, displacement) { - var buffer = this.m_tree.MoveProxy(proxy, aabb, displacement); - if (buffer) { - this.BufferMove(proxy); - } - } - b2DynamicTreeBroadPhase.prototype.TestOverlap = function (proxyA, proxyB) { - var aabbA = this.m_tree.GetFatAABB(proxyA); - var aabbB = this.m_tree.GetFatAABB(proxyB); - return aabbA.TestOverlap(aabbB); - } - b2DynamicTreeBroadPhase.prototype.GetUserData = function (proxy) { - return this.m_tree.GetUserData(proxy); - } - b2DynamicTreeBroadPhase.prototype.GetFatAABB = function (proxy) { - return this.m_tree.GetFatAABB(proxy); - } - b2DynamicTreeBroadPhase.prototype.GetProxyCount = function () { - return this.m_proxyCount; - } - b2DynamicTreeBroadPhase.prototype.UpdatePairs = function (callback) { - var __this = this; - __this.m_pairCount = 0; - var i = 0, - queryProxy; - for (i = 0; - i < __this.m_moveBuffer.length; ++i) { - queryProxy = __this.m_moveBuffer[i]; - - function QueryCallback(proxy) { - if (proxy == queryProxy) return true; - if (__this.m_pairCount == __this.m_pairBuffer.length) { - __this.m_pairBuffer[__this.m_pairCount] = new b2DynamicTreePair(); - } - var pair = __this.m_pairBuffer[__this.m_pairCount]; - pair.proxyA = proxy < queryProxy ? proxy : queryProxy; - pair.proxyB = proxy >= queryProxy ? proxy : queryProxy;++__this.m_pairCount; - return true; - }; - var fatAABB = __this.m_tree.GetFatAABB(queryProxy); - __this.m_tree.Query(QueryCallback, fatAABB); - } - __this.m_moveBuffer.length = 0; - for (var i = 0; i < __this.m_pairCount;) { - var primaryPair = __this.m_pairBuffer[i]; - var userDataA = __this.m_tree.GetUserData(primaryPair.proxyA); - var userDataB = __this.m_tree.GetUserData(primaryPair.proxyB); - callback(userDataA, userDataB); - ++i; - while (i < __this.m_pairCount) { - var pair = __this.m_pairBuffer[i]; - if (pair.proxyA != primaryPair.proxyA || pair.proxyB != primaryPair.proxyB) { - break; - }++i; - } - } - } - b2DynamicTreeBroadPhase.prototype.Query = function (callback, aabb) { - this.m_tree.Query(callback, aabb); - } - b2DynamicTreeBroadPhase.prototype.RayCast = function (callback, input) { - this.m_tree.RayCast(callback, input); - } - b2DynamicTreeBroadPhase.prototype.Validate = function () {} - b2DynamicTreeBroadPhase.prototype.Rebalance = function (iterations) { - if (iterations === undefined) iterations = 0; - this.m_tree.Rebalance(iterations); - } - b2DynamicTreeBroadPhase.prototype.BufferMove = function (proxy) { - this.m_moveBuffer[this.m_moveBuffer.length] = proxy; - } - b2DynamicTreeBroadPhase.prototype.UnBufferMove = function (proxy) { - var i = parseInt(this.m_moveBuffer.indexOf(proxy)); - this.m_moveBuffer.splice(i, 1); - } - b2DynamicTreeBroadPhase.prototype.ComparePairs = function (pair1, pair2) { - return 0; - } - b2DynamicTreeBroadPhase.__implements = {}; - b2DynamicTreeBroadPhase.__implements[IBroadPhase] = true; - b2DynamicTreeNode.b2DynamicTreeNode = function () { - this.aabb = new b2AABB(); - }; - b2DynamicTreeNode.prototype.IsLeaf = function () { - return this.child1 == null; - } - b2DynamicTreePair.b2DynamicTreePair = function () {}; - b2Manifold.b2Manifold = function () { - this.m_pointCount = 0; - }; - b2Manifold.prototype.b2Manifold = function () { - this.m_points = new Vector(b2Settings.b2_maxManifoldPoints); - for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { - this.m_points[i] = new b2ManifoldPoint(); - } - this.m_localPlaneNormal = new b2Vec2(); - this.m_localPoint = new b2Vec2(); - } - b2Manifold.prototype.Reset = function () { - for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { - ((this.m_points[i] instanceof b2ManifoldPoint ? this.m_points[i] : null)).Reset(); - } - this.m_localPlaneNormal.SetZero(); - this.m_localPoint.SetZero(); - this.m_type = 0; - this.m_pointCount = 0; - } - b2Manifold.prototype.Set = function (m) { - this.m_pointCount = m.m_pointCount; - for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { - ((this.m_points[i] instanceof b2ManifoldPoint ? this.m_points[i] : null)).Set(m.m_points[i]); - } - this.m_localPlaneNormal.SetV(m.m_localPlaneNormal); - this.m_localPoint.SetV(m.m_localPoint); - this.m_type = m.m_type; - } - b2Manifold.prototype.Copy = function () { - var copy = new b2Manifold(); - copy.Set(this); - return copy; - } - Box2D.postDefs.push(function () { - Box2D.Collision.b2Manifold.e_circles = 0x0001; - Box2D.Collision.b2Manifold.e_faceA = 0x0002; - Box2D.Collision.b2Manifold.e_faceB = 0x0004; - }); - b2ManifoldPoint.b2ManifoldPoint = function () { - this.m_localPoint = new b2Vec2(); - this.m_id = new b2ContactID(); - }; - b2ManifoldPoint.prototype.b2ManifoldPoint = function () { - this.Reset(); - } - b2ManifoldPoint.prototype.Reset = function () { - this.m_localPoint.SetZero(); - this.m_normalImpulse = 0.0; - this.m_tangentImpulse = 0.0; - this.m_id.key = 0; - } - b2ManifoldPoint.prototype.Set = function (m) { - this.m_localPoint.SetV(m.m_localPoint); - this.m_normalImpulse = m.m_normalImpulse; - this.m_tangentImpulse = m.m_tangentImpulse; - this.m_id.Set(m.m_id); - } - b2Point.b2Point = function () { - this.p = new b2Vec2(); - }; - b2Point.prototype.Support = function (xf, vX, vY) { - if (vX === undefined) vX = 0; - if (vY === undefined) vY = 0; - return this.p; - } - b2Point.prototype.GetFirstVertex = function (xf) { - return this.p; - } - b2RayCastInput.b2RayCastInput = function () { - this.p1 = new b2Vec2(); - this.p2 = new b2Vec2(); - }; - b2RayCastInput.prototype.b2RayCastInput = function (p1, p2, maxFraction) { - if (p1 === undefined) p1 = null; - if (p2 === undefined) p2 = null; - if (maxFraction === undefined) maxFraction = 1; - if (p1) this.p1.SetV(p1); - if (p2) this.p2.SetV(p2); - this.maxFraction = maxFraction; - } - b2RayCastOutput.b2RayCastOutput = function () { - this.normal = new b2Vec2(); - }; - b2Segment.b2Segment = function () { - this.p1 = new b2Vec2(); - this.p2 = new b2Vec2(); - }; - b2Segment.prototype.TestSegment = function (lambda, normal, segment, maxLambda) { - if (maxLambda === undefined) maxLambda = 0; - var s = segment.p1; - var rX = segment.p2.x - s.x; - var rY = segment.p2.y - s.y; - var dX = this.p2.x - this.p1.x; - var dY = this.p2.y - this.p1.y; - var nX = dY; - var nY = (-dX); - var k_slop = 100.0 * Number.MIN_VALUE; - var denom = (-(rX * nX + rY * nY)); - if (denom > k_slop) { - var bX = s.x - this.p1.x; - var bY = s.y - this.p1.y; - var a = (bX * nX + bY * nY); - if (0.0 <= a && a <= maxLambda * denom) { - var mu2 = (-rX * bY) + rY * bX; - if ((-k_slop * denom) <= mu2 && mu2 <= denom * (1.0 + k_slop)) { - a /= denom; - var nLen = Math.sqrt(nX * nX + nY * nY); - nX /= nLen; - nY /= nLen; - lambda[0] = a; - normal.Set(nX, nY); - return true; - } - } - } - return false; - } - b2Segment.prototype.Extend = function (aabb) { - this.ExtendForward(aabb); - this.ExtendBackward(aabb); - } - - - - - b2Segment.prototype.ExtendForward = function (aabb) { - var dX = this.p2.x - this.p1.x; - var dY = this.p2.y - this.p1.y; - var lambda = Math.min(dX > 0 ? (aabb.upperBound.x - this.p1.x) / dX : dX < 0 ? (aabb.lowerBound.x - this.p1.x) / dX : Number.POSITIVE_INFINITY, - dY > 0 ? (aabb.upperBound.y - this.p1.y) / dY : dY < 0 ? (aabb.lowerBound.y - this.p1.y) / dY : Number.POSITIVE_INFINITY); - this.p2.x = this.p1.x + dX * lambda; - this.p2.y = this.p1.y + dY * lambda; - } - b2Segment.prototype.ExtendBackward = function (aabb) { - var dX = (-this.p2.x) + this.p1.x; - var dY = (-this.p2.y) + this.p1.y; - var lambda = Math.min(dX > 0 ? (aabb.upperBound.x - this.p2.x) / dX : dX < 0 ? (aabb.lowerBound.x - this.p2.x) / dX : Number.POSITIVE_INFINITY, - dY > 0 ? (aabb.upperBound.y - this.p2.y) / dY : dY < 0 ? (aabb.lowerBound.y - this.p2.y) / dY : Number.POSITIVE_INFINITY); - this.p1.x = this.p2.x + dX * lambda; - this.p1.y = this.p2.y + dY * lambda; - } - b2SeparationFunction.b2SeparationFunction = function () { - this.m_localPoint = new b2Vec2(); - this.m_axis = new b2Vec2(); - }; - b2SeparationFunction.prototype.Initialize = function (cache, proxyA, transformA, proxyB, transformB) { - this.m_proxyA = proxyA; - this.m_proxyB = proxyB; - var count = parseInt(cache.count); - b2Settings.b2Assert(0 < count && count < 3); - var localPointA; - var localPointA1; - var localPointA2; - var localPointB; - var localPointB1; - var localPointB2; - var pointAX = 0; - var pointAY = 0; - var pointBX = 0; - var pointBY = 0; - var normalX = 0; - var normalY = 0; - var tMat; - var tVec; - var s = 0; - var sgn = 0; - if (count == 1) { - this.m_type = b2SeparationFunction.e_points; - localPointA = this.m_proxyA.GetVertex(cache.indexA[0]); - localPointB = this.m_proxyB.GetVertex(cache.indexB[0]); - tVec = localPointA; - tMat = transformA.R; - pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - tVec = localPointB; - tMat = transformB.R; - pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - this.m_axis.x = pointBX - pointAX; - this.m_axis.y = pointBY - pointAY; - this.m_axis.Normalize(); - } - else if (cache.indexB[0] == cache.indexB[1]) { - this.m_type = b2SeparationFunction.e_faceA; - localPointA1 = this.m_proxyA.GetVertex(cache.indexA[0]); - localPointA2 = this.m_proxyA.GetVertex(cache.indexA[1]); - localPointB = this.m_proxyB.GetVertex(cache.indexB[0]); - this.m_localPoint.x = 0.5 * (localPointA1.x + localPointA2.x); - this.m_localPoint.y = 0.5 * (localPointA1.y + localPointA2.y); - this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointA2, localPointA1), 1.0); - this.m_axis.Normalize(); - tVec = this.m_axis; - tMat = transformA.R; - normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - tVec = this.m_localPoint; - tMat = transformA.R; - pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - tVec = localPointB; - tMat = transformB.R; - pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - s = (pointBX - pointAX) * normalX + (pointBY - pointAY) * normalY; - if (s < 0.0) { - this.m_axis.NegativeSelf(); - } - } - else if (cache.indexA[0] == cache.indexA[0]) { - this.m_type = b2SeparationFunction.e_faceB; - localPointB1 = this.m_proxyB.GetVertex(cache.indexB[0]); - localPointB2 = this.m_proxyB.GetVertex(cache.indexB[1]); - localPointA = this.m_proxyA.GetVertex(cache.indexA[0]); - this.m_localPoint.x = 0.5 * (localPointB1.x + localPointB2.x); - this.m_localPoint.y = 0.5 * (localPointB1.y + localPointB2.y); - this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointB2, localPointB1), 1.0); - this.m_axis.Normalize(); - tVec = this.m_axis; - tMat = transformB.R; - normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - tVec = this.m_localPoint; - tMat = transformB.R; - pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - tVec = localPointA; - tMat = transformA.R; - pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - s = (pointAX - pointBX) * normalX + (pointAY - pointBY) * normalY; - if (s < 0.0) { - this.m_axis.NegativeSelf(); - } - } - else { - localPointA1 = this.m_proxyA.GetVertex(cache.indexA[0]); - localPointA2 = this.m_proxyA.GetVertex(cache.indexA[1]); - localPointB1 = this.m_proxyB.GetVertex(cache.indexB[0]); - localPointB2 = this.m_proxyB.GetVertex(cache.indexB[1]); - var pA = b2Math.MulX(transformA, localPointA); - var dA = b2Math.MulMV(transformA.R, b2Math.SubtractVV(localPointA2, localPointA1)); - var pB = b2Math.MulX(transformB, localPointB); - var dB = b2Math.MulMV(transformB.R, b2Math.SubtractVV(localPointB2, localPointB1)); - var a = dA.x * dA.x + dA.y * dA.y; - var e = dB.x * dB.x + dB.y * dB.y; - var r = b2Math.SubtractVV(dB, dA); - var c = dA.x * r.x + dA.y * r.y; - var f = dB.x * r.x + dB.y * r.y; - var b = dA.x * dB.x + dA.y * dB.y; - var denom = a * e - b * b; - s = 0.0; - if (denom != 0.0) { - s = b2Math.Clamp((b * f - c * e) / denom, 0.0, 1.0); - } - var t = (b * s + f) / e; - if (t < 0.0) { - t = 0.0; - s = b2Math.Clamp((b - c) / a, 0.0, 1.0); - } - localPointA = new b2Vec2(); - localPointA.x = localPointA1.x + s * (localPointA2.x - localPointA1.x); - localPointA.y = localPointA1.y + s * (localPointA2.y - localPointA1.y); - localPointB = new b2Vec2(); - localPointB.x = localPointB1.x + s * (localPointB2.x - localPointB1.x); - localPointB.y = localPointB1.y + s * (localPointB2.y - localPointB1.y); - if (s == 0.0 || s == 1.0) { - this.m_type = b2SeparationFunction.e_faceB; - this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointB2, localPointB1), 1.0); - this.m_axis.Normalize(); - this.m_localPoint = localPointB; - tVec = this.m_axis; - tMat = transformB.R; - normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - tVec = this.m_localPoint; - tMat = transformB.R; - pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - tVec = localPointA; - tMat = transformA.R; - pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - sgn = (pointAX - pointBX) * normalX + (pointAY - pointBY) * normalY; - if (s < 0.0) { - this.m_axis.NegativeSelf(); - } - } - else { - this.m_type = b2SeparationFunction.e_faceA; - this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointA2, localPointA1), 1.0); - this.m_localPoint = localPointA; - tVec = this.m_axis; - tMat = transformA.R; - normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - tVec = this.m_localPoint; - tMat = transformA.R; - pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - tVec = localPointB; - tMat = transformB.R; - pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - sgn = (pointBX - pointAX) * normalX + (pointBY - pointAY) * normalY; - if (s < 0.0) { - this.m_axis.NegativeSelf(); - } - } - } - } - b2SeparationFunction.prototype.Evaluate = function (transformA, transformB) { - var axisA; - var axisB; - var localPointA; - var localPointB; - var pointA; - var pointB; - var seperation = 0; - var normal; - switch (this.m_type) { - case b2SeparationFunction.e_points: - { - axisA = b2Math.MulTMV(transformA.R, this.m_axis); - axisB = b2Math.MulTMV(transformB.R, this.m_axis.GetNegative()); - localPointA = this.m_proxyA.GetSupportVertex(axisA); - localPointB = this.m_proxyB.GetSupportVertex(axisB); - pointA = b2Math.MulX(transformA, localPointA); - pointB = b2Math.MulX(transformB, localPointB); - seperation = (pointB.x - pointA.x) * this.m_axis.x + (pointB.y - pointA.y) * this.m_axis.y; - return seperation; - } - case b2SeparationFunction.e_faceA: - { - normal = b2Math.MulMV(transformA.R, this.m_axis); - pointA = b2Math.MulX(transformA, this.m_localPoint); - axisB = b2Math.MulTMV(transformB.R, normal.GetNegative()); - localPointB = this.m_proxyB.GetSupportVertex(axisB); - pointB = b2Math.MulX(transformB, localPointB); - seperation = (pointB.x - pointA.x) * normal.x + (pointB.y - pointA.y) * normal.y; - return seperation; - } - case b2SeparationFunction.e_faceB: - { - normal = b2Math.MulMV(transformB.R, this.m_axis); - pointB = b2Math.MulX(transformB, this.m_localPoint); - axisA = b2Math.MulTMV(transformA.R, normal.GetNegative()); - localPointA = this.m_proxyA.GetSupportVertex(axisA); - pointA = b2Math.MulX(transformA, localPointA); - seperation = (pointA.x - pointB.x) * normal.x + (pointA.y - pointB.y) * normal.y; - return seperation; - } - default: - b2Settings.b2Assert(false); - return 0.0; - } - } - Box2D.postDefs.push(function () { - Box2D.Collision.b2SeparationFunction.e_points = 0x01; - Box2D.Collision.b2SeparationFunction.e_faceA = 0x02; - Box2D.Collision.b2SeparationFunction.e_faceB = 0x04; - }); - b2Simplex.b2Simplex = function () { - this.m_v1 = new b2SimplexVertex(); - this.m_v2 = new b2SimplexVertex(); - this.m_v3 = new b2SimplexVertex(); - this.m_vertices = new Vector(3); - }; - b2Simplex.prototype.b2Simplex = function () { - this.m_vertices[0] = this.m_v1; - this.m_vertices[1] = this.m_v2; - this.m_vertices[2] = this.m_v3; - } - b2Simplex.prototype.ReadCache = function (cache, proxyA, transformA, proxyB, transformB) { - b2Settings.b2Assert(0 <= cache.count && cache.count <= 3); - var wALocal; - var wBLocal; - this.m_count = cache.count; - var vertices = this.m_vertices; - for (var i = 0; i < this.m_count; i++) { - var v = vertices[i]; - v.indexA = cache.indexA[i]; - v.indexB = cache.indexB[i]; - wALocal = proxyA.GetVertex(v.indexA); - wBLocal = proxyB.GetVertex(v.indexB); - v.wA = b2Math.MulX(transformA, wALocal); - v.wB = b2Math.MulX(transformB, wBLocal); - v.w = b2Math.SubtractVV(v.wB, v.wA); - v.a = 0; - } - if (this.m_count > 1) { - var metric1 = cache.metric; - var metric2 = this.GetMetric(); - if (metric2 < .5 * metric1 || 2.0 * metric1 < metric2 || metric2 < Number.MIN_VALUE) { - this.m_count = 0; - } - } - if (this.m_count == 0) { - v = vertices[0]; - v.indexA = 0; - v.indexB = 0; - wALocal = proxyA.GetVertex(0); - wBLocal = proxyB.GetVertex(0); - v.wA = b2Math.MulX(transformA, wALocal); - v.wB = b2Math.MulX(transformB, wBLocal); - v.w = b2Math.SubtractVV(v.wB, v.wA); - this.m_count = 1; - } - } - b2Simplex.prototype.WriteCache = function (cache) { - cache.metric = this.GetMetric(); - cache.count = Box2D.parseUInt(this.m_count); - var vertices = this.m_vertices; - for (var i = 0; i < this.m_count; i++) { - cache.indexA[i] = Box2D.parseUInt(vertices[i].indexA); - cache.indexB[i] = Box2D.parseUInt(vertices[i].indexB); - } - } - b2Simplex.prototype.GetSearchDirection = function () { - switch (this.m_count) { - case 1: - return this.m_v1.w.GetNegative(); - case 2: - { - var e12 = b2Math.SubtractVV(this.m_v2.w, this.m_v1.w); - var sgn = b2Math.CrossVV(e12, this.m_v1.w.GetNegative()); - if (sgn > 0.0) { - return b2Math.CrossFV(1.0, e12); - } - else { - return b2Math.CrossVF(e12, 1.0); - } - } - default: - b2Settings.b2Assert(false); - return new b2Vec2(); - } - } - b2Simplex.prototype.GetClosestPoint = function () { - switch (this.m_count) { - case 0: - b2Settings.b2Assert(false); - return new b2Vec2(); - case 1: - return this.m_v1.w; - case 2: - return new b2Vec2(this.m_v1.a * this.m_v1.w.x + this.m_v2.a * this.m_v2.w.x, this.m_v1.a * this.m_v1.w.y + this.m_v2.a * this.m_v2.w.y); - default: - b2Settings.b2Assert(false); - return new b2Vec2(); - } - } - b2Simplex.prototype.GetWitnessPoints = function (pA, pB) { - switch (this.m_count) { - case 0: - b2Settings.b2Assert(false); - break; - case 1: - pA.SetV(this.m_v1.wA); - pB.SetV(this.m_v1.wB); - break; - case 2: - pA.x = this.m_v1.a * this.m_v1.wA.x + this.m_v2.a * this.m_v2.wA.x; - pA.y = this.m_v1.a * this.m_v1.wA.y + this.m_v2.a * this.m_v2.wA.y; - pB.x = this.m_v1.a * this.m_v1.wB.x + this.m_v2.a * this.m_v2.wB.x; - pB.y = this.m_v1.a * this.m_v1.wB.y + this.m_v2.a * this.m_v2.wB.y; - break; - case 3: - pB.x = pA.x = this.m_v1.a * this.m_v1.wA.x + this.m_v2.a * this.m_v2.wA.x + this.m_v3.a * this.m_v3.wA.x; - pB.y = pA.y = this.m_v1.a * this.m_v1.wA.y + this.m_v2.a * this.m_v2.wA.y + this.m_v3.a * this.m_v3.wA.y; - break; - default: - b2Settings.b2Assert(false); - break; - } - } - b2Simplex.prototype.GetMetric = function () { - switch (this.m_count) { - case 0: - b2Settings.b2Assert(false); - return 0.0; - case 1: - return 0.0; - case 2: - return b2Math.SubtractVV(this.m_v1.w, this.m_v2.w).Length(); - case 3: - return b2Math.CrossVV(b2Math.SubtractVV(this.m_v2.w, this.m_v1.w), b2Math.SubtractVV(this.m_v3.w, this.m_v1.w)); - default: - b2Settings.b2Assert(false); - return 0.0; - } - } - b2Simplex.prototype.Solve2 = function () { - var w1 = this.m_v1.w; - var w2 = this.m_v2.w; - var e12 = b2Math.SubtractVV(w2, w1); - var d12_2 = (-(w1.x * e12.x + w1.y * e12.y)); - if (d12_2 <= 0.0) { - this.m_v1.a = 1.0; - this.m_count = 1; - return; - } - var d12_1 = (w2.x * e12.x + w2.y * e12.y); - if (d12_1 <= 0.0) { - this.m_v2.a = 1.0; - this.m_count = 1; - this.m_v1.Set(this.m_v2); - return; - } - var inv_d12 = 1.0 / (d12_1 + d12_2); - this.m_v1.a = d12_1 * inv_d12; - this.m_v2.a = d12_2 * inv_d12; - this.m_count = 2; - } - b2Simplex.prototype.Solve3 = function () { - var w1 = this.m_v1.w; - var w2 = this.m_v2.w; - var w3 = this.m_v3.w; - var e12 = b2Math.SubtractVV(w2, w1); - var w1e12 = b2Math.Dot(w1, e12); - var w2e12 = b2Math.Dot(w2, e12); - var d12_1 = w2e12; - var d12_2 = (-w1e12); - var e13 = b2Math.SubtractVV(w3, w1); - var w1e13 = b2Math.Dot(w1, e13); - var w3e13 = b2Math.Dot(w3, e13); - var d13_1 = w3e13; - var d13_2 = (-w1e13); - var e23 = b2Math.SubtractVV(w3, w2); - var w2e23 = b2Math.Dot(w2, e23); - var w3e23 = b2Math.Dot(w3, e23); - var d23_1 = w3e23; - var d23_2 = (-w2e23); - var n123 = b2Math.CrossVV(e12, e13); - var d123_1 = n123 * b2Math.CrossVV(w2, w3); - var d123_2 = n123 * b2Math.CrossVV(w3, w1); - var d123_3 = n123 * b2Math.CrossVV(w1, w2); - if (d12_2 <= 0.0 && d13_2 <= 0.0) { - this.m_v1.a = 1.0; - this.m_count = 1; - return; - } - if (d12_1 > 0.0 && d12_2 > 0.0 && d123_3 <= 0.0) { - var inv_d12 = 1.0 / (d12_1 + d12_2); - this.m_v1.a = d12_1 * inv_d12; - this.m_v2.a = d12_2 * inv_d12; - this.m_count = 2; - return; - } - if (d13_1 > 0.0 && d13_2 > 0.0 && d123_2 <= 0.0) { - var inv_d13 = 1.0 / (d13_1 + d13_2); - this.m_v1.a = d13_1 * inv_d13; - this.m_v3.a = d13_2 * inv_d13; - this.m_count = 2; - this.m_v2.Set(this.m_v3); - return; - } - if (d12_1 <= 0.0 && d23_2 <= 0.0) { - this.m_v2.a = 1.0; - this.m_count = 1; - this.m_v1.Set(this.m_v2); - return; - } - if (d13_1 <= 0.0 && d23_1 <= 0.0) { - this.m_v3.a = 1.0; - this.m_count = 1; - this.m_v1.Set(this.m_v3); - return; - } - if (d23_1 > 0.0 && d23_2 > 0.0 && d123_1 <= 0.0) { - var inv_d23 = 1.0 / (d23_1 + d23_2); - this.m_v2.a = d23_1 * inv_d23; - this.m_v3.a = d23_2 * inv_d23; - this.m_count = 2; - this.m_v1.Set(this.m_v3); - return; - } - var inv_d123 = 1.0 / (d123_1 + d123_2 + d123_3); - this.m_v1.a = d123_1 * inv_d123; - this.m_v2.a = d123_2 * inv_d123; - this.m_v3.a = d123_3 * inv_d123; - this.m_count = 3; - } - b2SimplexCache.b2SimplexCache = function () { - this.indexA = new Vector_a2j_Number(3); - this.indexB = new Vector_a2j_Number(3); - }; - b2SimplexVertex.b2SimplexVertex = function () {}; - b2SimplexVertex.prototype.Set = function (other) { - this.wA.SetV(other.wA); - this.wB.SetV(other.wB); - this.w.SetV(other.w); - this.a = other.a; - this.indexA = other.indexA; - this.indexB = other.indexB; - } - b2TimeOfImpact.b2TimeOfImpact = function () {}; - b2TimeOfImpact.TimeOfImpact = function (input) { - ++b2TimeOfImpact.b2_toiCalls; - var proxyA = input.proxyA; - var proxyB = input.proxyB; - var sweepA = input.sweepA; - var sweepB = input.sweepB; - b2Settings.b2Assert(sweepA.t0 == sweepB.t0); - b2Settings.b2Assert(1.0 - sweepA.t0 > Number.MIN_VALUE); - var radius = proxyA.m_radius + proxyB.m_radius; - var tolerance = input.tolerance; - var alpha = 0.0; - var k_maxIterations = 1000; - var iter = 0; - var target = 0.0; - b2TimeOfImpact.s_cache.count = 0; - b2TimeOfImpact.s_distanceInput.useRadii = false; - for (;;) { - sweepA.GetTransform(b2TimeOfImpact.s_xfA, alpha); - sweepB.GetTransform(b2TimeOfImpact.s_xfB, alpha); - b2TimeOfImpact.s_distanceInput.proxyA = proxyA; - b2TimeOfImpact.s_distanceInput.proxyB = proxyB; - b2TimeOfImpact.s_distanceInput.transformA = b2TimeOfImpact.s_xfA; - b2TimeOfImpact.s_distanceInput.transformB = b2TimeOfImpact.s_xfB; - b2Distance.Distance(b2TimeOfImpact.s_distanceOutput, b2TimeOfImpact.s_cache, b2TimeOfImpact.s_distanceInput); - if (b2TimeOfImpact.s_distanceOutput.distance <= 0.0) { - alpha = 1.0; - break; - } - b2TimeOfImpact.s_fcn.Initialize(b2TimeOfImpact.s_cache, proxyA, b2TimeOfImpact.s_xfA, proxyB, b2TimeOfImpact.s_xfB); - var separation = b2TimeOfImpact.s_fcn.Evaluate(b2TimeOfImpact.s_xfA, b2TimeOfImpact.s_xfB); - if (separation <= 0.0) { - alpha = 1.0; - break; - } - if (iter == 0) { - if (separation > radius) { - target = b2Math.Max(radius - tolerance, 0.75 * radius); - } - else { - target = b2Math.Max(separation - tolerance, 0.02 * radius); - } - } - if (separation - target < 0.5 * tolerance) { - if (iter == 0) { - alpha = 1.0; - break; - } - break; - } - var newAlpha = alpha; { - var x1 = alpha; - var x2 = 1.0; - var f1 = separation; - sweepA.GetTransform(b2TimeOfImpact.s_xfA, x2); - sweepB.GetTransform(b2TimeOfImpact.s_xfB, x2); - var f2 = b2TimeOfImpact.s_fcn.Evaluate(b2TimeOfImpact.s_xfA, b2TimeOfImpact.s_xfB); - if (f2 >= target) { - alpha = 1.0; - break; - } - var rootIterCount = 0; - for (;;) { - var x = 0; - if (rootIterCount & 1) { - x = x1 + (target - f1) * (x2 - x1) / (f2 - f1); - } - else { - x = 0.5 * (x1 + x2); - } - sweepA.GetTransform(b2TimeOfImpact.s_xfA, x); - sweepB.GetTransform(b2TimeOfImpact.s_xfB, x); - var f = b2TimeOfImpact.s_fcn.Evaluate(b2TimeOfImpact.s_xfA, b2TimeOfImpact.s_xfB); - if (b2Math.Abs(f - target) < 0.025 * tolerance) { - newAlpha = x; - break; - } - if (f > target) { - x1 = x; - f1 = f; - } - else { - x2 = x; - f2 = f; - }++rootIterCount; - ++b2TimeOfImpact.b2_toiRootIters; - if (rootIterCount == 50) { - break; - } - } - b2TimeOfImpact.b2_toiMaxRootIters = b2Math.Max(b2TimeOfImpact.b2_toiMaxRootIters, rootIterCount); - } - if (newAlpha < (1.0 + 100.0 * Number.MIN_VALUE) * alpha) { - break; - } - alpha = newAlpha; - iter++; - ++b2TimeOfImpact.b2_toiIters; - if (iter == k_maxIterations) { - break; - } - } - b2TimeOfImpact.b2_toiMaxIters = b2Math.Max(b2TimeOfImpact.b2_toiMaxIters, iter); - return alpha; - } - Box2D.postDefs.push(function () { - Box2D.Collision.b2TimeOfImpact.b2_toiCalls = 0; - Box2D.Collision.b2TimeOfImpact.b2_toiIters = 0; - Box2D.Collision.b2TimeOfImpact.b2_toiMaxIters = 0; - Box2D.Collision.b2TimeOfImpact.b2_toiRootIters = 0; - Box2D.Collision.b2TimeOfImpact.b2_toiMaxRootIters = 0; - Box2D.Collision.b2TimeOfImpact.s_cache = new b2SimplexCache(); - Box2D.Collision.b2TimeOfImpact.s_distanceInput = new b2DistanceInput(); - Box2D.Collision.b2TimeOfImpact.s_xfA = new b2Transform(); - Box2D.Collision.b2TimeOfImpact.s_xfB = new b2Transform(); - Box2D.Collision.b2TimeOfImpact.s_fcn = new b2SeparationFunction(); - Box2D.Collision.b2TimeOfImpact.s_distanceOutput = new b2DistanceOutput(); - }); - b2TOIInput.b2TOIInput = function () { - this.proxyA = new b2DistanceProxy(); - this.proxyB = new b2DistanceProxy(); - this.sweepA = new b2Sweep(); - this.sweepB = new b2Sweep(); - }; - b2WorldManifold.b2WorldManifold = function () { - this.m_normal = new b2Vec2(); - }; - b2WorldManifold.prototype.b2WorldManifold = function () { - this.m_points = new Vector(b2Settings.b2_maxManifoldPoints); - for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { - this.m_points[i] = new b2Vec2(); - } - } - b2WorldManifold.prototype.Initialize = function (manifold, xfA, radiusA, xfB, radiusB) { - if (radiusA === undefined) radiusA = 0; - if (radiusB === undefined) radiusB = 0; - if (manifold.m_pointCount == 0) { - return; - } - var i = 0; - var tVec; - var tMat; - var normalX = 0; - var normalY = 0; - var planePointX = 0; - var planePointY = 0; - var clipPointX = 0; - var clipPointY = 0; - switch (manifold.m_type) { - case b2Manifold.e_circles: - { - tMat = xfA.R; - tVec = manifold.m_localPoint; - var pointAX = xfA.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - var pointAY = xfA.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - tMat = xfB.R; - tVec = manifold.m_points[0].m_localPoint; - var pointBX = xfB.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - var pointBY = xfB.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - var dX = pointBX - pointAX; - var dY = pointBY - pointAY; - var d2 = dX * dX + dY * dY; - if (d2 > Number.MIN_VALUE * Number.MIN_VALUE) { - var d = Math.sqrt(d2); - this.m_normal.x = dX / d; - this.m_normal.y = dY / d; - } - else { - this.m_normal.x = 1; - this.m_normal.y = 0; - } - var cAX = pointAX + radiusA * this.m_normal.x; - var cAY = pointAY + radiusA * this.m_normal.y; - var cBX = pointBX - radiusB * this.m_normal.x; - var cBY = pointBY - radiusB * this.m_normal.y; - this.m_points[0].x = 0.5 * (cAX + cBX); - this.m_points[0].y = 0.5 * (cAY + cBY); - } - break; - case b2Manifold.e_faceA: - { - tMat = xfA.R; - tVec = manifold.m_localPlaneNormal; - normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - tMat = xfA.R; - tVec = manifold.m_localPoint; - planePointX = xfA.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - planePointY = xfA.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - this.m_normal.x = normalX; - this.m_normal.y = normalY; - for (i = 0; - i < manifold.m_pointCount; i++) { - tMat = xfB.R; - tVec = manifold.m_points[i].m_localPoint; - clipPointX = xfB.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - clipPointY = xfB.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - this.m_points[i].x = clipPointX + 0.5 * (radiusA - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusB) * normalX; - this.m_points[i].y = clipPointY + 0.5 * (radiusA - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusB) * normalY; - } - } - break; - case b2Manifold.e_faceB: - { - tMat = xfB.R; - tVec = manifold.m_localPlaneNormal; - normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - tMat = xfB.R; - tVec = manifold.m_localPoint; - planePointX = xfB.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - planePointY = xfB.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - this.m_normal.x = (-normalX); - this.m_normal.y = (-normalY); - for (i = 0; - i < manifold.m_pointCount; i++) { - tMat = xfA.R; - tVec = manifold.m_points[i].m_localPoint; - clipPointX = xfA.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - clipPointY = xfA.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - this.m_points[i].x = clipPointX + 0.5 * (radiusB - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusA) * normalX; - this.m_points[i].y = clipPointY + 0.5 * (radiusB - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusA) * normalY; - } - } - break; - } - } - ClipVertex.ClipVertex = function () { - this.v = new b2Vec2(); - this.id = new b2ContactID(); - }; - ClipVertex.prototype.Set = function (other) { - this.v.SetV(other.v); - this.id.Set(other.id); - } - Features.Features = function () {}; - Object.defineProperty(Features.prototype, 'referenceEdge', { - enumerable: false, - configurable: true, - get: function () { - return this._referenceEdge; - } - }); - Object.defineProperty(Features.prototype, 'referenceEdge', { - enumerable: false, - configurable: true, - set: function (value) { - if (value === undefined) value = 0; - this._referenceEdge = value; - this._m_id._key = (this._m_id._key & 0xffffff00) | (this._referenceEdge & 0x000000ff); - } - }); - Object.defineProperty(Features.prototype, 'incidentEdge', { - enumerable: false, - configurable: true, - get: function () { - return this._incidentEdge; - } - }); - Object.defineProperty(Features.prototype, 'incidentEdge', { - enumerable: false, - configurable: true, - set: function (value) { - if (value === undefined) value = 0; - this._incidentEdge = value; - this._m_id._key = (this._m_id._key & 0xffff00ff) | ((this._incidentEdge << 8) & 0x0000ff00); - } - }); - Object.defineProperty(Features.prototype, 'incidentVertex', { - enumerable: false, - configurable: true, - get: function () { - return this._incidentVertex; - } - }); - Object.defineProperty(Features.prototype, 'incidentVertex', { - enumerable: false, - configurable: true, - set: function (value) { - if (value === undefined) value = 0; - this._incidentVertex = value; - this._m_id._key = (this._m_id._key & 0xff00ffff) | ((this._incidentVertex << 16) & 0x00ff0000); - } - }); - Object.defineProperty(Features.prototype, 'flip', { - enumerable: false, - configurable: true, - get: function () { - return this._flip; - } - }); - Object.defineProperty(Features.prototype, 'flip', { - enumerable: false, - configurable: true, - set: function (value) { - if (value === undefined) value = 0; - this._flip = value; - this._m_id._key = (this._m_id._key & 0x00ffffff) | ((this._flip << 24) & 0xff000000); - } - }); -})(); -(function () { - var b2Color = Box2D.Common.b2Color, - b2internal = Box2D.Common.b2internal, - b2Settings = Box2D.Common.b2Settings, - b2CircleShape = Box2D.Collision.Shapes.b2CircleShape, - b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef, - b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape, - b2MassData = Box2D.Collision.Shapes.b2MassData, - b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape, - b2Shape = Box2D.Collision.Shapes.b2Shape, - b2Mat22 = Box2D.Common.Math.b2Mat22, - b2Mat33 = Box2D.Common.Math.b2Mat33, - b2Math = Box2D.Common.Math.b2Math, - b2Sweep = Box2D.Common.Math.b2Sweep, - b2Transform = Box2D.Common.Math.b2Transform, - b2Vec2 = Box2D.Common.Math.b2Vec2, - b2Vec3 = Box2D.Common.Math.b2Vec3, - b2Body = Box2D.Dynamics.b2Body, - b2BodyDef = Box2D.Dynamics.b2BodyDef, - b2ContactFilter = Box2D.Dynamics.b2ContactFilter, - b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse, - b2ContactListener = Box2D.Dynamics.b2ContactListener, - b2ContactManager = Box2D.Dynamics.b2ContactManager, - b2DebugDraw = Box2D.Dynamics.b2DebugDraw, - b2DestructionListener = Box2D.Dynamics.b2DestructionListener, - b2FilterData = Box2D.Dynamics.b2FilterData, - b2Fixture = Box2D.Dynamics.b2Fixture, - b2FixtureDef = Box2D.Dynamics.b2FixtureDef, - b2Island = Box2D.Dynamics.b2Island, - b2TimeStep = Box2D.Dynamics.b2TimeStep, - b2World = Box2D.Dynamics.b2World, - b2AABB = Box2D.Collision.b2AABB, - b2Bound = Box2D.Collision.b2Bound, - b2BoundValues = Box2D.Collision.b2BoundValues, - b2Collision = Box2D.Collision.b2Collision, - b2ContactID = Box2D.Collision.b2ContactID, - b2ContactPoint = Box2D.Collision.b2ContactPoint, - b2Distance = Box2D.Collision.b2Distance, - b2DistanceInput = Box2D.Collision.b2DistanceInput, - b2DistanceOutput = Box2D.Collision.b2DistanceOutput, - b2DistanceProxy = Box2D.Collision.b2DistanceProxy, - b2DynamicTree = Box2D.Collision.b2DynamicTree, - b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase, - b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode, - b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair, - b2Manifold = Box2D.Collision.b2Manifold, - b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint, - b2Point = Box2D.Collision.b2Point, - b2RayCastInput = Box2D.Collision.b2RayCastInput, - b2RayCastOutput = Box2D.Collision.b2RayCastOutput, - b2Segment = Box2D.Collision.b2Segment, - b2SeparationFunction = Box2D.Collision.b2SeparationFunction, - b2Simplex = Box2D.Collision.b2Simplex, - b2SimplexCache = Box2D.Collision.b2SimplexCache, - b2SimplexVertex = Box2D.Collision.b2SimplexVertex, - b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact, - b2TOIInput = Box2D.Collision.b2TOIInput, - b2WorldManifold = Box2D.Collision.b2WorldManifold, - ClipVertex = Box2D.Collision.ClipVertex, - Features = Box2D.Collision.Features, - IBroadPhase = Box2D.Collision.IBroadPhase; - - Box2D.inherit(b2CircleShape, Box2D.Collision.Shapes.b2Shape); - b2CircleShape.prototype.__super = Box2D.Collision.Shapes.b2Shape.prototype; - b2CircleShape.b2CircleShape = function () { - Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this, arguments); - this.m_p = new b2Vec2(); - }; - b2CircleShape.prototype.Copy = function () { - var s = new b2CircleShape(); - s.Set(this); - return s; - } - b2CircleShape.prototype.Set = function (other) { - this.__super.Set.call(this, other); - if (Box2D.is(other, b2CircleShape)) { - var other2 = (other instanceof b2CircleShape ? other : null); - this.m_p.SetV(other2.m_p); - } - } - b2CircleShape.prototype.TestPoint = function (transform, p) { - var tMat = transform.R; - var dX = transform.position.x + (tMat.col1.x * this.m_p.x + tMat.col2.x * this.m_p.y); - var dY = transform.position.y + (tMat.col1.y * this.m_p.x + tMat.col2.y * this.m_p.y); - dX = p.x - dX; - dY = p.y - dY; - return (dX * dX + dY * dY) <= this.m_radius * this.m_radius; - } - b2CircleShape.prototype.RayCast = function (output, input, transform) { - var tMat = transform.R; - var positionX = transform.position.x + (tMat.col1.x * this.m_p.x + tMat.col2.x * this.m_p.y); - var positionY = transform.position.y + (tMat.col1.y * this.m_p.x + tMat.col2.y * this.m_p.y); - var sX = input.p1.x - positionX; - var sY = input.p1.y - positionY; - var b = (sX * sX + sY * sY) - this.m_radius * this.m_radius; - var rX = input.p2.x - input.p1.x; - var rY = input.p2.y - input.p1.y; - var c = (sX * rX + sY * rY); - var rr = (rX * rX + rY * rY); - var sigma = c * c - rr * b; - if (sigma < 0.0 || rr < Number.MIN_VALUE) { - return false; - } - var a = (-(c + Math.sqrt(sigma))); - if (0.0 <= a && a <= input.maxFraction * rr) { - a /= rr; - output.fraction = a; - output.normal.x = sX + a * rX; - output.normal.y = sY + a * rY; - output.normal.Normalize(); - return true; - } - return false; - } - b2CircleShape.prototype.ComputeAABB = function (aabb, transform) { - var tMat = transform.R; - var pX = transform.position.x + (tMat.col1.x * this.m_p.x + tMat.col2.x * this.m_p.y); - var pY = transform.position.y + (tMat.col1.y * this.m_p.x + tMat.col2.y * this.m_p.y); - aabb.lowerBound.Set(pX - this.m_radius, pY - this.m_radius); - aabb.upperBound.Set(pX + this.m_radius, pY + this.m_radius); - } - b2CircleShape.prototype.ComputeMass = function (massData, density) { - if (density === undefined) density = 0; - massData.mass = density * b2Settings.b2_pi * this.m_radius * this.m_radius; - massData.center.SetV(this.m_p); - massData.I = massData.mass * (0.5 * this.m_radius * this.m_radius + (this.m_p.x * this.m_p.x + this.m_p.y * this.m_p.y)); - } - b2CircleShape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) { - if (offset === undefined) offset = 0; - var p = b2Math.MulX(xf, this.m_p); - var l = (-(b2Math.Dot(normal, p) - offset)); - if (l < (-this.m_radius) + Number.MIN_VALUE) { - return 0; - } - if (l > this.m_radius) { - c.SetV(p); - return Math.PI * this.m_radius * this.m_radius; - } - var r2 = this.m_radius * this.m_radius; - var l2 = l * l; - var area = r2 * (Math.asin(l / this.m_radius) + Math.PI / 2) + l * Math.sqrt(r2 - l2); - var com = (-2 / 3 * Math.pow(r2 - l2, 1.5) / area); - c.x = p.x + normal.x * com; - c.y = p.y + normal.y * com; - return area; - } - b2CircleShape.prototype.GetLocalPosition = function () { - return this.m_p; - } - b2CircleShape.prototype.SetLocalPosition = function (position) { - this.m_p.SetV(position); - } - b2CircleShape.prototype.GetRadius = function () { - return this.m_radius; - } - b2CircleShape.prototype.SetRadius = function (radius) { - if (radius === undefined) radius = 0; - this.m_radius = radius; - } - b2CircleShape.prototype.b2CircleShape = function (radius) { - if (radius === undefined) radius = 0; - this.__super.b2Shape.call(this); - this.m_type = b2Shape.e_circleShape; - this.m_radius = radius; - } - b2EdgeChainDef.b2EdgeChainDef = function () {}; - b2EdgeChainDef.prototype.b2EdgeChainDef = function () { - this.vertexCount = 0; - this.isALoop = true; - this.vertices = []; - } - Box2D.inherit(b2EdgeShape, Box2D.Collision.Shapes.b2Shape); - b2EdgeShape.prototype.__super = Box2D.Collision.Shapes.b2Shape.prototype; - b2EdgeShape.b2EdgeShape = function () { - Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this, arguments); - this.s_supportVec = new b2Vec2(); - this.m_v1 = new b2Vec2(); - this.m_v2 = new b2Vec2(); - this.m_coreV1 = new b2Vec2(); - this.m_coreV2 = new b2Vec2(); - this.m_normal = new b2Vec2(); - this.m_direction = new b2Vec2(); - this.m_cornerDir1 = new b2Vec2(); - this.m_cornerDir2 = new b2Vec2(); - }; - b2EdgeShape.prototype.TestPoint = function (transform, p) { - return false; - } - b2EdgeShape.prototype.RayCast = function (output, input, transform) { - var tMat; - var rX = input.p2.x - input.p1.x; - var rY = input.p2.y - input.p1.y; - tMat = transform.R; - var v1X = transform.position.x + (tMat.col1.x * this.m_v1.x + tMat.col2.x * this.m_v1.y); - var v1Y = transform.position.y + (tMat.col1.y * this.m_v1.x + tMat.col2.y * this.m_v1.y); - var nX = transform.position.y + (tMat.col1.y * this.m_v2.x + tMat.col2.y * this.m_v2.y) - v1Y; - var nY = (-(transform.position.x + (tMat.col1.x * this.m_v2.x + tMat.col2.x * this.m_v2.y) - v1X)); - var k_slop = 100.0 * Number.MIN_VALUE; - var denom = (-(rX * nX + rY * nY)); - if (denom > k_slop) { - var bX = input.p1.x - v1X; - var bY = input.p1.y - v1Y; - var a = (bX * nX + bY * nY); - if (0.0 <= a && a <= input.maxFraction * denom) { - var mu2 = (-rX * bY) + rY * bX; - if ((-k_slop * denom) <= mu2 && mu2 <= denom * (1.0 + k_slop)) { - a /= denom; - output.fraction = a; - var nLen = Math.sqrt(nX * nX + nY * nY); - output.normal.x = nX / nLen; - output.normal.y = nY / nLen; - return true; - } - } - } - return false; - } - b2EdgeShape.prototype.ComputeAABB = function (aabb, transform) { - var tMat = transform.R; - var v1X = transform.position.x + (tMat.col1.x * this.m_v1.x + tMat.col2.x * this.m_v1.y); - var v1Y = transform.position.y + (tMat.col1.y * this.m_v1.x + tMat.col2.y * this.m_v1.y); - var v2X = transform.position.x + (tMat.col1.x * this.m_v2.x + tMat.col2.x * this.m_v2.y); - var v2Y = transform.position.y + (tMat.col1.y * this.m_v2.x + tMat.col2.y * this.m_v2.y); - if (v1X < v2X) { - aabb.lowerBound.x = v1X; - aabb.upperBound.x = v2X; - } - else { - aabb.lowerBound.x = v2X; - aabb.upperBound.x = v1X; - } - if (v1Y < v2Y) { - aabb.lowerBound.y = v1Y; - aabb.upperBound.y = v2Y; - } - else { - aabb.lowerBound.y = v2Y; - aabb.upperBound.y = v1Y; - } - } - b2EdgeShape.prototype.ComputeMass = function (massData, density) { - if (density === undefined) density = 0; - massData.mass = 0; - massData.center.SetV(this.m_v1); - massData.I = 0; - } - b2EdgeShape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) { - if (offset === undefined) offset = 0; - var v0 = new b2Vec2(normal.x * offset, normal.y * offset); - var v1 = b2Math.MulX(xf, this.m_v1); - var v2 = b2Math.MulX(xf, this.m_v2); - var d1 = b2Math.Dot(normal, v1) - offset; - var d2 = b2Math.Dot(normal, v2) - offset; - if (d1 > 0) { - if (d2 > 0) { - return 0; - } - else { - v1.x = (-d2 / (d1 - d2) * v1.x) + d1 / (d1 - d2) * v2.x; - v1.y = (-d2 / (d1 - d2) * v1.y) + d1 / (d1 - d2) * v2.y; - } - } - else { - if (d2 > 0) { - v2.x = (-d2 / (d1 - d2) * v1.x) + d1 / (d1 - d2) * v2.x; - v2.y = (-d2 / (d1 - d2) * v1.y) + d1 / (d1 - d2) * v2.y; - } - else {} - } - c.x = (v0.x + v1.x + v2.x) / 3; - c.y = (v0.y + v1.y + v2.y) / 3; - return 0.5 * ((v1.x - v0.x) * (v2.y - v0.y) - (v1.y - v0.y) * (v2.x - v0.x)); - } - b2EdgeShape.prototype.GetLength = function () { - return this.m_length; - } - b2EdgeShape.prototype.GetVertex1 = function () { - return this.m_v1; - } - b2EdgeShape.prototype.GetVertex2 = function () { - return this.m_v2; - } - b2EdgeShape.prototype.GetCoreVertex1 = function () { - return this.m_coreV1; - } - b2EdgeShape.prototype.GetCoreVertex2 = function () { - return this.m_coreV2; - } - b2EdgeShape.prototype.GetNormalVector = function () { - return this.m_normal; - } - b2EdgeShape.prototype.GetDirectionVector = function () { - return this.m_direction; - } - b2EdgeShape.prototype.GetCorner1Vector = function () { - return this.m_cornerDir1; - } - b2EdgeShape.prototype.GetCorner2Vector = function () { - return this.m_cornerDir2; - } - b2EdgeShape.prototype.Corner1IsConvex = function () { - return this.m_cornerConvex1; - } - b2EdgeShape.prototype.Corner2IsConvex = function () { - return this.m_cornerConvex2; - } - b2EdgeShape.prototype.GetFirstVertex = function (xf) { - var tMat = xf.R; - return new b2Vec2(xf.position.x + (tMat.col1.x * this.m_coreV1.x + tMat.col2.x * this.m_coreV1.y), xf.position.y + (tMat.col1.y * this.m_coreV1.x + tMat.col2.y * this.m_coreV1.y)); - } - b2EdgeShape.prototype.GetNextEdge = function () { - return this.m_nextEdge; - } - b2EdgeShape.prototype.GetPrevEdge = function () { - return this.m_prevEdge; - } - b2EdgeShape.prototype.Support = function (xf, dX, dY) { - if (dX === undefined) dX = 0; - if (dY === undefined) dY = 0; - var tMat = xf.R; - var v1X = xf.position.x + (tMat.col1.x * this.m_coreV1.x + tMat.col2.x * this.m_coreV1.y); - var v1Y = xf.position.y + (tMat.col1.y * this.m_coreV1.x + tMat.col2.y * this.m_coreV1.y); - var v2X = xf.position.x + (tMat.col1.x * this.m_coreV2.x + tMat.col2.x * this.m_coreV2.y); - var v2Y = xf.position.y + (tMat.col1.y * this.m_coreV2.x + tMat.col2.y * this.m_coreV2.y); - if ((v1X * dX + v1Y * dY) > (v2X * dX + v2Y * dY)) { - this.s_supportVec.x = v1X; - this.s_supportVec.y = v1Y; - } - else { - this.s_supportVec.x = v2X; - this.s_supportVec.y = v2Y; - } - return this.s_supportVec; - } - b2EdgeShape.prototype.b2EdgeShape = function (v1, v2) { - this.__super.b2Shape.call(this); - this.m_type = b2Shape.e_edgeShape; - this.m_prevEdge = null; - this.m_nextEdge = null; - this.m_v1 = v1; - this.m_v2 = v2; - this.m_direction.Set(this.m_v2.x - this.m_v1.x, this.m_v2.y - this.m_v1.y); - this.m_length = this.m_direction.Normalize(); - this.m_normal.Set(this.m_direction.y, (-this.m_direction.x)); - this.m_coreV1.Set((-b2Settings.b2_toiSlop * (this.m_normal.x - this.m_direction.x)) + this.m_v1.x, (-b2Settings.b2_toiSlop * (this.m_normal.y - this.m_direction.y)) + this.m_v1.y); - this.m_coreV2.Set((-b2Settings.b2_toiSlop * (this.m_normal.x + this.m_direction.x)) + this.m_v2.x, (-b2Settings.b2_toiSlop * (this.m_normal.y + this.m_direction.y)) + this.m_v2.y); - this.m_cornerDir1 = this.m_normal; - this.m_cornerDir2.Set((-this.m_normal.x), (-this.m_normal.y)); - } - b2EdgeShape.prototype.SetPrevEdge = function (edge, core, cornerDir, convex) { - this.m_prevEdge = edge; - this.m_coreV1 = core; - this.m_cornerDir1 = cornerDir; - this.m_cornerConvex1 = convex; - } - b2EdgeShape.prototype.SetNextEdge = function (edge, core, cornerDir, convex) { - this.m_nextEdge = edge; - this.m_coreV2 = core; - this.m_cornerDir2 = cornerDir; - this.m_cornerConvex2 = convex; - } - b2MassData.b2MassData = function () { - this.mass = 0.0; - this.center = new b2Vec2(0, 0); - this.I = 0.0; - }; - Box2D.inherit(b2PolygonShape, Box2D.Collision.Shapes.b2Shape); - b2PolygonShape.prototype.__super = Box2D.Collision.Shapes.b2Shape.prototype; - b2PolygonShape.b2PolygonShape = function () { - Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this, arguments); - }; - b2PolygonShape.prototype.Copy = function () { - var s = new b2PolygonShape(); - s.Set(this); - return s; - } - b2PolygonShape.prototype.Set = function (other) { - this.__super.Set.call(this, other); - if (Box2D.is(other, b2PolygonShape)) { - var other2 = (other instanceof b2PolygonShape ? other : null); - this.m_centroid.SetV(other2.m_centroid); - this.m_vertexCount = other2.m_vertexCount; - this.Reserve(this.m_vertexCount); - for (var i = 0; i < this.m_vertexCount; i++) { - this.m_vertices[i].SetV(other2.m_vertices[i]); - this.m_normals[i].SetV(other2.m_normals[i]); - } - } - } - b2PolygonShape.prototype.SetAsArray = function (vertices, vertexCount) { - if (vertexCount === undefined) vertexCount = 0; - var v = new Vector(); - var i = 0, - tVec; - for (i = 0; - i < vertices.length; ++i) { - tVec = vertices[i]; - v.push(tVec); - } - this.SetAsVector(v, vertexCount); - } - b2PolygonShape.AsArray = function (vertices, vertexCount) { - if (vertexCount === undefined) vertexCount = 0; - var polygonShape = new b2PolygonShape(); - polygonShape.SetAsArray(vertices, vertexCount); - return polygonShape; - } - b2PolygonShape.prototype.SetAsVector = function (vertices, vertexCount) { - if (vertexCount === undefined) vertexCount = 0; - if (vertexCount == 0) vertexCount = vertices.length; - b2Settings.b2Assert(2 <= vertexCount); - this.m_vertexCount = vertexCount; - this.Reserve(vertexCount); - var i = 0; - for (i = 0; - i < this.m_vertexCount; i++) { - this.m_vertices[i].SetV(vertices[i]); - } - for (i = 0; - i < this.m_vertexCount; ++i) { - var i1 = parseInt(i); - var i2 = parseInt(i + 1 < this.m_vertexCount ? i + 1 : 0); - var edge = b2Math.SubtractVV(this.m_vertices[i2], this.m_vertices[i1]); - b2Settings.b2Assert(edge.LengthSquared() > Number.MIN_VALUE); - this.m_normals[i].SetV(b2Math.CrossVF(edge, 1.0)); - this.m_normals[i].Normalize(); - } - this.m_centroid = b2PolygonShape.ComputeCentroid(this.m_vertices, this.m_vertexCount); - } - b2PolygonShape.AsVector = function (vertices, vertexCount) { - if (vertexCount === undefined) vertexCount = 0; - var polygonShape = new b2PolygonShape(); - polygonShape.SetAsVector(vertices, vertexCount); - return polygonShape; - } - b2PolygonShape.prototype.SetAsBox = function (hx, hy) { - if (hx === undefined) hx = 0; - if (hy === undefined) hy = 0; - this.m_vertexCount = 4; - this.Reserve(4); - this.m_vertices[0].Set((-hx), (-hy)); - this.m_vertices[1].Set(hx, (-hy)); - this.m_vertices[2].Set(hx, hy); - this.m_vertices[3].Set((-hx), hy); - this.m_normals[0].Set(0.0, (-1.0)); - this.m_normals[1].Set(1.0, 0.0); - this.m_normals[2].Set(0.0, 1.0); - this.m_normals[3].Set((-1.0), 0.0); - this.m_centroid.SetZero(); - } - b2PolygonShape.AsBox = function (hx, hy) { - if (hx === undefined) hx = 0; - if (hy === undefined) hy = 0; - var polygonShape = new b2PolygonShape(); - polygonShape.SetAsBox(hx, hy); - return polygonShape; - } - b2PolygonShape.prototype.SetAsOrientedBox = function (hx, hy, center, angle) { - if (hx === undefined) hx = 0; - if (hy === undefined) hy = 0; - if (center === undefined) center = null; - if (angle === undefined) angle = 0.0; - this.m_vertexCount = 4; - this.Reserve(4); - this.m_vertices[0].Set((-hx), (-hy)); - this.m_vertices[1].Set(hx, (-hy)); - this.m_vertices[2].Set(hx, hy); - this.m_vertices[3].Set((-hx), hy); - this.m_normals[0].Set(0.0, (-1.0)); - this.m_normals[1].Set(1.0, 0.0); - this.m_normals[2].Set(0.0, 1.0); - this.m_normals[3].Set((-1.0), 0.0); - this.m_centroid = center; - var xf = new b2Transform(); - xf.position = center; - xf.R.Set(angle); - for (var i = 0; i < this.m_vertexCount; ++i) { - this.m_vertices[i] = b2Math.MulX(xf, this.m_vertices[i]); - this.m_normals[i] = b2Math.MulMV(xf.R, this.m_normals[i]); - } - } - b2PolygonShape.AsOrientedBox = function (hx, hy, center, angle) { - if (hx === undefined) hx = 0; - if (hy === undefined) hy = 0; - if (center === undefined) center = null; - if (angle === undefined) angle = 0.0; - var polygonShape = new b2PolygonShape(); - polygonShape.SetAsOrientedBox(hx, hy, center, angle); - return polygonShape; - } - b2PolygonShape.prototype.SetAsEdge = function (v1, v2) { - this.m_vertexCount = 2; - this.Reserve(2); - this.m_vertices[0].SetV(v1); - this.m_vertices[1].SetV(v2); - this.m_centroid.x = 0.5 * (v1.x + v2.x); - this.m_centroid.y = 0.5 * (v1.y + v2.y); - this.m_normals[0] = b2Math.CrossVF(b2Math.SubtractVV(v2, v1), 1.0); - this.m_normals[0].Normalize(); - this.m_normals[1].x = (-this.m_normals[0].x); - this.m_normals[1].y = (-this.m_normals[0].y); - } - b2PolygonShape.AsEdge = function (v1, v2) { - var polygonShape = new b2PolygonShape(); - polygonShape.SetAsEdge(v1, v2); - return polygonShape; - } - b2PolygonShape.prototype.TestPoint = function (xf, p) { - var tVec; - var tMat = xf.R; - var tX = p.x - xf.position.x; - var tY = p.y - xf.position.y; - var pLocalX = (tX * tMat.col1.x + tY * tMat.col1.y); - var pLocalY = (tX * tMat.col2.x + tY * tMat.col2.y); - for (var i = 0; i < this.m_vertexCount; ++i) { - tVec = this.m_vertices[i]; - tX = pLocalX - tVec.x; - tY = pLocalY - tVec.y; - tVec = this.m_normals[i]; - var dot = (tVec.x * tX + tVec.y * tY); - if (dot > 0.0) { - return false; - } - } - return true; - } - b2PolygonShape.prototype.RayCast = function (output, input, transform) { - var lower = 0.0; - var upper = input.maxFraction; - var tX = 0; - var tY = 0; - var tMat; - var tVec; - tX = input.p1.x - transform.position.x; - tY = input.p1.y - transform.position.y; - tMat = transform.R; - var p1X = (tX * tMat.col1.x + tY * tMat.col1.y); - var p1Y = (tX * tMat.col2.x + tY * tMat.col2.y); - tX = input.p2.x - transform.position.x; - tY = input.p2.y - transform.position.y; - tMat = transform.R; - var p2X = (tX * tMat.col1.x + tY * tMat.col1.y); - var p2Y = (tX * tMat.col2.x + tY * tMat.col2.y); - var dX = p2X - p1X; - var dY = p2Y - p1Y; - var index = parseInt((-1)); - for (var i = 0; i < this.m_vertexCount; ++i) { - tVec = this.m_vertices[i]; - tX = tVec.x - p1X; - tY = tVec.y - p1Y; - tVec = this.m_normals[i]; - var numerator = (tVec.x * tX + tVec.y * tY); - var denominator = (tVec.x * dX + tVec.y * dY); - if (denominator == 0.0) { - if (numerator < 0.0) { - return false; - } - } - else { - if (denominator < 0.0 && numerator < lower * denominator) { - lower = numerator / denominator; - index = i; - } - else if (denominator > 0.0 && numerator < upper * denominator) { - upper = numerator / denominator; - } - } - if (upper < lower - Number.MIN_VALUE) { - return false; - } - } - if (index >= 0) { - output.fraction = lower; - tMat = transform.R; - tVec = this.m_normals[index]; - output.normal.x = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - output.normal.y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - return true; - } - return false; - } - b2PolygonShape.prototype.ComputeAABB = function (aabb, xf) { - var tMat = xf.R; - var tVec = this.m_vertices[0]; - var lowerX = xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - var lowerY = xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - var upperX = lowerX; - var upperY = lowerY; - for (var i = 1; i < this.m_vertexCount; ++i) { - tVec = this.m_vertices[i]; - var vX = xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - var vY = xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - lowerX = lowerX < vX ? lowerX : vX; - lowerY = lowerY < vY ? lowerY : vY; - upperX = upperX > vX ? upperX : vX; - upperY = upperY > vY ? upperY : vY; - } - aabb.lowerBound.x = lowerX - this.m_radius; - aabb.lowerBound.y = lowerY - this.m_radius; - aabb.upperBound.x = upperX + this.m_radius; - aabb.upperBound.y = upperY + this.m_radius; - } - b2PolygonShape.prototype.ComputeMass = function (massData, density) { - if (density === undefined) density = 0; - if (this.m_vertexCount == 2) { - massData.center.x = 0.5 * (this.m_vertices[0].x + this.m_vertices[1].x); - massData.center.y = 0.5 * (this.m_vertices[0].y + this.m_vertices[1].y); - massData.mass = 0.0; - massData.I = 0.0; - return; - } - var centerX = 0.0; - var centerY = 0.0; - var area = 0.0; - var I = 0.0; - var p1X = 0.0; - var p1Y = 0.0; - var k_inv3 = 1.0 / 3.0; - for (var i = 0; i < this.m_vertexCount; ++i) { - var p2 = this.m_vertices[i]; - var p3 = i + 1 < this.m_vertexCount ? this.m_vertices[parseInt(i + 1)] : this.m_vertices[0]; - var e1X = p2.x - p1X; - var e1Y = p2.y - p1Y; - var e2X = p3.x - p1X; - var e2Y = p3.y - p1Y; - var D = e1X * e2Y - e1Y * e2X; - var triangleArea = 0.5 * D;area += triangleArea; - centerX += triangleArea * k_inv3 * (p1X + p2.x + p3.x); - centerY += triangleArea * k_inv3 * (p1Y + p2.y + p3.y); - var px = p1X; - var py = p1Y; - var ex1 = e1X; - var ey1 = e1Y; - var ex2 = e2X; - var ey2 = e2Y; - var intx2 = k_inv3 * (0.25 * (ex1 * ex1 + ex2 * ex1 + ex2 * ex2) + (px * ex1 + px * ex2)) + 0.5 * px * px; - var inty2 = k_inv3 * (0.25 * (ey1 * ey1 + ey2 * ey1 + ey2 * ey2) + (py * ey1 + py * ey2)) + 0.5 * py * py;I += D * (intx2 + inty2); - } - massData.mass = density * area; - centerX *= 1.0 / area; - centerY *= 1.0 / area; - massData.center.Set(centerX, centerY); - massData.I = density * I; - } - b2PolygonShape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) { - if (offset === undefined) offset = 0; - var normalL = b2Math.MulTMV(xf.R, normal); - var offsetL = offset - b2Math.Dot(normal, xf.position); - var depths = new Vector_a2j_Number(); - var diveCount = 0; - var intoIndex = parseInt((-1)); - var outoIndex = parseInt((-1)); - var lastSubmerged = false; - var i = 0; - for (i = 0; - i < this.m_vertexCount; ++i) { - depths[i] = b2Math.Dot(normalL, this.m_vertices[i]) - offsetL; - var isSubmerged = depths[i] < (-Number.MIN_VALUE); - if (i > 0) { - if (isSubmerged) { - if (!lastSubmerged) { - intoIndex = i - 1; - diveCount++; - } - } - else { - if (lastSubmerged) { - outoIndex = i - 1; - diveCount++; - } - } - } - lastSubmerged = isSubmerged; - } - switch (diveCount) { - case 0: - if (lastSubmerged) { - var md = new b2MassData(); - this.ComputeMass(md, 1); - c.SetV(b2Math.MulX(xf, md.center)); - return md.mass; - } - else { - return 0; - } - break; - case 1: - if (intoIndex == (-1)) { - intoIndex = this.m_vertexCount - 1; - } - else { - outoIndex = this.m_vertexCount - 1; - } - break; - } - var intoIndex2 = parseInt((intoIndex + 1) % this.m_vertexCount); - var outoIndex2 = parseInt((outoIndex + 1) % this.m_vertexCount); - var intoLamdda = (0 - depths[intoIndex]) / (depths[intoIndex2] - depths[intoIndex]); - var outoLamdda = (0 - depths[outoIndex]) / (depths[outoIndex2] - depths[outoIndex]); - var intoVec = new b2Vec2(this.m_vertices[intoIndex].x * (1 - intoLamdda) + this.m_vertices[intoIndex2].x * intoLamdda, this.m_vertices[intoIndex].y * (1 - intoLamdda) + this.m_vertices[intoIndex2].y * intoLamdda); - var outoVec = new b2Vec2(this.m_vertices[outoIndex].x * (1 - outoLamdda) + this.m_vertices[outoIndex2].x * outoLamdda, this.m_vertices[outoIndex].y * (1 - outoLamdda) + this.m_vertices[outoIndex2].y * outoLamdda); - var area = 0; - var center = new b2Vec2(); - var p2 = this.m_vertices[intoIndex2]; - var p3; - i = intoIndex2; - while (i != outoIndex2) { - i = (i + 1) % this.m_vertexCount; - if (i == outoIndex2) p3 = outoVec; - else p3 = this.m_vertices[i]; - var triangleArea = 0.5 * ((p2.x - intoVec.x) * (p3.y - intoVec.y) - (p2.y - intoVec.y) * (p3.x - intoVec.x)); - area += triangleArea; - center.x += triangleArea * (intoVec.x + p2.x + p3.x) / 3; - center.y += triangleArea * (intoVec.y + p2.y + p3.y) / 3; - p2 = p3; - } - center.Multiply(1 / area); - c.SetV(b2Math.MulX(xf, center)); - return area; - } - b2PolygonShape.prototype.GetVertexCount = function () { - return this.m_vertexCount; - } - b2PolygonShape.prototype.GetVertices = function () { - return this.m_vertices; - } - b2PolygonShape.prototype.GetNormals = function () { - return this.m_normals; - } - b2PolygonShape.prototype.GetSupport = function (d) { - var bestIndex = 0; - var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y; - for (var i = 1; i < this.m_vertexCount; ++i) { - var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y; - if (value > bestValue) { - bestIndex = i; - bestValue = value; - } - } - return bestIndex; - } - b2PolygonShape.prototype.GetSupportVertex = function (d) { - var bestIndex = 0; - var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y; - for (var i = 1; i < this.m_vertexCount; ++i) { - var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y; - if (value > bestValue) { - bestIndex = i; - bestValue = value; - } - } - return this.m_vertices[bestIndex]; - } - b2PolygonShape.prototype.Validate = function () { - return false; - } - b2PolygonShape.prototype.b2PolygonShape = function () { - this.__super.b2Shape.call(this); - this.m_type = b2Shape.e_polygonShape; - this.m_centroid = new b2Vec2(); - this.m_vertices = new Vector(); - this.m_normals = new Vector(); - } - b2PolygonShape.prototype.Reserve = function (count) { - if (count === undefined) count = 0; - for (var i = parseInt(this.m_vertices.length); i < count; i++) { - this.m_vertices[i] = new b2Vec2(); - this.m_normals[i] = new b2Vec2(); - } - } - b2PolygonShape.ComputeCentroid = function (vs, count) { - if (count === undefined) count = 0; - var c = new b2Vec2(); - var area = 0.0; - var p1X = 0.0; - var p1Y = 0.0; - var inv3 = 1.0 / 3.0; - for (var i = 0; i < count; ++i) { - var p2 = vs[i]; - var p3 = i + 1 < count ? vs[parseInt(i + 1)] : vs[0]; - var e1X = p2.x - p1X; - var e1Y = p2.y - p1Y; - var e2X = p3.x - p1X; - var e2Y = p3.y - p1Y; - var D = (e1X * e2Y - e1Y * e2X); - var triangleArea = 0.5 * D;area += triangleArea; - c.x += triangleArea * inv3 * (p1X + p2.x + p3.x); - c.y += triangleArea * inv3 * (p1Y + p2.y + p3.y); - } - c.x *= 1.0 / area; - c.y *= 1.0 / area; - return c; - } - b2PolygonShape.ComputeOBB = function (obb, vs, count) { - if (count === undefined) count = 0; - var i = 0; - var p = new Vector(count + 1); - for (i = 0; - i < count; ++i) { - p[i] = vs[i]; - } - p[count] = p[0]; - var minArea = Number.MAX_VALUE; - for (i = 1; - i <= count; ++i) { - var root = p[parseInt(i - 1)]; - var uxX = p[i].x - root.x; - var uxY = p[i].y - root.y; - var length = Math.sqrt(uxX * uxX + uxY * uxY); - uxX /= length; - uxY /= length; - var uyX = (-uxY); - var uyY = uxX; - var lowerX = Number.MAX_VALUE; - var lowerY = Number.MAX_VALUE; - var upperX = (-Number.MAX_VALUE); - var upperY = (-Number.MAX_VALUE); - for (var j = 0; j < count; ++j) { - var dX = p[j].x - root.x; - var dY = p[j].y - root.y; - var rX = (uxX * dX + uxY * dY); - var rY = (uyX * dX + uyY * dY); - if (rX < lowerX) lowerX = rX; - if (rY < lowerY) lowerY = rY; - if (rX > upperX) upperX = rX; - if (rY > upperY) upperY = rY; - } - var area = (upperX - lowerX) * (upperY - lowerY); - if (area < 0.95 * minArea) { - minArea = area; - obb.R.col1.x = uxX; - obb.R.col1.y = uxY; - obb.R.col2.x = uyX; - obb.R.col2.y = uyY; - var centerX = 0.5 * (lowerX + upperX); - var centerY = 0.5 * (lowerY + upperY); - var tMat = obb.R; - obb.center.x = root.x + (tMat.col1.x * centerX + tMat.col2.x * centerY); - obb.center.y = root.y + (tMat.col1.y * centerX + tMat.col2.y * centerY); - obb.extents.x = 0.5 * (upperX - lowerX); - obb.extents.y = 0.5 * (upperY - lowerY); - } - } - } - Box2D.postDefs.push(function () { - Box2D.Collision.Shapes.b2PolygonShape.s_mat = new b2Mat22(); - }); - b2Shape.b2Shape = function () {}; - b2Shape.prototype.Copy = function () { - return null; - } - b2Shape.prototype.Set = function (other) { - this.m_radius = other.m_radius; - } - b2Shape.prototype.GetType = function () { - return this.m_type; - } - b2Shape.prototype.TestPoint = function (xf, p) { - return false; - } - b2Shape.prototype.RayCast = function (output, input, transform) { - return false; - } - b2Shape.prototype.ComputeAABB = function (aabb, xf) {} - b2Shape.prototype.ComputeMass = function (massData, density) { - if (density === undefined) density = 0; - } - b2Shape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) { - if (offset === undefined) offset = 0; - return 0; - } - b2Shape.TestOverlap = function (shape1, transform1, shape2, transform2) { - var input = new b2DistanceInput(); - input.proxyA = new b2DistanceProxy(); - input.proxyA.Set(shape1); - input.proxyB = new b2DistanceProxy(); - input.proxyB.Set(shape2); - input.transformA = transform1; - input.transformB = transform2; - input.useRadii = true; - var simplexCache = new b2SimplexCache(); - simplexCache.count = 0; - var output = new b2DistanceOutput(); - b2Distance.Distance(output, simplexCache, input); - return output.distance < 10.0 * Number.MIN_VALUE; - } - b2Shape.prototype.b2Shape = function () { - this.m_type = b2Shape.e_unknownShape; - this.m_radius = b2Settings.b2_linearSlop; - } - Box2D.postDefs.push(function () { - Box2D.Collision.Shapes.b2Shape.e_unknownShape = parseInt((-1)); - Box2D.Collision.Shapes.b2Shape.e_circleShape = 0; - Box2D.Collision.Shapes.b2Shape.e_polygonShape = 1; - Box2D.Collision.Shapes.b2Shape.e_edgeShape = 2; - Box2D.Collision.Shapes.b2Shape.e_shapeTypeCount = 3; - Box2D.Collision.Shapes.b2Shape.e_hitCollide = 1; - Box2D.Collision.Shapes.b2Shape.e_missCollide = 0; - Box2D.Collision.Shapes.b2Shape.e_startsInsideCollide = parseInt((-1)); - }); -})(); -(function () { - var b2Color = Box2D.Common.b2Color, - b2internal = Box2D.Common.b2internal, - b2Settings = Box2D.Common.b2Settings, - b2Mat22 = Box2D.Common.Math.b2Mat22, - b2Mat33 = Box2D.Common.Math.b2Mat33, - b2Math = Box2D.Common.Math.b2Math, - b2Sweep = Box2D.Common.Math.b2Sweep, - b2Transform = Box2D.Common.Math.b2Transform, - b2Vec2 = Box2D.Common.Math.b2Vec2, - b2Vec3 = Box2D.Common.Math.b2Vec3; - - b2Color.b2Color = function () { - this._r = 0; - this._g = 0; - this._b = 0; - }; - b2Color.prototype.b2Color = function (rr, gg, bb) { - if (rr === undefined) rr = 0; - if (gg === undefined) gg = 0; - if (bb === undefined) bb = 0; - this._r = Box2D.parseUInt(255 * b2Math.Clamp(rr, 0.0, 1.0)); - this._g = Box2D.parseUInt(255 * b2Math.Clamp(gg, 0.0, 1.0)); - this._b = Box2D.parseUInt(255 * b2Math.Clamp(bb, 0.0, 1.0)); - } - b2Color.prototype.Set = function (rr, gg, bb) { - if (rr === undefined) rr = 0; - if (gg === undefined) gg = 0; - if (bb === undefined) bb = 0; - this._r = Box2D.parseUInt(255 * b2Math.Clamp(rr, 0.0, 1.0)); - this._g = Box2D.parseUInt(255 * b2Math.Clamp(gg, 0.0, 1.0)); - this._b = Box2D.parseUInt(255 * b2Math.Clamp(bb, 0.0, 1.0)); - } - Object.defineProperty(b2Color.prototype, 'r', { - enumerable: false, - configurable: true, - set: function (rr) { - if (rr === undefined) rr = 0; - this._r = Box2D.parseUInt(255 * b2Math.Clamp(rr, 0.0, 1.0)); - } - }); - Object.defineProperty(b2Color.prototype, 'g', { - enumerable: false, - configurable: true, - set: function (gg) { - if (gg === undefined) gg = 0; - this._g = Box2D.parseUInt(255 * b2Math.Clamp(gg, 0.0, 1.0)); - } - }); - Object.defineProperty(b2Color.prototype, 'b', { - enumerable: false, - configurable: true, - set: function (bb) { - if (bb === undefined) bb = 0; - this._b = Box2D.parseUInt(255 * b2Math.Clamp(bb, 0.0, 1.0)); - } - }); - Object.defineProperty(b2Color.prototype, 'color', { - enumerable: false, - configurable: true, - get: function () { - return (this._r << 16) | (this._g << 8) | (this._b); - } - }); - b2Settings.b2Settings = function () {}; - b2Settings.b2MixFriction = function (friction1, friction2) { - if (friction1 === undefined) friction1 = 0; - if (friction2 === undefined) friction2 = 0; - return Math.sqrt(friction1 * friction2); - } - b2Settings.b2MixRestitution = function (restitution1, restitution2) { - if (restitution1 === undefined) restitution1 = 0; - if (restitution2 === undefined) restitution2 = 0; - return restitution1 > restitution2 ? restitution1 : restitution2; - } - b2Settings.b2Assert = function (a) { - if (!a) { - throw "Assertion Failed"; - } - } - Box2D.postDefs.push(function () { - Box2D.Common.b2Settings.VERSION = "2.1alpha"; - Box2D.Common.b2Settings.USHRT_MAX = 0x0000ffff; - Box2D.Common.b2Settings.b2_pi = Math.PI; - Box2D.Common.b2Settings.b2_maxManifoldPoints = 2; - Box2D.Common.b2Settings.b2_aabbExtension = 0.1; - Box2D.Common.b2Settings.b2_aabbMultiplier = 2.0; - Box2D.Common.b2Settings.b2_polygonRadius = 2.0 * b2Settings.b2_linearSlop; - Box2D.Common.b2Settings.b2_linearSlop = 0.005; - Box2D.Common.b2Settings.b2_angularSlop = 2.0 / 180.0 * b2Settings.b2_pi; - Box2D.Common.b2Settings.b2_toiSlop = 8.0 * b2Settings.b2_linearSlop; - Box2D.Common.b2Settings.b2_maxTOIContactsPerIsland = 32; - Box2D.Common.b2Settings.b2_maxTOIJointsPerIsland = 32; - Box2D.Common.b2Settings.b2_velocityThreshold = 1.0; - Box2D.Common.b2Settings.b2_maxLinearCorrection = 0.2; - Box2D.Common.b2Settings.b2_maxAngularCorrection = 8.0 / 180.0 * b2Settings.b2_pi; - Box2D.Common.b2Settings.b2_maxTranslation = 2.0; - Box2D.Common.b2Settings.b2_maxTranslationSquared = b2Settings.b2_maxTranslation * b2Settings.b2_maxTranslation; - Box2D.Common.b2Settings.b2_maxRotation = 0.5 * b2Settings.b2_pi; - Box2D.Common.b2Settings.b2_maxRotationSquared = b2Settings.b2_maxRotation * b2Settings.b2_maxRotation; - Box2D.Common.b2Settings.b2_contactBaumgarte = 0.2; - Box2D.Common.b2Settings.b2_timeToSleep = 0.5; - Box2D.Common.b2Settings.b2_linearSleepTolerance = 0.01; - Box2D.Common.b2Settings.b2_angularSleepTolerance = 2.0 / 180.0 * b2Settings.b2_pi; - }); -})(); -(function () { - var b2AABB = Box2D.Collision.b2AABB, - b2Color = Box2D.Common.b2Color, - b2internal = Box2D.Common.b2internal, - b2Settings = Box2D.Common.b2Settings, - b2Mat22 = Box2D.Common.Math.b2Mat22, - b2Mat33 = Box2D.Common.Math.b2Mat33, - b2Math = Box2D.Common.Math.b2Math, - b2Sweep = Box2D.Common.Math.b2Sweep, - b2Transform = Box2D.Common.Math.b2Transform, - b2Vec2 = Box2D.Common.Math.b2Vec2, - b2Vec3 = Box2D.Common.Math.b2Vec3; - - b2Mat22.b2Mat22 = function () { - this.col1 = new b2Vec2(); - this.col2 = new b2Vec2(); - }; - b2Mat22.prototype.b2Mat22 = function () { - this.SetIdentity(); - } - b2Mat22.FromAngle = function (angle) { - if (angle === undefined) angle = 0; - var mat = new b2Mat22(); - mat.Set(angle); - return mat; - } - b2Mat22.FromVV = function (c1, c2) { - var mat = new b2Mat22(); - mat.SetVV(c1, c2); - return mat; - } - b2Mat22.prototype.Set = function (angle) { - if (angle === undefined) angle = 0; - var c = Math.cos(angle); - var s = Math.sin(angle); - this.col1.x = c; - this.col2.x = (-s); - this.col1.y = s; - this.col2.y = c; - } - b2Mat22.prototype.SetVV = function (c1, c2) { - this.col1.SetV(c1); - this.col2.SetV(c2); - } - b2Mat22.prototype.Copy = function () { - var mat = new b2Mat22(); - mat.SetM(this); - return mat; - } - b2Mat22.prototype.SetM = function (m) { - this.col1.SetV(m.col1); - this.col2.SetV(m.col2); - } - b2Mat22.prototype.AddM = function (m) { - this.col1.x += m.col1.x; - this.col1.y += m.col1.y; - this.col2.x += m.col2.x; - this.col2.y += m.col2.y; - } - b2Mat22.prototype.SetIdentity = function () { - this.col1.x = 1.0; - this.col2.x = 0.0; - this.col1.y = 0.0; - this.col2.y = 1.0; - } - b2Mat22.prototype.SetZero = function () { - this.col1.x = 0.0; - this.col2.x = 0.0; - this.col1.y = 0.0; - this.col2.y = 0.0; - } - b2Mat22.prototype.GetAngle = function () { - return Math.atan2(this.col1.y, this.col1.x); - } - b2Mat22.prototype.GetInverse = function (out) { - var a = this.col1.x; - var b = this.col2.x; - var c = this.col1.y; - var d = this.col2.y; - var det = a * d - b * c; - if (det != 0.0) { - det = 1.0 / det; - } - out.col1.x = det * d; - out.col2.x = (-det * b); - out.col1.y = (-det * c); - out.col2.y = det * a; - return out; - } - b2Mat22.prototype.Solve = function (out, bX, bY) { - if (bX === undefined) bX = 0; - if (bY === undefined) bY = 0; - var a11 = this.col1.x; - var a12 = this.col2.x; - var a21 = this.col1.y; - var a22 = this.col2.y; - var det = a11 * a22 - a12 * a21; - if (det != 0.0) { - det = 1.0 / det; - } - out.x = det * (a22 * bX - a12 * bY); - out.y = det * (a11 * bY - a21 * bX); - return out; - } - b2Mat22.prototype.Abs = function () { - this.col1.Abs(); - this.col2.Abs(); - } - b2Mat33.b2Mat33 = function () { - this.col1 = new b2Vec3(); - this.col2 = new b2Vec3(); - this.col3 = new b2Vec3(); - }; - b2Mat33.prototype.b2Mat33 = function (c1, c2, c3) { - if (c1 === undefined) c1 = null; - if (c2 === undefined) c2 = null; - if (c3 === undefined) c3 = null; - if (!c1 && !c2 && !c3) { - this.col1.SetZero(); - this.col2.SetZero(); - this.col3.SetZero(); - } - else { - this.col1.SetV(c1); - this.col2.SetV(c2); - this.col3.SetV(c3); - } - } - b2Mat33.prototype.SetVVV = function (c1, c2, c3) { - this.col1.SetV(c1); - this.col2.SetV(c2); - this.col3.SetV(c3); - } - b2Mat33.prototype.Copy = function () { - return new b2Mat33(this.col1, this.col2, this.col3); - } - b2Mat33.prototype.SetM = function (m) { - this.col1.SetV(m.col1); - this.col2.SetV(m.col2); - this.col3.SetV(m.col3); - } - b2Mat33.prototype.AddM = function (m) { - this.col1.x += m.col1.x; - this.col1.y += m.col1.y; - this.col1.z += m.col1.z; - this.col2.x += m.col2.x; - this.col2.y += m.col2.y; - this.col2.z += m.col2.z; - this.col3.x += m.col3.x; - this.col3.y += m.col3.y; - this.col3.z += m.col3.z; - } - b2Mat33.prototype.SetIdentity = function () { - this.col1.x = 1.0; - this.col2.x = 0.0; - this.col3.x = 0.0; - this.col1.y = 0.0; - this.col2.y = 1.0; - this.col3.y = 0.0; - this.col1.z = 0.0; - this.col2.z = 0.0; - this.col3.z = 1.0; - } - b2Mat33.prototype.SetZero = function () { - this.col1.x = 0.0; - this.col2.x = 0.0; - this.col3.x = 0.0; - this.col1.y = 0.0; - this.col2.y = 0.0; - this.col3.y = 0.0; - this.col1.z = 0.0; - this.col2.z = 0.0; - this.col3.z = 0.0; - } - b2Mat33.prototype.Solve22 = function (out, bX, bY) { - if (bX === undefined) bX = 0; - if (bY === undefined) bY = 0; - var a11 = this.col1.x; - var a12 = this.col2.x; - var a21 = this.col1.y; - var a22 = this.col2.y; - var det = a11 * a22 - a12 * a21; - if (det != 0.0) { - det = 1.0 / det; - } - out.x = det * (a22 * bX - a12 * bY); - out.y = det * (a11 * bY - a21 * bX); - return out; - } - b2Mat33.prototype.Solve33 = function (out, bX, bY, bZ) { - if (bX === undefined) bX = 0; - if (bY === undefined) bY = 0; - if (bZ === undefined) bZ = 0; - var a11 = this.col1.x; - var a21 = this.col1.y; - var a31 = this.col1.z; - var a12 = this.col2.x; - var a22 = this.col2.y; - var a32 = this.col2.z; - var a13 = this.col3.x; - var a23 = this.col3.y; - var a33 = this.col3.z; - var det = a11 * (a22 * a33 - a32 * a23) + a21 * (a32 * a13 - a12 * a33) + a31 * (a12 * a23 - a22 * a13); - if (det != 0.0) { - det = 1.0 / det; - } - out.x = det * (bX * (a22 * a33 - a32 * a23) + bY * (a32 * a13 - a12 * a33) + bZ * (a12 * a23 - a22 * a13)); - out.y = det * (a11 * (bY * a33 - bZ * a23) + a21 * (bZ * a13 - bX * a33) + a31 * (bX * a23 - bY * a13)); - out.z = det * (a11 * (a22 * bZ - a32 * bY) + a21 * (a32 * bX - a12 * bZ) + a31 * (a12 * bY - a22 * bX)); - return out; - } - b2Math.b2Math = function () {}; - b2Math.IsValid = function (x) { - if (x === undefined) x = 0; - return isFinite(x); - } - b2Math.Dot = function (a, b) { - return a.x * b.x + a.y * b.y; - } - b2Math.CrossVV = function (a, b) { - return a.x * b.y - a.y * b.x; - } - b2Math.CrossVF = function (a, s) { - if (s === undefined) s = 0; - var v = new b2Vec2(s * a.y, (-s * a.x)); - return v; - } - b2Math.CrossFV = function (s, a) { - if (s === undefined) s = 0; - var v = new b2Vec2((-s * a.y), s * a.x); - return v; - } - b2Math.MulMV = function (A, v) { - var u = new b2Vec2(A.col1.x * v.x + A.col2.x * v.y, A.col1.y * v.x + A.col2.y * v.y); - return u; - } - b2Math.MulTMV = function (A, v) { - var u = new b2Vec2(b2Math.Dot(v, A.col1), b2Math.Dot(v, A.col2)); - return u; - } - b2Math.MulX = function (T, v) { - var a = b2Math.MulMV(T.R, v); - a.x += T.position.x; - a.y += T.position.y; - return a; - } - b2Math.MulXT = function (T, v) { - var a = b2Math.SubtractVV(v, T.position); - var tX = (a.x * T.R.col1.x + a.y * T.R.col1.y); - a.y = (a.x * T.R.col2.x + a.y * T.R.col2.y); - a.x = tX; - return a; - } - b2Math.AddVV = function (a, b) { - var v = new b2Vec2(a.x + b.x, a.y + b.y); - return v; - } - b2Math.SubtractVV = function (a, b) { - var v = new b2Vec2(a.x - b.x, a.y - b.y); - return v; - } - b2Math.Distance = function (a, b) { - var cX = a.x - b.x; - var cY = a.y - b.y; - return Math.sqrt(cX * cX + cY * cY); - } - b2Math.DistanceSquared = function (a, b) { - var cX = a.x - b.x; - var cY = a.y - b.y; - return (cX * cX + cY * cY); - } - b2Math.MulFV = function (s, a) { - if (s === undefined) s = 0; - var v = new b2Vec2(s * a.x, s * a.y); - return v; - } - b2Math.AddMM = function (A, B) { - var C = b2Mat22.FromVV(b2Math.AddVV(A.col1, B.col1), b2Math.AddVV(A.col2, B.col2)); - return C; - } - b2Math.MulMM = function (A, B) { - var C = b2Mat22.FromVV(b2Math.MulMV(A, B.col1), b2Math.MulMV(A, B.col2)); - return C; - } - b2Math.MulTMM = function (A, B) { - var c1 = new b2Vec2(b2Math.Dot(A.col1, B.col1), b2Math.Dot(A.col2, B.col1)); - var c2 = new b2Vec2(b2Math.Dot(A.col1, B.col2), b2Math.Dot(A.col2, B.col2)); - var C = b2Mat22.FromVV(c1, c2); - return C; - } - b2Math.Abs = function (a) { - if (a === undefined) a = 0; - return a > 0.0 ? a : (-a); - } - b2Math.AbsV = function (a) { - var b = new b2Vec2(b2Math.Abs(a.x), b2Math.Abs(a.y)); - return b; - } - b2Math.AbsM = function (A) { - var B = b2Mat22.FromVV(b2Math.AbsV(A.col1), b2Math.AbsV(A.col2)); - return B; - } - b2Math.Min = function (a, b) { - if (a === undefined) a = 0; - if (b === undefined) b = 0; - return a < b ? a : b; - } - b2Math.MinV = function (a, b) { - var c = new b2Vec2(b2Math.Min(a.x, b.x), b2Math.Min(a.y, b.y)); - return c; - } - b2Math.Max = function (a, b) { - if (a === undefined) a = 0; - if (b === undefined) b = 0; - return a > b ? a : b; - } - b2Math.MaxV = function (a, b) { - var c = new b2Vec2(b2Math.Max(a.x, b.x), b2Math.Max(a.y, b.y)); - return c; - } - b2Math.Clamp = function (a, low, high) { - if (a === undefined) a = 0; - if (low === undefined) low = 0; - if (high === undefined) high = 0; - return a < low ? low : a > high ? high : a; - } - b2Math.ClampV = function (a, low, high) { - return b2Math.MaxV(low, b2Math.MinV(a, high)); - } - b2Math.Swap = function (a, b) { - var tmp = a[0]; - a[0] = b[0]; - b[0] = tmp; - } - b2Math.Random = function () { - return Math.random() * 2 - 1; - } - b2Math.RandomRange = function (lo, hi) { - if (lo === undefined) lo = 0; - if (hi === undefined) hi = 0; - var r = Math.random(); - r = (hi - lo) * r + lo; - return r; - } - b2Math.NextPowerOfTwo = function (x) { - if (x === undefined) x = 0; - x |= (x >> 1) & 0x7FFFFFFF; - x |= (x >> 2) & 0x3FFFFFFF; - x |= (x >> 4) & 0x0FFFFFFF; - x |= (x >> 8) & 0x00FFFFFF; - x |= (x >> 16) & 0x0000FFFF; - return x + 1; - } - b2Math.IsPowerOfTwo = function (x) { - if (x === undefined) x = 0; - var result = x > 0 && (x & (x - 1)) == 0; - return result; - } - Box2D.postDefs.push(function () { - Box2D.Common.Math.b2Math.b2Vec2_zero = new b2Vec2(0.0, 0.0); - Box2D.Common.Math.b2Math.b2Mat22_identity = b2Mat22.FromVV(new b2Vec2(1.0, 0.0), new b2Vec2(0.0, 1.0)); - Box2D.Common.Math.b2Math.b2Transform_identity = new b2Transform(b2Math.b2Vec2_zero, b2Math.b2Mat22_identity); - }); - b2Sweep.b2Sweep = function () { - this.localCenter = new b2Vec2(); - this.c0 = new b2Vec2; - this.c = new b2Vec2(); - }; - b2Sweep.prototype.Set = function (other) { - this.localCenter.SetV(other.localCenter); - this.c0.SetV(other.c0); - this.c.SetV(other.c); - this.a0 = other.a0; - this.a = other.a; - this.t0 = other.t0; - } - b2Sweep.prototype.Copy = function () { - var copy = new b2Sweep(); - copy.localCenter.SetV(this.localCenter); - copy.c0.SetV(this.c0); - copy.c.SetV(this.c); - copy.a0 = this.a0; - copy.a = this.a; - copy.t0 = this.t0; - return copy; - } - b2Sweep.prototype.GetTransform = function (xf, alpha) { - if (alpha === undefined) alpha = 0; - xf.position.x = (1.0 - alpha) * this.c0.x + alpha * this.c.x; - xf.position.y = (1.0 - alpha) * this.c0.y + alpha * this.c.y; - var angle = (1.0 - alpha) * this.a0 + alpha * this.a; - xf.R.Set(angle); - var tMat = xf.R; - xf.position.x -= (tMat.col1.x * this.localCenter.x + tMat.col2.x * this.localCenter.y); - xf.position.y -= (tMat.col1.y * this.localCenter.x + tMat.col2.y * this.localCenter.y); - } - b2Sweep.prototype.Advance = function (t) { - if (t === undefined) t = 0; - if (this.t0 < t && 1.0 - this.t0 > Number.MIN_VALUE) { - var alpha = (t - this.t0) / (1.0 - this.t0); - this.c0.x = (1.0 - alpha) * this.c0.x + alpha * this.c.x; - this.c0.y = (1.0 - alpha) * this.c0.y + alpha * this.c.y; - this.a0 = (1.0 - alpha) * this.a0 + alpha * this.a; - this.t0 = t; - } - } - b2Transform.b2Transform = function () { - this.position = new b2Vec2; - this.R = new b2Mat22(); - }; - b2Transform.prototype.b2Transform = function (pos, r) { - if (pos === undefined) pos = null; - if (r === undefined) r = null; - if (pos) { - this.position.SetV(pos); - this.R.SetM(r); - } - } - b2Transform.prototype.Initialize = function (pos, r) { - this.position.SetV(pos); - this.R.SetM(r); - } - b2Transform.prototype.SetIdentity = function () { - this.position.SetZero(); - this.R.SetIdentity(); - } - b2Transform.prototype.Set = function (x) { - this.position.SetV(x.position); - this.R.SetM(x.R); - } - b2Transform.prototype.GetAngle = function () { - return Math.atan2(this.R.col1.y, this.R.col1.x); - } - b2Vec2.b2Vec2 = function () {}; - b2Vec2.prototype.b2Vec2 = function (x_, y_) { - if (x_ === undefined) x_ = 0; - if (y_ === undefined) y_ = 0; - this.x = x_; - this.y = y_; - } - b2Vec2.prototype.SetZero = function () { - this.x = 0.0; - this.y = 0.0; - } - b2Vec2.prototype.Set = function (x_, y_) { - if (x_ === undefined) x_ = 0; - if (y_ === undefined) y_ = 0; - this.x = x_; - this.y = y_; - } - b2Vec2.prototype.SetV = function (v) { - this.x = v.x; - this.y = v.y; - } - b2Vec2.prototype.GetNegative = function () { - return new b2Vec2((-this.x), (-this.y)); - } - b2Vec2.prototype.NegativeSelf = function () { - this.x = (-this.x); - this.y = (-this.y); - } - b2Vec2.Make = function (x_, y_) { - if (x_ === undefined) x_ = 0; - if (y_ === undefined) y_ = 0; - return new b2Vec2(x_, y_); - } - b2Vec2.prototype.Copy = function () { - return new b2Vec2(this.x, this.y); - } - b2Vec2.prototype.Add = function (v) { - this.x += v.x; - this.y += v.y; - } - b2Vec2.prototype.Subtract = function (v) { - this.x -= v.x; - this.y -= v.y; - } - b2Vec2.prototype.Multiply = function (a) { - if (a === undefined) a = 0; - this.x *= a; - this.y *= a; - } - b2Vec2.prototype.MulM = function (A) { - var tX = this.x; - this.x = A.col1.x * tX + A.col2.x * this.y; - this.y = A.col1.y * tX + A.col2.y * this.y; - } - b2Vec2.prototype.MulTM = function (A) { - var tX = b2Math.Dot(this, A.col1); - this.y = b2Math.Dot(this, A.col2); - this.x = tX; - } - b2Vec2.prototype.CrossVF = function (s) { - if (s === undefined) s = 0; - var tX = this.x; - this.x = s * this.y; - this.y = (-s * tX); - } - b2Vec2.prototype.CrossFV = function (s) { - if (s === undefined) s = 0; - var tX = this.x; - this.x = (-s * this.y); - this.y = s * tX; - } - b2Vec2.prototype.MinV = function (b) { - this.x = this.x < b.x ? this.x : b.x; - this.y = this.y < b.y ? this.y : b.y; - } - b2Vec2.prototype.MaxV = function (b) { - this.x = this.x > b.x ? this.x : b.x; - this.y = this.y > b.y ? this.y : b.y; - } - b2Vec2.prototype.Abs = function () { - if (this.x < 0) this.x = (-this.x); - if (this.y < 0) this.y = (-this.y); - } - b2Vec2.prototype.Length = function () { - return Math.sqrt(this.x * this.x + this.y * this.y); - } - b2Vec2.prototype.LengthSquared = function () { - return (this.x * this.x + this.y * this.y); - } - b2Vec2.prototype.Normalize = function () { - var length = Math.sqrt(this.x * this.x + this.y * this.y); - if (length < Number.MIN_VALUE) { - return 0.0; - } - var invLength = 1.0 / length; - this.x *= invLength; - this.y *= invLength; - return length; - } - b2Vec2.prototype.IsValid = function () { - return b2Math.IsValid(this.x) && b2Math.IsValid(this.y); - } - b2Vec3.b2Vec3 = function () {}; - b2Vec3.prototype.b2Vec3 = function (x, y, z) { - if (x === undefined) x = 0; - if (y === undefined) y = 0; - if (z === undefined) z = 0; - this.x = x; - this.y = y; - this.z = z; - } - b2Vec3.prototype.SetZero = function () { - this.x = this.y = this.z = 0.0; - } - b2Vec3.prototype.Set = function (x, y, z) { - if (x === undefined) x = 0; - if (y === undefined) y = 0; - if (z === undefined) z = 0; - this.x = x; - this.y = y; - this.z = z; - } - b2Vec3.prototype.SetV = function (v) { - this.x = v.x; - this.y = v.y; - this.z = v.z; - } - b2Vec3.prototype.GetNegative = function () { - return new b2Vec3((-this.x), (-this.y), (-this.z)); - } - b2Vec3.prototype.NegativeSelf = function () { - this.x = (-this.x); - this.y = (-this.y); - this.z = (-this.z); - } - b2Vec3.prototype.Copy = function () { - return new b2Vec3(this.x, this.y, this.z); - } - b2Vec3.prototype.Add = function (v) { - this.x += v.x; - this.y += v.y; - this.z += v.z; - } - b2Vec3.prototype.Subtract = function (v) { - this.x -= v.x; - this.y -= v.y; - this.z -= v.z; - } - b2Vec3.prototype.Multiply = function (a) { - if (a === undefined) a = 0; - this.x *= a; - this.y *= a; - this.z *= a; - } -})(); -(function () { - var b2ControllerEdge = Box2D.Dynamics.Controllers.b2ControllerEdge, - b2Mat22 = Box2D.Common.Math.b2Mat22, - b2Mat33 = Box2D.Common.Math.b2Mat33, - b2Math = Box2D.Common.Math.b2Math, - b2Sweep = Box2D.Common.Math.b2Sweep, - b2Transform = Box2D.Common.Math.b2Transform, - b2Vec2 = Box2D.Common.Math.b2Vec2, - b2Vec3 = Box2D.Common.Math.b2Vec3, - b2Color = Box2D.Common.b2Color, - b2internal = Box2D.Common.b2internal, - b2Settings = Box2D.Common.b2Settings, - b2AABB = Box2D.Collision.b2AABB, - b2Bound = Box2D.Collision.b2Bound, - b2BoundValues = Box2D.Collision.b2BoundValues, - b2Collision = Box2D.Collision.b2Collision, - b2ContactID = Box2D.Collision.b2ContactID, - b2ContactPoint = Box2D.Collision.b2ContactPoint, - b2Distance = Box2D.Collision.b2Distance, - b2DistanceInput = Box2D.Collision.b2DistanceInput, - b2DistanceOutput = Box2D.Collision.b2DistanceOutput, - b2DistanceProxy = Box2D.Collision.b2DistanceProxy, - b2DynamicTree = Box2D.Collision.b2DynamicTree, - b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase, - b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode, - b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair, - b2Manifold = Box2D.Collision.b2Manifold, - b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint, - b2Point = Box2D.Collision.b2Point, - b2RayCastInput = Box2D.Collision.b2RayCastInput, - b2RayCastOutput = Box2D.Collision.b2RayCastOutput, - b2Segment = Box2D.Collision.b2Segment, - b2SeparationFunction = Box2D.Collision.b2SeparationFunction, - b2Simplex = Box2D.Collision.b2Simplex, - b2SimplexCache = Box2D.Collision.b2SimplexCache, - b2SimplexVertex = Box2D.Collision.b2SimplexVertex, - b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact, - b2TOIInput = Box2D.Collision.b2TOIInput, - b2WorldManifold = Box2D.Collision.b2WorldManifold, - ClipVertex = Box2D.Collision.ClipVertex, - Features = Box2D.Collision.Features, - IBroadPhase = Box2D.Collision.IBroadPhase, - b2CircleShape = Box2D.Collision.Shapes.b2CircleShape, - b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef, - b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape, - b2MassData = Box2D.Collision.Shapes.b2MassData, - b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape, - b2Shape = Box2D.Collision.Shapes.b2Shape, - b2Body = Box2D.Dynamics.b2Body, - b2BodyDef = Box2D.Dynamics.b2BodyDef, - b2ContactFilter = Box2D.Dynamics.b2ContactFilter, - b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse, - b2ContactListener = Box2D.Dynamics.b2ContactListener, - b2ContactManager = Box2D.Dynamics.b2ContactManager, - b2DebugDraw = Box2D.Dynamics.b2DebugDraw, - b2DestructionListener = Box2D.Dynamics.b2DestructionListener, - b2FilterData = Box2D.Dynamics.b2FilterData, - b2Fixture = Box2D.Dynamics.b2Fixture, - b2FixtureDef = Box2D.Dynamics.b2FixtureDef, - b2Island = Box2D.Dynamics.b2Island, - b2TimeStep = Box2D.Dynamics.b2TimeStep, - b2World = Box2D.Dynamics.b2World, - b2CircleContact = Box2D.Dynamics.Contacts.b2CircleContact, - b2Contact = Box2D.Dynamics.Contacts.b2Contact, - b2ContactConstraint = Box2D.Dynamics.Contacts.b2ContactConstraint, - b2ContactConstraintPoint = Box2D.Dynamics.Contacts.b2ContactConstraintPoint, - b2ContactEdge = Box2D.Dynamics.Contacts.b2ContactEdge, - b2ContactFactory = Box2D.Dynamics.Contacts.b2ContactFactory, - b2ContactRegister = Box2D.Dynamics.Contacts.b2ContactRegister, - b2ContactResult = Box2D.Dynamics.Contacts.b2ContactResult, - b2ContactSolver = Box2D.Dynamics.Contacts.b2ContactSolver, - b2EdgeAndCircleContact = Box2D.Dynamics.Contacts.b2EdgeAndCircleContact, - b2NullContact = Box2D.Dynamics.Contacts.b2NullContact, - b2PolyAndCircleContact = Box2D.Dynamics.Contacts.b2PolyAndCircleContact, - b2PolyAndEdgeContact = Box2D.Dynamics.Contacts.b2PolyAndEdgeContact, - b2PolygonContact = Box2D.Dynamics.Contacts.b2PolygonContact, - b2PositionSolverManifold = Box2D.Dynamics.Contacts.b2PositionSolverManifold, - b2Controller = Box2D.Dynamics.Controllers.b2Controller, - b2DistanceJoint = Box2D.Dynamics.Joints.b2DistanceJoint, - b2DistanceJointDef = Box2D.Dynamics.Joints.b2DistanceJointDef, - b2FrictionJoint = Box2D.Dynamics.Joints.b2FrictionJoint, - b2FrictionJointDef = Box2D.Dynamics.Joints.b2FrictionJointDef, - b2GearJoint = Box2D.Dynamics.Joints.b2GearJoint, - b2GearJointDef = Box2D.Dynamics.Joints.b2GearJointDef, - b2Jacobian = Box2D.Dynamics.Joints.b2Jacobian, - b2Joint = Box2D.Dynamics.Joints.b2Joint, - b2JointDef = Box2D.Dynamics.Joints.b2JointDef, - b2JointEdge = Box2D.Dynamics.Joints.b2JointEdge, - b2LineJoint = Box2D.Dynamics.Joints.b2LineJoint, - b2LineJointDef = Box2D.Dynamics.Joints.b2LineJointDef, - b2MouseJoint = Box2D.Dynamics.Joints.b2MouseJoint, - b2MouseJointDef = Box2D.Dynamics.Joints.b2MouseJointDef, - b2PrismaticJoint = Box2D.Dynamics.Joints.b2PrismaticJoint, - b2PrismaticJointDef = Box2D.Dynamics.Joints.b2PrismaticJointDef, - b2PulleyJoint = Box2D.Dynamics.Joints.b2PulleyJoint, - b2PulleyJointDef = Box2D.Dynamics.Joints.b2PulleyJointDef, - b2RevoluteJoint = Box2D.Dynamics.Joints.b2RevoluteJoint, - b2RevoluteJointDef = Box2D.Dynamics.Joints.b2RevoluteJointDef, - b2WeldJoint = Box2D.Dynamics.Joints.b2WeldJoint, - b2WeldJointDef = Box2D.Dynamics.Joints.b2WeldJointDef; - - b2Body.b2Body = function () { - this.m_xf = new b2Transform(); - this.m_sweep = new b2Sweep(); - this.m_linearVelocity = new b2Vec2(); - this.m_force = new b2Vec2(); - }; - b2Body.prototype.connectEdges = function (s1, s2, angle1) { - if (angle1 === undefined) angle1 = 0; - var angle2 = Math.atan2(s2.GetDirectionVector().y, s2.GetDirectionVector().x); - var coreOffset = Math.tan((angle2 - angle1) * 0.5); - var core = b2Math.MulFV(coreOffset, s2.GetDirectionVector()); - core = b2Math.SubtractVV(core, s2.GetNormalVector()); - core = b2Math.MulFV(b2Settings.b2_toiSlop, core); - core = b2Math.AddVV(core, s2.GetVertex1()); - var cornerDir = b2Math.AddVV(s1.GetDirectionVector(), s2.GetDirectionVector()); - cornerDir.Normalize(); - var convex = b2Math.Dot(s1.GetDirectionVector(), s2.GetNormalVector()) > 0.0; - s1.SetNextEdge(s2, core, cornerDir, convex); - s2.SetPrevEdge(s1, core, cornerDir, convex); - return angle2; - } - b2Body.prototype.CreateFixture = function (def) { - if (this.m_world.IsLocked() == true) { - return null; - } - var fixture = new b2Fixture(); - fixture.Create(this, this.m_xf, def); - if (this.m_flags & b2Body.e_activeFlag) { - var broadPhase = this.m_world.m_contactManager.m_broadPhase; - fixture.CreateProxy(broadPhase, this.m_xf); - } - fixture.m_next = this.m_fixtureList; - this.m_fixtureList = fixture; - ++this.m_fixtureCount; - fixture.m_body = this; - if (fixture.m_density > 0.0) { - this.ResetMassData(); - } - this.m_world.m_flags |= b2World.e_newFixture; - return fixture; - } - b2Body.prototype.CreateFixture2 = function (shape, density) { - if (density === undefined) density = 0.0; - var def = new b2FixtureDef(); - def.shape = shape; - def.density = density; - return this.CreateFixture(def); - } - b2Body.prototype.DestroyFixture = function (fixture) { - if (this.m_world.IsLocked() == true) { - return; - } - var node = this.m_fixtureList; - var ppF = null; - var found = false; - while (node != null) { - if (node == fixture) { - if (ppF) ppF.m_next = fixture.m_next; - else this.m_fixtureList = fixture.m_next; - found = true; - break; - } - ppF = node; - node = node.m_next; - } - var edge = this.m_contactList; - while (edge) { - var c = edge.contact; - edge = edge.next; - var fixtureA = c.GetFixtureA(); - var fixtureB = c.GetFixtureB(); - if (fixture == fixtureA || fixture == fixtureB) { - this.m_world.m_contactManager.Destroy(c); - } - } - if (this.m_flags & b2Body.e_activeFlag) { - var broadPhase = this.m_world.m_contactManager.m_broadPhase; - fixture.DestroyProxy(broadPhase); - } - else {} - fixture.Destroy(); - fixture.m_body = null; - fixture.m_next = null; - --this.m_fixtureCount; - this.ResetMassData(); - } - b2Body.prototype.SetPositionAndAngle = function (position, angle) { - if (angle === undefined) angle = 0; - var f; - if (this.m_world.IsLocked() == true) { - return; - } - this.m_xf.R.Set(angle); - this.m_xf.position.SetV(position); - var tMat = this.m_xf.R; - var tVec = this.m_sweep.localCenter; - this.m_sweep.c.x = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - this.m_sweep.c.y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - this.m_sweep.c.x += this.m_xf.position.x; - this.m_sweep.c.y += this.m_xf.position.y; - this.m_sweep.c0.SetV(this.m_sweep.c); - this.m_sweep.a0 = this.m_sweep.a = angle; - var broadPhase = this.m_world.m_contactManager.m_broadPhase; - for (f = this.m_fixtureList; - f; f = f.m_next) { - f.Synchronize(broadPhase, this.m_xf, this.m_xf); - } - this.m_world.m_contactManager.FindNewContacts(); - } - b2Body.prototype.SetTransform = function (xf) { - this.SetPositionAndAngle(xf.position, xf.GetAngle()); - } - b2Body.prototype.GetTransform = function () { - return this.m_xf; - } - b2Body.prototype.GetPosition = function () { - return this.m_xf.position; - } - b2Body.prototype.SetPosition = function (position) { - this.SetPositionAndAngle(position, this.GetAngle()); - } - b2Body.prototype.GetAngle = function () { - return this.m_sweep.a; - } - b2Body.prototype.SetAngle = function (angle) { - if (angle === undefined) angle = 0; - this.SetPositionAndAngle(this.GetPosition(), angle); - } - b2Body.prototype.GetWorldCenter = function () { - return this.m_sweep.c; - } - b2Body.prototype.GetLocalCenter = function () { - return this.m_sweep.localCenter; - } - b2Body.prototype.SetLinearVelocity = function (v) { - if (this.m_type == b2Body.b2_staticBody) { - return; - } - this.m_linearVelocity.SetV(v); - } - b2Body.prototype.GetLinearVelocity = function () { - return this.m_linearVelocity; - } - b2Body.prototype.SetAngularVelocity = function (omega) { - if (omega === undefined) omega = 0; - if (this.m_type == b2Body.b2_staticBody) { - return; - } - this.m_angularVelocity = omega; - } - b2Body.prototype.GetAngularVelocity = function () { - return this.m_angularVelocity; - } - b2Body.prototype.GetDefinition = function () { - var bd = new b2BodyDef(); - bd.type = this.GetType(); - bd.allowSleep = (this.m_flags & b2Body.e_allowSleepFlag) == b2Body.e_allowSleepFlag; - bd.angle = this.GetAngle(); - bd.angularDamping = this.m_angularDamping; - bd.angularVelocity = this.m_angularVelocity; - bd.fixedRotation = (this.m_flags & b2Body.e_fixedRotationFlag) == b2Body.e_fixedRotationFlag; - bd.bullet = (this.m_flags & b2Body.e_bulletFlag) == b2Body.e_bulletFlag; - bd.awake = (this.m_flags & b2Body.e_awakeFlag) == b2Body.e_awakeFlag; - bd.linearDamping = this.m_linearDamping; - bd.linearVelocity.SetV(this.GetLinearVelocity()); - bd.position = this.GetPosition(); - bd.userData = this.GetUserData(); - return bd; - } - b2Body.prototype.ApplyForce = function (force, point) { - if (this.m_type != b2Body.b2_dynamicBody) { - return; - } - if (this.IsAwake() == false) { - this.SetAwake(true); - } - this.m_force.x += force.x; - this.m_force.y += force.y; - this.m_torque += ((point.x - this.m_sweep.c.x) * force.y - (point.y - this.m_sweep.c.y) * force.x); - } - b2Body.prototype.ApplyTorque = function (torque) { - if (torque === undefined) torque = 0; - if (this.m_type != b2Body.b2_dynamicBody) { - return; - } - if (this.IsAwake() == false) { - this.SetAwake(true); - } - this.m_torque += torque; - } - b2Body.prototype.ApplyImpulse = function (impulse, point) { - if (this.m_type != b2Body.b2_dynamicBody) { - return; - } - if (this.IsAwake() == false) { - this.SetAwake(true); - } - this.m_linearVelocity.x += this.m_invMass * impulse.x; - this.m_linearVelocity.y += this.m_invMass * impulse.y; - this.m_angularVelocity += this.m_invI * ((point.x - this.m_sweep.c.x) * impulse.y - (point.y - this.m_sweep.c.y) * impulse.x); - } - b2Body.prototype.Split = function (callback) { - var linearVelocity = this.GetLinearVelocity().Copy(); - var angularVelocity = this.GetAngularVelocity(); - var center = this.GetWorldCenter(); - var body1 = this; - var body2 = this.m_world.CreateBody(this.GetDefinition()); - var prev; - for (var f = body1.m_fixtureList; f;) { - if (callback(f)) { - var next = f.m_next; - if (prev) { - prev.m_next = next; - } - else { - body1.m_fixtureList = next; - } - body1.m_fixtureCount--; - f.m_next = body2.m_fixtureList; - body2.m_fixtureList = f; - body2.m_fixtureCount++; - f.m_body = body2; - f = next; - } - else { - prev = f; - f = f.m_next; - } - } - body1.ResetMassData(); - body2.ResetMassData(); - var center1 = body1.GetWorldCenter(); - var center2 = body2.GetWorldCenter(); - var velocity1 = b2Math.AddVV(linearVelocity, b2Math.CrossFV(angularVelocity, b2Math.SubtractVV(center1, center))); - var velocity2 = b2Math.AddVV(linearVelocity, b2Math.CrossFV(angularVelocity, b2Math.SubtractVV(center2, center))); - body1.SetLinearVelocity(velocity1); - body2.SetLinearVelocity(velocity2); - body1.SetAngularVelocity(angularVelocity); - body2.SetAngularVelocity(angularVelocity); - body1.SynchronizeFixtures(); - body2.SynchronizeFixtures(); - return body2; - } - b2Body.prototype.Merge = function (other) { - var f; - for (f = other.m_fixtureList; - f;) { - var next = f.m_next; - other.m_fixtureCount--; - f.m_next = this.m_fixtureList; - this.m_fixtureList = f; - this.m_fixtureCount++; - f.m_body = body2; - f = next; - } - body1.m_fixtureCount = 0; - var body1 = this; - - var body2 = other; - var center1 = body1.GetWorldCenter(); - var center2 = body2.GetWorldCenter(); - var velocity1 = body1.GetLinearVelocity().Copy(); - var velocity2 = body2.GetLinearVelocity().Copy(); - var angular1 = body1.GetAngularVelocity(); - var angular = body2.GetAngularVelocity(); - body1.ResetMassData(); - this.SynchronizeFixtures(); - } - b2Body.prototype.GetMass = function () { - return this.m_mass; - } - b2Body.prototype.GetInertia = function () { - return this.m_I; - } - b2Body.prototype.GetMassData = function (data) { - data.mass = this.m_mass; - data.I = this.m_I; - data.center.SetV(this.m_sweep.localCenter); - } - b2Body.prototype.SetMassData = function (massData) { - b2Settings.b2Assert(this.m_world.IsLocked() == false); - if (this.m_world.IsLocked() == true) { - return; - } - if (this.m_type != b2Body.b2_dynamicBody) { - return; - } - this.m_invMass = 0.0; - this.m_I = 0.0; - this.m_invI = 0.0; - this.m_mass = massData.mass; - if (this.m_mass <= 0.0) { - this.m_mass = 1.0; - } - this.m_invMass = 1.0 / this.m_mass; - if (massData.I > 0.0 && (this.m_flags & b2Body.e_fixedRotationFlag) == 0) { - this.m_I = massData.I - this.m_mass * (massData.center.x * massData.center.x + massData.center.y * massData.center.y); - this.m_invI = 1.0 / this.m_I; - } - var oldCenter = this.m_sweep.c.Copy(); - this.m_sweep.localCenter.SetV(massData.center); - this.m_sweep.c0.SetV(b2Math.MulX(this.m_xf, this.m_sweep.localCenter)); - this.m_sweep.c.SetV(this.m_sweep.c0); - this.m_linearVelocity.x += this.m_angularVelocity * (-(this.m_sweep.c.y - oldCenter.y)); - this.m_linearVelocity.y += this.m_angularVelocity * (+(this.m_sweep.c.x - oldCenter.x)); - } - b2Body.prototype.ResetMassData = function () { - this.m_mass = 0.0; - this.m_invMass = 0.0; - this.m_I = 0.0; - this.m_invI = 0.0; - this.m_sweep.localCenter.SetZero(); - if (this.m_type == b2Body.b2_staticBody || this.m_type == b2Body.b2_kinematicBody) { - return; - } - var center = b2Vec2.Make(0, 0); - for (var f = this.m_fixtureList; f; f = f.m_next) { - if (f.m_density == 0.0) { - continue; - } - var massData = f.GetMassData(); - this.m_mass += massData.mass; - center.x += massData.center.x * massData.mass; - center.y += massData.center.y * massData.mass; - this.m_I += massData.I; - } - if (this.m_mass > 0.0) { - this.m_invMass = 1.0 / this.m_mass; - center.x *= this.m_invMass; - center.y *= this.m_invMass; - } - else { - this.m_mass = 1.0; - this.m_invMass = 1.0; - } - if (this.m_I > 0.0 && (this.m_flags & b2Body.e_fixedRotationFlag) == 0) { - this.m_I -= this.m_mass * (center.x * center.x + center.y * center.y); - this.m_I *= this.m_inertiaScale; - b2Settings.b2Assert(this.m_I > 0); - this.m_invI = 1.0 / this.m_I; - } - else { - this.m_I = 0.0; - this.m_invI = 0.0; - } - var oldCenter = this.m_sweep.c.Copy(); - this.m_sweep.localCenter.SetV(center); - this.m_sweep.c0.SetV(b2Math.MulX(this.m_xf, this.m_sweep.localCenter)); - this.m_sweep.c.SetV(this.m_sweep.c0); - this.m_linearVelocity.x += this.m_angularVelocity * (-(this.m_sweep.c.y - oldCenter.y)); - this.m_linearVelocity.y += this.m_angularVelocity * (+(this.m_sweep.c.x - oldCenter.x)); - } - b2Body.prototype.GetWorldPoint = function (localPoint) { - var A = this.m_xf.R; - var u = new b2Vec2(A.col1.x * localPoint.x + A.col2.x * localPoint.y, A.col1.y * localPoint.x + A.col2.y * localPoint.y); - u.x += this.m_xf.position.x; - u.y += this.m_xf.position.y; - return u; - } - b2Body.prototype.GetWorldVector = function (localVector) { - return b2Math.MulMV(this.m_xf.R, localVector); - } - b2Body.prototype.GetLocalPoint = function (worldPoint) { - return b2Math.MulXT(this.m_xf, worldPoint); - } - b2Body.prototype.GetLocalVector = function (worldVector) { - return b2Math.MulTMV(this.m_xf.R, worldVector); - } - b2Body.prototype.GetLinearVelocityFromWorldPoint = function (worldPoint) { - return new b2Vec2(this.m_linearVelocity.x - this.m_angularVelocity * (worldPoint.y - this.m_sweep.c.y), this.m_linearVelocity.y + this.m_angularVelocity * (worldPoint.x - this.m_sweep.c.x)); - } - b2Body.prototype.GetLinearVelocityFromLocalPoint = function (localPoint) { - var A = this.m_xf.R; - var worldPoint = new b2Vec2(A.col1.x * localPoint.x + A.col2.x * localPoint.y, A.col1.y * localPoint.x + A.col2.y * localPoint.y); - worldPoint.x += this.m_xf.position.x; - worldPoint.y += this.m_xf.position.y; - return new b2Vec2(this.m_linearVelocity.x - this.m_angularVelocity * (worldPoint.y - this.m_sweep.c.y), this.m_linearVelocity.y + this.m_angularVelocity * (worldPoint.x - this.m_sweep.c.x)); - } - b2Body.prototype.GetLinearDamping = function () { - return this.m_linearDamping; - } - b2Body.prototype.SetLinearDamping = function (linearDamping) { - if (linearDamping === undefined) linearDamping = 0; - this.m_linearDamping = linearDamping; - } - b2Body.prototype.GetAngularDamping = function () { - return this.m_angularDamping; - } - b2Body.prototype.SetAngularDamping = function (angularDamping) { - if (angularDamping === undefined) angularDamping = 0; - this.m_angularDamping = angularDamping; - } - b2Body.prototype.SetType = function (type) { - if (type === undefined) type = 0; - if (this.m_type == type) { - return; - } - this.m_type = type; - this.ResetMassData(); - if (this.m_type == b2Body.b2_staticBody) { - this.m_linearVelocity.SetZero(); - this.m_angularVelocity = 0.0; - } - this.SetAwake(true); - this.m_force.SetZero(); - this.m_torque = 0.0; - for (var ce = this.m_contactList; ce; ce = ce.next) { - ce.contact.FlagForFiltering(); - } - } - b2Body.prototype.GetType = function () { - return this.m_type; - } - b2Body.prototype.SetBullet = function (flag) { - if (flag) { - this.m_flags |= b2Body.e_bulletFlag; - } - else { - this.m_flags &= ~b2Body.e_bulletFlag; - } - } - b2Body.prototype.IsBullet = function () { - return (this.m_flags & b2Body.e_bulletFlag) == b2Body.e_bulletFlag; - } - b2Body.prototype.SetSleepingAllowed = function (flag) { - if (flag) { - this.m_flags |= b2Body.e_allowSleepFlag; - } - else { - this.m_flags &= ~b2Body.e_allowSleepFlag; - this.SetAwake(true); - } - } - b2Body.prototype.SetAwake = function (flag) { - if (flag) { - this.m_flags |= b2Body.e_awakeFlag; - this.m_sleepTime = 0.0; - } - else { - this.m_flags &= ~b2Body.e_awakeFlag; - this.m_sleepTime = 0.0; - this.m_linearVelocity.SetZero(); - this.m_angularVelocity = 0.0; - this.m_force.SetZero(); - this.m_torque = 0.0; - } - } - b2Body.prototype.IsAwake = function () { - return (this.m_flags & b2Body.e_awakeFlag) == b2Body.e_awakeFlag; - } - b2Body.prototype.SetFixedRotation = function (fixed) { - if (fixed) { - this.m_flags |= b2Body.e_fixedRotationFlag; - } - else { - this.m_flags &= ~b2Body.e_fixedRotationFlag; - } - this.ResetMassData(); - } - b2Body.prototype.IsFixedRotation = function () { - return (this.m_flags & b2Body.e_fixedRotationFlag) == b2Body.e_fixedRotationFlag; - } - b2Body.prototype.SetActive = function (flag) { - if (flag == this.IsActive()) { - return; - } - var broadPhase; - var f; - if (flag) { - this.m_flags |= b2Body.e_activeFlag; - broadPhase = this.m_world.m_contactManager.m_broadPhase; - for (f = this.m_fixtureList; - f; f = f.m_next) { - f.CreateProxy(broadPhase, this.m_xf); - } - } - else { - this.m_flags &= ~b2Body.e_activeFlag; - broadPhase = this.m_world.m_contactManager.m_broadPhase; - for (f = this.m_fixtureList; - f; f = f.m_next) { - f.DestroyProxy(broadPhase); - } - var ce = this.m_contactList; - while (ce) { - var ce0 = ce; - ce = ce.next; - this.m_world.m_contactManager.Destroy(ce0.contact); - } - this.m_contactList = null; - } - } - b2Body.prototype.IsActive = function () { - return (this.m_flags & b2Body.e_activeFlag) == b2Body.e_activeFlag; - } - b2Body.prototype.IsSleepingAllowed = function () { - return (this.m_flags & b2Body.e_allowSleepFlag) == b2Body.e_allowSleepFlag; - } - b2Body.prototype.GetFixtureList = function () { - return this.m_fixtureList; - } - b2Body.prototype.GetJointList = function () { - return this.m_jointList; - } - b2Body.prototype.GetControllerList = function () { - return this.m_controllerList; - } - b2Body.prototype.GetContactList = function () { - return this.m_contactList; - } - b2Body.prototype.GetNext = function () { - return this.m_next; - } - b2Body.prototype.GetUserData = function () { - return this.m_userData; - } - b2Body.prototype.SetUserData = function (data) { - this.m_userData = data; - } - b2Body.prototype.GetWorld = function () { - return this.m_world; - } - b2Body.prototype.b2Body = function (bd, world) { - this.m_flags = 0; - if (bd.bullet) { - this.m_flags |= b2Body.e_bulletFlag; - } - if (bd.fixedRotation) { - this.m_flags |= b2Body.e_fixedRotationFlag; - } - if (bd.allowSleep) { - this.m_flags |= b2Body.e_allowSleepFlag; - } - if (bd.awake) { - this.m_flags |= b2Body.e_awakeFlag; - } - if (bd.active) { - this.m_flags |= b2Body.e_activeFlag; - } - this.m_world = world; - this.m_xf.position.SetV(bd.position); - this.m_xf.R.Set(bd.angle); - this.m_sweep.localCenter.SetZero(); - this.m_sweep.t0 = 1.0; - this.m_sweep.a0 = this.m_sweep.a = bd.angle; - var tMat = this.m_xf.R; - var tVec = this.m_sweep.localCenter; - this.m_sweep.c.x = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - this.m_sweep.c.y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - this.m_sweep.c.x += this.m_xf.position.x; - this.m_sweep.c.y += this.m_xf.position.y; - this.m_sweep.c0.SetV(this.m_sweep.c); - this.m_jointList = null; - this.m_controllerList = null; - this.m_contactList = null; - this.m_controllerCount = 0; - this.m_prev = null; - this.m_next = null; - this.m_linearVelocity.SetV(bd.linearVelocity); - this.m_angularVelocity = bd.angularVelocity; - this.m_linearDamping = bd.linearDamping; - this.m_angularDamping = bd.angularDamping; - this.m_force.Set(0.0, 0.0); - this.m_torque = 0.0; - this.m_sleepTime = 0.0; - this.m_type = bd.type; - if (this.m_type == b2Body.b2_dynamicBody) { - this.m_mass = 1.0; - this.m_invMass = 1.0; - } - else { - this.m_mass = 0.0; - this.m_invMass = 0.0; - } - this.m_I = 0.0; - this.m_invI = 0.0; - this.m_inertiaScale = bd.inertiaScale; - this.m_userData = bd.userData; - this.m_fixtureList = null; - this.m_fixtureCount = 0; - } - b2Body.prototype.SynchronizeFixtures = function () { - var xf1 = b2Body.s_xf1; - xf1.R.Set(this.m_sweep.a0); - var tMat = xf1.R; - var tVec = this.m_sweep.localCenter; - xf1.position.x = this.m_sweep.c0.x - (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - xf1.position.y = this.m_sweep.c0.y - (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - var f; - var broadPhase = this.m_world.m_contactManager.m_broadPhase; - for (f = this.m_fixtureList; - f; f = f.m_next) { - f.Synchronize(broadPhase, xf1, this.m_xf); - } - } - b2Body.prototype.SynchronizeTransform = function () { - this.m_xf.R.Set(this.m_sweep.a); - var tMat = this.m_xf.R; - var tVec = this.m_sweep.localCenter; - this.m_xf.position.x = this.m_sweep.c.x - (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - this.m_xf.position.y = this.m_sweep.c.y - (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - } - b2Body.prototype.ShouldCollide = function (other) { - if (this.m_type != b2Body.b2_dynamicBody && other.m_type != b2Body.b2_dynamicBody) { - return false; - } - for (var jn = this.m_jointList; jn; jn = jn.next) { - if (jn.other == other) if (jn.joint.m_collideConnected == false) { - return false; - } - } - return true; - } - b2Body.prototype.Advance = function (t) { - if (t === undefined) t = 0; - this.m_sweep.Advance(t); - this.m_sweep.c.SetV(this.m_sweep.c0); - this.m_sweep.a = this.m_sweep.a0; - this.SynchronizeTransform(); - } - Box2D.postDefs.push(function () { - Box2D.Dynamics.b2Body.s_xf1 = new b2Transform(); - Box2D.Dynamics.b2Body.e_islandFlag = 0x0001; - Box2D.Dynamics.b2Body.e_awakeFlag = 0x0002; - Box2D.Dynamics.b2Body.e_allowSleepFlag = 0x0004; - Box2D.Dynamics.b2Body.e_bulletFlag = 0x0008; - Box2D.Dynamics.b2Body.e_fixedRotationFlag = 0x0010; - Box2D.Dynamics.b2Body.e_activeFlag = 0x0020; - Box2D.Dynamics.b2Body.b2_staticBody = 0; - Box2D.Dynamics.b2Body.b2_kinematicBody = 1; - Box2D.Dynamics.b2Body.b2_dynamicBody = 2; - }); - b2BodyDef.b2BodyDef = function () { - this.position = new b2Vec2(); - this.linearVelocity = new b2Vec2(); - }; - b2BodyDef.prototype.b2BodyDef = function () { - this.userData = null; - this.position.Set(0.0, 0.0); - this.angle = 0.0; - this.linearVelocity.Set(0, 0); - this.angularVelocity = 0.0; - this.linearDamping = 0.0; - this.angularDamping = 0.0; - this.allowSleep = true; - this.awake = true; - this.fixedRotation = false; - this.bullet = false; - this.type = b2Body.b2_staticBody; - this.active = true; - this.inertiaScale = 1.0; - } - b2ContactFilter.b2ContactFilter = function () {}; - b2ContactFilter.prototype.ShouldCollide = function (fixtureA, fixtureB) { - var filter1 = fixtureA.GetFilterData(); - var filter2 = fixtureB.GetFilterData(); - if (filter1.groupIndex == filter2.groupIndex && filter1.groupIndex != 0) { - return filter1.groupIndex > 0; - } - var collide = (filter1.maskBits & filter2.categoryBits) != 0 && (filter1.categoryBits & filter2.maskBits) != 0; - return collide; - } - b2ContactFilter.prototype.RayCollide = function (userData, fixture) { - if (!userData) return true; - return this.ShouldCollide((userData instanceof b2Fixture ? userData : null), fixture); - } - Box2D.postDefs.push(function () { - Box2D.Dynamics.b2ContactFilter.b2_defaultFilter = new b2ContactFilter(); - }); - b2ContactImpulse.b2ContactImpulse = function () { - this.normalImpulses = new Vector_a2j_Number(b2Settings.b2_maxManifoldPoints); - this.tangentImpulses = new Vector_a2j_Number(b2Settings.b2_maxManifoldPoints); - }; - b2ContactListener.b2ContactListener = function () {}; - b2ContactListener.prototype.BeginContact = function (contact) {} - b2ContactListener.prototype.EndContact = function (contact) {} - b2ContactListener.prototype.PreSolve = function (contact, oldManifold) {} - b2ContactListener.prototype.PostSolve = function (contact, impulse) {} - Box2D.postDefs.push(function () { - Box2D.Dynamics.b2ContactListener.b2_defaultListener = new b2ContactListener(); - }); - b2ContactManager.b2ContactManager = function () {}; - b2ContactManager.prototype.b2ContactManager = function () { - this.m_world = null; - this.m_contactCount = 0; - this.m_contactFilter = b2ContactFilter.b2_defaultFilter; - this.m_contactListener = b2ContactListener.b2_defaultListener; - this.m_contactFactory = new b2ContactFactory(this.m_allocator); - this.m_broadPhase = new b2DynamicTreeBroadPhase(); - } - b2ContactManager.prototype.AddPair = function (proxyUserDataA, proxyUserDataB) { - var fixtureA = (proxyUserDataA instanceof b2Fixture ? proxyUserDataA : null); - var fixtureB = (proxyUserDataB instanceof b2Fixture ? proxyUserDataB : null); - var bodyA = fixtureA.GetBody(); - var bodyB = fixtureB.GetBody(); - if (bodyA == bodyB) return; - var edge = bodyB.GetContactList(); - while (edge) { - if (edge.other == bodyA) { - var fA = edge.contact.GetFixtureA(); - var fB = edge.contact.GetFixtureB(); - if (fA == fixtureA && fB == fixtureB) return; - if (fA == fixtureB && fB == fixtureA) return; - } - edge = edge.next; - } - if (bodyB.ShouldCollide(bodyA) == false) { - return; - } - if (this.m_contactFilter.ShouldCollide(fixtureA, fixtureB) == false) { - return; - } - var c = this.m_contactFactory.Create(fixtureA, fixtureB); - fixtureA = c.GetFixtureA(); - fixtureB = c.GetFixtureB(); - bodyA = fixtureA.m_body; - bodyB = fixtureB.m_body; - c.m_prev = null; - c.m_next = this.m_world.m_contactList; - if (this.m_world.m_contactList != null) { - this.m_world.m_contactList.m_prev = c; - } - this.m_world.m_contactList = c; - c.m_nodeA.contact = c; - c.m_nodeA.other = bodyB; - c.m_nodeA.prev = null; - c.m_nodeA.next = bodyA.m_contactList; - if (bodyA.m_contactList != null) { - bodyA.m_contactList.prev = c.m_nodeA; - } - bodyA.m_contactList = c.m_nodeA; - c.m_nodeB.contact = c; - c.m_nodeB.other = bodyA; - c.m_nodeB.prev = null; - c.m_nodeB.next = bodyB.m_contactList; - if (bodyB.m_contactList != null) { - bodyB.m_contactList.prev = c.m_nodeB; - } - bodyB.m_contactList = c.m_nodeB; - ++this.m_world.m_contactCount; - return; - } - b2ContactManager.prototype.FindNewContacts = function () { - this.m_broadPhase.UpdatePairs(Box2D.generateCallback(this, this.AddPair)); - } - b2ContactManager.prototype.Destroy = function (c) { - var fixtureA = c.GetFixtureA(); - var fixtureB = c.GetFixtureB(); - var bodyA = fixtureA.GetBody(); - var bodyB = fixtureB.GetBody(); - if (c.IsTouching()) { - this.m_contactListener.EndContact(c); - } - if (c.m_prev) { - c.m_prev.m_next = c.m_next; - } - if (c.m_next) { - c.m_next.m_prev = c.m_prev; - } - if (c == this.m_world.m_contactList) { - this.m_world.m_contactList = c.m_next; - } - if (c.m_nodeA.prev) { - c.m_nodeA.prev.next = c.m_nodeA.next; - } - if (c.m_nodeA.next) { - c.m_nodeA.next.prev = c.m_nodeA.prev; - } - if (c.m_nodeA == bodyA.m_contactList) { - bodyA.m_contactList = c.m_nodeA.next; - } - if (c.m_nodeB.prev) { - c.m_nodeB.prev.next = c.m_nodeB.next; - } - if (c.m_nodeB.next) { - c.m_nodeB.next.prev = c.m_nodeB.prev; - } - if (c.m_nodeB == bodyB.m_contactList) { - bodyB.m_contactList = c.m_nodeB.next; - } - this.m_contactFactory.Destroy(c); - --this.m_contactCount; - } - b2ContactManager.prototype.Collide = function () { - var c = this.m_world.m_contactList; - while (c) { - var fixtureA = c.GetFixtureA(); - var fixtureB = c.GetFixtureB(); - var bodyA = fixtureA.GetBody(); - var bodyB = fixtureB.GetBody(); - if (bodyA.IsAwake() == false && bodyB.IsAwake() == false) { - c = c.GetNext(); - continue; - } - if (c.m_flags & b2Contact.e_filterFlag) { - if (bodyB.ShouldCollide(bodyA) == false) { - var cNuke = c; - c = cNuke.GetNext(); - this.Destroy(cNuke); - continue; - } - if (this.m_contactFilter.ShouldCollide(fixtureA, fixtureB) == false) { - cNuke = c; - c = cNuke.GetNext(); - this.Destroy(cNuke); - continue; - } - c.m_flags &= ~b2Contact.e_filterFlag; - } - var proxyA = fixtureA.m_proxy; - var proxyB = fixtureB.m_proxy; - var overlap = this.m_broadPhase.TestOverlap(proxyA, proxyB); - if (overlap == false) { - cNuke = c; - c = cNuke.GetNext(); - this.Destroy(cNuke); - continue; - } - c.Update(this.m_contactListener); - c = c.GetNext(); - } - } - Box2D.postDefs.push(function () { - Box2D.Dynamics.b2ContactManager.s_evalCP = new b2ContactPoint(); - }); - b2DebugDraw.b2DebugDraw = function () {}; - b2DebugDraw.prototype.b2DebugDraw = function () {} - b2DebugDraw.prototype.SetFlags = function (flags) { - if (flags === undefined) flags = 0; - } - b2DebugDraw.prototype.GetFlags = function () {} - b2DebugDraw.prototype.AppendFlags = function (flags) { - if (flags === undefined) flags = 0; - } - b2DebugDraw.prototype.ClearFlags = function (flags) { - if (flags === undefined) flags = 0; - } - b2DebugDraw.prototype.SetSprite = function (sprite) {} - b2DebugDraw.prototype.GetSprite = function () {} - b2DebugDraw.prototype.SetDrawScale = function (drawScale) { - if (drawScale === undefined) drawScale = 0; - } - b2DebugDraw.prototype.GetDrawScale = function () {} - b2DebugDraw.prototype.SetLineThickness = function (lineThickness) { - if (lineThickness === undefined) lineThickness = 0; - } - b2DebugDraw.prototype.GetLineThickness = function () {} - b2DebugDraw.prototype.SetAlpha = function (alpha) { - if (alpha === undefined) alpha = 0; - } - b2DebugDraw.prototype.GetAlpha = function () {} - b2DebugDraw.prototype.SetFillAlpha = function (alpha) { - if (alpha === undefined) alpha = 0; - } - b2DebugDraw.prototype.GetFillAlpha = function () {} - b2DebugDraw.prototype.SetXFormScale = function (xformScale) { - if (xformScale === undefined) xformScale = 0; - } - b2DebugDraw.prototype.GetXFormScale = function () {} - b2DebugDraw.prototype.DrawPolygon = function (vertices, vertexCount, color) { - if (vertexCount === undefined) vertexCount = 0; - } - b2DebugDraw.prototype.DrawSolidPolygon = function (vertices, vertexCount, color) { - if (vertexCount === undefined) vertexCount = 0; - } - b2DebugDraw.prototype.DrawCircle = function (center, radius, color) { - if (radius === undefined) radius = 0; - } - b2DebugDraw.prototype.DrawSolidCircle = function (center, radius, axis, color) { - if (radius === undefined) radius = 0; - } - b2DebugDraw.prototype.DrawSegment = function (p1, p2, color) {} - b2DebugDraw.prototype.DrawTransform = function (xf) {} - Box2D.postDefs.push(function () { - Box2D.Dynamics.b2DebugDraw.e_shapeBit = 0x0001; - Box2D.Dynamics.b2DebugDraw.e_jointBit = 0x0002; - Box2D.Dynamics.b2DebugDraw.e_aabbBit = 0x0004; - Box2D.Dynamics.b2DebugDraw.e_pairBit = 0x0008; - Box2D.Dynamics.b2DebugDraw.e_centerOfMassBit = 0x0010; - Box2D.Dynamics.b2DebugDraw.e_controllerBit = 0x0020; - }); - b2DestructionListener.b2DestructionListener = function () {}; - b2DestructionListener.prototype.SayGoodbyeJoint = function (joint) {} - b2DestructionListener.prototype.SayGoodbyeFixture = function (fixture) {} - b2FilterData.b2FilterData = function () { - this.categoryBits = 0x0001; - this.maskBits = 0xFFFF; - this.groupIndex = 0; - }; - b2FilterData.prototype.Copy = function () { - var copy = new b2FilterData(); - copy.categoryBits = this.categoryBits; - copy.maskBits = this.maskBits; - copy.groupIndex = this.groupIndex; - return copy; - } - b2Fixture.b2Fixture = function () { - this.m_filter = new b2FilterData(); - }; - b2Fixture.prototype.GetType = function () { - return this.m_shape.GetType(); - } - b2Fixture.prototype.GetShape = function () { - return this.m_shape; - } - b2Fixture.prototype.SetSensor = function (sensor) { - if (this.m_isSensor == sensor) return; - this.m_isSensor = sensor; - if (this.m_body == null) return; - var edge = this.m_body.GetContactList(); - while (edge) { - var contact = edge.contact; - var fixtureA = contact.GetFixtureA(); - var fixtureB = contact.GetFixtureB(); - if (fixtureA == this || fixtureB == this) contact.SetSensor(fixtureA.IsSensor() || fixtureB.IsSensor()); - edge = edge.next; - } - } - b2Fixture.prototype.IsSensor = function () { - return this.m_isSensor; - } - b2Fixture.prototype.SetFilterData = function (filter) { - this.m_filter = filter.Copy(); - if (this.m_body) return; - var edge = this.m_body.GetContactList(); - while (edge) { - var contact = edge.contact; - var fixtureA = contact.GetFixtureA(); - var fixtureB = contact.GetFixtureB(); - if (fixtureA == this || fixtureB == this) contact.FlagForFiltering(); - edge = edge.next; - } - } - b2Fixture.prototype.GetFilterData = function () { - return this.m_filter.Copy(); - } - b2Fixture.prototype.GetBody = function () { - return this.m_body; - } - b2Fixture.prototype.GetNext = function () { - return this.m_next; - } - b2Fixture.prototype.GetUserData = function () { - return this.m_userData; - } - b2Fixture.prototype.SetUserData = function (data) { - this.m_userData = data; - } - b2Fixture.prototype.TestPoint = function (p) { - return this.m_shape.TestPoint(this.m_body.GetTransform(), p); - } - b2Fixture.prototype.RayCast = function (output, input) { - return this.m_shape.RayCast(output, input, this.m_body.GetTransform()); - } - b2Fixture.prototype.GetMassData = function (massData) { - if (massData === undefined) massData = null; - if (massData == null) { - massData = new b2MassData(); - } - this.m_shape.ComputeMass(massData, this.m_density); - return massData; - } - b2Fixture.prototype.SetDensity = function (density) { - if (density === undefined) density = 0; - this.m_density = density; - } - b2Fixture.prototype.GetDensity = function () { - return this.m_density; - } - b2Fixture.prototype.GetFriction = function () { - return this.m_friction; - } - b2Fixture.prototype.SetFriction = function (friction) { - if (friction === undefined) friction = 0; - this.m_friction = friction; - } - b2Fixture.prototype.GetRestitution = function () { - return this.m_restitution; - } - b2Fixture.prototype.SetRestitution = function (restitution) { - if (restitution === undefined) restitution = 0; - this.m_restitution = restitution; - } - b2Fixture.prototype.GetAABB = function () { - return this.m_aabb; - } - b2Fixture.prototype.b2Fixture = function () { - this.m_aabb = new b2AABB(); - this.m_userData = null; - this.m_body = null; - this.m_next = null; - this.m_shape = null; - this.m_density = 0.0; - this.m_friction = 0.0; - this.m_restitution = 0.0; - } - b2Fixture.prototype.Create = function (body, xf, def) { - this.m_userData = def.userData; - this.m_friction = def.friction; - this.m_restitution = def.restitution; - this.m_body = body; - this.m_next = null; - this.m_filter = def.filter.Copy(); - this.m_isSensor = def.isSensor; - this.m_shape = def.shape.Copy(); - this.m_density = def.density; - } - b2Fixture.prototype.Destroy = function () { - this.m_shape = null; - } - b2Fixture.prototype.CreateProxy = function (broadPhase, xf) { - this.m_shape.ComputeAABB(this.m_aabb, xf); - this.m_proxy = broadPhase.CreateProxy(this.m_aabb, this); - } - b2Fixture.prototype.DestroyProxy = function (broadPhase) { - if (this.m_proxy == null) { - return; - } - broadPhase.DestroyProxy(this.m_proxy); - this.m_proxy = null; - } - b2Fixture.prototype.Synchronize = function (broadPhase, transform1, transform2) { - if (!this.m_proxy) return; - var aabb1 = new b2AABB(); - var aabb2 = new b2AABB(); - this.m_shape.ComputeAABB(aabb1, transform1); - this.m_shape.ComputeAABB(aabb2, transform2); - this.m_aabb.Combine(aabb1, aabb2); - var displacement = b2Math.SubtractVV(transform2.position, transform1.position); - broadPhase.MoveProxy(this.m_proxy, this.m_aabb, displacement); - } - b2FixtureDef.b2FixtureDef = function () { - this.filter = new b2FilterData(); - }; - b2FixtureDef.prototype.b2FixtureDef = function () { - this.shape = null; - this.userData = null; - this.friction = 0.2; - this.restitution = 0.0; - this.density = 0.0; - this.filter.categoryBits = 0x0001; - this.filter.maskBits = 0xFFFF; - this.filter.groupIndex = 0; - this.isSensor = false; - } - b2Island.b2Island = function () {}; - b2Island.prototype.b2Island = function () { - this.m_bodies = new Vector(); - this.m_contacts = new Vector(); - this.m_joints = new Vector(); - } - b2Island.prototype.Initialize = function (bodyCapacity, contactCapacity, jointCapacity, allocator, listener, contactSolver) { - if (bodyCapacity === undefined) bodyCapacity = 0; - if (contactCapacity === undefined) contactCapacity = 0; - if (jointCapacity === undefined) jointCapacity = 0; - var i = 0; - this.m_bodyCapacity = bodyCapacity; - this.m_contactCapacity = contactCapacity; - this.m_jointCapacity = jointCapacity; - this.m_bodyCount = 0; - this.m_contactCount = 0; - this.m_jointCount = 0; - this.m_allocator = allocator; - this.m_listener = listener; - this.m_contactSolver = contactSolver; - for (i = this.m_bodies.length; - i < bodyCapacity; i++) - this.m_bodies[i] = null; - for (i = this.m_contacts.length; - i < contactCapacity; i++) - this.m_contacts[i] = null; - for (i = this.m_joints.length; - i < jointCapacity; i++) - this.m_joints[i] = null; - } - b2Island.prototype.Clear = function () { - this.m_bodyCount = 0; - this.m_contactCount = 0; - this.m_jointCount = 0; - } - b2Island.prototype.Solve = function (step, gravity, allowSleep) { - var i = 0; - var j = 0; - var b; - var joint; - for (i = 0; - i < this.m_bodyCount; ++i) { - b = this.m_bodies[i]; - if (b.GetType() != b2Body.b2_dynamicBody) continue; - b.m_linearVelocity.x += step.dt * (gravity.x + b.m_invMass * b.m_force.x); - b.m_linearVelocity.y += step.dt * (gravity.y + b.m_invMass * b.m_force.y); - b.m_angularVelocity += step.dt * b.m_invI * b.m_torque; - b.m_linearVelocity.Multiply(b2Math.Clamp(1.0 - step.dt * b.m_linearDamping, 0.0, 1.0)); - b.m_angularVelocity *= b2Math.Clamp(1.0 - step.dt * b.m_angularDamping, 0.0, 1.0); - } - this.m_contactSolver.Initialize(step, this.m_contacts, this.m_contactCount, this.m_allocator); - var contactSolver = this.m_contactSolver; - contactSolver.InitVelocityConstraints(step); - for (i = 0; - i < this.m_jointCount; ++i) { - joint = this.m_joints[i]; - joint.InitVelocityConstraints(step); - } - for (i = 0; - i < step.velocityIterations; ++i) { - for (j = 0; - j < this.m_jointCount; ++j) { - joint = this.m_joints[j]; - joint.SolveVelocityConstraints(step); - } - contactSolver.SolveVelocityConstraints(); - } - for (i = 0; - i < this.m_jointCount; ++i) { - joint = this.m_joints[i]; - joint.FinalizeVelocityConstraints(); - } - contactSolver.FinalizeVelocityConstraints(); - for (i = 0; - i < this.m_bodyCount; ++i) { - b = this.m_bodies[i]; - if (b.GetType() == b2Body.b2_staticBody) continue; - var translationX = step.dt * b.m_linearVelocity.x; - var translationY = step.dt * b.m_linearVelocity.y; - if ((translationX * translationX + translationY * translationY) > b2Settings.b2_maxTranslationSquared) { - b.m_linearVelocity.Normalize(); - b.m_linearVelocity.x *= b2Settings.b2_maxTranslation * step.inv_dt; - b.m_linearVelocity.y *= b2Settings.b2_maxTranslation * step.inv_dt; - } - var rotation = step.dt * b.m_angularVelocity; - if (rotation * rotation > b2Settings.b2_maxRotationSquared) { - if (b.m_angularVelocity < 0.0) { - b.m_angularVelocity = (-b2Settings.b2_maxRotation * step.inv_dt); - } - else { - b.m_angularVelocity = b2Settings.b2_maxRotation * step.inv_dt; - } - } - b.m_sweep.c0.SetV(b.m_sweep.c); - b.m_sweep.a0 = b.m_sweep.a; - b.m_sweep.c.x += step.dt * b.m_linearVelocity.x; - b.m_sweep.c.y += step.dt * b.m_linearVelocity.y; - b.m_sweep.a += step.dt * b.m_angularVelocity; - b.SynchronizeTransform(); - } - for (i = 0; - i < step.positionIterations; ++i) { - var contactsOkay = contactSolver.SolvePositionConstraints(b2Settings.b2_contactBaumgarte); - var jointsOkay = true; - for (j = 0; - j < this.m_jointCount; ++j) { - joint = this.m_joints[j]; - var jointOkay = joint.SolvePositionConstraints(b2Settings.b2_contactBaumgarte); - jointsOkay = jointsOkay && jointOkay; - } - if (contactsOkay && jointsOkay) { - break; - } - } - this.Report(contactSolver.m_constraints); - if (allowSleep) { - var minSleepTime = Number.MAX_VALUE; - var linTolSqr = b2Settings.b2_linearSleepTolerance * b2Settings.b2_linearSleepTolerance; - var angTolSqr = b2Settings.b2_angularSleepTolerance * b2Settings.b2_angularSleepTolerance; - for (i = 0; - i < this.m_bodyCount; ++i) { - b = this.m_bodies[i]; - if (b.GetType() == b2Body.b2_staticBody) { - continue; - } - if ((b.m_flags & b2Body.e_allowSleepFlag) == 0) { - b.m_sleepTime = 0.0; - minSleepTime = 0.0; - } - if ((b.m_flags & b2Body.e_allowSleepFlag) == 0 || b.m_angularVelocity * b.m_angularVelocity > angTolSqr || b2Math.Dot(b.m_linearVelocity, b.m_linearVelocity) > linTolSqr) { - b.m_sleepTime = 0.0; - minSleepTime = 0.0; - } - else { - b.m_sleepTime += step.dt; - minSleepTime = b2Math.Min(minSleepTime, b.m_sleepTime); - } - } - if (minSleepTime >= b2Settings.b2_timeToSleep) { - for (i = 0; - i < this.m_bodyCount; ++i) { - b = this.m_bodies[i]; - b.SetAwake(false); - } - } - } - } - b2Island.prototype.SolveTOI = function (subStep) { - var i = 0; - var j = 0; - this.m_contactSolver.Initialize(subStep, this.m_contacts, this.m_contactCount, this.m_allocator); - var contactSolver = this.m_contactSolver; - for (i = 0; - i < this.m_jointCount; ++i) { - this.m_joints[i].InitVelocityConstraints(subStep); - } - for (i = 0; - i < subStep.velocityIterations; ++i) { - contactSolver.SolveVelocityConstraints(); - for (j = 0; - j < this.m_jointCount; ++j) { - this.m_joints[j].SolveVelocityConstraints(subStep); - } - } - for (i = 0; - i < this.m_bodyCount; ++i) { - var b = this.m_bodies[i]; - if (b.GetType() == b2Body.b2_staticBody) continue; - var translationX = subStep.dt * b.m_linearVelocity.x; - var translationY = subStep.dt * b.m_linearVelocity.y; - if ((translationX * translationX + translationY * translationY) > b2Settings.b2_maxTranslationSquared) { - b.m_linearVelocity.Normalize(); - b.m_linearVelocity.x *= b2Settings.b2_maxTranslation * subStep.inv_dt; - b.m_linearVelocity.y *= b2Settings.b2_maxTranslation * subStep.inv_dt; - } - var rotation = subStep.dt * b.m_angularVelocity; - if (rotation * rotation > b2Settings.b2_maxRotationSquared) { - if (b.m_angularVelocity < 0.0) { - b.m_angularVelocity = (-b2Settings.b2_maxRotation * subStep.inv_dt); - } - else { - b.m_angularVelocity = b2Settings.b2_maxRotation * subStep.inv_dt; - } - } - b.m_sweep.c0.SetV(b.m_sweep.c); - b.m_sweep.a0 = b.m_sweep.a; - b.m_sweep.c.x += subStep.dt * b.m_linearVelocity.x; - b.m_sweep.c.y += subStep.dt * b.m_linearVelocity.y; - b.m_sweep.a += subStep.dt * b.m_angularVelocity; - b.SynchronizeTransform(); - } - var k_toiBaumgarte = 0.75; - for (i = 0; - i < subStep.positionIterations; ++i) { - var contactsOkay = contactSolver.SolvePositionConstraints(k_toiBaumgarte); - var jointsOkay = true; - for (j = 0; - j < this.m_jointCount; ++j) { - var jointOkay = this.m_joints[j].SolvePositionConstraints(b2Settings.b2_contactBaumgarte); - jointsOkay = jointsOkay && jointOkay; - } - if (contactsOkay && jointsOkay) { - break; - } - } - this.Report(contactSolver.m_constraints); - } - b2Island.prototype.Report = function (constraints) { - if (this.m_listener == null) { - return; - } - for (var i = 0; i < this.m_contactCount; ++i) { - var c = this.m_contacts[i]; - var cc = constraints[i]; - for (var j = 0; j < cc.pointCount; ++j) { - b2Island.s_impulse.normalImpulses[j] = cc.points[j].normalImpulse; - b2Island.s_impulse.tangentImpulses[j] = cc.points[j].tangentImpulse; - } - this.m_listener.PostSolve(c, b2Island.s_impulse); - } - } - b2Island.prototype.AddBody = function (body) { - body.m_islandIndex = this.m_bodyCount; - this.m_bodies[this.m_bodyCount++] = body; - } - b2Island.prototype.AddContact = function (contact) { - this.m_contacts[this.m_contactCount++] = contact; - } - b2Island.prototype.AddJoint = function (joint) { - this.m_joints[this.m_jointCount++] = joint; - } - Box2D.postDefs.push(function () { - Box2D.Dynamics.b2Island.s_impulse = new b2ContactImpulse(); - }); - b2TimeStep.b2TimeStep = function () {}; - b2TimeStep.prototype.Set = function (step) { - this.dt = step.dt; - this.inv_dt = step.inv_dt; - this.positionIterations = step.positionIterations; - this.velocityIterations = step.velocityIterations; - this.warmStarting = step.warmStarting; - } - b2World.b2World = function () { - this.s_stack = new Vector(); - this.m_contactManager = new b2ContactManager(); - this.m_contactSolver = new b2ContactSolver(); - this.m_island = new b2Island(); - }; - b2World.prototype.b2World = function (gravity, doSleep) { - this.m_destructionListener = null; - this.m_debugDraw = null; - this.m_bodyList = null; - this.m_contactList = null; - this.m_jointList = null; - this.m_controllerList = null; - this.m_bodyCount = 0; - this.m_contactCount = 0; - this.m_jointCount = 0; - this.m_controllerCount = 0; - b2World.m_warmStarting = true; - b2World.m_continuousPhysics = true; - this.m_allowSleep = doSleep; - this.m_gravity = gravity; - this.m_inv_dt0 = 0.0; - this.m_contactManager.m_world = this; - var bd = new b2BodyDef(); - this.m_groundBody = this.CreateBody(bd); - } - b2World.prototype.SetDestructionListener = function (listener) { - this.m_destructionListener = listener; - } - b2World.prototype.SetContactFilter = function (filter) { - this.m_contactManager.m_contactFilter = filter; - } - b2World.prototype.SetContactListener = function (listener) { - this.m_contactManager.m_contactListener = listener; - } - b2World.prototype.SetDebugDraw = function (debugDraw) { - this.m_debugDraw = debugDraw; - } - b2World.prototype.SetBroadPhase = function (broadPhase) { - var oldBroadPhase = this.m_contactManager.m_broadPhase; - this.m_contactManager.m_broadPhase = broadPhase; - for (var b = this.m_bodyList; b; b = b.m_next) { - for (var f = b.m_fixtureList; f; f = f.m_next) { - f.m_proxy = broadPhase.CreateProxy(oldBroadPhase.GetFatAABB(f.m_proxy), f); - } - } - } - b2World.prototype.Validate = function () { - this.m_contactManager.m_broadPhase.Validate(); - } - b2World.prototype.GetProxyCount = function () { - return this.m_contactManager.m_broadPhase.GetProxyCount(); - } - b2World.prototype.CreateBody = function (def) { - if (this.IsLocked() == true) { - return null; - } - var b = new b2Body(def, this); - b.m_prev = null; - b.m_next = this.m_bodyList; - if (this.m_bodyList) { - this.m_bodyList.m_prev = b; - } - this.m_bodyList = b; - ++this.m_bodyCount; - return b; - } - b2World.prototype.DestroyBody = function (b) { - if (this.IsLocked() == true) { - return; - } - var jn = b.m_jointList; - while (jn) { - var jn0 = jn; - jn = jn.next; - if (this.m_destructionListener) { - this.m_destructionListener.SayGoodbyeJoint(jn0.joint); - } - this.DestroyJoint(jn0.joint); - } - var coe = b.m_controllerList; - while (coe) { - var coe0 = coe; - coe = coe.nextController; - coe0.controller.RemoveBody(b); - } - var ce = b.m_contactList; - while (ce) { - var ce0 = ce; - ce = ce.next; - this.m_contactManager.Destroy(ce0.contact); - } - b.m_contactList = null; - var f = b.m_fixtureList; - while (f) { - var f0 = f; - f = f.m_next; - if (this.m_destructionListener) { - this.m_destructionListener.SayGoodbyeFixture(f0); - } - f0.DestroyProxy(this.m_contactManager.m_broadPhase); - f0.Destroy(); - } - b.m_fixtureList = null; - b.m_fixtureCount = 0; - if (b.m_prev) { - b.m_prev.m_next = b.m_next; - } - if (b.m_next) { - b.m_next.m_prev = b.m_prev; - } - if (b == this.m_bodyList) { - this.m_bodyList = b.m_next; - }--this.m_bodyCount; - } - b2World.prototype.CreateJoint = function (def) { - var j = b2Joint.Create(def, null); - j.m_prev = null; - j.m_next = this.m_jointList; - if (this.m_jointList) { - this.m_jointList.m_prev = j; - } - this.m_jointList = j; - ++this.m_jointCount; - j.m_edgeA.joint = j; - j.m_edgeA.other = j.m_bodyB; - j.m_edgeA.prev = null; - j.m_edgeA.next = j.m_bodyA.m_jointList; - if (j.m_bodyA.m_jointList) j.m_bodyA.m_jointList.prev = j.m_edgeA; - j.m_bodyA.m_jointList = j.m_edgeA; - j.m_edgeB.joint = j; - j.m_edgeB.other = j.m_bodyA; - j.m_edgeB.prev = null; - j.m_edgeB.next = j.m_bodyB.m_jointList; - if (j.m_bodyB.m_jointList) j.m_bodyB.m_jointList.prev = j.m_edgeB; - j.m_bodyB.m_jointList = j.m_edgeB; - var bodyA = def.bodyA; - var bodyB = def.bodyB; - if (def.collideConnected == false) { - var edge = bodyB.GetContactList(); - while (edge) { - if (edge.other == bodyA) { - edge.contact.FlagForFiltering(); - } - edge = edge.next; - } - } - return j; - } - b2World.prototype.DestroyJoint = function (j) { - var collideConnected = j.m_collideConnected; - if (j.m_prev) { - j.m_prev.m_next = j.m_next; - } - if (j.m_next) { - j.m_next.m_prev = j.m_prev; - } - if (j == this.m_jointList) { - this.m_jointList = j.m_next; - } - var bodyA = j.m_bodyA; - var bodyB = j.m_bodyB; - bodyA.SetAwake(true); - bodyB.SetAwake(true); - if (j.m_edgeA.prev) { - j.m_edgeA.prev.next = j.m_edgeA.next; - } - if (j.m_edgeA.next) { - j.m_edgeA.next.prev = j.m_edgeA.prev; - } - if (j.m_edgeA == bodyA.m_jointList) { - bodyA.m_jointList = j.m_edgeA.next; - } - j.m_edgeA.prev = null; - j.m_edgeA.next = null; - if (j.m_edgeB.prev) { - j.m_edgeB.prev.next = j.m_edgeB.next; - } - if (j.m_edgeB.next) { - j.m_edgeB.next.prev = j.m_edgeB.prev; - } - if (j.m_edgeB == bodyB.m_jointList) { - bodyB.m_jointList = j.m_edgeB.next; - } - j.m_edgeB.prev = null; - j.m_edgeB.next = null; - b2Joint.Destroy(j, null); - --this.m_jointCount; - if (collideConnected == false) { - var edge = bodyB.GetContactList(); - while (edge) { - if (edge.other == bodyA) { - edge.contact.FlagForFiltering(); - } - edge = edge.next; - } - } - } - b2World.prototype.AddController = function (c) { - c.m_next = this.m_controllerList; - c.m_prev = null; - this.m_controllerList = c; - c.m_world = this; - this.m_controllerCount++; - return c; - } - b2World.prototype.RemoveController = function (c) { - if (c.m_prev) c.m_prev.m_next = c.m_next; - if (c.m_next) c.m_next.m_prev = c.m_prev; - if (this.m_controllerList == c) this.m_controllerList = c.m_next; - this.m_controllerCount--; - } - b2World.prototype.CreateController = function (controller) { - if (controller.m_world != this) throw new Error("Controller can only be a member of one world"); - controller.m_next = this.m_controllerList; - controller.m_prev = null; - if (this.m_controllerList) this.m_controllerList.m_prev = controller; - this.m_controllerList = controller; - ++this.m_controllerCount; - controller.m_world = this; - return controller; - } - b2World.prototype.DestroyController = function (controller) { - controller.Clear(); - if (controller.m_next) controller.m_next.m_prev = controller.m_prev; - if (controller.m_prev) controller.m_prev.m_next = controller.m_next; - if (controller == this.m_controllerList) this.m_controllerList = controller.m_next; - --this.m_controllerCount; - } - b2World.prototype.SetWarmStarting = function (flag) { - b2World.m_warmStarting = flag; - } - b2World.prototype.SetContinuousPhysics = function (flag) { - b2World.m_continuousPhysics = flag; - } - b2World.prototype.GetBodyCount = function () { - return this.m_bodyCount; - } - b2World.prototype.GetJointCount = function () { - return this.m_jointCount; - } - b2World.prototype.GetContactCount = function () { - return this.m_contactCount; - } - b2World.prototype.SetGravity = function (gravity) { - this.m_gravity = gravity; - } - b2World.prototype.GetGravity = function () { - return this.m_gravity; - } - b2World.prototype.GetGroundBody = function () { - return this.m_groundBody; - } - b2World.prototype.Step = function (dt, velocityIterations, positionIterations) { - if (dt === undefined) dt = 0; - if (velocityIterations === undefined) velocityIterations = 0; - if (positionIterations === undefined) positionIterations = 0; - if (this.m_flags & b2World.e_newFixture) { - this.m_contactManager.FindNewContacts(); - this.m_flags &= ~b2World.e_newFixture; - } - this.m_flags |= b2World.e_locked; - var step = b2World.s_timestep2; - step.dt = dt; - step.velocityIterations = velocityIterations; - step.positionIterations = positionIterations; - if (dt > 0.0) { - step.inv_dt = 1.0 / dt; - } - else { - step.inv_dt = 0.0; - } - step.dtRatio = this.m_inv_dt0 * dt; - step.warmStarting = b2World.m_warmStarting; - this.m_contactManager.Collide(); - if (step.dt > 0.0) { - this.Solve(step); - } - if (b2World.m_continuousPhysics && step.dt > 0.0) { - this.SolveTOI(step); - } - if (step.dt > 0.0) { - this.m_inv_dt0 = step.inv_dt; - } - this.m_flags &= ~b2World.e_locked; - } - b2World.prototype.ClearForces = function () { - for (var body = this.m_bodyList; body; body = body.m_next) { - body.m_force.SetZero(); - body.m_torque = 0.0; - } - } - b2World.prototype.DrawDebugData = function () { - if (this.m_debugDraw == null) { - return; - } - this.m_debugDraw.m_sprite.graphics.clear(); - var flags = this.m_debugDraw.GetFlags(); - var i = 0; - var b; - var f; - var s; - var j; - var bp; - var invQ = new b2Vec2; - var x1 = new b2Vec2; - var x2 = new b2Vec2; - var xf; - var b1 = new b2AABB(); - var b2 = new b2AABB(); - var vs = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()]; - var color = new b2Color(0, 0, 0); - if (flags & b2DebugDraw.e_shapeBit) { - for (b = this.m_bodyList; - b; b = b.m_next) { - xf = b.m_xf; - for (f = b.GetFixtureList(); - f; f = f.m_next) { - s = f.GetShape(); - if (b.IsActive() == false) { - color.Set(0.5, 0.5, 0.3); - this.DrawShape(s, xf, color); - } - else if (b.GetType() == b2Body.b2_staticBody) { - color.Set(0.5, 0.9, 0.5); - this.DrawShape(s, xf, color); - } - else if (b.GetType() == b2Body.b2_kinematicBody) { - color.Set(0.5, 0.5, 0.9); - this.DrawShape(s, xf, color); - } - else if (b.IsAwake() == false) { - color.Set(0.6, 0.6, 0.6); - this.DrawShape(s, xf, color); - } - else { - color.Set(0.9, 0.7, 0.7); - this.DrawShape(s, xf, color); - } - } - } - } - if (flags & b2DebugDraw.e_jointBit) { - for (j = this.m_jointList; - j; j = j.m_next) { - this.DrawJoint(j); - } - } - if (flags & b2DebugDraw.e_controllerBit) { - for (var c = this.m_controllerList; c; c = c.m_next) { - c.Draw(this.m_debugDraw); - } - } - if (flags & b2DebugDraw.e_pairBit) { - color.Set(0.3, 0.9, 0.9); - for (var contact = this.m_contactManager.m_contactList; contact; contact = contact.GetNext()) { - var fixtureA = contact.GetFixtureA(); - var fixtureB = contact.GetFixtureB(); - var cA = fixtureA.GetAABB().GetCenter(); - var cB = fixtureB.GetAABB().GetCenter(); - this.m_debugDraw.DrawSegment(cA, cB, color); - } - } - if (flags & b2DebugDraw.e_aabbBit) { - bp = this.m_contactManager.m_broadPhase; - vs = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()]; - for (b = this.m_bodyList; - b; b = b.GetNext()) { - if (b.IsActive() == false) { - continue; - } - for (f = b.GetFixtureList(); - f; f = f.GetNext()) { - var aabb = bp.GetFatAABB(f.m_proxy); - vs[0].Set(aabb.lowerBound.x, aabb.lowerBound.y); - vs[1].Set(aabb.upperBound.x, aabb.lowerBound.y); - vs[2].Set(aabb.upperBound.x, aabb.upperBound.y); - vs[3].Set(aabb.lowerBound.x, aabb.upperBound.y); - this.m_debugDraw.DrawPolygon(vs, 4, color); - } - } - } - if (flags & b2DebugDraw.e_centerOfMassBit) { - for (b = this.m_bodyList; - b; b = b.m_next) { - xf = b2World.s_xf; - xf.R = b.m_xf.R; - xf.position = b.GetWorldCenter(); - this.m_debugDraw.DrawTransform(xf); - } - } - } - b2World.prototype.QueryAABB = function (callback, aabb) { - var __this = this; - var broadPhase = __this.m_contactManager.m_broadPhase; - - function WorldQueryWrapper(proxy) { - return callback(broadPhase.GetUserData(proxy)); - }; - broadPhase.Query(WorldQueryWrapper, aabb); - } - b2World.prototype.QueryShape = function (callback, shape, transform) { - var __this = this; - if (transform === undefined) transform = null; - if (transform == null) { - transform = new b2Transform(); - transform.SetIdentity(); - } - var broadPhase = __this.m_contactManager.m_broadPhase; - - function WorldQueryWrapper(proxy) { - var fixture = (broadPhase.GetUserData(proxy) instanceof b2Fixture ? broadPhase.GetUserData(proxy) : null); - if (b2Shape.TestOverlap(shape, transform, fixture.GetShape(), fixture.GetBody().GetTransform())) return callback(fixture); - return true; - }; - var aabb = new b2AABB(); - shape.ComputeAABB(aabb, transform); - broadPhase.Query(WorldQueryWrapper, aabb); - } - b2World.prototype.QueryPoint = function (callback, p) { - var __this = this; - var broadPhase = __this.m_contactManager.m_broadPhase; - - function WorldQueryWrapper(proxy) { - var fixture = (broadPhase.GetUserData(proxy) instanceof b2Fixture ? broadPhase.GetUserData(proxy) : null); - if (fixture.TestPoint(p)) return callback(fixture); - return true; - }; - var aabb = new b2AABB(); - aabb.lowerBound.Set(p.x - b2Settings.b2_linearSlop, p.y - b2Settings.b2_linearSlop); - aabb.upperBound.Set(p.x + b2Settings.b2_linearSlop, p.y + b2Settings.b2_linearSlop); - broadPhase.Query(WorldQueryWrapper, aabb); - } - b2World.prototype.RayCast = function (callback, point1, point2) { - var __this = this; - var broadPhase = __this.m_contactManager.m_broadPhase; - var output = new b2RayCastOutput; - - function RayCastWrapper(input, proxy) { - var userData = broadPhase.GetUserData(proxy); - var fixture = (userData instanceof b2Fixture ? userData : null); - var hit = fixture.RayCast(output, input); - if (hit) { - var fraction = output.fraction; - var point = new b2Vec2((1.0 - fraction) * point1.x + fraction * point2.x, (1.0 - fraction) * point1.y + fraction * point2.y); - return callback(fixture, point, output.normal, fraction); - } - return input.maxFraction; - }; - var input = new b2RayCastInput(point1, point2); - broadPhase.RayCast(RayCastWrapper, input); - } - b2World.prototype.RayCastOne = function (point1, point2) { - var __this = this; - var result; - - function RayCastOneWrapper(fixture, point, normal, fraction) { - if (fraction === undefined) fraction = 0; - result = fixture; - return fraction; - }; - __this.RayCast(RayCastOneWrapper, point1, point2); - return result; - } - b2World.prototype.RayCastAll = function (point1, point2) { - var __this = this; - var result = new Vector(); - - function RayCastAllWrapper(fixture, point, normal, fraction) { - if (fraction === undefined) fraction = 0; - result[result.length] = fixture; - return 1; - }; - __this.RayCast(RayCastAllWrapper, point1, point2); - return result; - } - b2World.prototype.GetBodyList = function () { - return this.m_bodyList; - } - b2World.prototype.GetJointList = function () { - return this.m_jointList; - } - b2World.prototype.GetContactList = function () { - return this.m_contactList; - } - b2World.prototype.IsLocked = function () { - return (this.m_flags & b2World.e_locked) > 0; - } - b2World.prototype.Solve = function (step) { - var b; - for (var controller = this.m_controllerList; controller; controller = controller.m_next) { - controller.Step(step); - } - var island = this.m_island; - island.Initialize(this.m_bodyCount, this.m_contactCount, this.m_jointCount, null, this.m_contactManager.m_contactListener, this.m_contactSolver); - for (b = this.m_bodyList; - b; b = b.m_next) { - b.m_flags &= ~b2Body.e_islandFlag; - } - for (var c = this.m_contactList; c; c = c.m_next) { - c.m_flags &= ~b2Contact.e_islandFlag; - } - for (var j = this.m_jointList; j; j = j.m_next) { - j.m_islandFlag = false; - } - var stackSize = parseInt(this.m_bodyCount); - var stack = this.s_stack; - for (var seed = this.m_bodyList; seed; seed = seed.m_next) { - if (seed.m_flags & b2Body.e_islandFlag) { - continue; - } - if (seed.IsAwake() == false || seed.IsActive() == false) { - continue; - } - if (seed.GetType() == b2Body.b2_staticBody) { - continue; - } - island.Clear(); - var stackCount = 0; - stack[stackCount++] = seed; - seed.m_flags |= b2Body.e_islandFlag; - while (stackCount > 0) { - b = stack[--stackCount]; - island.AddBody(b); - if (b.IsAwake() == false) { - b.SetAwake(true); - } - if (b.GetType() == b2Body.b2_staticBody) { - continue; - } - var other; - for (var ce = b.m_contactList; ce; ce = ce.next) { - if (ce.contact.m_flags & b2Contact.e_islandFlag) { - continue; - } - if (ce.contact.IsSensor() == true || ce.contact.IsEnabled() == false || ce.contact.IsTouching() == false) { - continue; - } - island.AddContact(ce.contact); - ce.contact.m_flags |= b2Contact.e_islandFlag; - other = ce.other; - if (other.m_flags & b2Body.e_islandFlag) { - continue; - } - stack[stackCount++] = other; - other.m_flags |= b2Body.e_islandFlag; - } - for (var jn = b.m_jointList; jn; jn = jn.next) { - if (jn.joint.m_islandFlag == true) { - continue; - } - other = jn.other; - if (other.IsActive() == false) { - continue; - } - island.AddJoint(jn.joint); - jn.joint.m_islandFlag = true; - if (other.m_flags & b2Body.e_islandFlag) { - continue; - } - stack[stackCount++] = other; - other.m_flags |= b2Body.e_islandFlag; - } - } - island.Solve(step, this.m_gravity, this.m_allowSleep); - for (var i = 0; i < island.m_bodyCount; ++i) { - b = island.m_bodies[i]; - if (b.GetType() == b2Body.b2_staticBody) { - b.m_flags &= ~b2Body.e_islandFlag; - } - } - } - for (i = 0; - i < stack.length; ++i) { - if (!stack[i]) break; - stack[i] = null; - } - for (b = this.m_bodyList; - b; b = b.m_next) { - if (b.IsAwake() == false || b.IsActive() == false) { - continue; - } - if (b.GetType() == b2Body.b2_staticBody) { - continue; - } - b.SynchronizeFixtures(); - } - this.m_contactManager.FindNewContacts(); - } - b2World.prototype.SolveTOI = function (step) { - var b; - var fA; - var fB; - var bA; - var bB; - var cEdge; - var j; - var island = this.m_island; - island.Initialize(this.m_bodyCount, b2Settings.b2_maxTOIContactsPerIsland, b2Settings.b2_maxTOIJointsPerIsland, null, this.m_contactManager.m_contactListener, this.m_contactSolver); - var queue = b2World.s_queue; - for (b = this.m_bodyList; - b; b = b.m_next) { - b.m_flags &= ~b2Body.e_islandFlag; - b.m_sweep.t0 = 0.0; - } - var c; - for (c = this.m_contactList; - c; c = c.m_next) { - c.m_flags &= ~ (b2Contact.e_toiFlag | b2Contact.e_islandFlag); - } - for (j = this.m_jointList; - j; j = j.m_next) { - j.m_islandFlag = false; - } - for (;;) { - var minContact = null; - var minTOI = 1.0; - for (c = this.m_contactList; - c; c = c.m_next) { - if (c.IsSensor() == true || c.IsEnabled() == false || c.IsContinuous() == false) { - continue; - } - var toi = 1.0; - if (c.m_flags & b2Contact.e_toiFlag) { - toi = c.m_toi; - } - else { - fA = c.m_fixtureA; - fB = c.m_fixtureB; - bA = fA.m_body; - bB = fB.m_body; - if ((bA.GetType() != b2Body.b2_dynamicBody || bA.IsAwake() == false) && (bB.GetType() != b2Body.b2_dynamicBody || bB.IsAwake() == false)) { - continue; - } - var t0 = bA.m_sweep.t0; - if (bA.m_sweep.t0 < bB.m_sweep.t0) { - t0 = bB.m_sweep.t0; - bA.m_sweep.Advance(t0); - } - else if (bB.m_sweep.t0 < bA.m_sweep.t0) { - t0 = bA.m_sweep.t0; - bB.m_sweep.Advance(t0); - } - toi = c.ComputeTOI(bA.m_sweep, bB.m_sweep); - b2Settings.b2Assert(0.0 <= toi && toi <= 1.0); - if (toi > 0.0 && toi < 1.0) { - toi = (1.0 - toi) * t0 + toi; - if (toi > 1) toi = 1; - } - c.m_toi = toi; - c.m_flags |= b2Contact.e_toiFlag; - } - if (Number.MIN_VALUE < toi && toi < minTOI) { - minContact = c; - minTOI = toi; - } - } - if (minContact == null || 1.0 - 100.0 * Number.MIN_VALUE < minTOI) { - break; - } - fA = minContact.m_fixtureA; - fB = minContact.m_fixtureB; - bA = fA.m_body; - bB = fB.m_body; - b2World.s_backupA.Set(bA.m_sweep); - b2World.s_backupB.Set(bB.m_sweep); - bA.Advance(minTOI); - bB.Advance(minTOI); - minContact.Update(this.m_contactManager.m_contactListener); - minContact.m_flags &= ~b2Contact.e_toiFlag; - if (minContact.IsSensor() == true || minContact.IsEnabled() == false) { - bA.m_sweep.Set(b2World.s_backupA); - bB.m_sweep.Set(b2World.s_backupB); - bA.SynchronizeTransform(); - bB.SynchronizeTransform(); - continue; - } - if (minContact.IsTouching() == false) { - continue; - } - var seed = bA; - if (seed.GetType() != b2Body.b2_dynamicBody) { - seed = bB; - } - island.Clear(); - var queueStart = 0; - var queueSize = 0; - queue[queueStart + queueSize++] = seed; - seed.m_flags |= b2Body.e_islandFlag; - while (queueSize > 0) { - b = queue[queueStart++]; - --queueSize; - island.AddBody(b); - if (b.IsAwake() == false) { - b.SetAwake(true); - } - if (b.GetType() != b2Body.b2_dynamicBody) { - continue; - } - for (cEdge = b.m_contactList; - cEdge; cEdge = cEdge.next) { - if (island.m_contactCount == island.m_contactCapacity) { - break; - } - if (cEdge.contact.m_flags & b2Contact.e_islandFlag) { - continue; - } - if (cEdge.contact.IsSensor() == true || cEdge.contact.IsEnabled() == false || cEdge.contact.IsTouching() == false) { - continue; - } - island.AddContact(cEdge.contact); - cEdge.contact.m_flags |= b2Contact.e_islandFlag; - var other = cEdge.other; - if (other.m_flags & b2Body.e_islandFlag) { - continue; - } - if (other.GetType() != b2Body.b2_staticBody) { - other.Advance(minTOI); - other.SetAwake(true); - } - queue[queueStart + queueSize] = other; - ++queueSize; - other.m_flags |= b2Body.e_islandFlag; - } - for (var jEdge = b.m_jointList; jEdge; jEdge = jEdge.next) { - if (island.m_jointCount == island.m_jointCapacity) continue; - if (jEdge.joint.m_islandFlag == true) continue; - other = jEdge.other; - if (other.IsActive() == false) { - continue; - } - island.AddJoint(jEdge.joint); - jEdge.joint.m_islandFlag = true; - if (other.m_flags & b2Body.e_islandFlag) continue; - if (other.GetType() != b2Body.b2_staticBody) { - other.Advance(minTOI); - other.SetAwake(true); - } - queue[queueStart + queueSize] = other; - ++queueSize; - other.m_flags |= b2Body.e_islandFlag; - } - } - var subStep = b2World.s_timestep; - subStep.warmStarting = false; - subStep.dt = (1.0 - minTOI) * step.dt; - subStep.inv_dt = 1.0 / subStep.dt; - subStep.dtRatio = 0.0; - subStep.velocityIterations = step.velocityIterations; - subStep.positionIterations = step.positionIterations; - island.SolveTOI(subStep); - var i = 0; - for (i = 0; - i < island.m_bodyCount; ++i) { - b = island.m_bodies[i]; - b.m_flags &= ~b2Body.e_islandFlag; - if (b.IsAwake() == false) { - continue; - } - if (b.GetType() != b2Body.b2_dynamicBody) { - continue; - } - b.SynchronizeFixtures(); - for (cEdge = b.m_contactList; - cEdge; cEdge = cEdge.next) { - cEdge.contact.m_flags &= ~b2Contact.e_toiFlag; - } - } - for (i = 0; - i < island.m_contactCount; ++i) { - c = island.m_contacts[i]; - c.m_flags &= ~ (b2Contact.e_toiFlag | b2Contact.e_islandFlag); - } - for (i = 0; - i < island.m_jointCount; ++i) { - j = island.m_joints[i]; - j.m_islandFlag = false; - } - this.m_contactManager.FindNewContacts(); - } - } - b2World.prototype.DrawJoint = function (joint) { - var b1 = joint.GetBodyA(); - var b2 = joint.GetBodyB(); - var xf1 = b1.m_xf; - var xf2 = b2.m_xf; - var x1 = xf1.position; - var x2 = xf2.position; - var p1 = joint.GetAnchorA(); - var p2 = joint.GetAnchorB(); - var color = b2World.s_jointColor; - switch (joint.m_type) { - case b2Joint.e_distanceJoint: - this.m_debugDraw.DrawSegment(p1, p2, color); - break; - case b2Joint.e_pulleyJoint: - { - var pulley = ((joint instanceof b2PulleyJoint ? joint : null)); - var s1 = pulley.GetGroundAnchorA(); - var s2 = pulley.GetGroundAnchorB(); - this.m_debugDraw.DrawSegment(s1, p1, color); - this.m_debugDraw.DrawSegment(s2, p2, color); - this.m_debugDraw.DrawSegment(s1, s2, color); - } - break; - case b2Joint.e_mouseJoint: - this.m_debugDraw.DrawSegment(p1, p2, color); - break; - default: - if (b1 != this.m_groundBody) this.m_debugDraw.DrawSegment(x1, p1, color); - this.m_debugDraw.DrawSegment(p1, p2, color); - if (b2 != this.m_groundBody) this.m_debugDraw.DrawSegment(x2, p2, color); - } - } - b2World.prototype.DrawShape = function (shape, xf, color) { - switch (shape.m_type) { - case b2Shape.e_circleShape: - { - var circle = ((shape instanceof b2CircleShape ? shape : null)); - var center = b2Math.MulX(xf, circle.m_p); - var radius = circle.m_radius; - var axis = xf.R.col1; - this.m_debugDraw.DrawSolidCircle(center, radius, axis, color); - } - break; - case b2Shape.e_polygonShape: - { - var i = 0; - var poly = ((shape instanceof b2PolygonShape ? shape : null)); - var vertexCount = parseInt(poly.GetVertexCount()); - var localVertices = poly.GetVertices(); - var vertices = new Vector(vertexCount); - for (i = 0; - i < vertexCount; ++i) { - vertices[i] = b2Math.MulX(xf, localVertices[i]); - } - this.m_debugDraw.DrawSolidPolygon(vertices, vertexCount, color); - } - break; - case b2Shape.e_edgeShape: - { - var edge = (shape instanceof b2EdgeShape ? shape : null); - this.m_debugDraw.DrawSegment(b2Math.MulX(xf, edge.GetVertex1()), b2Math.MulX(xf, edge.GetVertex2()), color); - } - break; - } - } - Box2D.postDefs.push(function () { - Box2D.Dynamics.b2World.s_timestep2 = new b2TimeStep(); - Box2D.Dynamics.b2World.s_xf = new b2Transform(); - Box2D.Dynamics.b2World.s_backupA = new b2Sweep(); - Box2D.Dynamics.b2World.s_backupB = new b2Sweep(); - Box2D.Dynamics.b2World.s_timestep = new b2TimeStep(); - Box2D.Dynamics.b2World.s_queue = new Vector(); - Box2D.Dynamics.b2World.s_jointColor = new b2Color(0.5, 0.8, 0.8); - Box2D.Dynamics.b2World.e_newFixture = 0x0001; - Box2D.Dynamics.b2World.e_locked = 0x0002; - }); -})(); -(function () { - var b2CircleShape = Box2D.Collision.Shapes.b2CircleShape, - b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef, - b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape, - b2MassData = Box2D.Collision.Shapes.b2MassData, - b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape, - b2Shape = Box2D.Collision.Shapes.b2Shape, - b2CircleContact = Box2D.Dynamics.Contacts.b2CircleContact, - b2Contact = Box2D.Dynamics.Contacts.b2Contact, - b2ContactConstraint = Box2D.Dynamics.Contacts.b2ContactConstraint, - b2ContactConstraintPoint = Box2D.Dynamics.Contacts.b2ContactConstraintPoint, - b2ContactEdge = Box2D.Dynamics.Contacts.b2ContactEdge, - b2ContactFactory = Box2D.Dynamics.Contacts.b2ContactFactory, - b2ContactRegister = Box2D.Dynamics.Contacts.b2ContactRegister, - b2ContactResult = Box2D.Dynamics.Contacts.b2ContactResult, - b2ContactSolver = Box2D.Dynamics.Contacts.b2ContactSolver, - b2EdgeAndCircleContact = Box2D.Dynamics.Contacts.b2EdgeAndCircleContact, - b2NullContact = Box2D.Dynamics.Contacts.b2NullContact, - b2PolyAndCircleContact = Box2D.Dynamics.Contacts.b2PolyAndCircleContact, - b2PolyAndEdgeContact = Box2D.Dynamics.Contacts.b2PolyAndEdgeContact, - b2PolygonContact = Box2D.Dynamics.Contacts.b2PolygonContact, - b2PositionSolverManifold = Box2D.Dynamics.Contacts.b2PositionSolverManifold, - b2Body = Box2D.Dynamics.b2Body, - b2BodyDef = Box2D.Dynamics.b2BodyDef, - b2ContactFilter = Box2D.Dynamics.b2ContactFilter, - b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse, - b2ContactListener = Box2D.Dynamics.b2ContactListener, - b2ContactManager = Box2D.Dynamics.b2ContactManager, - b2DebugDraw = Box2D.Dynamics.b2DebugDraw, - b2DestructionListener = Box2D.Dynamics.b2DestructionListener, - b2FilterData = Box2D.Dynamics.b2FilterData, - b2Fixture = Box2D.Dynamics.b2Fixture, - b2FixtureDef = Box2D.Dynamics.b2FixtureDef, - b2Island = Box2D.Dynamics.b2Island, - b2TimeStep = Box2D.Dynamics.b2TimeStep, - b2World = Box2D.Dynamics.b2World, - b2Color = Box2D.Common.b2Color, - b2internal = Box2D.Common.b2internal, - b2Settings = Box2D.Common.b2Settings, - b2Mat22 = Box2D.Common.Math.b2Mat22, - b2Mat33 = Box2D.Common.Math.b2Mat33, - b2Math = Box2D.Common.Math.b2Math, - b2Sweep = Box2D.Common.Math.b2Sweep, - b2Transform = Box2D.Common.Math.b2Transform, - b2Vec2 = Box2D.Common.Math.b2Vec2, - b2Vec3 = Box2D.Common.Math.b2Vec3, - b2AABB = Box2D.Collision.b2AABB, - b2Bound = Box2D.Collision.b2Bound, - b2BoundValues = Box2D.Collision.b2BoundValues, - b2Collision = Box2D.Collision.b2Collision, - b2ContactID = Box2D.Collision.b2ContactID, - b2ContactPoint = Box2D.Collision.b2ContactPoint, - b2Distance = Box2D.Collision.b2Distance, - b2DistanceInput = Box2D.Collision.b2DistanceInput, - b2DistanceOutput = Box2D.Collision.b2DistanceOutput, - b2DistanceProxy = Box2D.Collision.b2DistanceProxy, - b2DynamicTree = Box2D.Collision.b2DynamicTree, - b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase, - b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode, - b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair, - b2Manifold = Box2D.Collision.b2Manifold, - b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint, - b2Point = Box2D.Collision.b2Point, - b2RayCastInput = Box2D.Collision.b2RayCastInput, - b2RayCastOutput = Box2D.Collision.b2RayCastOutput, - b2Segment = Box2D.Collision.b2Segment, - b2SeparationFunction = Box2D.Collision.b2SeparationFunction, - b2Simplex = Box2D.Collision.b2Simplex, - b2SimplexCache = Box2D.Collision.b2SimplexCache, - b2SimplexVertex = Box2D.Collision.b2SimplexVertex, - b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact, - b2TOIInput = Box2D.Collision.b2TOIInput, - b2WorldManifold = Box2D.Collision.b2WorldManifold, - ClipVertex = Box2D.Collision.ClipVertex, - Features = Box2D.Collision.Features, - IBroadPhase = Box2D.Collision.IBroadPhase; - - Box2D.inherit(b2CircleContact, Box2D.Dynamics.Contacts.b2Contact); - b2CircleContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; - b2CircleContact.b2CircleContact = function () { - Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); - }; - b2CircleContact.Create = function (allocator) { - return new b2CircleContact(); - } - b2CircleContact.Destroy = function (contact, allocator) {} - b2CircleContact.prototype.Reset = function (fixtureA, fixtureB) { - this.__super.Reset.call(this, fixtureA, fixtureB); - } - b2CircleContact.prototype.Evaluate = function () { - var bA = this.m_fixtureA.GetBody(); - var bB = this.m_fixtureB.GetBody(); - b2Collision.CollideCircles(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2CircleShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2CircleShape ? this.m_fixtureB.GetShape() : null), bB.m_xf); - } - b2Contact.b2Contact = function () { - this.m_nodeA = new b2ContactEdge(); - this.m_nodeB = new b2ContactEdge(); - this.m_manifold = new b2Manifold(); - this.m_oldManifold = new b2Manifold(); - }; - b2Contact.prototype.GetManifold = function () { - return this.m_manifold; - } - b2Contact.prototype.GetWorldManifold = function (worldManifold) { - var bodyA = this.m_fixtureA.GetBody(); - var bodyB = this.m_fixtureB.GetBody(); - var shapeA = this.m_fixtureA.GetShape(); - var shapeB = this.m_fixtureB.GetShape(); - worldManifold.Initialize(this.m_manifold, bodyA.GetTransform(), shapeA.m_radius, bodyB.GetTransform(), shapeB.m_radius); - } - b2Contact.prototype.IsTouching = function () { - return (this.m_flags & b2Contact.e_touchingFlag) == b2Contact.e_touchingFlag; - } - b2Contact.prototype.IsContinuous = function () { - return (this.m_flags & b2Contact.e_continuousFlag) == b2Contact.e_continuousFlag; - } - b2Contact.prototype.SetSensor = function (sensor) { - if (sensor) { - this.m_flags |= b2Contact.e_sensorFlag; - } - else { - this.m_flags &= ~b2Contact.e_sensorFlag; - } - } - b2Contact.prototype.IsSensor = function () { - return (this.m_flags & b2Contact.e_sensorFlag) == b2Contact.e_sensorFlag; - } - b2Contact.prototype.SetEnabled = function (flag) { - if (flag) { - this.m_flags |= b2Contact.e_enabledFlag; - } - else { - this.m_flags &= ~b2Contact.e_enabledFlag; - } - } - b2Contact.prototype.IsEnabled = function () { - return (this.m_flags & b2Contact.e_enabledFlag) == b2Contact.e_enabledFlag; - } - b2Contact.prototype.GetNext = function () { - return this.m_next; - } - b2Contact.prototype.GetFixtureA = function () { - return this.m_fixtureA; - } - b2Contact.prototype.GetFixtureB = function () { - return this.m_fixtureB; - } - b2Contact.prototype.FlagForFiltering = function () { - this.m_flags |= b2Contact.e_filterFlag; - } - b2Contact.prototype.b2Contact = function () {} - b2Contact.prototype.Reset = function (fixtureA, fixtureB) { - if (fixtureA === undefined) fixtureA = null; - if (fixtureB === undefined) fixtureB = null; - this.m_flags = b2Contact.e_enabledFlag; - if (!fixtureA || !fixtureB) { - this.m_fixtureA = null; - this.m_fixtureB = null; - return; - } - if (fixtureA.IsSensor() || fixtureB.IsSensor()) { - this.m_flags |= b2Contact.e_sensorFlag; - } - var bodyA = fixtureA.GetBody(); - var bodyB = fixtureB.GetBody(); - if (bodyA.GetType() != b2Body.b2_dynamicBody || bodyA.IsBullet() || bodyB.GetType() != b2Body.b2_dynamicBody || bodyB.IsBullet()) { - this.m_flags |= b2Contact.e_continuousFlag; - } - this.m_fixtureA = fixtureA; - this.m_fixtureB = fixtureB; - this.m_manifold.m_pointCount = 0; - this.m_prev = null; - this.m_next = null; - this.m_nodeA.contact = null; - this.m_nodeA.prev = null; - this.m_nodeA.next = null; - this.m_nodeA.other = null; - this.m_nodeB.contact = null; - this.m_nodeB.prev = null; - this.m_nodeB.next = null; - this.m_nodeB.other = null; - } - b2Contact.prototype.Update = function (listener) { - var tManifold = this.m_oldManifold; - this.m_oldManifold = this.m_manifold; - this.m_manifold = tManifold; - this.m_flags |= b2Contact.e_enabledFlag; - var touching = false; - var wasTouching = (this.m_flags & b2Contact.e_touchingFlag) == b2Contact.e_touchingFlag; - var bodyA = this.m_fixtureA.m_body; - var bodyB = this.m_fixtureB.m_body; - var aabbOverlap = this.m_fixtureA.m_aabb.TestOverlap(this.m_fixtureB.m_aabb); - if (this.m_flags & b2Contact.e_sensorFlag) { - if (aabbOverlap) { - var shapeA = this.m_fixtureA.GetShape(); - var shapeB = this.m_fixtureB.GetShape(); - var xfA = bodyA.GetTransform(); - var xfB = bodyB.GetTransform(); - touching = b2Shape.TestOverlap(shapeA, xfA, shapeB, xfB); - } - this.m_manifold.m_pointCount = 0; - } - else { - if (bodyA.GetType() != b2Body.b2_dynamicBody || bodyA.IsBullet() || bodyB.GetType() != b2Body.b2_dynamicBody || bodyB.IsBullet()) { - this.m_flags |= b2Contact.e_continuousFlag; - } - else { - this.m_flags &= ~b2Contact.e_continuousFlag; - } - if (aabbOverlap) { - this.Evaluate(); - touching = this.m_manifold.m_pointCount > 0; - for (var i = 0; i < this.m_manifold.m_pointCount; ++i) { - var mp2 = this.m_manifold.m_points[i]; - mp2.m_normalImpulse = 0.0; - mp2.m_tangentImpulse = 0.0; - var id2 = mp2.m_id; - for (var j = 0; j < this.m_oldManifold.m_pointCount; ++j) { - var mp1 = this.m_oldManifold.m_points[j]; - if (mp1.m_id.key == id2.key) { - mp2.m_normalImpulse = mp1.m_normalImpulse; - mp2.m_tangentImpulse = mp1.m_tangentImpulse; - break; - } - } - } - } - else { - this.m_manifold.m_pointCount = 0; - } - if (touching != wasTouching) { - bodyA.SetAwake(true); - bodyB.SetAwake(true); - } - } - if (touching) { - this.m_flags |= b2Contact.e_touchingFlag; - } - else { - this.m_flags &= ~b2Contact.e_touchingFlag; - } - if (wasTouching == false && touching == true) { - listener.BeginContact(this); - } - if (wasTouching == true && touching == false) { - listener.EndContact(this); - } - if ((this.m_flags & b2Contact.e_sensorFlag) == 0) { - listener.PreSolve(this, this.m_oldManifold); - } - } - b2Contact.prototype.Evaluate = function () {} - b2Contact.prototype.ComputeTOI = function (sweepA, sweepB) { - b2Contact.s_input.proxyA.Set(this.m_fixtureA.GetShape()); - b2Contact.s_input.proxyB.Set(this.m_fixtureB.GetShape()); - b2Contact.s_input.sweepA = sweepA; - b2Contact.s_input.sweepB = sweepB; - b2Contact.s_input.tolerance = b2Settings.b2_linearSlop; - return b2TimeOfImpact.TimeOfImpact(b2Contact.s_input); - } - Box2D.postDefs.push(function () { - Box2D.Dynamics.Contacts.b2Contact.e_sensorFlag = 0x0001; - Box2D.Dynamics.Contacts.b2Contact.e_continuousFlag = 0x0002; - Box2D.Dynamics.Contacts.b2Contact.e_islandFlag = 0x0004; - Box2D.Dynamics.Contacts.b2Contact.e_toiFlag = 0x0008; - Box2D.Dynamics.Contacts.b2Contact.e_touchingFlag = 0x0010; - Box2D.Dynamics.Contacts.b2Contact.e_enabledFlag = 0x0020; - Box2D.Dynamics.Contacts.b2Contact.e_filterFlag = 0x0040; - Box2D.Dynamics.Contacts.b2Contact.s_input = new b2TOIInput(); - }); - b2ContactConstraint.b2ContactConstraint = function () { - this.localPlaneNormal = new b2Vec2(); - this.localPoint = new b2Vec2(); - this.normal = new b2Vec2(); - this.normalMass = new b2Mat22(); - this.K = new b2Mat22(); - }; - b2ContactConstraint.prototype.b2ContactConstraint = function () { - this.points = new Vector(b2Settings.b2_maxManifoldPoints); - for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { - this.points[i] = new b2ContactConstraintPoint(); - } - } - b2ContactConstraintPoint.b2ContactConstraintPoint = function () { - this.localPoint = new b2Vec2(); - this.rA = new b2Vec2(); - this.rB = new b2Vec2(); - }; - b2ContactEdge.b2ContactEdge = function () {}; - b2ContactFactory.b2ContactFactory = function () {}; - b2ContactFactory.prototype.b2ContactFactory = function (allocator) { - this.m_allocator = allocator; - this.InitializeRegisters(); - } - b2ContactFactory.prototype.AddType = function (createFcn, destroyFcn, type1, type2) { - if (type1 === undefined) type1 = 0; - if (type2 === undefined) type2 = 0; - this.m_registers[type1][type2].createFcn = createFcn; - this.m_registers[type1][type2].destroyFcn = destroyFcn; - this.m_registers[type1][type2].primary = true; - if (type1 != type2) { - this.m_registers[type2][type1].createFcn = createFcn; - this.m_registers[type2][type1].destroyFcn = destroyFcn; - this.m_registers[type2][type1].primary = false; - } - } - b2ContactFactory.prototype.InitializeRegisters = function () { - this.m_registers = new Vector(b2Shape.e_shapeTypeCount); - for (var i = 0; i < b2Shape.e_shapeTypeCount; i++) { - this.m_registers[i] = new Vector(b2Shape.e_shapeTypeCount); - for (var j = 0; j < b2Shape.e_shapeTypeCount; j++) { - this.m_registers[i][j] = new b2ContactRegister(); - } - } - this.AddType(b2CircleContact.Create, b2CircleContact.Destroy, b2Shape.e_circleShape, b2Shape.e_circleShape); - this.AddType(b2PolyAndCircleContact.Create, b2PolyAndCircleContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_circleShape); - this.AddType(b2PolygonContact.Create, b2PolygonContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_polygonShape); - this.AddType(b2EdgeAndCircleContact.Create, b2EdgeAndCircleContact.Destroy, b2Shape.e_edgeShape, b2Shape.e_circleShape); - this.AddType(b2PolyAndEdgeContact.Create, b2PolyAndEdgeContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_edgeShape); - } - b2ContactFactory.prototype.Create = function (fixtureA, fixtureB) { - var type1 = parseInt(fixtureA.GetType()); - var type2 = parseInt(fixtureB.GetType()); - var reg = this.m_registers[type1][type2]; - var c; - if (reg.pool) { - c = reg.pool; - reg.pool = c.m_next; - reg.poolCount--; - c.Reset(fixtureA, fixtureB); - return c; - } - var createFcn = reg.createFcn; - if (createFcn != null) { - if (reg.primary) { - c = createFcn(this.m_allocator); - c.Reset(fixtureA, fixtureB); - return c; - } - else { - c = createFcn(this.m_allocator); - c.Reset(fixtureB, fixtureA); - return c; - } - } - else { - return null; - } - } - b2ContactFactory.prototype.Destroy = function (contact) { - if (contact.m_manifold.m_pointCount > 0) { - contact.m_fixtureA.m_body.SetAwake(true); - contact.m_fixtureB.m_body.SetAwake(true); - } - var type1 = parseInt(contact.m_fixtureA.GetType()); - var type2 = parseInt(contact.m_fixtureB.GetType()); - var reg = this.m_registers[type1][type2]; - if (true) { - reg.poolCount++; - contact.m_next = reg.pool; - reg.pool = contact; - } - var destroyFcn = reg.destroyFcn; - destroyFcn(contact, this.m_allocator); - } - b2ContactRegister.b2ContactRegister = function () {}; - b2ContactResult.b2ContactResult = function () { - this.position = new b2Vec2(); - this.normal = new b2Vec2(); - this.id = new b2ContactID(); - }; - b2ContactSolver.b2ContactSolver = function () { - this.m_step = new b2TimeStep(); - this.m_constraints = new Vector(); - }; - b2ContactSolver.prototype.b2ContactSolver = function () {} - b2ContactSolver.prototype.Initialize = function (step, contacts, contactCount, allocator) { - if (contactCount === undefined) contactCount = 0; - var contact; - this.m_step.Set(step); - this.m_allocator = allocator; - var i = 0; - var tVec; - var tMat; - this.m_constraintCount = contactCount; - while (this.m_constraints.length < this.m_constraintCount) { - this.m_constraints[this.m_constraints.length] = new b2ContactConstraint(); - } - for (i = 0; - i < contactCount; ++i) { - contact = contacts[i]; - var fixtureA = contact.m_fixtureA; - var fixtureB = contact.m_fixtureB; - var shapeA = fixtureA.m_shape; - var shapeB = fixtureB.m_shape; - var radiusA = shapeA.m_radius; - var radiusB = shapeB.m_radius; - var bodyA = fixtureA.m_body; - var bodyB = fixtureB.m_body; - var manifold = contact.GetManifold(); - var friction = b2Settings.b2MixFriction(fixtureA.GetFriction(), fixtureB.GetFriction()); - var restitution = b2Settings.b2MixRestitution(fixtureA.GetRestitution(), fixtureB.GetRestitution()); - var vAX = bodyA.m_linearVelocity.x; - var vAY = bodyA.m_linearVelocity.y; - var vBX = bodyB.m_linearVelocity.x; - var vBY = bodyB.m_linearVelocity.y; - var wA = bodyA.m_angularVelocity; - var wB = bodyB.m_angularVelocity; - b2Settings.b2Assert(manifold.m_pointCount > 0); - b2ContactSolver.s_worldManifold.Initialize(manifold, bodyA.m_xf, radiusA, bodyB.m_xf, radiusB); - var normalX = b2ContactSolver.s_worldManifold.m_normal.x; - var normalY = b2ContactSolver.s_worldManifold.m_normal.y; - var cc = this.m_constraints[i]; - cc.bodyA = bodyA; - cc.bodyB = bodyB; - cc.manifold = manifold; - cc.normal.x = normalX; - cc.normal.y = normalY; - cc.pointCount = manifold.m_pointCount; - cc.friction = friction; - cc.restitution = restitution; - cc.localPlaneNormal.x = manifold.m_localPlaneNormal.x; - cc.localPlaneNormal.y = manifold.m_localPlaneNormal.y; - cc.localPoint.x = manifold.m_localPoint.x; - cc.localPoint.y = manifold.m_localPoint.y; - cc.radius = radiusA + radiusB; - cc.type = manifold.m_type; - for (var k = 0; k < cc.pointCount; ++k) { - var cp = manifold.m_points[k]; - var ccp = cc.points[k]; - ccp.normalImpulse = cp.m_normalImpulse; - ccp.tangentImpulse = cp.m_tangentImpulse; - ccp.localPoint.SetV(cp.m_localPoint); - var rAX = ccp.rA.x = b2ContactSolver.s_worldManifold.m_points[k].x - bodyA.m_sweep.c.x; - var rAY = ccp.rA.y = b2ContactSolver.s_worldManifold.m_points[k].y - bodyA.m_sweep.c.y; - var rBX = ccp.rB.x = b2ContactSolver.s_worldManifold.m_points[k].x - bodyB.m_sweep.c.x; - var rBY = ccp.rB.y = b2ContactSolver.s_worldManifold.m_points[k].y - bodyB.m_sweep.c.y; - var rnA = rAX * normalY - rAY * normalX; - var rnB = rBX * normalY - rBY * normalX; - rnA *= rnA; - rnB *= rnB; - var kNormal = bodyA.m_invMass + bodyB.m_invMass + bodyA.m_invI * rnA + bodyB.m_invI * rnB; - ccp.normalMass = 1.0 / kNormal; - var kEqualized = bodyA.m_mass * bodyA.m_invMass + bodyB.m_mass * bodyB.m_invMass; - kEqualized += bodyA.m_mass * bodyA.m_invI * rnA + bodyB.m_mass * bodyB.m_invI * rnB; - ccp.equalizedMass = 1.0 / kEqualized; - var tangentX = normalY; - var tangentY = (-normalX); - var rtA = rAX * tangentY - rAY * tangentX; - var rtB = rBX * tangentY - rBY * tangentX; - rtA *= rtA; - rtB *= rtB; - var kTangent = bodyA.m_invMass + bodyB.m_invMass + bodyA.m_invI * rtA + bodyB.m_invI * rtB; - ccp.tangentMass = 1.0 / kTangent; - ccp.velocityBias = 0.0; - var tX = vBX + ((-wB * rBY)) - vAX - ((-wA * rAY)); - var tY = vBY + (wB * rBX) - vAY - (wA * rAX); - var vRel = cc.normal.x * tX + cc.normal.y * tY; - if (vRel < (-b2Settings.b2_velocityThreshold)) { - ccp.velocityBias += (-cc.restitution * vRel); - } - } - if (cc.pointCount == 2) { - var ccp1 = cc.points[0]; - var ccp2 = cc.points[1]; - var invMassA = bodyA.m_invMass; - var invIA = bodyA.m_invI; - var invMassB = bodyB.m_invMass; - var invIB = bodyB.m_invI; - var rn1A = ccp1.rA.x * normalY - ccp1.rA.y * normalX; - var rn1B = ccp1.rB.x * normalY - ccp1.rB.y * normalX; - var rn2A = ccp2.rA.x * normalY - ccp2.rA.y * normalX; - var rn2B = ccp2.rB.x * normalY - ccp2.rB.y * normalX; - var k11 = invMassA + invMassB + invIA * rn1A * rn1A + invIB * rn1B * rn1B; - var k22 = invMassA + invMassB + invIA * rn2A * rn2A + invIB * rn2B * rn2B; - var k12 = invMassA + invMassB + invIA * rn1A * rn2A + invIB * rn1B * rn2B; - var k_maxConditionNumber = 100.0; - if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12)) { - cc.K.col1.Set(k11, k12); - cc.K.col2.Set(k12, k22); - cc.K.GetInverse(cc.normalMass); - } - else { - cc.pointCount = 1; - } - } - } - } - b2ContactSolver.prototype.InitVelocityConstraints = function (step) { - var tVec; - var tVec2; - var tMat; - for (var i = 0; i < this.m_constraintCount; ++i) { - var c = this.m_constraints[i]; - var bodyA = c.bodyA; - var bodyB = c.bodyB; - var invMassA = bodyA.m_invMass; - var invIA = bodyA.m_invI; - var invMassB = bodyB.m_invMass; - var invIB = bodyB.m_invI; - var normalX = c.normal.x; - var normalY = c.normal.y; - var tangentX = normalY; - var tangentY = (-normalX); - var tX = 0; - var j = 0; - var tCount = 0; - if (step.warmStarting) { - tCount = c.pointCount; - for (j = 0; - j < tCount; ++j) { - var ccp = c.points[j]; - ccp.normalImpulse *= step.dtRatio; - ccp.tangentImpulse *= step.dtRatio; - var PX = ccp.normalImpulse * normalX + ccp.tangentImpulse * tangentX; - var PY = ccp.normalImpulse * normalY + ccp.tangentImpulse * tangentY; - bodyA.m_angularVelocity -= invIA * (ccp.rA.x * PY - ccp.rA.y * PX); - bodyA.m_linearVelocity.x -= invMassA * PX; - bodyA.m_linearVelocity.y -= invMassA * PY; - bodyB.m_angularVelocity += invIB * (ccp.rB.x * PY - ccp.rB.y * PX); - bodyB.m_linearVelocity.x += invMassB * PX; - bodyB.m_linearVelocity.y += invMassB * PY; - } - } - else { - tCount = c.pointCount; - for (j = 0; - j < tCount; ++j) { - var ccp2 = c.points[j]; - ccp2.normalImpulse = 0.0; - ccp2.tangentImpulse = 0.0; - } - } - } - } - b2ContactSolver.prototype.SolveVelocityConstraints = function () { - var j = 0; - var ccp; - var rAX = 0; - var rAY = 0; - var rBX = 0; - var rBY = 0; - var dvX = 0; - var dvY = 0; - var vn = 0; - var vt = 0; - var lambda = 0; - var maxFriction = 0; - var newImpulse = 0; - var PX = 0; - var PY = 0; - var dX = 0; - var dY = 0; - var P1X = 0; - var P1Y = 0; - var P2X = 0; - var P2Y = 0; - var tMat; - var tVec; - for (var i = 0; i < this.m_constraintCount; ++i) { - var c = this.m_constraints[i]; - var bodyA = c.bodyA; - var bodyB = c.bodyB; - var wA = bodyA.m_angularVelocity; - var wB = bodyB.m_angularVelocity; - var vA = bodyA.m_linearVelocity; - var vB = bodyB.m_linearVelocity; - var invMassA = bodyA.m_invMass; - var invIA = bodyA.m_invI; - var invMassB = bodyB.m_invMass; - var invIB = bodyB.m_invI; - var normalX = c.normal.x; - var normalY = c.normal.y; - var tangentX = normalY; - var tangentY = (-normalX); - var friction = c.friction; - var tX = 0; - for (j = 0; - j < c.pointCount; j++) { - ccp = c.points[j]; - dvX = vB.x - wB * ccp.rB.y - vA.x + wA * ccp.rA.y; - dvY = vB.y + wB * ccp.rB.x - vA.y - wA * ccp.rA.x; - vt = dvX * tangentX + dvY * tangentY; - lambda = ccp.tangentMass * (-vt); - maxFriction = friction * ccp.normalImpulse; - newImpulse = b2Math.Clamp(ccp.tangentImpulse + lambda, (-maxFriction), maxFriction); - lambda = newImpulse - ccp.tangentImpulse; - PX = lambda * tangentX; - PY = lambda * tangentY; - vA.x -= invMassA * PX; - vA.y -= invMassA * PY; - wA -= invIA * (ccp.rA.x * PY - ccp.rA.y * PX); - vB.x += invMassB * PX; - vB.y += invMassB * PY; - wB += invIB * (ccp.rB.x * PY - ccp.rB.y * PX); - ccp.tangentImpulse = newImpulse; - } - var tCount = parseInt(c.pointCount); - if (c.pointCount == 1) { - ccp = c.points[0]; - dvX = vB.x + ((-wB * ccp.rB.y)) - vA.x - ((-wA * ccp.rA.y)); - dvY = vB.y + (wB * ccp.rB.x) - vA.y - (wA * ccp.rA.x); - vn = dvX * normalX + dvY * normalY; - lambda = (-ccp.normalMass * (vn - ccp.velocityBias)); - newImpulse = ccp.normalImpulse + lambda; - newImpulse = newImpulse > 0 ? newImpulse : 0.0; - lambda = newImpulse - ccp.normalImpulse; - PX = lambda * normalX; - PY = lambda * normalY; - vA.x -= invMassA * PX; - vA.y -= invMassA * PY; - wA -= invIA * (ccp.rA.x * PY - ccp.rA.y * PX); - vB.x += invMassB * PX; - vB.y += invMassB * PY; - wB += invIB * (ccp.rB.x * PY - ccp.rB.y * PX); - ccp.normalImpulse = newImpulse; - } - else { - var cp1 = c.points[0]; - var cp2 = c.points[1]; - var aX = cp1.normalImpulse; - var aY = cp2.normalImpulse; - var dv1X = vB.x - wB * cp1.rB.y - vA.x + wA * cp1.rA.y; - var dv1Y = vB.y + wB * cp1.rB.x - vA.y - wA * cp1.rA.x; - var dv2X = vB.x - wB * cp2.rB.y - vA.x + wA * cp2.rA.y; - var dv2Y = vB.y + wB * cp2.rB.x - vA.y - wA * cp2.rA.x; - var vn1 = dv1X * normalX + dv1Y * normalY; - var vn2 = dv2X * normalX + dv2Y * normalY; - var bX = vn1 - cp1.velocityBias; - var bY = vn2 - cp2.velocityBias; - tMat = c.K; - bX -= tMat.col1.x * aX + tMat.col2.x * aY; - bY -= tMat.col1.y * aX + tMat.col2.y * aY; - var k_errorTol = 0.001; - for (;;) { - tMat = c.normalMass; - var xX = (-(tMat.col1.x * bX + tMat.col2.x * bY)); - var xY = (-(tMat.col1.y * bX + tMat.col2.y * bY)); - if (xX >= 0.0 && xY >= 0.0) { - dX = xX - aX; - dY = xY - aY; - P1X = dX * normalX; - P1Y = dX * normalY; - P2X = dY * normalX; - P2Y = dY * normalY; - vA.x -= invMassA * (P1X + P2X); - vA.y -= invMassA * (P1Y + P2Y); - wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X); - vB.x += invMassB * (P1X + P2X); - vB.y += invMassB * (P1Y + P2Y); - wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X); - cp1.normalImpulse = xX; - cp2.normalImpulse = xY; - break; - } - xX = (-cp1.normalMass * bX); - xY = 0.0; - vn1 = 0.0; - vn2 = c.K.col1.y * xX + bY; - if (xX >= 0.0 && vn2 >= 0.0) { - dX = xX - aX; - dY = xY - aY; - P1X = dX * normalX; - P1Y = dX * normalY; - P2X = dY * normalX; - P2Y = dY * normalY; - vA.x -= invMassA * (P1X + P2X); - vA.y -= invMassA * (P1Y + P2Y); - wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X); - vB.x += invMassB * (P1X + P2X); - vB.y += invMassB * (P1Y + P2Y); - wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X); - cp1.normalImpulse = xX; - cp2.normalImpulse = xY; - break; - } - xX = 0.0; - xY = (-cp2.normalMass * bY); - vn1 = c.K.col2.x * xY + bX; - vn2 = 0.0; - if (xY >= 0.0 && vn1 >= 0.0) { - dX = xX - aX; - dY = xY - aY; - P1X = dX * normalX; - P1Y = dX * normalY; - P2X = dY * normalX; - P2Y = dY * normalY; - vA.x -= invMassA * (P1X + P2X); - vA.y -= invMassA * (P1Y + P2Y); - wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X); - vB.x += invMassB * (P1X + P2X); - vB.y += invMassB * (P1Y + P2Y); - wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X); - cp1.normalImpulse = xX; - cp2.normalImpulse = xY; - break; - } - xX = 0.0; - xY = 0.0; - vn1 = bX; - vn2 = bY; - if (vn1 >= 0.0 && vn2 >= 0.0) { - dX = xX - aX; - dY = xY - aY; - P1X = dX * normalX; - P1Y = dX * normalY; - P2X = dY * normalX; - P2Y = dY * normalY; - vA.x -= invMassA * (P1X + P2X); - vA.y -= invMassA * (P1Y + P2Y); - wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X); - vB.x += invMassB * (P1X + P2X); - vB.y += invMassB * (P1Y + P2Y); - wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X); - cp1.normalImpulse = xX; - cp2.normalImpulse = xY; - break; - } - break; - } - } - bodyA.m_angularVelocity = wA; - bodyB.m_angularVelocity = wB; - } - } - b2ContactSolver.prototype.FinalizeVelocityConstraints = function () { - for (var i = 0; i < this.m_constraintCount; ++i) { - var c = this.m_constraints[i]; - var m = c.manifold; - for (var j = 0; j < c.pointCount; ++j) { - var point1 = m.m_points[j]; - var point2 = c.points[j]; - point1.m_normalImpulse = point2.normalImpulse; - point1.m_tangentImpulse = point2.tangentImpulse; - } - } - } - b2ContactSolver.prototype.SolvePositionConstraints = function (baumgarte) { - if (baumgarte === undefined) baumgarte = 0; - var minSeparation = 0.0; - for (var i = 0; i < this.m_constraintCount; i++) { - var c = this.m_constraints[i]; - var bodyA = c.bodyA; - var bodyB = c.bodyB; - var invMassA = bodyA.m_mass * bodyA.m_invMass; - var invIA = bodyA.m_mass * bodyA.m_invI; - var invMassB = bodyB.m_mass * bodyB.m_invMass; - var invIB = bodyB.m_mass * bodyB.m_invI; - b2ContactSolver.s_psm.Initialize(c); - var normal = b2ContactSolver.s_psm.m_normal; - for (var j = 0; j < c.pointCount; j++) { - var ccp = c.points[j]; - var point = b2ContactSolver.s_psm.m_points[j]; - var separation = b2ContactSolver.s_psm.m_separations[j]; - var rAX = point.x - bodyA.m_sweep.c.x; - var rAY = point.y - bodyA.m_sweep.c.y; - var rBX = point.x - bodyB.m_sweep.c.x; - var rBY = point.y - bodyB.m_sweep.c.y; - minSeparation = minSeparation < separation ? minSeparation : separation; - var C = b2Math.Clamp(baumgarte * (separation + b2Settings.b2_linearSlop), (-b2Settings.b2_maxLinearCorrection), 0.0); - var impulse = (-ccp.equalizedMass * C); - var PX = impulse * normal.x; - var PY = impulse * normal.y;bodyA.m_sweep.c.x -= invMassA * PX; - bodyA.m_sweep.c.y -= invMassA * PY; - bodyA.m_sweep.a -= invIA * (rAX * PY - rAY * PX); - bodyA.SynchronizeTransform(); - bodyB.m_sweep.c.x += invMassB * PX; - bodyB.m_sweep.c.y += invMassB * PY; - bodyB.m_sweep.a += invIB * (rBX * PY - rBY * PX); - bodyB.SynchronizeTransform(); - } - } - return minSeparation > (-1.5 * b2Settings.b2_linearSlop); - } - Box2D.postDefs.push(function () { - Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold = new b2WorldManifold(); - Box2D.Dynamics.Contacts.b2ContactSolver.s_psm = new b2PositionSolverManifold(); - }); - Box2D.inherit(b2EdgeAndCircleContact, Box2D.Dynamics.Contacts.b2Contact); - b2EdgeAndCircleContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; - b2EdgeAndCircleContact.b2EdgeAndCircleContact = function () { - Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); - }; - b2EdgeAndCircleContact.Create = function (allocator) { - return new b2EdgeAndCircleContact(); - } - b2EdgeAndCircleContact.Destroy = function (contact, allocator) {} - b2EdgeAndCircleContact.prototype.Reset = function (fixtureA, fixtureB) { - this.__super.Reset.call(this, fixtureA, fixtureB); - } - b2EdgeAndCircleContact.prototype.Evaluate = function () { - var bA = this.m_fixtureA.GetBody(); - var bB = this.m_fixtureB.GetBody(); - this.b2CollideEdgeAndCircle(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2EdgeShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2CircleShape ? this.m_fixtureB.GetShape() : null), bB.m_xf); - } - b2EdgeAndCircleContact.prototype.b2CollideEdgeAndCircle = function (manifold, edge, xf1, circle, xf2) {} - Box2D.inherit(b2NullContact, Box2D.Dynamics.Contacts.b2Contact); - b2NullContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; - b2NullContact.b2NullContact = function () { - Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); - }; - b2NullContact.prototype.b2NullContact = function () { - this.__super.b2Contact.call(this); - } - b2NullContact.prototype.Evaluate = function () {} - Box2D.inherit(b2PolyAndCircleContact, Box2D.Dynamics.Contacts.b2Contact); - b2PolyAndCircleContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; - b2PolyAndCircleContact.b2PolyAndCircleContact = function () { - Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); - }; - b2PolyAndCircleContact.Create = function (allocator) { - return new b2PolyAndCircleContact(); - } - b2PolyAndCircleContact.Destroy = function (contact, allocator) {} - b2PolyAndCircleContact.prototype.Reset = function (fixtureA, fixtureB) { - this.__super.Reset.call(this, fixtureA, fixtureB); - b2Settings.b2Assert(fixtureA.GetType() == b2Shape.e_polygonShape); - b2Settings.b2Assert(fixtureB.GetType() == b2Shape.e_circleShape); - } - b2PolyAndCircleContact.prototype.Evaluate = function () { - var bA = this.m_fixtureA.m_body; - var bB = this.m_fixtureB.m_body; - b2Collision.CollidePolygonAndCircle(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2PolygonShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2CircleShape ? this.m_fixtureB.GetShape() : null), bB.m_xf); - } - Box2D.inherit(b2PolyAndEdgeContact, Box2D.Dynamics.Contacts.b2Contact); - b2PolyAndEdgeContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; - b2PolyAndEdgeContact.b2PolyAndEdgeContact = function () { - Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); - }; - b2PolyAndEdgeContact.Create = function (allocator) { - return new b2PolyAndEdgeContact(); - } - b2PolyAndEdgeContact.Destroy = function (contact, allocator) {} - b2PolyAndEdgeContact.prototype.Reset = function (fixtureA, fixtureB) { - this.__super.Reset.call(this, fixtureA, fixtureB); - b2Settings.b2Assert(fixtureA.GetType() == b2Shape.e_polygonShape); - b2Settings.b2Assert(fixtureB.GetType() == b2Shape.e_edgeShape); - } - b2PolyAndEdgeContact.prototype.Evaluate = function () { - var bA = this.m_fixtureA.GetBody(); - var bB = this.m_fixtureB.GetBody(); - this.b2CollidePolyAndEdge(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2PolygonShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2EdgeShape ? this.m_fixtureB.GetShape() : null), bB.m_xf); - } - b2PolyAndEdgeContact.prototype.b2CollidePolyAndEdge = function (manifold, polygon, xf1, edge, xf2) {} - Box2D.inherit(b2PolygonContact, Box2D.Dynamics.Contacts.b2Contact); - b2PolygonContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; - b2PolygonContact.b2PolygonContact = function () { - Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); - }; - b2PolygonContact.Create = function (allocator) { - return new b2PolygonContact(); - } - b2PolygonContact.Destroy = function (contact, allocator) {} - b2PolygonContact.prototype.Reset = function (fixtureA, fixtureB) { - this.__super.Reset.call(this, fixtureA, fixtureB); - } - b2PolygonContact.prototype.Evaluate = function () { - var bA = this.m_fixtureA.GetBody(); - var bB = this.m_fixtureB.GetBody(); - b2Collision.CollidePolygons(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2PolygonShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2PolygonShape ? this.m_fixtureB.GetShape() : null), bB.m_xf); - } - b2PositionSolverManifold.b2PositionSolverManifold = function () {}; - b2PositionSolverManifold.prototype.b2PositionSolverManifold = function () { - this.m_normal = new b2Vec2(); - this.m_separations = new Vector_a2j_Number(b2Settings.b2_maxManifoldPoints); - this.m_points = new Vector(b2Settings.b2_maxManifoldPoints); - for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { - this.m_points[i] = new b2Vec2(); - } - } - b2PositionSolverManifold.prototype.Initialize = function (cc) { - b2Settings.b2Assert(cc.pointCount > 0); - var i = 0; - var clipPointX = 0; - var clipPointY = 0; - var tMat; - var tVec; - var planePointX = 0; - var planePointY = 0; - switch (cc.type) { - case b2Manifold.e_circles: - { - tMat = cc.bodyA.m_xf.R; - tVec = cc.localPoint; - var pointAX = cc.bodyA.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - var pointAY = cc.bodyA.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - tMat = cc.bodyB.m_xf.R; - tVec = cc.points[0].localPoint; - var pointBX = cc.bodyB.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - var pointBY = cc.bodyB.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - var dX = pointBX - pointAX; - var dY = pointBY - pointAY; - var d2 = dX * dX + dY * dY; - if (d2 > Number.MIN_VALUE * Number.MIN_VALUE) { - var d = Math.sqrt(d2); - this.m_normal.x = dX / d; - this.m_normal.y = dY / d; - } - else { - this.m_normal.x = 1.0; - this.m_normal.y = 0.0; - } - this.m_points[0].x = 0.5 * (pointAX + pointBX); - this.m_points[0].y = 0.5 * (pointAY + pointBY); - this.m_separations[0] = dX * this.m_normal.x + dY * this.m_normal.y - cc.radius; - } - break; - case b2Manifold.e_faceA: - { - tMat = cc.bodyA.m_xf.R; - tVec = cc.localPlaneNormal; - this.m_normal.x = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - this.m_normal.y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - tMat = cc.bodyA.m_xf.R; - tVec = cc.localPoint; - planePointX = cc.bodyA.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - planePointY = cc.bodyA.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - tMat = cc.bodyB.m_xf.R; - for (i = 0; - i < cc.pointCount; ++i) { - tVec = cc.points[i].localPoint; - clipPointX = cc.bodyB.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - clipPointY = cc.bodyB.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - this.m_separations[i] = (clipPointX - planePointX) * this.m_normal.x + (clipPointY - planePointY) * this.m_normal.y - cc.radius; - this.m_points[i].x = clipPointX; - this.m_points[i].y = clipPointY; - } - } - break; - case b2Manifold.e_faceB: - { - tMat = cc.bodyB.m_xf.R; - tVec = cc.localPlaneNormal; - this.m_normal.x = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - this.m_normal.y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - tMat = cc.bodyB.m_xf.R; - tVec = cc.localPoint; - planePointX = cc.bodyB.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - planePointY = cc.bodyB.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - tMat = cc.bodyA.m_xf.R; - for (i = 0; - i < cc.pointCount; ++i) { - tVec = cc.points[i].localPoint; - clipPointX = cc.bodyA.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); - clipPointY = cc.bodyA.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); - this.m_separations[i] = (clipPointX - planePointX) * this.m_normal.x + (clipPointY - planePointY) * this.m_normal.y - cc.radius; - this.m_points[i].Set(clipPointX, clipPointY); - } - this.m_normal.x *= (-1); - this.m_normal.y *= (-1); - } - break; - } - } - Box2D.postDefs.push(function () { - Box2D.Dynamics.Contacts.b2PositionSolverManifold.circlePointA = new b2Vec2(); - Box2D.Dynamics.Contacts.b2PositionSolverManifold.circlePointB = new b2Vec2(); - }); -})(); -(function () { - var b2Body = Box2D.Dynamics.b2Body, - b2BodyDef = Box2D.Dynamics.b2BodyDef, - b2ContactFilter = Box2D.Dynamics.b2ContactFilter, - b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse, - b2ContactListener = Box2D.Dynamics.b2ContactListener, - b2ContactManager = Box2D.Dynamics.b2ContactManager, - b2DebugDraw = Box2D.Dynamics.b2DebugDraw, - b2DestructionListener = Box2D.Dynamics.b2DestructionListener, - b2FilterData = Box2D.Dynamics.b2FilterData, - b2Fixture = Box2D.Dynamics.b2Fixture, - b2FixtureDef = Box2D.Dynamics.b2FixtureDef, - b2Island = Box2D.Dynamics.b2Island, - b2TimeStep = Box2D.Dynamics.b2TimeStep, - b2World = Box2D.Dynamics.b2World, - b2Mat22 = Box2D.Common.Math.b2Mat22, - b2Mat33 = Box2D.Common.Math.b2Mat33, - b2Math = Box2D.Common.Math.b2Math, - b2Sweep = Box2D.Common.Math.b2Sweep, - b2Transform = Box2D.Common.Math.b2Transform, - b2Vec2 = Box2D.Common.Math.b2Vec2, - b2Vec3 = Box2D.Common.Math.b2Vec3, - b2Color = Box2D.Common.b2Color, - b2internal = Box2D.Common.b2internal, - b2Settings = Box2D.Common.b2Settings, - b2CircleShape = Box2D.Collision.Shapes.b2CircleShape, - b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef, - b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape, - b2MassData = Box2D.Collision.Shapes.b2MassData, - b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape, - b2Shape = Box2D.Collision.Shapes.b2Shape, - b2BuoyancyController = Box2D.Dynamics.Controllers.b2BuoyancyController, - b2ConstantAccelController = Box2D.Dynamics.Controllers.b2ConstantAccelController, - b2ConstantForceController = Box2D.Dynamics.Controllers.b2ConstantForceController, - b2Controller = Box2D.Dynamics.Controllers.b2Controller, - b2ControllerEdge = Box2D.Dynamics.Controllers.b2ControllerEdge, - b2GravityController = Box2D.Dynamics.Controllers.b2GravityController, - b2TensorDampingController = Box2D.Dynamics.Controllers.b2TensorDampingController; - - Box2D.inherit(b2BuoyancyController, Box2D.Dynamics.Controllers.b2Controller); - b2BuoyancyController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype; - b2BuoyancyController.b2BuoyancyController = function () { - Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments); - this.normal = new b2Vec2(0, (-1)); - this.offset = 0; - this.density = 0; - this.velocity = new b2Vec2(0, 0); - this.linearDrag = 2; - this.angularDrag = 1; - this.useDensity = false; - this.useWorldGravity = true; - this.gravity = null; - }; - b2BuoyancyController.prototype.Step = function (step) { - if (!this.m_bodyList) return; - if (this.useWorldGravity) { - this.gravity = this.GetWorld().GetGravity().Copy(); - } - for (var i = this.m_bodyList; i; i = i.nextBody) { - var body = i.body; - if (body.IsAwake() == false) { - continue; - } - var areac = new b2Vec2(); - var massc = new b2Vec2(); - var area = 0.0; - var mass = 0.0; - for (var fixture = body.GetFixtureList(); fixture; fixture = fixture.GetNext()) { - var sc = new b2Vec2(); - var sarea = fixture.GetShape().ComputeSubmergedArea(this.normal, this.offset, body.GetTransform(), sc); - area += sarea; - areac.x += sarea * sc.x; - areac.y += sarea * sc.y; - var shapeDensity = 0; - if (this.useDensity) { - shapeDensity = 1; - } - else { - shapeDensity = 1; - } - mass += sarea * shapeDensity; - massc.x += sarea * sc.x * shapeDensity; - massc.y += sarea * sc.y * shapeDensity; - } - areac.x /= area; - areac.y /= area; - massc.x /= mass; - massc.y /= mass; - if (area < Number.MIN_VALUE) continue; - var buoyancyForce = this.gravity.GetNegative(); - buoyancyForce.Multiply(this.density * area); - body.ApplyForce(buoyancyForce, massc); - var dragForce = body.GetLinearVelocityFromWorldPoint(areac); - dragForce.Subtract(this.velocity); - dragForce.Multiply((-this.linearDrag * area)); - body.ApplyForce(dragForce, areac); - body.ApplyTorque((-body.GetInertia() / body.GetMass() * area * body.GetAngularVelocity() * this.angularDrag)); - } - } - b2BuoyancyController.prototype.Draw = function (debugDraw) { - var r = 1000; - var p1 = new b2Vec2(); - var p2 = new b2Vec2(); - p1.x = this.normal.x * this.offset + this.normal.y * r; - p1.y = this.normal.y * this.offset - this.normal.x * r; - p2.x = this.normal.x * this.offset - this.normal.y * r; - p2.y = this.normal.y * this.offset + this.normal.x * r; - var color = new b2Color(0, 0, 1); - debugDraw.DrawSegment(p1, p2, color); - } - Box2D.inherit(b2ConstantAccelController, Box2D.Dynamics.Controllers.b2Controller); - b2ConstantAccelController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype; - b2ConstantAccelController.b2ConstantAccelController = function () { - Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments); - this.A = new b2Vec2(0, 0); - }; - b2ConstantAccelController.prototype.Step = function (step) { - var smallA = new b2Vec2(this.A.x * step.dt, this.A.y * step.dt); - for (var i = this.m_bodyList; i; i = i.nextBody) { - var body = i.body; - if (!body.IsAwake()) continue; - body.SetLinearVelocity(new b2Vec2(body.GetLinearVelocity().x + smallA.x, body.GetLinearVelocity().y + smallA.y)); - } - } - Box2D.inherit(b2ConstantForceController, Box2D.Dynamics.Controllers.b2Controller); - b2ConstantForceController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype; - b2ConstantForceController.b2ConstantForceController = function () { - Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments); - this.F = new b2Vec2(0, 0); - }; - b2ConstantForceController.prototype.Step = function (step) { - for (var i = this.m_bodyList; i; i = i.nextBody) { - var body = i.body; - if (!body.IsAwake()) continue; - body.ApplyForce(this.F, body.GetWorldCenter()); - } - } - b2Controller.b2Controller = function () {}; - b2Controller.prototype.Step = function (step) {} - b2Controller.prototype.Draw = function (debugDraw) {} - b2Controller.prototype.AddBody = function (body) { - var edge = new b2ControllerEdge(); - edge.controller = this; - edge.body = body; - edge.nextBody = this.m_bodyList; - edge.prevBody = null; - this.m_bodyList = edge; - if (edge.nextBody) edge.nextBody.prevBody = edge; - this.m_bodyCount++; - edge.nextController = body.m_controllerList; - edge.prevController = null; - body.m_controllerList = edge; - if (edge.nextController) edge.nextController.prevController = edge; - body.m_controllerCount++; - } - b2Controller.prototype.RemoveBody = function (body) { - var edge = body.m_controllerList; - while (edge && edge.controller != this) - edge = edge.nextController; - if (edge.prevBody) edge.prevBody.nextBody = edge.nextBody; - if (edge.nextBody) edge.nextBody.prevBody = edge.prevBody; - if (edge.nextController) edge.nextController.prevController = edge.prevController; - if (edge.prevController) edge.prevController.nextController = edge.nextController; - if (this.m_bodyList == edge) this.m_bodyList = edge.nextBody; - if (body.m_controllerList == edge) body.m_controllerList = edge.nextController; - body.m_controllerCount--; - this.m_bodyCount--; - } - b2Controller.prototype.Clear = function () { - while (this.m_bodyList) - this.RemoveBody(this.m_bodyList.body); - } - b2Controller.prototype.GetNext = function () { - return this.m_next; - } - b2Controller.prototype.GetWorld = function () { - return this.m_world; - } - b2Controller.prototype.GetBodyList = function () { - return this.m_bodyList; - } - b2ControllerEdge.b2ControllerEdge = function () {}; - Box2D.inherit(b2GravityController, Box2D.Dynamics.Controllers.b2Controller); - b2GravityController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype; - b2GravityController.b2GravityController = function () { - Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments); - this.G = 1; - this.invSqr = true; - }; - b2GravityController.prototype.Step = function (step) { - var i = null; - var body1 = null; - var p1 = null; - var mass1 = 0; - var j = null; - var body2 = null; - var p2 = null; - var dx = 0; - var dy = 0; - var r2 = 0; - var f = null; - if (this.invSqr) { - for (i = this.m_bodyList; - i; i = i.nextBody) { - body1 = i.body; - p1 = body1.GetWorldCenter(); - mass1 = body1.GetMass(); - for (j = this.m_bodyList; - j != i; j = j.nextBody) { - body2 = j.body; - p2 = body2.GetWorldCenter(); - dx = p2.x - p1.x; - dy = p2.y - p1.y; - r2 = dx * dx + dy * dy; - if (r2 < Number.MIN_VALUE) continue; - f = new b2Vec2(dx, dy); - f.Multiply(this.G / r2 / Math.sqrt(r2) * mass1 * body2.GetMass()); - if (body1.IsAwake()) body1.ApplyForce(f, p1); - f.Multiply((-1)); - if (body2.IsAwake()) body2.ApplyForce(f, p2); - } - } - } - else { - for (i = this.m_bodyList; - i; i = i.nextBody) { - body1 = i.body; - p1 = body1.GetWorldCenter(); - mass1 = body1.GetMass(); - for (j = this.m_bodyList; - j != i; j = j.nextBody) { - body2 = j.body; - p2 = body2.GetWorldCenter(); - dx = p2.x - p1.x; - dy = p2.y - p1.y; - r2 = dx * dx + dy * dy; - if (r2 < Number.MIN_VALUE) continue; - f = new b2Vec2(dx, dy); - f.Multiply(this.G / r2 * mass1 * body2.GetMass()); - if (body1.IsAwake()) body1.ApplyForce(f, p1); - f.Multiply((-1)); - if (body2.IsAwake()) body2.ApplyForce(f, p2); - } - } - } - } - Box2D.inherit(b2TensorDampingController, Box2D.Dynamics.Controllers.b2Controller); - b2TensorDampingController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype; - b2TensorDampingController.b2TensorDampingController = function () { - Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments); - this.T = new b2Mat22(); - this.maxTimestep = 0; - }; - b2TensorDampingController.prototype.SetAxisAligned = function (xDamping, yDamping) { - if (xDamping === undefined) xDamping = 0; - if (yDamping === undefined) yDamping = 0; - this.T.col1.x = (-xDamping); - this.T.col1.y = 0; - this.T.col2.x = 0; - this.T.col2.y = (-yDamping); - if (xDamping > 0 || yDamping > 0) { - this.maxTimestep = 1 / Math.max(xDamping, yDamping); - } - else { - this.maxTimestep = 0; - } - } - b2TensorDampingController.prototype.Step = function (step) { - var timestep = step.dt; - if (timestep <= Number.MIN_VALUE) return; - if (timestep > this.maxTimestep && this.maxTimestep > 0) timestep = this.maxTimestep; - for (var i = this.m_bodyList; i; i = i.nextBody) { - var body = i.body; - if (!body.IsAwake()) { - continue; - } - var damping = body.GetWorldVector(b2Math.MulMV(this.T, body.GetLocalVector(body.GetLinearVelocity()))); - body.SetLinearVelocity(new b2Vec2(body.GetLinearVelocity().x + damping.x * timestep, body.GetLinearVelocity().y + damping.y * timestep)); - } - } -})(); -(function () { - var b2Color = Box2D.Common.b2Color, - b2internal = Box2D.Common.b2internal, - b2Settings = Box2D.Common.b2Settings, - b2Mat22 = Box2D.Common.Math.b2Mat22, - b2Mat33 = Box2D.Common.Math.b2Mat33, - b2Math = Box2D.Common.Math.b2Math, - b2Sweep = Box2D.Common.Math.b2Sweep, - b2Transform = Box2D.Common.Math.b2Transform, - b2Vec2 = Box2D.Common.Math.b2Vec2, - b2Vec3 = Box2D.Common.Math.b2Vec3, - b2DistanceJoint = Box2D.Dynamics.Joints.b2DistanceJoint, - b2DistanceJointDef = Box2D.Dynamics.Joints.b2DistanceJointDef, - b2FrictionJoint = Box2D.Dynamics.Joints.b2FrictionJoint, - b2FrictionJointDef = Box2D.Dynamics.Joints.b2FrictionJointDef, - b2GearJoint = Box2D.Dynamics.Joints.b2GearJoint, - b2GearJointDef = Box2D.Dynamics.Joints.b2GearJointDef, - b2Jacobian = Box2D.Dynamics.Joints.b2Jacobian, - b2Joint = Box2D.Dynamics.Joints.b2Joint, - b2JointDef = Box2D.Dynamics.Joints.b2JointDef, - b2JointEdge = Box2D.Dynamics.Joints.b2JointEdge, - b2LineJoint = Box2D.Dynamics.Joints.b2LineJoint, - b2LineJointDef = Box2D.Dynamics.Joints.b2LineJointDef, - b2MouseJoint = Box2D.Dynamics.Joints.b2MouseJoint, - b2MouseJointDef = Box2D.Dynamics.Joints.b2MouseJointDef, - b2PrismaticJoint = Box2D.Dynamics.Joints.b2PrismaticJoint, - b2PrismaticJointDef = Box2D.Dynamics.Joints.b2PrismaticJointDef, - b2PulleyJoint = Box2D.Dynamics.Joints.b2PulleyJoint, - b2PulleyJointDef = Box2D.Dynamics.Joints.b2PulleyJointDef, - b2RevoluteJoint = Box2D.Dynamics.Joints.b2RevoluteJoint, - b2RevoluteJointDef = Box2D.Dynamics.Joints.b2RevoluteJointDef, - b2WeldJoint = Box2D.Dynamics.Joints.b2WeldJoint, - b2WeldJointDef = Box2D.Dynamics.Joints.b2WeldJointDef, - b2Body = Box2D.Dynamics.b2Body, - b2BodyDef = Box2D.Dynamics.b2BodyDef, - b2ContactFilter = Box2D.Dynamics.b2ContactFilter, - b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse, - b2ContactListener = Box2D.Dynamics.b2ContactListener, - b2ContactManager = Box2D.Dynamics.b2ContactManager, - b2DebugDraw = Box2D.Dynamics.b2DebugDraw, - b2DestructionListener = Box2D.Dynamics.b2DestructionListener, - b2FilterData = Box2D.Dynamics.b2FilterData, - b2Fixture = Box2D.Dynamics.b2Fixture, - b2FixtureDef = Box2D.Dynamics.b2FixtureDef, - b2Island = Box2D.Dynamics.b2Island, - b2TimeStep = Box2D.Dynamics.b2TimeStep, - b2World = Box2D.Dynamics.b2World; - - Box2D.inherit(b2DistanceJoint, Box2D.Dynamics.Joints.b2Joint); - b2DistanceJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; - b2DistanceJoint.b2DistanceJoint = function () { - Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); - this.m_localAnchor1 = new b2Vec2(); - this.m_localAnchor2 = new b2Vec2(); - this.m_u = new b2Vec2(); - }; - b2DistanceJoint.prototype.GetAnchorA = function () { - return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); - } - b2DistanceJoint.prototype.GetAnchorB = function () { - return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); - } - b2DistanceJoint.prototype.GetReactionForce = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return new b2Vec2(inv_dt * this.m_impulse * this.m_u.x, inv_dt * this.m_impulse * this.m_u.y); - } - b2DistanceJoint.prototype.GetReactionTorque = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return 0.0; - } - b2DistanceJoint.prototype.GetLength = function () { - return this.m_length; - } - b2DistanceJoint.prototype.SetLength = function (length) { - if (length === undefined) length = 0; - this.m_length = length; - } - b2DistanceJoint.prototype.GetFrequency = function () { - return this.m_frequencyHz; - } - b2DistanceJoint.prototype.SetFrequency = function (hz) { - if (hz === undefined) hz = 0; - this.m_frequencyHz = hz; - } - b2DistanceJoint.prototype.GetDampingRatio = function () { - return this.m_dampingRatio; - } - b2DistanceJoint.prototype.SetDampingRatio = function (ratio) { - if (ratio === undefined) ratio = 0; - this.m_dampingRatio = ratio; - } - b2DistanceJoint.prototype.b2DistanceJoint = function (def) { - this.__super.b2Joint.call(this, def); - var tMat; - var tX = 0; - var tY = 0; - this.m_localAnchor1.SetV(def.localAnchorA); - this.m_localAnchor2.SetV(def.localAnchorB); - this.m_length = def.length; - this.m_frequencyHz = def.frequencyHz; - this.m_dampingRatio = def.dampingRatio; - this.m_impulse = 0.0; - this.m_gamma = 0.0; - this.m_bias = 0.0; - } - b2DistanceJoint.prototype.InitVelocityConstraints = function (step) { - var tMat; - var tX = 0; - var bA = this.m_bodyA; - var bB = this.m_bodyB; - tMat = bA.m_xf.R; - var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; - var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; - tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = bB.m_xf.R; - var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; - var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - this.m_u.x = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; - this.m_u.y = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; - var length = Math.sqrt(this.m_u.x * this.m_u.x + this.m_u.y * this.m_u.y); - if (length > b2Settings.b2_linearSlop) { - this.m_u.Multiply(1.0 / length); - } - else { - this.m_u.SetZero(); - } - var cr1u = (r1X * this.m_u.y - r1Y * this.m_u.x); - var cr2u = (r2X * this.m_u.y - r2Y * this.m_u.x); - var invMass = bA.m_invMass + bA.m_invI * cr1u * cr1u + bB.m_invMass + bB.m_invI * cr2u * cr2u; - this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0; - if (this.m_frequencyHz > 0.0) { - var C = length - this.m_length; - var omega = 2.0 * Math.PI * this.m_frequencyHz; - var d = 2.0 * this.m_mass * this.m_dampingRatio * omega; - var k = this.m_mass * omega * omega; - this.m_gamma = step.dt * (d + step.dt * k); - this.m_gamma = this.m_gamma != 0.0 ? 1 / this.m_gamma : 0.0; - this.m_bias = C * step.dt * k * this.m_gamma; - this.m_mass = invMass + this.m_gamma; - this.m_mass = this.m_mass != 0.0 ? 1.0 / this.m_mass : 0.0; - } - if (step.warmStarting) { - this.m_impulse *= step.dtRatio; - var PX = this.m_impulse * this.m_u.x; - var PY = this.m_impulse * this.m_u.y; - bA.m_linearVelocity.x -= bA.m_invMass * PX; - bA.m_linearVelocity.y -= bA.m_invMass * PY; - bA.m_angularVelocity -= bA.m_invI * (r1X * PY - r1Y * PX); - bB.m_linearVelocity.x += bB.m_invMass * PX; - bB.m_linearVelocity.y += bB.m_invMass * PY; - bB.m_angularVelocity += bB.m_invI * (r2X * PY - r2Y * PX); - } - else { - this.m_impulse = 0.0; - } - } - b2DistanceJoint.prototype.SolveVelocityConstraints = function (step) { - var tMat; - var bA = this.m_bodyA; - var bB = this.m_bodyB; - tMat = bA.m_xf.R; - var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; - var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; - var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = bB.m_xf.R; - var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; - var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - var v1X = bA.m_linearVelocity.x + ((-bA.m_angularVelocity * r1Y)); - var v1Y = bA.m_linearVelocity.y + (bA.m_angularVelocity * r1X); - var v2X = bB.m_linearVelocity.x + ((-bB.m_angularVelocity * r2Y)); - var v2Y = bB.m_linearVelocity.y + (bB.m_angularVelocity * r2X); - var Cdot = (this.m_u.x * (v2X - v1X) + this.m_u.y * (v2Y - v1Y)); - var impulse = (-this.m_mass * (Cdot + this.m_bias + this.m_gamma * this.m_impulse)); - this.m_impulse += impulse; - var PX = impulse * this.m_u.x; - var PY = impulse * this.m_u.y; - bA.m_linearVelocity.x -= bA.m_invMass * PX; - bA.m_linearVelocity.y -= bA.m_invMass * PY; - bA.m_angularVelocity -= bA.m_invI * (r1X * PY - r1Y * PX); - bB.m_linearVelocity.x += bB.m_invMass * PX; - bB.m_linearVelocity.y += bB.m_invMass * PY; - bB.m_angularVelocity += bB.m_invI * (r2X * PY - r2Y * PX); - } - b2DistanceJoint.prototype.SolvePositionConstraints = function (baumgarte) { - if (baumgarte === undefined) baumgarte = 0; - var tMat; - if (this.m_frequencyHz > 0.0) { - return true; - } - var bA = this.m_bodyA; - var bB = this.m_bodyB; - tMat = bA.m_xf.R; - var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; - var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; - var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = bB.m_xf.R; - var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; - var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - var dX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; - var dY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; - var length = Math.sqrt(dX * dX + dY * dY); - dX /= length; - dY /= length; - var C = length - this.m_length; - C = b2Math.Clamp(C, (-b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection); - var impulse = (-this.m_mass * C); - this.m_u.Set(dX, dY); - var PX = impulse * this.m_u.x; - var PY = impulse * this.m_u.y; - bA.m_sweep.c.x -= bA.m_invMass * PX; - bA.m_sweep.c.y -= bA.m_invMass * PY; - bA.m_sweep.a -= bA.m_invI * (r1X * PY - r1Y * PX); - bB.m_sweep.c.x += bB.m_invMass * PX; - bB.m_sweep.c.y += bB.m_invMass * PY; - bB.m_sweep.a += bB.m_invI * (r2X * PY - r2Y * PX); - bA.SynchronizeTransform(); - bB.SynchronizeTransform(); - return b2Math.Abs(C) < b2Settings.b2_linearSlop; - } - Box2D.inherit(b2DistanceJointDef, Box2D.Dynamics.Joints.b2JointDef); - b2DistanceJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; - b2DistanceJointDef.b2DistanceJointDef = function () { - Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); - this.localAnchorA = new b2Vec2(); - this.localAnchorB = new b2Vec2(); - }; - b2DistanceJointDef.prototype.b2DistanceJointDef = function () { - this.__super.b2JointDef.call(this); - this.type = b2Joint.e_distanceJoint; - this.length = 1.0; - this.frequencyHz = 0.0; - this.dampingRatio = 0.0; - } - b2DistanceJointDef.prototype.Initialize = function (bA, bB, anchorA, anchorB) { - this.bodyA = bA; - this.bodyB = bB; - this.localAnchorA.SetV(this.bodyA.GetLocalPoint(anchorA)); - this.localAnchorB.SetV(this.bodyB.GetLocalPoint(anchorB)); - var dX = anchorB.x - anchorA.x; - var dY = anchorB.y - anchorA.y; - this.length = Math.sqrt(dX * dX + dY * dY); - this.frequencyHz = 0.0; - this.dampingRatio = 0.0; - } - Box2D.inherit(b2FrictionJoint, Box2D.Dynamics.Joints.b2Joint); - b2FrictionJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; - b2FrictionJoint.b2FrictionJoint = function () { - Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); - this.m_localAnchorA = new b2Vec2(); - this.m_localAnchorB = new b2Vec2(); - this.m_linearMass = new b2Mat22(); - this.m_linearImpulse = new b2Vec2(); - }; - b2FrictionJoint.prototype.GetAnchorA = function () { - return this.m_bodyA.GetWorldPoint(this.m_localAnchorA); - } - b2FrictionJoint.prototype.GetAnchorB = function () { - return this.m_bodyB.GetWorldPoint(this.m_localAnchorB); - } - b2FrictionJoint.prototype.GetReactionForce = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return new b2Vec2(inv_dt * this.m_linearImpulse.x, inv_dt * this.m_linearImpulse.y); - } - b2FrictionJoint.prototype.GetReactionTorque = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return inv_dt * this.m_angularImpulse; - } - b2FrictionJoint.prototype.SetMaxForce = function (force) { - if (force === undefined) force = 0; - this.m_maxForce = force; - } - b2FrictionJoint.prototype.GetMaxForce = function () { - return this.m_maxForce; - } - b2FrictionJoint.prototype.SetMaxTorque = function (torque) { - if (torque === undefined) torque = 0; - this.m_maxTorque = torque; - } - b2FrictionJoint.prototype.GetMaxTorque = function () { - return this.m_maxTorque; - } - b2FrictionJoint.prototype.b2FrictionJoint = function (def) { - this.__super.b2Joint.call(this, def); - this.m_localAnchorA.SetV(def.localAnchorA); - this.m_localAnchorB.SetV(def.localAnchorB); - this.m_linearMass.SetZero(); - this.m_angularMass = 0.0; - this.m_linearImpulse.SetZero(); - this.m_angularImpulse = 0.0; - this.m_maxForce = def.maxForce; - this.m_maxTorque = def.maxTorque; - } - b2FrictionJoint.prototype.InitVelocityConstraints = function (step) { - var tMat; - var tX = 0; - var bA = this.m_bodyA; - var bB = this.m_bodyB; - tMat = bA.m_xf.R; - var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x; - var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y; - tX = (tMat.col1.x * rAX + tMat.col2.x * rAY); - rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY); - rAX = tX; - tMat = bB.m_xf.R; - var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x; - var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * rBX + tMat.col2.x * rBY); - rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY); - rBX = tX; - var mA = bA.m_invMass; - var mB = bB.m_invMass; - var iA = bA.m_invI; - var iB = bB.m_invI; - var K = new b2Mat22(); - K.col1.x = mA + mB; - K.col2.x = 0.0; - K.col1.y = 0.0; - K.col2.y = mA + mB; - K.col1.x += iA * rAY * rAY; - K.col2.x += (-iA * rAX * rAY); - K.col1.y += (-iA * rAX * rAY); - K.col2.y += iA * rAX * rAX; - K.col1.x += iB * rBY * rBY; - K.col2.x += (-iB * rBX * rBY); - K.col1.y += (-iB * rBX * rBY); - K.col2.y += iB * rBX * rBX; - K.GetInverse(this.m_linearMass); - this.m_angularMass = iA + iB; - if (this.m_angularMass > 0.0) { - this.m_angularMass = 1.0 / this.m_angularMass; - } - if (step.warmStarting) { - this.m_linearImpulse.x *= step.dtRatio; - this.m_linearImpulse.y *= step.dtRatio; - this.m_angularImpulse *= step.dtRatio; - var P = this.m_linearImpulse; - bA.m_linearVelocity.x -= mA * P.x; - bA.m_linearVelocity.y -= mA * P.y; - bA.m_angularVelocity -= iA * (rAX * P.y - rAY * P.x + this.m_angularImpulse); - bB.m_linearVelocity.x += mB * P.x; - bB.m_linearVelocity.y += mB * P.y; - bB.m_angularVelocity += iB * (rBX * P.y - rBY * P.x + this.m_angularImpulse); - } - else { - this.m_linearImpulse.SetZero(); - this.m_angularImpulse = 0.0; - } - } - b2FrictionJoint.prototype.SolveVelocityConstraints = function (step) { - var tMat; - var tX = 0; - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var vA = bA.m_linearVelocity; - var wA = bA.m_angularVelocity; - var vB = bB.m_linearVelocity; - var wB = bB.m_angularVelocity; - var mA = bA.m_invMass; - var mB = bB.m_invMass; - var iA = bA.m_invI; - var iB = bB.m_invI; - tMat = bA.m_xf.R; - var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x; - var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y; - tX = (tMat.col1.x * rAX + tMat.col2.x * rAY); - rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY); - rAX = tX; - tMat = bB.m_xf.R; - var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x; - var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * rBX + tMat.col2.x * rBY); - rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY); - rBX = tX; - var maxImpulse = 0; { - var Cdot = wB - wA; - var impulse = (-this.m_angularMass * Cdot); - var oldImpulse = this.m_angularImpulse; - maxImpulse = step.dt * this.m_maxTorque; - this.m_angularImpulse = b2Math.Clamp(this.m_angularImpulse + impulse, (-maxImpulse), maxImpulse); - impulse = this.m_angularImpulse - oldImpulse; - wA -= iA * impulse; - wB += iB * impulse; - } { - var CdotX = vB.x - wB * rBY - vA.x + wA * rAY; - var CdotY = vB.y + wB * rBX - vA.y - wA * rAX; - var impulseV = b2Math.MulMV(this.m_linearMass, new b2Vec2((-CdotX), (-CdotY))); - var oldImpulseV = this.m_linearImpulse.Copy(); - this.m_linearImpulse.Add(impulseV); - maxImpulse = step.dt * this.m_maxForce; - if (this.m_linearImpulse.LengthSquared() > maxImpulse * maxImpulse) { - this.m_linearImpulse.Normalize(); - this.m_linearImpulse.Multiply(maxImpulse); - } - impulseV = b2Math.SubtractVV(this.m_linearImpulse, oldImpulseV); - vA.x -= mA * impulseV.x; - vA.y -= mA * impulseV.y; - wA -= iA * (rAX * impulseV.y - rAY * impulseV.x); - vB.x += mB * impulseV.x; - vB.y += mB * impulseV.y; - wB += iB * (rBX * impulseV.y - rBY * impulseV.x); - } - bA.m_angularVelocity = wA; - bB.m_angularVelocity = wB; - } - b2FrictionJoint.prototype.SolvePositionConstraints = function (baumgarte) { - if (baumgarte === undefined) baumgarte = 0; - return true; - } - Box2D.inherit(b2FrictionJointDef, Box2D.Dynamics.Joints.b2JointDef); - b2FrictionJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; - b2FrictionJointDef.b2FrictionJointDef = function () { - Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); - this.localAnchorA = new b2Vec2(); - this.localAnchorB = new b2Vec2(); - }; - b2FrictionJointDef.prototype.b2FrictionJointDef = function () { - this.__super.b2JointDef.call(this); - this.type = b2Joint.e_frictionJoint; - this.maxForce = 0.0; - this.maxTorque = 0.0; - } - b2FrictionJointDef.prototype.Initialize = function (bA, bB, anchor) { - this.bodyA = bA; - this.bodyB = bB; - this.localAnchorA.SetV(this.bodyA.GetLocalPoint(anchor)); - this.localAnchorB.SetV(this.bodyB.GetLocalPoint(anchor)); - } - Box2D.inherit(b2GearJoint, Box2D.Dynamics.Joints.b2Joint); - b2GearJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; - b2GearJoint.b2GearJoint = function () { - Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); - this.m_groundAnchor1 = new b2Vec2(); - this.m_groundAnchor2 = new b2Vec2(); - this.m_localAnchor1 = new b2Vec2(); - this.m_localAnchor2 = new b2Vec2(); - this.m_J = new b2Jacobian(); - }; - b2GearJoint.prototype.GetAnchorA = function () { - return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); - } - b2GearJoint.prototype.GetAnchorB = function () { - return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); - } - b2GearJoint.prototype.GetReactionForce = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return new b2Vec2(inv_dt * this.m_impulse * this.m_J.linearB.x, inv_dt * this.m_impulse * this.m_J.linearB.y); - } - b2GearJoint.prototype.GetReactionTorque = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - var tMat = this.m_bodyB.m_xf.R; - var rX = this.m_localAnchor1.x - this.m_bodyB.m_sweep.localCenter.x; - var rY = this.m_localAnchor1.y - this.m_bodyB.m_sweep.localCenter.y; - var tX = tMat.col1.x * rX + tMat.col2.x * rY; - rY = tMat.col1.y * rX + tMat.col2.y * rY; - rX = tX; - var PX = this.m_impulse * this.m_J.linearB.x; - var PY = this.m_impulse * this.m_J.linearB.y; - return inv_dt * (this.m_impulse * this.m_J.angularB - rX * PY + rY * PX); - } - b2GearJoint.prototype.GetRatio = function () { - return this.m_ratio; - } - b2GearJoint.prototype.SetRatio = function (ratio) { - if (ratio === undefined) ratio = 0; - this.m_ratio = ratio; - } - b2GearJoint.prototype.b2GearJoint = function (def) { - this.__super.b2Joint.call(this, def); - var type1 = parseInt(def.joint1.m_type); - var type2 = parseInt(def.joint2.m_type); - this.m_revolute1 = null; - this.m_prismatic1 = null; - this.m_revolute2 = null; - this.m_prismatic2 = null; - var coordinate1 = 0; - var coordinate2 = 0; - this.m_ground1 = def.joint1.GetBodyA(); - this.m_bodyA = def.joint1.GetBodyB(); - if (type1 == b2Joint.e_revoluteJoint) { - this.m_revolute1 = (def.joint1 instanceof b2RevoluteJoint ? def.joint1 : null); - this.m_groundAnchor1.SetV(this.m_revolute1.m_localAnchor1); - this.m_localAnchor1.SetV(this.m_revolute1.m_localAnchor2); - coordinate1 = this.m_revolute1.GetJointAngle(); - } - else { - this.m_prismatic1 = (def.joint1 instanceof b2PrismaticJoint ? def.joint1 : null); - this.m_groundAnchor1.SetV(this.m_prismatic1.m_localAnchor1); - this.m_localAnchor1.SetV(this.m_prismatic1.m_localAnchor2); - coordinate1 = this.m_prismatic1.GetJointTranslation(); - } - this.m_ground2 = def.joint2.GetBodyA(); - this.m_bodyB = def.joint2.GetBodyB(); - if (type2 == b2Joint.e_revoluteJoint) { - this.m_revolute2 = (def.joint2 instanceof b2RevoluteJoint ? def.joint2 : null); - this.m_groundAnchor2.SetV(this.m_revolute2.m_localAnchor1); - this.m_localAnchor2.SetV(this.m_revolute2.m_localAnchor2); - coordinate2 = this.m_revolute2.GetJointAngle(); - } - else { - this.m_prismatic2 = (def.joint2 instanceof b2PrismaticJoint ? def.joint2 : null); - this.m_groundAnchor2.SetV(this.m_prismatic2.m_localAnchor1); - this.m_localAnchor2.SetV(this.m_prismatic2.m_localAnchor2); - coordinate2 = this.m_prismatic2.GetJointTranslation(); - } - this.m_ratio = def.ratio; - this.m_constant = coordinate1 + this.m_ratio * coordinate2; - this.m_impulse = 0.0; - } - b2GearJoint.prototype.InitVelocityConstraints = function (step) { - var g1 = this.m_ground1; - var g2 = this.m_ground2; - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var ugX = 0; - var ugY = 0; - var rX = 0; - var rY = 0; - var tMat; - var tVec; - var crug = 0; - var tX = 0; - var K = 0.0; - this.m_J.SetZero(); - if (this.m_revolute1) { - this.m_J.angularA = (-1.0); - K += bA.m_invI; - } - else { - tMat = g1.m_xf.R; - tVec = this.m_prismatic1.m_localXAxis1; - ugX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - ugY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - tMat = bA.m_xf.R; - rX = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; - rY = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; - tX = tMat.col1.x * rX + tMat.col2.x * rY; - rY = tMat.col1.y * rX + tMat.col2.y * rY; - rX = tX; - crug = rX * ugY - rY * ugX; - this.m_J.linearA.Set((-ugX), (-ugY)); - this.m_J.angularA = (-crug); - K += bA.m_invMass + bA.m_invI * crug * crug; - } - if (this.m_revolute2) { - this.m_J.angularB = (-this.m_ratio); - K += this.m_ratio * this.m_ratio * bB.m_invI; - } - else { - tMat = g2.m_xf.R; - tVec = this.m_prismatic2.m_localXAxis1; - ugX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; - ugY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; - tMat = bB.m_xf.R; - rX = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; - rY = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; - tX = tMat.col1.x * rX + tMat.col2.x * rY; - rY = tMat.col1.y * rX + tMat.col2.y * rY; - rX = tX; - crug = rX * ugY - rY * ugX; - this.m_J.linearB.Set((-this.m_ratio * ugX), (-this.m_ratio * ugY)); - this.m_J.angularB = (-this.m_ratio * crug); - K += this.m_ratio * this.m_ratio * (bB.m_invMass + bB.m_invI * crug * crug); - } - this.m_mass = K > 0.0 ? 1.0 / K : 0.0; - if (step.warmStarting) { - bA.m_linearVelocity.x += bA.m_invMass * this.m_impulse * this.m_J.linearA.x; - bA.m_linearVelocity.y += bA.m_invMass * this.m_impulse * this.m_J.linearA.y; - bA.m_angularVelocity += bA.m_invI * this.m_impulse * this.m_J.angularA; - bB.m_linearVelocity.x += bB.m_invMass * this.m_impulse * this.m_J.linearB.x; - bB.m_linearVelocity.y += bB.m_invMass * this.m_impulse * this.m_J.linearB.y; - bB.m_angularVelocity += bB.m_invI * this.m_impulse * this.m_J.angularB; - } - else { - this.m_impulse = 0.0; - } - } - b2GearJoint.prototype.SolveVelocityConstraints = function (step) { - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var Cdot = this.m_J.Compute(bA.m_linearVelocity, bA.m_angularVelocity, bB.m_linearVelocity, bB.m_angularVelocity); - var impulse = (-this.m_mass * Cdot); - this.m_impulse += impulse; - bA.m_linearVelocity.x += bA.m_invMass * impulse * this.m_J.linearA.x; - bA.m_linearVelocity.y += bA.m_invMass * impulse * this.m_J.linearA.y; - bA.m_angularVelocity += bA.m_invI * impulse * this.m_J.angularA; - bB.m_linearVelocity.x += bB.m_invMass * impulse * this.m_J.linearB.x; - bB.m_linearVelocity.y += bB.m_invMass * impulse * this.m_J.linearB.y; - bB.m_angularVelocity += bB.m_invI * impulse * this.m_J.angularB; - } - b2GearJoint.prototype.SolvePositionConstraints = function (baumgarte) { - if (baumgarte === undefined) baumgarte = 0; - var linearError = 0.0; - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var coordinate1 = 0; - var coordinate2 = 0; - if (this.m_revolute1) { - coordinate1 = this.m_revolute1.GetJointAngle(); - } - else { - coordinate1 = this.m_prismatic1.GetJointTranslation(); - } - if (this.m_revolute2) { - coordinate2 = this.m_revolute2.GetJointAngle(); - } - else { - coordinate2 = this.m_prismatic2.GetJointTranslation(); - } - var C = this.m_constant - (coordinate1 + this.m_ratio * coordinate2); - var impulse = (-this.m_mass * C); - bA.m_sweep.c.x += bA.m_invMass * impulse * this.m_J.linearA.x; - bA.m_sweep.c.y += bA.m_invMass * impulse * this.m_J.linearA.y; - bA.m_sweep.a += bA.m_invI * impulse * this.m_J.angularA; - bB.m_sweep.c.x += bB.m_invMass * impulse * this.m_J.linearB.x; - bB.m_sweep.c.y += bB.m_invMass * impulse * this.m_J.linearB.y; - bB.m_sweep.a += bB.m_invI * impulse * this.m_J.angularB; - bA.SynchronizeTransform(); - bB.SynchronizeTransform(); - return linearError < b2Settings.b2_linearSlop; - } - Box2D.inherit(b2GearJointDef, Box2D.Dynamics.Joints.b2JointDef); - b2GearJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; - b2GearJointDef.b2GearJointDef = function () { - Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); - }; - b2GearJointDef.prototype.b2GearJointDef = function () { - this.__super.b2JointDef.call(this); - this.type = b2Joint.e_gearJoint; - this.joint1 = null; - this.joint2 = null; - this.ratio = 1.0; - } - b2Jacobian.b2Jacobian = function () { - this.linearA = new b2Vec2(); - this.linearB = new b2Vec2(); - }; - b2Jacobian.prototype.SetZero = function () { - this.linearA.SetZero(); - this.angularA = 0.0; - this.linearB.SetZero(); - this.angularB = 0.0; - } - b2Jacobian.prototype.Set = function (x1, a1, x2, a2) { - if (a1 === undefined) a1 = 0; - if (a2 === undefined) a2 = 0; - this.linearA.SetV(x1); - this.angularA = a1; - this.linearB.SetV(x2); - this.angularB = a2; - } - b2Jacobian.prototype.Compute = function (x1, a1, x2, a2) { - if (a1 === undefined) a1 = 0; - if (a2 === undefined) a2 = 0; - return (this.linearA.x * x1.x + this.linearA.y * x1.y) + this.angularA * a1 + (this.linearB.x * x2.x + this.linearB.y * x2.y) + this.angularB * a2; - } - b2Joint.b2Joint = function () { - this.m_edgeA = new b2JointEdge(); - this.m_edgeB = new b2JointEdge(); - this.m_localCenterA = new b2Vec2(); - this.m_localCenterB = new b2Vec2(); - }; - b2Joint.prototype.GetType = function () { - return this.m_type; - } - b2Joint.prototype.GetAnchorA = function () { - return null; - } - b2Joint.prototype.GetAnchorB = function () { - return null; - } - b2Joint.prototype.GetReactionForce = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return null; - } - b2Joint.prototype.GetReactionTorque = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return 0.0; - } - b2Joint.prototype.GetBodyA = function () { - return this.m_bodyA; - } - b2Joint.prototype.GetBodyB = function () { - return this.m_bodyB; - } - b2Joint.prototype.GetNext = function () { - return this.m_next; - } - b2Joint.prototype.GetUserData = function () { - return this.m_userData; - } - b2Joint.prototype.SetUserData = function (data) { - this.m_userData = data; - } - b2Joint.prototype.IsActive = function () { - return this.m_bodyA.IsActive() && this.m_bodyB.IsActive(); - } - b2Joint.Create = function (def, allocator) { - var joint = null; - switch (def.type) { - case b2Joint.e_distanceJoint: - { - joint = new b2DistanceJoint((def instanceof b2DistanceJointDef ? def : null)); - } - break; - case b2Joint.e_mouseJoint: - { - joint = new b2MouseJoint((def instanceof b2MouseJointDef ? def : null)); - } - break; - case b2Joint.e_prismaticJoint: - { - joint = new b2PrismaticJoint((def instanceof b2PrismaticJointDef ? def : null)); - } - break; - case b2Joint.e_revoluteJoint: - { - joint = new b2RevoluteJoint((def instanceof b2RevoluteJointDef ? def : null)); - } - break; - case b2Joint.e_pulleyJoint: - { - joint = new b2PulleyJoint((def instanceof b2PulleyJointDef ? def : null)); - } - break; - case b2Joint.e_gearJoint: - { - joint = new b2GearJoint((def instanceof b2GearJointDef ? def : null)); - } - break; - case b2Joint.e_lineJoint: - { - joint = new b2LineJoint((def instanceof b2LineJointDef ? def : null)); - } - break; - case b2Joint.e_weldJoint: - { - joint = new b2WeldJoint((def instanceof b2WeldJointDef ? def : null)); - } - break; - case b2Joint.e_frictionJoint: - { - joint = new b2FrictionJoint((def instanceof b2FrictionJointDef ? def : null)); - } - break; - default: - break; - } - return joint; - } - b2Joint.Destroy = function (joint, allocator) {} - b2Joint.prototype.b2Joint = function (def) { - b2Settings.b2Assert(def.bodyA != def.bodyB); - this.m_type = def.type; - this.m_prev = null; - this.m_next = null; - this.m_bodyA = def.bodyA; - this.m_bodyB = def.bodyB; - this.m_collideConnected = def.collideConnected; - this.m_islandFlag = false; - this.m_userData = def.userData; - } - b2Joint.prototype.InitVelocityConstraints = function (step) {} - b2Joint.prototype.SolveVelocityConstraints = function (step) {} - b2Joint.prototype.FinalizeVelocityConstraints = function () {} - b2Joint.prototype.SolvePositionConstraints = function (baumgarte) { - if (baumgarte === undefined) baumgarte = 0; - return false; - } - Box2D.postDefs.push(function () { - Box2D.Dynamics.Joints.b2Joint.e_unknownJoint = 0; - Box2D.Dynamics.Joints.b2Joint.e_revoluteJoint = 1; - Box2D.Dynamics.Joints.b2Joint.e_prismaticJoint = 2; - Box2D.Dynamics.Joints.b2Joint.e_distanceJoint = 3; - Box2D.Dynamics.Joints.b2Joint.e_pulleyJoint = 4; - Box2D.Dynamics.Joints.b2Joint.e_mouseJoint = 5; - Box2D.Dynamics.Joints.b2Joint.e_gearJoint = 6; - Box2D.Dynamics.Joints.b2Joint.e_lineJoint = 7; - Box2D.Dynamics.Joints.b2Joint.e_weldJoint = 8; - Box2D.Dynamics.Joints.b2Joint.e_frictionJoint = 9; - Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit = 0; - Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit = 1; - Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit = 2; - Box2D.Dynamics.Joints.b2Joint.e_equalLimits = 3; - }); - b2JointDef.b2JointDef = function () {}; - b2JointDef.prototype.b2JointDef = function () { - this.type = b2Joint.e_unknownJoint; - this.userData = null; - this.bodyA = null; - this.bodyB = null; - this.collideConnected = false; - } - b2JointEdge.b2JointEdge = function () {}; - Box2D.inherit(b2LineJoint, Box2D.Dynamics.Joints.b2Joint); - b2LineJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; - b2LineJoint.b2LineJoint = function () { - Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); - this.m_localAnchor1 = new b2Vec2(); - this.m_localAnchor2 = new b2Vec2(); - this.m_localXAxis1 = new b2Vec2(); - this.m_localYAxis1 = new b2Vec2(); - this.m_axis = new b2Vec2(); - this.m_perp = new b2Vec2(); - this.m_K = new b2Mat22(); - this.m_impulse = new b2Vec2(); - }; - b2LineJoint.prototype.GetAnchorA = function () { - return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); - } - b2LineJoint.prototype.GetAnchorB = function () { - return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); - } - b2LineJoint.prototype.GetReactionForce = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return new b2Vec2(inv_dt * (this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.x), inv_dt * (this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.y)); - } - b2LineJoint.prototype.GetReactionTorque = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return inv_dt * this.m_impulse.y; - } - b2LineJoint.prototype.GetJointTranslation = function () { - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var tMat; - var p1 = bA.GetWorldPoint(this.m_localAnchor1); - var p2 = bB.GetWorldPoint(this.m_localAnchor2); - var dX = p2.x - p1.x; - var dY = p2.y - p1.y; - var axis = bA.GetWorldVector(this.m_localXAxis1); - var translation = axis.x * dX + axis.y * dY; - return translation; - } - b2LineJoint.prototype.GetJointSpeed = function () { - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var tMat; - tMat = bA.m_xf.R; - var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; - var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; - var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = bB.m_xf.R; - var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; - var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - var p1X = bA.m_sweep.c.x + r1X; - var p1Y = bA.m_sweep.c.y + r1Y; - var p2X = bB.m_sweep.c.x + r2X; - var p2Y = bB.m_sweep.c.y + r2Y; - var dX = p2X - p1X; - var dY = p2Y - p1Y; - var axis = bA.GetWorldVector(this.m_localXAxis1); - var v1 = bA.m_linearVelocity; - var v2 = bB.m_linearVelocity; - var w1 = bA.m_angularVelocity; - var w2 = bB.m_angularVelocity; - var speed = (dX * ((-w1 * axis.y)) + dY * (w1 * axis.x)) + (axis.x * (((v2.x + ((-w2 * r2Y))) - v1.x) - ((-w1 * r1Y))) + axis.y * (((v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X))); - return speed; - } - b2LineJoint.prototype.IsLimitEnabled = function () { - return this.m_enableLimit; - } - b2LineJoint.prototype.EnableLimit = function (flag) { - this.m_bodyA.SetAwake(true); - this.m_bodyB.SetAwake(true); - this.m_enableLimit = flag; - } - b2LineJoint.prototype.GetLowerLimit = function () { - return this.m_lowerTranslation; - } - b2LineJoint.prototype.GetUpperLimit = function () { - return this.m_upperTranslation; - } - b2LineJoint.prototype.SetLimits = function (lower, upper) { - if (lower === undefined) lower = 0; - if (upper === undefined) upper = 0; - this.m_bodyA.SetAwake(true); - this.m_bodyB.SetAwake(true); - this.m_lowerTranslation = lower; - this.m_upperTranslation = upper; - } - b2LineJoint.prototype.IsMotorEnabled = function () { - return this.m_enableMotor; - } - b2LineJoint.prototype.EnableMotor = function (flag) { - this.m_bodyA.SetAwake(true); - this.m_bodyB.SetAwake(true); - this.m_enableMotor = flag; - } - b2LineJoint.prototype.SetMotorSpeed = function (speed) { - if (speed === undefined) speed = 0; - this.m_bodyA.SetAwake(true); - this.m_bodyB.SetAwake(true); - this.m_motorSpeed = speed; - } - b2LineJoint.prototype.GetMotorSpeed = function () { - return this.m_motorSpeed; - } - b2LineJoint.prototype.SetMaxMotorForce = function (force) { - if (force === undefined) force = 0; - this.m_bodyA.SetAwake(true); - this.m_bodyB.SetAwake(true); - this.m_maxMotorForce = force; - } - b2LineJoint.prototype.GetMaxMotorForce = function () { - return this.m_maxMotorForce; - } - b2LineJoint.prototype.GetMotorForce = function () { - return this.m_motorImpulse; - } - b2LineJoint.prototype.b2LineJoint = function (def) { - this.__super.b2Joint.call(this, def); - var tMat; - var tX = 0; - var tY = 0; - this.m_localAnchor1.SetV(def.localAnchorA); - this.m_localAnchor2.SetV(def.localAnchorB); - this.m_localXAxis1.SetV(def.localAxisA); - this.m_localYAxis1.x = (-this.m_localXAxis1.y); - this.m_localYAxis1.y = this.m_localXAxis1.x; - this.m_impulse.SetZero(); - this.m_motorMass = 0.0; - this.m_motorImpulse = 0.0; - this.m_lowerTranslation = def.lowerTranslation; - this.m_upperTranslation = def.upperTranslation; - this.m_maxMotorForce = def.maxMotorForce; - this.m_motorSpeed = def.motorSpeed; - this.m_enableLimit = def.enableLimit; - this.m_enableMotor = def.enableMotor; - this.m_limitState = b2Joint.e_inactiveLimit; - this.m_axis.SetZero(); - this.m_perp.SetZero(); - } - b2LineJoint.prototype.InitVelocityConstraints = function (step) { - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var tMat; - var tX = 0; - this.m_localCenterA.SetV(bA.GetLocalCenter()); - this.m_localCenterB.SetV(bB.GetLocalCenter()); - var xf1 = bA.GetTransform(); - var xf2 = bB.GetTransform(); - tMat = bA.m_xf.R; - var r1X = this.m_localAnchor1.x - this.m_localCenterA.x; - var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y; - tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = bB.m_xf.R; - var r2X = this.m_localAnchor2.x - this.m_localCenterB.x; - var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - var dX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; - var dY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; - this.m_invMassA = bA.m_invMass; - this.m_invMassB = bB.m_invMass; - this.m_invIA = bA.m_invI; - this.m_invIB = bB.m_invI; { - this.m_axis.SetV(b2Math.MulMV(xf1.R, this.m_localXAxis1)); - this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x; - this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x; - this.m_motorMass = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_a1 * this.m_a1 + this.m_invIB * this.m_a2 * this.m_a2; - this.m_motorMass = this.m_motorMass > Number.MIN_VALUE ? 1.0 / this.m_motorMass : 0.0; - } { - this.m_perp.SetV(b2Math.MulMV(xf1.R, this.m_localYAxis1)); - this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x; - this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x; - var m1 = this.m_invMassA; - var m2 = this.m_invMassB; - var i1 = this.m_invIA; - var i2 = this.m_invIB; - this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; - this.m_K.col1.y = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2; - this.m_K.col2.x = this.m_K.col1.y; - this.m_K.col2.y = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2; - } - if (this.m_enableLimit) { - var jointTransition = this.m_axis.x * dX + this.m_axis.y * dY; - if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) { - this.m_limitState = b2Joint.e_equalLimits; - } - else if (jointTransition <= this.m_lowerTranslation) { - if (this.m_limitState != b2Joint.e_atLowerLimit) { - this.m_limitState = b2Joint.e_atLowerLimit; - this.m_impulse.y = 0.0; - } - } - else if (jointTransition >= this.m_upperTranslation) { - if (this.m_limitState != b2Joint.e_atUpperLimit) { - this.m_limitState = b2Joint.e_atUpperLimit; - this.m_impulse.y = 0.0; - } - } - else { - this.m_limitState = b2Joint.e_inactiveLimit; - this.m_impulse.y = 0.0; - } - } - else { - this.m_limitState = b2Joint.e_inactiveLimit; - } - if (this.m_enableMotor == false) { - this.m_motorImpulse = 0.0; - } - if (step.warmStarting) { - this.m_impulse.x *= step.dtRatio; - this.m_impulse.y *= step.dtRatio; - this.m_motorImpulse *= step.dtRatio; - var PX = this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.x; - var PY = this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.y; - var L1 = this.m_impulse.x * this.m_s1 + (this.m_motorImpulse + this.m_impulse.y) * this.m_a1; - var L2 = this.m_impulse.x * this.m_s2 + (this.m_motorImpulse + this.m_impulse.y) * this.m_a2; - bA.m_linearVelocity.x -= this.m_invMassA * PX; - bA.m_linearVelocity.y -= this.m_invMassA * PY; - bA.m_angularVelocity -= this.m_invIA * L1; - bB.m_linearVelocity.x += this.m_invMassB * PX; - bB.m_linearVelocity.y += this.m_invMassB * PY; - bB.m_angularVelocity += this.m_invIB * L2; - } - else { - this.m_impulse.SetZero(); - this.m_motorImpulse = 0.0; - } - } - b2LineJoint.prototype.SolveVelocityConstraints = function (step) { - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var v1 = bA.m_linearVelocity; - var w1 = bA.m_angularVelocity; - var v2 = bB.m_linearVelocity; - var w2 = bB.m_angularVelocity; - var PX = 0; - var PY = 0; - var L1 = 0; - var L2 = 0; - if (this.m_enableMotor && this.m_limitState != b2Joint.e_equalLimits) { - var Cdot = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1; - var impulse = this.m_motorMass * (this.m_motorSpeed - Cdot); - var oldImpulse = this.m_motorImpulse; - var maxImpulse = step.dt * this.m_maxMotorForce; - this.m_motorImpulse = b2Math.Clamp(this.m_motorImpulse + impulse, (-maxImpulse), maxImpulse); - impulse = this.m_motorImpulse - oldImpulse; - PX = impulse * this.m_axis.x; - PY = impulse * this.m_axis.y; - L1 = impulse * this.m_a1; - L2 = impulse * this.m_a2; - v1.x -= this.m_invMassA * PX; - v1.y -= this.m_invMassA * PY; - w1 -= this.m_invIA * L1; - v2.x += this.m_invMassB * PX; - v2.y += this.m_invMassB * PY; - w2 += this.m_invIB * L2; - } - var Cdot1 = this.m_perp.x * (v2.x - v1.x) + this.m_perp.y * (v2.y - v1.y) + this.m_s2 * w2 - this.m_s1 * w1; - if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) { - var Cdot2 = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1; - var f1 = this.m_impulse.Copy(); - var df = this.m_K.Solve(new b2Vec2(), (-Cdot1), (-Cdot2)); - this.m_impulse.Add(df); - if (this.m_limitState == b2Joint.e_atLowerLimit) { - this.m_impulse.y = b2Math.Max(this.m_impulse.y, 0.0); - } - else if (this.m_limitState == b2Joint.e_atUpperLimit) { - this.m_impulse.y = b2Math.Min(this.m_impulse.y, 0.0); - } - var b = (-Cdot1) - (this.m_impulse.y - f1.y) * this.m_K.col2.x; - var f2r = 0; - if (this.m_K.col1.x != 0.0) { - f2r = b / this.m_K.col1.x + f1.x; - } - else { - f2r = f1.x; - } - this.m_impulse.x = f2r; - df.x = this.m_impulse.x - f1.x; - df.y = this.m_impulse.y - f1.y; - PX = df.x * this.m_perp.x + df.y * this.m_axis.x; - PY = df.x * this.m_perp.y + df.y * this.m_axis.y; - L1 = df.x * this.m_s1 + df.y * this.m_a1; - L2 = df.x * this.m_s2 + df.y * this.m_a2; - v1.x -= this.m_invMassA * PX; - v1.y -= this.m_invMassA * PY; - w1 -= this.m_invIA * L1; - v2.x += this.m_invMassB * PX; - v2.y += this.m_invMassB * PY; - w2 += this.m_invIB * L2; - } - else { - var df2 = 0; - if (this.m_K.col1.x != 0.0) { - df2 = ((-Cdot1)) / this.m_K.col1.x; - } - else { - df2 = 0.0; - } - this.m_impulse.x += df2; - PX = df2 * this.m_perp.x; - PY = df2 * this.m_perp.y; - L1 = df2 * this.m_s1; - L2 = df2 * this.m_s2; - v1.x -= this.m_invMassA * PX; - v1.y -= this.m_invMassA * PY; - w1 -= this.m_invIA * L1; - v2.x += this.m_invMassB * PX; - v2.y += this.m_invMassB * PY; - w2 += this.m_invIB * L2; - } - bA.m_linearVelocity.SetV(v1); - bA.m_angularVelocity = w1; - bB.m_linearVelocity.SetV(v2); - bB.m_angularVelocity = w2; - } - b2LineJoint.prototype.SolvePositionConstraints = function (baumgarte) { - if (baumgarte === undefined) baumgarte = 0; - var limitC = 0; - var oldLimitImpulse = 0; - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var c1 = bA.m_sweep.c; - var a1 = bA.m_sweep.a; - var c2 = bB.m_sweep.c; - var a2 = bB.m_sweep.a; - var tMat; - var tX = 0; - var m1 = 0; - var m2 = 0; - var i1 = 0; - var i2 = 0; - var linearError = 0.0; - var angularError = 0.0; - var active = false; - var C2 = 0.0; - var R1 = b2Mat22.FromAngle(a1); - var R2 = b2Mat22.FromAngle(a2); - tMat = R1; - var r1X = this.m_localAnchor1.x - this.m_localCenterA.x; - var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y; - tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = R2; - var r2X = this.m_localAnchor2.x - this.m_localCenterB.x; - var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - var dX = c2.x + r2X - c1.x - r1X; - var dY = c2.y + r2Y - c1.y - r1Y; - if (this.m_enableLimit) { - this.m_axis = b2Math.MulMV(R1, this.m_localXAxis1); - this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x; - this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x; - var translation = this.m_axis.x * dX + this.m_axis.y * dY; - if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) { - C2 = b2Math.Clamp(translation, (-b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection); - linearError = b2Math.Abs(translation); - active = true; - } - else if (translation <= this.m_lowerTranslation) { - C2 = b2Math.Clamp(translation - this.m_lowerTranslation + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0); - linearError = this.m_lowerTranslation - translation; - active = true; - } - else if (translation >= this.m_upperTranslation) { - C2 = b2Math.Clamp(translation - this.m_upperTranslation + b2Settings.b2_linearSlop, 0.0, b2Settings.b2_maxLinearCorrection); - linearError = translation - this.m_upperTranslation; - active = true; - } - } - this.m_perp = b2Math.MulMV(R1, this.m_localYAxis1); - this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x; - this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x; - var impulse = new b2Vec2(); - var C1 = this.m_perp.x * dX + this.m_perp.y * dY; - linearError = b2Math.Max(linearError, b2Math.Abs(C1)); - angularError = 0.0; - if (active) { - m1 = this.m_invMassA; - m2 = this.m_invMassB; - i1 = this.m_invIA; - i2 = this.m_invIB; - this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; - this.m_K.col1.y = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2; - this.m_K.col2.x = this.m_K.col1.y; - this.m_K.col2.y = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2; - this.m_K.Solve(impulse, (-C1), (-C2)); - } - else { - m1 = this.m_invMassA; - m2 = this.m_invMassB; - i1 = this.m_invIA; - i2 = this.m_invIB; - var k11 = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; - var impulse1 = 0; - if (k11 != 0.0) { - impulse1 = ((-C1)) / k11; - } - else { - impulse1 = 0.0; - } - impulse.x = impulse1; - impulse.y = 0.0; - } - var PX = impulse.x * this.m_perp.x + impulse.y * this.m_axis.x; - var PY = impulse.x * this.m_perp.y + impulse.y * this.m_axis.y; - var L1 = impulse.x * this.m_s1 + impulse.y * this.m_a1; - var L2 = impulse.x * this.m_s2 + impulse.y * this.m_a2; - c1.x -= this.m_invMassA * PX; - c1.y -= this.m_invMassA * PY; - a1 -= this.m_invIA * L1; - c2.x += this.m_invMassB * PX; - c2.y += this.m_invMassB * PY; - a2 += this.m_invIB * L2; - bA.m_sweep.a = a1; - bB.m_sweep.a = a2; - bA.SynchronizeTransform(); - bB.SynchronizeTransform(); - - return linearError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop; - } - Box2D.inherit(b2LineJointDef, Box2D.Dynamics.Joints.b2JointDef); - b2LineJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; - b2LineJointDef.b2LineJointDef = function () { - Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); - this.localAnchorA = new b2Vec2(); - this.localAnchorB = new b2Vec2(); - this.localAxisA = new b2Vec2(); - }; - b2LineJointDef.prototype.b2LineJointDef = function () { - this.__super.b2JointDef.call(this); - this.type = b2Joint.e_lineJoint; - this.localAxisA.Set(1.0, 0.0); - this.enableLimit = false; - this.lowerTranslation = 0.0; - this.upperTranslation = 0.0; - this.enableMotor = false; - this.maxMotorForce = 0.0; - this.motorSpeed = 0.0; - } - b2LineJointDef.prototype.Initialize = function (bA, bB, anchor, axis) { - this.bodyA = bA; - this.bodyB = bB; - this.localAnchorA = this.bodyA.GetLocalPoint(anchor); - this.localAnchorB = this.bodyB.GetLocalPoint(anchor); - this.localAxisA = this.bodyA.GetLocalVector(axis); - } - Box2D.inherit(b2MouseJoint, Box2D.Dynamics.Joints.b2Joint); - b2MouseJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; - b2MouseJoint.b2MouseJoint = function () { - Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); - this.K = new b2Mat22(); - this.K1 = new b2Mat22(); - this.K2 = new b2Mat22(); - this.m_localAnchor = new b2Vec2(); - this.m_target = new b2Vec2(); - this.m_impulse = new b2Vec2(); - this.m_mass = new b2Mat22(); - this.m_C = new b2Vec2(); - }; - b2MouseJoint.prototype.GetAnchorA = function () { - return this.m_target; - } - b2MouseJoint.prototype.GetAnchorB = function () { - return this.m_bodyB.GetWorldPoint(this.m_localAnchor); - } - b2MouseJoint.prototype.GetReactionForce = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return new b2Vec2(inv_dt * this.m_impulse.x, inv_dt * this.m_impulse.y); - } - b2MouseJoint.prototype.GetReactionTorque = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return 0.0; - } - b2MouseJoint.prototype.GetTarget = function () { - return this.m_target; - } - b2MouseJoint.prototype.SetTarget = function (target) { - if (this.m_bodyB.IsAwake() == false) { - this.m_bodyB.SetAwake(true); - } - this.m_target = target; - } - b2MouseJoint.prototype.GetMaxForce = function () { - return this.m_maxForce; - } - b2MouseJoint.prototype.SetMaxForce = function (maxForce) { - if (maxForce === undefined) maxForce = 0; - this.m_maxForce = maxForce; - } - b2MouseJoint.prototype.GetFrequency = function () { - return this.m_frequencyHz; - } - b2MouseJoint.prototype.SetFrequency = function (hz) { - if (hz === undefined) hz = 0; - this.m_frequencyHz = hz; - } - b2MouseJoint.prototype.GetDampingRatio = function () { - return this.m_dampingRatio; - } - b2MouseJoint.prototype.SetDampingRatio = function (ratio) { - if (ratio === undefined) ratio = 0; - this.m_dampingRatio = ratio; - } - b2MouseJoint.prototype.b2MouseJoint = function (def) { - this.__super.b2Joint.call(this, def); - this.m_target.SetV(def.target); - var tX = this.m_target.x - this.m_bodyB.m_xf.position.x; - var tY = this.m_target.y - this.m_bodyB.m_xf.position.y; - var tMat = this.m_bodyB.m_xf.R; - this.m_localAnchor.x = (tX * tMat.col1.x + tY * tMat.col1.y); - this.m_localAnchor.y = (tX * tMat.col2.x + tY * tMat.col2.y); - this.m_maxForce = def.maxForce; - this.m_impulse.SetZero(); - this.m_frequencyHz = def.frequencyHz; - this.m_dampingRatio = def.dampingRatio; - this.m_beta = 0.0; - this.m_gamma = 0.0; - } - b2MouseJoint.prototype.InitVelocityConstraints = function (step) { - var b = this.m_bodyB; - var mass = b.GetMass(); - var omega = 2.0 * Math.PI * this.m_frequencyHz; - var d = 2.0 * mass * this.m_dampingRatio * omega; - var k = mass * omega * omega; - this.m_gamma = step.dt * (d + step.dt * k); - this.m_gamma = this.m_gamma != 0 ? 1 / this.m_gamma : 0.0; - this.m_beta = step.dt * k * this.m_gamma; - var tMat;tMat = b.m_xf.R; - var rX = this.m_localAnchor.x - b.m_sweep.localCenter.x; - var rY = this.m_localAnchor.y - b.m_sweep.localCenter.y; - var tX = (tMat.col1.x * rX + tMat.col2.x * rY);rY = (tMat.col1.y * rX + tMat.col2.y * rY); - rX = tX; - var invMass = b.m_invMass; - var invI = b.m_invI;this.K1.col1.x = invMass; - this.K1.col2.x = 0.0; - this.K1.col1.y = 0.0; - this.K1.col2.y = invMass; - this.K2.col1.x = invI * rY * rY; - this.K2.col2.x = (-invI * rX * rY); - this.K2.col1.y = (-invI * rX * rY); - this.K2.col2.y = invI * rX * rX; - this.K.SetM(this.K1); - this.K.AddM(this.K2); - this.K.col1.x += this.m_gamma; - this.K.col2.y += this.m_gamma; - this.K.GetInverse(this.m_mass); - this.m_C.x = b.m_sweep.c.x + rX - this.m_target.x; - this.m_C.y = b.m_sweep.c.y + rY - this.m_target.y; - b.m_angularVelocity *= 0.98; - this.m_impulse.x *= step.dtRatio; - this.m_impulse.y *= step.dtRatio; - b.m_linearVelocity.x += invMass * this.m_impulse.x; - b.m_linearVelocity.y += invMass * this.m_impulse.y; - b.m_angularVelocity += invI * (rX * this.m_impulse.y - rY * this.m_impulse.x); - } - b2MouseJoint.prototype.SolveVelocityConstraints = function (step) { - var b = this.m_bodyB; - var tMat; - var tX = 0; - var tY = 0; - tMat = b.m_xf.R; - var rX = this.m_localAnchor.x - b.m_sweep.localCenter.x; - var rY = this.m_localAnchor.y - b.m_sweep.localCenter.y; - tX = (tMat.col1.x * rX + tMat.col2.x * rY); - rY = (tMat.col1.y * rX + tMat.col2.y * rY); - rX = tX; - var CdotX = b.m_linearVelocity.x + ((-b.m_angularVelocity * rY)); - var CdotY = b.m_linearVelocity.y + (b.m_angularVelocity * rX); - tMat = this.m_mass; - tX = CdotX + this.m_beta * this.m_C.x + this.m_gamma * this.m_impulse.x; - tY = CdotY + this.m_beta * this.m_C.y + this.m_gamma * this.m_impulse.y; - var impulseX = (-(tMat.col1.x * tX + tMat.col2.x * tY)); - var impulseY = (-(tMat.col1.y * tX + tMat.col2.y * tY)); - var oldImpulseX = this.m_impulse.x; - var oldImpulseY = this.m_impulse.y; - this.m_impulse.x += impulseX; - this.m_impulse.y += impulseY; - var maxImpulse = step.dt * this.m_maxForce; - if (this.m_impulse.LengthSquared() > maxImpulse * maxImpulse) { - this.m_impulse.Multiply(maxImpulse / this.m_impulse.Length()); - } - impulseX = this.m_impulse.x - oldImpulseX; - impulseY = this.m_impulse.y - oldImpulseY; - b.m_linearVelocity.x += b.m_invMass * impulseX; - b.m_linearVelocity.y += b.m_invMass * impulseY; - b.m_angularVelocity += b.m_invI * (rX * impulseY - rY * impulseX); - } - b2MouseJoint.prototype.SolvePositionConstraints = function (baumgarte) { - if (baumgarte === undefined) baumgarte = 0; - return true; - } - Box2D.inherit(b2MouseJointDef, Box2D.Dynamics.Joints.b2JointDef); - b2MouseJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; - b2MouseJointDef.b2MouseJointDef = function () { - Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); - this.target = new b2Vec2(); - }; - b2MouseJointDef.prototype.b2MouseJointDef = function () { - this.__super.b2JointDef.call(this); - this.type = b2Joint.e_mouseJoint; - this.maxForce = 0.0; - this.frequencyHz = 5.0; - this.dampingRatio = 0.7; - } - Box2D.inherit(b2PrismaticJoint, Box2D.Dynamics.Joints.b2Joint); - b2PrismaticJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; - b2PrismaticJoint.b2PrismaticJoint = function () { - Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); - this.m_localAnchor1 = new b2Vec2(); - this.m_localAnchor2 = new b2Vec2(); - this.m_localXAxis1 = new b2Vec2(); - this.m_localYAxis1 = new b2Vec2(); - this.m_axis = new b2Vec2(); - this.m_perp = new b2Vec2(); - this.m_K = new b2Mat33(); - this.m_impulse = new b2Vec3(); - }; - b2PrismaticJoint.prototype.GetAnchorA = function () { - return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); - } - b2PrismaticJoint.prototype.GetAnchorB = function () { - return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); - } - b2PrismaticJoint.prototype.GetReactionForce = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return new b2Vec2(inv_dt * (this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.x), inv_dt * (this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.y)); - } - b2PrismaticJoint.prototype.GetReactionTorque = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return inv_dt * this.m_impulse.y; - } - b2PrismaticJoint.prototype.GetJointTranslation = function () { - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var tMat; - var p1 = bA.GetWorldPoint(this.m_localAnchor1); - var p2 = bB.GetWorldPoint(this.m_localAnchor2); - var dX = p2.x - p1.x; - var dY = p2.y - p1.y; - var axis = bA.GetWorldVector(this.m_localXAxis1); - var translation = axis.x * dX + axis.y * dY; - return translation; - } - b2PrismaticJoint.prototype.GetJointSpeed = function () { - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var tMat; - tMat = bA.m_xf.R; - var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; - var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; - var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = bB.m_xf.R; - var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; - var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - var p1X = bA.m_sweep.c.x + r1X; - var p1Y = bA.m_sweep.c.y + r1Y; - var p2X = bB.m_sweep.c.x + r2X; - var p2Y = bB.m_sweep.c.y + r2Y; - var dX = p2X - p1X; - var dY = p2Y - p1Y; - var axis = bA.GetWorldVector(this.m_localXAxis1); - var v1 = bA.m_linearVelocity; - var v2 = bB.m_linearVelocity; - var w1 = bA.m_angularVelocity; - var w2 = bB.m_angularVelocity; - var speed = (dX * ((-w1 * axis.y)) + dY * (w1 * axis.x)) + (axis.x * (((v2.x + ((-w2 * r2Y))) - v1.x) - ((-w1 * r1Y))) + axis.y * (((v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X))); - return speed; - } - b2PrismaticJoint.prototype.IsLimitEnabled = function () { - return this.m_enableLimit; - } - b2PrismaticJoint.prototype.EnableLimit = function (flag) { - this.m_bodyA.SetAwake(true); - this.m_bodyB.SetAwake(true); - this.m_enableLimit = flag; - } - b2PrismaticJoint.prototype.GetLowerLimit = function () { - return this.m_lowerTranslation; - } - b2PrismaticJoint.prototype.GetUpperLimit = function () { - return this.m_upperTranslation; - } - b2PrismaticJoint.prototype.SetLimits = function (lower, upper) { - if (lower === undefined) lower = 0; - if (upper === undefined) upper = 0; - this.m_bodyA.SetAwake(true); - this.m_bodyB.SetAwake(true); - this.m_lowerTranslation = lower; - this.m_upperTranslation = upper; - } - b2PrismaticJoint.prototype.IsMotorEnabled = function () { - return this.m_enableMotor; - } - b2PrismaticJoint.prototype.EnableMotor = function (flag) { - this.m_bodyA.SetAwake(true); - this.m_bodyB.SetAwake(true); - this.m_enableMotor = flag; - } - b2PrismaticJoint.prototype.SetMotorSpeed = function (speed) { - if (speed === undefined) speed = 0; - this.m_bodyA.SetAwake(true); - this.m_bodyB.SetAwake(true); - this.m_motorSpeed = speed; - } - b2PrismaticJoint.prototype.GetMotorSpeed = function () { - return this.m_motorSpeed; - } - b2PrismaticJoint.prototype.SetMaxMotorForce = function (force) { - if (force === undefined) force = 0; - this.m_bodyA.SetAwake(true); - this.m_bodyB.SetAwake(true); - this.m_maxMotorForce = force; - } - b2PrismaticJoint.prototype.GetMotorForce = function () { - return this.m_motorImpulse; - } - b2PrismaticJoint.prototype.b2PrismaticJoint = function (def) { - this.__super.b2Joint.call(this, def); - var tMat; - var tX = 0; - var tY = 0; - this.m_localAnchor1.SetV(def.localAnchorA); - this.m_localAnchor2.SetV(def.localAnchorB); - this.m_localXAxis1.SetV(def.localAxisA); - this.m_localYAxis1.x = (-this.m_localXAxis1.y); - this.m_localYAxis1.y = this.m_localXAxis1.x; - this.m_refAngle = def.referenceAngle; - this.m_impulse.SetZero(); - this.m_motorMass = 0.0; - this.m_motorImpulse = 0.0; - this.m_lowerTranslation = def.lowerTranslation; - this.m_upperTranslation = def.upperTranslation; - this.m_maxMotorForce = def.maxMotorForce; - this.m_motorSpeed = def.motorSpeed; - this.m_enableLimit = def.enableLimit; - this.m_enableMotor = def.enableMotor; - this.m_limitState = b2Joint.e_inactiveLimit; - this.m_axis.SetZero(); - this.m_perp.SetZero(); - } - b2PrismaticJoint.prototype.InitVelocityConstraints = function (step) { - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var tMat; - var tX = 0; - this.m_localCenterA.SetV(bA.GetLocalCenter()); - this.m_localCenterB.SetV(bB.GetLocalCenter()); - var xf1 = bA.GetTransform(); - var xf2 = bB.GetTransform(); - tMat = bA.m_xf.R; - var r1X = this.m_localAnchor1.x - this.m_localCenterA.x; - var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y; - tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = bB.m_xf.R; - var r2X = this.m_localAnchor2.x - this.m_localCenterB.x; - var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - var dX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; - var dY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; - this.m_invMassA = bA.m_invMass; - this.m_invMassB = bB.m_invMass; - this.m_invIA = bA.m_invI; - this.m_invIB = bB.m_invI; { - this.m_axis.SetV(b2Math.MulMV(xf1.R, this.m_localXAxis1)); - this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x; - this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x; - this.m_motorMass = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_a1 * this.m_a1 + this.m_invIB * this.m_a2 * this.m_a2; - if (this.m_motorMass > Number.MIN_VALUE) this.m_motorMass = 1.0 / this.m_motorMass; - } { - this.m_perp.SetV(b2Math.MulMV(xf1.R, this.m_localYAxis1)); - this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x; - this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x; - var m1 = this.m_invMassA; - var m2 = this.m_invMassB; - var i1 = this.m_invIA; - var i2 = this.m_invIB; - this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; - this.m_K.col1.y = i1 * this.m_s1 + i2 * this.m_s2; - this.m_K.col1.z = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2; - this.m_K.col2.x = this.m_K.col1.y; - this.m_K.col2.y = i1 + i2; - this.m_K.col2.z = i1 * this.m_a1 + i2 * this.m_a2; - this.m_K.col3.x = this.m_K.col1.z; - this.m_K.col3.y = this.m_K.col2.z; - this.m_K.col3.z = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2; - } - if (this.m_enableLimit) { - var jointTransition = this.m_axis.x * dX + this.m_axis.y * dY; - if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) { - this.m_limitState = b2Joint.e_equalLimits; - } - else if (jointTransition <= this.m_lowerTranslation) { - if (this.m_limitState != b2Joint.e_atLowerLimit) { - this.m_limitState = b2Joint.e_atLowerLimit; - this.m_impulse.z = 0.0; - } - } - else if (jointTransition >= this.m_upperTranslation) { - if (this.m_limitState != b2Joint.e_atUpperLimit) { - this.m_limitState = b2Joint.e_atUpperLimit; - this.m_impulse.z = 0.0; - } - } - else { - this.m_limitState = b2Joint.e_inactiveLimit; - this.m_impulse.z = 0.0; - } - } - else { - this.m_limitState = b2Joint.e_inactiveLimit; - } - if (this.m_enableMotor == false) { - this.m_motorImpulse = 0.0; - } - if (step.warmStarting) { - this.m_impulse.x *= step.dtRatio; - this.m_impulse.y *= step.dtRatio; - this.m_motorImpulse *= step.dtRatio; - var PX = this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.x; - var PY = this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.y; - var L1 = this.m_impulse.x * this.m_s1 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1; - var L2 = this.m_impulse.x * this.m_s2 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2; - bA.m_linearVelocity.x -= this.m_invMassA * PX; - bA.m_linearVelocity.y -= this.m_invMassA * PY; - bA.m_angularVelocity -= this.m_invIA * L1; - bB.m_linearVelocity.x += this.m_invMassB * PX; - bB.m_linearVelocity.y += this.m_invMassB * PY; - bB.m_angularVelocity += this.m_invIB * L2; - } - else { - this.m_impulse.SetZero(); - this.m_motorImpulse = 0.0; - } - } - b2PrismaticJoint.prototype.SolveVelocityConstraints = function (step) { - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var v1 = bA.m_linearVelocity; - var w1 = bA.m_angularVelocity; - var v2 = bB.m_linearVelocity; - var w2 = bB.m_angularVelocity; - var PX = 0; - var PY = 0; - var L1 = 0; - var L2 = 0; - if (this.m_enableMotor && this.m_limitState != b2Joint.e_equalLimits) { - var Cdot = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1; - var impulse = this.m_motorMass * (this.m_motorSpeed - Cdot); - var oldImpulse = this.m_motorImpulse; - var maxImpulse = step.dt * this.m_maxMotorForce; - this.m_motorImpulse = b2Math.Clamp(this.m_motorImpulse + impulse, (-maxImpulse), maxImpulse); - impulse = this.m_motorImpulse - oldImpulse; - PX = impulse * this.m_axis.x; - PY = impulse * this.m_axis.y; - L1 = impulse * this.m_a1; - L2 = impulse * this.m_a2; - v1.x -= this.m_invMassA * PX; - v1.y -= this.m_invMassA * PY; - w1 -= this.m_invIA * L1; - v2.x += this.m_invMassB * PX; - v2.y += this.m_invMassB * PY; - w2 += this.m_invIB * L2; - } - var Cdot1X = this.m_perp.x * (v2.x - v1.x) + this.m_perp.y * (v2.y - v1.y) + this.m_s2 * w2 - this.m_s1 * w1; - var Cdot1Y = w2 - w1; - if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) { - var Cdot2 = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1; - var f1 = this.m_impulse.Copy(); - var df = this.m_K.Solve33(new b2Vec3(), (-Cdot1X), (-Cdot1Y), (-Cdot2)); - this.m_impulse.Add(df); - if (this.m_limitState == b2Joint.e_atLowerLimit) { - this.m_impulse.z = b2Math.Max(this.m_impulse.z, 0.0); - } - else if (this.m_limitState == b2Joint.e_atUpperLimit) { - this.m_impulse.z = b2Math.Min(this.m_impulse.z, 0.0); - } - var bX = (-Cdot1X) - (this.m_impulse.z - f1.z) * this.m_K.col3.x; - var bY = (-Cdot1Y) - (this.m_impulse.z - f1.z) * this.m_K.col3.y; - var f2r = this.m_K.Solve22(new b2Vec2(), bX, bY); - f2r.x += f1.x; - f2r.y += f1.y; - this.m_impulse.x = f2r.x; - this.m_impulse.y = f2r.y; - df.x = this.m_impulse.x - f1.x; - df.y = this.m_impulse.y - f1.y; - df.z = this.m_impulse.z - f1.z; - PX = df.x * this.m_perp.x + df.z * this.m_axis.x; - PY = df.x * this.m_perp.y + df.z * this.m_axis.y; - L1 = df.x * this.m_s1 + df.y + df.z * this.m_a1; - L2 = df.x * this.m_s2 + df.y + df.z * this.m_a2; - v1.x -= this.m_invMassA * PX; - v1.y -= this.m_invMassA * PY; - w1 -= this.m_invIA * L1; - v2.x += this.m_invMassB * PX; - v2.y += this.m_invMassB * PY; - w2 += this.m_invIB * L2; - } - else { - var df2 = this.m_K.Solve22(new b2Vec2(), (-Cdot1X), (-Cdot1Y)); - this.m_impulse.x += df2.x; - this.m_impulse.y += df2.y; - PX = df2.x * this.m_perp.x; - PY = df2.x * this.m_perp.y; - L1 = df2.x * this.m_s1 + df2.y; - L2 = df2.x * this.m_s2 + df2.y; - v1.x -= this.m_invMassA * PX; - v1.y -= this.m_invMassA * PY; - w1 -= this.m_invIA * L1; - v2.x += this.m_invMassB * PX; - v2.y += this.m_invMassB * PY; - w2 += this.m_invIB * L2; - } - bA.m_linearVelocity.SetV(v1); - bA.m_angularVelocity = w1; - bB.m_linearVelocity.SetV(v2); - bB.m_angularVelocity = w2; - } - b2PrismaticJoint.prototype.SolvePositionConstraints = function (baumgarte) { - if (baumgarte === undefined) baumgarte = 0; - var limitC = 0; - var oldLimitImpulse = 0; - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var c1 = bA.m_sweep.c; - var a1 = bA.m_sweep.a; - var c2 = bB.m_sweep.c; - var a2 = bB.m_sweep.a; - var tMat; - var tX = 0; - var m1 = 0; - var m2 = 0; - var i1 = 0; - var i2 = 0; - var linearError = 0.0; - var angularError = 0.0; - var active = false; - var C2 = 0.0; - var R1 = b2Mat22.FromAngle(a1); - var R2 = b2Mat22.FromAngle(a2); - tMat = R1; - var r1X = this.m_localAnchor1.x - this.m_localCenterA.x; - var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y; - tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = R2; - var r2X = this.m_localAnchor2.x - this.m_localCenterB.x; - var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - var dX = c2.x + r2X - c1.x - r1X; - var dY = c2.y + r2Y - c1.y - r1Y; - if (this.m_enableLimit) { - this.m_axis = b2Math.MulMV(R1, this.m_localXAxis1); - this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x; - this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x; - var translation = this.m_axis.x * dX + this.m_axis.y * dY; - if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) { - C2 = b2Math.Clamp(translation, (-b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection); - linearError = b2Math.Abs(translation); - active = true; - } - else if (translation <= this.m_lowerTranslation) { - C2 = b2Math.Clamp(translation - this.m_lowerTranslation + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0); - linearError = this.m_lowerTranslation - translation; - active = true; - } - else if (translation >= this.m_upperTranslation) { - C2 = b2Math.Clamp(translation - this.m_upperTranslation + b2Settings.b2_linearSlop, 0.0, b2Settings.b2_maxLinearCorrection); - linearError = translation - this.m_upperTranslation; - active = true; - } - } - this.m_perp = b2Math.MulMV(R1, this.m_localYAxis1); - this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x; - this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x; - var impulse = new b2Vec3(); - var C1X = this.m_perp.x * dX + this.m_perp.y * dY; - var C1Y = a2 - a1 - this.m_refAngle; - linearError = b2Math.Max(linearError, b2Math.Abs(C1X)); - angularError = b2Math.Abs(C1Y); - if (active) { - m1 = this.m_invMassA; - m2 = this.m_invMassB; - i1 = this.m_invIA; - i2 = this.m_invIB; - this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; - this.m_K.col1.y = i1 * this.m_s1 + i2 * this.m_s2; - this.m_K.col1.z = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2; - this.m_K.col2.x = this.m_K.col1.y; - this.m_K.col2.y = i1 + i2; - this.m_K.col2.z = i1 * this.m_a1 + i2 * this.m_a2; - this.m_K.col3.x = this.m_K.col1.z; - this.m_K.col3.y = this.m_K.col2.z; - this.m_K.col3.z = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2; - this.m_K.Solve33(impulse, (-C1X), (-C1Y), (-C2)); - } - else { - m1 = this.m_invMassA; - m2 = this.m_invMassB; - i1 = this.m_invIA; - i2 = this.m_invIB; - var k11 = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; - var k12 = i1 * this.m_s1 + i2 * this.m_s2; - var k22 = i1 + i2; - this.m_K.col1.Set(k11, k12, 0.0); - this.m_K.col2.Set(k12, k22, 0.0); - var impulse1 = this.m_K.Solve22(new b2Vec2(), (-C1X), (-C1Y)); - impulse.x = impulse1.x; - impulse.y = impulse1.y; - impulse.z = 0.0; - } - var PX = impulse.x * this.m_perp.x + impulse.z * this.m_axis.x; - var PY = impulse.x * this.m_perp.y + impulse.z * this.m_axis.y; - var L1 = impulse.x * this.m_s1 + impulse.y + impulse.z * this.m_a1; - var L2 = impulse.x * this.m_s2 + impulse.y + impulse.z * this.m_a2; - c1.x -= this.m_invMassA * PX; - c1.y -= this.m_invMassA * PY; - a1 -= this.m_invIA * L1; - c2.x += this.m_invMassB * PX; - c2.y += this.m_invMassB * PY; - a2 += this.m_invIB * L2; - bA.m_sweep.a = a1; - bB.m_sweep.a = a2; - bA.SynchronizeTransform(); - bB.SynchronizeTransform(); - return linearError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop; - } - Box2D.inherit(b2PrismaticJointDef, Box2D.Dynamics.Joints.b2JointDef); - b2PrismaticJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; - b2PrismaticJointDef.b2PrismaticJointDef = function () { - Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); - this.localAnchorA = new b2Vec2(); - this.localAnchorB = new b2Vec2(); - this.localAxisA = new b2Vec2(); - }; - b2PrismaticJointDef.prototype.b2PrismaticJointDef = function () { - this.__super.b2JointDef.call(this); - this.type = b2Joint.e_prismaticJoint; - this.localAxisA.Set(1.0, 0.0); - this.referenceAngle = 0.0; - this.enableLimit = false; - this.lowerTranslation = 0.0; - this.upperTranslation = 0.0; - this.enableMotor = false; - this.maxMotorForce = 0.0; - this.motorSpeed = 0.0; - } - b2PrismaticJointDef.prototype.Initialize = function (bA, bB, anchor, axis) { - this.bodyA = bA; - this.bodyB = bB; - this.localAnchorA = this.bodyA.GetLocalPoint(anchor); - this.localAnchorB = this.bodyB.GetLocalPoint(anchor); - this.localAxisA = this.bodyA.GetLocalVector(axis); - this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle(); - } - Box2D.inherit(b2PulleyJoint, Box2D.Dynamics.Joints.b2Joint); - b2PulleyJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; - b2PulleyJoint.b2PulleyJoint = function () { - Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); - this.m_groundAnchor1 = new b2Vec2(); - this.m_groundAnchor2 = new b2Vec2(); - this.m_localAnchor1 = new b2Vec2(); - this.m_localAnchor2 = new b2Vec2(); - this.m_u1 = new b2Vec2(); - this.m_u2 = new b2Vec2(); - }; - b2PulleyJoint.prototype.GetAnchorA = function () { - return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); - } - b2PulleyJoint.prototype.GetAnchorB = function () { - return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); - } - b2PulleyJoint.prototype.GetReactionForce = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return new b2Vec2(inv_dt * this.m_impulse * this.m_u2.x, inv_dt * this.m_impulse * this.m_u2.y); - } - b2PulleyJoint.prototype.GetReactionTorque = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return 0.0; - } - b2PulleyJoint.prototype.GetGroundAnchorA = function () { - var a = this.m_ground.m_xf.position.Copy(); - a.Add(this.m_groundAnchor1); - return a; - } - b2PulleyJoint.prototype.GetGroundAnchorB = function () { - var a = this.m_ground.m_xf.position.Copy(); - a.Add(this.m_groundAnchor2); - return a; - } - b2PulleyJoint.prototype.GetLength1 = function () { - var p = this.m_bodyA.GetWorldPoint(this.m_localAnchor1); - var sX = this.m_ground.m_xf.position.x + this.m_groundAnchor1.x; - var sY = this.m_ground.m_xf.position.y + this.m_groundAnchor1.y; - var dX = p.x - sX; - var dY = p.y - sY; - return Math.sqrt(dX * dX + dY * dY); - } - b2PulleyJoint.prototype.GetLength2 = function () { - var p = this.m_bodyB.GetWorldPoint(this.m_localAnchor2); - var sX = this.m_ground.m_xf.position.x + this.m_groundAnchor2.x; - var sY = this.m_ground.m_xf.position.y + this.m_groundAnchor2.y; - var dX = p.x - sX; - var dY = p.y - sY; - return Math.sqrt(dX * dX + dY * dY); - } - b2PulleyJoint.prototype.GetRatio = function () { - return this.m_ratio; - } - b2PulleyJoint.prototype.b2PulleyJoint = function (def) { - this.__super.b2Joint.call(this, def); - var tMat; - var tX = 0; - var tY = 0; - this.m_ground = this.m_bodyA.m_world.m_groundBody; - this.m_groundAnchor1.x = def.groundAnchorA.x - this.m_ground.m_xf.position.x; - this.m_groundAnchor1.y = def.groundAnchorA.y - this.m_ground.m_xf.position.y; - this.m_groundAnchor2.x = def.groundAnchorB.x - this.m_ground.m_xf.position.x; - this.m_groundAnchor2.y = def.groundAnchorB.y - this.m_ground.m_xf.position.y; - this.m_localAnchor1.SetV(def.localAnchorA); - this.m_localAnchor2.SetV(def.localAnchorB); - this.m_ratio = def.ratio; - this.m_constant = def.lengthA + this.m_ratio * def.lengthB; - this.m_maxLength1 = b2Math.Min(def.maxLengthA, this.m_constant - this.m_ratio * b2PulleyJoint.b2_minPulleyLength); - this.m_maxLength2 = b2Math.Min(def.maxLengthB, (this.m_constant - b2PulleyJoint.b2_minPulleyLength) / this.m_ratio); - this.m_impulse = 0.0; - this.m_limitImpulse1 = 0.0; - this.m_limitImpulse2 = 0.0; - } - b2PulleyJoint.prototype.InitVelocityConstraints = function (step) { - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var tMat; - tMat = bA.m_xf.R; - var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; - var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; - var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = bB.m_xf.R; - var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; - var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - var p1X = bA.m_sweep.c.x + r1X; - var p1Y = bA.m_sweep.c.y + r1Y; - var p2X = bB.m_sweep.c.x + r2X; - var p2Y = bB.m_sweep.c.y + r2Y; - var s1X = this.m_ground.m_xf.position.x + this.m_groundAnchor1.x; - var s1Y = this.m_ground.m_xf.position.y + this.m_groundAnchor1.y; - var s2X = this.m_ground.m_xf.position.x + this.m_groundAnchor2.x; - var s2Y = this.m_ground.m_xf.position.y + this.m_groundAnchor2.y; - this.m_u1.Set(p1X - s1X, p1Y - s1Y); - this.m_u2.Set(p2X - s2X, p2Y - s2Y); - var length1 = this.m_u1.Length(); - var length2 = this.m_u2.Length(); - if (length1 > b2Settings.b2_linearSlop) { - this.m_u1.Multiply(1.0 / length1); - } - else { - this.m_u1.SetZero(); - } - if (length2 > b2Settings.b2_linearSlop) { - this.m_u2.Multiply(1.0 / length2); - } - else { - this.m_u2.SetZero(); - } - var C = this.m_constant - length1 - this.m_ratio * length2; - if (C > 0.0) { - this.m_state = b2Joint.e_inactiveLimit; - this.m_impulse = 0.0; - } - else { - this.m_state = b2Joint.e_atUpperLimit; - } - if (length1 < this.m_maxLength1) { - this.m_limitState1 = b2Joint.e_inactiveLimit; - this.m_limitImpulse1 = 0.0; - } - else { - this.m_limitState1 = b2Joint.e_atUpperLimit; - } - if (length2 < this.m_maxLength2) { - this.m_limitState2 = b2Joint.e_inactiveLimit; - this.m_limitImpulse2 = 0.0; - } - else { - this.m_limitState2 = b2Joint.e_atUpperLimit; - } - var cr1u1 = r1X * this.m_u1.y - r1Y * this.m_u1.x; - var cr2u2 = r2X * this.m_u2.y - r2Y * this.m_u2.x; - this.m_limitMass1 = bA.m_invMass + bA.m_invI * cr1u1 * cr1u1; - this.m_limitMass2 = bB.m_invMass + bB.m_invI * cr2u2 * cr2u2; - this.m_pulleyMass = this.m_limitMass1 + this.m_ratio * this.m_ratio * this.m_limitMass2; - this.m_limitMass1 = 1.0 / this.m_limitMass1; - this.m_limitMass2 = 1.0 / this.m_limitMass2; - this.m_pulleyMass = 1.0 / this.m_pulleyMass; - if (step.warmStarting) { - this.m_impulse *= step.dtRatio; - this.m_limitImpulse1 *= step.dtRatio; - this.m_limitImpulse2 *= step.dtRatio; - var P1X = ((-this.m_impulse) - this.m_limitImpulse1) * this.m_u1.x; - var P1Y = ((-this.m_impulse) - this.m_limitImpulse1) * this.m_u1.y; - var P2X = ((-this.m_ratio * this.m_impulse) - this.m_limitImpulse2) * this.m_u2.x; - var P2Y = ((-this.m_ratio * this.m_impulse) - this.m_limitImpulse2) * this.m_u2.y; - bA.m_linearVelocity.x += bA.m_invMass * P1X; - bA.m_linearVelocity.y += bA.m_invMass * P1Y; - bA.m_angularVelocity += bA.m_invI * (r1X * P1Y - r1Y * P1X); - bB.m_linearVelocity.x += bB.m_invMass * P2X; - bB.m_linearVelocity.y += bB.m_invMass * P2Y; - bB.m_angularVelocity += bB.m_invI * (r2X * P2Y - r2Y * P2X); - } - else { - this.m_impulse = 0.0; - this.m_limitImpulse1 = 0.0; - this.m_limitImpulse2 = 0.0; - } - } - b2PulleyJoint.prototype.SolveVelocityConstraints = function (step) { - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var tMat; - tMat = bA.m_xf.R; - var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; - var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; - var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = bB.m_xf.R; - var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; - var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - var v1X = 0; - var v1Y = 0; - var v2X = 0; - var v2Y = 0; - var P1X = 0; - var P1Y = 0; - var P2X = 0; - var P2Y = 0; - var Cdot = 0; - var impulse = 0; - var oldImpulse = 0; - if (this.m_state == b2Joint.e_atUpperLimit) { - v1X = bA.m_linearVelocity.x + ((-bA.m_angularVelocity * r1Y)); - v1Y = bA.m_linearVelocity.y + (bA.m_angularVelocity * r1X); - v2X = bB.m_linearVelocity.x + ((-bB.m_angularVelocity * r2Y)); - v2Y = bB.m_linearVelocity.y + (bB.m_angularVelocity * r2X); - Cdot = (-(this.m_u1.x * v1X + this.m_u1.y * v1Y)) - this.m_ratio * (this.m_u2.x * v2X + this.m_u2.y * v2Y); - impulse = this.m_pulleyMass * ((-Cdot)); - oldImpulse = this.m_impulse; - this.m_impulse = b2Math.Max(0.0, this.m_impulse + impulse); - impulse = this.m_impulse - oldImpulse; - P1X = (-impulse * this.m_u1.x); - P1Y = (-impulse * this.m_u1.y); - P2X = (-this.m_ratio * impulse * this.m_u2.x); - P2Y = (-this.m_ratio * impulse * this.m_u2.y); - bA.m_linearVelocity.x += bA.m_invMass * P1X; - bA.m_linearVelocity.y += bA.m_invMass * P1Y; - bA.m_angularVelocity += bA.m_invI * (r1X * P1Y - r1Y * P1X); - bB.m_linearVelocity.x += bB.m_invMass * P2X; - bB.m_linearVelocity.y += bB.m_invMass * P2Y; - bB.m_angularVelocity += bB.m_invI * (r2X * P2Y - r2Y * P2X); - } - if (this.m_limitState1 == b2Joint.e_atUpperLimit) { - v1X = bA.m_linearVelocity.x + ((-bA.m_angularVelocity * r1Y)); - v1Y = bA.m_linearVelocity.y + (bA.m_angularVelocity * r1X); - Cdot = (-(this.m_u1.x * v1X + this.m_u1.y * v1Y)); - impulse = (-this.m_limitMass1 * Cdot); - oldImpulse = this.m_limitImpulse1; - this.m_limitImpulse1 = b2Math.Max(0.0, this.m_limitImpulse1 + impulse); - impulse = this.m_limitImpulse1 - oldImpulse; - P1X = (-impulse * this.m_u1.x); - P1Y = (-impulse * this.m_u1.y); - bA.m_linearVelocity.x += bA.m_invMass * P1X; - bA.m_linearVelocity.y += bA.m_invMass * P1Y; - bA.m_angularVelocity += bA.m_invI * (r1X * P1Y - r1Y * P1X); - } - if (this.m_limitState2 == b2Joint.e_atUpperLimit) { - v2X = bB.m_linearVelocity.x + ((-bB.m_angularVelocity * r2Y)); - v2Y = bB.m_linearVelocity.y + (bB.m_angularVelocity * r2X); - Cdot = (-(this.m_u2.x * v2X + this.m_u2.y * v2Y)); - impulse = (-this.m_limitMass2 * Cdot); - oldImpulse = this.m_limitImpulse2; - this.m_limitImpulse2 = b2Math.Max(0.0, this.m_limitImpulse2 + impulse); - impulse = this.m_limitImpulse2 - oldImpulse; - P2X = (-impulse * this.m_u2.x); - P2Y = (-impulse * this.m_u2.y); - bB.m_linearVelocity.x += bB.m_invMass * P2X; - bB.m_linearVelocity.y += bB.m_invMass * P2Y; - bB.m_angularVelocity += bB.m_invI * (r2X * P2Y - r2Y * P2X); - } - } - b2PulleyJoint.prototype.SolvePositionConstraints = function (baumgarte) { - if (baumgarte === undefined) baumgarte = 0; - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var tMat; - var s1X = this.m_ground.m_xf.position.x + this.m_groundAnchor1.x; - var s1Y = this.m_ground.m_xf.position.y + this.m_groundAnchor1.y; - var s2X = this.m_ground.m_xf.position.x + this.m_groundAnchor2.x; - var s2Y = this.m_ground.m_xf.position.y + this.m_groundAnchor2.y; - var r1X = 0; - var r1Y = 0; - var r2X = 0; - var r2Y = 0; - var p1X = 0; - var p1Y = 0; - var p2X = 0; - var p2Y = 0; - var length1 = 0; - var length2 = 0; - var C = 0; - var impulse = 0; - var oldImpulse = 0; - var oldLimitPositionImpulse = 0; - var tX = 0; - var linearError = 0.0; - if (this.m_state == b2Joint.e_atUpperLimit) { - tMat = bA.m_xf.R; - r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; - r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; - tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = bB.m_xf.R; - r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; - r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - p1X = bA.m_sweep.c.x + r1X; - p1Y = bA.m_sweep.c.y + r1Y; - p2X = bB.m_sweep.c.x + r2X; - p2Y = bB.m_sweep.c.y + r2Y; - this.m_u1.Set(p1X - s1X, p1Y - s1Y); - this.m_u2.Set(p2X - s2X, p2Y - s2Y); - length1 = this.m_u1.Length(); - length2 = this.m_u2.Length(); - if (length1 > b2Settings.b2_linearSlop) { - this.m_u1.Multiply(1.0 / length1); - } - else { - this.m_u1.SetZero(); - } - if (length2 > b2Settings.b2_linearSlop) { - this.m_u2.Multiply(1.0 / length2); - } - else { - this.m_u2.SetZero(); - } - C = this.m_constant - length1 - this.m_ratio * length2; - linearError = b2Math.Max(linearError, (-C)); - C = b2Math.Clamp(C + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0); - impulse = (-this.m_pulleyMass * C); - p1X = (-impulse * this.m_u1.x); - p1Y = (-impulse * this.m_u1.y); - p2X = (-this.m_ratio * impulse * this.m_u2.x); - p2Y = (-this.m_ratio * impulse * this.m_u2.y); - bA.m_sweep.c.x += bA.m_invMass * p1X; - bA.m_sweep.c.y += bA.m_invMass * p1Y; - bA.m_sweep.a += bA.m_invI * (r1X * p1Y - r1Y * p1X); - bB.m_sweep.c.x += bB.m_invMass * p2X; - bB.m_sweep.c.y += bB.m_invMass * p2Y; - bB.m_sweep.a += bB.m_invI * (r2X * p2Y - r2Y * p2X); - bA.SynchronizeTransform(); - bB.SynchronizeTransform(); - } - if (this.m_limitState1 == b2Joint.e_atUpperLimit) { - tMat = bA.m_xf.R; - r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; - r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; - tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - p1X = bA.m_sweep.c.x + r1X; - p1Y = bA.m_sweep.c.y + r1Y; - this.m_u1.Set(p1X - s1X, p1Y - s1Y); - length1 = this.m_u1.Length(); - if (length1 > b2Settings.b2_linearSlop) { - this.m_u1.x *= 1.0 / length1; - this.m_u1.y *= 1.0 / length1; - } - else { - this.m_u1.SetZero(); - } - C = this.m_maxLength1 - length1; - linearError = b2Math.Max(linearError, (-C)); - C = b2Math.Clamp(C + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0); - impulse = (-this.m_limitMass1 * C); - p1X = (-impulse * this.m_u1.x); - p1Y = (-impulse * this.m_u1.y); - bA.m_sweep.c.x += bA.m_invMass * p1X; - bA.m_sweep.c.y += bA.m_invMass * p1Y; - bA.m_sweep.a += bA.m_invI * (r1X * p1Y - r1Y * p1X); - bA.SynchronizeTransform(); - } - if (this.m_limitState2 == b2Joint.e_atUpperLimit) { - tMat = bB.m_xf.R; - r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; - r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - p2X = bB.m_sweep.c.x + r2X; - p2Y = bB.m_sweep.c.y + r2Y; - this.m_u2.Set(p2X - s2X, p2Y - s2Y); - length2 = this.m_u2.Length(); - if (length2 > b2Settings.b2_linearSlop) { - this.m_u2.x *= 1.0 / length2; - this.m_u2.y *= 1.0 / length2; - } - else { - this.m_u2.SetZero(); - } - C = this.m_maxLength2 - length2; - linearError = b2Math.Max(linearError, (-C)); - C = b2Math.Clamp(C + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0); - impulse = (-this.m_limitMass2 * C); - p2X = (-impulse * this.m_u2.x); - p2Y = (-impulse * this.m_u2.y); - bB.m_sweep.c.x += bB.m_invMass * p2X; - bB.m_sweep.c.y += bB.m_invMass * p2Y; - bB.m_sweep.a += bB.m_invI * (r2X * p2Y - r2Y * p2X); - bB.SynchronizeTransform(); - } - return linearError < b2Settings.b2_linearSlop; - } - Box2D.postDefs.push(function () { - Box2D.Dynamics.Joints.b2PulleyJoint.b2_minPulleyLength = 2.0; - }); - Box2D.inherit(b2PulleyJointDef, Box2D.Dynamics.Joints.b2JointDef); - b2PulleyJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; - b2PulleyJointDef.b2PulleyJointDef = function () { - Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); - this.groundAnchorA = new b2Vec2(); - this.groundAnchorB = new b2Vec2(); - this.localAnchorA = new b2Vec2(); - this.localAnchorB = new b2Vec2(); - }; - b2PulleyJointDef.prototype.b2PulleyJointDef = function () { - this.__super.b2JointDef.call(this); - this.type = b2Joint.e_pulleyJoint; - this.groundAnchorA.Set((-1.0), 1.0); - this.groundAnchorB.Set(1.0, 1.0); - this.localAnchorA.Set((-1.0), 0.0); - this.localAnchorB.Set(1.0, 0.0); - this.lengthA = 0.0; - this.maxLengthA = 0.0; - this.lengthB = 0.0; - this.maxLengthB = 0.0; - this.ratio = 1.0; - this.collideConnected = true; - } - b2PulleyJointDef.prototype.Initialize = function (bA, bB, gaA, gaB, anchorA, anchorB, r) { - if (r === undefined) r = 0; - this.bodyA = bA; - this.bodyB = bB; - this.groundAnchorA.SetV(gaA); - this.groundAnchorB.SetV(gaB); - this.localAnchorA = this.bodyA.GetLocalPoint(anchorA); - this.localAnchorB = this.bodyB.GetLocalPoint(anchorB); - var d1X = anchorA.x - gaA.x; - var d1Y = anchorA.y - gaA.y; - this.lengthA = Math.sqrt(d1X * d1X + d1Y * d1Y); - var d2X = anchorB.x - gaB.x; - var d2Y = anchorB.y - gaB.y; - this.lengthB = Math.sqrt(d2X * d2X + d2Y * d2Y); - this.ratio = r; - var C = this.lengthA + this.ratio * this.lengthB; - this.maxLengthA = C - this.ratio * b2PulleyJoint.b2_minPulleyLength; - this.maxLengthB = (C - b2PulleyJoint.b2_minPulleyLength) / this.ratio; - } - Box2D.inherit(b2RevoluteJoint, Box2D.Dynamics.Joints.b2Joint); - b2RevoluteJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; - b2RevoluteJoint.b2RevoluteJoint = function () { - Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); - this.K = new b2Mat22(); - this.K1 = new b2Mat22(); - this.K2 = new b2Mat22(); - this.K3 = new b2Mat22(); - this.impulse3 = new b2Vec3(); - this.impulse2 = new b2Vec2(); - this.reduced = new b2Vec2(); - this.m_localAnchor1 = new b2Vec2(); - this.m_localAnchor2 = new b2Vec2(); - this.m_impulse = new b2Vec3(); - this.m_mass = new b2Mat33(); - }; - b2RevoluteJoint.prototype.GetAnchorA = function () { - return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); - } - b2RevoluteJoint.prototype.GetAnchorB = function () { - return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); - } - b2RevoluteJoint.prototype.GetReactionForce = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return new b2Vec2(inv_dt * this.m_impulse.x, inv_dt * this.m_impulse.y); - } - b2RevoluteJoint.prototype.GetReactionTorque = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return inv_dt * this.m_impulse.z; - } - b2RevoluteJoint.prototype.GetJointAngle = function () { - return this.m_bodyB.m_sweep.a - this.m_bodyA.m_sweep.a - this.m_referenceAngle; - } - b2RevoluteJoint.prototype.GetJointSpeed = function () { - return this.m_bodyB.m_angularVelocity - this.m_bodyA.m_angularVelocity; - } - b2RevoluteJoint.prototype.IsLimitEnabled = function () { - return this.m_enableLimit; - } - b2RevoluteJoint.prototype.EnableLimit = function (flag) { - this.m_enableLimit = flag; - } - b2RevoluteJoint.prototype.GetLowerLimit = function () { - return this.m_lowerAngle; - } - b2RevoluteJoint.prototype.GetUpperLimit = function () { - return this.m_upperAngle; - } - b2RevoluteJoint.prototype.SetLimits = function (lower, upper) { - - if (lower === undefined) lower = 0; - if (upper === undefined) upper = 0; - this.m_lowerAngle = lower; - this.m_upperAngle = upper; - } - b2RevoluteJoint.prototype.IsMotorEnabled = function () { - this.m_bodyA.SetAwake(true); - this.m_bodyB.SetAwake(true); - return this.m_enableMotor; - } - b2RevoluteJoint.prototype.EnableMotor = function (flag) { - this.m_enableMotor = flag; - } - b2RevoluteJoint.prototype.SetMotorSpeed = function (speed) { - if (speed === undefined) speed = 0; - this.m_bodyA.SetAwake(true); - this.m_bodyB.SetAwake(true); - this.m_motorSpeed = speed; - } - b2RevoluteJoint.prototype.GetMotorSpeed = function () { - return this.m_motorSpeed; - } - b2RevoluteJoint.prototype.SetMaxMotorTorque = function (torque) { - if (torque === undefined) torque = 0; - this.m_maxMotorTorque = torque; - } - b2RevoluteJoint.prototype.GetMotorTorque = function () { - return this.m_maxMotorTorque; - } - b2RevoluteJoint.prototype.b2RevoluteJoint = function (def) { - this.__super.b2Joint.call(this, def); - this.m_localAnchor1.SetV(def.localAnchorA); - this.m_localAnchor2.SetV(def.localAnchorB); - this.m_referenceAngle = def.referenceAngle; - this.m_impulse.SetZero(); - this.m_motorImpulse = 0.0; - this.m_lowerAngle = def.lowerAngle; - this.m_upperAngle = def.upperAngle; - this.m_maxMotorTorque = def.maxMotorTorque; - this.m_motorSpeed = def.motorSpeed; - this.m_enableLimit = def.enableLimit; - this.m_enableMotor = def.enableMotor; - this.m_limitState = b2Joint.e_inactiveLimit; - } - b2RevoluteJoint.prototype.InitVelocityConstraints = function (step) { - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var tMat; - var tX = 0; - if (this.m_enableMotor || this.m_enableLimit) {} - tMat = bA.m_xf.R; - var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; - var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; - tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = bB.m_xf.R; - var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; - var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - var m1 = bA.m_invMass; - var m2 = bB.m_invMass; - var i1 = bA.m_invI; - var i2 = bB.m_invI; - this.m_mass.col1.x = m1 + m2 + r1Y * r1Y * i1 + r2Y * r2Y * i2; - this.m_mass.col2.x = (-r1Y * r1X * i1) - r2Y * r2X * i2; - this.m_mass.col3.x = (-r1Y * i1) - r2Y * i2; - this.m_mass.col1.y = this.m_mass.col2.x; - this.m_mass.col2.y = m1 + m2 + r1X * r1X * i1 + r2X * r2X * i2; - this.m_mass.col3.y = r1X * i1 + r2X * i2; - this.m_mass.col1.z = this.m_mass.col3.x; - this.m_mass.col2.z = this.m_mass.col3.y; - this.m_mass.col3.z = i1 + i2; - this.m_motorMass = 1.0 / (i1 + i2); - if (this.m_enableMotor == false) { - this.m_motorImpulse = 0.0; - } - if (this.m_enableLimit) { - var jointAngle = bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle; - if (b2Math.Abs(this.m_upperAngle - this.m_lowerAngle) < 2.0 * b2Settings.b2_angularSlop) { - this.m_limitState = b2Joint.e_equalLimits; - } - else if (jointAngle <= this.m_lowerAngle) { - if (this.m_limitState != b2Joint.e_atLowerLimit) { - this.m_impulse.z = 0.0; - } - this.m_limitState = b2Joint.e_atLowerLimit; - } - else if (jointAngle >= this.m_upperAngle) { - if (this.m_limitState != b2Joint.e_atUpperLimit) { - this.m_impulse.z = 0.0; - } - this.m_limitState = b2Joint.e_atUpperLimit; - } - else { - this.m_limitState = b2Joint.e_inactiveLimit; - this.m_impulse.z = 0.0; - } - } - else { - this.m_limitState = b2Joint.e_inactiveLimit; - } - if (step.warmStarting) { - this.m_impulse.x *= step.dtRatio; - this.m_impulse.y *= step.dtRatio; - this.m_motorImpulse *= step.dtRatio; - var PX = this.m_impulse.x; - var PY = this.m_impulse.y; - bA.m_linearVelocity.x -= m1 * PX; - bA.m_linearVelocity.y -= m1 * PY; - bA.m_angularVelocity -= i1 * ((r1X * PY - r1Y * PX) + this.m_motorImpulse + this.m_impulse.z); - bB.m_linearVelocity.x += m2 * PX; - bB.m_linearVelocity.y += m2 * PY; - bB.m_angularVelocity += i2 * ((r2X * PY - r2Y * PX) + this.m_motorImpulse + this.m_impulse.z); - } - else { - this.m_impulse.SetZero(); - this.m_motorImpulse = 0.0; - } - } - b2RevoluteJoint.prototype.SolveVelocityConstraints = function (step) { - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var tMat; - var tX = 0; - var newImpulse = 0; - var r1X = 0; - var r1Y = 0; - var r2X = 0; - var r2Y = 0; - var v1 = bA.m_linearVelocity; - var w1 = bA.m_angularVelocity; - var v2 = bB.m_linearVelocity; - var w2 = bB.m_angularVelocity; - var m1 = bA.m_invMass; - var m2 = bB.m_invMass; - var i1 = bA.m_invI; - var i2 = bB.m_invI; - if (this.m_enableMotor && this.m_limitState != b2Joint.e_equalLimits) { - var Cdot = w2 - w1 - this.m_motorSpeed; - var impulse = this.m_motorMass * ((-Cdot)); - var oldImpulse = this.m_motorImpulse; - var maxImpulse = step.dt * this.m_maxMotorTorque; - this.m_motorImpulse = b2Math.Clamp(this.m_motorImpulse + impulse, (-maxImpulse), maxImpulse); - impulse = this.m_motorImpulse - oldImpulse; - w1 -= i1 * impulse; - w2 += i2 * impulse; - } - if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) { - tMat = bA.m_xf.R; - r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; - r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; - tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = bB.m_xf.R; - r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; - r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - var Cdot1X = v2.x + ((-w2 * r2Y)) - v1.x - ((-w1 * r1Y)); - var Cdot1Y = v2.y + (w2 * r2X) - v1.y - (w1 * r1X); - var Cdot2 = w2 - w1; - this.m_mass.Solve33(this.impulse3, (-Cdot1X), (-Cdot1Y), (-Cdot2)); - if (this.m_limitState == b2Joint.e_equalLimits) { - this.m_impulse.Add(this.impulse3); - } - else if (this.m_limitState == b2Joint.e_atLowerLimit) { - newImpulse = this.m_impulse.z + this.impulse3.z; - if (newImpulse < 0.0) { - this.m_mass.Solve22(this.reduced, (-Cdot1X), (-Cdot1Y)); - this.impulse3.x = this.reduced.x; - this.impulse3.y = this.reduced.y; - this.impulse3.z = (-this.m_impulse.z); - this.m_impulse.x += this.reduced.x; - this.m_impulse.y += this.reduced.y; - this.m_impulse.z = 0.0; - } - } - else if (this.m_limitState == b2Joint.e_atUpperLimit) { - newImpulse = this.m_impulse.z + this.impulse3.z; - if (newImpulse > 0.0) { - this.m_mass.Solve22(this.reduced, (-Cdot1X), (-Cdot1Y)); - this.impulse3.x = this.reduced.x; - this.impulse3.y = this.reduced.y; - this.impulse3.z = (-this.m_impulse.z); - this.m_impulse.x += this.reduced.x; - this.m_impulse.y += this.reduced.y; - this.m_impulse.z = 0.0; - } - } - v1.x -= m1 * this.impulse3.x; - v1.y -= m1 * this.impulse3.y; - w1 -= i1 * (r1X * this.impulse3.y - r1Y * this.impulse3.x + this.impulse3.z); - v2.x += m2 * this.impulse3.x; - v2.y += m2 * this.impulse3.y; - w2 += i2 * (r2X * this.impulse3.y - r2Y * this.impulse3.x + this.impulse3.z); - } - else { - tMat = bA.m_xf.R; - r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; - r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; - tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = bB.m_xf.R; - r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; - r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - var CdotX = v2.x + ((-w2 * r2Y)) - v1.x - ((-w1 * r1Y)); - var CdotY = v2.y + (w2 * r2X) - v1.y - (w1 * r1X); - this.m_mass.Solve22(this.impulse2, (-CdotX), (-CdotY)); - this.m_impulse.x += this.impulse2.x; - this.m_impulse.y += this.impulse2.y; - v1.x -= m1 * this.impulse2.x; - v1.y -= m1 * this.impulse2.y; - w1 -= i1 * (r1X * this.impulse2.y - r1Y * this.impulse2.x); - v2.x += m2 * this.impulse2.x; - v2.y += m2 * this.impulse2.y; - w2 += i2 * (r2X * this.impulse2.y - r2Y * this.impulse2.x); - } - bA.m_linearVelocity.SetV(v1); - bA.m_angularVelocity = w1; - bB.m_linearVelocity.SetV(v2); - bB.m_angularVelocity = w2; - } - b2RevoluteJoint.prototype.SolvePositionConstraints = function (baumgarte) { - if (baumgarte === undefined) baumgarte = 0; - var oldLimitImpulse = 0; - var C = 0; - var tMat; - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var angularError = 0.0; - var positionError = 0.0; - var tX = 0; - var impulseX = 0; - var impulseY = 0; - if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) { - var angle = bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle; - var limitImpulse = 0.0; - if (this.m_limitState == b2Joint.e_equalLimits) { - C = b2Math.Clamp(angle - this.m_lowerAngle, (-b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection); - limitImpulse = (-this.m_motorMass * C); - angularError = b2Math.Abs(C); - } - else if (this.m_limitState == b2Joint.e_atLowerLimit) { - C = angle - this.m_lowerAngle; - angularError = (-C); - C = b2Math.Clamp(C + b2Settings.b2_angularSlop, (-b2Settings.b2_maxAngularCorrection), 0.0); - limitImpulse = (-this.m_motorMass * C); - } - else if (this.m_limitState == b2Joint.e_atUpperLimit) { - C = angle - this.m_upperAngle; - angularError = C; - C = b2Math.Clamp(C - b2Settings.b2_angularSlop, 0.0, b2Settings.b2_maxAngularCorrection); - limitImpulse = (-this.m_motorMass * C); - } - bA.m_sweep.a -= bA.m_invI * limitImpulse; - bB.m_sweep.a += bB.m_invI * limitImpulse; - bA.SynchronizeTransform(); - bB.SynchronizeTransform(); - } { - tMat = bA.m_xf.R; - var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; - var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; - tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); - r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); - r1X = tX; - tMat = bB.m_xf.R; - var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; - var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); - r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); - r2X = tX; - var CX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; - var CY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; - var CLengthSquared = CX * CX + CY * CY; - var CLength = Math.sqrt(CLengthSquared); - positionError = CLength; - var invMass1 = bA.m_invMass; - var invMass2 = bB.m_invMass; - var invI1 = bA.m_invI; - var invI2 = bB.m_invI; - var k_allowedStretch = 10.0 * b2Settings.b2_linearSlop; - if (CLengthSquared > k_allowedStretch * k_allowedStretch) { - var uX = CX / CLength; - var uY = CY / CLength; - var k = invMass1 + invMass2; - var m = 1.0 / k; - impulseX = m * ((-CX)); - impulseY = m * ((-CY)); - var k_beta = 0.5; - bA.m_sweep.c.x -= k_beta * invMass1 * impulseX; - bA.m_sweep.c.y -= k_beta * invMass1 * impulseY; - bB.m_sweep.c.x += k_beta * invMass2 * impulseX; - bB.m_sweep.c.y += k_beta * invMass2 * impulseY; - CX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; - CY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; - } - this.K1.col1.x = invMass1 + invMass2; - this.K1.col2.x = 0.0; - this.K1.col1.y = 0.0; - this.K1.col2.y = invMass1 + invMass2; - this.K2.col1.x = invI1 * r1Y * r1Y; - this.K2.col2.x = (-invI1 * r1X * r1Y); - this.K2.col1.y = (-invI1 * r1X * r1Y); - this.K2.col2.y = invI1 * r1X * r1X; - this.K3.col1.x = invI2 * r2Y * r2Y; - this.K3.col2.x = (-invI2 * r2X * r2Y); - this.K3.col1.y = (-invI2 * r2X * r2Y); - this.K3.col2.y = invI2 * r2X * r2X; - this.K.SetM(this.K1); - this.K.AddM(this.K2); - this.K.AddM(this.K3); - this.K.Solve(b2RevoluteJoint.tImpulse, (-CX), (-CY)); - impulseX = b2RevoluteJoint.tImpulse.x; - impulseY = b2RevoluteJoint.tImpulse.y; - bA.m_sweep.c.x -= bA.m_invMass * impulseX; - bA.m_sweep.c.y -= bA.m_invMass * impulseY; - bA.m_sweep.a -= bA.m_invI * (r1X * impulseY - r1Y * impulseX); - bB.m_sweep.c.x += bB.m_invMass * impulseX; - bB.m_sweep.c.y += bB.m_invMass * impulseY; - bB.m_sweep.a += bB.m_invI * (r2X * impulseY - r2Y * impulseX); - bA.SynchronizeTransform(); - bB.SynchronizeTransform(); - } - return positionError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop; - } - Box2D.postDefs.push(function () { - Box2D.Dynamics.Joints.b2RevoluteJoint.tImpulse = new b2Vec2(); - }); - Box2D.inherit(b2RevoluteJointDef, Box2D.Dynamics.Joints.b2JointDef); - b2RevoluteJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; - b2RevoluteJointDef.b2RevoluteJointDef = function () { - Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); - this.localAnchorA = new b2Vec2(); - this.localAnchorB = new b2Vec2(); - }; - b2RevoluteJointDef.prototype.b2RevoluteJointDef = function () { - this.__super.b2JointDef.call(this); - this.type = b2Joint.e_revoluteJoint; - this.localAnchorA.Set(0.0, 0.0); - this.localAnchorB.Set(0.0, 0.0); - this.referenceAngle = 0.0; - this.lowerAngle = 0.0; - this.upperAngle = 0.0; - this.maxMotorTorque = 0.0; - this.motorSpeed = 0.0; - this.enableLimit = false; - this.enableMotor = false; - } - b2RevoluteJointDef.prototype.Initialize = function (bA, bB, anchor) { - this.bodyA = bA; - this.bodyB = bB; - this.localAnchorA = this.bodyA.GetLocalPoint(anchor); - this.localAnchorB = this.bodyB.GetLocalPoint(anchor); - this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle(); - } - Box2D.inherit(b2WeldJoint, Box2D.Dynamics.Joints.b2Joint); - b2WeldJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; - b2WeldJoint.b2WeldJoint = function () { - Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); - this.m_localAnchorA = new b2Vec2(); - this.m_localAnchorB = new b2Vec2(); - this.m_impulse = new b2Vec3(); - this.m_mass = new b2Mat33(); - }; - b2WeldJoint.prototype.GetAnchorA = function () { - return this.m_bodyA.GetWorldPoint(this.m_localAnchorA); - } - b2WeldJoint.prototype.GetAnchorB = function () { - return this.m_bodyB.GetWorldPoint(this.m_localAnchorB); - } - b2WeldJoint.prototype.GetReactionForce = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return new b2Vec2(inv_dt * this.m_impulse.x, inv_dt * this.m_impulse.y); - } - b2WeldJoint.prototype.GetReactionTorque = function (inv_dt) { - if (inv_dt === undefined) inv_dt = 0; - return inv_dt * this.m_impulse.z; - } - b2WeldJoint.prototype.b2WeldJoint = function (def) { - this.__super.b2Joint.call(this, def); - this.m_localAnchorA.SetV(def.localAnchorA); - this.m_localAnchorB.SetV(def.localAnchorB); - this.m_referenceAngle = def.referenceAngle; - this.m_impulse.SetZero(); - this.m_mass = new b2Mat33(); - } - b2WeldJoint.prototype.InitVelocityConstraints = function (step) { - var tMat; - var tX = 0; - var bA = this.m_bodyA; - var bB = this.m_bodyB; - tMat = bA.m_xf.R; - var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x; - var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y; - tX = (tMat.col1.x * rAX + tMat.col2.x * rAY); - rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY); - rAX = tX; - tMat = bB.m_xf.R; - var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x; - var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * rBX + tMat.col2.x * rBY); - rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY); - rBX = tX; - var mA = bA.m_invMass; - var mB = bB.m_invMass; - var iA = bA.m_invI; - var iB = bB.m_invI; - this.m_mass.col1.x = mA + mB + rAY * rAY * iA + rBY * rBY * iB; - this.m_mass.col2.x = (-rAY * rAX * iA) - rBY * rBX * iB; - this.m_mass.col3.x = (-rAY * iA) - rBY * iB; - this.m_mass.col1.y = this.m_mass.col2.x; - this.m_mass.col2.y = mA + mB + rAX * rAX * iA + rBX * rBX * iB; - this.m_mass.col3.y = rAX * iA + rBX * iB; - this.m_mass.col1.z = this.m_mass.col3.x; - this.m_mass.col2.z = this.m_mass.col3.y; - this.m_mass.col3.z = iA + iB; - if (step.warmStarting) { - this.m_impulse.x *= step.dtRatio; - this.m_impulse.y *= step.dtRatio; - this.m_impulse.z *= step.dtRatio; - bA.m_linearVelocity.x -= mA * this.m_impulse.x; - bA.m_linearVelocity.y -= mA * this.m_impulse.y; - bA.m_angularVelocity -= iA * (rAX * this.m_impulse.y - rAY * this.m_impulse.x + this.m_impulse.z); - bB.m_linearVelocity.x += mB * this.m_impulse.x; - bB.m_linearVelocity.y += mB * this.m_impulse.y; - bB.m_angularVelocity += iB * (rBX * this.m_impulse.y - rBY * this.m_impulse.x + this.m_impulse.z); - } - else { - this.m_impulse.SetZero(); - } - } - b2WeldJoint.prototype.SolveVelocityConstraints = function (step) { - var tMat; - var tX = 0; - var bA = this.m_bodyA; - var bB = this.m_bodyB; - var vA = bA.m_linearVelocity; - var wA = bA.m_angularVelocity; - var vB = bB.m_linearVelocity; - var wB = bB.m_angularVelocity; - var mA = bA.m_invMass; - var mB = bB.m_invMass; - var iA = bA.m_invI; - var iB = bB.m_invI; - tMat = bA.m_xf.R; - var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x; - var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y; - tX = (tMat.col1.x * rAX + tMat.col2.x * rAY); - rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY); - rAX = tX; - tMat = bB.m_xf.R; - var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x; - var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * rBX + tMat.col2.x * rBY); - rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY); - rBX = tX; - var Cdot1X = vB.x - wB * rBY - vA.x + wA * rAY; - var Cdot1Y = vB.y + wB * rBX - vA.y - wA * rAX; - var Cdot2 = wB - wA; - var impulse = new b2Vec3(); - this.m_mass.Solve33(impulse, (-Cdot1X), (-Cdot1Y), (-Cdot2)); - this.m_impulse.Add(impulse); - vA.x -= mA * impulse.x; - vA.y -= mA * impulse.y; - wA -= iA * (rAX * impulse.y - rAY * impulse.x + impulse.z); - vB.x += mB * impulse.x; - vB.y += mB * impulse.y; - wB += iB * (rBX * impulse.y - rBY * impulse.x + impulse.z); - bA.m_angularVelocity = wA; - bB.m_angularVelocity = wB; - } - b2WeldJoint.prototype.SolvePositionConstraints = function (baumgarte) { - if (baumgarte === undefined) baumgarte = 0; - var tMat; - var tX = 0; - var bA = this.m_bodyA; - var bB = this.m_bodyB; - tMat = bA.m_xf.R; - var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x; - var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y; - tX = (tMat.col1.x * rAX + tMat.col2.x * rAY); - rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY); - rAX = tX; - tMat = bB.m_xf.R; - var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x; - var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y; - tX = (tMat.col1.x * rBX + tMat.col2.x * rBY); - rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY); - rBX = tX; - var mA = bA.m_invMass; - var mB = bB.m_invMass; - var iA = bA.m_invI; - var iB = bB.m_invI; - var C1X = bB.m_sweep.c.x + rBX - bA.m_sweep.c.x - rAX; - var C1Y = bB.m_sweep.c.y + rBY - bA.m_sweep.c.y - rAY; - var C2 = bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle; - var k_allowedStretch = 10.0 * b2Settings.b2_linearSlop; - var positionError = Math.sqrt(C1X * C1X + C1Y * C1Y); - var angularError = b2Math.Abs(C2); - if (positionError > k_allowedStretch) { - iA *= 1.0; - iB *= 1.0; - } - this.m_mass.col1.x = mA + mB + rAY * rAY * iA + rBY * rBY * iB; - this.m_mass.col2.x = (-rAY * rAX * iA) - rBY * rBX * iB; - this.m_mass.col3.x = (-rAY * iA) - rBY * iB; - this.m_mass.col1.y = this.m_mass.col2.x; - this.m_mass.col2.y = mA + mB + rAX * rAX * iA + rBX * rBX * iB; - this.m_mass.col3.y = rAX * iA + rBX * iB; - this.m_mass.col1.z = this.m_mass.col3.x; - this.m_mass.col2.z = this.m_mass.col3.y; - this.m_mass.col3.z = iA + iB; - var impulse = new b2Vec3(); - this.m_mass.Solve33(impulse, (-C1X), (-C1Y), (-C2)); - bA.m_sweep.c.x -= mA * impulse.x; - bA.m_sweep.c.y -= mA * impulse.y; - bA.m_sweep.a -= iA * (rAX * impulse.y - rAY * impulse.x + impulse.z); - bB.m_sweep.c.x += mB * impulse.x; - bB.m_sweep.c.y += mB * impulse.y; - bB.m_sweep.a += iB * (rBX * impulse.y - rBY * impulse.x + impulse.z); - bA.SynchronizeTransform(); - bB.SynchronizeTransform(); - return positionError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop; - } - Box2D.inherit(b2WeldJointDef, Box2D.Dynamics.Joints.b2JointDef); - b2WeldJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; - b2WeldJointDef.b2WeldJointDef = function () { - Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); - this.localAnchorA = new b2Vec2(); - this.localAnchorB = new b2Vec2(); - }; - b2WeldJointDef.prototype.b2WeldJointDef = function () { - this.__super.b2JointDef.call(this); - this.type = b2Joint.e_weldJoint; - this.referenceAngle = 0.0; - } - b2WeldJointDef.prototype.Initialize = function (bA, bB, anchor) { - this.bodyA = bA; - this.bodyB = bB; - this.localAnchorA.SetV(this.bodyA.GetLocalPoint(anchor)); - this.localAnchorB.SetV(this.bodyB.GetLocalPoint(anchor)); - this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle(); - } -})(); -(function () { - var b2DebugDraw = Box2D.Dynamics.b2DebugDraw; - b2DebugDraw.b2DebugDraw = function () { - this.m_drawScale = 1.0; - this.m_lineThickness = 1.0; - this.m_alpha = 1.0; - this.m_fillAlpha = 1.0; - this.m_xformScale = 1.0; - var __this = this; - //#WORKAROUND - this.m_sprite = { - graphics: { - clear: function () { - __this.m_ctx.clearRect(0, 0, __this.m_ctx.canvas.width, __this.m_ctx.canvas.height) - } - } - }; - }; - b2DebugDraw.prototype._color = function (color, alpha) { - return "rgba(" + ((color & 0xFF0000) >> 16) + "," + ((color & 0xFF00) >> 8) + "," + (color & 0xFF) + "," + alpha + ")"; - }; - b2DebugDraw.prototype.b2DebugDraw = function () { - this.m_drawFlags = 0; - }; - b2DebugDraw.prototype.SetFlags = function (flags) { - if (flags === undefined) flags = 0; - this.m_drawFlags = flags; - }; - b2DebugDraw.prototype.GetFlags = function () { - return this.m_drawFlags; - }; - b2DebugDraw.prototype.AppendFlags = function (flags) { - if (flags === undefined) flags = 0; - this.m_drawFlags |= flags; - }; - b2DebugDraw.prototype.ClearFlags = function (flags) { - if (flags === undefined) flags = 0; - this.m_drawFlags &= ~flags; - }; - b2DebugDraw.prototype.SetSprite = function (sprite) { - this.m_ctx = sprite; - }; - b2DebugDraw.prototype.GetSprite = function () { - return this.m_ctx; - }; - b2DebugDraw.prototype.SetDrawScale = function (drawScale) { - if (drawScale === undefined) drawScale = 0; - this.m_drawScale = drawScale; - }; - b2DebugDraw.prototype.GetDrawScale = function () { - return this.m_drawScale; - }; - b2DebugDraw.prototype.SetLineThickness = function (lineThickness) { - if (lineThickness === undefined) lineThickness = 0; - this.m_lineThickness = lineThickness; - this.m_ctx.strokeWidth = lineThickness; - }; - b2DebugDraw.prototype.GetLineThickness = function () { - return this.m_lineThickness; - }; - b2DebugDraw.prototype.SetAlpha = function (alpha) { - if (alpha === undefined) alpha = 0; - this.m_alpha = alpha; - }; - b2DebugDraw.prototype.GetAlpha = function () { - return this.m_alpha; - }; - b2DebugDraw.prototype.SetFillAlpha = function (alpha) { - if (alpha === undefined) alpha = 0; - this.m_fillAlpha = alpha; - }; - b2DebugDraw.prototype.GetFillAlpha = function () { - return this.m_fillAlpha; - }; - b2DebugDraw.prototype.SetXFormScale = function (xformScale) { - if (xformScale === undefined) xformScale = 0; - this.m_xformScale = xformScale; - }; - b2DebugDraw.prototype.GetXFormScale = function () { - return this.m_xformScale; - }; - b2DebugDraw.prototype.DrawPolygon = function (vertices, vertexCount, color) { - if (!vertexCount) return; - var s = this.m_ctx; - var drawScale = this.m_drawScale; - s.beginPath(); - s.strokeStyle = this._color(color.color, this.m_alpha); - s.moveTo(vertices[0].x * drawScale, vertices[0].y * drawScale); - for (var i = 1; i < vertexCount; i++) { - s.lineTo(vertices[i].x * drawScale, vertices[i].y * drawScale); - } - s.lineTo(vertices[0].x * drawScale, vertices[0].y * drawScale); - s.closePath(); - s.stroke(); - }; - b2DebugDraw.prototype.DrawSolidPolygon = function (vertices, vertexCount, color) { - if (!vertexCount) return; - var s = this.m_ctx; - var drawScale = this.m_drawScale; - s.beginPath(); - s.strokeStyle = this._color(color.color, this.m_alpha); - s.fillStyle = this._color(color.color, this.m_fillAlpha); - s.moveTo(vertices[0].x * drawScale, vertices[0].y * drawScale); - for (var i = 1; i < vertexCount; i++) { - s.lineTo(vertices[i].x * drawScale, vertices[i].y * drawScale); - } - s.lineTo(vertices[0].x * drawScale, vertices[0].y * drawScale); - s.closePath(); - s.fill(); - s.stroke(); - }; - b2DebugDraw.prototype.DrawCircle = function (center, radius, color) { - if (!radius) return; - var s = this.m_ctx; - var drawScale = this.m_drawScale; - s.beginPath(); - s.strokeStyle = this._color(color.color, this.m_alpha); - s.arc(center.x * drawScale, center.y * drawScale, radius * drawScale, 0, Math.PI * 2, true); - s.closePath(); - s.stroke(); - }; - b2DebugDraw.prototype.DrawSolidCircle = function (center, radius, axis, color) { - if (!radius) return; - var s = this.m_ctx, - drawScale = this.m_drawScale, - cx = center.x * drawScale, - cy = center.y * drawScale; - s.moveTo(0, 0); - s.beginPath(); - s.strokeStyle = this._color(color.color, this.m_alpha); - s.fillStyle = this._color(color.color, this.m_fillAlpha); - s.arc(cx, cy, radius * drawScale, 0, Math.PI * 2, true); - s.moveTo(cx, cy); - s.lineTo((center.x + axis.x * radius) * drawScale, (center.y + axis.y * radius) * drawScale); - s.closePath(); - s.fill(); - s.stroke(); - }; - b2DebugDraw.prototype.DrawSegment = function (p1, p2, color) { - var s = this.m_ctx, - drawScale = this.m_drawScale; - s.strokeStyle = this._color(color.color, this.m_alpha); - s.beginPath(); - s.moveTo(p1.x * drawScale, p1.y * drawScale); - s.lineTo(p2.x * drawScale, p2.y * drawScale); - s.closePath(); - s.stroke(); - }; - b2DebugDraw.prototype.DrawTransform = function (xf) { - var s = this.m_ctx, - drawScale = this.m_drawScale; - s.beginPath(); - s.strokeStyle = this._color(0xff0000, this.m_alpha); - s.moveTo(xf.position.x * drawScale, xf.position.y * drawScale); - s.lineTo((xf.position.x + this.m_xformScale * xf.R.col1.x) * drawScale, (xf.position.y + this.m_xformScale * xf.R.col1.y) * drawScale); - - s.strokeStyle = this._color(0xff00, this.m_alpha); - s.moveTo(xf.position.x * drawScale, xf.position.y * drawScale); - s.lineTo((xf.position.x + this.m_xformScale * xf.R.col2.x) * drawScale, (xf.position.y + this.m_xformScale * xf.R.col2.y) * drawScale); - s.closePath(); - s.stroke(); - }; -})(); //post-definitions -var i; -for (i = 0; i < Box2D.postDefs.length; ++i) Box2D.postDefs[i](); -delete Box2D.postDefs; - - return Box2D; }); \ No newline at end of file diff --git a/app/Lib/Vendor/Box2D/Box2D.js b/app/Lib/Vendor/Box2D/Box2D.js new file mode 100755 index 0000000..c059918 --- /dev/null +++ b/app/Lib/Vendor/Box2D/Box2D.js @@ -0,0 +1,10866 @@ +define(function() { + +/* +* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com +* +* This software is provided 'as-is', without any express or implied +* warranty. In no event will the authors be held liable for any damages +* arising from the use of this software. +* Permission is granted to anyone to use this software for any purpose, +* including commercial applications, and to alter it and redistribute it +* freely, subject to the following restrictions: +* 1. The origin of this software must not be misrepresented; you must not +* claim that you wrote the original software. If you use this software +* in a product, an acknowledgment in the product documentation would be +* appreciated but is not required. +* 2. Altered source versions must be plainly marked as such, and must not be +* misrepresented as being the original software. +* 3. This notice may not be removed or altered from any source distribution. +*/ +var Box2D = {}; + +(function (a2j, undefined) { + + function emptyFn() {}; + a2j.inherit = function(cls, base) { + var tmpCtr = cls; + emptyFn.prototype = base.prototype; + cls.prototype = new emptyFn; + cls.prototype.constructor = tmpCtr; + }; + + a2j.generateCallback = function generateCallback(context, cb) { + return function () { + cb.apply(context, arguments); + }; + }; + + a2j.NVector = function NVector(length) { + if (length === undefined) length = 0; + var tmp = new Array(length || 0); + for (var i = 0; i < length; ++i) + tmp[i] = 0; + return tmp; + }; + + a2j.is = function is(o1, o2) { + if (o1 === null) return false; + if ((o2 instanceof Function) && (o1 instanceof o2)) return true; + if ((o1.constructor.__implements != undefined) && (o1.constructor.__implements[o2])) return true; + return false; + }; + + a2j.parseUInt = function(v) { + return Math.abs(parseInt(v)); + } + +})(Box2D); + +//#TODO remove assignments from global namespace +var Vector = Array; +var Vector_a2j_Number = Box2D.NVector; +//package structure +if (typeof(Box2D) === "undefined") Box2D = {}; +if (typeof(Box2D.Collision) === "undefined") Box2D.Collision = {}; +if (typeof(Box2D.Collision.Shapes) === "undefined") Box2D.Collision.Shapes = {}; +if (typeof(Box2D.Common) === "undefined") Box2D.Common = {}; +if (typeof(Box2D.Common.Math) === "undefined") Box2D.Common.Math = {}; +if (typeof(Box2D.Dynamics) === "undefined") Box2D.Dynamics = {}; +if (typeof(Box2D.Dynamics.Contacts) === "undefined") Box2D.Dynamics.Contacts = {}; +if (typeof(Box2D.Dynamics.Controllers) === "undefined") Box2D.Dynamics.Controllers = {}; +if (typeof(Box2D.Dynamics.Joints) === "undefined") Box2D.Dynamics.Joints = {}; +//pre-definitions +(function () { + Box2D.Collision.IBroadPhase = 'Box2D.Collision.IBroadPhase'; + + function b2AABB() { + b2AABB.b2AABB.apply(this, arguments); + }; + Box2D.Collision.b2AABB = b2AABB; + + function b2Bound() { + b2Bound.b2Bound.apply(this, arguments); + }; + Box2D.Collision.b2Bound = b2Bound; + + function b2BoundValues() { + b2BoundValues.b2BoundValues.apply(this, arguments); + if (this.constructor === b2BoundValues) this.b2BoundValues.apply(this, arguments); + }; + Box2D.Collision.b2BoundValues = b2BoundValues; + + function b2Collision() { + b2Collision.b2Collision.apply(this, arguments); + }; + Box2D.Collision.b2Collision = b2Collision; + + function b2ContactID() { + b2ContactID.b2ContactID.apply(this, arguments); + if (this.constructor === b2ContactID) this.b2ContactID.apply(this, arguments); + }; + Box2D.Collision.b2ContactID = b2ContactID; + + function b2ContactPoint() { + b2ContactPoint.b2ContactPoint.apply(this, arguments); + }; + Box2D.Collision.b2ContactPoint = b2ContactPoint; + + function b2Distance() { + b2Distance.b2Distance.apply(this, arguments); + }; + Box2D.Collision.b2Distance = b2Distance; + + function b2DistanceInput() { + b2DistanceInput.b2DistanceInput.apply(this, arguments); + }; + Box2D.Collision.b2DistanceInput = b2DistanceInput; + + function b2DistanceOutput() { + b2DistanceOutput.b2DistanceOutput.apply(this, arguments); + }; + Box2D.Collision.b2DistanceOutput = b2DistanceOutput; + + function b2DistanceProxy() { + b2DistanceProxy.b2DistanceProxy.apply(this, arguments); + }; + Box2D.Collision.b2DistanceProxy = b2DistanceProxy; + + function b2DynamicTree() { + b2DynamicTree.b2DynamicTree.apply(this, arguments); + if (this.constructor === b2DynamicTree) this.b2DynamicTree.apply(this, arguments); + }; + Box2D.Collision.b2DynamicTree = b2DynamicTree; + + function b2DynamicTreeBroadPhase() { + b2DynamicTreeBroadPhase.b2DynamicTreeBroadPhase.apply(this, arguments); + }; + Box2D.Collision.b2DynamicTreeBroadPhase = b2DynamicTreeBroadPhase; + + function b2DynamicTreeNode() { + b2DynamicTreeNode.b2DynamicTreeNode.apply(this, arguments); + }; + Box2D.Collision.b2DynamicTreeNode = b2DynamicTreeNode; + + function b2DynamicTreePair() { + b2DynamicTreePair.b2DynamicTreePair.apply(this, arguments); + }; + Box2D.Collision.b2DynamicTreePair = b2DynamicTreePair; + + function b2Manifold() { + b2Manifold.b2Manifold.apply(this, arguments); + if (this.constructor === b2Manifold) this.b2Manifold.apply(this, arguments); + }; + Box2D.Collision.b2Manifold = b2Manifold; + + function b2ManifoldPoint() { + b2ManifoldPoint.b2ManifoldPoint.apply(this, arguments); + if (this.constructor === b2ManifoldPoint) this.b2ManifoldPoint.apply(this, arguments); + }; + Box2D.Collision.b2ManifoldPoint = b2ManifoldPoint; + + function b2Point() { + b2Point.b2Point.apply(this, arguments); + }; + Box2D.Collision.b2Point = b2Point; + + function b2RayCastInput() { + b2RayCastInput.b2RayCastInput.apply(this, arguments); + if (this.constructor === b2RayCastInput) this.b2RayCastInput.apply(this, arguments); + }; + Box2D.Collision.b2RayCastInput = b2RayCastInput; + + function b2RayCastOutput() { + b2RayCastOutput.b2RayCastOutput.apply(this, arguments); + }; + Box2D.Collision.b2RayCastOutput = b2RayCastOutput; + + function b2Segment() { + b2Segment.b2Segment.apply(this, arguments); + }; + Box2D.Collision.b2Segment = b2Segment; + + function b2SeparationFunction() { + b2SeparationFunction.b2SeparationFunction.apply(this, arguments); + }; + Box2D.Collision.b2SeparationFunction = b2SeparationFunction; + + function b2Simplex() { + b2Simplex.b2Simplex.apply(this, arguments); + if (this.constructor === b2Simplex) this.b2Simplex.apply(this, arguments); + }; + Box2D.Collision.b2Simplex = b2Simplex; + + function b2SimplexCache() { + b2SimplexCache.b2SimplexCache.apply(this, arguments); + }; + Box2D.Collision.b2SimplexCache = b2SimplexCache; + + function b2SimplexVertex() { + b2SimplexVertex.b2SimplexVertex.apply(this, arguments); + }; + Box2D.Collision.b2SimplexVertex = b2SimplexVertex; + + function b2TimeOfImpact() { + b2TimeOfImpact.b2TimeOfImpact.apply(this, arguments); + }; + Box2D.Collision.b2TimeOfImpact = b2TimeOfImpact; + + function b2TOIInput() { + b2TOIInput.b2TOIInput.apply(this, arguments); + }; + Box2D.Collision.b2TOIInput = b2TOIInput; + + function b2WorldManifold() { + b2WorldManifold.b2WorldManifold.apply(this, arguments); + if (this.constructor === b2WorldManifold) this.b2WorldManifold.apply(this, arguments); + }; + Box2D.Collision.b2WorldManifold = b2WorldManifold; + + function ClipVertex() { + ClipVertex.ClipVertex.apply(this, arguments); + }; + Box2D.Collision.ClipVertex = ClipVertex; + + function Features() { + Features.Features.apply(this, arguments); + }; + Box2D.Collision.Features = Features; + + function b2CircleShape() { + b2CircleShape.b2CircleShape.apply(this, arguments); + if (this.constructor === b2CircleShape) this.b2CircleShape.apply(this, arguments); + }; + Box2D.Collision.Shapes.b2CircleShape = b2CircleShape; + + function b2EdgeChainDef() { + b2EdgeChainDef.b2EdgeChainDef.apply(this, arguments); + if (this.constructor === b2EdgeChainDef) this.b2EdgeChainDef.apply(this, arguments); + }; + Box2D.Collision.Shapes.b2EdgeChainDef = b2EdgeChainDef; + + function b2EdgeShape() { + b2EdgeShape.b2EdgeShape.apply(this, arguments); + if (this.constructor === b2EdgeShape) this.b2EdgeShape.apply(this, arguments); + }; + Box2D.Collision.Shapes.b2EdgeShape = b2EdgeShape; + + function b2MassData() { + b2MassData.b2MassData.apply(this, arguments); + }; + Box2D.Collision.Shapes.b2MassData = b2MassData; + + function b2PolygonShape() { + b2PolygonShape.b2PolygonShape.apply(this, arguments); + if (this.constructor === b2PolygonShape) this.b2PolygonShape.apply(this, arguments); + }; + Box2D.Collision.Shapes.b2PolygonShape = b2PolygonShape; + + function b2Shape() { + b2Shape.b2Shape.apply(this, arguments); + if (this.constructor === b2Shape) this.b2Shape.apply(this, arguments); + }; + Box2D.Collision.Shapes.b2Shape = b2Shape; + Box2D.Common.b2internal = 'Box2D.Common.b2internal'; + + function b2Color() { + b2Color.b2Color.apply(this, arguments); + if (this.constructor === b2Color) this.b2Color.apply(this, arguments); + }; + Box2D.Common.b2Color = b2Color; + + function b2Settings() { + b2Settings.b2Settings.apply(this, arguments); + }; + Box2D.Common.b2Settings = b2Settings; + + function b2Mat22() { + b2Mat22.b2Mat22.apply(this, arguments); + if (this.constructor === b2Mat22) this.b2Mat22.apply(this, arguments); + }; + Box2D.Common.Math.b2Mat22 = b2Mat22; + + function b2Mat33() { + b2Mat33.b2Mat33.apply(this, arguments); + if (this.constructor === b2Mat33) this.b2Mat33.apply(this, arguments); + }; + Box2D.Common.Math.b2Mat33 = b2Mat33; + + function b2Math() { + b2Math.b2Math.apply(this, arguments); + }; + Box2D.Common.Math.b2Math = b2Math; + + function b2Sweep() { + b2Sweep.b2Sweep.apply(this, arguments); + }; + Box2D.Common.Math.b2Sweep = b2Sweep; + + function b2Transform() { + b2Transform.b2Transform.apply(this, arguments); + if (this.constructor === b2Transform) this.b2Transform.apply(this, arguments); + }; + Box2D.Common.Math.b2Transform = b2Transform; + + function b2Vec2() { + b2Vec2.b2Vec2.apply(this, arguments); + if (this.constructor === b2Vec2) this.b2Vec2.apply(this, arguments); + }; + Box2D.Common.Math.b2Vec2 = b2Vec2; + + function b2Vec3() { + b2Vec3.b2Vec3.apply(this, arguments); + if (this.constructor === b2Vec3) this.b2Vec3.apply(this, arguments); + }; + Box2D.Common.Math.b2Vec3 = b2Vec3; + + function b2Body() { + b2Body.b2Body.apply(this, arguments); + if (this.constructor === b2Body) this.b2Body.apply(this, arguments); + }; + Box2D.Dynamics.b2Body = b2Body; + + function b2BodyDef() { + b2BodyDef.b2BodyDef.apply(this, arguments); + if (this.constructor === b2BodyDef) this.b2BodyDef.apply(this, arguments); + }; + Box2D.Dynamics.b2BodyDef = b2BodyDef; + + function b2ContactFilter() { + b2ContactFilter.b2ContactFilter.apply(this, arguments); + }; + Box2D.Dynamics.b2ContactFilter = b2ContactFilter; + + function b2ContactImpulse() { + b2ContactImpulse.b2ContactImpulse.apply(this, arguments); + }; + Box2D.Dynamics.b2ContactImpulse = b2ContactImpulse; + + function b2ContactListener() { + b2ContactListener.b2ContactListener.apply(this, arguments); + }; + Box2D.Dynamics.b2ContactListener = b2ContactListener; + + function b2ContactManager() { + b2ContactManager.b2ContactManager.apply(this, arguments); + if (this.constructor === b2ContactManager) this.b2ContactManager.apply(this, arguments); + }; + Box2D.Dynamics.b2ContactManager = b2ContactManager; + + function b2DebugDraw() { + b2DebugDraw.b2DebugDraw.apply(this, arguments); + if (this.constructor === b2DebugDraw) this.b2DebugDraw.apply(this, arguments); + }; + Box2D.Dynamics.b2DebugDraw = b2DebugDraw; + + function b2DestructionListener() { + b2DestructionListener.b2DestructionListener.apply(this, arguments); + }; + Box2D.Dynamics.b2DestructionListener = b2DestructionListener; + + function b2FilterData() { + b2FilterData.b2FilterData.apply(this, arguments); + }; + Box2D.Dynamics.b2FilterData = b2FilterData; + + function b2Fixture() { + b2Fixture.b2Fixture.apply(this, arguments); + if (this.constructor === b2Fixture) this.b2Fixture.apply(this, arguments); + }; + Box2D.Dynamics.b2Fixture = b2Fixture; + + function b2FixtureDef() { + b2FixtureDef.b2FixtureDef.apply(this, arguments); + if (this.constructor === b2FixtureDef) this.b2FixtureDef.apply(this, arguments); + }; + Box2D.Dynamics.b2FixtureDef = b2FixtureDef; + + function b2Island() { + b2Island.b2Island.apply(this, arguments); + if (this.constructor === b2Island) this.b2Island.apply(this, arguments); + }; + Box2D.Dynamics.b2Island = b2Island; + + function b2TimeStep() { + b2TimeStep.b2TimeStep.apply(this, arguments); + }; + Box2D.Dynamics.b2TimeStep = b2TimeStep; + + function b2World() { + b2World.b2World.apply(this, arguments); + if (this.constructor === b2World) this.b2World.apply(this, arguments); + }; + Box2D.Dynamics.b2World = b2World; + + function b2CircleContact() { + b2CircleContact.b2CircleContact.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2CircleContact = b2CircleContact; + + function b2Contact() { + b2Contact.b2Contact.apply(this, arguments); + if (this.constructor === b2Contact) this.b2Contact.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2Contact = b2Contact; + + function b2ContactConstraint() { + b2ContactConstraint.b2ContactConstraint.apply(this, arguments); + if (this.constructor === b2ContactConstraint) this.b2ContactConstraint.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2ContactConstraint = b2ContactConstraint; + + function b2ContactConstraintPoint() { + b2ContactConstraintPoint.b2ContactConstraintPoint.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2ContactConstraintPoint = b2ContactConstraintPoint; + + function b2ContactEdge() { + b2ContactEdge.b2ContactEdge.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2ContactEdge = b2ContactEdge; + + function b2ContactFactory() { + b2ContactFactory.b2ContactFactory.apply(this, arguments); + if (this.constructor === b2ContactFactory) this.b2ContactFactory.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2ContactFactory = b2ContactFactory; + + function b2ContactRegister() { + b2ContactRegister.b2ContactRegister.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2ContactRegister = b2ContactRegister; + + function b2ContactResult() { + b2ContactResult.b2ContactResult.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2ContactResult = b2ContactResult; + + function b2ContactSolver() { + b2ContactSolver.b2ContactSolver.apply(this, arguments); + if (this.constructor === b2ContactSolver) this.b2ContactSolver.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2ContactSolver = b2ContactSolver; + + function b2EdgeAndCircleContact() { + b2EdgeAndCircleContact.b2EdgeAndCircleContact.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2EdgeAndCircleContact = b2EdgeAndCircleContact; + + function b2NullContact() { + b2NullContact.b2NullContact.apply(this, arguments); + if (this.constructor === b2NullContact) this.b2NullContact.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2NullContact = b2NullContact; + + function b2PolyAndCircleContact() { + b2PolyAndCircleContact.b2PolyAndCircleContact.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2PolyAndCircleContact = b2PolyAndCircleContact; + + function b2PolyAndEdgeContact() { + b2PolyAndEdgeContact.b2PolyAndEdgeContact.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2PolyAndEdgeContact = b2PolyAndEdgeContact; + + function b2PolygonContact() { + b2PolygonContact.b2PolygonContact.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2PolygonContact = b2PolygonContact; + + function b2PositionSolverManifold() { + b2PositionSolverManifold.b2PositionSolverManifold.apply(this, arguments); + if (this.constructor === b2PositionSolverManifold) this.b2PositionSolverManifold.apply(this, arguments); + }; + Box2D.Dynamics.Contacts.b2PositionSolverManifold = b2PositionSolverManifold; + + function b2BuoyancyController() { + b2BuoyancyController.b2BuoyancyController.apply(this, arguments); + }; + Box2D.Dynamics.Controllers.b2BuoyancyController = b2BuoyancyController; + + function b2ConstantAccelController() { + b2ConstantAccelController.b2ConstantAccelController.apply(this, arguments); + }; + Box2D.Dynamics.Controllers.b2ConstantAccelController = b2ConstantAccelController; + + function b2ConstantForceController() { + b2ConstantForceController.b2ConstantForceController.apply(this, arguments); + }; + Box2D.Dynamics.Controllers.b2ConstantForceController = b2ConstantForceController; + + function b2Controller() { + b2Controller.b2Controller.apply(this, arguments); + }; + Box2D.Dynamics.Controllers.b2Controller = b2Controller; + + function b2ControllerEdge() { + b2ControllerEdge.b2ControllerEdge.apply(this, arguments); + }; + Box2D.Dynamics.Controllers.b2ControllerEdge = b2ControllerEdge; + + function b2GravityController() { + b2GravityController.b2GravityController.apply(this, arguments); + }; + Box2D.Dynamics.Controllers.b2GravityController = b2GravityController; + + function b2TensorDampingController() { + b2TensorDampingController.b2TensorDampingController.apply(this, arguments); + }; + Box2D.Dynamics.Controllers.b2TensorDampingController = b2TensorDampingController; + + function b2DistanceJoint() { + b2DistanceJoint.b2DistanceJoint.apply(this, arguments); + if (this.constructor === b2DistanceJoint) this.b2DistanceJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2DistanceJoint = b2DistanceJoint; + + function b2DistanceJointDef() { + b2DistanceJointDef.b2DistanceJointDef.apply(this, arguments); + if (this.constructor === b2DistanceJointDef) this.b2DistanceJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2DistanceJointDef = b2DistanceJointDef; + + function b2FrictionJoint() { + b2FrictionJoint.b2FrictionJoint.apply(this, arguments); + if (this.constructor === b2FrictionJoint) this.b2FrictionJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2FrictionJoint = b2FrictionJoint; + + function b2FrictionJointDef() { + b2FrictionJointDef.b2FrictionJointDef.apply(this, arguments); + if (this.constructor === b2FrictionJointDef) this.b2FrictionJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2FrictionJointDef = b2FrictionJointDef; + + function b2GearJoint() { + b2GearJoint.b2GearJoint.apply(this, arguments); + if (this.constructor === b2GearJoint) this.b2GearJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2GearJoint = b2GearJoint; + + function b2GearJointDef() { + b2GearJointDef.b2GearJointDef.apply(this, arguments); + if (this.constructor === b2GearJointDef) this.b2GearJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2GearJointDef = b2GearJointDef; + + function b2Jacobian() { + b2Jacobian.b2Jacobian.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2Jacobian = b2Jacobian; + + function b2Joint() { + b2Joint.b2Joint.apply(this, arguments); + if (this.constructor === b2Joint) this.b2Joint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2Joint = b2Joint; + + function b2JointDef() { + b2JointDef.b2JointDef.apply(this, arguments); + if (this.constructor === b2JointDef) this.b2JointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2JointDef = b2JointDef; + + function b2JointEdge() { + b2JointEdge.b2JointEdge.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2JointEdge = b2JointEdge; + + function b2LineJoint() { + b2LineJoint.b2LineJoint.apply(this, arguments); + if (this.constructor === b2LineJoint) this.b2LineJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2LineJoint = b2LineJoint; + + function b2LineJointDef() { + b2LineJointDef.b2LineJointDef.apply(this, arguments); + if (this.constructor === b2LineJointDef) this.b2LineJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2LineJointDef = b2LineJointDef; + + function b2MouseJoint() { + b2MouseJoint.b2MouseJoint.apply(this, arguments); + if (this.constructor === b2MouseJoint) this.b2MouseJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2MouseJoint = b2MouseJoint; + + function b2MouseJointDef() { + b2MouseJointDef.b2MouseJointDef.apply(this, arguments); + if (this.constructor === b2MouseJointDef) this.b2MouseJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2MouseJointDef = b2MouseJointDef; + + function b2PrismaticJoint() { + b2PrismaticJoint.b2PrismaticJoint.apply(this, arguments); + if (this.constructor === b2PrismaticJoint) this.b2PrismaticJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2PrismaticJoint = b2PrismaticJoint; + + function b2PrismaticJointDef() { + b2PrismaticJointDef.b2PrismaticJointDef.apply(this, arguments); + if (this.constructor === b2PrismaticJointDef) this.b2PrismaticJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2PrismaticJointDef = b2PrismaticJointDef; + + function b2PulleyJoint() { + b2PulleyJoint.b2PulleyJoint.apply(this, arguments); + if (this.constructor === b2PulleyJoint) this.b2PulleyJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2PulleyJoint = b2PulleyJoint; + + function b2PulleyJointDef() { + b2PulleyJointDef.b2PulleyJointDef.apply(this, arguments); + if (this.constructor === b2PulleyJointDef) this.b2PulleyJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2PulleyJointDef = b2PulleyJointDef; + + function b2RevoluteJoint() { + b2RevoluteJoint.b2RevoluteJoint.apply(this, arguments); + if (this.constructor === b2RevoluteJoint) this.b2RevoluteJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2RevoluteJoint = b2RevoluteJoint; + + function b2RevoluteJointDef() { + b2RevoluteJointDef.b2RevoluteJointDef.apply(this, arguments); + if (this.constructor === b2RevoluteJointDef) this.b2RevoluteJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2RevoluteJointDef = b2RevoluteJointDef; + + function b2WeldJoint() { + b2WeldJoint.b2WeldJoint.apply(this, arguments); + if (this.constructor === b2WeldJoint) this.b2WeldJoint.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2WeldJoint = b2WeldJoint; + + function b2WeldJointDef() { + b2WeldJointDef.b2WeldJointDef.apply(this, arguments); + if (this.constructor === b2WeldJointDef) this.b2WeldJointDef.apply(this, arguments); + }; + Box2D.Dynamics.Joints.b2WeldJointDef = b2WeldJointDef; +})(); //definitions +Box2D.postDefs = []; +(function () { + var b2CircleShape = Box2D.Collision.Shapes.b2CircleShape, + b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef, + b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape, + b2MassData = Box2D.Collision.Shapes.b2MassData, + b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape, + b2Shape = Box2D.Collision.Shapes.b2Shape, + b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3, + b2AABB = Box2D.Collision.b2AABB, + b2Bound = Box2D.Collision.b2Bound, + b2BoundValues = Box2D.Collision.b2BoundValues, + b2Collision = Box2D.Collision.b2Collision, + b2ContactID = Box2D.Collision.b2ContactID, + b2ContactPoint = Box2D.Collision.b2ContactPoint, + b2Distance = Box2D.Collision.b2Distance, + b2DistanceInput = Box2D.Collision.b2DistanceInput, + b2DistanceOutput = Box2D.Collision.b2DistanceOutput, + b2DistanceProxy = Box2D.Collision.b2DistanceProxy, + b2DynamicTree = Box2D.Collision.b2DynamicTree, + b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase, + b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode, + b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair, + b2Manifold = Box2D.Collision.b2Manifold, + b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint, + b2Point = Box2D.Collision.b2Point, + b2RayCastInput = Box2D.Collision.b2RayCastInput, + b2RayCastOutput = Box2D.Collision.b2RayCastOutput, + b2Segment = Box2D.Collision.b2Segment, + b2SeparationFunction = Box2D.Collision.b2SeparationFunction, + b2Simplex = Box2D.Collision.b2Simplex, + b2SimplexCache = Box2D.Collision.b2SimplexCache, + b2SimplexVertex = Box2D.Collision.b2SimplexVertex, + b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact, + b2TOIInput = Box2D.Collision.b2TOIInput, + b2WorldManifold = Box2D.Collision.b2WorldManifold, + ClipVertex = Box2D.Collision.ClipVertex, + Features = Box2D.Collision.Features, + IBroadPhase = Box2D.Collision.IBroadPhase; + + b2AABB.b2AABB = function () { + this.lowerBound = new b2Vec2(); + this.upperBound = new b2Vec2(); + }; + b2AABB.prototype.IsValid = function () { + var dX = this.upperBound.x - this.lowerBound.x; + var dY = this.upperBound.y - this.lowerBound.y; + var valid = dX >= 0.0 && dY >= 0.0; + valid = valid && this.lowerBound.IsValid() && this.upperBound.IsValid(); + return valid; + } + b2AABB.prototype.GetCenter = function () { + return new b2Vec2((this.lowerBound.x + this.upperBound.x) / 2, (this.lowerBound.y + this.upperBound.y) / 2); + } + b2AABB.prototype.GetExtents = function () { + return new b2Vec2((this.upperBound.x - this.lowerBound.x) / 2, (this.upperBound.y - this.lowerBound.y) / 2); + } + b2AABB.prototype.Contains = function (aabb) { + var result = true; + result = result && this.lowerBound.x <= aabb.lowerBound.x; + result = result && this.lowerBound.y <= aabb.lowerBound.y; + result = result && aabb.upperBound.x <= this.upperBound.x; + result = result && aabb.upperBound.y <= this.upperBound.y; + return result; + } + b2AABB.prototype.RayCast = function (output, input) { + var tmin = (-Number.MAX_VALUE); + var tmax = Number.MAX_VALUE; + var pX = input.p1.x; + var pY = input.p1.y; + var dX = input.p2.x - input.p1.x; + var dY = input.p2.y - input.p1.y; + var absDX = Math.abs(dX); + var absDY = Math.abs(dY); + var normal = output.normal; + var inv_d = 0; + var t1 = 0; + var t2 = 0; + var t3 = 0; + var s = 0; { + if (absDX < Number.MIN_VALUE) { + if (pX < this.lowerBound.x || this.upperBound.x < pX) return false; + } + else { + inv_d = 1.0 / dX; + t1 = (this.lowerBound.x - pX) * inv_d; + t2 = (this.upperBound.x - pX) * inv_d; + s = (-1.0); + if (t1 > t2) { + t3 = t1; + t1 = t2; + t2 = t3; + s = 1.0; + } + if (t1 > tmin) { + normal.x = s; + normal.y = 0; + tmin = t1; + } + tmax = Math.min(tmax, t2); + if (tmin > tmax) return false; + } + } { + if (absDY < Number.MIN_VALUE) { + if (pY < this.lowerBound.y || this.upperBound.y < pY) return false; + } + else { + inv_d = 1.0 / dY; + t1 = (this.lowerBound.y - pY) * inv_d; + t2 = (this.upperBound.y - pY) * inv_d; + s = (-1.0); + if (t1 > t2) { + t3 = t1; + t1 = t2; + t2 = t3; + s = 1.0; + } + if (t1 > tmin) { + normal.y = s; + normal.x = 0; + tmin = t1; + } + tmax = Math.min(tmax, t2); + if (tmin > tmax) return false; + } + } + output.fraction = tmin; + return true; + } + b2AABB.prototype.TestOverlap = function (other) { + var d1X = other.lowerBound.x - this.upperBound.x; + var d1Y = other.lowerBound.y - this.upperBound.y; + var d2X = this.lowerBound.x - other.upperBound.x; + var d2Y = this.lowerBound.y - other.upperBound.y; + if (d1X > 0.0 || d1Y > 0.0) return false; + if (d2X > 0.0 || d2Y > 0.0) return false; + return true; + } + b2AABB.Combine = function (aabb1, aabb2) { + var aabb = new b2AABB(); + aabb.Combine(aabb1, aabb2); + return aabb; + } + b2AABB.prototype.Combine = function (aabb1, aabb2) { + this.lowerBound.x = Math.min(aabb1.lowerBound.x, aabb2.lowerBound.x); + this.lowerBound.y = Math.min(aabb1.lowerBound.y, aabb2.lowerBound.y); + this.upperBound.x = Math.max(aabb1.upperBound.x, aabb2.upperBound.x); + this.upperBound.y = Math.max(aabb1.upperBound.y, aabb2.upperBound.y); + } + b2Bound.b2Bound = function () {}; + b2Bound.prototype.IsLower = function () { + return (this.value & 1) == 0; + } + b2Bound.prototype.IsUpper = function () { + return (this.value & 1) == 1; + } + b2Bound.prototype.Swap = function (b) { + var tempValue = this.value; + var tempProxy = this.proxy; + var tempStabbingCount = this.stabbingCount; + this.value = b.value; + this.proxy = b.proxy; + this.stabbingCount = b.stabbingCount; + b.value = tempValue; + b.proxy = tempProxy; + b.stabbingCount = tempStabbingCount; + } + b2BoundValues.b2BoundValues = function () {}; + b2BoundValues.prototype.b2BoundValues = function () { + this.lowerValues = new Vector_a2j_Number(); + this.lowerValues[0] = 0.0; + this.lowerValues[1] = 0.0; + this.upperValues = new Vector_a2j_Number(); + this.upperValues[0] = 0.0; + this.upperValues[1] = 0.0; + } + b2Collision.b2Collision = function () {}; + b2Collision.ClipSegmentToLine = function (vOut, vIn, normal, offset) { + if (offset === undefined) offset = 0; + var cv; + var numOut = 0; + cv = vIn[0]; + var vIn0 = cv.v; + cv = vIn[1]; + var vIn1 = cv.v; + var distance0 = normal.x * vIn0.x + normal.y * vIn0.y - offset; + var distance1 = normal.x * vIn1.x + normal.y * vIn1.y - offset; + if (distance0 <= 0.0) vOut[numOut++].Set(vIn[0]); + if (distance1 <= 0.0) vOut[numOut++].Set(vIn[1]); + if (distance0 * distance1 < 0.0) { + var interp = distance0 / (distance0 - distance1); + cv = vOut[numOut]; + var tVec = cv.v; + tVec.x = vIn0.x + interp * (vIn1.x - vIn0.x); + tVec.y = vIn0.y + interp * (vIn1.y - vIn0.y); + cv = vOut[numOut]; + var cv2; + if (distance0 > 0.0) { + cv2 = vIn[0]; + cv.id = cv2.id; + } + else { + cv2 = vIn[1]; + cv.id = cv2.id; + }++numOut; + } + return numOut; + } + b2Collision.EdgeSeparation = function (poly1, xf1, edge1, poly2, xf2) { + if (edge1 === undefined) edge1 = 0; + var count1 = parseInt(poly1.m_vertexCount); + var vertices1 = poly1.m_vertices; + var normals1 = poly1.m_normals; + var count2 = parseInt(poly2.m_vertexCount); + var vertices2 = poly2.m_vertices; + var tMat; + var tVec; + tMat = xf1.R; + tVec = normals1[edge1]; + var normal1WorldX = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var normal1WorldY = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tMat = xf2.R; + var normal1X = (tMat.col1.x * normal1WorldX + tMat.col1.y * normal1WorldY); + var normal1Y = (tMat.col2.x * normal1WorldX + tMat.col2.y * normal1WorldY); + var index = 0; + var minDot = Number.MAX_VALUE; + for (var i = 0; i < count2; ++i) { + tVec = vertices2[i]; + var dot = tVec.x * normal1X + tVec.y * normal1Y; + if (dot < minDot) { + minDot = dot; + index = i; + } + } + tVec = vertices1[edge1]; + tMat = xf1.R; + var v1X = xf1.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var v1Y = xf1.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tVec = vertices2[index]; + tMat = xf2.R; + var v2X = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var v2Y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + v2X -= v1X; + v2Y -= v1Y; + var separation = v2X * normal1WorldX + v2Y * normal1WorldY; + return separation; + } + b2Collision.FindMaxSeparation = function (edgeIndex, poly1, xf1, poly2, xf2) { + var count1 = parseInt(poly1.m_vertexCount); + var normals1 = poly1.m_normals; + var tVec; + var tMat; + tMat = xf2.R; + tVec = poly2.m_centroid; + var dX = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var dY = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tMat = xf1.R; + tVec = poly1.m_centroid; + dX -= xf1.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + dY -= xf1.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + var dLocal1X = (dX * xf1.R.col1.x + dY * xf1.R.col1.y); + var dLocal1Y = (dX * xf1.R.col2.x + dY * xf1.R.col2.y); + var edge = 0; + var maxDot = (-Number.MAX_VALUE); + for (var i = 0; i < count1; ++i) { + tVec = normals1[i]; + var dot = (tVec.x * dLocal1X + tVec.y * dLocal1Y); + if (dot > maxDot) { + maxDot = dot; + edge = i; + } + } + var s = b2Collision.EdgeSeparation(poly1, xf1, edge, poly2, xf2); + var prevEdge = parseInt(edge - 1 >= 0 ? edge - 1 : count1 - 1); + var sPrev = b2Collision.EdgeSeparation(poly1, xf1, prevEdge, poly2, xf2); + var nextEdge = parseInt(edge + 1 < count1 ? edge + 1 : 0); + var sNext = b2Collision.EdgeSeparation(poly1, xf1, nextEdge, poly2, xf2); + var bestEdge = 0; + var bestSeparation = 0; + var increment = 0; + if (sPrev > s && sPrev > sNext) { + increment = (-1); + bestEdge = prevEdge; + bestSeparation = sPrev; + } + else if (sNext > s) { + increment = 1; + bestEdge = nextEdge; + bestSeparation = sNext; + } + else { + edgeIndex[0] = edge; + return s; + } + while (true) { + if (increment == (-1)) edge = bestEdge - 1 >= 0 ? bestEdge - 1 : count1 - 1; + else edge = bestEdge + 1 < count1 ? bestEdge + 1 : 0;s = b2Collision.EdgeSeparation(poly1, xf1, edge, poly2, xf2); + if (s > bestSeparation) { + bestEdge = edge; + bestSeparation = s; + } + else { + break; + } + } + edgeIndex[0] = bestEdge; + return bestSeparation; + } + b2Collision.FindIncidentEdge = function (c, poly1, xf1, edge1, poly2, xf2) { + if (edge1 === undefined) edge1 = 0; + var count1 = parseInt(poly1.m_vertexCount); + var normals1 = poly1.m_normals; + var count2 = parseInt(poly2.m_vertexCount); + var vertices2 = poly2.m_vertices; + var normals2 = poly2.m_normals; + var tMat; + var tVec; + tMat = xf1.R; + tVec = normals1[edge1]; + var normal1X = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var normal1Y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tMat = xf2.R; + var tX = (tMat.col1.x * normal1X + tMat.col1.y * normal1Y); + normal1Y = (tMat.col2.x * normal1X + tMat.col2.y * normal1Y); + normal1X = tX; + var index = 0; + var minDot = Number.MAX_VALUE; + for (var i = 0; i < count2; ++i) { + tVec = normals2[i]; + var dot = (normal1X * tVec.x + normal1Y * tVec.y); + if (dot < minDot) { + minDot = dot; + index = i; + } + } + var tClip; + var i1 = parseInt(index); + var i2 = parseInt(i1 + 1 < count2 ? i1 + 1 : 0); + tClip = c[0]; + tVec = vertices2[i1]; + tMat = xf2.R; + tClip.v.x = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + tClip.v.y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tClip.id.features.referenceEdge = edge1; + tClip.id.features.incidentEdge = i1; + tClip.id.features.incidentVertex = 0; + tClip = c[1]; + tVec = vertices2[i2]; + tMat = xf2.R; + tClip.v.x = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + tClip.v.y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tClip.id.features.referenceEdge = edge1; + tClip.id.features.incidentEdge = i2; + tClip.id.features.incidentVertex = 1; + } + b2Collision.MakeClipPointVector = function () { + var r = new Vector(2); + r[0] = new ClipVertex(); + r[1] = new ClipVertex(); + return r; + } + b2Collision.CollidePolygons = function (manifold, polyA, xfA, polyB, xfB) { + var cv; + manifold.m_pointCount = 0; + var totalRadius = polyA.m_radius + polyB.m_radius; + var edgeA = 0; + b2Collision.s_edgeAO[0] = edgeA; + var separationA = b2Collision.FindMaxSeparation(b2Collision.s_edgeAO, polyA, xfA, polyB, xfB); + edgeA = b2Collision.s_edgeAO[0]; + if (separationA > totalRadius) return; + var edgeB = 0; + b2Collision.s_edgeBO[0] = edgeB; + var separationB = b2Collision.FindMaxSeparation(b2Collision.s_edgeBO, polyB, xfB, polyA, xfA); + edgeB = b2Collision.s_edgeBO[0]; + if (separationB > totalRadius) return; + var poly1; + var poly2; + var xf1; + var xf2; + var edge1 = 0; + var flip = 0; + var k_relativeTol = 0.98; + var k_absoluteTol = 0.001; + var tMat; + if (separationB > k_relativeTol * separationA + k_absoluteTol) { + poly1 = polyB; + poly2 = polyA; + xf1 = xfB; + xf2 = xfA; + edge1 = edgeB; + manifold.m_type = b2Manifold.e_faceB; + flip = 1; + } + else { + poly1 = polyA; + poly2 = polyB; + xf1 = xfA; + xf2 = xfB; + edge1 = edgeA; + manifold.m_type = b2Manifold.e_faceA; + flip = 0; + } + var incidentEdge = b2Collision.s_incidentEdge; + b2Collision.FindIncidentEdge(incidentEdge, poly1, xf1, edge1, poly2, xf2); + var count1 = parseInt(poly1.m_vertexCount); + var vertices1 = poly1.m_vertices; + var local_v11 = vertices1[edge1]; + var local_v12; + if (edge1 + 1 < count1) { + local_v12 = vertices1[parseInt(edge1 + 1)]; + } + else { + local_v12 = vertices1[0]; + } + var localTangent = b2Collision.s_localTangent; + localTangent.Set(local_v12.x - local_v11.x, local_v12.y - local_v11.y); + localTangent.Normalize(); + var localNormal = b2Collision.s_localNormal; + localNormal.x = localTangent.y; + localNormal.y = (-localTangent.x); + var planePoint = b2Collision.s_planePoint; + planePoint.Set(0.5 * (local_v11.x + local_v12.x), 0.5 * (local_v11.y + local_v12.y)); + var tangent = b2Collision.s_tangent; + tMat = xf1.R; + tangent.x = (tMat.col1.x * localTangent.x + tMat.col2.x * localTangent.y); + tangent.y = (tMat.col1.y * localTangent.x + tMat.col2.y * localTangent.y); + var tangent2 = b2Collision.s_tangent2; + tangent2.x = (-tangent.x); + tangent2.y = (-tangent.y); + var normal = b2Collision.s_normal; + normal.x = tangent.y; + normal.y = (-tangent.x); + var v11 = b2Collision.s_v11; + var v12 = b2Collision.s_v12; + v11.x = xf1.position.x + (tMat.col1.x * local_v11.x + tMat.col2.x * local_v11.y); + v11.y = xf1.position.y + (tMat.col1.y * local_v11.x + tMat.col2.y * local_v11.y); + v12.x = xf1.position.x + (tMat.col1.x * local_v12.x + tMat.col2.x * local_v12.y); + v12.y = xf1.position.y + (tMat.col1.y * local_v12.x + tMat.col2.y * local_v12.y); + var frontOffset = normal.x * v11.x + normal.y * v11.y; + var sideOffset1 = (-tangent.x * v11.x) - tangent.y * v11.y + totalRadius; + var sideOffset2 = tangent.x * v12.x + tangent.y * v12.y + totalRadius; + var clipPoints1 = b2Collision.s_clipPoints1; + var clipPoints2 = b2Collision.s_clipPoints2; + var np = 0; + np = b2Collision.ClipSegmentToLine(clipPoints1, incidentEdge, tangent2, sideOffset1); + if (np < 2) return; + np = b2Collision.ClipSegmentToLine(clipPoints2, clipPoints1, tangent, sideOffset2); + if (np < 2) return; + manifold.m_localPlaneNormal.SetV(localNormal); + manifold.m_localPoint.SetV(planePoint); + var pointCount = 0; + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; ++i) { + cv = clipPoints2[i]; + var separation = normal.x * cv.v.x + normal.y * cv.v.y - frontOffset; + if (separation <= totalRadius) { + var cp = manifold.m_points[pointCount]; + tMat = xf2.R; + var tX = cv.v.x - xf2.position.x; + var tY = cv.v.y - xf2.position.y; + cp.m_localPoint.x = (tX * tMat.col1.x + tY * tMat.col1.y); + cp.m_localPoint.y = (tX * tMat.col2.x + tY * tMat.col2.y); + cp.m_id.Set(cv.id); + cp.m_id.features.flip = flip; + ++pointCount; + } + } + manifold.m_pointCount = pointCount; + } + b2Collision.CollideCircles = function (manifold, circle1, xf1, circle2, xf2) { + manifold.m_pointCount = 0; + var tMat; + var tVec; + tMat = xf1.R; + tVec = circle1.m_p; + var p1X = xf1.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var p1Y = xf1.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tMat = xf2.R; + tVec = circle2.m_p; + var p2X = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var p2Y = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + var dX = p2X - p1X; + var dY = p2Y - p1Y; + var distSqr = dX * dX + dY * dY; + var radius = circle1.m_radius + circle2.m_radius; + if (distSqr > radius * radius) { + return; + } + manifold.m_type = b2Manifold.e_circles; + manifold.m_localPoint.SetV(circle1.m_p); + manifold.m_localPlaneNormal.SetZero(); + manifold.m_pointCount = 1; + manifold.m_points[0].m_localPoint.SetV(circle2.m_p); + manifold.m_points[0].m_id.key = 0; + } + b2Collision.CollidePolygonAndCircle = function (manifold, polygon, xf1, circle, xf2) { + manifold.m_pointCount = 0; + var tPoint; + var dX = 0; + var dY = 0; + var positionX = 0; + var positionY = 0; + var tVec; + var tMat; + tMat = xf2.R; + tVec = circle.m_p; + var cX = xf2.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var cY = xf2.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + dX = cX - xf1.position.x; + dY = cY - xf1.position.y; + tMat = xf1.R; + var cLocalX = (dX * tMat.col1.x + dY * tMat.col1.y); + var cLocalY = (dX * tMat.col2.x + dY * tMat.col2.y); + var dist = 0; + var normalIndex = 0; + var separation = (-Number.MAX_VALUE); + var radius = polygon.m_radius + circle.m_radius; + var vertexCount = parseInt(polygon.m_vertexCount); + var vertices = polygon.m_vertices; + var normals = polygon.m_normals; + for (var i = 0; i < vertexCount; ++i) { + tVec = vertices[i]; + dX = cLocalX - tVec.x; + dY = cLocalY - tVec.y; + tVec = normals[i]; + var s = tVec.x * dX + tVec.y * dY; + if (s > radius) { + return; + } + if (s > separation) { + separation = s; + normalIndex = i; + } + } + var vertIndex1 = parseInt(normalIndex); + var vertIndex2 = parseInt(vertIndex1 + 1 < vertexCount ? vertIndex1 + 1 : 0); + var v1 = vertices[vertIndex1]; + var v2 = vertices[vertIndex2]; + if (separation < Number.MIN_VALUE) { + manifold.m_pointCount = 1; + manifold.m_type = b2Manifold.e_faceA; + manifold.m_localPlaneNormal.SetV(normals[normalIndex]); + manifold.m_localPoint.x = 0.5 * (v1.x + v2.x); + manifold.m_localPoint.y = 0.5 * (v1.y + v2.y); + manifold.m_points[0].m_localPoint.SetV(circle.m_p); + manifold.m_points[0].m_id.key = 0; + return; + } + var u1 = (cLocalX - v1.x) * (v2.x - v1.x) + (cLocalY - v1.y) * (v2.y - v1.y); + var u2 = (cLocalX - v2.x) * (v1.x - v2.x) + (cLocalY - v2.y) * (v1.y - v2.y); + if (u1 <= 0.0) { + if ((cLocalX - v1.x) * (cLocalX - v1.x) + (cLocalY - v1.y) * (cLocalY - v1.y) > radius * radius) return; + manifold.m_pointCount = 1; + manifold.m_type = b2Manifold.e_faceA; + manifold.m_localPlaneNormal.x = cLocalX - v1.x; + manifold.m_localPlaneNormal.y = cLocalY - v1.y; + manifold.m_localPlaneNormal.Normalize(); + manifold.m_localPoint.SetV(v1); + manifold.m_points[0].m_localPoint.SetV(circle.m_p); + manifold.m_points[0].m_id.key = 0; + } + else if (u2 <= 0) { + if ((cLocalX - v2.x) * (cLocalX - v2.x) + (cLocalY - v2.y) * (cLocalY - v2.y) > radius * radius) return; + manifold.m_pointCount = 1; + manifold.m_type = b2Manifold.e_faceA; + manifold.m_localPlaneNormal.x = cLocalX - v2.x; + manifold.m_localPlaneNormal.y = cLocalY - v2.y; + manifold.m_localPlaneNormal.Normalize(); + manifold.m_localPoint.SetV(v2); + manifold.m_points[0].m_localPoint.SetV(circle.m_p); + manifold.m_points[0].m_id.key = 0; + } + else { + var faceCenterX = 0.5 * (v1.x + v2.x); + var faceCenterY = 0.5 * (v1.y + v2.y); + separation = (cLocalX - faceCenterX) * normals[vertIndex1].x + (cLocalY - faceCenterY) * normals[vertIndex1].y; + if (separation > radius) return; + manifold.m_pointCount = 1; + manifold.m_type = b2Manifold.e_faceA; + manifold.m_localPlaneNormal.x = normals[vertIndex1].x; + manifold.m_localPlaneNormal.y = normals[vertIndex1].y; + manifold.m_localPlaneNormal.Normalize(); + manifold.m_localPoint.Set(faceCenterX, faceCenterY); + manifold.m_points[0].m_localPoint.SetV(circle.m_p); + manifold.m_points[0].m_id.key = 0; + } + } + b2Collision.TestOverlap = function (a, b) { + var t1 = b.lowerBound; + var t2 = a.upperBound; + var d1X = t1.x - t2.x; + var d1Y = t1.y - t2.y; + t1 = a.lowerBound; + t2 = b.upperBound; + var d2X = t1.x - t2.x; + var d2Y = t1.y - t2.y; + if (d1X > 0.0 || d1Y > 0.0) return false; + if (d2X > 0.0 || d2Y > 0.0) return false; + return true; + } + Box2D.postDefs.push(function () { + Box2D.Collision.b2Collision.s_incidentEdge = b2Collision.MakeClipPointVector(); + Box2D.Collision.b2Collision.s_clipPoints1 = b2Collision.MakeClipPointVector(); + Box2D.Collision.b2Collision.s_clipPoints2 = b2Collision.MakeClipPointVector(); + Box2D.Collision.b2Collision.s_edgeAO = new Vector_a2j_Number(1); + Box2D.Collision.b2Collision.s_edgeBO = new Vector_a2j_Number(1); + Box2D.Collision.b2Collision.s_localTangent = new b2Vec2(); + Box2D.Collision.b2Collision.s_localNormal = new b2Vec2(); + Box2D.Collision.b2Collision.s_planePoint = new b2Vec2(); + Box2D.Collision.b2Collision.s_normal = new b2Vec2(); + Box2D.Collision.b2Collision.s_tangent = new b2Vec2(); + Box2D.Collision.b2Collision.s_tangent2 = new b2Vec2(); + Box2D.Collision.b2Collision.s_v11 = new b2Vec2(); + Box2D.Collision.b2Collision.s_v12 = new b2Vec2(); + Box2D.Collision.b2Collision.b2CollidePolyTempVec = new b2Vec2(); + Box2D.Collision.b2Collision.b2_nullFeature = 0x000000ff; + }); + b2ContactID.b2ContactID = function () { + this.features = new Features(); + }; + b2ContactID.prototype.b2ContactID = function () { + this.features._m_id = this; + } + b2ContactID.prototype.Set = function (id) { + this.key = id._key; + } + b2ContactID.prototype.Copy = function () { + var id = new b2ContactID(); + id.key = this.key; + return id; + } + Object.defineProperty(b2ContactID.prototype, 'key', { + enumerable: false, + configurable: true, + get: function () { + return this._key; + } + }); + Object.defineProperty(b2ContactID.prototype, 'key', { + enumerable: false, + configurable: true, + set: function (value) { + if (value === undefined) value = 0; + this._key = value; + this.features._referenceEdge = this._key & 0x000000ff; + this.features._incidentEdge = ((this._key & 0x0000ff00) >> 8) & 0x000000ff; + this.features._incidentVertex = ((this._key & 0x00ff0000) >> 16) & 0x000000ff; + this.features._flip = ((this._key & 0xff000000) >> 24) & 0x000000ff; + } + }); + b2ContactPoint.b2ContactPoint = function () { + this.position = new b2Vec2(); + this.velocity = new b2Vec2(); + this.normal = new b2Vec2(); + this.id = new b2ContactID(); + }; + b2Distance.b2Distance = function () {}; + b2Distance.Distance = function (output, cache, input) { + ++b2Distance.b2_gjkCalls; + var proxyA = input.proxyA; + var proxyB = input.proxyB; + var transformA = input.transformA; + var transformB = input.transformB; + var simplex = b2Distance.s_simplex; + simplex.ReadCache(cache, proxyA, transformA, proxyB, transformB); + var vertices = simplex.m_vertices; + var k_maxIters = 20; + var saveA = b2Distance.s_saveA; + var saveB = b2Distance.s_saveB; + var saveCount = 0; + var closestPoint = simplex.GetClosestPoint(); + var distanceSqr1 = closestPoint.LengthSquared(); + var distanceSqr2 = distanceSqr1; + var i = 0; + var p; + var iter = 0; + while (iter < k_maxIters) { + saveCount = simplex.m_count; + for (i = 0; + i < saveCount; i++) { + saveA[i] = vertices[i].indexA; + saveB[i] = vertices[i].indexB; + } + switch (simplex.m_count) { + case 1: + break; + case 2: + simplex.Solve2(); + break; + case 3: + simplex.Solve3(); + break; + default: + b2Settings.b2Assert(false); + } + if (simplex.m_count == 3) { + break; + } + p = simplex.GetClosestPoint(); + distanceSqr2 = p.LengthSquared(); + if (distanceSqr2 > distanceSqr1) {} + distanceSqr1 = distanceSqr2; + var d = simplex.GetSearchDirection(); + if (d.LengthSquared() < Number.MIN_VALUE * Number.MIN_VALUE) { + break; + } + var vertex = vertices[simplex.m_count]; + vertex.indexA = proxyA.GetSupport(b2Math.MulTMV(transformA.R, d.GetNegative())); + vertex.wA = b2Math.MulX(transformA, proxyA.GetVertex(vertex.indexA)); + vertex.indexB = proxyB.GetSupport(b2Math.MulTMV(transformB.R, d)); + vertex.wB = b2Math.MulX(transformB, proxyB.GetVertex(vertex.indexB)); + vertex.w = b2Math.SubtractVV(vertex.wB, vertex.wA); + ++iter; + ++b2Distance.b2_gjkIters; + var duplicate = false; + for (i = 0; + i < saveCount; i++) { + if (vertex.indexA == saveA[i] && vertex.indexB == saveB[i]) { + duplicate = true; + break; + } + } + if (duplicate) { + break; + }++simplex.m_count; + } + b2Distance.b2_gjkMaxIters = b2Math.Max(b2Distance.b2_gjkMaxIters, iter); + simplex.GetWitnessPoints(output.pointA, output.pointB); + output.distance = b2Math.SubtractVV(output.pointA, output.pointB).Length(); + output.iterations = iter; + simplex.WriteCache(cache); + if (input.useRadii) { + var rA = proxyA.m_radius; + var rB = proxyB.m_radius; + if (output.distance > rA + rB && output.distance > Number.MIN_VALUE) { + output.distance -= rA + rB; + var normal = b2Math.SubtractVV(output.pointB, output.pointA); + normal.Normalize(); + output.pointA.x += rA * normal.x; + output.pointA.y += rA * normal.y; + output.pointB.x -= rB * normal.x; + output.pointB.y -= rB * normal.y; + } + else { + p = new b2Vec2(); + p.x = .5 * (output.pointA.x + output.pointB.x); + p.y = .5 * (output.pointA.y + output.pointB.y); + output.pointA.x = output.pointB.x = p.x; + output.pointA.y = output.pointB.y = p.y; + output.distance = 0.0; + } + } + } + Box2D.postDefs.push(function () { + Box2D.Collision.b2Distance.s_simplex = new b2Simplex(); + Box2D.Collision.b2Distance.s_saveA = new Vector_a2j_Number(3); + Box2D.Collision.b2Distance.s_saveB = new Vector_a2j_Number(3); + }); + b2DistanceInput.b2DistanceInput = function () {}; + b2DistanceOutput.b2DistanceOutput = function () { + this.pointA = new b2Vec2(); + this.pointB = new b2Vec2(); + }; + b2DistanceProxy.b2DistanceProxy = function () {}; + b2DistanceProxy.prototype.Set = function (shape) { + switch (shape.GetType()) { + case b2Shape.e_circleShape: + { + var circle = (shape instanceof b2CircleShape ? shape : null); + this.m_vertices = new Vector(1, true); + this.m_vertices[0] = circle.m_p; + this.m_count = 1; + this.m_radius = circle.m_radius; + } + break; + case b2Shape.e_polygonShape: + { + var polygon = (shape instanceof b2PolygonShape ? shape : null); + this.m_vertices = polygon.m_vertices; + this.m_count = polygon.m_vertexCount; + this.m_radius = polygon.m_radius; + } + break; + default: + b2Settings.b2Assert(false); + } + } + b2DistanceProxy.prototype.GetSupport = function (d) { + var bestIndex = 0; + var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y; + for (var i = 1; i < this.m_count; ++i) { + var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y; + if (value > bestValue) { + bestIndex = i; + bestValue = value; + } + } + return bestIndex; + } + b2DistanceProxy.prototype.GetSupportVertex = function (d) { + var bestIndex = 0; + var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y; + for (var i = 1; i < this.m_count; ++i) { + var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y; + if (value > bestValue) { + bestIndex = i; + bestValue = value; + } + } + return this.m_vertices[bestIndex]; + } + b2DistanceProxy.prototype.GetVertexCount = function () { + return this.m_count; + } + b2DistanceProxy.prototype.GetVertex = function (index) { + if (index === undefined) index = 0; + b2Settings.b2Assert(0 <= index && index < this.m_count); + return this.m_vertices[index]; + } + b2DynamicTree.b2DynamicTree = function () {}; + b2DynamicTree.prototype.b2DynamicTree = function () { + this.m_root = null; + this.m_freeList = null; + this.m_path = 0; + this.m_insertionCount = 0; + } + b2DynamicTree.prototype.CreateProxy = function (aabb, userData) { + var node = this.AllocateNode(); + var extendX = b2Settings.b2_aabbExtension; + var extendY = b2Settings.b2_aabbExtension; + node.aabb.lowerBound.x = aabb.lowerBound.x - extendX; + node.aabb.lowerBound.y = aabb.lowerBound.y - extendY; + node.aabb.upperBound.x = aabb.upperBound.x + extendX; + node.aabb.upperBound.y = aabb.upperBound.y + extendY; + node.userData = userData; + this.InsertLeaf(node); + return node; + } + b2DynamicTree.prototype.DestroyProxy = function (proxy) { + this.RemoveLeaf(proxy); + this.FreeNode(proxy); + } + b2DynamicTree.prototype.MoveProxy = function (proxy, aabb, displacement) { + b2Settings.b2Assert(proxy.IsLeaf()); + if (proxy.aabb.Contains(aabb)) { + return false; + } + this.RemoveLeaf(proxy); + var extendX = b2Settings.b2_aabbExtension + b2Settings.b2_aabbMultiplier * (displacement.x > 0 ? displacement.x : (-displacement.x)); + var extendY = b2Settings.b2_aabbExtension + b2Settings.b2_aabbMultiplier * (displacement.y > 0 ? displacement.y : (-displacement.y)); + proxy.aabb.lowerBound.x = aabb.lowerBound.x - extendX; + proxy.aabb.lowerBound.y = aabb.lowerBound.y - extendY; + proxy.aabb.upperBound.x = aabb.upperBound.x + extendX; + proxy.aabb.upperBound.y = aabb.upperBound.y + extendY; + this.InsertLeaf(proxy); + return true; + } + b2DynamicTree.prototype.Rebalance = function (iterations) { + if (iterations === undefined) iterations = 0; + if (this.m_root == null) return; + for (var i = 0; i < iterations; i++) { + var node = this.m_root; + var bit = 0; + while (node.IsLeaf() == false) { + node = (this.m_path >> bit) & 1 ? node.child2 : node.child1; + bit = (bit + 1) & 31; + }++this.m_path; + this.RemoveLeaf(node); + this.InsertLeaf(node); + } + } + b2DynamicTree.prototype.GetFatAABB = function (proxy) { + return proxy.aabb; + } + b2DynamicTree.prototype.GetUserData = function (proxy) { + return proxy.userData; + } + b2DynamicTree.prototype.Query = function (callback, aabb) { + if (this.m_root == null) return; + var stack = new Vector(); + var count = 0; + stack[count++] = this.m_root; + while (count > 0) { + var node = stack[--count]; + if (node.aabb.TestOverlap(aabb)) { + if (node.IsLeaf()) { + var proceed = callback(node); + if (!proceed) return; + } + else { + stack[count++] = node.child1; + stack[count++] = node.child2; + } + } + } + } + b2DynamicTree.prototype.RayCast = function (callback, input) { + if (this.m_root == null) return; + var p1 = input.p1; + var p2 = input.p2; + var r = b2Math.SubtractVV(p1, p2); + r.Normalize(); + var v = b2Math.CrossFV(1.0, r); + var abs_v = b2Math.AbsV(v); + var maxFraction = input.maxFraction; + var segmentAABB = new b2AABB(); + var tX = 0; + var tY = 0; { + tX = p1.x + maxFraction * (p2.x - p1.x); + tY = p1.y + maxFraction * (p2.y - p1.y); + segmentAABB.lowerBound.x = Math.min(p1.x, tX); + segmentAABB.lowerBound.y = Math.min(p1.y, tY); + segmentAABB.upperBound.x = Math.max(p1.x, tX); + segmentAABB.upperBound.y = Math.max(p1.y, tY); + } + var stack = new Vector(); + var count = 0; + stack[count++] = this.m_root; + while (count > 0) { + var node = stack[--count]; + if (node.aabb.TestOverlap(segmentAABB) == false) { + continue; + } + var c = node.aabb.GetCenter(); + var h = node.aabb.GetExtents(); + var separation = Math.abs(v.x * (p1.x - c.x) + v.y * (p1.y - c.y)) - abs_v.x * h.x - abs_v.y * h.y; + if (separation > 0.0) continue; + if (node.IsLeaf()) { + var subInput = new b2RayCastInput(); + subInput.p1 = input.p1; + subInput.p2 = input.p2; + subInput.maxFraction = input.maxFraction; + maxFraction = callback(subInput, node); + if (maxFraction == 0.0) return; + if (maxFraction > 0.0) { + tX = p1.x + maxFraction * (p2.x - p1.x); + tY = p1.y + maxFraction * (p2.y - p1.y); + segmentAABB.lowerBound.x = Math.min(p1.x, tX); + segmentAABB.lowerBound.y = Math.min(p1.y, tY); + segmentAABB.upperBound.x = Math.max(p1.x, tX); + segmentAABB.upperBound.y = Math.max(p1.y, tY); + } + } + else { + stack[count++] = node.child1; + stack[count++] = node.child2; + } + } + } + b2DynamicTree.prototype.AllocateNode = function () { + if (this.m_freeList) { + var node = this.m_freeList; + this.m_freeList = node.parent; + node.parent = null; + node.child1 = null; + node.child2 = null; + return node; + } + return new b2DynamicTreeNode(); + } + b2DynamicTree.prototype.FreeNode = function (node) { + node.parent = this.m_freeList; + this.m_freeList = node; + } + b2DynamicTree.prototype.InsertLeaf = function (leaf) { + ++this.m_insertionCount; + if (this.m_root == null) { + this.m_root = leaf; + this.m_root.parent = null; + return; + } + var center = leaf.aabb.GetCenter(); + var sibling = this.m_root; + if (sibling.IsLeaf() == false) { + do { + var child1 = sibling.child1; + var child2 = sibling.child2; + var norm1 = Math.abs((child1.aabb.lowerBound.x + child1.aabb.upperBound.x) / 2 - center.x) + Math.abs((child1.aabb.lowerBound.y + child1.aabb.upperBound.y) / 2 - center.y); + var norm2 = Math.abs((child2.aabb.lowerBound.x + child2.aabb.upperBound.x) / 2 - center.x) + Math.abs((child2.aabb.lowerBound.y + child2.aabb.upperBound.y) / 2 - center.y); + if (norm1 < norm2) { + sibling = child1; + } + else { + sibling = child2; + } + } + while (sibling.IsLeaf() == false) + } + var node1 = sibling.parent; + var node2 = this.AllocateNode(); + node2.parent = node1; + node2.userData = null; + node2.aabb.Combine(leaf.aabb, sibling.aabb); + if (node1) { + if (sibling.parent.child1 == sibling) { + node1.child1 = node2; + } + else { + node1.child2 = node2; + } + node2.child1 = sibling; + node2.child2 = leaf; + sibling.parent = node2; + leaf.parent = node2; + do { + if (node1.aabb.Contains(node2.aabb)) break; + node1.aabb.Combine(node1.child1.aabb, node1.child2.aabb); + node2 = node1; + node1 = node1.parent; + } + while (node1) + } + else { + node2.child1 = sibling; + node2.child2 = leaf; + sibling.parent = node2; + leaf.parent = node2; + this.m_root = node2; + } + } + b2DynamicTree.prototype.RemoveLeaf = function (leaf) { + if (leaf == this.m_root) { + this.m_root = null; + return; + } + var node2 = leaf.parent; + var node1 = node2.parent; + var sibling; + if (node2.child1 == leaf) { + sibling = node2.child2; + } + else { + sibling = node2.child1; + } + if (node1) { + if (node1.child1 == node2) { + node1.child1 = sibling; + } + else { + node1.child2 = sibling; + } + sibling.parent = node1; + this.FreeNode(node2); + while (node1) { + var oldAABB = node1.aabb; + node1.aabb = b2AABB.Combine(node1.child1.aabb, node1.child2.aabb); + if (oldAABB.Contains(node1.aabb)) break; + node1 = node1.parent; + } + } + else { + this.m_root = sibling; + sibling.parent = null; + this.FreeNode(node2); + } + } + b2DynamicTreeBroadPhase.b2DynamicTreeBroadPhase = function () { + this.m_tree = new b2DynamicTree(); + this.m_moveBuffer = new Vector(); + this.m_pairBuffer = new Vector(); + this.m_pairCount = 0; + }; + b2DynamicTreeBroadPhase.prototype.CreateProxy = function (aabb, userData) { + var proxy = this.m_tree.CreateProxy(aabb, userData); + ++this.m_proxyCount; + this.BufferMove(proxy); + return proxy; + } + b2DynamicTreeBroadPhase.prototype.DestroyProxy = function (proxy) { + this.UnBufferMove(proxy); + --this.m_proxyCount; + this.m_tree.DestroyProxy(proxy); + } + b2DynamicTreeBroadPhase.prototype.MoveProxy = function (proxy, aabb, displacement) { + var buffer = this.m_tree.MoveProxy(proxy, aabb, displacement); + if (buffer) { + this.BufferMove(proxy); + } + } + b2DynamicTreeBroadPhase.prototype.TestOverlap = function (proxyA, proxyB) { + var aabbA = this.m_tree.GetFatAABB(proxyA); + var aabbB = this.m_tree.GetFatAABB(proxyB); + return aabbA.TestOverlap(aabbB); + } + b2DynamicTreeBroadPhase.prototype.GetUserData = function (proxy) { + return this.m_tree.GetUserData(proxy); + } + b2DynamicTreeBroadPhase.prototype.GetFatAABB = function (proxy) { + return this.m_tree.GetFatAABB(proxy); + } + b2DynamicTreeBroadPhase.prototype.GetProxyCount = function () { + return this.m_proxyCount; + } + b2DynamicTreeBroadPhase.prototype.UpdatePairs = function (callback) { + var __this = this; + __this.m_pairCount = 0; + var i = 0, + queryProxy; + for (i = 0; + i < __this.m_moveBuffer.length; ++i) { + queryProxy = __this.m_moveBuffer[i]; + + function QueryCallback(proxy) { + if (proxy == queryProxy) return true; + if (__this.m_pairCount == __this.m_pairBuffer.length) { + __this.m_pairBuffer[__this.m_pairCount] = new b2DynamicTreePair(); + } + var pair = __this.m_pairBuffer[__this.m_pairCount]; + pair.proxyA = proxy < queryProxy ? proxy : queryProxy; + pair.proxyB = proxy >= queryProxy ? proxy : queryProxy;++__this.m_pairCount; + return true; + }; + var fatAABB = __this.m_tree.GetFatAABB(queryProxy); + __this.m_tree.Query(QueryCallback, fatAABB); + } + __this.m_moveBuffer.length = 0; + for (var i = 0; i < __this.m_pairCount;) { + var primaryPair = __this.m_pairBuffer[i]; + var userDataA = __this.m_tree.GetUserData(primaryPair.proxyA); + var userDataB = __this.m_tree.GetUserData(primaryPair.proxyB); + callback(userDataA, userDataB); + ++i; + while (i < __this.m_pairCount) { + var pair = __this.m_pairBuffer[i]; + if (pair.proxyA != primaryPair.proxyA || pair.proxyB != primaryPair.proxyB) { + break; + }++i; + } + } + } + b2DynamicTreeBroadPhase.prototype.Query = function (callback, aabb) { + this.m_tree.Query(callback, aabb); + } + b2DynamicTreeBroadPhase.prototype.RayCast = function (callback, input) { + this.m_tree.RayCast(callback, input); + } + b2DynamicTreeBroadPhase.prototype.Validate = function () {} + b2DynamicTreeBroadPhase.prototype.Rebalance = function (iterations) { + if (iterations === undefined) iterations = 0; + this.m_tree.Rebalance(iterations); + } + b2DynamicTreeBroadPhase.prototype.BufferMove = function (proxy) { + this.m_moveBuffer[this.m_moveBuffer.length] = proxy; + } + b2DynamicTreeBroadPhase.prototype.UnBufferMove = function (proxy) { + var i = parseInt(this.m_moveBuffer.indexOf(proxy)); + this.m_moveBuffer.splice(i, 1); + } + b2DynamicTreeBroadPhase.prototype.ComparePairs = function (pair1, pair2) { + return 0; + } + b2DynamicTreeBroadPhase.__implements = {}; + b2DynamicTreeBroadPhase.__implements[IBroadPhase] = true; + b2DynamicTreeNode.b2DynamicTreeNode = function () { + this.aabb = new b2AABB(); + }; + b2DynamicTreeNode.prototype.IsLeaf = function () { + return this.child1 == null; + } + b2DynamicTreePair.b2DynamicTreePair = function () {}; + b2Manifold.b2Manifold = function () { + this.m_pointCount = 0; + }; + b2Manifold.prototype.b2Manifold = function () { + this.m_points = new Vector(b2Settings.b2_maxManifoldPoints); + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { + this.m_points[i] = new b2ManifoldPoint(); + } + this.m_localPlaneNormal = new b2Vec2(); + this.m_localPoint = new b2Vec2(); + } + b2Manifold.prototype.Reset = function () { + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { + ((this.m_points[i] instanceof b2ManifoldPoint ? this.m_points[i] : null)).Reset(); + } + this.m_localPlaneNormal.SetZero(); + this.m_localPoint.SetZero(); + this.m_type = 0; + this.m_pointCount = 0; + } + b2Manifold.prototype.Set = function (m) { + this.m_pointCount = m.m_pointCount; + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { + ((this.m_points[i] instanceof b2ManifoldPoint ? this.m_points[i] : null)).Set(m.m_points[i]); + } + this.m_localPlaneNormal.SetV(m.m_localPlaneNormal); + this.m_localPoint.SetV(m.m_localPoint); + this.m_type = m.m_type; + } + b2Manifold.prototype.Copy = function () { + var copy = new b2Manifold(); + copy.Set(this); + return copy; + } + Box2D.postDefs.push(function () { + Box2D.Collision.b2Manifold.e_circles = 0x0001; + Box2D.Collision.b2Manifold.e_faceA = 0x0002; + Box2D.Collision.b2Manifold.e_faceB = 0x0004; + }); + b2ManifoldPoint.b2ManifoldPoint = function () { + this.m_localPoint = new b2Vec2(); + this.m_id = new b2ContactID(); + }; + b2ManifoldPoint.prototype.b2ManifoldPoint = function () { + this.Reset(); + } + b2ManifoldPoint.prototype.Reset = function () { + this.m_localPoint.SetZero(); + this.m_normalImpulse = 0.0; + this.m_tangentImpulse = 0.0; + this.m_id.key = 0; + } + b2ManifoldPoint.prototype.Set = function (m) { + this.m_localPoint.SetV(m.m_localPoint); + this.m_normalImpulse = m.m_normalImpulse; + this.m_tangentImpulse = m.m_tangentImpulse; + this.m_id.Set(m.m_id); + } + b2Point.b2Point = function () { + this.p = new b2Vec2(); + }; + b2Point.prototype.Support = function (xf, vX, vY) { + if (vX === undefined) vX = 0; + if (vY === undefined) vY = 0; + return this.p; + } + b2Point.prototype.GetFirstVertex = function (xf) { + return this.p; + } + b2RayCastInput.b2RayCastInput = function () { + this.p1 = new b2Vec2(); + this.p2 = new b2Vec2(); + }; + b2RayCastInput.prototype.b2RayCastInput = function (p1, p2, maxFraction) { + if (p1 === undefined) p1 = null; + if (p2 === undefined) p2 = null; + if (maxFraction === undefined) maxFraction = 1; + if (p1) this.p1.SetV(p1); + if (p2) this.p2.SetV(p2); + this.maxFraction = maxFraction; + } + b2RayCastOutput.b2RayCastOutput = function () { + this.normal = new b2Vec2(); + }; + b2Segment.b2Segment = function () { + this.p1 = new b2Vec2(); + this.p2 = new b2Vec2(); + }; + b2Segment.prototype.TestSegment = function (lambda, normal, segment, maxLambda) { + if (maxLambda === undefined) maxLambda = 0; + var s = segment.p1; + var rX = segment.p2.x - s.x; + var rY = segment.p2.y - s.y; + var dX = this.p2.x - this.p1.x; + var dY = this.p2.y - this.p1.y; + var nX = dY; + var nY = (-dX); + var k_slop = 100.0 * Number.MIN_VALUE; + var denom = (-(rX * nX + rY * nY)); + if (denom > k_slop) { + var bX = s.x - this.p1.x; + var bY = s.y - this.p1.y; + var a = (bX * nX + bY * nY); + if (0.0 <= a && a <= maxLambda * denom) { + var mu2 = (-rX * bY) + rY * bX; + if ((-k_slop * denom) <= mu2 && mu2 <= denom * (1.0 + k_slop)) { + a /= denom; + var nLen = Math.sqrt(nX * nX + nY * nY); + nX /= nLen; + nY /= nLen; + lambda[0] = a; + normal.Set(nX, nY); + return true; + } + } + } + return false; + } + b2Segment.prototype.Extend = function (aabb) { + this.ExtendForward(aabb); + this.ExtendBackward(aabb); + } + + + + + b2Segment.prototype.ExtendForward = function (aabb) { + var dX = this.p2.x - this.p1.x; + var dY = this.p2.y - this.p1.y; + var lambda = Math.min(dX > 0 ? (aabb.upperBound.x - this.p1.x) / dX : dX < 0 ? (aabb.lowerBound.x - this.p1.x) / dX : Number.POSITIVE_INFINITY, + dY > 0 ? (aabb.upperBound.y - this.p1.y) / dY : dY < 0 ? (aabb.lowerBound.y - this.p1.y) / dY : Number.POSITIVE_INFINITY); + this.p2.x = this.p1.x + dX * lambda; + this.p2.y = this.p1.y + dY * lambda; + } + b2Segment.prototype.ExtendBackward = function (aabb) { + var dX = (-this.p2.x) + this.p1.x; + var dY = (-this.p2.y) + this.p1.y; + var lambda = Math.min(dX > 0 ? (aabb.upperBound.x - this.p2.x) / dX : dX < 0 ? (aabb.lowerBound.x - this.p2.x) / dX : Number.POSITIVE_INFINITY, + dY > 0 ? (aabb.upperBound.y - this.p2.y) / dY : dY < 0 ? (aabb.lowerBound.y - this.p2.y) / dY : Number.POSITIVE_INFINITY); + this.p1.x = this.p2.x + dX * lambda; + this.p1.y = this.p2.y + dY * lambda; + } + b2SeparationFunction.b2SeparationFunction = function () { + this.m_localPoint = new b2Vec2(); + this.m_axis = new b2Vec2(); + }; + b2SeparationFunction.prototype.Initialize = function (cache, proxyA, transformA, proxyB, transformB) { + this.m_proxyA = proxyA; + this.m_proxyB = proxyB; + var count = parseInt(cache.count); + b2Settings.b2Assert(0 < count && count < 3); + var localPointA; + var localPointA1; + var localPointA2; + var localPointB; + var localPointB1; + var localPointB2; + var pointAX = 0; + var pointAY = 0; + var pointBX = 0; + var pointBY = 0; + var normalX = 0; + var normalY = 0; + var tMat; + var tVec; + var s = 0; + var sgn = 0; + if (count == 1) { + this.m_type = b2SeparationFunction.e_points; + localPointA = this.m_proxyA.GetVertex(cache.indexA[0]); + localPointB = this.m_proxyB.GetVertex(cache.indexB[0]); + tVec = localPointA; + tMat = transformA.R; + pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tVec = localPointB; + tMat = transformB.R; + pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + this.m_axis.x = pointBX - pointAX; + this.m_axis.y = pointBY - pointAY; + this.m_axis.Normalize(); + } + else if (cache.indexB[0] == cache.indexB[1]) { + this.m_type = b2SeparationFunction.e_faceA; + localPointA1 = this.m_proxyA.GetVertex(cache.indexA[0]); + localPointA2 = this.m_proxyA.GetVertex(cache.indexA[1]); + localPointB = this.m_proxyB.GetVertex(cache.indexB[0]); + this.m_localPoint.x = 0.5 * (localPointA1.x + localPointA2.x); + this.m_localPoint.y = 0.5 * (localPointA1.y + localPointA2.y); + this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointA2, localPointA1), 1.0); + this.m_axis.Normalize(); + tVec = this.m_axis; + tMat = transformA.R; + normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tVec = this.m_localPoint; + tMat = transformA.R; + pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tVec = localPointB; + tMat = transformB.R; + pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + s = (pointBX - pointAX) * normalX + (pointBY - pointAY) * normalY; + if (s < 0.0) { + this.m_axis.NegativeSelf(); + } + } + else if (cache.indexA[0] == cache.indexA[0]) { + this.m_type = b2SeparationFunction.e_faceB; + localPointB1 = this.m_proxyB.GetVertex(cache.indexB[0]); + localPointB2 = this.m_proxyB.GetVertex(cache.indexB[1]); + localPointA = this.m_proxyA.GetVertex(cache.indexA[0]); + this.m_localPoint.x = 0.5 * (localPointB1.x + localPointB2.x); + this.m_localPoint.y = 0.5 * (localPointB1.y + localPointB2.y); + this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointB2, localPointB1), 1.0); + this.m_axis.Normalize(); + tVec = this.m_axis; + tMat = transformB.R; + normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tVec = this.m_localPoint; + tMat = transformB.R; + pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tVec = localPointA; + tMat = transformA.R; + pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + s = (pointAX - pointBX) * normalX + (pointAY - pointBY) * normalY; + if (s < 0.0) { + this.m_axis.NegativeSelf(); + } + } + else { + localPointA1 = this.m_proxyA.GetVertex(cache.indexA[0]); + localPointA2 = this.m_proxyA.GetVertex(cache.indexA[1]); + localPointB1 = this.m_proxyB.GetVertex(cache.indexB[0]); + localPointB2 = this.m_proxyB.GetVertex(cache.indexB[1]); + var pA = b2Math.MulX(transformA, localPointA); + var dA = b2Math.MulMV(transformA.R, b2Math.SubtractVV(localPointA2, localPointA1)); + var pB = b2Math.MulX(transformB, localPointB); + var dB = b2Math.MulMV(transformB.R, b2Math.SubtractVV(localPointB2, localPointB1)); + var a = dA.x * dA.x + dA.y * dA.y; + var e = dB.x * dB.x + dB.y * dB.y; + var r = b2Math.SubtractVV(dB, dA); + var c = dA.x * r.x + dA.y * r.y; + var f = dB.x * r.x + dB.y * r.y; + var b = dA.x * dB.x + dA.y * dB.y; + var denom = a * e - b * b; + s = 0.0; + if (denom != 0.0) { + s = b2Math.Clamp((b * f - c * e) / denom, 0.0, 1.0); + } + var t = (b * s + f) / e; + if (t < 0.0) { + t = 0.0; + s = b2Math.Clamp((b - c) / a, 0.0, 1.0); + } + localPointA = new b2Vec2(); + localPointA.x = localPointA1.x + s * (localPointA2.x - localPointA1.x); + localPointA.y = localPointA1.y + s * (localPointA2.y - localPointA1.y); + localPointB = new b2Vec2(); + localPointB.x = localPointB1.x + s * (localPointB2.x - localPointB1.x); + localPointB.y = localPointB1.y + s * (localPointB2.y - localPointB1.y); + if (s == 0.0 || s == 1.0) { + this.m_type = b2SeparationFunction.e_faceB; + this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointB2, localPointB1), 1.0); + this.m_axis.Normalize(); + this.m_localPoint = localPointB; + tVec = this.m_axis; + tMat = transformB.R; + normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tVec = this.m_localPoint; + tMat = transformB.R; + pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tVec = localPointA; + tMat = transformA.R; + pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + sgn = (pointAX - pointBX) * normalX + (pointAY - pointBY) * normalY; + if (s < 0.0) { + this.m_axis.NegativeSelf(); + } + } + else { + this.m_type = b2SeparationFunction.e_faceA; + this.m_axis = b2Math.CrossVF(b2Math.SubtractVV(localPointA2, localPointA1), 1.0); + this.m_localPoint = localPointA; + tVec = this.m_axis; + tMat = transformA.R; + normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tVec = this.m_localPoint; + tMat = transformA.R; + pointAX = transformA.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointAY = transformA.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tVec = localPointB; + tMat = transformB.R; + pointBX = transformB.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + pointBY = transformB.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + sgn = (pointBX - pointAX) * normalX + (pointBY - pointAY) * normalY; + if (s < 0.0) { + this.m_axis.NegativeSelf(); + } + } + } + } + b2SeparationFunction.prototype.Evaluate = function (transformA, transformB) { + var axisA; + var axisB; + var localPointA; + var localPointB; + var pointA; + var pointB; + var seperation = 0; + var normal; + switch (this.m_type) { + case b2SeparationFunction.e_points: + { + axisA = b2Math.MulTMV(transformA.R, this.m_axis); + axisB = b2Math.MulTMV(transformB.R, this.m_axis.GetNegative()); + localPointA = this.m_proxyA.GetSupportVertex(axisA); + localPointB = this.m_proxyB.GetSupportVertex(axisB); + pointA = b2Math.MulX(transformA, localPointA); + pointB = b2Math.MulX(transformB, localPointB); + seperation = (pointB.x - pointA.x) * this.m_axis.x + (pointB.y - pointA.y) * this.m_axis.y; + return seperation; + } + case b2SeparationFunction.e_faceA: + { + normal = b2Math.MulMV(transformA.R, this.m_axis); + pointA = b2Math.MulX(transformA, this.m_localPoint); + axisB = b2Math.MulTMV(transformB.R, normal.GetNegative()); + localPointB = this.m_proxyB.GetSupportVertex(axisB); + pointB = b2Math.MulX(transformB, localPointB); + seperation = (pointB.x - pointA.x) * normal.x + (pointB.y - pointA.y) * normal.y; + return seperation; + } + case b2SeparationFunction.e_faceB: + { + normal = b2Math.MulMV(transformB.R, this.m_axis); + pointB = b2Math.MulX(transformB, this.m_localPoint); + axisA = b2Math.MulTMV(transformA.R, normal.GetNegative()); + localPointA = this.m_proxyA.GetSupportVertex(axisA); + pointA = b2Math.MulX(transformA, localPointA); + seperation = (pointA.x - pointB.x) * normal.x + (pointA.y - pointB.y) * normal.y; + return seperation; + } + default: + b2Settings.b2Assert(false); + return 0.0; + } + } + Box2D.postDefs.push(function () { + Box2D.Collision.b2SeparationFunction.e_points = 0x01; + Box2D.Collision.b2SeparationFunction.e_faceA = 0x02; + Box2D.Collision.b2SeparationFunction.e_faceB = 0x04; + }); + b2Simplex.b2Simplex = function () { + this.m_v1 = new b2SimplexVertex(); + this.m_v2 = new b2SimplexVertex(); + this.m_v3 = new b2SimplexVertex(); + this.m_vertices = new Vector(3); + }; + b2Simplex.prototype.b2Simplex = function () { + this.m_vertices[0] = this.m_v1; + this.m_vertices[1] = this.m_v2; + this.m_vertices[2] = this.m_v3; + } + b2Simplex.prototype.ReadCache = function (cache, proxyA, transformA, proxyB, transformB) { + b2Settings.b2Assert(0 <= cache.count && cache.count <= 3); + var wALocal; + var wBLocal; + this.m_count = cache.count; + var vertices = this.m_vertices; + for (var i = 0; i < this.m_count; i++) { + var v = vertices[i]; + v.indexA = cache.indexA[i]; + v.indexB = cache.indexB[i]; + wALocal = proxyA.GetVertex(v.indexA); + wBLocal = proxyB.GetVertex(v.indexB); + v.wA = b2Math.MulX(transformA, wALocal); + v.wB = b2Math.MulX(transformB, wBLocal); + v.w = b2Math.SubtractVV(v.wB, v.wA); + v.a = 0; + } + if (this.m_count > 1) { + var metric1 = cache.metric; + var metric2 = this.GetMetric(); + if (metric2 < .5 * metric1 || 2.0 * metric1 < metric2 || metric2 < Number.MIN_VALUE) { + this.m_count = 0; + } + } + if (this.m_count == 0) { + v = vertices[0]; + v.indexA = 0; + v.indexB = 0; + wALocal = proxyA.GetVertex(0); + wBLocal = proxyB.GetVertex(0); + v.wA = b2Math.MulX(transformA, wALocal); + v.wB = b2Math.MulX(transformB, wBLocal); + v.w = b2Math.SubtractVV(v.wB, v.wA); + this.m_count = 1; + } + } + b2Simplex.prototype.WriteCache = function (cache) { + cache.metric = this.GetMetric(); + cache.count = Box2D.parseUInt(this.m_count); + var vertices = this.m_vertices; + for (var i = 0; i < this.m_count; i++) { + cache.indexA[i] = Box2D.parseUInt(vertices[i].indexA); + cache.indexB[i] = Box2D.parseUInt(vertices[i].indexB); + } + } + b2Simplex.prototype.GetSearchDirection = function () { + switch (this.m_count) { + case 1: + return this.m_v1.w.GetNegative(); + case 2: + { + var e12 = b2Math.SubtractVV(this.m_v2.w, this.m_v1.w); + var sgn = b2Math.CrossVV(e12, this.m_v1.w.GetNegative()); + if (sgn > 0.0) { + return b2Math.CrossFV(1.0, e12); + } + else { + return b2Math.CrossVF(e12, 1.0); + } + } + default: + b2Settings.b2Assert(false); + return new b2Vec2(); + } + } + b2Simplex.prototype.GetClosestPoint = function () { + switch (this.m_count) { + case 0: + b2Settings.b2Assert(false); + return new b2Vec2(); + case 1: + return this.m_v1.w; + case 2: + return new b2Vec2(this.m_v1.a * this.m_v1.w.x + this.m_v2.a * this.m_v2.w.x, this.m_v1.a * this.m_v1.w.y + this.m_v2.a * this.m_v2.w.y); + default: + b2Settings.b2Assert(false); + return new b2Vec2(); + } + } + b2Simplex.prototype.GetWitnessPoints = function (pA, pB) { + switch (this.m_count) { + case 0: + b2Settings.b2Assert(false); + break; + case 1: + pA.SetV(this.m_v1.wA); + pB.SetV(this.m_v1.wB); + break; + case 2: + pA.x = this.m_v1.a * this.m_v1.wA.x + this.m_v2.a * this.m_v2.wA.x; + pA.y = this.m_v1.a * this.m_v1.wA.y + this.m_v2.a * this.m_v2.wA.y; + pB.x = this.m_v1.a * this.m_v1.wB.x + this.m_v2.a * this.m_v2.wB.x; + pB.y = this.m_v1.a * this.m_v1.wB.y + this.m_v2.a * this.m_v2.wB.y; + break; + case 3: + pB.x = pA.x = this.m_v1.a * this.m_v1.wA.x + this.m_v2.a * this.m_v2.wA.x + this.m_v3.a * this.m_v3.wA.x; + pB.y = pA.y = this.m_v1.a * this.m_v1.wA.y + this.m_v2.a * this.m_v2.wA.y + this.m_v3.a * this.m_v3.wA.y; + break; + default: + b2Settings.b2Assert(false); + break; + } + } + b2Simplex.prototype.GetMetric = function () { + switch (this.m_count) { + case 0: + b2Settings.b2Assert(false); + return 0.0; + case 1: + return 0.0; + case 2: + return b2Math.SubtractVV(this.m_v1.w, this.m_v2.w).Length(); + case 3: + return b2Math.CrossVV(b2Math.SubtractVV(this.m_v2.w, this.m_v1.w), b2Math.SubtractVV(this.m_v3.w, this.m_v1.w)); + default: + b2Settings.b2Assert(false); + return 0.0; + } + } + b2Simplex.prototype.Solve2 = function () { + var w1 = this.m_v1.w; + var w2 = this.m_v2.w; + var e12 = b2Math.SubtractVV(w2, w1); + var d12_2 = (-(w1.x * e12.x + w1.y * e12.y)); + if (d12_2 <= 0.0) { + this.m_v1.a = 1.0; + this.m_count = 1; + return; + } + var d12_1 = (w2.x * e12.x + w2.y * e12.y); + if (d12_1 <= 0.0) { + this.m_v2.a = 1.0; + this.m_count = 1; + this.m_v1.Set(this.m_v2); + return; + } + var inv_d12 = 1.0 / (d12_1 + d12_2); + this.m_v1.a = d12_1 * inv_d12; + this.m_v2.a = d12_2 * inv_d12; + this.m_count = 2; + } + b2Simplex.prototype.Solve3 = function () { + var w1 = this.m_v1.w; + var w2 = this.m_v2.w; + var w3 = this.m_v3.w; + var e12 = b2Math.SubtractVV(w2, w1); + var w1e12 = b2Math.Dot(w1, e12); + var w2e12 = b2Math.Dot(w2, e12); + var d12_1 = w2e12; + var d12_2 = (-w1e12); + var e13 = b2Math.SubtractVV(w3, w1); + var w1e13 = b2Math.Dot(w1, e13); + var w3e13 = b2Math.Dot(w3, e13); + var d13_1 = w3e13; + var d13_2 = (-w1e13); + var e23 = b2Math.SubtractVV(w3, w2); + var w2e23 = b2Math.Dot(w2, e23); + var w3e23 = b2Math.Dot(w3, e23); + var d23_1 = w3e23; + var d23_2 = (-w2e23); + var n123 = b2Math.CrossVV(e12, e13); + var d123_1 = n123 * b2Math.CrossVV(w2, w3); + var d123_2 = n123 * b2Math.CrossVV(w3, w1); + var d123_3 = n123 * b2Math.CrossVV(w1, w2); + if (d12_2 <= 0.0 && d13_2 <= 0.0) { + this.m_v1.a = 1.0; + this.m_count = 1; + return; + } + if (d12_1 > 0.0 && d12_2 > 0.0 && d123_3 <= 0.0) { + var inv_d12 = 1.0 / (d12_1 + d12_2); + this.m_v1.a = d12_1 * inv_d12; + this.m_v2.a = d12_2 * inv_d12; + this.m_count = 2; + return; + } + if (d13_1 > 0.0 && d13_2 > 0.0 && d123_2 <= 0.0) { + var inv_d13 = 1.0 / (d13_1 + d13_2); + this.m_v1.a = d13_1 * inv_d13; + this.m_v3.a = d13_2 * inv_d13; + this.m_count = 2; + this.m_v2.Set(this.m_v3); + return; + } + if (d12_1 <= 0.0 && d23_2 <= 0.0) { + this.m_v2.a = 1.0; + this.m_count = 1; + this.m_v1.Set(this.m_v2); + return; + } + if (d13_1 <= 0.0 && d23_1 <= 0.0) { + this.m_v3.a = 1.0; + this.m_count = 1; + this.m_v1.Set(this.m_v3); + return; + } + if (d23_1 > 0.0 && d23_2 > 0.0 && d123_1 <= 0.0) { + var inv_d23 = 1.0 / (d23_1 + d23_2); + this.m_v2.a = d23_1 * inv_d23; + this.m_v3.a = d23_2 * inv_d23; + this.m_count = 2; + this.m_v1.Set(this.m_v3); + return; + } + var inv_d123 = 1.0 / (d123_1 + d123_2 + d123_3); + this.m_v1.a = d123_1 * inv_d123; + this.m_v2.a = d123_2 * inv_d123; + this.m_v3.a = d123_3 * inv_d123; + this.m_count = 3; + } + b2SimplexCache.b2SimplexCache = function () { + this.indexA = new Vector_a2j_Number(3); + this.indexB = new Vector_a2j_Number(3); + }; + b2SimplexVertex.b2SimplexVertex = function () {}; + b2SimplexVertex.prototype.Set = function (other) { + this.wA.SetV(other.wA); + this.wB.SetV(other.wB); + this.w.SetV(other.w); + this.a = other.a; + this.indexA = other.indexA; + this.indexB = other.indexB; + } + b2TimeOfImpact.b2TimeOfImpact = function () {}; + b2TimeOfImpact.TimeOfImpact = function (input) { + ++b2TimeOfImpact.b2_toiCalls; + var proxyA = input.proxyA; + var proxyB = input.proxyB; + var sweepA = input.sweepA; + var sweepB = input.sweepB; + b2Settings.b2Assert(sweepA.t0 == sweepB.t0); + b2Settings.b2Assert(1.0 - sweepA.t0 > Number.MIN_VALUE); + var radius = proxyA.m_radius + proxyB.m_radius; + var tolerance = input.tolerance; + var alpha = 0.0; + var k_maxIterations = 1000; + var iter = 0; + var target = 0.0; + b2TimeOfImpact.s_cache.count = 0; + b2TimeOfImpact.s_distanceInput.useRadii = false; + for (;;) { + sweepA.GetTransform(b2TimeOfImpact.s_xfA, alpha); + sweepB.GetTransform(b2TimeOfImpact.s_xfB, alpha); + b2TimeOfImpact.s_distanceInput.proxyA = proxyA; + b2TimeOfImpact.s_distanceInput.proxyB = proxyB; + b2TimeOfImpact.s_distanceInput.transformA = b2TimeOfImpact.s_xfA; + b2TimeOfImpact.s_distanceInput.transformB = b2TimeOfImpact.s_xfB; + b2Distance.Distance(b2TimeOfImpact.s_distanceOutput, b2TimeOfImpact.s_cache, b2TimeOfImpact.s_distanceInput); + if (b2TimeOfImpact.s_distanceOutput.distance <= 0.0) { + alpha = 1.0; + break; + } + b2TimeOfImpact.s_fcn.Initialize(b2TimeOfImpact.s_cache, proxyA, b2TimeOfImpact.s_xfA, proxyB, b2TimeOfImpact.s_xfB); + var separation = b2TimeOfImpact.s_fcn.Evaluate(b2TimeOfImpact.s_xfA, b2TimeOfImpact.s_xfB); + if (separation <= 0.0) { + alpha = 1.0; + break; + } + if (iter == 0) { + if (separation > radius) { + target = b2Math.Max(radius - tolerance, 0.75 * radius); + } + else { + target = b2Math.Max(separation - tolerance, 0.02 * radius); + } + } + if (separation - target < 0.5 * tolerance) { + if (iter == 0) { + alpha = 1.0; + break; + } + break; + } + var newAlpha = alpha; { + var x1 = alpha; + var x2 = 1.0; + var f1 = separation; + sweepA.GetTransform(b2TimeOfImpact.s_xfA, x2); + sweepB.GetTransform(b2TimeOfImpact.s_xfB, x2); + var f2 = b2TimeOfImpact.s_fcn.Evaluate(b2TimeOfImpact.s_xfA, b2TimeOfImpact.s_xfB); + if (f2 >= target) { + alpha = 1.0; + break; + } + var rootIterCount = 0; + for (;;) { + var x = 0; + if (rootIterCount & 1) { + x = x1 + (target - f1) * (x2 - x1) / (f2 - f1); + } + else { + x = 0.5 * (x1 + x2); + } + sweepA.GetTransform(b2TimeOfImpact.s_xfA, x); + sweepB.GetTransform(b2TimeOfImpact.s_xfB, x); + var f = b2TimeOfImpact.s_fcn.Evaluate(b2TimeOfImpact.s_xfA, b2TimeOfImpact.s_xfB); + if (b2Math.Abs(f - target) < 0.025 * tolerance) { + newAlpha = x; + break; + } + if (f > target) { + x1 = x; + f1 = f; + } + else { + x2 = x; + f2 = f; + }++rootIterCount; + ++b2TimeOfImpact.b2_toiRootIters; + if (rootIterCount == 50) { + break; + } + } + b2TimeOfImpact.b2_toiMaxRootIters = b2Math.Max(b2TimeOfImpact.b2_toiMaxRootIters, rootIterCount); + } + if (newAlpha < (1.0 + 100.0 * Number.MIN_VALUE) * alpha) { + break; + } + alpha = newAlpha; + iter++; + ++b2TimeOfImpact.b2_toiIters; + if (iter == k_maxIterations) { + break; + } + } + b2TimeOfImpact.b2_toiMaxIters = b2Math.Max(b2TimeOfImpact.b2_toiMaxIters, iter); + return alpha; + } + Box2D.postDefs.push(function () { + Box2D.Collision.b2TimeOfImpact.b2_toiCalls = 0; + Box2D.Collision.b2TimeOfImpact.b2_toiIters = 0; + Box2D.Collision.b2TimeOfImpact.b2_toiMaxIters = 0; + Box2D.Collision.b2TimeOfImpact.b2_toiRootIters = 0; + Box2D.Collision.b2TimeOfImpact.b2_toiMaxRootIters = 0; + Box2D.Collision.b2TimeOfImpact.s_cache = new b2SimplexCache(); + Box2D.Collision.b2TimeOfImpact.s_distanceInput = new b2DistanceInput(); + Box2D.Collision.b2TimeOfImpact.s_xfA = new b2Transform(); + Box2D.Collision.b2TimeOfImpact.s_xfB = new b2Transform(); + Box2D.Collision.b2TimeOfImpact.s_fcn = new b2SeparationFunction(); + Box2D.Collision.b2TimeOfImpact.s_distanceOutput = new b2DistanceOutput(); + }); + b2TOIInput.b2TOIInput = function () { + this.proxyA = new b2DistanceProxy(); + this.proxyB = new b2DistanceProxy(); + this.sweepA = new b2Sweep(); + this.sweepB = new b2Sweep(); + }; + b2WorldManifold.b2WorldManifold = function () { + this.m_normal = new b2Vec2(); + }; + b2WorldManifold.prototype.b2WorldManifold = function () { + this.m_points = new Vector(b2Settings.b2_maxManifoldPoints); + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { + this.m_points[i] = new b2Vec2(); + } + } + b2WorldManifold.prototype.Initialize = function (manifold, xfA, radiusA, xfB, radiusB) { + if (radiusA === undefined) radiusA = 0; + if (radiusB === undefined) radiusB = 0; + if (manifold.m_pointCount == 0) { + return; + } + var i = 0; + var tVec; + var tMat; + var normalX = 0; + var normalY = 0; + var planePointX = 0; + var planePointY = 0; + var clipPointX = 0; + var clipPointY = 0; + switch (manifold.m_type) { + case b2Manifold.e_circles: + { + tMat = xfA.R; + tVec = manifold.m_localPoint; + var pointAX = xfA.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + var pointAY = xfA.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tMat = xfB.R; + tVec = manifold.m_points[0].m_localPoint; + var pointBX = xfB.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + var pointBY = xfB.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + var dX = pointBX - pointAX; + var dY = pointBY - pointAY; + var d2 = dX * dX + dY * dY; + if (d2 > Number.MIN_VALUE * Number.MIN_VALUE) { + var d = Math.sqrt(d2); + this.m_normal.x = dX / d; + this.m_normal.y = dY / d; + } + else { + this.m_normal.x = 1; + this.m_normal.y = 0; + } + var cAX = pointAX + radiusA * this.m_normal.x; + var cAY = pointAY + radiusA * this.m_normal.y; + var cBX = pointBX - radiusB * this.m_normal.x; + var cBY = pointBY - radiusB * this.m_normal.y; + this.m_points[0].x = 0.5 * (cAX + cBX); + this.m_points[0].y = 0.5 * (cAY + cBY); + } + break; + case b2Manifold.e_faceA: + { + tMat = xfA.R; + tVec = manifold.m_localPlaneNormal; + normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tMat = xfA.R; + tVec = manifold.m_localPoint; + planePointX = xfA.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + planePointY = xfA.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + this.m_normal.x = normalX; + this.m_normal.y = normalY; + for (i = 0; + i < manifold.m_pointCount; i++) { + tMat = xfB.R; + tVec = manifold.m_points[i].m_localPoint; + clipPointX = xfB.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + clipPointY = xfB.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + this.m_points[i].x = clipPointX + 0.5 * (radiusA - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusB) * normalX; + this.m_points[i].y = clipPointY + 0.5 * (radiusA - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusB) * normalY; + } + } + break; + case b2Manifold.e_faceB: + { + tMat = xfB.R; + tVec = manifold.m_localPlaneNormal; + normalX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + normalY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tMat = xfB.R; + tVec = manifold.m_localPoint; + planePointX = xfB.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + planePointY = xfB.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + this.m_normal.x = (-normalX); + this.m_normal.y = (-normalY); + for (i = 0; + i < manifold.m_pointCount; i++) { + tMat = xfA.R; + tVec = manifold.m_points[i].m_localPoint; + clipPointX = xfA.position.x + tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + clipPointY = xfA.position.y + tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + this.m_points[i].x = clipPointX + 0.5 * (radiusB - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusA) * normalX; + this.m_points[i].y = clipPointY + 0.5 * (radiusB - (clipPointX - planePointX) * normalX - (clipPointY - planePointY) * normalY - radiusA) * normalY; + } + } + break; + } + } + ClipVertex.ClipVertex = function () { + this.v = new b2Vec2(); + this.id = new b2ContactID(); + }; + ClipVertex.prototype.Set = function (other) { + this.v.SetV(other.v); + this.id.Set(other.id); + } + Features.Features = function () {}; + Object.defineProperty(Features.prototype, 'referenceEdge', { + enumerable: false, + configurable: true, + get: function () { + return this._referenceEdge; + } + }); + Object.defineProperty(Features.prototype, 'referenceEdge', { + enumerable: false, + configurable: true, + set: function (value) { + if (value === undefined) value = 0; + this._referenceEdge = value; + this._m_id._key = (this._m_id._key & 0xffffff00) | (this._referenceEdge & 0x000000ff); + } + }); + Object.defineProperty(Features.prototype, 'incidentEdge', { + enumerable: false, + configurable: true, + get: function () { + return this._incidentEdge; + } + }); + Object.defineProperty(Features.prototype, 'incidentEdge', { + enumerable: false, + configurable: true, + set: function (value) { + if (value === undefined) value = 0; + this._incidentEdge = value; + this._m_id._key = (this._m_id._key & 0xffff00ff) | ((this._incidentEdge << 8) & 0x0000ff00); + } + }); + Object.defineProperty(Features.prototype, 'incidentVertex', { + enumerable: false, + configurable: true, + get: function () { + return this._incidentVertex; + } + }); + Object.defineProperty(Features.prototype, 'incidentVertex', { + enumerable: false, + configurable: true, + set: function (value) { + if (value === undefined) value = 0; + this._incidentVertex = value; + this._m_id._key = (this._m_id._key & 0xff00ffff) | ((this._incidentVertex << 16) & 0x00ff0000); + } + }); + Object.defineProperty(Features.prototype, 'flip', { + enumerable: false, + configurable: true, + get: function () { + return this._flip; + } + }); + Object.defineProperty(Features.prototype, 'flip', { + enumerable: false, + configurable: true, + set: function (value) { + if (value === undefined) value = 0; + this._flip = value; + this._m_id._key = (this._m_id._key & 0x00ffffff) | ((this._flip << 24) & 0xff000000); + } + }); +})(); +(function () { + var b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2CircleShape = Box2D.Collision.Shapes.b2CircleShape, + b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef, + b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape, + b2MassData = Box2D.Collision.Shapes.b2MassData, + b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape, + b2Shape = Box2D.Collision.Shapes.b2Shape, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3, + b2Body = Box2D.Dynamics.b2Body, + b2BodyDef = Box2D.Dynamics.b2BodyDef, + b2ContactFilter = Box2D.Dynamics.b2ContactFilter, + b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse, + b2ContactListener = Box2D.Dynamics.b2ContactListener, + b2ContactManager = Box2D.Dynamics.b2ContactManager, + b2DebugDraw = Box2D.Dynamics.b2DebugDraw, + b2DestructionListener = Box2D.Dynamics.b2DestructionListener, + b2FilterData = Box2D.Dynamics.b2FilterData, + b2Fixture = Box2D.Dynamics.b2Fixture, + b2FixtureDef = Box2D.Dynamics.b2FixtureDef, + b2Island = Box2D.Dynamics.b2Island, + b2TimeStep = Box2D.Dynamics.b2TimeStep, + b2World = Box2D.Dynamics.b2World, + b2AABB = Box2D.Collision.b2AABB, + b2Bound = Box2D.Collision.b2Bound, + b2BoundValues = Box2D.Collision.b2BoundValues, + b2Collision = Box2D.Collision.b2Collision, + b2ContactID = Box2D.Collision.b2ContactID, + b2ContactPoint = Box2D.Collision.b2ContactPoint, + b2Distance = Box2D.Collision.b2Distance, + b2DistanceInput = Box2D.Collision.b2DistanceInput, + b2DistanceOutput = Box2D.Collision.b2DistanceOutput, + b2DistanceProxy = Box2D.Collision.b2DistanceProxy, + b2DynamicTree = Box2D.Collision.b2DynamicTree, + b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase, + b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode, + b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair, + b2Manifold = Box2D.Collision.b2Manifold, + b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint, + b2Point = Box2D.Collision.b2Point, + b2RayCastInput = Box2D.Collision.b2RayCastInput, + b2RayCastOutput = Box2D.Collision.b2RayCastOutput, + b2Segment = Box2D.Collision.b2Segment, + b2SeparationFunction = Box2D.Collision.b2SeparationFunction, + b2Simplex = Box2D.Collision.b2Simplex, + b2SimplexCache = Box2D.Collision.b2SimplexCache, + b2SimplexVertex = Box2D.Collision.b2SimplexVertex, + b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact, + b2TOIInput = Box2D.Collision.b2TOIInput, + b2WorldManifold = Box2D.Collision.b2WorldManifold, + ClipVertex = Box2D.Collision.ClipVertex, + Features = Box2D.Collision.Features, + IBroadPhase = Box2D.Collision.IBroadPhase; + + Box2D.inherit(b2CircleShape, Box2D.Collision.Shapes.b2Shape); + b2CircleShape.prototype.__super = Box2D.Collision.Shapes.b2Shape.prototype; + b2CircleShape.b2CircleShape = function () { + Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this, arguments); + this.m_p = new b2Vec2(); + }; + b2CircleShape.prototype.Copy = function () { + var s = new b2CircleShape(); + s.Set(this); + return s; + } + b2CircleShape.prototype.Set = function (other) { + this.__super.Set.call(this, other); + if (Box2D.is(other, b2CircleShape)) { + var other2 = (other instanceof b2CircleShape ? other : null); + this.m_p.SetV(other2.m_p); + } + } + b2CircleShape.prototype.TestPoint = function (transform, p) { + var tMat = transform.R; + var dX = transform.position.x + (tMat.col1.x * this.m_p.x + tMat.col2.x * this.m_p.y); + var dY = transform.position.y + (tMat.col1.y * this.m_p.x + tMat.col2.y * this.m_p.y); + dX = p.x - dX; + dY = p.y - dY; + return (dX * dX + dY * dY) <= this.m_radius * this.m_radius; + } + b2CircleShape.prototype.RayCast = function (output, input, transform) { + var tMat = transform.R; + var positionX = transform.position.x + (tMat.col1.x * this.m_p.x + tMat.col2.x * this.m_p.y); + var positionY = transform.position.y + (tMat.col1.y * this.m_p.x + tMat.col2.y * this.m_p.y); + var sX = input.p1.x - positionX; + var sY = input.p1.y - positionY; + var b = (sX * sX + sY * sY) - this.m_radius * this.m_radius; + var rX = input.p2.x - input.p1.x; + var rY = input.p2.y - input.p1.y; + var c = (sX * rX + sY * rY); + var rr = (rX * rX + rY * rY); + var sigma = c * c - rr * b; + if (sigma < 0.0 || rr < Number.MIN_VALUE) { + return false; + } + var a = (-(c + Math.sqrt(sigma))); + if (0.0 <= a && a <= input.maxFraction * rr) { + a /= rr; + output.fraction = a; + output.normal.x = sX + a * rX; + output.normal.y = sY + a * rY; + output.normal.Normalize(); + return true; + } + return false; + } + b2CircleShape.prototype.ComputeAABB = function (aabb, transform) { + var tMat = transform.R; + var pX = transform.position.x + (tMat.col1.x * this.m_p.x + tMat.col2.x * this.m_p.y); + var pY = transform.position.y + (tMat.col1.y * this.m_p.x + tMat.col2.y * this.m_p.y); + aabb.lowerBound.Set(pX - this.m_radius, pY - this.m_radius); + aabb.upperBound.Set(pX + this.m_radius, pY + this.m_radius); + } + b2CircleShape.prototype.ComputeMass = function (massData, density) { + if (density === undefined) density = 0; + massData.mass = density * b2Settings.b2_pi * this.m_radius * this.m_radius; + massData.center.SetV(this.m_p); + massData.I = massData.mass * (0.5 * this.m_radius * this.m_radius + (this.m_p.x * this.m_p.x + this.m_p.y * this.m_p.y)); + } + b2CircleShape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) { + if (offset === undefined) offset = 0; + var p = b2Math.MulX(xf, this.m_p); + var l = (-(b2Math.Dot(normal, p) - offset)); + if (l < (-this.m_radius) + Number.MIN_VALUE) { + return 0; + } + if (l > this.m_radius) { + c.SetV(p); + return Math.PI * this.m_radius * this.m_radius; + } + var r2 = this.m_radius * this.m_radius; + var l2 = l * l; + var area = r2 * (Math.asin(l / this.m_radius) + Math.PI / 2) + l * Math.sqrt(r2 - l2); + var com = (-2 / 3 * Math.pow(r2 - l2, 1.5) / area); + c.x = p.x + normal.x * com; + c.y = p.y + normal.y * com; + return area; + } + b2CircleShape.prototype.GetLocalPosition = function () { + return this.m_p; + } + b2CircleShape.prototype.SetLocalPosition = function (position) { + this.m_p.SetV(position); + } + b2CircleShape.prototype.GetRadius = function () { + return this.m_radius; + } + b2CircleShape.prototype.SetRadius = function (radius) { + if (radius === undefined) radius = 0; + this.m_radius = radius; + } + b2CircleShape.prototype.b2CircleShape = function (radius) { + if (radius === undefined) radius = 0; + this.__super.b2Shape.call(this); + this.m_type = b2Shape.e_circleShape; + this.m_radius = radius; + } + b2EdgeChainDef.b2EdgeChainDef = function () {}; + b2EdgeChainDef.prototype.b2EdgeChainDef = function () { + this.vertexCount = 0; + this.isALoop = true; + this.vertices = []; + } + Box2D.inherit(b2EdgeShape, Box2D.Collision.Shapes.b2Shape); + b2EdgeShape.prototype.__super = Box2D.Collision.Shapes.b2Shape.prototype; + b2EdgeShape.b2EdgeShape = function () { + Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this, arguments); + this.s_supportVec = new b2Vec2(); + this.m_v1 = new b2Vec2(); + this.m_v2 = new b2Vec2(); + this.m_coreV1 = new b2Vec2(); + this.m_coreV2 = new b2Vec2(); + this.m_normal = new b2Vec2(); + this.m_direction = new b2Vec2(); + this.m_cornerDir1 = new b2Vec2(); + this.m_cornerDir2 = new b2Vec2(); + }; + b2EdgeShape.prototype.TestPoint = function (transform, p) { + return false; + } + b2EdgeShape.prototype.RayCast = function (output, input, transform) { + var tMat; + var rX = input.p2.x - input.p1.x; + var rY = input.p2.y - input.p1.y; + tMat = transform.R; + var v1X = transform.position.x + (tMat.col1.x * this.m_v1.x + tMat.col2.x * this.m_v1.y); + var v1Y = transform.position.y + (tMat.col1.y * this.m_v1.x + tMat.col2.y * this.m_v1.y); + var nX = transform.position.y + (tMat.col1.y * this.m_v2.x + tMat.col2.y * this.m_v2.y) - v1Y; + var nY = (-(transform.position.x + (tMat.col1.x * this.m_v2.x + tMat.col2.x * this.m_v2.y) - v1X)); + var k_slop = 100.0 * Number.MIN_VALUE; + var denom = (-(rX * nX + rY * nY)); + if (denom > k_slop) { + var bX = input.p1.x - v1X; + var bY = input.p1.y - v1Y; + var a = (bX * nX + bY * nY); + if (0.0 <= a && a <= input.maxFraction * denom) { + var mu2 = (-rX * bY) + rY * bX; + if ((-k_slop * denom) <= mu2 && mu2 <= denom * (1.0 + k_slop)) { + a /= denom; + output.fraction = a; + var nLen = Math.sqrt(nX * nX + nY * nY); + output.normal.x = nX / nLen; + output.normal.y = nY / nLen; + return true; + } + } + } + return false; + } + b2EdgeShape.prototype.ComputeAABB = function (aabb, transform) { + var tMat = transform.R; + var v1X = transform.position.x + (tMat.col1.x * this.m_v1.x + tMat.col2.x * this.m_v1.y); + var v1Y = transform.position.y + (tMat.col1.y * this.m_v1.x + tMat.col2.y * this.m_v1.y); + var v2X = transform.position.x + (tMat.col1.x * this.m_v2.x + tMat.col2.x * this.m_v2.y); + var v2Y = transform.position.y + (tMat.col1.y * this.m_v2.x + tMat.col2.y * this.m_v2.y); + if (v1X < v2X) { + aabb.lowerBound.x = v1X; + aabb.upperBound.x = v2X; + } + else { + aabb.lowerBound.x = v2X; + aabb.upperBound.x = v1X; + } + if (v1Y < v2Y) { + aabb.lowerBound.y = v1Y; + aabb.upperBound.y = v2Y; + } + else { + aabb.lowerBound.y = v2Y; + aabb.upperBound.y = v1Y; + } + } + b2EdgeShape.prototype.ComputeMass = function (massData, density) { + if (density === undefined) density = 0; + massData.mass = 0; + massData.center.SetV(this.m_v1); + massData.I = 0; + } + b2EdgeShape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) { + if (offset === undefined) offset = 0; + var v0 = new b2Vec2(normal.x * offset, normal.y * offset); + var v1 = b2Math.MulX(xf, this.m_v1); + var v2 = b2Math.MulX(xf, this.m_v2); + var d1 = b2Math.Dot(normal, v1) - offset; + var d2 = b2Math.Dot(normal, v2) - offset; + if (d1 > 0) { + if (d2 > 0) { + return 0; + } + else { + v1.x = (-d2 / (d1 - d2) * v1.x) + d1 / (d1 - d2) * v2.x; + v1.y = (-d2 / (d1 - d2) * v1.y) + d1 / (d1 - d2) * v2.y; + } + } + else { + if (d2 > 0) { + v2.x = (-d2 / (d1 - d2) * v1.x) + d1 / (d1 - d2) * v2.x; + v2.y = (-d2 / (d1 - d2) * v1.y) + d1 / (d1 - d2) * v2.y; + } + else {} + } + c.x = (v0.x + v1.x + v2.x) / 3; + c.y = (v0.y + v1.y + v2.y) / 3; + return 0.5 * ((v1.x - v0.x) * (v2.y - v0.y) - (v1.y - v0.y) * (v2.x - v0.x)); + } + b2EdgeShape.prototype.GetLength = function () { + return this.m_length; + } + b2EdgeShape.prototype.GetVertex1 = function () { + return this.m_v1; + } + b2EdgeShape.prototype.GetVertex2 = function () { + return this.m_v2; + } + b2EdgeShape.prototype.GetCoreVertex1 = function () { + return this.m_coreV1; + } + b2EdgeShape.prototype.GetCoreVertex2 = function () { + return this.m_coreV2; + } + b2EdgeShape.prototype.GetNormalVector = function () { + return this.m_normal; + } + b2EdgeShape.prototype.GetDirectionVector = function () { + return this.m_direction; + } + b2EdgeShape.prototype.GetCorner1Vector = function () { + return this.m_cornerDir1; + } + b2EdgeShape.prototype.GetCorner2Vector = function () { + return this.m_cornerDir2; + } + b2EdgeShape.prototype.Corner1IsConvex = function () { + return this.m_cornerConvex1; + } + b2EdgeShape.prototype.Corner2IsConvex = function () { + return this.m_cornerConvex2; + } + b2EdgeShape.prototype.GetFirstVertex = function (xf) { + var tMat = xf.R; + return new b2Vec2(xf.position.x + (tMat.col1.x * this.m_coreV1.x + tMat.col2.x * this.m_coreV1.y), xf.position.y + (tMat.col1.y * this.m_coreV1.x + tMat.col2.y * this.m_coreV1.y)); + } + b2EdgeShape.prototype.GetNextEdge = function () { + return this.m_nextEdge; + } + b2EdgeShape.prototype.GetPrevEdge = function () { + return this.m_prevEdge; + } + b2EdgeShape.prototype.Support = function (xf, dX, dY) { + if (dX === undefined) dX = 0; + if (dY === undefined) dY = 0; + var tMat = xf.R; + var v1X = xf.position.x + (tMat.col1.x * this.m_coreV1.x + tMat.col2.x * this.m_coreV1.y); + var v1Y = xf.position.y + (tMat.col1.y * this.m_coreV1.x + tMat.col2.y * this.m_coreV1.y); + var v2X = xf.position.x + (tMat.col1.x * this.m_coreV2.x + tMat.col2.x * this.m_coreV2.y); + var v2Y = xf.position.y + (tMat.col1.y * this.m_coreV2.x + tMat.col2.y * this.m_coreV2.y); + if ((v1X * dX + v1Y * dY) > (v2X * dX + v2Y * dY)) { + this.s_supportVec.x = v1X; + this.s_supportVec.y = v1Y; + } + else { + this.s_supportVec.x = v2X; + this.s_supportVec.y = v2Y; + } + return this.s_supportVec; + } + b2EdgeShape.prototype.b2EdgeShape = function (v1, v2) { + this.__super.b2Shape.call(this); + this.m_type = b2Shape.e_edgeShape; + this.m_prevEdge = null; + this.m_nextEdge = null; + this.m_v1 = v1; + this.m_v2 = v2; + this.m_direction.Set(this.m_v2.x - this.m_v1.x, this.m_v2.y - this.m_v1.y); + this.m_length = this.m_direction.Normalize(); + this.m_normal.Set(this.m_direction.y, (-this.m_direction.x)); + this.m_coreV1.Set((-b2Settings.b2_toiSlop * (this.m_normal.x - this.m_direction.x)) + this.m_v1.x, (-b2Settings.b2_toiSlop * (this.m_normal.y - this.m_direction.y)) + this.m_v1.y); + this.m_coreV2.Set((-b2Settings.b2_toiSlop * (this.m_normal.x + this.m_direction.x)) + this.m_v2.x, (-b2Settings.b2_toiSlop * (this.m_normal.y + this.m_direction.y)) + this.m_v2.y); + this.m_cornerDir1 = this.m_normal; + this.m_cornerDir2.Set((-this.m_normal.x), (-this.m_normal.y)); + } + b2EdgeShape.prototype.SetPrevEdge = function (edge, core, cornerDir, convex) { + this.m_prevEdge = edge; + this.m_coreV1 = core; + this.m_cornerDir1 = cornerDir; + this.m_cornerConvex1 = convex; + } + b2EdgeShape.prototype.SetNextEdge = function (edge, core, cornerDir, convex) { + this.m_nextEdge = edge; + this.m_coreV2 = core; + this.m_cornerDir2 = cornerDir; + this.m_cornerConvex2 = convex; + } + b2MassData.b2MassData = function () { + this.mass = 0.0; + this.center = new b2Vec2(0, 0); + this.I = 0.0; + }; + Box2D.inherit(b2PolygonShape, Box2D.Collision.Shapes.b2Shape); + b2PolygonShape.prototype.__super = Box2D.Collision.Shapes.b2Shape.prototype; + b2PolygonShape.b2PolygonShape = function () { + Box2D.Collision.Shapes.b2Shape.b2Shape.apply(this, arguments); + }; + b2PolygonShape.prototype.Copy = function () { + var s = new b2PolygonShape(); + s.Set(this); + return s; + } + b2PolygonShape.prototype.Set = function (other) { + this.__super.Set.call(this, other); + if (Box2D.is(other, b2PolygonShape)) { + var other2 = (other instanceof b2PolygonShape ? other : null); + this.m_centroid.SetV(other2.m_centroid); + this.m_vertexCount = other2.m_vertexCount; + this.Reserve(this.m_vertexCount); + for (var i = 0; i < this.m_vertexCount; i++) { + this.m_vertices[i].SetV(other2.m_vertices[i]); + this.m_normals[i].SetV(other2.m_normals[i]); + } + } + } + b2PolygonShape.prototype.SetAsArray = function (vertices, vertexCount) { + if (vertexCount === undefined) vertexCount = 0; + var v = new Vector(); + var i = 0, + tVec; + for (i = 0; + i < vertices.length; ++i) { + tVec = vertices[i]; + v.push(tVec); + } + this.SetAsVector(v, vertexCount); + } + b2PolygonShape.AsArray = function (vertices, vertexCount) { + if (vertexCount === undefined) vertexCount = 0; + var polygonShape = new b2PolygonShape(); + polygonShape.SetAsArray(vertices, vertexCount); + return polygonShape; + } + b2PolygonShape.prototype.SetAsVector = function (vertices, vertexCount) { + if (vertexCount === undefined) vertexCount = 0; + if (vertexCount == 0) vertexCount = vertices.length; + b2Settings.b2Assert(2 <= vertexCount); + this.m_vertexCount = vertexCount; + this.Reserve(vertexCount); + var i = 0; + for (i = 0; + i < this.m_vertexCount; i++) { + this.m_vertices[i].SetV(vertices[i]); + } + for (i = 0; + i < this.m_vertexCount; ++i) { + var i1 = parseInt(i); + var i2 = parseInt(i + 1 < this.m_vertexCount ? i + 1 : 0); + var edge = b2Math.SubtractVV(this.m_vertices[i2], this.m_vertices[i1]); + b2Settings.b2Assert(edge.LengthSquared() > Number.MIN_VALUE); + this.m_normals[i].SetV(b2Math.CrossVF(edge, 1.0)); + this.m_normals[i].Normalize(); + } + this.m_centroid = b2PolygonShape.ComputeCentroid(this.m_vertices, this.m_vertexCount); + } + b2PolygonShape.AsVector = function (vertices, vertexCount) { + if (vertexCount === undefined) vertexCount = 0; + var polygonShape = new b2PolygonShape(); + polygonShape.SetAsVector(vertices, vertexCount); + return polygonShape; + } + b2PolygonShape.prototype.SetAsBox = function (hx, hy) { + if (hx === undefined) hx = 0; + if (hy === undefined) hy = 0; + this.m_vertexCount = 4; + this.Reserve(4); + this.m_vertices[0].Set((-hx), (-hy)); + this.m_vertices[1].Set(hx, (-hy)); + this.m_vertices[2].Set(hx, hy); + this.m_vertices[3].Set((-hx), hy); + this.m_normals[0].Set(0.0, (-1.0)); + this.m_normals[1].Set(1.0, 0.0); + this.m_normals[2].Set(0.0, 1.0); + this.m_normals[3].Set((-1.0), 0.0); + this.m_centroid.SetZero(); + } + b2PolygonShape.AsBox = function (hx, hy) { + if (hx === undefined) hx = 0; + if (hy === undefined) hy = 0; + var polygonShape = new b2PolygonShape(); + polygonShape.SetAsBox(hx, hy); + return polygonShape; + } + b2PolygonShape.prototype.SetAsOrientedBox = function (hx, hy, center, angle) { + if (hx === undefined) hx = 0; + if (hy === undefined) hy = 0; + if (center === undefined) center = null; + if (angle === undefined) angle = 0.0; + this.m_vertexCount = 4; + this.Reserve(4); + this.m_vertices[0].Set((-hx), (-hy)); + this.m_vertices[1].Set(hx, (-hy)); + this.m_vertices[2].Set(hx, hy); + this.m_vertices[3].Set((-hx), hy); + this.m_normals[0].Set(0.0, (-1.0)); + this.m_normals[1].Set(1.0, 0.0); + this.m_normals[2].Set(0.0, 1.0); + this.m_normals[3].Set((-1.0), 0.0); + this.m_centroid = center; + var xf = new b2Transform(); + xf.position = center; + xf.R.Set(angle); + for (var i = 0; i < this.m_vertexCount; ++i) { + this.m_vertices[i] = b2Math.MulX(xf, this.m_vertices[i]); + this.m_normals[i] = b2Math.MulMV(xf.R, this.m_normals[i]); + } + } + b2PolygonShape.AsOrientedBox = function (hx, hy, center, angle) { + if (hx === undefined) hx = 0; + if (hy === undefined) hy = 0; + if (center === undefined) center = null; + if (angle === undefined) angle = 0.0; + var polygonShape = new b2PolygonShape(); + polygonShape.SetAsOrientedBox(hx, hy, center, angle); + return polygonShape; + } + b2PolygonShape.prototype.SetAsEdge = function (v1, v2) { + this.m_vertexCount = 2; + this.Reserve(2); + this.m_vertices[0].SetV(v1); + this.m_vertices[1].SetV(v2); + this.m_centroid.x = 0.5 * (v1.x + v2.x); + this.m_centroid.y = 0.5 * (v1.y + v2.y); + this.m_normals[0] = b2Math.CrossVF(b2Math.SubtractVV(v2, v1), 1.0); + this.m_normals[0].Normalize(); + this.m_normals[1].x = (-this.m_normals[0].x); + this.m_normals[1].y = (-this.m_normals[0].y); + } + b2PolygonShape.AsEdge = function (v1, v2) { + var polygonShape = new b2PolygonShape(); + polygonShape.SetAsEdge(v1, v2); + return polygonShape; + } + b2PolygonShape.prototype.TestPoint = function (xf, p) { + var tVec; + var tMat = xf.R; + var tX = p.x - xf.position.x; + var tY = p.y - xf.position.y; + var pLocalX = (tX * tMat.col1.x + tY * tMat.col1.y); + var pLocalY = (tX * tMat.col2.x + tY * tMat.col2.y); + for (var i = 0; i < this.m_vertexCount; ++i) { + tVec = this.m_vertices[i]; + tX = pLocalX - tVec.x; + tY = pLocalY - tVec.y; + tVec = this.m_normals[i]; + var dot = (tVec.x * tX + tVec.y * tY); + if (dot > 0.0) { + return false; + } + } + return true; + } + b2PolygonShape.prototype.RayCast = function (output, input, transform) { + var lower = 0.0; + var upper = input.maxFraction; + var tX = 0; + var tY = 0; + var tMat; + var tVec; + tX = input.p1.x - transform.position.x; + tY = input.p1.y - transform.position.y; + tMat = transform.R; + var p1X = (tX * tMat.col1.x + tY * tMat.col1.y); + var p1Y = (tX * tMat.col2.x + tY * tMat.col2.y); + tX = input.p2.x - transform.position.x; + tY = input.p2.y - transform.position.y; + tMat = transform.R; + var p2X = (tX * tMat.col1.x + tY * tMat.col1.y); + var p2Y = (tX * tMat.col2.x + tY * tMat.col2.y); + var dX = p2X - p1X; + var dY = p2Y - p1Y; + var index = parseInt((-1)); + for (var i = 0; i < this.m_vertexCount; ++i) { + tVec = this.m_vertices[i]; + tX = tVec.x - p1X; + tY = tVec.y - p1Y; + tVec = this.m_normals[i]; + var numerator = (tVec.x * tX + tVec.y * tY); + var denominator = (tVec.x * dX + tVec.y * dY); + if (denominator == 0.0) { + if (numerator < 0.0) { + return false; + } + } + else { + if (denominator < 0.0 && numerator < lower * denominator) { + lower = numerator / denominator; + index = i; + } + else if (denominator > 0.0 && numerator < upper * denominator) { + upper = numerator / denominator; + } + } + if (upper < lower - Number.MIN_VALUE) { + return false; + } + } + if (index >= 0) { + output.fraction = lower; + tMat = transform.R; + tVec = this.m_normals[index]; + output.normal.x = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + output.normal.y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + return true; + } + return false; + } + b2PolygonShape.prototype.ComputeAABB = function (aabb, xf) { + var tMat = xf.R; + var tVec = this.m_vertices[0]; + var lowerX = xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var lowerY = xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + var upperX = lowerX; + var upperY = lowerY; + for (var i = 1; i < this.m_vertexCount; ++i) { + tVec = this.m_vertices[i]; + var vX = xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var vY = xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + lowerX = lowerX < vX ? lowerX : vX; + lowerY = lowerY < vY ? lowerY : vY; + upperX = upperX > vX ? upperX : vX; + upperY = upperY > vY ? upperY : vY; + } + aabb.lowerBound.x = lowerX - this.m_radius; + aabb.lowerBound.y = lowerY - this.m_radius; + aabb.upperBound.x = upperX + this.m_radius; + aabb.upperBound.y = upperY + this.m_radius; + } + b2PolygonShape.prototype.ComputeMass = function (massData, density) { + if (density === undefined) density = 0; + if (this.m_vertexCount == 2) { + massData.center.x = 0.5 * (this.m_vertices[0].x + this.m_vertices[1].x); + massData.center.y = 0.5 * (this.m_vertices[0].y + this.m_vertices[1].y); + massData.mass = 0.0; + massData.I = 0.0; + return; + } + var centerX = 0.0; + var centerY = 0.0; + var area = 0.0; + var I = 0.0; + var p1X = 0.0; + var p1Y = 0.0; + var k_inv3 = 1.0 / 3.0; + for (var i = 0; i < this.m_vertexCount; ++i) { + var p2 = this.m_vertices[i]; + var p3 = i + 1 < this.m_vertexCount ? this.m_vertices[parseInt(i + 1)] : this.m_vertices[0]; + var e1X = p2.x - p1X; + var e1Y = p2.y - p1Y; + var e2X = p3.x - p1X; + var e2Y = p3.y - p1Y; + var D = e1X * e2Y - e1Y * e2X; + var triangleArea = 0.5 * D;area += triangleArea; + centerX += triangleArea * k_inv3 * (p1X + p2.x + p3.x); + centerY += triangleArea * k_inv3 * (p1Y + p2.y + p3.y); + var px = p1X; + var py = p1Y; + var ex1 = e1X; + var ey1 = e1Y; + var ex2 = e2X; + var ey2 = e2Y; + var intx2 = k_inv3 * (0.25 * (ex1 * ex1 + ex2 * ex1 + ex2 * ex2) + (px * ex1 + px * ex2)) + 0.5 * px * px; + var inty2 = k_inv3 * (0.25 * (ey1 * ey1 + ey2 * ey1 + ey2 * ey2) + (py * ey1 + py * ey2)) + 0.5 * py * py;I += D * (intx2 + inty2); + } + massData.mass = density * area; + centerX *= 1.0 / area; + centerY *= 1.0 / area; + massData.center.Set(centerX, centerY); + massData.I = density * I; + } + b2PolygonShape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) { + if (offset === undefined) offset = 0; + var normalL = b2Math.MulTMV(xf.R, normal); + var offsetL = offset - b2Math.Dot(normal, xf.position); + var depths = new Vector_a2j_Number(); + var diveCount = 0; + var intoIndex = parseInt((-1)); + var outoIndex = parseInt((-1)); + var lastSubmerged = false; + var i = 0; + for (i = 0; + i < this.m_vertexCount; ++i) { + depths[i] = b2Math.Dot(normalL, this.m_vertices[i]) - offsetL; + var isSubmerged = depths[i] < (-Number.MIN_VALUE); + if (i > 0) { + if (isSubmerged) { + if (!lastSubmerged) { + intoIndex = i - 1; + diveCount++; + } + } + else { + if (lastSubmerged) { + outoIndex = i - 1; + diveCount++; + } + } + } + lastSubmerged = isSubmerged; + } + switch (diveCount) { + case 0: + if (lastSubmerged) { + var md = new b2MassData(); + this.ComputeMass(md, 1); + c.SetV(b2Math.MulX(xf, md.center)); + return md.mass; + } + else { + return 0; + } + break; + case 1: + if (intoIndex == (-1)) { + intoIndex = this.m_vertexCount - 1; + } + else { + outoIndex = this.m_vertexCount - 1; + } + break; + } + var intoIndex2 = parseInt((intoIndex + 1) % this.m_vertexCount); + var outoIndex2 = parseInt((outoIndex + 1) % this.m_vertexCount); + var intoLamdda = (0 - depths[intoIndex]) / (depths[intoIndex2] - depths[intoIndex]); + var outoLamdda = (0 - depths[outoIndex]) / (depths[outoIndex2] - depths[outoIndex]); + var intoVec = new b2Vec2(this.m_vertices[intoIndex].x * (1 - intoLamdda) + this.m_vertices[intoIndex2].x * intoLamdda, this.m_vertices[intoIndex].y * (1 - intoLamdda) + this.m_vertices[intoIndex2].y * intoLamdda); + var outoVec = new b2Vec2(this.m_vertices[outoIndex].x * (1 - outoLamdda) + this.m_vertices[outoIndex2].x * outoLamdda, this.m_vertices[outoIndex].y * (1 - outoLamdda) + this.m_vertices[outoIndex2].y * outoLamdda); + var area = 0; + var center = new b2Vec2(); + var p2 = this.m_vertices[intoIndex2]; + var p3; + i = intoIndex2; + while (i != outoIndex2) { + i = (i + 1) % this.m_vertexCount; + if (i == outoIndex2) p3 = outoVec; + else p3 = this.m_vertices[i]; + var triangleArea = 0.5 * ((p2.x - intoVec.x) * (p3.y - intoVec.y) - (p2.y - intoVec.y) * (p3.x - intoVec.x)); + area += triangleArea; + center.x += triangleArea * (intoVec.x + p2.x + p3.x) / 3; + center.y += triangleArea * (intoVec.y + p2.y + p3.y) / 3; + p2 = p3; + } + center.Multiply(1 / area); + c.SetV(b2Math.MulX(xf, center)); + return area; + } + b2PolygonShape.prototype.GetVertexCount = function () { + return this.m_vertexCount; + } + b2PolygonShape.prototype.GetVertices = function () { + return this.m_vertices; + } + b2PolygonShape.prototype.GetNormals = function () { + return this.m_normals; + } + b2PolygonShape.prototype.GetSupport = function (d) { + var bestIndex = 0; + var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y; + for (var i = 1; i < this.m_vertexCount; ++i) { + var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y; + if (value > bestValue) { + bestIndex = i; + bestValue = value; + } + } + return bestIndex; + } + b2PolygonShape.prototype.GetSupportVertex = function (d) { + var bestIndex = 0; + var bestValue = this.m_vertices[0].x * d.x + this.m_vertices[0].y * d.y; + for (var i = 1; i < this.m_vertexCount; ++i) { + var value = this.m_vertices[i].x * d.x + this.m_vertices[i].y * d.y; + if (value > bestValue) { + bestIndex = i; + bestValue = value; + } + } + return this.m_vertices[bestIndex]; + } + b2PolygonShape.prototype.Validate = function () { + return false; + } + b2PolygonShape.prototype.b2PolygonShape = function () { + this.__super.b2Shape.call(this); + this.m_type = b2Shape.e_polygonShape; + this.m_centroid = new b2Vec2(); + this.m_vertices = new Vector(); + this.m_normals = new Vector(); + } + b2PolygonShape.prototype.Reserve = function (count) { + if (count === undefined) count = 0; + for (var i = parseInt(this.m_vertices.length); i < count; i++) { + this.m_vertices[i] = new b2Vec2(); + this.m_normals[i] = new b2Vec2(); + } + } + b2PolygonShape.ComputeCentroid = function (vs, count) { + if (count === undefined) count = 0; + var c = new b2Vec2(); + var area = 0.0; + var p1X = 0.0; + var p1Y = 0.0; + var inv3 = 1.0 / 3.0; + for (var i = 0; i < count; ++i) { + var p2 = vs[i]; + var p3 = i + 1 < count ? vs[parseInt(i + 1)] : vs[0]; + var e1X = p2.x - p1X; + var e1Y = p2.y - p1Y; + var e2X = p3.x - p1X; + var e2Y = p3.y - p1Y; + var D = (e1X * e2Y - e1Y * e2X); + var triangleArea = 0.5 * D;area += triangleArea; + c.x += triangleArea * inv3 * (p1X + p2.x + p3.x); + c.y += triangleArea * inv3 * (p1Y + p2.y + p3.y); + } + c.x *= 1.0 / area; + c.y *= 1.0 / area; + return c; + } + b2PolygonShape.ComputeOBB = function (obb, vs, count) { + if (count === undefined) count = 0; + var i = 0; + var p = new Vector(count + 1); + for (i = 0; + i < count; ++i) { + p[i] = vs[i]; + } + p[count] = p[0]; + var minArea = Number.MAX_VALUE; + for (i = 1; + i <= count; ++i) { + var root = p[parseInt(i - 1)]; + var uxX = p[i].x - root.x; + var uxY = p[i].y - root.y; + var length = Math.sqrt(uxX * uxX + uxY * uxY); + uxX /= length; + uxY /= length; + var uyX = (-uxY); + var uyY = uxX; + var lowerX = Number.MAX_VALUE; + var lowerY = Number.MAX_VALUE; + var upperX = (-Number.MAX_VALUE); + var upperY = (-Number.MAX_VALUE); + for (var j = 0; j < count; ++j) { + var dX = p[j].x - root.x; + var dY = p[j].y - root.y; + var rX = (uxX * dX + uxY * dY); + var rY = (uyX * dX + uyY * dY); + if (rX < lowerX) lowerX = rX; + if (rY < lowerY) lowerY = rY; + if (rX > upperX) upperX = rX; + if (rY > upperY) upperY = rY; + } + var area = (upperX - lowerX) * (upperY - lowerY); + if (area < 0.95 * minArea) { + minArea = area; + obb.R.col1.x = uxX; + obb.R.col1.y = uxY; + obb.R.col2.x = uyX; + obb.R.col2.y = uyY; + var centerX = 0.5 * (lowerX + upperX); + var centerY = 0.5 * (lowerY + upperY); + var tMat = obb.R; + obb.center.x = root.x + (tMat.col1.x * centerX + tMat.col2.x * centerY); + obb.center.y = root.y + (tMat.col1.y * centerX + tMat.col2.y * centerY); + obb.extents.x = 0.5 * (upperX - lowerX); + obb.extents.y = 0.5 * (upperY - lowerY); + } + } + } + Box2D.postDefs.push(function () { + Box2D.Collision.Shapes.b2PolygonShape.s_mat = new b2Mat22(); + }); + b2Shape.b2Shape = function () {}; + b2Shape.prototype.Copy = function () { + return null; + } + b2Shape.prototype.Set = function (other) { + this.m_radius = other.m_radius; + } + b2Shape.prototype.GetType = function () { + return this.m_type; + } + b2Shape.prototype.TestPoint = function (xf, p) { + return false; + } + b2Shape.prototype.RayCast = function (output, input, transform) { + return false; + } + b2Shape.prototype.ComputeAABB = function (aabb, xf) {} + b2Shape.prototype.ComputeMass = function (massData, density) { + if (density === undefined) density = 0; + } + b2Shape.prototype.ComputeSubmergedArea = function (normal, offset, xf, c) { + if (offset === undefined) offset = 0; + return 0; + } + b2Shape.TestOverlap = function (shape1, transform1, shape2, transform2) { + var input = new b2DistanceInput(); + input.proxyA = new b2DistanceProxy(); + input.proxyA.Set(shape1); + input.proxyB = new b2DistanceProxy(); + input.proxyB.Set(shape2); + input.transformA = transform1; + input.transformB = transform2; + input.useRadii = true; + var simplexCache = new b2SimplexCache(); + simplexCache.count = 0; + var output = new b2DistanceOutput(); + b2Distance.Distance(output, simplexCache, input); + return output.distance < 10.0 * Number.MIN_VALUE; + } + b2Shape.prototype.b2Shape = function () { + this.m_type = b2Shape.e_unknownShape; + this.m_radius = b2Settings.b2_linearSlop; + } + Box2D.postDefs.push(function () { + Box2D.Collision.Shapes.b2Shape.e_unknownShape = parseInt((-1)); + Box2D.Collision.Shapes.b2Shape.e_circleShape = 0; + Box2D.Collision.Shapes.b2Shape.e_polygonShape = 1; + Box2D.Collision.Shapes.b2Shape.e_edgeShape = 2; + Box2D.Collision.Shapes.b2Shape.e_shapeTypeCount = 3; + Box2D.Collision.Shapes.b2Shape.e_hitCollide = 1; + Box2D.Collision.Shapes.b2Shape.e_missCollide = 0; + Box2D.Collision.Shapes.b2Shape.e_startsInsideCollide = parseInt((-1)); + }); +})(); +(function () { + var b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3; + + b2Color.b2Color = function () { + this._r = 0; + this._g = 0; + this._b = 0; + }; + b2Color.prototype.b2Color = function (rr, gg, bb) { + if (rr === undefined) rr = 0; + if (gg === undefined) gg = 0; + if (bb === undefined) bb = 0; + this._r = Box2D.parseUInt(255 * b2Math.Clamp(rr, 0.0, 1.0)); + this._g = Box2D.parseUInt(255 * b2Math.Clamp(gg, 0.0, 1.0)); + this._b = Box2D.parseUInt(255 * b2Math.Clamp(bb, 0.0, 1.0)); + } + b2Color.prototype.Set = function (rr, gg, bb) { + if (rr === undefined) rr = 0; + if (gg === undefined) gg = 0; + if (bb === undefined) bb = 0; + this._r = Box2D.parseUInt(255 * b2Math.Clamp(rr, 0.0, 1.0)); + this._g = Box2D.parseUInt(255 * b2Math.Clamp(gg, 0.0, 1.0)); + this._b = Box2D.parseUInt(255 * b2Math.Clamp(bb, 0.0, 1.0)); + } + Object.defineProperty(b2Color.prototype, 'r', { + enumerable: false, + configurable: true, + set: function (rr) { + if (rr === undefined) rr = 0; + this._r = Box2D.parseUInt(255 * b2Math.Clamp(rr, 0.0, 1.0)); + } + }); + Object.defineProperty(b2Color.prototype, 'g', { + enumerable: false, + configurable: true, + set: function (gg) { + if (gg === undefined) gg = 0; + this._g = Box2D.parseUInt(255 * b2Math.Clamp(gg, 0.0, 1.0)); + } + }); + Object.defineProperty(b2Color.prototype, 'b', { + enumerable: false, + configurable: true, + set: function (bb) { + if (bb === undefined) bb = 0; + this._b = Box2D.parseUInt(255 * b2Math.Clamp(bb, 0.0, 1.0)); + } + }); + Object.defineProperty(b2Color.prototype, 'color', { + enumerable: false, + configurable: true, + get: function () { + return (this._r << 16) | (this._g << 8) | (this._b); + } + }); + b2Settings.b2Settings = function () {}; + b2Settings.b2MixFriction = function (friction1, friction2) { + if (friction1 === undefined) friction1 = 0; + if (friction2 === undefined) friction2 = 0; + return Math.sqrt(friction1 * friction2); + } + b2Settings.b2MixRestitution = function (restitution1, restitution2) { + if (restitution1 === undefined) restitution1 = 0; + if (restitution2 === undefined) restitution2 = 0; + return restitution1 > restitution2 ? restitution1 : restitution2; + } + b2Settings.b2Assert = function (a) { + if (!a) { + throw "Assertion Failed"; + } + } + Box2D.postDefs.push(function () { + Box2D.Common.b2Settings.VERSION = "2.1alpha"; + Box2D.Common.b2Settings.USHRT_MAX = 0x0000ffff; + Box2D.Common.b2Settings.b2_pi = Math.PI; + Box2D.Common.b2Settings.b2_maxManifoldPoints = 2; + Box2D.Common.b2Settings.b2_aabbExtension = 0.1; + Box2D.Common.b2Settings.b2_aabbMultiplier = 2.0; + Box2D.Common.b2Settings.b2_polygonRadius = 2.0 * b2Settings.b2_linearSlop; + Box2D.Common.b2Settings.b2_linearSlop = 0.005; + Box2D.Common.b2Settings.b2_angularSlop = 2.0 / 180.0 * b2Settings.b2_pi; + Box2D.Common.b2Settings.b2_toiSlop = 8.0 * b2Settings.b2_linearSlop; + Box2D.Common.b2Settings.b2_maxTOIContactsPerIsland = 32; + Box2D.Common.b2Settings.b2_maxTOIJointsPerIsland = 32; + Box2D.Common.b2Settings.b2_velocityThreshold = 1.0; + Box2D.Common.b2Settings.b2_maxLinearCorrection = 0.2; + Box2D.Common.b2Settings.b2_maxAngularCorrection = 8.0 / 180.0 * b2Settings.b2_pi; + Box2D.Common.b2Settings.b2_maxTranslation = 2.0; + Box2D.Common.b2Settings.b2_maxTranslationSquared = b2Settings.b2_maxTranslation * b2Settings.b2_maxTranslation; + Box2D.Common.b2Settings.b2_maxRotation = 0.5 * b2Settings.b2_pi; + Box2D.Common.b2Settings.b2_maxRotationSquared = b2Settings.b2_maxRotation * b2Settings.b2_maxRotation; + Box2D.Common.b2Settings.b2_contactBaumgarte = 0.2; + Box2D.Common.b2Settings.b2_timeToSleep = 0.5; + Box2D.Common.b2Settings.b2_linearSleepTolerance = 0.01; + Box2D.Common.b2Settings.b2_angularSleepTolerance = 2.0 / 180.0 * b2Settings.b2_pi; + }); +})(); +(function () { + var b2AABB = Box2D.Collision.b2AABB, + b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3; + + b2Mat22.b2Mat22 = function () { + this.col1 = new b2Vec2(); + this.col2 = new b2Vec2(); + }; + b2Mat22.prototype.b2Mat22 = function () { + this.SetIdentity(); + } + b2Mat22.FromAngle = function (angle) { + if (angle === undefined) angle = 0; + var mat = new b2Mat22(); + mat.Set(angle); + return mat; + } + b2Mat22.FromVV = function (c1, c2) { + var mat = new b2Mat22(); + mat.SetVV(c1, c2); + return mat; + } + b2Mat22.prototype.Set = function (angle) { + if (angle === undefined) angle = 0; + var c = Math.cos(angle); + var s = Math.sin(angle); + this.col1.x = c; + this.col2.x = (-s); + this.col1.y = s; + this.col2.y = c; + } + b2Mat22.prototype.SetVV = function (c1, c2) { + this.col1.SetV(c1); + this.col2.SetV(c2); + } + b2Mat22.prototype.Copy = function () { + var mat = new b2Mat22(); + mat.SetM(this); + return mat; + } + b2Mat22.prototype.SetM = function (m) { + this.col1.SetV(m.col1); + this.col2.SetV(m.col2); + } + b2Mat22.prototype.AddM = function (m) { + this.col1.x += m.col1.x; + this.col1.y += m.col1.y; + this.col2.x += m.col2.x; + this.col2.y += m.col2.y; + } + b2Mat22.prototype.SetIdentity = function () { + this.col1.x = 1.0; + this.col2.x = 0.0; + this.col1.y = 0.0; + this.col2.y = 1.0; + } + b2Mat22.prototype.SetZero = function () { + this.col1.x = 0.0; + this.col2.x = 0.0; + this.col1.y = 0.0; + this.col2.y = 0.0; + } + b2Mat22.prototype.GetAngle = function () { + return Math.atan2(this.col1.y, this.col1.x); + } + b2Mat22.prototype.GetInverse = function (out) { + var a = this.col1.x; + var b = this.col2.x; + var c = this.col1.y; + var d = this.col2.y; + var det = a * d - b * c; + if (det != 0.0) { + det = 1.0 / det; + } + out.col1.x = det * d; + out.col2.x = (-det * b); + out.col1.y = (-det * c); + out.col2.y = det * a; + return out; + } + b2Mat22.prototype.Solve = function (out, bX, bY) { + if (bX === undefined) bX = 0; + if (bY === undefined) bY = 0; + var a11 = this.col1.x; + var a12 = this.col2.x; + var a21 = this.col1.y; + var a22 = this.col2.y; + var det = a11 * a22 - a12 * a21; + if (det != 0.0) { + det = 1.0 / det; + } + out.x = det * (a22 * bX - a12 * bY); + out.y = det * (a11 * bY - a21 * bX); + return out; + } + b2Mat22.prototype.Abs = function () { + this.col1.Abs(); + this.col2.Abs(); + } + b2Mat33.b2Mat33 = function () { + this.col1 = new b2Vec3(); + this.col2 = new b2Vec3(); + this.col3 = new b2Vec3(); + }; + b2Mat33.prototype.b2Mat33 = function (c1, c2, c3) { + if (c1 === undefined) c1 = null; + if (c2 === undefined) c2 = null; + if (c3 === undefined) c3 = null; + if (!c1 && !c2 && !c3) { + this.col1.SetZero(); + this.col2.SetZero(); + this.col3.SetZero(); + } + else { + this.col1.SetV(c1); + this.col2.SetV(c2); + this.col3.SetV(c3); + } + } + b2Mat33.prototype.SetVVV = function (c1, c2, c3) { + this.col1.SetV(c1); + this.col2.SetV(c2); + this.col3.SetV(c3); + } + b2Mat33.prototype.Copy = function () { + return new b2Mat33(this.col1, this.col2, this.col3); + } + b2Mat33.prototype.SetM = function (m) { + this.col1.SetV(m.col1); + this.col2.SetV(m.col2); + this.col3.SetV(m.col3); + } + b2Mat33.prototype.AddM = function (m) { + this.col1.x += m.col1.x; + this.col1.y += m.col1.y; + this.col1.z += m.col1.z; + this.col2.x += m.col2.x; + this.col2.y += m.col2.y; + this.col2.z += m.col2.z; + this.col3.x += m.col3.x; + this.col3.y += m.col3.y; + this.col3.z += m.col3.z; + } + b2Mat33.prototype.SetIdentity = function () { + this.col1.x = 1.0; + this.col2.x = 0.0; + this.col3.x = 0.0; + this.col1.y = 0.0; + this.col2.y = 1.0; + this.col3.y = 0.0; + this.col1.z = 0.0; + this.col2.z = 0.0; + this.col3.z = 1.0; + } + b2Mat33.prototype.SetZero = function () { + this.col1.x = 0.0; + this.col2.x = 0.0; + this.col3.x = 0.0; + this.col1.y = 0.0; + this.col2.y = 0.0; + this.col3.y = 0.0; + this.col1.z = 0.0; + this.col2.z = 0.0; + this.col3.z = 0.0; + } + b2Mat33.prototype.Solve22 = function (out, bX, bY) { + if (bX === undefined) bX = 0; + if (bY === undefined) bY = 0; + var a11 = this.col1.x; + var a12 = this.col2.x; + var a21 = this.col1.y; + var a22 = this.col2.y; + var det = a11 * a22 - a12 * a21; + if (det != 0.0) { + det = 1.0 / det; + } + out.x = det * (a22 * bX - a12 * bY); + out.y = det * (a11 * bY - a21 * bX); + return out; + } + b2Mat33.prototype.Solve33 = function (out, bX, bY, bZ) { + if (bX === undefined) bX = 0; + if (bY === undefined) bY = 0; + if (bZ === undefined) bZ = 0; + var a11 = this.col1.x; + var a21 = this.col1.y; + var a31 = this.col1.z; + var a12 = this.col2.x; + var a22 = this.col2.y; + var a32 = this.col2.z; + var a13 = this.col3.x; + var a23 = this.col3.y; + var a33 = this.col3.z; + var det = a11 * (a22 * a33 - a32 * a23) + a21 * (a32 * a13 - a12 * a33) + a31 * (a12 * a23 - a22 * a13); + if (det != 0.0) { + det = 1.0 / det; + } + out.x = det * (bX * (a22 * a33 - a32 * a23) + bY * (a32 * a13 - a12 * a33) + bZ * (a12 * a23 - a22 * a13)); + out.y = det * (a11 * (bY * a33 - bZ * a23) + a21 * (bZ * a13 - bX * a33) + a31 * (bX * a23 - bY * a13)); + out.z = det * (a11 * (a22 * bZ - a32 * bY) + a21 * (a32 * bX - a12 * bZ) + a31 * (a12 * bY - a22 * bX)); + return out; + } + b2Math.b2Math = function () {}; + b2Math.IsValid = function (x) { + if (x === undefined) x = 0; + return isFinite(x); + } + b2Math.Dot = function (a, b) { + return a.x * b.x + a.y * b.y; + } + b2Math.CrossVV = function (a, b) { + return a.x * b.y - a.y * b.x; + } + b2Math.CrossVF = function (a, s) { + if (s === undefined) s = 0; + var v = new b2Vec2(s * a.y, (-s * a.x)); + return v; + } + b2Math.CrossFV = function (s, a) { + if (s === undefined) s = 0; + var v = new b2Vec2((-s * a.y), s * a.x); + return v; + } + b2Math.MulMV = function (A, v) { + var u = new b2Vec2(A.col1.x * v.x + A.col2.x * v.y, A.col1.y * v.x + A.col2.y * v.y); + return u; + } + b2Math.MulTMV = function (A, v) { + var u = new b2Vec2(b2Math.Dot(v, A.col1), b2Math.Dot(v, A.col2)); + return u; + } + b2Math.MulX = function (T, v) { + var a = b2Math.MulMV(T.R, v); + a.x += T.position.x; + a.y += T.position.y; + return a; + } + b2Math.MulXT = function (T, v) { + var a = b2Math.SubtractVV(v, T.position); + var tX = (a.x * T.R.col1.x + a.y * T.R.col1.y); + a.y = (a.x * T.R.col2.x + a.y * T.R.col2.y); + a.x = tX; + return a; + } + b2Math.AddVV = function (a, b) { + var v = new b2Vec2(a.x + b.x, a.y + b.y); + return v; + } + b2Math.SubtractVV = function (a, b) { + var v = new b2Vec2(a.x - b.x, a.y - b.y); + return v; + } + b2Math.Distance = function (a, b) { + var cX = a.x - b.x; + var cY = a.y - b.y; + return Math.sqrt(cX * cX + cY * cY); + } + b2Math.DistanceSquared = function (a, b) { + var cX = a.x - b.x; + var cY = a.y - b.y; + return (cX * cX + cY * cY); + } + b2Math.MulFV = function (s, a) { + if (s === undefined) s = 0; + var v = new b2Vec2(s * a.x, s * a.y); + return v; + } + b2Math.AddMM = function (A, B) { + var C = b2Mat22.FromVV(b2Math.AddVV(A.col1, B.col1), b2Math.AddVV(A.col2, B.col2)); + return C; + } + b2Math.MulMM = function (A, B) { + var C = b2Mat22.FromVV(b2Math.MulMV(A, B.col1), b2Math.MulMV(A, B.col2)); + return C; + } + b2Math.MulTMM = function (A, B) { + var c1 = new b2Vec2(b2Math.Dot(A.col1, B.col1), b2Math.Dot(A.col2, B.col1)); + var c2 = new b2Vec2(b2Math.Dot(A.col1, B.col2), b2Math.Dot(A.col2, B.col2)); + var C = b2Mat22.FromVV(c1, c2); + return C; + } + b2Math.Abs = function (a) { + if (a === undefined) a = 0; + return a > 0.0 ? a : (-a); + } + b2Math.AbsV = function (a) { + var b = new b2Vec2(b2Math.Abs(a.x), b2Math.Abs(a.y)); + return b; + } + b2Math.AbsM = function (A) { + var B = b2Mat22.FromVV(b2Math.AbsV(A.col1), b2Math.AbsV(A.col2)); + return B; + } + b2Math.Min = function (a, b) { + if (a === undefined) a = 0; + if (b === undefined) b = 0; + return a < b ? a : b; + } + b2Math.MinV = function (a, b) { + var c = new b2Vec2(b2Math.Min(a.x, b.x), b2Math.Min(a.y, b.y)); + return c; + } + b2Math.Max = function (a, b) { + if (a === undefined) a = 0; + if (b === undefined) b = 0; + return a > b ? a : b; + } + b2Math.MaxV = function (a, b) { + var c = new b2Vec2(b2Math.Max(a.x, b.x), b2Math.Max(a.y, b.y)); + return c; + } + b2Math.Clamp = function (a, low, high) { + if (a === undefined) a = 0; + if (low === undefined) low = 0; + if (high === undefined) high = 0; + return a < low ? low : a > high ? high : a; + } + b2Math.ClampV = function (a, low, high) { + return b2Math.MaxV(low, b2Math.MinV(a, high)); + } + b2Math.Swap = function (a, b) { + var tmp = a[0]; + a[0] = b[0]; + b[0] = tmp; + } + b2Math.Random = function () { + return Math.random() * 2 - 1; + } + b2Math.RandomRange = function (lo, hi) { + if (lo === undefined) lo = 0; + if (hi === undefined) hi = 0; + var r = Math.random(); + r = (hi - lo) * r + lo; + return r; + } + b2Math.NextPowerOfTwo = function (x) { + if (x === undefined) x = 0; + x |= (x >> 1) & 0x7FFFFFFF; + x |= (x >> 2) & 0x3FFFFFFF; + x |= (x >> 4) & 0x0FFFFFFF; + x |= (x >> 8) & 0x00FFFFFF; + x |= (x >> 16) & 0x0000FFFF; + return x + 1; + } + b2Math.IsPowerOfTwo = function (x) { + if (x === undefined) x = 0; + var result = x > 0 && (x & (x - 1)) == 0; + return result; + } + Box2D.postDefs.push(function () { + Box2D.Common.Math.b2Math.b2Vec2_zero = new b2Vec2(0.0, 0.0); + Box2D.Common.Math.b2Math.b2Mat22_identity = b2Mat22.FromVV(new b2Vec2(1.0, 0.0), new b2Vec2(0.0, 1.0)); + Box2D.Common.Math.b2Math.b2Transform_identity = new b2Transform(b2Math.b2Vec2_zero, b2Math.b2Mat22_identity); + }); + b2Sweep.b2Sweep = function () { + this.localCenter = new b2Vec2(); + this.c0 = new b2Vec2; + this.c = new b2Vec2(); + }; + b2Sweep.prototype.Set = function (other) { + this.localCenter.SetV(other.localCenter); + this.c0.SetV(other.c0); + this.c.SetV(other.c); + this.a0 = other.a0; + this.a = other.a; + this.t0 = other.t0; + } + b2Sweep.prototype.Copy = function () { + var copy = new b2Sweep(); + copy.localCenter.SetV(this.localCenter); + copy.c0.SetV(this.c0); + copy.c.SetV(this.c); + copy.a0 = this.a0; + copy.a = this.a; + copy.t0 = this.t0; + return copy; + } + b2Sweep.prototype.GetTransform = function (xf, alpha) { + if (alpha === undefined) alpha = 0; + xf.position.x = (1.0 - alpha) * this.c0.x + alpha * this.c.x; + xf.position.y = (1.0 - alpha) * this.c0.y + alpha * this.c.y; + var angle = (1.0 - alpha) * this.a0 + alpha * this.a; + xf.R.Set(angle); + var tMat = xf.R; + xf.position.x -= (tMat.col1.x * this.localCenter.x + tMat.col2.x * this.localCenter.y); + xf.position.y -= (tMat.col1.y * this.localCenter.x + tMat.col2.y * this.localCenter.y); + } + b2Sweep.prototype.Advance = function (t) { + if (t === undefined) t = 0; + if (this.t0 < t && 1.0 - this.t0 > Number.MIN_VALUE) { + var alpha = (t - this.t0) / (1.0 - this.t0); + this.c0.x = (1.0 - alpha) * this.c0.x + alpha * this.c.x; + this.c0.y = (1.0 - alpha) * this.c0.y + alpha * this.c.y; + this.a0 = (1.0 - alpha) * this.a0 + alpha * this.a; + this.t0 = t; + } + } + b2Transform.b2Transform = function () { + this.position = new b2Vec2; + this.R = new b2Mat22(); + }; + b2Transform.prototype.b2Transform = function (pos, r) { + if (pos === undefined) pos = null; + if (r === undefined) r = null; + if (pos) { + this.position.SetV(pos); + this.R.SetM(r); + } + } + b2Transform.prototype.Initialize = function (pos, r) { + this.position.SetV(pos); + this.R.SetM(r); + } + b2Transform.prototype.SetIdentity = function () { + this.position.SetZero(); + this.R.SetIdentity(); + } + b2Transform.prototype.Set = function (x) { + this.position.SetV(x.position); + this.R.SetM(x.R); + } + b2Transform.prototype.GetAngle = function () { + return Math.atan2(this.R.col1.y, this.R.col1.x); + } + b2Vec2.b2Vec2 = function () {}; + b2Vec2.prototype.b2Vec2 = function (x_, y_) { + if (x_ === undefined) x_ = 0; + if (y_ === undefined) y_ = 0; + this.x = x_; + this.y = y_; + } + b2Vec2.prototype.SetZero = function () { + this.x = 0.0; + this.y = 0.0; + } + b2Vec2.prototype.Set = function (x_, y_) { + if (x_ === undefined) x_ = 0; + if (y_ === undefined) y_ = 0; + this.x = x_; + this.y = y_; + } + b2Vec2.prototype.SetV = function (v) { + this.x = v.x; + this.y = v.y; + } + b2Vec2.prototype.GetNegative = function () { + return new b2Vec2((-this.x), (-this.y)); + } + b2Vec2.prototype.NegativeSelf = function () { + this.x = (-this.x); + this.y = (-this.y); + } + b2Vec2.Make = function (x_, y_) { + if (x_ === undefined) x_ = 0; + if (y_ === undefined) y_ = 0; + return new b2Vec2(x_, y_); + } + b2Vec2.prototype.Copy = function () { + return new b2Vec2(this.x, this.y); + } + b2Vec2.prototype.Add = function (v) { + this.x += v.x; + this.y += v.y; + } + b2Vec2.prototype.Subtract = function (v) { + this.x -= v.x; + this.y -= v.y; + } + b2Vec2.prototype.Multiply = function (a) { + if (a === undefined) a = 0; + this.x *= a; + this.y *= a; + } + b2Vec2.prototype.MulM = function (A) { + var tX = this.x; + this.x = A.col1.x * tX + A.col2.x * this.y; + this.y = A.col1.y * tX + A.col2.y * this.y; + } + b2Vec2.prototype.MulTM = function (A) { + var tX = b2Math.Dot(this, A.col1); + this.y = b2Math.Dot(this, A.col2); + this.x = tX; + } + b2Vec2.prototype.CrossVF = function (s) { + if (s === undefined) s = 0; + var tX = this.x; + this.x = s * this.y; + this.y = (-s * tX); + } + b2Vec2.prototype.CrossFV = function (s) { + if (s === undefined) s = 0; + var tX = this.x; + this.x = (-s * this.y); + this.y = s * tX; + } + b2Vec2.prototype.MinV = function (b) { + this.x = this.x < b.x ? this.x : b.x; + this.y = this.y < b.y ? this.y : b.y; + } + b2Vec2.prototype.MaxV = function (b) { + this.x = this.x > b.x ? this.x : b.x; + this.y = this.y > b.y ? this.y : b.y; + } + b2Vec2.prototype.Abs = function () { + if (this.x < 0) this.x = (-this.x); + if (this.y < 0) this.y = (-this.y); + } + b2Vec2.prototype.Length = function () { + return Math.sqrt(this.x * this.x + this.y * this.y); + } + b2Vec2.prototype.LengthSquared = function () { + return (this.x * this.x + this.y * this.y); + } + b2Vec2.prototype.Normalize = function () { + var length = Math.sqrt(this.x * this.x + this.y * this.y); + if (length < Number.MIN_VALUE) { + return 0.0; + } + var invLength = 1.0 / length; + this.x *= invLength; + this.y *= invLength; + return length; + } + b2Vec2.prototype.IsValid = function () { + return b2Math.IsValid(this.x) && b2Math.IsValid(this.y); + } + b2Vec3.b2Vec3 = function () {}; + b2Vec3.prototype.b2Vec3 = function (x, y, z) { + if (x === undefined) x = 0; + if (y === undefined) y = 0; + if (z === undefined) z = 0; + this.x = x; + this.y = y; + this.z = z; + } + b2Vec3.prototype.SetZero = function () { + this.x = this.y = this.z = 0.0; + } + b2Vec3.prototype.Set = function (x, y, z) { + if (x === undefined) x = 0; + if (y === undefined) y = 0; + if (z === undefined) z = 0; + this.x = x; + this.y = y; + this.z = z; + } + b2Vec3.prototype.SetV = function (v) { + this.x = v.x; + this.y = v.y; + this.z = v.z; + } + b2Vec3.prototype.GetNegative = function () { + return new b2Vec3((-this.x), (-this.y), (-this.z)); + } + b2Vec3.prototype.NegativeSelf = function () { + this.x = (-this.x); + this.y = (-this.y); + this.z = (-this.z); + } + b2Vec3.prototype.Copy = function () { + return new b2Vec3(this.x, this.y, this.z); + } + b2Vec3.prototype.Add = function (v) { + this.x += v.x; + this.y += v.y; + this.z += v.z; + } + b2Vec3.prototype.Subtract = function (v) { + this.x -= v.x; + this.y -= v.y; + this.z -= v.z; + } + b2Vec3.prototype.Multiply = function (a) { + if (a === undefined) a = 0; + this.x *= a; + this.y *= a; + this.z *= a; + } +})(); +(function () { + var b2ControllerEdge = Box2D.Dynamics.Controllers.b2ControllerEdge, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3, + b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2AABB = Box2D.Collision.b2AABB, + b2Bound = Box2D.Collision.b2Bound, + b2BoundValues = Box2D.Collision.b2BoundValues, + b2Collision = Box2D.Collision.b2Collision, + b2ContactID = Box2D.Collision.b2ContactID, + b2ContactPoint = Box2D.Collision.b2ContactPoint, + b2Distance = Box2D.Collision.b2Distance, + b2DistanceInput = Box2D.Collision.b2DistanceInput, + b2DistanceOutput = Box2D.Collision.b2DistanceOutput, + b2DistanceProxy = Box2D.Collision.b2DistanceProxy, + b2DynamicTree = Box2D.Collision.b2DynamicTree, + b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase, + b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode, + b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair, + b2Manifold = Box2D.Collision.b2Manifold, + b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint, + b2Point = Box2D.Collision.b2Point, + b2RayCastInput = Box2D.Collision.b2RayCastInput, + b2RayCastOutput = Box2D.Collision.b2RayCastOutput, + b2Segment = Box2D.Collision.b2Segment, + b2SeparationFunction = Box2D.Collision.b2SeparationFunction, + b2Simplex = Box2D.Collision.b2Simplex, + b2SimplexCache = Box2D.Collision.b2SimplexCache, + b2SimplexVertex = Box2D.Collision.b2SimplexVertex, + b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact, + b2TOIInput = Box2D.Collision.b2TOIInput, + b2WorldManifold = Box2D.Collision.b2WorldManifold, + ClipVertex = Box2D.Collision.ClipVertex, + Features = Box2D.Collision.Features, + IBroadPhase = Box2D.Collision.IBroadPhase, + b2CircleShape = Box2D.Collision.Shapes.b2CircleShape, + b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef, + b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape, + b2MassData = Box2D.Collision.Shapes.b2MassData, + b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape, + b2Shape = Box2D.Collision.Shapes.b2Shape, + b2Body = Box2D.Dynamics.b2Body, + b2BodyDef = Box2D.Dynamics.b2BodyDef, + b2ContactFilter = Box2D.Dynamics.b2ContactFilter, + b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse, + b2ContactListener = Box2D.Dynamics.b2ContactListener, + b2ContactManager = Box2D.Dynamics.b2ContactManager, + b2DebugDraw = Box2D.Dynamics.b2DebugDraw, + b2DestructionListener = Box2D.Dynamics.b2DestructionListener, + b2FilterData = Box2D.Dynamics.b2FilterData, + b2Fixture = Box2D.Dynamics.b2Fixture, + b2FixtureDef = Box2D.Dynamics.b2FixtureDef, + b2Island = Box2D.Dynamics.b2Island, + b2TimeStep = Box2D.Dynamics.b2TimeStep, + b2World = Box2D.Dynamics.b2World, + b2CircleContact = Box2D.Dynamics.Contacts.b2CircleContact, + b2Contact = Box2D.Dynamics.Contacts.b2Contact, + b2ContactConstraint = Box2D.Dynamics.Contacts.b2ContactConstraint, + b2ContactConstraintPoint = Box2D.Dynamics.Contacts.b2ContactConstraintPoint, + b2ContactEdge = Box2D.Dynamics.Contacts.b2ContactEdge, + b2ContactFactory = Box2D.Dynamics.Contacts.b2ContactFactory, + b2ContactRegister = Box2D.Dynamics.Contacts.b2ContactRegister, + b2ContactResult = Box2D.Dynamics.Contacts.b2ContactResult, + b2ContactSolver = Box2D.Dynamics.Contacts.b2ContactSolver, + b2EdgeAndCircleContact = Box2D.Dynamics.Contacts.b2EdgeAndCircleContact, + b2NullContact = Box2D.Dynamics.Contacts.b2NullContact, + b2PolyAndCircleContact = Box2D.Dynamics.Contacts.b2PolyAndCircleContact, + b2PolyAndEdgeContact = Box2D.Dynamics.Contacts.b2PolyAndEdgeContact, + b2PolygonContact = Box2D.Dynamics.Contacts.b2PolygonContact, + b2PositionSolverManifold = Box2D.Dynamics.Contacts.b2PositionSolverManifold, + b2Controller = Box2D.Dynamics.Controllers.b2Controller, + b2DistanceJoint = Box2D.Dynamics.Joints.b2DistanceJoint, + b2DistanceJointDef = Box2D.Dynamics.Joints.b2DistanceJointDef, + b2FrictionJoint = Box2D.Dynamics.Joints.b2FrictionJoint, + b2FrictionJointDef = Box2D.Dynamics.Joints.b2FrictionJointDef, + b2GearJoint = Box2D.Dynamics.Joints.b2GearJoint, + b2GearJointDef = Box2D.Dynamics.Joints.b2GearJointDef, + b2Jacobian = Box2D.Dynamics.Joints.b2Jacobian, + b2Joint = Box2D.Dynamics.Joints.b2Joint, + b2JointDef = Box2D.Dynamics.Joints.b2JointDef, + b2JointEdge = Box2D.Dynamics.Joints.b2JointEdge, + b2LineJoint = Box2D.Dynamics.Joints.b2LineJoint, + b2LineJointDef = Box2D.Dynamics.Joints.b2LineJointDef, + b2MouseJoint = Box2D.Dynamics.Joints.b2MouseJoint, + b2MouseJointDef = Box2D.Dynamics.Joints.b2MouseJointDef, + b2PrismaticJoint = Box2D.Dynamics.Joints.b2PrismaticJoint, + b2PrismaticJointDef = Box2D.Dynamics.Joints.b2PrismaticJointDef, + b2PulleyJoint = Box2D.Dynamics.Joints.b2PulleyJoint, + b2PulleyJointDef = Box2D.Dynamics.Joints.b2PulleyJointDef, + b2RevoluteJoint = Box2D.Dynamics.Joints.b2RevoluteJoint, + b2RevoluteJointDef = Box2D.Dynamics.Joints.b2RevoluteJointDef, + b2WeldJoint = Box2D.Dynamics.Joints.b2WeldJoint, + b2WeldJointDef = Box2D.Dynamics.Joints.b2WeldJointDef; + + b2Body.b2Body = function () { + this.m_xf = new b2Transform(); + this.m_sweep = new b2Sweep(); + this.m_linearVelocity = new b2Vec2(); + this.m_force = new b2Vec2(); + }; + b2Body.prototype.connectEdges = function (s1, s2, angle1) { + if (angle1 === undefined) angle1 = 0; + var angle2 = Math.atan2(s2.GetDirectionVector().y, s2.GetDirectionVector().x); + var coreOffset = Math.tan((angle2 - angle1) * 0.5); + var core = b2Math.MulFV(coreOffset, s2.GetDirectionVector()); + core = b2Math.SubtractVV(core, s2.GetNormalVector()); + core = b2Math.MulFV(b2Settings.b2_toiSlop, core); + core = b2Math.AddVV(core, s2.GetVertex1()); + var cornerDir = b2Math.AddVV(s1.GetDirectionVector(), s2.GetDirectionVector()); + cornerDir.Normalize(); + var convex = b2Math.Dot(s1.GetDirectionVector(), s2.GetNormalVector()) > 0.0; + s1.SetNextEdge(s2, core, cornerDir, convex); + s2.SetPrevEdge(s1, core, cornerDir, convex); + return angle2; + } + b2Body.prototype.CreateFixture = function (def) { + if (this.m_world.IsLocked() == true) { + return null; + } + var fixture = new b2Fixture(); + fixture.Create(this, this.m_xf, def); + if (this.m_flags & b2Body.e_activeFlag) { + var broadPhase = this.m_world.m_contactManager.m_broadPhase; + fixture.CreateProxy(broadPhase, this.m_xf); + } + fixture.m_next = this.m_fixtureList; + this.m_fixtureList = fixture; + ++this.m_fixtureCount; + fixture.m_body = this; + if (fixture.m_density > 0.0) { + this.ResetMassData(); + } + this.m_world.m_flags |= b2World.e_newFixture; + return fixture; + } + b2Body.prototype.CreateFixture2 = function (shape, density) { + if (density === undefined) density = 0.0; + var def = new b2FixtureDef(); + def.shape = shape; + def.density = density; + return this.CreateFixture(def); + } + b2Body.prototype.DestroyFixture = function (fixture) { + if (this.m_world.IsLocked() == true) { + return; + } + var node = this.m_fixtureList; + var ppF = null; + var found = false; + while (node != null) { + if (node == fixture) { + if (ppF) ppF.m_next = fixture.m_next; + else this.m_fixtureList = fixture.m_next; + found = true; + break; + } + ppF = node; + node = node.m_next; + } + var edge = this.m_contactList; + while (edge) { + var c = edge.contact; + edge = edge.next; + var fixtureA = c.GetFixtureA(); + var fixtureB = c.GetFixtureB(); + if (fixture == fixtureA || fixture == fixtureB) { + this.m_world.m_contactManager.Destroy(c); + } + } + if (this.m_flags & b2Body.e_activeFlag) { + var broadPhase = this.m_world.m_contactManager.m_broadPhase; + fixture.DestroyProxy(broadPhase); + } + else {} + fixture.Destroy(); + fixture.m_body = null; + fixture.m_next = null; + --this.m_fixtureCount; + this.ResetMassData(); + } + b2Body.prototype.SetPositionAndAngle = function (position, angle) { + if (angle === undefined) angle = 0; + var f; + if (this.m_world.IsLocked() == true) { + return; + } + this.m_xf.R.Set(angle); + this.m_xf.position.SetV(position); + var tMat = this.m_xf.R; + var tVec = this.m_sweep.localCenter; + this.m_sweep.c.x = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + this.m_sweep.c.y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + this.m_sweep.c.x += this.m_xf.position.x; + this.m_sweep.c.y += this.m_xf.position.y; + this.m_sweep.c0.SetV(this.m_sweep.c); + this.m_sweep.a0 = this.m_sweep.a = angle; + var broadPhase = this.m_world.m_contactManager.m_broadPhase; + for (f = this.m_fixtureList; + f; f = f.m_next) { + f.Synchronize(broadPhase, this.m_xf, this.m_xf); + } + this.m_world.m_contactManager.FindNewContacts(); + } + b2Body.prototype.SetTransform = function (xf) { + this.SetPositionAndAngle(xf.position, xf.GetAngle()); + } + b2Body.prototype.GetTransform = function () { + return this.m_xf; + } + b2Body.prototype.GetPosition = function () { + return this.m_xf.position; + } + b2Body.prototype.SetPosition = function (position) { + this.SetPositionAndAngle(position, this.GetAngle()); + } + b2Body.prototype.GetAngle = function () { + return this.m_sweep.a; + } + b2Body.prototype.SetAngle = function (angle) { + if (angle === undefined) angle = 0; + this.SetPositionAndAngle(this.GetPosition(), angle); + } + b2Body.prototype.GetWorldCenter = function () { + return this.m_sweep.c; + } + b2Body.prototype.GetLocalCenter = function () { + return this.m_sweep.localCenter; + } + b2Body.prototype.SetLinearVelocity = function (v) { + if (this.m_type == b2Body.b2_staticBody) { + return; + } + this.m_linearVelocity.SetV(v); + } + b2Body.prototype.GetLinearVelocity = function () { + return this.m_linearVelocity; + } + b2Body.prototype.SetAngularVelocity = function (omega) { + if (omega === undefined) omega = 0; + if (this.m_type == b2Body.b2_staticBody) { + return; + } + this.m_angularVelocity = omega; + } + b2Body.prototype.GetAngularVelocity = function () { + return this.m_angularVelocity; + } + b2Body.prototype.GetDefinition = function () { + var bd = new b2BodyDef(); + bd.type = this.GetType(); + bd.allowSleep = (this.m_flags & b2Body.e_allowSleepFlag) == b2Body.e_allowSleepFlag; + bd.angle = this.GetAngle(); + bd.angularDamping = this.m_angularDamping; + bd.angularVelocity = this.m_angularVelocity; + bd.fixedRotation = (this.m_flags & b2Body.e_fixedRotationFlag) == b2Body.e_fixedRotationFlag; + bd.bullet = (this.m_flags & b2Body.e_bulletFlag) == b2Body.e_bulletFlag; + bd.awake = (this.m_flags & b2Body.e_awakeFlag) == b2Body.e_awakeFlag; + bd.linearDamping = this.m_linearDamping; + bd.linearVelocity.SetV(this.GetLinearVelocity()); + bd.position = this.GetPosition(); + bd.userData = this.GetUserData(); + return bd; + } + b2Body.prototype.ApplyForce = function (force, point) { + if (this.m_type != b2Body.b2_dynamicBody) { + return; + } + if (this.IsAwake() == false) { + this.SetAwake(true); + } + this.m_force.x += force.x; + this.m_force.y += force.y; + this.m_torque += ((point.x - this.m_sweep.c.x) * force.y - (point.y - this.m_sweep.c.y) * force.x); + } + b2Body.prototype.ApplyTorque = function (torque) { + if (torque === undefined) torque = 0; + if (this.m_type != b2Body.b2_dynamicBody) { + return; + } + if (this.IsAwake() == false) { + this.SetAwake(true); + } + this.m_torque += torque; + } + b2Body.prototype.ApplyImpulse = function (impulse, point) { + if (this.m_type != b2Body.b2_dynamicBody) { + return; + } + if (this.IsAwake() == false) { + this.SetAwake(true); + } + this.m_linearVelocity.x += this.m_invMass * impulse.x; + this.m_linearVelocity.y += this.m_invMass * impulse.y; + this.m_angularVelocity += this.m_invI * ((point.x - this.m_sweep.c.x) * impulse.y - (point.y - this.m_sweep.c.y) * impulse.x); + } + b2Body.prototype.Split = function (callback) { + var linearVelocity = this.GetLinearVelocity().Copy(); + var angularVelocity = this.GetAngularVelocity(); + var center = this.GetWorldCenter(); + var body1 = this; + var body2 = this.m_world.CreateBody(this.GetDefinition()); + var prev; + for (var f = body1.m_fixtureList; f;) { + if (callback(f)) { + var next = f.m_next; + if (prev) { + prev.m_next = next; + } + else { + body1.m_fixtureList = next; + } + body1.m_fixtureCount--; + f.m_next = body2.m_fixtureList; + body2.m_fixtureList = f; + body2.m_fixtureCount++; + f.m_body = body2; + f = next; + } + else { + prev = f; + f = f.m_next; + } + } + body1.ResetMassData(); + body2.ResetMassData(); + var center1 = body1.GetWorldCenter(); + var center2 = body2.GetWorldCenter(); + var velocity1 = b2Math.AddVV(linearVelocity, b2Math.CrossFV(angularVelocity, b2Math.SubtractVV(center1, center))); + var velocity2 = b2Math.AddVV(linearVelocity, b2Math.CrossFV(angularVelocity, b2Math.SubtractVV(center2, center))); + body1.SetLinearVelocity(velocity1); + body2.SetLinearVelocity(velocity2); + body1.SetAngularVelocity(angularVelocity); + body2.SetAngularVelocity(angularVelocity); + body1.SynchronizeFixtures(); + body2.SynchronizeFixtures(); + return body2; + } + b2Body.prototype.Merge = function (other) { + var f; + for (f = other.m_fixtureList; + f;) { + var next = f.m_next; + other.m_fixtureCount--; + f.m_next = this.m_fixtureList; + this.m_fixtureList = f; + this.m_fixtureCount++; + f.m_body = body2; + f = next; + } + body1.m_fixtureCount = 0; + var body1 = this; + + var body2 = other; + var center1 = body1.GetWorldCenter(); + var center2 = body2.GetWorldCenter(); + var velocity1 = body1.GetLinearVelocity().Copy(); + var velocity2 = body2.GetLinearVelocity().Copy(); + var angular1 = body1.GetAngularVelocity(); + var angular = body2.GetAngularVelocity(); + body1.ResetMassData(); + this.SynchronizeFixtures(); + } + b2Body.prototype.GetMass = function () { + return this.m_mass; + } + b2Body.prototype.GetInertia = function () { + return this.m_I; + } + b2Body.prototype.GetMassData = function (data) { + data.mass = this.m_mass; + data.I = this.m_I; + data.center.SetV(this.m_sweep.localCenter); + } + b2Body.prototype.SetMassData = function (massData) { + b2Settings.b2Assert(this.m_world.IsLocked() == false); + if (this.m_world.IsLocked() == true) { + return; + } + if (this.m_type != b2Body.b2_dynamicBody) { + return; + } + this.m_invMass = 0.0; + this.m_I = 0.0; + this.m_invI = 0.0; + this.m_mass = massData.mass; + if (this.m_mass <= 0.0) { + this.m_mass = 1.0; + } + this.m_invMass = 1.0 / this.m_mass; + if (massData.I > 0.0 && (this.m_flags & b2Body.e_fixedRotationFlag) == 0) { + this.m_I = massData.I - this.m_mass * (massData.center.x * massData.center.x + massData.center.y * massData.center.y); + this.m_invI = 1.0 / this.m_I; + } + var oldCenter = this.m_sweep.c.Copy(); + this.m_sweep.localCenter.SetV(massData.center); + this.m_sweep.c0.SetV(b2Math.MulX(this.m_xf, this.m_sweep.localCenter)); + this.m_sweep.c.SetV(this.m_sweep.c0); + this.m_linearVelocity.x += this.m_angularVelocity * (-(this.m_sweep.c.y - oldCenter.y)); + this.m_linearVelocity.y += this.m_angularVelocity * (+(this.m_sweep.c.x - oldCenter.x)); + } + b2Body.prototype.ResetMassData = function () { + this.m_mass = 0.0; + this.m_invMass = 0.0; + this.m_I = 0.0; + this.m_invI = 0.0; + this.m_sweep.localCenter.SetZero(); + if (this.m_type == b2Body.b2_staticBody || this.m_type == b2Body.b2_kinematicBody) { + return; + } + var center = b2Vec2.Make(0, 0); + for (var f = this.m_fixtureList; f; f = f.m_next) { + if (f.m_density == 0.0) { + continue; + } + var massData = f.GetMassData(); + this.m_mass += massData.mass; + center.x += massData.center.x * massData.mass; + center.y += massData.center.y * massData.mass; + this.m_I += massData.I; + } + if (this.m_mass > 0.0) { + this.m_invMass = 1.0 / this.m_mass; + center.x *= this.m_invMass; + center.y *= this.m_invMass; + } + else { + this.m_mass = 1.0; + this.m_invMass = 1.0; + } + if (this.m_I > 0.0 && (this.m_flags & b2Body.e_fixedRotationFlag) == 0) { + this.m_I -= this.m_mass * (center.x * center.x + center.y * center.y); + this.m_I *= this.m_inertiaScale; + b2Settings.b2Assert(this.m_I > 0); + this.m_invI = 1.0 / this.m_I; + } + else { + this.m_I = 0.0; + this.m_invI = 0.0; + } + var oldCenter = this.m_sweep.c.Copy(); + this.m_sweep.localCenter.SetV(center); + this.m_sweep.c0.SetV(b2Math.MulX(this.m_xf, this.m_sweep.localCenter)); + this.m_sweep.c.SetV(this.m_sweep.c0); + this.m_linearVelocity.x += this.m_angularVelocity * (-(this.m_sweep.c.y - oldCenter.y)); + this.m_linearVelocity.y += this.m_angularVelocity * (+(this.m_sweep.c.x - oldCenter.x)); + } + b2Body.prototype.GetWorldPoint = function (localPoint) { + var A = this.m_xf.R; + var u = new b2Vec2(A.col1.x * localPoint.x + A.col2.x * localPoint.y, A.col1.y * localPoint.x + A.col2.y * localPoint.y); + u.x += this.m_xf.position.x; + u.y += this.m_xf.position.y; + return u; + } + b2Body.prototype.GetWorldVector = function (localVector) { + return b2Math.MulMV(this.m_xf.R, localVector); + } + b2Body.prototype.GetLocalPoint = function (worldPoint) { + return b2Math.MulXT(this.m_xf, worldPoint); + } + b2Body.prototype.GetLocalVector = function (worldVector) { + return b2Math.MulTMV(this.m_xf.R, worldVector); + } + b2Body.prototype.GetLinearVelocityFromWorldPoint = function (worldPoint) { + return new b2Vec2(this.m_linearVelocity.x - this.m_angularVelocity * (worldPoint.y - this.m_sweep.c.y), this.m_linearVelocity.y + this.m_angularVelocity * (worldPoint.x - this.m_sweep.c.x)); + } + b2Body.prototype.GetLinearVelocityFromLocalPoint = function (localPoint) { + var A = this.m_xf.R; + var worldPoint = new b2Vec2(A.col1.x * localPoint.x + A.col2.x * localPoint.y, A.col1.y * localPoint.x + A.col2.y * localPoint.y); + worldPoint.x += this.m_xf.position.x; + worldPoint.y += this.m_xf.position.y; + return new b2Vec2(this.m_linearVelocity.x - this.m_angularVelocity * (worldPoint.y - this.m_sweep.c.y), this.m_linearVelocity.y + this.m_angularVelocity * (worldPoint.x - this.m_sweep.c.x)); + } + b2Body.prototype.GetLinearDamping = function () { + return this.m_linearDamping; + } + b2Body.prototype.SetLinearDamping = function (linearDamping) { + if (linearDamping === undefined) linearDamping = 0; + this.m_linearDamping = linearDamping; + } + b2Body.prototype.GetAngularDamping = function () { + return this.m_angularDamping; + } + b2Body.prototype.SetAngularDamping = function (angularDamping) { + if (angularDamping === undefined) angularDamping = 0; + this.m_angularDamping = angularDamping; + } + b2Body.prototype.SetType = function (type) { + if (type === undefined) type = 0; + if (this.m_type == type) { + return; + } + this.m_type = type; + this.ResetMassData(); + if (this.m_type == b2Body.b2_staticBody) { + this.m_linearVelocity.SetZero(); + this.m_angularVelocity = 0.0; + } + this.SetAwake(true); + this.m_force.SetZero(); + this.m_torque = 0.0; + for (var ce = this.m_contactList; ce; ce = ce.next) { + ce.contact.FlagForFiltering(); + } + } + b2Body.prototype.GetType = function () { + return this.m_type; + } + b2Body.prototype.SetBullet = function (flag) { + if (flag) { + this.m_flags |= b2Body.e_bulletFlag; + } + else { + this.m_flags &= ~b2Body.e_bulletFlag; + } + } + b2Body.prototype.IsBullet = function () { + return (this.m_flags & b2Body.e_bulletFlag) == b2Body.e_bulletFlag; + } + b2Body.prototype.SetSleepingAllowed = function (flag) { + if (flag) { + this.m_flags |= b2Body.e_allowSleepFlag; + } + else { + this.m_flags &= ~b2Body.e_allowSleepFlag; + this.SetAwake(true); + } + } + b2Body.prototype.SetAwake = function (flag) { + if (flag) { + this.m_flags |= b2Body.e_awakeFlag; + this.m_sleepTime = 0.0; + } + else { + this.m_flags &= ~b2Body.e_awakeFlag; + this.m_sleepTime = 0.0; + this.m_linearVelocity.SetZero(); + this.m_angularVelocity = 0.0; + this.m_force.SetZero(); + this.m_torque = 0.0; + } + } + b2Body.prototype.IsAwake = function () { + return (this.m_flags & b2Body.e_awakeFlag) == b2Body.e_awakeFlag; + } + b2Body.prototype.SetFixedRotation = function (fixed) { + if (fixed) { + this.m_flags |= b2Body.e_fixedRotationFlag; + } + else { + this.m_flags &= ~b2Body.e_fixedRotationFlag; + } + this.ResetMassData(); + } + b2Body.prototype.IsFixedRotation = function () { + return (this.m_flags & b2Body.e_fixedRotationFlag) == b2Body.e_fixedRotationFlag; + } + b2Body.prototype.SetActive = function (flag) { + if (flag == this.IsActive()) { + return; + } + var broadPhase; + var f; + if (flag) { + this.m_flags |= b2Body.e_activeFlag; + broadPhase = this.m_world.m_contactManager.m_broadPhase; + for (f = this.m_fixtureList; + f; f = f.m_next) { + f.CreateProxy(broadPhase, this.m_xf); + } + } + else { + this.m_flags &= ~b2Body.e_activeFlag; + broadPhase = this.m_world.m_contactManager.m_broadPhase; + for (f = this.m_fixtureList; + f; f = f.m_next) { + f.DestroyProxy(broadPhase); + } + var ce = this.m_contactList; + while (ce) { + var ce0 = ce; + ce = ce.next; + this.m_world.m_contactManager.Destroy(ce0.contact); + } + this.m_contactList = null; + } + } + b2Body.prototype.IsActive = function () { + return (this.m_flags & b2Body.e_activeFlag) == b2Body.e_activeFlag; + } + b2Body.prototype.IsSleepingAllowed = function () { + return (this.m_flags & b2Body.e_allowSleepFlag) == b2Body.e_allowSleepFlag; + } + b2Body.prototype.GetFixtureList = function () { + return this.m_fixtureList; + } + b2Body.prototype.GetJointList = function () { + return this.m_jointList; + } + b2Body.prototype.GetControllerList = function () { + return this.m_controllerList; + } + b2Body.prototype.GetContactList = function () { + return this.m_contactList; + } + b2Body.prototype.GetNext = function () { + return this.m_next; + } + b2Body.prototype.GetUserData = function () { + return this.m_userData; + } + b2Body.prototype.SetUserData = function (data) { + this.m_userData = data; + } + b2Body.prototype.GetWorld = function () { + return this.m_world; + } + b2Body.prototype.b2Body = function (bd, world) { + this.m_flags = 0; + if (bd.bullet) { + this.m_flags |= b2Body.e_bulletFlag; + } + if (bd.fixedRotation) { + this.m_flags |= b2Body.e_fixedRotationFlag; + } + if (bd.allowSleep) { + this.m_flags |= b2Body.e_allowSleepFlag; + } + if (bd.awake) { + this.m_flags |= b2Body.e_awakeFlag; + } + if (bd.active) { + this.m_flags |= b2Body.e_activeFlag; + } + this.m_world = world; + this.m_xf.position.SetV(bd.position); + this.m_xf.R.Set(bd.angle); + this.m_sweep.localCenter.SetZero(); + this.m_sweep.t0 = 1.0; + this.m_sweep.a0 = this.m_sweep.a = bd.angle; + var tMat = this.m_xf.R; + var tVec = this.m_sweep.localCenter; + this.m_sweep.c.x = (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + this.m_sweep.c.y = (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + this.m_sweep.c.x += this.m_xf.position.x; + this.m_sweep.c.y += this.m_xf.position.y; + this.m_sweep.c0.SetV(this.m_sweep.c); + this.m_jointList = null; + this.m_controllerList = null; + this.m_contactList = null; + this.m_controllerCount = 0; + this.m_prev = null; + this.m_next = null; + this.m_linearVelocity.SetV(bd.linearVelocity); + this.m_angularVelocity = bd.angularVelocity; + this.m_linearDamping = bd.linearDamping; + this.m_angularDamping = bd.angularDamping; + this.m_force.Set(0.0, 0.0); + this.m_torque = 0.0; + this.m_sleepTime = 0.0; + this.m_type = bd.type; + if (this.m_type == b2Body.b2_dynamicBody) { + this.m_mass = 1.0; + this.m_invMass = 1.0; + } + else { + this.m_mass = 0.0; + this.m_invMass = 0.0; + } + this.m_I = 0.0; + this.m_invI = 0.0; + this.m_inertiaScale = bd.inertiaScale; + this.m_userData = bd.userData; + this.m_fixtureList = null; + this.m_fixtureCount = 0; + } + b2Body.prototype.SynchronizeFixtures = function () { + var xf1 = b2Body.s_xf1; + xf1.R.Set(this.m_sweep.a0); + var tMat = xf1.R; + var tVec = this.m_sweep.localCenter; + xf1.position.x = this.m_sweep.c0.x - (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + xf1.position.y = this.m_sweep.c0.y - (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + var f; + var broadPhase = this.m_world.m_contactManager.m_broadPhase; + for (f = this.m_fixtureList; + f; f = f.m_next) { + f.Synchronize(broadPhase, xf1, this.m_xf); + } + } + b2Body.prototype.SynchronizeTransform = function () { + this.m_xf.R.Set(this.m_sweep.a); + var tMat = this.m_xf.R; + var tVec = this.m_sweep.localCenter; + this.m_xf.position.x = this.m_sweep.c.x - (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + this.m_xf.position.y = this.m_sweep.c.y - (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + } + b2Body.prototype.ShouldCollide = function (other) { + if (this.m_type != b2Body.b2_dynamicBody && other.m_type != b2Body.b2_dynamicBody) { + return false; + } + for (var jn = this.m_jointList; jn; jn = jn.next) { + if (jn.other == other) if (jn.joint.m_collideConnected == false) { + return false; + } + } + return true; + } + b2Body.prototype.Advance = function (t) { + if (t === undefined) t = 0; + this.m_sweep.Advance(t); + this.m_sweep.c.SetV(this.m_sweep.c0); + this.m_sweep.a = this.m_sweep.a0; + this.SynchronizeTransform(); + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.b2Body.s_xf1 = new b2Transform(); + Box2D.Dynamics.b2Body.e_islandFlag = 0x0001; + Box2D.Dynamics.b2Body.e_awakeFlag = 0x0002; + Box2D.Dynamics.b2Body.e_allowSleepFlag = 0x0004; + Box2D.Dynamics.b2Body.e_bulletFlag = 0x0008; + Box2D.Dynamics.b2Body.e_fixedRotationFlag = 0x0010; + Box2D.Dynamics.b2Body.e_activeFlag = 0x0020; + Box2D.Dynamics.b2Body.b2_staticBody = 0; + Box2D.Dynamics.b2Body.b2_kinematicBody = 1; + Box2D.Dynamics.b2Body.b2_dynamicBody = 2; + }); + b2BodyDef.b2BodyDef = function () { + this.position = new b2Vec2(); + this.linearVelocity = new b2Vec2(); + }; + b2BodyDef.prototype.b2BodyDef = function () { + this.userData = null; + this.position.Set(0.0, 0.0); + this.angle = 0.0; + this.linearVelocity.Set(0, 0); + this.angularVelocity = 0.0; + this.linearDamping = 0.0; + this.angularDamping = 0.0; + this.allowSleep = true; + this.awake = true; + this.fixedRotation = false; + this.bullet = false; + this.type = b2Body.b2_staticBody; + this.active = true; + this.inertiaScale = 1.0; + } + b2ContactFilter.b2ContactFilter = function () {}; + b2ContactFilter.prototype.ShouldCollide = function (fixtureA, fixtureB) { + var filter1 = fixtureA.GetFilterData(); + var filter2 = fixtureB.GetFilterData(); + if (filter1.groupIndex == filter2.groupIndex && filter1.groupIndex != 0) { + return filter1.groupIndex > 0; + } + var collide = (filter1.maskBits & filter2.categoryBits) != 0 && (filter1.categoryBits & filter2.maskBits) != 0; + return collide; + } + b2ContactFilter.prototype.RayCollide = function (userData, fixture) { + if (!userData) return true; + return this.ShouldCollide((userData instanceof b2Fixture ? userData : null), fixture); + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.b2ContactFilter.b2_defaultFilter = new b2ContactFilter(); + }); + b2ContactImpulse.b2ContactImpulse = function () { + this.normalImpulses = new Vector_a2j_Number(b2Settings.b2_maxManifoldPoints); + this.tangentImpulses = new Vector_a2j_Number(b2Settings.b2_maxManifoldPoints); + }; + b2ContactListener.b2ContactListener = function () {}; + b2ContactListener.prototype.BeginContact = function (contact) {} + b2ContactListener.prototype.EndContact = function (contact) {} + b2ContactListener.prototype.PreSolve = function (contact, oldManifold) {} + b2ContactListener.prototype.PostSolve = function (contact, impulse) {} + Box2D.postDefs.push(function () { + Box2D.Dynamics.b2ContactListener.b2_defaultListener = new b2ContactListener(); + }); + b2ContactManager.b2ContactManager = function () {}; + b2ContactManager.prototype.b2ContactManager = function () { + this.m_world = null; + this.m_contactCount = 0; + this.m_contactFilter = b2ContactFilter.b2_defaultFilter; + this.m_contactListener = b2ContactListener.b2_defaultListener; + this.m_contactFactory = new b2ContactFactory(this.m_allocator); + this.m_broadPhase = new b2DynamicTreeBroadPhase(); + } + b2ContactManager.prototype.AddPair = function (proxyUserDataA, proxyUserDataB) { + var fixtureA = (proxyUserDataA instanceof b2Fixture ? proxyUserDataA : null); + var fixtureB = (proxyUserDataB instanceof b2Fixture ? proxyUserDataB : null); + var bodyA = fixtureA.GetBody(); + var bodyB = fixtureB.GetBody(); + if (bodyA == bodyB) return; + var edge = bodyB.GetContactList(); + while (edge) { + if (edge.other == bodyA) { + var fA = edge.contact.GetFixtureA(); + var fB = edge.contact.GetFixtureB(); + if (fA == fixtureA && fB == fixtureB) return; + if (fA == fixtureB && fB == fixtureA) return; + } + edge = edge.next; + } + if (bodyB.ShouldCollide(bodyA) == false) { + return; + } + if (this.m_contactFilter.ShouldCollide(fixtureA, fixtureB) == false) { + return; + } + var c = this.m_contactFactory.Create(fixtureA, fixtureB); + fixtureA = c.GetFixtureA(); + fixtureB = c.GetFixtureB(); + bodyA = fixtureA.m_body; + bodyB = fixtureB.m_body; + c.m_prev = null; + c.m_next = this.m_world.m_contactList; + if (this.m_world.m_contactList != null) { + this.m_world.m_contactList.m_prev = c; + } + this.m_world.m_contactList = c; + c.m_nodeA.contact = c; + c.m_nodeA.other = bodyB; + c.m_nodeA.prev = null; + c.m_nodeA.next = bodyA.m_contactList; + if (bodyA.m_contactList != null) { + bodyA.m_contactList.prev = c.m_nodeA; + } + bodyA.m_contactList = c.m_nodeA; + c.m_nodeB.contact = c; + c.m_nodeB.other = bodyA; + c.m_nodeB.prev = null; + c.m_nodeB.next = bodyB.m_contactList; + if (bodyB.m_contactList != null) { + bodyB.m_contactList.prev = c.m_nodeB; + } + bodyB.m_contactList = c.m_nodeB; + ++this.m_world.m_contactCount; + return; + } + b2ContactManager.prototype.FindNewContacts = function () { + this.m_broadPhase.UpdatePairs(Box2D.generateCallback(this, this.AddPair)); + } + b2ContactManager.prototype.Destroy = function (c) { + var fixtureA = c.GetFixtureA(); + var fixtureB = c.GetFixtureB(); + var bodyA = fixtureA.GetBody(); + var bodyB = fixtureB.GetBody(); + if (c.IsTouching()) { + this.m_contactListener.EndContact(c); + } + if (c.m_prev) { + c.m_prev.m_next = c.m_next; + } + if (c.m_next) { + c.m_next.m_prev = c.m_prev; + } + if (c == this.m_world.m_contactList) { + this.m_world.m_contactList = c.m_next; + } + if (c.m_nodeA.prev) { + c.m_nodeA.prev.next = c.m_nodeA.next; + } + if (c.m_nodeA.next) { + c.m_nodeA.next.prev = c.m_nodeA.prev; + } + if (c.m_nodeA == bodyA.m_contactList) { + bodyA.m_contactList = c.m_nodeA.next; + } + if (c.m_nodeB.prev) { + c.m_nodeB.prev.next = c.m_nodeB.next; + } + if (c.m_nodeB.next) { + c.m_nodeB.next.prev = c.m_nodeB.prev; + } + if (c.m_nodeB == bodyB.m_contactList) { + bodyB.m_contactList = c.m_nodeB.next; + } + this.m_contactFactory.Destroy(c); + --this.m_contactCount; + } + b2ContactManager.prototype.Collide = function () { + var c = this.m_world.m_contactList; + while (c) { + var fixtureA = c.GetFixtureA(); + var fixtureB = c.GetFixtureB(); + var bodyA = fixtureA.GetBody(); + var bodyB = fixtureB.GetBody(); + if (bodyA.IsAwake() == false && bodyB.IsAwake() == false) { + c = c.GetNext(); + continue; + } + if (c.m_flags & b2Contact.e_filterFlag) { + if (bodyB.ShouldCollide(bodyA) == false) { + var cNuke = c; + c = cNuke.GetNext(); + this.Destroy(cNuke); + continue; + } + if (this.m_contactFilter.ShouldCollide(fixtureA, fixtureB) == false) { + cNuke = c; + c = cNuke.GetNext(); + this.Destroy(cNuke); + continue; + } + c.m_flags &= ~b2Contact.e_filterFlag; + } + var proxyA = fixtureA.m_proxy; + var proxyB = fixtureB.m_proxy; + var overlap = this.m_broadPhase.TestOverlap(proxyA, proxyB); + if (overlap == false) { + cNuke = c; + c = cNuke.GetNext(); + this.Destroy(cNuke); + continue; + } + c.Update(this.m_contactListener); + c = c.GetNext(); + } + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.b2ContactManager.s_evalCP = new b2ContactPoint(); + }); + b2DebugDraw.b2DebugDraw = function () {}; + b2DebugDraw.prototype.b2DebugDraw = function () {} + b2DebugDraw.prototype.SetFlags = function (flags) { + if (flags === undefined) flags = 0; + } + b2DebugDraw.prototype.GetFlags = function () {} + b2DebugDraw.prototype.AppendFlags = function (flags) { + if (flags === undefined) flags = 0; + } + b2DebugDraw.prototype.ClearFlags = function (flags) { + if (flags === undefined) flags = 0; + } + b2DebugDraw.prototype.SetSprite = function (sprite) {} + b2DebugDraw.prototype.GetSprite = function () {} + b2DebugDraw.prototype.SetDrawScale = function (drawScale) { + if (drawScale === undefined) drawScale = 0; + } + b2DebugDraw.prototype.GetDrawScale = function () {} + b2DebugDraw.prototype.SetLineThickness = function (lineThickness) { + if (lineThickness === undefined) lineThickness = 0; + } + b2DebugDraw.prototype.GetLineThickness = function () {} + b2DebugDraw.prototype.SetAlpha = function (alpha) { + if (alpha === undefined) alpha = 0; + } + b2DebugDraw.prototype.GetAlpha = function () {} + b2DebugDraw.prototype.SetFillAlpha = function (alpha) { + if (alpha === undefined) alpha = 0; + } + b2DebugDraw.prototype.GetFillAlpha = function () {} + b2DebugDraw.prototype.SetXFormScale = function (xformScale) { + if (xformScale === undefined) xformScale = 0; + } + b2DebugDraw.prototype.GetXFormScale = function () {} + b2DebugDraw.prototype.DrawPolygon = function (vertices, vertexCount, color) { + if (vertexCount === undefined) vertexCount = 0; + } + b2DebugDraw.prototype.DrawSolidPolygon = function (vertices, vertexCount, color) { + if (vertexCount === undefined) vertexCount = 0; + } + b2DebugDraw.prototype.DrawCircle = function (center, radius, color) { + if (radius === undefined) radius = 0; + } + b2DebugDraw.prototype.DrawSolidCircle = function (center, radius, axis, color) { + if (radius === undefined) radius = 0; + } + b2DebugDraw.prototype.DrawSegment = function (p1, p2, color) {} + b2DebugDraw.prototype.DrawTransform = function (xf) {} + Box2D.postDefs.push(function () { + Box2D.Dynamics.b2DebugDraw.e_shapeBit = 0x0001; + Box2D.Dynamics.b2DebugDraw.e_jointBit = 0x0002; + Box2D.Dynamics.b2DebugDraw.e_aabbBit = 0x0004; + Box2D.Dynamics.b2DebugDraw.e_pairBit = 0x0008; + Box2D.Dynamics.b2DebugDraw.e_centerOfMassBit = 0x0010; + Box2D.Dynamics.b2DebugDraw.e_controllerBit = 0x0020; + }); + b2DestructionListener.b2DestructionListener = function () {}; + b2DestructionListener.prototype.SayGoodbyeJoint = function (joint) {} + b2DestructionListener.prototype.SayGoodbyeFixture = function (fixture) {} + b2FilterData.b2FilterData = function () { + this.categoryBits = 0x0001; + this.maskBits = 0xFFFF; + this.groupIndex = 0; + }; + b2FilterData.prototype.Copy = function () { + var copy = new b2FilterData(); + copy.categoryBits = this.categoryBits; + copy.maskBits = this.maskBits; + copy.groupIndex = this.groupIndex; + return copy; + } + b2Fixture.b2Fixture = function () { + this.m_filter = new b2FilterData(); + }; + b2Fixture.prototype.GetType = function () { + return this.m_shape.GetType(); + } + b2Fixture.prototype.GetShape = function () { + return this.m_shape; + } + b2Fixture.prototype.SetSensor = function (sensor) { + if (this.m_isSensor == sensor) return; + this.m_isSensor = sensor; + if (this.m_body == null) return; + var edge = this.m_body.GetContactList(); + while (edge) { + var contact = edge.contact; + var fixtureA = contact.GetFixtureA(); + var fixtureB = contact.GetFixtureB(); + if (fixtureA == this || fixtureB == this) contact.SetSensor(fixtureA.IsSensor() || fixtureB.IsSensor()); + edge = edge.next; + } + } + b2Fixture.prototype.IsSensor = function () { + return this.m_isSensor; + } + b2Fixture.prototype.SetFilterData = function (filter) { + this.m_filter = filter.Copy(); + if (this.m_body) return; + var edge = this.m_body.GetContactList(); + while (edge) { + var contact = edge.contact; + var fixtureA = contact.GetFixtureA(); + var fixtureB = contact.GetFixtureB(); + if (fixtureA == this || fixtureB == this) contact.FlagForFiltering(); + edge = edge.next; + } + } + b2Fixture.prototype.GetFilterData = function () { + return this.m_filter.Copy(); + } + b2Fixture.prototype.GetBody = function () { + return this.m_body; + } + b2Fixture.prototype.GetNext = function () { + return this.m_next; + } + b2Fixture.prototype.GetUserData = function () { + return this.m_userData; + } + b2Fixture.prototype.SetUserData = function (data) { + this.m_userData = data; + } + b2Fixture.prototype.TestPoint = function (p) { + return this.m_shape.TestPoint(this.m_body.GetTransform(), p); + } + b2Fixture.prototype.RayCast = function (output, input) { + return this.m_shape.RayCast(output, input, this.m_body.GetTransform()); + } + b2Fixture.prototype.GetMassData = function (massData) { + if (massData === undefined) massData = null; + if (massData == null) { + massData = new b2MassData(); + } + this.m_shape.ComputeMass(massData, this.m_density); + return massData; + } + b2Fixture.prototype.SetDensity = function (density) { + if (density === undefined) density = 0; + this.m_density = density; + } + b2Fixture.prototype.GetDensity = function () { + return this.m_density; + } + b2Fixture.prototype.GetFriction = function () { + return this.m_friction; + } + b2Fixture.prototype.SetFriction = function (friction) { + if (friction === undefined) friction = 0; + this.m_friction = friction; + } + b2Fixture.prototype.GetRestitution = function () { + return this.m_restitution; + } + b2Fixture.prototype.SetRestitution = function (restitution) { + if (restitution === undefined) restitution = 0; + this.m_restitution = restitution; + } + b2Fixture.prototype.GetAABB = function () { + return this.m_aabb; + } + b2Fixture.prototype.b2Fixture = function () { + this.m_aabb = new b2AABB(); + this.m_userData = null; + this.m_body = null; + this.m_next = null; + this.m_shape = null; + this.m_density = 0.0; + this.m_friction = 0.0; + this.m_restitution = 0.0; + } + b2Fixture.prototype.Create = function (body, xf, def) { + this.m_userData = def.userData; + this.m_friction = def.friction; + this.m_restitution = def.restitution; + this.m_body = body; + this.m_next = null; + this.m_filter = def.filter.Copy(); + this.m_isSensor = def.isSensor; + this.m_shape = def.shape.Copy(); + this.m_density = def.density; + } + b2Fixture.prototype.Destroy = function () { + this.m_shape = null; + } + b2Fixture.prototype.CreateProxy = function (broadPhase, xf) { + this.m_shape.ComputeAABB(this.m_aabb, xf); + this.m_proxy = broadPhase.CreateProxy(this.m_aabb, this); + } + b2Fixture.prototype.DestroyProxy = function (broadPhase) { + if (this.m_proxy == null) { + return; + } + broadPhase.DestroyProxy(this.m_proxy); + this.m_proxy = null; + } + b2Fixture.prototype.Synchronize = function (broadPhase, transform1, transform2) { + if (!this.m_proxy) return; + var aabb1 = new b2AABB(); + var aabb2 = new b2AABB(); + this.m_shape.ComputeAABB(aabb1, transform1); + this.m_shape.ComputeAABB(aabb2, transform2); + this.m_aabb.Combine(aabb1, aabb2); + var displacement = b2Math.SubtractVV(transform2.position, transform1.position); + broadPhase.MoveProxy(this.m_proxy, this.m_aabb, displacement); + } + b2FixtureDef.b2FixtureDef = function () { + this.filter = new b2FilterData(); + }; + b2FixtureDef.prototype.b2FixtureDef = function () { + this.shape = null; + this.userData = null; + this.friction = 0.2; + this.restitution = 0.0; + this.density = 0.0; + this.filter.categoryBits = 0x0001; + this.filter.maskBits = 0xFFFF; + this.filter.groupIndex = 0; + this.isSensor = false; + } + b2Island.b2Island = function () {}; + b2Island.prototype.b2Island = function () { + this.m_bodies = new Vector(); + this.m_contacts = new Vector(); + this.m_joints = new Vector(); + } + b2Island.prototype.Initialize = function (bodyCapacity, contactCapacity, jointCapacity, allocator, listener, contactSolver) { + if (bodyCapacity === undefined) bodyCapacity = 0; + if (contactCapacity === undefined) contactCapacity = 0; + if (jointCapacity === undefined) jointCapacity = 0; + var i = 0; + this.m_bodyCapacity = bodyCapacity; + this.m_contactCapacity = contactCapacity; + this.m_jointCapacity = jointCapacity; + this.m_bodyCount = 0; + this.m_contactCount = 0; + this.m_jointCount = 0; + this.m_allocator = allocator; + this.m_listener = listener; + this.m_contactSolver = contactSolver; + for (i = this.m_bodies.length; + i < bodyCapacity; i++) + this.m_bodies[i] = null; + for (i = this.m_contacts.length; + i < contactCapacity; i++) + this.m_contacts[i] = null; + for (i = this.m_joints.length; + i < jointCapacity; i++) + this.m_joints[i] = null; + } + b2Island.prototype.Clear = function () { + this.m_bodyCount = 0; + this.m_contactCount = 0; + this.m_jointCount = 0; + } + b2Island.prototype.Solve = function (step, gravity, allowSleep) { + var i = 0; + var j = 0; + var b; + var joint; + for (i = 0; + i < this.m_bodyCount; ++i) { + b = this.m_bodies[i]; + if (b.GetType() != b2Body.b2_dynamicBody) continue; + b.m_linearVelocity.x += step.dt * (gravity.x + b.m_invMass * b.m_force.x); + b.m_linearVelocity.y += step.dt * (gravity.y + b.m_invMass * b.m_force.y); + b.m_angularVelocity += step.dt * b.m_invI * b.m_torque; + b.m_linearVelocity.Multiply(b2Math.Clamp(1.0 - step.dt * b.m_linearDamping, 0.0, 1.0)); + b.m_angularVelocity *= b2Math.Clamp(1.0 - step.dt * b.m_angularDamping, 0.0, 1.0); + } + this.m_contactSolver.Initialize(step, this.m_contacts, this.m_contactCount, this.m_allocator); + var contactSolver = this.m_contactSolver; + contactSolver.InitVelocityConstraints(step); + for (i = 0; + i < this.m_jointCount; ++i) { + joint = this.m_joints[i]; + joint.InitVelocityConstraints(step); + } + for (i = 0; + i < step.velocityIterations; ++i) { + for (j = 0; + j < this.m_jointCount; ++j) { + joint = this.m_joints[j]; + joint.SolveVelocityConstraints(step); + } + contactSolver.SolveVelocityConstraints(); + } + for (i = 0; + i < this.m_jointCount; ++i) { + joint = this.m_joints[i]; + joint.FinalizeVelocityConstraints(); + } + contactSolver.FinalizeVelocityConstraints(); + for (i = 0; + i < this.m_bodyCount; ++i) { + b = this.m_bodies[i]; + if (b.GetType() == b2Body.b2_staticBody) continue; + var translationX = step.dt * b.m_linearVelocity.x; + var translationY = step.dt * b.m_linearVelocity.y; + if ((translationX * translationX + translationY * translationY) > b2Settings.b2_maxTranslationSquared) { + b.m_linearVelocity.Normalize(); + b.m_linearVelocity.x *= b2Settings.b2_maxTranslation * step.inv_dt; + b.m_linearVelocity.y *= b2Settings.b2_maxTranslation * step.inv_dt; + } + var rotation = step.dt * b.m_angularVelocity; + if (rotation * rotation > b2Settings.b2_maxRotationSquared) { + if (b.m_angularVelocity < 0.0) { + b.m_angularVelocity = (-b2Settings.b2_maxRotation * step.inv_dt); + } + else { + b.m_angularVelocity = b2Settings.b2_maxRotation * step.inv_dt; + } + } + b.m_sweep.c0.SetV(b.m_sweep.c); + b.m_sweep.a0 = b.m_sweep.a; + b.m_sweep.c.x += step.dt * b.m_linearVelocity.x; + b.m_sweep.c.y += step.dt * b.m_linearVelocity.y; + b.m_sweep.a += step.dt * b.m_angularVelocity; + b.SynchronizeTransform(); + } + for (i = 0; + i < step.positionIterations; ++i) { + var contactsOkay = contactSolver.SolvePositionConstraints(b2Settings.b2_contactBaumgarte); + var jointsOkay = true; + for (j = 0; + j < this.m_jointCount; ++j) { + joint = this.m_joints[j]; + var jointOkay = joint.SolvePositionConstraints(b2Settings.b2_contactBaumgarte); + jointsOkay = jointsOkay && jointOkay; + } + if (contactsOkay && jointsOkay) { + break; + } + } + this.Report(contactSolver.m_constraints); + if (allowSleep) { + var minSleepTime = Number.MAX_VALUE; + var linTolSqr = b2Settings.b2_linearSleepTolerance * b2Settings.b2_linearSleepTolerance; + var angTolSqr = b2Settings.b2_angularSleepTolerance * b2Settings.b2_angularSleepTolerance; + for (i = 0; + i < this.m_bodyCount; ++i) { + b = this.m_bodies[i]; + if (b.GetType() == b2Body.b2_staticBody) { + continue; + } + if ((b.m_flags & b2Body.e_allowSleepFlag) == 0) { + b.m_sleepTime = 0.0; + minSleepTime = 0.0; + } + if ((b.m_flags & b2Body.e_allowSleepFlag) == 0 || b.m_angularVelocity * b.m_angularVelocity > angTolSqr || b2Math.Dot(b.m_linearVelocity, b.m_linearVelocity) > linTolSqr) { + b.m_sleepTime = 0.0; + minSleepTime = 0.0; + } + else { + b.m_sleepTime += step.dt; + minSleepTime = b2Math.Min(minSleepTime, b.m_sleepTime); + } + } + if (minSleepTime >= b2Settings.b2_timeToSleep) { + for (i = 0; + i < this.m_bodyCount; ++i) { + b = this.m_bodies[i]; + b.SetAwake(false); + } + } + } + } + b2Island.prototype.SolveTOI = function (subStep) { + var i = 0; + var j = 0; + this.m_contactSolver.Initialize(subStep, this.m_contacts, this.m_contactCount, this.m_allocator); + var contactSolver = this.m_contactSolver; + for (i = 0; + i < this.m_jointCount; ++i) { + this.m_joints[i].InitVelocityConstraints(subStep); + } + for (i = 0; + i < subStep.velocityIterations; ++i) { + contactSolver.SolveVelocityConstraints(); + for (j = 0; + j < this.m_jointCount; ++j) { + this.m_joints[j].SolveVelocityConstraints(subStep); + } + } + for (i = 0; + i < this.m_bodyCount; ++i) { + var b = this.m_bodies[i]; + if (b.GetType() == b2Body.b2_staticBody) continue; + var translationX = subStep.dt * b.m_linearVelocity.x; + var translationY = subStep.dt * b.m_linearVelocity.y; + if ((translationX * translationX + translationY * translationY) > b2Settings.b2_maxTranslationSquared) { + b.m_linearVelocity.Normalize(); + b.m_linearVelocity.x *= b2Settings.b2_maxTranslation * subStep.inv_dt; + b.m_linearVelocity.y *= b2Settings.b2_maxTranslation * subStep.inv_dt; + } + var rotation = subStep.dt * b.m_angularVelocity; + if (rotation * rotation > b2Settings.b2_maxRotationSquared) { + if (b.m_angularVelocity < 0.0) { + b.m_angularVelocity = (-b2Settings.b2_maxRotation * subStep.inv_dt); + } + else { + b.m_angularVelocity = b2Settings.b2_maxRotation * subStep.inv_dt; + } + } + b.m_sweep.c0.SetV(b.m_sweep.c); + b.m_sweep.a0 = b.m_sweep.a; + b.m_sweep.c.x += subStep.dt * b.m_linearVelocity.x; + b.m_sweep.c.y += subStep.dt * b.m_linearVelocity.y; + b.m_sweep.a += subStep.dt * b.m_angularVelocity; + b.SynchronizeTransform(); + } + var k_toiBaumgarte = 0.75; + for (i = 0; + i < subStep.positionIterations; ++i) { + var contactsOkay = contactSolver.SolvePositionConstraints(k_toiBaumgarte); + var jointsOkay = true; + for (j = 0; + j < this.m_jointCount; ++j) { + var jointOkay = this.m_joints[j].SolvePositionConstraints(b2Settings.b2_contactBaumgarte); + jointsOkay = jointsOkay && jointOkay; + } + if (contactsOkay && jointsOkay) { + break; + } + } + this.Report(contactSolver.m_constraints); + } + b2Island.prototype.Report = function (constraints) { + if (this.m_listener == null) { + return; + } + for (var i = 0; i < this.m_contactCount; ++i) { + var c = this.m_contacts[i]; + var cc = constraints[i]; + for (var j = 0; j < cc.pointCount; ++j) { + b2Island.s_impulse.normalImpulses[j] = cc.points[j].normalImpulse; + b2Island.s_impulse.tangentImpulses[j] = cc.points[j].tangentImpulse; + } + this.m_listener.PostSolve(c, b2Island.s_impulse); + } + } + b2Island.prototype.AddBody = function (body) { + body.m_islandIndex = this.m_bodyCount; + this.m_bodies[this.m_bodyCount++] = body; + } + b2Island.prototype.AddContact = function (contact) { + this.m_contacts[this.m_contactCount++] = contact; + } + b2Island.prototype.AddJoint = function (joint) { + this.m_joints[this.m_jointCount++] = joint; + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.b2Island.s_impulse = new b2ContactImpulse(); + }); + b2TimeStep.b2TimeStep = function () {}; + b2TimeStep.prototype.Set = function (step) { + this.dt = step.dt; + this.inv_dt = step.inv_dt; + this.positionIterations = step.positionIterations; + this.velocityIterations = step.velocityIterations; + this.warmStarting = step.warmStarting; + } + b2World.b2World = function () { + this.s_stack = new Vector(); + this.m_contactManager = new b2ContactManager(); + this.m_contactSolver = new b2ContactSolver(); + this.m_island = new b2Island(); + }; + b2World.prototype.b2World = function (gravity, doSleep) { + this.m_destructionListener = null; + this.m_debugDraw = null; + this.m_bodyList = null; + this.m_contactList = null; + this.m_jointList = null; + this.m_controllerList = null; + this.m_bodyCount = 0; + this.m_contactCount = 0; + this.m_jointCount = 0; + this.m_controllerCount = 0; + b2World.m_warmStarting = true; + b2World.m_continuousPhysics = true; + this.m_allowSleep = doSleep; + this.m_gravity = gravity; + this.m_inv_dt0 = 0.0; + this.m_contactManager.m_world = this; + var bd = new b2BodyDef(); + this.m_groundBody = this.CreateBody(bd); + } + b2World.prototype.SetDestructionListener = function (listener) { + this.m_destructionListener = listener; + } + b2World.prototype.SetContactFilter = function (filter) { + this.m_contactManager.m_contactFilter = filter; + } + b2World.prototype.SetContactListener = function (listener) { + this.m_contactManager.m_contactListener = listener; + } + b2World.prototype.SetDebugDraw = function (debugDraw) { + this.m_debugDraw = debugDraw; + } + b2World.prototype.SetBroadPhase = function (broadPhase) { + var oldBroadPhase = this.m_contactManager.m_broadPhase; + this.m_contactManager.m_broadPhase = broadPhase; + for (var b = this.m_bodyList; b; b = b.m_next) { + for (var f = b.m_fixtureList; f; f = f.m_next) { + f.m_proxy = broadPhase.CreateProxy(oldBroadPhase.GetFatAABB(f.m_proxy), f); + } + } + } + b2World.prototype.Validate = function () { + this.m_contactManager.m_broadPhase.Validate(); + } + b2World.prototype.GetProxyCount = function () { + return this.m_contactManager.m_broadPhase.GetProxyCount(); + } + b2World.prototype.CreateBody = function (def) { + if (this.IsLocked() == true) { + return null; + } + var b = new b2Body(def, this); + b.m_prev = null; + b.m_next = this.m_bodyList; + if (this.m_bodyList) { + this.m_bodyList.m_prev = b; + } + this.m_bodyList = b; + ++this.m_bodyCount; + return b; + } + b2World.prototype.DestroyBody = function (b) { + if (this.IsLocked() == true) { + return; + } + var jn = b.m_jointList; + while (jn) { + var jn0 = jn; + jn = jn.next; + if (this.m_destructionListener) { + this.m_destructionListener.SayGoodbyeJoint(jn0.joint); + } + this.DestroyJoint(jn0.joint); + } + var coe = b.m_controllerList; + while (coe) { + var coe0 = coe; + coe = coe.nextController; + coe0.controller.RemoveBody(b); + } + var ce = b.m_contactList; + while (ce) { + var ce0 = ce; + ce = ce.next; + this.m_contactManager.Destroy(ce0.contact); + } + b.m_contactList = null; + var f = b.m_fixtureList; + while (f) { + var f0 = f; + f = f.m_next; + if (this.m_destructionListener) { + this.m_destructionListener.SayGoodbyeFixture(f0); + } + f0.DestroyProxy(this.m_contactManager.m_broadPhase); + f0.Destroy(); + } + b.m_fixtureList = null; + b.m_fixtureCount = 0; + if (b.m_prev) { + b.m_prev.m_next = b.m_next; + } + if (b.m_next) { + b.m_next.m_prev = b.m_prev; + } + if (b == this.m_bodyList) { + this.m_bodyList = b.m_next; + }--this.m_bodyCount; + } + b2World.prototype.CreateJoint = function (def) { + var j = b2Joint.Create(def, null); + j.m_prev = null; + j.m_next = this.m_jointList; + if (this.m_jointList) { + this.m_jointList.m_prev = j; + } + this.m_jointList = j; + ++this.m_jointCount; + j.m_edgeA.joint = j; + j.m_edgeA.other = j.m_bodyB; + j.m_edgeA.prev = null; + j.m_edgeA.next = j.m_bodyA.m_jointList; + if (j.m_bodyA.m_jointList) j.m_bodyA.m_jointList.prev = j.m_edgeA; + j.m_bodyA.m_jointList = j.m_edgeA; + j.m_edgeB.joint = j; + j.m_edgeB.other = j.m_bodyA; + j.m_edgeB.prev = null; + j.m_edgeB.next = j.m_bodyB.m_jointList; + if (j.m_bodyB.m_jointList) j.m_bodyB.m_jointList.prev = j.m_edgeB; + j.m_bodyB.m_jointList = j.m_edgeB; + var bodyA = def.bodyA; + var bodyB = def.bodyB; + if (def.collideConnected == false) { + var edge = bodyB.GetContactList(); + while (edge) { + if (edge.other == bodyA) { + edge.contact.FlagForFiltering(); + } + edge = edge.next; + } + } + return j; + } + b2World.prototype.DestroyJoint = function (j) { + var collideConnected = j.m_collideConnected; + if (j.m_prev) { + j.m_prev.m_next = j.m_next; + } + if (j.m_next) { + j.m_next.m_prev = j.m_prev; + } + if (j == this.m_jointList) { + this.m_jointList = j.m_next; + } + var bodyA = j.m_bodyA; + var bodyB = j.m_bodyB; + bodyA.SetAwake(true); + bodyB.SetAwake(true); + if (j.m_edgeA.prev) { + j.m_edgeA.prev.next = j.m_edgeA.next; + } + if (j.m_edgeA.next) { + j.m_edgeA.next.prev = j.m_edgeA.prev; + } + if (j.m_edgeA == bodyA.m_jointList) { + bodyA.m_jointList = j.m_edgeA.next; + } + j.m_edgeA.prev = null; + j.m_edgeA.next = null; + if (j.m_edgeB.prev) { + j.m_edgeB.prev.next = j.m_edgeB.next; + } + if (j.m_edgeB.next) { + j.m_edgeB.next.prev = j.m_edgeB.prev; + } + if (j.m_edgeB == bodyB.m_jointList) { + bodyB.m_jointList = j.m_edgeB.next; + } + j.m_edgeB.prev = null; + j.m_edgeB.next = null; + b2Joint.Destroy(j, null); + --this.m_jointCount; + if (collideConnected == false) { + var edge = bodyB.GetContactList(); + while (edge) { + if (edge.other == bodyA) { + edge.contact.FlagForFiltering(); + } + edge = edge.next; + } + } + } + b2World.prototype.AddController = function (c) { + c.m_next = this.m_controllerList; + c.m_prev = null; + this.m_controllerList = c; + c.m_world = this; + this.m_controllerCount++; + return c; + } + b2World.prototype.RemoveController = function (c) { + if (c.m_prev) c.m_prev.m_next = c.m_next; + if (c.m_next) c.m_next.m_prev = c.m_prev; + if (this.m_controllerList == c) this.m_controllerList = c.m_next; + this.m_controllerCount--; + } + b2World.prototype.CreateController = function (controller) { + if (controller.m_world != this) throw new Error("Controller can only be a member of one world"); + controller.m_next = this.m_controllerList; + controller.m_prev = null; + if (this.m_controllerList) this.m_controllerList.m_prev = controller; + this.m_controllerList = controller; + ++this.m_controllerCount; + controller.m_world = this; + return controller; + } + b2World.prototype.DestroyController = function (controller) { + controller.Clear(); + if (controller.m_next) controller.m_next.m_prev = controller.m_prev; + if (controller.m_prev) controller.m_prev.m_next = controller.m_next; + if (controller == this.m_controllerList) this.m_controllerList = controller.m_next; + --this.m_controllerCount; + } + b2World.prototype.SetWarmStarting = function (flag) { + b2World.m_warmStarting = flag; + } + b2World.prototype.SetContinuousPhysics = function (flag) { + b2World.m_continuousPhysics = flag; + } + b2World.prototype.GetBodyCount = function () { + return this.m_bodyCount; + } + b2World.prototype.GetJointCount = function () { + return this.m_jointCount; + } + b2World.prototype.GetContactCount = function () { + return this.m_contactCount; + } + b2World.prototype.SetGravity = function (gravity) { + this.m_gravity = gravity; + } + b2World.prototype.GetGravity = function () { + return this.m_gravity; + } + b2World.prototype.GetGroundBody = function () { + return this.m_groundBody; + } + b2World.prototype.Step = function (dt, velocityIterations, positionIterations) { + if (dt === undefined) dt = 0; + if (velocityIterations === undefined) velocityIterations = 0; + if (positionIterations === undefined) positionIterations = 0; + if (this.m_flags & b2World.e_newFixture) { + this.m_contactManager.FindNewContacts(); + this.m_flags &= ~b2World.e_newFixture; + } + this.m_flags |= b2World.e_locked; + var step = b2World.s_timestep2; + step.dt = dt; + step.velocityIterations = velocityIterations; + step.positionIterations = positionIterations; + if (dt > 0.0) { + step.inv_dt = 1.0 / dt; + } + else { + step.inv_dt = 0.0; + } + step.dtRatio = this.m_inv_dt0 * dt; + step.warmStarting = b2World.m_warmStarting; + this.m_contactManager.Collide(); + if (step.dt > 0.0) { + this.Solve(step); + } + if (b2World.m_continuousPhysics && step.dt > 0.0) { + this.SolveTOI(step); + } + if (step.dt > 0.0) { + this.m_inv_dt0 = step.inv_dt; + } + this.m_flags &= ~b2World.e_locked; + } + b2World.prototype.ClearForces = function () { + for (var body = this.m_bodyList; body; body = body.m_next) { + body.m_force.SetZero(); + body.m_torque = 0.0; + } + } + b2World.prototype.DrawDebugData = function () { + if (this.m_debugDraw == null) { + return; + } + this.m_debugDraw.m_sprite.graphics.clear(); + var flags = this.m_debugDraw.GetFlags(); + var i = 0; + var b; + var f; + var s; + var j; + var bp; + var invQ = new b2Vec2; + var x1 = new b2Vec2; + var x2 = new b2Vec2; + var xf; + var b1 = new b2AABB(); + var b2 = new b2AABB(); + var vs = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()]; + var color = new b2Color(0, 0, 0); + if (flags & b2DebugDraw.e_shapeBit) { + for (b = this.m_bodyList; + b; b = b.m_next) { + xf = b.m_xf; + for (f = b.GetFixtureList(); + f; f = f.m_next) { + s = f.GetShape(); + if (b.IsActive() == false) { + color.Set(0.5, 0.5, 0.3); + this.DrawShape(s, xf, color); + } + else if (b.GetType() == b2Body.b2_staticBody) { + color.Set(0.5, 0.9, 0.5); + this.DrawShape(s, xf, color); + } + else if (b.GetType() == b2Body.b2_kinematicBody) { + color.Set(0.5, 0.5, 0.9); + this.DrawShape(s, xf, color); + } + else if (b.IsAwake() == false) { + color.Set(0.6, 0.6, 0.6); + this.DrawShape(s, xf, color); + } + else { + color.Set(0.9, 0.7, 0.7); + this.DrawShape(s, xf, color); + } + } + } + } + if (flags & b2DebugDraw.e_jointBit) { + for (j = this.m_jointList; + j; j = j.m_next) { + this.DrawJoint(j); + } + } + if (flags & b2DebugDraw.e_controllerBit) { + for (var c = this.m_controllerList; c; c = c.m_next) { + c.Draw(this.m_debugDraw); + } + } + if (flags & b2DebugDraw.e_pairBit) { + color.Set(0.3, 0.9, 0.9); + for (var contact = this.m_contactManager.m_contactList; contact; contact = contact.GetNext()) { + var fixtureA = contact.GetFixtureA(); + var fixtureB = contact.GetFixtureB(); + var cA = fixtureA.GetAABB().GetCenter(); + var cB = fixtureB.GetAABB().GetCenter(); + this.m_debugDraw.DrawSegment(cA, cB, color); + } + } + if (flags & b2DebugDraw.e_aabbBit) { + bp = this.m_contactManager.m_broadPhase; + vs = [new b2Vec2(), new b2Vec2(), new b2Vec2(), new b2Vec2()]; + for (b = this.m_bodyList; + b; b = b.GetNext()) { + if (b.IsActive() == false) { + continue; + } + for (f = b.GetFixtureList(); + f; f = f.GetNext()) { + var aabb = bp.GetFatAABB(f.m_proxy); + vs[0].Set(aabb.lowerBound.x, aabb.lowerBound.y); + vs[1].Set(aabb.upperBound.x, aabb.lowerBound.y); + vs[2].Set(aabb.upperBound.x, aabb.upperBound.y); + vs[3].Set(aabb.lowerBound.x, aabb.upperBound.y); + this.m_debugDraw.DrawPolygon(vs, 4, color); + } + } + } + if (flags & b2DebugDraw.e_centerOfMassBit) { + for (b = this.m_bodyList; + b; b = b.m_next) { + xf = b2World.s_xf; + xf.R = b.m_xf.R; + xf.position = b.GetWorldCenter(); + this.m_debugDraw.DrawTransform(xf); + } + } + } + b2World.prototype.QueryAABB = function (callback, aabb) { + var __this = this; + var broadPhase = __this.m_contactManager.m_broadPhase; + + function WorldQueryWrapper(proxy) { + return callback(broadPhase.GetUserData(proxy)); + }; + broadPhase.Query(WorldQueryWrapper, aabb); + } + b2World.prototype.QueryShape = function (callback, shape, transform) { + var __this = this; + if (transform === undefined) transform = null; + if (transform == null) { + transform = new b2Transform(); + transform.SetIdentity(); + } + var broadPhase = __this.m_contactManager.m_broadPhase; + + function WorldQueryWrapper(proxy) { + var fixture = (broadPhase.GetUserData(proxy) instanceof b2Fixture ? broadPhase.GetUserData(proxy) : null); + if (b2Shape.TestOverlap(shape, transform, fixture.GetShape(), fixture.GetBody().GetTransform())) return callback(fixture); + return true; + }; + var aabb = new b2AABB(); + shape.ComputeAABB(aabb, transform); + broadPhase.Query(WorldQueryWrapper, aabb); + } + b2World.prototype.QueryPoint = function (callback, p) { + var __this = this; + var broadPhase = __this.m_contactManager.m_broadPhase; + + function WorldQueryWrapper(proxy) { + var fixture = (broadPhase.GetUserData(proxy) instanceof b2Fixture ? broadPhase.GetUserData(proxy) : null); + if (fixture.TestPoint(p)) return callback(fixture); + return true; + }; + var aabb = new b2AABB(); + aabb.lowerBound.Set(p.x - b2Settings.b2_linearSlop, p.y - b2Settings.b2_linearSlop); + aabb.upperBound.Set(p.x + b2Settings.b2_linearSlop, p.y + b2Settings.b2_linearSlop); + broadPhase.Query(WorldQueryWrapper, aabb); + } + b2World.prototype.RayCast = function (callback, point1, point2) { + var __this = this; + var broadPhase = __this.m_contactManager.m_broadPhase; + var output = new b2RayCastOutput; + + function RayCastWrapper(input, proxy) { + var userData = broadPhase.GetUserData(proxy); + var fixture = (userData instanceof b2Fixture ? userData : null); + var hit = fixture.RayCast(output, input); + if (hit) { + var fraction = output.fraction; + var point = new b2Vec2((1.0 - fraction) * point1.x + fraction * point2.x, (1.0 - fraction) * point1.y + fraction * point2.y); + return callback(fixture, point, output.normal, fraction); + } + return input.maxFraction; + }; + var input = new b2RayCastInput(point1, point2); + broadPhase.RayCast(RayCastWrapper, input); + } + b2World.prototype.RayCastOne = function (point1, point2) { + var __this = this; + var result; + + function RayCastOneWrapper(fixture, point, normal, fraction) { + if (fraction === undefined) fraction = 0; + result = fixture; + return fraction; + }; + __this.RayCast(RayCastOneWrapper, point1, point2); + return result; + } + b2World.prototype.RayCastAll = function (point1, point2) { + var __this = this; + var result = new Vector(); + + function RayCastAllWrapper(fixture, point, normal, fraction) { + if (fraction === undefined) fraction = 0; + result[result.length] = fixture; + return 1; + }; + __this.RayCast(RayCastAllWrapper, point1, point2); + return result; + } + b2World.prototype.GetBodyList = function () { + return this.m_bodyList; + } + b2World.prototype.GetJointList = function () { + return this.m_jointList; + } + b2World.prototype.GetContactList = function () { + return this.m_contactList; + } + b2World.prototype.IsLocked = function () { + return (this.m_flags & b2World.e_locked) > 0; + } + b2World.prototype.Solve = function (step) { + var b; + for (var controller = this.m_controllerList; controller; controller = controller.m_next) { + controller.Step(step); + } + var island = this.m_island; + island.Initialize(this.m_bodyCount, this.m_contactCount, this.m_jointCount, null, this.m_contactManager.m_contactListener, this.m_contactSolver); + for (b = this.m_bodyList; + b; b = b.m_next) { + b.m_flags &= ~b2Body.e_islandFlag; + } + for (var c = this.m_contactList; c; c = c.m_next) { + c.m_flags &= ~b2Contact.e_islandFlag; + } + for (var j = this.m_jointList; j; j = j.m_next) { + j.m_islandFlag = false; + } + var stackSize = parseInt(this.m_bodyCount); + var stack = this.s_stack; + for (var seed = this.m_bodyList; seed; seed = seed.m_next) { + if (seed.m_flags & b2Body.e_islandFlag) { + continue; + } + if (seed.IsAwake() == false || seed.IsActive() == false) { + continue; + } + if (seed.GetType() == b2Body.b2_staticBody) { + continue; + } + island.Clear(); + var stackCount = 0; + stack[stackCount++] = seed; + seed.m_flags |= b2Body.e_islandFlag; + while (stackCount > 0) { + b = stack[--stackCount]; + island.AddBody(b); + if (b.IsAwake() == false) { + b.SetAwake(true); + } + if (b.GetType() == b2Body.b2_staticBody) { + continue; + } + var other; + for (var ce = b.m_contactList; ce; ce = ce.next) { + if (ce.contact.m_flags & b2Contact.e_islandFlag) { + continue; + } + if (ce.contact.IsSensor() == true || ce.contact.IsEnabled() == false || ce.contact.IsTouching() == false) { + continue; + } + island.AddContact(ce.contact); + ce.contact.m_flags |= b2Contact.e_islandFlag; + other = ce.other; + if (other.m_flags & b2Body.e_islandFlag) { + continue; + } + stack[stackCount++] = other; + other.m_flags |= b2Body.e_islandFlag; + } + for (var jn = b.m_jointList; jn; jn = jn.next) { + if (jn.joint.m_islandFlag == true) { + continue; + } + other = jn.other; + if (other.IsActive() == false) { + continue; + } + island.AddJoint(jn.joint); + jn.joint.m_islandFlag = true; + if (other.m_flags & b2Body.e_islandFlag) { + continue; + } + stack[stackCount++] = other; + other.m_flags |= b2Body.e_islandFlag; + } + } + island.Solve(step, this.m_gravity, this.m_allowSleep); + for (var i = 0; i < island.m_bodyCount; ++i) { + b = island.m_bodies[i]; + if (b.GetType() == b2Body.b2_staticBody) { + b.m_flags &= ~b2Body.e_islandFlag; + } + } + } + for (i = 0; + i < stack.length; ++i) { + if (!stack[i]) break; + stack[i] = null; + } + for (b = this.m_bodyList; + b; b = b.m_next) { + if (b.IsAwake() == false || b.IsActive() == false) { + continue; + } + if (b.GetType() == b2Body.b2_staticBody) { + continue; + } + b.SynchronizeFixtures(); + } + this.m_contactManager.FindNewContacts(); + } + b2World.prototype.SolveTOI = function (step) { + var b; + var fA; + var fB; + var bA; + var bB; + var cEdge; + var j; + var island = this.m_island; + island.Initialize(this.m_bodyCount, b2Settings.b2_maxTOIContactsPerIsland, b2Settings.b2_maxTOIJointsPerIsland, null, this.m_contactManager.m_contactListener, this.m_contactSolver); + var queue = b2World.s_queue; + for (b = this.m_bodyList; + b; b = b.m_next) { + b.m_flags &= ~b2Body.e_islandFlag; + b.m_sweep.t0 = 0.0; + } + var c; + for (c = this.m_contactList; + c; c = c.m_next) { + c.m_flags &= ~ (b2Contact.e_toiFlag | b2Contact.e_islandFlag); + } + for (j = this.m_jointList; + j; j = j.m_next) { + j.m_islandFlag = false; + } + for (;;) { + var minContact = null; + var minTOI = 1.0; + for (c = this.m_contactList; + c; c = c.m_next) { + if (c.IsSensor() == true || c.IsEnabled() == false || c.IsContinuous() == false) { + continue; + } + var toi = 1.0; + if (c.m_flags & b2Contact.e_toiFlag) { + toi = c.m_toi; + } + else { + fA = c.m_fixtureA; + fB = c.m_fixtureB; + bA = fA.m_body; + bB = fB.m_body; + if ((bA.GetType() != b2Body.b2_dynamicBody || bA.IsAwake() == false) && (bB.GetType() != b2Body.b2_dynamicBody || bB.IsAwake() == false)) { + continue; + } + var t0 = bA.m_sweep.t0; + if (bA.m_sweep.t0 < bB.m_sweep.t0) { + t0 = bB.m_sweep.t0; + bA.m_sweep.Advance(t0); + } + else if (bB.m_sweep.t0 < bA.m_sweep.t0) { + t0 = bA.m_sweep.t0; + bB.m_sweep.Advance(t0); + } + toi = c.ComputeTOI(bA.m_sweep, bB.m_sweep); + b2Settings.b2Assert(0.0 <= toi && toi <= 1.0); + if (toi > 0.0 && toi < 1.0) { + toi = (1.0 - toi) * t0 + toi; + if (toi > 1) toi = 1; + } + c.m_toi = toi; + c.m_flags |= b2Contact.e_toiFlag; + } + if (Number.MIN_VALUE < toi && toi < minTOI) { + minContact = c; + minTOI = toi; + } + } + if (minContact == null || 1.0 - 100.0 * Number.MIN_VALUE < minTOI) { + break; + } + fA = minContact.m_fixtureA; + fB = minContact.m_fixtureB; + bA = fA.m_body; + bB = fB.m_body; + b2World.s_backupA.Set(bA.m_sweep); + b2World.s_backupB.Set(bB.m_sweep); + bA.Advance(minTOI); + bB.Advance(minTOI); + minContact.Update(this.m_contactManager.m_contactListener); + minContact.m_flags &= ~b2Contact.e_toiFlag; + if (minContact.IsSensor() == true || minContact.IsEnabled() == false) { + bA.m_sweep.Set(b2World.s_backupA); + bB.m_sweep.Set(b2World.s_backupB); + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + continue; + } + if (minContact.IsTouching() == false) { + continue; + } + var seed = bA; + if (seed.GetType() != b2Body.b2_dynamicBody) { + seed = bB; + } + island.Clear(); + var queueStart = 0; + var queueSize = 0; + queue[queueStart + queueSize++] = seed; + seed.m_flags |= b2Body.e_islandFlag; + while (queueSize > 0) { + b = queue[queueStart++]; + --queueSize; + island.AddBody(b); + if (b.IsAwake() == false) { + b.SetAwake(true); + } + if (b.GetType() != b2Body.b2_dynamicBody) { + continue; + } + for (cEdge = b.m_contactList; + cEdge; cEdge = cEdge.next) { + if (island.m_contactCount == island.m_contactCapacity) { + break; + } + if (cEdge.contact.m_flags & b2Contact.e_islandFlag) { + continue; + } + if (cEdge.contact.IsSensor() == true || cEdge.contact.IsEnabled() == false || cEdge.contact.IsTouching() == false) { + continue; + } + island.AddContact(cEdge.contact); + cEdge.contact.m_flags |= b2Contact.e_islandFlag; + var other = cEdge.other; + if (other.m_flags & b2Body.e_islandFlag) { + continue; + } + if (other.GetType() != b2Body.b2_staticBody) { + other.Advance(minTOI); + other.SetAwake(true); + } + queue[queueStart + queueSize] = other; + ++queueSize; + other.m_flags |= b2Body.e_islandFlag; + } + for (var jEdge = b.m_jointList; jEdge; jEdge = jEdge.next) { + if (island.m_jointCount == island.m_jointCapacity) continue; + if (jEdge.joint.m_islandFlag == true) continue; + other = jEdge.other; + if (other.IsActive() == false) { + continue; + } + island.AddJoint(jEdge.joint); + jEdge.joint.m_islandFlag = true; + if (other.m_flags & b2Body.e_islandFlag) continue; + if (other.GetType() != b2Body.b2_staticBody) { + other.Advance(minTOI); + other.SetAwake(true); + } + queue[queueStart + queueSize] = other; + ++queueSize; + other.m_flags |= b2Body.e_islandFlag; + } + } + var subStep = b2World.s_timestep; + subStep.warmStarting = false; + subStep.dt = (1.0 - minTOI) * step.dt; + subStep.inv_dt = 1.0 / subStep.dt; + subStep.dtRatio = 0.0; + subStep.velocityIterations = step.velocityIterations; + subStep.positionIterations = step.positionIterations; + island.SolveTOI(subStep); + var i = 0; + for (i = 0; + i < island.m_bodyCount; ++i) { + b = island.m_bodies[i]; + b.m_flags &= ~b2Body.e_islandFlag; + if (b.IsAwake() == false) { + continue; + } + if (b.GetType() != b2Body.b2_dynamicBody) { + continue; + } + b.SynchronizeFixtures(); + for (cEdge = b.m_contactList; + cEdge; cEdge = cEdge.next) { + cEdge.contact.m_flags &= ~b2Contact.e_toiFlag; + } + } + for (i = 0; + i < island.m_contactCount; ++i) { + c = island.m_contacts[i]; + c.m_flags &= ~ (b2Contact.e_toiFlag | b2Contact.e_islandFlag); + } + for (i = 0; + i < island.m_jointCount; ++i) { + j = island.m_joints[i]; + j.m_islandFlag = false; + } + this.m_contactManager.FindNewContacts(); + } + } + b2World.prototype.DrawJoint = function (joint) { + var b1 = joint.GetBodyA(); + var b2 = joint.GetBodyB(); + var xf1 = b1.m_xf; + var xf2 = b2.m_xf; + var x1 = xf1.position; + var x2 = xf2.position; + var p1 = joint.GetAnchorA(); + var p2 = joint.GetAnchorB(); + var color = b2World.s_jointColor; + switch (joint.m_type) { + case b2Joint.e_distanceJoint: + this.m_debugDraw.DrawSegment(p1, p2, color); + break; + case b2Joint.e_pulleyJoint: + { + var pulley = ((joint instanceof b2PulleyJoint ? joint : null)); + var s1 = pulley.GetGroundAnchorA(); + var s2 = pulley.GetGroundAnchorB(); + this.m_debugDraw.DrawSegment(s1, p1, color); + this.m_debugDraw.DrawSegment(s2, p2, color); + this.m_debugDraw.DrawSegment(s1, s2, color); + } + break; + case b2Joint.e_mouseJoint: + this.m_debugDraw.DrawSegment(p1, p2, color); + break; + default: + if (b1 != this.m_groundBody) this.m_debugDraw.DrawSegment(x1, p1, color); + this.m_debugDraw.DrawSegment(p1, p2, color); + if (b2 != this.m_groundBody) this.m_debugDraw.DrawSegment(x2, p2, color); + } + } + b2World.prototype.DrawShape = function (shape, xf, color) { + switch (shape.m_type) { + case b2Shape.e_circleShape: + { + var circle = ((shape instanceof b2CircleShape ? shape : null)); + var center = b2Math.MulX(xf, circle.m_p); + var radius = circle.m_radius; + var axis = xf.R.col1; + this.m_debugDraw.DrawSolidCircle(center, radius, axis, color); + } + break; + case b2Shape.e_polygonShape: + { + var i = 0; + var poly = ((shape instanceof b2PolygonShape ? shape : null)); + var vertexCount = parseInt(poly.GetVertexCount()); + var localVertices = poly.GetVertices(); + var vertices = new Vector(vertexCount); + for (i = 0; + i < vertexCount; ++i) { + vertices[i] = b2Math.MulX(xf, localVertices[i]); + } + this.m_debugDraw.DrawSolidPolygon(vertices, vertexCount, color); + } + break; + case b2Shape.e_edgeShape: + { + var edge = (shape instanceof b2EdgeShape ? shape : null); + this.m_debugDraw.DrawSegment(b2Math.MulX(xf, edge.GetVertex1()), b2Math.MulX(xf, edge.GetVertex2()), color); + } + break; + } + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.b2World.s_timestep2 = new b2TimeStep(); + Box2D.Dynamics.b2World.s_xf = new b2Transform(); + Box2D.Dynamics.b2World.s_backupA = new b2Sweep(); + Box2D.Dynamics.b2World.s_backupB = new b2Sweep(); + Box2D.Dynamics.b2World.s_timestep = new b2TimeStep(); + Box2D.Dynamics.b2World.s_queue = new Vector(); + Box2D.Dynamics.b2World.s_jointColor = new b2Color(0.5, 0.8, 0.8); + Box2D.Dynamics.b2World.e_newFixture = 0x0001; + Box2D.Dynamics.b2World.e_locked = 0x0002; + }); +})(); +(function () { + var b2CircleShape = Box2D.Collision.Shapes.b2CircleShape, + b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef, + b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape, + b2MassData = Box2D.Collision.Shapes.b2MassData, + b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape, + b2Shape = Box2D.Collision.Shapes.b2Shape, + b2CircleContact = Box2D.Dynamics.Contacts.b2CircleContact, + b2Contact = Box2D.Dynamics.Contacts.b2Contact, + b2ContactConstraint = Box2D.Dynamics.Contacts.b2ContactConstraint, + b2ContactConstraintPoint = Box2D.Dynamics.Contacts.b2ContactConstraintPoint, + b2ContactEdge = Box2D.Dynamics.Contacts.b2ContactEdge, + b2ContactFactory = Box2D.Dynamics.Contacts.b2ContactFactory, + b2ContactRegister = Box2D.Dynamics.Contacts.b2ContactRegister, + b2ContactResult = Box2D.Dynamics.Contacts.b2ContactResult, + b2ContactSolver = Box2D.Dynamics.Contacts.b2ContactSolver, + b2EdgeAndCircleContact = Box2D.Dynamics.Contacts.b2EdgeAndCircleContact, + b2NullContact = Box2D.Dynamics.Contacts.b2NullContact, + b2PolyAndCircleContact = Box2D.Dynamics.Contacts.b2PolyAndCircleContact, + b2PolyAndEdgeContact = Box2D.Dynamics.Contacts.b2PolyAndEdgeContact, + b2PolygonContact = Box2D.Dynamics.Contacts.b2PolygonContact, + b2PositionSolverManifold = Box2D.Dynamics.Contacts.b2PositionSolverManifold, + b2Body = Box2D.Dynamics.b2Body, + b2BodyDef = Box2D.Dynamics.b2BodyDef, + b2ContactFilter = Box2D.Dynamics.b2ContactFilter, + b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse, + b2ContactListener = Box2D.Dynamics.b2ContactListener, + b2ContactManager = Box2D.Dynamics.b2ContactManager, + b2DebugDraw = Box2D.Dynamics.b2DebugDraw, + b2DestructionListener = Box2D.Dynamics.b2DestructionListener, + b2FilterData = Box2D.Dynamics.b2FilterData, + b2Fixture = Box2D.Dynamics.b2Fixture, + b2FixtureDef = Box2D.Dynamics.b2FixtureDef, + b2Island = Box2D.Dynamics.b2Island, + b2TimeStep = Box2D.Dynamics.b2TimeStep, + b2World = Box2D.Dynamics.b2World, + b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3, + b2AABB = Box2D.Collision.b2AABB, + b2Bound = Box2D.Collision.b2Bound, + b2BoundValues = Box2D.Collision.b2BoundValues, + b2Collision = Box2D.Collision.b2Collision, + b2ContactID = Box2D.Collision.b2ContactID, + b2ContactPoint = Box2D.Collision.b2ContactPoint, + b2Distance = Box2D.Collision.b2Distance, + b2DistanceInput = Box2D.Collision.b2DistanceInput, + b2DistanceOutput = Box2D.Collision.b2DistanceOutput, + b2DistanceProxy = Box2D.Collision.b2DistanceProxy, + b2DynamicTree = Box2D.Collision.b2DynamicTree, + b2DynamicTreeBroadPhase = Box2D.Collision.b2DynamicTreeBroadPhase, + b2DynamicTreeNode = Box2D.Collision.b2DynamicTreeNode, + b2DynamicTreePair = Box2D.Collision.b2DynamicTreePair, + b2Manifold = Box2D.Collision.b2Manifold, + b2ManifoldPoint = Box2D.Collision.b2ManifoldPoint, + b2Point = Box2D.Collision.b2Point, + b2RayCastInput = Box2D.Collision.b2RayCastInput, + b2RayCastOutput = Box2D.Collision.b2RayCastOutput, + b2Segment = Box2D.Collision.b2Segment, + b2SeparationFunction = Box2D.Collision.b2SeparationFunction, + b2Simplex = Box2D.Collision.b2Simplex, + b2SimplexCache = Box2D.Collision.b2SimplexCache, + b2SimplexVertex = Box2D.Collision.b2SimplexVertex, + b2TimeOfImpact = Box2D.Collision.b2TimeOfImpact, + b2TOIInput = Box2D.Collision.b2TOIInput, + b2WorldManifold = Box2D.Collision.b2WorldManifold, + ClipVertex = Box2D.Collision.ClipVertex, + Features = Box2D.Collision.Features, + IBroadPhase = Box2D.Collision.IBroadPhase; + + Box2D.inherit(b2CircleContact, Box2D.Dynamics.Contacts.b2Contact); + b2CircleContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; + b2CircleContact.b2CircleContact = function () { + Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); + }; + b2CircleContact.Create = function (allocator) { + return new b2CircleContact(); + } + b2CircleContact.Destroy = function (contact, allocator) {} + b2CircleContact.prototype.Reset = function (fixtureA, fixtureB) { + this.__super.Reset.call(this, fixtureA, fixtureB); + } + b2CircleContact.prototype.Evaluate = function () { + var bA = this.m_fixtureA.GetBody(); + var bB = this.m_fixtureB.GetBody(); + b2Collision.CollideCircles(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2CircleShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2CircleShape ? this.m_fixtureB.GetShape() : null), bB.m_xf); + } + b2Contact.b2Contact = function () { + this.m_nodeA = new b2ContactEdge(); + this.m_nodeB = new b2ContactEdge(); + this.m_manifold = new b2Manifold(); + this.m_oldManifold = new b2Manifold(); + }; + b2Contact.prototype.GetManifold = function () { + return this.m_manifold; + } + b2Contact.prototype.GetWorldManifold = function (worldManifold) { + var bodyA = this.m_fixtureA.GetBody(); + var bodyB = this.m_fixtureB.GetBody(); + var shapeA = this.m_fixtureA.GetShape(); + var shapeB = this.m_fixtureB.GetShape(); + worldManifold.Initialize(this.m_manifold, bodyA.GetTransform(), shapeA.m_radius, bodyB.GetTransform(), shapeB.m_radius); + } + b2Contact.prototype.IsTouching = function () { + return (this.m_flags & b2Contact.e_touchingFlag) == b2Contact.e_touchingFlag; + } + b2Contact.prototype.IsContinuous = function () { + return (this.m_flags & b2Contact.e_continuousFlag) == b2Contact.e_continuousFlag; + } + b2Contact.prototype.SetSensor = function (sensor) { + if (sensor) { + this.m_flags |= b2Contact.e_sensorFlag; + } + else { + this.m_flags &= ~b2Contact.e_sensorFlag; + } + } + b2Contact.prototype.IsSensor = function () { + return (this.m_flags & b2Contact.e_sensorFlag) == b2Contact.e_sensorFlag; + } + b2Contact.prototype.SetEnabled = function (flag) { + if (flag) { + this.m_flags |= b2Contact.e_enabledFlag; + } + else { + this.m_flags &= ~b2Contact.e_enabledFlag; + } + } + b2Contact.prototype.IsEnabled = function () { + return (this.m_flags & b2Contact.e_enabledFlag) == b2Contact.e_enabledFlag; + } + b2Contact.prototype.GetNext = function () { + return this.m_next; + } + b2Contact.prototype.GetFixtureA = function () { + return this.m_fixtureA; + } + b2Contact.prototype.GetFixtureB = function () { + return this.m_fixtureB; + } + b2Contact.prototype.FlagForFiltering = function () { + this.m_flags |= b2Contact.e_filterFlag; + } + b2Contact.prototype.b2Contact = function () {} + b2Contact.prototype.Reset = function (fixtureA, fixtureB) { + if (fixtureA === undefined) fixtureA = null; + if (fixtureB === undefined) fixtureB = null; + this.m_flags = b2Contact.e_enabledFlag; + if (!fixtureA || !fixtureB) { + this.m_fixtureA = null; + this.m_fixtureB = null; + return; + } + if (fixtureA.IsSensor() || fixtureB.IsSensor()) { + this.m_flags |= b2Contact.e_sensorFlag; + } + var bodyA = fixtureA.GetBody(); + var bodyB = fixtureB.GetBody(); + if (bodyA.GetType() != b2Body.b2_dynamicBody || bodyA.IsBullet() || bodyB.GetType() != b2Body.b2_dynamicBody || bodyB.IsBullet()) { + this.m_flags |= b2Contact.e_continuousFlag; + } + this.m_fixtureA = fixtureA; + this.m_fixtureB = fixtureB; + this.m_manifold.m_pointCount = 0; + this.m_prev = null; + this.m_next = null; + this.m_nodeA.contact = null; + this.m_nodeA.prev = null; + this.m_nodeA.next = null; + this.m_nodeA.other = null; + this.m_nodeB.contact = null; + this.m_nodeB.prev = null; + this.m_nodeB.next = null; + this.m_nodeB.other = null; + } + b2Contact.prototype.Update = function (listener) { + var tManifold = this.m_oldManifold; + this.m_oldManifold = this.m_manifold; + this.m_manifold = tManifold; + this.m_flags |= b2Contact.e_enabledFlag; + var touching = false; + var wasTouching = (this.m_flags & b2Contact.e_touchingFlag) == b2Contact.e_touchingFlag; + var bodyA = this.m_fixtureA.m_body; + var bodyB = this.m_fixtureB.m_body; + var aabbOverlap = this.m_fixtureA.m_aabb.TestOverlap(this.m_fixtureB.m_aabb); + if (this.m_flags & b2Contact.e_sensorFlag) { + if (aabbOverlap) { + var shapeA = this.m_fixtureA.GetShape(); + var shapeB = this.m_fixtureB.GetShape(); + var xfA = bodyA.GetTransform(); + var xfB = bodyB.GetTransform(); + touching = b2Shape.TestOverlap(shapeA, xfA, shapeB, xfB); + } + this.m_manifold.m_pointCount = 0; + } + else { + if (bodyA.GetType() != b2Body.b2_dynamicBody || bodyA.IsBullet() || bodyB.GetType() != b2Body.b2_dynamicBody || bodyB.IsBullet()) { + this.m_flags |= b2Contact.e_continuousFlag; + } + else { + this.m_flags &= ~b2Contact.e_continuousFlag; + } + if (aabbOverlap) { + this.Evaluate(); + touching = this.m_manifold.m_pointCount > 0; + for (var i = 0; i < this.m_manifold.m_pointCount; ++i) { + var mp2 = this.m_manifold.m_points[i]; + mp2.m_normalImpulse = 0.0; + mp2.m_tangentImpulse = 0.0; + var id2 = mp2.m_id; + for (var j = 0; j < this.m_oldManifold.m_pointCount; ++j) { + var mp1 = this.m_oldManifold.m_points[j]; + if (mp1.m_id.key == id2.key) { + mp2.m_normalImpulse = mp1.m_normalImpulse; + mp2.m_tangentImpulse = mp1.m_tangentImpulse; + break; + } + } + } + } + else { + this.m_manifold.m_pointCount = 0; + } + if (touching != wasTouching) { + bodyA.SetAwake(true); + bodyB.SetAwake(true); + } + } + if (touching) { + this.m_flags |= b2Contact.e_touchingFlag; + } + else { + this.m_flags &= ~b2Contact.e_touchingFlag; + } + if (wasTouching == false && touching == true) { + listener.BeginContact(this); + } + if (wasTouching == true && touching == false) { + listener.EndContact(this); + } + if ((this.m_flags & b2Contact.e_sensorFlag) == 0) { + listener.PreSolve(this, this.m_oldManifold); + } + } + b2Contact.prototype.Evaluate = function () {} + b2Contact.prototype.ComputeTOI = function (sweepA, sweepB) { + b2Contact.s_input.proxyA.Set(this.m_fixtureA.GetShape()); + b2Contact.s_input.proxyB.Set(this.m_fixtureB.GetShape()); + b2Contact.s_input.sweepA = sweepA; + b2Contact.s_input.sweepB = sweepB; + b2Contact.s_input.tolerance = b2Settings.b2_linearSlop; + return b2TimeOfImpact.TimeOfImpact(b2Contact.s_input); + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.Contacts.b2Contact.e_sensorFlag = 0x0001; + Box2D.Dynamics.Contacts.b2Contact.e_continuousFlag = 0x0002; + Box2D.Dynamics.Contacts.b2Contact.e_islandFlag = 0x0004; + Box2D.Dynamics.Contacts.b2Contact.e_toiFlag = 0x0008; + Box2D.Dynamics.Contacts.b2Contact.e_touchingFlag = 0x0010; + Box2D.Dynamics.Contacts.b2Contact.e_enabledFlag = 0x0020; + Box2D.Dynamics.Contacts.b2Contact.e_filterFlag = 0x0040; + Box2D.Dynamics.Contacts.b2Contact.s_input = new b2TOIInput(); + }); + b2ContactConstraint.b2ContactConstraint = function () { + this.localPlaneNormal = new b2Vec2(); + this.localPoint = new b2Vec2(); + this.normal = new b2Vec2(); + this.normalMass = new b2Mat22(); + this.K = new b2Mat22(); + }; + b2ContactConstraint.prototype.b2ContactConstraint = function () { + this.points = new Vector(b2Settings.b2_maxManifoldPoints); + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { + this.points[i] = new b2ContactConstraintPoint(); + } + } + b2ContactConstraintPoint.b2ContactConstraintPoint = function () { + this.localPoint = new b2Vec2(); + this.rA = new b2Vec2(); + this.rB = new b2Vec2(); + }; + b2ContactEdge.b2ContactEdge = function () {}; + b2ContactFactory.b2ContactFactory = function () {}; + b2ContactFactory.prototype.b2ContactFactory = function (allocator) { + this.m_allocator = allocator; + this.InitializeRegisters(); + } + b2ContactFactory.prototype.AddType = function (createFcn, destroyFcn, type1, type2) { + if (type1 === undefined) type1 = 0; + if (type2 === undefined) type2 = 0; + this.m_registers[type1][type2].createFcn = createFcn; + this.m_registers[type1][type2].destroyFcn = destroyFcn; + this.m_registers[type1][type2].primary = true; + if (type1 != type2) { + this.m_registers[type2][type1].createFcn = createFcn; + this.m_registers[type2][type1].destroyFcn = destroyFcn; + this.m_registers[type2][type1].primary = false; + } + } + b2ContactFactory.prototype.InitializeRegisters = function () { + this.m_registers = new Vector(b2Shape.e_shapeTypeCount); + for (var i = 0; i < b2Shape.e_shapeTypeCount; i++) { + this.m_registers[i] = new Vector(b2Shape.e_shapeTypeCount); + for (var j = 0; j < b2Shape.e_shapeTypeCount; j++) { + this.m_registers[i][j] = new b2ContactRegister(); + } + } + this.AddType(b2CircleContact.Create, b2CircleContact.Destroy, b2Shape.e_circleShape, b2Shape.e_circleShape); + this.AddType(b2PolyAndCircleContact.Create, b2PolyAndCircleContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_circleShape); + this.AddType(b2PolygonContact.Create, b2PolygonContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_polygonShape); + this.AddType(b2EdgeAndCircleContact.Create, b2EdgeAndCircleContact.Destroy, b2Shape.e_edgeShape, b2Shape.e_circleShape); + this.AddType(b2PolyAndEdgeContact.Create, b2PolyAndEdgeContact.Destroy, b2Shape.e_polygonShape, b2Shape.e_edgeShape); + } + b2ContactFactory.prototype.Create = function (fixtureA, fixtureB) { + var type1 = parseInt(fixtureA.GetType()); + var type2 = parseInt(fixtureB.GetType()); + var reg = this.m_registers[type1][type2]; + var c; + if (reg.pool) { + c = reg.pool; + reg.pool = c.m_next; + reg.poolCount--; + c.Reset(fixtureA, fixtureB); + return c; + } + var createFcn = reg.createFcn; + if (createFcn != null) { + if (reg.primary) { + c = createFcn(this.m_allocator); + c.Reset(fixtureA, fixtureB); + return c; + } + else { + c = createFcn(this.m_allocator); + c.Reset(fixtureB, fixtureA); + return c; + } + } + else { + return null; + } + } + b2ContactFactory.prototype.Destroy = function (contact) { + if (contact.m_manifold.m_pointCount > 0) { + contact.m_fixtureA.m_body.SetAwake(true); + contact.m_fixtureB.m_body.SetAwake(true); + } + var type1 = parseInt(contact.m_fixtureA.GetType()); + var type2 = parseInt(contact.m_fixtureB.GetType()); + var reg = this.m_registers[type1][type2]; + if (true) { + reg.poolCount++; + contact.m_next = reg.pool; + reg.pool = contact; + } + var destroyFcn = reg.destroyFcn; + destroyFcn(contact, this.m_allocator); + } + b2ContactRegister.b2ContactRegister = function () {}; + b2ContactResult.b2ContactResult = function () { + this.position = new b2Vec2(); + this.normal = new b2Vec2(); + this.id = new b2ContactID(); + }; + b2ContactSolver.b2ContactSolver = function () { + this.m_step = new b2TimeStep(); + this.m_constraints = new Vector(); + }; + b2ContactSolver.prototype.b2ContactSolver = function () {} + b2ContactSolver.prototype.Initialize = function (step, contacts, contactCount, allocator) { + if (contactCount === undefined) contactCount = 0; + var contact; + this.m_step.Set(step); + this.m_allocator = allocator; + var i = 0; + var tVec; + var tMat; + this.m_constraintCount = contactCount; + while (this.m_constraints.length < this.m_constraintCount) { + this.m_constraints[this.m_constraints.length] = new b2ContactConstraint(); + } + for (i = 0; + i < contactCount; ++i) { + contact = contacts[i]; + var fixtureA = contact.m_fixtureA; + var fixtureB = contact.m_fixtureB; + var shapeA = fixtureA.m_shape; + var shapeB = fixtureB.m_shape; + var radiusA = shapeA.m_radius; + var radiusB = shapeB.m_radius; + var bodyA = fixtureA.m_body; + var bodyB = fixtureB.m_body; + var manifold = contact.GetManifold(); + var friction = b2Settings.b2MixFriction(fixtureA.GetFriction(), fixtureB.GetFriction()); + var restitution = b2Settings.b2MixRestitution(fixtureA.GetRestitution(), fixtureB.GetRestitution()); + var vAX = bodyA.m_linearVelocity.x; + var vAY = bodyA.m_linearVelocity.y; + var vBX = bodyB.m_linearVelocity.x; + var vBY = bodyB.m_linearVelocity.y; + var wA = bodyA.m_angularVelocity; + var wB = bodyB.m_angularVelocity; + b2Settings.b2Assert(manifold.m_pointCount > 0); + b2ContactSolver.s_worldManifold.Initialize(manifold, bodyA.m_xf, radiusA, bodyB.m_xf, radiusB); + var normalX = b2ContactSolver.s_worldManifold.m_normal.x; + var normalY = b2ContactSolver.s_worldManifold.m_normal.y; + var cc = this.m_constraints[i]; + cc.bodyA = bodyA; + cc.bodyB = bodyB; + cc.manifold = manifold; + cc.normal.x = normalX; + cc.normal.y = normalY; + cc.pointCount = manifold.m_pointCount; + cc.friction = friction; + cc.restitution = restitution; + cc.localPlaneNormal.x = manifold.m_localPlaneNormal.x; + cc.localPlaneNormal.y = manifold.m_localPlaneNormal.y; + cc.localPoint.x = manifold.m_localPoint.x; + cc.localPoint.y = manifold.m_localPoint.y; + cc.radius = radiusA + radiusB; + cc.type = manifold.m_type; + for (var k = 0; k < cc.pointCount; ++k) { + var cp = manifold.m_points[k]; + var ccp = cc.points[k]; + ccp.normalImpulse = cp.m_normalImpulse; + ccp.tangentImpulse = cp.m_tangentImpulse; + ccp.localPoint.SetV(cp.m_localPoint); + var rAX = ccp.rA.x = b2ContactSolver.s_worldManifold.m_points[k].x - bodyA.m_sweep.c.x; + var rAY = ccp.rA.y = b2ContactSolver.s_worldManifold.m_points[k].y - bodyA.m_sweep.c.y; + var rBX = ccp.rB.x = b2ContactSolver.s_worldManifold.m_points[k].x - bodyB.m_sweep.c.x; + var rBY = ccp.rB.y = b2ContactSolver.s_worldManifold.m_points[k].y - bodyB.m_sweep.c.y; + var rnA = rAX * normalY - rAY * normalX; + var rnB = rBX * normalY - rBY * normalX; + rnA *= rnA; + rnB *= rnB; + var kNormal = bodyA.m_invMass + bodyB.m_invMass + bodyA.m_invI * rnA + bodyB.m_invI * rnB; + ccp.normalMass = 1.0 / kNormal; + var kEqualized = bodyA.m_mass * bodyA.m_invMass + bodyB.m_mass * bodyB.m_invMass; + kEqualized += bodyA.m_mass * bodyA.m_invI * rnA + bodyB.m_mass * bodyB.m_invI * rnB; + ccp.equalizedMass = 1.0 / kEqualized; + var tangentX = normalY; + var tangentY = (-normalX); + var rtA = rAX * tangentY - rAY * tangentX; + var rtB = rBX * tangentY - rBY * tangentX; + rtA *= rtA; + rtB *= rtB; + var kTangent = bodyA.m_invMass + bodyB.m_invMass + bodyA.m_invI * rtA + bodyB.m_invI * rtB; + ccp.tangentMass = 1.0 / kTangent; + ccp.velocityBias = 0.0; + var tX = vBX + ((-wB * rBY)) - vAX - ((-wA * rAY)); + var tY = vBY + (wB * rBX) - vAY - (wA * rAX); + var vRel = cc.normal.x * tX + cc.normal.y * tY; + if (vRel < (-b2Settings.b2_velocityThreshold)) { + ccp.velocityBias += (-cc.restitution * vRel); + } + } + if (cc.pointCount == 2) { + var ccp1 = cc.points[0]; + var ccp2 = cc.points[1]; + var invMassA = bodyA.m_invMass; + var invIA = bodyA.m_invI; + var invMassB = bodyB.m_invMass; + var invIB = bodyB.m_invI; + var rn1A = ccp1.rA.x * normalY - ccp1.rA.y * normalX; + var rn1B = ccp1.rB.x * normalY - ccp1.rB.y * normalX; + var rn2A = ccp2.rA.x * normalY - ccp2.rA.y * normalX; + var rn2B = ccp2.rB.x * normalY - ccp2.rB.y * normalX; + var k11 = invMassA + invMassB + invIA * rn1A * rn1A + invIB * rn1B * rn1B; + var k22 = invMassA + invMassB + invIA * rn2A * rn2A + invIB * rn2B * rn2B; + var k12 = invMassA + invMassB + invIA * rn1A * rn2A + invIB * rn1B * rn2B; + var k_maxConditionNumber = 100.0; + if (k11 * k11 < k_maxConditionNumber * (k11 * k22 - k12 * k12)) { + cc.K.col1.Set(k11, k12); + cc.K.col2.Set(k12, k22); + cc.K.GetInverse(cc.normalMass); + } + else { + cc.pointCount = 1; + } + } + } + } + b2ContactSolver.prototype.InitVelocityConstraints = function (step) { + var tVec; + var tVec2; + var tMat; + for (var i = 0; i < this.m_constraintCount; ++i) { + var c = this.m_constraints[i]; + var bodyA = c.bodyA; + var bodyB = c.bodyB; + var invMassA = bodyA.m_invMass; + var invIA = bodyA.m_invI; + var invMassB = bodyB.m_invMass; + var invIB = bodyB.m_invI; + var normalX = c.normal.x; + var normalY = c.normal.y; + var tangentX = normalY; + var tangentY = (-normalX); + var tX = 0; + var j = 0; + var tCount = 0; + if (step.warmStarting) { + tCount = c.pointCount; + for (j = 0; + j < tCount; ++j) { + var ccp = c.points[j]; + ccp.normalImpulse *= step.dtRatio; + ccp.tangentImpulse *= step.dtRatio; + var PX = ccp.normalImpulse * normalX + ccp.tangentImpulse * tangentX; + var PY = ccp.normalImpulse * normalY + ccp.tangentImpulse * tangentY; + bodyA.m_angularVelocity -= invIA * (ccp.rA.x * PY - ccp.rA.y * PX); + bodyA.m_linearVelocity.x -= invMassA * PX; + bodyA.m_linearVelocity.y -= invMassA * PY; + bodyB.m_angularVelocity += invIB * (ccp.rB.x * PY - ccp.rB.y * PX); + bodyB.m_linearVelocity.x += invMassB * PX; + bodyB.m_linearVelocity.y += invMassB * PY; + } + } + else { + tCount = c.pointCount; + for (j = 0; + j < tCount; ++j) { + var ccp2 = c.points[j]; + ccp2.normalImpulse = 0.0; + ccp2.tangentImpulse = 0.0; + } + } + } + } + b2ContactSolver.prototype.SolveVelocityConstraints = function () { + var j = 0; + var ccp; + var rAX = 0; + var rAY = 0; + var rBX = 0; + var rBY = 0; + var dvX = 0; + var dvY = 0; + var vn = 0; + var vt = 0; + var lambda = 0; + var maxFriction = 0; + var newImpulse = 0; + var PX = 0; + var PY = 0; + var dX = 0; + var dY = 0; + var P1X = 0; + var P1Y = 0; + var P2X = 0; + var P2Y = 0; + var tMat; + var tVec; + for (var i = 0; i < this.m_constraintCount; ++i) { + var c = this.m_constraints[i]; + var bodyA = c.bodyA; + var bodyB = c.bodyB; + var wA = bodyA.m_angularVelocity; + var wB = bodyB.m_angularVelocity; + var vA = bodyA.m_linearVelocity; + var vB = bodyB.m_linearVelocity; + var invMassA = bodyA.m_invMass; + var invIA = bodyA.m_invI; + var invMassB = bodyB.m_invMass; + var invIB = bodyB.m_invI; + var normalX = c.normal.x; + var normalY = c.normal.y; + var tangentX = normalY; + var tangentY = (-normalX); + var friction = c.friction; + var tX = 0; + for (j = 0; + j < c.pointCount; j++) { + ccp = c.points[j]; + dvX = vB.x - wB * ccp.rB.y - vA.x + wA * ccp.rA.y; + dvY = vB.y + wB * ccp.rB.x - vA.y - wA * ccp.rA.x; + vt = dvX * tangentX + dvY * tangentY; + lambda = ccp.tangentMass * (-vt); + maxFriction = friction * ccp.normalImpulse; + newImpulse = b2Math.Clamp(ccp.tangentImpulse + lambda, (-maxFriction), maxFriction); + lambda = newImpulse - ccp.tangentImpulse; + PX = lambda * tangentX; + PY = lambda * tangentY; + vA.x -= invMassA * PX; + vA.y -= invMassA * PY; + wA -= invIA * (ccp.rA.x * PY - ccp.rA.y * PX); + vB.x += invMassB * PX; + vB.y += invMassB * PY; + wB += invIB * (ccp.rB.x * PY - ccp.rB.y * PX); + ccp.tangentImpulse = newImpulse; + } + var tCount = parseInt(c.pointCount); + if (c.pointCount == 1) { + ccp = c.points[0]; + dvX = vB.x + ((-wB * ccp.rB.y)) - vA.x - ((-wA * ccp.rA.y)); + dvY = vB.y + (wB * ccp.rB.x) - vA.y - (wA * ccp.rA.x); + vn = dvX * normalX + dvY * normalY; + lambda = (-ccp.normalMass * (vn - ccp.velocityBias)); + newImpulse = ccp.normalImpulse + lambda; + newImpulse = newImpulse > 0 ? newImpulse : 0.0; + lambda = newImpulse - ccp.normalImpulse; + PX = lambda * normalX; + PY = lambda * normalY; + vA.x -= invMassA * PX; + vA.y -= invMassA * PY; + wA -= invIA * (ccp.rA.x * PY - ccp.rA.y * PX); + vB.x += invMassB * PX; + vB.y += invMassB * PY; + wB += invIB * (ccp.rB.x * PY - ccp.rB.y * PX); + ccp.normalImpulse = newImpulse; + } + else { + var cp1 = c.points[0]; + var cp2 = c.points[1]; + var aX = cp1.normalImpulse; + var aY = cp2.normalImpulse; + var dv1X = vB.x - wB * cp1.rB.y - vA.x + wA * cp1.rA.y; + var dv1Y = vB.y + wB * cp1.rB.x - vA.y - wA * cp1.rA.x; + var dv2X = vB.x - wB * cp2.rB.y - vA.x + wA * cp2.rA.y; + var dv2Y = vB.y + wB * cp2.rB.x - vA.y - wA * cp2.rA.x; + var vn1 = dv1X * normalX + dv1Y * normalY; + var vn2 = dv2X * normalX + dv2Y * normalY; + var bX = vn1 - cp1.velocityBias; + var bY = vn2 - cp2.velocityBias; + tMat = c.K; + bX -= tMat.col1.x * aX + tMat.col2.x * aY; + bY -= tMat.col1.y * aX + tMat.col2.y * aY; + var k_errorTol = 0.001; + for (;;) { + tMat = c.normalMass; + var xX = (-(tMat.col1.x * bX + tMat.col2.x * bY)); + var xY = (-(tMat.col1.y * bX + tMat.col2.y * bY)); + if (xX >= 0.0 && xY >= 0.0) { + dX = xX - aX; + dY = xY - aY; + P1X = dX * normalX; + P1Y = dX * normalY; + P2X = dY * normalX; + P2Y = dY * normalY; + vA.x -= invMassA * (P1X + P2X); + vA.y -= invMassA * (P1Y + P2Y); + wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X); + vB.x += invMassB * (P1X + P2X); + vB.y += invMassB * (P1Y + P2Y); + wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X); + cp1.normalImpulse = xX; + cp2.normalImpulse = xY; + break; + } + xX = (-cp1.normalMass * bX); + xY = 0.0; + vn1 = 0.0; + vn2 = c.K.col1.y * xX + bY; + if (xX >= 0.0 && vn2 >= 0.0) { + dX = xX - aX; + dY = xY - aY; + P1X = dX * normalX; + P1Y = dX * normalY; + P2X = dY * normalX; + P2Y = dY * normalY; + vA.x -= invMassA * (P1X + P2X); + vA.y -= invMassA * (P1Y + P2Y); + wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X); + vB.x += invMassB * (P1X + P2X); + vB.y += invMassB * (P1Y + P2Y); + wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X); + cp1.normalImpulse = xX; + cp2.normalImpulse = xY; + break; + } + xX = 0.0; + xY = (-cp2.normalMass * bY); + vn1 = c.K.col2.x * xY + bX; + vn2 = 0.0; + if (xY >= 0.0 && vn1 >= 0.0) { + dX = xX - aX; + dY = xY - aY; + P1X = dX * normalX; + P1Y = dX * normalY; + P2X = dY * normalX; + P2Y = dY * normalY; + vA.x -= invMassA * (P1X + P2X); + vA.y -= invMassA * (P1Y + P2Y); + wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X); + vB.x += invMassB * (P1X + P2X); + vB.y += invMassB * (P1Y + P2Y); + wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X); + cp1.normalImpulse = xX; + cp2.normalImpulse = xY; + break; + } + xX = 0.0; + xY = 0.0; + vn1 = bX; + vn2 = bY; + if (vn1 >= 0.0 && vn2 >= 0.0) { + dX = xX - aX; + dY = xY - aY; + P1X = dX * normalX; + P1Y = dX * normalY; + P2X = dY * normalX; + P2Y = dY * normalY; + vA.x -= invMassA * (P1X + P2X); + vA.y -= invMassA * (P1Y + P2Y); + wA -= invIA * (cp1.rA.x * P1Y - cp1.rA.y * P1X + cp2.rA.x * P2Y - cp2.rA.y * P2X); + vB.x += invMassB * (P1X + P2X); + vB.y += invMassB * (P1Y + P2Y); + wB += invIB * (cp1.rB.x * P1Y - cp1.rB.y * P1X + cp2.rB.x * P2Y - cp2.rB.y * P2X); + cp1.normalImpulse = xX; + cp2.normalImpulse = xY; + break; + } + break; + } + } + bodyA.m_angularVelocity = wA; + bodyB.m_angularVelocity = wB; + } + } + b2ContactSolver.prototype.FinalizeVelocityConstraints = function () { + for (var i = 0; i < this.m_constraintCount; ++i) { + var c = this.m_constraints[i]; + var m = c.manifold; + for (var j = 0; j < c.pointCount; ++j) { + var point1 = m.m_points[j]; + var point2 = c.points[j]; + point1.m_normalImpulse = point2.normalImpulse; + point1.m_tangentImpulse = point2.tangentImpulse; + } + } + } + b2ContactSolver.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var minSeparation = 0.0; + for (var i = 0; i < this.m_constraintCount; i++) { + var c = this.m_constraints[i]; + var bodyA = c.bodyA; + var bodyB = c.bodyB; + var invMassA = bodyA.m_mass * bodyA.m_invMass; + var invIA = bodyA.m_mass * bodyA.m_invI; + var invMassB = bodyB.m_mass * bodyB.m_invMass; + var invIB = bodyB.m_mass * bodyB.m_invI; + b2ContactSolver.s_psm.Initialize(c); + var normal = b2ContactSolver.s_psm.m_normal; + for (var j = 0; j < c.pointCount; j++) { + var ccp = c.points[j]; + var point = b2ContactSolver.s_psm.m_points[j]; + var separation = b2ContactSolver.s_psm.m_separations[j]; + var rAX = point.x - bodyA.m_sweep.c.x; + var rAY = point.y - bodyA.m_sweep.c.y; + var rBX = point.x - bodyB.m_sweep.c.x; + var rBY = point.y - bodyB.m_sweep.c.y; + minSeparation = minSeparation < separation ? minSeparation : separation; + var C = b2Math.Clamp(baumgarte * (separation + b2Settings.b2_linearSlop), (-b2Settings.b2_maxLinearCorrection), 0.0); + var impulse = (-ccp.equalizedMass * C); + var PX = impulse * normal.x; + var PY = impulse * normal.y;bodyA.m_sweep.c.x -= invMassA * PX; + bodyA.m_sweep.c.y -= invMassA * PY; + bodyA.m_sweep.a -= invIA * (rAX * PY - rAY * PX); + bodyA.SynchronizeTransform(); + bodyB.m_sweep.c.x += invMassB * PX; + bodyB.m_sweep.c.y += invMassB * PY; + bodyB.m_sweep.a += invIB * (rBX * PY - rBY * PX); + bodyB.SynchronizeTransform(); + } + } + return minSeparation > (-1.5 * b2Settings.b2_linearSlop); + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.Contacts.b2ContactSolver.s_worldManifold = new b2WorldManifold(); + Box2D.Dynamics.Contacts.b2ContactSolver.s_psm = new b2PositionSolverManifold(); + }); + Box2D.inherit(b2EdgeAndCircleContact, Box2D.Dynamics.Contacts.b2Contact); + b2EdgeAndCircleContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; + b2EdgeAndCircleContact.b2EdgeAndCircleContact = function () { + Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); + }; + b2EdgeAndCircleContact.Create = function (allocator) { + return new b2EdgeAndCircleContact(); + } + b2EdgeAndCircleContact.Destroy = function (contact, allocator) {} + b2EdgeAndCircleContact.prototype.Reset = function (fixtureA, fixtureB) { + this.__super.Reset.call(this, fixtureA, fixtureB); + } + b2EdgeAndCircleContact.prototype.Evaluate = function () { + var bA = this.m_fixtureA.GetBody(); + var bB = this.m_fixtureB.GetBody(); + this.b2CollideEdgeAndCircle(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2EdgeShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2CircleShape ? this.m_fixtureB.GetShape() : null), bB.m_xf); + } + b2EdgeAndCircleContact.prototype.b2CollideEdgeAndCircle = function (manifold, edge, xf1, circle, xf2) {} + Box2D.inherit(b2NullContact, Box2D.Dynamics.Contacts.b2Contact); + b2NullContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; + b2NullContact.b2NullContact = function () { + Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); + }; + b2NullContact.prototype.b2NullContact = function () { + this.__super.b2Contact.call(this); + } + b2NullContact.prototype.Evaluate = function () {} + Box2D.inherit(b2PolyAndCircleContact, Box2D.Dynamics.Contacts.b2Contact); + b2PolyAndCircleContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; + b2PolyAndCircleContact.b2PolyAndCircleContact = function () { + Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); + }; + b2PolyAndCircleContact.Create = function (allocator) { + return new b2PolyAndCircleContact(); + } + b2PolyAndCircleContact.Destroy = function (contact, allocator) {} + b2PolyAndCircleContact.prototype.Reset = function (fixtureA, fixtureB) { + this.__super.Reset.call(this, fixtureA, fixtureB); + b2Settings.b2Assert(fixtureA.GetType() == b2Shape.e_polygonShape); + b2Settings.b2Assert(fixtureB.GetType() == b2Shape.e_circleShape); + } + b2PolyAndCircleContact.prototype.Evaluate = function () { + var bA = this.m_fixtureA.m_body; + var bB = this.m_fixtureB.m_body; + b2Collision.CollidePolygonAndCircle(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2PolygonShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2CircleShape ? this.m_fixtureB.GetShape() : null), bB.m_xf); + } + Box2D.inherit(b2PolyAndEdgeContact, Box2D.Dynamics.Contacts.b2Contact); + b2PolyAndEdgeContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; + b2PolyAndEdgeContact.b2PolyAndEdgeContact = function () { + Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); + }; + b2PolyAndEdgeContact.Create = function (allocator) { + return new b2PolyAndEdgeContact(); + } + b2PolyAndEdgeContact.Destroy = function (contact, allocator) {} + b2PolyAndEdgeContact.prototype.Reset = function (fixtureA, fixtureB) { + this.__super.Reset.call(this, fixtureA, fixtureB); + b2Settings.b2Assert(fixtureA.GetType() == b2Shape.e_polygonShape); + b2Settings.b2Assert(fixtureB.GetType() == b2Shape.e_edgeShape); + } + b2PolyAndEdgeContact.prototype.Evaluate = function () { + var bA = this.m_fixtureA.GetBody(); + var bB = this.m_fixtureB.GetBody(); + this.b2CollidePolyAndEdge(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2PolygonShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2EdgeShape ? this.m_fixtureB.GetShape() : null), bB.m_xf); + } + b2PolyAndEdgeContact.prototype.b2CollidePolyAndEdge = function (manifold, polygon, xf1, edge, xf2) {} + Box2D.inherit(b2PolygonContact, Box2D.Dynamics.Contacts.b2Contact); + b2PolygonContact.prototype.__super = Box2D.Dynamics.Contacts.b2Contact.prototype; + b2PolygonContact.b2PolygonContact = function () { + Box2D.Dynamics.Contacts.b2Contact.b2Contact.apply(this, arguments); + }; + b2PolygonContact.Create = function (allocator) { + return new b2PolygonContact(); + } + b2PolygonContact.Destroy = function (contact, allocator) {} + b2PolygonContact.prototype.Reset = function (fixtureA, fixtureB) { + this.__super.Reset.call(this, fixtureA, fixtureB); + } + b2PolygonContact.prototype.Evaluate = function () { + var bA = this.m_fixtureA.GetBody(); + var bB = this.m_fixtureB.GetBody(); + b2Collision.CollidePolygons(this.m_manifold, (this.m_fixtureA.GetShape() instanceof b2PolygonShape ? this.m_fixtureA.GetShape() : null), bA.m_xf, (this.m_fixtureB.GetShape() instanceof b2PolygonShape ? this.m_fixtureB.GetShape() : null), bB.m_xf); + } + b2PositionSolverManifold.b2PositionSolverManifold = function () {}; + b2PositionSolverManifold.prototype.b2PositionSolverManifold = function () { + this.m_normal = new b2Vec2(); + this.m_separations = new Vector_a2j_Number(b2Settings.b2_maxManifoldPoints); + this.m_points = new Vector(b2Settings.b2_maxManifoldPoints); + for (var i = 0; i < b2Settings.b2_maxManifoldPoints; i++) { + this.m_points[i] = new b2Vec2(); + } + } + b2PositionSolverManifold.prototype.Initialize = function (cc) { + b2Settings.b2Assert(cc.pointCount > 0); + var i = 0; + var clipPointX = 0; + var clipPointY = 0; + var tMat; + var tVec; + var planePointX = 0; + var planePointY = 0; + switch (cc.type) { + case b2Manifold.e_circles: + { + tMat = cc.bodyA.m_xf.R; + tVec = cc.localPoint; + var pointAX = cc.bodyA.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var pointAY = cc.bodyA.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tMat = cc.bodyB.m_xf.R; + tVec = cc.points[0].localPoint; + var pointBX = cc.bodyB.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + var pointBY = cc.bodyB.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + var dX = pointBX - pointAX; + var dY = pointBY - pointAY; + var d2 = dX * dX + dY * dY; + if (d2 > Number.MIN_VALUE * Number.MIN_VALUE) { + var d = Math.sqrt(d2); + this.m_normal.x = dX / d; + this.m_normal.y = dY / d; + } + else { + this.m_normal.x = 1.0; + this.m_normal.y = 0.0; + } + this.m_points[0].x = 0.5 * (pointAX + pointBX); + this.m_points[0].y = 0.5 * (pointAY + pointBY); + this.m_separations[0] = dX * this.m_normal.x + dY * this.m_normal.y - cc.radius; + } + break; + case b2Manifold.e_faceA: + { + tMat = cc.bodyA.m_xf.R; + tVec = cc.localPlaneNormal; + this.m_normal.x = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + this.m_normal.y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tMat = cc.bodyA.m_xf.R; + tVec = cc.localPoint; + planePointX = cc.bodyA.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + planePointY = cc.bodyA.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tMat = cc.bodyB.m_xf.R; + for (i = 0; + i < cc.pointCount; ++i) { + tVec = cc.points[i].localPoint; + clipPointX = cc.bodyB.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + clipPointY = cc.bodyB.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + this.m_separations[i] = (clipPointX - planePointX) * this.m_normal.x + (clipPointY - planePointY) * this.m_normal.y - cc.radius; + this.m_points[i].x = clipPointX; + this.m_points[i].y = clipPointY; + } + } + break; + case b2Manifold.e_faceB: + { + tMat = cc.bodyB.m_xf.R; + tVec = cc.localPlaneNormal; + this.m_normal.x = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + this.m_normal.y = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tMat = cc.bodyB.m_xf.R; + tVec = cc.localPoint; + planePointX = cc.bodyB.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + planePointY = cc.bodyB.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + tMat = cc.bodyA.m_xf.R; + for (i = 0; + i < cc.pointCount; ++i) { + tVec = cc.points[i].localPoint; + clipPointX = cc.bodyA.m_xf.position.x + (tMat.col1.x * tVec.x + tMat.col2.x * tVec.y); + clipPointY = cc.bodyA.m_xf.position.y + (tMat.col1.y * tVec.x + tMat.col2.y * tVec.y); + this.m_separations[i] = (clipPointX - planePointX) * this.m_normal.x + (clipPointY - planePointY) * this.m_normal.y - cc.radius; + this.m_points[i].Set(clipPointX, clipPointY); + } + this.m_normal.x *= (-1); + this.m_normal.y *= (-1); + } + break; + } + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.Contacts.b2PositionSolverManifold.circlePointA = new b2Vec2(); + Box2D.Dynamics.Contacts.b2PositionSolverManifold.circlePointB = new b2Vec2(); + }); +})(); +(function () { + var b2Body = Box2D.Dynamics.b2Body, + b2BodyDef = Box2D.Dynamics.b2BodyDef, + b2ContactFilter = Box2D.Dynamics.b2ContactFilter, + b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse, + b2ContactListener = Box2D.Dynamics.b2ContactListener, + b2ContactManager = Box2D.Dynamics.b2ContactManager, + b2DebugDraw = Box2D.Dynamics.b2DebugDraw, + b2DestructionListener = Box2D.Dynamics.b2DestructionListener, + b2FilterData = Box2D.Dynamics.b2FilterData, + b2Fixture = Box2D.Dynamics.b2Fixture, + b2FixtureDef = Box2D.Dynamics.b2FixtureDef, + b2Island = Box2D.Dynamics.b2Island, + b2TimeStep = Box2D.Dynamics.b2TimeStep, + b2World = Box2D.Dynamics.b2World, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3, + b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2CircleShape = Box2D.Collision.Shapes.b2CircleShape, + b2EdgeChainDef = Box2D.Collision.Shapes.b2EdgeChainDef, + b2EdgeShape = Box2D.Collision.Shapes.b2EdgeShape, + b2MassData = Box2D.Collision.Shapes.b2MassData, + b2PolygonShape = Box2D.Collision.Shapes.b2PolygonShape, + b2Shape = Box2D.Collision.Shapes.b2Shape, + b2BuoyancyController = Box2D.Dynamics.Controllers.b2BuoyancyController, + b2ConstantAccelController = Box2D.Dynamics.Controllers.b2ConstantAccelController, + b2ConstantForceController = Box2D.Dynamics.Controllers.b2ConstantForceController, + b2Controller = Box2D.Dynamics.Controllers.b2Controller, + b2ControllerEdge = Box2D.Dynamics.Controllers.b2ControllerEdge, + b2GravityController = Box2D.Dynamics.Controllers.b2GravityController, + b2TensorDampingController = Box2D.Dynamics.Controllers.b2TensorDampingController; + + Box2D.inherit(b2BuoyancyController, Box2D.Dynamics.Controllers.b2Controller); + b2BuoyancyController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype; + b2BuoyancyController.b2BuoyancyController = function () { + Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments); + this.normal = new b2Vec2(0, (-1)); + this.offset = 0; + this.density = 0; + this.velocity = new b2Vec2(0, 0); + this.linearDrag = 2; + this.angularDrag = 1; + this.useDensity = false; + this.useWorldGravity = true; + this.gravity = null; + }; + b2BuoyancyController.prototype.Step = function (step) { + if (!this.m_bodyList) return; + if (this.useWorldGravity) { + this.gravity = this.GetWorld().GetGravity().Copy(); + } + for (var i = this.m_bodyList; i; i = i.nextBody) { + var body = i.body; + if (body.IsAwake() == false) { + continue; + } + var areac = new b2Vec2(); + var massc = new b2Vec2(); + var area = 0.0; + var mass = 0.0; + for (var fixture = body.GetFixtureList(); fixture; fixture = fixture.GetNext()) { + var sc = new b2Vec2(); + var sarea = fixture.GetShape().ComputeSubmergedArea(this.normal, this.offset, body.GetTransform(), sc); + area += sarea; + areac.x += sarea * sc.x; + areac.y += sarea * sc.y; + var shapeDensity = 0; + if (this.useDensity) { + shapeDensity = 1; + } + else { + shapeDensity = 1; + } + mass += sarea * shapeDensity; + massc.x += sarea * sc.x * shapeDensity; + massc.y += sarea * sc.y * shapeDensity; + } + areac.x /= area; + areac.y /= area; + massc.x /= mass; + massc.y /= mass; + if (area < Number.MIN_VALUE) continue; + var buoyancyForce = this.gravity.GetNegative(); + buoyancyForce.Multiply(this.density * area); + body.ApplyForce(buoyancyForce, massc); + var dragForce = body.GetLinearVelocityFromWorldPoint(areac); + dragForce.Subtract(this.velocity); + dragForce.Multiply((-this.linearDrag * area)); + body.ApplyForce(dragForce, areac); + body.ApplyTorque((-body.GetInertia() / body.GetMass() * area * body.GetAngularVelocity() * this.angularDrag)); + } + } + b2BuoyancyController.prototype.Draw = function (debugDraw) { + var r = 1000; + var p1 = new b2Vec2(); + var p2 = new b2Vec2(); + p1.x = this.normal.x * this.offset + this.normal.y * r; + p1.y = this.normal.y * this.offset - this.normal.x * r; + p2.x = this.normal.x * this.offset - this.normal.y * r; + p2.y = this.normal.y * this.offset + this.normal.x * r; + var color = new b2Color(0, 0, 1); + debugDraw.DrawSegment(p1, p2, color); + } + Box2D.inherit(b2ConstantAccelController, Box2D.Dynamics.Controllers.b2Controller); + b2ConstantAccelController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype; + b2ConstantAccelController.b2ConstantAccelController = function () { + Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments); + this.A = new b2Vec2(0, 0); + }; + b2ConstantAccelController.prototype.Step = function (step) { + var smallA = new b2Vec2(this.A.x * step.dt, this.A.y * step.dt); + for (var i = this.m_bodyList; i; i = i.nextBody) { + var body = i.body; + if (!body.IsAwake()) continue; + body.SetLinearVelocity(new b2Vec2(body.GetLinearVelocity().x + smallA.x, body.GetLinearVelocity().y + smallA.y)); + } + } + Box2D.inherit(b2ConstantForceController, Box2D.Dynamics.Controllers.b2Controller); + b2ConstantForceController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype; + b2ConstantForceController.b2ConstantForceController = function () { + Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments); + this.F = new b2Vec2(0, 0); + }; + b2ConstantForceController.prototype.Step = function (step) { + for (var i = this.m_bodyList; i; i = i.nextBody) { + var body = i.body; + if (!body.IsAwake()) continue; + body.ApplyForce(this.F, body.GetWorldCenter()); + } + } + b2Controller.b2Controller = function () {}; + b2Controller.prototype.Step = function (step) {} + b2Controller.prototype.Draw = function (debugDraw) {} + b2Controller.prototype.AddBody = function (body) { + var edge = new b2ControllerEdge(); + edge.controller = this; + edge.body = body; + edge.nextBody = this.m_bodyList; + edge.prevBody = null; + this.m_bodyList = edge; + if (edge.nextBody) edge.nextBody.prevBody = edge; + this.m_bodyCount++; + edge.nextController = body.m_controllerList; + edge.prevController = null; + body.m_controllerList = edge; + if (edge.nextController) edge.nextController.prevController = edge; + body.m_controllerCount++; + } + b2Controller.prototype.RemoveBody = function (body) { + var edge = body.m_controllerList; + while (edge && edge.controller != this) + edge = edge.nextController; + if (edge.prevBody) edge.prevBody.nextBody = edge.nextBody; + if (edge.nextBody) edge.nextBody.prevBody = edge.prevBody; + if (edge.nextController) edge.nextController.prevController = edge.prevController; + if (edge.prevController) edge.prevController.nextController = edge.nextController; + if (this.m_bodyList == edge) this.m_bodyList = edge.nextBody; + if (body.m_controllerList == edge) body.m_controllerList = edge.nextController; + body.m_controllerCount--; + this.m_bodyCount--; + } + b2Controller.prototype.Clear = function () { + while (this.m_bodyList) + this.RemoveBody(this.m_bodyList.body); + } + b2Controller.prototype.GetNext = function () { + return this.m_next; + } + b2Controller.prototype.GetWorld = function () { + return this.m_world; + } + b2Controller.prototype.GetBodyList = function () { + return this.m_bodyList; + } + b2ControllerEdge.b2ControllerEdge = function () {}; + Box2D.inherit(b2GravityController, Box2D.Dynamics.Controllers.b2Controller); + b2GravityController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype; + b2GravityController.b2GravityController = function () { + Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments); + this.G = 1; + this.invSqr = true; + }; + b2GravityController.prototype.Step = function (step) { + var i = null; + var body1 = null; + var p1 = null; + var mass1 = 0; + var j = null; + var body2 = null; + var p2 = null; + var dx = 0; + var dy = 0; + var r2 = 0; + var f = null; + if (this.invSqr) { + for (i = this.m_bodyList; + i; i = i.nextBody) { + body1 = i.body; + p1 = body1.GetWorldCenter(); + mass1 = body1.GetMass(); + for (j = this.m_bodyList; + j != i; j = j.nextBody) { + body2 = j.body; + p2 = body2.GetWorldCenter(); + dx = p2.x - p1.x; + dy = p2.y - p1.y; + r2 = dx * dx + dy * dy; + if (r2 < Number.MIN_VALUE) continue; + f = new b2Vec2(dx, dy); + f.Multiply(this.G / r2 / Math.sqrt(r2) * mass1 * body2.GetMass()); + if (body1.IsAwake()) body1.ApplyForce(f, p1); + f.Multiply((-1)); + if (body2.IsAwake()) body2.ApplyForce(f, p2); + } + } + } + else { + for (i = this.m_bodyList; + i; i = i.nextBody) { + body1 = i.body; + p1 = body1.GetWorldCenter(); + mass1 = body1.GetMass(); + for (j = this.m_bodyList; + j != i; j = j.nextBody) { + body2 = j.body; + p2 = body2.GetWorldCenter(); + dx = p2.x - p1.x; + dy = p2.y - p1.y; + r2 = dx * dx + dy * dy; + if (r2 < Number.MIN_VALUE) continue; + f = new b2Vec2(dx, dy); + f.Multiply(this.G / r2 * mass1 * body2.GetMass()); + if (body1.IsAwake()) body1.ApplyForce(f, p1); + f.Multiply((-1)); + if (body2.IsAwake()) body2.ApplyForce(f, p2); + } + } + } + } + Box2D.inherit(b2TensorDampingController, Box2D.Dynamics.Controllers.b2Controller); + b2TensorDampingController.prototype.__super = Box2D.Dynamics.Controllers.b2Controller.prototype; + b2TensorDampingController.b2TensorDampingController = function () { + Box2D.Dynamics.Controllers.b2Controller.b2Controller.apply(this, arguments); + this.T = new b2Mat22(); + this.maxTimestep = 0; + }; + b2TensorDampingController.prototype.SetAxisAligned = function (xDamping, yDamping) { + if (xDamping === undefined) xDamping = 0; + if (yDamping === undefined) yDamping = 0; + this.T.col1.x = (-xDamping); + this.T.col1.y = 0; + this.T.col2.x = 0; + this.T.col2.y = (-yDamping); + if (xDamping > 0 || yDamping > 0) { + this.maxTimestep = 1 / Math.max(xDamping, yDamping); + } + else { + this.maxTimestep = 0; + } + } + b2TensorDampingController.prototype.Step = function (step) { + var timestep = step.dt; + if (timestep <= Number.MIN_VALUE) return; + if (timestep > this.maxTimestep && this.maxTimestep > 0) timestep = this.maxTimestep; + for (var i = this.m_bodyList; i; i = i.nextBody) { + var body = i.body; + if (!body.IsAwake()) { + continue; + } + var damping = body.GetWorldVector(b2Math.MulMV(this.T, body.GetLocalVector(body.GetLinearVelocity()))); + body.SetLinearVelocity(new b2Vec2(body.GetLinearVelocity().x + damping.x * timestep, body.GetLinearVelocity().y + damping.y * timestep)); + } + } +})(); +(function () { + var b2Color = Box2D.Common.b2Color, + b2internal = Box2D.Common.b2internal, + b2Settings = Box2D.Common.b2Settings, + b2Mat22 = Box2D.Common.Math.b2Mat22, + b2Mat33 = Box2D.Common.Math.b2Mat33, + b2Math = Box2D.Common.Math.b2Math, + b2Sweep = Box2D.Common.Math.b2Sweep, + b2Transform = Box2D.Common.Math.b2Transform, + b2Vec2 = Box2D.Common.Math.b2Vec2, + b2Vec3 = Box2D.Common.Math.b2Vec3, + b2DistanceJoint = Box2D.Dynamics.Joints.b2DistanceJoint, + b2DistanceJointDef = Box2D.Dynamics.Joints.b2DistanceJointDef, + b2FrictionJoint = Box2D.Dynamics.Joints.b2FrictionJoint, + b2FrictionJointDef = Box2D.Dynamics.Joints.b2FrictionJointDef, + b2GearJoint = Box2D.Dynamics.Joints.b2GearJoint, + b2GearJointDef = Box2D.Dynamics.Joints.b2GearJointDef, + b2Jacobian = Box2D.Dynamics.Joints.b2Jacobian, + b2Joint = Box2D.Dynamics.Joints.b2Joint, + b2JointDef = Box2D.Dynamics.Joints.b2JointDef, + b2JointEdge = Box2D.Dynamics.Joints.b2JointEdge, + b2LineJoint = Box2D.Dynamics.Joints.b2LineJoint, + b2LineJointDef = Box2D.Dynamics.Joints.b2LineJointDef, + b2MouseJoint = Box2D.Dynamics.Joints.b2MouseJoint, + b2MouseJointDef = Box2D.Dynamics.Joints.b2MouseJointDef, + b2PrismaticJoint = Box2D.Dynamics.Joints.b2PrismaticJoint, + b2PrismaticJointDef = Box2D.Dynamics.Joints.b2PrismaticJointDef, + b2PulleyJoint = Box2D.Dynamics.Joints.b2PulleyJoint, + b2PulleyJointDef = Box2D.Dynamics.Joints.b2PulleyJointDef, + b2RevoluteJoint = Box2D.Dynamics.Joints.b2RevoluteJoint, + b2RevoluteJointDef = Box2D.Dynamics.Joints.b2RevoluteJointDef, + b2WeldJoint = Box2D.Dynamics.Joints.b2WeldJoint, + b2WeldJointDef = Box2D.Dynamics.Joints.b2WeldJointDef, + b2Body = Box2D.Dynamics.b2Body, + b2BodyDef = Box2D.Dynamics.b2BodyDef, + b2ContactFilter = Box2D.Dynamics.b2ContactFilter, + b2ContactImpulse = Box2D.Dynamics.b2ContactImpulse, + b2ContactListener = Box2D.Dynamics.b2ContactListener, + b2ContactManager = Box2D.Dynamics.b2ContactManager, + b2DebugDraw = Box2D.Dynamics.b2DebugDraw, + b2DestructionListener = Box2D.Dynamics.b2DestructionListener, + b2FilterData = Box2D.Dynamics.b2FilterData, + b2Fixture = Box2D.Dynamics.b2Fixture, + b2FixtureDef = Box2D.Dynamics.b2FixtureDef, + b2Island = Box2D.Dynamics.b2Island, + b2TimeStep = Box2D.Dynamics.b2TimeStep, + b2World = Box2D.Dynamics.b2World; + + Box2D.inherit(b2DistanceJoint, Box2D.Dynamics.Joints.b2Joint); + b2DistanceJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2DistanceJoint.b2DistanceJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.m_localAnchor1 = new b2Vec2(); + this.m_localAnchor2 = new b2Vec2(); + this.m_u = new b2Vec2(); + }; + b2DistanceJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); + } + b2DistanceJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); + } + b2DistanceJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * this.m_impulse * this.m_u.x, inv_dt * this.m_impulse * this.m_u.y); + } + b2DistanceJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return 0.0; + } + b2DistanceJoint.prototype.GetLength = function () { + return this.m_length; + } + b2DistanceJoint.prototype.SetLength = function (length) { + if (length === undefined) length = 0; + this.m_length = length; + } + b2DistanceJoint.prototype.GetFrequency = function () { + return this.m_frequencyHz; + } + b2DistanceJoint.prototype.SetFrequency = function (hz) { + if (hz === undefined) hz = 0; + this.m_frequencyHz = hz; + } + b2DistanceJoint.prototype.GetDampingRatio = function () { + return this.m_dampingRatio; + } + b2DistanceJoint.prototype.SetDampingRatio = function (ratio) { + if (ratio === undefined) ratio = 0; + this.m_dampingRatio = ratio; + } + b2DistanceJoint.prototype.b2DistanceJoint = function (def) { + this.__super.b2Joint.call(this, def); + var tMat; + var tX = 0; + var tY = 0; + this.m_localAnchor1.SetV(def.localAnchorA); + this.m_localAnchor2.SetV(def.localAnchorB); + this.m_length = def.length; + this.m_frequencyHz = def.frequencyHz; + this.m_dampingRatio = def.dampingRatio; + this.m_impulse = 0.0; + this.m_gamma = 0.0; + this.m_bias = 0.0; + } + b2DistanceJoint.prototype.InitVelocityConstraints = function (step) { + var tMat; + var tX = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + this.m_u.x = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; + this.m_u.y = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; + var length = Math.sqrt(this.m_u.x * this.m_u.x + this.m_u.y * this.m_u.y); + if (length > b2Settings.b2_linearSlop) { + this.m_u.Multiply(1.0 / length); + } + else { + this.m_u.SetZero(); + } + var cr1u = (r1X * this.m_u.y - r1Y * this.m_u.x); + var cr2u = (r2X * this.m_u.y - r2Y * this.m_u.x); + var invMass = bA.m_invMass + bA.m_invI * cr1u * cr1u + bB.m_invMass + bB.m_invI * cr2u * cr2u; + this.m_mass = invMass != 0.0 ? 1.0 / invMass : 0.0; + if (this.m_frequencyHz > 0.0) { + var C = length - this.m_length; + var omega = 2.0 * Math.PI * this.m_frequencyHz; + var d = 2.0 * this.m_mass * this.m_dampingRatio * omega; + var k = this.m_mass * omega * omega; + this.m_gamma = step.dt * (d + step.dt * k); + this.m_gamma = this.m_gamma != 0.0 ? 1 / this.m_gamma : 0.0; + this.m_bias = C * step.dt * k * this.m_gamma; + this.m_mass = invMass + this.m_gamma; + this.m_mass = this.m_mass != 0.0 ? 1.0 / this.m_mass : 0.0; + } + if (step.warmStarting) { + this.m_impulse *= step.dtRatio; + var PX = this.m_impulse * this.m_u.x; + var PY = this.m_impulse * this.m_u.y; + bA.m_linearVelocity.x -= bA.m_invMass * PX; + bA.m_linearVelocity.y -= bA.m_invMass * PY; + bA.m_angularVelocity -= bA.m_invI * (r1X * PY - r1Y * PX); + bB.m_linearVelocity.x += bB.m_invMass * PX; + bB.m_linearVelocity.y += bB.m_invMass * PY; + bB.m_angularVelocity += bB.m_invI * (r2X * PY - r2Y * PX); + } + else { + this.m_impulse = 0.0; + } + } + b2DistanceJoint.prototype.SolveVelocityConstraints = function (step) { + var tMat; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var v1X = bA.m_linearVelocity.x + ((-bA.m_angularVelocity * r1Y)); + var v1Y = bA.m_linearVelocity.y + (bA.m_angularVelocity * r1X); + var v2X = bB.m_linearVelocity.x + ((-bB.m_angularVelocity * r2Y)); + var v2Y = bB.m_linearVelocity.y + (bB.m_angularVelocity * r2X); + var Cdot = (this.m_u.x * (v2X - v1X) + this.m_u.y * (v2Y - v1Y)); + var impulse = (-this.m_mass * (Cdot + this.m_bias + this.m_gamma * this.m_impulse)); + this.m_impulse += impulse; + var PX = impulse * this.m_u.x; + var PY = impulse * this.m_u.y; + bA.m_linearVelocity.x -= bA.m_invMass * PX; + bA.m_linearVelocity.y -= bA.m_invMass * PY; + bA.m_angularVelocity -= bA.m_invI * (r1X * PY - r1Y * PX); + bB.m_linearVelocity.x += bB.m_invMass * PX; + bB.m_linearVelocity.y += bB.m_invMass * PY; + bB.m_angularVelocity += bB.m_invI * (r2X * PY - r2Y * PX); + } + b2DistanceJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var tMat; + if (this.m_frequencyHz > 0.0) { + return true; + } + var bA = this.m_bodyA; + var bB = this.m_bodyB; + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var dX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; + var dY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; + var length = Math.sqrt(dX * dX + dY * dY); + dX /= length; + dY /= length; + var C = length - this.m_length; + C = b2Math.Clamp(C, (-b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection); + var impulse = (-this.m_mass * C); + this.m_u.Set(dX, dY); + var PX = impulse * this.m_u.x; + var PY = impulse * this.m_u.y; + bA.m_sweep.c.x -= bA.m_invMass * PX; + bA.m_sweep.c.y -= bA.m_invMass * PY; + bA.m_sweep.a -= bA.m_invI * (r1X * PY - r1Y * PX); + bB.m_sweep.c.x += bB.m_invMass * PX; + bB.m_sweep.c.y += bB.m_invMass * PY; + bB.m_sweep.a += bB.m_invI * (r2X * PY - r2Y * PX); + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + return b2Math.Abs(C) < b2Settings.b2_linearSlop; + } + Box2D.inherit(b2DistanceJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2DistanceJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2DistanceJointDef.b2DistanceJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.localAnchorA = new b2Vec2(); + this.localAnchorB = new b2Vec2(); + }; + b2DistanceJointDef.prototype.b2DistanceJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_distanceJoint; + this.length = 1.0; + this.frequencyHz = 0.0; + this.dampingRatio = 0.0; + } + b2DistanceJointDef.prototype.Initialize = function (bA, bB, anchorA, anchorB) { + this.bodyA = bA; + this.bodyB = bB; + this.localAnchorA.SetV(this.bodyA.GetLocalPoint(anchorA)); + this.localAnchorB.SetV(this.bodyB.GetLocalPoint(anchorB)); + var dX = anchorB.x - anchorA.x; + var dY = anchorB.y - anchorA.y; + this.length = Math.sqrt(dX * dX + dY * dY); + this.frequencyHz = 0.0; + this.dampingRatio = 0.0; + } + Box2D.inherit(b2FrictionJoint, Box2D.Dynamics.Joints.b2Joint); + b2FrictionJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2FrictionJoint.b2FrictionJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.m_localAnchorA = new b2Vec2(); + this.m_localAnchorB = new b2Vec2(); + this.m_linearMass = new b2Mat22(); + this.m_linearImpulse = new b2Vec2(); + }; + b2FrictionJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA); + } + b2FrictionJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB); + } + b2FrictionJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * this.m_linearImpulse.x, inv_dt * this.m_linearImpulse.y); + } + b2FrictionJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return inv_dt * this.m_angularImpulse; + } + b2FrictionJoint.prototype.SetMaxForce = function (force) { + if (force === undefined) force = 0; + this.m_maxForce = force; + } + b2FrictionJoint.prototype.GetMaxForce = function () { + return this.m_maxForce; + } + b2FrictionJoint.prototype.SetMaxTorque = function (torque) { + if (torque === undefined) torque = 0; + this.m_maxTorque = torque; + } + b2FrictionJoint.prototype.GetMaxTorque = function () { + return this.m_maxTorque; + } + b2FrictionJoint.prototype.b2FrictionJoint = function (def) { + this.__super.b2Joint.call(this, def); + this.m_localAnchorA.SetV(def.localAnchorA); + this.m_localAnchorB.SetV(def.localAnchorB); + this.m_linearMass.SetZero(); + this.m_angularMass = 0.0; + this.m_linearImpulse.SetZero(); + this.m_angularImpulse = 0.0; + this.m_maxForce = def.maxForce; + this.m_maxTorque = def.maxTorque; + } + b2FrictionJoint.prototype.InitVelocityConstraints = function (step) { + var tMat; + var tX = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + tMat = bA.m_xf.R; + var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x; + var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * rAX + tMat.col2.x * rAY); + rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY); + rAX = tX; + tMat = bB.m_xf.R; + var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x; + var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * rBX + tMat.col2.x * rBY); + rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY); + rBX = tX; + var mA = bA.m_invMass; + var mB = bB.m_invMass; + var iA = bA.m_invI; + var iB = bB.m_invI; + var K = new b2Mat22(); + K.col1.x = mA + mB; + K.col2.x = 0.0; + K.col1.y = 0.0; + K.col2.y = mA + mB; + K.col1.x += iA * rAY * rAY; + K.col2.x += (-iA * rAX * rAY); + K.col1.y += (-iA * rAX * rAY); + K.col2.y += iA * rAX * rAX; + K.col1.x += iB * rBY * rBY; + K.col2.x += (-iB * rBX * rBY); + K.col1.y += (-iB * rBX * rBY); + K.col2.y += iB * rBX * rBX; + K.GetInverse(this.m_linearMass); + this.m_angularMass = iA + iB; + if (this.m_angularMass > 0.0) { + this.m_angularMass = 1.0 / this.m_angularMass; + } + if (step.warmStarting) { + this.m_linearImpulse.x *= step.dtRatio; + this.m_linearImpulse.y *= step.dtRatio; + this.m_angularImpulse *= step.dtRatio; + var P = this.m_linearImpulse; + bA.m_linearVelocity.x -= mA * P.x; + bA.m_linearVelocity.y -= mA * P.y; + bA.m_angularVelocity -= iA * (rAX * P.y - rAY * P.x + this.m_angularImpulse); + bB.m_linearVelocity.x += mB * P.x; + bB.m_linearVelocity.y += mB * P.y; + bB.m_angularVelocity += iB * (rBX * P.y - rBY * P.x + this.m_angularImpulse); + } + else { + this.m_linearImpulse.SetZero(); + this.m_angularImpulse = 0.0; + } + } + b2FrictionJoint.prototype.SolveVelocityConstraints = function (step) { + var tMat; + var tX = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var vA = bA.m_linearVelocity; + var wA = bA.m_angularVelocity; + var vB = bB.m_linearVelocity; + var wB = bB.m_angularVelocity; + var mA = bA.m_invMass; + var mB = bB.m_invMass; + var iA = bA.m_invI; + var iB = bB.m_invI; + tMat = bA.m_xf.R; + var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x; + var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * rAX + tMat.col2.x * rAY); + rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY); + rAX = tX; + tMat = bB.m_xf.R; + var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x; + var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * rBX + tMat.col2.x * rBY); + rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY); + rBX = tX; + var maxImpulse = 0; { + var Cdot = wB - wA; + var impulse = (-this.m_angularMass * Cdot); + var oldImpulse = this.m_angularImpulse; + maxImpulse = step.dt * this.m_maxTorque; + this.m_angularImpulse = b2Math.Clamp(this.m_angularImpulse + impulse, (-maxImpulse), maxImpulse); + impulse = this.m_angularImpulse - oldImpulse; + wA -= iA * impulse; + wB += iB * impulse; + } { + var CdotX = vB.x - wB * rBY - vA.x + wA * rAY; + var CdotY = vB.y + wB * rBX - vA.y - wA * rAX; + var impulseV = b2Math.MulMV(this.m_linearMass, new b2Vec2((-CdotX), (-CdotY))); + var oldImpulseV = this.m_linearImpulse.Copy(); + this.m_linearImpulse.Add(impulseV); + maxImpulse = step.dt * this.m_maxForce; + if (this.m_linearImpulse.LengthSquared() > maxImpulse * maxImpulse) { + this.m_linearImpulse.Normalize(); + this.m_linearImpulse.Multiply(maxImpulse); + } + impulseV = b2Math.SubtractVV(this.m_linearImpulse, oldImpulseV); + vA.x -= mA * impulseV.x; + vA.y -= mA * impulseV.y; + wA -= iA * (rAX * impulseV.y - rAY * impulseV.x); + vB.x += mB * impulseV.x; + vB.y += mB * impulseV.y; + wB += iB * (rBX * impulseV.y - rBY * impulseV.x); + } + bA.m_angularVelocity = wA; + bB.m_angularVelocity = wB; + } + b2FrictionJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + return true; + } + Box2D.inherit(b2FrictionJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2FrictionJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2FrictionJointDef.b2FrictionJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.localAnchorA = new b2Vec2(); + this.localAnchorB = new b2Vec2(); + }; + b2FrictionJointDef.prototype.b2FrictionJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_frictionJoint; + this.maxForce = 0.0; + this.maxTorque = 0.0; + } + b2FrictionJointDef.prototype.Initialize = function (bA, bB, anchor) { + this.bodyA = bA; + this.bodyB = bB; + this.localAnchorA.SetV(this.bodyA.GetLocalPoint(anchor)); + this.localAnchorB.SetV(this.bodyB.GetLocalPoint(anchor)); + } + Box2D.inherit(b2GearJoint, Box2D.Dynamics.Joints.b2Joint); + b2GearJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2GearJoint.b2GearJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.m_groundAnchor1 = new b2Vec2(); + this.m_groundAnchor2 = new b2Vec2(); + this.m_localAnchor1 = new b2Vec2(); + this.m_localAnchor2 = new b2Vec2(); + this.m_J = new b2Jacobian(); + }; + b2GearJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); + } + b2GearJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); + } + b2GearJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * this.m_impulse * this.m_J.linearB.x, inv_dt * this.m_impulse * this.m_J.linearB.y); + } + b2GearJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + var tMat = this.m_bodyB.m_xf.R; + var rX = this.m_localAnchor1.x - this.m_bodyB.m_sweep.localCenter.x; + var rY = this.m_localAnchor1.y - this.m_bodyB.m_sweep.localCenter.y; + var tX = tMat.col1.x * rX + tMat.col2.x * rY; + rY = tMat.col1.y * rX + tMat.col2.y * rY; + rX = tX; + var PX = this.m_impulse * this.m_J.linearB.x; + var PY = this.m_impulse * this.m_J.linearB.y; + return inv_dt * (this.m_impulse * this.m_J.angularB - rX * PY + rY * PX); + } + b2GearJoint.prototype.GetRatio = function () { + return this.m_ratio; + } + b2GearJoint.prototype.SetRatio = function (ratio) { + if (ratio === undefined) ratio = 0; + this.m_ratio = ratio; + } + b2GearJoint.prototype.b2GearJoint = function (def) { + this.__super.b2Joint.call(this, def); + var type1 = parseInt(def.joint1.m_type); + var type2 = parseInt(def.joint2.m_type); + this.m_revolute1 = null; + this.m_prismatic1 = null; + this.m_revolute2 = null; + this.m_prismatic2 = null; + var coordinate1 = 0; + var coordinate2 = 0; + this.m_ground1 = def.joint1.GetBodyA(); + this.m_bodyA = def.joint1.GetBodyB(); + if (type1 == b2Joint.e_revoluteJoint) { + this.m_revolute1 = (def.joint1 instanceof b2RevoluteJoint ? def.joint1 : null); + this.m_groundAnchor1.SetV(this.m_revolute1.m_localAnchor1); + this.m_localAnchor1.SetV(this.m_revolute1.m_localAnchor2); + coordinate1 = this.m_revolute1.GetJointAngle(); + } + else { + this.m_prismatic1 = (def.joint1 instanceof b2PrismaticJoint ? def.joint1 : null); + this.m_groundAnchor1.SetV(this.m_prismatic1.m_localAnchor1); + this.m_localAnchor1.SetV(this.m_prismatic1.m_localAnchor2); + coordinate1 = this.m_prismatic1.GetJointTranslation(); + } + this.m_ground2 = def.joint2.GetBodyA(); + this.m_bodyB = def.joint2.GetBodyB(); + if (type2 == b2Joint.e_revoluteJoint) { + this.m_revolute2 = (def.joint2 instanceof b2RevoluteJoint ? def.joint2 : null); + this.m_groundAnchor2.SetV(this.m_revolute2.m_localAnchor1); + this.m_localAnchor2.SetV(this.m_revolute2.m_localAnchor2); + coordinate2 = this.m_revolute2.GetJointAngle(); + } + else { + this.m_prismatic2 = (def.joint2 instanceof b2PrismaticJoint ? def.joint2 : null); + this.m_groundAnchor2.SetV(this.m_prismatic2.m_localAnchor1); + this.m_localAnchor2.SetV(this.m_prismatic2.m_localAnchor2); + coordinate2 = this.m_prismatic2.GetJointTranslation(); + } + this.m_ratio = def.ratio; + this.m_constant = coordinate1 + this.m_ratio * coordinate2; + this.m_impulse = 0.0; + } + b2GearJoint.prototype.InitVelocityConstraints = function (step) { + var g1 = this.m_ground1; + var g2 = this.m_ground2; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var ugX = 0; + var ugY = 0; + var rX = 0; + var rY = 0; + var tMat; + var tVec; + var crug = 0; + var tX = 0; + var K = 0.0; + this.m_J.SetZero(); + if (this.m_revolute1) { + this.m_J.angularA = (-1.0); + K += bA.m_invI; + } + else { + tMat = g1.m_xf.R; + tVec = this.m_prismatic1.m_localXAxis1; + ugX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + ugY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tMat = bA.m_xf.R; + rX = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + rY = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = tMat.col1.x * rX + tMat.col2.x * rY; + rY = tMat.col1.y * rX + tMat.col2.y * rY; + rX = tX; + crug = rX * ugY - rY * ugX; + this.m_J.linearA.Set((-ugX), (-ugY)); + this.m_J.angularA = (-crug); + K += bA.m_invMass + bA.m_invI * crug * crug; + } + if (this.m_revolute2) { + this.m_J.angularB = (-this.m_ratio); + K += this.m_ratio * this.m_ratio * bB.m_invI; + } + else { + tMat = g2.m_xf.R; + tVec = this.m_prismatic2.m_localXAxis1; + ugX = tMat.col1.x * tVec.x + tMat.col2.x * tVec.y; + ugY = tMat.col1.y * tVec.x + tMat.col2.y * tVec.y; + tMat = bB.m_xf.R; + rX = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + rY = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = tMat.col1.x * rX + tMat.col2.x * rY; + rY = tMat.col1.y * rX + tMat.col2.y * rY; + rX = tX; + crug = rX * ugY - rY * ugX; + this.m_J.linearB.Set((-this.m_ratio * ugX), (-this.m_ratio * ugY)); + this.m_J.angularB = (-this.m_ratio * crug); + K += this.m_ratio * this.m_ratio * (bB.m_invMass + bB.m_invI * crug * crug); + } + this.m_mass = K > 0.0 ? 1.0 / K : 0.0; + if (step.warmStarting) { + bA.m_linearVelocity.x += bA.m_invMass * this.m_impulse * this.m_J.linearA.x; + bA.m_linearVelocity.y += bA.m_invMass * this.m_impulse * this.m_J.linearA.y; + bA.m_angularVelocity += bA.m_invI * this.m_impulse * this.m_J.angularA; + bB.m_linearVelocity.x += bB.m_invMass * this.m_impulse * this.m_J.linearB.x; + bB.m_linearVelocity.y += bB.m_invMass * this.m_impulse * this.m_J.linearB.y; + bB.m_angularVelocity += bB.m_invI * this.m_impulse * this.m_J.angularB; + } + else { + this.m_impulse = 0.0; + } + } + b2GearJoint.prototype.SolveVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var Cdot = this.m_J.Compute(bA.m_linearVelocity, bA.m_angularVelocity, bB.m_linearVelocity, bB.m_angularVelocity); + var impulse = (-this.m_mass * Cdot); + this.m_impulse += impulse; + bA.m_linearVelocity.x += bA.m_invMass * impulse * this.m_J.linearA.x; + bA.m_linearVelocity.y += bA.m_invMass * impulse * this.m_J.linearA.y; + bA.m_angularVelocity += bA.m_invI * impulse * this.m_J.angularA; + bB.m_linearVelocity.x += bB.m_invMass * impulse * this.m_J.linearB.x; + bB.m_linearVelocity.y += bB.m_invMass * impulse * this.m_J.linearB.y; + bB.m_angularVelocity += bB.m_invI * impulse * this.m_J.angularB; + } + b2GearJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var linearError = 0.0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var coordinate1 = 0; + var coordinate2 = 0; + if (this.m_revolute1) { + coordinate1 = this.m_revolute1.GetJointAngle(); + } + else { + coordinate1 = this.m_prismatic1.GetJointTranslation(); + } + if (this.m_revolute2) { + coordinate2 = this.m_revolute2.GetJointAngle(); + } + else { + coordinate2 = this.m_prismatic2.GetJointTranslation(); + } + var C = this.m_constant - (coordinate1 + this.m_ratio * coordinate2); + var impulse = (-this.m_mass * C); + bA.m_sweep.c.x += bA.m_invMass * impulse * this.m_J.linearA.x; + bA.m_sweep.c.y += bA.m_invMass * impulse * this.m_J.linearA.y; + bA.m_sweep.a += bA.m_invI * impulse * this.m_J.angularA; + bB.m_sweep.c.x += bB.m_invMass * impulse * this.m_J.linearB.x; + bB.m_sweep.c.y += bB.m_invMass * impulse * this.m_J.linearB.y; + bB.m_sweep.a += bB.m_invI * impulse * this.m_J.angularB; + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + return linearError < b2Settings.b2_linearSlop; + } + Box2D.inherit(b2GearJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2GearJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2GearJointDef.b2GearJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + }; + b2GearJointDef.prototype.b2GearJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_gearJoint; + this.joint1 = null; + this.joint2 = null; + this.ratio = 1.0; + } + b2Jacobian.b2Jacobian = function () { + this.linearA = new b2Vec2(); + this.linearB = new b2Vec2(); + }; + b2Jacobian.prototype.SetZero = function () { + this.linearA.SetZero(); + this.angularA = 0.0; + this.linearB.SetZero(); + this.angularB = 0.0; + } + b2Jacobian.prototype.Set = function (x1, a1, x2, a2) { + if (a1 === undefined) a1 = 0; + if (a2 === undefined) a2 = 0; + this.linearA.SetV(x1); + this.angularA = a1; + this.linearB.SetV(x2); + this.angularB = a2; + } + b2Jacobian.prototype.Compute = function (x1, a1, x2, a2) { + if (a1 === undefined) a1 = 0; + if (a2 === undefined) a2 = 0; + return (this.linearA.x * x1.x + this.linearA.y * x1.y) + this.angularA * a1 + (this.linearB.x * x2.x + this.linearB.y * x2.y) + this.angularB * a2; + } + b2Joint.b2Joint = function () { + this.m_edgeA = new b2JointEdge(); + this.m_edgeB = new b2JointEdge(); + this.m_localCenterA = new b2Vec2(); + this.m_localCenterB = new b2Vec2(); + }; + b2Joint.prototype.GetType = function () { + return this.m_type; + } + b2Joint.prototype.GetAnchorA = function () { + return null; + } + b2Joint.prototype.GetAnchorB = function () { + return null; + } + b2Joint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return null; + } + b2Joint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return 0.0; + } + b2Joint.prototype.GetBodyA = function () { + return this.m_bodyA; + } + b2Joint.prototype.GetBodyB = function () { + return this.m_bodyB; + } + b2Joint.prototype.GetNext = function () { + return this.m_next; + } + b2Joint.prototype.GetUserData = function () { + return this.m_userData; + } + b2Joint.prototype.SetUserData = function (data) { + this.m_userData = data; + } + b2Joint.prototype.IsActive = function () { + return this.m_bodyA.IsActive() && this.m_bodyB.IsActive(); + } + b2Joint.Create = function (def, allocator) { + var joint = null; + switch (def.type) { + case b2Joint.e_distanceJoint: + { + joint = new b2DistanceJoint((def instanceof b2DistanceJointDef ? def : null)); + } + break; + case b2Joint.e_mouseJoint: + { + joint = new b2MouseJoint((def instanceof b2MouseJointDef ? def : null)); + } + break; + case b2Joint.e_prismaticJoint: + { + joint = new b2PrismaticJoint((def instanceof b2PrismaticJointDef ? def : null)); + } + break; + case b2Joint.e_revoluteJoint: + { + joint = new b2RevoluteJoint((def instanceof b2RevoluteJointDef ? def : null)); + } + break; + case b2Joint.e_pulleyJoint: + { + joint = new b2PulleyJoint((def instanceof b2PulleyJointDef ? def : null)); + } + break; + case b2Joint.e_gearJoint: + { + joint = new b2GearJoint((def instanceof b2GearJointDef ? def : null)); + } + break; + case b2Joint.e_lineJoint: + { + joint = new b2LineJoint((def instanceof b2LineJointDef ? def : null)); + } + break; + case b2Joint.e_weldJoint: + { + joint = new b2WeldJoint((def instanceof b2WeldJointDef ? def : null)); + } + break; + case b2Joint.e_frictionJoint: + { + joint = new b2FrictionJoint((def instanceof b2FrictionJointDef ? def : null)); + } + break; + default: + break; + } + return joint; + } + b2Joint.Destroy = function (joint, allocator) {} + b2Joint.prototype.b2Joint = function (def) { + b2Settings.b2Assert(def.bodyA != def.bodyB); + this.m_type = def.type; + this.m_prev = null; + this.m_next = null; + this.m_bodyA = def.bodyA; + this.m_bodyB = def.bodyB; + this.m_collideConnected = def.collideConnected; + this.m_islandFlag = false; + this.m_userData = def.userData; + } + b2Joint.prototype.InitVelocityConstraints = function (step) {} + b2Joint.prototype.SolveVelocityConstraints = function (step) {} + b2Joint.prototype.FinalizeVelocityConstraints = function () {} + b2Joint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + return false; + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.Joints.b2Joint.e_unknownJoint = 0; + Box2D.Dynamics.Joints.b2Joint.e_revoluteJoint = 1; + Box2D.Dynamics.Joints.b2Joint.e_prismaticJoint = 2; + Box2D.Dynamics.Joints.b2Joint.e_distanceJoint = 3; + Box2D.Dynamics.Joints.b2Joint.e_pulleyJoint = 4; + Box2D.Dynamics.Joints.b2Joint.e_mouseJoint = 5; + Box2D.Dynamics.Joints.b2Joint.e_gearJoint = 6; + Box2D.Dynamics.Joints.b2Joint.e_lineJoint = 7; + Box2D.Dynamics.Joints.b2Joint.e_weldJoint = 8; + Box2D.Dynamics.Joints.b2Joint.e_frictionJoint = 9; + Box2D.Dynamics.Joints.b2Joint.e_inactiveLimit = 0; + Box2D.Dynamics.Joints.b2Joint.e_atLowerLimit = 1; + Box2D.Dynamics.Joints.b2Joint.e_atUpperLimit = 2; + Box2D.Dynamics.Joints.b2Joint.e_equalLimits = 3; + }); + b2JointDef.b2JointDef = function () {}; + b2JointDef.prototype.b2JointDef = function () { + this.type = b2Joint.e_unknownJoint; + this.userData = null; + this.bodyA = null; + this.bodyB = null; + this.collideConnected = false; + } + b2JointEdge.b2JointEdge = function () {}; + Box2D.inherit(b2LineJoint, Box2D.Dynamics.Joints.b2Joint); + b2LineJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2LineJoint.b2LineJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.m_localAnchor1 = new b2Vec2(); + this.m_localAnchor2 = new b2Vec2(); + this.m_localXAxis1 = new b2Vec2(); + this.m_localYAxis1 = new b2Vec2(); + this.m_axis = new b2Vec2(); + this.m_perp = new b2Vec2(); + this.m_K = new b2Mat22(); + this.m_impulse = new b2Vec2(); + }; + b2LineJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); + } + b2LineJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); + } + b2LineJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * (this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.x), inv_dt * (this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.y)); + } + b2LineJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return inv_dt * this.m_impulse.y; + } + b2LineJoint.prototype.GetJointTranslation = function () { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + var p1 = bA.GetWorldPoint(this.m_localAnchor1); + var p2 = bB.GetWorldPoint(this.m_localAnchor2); + var dX = p2.x - p1.x; + var dY = p2.y - p1.y; + var axis = bA.GetWorldVector(this.m_localXAxis1); + var translation = axis.x * dX + axis.y * dY; + return translation; + } + b2LineJoint.prototype.GetJointSpeed = function () { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var p1X = bA.m_sweep.c.x + r1X; + var p1Y = bA.m_sweep.c.y + r1Y; + var p2X = bB.m_sweep.c.x + r2X; + var p2Y = bB.m_sweep.c.y + r2Y; + var dX = p2X - p1X; + var dY = p2Y - p1Y; + var axis = bA.GetWorldVector(this.m_localXAxis1); + var v1 = bA.m_linearVelocity; + var v2 = bB.m_linearVelocity; + var w1 = bA.m_angularVelocity; + var w2 = bB.m_angularVelocity; + var speed = (dX * ((-w1 * axis.y)) + dY * (w1 * axis.x)) + (axis.x * (((v2.x + ((-w2 * r2Y))) - v1.x) - ((-w1 * r1Y))) + axis.y * (((v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X))); + return speed; + } + b2LineJoint.prototype.IsLimitEnabled = function () { + return this.m_enableLimit; + } + b2LineJoint.prototype.EnableLimit = function (flag) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_enableLimit = flag; + } + b2LineJoint.prototype.GetLowerLimit = function () { + return this.m_lowerTranslation; + } + b2LineJoint.prototype.GetUpperLimit = function () { + return this.m_upperTranslation; + } + b2LineJoint.prototype.SetLimits = function (lower, upper) { + if (lower === undefined) lower = 0; + if (upper === undefined) upper = 0; + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_lowerTranslation = lower; + this.m_upperTranslation = upper; + } + b2LineJoint.prototype.IsMotorEnabled = function () { + return this.m_enableMotor; + } + b2LineJoint.prototype.EnableMotor = function (flag) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_enableMotor = flag; + } + b2LineJoint.prototype.SetMotorSpeed = function (speed) { + if (speed === undefined) speed = 0; + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_motorSpeed = speed; + } + b2LineJoint.prototype.GetMotorSpeed = function () { + return this.m_motorSpeed; + } + b2LineJoint.prototype.SetMaxMotorForce = function (force) { + if (force === undefined) force = 0; + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_maxMotorForce = force; + } + b2LineJoint.prototype.GetMaxMotorForce = function () { + return this.m_maxMotorForce; + } + b2LineJoint.prototype.GetMotorForce = function () { + return this.m_motorImpulse; + } + b2LineJoint.prototype.b2LineJoint = function (def) { + this.__super.b2Joint.call(this, def); + var tMat; + var tX = 0; + var tY = 0; + this.m_localAnchor1.SetV(def.localAnchorA); + this.m_localAnchor2.SetV(def.localAnchorB); + this.m_localXAxis1.SetV(def.localAxisA); + this.m_localYAxis1.x = (-this.m_localXAxis1.y); + this.m_localYAxis1.y = this.m_localXAxis1.x; + this.m_impulse.SetZero(); + this.m_motorMass = 0.0; + this.m_motorImpulse = 0.0; + this.m_lowerTranslation = def.lowerTranslation; + this.m_upperTranslation = def.upperTranslation; + this.m_maxMotorForce = def.maxMotorForce; + this.m_motorSpeed = def.motorSpeed; + this.m_enableLimit = def.enableLimit; + this.m_enableMotor = def.enableMotor; + this.m_limitState = b2Joint.e_inactiveLimit; + this.m_axis.SetZero(); + this.m_perp.SetZero(); + } + b2LineJoint.prototype.InitVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + var tX = 0; + this.m_localCenterA.SetV(bA.GetLocalCenter()); + this.m_localCenterB.SetV(bB.GetLocalCenter()); + var xf1 = bA.GetTransform(); + var xf2 = bB.GetTransform(); + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - this.m_localCenterA.x; + var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - this.m_localCenterB.x; + var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var dX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; + var dY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; + this.m_invMassA = bA.m_invMass; + this.m_invMassB = bB.m_invMass; + this.m_invIA = bA.m_invI; + this.m_invIB = bB.m_invI; { + this.m_axis.SetV(b2Math.MulMV(xf1.R, this.m_localXAxis1)); + this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x; + this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x; + this.m_motorMass = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_a1 * this.m_a1 + this.m_invIB * this.m_a2 * this.m_a2; + this.m_motorMass = this.m_motorMass > Number.MIN_VALUE ? 1.0 / this.m_motorMass : 0.0; + } { + this.m_perp.SetV(b2Math.MulMV(xf1.R, this.m_localYAxis1)); + this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x; + this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x; + var m1 = this.m_invMassA; + var m2 = this.m_invMassB; + var i1 = this.m_invIA; + var i2 = this.m_invIB; + this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; + this.m_K.col1.y = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2; + this.m_K.col2.x = this.m_K.col1.y; + this.m_K.col2.y = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2; + } + if (this.m_enableLimit) { + var jointTransition = this.m_axis.x * dX + this.m_axis.y * dY; + if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) { + this.m_limitState = b2Joint.e_equalLimits; + } + else if (jointTransition <= this.m_lowerTranslation) { + if (this.m_limitState != b2Joint.e_atLowerLimit) { + this.m_limitState = b2Joint.e_atLowerLimit; + this.m_impulse.y = 0.0; + } + } + else if (jointTransition >= this.m_upperTranslation) { + if (this.m_limitState != b2Joint.e_atUpperLimit) { + this.m_limitState = b2Joint.e_atUpperLimit; + this.m_impulse.y = 0.0; + } + } + else { + this.m_limitState = b2Joint.e_inactiveLimit; + this.m_impulse.y = 0.0; + } + } + else { + this.m_limitState = b2Joint.e_inactiveLimit; + } + if (this.m_enableMotor == false) { + this.m_motorImpulse = 0.0; + } + if (step.warmStarting) { + this.m_impulse.x *= step.dtRatio; + this.m_impulse.y *= step.dtRatio; + this.m_motorImpulse *= step.dtRatio; + var PX = this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.x; + var PY = this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.y) * this.m_axis.y; + var L1 = this.m_impulse.x * this.m_s1 + (this.m_motorImpulse + this.m_impulse.y) * this.m_a1; + var L2 = this.m_impulse.x * this.m_s2 + (this.m_motorImpulse + this.m_impulse.y) * this.m_a2; + bA.m_linearVelocity.x -= this.m_invMassA * PX; + bA.m_linearVelocity.y -= this.m_invMassA * PY; + bA.m_angularVelocity -= this.m_invIA * L1; + bB.m_linearVelocity.x += this.m_invMassB * PX; + bB.m_linearVelocity.y += this.m_invMassB * PY; + bB.m_angularVelocity += this.m_invIB * L2; + } + else { + this.m_impulse.SetZero(); + this.m_motorImpulse = 0.0; + } + } + b2LineJoint.prototype.SolveVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var v1 = bA.m_linearVelocity; + var w1 = bA.m_angularVelocity; + var v2 = bB.m_linearVelocity; + var w2 = bB.m_angularVelocity; + var PX = 0; + var PY = 0; + var L1 = 0; + var L2 = 0; + if (this.m_enableMotor && this.m_limitState != b2Joint.e_equalLimits) { + var Cdot = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1; + var impulse = this.m_motorMass * (this.m_motorSpeed - Cdot); + var oldImpulse = this.m_motorImpulse; + var maxImpulse = step.dt * this.m_maxMotorForce; + this.m_motorImpulse = b2Math.Clamp(this.m_motorImpulse + impulse, (-maxImpulse), maxImpulse); + impulse = this.m_motorImpulse - oldImpulse; + PX = impulse * this.m_axis.x; + PY = impulse * this.m_axis.y; + L1 = impulse * this.m_a1; + L2 = impulse * this.m_a2; + v1.x -= this.m_invMassA * PX; + v1.y -= this.m_invMassA * PY; + w1 -= this.m_invIA * L1; + v2.x += this.m_invMassB * PX; + v2.y += this.m_invMassB * PY; + w2 += this.m_invIB * L2; + } + var Cdot1 = this.m_perp.x * (v2.x - v1.x) + this.m_perp.y * (v2.y - v1.y) + this.m_s2 * w2 - this.m_s1 * w1; + if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) { + var Cdot2 = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1; + var f1 = this.m_impulse.Copy(); + var df = this.m_K.Solve(new b2Vec2(), (-Cdot1), (-Cdot2)); + this.m_impulse.Add(df); + if (this.m_limitState == b2Joint.e_atLowerLimit) { + this.m_impulse.y = b2Math.Max(this.m_impulse.y, 0.0); + } + else if (this.m_limitState == b2Joint.e_atUpperLimit) { + this.m_impulse.y = b2Math.Min(this.m_impulse.y, 0.0); + } + var b = (-Cdot1) - (this.m_impulse.y - f1.y) * this.m_K.col2.x; + var f2r = 0; + if (this.m_K.col1.x != 0.0) { + f2r = b / this.m_K.col1.x + f1.x; + } + else { + f2r = f1.x; + } + this.m_impulse.x = f2r; + df.x = this.m_impulse.x - f1.x; + df.y = this.m_impulse.y - f1.y; + PX = df.x * this.m_perp.x + df.y * this.m_axis.x; + PY = df.x * this.m_perp.y + df.y * this.m_axis.y; + L1 = df.x * this.m_s1 + df.y * this.m_a1; + L2 = df.x * this.m_s2 + df.y * this.m_a2; + v1.x -= this.m_invMassA * PX; + v1.y -= this.m_invMassA * PY; + w1 -= this.m_invIA * L1; + v2.x += this.m_invMassB * PX; + v2.y += this.m_invMassB * PY; + w2 += this.m_invIB * L2; + } + else { + var df2 = 0; + if (this.m_K.col1.x != 0.0) { + df2 = ((-Cdot1)) / this.m_K.col1.x; + } + else { + df2 = 0.0; + } + this.m_impulse.x += df2; + PX = df2 * this.m_perp.x; + PY = df2 * this.m_perp.y; + L1 = df2 * this.m_s1; + L2 = df2 * this.m_s2; + v1.x -= this.m_invMassA * PX; + v1.y -= this.m_invMassA * PY; + w1 -= this.m_invIA * L1; + v2.x += this.m_invMassB * PX; + v2.y += this.m_invMassB * PY; + w2 += this.m_invIB * L2; + } + bA.m_linearVelocity.SetV(v1); + bA.m_angularVelocity = w1; + bB.m_linearVelocity.SetV(v2); + bB.m_angularVelocity = w2; + } + b2LineJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var limitC = 0; + var oldLimitImpulse = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var c1 = bA.m_sweep.c; + var a1 = bA.m_sweep.a; + var c2 = bB.m_sweep.c; + var a2 = bB.m_sweep.a; + var tMat; + var tX = 0; + var m1 = 0; + var m2 = 0; + var i1 = 0; + var i2 = 0; + var linearError = 0.0; + var angularError = 0.0; + var active = false; + var C2 = 0.0; + var R1 = b2Mat22.FromAngle(a1); + var R2 = b2Mat22.FromAngle(a2); + tMat = R1; + var r1X = this.m_localAnchor1.x - this.m_localCenterA.x; + var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = R2; + var r2X = this.m_localAnchor2.x - this.m_localCenterB.x; + var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var dX = c2.x + r2X - c1.x - r1X; + var dY = c2.y + r2Y - c1.y - r1Y; + if (this.m_enableLimit) { + this.m_axis = b2Math.MulMV(R1, this.m_localXAxis1); + this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x; + this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x; + var translation = this.m_axis.x * dX + this.m_axis.y * dY; + if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) { + C2 = b2Math.Clamp(translation, (-b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection); + linearError = b2Math.Abs(translation); + active = true; + } + else if (translation <= this.m_lowerTranslation) { + C2 = b2Math.Clamp(translation - this.m_lowerTranslation + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0); + linearError = this.m_lowerTranslation - translation; + active = true; + } + else if (translation >= this.m_upperTranslation) { + C2 = b2Math.Clamp(translation - this.m_upperTranslation + b2Settings.b2_linearSlop, 0.0, b2Settings.b2_maxLinearCorrection); + linearError = translation - this.m_upperTranslation; + active = true; + } + } + this.m_perp = b2Math.MulMV(R1, this.m_localYAxis1); + this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x; + this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x; + var impulse = new b2Vec2(); + var C1 = this.m_perp.x * dX + this.m_perp.y * dY; + linearError = b2Math.Max(linearError, b2Math.Abs(C1)); + angularError = 0.0; + if (active) { + m1 = this.m_invMassA; + m2 = this.m_invMassB; + i1 = this.m_invIA; + i2 = this.m_invIB; + this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; + this.m_K.col1.y = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2; + this.m_K.col2.x = this.m_K.col1.y; + this.m_K.col2.y = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2; + this.m_K.Solve(impulse, (-C1), (-C2)); + } + else { + m1 = this.m_invMassA; + m2 = this.m_invMassB; + i1 = this.m_invIA; + i2 = this.m_invIB; + var k11 = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; + var impulse1 = 0; + if (k11 != 0.0) { + impulse1 = ((-C1)) / k11; + } + else { + impulse1 = 0.0; + } + impulse.x = impulse1; + impulse.y = 0.0; + } + var PX = impulse.x * this.m_perp.x + impulse.y * this.m_axis.x; + var PY = impulse.x * this.m_perp.y + impulse.y * this.m_axis.y; + var L1 = impulse.x * this.m_s1 + impulse.y * this.m_a1; + var L2 = impulse.x * this.m_s2 + impulse.y * this.m_a2; + c1.x -= this.m_invMassA * PX; + c1.y -= this.m_invMassA * PY; + a1 -= this.m_invIA * L1; + c2.x += this.m_invMassB * PX; + c2.y += this.m_invMassB * PY; + a2 += this.m_invIB * L2; + bA.m_sweep.a = a1; + bB.m_sweep.a = a2; + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + + return linearError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop; + } + Box2D.inherit(b2LineJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2LineJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2LineJointDef.b2LineJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.localAnchorA = new b2Vec2(); + this.localAnchorB = new b2Vec2(); + this.localAxisA = new b2Vec2(); + }; + b2LineJointDef.prototype.b2LineJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_lineJoint; + this.localAxisA.Set(1.0, 0.0); + this.enableLimit = false; + this.lowerTranslation = 0.0; + this.upperTranslation = 0.0; + this.enableMotor = false; + this.maxMotorForce = 0.0; + this.motorSpeed = 0.0; + } + b2LineJointDef.prototype.Initialize = function (bA, bB, anchor, axis) { + this.bodyA = bA; + this.bodyB = bB; + this.localAnchorA = this.bodyA.GetLocalPoint(anchor); + this.localAnchorB = this.bodyB.GetLocalPoint(anchor); + this.localAxisA = this.bodyA.GetLocalVector(axis); + } + Box2D.inherit(b2MouseJoint, Box2D.Dynamics.Joints.b2Joint); + b2MouseJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2MouseJoint.b2MouseJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.K = new b2Mat22(); + this.K1 = new b2Mat22(); + this.K2 = new b2Mat22(); + this.m_localAnchor = new b2Vec2(); + this.m_target = new b2Vec2(); + this.m_impulse = new b2Vec2(); + this.m_mass = new b2Mat22(); + this.m_C = new b2Vec2(); + }; + b2MouseJoint.prototype.GetAnchorA = function () { + return this.m_target; + } + b2MouseJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchor); + } + b2MouseJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * this.m_impulse.x, inv_dt * this.m_impulse.y); + } + b2MouseJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return 0.0; + } + b2MouseJoint.prototype.GetTarget = function () { + return this.m_target; + } + b2MouseJoint.prototype.SetTarget = function (target) { + if (this.m_bodyB.IsAwake() == false) { + this.m_bodyB.SetAwake(true); + } + this.m_target = target; + } + b2MouseJoint.prototype.GetMaxForce = function () { + return this.m_maxForce; + } + b2MouseJoint.prototype.SetMaxForce = function (maxForce) { + if (maxForce === undefined) maxForce = 0; + this.m_maxForce = maxForce; + } + b2MouseJoint.prototype.GetFrequency = function () { + return this.m_frequencyHz; + } + b2MouseJoint.prototype.SetFrequency = function (hz) { + if (hz === undefined) hz = 0; + this.m_frequencyHz = hz; + } + b2MouseJoint.prototype.GetDampingRatio = function () { + return this.m_dampingRatio; + } + b2MouseJoint.prototype.SetDampingRatio = function (ratio) { + if (ratio === undefined) ratio = 0; + this.m_dampingRatio = ratio; + } + b2MouseJoint.prototype.b2MouseJoint = function (def) { + this.__super.b2Joint.call(this, def); + this.m_target.SetV(def.target); + var tX = this.m_target.x - this.m_bodyB.m_xf.position.x; + var tY = this.m_target.y - this.m_bodyB.m_xf.position.y; + var tMat = this.m_bodyB.m_xf.R; + this.m_localAnchor.x = (tX * tMat.col1.x + tY * tMat.col1.y); + this.m_localAnchor.y = (tX * tMat.col2.x + tY * tMat.col2.y); + this.m_maxForce = def.maxForce; + this.m_impulse.SetZero(); + this.m_frequencyHz = def.frequencyHz; + this.m_dampingRatio = def.dampingRatio; + this.m_beta = 0.0; + this.m_gamma = 0.0; + } + b2MouseJoint.prototype.InitVelocityConstraints = function (step) { + var b = this.m_bodyB; + var mass = b.GetMass(); + var omega = 2.0 * Math.PI * this.m_frequencyHz; + var d = 2.0 * mass * this.m_dampingRatio * omega; + var k = mass * omega * omega; + this.m_gamma = step.dt * (d + step.dt * k); + this.m_gamma = this.m_gamma != 0 ? 1 / this.m_gamma : 0.0; + this.m_beta = step.dt * k * this.m_gamma; + var tMat;tMat = b.m_xf.R; + var rX = this.m_localAnchor.x - b.m_sweep.localCenter.x; + var rY = this.m_localAnchor.y - b.m_sweep.localCenter.y; + var tX = (tMat.col1.x * rX + tMat.col2.x * rY);rY = (tMat.col1.y * rX + tMat.col2.y * rY); + rX = tX; + var invMass = b.m_invMass; + var invI = b.m_invI;this.K1.col1.x = invMass; + this.K1.col2.x = 0.0; + this.K1.col1.y = 0.0; + this.K1.col2.y = invMass; + this.K2.col1.x = invI * rY * rY; + this.K2.col2.x = (-invI * rX * rY); + this.K2.col1.y = (-invI * rX * rY); + this.K2.col2.y = invI * rX * rX; + this.K.SetM(this.K1); + this.K.AddM(this.K2); + this.K.col1.x += this.m_gamma; + this.K.col2.y += this.m_gamma; + this.K.GetInverse(this.m_mass); + this.m_C.x = b.m_sweep.c.x + rX - this.m_target.x; + this.m_C.y = b.m_sweep.c.y + rY - this.m_target.y; + b.m_angularVelocity *= 0.98; + this.m_impulse.x *= step.dtRatio; + this.m_impulse.y *= step.dtRatio; + b.m_linearVelocity.x += invMass * this.m_impulse.x; + b.m_linearVelocity.y += invMass * this.m_impulse.y; + b.m_angularVelocity += invI * (rX * this.m_impulse.y - rY * this.m_impulse.x); + } + b2MouseJoint.prototype.SolveVelocityConstraints = function (step) { + var b = this.m_bodyB; + var tMat; + var tX = 0; + var tY = 0; + tMat = b.m_xf.R; + var rX = this.m_localAnchor.x - b.m_sweep.localCenter.x; + var rY = this.m_localAnchor.y - b.m_sweep.localCenter.y; + tX = (tMat.col1.x * rX + tMat.col2.x * rY); + rY = (tMat.col1.y * rX + tMat.col2.y * rY); + rX = tX; + var CdotX = b.m_linearVelocity.x + ((-b.m_angularVelocity * rY)); + var CdotY = b.m_linearVelocity.y + (b.m_angularVelocity * rX); + tMat = this.m_mass; + tX = CdotX + this.m_beta * this.m_C.x + this.m_gamma * this.m_impulse.x; + tY = CdotY + this.m_beta * this.m_C.y + this.m_gamma * this.m_impulse.y; + var impulseX = (-(tMat.col1.x * tX + tMat.col2.x * tY)); + var impulseY = (-(tMat.col1.y * tX + tMat.col2.y * tY)); + var oldImpulseX = this.m_impulse.x; + var oldImpulseY = this.m_impulse.y; + this.m_impulse.x += impulseX; + this.m_impulse.y += impulseY; + var maxImpulse = step.dt * this.m_maxForce; + if (this.m_impulse.LengthSquared() > maxImpulse * maxImpulse) { + this.m_impulse.Multiply(maxImpulse / this.m_impulse.Length()); + } + impulseX = this.m_impulse.x - oldImpulseX; + impulseY = this.m_impulse.y - oldImpulseY; + b.m_linearVelocity.x += b.m_invMass * impulseX; + b.m_linearVelocity.y += b.m_invMass * impulseY; + b.m_angularVelocity += b.m_invI * (rX * impulseY - rY * impulseX); + } + b2MouseJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + return true; + } + Box2D.inherit(b2MouseJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2MouseJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2MouseJointDef.b2MouseJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.target = new b2Vec2(); + }; + b2MouseJointDef.prototype.b2MouseJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_mouseJoint; + this.maxForce = 0.0; + this.frequencyHz = 5.0; + this.dampingRatio = 0.7; + } + Box2D.inherit(b2PrismaticJoint, Box2D.Dynamics.Joints.b2Joint); + b2PrismaticJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2PrismaticJoint.b2PrismaticJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.m_localAnchor1 = new b2Vec2(); + this.m_localAnchor2 = new b2Vec2(); + this.m_localXAxis1 = new b2Vec2(); + this.m_localYAxis1 = new b2Vec2(); + this.m_axis = new b2Vec2(); + this.m_perp = new b2Vec2(); + this.m_K = new b2Mat33(); + this.m_impulse = new b2Vec3(); + }; + b2PrismaticJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); + } + b2PrismaticJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); + } + b2PrismaticJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * (this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.x), inv_dt * (this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.y)); + } + b2PrismaticJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return inv_dt * this.m_impulse.y; + } + b2PrismaticJoint.prototype.GetJointTranslation = function () { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + var p1 = bA.GetWorldPoint(this.m_localAnchor1); + var p2 = bB.GetWorldPoint(this.m_localAnchor2); + var dX = p2.x - p1.x; + var dY = p2.y - p1.y; + var axis = bA.GetWorldVector(this.m_localXAxis1); + var translation = axis.x * dX + axis.y * dY; + return translation; + } + b2PrismaticJoint.prototype.GetJointSpeed = function () { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var p1X = bA.m_sweep.c.x + r1X; + var p1Y = bA.m_sweep.c.y + r1Y; + var p2X = bB.m_sweep.c.x + r2X; + var p2Y = bB.m_sweep.c.y + r2Y; + var dX = p2X - p1X; + var dY = p2Y - p1Y; + var axis = bA.GetWorldVector(this.m_localXAxis1); + var v1 = bA.m_linearVelocity; + var v2 = bB.m_linearVelocity; + var w1 = bA.m_angularVelocity; + var w2 = bB.m_angularVelocity; + var speed = (dX * ((-w1 * axis.y)) + dY * (w1 * axis.x)) + (axis.x * (((v2.x + ((-w2 * r2Y))) - v1.x) - ((-w1 * r1Y))) + axis.y * (((v2.y + (w2 * r2X)) - v1.y) - (w1 * r1X))); + return speed; + } + b2PrismaticJoint.prototype.IsLimitEnabled = function () { + return this.m_enableLimit; + } + b2PrismaticJoint.prototype.EnableLimit = function (flag) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_enableLimit = flag; + } + b2PrismaticJoint.prototype.GetLowerLimit = function () { + return this.m_lowerTranslation; + } + b2PrismaticJoint.prototype.GetUpperLimit = function () { + return this.m_upperTranslation; + } + b2PrismaticJoint.prototype.SetLimits = function (lower, upper) { + if (lower === undefined) lower = 0; + if (upper === undefined) upper = 0; + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_lowerTranslation = lower; + this.m_upperTranslation = upper; + } + b2PrismaticJoint.prototype.IsMotorEnabled = function () { + return this.m_enableMotor; + } + b2PrismaticJoint.prototype.EnableMotor = function (flag) { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_enableMotor = flag; + } + b2PrismaticJoint.prototype.SetMotorSpeed = function (speed) { + if (speed === undefined) speed = 0; + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_motorSpeed = speed; + } + b2PrismaticJoint.prototype.GetMotorSpeed = function () { + return this.m_motorSpeed; + } + b2PrismaticJoint.prototype.SetMaxMotorForce = function (force) { + if (force === undefined) force = 0; + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_maxMotorForce = force; + } + b2PrismaticJoint.prototype.GetMotorForce = function () { + return this.m_motorImpulse; + } + b2PrismaticJoint.prototype.b2PrismaticJoint = function (def) { + this.__super.b2Joint.call(this, def); + var tMat; + var tX = 0; + var tY = 0; + this.m_localAnchor1.SetV(def.localAnchorA); + this.m_localAnchor2.SetV(def.localAnchorB); + this.m_localXAxis1.SetV(def.localAxisA); + this.m_localYAxis1.x = (-this.m_localXAxis1.y); + this.m_localYAxis1.y = this.m_localXAxis1.x; + this.m_refAngle = def.referenceAngle; + this.m_impulse.SetZero(); + this.m_motorMass = 0.0; + this.m_motorImpulse = 0.0; + this.m_lowerTranslation = def.lowerTranslation; + this.m_upperTranslation = def.upperTranslation; + this.m_maxMotorForce = def.maxMotorForce; + this.m_motorSpeed = def.motorSpeed; + this.m_enableLimit = def.enableLimit; + this.m_enableMotor = def.enableMotor; + this.m_limitState = b2Joint.e_inactiveLimit; + this.m_axis.SetZero(); + this.m_perp.SetZero(); + } + b2PrismaticJoint.prototype.InitVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + var tX = 0; + this.m_localCenterA.SetV(bA.GetLocalCenter()); + this.m_localCenterB.SetV(bB.GetLocalCenter()); + var xf1 = bA.GetTransform(); + var xf2 = bB.GetTransform(); + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - this.m_localCenterA.x; + var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - this.m_localCenterB.x; + var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var dX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; + var dY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; + this.m_invMassA = bA.m_invMass; + this.m_invMassB = bB.m_invMass; + this.m_invIA = bA.m_invI; + this.m_invIB = bB.m_invI; { + this.m_axis.SetV(b2Math.MulMV(xf1.R, this.m_localXAxis1)); + this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x; + this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x; + this.m_motorMass = this.m_invMassA + this.m_invMassB + this.m_invIA * this.m_a1 * this.m_a1 + this.m_invIB * this.m_a2 * this.m_a2; + if (this.m_motorMass > Number.MIN_VALUE) this.m_motorMass = 1.0 / this.m_motorMass; + } { + this.m_perp.SetV(b2Math.MulMV(xf1.R, this.m_localYAxis1)); + this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x; + this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x; + var m1 = this.m_invMassA; + var m2 = this.m_invMassB; + var i1 = this.m_invIA; + var i2 = this.m_invIB; + this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; + this.m_K.col1.y = i1 * this.m_s1 + i2 * this.m_s2; + this.m_K.col1.z = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2; + this.m_K.col2.x = this.m_K.col1.y; + this.m_K.col2.y = i1 + i2; + this.m_K.col2.z = i1 * this.m_a1 + i2 * this.m_a2; + this.m_K.col3.x = this.m_K.col1.z; + this.m_K.col3.y = this.m_K.col2.z; + this.m_K.col3.z = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2; + } + if (this.m_enableLimit) { + var jointTransition = this.m_axis.x * dX + this.m_axis.y * dY; + if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) { + this.m_limitState = b2Joint.e_equalLimits; + } + else if (jointTransition <= this.m_lowerTranslation) { + if (this.m_limitState != b2Joint.e_atLowerLimit) { + this.m_limitState = b2Joint.e_atLowerLimit; + this.m_impulse.z = 0.0; + } + } + else if (jointTransition >= this.m_upperTranslation) { + if (this.m_limitState != b2Joint.e_atUpperLimit) { + this.m_limitState = b2Joint.e_atUpperLimit; + this.m_impulse.z = 0.0; + } + } + else { + this.m_limitState = b2Joint.e_inactiveLimit; + this.m_impulse.z = 0.0; + } + } + else { + this.m_limitState = b2Joint.e_inactiveLimit; + } + if (this.m_enableMotor == false) { + this.m_motorImpulse = 0.0; + } + if (step.warmStarting) { + this.m_impulse.x *= step.dtRatio; + this.m_impulse.y *= step.dtRatio; + this.m_motorImpulse *= step.dtRatio; + var PX = this.m_impulse.x * this.m_perp.x + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.x; + var PY = this.m_impulse.x * this.m_perp.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_axis.y; + var L1 = this.m_impulse.x * this.m_s1 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a1; + var L2 = this.m_impulse.x * this.m_s2 + this.m_impulse.y + (this.m_motorImpulse + this.m_impulse.z) * this.m_a2; + bA.m_linearVelocity.x -= this.m_invMassA * PX; + bA.m_linearVelocity.y -= this.m_invMassA * PY; + bA.m_angularVelocity -= this.m_invIA * L1; + bB.m_linearVelocity.x += this.m_invMassB * PX; + bB.m_linearVelocity.y += this.m_invMassB * PY; + bB.m_angularVelocity += this.m_invIB * L2; + } + else { + this.m_impulse.SetZero(); + this.m_motorImpulse = 0.0; + } + } + b2PrismaticJoint.prototype.SolveVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var v1 = bA.m_linearVelocity; + var w1 = bA.m_angularVelocity; + var v2 = bB.m_linearVelocity; + var w2 = bB.m_angularVelocity; + var PX = 0; + var PY = 0; + var L1 = 0; + var L2 = 0; + if (this.m_enableMotor && this.m_limitState != b2Joint.e_equalLimits) { + var Cdot = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1; + var impulse = this.m_motorMass * (this.m_motorSpeed - Cdot); + var oldImpulse = this.m_motorImpulse; + var maxImpulse = step.dt * this.m_maxMotorForce; + this.m_motorImpulse = b2Math.Clamp(this.m_motorImpulse + impulse, (-maxImpulse), maxImpulse); + impulse = this.m_motorImpulse - oldImpulse; + PX = impulse * this.m_axis.x; + PY = impulse * this.m_axis.y; + L1 = impulse * this.m_a1; + L2 = impulse * this.m_a2; + v1.x -= this.m_invMassA * PX; + v1.y -= this.m_invMassA * PY; + w1 -= this.m_invIA * L1; + v2.x += this.m_invMassB * PX; + v2.y += this.m_invMassB * PY; + w2 += this.m_invIB * L2; + } + var Cdot1X = this.m_perp.x * (v2.x - v1.x) + this.m_perp.y * (v2.y - v1.y) + this.m_s2 * w2 - this.m_s1 * w1; + var Cdot1Y = w2 - w1; + if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) { + var Cdot2 = this.m_axis.x * (v2.x - v1.x) + this.m_axis.y * (v2.y - v1.y) + this.m_a2 * w2 - this.m_a1 * w1; + var f1 = this.m_impulse.Copy(); + var df = this.m_K.Solve33(new b2Vec3(), (-Cdot1X), (-Cdot1Y), (-Cdot2)); + this.m_impulse.Add(df); + if (this.m_limitState == b2Joint.e_atLowerLimit) { + this.m_impulse.z = b2Math.Max(this.m_impulse.z, 0.0); + } + else if (this.m_limitState == b2Joint.e_atUpperLimit) { + this.m_impulse.z = b2Math.Min(this.m_impulse.z, 0.0); + } + var bX = (-Cdot1X) - (this.m_impulse.z - f1.z) * this.m_K.col3.x; + var bY = (-Cdot1Y) - (this.m_impulse.z - f1.z) * this.m_K.col3.y; + var f2r = this.m_K.Solve22(new b2Vec2(), bX, bY); + f2r.x += f1.x; + f2r.y += f1.y; + this.m_impulse.x = f2r.x; + this.m_impulse.y = f2r.y; + df.x = this.m_impulse.x - f1.x; + df.y = this.m_impulse.y - f1.y; + df.z = this.m_impulse.z - f1.z; + PX = df.x * this.m_perp.x + df.z * this.m_axis.x; + PY = df.x * this.m_perp.y + df.z * this.m_axis.y; + L1 = df.x * this.m_s1 + df.y + df.z * this.m_a1; + L2 = df.x * this.m_s2 + df.y + df.z * this.m_a2; + v1.x -= this.m_invMassA * PX; + v1.y -= this.m_invMassA * PY; + w1 -= this.m_invIA * L1; + v2.x += this.m_invMassB * PX; + v2.y += this.m_invMassB * PY; + w2 += this.m_invIB * L2; + } + else { + var df2 = this.m_K.Solve22(new b2Vec2(), (-Cdot1X), (-Cdot1Y)); + this.m_impulse.x += df2.x; + this.m_impulse.y += df2.y; + PX = df2.x * this.m_perp.x; + PY = df2.x * this.m_perp.y; + L1 = df2.x * this.m_s1 + df2.y; + L2 = df2.x * this.m_s2 + df2.y; + v1.x -= this.m_invMassA * PX; + v1.y -= this.m_invMassA * PY; + w1 -= this.m_invIA * L1; + v2.x += this.m_invMassB * PX; + v2.y += this.m_invMassB * PY; + w2 += this.m_invIB * L2; + } + bA.m_linearVelocity.SetV(v1); + bA.m_angularVelocity = w1; + bB.m_linearVelocity.SetV(v2); + bB.m_angularVelocity = w2; + } + b2PrismaticJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var limitC = 0; + var oldLimitImpulse = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var c1 = bA.m_sweep.c; + var a1 = bA.m_sweep.a; + var c2 = bB.m_sweep.c; + var a2 = bB.m_sweep.a; + var tMat; + var tX = 0; + var m1 = 0; + var m2 = 0; + var i1 = 0; + var i2 = 0; + var linearError = 0.0; + var angularError = 0.0; + var active = false; + var C2 = 0.0; + var R1 = b2Mat22.FromAngle(a1); + var R2 = b2Mat22.FromAngle(a2); + tMat = R1; + var r1X = this.m_localAnchor1.x - this.m_localCenterA.x; + var r1Y = this.m_localAnchor1.y - this.m_localCenterA.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = R2; + var r2X = this.m_localAnchor2.x - this.m_localCenterB.x; + var r2Y = this.m_localAnchor2.y - this.m_localCenterB.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var dX = c2.x + r2X - c1.x - r1X; + var dY = c2.y + r2Y - c1.y - r1Y; + if (this.m_enableLimit) { + this.m_axis = b2Math.MulMV(R1, this.m_localXAxis1); + this.m_a1 = (dX + r1X) * this.m_axis.y - (dY + r1Y) * this.m_axis.x; + this.m_a2 = r2X * this.m_axis.y - r2Y * this.m_axis.x; + var translation = this.m_axis.x * dX + this.m_axis.y * dY; + if (b2Math.Abs(this.m_upperTranslation - this.m_lowerTranslation) < 2.0 * b2Settings.b2_linearSlop) { + C2 = b2Math.Clamp(translation, (-b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection); + linearError = b2Math.Abs(translation); + active = true; + } + else if (translation <= this.m_lowerTranslation) { + C2 = b2Math.Clamp(translation - this.m_lowerTranslation + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0); + linearError = this.m_lowerTranslation - translation; + active = true; + } + else if (translation >= this.m_upperTranslation) { + C2 = b2Math.Clamp(translation - this.m_upperTranslation + b2Settings.b2_linearSlop, 0.0, b2Settings.b2_maxLinearCorrection); + linearError = translation - this.m_upperTranslation; + active = true; + } + } + this.m_perp = b2Math.MulMV(R1, this.m_localYAxis1); + this.m_s1 = (dX + r1X) * this.m_perp.y - (dY + r1Y) * this.m_perp.x; + this.m_s2 = r2X * this.m_perp.y - r2Y * this.m_perp.x; + var impulse = new b2Vec3(); + var C1X = this.m_perp.x * dX + this.m_perp.y * dY; + var C1Y = a2 - a1 - this.m_refAngle; + linearError = b2Math.Max(linearError, b2Math.Abs(C1X)); + angularError = b2Math.Abs(C1Y); + if (active) { + m1 = this.m_invMassA; + m2 = this.m_invMassB; + i1 = this.m_invIA; + i2 = this.m_invIB; + this.m_K.col1.x = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; + this.m_K.col1.y = i1 * this.m_s1 + i2 * this.m_s2; + this.m_K.col1.z = i1 * this.m_s1 * this.m_a1 + i2 * this.m_s2 * this.m_a2; + this.m_K.col2.x = this.m_K.col1.y; + this.m_K.col2.y = i1 + i2; + this.m_K.col2.z = i1 * this.m_a1 + i2 * this.m_a2; + this.m_K.col3.x = this.m_K.col1.z; + this.m_K.col3.y = this.m_K.col2.z; + this.m_K.col3.z = m1 + m2 + i1 * this.m_a1 * this.m_a1 + i2 * this.m_a2 * this.m_a2; + this.m_K.Solve33(impulse, (-C1X), (-C1Y), (-C2)); + } + else { + m1 = this.m_invMassA; + m2 = this.m_invMassB; + i1 = this.m_invIA; + i2 = this.m_invIB; + var k11 = m1 + m2 + i1 * this.m_s1 * this.m_s1 + i2 * this.m_s2 * this.m_s2; + var k12 = i1 * this.m_s1 + i2 * this.m_s2; + var k22 = i1 + i2; + this.m_K.col1.Set(k11, k12, 0.0); + this.m_K.col2.Set(k12, k22, 0.0); + var impulse1 = this.m_K.Solve22(new b2Vec2(), (-C1X), (-C1Y)); + impulse.x = impulse1.x; + impulse.y = impulse1.y; + impulse.z = 0.0; + } + var PX = impulse.x * this.m_perp.x + impulse.z * this.m_axis.x; + var PY = impulse.x * this.m_perp.y + impulse.z * this.m_axis.y; + var L1 = impulse.x * this.m_s1 + impulse.y + impulse.z * this.m_a1; + var L2 = impulse.x * this.m_s2 + impulse.y + impulse.z * this.m_a2; + c1.x -= this.m_invMassA * PX; + c1.y -= this.m_invMassA * PY; + a1 -= this.m_invIA * L1; + c2.x += this.m_invMassB * PX; + c2.y += this.m_invMassB * PY; + a2 += this.m_invIB * L2; + bA.m_sweep.a = a1; + bB.m_sweep.a = a2; + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + return linearError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop; + } + Box2D.inherit(b2PrismaticJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2PrismaticJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2PrismaticJointDef.b2PrismaticJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.localAnchorA = new b2Vec2(); + this.localAnchorB = new b2Vec2(); + this.localAxisA = new b2Vec2(); + }; + b2PrismaticJointDef.prototype.b2PrismaticJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_prismaticJoint; + this.localAxisA.Set(1.0, 0.0); + this.referenceAngle = 0.0; + this.enableLimit = false; + this.lowerTranslation = 0.0; + this.upperTranslation = 0.0; + this.enableMotor = false; + this.maxMotorForce = 0.0; + this.motorSpeed = 0.0; + } + b2PrismaticJointDef.prototype.Initialize = function (bA, bB, anchor, axis) { + this.bodyA = bA; + this.bodyB = bB; + this.localAnchorA = this.bodyA.GetLocalPoint(anchor); + this.localAnchorB = this.bodyB.GetLocalPoint(anchor); + this.localAxisA = this.bodyA.GetLocalVector(axis); + this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle(); + } + Box2D.inherit(b2PulleyJoint, Box2D.Dynamics.Joints.b2Joint); + b2PulleyJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2PulleyJoint.b2PulleyJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.m_groundAnchor1 = new b2Vec2(); + this.m_groundAnchor2 = new b2Vec2(); + this.m_localAnchor1 = new b2Vec2(); + this.m_localAnchor2 = new b2Vec2(); + this.m_u1 = new b2Vec2(); + this.m_u2 = new b2Vec2(); + }; + b2PulleyJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); + } + b2PulleyJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); + } + b2PulleyJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * this.m_impulse * this.m_u2.x, inv_dt * this.m_impulse * this.m_u2.y); + } + b2PulleyJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return 0.0; + } + b2PulleyJoint.prototype.GetGroundAnchorA = function () { + var a = this.m_ground.m_xf.position.Copy(); + a.Add(this.m_groundAnchor1); + return a; + } + b2PulleyJoint.prototype.GetGroundAnchorB = function () { + var a = this.m_ground.m_xf.position.Copy(); + a.Add(this.m_groundAnchor2); + return a; + } + b2PulleyJoint.prototype.GetLength1 = function () { + var p = this.m_bodyA.GetWorldPoint(this.m_localAnchor1); + var sX = this.m_ground.m_xf.position.x + this.m_groundAnchor1.x; + var sY = this.m_ground.m_xf.position.y + this.m_groundAnchor1.y; + var dX = p.x - sX; + var dY = p.y - sY; + return Math.sqrt(dX * dX + dY * dY); + } + b2PulleyJoint.prototype.GetLength2 = function () { + var p = this.m_bodyB.GetWorldPoint(this.m_localAnchor2); + var sX = this.m_ground.m_xf.position.x + this.m_groundAnchor2.x; + var sY = this.m_ground.m_xf.position.y + this.m_groundAnchor2.y; + var dX = p.x - sX; + var dY = p.y - sY; + return Math.sqrt(dX * dX + dY * dY); + } + b2PulleyJoint.prototype.GetRatio = function () { + return this.m_ratio; + } + b2PulleyJoint.prototype.b2PulleyJoint = function (def) { + this.__super.b2Joint.call(this, def); + var tMat; + var tX = 0; + var tY = 0; + this.m_ground = this.m_bodyA.m_world.m_groundBody; + this.m_groundAnchor1.x = def.groundAnchorA.x - this.m_ground.m_xf.position.x; + this.m_groundAnchor1.y = def.groundAnchorA.y - this.m_ground.m_xf.position.y; + this.m_groundAnchor2.x = def.groundAnchorB.x - this.m_ground.m_xf.position.x; + this.m_groundAnchor2.y = def.groundAnchorB.y - this.m_ground.m_xf.position.y; + this.m_localAnchor1.SetV(def.localAnchorA); + this.m_localAnchor2.SetV(def.localAnchorB); + this.m_ratio = def.ratio; + this.m_constant = def.lengthA + this.m_ratio * def.lengthB; + this.m_maxLength1 = b2Math.Min(def.maxLengthA, this.m_constant - this.m_ratio * b2PulleyJoint.b2_minPulleyLength); + this.m_maxLength2 = b2Math.Min(def.maxLengthB, (this.m_constant - b2PulleyJoint.b2_minPulleyLength) / this.m_ratio); + this.m_impulse = 0.0; + this.m_limitImpulse1 = 0.0; + this.m_limitImpulse2 = 0.0; + } + b2PulleyJoint.prototype.InitVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var p1X = bA.m_sweep.c.x + r1X; + var p1Y = bA.m_sweep.c.y + r1Y; + var p2X = bB.m_sweep.c.x + r2X; + var p2Y = bB.m_sweep.c.y + r2Y; + var s1X = this.m_ground.m_xf.position.x + this.m_groundAnchor1.x; + var s1Y = this.m_ground.m_xf.position.y + this.m_groundAnchor1.y; + var s2X = this.m_ground.m_xf.position.x + this.m_groundAnchor2.x; + var s2Y = this.m_ground.m_xf.position.y + this.m_groundAnchor2.y; + this.m_u1.Set(p1X - s1X, p1Y - s1Y); + this.m_u2.Set(p2X - s2X, p2Y - s2Y); + var length1 = this.m_u1.Length(); + var length2 = this.m_u2.Length(); + if (length1 > b2Settings.b2_linearSlop) { + this.m_u1.Multiply(1.0 / length1); + } + else { + this.m_u1.SetZero(); + } + if (length2 > b2Settings.b2_linearSlop) { + this.m_u2.Multiply(1.0 / length2); + } + else { + this.m_u2.SetZero(); + } + var C = this.m_constant - length1 - this.m_ratio * length2; + if (C > 0.0) { + this.m_state = b2Joint.e_inactiveLimit; + this.m_impulse = 0.0; + } + else { + this.m_state = b2Joint.e_atUpperLimit; + } + if (length1 < this.m_maxLength1) { + this.m_limitState1 = b2Joint.e_inactiveLimit; + this.m_limitImpulse1 = 0.0; + } + else { + this.m_limitState1 = b2Joint.e_atUpperLimit; + } + if (length2 < this.m_maxLength2) { + this.m_limitState2 = b2Joint.e_inactiveLimit; + this.m_limitImpulse2 = 0.0; + } + else { + this.m_limitState2 = b2Joint.e_atUpperLimit; + } + var cr1u1 = r1X * this.m_u1.y - r1Y * this.m_u1.x; + var cr2u2 = r2X * this.m_u2.y - r2Y * this.m_u2.x; + this.m_limitMass1 = bA.m_invMass + bA.m_invI * cr1u1 * cr1u1; + this.m_limitMass2 = bB.m_invMass + bB.m_invI * cr2u2 * cr2u2; + this.m_pulleyMass = this.m_limitMass1 + this.m_ratio * this.m_ratio * this.m_limitMass2; + this.m_limitMass1 = 1.0 / this.m_limitMass1; + this.m_limitMass2 = 1.0 / this.m_limitMass2; + this.m_pulleyMass = 1.0 / this.m_pulleyMass; + if (step.warmStarting) { + this.m_impulse *= step.dtRatio; + this.m_limitImpulse1 *= step.dtRatio; + this.m_limitImpulse2 *= step.dtRatio; + var P1X = ((-this.m_impulse) - this.m_limitImpulse1) * this.m_u1.x; + var P1Y = ((-this.m_impulse) - this.m_limitImpulse1) * this.m_u1.y; + var P2X = ((-this.m_ratio * this.m_impulse) - this.m_limitImpulse2) * this.m_u2.x; + var P2Y = ((-this.m_ratio * this.m_impulse) - this.m_limitImpulse2) * this.m_u2.y; + bA.m_linearVelocity.x += bA.m_invMass * P1X; + bA.m_linearVelocity.y += bA.m_invMass * P1Y; + bA.m_angularVelocity += bA.m_invI * (r1X * P1Y - r1Y * P1X); + bB.m_linearVelocity.x += bB.m_invMass * P2X; + bB.m_linearVelocity.y += bB.m_invMass * P2Y; + bB.m_angularVelocity += bB.m_invI * (r2X * P2Y - r2Y * P2X); + } + else { + this.m_impulse = 0.0; + this.m_limitImpulse1 = 0.0; + this.m_limitImpulse2 = 0.0; + } + } + b2PulleyJoint.prototype.SolveVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + var tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var v1X = 0; + var v1Y = 0; + var v2X = 0; + var v2Y = 0; + var P1X = 0; + var P1Y = 0; + var P2X = 0; + var P2Y = 0; + var Cdot = 0; + var impulse = 0; + var oldImpulse = 0; + if (this.m_state == b2Joint.e_atUpperLimit) { + v1X = bA.m_linearVelocity.x + ((-bA.m_angularVelocity * r1Y)); + v1Y = bA.m_linearVelocity.y + (bA.m_angularVelocity * r1X); + v2X = bB.m_linearVelocity.x + ((-bB.m_angularVelocity * r2Y)); + v2Y = bB.m_linearVelocity.y + (bB.m_angularVelocity * r2X); + Cdot = (-(this.m_u1.x * v1X + this.m_u1.y * v1Y)) - this.m_ratio * (this.m_u2.x * v2X + this.m_u2.y * v2Y); + impulse = this.m_pulleyMass * ((-Cdot)); + oldImpulse = this.m_impulse; + this.m_impulse = b2Math.Max(0.0, this.m_impulse + impulse); + impulse = this.m_impulse - oldImpulse; + P1X = (-impulse * this.m_u1.x); + P1Y = (-impulse * this.m_u1.y); + P2X = (-this.m_ratio * impulse * this.m_u2.x); + P2Y = (-this.m_ratio * impulse * this.m_u2.y); + bA.m_linearVelocity.x += bA.m_invMass * P1X; + bA.m_linearVelocity.y += bA.m_invMass * P1Y; + bA.m_angularVelocity += bA.m_invI * (r1X * P1Y - r1Y * P1X); + bB.m_linearVelocity.x += bB.m_invMass * P2X; + bB.m_linearVelocity.y += bB.m_invMass * P2Y; + bB.m_angularVelocity += bB.m_invI * (r2X * P2Y - r2Y * P2X); + } + if (this.m_limitState1 == b2Joint.e_atUpperLimit) { + v1X = bA.m_linearVelocity.x + ((-bA.m_angularVelocity * r1Y)); + v1Y = bA.m_linearVelocity.y + (bA.m_angularVelocity * r1X); + Cdot = (-(this.m_u1.x * v1X + this.m_u1.y * v1Y)); + impulse = (-this.m_limitMass1 * Cdot); + oldImpulse = this.m_limitImpulse1; + this.m_limitImpulse1 = b2Math.Max(0.0, this.m_limitImpulse1 + impulse); + impulse = this.m_limitImpulse1 - oldImpulse; + P1X = (-impulse * this.m_u1.x); + P1Y = (-impulse * this.m_u1.y); + bA.m_linearVelocity.x += bA.m_invMass * P1X; + bA.m_linearVelocity.y += bA.m_invMass * P1Y; + bA.m_angularVelocity += bA.m_invI * (r1X * P1Y - r1Y * P1X); + } + if (this.m_limitState2 == b2Joint.e_atUpperLimit) { + v2X = bB.m_linearVelocity.x + ((-bB.m_angularVelocity * r2Y)); + v2Y = bB.m_linearVelocity.y + (bB.m_angularVelocity * r2X); + Cdot = (-(this.m_u2.x * v2X + this.m_u2.y * v2Y)); + impulse = (-this.m_limitMass2 * Cdot); + oldImpulse = this.m_limitImpulse2; + this.m_limitImpulse2 = b2Math.Max(0.0, this.m_limitImpulse2 + impulse); + impulse = this.m_limitImpulse2 - oldImpulse; + P2X = (-impulse * this.m_u2.x); + P2Y = (-impulse * this.m_u2.y); + bB.m_linearVelocity.x += bB.m_invMass * P2X; + bB.m_linearVelocity.y += bB.m_invMass * P2Y; + bB.m_angularVelocity += bB.m_invI * (r2X * P2Y - r2Y * P2X); + } + } + b2PulleyJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + var s1X = this.m_ground.m_xf.position.x + this.m_groundAnchor1.x; + var s1Y = this.m_ground.m_xf.position.y + this.m_groundAnchor1.y; + var s2X = this.m_ground.m_xf.position.x + this.m_groundAnchor2.x; + var s2Y = this.m_ground.m_xf.position.y + this.m_groundAnchor2.y; + var r1X = 0; + var r1Y = 0; + var r2X = 0; + var r2Y = 0; + var p1X = 0; + var p1Y = 0; + var p2X = 0; + var p2Y = 0; + var length1 = 0; + var length2 = 0; + var C = 0; + var impulse = 0; + var oldImpulse = 0; + var oldLimitPositionImpulse = 0; + var tX = 0; + var linearError = 0.0; + if (this.m_state == b2Joint.e_atUpperLimit) { + tMat = bA.m_xf.R; + r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + p1X = bA.m_sweep.c.x + r1X; + p1Y = bA.m_sweep.c.y + r1Y; + p2X = bB.m_sweep.c.x + r2X; + p2Y = bB.m_sweep.c.y + r2Y; + this.m_u1.Set(p1X - s1X, p1Y - s1Y); + this.m_u2.Set(p2X - s2X, p2Y - s2Y); + length1 = this.m_u1.Length(); + length2 = this.m_u2.Length(); + if (length1 > b2Settings.b2_linearSlop) { + this.m_u1.Multiply(1.0 / length1); + } + else { + this.m_u1.SetZero(); + } + if (length2 > b2Settings.b2_linearSlop) { + this.m_u2.Multiply(1.0 / length2); + } + else { + this.m_u2.SetZero(); + } + C = this.m_constant - length1 - this.m_ratio * length2; + linearError = b2Math.Max(linearError, (-C)); + C = b2Math.Clamp(C + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0); + impulse = (-this.m_pulleyMass * C); + p1X = (-impulse * this.m_u1.x); + p1Y = (-impulse * this.m_u1.y); + p2X = (-this.m_ratio * impulse * this.m_u2.x); + p2Y = (-this.m_ratio * impulse * this.m_u2.y); + bA.m_sweep.c.x += bA.m_invMass * p1X; + bA.m_sweep.c.y += bA.m_invMass * p1Y; + bA.m_sweep.a += bA.m_invI * (r1X * p1Y - r1Y * p1X); + bB.m_sweep.c.x += bB.m_invMass * p2X; + bB.m_sweep.c.y += bB.m_invMass * p2Y; + bB.m_sweep.a += bB.m_invI * (r2X * p2Y - r2Y * p2X); + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + } + if (this.m_limitState1 == b2Joint.e_atUpperLimit) { + tMat = bA.m_xf.R; + r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + p1X = bA.m_sweep.c.x + r1X; + p1Y = bA.m_sweep.c.y + r1Y; + this.m_u1.Set(p1X - s1X, p1Y - s1Y); + length1 = this.m_u1.Length(); + if (length1 > b2Settings.b2_linearSlop) { + this.m_u1.x *= 1.0 / length1; + this.m_u1.y *= 1.0 / length1; + } + else { + this.m_u1.SetZero(); + } + C = this.m_maxLength1 - length1; + linearError = b2Math.Max(linearError, (-C)); + C = b2Math.Clamp(C + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0); + impulse = (-this.m_limitMass1 * C); + p1X = (-impulse * this.m_u1.x); + p1Y = (-impulse * this.m_u1.y); + bA.m_sweep.c.x += bA.m_invMass * p1X; + bA.m_sweep.c.y += bA.m_invMass * p1Y; + bA.m_sweep.a += bA.m_invI * (r1X * p1Y - r1Y * p1X); + bA.SynchronizeTransform(); + } + if (this.m_limitState2 == b2Joint.e_atUpperLimit) { + tMat = bB.m_xf.R; + r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + p2X = bB.m_sweep.c.x + r2X; + p2Y = bB.m_sweep.c.y + r2Y; + this.m_u2.Set(p2X - s2X, p2Y - s2Y); + length2 = this.m_u2.Length(); + if (length2 > b2Settings.b2_linearSlop) { + this.m_u2.x *= 1.0 / length2; + this.m_u2.y *= 1.0 / length2; + } + else { + this.m_u2.SetZero(); + } + C = this.m_maxLength2 - length2; + linearError = b2Math.Max(linearError, (-C)); + C = b2Math.Clamp(C + b2Settings.b2_linearSlop, (-b2Settings.b2_maxLinearCorrection), 0.0); + impulse = (-this.m_limitMass2 * C); + p2X = (-impulse * this.m_u2.x); + p2Y = (-impulse * this.m_u2.y); + bB.m_sweep.c.x += bB.m_invMass * p2X; + bB.m_sweep.c.y += bB.m_invMass * p2Y; + bB.m_sweep.a += bB.m_invI * (r2X * p2Y - r2Y * p2X); + bB.SynchronizeTransform(); + } + return linearError < b2Settings.b2_linearSlop; + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.Joints.b2PulleyJoint.b2_minPulleyLength = 2.0; + }); + Box2D.inherit(b2PulleyJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2PulleyJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2PulleyJointDef.b2PulleyJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.groundAnchorA = new b2Vec2(); + this.groundAnchorB = new b2Vec2(); + this.localAnchorA = new b2Vec2(); + this.localAnchorB = new b2Vec2(); + }; + b2PulleyJointDef.prototype.b2PulleyJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_pulleyJoint; + this.groundAnchorA.Set((-1.0), 1.0); + this.groundAnchorB.Set(1.0, 1.0); + this.localAnchorA.Set((-1.0), 0.0); + this.localAnchorB.Set(1.0, 0.0); + this.lengthA = 0.0; + this.maxLengthA = 0.0; + this.lengthB = 0.0; + this.maxLengthB = 0.0; + this.ratio = 1.0; + this.collideConnected = true; + } + b2PulleyJointDef.prototype.Initialize = function (bA, bB, gaA, gaB, anchorA, anchorB, r) { + if (r === undefined) r = 0; + this.bodyA = bA; + this.bodyB = bB; + this.groundAnchorA.SetV(gaA); + this.groundAnchorB.SetV(gaB); + this.localAnchorA = this.bodyA.GetLocalPoint(anchorA); + this.localAnchorB = this.bodyB.GetLocalPoint(anchorB); + var d1X = anchorA.x - gaA.x; + var d1Y = anchorA.y - gaA.y; + this.lengthA = Math.sqrt(d1X * d1X + d1Y * d1Y); + var d2X = anchorB.x - gaB.x; + var d2Y = anchorB.y - gaB.y; + this.lengthB = Math.sqrt(d2X * d2X + d2Y * d2Y); + this.ratio = r; + var C = this.lengthA + this.ratio * this.lengthB; + this.maxLengthA = C - this.ratio * b2PulleyJoint.b2_minPulleyLength; + this.maxLengthB = (C - b2PulleyJoint.b2_minPulleyLength) / this.ratio; + } + Box2D.inherit(b2RevoluteJoint, Box2D.Dynamics.Joints.b2Joint); + b2RevoluteJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2RevoluteJoint.b2RevoluteJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.K = new b2Mat22(); + this.K1 = new b2Mat22(); + this.K2 = new b2Mat22(); + this.K3 = new b2Mat22(); + this.impulse3 = new b2Vec3(); + this.impulse2 = new b2Vec2(); + this.reduced = new b2Vec2(); + this.m_localAnchor1 = new b2Vec2(); + this.m_localAnchor2 = new b2Vec2(); + this.m_impulse = new b2Vec3(); + this.m_mass = new b2Mat33(); + }; + b2RevoluteJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchor1); + } + b2RevoluteJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchor2); + } + b2RevoluteJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * this.m_impulse.x, inv_dt * this.m_impulse.y); + } + b2RevoluteJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return inv_dt * this.m_impulse.z; + } + b2RevoluteJoint.prototype.GetJointAngle = function () { + return this.m_bodyB.m_sweep.a - this.m_bodyA.m_sweep.a - this.m_referenceAngle; + } + b2RevoluteJoint.prototype.GetJointSpeed = function () { + return this.m_bodyB.m_angularVelocity - this.m_bodyA.m_angularVelocity; + } + b2RevoluteJoint.prototype.IsLimitEnabled = function () { + return this.m_enableLimit; + } + b2RevoluteJoint.prototype.EnableLimit = function (flag) { + this.m_enableLimit = flag; + } + b2RevoluteJoint.prototype.GetLowerLimit = function () { + return this.m_lowerAngle; + } + b2RevoluteJoint.prototype.GetUpperLimit = function () { + return this.m_upperAngle; + } + b2RevoluteJoint.prototype.SetLimits = function (lower, upper) { + + if (lower === undefined) lower = 0; + if (upper === undefined) upper = 0; + this.m_lowerAngle = lower; + this.m_upperAngle = upper; + } + b2RevoluteJoint.prototype.IsMotorEnabled = function () { + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + return this.m_enableMotor; + } + b2RevoluteJoint.prototype.EnableMotor = function (flag) { + this.m_enableMotor = flag; + } + b2RevoluteJoint.prototype.SetMotorSpeed = function (speed) { + if (speed === undefined) speed = 0; + this.m_bodyA.SetAwake(true); + this.m_bodyB.SetAwake(true); + this.m_motorSpeed = speed; + } + b2RevoluteJoint.prototype.GetMotorSpeed = function () { + return this.m_motorSpeed; + } + b2RevoluteJoint.prototype.SetMaxMotorTorque = function (torque) { + if (torque === undefined) torque = 0; + this.m_maxMotorTorque = torque; + } + b2RevoluteJoint.prototype.GetMotorTorque = function () { + return this.m_maxMotorTorque; + } + b2RevoluteJoint.prototype.b2RevoluteJoint = function (def) { + this.__super.b2Joint.call(this, def); + this.m_localAnchor1.SetV(def.localAnchorA); + this.m_localAnchor2.SetV(def.localAnchorB); + this.m_referenceAngle = def.referenceAngle; + this.m_impulse.SetZero(); + this.m_motorImpulse = 0.0; + this.m_lowerAngle = def.lowerAngle; + this.m_upperAngle = def.upperAngle; + this.m_maxMotorTorque = def.maxMotorTorque; + this.m_motorSpeed = def.motorSpeed; + this.m_enableLimit = def.enableLimit; + this.m_enableMotor = def.enableMotor; + this.m_limitState = b2Joint.e_inactiveLimit; + } + b2RevoluteJoint.prototype.InitVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + var tX = 0; + if (this.m_enableMotor || this.m_enableLimit) {} + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var m1 = bA.m_invMass; + var m2 = bB.m_invMass; + var i1 = bA.m_invI; + var i2 = bB.m_invI; + this.m_mass.col1.x = m1 + m2 + r1Y * r1Y * i1 + r2Y * r2Y * i2; + this.m_mass.col2.x = (-r1Y * r1X * i1) - r2Y * r2X * i2; + this.m_mass.col3.x = (-r1Y * i1) - r2Y * i2; + this.m_mass.col1.y = this.m_mass.col2.x; + this.m_mass.col2.y = m1 + m2 + r1X * r1X * i1 + r2X * r2X * i2; + this.m_mass.col3.y = r1X * i1 + r2X * i2; + this.m_mass.col1.z = this.m_mass.col3.x; + this.m_mass.col2.z = this.m_mass.col3.y; + this.m_mass.col3.z = i1 + i2; + this.m_motorMass = 1.0 / (i1 + i2); + if (this.m_enableMotor == false) { + this.m_motorImpulse = 0.0; + } + if (this.m_enableLimit) { + var jointAngle = bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle; + if (b2Math.Abs(this.m_upperAngle - this.m_lowerAngle) < 2.0 * b2Settings.b2_angularSlop) { + this.m_limitState = b2Joint.e_equalLimits; + } + else if (jointAngle <= this.m_lowerAngle) { + if (this.m_limitState != b2Joint.e_atLowerLimit) { + this.m_impulse.z = 0.0; + } + this.m_limitState = b2Joint.e_atLowerLimit; + } + else if (jointAngle >= this.m_upperAngle) { + if (this.m_limitState != b2Joint.e_atUpperLimit) { + this.m_impulse.z = 0.0; + } + this.m_limitState = b2Joint.e_atUpperLimit; + } + else { + this.m_limitState = b2Joint.e_inactiveLimit; + this.m_impulse.z = 0.0; + } + } + else { + this.m_limitState = b2Joint.e_inactiveLimit; + } + if (step.warmStarting) { + this.m_impulse.x *= step.dtRatio; + this.m_impulse.y *= step.dtRatio; + this.m_motorImpulse *= step.dtRatio; + var PX = this.m_impulse.x; + var PY = this.m_impulse.y; + bA.m_linearVelocity.x -= m1 * PX; + bA.m_linearVelocity.y -= m1 * PY; + bA.m_angularVelocity -= i1 * ((r1X * PY - r1Y * PX) + this.m_motorImpulse + this.m_impulse.z); + bB.m_linearVelocity.x += m2 * PX; + bB.m_linearVelocity.y += m2 * PY; + bB.m_angularVelocity += i2 * ((r2X * PY - r2Y * PX) + this.m_motorImpulse + this.m_impulse.z); + } + else { + this.m_impulse.SetZero(); + this.m_motorImpulse = 0.0; + } + } + b2RevoluteJoint.prototype.SolveVelocityConstraints = function (step) { + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var tMat; + var tX = 0; + var newImpulse = 0; + var r1X = 0; + var r1Y = 0; + var r2X = 0; + var r2Y = 0; + var v1 = bA.m_linearVelocity; + var w1 = bA.m_angularVelocity; + var v2 = bB.m_linearVelocity; + var w2 = bB.m_angularVelocity; + var m1 = bA.m_invMass; + var m2 = bB.m_invMass; + var i1 = bA.m_invI; + var i2 = bB.m_invI; + if (this.m_enableMotor && this.m_limitState != b2Joint.e_equalLimits) { + var Cdot = w2 - w1 - this.m_motorSpeed; + var impulse = this.m_motorMass * ((-Cdot)); + var oldImpulse = this.m_motorImpulse; + var maxImpulse = step.dt * this.m_maxMotorTorque; + this.m_motorImpulse = b2Math.Clamp(this.m_motorImpulse + impulse, (-maxImpulse), maxImpulse); + impulse = this.m_motorImpulse - oldImpulse; + w1 -= i1 * impulse; + w2 += i2 * impulse; + } + if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) { + tMat = bA.m_xf.R; + r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var Cdot1X = v2.x + ((-w2 * r2Y)) - v1.x - ((-w1 * r1Y)); + var Cdot1Y = v2.y + (w2 * r2X) - v1.y - (w1 * r1X); + var Cdot2 = w2 - w1; + this.m_mass.Solve33(this.impulse3, (-Cdot1X), (-Cdot1Y), (-Cdot2)); + if (this.m_limitState == b2Joint.e_equalLimits) { + this.m_impulse.Add(this.impulse3); + } + else if (this.m_limitState == b2Joint.e_atLowerLimit) { + newImpulse = this.m_impulse.z + this.impulse3.z; + if (newImpulse < 0.0) { + this.m_mass.Solve22(this.reduced, (-Cdot1X), (-Cdot1Y)); + this.impulse3.x = this.reduced.x; + this.impulse3.y = this.reduced.y; + this.impulse3.z = (-this.m_impulse.z); + this.m_impulse.x += this.reduced.x; + this.m_impulse.y += this.reduced.y; + this.m_impulse.z = 0.0; + } + } + else if (this.m_limitState == b2Joint.e_atUpperLimit) { + newImpulse = this.m_impulse.z + this.impulse3.z; + if (newImpulse > 0.0) { + this.m_mass.Solve22(this.reduced, (-Cdot1X), (-Cdot1Y)); + this.impulse3.x = this.reduced.x; + this.impulse3.y = this.reduced.y; + this.impulse3.z = (-this.m_impulse.z); + this.m_impulse.x += this.reduced.x; + this.m_impulse.y += this.reduced.y; + this.m_impulse.z = 0.0; + } + } + v1.x -= m1 * this.impulse3.x; + v1.y -= m1 * this.impulse3.y; + w1 -= i1 * (r1X * this.impulse3.y - r1Y * this.impulse3.x + this.impulse3.z); + v2.x += m2 * this.impulse3.x; + v2.y += m2 * this.impulse3.y; + w2 += i2 * (r2X * this.impulse3.y - r2Y * this.impulse3.x + this.impulse3.z); + } + else { + tMat = bA.m_xf.R; + r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var CdotX = v2.x + ((-w2 * r2Y)) - v1.x - ((-w1 * r1Y)); + var CdotY = v2.y + (w2 * r2X) - v1.y - (w1 * r1X); + this.m_mass.Solve22(this.impulse2, (-CdotX), (-CdotY)); + this.m_impulse.x += this.impulse2.x; + this.m_impulse.y += this.impulse2.y; + v1.x -= m1 * this.impulse2.x; + v1.y -= m1 * this.impulse2.y; + w1 -= i1 * (r1X * this.impulse2.y - r1Y * this.impulse2.x); + v2.x += m2 * this.impulse2.x; + v2.y += m2 * this.impulse2.y; + w2 += i2 * (r2X * this.impulse2.y - r2Y * this.impulse2.x); + } + bA.m_linearVelocity.SetV(v1); + bA.m_angularVelocity = w1; + bB.m_linearVelocity.SetV(v2); + bB.m_angularVelocity = w2; + } + b2RevoluteJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var oldLimitImpulse = 0; + var C = 0; + var tMat; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var angularError = 0.0; + var positionError = 0.0; + var tX = 0; + var impulseX = 0; + var impulseY = 0; + if (this.m_enableLimit && this.m_limitState != b2Joint.e_inactiveLimit) { + var angle = bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle; + var limitImpulse = 0.0; + if (this.m_limitState == b2Joint.e_equalLimits) { + C = b2Math.Clamp(angle - this.m_lowerAngle, (-b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection); + limitImpulse = (-this.m_motorMass * C); + angularError = b2Math.Abs(C); + } + else if (this.m_limitState == b2Joint.e_atLowerLimit) { + C = angle - this.m_lowerAngle; + angularError = (-C); + C = b2Math.Clamp(C + b2Settings.b2_angularSlop, (-b2Settings.b2_maxAngularCorrection), 0.0); + limitImpulse = (-this.m_motorMass * C); + } + else if (this.m_limitState == b2Joint.e_atUpperLimit) { + C = angle - this.m_upperAngle; + angularError = C; + C = b2Math.Clamp(C - b2Settings.b2_angularSlop, 0.0, b2Settings.b2_maxAngularCorrection); + limitImpulse = (-this.m_motorMass * C); + } + bA.m_sweep.a -= bA.m_invI * limitImpulse; + bB.m_sweep.a += bB.m_invI * limitImpulse; + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + } { + tMat = bA.m_xf.R; + var r1X = this.m_localAnchor1.x - bA.m_sweep.localCenter.x; + var r1Y = this.m_localAnchor1.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * r1X + tMat.col2.x * r1Y); + r1Y = (tMat.col1.y * r1X + tMat.col2.y * r1Y); + r1X = tX; + tMat = bB.m_xf.R; + var r2X = this.m_localAnchor2.x - bB.m_sweep.localCenter.x; + var r2Y = this.m_localAnchor2.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * r2X + tMat.col2.x * r2Y); + r2Y = (tMat.col1.y * r2X + tMat.col2.y * r2Y); + r2X = tX; + var CX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; + var CY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; + var CLengthSquared = CX * CX + CY * CY; + var CLength = Math.sqrt(CLengthSquared); + positionError = CLength; + var invMass1 = bA.m_invMass; + var invMass2 = bB.m_invMass; + var invI1 = bA.m_invI; + var invI2 = bB.m_invI; + var k_allowedStretch = 10.0 * b2Settings.b2_linearSlop; + if (CLengthSquared > k_allowedStretch * k_allowedStretch) { + var uX = CX / CLength; + var uY = CY / CLength; + var k = invMass1 + invMass2; + var m = 1.0 / k; + impulseX = m * ((-CX)); + impulseY = m * ((-CY)); + var k_beta = 0.5; + bA.m_sweep.c.x -= k_beta * invMass1 * impulseX; + bA.m_sweep.c.y -= k_beta * invMass1 * impulseY; + bB.m_sweep.c.x += k_beta * invMass2 * impulseX; + bB.m_sweep.c.y += k_beta * invMass2 * impulseY; + CX = bB.m_sweep.c.x + r2X - bA.m_sweep.c.x - r1X; + CY = bB.m_sweep.c.y + r2Y - bA.m_sweep.c.y - r1Y; + } + this.K1.col1.x = invMass1 + invMass2; + this.K1.col2.x = 0.0; + this.K1.col1.y = 0.0; + this.K1.col2.y = invMass1 + invMass2; + this.K2.col1.x = invI1 * r1Y * r1Y; + this.K2.col2.x = (-invI1 * r1X * r1Y); + this.K2.col1.y = (-invI1 * r1X * r1Y); + this.K2.col2.y = invI1 * r1X * r1X; + this.K3.col1.x = invI2 * r2Y * r2Y; + this.K3.col2.x = (-invI2 * r2X * r2Y); + this.K3.col1.y = (-invI2 * r2X * r2Y); + this.K3.col2.y = invI2 * r2X * r2X; + this.K.SetM(this.K1); + this.K.AddM(this.K2); + this.K.AddM(this.K3); + this.K.Solve(b2RevoluteJoint.tImpulse, (-CX), (-CY)); + impulseX = b2RevoluteJoint.tImpulse.x; + impulseY = b2RevoluteJoint.tImpulse.y; + bA.m_sweep.c.x -= bA.m_invMass * impulseX; + bA.m_sweep.c.y -= bA.m_invMass * impulseY; + bA.m_sweep.a -= bA.m_invI * (r1X * impulseY - r1Y * impulseX); + bB.m_sweep.c.x += bB.m_invMass * impulseX; + bB.m_sweep.c.y += bB.m_invMass * impulseY; + bB.m_sweep.a += bB.m_invI * (r2X * impulseY - r2Y * impulseX); + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + } + return positionError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop; + } + Box2D.postDefs.push(function () { + Box2D.Dynamics.Joints.b2RevoluteJoint.tImpulse = new b2Vec2(); + }); + Box2D.inherit(b2RevoluteJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2RevoluteJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2RevoluteJointDef.b2RevoluteJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.localAnchorA = new b2Vec2(); + this.localAnchorB = new b2Vec2(); + }; + b2RevoluteJointDef.prototype.b2RevoluteJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_revoluteJoint; + this.localAnchorA.Set(0.0, 0.0); + this.localAnchorB.Set(0.0, 0.0); + this.referenceAngle = 0.0; + this.lowerAngle = 0.0; + this.upperAngle = 0.0; + this.maxMotorTorque = 0.0; + this.motorSpeed = 0.0; + this.enableLimit = false; + this.enableMotor = false; + } + b2RevoluteJointDef.prototype.Initialize = function (bA, bB, anchor) { + this.bodyA = bA; + this.bodyB = bB; + this.localAnchorA = this.bodyA.GetLocalPoint(anchor); + this.localAnchorB = this.bodyB.GetLocalPoint(anchor); + this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle(); + } + Box2D.inherit(b2WeldJoint, Box2D.Dynamics.Joints.b2Joint); + b2WeldJoint.prototype.__super = Box2D.Dynamics.Joints.b2Joint.prototype; + b2WeldJoint.b2WeldJoint = function () { + Box2D.Dynamics.Joints.b2Joint.b2Joint.apply(this, arguments); + this.m_localAnchorA = new b2Vec2(); + this.m_localAnchorB = new b2Vec2(); + this.m_impulse = new b2Vec3(); + this.m_mass = new b2Mat33(); + }; + b2WeldJoint.prototype.GetAnchorA = function () { + return this.m_bodyA.GetWorldPoint(this.m_localAnchorA); + } + b2WeldJoint.prototype.GetAnchorB = function () { + return this.m_bodyB.GetWorldPoint(this.m_localAnchorB); + } + b2WeldJoint.prototype.GetReactionForce = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return new b2Vec2(inv_dt * this.m_impulse.x, inv_dt * this.m_impulse.y); + } + b2WeldJoint.prototype.GetReactionTorque = function (inv_dt) { + if (inv_dt === undefined) inv_dt = 0; + return inv_dt * this.m_impulse.z; + } + b2WeldJoint.prototype.b2WeldJoint = function (def) { + this.__super.b2Joint.call(this, def); + this.m_localAnchorA.SetV(def.localAnchorA); + this.m_localAnchorB.SetV(def.localAnchorB); + this.m_referenceAngle = def.referenceAngle; + this.m_impulse.SetZero(); + this.m_mass = new b2Mat33(); + } + b2WeldJoint.prototype.InitVelocityConstraints = function (step) { + var tMat; + var tX = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + tMat = bA.m_xf.R; + var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x; + var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * rAX + tMat.col2.x * rAY); + rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY); + rAX = tX; + tMat = bB.m_xf.R; + var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x; + var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * rBX + tMat.col2.x * rBY); + rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY); + rBX = tX; + var mA = bA.m_invMass; + var mB = bB.m_invMass; + var iA = bA.m_invI; + var iB = bB.m_invI; + this.m_mass.col1.x = mA + mB + rAY * rAY * iA + rBY * rBY * iB; + this.m_mass.col2.x = (-rAY * rAX * iA) - rBY * rBX * iB; + this.m_mass.col3.x = (-rAY * iA) - rBY * iB; + this.m_mass.col1.y = this.m_mass.col2.x; + this.m_mass.col2.y = mA + mB + rAX * rAX * iA + rBX * rBX * iB; + this.m_mass.col3.y = rAX * iA + rBX * iB; + this.m_mass.col1.z = this.m_mass.col3.x; + this.m_mass.col2.z = this.m_mass.col3.y; + this.m_mass.col3.z = iA + iB; + if (step.warmStarting) { + this.m_impulse.x *= step.dtRatio; + this.m_impulse.y *= step.dtRatio; + this.m_impulse.z *= step.dtRatio; + bA.m_linearVelocity.x -= mA * this.m_impulse.x; + bA.m_linearVelocity.y -= mA * this.m_impulse.y; + bA.m_angularVelocity -= iA * (rAX * this.m_impulse.y - rAY * this.m_impulse.x + this.m_impulse.z); + bB.m_linearVelocity.x += mB * this.m_impulse.x; + bB.m_linearVelocity.y += mB * this.m_impulse.y; + bB.m_angularVelocity += iB * (rBX * this.m_impulse.y - rBY * this.m_impulse.x + this.m_impulse.z); + } + else { + this.m_impulse.SetZero(); + } + } + b2WeldJoint.prototype.SolveVelocityConstraints = function (step) { + var tMat; + var tX = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + var vA = bA.m_linearVelocity; + var wA = bA.m_angularVelocity; + var vB = bB.m_linearVelocity; + var wB = bB.m_angularVelocity; + var mA = bA.m_invMass; + var mB = bB.m_invMass; + var iA = bA.m_invI; + var iB = bB.m_invI; + tMat = bA.m_xf.R; + var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x; + var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * rAX + tMat.col2.x * rAY); + rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY); + rAX = tX; + tMat = bB.m_xf.R; + var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x; + var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * rBX + tMat.col2.x * rBY); + rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY); + rBX = tX; + var Cdot1X = vB.x - wB * rBY - vA.x + wA * rAY; + var Cdot1Y = vB.y + wB * rBX - vA.y - wA * rAX; + var Cdot2 = wB - wA; + var impulse = new b2Vec3(); + this.m_mass.Solve33(impulse, (-Cdot1X), (-Cdot1Y), (-Cdot2)); + this.m_impulse.Add(impulse); + vA.x -= mA * impulse.x; + vA.y -= mA * impulse.y; + wA -= iA * (rAX * impulse.y - rAY * impulse.x + impulse.z); + vB.x += mB * impulse.x; + vB.y += mB * impulse.y; + wB += iB * (rBX * impulse.y - rBY * impulse.x + impulse.z); + bA.m_angularVelocity = wA; + bB.m_angularVelocity = wB; + } + b2WeldJoint.prototype.SolvePositionConstraints = function (baumgarte) { + if (baumgarte === undefined) baumgarte = 0; + var tMat; + var tX = 0; + var bA = this.m_bodyA; + var bB = this.m_bodyB; + tMat = bA.m_xf.R; + var rAX = this.m_localAnchorA.x - bA.m_sweep.localCenter.x; + var rAY = this.m_localAnchorA.y - bA.m_sweep.localCenter.y; + tX = (tMat.col1.x * rAX + tMat.col2.x * rAY); + rAY = (tMat.col1.y * rAX + tMat.col2.y * rAY); + rAX = tX; + tMat = bB.m_xf.R; + var rBX = this.m_localAnchorB.x - bB.m_sweep.localCenter.x; + var rBY = this.m_localAnchorB.y - bB.m_sweep.localCenter.y; + tX = (tMat.col1.x * rBX + tMat.col2.x * rBY); + rBY = (tMat.col1.y * rBX + tMat.col2.y * rBY); + rBX = tX; + var mA = bA.m_invMass; + var mB = bB.m_invMass; + var iA = bA.m_invI; + var iB = bB.m_invI; + var C1X = bB.m_sweep.c.x + rBX - bA.m_sweep.c.x - rAX; + var C1Y = bB.m_sweep.c.y + rBY - bA.m_sweep.c.y - rAY; + var C2 = bB.m_sweep.a - bA.m_sweep.a - this.m_referenceAngle; + var k_allowedStretch = 10.0 * b2Settings.b2_linearSlop; + var positionError = Math.sqrt(C1X * C1X + C1Y * C1Y); + var angularError = b2Math.Abs(C2); + if (positionError > k_allowedStretch) { + iA *= 1.0; + iB *= 1.0; + } + this.m_mass.col1.x = mA + mB + rAY * rAY * iA + rBY * rBY * iB; + this.m_mass.col2.x = (-rAY * rAX * iA) - rBY * rBX * iB; + this.m_mass.col3.x = (-rAY * iA) - rBY * iB; + this.m_mass.col1.y = this.m_mass.col2.x; + this.m_mass.col2.y = mA + mB + rAX * rAX * iA + rBX * rBX * iB; + this.m_mass.col3.y = rAX * iA + rBX * iB; + this.m_mass.col1.z = this.m_mass.col3.x; + this.m_mass.col2.z = this.m_mass.col3.y; + this.m_mass.col3.z = iA + iB; + var impulse = new b2Vec3(); + this.m_mass.Solve33(impulse, (-C1X), (-C1Y), (-C2)); + bA.m_sweep.c.x -= mA * impulse.x; + bA.m_sweep.c.y -= mA * impulse.y; + bA.m_sweep.a -= iA * (rAX * impulse.y - rAY * impulse.x + impulse.z); + bB.m_sweep.c.x += mB * impulse.x; + bB.m_sweep.c.y += mB * impulse.y; + bB.m_sweep.a += iB * (rBX * impulse.y - rBY * impulse.x + impulse.z); + bA.SynchronizeTransform(); + bB.SynchronizeTransform(); + return positionError <= b2Settings.b2_linearSlop && angularError <= b2Settings.b2_angularSlop; + } + Box2D.inherit(b2WeldJointDef, Box2D.Dynamics.Joints.b2JointDef); + b2WeldJointDef.prototype.__super = Box2D.Dynamics.Joints.b2JointDef.prototype; + b2WeldJointDef.b2WeldJointDef = function () { + Box2D.Dynamics.Joints.b2JointDef.b2JointDef.apply(this, arguments); + this.localAnchorA = new b2Vec2(); + this.localAnchorB = new b2Vec2(); + }; + b2WeldJointDef.prototype.b2WeldJointDef = function () { + this.__super.b2JointDef.call(this); + this.type = b2Joint.e_weldJoint; + this.referenceAngle = 0.0; + } + b2WeldJointDef.prototype.Initialize = function (bA, bB, anchor) { + this.bodyA = bA; + this.bodyB = bB; + this.localAnchorA.SetV(this.bodyA.GetLocalPoint(anchor)); + this.localAnchorB.SetV(this.bodyB.GetLocalPoint(anchor)); + this.referenceAngle = this.bodyB.GetAngle() - this.bodyA.GetAngle(); + } +})(); +(function () { + var b2DebugDraw = Box2D.Dynamics.b2DebugDraw; + b2DebugDraw.b2DebugDraw = function () { + this.m_drawScale = 1.0; + this.m_lineThickness = 1.0; + this.m_alpha = 1.0; + this.m_fillAlpha = 1.0; + this.m_xformScale = 1.0; + var __this = this; + //#WORKAROUND + this.m_sprite = { + graphics: { + clear: function () { + __this.m_ctx.clearRect(0, 0, __this.m_ctx.canvas.width, __this.m_ctx.canvas.height) + } + } + }; + }; + b2DebugDraw.prototype._color = function (color, alpha) { + return "rgba(" + ((color & 0xFF0000) >> 16) + "," + ((color & 0xFF00) >> 8) + "," + (color & 0xFF) + "," + alpha + ")"; + }; + b2DebugDraw.prototype.b2DebugDraw = function () { + this.m_drawFlags = 0; + }; + b2DebugDraw.prototype.SetFlags = function (flags) { + if (flags === undefined) flags = 0; + this.m_drawFlags = flags; + }; + b2DebugDraw.prototype.GetFlags = function () { + return this.m_drawFlags; + }; + b2DebugDraw.prototype.AppendFlags = function (flags) { + if (flags === undefined) flags = 0; + this.m_drawFlags |= flags; + }; + b2DebugDraw.prototype.ClearFlags = function (flags) { + if (flags === undefined) flags = 0; + this.m_drawFlags &= ~flags; + }; + b2DebugDraw.prototype.SetSprite = function (sprite) { + this.m_ctx = sprite; + }; + b2DebugDraw.prototype.GetSprite = function () { + return this.m_ctx; + }; + b2DebugDraw.prototype.SetDrawScale = function (drawScale) { + if (drawScale === undefined) drawScale = 0; + this.m_drawScale = drawScale; + }; + b2DebugDraw.prototype.GetDrawScale = function () { + return this.m_drawScale; + }; + b2DebugDraw.prototype.SetLineThickness = function (lineThickness) { + if (lineThickness === undefined) lineThickness = 0; + this.m_lineThickness = lineThickness; + this.m_ctx.strokeWidth = lineThickness; + }; + b2DebugDraw.prototype.GetLineThickness = function () { + return this.m_lineThickness; + }; + b2DebugDraw.prototype.SetAlpha = function (alpha) { + if (alpha === undefined) alpha = 0; + this.m_alpha = alpha; + }; + b2DebugDraw.prototype.GetAlpha = function () { + return this.m_alpha; + }; + b2DebugDraw.prototype.SetFillAlpha = function (alpha) { + if (alpha === undefined) alpha = 0; + this.m_fillAlpha = alpha; + }; + b2DebugDraw.prototype.GetFillAlpha = function () { + return this.m_fillAlpha; + }; + b2DebugDraw.prototype.SetXFormScale = function (xformScale) { + if (xformScale === undefined) xformScale = 0; + this.m_xformScale = xformScale; + }; + b2DebugDraw.prototype.GetXFormScale = function () { + return this.m_xformScale; + }; + b2DebugDraw.prototype.DrawPolygon = function (vertices, vertexCount, color) { + if (!vertexCount) return; + var s = this.m_ctx; + var drawScale = this.m_drawScale; + s.beginPath(); + s.strokeStyle = this._color(color.color, this.m_alpha); + s.moveTo(vertices[0].x * drawScale, vertices[0].y * drawScale); + for (var i = 1; i < vertexCount; i++) { + s.lineTo(vertices[i].x * drawScale, vertices[i].y * drawScale); + } + s.lineTo(vertices[0].x * drawScale, vertices[0].y * drawScale); + s.closePath(); + s.stroke(); + }; + b2DebugDraw.prototype.DrawSolidPolygon = function (vertices, vertexCount, color) { + if (!vertexCount) return; + var s = this.m_ctx; + var drawScale = this.m_drawScale; + s.beginPath(); + s.strokeStyle = this._color(color.color, this.m_alpha); + s.fillStyle = this._color(color.color, this.m_fillAlpha); + s.moveTo(vertices[0].x * drawScale, vertices[0].y * drawScale); + for (var i = 1; i < vertexCount; i++) { + s.lineTo(vertices[i].x * drawScale, vertices[i].y * drawScale); + } + s.lineTo(vertices[0].x * drawScale, vertices[0].y * drawScale); + s.closePath(); + s.fill(); + s.stroke(); + }; + b2DebugDraw.prototype.DrawCircle = function (center, radius, color) { + if (!radius) return; + var s = this.m_ctx; + var drawScale = this.m_drawScale; + s.beginPath(); + s.strokeStyle = this._color(color.color, this.m_alpha); + s.arc(center.x * drawScale, center.y * drawScale, radius * drawScale, 0, Math.PI * 2, true); + s.closePath(); + s.stroke(); + }; + b2DebugDraw.prototype.DrawSolidCircle = function (center, radius, axis, color) { + if (!radius) return; + var s = this.m_ctx, + drawScale = this.m_drawScale, + cx = center.x * drawScale, + cy = center.y * drawScale; + s.moveTo(0, 0); + s.beginPath(); + s.strokeStyle = this._color(color.color, this.m_alpha); + s.fillStyle = this._color(color.color, this.m_fillAlpha); + s.arc(cx, cy, radius * drawScale, 0, Math.PI * 2, true); + s.moveTo(cx, cy); + s.lineTo((center.x + axis.x * radius) * drawScale, (center.y + axis.y * radius) * drawScale); + s.closePath(); + s.fill(); + s.stroke(); + }; + b2DebugDraw.prototype.DrawSegment = function (p1, p2, color) { + var s = this.m_ctx, + drawScale = this.m_drawScale; + s.strokeStyle = this._color(color.color, this.m_alpha); + s.beginPath(); + s.moveTo(p1.x * drawScale, p1.y * drawScale); + s.lineTo(p2.x * drawScale, p2.y * drawScale); + s.closePath(); + s.stroke(); + }; + b2DebugDraw.prototype.DrawTransform = function (xf) { + var s = this.m_ctx, + drawScale = this.m_drawScale; + s.beginPath(); + s.strokeStyle = this._color(0xff0000, this.m_alpha); + s.moveTo(xf.position.x * drawScale, xf.position.y * drawScale); + s.lineTo((xf.position.x + this.m_xformScale * xf.R.col1.x) * drawScale, (xf.position.y + this.m_xformScale * xf.R.col1.y) * drawScale); + + s.strokeStyle = this._color(0xff00, this.m_alpha); + s.moveTo(xf.position.x * drawScale, xf.position.y * drawScale); + s.lineTo((xf.position.x + this.m_xformScale * xf.R.col2.x) * drawScale, (xf.position.y + this.m_xformScale * xf.R.col2.y) * drawScale); + s.closePath(); + s.stroke(); + }; +})(); //post-definitions +var i; +for (i = 0; i < Box2D.postDefs.length; ++i) Box2D.postDefs[i](); +delete Box2D.postDefs; + + return Box2D; +}); \ No newline at end of file diff --git a/app/Lib/Vendor/Box2D/asmBox2d.js b/app/Lib/Vendor/Box2D/asmBox2d.js new file mode 100644 index 0000000..5efb066 --- /dev/null +++ b/app/Lib/Vendor/Box2D/asmBox2d.js @@ -0,0 +1,537 @@ +function b(a){throw a;}var f=void 0,j=!0,l=null,n=!1;function aa(){return function(){}}try{this.Module=Module,Module.test}catch(ba){this.Module=Module={}}var ca="object"===typeof process&&"function"===typeof require,da="object"===typeof window,ea="function"===typeof importScripts,fa=!da&&!ca&&!ea;"object"===typeof module&&(module.Z=Module); +if(ca){Module.print=function(a){process.stdout.write(a+"\n")};Module.printErr=function(a){process.stderr.write(a+"\n")};var ga=require("fs"),ha=require("path");Module.read=function(a,c){var a=ha.normalize(a),d=ga.readFileSync(a);!d&&a!=ha.resolve(a)&&(a=path.join(__dirname,"..","src",a),d=ga.readFileSync(a));d&&!c&&(d=d.toString());return d};Module.readBinary=function(a){return Module.read(a,j)};Module.load=function(a){ia(read(a))};Module.arguments||(Module.arguments=process.argv.slice(2))} +fa&&(Module.print=print,"undefined"!=typeof printErr&&(Module.printErr=printErr),Module.read=read,Module.readBinary=function(a){return read(a,"binary")},Module.arguments||("undefined"!=typeof scriptArgs?Module.arguments=scriptArgs:"undefined"!=typeof arguments&&(Module.arguments=arguments)));da&&!ea&&(Module.print||(Module.print=function(a){console.log(a)}),Module.printErr||(Module.printErr=function(a){console.log(a)})); +if(da||ea)Module.read=function(a){var c=new XMLHttpRequest;c.open("GET",a,n);c.send(l);return c.responseText},Module.arguments||"undefined"!=typeof arguments&&(Module.arguments=arguments);ea&&(Module.print||(Module.print=aa()),Module.load=importScripts);!ea&&(!da&&!ca&&!fa)&&b("Unknown runtime environment. Where are we?");function ia(a){eval.call(l,a)}"undefined"==!Module.load&&Module.read&&(Module.load=function(a){ia(Module.read(a))});Module.print||(Module.print=aa()); +Module.printErr||(Module.printErr=Module.print);Module.arguments||(Module.arguments=[]);Module.print=Module.print;Module.i=Module.printErr;Module.preRun||(Module.preRun=[]);Module.postRun||(Module.postRun=[]);function ja(){return ka}function ma(a){ka=a}function na(a){if(1==oa)return 1;var c={"%i1":1,"%i8":1,"%i16":2,"%i32":4,"%i64":8,"%float":4,"%double":8}["%"+a];c||("*"==a.charAt(a.length-1)?c=oa:"i"==a[0]&&(a=parseInt(a.substr(1)),qa(0==a%8),c=a/8));return c} +function ra(a,c,d){d&&d.length?(d.splice||(d=Array.prototype.slice.call(d)),d.splice(0,0,c),Module["dynCall_"+a].apply(l,d)):Module["dynCall_"+a].call(l,c)}var sa=[l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l,l];function ta(a){for(var c=0;cd)return String.fromCharCode(d);a.push(d);c=191d?1:2;return""}if(0d?String.fromCharCode((d&31)<<6|e&63):String.fromCharCode((d&15)<<12|(e&63)<<6|g&63);a.length=0;return d};this.U=function(a){for(var a=unescape(encodeURIComponent(a)),c=[],g=0;g>3<<3;return c}function ya(a){var c=za;za=za+a|0;za=za+7>>3<<3;return c}function Aa(a){var c=Ba;Ba=Ba+a|0;Ba=Ba+7>>3<<3;Ba>=Ca&&Ea("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.");return c}function Fa(a,c){return Math.ceil(a/(c?c:8))*(c?c:8)}var oa=4,Ga={},Ha=n,Ia; +function Ea(a){Module.print(a+":\n"+Error().stack);Ha=j;b("Assertion: "+a)}function qa(a,c){a||Ea("Assertion failed: "+c)}var Ja=this;Module.ccall=function(a,c,d,e){return Ka(La(a),c,d,e)};function La(a){try{var c=Ja.Module["_"+a];c||(c=eval("_"+a))}catch(d){}qa(c,"Cannot call unknown function "+a+" (perhaps LLVM optimizations or closure removed it?)");return c} +function Ka(a,c,d,e){function g(a,c){if("string"==c){if(a===l||a===f||0===a)return 0;h||(h=ja());var d=xa(a.length+1);Ma(a,d);return d}return"array"==c?(h||(h=ja()),d=xa(a.length),Na(a,d),d):a}var h=0,i=0,e=e?e.map(function(a){return g(a,d[i++])}):[];a=a.apply(l,e);"string"==c?c=Oa(a):(qa("array"!=c),c=a);h&&ma(h);return c}Module.cwrap=function(a,c,d){var e=La(a);return function(){return Ka(e,c,d,Array.prototype.slice.call(arguments))}}; +function Pa(a,c,d){d=d||"i8";"*"===d.charAt(d.length-1)&&(d="i32");switch(d){case "i1":p[a]=c;break;case "i8":p[a]=c;break;case "i16":Qa[a>>1]=c;break;case "i32":q[a>>2]=c;break;case "i64":Ia=[c>>>0,(Math.min(+Math.floor(c/4294967296),4294967295)|0)>>>0];q[a>>2]=Ia[0];q[a+4>>2]=Ia[1];break;case "float":Ra[a>>2]=c;break;case "double":Sa[a>>3]=c;break;default:Ea("invalid type for setValue: "+d)}}Module.setValue=Pa; +function Ta(a,c){c=c||"i8";"*"===c.charAt(c.length-1)&&(c="i32");switch(c){case "i1":return p[a];case "i8":return p[a];case "i16":return Qa[a>>1];case "i32":return q[a>>2];case "i64":return q[a>>2];case "float":return Ra[a>>2];case "double":return Sa[a>>3];default:Ea("invalid type for setValue: "+c)}return l}Module.getValue=Ta;var Ua=1,Va=2,Wa=4;Module.ALLOC_NORMAL=0;Module.ALLOC_STACK=Ua;Module.ALLOC_STATIC=Va;Module.ALLOC_DYNAMIC=3;Module.ALLOC_NONE=Wa; +function Xa(a,c,d,e){var g,h;"number"===typeof a?(g=j,h=a):(g=n,h=a.length);var i="string"===typeof c?c:l,d=d==Wa?e:[Ya,xa,ya,Aa][d===f?Va:d](Math.max(h,i?1:c.length));if(g){e=d;qa(0==(d&3));for(a=d+(h&-4);e>2]=0;for(a=d+h;e=c?2*Math.abs(1<=a)return a;var d=32>=c?Math.abs(1<=d&&(32>=c||a>d))a=-2*d+a;return a}Math.imul||(Math.imul=function(a,c){var d=a&65535,e=c&65535;return d*e+((a>>>16)*e+d*(c>>>16)<<16)|0}); +var ob=0,pb={},qb=n,rb=l;function sb(a){ob++;Module.monitorRunDependencies&&Module.monitorRunDependencies(ob);a?(qa(!pb[a]),pb[a]=1):Module.i("warning: run dependency added without ID")}Module.addRunDependency=sb;function tb(a){ob--;Module.monitorRunDependencies&&Module.monitorRunDependencies(ob);a?(qa(pb[a]),delete pb[a]):Module.i("warning: run dependency removed without ID");0==ob&&(rb!==l&&(clearInterval(rb),rb=l),!qb&&ub&&vb())}Module.removeRunDependency=tb;Module.preloadedImages={}; +Module.preloadedAudios={};var bb=8,za=bb+23168,hb=hb.concat([]),s,t;s=Xa([0,0,0,0,152,83,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"i8",Va);t=Xa([0,0,0,0,168,83,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],"i8",Va); +Xa([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,8,1,0,0,248,0,0,0,44,0,0,0,58,0,0,0,74,0,0,0,174,0,0,0,86,1,0,0,190,1,0,0,18,1,0,0,104,2,0,0,116,0,0,0,214,0,0,0,154,0,0,0,18, +1,0,0,254,0,0,0,78,1,0,0,0,1,0,0,248,1,0,0,130,0,0,0,160,0,0,0,90,0,0,0,212,0,0,0,244,1,0,0,220,1,0,0,44,0,0,0,120,0,0,0,250,1,0,0,160,0,0,0,60,0,0,0,120,0,0,0,50,0,0,0,72,1,0,0,156,0,0,0,178,0,0,0,210,1,0,0,84,1,0,0,174,0,0,0,68,0,0,0,56,0,0,0,52,2,0,0,170,0,0,0,118,1,0,0,166,0,0,0,84,0,0,0,208,0,0,0,42,0,0,0,130,1,0,0,82,0,0,0,96,0,0,0,222,1,0,0,188,0,0,0,142,1,0,0,16,1,0,0,44,0,0,0,52,0,0,0,246,0,0,0,124,0,0,0,42,0,0,0,202,0,0,0,60,0,0,0,102,0,0,0,22,1,0,0,34,1,0,0,216,0,0,0,198,0,0,0,152,0,0, +0,68,0,0,0,114,1,0,0,88,0,0,0,62,0,0,0,6,2,0,0,38,2,0,0,190,0,0,0,240,0,0,0,132,0,0,0,96,1,0,0,152,0,0,0,52,0,0,0,64,0,0,0,108,1,0,0,218,0,0,0,138,0,0,0,150,1,0,0,46,0,0,0,78,0,0,0,54,0,0,0,202,0,0,0,56,1,0,0,28,1,0,0,66,1,0,0,250,0,0,0,28,2,0,0,60,0,0,0,248,0,0,0,88,1,0,0,0,1,0,0,66,2,0,0,222,0,0,0,72,2,0,0,2,1,0,0,168,0,0,0,116,0,0,0,56,0,0,0,56,0,0,0,80,2,0,0,70,0,0,0,190,0,0,0,148,0,0,0,74,0,0,0,42,0,0,0,72,0,0,0,62,2,0,0,76,0,0,0,162,1,0,0,178,1,0,0,50,0,0,0,70,0,0,0,46,0,0,0,50,0,0,0,126,1, +0,0,60,0,0,0,166,0,0,0,198,0,0,0,188,1,0,0,60,1,0,0,56,2,0,0,40,2,0,0,170,1,0,0,136,1,0,0,222,0,0,0,94,1,0,0,64,0,0,0,212,0,0,0,120,1,0,0,106,1,0,0,98,2,0,0,136,0,0,0,68,0,0,0,88,1,0,0,146,0,0,0,106,2,0,0,62,0,0,0,42,0,0,0,148,0,0,0,88,0,0,0,208,0,0,0,164,0,0,0,86,0,0,0,130,0,0,0,108,0,0,0,92,0,0,0,166,0,0,0,72,0,0,0,238,0,0,0,14,1,0,0,84,0,0,0,96,0,0,0,58,1,0,0,148,1,0,0,210,1,0,0,170,1,0,0,94,0,0,0,118,0,0,0,62,1,0,0,54,1,0,0,82,0,0,0,200,1,0,0,74,0,0,0,242,1,0,0,128,1,0,0,120,0,0,0,134,0,0,0,224, +0,0,0,50,0,0,0,46,0,0,0,38,1,0,0,46,1,0,0,46,0,0,0,240,0,0,0,20,1,0,0,208,0,0,0,118,0,0,0,46,0,0,0,254,0,0,0,54,1,0,0,42,0,0,0,72,0,0,0,50,0,0,0,64,1,0,0,44,0,0,0,42,0,0,0,214,0,0,0,142,1,0,0,164,1,0,0,2,1,0,0,214,0,0,0,62,0,0,0,140,0,0,0,174,0,0,0,138,0,0,0,116,0,0,0,76,0,0,0,46,0,0,0,76,0,0,0,216,1,0,0,100,2,0,0,56,0,0,0,72,0,0,0,100,0,0,0,168,1,0,0,2,2,0,0,80,0,0,0,144,1,0,0,174,0,0,0,78,1,0,0,194,1,0,0,72,0,0,0,16,1,0,0,80,1,0,0,246,0,0,0,42,0,0,0,152,1,0,0,196,0,0,0,32,2,0,0,106,0,0,0,56,0,0, +0,208,1,0,0,246,1,0,0,228,0,0,0,112,0,0,0,42,0,0,0,78,0,0,0,52,0,0,0,0,2,0,0,84,0,0,0,158,0,0,0,198,0,0,0,60,1,0,0,238,0,0,0,94,2,0,0,72,0,0,0,134,0,0,0,222,0,0,0,232,0,0,0,116,0,0,0,196,1,0,0,76,1,0,0,46,0,0,0,44,0,0,0,48,0,0,0,42,0,0,0,204,0,0,0,94,0,0,0,66,0,0,0,218,0,0,0,186,0,0,0,146,0,0,0,112,1,0,0,86,0,0,0,206,1,0,0,212,1,0,0,230,0,0,0,188,0,0,0,94,1,0,0,38,1,0,0,168,1,0,0,44,0,0,0,54,0,0,0,248,0,0,0,78,2,0,0,238,1,0,0,14,2,0,0,82,0,0,0,118,0,0,0,126,0,0,0,210,0,0,0,200,0,0,0,14,1,0,0,90,2, +0,0,118,1,0,0,56,1,0,0,126,0,0,0,62,0,0,0,254,1,0,0,20,2,0,0,216,0,0,0,244,0,0,0,42,0,0,0,46,0,0,0,82,0,0,0,150,0,0,0,58,0,0,0,110,0,0,0,70,0,0,0,30,1,0,0,186,1,0,0,182,0,0,0,88,0,0,0,42,0,0,0,44,0,0,0,52,0,0,0,54,0,0,0,134,1,0,0,166,1,0,0,204,0,0,0,42,1,0,0,78,0,0,0,110,0,0,0,162,0,0,0,202,1,0,0,64,0,0,0,236,0,0,0,46,0,0,0,158,0,0,0,54,0,0,0,218,0,0,0,124,1,0,0,100,0,0,0,142,0,0,0,58,1,0,0,110,1,0,0,168,0,0,0,74,0,0,0,160,0,0,0,160,1,0,0,230,1,0,0,232,1,0,0,164,0,0,0,188,0,0,0,138,1,0,0,238,0,0, +0,52,0,0,0,138,0,0,0,104,1,0,0,108,0,0,0,242,0,0,0,70,0,0,0,180,0,0,0,44,0,0,0,90,1,0,0,72,1,0,0,48,0,0,0,206,0,0,0,140,1,0,0,60,0,0,0,172,1,0,0,226,0,0,0,90,0,0,0,216,0,0,0,44,0,0,0,44,0,0,0,154,1,0,0,76,0,0,0,206,0,0,0,214,1,0,0,220,0,0,0,88,0,0,0,186,0,0,0,142,0,0,0,192,0,0,0,122,0,0,0,106,0,0,0,226,0,0,0,98,1,0,0,42,0,0,0,44,0,0,0,196,0,0,0,252,1,0,0,50,0,0,0,186,0,0,0,122,0,0,0,86,1,0,0,66,0,0,0,150,0,0,0,198,1,0,0,62,0,0,0,48,0,0,0,66,0,0,0,56,0,0,0,92,2,0,0,60,0,0,0,116,1,0,0,46,0,0,0,110, +1,0,0,186,0,0,0,28,1,0,0,184,0,0,0,188,0,0,0,80,0,0,0,50,0,0,0,164,0,0,0,54,0,0,0,186,0,0,0,54,0,0,0,236,1,0,0,22,1,0,0,234,0,0,0,46,0,0,0,196,0,0,0,232,0,0,0,176,1,0,0,12,1,0,0,210,0,0,0,4,1,0,0,122,0,0,0,212,0,0,0,184,0,0,0,84,0,0,0,140,1,0,0,224,0,0,0,50,0,0,0,226,0,0,0,242,0,0,0,50,1,0,0,44,0,0,0,56,0,0,0,70,0,0,0,100,0,0,0,66,0,0,0,92,0,0,0,84,0,0,0,58,0,0,0,46,0,0,0,42,0,0,0,92,0,0,0,64,0,0,0,134,1,0,0,10,1,0,0,184,0,0,0,48,0,0,0,52,1,0,0,94,0,0,0,164,0,0,0,36,1,0,0,162,0,0,0,66,0,0,0,48,0, +0,0,106,0,0,0,54,0,0,0,176,0,0,0,108,2,0,0,44,0,0,0,68,0,0,0,82,1,0,0,44,0,0,0,100,0,0,0,98,1,0,0,98,0,0,0,152,0,0,0,154,0,0,0,206,0,0,0,188,0,0,0,44,1,0,0,122,1,0,0,172,1,0,0,74,0,0,0,132,1,0,0,206,0,0,0,138,0,0,0,72,0,0,0,86,0,0,0,156,0,0,0,144,0,0,0,158,0,0,0,58,0,0,0,132,0,0,0,124,0,0,0,252,0,0,0,48,0,0,0,100,0,0,0,88,2,0,0,62,0,0,0,136,0,0,0,74,2,0,0,96,0,0,0,54,0,0,0,124,0,0,0,122,0,0,0,182,1,0,0,94,0,0,0,24,2,0,0,68,0,0,0,68,0,0,0,188,1,0,0,192,0,0,0,254,0,0,0,60,2,0,0,186,1,0,0,64,0,0,0,76, +0,0,0,152,0,0,0,218,0,0,0,156,0,0,0,16,1,0,0,44,1,0,0,80,0,0,0,36,2,0,0,198,0,0,0,160,0,0,0,42,0,0,0,142,0,0,0,240,1,0,0,10,2,0,0,116,0,0,0,72,0,0,0,144,0,0,0,192,1,0,0,172,0,0,0,146,0,0,0,92,1,0,0,166,0,0,0,82,1,0,0,48,0,0,0,16,2,0,0,244,0,0,0,98,0,0,0,190,0,0,0,92,0,0,0,240,0,0,0,234,1,0,0,56,0,0,0,122,0,0,0,118,0,0,0,64,2,0,0,48,1,0,0,172,0,0,0,218,1,0,0,102,0,0,0,130,0,0,0,204,0,0,0,64,0,0,0,26,1,0,0,74,1,0,0,54,2,0,0,106,0,0,0,76,2,0,0,92,0,0,0,178,0,0,0,18,2,0,0,18,1,0,0,42,2,0,0,92,1,0,0,48, +1,0,0,58,0,0,0,228,0,0,0,86,2,0,0,202,0,0,0,148,0,0,0,124,0,0,0,192,0,0,0,52,0,0,0,120,0,0,0,176,0,0,0,70,0,0,0,154,0,0,0,78,0,0,0,246,0,0,0,50,0,0,0,84,1,0,0,44,2,0,0,138,0,0,0,98,0,0,0,42,0,0,0,96,2,0,0,36,1,0,0,94,0,0,0,108,0,0,0,158,1,0,0,64,1,0,0,52,1,0,0,132,0,0,0,166,0,0,0,62,0,0,0,40,1,0,0,84,0,0,0,74,1,0,0,112,0,0,0,198,0,0,0,206,0,0,0,96,0,0,0,68,0,0,0,70,0,0,0,4,2,0,0,68,1,0,0,114,0,0,0,2,1,0,0,102,0,0,0,74,0,0,0,100,0,0,0,48,2,0,0,202,0,0,0,234,0,0,0,108,0,0,0,250,0,0,0,136,0,0,0,154, +1,0,0,104,0,0,0,10,1,0,0,102,1,0,0,104,0,0,0,74,0,0,0,200,1,0,0,236,0,0,0,200,0,0,0,252,0,0,0,226,0,0,0,78,0,0,0,28,1,0,0,144,0,0,0,46,1,0,0,50,1,0,0,128,0,0,0,164,0,0,0,102,0,0,0,42,0,0,0,48,0,0,0,236,0,0,0,52,0,0,0,128,0,0,0,194,0,0,0,76,0,0,0,178,0,0,0,52,0,0,0,170,0,0,0,146,0,0,0,214,0,0,0,58,0,0,0,132,0,0,0,90,0,0,0,156,0,0,0,42,0,0,0,110,0,0,0,218,1,0,0,204,0,0,0,112,0,0,0,44,0,0,0,66,0,0,0,102,2,0,0,98,0,0,0,64,0,0,0,92,0,0,0,96,0,0,0,200,0,0,0,42,0,0,0,78,0,0,0,50,2,0,0,170,0,0,0,194,0,0, +0,170,0,0,0,216,1,0,0,70,1,0,0,68,1,0,0,46,2,0,0,14,1,0,0,138,1,0,0,180,0,0,0,140,0,0,0,60,0,0,0,82,0,0,0,94,0,0,0,112,0,0,0,72,0,0,0,172,0,0,0,144,0,0,0,180,0,0,0,182,1,0,0,244,0,0,0,68,1,0,0,120,0,0,0,220,0,0,0,112,0,0,0,186,0,0,0,214,1,0,0,48,0,0,0,136,1,0,0,242,0,0,0,10,1,0,0,70,0,0,0,50,0,0,0,60,0,0,0,234,0,0,0,22,2,0,0,172,0,0,0,178,0,0,0,110,2,0,0,60,0,0,0,134,0,0,0,178,0,0,0,118,0,0,0,76,0,0,0,92,0,0,0,90,0,0,0,178,0,0,0,156,1,0,0,88,0,0,0,160,1,0,0,62,1,0,0,112,0,0,0,168,0,0,0,174,1,0,0, +6,1,0,0,64,0,0,0,106,0,0,0,50,0,0,0,42,0,0,0,184,0,0,0,6,1,0,0,62,1,0,0,114,0,0,0,116,0,0,0,46,0,0,0,124,0,0,0,204,1,0,0,220,0,0,0,196,0,0,0,42,0,0,0,96,0,0,0,134,0,0,0,192,0,0,0,146,0,0,0,102,1,0,0,104,0,0,0,26,1,0,0,154,0,0,0,182,0,0,0,150,0,0,0,72,0,0,0,54,0,0,0,230,0,0,0,58,0,0,0,86,1,0,0,250,0,0,0,232,0,0,0,34,1,0,0,108,0,0,0,226,1,0,0,142,0,0,0,248,0,0,0,162,1,0,0,176,0,0,0,182,0,0,0,212,0,0,0,56,0,0,0,66,0,0,0,104,0,0,0,98,0,0,0,142,0,0,0,86,0,0,0,102,0,0,0,110,0,0,0,58,0,0,0,66,0,0,0,62,0, +0,0,102,0,0,0,60,0,0,0,118,0,0,0,202,1,0,0,100,1,0,0,42,0,0,0,20,1,0,0,98,0,0,0,190,0,0,0,42,1,0,0,30,2,0,0,58,2,0,0,128,0,0,0,178,1,0,0,42,0,0,0,246,0,0,0,66,1,0,0,196,0,0,0,8,2,0,0,50,0,0,0,70,0,0,0,162,0,0,0,90,0,0,0,106,0,0,0,140,0,0,0,156,0,0,0,172,0,0,0,82,0,0,0,146,1,0,0,182,0,0,0,94,0,0,0,68,0,0,0,154,0,0,0,196,1,0,0,252,0,0,0,116,1,0,0,48,0,0,0,194,1,0,0,114,0,0,0,150,0,0,0,12,1,0,0,44,0,0,0,208,1,0,0,210,0,0,0,12,2,0,0,82,2,0,0,56,0,0,0,46,0,0,0,240,0,0,0,242,0,0,0,44,0,0,0,62,0,0,0,172, +0,0,0,90,0,0,0,42,0,0,0,150,0,0,0,162,0,0,0,210,0,0,0,170,0,0,0,176,0,0,0,68,0,0,0,32,1,0,0,190,1,0,0,188,0,0,0,180,1,0,0,70,1,0,0,156,1,0,0,204,0,0,0,24,1,0,0,52,0,0,0,70,0,0,0,74,1,0,0,176,0,0,0,100,0,0,0,86,0,0,0,48,0,0,0,90,0,0,0,194,0,0,0,220,1,0,0,192,1,0,0,42,1,0,0,208,0,0,0,184,1,0,0,86,0,0,0,126,1,0,0,56,0,0,0,230,0,0,0,202,0,0,0,158,0,0,0,78,0,0,0,194,0,0,0,64,0,0,0,196,0,0,0,180,0,0,0,154,0,0,0,122,1,0,0,90,1,0,0,86,0,0,0,126,0,0,0,60,1,0,0,126,0,0,0,62,0,0,0,92,0,0,0,132,0,0,0,24,1,0, +0,204,1,0,0,114,0,0,0,58,0,0,0,96,1,0,0,58,0,0,0,66,0,0,0,176,1,0,0,148,0,0,0,180,0,0,0,76,0,0,0,124,0,0,0,24,1,0,0,138,0,0,0,26,2,0,0,182,0,0,0,80,0,0,0,108,0,0,0,72,1,0,0,174,1,0,0,130,0,0,0,44,0,0,0,44,0,0,0,60,0,0,0,164,0,0,0,114,0,0,0,84,2,0,0,146,1,0,0,104,1,0,0,148,1,0,0,146,0,0,0,158,0,0,0,34,2,0,0,132,0,0,0,116,0,0,0,100,0,0,0,166,1,0,0,78,1,0,0,128,1,0,0,168,0,0,0,32,1,0,0,152,1,0,0,228,1,0,0,136,0,0,0,86,0,0,0,110,0,0,0,224,1,0,0,110,0,0,0,144,0,0,0,128,0,0,0,104,0,0,0,30,1,0,0,232,0,0, +0,244,0,0,0,158,1,0,0,200,0,0,0,136,0,0,0,80,0,0,0,134,0,0,0,98,0,0,0,176,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,184,76,0,0,0,0,0,0,0,78,0,0,0,0,0,0,0,0,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,67,111,117,110,116,32,62,32,48,0,0,0,0,0,0,32,32,106,100,46,109,97,120,77,111,116,111,114,84,111,114,113,117,101,32,61,32,37,46,49,53,108,101,102,59,10,0,32,32,106,100,46,101,110,97,98,108,101,76,105, +109,105,116,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,0,32,32,106,100,46,106,111,105,110,116,50,32,61,32,106,111,105,110,116,115,91,37,100,93,59,10,0,0,0,0,0,0,32,32,106,100,46,109,97,120,70,111,114,99,101,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,0,98,50,86,101,99,50,32,103,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,32,32,32,32,102,100,46,102,105,108,116,101,114,46,109,97,115,107,66,105,116,115,32,61,32,117,105,110,116,49,54,40,37,100,41,59,10,0,0,0,48, +32,60,61,32,105,66,32,38,38,32,105,66,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,102,105,120,116,117,114,101,45,62,109,95,98,111,100,121,32,61,61,32,116,104,105,115,0,32,32,106,100,46,109,111,116,111,114,83,112,101,101,100,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,32,32,106,100,46,103,114,111,117,110,100,65,110,99,104,111,114,66,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,0,32,32,106,100,46,106,111,105,110,116,49,32,61,32,106, +111,105,110,116,115,91,37,100,93,59,10,0,0,0,0,0,0,118,101,114,116,101,120,67,111,117,110,116,32,60,61,32,56,0,0,0,0,0,0,0,0,32,32,32,32,102,100,46,102,105,108,116,101,114,46,99,97,116,101,103,111,114,121,66,105,116,115,32,61,32,117,105,110,116,49,54,40,37,100,41,59,10,0,0,0,0,0,0,0,105,65,32,33,61,32,40,45,49,41,0,0,0,0,0,0,109,95,119,111,114,108,100,45,62,73,115,76,111,99,107,101,100,40,41,32,61,61,32,102,97,108,115,101,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121, +110,97,109,105,99,115,47,98,50,66,111,100,121,46,99,112,112,0,0,32,32,106,100,46,101,110,97,98,108,101,77,111,116,111,114,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,0,32,32,106,100,46,103,114,111,117,110,100,65,110,99,104,111,114,65,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,67,111,109,109,111,110,47,98,50,83,116,97,99,107,65,108,108,111,99,97,116,111,114,46,99,112,112,0,0,97,108,112, +104,97,48,32,60,32,49,46,48,102,0,0,0,32,32,32,32,102,100,46,105,115,83,101,110,115,111,114,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,0,0,99,104,105,108,100,50,32,33,61,32,40,45,49,41,0,0,98,50,73,115,86,97,108,105,100,40,98,100,45,62,108,105,110,101,97,114,68,97,109,112,105,110,103,41,32,38,38,32,98,100,45,62,108,105,110,101,97,114,68,97,109,112,105,110,103,32,62,61,32,48,46,48,102,0,0,0,0,0,0,0,99,111,117,110,116,32,62,61,32,51,0,0,0,0,0,0,32,32,106,100,46,108,111,99,97,108,65,120,105,115, +65,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,32,32,106,100,46,114,101,102,101,114,101,110,99,101,65,110,103,108,101,32,61,32,37,46,49,53,108,101,102,59,10,0,32,32,106,100,46,109,97,120,76,101,110,103,116,104,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,77,111,117,115,101,32,106,111,105,110,116,32,100,117,109,112,105,110,103,32,105,115,32,110,111,116,32,115,117,112,112,111,114,116,101,100,46,10,0,0,32,32,106,100,46,108,101,110,103,116,104,32,61,32,37,46, +49,53,108,101,102,59,10,0,99,104,105,108,100,49,32,33,61,32,40,45,49,41,0,0,116,121,112,101,65,32,61,61,32,98,50,95,100,121,110,97,109,105,99,66,111,100,121,32,124,124,32,116,121,112,101,66,32,61,61,32,98,50,95,100,121,110,97,109,105,99,66,111,100,121,0,0,0,0,0,0,32,32,32,32,102,100,46,100,101,110,115,105,116,121,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,105,115,116,97,110,99,101, +46,99,112,112,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,67,111,109,109,111,110,47,98,50,66,108,111,99,107,65,108,108,111,99,97,116,111,114,46,99,112,112,0,0,98,50,73,115,86,97,108,105,100,40,98,100,45,62,97,110,103,117,108,97,114,68,97,109,112,105,110,103,41,32,38,38,32,98,100,45,62,97,110,103,117,108,97,114,68,97,109,112,105,110,103,32,62,61,32,48,46,48,102,0,0,0,0,0,112,32,61,61,32,101,110,116,114,121,45,62,100,97,116,97,0,0,0,0,0,0,0,0,97,114,101,97,32,62,32,49,46, +49,57,50,48,57,50,57,48,69,45,48,55,70,0,0,99,104,105,108,100,73,110,100,101,120,32,60,32,109,95,99,111,117,110,116,0,0,0,0,32,32,106,100,46,108,111,99,97,108,65,110,99,104,111,114,66,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,0,0,48,32,60,32,99,111,117,110,116,32,38,38,32,99,111,117,110,116,32,60,32,51,0,0,100,32,43,32,104,32,42,32,107,32,62,32,49,46,49,57,50,48,57,50,57,48,69,45,48,55,70,0,0,0,0,0,112,99,45,62,112,111,105,110,116,67,111,117,110,116, +32,62,32,48,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,83,104,97,112,101,115,47,98,50,80,111,108,121,103,111,110,83,104,97,112,101,46,99,112,112,0,0,109,95,110,111,100,101,115,91,112,114,111,120,121,73,100,93,46,73,115,76,101,97,102,40,41,0,0,0,0,0,0,0,115,116,97,99,107,67,111,117,110,116,32,60,32,115,116,97,99,107,83,105,122,101,0,0,32,32,32,32,102,100,46,114,101,115,116,105,116,117,116,105,111,110,32,61,32,37,46,49,53,108,101, +102,59,10,0,0,99,97,99,104,101,45,62,99,111,117,110,116,32,60,61,32,51,0,0,0,0,0,0,0,98,50,73,115,86,97,108,105,100,40,98,100,45,62,97,110,103,117,108,97,114,86,101,108,111,99,105,116,121,41,0,0,109,95,101,110,116,114,121,67,111,117,110,116,32,62,32,48,0,0,0,0,0,0,0,0,98,108,111,99,107,67,111,117,110,116,32,42,32,98,108,111,99,107,83,105,122,101,32,60,61,32,98,50,95,99,104,117,110,107,83,105,122,101,0,0,109,95,118,101,114,116,101,120,67,111,117,110,116,32,62,61,32,51,0,0,0,0,0,0,48,32,60,61,32,105, +110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,109,95,99,111,117,110,116,32,45,32,49,0,0,0,0,0,0,0,32,32,106,100,46,108,111,99,97,108,65,110,99,104,111,114,65,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,0,0,98,50,73,115,86,97,108,105,100,40,100,101,102,45,62,100,97,109,112,105,110,103,82,97,116,105,111,41,32,38,38,32,100,101,102,45,62,100,97,109,112,105,110,103,82,97,116,105,111,32,62,61,32,48,46,48,102,0,0,0,0,0,0,0,32,32,98,50,71,101,97,114, +74,111,105,110,116,68,101,102,32,106,100,59,10,0,0,0,97,46,120,32,62,61,32,48,46,48,102,32,38,38,32,97,46,121,32,62,61,32,48,46,48,102,0,0,0,0,0,0,48,32,60,61,32,116,121,112,101,65,32,38,38,32,116,121,112,101,66,32,60,32,98,50,83,104,97,112,101,58,58,101,95,116,121,112,101,67,111,117,110,116,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,83,104,97,112,101,115,47,98,50,67,104,97,105,110,83,104,97,112,101,46,99,112,112,0,0,0,0,98,45,62, +73,115,65,99,116,105,118,101,40,41,32,61,61,32,116,114,117,101,0,0,0,32,32,98,50,87,104,101,101,108,74,111,105,110,116,68,101,102,32,106,100,59,10,0,0,32,32,32,32,102,100,46,102,114,105,99,116,105,111,110,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,32,32,98,50,87,101,108,100,74,111,105,110,116,68,101,102,32,106,100,59,10,0,0,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,109,95,99,111,117,110,116,0,0,0,32,32,98,50,82,111,112,101,74,111,105,110,116,68,101,102,32, +106,100,59,10,0,0,0,98,50,73,115,86,97,108,105,100,40,98,100,45,62,97,110,103,108,101,41,0,0,0,0,109,95,101,110,116,114,121,67,111,117,110,116,32,60,32,98,50,95,109,97,120,83,116,97,99,107,69,110,116,114,105,101,115,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,74,111,105,110,116,115,47,98,50,82,101,118,111,108,117,116,101,74,111,105,110,116,46,99,112,112,0,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,98, +50,95,98,108,111,99,107,83,105,122,101,115,0,0,0,0,0,48,46,48,102,32,60,61,32,108,111,119,101,114,32,38,38,32,108,111,119,101,114,32,60,61,32,105,110,112,117,116,46,109,97,120,70,114,97,99,116,105,111,110,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,74,111,105,110,116,115,47,98,50,80,117,108,108,101,121,74,111,105,110,116,46,99,112,112,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110, +47,98,50,84,105,109,101,79,102,73,109,112,97,99,116,46,99,112,112,0,99,111,117,110,116,32,62,61,32,50,0,0,0,0,0,0,115,116,100,58,58,98,97,100,95,97,108,108,111,99,0,0,32,32,106,100,46,99,111,108,108,105,100,101,67,111,110,110,101,99,116,101,100,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,0,0,0,0,32,32,98,50,80,117,108,108,101,121,74,111,105,110,116,68,101,102,32,106,100,59,10,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,74,111,105,110,116,115, +47,98,50,80,114,105,115,109,97,116,105,99,74,111,105,110,116,46,99,112,112,0,98,50,73,115,86,97,108,105,100,40,100,101,102,45,62,102,114,101,113,117,101,110,99,121,72,122,41,32,38,38,32,100,101,102,45,62,102,114,101,113,117,101,110,99,121,72,122,32,62,61,32,48,46,48,102,0,47,47,32,68,117,109,112,32,105,115,32,110,111,116,32,115,117,112,112,111,114,116,101,100,32,102,111,114,32,116,104,105,115,32,106,111,105,110,116,32,116,121,112,101,46,10,0,0,98,50,73,115,86,97,108,105,100,40,114,97,116,105,111, +41,0,0,0,0,0,0,0,0,32,32,32,32,98,111,100,105,101,115,91,37,100,93,45,62,67,114,101,97,116,101,70,105,120,116,117,114,101,40,38,102,100,41,59,10,0,0,0,0,32,32,98,50,70,114,105,99,116,105,111,110,74,111,105,110,116,68,101,102,32,106,100,59,10,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,74,111,105,110,116,115,47,98,50,77,111,117,115,101,74,111,105,110,116,46,99,112,112,0,0,0,0,0,112,111,105,110,116,67,111,117,110,116,32,61,61,32,49,32, +124,124,32,112,111,105,110,116,67,111,117,110,116,32,61,61,32,50,0,0,0,0,0,0,115,95,105,110,105,116,105,97,108,105,122,101,100,32,61,61,32,116,114,117,101,0,0,0,32,32,32,32,102,100,46,115,104,97,112,101,32,61,32,38,115,104,97,112,101,59,10,0,109,95,106,111,105,110,116,67,111,117,110,116,32,62,32,48,0,0,0,0,0,0,0,0,48,32,60,32,109,95,110,111,100,101,67,111,117,110,116,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,74,111,105,110,116,115,47,98,50,74, +111,105,110,116,46,99,112,112,0,0,32,32,32,32,98,50,70,105,120,116,117,114,101,68,101,102,32,102,100,59,10,0,0,0,10,0,0,0,0,0,0,0,32,32,125,10,0,0,0,0,110,111,100,101,45,62,73,115,76,101,97,102,40,41,32,61,61,32,102,97,108,115,101,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,74,111,105,110,116,115,47,98,50,71,101,97,114,74,111,105,110,116,46,99,112,112,0,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,104,97,115,78,101,120,116,86,101,114,116,101, +120,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,32,32,123,10,0,0,0,0,109,95,110,111,100,101,67,111,117,110,116,32,43,32,102,114,101,101,67,111,117,110,116,32,61,61,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,105,115,116,97,110,99,101,46,104,0,0,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,104,97,115,80,114,101,118,86,101,114,116,101,120,32,61,32,98,111,111, +108,40,37,100,41,59,10,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,74,111,105,110,116,115,47,98,50,70,114,105,99,116,105,111,110,74,111,105,110,116,46,99,112,112,0,0,71,101,116,72,101,105,103,104,116,40,41,32,61,61,32,67,111,109,112,117,116,101,72,101,105,103,104,116,40,41,0,0,48,32,60,61,32,102,114,101,101,73,110,100,101,120,32,38,38,32,102,114,101,101,73,110,100,101,120,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,0,0,109, +95,98,111,100,121,67,111,117,110,116,32,60,32,109,95,98,111,100,121,67,97,112,97,99,105,116,121,0,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,110,101,120,116,86,101,114,116,101,120,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,32,32,98,111,100,105,101,115,91,37,100,93,32,61,32,109,95,119,111,114,108,100,45,62,67,114,101,97,116,101,66,111,100,121,40,38,98,100,41,59,10,0,0,0,0,0,0,0,32,32,98,50,68,105,115,116,97,110,99,101,74,111,105,110,116,68,101,102,32,106, +100,59,10,0,0,0,0,0,0,0,98,100,45,62,108,105,110,101,97,114,86,101,108,111,99,105,116,121,46,73,115,86,97,108,105,100,40,41,0,0,0,0,109,95,101,110,116,114,121,67,111,117,110,116,32,61,61,32,48,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,80,111,108,121,103,111,110,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,0,109,95,99,111,110,116,97,99,116,67,111,117,110,116,32,60,32,109,95,99,111,110,116, +97,99,116,67,97,112,97,99,105,116,121,0,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,112,114,101,118,86,101,114,116,101,120,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,32,32,98,100,46,103,114,97,118,105,116,121,83,99,97,108,101,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,97,97,98,98,46,117,112,112,101,114,66,111,117,110,100,32,61,61,32,110,111,100,101,45,62,97,97,98,98,46,117,112,112,101,114,66,111,117,110,100,0,0,0,0,0,0,0,0,66,111,120,50,68,95,118, +50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,80,111,108,121,103,111,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,109,95,106,111,105,110,116,67,111,117,110,116,32,60,32,109,95,106,111,105,110,116,67,97,112,97,99,105,116,121,0,0,32,32,32,32,115,104,97,112,101,46,67,114,101,97,116,101,67,104,97,105,110,40,118,115,44,32,37,100,41,59,10,0,32,32,98,100,46,97,99,116,105,118,101,32,61,32,98,111,111,108, +40,37,100,41,59,10,0,0,0,0,0,0,0,0,48,32,60,32,115,105,122,101,0,0,0,0,0,0,0,0,97,97,98,98,46,108,111,119,101,114,66,111,117,110,100,32,61,61,32,110,111,100,101,45,62,97,97,98,98,46,108,111,119,101,114,66,111,117,110,100,0,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,69,100,103,101,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,0,0,101,100,103,101,46,76,101, +110,103,116,104,83,113,117,97,114,101,100,40,41,32,62,32,49,46,49,57,50,48,57,50,57,48,69,45,48,55,70,32,42,32,49,46,49,57,50,48,57,50,57,48,69,45,48,55,70,0,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,73,115,108,97,110,100,46,104,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,69,100,103,101,65,110,100,67,105,114,99,108,101,67,111,110,116,97, +99,116,46,99,112,112,0,32,32,32,32,98,50,67,104,97,105,110,83,104,97,112,101,32,115,104,97,112,101,59,10,0,0,0,0,0,0,0,0,32,32,98,100,46,98,117,108,108,101,116,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,0,0,0,0,0,0,110,111,100,101,45,62,104,101,105,103,104,116,32,61,61,32,104,101,105,103,104,116,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,67,111,109,109,111,110,47,98,50,77,97,116,104,46,104,0,0,0,0,0,0,32,32,106,100,46,98,111,100,121,66,32,61,32,98,111,100,105,101,115,91, +37,100,93,59,10,0,0,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,83,101,116,40,118,115,44,32,37,100,41,59,10,0,32,32,98,100,46,102,105,120,101,100,82,111,116,97,116,105,111,110,32,61,32,98,111,111,108,40,37,100,41,59,10,0,109,95,110,111,100,101,115,91,99,104,105,108,100,50,93,46,112,97,114,101,110,116,32,61,61,32,105,110,100,101,120,0,32,32,98,50,82,101,118,111,108,117,116,101,74,111,105,110,116,68,101,102,32,106,100,59,10,0,0,0,0,0,0,0,100,101,102,45,62,114,97,116,105,111,32,33,61,32,48,46,48,102, +0,0,0,0,0,0,32,32,98,50,80,114,105,115,109,97,116,105,99,74,111,105,110,116,68,101,102,32,106,100,59,10,0,0,0,0,0,0,98,50,73,115,86,97,108,105,100,40,100,101,102,45,62,109,97,120,70,111,114,99,101,41,32,38,38,32,100,101,102,45,62,109,97,120,70,111,114,99,101,32,62,61,32,48,46,48,102,0,0,0,0,0,0,0,100,101,102,45,62,98,111,100,121,65,32,33,61,32,100,101,102,45,62,98,111,100,121,66,0,0,0,0,0,0,0,0,32,32,32,32,118,115,91,37,100,93,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102, +41,59,10,0,0,0,0,0,0,32,32,98,100,46,97,119,97,107,101,32,61,32,98,111,111,108,40,37,100,41,59,10,0,109,95,116,121,112,101,66,32,61,61,32,101,95,114,101,118,111,108,117,116,101,74,111,105,110,116,32,124,124,32,109,95,116,121,112,101,66,32,61,61,32,101,95,112,114,105,115,109,97,116,105,99,74,111,105,110,116,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,111,110,116,97,99,116,83,111,108,118,101,114, +46,99,112,112,0,0,0,0,0,0,0,0,109,95,110,111,100,101,115,91,99,104,105,108,100,49,93,46,112,97,114,101,110,116,32,61,61,32,105,110,100,101,120,0,98,50,73,115,86,97,108,105,100,40,116,111,114,113,117,101,41,32,38,38,32,116,111,114,113,117,101,32,62,61,32,48,46,48,102,0,0,0,0,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,112,111,108,121,103,111,110,0,0,0,0,0,109,95,102,105,120,116,117,114,101,66,45,62,71,101,116,84,121, +112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,105,114,99,108,101,0,0,0,0,0,0,109,97,110,105,102,111,108,100,45,62,112,111,105,110,116,67,111,117,110,116,32,62,32,48,0,0,0,0,0,0,0,0,48,32,60,61,32,116,121,112,101,50,32,38,38,32,116,121,112,101,50,32,60,32,98,50,83,104,97,112,101,58,58,101,95,116,121,112,101,67,111,117,110,116,0,0,0,0,0,0,32,32,32,32,98,50,86,101,99,50,32,118,115,91,37,100,93,59,10,0,0,0,0,0,32,32,98,100,46,97,108,108,111,119,83,108,101,101,112,32,61,32,98,111,111, +108,40,37,100,41,59,10,0,0,0,0,48,32,60,61,32,99,104,105,108,100,50,32,38,38,32,99,104,105,108,100,50,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,32,32,98,100,46,97,110,103,117,108,97,114,68,97,109,112,105,110,103,32,61,32,37,46,49,53,108,101,102,59,10,0,109,95,98,111,100,121,67,111,117,110,116,32,62,32,48,0,116,111,105,73,110,100,101,120,66,32,60,32,109,95,98,111,100,121,67,111,117,110,116,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99, +115,47,67,111,110,116,97,99,116,115,47,98,50,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,48,32,60,61,32,110,111,100,101,73,100,32,38,38,32,110,111,100,101,73,100,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,105,114,99,108,101,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,0,0,32,32,32,32,98,50,80,111,108,121,103,111,110,83,104,97,112, +101,32,115,104,97,112,101,59,10,0,0,0,0,0,0,48,32,60,61,32,112,114,111,120,121,73,100,32,38,38,32,112,114,111,120,121,73,100,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,104,97,105,110,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,0,48,32,60,61,32,99,104,105,108,100,49,32,38,38,32,99,104,105, +108,100,49,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,32,32,98,100,46,108,105,110,101,97,114,68,97,109,112,105,110,103,32,61,32,37,46,49,53,108,101,102,59,10,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,67,111,110,116,97,99,116,115,47,98,50,67,104,97,105,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,46,99,112,112,0,0,0,0,0,0,0,0,114,46,76,101,110,103,116,104,83,113,117,97,114,101,100,40,41,32,62,32,48,46,48, +102,0,0,0,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,104,97,115,86,101,114,116,101,120,51,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,0,0,0,110,111,100,101,45,62,104,101].concat([105,103,104,116,32,61,61,32,48,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,67,111,108,108,105,100,101,80,111,108,121,103,111,110,46,99,112,112,0,0,0,0,0,0,0,32,32,98,100,46,97,110,103,117,108,97,114,86,101,108,111,99,105,116,121,32,61, +32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,68,121,110,97,109,105,99,84,114,101,101,46,104,0,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,104,97,115,86,101,114,116,101,120,48,32,61,32,98,111,111,108,40,37,100,41,59,10,0,0,0,0,0,99,104,105,108,100,50,32,61,61,32,40,45,49,41,0,0,32,32,98,100,46,108,105,110,101,97,114,86,101,108,111,99,105,116,121,46,83,101,116,40,37,46,49,53,108,101,102, +44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,98,111,100,105,101,115,32,61,32,78,85,76,76,59,10,0,32,32,32,32,115,104,97,112,101,46,109,95,118,101,114,116,101,120,51,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,32,32,98,100,46,97,110,103,108,101,32,61,32,37,46,49,53,108,101,102,59,10,0,0,98,100,45,62,112,111,115,105,116,105,111,110,46,73,115,86,97,108,105,100,40,41,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105, +99,115,47,98,50,87,111,114,108,100,46,99,112,112,0,109,95,105,110,100,101,120,32,61,61,32,48,0,0,0,0,109,95,110,111,100,101,115,91,105,110,100,101,120,93,46,112,97,114,101,110,116,32,61,61,32,40,45,49,41,0,0,0,106,111,105,110,116,115,32,61,32,78,85,76,76,59,10,0,32,32,32,32,115,104,97,112,101,46,109,95,118,101,114,116,101,120,50,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109, +105,99,115,47,98,50,73,115,108,97,110,100,46,99,112,112,0,0,0,0,0,0,0,0,48,32,60,61,32,105,110,100,101,120,32,38,38,32,105,110,100,101,120,32,60,32,99,104,97,105,110,45,62,109,95,99,111,117,110,116,0,0,0,0,32,32,98,100,46,112,111,115,105,116,105,111,110,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,98,50,70,114,101,101,40,98,111,100,105,101,115,41,59,10,0,0,0,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,118,101,114,116,101,120,49,46,83,101,116,40,37,46, +49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,106,32,60,32,98,50,95,98,108,111,99,107,83,105,122,101,115,0,0,0,0,0,0,0,109,95,110,111,100,101,115,91,66,45,62,112,97,114,101,110,116,93,46,99,104,105,108,100,50,32,61,61,32,105,65,0,32,32,98,100,46,116,121,112,101,32,61,32,98,50,66,111,100,121,84,121,112,101,40,37,100,41,59,10,0,0,0,0,32,32,106,100,46,109,97,120,77,111,116,111,114,70,111,114,99,101,32,61,32,37,46,49,53,108,101,102,59,10,0,0,51,32,60,61,32,99,111,117,110,116,32,38, +38,32,99,111,117,110,116,32,60,61,32,56,0,0,0,0,0,0,0,0,98,50,70,114,101,101,40,106,111,105,110,116,115,41,59,10,0,0,0,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,118,101,114,116,101,120,48,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,0,0,48,32,60,61,32,105,69,32,38,38,32,105,69,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,32,32,98,50,66,111,100,121,68,101,102,32,98,100,59,10,0,0,0,0,0,0,0,0,109,95,118,101,114,116,105,99,101,115,32, +61,61,32,95,95,110,117,108,108,32,38,38,32,109,95,99,111,117,110,116,32,61,61,32,48,0,0,0,0,48,32,60,61,32,105,68,32,38,38,32,105,68,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,125,10,0,0,0,0,0,0,32,32,106,100,46,98,111,100,121,65,32,61,32,98,111,100,105,101,115,91,37,100,93,59,10,0,0,0,0,0,0,0,32,32,32,32,98,50,69,100,103,101,83,104,97,112,101,32,115,104,97,112,101,59,10,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50, +68,121,110,97,109,105,99,84,114,101,101,46,99,112,112,0,0,108,111,119,101,114,32,60,61,32,117,112,112,101,114,0,0,116,97,114,103,101,116,32,62,32,116,111,108,101,114,97,110,99,101,0,0,0,0,0,0,114,97,116,105,111,32,62,32,49,46,49,57,50,48,57,50,57,48,69,45,48,55,70,0,32,32,106,100,46,114,97,116,105,111,32,61,32,37,46,49,53,108,101,102,59,10,0,0,100,101,102,45,62,116,97,114,103,101,116,46,73,115,86,97,108,105,100,40,41,0,0,0,109,95,110,111,100,101,115,91,67,45,62,112,97,114,101,110,116,93,46,99,104, +105,108,100,50,32,61,61,32,105,65,0,123,10,0,0,0,0,0,0,102,97,108,115,101,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,112,46,83,101,116,40,37,46,49,53,108,101,102,44,32,37,46,49,53,108,101,102,41,59,10,0,0,0,109,95,116,121,112,101,65,32,61,61,32,101,95,114,101,118,111,108,117,116,101,74,111,105,110,116,32,124,124,32,109,95,116,121,112,101,65,32,61,61,32,101,95,112,114,105,115,109,97,116,105,99,74,111,105,110,116,0,0,0,0,0,0,0,48,32,60,61,32,101,100,103,101,49,32,38,38,32,101,100,103,101,49,32, +60,32,112,111,108,121,49,45,62,109,95,118,101,114,116,101,120,67,111,117,110,116,0,0,0,0,0,0,98,50,73,115,86,97,108,105,100,40,102,111,114,99,101,41,32,38,38,32,102,111,114,99,101,32,62,61,32,48,46,48,102,0,0,0,0,0,0,0,109,95,73,32,62,32,48,46,48,102,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,112,111,108,121,103,111,110,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41, +32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,101,100,103,101,0,0,0,0,0,0,0,0,32,32,106,111,105,110,116,115,91,37,100,93,32,61,32,109,95,119,111,114,108,100,45,62,67,114,101,97,116,101,74,111,105,110,116,40,38,106,100,41,59,10,0,0,0,0,0,0,32,32,106,100,46,108,101,110,103,116,104,66,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,0,0,32,32,106,100,46,117,112,112,101,114,84,114,97,110,115,108,97,116,105,111,110,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,0,112,111,105,110,116,67,111,117, +110,116,32,62,32,48,0,0,98,50,74,111,105,110,116,42,42,32,106,111,105,110,116,115,32,61,32,40,98,50,74,111,105,110,116,42,42,41,98,50,65,108,108,111,99,40,37,100,32,42,32,115,105,122,101,111,102,40,98,50,74,111,105,110,116,42,41,41,59,10,0,0,48,32,60,61,32,116,121,112,101,49,32,38,38,32,116,121,112,101,49,32,60,32,98,50,83,104,97,112,101,58,58,101,95,116,121,112,101,67,111,117,110,116,0,0,0,0,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104, +97,112,101,58,58,101,95,99,105,114,99,108,101,0,0,0,0,0,0,32,32,32,32,115,104,97,112,101,46,109,95,114,97,100,105,117,115,32,61,32,37,46,49,53,108,101,102,59,10,0,0,109,95,102,105,120,116,117,114,101,65,45,62,71,101,116,84,121,112,101,40,41,32,61,61,32,98,50,83,104,97,112,101,58,58,101,95,99,104,97,105,110,0,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,68,121,110,97,109,105,99,115,47,98,50,70,105,120,116,117,114,101,46,99,112,112,0,0,0,0,0,0,0,48,32,60,61,32,105,71,32, +38,38,32,105,71,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,109,95,116,121,112,101,32,61,61,32,98,50,95,100,121,110,97,109,105,99,66,111,100,121,0,0,0,0,0,0,0,0,73,115,76,111,99,107,101,100,40,41,32,61,61,32,102,97,108,115,101,0,0,0,0,0,116,111,105,73,110,100,101,120,65,32,60,32,109,95,98,111,100,121,67,111,117,110,116,0,109,95,110,111,100,101,67,111,117,110,116,32,61,61,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,0,32,32,106,100,46,100,97,109,112,105,110,103,82, +97,116,105,111,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,32,32,106,100,46,117,112,112,101,114,65,110,103,108,101,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,32,32,106,100,46,108,101,110,103,116,104,65,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,0,0,32,32,106,100,46,108,111,119,101,114,84,114,97,110,115,108,97,116,105,111,110,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,0,109,95,112,114,111,120,121,67,111,117,110,116,32,61,61,32,48,0,0,0,0,0,0,0,98,50,66,111,100,121,42,42,32,98, +111,100,105,101,115,32,61,32,40,98,50,66,111,100,121,42,42,41,98,50,65,108,108,111,99,40,37,100,32,42,32,115,105,122,101,111,102,40,98,50,66,111,100,121,42,41,41,59,10,0,0,0,0,0,32,32,32,32,98,50,67,105,114,99,108,101,83,104,97,112,101,32,115,104,97,112,101,59,10,0,0,0,0,0,0,0,48,32,60,61,32,105,70,32,38,38,32,105,70,32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,102,111,117,110,100,0,0,0,32,32,106,100,46,102,114,101,113,117,101,110,99,121,72,122,32,61,32,37,46,49,53,108,101,102, +59,10,0,0,0,0,32,32,106,100,46,108,111,119,101,114,65,110,103,108,101,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,32,32,106,100,46,109,97,120,84,111,114,113,117,101,32,61,32,37,46,49,53,108,101,102,59,10,0,0,0,0,0,0,109,95,119,111,114,108,100,45,62,83,101,116,71,114,97,118,105,116,121,40,103,41,59,10,0,0,0,0,0,0,0,0,32,32,32,32,102,100,46,102,105,108,116,101,114,46,103,114,111,117,112,73,110,100,101,120,32,61,32,105,110,116,49,54,40,37,100,41,59,10,0,0,48,32,60,61,32,105,67,32,38,38,32,105,67, +32,60,32,109,95,110,111,100,101,67,97,112,97,99,105,116,121,0,0,100,101,110,32,62,32,48,46,48,102,0,0,0,0,0,0,66,111,120,50,68,95,118,50,46,50,46,49,47,66,111,120,50,68,47,67,111,108,108,105,115,105,111,110,47,98,50,67,111,108,108,105,100,101,69,100,103,101,46,99,112,112,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,102,108,111,97,116,51,50,32,98,50,83,105,109,112,108,101,120,58,58,71,101,116,77,101,116,114,105,99,40,41,32,99,111,110,115,116,0,0,0,0,118,111,105,100,32,98,50,83,105,109,112,108,101,120,58,58,71,101,116,87,105,116,110,101,115,115,80,111,105,110,116,115,40,98,50,86,101,99,50,32,42,44, +32,98,50,86,101,99,50,32,42,41,32,99,111,110,115,116,0,0,0,0,0,0,98,50,86,101,99,50,32,98,50,83,105,109,112,108,101,120,58,58,71,101,116,67,108,111,115,101,115,116,80,111,105,110,116,40,41,32,99,111,110,115,116,0,0,0,0,0,0,0,102,108,111,97,116,51,50,32,98,50,83,101,112,97,114,97,116,105,111,110,70,117,110,99,116,105,111,110,58,58,69,118,97,108,117,97,116,101,40,105,110,116,51,50,44,32,105,110,116,51,50,44,32,102,108,111,97,116,51,50,41,32,99,111,110,115,116,0,0,0,0,0,102,108,111,97,116,51,50,32,98, +50,83,101,112,97,114,97,116,105,111,110,70,117,110,99,116,105,111,110,58,58,70,105,110,100,77,105,110,83,101,112,97,114,97,116,105,111,110,40,105,110,116,51,50,32,42,44,32,105,110,116,51,50,32,42,44,32,102,108,111,97,116,51,50,41,32,99,111,110,115,116,0,0,0,0,0,0,0,0,99,111,110,115,116,32,98,50,86,101,99,50,32,38,98,50,68,105,115,116,97,110,99,101,80,114,111,120,121,58,58,71,101,116,86,101,114,116,101,120,40,105,110,116,51,50,41,32,99,111,110,115,116,0,0,0,118,105,114,116,117,97,108,32,98,111,111, +108,32,98,50,80,111,108,121,103,111,110,83,104,97,112,101,58,58,82,97,121,67,97,115,116,40,98,50,82,97,121,67,97,115,116,79,117,116,112,117,116,32,42,44,32,99,111,110,115,116,32,98,50,82,97,121,67,97,115,116,73,110,112,117,116,32,38,44,32,99,111,110,115,116,32,98,50,84,114,97,110,115,102,111,114,109,32,38,44,32,105,110,116,51,50,41,32,99,111,110,115,116,0,0,0,0,0,0,0,118,105,114,116,117,97,108,32,118,111,105,100,32,98,50,80,111,108,121,103,111,110,83,104,97,112,101,58,58,67,111,109,112,117,116,101, +77,97,115,115,40,98,50,77,97,115,115,68,97,116,97,32,42,44,32,102,108,111,97,116,51,50,41,32,99,111,110,115,116,0,0,0,118,111,105,100,32,98,50,68,121,110,97,109,105,99,84,114,101,101,58,58,86,97,108,105,100,97,116,101,40,41,32,99,111,110,115,116,0,0,0,0,118,111,105,100,32,98,50,68,121,110,97,109,105,99,84,114,101,101,58,58,82,97,121,67,97,115,116,40,84,32,42,44,32,99,111,110,115,116,32,98,50,82,97,121,67,97,115,116,73,110,112,117,116,32,38,41,32,99,111,110,115,116,32,91,84,32,61,32,98,50,87,111,114, +108,100,82,97,121,67,97,115,116,87,114,97,112,112,101,114,93,0,0,0,0,0,0,118,111,105,100,32,98,50,68,121,110,97,109,105,99,84,114,101,101,58,58,86,97,108,105,100,97,116,101,83,116,114,117,99,116,117,114,101,40,105,110,116,51,50,41,32,99,111,110,115,116,0,0,0,0,0,0,118,111,105,100,32,98,50,68,121,110,97,109,105,99,84,114,101,101,58,58,86,97,108,105,100,97,116,101,77,101,116,114,105,99,115,40,105,110,116,51,50,41,32,99,111,110,115,116,0,0,0,0,0,0,0,0,105,110,116,51,50,32,98,50,68,121,110,97,109,105, +99,84,114,101,101,58,58,71,101,116,77,97,120,66,97,108,97,110,99,101,40,41,32,99,111,110,115,116,0,0,0,0,0,0,105,110,116,51,50,32,98,50,68,121,110,97,109,105,99,84,114,101,101,58,58,67,111,109,112,117,116,101,72,101,105,103,104,116,40,105,110,116,51,50,41,32,99,111,110,115,116,0,118,111,105,100,32,42,98,50,68,121,110,97,109,105,99,84,114,101,101,58,58,71,101,116,85,115,101,114,68,97,116,97,40,105,110,116,51,50,41,32,99,111,110,115,116,0,0,0,99,111,110,115,116,32,98,50,65,65,66,66,32,38,98,50,68,121, +110,97,109,105,99,84,114,101,101,58,58,71,101,116,70,97,116,65,65,66,66,40,105,110,116,51,50,41,32,99,111,110,115,116,0,0,0,0,118,105,114,116,117,97,108,32,98,111,111,108,32,98,50,67,104,97,105,110,83,104,97,112,101,58,58,82,97,121,67,97,115,116,40,98,50,82,97,121,67,97,115,116,79,117,116,112,117,116,32,42,44,32,99,111,110,115,116,32,98,50,82,97,121,67,97,115,116,73,110,112,117,116,32,38,44,32,99,111,110,115,116,32,98,50,84,114,97,110,115,102,111,114,109,32,38,44,32,105,110,116,51,50,41,32,99,111, +110,115,116,0,118,111,105,100,32,98,50,67,104,97,105,110,83,104,97,112,101,58,58,71,101,116,67,104,105,108,100,69,100,103,101,40,98,50,69,100,103,101,83,104,97,112,101,32,42,44,32,105,110,116,51,50,41,32,99,111,110,115,116,0,0,0,0,0,118,105,114,116,117,97,108,32,118,111,105,100,32,98,50,67,104,97,105,110,83,104,97,112,101,58,58,67,111,109,112,117,116,101,65,65,66,66,40,98,50,65,65,66,66,32,42,44,32,99,111,110,115,116,32,98,50,84,114,97,110,115,102,111,114,109,32,38,44,32,105,110,116,51,50,41,32,99, +111,110,115,116,0,0,0,0,0,0,118,111,105,100,32,98,50,83,105,109,112,108,101,120,58,58,82,101,97,100,67,97,99,104,101,40,99,111,110,115,116,32,98,50,83,105,109,112,108,101,120,67,97,99,104,101,32,42,44,32,99,111,110,115,116,32,98,50,68,105,115,116,97,110,99,101,80,114,111,120,121,32,42,44,32,99,111,110,115,116,32,98,50,84,114,97,110,115,102,111,114,109,32,38,44,32,99,111,110,115,116,32,98,50,68,105,115,116,97,110,99,101,80,114,111,120,121,32,42,44,32,99,111,110,115,116,32,98,50,84,114,97,110,115,102, +111,114,109,32,38,41,0,0,0,118,111,105,100,32,98,50,70,105,120,116,117,114,101,58,58,68,101,115,116,114,111,121,40,98,50,66,108,111,99,107,65,108,108,111,99,97,116,111,114,32,42,41,0,0,0,0,0,118,111,105,100,32,98,50,70,105,120,116,117,114,101,58,58,67,114,101,97,116,101,80,114,111,120,105,101,115,40,98,50,66,114,111,97,100,80,104,97,115,101,32,42,44,32,99,111,110,115,116,32,98,50,84,114,97,110,115,102,111,114,109,32,38,41,0,0,0,0,0,0,115,116,97,116,105,99,32,118,111,105,100,32,98,50,67,111,110,116, +97,99,116,58,58,68,101,115,116,114,111,121,40,98,50,67,111,110,116,97,99,116,32,42,44,32,98,50,66,108,111,99,107,65,108,108,111,99,97,116,111,114,32,42,41,0,115,116,97,116,105,99,32,98,50,67,111,110,116,97,99,116,32,42,98,50,67,111,110,116,97,99,116,58,58,67,114,101,97,116,101,40,98,50,70,105,120,116,117,114,101,32,42,44,32,105,110,116,51,50,44,32,98,50,70,105,120,116,117,114,101,32,42,44,32,105,110,116,51,50,44,32,98,50,66,108,111,99,107,65,108,108,111,99,97,116,111,114,32,42,41,0,118,111,105,100, +32,98,50,73,115,108,97,110,100,58,58,83,111,108,118,101,84,79,73,40,99,111,110,115,116,32,98,50,84,105,109,101,83,116,101,112,32,38,44,32,105,110,116,51,50,44,32,105,110,116,51,50,41,0,0,0,0,0,0,0,118,111,105,100,32,98,50,73,115,108,97,110,100,58,58,65,100,100,40,98,50,67,111,110,116,97,99,116,32,42,41,0,118,111,105,100,32,98,50,73,115,108,97,110,100,58,58,65,100,100,40,98,50,74,111,105,110,116,32,42,41,0,0,0,118,111,105,100,32,98,50,73,115,108,97,110,100,58,58,65,100,100,40,98,50,66,111,100,121, +32,42,41,0,0,0,0,118,111,105,100,32,98,50,87,111,114,108,100,58,58,68,114,97,119,83,104,97,112,101,40,98,50,70,105,120,116,117,114,101,32,42,44,32,99,111,110,115,116,32,98,50,84,114,97,110,115,102,111,114,109,32,38,44,32,99,111,110,115,116,32,98,50,67,111,108,111,114,32,38,41,0,0,0,0,0,0,118,111,105,100,32,98,50,87,111,114,108,100,58,58,83,111,108,118,101,84,79,73,40,99,111,110,115,116,32,98,50,84,105,109,101,83,116,101,112,32,38,41,0,0,0,0,0,0,118,111,105,100,32,98,50,87,111,114,108,100,58,58,83, +111,108,118,101,40,99,111,110,115,116,32,98,50,84,105,109,101,83,116,101,112,32,38,41,0,118,111,105,100,32,98,50,87,111,114,108,100,58,58,68,101,115,116,114,111,121,74,111,105,110,116,40,98,50,74,111,105,110,116,32,42,41,0,0,0,118,111,105,100,32,98,50,87,111,114,108,100,58,58,68,101,115,116,114,111,121,66,111,100,121,40,98,50,66,111,100,121,32,42,41,0,0,0,0,0,98,50,74,111,105,110,116,32,42,98,50,87,111,114,108,100,58,58,67,114,101,97,116,101,74,111,105,110,116,40,99,111,110,115,116,32,98,50,74,111, +105,110,116,68,101,102,32,42,41,0,0,0,0,0,0,0,98,50,66,111,100,121,32,42,98,50,87,111,114,108,100,58,58,67,114,101,97,116,101,66,111,100,121,40,99,111,110,115,116,32,98,50,66,111,100,121,68,101,102,32,42,41,0,0,118,111,105,100,32,98,50,83,119,101,101,112,58,58,65,100,118,97,110,99,101,40,102,108,111,97,116,51,50,41,0,0,98,50,74,111,105,110,116,58,58,98,50,74,111,105,110,116,40,99,111,110,115,116,32,98,50,74,111,105,110,116,68,101,102,32,42,41,0,0,0,0,115,116,97,116,105,99,32,118,111,105,100,32,98, +50,74,111,105,110,116,58,58,68,101,115,116,114,111,121,40,98,50,74,111,105,110,116,32,42,44,32,98,50,66,108,111,99,107,65,108,108,111,99,97,116,111,114,32,42,41,0,0,0,0,0,115,116,97,116,105,99,32,98,50,74,111,105,110,116,32,42,98,50,74,111,105,110,116,58,58,67,114,101,97,116,101,40,99,111,110,115,116,32,98,50,74,111,105,110,116,68,101,102,32,42,44,32,98,50,66,108,111,99,107,65,108,108,111,99,97,116,111,114,32,42,41,0,98,50,66,111,100,121,58,58,98,50,66,111,100,121,40,99,111,110,115,116,32,98,50,66, +111,100,121,68,101,102,32,42,44,32,98,50,87,111,114,108,100,32,42,41,0,0,0,0,118,111,105,100,32,98,50,66,111,100,121,58,58,83,101,116,65,99,116,105,118,101,40,98,111,111,108,41,0,0,0,0,118,111,105,100,32,98,50,66,111,100,121,58,58,83,101,116,84,121,112,101,40,98,50,66,111,100,121,84,121,112,101,41,0,0,0,0,0,0,0,0,118,111,105,100,32,98,50,66,111,100,121,58,58,68,101,115,116,114,111,121,70,105,120,116,117,114,101,40,98,50,70,105,120,116,117,114,101,32,42,41,0,0,0,0,0,0,0,0,118,111,105,100,32,98,50, +66,111,100,121,58,58,82,101,115,101,116,77,97,115,115,68,97,116,97,40,41,0,0,0,0,98,50,70,105,120,116,117,114,101,32,42,98,50,66,111,100,121,58,58,67,114,101,97,116,101,70,105,120,116,117,114,101,40,99,111,110,115,116,32,98,50,70,105,120,116,117,114,101,68,101,102,32,42,41,0,0,118,111,105,100,32,98,50,66,111,100,121,58,58,83,101,116,84,114,97,110,115,102,111,114,109,40,99,111,110,115,116,32,98,50,86,101,99,50,32,38,44,32,102,108,111,97,116,51,50,41,0,0,0,0,0,0,118,111,105,100,32,98,50,66,111,100, +121,58,58,83,101,116,77,97,115,115,68,97,116,97,40,99,111,110,115,116,32,98,50,77,97,115,115,68,97,116,97,32,42,41,0,0,0,0,98,50,80,111,108,121,103,111,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,58,58,98,50,80,111,108,121,103,111,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,40,98,50,70,105,120,116,117,114,101,32,42,44,32,98,50,70,105,120,116,117,114,101,32,42,41,0,0,118,111,105,100,32,98,50,80,111,115,105,116,105,111,110,83,111,108,118,101,114,77,97,110,105,102, +111,108,100,58,58,73,110,105,116,105,97,108,105,122,101,40,98,50,67,111,110,116,97,99,116,80,111,115,105,116,105,111,110,67,111,110,115,116,114,97,105,110,116,32,42,44,32,99,111,110,115,116,32,98,50,84,114,97,110,115,102,111,114,109,32,38,44,32,99,111,110,115,116,32,98,50,84,114,97,110,115,102,111,114,109,32,38,44,32,105,110,116,51,50,41,0,0,0,0,0,0,0,98,50,67,104,97,105,110,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,58,58,98,50,67,104,97,105,110,65,110,100,80,111,108,121,103, +111,110,67,111,110,116,97,99,116,40,98,50,70,105,120,116,117,114,101,32,42,44,32,105,110,116,51,50,44,32,98,50,70,105,120,116,117,114,101,32,42,44,32,105,110,116,51,50,41,0,0,0,0,0,0,98,50,69,100,103,101,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,58,58,98,50,69,100,103,101,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,40,98,50,70,105,120,116,117,114,101,32,42,44,32,98,50,70,105,120,116,117,114,101,32,42,41,0,0,0,0,0,0,98,50,67,104,97,105,110,65,110,100,67,105, +114,99,108,101,67,111,110,116,97,99,116,58,58,98,50,67,104,97,105,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,40,98,50,70,105,120,116,117,114,101,32,42,44,32,105,110,116,51,50,44,32,98,50,70,105,120,116,117,114,101,32,42,44,32,105,110,116,51,50,41,0,0,0,0,0,0,0,0,98,50,69,100,103,101,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,58,58,98,50,69,100,103,101,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,40,98,50,70,105,120,116,117,114,101,32,42,44,32,98,50,70, +105,120,116,117,114,101,32,42,41,0,0,0,0,0,0,0,0,102,108,111,97,116,51,50,32,98,50,83,101,112,97,114,97,116,105,111,110,70,117,110,99,116,105,111,110,58,58,73,110,105,116,105,97,108,105,122,101,40,99,111,110,115,116,32,98,50,83,105,109,112,108,101,120,67,97,99,104,101,32,42,44,32,99,111,110,115,116,32,98,50,68,105,115,116,97,110,99,101,80,114,111,120,121,32,42,44,32,99,111,110,115,116,32,98,50,83,119,101,101,112,32,38,44,32,99,111,110,115,116,32,98,50,68,105,115,116,97,110,99,101,80,114,111,120,121, +32,42,44,32,99,111,110,115,116,32,98,50,83,119,101,101,112,32,38,44,32,102,108,111,97,116,51,50,41,0,0,0,98,50,83,116,97,99,107,65,108,108,111,99,97,116,111,114,58,58,126,98,50,83,116,97,99,107,65,108,108,111,99,97,116,111,114,40,41,0,0,0,118,111,105,100,32,42,98,50,83,116,97,99,107,65,108,108,111,99,97,116,111,114,58,58,65,108,108,111,99,97,116,101,40,105,110,116,51,50,41,0,118,111,105,100,32,98,50,83,116,97,99,107,65,108,108,111,99,97,116,111,114,58,58,70,114,101,101,40,118,111,105,100,32,42,41, +0,0,0,0,0,118,111,105,100,32,98,50,80,117,108,108,101,121,74,111,105,110,116,68,101,102,58,58,73,110,105,116,105,97,108,105,122,101,40,98,50,66,111,100,121,32,42,44,32,98,50,66,111,100,121,32,42,44,32,99,111,110,115,116,32,98,50,86,101,99,50,32,38,44,32,99,111,110,115,116,32,98,50,86,101,99,50,32,38,44,32,99,111,110,115,116,32,98,50,86,101,99,50,32,38,44,32,99,111,110,115,116,32,98,50,86,101,99,50,32,38,44,32,102,108,111,97,116,51,50,41,0,0,118,111,105,100,32,98,50,80,114,105,115,109,97,116,105,99, +74,111,105,110,116,58,58,83,101,116,76,105,109,105,116,115,40,102,108,111,97,116,51,50,44,32,102,108,111,97,116,51,50,41,0,0,0,0,0,0,98,50,80,111,108,121,103,111,110,67,111,110,116,97,99,116,58,58,98,50,80,111,108,121,103,111,110,67,111,110,116,97,99,116,40,98,50,70,105,120,116,117,114,101,32,42,44,32,98,50,70,105,120,116,117,114,101,32,42,41,0,0,0,0,98,50,66,108,111,99,107,65,108,108,111,99,97,116,111,114,58,58,98,50,66,108,111,99,107,65,108,108,111,99,97,116,111,114,40,41,0,0,0,0,118,111,105,100, +32,42,98,50,66,108,111,99,107,65,108,108,111,99,97,116,111,114,58,58,65,108,108,111,99,97,116,101,40,105,110,116,51,50,41,0,118,111,105,100,32,98,50,66,108,111,99,107,65,108,108,111,99,97,116,111,114,58,58,70,114,101,101,40,118,111,105,100,32,42,44,32,105,110,116,51,50,41,0,0,0,0,0,0,118,111,105,100,32,98,50,82,101,118,111,108,117,116,101,74,111,105,110,116,58,58,83,101,116,76,105,109,105,116,115,40,102,108,111,97,116,51,50,44,32,102,108,111,97,116,51,50,41,0,0,0,0,0,0,0,118,111,105,100,32,98,50, +70,114,105,99,116,105,111,110,74,111,105,110,116,58,58,83,101,116,77,97,120,84,111,114,113,117,101,40,102,108,111,97,116,51,50,41,0,0,0,0,0,118,111,105,100,32,98,50,70,114,105,99,116,105,111,110,74,111,105,110,116,58,58,83,101,116,77,97,120,70,111,114,99,101,40,102,108,111,97,116,51,50,41,0,0,0,0,0,0,118,111,105,100,32,98,50,68,105,115,116,97,110,99,101,80,114,111,120,121,58,58,83,101,116,40,99,111,110,115,116,32,98,50,83,104,97,112,101,32,42,44,32,105,110,116,51,50,41,0,0,0,0,0,0,0,98,50,67,111, +110,116,97,99,116,83,111,108,118,101,114,58,58,98,50,67,111,110,116,97,99,116,83,111,108,118,101,114,40,98,50,67,111,110,116,97,99,116,83,111,108,118,101,114,68,101,102,32,42,41,0,0,118,111,105,100,32,98,50,67,111,110,116,97,99,116,83,111,108,118,101,114,58,58,73,110,105,116,105,97,108,105,122,101,86,101,108,111,99,105,116,121,67,111,110,115,116,114,97,105,110,116,115,40,41,0,0,0,118,111,105,100,32,98,50,67,111,110,116,97,99,116,83,111,108,118,101,114,58,58,83,111,108,118,101,86,101,108,111,99,105, +116,121,67,111,110,115,116,114,97,105,110,116,115,40,41,0,0,0,0,0,0,0,0,98,50,67,105,114,99,108,101,67,111,110,116,97,99,116,58,58,98,50,67,105,114,99,108,101,67,111,110,116,97,99,116,40,98,50,70,105,120,116,117,114,101,32,42,44,32,98,50,70,105,120,116,117,114,101,32,42,41,0,0,0,0,0,0,118,111,105,100,32,98,50,80,111,108,121,103,111,110,83,104,97,112,101,58,58,83,101,116,40,99,111,110,115,116,32,98,50,86,101,99,50,32,42,44,32,105,110,116,51,50,41,0,98,50,80,117,108,108,101,121,74,111,105,110,116,58, +58,98,50,80,117,108,108,101,121,74,111,105,110,116,40,99,111,110,115,116,32,98,50,80,117,108,108,101,121,74,111,105,110,116,68,101,102,32,42,41,0,0,98,111,111,108,32,98,50,68,121,110,97,109,105,99,84,114,101,101,58,58,77,111,118,101,80,114,111,120,121,40,105,110,116,51,50,44,32,99,111,110,115,116,32,98,50,65,65,66,66,32,38,44,32,99,111,110,115,116,32,98,50,86,101,99,50,32,38,41,0,0,0,0,118,111,105,100,32,98,50,68,121,110,97,109,105,99,84,114,101,101,58,58,70,114,101,101,78,111,100,101,40,105,110, +116,51,50,41,0,0,0,0,0,105,110,116,51,50,32,98,50,68,121,110,97,109,105,99,84,114,101,101,58,58,66,97,108,97,110,99,101,40,105,110,116,51,50,41,0,0,0,0,0,118,111,105,100,32,98,50,68,121,110,97,109,105,99,84,114,101,101,58,58,68,101,115,116,114,111,121,80,114,111,120,121,40,105,110,116,51,50,41,0,105,110,116,51,50,32,98,50,68,121,110,97,109,105,99,84,114,101,101,58,58,65,108,108,111,99,97,116,101,78,111,100,101,40,41,0,0,0,0,0,118,111,105,100,32,98,50,68,121,110,97,109,105,99,84,114,101,101,58,58, +73,110,115,101,114,116,76,101,97,102,40,105,110,116,51,50,41,0,0,0,98,50,77,111,117,115,101,74,111,105,110,116,58,58,98,50,77,111,117,115,101,74,111,105,110,116,40,99,111,110,115,116,32,98,50,77,111,117,115,101,74,111,105,110,116,68,101,102,32,42,41,0,0,0,0,0,118,105,114,116,117,97,108,32,118,111,105,100,32,98,50,77,111,117,115,101,74,111,105,110,116,58,58,73,110,105,116,86,101,108,111,99,105,116,121,67,111,110,115,116,114,97,105,110,116,115,40,99,111,110,115,116,32,98,50,83,111,108,118,101,114,68, +97,116,97,32,38,41,0,0,0,0,0,0,0,0,118,111,105,100,32,98,50,67,104,97,105,110,83,104,97,112,101,58,58,67,114,101,97,116,101,67,104,97,105,110,40,99,111,110,115,116,32,98,50,86,101,99,50,32,42,44,32,105,110,116,51,50,41,0,0,0,118,111,105,100,32,98,50,67,104,97,105,110,83,104,97,112,101,58,58,67,114,101,97,116,101,76,111,111,112,40,99,111,110,115,116,32,98,50,86,101,99,50,32,42,44,32,105,110,116,51,50,41,0,0,0,0,98,50,71,101,97,114,74,111,105,110,116,58,58,98,50,71,101,97,114,74,111,105,110,116,40, +99,111,110,115,116,32,98,50,71,101,97,114,74,111,105,110,116,68,101,102,32,42,41,0,0,0,0,0,0,0,0,118,111,105,100,32,98,50,71,101,97,114,74,111,105,110,116,58,58,83,101,116,82,97,116,105,111,40,102,108,111,97,116,51,50,41,0,0,0,0,0,118,111,105,100,32,98,50,70,105,110,100,73,110,99,105,100,101,110,116,69,100,103,101,40,98,50,67,108,105,112,86,101,114,116,101,120,32,42,44,32,99,111,110,115,116,32,98,50,80,111,108,121,103,111,110,83,104,97,112,101,32,42,44,32,99,111,110,115,116,32,98,50,84,114,97,110, +115,102,111,114,109,32,38,44,32,105,110,116,51,50,44,32,99,111,110,115,116,32,98,50,80,111,108,121,103,111,110,83,104,97,112,101,32,42,44,32,99,111,110,115,116,32,98,50,84,114,97,110,115,102,111,114,109,32,38,41,0,0,0,0,0,0,0,0,102,108,111,97,116,51,50,32,98,50,69,100,103,101,83,101,112,97,114,97,116,105,111,110,40,99,111,110,115,116,32,98,50,80,111,108,121,103,111,110,83,104,97,112,101,32,42,44,32,99,111,110,115,116,32,98,50,84,114,97,110,115,102,111,114,109,32,38,44,32,105,110,116,51,50,44,32,99, +111,110,115,116,32,98,50,80,111,108,121,103,111,110,83,104,97,112,101,32,42,44,32,99,111,110,115,116,32,98,50,84,114,97,110,115,102,111,114,109,32,38,41,0,0,0,0,0,0,0,98,50,86,101,99,50,32,67,111,109,112,117,116,101,67,101,110,116,114,111,105,100,40,99,111,110,115,116,32,98,50,86,101,99,50,32,42,44,32,105,110,116,51,50,41,0,0,0,118,111,105,100,32,98,50,67,111,108,108,105,100,101,69,100,103,101,65,110,100,67,105,114,99,108,101,40,98,50,77,97,110,105,102,111,108,100,32,42,44,32,99,111,110,115,116,32, +98,50,69,100,103,101,83,104,97,112,101,32,42,44,32,99,111,110,115,116,32,98,50,84,114,97,110,115,102,111,114,109,32,38,44,32,99,111,110,115,116,32,98,50,67,105,114,99,108,101,83,104,97,112,101,32,42,44,32,99,111,110,115,116,32,98,50,84,114,97,110,115,102,111,114,109,32,38,41,0,118,111,105,100,32,98,50,84,105,109,101,79,102,73,109,112,97,99,116,40,98,50,84,79,73,79,117,116,112,117,116,32,42,44,32,99,111,110,115,116,32,98,50,84,79,73,73,110,112,117,116,32,42,41,0,0,118,111,105,100,32,98,50,68,105,115, +116,97,110,99,101,40,98,50,68,105,115,116,97,110,99,101,79,117,116,112,117,116,32,42,44,32,98,50,83,105,109,112,108,101,120,67,97,99,104,101,32,42,44,32,99,111,110,115,116,32,98,50,68,105,115,116,97,110,99,101,73,110,112,117,116,32,42,41,0,0,0,0,0,0,136,83,0,0,78,0,0,0,4,1,0,0,150,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,200,83,0,0,42,0,0,0,62,0,0,0,184,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,216,83,0,0,42,0,0,0,42,0,0,0,42,0,0,0,42,0,0,0,20,1,0,0,210,0,0,0,48,0,0,0,42,0,0,0,42,0,0,0,42,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,224,83,0,0,168,0,0,0,254,0,0,0,56,0,0,0,82,0,0,0,44,0,0,0,42,0,0,0,86,0,0,0,148,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,232,83,0,0,58,0,0,0,74,0,0,0,112,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,83,0,0,70,0,0,0,40,1,0,0,134,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,84,0,0,62,0,0,0,190,0,0,0,174,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,84,0,0,54,0,0,0,236,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,40,84,0,0,80,0,0,0,70,1,0,0,228,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,56,84,0,0,90,1,0,0,66,0, +0,0,58,1,0,0,150,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,84,0,0,52,1,0,0,102,0,0,0,44,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,72,84,0,0,182,0,0,0,152,0,0,0,144,1,0,0,38,1,0,0,48,0,0,0,70,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,84,0,0,82,0,0,0,222,0,0,0,68,0,0,0,78,0,0,0,76,0,0,0,136,0,0,0,166,0,0,0,48,0,0,0,4,1,0,0,88,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,84,0,0,90,0,0,0,46,1,0,0,94,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,112,84,0,0,112,1,0,0,0,1,0,0,54,0,0,0,66,0,0,0,68,0,0,0,54,0,0,0,88,1,0,0,114,1,0,0,164,1,0,0,168, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,84,0,0,120,0,0,0,230,0,0,0,174,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,136,84,0,0,106,1,0,0,216,0,0,0,72,0,0,0,84,0,0,0,104,0,0,0,44,1,0,0,160,0,0,0,130,0,0,0,108,1,0,0,152,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,152,84,0,0,206,1,0,0,120,1,0,0,78,0,0,0,88,0,0,0,50,1,0,0,82,1,0,0,58,0,0,0,84,0,0,0,198,1,0,0,190,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,168,84,0,0,110,0,0,0,250,0,0,0,58,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,176,84,0,0,88,0,0,0,234,0,0,0,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,192,84,0,0,180,0,0,0,220,0,0,0,104,0,0,0,100,1,0,0,64,0,0,0,42,0,0,0,84,0,0,0,74,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,208,84,0,0,192,0,0,0,144,0,0,0,80,0,0,0,80,0,0,0,98,0,0,0,96,0,0,0,6,1,0,0,80,0,0,0,180,1,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,224,84,0,0,140,0,0,0,114,0,0,0,82,0,0,0,70,2,0,0,54,0,0,0,66,0,0,0,42,0,0,0,50,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,84,0,0,212,1,0,0,156,0,0,0,52,0,0,0,48,0,0,0,64,1,0,0,42,0,0,0,194,0,0,0,200,0,0,0,132,1,0,0,148,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,85,0,0,126,0,0, +0,80,1,0,0,56,0,0,0,50,0,0,0,36,1,0,0,76,1,0,0,92,1,0,0,8,1,0,0,124,1,0,0,96,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,85,0,0,108,0,0,0,8,1,0,0,162,0,0,0,76,1,0,0,68,0,0,0,50,0,0,0,52,0,0,0,42,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,85,0,0,224,0,0,0,184,1,0,0,76,0,0,0,58,0,0,0,48,1,0,0,128,0,0,0,158,0,0,0,184,0,0,0,66,1,0,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,85,0,0,170,0,0,0,88,0,0,0,60,0,0,0,62,0,0,0,84,1,0,0,30,1,0,0,238,0,0,0,114,0,0,0,162,0,0,0,126,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,85,0,0,194,0,0,0,12,1,0,0, +46,0,0,0,52,0,0,0,208,0,0,0,56,1,0,0,64,0,0,0,54,1,0,0]).concat([26,1,0,0,140,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,80,85,0,0,80,0,0,0,56,0,0,0,142,0,0,0,68,2,0,0,66,0,0,0,68,0,0,0,44,0,0,0,82,0,0,0,0,0,0,0,0,0,0,0,83,116,57,116,121,112,101,95,105,110,102,111,0,0,0,0,83,116,57,101,120,99,101,112,116,105,111,110,0,0,0,0,83,116,57,98,97,100,95,97,108,108,111,99,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,50,48,95,95,115,105,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,78,49, +48,95,95,99,120,120,97,98,105,118,49,49,55,95,95,99,108,97,115,115,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,78,49,48,95,95,99,120,120,97,98,105,118,49,49,54,95,95,115,104,105,109,95,116,121,112,101,95,105,110,102,111,69,0,0,0,0,0,0,0,0,57,98,50,67,111,110,116,97,99,116,0,0,0,0,0,0,55,98,50,83,104,97,112,101,0,0,0,0,0,0,0,0,55,98,50,74,111,105,110,116,0,0,0,0,0,0,0,0,54,98,50,68,114,97,119,0,50,53,98,50,80,111,108,121,103,111,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99, +116,0,0,0,0,0,50,52,98,50,67,104,97,105,110,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,50,51,98,50,69,100,103,101,65,110,100,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,0,50,51,98,50,67,104,97,105,110,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,0,0,50,50,98,50,69,100,103,101,65,110,100,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,0,0,0,50,49,98,50,68,101,115,116,114,117,99,116,105,111,110,76,105,115,116,101,110, +101,114,0,49,55,98,50,82,97,121,67,97,115,116,67,97,108,108,98,97,99,107,0,0,0,0,0,49,55,98,50,67,111,110,116,97,99,116,76,105,115,116,101,110,101,114,0,0,0,0,0,49,54,98,50,80,114,105,115,109,97,116,105,99,74,111,105,110,116,0,0,0,0,0,0,49,54,98,50,80,111,108,121,103,111,110,67,111,110,116,97,99,116,0,0,0,0,0,0,49,53,98,50,82,101,118,111,108,117,116,101,74,111,105,110,116,0,0,0,0,0,0,0,49,53,98,50,81,117,101,114,121,67,97,108,108,98,97,99,107,0,0,0,0,0,0,0,49,53,98,50,70,114,105,99,116,105,111,110, +74,111,105,110,116,0,0,0,0,0,0,0,49,53,98,50,68,105,115,116,97,110,99,101,74,111,105,110,116,0,0,0,0,0,0,0,49,53,98,50,67,111,110,116,97,99,116,70,105,108,116,101,114,0,0,0,0,0,0,0,49,53,98,50,67,105,114,99,108,101,67,111,110,116,97,99,116,0,0,0,0,0,0,0,49,52,98,50,80,111,108,121,103,111,110,83,104,97,112,101,0,0,0,0,0,0,0,0,49,51,98,50,80,117,108,108,101,121,74,111,105,110,116,0,49,51,98,50,67,105,114,99,108,101,83,104,97,112,101,0,49,50,98,50,87,104,101,101,108,74,111,105,110,116,0,0,49,50,98,50, +77,111,117,115,101,74,111,105,110,116,0,0,49,50,98,50,67,104,97,105,110,83,104,97,112,101,0,0,49,49,98,50,87,101,108,100,74,111,105,110,116,0,0,0,49,49,98,50,82,111,112,101,74,111,105,110,116,0,0,0,49,49,98,50,71,101,97,114,74,111,105,110,116,0,0,0,49,49,98,50,69,100,103,101,83,104,97,112,101,0,0,0,0,0,0,0,72,80,0,0,0,0,0,0,88,80,0,0,0,0,0,0,104,80,0,0,128,83,0,0,0,0,0,0,0,0,0,0,120,80,0,0,168,83,0,0,0,0,0,0,0,0,0,0,160,80,0,0,184,83,0,0,0,0,0,0,0,0,0,0,200,80,0,0,120,83,0,0,0,0,0,0,0,0,0,0,240,80, +0,0,0,0,0,0,0,81,0,0,0,0,0,0,16,81,0,0,0,0,0,0,32,81,0,0,0,0,0,0,40,81,0,0,200,83,0,0,0,0,0,0,0,0,0,0,72,81,0,0,200,83,0,0,0,0,0,0,0,0,0,0,104,81,0,0,200,83,0,0,0,0,0,0,0,0,0,0,136,81,0,0,200,83,0,0,0,0,0,0,0,0,0,0,168,81,0,0,200,83,0,0,0,0,0,0,0,0,0,0,200,81,0,0,0,0,0,0,224,81,0,0,0,0,0,0,248,81,0,0,0,0,0,0,16,82,0,0,216,83,0,0,0,0,0,0,0,0,0,0,40,82,0,0,200,83,0,0,0,0,0,0,0,0,0,0,64,82,0,0,216,83,0,0,0,0,0,0,0,0,0,0,88,82,0,0,0,0,0,0,112,82,0,0,216,83,0,0,0,0,0,0,0,0,0,0,136,82,0,0,216,83,0,0,0, +0,0,0,0,0,0,0,160,82,0,0,0,0,0,0,184,82,0,0,200,83,0,0,0,0,0,0,0,0,0,0,208,82,0,0,208,83,0,0,0,0,0,0,0,0,0,0,232,82,0,0,216,83,0,0,0,0,0,0,0,0,0,0,248,82,0,0,208,83,0,0,0,0,0,0,0,0,0,0,8,83,0,0,216,83,0,0,0,0,0,0,0,0,0,0,24,83,0,0,216,83,0,0,0,0,0,0,0,0,0,0,40,83,0,0,208,83,0,0,0,0,0,0,0,0,0,0,56,83,0,0,216,83,0,0,0,0,0,0,0,0,0,0,72,83,0,0,216,83,0,0,0,0,0,0,0,0,0,0,88,83,0,0,216,83,0,0,0,0,0,0,0,0,0,0,104,83,0,0,208,83,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,0,0,32,0,0,0,64,0,0,0,96,0,0,0,128,0,0,0,160,0,0,0,192,0,0,0,224,0,0,0,0,1,0,0,64,1,0,0,128,1,0,0,192,1,0,0,0,2,0,0,128,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),"i8",Wa,8);q[s+8>>2]=288;q[s+12>>2]=224;q[s+16>>2]=130;q[s+20>>2]=290;q[s+24>>2]=52;q[s+28>>2]=42;q[s+32>>2]=46;q[s+36>>2]=60;q[t+8>>2]=288;q[t+12>>2]=336;q[t+16>>2]=130;q[t+20>>2]=290;q[t+24>>2]=52;q[t+28>>2]=44;q[t+32>>2]=48;q[t+36>>2]=74;q[5342]=t+8|0;q[5344]=t+8|0;q[5346]=s+8|0;q[5350]=s+8|0;q[5354]=s+8|0;q[5358]=s+8|0;q[5362]=t+8|0;q[5364]=t+8|0;q[5366]=t+8|0;q[5368]=t+8|0;q[5370]=s+8|0;q[5374]=s+8|0; +q[5378]=s+8|0;q[5382]=s+8|0;q[5386]=s+8|0;q[5390]=t+8|0;q[5392]=t+8|0;q[5394]=t+8|0;q[5396]=s+8|0;q[5400]=s+8|0;q[5404]=s+8|0;q[5408]=t+8|0;q[5410]=s+8|0;q[5414]=s+8|0;q[5418]=t+8|0;q[5420]=s+8|0;q[5424]=s+8|0;q[5428]=s+8|0;q[5432]=s+8|0;q[5436]=s+8|0;q[5440]=s+8|0;q[5444]=s+8|0;q[5448]=s+8|0;q[5452]=s+8|0;q[5456]=s+8|0;q[5460]=s+8|0;var wb=Fa(Xa(12,"i8",Va),8);qa(0==wb%8); +function xb(a){function c(){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a;Module.print("Exit Status: "+a)}c.prototype=Error();gb(jb);Ha=j;b(new c)}Module._memcpy=yb;var zb=Math.sqrt;Module._memset=Ab;var Bb=Math.sin,Cb=Math.cos,Db=Math.floor,Eb=5,Fb=6,Gb=9,Hb=13,Ib=21,Jb=22,Kb=0;function Lb(a){return q[Kb>>2]=a}var Mb=Xa(1,"i32*",Va),Nb=Xa(1,"i32*",Va),Ob=Xa(1,"i32*",Va),Pb=Xa(1,"i32*",Va),Qb=2,v=[l],Rb=j; +function Sb(a,c){if("string"!==typeof a)return l;c===f&&(c="/");a&&"/"==a[0]&&(c="");for(var d=(c+"/"+a).split("/").reverse(),e=[""];d.length;){var g=d.pop();""==g||"."==g||(".."==g?1d||0>e)return Lb(Jb),-1;for(var g=a.object.d;g.lengthd)return Lb(Jb),-1;if(e.object.f){if(e.object.h){for(a=0;aa||0===a&&-Infinity===1/a} +function jc(a,c){function d(a){var d;"double"===a?d=Sa[c+g>>3]:"i64"==a?(d=[q[c+g>>2],q[c+(g+8)>>2]],g+=8):(a="i32",d=q[c+g>>2]);g+=Math.max(Math.max(na(a),oa),8);return d}for(var e=a,g=0,h=[],i,k;;){var r=e;i=p[e];if(0===i)break;k=p[e+1|0];if(37==i){var H=n,$=n,N=n,E=n;a:for(;;){switch(k){case 43:H=j;break;case 45:$=j;break;case 35:N=j;break;case 48:if(E)break a;else{E=j;break}default:break a}e++;k=p[e+1|0]}var la=0;if(42==k)la=d("i32"),e++,k=p[e+1|0];else for(;48<=k&&57>=k;)la=10*la+(k-48),e++, +k=p[e+1|0];var Da=n;if(46==k){var u=0,Da=j;e++;k=p[e+1|0];if(42==k)u=d("i32"),e++;else for(;;){k=p[e+1|0];if(48>k||57>>0)+4294967296*+(i[1]>>>0):+(i[0]>>>0)+4294967296*+(i[1]|0));4>=y&&(i=(r?nb:mb)(i&Math.pow(256,y)-1,8*y));var pa=Math.abs(i),r="";if(100==k||105==k)m=8==y&&kc?kc.stringify(va[0],va[1],l):nb(i,8*y).toString(10);else if(117==k)m=8==y&&kc?kc.stringify(va[0],va[1],j):mb(i,8*y).toString(10),i=Math.abs(i);else if(111==k)m=(N?"0":"")+pa.toString(8);else if(120==k||88==k){r=N&&0!=i?"0x":"";if(8==y&&kc)if(va[1]){m=(va[1]>>>0).toString(16);for(N=(va[0]>>> +0).toString(16);8>N.length;)N="0"+N;m+=N}else m=(va[0]>>>0).toString(16);else if(0>i){i=-i;m=(pa-1).toString(16);va=[];for(N=0;Ni?"-"+r:"+"+r);r.length+m.lengthy&&-4<=y?(k=(103==k?"f":"F").charCodeAt(0),u-=y+1):(k=(103==k?"e":"E").charCodeAt(0),u--),y=Math.min(u,20);if(101==k||69==k)m=i.toExponential(y),/[eE][-+]\d$/.test(m)&&(m=m.slice(0,-1)+"0"+m.slice(-1));else if(102==k||70==k)m=i.toFixed(y),0===i&&ic(i)&&(m="-"+m);r=m.split("e");if(Da&& +!N)for(;1y++;)r[0]+="0";m=r[0]+(1i?"-":"")+"inf",E=n;for(;m.lengthk&&(m=m.toUpperCase());m.split("").forEach(function(a){h.push(a.charCodeAt(0))});break;case "s":E=(H=d("i8*"))?hc(H):6;Da&&(E=Math.min(E, +u));if(!$)for(;E>2]=h.length;break;case "%":h.push(i);break;default:for(N=r;N>2],a,c)} +var nc=Math.atan2;function oc(a){oc.N||(Ba=Ba+4095>>12<<12,oc.N=j,qa(Aa),oc.M=Aa,Aa=function(){Ea("cannot dynamically allocate, sbrk now has control")});var c=Ba;0!=a&&oc.M(a);return c}function pc(){return q[pc.e>>2]}function qc(){return!!qc.I} +function rc(a){var c=n;try{a==__ZTIi&&(c=j)}catch(d){}try{a==__ZTIj&&(c=j)}catch(e){}try{a==__ZTIl&&(c=j)}catch(g){}try{a==__ZTIm&&(c=j)}catch(h){}try{a==__ZTIx&&(c=j)}catch(i){}try{a==__ZTIy&&(c=j)}catch(k){}try{a==__ZTIf&&(c=j)}catch(r){}try{a==__ZTId&&(c=j)}catch(H){}try{a==__ZTIe&&(c=j)}catch($){}try{a==__ZTIc&&(c=j)}catch(N){}try{a==__ZTIa&&(c=j)}catch(E){}try{a==__ZTIh&&(c=j)}catch(la){}try{a==__ZTIs&&(c=j)}catch(Da){}try{a==__ZTIt&&(c=j)}catch(u){}return c} +function sc(a,c,d){if(0==d)return n;if(0==c||c==a)return j;switch(rc(c)?c:q[q[c>>2]-8>>2]){case 0:return 0==q[q[a>>2]-8>>2]?sc(q[a+8>>2],q[c+8>>2],d):n;case 1:return n;case 2:return sc(a,q[c+8>>2],d);default:return n}} +function tc(a,c,d){if(!tc.Q){try{q[__ZTVN10__cxxabiv119__pointer_type_infoE>>2]=0}catch(e){}try{q[t>>2]=1}catch(g){}try{q[s>>2]=2}catch(h){}tc.Q=j}q[pc.e>>2]=a;q[pc.e+4>>2]=c;q[pc.e+8>>2]=d;"uncaught_exception"in qc?qc.I++:qc.I=1;b(a+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.")}var uc=n,vc=n,wc=n,xc=n,yc=f,zc=f,Ac=[]; +function Bc(){var a=Module.canvas;Ac.forEach(function(c){c(a.width,a.height)})}function Cc(){var a=Module.canvas;this.Y=a.width;this.X=a.height;a.width=screen.width;a.height=screen.height;a=ab[SDL.screen+0*oa>>2];q[SDL.screen+0*oa>>2]=a|8388608;Bc()}function Dc(){var a=Module.canvas;a.width=this.Y;a.height=this.X;a=ab[SDL.screen+0*oa>>2];q[SDL.screen+0*oa>>2]=a&-8388609;Bc()}var Ec,Fc,Gc,Hc; +hb.unshift({p:function(){if(!Module.noFSInit&&!cc){var a,c,d,e=function(a){a===l||10===a?(c.l(c.buffer.join("")),c.buffer=[]):c.buffer.push(k.G(a))};qa(!cc,"FS.init was previously called. If you want to initialize later with custom parameters, remove any earlier calls (note that one is automatically added to the generated code)");cc=j;Wb();a=a||Module.stdin;c=c||Module.stdout;d=d||Module.stderr;var g=j,h=j,i=j;a||(g=n,a=function(){if(!a.n||!a.n.length){var c;"undefined"!=typeof window&&"function"== +typeof window.prompt?(c=window.prompt("Input: "),c===l&&(c=String.fromCharCode(0))):"function"==typeof readline&&(c=readline());c||(c="");a.n=lb(c+"\n",j)}return a.n.shift()});var k=new wa;c||(h=n,c=e);c.l||(c.l=Module.print);c.buffer||(c.buffer=[]);d||(i=n,d=e);d.l||(d.l=Module.print);d.buffer||(d.buffer=[]);try{Yb("/","tmp",j,j)}catch(r){}var e=Yb("/","dev",j,j),H=bc(e,"stdin",a),$=bc(e,"stdout",l,c);d=bc(e,"stderr",l,d);bc(e,"tty",a,c);bc(e,"null",aa(),aa());v[1]={path:"/dev/stdin",object:H,position:0, +A:j,k:n,z:n,B:!g,error:n,u:n,J:[]};v[2]={path:"/dev/stdout",object:$,position:0,A:n,k:j,z:n,B:!h,error:n,u:n,J:[]};v[3]={path:"/dev/stderr",object:d,position:0,A:n,k:j,z:n,B:!i,error:n,u:n,J:[]};q[Mb>>2]=1;q[Nb>>2]=2;q[Ob>>2]=3;Zb("/","dev/shm/tmp",j,j);for(g=v.length;g>h-6&63,h=h-6,d=d+"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[m]}2==h?(d+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(e& +3)<<4],d+="=="):4==h&&(d+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(e&15)<<2],d+="=");r.src="data:audio/x-"+c.substr(-3)+";base64,"+d;g(r)}};r.src=k;setTimeout(function(){Ha||g(r)},1E4)}else return h()}});var E=Module.canvas;E.r=E.requestPointerLock||E.mozRequestPointerLock||E.webkitRequestPointerLock;E.v=document.exitPointerLock||document.mozExitPointerLock||document.webkitExitPointerLock||aa();E.v=E.v.bind(document);document.addEventListener("pointerlockchange",r,n);document.addEventListener("mozpointerlockchange", +r,n);document.addEventListener("webkitpointerlockchange",r,n);Module.elementPointerLock&&E.addEventListener("click",function(a){!wc&&E.r&&(E.r(),a.preventDefault())},n)}for(var la,Da=[a,c],u=Da[0],y=1;ythis.length-1||0>a)){var c=a%this.O;return this.P(Math.floor(a/this.O))[c]}};h.prototype.W=function(a){this.P=a};h.prototype.s=function(){var a=new XMLHttpRequest;a.open("HEAD",d,n);a.send(l);200<=a.status&&300>a.status|| +304===a.status||b(Error("Couldn't load "+d+". Status: "+a.status));var c=Number(a.getResponseHeader("Content-length")),e,g=1048576;if(!((e=a.getResponseHeader("Accept-Ranges"))&&"bytes"===e))g=c;var h=this;h.W(function(a){var e=a*g,i=(a+1)*g-1,i=Math.min(i,c-1);if("undefined"===typeof h.j[a]){var r=h.j;e>i&&b(Error("invalid range ("+e+", "+i+") or no bytes requested!"));i>c-1&&b(Error("only "+c+" bytes available! programmer error!"));var u=new XMLHttpRequest;u.open("GET",d,n);c!==g&&u.setRequestHeader("Range", +"bytes="+e+"-"+i);"undefined"!=typeof Uint8Array&&(u.responseType="arraybuffer");u.overrideMimeType&&u.overrideMimeType("text/plain; charset=x-user-defined");u.send(l);200<=u.status&&300>u.status||304===u.status||b(Error("Couldn't load "+d+". Status: "+u.status));e=u.response!==f?new Uint8Array(u.response||[]):lb(u.responseText||"",j);r[a]=e}"undefined"===typeof h.j[a]&&b(Error("doXHR failed!"));return h.j[a]});this.L=c;this.K=g;this.q=j};h=new h;Object.defineProperty(h,"length",{get:function(){this.q|| +this.s();return this.L}});Object.defineProperty(h,"chunkSize",{get:function(){this.q||this.s();return this.K}});h={f:n,d:h}}else h={f:n,url:d};return $b(a,c,h,e,g)};Module.FS_createLink=function(a,c,d,e,g){return $b(a,c,{f:n,link:d},e,g)};Module.FS_createDevice=bc;Kb=ya(4);q[Kb>>2]=0;pc.e=Xa(12,"void*",Va); +Module.requestFullScreen=function(a,c){function d(){vc=n;(document.webkitFullScreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.mozFullscreenElement||document.fullScreenElement||document.fullscreenElement)===e?(e.t=document.cancelFullScreen||document.mozCancelFullScreen||document.webkitCancelFullScreen,e.t=e.t.bind(document),yc&&e.r(),vc=j,zc&&Cc()):zc&&Dc();if(Module.onFullScreen)Module.onFullScreen(vc)}yc=a;zc=c;"undefined"===typeof yc&&(yc=j);"undefined"=== +typeof zc&&(zc=n);var e=Module.canvas;xc||(xc=j,document.addEventListener("fullscreenchange",d,n),document.addEventListener("mozfullscreenchange",d,n),document.addEventListener("webkitfullscreenchange",d,n));e.V=e.requestFullScreen||e.mozRequestFullScreen||(e.webkitRequestFullScreen?function(){e.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT)}:l);e.V()}; +Module.requestAnimationFrame=function(a){window.requestAnimationFrame||(window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame||window.oRequestAnimationFrame||window.setTimeout);window.requestAnimationFrame(a)};Module.pauseMainLoop=aa();Module.resumeMainLoop=function(){uc&&(uc=n,l())};Module.getUserMedia=function(){window.w||(window.w=navigator.getUserMedia||navigator.mozGetUserMedia);window.w(f)}; +cb=ka=Fa(za);db=cb+5242880;eb=Ba=Fa(db);qa(eb>3<<3;return b|0}function bQ(){return i|0}function bR(a){a=a|0;i=a}function bS(a,b){a=a|0;b=b|0;if((q|0)==0){q=a;r=b}}function bT(b){b=b|0;a[k]=a[b];a[k+1|0]=a[b+1|0];a[k+2|0]=a[b+2|0];a[k+3|0]=a[b+3|0]}function bU(b){b=b|0;a[k]=a[b];a[k+1|0]=a[b+1|0];a[k+2|0]=a[b+2|0];a[k+3|0]=a[b+3|0];a[k+4|0]=a[b+4|0];a[k+5|0]=a[b+5|0];a[k+6|0]=a[b+6|0];a[k+7|0]=a[b+7|0]}function bV(a){a=a|0;D=a}function bW(a){a=a|0;E=a}function bX(a){a=a|0;F=a}function bY(a){a=a|0;G=a}function bZ(a){a=a|0;H=a}function b_(a){a=a|0;I=a}function b$(a){a=a|0;J=a}function b0(a){a=a|0;K=a}function b1(a){a=a|0;L=a}function b2(a){a=a|0;M=a}function b3(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0;c[a>>2]=-1;b=a+12|0;c[b>>2]=16;c[a+8>>2]=0;d=vh(576)|0;e=a+4|0;c[e>>2]=d;vq(d|0,0,(c[b>>2]|0)*36&-1|0);d=(c[b>>2]|0)-1|0;if((d|0)>0){f=0;while(1){g=f+1|0;c[(c[e>>2]|0)+(f*36&-1)+20>>2]=g;c[(c[e>>2]|0)+(f*36&-1)+32>>2]=-1;h=(c[b>>2]|0)-1|0;if((g|0)<(h|0)){f=g}else{i=h;break}}}else{i=d}c[(c[e>>2]|0)+(i*36&-1)+20>>2]=-1;c[(c[e>>2]|0)+(((c[b>>2]|0)-1|0)*36&-1)+32>>2]=-1;vq(a+16|0,0,16);c[a+48>>2]=16;c[a+52>>2]=0;c[a+44>>2]=vh(192)|0;c[a+36>>2]=16;c[a+40>>2]=0;c[a+32>>2]=vh(64)|0;return}function b4(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0.0,k=0,l=0,m=0,n=0,o=0;e=a|0;f=cj(e)|0;h=a+4|0;i=(c[h>>2]|0)+(f*36&-1)|0;j=+(+g[b+4>>2]+-.10000000149011612);g[i>>2]=+g[b>>2]+-.10000000149011612;g[i+4>>2]=j;i=(c[h>>2]|0)+(f*36&-1)+8|0;j=+(+g[b+12>>2]+.10000000149011612);g[i>>2]=+g[b+8>>2]+.10000000149011612;g[i+4>>2]=j;c[(c[h>>2]|0)+(f*36&-1)+16>>2]=d;c[(c[h>>2]|0)+(f*36&-1)+32>>2]=0;ck(e,f);e=a+28|0;c[e>>2]=(c[e>>2]|0)+1;e=a+40|0;h=c[e>>2]|0;d=a+36|0;i=a+32|0;if((h|0)!=(c[d>>2]|0)){k=h;l=c[i>>2]|0;m=l+(k<<2)|0;c[m>>2]=f;n=c[e>>2]|0;o=n+1|0;c[e>>2]=o;return f|0}a=c[i>>2]|0;c[d>>2]=h<<1;d=vh(h<<3)|0;c[i>>2]=d;h=a;a=c[e>>2]<<2;vp(d|0,h|0,a)|0;vi(h);k=c[e>>2]|0;l=c[i>>2]|0;m=l+(k<<2)|0;c[m>>2]=f;n=c[e>>2]|0;o=n+1|0;c[e>>2]=o;return f|0}function b5(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0,j=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0,s=0.0,t=0,u=0,v=0,w=0,x=0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0;h=a+60|0;c[h>>2]=0;i=e+12|0;j=+g[f+12>>2];l=+g[i>>2];m=+g[f+8>>2];n=+g[e+16>>2];o=+g[f>>2]+(j*l-m*n)- +g[d>>2];p=l*m+j*n+ +g[f+4>>2]- +g[d+4>>2];n=+g[d+12>>2];j=+g[d+8>>2];m=o*n+p*j;l=n*p+o*(-0.0-j);j=+g[b+8>>2]+ +g[e+8>>2];e=c[b+148>>2]|0;do{if((e|0)>0){d=0;o=-3.4028234663852886e+38;f=0;while(1){p=(m- +g[b+20+(d<<3)>>2])*+g[b+84+(d<<3)>>2]+(l- +g[b+20+(d<<3)+4>>2])*+g[b+84+(d<<3)+4>>2];if(p>j){q=28;break}r=p>o;s=r?p:o;t=r?d:f;r=d+1|0;if((r|0)<(e|0)){d=r;o=s;f=t}else{q=12;break}}if((q|0)==12){u=s<1.1920928955078125e-7;v=t;break}else if((q|0)==28){return}}else{u=1;v=0}}while(0);q=v+1|0;t=b+20+(v<<3)|0;f=c[t>>2]|0;d=c[t+4>>2]|0;s=(c[k>>2]=f,+g[k>>2]);t=d;o=(c[k>>2]=t,+g[k>>2]);r=b+20+(((q|0)<(e|0)?q:0)<<3)|0;q=c[r>>2]|0;e=c[r+4>>2]|0;p=(c[k>>2]=q,+g[k>>2]);r=e;n=(c[k>>2]=r,+g[k>>2]);if(u){c[h>>2]=1;c[a+56>>2]=1;u=b+84+(v<<3)|0;w=a+40|0;x=c[u+4>>2]|0;c[w>>2]=c[u>>2];c[w+4>>2]=x;x=a+48|0;y=+((o+n)*.5);g[x>>2]=(s+p)*.5;g[x+4>>2]=y;x=i;w=a;u=c[x+4>>2]|0;c[w>>2]=c[x>>2];c[w+4>>2]=u;c[a+16>>2]=0;return}y=m-s;z=l-o;A=m-p;B=l-n;if(y*(p-s)+z*(n-o)<=0.0){if(y*y+z*z>j*j){return}c[h>>2]=1;c[a+56>>2]=1;u=a+40|0;w=u;C=+z;g[w>>2]=y;g[w+4>>2]=C;C=+P(+(y*y+z*z));if(C>=1.1920928955078125e-7){D=1.0/C;g[u>>2]=y*D;g[a+44>>2]=z*D}u=a+48|0;c[u>>2]=f&-1;c[u+4>>2]=t|d&0;d=i;t=a;u=c[d+4>>2]|0;c[t>>2]=c[d>>2];c[t+4>>2]=u;c[a+16>>2]=0;return}if(A*(s-p)+B*(o-n)>0.0){D=(s+p)*.5;p=(o+n)*.5;u=b+84+(v<<3)|0;if((m-D)*+g[u>>2]+(l-p)*+g[b+84+(v<<3)+4>>2]>j){return}c[h>>2]=1;c[a+56>>2]=1;v=u;u=a+40|0;b=c[v+4>>2]|0;c[u>>2]=c[v>>2];c[u+4>>2]=b;b=a+48|0;l=+p;g[b>>2]=D;g[b+4>>2]=l;b=i;u=a;v=c[b+4>>2]|0;c[u>>2]=c[b>>2];c[u+4>>2]=v;c[a+16>>2]=0;return}if(A*A+B*B>j*j){return}c[h>>2]=1;c[a+56>>2]=1;h=a+40|0;v=h;j=+B;g[v>>2]=A;g[v+4>>2]=j;j=+P(+(A*A+B*B));if(j>=1.1920928955078125e-7){l=1.0/j;g[h>>2]=A*l;g[a+44>>2]=B*l}h=a+48|0;c[h>>2]=q&-1;c[h+4>>2]=r|e&0;e=i;i=a;r=c[e+4>>2]|0;c[i>>2]=c[e>>2];c[i+4>>2]=r;c[a+16>>2]=0;return}function b6(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var i=0,j=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0,D=0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0;i=b+60|0;c[i>>2]=0;j=f+12|0;l=+g[h+12>>2];m=+g[j>>2];n=+g[h+8>>2];o=+g[f+16>>2];p=+g[h>>2]+(l*m-n*o)- +g[e>>2];q=m*n+l*o+ +g[h+4>>2]- +g[e+4>>2];o=+g[e+12>>2];l=+g[e+8>>2];n=p*o+q*l;m=o*q+p*(-0.0-l);e=d+12|0;h=c[e>>2]|0;r=c[e+4>>2]|0;l=(c[k>>2]=h,+g[k>>2]);e=r;p=(c[k>>2]=e,+g[k>>2]);s=d+20|0;t=c[s>>2]|0;u=c[s+4>>2]|0;q=(c[k>>2]=t,+g[k>>2]);s=u;o=(c[k>>2]=s,+g[k>>2]);v=q-l;w=o-p;x=v*(q-n)+w*(o-m);y=n-l;z=m-p;A=y*v+z*w;B=+g[d+8>>2]+ +g[f+8>>2];if(A<=0.0){if(y*y+z*z>B*B){return}do{if((a[d+44|0]&1)!=0){f=d+28|0;if((l-n)*(l- +g[f>>2])+(p-m)*(p- +g[f+4>>2])<=0.0){break}return}}while(0);c[i>>2]=1;c[b+56>>2]=0;g[b+40>>2]=0.0;g[b+44>>2]=0.0;f=b+48|0;c[f>>2]=h&-1;c[f+4>>2]=e|r&0;f=b+16|0;c[f>>2]=0;C=f;a[f]=0;a[C+1|0]=0;a[C+2|0]=0;a[C+3|0]=0;C=j;f=b;D=c[C+4>>2]|0;c[f>>2]=c[C>>2];c[f+4>>2]=D;return}if(x<=0.0){E=n-q;F=m-o;if(E*E+F*F>B*B){return}do{if((a[d+45|0]&1)!=0){D=d+36|0;if(E*(+g[D>>2]-q)+F*(+g[D+4>>2]-o)<=0.0){break}return}}while(0);c[i>>2]=1;c[b+56>>2]=0;g[b+40>>2]=0.0;g[b+44>>2]=0.0;d=b+48|0;c[d>>2]=t&-1;c[d+4>>2]=s|u&0;u=b+16|0;c[u>>2]=0;s=u;a[u]=1;a[s+1|0]=0;a[s+2|0]=0;a[s+3|0]=0;s=j;u=b;d=c[s+4>>2]|0;c[u>>2]=c[s>>2];c[u+4>>2]=d;return}F=v*v+w*w;if(F<=0.0){ba(12984,127,18976,12968)}E=1.0/F;F=n-(l*x+q*A)*E;q=m-(p*x+o*A)*E;if(F*F+q*q>B*B){return}B=-0.0-w;if(v*z+y*B<0.0){G=w;H=-0.0-v}else{G=B;H=v}v=+P(+(H*H+G*G));if(v<1.1920928955078125e-7){I=G;J=H}else{B=1.0/v;I=G*B;J=H*B}c[i>>2]=1;c[b+56>>2]=1;i=b+40|0;B=+J;g[i>>2]=I;g[i+4>>2]=B;i=b+48|0;c[i>>2]=h&-1;c[i+4>>2]=e|r&0;r=b+16|0;c[r>>2]=0;e=r;a[r]=0;a[e+1|0]=0;a[e+2|0]=1;a[e+3|0]=0;e=j;j=b;b=c[e+4>>2]|0;c[j>>2]=c[e>>2];c[j+4>>2]=b;return}function b7(b,d,e,f,h,j){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;var l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,Q=0,R=0,S=0,T=0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ab=0,ac=0.0,ad=0.0,ae=0,af=0.0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0,ao=0,ap=0,aq=0,ar=0,as=0,at=0,au=0.0,av=0,aw=0,ax=0,ay=0,az=0,aA=0,aB=0,aC=0,aD=0,aE=0,aF=0.0,aG=0.0,aH=0.0,aI=0.0,aJ=0,aK=0,aL=0,aM=0,aN=0,aO=0,aP=0,aQ=0,aR=0,aS=0,aT=0,aU=0.0,aV=0,aW=0,aX=0.0;l=i;i=i+40|0;m=l|0;n=l+16|0;o=n|0;p=n;q=i;i=i+24|0;r=i;i=i+24|0;s=r|0;t=r;u=b+132|0;v=+g[f+12>>2];w=+g[j+8>>2];x=+g[f+8>>2];y=+g[j+12>>2];z=v*w-x*y;A=w*x+v*y;y=+z;w=+A;B=+g[j>>2]- +g[f>>2];C=+g[j+4>>2]- +g[f+4>>2];D=v*B+x*C;E=B*(-0.0-x)+v*C;C=+E;f=u;g[f>>2]=D;g[f+4>>2]=C;f=b+140|0;g[f>>2]=y;g[f+4>>2]=w;f=b+144|0;w=+g[h+12>>2];j=b+140|0;y=+g[h+16>>2];F=u|0;C=D+(A*w-z*y);u=b+136|0;D=w*z+A*y+E;G=b+148|0;E=+D;g[G>>2]=C;g[G+4>>2]=E;G=e+28|0;H=b+156|0;I=c[G>>2]|0;J=c[G+4>>2]|0;c[H>>2]=I;c[H+4>>2]=J;H=e+12|0;G=b+164|0;K=c[H>>2]|0;L=c[H+4>>2]|0;c[G>>2]=K;c[G+4>>2]=L;H=e+20|0;M=b+172|0;N=c[H>>2]|0;O=c[H+4>>2]|0;c[M>>2]=N;c[M+4>>2]=O;H=e+36|0;Q=b+180|0;R=c[H>>2]|0;S=c[H+4>>2]|0;c[Q>>2]=R;c[Q+4>>2]=S;Q=a[e+44|0]&1;H=Q<<24>>24!=0;T=a[e+45|0]|0;e=(T&1)!=0;E=(c[k>>2]=N,+g[k>>2]);y=(c[k>>2]=K,+g[k>>2]);A=E-y;z=(c[k>>2]=O,+g[k>>2]);O=b+168|0;w=(c[k>>2]=L,+g[k>>2]);v=z-w;x=+P(+(A*A+v*v));B=(c[k>>2]=I,+g[k>>2]);U=(c[k>>2]=J,+g[k>>2]);V=(c[k>>2]=R,+g[k>>2]);W=(c[k>>2]=S,+g[k>>2]);if(x<1.1920928955078125e-7){X=A;Y=v}else{Z=1.0/x;X=A*Z;Y=v*Z}S=b+196|0;Z=-0.0-X;R=S|0;g[R>>2]=Y;J=b+200|0;g[J>>2]=Z;v=(C-y)*Y+(D-w)*Z;if(H){Z=y-B;y=w-U;w=+P(+(Z*Z+y*y));if(w<1.1920928955078125e-7){_=Z;$=y}else{A=1.0/w;_=Z*A;$=y*A}A=-0.0-_;g[b+188>>2]=$;g[b+192>>2]=A;aa=(C-B)*$+(D-U)*A;ab=Y*_-X*$>=0.0}else{aa=0.0;ab=0}L93:do{if(e){$=V-E;_=W-z;A=+P(+($*$+_*_));if(A<1.1920928955078125e-7){ac=$;ad=_}else{U=1.0/A;ac=$*U;ad=_*U}U=-0.0-ac;I=b+204|0;g[I>>2]=ad;L=b+208|0;g[L>>2]=U;K=X*ad-Y*ac>0.0;_=(C-E)*ad+(D-z)*U;if((Q&T)<<24>>24==0){ae=K;af=_;ag=100;break}if(ab&K){do{if(aa<0.0&v<0.0){N=_>=0.0;a[b+248|0]=N&1;ah=b+212|0;if(N){ai=ah;break}N=ah;U=+(-0.0-Y);$=+X;g[N>>2]=U;g[N+4>>2]=$;N=b+228|0;g[N>>2]=U;g[N+4>>2]=$;N=b+236|0;g[N>>2]=U;g[N+4>>2]=$;break L93}else{a[b+248|0]=1;ai=b+212|0}}while(0);N=S;ah=ai;aj=c[N+4>>2]|0;c[ah>>2]=c[N>>2];c[ah+4>>2]=aj;aj=b+188|0;ah=b+228|0;N=c[aj+4>>2]|0;c[ah>>2]=c[aj>>2];c[ah+4>>2]=N;N=b+204|0;ah=b+236|0;aj=c[N+4>>2]|0;c[ah>>2]=c[N>>2];c[ah+4>>2]=aj;break}if(ab){do{if(aa<0.0){if(v<0.0){a[b+248|0]=0;ak=b+212|0}else{aj=_>=0.0;a[b+248|0]=aj&1;ah=b+212|0;if(aj){al=ah;break}else{ak=ah}}ah=ak;$=+X;g[ah>>2]=-0.0-Y;g[ah+4>>2]=$;ah=b+228|0;$=+(-0.0- +g[L>>2]);g[ah>>2]=-0.0- +g[I>>2];g[ah+4>>2]=$;ah=b+236|0;$=+(-0.0- +g[J>>2]);g[ah>>2]=-0.0- +g[R>>2];g[ah+4>>2]=$;break L93}else{a[b+248|0]=1;al=b+212|0}}while(0);ah=S;aj=al;N=c[ah+4>>2]|0;c[aj>>2]=c[ah>>2];c[aj+4>>2]=N;N=b+188|0;aj=b+228|0;am=c[N+4>>2]|0;c[aj>>2]=c[N>>2];c[aj+4>>2]=am;am=b+236|0;aj=c[ah+4>>2]|0;c[am>>2]=c[ah>>2];c[am+4>>2]=aj;break}if(!K){do{if(aa<0.0|v<0.0){a[b+248|0]=0;an=b+212|0}else{aj=_>=0.0;a[b+248|0]=aj&1;am=b+212|0;if(!aj){an=am;break}aj=S;ah=am;am=c[aj>>2]|0;N=c[aj+4>>2]|0;c[ah>>2]=am;c[ah+4>>2]=N;ah=b+228|0;c[ah>>2]=am;c[ah+4>>2]=N;ah=b+236|0;c[ah>>2]=am;c[ah+4>>2]=N;break L93}}while(0);K=an;$=+X;g[K>>2]=-0.0-Y;g[K+4>>2]=$;K=b+228|0;$=+(-0.0- +g[L>>2]);g[K>>2]=-0.0- +g[I>>2];g[K+4>>2]=$;K=b+236|0;$=+(-0.0- +g[b+192>>2]);g[K>>2]=-0.0- +g[b+188>>2];g[K+4>>2]=$;break}do{if(_<0.0){if(aa<0.0){a[b+248|0]=0;ao=b+212|0}else{K=v>=0.0;a[b+248|0]=K&1;N=b+212|0;if(K){ap=N;break}else{ao=N}}N=ao;$=+X;g[N>>2]=-0.0-Y;g[N+4>>2]=$;N=b+228|0;$=+(-0.0- +g[J>>2]);g[N>>2]=-0.0- +g[R>>2];g[N+4>>2]=$;N=b+236|0;$=+(-0.0- +g[b+192>>2]);g[N>>2]=-0.0- +g[b+188>>2];g[N+4>>2]=$;break L93}else{a[b+248|0]=1;ap=b+212|0}}while(0);I=S;L=ap;N=c[I+4>>2]|0;c[L>>2]=c[I>>2];c[L+4>>2]=N;N=b+228|0;L=c[I+4>>2]|0;c[N>>2]=c[I>>2];c[N+4>>2]=L;L=b+204|0;N=b+236|0;I=c[L+4>>2]|0;c[N>>2]=c[L>>2];c[N+4>>2]=I}else{ae=0;af=0.0;ag=100}}while(0);L134:do{if((ag|0)==100){if(H){ap=aa>=0.0;if(ab){do{if(ap){a[b+248|0]=1;aq=b+212|0}else{ao=v>=0.0;a[b+248|0]=ao&1;an=b+212|0;if(ao){aq=an;break}ao=an;an=0;z=+X;c[ao>>2]=an|(g[k>>2]=-0.0-Y,c[k>>2]|0);g[ao+4>>2]=z;ao=S;al=b+228|0;ak=c[ao>>2]|0;ai=c[ao+4>>2]|0;c[al>>2]=ak;c[al+4>>2]=ai;ai=b+236|0;c[ai>>2]=an|(g[k>>2]=-0.0-(c[k>>2]=ak,+g[k>>2]),c[k>>2]|0);g[ai+4>>2]=z;break L134}}while(0);ai=S;ak=aq;an=c[ai+4>>2]|0;c[ak>>2]=c[ai>>2];c[ak+4>>2]=an;an=b+188|0;ak=b+228|0;ai=c[an+4>>2]|0;c[ak>>2]=c[an>>2];c[ak+4>>2]=ai;ai=b+236|0;z=+(-0.0- +g[J>>2]);g[ai>>2]=-0.0- +g[R>>2];g[ai+4>>2]=z;break}else{do{if(ap){ai=v>=0.0;a[b+248|0]=ai&1;ak=b+212|0;if(!ai){ar=ak;break}ai=S;an=ak;ak=c[ai>>2]|0;al=c[ai+4>>2]|0;c[an>>2]=ak;c[an+4>>2]=al;an=b+228|0;c[an>>2]=ak;c[an+4>>2]=al;al=b+236|0;z=+X;g[al>>2]=-0.0-(c[k>>2]=ak,+g[k>>2]);g[al+4>>2]=z;break L134}else{a[b+248|0]=0;ar=b+212|0}}while(0);ap=ar;z=+X;g[ap>>2]=-0.0-Y;g[ap+4>>2]=z;ap=S;al=b+228|0;ak=c[ap+4>>2]|0;c[al>>2]=c[ap>>2];c[al+4>>2]=ak;ak=b+236|0;z=+(-0.0- +g[b+192>>2]);g[ak>>2]=-0.0- +g[b+188>>2];g[ak+4>>2]=z;break}}ak=v>=0.0;if(!e){a[b+248|0]=ak&1;al=b+212|0;if(ak){ap=S;an=al;ai=c[ap>>2]|0;ao=c[ap+4>>2]|0;c[an>>2]=ai;c[an+4>>2]=ao;ao=b+228|0;z=+(-0.0-(c[k>>2]=ai,+g[k>>2]));D=+X;g[ao>>2]=z;g[ao+4>>2]=D;ao=b+236|0;g[ao>>2]=z;g[ao+4>>2]=D;break}else{ao=al;D=+X;g[ao>>2]=-0.0-Y;g[ao+4>>2]=D;ao=S;al=b+228|0;ai=c[ao>>2]|0;an=c[ao+4>>2]|0;c[al>>2]=ai;c[al+4>>2]=an;al=b+236|0;c[al>>2]=ai;c[al+4>>2]=an;break}}if(ae){do{if(ak){a[b+248|0]=1;as=b+212|0}else{an=af>=0.0;a[b+248|0]=an&1;al=b+212|0;if(an){as=al;break}an=al;D=+(-0.0-Y);z=+X;g[an>>2]=D;g[an+4>>2]=z;an=b+228|0;g[an>>2]=D;g[an+4>>2]=z;an=S;al=b+236|0;ai=c[an+4>>2]|0;c[al>>2]=c[an>>2];c[al+4>>2]=ai;break L134}}while(0);ai=S;al=as;an=c[ai+4>>2]|0;c[al>>2]=c[ai>>2];c[al+4>>2]=an;an=b+228|0;z=+(-0.0- +g[J>>2]);g[an>>2]=-0.0- +g[R>>2];g[an+4>>2]=z;an=b+204|0;al=b+236|0;ai=c[an+4>>2]|0;c[al>>2]=c[an>>2];c[al+4>>2]=ai;break}else{do{if(ak){ai=af>=0.0;a[b+248|0]=ai&1;al=b+212|0;if(!ai){at=al;break}ai=S;an=al;al=c[ai>>2]|0;ao=c[ai+4>>2]|0;c[an>>2]=al;c[an+4>>2]=ao;an=b+228|0;z=+X;g[an>>2]=-0.0-(c[k>>2]=al,+g[k>>2]);g[an+4>>2]=z;an=b+236|0;c[an>>2]=al;c[an+4>>2]=ao;break L134}else{a[b+248|0]=0;at=b+212|0}}while(0);ak=at;z=+X;g[ak>>2]=-0.0-Y;g[ak+4>>2]=z;ak=b+228|0;z=+(-0.0- +g[b+208>>2]);g[ak>>2]=-0.0- +g[b+204>>2];g[ak+4>>2]=z;ak=S;ao=b+236|0;an=c[ak+4>>2]|0;c[ao>>2]=c[ak>>2];c[ao+4>>2]=an;break}}}while(0);at=h+148|0;as=b+128|0;c[as>>2]=c[at>>2];if((c[at>>2]|0)>0){ae=0;do{Y=+g[f>>2];X=+g[h+20+(ae<<3)>>2];af=+g[j>>2];v=+g[h+20+(ae<<3)+4>>2];e=b+(ae<<3)|0;aa=+(X*af+Y*v+ +g[u>>2]);g[e>>2]=+g[F>>2]+(Y*X-af*v);g[e+4>>2]=aa;aa=+g[f>>2];v=+g[h+84+(ae<<3)>>2];af=+g[j>>2];X=+g[h+84+(ae<<3)+4>>2];e=b+64+(ae<<3)|0;Y=+(v*af+aa*X);g[e>>2]=aa*v-af*X;g[e+4>>2]=Y;ae=ae+1|0;}while((ae|0)<(c[at>>2]|0))}at=b+244|0;g[at>>2]=.019999999552965164;ae=d+60|0;c[ae>>2]=0;e=b+248|0;ar=c[as>>2]|0;if((ar|0)>0){Y=+g[b+164>>2];X=+g[O>>2];af=+g[b+212>>2];v=+g[b+216>>2];O=0;aa=3.4028234663852886e+38;while(1){z=af*(+g[b+(O<<3)>>2]-Y)+v*(+g[b+(O<<3)+4>>2]-X);D=z+g[at>>2]){i=l;return}b8(m,b);O=c[m>>2]|0;do{if((O|0)==0){ag=136}else{aa=+g[m+8>>2];if(aa>+g[at>>2]){i=l;return}if(aa<=au*.9800000190734863+.0010000000474974513){ag=136;break}ar=c[m+4>>2]|0;aq=n;ab=d+56|0;if((O|0)==1){av=aq;aw=ab;ag=138;break}c[ab>>2]=2;ab=c[G>>2]|0;H=c[G+4>>2]|0;c[o>>2]=ab;c[o+4>>2]=H;an=n+8|0;ao=an;a[an]=0;an=ar&255;a[ao+1|0]=an;a[ao+2|0]=0;a[ao+3|0]=1;ao=p+12|0;ak=c[M>>2]|0;al=c[M+4>>2]|0;c[ao>>2]=ak;c[ao+4>>2]=al;ao=p+20|0;ai=ao;a[ao]=0;a[ai+1|0]=an;a[ai+2|0]=0;a[ai+3|0]=1;ai=ar+1|0;ao=(ai|0)<(c[as>>2]|0)?ai:0;ai=b+(ar<<3)|0;ap=b+(ao<<3)|0;T=b+64+(ar<<3)|0;ax=ar;ay=ao&255;az=c[T>>2]|0;aA=c[T+4>>2]|0;aB=c[ap>>2]|0;aC=c[ap+4>>2]|0;aD=c[ai>>2]|0;aE=c[ai+4>>2]|0;aF=(c[k>>2]=ak,+g[k>>2]);aG=(c[k>>2]=ab,+g[k>>2]);aH=(c[k>>2]=al,+g[k>>2]);aI=(c[k>>2]=H,+g[k>>2]);aJ=an;aK=0;aL=aq}}while(0);if((ag|0)==136){av=n;aw=d+56|0;ag=138}do{if((ag|0)==138){c[aw>>2]=1;O=c[as>>2]|0;if((O|0)>1){au=+g[b+216>>2];aa=+g[b+212>>2];m=0;X=aa*+g[b+64>>2]+au*+g[b+68>>2];aq=1;while(1){v=aa*+g[b+64+(aq<<3)>>2]+au*+g[b+64+(aq<<3)+4>>2];an=v>2]|0;al=c[aq+4>>2]|0;c[o>>2]=H;c[o+4>>2]=al;aq=n+8|0;an=aq;a[aq]=0;aq=aM&255;a[an+1|0]=aq;a[an+2|0]=1;a[an+3|0]=0;an=b+(m<<3)|0;ab=p+12|0;ak=c[an>>2]|0;ai=c[an+4>>2]|0;c[ab>>2]=ak;c[ab+4>>2]=ai;ab=p+20|0;an=ab;a[ab]=0;a[an+1|0]=m&255;a[an+2|0]=1;a[an+3|0]=0;X=(c[k>>2]=H,+g[k>>2]);au=(c[k>>2]=al,+g[k>>2]);aa=(c[k>>2]=ak,+g[k>>2]);v=(c[k>>2]=ai,+g[k>>2]);if((a[e]&1)==0){ax=1;ay=0;az=(g[k>>2]=-0.0- +g[R>>2],c[k>>2]|0);aA=(g[k>>2]=-0.0- +g[J>>2],c[k>>2]|0);aB=c[G>>2]|0;aC=c[G+4>>2]|0;aD=c[M>>2]|0;aE=c[M+4>>2]|0;aF=aa;aG=X;aH=v;aI=au;aJ=aq;aK=1;aL=av;break}else{ai=S;ax=0;ay=1;az=c[ai>>2]|0;aA=c[ai+4>>2]|0;aB=c[M>>2]|0;aC=c[M+4>>2]|0;aD=c[G>>2]|0;aE=c[G+4>>2]|0;aF=aa;aG=X;aH=v;aI=au;aJ=aq;aK=1;aL=av;break}}}while(0);au=(c[k>>2]=az,+g[k>>2]);v=(c[k>>2]=aA,+g[k>>2]);X=(c[k>>2]=aD,+g[k>>2]);aa=(c[k>>2]=aE,+g[k>>2]);Y=-0.0-au;af=X*v+aa*Y;D=-0.0-v;z=(c[k>>2]=aB,+g[k>>2])*D+(c[k>>2]=aC,+g[k>>2])*au;ad=v*aG+aI*Y-af;E=v*aF+aH*Y-af;if(ad>0.0){aN=0}else{aC=q;aB=n;c[aC>>2]=c[aB>>2];c[aC+4>>2]=c[aB+4>>2];c[aC+8>>2]=c[aB+8>>2];aN=1}if(E>0.0){aO=aN}else{aB=q+(aN*12&-1)|0;aC=aL+12|0;c[aB>>2]=c[aC>>2];c[aB+4>>2]=c[aC+4>>2];c[aB+8>>2]=c[aC+8>>2];aO=aN+1|0}if(ad*E<0.0){af=ad/(ad-E);aN=q+(aO*12&-1)|0;E=+(aI+af*(aH-aI));g[aN>>2]=aG+af*(aF-aG);g[aN+4>>2]=E;aN=q+(aO*12&-1)+8|0;aC=aN;a[aN]=ax&255;a[aC+1|0]=aJ;a[aC+2|0]=0;a[aC+3|0]=1;aP=aO+1|0}else{aP=aO}if((aP|0)<2){i=l;return}E=+g[q>>2];aG=+g[q+4>>2];aF=E*D+au*aG-z;aP=q+12|0;af=+g[aP>>2];aI=+g[q+16>>2];aH=af*D+au*aI-z;if(aF>0.0){aQ=0}else{aO=r;aC=q;c[aO>>2]=c[aC>>2];c[aO+4>>2]=c[aC+4>>2];c[aO+8>>2]=c[aC+8>>2];aQ=1}if(aH>0.0){aR=aQ}else{aC=t+(aQ*12&-1)|0;aO=aP;c[aC>>2]=c[aO>>2];c[aC+4>>2]=c[aO+4>>2];c[aC+8>>2]=c[aO+8>>2];aR=aQ+1|0}if(aF*aH<0.0){z=aF/(aF-aH);aQ=t+(aR*12&-1)|0;aH=+(aG+z*(aI-aG));g[aQ>>2]=E+z*(af-E);g[aQ+4>>2]=aH;aQ=t+(aR*12&-1)+8|0;aO=aQ;a[aQ]=ay;a[aO+1|0]=a[q+9|0]|0;a[aO+2|0]=0;a[aO+3|0]=1;aS=aR+1|0}else{aS=aR}if((aS|0)<2){i=l;return}aS=d+40|0;do{if(aK){aR=aS;c[aR>>2]=az;c[aR+4>>2]=aA;aR=d+48|0;c[aR>>2]=aD;c[aR+4>>2]=aE;aH=+g[r>>2];E=+g[t+4>>2];af=+g[at>>2];if(au*(aH-X)+v*(E-aa)>af){aT=0;aU=af}else{af=aH- +g[F>>2];aH=E- +g[u>>2];E=+g[f>>2];z=+g[j>>2];aR=d;aG=+(E*aH+af*(-0.0-z));g[aR>>2]=af*E+aH*z;g[aR+4>>2]=aG;c[d+16>>2]=c[r+8>>2];aT=1;aU=+g[at>>2]}aG=+g[t+12>>2];z=+g[r+16>>2];if(au*(aG-X)+v*(z-aa)>aU){aV=aT;break}aH=aG- +g[F>>2];aG=z- +g[u>>2];z=+g[f>>2];E=+g[j>>2];aR=d+(aT*20&-1)|0;af=+(z*aG+aH*(-0.0-E));g[aR>>2]=aH*z+aG*E;g[aR+4>>2]=af;c[d+(aT*20&-1)+16>>2]=c[t+20>>2];aV=aT+1|0}else{aR=h+84+(ax<<3)|0;aO=aS;q=c[aR+4>>2]|0;c[aO>>2]=c[aR>>2];c[aO+4>>2]=q;q=h+20+(ax<<3)|0;aO=d+48|0;aR=c[q+4>>2]|0;c[aO>>2]=c[q>>2];c[aO+4>>2]=aR;af=+g[at>>2];if(au*(+g[r>>2]-X)+v*(+g[t+4>>2]-aa)>af){aW=0;aX=af}else{aR=d;aO=c[s+4>>2]|0;c[aR>>2]=c[s>>2];c[aR+4>>2]=aO;aO=r+8|0;aR=aO;q=d+16|0;ay=q;a[ay+2|0]=a[aR+3|0]|0;a[ay+3|0]=a[aR+2|0]|0;a[q]=a[aR+1|0]|0;a[ay+1|0]=a[aO]|0;aW=1;aX=+g[at>>2]}aO=t+12|0;if(au*(+g[aO>>2]-X)+v*(+g[r+16>>2]-aa)>aX){aV=aW;break}ay=aO;aO=d+(aW*20&-1)|0;aR=c[ay+4>>2]|0;c[aO>>2]=c[ay>>2];c[aO+4>>2]=aR;aR=t+20|0;aO=aR;ay=d+(aW*20&-1)+16|0;q=ay;a[q+2|0]=a[aO+3|0]|0;a[q+3|0]=a[aO+2|0]|0;a[ay]=a[aO+1|0]|0;a[q+1|0]=a[aR]|0;aV=aW+1|0}}while(0);c[ae>>2]=aV;i=l;return}function b8(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0,q=0,r=0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0,D=0.0,E=0;d=a|0;c[d>>2]=0;e=a+4|0;c[e>>2]=-1;f=a+8|0;g[f>>2]=-3.4028234663852886e+38;h=+g[b+216>>2];i=+g[b+212>>2];a=c[b+128>>2]|0;if((a|0)<=0){return}j=+g[b+164>>2];k=+g[b+168>>2];l=+g[b+172>>2];m=+g[b+176>>2];n=+g[b+244>>2];o=b+228|0;p=b+232|0;q=b+236|0;r=b+240|0;s=0;t=-3.4028234663852886e+38;while(1){u=+g[b+64+(s<<3)>>2];v=-0.0-u;w=-0.0- +g[b+64+(s<<3)+4>>2];x=+g[b+(s<<3)>>2];y=+g[b+(s<<3)+4>>2];z=(x-j)*v+(y-k)*w;A=(x-l)*v+(y-m)*w;B=zn){break}if(h*u+i*w<0.0){if((v- +g[o>>2])*i+(w- +g[p>>2])*h>=-.03490658849477768&B>t){C=182}else{D=t}}else{if((v- +g[q>>2])*i+(w- +g[r>>2])*h>=-.03490658849477768&B>t){C=182}else{D=t}}if((C|0)==182){C=0;c[d>>2]=2;c[e>>2]=s;g[f>>2]=B;D=B}E=s+1|0;if((E|0)<(a|0)){s=E;t=D}else{C=186;break}}if((C|0)==186){return}c[d>>2]=2;c[e>>2]=s;g[f>>2]=B;return}function b9(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0,t=0,u=0,v=0,w=0,x=0,y=0.0,z=0,A=0.0,B=0;h=c[b+148>>2]|0;i=+g[f+12>>2];j=+g[e+12>>2];k=+g[f+8>>2];l=+g[e+16>>2];m=+g[d+12>>2];n=+g[b+12>>2];o=+g[d+8>>2];p=+g[b+16>>2];q=+g[f>>2]+(i*j-k*l)-(+g[d>>2]+(m*n-o*p));r=j*k+i*l+ +g[f+4>>2]-(n*o+m*p+ +g[d+4>>2]);p=m*q+o*r;n=m*r+q*(-0.0-o);if((h|0)>0){s=0;o=-3.4028234663852886e+38;t=0;while(1){q=p*+g[b+84+(s<<3)>>2]+n*+g[b+84+(s<<3)+4>>2];u=q>o;v=u?s:t;w=s+1|0;if((w|0)<(h|0)){s=w;o=u?q:o;t=v}else{x=v;break}}}else{x=0}o=+cb(b,d,x,e,f);t=((x|0)>0?x:h)-1|0;n=+cb(b,d,t,e,f);s=x+1|0;v=(s|0)<(h|0)?s:0;p=+cb(b,d,v,e,f);if(n>o&n>p){q=n;s=t;while(1){t=((s|0)>0?s:h)-1|0;n=+cb(b,d,t,e,f);if(n>q){q=n;s=t}else{y=q;z=s;break}}c[a>>2]=z;return+y}if(p>o){A=p;B=v}else{y=o;z=x;c[a>>2]=z;return+y}while(1){x=B+1|0;v=(x|0)<(h|0)?x:0;o=+cb(b,d,v,e,f);if(o>A){A=o;B=v}else{y=A;z=B;break}}c[a>>2]=z;return+y}function ca(b,d,e,f,h){b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;var j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0,B=0,C=0,D=0,E=0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0,O=0,Q=0.0,R=0.0,S=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0;j=i;i=i+40|0;k=j|0;l=j+8|0;m=j+16|0;n=m|0;o=i;i=i+24|0;p=i;i=i+24|0;q=b+60|0;c[q>>2]=0;r=+g[d+8>>2]+ +g[f+8>>2];c[k>>2]=0;s=+b9(k,d,e,f,h);if(s>r){i=j;return}c[l>>2]=0;t=+b9(l,f,h,d,e);if(t>r){i=j;return}if(t>s*.9800000190734863+.0010000000474974513){s=+g[h>>2];t=+g[h+4>>2];u=+g[h+8>>2];v=+g[h+12>>2];w=+g[e>>2];x=+g[e+4>>2];y=+g[e+8>>2];z=+g[e+12>>2];A=c[l>>2]|0;c[b+56>>2]=2;B=f;C=d;D=A;E=1;F=w;G=x;H=y;I=z;J=s;K=t;L=u;M=v}else{v=+g[e>>2];u=+g[e+4>>2];t=+g[e+8>>2];s=+g[e+12>>2];z=+g[h>>2];y=+g[h+4>>2];x=+g[h+8>>2];w=+g[h+12>>2];h=c[k>>2]|0;c[b+56>>2]=1;B=d;C=f;D=h;E=0;F=z;G=y;H=x;I=w;J=v;K=u;L=t;M=s}h=m;f=c[C+148>>2]|0;if((D|0)<=-1){ba(10264,151,18656,11704)}d=c[B+148>>2]|0;if((d|0)<=(D|0)){ba(10264,151,18656,11704)}s=+g[B+84+(D<<3)>>2];t=+g[B+84+(D<<3)+4>>2];u=M*s-L*t;v=L*s+M*t;t=I*u+H*v;s=-0.0-H;w=I*v+u*s;if((f|0)>0){k=0;u=3.4028234663852886e+38;e=0;while(1){v=t*+g[C+84+(k<<3)>>2]+w*+g[C+84+(k<<3)+4>>2];A=v>2];w=+g[C+20+(O<<3)+4>>2];t=F+(I*u-H*w);v=G+(H*u+I*w);w=+v;g[n>>2]=t;g[n+4>>2]=w;n=D&255;e=m+8|0;f=e;a[e]=n;e=O&255;a[f+1|0]=e;a[f+2|0]=1;a[f+3|0]=0;f=h+12|0;w=+g[C+20+(k<<3)>>2];u=+g[C+20+(k<<3)+4>>2];x=F+(I*w-H*u);y=G+(H*w+I*u);C=f;u=+y;g[C>>2]=x;g[C+4>>2]=u;C=h+20|0;h=C;a[C]=n;a[h+1|0]=k&255;a[h+2|0]=1;a[h+3|0]=0;h=D+1|0;k=(h|0)<(d|0)?h:0;h=B+20+(D<<3)|0;u=+g[h>>2];w=+g[h+4>>2];h=B+20+(k<<3)|0;z=+g[h>>2];Q=+g[h+4>>2];R=z-u;S=Q-w;T=+P(+(R*R+S*S));if(T<1.1920928955078125e-7){U=R;V=S}else{W=1.0/T;U=R*W;V=S*W}W=M*U-L*V;S=M*V+L*U;R=W*-1.0;T=J+(M*u-L*w);X=K+(L*u+M*w);Y=T*S+X*R;Z=r-(T*W+X*S);X=r+((J+(M*z-L*Q))*W+(K+(L*z+M*Q))*S);M=-0.0-W;L=-0.0-S;K=t*M+v*L-Z;J=x*M+y*L-Z;if(K>0.0){_=0}else{h=o;B=m;c[h>>2]=c[B>>2];c[h+4>>2]=c[B+4>>2];c[h+8>>2]=c[B+8>>2];_=1}if(J>0.0){$=_}else{B=o+(_*12&-1)|0;h=f;c[B>>2]=c[h>>2];c[B+4>>2]=c[h+4>>2];c[B+8>>2]=c[h+8>>2];$=_+1|0}if(K*J<0.0){Z=K/(K-J);_=o+($*12&-1)|0;J=+(v+Z*(y-v));g[_>>2]=t+Z*(x-t);g[_+4>>2]=J;_=o+($*12&-1)+8|0;h=_;a[_]=n;a[h+1|0]=e;a[h+2|0]=0;a[h+3|0]=1;aa=$+1|0}else{aa=$}if((aa|0)<2){i=j;return}J=+g[o>>2];t=+g[o+4>>2];x=W*J+S*t-X;aa=o+12|0;Z=+g[aa>>2];v=+g[o+16>>2];y=W*Z+S*v-X;if(x>0.0){ab=0}else{$=p;h=o;c[$>>2]=c[h>>2];c[$+4>>2]=c[h+4>>2];c[$+8>>2]=c[h+8>>2];ab=1}if(y>0.0){ac=ab}else{h=p+(ab*12&-1)|0;$=aa;c[h>>2]=c[$>>2];c[h+4>>2]=c[$+4>>2];c[h+8>>2]=c[$+8>>2];ac=ab+1|0}if(x*y<0.0){X=x/(x-y);ab=p+(ac*12&-1)|0;y=+(t+X*(v-t));g[ab>>2]=J+X*(Z-J);g[ab+4>>2]=y;ab=p+(ac*12&-1)+8|0;$=ab;a[ab]=k&255;a[$+1|0]=a[o+9|0]|0;a[$+2|0]=0;a[$+3|0]=1;ad=ac+1|0}else{ad=ac}if((ad|0)<2){i=j;return}ad=b+40|0;y=+(U*-1.0);g[ad>>2]=V;g[ad+4>>2]=y;ad=b+48|0;y=+((w+Q)*.5);g[ad>>2]=(u+z)*.5;g[ad+4>>2]=y;y=+g[p>>2];z=+g[p+4>>2];ad=S*y+R*z-Y>r;do{if(E<<24>>24==0){if(ad){ae=0}else{u=y-F;Q=z-G;ac=b;w=+(u*s+I*Q);g[ac>>2]=I*u+H*Q;g[ac+4>>2]=w;c[b+16>>2]=c[p+8>>2];ae=1}w=+g[p+12>>2];Q=+g[p+16>>2];if(S*w+R*Q-Y>r){af=ae;break}u=w-F;w=Q-G;ac=b+(ae*20&-1)|0;Q=+(u*s+I*w);g[ac>>2]=I*u+H*w;g[ac+4>>2]=Q;c[b+(ae*20&-1)+16>>2]=c[p+20>>2];af=ae+1|0}else{if(ad){ag=0}else{Q=y-F;w=z-G;ac=b;u=+(Q*s+I*w);g[ac>>2]=I*Q+H*w;g[ac+4>>2]=u;ac=b+16|0;$=c[p+8>>2]|0;c[ac>>2]=$;o=ac;a[ac]=$>>>8&255;a[o+1|0]=$&255;a[o+2|0]=$>>>24&255;a[o+3|0]=$>>>16&255;ag=1}u=+g[p+12>>2];w=+g[p+16>>2];if(S*u+R*w-Y>r){af=ag;break}Q=u-F;u=w-G;$=b+(ag*20&-1)|0;w=+(Q*s+I*u);g[$>>2]=I*Q+H*u;g[$+4>>2]=w;$=b+(ag*20&-1)+16|0;o=c[p+20>>2]|0;c[$>>2]=o;ac=$;a[$]=o>>>8&255;a[ac+1|0]=o&255;a[ac+2|0]=o>>>24&255;a[ac+3|0]=o>>>16&255;af=ag+1|0}}while(0);c[q>>2]=af;i=j;return}function cb(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0.0,s=0,t=0.0,u=0,v=0,w=0,x=0;h=c[e+148>>2]|0;if((d|0)<=-1){ba(10264,32,18800,11704);return 0.0}if((c[a+148>>2]|0)<=(d|0)){ba(10264,32,18800,11704);return 0.0}i=+g[b+12>>2];j=+g[a+84+(d<<3)>>2];k=+g[b+8>>2];l=+g[a+84+(d<<3)+4>>2];m=i*j-k*l;n=j*k+i*l;l=+g[f+12>>2];j=+g[f+8>>2];o=l*m+j*n;p=l*n+m*(-0.0-j);if((h|0)>0){q=0;r=3.4028234663852886e+38;s=0;while(1){t=o*+g[e+20+(q<<3)>>2]+p*+g[e+20+(q<<3)+4>>2];u=t>2];p=+g[a+20+(d<<3)+4>>2];o=+g[e+20+(x<<3)>>2];t=+g[e+20+(x<<3)+4>>2];return+(m*(+g[f>>2]+(l*o-j*t)-(+g[b>>2]+(i*r-k*p)))+n*(o*j+l*t+ +g[f+4>>2]-(r*k+i*p+ +g[b+4>>2])))}function cc(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0,y=0.0,z=0.0,A=0.0,B=0.0;e=i;i=i+8|0;f=e|0;h=d;j=+g[h>>2];k=+g[d+8>>2]-j;l=+g[d+12>>2]- +g[d+4>>2];m=+g[h+4>>2];if(k>0.0){n=k}else{n=-0.0-k}if(l>0.0){o=l}else{o=-0.0-l}h=a|0;p=a+8|0;a=f;q=f+4|0;do{if(n<1.1920928955078125e-7){if(j<+g[h>>2]){r=0;i=e;return r|0}if(+g[p>>2]>2]-j);w=u*(+g[p>>2]-j);x=v>w;u=x?w:v;y=x?v:w;if(u>-3.4028234663852886e+38){g[q>>2]=0.0;g[a>>2]=x?1.0:-1.0;z=u}else{z=-3.4028234663852886e+38}u=y>3.4028234663852886e+38?3.4028234663852886e+38:y;if(z>u){r=0}else{s=u;t=z;break}i=e;return r|0}}while(0);do{if(o<1.1920928955078125e-7){if(m<+g[h+4>>2]){r=0;i=e;return r|0}if(+g[p+4>>2]>2]-m);k=z*(+g[p+4>>2]-m);q=j>k;z=q?k:j;n=q?j:k;if(z>t){g[a>>2]=0.0;g[a+4>>2]=q?1.0:-1.0;B=z}else{B=t}if(B>(s>2]>2]=A;d=b;b=c[f+4>>2]|0;c[d>>2]=c[f>>2];c[d+4>>2]=b;r=1;i=e;return r|0}function cd(a,b,d,e,f,h){a=a|0;b=b|0;d=d|0;e=+e;f=f|0;h=+h;var i=0,j=0,k=0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0;i=b+60|0;if((c[i>>2]|0)==0){return}j=c[b+56>>2]|0;if((j|0)==0){k=a|0;g[k>>2]=1.0;l=a+4|0;g[l>>2]=0.0;m=+g[d+12>>2];n=+g[b+48>>2];o=+g[d+8>>2];p=+g[b+52>>2];q=+g[d>>2]+(m*n-o*p);r=n*o+m*p+ +g[d+4>>2];p=+g[f+12>>2];m=+g[b>>2];o=+g[f+8>>2];n=+g[b+4>>2];s=+g[f>>2]+(p*m-o*n);t=m*o+p*n+ +g[f+4>>2];n=q-s;p=r-t;do{if(n*n+p*p>1.4210854715202004e-14){o=s-q;m=t-r;u=a;v=+m;g[u>>2]=o;g[u+4>>2]=v;v=+P(+(o*o+m*m));if(v<1.1920928955078125e-7){w=o;x=m;break}y=1.0/v;v=o*y;g[k>>2]=v;o=m*y;g[l>>2]=o;w=v;x=o}else{w=1.0;x=0.0}}while(0);l=a+8|0;p=+((r+x*e+(t-x*h))*.5);g[l>>2]=(q+w*e+(s-w*h))*.5;g[l+4>>2]=p;return}else if((j|0)==1){l=d+12|0;p=+g[l>>2];w=+g[b+40>>2];k=d+8|0;s=+g[k>>2];q=+g[b+44>>2];x=p*w-s*q;t=w*s+p*q;u=a;q=+t;g[u>>2]=x;g[u+4>>2]=q;q=+g[l>>2];p=+g[b+48>>2];s=+g[k>>2];w=+g[b+52>>2];r=+g[d>>2]+(q*p-s*w);n=p*s+q*w+ +g[d+4>>2];if((c[i>>2]|0)<=0){return}k=f+12|0;l=f+8|0;u=f|0;z=f+4|0;A=a|0;B=a+4|0;C=0;w=x;x=t;while(1){t=+g[k>>2];q=+g[b+(C*20&-1)>>2];s=+g[l>>2];p=+g[b+(C*20&-1)+4>>2];o=+g[u>>2]+(t*q-s*p);v=q*s+t*p+ +g[z>>2];p=e-(w*(o-r)+(v-n)*x);D=a+8+(C<<3)|0;t=+((v-x*h+(v+x*p))*.5);g[D>>2]=(o-w*h+(o+w*p))*.5;g[D+4>>2]=t;D=C+1|0;if((D|0)>=(c[i>>2]|0)){break}C=D;w=+g[A>>2];x=+g[B>>2]}return}else if((j|0)==2){j=f+12|0;x=+g[j>>2];w=+g[b+40>>2];B=f+8|0;n=+g[B>>2];r=+g[b+44>>2];t=x*w-n*r;p=w*n+x*r;A=a;r=+p;g[A>>2]=t;g[A+4>>2]=r;r=+g[j>>2];x=+g[b+48>>2];n=+g[B>>2];w=+g[b+52>>2];o=+g[f>>2]+(r*x-n*w);v=x*n+r*w+ +g[f+4>>2];if((c[i>>2]|0)>0){f=d+12|0;B=d+8|0;j=d|0;C=d+4|0;d=a|0;z=a+4|0;u=0;w=t;r=p;while(1){n=+g[f>>2];x=+g[b+(u*20&-1)>>2];s=+g[B>>2];q=+g[b+(u*20&-1)+4>>2];y=+g[j>>2]+(n*x-s*q);m=x*s+n*q+ +g[C>>2];q=h-(w*(y-o)+(m-v)*r);l=a+8+(u<<3)|0;n=+((m-r*e+(m+r*q))*.5);g[l>>2]=(y-w*e+(y+w*q))*.5;g[l+4>>2]=n;l=u+1|0;n=+g[d>>2];q=+g[z>>2];if((l|0)<(c[i>>2]|0)){u=l;w=n;r=q}else{E=n;F=q;break}}}else{E=t;F=p}p=+(-0.0-F);g[A>>2]=-0.0-E;g[A+4>>2]=p;return}else{return}}function ce(a){a=a|0;var b=0,d=0.0,e=0.0,f=0,h=0.0,i=0.0,j=0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0;b=a+16|0;d=+g[b>>2];e=+g[b+4>>2];b=a+36|0;f=a+52|0;h=+g[f>>2];i=+g[f+4>>2];f=a+72|0;j=a+88|0;k=+g[j>>2];l=+g[j+4>>2];m=h-d;n=i-e;o=d*m+e*n;p=h*m+i*n;q=k-d;r=l-e;s=d*q+e*r;t=k*q+l*r;u=k-h;v=l-i;w=h*u+i*v;x=k*u+l*v;v=m*r-n*q;q=(h*l-i*k)*v;n=(e*k-d*l)*v;l=(d*i-e*h)*v;if(!(o<-0.0|s<-0.0)){g[a+24>>2]=1.0;c[a+108>>2]=1;return}if(!(o>=-0.0|p<=0.0|l>0.0)){v=1.0/(p-o);g[a+24>>2]=p*v;g[a+60>>2]=v*(-0.0-o);c[a+108>>2]=2;return}if(!(s>=-0.0|t<=0.0|n>0.0)){o=1.0/(t-s);g[a+24>>2]=t*o;g[a+96>>2]=o*(-0.0-s);c[a+108>>2]=2;j=b;y=f;vp(j|0,y|0,36)|0;return}if(!(p>0.0|w<-0.0)){g[a+60>>2]=1.0;c[a+108>>2]=1;y=a;j=b;vp(y|0,j|0,36)|0;return}if(!(t>0.0|x>0.0)){g[a+96>>2]=1.0;c[a+108>>2]=1;j=a;y=f;vp(j|0,y|0,36)|0;return}if(w>=-0.0|x<=0.0|q>0.0){t=1.0/(l+(q+n));g[a+24>>2]=q*t;g[a+60>>2]=n*t;g[a+96>>2]=l*t;c[a+108>>2]=3;return}else{t=1.0/(x-w);g[a+60>>2]=x*t;g[a+96>>2]=t*(-0.0-w);c[a+108>>2]=2;y=a;a=f;vp(y|0,a|0,36)|0;return}}function cf(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,k=0;e=c[b+4>>2]|0;if((e|0)==0){c[a+16>>2]=b+12;c[a+20>>2]=1;g[a+24>>2]=+g[b+8>>2];return}else if((e|0)==2){c[a+16>>2]=b+20;c[a+20>>2]=c[b+148>>2];g[a+24>>2]=+g[b+8>>2];return}else if((e|0)==3){if((d|0)<=-1){ba(5304,53,17648,10824)}f=b+16|0;if((c[f>>2]|0)<=(d|0)){ba(5304,53,17648,10824)}h=b+12|0;i=(c[h>>2]|0)+(d<<3)|0;j=a;k=c[i+4>>2]|0;c[j>>2]=c[i>>2];c[j+4>>2]=k;k=d+1|0;d=a+8|0;j=c[h>>2]|0;if((k|0)<(c[f>>2]|0)){f=j+(k<<3)|0;k=d;h=c[f+4>>2]|0;c[k>>2]=c[f>>2];c[k+4>>2]=h}else{h=j;j=d;d=c[h+4>>2]|0;c[j>>2]=c[h>>2];c[j+4>>2]=d}c[a+16>>2]=a;c[a+20>>2]=2;g[a+24>>2]=+g[b+8>>2];return}else if((e|0)==1){c[a+16>>2]=b+12;c[a+20>>2]=2;g[a+24>>2]=+g[b+8>>2];return}else{ba(5304,81,17648,11592)}}function cg(d,e,f){d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0.0,u=0.0,v=0,w=0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0,D=0.0,E=0.0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,Q=0,R=0.0,S=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0,Z=0,_=0.0,$=0.0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0,ao=0,ap=0.0,aq=0.0,ar=0.0;h=i;i=i+176|0;j=h|0;k=h+16|0;l=h+32|0;m=h+144|0;n=h+160|0;c[1044]=(c[1044]|0)+1;o=j;p=f+56|0;c[o>>2]=c[p>>2];c[o+4>>2]=c[p+4>>2];c[o+8>>2]=c[p+8>>2];c[o+12>>2]=c[p+12>>2];p=k;o=f+72|0;c[p>>2]=c[o>>2];c[p+4>>2]=c[o+4>>2];c[p+8>>2]=c[o+8>>2];c[p+12>>2]=c[o+12>>2];ch(l,e,f|0,j,f+28|0,k);o=l|0;p=l+108|0;q=c[p>>2]|0;if((q|0)==1|(q|0)==2|(q|0)==3){r=l+16|0;s=l+20|0;t=+g[j+12>>2];u=+g[j+8>>2];v=f+16|0;w=f+20|0;x=+g[j>>2];y=+g[j+4>>2];z=+g[k+12>>2];A=+g[k+8>>2];B=-0.0-A;j=f+44|0;C=f+48|0;D=+g[k>>2];E=+g[k+4>>2];k=l+52|0;F=l+56|0;G=l+16|0;H=l+52|0;I=l+24|0;J=l+60|0;K=l;L=l+36|0;M=0;N=q;L460:while(1){O=(N|0)>0;if(O){Q=0;do{c[m+(Q<<2)>>2]=c[o+(Q*36&-1)+28>>2];c[n+(Q<<2)>>2]=c[o+(Q*36&-1)+32>>2];Q=Q+1|0;}while((Q|0)<(N|0))}do{if((N|0)==2){R=+g[G>>2];S=+g[G+4>>2];T=+g[H>>2];U=+g[H+4>>2];V=T-R;W=U-S;X=R*V+S*W;if(X>=-0.0){g[I>>2]=1.0;c[p>>2]=1;Y=356;break}S=T*V+U*W;if(S>0.0){W=1.0/(S-X);g[I>>2]=S*W;g[J>>2]=W*(-0.0-X);c[p>>2]=2;Y=357;break}else{g[J>>2]=1.0;c[p>>2]=1;vp(K|0,L|0,36)|0;Y=356;break}}else if((N|0)==3){ce(l);Q=c[p>>2]|0;if((Q|0)==0){Y=354;break L460}else if((Q|0)==1){Y=356}else if((Q|0)==2){Y=357}else if((Q|0)==3){Z=M;Y=381;break L460}else{Y=355;break L460}}else if((N|0)==1){Y=356}else{Y=352;break L460}}while(0);do{if((Y|0)==356){Y=0;_=-0.0- +g[r>>2];$=-0.0- +g[s>>2];aa=1}else if((Y|0)==357){Y=0;X=+g[r>>2];W=+g[k>>2]-X;S=+g[s>>2];U=+g[F>>2]-S;if(W*(-0.0-S)-U*(-0.0-X)>0.0){_=U*-1.0;$=W;aa=2;break}else{_=U;$=W*-1.0;aa=2;break}}}while(0);if($*$+_*_<1.4210854715202004e-14){Z=M;Y=381;break}Q=o+(aa*36&-1)|0;W=-0.0-$;U=t*(-0.0-_)+u*W;X=t*W+_*u;ab=c[v>>2]|0;ac=c[w>>2]|0;if((ac|0)>1){W=X*+g[ab+4>>2]+U*+g[ab>>2];ad=1;ae=0;while(1){S=U*+g[ab+(ad<<3)>>2]+X*+g[ab+(ad<<3)+4>>2];af=S>W;ag=af?ad:ae;ah=ad+1|0;if((ah|0)<(ac|0)){W=af?S:W;ad=ah;ae=ag}else{break}}ae=o+(aa*36&-1)+28|0;c[ae>>2]=ag;if((ag|0)>-1){ai=ag;aj=ae}else{Y=395;break}}else{ae=o+(aa*36&-1)+28|0;c[ae>>2]=0;ai=0;aj=ae}if((ac|0)<=(ai|0)){Y=396;break}W=+g[ab+(ai<<3)>>2];X=+g[ab+(ai<<3)+4>>2];U=x+(t*W-u*X);ae=Q;S=+(W*u+t*X+y);g[ae>>2]=U;g[ae+4>>2]=S;S=_*z+$*A;X=$*z+_*B;ae=c[j>>2]|0;ad=c[C>>2]|0;if((ad|0)>1){W=X*+g[ae+4>>2]+S*+g[ae>>2];ah=1;af=0;while(1){V=S*+g[ae+(ah<<3)>>2]+X*+g[ae+(ah<<3)+4>>2];ak=V>W;al=ak?ah:af;am=ah+1|0;if((am|0)<(ad|0)){W=ak?V:W;ah=am;af=al}else{break}}af=o+(aa*36&-1)+32|0;c[af>>2]=al;if((al|0)>-1){an=al;ao=af}else{Y=397;break}}else{af=o+(aa*36&-1)+32|0;c[af>>2]=0;an=0;ao=af}if((ad|0)<=(an|0)){Y=398;break}W=+g[ae+(an<<3)>>2];X=+g[ae+(an<<3)+4>>2];S=D+(z*W-A*X);af=o+(aa*36&-1)+8|0;V=+(W*A+z*X+E);g[af>>2]=S;g[af+4>>2]=V;af=o+(aa*36&-1)+16|0;V=+(+g[o+(aa*36&-1)+12>>2]- +g[o+(aa*36&-1)+4>>2]);g[af>>2]=S-U;g[af+4>>2]=V;af=M+1|0;c[1042]=(c[1042]|0)+1;if(O){ah=c[aj>>2]|0;Q=0;do{if((ah|0)==(c[m+(Q<<2)>>2]|0)){if((c[ao>>2]|0)==(c[n+(Q<<2)>>2]|0)){Z=af;Y=381;break L460}}Q=Q+1|0;}while((Q|0)<(N|0))}Q=(c[p>>2]|0)+1|0;c[p>>2]=Q;if((af|0)<20){M=af;N=Q}else{Z=af;Y=381;break}}if((Y|0)==352){ba(5304,498,19160,11592)}else if((Y|0)==354){ba(5304,194,13608,11592)}else if((Y|0)==355){ba(5304,207,13608,11592)}else if((Y|0)==381){N=c[1040]|0;c[1040]=(N|0)>(Z|0)?N:Z;N=d+8|0;ci(l,d|0,N);M=d|0;n=N|0;E=+g[M>>2]- +g[n>>2];ao=d+4|0;m=d+12|0;z=+g[ao>>2]- +g[m>>2];aj=d+16|0;g[aj>>2]=+P(+(E*E+z*z));c[d+20>>2]=Z;Z=c[p>>2]|0;if((Z|0)==0){ba(5304,246,13504,11592)}else if((Z|0)==2){z=+g[r>>2]- +g[k>>2];E=+g[s>>2]- +g[F>>2];ap=+P(+(z*z+E*E))}else if((Z|0)==3){E=+g[r>>2];z=+g[s>>2];ap=(+g[k>>2]-E)*(+g[l+92>>2]-z)-(+g[F>>2]-z)*(+g[l+88>>2]-E)}else if((Z|0)==1){ap=0.0}else{ba(5304,259,13504,11592)}g[e>>2]=ap;b[e+4>>1]=Z&65535;l=0;do{a[l+(e+6)|0]=c[o+(l*36&-1)+28>>2]&255;a[l+(e+9)|0]=c[o+(l*36&-1)+32>>2]&255;l=l+1|0;}while((l|0)<(Z|0));if((a[f+88|0]&1)==0){i=h;return}ap=+g[f+24>>2];E=+g[f+52>>2];z=+g[aj>>2];A=ap+E;if(!(z>A&z>1.1920928955078125e-7)){f=d;D=+((+g[M>>2]+ +g[n>>2])*.5);B=+((+g[ao>>2]+ +g[m>>2])*.5);g[f>>2]=D;g[f+4>>2]=B;f=N;g[f>>2]=D;g[f+4>>2]=B;g[aj>>2]=0.0;i=h;return}g[aj>>2]=z-A;A=+g[n>>2];z=+g[M>>2];B=A-z;D=+g[m>>2];_=+g[ao>>2];$=D-_;y=+P(+(B*B+$*$));if(y<1.1920928955078125e-7){aq=B;ar=$}else{t=1.0/y;aq=B*t;ar=$*t}g[M>>2]=ap*aq+z;g[ao>>2]=ap*ar+_;g[n>>2]=A-E*aq;g[m>>2]=D-E*ar;i=h;return}else if((Y|0)==395){ba(7536,103,13816,6368)}else if((Y|0)==396){ba(7536,103,13816,6368)}else if((Y|0)==397){ba(7536,103,13816,6368)}else if((Y|0)==398){ba(7536,103,13816,6368)}}else if((q|0)==0){ba(5304,194,13608,11592)}else{ba(5304,207,13608,11592)}}function ch(a,e,f,h,i,j){a=a|0;e=e|0;f=f|0;h=h|0;i=i|0;j=j|0;var k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0;k=b[e+4>>1]|0;if((k&65535)>=4){ba(5304,102,14776,5808)}l=k&65535;m=a+108|0;c[m>>2]=l;n=a|0;L542:do{if(k<<16>>16==0){o=l}else{p=f+20|0;q=f+16|0;r=i+20|0;s=i+16|0;t=h+12|0;u=h+8|0;v=h|0;w=h+4|0;x=j+12|0;y=j+8|0;z=j|0;A=j+4|0;B=0;while(1){C=d[B+(e+6)|0]|0;c[n+(B*36&-1)+28>>2]=C;D=d[B+(e+9)|0]|0;c[n+(B*36&-1)+32>>2]=D;if((c[p>>2]|0)<=(C|0)){E=407;break}F=(c[q>>2]|0)+(C<<3)|0;G=+g[F>>2];H=+g[F+4>>2];if((c[r>>2]|0)<=(D|0)){E=409;break}F=(c[s>>2]|0)+(D<<3)|0;I=+g[F>>2];J=+g[F+4>>2];K=+g[t>>2];L=+g[u>>2];M=+g[v>>2]+(G*K-H*L);F=n+(B*36&-1)|0;N=+(H*K+G*L+ +g[w>>2]);g[F>>2]=M;g[F+4>>2]=N;N=+g[x>>2];L=+g[y>>2];G=+g[z>>2]+(I*N-J*L);F=n+(B*36&-1)+8|0;K=+(J*N+I*L+ +g[A>>2]);g[F>>2]=G;g[F+4>>2]=K;F=n+(B*36&-1)+16|0;K=+(+g[n+(B*36&-1)+12>>2]- +g[n+(B*36&-1)+4>>2]);g[F>>2]=G-M;g[F+4>>2]=K;g[n+(B*36&-1)+24>>2]=0.0;F=B+1|0;D=c[m>>2]|0;if((F|0)<(D|0)){B=F}else{o=D;break L542}}if((E|0)==407){ba(7536,103,13816,6368)}else if((E|0)==409){ba(7536,103,13816,6368)}}}while(0);do{if((o|0)>1){K=+g[e>>2];if((o|0)==2){M=+g[a+16>>2]- +g[a+52>>2];G=+g[a+20>>2]- +g[a+56>>2];O=+P(+(M*M+G*G))}else if((o|0)==3){G=+g[a+16>>2];M=+g[a+20>>2];O=(+g[a+52>>2]-G)*(+g[a+92>>2]-M)-(+g[a+56>>2]-M)*(+g[a+88>>2]-G)}else{ba(5304,259,13504,11592)}if(O>=K*.5){if(!(K*2.0>2]=0}else{E=419}}while(0);do{if((E|0)==419){if((o|0)==0){break}return}}while(0);c[a+28>>2]=0;c[a+32>>2]=0;if((c[f+20>>2]|0)<=0){ba(7536,103,13816,6368)}o=c[f+16>>2]|0;O=+g[o>>2];K=+g[o+4>>2];if((c[i+20>>2]|0)<=0){ba(7536,103,13816,6368)}o=c[i+16>>2]|0;G=+g[o>>2];M=+g[o+4>>2];L=+g[h+12>>2];I=+g[h+8>>2];N=+g[h>>2]+(O*L-K*I);J=K*L+O*I+ +g[h+4>>2];h=a;I=+J;g[h>>2]=N;g[h+4>>2]=I;I=+g[j+12>>2];O=+g[j+8>>2];L=+g[j>>2]+(G*I-M*O);K=M*I+G*O+ +g[j+4>>2];j=a+8|0;O=+K;g[j>>2]=L;g[j+4>>2]=O;j=a+16|0;O=+(K-J);g[j>>2]=L-N;g[j+4>>2]=O;c[m>>2]=1;return}function ci(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0;e=c[a+108>>2]|0;if((e|0)==0){ba(5304,217,13544,11592)}else if((e|0)==1){f=a;h=b;i=c[f+4>>2]|0;c[h>>2]=c[f>>2];c[h+4>>2]=i;i=a+8|0;h=d;f=c[i+4>>2]|0;c[h>>2]=c[i>>2];c[h+4>>2]=f;return}else if((e|0)==2){f=a+24|0;j=+g[f>>2];h=a+60|0;k=+g[h>>2];i=b;l=+(j*+g[a+4>>2]+k*+g[a+40>>2]);g[i>>2]=j*+g[a>>2]+k*+g[a+36>>2];g[i+4>>2]=l;l=+g[f>>2];k=+g[h>>2];h=d;j=+(l*+g[a+12>>2]+k*+g[a+48>>2]);g[h>>2]=l*+g[a+8>>2]+k*+g[a+44>>2];g[h+4>>2]=j;return}else if((e|0)==3){j=+g[a+24>>2];k=+g[a+60>>2];l=+g[a+96>>2];e=b;m=+(j*+g[a>>2]+k*+g[a+36>>2]+l*+g[a+72>>2]);n=+(j*+g[a+4>>2]+k*+g[a+40>>2]+l*+g[a+76>>2]);g[e>>2]=m;g[e+4>>2]=n;e=d;g[e>>2]=m;g[e+4>>2]=n;return}else{ba(5304,236,13544,11592)}}function cj(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;b=a+16|0;d=c[b>>2]|0;if((d|0)==-1){e=a+8|0;f=c[e>>2]|0;g=a+12|0;if((f|0)!=(c[g>>2]|0)){ba(11392,61,18232,12440);return 0}h=a+4|0;i=c[h>>2]|0;c[g>>2]=f<<1;j=vh(f*72&-1)|0;c[h>>2]=j;f=i;i=(c[e>>2]|0)*36&-1;vp(j|0,f|0,i)|0;vi(f);f=c[e>>2]|0;i=(c[g>>2]|0)-1|0;if((f|0)<(i|0)){j=f;while(1){f=j+1|0;c[(c[h>>2]|0)+(j*36&-1)+20>>2]=f;c[(c[h>>2]|0)+(j*36&-1)+32>>2]=-1;k=(c[g>>2]|0)-1|0;if((f|0)<(k|0)){j=f}else{l=k;break}}}else{l=i}c[(c[h>>2]|0)+(l*36&-1)+20>>2]=-1;c[(c[h>>2]|0)+(((c[g>>2]|0)-1|0)*36&-1)+32>>2]=-1;g=c[e>>2]|0;c[b>>2]=g;m=g;n=h;o=e}else{m=d;n=a+4|0;o=a+8|0}a=(c[n>>2]|0)+(m*36&-1)+20|0;c[b>>2]=c[a>>2];c[a>>2]=-1;c[(c[n>>2]|0)+(m*36&-1)+24>>2]=-1;c[(c[n>>2]|0)+(m*36&-1)+28>>2]=-1;c[(c[n>>2]|0)+(m*36&-1)+32>>2]=0;c[(c[n>>2]|0)+(m*36&-1)+16>>2]=0;c[o>>2]=(c[o>>2]|0)+1;return m|0}function ck(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0.0,m=0,n=0,o=0,p=0,q=0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0,F=0,G=0;d=a+24|0;c[d>>2]=(c[d>>2]|0)+1;d=a|0;e=c[d>>2]|0;if((e|0)==-1){c[d>>2]=b;c[(c[a+4>>2]|0)+(b*36&-1)+20>>2]=-1;return}f=a+4|0;h=c[f>>2]|0;i=+g[h+(b*36&-1)>>2];j=+g[h+(b*36&-1)+4>>2];k=+g[h+(b*36&-1)+8>>2];l=+g[h+(b*36&-1)+12>>2];m=c[h+(e*36&-1)+24>>2]|0;L600:do{if((m|0)==-1){n=e}else{o=e;p=m;while(1){q=c[h+(o*36&-1)+28>>2]|0;r=+g[h+(o*36&-1)+8>>2];s=+g[h+(o*36&-1)>>2];t=+g[h+(o*36&-1)+12>>2];u=+g[h+(o*36&-1)+4>>2];v=((r>k?r:k)-(sl?t:l)-(u>2];t=i>2];r=j>2];y=k>v?k:v;z=+g[h+(p*36&-1)+12>>2];A=l>z?l:z;if((c[h+(p*36&-1)+24>>2]|0)==-1){B=(y-t+(A-r))*2.0}else{B=(y-t+(A-r))*2.0-(v-u+(z-s))*2.0}s=x+B;z=+g[h+(q*36&-1)>>2];u=i>2];r=j>2];t=k>A?k:A;y=+g[h+(q*36&-1)+12>>2];C=l>y?l:y;if((c[h+(q*36&-1)+24>>2]|0)==-1){D=(t-u+(C-r))*2.0}else{D=(t-u+(C-r))*2.0-(A-z+(y-v))*2.0}v=x+D;if(w>2]|0;if((q|0)==-1){n=E;break}else{o=E;p=q}}}}while(0);m=c[h+(n*36&-1)+20>>2]|0;h=cj(a)|0;c[(c[f>>2]|0)+(h*36&-1)+20>>2]=m;c[(c[f>>2]|0)+(h*36&-1)+16>>2]=0;e=c[f>>2]|0;D=+g[e+(n*36&-1)>>2];B=+g[e+(n*36&-1)+4>>2];p=e+(h*36&-1)|0;v=+(j>2]=i>2]=v;v=+g[e+(n*36&-1)+8>>2];D=+g[e+(n*36&-1)+12>>2];p=e+(h*36&-1)+8|0;i=+(l>D?l:D);g[p>>2]=k>v?k:v;g[p+4>>2]=i;p=c[f>>2]|0;c[p+(h*36&-1)+32>>2]=(c[p+(n*36&-1)+32>>2]|0)+1;p=c[f>>2]|0;if((m|0)==-1){c[p+(h*36&-1)+24>>2]=n;c[(c[f>>2]|0)+(h*36&-1)+28>>2]=b;c[(c[f>>2]|0)+(n*36&-1)+20>>2]=h;c[(c[f>>2]|0)+(b*36&-1)+20>>2]=h;c[d>>2]=h}else{d=p+(m*36&-1)+24|0;if((c[d>>2]|0)==(n|0)){c[d>>2]=h}else{c[p+(m*36&-1)+28>>2]=h}c[(c[f>>2]|0)+(h*36&-1)+24>>2]=n;c[(c[f>>2]|0)+(h*36&-1)+28>>2]=b;c[(c[f>>2]|0)+(n*36&-1)+20>>2]=h;c[(c[f>>2]|0)+(b*36&-1)+20>>2]=h}h=c[(c[f>>2]|0)+(b*36&-1)+20>>2]|0;if((h|0)==-1){return}else{F=h}while(1){h=co(a,F)|0;b=c[f>>2]|0;n=c[b+(h*36&-1)+24>>2]|0;m=c[b+(h*36&-1)+28>>2]|0;if((n|0)==-1){G=465;break}if((m|0)==-1){G=467;break}p=c[b+(n*36&-1)+32>>2]|0;d=c[b+(m*36&-1)+32>>2]|0;c[b+(h*36&-1)+32>>2]=((p|0)>(d|0)?p:d)+1;d=c[f>>2]|0;i=+g[d+(n*36&-1)>>2];v=+g[d+(m*36&-1)>>2];k=+g[d+(n*36&-1)+4>>2];D=+g[d+(m*36&-1)+4>>2];p=d+(h*36&-1)|0;l=+(k>2]=i>2]=l;l=+g[d+(n*36&-1)+8>>2];v=+g[d+(m*36&-1)+8>>2];i=+g[d+(n*36&-1)+12>>2];D=+g[d+(m*36&-1)+12>>2];m=d+(h*36&-1)+8|0;k=+(i>D?i:D);g[m>>2]=l>v?l:v;g[m+4>>2]=k;m=c[(c[f>>2]|0)+(h*36&-1)+20>>2]|0;if((m|0)==-1){G=472;break}else{F=m}}if((G|0)==465){ba(11392,307,18272,5200)}else if((G|0)==467){ba(11392,308,18272,4936)}else if((G|0)==472){return}}function cl(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;if((b|0)<=-1){ba(11392,126,18192,9904)}d=a+12|0;if((c[d>>2]|0)<=(b|0)){ba(11392,126,18192,9904)}e=a+4|0;if((c[(c[e>>2]|0)+(b*36&-1)+24>>2]|0)!=-1){ba(11392,127,18192,5720)}cm(a,b);if((c[d>>2]|0)<=(b|0)){ba(11392,97,18112,9768)}d=a+8|0;if((c[d>>2]|0)>0){f=a+16|0;c[(c[e>>2]|0)+(b*36&-1)+20>>2]=c[f>>2];c[(c[e>>2]|0)+(b*36&-1)+32>>2]=-1;c[f>>2]=b;c[d>>2]=(c[d>>2]|0)-1;return}else{ba(11392,98,18112,7256)}}function cm(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0;d=a|0;if((c[d>>2]|0)==(b|0)){c[d>>2]=-1;return}e=a+4|0;f=c[e>>2]|0;h=c[f+(b*36&-1)+20>>2]|0;i=c[f+(h*36&-1)+20>>2]|0;j=c[f+(h*36&-1)+24>>2]|0;if((j|0)==(b|0)){k=c[f+(h*36&-1)+28>>2]|0}else{k=j}if((i|0)==-1){c[d>>2]=k;c[f+(k*36&-1)+20>>2]=-1;if((h|0)<=-1){ba(11392,97,18112,9768)}if((c[a+12>>2]|0)<=(h|0)){ba(11392,97,18112,9768)}d=a+8|0;if((c[d>>2]|0)<=0){ba(11392,98,18112,7256)}j=a+16|0;c[(c[e>>2]|0)+(h*36&-1)+20>>2]=c[j>>2];c[(c[e>>2]|0)+(h*36&-1)+32>>2]=-1;c[j>>2]=h;c[d>>2]=(c[d>>2]|0)-1;return}d=f+(i*36&-1)+24|0;if((c[d>>2]|0)==(h|0)){c[d>>2]=k}else{c[f+(i*36&-1)+28>>2]=k}c[(c[e>>2]|0)+(k*36&-1)+20>>2]=i;if((h|0)<=-1){ba(11392,97,18112,9768)}if((c[a+12>>2]|0)<=(h|0)){ba(11392,97,18112,9768)}k=a+8|0;if((c[k>>2]|0)<=0){ba(11392,98,18112,7256)}f=a+16|0;c[(c[e>>2]|0)+(h*36&-1)+20>>2]=c[f>>2];c[(c[e>>2]|0)+(h*36&-1)+32>>2]=-1;c[f>>2]=h;c[k>>2]=(c[k>>2]|0)-1;k=i;do{i=co(a,k)|0;h=c[e>>2]|0;f=c[h+(i*36&-1)+24>>2]|0;d=c[h+(i*36&-1)+28>>2]|0;l=+g[h+(f*36&-1)>>2];m=+g[h+(d*36&-1)>>2];n=+g[h+(f*36&-1)+4>>2];o=+g[h+(d*36&-1)+4>>2];j=h+(i*36&-1)|0;p=+(n>2]=l>2]=p;p=+g[h+(f*36&-1)+8>>2];m=+g[h+(d*36&-1)+8>>2];l=+g[h+(f*36&-1)+12>>2];o=+g[h+(d*36&-1)+12>>2];j=h+(i*36&-1)+8|0;n=+(l>o?l:o);g[j>>2]=p>m?p:m;g[j+4>>2]=n;j=c[e>>2]|0;h=c[j+(f*36&-1)+32>>2]|0;f=c[j+(d*36&-1)+32>>2]|0;c[j+(i*36&-1)+32>>2]=((h|0)>(f|0)?h:f)+1;k=c[(c[e>>2]|0)+(i*36&-1)+20>>2]|0;}while((k|0)!=-1);return}function cn(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,i=0,j=0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0;if((b|0)<=-1){ba(11392,135,18040,9904);return 0}if((c[a+12>>2]|0)<=(b|0)){ba(11392,135,18040,9904);return 0}f=a+4|0;h=c[f>>2]|0;if((c[h+(b*36&-1)+24>>2]|0)!=-1){ba(11392,137,18040,5720);return 0}do{if(+g[h+(b*36&-1)>>2]<=+g[d>>2]){if(+g[h+(b*36&-1)+4>>2]>+g[d+4>>2]){break}if(+g[d+8>>2]>+g[h+(b*36&-1)+8>>2]){break}if(+g[d+12>>2]>+g[h+(b*36&-1)+12>>2]){break}else{i=0}return i|0}}while(0);cm(a,b);h=d;j=d+8|0;k=+g[h>>2]+-.10000000149011612;l=+g[h+4>>2]+-.10000000149011612;m=+g[j>>2]+.10000000149011612;n=+g[j+4>>2]+.10000000149011612;o=+g[e>>2]*2.0;p=+g[e+4>>2]*2.0;if(o<0.0){q=m;r=k+o}else{q=o+m;r=k}if(p<0.0){s=n;t=l+p}else{s=p+n;t=l}e=c[f>>2]|0;f=e+(b*36&-1)|0;l=+t;g[f>>2]=r;g[f+4>>2]=l;f=e+(b*36&-1)+8|0;l=+s;g[f>>2]=q;g[f+4>>2]=l;ck(a,b);i=1;return i|0}function co(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0,I=0,J=0,K=0;if((b|0)==-1){ba(11392,382,18152,4672);return 0}d=a+4|0;e=c[d>>2]|0;f=e+(b*36&-1)|0;h=e+(b*36&-1)+24|0;i=c[h>>2]|0;if((i|0)==-1){j=b;return j|0}k=e+(b*36&-1)+32|0;if((c[k>>2]|0)<2){j=b;return j|0}l=e+(b*36&-1)+28|0;m=c[l>>2]|0;if((i|0)<=-1){ba(11392,392,18152,4432);return 0}n=c[a+12>>2]|0;if((i|0)>=(n|0)){ba(11392,392,18152,4432);return 0}if(!((m|0)>-1&(m|0)<(n|0))){ba(11392,393,18152,12936);return 0}o=e+(i*36&-1)|0;p=e+(m*36&-1)|0;q=e+(m*36&-1)+32|0;r=e+(i*36&-1)+32|0;s=(c[q>>2]|0)-(c[r>>2]|0)|0;if((s|0)>1){t=e+(m*36&-1)+24|0;u=c[t>>2]|0;v=e+(m*36&-1)+28|0;w=c[v>>2]|0;x=e+(u*36&-1)|0;y=e+(w*36&-1)|0;if(!((u|0)>-1&(u|0)<(n|0))){ba(11392,407,18152,12728);return 0}if(!((w|0)>-1&(w|0)<(n|0))){ba(11392,408,18152,12328);return 0}c[t>>2]=b;t=e+(b*36&-1)+20|0;z=e+(m*36&-1)+20|0;c[z>>2]=c[t>>2];c[t>>2]=m;t=c[z>>2]|0;do{if((t|0)==-1){c[a>>2]=m}else{z=c[d>>2]|0;A=z+(t*36&-1)+24|0;if((c[A>>2]|0)==(b|0)){c[A>>2]=m;break}A=z+(t*36&-1)+28|0;if((c[A>>2]|0)==(b|0)){c[A>>2]=m;break}else{ba(11392,424,18152,11552);return 0}}}while(0);t=e+(u*36&-1)+32|0;A=e+(w*36&-1)+32|0;if((c[t>>2]|0)>(c[A>>2]|0)){c[v>>2]=u;c[l>>2]=w;c[e+(w*36&-1)+20>>2]=b;B=+g[o>>2];C=+g[y>>2];D=B>2];B=+g[e+(w*36&-1)+4>>2];z=f;E=+(C>2]=D;g[z+4>>2]=E;E=+g[e+(i*36&-1)+8>>2];B=+g[e+(w*36&-1)+8>>2];C=+g[e+(i*36&-1)+12>>2];F=+g[e+(w*36&-1)+12>>2];z=e+(b*36&-1)+8|0;G=+(C>F?C:F);g[z>>2]=E>B?E:B;g[z+4>>2]=G;G=+g[x>>2];B=+g[e+(b*36&-1)+4>>2];E=+g[e+(u*36&-1)+4>>2];z=p;F=+(B>2]=D>2]=F;F=+g[e+(b*36&-1)+8>>2];G=+g[e+(u*36&-1)+8>>2];D=+g[e+(b*36&-1)+12>>2];E=+g[e+(u*36&-1)+12>>2];z=e+(m*36&-1)+8|0;B=+(D>E?D:E);g[z>>2]=F>G?F:G;g[z+4>>2]=B;z=c[r>>2]|0;H=c[A>>2]|0;I=((z|0)>(H|0)?z:H)+1|0;c[k>>2]=I;H=c[t>>2]|0;J=(I|0)>(H|0)?I:H}else{c[v>>2]=w;c[l>>2]=u;c[e+(u*36&-1)+20>>2]=b;B=+g[o>>2];G=+g[x>>2];F=B>2];B=+g[e+(u*36&-1)+4>>2];x=f;E=+(G>2]=F;g[x+4>>2]=E;E=+g[e+(i*36&-1)+8>>2];B=+g[e+(u*36&-1)+8>>2];G=+g[e+(i*36&-1)+12>>2];D=+g[e+(u*36&-1)+12>>2];u=e+(b*36&-1)+8|0;C=+(G>D?G:D);g[u>>2]=E>B?E:B;g[u+4>>2]=C;C=+g[y>>2];B=+g[e+(b*36&-1)+4>>2];E=+g[e+(w*36&-1)+4>>2];y=p;D=+(B>2]=F>2]=D;D=+g[e+(b*36&-1)+8>>2];C=+g[e+(w*36&-1)+8>>2];F=+g[e+(b*36&-1)+12>>2];E=+g[e+(w*36&-1)+12>>2];w=e+(m*36&-1)+8|0;B=+(F>E?F:E);g[w>>2]=D>C?D:C;g[w+4>>2]=B;w=c[r>>2]|0;y=c[t>>2]|0;t=((w|0)>(y|0)?w:y)+1|0;c[k>>2]=t;y=c[A>>2]|0;J=(t|0)>(y|0)?t:y}c[q>>2]=J+1;j=m;return j|0}if((s|0)>=-1){j=b;return j|0}s=e+(i*36&-1)+24|0;J=c[s>>2]|0;y=e+(i*36&-1)+28|0;t=c[y>>2]|0;A=e+(J*36&-1)|0;w=e+(t*36&-1)|0;if(!((J|0)>-1&(J|0)<(n|0))){ba(11392,467,18152,11296);return 0}if(!((t|0)>-1&(t|0)<(n|0))){ba(11392,468,18152,11200);return 0}c[s>>2]=b;s=e+(b*36&-1)+20|0;n=e+(i*36&-1)+20|0;c[n>>2]=c[s>>2];c[s>>2]=i;s=c[n>>2]|0;do{if((s|0)==-1){c[a>>2]=i}else{n=c[d>>2]|0;u=n+(s*36&-1)+24|0;if((c[u>>2]|0)==(b|0)){c[u>>2]=i;break}u=n+(s*36&-1)+28|0;if((c[u>>2]|0)==(b|0)){c[u>>2]=i;break}else{ba(11392,484,18152,11e3);return 0}}}while(0);s=e+(J*36&-1)+32|0;d=e+(t*36&-1)+32|0;if((c[s>>2]|0)>(c[d>>2]|0)){c[y>>2]=J;c[h>>2]=t;c[e+(t*36&-1)+20>>2]=b;B=+g[p>>2];C=+g[w>>2];D=B>2];B=+g[e+(t*36&-1)+4>>2];a=f;E=+(C>2]=D;g[a+4>>2]=E;E=+g[e+(m*36&-1)+8>>2];B=+g[e+(t*36&-1)+8>>2];C=+g[e+(m*36&-1)+12>>2];F=+g[e+(t*36&-1)+12>>2];a=e+(b*36&-1)+8|0;G=+(C>F?C:F);g[a>>2]=E>B?E:B;g[a+4>>2]=G;G=+g[A>>2];B=+g[e+(b*36&-1)+4>>2];E=+g[e+(J*36&-1)+4>>2];a=o;F=+(B>2]=D>2]=F;F=+g[e+(b*36&-1)+8>>2];G=+g[e+(J*36&-1)+8>>2];D=+g[e+(b*36&-1)+12>>2];E=+g[e+(J*36&-1)+12>>2];a=e+(i*36&-1)+8|0;B=+(D>E?D:E);g[a>>2]=F>G?F:G;g[a+4>>2]=B;a=c[q>>2]|0;u=c[d>>2]|0;n=((a|0)>(u|0)?a:u)+1|0;c[k>>2]=n;u=c[s>>2]|0;K=(n|0)>(u|0)?n:u}else{c[y>>2]=t;c[h>>2]=J;c[e+(J*36&-1)+20>>2]=b;B=+g[p>>2];G=+g[A>>2];F=B>2];B=+g[e+(J*36&-1)+4>>2];A=f;E=+(G>2]=F;g[A+4>>2]=E;E=+g[e+(m*36&-1)+8>>2];B=+g[e+(J*36&-1)+8>>2];G=+g[e+(m*36&-1)+12>>2];D=+g[e+(J*36&-1)+12>>2];J=e+(b*36&-1)+8|0;C=+(G>D?G:D);g[J>>2]=E>B?E:B;g[J+4>>2]=C;C=+g[w>>2];B=+g[e+(b*36&-1)+4>>2];E=+g[e+(t*36&-1)+4>>2];w=o;D=+(B>2]=F>2]=D;D=+g[e+(b*36&-1)+8>>2];C=+g[e+(t*36&-1)+8>>2];F=+g[e+(b*36&-1)+12>>2];E=+g[e+(t*36&-1)+12>>2];t=e+(i*36&-1)+8|0;B=+(F>E?F:E);g[t>>2]=D>C?D:C;g[t+4>>2]=B;t=c[q>>2]|0;q=c[s>>2]|0;s=((t|0)>(q|0)?t:q)+1|0;c[k>>2]=s;k=c[d>>2]|0;K=(s|0)>(k|0)?s:k}c[r>>2]=K+1;j=i;return j|0}function cp(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;if((b|0)<=-1){ba(11392,563,14360,9768);return 0}if((c[a+12>>2]|0)<=(b|0)){ba(11392,563,14360,9768);return 0}d=c[a+4>>2]|0;e=c[d+(b*36&-1)+24>>2]|0;if((e|0)==-1){return 0}else{f=cp(a,e)|0;e=cp(a,c[d+(b*36&-1)+28>>2]|0)|0;return((f|0)>(e|0)?f:e)+1|0}return 0}function cq(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;if((b|0)==-1){return}d=a|0;e=a+4|0;f=a+12|0;g=b;while(1){h=c[e>>2]|0;if((c[d>>2]|0)==(g|0)){if((c[h+(g*36&-1)+20>>2]|0)!=-1){i=596;break}}b=c[h+(g*36&-1)+24>>2]|0;j=c[h+(g*36&-1)+28>>2]|0;if((b|0)==-1){i=598;break}if((b|0)<=-1){i=614;break}k=c[f>>2]|0;if((b|0)>=(k|0)){i=613;break}if(!((j|0)>-1&(j|0)<(k|0))){i=606;break}if((c[h+(b*36&-1)+20>>2]|0)!=(g|0)){i=608;break}if((c[h+(j*36&-1)+20>>2]|0)!=(g|0)){i=610;break}cq(a,b);if((j|0)==-1){i=616;break}else{g=j}}if((i|0)==598){if((j|0)!=-1){ba(11392,602,14200,10448)}if((c[h+(g*36&-1)+32>>2]|0)==0){return}else{ba(11392,603,14200,10240)}}else if((i|0)==610){ba(11392,611,14200,8896)}else if((i|0)==613){ba(11392,607,14200,10024)}else if((i|0)==616){return}else if((i|0)==606){ba(11392,608,14200,9600)}else if((i|0)==614){ba(11392,607,14200,10024)}else if((i|0)==596){ba(11392,591,14200,10680)}else if((i|0)==608){ba(11392,610,14200,9296)}}function cr(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0,j=0,k=0,l=0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0;if((b|0)==-1){return}d=a+4|0;e=a+12|0;f=b;while(1){h=c[d>>2]|0;b=c[h+(f*36&-1)+24>>2]|0;i=c[h+(f*36&-1)+28>>2]|0;if((b|0)==-1){j=621;break}if((b|0)<=-1){j=647;break}k=c[e>>2]|0;if((b|0)>=(k|0)){j=648;break}if(!((i|0)>-1&(i|0)<(k|0))){j=629;break}k=c[h+(b*36&-1)+32>>2]|0;l=c[h+(i*36&-1)+32>>2]|0;if((c[h+(f*36&-1)+32>>2]|0)!=(((k|0)>(l|0)?k:l)+1|0)){j=631;break}m=+g[h+(b*36&-1)>>2];n=+g[h+(i*36&-1)>>2];o=+g[h+(b*36&-1)+4>>2];p=+g[h+(i*36&-1)+4>>2];q=+g[h+(b*36&-1)+8>>2];r=+g[h+(i*36&-1)+8>>2];s=+g[h+(b*36&-1)+12>>2];t=+g[h+(i*36&-1)+12>>2];if((m>2]){j=643;break}if((o>2]){j=644;break}if((q>r?q:r)!=+g[h+(f*36&-1)+8>>2]){j=645;break}if((s>t?s:t)!=+g[h+(f*36&-1)+12>>2]){j=646;break}cr(a,b);if((i|0)==-1){j=640;break}else{f=i}}if((j|0)==648){ba(11392,637,14256,10024)}else if((j|0)==631){ba(11392,644,14256,8744)}else if((j|0)==621){if((i|0)!=-1){ba(11392,632,14256,10448)}if((c[h+(f*36&-1)+32>>2]|0)==0){return}else{ba(11392,633,14256,10240)}}else if((j|0)==645){ba(11392,650,14256,8160)}else if((j|0)==629){ba(11392,638,14256,9600)}else if((j|0)==640){return}else if((j|0)==643){ba(11392,649,14256,8392)}else if((j|0)==644){ba(11392,649,14256,8392)}else if((j|0)==646){ba(11392,650,14256,8160)}else if((j|0)==647){ba(11392,637,14256,10024)}}function cs(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;b=a|0;cq(a,c[b>>2]|0);cr(a,c[b>>2]|0);d=c[a+16>>2]|0;L849:do{if((d|0)==-1){e=0}else{f=a+12|0;g=a+4|0;h=0;i=d;while(1){if((i|0)<=-1){j=663;break}if((i|0)>=(c[f>>2]|0)){j=662;break}k=h+1|0;l=c[(c[g>>2]|0)+(i*36&-1)+20>>2]|0;if((l|0)==-1){e=k;break L849}else{h=k;i=l}}if((j|0)==662){ba(11392,665,14064,7712)}else if((j|0)==663){ba(11392,665,14064,7712)}}}while(0);j=c[b>>2]|0;if((j|0)==-1){m=0}else{m=c[(c[a+4>>2]|0)+(j*36&-1)+32>>2]|0}if((m|0)!=(cp(a,j)|0)){ba(11392,670,14064,7680)}if(((c[a+8>>2]|0)+e|0)==(c[a+12>>2]|0)){return}else{ba(11392,672,14064,7488)}}function ct(a){a=a|0;var b=0,d=0,e=0,f=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0,w=0,x=0,y=0.0,z=0,A=0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0,H=0,I=0,J=0;b=a+8|0;d=vh(c[b>>2]<<2)|0;e=d;f=a+12|0;if((c[f>>2]|0)<=0){h=c[e>>2]|0;i=a|0;c[i>>2]=h;vi(d);cs(a);return}j=a+4|0;k=a+16|0;l=0;m=0;L872:while(1){n=c[j>>2]|0;do{if((c[n+(l*36&-1)+32>>2]|0)<0){o=m}else{if((c[n+(l*36&-1)+24>>2]|0)==-1){c[n+(l*36&-1)+20>>2]=-1;c[e+(m<<2)>>2]=l;o=m+1|0;break}if((c[b>>2]|0)<=0){p=672;break L872}c[n+(l*36&-1)+20>>2]=c[k>>2];c[(c[j>>2]|0)+(l*36&-1)+32>>2]=-1;c[k>>2]=l;c[b>>2]=(c[b>>2]|0)-1;o=m}}while(0);n=l+1|0;if((n|0)<(c[f>>2]|0)){l=n;m=o}else{break}}if((p|0)==672){ba(11392,98,18112,7256)}if((o|0)<=1){h=c[e>>2]|0;i=a|0;c[i>>2]=h;vi(d);cs(a);return}p=a+4|0;m=o;do{o=c[p>>2]|0;l=0;f=-1;b=-1;q=3.4028234663852886e+38;while(1){k=c[e+(l<<2)>>2]|0;r=+g[o+(k*36&-1)>>2];s=+g[o+(k*36&-1)+4>>2];t=+g[o+(k*36&-1)+8>>2];u=+g[o+(k*36&-1)+12>>2];k=l+1|0;j=(k|0)<(m|0);if(j){v=k;w=f;x=b;y=q}else{z=b;A=f;break}do{n=c[e+(v<<2)>>2]|0;B=+g[o+(n*36&-1)>>2];C=+g[o+(n*36&-1)+4>>2];D=+g[o+(n*36&-1)+8>>2];E=+g[o+(n*36&-1)+12>>2];F=((t>D?t:D)-(rE?u:E)-(s>2]|0;l=e+(A<<2)|0;n=c[l>>2]|0;G=cj(a)|0;H=c[p>>2]|0;c[H+(G*36&-1)+24>>2]=f;c[H+(G*36&-1)+28>>2]=n;I=c[o+(f*36&-1)+32>>2]|0;J=c[o+(n*36&-1)+32>>2]|0;c[H+(G*36&-1)+32>>2]=((I|0)>(J|0)?I:J)+1;q=+g[o+(f*36&-1)>>2];s=+g[o+(n*36&-1)>>2];u=+g[o+(f*36&-1)+4>>2];r=+g[o+(n*36&-1)+4>>2];J=H+(G*36&-1)|0;t=+(u>2]=q>2]=t;t=+g[o+(f*36&-1)+8>>2];s=+g[o+(n*36&-1)+8>>2];q=+g[o+(f*36&-1)+12>>2];r=+g[o+(n*36&-1)+12>>2];J=H+(G*36&-1)+8|0;u=+(q>r?q:r);g[J>>2]=t>s?t:s;g[J+4>>2]=u;c[H+(G*36&-1)+20>>2]=-1;c[o+(f*36&-1)+20>>2]=G;c[o+(n*36&-1)+20>>2]=G;m=m-1|0;c[l>>2]=c[e+(m<<2)>>2];c[b>>2]=G;}while((m|0)>1);h=c[e>>2]|0;i=a|0;c[i>>2]=h;vi(d);cs(a);return}function cu(d,e){d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0.0,x=0.0,y=0.0,z=0,A=0.0,B=0.0,C=0,D=0.0,E=0.0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,O=0,P=0,Q=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0.0,_=0.0,$=0,aa=0.0,ab=0.0,ac=0.0,ad=0.0,ae=0.0,af=0.0,ag=0.0,ah=0.0,ai=0.0,aj=0.0,ak=0.0,al=0.0,am=0.0,an=0,ao=0,ap=0.0,aq=0,ar=0,as=0.0,at=0.0,au=0,av=0.0,aw=0.0,ax=0.0,ay=0.0,az=0,aA=0.0,aB=0,aC=0,aD=0,aE=0,aF=0,aG=0;f=i;i=i+336|0;h=f|0;j=f+40|0;k=f+80|0;l=f+96|0;m=f+192|0;n=f+216|0;o=f+320|0;p=f+328|0;c[1038]=(c[1038]|0)+1;q=d|0;c[q>>2]=0;r=e+128|0;s=d+4|0;g[s>>2]=+g[r>>2];d=e|0;t=e+28|0;u=h;v=e+56|0;vp(u|0,v|0,36)|0;v=j;u=e+92|0;vp(v|0,u|0,36)|0;u=h+24|0;w=+g[u>>2];x=+N(+(w/6.2831854820251465))*6.2831854820251465;y=w-x;g[u>>2]=y;v=h+28|0;w=+g[v>>2]-x;g[v>>2]=w;z=j+24|0;x=+g[z>>2];A=+N(+(x/6.2831854820251465))*6.2831854820251465;B=x-A;g[z>>2]=B;C=j+28|0;x=+g[C>>2]-A;g[C>>2]=x;A=+g[r>>2];D=+g[e+24>>2]+ +g[e+52>>2]+-.014999999664723873;E=D<.004999999888241291?.004999999888241291:D;if(E<=.0012499999720603228){ba(6688,280,19104,11456)}b[k+4>>1]=0;r=l;F=e;c[r>>2]=c[F>>2];c[r+4>>2]=c[F+4>>2];c[r+8>>2]=c[F+8>>2];c[r+12>>2]=c[F+12>>2];c[r+16>>2]=c[F+16>>2];c[r+20>>2]=c[F+20>>2];c[r+24>>2]=c[F+24>>2];F=l+28|0;r=t;c[F>>2]=c[r>>2];c[F+4>>2]=c[r+4>>2];c[F+8>>2]=c[r+8>>2];c[F+12>>2]=c[r+12>>2];c[F+16>>2]=c[r+16>>2];c[F+20>>2]=c[r+20>>2];c[F+24>>2]=c[r+24>>2];a[l+88|0]=0;r=h+8|0;F=h+12|0;e=h+16|0;G=h+20|0;H=h|0;I=h+4|0;J=j+8|0;K=j+12|0;L=j+16|0;M=j+20|0;O=j|0;P=j+4|0;Q=l+56|0;T=l+64|0;U=l+68|0;V=l+72|0;W=l+80|0;X=l+84|0;Y=m+16|0;D=E+.0012499999720603228;Z=E+-.0012499999720603228;_=0.0;$=0;aa=y;y=w;w=B;B=x;L900:while(1){x=1.0-_;ab=x*+g[r>>2]+_*+g[e>>2];ac=x*+g[F>>2]+_*+g[G>>2];ad=x*aa+_*y;ae=+S(+ad);af=+R(+ad);ad=+g[H>>2];ag=+g[I>>2];ah=x*+g[J>>2]+_*+g[L>>2];ai=x*+g[K>>2]+_*+g[M>>2];aj=x*w+_*B;x=+S(+aj);ak=+R(+aj);aj=+g[O>>2];al=+g[P>>2];am=+(ac-(ae*ad+af*ag));g[Q>>2]=ab-(af*ad-ae*ag);g[Q+4>>2]=am;g[T>>2]=ae;g[U>>2]=af;af=+(ai-(x*aj+ak*al));g[V>>2]=ah-(ak*aj-x*al);g[V+4>>2]=af;g[W>>2]=x;g[X>>2]=ak;cg(m,k,l);ak=+g[Y>>2];if(ak<=0.0){an=688;break}if(akD){an=693;break L900}if(x>Z){ap=ak;break}aq=c[o>>2]|0;ar=c[p>>2]|0;af=+cA(n,aq,ar,_);if(afD){as=ak;at=_;au=0;av=af;aw=x}else{an=698;break L900}while(1){if((au&1|0)==0){ax=(at+as)*.5}else{ax=at+(E-av)*(as-at)/(aw-av)}x=+cA(n,aq,ar,ax);af=x-E;if(af>0.0){ay=af}else{ay=-0.0-af}if(ay<.0012499999720603228){az=au;aA=ax;break}aB=x>E;aC=au+1|0;c[1030]=(c[1030]|0)+1;if((aC|0)==50){az=50;aA=ak;break}else{as=aB?as:ax;at=aB?ax:at;au=aC;av=aB?x:av;aw=aB?aw:x}}ar=c[1032]|0;c[1032]=(ar|0)>(az|0)?ar:az;ar=ao+1|0;if((ar|0)==8){ap=_;break}else{ao=ar;ak=aA}}ao=$+1|0;c[1036]=(c[1036]|0)+1;if((ao|0)==20){an=710;break}_=ap;$=ao;aa=+g[u>>2];y=+g[v>>2];w=+g[z>>2];B=+g[C>>2]}if((an|0)==710){c[q>>2]=1;g[s>>2]=ap;aD=20;aE=c[1034]|0;aF=(aE|0)>(aD|0);aG=aF?aE:aD;c[1034]=aG;i=f;return}else if((an|0)==696){c[q>>2]=1;g[s>>2]=_}else if((an|0)==688){c[q>>2]=2;g[s>>2]=0.0;aD=$;aE=c[1034]|0;aF=(aE|0)>(aD|0);aG=aF?aE:aD;c[1034]=aG;i=f;return}else if((an|0)==690){c[q>>2]=3;g[s>>2]=_;aD=$;aE=c[1034]|0;aF=(aE|0)>(aD|0);aG=aF?aE:aD;c[1034]=aG;i=f;return}else if((an|0)==693){c[q>>2]=4;g[s>>2]=A}else if((an|0)==698){c[q>>2]=3;g[s>>2]=_}c[1036]=(c[1036]|0)+1;aD=$+1|0;aE=c[1034]|0;aF=(aE|0)>(aD|0);aG=aF?aE:aD;c[1034]=aG;i=f;return}function cv(e,f,h,i,j,k,l){e=e|0;f=f|0;h=h|0;i=i|0;j=j|0;k=k|0;l=+l;var m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0;c[e>>2]=h;c[e+4>>2]=j;m=b[f+4>>1]|0;if(!(m<<16>>16!=0&(m&65535)<3)){ba(6688,50,16840,5584);return 0.0}n=e+8|0;o=n;p=i;vp(o|0,p|0,36)|0;p=e+44|0;o=p;i=k;vp(o|0,i|0,36)|0;q=1.0-l;r=q*+g[e+16>>2]+ +g[e+24>>2]*l;s=q*+g[e+20>>2]+ +g[e+28>>2]*l;t=q*+g[e+32>>2]+ +g[e+36>>2]*l;u=+S(+t);v=+R(+t);t=+g[n>>2];w=+g[e+12>>2];x=r-(v*t-u*w);r=s-(u*t+v*w);w=q*+g[e+52>>2]+ +g[e+60>>2]*l;t=q*+g[e+56>>2]+ +g[e+64>>2]*l;s=q*+g[e+68>>2]+ +g[e+72>>2]*l;l=+S(+s);q=+R(+s);s=+g[p>>2];y=+g[e+48>>2];z=w-(q*s-l*y);w=t-(l*s+q*y);if(m<<16>>16==1){c[e+80>>2]=0;m=d[f+6|0]|0;if((c[h+20>>2]|0)<=(m|0)){ba(7536,103,13816,6368);return 0.0}p=(c[h+16>>2]|0)+(m<<3)|0;y=+g[p>>2];s=+g[p+4>>2];p=d[f+9|0]|0;if((c[j+20>>2]|0)<=(p|0)){ba(7536,103,13816,6368);return 0.0}m=(c[j+16>>2]|0)+(p<<3)|0;t=+g[m>>2];A=+g[m+4>>2];m=e+92|0;B=z+(q*t-l*A)-(x+(v*y-u*s));C=w+(l*t+q*A)-(r+(u*y+v*s));p=m;s=+C;g[p>>2]=B;g[p+4>>2]=s;s=+P(+(B*B+C*C));if(s<1.1920928955078125e-7){D=0.0;return+D}y=1.0/s;g[m>>2]=B*y;g[e+96>>2]=C*y;D=s;return+D}m=f+6|0;p=f+7|0;n=e+80|0;if((a[m]|0)==(a[p]|0)){c[n>>2]=2;i=d[f+9|0]|0;o=c[j+20>>2]|0;if((o|0)<=(i|0)){ba(7536,103,13816,6368);return 0.0}k=c[j+16>>2]|0;E=k+(i<<3)|0;s=+g[E>>2];y=+g[E+4>>2];E=d[f+10|0]|0;if((o|0)<=(E|0)){ba(7536,103,13816,6368);return 0.0}o=k+(E<<3)|0;C=+g[o>>2];B=+g[o+4>>2];o=e+92|0;A=B-y;t=(C-s)*-1.0;E=o;F=+t;g[E>>2]=A;g[E+4>>2]=F;F=+P(+(A*A+t*t));if(F<1.1920928955078125e-7){G=A;H=t}else{I=1.0/F;F=A*I;g[o>>2]=F;A=t*I;g[e+96>>2]=A;G=F;H=A}A=(s+C)*.5;C=(y+B)*.5;o=e+84|0;B=+C;g[o>>2]=A;g[o+4>>2]=B;o=d[m]|0;if((c[h+20>>2]|0)<=(o|0)){ba(7536,103,13816,6368);return 0.0}k=(c[h+16>>2]|0)+(o<<3)|0;B=+g[k>>2];y=+g[k+4>>2];s=(q*G-l*H)*(x+(v*B-u*y)-(z+(q*A-l*C)))+(l*G+q*H)*(r+(u*B+v*y)-(w+(l*A+q*C)));if(s>=0.0){D=s;return+D}C=+(-0.0-H);g[E>>2]=-0.0-G;g[E+4>>2]=C;D=-0.0-s;return+D}else{c[n>>2]=1;n=d[m]|0;m=c[h+20>>2]|0;if((m|0)<=(n|0)){ba(7536,103,13816,6368);return 0.0}E=c[h+16>>2]|0;h=E+(n<<3)|0;s=+g[h>>2];C=+g[h+4>>2];h=d[p]|0;if((m|0)<=(h|0)){ba(7536,103,13816,6368);return 0.0}m=E+(h<<3)|0;G=+g[m>>2];H=+g[m+4>>2];m=e+92|0;A=H-C;y=(G-s)*-1.0;h=m;B=+y;g[h>>2]=A;g[h+4>>2]=B;B=+P(+(A*A+y*y));if(B<1.1920928955078125e-7){J=A;K=y}else{F=1.0/B;B=A*F;g[m>>2]=B;A=y*F;g[e+96>>2]=A;J=B;K=A}A=(s+G)*.5;G=(C+H)*.5;m=e+84|0;H=+G;g[m>>2]=A;g[m+4>>2]=H;m=d[f+9|0]|0;if((c[j+20>>2]|0)<=(m|0)){ba(7536,103,13816,6368);return 0.0}f=(c[j+16>>2]|0)+(m<<3)|0;H=+g[f>>2];C=+g[f+4>>2];s=(v*J-u*K)*(z+(q*H-l*C)-(x+(v*A-u*G)))+(u*J+v*K)*(w+(l*H+q*C)-(r+(u*A+v*G)));if(s>=0.0){D=s;return+D}G=+(-0.0-K);g[h>>2]=-0.0-J;g[h+4>>2]=G;D=-0.0-s;return+D}return 0.0}function cw(a){a=a|0;return(c[a+16>>2]|0)-1|0}function cx(a){a=a|0;var b=0;c[a>>2]=20296;b=a+12|0;vi(c[b>>2]|0);c[b>>2]=0;c[a+16>>2]=0;vl(a);return}function cy(a){a=a|0;var b=0;c[a>>2]=20296;b=a+12|0;vi(c[b>>2]|0);c[b>>2]=0;c[a+16>>2]=0;return}function cz(a,b,d,e){a=a|0;b=b|0;d=d|0;e=+e;var f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0,s=0,t=0.0,u=0.0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0.0,H=0.0,I=0.0,J=0,K=0,L=0,M=0;f=1.0-e;h=f*+g[a+16>>2]+ +g[a+24>>2]*e;i=f*+g[a+20>>2]+ +g[a+28>>2]*e;j=f*+g[a+32>>2]+ +g[a+36>>2]*e;k=+S(+j);l=+R(+j);j=+g[a+8>>2];m=+g[a+12>>2];n=h-(l*j-k*m);h=i-(k*j+l*m);m=f*+g[a+52>>2]+ +g[a+60>>2]*e;j=f*+g[a+56>>2]+ +g[a+64>>2]*e;i=f*+g[a+68>>2]+ +g[a+72>>2]*e;e=+S(+i);f=+R(+i);i=+g[a+44>>2];o=+g[a+48>>2];p=m-(f*i-e*o);m=j-(e*i+f*o);q=c[a+80>>2]|0;if((q|0)==0){r=a+92|0;o=+g[r>>2];s=a+96|0;i=+g[s>>2];j=l*o+k*i;t=o*(-0.0-k)+l*i;u=-0.0-i;i=f*(-0.0-o)+e*u;v=e*o+f*u;w=a|0;x=c[w>>2]|0;y=c[x+16>>2]|0;z=c[x+20>>2]|0;if((z|0)>1){u=t*+g[y+4>>2]+j*+g[y>>2];x=1;A=0;while(1){o=j*+g[y+(x<<3)>>2]+t*+g[y+(x<<3)+4>>2];B=o>u;C=B?x:A;D=x+1|0;if((D|0)<(z|0)){u=B?o:u;x=D;A=C}else{E=C;break}}}else{E=0}c[b>>2]=E;E=a+4|0;A=c[E>>2]|0;x=c[A+16>>2]|0;z=c[A+20>>2]|0;if((z|0)>1){u=v*+g[x+4>>2]+i*+g[x>>2];A=1;y=0;while(1){t=i*+g[x+(A<<3)>>2]+v*+g[x+(A<<3)+4>>2];C=t>u;D=C?A:y;B=A+1|0;if((B|0)<(z|0)){u=C?t:u;A=B;y=D}else{F=D;break}}}else{F=0}c[d>>2]=F;y=c[w>>2]|0;w=c[b>>2]|0;if((w|0)<=-1){ba(7536,103,13816,6368);return 0.0}if((c[y+20>>2]|0)<=(w|0)){ba(7536,103,13816,6368);return 0.0}A=(c[y+16>>2]|0)+(w<<3)|0;u=+g[A>>2];v=+g[A+4>>2];A=c[E>>2]|0;if((F|0)<=-1){ba(7536,103,13816,6368);return 0.0}if((c[A+20>>2]|0)<=(F|0)){ba(7536,103,13816,6368);return 0.0}E=(c[A+16>>2]|0)+(F<<3)|0;i=+g[E>>2];t=+g[E+4>>2];G=+g[r>>2]*(p+(f*i-e*t)-(n+(l*u-k*v)))+ +g[s>>2]*(m+(e*i+f*t)-(h+(k*u+l*v)));return+G}else if((q|0)==1){v=+g[a+92>>2];u=+g[a+96>>2];t=l*v-k*u;i=k*v+l*u;u=+g[a+84>>2];v=+g[a+88>>2];j=n+(l*u-k*v);o=h+(k*u+l*v);v=-0.0-i;u=f*(-0.0-t)+e*v;H=e*t+f*v;c[b>>2]=-1;s=a+4|0;r=c[s>>2]|0;E=c[r+16>>2]|0;F=c[r+20>>2]|0;do{if((F|0)>1){v=H*+g[E+4>>2]+u*+g[E>>2];r=1;A=0;while(1){I=u*+g[E+(r<<3)>>2]+H*+g[E+(r<<3)+4>>2];w=I>v;J=w?r:A;y=r+1|0;if((y|0)<(F|0)){v=w?I:v;r=y;A=J}else{break}}c[d>>2]=J;if((J|0)>-1){K=J;break}ba(7536,103,13816,6368);return 0.0}else{c[d>>2]=0;K=0}}while(0);J=c[s>>2]|0;if((c[J+20>>2]|0)<=(K|0)){ba(7536,103,13816,6368);return 0.0}s=(c[J+16>>2]|0)+(K<<3)|0;H=+g[s>>2];u=+g[s+4>>2];G=t*(p+(f*H-e*u)-j)+i*(m+(e*H+f*u)-o);return+G}else if((q|0)==2){o=+g[a+92>>2];u=+g[a+96>>2];H=f*o-e*u;i=e*o+f*u;u=+g[a+84>>2];o=+g[a+88>>2];j=p+(f*u-e*o);p=m+(e*u+f*o);o=-0.0-i;f=l*(-0.0-H)+k*o;u=k*H+l*o;c[d>>2]=-1;d=a|0;a=c[d>>2]|0;q=c[a+16>>2]|0;s=c[a+20>>2]|0;do{if((s|0)>1){o=u*+g[q+4>>2]+f*+g[q>>2];a=1;K=0;while(1){e=f*+g[q+(a<<3)>>2]+u*+g[q+(a<<3)+4>>2];J=e>o;L=J?a:K;F=a+1|0;if((F|0)<(s|0)){o=J?e:o;a=F;K=L}else{break}}c[b>>2]=L;if((L|0)>-1){M=L;break}ba(7536,103,13816,6368);return 0.0}else{c[b>>2]=0;M=0}}while(0);b=c[d>>2]|0;if((c[b+20>>2]|0)<=(M|0)){ba(7536,103,13816,6368);return 0.0}d=(c[b+16>>2]|0)+(M<<3)|0;u=+g[d>>2];f=+g[d+4>>2];G=H*(n+(l*u-k*f)-j)+i*(h+(k*u+l*f)-p);return+G}else{ba(6688,183,13728,11592);return 0.0}return 0.0}function cA(a,b,d,e){a=a|0;b=b|0;d=d|0;e=+e;var f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0.0,s=0,t=0,u=0.0,v=0.0,w=0.0;f=1.0-e;h=f*+g[a+16>>2]+ +g[a+24>>2]*e;i=f*+g[a+20>>2]+ +g[a+28>>2]*e;j=f*+g[a+32>>2]+ +g[a+36>>2]*e;k=+S(+j);l=+R(+j);j=+g[a+8>>2];m=+g[a+12>>2];n=h-(l*j-k*m);h=i-(k*j+l*m);m=f*+g[a+52>>2]+ +g[a+60>>2]*e;j=f*+g[a+56>>2]+ +g[a+64>>2]*e;i=f*+g[a+68>>2]+ +g[a+72>>2]*e;e=+S(+i);f=+R(+i);i=+g[a+44>>2];o=+g[a+48>>2];p=m-(f*i-e*o);m=j-(e*i+f*o);q=c[a+80>>2]|0;if((q|0)==1){o=+g[a+92>>2];i=+g[a+96>>2];j=+g[a+84>>2];r=+g[a+88>>2];s=c[a+4>>2]|0;if((d|0)<=-1){ba(7536,103,13816,6368);return 0.0}if((c[s+20>>2]|0)<=(d|0)){ba(7536,103,13816,6368);return 0.0}t=(c[s+16>>2]|0)+(d<<3)|0;u=+g[t>>2];v=+g[t+4>>2];w=(l*o-k*i)*(p+(f*u-e*v)-(n+(l*j-k*r)))+(k*o+l*i)*(m+(e*u+f*v)-(h+(k*j+l*r)));return+w}else if((q|0)==2){r=+g[a+92>>2];j=+g[a+96>>2];v=+g[a+84>>2];u=+g[a+88>>2];t=c[a>>2]|0;if((b|0)<=-1){ba(7536,103,13816,6368);return 0.0}if((c[t+20>>2]|0)<=(b|0)){ba(7536,103,13816,6368);return 0.0}s=(c[t+16>>2]|0)+(b<<3)|0;i=+g[s>>2];o=+g[s+4>>2];w=(f*r-e*j)*(n+(l*i-k*o)-(p+(f*v-e*u)))+(e*r+f*j)*(h+(k*i+l*o)-(m+(e*v+f*u)));return+w}else if((q|0)==0){u=+g[a+92>>2];v=+g[a+96>>2];q=c[a>>2]|0;if((b|0)<=-1){ba(7536,103,13816,6368);return 0.0}if((c[q+20>>2]|0)<=(b|0)){ba(7536,103,13816,6368);return 0.0}s=(c[q+16>>2]|0)+(b<<3)|0;o=+g[s>>2];i=+g[s+4>>2];s=c[a+4>>2]|0;if((d|0)<=-1){ba(7536,103,13816,6368);return 0.0}if((c[s+20>>2]|0)<=(d|0)){ba(7536,103,13816,6368);return 0.0}a=(c[s+16>>2]|0)+(d<<3)|0;j=+g[a>>2];r=+g[a+4>>2];w=u*(p+(f*j-e*r)-(n+(l*o-k*i)))+v*(m+(e*j+f*r)-(h+(k*o+l*i)));return+w}else{ba(6688,242,13656,11592);return 0.0}return 0.0}function cB(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0;e=df(d,40)|0;if((e|0)==0){f=0}else{c[e>>2]=20296;c[e+4>>2]=3;g[e+8>>2]=.009999999776482582;c[e+12>>2]=0;c[e+16>>2]=0;a[e+36|0]=0;a[e+37|0]=0;f=e}e=c[b+12>>2]|0;d=c[b+16>>2]|0;h=f+12|0;if((c[h>>2]|0)!=0){ba(6208,48,18448,11256);return 0}i=f+16|0;if((c[i>>2]|0)!=0){ba(6208,48,18448,11256);return 0}if((d|0)>1){c[i>>2]=d;j=vh(d<<3)|0;c[h>>2]=j;h=e;e=c[i>>2]<<3;vp(j|0,h|0,e)|0;e=f+36|0;a[e]=0;h=f+37|0;a[h]=0;j=b+20|0;i=f+20|0;d=c[j+4>>2]|0;c[i>>2]=c[j>>2];c[i+4>>2]=d;d=b+28|0;i=f+28|0;j=c[d+4>>2]|0;c[i>>2]=c[d>>2];c[i+4>>2]=j;a[e]=a[b+36|0]&1;a[h]=a[b+37|0]&1;return f|0}else{ba(6208,49,18448,6736);return 0}return 0}function cC(a,b,c){a=a|0;b=b|0;c=c|0;return 0}function cD(a){a=a|0;return}function cE(a){a=a|0;return 1}function cF(a){a=a|0;return}function cG(a){a=a|0;return 1}function cH(a,b,c){a=a|0;b=b|0;c=c|0;return 0}function cI(a){a=a|0;return 1}function cJ(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=+g[b+12>>2];e=+g[a+12>>2];f=+g[b+8>>2];h=+g[a+16>>2];i=+g[c>>2]-(+g[b>>2]+(d*e-f*h));j=+g[c+4>>2]-(+g[b+4>>2]+(e*f+d*h));h=+g[a+8>>2];return i*i+j*j<=h*h|0}function cK(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0;e=+g[c+12>>2];f=+g[a+12>>2];h=+g[c+8>>2];i=+g[a+16>>2];j=+g[c>>2]+(e*f-h*i);k=+g[c+4>>2]+(f*h+e*i);c=a+8|0;i=+g[c>>2];g[b>>2]=j-i;g[b+4>>2]=k-i;i=+g[c>>2];g[b+8>>2]=j+i;g[b+12>>2]=k+i;return}function cL(a,b,d){a=a|0;b=b|0;d=+d;var e=0,f=0.0,h=0.0,i=0,j=0,k=0,l=0,m=0.0;e=a+8|0;f=+g[e>>2];h=f*d*3.1415927410125732*f;g[b>>2]=h;i=a+12|0;j=i;k=b+4|0;l=c[j+4>>2]|0;c[k>>2]=c[j>>2];c[k+4>>2]=l;f=+g[e>>2];d=+g[i>>2];m=+g[a+16>>2];g[b+12>>2]=h*(f*f*.5+(d*d+m*m));return}function cM(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0;e=+g[c+12>>2];f=+g[a+12>>2];h=+g[c+8>>2];i=+g[a+16>>2];j=+g[c>>2];k=j+(e*f-h*i);l=+g[c+4>>2];m=f*h+e*i+l;i=+g[a+20>>2];f=+g[a+24>>2];n=j+(e*i-h*f);j=l+(h*i+e*f);f=+g[a+8>>2];a=b;e=+((m>2]=(k>2]=e;a=b+8|0;e=+(f+(m>j?m:j));g[a>>2]=f+(k>n?k:n);g[a+4>>2]=e;return}function cN(a,b,c){a=a|0;b=b|0;c=+c;var d=0;g[b>>2]=0.0;d=b+4|0;c=+((+g[a+16>>2]+ +g[a+24>>2])*.5);g[d>>2]=(+g[a+12>>2]+ +g[a+20>>2])*.5;g[d+4>>2]=c;g[b+12>>2]=0.0;return}function cO(a,b,c){a=a|0;b=b|0;c=+c;vq(b|0,0,16);return}function cP(a,b){a=a|0;b=b|0;var d=0,e=0;d=df(b,20)|0;if((d|0)==0){e=0}else{c[d>>2]=20136;vq(d+4|0,0,16);e=d}c[e+4>>2]=c[a+4>>2];g[e+8>>2]=+g[a+8>>2];d=a+12|0;a=e+12|0;b=c[d+4>>2]|0;c[a>>2]=c[d>>2];c[a+4>>2]=b;return e|0}function cQ(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0;f=+g[d+12>>2];h=+g[a+12>>2];i=+g[d+8>>2];j=+g[a+16>>2];k=+g[c>>2];l=k-(+g[d>>2]+(f*h-i*j));m=+g[c+4>>2];n=m-(+g[d+4>>2]+(h*i+f*j));j=+g[a+8>>2];f=+g[c+8>>2]-k;k=+g[c+12>>2]-m;m=l*f+n*k;i=f*f+k*k;h=m*m-(l*l+n*n-j*j)*i;if(h<0.0|i<1.1920928955078125e-7){o=0;return o|0}j=m+ +P(+h);h=-0.0-j;if(j>-0.0){o=0;return o|0}if(i*+g[c+16>>2]>2]=j;i=l+f*j;f=n+k*j;c=b;j=+f;g[c>>2]=i;g[c+4>>2]=j;j=+P(+(i*i+f*f));if(j<1.1920928955078125e-7){o=1;return o|0}k=1.0/j;g[b>>2]=i*k;g[b+4>>2]=f*k;o=1;return o|0}function cR(a){a=a|0;vl(a);return}function cS(b,d){b=b|0;d=d|0;var e=0,f=0,h=0;e=df(d,48)|0;if((e|0)==0){f=0}else{c[e>>2]=20512;c[e+4>>2]=1;g[e+8>>2]=.009999999776482582;vq(e+28|0,0,18);f=e}c[f+4>>2]=c[b+4>>2];g[f+8>>2]=+g[b+8>>2];e=b+12|0;d=f+12|0;h=c[e+4>>2]|0;c[d>>2]=c[e>>2];c[d+4>>2]=h;h=b+20|0;d=f+20|0;e=c[h+4>>2]|0;c[d>>2]=c[h>>2];c[d+4>>2]=e;e=b+28|0;d=f+28|0;h=c[e+4>>2]|0;c[d>>2]=c[e>>2];c[d+4>>2]=h;h=b+36|0;d=f+36|0;e=c[h+4>>2]|0;c[d>>2]=c[h>>2];c[d+4>>2]=e;a[f+44|0]=a[b+44|0]&1;a[f+45|0]=a[b+45|0]&1;return f|0}function cT(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;var f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0;f=+g[d>>2];h=+g[c>>2]-f;i=+g[d+4>>2];j=+g[c+4>>2]-i;k=+g[d+12>>2];l=+g[d+8>>2];m=h*k+j*l;n=-0.0-l;o=k*j+h*n;h=+g[c+8>>2]-f;f=+g[c+12>>2]-i;i=k*h+l*f-m;l=h*n+k*f-o;d=a+12|0;f=+g[d>>2];k=+g[d+4>>2];d=a+20|0;n=+g[d>>2]-f;h=+g[d+4>>2]-k;j=-0.0-n;p=n*n+h*h;q=+P(+p);if(q<1.1920928955078125e-7){r=h;s=j}else{t=1.0/q;r=h*t;s=t*j}j=(k-o)*s+(f-m)*r;t=l*s+i*r;if(t==0.0){u=0;return u|0}q=j/t;if(q<0.0){u=0;return u|0}if(+g[c+16>>2]1.0){u=0;return u|0}g[b+8>>2]=q;if(j>0.0){c=b;j=+(-0.0-s);g[c>>2]=-0.0-r;g[c+4>>2]=j;u=1;return u|0}else{c=b;j=+s;g[c>>2]=r;g[c+4>>2]=j;u=1;return u|0}return 0}function cU(a){a=a|0;vl(a);return}function cV(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=df(b,152)|0;if((d|0)==0){e=0}else{c[d>>2]=20032;c[d+4>>2]=2;g[d+8>>2]=.009999999776482582;c[d+148>>2]=0;g[d+12>>2]=0.0;g[d+16>>2]=0.0;e=d}c[e+4>>2]=c[a+4>>2];g[e+8>>2]=+g[a+8>>2];d=a+12|0;b=e+12|0;f=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=f;f=e+20|0;b=a+20|0;vp(f|0,b|0,64)|0;b=e+84|0;f=a+84|0;vp(b|0,f|0,64)|0;c[e+148>>2]=c[a+148>>2];return e|0}function cW(a,b,d,e,f){a=a|0;b=+b;d=+d;e=e|0;f=+f;var h=0,i=0.0,j=0.0,k=0,l=0,m=0.0,n=0.0,o=0.0;h=a+148|0;c[h>>2]=4;i=-0.0-b;j=-0.0-d;g[a+20>>2]=i;g[a+24>>2]=j;g[a+28>>2]=b;g[a+32>>2]=j;g[a+36>>2]=b;g[a+40>>2]=d;g[a+44>>2]=i;g[a+48>>2]=d;g[a+84>>2]=0.0;g[a+88>>2]=-1.0;g[a+92>>2]=1.0;g[a+96>>2]=0.0;g[a+100>>2]=0.0;g[a+104>>2]=1.0;g[a+108>>2]=-1.0;g[a+112>>2]=0.0;k=e;e=a+12|0;l=c[k+4>>2]|0;c[e>>2]=c[k>>2];c[e+4>>2]=l;d=+g[k>>2];i=+g[k+4>>2];b=+S(+f);m=+R(+f);k=0;f=j;j=-1.0;while(1){l=a+20+(k<<3)|0;n=+g[l>>2];e=l;o=+(i+(b*n+m*f));g[e>>2]=d+(m*n-b*f);g[e+4>>2]=o;e=a+84+(k<<3)|0;o=+g[e>>2];l=e;n=+(b*o+m*j);g[l>>2]=m*o-b*j;g[l+4>>2]=n;l=k+1|0;if((l|0)>=(c[h>>2]|0)){break}k=l;f=+g[a+20+(l<<3)+4>>2];j=+g[a+84+(l<<3)+4>>2]}return}function cX(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,h=0,i=0,j=0,k=0,l=0;if((e|0)<=-1){ba(6208,89,14624,5952)}f=b+16|0;if(((c[f>>2]|0)-1|0)<=(e|0)){ba(6208,89,14624,5952)}c[d+4>>2]=1;g[d+8>>2]=+g[b+8>>2];h=b+12|0;i=(c[h>>2]|0)+(e<<3)|0;j=d+12|0;k=c[i+4>>2]|0;c[j>>2]=c[i>>2];c[j+4>>2]=k;k=(c[h>>2]|0)+(e+1<<3)|0;j=d+20|0;i=c[k+4>>2]|0;c[j>>2]=c[k>>2];c[j+4>>2]=i;i=d+28|0;if((e|0)>0){j=(c[h>>2]|0)+(e-1<<3)|0;k=i;l=c[j+4>>2]|0;c[k>>2]=c[j>>2];c[k+4>>2]=l;a[d+44|0]=1}else{l=b+20|0;k=i;i=c[l+4>>2]|0;c[k>>2]=c[l>>2];c[k+4>>2]=i;a[d+44|0]=a[b+36|0]&1}i=d+36|0;if(((c[f>>2]|0)-2|0)>(e|0)){f=(c[h>>2]|0)+(e+2<<3)|0;e=i;h=c[f+4>>2]|0;c[e>>2]=c[f>>2];c[e+4>>2]=h;a[d+45|0]=1;return}else{h=b+28|0;e=i;i=c[h+4>>2]|0;c[e>>2]=c[h>>2];c[e+4>>2]=i;a[d+45|0]=a[b+37|0]&1;return}}function cY(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,j=0,k=0,l=0,m=0,n=0;h=i;i=i+48|0;j=h|0;k=c[a+16>>2]|0;if((k|0)>(f|0)){c[j>>2]=20512;c[j+4>>2]=1;g[j+8>>2]=.009999999776482582;vq(j+28|0,0,18);l=f+1|0;m=c[a+12>>2]|0;a=m+(f<<3)|0;f=j+12|0;n=c[a+4>>2]|0;c[f>>2]=c[a>>2];c[f+4>>2]=n;n=m+(((l|0)==(k|0)?0:l)<<3)|0;l=j+20|0;k=c[n+4>>2]|0;c[l>>2]=c[n>>2];c[l+4>>2]=k;k=cT(j,b,d,e,0)|0;i=h;return k|0}else{ba(6208,129,14512,5512);return 0}return 0}function cZ(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,i=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0;f=c[a+16>>2]|0;if((f|0)>(e|0)){h=e+1|0;i=(h|0)==(f|0)?0:h;h=c[a+12>>2]|0;j=+g[d+12>>2];k=+g[h+(e<<3)>>2];l=+g[d+8>>2];m=+g[h+(e<<3)+4>>2];n=+g[d>>2];o=n+(j*k-l*m);p=+g[d+4>>2];q=k*l+j*m+p;m=+g[h+(i<<3)>>2];k=+g[h+(i<<3)+4>>2];r=n+(j*m-l*k);n=p+(l*m+j*k);i=b;k=+(q>2]=o>2]=k;i=b+8|0;k=+(q>n?q:n);g[i>>2]=o>r?o:r;g[i+4>>2]=k;return}else{ba(6208,148,14688,5512)}}function c_(a){a=a|0;return}function c$(a){a=a|0;return}function c0(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return}function c1(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return}function c2(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;return}function c3(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;return}function c4(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return}function c5(a,b){a=a|0;b=b|0;return}function c6(a,b,d){a=a|0;b=b|0;d=d|0;var e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0,m=0;e=+g[d>>2]- +g[b>>2];f=+g[d+4>>2]- +g[b+4>>2];h=+g[b+12>>2];i=+g[b+8>>2];j=e*h+f*i;k=h*f+e*(-0.0-i);b=c[a+148>>2]|0;d=0;while(1){if((d|0)>=(b|0)){l=1;m=926;break}if((j- +g[a+20+(d<<3)>>2])*+g[a+84+(d<<3)>>2]+(k- +g[a+20+(d<<3)+4>>2])*+g[a+84+(d<<3)+4>>2]>0.0){l=0;m=925;break}else{d=d+1|0}}if((m|0)==925){return l|0}else if((m|0)==926){return l|0}return 0}function c7(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0,w=0.0,x=0.0,y=0.0,z=0.0;f=+g[d+12>>2];h=+g[a+20>>2];i=+g[d+8>>2];j=+g[a+24>>2];k=+g[d>>2];l=k+(f*h-i*j);m=+g[d+4>>2];n=h*i+f*j+m;d=c[a+148>>2]|0;if((d|0)>1){j=n;h=l;o=n;p=l;e=1;while(1){q=+g[a+20+(e<<3)>>2];r=+g[a+20+(e<<3)+4>>2];s=k+(f*q-i*r);t=q*i+f*r+m;r=hs?p:s;s=o>t?o:t;v=e+1|0;if((v|0)<(d|0)){j=q;h=r;o=s;p=u;e=v}else{w=q;x=r;y=s;z=u;break}}}else{w=n;x=l;y=n;z=l}l=+g[a+8>>2];a=b;n=+(w-l);g[a>>2]=x-l;g[a+4>>2]=n;a=b+8|0;n=+(y+l);g[a>>2]=z+l;g[a+4>>2]=n;return}function c8(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0;d=+g[b+16>>2];e=+g[b+32>>2];f=+g[b+20>>2];h=+g[b+28>>2];i=d*e-f*h;j=+g[b+24>>2];k=+g[b+12>>2];l=f*j-e*k;m=h*k-d*j;n=+g[b>>2];o=+g[b+4>>2];p=+g[b+8>>2];q=i*n+o*l+m*p;if(q!=0.0){r=1.0/q}else{r=q}q=+g[c>>2];s=+g[c+4>>2];t=+g[c+8>>2];g[a>>2]=r*(i*q+s*l+m*t);g[a+4>>2]=r*((s*e-t*h)*n+o*(t*j-e*q)+(h*q-s*j)*p);g[a+8>>2]=r*((d*t-f*s)*n+o*(f*q-t*k)+(s*k-d*q)*p);return}function c9(a){a=a|0;vl(a);return}function da(a){a=a|0;vl(a);return}function db(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=i;i=i+16|0;e=d|0;f=e;c[f>>2]=b;c[f+4>>2]=0;a2(a|0,e|0)|0;i=d;return}function dc(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,k=0,l=0,m=0.0,n=0.0,o=0,p=0.0,q=0.0,r=0,s=0,t=0.0,u=0.0,v=0.0,w=0,x=0.0,y=0.0;if((d-3|0)>>>0>=6){ba(5664,122,17936,11096)}e=a+148|0;c[e>>2]=d;d=0;do{f=b+(d<<3)|0;h=a+20+(d<<3)|0;i=c[f+4>>2]|0;c[h>>2]=c[f>>2];c[h+4>>2]=i;d=d+1|0;j=c[e>>2]|0;}while((d|0)<(j|0));if((j|0)>0){k=j;l=0}else{ba(5664,76,18928,5016)}while(1){j=l+1|0;d=(j|0)<(k|0)?j:0;m=+g[a+20+(d<<3)>>2]- +g[a+20+(l<<3)>>2];n=+g[a+20+(d<<3)+4>>2]- +g[a+20+(l<<3)+4>>2];if(m*m+n*n<=1.4210854715202004e-14){o=943;break}d=a+84+(l<<3)|0;b=d;p=+(m*-1.0);g[b>>2]=n;g[b+4>>2]=p;b=a+84+(l<<3)+4|0;p=+g[b>>2];m=+P(+(n*n+p*p));if(m>=1.1920928955078125e-7){q=1.0/m;g[d>>2]=n*q;g[b>>2]=p*q}r=c[e>>2]|0;if((j|0)<(r|0)){k=r;l=j}else{break}}if((o|0)==943){ba(5664,137,17936,8512)}o=a+12|0;l=a+20|0;if((r|0)>2){s=0;t=0.0;u=0.0;v=0.0}else{ba(5664,76,18928,5016)}do{k=a+20+(s<<3)|0;q=+g[k>>2];p=+g[k+4>>2];s=s+1|0;k=(s|0)<(r|0);if(k){w=a+20+(s<<3)|0}else{w=l}e=w;n=+g[e>>2];m=+g[e+4>>2];x=(q*m-p*n)*.5;t=t+x;y=x*.3333333432674408;u=u+(q+0.0+n)*y;v=v+(p+0.0+m)*y}while(k);if(t>1.1920928955078125e-7){y=1.0/t;w=o;t=+(v*y);g[w>>2]=u*y;g[w+4>>2]=t;return}else{ba(5664,115,18928,5488)}}function dd(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0.0,u=0.0,v=0,w=0.0,x=0,y=0.0;h=+g[e>>2];i=+g[d>>2]-h;j=+g[e+4>>2];k=+g[d+4>>2]-j;f=e+12|0;l=+g[f>>2];m=e+8|0;n=+g[m>>2];o=i*l+k*n;p=-0.0-n;q=l*k+i*p;i=+g[d+8>>2]-h;h=+g[d+12>>2]-j;j=l*i+n*h-o;n=i*p+l*h-q;h=+g[d+16>>2];d=c[a+148>>2]|0;l=0.0;e=0;r=-1;p=h;L1236:while(1){if((e|0)>=(d|0)){s=967;break}i=+g[a+84+(e<<3)>>2];k=+g[a+84+(e<<3)+4>>2];t=(+g[a+20+(e<<3)>>2]-o)*i+(+g[a+20+(e<<3)+4>>2]-q)*k;u=j*i+n*k;L1239:do{if(u==0.0){if(t<0.0){v=0;s=972;break L1236}else{w=l;x=r;y=p}}else{do{if(u<0.0){if(t>=l*u){break}w=t/u;x=e;y=p;break L1239}}while(0);if(u<=0.0){w=l;x=r;y=p;break}if(t>=p*u){w=l;x=r;y=p;break}w=l;x=r;y=t/u}}while(0);if(yh){ba(5664,249,13872,6584);return 0}if((r|0)<=-1){v=0;return v|0}g[b+8>>2]=l;l=+g[f>>2];h=+g[a+84+(r<<3)>>2];y=+g[m>>2];p=+g[a+84+(r<<3)+4>>2];r=b;w=+(h*y+l*p);g[r>>2]=l*h-y*p;g[r+4>>2]=w;v=1;return v|0}return 0}function de(a,b,d){a=a|0;b=b|0;d=+d;var e=0,f=0.0,h=0.0,i=0,j=0.0,k=0.0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0;e=c[a+148>>2]|0;if((e|0)>2){f=0.0;h=0.0;i=0}else{ba(5664,306,13992,5928)}do{h=h+ +g[a+20+(i<<3)>>2];f=f+ +g[a+20+(i<<3)+4>>2];i=i+1|0;}while((i|0)<(e|0));j=1.0/+(e|0);k=h*j;h=f*j;i=a+20|0;l=a+24|0;j=0.0;f=0.0;m=0;n=0.0;o=0.0;do{p=+g[a+20+(m<<3)>>2]-k;q=+g[a+20+(m<<3)+4>>2]-h;m=m+1|0;r=(m|0)<(e|0);if(r){s=a+20+(m<<3)|0;t=a+20+(m<<3)+4|0}else{s=i;t=l}u=+g[s>>2]-k;v=+g[t>>2]-h;w=p*v-q*u;x=w*.5;o=o+x;y=x*.3333333432674408;f=f+(p+u)*y;j=j+(q+v)*y;n=n+w*.0833333358168602*(u*u+(p*p+p*u)+(v*v+(q*q+q*v)))}while(r);v=o*d;g[b>>2]=v;if(o>1.1920928955078125e-7){q=1.0/o;o=f*q;f=j*q;q=k+o;k=h+f;t=b+4|0;h=+k;g[t>>2]=q;g[t+4>>2]=h;g[b+12>>2]=n*d+v*(q*q+k*k-(o*o+f*f));return}else{ba(5664,352,13992,5488)}}function df(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0;if((d|0)==0){e=0;return e|0}if((d|0)<=0){ba(5352,104,17408,8376);return 0}if((d|0)>640){e=vh(d)|0;return e|0}f=a[d+22064|0]|0;d=f&255;if((f&255)>=14){ba(5352,112,17408,6544);return 0}f=b+12+(d<<2)|0;g=c[f>>2]|0;if((g|0)!=0){c[f>>2]=c[g>>2];e=g;return e|0}g=b+4|0;h=c[g>>2]|0;i=b+8|0;j=b|0;if((h|0)==(c[i>>2]|0)){b=c[j>>2]|0;k=h+128|0;c[i>>2]=k;i=vh(k<<3)|0;c[j>>2]=i;k=b;b=c[g>>2]<<3;vp(i|0,k|0,b)|0;vq((c[j>>2]|0)+(c[g>>2]<<3)|0,0,1024);vi(k);l=c[g>>2]|0}else{l=h}h=c[j>>2]|0;j=vh(16384)|0;k=h+(l<<3)+4|0;c[k>>2]=j;b=c[22712+(d<<2)>>2]|0;c[h+(l<<3)>>2]=b;l=16384/(b|0)&-1;if(($(l,b)|0)>=16385){ba(5352,140,17408,5888);return 0}h=l-1|0;if((h|0)>0){l=0;d=j;while(1){i=d+($(l,b)|0)|0;m=l+1|0;c[i>>2]=d+($(m,b)|0);i=c[k>>2]|0;if((m|0)<(h|0)){l=m;d=i}else{n=i;break}}}else{n=j}c[n+($(h,b)|0)>>2]=0;c[f>>2]=c[c[k>>2]>>2];c[g>>2]=(c[g>>2]|0)+1;e=c[k>>2]|0;return e|0}function dg(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0;e=b+102796|0;f=c[e>>2]|0;if((f|0)<=0){ba(4840,63,17080,5864)}g=f-1|0;if((c[b+102412+(g*12&-1)>>2]|0)!=(d|0)){ba(4840,65,17080,5464)}if((a[b+102412+(g*12&-1)+8|0]&1)==0){h=b+102412+(g*12&-1)+4|0;i=b+102400|0;c[i>>2]=(c[i>>2]|0)-(c[h>>2]|0);j=f;k=h}else{vi(d);j=c[e>>2]|0;k=b+102412+(g*12&-1)+4|0}g=b+102404|0;c[g>>2]=(c[g>>2]|0)-(c[k>>2]|0);c[e>>2]=j-1;return}function dh(d,e,f){d=d|0;e=e|0;f=f|0;var h=0,i=0.0,j=0,k=0,l=0,m=0,n=0,o=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0;h=e+4|0;i=+g[h>>2];if(!(i==i&!(C=0.0,C!=C)&i>+-p&i<+p)){ba(4720,27,15920,10600)}i=+g[e+8>>2];if(!(i==i&!(C=0.0,C!=C)&i>+-p&i<+p)){ba(4720,27,15920,10600)}j=e+16|0;i=+g[j>>2];if(!(i==i&!(C=0.0,C!=C)&i>+-p&i<+p)){ba(4720,28,15920,7920)}i=+g[e+20>>2];if(!(i==i&!(C=0.0,C!=C)&i>+-p&i<+p)){ba(4720,28,15920,7920)}k=e+12|0;i=+g[k>>2];if(!(i==i&!(C=0.0,C!=C)&i>+-p&i<+p)){ba(4720,29,15920,6424)}l=e+24|0;i=+g[l>>2];if(!(i==i&!(C=0.0,C!=C)&i>+-p&i<+p)){ba(4720,30,15920,5832)}m=e+32|0;i=+g[m>>2];if(i<0.0|i==i&!(C=0.0,C!=C)&i>+-p&i<+p^1){ba(4720,31,15920,5400)}n=e+28|0;i=+g[n>>2];if(i<0.0|i==i&!(C=0.0,C!=C)&i>+-p&i<+p^1){ba(4720,32,15920,4952)}o=d+4|0;b[o>>1]=0;if((a[e+39|0]&1)==0){q=0}else{b[o>>1]=8;q=8}if((a[e+38|0]&1)==0){r=q}else{s=q|16;b[o>>1]=s;r=s}if((a[e+36|0]&1)==0){t=r}else{s=r|4;b[o>>1]=s;t=s}if((a[e+37|0]&1)==0){u=t}else{s=t|2;b[o>>1]=s;u=s}if((a[e+40|0]&1)!=0){b[o>>1]=u|32}c[d+88>>2]=f;f=h;h=d+12|0;u=c[f>>2]|0;o=c[f+4>>2]|0;c[h>>2]=u;c[h+4>>2]=o;i=+g[k>>2];g[d+20>>2]=+S(+i);g[d+24>>2]=+R(+i);g[d+28>>2]=0.0;g[d+32>>2]=0.0;h=d+36|0;c[h>>2]=u;c[h+4>>2]=o;h=d+44|0;c[h>>2]=u;c[h+4>>2]=o;g[d+52>>2]=+g[k>>2];g[d+56>>2]=+g[k>>2];g[d+60>>2]=0.0;c[d+108>>2]=0;c[d+112>>2]=0;c[d+92>>2]=0;c[d+96>>2]=0;k=j;j=d+64|0;o=c[k+4>>2]|0;c[j>>2]=c[k>>2];c[j+4>>2]=o;g[d+72>>2]=+g[l>>2];g[d+132>>2]=+g[n>>2];g[d+136>>2]=+g[m>>2];g[d+140>>2]=+g[e+48>>2];g[d+76>>2]=0.0;g[d+80>>2]=0.0;g[d+84>>2]=0.0;g[d+144>>2]=0.0;m=c[e>>2]|0;c[d>>2]=m;n=d+116|0;if((m|0)==2){g[n>>2]=1.0;g[d+120>>2]=1.0;v=d+124|0;g[v>>2]=0.0;w=d+128|0;g[w>>2]=0.0;x=e+44|0;y=c[x>>2]|0;z=d+148|0;c[z>>2]=y;A=d+100|0;c[A>>2]=0;B=d+104|0;c[B>>2]=0;return}else{g[n>>2]=0.0;g[d+120>>2]=0.0;v=d+124|0;g[v>>2]=0.0;w=d+128|0;g[w>>2]=0.0;x=e+44|0;y=c[x>>2]|0;z=d+148|0;c[z>>2]=y;A=d+100|0;c[A>>2]=0;B=d+104|0;c[B>>2]=0;return}}function di(a,d){a=a|0;d=d|0;var e=0,f=0,h=0,j=0,l=0.0,m=0,n=0,o=0,p=0,q=0.0,r=0.0,s=0.0,t=0.0,u=0;e=i;i=i+16|0;f=e|0;h=a+88|0;if((c[(c[h>>2]|0)+102868>>2]&2|0)!=0){ba(4720,115,16e3,4688)}j=a|0;if((c[j>>2]|0)==(d|0)){i=e;return}c[j>>2]=d;dj(a);do{if((c[j>>2]|0)==0){g[a+64>>2]=0.0;g[a+68>>2]=0.0;g[a+72>>2]=0.0;l=+g[a+56>>2];g[a+52>>2]=l;d=a+44|0;m=a+36|0;n=c[d>>2]|0;o=c[d+4>>2]|0;c[m>>2]=n;c[m+4>>2]=o;m=f|0;d=f;p=f+8|0;q=+S(+l);g[p>>2]=q;r=+R(+l);g[p+4>>2]=r;l=+g[a+28>>2];s=+g[a+32>>2];t=+((c[k>>2]=o,+g[k>>2])-(q*l+r*s));g[m>>2]=(c[k>>2]=n,+g[k>>2])-(r*l-q*s);g[m+4>>2]=t;m=(c[h>>2]|0)+102872|0;n=c[a+100>>2]|0;if((n|0)==0){break}o=a+12|0;p=n;do{dH(p,m,d,o);p=c[p+4>>2]|0;}while((p|0)!=0)}}while(0);h=a+4|0;f=b[h>>1]|0;if((f&2)==0){b[h>>1]=f|2;g[a+144>>2]=0.0}g[a+76>>2]=0.0;g[a+80>>2]=0.0;g[a+84>>2]=0.0;f=c[a+100>>2]|0;if((f|0)==0){i=e;return}else{u=f}do{dI(u);u=c[u+4>>2]|0;}while((u|0)!=0);i=e;return}function dj(a){a=a|0;var d=0,e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0,u=0,v=0,w=0,x=0,y=0.0,z=0.0,A=0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0.0;d=i;i=i+16|0;e=d|0;f=a+116|0;h=a+120|0;j=a+124|0;k=a+128|0;l=a+28|0;g[l>>2]=0.0;g[a+32>>2]=0.0;vq(f|0,0,16);m=c[a>>2]|0;if((m|0)==2){n=4200;o=+g[n>>2];p=+g[n+4>>2];n=c[a+100>>2]|0;do{if((n|0)==0){q=0.0;r=o;s=p;t=1074}else{u=e|0;v=e+4|0;w=e+8|0;x=e+12|0;y=p;z=o;A=n;B=0.0;C=0.0;while(1){D=+g[A>>2];if(D==0.0){E=z;F=y;G=B;H=C}else{I=c[A+12>>2]|0;bN[c[(c[I>>2]|0)+28>>2]&127](I,e,D);D=+g[u>>2];J=D+ +g[f>>2];g[f>>2]=J;K=z+D*+g[v>>2];L=y+D*+g[w>>2];D=+g[x>>2]+ +g[j>>2];g[j>>2]=D;E=K;F=L;G=J;H=D}I=c[A+4>>2]|0;if((I|0)==0){break}else{y=F;z=E;A=I;B=G;C=H}}if(G<=0.0){q=H;r=E;s=F;t=1074;break}C=1.0/G;g[h>>2]=C;M=E*C;N=F*C;O=G;P=H}}while(0);if((t|0)==1074){g[f>>2]=1.0;g[h>>2]=1.0;M=r;N=s;O=1.0;P=q}do{if(P>0.0){if((b[a+4>>1]&16)!=0){t=1080;break}q=P-(N*N+M*M)*O;g[j>>2]=q;if(q>0.0){Q=1.0/q;break}else{ba(4720,319,16088,11792)}}else{t=1080}}while(0);if((t|0)==1080){g[j>>2]=0.0;Q=0.0}g[k>>2]=Q;k=a+44|0;Q=+g[k>>2];O=+g[k+4>>2];j=l;P=+N;g[j>>2]=M;g[j+4>>2]=P;P=+g[a+24>>2];q=+g[a+20>>2];s=+g[a+12>>2]+(P*M-q*N);r=M*q+P*N+ +g[a+16>>2];N=+s;P=+r;g[k>>2]=N;g[k+4>>2]=P;k=a+36|0;g[k>>2]=N;g[k+4>>2]=P;P=+g[a+72>>2];k=a+64|0;g[k>>2]=+g[k>>2]+(r-O)*(-0.0-P);k=a+68|0;g[k>>2]=P*(s-Q)+ +g[k>>2];i=d;return}else if((m|0)==0|(m|0)==1){m=a+12|0;k=a+36|0;j=c[m>>2]|0;l=c[m+4>>2]|0;c[k>>2]=j;c[k+4>>2]=l;k=a+44|0;c[k>>2]=j;c[k+4>>2]=l;g[a+52>>2]=+g[a+56>>2];i=d;return}else{ba(4720,284,16088,12360)}}function dk(d,e){d=d|0;e=e|0;var f=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0;f=d+88|0;h=c[f>>2]|0;if((c[h+102868>>2]&2|0)!=0){ba(4720,153,16120,4688);return 0}i=h|0;h=df(i,44)|0;if((h|0)==0){j=0}else{b[h+32>>1]=1;b[h+34>>1]=-1;b[h+36>>1]=0;c[h+40>>2]=0;c[h+24>>2]=0;c[h+28>>2]=0;vq(h|0,0,16);j=h}c[j+40>>2]=c[e+4>>2];g[j+16>>2]=+g[e+8>>2];g[j+20>>2]=+g[e+12>>2];h=j+8|0;c[h>>2]=d;k=j+4|0;c[k>>2]=0;l=j+32|0;m=e+22|0;b[l>>1]=b[m>>1]|0;b[l+2>>1]=b[m+2>>1]|0;b[l+4>>1]=b[m+4>>1]|0;a[j+38|0]=a[e+20|0]&1;m=c[e>>2]|0;l=bF[c[(c[m>>2]|0)+8>>2]&255](m,i)|0;m=j+12|0;c[m>>2]=l;n=bq[c[(c[l>>2]|0)+12>>2]&1023](l)|0;l=df(i,n*28&-1)|0;i=j+24|0;c[i>>2]=l;do{if((n|0)>0){c[l+16>>2]=0;c[(c[i>>2]|0)+24>>2]=-1;if((n|0)>1){o=1}else{break}do{c[(c[i>>2]|0)+(o*28&-1)+16>>2]=0;c[(c[i>>2]|0)+(o*28&-1)+24>>2]=-1;o=o+1|0;}while((o|0)<(n|0))}}while(0);n=j+28|0;c[n>>2]=0;o=j|0;g[o>>2]=+g[e+16>>2];do{if((b[d+4>>1]&32)!=0){e=(c[f>>2]|0)+102872|0;l=d+12|0;p=c[m>>2]|0;q=bq[c[(c[p>>2]|0)+12>>2]&1023](p)|0;c[n>>2]=q;if((q|0)>0){r=0}else{break}do{q=c[i>>2]|0;p=q+(r*28&-1)|0;s=c[m>>2]|0;t=p|0;bO[c[(c[s>>2]|0)+24>>2]&127](s,t,l,r);c[q+(r*28&-1)+24>>2]=b4(e,t,p)|0;c[q+(r*28&-1)+16>>2]=j;c[q+(r*28&-1)+20>>2]=r;r=r+1|0;}while((r|0)<(c[n>>2]|0))}}while(0);n=d+100|0;c[k>>2]=c[n>>2];c[n>>2]=j;n=d+104|0;c[n>>2]=(c[n>>2]|0)+1;c[h>>2]=d;if(+g[o>>2]<=0.0){u=c[f>>2]|0;v=u+102868|0;w=c[v>>2]|0;x=w|1;c[v>>2]=x;return j|0}dj(d);u=c[f>>2]|0;v=u+102868|0;w=c[v>>2]|0;x=w|1;c[v>>2]=x;return j|0}function dl(a){a=a|0;return}function dm(a){a=a|0;return}function dn(a){a=a|0;var d=0,e=0,f=0,j=0.0,k=0,l=0;d=i;e=a+8|0;f=c[e>>2]|0;db(11584,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(11232,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(11032,(u=i,i=i+8|0,c[u>>2]=c[a>>2],u)|0);j=+g[a+16>>2];db(10864,(u=i,i=i+16|0,h[u>>3]=+g[a+12>>2],h[u+8>>3]=j,u)|0);db(10576,(u=i,i=i+8|0,h[u>>3]=+g[a+56>>2],u)|0);j=+g[a+68>>2];db(10464,(u=i,i=i+16|0,h[u>>3]=+g[a+64>>2],h[u+8>>3]=j,u)|0);db(10320,(u=i,i=i+8|0,h[u>>3]=+g[a+72>>2],u)|0);db(10064,(u=i,i=i+8|0,h[u>>3]=+g[a+132>>2],u)|0);db(9640,(u=i,i=i+8|0,h[u>>3]=+g[a+136>>2],u)|0);k=a+4|0;db(9568,(u=i,i=i+8|0,c[u>>2]=b[k>>1]&4,u)|0);db(9144,(u=i,i=i+8|0,c[u>>2]=b[k>>1]&2,u)|0);db(8864,(u=i,i=i+8|0,c[u>>2]=b[k>>1]&16,u)|0);db(8712,(u=i,i=i+8|0,c[u>>2]=b[k>>1]&8,u)|0);db(8344,(u=i,i=i+8|0,c[u>>2]=b[k>>1]&32,u)|0);db(8128,(u=i,i=i+8|0,h[u>>3]=+g[a+140>>2],u)|0);db(7840,(u=i,i=i+8|0,c[u>>2]=c[e>>2],u)|0);db(7344,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);e=c[a+100>>2]|0;if((e|0)==0){db(11328,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);i=d;return}else{l=e}do{db(7480,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);dJ(l,f);db(7352,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);l=c[l+4>>2]|0;}while((l|0)!=0);db(11328,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);i=d;return}function dp(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;d=c[(c[b+48>>2]|0)+8>>2]|0;e=c[(c[b+52>>2]|0)+8>>2]|0;f=c[a+72>>2]|0;do{if((f|0)!=0){if((c[b+4>>2]&2|0)==0){break}bp[c[(c[f>>2]|0)+12>>2]&511](f,b)}}while(0);f=b+8|0;g=c[f>>2]|0;h=b+12|0;if((g|0)!=0){c[g+12>>2]=c[h>>2]}g=c[h>>2]|0;if((g|0)!=0){c[g+8>>2]=c[f>>2]}f=a+60|0;if((c[f>>2]|0)==(b|0)){c[f>>2]=c[h>>2]}h=b+24|0;f=c[h>>2]|0;g=b+28|0;if((f|0)!=0){c[f+12>>2]=c[g>>2]}f=c[g>>2]|0;if((f|0)!=0){c[f+8>>2]=c[h>>2]}h=d+112|0;if((b+16|0)==(c[h>>2]|0)){c[h>>2]=c[g>>2]}g=b+40|0;h=c[g>>2]|0;d=b+44|0;if((h|0)!=0){c[h+12>>2]=c[d>>2]}h=c[d>>2]|0;if((h|0)!=0){c[h+8>>2]=c[g>>2]}g=e+112|0;if((b+32|0)!=(c[g>>2]|0)){i=a+76|0;j=c[i>>2]|0;em(b,j);k=a+64|0;l=c[k>>2]|0;m=l-1|0;c[k>>2]=m;return}c[g>>2]=c[d>>2];i=a+76|0;j=c[i>>2]|0;em(b,j);k=a+64|0;l=c[k>>2]|0;m=l-1|0;c[k>>2]=m;return}function dq(d,e){d=d|0;e=e|0;var f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0;f=d+88|0;if((c[(c[f>>2]|0)+102868>>2]&2|0)!=0){ba(4720,201,16040,4688)}g=e+8|0;if((c[g>>2]|0)!=(d|0)){ba(4720,207,16040,4464)}h=d+104|0;if((c[h>>2]|0)<=0){ba(4720,210,16040,4208)}i=d+100|0;while(1){j=c[i>>2]|0;if((j|0)==0){k=1141;break}if((j|0)==(e|0)){break}else{i=j+4|0}}if((k|0)==1141){ba(4720,226,16040,12760)}j=e+4|0;c[i>>2]=c[j>>2];i=c[d+112>>2]|0;if((i|0)!=0){l=i;do{i=c[l+4>>2]|0;l=c[l+12>>2]|0;if((c[i+48>>2]|0)==(e|0)|(c[i+52>>2]|0)==(e|0)){dp((c[f>>2]|0)+102872|0,i)}}while((l|0)!=0)}l=c[f>>2]|0;f=l|0;if((b[d+4>>1]&32)!=0){i=e+28|0;if((c[i>>2]|0)>0){m=e+24|0;n=l+102912|0;o=l+102904|0;p=l+102900|0;q=l+102872|0;r=0;do{s=(c[m>>2]|0)+(r*28&-1)+24|0;t=c[s>>2]|0;u=c[n>>2]|0;v=0;while(1){if((v|0)>=(u|0)){break}w=(c[o>>2]|0)+(v<<2)|0;if((c[w>>2]|0)==(t|0)){k=1151;break}else{v=v+1|0}}if((k|0)==1151){k=0;c[w>>2]=-1}c[p>>2]=(c[p>>2]|0)-1;cl(q,t);c[s>>2]=-1;r=r+1|0;}while((r|0)<(c[i>>2]|0))}c[i>>2]=0}dK(e,f);c[g>>2]=0;c[j>>2]=0;j=a[22108]|0;if((j&255)<14){g=l+12+((j&255)<<2)|0;c[e>>2]=c[g>>2];c[g>>2]=e;c[h>>2]=(c[h>>2]|0)-1;dj(d);return}else{ba(5352,173,17448,6544)}}function dr(a,d){a=a|0;d=d|0;var e=0,f=0,h=0,i=0.0,j=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0.0,q=0.0,r=0.0;if((c[(c[a+88>>2]|0)+102868>>2]&2|0)!=0){ba(4720,340,16232,4688)}if((c[a>>2]|0)!=2){return}e=a+120|0;g[e>>2]=0.0;f=a+124|0;g[f>>2]=0.0;h=a+128|0;g[h>>2]=0.0;i=+g[d>>2];j=i>0.0?i:1.0;g[a+116>>2]=j;g[e>>2]=1.0/j;i=+g[d+12>>2];do{if(i>0.0){if((b[a+4>>1]&16)!=0){break}l=+g[d+4>>2];m=+g[d+8>>2];n=i-j*(l*l+m*m);g[f>>2]=n;if(n>0.0){g[h>>2]=1.0/n;break}else{ba(4720,366,16232,11792)}}}while(0);h=a+44|0;j=+g[h>>2];i=+g[h+4>>2];f=d+4|0;d=a+28|0;e=c[f>>2]|0;o=c[f+4>>2]|0;c[d>>2]=e;c[d+4>>2]=o;n=+g[a+24>>2];m=(c[k>>2]=e,+g[k>>2]);l=+g[a+20>>2];p=(c[k>>2]=o,+g[k>>2]);q=+g[a+12>>2]+(n*m-l*p);r=m*l+n*p+ +g[a+16>>2];p=+q;n=+r;g[h>>2]=p;g[h+4>>2]=n;h=a+36|0;g[h>>2]=p;g[h+4>>2]=n;n=+g[a+72>>2];h=a+64|0;g[h>>2]=+g[h>>2]+(r-i)*(-0.0-n);h=a+68|0;g[h>>2]=n*(q-j)+ +g[h>>2];return}function ds(a,b,d){a=a|0;b=b|0;d=+d;var e=0,f=0,h=0,i=0.0,j=0.0,l=0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0,t=0,u=0,v=0;e=a+88|0;f=c[e>>2]|0;if((c[f+102868>>2]&2|0)!=0){ba(4720,404,16176,4688)}h=a+12|0;i=+S(+d);g[a+20>>2]=i;j=+R(+d);g[a+24>>2]=j;l=b;b=h;m=c[l>>2]|0;n=c[l+4>>2]|0;c[b>>2]=m;c[b+4>>2]=n;o=+g[a+28>>2];p=+g[a+32>>2];b=a+44|0;q=+((c[k>>2]=m,+g[k>>2])+(j*o-i*p));r=+(o*i+j*p+(c[k>>2]=n,+g[k>>2]));g[b>>2]=q;g[b+4>>2]=r;g[a+56>>2]=d;b=a+36|0;g[b>>2]=q;g[b+4>>2]=r;g[a+52>>2]=d;b=f+102872|0;n=c[a+100>>2]|0;if((n|0)==0){s=f;t=s+102872|0;u=t|0;dy(u,t);return}else{v=n}do{dH(v,b,h,h);v=c[v+4>>2]|0;}while((v|0)!=0);s=c[e>>2]|0;t=s+102872|0;u=t|0;dy(u,t);return}function dt(a,d){a=a|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;e=a+88|0;f=c[e>>2]|0;if((c[f+102868>>2]&2|0)!=0){ba(4720,443,15968,4688)}g=a+4|0;h=b[g>>1]|0;if(!((h&32)!=0^d)){return}if(d){b[g>>1]=h|32;d=f+102872|0;i=c[a+100>>2]|0;if((i|0)==0){return}j=a+12|0;k=i;while(1){i=k+28|0;if((c[i>>2]|0)!=0){l=1184;break}m=k+12|0;n=c[m>>2]|0;o=bq[c[(c[n>>2]|0)+12>>2]&1023](n)|0;c[i>>2]=o;if((o|0)>0){o=k+24|0;n=0;do{p=c[o>>2]|0;q=p+(n*28&-1)|0;r=c[m>>2]|0;s=q|0;bO[c[(c[r>>2]|0)+24>>2]&127](r,s,j,n);c[p+(n*28&-1)+24>>2]=b4(d,s,q)|0;c[p+(n*28&-1)+16>>2]=k;c[p+(n*28&-1)+20>>2]=n;n=n+1|0;}while((n|0)<(c[i>>2]|0))}i=c[k+4>>2]|0;if((i|0)==0){l=1205;break}else{k=i}}if((l|0)==1205){return}else if((l|0)==1184){ba(12280,124,14968,12608)}}b[g>>1]=h&-33;h=c[a+100>>2]|0;if((h|0)!=0){g=f+102912|0;k=f+102904|0;d=f+102900|0;j=f+102872|0;f=h;do{h=f+28|0;if((c[h>>2]|0)>0){i=f+24|0;n=0;do{m=(c[i>>2]|0)+(n*28&-1)+24|0;o=c[m>>2]|0;p=c[g>>2]|0;q=0;while(1){if((q|0)>=(p|0)){break}t=(c[k>>2]|0)+(q<<2)|0;if((c[t>>2]|0)==(o|0)){l=1196;break}else{q=q+1|0}}if((l|0)==1196){l=0;c[t>>2]=-1}c[d>>2]=(c[d>>2]|0)-1;cl(j,o);c[m>>2]=-1;n=n+1|0;}while((n|0)<(c[h>>2]|0))}c[h>>2]=0;f=c[f+4>>2]|0;}while((f|0)!=0)}f=a+112|0;a=c[f>>2]|0;if((a|0)!=0){j=a;while(1){a=c[j+12>>2]|0;dp((c[e>>2]|0)+102872|0,c[j+4>>2]|0);if((a|0)==0){break}else{j=a}}}c[f>>2]=0;return}function du(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=c[a>>2]|0;e=c[b>>2]|0;if((d|0)<(e|0)){f=1;return f|0}if((d|0)!=(e|0)){f=0;return f|0}f=(c[a+4>>2]|0)<(c[b+4>>2]|0);return f|0}function dv(d,e,f){d=d|0;e=e|0;f=f|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0;h=c[e+16>>2]|0;i=c[f+16>>2]|0;j=c[e+20>>2]|0;e=c[f+20>>2]|0;f=c[h+8>>2]|0;k=c[i+8>>2]|0;if((f|0)==(k|0)){return}l=c[k+112>>2]|0;L1593:do{if((l|0)!=0){m=l;while(1){if((c[m>>2]|0)==(f|0)){n=c[m+4>>2]|0;o=c[n+48>>2]|0;p=c[n+52>>2]|0;q=c[n+56>>2]|0;r=c[n+60>>2]|0;if((o|0)==(h|0)&(p|0)==(i|0)&(q|0)==(j|0)&(r|0)==(e|0)){s=1241;break}if((o|0)==(i|0)&(p|0)==(h|0)&(q|0)==(e|0)&(r|0)==(j|0)){s=1247;break}}m=c[m+12>>2]|0;if((m|0)==0){break L1593}}if((s|0)==1241){return}else if((s|0)==1247){return}}}while(0);do{if((c[k>>2]|0)!=2){if((c[f>>2]|0)==2){break}return}}while(0);s=c[k+108>>2]|0;L1608:do{if((s|0)!=0){k=s;while(1){if((c[k>>2]|0)==(f|0)){if((a[(c[k+4>>2]|0)+61|0]&1)==0){break}}k=c[k+12>>2]|0;if((k|0)==0){break L1608}}return}}while(0);f=c[d+68>>2]|0;do{if((f|0)!=0){if(bv[c[(c[f>>2]|0)+8>>2]&127](f,h,i)|0){break}return}}while(0);f=el(h,j,i,e,c[d+76>>2]|0)|0;if((f|0)==0){return}e=c[(c[f+48>>2]|0)+8>>2]|0;i=c[(c[f+52>>2]|0)+8>>2]|0;c[f+8>>2]=0;j=d+60|0;c[f+12>>2]=c[j>>2];h=c[j>>2]|0;if((h|0)!=0){c[h+8>>2]=f}c[j>>2]=f;j=f+16|0;c[f+20>>2]=f;c[j>>2]=i;c[f+24>>2]=0;h=e+112|0;c[f+28>>2]=c[h>>2];s=c[h>>2]|0;if((s|0)!=0){c[s+8>>2]=j}c[h>>2]=j;j=f+32|0;c[f+36>>2]=f;c[j>>2]=e;c[f+40>>2]=0;h=i+112|0;c[f+44>>2]=c[h>>2];f=c[h>>2]|0;if((f|0)!=0){c[f+8>>2]=j}c[h>>2]=j;j=e+4|0;h=b[j>>1]|0;if((h&2)==0){b[j>>1]=h|2;g[e+144>>2]=0.0}e=i+4|0;h=b[e>>1]|0;if((h&2)==0){b[e>>1]=h|2;g[i+144>>2]=0.0}i=d+64|0;c[i>>2]=(c[i>>2]|0)+1;return}function dw(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;e=i;i=i+1040|0;f=e|0;h=f+4|0;j=f|0;c[j>>2]=h;k=f+1028|0;c[k>>2]=0;l=f+1032|0;c[l>>2]=256;c[(c[j>>2]|0)+(c[k>>2]<<2)>>2]=c[a>>2];f=(c[k>>2]|0)+1|0;c[k>>2]=f;if((f|0)>0){m=a+4|0;a=d|0;n=d+4|0;o=d+8|0;p=d+12|0;d=b+56|0;q=b+52|0;r=b+48|0;s=b+44|0;b=f;while(1){f=b-1|0;c[k>>2]=f;t=c[j>>2]|0;u=c[t+(f<<2)>>2]|0;do{if((u|0)==-1){v=f}else{w=c[m>>2]|0;if(+g[a>>2]- +g[w+(u*36&-1)+8>>2]>0.0|+g[n>>2]- +g[w+(u*36&-1)+12>>2]>0.0|+g[w+(u*36&-1)>>2]- +g[o>>2]>0.0|+g[w+(u*36&-1)+4>>2]- +g[p>>2]>0.0){v=f;break}x=w+(u*36&-1)+24|0;if((c[x>>2]|0)==-1){y=c[d>>2]|0;if((y|0)==(u|0)){v=f;break}z=c[q>>2]|0;if((z|0)==(c[r>>2]|0)){A=c[s>>2]|0;c[r>>2]=z<<1;B=vh(z*24&-1)|0;c[s>>2]=B;C=A;A=(c[q>>2]|0)*12&-1;vp(B|0,C|0,A)|0;vi(C);D=c[d>>2]|0;E=c[q>>2]|0}else{D=y;E=z}c[(c[s>>2]|0)+(E*12&-1)>>2]=(D|0)>(u|0)?u:D;z=c[d>>2]|0;c[(c[s>>2]|0)+((c[q>>2]|0)*12&-1)+4>>2]=(z|0)<(u|0)?u:z;c[q>>2]=(c[q>>2]|0)+1;v=c[k>>2]|0;break}do{if((f|0)==(c[l>>2]|0)){c[l>>2]=f<<1;z=vh(f<<3)|0;c[j>>2]=z;y=t;C=c[k>>2]<<2;vp(z|0,y|0,C)|0;if((t|0)==(h|0)){break}vi(y)}}while(0);c[(c[j>>2]|0)+(c[k>>2]<<2)>>2]=c[x>>2];y=(c[k>>2]|0)+1|0;c[k>>2]=y;C=w+(u*36&-1)+28|0;do{if((y|0)==(c[l>>2]|0)){z=c[j>>2]|0;c[l>>2]=y<<1;A=vh(y<<3)|0;c[j>>2]=A;B=z;F=c[k>>2]<<2;vp(A|0,B|0,F)|0;if((z|0)==(h|0)){break}vi(B)}}while(0);c[(c[j>>2]|0)+(c[k>>2]<<2)>>2]=c[C>>2];y=(c[k>>2]|0)+1|0;c[k>>2]=y;v=y}}while(0);if((v|0)>0){b=v}else{break}}}v=c[j>>2]|0;if((v|0)==(h|0)){i=e;return}vi(v);c[j>>2]=0;i=e;return}function dx(d){d=d|0;var e=0,f=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0;e=c[d+60>>2]|0;if((e|0)==0){return}f=d+12|0;h=d+4|0;i=d+72|0;j=d+68|0;k=e;L1672:while(1){e=c[k+48>>2]|0;l=c[k+52>>2]|0;m=c[k+56>>2]|0;n=c[k+60>>2]|0;o=c[e+8>>2]|0;p=c[l+8>>2]|0;q=k+4|0;r=c[q>>2]|0;L1674:do{if((r&8|0)==0){s=1287}else{if((c[p>>2]|0)==2){s=1276}else{if((c[o>>2]|0)==2){s=1276}}L1678:do{if((s|0)==1276){s=0;t=c[p+108>>2]|0;if((t|0)!=0){u=t;do{if((c[u>>2]|0)==(o|0)){if((a[(c[u+4>>2]|0)+61|0]&1)==0){break L1678}}u=c[u+12>>2]|0;}while((u|0)!=0)}u=c[j>>2]|0;do{if((u|0)==0){v=r}else{if(bv[c[(c[u>>2]|0)+8>>2]&127](u,e,l)|0){v=c[q>>2]|0;break}else{t=c[k+12>>2]|0;dp(d,k);w=t;break L1674}}}while(0);c[q>>2]=v&-9;s=1287;break L1674}}while(0);u=c[k+12>>2]|0;dp(d,k);w=u}}while(0);do{if((s|0)==1287){s=0;if((b[o+4>>1]&2)==0){x=0}else{x=(c[o>>2]|0)!=0&1}if((b[p+4>>1]&2)==0){y=1}else{y=(c[p>>2]|0)==0}if((x|0)==0&y){w=c[k+12>>2]|0;break}q=c[(c[e+24>>2]|0)+(m*28&-1)+24>>2]|0;r=c[(c[l+24>>2]|0)+(n*28&-1)+24>>2]|0;if((q|0)<=-1){s=1305;break L1672}u=c[f>>2]|0;if((u|0)<=(q|0)){s=1304;break L1672}t=c[h>>2]|0;if(!((r|0)>-1&(u|0)>(r|0))){s=1297;break L1672}if(+g[t+(r*36&-1)>>2]- +g[t+(q*36&-1)+8>>2]>0.0|+g[t+(r*36&-1)+4>>2]- +g[t+(q*36&-1)+12>>2]>0.0|+g[t+(q*36&-1)>>2]- +g[t+(r*36&-1)+8>>2]>0.0|+g[t+(q*36&-1)+4>>2]- +g[t+(r*36&-1)+12>>2]>0.0){r=c[k+12>>2]|0;dp(d,k);w=r;break}else{eh(k,c[i>>2]|0);w=c[k+12>>2]|0;break}}}while(0);if((w|0)==0){s=1302;break}else{k=w}}if((s|0)==1297){ba(10360,159,14456,9904)}else if((s|0)==1302){return}else if((s|0)==1304){ba(10360,159,14456,9904)}else if((s|0)==1305){ba(10360,159,14456,9904)}}function dy(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0;d=i;i=i+8|0;e=d|0;f=a+52|0;c[f>>2]=0;g=a+40|0;h=c[g>>2]|0;do{if((h|0)>0){j=a+32|0;k=a+56|0;l=a|0;m=a+12|0;n=a+4|0;o=0;p=h;while(1){q=c[(c[j>>2]|0)+(o<<2)>>2]|0;c[k>>2]=q;if((q|0)==-1){r=p}else{if((q|0)<=-1){s=1329;break}if((c[m>>2]|0)<=(q|0)){s=1330;break}dw(l,a,(c[n>>2]|0)+(q*36&-1)|0);r=c[g>>2]|0}q=o+1|0;if((q|0)<(r|0)){o=q;p=r}else{s=1314;break}}if((s|0)==1314){t=c[f>>2]|0;break}else if((s|0)==1329){ba(10360,159,14456,9904)}else if((s|0)==1330){ba(10360,159,14456,9904)}}else{t=0}}while(0);c[g>>2]=0;g=a+44|0;r=c[g>>2]|0;c[e>>2]=122;dz(r,r+(t*12&-1)|0,e);if((c[f>>2]|0)<=0){i=d;return}e=a+12|0;t=a+4|0;a=0;L1735:while(1){r=c[g>>2]|0;h=r+(a*12&-1)|0;p=c[h>>2]|0;if((p|0)<=-1){s=1328;break}o=c[e>>2]|0;if((o|0)<=(p|0)){s=1327;break}n=c[t>>2]|0;l=r+(a*12&-1)+4|0;r=c[l>>2]|0;if(!((r|0)>-1&(o|0)>(r|0))){s=1321;break}dv(b,c[n+(p*36&-1)+16>>2]|0,c[n+(r*36&-1)+16>>2]|0);r=c[f>>2]|0;n=a;while(1){p=n+1|0;if((p|0)>=(r|0)){s=1331;break L1735}o=c[g>>2]|0;if((c[o+(p*12&-1)>>2]|0)!=(c[h>>2]|0)){a=p;continue L1735}if((c[o+(p*12&-1)+4>>2]|0)==(c[l>>2]|0)){n=p}else{a=p;continue L1735}}}if((s|0)==1321){ba(10360,153,14408,9904)}else if((s|0)==1331){i=d;return}else if((s|0)==1327){ba(10360,153,14408,9904)}else if((s|0)==1328){ba(10360,153,14408,9904)}}function dz(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0,ao=0,ap=0,aq=0;e=i;i=i+480|0;f=e|0;g=e+16|0;h=e+32|0;j=e+48|0;k=e+64|0;l=e+224|0;m=e+240|0;n=e+256|0;o=e+272|0;p=e+288|0;q=e+304|0;r=e+320|0;s=e+336|0;t=e+352|0;u=e+368|0;v=e+464|0;w=e+160|0;x=e+176|0;y=e+192|0;z=e+208|0;A=e+384|0;B=e+400|0;C=e+432|0;D=e+448|0;E=e+416|0;F=e+80|0;G=e+96|0;H=e+112|0;I=e+128|0;J=e+144|0;K=a;a=b;L1750:while(1){b=a;L=a-12|0;M=L;N=K;L1752:while(1){O=N;P=b-O|0;Q=(P|0)/12&-1;if((Q|0)==0|(Q|0)==1){R=1432;break L1750}else if((Q|0)==5){R=1347;break L1750}else if((Q|0)==4){R=1346;break L1750}else if((Q|0)==3){R=1338;break L1750}else if((Q|0)==2){R=1336;break L1750}if((P|0)<372){R=1353;break L1750}Q=(P|0)/24&-1;S=N+(Q*12&-1)|0;do{if((P|0)>11988){T=(P|0)/48&-1;U=N+(T*12&-1)|0;V=N+((T+Q|0)*12&-1)|0;T=dA(N,U,S,V,d)|0;if(!(bF[c[d>>2]&255](L,V)|0)){W=T;break}X=V;c[z>>2]=c[X>>2];c[z+4>>2]=c[X+4>>2];c[z+8>>2]=c[X+8>>2];c[X>>2]=c[M>>2];c[X+4>>2]=c[M+4>>2];c[X+8>>2]=c[M+8>>2];c[M>>2]=c[z>>2];c[M+4>>2]=c[z+4>>2];c[M+8>>2]=c[z+8>>2];if(!(bF[c[d>>2]&255](V,S)|0)){W=T+1|0;break}V=S;c[x>>2]=c[V>>2];c[x+4>>2]=c[V+4>>2];c[x+8>>2]=c[V+8>>2];c[V>>2]=c[X>>2];c[V+4>>2]=c[X+4>>2];c[V+8>>2]=c[X+8>>2];c[X>>2]=c[x>>2];c[X+4>>2]=c[x+4>>2];c[X+8>>2]=c[x+8>>2];if(!(bF[c[d>>2]&255](S,U)|0)){W=T+2|0;break}X=U;c[w>>2]=c[X>>2];c[w+4>>2]=c[X+4>>2];c[w+8>>2]=c[X+8>>2];c[X>>2]=c[V>>2];c[X+4>>2]=c[V+4>>2];c[X+8>>2]=c[V+8>>2];c[V>>2]=c[w>>2];c[V+4>>2]=c[w+4>>2];c[V+8>>2]=c[w+8>>2];if(!(bF[c[d>>2]&255](U,N)|0)){W=T+3|0;break}U=N;c[y>>2]=c[U>>2];c[y+4>>2]=c[U+4>>2];c[y+8>>2]=c[U+8>>2];c[U>>2]=c[X>>2];c[U+4>>2]=c[X+4>>2];c[U+8>>2]=c[X+8>>2];c[X>>2]=c[y>>2];c[X+4>>2]=c[y+4>>2];c[X+8>>2]=c[y+8>>2];W=T+4|0}else{T=bF[c[d>>2]&255](S,N)|0;X=bF[c[d>>2]&255](L,S)|0;if(!T){if(!X){W=0;break}T=S;c[J>>2]=c[T>>2];c[J+4>>2]=c[T+4>>2];c[J+8>>2]=c[T+8>>2];c[T>>2]=c[M>>2];c[T+4>>2]=c[M+4>>2];c[T+8>>2]=c[M+8>>2];c[M>>2]=c[J>>2];c[M+4>>2]=c[J+4>>2];c[M+8>>2]=c[J+8>>2];if(!(bF[c[d>>2]&255](S,N)|0)){W=1;break}U=N;c[H>>2]=c[U>>2];c[H+4>>2]=c[U+4>>2];c[H+8>>2]=c[U+8>>2];c[U>>2]=c[T>>2];c[U+4>>2]=c[T+4>>2];c[U+8>>2]=c[T+8>>2];c[T>>2]=c[H>>2];c[T+4>>2]=c[H+4>>2];c[T+8>>2]=c[H+8>>2];W=2;break}T=N;if(X){c[F>>2]=c[T>>2];c[F+4>>2]=c[T+4>>2];c[F+8>>2]=c[T+8>>2];c[T>>2]=c[M>>2];c[T+4>>2]=c[M+4>>2];c[T+8>>2]=c[M+8>>2];c[M>>2]=c[F>>2];c[M+4>>2]=c[F+4>>2];c[M+8>>2]=c[F+8>>2];W=1;break}c[G>>2]=c[T>>2];c[G+4>>2]=c[T+4>>2];c[G+8>>2]=c[T+8>>2];X=S;c[T>>2]=c[X>>2];c[T+4>>2]=c[X+4>>2];c[T+8>>2]=c[X+8>>2];c[X>>2]=c[G>>2];c[X+4>>2]=c[G+4>>2];c[X+8>>2]=c[G+8>>2];if(!(bF[c[d>>2]&255](L,S)|0)){W=1;break}c[I>>2]=c[X>>2];c[I+4>>2]=c[X+4>>2];c[I+8>>2]=c[X+8>>2];c[X>>2]=c[M>>2];c[X+4>>2]=c[M+4>>2];c[X+8>>2]=c[M+8>>2];c[M>>2]=c[I>>2];c[M+4>>2]=c[I+4>>2];c[M+8>>2]=c[I+8>>2];W=2}}while(0);do{if(bF[c[d>>2]&255](N,S)|0){Y=L;Z=W}else{Q=L;while(1){_=Q-12|0;if((N|0)==(_|0)){break}if(bF[c[d>>2]&255](_,S)|0){R=1395;break}else{Q=_}}if((R|0)==1395){R=0;Q=N;c[E>>2]=c[Q>>2];c[E+4>>2]=c[Q+4>>2];c[E+8>>2]=c[Q+8>>2];P=_;c[Q>>2]=c[P>>2];c[Q+4>>2]=c[P+4>>2];c[Q+8>>2]=c[P+8>>2];c[P>>2]=c[E>>2];c[P+4>>2]=c[E+4>>2];c[P+8>>2]=c[E+8>>2];Y=_;Z=W+1|0;break}P=N+12|0;if(bF[c[d>>2]&255](N,L)|0){$=P}else{Q=P;while(1){if((Q|0)==(L|0)){R=1422;break L1750}aa=Q+12|0;if(bF[c[d>>2]&255](N,Q)|0){break}else{Q=aa}}P=Q;c[D>>2]=c[P>>2];c[D+4>>2]=c[P+4>>2];c[D+8>>2]=c[P+8>>2];c[P>>2]=c[M>>2];c[P+4>>2]=c[M+4>>2];c[P+8>>2]=c[M+8>>2];c[M>>2]=c[D>>2];c[M+4>>2]=c[D+4>>2];c[M+8>>2]=c[D+8>>2];$=aa}if(($|0)==(L|0)){R=1416;break L1750}else{ab=L;ac=$}while(1){P=ac;while(1){ad=P+12|0;if(bF[c[d>>2]&255](N,P)|0){ae=ab;break}else{P=ad}}do{ae=ae-12|0;}while(bF[c[d>>2]&255](N,ae)|0);if(P>>>0>=ae>>>0){N=P;continue L1752}X=P;c[C>>2]=c[X>>2];c[C+4>>2]=c[X+4>>2];c[C+8>>2]=c[X+8>>2];T=ae;c[X>>2]=c[T>>2];c[X+4>>2]=c[T+4>>2];c[X+8>>2]=c[T+8>>2];c[T>>2]=c[C>>2];c[T+4>>2]=c[C+4>>2];c[T+8>>2]=c[C+8>>2];ab=ae;ac=ad}}}while(0);Q=N+12|0;L1795:do{if(Q>>>0>>0){T=Y;X=Q;U=Z;V=S;while(1){af=X;while(1){ag=af+12|0;if(bF[c[d>>2]&255](af,V)|0){af=ag}else{ah=T;break}}do{ah=ah-12|0;}while(!(bF[c[d>>2]&255](ah,V)|0));if(af>>>0>ah>>>0){ai=af;aj=U;ak=V;break L1795}P=af;c[B>>2]=c[P>>2];c[B+4>>2]=c[P+4>>2];c[B+8>>2]=c[P+8>>2];al=ah;c[P>>2]=c[al>>2];c[P+4>>2]=c[al+4>>2];c[P+8>>2]=c[al+8>>2];c[al>>2]=c[B>>2];c[al+4>>2]=c[B+4>>2];c[al+8>>2]=c[B+8>>2];T=ah;X=ag;U=U+1|0;V=(V|0)==(af|0)?ah:V}}else{ai=Q;aj=Z;ak=S}}while(0);do{if((ai|0)==(ak|0)){am=aj}else{if(!(bF[c[d>>2]&255](ak,ai)|0)){am=aj;break}S=ai;c[A>>2]=c[S>>2];c[A+4>>2]=c[S+4>>2];c[A+8>>2]=c[S+8>>2];Q=ak;c[S>>2]=c[Q>>2];c[S+4>>2]=c[Q+4>>2];c[S+8>>2]=c[Q+8>>2];c[Q>>2]=c[A>>2];c[Q+4>>2]=c[A+4>>2];c[Q+8>>2]=c[A+8>>2];am=aj+1|0}}while(0);if((am|0)==0){an=dF(N,ai,d)|0;Q=ai+12|0;if(dF(Q,a,d)|0){R=1407;break}if(an){N=Q;continue}}Q=ai;if((Q-O|0)>=(b-Q|0)){R=1411;break}dz(N,ai,d);N=ai+12|0}if((R|0)==1411){R=0;dz(ai+12|0,a,d);K=N;a=ai;continue}else if((R|0)==1407){R=0;if(an){R=1424;break}else{K=N;a=ai;continue}}}if((R|0)==1432){i=e;return}else if((R|0)==1416){i=e;return}else if((R|0)==1422){i=e;return}else if((R|0)==1424){i=e;return}else if((R|0)==1347){ai=N+12|0;K=N+24|0;an=N+36|0;am=m;m=n;n=o;o=p;dA(N,ai,K,an,d)|0;if(!(bF[c[d>>2]&255](L,an)|0)){i=e;return}p=an;c[o>>2]=c[p>>2];c[o+4>>2]=c[p+4>>2];c[o+8>>2]=c[p+8>>2];c[p>>2]=c[M>>2];c[p+4>>2]=c[M+4>>2];c[p+8>>2]=c[M+8>>2];c[M>>2]=c[o>>2];c[M+4>>2]=c[o+4>>2];c[M+8>>2]=c[o+8>>2];if(!(bF[c[d>>2]&255](an,K)|0)){i=e;return}an=K;c[m>>2]=c[an>>2];c[m+4>>2]=c[an+4>>2];c[m+8>>2]=c[an+8>>2];c[an>>2]=c[p>>2];c[an+4>>2]=c[p+4>>2];c[an+8>>2]=c[p+8>>2];c[p>>2]=c[m>>2];c[p+4>>2]=c[m+4>>2];c[p+8>>2]=c[m+8>>2];if(!(bF[c[d>>2]&255](K,ai)|0)){i=e;return}K=ai;c[am>>2]=c[K>>2];c[am+4>>2]=c[K+4>>2];c[am+8>>2]=c[K+8>>2];c[K>>2]=c[an>>2];c[K+4>>2]=c[an+4>>2];c[K+8>>2]=c[an+8>>2];c[an>>2]=c[am>>2];c[an+4>>2]=c[am+4>>2];c[an+8>>2]=c[am+8>>2];if(!(bF[c[d>>2]&255](ai,N)|0)){i=e;return}ai=N;c[n>>2]=c[ai>>2];c[n+4>>2]=c[ai+4>>2];c[n+8>>2]=c[ai+8>>2];c[ai>>2]=c[K>>2];c[ai+4>>2]=c[K+4>>2];c[ai+8>>2]=c[K+8>>2];c[K>>2]=c[n>>2];c[K+4>>2]=c[n+4>>2];c[K+8>>2]=c[n+8>>2];i=e;return}else if((R|0)==1346){dA(N,N+12|0,N+24|0,L,d)|0;i=e;return}else if((R|0)==1353){n=l;K=N+24|0;ai=N+12|0;am=f;f=g;g=h;h=j;j=k;k=bF[c[d>>2]&255](ai,N)|0;an=bF[c[d>>2]&255](K,ai)|0;do{if(k){m=N;if(an){c[am>>2]=c[m>>2];c[am+4>>2]=c[m+4>>2];c[am+8>>2]=c[m+8>>2];p=K;c[m>>2]=c[p>>2];c[m+4>>2]=c[p+4>>2];c[m+8>>2]=c[p+8>>2];c[p>>2]=c[am>>2];c[p+4>>2]=c[am+4>>2];c[p+8>>2]=c[am+8>>2];break}c[f>>2]=c[m>>2];c[f+4>>2]=c[m+4>>2];c[f+8>>2]=c[m+8>>2];p=ai;c[m>>2]=c[p>>2];c[m+4>>2]=c[p+4>>2];c[m+8>>2]=c[p+8>>2];c[p>>2]=c[f>>2];c[p+4>>2]=c[f+4>>2];c[p+8>>2]=c[f+8>>2];if(!(bF[c[d>>2]&255](K,ai)|0)){break}c[h>>2]=c[p>>2];c[h+4>>2]=c[p+4>>2];c[h+8>>2]=c[p+8>>2];m=K;c[p>>2]=c[m>>2];c[p+4>>2]=c[m+4>>2];c[p+8>>2]=c[m+8>>2];c[m>>2]=c[h>>2];c[m+4>>2]=c[h+4>>2];c[m+8>>2]=c[h+8>>2]}else{if(!an){break}m=ai;c[j>>2]=c[m>>2];c[j+4>>2]=c[m+4>>2];c[j+8>>2]=c[m+8>>2];p=K;c[m>>2]=c[p>>2];c[m+4>>2]=c[p+4>>2];c[m+8>>2]=c[p+8>>2];c[p>>2]=c[j>>2];c[p+4>>2]=c[j+4>>2];c[p+8>>2]=c[j+8>>2];if(!(bF[c[d>>2]&255](ai,N)|0)){break}p=N;c[g>>2]=c[p>>2];c[g+4>>2]=c[p+4>>2];c[g+8>>2]=c[p+8>>2];c[p>>2]=c[m>>2];c[p+4>>2]=c[m+4>>2];c[p+8>>2]=c[m+8>>2];c[m>>2]=c[g>>2];c[m+4>>2]=c[g+4>>2];c[m+8>>2]=c[g+8>>2]}}while(0);g=N+36|0;if((g|0)==(a|0)){i=e;return}else{ao=K;ap=g}while(1){if(bF[c[d>>2]&255](ap,ao)|0){g=ap;c[n>>2]=c[g>>2];c[n+4>>2]=c[g+4>>2];c[n+8>>2]=c[g+8>>2];g=ao;K=ap;while(1){ai=K;aq=g;c[ai>>2]=c[aq>>2];c[ai+4>>2]=c[aq+4>>2];c[ai+8>>2]=c[aq+8>>2];if((g|0)==(N|0)){break}ai=g-12|0;if(bF[c[d>>2]&255](l,ai)|0){K=g;g=ai}else{break}}c[aq>>2]=c[n>>2];c[aq+4>>2]=c[n+4>>2];c[aq+8>>2]=c[n+8>>2]}g=ap+12|0;if((g|0)==(a|0)){break}else{ao=ap;ap=g}}i=e;return}else if((R|0)==1338){ap=N+12|0;ao=q;q=r;r=s;s=t;t=u;u=bF[c[d>>2]&255](ap,N)|0;a=bF[c[d>>2]&255](L,ap)|0;if(!u){if(!a){i=e;return}u=ap;c[t>>2]=c[u>>2];c[t+4>>2]=c[u+4>>2];c[t+8>>2]=c[u+8>>2];c[u>>2]=c[M>>2];c[u+4>>2]=c[M+4>>2];c[u+8>>2]=c[M+8>>2];c[M>>2]=c[t>>2];c[M+4>>2]=c[t+4>>2];c[M+8>>2]=c[t+8>>2];if(!(bF[c[d>>2]&255](ap,N)|0)){i=e;return}t=N;c[r>>2]=c[t>>2];c[r+4>>2]=c[t+4>>2];c[r+8>>2]=c[t+8>>2];c[t>>2]=c[u>>2];c[t+4>>2]=c[u+4>>2];c[t+8>>2]=c[u+8>>2];c[u>>2]=c[r>>2];c[u+4>>2]=c[r+4>>2];c[u+8>>2]=c[r+8>>2];i=e;return}r=N;if(a){c[ao>>2]=c[r>>2];c[ao+4>>2]=c[r+4>>2];c[ao+8>>2]=c[r+8>>2];c[r>>2]=c[M>>2];c[r+4>>2]=c[M+4>>2];c[r+8>>2]=c[M+8>>2];c[M>>2]=c[ao>>2];c[M+4>>2]=c[ao+4>>2];c[M+8>>2]=c[ao+8>>2];i=e;return}c[q>>2]=c[r>>2];c[q+4>>2]=c[r+4>>2];c[q+8>>2]=c[r+8>>2];ao=ap;c[r>>2]=c[ao>>2];c[r+4>>2]=c[ao+4>>2];c[r+8>>2]=c[ao+8>>2];c[ao>>2]=c[q>>2];c[ao+4>>2]=c[q+4>>2];c[ao+8>>2]=c[q+8>>2];if(!(bF[c[d>>2]&255](L,ap)|0)){i=e;return}c[s>>2]=c[ao>>2];c[s+4>>2]=c[ao+4>>2];c[s+8>>2]=c[ao+8>>2];c[ao>>2]=c[M>>2];c[ao+4>>2]=c[M+4>>2];c[ao+8>>2]=c[M+8>>2];c[M>>2]=c[s>>2];c[M+4>>2]=c[s+4>>2];c[M+8>>2]=c[s+8>>2];i=e;return}else if((R|0)==1336){if(!(bF[c[d>>2]&255](L,N)|0)){i=e;return}L=v;v=N;c[L>>2]=c[v>>2];c[L+4>>2]=c[v+4>>2];c[L+8>>2]=c[v+8>>2];c[v>>2]=c[M>>2];c[v+4>>2]=c[M+4>>2];c[v+8>>2]=c[M+8>>2];c[M>>2]=c[L>>2];c[M+4>>2]=c[L+4>>2];c[M+8>>2]=c[L+8>>2];i=e;return}}function dA(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;g=i;i=i+128|0;h=g+80|0;j=g+96|0;k=g+112|0;l=g|0;m=g+16|0;n=g+32|0;o=g+48|0;p=g+64|0;q=bF[c[f>>2]&255](b,a)|0;r=bF[c[f>>2]&255](d,b)|0;do{if(q){s=a;if(r){c[l>>2]=c[s>>2];c[l+4>>2]=c[s+4>>2];c[l+8>>2]=c[s+8>>2];t=d;c[s>>2]=c[t>>2];c[s+4>>2]=c[t+4>>2];c[s+8>>2]=c[t+8>>2];c[t>>2]=c[l>>2];c[t+4>>2]=c[l+4>>2];c[t+8>>2]=c[l+8>>2];u=1;break}c[m>>2]=c[s>>2];c[m+4>>2]=c[s+4>>2];c[m+8>>2]=c[s+8>>2];t=b;c[s>>2]=c[t>>2];c[s+4>>2]=c[t+4>>2];c[s+8>>2]=c[t+8>>2];c[t>>2]=c[m>>2];c[t+4>>2]=c[m+4>>2];c[t+8>>2]=c[m+8>>2];if(!(bF[c[f>>2]&255](d,b)|0)){u=1;break}c[o>>2]=c[t>>2];c[o+4>>2]=c[t+4>>2];c[o+8>>2]=c[t+8>>2];s=d;c[t>>2]=c[s>>2];c[t+4>>2]=c[s+4>>2];c[t+8>>2]=c[s+8>>2];c[s>>2]=c[o>>2];c[s+4>>2]=c[o+4>>2];c[s+8>>2]=c[o+8>>2];u=2}else{if(!r){u=0;break}s=b;c[p>>2]=c[s>>2];c[p+4>>2]=c[s+4>>2];c[p+8>>2]=c[s+8>>2];t=d;c[s>>2]=c[t>>2];c[s+4>>2]=c[t+4>>2];c[s+8>>2]=c[t+8>>2];c[t>>2]=c[p>>2];c[t+4>>2]=c[p+4>>2];c[t+8>>2]=c[p+8>>2];if(!(bF[c[f>>2]&255](b,a)|0)){u=1;break}t=a;c[n>>2]=c[t>>2];c[n+4>>2]=c[t+4>>2];c[n+8>>2]=c[t+8>>2];c[t>>2]=c[s>>2];c[t+4>>2]=c[s+4>>2];c[t+8>>2]=c[s+8>>2];c[s>>2]=c[n>>2];c[s+4>>2]=c[n+4>>2];c[s+8>>2]=c[n+8>>2];u=2}}while(0);if(!(bF[c[f>>2]&255](e,d)|0)){v=u;i=g;return v|0}n=k;k=d;c[n>>2]=c[k>>2];c[n+4>>2]=c[k+4>>2];c[n+8>>2]=c[k+8>>2];p=e;c[k>>2]=c[p>>2];c[k+4>>2]=c[p+4>>2];c[k+8>>2]=c[p+8>>2];c[p>>2]=c[n>>2];c[p+4>>2]=c[n+4>>2];c[p+8>>2]=c[n+8>>2];if(!(bF[c[f>>2]&255](d,b)|0)){v=u+1|0;i=g;return v|0}d=h;h=b;c[d>>2]=c[h>>2];c[d+4>>2]=c[h+4>>2];c[d+8>>2]=c[h+8>>2];c[h>>2]=c[k>>2];c[h+4>>2]=c[k+4>>2];c[h+8>>2]=c[k+8>>2];c[k>>2]=c[d>>2];c[k+4>>2]=c[d+4>>2];c[k+8>>2]=c[d+8>>2];if(!(bF[c[f>>2]&255](b,a)|0)){v=u+2|0;i=g;return v|0}b=j;j=a;c[b>>2]=c[j>>2];c[b+4>>2]=c[j+4>>2];c[b+8>>2]=c[j+8>>2];c[j>>2]=c[h>>2];c[j+4>>2]=c[h+4>>2];c[j+8>>2]=c[h+8>>2];c[h>>2]=c[b>>2];c[h+4>>2]=c[b+4>>2];c[h+8>>2]=c[b+8>>2];v=u+3|0;i=g;return v|0}function dB(a,b){a=a|0;b=b|0;return}function dC(a,b){a=a|0;b=b|0;return}function dD(a,b,c){a=a|0;b=b|0;c=c|0;return}function dE(a,b,c){a=a|0;b=b|0;c=c|0;return}function dF(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;e=i;i=i+256|0;f=e|0;g=e+16|0;h=e+32|0;j=e+48|0;k=e+64|0;l=e+144|0;m=e+160|0;n=e+176|0;o=e+192|0;p=e+208|0;q=e+224|0;r=e+240|0;s=(b-a|0)/12&-1;if((s|0)==5){t=a+12|0;u=a+24|0;v=a+36|0;w=b-12|0;x=e+80|0;y=e+96|0;z=e+112|0;A=e+128|0;dA(a,t,u,v,d)|0;if(!(bF[c[d>>2]&255](w,v)|0)){B=1;i=e;return B|0}C=v;c[A>>2]=c[C>>2];c[A+4>>2]=c[C+4>>2];c[A+8>>2]=c[C+8>>2];D=w;c[C>>2]=c[D>>2];c[C+4>>2]=c[D+4>>2];c[C+8>>2]=c[D+8>>2];c[D>>2]=c[A>>2];c[D+4>>2]=c[A+4>>2];c[D+8>>2]=c[A+8>>2];if(!(bF[c[d>>2]&255](v,u)|0)){B=1;i=e;return B|0}v=u;c[y>>2]=c[v>>2];c[y+4>>2]=c[v+4>>2];c[y+8>>2]=c[v+8>>2];c[v>>2]=c[C>>2];c[v+4>>2]=c[C+4>>2];c[v+8>>2]=c[C+8>>2];c[C>>2]=c[y>>2];c[C+4>>2]=c[y+4>>2];c[C+8>>2]=c[y+8>>2];if(!(bF[c[d>>2]&255](u,t)|0)){B=1;i=e;return B|0}u=t;c[x>>2]=c[u>>2];c[x+4>>2]=c[u+4>>2];c[x+8>>2]=c[u+8>>2];c[u>>2]=c[v>>2];c[u+4>>2]=c[v+4>>2];c[u+8>>2]=c[v+8>>2];c[v>>2]=c[x>>2];c[v+4>>2]=c[x+4>>2];c[v+8>>2]=c[x+8>>2];if(!(bF[c[d>>2]&255](t,a)|0)){B=1;i=e;return B|0}t=a;c[z>>2]=c[t>>2];c[z+4>>2]=c[t+4>>2];c[z+8>>2]=c[t+8>>2];c[t>>2]=c[u>>2];c[t+4>>2]=c[u+4>>2];c[t+8>>2]=c[u+8>>2];c[u>>2]=c[z>>2];c[u+4>>2]=c[z+4>>2];c[u+8>>2]=c[z+8>>2];B=1;i=e;return B|0}else if((s|0)==2){z=b-12|0;if(!(bF[c[d>>2]&255](z,a)|0)){B=1;i=e;return B|0}u=q;q=a;c[u>>2]=c[q>>2];c[u+4>>2]=c[q+4>>2];c[u+8>>2]=c[q+8>>2];t=z;c[q>>2]=c[t>>2];c[q+4>>2]=c[t+4>>2];c[q+8>>2]=c[t+8>>2];c[t>>2]=c[u>>2];c[t+4>>2]=c[u+4>>2];c[t+8>>2]=c[u+8>>2];B=1;i=e;return B|0}else if((s|0)==4){dA(a,a+12|0,a+24|0,b-12|0,d)|0;B=1;i=e;return B|0}else if((s|0)==3){u=a+12|0;t=b-12|0;q=l;l=m;m=n;n=o;o=p;p=bF[c[d>>2]&255](u,a)|0;z=bF[c[d>>2]&255](t,u)|0;if(!p){if(!z){B=1;i=e;return B|0}p=u;c[o>>2]=c[p>>2];c[o+4>>2]=c[p+4>>2];c[o+8>>2]=c[p+8>>2];x=t;c[p>>2]=c[x>>2];c[p+4>>2]=c[x+4>>2];c[p+8>>2]=c[x+8>>2];c[x>>2]=c[o>>2];c[x+4>>2]=c[o+4>>2];c[x+8>>2]=c[o+8>>2];if(!(bF[c[d>>2]&255](u,a)|0)){B=1;i=e;return B|0}o=a;c[m>>2]=c[o>>2];c[m+4>>2]=c[o+4>>2];c[m+8>>2]=c[o+8>>2];c[o>>2]=c[p>>2];c[o+4>>2]=c[p+4>>2];c[o+8>>2]=c[p+8>>2];c[p>>2]=c[m>>2];c[p+4>>2]=c[m+4>>2];c[p+8>>2]=c[m+8>>2];B=1;i=e;return B|0}m=a;if(z){c[q>>2]=c[m>>2];c[q+4>>2]=c[m+4>>2];c[q+8>>2]=c[m+8>>2];z=t;c[m>>2]=c[z>>2];c[m+4>>2]=c[z+4>>2];c[m+8>>2]=c[z+8>>2];c[z>>2]=c[q>>2];c[z+4>>2]=c[q+4>>2];c[z+8>>2]=c[q+8>>2];B=1;i=e;return B|0}c[l>>2]=c[m>>2];c[l+4>>2]=c[m+4>>2];c[l+8>>2]=c[m+8>>2];q=u;c[m>>2]=c[q>>2];c[m+4>>2]=c[q+4>>2];c[m+8>>2]=c[q+8>>2];c[q>>2]=c[l>>2];c[q+4>>2]=c[l+4>>2];c[q+8>>2]=c[l+8>>2];if(!(bF[c[d>>2]&255](t,u)|0)){B=1;i=e;return B|0}c[n>>2]=c[q>>2];c[n+4>>2]=c[q+4>>2];c[n+8>>2]=c[q+8>>2];u=t;c[q>>2]=c[u>>2];c[q+4>>2]=c[u+4>>2];c[q+8>>2]=c[u+8>>2];c[u>>2]=c[n>>2];c[u+4>>2]=c[n+4>>2];c[u+8>>2]=c[n+8>>2];B=1;i=e;return B|0}else if((s|0)==0|(s|0)==1){B=1;i=e;return B|0}else{s=a+24|0;n=a+12|0;u=f;f=g;g=h;h=j;j=k;k=bF[c[d>>2]&255](n,a)|0;q=bF[c[d>>2]&255](s,n)|0;do{if(k){t=a;if(q){c[u>>2]=c[t>>2];c[u+4>>2]=c[t+4>>2];c[u+8>>2]=c[t+8>>2];l=s;c[t>>2]=c[l>>2];c[t+4>>2]=c[l+4>>2];c[t+8>>2]=c[l+8>>2];c[l>>2]=c[u>>2];c[l+4>>2]=c[u+4>>2];c[l+8>>2]=c[u+8>>2];break}c[f>>2]=c[t>>2];c[f+4>>2]=c[t+4>>2];c[f+8>>2]=c[t+8>>2];l=n;c[t>>2]=c[l>>2];c[t+4>>2]=c[l+4>>2];c[t+8>>2]=c[l+8>>2];c[l>>2]=c[f>>2];c[l+4>>2]=c[f+4>>2];c[l+8>>2]=c[f+8>>2];if(!(bF[c[d>>2]&255](s,n)|0)){break}c[h>>2]=c[l>>2];c[h+4>>2]=c[l+4>>2];c[h+8>>2]=c[l+8>>2];t=s;c[l>>2]=c[t>>2];c[l+4>>2]=c[t+4>>2];c[l+8>>2]=c[t+8>>2];c[t>>2]=c[h>>2];c[t+4>>2]=c[h+4>>2];c[t+8>>2]=c[h+8>>2]}else{if(!q){break}t=n;c[j>>2]=c[t>>2];c[j+4>>2]=c[t+4>>2];c[j+8>>2]=c[t+8>>2];l=s;c[t>>2]=c[l>>2];c[t+4>>2]=c[l+4>>2];c[t+8>>2]=c[l+8>>2];c[l>>2]=c[j>>2];c[l+4>>2]=c[j+4>>2];c[l+8>>2]=c[j+8>>2];if(!(bF[c[d>>2]&255](n,a)|0)){break}l=a;c[g>>2]=c[l>>2];c[g+4>>2]=c[l+4>>2];c[g+8>>2]=c[l+8>>2];c[l>>2]=c[t>>2];c[l+4>>2]=c[t+4>>2];c[l+8>>2]=c[t+8>>2];c[t>>2]=c[g>>2];c[t+4>>2]=c[g+4>>2];c[t+8>>2]=c[g+8>>2]}}while(0);g=a+36|0;if((g|0)==(b|0)){B=1;i=e;return B|0}n=r;j=s;s=0;q=g;while(1){if(bF[c[d>>2]&255](q,j)|0){g=q;c[n>>2]=c[g>>2];c[n+4>>2]=c[g+4>>2];c[n+8>>2]=c[g+8>>2];g=j;h=q;while(1){f=h;E=g;c[f>>2]=c[E>>2];c[f+4>>2]=c[E+4>>2];c[f+8>>2]=c[E+8>>2];if((g|0)==(a|0)){break}f=g-12|0;if(bF[c[d>>2]&255](r,f)|0){h=g;g=f}else{break}}c[E>>2]=c[n>>2];c[E+4>>2]=c[n+4>>2];c[E+8>>2]=c[n+8>>2];g=s+1|0;if((g|0)==8){break}else{F=g}}else{F=s}g=q+12|0;if((g|0)==(b|0)){B=1;G=1499;break}else{j=q;s=F;q=g}}if((G|0)==1499){i=e;return B|0}B=(q+12|0)==(b|0);i=e;return B|0}return 0}function dG(a){a=a|0;vl(a);return}function dH(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0,O=0,P=0;f=i;i=i+40|0;h=f|0;j=f+16|0;k=f+32|0;l=a+28|0;if((c[l>>2]|0)<=0){i=f;return}m=a+24|0;n=a+12|0;a=h|0;o=j|0;p=h+4|0;q=j+4|0;r=h+8|0;s=j+8|0;t=h+12|0;u=j+12|0;v=e|0;w=d|0;x=e+4|0;y=d+4|0;z=k|0;A=k+4|0;B=b|0;C=b+40|0;D=b+36|0;E=b+32|0;b=0;do{F=c[m>>2]|0;G=c[n>>2]|0;H=F+(b*28&-1)+20|0;bO[c[(c[G>>2]|0)+24>>2]&127](G,h,d,c[H>>2]|0);G=c[n>>2]|0;bO[c[(c[G>>2]|0)+24>>2]&127](G,j,e,c[H>>2]|0);H=F+(b*28&-1)|0;I=+g[a>>2];J=+g[o>>2];K=+g[p>>2];L=+g[q>>2];G=H;M=+(K>2]=I>2]=M;M=+g[r>>2];J=+g[s>>2];I=+g[t>>2];L=+g[u>>2];G=F+(b*28&-1)+8|0;K=+(I>L?I:L);g[G>>2]=M>J?M:J;g[G+4>>2]=K;K=+g[x>>2]- +g[y>>2];g[z>>2]=+g[v>>2]- +g[w>>2];g[A>>2]=K;G=c[F+(b*28&-1)+24>>2]|0;if(cn(B,G,H,k)|0){H=c[C>>2]|0;if((H|0)==(c[D>>2]|0)){F=c[E>>2]|0;c[D>>2]=H<<1;N=vh(H<<3)|0;c[E>>2]=N;O=F;F=c[C>>2]<<2;vp(N|0,O|0,F)|0;vi(O);P=c[C>>2]|0}else{P=H}c[(c[E>>2]|0)+(P<<2)>>2]=G;c[C>>2]=(c[C>>2]|0)+1}b=b+1|0;}while((b|0)<(c[l>>2]|0));i=f;return}function dI(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;b=a+8|0;d=c[b>>2]|0;if((d|0)==0){return}e=c[d+112>>2]|0;if((e|0)==0){f=d}else{d=e;do{e=c[d+4>>2]|0;if((c[e+48>>2]|0)==(a|0)|(c[e+52>>2]|0)==(a|0)){g=e+4|0;c[g>>2]=c[g>>2]|8}d=c[d+12>>2]|0;}while((d|0)!=0);f=c[b>>2]|0}b=c[f+88>>2]|0;if((b|0)==0){return}f=a+28|0;if((c[f>>2]|0)<=0){return}d=a+24|0;a=b+102912|0;g=b+102908|0;e=b+102904|0;b=0;h=c[a>>2]|0;do{i=c[(c[d>>2]|0)+(b*28&-1)+24>>2]|0;if((h|0)==(c[g>>2]|0)){j=c[e>>2]|0;c[g>>2]=h<<1;k=vh(h<<3)|0;c[e>>2]=k;l=j;j=c[a>>2]<<2;vp(k|0,l|0,j)|0;vi(l);m=c[a>>2]|0}else{m=h}c[(c[e>>2]|0)+(m<<2)>>2]=i;h=(c[a>>2]|0)+1|0;c[a>>2]=h;b=b+1|0;}while((b|0)<(c[f>>2]|0));return}function dJ(d,f){d=d|0;f=f|0;var j=0,k=0,l=0,m=0.0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,v=0;j=i;db(7320,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(6312,(u=i,i=i+8|0,h[u>>3]=+g[d+16>>2],u)|0);db(5776,(u=i,i=i+8|0,h[u>>3]=+g[d+20>>2],u)|0);db(5272,(u=i,i=i+8|0,h[u>>3]=+g[d>>2],u)|0);db(4904,(u=i,i=i+8|0,c[u>>2]=a[d+38|0]&1,u)|0);db(4624,(u=i,i=i+8|0,c[u>>2]=e[d+32>>1]|0,u)|0);db(4392,(u=i,i=i+8|0,c[u>>2]=e[d+34>>1]|0,u)|0);db(12896,(u=i,i=i+8|0,c[u>>2]=b[d+36>>1]|0,u)|0);k=c[d+12>>2]|0;d=c[k+4>>2]|0;if((d|0)==1){db(11368,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(12200,(u=i,i=i+8|0,h[u>>3]=+g[k+8>>2],u)|0);l=k+28|0;m=+g[l+4>>2];db(11152,(u=i,i=i+16|0,h[u>>3]=+g[l>>2],h[u+8>>3]=m,u)|0);m=+g[k+16>>2];db(10928,(u=i,i=i+16|0,h[u>>3]=+g[k+12>>2],h[u+8>>3]=m,u)|0);l=k+20|0;m=+g[l+4>>2];db(10728,(u=i,i=i+16|0,h[u>>3]=+g[l>>2],h[u+8>>3]=m,u)|0);m=+g[k+40>>2];db(10528,(u=i,i=i+16|0,h[u>>3]=+g[k+36>>2],h[u+8>>3]=m,u)|0);db(10408,(u=i,i=i+8|0,c[u>>2]=a[k+44|0]&1,u)|0);db(10200,(u=i,i=i+8|0,c[u>>2]=a[k+45|0]&1,u)|0)}else if((d|0)==0){db(12696,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(12200,(u=i,i=i+8|0,h[u>>3]=+g[k+8>>2],u)|0);m=+g[k+16>>2];db(11600,(u=i,i=i+16|0,h[u>>3]=+g[k+12>>2],h[u+8>>3]=m,u)|0)}else if((d|0)==2){db(9872,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(9544,(u=i,i=i+8|0,c[u>>2]=8,u)|0);l=k+148|0;n=c[l>>2]|0;if((n|0)>0){o=k+20|0;p=0;while(1){m=+g[o+(p<<3)>>2];q=+g[o+(p<<3)+4>>2];db(9104,(u=i,i=i+24|0,c[u>>2]=p,h[u+8>>3]=m,h[u+16>>3]=q,u)|0);r=p+1|0;s=c[l>>2]|0;if((r|0)<(s|0)){p=r}else{t=s;break}}}else{t=n}db(8840,(u=i,i=i+8|0,c[u>>2]=t,u)|0)}else if((d|0)==3){d=k;db(8680,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);t=k+16|0;db(9544,(u=i,i=i+8|0,c[u>>2]=c[t>>2],u)|0);n=c[t>>2]|0;if((n|0)>0){p=k+12|0;l=0;while(1){o=c[p>>2]|0;q=+g[o+(l<<3)>>2];m=+g[o+(l<<3)+4>>2];db(9104,(u=i,i=i+24|0,c[u>>2]=l,h[u+8>>3]=q,h[u+16>>3]=m,u)|0);o=l+1|0;s=c[t>>2]|0;if((o|0)<(s|0)){l=o}else{v=s;break}}}else{v=n}db(8312,(u=i,i=i+8|0,c[u>>2]=v,u)|0);v=k+20|0;m=+g[v+4>>2];db(8080,(u=i,i=i+16|0,h[u>>3]=+g[v>>2],h[u+8>>3]=m,u)|0);v=k+28|0;m=+g[v+4>>2];db(7792,(u=i,i=i+16|0,h[u>>3]=+g[v>>2],h[u+8>>3]=m,u)|0);db(7584,(u=i,i=i+8|0,c[u>>2]=a[k+36|0]&1,u)|0);db(7440,(u=i,i=i+8|0,c[u>>2]=a[d+37|0]&1,u)|0)}else{i=j;return}db(7344,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(7208,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(7344,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(7016,(u=i,i=i+8|0,c[u>>2]=f,u)|0);i=j;return}function dK(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0;if((c[b+28>>2]|0)!=0){ba(12280,72,14920,12608)}e=b+12|0;f=c[e>>2]|0;g=bq[c[(c[f>>2]|0)+12>>2]&1023](f)|0;f=b+24|0;b=c[f>>2]|0;h=b;i=g*28&-1;do{if((i|0)!=0){if((i|0)<=0){ba(5352,164,17448,8376)}if((i|0)>640){vi(h);break}g=a[i+22064|0]|0;if((g&255)<14){j=d+12+((g&255)<<2)|0;c[b>>2]=c[j>>2];c[j>>2]=b;break}else{ba(5352,173,17448,6544)}}}while(0);c[f>>2]=0;f=c[e>>2]|0;b=c[f+4>>2]|0;if((b|0)==3){bo[c[c[f>>2]>>2]&511](f);i=a[22104]|0;if((i&255)>=14){ba(5352,173,17448,6544)}h=d+12+((i&255)<<2)|0;c[f>>2]=c[h>>2];c[h>>2]=f;c[e>>2]=0;return}else if((b|0)==0){bo[c[c[f>>2]>>2]&511](f);h=a[22084]|0;if((h&255)>=14){ba(5352,173,17448,6544)}i=d+12+((h&255)<<2)|0;c[f>>2]=c[i>>2];c[i>>2]=f;c[e>>2]=0;return}else if((b|0)==2){bo[c[c[f>>2]>>2]&511](f);i=a[22216]|0;if((i&255)>=14){ba(5352,173,17448,6544)}h=d+12+((i&255)<<2)|0;c[f>>2]=c[h>>2];c[h>>2]=f;c[e>>2]=0;return}else if((b|0)==1){bo[c[c[f>>2]>>2]&511](f);b=a[22112]|0;if((b&255)>=14){ba(5352,173,17448,6544)}h=d+12+((b&255)<<2)|0;c[f>>2]=c[h>>2];c[h>>2]=f;c[e>>2]=0;return}else{ba(12280,115,14920,11592)}}function dL(b,d,e,f,g,h){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0;i=b+40|0;c[i>>2]=d;c[b+44>>2]=e;c[b+48>>2]=f;c[b+28>>2]=0;c[b+36>>2]=0;c[b+32>>2]=0;j=b|0;c[j>>2]=g;c[b+4>>2]=h;h=d<<2;d=g+102796|0;k=c[d>>2]|0;if((k|0)>=32){ba(4840,38,17040,6448)}l=g+102412+(k*12&-1)|0;c[g+102412+(k*12&-1)+4>>2]=h;m=g+102400|0;n=c[m>>2]|0;if((n+h|0)>102400){c[l>>2]=vh(h)|0;a[g+102412+(k*12&-1)+8|0]=1}else{c[l>>2]=g+n;a[g+102412+(k*12&-1)+8|0]=0;c[m>>2]=(c[m>>2]|0)+h}m=g+102404|0;k=(c[m>>2]|0)+h|0;c[m>>2]=k;m=g+102408|0;g=c[m>>2]|0;c[m>>2]=(g|0)>(k|0)?g:k;c[d>>2]=(c[d>>2]|0)+1;c[b+8>>2]=c[l>>2];l=c[j>>2]|0;d=e<<2;e=l+102796|0;k=c[e>>2]|0;if((k|0)>=32){ba(4840,38,17040,6448)}g=l+102412+(k*12&-1)|0;c[l+102412+(k*12&-1)+4>>2]=d;m=l+102400|0;h=c[m>>2]|0;if((h+d|0)>102400){c[g>>2]=vh(d)|0;a[l+102412+(k*12&-1)+8|0]=1}else{c[g>>2]=l+h;a[l+102412+(k*12&-1)+8|0]=0;c[m>>2]=(c[m>>2]|0)+d}m=l+102404|0;k=(c[m>>2]|0)+d|0;c[m>>2]=k;m=l+102408|0;l=c[m>>2]|0;c[m>>2]=(l|0)>(k|0)?l:k;c[e>>2]=(c[e>>2]|0)+1;c[b+12>>2]=c[g>>2];g=c[j>>2]|0;e=f<<2;f=g+102796|0;k=c[f>>2]|0;if((k|0)>=32){ba(4840,38,17040,6448)}l=g+102412+(k*12&-1)|0;c[g+102412+(k*12&-1)+4>>2]=e;m=g+102400|0;d=c[m>>2]|0;if((d+e|0)>102400){c[l>>2]=vh(e)|0;a[g+102412+(k*12&-1)+8|0]=1}else{c[l>>2]=g+d;a[g+102412+(k*12&-1)+8|0]=0;c[m>>2]=(c[m>>2]|0)+e}m=g+102404|0;k=(c[m>>2]|0)+e|0;c[m>>2]=k;m=g+102408|0;g=c[m>>2]|0;c[m>>2]=(g|0)>(k|0)?g:k;c[f>>2]=(c[f>>2]|0)+1;c[b+16>>2]=c[l>>2];l=c[j>>2]|0;f=(c[i>>2]|0)*12&-1;k=l+102796|0;g=c[k>>2]|0;if((g|0)>=32){ba(4840,38,17040,6448)}m=l+102412+(g*12&-1)|0;c[l+102412+(g*12&-1)+4>>2]=f;e=l+102400|0;d=c[e>>2]|0;if((d+f|0)>102400){c[m>>2]=vh(f)|0;a[l+102412+(g*12&-1)+8|0]=1}else{c[m>>2]=l+d;a[l+102412+(g*12&-1)+8|0]=0;c[e>>2]=(c[e>>2]|0)+f}e=l+102404|0;g=(c[e>>2]|0)+f|0;c[e>>2]=g;e=l+102408|0;l=c[e>>2]|0;c[e>>2]=(l|0)>(g|0)?l:g;c[k>>2]=(c[k>>2]|0)+1;c[b+24>>2]=c[m>>2];m=c[j>>2]|0;j=(c[i>>2]|0)*12&-1;i=m+102796|0;k=c[i>>2]|0;if((k|0)>=32){ba(4840,38,17040,6448)}g=m+102412+(k*12&-1)|0;c[m+102412+(k*12&-1)+4>>2]=j;l=m+102400|0;e=c[l>>2]|0;if((e+j|0)>102400){c[g>>2]=vh(j)|0;a[m+102412+(k*12&-1)+8|0]=1;o=m+102404|0;p=c[o>>2]|0;q=p+j|0;c[o>>2]=q;r=m+102408|0;s=c[r>>2]|0;t=(s|0)>(q|0);u=t?s:q;c[r>>2]=u;v=c[i>>2]|0;w=v+1|0;c[i>>2]=w;x=g|0;y=c[x>>2]|0;z=y;A=b+20|0;c[A>>2]=z;return}else{c[g>>2]=m+e;a[m+102412+(k*12&-1)+8|0]=0;c[l>>2]=(c[l>>2]|0)+j;o=m+102404|0;p=c[o>>2]|0;q=p+j|0;c[o>>2]=q;r=m+102408|0;s=c[r>>2]|0;t=(s|0)>(q|0);u=t?s:q;c[r>>2]=u;v=c[i>>2]|0;w=v+1|0;c[i>>2]=w;x=g|0;y=c[x>>2]|0;z=y;A=b+20|0;c[A>>2]=z;return}}function dM(d,e,f,h,j){d=d|0;e=e|0;f=f|0;h=h|0;j=j|0;var l=0,m=0,n=0,o=0,p=0,q=0.0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0,O=0,Q=0.0,T=0.0,U=0.0,V=0.0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0.0,ad=0.0,ae=0;l=i;i=i+160|0;m=l|0;n=l+24|0;o=l+56|0;p=l+104|0;q=+g[f>>2];r=d+28|0;if((c[r>>2]|0)>0){s=d+8|0;t=h|0;u=h+4|0;h=d+20|0;v=d+24|0;w=0;while(1){x=c[(c[s>>2]|0)+(w<<2)>>2]|0;y=x+44|0;z=c[y>>2]|0;A=c[y+4>>2]|0;B=+g[x+56>>2];y=x+64|0;C=+g[y>>2];D=+g[y+4>>2];E=+g[x+72>>2];y=x+36|0;c[y>>2]=z;c[y+4>>2]=A;g[x+52>>2]=B;if((c[x>>2]|0)==2){F=+g[x+140>>2];G=+g[x+120>>2];H=1.0-q*+g[x+132>>2];I=H<1.0?H:1.0;H=I<0.0?0.0:I;I=1.0-q*+g[x+136>>2];J=I<1.0?I:1.0;K=(E+q*+g[x+128>>2]*+g[x+84>>2])*(J<0.0?0.0:J);L=(C+q*(F*+g[t>>2]+G*+g[x+76>>2]))*H;M=(D+q*(F*+g[u>>2]+G*+g[x+80>>2]))*H}else{K=E;L=C;M=D}x=(c[h>>2]|0)+(w*12&-1)|0;c[x>>2]=z;c[x+4>>2]=A;g[(c[h>>2]|0)+(w*12&-1)+8>>2]=B;A=(c[v>>2]|0)+(w*12&-1)|0;B=+M;g[A>>2]=L;g[A+4>>2]=B;g[(c[v>>2]|0)+(w*12&-1)+8>>2]=K;A=w+1|0;if((A|0)<(c[r>>2]|0)){w=A}else{N=h;O=v;break}}}else{N=d+20|0;O=d+24|0}v=n;h=f;c[v>>2]=c[h>>2];c[v+4>>2]=c[h+4>>2];c[v+8>>2]=c[h+8>>2];c[v+12>>2]=c[h+12>>2];c[v+16>>2]=c[h+16>>2];c[v+20>>2]=c[h+20>>2];v=c[N>>2]|0;c[n+24>>2]=v;w=c[O>>2]|0;c[n+28>>2]=w;u=o;c[u>>2]=c[h>>2];c[u+4>>2]=c[h+4>>2];c[u+8>>2]=c[h+8>>2];c[u+12>>2]=c[h+12>>2];c[u+16>>2]=c[h+16>>2];c[u+20>>2]=c[h+20>>2];h=d+12|0;c[o+24>>2]=c[h>>2];u=d+36|0;c[o+28>>2]=c[u>>2];c[o+32>>2]=v;c[o+36>>2]=w;c[o+40>>2]=c[d>>2];en(p,o);ep(p);if((a[f+20|0]&1)!=0){eo(p)}o=d+32|0;if((c[o>>2]|0)>0){w=d+16|0;v=0;do{t=c[(c[w>>2]|0)+(v<<2)>>2]|0;bp[c[(c[t>>2]|0)+28>>2]&511](t,n);v=v+1|0;}while((v|0)<(c[o>>2]|0))}g[e+12>>2]=0.0;v=f+12|0;if((c[v>>2]|0)>0){w=d+16|0;t=0;do{if((c[o>>2]|0)>0){s=0;do{A=c[(c[w>>2]|0)+(s<<2)>>2]|0;bp[c[(c[A>>2]|0)+32>>2]&511](A,n);s=s+1|0;}while((s|0)<(c[o>>2]|0))}er(p);t=t+1|0;}while((t|0)<(c[v>>2]|0))}v=c[p+48>>2]|0;if((v|0)>0){t=c[p+40>>2]|0;w=c[p+44>>2]|0;s=0;do{A=c[w+(c[t+(s*152&-1)+148>>2]<<2)>>2]|0;x=t+(s*152&-1)+144|0;if((c[x>>2]|0)>0){z=0;do{g[A+64+(z*20&-1)+8>>2]=+g[t+(s*152&-1)+(z*36&-1)+16>>2];g[A+64+(z*20&-1)+12>>2]=+g[t+(s*152&-1)+(z*36&-1)+20>>2];z=z+1|0;}while((z|0)<(c[x>>2]|0))}s=s+1|0;}while((s|0)<(v|0))}g[e+16>>2]=0.0;if((c[r>>2]|0)>0){v=0;do{s=c[N>>2]|0;t=s+(v*12&-1)|0;K=+g[t>>2];L=+g[t+4>>2];M=+g[s+(v*12&-1)+8>>2];s=c[O>>2]|0;w=s+(v*12&-1)|0;B=+g[w>>2];D=+g[w+4>>2];C=+g[s+(v*12&-1)+8>>2];E=q*B;H=q*D;G=E*E+H*H;if(G>4.0){H=2.0/+P(+G);Q=B*H;T=D*H}else{Q=B;T=D}D=q*C;if(D*D>2.4674012660980225){if(D>0.0){U=D}else{U=-0.0-D}V=C*(1.5707963705062866/U)}else{V=C}C=+(L+q*T);g[t>>2]=K+q*Q;g[t+4>>2]=C;g[(c[N>>2]|0)+(v*12&-1)+8>>2]=M+q*V;t=(c[O>>2]|0)+(v*12&-1)|0;M=+T;g[t>>2]=Q;g[t+4>>2]=M;g[(c[O>>2]|0)+(v*12&-1)+8>>2]=V;v=v+1|0;}while((v|0)<(c[r>>2]|0))}v=f+16|0;f=d+16|0;t=0;while(1){if((t|0)>=(c[v>>2]|0)){W=1;break}s=eq(p)|0;if((c[o>>2]|0)>0){w=1;x=0;while(1){z=c[(c[f>>2]|0)+(x<<2)>>2]|0;A=w&(bF[c[(c[z>>2]|0)+36>>2]&255](z,n)|0);z=x+1|0;if((z|0)<(c[o>>2]|0)){w=A;x=z}else{X=A;break}}}else{X=1}if(s&X){W=0;break}else{t=t+1|0}}if((c[r>>2]|0)>0){t=d+8|0;X=0;do{o=c[(c[t>>2]|0)+(X<<2)>>2]|0;n=(c[N>>2]|0)+(X*12&-1)|0;f=o+44|0;v=c[n>>2]|0;x=c[n+4>>2]|0;c[f>>2]=v;c[f+4>>2]=x;V=+g[(c[N>>2]|0)+(X*12&-1)+8>>2];g[o+56>>2]=V;f=(c[O>>2]|0)+(X*12&-1)|0;n=o+64|0;w=c[f+4>>2]|0;c[n>>2]=c[f>>2];c[n+4>>2]=w;g[o+72>>2]=+g[(c[O>>2]|0)+(X*12&-1)+8>>2];Q=+S(+V);g[o+20>>2]=Q;T=+R(+V);g[o+24>>2]=T;V=+g[o+28>>2];U=+g[o+32>>2];w=o+12|0;M=+((c[k>>2]=x,+g[k>>2])-(Q*V+T*U));g[w>>2]=(c[k>>2]=v,+g[k>>2])-(T*V-Q*U);g[w+4>>2]=M;X=X+1|0;}while((X|0)<(c[r>>2]|0))}g[e+20>>2]=0.0;e=c[p+40>>2]|0;X=d+4|0;do{if((c[X>>2]|0)!=0){if((c[u>>2]|0)<=0){break}O=m+16|0;N=0;do{t=c[(c[h>>2]|0)+(N<<2)>>2]|0;w=c[e+(N*152&-1)+144>>2]|0;c[O>>2]=w;if((w|0)>0){v=0;do{g[m+(v<<2)>>2]=+g[e+(N*152&-1)+(v*36&-1)+16>>2];g[m+8+(v<<2)>>2]=+g[e+(N*152&-1)+(v*36&-1)+20>>2];v=v+1|0;}while((v|0)<(w|0))}w=c[X>>2]|0;bL[c[(c[w>>2]|0)+20>>2]&127](w,t,m);N=N+1|0;}while((N|0)<(c[u>>2]|0))}}while(0);if(!j){Y=p+32|0;Z=c[Y>>2]|0;_=e;dg(Z,_);$=p+36|0;aa=c[$>>2]|0;ab=aa;dg(Z,ab);i=l;return}j=c[r>>2]|0;if((j|0)>0){u=d+8|0;M=3.4028234663852886e+38;m=0;while(1){X=c[(c[u>>2]|0)+(m<<2)>>2]|0;L2198:do{if((c[X>>2]|0)==0){ac=M}else{do{if((b[X+4>>1]&4)!=0){U=+g[X+72>>2];if(U*U>.001218469929881394){break}U=+g[X+64>>2];Q=+g[X+68>>2];if(U*U+Q*Q>9999999747378752.0e-20){break}h=X+144|0;Q=q+ +g[h>>2];g[h>>2]=Q;ac=M>2]=0.0;ac=0.0}}while(0);X=m+1|0;t=c[r>>2]|0;if((X|0)<(t|0)){M=ac;m=X}else{ad=ac;ae=t;break}}}else{ad=3.4028234663852886e+38;ae=j}if(!((ae|0)>0&((ad<.5|W)^1))){Y=p+32|0;Z=c[Y>>2]|0;_=e;dg(Z,_);$=p+36|0;aa=c[$>>2]|0;ab=aa;dg(Z,ab);i=l;return}W=d+8|0;d=0;do{ae=c[(c[W>>2]|0)+(d<<2)>>2]|0;j=ae+4|0;b[j>>1]=b[j>>1]&-3;g[ae+144>>2]=0.0;vq(ae+64|0,0,24);d=d+1|0;}while((d|0)<(c[r>>2]|0));Y=p+32|0;Z=c[Y>>2]|0;_=e;dg(Z,_);$=p+36|0;aa=c[$>>2]|0;ab=aa;dg(Z,ab);i=l;return}function dN(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0,L=0,M=0,N=0,O=0,Q=0;f=i;i=i+128|0;h=f|0;j=f+24|0;k=f+72|0;l=a+28|0;m=c[l>>2]|0;if((m|0)<=(d|0)){ba(10776,386,15200,12416)}if((m|0)<=(e|0)){ba(10776,387,15200,9688)}if((m|0)>0){m=a+8|0;n=a+20|0;o=a+24|0;p=0;while(1){q=c[(c[m>>2]|0)+(p<<2)>>2]|0;r=q+44|0;s=(c[n>>2]|0)+(p*12&-1)|0;t=c[r+4>>2]|0;c[s>>2]=c[r>>2];c[s+4>>2]=t;g[(c[n>>2]|0)+(p*12&-1)+8>>2]=+g[q+56>>2];t=q+64|0;s=(c[o>>2]|0)+(p*12&-1)|0;r=c[t+4>>2]|0;c[s>>2]=c[t>>2];c[s+4>>2]=r;g[(c[o>>2]|0)+(p*12&-1)+8>>2]=+g[q+72>>2];q=p+1|0;if((q|0)<(c[l>>2]|0)){p=q}else{u=n;v=o;break}}}else{u=a+20|0;v=a+24|0}o=a+12|0;c[j+24>>2]=c[o>>2];n=a+36|0;c[j+28>>2]=c[n>>2];c[j+40>>2]=c[a>>2];p=j;m=b;c[p>>2]=c[m>>2];c[p+4>>2]=c[m+4>>2];c[p+8>>2]=c[m+8>>2];c[p+12>>2]=c[m+12>>2];c[p+16>>2]=c[m+16>>2];c[p+20>>2]=c[m+20>>2];c[j+32>>2]=c[u>>2];c[j+36>>2]=c[v>>2];en(k,j);j=b+16|0;m=0;while(1){if((m|0)>=(c[j>>2]|0)){break}if(ev(k,d,e)|0){break}else{m=m+1|0}}m=a+8|0;j=(c[u>>2]|0)+(d*12&-1)|0;p=(c[(c[m>>2]|0)+(d<<2)>>2]|0)+36|0;q=c[j+4>>2]|0;c[p>>2]=c[j>>2];c[p+4>>2]=q;g[(c[(c[m>>2]|0)+(d<<2)>>2]|0)+52>>2]=+g[(c[u>>2]|0)+(d*12&-1)+8>>2];d=(c[u>>2]|0)+(e*12&-1)|0;q=(c[(c[m>>2]|0)+(e<<2)>>2]|0)+36|0;p=c[d+4>>2]|0;c[q>>2]=c[d>>2];c[q+4>>2]=p;g[(c[(c[m>>2]|0)+(e<<2)>>2]|0)+52>>2]=+g[(c[u>>2]|0)+(e*12&-1)+8>>2];ep(k);e=b+12|0;if((c[e>>2]|0)>0){p=0;do{er(k);p=p+1|0;}while((p|0)<(c[e>>2]|0))}w=+g[b>>2];if((c[l>>2]|0)>0){b=0;do{e=c[u>>2]|0;p=e+(b*12&-1)|0;x=+g[p>>2];y=+g[p+4>>2];z=+g[e+(b*12&-1)+8>>2];e=c[v>>2]|0;q=e+(b*12&-1)|0;A=+g[q>>2];B=+g[q+4>>2];C=+g[e+(b*12&-1)+8>>2];D=w*A;E=w*B;F=D*D+E*E;if(F>4.0){E=2.0/+P(+F);G=A*E;H=B*E}else{G=A;H=B}B=w*C;if(B*B>2.4674012660980225){if(B>0.0){I=B}else{I=-0.0-B}J=C*(1.5707963705062866/I)}else{J=C}C=x+w*G;x=y+w*H;y=z+w*J;z=+C;B=+x;g[p>>2]=z;g[p+4>>2]=B;g[(c[u>>2]|0)+(b*12&-1)+8>>2]=y;p=(c[v>>2]|0)+(b*12&-1)|0;A=+G;E=+H;g[p>>2]=A;g[p+4>>2]=E;g[(c[v>>2]|0)+(b*12&-1)+8>>2]=J;p=c[(c[m>>2]|0)+(b<<2)>>2]|0;e=p+44|0;g[e>>2]=z;g[e+4>>2]=B;g[p+56>>2]=y;e=p+64|0;g[e>>2]=A;g[e+4>>2]=E;g[p+72>>2]=J;E=+S(+y);g[p+20>>2]=E;A=+R(+y);g[p+24>>2]=A;y=+g[p+28>>2];B=+g[p+32>>2];e=p+12|0;z=+(x-(E*y+A*B));g[e>>2]=C-(A*y-E*B);g[e+4>>2]=z;b=b+1|0;}while((b|0)<(c[l>>2]|0))}l=c[k+40>>2]|0;b=a+4|0;if((c[b>>2]|0)==0){K=k+32|0;L=c[K>>2]|0;M=l;dg(L,M);N=k+36|0;O=c[N>>2]|0;Q=O;dg(L,Q);i=f;return}if((c[n>>2]|0)<=0){K=k+32|0;L=c[K>>2]|0;M=l;dg(L,M);N=k+36|0;O=c[N>>2]|0;Q=O;dg(L,Q);i=f;return}a=h+16|0;m=0;do{v=c[(c[o>>2]|0)+(m<<2)>>2]|0;u=c[l+(m*152&-1)+144>>2]|0;c[a>>2]=u;if((u|0)>0){e=0;do{g[h+(e<<2)>>2]=+g[l+(m*152&-1)+(e*36&-1)+16>>2];g[h+8+(e<<2)>>2]=+g[l+(m*152&-1)+(e*36&-1)+20>>2];e=e+1|0;}while((e|0)<(u|0))}u=c[b>>2]|0;bL[c[(c[u>>2]|0)+20>>2]&127](u,v,h);m=m+1|0;}while((m|0)<(c[n>>2]|0));K=k+32|0;L=c[K>>2]|0;M=l;dg(L,M);N=k+36|0;O=c[N>>2]|0;Q=O;dg(L,Q);i=f;return}function dO(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,k=0;e=b|0;f=b+8|0;c[f>>2]=128;c[b+4>>2]=0;h=vh(1024)|0;c[b>>2]=h;vq(h|0,0,c[f>>2]<<3|0);vq(b+12|0,0,56);do{if((a[22056]&1)==0){f=0;h=1;while(1){if((f|0)>=14){i=1732;break}if((h|0)>(c[22712+(f<<2)>>2]|0)){j=f+1|0;a[h+22064|0]=j&255;k=j}else{a[h+22064|0]=f&255;k=f}j=h+1|0;if((j|0)<641){f=k;h=j}else{i=1737;break}}if((i|0)==1737){a[22056]=1;break}else if((i|0)==1732){ba(5352,73,17368,10976)}}}while(0);c[b+102468>>2]=0;c[b+102472>>2]=0;c[b+102476>>2]=0;c[b+102864>>2]=0;b3(b+102872|0);c[b+102932>>2]=0;c[b+102936>>2]=0;c[b+102940>>2]=4192;c[b+102944>>2]=4184;i=b+102948|0;c[b+102980>>2]=0;c[b+102984>>2]=0;vq(i|0,0,20);a[b+102992|0]=1;a[b+102993|0]=1;a[b+102994|0]=0;a[b+102995|0]=1;a[b+102976|0]=1;k=d;d=b+102968|0;h=c[k+4>>2]|0;c[d>>2]=c[k>>2];c[d+4>>2]=h;c[b+102868>>2]=4;g[b+102988>>2]=0.0;c[i>>2]=e;vq(b+102996|0,0,32);return}function dP(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;b=c[a+102952>>2]|0;if((b|0)!=0){d=a|0;e=b;while(1){b=c[e+96>>2]|0;f=c[e+100>>2]|0;while(1){if((f|0)==0){break}g=c[f+4>>2]|0;c[f+28>>2]=0;dK(f,d);f=g}if((b|0)==0){break}else{e=b}}}vi(c[a+102904>>2]|0);vi(c[a+102916>>2]|0);vi(c[a+102876>>2]|0);if((c[a+102468>>2]|0)!=0){ba(4840,32,17e3,10664)}if((c[a+102864>>2]|0)!=0){ba(4840,33,17e3,7952)}e=a+4|0;d=a|0;a=c[d>>2]|0;if((c[e>>2]|0)>0){h=0;i=a}else{j=a;k=j;vi(k);return}while(1){vi(c[i+(h<<3)+4>>2]|0);a=h+1|0;f=c[d>>2]|0;if((a|0)<(c[e>>2]|0)){h=a;i=f}else{j=f;break}}k=j;vi(k);return}function dQ(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0;e=b+102960|0;if((c[e>>2]|0)<=0){ba(10624,133,15568,9672)}if((c[b+102868>>2]&2|0)!=0){ba(10624,134,15568,12392)}f=d+108|0;g=c[f>>2]|0;if((g|0)!=0){h=b+102980|0;i=g;while(1){g=c[i+12>>2]|0;j=c[h>>2]|0;if((j|0)==0){k=i+4|0}else{l=i+4|0;bp[c[(c[j>>2]|0)+8>>2]&511](j,c[l>>2]|0);k=l}dR(b,c[k>>2]|0);c[f>>2]=g;if((g|0)==0){break}else{i=g}}}c[f>>2]=0;f=d+112|0;i=c[f>>2]|0;if((i|0)!=0){k=b+102872|0;h=i;while(1){i=c[h+12>>2]|0;dp(k,c[h+4>>2]|0);if((i|0)==0){break}else{h=i}}}c[f>>2]=0;f=d+100|0;h=c[f>>2]|0;L2321:do{if((h|0)==0){m=d+104|0}else{k=b+102980|0;i=b+102912|0;g=b+102904|0;l=b+102900|0;j=b+102872|0;n=b|0;o=d+104|0;p=h;while(1){q=c[p+4>>2]|0;r=c[k>>2]|0;if((r|0)!=0){bp[c[(c[r>>2]|0)+12>>2]&511](r,p)}r=p+28|0;if((c[r>>2]|0)>0){s=p+24|0;t=0;do{u=(c[s>>2]|0)+(t*28&-1)+24|0;v=c[u>>2]|0;w=c[i>>2]|0;x=0;while(1){if((x|0)>=(w|0)){break}y=(c[g>>2]|0)+(x<<2)|0;if((c[y>>2]|0)==(v|0)){z=1790;break}else{x=x+1|0}}if((z|0)==1790){z=0;c[y>>2]=-1}c[l>>2]=(c[l>>2]|0)-1;cl(j,v);c[u>>2]=-1;t=t+1|0;}while((t|0)<(c[r>>2]|0))}c[r>>2]=0;dK(p,n);t=a[22108]|0;if((t&255)>=14){break}s=b+12+((t&255)<<2)|0;c[p>>2]=c[s>>2];c[s>>2]=p;c[f>>2]=q;c[o>>2]=(c[o>>2]|0)-1;if((q|0)==0){m=o;break L2321}else{p=q}}ba(5352,173,17448,6544)}}while(0);c[f>>2]=0;c[m>>2]=0;m=d+92|0;f=c[m>>2]|0;y=d+96|0;if((f|0)!=0){c[f+96>>2]=c[y>>2]}f=c[y>>2]|0;if((f|0)!=0){c[f+92>>2]=c[m>>2]}m=b+102952|0;if((c[m>>2]|0)==(d|0)){c[m>>2]=c[y>>2]}c[e>>2]=(c[e>>2]|0)-1;e=a[22216]|0;if((e&255)<14){y=b+12+((e&255)<<2)|0;c[d>>2]=c[y>>2];c[y>>2]=d;return}else{ba(5352,173,17448,6544)}}function dR(d,e){d=d|0;e=e|0;var f=0,h=0,i=0,j=0,k=0,l=0,m=0;if((c[d+102868>>2]&2|0)!=0){ba(10624,274,15528,12392)}f=a[e+61|0]&1;h=e+8|0;i=c[h>>2]|0;j=e+12|0;if((i|0)!=0){c[i+12>>2]=c[j>>2]}i=c[j>>2]|0;if((i|0)!=0){c[i+8>>2]=c[h>>2]}h=d+102956|0;if((c[h>>2]|0)==(e|0)){c[h>>2]=c[j>>2]}j=c[e+48>>2]|0;h=c[e+52>>2]|0;i=j+4|0;k=b[i>>1]|0;if((k&2)==0){b[i>>1]=k|2;g[j+144>>2]=0.0}k=h+4|0;i=b[k>>1]|0;if((i&2)==0){b[k>>1]=i|2;g[h+144>>2]=0.0}i=e+24|0;k=c[i>>2]|0;l=e+28|0;if((k|0)!=0){c[k+12>>2]=c[l>>2]}k=c[l>>2]|0;if((k|0)!=0){c[k+8>>2]=c[i>>2]}k=j+108|0;if((e+16|0)==(c[k>>2]|0)){c[k>>2]=c[l>>2]}c[i>>2]=0;c[l>>2]=0;l=e+40|0;i=c[l>>2]|0;k=e+44|0;if((i|0)!=0){c[i+12>>2]=c[k>>2]}i=c[k>>2]|0;if((i|0)!=0){c[i+8>>2]=c[l>>2]}i=h+108|0;if((e+32|0)==(c[i>>2]|0)){c[i>>2]=c[k>>2]}c[l>>2]=0;c[k>>2]=0;fl(e,d|0);e=d+102964|0;d=c[e>>2]|0;if((d|0)<=0){ba(10624,346,15528,7232)}c[e>>2]=d-1;if(f<<24>>24!=0){return}f=c[h+112>>2]|0;if((f|0)==0){return}else{m=f}do{if((c[m>>2]|0)==(j|0)){f=(c[m+4>>2]|0)+4|0;c[f>>2]=c[f>>2]|8}m=c[m+12>>2]|0;}while((m|0)!=0);return}function dS(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;if((c[b+102868>>2]&2|0)!=0){ba(10624,214,15608,12392);return 0}e=fk(d,b|0)|0;c[e+8>>2]=0;f=b+102956|0;c[e+12>>2]=c[f>>2];g=c[f>>2]|0;if((g|0)!=0){c[g+8>>2]=e}c[f>>2]=e;f=b+102964|0;c[f>>2]=(c[f>>2]|0)+1;f=e+16|0;c[e+20>>2]=e;b=e+52|0;c[f>>2]=c[b>>2];c[e+24>>2]=0;g=e+48|0;h=c[g>>2]|0;i=h+108|0;c[e+28>>2]=c[i>>2];j=c[i>>2]|0;if((j|0)==0){k=h}else{c[j+8>>2]=f;k=c[g>>2]|0}c[k+108>>2]=f;f=e+32|0;c[e+36>>2]=e;c[f>>2]=c[g>>2];c[e+40>>2]=0;g=c[b>>2]|0;k=g+108|0;c[e+44>>2]=c[k>>2];j=c[k>>2]|0;if((j|0)==0){l=g}else{c[j+8>>2]=f;l=c[b>>2]|0}c[l+108>>2]=f;f=c[d+8>>2]|0;if((a[d+16|0]&1)!=0){return e|0}l=c[(c[d+12>>2]|0)+112>>2]|0;if((l|0)==0){return e|0}else{m=l}do{if((c[m>>2]|0)==(f|0)){l=(c[m+4>>2]|0)+4|0;c[l>>2]=c[l>>2]|8}m=c[m+12>>2]|0;}while((m|0)!=0);return e|0}function dT(d,e){d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0.0,af=0.0,ag=0.0,ah=0.0,ai=0.0;f=i;i=i+104|0;h=f|0;j=f+16|0;k=f+72|0;l=d+103008|0;g[l>>2]=0.0;m=d+103012|0;g[m>>2]=0.0;n=d+103016|0;g[n>>2]=0.0;o=d+102960|0;p=d+102872|0;q=d+68|0;dL(j,c[o>>2]|0,c[d+102936>>2]|0,c[d+102964>>2]|0,q,c[d+102944>>2]|0);r=d+102952|0;s=c[r>>2]|0;if((s|0)!=0){t=s;do{s=t+4|0;b[s>>1]=b[s>>1]&-2;t=c[t+96>>2]|0;}while((t|0)!=0)}t=c[d+102932>>2]|0;if((t|0)!=0){s=t;do{t=s+4|0;c[t>>2]=c[t>>2]&-2;s=c[s+12>>2]|0;}while((s|0)!=0)}s=c[d+102956>>2]|0;if((s|0)!=0){t=s;do{a[t+60|0]=0;t=c[t+12>>2]|0;}while((t|0)!=0)}t=c[o>>2]|0;o=t<<2;s=d+102864|0;u=c[s>>2]|0;if((u|0)>=32){ba(4840,38,17040,6448)}v=d+102480+(u*12&-1)|0;c[d+102480+(u*12&-1)+4>>2]=o;w=d+102468|0;x=c[w>>2]|0;if((x+o|0)>102400){c[v>>2]=vh(o)|0;a[d+102480+(u*12&-1)+8|0]=1}else{c[v>>2]=x+(d+68);a[d+102480+(u*12&-1)+8|0]=0;c[w>>2]=(c[w>>2]|0)+o}w=d+102472|0;u=(c[w>>2]|0)+o|0;c[w>>2]=u;w=d+102476|0;o=c[w>>2]|0;c[w>>2]=(o|0)>(u|0)?o:u;c[s>>2]=(c[s>>2]|0)+1;s=c[v>>2]|0;v=s;u=c[r>>2]|0;L2451:do{if((u|0)!=0){o=j+28|0;w=j+36|0;x=j+32|0;y=j+40|0;z=j+8|0;A=j+48|0;B=j+16|0;C=j+44|0;D=j+12|0;E=d+102968|0;F=d+102976|0;G=k+12|0;H=k+16|0;I=k+20|0;J=u;L2453:while(1){K=J+4|0;do{if((b[K>>1]&35)==34){if((c[J>>2]|0)==0){break}c[o>>2]=0;c[w>>2]=0;c[x>>2]=0;c[v>>2]=J;b[K>>1]=b[K>>1]|1;L=1;while(1){M=L-1|0;N=c[v+(M<<2)>>2]|0;O=N+4|0;if((b[O>>1]&32)==0){P=1882;break L2453}Q=c[o>>2]|0;if((Q|0)>=(c[y>>2]|0)){P=1885;break L2453}c[N+8>>2]=Q;c[(c[z>>2]|0)+(c[o>>2]<<2)>>2]=N;c[o>>2]=(c[o>>2]|0)+1;Q=b[O>>1]|0;if((Q&2)==0){b[O>>1]=Q|2;g[N+144>>2]=0.0}do{if((c[N>>2]|0)==0){T=M}else{Q=c[N+112>>2]|0;if((Q|0)==0){U=M}else{O=M;V=Q;while(1){Q=c[V+4>>2]|0;W=Q+4|0;do{if((c[W>>2]&7|0)==6){if((a[(c[Q+48>>2]|0)+38|0]&1)!=0){X=O;break}if((a[(c[Q+52>>2]|0)+38|0]&1)!=0){X=O;break}Y=c[w>>2]|0;if((Y|0)>=(c[C>>2]|0)){P=1896;break L2453}c[w>>2]=Y+1;c[(c[D>>2]|0)+(Y<<2)>>2]=Q;c[W>>2]=c[W>>2]|1;Y=c[V>>2]|0;Z=Y+4|0;if((b[Z>>1]&1)!=0){X=O;break}if((O|0)>=(t|0)){P=1900;break L2453}c[v+(O<<2)>>2]=Y;b[Z>>1]=b[Z>>1]|1;X=O+1|0}else{X=O}}while(0);W=c[V+12>>2]|0;if((W|0)==0){U=X;break}else{O=X;V=W}}}V=c[N+108>>2]|0;if((V|0)==0){T=U;break}else{_=U;$=V}while(1){V=$+4|0;O=c[V>>2]|0;do{if((a[O+60|0]&1)==0){W=c[$>>2]|0;Q=W+4|0;if((b[Q>>1]&32)==0){aa=_;break}Z=c[x>>2]|0;if((Z|0)>=(c[A>>2]|0)){P=1908;break L2453}c[x>>2]=Z+1;c[(c[B>>2]|0)+(Z<<2)>>2]=O;a[(c[V>>2]|0)+60|0]=1;if((b[Q>>1]&1)!=0){aa=_;break}if((_|0)>=(t|0)){P=1912;break L2453}c[v+(_<<2)>>2]=W;b[Q>>1]=b[Q>>1]|1;aa=_+1|0}else{aa=_}}while(0);V=c[$+12>>2]|0;if((V|0)==0){T=aa;break}else{_=aa;$=V}}}}while(0);if((T|0)>0){L=T}else{break}}dM(j,k,e,E,(a[F]&1)!=0);g[l>>2]=+g[G>>2]+ +g[l>>2];g[m>>2]=+g[H>>2]+ +g[m>>2];g[n>>2]=+g[I>>2]+ +g[n>>2];L=c[o>>2]|0;if((L|0)>0){ab=0;ac=L}else{break}while(1){L=c[(c[z>>2]|0)+(ab<<2)>>2]|0;if((c[L>>2]|0)==0){N=L+4|0;b[N>>1]=b[N>>1]&-2;ad=c[o>>2]|0}else{ad=ac}N=ab+1|0;if((N|0)<(ad|0)){ab=N;ac=ad}else{break}}}}while(0);J=c[J+96>>2]|0;if((J|0)==0){break L2451}}if((P|0)==1896){ba(8576,62,15264,8040)}else if((P|0)==1900){ba(10624,495,15488,5752)}else if((P|0)==1885){ba(8576,54,15328,7760)}else if((P|0)==1882){ba(10624,445,15488,6264)}else if((P|0)==1912){ba(10624,524,15488,5752)}else if((P|0)==1908){ba(8576,68,15296,8280)}}}while(0);dg(q,s);s=c[r>>2]|0;if((s|0)!=0){r=h|0;q=h;P=h+8|0;h=P;ad=P+4|0;P=s;do{do{if((b[P+4>>1]&1)!=0){if((c[P>>2]|0)==0){break}ae=+g[P+52>>2];af=+S(+ae);g[h>>2]=af;ag=+R(+ae);g[ad>>2]=ag;ae=+g[P+28>>2];ah=+g[P+32>>2];ai=+(+g[P+40>>2]-(af*ae+ag*ah));g[r>>2]=+g[P+36>>2]-(ag*ae-af*ah);g[r+4>>2]=ai;s=(c[P+88>>2]|0)+102872|0;ac=c[P+100>>2]|0;if((ac|0)==0){break}ab=P+12|0;n=ac;do{dH(n,s,q,ab);n=c[n+4>>2]|0;}while((n|0)!=0)}}while(0);P=c[P+96>>2]|0;}while((P|0)!=0)}dy(p|0,p);g[d+103020>>2]=0.0;d=j|0;dg(c[d>>2]|0,c[j+20>>2]|0);dg(c[d>>2]|0,c[j+24>>2]|0);dg(c[d>>2]|0,c[j+16>>2]|0);dg(c[d>>2]|0,c[j+12>>2]|0);dg(c[d>>2]|0,c[j+8>>2]|0);i=f;return}function dU(d,e){d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0.0,ag=0,ah=0,ai=0,aj=0,ak=0.0,al=0,am=0,an=0,ao=0,ap=0,aq=0,ar=0,as=0,at=0,au=0,av=0.0,aw=0.0,ax=0.0,ay=0.0,az=0,aA=0.0,aB=0.0,aC=0.0,aD=0.0,aE=0,aF=0.0,aG=0.0,aH=0,aI=0,aJ=0,aK=0,aL=0,aM=0,aN=0,aO=0,aP=0,aQ=0,aR=0,aS=0,aT=0,aU=0,aV=0,aW=0,aX=0,aY=0,aZ=0,a_=0,a$=0,a0=0,a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0,a8=0,a9=0,bb=0,bc=0,bd=0;f=i;i=i+368|0;h=f|0;j=f+16|0;k=f+72|0;l=f+208|0;m=f+216|0;n=f+256|0;o=f+296|0;p=f+304|0;q=f+344|0;r=d+102872|0;s=d+102944|0;dL(j,64,32,0,d+68|0,c[s>>2]|0);t=d+102995|0;do{if((a[t]&1)==0){u=d+102932|0}else{v=c[d+102952>>2]|0;if((v|0)!=0){w=v;do{v=w+4|0;b[v>>1]=b[v>>1]&-2;g[w+60>>2]=0.0;w=c[w+96>>2]|0;}while((w|0)!=0)}w=d+102932|0;v=c[w>>2]|0;if((v|0)==0){u=w;break}else{x=v}while(1){v=x+4|0;c[v>>2]=c[v>>2]&-34;c[x+128>>2]=0;g[x+132>>2]=1.0;v=c[x+12>>2]|0;if((v|0)==0){u=w;break}else{x=v}}}}while(0);x=m;m=n;n=j+28|0;w=j+36|0;v=j+32|0;y=j+40|0;z=j+8|0;A=j+44|0;B=j+12|0;C=o|0;D=o+4|0;E=p;p=e|0;F=q|0;G=q+4|0;H=q+8|0;I=q+16|0;J=e+12|0;e=q+12|0;K=q+20|0;L=r|0;M=d+102994|0;d=h|0;N=h;O=h+8|0;h=O;P=O+4|0;O=k+16|0;Q=k+20|0;T=k+24|0;U=k+44|0;V=k+48|0;W=k+52|0;X=k|0;Y=k+28|0;Z=k+56|0;_=k+92|0;$=k+128|0;aa=l|0;ab=l+4|0;L2537:while(1){ac=c[u>>2]|0;if((ac|0)==0){ad=1;ae=2066;break}else{af=1.0;ag=0;ah=ac}while(1){ac=ah+4|0;ai=c[ac>>2]|0;do{if((ai&4|0)==0){aj=ag;ak=af}else{if((c[ah+128>>2]|0)>8){aj=ag;ak=af;break}if((ai&32|0)==0){al=c[ah+48>>2]|0;am=c[ah+52>>2]|0;if((a[al+38|0]&1)!=0){aj=ag;ak=af;break}if((a[am+38|0]&1)!=0){aj=ag;ak=af;break}an=c[al+8>>2]|0;ao=c[am+8>>2]|0;ap=c[an>>2]|0;aq=c[ao>>2]|0;ar=(aq|0)==2;if(!((ap|0)==2|ar)){ae=1961;break L2537}as=b[an+4>>1]|0;at=b[ao+4>>1]|0;if(((as&2)==0|(ap|0)==0)&((at&2)==0|(aq|0)==0)){aj=ag;ak=af;break}if((as&8)==0){au=(ap|0)!=2&1}else{au=1}if((at&8)==0){if((au|0)==0&ar){aj=ag;ak=af;break}}ar=an+28|0;at=an+60|0;av=+g[at>>2];ap=ao+28|0;as=ao+60|0;aw=+g[as>>2];do{if(av=1.0){ae=1970;break L2537}ax=(aw-av)/(1.0-av);aq=an+36|0;ay=1.0-ax;az=aq;aA=+(ay*+g[an+40>>2]+ax*+g[an+48>>2]);g[az>>2]=+g[aq>>2]*ay+ax*+g[an+44>>2];g[az+4>>2]=aA;az=an+52|0;g[az>>2]=ay*+g[az>>2]+ax*+g[an+56>>2];g[at>>2]=aw;aB=aw}else{if(aw>=av){aB=av;break}if(aw>=1.0){ae=1975;break L2537}ax=(av-aw)/(1.0-aw);az=ao+36|0;ay=1.0-ax;aq=az;aA=+(ay*+g[ao+40>>2]+ax*+g[ao+48>>2]);g[aq>>2]=+g[az>>2]*ay+ax*+g[ao+44>>2];g[aq+4>>2]=aA;aq=ao+52|0;g[aq>>2]=ay*+g[aq>>2]+ax*+g[ao+56>>2];g[as>>2]=av;aB=av}}while(0);if(aB>=1.0){ae=1979;break L2537}as=c[ah+56>>2]|0;ao=c[ah+60>>2]|0;c[O>>2]=0;c[Q>>2]=0;g[T>>2]=0.0;c[U>>2]=0;c[V>>2]=0;g[W>>2]=0.0;cf(X,c[al+12>>2]|0,as);cf(Y,c[am+12>>2]|0,ao);ao=ar;vp(Z|0,ao|0,36)|0;ao=ap;vp(_|0,ao|0,36)|0;g[$>>2]=1.0;cu(l,k);if((c[aa>>2]|0)==3){av=aB+(1.0-aB)*+g[ab>>2];aC=av<1.0?av:1.0}else{aC=1.0}g[ah+132>>2]=aC;c[ac>>2]=c[ac>>2]|32;aD=aC}else{aD=+g[ah+132>>2]}if(aD>=af){aj=ag;ak=af;break}aj=ah;ak=aD}}while(0);ac=c[ah+12>>2]|0;if((ac|0)==0){break}else{af=ak;ag=aj;ah=ac}}if((aj|0)==0|ak>.9999988079071045){ad=1;ae=2065;break}ac=c[(c[aj+48>>2]|0)+8>>2]|0;ai=c[(c[aj+52>>2]|0)+8>>2]|0;ao=ac+28|0;vp(x|0,ao|0,36)|0;as=ai+28|0;vp(m|0,as|0,36)|0;at=ac+60|0;av=+g[at>>2];if(av>=1.0){ae=1992;break}aw=(ak-av)/(1.0-av);an=ac+36|0;av=1.0-aw;aq=ac+44|0;az=ac+48|0;ax=+g[an>>2]*av+aw*+g[aq>>2];ay=av*+g[ac+40>>2]+aw*+g[az>>2];aE=an;aA=+ax;aF=+ay;g[aE>>2]=aA;g[aE+4>>2]=aF;aE=ac+52|0;an=ac+56|0;aG=av*+g[aE>>2]+aw*+g[an>>2];g[aE>>2]=aG;g[at>>2]=ak;at=ac+44|0;g[at>>2]=aA;g[at+4>>2]=aF;g[an>>2]=aG;aF=+S(+aG);at=ac+20|0;g[at>>2]=aF;aA=+R(+aG);aE=ac+24|0;g[aE>>2]=aA;aH=ac+28|0;aG=+g[aH>>2];aI=ac+32|0;aw=+g[aI>>2];aJ=ac+12|0;av=+(ay-(aF*aG+aA*aw));g[aJ>>2]=ax-(aA*aG-aF*aw);g[aJ+4>>2]=av;aK=ai+60|0;av=+g[aK>>2];if(av>=1.0){ae=1995;break}aw=(ak-av)/(1.0-av);aL=ai+36|0;av=1.0-aw;aM=ai+44|0;aN=ai+48|0;aF=+g[aL>>2]*av+aw*+g[aM>>2];aG=av*+g[ai+40>>2]+aw*+g[aN>>2];aO=aL;aA=+aF;ax=+aG;g[aO>>2]=aA;g[aO+4>>2]=ax;aO=ai+52|0;aL=ai+56|0;ay=av*+g[aO>>2]+aw*+g[aL>>2];g[aO>>2]=ay;g[aK>>2]=ak;aK=ai+44|0;g[aK>>2]=aA;g[aK+4>>2]=ax;g[aL>>2]=ay;ax=+S(+ay);aK=ai+20|0;g[aK>>2]=ax;aA=+R(+ay);aO=ai+24|0;g[aO>>2]=aA;aP=ai+28|0;ay=+g[aP>>2];aQ=ai+32|0;aw=+g[aQ>>2];aR=ai+12|0;av=+(aG-(ax*ay+aA*aw));g[aR>>2]=aF-(aA*ay-ax*aw);g[aR+4>>2]=av;eh(aj,c[s>>2]|0);aS=aj+4|0;aT=c[aS>>2]|0;c[aS>>2]=aT&-33;aU=aj+128|0;c[aU>>2]=(c[aU>>2]|0)+1;if((aT&6|0)!=6){c[aS>>2]=aT&-37;vp(ao|0,x|0,36)|0;vp(as|0,m|0,36)|0;av=+g[an>>2];aw=+S(+av);g[at>>2]=aw;ax=+R(+av);g[aE>>2]=ax;av=+g[aH>>2];ay=+g[aI>>2];aA=+(+g[az>>2]-(aw*av+ax*ay));g[aJ>>2]=+g[aq>>2]-(ax*av-aw*ay);g[aJ+4>>2]=aA;aA=+g[aL>>2];ay=+S(+aA);g[aK>>2]=ay;aw=+R(+aA);g[aO>>2]=aw;aA=+g[aP>>2];av=+g[aQ>>2];ax=+(+g[aN>>2]-(ay*aA+aw*av));g[aR>>2]=+g[aM>>2]-(aw*aA-ay*av);g[aR+4>>2]=ax;continue}aR=ac+4|0;aM=b[aR>>1]|0;if((aM&2)==0){b[aR>>1]=aM|2;g[ac+144>>2]=0.0}aM=ai+4|0;aN=b[aM>>1]|0;if((aN&2)==0){b[aM>>1]=aN|2;g[ai+144>>2]=0.0}c[n>>2]=0;c[w>>2]=0;c[v>>2]=0;aN=c[y>>2]|0;if((aN|0)<=0){ae=2005;break}aQ=ac+8|0;c[aQ>>2]=0;aP=c[z>>2]|0;c[aP>>2]=ac;c[n>>2]=1;if((aN|0)<=1){ae=2008;break}aN=ai+8|0;c[aN>>2]=1;c[aP+4>>2]=ai;c[n>>2]=2;if((c[A>>2]|0)<=0){ae=2011;break}c[w>>2]=1;c[c[B>>2]>>2]=aj;b[aR>>1]=b[aR>>1]|1;b[aM>>1]=b[aM>>1]|1;c[aS>>2]=c[aS>>2]|1;c[C>>2]=ac;c[D>>2]=ai;ai=1;aS=ac;while(1){L2593:do{if((c[aS>>2]|0)==2){ac=c[aS+112>>2]|0;if((ac|0)==0){break}aM=aS+4|0;aR=c[y>>2]|0;aP=ac;ac=c[n>>2]|0;while(1){if((ac|0)==(aR|0)){break L2593}aO=c[w>>2]|0;aK=c[A>>2]|0;if((aO|0)==(aK|0)){break L2593}aL=c[aP+4>>2]|0;aJ=aL+4|0;L2600:do{if((c[aJ>>2]&1|0)==0){aq=c[aP>>2]|0;az=aq|0;do{if((c[az>>2]|0)==2){if((b[aM>>1]&8)!=0){break}if((b[aq+4>>1]&8)==0){aV=ac;break L2600}}}while(0);if((a[(c[aL+48>>2]|0)+38|0]&1)!=0){aV=ac;break}if((a[(c[aL+52>>2]|0)+38|0]&1)!=0){aV=ac;break}aI=aq+28|0;vp(E|0,aI|0,36)|0;aH=aq+4|0;if((b[aH>>1]&1)==0){aE=aq+60|0;ax=+g[aE>>2];if(ax>=1.0){ae=2027;break L2537}av=(ak-ax)/(1.0-ax);at=aq+36|0;ax=1.0-av;ay=+g[at>>2]*ax+av*+g[aq+44>>2];aA=ax*+g[aq+40>>2]+av*+g[aq+48>>2];an=at;aw=+ay;aF=+aA;g[an>>2]=aw;g[an+4>>2]=aF;an=aq+52|0;at=aq+56|0;aG=ax*+g[an>>2]+av*+g[at>>2];g[an>>2]=aG;g[aE>>2]=ak;aE=aq+44|0;g[aE>>2]=aw;g[aE+4>>2]=aF;g[at>>2]=aG;aF=+S(+aG);g[aq+20>>2]=aF;aw=+R(+aG);g[aq+24>>2]=aw;aG=+g[aq+28>>2];av=+g[aq+32>>2];at=aq+12|0;ax=+(aA-(aF*aG+aw*av));g[at>>2]=ay-(aw*aG-aF*av);g[at+4>>2]=ax}eh(aL,c[s>>2]|0);at=c[aJ>>2]|0;if((at&4|0)==0){vp(aI|0,E|0,36)|0;ax=+g[aq+56>>2];av=+S(+ax);g[aq+20>>2]=av;aF=+R(+ax);g[aq+24>>2]=aF;ax=+g[aq+28>>2];aG=+g[aq+32>>2];aE=aq+12|0;aw=+(+g[aq+48>>2]-(av*ax+aF*aG));g[aE>>2]=+g[aq+44>>2]-(aF*ax-av*aG);g[aE+4>>2]=aw;aV=ac;break}if((at&2|0)==0){vp(aI|0,E|0,36)|0;aw=+g[aq+56>>2];aG=+S(+aw);g[aq+20>>2]=aG;av=+R(+aw);g[aq+24>>2]=av;aw=+g[aq+28>>2];ax=+g[aq+32>>2];aI=aq+12|0;aF=+(+g[aq+48>>2]-(aG*aw+av*ax));g[aI>>2]=+g[aq+44>>2]-(av*aw-aG*ax);g[aI+4>>2]=aF;aV=ac;break}c[aJ>>2]=at|1;if((aO|0)>=(aK|0)){ae=2036;break L2537}c[w>>2]=aO+1;c[(c[B>>2]|0)+(aO<<2)>>2]=aL;at=b[aH>>1]|0;if((at&1)!=0){aV=ac;break}b[aH>>1]=at|1;do{if((c[az>>2]|0)!=0){if((at&2)!=0){break}b[aH>>1]=at|3;g[aq+144>>2]=0.0}}while(0);if((ac|0)>=(aR|0)){ae=2043;break L2537}c[aq+8>>2]=ac;c[(c[z>>2]|0)+(ac<<2)>>2]=aq;at=ac+1|0;c[n>>2]=at;aV=at}else{aV=ac}}while(0);aL=c[aP+12>>2]|0;if((aL|0)==0){break}else{aP=aL;ac=aV}}}}while(0);if((ai|0)>=2){break}ac=c[o+(ai<<2)>>2]|0;ai=ai+1|0;aS=ac}aF=(1.0-ak)*+g[p>>2];g[F>>2]=aF;g[G>>2]=1.0/aF;g[H>>2]=1.0;c[I>>2]=20;c[e>>2]=c[J>>2];a[K]=0;dN(j,q,c[aQ>>2]|0,c[aN>>2]|0);aS=c[n>>2]|0;if((aS|0)>0){ai=c[z>>2]|0;ac=0;do{aP=c[ai+(ac<<2)>>2]|0;aR=aP+4|0;b[aR>>1]=b[aR>>1]&-2;do{if((c[aP>>2]|0)==2){aF=+g[aP+52>>2];ax=+S(+aF);g[h>>2]=ax;aG=+R(+aF);g[P>>2]=aG;aF=+g[aP+28>>2];aw=+g[aP+32>>2];av=+(+g[aP+40>>2]-(ax*aF+aG*aw));g[d>>2]=+g[aP+36>>2]-(aG*aF-ax*aw);g[d+4>>2]=av;aR=(c[aP+88>>2]|0)+102872|0;aM=c[aP+100>>2]|0;if((aM|0)!=0){ap=aP+12|0;ar=aM;do{dH(ar,aR,N,ap);ar=c[ar+4>>2]|0;}while((ar|0)!=0)}ar=c[aP+112>>2]|0;if((ar|0)==0){break}else{aW=ar}do{ar=(c[aW+4>>2]|0)+4|0;c[ar>>2]=c[ar>>2]&-34;aW=c[aW+12>>2]|0;}while((aW|0)!=0)}}while(0);ac=ac+1|0;}while((ac|0)<(aS|0))}dy(L,r);if((a[M]&1)!=0){ad=0;ae=2067;break}}if((ae|0)==2065){a[t]=ad;aX=j|0;aY=c[aX>>2]|0;aZ=j+20|0;a_=c[aZ>>2]|0;a$=a_;dg(aY,a$);a0=c[aX>>2]|0;a1=j+24|0;a2=c[a1>>2]|0;a3=a2;dg(a0,a3);a4=c[aX>>2]|0;a5=j+16|0;a6=c[a5>>2]|0;a7=a6;dg(a4,a7);a8=c[aX>>2]|0;a9=c[B>>2]|0;bb=a9;dg(a8,bb);bc=c[z>>2]|0;bd=bc;dg(a8,bd);i=f;return}else if((ae|0)==2066){a[t]=ad;aX=j|0;aY=c[aX>>2]|0;aZ=j+20|0;a_=c[aZ>>2]|0;a$=a_;dg(aY,a$);a0=c[aX>>2]|0;a1=j+24|0;a2=c[a1>>2]|0;a3=a2;dg(a0,a3);a4=c[aX>>2]|0;a5=j+16|0;a6=c[a5>>2]|0;a7=a6;dg(a4,a7);a8=c[aX>>2]|0;a9=c[B>>2]|0;bb=a9;dg(a8,bb);bc=c[z>>2]|0;bd=bc;dg(a8,bd);i=f;return}else if((ae|0)==2067){a[t]=ad;aX=j|0;aY=c[aX>>2]|0;aZ=j+20|0;a_=c[aZ>>2]|0;a$=a_;dg(aY,a$);a0=c[aX>>2]|0;a1=j+24|0;a2=c[a1>>2]|0;a3=a2;dg(a0,a3);a4=c[aX>>2]|0;a5=j+16|0;a6=c[a5>>2]|0;a7=a6;dg(a4,a7);a8=c[aX>>2]|0;a9=c[B>>2]|0;bb=a9;dg(a8,bb);bc=c[z>>2]|0;bd=bc;dg(a8,bd);i=f;return}else if((ae|0)==1979){ba(10624,676,15440,4888)}else if((ae|0)==1995){ba(8768,723,15712,4888)}else if((ae|0)==1975){ba(8768,723,15712,4888)}else if((ae|0)==2043){ba(8576,54,15328,7760)}else if((ae|0)==2008){ba(8576,54,15328,7760)}else if((ae|0)==2036){ba(8576,62,15264,8040)}else if((ae|0)==1992){ba(8768,723,15712,4888)}else if((ae|0)==2027){ba(8768,723,15712,4888)}else if((ae|0)==1961){ba(10624,641,15440,5216)}else if((ae|0)==1970){ba(8768,723,15712,4888)}else if((ae|0)==2011){ba(8576,62,15264,8040)}else if((ae|0)==2005){ba(8576,54,15328,7760)}}function dV(b,d,e,f){b=b|0;d=+d;e=e|0;f=f|0;var h=0,j=0,k=0,l=0,m=0,n=0,o=0.0,p=0,q=0,r=0,s=0;h=i;i=i+24|0;j=h|0;k=b+102868|0;l=c[k>>2]|0;if((l&1|0)==0){m=l}else{l=b+102872|0;dy(l|0,l);l=c[k>>2]&-2;c[k>>2]=l;m=l}c[k>>2]=m|2;m=j|0;g[m>>2]=d;c[j+12>>2]=e;c[j+16>>2]=f;f=d>0.0;if(f){g[j+4>>2]=1.0/d}else{g[j+4>>2]=0.0}e=b+102988|0;g[j+8>>2]=+g[e>>2]*d;a[j+20|0]=a[b+102992|0]&1;dx(b+102872|0);g[b+103e3>>2]=0.0;if(!((a[b+102995|0]&1)==0|f^1)){dT(b,j);g[b+103004>>2]=0.0}do{if((a[b+102993|0]&1)==0){n=2078}else{d=+g[m>>2];if(d<=0.0){o=d;break}dU(b,j);g[b+103024>>2]=0.0;n=2078}}while(0);if((n|0)==2078){o=+g[m>>2]}if(o>0.0){g[e>>2]=+g[j+4>>2]}j=c[k>>2]|0;if((j&4|0)==0){p=j;q=p&-3;c[k>>2]=q;r=b+102996|0;g[r>>2]=0.0;i=h;return}e=c[b+102952>>2]|0;if((e|0)==0){p=j;q=p&-3;c[k>>2]=q;r=b+102996|0;g[r>>2]=0.0;i=h;return}else{s=e}do{g[s+76>>2]=0.0;g[s+80>>2]=0.0;g[s+84>>2]=0.0;s=c[s+96>>2]|0;}while((s|0)!=0);p=c[k>>2]|0;q=p&-3;c[k>>2]=q;r=b+102996|0;g[r>>2]=0.0;i=h;return}function dW(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0;d=i;i=i+56|0;e=d|0;f=d+8|0;h=d+16|0;j=d+24|0;k=d+32|0;l=d+48|0;m=l;n=i;i=i+8|0;o=n;p=(c[b+52>>2]|0)+12|0;q=(c[b+48>>2]|0)+12|0;r=c[q+4>>2]|0;c[e>>2]=c[q>>2];c[e+4>>2]=r;r=p;p=c[r+4>>2]|0;c[f>>2]=c[r>>2];c[f+4>>2]=p;p=b;bp[c[c[p>>2]>>2]&511](h,b);bp[c[(c[p>>2]|0)+4>>2]&511](j,b);g[k>>2]=.5;g[k+4>>2]=.800000011920929;g[k+8>>2]=.800000011920929;p=c[b+4>>2]|0;if((p|0)==5){i=d;return}else if((p|0)==3){r=c[a+102984>>2]|0;bO[c[(c[r>>2]|0)+24>>2]&127](r,h,j,k);i=d;return}else if((p|0)==4){p=b+68|0;r=c[p+4>>2]|0;c[l>>2]=c[p>>2];c[l+4>>2]=r;r=b+76|0;b=c[r+4>>2]|0;c[n>>2]=c[r>>2];c[n+4>>2]=b;b=a+102984|0;n=c[b>>2]|0;bO[c[(c[n>>2]|0)+24>>2]&127](n,m,h,k);n=c[b>>2]|0;bO[c[(c[n>>2]|0)+24>>2]&127](n,o,j,k);n=c[b>>2]|0;bO[c[(c[n>>2]|0)+24>>2]&127](n,m,o,k);i=d;return}else{o=a+102984|0;a=c[o>>2]|0;bO[c[(c[a>>2]|0)+24>>2]&127](a,e,h,k);e=c[o>>2]|0;bO[c[(c[e>>2]|0)+24>>2]&127](e,h,j,k);h=c[o>>2]|0;bO[c[(c[h>>2]|0)+24>>2]&127](h,f,j,k);i=d;return}}function dX(a){a=a|0;var b=0,d=0.0,e=0,f=0,j=0,k=0,l=0,m=0;b=i;if((c[a+102868>>2]&2|0)!=0){i=b;return}d=+g[a+102972>>2];db(4360,(u=i,i=i+16|0,h[u>>3]=+g[a+102968>>2],h[u+8>>3]=d,u)|0);db(12864,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(12632,(u=i,i=i+8|0,c[u>>2]=c[a+102960>>2],u)|0);db(12040,(u=i,i=i+8|0,c[u>>2]=c[a+102964>>2],u)|0);e=c[a+102952>>2]|0;if((e|0)!=0){f=0;j=e;while(1){c[j+8>>2]=f;dn(j);e=c[j+96>>2]|0;if((e|0)==0){break}else{f=f+1|0;j=e}}}j=a+102956|0;a=c[j>>2]|0;do{if((a|0)!=0){f=0;e=a;while(1){c[e+56>>2]=f;k=c[e+12>>2]|0;if((k|0)==0){break}else{f=f+1|0;e=k}}e=c[j>>2]|0;if((e|0)==0){break}else{l=e}do{if((c[l+4>>2]|0)!=6){db(11584,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);bo[c[(c[l>>2]|0)+16>>2]&511](l);db(11328,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0)}l=c[l+12>>2]|0;}while((l|0)!=0);e=c[j>>2]|0;if((e|0)==0){break}else{m=e}do{if((c[m+4>>2]|0)==6){db(11584,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);bo[c[(c[m>>2]|0)+16>>2]&511](m);db(11328,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0)}m=c[m+12>>2]|0;}while((m|0)!=0)}}while(0);db(11128,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(10904,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(10712,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(10512,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);i=b;return}function dY(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0,y=0,z=0,A=0,B=0.0,C=0,D=0,E=0,F=0,G=0,H=0.0;f=i;i=i+40|0;h=f|0;j=f+8|0;k=f+16|0;l=f+24|0;m=f+32|0;n=m;o=i;i=i+8|0;p=o;q=i;i=i+64|0;r=c[b+12>>2]|0;b=c[r+4>>2]|0;if((b|0)==0){s=+g[d+12>>2];t=+g[r+12>>2];u=+g[d+8>>2];v=+g[r+16>>2];w=t*u+s*v+ +g[d+4>>2];g[h>>2]=+g[d>>2]+(s*t-u*v);g[h+4>>2]=w;w=+g[r+8>>2];g[j>>2]=s-u*0.0;g[j+4>>2]=u+s*0.0;x=c[a+102984>>2]|0;bn[c[(c[x>>2]|0)+20>>2]&63](x,h,w,j,e);i=f;return}else if((b|0)==3){j=c[r+16>>2]|0;h=c[r+12>>2]|0;x=d+12|0;w=+g[x>>2];s=+g[h>>2];y=d+8|0;u=+g[y>>2];v=+g[h+4>>2];z=d|0;t=+g[z>>2];A=d+4|0;B=+g[A>>2];g[m>>2]=t+(w*s-u*v);g[n+4>>2]=s*u+w*v+B;if((j|0)<=1){i=f;return}C=o;D=p+4|0;E=a+102984|0;F=1;v=w;w=u;u=t;t=B;while(1){B=+g[h+(F<<3)>>2];s=+g[h+(F<<3)+4>>2];g[C>>2]=u+(v*B-w*s);g[D>>2]=B*w+v*s+t;G=c[E>>2]|0;bO[c[(c[G>>2]|0)+24>>2]&127](G,n,p,e);G=c[E>>2]|0;br[c[(c[G>>2]|0)+16>>2]&63](G,n,.05000000074505806,e);G=c[o+4>>2]|0;c[m>>2]=c[o>>2];c[m+4>>2]=G;G=F+1|0;if((G|0)>=(j|0)){break}F=G;v=+g[x>>2];w=+g[y>>2];u=+g[z>>2];t=+g[A>>2]}i=f;return}else if((b|0)==2){A=c[r+148>>2]|0;if((A|0)>=9){ba(10624,1077,15360,4600)}z=q|0;if((A|0)>0){y=r+20|0;t=+g[d+12>>2];u=+g[d+8>>2];w=+g[d>>2];v=+g[d+4>>2];x=0;do{s=+g[y+(x<<3)>>2];B=+g[y+(x<<3)+4>>2];F=q+(x<<3)|0;H=+(s*u+t*B+v);g[F>>2]=w+(t*s-u*B);g[F+4>>2]=H;x=x+1|0;}while((x|0)<(A|0))}x=c[a+102984>>2]|0;bO[c[(c[x>>2]|0)+12>>2]&127](x,z,A,e);i=f;return}else if((b|0)==1){u=+g[d+12>>2];t=+g[r+12>>2];w=+g[d+8>>2];v=+g[r+16>>2];H=+g[d>>2];B=+g[d+4>>2];g[k>>2]=H+(u*t-w*v);g[k+4>>2]=t*w+u*v+B;d=r+20|0;v=+g[d>>2];t=+g[d+4>>2];g[l>>2]=H+(u*v-w*t);g[l+4>>2]=v*w+u*t+B;d=c[a+102984>>2]|0;bO[c[(c[d>>2]|0)+24>>2]&127](d,k,l,e);i=f;return}else{i=f;return}}function dZ(a){a=a|0;var d=0,e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0.0,S=0.0,T=0.0,U=0.0;d=i;i=i+144|0;e=d|0;f=d+16|0;h=d+32|0;j=d+48|0;k=d+64|0;l=d+80|0;m=d+96|0;n=d+128|0;o=n|0;p=n;q=a+102984|0;r=c[q>>2]|0;if((r|0)==0){i=d;return}s=c[r+4>>2]|0;do{if((s&1|0)!=0){r=c[a+102952>>2]|0;if((r|0)==0){break}t=e|0;u=e+4|0;v=e+8|0;w=j|0;x=j+4|0;y=j+8|0;z=k|0;A=k+4|0;B=k+8|0;C=f|0;D=f+4|0;E=f+8|0;F=h|0;G=h+4|0;H=h+8|0;I=r;do{r=I+12|0;J=c[I+100>>2]|0;if((J|0)!=0){K=I+4|0;L=I|0;M=J;do{J=b[K>>1]|0;do{if((J&32)==0){g[t>>2]=.5;g[u>>2]=.5;g[v>>2]=.30000001192092896;dY(a,M,r,e)}else{N=c[L>>2]|0;if((N|0)==1){g[F>>2]=.5;g[G>>2]=.5;g[H>>2]=.8999999761581421;dY(a,M,r,h);break}else if((N|0)==0){g[C>>2]=.5;g[D>>2]=.8999999761581421;g[E>>2]=.5;dY(a,M,r,f);break}else{if((J&2)==0){g[w>>2]=.6000000238418579;g[x>>2]=.6000000238418579;g[y>>2]=.6000000238418579;dY(a,M,r,j);break}else{g[z>>2]=.8999999761581421;g[A>>2]=.699999988079071;g[B>>2]=.699999988079071;dY(a,M,r,k);break}}}}while(0);M=c[M+4>>2]|0;}while((M|0)!=0)}I=c[I+96>>2]|0;}while((I|0)!=0)}}while(0);do{if((s&2|0)!=0){k=c[a+102956>>2]|0;if((k|0)==0){break}else{O=k}do{dW(a,O);O=c[O+12>>2]|0;}while((O|0)!=0)}}while(0);if((s&8|0)!=0){O=a+102932|0;while(1){k=c[O>>2]|0;if((k|0)==0){break}else{O=k+12|0}}}L2800:do{if((s&4|0)!=0){g[l>>2]=.8999999761581421;g[l+4>>2]=.30000001192092896;g[l+8>>2]=.8999999761581421;O=c[a+102952>>2]|0;if((O|0)==0){break}k=a+102884|0;j=a+102876|0;f=m|0;h=m|0;e=m+4|0;I=m+8|0;B=m+12|0;A=m+16|0;z=m+20|0;y=m+24|0;x=m+28|0;w=O;L2803:while(1){do{if((b[w+4>>1]&32)!=0){O=c[w+100>>2]|0;if((O|0)==0){break}else{P=O}do{O=P+28|0;if((c[O>>2]|0)>0){E=P+24|0;D=0;do{C=c[(c[E>>2]|0)+(D*28&-1)+24>>2]|0;if((C|0)<=-1){Q=2175;break L2803}if((c[k>>2]|0)<=(C|0)){Q=2176;break L2803}H=c[j>>2]|0;R=+g[H+(C*36&-1)>>2];S=+g[H+(C*36&-1)+4>>2];T=+g[H+(C*36&-1)+8>>2];U=+g[H+(C*36&-1)+12>>2];g[h>>2]=R;g[e>>2]=S;g[I>>2]=T;g[B>>2]=S;g[A>>2]=T;g[z>>2]=U;g[y>>2]=R;g[x>>2]=U;C=c[q>>2]|0;bO[c[(c[C>>2]|0)+8>>2]&127](C,f,4,l);D=D+1|0;}while((D|0)<(c[O>>2]|0))}P=c[P+4>>2]|0;}while((P|0)!=0)}}while(0);w=c[w+96>>2]|0;if((w|0)==0){break L2800}}if((Q|0)==2175){ba(10360,159,14456,9904)}else if((Q|0)==2176){ba(10360,159,14456,9904)}}}while(0);if((s&16|0)==0){i=d;return}s=c[a+102952>>2]|0;if((s|0)==0){i=d;return}a=n;n=s;do{s=n+12|0;c[a>>2]=c[s>>2];c[a+4>>2]=c[s+4>>2];c[a+8>>2]=c[s+8>>2];c[a+12>>2]=c[s+12>>2];s=n+44|0;Q=c[s+4>>2]|0;c[o>>2]=c[s>>2];c[o+4>>2]=Q;Q=c[q>>2]|0;bp[c[(c[Q>>2]|0)+28>>2]&511](Q,p);n=c[n+96>>2]|0;}while((n|0)!=0);i=d;return}function d_(a){a=a|0;return}function d$(a){a=a|0;return}function d0(a,c,d){a=a|0;c=c|0;d=d|0;var e=0;a=b[c+36>>1]|0;if(!(a<<16>>16!=(b[d+36>>1]|0)|a<<16>>16==0)){e=a<<16>>16>0;return e|0}if((b[d+32>>1]&b[c+34>>1])<<16>>16==0){e=0;return e|0}e=(b[d+34>>1]&b[c+32>>1])<<16>>16!=0;return e|0}function d1(a){a=a|0;vl(a);return}function d2(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0;f=i;i=i+48|0;h=f|0;j=c[(c[a+48>>2]|0)+12>>2]|0;c[h>>2]=20512;c[h+4>>2]=1;g[h+8>>2]=.009999999776482582;vq(h+28|0,0,18);cX(j,h,c[a+56>>2]|0);b6(b,h,d,c[(c[a+52>>2]|0)+12>>2]|0,e);i=f;return}function d3(a){a=a|0;vl(a);return}function d4(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0;f=i;i=i+304|0;h=f+256|0;j=c[(c[a+48>>2]|0)+12>>2]|0;c[h>>2]=20512;c[h+4>>2]=1;g[h+8>>2]=.009999999776482582;vq(h+28|0,0,18);cX(j,h,c[a+56>>2]|0);b7(f|0,b,h,d,c[(c[a+52>>2]|0)+12>>2]|0,e);i=f;return}function d5(a){a=a|0;vl(a);return}function d6(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,j=0,k=0.0,l=0.0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0,K=0,L=0,M=0,N=0.0,O=0.0,Q=0.0,R=0.0,S=0.0,T=0,U=0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ab=0.0,ac=0,ad=0.0,ae=0.0,af=0,ag=0,ah=0,ai=0,aj=0;e=i;i=i+1064|0;f=e|0;h=e+1040|0;j=d;k=+g[j>>2];l=+g[j+4>>2];m=d+8|0;n=+g[m>>2]-k;o=+g[m+4>>2]-l;p=n*n+o*o;if(p<=0.0){ba(10360,204,14104,10168)}q=+P(+p);if(q<1.1920928955078125e-7){r=n;s=o}else{p=1.0/q;r=n*p;s=o*p}p=s*-1.0;if(p>0.0){t=p}else{t=-0.0-p}if(r>0.0){u=r}else{u=-0.0-r}s=+g[d+16>>2];q=k+n*s;v=l+o*s;d=f+4|0;w=f|0;c[w>>2]=d;x=f+1028|0;c[x>>2]=0;y=f+1032|0;c[y>>2]=256;c[(c[w>>2]|0)+(c[x>>2]<<2)>>2]=c[a>>2];f=(c[x>>2]|0)+1|0;c[x>>2]=f;L2859:do{if((f|0)>0){z=a+4|0;A=h;B=h+8|0;C=h+16|0;D=f;E=lv?l:v;H=k>q?k:q;I=s;while(1){J=D;while(1){K=J-1|0;c[x>>2]=K;L=c[w>>2]|0;M=c[L+(K<<2)>>2]|0;if((M|0)==-1){N=I;O=H;Q=G;R=F;S=E;T=K;break}U=c[z>>2]|0;V=+g[U+(M*36&-1)+8>>2];W=+g[U+(M*36&-1)+12>>2];X=+g[U+(M*36&-1)>>2];Y=+g[U+(M*36&-1)+4>>2];if(F-V>0.0|E-W>0.0|X-H>0.0|Y-G>0.0){Z=I;_=H;$=G;aa=F;ab=E;ac=2206;break}ad=p*(k-(V+X)*.5)+r*(l-(W+Y)*.5);if(ad>0.0){ae=ad}else{ae=-0.0-ad}if(ae-(t*(V-X)*.5+u*(W-Y)*.5)>0.0){Z=I;_=H;$=G;aa=F;ab=E;ac=2206;break}af=U+(M*36&-1)+24|0;if((c[af>>2]|0)==-1){ac=2217;break}do{if((K|0)==(c[y>>2]|0)){c[y>>2]=K<<1;ag=vh(K<<3)|0;c[w>>2]=ag;ah=L;ai=c[x>>2]<<2;vp(ag|0,ah|0,ai)|0;if((L|0)==(d|0)){break}vi(ah)}}while(0);c[(c[w>>2]|0)+(c[x>>2]<<2)>>2]=c[af>>2];L=(c[x>>2]|0)+1|0;c[x>>2]=L;K=U+(M*36&-1)+28|0;do{if((L|0)==(c[y>>2]|0)){ah=c[w>>2]|0;c[y>>2]=L<<1;ai=vh(L<<3)|0;c[w>>2]=ai;ag=ah;aj=c[x>>2]<<2;vp(ai|0,ag|0,aj)|0;if((ah|0)==(d|0)){break}vi(ag)}}while(0);c[(c[w>>2]|0)+(c[x>>2]<<2)>>2]=c[K>>2];J=(c[x>>2]|0)+1|0;c[x>>2]=J;if((J|0)<=0){break L2859}}do{if((ac|0)==2217){ac=0;J=c[j+4>>2]|0;c[A>>2]=c[j>>2];c[A+4>>2]=J;J=c[m+4>>2]|0;c[B>>2]=c[m>>2];c[B+4>>2]=J;g[C>>2]=I;Y=+d7(b,h,M);if(Y==0.0){break L2859}if(Y<=0.0){Z=I;_=H;$=G;aa=F;ab=E;ac=2206;break}W=k+n*Y;X=l+o*Y;Z=Y;_=k>W?k:W;$=l>X?l:X;aa=k>2]|0}if((T|0)>0){D=T;E=S;F=R;G=Q;H=O;I=N}else{break}}}}while(0);T=c[w>>2]|0;if((T|0)==(d|0)){i=e;return}vi(T);c[w>>2]=0;i=e;return}function d7(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,j=0,k=0,l=0.0,m=0.0,n=0.0,o=0.0;e=i;i=i+24|0;f=e|0;h=e+16|0;j=c[a>>2]|0;if((d|0)<=-1){ba(10360,153,14408,9904);return 0.0}if((c[j+12>>2]|0)<=(d|0)){ba(10360,153,14408,9904);return 0.0}k=c[(c[j+4>>2]|0)+(d*36&-1)+16>>2]|0;d=c[k+16>>2]|0;j=c[d+12>>2]|0;if(bI[c[(c[j>>2]|0)+20>>2]&127](j,f,b,(c[d+8>>2]|0)+12|0,c[k+20>>2]|0)|0){l=+g[f+8>>2];m=1.0-l;n=m*+g[b+4>>2]+l*+g[b+12>>2];g[h>>2]=+g[b>>2]*m+l*+g[b+8>>2];g[h+4>>2]=n;k=c[a+4>>2]|0;o=+bG[c[(c[k>>2]|0)+8>>2]&63](k,d,h,f|0,l);i=e;return+o}else{o=+g[b+16>>2];i=e;return+o}return 0.0}function d8(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0;e=i;i=i+1040|0;f=e|0;h=f+4|0;j=f|0;c[j>>2]=h;k=f+1028|0;c[k>>2]=0;l=f+1032|0;c[l>>2]=256;c[(c[j>>2]|0)+(c[k>>2]<<2)>>2]=c[a>>2];f=(c[k>>2]|0)+1|0;c[k>>2]=f;L2906:do{if((f|0)>0){m=a+4|0;n=d|0;o=d+4|0;p=d+8|0;q=d+12|0;r=b|0;s=b+4|0;t=f;L2908:while(1){u=t-1|0;c[k>>2]=u;v=c[j>>2]|0;w=c[v+(u<<2)>>2]|0;do{if((w|0)==-1){x=u}else{y=c[m>>2]|0;if(+g[n>>2]- +g[y+(w*36&-1)+8>>2]>0.0|+g[o>>2]- +g[y+(w*36&-1)+12>>2]>0.0|+g[y+(w*36&-1)>>2]- +g[p>>2]>0.0|+g[y+(w*36&-1)+4>>2]- +g[q>>2]>0.0){x=u;break}z=y+(w*36&-1)+24|0;if((c[z>>2]|0)==-1){A=c[r>>2]|0;if((w|0)<=-1){break L2908}if((c[A+12>>2]|0)<=(w|0)){break L2908}B=c[s>>2]|0;if(!(bF[c[(c[B>>2]|0)+8>>2]&255](B,c[(c[(c[A+4>>2]|0)+(w*36&-1)+16>>2]|0)+16>>2]|0)|0)){break L2906}x=c[k>>2]|0;break}do{if((u|0)==(c[l>>2]|0)){c[l>>2]=u<<1;A=vh(u<<3)|0;c[j>>2]=A;B=v;C=c[k>>2]<<2;vp(A|0,B|0,C)|0;if((v|0)==(h|0)){break}vi(B)}}while(0);c[(c[j>>2]|0)+(c[k>>2]<<2)>>2]=c[z>>2];B=(c[k>>2]|0)+1|0;c[k>>2]=B;C=y+(w*36&-1)+28|0;do{if((B|0)==(c[l>>2]|0)){A=c[j>>2]|0;c[l>>2]=B<<1;D=vh(B<<3)|0;c[j>>2]=D;E=A;F=c[k>>2]<<2;vp(D|0,E|0,F)|0;if((A|0)==(h|0)){break}vi(E)}}while(0);c[(c[j>>2]|0)+(c[k>>2]<<2)>>2]=c[C>>2];B=(c[k>>2]|0)+1|0;c[k>>2]=B;x=B}}while(0);if((x|0)>0){t=x}else{break L2906}}ba(10360,153,14408,9904)}}while(0);x=c[j>>2]|0;if((x|0)==(h|0)){i=e;return}vi(x);c[j>>2]=0;i=e;return}function d9(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0,j=0,k=0.0,l=0.0;h=df(f,144)|0;if((h|0)==0){i=0;j=i|0;return j|0}f=h;c[f>>2]=19280;c[h+4>>2]=4;c[h+48>>2]=a;c[h+52>>2]=d;c[h+56>>2]=b;c[h+60>>2]=e;c[h+124>>2]=0;c[h+128>>2]=0;vq(h+8|0,0,40);g[h+136>>2]=+P(+(+g[a+16>>2]*+g[d+16>>2]));k=+g[a+20>>2];l=+g[d+20>>2];g[h+140>>2]=k>l?k:l;c[f>>2]=19512;if((c[(c[a+12>>2]|0)+4>>2]|0)!=3){ba(10096,43,16664,12232);return 0}if((c[(c[d+12>>2]|0)+4>>2]|0)==0){i=h;j=i|0;return j|0}else{ba(10096,44,16664,9416);return 0}return 0}function ea(b,d){b=b|0;d=d|0;var e=0,f=0;bo[c[(c[b>>2]|0)+4>>2]&511](b);e=a[22208]|0;if((e&255)<14){f=d+12+((e&255)<<2)|0;c[b>>2]=c[f>>2];c[f>>2]=b;return}else{ba(5352,173,17448,6544)}}function eb(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0,j=0,k=0.0,l=0.0;h=df(f,144)|0;if((h|0)==0){i=0;j=i|0;return j|0}f=h;c[f>>2]=19280;c[h+4>>2]=4;c[h+48>>2]=a;c[h+52>>2]=d;c[h+56>>2]=b;c[h+60>>2]=e;c[h+124>>2]=0;c[h+128>>2]=0;vq(h+8|0,0,40);g[h+136>>2]=+P(+(+g[a+16>>2]*+g[d+16>>2]));k=+g[a+20>>2];l=+g[d+20>>2];g[h+140>>2]=k>l?k:l;c[f>>2]=19448;if((c[(c[a+12>>2]|0)+4>>2]|0)!=3){ba(9952,43,16488,12232);return 0}if((c[(c[d+12>>2]|0)+4>>2]|0)==2){i=h;j=i|0;return j|0}else{ba(9952,44,16488,9368);return 0}return 0}function ec(b,d){b=b|0;d=d|0;var e=0,f=0;bo[c[(c[b>>2]|0)+4>>2]&511](b);e=a[22208]|0;if((e&255)<14){f=d+12+((e&255)<<2)|0;c[b>>2]=c[f>>2];c[f>>2]=b;return}else{ba(5352,173,17448,6544)}}function ed(a){a=a|0;return}function ee(a){a=a|0;return}function ef(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,i=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0;f=c[(c[a+48>>2]|0)+12>>2]|0;h=c[(c[a+52>>2]|0)+12>>2]|0;a=b+60|0;c[a>>2]=0;i=f+12|0;j=+g[d+12>>2];k=+g[i>>2];l=+g[d+8>>2];m=+g[f+16>>2];n=h+12|0;o=+g[e+12>>2];p=+g[n>>2];q=+g[e+8>>2];r=+g[h+16>>2];s=+g[e>>2]+(o*p-q*r)-(+g[d>>2]+(j*k-l*m));t=p*q+o*r+ +g[e+4>>2]-(k*l+j*m+ +g[d+4>>2]);m=+g[f+8>>2]+ +g[h+8>>2];if(s*s+t*t>m*m){return}c[b+56>>2]=0;h=i;i=b+48|0;f=c[h+4>>2]|0;c[i>>2]=c[h>>2];c[i+4>>2]=f;g[b+40>>2]=0.0;g[b+44>>2]=0.0;c[a>>2]=1;a=n;n=b;f=c[a+4>>2]|0;c[n>>2]=c[a>>2];c[n+4>>2]=f;c[b+16>>2]=0;return}function eg(a){a=a|0;vl(a);return}function eh(d,e){d=d|0;e=e|0;var f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0;f=i;i=i+200|0;h=f|0;j=f+96|0;k=f+112|0;l=f+136|0;m=d+64|0;n=l;o=m;vp(n|0,o|0,64)|0;o=d+4|0;n=c[o>>2]|0;c[o>>2]=n|4;p=n>>>1;n=c[d+48>>2]|0;q=c[d+52>>2]|0;r=((a[q+38|0]|a[n+38|0])&1)!=0;s=c[n+8>>2]|0;t=c[q+8>>2]|0;u=s+12|0;v=t+12|0;do{if(r){w=c[n+12>>2]|0;x=c[q+12>>2]|0;y=c[d+56>>2]|0;z=c[d+60>>2]|0;c[h+16>>2]=0;c[h+20>>2]=0;g[h+24>>2]=0.0;c[h+44>>2]=0;c[h+48>>2]=0;g[h+52>>2]=0.0;cf(h|0,w,y);cf(h+28|0,x,z);z=h+56|0;x=u;c[z>>2]=c[x>>2];c[z+4>>2]=c[x+4>>2];c[z+8>>2]=c[x+8>>2];c[z+12>>2]=c[x+12>>2];x=h+72|0;z=v;c[x>>2]=c[z>>2];c[x+4>>2]=c[z+4>>2];c[x+8>>2]=c[z+8>>2];c[x+12>>2]=c[z+12>>2];a[h+88|0]=1;b[j+4>>1]=0;cg(k,j,h);z=+g[k+16>>2]<11920928955078125.0e-22;c[d+124>>2]=0;A=z;B=p&1}else{bO[c[c[d>>2]>>2]&127](d,m,u,v);z=d+124|0;x=(c[z>>2]|0)>0;if(x){y=c[l+60>>2]|0;w=0;do{C=d+64+(w*20&-1)+8|0;g[C>>2]=0.0;D=d+64+(w*20&-1)+12|0;g[D>>2]=0.0;E=c[d+64+(w*20&-1)+16>>2]|0;F=0;while(1){if((F|0)>=(y|0)){break}if((c[l+(F*20&-1)+16>>2]|0)==(E|0)){G=2312;break}else{F=F+1|0}}if((G|0)==2312){G=0;g[C>>2]=+g[l+(F*20&-1)+8>>2];g[D>>2]=+g[l+(F*20&-1)+12>>2]}w=w+1|0;}while((w|0)<(c[z>>2]|0))}z=p&1;if(!(x^(z|0)!=0)){A=x;B=z;break}w=s+4|0;y=b[w>>1]|0;if((y&2)==0){b[w>>1]=y|2;g[s+144>>2]=0.0}y=t+4|0;w=b[y>>1]|0;if((w&2)!=0){A=x;B=z;break}b[y>>1]=w|2;g[t+144>>2]=0.0;A=x;B=z}}while(0);t=c[o>>2]|0;c[o>>2]=A?t|2:t&-3;t=(B|0)==0;B=A^1;o=(e|0)==0;if(!(t^1|B|o)){bp[c[(c[e>>2]|0)+8>>2]&511](e,d)}if(!(t|A|o)){bp[c[(c[e>>2]|0)+12>>2]&511](e,d)}if(r|B|o){i=f;return}bL[c[(c[e>>2]|0)+16>>2]&127](e,d,l);i=f;return}function ei(a){a=a|0;vl(a);return}function ej(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0,j=0.0,k=0.0;e=df(f,144)|0;if((e|0)==0){h=0;i=h|0;return i|0}f=e;c[f>>2]=19280;c[e+4>>2]=4;c[e+48>>2]=a;c[e+52>>2]=d;c[e+56>>2]=0;c[e+60>>2]=0;c[e+124>>2]=0;c[e+128>>2]=0;vq(e+8|0,0,40);g[e+136>>2]=+P(+(+g[a+16>>2]*+g[d+16>>2]));j=+g[a+20>>2];k=+g[d+20>>2];g[e+140>>2]=j>k?j:k;c[f>>2]=2e4;if((c[(c[a+12>>2]|0)+4>>2]|0)!=0){ba(9808,44,17872,12152);return 0}if((c[(c[d+12>>2]|0)+4>>2]|0)==0){h=e;i=h|0;return i|0}else{ba(9808,45,17872,9416);return 0}return 0}function ek(b,d){b=b|0;d=d|0;var e=0,f=0;bo[c[(c[b>>2]|0)+4>>2]&511](b);e=a[22208]|0;if((e&255)<14){f=d+12+((e&255)<<2)|0;c[b>>2]=c[f>>2];c[f>>2]=b;return}else{ba(5352,173,17448,6544)}}function el(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0;if((a[21856]&1)==0){c[5466]=62;c[5467]=140;a[21872]=1;c[5490]=54;c[5491]=386;a[21968]=1;c[5472]=54;c[5473]=386;a[21896]=0;c[5496]=70;c[5497]=296;a[21992]=1;c[5478]=60;c[5479]=106;a[21920]=1;c[5469]=60;c[5470]=106;a[21884]=0;c[5484]=64;c[5485]=228;a[21944]=1;c[5493]=64;c[5494]=228;a[21980]=0;c[5502]=52;c[5503]=278;a[22016]=1;c[5475]=52;c[5476]=278;a[21908]=0;c[5508]=72;c[5509]=160;a[22040]=1;c[5499]=72;c[5500]=160;a[22004]=0;a[21856]=1}h=c[(c[b+12>>2]|0)+4>>2]|0;i=c[(c[e+12>>2]|0)+4>>2]|0;if(h>>>0>=4){ba(9712,80,15104,12104);return 0}if(i>>>0>=4){ba(9712,81,15104,9496);return 0}j=c[21864+(h*48&-1)+(i*12&-1)>>2]|0;if((j|0)==0){k=0;return k|0}if((a[21864+(h*48&-1)+(i*12&-1)+8|0]&1)==0){k=bI[j&127](e,f,b,d,g)|0;return k|0}else{k=bI[j&127](b,d,e,f,g)|0;return k|0}return 0}function em(d,e){d=d|0;e=e|0;var f=0,h=0,i=0,j=0,k=0,l=0;if((a[21856]&1)==0){ba(9712,103,15040,7184)}f=d+48|0;do{if((c[d+124>>2]|0)>0){h=c[(c[f>>2]|0)+8>>2]|0;i=h+4|0;j=b[i>>1]|0;if((j&2)==0){b[i>>1]=j|2;g[h+144>>2]=0.0}h=d+52|0;j=c[(c[h>>2]|0)+8>>2]|0;i=j+4|0;k=b[i>>1]|0;if((k&2)!=0){l=h;break}b[i>>1]=k|2;g[j+144>>2]=0.0;l=h}else{l=d+52|0}}while(0);h=c[(c[(c[f>>2]|0)+12>>2]|0)+4>>2]|0;f=c[(c[(c[l>>2]|0)+12>>2]|0)+4>>2]|0;if((h|0)>-1&(f|0)<4){bp[c[21864+(h*48&-1)+(f*12&-1)+4>>2]&511](d,e);return}else{ba(9712,114,15040,6160)}}function en(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0,v=0,w=0,x=0,y=0,z=0;e=b;f=d;c[e>>2]=c[f>>2];c[e+4>>2]=c[f+4>>2];c[e+8>>2]=c[f+8>>2];c[e+12>>2]=c[f+12>>2];c[e+16>>2]=c[f+16>>2];c[e+20>>2]=c[f+20>>2];f=c[d+40>>2]|0;e=b+32|0;c[e>>2]=f;h=c[d+28>>2]|0;i=b+48|0;c[i>>2]=h;j=h*88&-1;h=f+102796|0;k=c[h>>2]|0;if((k|0)>=32){ba(4840,38,17040,6448)}l=f+102412+(k*12&-1)|0;c[f+102412+(k*12&-1)+4>>2]=j;m=f+102400|0;n=c[m>>2]|0;if((n+j|0)>102400){c[l>>2]=vh(j)|0;a[f+102412+(k*12&-1)+8|0]=1}else{c[l>>2]=f+n;a[f+102412+(k*12&-1)+8|0]=0;c[m>>2]=(c[m>>2]|0)+j}m=f+102404|0;k=(c[m>>2]|0)+j|0;c[m>>2]=k;m=f+102408|0;f=c[m>>2]|0;c[m>>2]=(f|0)>(k|0)?f:k;c[h>>2]=(c[h>>2]|0)+1;h=b+36|0;c[h>>2]=c[l>>2];l=c[e>>2]|0;e=(c[i>>2]|0)*152&-1;k=l+102796|0;f=c[k>>2]|0;if((f|0)>=32){ba(4840,38,17040,6448)}m=l+102412+(f*12&-1)|0;c[l+102412+(f*12&-1)+4>>2]=e;j=l+102400|0;n=c[j>>2]|0;if((n+e|0)>102400){c[m>>2]=vh(e)|0;a[l+102412+(f*12&-1)+8|0]=1}else{c[m>>2]=l+n;a[l+102412+(f*12&-1)+8|0]=0;c[j>>2]=(c[j>>2]|0)+e}j=l+102404|0;f=(c[j>>2]|0)+e|0;c[j>>2]=f;j=l+102408|0;l=c[j>>2]|0;c[j>>2]=(l|0)>(f|0)?l:f;c[k>>2]=(c[k>>2]|0)+1;k=b+40|0;c[k>>2]=c[m>>2];c[b+24>>2]=c[d+32>>2];c[b+28>>2]=c[d+36>>2];m=c[d+24>>2]|0;d=b+44|0;c[d>>2]=m;if((c[i>>2]|0)<=0){return}f=b+20|0;l=b+8|0;b=0;j=m;while(1){m=c[j+(b<<2)>>2]|0;e=c[m+48>>2]|0;n=c[m+52>>2]|0;o=c[e+8>>2]|0;p=c[n+8>>2]|0;q=c[m+124>>2]|0;if((q|0)<=0){r=2378;break}s=+g[(c[n+12>>2]|0)+8>>2];t=+g[(c[e+12>>2]|0)+8>>2];e=c[k>>2]|0;g[e+(b*152&-1)+136>>2]=+g[m+136>>2];g[e+(b*152&-1)+140>>2]=+g[m+140>>2];n=o+8|0;c[e+(b*152&-1)+112>>2]=c[n>>2];u=p+8|0;c[e+(b*152&-1)+116>>2]=c[u>>2];v=o+120|0;g[e+(b*152&-1)+120>>2]=+g[v>>2];w=p+120|0;g[e+(b*152&-1)+124>>2]=+g[w>>2];x=o+128|0;g[e+(b*152&-1)+128>>2]=+g[x>>2];y=p+128|0;g[e+(b*152&-1)+132>>2]=+g[y>>2];c[e+(b*152&-1)+148>>2]=b;c[e+(b*152&-1)+144>>2]=q;vq(e+(b*152&-1)+80|0,0,32);z=c[h>>2]|0;c[z+(b*88&-1)+32>>2]=c[n>>2];c[z+(b*88&-1)+36>>2]=c[u>>2];g[z+(b*88&-1)+40>>2]=+g[v>>2];g[z+(b*88&-1)+44>>2]=+g[w>>2];w=o+28|0;o=z+(b*88&-1)+48|0;v=c[w+4>>2]|0;c[o>>2]=c[w>>2];c[o+4>>2]=v;v=p+28|0;p=z+(b*88&-1)+56|0;o=c[v+4>>2]|0;c[p>>2]=c[v>>2];c[p+4>>2]=o;g[z+(b*88&-1)+64>>2]=+g[x>>2];g[z+(b*88&-1)+68>>2]=+g[y>>2];y=m+104|0;x=z+(b*88&-1)+16|0;o=c[y+4>>2]|0;c[x>>2]=c[y>>2];c[x+4>>2]=o;o=m+112|0;x=z+(b*88&-1)+24|0;y=c[o+4>>2]|0;c[x>>2]=c[o>>2];c[x+4>>2]=y;c[z+(b*88&-1)+84>>2]=q;g[z+(b*88&-1)+76>>2]=t;g[z+(b*88&-1)+80>>2]=s;c[z+(b*88&-1)+72>>2]=c[m+120>>2];y=0;do{if((a[f]&1)==0){g[e+(b*152&-1)+(y*36&-1)+16>>2]=0.0;g[e+(b*152&-1)+(y*36&-1)+20>>2]=0.0}else{g[e+(b*152&-1)+(y*36&-1)+16>>2]=+g[l>>2]*+g[m+64+(y*20&-1)+8>>2];g[e+(b*152&-1)+(y*36&-1)+20>>2]=+g[l>>2]*+g[m+64+(y*20&-1)+12>>2]}g[e+(b*152&-1)+(y*36&-1)+24>>2]=0.0;g[e+(b*152&-1)+(y*36&-1)+28>>2]=0.0;g[e+(b*152&-1)+(y*36&-1)+32>>2]=0.0;x=m+64+(y*20&-1)|0;o=z+(b*88&-1)+(y<<3)|0;vq(e+(b*152&-1)+(y*36&-1)|0,0,16);p=c[x+4>>2]|0;c[o>>2]=c[x>>2];c[o+4>>2]=p;y=y+1|0;}while((y|0)<(q|0));q=b+1|0;if((q|0)>=(c[i>>2]|0)){r=2387;break}b=q;j=c[d>>2]|0}if((r|0)==2387){return}else if((r|0)==2378){ba(9232,71,17704,12024)}}function eo(a){a=a|0;var b=0,d=0,e=0,f=0,h=0,i=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0,o=0,p=0,q=0.0,r=0.0,s=0.0,t=0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0.0,R=0.0,S=0.0;b=a+48|0;if((c[b>>2]|0)<=0){return}d=a+40|0;e=a+28|0;a=0;do{f=c[d>>2]|0;h=c[f+(a*152&-1)+112>>2]|0;i=c[f+(a*152&-1)+116>>2]|0;j=+g[f+(a*152&-1)+120>>2];k=+g[f+(a*152&-1)+128>>2];l=+g[f+(a*152&-1)+124>>2];m=+g[f+(a*152&-1)+132>>2];n=c[f+(a*152&-1)+144>>2]|0;o=c[e>>2]|0;p=o+(h*12&-1)|0;q=+g[p>>2];r=+g[p+4>>2];s=+g[o+(h*12&-1)+8>>2];t=o+(i*12&-1)|0;u=+g[t>>2];v=+g[t+4>>2];w=+g[o+(i*12&-1)+8>>2];o=f+(a*152&-1)+72|0;x=+g[o>>2];y=+g[o+4>>2];z=x*-1.0;if((n|0)>0){A=r;B=q;C=v;D=u;E=s;F=w;o=0;while(1){G=+g[f+(a*152&-1)+(o*36&-1)+16>>2];H=+g[f+(a*152&-1)+(o*36&-1)+20>>2];I=x*G+y*H;J=y*G+z*H;H=E-k*(+g[f+(a*152&-1)+(o*36&-1)>>2]*J- +g[f+(a*152&-1)+(o*36&-1)+4>>2]*I);G=B-j*I;K=A-j*J;L=F+m*(J*+g[f+(a*152&-1)+(o*36&-1)+8>>2]-I*+g[f+(a*152&-1)+(o*36&-1)+12>>2]);M=D+l*I;I=C+l*J;t=o+1|0;if((t|0)<(n|0)){A=K;B=G;C=I;D=M;E=H;F=L;o=t}else{N=K;O=G;P=I;Q=M;R=H;S=L;break}}}else{N=r;O=q;P=v;Q=u;R=s;S=w}F=+N;g[p>>2]=O;g[p+4>>2]=F;g[(c[e>>2]|0)+(h*12&-1)+8>>2]=R;o=(c[e>>2]|0)+(i*12&-1)|0;F=+P;g[o>>2]=Q;g[o+4>>2]=F;g[(c[e>>2]|0)+(i*12&-1)+8>>2]=S;a=a+1|0;}while((a|0)<(c[b>>2]|0));return} +function ep(a){a=a|0;var b=0,d=0,e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0.0,C=0.0,D=0.0,E=0.0,F=0,G=0.0,H=0.0,I=0.0,J=0.0,K=0,L=0.0,M=0.0,N=0.0,O=0,P=0.0,Q=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0,$=0.0,aa=0.0,ab=0.0,ac=0.0,ad=0.0,ae=0,af=0.0,ag=0.0,ah=0.0;b=i;i=i+16|0;d=b|0;e=d|0;f=d;h=i;i=i+16|0;j=h|0;k=h;l=i;i=i+24|0;m=l|0;n=l;o=a+48|0;if((c[o>>2]|0)<=0){i=b;return}p=a+40|0;q=a+36|0;r=a+44|0;s=a+24|0;t=a+28|0;a=d+8|0;d=a;u=a+4|0;a=h+8|0;h=a;v=a+4|0;a=l+8|0;l=0;while(1){w=c[p>>2]|0;x=c[q>>2]|0;y=c[(c[r>>2]|0)+(c[w+(l*152&-1)+148>>2]<<2)>>2]|0;z=c[w+(l*152&-1)+112>>2]|0;A=c[w+(l*152&-1)+116>>2]|0;B=+g[w+(l*152&-1)+120>>2];C=+g[w+(l*152&-1)+124>>2];D=+g[w+(l*152&-1)+128>>2];E=+g[w+(l*152&-1)+132>>2];F=x+(l*88&-1)+48|0;G=+g[F>>2];H=+g[F+4>>2];F=x+(l*88&-1)+56|0;I=+g[F>>2];J=+g[F+4>>2];F=c[s>>2]|0;K=F+(z*12&-1)|0;L=+g[K>>2];M=+g[K+4>>2];N=+g[F+(z*12&-1)+8>>2];K=c[t>>2]|0;O=K+(z*12&-1)|0;P=+g[O>>2];Q=+g[O+4>>2];T=+g[K+(z*12&-1)+8>>2];z=F+(A*12&-1)|0;U=+g[z>>2];V=+g[z+4>>2];W=+g[F+(A*12&-1)+8>>2];F=K+(A*12&-1)|0;X=+g[F>>2];Y=+g[F+4>>2];Z=+g[K+(A*12&-1)+8>>2];if((c[y+124>>2]|0)<=0){_=2400;break}$=+g[x+(l*88&-1)+80>>2];aa=+g[x+(l*88&-1)+76>>2];ab=+S(+N);g[d>>2]=ab;ac=+R(+N);g[u>>2]=ac;N=+S(+W);g[h>>2]=N;ad=+R(+W);g[v>>2]=ad;W=+(M-(H*ac+G*ab));g[e>>2]=L-(G*ac-H*ab);g[e+4>>2]=W;W=+(V-(J*ad+I*N));g[j>>2]=U-(I*ad-J*N);g[j+4>>2]=W;cd(n,y+64|0,f,aa,k,$);y=w+(l*152&-1)+72|0;x=y;A=c[m+4>>2]|0;c[x>>2]=c[m>>2];c[x+4>>2]=A;A=w+(l*152&-1)+144|0;x=c[A>>2]|0;do{if((x|0)>0){K=w+(l*152&-1)+76|0;F=y|0;$=B+C;aa=-0.0-Z;W=-0.0-T;z=w+(l*152&-1)+140|0;O=0;do{N=+g[a+(O<<3)>>2];J=N-L;ad=+g[a+(O<<3)+4>>2];ae=w+(l*152&-1)+(O*36&-1)|0;I=+(ad-M);g[ae>>2]=J;g[ae+4>>2]=I;I=N-U;ae=w+(l*152&-1)+(O*36&-1)+8|0;N=+(ad-V);g[ae>>2]=I;g[ae+4>>2]=N;N=+g[K>>2];ad=+g[w+(l*152&-1)+(O*36&-1)+4>>2];ab=+g[F>>2];H=J*N-ad*ab;ac=+g[w+(l*152&-1)+(O*36&-1)+12>>2];G=N*I-ab*ac;ab=$+H*D*H+G*E*G;if(ab>0.0){af=1.0/ab}else{af=0.0}g[w+(l*152&-1)+(O*36&-1)+24>>2]=af;ab=+g[K>>2];G=+g[F>>2]*-1.0;H=J*G-ab*ad;N=G*I-ab*ac;ab=$+H*D*H+N*E*N;if(ab>0.0){ag=1.0/ab}else{ag=0.0}g[w+(l*152&-1)+(O*36&-1)+28>>2]=ag;ae=w+(l*152&-1)+(O*36&-1)+32|0;g[ae>>2]=0.0;ab=+g[F>>2]*(X+ac*aa-P-ad*W)+ +g[K>>2]*(Y+Z*I-Q-T*J);if(ab<-1.0){g[ae>>2]=ab*(-0.0- +g[z>>2])}O=O+1|0;}while((O|0)<(x|0));if((c[A>>2]|0)!=2){break}W=+g[w+(l*152&-1)+76>>2];aa=+g[y>>2];$=+g[w+(l*152&-1)>>2]*W- +g[w+(l*152&-1)+4>>2]*aa;ab=W*+g[w+(l*152&-1)+8>>2]-aa*+g[w+(l*152&-1)+12>>2];J=W*+g[w+(l*152&-1)+36>>2]-aa*+g[w+(l*152&-1)+40>>2];I=W*+g[w+(l*152&-1)+44>>2]-aa*+g[w+(l*152&-1)+48>>2];aa=B+C;W=D*$;ad=E*ab;ac=aa+$*W+ab*ad;ab=aa+J*D*J+I*E*I;$=aa+W*J+ad*I;I=ac*ab-$*$;if(ac*ac>=I*1.0e3){c[A>>2]=1;break}g[w+(l*152&-1)+96>>2]=ac;g[w+(l*152&-1)+100>>2]=$;g[w+(l*152&-1)+104>>2]=$;g[w+(l*152&-1)+108>>2]=ab;if(I!=0.0){ah=1.0/I}else{ah=I}I=$*(-0.0-ah);g[w+(l*152&-1)+80>>2]=ab*ah;g[w+(l*152&-1)+84>>2]=I;g[w+(l*152&-1)+88>>2]=I;g[w+(l*152&-1)+92>>2]=ac*ah}}while(0);w=l+1|0;if((w|0)<(c[o>>2]|0)){l=w}else{_=2418;break}}if((_|0)==2418){i=b;return}else if((_|0)==2400){ba(9232,168,17760,9464)}}function eq(a){a=a|0;var b=0,d=0,e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0.0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0.0,x=0,y=0,z=0,A=0,B=0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ab=0.0,ac=0.0,ad=0.0,ae=0.0,af=0.0,ag=0.0,ah=0.0,ai=0.0,aj=0.0,ak=0.0,al=0.0,am=0.0,an=0.0,ao=0.0,ap=0.0,aq=0.0,ar=0;b=i;i=i+16|0;d=b|0;e=d|0;f=d;h=i;i=i+16|0;j=h|0;k=h;l=i;i=i+20|0;i=i+7>>3<<3;m=a+48|0;if((c[m>>2]|0)<=0){n=0.0;o=n>=-.014999999664723873;i=b;return o|0}p=a+36|0;q=a+24|0;a=d+8|0;d=a;r=a+4|0;a=h+8|0;h=a;s=a+4|0;a=l;t=l+8|0;u=l+16|0;v=0;w=0.0;while(1){x=c[p>>2]|0;y=x+(v*88&-1)|0;z=c[x+(v*88&-1)+32>>2]|0;A=c[x+(v*88&-1)+36>>2]|0;B=x+(v*88&-1)+48|0;C=+g[B>>2];D=+g[B+4>>2];E=+g[x+(v*88&-1)+40>>2];F=+g[x+(v*88&-1)+64>>2];B=x+(v*88&-1)+56|0;G=+g[B>>2];H=+g[B+4>>2];I=+g[x+(v*88&-1)+44>>2];J=+g[x+(v*88&-1)+68>>2];B=c[x+(v*88&-1)+84>>2]|0;x=c[q>>2]|0;K=x+(z*12&-1)|0;L=+g[K>>2];M=+g[K+4>>2];N=+g[x+(z*12&-1)+8>>2];K=x+(A*12&-1)|0;O=+g[K>>2];P=+g[K+4>>2];Q=+g[x+(A*12&-1)+8>>2];if((B|0)>0){T=E+I;U=M;V=L;W=P;X=O;K=0;Y=Q;Z=N;_=w;do{$=+S(+Z);g[d>>2]=$;aa=+R(+Z);g[r>>2]=aa;ab=+S(+Y);g[h>>2]=ab;ac=+R(+Y);g[s>>2]=ac;ad=+(U-(D*aa+C*$));g[e>>2]=V-(C*aa-D*$);g[e+4>>2]=ad;ad=+(W-(H*ac+G*ab));g[j>>2]=X-(G*ac-H*ab);g[j+4>>2]=ad;eC(l,y,f,k,K);ad=+g[a>>2];ab=+g[a+4>>2];ac=+g[t>>2];$=+g[t+4>>2];aa=+g[u>>2];ae=ac-V;af=$-U;ag=ac-X;ac=$-W;_=_0.0){aj=(-0.0-(aa<-.20000000298023224?-.20000000298023224:aa))/ai}else{aj=0.0}ai=ad*aj;ad=ab*aj;V=V-E*ai;U=U-E*ad;Z=Z-F*(ae*ad-af*ai);X=X+I*ai;W=W+I*ad;Y=Y+J*(ag*ad-ac*ai);K=K+1|0;}while((K|0)<(B|0));ak=U;al=V;am=W;an=X;ao=Y;ap=Z;aq=_;ar=c[q>>2]|0}else{ak=M;al=L;am=P;an=O;ao=Q;ap=N;aq=w;ar=x}B=ar+(z*12&-1)|0;J=+ak;g[B>>2]=al;g[B+4>>2]=J;g[(c[q>>2]|0)+(z*12&-1)+8>>2]=ap;B=(c[q>>2]|0)+(A*12&-1)|0;J=+am;g[B>>2]=an;g[B+4>>2]=J;g[(c[q>>2]|0)+(A*12&-1)+8>>2]=ao;B=v+1|0;if((B|0)<(c[m>>2]|0)){v=B;w=aq}else{n=aq;break}}o=n>=-.014999999664723873;i=b;return o|0}function er(a){a=a|0;var b=0,d=0,e=0,f=0,h=0,i=0,j=0,k=0.0,l=0.0,m=0.0,n=0.0,o=0,p=0,q=0,r=0,s=0,t=0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0,D=0.0,E=0.0,F=0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0.0,R=0.0,S=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ab=0.0,ac=0.0,ad=0.0;b=a+48|0;if((c[b>>2]|0)<=0){return}d=a+40|0;e=a+28|0;a=0;L3146:while(1){f=c[d>>2]|0;h=f+(a*152&-1)|0;i=c[f+(a*152&-1)+112>>2]|0;j=c[f+(a*152&-1)+116>>2]|0;k=+g[f+(a*152&-1)+120>>2];l=+g[f+(a*152&-1)+128>>2];m=+g[f+(a*152&-1)+124>>2];n=+g[f+(a*152&-1)+132>>2];o=f+(a*152&-1)+144|0;p=c[o>>2]|0;q=c[e>>2]|0;r=q+(i*12&-1)|0;s=q+(j*12&-1)|0;t=f+(a*152&-1)+72|0;u=+g[t>>2];v=+g[t+4>>2];w=u*-1.0;x=+g[f+(a*152&-1)+136>>2];if((p-1|0)>>>0<2){y=+g[r+4>>2];z=+g[r>>2];A=+g[s+4>>2];B=+g[s>>2];C=0;D=+g[q+(j*12&-1)+8>>2];E=+g[q+(i*12&-1)+8>>2]}else{F=2435;break}do{G=+g[f+(a*152&-1)+(C*36&-1)+12>>2];H=+g[f+(a*152&-1)+(C*36&-1)+8>>2];I=+g[f+(a*152&-1)+(C*36&-1)+4>>2];J=+g[f+(a*152&-1)+(C*36&-1)>>2];K=x*+g[f+(a*152&-1)+(C*36&-1)+16>>2];q=f+(a*152&-1)+(C*36&-1)+20|0;L=+g[q>>2];M=L+ +g[f+(a*152&-1)+(C*36&-1)+28>>2]*(-0.0-(v*(B+G*(-0.0-D)-z-I*(-0.0-E))+w*(A+D*H-y-E*J)));N=-0.0-K;O=M>2]=K;K=v*O;L=w*O;z=z-k*K;y=y-k*L;E=E-l*(J*L-I*K);B=B+m*K;A=A+m*L;D=D+n*(H*L-G*K);C=C+1|0;}while((C|0)<(p|0));L3151:do{if((c[o>>2]|0)==1){w=+g[f+(a*152&-1)+12>>2];x=+g[f+(a*152&-1)+8>>2];K=+g[f+(a*152&-1)+4>>2];G=+g[h>>2];p=f+(a*152&-1)+16|0;L=+g[p>>2];H=L+(u*(B+w*(-0.0-D)-z-K*(-0.0-E))+v*(A+D*x-y-E*G)- +g[f+(a*152&-1)+32>>2])*(-0.0- +g[f+(a*152&-1)+24>>2]);I=H>0.0?H:0.0;H=I-L;g[p>>2]=I;I=u*H;L=v*H;P=E-l*(G*L-K*I);Q=D+n*(x*L-w*I);R=B+m*I;S=A+m*L;T=z-k*I;U=y-k*L}else{p=f+(a*152&-1)+16|0;L=+g[p>>2];q=f+(a*152&-1)+52|0;I=+g[q>>2];if(L<0.0|I<0.0){F=2440;break L3146}w=-0.0-D;x=+g[f+(a*152&-1)+12>>2];K=+g[f+(a*152&-1)+8>>2];G=-0.0-E;H=+g[f+(a*152&-1)+4>>2];J=+g[h>>2];O=+g[f+(a*152&-1)+48>>2];N=+g[f+(a*152&-1)+44>>2];M=+g[f+(a*152&-1)+40>>2];V=+g[f+(a*152&-1)+36>>2];W=+g[f+(a*152&-1)+104>>2];X=+g[f+(a*152&-1)+100>>2];Y=u*(B+x*w-z-H*G)+v*(A+D*K-y-E*J)- +g[f+(a*152&-1)+32>>2]-(L*+g[f+(a*152&-1)+96>>2]+I*W);Z=u*(B+O*w-z-M*G)+v*(A+D*N-y-E*V)- +g[f+(a*152&-1)+68>>2]-(L*X+I*+g[f+(a*152&-1)+108>>2]);G=+g[f+(a*152&-1)+80>>2]*Y+ +g[f+(a*152&-1)+88>>2]*Z;w=Y*+g[f+(a*152&-1)+84>>2]+Z*+g[f+(a*152&-1)+92>>2];_=-0.0-G;$=-0.0-w;if(!(G>-0.0|w>-0.0)){w=_-L;G=$-I;aa=u*w;ab=v*w;w=u*G;ac=v*G;G=aa+w;ad=ab+ac;g[p>>2]=_;g[q>>2]=$;P=E-l*(J*ab-H*aa+(V*ac-M*w));Q=D+n*(K*ab-x*aa+(N*ac-O*w));R=B+m*G;S=A+m*ad;T=z-k*G;U=y-k*ad;break}ad=Y*(-0.0- +g[f+(a*152&-1)+24>>2]);do{if(ad>=0.0){if(Z+ad*X<0.0){break}G=ad-L;w=0.0-I;ac=u*G;aa=v*G;G=u*w;ab=v*w;w=G+ac;$=ab+aa;g[p>>2]=ad;g[q>>2]=0.0;P=E-l*(aa*J-ac*H+(ab*V-G*M));Q=D+n*(aa*K-ac*x+(ab*N-G*O));R=B+m*w;S=A+m*$;T=z-k*w;U=y-k*$;break L3151}}while(0);ad=Z*(-0.0- +g[f+(a*152&-1)+60>>2]);do{if(ad>=0.0){if(Y+ad*W<0.0){break}X=0.0-L;$=ad-I;w=u*X;G=v*X;X=u*$;ab=v*$;$=w+X;ac=G+ab;g[p>>2]=0.0;g[q>>2]=ad;P=E-l*(G*J-w*H+(ab*V-X*M));Q=D+n*(G*K-w*x+(ab*N-X*O));R=B+m*$;S=A+m*ac;T=z-k*$;U=y-k*ac;break L3151}}while(0);if(Y<0.0|Z<0.0){P=E;Q=D;R=B;S=A;T=z;U=y;break}ad=0.0-L;W=0.0-I;ac=u*ad;$=v*ad;ad=u*W;X=v*W;W=ac+ad;ab=$+X;g[p>>2]=0.0;g[q>>2]=0.0;P=E-l*($*J-ac*H+(X*V-ad*M));Q=D+n*($*K-ac*x+(X*N-ad*O));R=B+m*W;S=A+m*ab;T=z-k*W;U=y-k*ab}}while(0);f=(c[e>>2]|0)+(i*12&-1)|0;k=+U;g[f>>2]=T;g[f+4>>2]=k;g[(c[e>>2]|0)+(i*12&-1)+8>>2]=P;f=(c[e>>2]|0)+(j*12&-1)|0;k=+S;g[f>>2]=R;g[f+4>>2]=k;g[(c[e>>2]|0)+(j*12&-1)+8>>2]=Q;f=a+1|0;if((f|0)<(c[b>>2]|0)){a=f}else{F=2454;break}}if((F|0)==2435){ba(9232,311,17816,7144)}else if((F|0)==2454){return}else if((F|0)==2440){ba(9232,406,17816,6128)}}function es(a){a=a|0;return}function et(a){a=a|0;return}function eu(a){a=a|0;return}function ev(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0.0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0.0,z=0,A=0,B=0,C=0,D=0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0,N=0.0,O=0.0,P=0.0,Q=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ab=0.0,ac=0.0,ad=0.0,ae=0.0,af=0.0,ag=0.0,ah=0.0,ai=0.0,aj=0.0,ak=0.0,al=0.0,am=0.0,an=0.0,ao=0.0,ap=0.0,aq=0.0,ar=0.0,as=0.0,at=0;e=i;i=i+16|0;f=e|0;h=f|0;j=f;k=i;i=i+16|0;l=k|0;m=k;n=i;i=i+20|0;i=i+7>>3<<3;o=a+48|0;if((c[o>>2]|0)<=0){p=0.0;q=p>=-.007499999832361937;i=e;return q|0}r=a+36|0;s=a+24|0;a=f+8|0;f=a;t=a+4|0;a=k+8|0;k=a;u=a+4|0;a=n;v=n+8|0;w=n+16|0;x=0;y=0.0;while(1){z=c[r>>2]|0;A=z+(x*88&-1)|0;B=c[z+(x*88&-1)+32>>2]|0;C=c[z+(x*88&-1)+36>>2]|0;D=z+(x*88&-1)+48|0;E=+g[D>>2];F=+g[D+4>>2];D=z+(x*88&-1)+56|0;G=+g[D>>2];H=+g[D+4>>2];D=c[z+(x*88&-1)+84>>2]|0;if((B|0)==(b|0)|(B|0)==(d|0)){I=+g[z+(x*88&-1)+40>>2];J=+g[z+(x*88&-1)+64>>2]}else{I=0.0;J=0.0}K=+g[z+(x*88&-1)+44>>2];L=+g[z+(x*88&-1)+68>>2];z=c[s>>2]|0;M=z+(B*12&-1)|0;N=+g[M>>2];O=+g[M+4>>2];P=+g[z+(B*12&-1)+8>>2];M=z+(C*12&-1)|0;Q=+g[M>>2];T=+g[M+4>>2];U=+g[z+(C*12&-1)+8>>2];if((D|0)>0){V=I+K;W=O;X=N;Y=T;Z=Q;_=P;$=U;M=0;aa=y;do{ab=+S(+_);g[f>>2]=ab;ac=+R(+_);g[t>>2]=ac;ad=+S(+$);g[k>>2]=ad;ae=+R(+$);g[u>>2]=ae;af=+(W-(F*ac+E*ab));g[h>>2]=X-(E*ac-F*ab);g[h+4>>2]=af;af=+(Y-(H*ae+G*ad));g[l>>2]=Z-(G*ae-H*ad);g[l+4>>2]=af;eC(n,A,j,m,M);af=+g[a>>2];ad=+g[a+4>>2];ae=+g[v>>2];ab=+g[v+4>>2];ac=+g[w>>2];ag=ae-X;ah=ab-W;ai=ae-Z;ae=ab-Y;aa=aa0.0){al=(-0.0-(ac<-.20000000298023224?-.20000000298023224:ac))/ak}else{al=0.0}ak=af*al;af=ad*al;X=X-I*ak;W=W-I*af;_=_-J*(ag*af-ah*ak);Z=Z+K*ak;Y=Y+K*af;$=$+L*(ai*af-ae*ak);M=M+1|0;}while((M|0)<(D|0));am=W;an=X;ao=Y;ap=Z;aq=_;ar=$;as=aa;at=c[s>>2]|0}else{am=O;an=N;ao=T;ap=Q;aq=P;ar=U;as=y;at=z}D=at+(B*12&-1)|0;L=+am;g[D>>2]=an;g[D+4>>2]=L;g[(c[s>>2]|0)+(B*12&-1)+8>>2]=aq;D=(c[s>>2]|0)+(C*12&-1)|0;L=+ao;g[D>>2]=ap;g[D+4>>2]=L;g[(c[s>>2]|0)+(C*12&-1)+8>>2]=ar;D=x+1|0;if((D|0)<(c[o>>2]|0)){x=D;y=as}else{p=as;break}}q=p>=-.007499999832361937;i=e;return q|0}function ew(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;b6(b,c[(c[a+48>>2]|0)+12>>2]|0,d,c[(c[a+52>>2]|0)+12>>2]|0,e);return}function ex(a){a=a|0;vl(a);return}function ey(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=i;i=i+256|0;b7(f|0,b,c[(c[a+48>>2]|0)+12>>2]|0,d,c[(c[a+52>>2]|0)+12>>2]|0,e);i=f;return}function ez(a){a=a|0;vl(a);return}function eA(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;b5(b,c[(c[a+48>>2]|0)+12>>2]|0,d,c[(c[a+52>>2]|0)+12>>2]|0,e);return}function eB(a){a=a|0;vl(a);return}function eC(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0.0,s=0.0,t=0.0,u=0,v=0,w=0.0;if((c[b+84>>2]|0)<=0){ba(9232,617,16360,5640)}h=c[b+72>>2]|0;if((h|0)==0){i=+g[d+12>>2];j=+g[b+24>>2];k=+g[d+8>>2];l=+g[b+28>>2];m=+g[d>>2]+(i*j-k*l);n=j*k+i*l+ +g[d+4>>2];l=+g[e+12>>2];i=+g[b>>2];k=+g[e+8>>2];j=+g[b+4>>2];o=+g[e>>2]+(l*i-k*j);p=i*k+l*j+ +g[e+4>>2];j=o-m;l=p-n;q=a;k=+l;g[q>>2]=j;g[q+4>>2]=k;k=+P(+(j*j+l*l));if(k<1.1920928955078125e-7){r=j;s=l}else{i=1.0/k;k=j*i;g[a>>2]=k;t=l*i;g[a+4>>2]=t;r=k;s=t}q=a+8|0;t=+((n+p)*.5);g[q>>2]=(m+o)*.5;g[q+4>>2]=t;g[a+16>>2]=j*r+l*s- +g[b+76>>2]- +g[b+80>>2];return}else if((h|0)==1){q=d+12|0;s=+g[q>>2];l=+g[b+16>>2];u=d+8|0;r=+g[u>>2];j=+g[b+20>>2];t=s*l-r*j;o=l*r+s*j;v=a;j=+o;g[v>>2]=t;g[v+4>>2]=j;j=+g[q>>2];s=+g[b+24>>2];r=+g[u>>2];l=+g[b+28>>2];m=+g[e+12>>2];p=+g[b+(f<<3)>>2];n=+g[e+8>>2];k=+g[b+(f<<3)+4>>2];i=+g[e>>2]+(m*p-n*k);w=p*n+m*k+ +g[e+4>>2];g[a+16>>2]=t*(i-(+g[d>>2]+(j*s-r*l)))+(w-(s*r+j*l+ +g[d+4>>2]))*o- +g[b+76>>2]- +g[b+80>>2];u=a+8|0;o=+w;g[u>>2]=i;g[u+4>>2]=o;return}else if((h|0)==2){h=e+12|0;o=+g[h>>2];i=+g[b+16>>2];u=e+8|0;w=+g[u>>2];l=+g[b+20>>2];j=o*i-w*l;r=i*w+o*l;q=a;l=+r;g[q>>2]=j;g[q+4>>2]=l;l=+g[h>>2];o=+g[b+24>>2];w=+g[u>>2];i=+g[b+28>>2];s=+g[d+12>>2];t=+g[b+(f<<3)>>2];k=+g[d+8>>2];m=+g[b+(f<<3)+4>>2];n=+g[d>>2]+(s*t-k*m);p=t*k+s*m+ +g[d+4>>2];g[a+16>>2]=j*(n-(+g[e>>2]+(l*o-w*i)))+(p-(o*w+l*i+ +g[e+4>>2]))*r- +g[b+76>>2]- +g[b+80>>2];b=a+8|0;i=+p;g[b>>2]=n;g[b+4>>2]=i;i=+(-0.0-r);g[q>>2]=-0.0-j;g[q+4>>2]=i;return}else{return}}function eD(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0,j=0.0,k=0.0;e=df(f,144)|0;if((e|0)==0){h=0;i=h|0;return i|0}f=e;c[f>>2]=19280;c[e+4>>2]=4;c[e+48>>2]=a;c[e+52>>2]=d;c[e+56>>2]=0;c[e+60>>2]=0;c[e+124>>2]=0;c[e+128>>2]=0;vq(e+8|0,0,40);g[e+136>>2]=+P(+(+g[a+16>>2]*+g[d+16>>2]));j=+g[a+20>>2];k=+g[d+20>>2];g[e+140>>2]=j>k?j:k;c[f>>2]=19544;if((c[(c[a+12>>2]|0)+4>>2]|0)!=1){ba(8616,41,16760,11856);return 0}if((c[(c[d+12>>2]|0)+4>>2]|0)==0){h=e;i=h|0;return i|0}else{ba(8616,42,16760,9416);return 0}return 0}function eE(b,d){b=b|0;d=d|0;var e=0,f=0;bo[c[(c[b>>2]|0)+4>>2]&511](b);e=a[22208]|0;if((e&255)<14){f=d+12+((e&255)<<2)|0;c[b>>2]=c[f>>2];c[f>>2]=b;return}else{ba(5352,173,17448,6544)}}function eF(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0,j=0.0,k=0.0;e=df(f,144)|0;if((e|0)==0){h=0;i=h|0;return i|0}f=e;c[f>>2]=19280;c[e+4>>2]=4;c[e+48>>2]=a;c[e+52>>2]=d;c[e+56>>2]=0;c[e+60>>2]=0;c[e+124>>2]=0;c[e+128>>2]=0;vq(e+8|0,0,40);g[e+136>>2]=+P(+(+g[a+16>>2]*+g[d+16>>2]));j=+g[a+20>>2];k=+g[d+20>>2];g[e+140>>2]=j>k?j:k;c[f>>2]=19480;if((c[(c[a+12>>2]|0)+4>>2]|0)!=1){ba(8440,41,16584,11856);return 0}if((c[(c[d+12>>2]|0)+4>>2]|0)==2){h=e;i=h|0;return i|0}else{ba(8440,42,16584,9368);return 0}return 0}function eG(b,d){b=b|0;d=d|0;var e=0,f=0;bo[c[(c[b>>2]|0)+4>>2]&511](b);e=a[22208]|0;if((e&255)<14){f=d+12+((e&255)<<2)|0;c[b>>2]=c[f>>2];c[f>>2]=b;return}else{ba(5352,173,17448,6544)}}function eH(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0,j=0.0,k=0.0;e=df(f,144)|0;if((e|0)==0){h=0;i=h|0;return i|0}f=e;c[f>>2]=19280;c[e+4>>2]=4;c[e+48>>2]=a;c[e+52>>2]=d;c[e+56>>2]=0;c[e+60>>2]=0;c[e+124>>2]=0;c[e+128>>2]=0;vq(e+8|0,0,40);g[e+136>>2]=+P(+(+g[a+16>>2]*+g[d+16>>2]));j=+g[a+20>>2];k=+g[d+20>>2];g[e+140>>2]=j>k?j:k;c[f>>2]=19416;if((c[(c[a+12>>2]|0)+4>>2]|0)!=2){ba(8208,41,16280,11808);return 0}if((c[(c[d+12>>2]|0)+4>>2]|0)==0){h=e;i=h|0;return i|0}else{ba(8208,42,16280,9416);return 0}return 0}function eI(b,d){b=b|0;d=d|0;var e=0,f=0;bo[c[(c[b>>2]|0)+4>>2]&511](b);e=a[22208]|0;if((e&255)<14){f=d+12+((e&255)<<2)|0;c[b>>2]=c[f>>2];c[f>>2]=b;return}else{ba(5352,173,17448,6544)}}function eJ(a){a=a|0;return}function eK(a,b){a=a|0;b=+b;return+0.0}function eL(a){a=a|0;return}function eM(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0;d=a+108|0;e=c[d>>2]|0;f=b+28|0;b=c[f>>2]|0;h=b+(e*12&-1)|0;i=+g[h>>2];j=+g[h+4>>2];k=+g[b+(e*12&-1)+8>>2];h=a+112|0;l=c[h>>2]|0;m=b+(l*12&-1)|0;n=+g[m>>2];o=+g[m+4>>2];p=+g[b+(l*12&-1)+8>>2];q=+g[a+128>>2];r=+g[a+124>>2];s=+g[a+136>>2];t=+g[a+132>>2];u=+g[a+116>>2];v=+g[a+120>>2];l=a+100|0;w=+g[l>>2];x=(+g[a+76>>2]+(u*(n+s*(-0.0-p)-(i+q*(-0.0-k)))+v*(o+p*t-(j+k*r)))+ +g[a+96>>2]*w)*(-0.0- +g[a+172>>2]);g[l>>2]=w+x;w=u*x;u=v*x;x=+g[a+156>>2];v=k- +g[a+164>>2]*(u*r-w*q);q=+g[a+160>>2];r=p+ +g[a+168>>2]*(u*t-w*s);a=(c[f>>2]|0)+(e*12&-1)|0;s=+(j-x*u);g[a>>2]=i-x*w;g[a+4>>2]=s;g[(c[f>>2]|0)+((c[d>>2]|0)*12&-1)+8>>2]=v;d=(c[f>>2]|0)+((c[h>>2]|0)*12&-1)|0;v=+(o+u*q);g[d>>2]=n+w*q;g[d+4>>2]=v;g[(c[f>>2]|0)+((c[h>>2]|0)*12&-1)+8>>2]=r;return}function eN(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+48>>2]|0;e=+g[d+24>>2];f=+g[b+80>>2];h=+g[d+20>>2];i=+g[b+84>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function eO(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+52>>2]|0;e=+g[d+24>>2];f=+g[b+88>>2];h=+g[d+20>>2];i=+g[b+92>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function eP(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0;d=+g[b+100>>2]*c;c=d*+g[b+120>>2];g[a>>2]=+g[b+116>>2]*d;g[a+4>>2]=c;return}function eQ(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;ca(b,c[(c[a+48>>2]|0)+12>>2]|0,d,c[(c[a+52>>2]|0)+12>>2]|0,e);return}function eR(a){a=a|0;vl(a);return}function eS(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,Q=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0,ao=0,ap=0,aq=0,ar=0,as=0,at=0,au=0,av=0,aw=0,ax=0,ay=0,az=0,aA=0,aB=0,aC=0,aD=0,aE=0,aF=0,aG=0,aH=0,aI=0,aJ=0,aK=0;e=c[b+48>>2]|0;f=c[e+8>>2]|0;h=b+108|0;c[h>>2]=f;i=c[b+52>>2]|0;j=c[i+8>>2]|0;l=b+112|0;c[l>>2]=j;m=e+28|0;n=b+140|0;o=c[m>>2]|0;p=c[m+4>>2]|0;c[n>>2]=o;c[n+4>>2]=p;n=i+28|0;m=b+148|0;q=c[n>>2]|0;r=c[n+4>>2]|0;c[m>>2]=q;c[m+4>>2]=r;s=+g[e+120>>2];g[b+156>>2]=s;t=+g[i+120>>2];g[b+160>>2]=t;u=+g[e+128>>2];g[b+164>>2]=u;v=+g[i+128>>2];g[b+168>>2]=v;i=c[d+24>>2]|0;e=i+(f*12&-1)|0;w=+g[e>>2];x=+g[e+4>>2];y=+g[i+(f*12&-1)+8>>2];e=d+28|0;m=c[e>>2]|0;n=m+(f*12&-1)|0;z=+g[n>>2];A=+g[n+4>>2];B=+g[m+(f*12&-1)+8>>2];n=i+(j*12&-1)|0;C=+g[n>>2];D=+g[n+4>>2];E=+g[i+(j*12&-1)+8>>2];i=m+(j*12&-1)|0;F=+g[i>>2];G=+g[i+4>>2];H=+g[m+(j*12&-1)+8>>2];I=+S(+y);J=+R(+y);y=+S(+E);K=+R(+E);E=+g[b+80>>2]-(c[k>>2]=o,+g[k>>2]);L=+g[b+84>>2]-(c[k>>2]=p,+g[k>>2]);M=J*E-I*L;N=I*E+J*L;p=b+124|0;L=+N;g[p>>2]=M;g[p+4>>2]=L;L=+g[b+88>>2]-(c[k>>2]=q,+g[k>>2]);J=+g[b+92>>2]-(c[k>>2]=r,+g[k>>2]);E=K*L-y*J;I=y*L+K*J;r=b+132|0;J=+I;g[r>>2]=E;g[r+4>>2]=J;r=b+116|0;J=C+E-w-M;w=D+I-x-N;q=r;x=+w;g[q>>2]=J;g[q+4>>2]=x;q=r|0;x=+P(+(J*J+w*w));if(x>.004999999888241291){D=1.0/x;C=J*D;g[q>>2]=C;O=D*w;Q=C}else{g[q>>2]=0.0;O=0.0;Q=0.0}g[b+120>>2]=O;C=O*M-N*Q;w=O*E-Q*I;D=t+(s+C*C*u)+w*w*v;if(D!=0.0){T=1.0/D}else{T=0.0}q=b+172|0;g[q>>2]=T;w=+g[b+68>>2];if(w>0.0){C=x- +g[b+104>>2];x=w*6.2831854820251465;w=x*T*x;J=+g[d>>2];K=J*(x*T*2.0*+g[b+72>>2]+w*J);r=b+96|0;g[r>>2]=K;if(K!=0.0){U=1.0/K}else{U=0.0}g[r>>2]=U;g[b+76>>2]=w*C*J*U;J=D+U;if(J!=0.0){V=1.0/J}else{V=0.0}g[q>>2]=V}else{g[b+96>>2]=0.0;g[b+76>>2]=0.0}if((a[d+20|0]&1)==0){g[b+100>>2]=0.0;W=B;X=H;Y=F;Z=G;_=z;$=A;aa=c[e>>2]|0;ab=aa+(f*12&-1)|0;ac=ab;ad=(g[k>>2]=_,c[k>>2]|0);ae=(g[k>>2]=$,c[k>>2]|0);af=ae;ag=0;ah=0;ai=af;aj=ad;ak=0;al=ah|aj;am=ai|ak;an=ac|0;c[an>>2]=al;ao=ac+4|0;c[ao>>2]=am;ap=c[h>>2]|0;aq=c[e>>2]|0;ar=aq+(ap*12&-1)+8|0;g[ar>>2]=W;as=c[l>>2]|0;at=c[e>>2]|0;au=at+(as*12&-1)|0;av=au;aw=(g[k>>2]=Y,c[k>>2]|0);ax=(g[k>>2]=Z,c[k>>2]|0);ay=ax;az=0;aA=0;aB=ay;aC=aw;aD=0;aE=aA|aC;aF=aB|aD;aG=av|0;c[aG>>2]=aE;aH=av+4|0;c[aH>>2]=aF;aI=c[l>>2]|0;aJ=c[e>>2]|0;aK=aJ+(aI*12&-1)+8|0;g[aK>>2]=X;return}else{q=b+100|0;V=+g[d+8>>2]*+g[q>>2];g[q>>2]=V;J=Q*V;Q=V*O;W=B-u*(Q*M-J*N);X=H+v*(Q*E-J*I);Y=F+J*t;Z=G+Q*t;_=z-J*s;$=A-Q*s;aa=c[e>>2]|0;ab=aa+(f*12&-1)|0;ac=ab;ad=(g[k>>2]=_,c[k>>2]|0);ae=(g[k>>2]=$,c[k>>2]|0);af=ae;ag=0;ah=0;ai=af;aj=ad;ak=0;al=ah|aj;am=ai|ak;an=ac|0;c[an>>2]=al;ao=ac+4|0;c[ao>>2]=am;ap=c[h>>2]|0;aq=c[e>>2]|0;ar=aq+(ap*12&-1)+8|0;g[ar>>2]=W;as=c[l>>2]|0;at=c[e>>2]|0;au=at+(as*12&-1)|0;av=au;aw=(g[k>>2]=Y,c[k>>2]|0);ax=(g[k>>2]=Z,c[k>>2]|0);ay=ax;az=0;aA=0;aB=ay;aC=aw;aD=0;aE=aA|aC;aF=aB|aD;aG=av|0;c[aG>>2]=aE;aH=av+4|0;c[aH>>2]=aF;aI=c[l>>2]|0;aJ=c[e>>2]|0;aK=aJ+(aI*12&-1)+8|0;g[aK>>2]=X;return}}function eT(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0,j=0.0,k=0.0,l=0.0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0;if(+g[a+68>>2]>0.0){d=1;return d|0}e=a+108|0;f=c[e>>2]|0;h=b+24|0;b=c[h>>2]|0;i=b+(f*12&-1)|0;j=+g[i>>2];k=+g[i+4>>2];l=+g[b+(f*12&-1)+8>>2];f=a+112|0;m=c[f>>2]|0;n=b+(m*12&-1)|0;o=+g[n>>2];p=+g[n+4>>2];q=+g[b+(m*12&-1)+8>>2];r=+S(+l);s=+R(+l);t=+S(+q);u=+R(+q);v=+g[a+80>>2]- +g[a+140>>2];w=+g[a+84>>2]- +g[a+144>>2];x=s*v-r*w;y=r*v+s*w;w=+g[a+88>>2]- +g[a+148>>2];s=+g[a+92>>2]- +g[a+152>>2];v=u*w-t*s;r=t*w+u*s;s=o+v-j-x;u=p+r-k-y;w=+P(+(s*s+u*u));if(w<1.1920928955078125e-7){z=0.0;A=s;B=u}else{t=1.0/w;z=w;A=s*t;B=u*t}t=z- +g[a+104>>2];z=t<.20000000298023224?t:.20000000298023224;t=z<-.20000000298023224?-.20000000298023224:z;z=t*(-0.0- +g[a+172>>2]);u=A*z;A=B*z;z=+g[a+156>>2];B=l- +g[a+164>>2]*(x*A-y*u);y=+g[a+160>>2];x=q+ +g[a+168>>2]*(v*A-r*u);r=+(k-z*A);g[i>>2]=j-z*u;g[i+4>>2]=r;g[(c[h>>2]|0)+((c[e>>2]|0)*12&-1)+8>>2]=B;e=(c[h>>2]|0)+((c[f>>2]|0)*12&-1)|0;B=+(p+y*A);g[e>>2]=o+y*u;g[e+4>>2]=B;g[(c[h>>2]|0)+((c[f>>2]|0)*12&-1)+8>>2]=x;if(t>0.0){C=t}else{C=-0.0-t}d=C<.004999999888241291;return d|0}function eU(b){b=b|0;var d=0,e=0,f=0,j=0.0;d=i;e=c[(c[b+48>>2]|0)+8>>2]|0;f=c[(c[b+52>>2]|0)+8>>2]|0;db(7888,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(11336,(u=i,i=i+8|0,c[u>>2]=e,u)|0);db(8808,(u=i,i=i+8|0,c[u>>2]=f,u)|0);db(6768,(u=i,i=i+8|0,c[u>>2]=a[b+61|0]&1,u)|0);j=+g[b+84>>2];db(5992,(u=i,i=i+16|0,h[u>>3]=+g[b+80>>2],h[u+8>>3]=j,u)|0);j=+g[b+92>>2];db(5536,(u=i,i=i+16|0,h[u>>3]=+g[b+88>>2],h[u+8>>3]=j,u)|0);db(5176,(u=i,i=i+8|0,h[u>>3]=+g[b+104>>2],u)|0);db(12768,(u=i,i=i+8|0,h[u>>3]=+g[b+68>>2],u)|0);db(12472,(u=i,i=i+8|0,h[u>>3]=+g[b+72>>2],u)|0);db(11904,(u=i,i=i+8|0,c[u>>2]=c[b+56>>2],u)|0);i=d;return}function eV(a){a=a|0;vl(a);return}function eW(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0,j=0.0,k=0.0;e=df(f,144)|0;if((e|0)==0){h=0;i=h|0;return i|0}f=e;c[f>>2]=19280;c[e+4>>2]=4;c[e+48>>2]=a;c[e+52>>2]=d;c[e+56>>2]=0;c[e+60>>2]=0;c[e+124>>2]=0;c[e+128>>2]=0;vq(e+8|0,0,40);g[e+136>>2]=+P(+(+g[a+16>>2]*+g[d+16>>2]));j=+g[a+20>>2];k=+g[d+20>>2];g[e+140>>2]=j>k?j:k;c[f>>2]=19736;if((c[(c[a+12>>2]|0)+4>>2]|0)!=2){ba(7976,44,17304,11808);return 0}if((c[(c[d+12>>2]|0)+4>>2]|0)==2){h=e;i=h|0;return i|0}else{ba(7976,45,17304,9368);return 0}return 0}function eX(b,d){b=b|0;d=d|0;var e=0,f=0;bo[c[(c[b>>2]|0)+4>>2]&511](b);e=a[22208]|0;if((e&255)<14){f=d+12+((e&255)<<2)|0;c[b>>2]=c[f>>2];c[f>>2]=b;return}else{ba(5352,173,17448,6544)}}function eY(a,b){a=a|0;b=b|0;return 1}function eZ(a){a=a|0;return}function e_(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+48>>2]|0;e=+g[d+24>>2];f=+g[b+68>>2];h=+g[d+20>>2];i=+g[b+72>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function e$(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+52>>2]|0;e=+g[d+24>>2];f=+g[b+76>>2];h=+g[d+20>>2];i=+g[b+80>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function e0(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0;d=+g[b+88>>2]*c;g[a>>2]=+g[b+84>>2]*c;g[a+4>>2]=d;return}function e1(a,b){a=a|0;b=+b;return+(+g[a+92>>2]*b)}function e2(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0.0,T=0.0,U=0.0;e=c[b+48>>2]|0;f=c[e+8>>2]|0;h=b+104|0;c[h>>2]=f;i=c[b+52>>2]|0;j=c[i+8>>2]|0;l=b+108|0;c[l>>2]=j;m=e+28|0;n=b+128|0;o=c[m>>2]|0;p=c[m+4>>2]|0;c[n>>2]=o;c[n+4>>2]=p;n=i+28|0;m=b+136|0;q=c[n>>2]|0;r=c[n+4>>2]|0;c[m>>2]=q;c[m+4>>2]=r;s=+g[e+120>>2];g[b+144>>2]=s;t=+g[i+120>>2];g[b+148>>2]=t;u=+g[e+128>>2];g[b+152>>2]=u;v=+g[i+128>>2];g[b+156>>2]=v;i=c[d+24>>2]|0;w=+g[i+(f*12&-1)+8>>2];e=d+28|0;m=c[e>>2]|0;n=m+(f*12&-1)|0;x=+g[n>>2];y=+g[n+4>>2];z=+g[m+(f*12&-1)+8>>2];A=+g[i+(j*12&-1)+8>>2];i=m+(j*12&-1)|0;B=+g[i>>2];C=+g[i+4>>2];D=+g[m+(j*12&-1)+8>>2];E=+S(+w);F=+R(+w);w=+S(+A);G=+R(+A);A=+g[b+68>>2]-(c[k>>2]=o,+g[k>>2]);H=+g[b+72>>2]-(c[k>>2]=p,+g[k>>2]);I=F*A-E*H;J=E*A+F*H;p=b+112|0;H=+J;g[p>>2]=I;g[p+4>>2]=H;H=+g[b+76>>2]-(c[k>>2]=q,+g[k>>2]);F=+g[b+80>>2]-(c[k>>2]=r,+g[k>>2]);A=G*H-w*F;E=w*H+G*F;r=b+120|0;F=+E;g[r>>2]=A;g[r+4>>2]=F;F=s+t;G=F+J*u*J+E*v*E;H=v*A;w=J*I*(-0.0-u)-E*H;K=F+I*u*I+A*H;H=G*K-w*w;if(H!=0.0){L=1.0/H}else{L=H}H=w*(-0.0-L);g[b+160>>2]=K*L;g[b+164>>2]=H;g[b+168>>2]=H;g[b+172>>2]=G*L;L=u+v;if(L>0.0){M=1.0/L}else{M=L}g[b+176>>2]=M;r=b+84|0;if((a[d+20|0]&1)==0){g[r>>2]=0.0;g[b+88>>2]=0.0;g[b+92>>2]=0.0;N=z;O=D;P=B;Q=C;T=x;U=y}else{q=d+8|0;M=+g[q>>2];d=r|0;L=M*+g[d>>2];g[d>>2]=L;d=b+88|0;G=M*+g[d>>2];g[d>>2]=G;d=b+92|0;M=+g[q>>2]*+g[d>>2];g[d>>2]=M;N=z-u*(M+(G*I-L*J));O=D+v*(M+(G*A-L*E));P=B+t*L;Q=C+t*G;T=x-s*L;U=y-s*G}d=(c[e>>2]|0)+(f*12&-1)|0;G=+U;g[d>>2]=T;g[d+4>>2]=G;g[(c[e>>2]|0)+((c[h>>2]|0)*12&-1)+8>>2]=N;h=(c[e>>2]|0)+((c[l>>2]|0)*12&-1)|0;N=+Q;g[h>>2]=P;g[h+4>>2]=N;g[(c[e>>2]|0)+((c[l>>2]|0)*12&-1)+8>>2]=O;return}function e3(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0,j=0.0,k=0.0,l=0.0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0;d=a+104|0;e=c[d>>2]|0;f=b+28|0;h=c[f>>2]|0;i=h+(e*12&-1)|0;j=+g[i>>2];k=+g[i+4>>2];l=+g[h+(e*12&-1)+8>>2];i=a+108|0;m=c[i>>2]|0;n=h+(m*12&-1)|0;o=+g[n>>2];p=+g[n+4>>2];q=+g[h+(m*12&-1)+8>>2];r=+g[a+144>>2];s=+g[a+148>>2];t=+g[a+152>>2];u=+g[a+156>>2];v=+g[b>>2];b=a+92|0;w=+g[b>>2];x=v*+g[a+100>>2];y=w+(q-l)*(-0.0- +g[a+176>>2]);z=-0.0-x;A=y>2]=x;A=x-w;w=l-t*A;l=q+u*A;A=+g[a+124>>2];q=+g[a+120>>2];x=+g[a+116>>2];z=+g[a+112>>2];y=o+A*(-0.0-l)-j-x*(-0.0-w);B=p+q*l-k-z*w;C=+g[a+172>>2]*B+ +g[a+164>>2]*y;b=a+84|0;m=b;D=+g[m>>2];E=+g[m+4>>2];m=b|0;F=D-(+g[a+168>>2]*B+ +g[a+160>>2]*y);g[m>>2]=F;b=a+88|0;y=+g[b>>2]-C;g[b>>2]=y;C=v*+g[a+96>>2];v=F*F+y*y;if(v>C*C){B=+P(+v);if(B<1.1920928955078125e-7){G=F;H=y}else{v=1.0/B;B=F*v;g[m>>2]=B;I=y*v;g[b>>2]=I;G=B;H=I}I=C*G;g[m>>2]=I;G=C*H;g[b>>2]=G;J=I;K=G}else{J=F;K=y}y=J-D;D=K-E;b=(c[f>>2]|0)+(e*12&-1)|0;E=+(k-r*D);g[b>>2]=j-r*y;g[b+4>>2]=E;g[(c[f>>2]|0)+((c[d>>2]|0)*12&-1)+8>>2]=w-t*(z*D-y*x);d=(c[f>>2]|0)+((c[i>>2]|0)*12&-1)|0;x=+(p+s*D);g[d>>2]=o+s*y;g[d+4>>2]=x;g[(c[f>>2]|0)+((c[i>>2]|0)*12&-1)+8>>2]=l+u*(D*q-y*A);return}function e4(b){b=b|0;var d=0,e=0,f=0,j=0.0;d=i;e=c[(c[b+48>>2]|0)+8>>2]|0;f=c[(c[b+52>>2]|0)+8>>2]|0;db(7056,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(11336,(u=i,i=i+8|0,c[u>>2]=e,u)|0);db(8808,(u=i,i=i+8|0,c[u>>2]=f,u)|0);db(6768,(u=i,i=i+8|0,c[u>>2]=a[b+61|0]&1,u)|0);j=+g[b+72>>2];db(5992,(u=i,i=i+16|0,h[u>>3]=+g[b+68>>2],h[u+8>>3]=j,u)|0);j=+g[b+80>>2];db(5536,(u=i,i=i+16|0,h[u>>3]=+g[b+76>>2],h[u+8>>3]=j,u)|0);db(4328,(u=i,i=i+8|0,h[u>>3]=+g[b+96>>2],u)|0);db(12832,(u=i,i=i+8|0,h[u>>3]=+g[b+100>>2],u)|0);db(11904,(u=i,i=i+8|0,c[u>>2]=c[b+56>>2],u)|0);i=d;return}function e5(a){a=a|0;vl(a);return}function e6(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0,K=0.0,L=0,M=0.0,N=0.0,O=0,P=0;e=b|0;c[e>>2]=19312;f=d+8|0;h=d+12|0;if((c[f>>2]|0)==(c[h>>2]|0)){ba(7272,173,15744,9072)}c[b+4>>2]=c[d>>2];c[b+8>>2]=0;c[b+12>>2]=0;i=b+48|0;c[i>>2]=c[f>>2];f=b+52|0;c[f>>2]=c[h>>2];c[b+56>>2]=0;a[b+61|0]=a[d+16|0]&1;a[b+60|0]=0;c[b+64>>2]=c[d+4>>2];vq(b+16|0,0,32);c[e>>2]=20456;e=b+92|0;h=b+100|0;j=b+108|0;l=b+116|0;m=b+124|0;n=b+132|0;o=d+20|0;p=c[o>>2]|0;c[b+68>>2]=p;q=d+24|0;r=c[q>>2]|0;c[b+72>>2]=r;s=c[p+4>>2]|0;c[b+76>>2]=s;t=c[r+4>>2]|0;c[b+80>>2]=t;if((s-1|0)>>>0>=2){ba(7384,53,18560,11640)}if((t-1|0)>>>0>=2){ba(7384,54,18560,9168)}u=c[p+48>>2]|0;c[b+84>>2]=u;v=c[p+52>>2]|0;c[i>>2]=v;w=+g[v+20>>2];x=+g[v+24>>2];y=+g[u+20>>2];z=+g[u+24>>2];i=c[o>>2]|0;if((s|0)==1){A=+g[v+56>>2];B=+g[u+56>>2];s=i+68|0;o=j;p=c[s+4>>2]|0;c[o>>2]=c[s>>2];c[o+4>>2]=p;p=i+76|0;o=e;s=c[p+4>>2]|0;c[o>>2]=c[p>>2];c[o+4>>2]=s;C=+g[i+116>>2];g[b+140>>2]=C;g[m>>2]=0.0;g[b+128>>2]=0.0;D=A-B-C}else{C=+g[u+16>>2];B=+g[u+12>>2];A=+g[v+16>>2];E=+g[v+12>>2];v=i+68|0;u=j;j=c[v>>2]|0;s=c[v+4>>2]|0;c[u>>2]=j;c[u+4>>2]=s;u=i+76|0;v=e;e=c[u>>2]|0;o=c[u+4>>2]|0;c[v>>2]=e;c[v+4>>2]=o;g[b+140>>2]=+g[i+100>>2];v=i+84|0;i=m;m=c[v>>2]|0;u=c[v+4>>2]|0;c[i>>2]=m;c[i+4>>2]=u;F=(c[k>>2]=e,+g[k>>2]);G=(c[k>>2]=o,+g[k>>2]);H=E-B+(x*F-w*G);B=A-C+(w*F+x*G);D=(c[k>>2]=m,+g[k>>2])*(z*H+y*B-(c[k>>2]=j,+g[k>>2]))+(c[k>>2]=u,+g[k>>2])*(H*(-0.0-y)+z*B-(c[k>>2]=s,+g[k>>2]))}s=c[r+48>>2]|0;c[b+88>>2]=s;u=c[r+52>>2]|0;c[f>>2]=u;B=+g[u+20>>2];z=+g[u+24>>2];y=+g[s+20>>2];H=+g[s+24>>2];f=c[q>>2]|0;if((t|0)==1){G=+g[u+56>>2];x=+g[s+56>>2];t=f+68|0;q=l;r=c[t+4>>2]|0;c[q>>2]=c[t>>2];c[q+4>>2]=r;r=f+76|0;q=h;t=c[r+4>>2]|0;c[q>>2]=c[r>>2];c[q+4>>2]=t;F=+g[f+116>>2];g[b+144>>2]=F;g[n>>2]=0.0;g[b+136>>2]=0.0;I=G-x-F;J=d+28|0;K=+g[J>>2];L=b+152|0;g[L>>2]=K;M=I*K;N=D+M;O=b+148|0;g[O>>2]=N;P=b+156|0;g[P>>2]=0.0;return}else{F=+g[s+16>>2];x=+g[s+12>>2];G=+g[u+16>>2];w=+g[u+12>>2];u=f+68|0;s=l;l=c[u>>2]|0;t=c[u+4>>2]|0;c[s>>2]=l;c[s+4>>2]=t;s=f+76|0;u=h;h=c[s>>2]|0;q=c[s+4>>2]|0;c[u>>2]=h;c[u+4>>2]=q;g[b+144>>2]=+g[f+100>>2];u=f+84|0;f=n;n=c[u>>2]|0;s=c[u+4>>2]|0;c[f>>2]=n;c[f+4>>2]=s;C=(c[k>>2]=h,+g[k>>2]);A=(c[k>>2]=q,+g[k>>2]);E=w-x+(z*C-B*A);x=G-F+(B*C+z*A);I=(c[k>>2]=n,+g[k>>2])*(H*E+y*x-(c[k>>2]=l,+g[k>>2]))+(c[k>>2]=s,+g[k>>2])*(E*(-0.0-y)+H*x-(c[k>>2]=t,+g[k>>2]));J=d+28|0;K=+g[J>>2];L=b+152|0;g[L>>2]=K;M=I*K;N=D+M;O=b+148|0;g[O>>2]=N;P=b+156|0;g[P>>2]=0.0;return}}function e7(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0,r=0.0,s=0.0,t=0.0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0;d=a+160|0;e=c[d>>2]|0;f=b+28|0;b=c[f>>2]|0;h=b+(e*12&-1)|0;i=+g[h>>2];j=+g[h+4>>2];k=+g[b+(e*12&-1)+8>>2];h=a+164|0;l=c[h>>2]|0;m=b+(l*12&-1)|0;n=+g[m>>2];o=+g[m+4>>2];p=+g[b+(l*12&-1)+8>>2];l=a+168|0;m=c[l>>2]|0;q=b+(m*12&-1)|0;r=+g[q>>2];s=+g[q+4>>2];t=+g[b+(m*12&-1)+8>>2];m=a+172|0;q=c[m>>2]|0;u=b+(q*12&-1)|0;v=+g[u>>2];w=+g[u+4>>2];x=+g[b+(q*12&-1)+8>>2];y=+g[a+240>>2];z=+g[a+244>>2];A=+g[a+248>>2];B=+g[a+252>>2];C=+g[a+256>>2];D=+g[a+264>>2];E=+g[a+260>>2];F=+g[a+268>>2];G=((i-r)*y+(j-s)*z+((n-v)*A+(o-w)*B)+(k*C-t*D+(p*E-x*F)))*(-0.0- +g[a+272>>2]);q=a+156|0;g[q>>2]=+g[q>>2]+G;H=+g[a+208>>2]*G;I=k+G*+g[a+224>>2]*C;C=G*+g[a+212>>2];k=p+G*+g[a+228>>2]*E;E=G*+g[a+216>>2];p=t-G*+g[a+232>>2]*D;D=G*+g[a+220>>2];t=x-G*+g[a+236>>2]*F;a=(c[f>>2]|0)+(e*12&-1)|0;F=+(j+z*H);g[a>>2]=i+y*H;g[a+4>>2]=F;g[(c[f>>2]|0)+((c[d>>2]|0)*12&-1)+8>>2]=I;d=(c[f>>2]|0)+((c[h>>2]|0)*12&-1)|0;I=+(o+C*B);g[d>>2]=n+A*C;g[d+4>>2]=I;g[(c[f>>2]|0)+((c[h>>2]|0)*12&-1)+8>>2]=k;h=(c[f>>2]|0)+((c[l>>2]|0)*12&-1)|0;k=+(s-z*E);g[h>>2]=r-y*E;g[h+4>>2]=k;g[(c[f>>2]|0)+((c[l>>2]|0)*12&-1)+8>>2]=p;l=(c[f>>2]|0)+((c[m>>2]|0)*12&-1)|0;p=+(w-B*D);g[l>>2]=v-A*D;g[l+4>>2]=p;g[(c[f>>2]|0)+((c[m>>2]|0)*12&-1)+8>>2]=t;return}function e8(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ab=0.0,ac=0.0,ad=0.0,ae=0.0,af=0.0,ag=0.0,ah=0.0,ai=0.0,aj=0.0,ak=0.0,al=0.0,am=0.0,an=0.0,ao=0.0,ap=0.0,aq=0.0,ar=0.0,as=0.0,at=0.0,au=0.0,av=0.0,aw=0.0,ax=0.0,ay=0.0,az=0.0,aA=0.0,aB=0.0,aC=0.0,aD=0.0,aE=0.0,aF=0.0,aG=0.0,aH=0.0,aI=0.0,aJ=0.0,aK=0.0,aL=0.0;e=c[b+48>>2]|0;f=c[e+8>>2]|0;h=b+160|0;c[h>>2]=f;i=c[b+52>>2]|0;j=c[i+8>>2]|0;l=b+164|0;c[l>>2]=j;m=c[b+84>>2]|0;n=c[m+8>>2]|0;o=b+168|0;c[o>>2]=n;p=c[b+88>>2]|0;q=c[p+8>>2]|0;r=b+172|0;c[r>>2]=q;s=e+28|0;t=b+176|0;u=c[s>>2]|0;v=c[s+4>>2]|0;c[t>>2]=u;c[t+4>>2]=v;t=i+28|0;s=b+184|0;w=c[t>>2]|0;x=c[t+4>>2]|0;c[s>>2]=w;c[s+4>>2]=x;s=m+28|0;t=b+192|0;y=c[s>>2]|0;z=c[s+4>>2]|0;c[t>>2]=y;c[t+4>>2]=z;t=p+28|0;s=b+200|0;A=c[t>>2]|0;B=c[t+4>>2]|0;c[s>>2]=A;c[s+4>>2]=B;C=+g[e+120>>2];g[b+208>>2]=C;D=+g[i+120>>2];g[b+212>>2]=D;E=+g[m+120>>2];g[b+216>>2]=E;F=+g[p+120>>2];g[b+220>>2]=F;G=+g[e+128>>2];g[b+224>>2]=G;H=+g[i+128>>2];g[b+228>>2]=H;I=+g[m+128>>2];g[b+232>>2]=I;J=+g[p+128>>2];g[b+236>>2]=J;p=c[d+24>>2]|0;K=+g[p+(f*12&-1)+8>>2];m=d+28|0;i=c[m>>2]|0;e=i+(f*12&-1)|0;L=+g[e>>2];M=+g[e+4>>2];N=+g[i+(f*12&-1)+8>>2];O=+g[p+(j*12&-1)+8>>2];e=i+(j*12&-1)|0;P=+g[e>>2];Q=+g[e+4>>2];T=+g[i+(j*12&-1)+8>>2];U=+g[p+(n*12&-1)+8>>2];j=i+(n*12&-1)|0;V=+g[j>>2];W=+g[j+4>>2];X=+g[i+(n*12&-1)+8>>2];Y=+g[p+(q*12&-1)+8>>2];p=i+(q*12&-1)|0;Z=+g[p>>2];_=+g[p+4>>2];$=+g[i+(q*12&-1)+8>>2];aa=+S(+K);ab=+R(+K);K=+S(+O);ac=+R(+O);O=+S(+U);ad=+R(+U);U=+S(+Y);ae=+R(+Y);q=b+272|0;g[q>>2]=0.0;Y=(c[k>>2]=A,+g[k>>2]);af=(c[k>>2]=B,+g[k>>2]);ag=(c[k>>2]=w,+g[k>>2]);ah=(c[k>>2]=x,+g[k>>2]);if((c[b+76>>2]|0)==1){g[b+240>>2]=0.0;g[b+244>>2]=0.0;g[b+256>>2]=1.0;g[b+264>>2]=1.0;ai=G+I;aj=0.0;ak=0.0;al=1.0;am=1.0}else{an=+g[b+124>>2];ao=+g[b+128>>2];ap=ad*an-O*ao;aq=O*an+ad*ao;ao=+g[b+108>>2]-(c[k>>2]=y,+g[k>>2]);an=+g[b+112>>2]-(c[k>>2]=z,+g[k>>2]);ar=+g[b+92>>2]-(c[k>>2]=u,+g[k>>2]);as=+g[b+96>>2]-(c[k>>2]=v,+g[k>>2]);v=b+240|0;at=+aq;g[v>>2]=ap;g[v+4>>2]=at;at=aq*(ad*ao-O*an)-ap*(O*ao+ad*an);g[b+264>>2]=at;an=aq*(ab*ar-aa*as)-ap*(aa*ar+ab*as);g[b+256>>2]=an;ai=E+C+at*I*at+an*G*an;aj=ap;ak=aq;al=an;am=at}at=ai+0.0;g[q>>2]=at;if((c[b+80>>2]|0)==1){g[b+248>>2]=0.0;g[b+252>>2]=0.0;ai=+g[b+152>>2];g[b+260>>2]=ai;g[b+268>>2]=ai;au=ai*ai*(H+J);av=0.0;aw=0.0;ax=ai;ay=ai}else{ai=+g[b+132>>2];an=+g[b+136>>2];aq=ae*ai-U*an;ap=U*ai+ae*an;an=+g[b+116>>2]-Y;Y=+g[b+120>>2]-af;af=+g[b+100>>2]-ag;ag=+g[b+104>>2]-ah;ah=+g[b+152>>2];ai=aq*ah;as=ap*ah;v=b+248|0;ab=+as;g[v>>2]=ai;g[v+4>>2]=ab;ab=(ap*(ae*an-U*Y)-aq*(U*an+ae*Y))*ah;g[b+268>>2]=ab;Y=ah*(ap*(ac*af-K*ag)-aq*(K*af+ac*ag));g[b+260>>2]=Y;au=ah*ah*(F+D)+ab*J*ab+Y*Y*H;av=ai;aw=as;ax=Y;ay=ab}ab=at+au;g[q>>2]=ab;if(ab>0.0){az=1.0/ab}else{az=0.0}g[q>>2]=az;q=b+156|0;if((a[d+20|0]&1)==0){g[q>>2]=0.0;aA=$;aB=N;aC=X;aD=T;aE=Z;aF=_;aG=V;aH=W;aI=P;aJ=Q;aK=L;aL=M}else{az=+g[q>>2];ab=C*az;C=az*D;D=az*E;E=az*F;aA=$-az*J*ay;aB=N+az*G*al;aC=X-az*I*am;aD=T+az*H*ax;aE=Z-av*E;aF=_-aw*E;aG=V-aj*D;aH=W-ak*D;aI=P+av*C;aJ=Q+C*aw;aK=L+aj*ab;aL=M+ab*ak}q=(c[m>>2]|0)+(f*12&-1)|0;ak=+aL;g[q>>2]=aK;g[q+4>>2]=ak;g[(c[m>>2]|0)+((c[h>>2]|0)*12&-1)+8>>2]=aB;h=(c[m>>2]|0)+((c[l>>2]|0)*12&-1)|0;aB=+aJ;g[h>>2]=aI;g[h+4>>2]=aB;g[(c[m>>2]|0)+((c[l>>2]|0)*12&-1)+8>>2]=aD;l=(c[m>>2]|0)+((c[o>>2]|0)*12&-1)|0;aD=+aH;g[l>>2]=aG;g[l+4>>2]=aD;g[(c[m>>2]|0)+((c[o>>2]|0)*12&-1)+8>>2]=aC;o=(c[m>>2]|0)+((c[r>>2]|0)*12&-1)|0;aC=+aF;g[o>>2]=aE;g[o+4>>2]=aC;g[(c[m>>2]|0)+((c[r>>2]|0)*12&-1)+8>>2]=aA;return}function e9(a){a=a|0;return}function fa(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+48>>2]|0;e=+g[d+24>>2];f=+g[b+92>>2];h=+g[d+20>>2];i=+g[b+96>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function fb(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+52>>2]|0;e=+g[d+24>>2];f=+g[b+100>>2];h=+g[d+20>>2];i=+g[b+104>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function fc(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0,e=0.0;d=+g[b+156>>2];e=d*+g[b+244>>2]*c;g[a>>2]=d*+g[b+240>>2]*c;g[a+4>>2]=e;return}function fd(a,b){a=a|0;b=+b;return+(+g[a+156>>2]*+g[a+256>>2]*b)}function fe(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0,r=0.0,s=0.0,t=0.0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ab=0.0,ac=0.0,ad=0.0,ae=0.0,af=0.0,ag=0.0,ah=0.0,ai=0.0;d=a+160|0;e=c[d>>2]|0;f=b+24|0;b=c[f>>2]|0;h=b+(e*12&-1)|0;i=+g[h>>2];j=+g[h+4>>2];k=+g[b+(e*12&-1)+8>>2];e=a+164|0;l=c[e>>2]|0;m=b+(l*12&-1)|0;n=+g[m>>2];o=+g[m+4>>2];p=+g[b+(l*12&-1)+8>>2];l=a+168|0;m=c[l>>2]|0;q=b+(m*12&-1)|0;r=+g[q>>2];s=+g[q+4>>2];t=+g[b+(m*12&-1)+8>>2];m=a+172|0;q=c[m>>2]|0;u=b+(q*12&-1)|0;v=+g[u>>2];w=+g[u+4>>2];x=+g[b+(q*12&-1)+8>>2];y=+S(+k);z=+R(+k);A=+S(+p);B=+R(+p);C=+S(+t);D=+R(+t);E=+S(+x);F=+R(+x);if((c[a+76>>2]|0)==1){G=+g[a+224>>2];H=+g[a+232>>2];I=G+H;J=1.0;K=1.0;L=k-t- +g[a+140>>2];M=0.0;N=0.0;O=G;P=H}else{H=+g[a+124>>2];G=+g[a+128>>2];Q=D*H-C*G;T=C*H+D*G;U=+g[a+108>>2]- +g[a+192>>2];V=+g[a+112>>2]- +g[a+196>>2];W=+g[a+92>>2]- +g[a+176>>2];X=+g[a+96>>2]- +g[a+180>>2];Y=z*W-y*X;Z=y*W+z*X;X=T*(D*U-C*V)-Q*(C*U+D*V);z=T*Y-Q*Z;W=+g[a+232>>2];y=+g[a+224>>2];_=i-r+Y;Y=j-s+Z;I=+g[a+216>>2]+ +g[a+208>>2]+X*X*W+z*y*z;J=X;K=z;L=H*(D*_+C*Y-U)+G*(_*(-0.0-C)+D*Y-V);M=Q;N=T;O=y;P=W}if((c[a+80>>2]|0)==1){W=+g[a+152>>2];y=+g[a+228>>2];T=+g[a+236>>2];$=W*W*(y+T);aa=W;ab=W;ac=p-x- +g[a+144>>2];ad=0.0;ae=0.0;af=W;ag=y;ah=T}else{T=+g[a+132>>2];y=+g[a+136>>2];W=F*T-E*y;Q=E*T+F*y;V=+g[a+116>>2]- +g[a+200>>2];Y=+g[a+120>>2]- +g[a+204>>2];D=+g[a+100>>2]- +g[a+184>>2];C=+g[a+104>>2]- +g[a+188>>2];_=B*D-A*C;G=A*D+B*C;C=+g[a+152>>2];B=C*(Q*(F*V-E*Y)-W*(E*V+F*Y));D=C*(Q*_-W*G);A=+g[a+236>>2];U=+g[a+228>>2];H=n-v+_;_=o-w+G;$=C*C*(+g[a+220>>2]+ +g[a+212>>2])+B*B*A+D*U*D;aa=B;ab=D;ac=T*(F*H+E*_-V)+y*(H*(-0.0-E)+F*_-Y);ad=W*C;ae=Q*C;af=C;ag=U;ah=A}A=I+0.0+$;if(A>0.0){ai=(-0.0-(L+ac*af- +g[a+148>>2]))/A}else{ai=0.0}A=ai*+g[a+208>>2];af=ai*+g[a+212>>2];ac=ai*+g[a+216>>2];L=ai*+g[a+220>>2];$=+(j+N*A);g[h>>2]=i+M*A;g[h+4>>2]=$;g[(c[f>>2]|0)+((c[d>>2]|0)*12&-1)+8>>2]=k+K*ai*O;d=(c[f>>2]|0)+((c[e>>2]|0)*12&-1)|0;O=+(o+ae*af);g[d>>2]=n+ad*af;g[d+4>>2]=O;g[(c[f>>2]|0)+((c[e>>2]|0)*12&-1)+8>>2]=p+ab*ai*ag;e=(c[f>>2]|0)+((c[l>>2]|0)*12&-1)|0;ag=+(s-N*ac);g[e>>2]=r-M*ac;g[e+4>>2]=ag;g[(c[f>>2]|0)+((c[l>>2]|0)*12&-1)+8>>2]=t-J*ai*P;l=(c[f>>2]|0)+((c[m>>2]|0)*12&-1)|0;P=+(w-ae*L);g[l>>2]=v-ad*L;g[l+4>>2]=P;g[(c[f>>2]|0)+((c[m>>2]|0)*12&-1)+8>>2]=x-aa*ai*ah;return 1}function ff(b){b=b|0;var d=0,e=0,f=0,j=0,k=0;d=i;e=c[(c[b+48>>2]|0)+8>>2]|0;f=c[(c[b+52>>2]|0)+8>>2]|0;j=c[(c[b+68>>2]|0)+56>>2]|0;k=c[(c[b+72>>2]|0)+56>>2]|0;db(6104,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(11336,(u=i,i=i+8|0,c[u>>2]=e,u)|0);db(8808,(u=i,i=i+8|0,c[u>>2]=f,u)|0);db(6768,(u=i,i=i+8|0,c[u>>2]=a[b+61|0]&1,u)|0);db(4568,(u=i,i=i+8|0,c[u>>2]=j,u)|0);db(4296,(u=i,i=i+8|0,c[u>>2]=k,u)|0);db(11504,(u=i,i=i+8|0,h[u>>3]=+g[b+152>>2],u)|0);db(11904,(u=i,i=i+8|0,c[u>>2]=c[b+56>>2],u)|0);i=d;return}function fg(a){a=a|0;vl(a);return}function fh(a){a=a|0;return}function fi(a){a=a|0;a=i;db(6944,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);i=a;return}function fj(a){a=a|0;vl(a);return}function fk(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;e=b|0;f=c[e>>2]|0;if((f|0)==10){h=df(d,168)|0;do{if((h|0)==0){i=0}else{j=h;c[j>>2]=19312;k=b+8|0;l=b+12|0;if((c[k>>2]|0)==(c[l>>2]|0)){ba(7272,173,15744,9072);return 0}else{c[h+4>>2]=c[e>>2];c[h+8>>2]=0;c[h+12>>2]=0;c[h+48>>2]=c[k>>2];c[h+52>>2]=c[l>>2];c[h+56>>2]=0;a[h+61|0]=a[b+16|0]&1;a[h+60|0]=0;c[h+64>>2]=c[b+4>>2];vq(h+16|0,0,32);c[j>>2]=20400;j=b+20|0;l=h+68|0;k=c[j+4>>2]|0;c[l>>2]=c[j>>2];c[l+4>>2]=k;k=b+28|0;l=h+76|0;j=c[k+4>>2]|0;c[l>>2]=c[k>>2];c[l+4>>2]=j;g[h+84>>2]=+g[b+36>>2];g[h+160>>2]=0.0;g[h+92>>2]=0.0;c[h+164>>2]=0;g[h+88>>2]=0.0;i=h;break}}}while(0);m=i|0;return m|0}else if((f|0)==2){i=df(d,256)|0;if((i|0)==0){n=0}else{h=i;fx(h,b);n=h}m=n|0;return m|0}else if((f|0)==3){n=df(d,176)|0;do{if((n|0)==0){o=0}else{h=n;c[h>>2]=19312;i=b+8|0;j=b+12|0;if((c[i>>2]|0)==(c[j>>2]|0)){ba(7272,173,15744,9072);return 0}else{c[n+4>>2]=c[e>>2];c[n+8>>2]=0;c[n+12>>2]=0;c[n+48>>2]=c[i>>2];c[n+52>>2]=c[j>>2];c[n+56>>2]=0;a[n+61|0]=a[b+16|0]&1;a[n+60|0]=0;c[n+64>>2]=c[b+4>>2];vq(n+16|0,0,32);c[h>>2]=19912;h=b+20|0;j=n+80|0;i=c[h+4>>2]|0;c[j>>2]=c[h>>2];c[j+4>>2]=i;i=b+28|0;j=n+88|0;h=c[i+4>>2]|0;c[j>>2]=c[i>>2];c[j+4>>2]=h;g[n+104>>2]=+g[b+36>>2];g[n+68>>2]=+g[b+40>>2];g[n+72>>2]=+g[b+44>>2];g[n+100>>2]=0.0;g[n+96>>2]=0.0;g[n+76>>2]=0.0;o=n;break}}}while(0);m=o|0;return m|0}else if((f|0)==1){o=df(d,228)|0;do{if((o|0)==0){p=0}else{n=o;c[n>>2]=19312;h=b+8|0;j=b+12|0;if((c[h>>2]|0)==(c[j>>2]|0)){ba(7272,173,15744,9072);return 0}else{c[o+4>>2]=c[e>>2];c[o+8>>2]=0;c[o+12>>2]=0;c[o+48>>2]=c[h>>2];c[o+52>>2]=c[j>>2];c[o+56>>2]=0;a[o+61|0]=a[b+16|0]&1;a[o+60|0]=0;c[o+64>>2]=c[b+4>>2];vq(o+16|0,0,32);c[n>>2]=19768;n=b+20|0;j=o+68|0;h=c[n+4>>2]|0;c[j>>2]=c[n>>2];c[j+4>>2]=h;h=b+28|0;j=o+76|0;n=c[h+4>>2]|0;c[j>>2]=c[h>>2];c[j+4>>2]=n;g[o+116>>2]=+g[b+36>>2];vq(o+84|0,0,16);g[o+120>>2]=+g[b+44>>2];g[o+124>>2]=+g[b+48>>2];g[o+104>>2]=+g[b+60>>2];g[o+108>>2]=+g[b+56>>2];a[o+112|0]=a[b+40|0]&1;a[o+100|0]=a[b+52|0]&1;c[o+224>>2]=0;p=o;break}}}while(0);m=p|0;return m|0}else if((f|0)==8){p=df(d,208)|0;do{if((p|0)==0){q=0}else{o=p;c[o>>2]=19312;n=b+8|0;j=b+12|0;if((c[n>>2]|0)==(c[j>>2]|0)){ba(7272,173,15744,9072);return 0}else{c[p+4>>2]=c[e>>2];c[p+8>>2]=0;c[p+12>>2]=0;c[p+48>>2]=c[n>>2];c[p+52>>2]=c[j>>2];c[p+56>>2]=0;a[p+61|0]=a[b+16|0]&1;a[p+60|0]=0;c[p+64>>2]=c[b+4>>2];vq(p+16|0,0,32);c[o>>2]=20344;o=b+20|0;j=p+80|0;n=c[o+4>>2]|0;c[j>>2]=c[o>>2];c[j+4>>2]=n;n=b+28|0;j=p+88|0;o=c[n+4>>2]|0;c[j>>2]=c[n>>2];c[j+4>>2]=o;g[p+96>>2]=+g[b+36>>2];g[p+68>>2]=+g[b+40>>2];g[p+72>>2]=+g[b+44>>2];g[p+104>>2]=0.0;g[p+108>>2]=0.0;g[p+112>>2]=0.0;q=p;break}}}while(0);m=q|0;return m|0}else if((f|0)==7){q=df(d,224)|0;if((q|0)==0){r=0}else{p=q;gn(p,b);r=p}m=r|0;return m|0}else if((f|0)==4){r=df(d,196)|0;if((r|0)==0){s=0}else{p=r;fJ(p,b);s=p}m=s|0;return m|0}else if((f|0)==9){s=df(d,180)|0;do{if((s|0)==0){t=0}else{p=s;c[p>>2]=19312;r=b+8|0;q=b+12|0;if((c[r>>2]|0)==(c[q>>2]|0)){ba(7272,173,15744,9072);return 0}else{c[s+4>>2]=c[e>>2];c[s+8>>2]=0;c[s+12>>2]=0;c[s+48>>2]=c[r>>2];c[s+52>>2]=c[q>>2];c[s+56>>2]=0;a[s+61|0]=a[b+16|0]&1;a[s+60|0]=0;c[s+64>>2]=c[b+4>>2];vq(s+16|0,0,32);c[p>>2]=19856;p=b+20|0;q=s+68|0;r=c[p+4>>2]|0;c[q>>2]=c[p>>2];c[q+4>>2]=r;r=b+28|0;q=s+76|0;p=c[r+4>>2]|0;c[q>>2]=c[r>>2];c[q+4>>2]=p;g[s+84>>2]=0.0;g[s+88>>2]=0.0;g[s+92>>2]=0.0;g[s+96>>2]=+g[b+36>>2];g[s+100>>2]=+g[b+40>>2];t=s;break}}}while(0);m=t|0;return m|0}else if((f|0)==5){t=df(d,168)|0;if((t|0)==0){u=0}else{s=t;fv(s,b);u=s}m=u|0;return m|0}else if((f|0)==6){f=df(d,276)|0;if((f|0)==0){v=0}else{d=f;e6(d,b);v=d}m=v|0;return m|0}else{ba(7272,113,15848,11592);return 0}return 0}function fl(b,d){b=b|0;d=d|0;var e=0,f=0,g=0;bo[c[(c[b>>2]|0)+20>>2]&511](b);e=c[b+4>>2]|0;if((e|0)==7){f=a[22288]|0;if((f&255)>=14){ba(5352,173,17448,6544)}g=d+12+((f&255)<<2)|0;c[b>>2]=c[g>>2];c[g>>2]=b;return}else if((e|0)==6){g=a[22340]|0;if((g&255)>=14){ba(5352,173,17448,6544)}f=d+12+((g&255)<<2)|0;c[b>>2]=c[f>>2];c[f>>2]=b;return}else if((e|0)==2){f=a[22320]|0;if((f&255)>=14){ba(5352,173,17448,6544)}g=d+12+((f&255)<<2)|0;c[b>>2]=c[g>>2];c[g>>2]=b;return}else if((e|0)==3){g=a[22240]|0;if((g&255)>=14){ba(5352,173,17448,6544)}f=d+12+((g&255)<<2)|0;c[b>>2]=c[f>>2];c[f>>2]=b;return}else if((e|0)==9){f=a[22244]|0;if((f&255)>=14){ba(5352,173,17448,6544)}g=d+12+((f&255)<<2)|0;c[b>>2]=c[g>>2];c[g>>2]=b;return}else if((e|0)==8){g=a[22272]|0;if((g&255)>=14){ba(5352,173,17448,6544)}f=d+12+((g&255)<<2)|0;c[b>>2]=c[f>>2];c[f>>2]=b;return}else if((e|0)==1){f=a[22292]|0;if((f&255)>=14){ba(5352,173,17448,6544)}g=d+12+((f&255)<<2)|0;c[b>>2]=c[g>>2];c[g>>2]=b;return}else if((e|0)==4){g=a[22260]|0;if((g&255)>=14){ba(5352,173,17448,6544)}f=d+12+((g&255)<<2)|0;c[b>>2]=c[f>>2];c[f>>2]=b;return}else if((e|0)==5){f=a[22232]|0;if((f&255)>=14){ba(5352,173,17448,6544)}g=d+12+((f&255)<<2)|0;c[b>>2]=c[g>>2];c[g>>2]=b;return}else if((e|0)==10){e=a[22232]|0;if((e&255)>=14){ba(5352,173,17448,6544)}g=d+12+((e&255)<<2)|0;c[b>>2]=c[g>>2];c[g>>2]=b;return}else{ba(7272,166,15784,11592)}}function fm(a,b){a=a|0;b=b|0;return 1}function fn(a){a=a|0;return}function fo(a,b){a=a|0;b=+b;return+(b*0.0)}function fp(a,b){a=a|0;b=b|0;var d=0;d=b+76|0;b=a;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function fq(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+52>>2]|0;e=+g[d+24>>2];f=+g[b+68>>2];h=+g[d+20>>2];i=+g[b+72>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function fr(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0;d=+g[b+100>>2]*c;g[a>>2]=+g[b+96>>2]*c;g[a+4>>2]=d;return}function fs(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0,r=0.0,s=0.0,t=0.0,u=0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0;d=a+116|0;e=c[d>>2]|0;f=b+28|0;h=c[f>>2]|0;i=h+(e*12&-1)|0;j=+g[i>>2];k=+g[i+4>>2];l=+g[h+(e*12&-1)+8>>2];m=+g[a+124>>2];n=+g[a+120>>2];o=+g[a+108>>2];h=a+96|0;i=h|0;p=+g[i>>2];q=a+100|0;r=+g[q>>2];s=-0.0-(j+m*(-0.0-l)+ +g[a+160>>2]+o*p);t=-0.0-(k+l*n+ +g[a+164>>2]+o*r);o=+g[a+148>>2]*s+ +g[a+156>>2]*t;u=h;v=+g[u>>2];w=+g[u+4>>2];x=p+(+g[a+144>>2]*s+ +g[a+152>>2]*t);g[i>>2]=x;t=o+r;g[q>>2]=t;r=+g[b>>2]*+g[a+104>>2];o=t*t+x*x;if(o>r*r){s=r/+P(+o);o=x*s;g[i>>2]=o;r=s*t;g[q>>2]=r;y=o;z=r}else{y=x;z=t}t=y-v;v=z-w;w=+g[a+136>>2];z=l+ +g[a+140>>2]*(v*n-t*m);a=(c[f>>2]|0)+(e*12&-1)|0;m=+(k+v*w);g[a>>2]=j+t*w;g[a+4>>2]=m;g[(c[f>>2]|0)+((c[d>>2]|0)*12&-1)+8>>2]=z;return}function ft(a){a=a|0;a=i;db(5136,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);i=a;return}function fu(a){a=a|0;vl(a);return}function fv(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0.0,j=0,l=0,m=0,n=0,o=0.0,q=0.0,r=0.0,s=0.0;e=b|0;c[e>>2]=19312;f=d+8|0;h=d+12|0;if((c[f>>2]|0)==(c[h>>2]|0)){ba(7272,173,15744,9072)}c[b+4>>2]=c[d>>2];c[b+8>>2]=0;c[b+12>>2]=0;c[b+48>>2]=c[f>>2];f=c[h>>2]|0;c[b+52>>2]=f;c[b+56>>2]=0;a[b+61|0]=a[d+16|0]&1;a[b+60|0]=0;c[b+64>>2]=c[d+4>>2];vq(b+16|0,0,32);c[e>>2]=20240;e=d+20|0;i=+g[e>>2];if(!(i==i&!(C=0.0,C!=C)&i>+-p&i<+p)){ba(7088,34,18312,11528)}i=+g[d+24>>2];if(!(i==i&!(C=0.0,C!=C)&i>+-p&i<+p)){ba(7088,34,18312,11528)}h=d+28|0;i=+g[h>>2];if(i<0.0|i==i&!(C=0.0,C!=C)&i>+-p&i<+p^1){ba(7088,35,18312,9016)}j=d+32|0;i=+g[j>>2];if(i<0.0|i==i&!(C=0.0,C!=C)&i>+-p&i<+p^1){ba(7088,36,18312,6888)}l=d+36|0;i=+g[l>>2];if(i<0.0|i==i&!(C=0.0,C!=C)&i>+-p&i<+p^1){ba(7088,37,18312,6040)}else{d=e;e=b+76|0;m=c[d>>2]|0;n=c[d+4>>2]|0;c[e>>2]=m;c[e+4>>2]=n;i=(c[k>>2]=m,+g[k>>2])- +g[f+12>>2];o=(c[k>>2]=n,+g[k>>2])- +g[f+16>>2];q=+g[f+24>>2];r=+g[f+20>>2];f=b+68|0;s=+(q*o+i*(-0.0-r));g[f>>2]=i*q+o*r;g[f+4>>2]=s;g[b+104>>2]=+g[h>>2];g[b+96>>2]=0.0;g[b+100>>2]=0.0;g[b+84>>2]=+g[j>>2];g[b+88>>2]=+g[l>>2];g[b+92>>2]=0.0;g[b+108>>2]=0.0;return}}function fw(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0;e=c[b+52>>2]|0;f=c[e+8>>2]|0;h=b+116|0;c[h>>2]=f;i=e+28|0;j=b+128|0;l=c[i>>2]|0;m=c[i+4>>2]|0;c[j>>2]=l;c[j+4>>2]=m;n=+g[e+120>>2];g[b+136>>2]=n;o=+g[e+128>>2];g[b+140>>2]=o;j=c[d+24>>2]|0;i=j+(f*12&-1)|0;p=+g[i>>2];q=+g[i+4>>2];r=+g[j+(f*12&-1)+8>>2];j=d+28|0;i=c[j>>2]|0;s=i+(f*12&-1)|0;t=+g[s>>2];u=+g[s+4>>2];v=+g[i+(f*12&-1)+8>>2];w=+S(+r);x=+R(+r);r=+g[e+116>>2];y=+g[b+84>>2]*6.2831854820251465;z=+g[d>>2];A=z*r*y*y;B=y*r*2.0*+g[b+88>>2]+A;r=(c[k>>2]=l,+g[k>>2]);y=(c[k>>2]=m,+g[k>>2]);if(B<=1.1920928955078125e-7){ba(7088,125,18368,5608)}C=z*B;if(C!=0.0){D=1.0/C}else{D=C}g[b+108>>2]=D;C=A*D;g[b+92>>2]=C;A=+g[b+68>>2]-r;r=+g[b+72>>2]-y;y=x*A-w*r;B=w*A+x*r;m=b+120|0;r=+B;g[m>>2]=y;g[m+4>>2]=r;r=D+(n+B*o*B);x=B*y*(-0.0-o);A=D+(n+y*o*y);D=r*A-x*x;if(D!=0.0){E=1.0/D}else{E=D}D=x*(-0.0-E);g[b+144>>2]=A*E;g[b+148>>2]=D;g[b+152>>2]=D;g[b+156>>2]=r*E;m=b+160|0;E=p+y- +g[b+76>>2];p=q+B- +g[b+80>>2];l=m;q=+p;g[l>>2]=E;g[l+4>>2]=q;g[m>>2]=C*E;g[b+164>>2]=C*p;p=v*.9800000190734863;m=b+96|0;if((a[d+20|0]&1)==0){g[m>>2]=0.0;g[b+100>>2]=0.0;F=p;G=t;H=u;I=c[j>>2]|0;J=I+(f*12&-1)|0;K=J;L=(g[k>>2]=G,c[k>>2]|0);M=(g[k>>2]=H,c[k>>2]|0);N=M;O=0;P=0;Q=N;T=L;U=0;V=P|T;W=Q|U;X=K|0;c[X>>2]=V;Y=K+4|0;c[Y>>2]=W;Z=c[h>>2]|0;_=c[j>>2]|0;$=_+(Z*12&-1)+8|0;g[$>>2]=F;return}else{v=+g[d+8>>2];d=m|0;C=v*+g[d>>2];g[d>>2]=C;d=b+100|0;E=v*+g[d>>2];g[d>>2]=E;F=p+o*(E*y-C*B);G=t+n*C;H=u+E*n;I=c[j>>2]|0;J=I+(f*12&-1)|0;K=J;L=(g[k>>2]=G,c[k>>2]|0);M=(g[k>>2]=H,c[k>>2]|0);N=M;O=0;P=0;Q=N;T=L;U=0;V=P|T;W=Q|U;X=K|0;c[X>>2]=V;Y=K+4|0;c[Y>>2]=W;Z=c[h>>2]|0;_=c[j>>2]|0;$=_+(Z*12&-1)+8|0;g[$>>2]=F;return}}function fx(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,l=0.0,m=0.0,n=0.0,o=0.0,p=0.0,q=0.0;e=b|0;c[e>>2]=19312;f=d+8|0;h=d+12|0;if((c[f>>2]|0)==(c[h>>2]|0)){ba(7272,173,15744,9072)}c[b+4>>2]=c[d>>2];c[b+8>>2]=0;c[b+12>>2]=0;c[b+48>>2]=c[f>>2];c[b+52>>2]=c[h>>2];c[b+56>>2]=0;a[b+61|0]=a[d+16|0]&1;a[b+60|0]=0;c[b+64>>2]=c[d+4>>2];vq(b+16|0,0,32);c[e>>2]=19680;e=b+84|0;h=d+20|0;f=b+68|0;i=c[h+4>>2]|0;c[f>>2]=c[h>>2];c[f+4>>2]=i;i=d+28|0;f=b+76|0;h=c[i+4>>2]|0;c[f>>2]=c[i>>2];c[f+4>>2]=h;h=d+36|0;f=e;i=c[h>>2]|0;j=c[h+4>>2]|0;c[f>>2]=i;c[f+4>>2]=j;l=(c[k>>2]=i,+g[k>>2]);m=(c[k>>2]=j,+g[k>>2]);n=+P(+(l*l+m*m));if(n<1.1920928955078125e-7){o=m;p=l}else{q=1.0/n;n=l*q;g[e>>2]=n;l=m*q;g[b+88>>2]=l;o=l;p=n}e=b+92|0;n=+p;g[e>>2]=o*-1.0;g[e+4>>2]=n;g[b+100>>2]=+g[d+44>>2];g[b+252>>2]=0.0;vq(b+104|0,0,16);g[b+120>>2]=+g[d+52>>2];g[b+124>>2]=+g[d+56>>2];g[b+128>>2]=+g[d+64>>2];g[b+132>>2]=+g[d+68>>2];a[b+136|0]=a[d+48|0]&1;a[b+137|0]=a[d+60|0]&1;c[b+140>>2]=0;vq(b+184|0,0,16);return}function fy(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ab=0.0,ac=0.0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0,ao=0,ap=0,aq=0,ar=0,as=0,at=0,au=0,av=0,aw=0,ax=0,ay=0,az=0,aA=0,aB=0,aC=0,aD=0,aE=0,aF=0,aG=0,aH=0,aI=0,aJ=0,aK=0,aL=0,aM=0,aN=0;e=c[b+48>>2]|0;f=c[e+8>>2]|0;h=b+144|0;c[h>>2]=f;i=c[b+52>>2]|0;j=c[i+8>>2]|0;l=b+148|0;c[l>>2]=j;m=e+28|0;n=b+152|0;o=c[m>>2]|0;p=c[m+4>>2]|0;c[n>>2]=o;c[n+4>>2]=p;n=i+28|0;m=b+160|0;q=c[n>>2]|0;r=c[n+4>>2]|0;c[m>>2]=q;c[m+4>>2]=r;s=+g[e+120>>2];g[b+168>>2]=s;t=+g[i+120>>2];g[b+172>>2]=t;u=+g[e+128>>2];g[b+176>>2]=u;v=+g[i+128>>2];g[b+180>>2]=v;i=c[d+24>>2]|0;e=i+(f*12&-1)|0;w=+g[e>>2];x=+g[e+4>>2];y=+g[i+(f*12&-1)+8>>2];e=d+28|0;m=c[e>>2]|0;n=m+(f*12&-1)|0;z=+g[n>>2];A=+g[n+4>>2];B=+g[m+(f*12&-1)+8>>2];n=i+(j*12&-1)|0;C=+g[n>>2];D=+g[n+4>>2];E=+g[i+(j*12&-1)+8>>2];i=m+(j*12&-1)|0;F=+g[i>>2];G=+g[i+4>>2];H=+g[m+(j*12&-1)+8>>2];I=+S(+y);J=+R(+y);y=+S(+E);K=+R(+E);E=+g[b+68>>2]-(c[k>>2]=o,+g[k>>2]);L=+g[b+72>>2]-(c[k>>2]=p,+g[k>>2]);M=J*E-I*L;N=I*E+J*L;L=+g[b+76>>2]-(c[k>>2]=q,+g[k>>2]);E=+g[b+80>>2]-(c[k>>2]=r,+g[k>>2]);O=K*L-y*E;P=y*L+K*E;E=C-w+O-M;w=D-x+P-N;x=+g[b+84>>2];D=+g[b+88>>2];C=J*x-I*D;K=I*x+J*D;r=b+184|0;D=+K;g[r>>2]=C;g[r+4>>2]=D;D=M+E;M=N+w;N=D*K-M*C;g[b+208>>2]=N;x=O*K-P*C;g[b+212>>2]=x;L=s+t;y=u*N;Q=v*x;T=L+N*y+x*Q;if(T>0.0){U=1.0/T}else{U=T}g[b+252>>2]=U;U=+g[b+92>>2];V=+g[b+96>>2];W=J*U-I*V;X=I*U+J*V;r=b+192|0;V=+X;g[r>>2]=W;g[r+4>>2]=V;V=D*X-M*W;g[b+200>>2]=V;M=O*X-P*W;g[b+204>>2]=M;P=u*V;O=v*M;D=P+O;J=P*N+O*x;U=v+u;I=y+Q;g[b+216>>2]=L+V*P+M*O;g[b+220>>2]=D;g[b+224>>2]=J;g[b+228>>2]=D;g[b+232>>2]=U==0.0?1.0:U;g[b+236>>2]=I;g[b+240>>2]=J;g[b+244>>2]=I;g[b+248>>2]=T;do{if((a[b+136|0]&1)==0){c[b+140>>2]=0;g[b+112>>2]=0.0}else{T=E*C+w*K;I=+g[b+124>>2];J=+g[b+120>>2];U=I-J;if(U>0.0){Y=U}else{Y=-0.0-U}if(Y<.009999999776482582){c[b+140>>2]=3;break}if(T<=J){r=b+140|0;if((c[r>>2]|0)==1){break}c[r>>2]=1;g[b+112>>2]=0.0;break}r=b+140|0;if(T>2]=0;g[b+112>>2]=0.0;break}if((c[r>>2]|0)==2){break}c[r>>2]=2;g[b+112>>2]=0.0}}while(0);if((a[b+137|0]&1)==0){g[b+116>>2]=0.0}r=b+104|0;if((a[d+20|0]&1)==0){vq(r|0,0,16);Z=B;_=H;$=F;aa=G;ab=z;ac=A;ad=c[e>>2]|0;ae=ad+(f*12&-1)|0;af=ae;ag=(g[k>>2]=ab,c[k>>2]|0);ah=(g[k>>2]=ac,c[k>>2]|0);ai=ah;aj=0;ak=0;al=ai;am=ag;an=0;ao=ak|am;ap=al|an;aq=af|0;c[aq>>2]=ao;ar=af+4|0;c[ar>>2]=ap;as=c[h>>2]|0;at=c[e>>2]|0;au=at+(as*12&-1)+8|0;g[au>>2]=Z;av=c[l>>2]|0;aw=c[e>>2]|0;ax=aw+(av*12&-1)|0;ay=ax;az=(g[k>>2]=$,c[k>>2]|0);aA=(g[k>>2]=aa,c[k>>2]|0);aB=aA;aC=0;aD=0;aE=aB;aF=az;aG=0;aH=aD|aF;aI=aE|aG;aJ=ay|0;c[aJ>>2]=aH;aK=ay+4|0;c[aK>>2]=aI;aL=c[l>>2]|0;aM=c[e>>2]|0;aN=aM+(aL*12&-1)+8|0;g[aN>>2]=_;return}else{q=d+8|0;Y=+g[q>>2];d=r|0;w=Y*+g[d>>2];g[d>>2]=w;d=b+108|0;E=Y*+g[d>>2];g[d>>2]=E;d=b+112|0;I=Y*+g[d>>2];g[d>>2]=I;d=b+116|0;Y=+g[q>>2]*+g[d>>2];g[d>>2]=Y;T=Y+I;I=w*W+C*T;C=w*X+T*K;Z=B-u*(w*V+E+T*N);_=H+v*(E+w*M+T*x);$=F+t*I;aa=G+t*C;ab=z-s*I;ac=A-s*C;ad=c[e>>2]|0;ae=ad+(f*12&-1)|0;af=ae;ag=(g[k>>2]=ab,c[k>>2]|0);ah=(g[k>>2]=ac,c[k>>2]|0);ai=ah;aj=0;ak=0;al=ai;am=ag;an=0;ao=ak|am;ap=al|an;aq=af|0;c[aq>>2]=ao;ar=af+4|0;c[ar>>2]=ap;as=c[h>>2]|0;at=c[e>>2]|0;au=at+(as*12&-1)+8|0;g[au>>2]=Z;av=c[l>>2]|0;aw=c[e>>2]|0;ax=aw+(av*12&-1)|0;ay=ax;az=(g[k>>2]=$,c[k>>2]|0);aA=(g[k>>2]=aa,c[k>>2]|0);aB=aA;aC=0;aD=0;aE=aB;aF=az;aG=0;aH=aD|aF;aI=aE|aG;aJ=ay|0;c[aJ>>2]=aH;aK=ay+4|0;c[aK>>2]=aI;aL=c[l>>2]|0;aM=c[e>>2]|0;aN=aM+(aL*12&-1)+8|0;g[aN>>2]=_;return}}function fz(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0.0,ac=0.0,ad=0.0,ae=0.0,af=0.0,ag=0.0,ah=0.0,ai=0.0,aj=0.0,ak=0,al=0.0;e=i;i=i+32|0;f=e|0;h=e+16|0;j=b+144|0;k=c[j>>2]|0;l=d+28|0;m=c[l>>2]|0;n=m+(k*12&-1)|0;o=+g[n>>2];p=+g[n+4>>2];q=+g[m+(k*12&-1)+8>>2];n=b+148|0;r=c[n>>2]|0;s=m+(r*12&-1)|0;t=+g[s>>2];u=+g[s+4>>2];v=+g[m+(r*12&-1)+8>>2];w=+g[b+168>>2];x=+g[b+172>>2];y=+g[b+176>>2];z=+g[b+180>>2];do{if((a[b+137|0]&1)==0){A=q;B=v;C=t;D=u;E=o;F=p}else{if((c[b+140>>2]|0)==3){A=q;B=v;C=t;D=u;E=o;F=p;break}G=+g[b+184>>2];H=+g[b+188>>2];I=+g[b+212>>2];J=+g[b+208>>2];r=b+116|0;K=+g[r>>2];L=+g[d>>2]*+g[b+128>>2];M=K+ +g[b+252>>2]*(+g[b+132>>2]-((t-o)*G+(u-p)*H+v*I-q*J));N=-0.0-L;O=M>2]=L;O=L-K;K=G*O;G=H*O;A=q-y*J*O;B=v+z*I*O;C=t+x*K;D=u+x*G;E=o-w*K;F=p-w*G}}while(0);p=C-E;o=D-F;d=b+192|0;u=+g[d>>2];r=b+196|0;t=+g[r>>2];m=b+204|0;v=+g[m>>2];s=b+200|0;q=+g[s>>2];G=p*u+o*t+B*v-A*q;K=B-A;do{if((a[b+136|0]&1)==0){P=2813}else{Q=b+140|0;if((c[Q>>2]|0)==0){P=2813;break}R=b+184|0;S=b+188|0;T=b+212|0;U=b+208|0;V=b+104|0;O=+g[V>>2];W=b+108|0;I=+g[W>>2];X=b+112|0;J=+g[X>>2];Y=b+216|0;H=-0.0-G;L=-0.0-K;N=-0.0-(p*+g[R>>2]+o*+g[S>>2]+B*+g[T>>2]-A*+g[U>>2]);g[h>>2]=H;g[h+4>>2]=L;g[h+8>>2]=N;c8(f,Y,h);Z=f|0;g[V>>2]=+g[Z>>2]+ +g[V>>2];_=f+4|0;g[W>>2]=+g[_>>2]+ +g[W>>2];$=f+8|0;N=+g[$>>2]+ +g[X>>2];g[X>>2]=N;aa=c[Q>>2]|0;if((aa|0)==2){M=N<0.0?N:0.0;g[X>>2]=M;ab=M}else if((aa|0)==1){M=N>0.0?N:0.0;g[X>>2]=M;ab=M}else{ab=N}N=ab-J;J=H- +g[b+240>>2]*N;H=L-N*+g[b+244>>2];L=+g[Y>>2];M=+g[b+228>>2];ac=+g[b+220>>2];ad=+g[b+232>>2];ae=L*ad-M*ac;if(ae!=0.0){af=1.0/ae}else{af=ae}ae=O+(J*ad-M*H)*af;M=I+(L*H-J*ac)*af;g[V>>2]=ae;g[W>>2]=M;ac=ae-O;O=M-I;g[Z>>2]=ac;g[_>>2]=O;g[$>>2]=N;ag=O+ac*+g[m>>2]+N*+g[T>>2];ah=ac*+g[s>>2]+O+N*+g[U>>2];ai=ac*+g[r>>2]+N*+g[S>>2];aj=ac*+g[d>>2]+N*+g[R>>2];ak=c[j>>2]|0}}while(0);if((P|0)==2813){af=-0.0-G;G=-0.0-K;K=+g[b+216>>2];ab=+g[b+228>>2];o=+g[b+220>>2];p=+g[b+232>>2];N=K*p-ab*o;if(N!=0.0){al=1.0/N}else{al=N}N=(p*af-ab*G)*al;ab=(K*G-o*af)*al;P=b+104|0;g[P>>2]=+g[P>>2]+N;P=b+108|0;g[P>>2]=ab+ +g[P>>2];ag=ab+N*v;ah=ab+N*q;ai=N*t;aj=N*u;ak=k}k=(c[l>>2]|0)+(ak*12&-1)|0;u=+(F-w*ai);g[k>>2]=E-w*aj;g[k+4>>2]=u;g[(c[l>>2]|0)+((c[j>>2]|0)*12&-1)+8>>2]=A-y*ah;j=(c[l>>2]|0)+((c[n>>2]|0)*12&-1)|0;ah=+(D+x*ai);g[j>>2]=C+x*aj;g[j+4>>2]=ah;g[(c[l>>2]|0)+((c[n>>2]|0)*12&-1)+8>>2]=B+z*ag;i=e;return}function fA(a){a=a|0;return}function fB(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+48>>2]|0;e=+g[d+24>>2];f=+g[b+68>>2];h=+g[d+20>>2];i=+g[b+72>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function fC(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+52>>2]|0;e=+g[d+24>>2];f=+g[b+76>>2];h=+g[d+20>>2];i=+g[b+80>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function fD(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0,e=0.0,f=0.0;d=+g[b+104>>2];e=+g[b+116>>2]+ +g[b+112>>2];f=(d*+g[b+196>>2]+e*+g[b+188>>2])*c;g[a>>2]=(d*+g[b+192>>2]+ +g[b+184>>2]*e)*c;g[a+4>>2]=f;return}function fE(a,b){a=a|0;b=+b;return+(+g[a+108>>2]*b)}function fF(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0.0,k=0.0,l=0.0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0,P=0.0,Q=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0;e=b+144|0;f=c[e>>2]|0;h=d+24|0;d=c[h>>2]|0;i=d+(f*12&-1)|0;j=+g[i>>2];k=+g[i+4>>2];l=+g[d+(f*12&-1)+8>>2];f=b+148|0;m=c[f>>2]|0;n=d+(m*12&-1)|0;o=+g[n>>2];p=+g[n+4>>2];q=+g[d+(m*12&-1)+8>>2];r=+S(+l);s=+R(+l);t=+S(+q);u=+R(+q);v=+g[b+168>>2];w=+g[b+172>>2];x=+g[b+176>>2];y=+g[b+180>>2];z=+g[b+68>>2]- +g[b+152>>2];A=+g[b+72>>2]- +g[b+156>>2];B=s*z-r*A;C=r*z+s*A;A=+g[b+76>>2]- +g[b+160>>2];z=+g[b+80>>2]- +g[b+164>>2];D=u*A-t*z;E=t*A+u*z;z=o+D-j-B;u=p+E-k-C;A=+g[b+84>>2];t=+g[b+88>>2];F=s*A-r*t;G=r*A+s*t;t=B+z;B=C+u;C=G*t-F*B;A=D*G-E*F;H=+g[b+92>>2];I=+g[b+96>>2];J=s*H-r*I;K=r*H+s*I;I=K*t-J*B;B=D*K-E*J;E=J*z+K*u;D=q-l- +g[b+100>>2];if(E>0.0){L=E}else{L=-0.0-E}if(D>0.0){M=D}else{M=-0.0-D}do{if((a[b+136|0]&1)==0){N=L;O=0;P=0.0}else{t=F*z+G*u;s=+g[b+124>>2];H=+g[b+120>>2];r=s-H;if(r>0.0){Q=r}else{Q=-0.0-r}if(Q<.009999999776482582){r=t<.20000000298023224?t:.20000000298023224;if(t>0.0){T=t}else{T=-0.0-t}N=L>T?L:T;O=1;P=r<-.20000000298023224?-.20000000298023224:r;break}if(t<=H){r=t-H+.004999999888241291;U=r<0.0?r:0.0;r=H-t;N=L>r?L:r;O=1;P=U<-.20000000298023224?-.20000000298023224:U;break}if(tU?L:U;O=1;P=t<0.0?0.0:t}}while(0);L=v+w;T=x*I;Q=y*B;u=B*Q+(L+I*T);z=Q+T;if(O){t=A*Q+C*T;T=x+y;Q=T==0.0?1.0:T;T=x*C;U=y*A;s=U+T;r=A*U+(L+C*T);T=-0.0-E;L=-0.0-D;U=-0.0-P;P=Q*r-s*s;H=s*t-z*r;V=s*z-Q*t;W=t*V+(u*P+z*H);if(W!=0.0){X=1.0/W}else{X=W}W=s*T;Y=(P*T+H*L+V*U)*X;Z=(t*(W-t*L)+(u*(r*L-s*U)+z*(t*U-r*T)))*X;_=(t*(z*L-Q*T)+(u*(Q*U-s*L)+z*(W-z*U)))*X}else{X=x+y;U=X==0.0?1.0:X;X=-0.0-E;E=-0.0-D;D=U*u-z*z;if(D!=0.0){$=1.0/D}else{$=D}Y=(U*X-z*E)*$;Z=(u*E-z*X)*$;_=0.0}$=F*_+J*Y;J=G*_+K*Y;K=+(k-v*J);g[i>>2]=j-v*$;g[i+4>>2]=K;g[(c[h>>2]|0)+((c[e>>2]|0)*12&-1)+8>>2]=l-x*(C*_+(Z+I*Y));e=(c[h>>2]|0)+((c[f>>2]|0)*12&-1)|0;I=+(p+w*J);g[e>>2]=o+w*$;g[e+4>>2]=I;g[(c[h>>2]|0)+((c[f>>2]|0)*12&-1)+8>>2]=q+y*(A*_+(Z+B*Y));if(N>.004999999888241291){aa=0;return aa|0}aa=M<=.03490658849477768;return aa|0}function fG(b){b=b|0;var d=0,e=0,f=0,j=0.0;d=i;e=c[(c[b+48>>2]|0)+8>>2]|0;f=c[(c[b+52>>2]|0)+8>>2]|0;db(8984,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(11336,(u=i,i=i+8|0,c[u>>2]=e,u)|0);db(8808,(u=i,i=i+8|0,c[u>>2]=f,u)|0);db(6768,(u=i,i=i+8|0,c[u>>2]=a[b+61|0]&1,u)|0);j=+g[b+72>>2];db(5992,(u=i,i=i+16|0,h[u>>3]=+g[b+68>>2],h[u+8>>3]=j,u)|0);j=+g[b+80>>2];db(5536,(u=i,i=i+16|0,h[u>>3]=+g[b+76>>2],h[u+8>>3]=j,u)|0);j=+g[b+88>>2];db(5032,(u=i,i=i+16|0,h[u>>3]=+g[b+84>>2],h[u+8>>3]=j,u)|0);db(5072,(u=i,i=i+8|0,h[u>>3]=+g[b+100>>2],u)|0);db(4264,(u=i,i=i+8|0,c[u>>2]=a[b+136|0]&1,u)|0);db(12568,(u=i,i=i+8|0,h[u>>3]=+g[b+120>>2],u)|0);db(11984,(u=i,i=i+8|0,h[u>>3]=+g[b+124>>2],u)|0);db(4760,(u=i,i=i+8|0,c[u>>2]=a[b+137|0]&1,u)|0);db(4488,(u=i,i=i+8|0,h[u>>3]=+g[b+132>>2],u)|0);db(11064,(u=i,i=i+8|0,h[u>>3]=+g[b+128>>2],u)|0);db(11904,(u=i,i=i+8|0,c[u>>2]=c[b+56>>2],u)|0);i=d;return}function fH(a){a=a|0;vl(a);return}function fI(a,b,d,e,f,h,i,j){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;h=h|0;i=i|0;j=+j;var k=0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0;c[a+8>>2]=b;c[a+12>>2]=d;k=e;l=a+20|0;m=c[k+4>>2]|0;c[l>>2]=c[k>>2];c[l+4>>2]=m;m=f;l=a+28|0;k=c[m+4>>2]|0;c[l>>2]=c[m>>2];c[l+4>>2]=k;k=h|0;n=+g[k>>2]- +g[b+12>>2];l=h+4|0;o=+g[l>>2]- +g[b+16>>2];p=+g[b+24>>2];q=+g[b+20>>2];b=a+36|0;r=+(p*o+n*(-0.0-q));g[b>>2]=n*p+o*q;g[b+4>>2]=r;b=i|0;r=+g[b>>2]- +g[d+12>>2];h=i+4|0;q=+g[h>>2]- +g[d+16>>2];o=+g[d+24>>2];p=+g[d+20>>2];d=a+44|0;n=+(o*q+r*(-0.0-p));g[d>>2]=r*o+q*p;g[d+4>>2]=n;n=+g[k>>2]- +g[e>>2];p=+g[l>>2]- +g[e+4>>2];g[a+52>>2]=+P(+(n*n+p*p));p=+g[b>>2]- +g[f>>2];n=+g[h>>2]- +g[f+4>>2];g[a+56>>2]=+P(+(p*p+n*n));g[a+60>>2]=j;if(j>1.1920928955078125e-7){return}else{ba(6632,51,17120,11480)}}function fJ(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0.0;e=b|0;c[e>>2]=19312;f=d+8|0;h=d+12|0;if((c[f>>2]|0)==(c[h>>2]|0)){ba(7272,173,15744,9072)}c[b+4>>2]=c[d>>2];c[b+8>>2]=0;c[b+12>>2]=0;c[b+48>>2]=c[f>>2];c[b+52>>2]=c[h>>2];c[b+56>>2]=0;a[b+61|0]=a[d+16|0]&1;a[b+60|0]=0;c[b+64>>2]=c[d+4>>2];vq(b+16|0,0,32);c[e>>2]=20080;e=d+20|0;h=b+68|0;f=c[e+4>>2]|0;c[h>>2]=c[e>>2];c[h+4>>2]=f;f=d+28|0;h=b+76|0;e=c[f+4>>2]|0;c[h>>2]=c[f>>2];c[h+4>>2]=e;e=d+36|0;h=b+92|0;f=c[e+4>>2]|0;c[h>>2]=c[e>>2];c[h+4>>2]=f;f=d+44|0;h=b+100|0;e=c[f+4>>2]|0;c[h>>2]=c[f>>2];c[h+4>>2]=e;e=d+52|0;g[b+84>>2]=+g[e>>2];h=d+56|0;g[b+88>>2]=+g[h>>2];i=+g[d+60>>2];if(i!=0.0){g[b+112>>2]=i;g[b+108>>2]=+g[e>>2]+i*+g[h>>2];g[b+116>>2]=0.0;return}else{ba(6632,65,17984,8960)}}function fK(a,b){a=a|0;b=+b;return+0.0}function fL(a){a=a|0;return}function fM(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0;d=a+120|0;e=c[d>>2]|0;f=b+28|0;b=c[f>>2]|0;h=b+(e*12&-1)|0;i=+g[h>>2];j=+g[h+4>>2];k=+g[b+(e*12&-1)+8>>2];h=a+124|0;l=c[h>>2]|0;m=b+(l*12&-1)|0;n=+g[m>>2];o=+g[m+4>>2];p=+g[b+(l*12&-1)+8>>2];q=+g[a+148>>2];r=+g[a+144>>2];s=+g[a+156>>2];t=+g[a+152>>2];u=+g[a+128>>2];v=+g[a+132>>2];w=+g[a+112>>2];x=+g[a+136>>2];y=+g[a+140>>2];z=(-0.0-((i+q*(-0.0-k))*u+(j+k*r)*v)-w*((n+s*(-0.0-p))*x+(o+p*t)*y))*(-0.0- +g[a+192>>2]);l=a+116|0;g[l>>2]=+g[l>>2]+z;A=-0.0-z;B=u*A;u=v*A;A=z*(-0.0-w);w=x*A;x=y*A;A=+g[a+176>>2];y=k+ +g[a+184>>2]*(u*r-B*q);q=+g[a+180>>2];r=p+ +g[a+188>>2]*(x*t-w*s);a=(c[f>>2]|0)+(e*12&-1)|0;s=+(j+u*A);g[a>>2]=i+B*A;g[a+4>>2]=s;g[(c[f>>2]|0)+((c[d>>2]|0)*12&-1)+8>>2]=y;d=(c[f>>2]|0)+((c[h>>2]|0)*12&-1)|0;y=+(o+x*q);g[d>>2]=n+w*q;g[d+4>>2]=y;g[(c[f>>2]|0)+((c[h>>2]|0)*12&-1)+8>>2]=r;return}function fN(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+48>>2]|0;e=+g[d+24>>2];f=+g[b+92>>2];h=+g[d+20>>2];i=+g[b+96>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function fO(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+52>>2]|0;e=+g[d+24>>2];f=+g[b+100>>2];h=+g[d+20>>2];i=+g[b+104>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function fP(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0,e=0.0;d=+g[b+116>>2];e=d*+g[b+140>>2]*c;g[a>>2]=d*+g[b+136>>2]*c;g[a+4>>2]=e;return}function fQ(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,Q=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0,ao=0,ap=0,aq=0,ar=0,as=0,at=0,au=0,av=0,aw=0,ax=0,ay=0,az=0,aA=0,aB=0,aC=0,aD=0,aE=0,aF=0,aG=0,aH=0,aI=0,aJ=0,aK=0;e=c[b+48>>2]|0;f=c[e+8>>2]|0;h=b+120|0;c[h>>2]=f;i=c[b+52>>2]|0;j=c[i+8>>2]|0;l=b+124|0;c[l>>2]=j;m=e+28|0;n=b+160|0;o=c[m>>2]|0;p=c[m+4>>2]|0;c[n>>2]=o;c[n+4>>2]=p;n=i+28|0;m=b+168|0;q=c[n>>2]|0;r=c[n+4>>2]|0;c[m>>2]=q;c[m+4>>2]=r;s=+g[e+120>>2];g[b+176>>2]=s;t=+g[i+120>>2];g[b+180>>2]=t;u=+g[e+128>>2];g[b+184>>2]=u;v=+g[i+128>>2];g[b+188>>2]=v;i=c[d+24>>2]|0;e=i+(f*12&-1)|0;w=+g[e>>2];x=+g[e+4>>2];y=+g[i+(f*12&-1)+8>>2];e=d+28|0;m=c[e>>2]|0;n=m+(f*12&-1)|0;z=+g[n>>2];A=+g[n+4>>2];B=+g[m+(f*12&-1)+8>>2];n=i+(j*12&-1)|0;C=+g[n>>2];D=+g[n+4>>2];E=+g[i+(j*12&-1)+8>>2];i=m+(j*12&-1)|0;F=+g[i>>2];G=+g[i+4>>2];H=+g[m+(j*12&-1)+8>>2];I=+S(+y);J=+R(+y);y=+S(+E);K=+R(+E);E=+g[b+92>>2]-(c[k>>2]=o,+g[k>>2]);L=+g[b+96>>2]-(c[k>>2]=p,+g[k>>2]);M=J*E-I*L;N=I*E+J*L;p=b+144|0;L=+N;g[p>>2]=M;g[p+4>>2]=L;L=+g[b+100>>2]-(c[k>>2]=q,+g[k>>2]);J=+g[b+104>>2]-(c[k>>2]=r,+g[k>>2]);E=K*L-y*J;I=y*L+K*J;r=b+152|0;J=+I;g[r>>2]=E;g[r+4>>2]=J;r=b+128|0;J=w+M- +g[b+68>>2];w=x+N- +g[b+72>>2];q=r;x=+w;g[q>>2]=J;g[q+4>>2]=x;q=b+136|0;x=C+E- +g[b+76>>2];C=D+I- +g[b+80>>2];p=q;D=+C;g[p>>2]=x;g[p+4>>2]=D;p=r|0;D=+P(+(J*J+w*w));r=q|0;K=+P(+(x*x+C*C));if(D>.04999999701976776){L=1.0/D;D=J*L;g[p>>2]=D;O=L*w;Q=D}else{g[p>>2]=0.0;O=0.0;Q=0.0}g[b+132>>2]=O;if(K>.04999999701976776){D=1.0/K;K=D*x;g[r>>2]=K;T=D*C;U=K}else{g[r>>2]=0.0;T=0.0;U=0.0}g[b+140>>2]=T;K=M*O-N*Q;C=E*T-I*U;D=+g[b+112>>2];x=s+K*K*u+D*D*(t+C*C*v);if(x>0.0){V=1.0/x}else{V=x}g[b+192>>2]=V;if((a[d+20|0]&1)==0){g[b+116>>2]=0.0;W=B;X=H;Y=F;Z=G;_=z;$=A;aa=c[e>>2]|0;ab=aa+(f*12&-1)|0;ac=ab;ad=(g[k>>2]=_,c[k>>2]|0);ae=(g[k>>2]=$,c[k>>2]|0);af=ae;ag=0;ah=0;ai=af;aj=ad;ak=0;al=ah|aj;am=ai|ak;an=ac|0;c[an>>2]=al;ao=ac+4|0;c[ao>>2]=am;ap=c[h>>2]|0;aq=c[e>>2]|0;ar=aq+(ap*12&-1)+8|0;g[ar>>2]=W;as=c[l>>2]|0;at=c[e>>2]|0;au=at+(as*12&-1)|0;av=au;aw=(g[k>>2]=Y,c[k>>2]|0);ax=(g[k>>2]=Z,c[k>>2]|0);ay=ax;az=0;aA=0;aB=ay;aC=aw;aD=0;aE=aA|aC;aF=aB|aD;aG=av|0;c[aG>>2]=aE;aH=av+4|0;c[aH>>2]=aF;aI=c[l>>2]|0;aJ=c[e>>2]|0;aK=aJ+(aI*12&-1)+8|0;g[aK>>2]=X;return}else{r=b+116|0;V=+g[d+8>>2]*+g[r>>2];g[r>>2]=V;x=-0.0-V;C=Q*x;Q=O*x;x=V*(-0.0-D);D=U*x;U=T*x;W=B+u*(Q*M-C*N);X=H+v*(U*E-D*I);Y=F+D*t;Z=G+U*t;_=z+C*s;$=A+Q*s;aa=c[e>>2]|0;ab=aa+(f*12&-1)|0;ac=ab;ad=(g[k>>2]=_,c[k>>2]|0);ae=(g[k>>2]=$,c[k>>2]|0);af=ae;ag=0;ah=0;ai=af;aj=ad;ak=0;al=ah|aj;am=ai|ak;an=ac|0;c[an>>2]=al;ao=ac+4|0;c[ao>>2]=am;ap=c[h>>2]|0;aq=c[e>>2]|0;ar=aq+(ap*12&-1)+8|0;g[ar>>2]=W;as=c[l>>2]|0;at=c[e>>2]|0;au=at+(as*12&-1)|0;av=au;aw=(g[k>>2]=Y,c[k>>2]|0);ax=(g[k>>2]=Z,c[k>>2]|0);ay=ax;az=0;aA=0;aB=ay;aC=aw;aD=0;aE=aA|aC;aF=aB|aD;aG=av|0;c[aG>>2]=aE;aH=av+4|0;c[aH>>2]=aF;aI=c[l>>2]|0;aJ=c[e>>2]|0;aK=aJ+(aI*12&-1)+8|0;g[aK>>2]=X;return}}function fR(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0;d=a+120|0;e=c[d>>2]|0;f=b+24|0;b=c[f>>2]|0;h=b+(e*12&-1)|0;i=+g[h>>2];j=+g[h+4>>2];k=+g[b+(e*12&-1)+8>>2];e=a+124|0;l=c[e>>2]|0;m=b+(l*12&-1)|0;n=+g[m>>2];o=+g[m+4>>2];p=+g[b+(l*12&-1)+8>>2];q=+S(+k);r=+R(+k);s=+S(+p);t=+R(+p);u=+g[a+92>>2]- +g[a+160>>2];v=+g[a+96>>2]- +g[a+164>>2];w=r*u-q*v;x=q*u+r*v;v=+g[a+100>>2]- +g[a+168>>2];r=+g[a+104>>2]- +g[a+172>>2];u=t*v-s*r;q=s*v+t*r;r=i+w- +g[a+68>>2];t=j+x- +g[a+72>>2];v=n+u- +g[a+76>>2];s=o+q- +g[a+80>>2];y=+P(+(r*r+t*t));z=+P(+(v*v+s*s));if(y>.04999999701976776){A=1.0/y;B=r*A;C=t*A}else{B=0.0;C=0.0}if(z>.04999999701976776){A=1.0/z;D=v*A;E=s*A}else{D=0.0;E=0.0}A=w*C-x*B;s=u*E-q*D;v=+g[a+176>>2];t=+g[a+184>>2];r=+g[a+180>>2];F=+g[a+188>>2];G=+g[a+112>>2];H=v+A*A*t+G*G*(r+s*s*F);if(H>0.0){I=1.0/H}else{I=H}H=+g[a+108>>2]-y-z*G;if(H>0.0){J=H}else{J=-0.0-H}z=H*(-0.0-I);I=-0.0-z;H=B*I;B=C*I;I=z*(-0.0-G);G=D*I;D=E*I;I=+(j+B*v);g[h>>2]=i+H*v;g[h+4>>2]=I;g[(c[f>>2]|0)+((c[d>>2]|0)*12&-1)+8>>2]=k+(w*B-x*H)*t;d=(c[f>>2]|0)+((c[e>>2]|0)*12&-1)|0;t=+(o+D*r);g[d>>2]=n+G*r;g[d+4>>2]=t;g[(c[f>>2]|0)+((c[e>>2]|0)*12&-1)+8>>2]=p+F*(u*D-q*G);return J<.004999999888241291|0}function fS(b){b=b|0;var d=0,e=0,f=0,j=0.0;d=i;e=c[(c[b+48>>2]|0)+8>>2]|0;f=c[(c[b+52>>2]|0)+8>>2]|0;db(6808,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(11336,(u=i,i=i+8|0,c[u>>2]=e,u)|0);db(8808,(u=i,i=i+8|0,c[u>>2]=f,u)|0);db(6768,(u=i,i=i+8|0,c[u>>2]=a[b+61|0]&1,u)|0);j=+g[b+72>>2];db(4792,(u=i,i=i+16|0,h[u>>3]=+g[b+68>>2],h[u+8>>3]=j,u)|0);j=+g[b+80>>2];db(4520,(u=i,i=i+16|0,h[u>>3]=+g[b+76>>2],h[u+8>>3]=j,u)|0);j=+g[b+96>>2];db(5992,(u=i,i=i+16|0,h[u>>3]=+g[b+92>>2],h[u+8>>3]=j,u)|0);j=+g[b+104>>2];db(5536,(u=i,i=i+16|0,h[u>>3]=+g[b+100>>2],h[u+8>>3]=j,u)|0);db(12536,(u=i,i=i+8|0,h[u>>3]=+g[b+84>>2],u)|0);db(11952,(u=i,i=i+8|0,h[u>>3]=+g[b+88>>2],u)|0);db(11504,(u=i,i=i+8|0,h[u>>3]=+g[b+112>>2],u)|0);db(11904,(u=i,i=i+8|0,c[u>>2]=c[b+56>>2],u)|0);i=d;return}function fT(a){a=a|0;vl(a);return}function fU(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0,ao=0,ap=0,aq=0,ar=0,as=0,at=0,au=0,av=0,aw=0,ax=0,ay=0,az=0,aA=0,aB=0,aC=0,aD=0,aE=0,aF=0;e=c[b+48>>2]|0;f=c[e+8>>2]|0;h=b+128|0;c[h>>2]=f;i=c[b+52>>2]|0;j=c[i+8>>2]|0;l=b+132|0;c[l>>2]=j;m=e+28|0;n=b+152|0;o=c[m>>2]|0;p=c[m+4>>2]|0;c[n>>2]=o;c[n+4>>2]=p;n=i+28|0;m=b+160|0;q=c[n>>2]|0;r=c[n+4>>2]|0;c[m>>2]=q;c[m+4>>2]=r;s=+g[e+120>>2];g[b+168>>2]=s;t=+g[i+120>>2];g[b+172>>2]=t;u=+g[e+128>>2];g[b+176>>2]=u;v=+g[i+128>>2];g[b+180>>2]=v;i=c[d+24>>2]|0;w=+g[i+(f*12&-1)+8>>2];e=d+28|0;m=c[e>>2]|0;n=m+(f*12&-1)|0;x=+g[n>>2];y=+g[n+4>>2];z=+g[m+(f*12&-1)+8>>2];A=+g[i+(j*12&-1)+8>>2];i=m+(j*12&-1)|0;B=+g[i>>2];C=+g[i+4>>2];D=+g[m+(j*12&-1)+8>>2];E=+S(+w);F=+R(+w);G=+S(+A);H=+R(+A);I=+g[b+68>>2]-(c[k>>2]=o,+g[k>>2]);J=+g[b+72>>2]-(c[k>>2]=p,+g[k>>2]);K=F*I-E*J;L=E*I+F*J;p=b+136|0;J=+L;g[p>>2]=K;g[p+4>>2]=J;J=+g[b+76>>2]-(c[k>>2]=q,+g[k>>2]);F=+g[b+80>>2]-(c[k>>2]=r,+g[k>>2]);I=H*J-G*F;E=G*J+H*F;r=b+144|0;F=+E;g[r>>2]=I;g[r+4>>2]=F;F=u+v;r=F==0.0;H=s+t;g[b+184>>2]=H+u*L*L+v*E*E;J=-0.0-L;G=u*K*J-v*E*I;g[b+196>>2]=G;M=u*J-v*E;g[b+208>>2]=M;g[b+188>>2]=G;g[b+200>>2]=H+u*K*K+v*I*I;H=u*K+v*I;g[b+212>>2]=H;g[b+192>>2]=M;g[b+204>>2]=H;g[b+216>>2]=F;if(F>0.0){N=1.0/F}else{N=F}g[b+220>>2]=N;if((a[b+100|0]&1)==0|r){g[b+96>>2]=0.0}do{if((a[b+112|0]&1)==0|r){c[b+224>>2]=0}else{N=A-w- +g[b+116>>2];F=+g[b+124>>2];H=+g[b+120>>2];M=F-H;if(M>0.0){O=M}else{O=-0.0-M}if(O<.06981317698955536){c[b+224>>2]=3;break}if(N<=H){q=b+224|0;if((c[q>>2]|0)!=1){g[b+92>>2]=0.0}c[q>>2]=1;break}q=b+224|0;if(N>2]=0;g[b+92>>2]=0.0;break}if((c[q>>2]|0)!=2){g[b+92>>2]=0.0}c[q>>2]=2}}while(0);r=b+84|0;if((a[d+20|0]&1)==0){vq(r|0,0,16);P=z;Q=D;T=B;U=C;V=x;W=y;X=c[e>>2]|0;Y=X+(f*12&-1)|0;Z=Y;_=(g[k>>2]=V,c[k>>2]|0);$=(g[k>>2]=W,c[k>>2]|0);aa=$;ab=0;ac=0;ad=aa;ae=_;af=0;ag=ac|ae;ah=ad|af;ai=Z|0;c[ai>>2]=ag;aj=Z+4|0;c[aj>>2]=ah;ak=c[h>>2]|0;al=c[e>>2]|0;am=al+(ak*12&-1)+8|0;g[am>>2]=P;an=c[l>>2]|0;ao=c[e>>2]|0;ap=ao+(an*12&-1)|0;aq=ap;ar=(g[k>>2]=T,c[k>>2]|0);as=(g[k>>2]=U,c[k>>2]|0);at=as;au=0;av=0;aw=at;ax=ar;ay=0;az=av|ax;aA=aw|ay;aB=aq|0;c[aB>>2]=az;aC=aq+4|0;c[aC>>2]=aA;aD=c[l>>2]|0;aE=c[e>>2]|0;aF=aE+(aD*12&-1)+8|0;g[aF>>2]=Q;return}else{q=d+8|0;O=+g[q>>2];d=r|0;w=O*+g[d>>2];g[d>>2]=w;d=b+88|0;A=O*+g[d>>2];g[d>>2]=A;d=b+92|0;F=O*+g[d>>2];g[d>>2]=F;d=b+96|0;O=+g[q>>2]*+g[d>>2];g[d>>2]=O;P=z-u*(F+(O+(A*K-w*L)));Q=D+v*(F+(O+(A*I-w*E)));T=B+t*w;U=C+t*A;V=x-s*w;W=y-s*A;X=c[e>>2]|0;Y=X+(f*12&-1)|0;Z=Y;_=(g[k>>2]=V,c[k>>2]|0);$=(g[k>>2]=W,c[k>>2]|0);aa=$;ab=0;ac=0;ad=aa;ae=_;af=0;ag=ac|ae;ah=ad|af;ai=Z|0;c[ai>>2]=ag;aj=Z+4|0;c[aj>>2]=ah;ak=c[h>>2]|0;al=c[e>>2]|0;am=al+(ak*12&-1)+8|0;g[am>>2]=P;an=c[l>>2]|0;ao=c[e>>2]|0;ap=ao+(an*12&-1)|0;aq=ap;ar=(g[k>>2]=T,c[k>>2]|0);as=(g[k>>2]=U,c[k>>2]|0);at=as;au=0;av=0;aw=at;ax=ar;ay=0;az=av|ax;aA=aw|ay;aB=aq|0;c[aB>>2]=az;aC=aq+4|0;c[aC>>2]=aA;aD=c[l>>2]|0;aE=c[e>>2]|0;aF=aE+(aD*12&-1)+8|0;g[aF>>2]=Q;return}}function fV(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0,s=0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0,I=0,J=0,K=0,L=0.0,M=0,N=0.0,O=0.0,P=0.0,Q=0,R=0.0,S=0.0,T=0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ab=0.0,ac=0.0,ad=0.0,ae=0,af=0.0;e=i;i=i+32|0;f=e|0;h=e+16|0;j=b+128|0;k=c[j>>2]|0;l=d+28|0;m=c[l>>2]|0;n=m+(k*12&-1)|0;o=+g[n>>2];p=+g[n+4>>2];q=+g[m+(k*12&-1)+8>>2];n=b+132|0;r=c[n>>2]|0;s=m+(r*12&-1)|0;t=+g[s>>2];u=+g[s+4>>2];v=+g[m+(r*12&-1)+8>>2];w=+g[b+168>>2];x=+g[b+172>>2];y=+g[b+176>>2];z=+g[b+180>>2];r=y+z==0.0;do{if((a[b+100|0]&1)==0){A=q;B=v}else{if((c[b+224>>2]|0)==3|r){A=q;B=v;break}m=b+96|0;C=+g[m>>2];D=+g[d>>2]*+g[b+104>>2];E=C+(v-q- +g[b+108>>2])*(-0.0- +g[b+220>>2]);F=-0.0-D;G=E>2]=D;G=D-C;A=q-y*G;B=v+z*G}}while(0);do{if((a[b+112|0]&1)==0){H=75}else{d=b+224|0;if((c[d>>2]|0)==0|r){H=75;break}m=b+148|0;s=b+144|0;I=b+140|0;J=b+136|0;v=t+ +g[m>>2]*(-0.0-B)-o- +g[I>>2]*(-0.0-A);q=u+B*+g[s>>2]-p-A*+g[J>>2];g[f>>2]=v;g[f+4>>2]=q;g[f+8>>2]=B-A;K=b+184|0;c8(h,K,f);G=+g[h>>2];C=-0.0-G;D=+g[h+4>>2];F=-0.0-D;E=+g[h+8>>2];L=-0.0-E;M=c[d>>2]|0;do{if((M|0)==3){d=b+84|0;g[d>>2]=+g[d>>2]-G;d=b+88|0;g[d>>2]=+g[d>>2]-D;d=b+92|0;g[d>>2]=+g[d>>2]-E;N=C;O=F;P=L}else if((M|0)==1){d=b+84|0;Q=b+92|0;R=+g[Q>>2];S=R-E;if(S>=0.0){T=d|0;g[T>>2]=+g[T>>2]-G;T=b+88|0;g[T>>2]=+g[T>>2]-D;g[Q>>2]=S;N=C;O=F;P=L;break}S=R*+g[b+208>>2]-v;U=R*+g[b+212>>2]-q;V=+g[K>>2];W=+g[b+196>>2];X=+g[b+188>>2];Y=+g[b+200>>2];Z=V*Y-W*X;if(Z!=0.0){_=1.0/Z}else{_=Z}Z=(S*Y-W*U)*_;W=(V*U-S*X)*_;T=d|0;g[T>>2]=Z+ +g[T>>2];T=b+88|0;g[T>>2]=W+ +g[T>>2];g[Q>>2]=0.0;N=Z;O=W;P=-0.0-R}else if((M|0)==2){Q=b+84|0;T=b+92|0;R=+g[T>>2];W=R-E;if(W<=0.0){d=Q|0;g[d>>2]=+g[d>>2]-G;d=b+88|0;g[d>>2]=+g[d>>2]-D;g[T>>2]=W;N=C;O=F;P=L;break}W=R*+g[b+208>>2]-v;Z=R*+g[b+212>>2]-q;X=+g[K>>2];S=+g[b+196>>2];U=+g[b+188>>2];V=+g[b+200>>2];Y=X*V-S*U;if(Y!=0.0){$=1.0/Y}else{$=Y}Y=(W*V-S*Z)*$;S=(X*Z-W*U)*$;d=Q|0;g[d>>2]=Y+ +g[d>>2];d=b+88|0;g[d>>2]=S+ +g[d>>2];g[T>>2]=0.0;N=Y;O=S;P=-0.0-R}else{N=C;O=F;P=L}}while(0);aa=P+(O*+g[J>>2]-N*+g[I>>2]);ab=P+(O*+g[s>>2]-N*+g[m>>2]);ac=N;ad=O;ae=c[j>>2]|0}}while(0);if((H|0)==75){O=+g[b+148>>2];N=+g[b+144>>2];P=+g[b+140>>2];$=+g[b+136>>2];_=-0.0-(t+O*(-0.0-B)-o-P*(-0.0-A));L=-0.0-(u+B*N-p-A*$);F=+g[b+184>>2];C=+g[b+196>>2];q=+g[b+188>>2];v=+g[b+200>>2];D=F*v-C*q;if(D!=0.0){af=1.0/D}else{af=D}D=(v*_-C*L)*af;C=(F*L-q*_)*af;H=b+84|0;g[H>>2]=+g[H>>2]+D;H=b+88|0;g[H>>2]=C+ +g[H>>2];aa=C*$-D*P;ab=C*N-D*O;ac=D;ad=C;ae=k}k=(c[l>>2]|0)+(ae*12&-1)|0;C=+(p-w*ad);g[k>>2]=o-w*ac;g[k+4>>2]=C;g[(c[l>>2]|0)+((c[j>>2]|0)*12&-1)+8>>2]=A-y*aa;j=(c[l>>2]|0)+((c[n>>2]|0)*12&-1)|0;aa=+(u+x*ad);g[j>>2]=t+x*ac;g[j+4>>2]=aa;g[(c[l>>2]|0)+((c[n>>2]|0)*12&-1)+8>>2]=B+z*ab;i=e;return}function fW(a){a=a|0;return}function fX(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+48>>2]|0;e=+g[d+24>>2];f=+g[b+68>>2];h=+g[d+20>>2];i=+g[b+72>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function fY(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+52>>2]|0;e=+g[d+24>>2];f=+g[b+76>>2];h=+g[d+20>>2];i=+g[b+80>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function fZ(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0;d=+g[b+88>>2]*c;g[a>>2]=+g[b+84>>2]*c;g[a+4>>2]=d;return}function f_(a,b){a=a|0;b=+b;return+(+g[a+92>>2]*b)}function f$(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0,j=0.0,k=0.0,l=0.0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0;d=a+96|0;e=c[d>>2]|0;f=b+28|0;h=c[f>>2]|0;i=h+(e*12&-1)|0;j=+g[i>>2];k=+g[i+4>>2];l=+g[h+(e*12&-1)+8>>2];i=a+100|0;m=c[i>>2]|0;n=h+(m*12&-1)|0;o=+g[n>>2];p=+g[n+4>>2];q=+g[h+(m*12&-1)+8>>2];r=+g[a+116>>2];s=+g[a+112>>2];t=+g[a+124>>2];u=+g[a+120>>2];v=+g[a+88>>2]- +g[a+84>>2];w=+g[a+104>>2];x=+g[a+108>>2];y=(o+t*(-0.0-q)-(j+r*(-0.0-l)))*w+(p+q*u-(k+l*s))*x;if(v<0.0){z=y+v*+g[b+4>>2]}else{z=y}b=a+92|0;y=+g[b>>2];v=y+z*(-0.0- +g[a+160>>2]);z=v>0.0?0.0:v;g[b>>2]=z;v=z-y;y=w*v;w=x*v;v=+g[a+144>>2];x=l- +g[a+152>>2]*(s*w-r*y);r=+g[a+148>>2];s=q+ +g[a+156>>2]*(w*u-y*t);a=(c[f>>2]|0)+(e*12&-1)|0;t=+(k-v*w);g[a>>2]=j-v*y;g[a+4>>2]=t;g[(c[f>>2]|0)+((c[d>>2]|0)*12&-1)+8>>2]=x;d=(c[f>>2]|0)+((c[i>>2]|0)*12&-1)|0;x=+(p+w*r);g[d>>2]=o+y*r;g[d+4>>2]=x;g[(c[f>>2]|0)+((c[i>>2]|0)*12&-1)+8>>2]=s;return}function f0(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0.0,k=0.0,l=0.0,m=0,n=0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0;e=b+128|0;f=c[e>>2]|0;h=d+24|0;d=c[h>>2]|0;i=d+(f*12&-1)|0;j=+g[i>>2];k=+g[i+4>>2];l=+g[d+(f*12&-1)+8>>2];f=b+132|0;m=c[f>>2]|0;n=d+(m*12&-1)|0;o=+g[n>>2];p=+g[n+4>>2];q=+g[d+(m*12&-1)+8>>2];m=b+176|0;d=b+180|0;do{if((a[b+112|0]&1)==0){r=l;s=q;t=0.0;u=+g[m>>2];v=+g[d>>2]}else{w=+g[d>>2];x=+g[m>>2];n=c[b+224>>2]|0;if((n|0)==0|w+x==0.0){r=l;s=q;t=0.0;u=x;v=w;break}y=q-l- +g[b+116>>2];do{if((n|0)==3){z=y- +g[b+120>>2];A=z<.13962635397911072?z:.13962635397911072;z=A<-.13962635397911072?-.13962635397911072:A;A=z*(-0.0- +g[b+220>>2]);if(z>0.0){B=z;C=A;break}B=-0.0-z;C=A}else if((n|0)==1){A=y- +g[b+120>>2];z=A+.03490658849477768;D=z<0.0?z:0.0;B=-0.0-A;C=(D<-.13962635397911072?-.13962635397911072:D)*(-0.0- +g[b+220>>2])}else if((n|0)==2){D=y- +g[b+124>>2];A=D+-.03490658849477768;z=A<.13962635397911072?A:.13962635397911072;B=D;C=(z<0.0?0.0:z)*(-0.0- +g[b+220>>2])}else{B=0.0;C=0.0}}while(0);r=l-C*x;s=q+C*w;t=B;u=x;v=w}}while(0);B=+S(+r);C=+R(+r);q=+S(+s);l=+R(+s);y=+g[b+68>>2]- +g[b+152>>2];z=+g[b+72>>2]- +g[b+156>>2];D=C*y-B*z;A=B*y+C*z;z=+g[b+76>>2]- +g[b+160>>2];C=+g[b+80>>2]- +g[b+164>>2];y=l*z-q*C;B=q*z+l*C;C=o+y-j-D;l=p+B-k-A;z=+P(+(C*C+l*l));q=+g[b+168>>2];E=+g[b+172>>2];F=q+E;G=F+A*A*u+B*B*v;H=y*v;I=A*D*(-0.0-u)-B*H;J=F+D*D*u+y*H;H=G*J-I*I;if(H!=0.0){K=1.0/H}else{K=H}H=-0.0-(C*J-l*I)*K;J=-0.0-(l*G-C*I)*K;K=+(k-q*J);g[i>>2]=j-q*H;g[i+4>>2]=K;g[(c[h>>2]|0)+((c[e>>2]|0)*12&-1)+8>>2]=r-u*(D*J-A*H);e=(c[h>>2]|0)+((c[f>>2]|0)*12&-1)|0;A=+(p+E*J);g[e>>2]=o+E*H;g[e+4>>2]=A;g[(c[h>>2]|0)+((c[f>>2]|0)*12&-1)+8>>2]=s+v*(y*J-B*H);if(z>.004999999888241291){L=0;return L|0}L=t<=.03490658849477768;return L|0}function f1(b){b=b|0;var d=0,e=0,f=0,j=0.0;d=i;e=c[(c[b+48>>2]|0)+8>>2]|0;f=c[(c[b+52>>2]|0)+8>>2]|0;db(8928,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(11336,(u=i,i=i+8|0,c[u>>2]=e,u)|0);db(8808,(u=i,i=i+8|0,c[u>>2]=f,u)|0);db(6768,(u=i,i=i+8|0,c[u>>2]=a[b+61|0]&1,u)|0);j=+g[b+72>>2];db(5992,(u=i,i=i+16|0,h[u>>3]=+g[b+68>>2],h[u+8>>3]=j,u)|0);j=+g[b+80>>2];db(5536,(u=i,i=i+16|0,h[u>>3]=+g[b+76>>2],h[u+8>>3]=j,u)|0);db(5072,(u=i,i=i+8|0,h[u>>3]=+g[b+116>>2],u)|0);db(4264,(u=i,i=i+8|0,c[u>>2]=a[b+112|0]&1,u)|0);db(12800,(u=i,i=i+8|0,h[u>>3]=+g[b+120>>2],u)|0);db(12504,(u=i,i=i+8|0,h[u>>3]=+g[b+124>>2],u)|0);db(4760,(u=i,i=i+8|0,c[u>>2]=a[b+100|0]&1,u)|0);db(4488,(u=i,i=i+8|0,h[u>>3]=+g[b+108>>2],u)|0);db(4232,(u=i,i=i+8|0,h[u>>3]=+g[b+104>>2],u)|0);db(11904,(u=i,i=i+8|0,c[u>>2]=c[b+56>>2],u)|0);i=d;return}function f2(a){a=a|0;vl(a);return}function f3(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,Q=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0;e=c[b+48>>2]|0;f=c[e+8>>2]|0;h=b+96|0;c[h>>2]=f;i=c[b+52>>2]|0;j=c[i+8>>2]|0;l=b+100|0;c[l>>2]=j;m=e+28|0;n=b+128|0;o=c[m>>2]|0;p=c[m+4>>2]|0;c[n>>2]=o;c[n+4>>2]=p;n=i+28|0;m=b+136|0;q=c[n>>2]|0;r=c[n+4>>2]|0;c[m>>2]=q;c[m+4>>2]=r;s=+g[e+120>>2];g[b+144>>2]=s;t=+g[i+120>>2];g[b+148>>2]=t;u=+g[e+128>>2];g[b+152>>2]=u;v=+g[i+128>>2];g[b+156>>2]=v;i=c[d+24>>2]|0;e=i+(f*12&-1)|0;w=+g[e>>2];x=+g[e+4>>2];y=+g[i+(f*12&-1)+8>>2];e=d+28|0;m=c[e>>2]|0;n=m+(f*12&-1)|0;z=+g[n>>2];A=+g[n+4>>2];B=+g[m+(f*12&-1)+8>>2];n=i+(j*12&-1)|0;C=+g[n>>2];D=+g[n+4>>2];E=+g[i+(j*12&-1)+8>>2];i=m+(j*12&-1)|0;F=+g[i>>2];G=+g[i+4>>2];H=+g[m+(j*12&-1)+8>>2];I=+S(+y);J=+R(+y);y=+S(+E);K=+R(+E);E=+g[b+68>>2]-(c[k>>2]=o,+g[k>>2]);L=+g[b+72>>2]-(c[k>>2]=p,+g[k>>2]);M=J*E-I*L;N=I*E+J*L;p=b+112|0;L=+N;g[p>>2]=M;g[p+4>>2]=L;L=+g[b+76>>2]-(c[k>>2]=q,+g[k>>2]);J=+g[b+80>>2]-(c[k>>2]=r,+g[k>>2]);E=K*L-y*J;I=y*L+K*J;r=b+120|0;J=+I;g[r>>2]=E;g[r+4>>2]=J;r=b+104|0;J=C+E-w-M;w=D+I-x-N;q=r;x=+w;g[q>>2]=J;g[q+4>>2]=x;q=r|0;r=b+108|0;x=+P(+(J*J+w*w));g[b+88>>2]=x;c[b+164>>2]=x- +g[b+84>>2]>0.0?2:0;if(x<=.004999999888241291){g[q>>2]=0.0;g[r>>2]=0.0;g[b+160>>2]=0.0;g[b+92>>2]=0.0;return}D=1.0/x;x=D*J;g[q>>2]=x;J=D*w;g[r>>2]=J;w=M*J-N*x;D=J*E-x*I;C=t+(s+w*w*u)+D*D*v;if(C!=0.0){O=1.0/C}else{O=0.0}g[b+160>>2]=O;if((a[d+20|0]&1)==0){g[b+92>>2]=0.0;Q=B;T=H;U=F;V=G;W=z;X=A}else{r=b+92|0;O=+g[d+8>>2]*+g[r>>2];g[r>>2]=O;C=x*O;x=O*J;Q=B-u*(x*M-C*N);T=H+v*(x*E-C*I);U=F+C*t;V=G+x*t;W=z-C*s;X=A-x*s}r=(c[e>>2]|0)+(f*12&-1)|0;s=+X;g[r>>2]=W;g[r+4>>2]=s;g[(c[e>>2]|0)+((c[h>>2]|0)*12&-1)+8>>2]=Q;h=(c[e>>2]|0)+((c[l>>2]|0)*12&-1)|0;Q=+V;g[h>>2]=U;g[h+4>>2]=Q;g[(c[e>>2]|0)+((c[l>>2]|0)*12&-1)+8>>2]=T;return}function f4(a,b){a=a|0;b=+b;return+0.0}function f5(a){a=a|0;return}function f6(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+48>>2]|0;e=+g[d+24>>2];f=+g[b+68>>2];h=+g[d+20>>2];i=+g[b+72>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function f7(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+52>>2]|0;e=+g[d+24>>2];f=+g[b+76>>2];h=+g[d+20>>2];i=+g[b+80>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function f8(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0;d=+g[b+92>>2]*c;c=d*+g[b+108>>2];g[a>>2]=+g[b+104>>2]*d;g[a+4>>2]=c;return}function f9(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0;d=a+116|0;e=c[d>>2]|0;f=b+28|0;b=c[f>>2]|0;h=b+(e*12&-1)|0;i=+g[h>>2];j=+g[h+4>>2];k=+g[b+(e*12&-1)+8>>2];h=a+120|0;l=c[h>>2]|0;m=b+(l*12&-1)|0;n=+g[m>>2];o=+g[m+4>>2];p=+g[b+(l*12&-1)+8>>2];q=+g[a+156>>2];r=+g[a+160>>2];s=+g[a+164>>2];t=+g[a+168>>2];if(+g[a+68>>2]>0.0){l=a+112|0;u=+g[l>>2];v=(p-k+ +g[a+76>>2]+ +g[a+100>>2]*u)*(-0.0- +g[a+204>>2]);g[l>>2]=u+v;u=k-s*v;w=p+t*v;v=+g[a+136>>2];x=+g[a+132>>2];y=+g[a+128>>2];z=+g[a+124>>2];A=n+v*(-0.0-w)-i-y*(-0.0-u);B=o+x*w-j-z*u;C=+g[a+184>>2]*B+ +g[a+172>>2]*A;D=+g[a+188>>2]*B+ +g[a+176>>2]*A;A=-0.0-C;B=-0.0-D;l=a+104|0;g[l>>2]=+g[l>>2]-C;l=a+108|0;g[l>>2]=+g[l>>2]-D;E=u-s*(z*B-y*A);F=w+t*(x*B-v*A);G=A;H=B}else{B=+g[a+136>>2];A=+g[a+132>>2];v=+g[a+128>>2];x=+g[a+124>>2];w=n+B*(-0.0-p)-i-v*(-0.0-k);y=o+p*A-j-k*x;z=p-k;u=w*+g[a+172>>2]+y*+g[a+184>>2]+z*+g[a+196>>2];D=w*+g[a+176>>2]+y*+g[a+188>>2]+z*+g[a+200>>2];C=w*+g[a+180>>2]+y*+g[a+192>>2]+z*+g[a+204>>2];z=-0.0-u;y=-0.0-D;l=a+104|0;g[l>>2]=+g[l>>2]-u;l=a+108|0;g[l>>2]=+g[l>>2]-D;l=a+112|0;g[l>>2]=+g[l>>2]-C;E=k-s*(x*y-v*z-C);F=p+t*(A*y-B*z-C);G=z;H=y}l=(c[f>>2]|0)+(e*12&-1)|0;y=+(j-q*H);g[l>>2]=i-q*G;g[l+4>>2]=y;g[(c[f>>2]|0)+((c[d>>2]|0)*12&-1)+8>>2]=E;d=(c[f>>2]|0)+((c[h>>2]|0)*12&-1)|0;E=+(o+r*H);g[d>>2]=n+r*G;g[d+4>>2]=E;g[(c[f>>2]|0)+((c[h>>2]|0)*12&-1)+8>>2]=F;return}function ga(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0;d=a+96|0;e=c[d>>2]|0;f=b+24|0;b=c[f>>2]|0;h=b+(e*12&-1)|0;i=+g[h>>2];j=+g[h+4>>2];k=+g[b+(e*12&-1)+8>>2];e=a+100|0;l=c[e>>2]|0;m=b+(l*12&-1)|0;n=+g[m>>2];o=+g[m+4>>2];p=+g[b+(l*12&-1)+8>>2];q=+S(+k);r=+R(+k);s=+S(+p);t=+R(+p);u=+g[a+68>>2]- +g[a+128>>2];v=+g[a+72>>2]- +g[a+132>>2];w=r*u-q*v;x=q*u+r*v;v=+g[a+76>>2]- +g[a+136>>2];r=+g[a+80>>2]- +g[a+140>>2];u=t*v-s*r;q=s*v+t*r;r=n+u-i-w;t=o+q-j-x;v=+P(+(r*r+t*t));if(v<1.1920928955078125e-7){y=0.0;z=r;A=t}else{s=1.0/v;y=v;z=r*s;A=t*s}l=a+84|0;s=y- +g[l>>2];t=s<.20000000298023224?s:.20000000298023224;s=(t<0.0?0.0:t)*(-0.0- +g[a+160>>2]);t=z*s;z=A*s;s=+g[a+144>>2];A=k- +g[a+152>>2]*(w*z-x*t);x=+g[a+148>>2];w=p+ +g[a+156>>2]*(u*z-q*t);q=+(j-s*z);g[h>>2]=i-s*t;g[h+4>>2]=q;g[(c[f>>2]|0)+((c[d>>2]|0)*12&-1)+8>>2]=A;d=(c[f>>2]|0)+((c[e>>2]|0)*12&-1)|0;A=+(o+x*z);g[d>>2]=n+x*t;g[d+4>>2]=A;g[(c[f>>2]|0)+((c[e>>2]|0)*12&-1)+8>>2]=w;return y- +g[l>>2]<.004999999888241291|0}function gb(b){b=b|0;var d=0,e=0,f=0,j=0.0;d=i;e=c[(c[b+48>>2]|0)+8>>2]|0;f=c[(c[b+52>>2]|0)+8>>2]|0;db(6400,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(11336,(u=i,i=i+8|0,c[u>>2]=e,u)|0);db(8808,(u=i,i=i+8|0,c[u>>2]=f,u)|0);db(6768,(u=i,i=i+8|0,c[u>>2]=a[b+61|0]&1,u)|0);j=+g[b+72>>2];db(5992,(u=i,i=i+16|0,h[u>>3]=+g[b+68>>2],h[u+8>>3]=j,u)|0);j=+g[b+80>>2];db(5536,(u=i,i=i+16|0,h[u>>3]=+g[b+76>>2],h[u+8>>3]=j,u)|0);db(5104,(u=i,i=i+8|0,h[u>>3]=+g[b+84>>2],u)|0);db(11904,(u=i,i=i+8|0,c[u>>2]=c[b+56>>2],u)|0);i=d;return}function gc(a){a=a|0;vl(a);return}function gd(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0,ao=0,ap=0,aq=0,ar=0,as=0,at=0,au=0,av=0,aw=0,ax=0,ay=0,az=0,aA=0,aB=0,aC=0,aD=0,aE=0,aF=0,aG=0,aH=0,aI=0,aJ=0,aK=0,aL=0;e=c[b+48>>2]|0;f=c[e+8>>2]|0;h=b+116|0;c[h>>2]=f;i=c[b+52>>2]|0;j=c[i+8>>2]|0;l=b+120|0;c[l>>2]=j;m=e+28|0;n=b+140|0;o=c[m>>2]|0;p=c[m+4>>2]|0;c[n>>2]=o;c[n+4>>2]=p;n=i+28|0;m=b+148|0;q=c[n>>2]|0;r=c[n+4>>2]|0;c[m>>2]=q;c[m+4>>2]=r;s=+g[e+120>>2];g[b+156>>2]=s;t=+g[i+120>>2];g[b+160>>2]=t;u=+g[e+128>>2];g[b+164>>2]=u;v=+g[i+128>>2];g[b+168>>2]=v;i=c[d+24>>2]|0;w=+g[i+(f*12&-1)+8>>2];e=d+28|0;m=c[e>>2]|0;n=m+(f*12&-1)|0;x=+g[n>>2];y=+g[n+4>>2];z=+g[m+(f*12&-1)+8>>2];A=+g[i+(j*12&-1)+8>>2];i=m+(j*12&-1)|0;B=+g[i>>2];C=+g[i+4>>2];D=+g[m+(j*12&-1)+8>>2];E=+S(+w);F=+R(+w);G=+S(+A);H=+R(+A);I=+g[b+80>>2]-(c[k>>2]=o,+g[k>>2]);J=+g[b+84>>2]-(c[k>>2]=p,+g[k>>2]);K=F*I-E*J;L=E*I+F*J;p=b+124|0;J=+L;g[p>>2]=K;g[p+4>>2]=J;J=+g[b+88>>2]-(c[k>>2]=q,+g[k>>2]);F=+g[b+92>>2]-(c[k>>2]=r,+g[k>>2]);I=H*J-G*F;E=G*J+H*F;r=b+132|0;F=+E;g[r>>2]=I;g[r+4>>2]=F;F=s+t;H=F+u*L*L+v*E*E;J=-0.0-L;G=u*K*J-v*E*I;M=u*J-v*E;J=F+u*K*K+v*I*I;F=u*K+v*I;N=u+v;O=+g[b+68>>2];r=b+172|0;if(O>0.0){P=H*J-G*G;if(P!=0.0){Q=1.0/P}else{Q=P}g[r>>2]=J*Q;P=G*(-0.0-Q);g[b+184>>2]=P;g[b+180>>2]=0.0;g[b+176>>2]=P;g[b+188>>2]=H*Q;vq(b+192|0,0,16);if(N>0.0){T=1.0/N}else{T=0.0}Q=A-w- +g[b+96>>2];w=O*6.2831854820251465;O=w*T*w;A=+g[d>>2];P=A*(w*T*2.0*+g[b+72>>2]+A*O);q=b+100|0;g[q>>2]=P;if(P!=0.0){U=1.0/P}else{U=0.0}g[q>>2]=U;g[b+76>>2]=Q*A*O*U;O=N+U;if(O!=0.0){V=1.0/O}else{V=0.0}g[b+204>>2]=V}else{V=N*J-F*F;O=M*F-N*G;U=F*G-M*J;A=M*U+(H*V+G*O);if(A!=0.0){W=1.0/A}else{W=A}g[r>>2]=V*W;V=O*W;g[b+176>>2]=V;O=U*W;g[b+180>>2]=O;g[b+184>>2]=V;g[b+188>>2]=(N*H-M*M)*W;N=(M*G-H*F)*W;g[b+192>>2]=N;g[b+196>>2]=O;g[b+200>>2]=N;g[b+204>>2]=(H*J-G*G)*W;g[b+100>>2]=0.0;g[b+76>>2]=0.0}r=b+104|0;if((a[d+20|0]&1)==0){g[r>>2]=0.0;g[b+108>>2]=0.0;g[b+112>>2]=0.0;X=z;Y=D;Z=B;_=C;$=x;aa=y;ab=c[e>>2]|0;ac=ab+(f*12&-1)|0;ad=ac;ae=(g[k>>2]=$,c[k>>2]|0);af=(g[k>>2]=aa,c[k>>2]|0);ag=af;ah=0;ai=0;aj=ag;ak=ae;al=0;am=ai|ak;an=aj|al;ao=ad|0;c[ao>>2]=am;ap=ad+4|0;c[ap>>2]=an;aq=c[h>>2]|0;ar=c[e>>2]|0;as=ar+(aq*12&-1)+8|0;g[as>>2]=X;at=c[l>>2]|0;au=c[e>>2]|0;av=au+(at*12&-1)|0;aw=av;ax=(g[k>>2]=Z,c[k>>2]|0);ay=(g[k>>2]=_,c[k>>2]|0);az=ay;aA=0;aB=0;aC=az;aD=ax;aE=0;aF=aB|aD;aG=aC|aE;aH=aw|0;c[aH>>2]=aF;aI=aw+4|0;c[aI>>2]=aG;aJ=c[l>>2]|0;aK=c[e>>2]|0;aL=aK+(aJ*12&-1)+8|0;g[aL>>2]=Y;return}else{W=+g[d+8>>2];d=r|0;G=W*+g[d>>2];g[d>>2]=G;d=b+108|0;J=W*+g[d>>2];g[d>>2]=J;d=b+112|0;H=W*+g[d>>2];g[d>>2]=H;X=z-u*(H+(J*K-G*L));Y=D+v*(H+(J*I-G*E));Z=B+t*G;_=C+t*J;$=x-s*G;aa=y-s*J;ab=c[e>>2]|0;ac=ab+(f*12&-1)|0;ad=ac;ae=(g[k>>2]=$,c[k>>2]|0);af=(g[k>>2]=aa,c[k>>2]|0);ag=af;ah=0;ai=0;aj=ag;ak=ae;al=0;am=ai|ak;an=aj|al;ao=ad|0;c[ao>>2]=am;ap=ad+4|0;c[ap>>2]=an;aq=c[h>>2]|0;ar=c[e>>2]|0;as=ar+(aq*12&-1)+8|0;g[as>>2]=X;at=c[l>>2]|0;au=c[e>>2]|0;av=au+(at*12&-1)|0;aw=av;ax=(g[k>>2]=Z,c[k>>2]|0);ay=(g[k>>2]=_,c[k>>2]|0);az=ay;aA=0;aB=0;aC=az;aD=ax;aE=0;aF=aB|aD;aG=aC|aE;aH=aw|0;c[aH>>2]=aF;aI=aw+4|0;c[aI>>2]=aG;aJ=c[l>>2]|0;aK=c[e>>2]|0;aL=aK+(aJ*12&-1)+8|0;g[aL>>2]=Y;return}}function ge(a){a=a|0;return}function gf(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+48>>2]|0;e=+g[d+24>>2];f=+g[b+80>>2];h=+g[d+20>>2];i=+g[b+84>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function gg(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+52>>2]|0;e=+g[d+24>>2];f=+g[b+88>>2];h=+g[d+20>>2];i=+g[b+92>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function gh(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0;d=+g[b+108>>2]*c;g[a>>2]=+g[b+104>>2]*c;g[a+4>>2]=d;return}function gi(a,b){a=a|0;b=+b;return+(+g[a+112>>2]*b)}function gj(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,Q=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0;d=a+116|0;e=c[d>>2]|0;f=b+24|0;b=c[f>>2]|0;h=b+(e*12&-1)|0;i=+g[h>>2];j=+g[h+4>>2];k=+g[b+(e*12&-1)+8>>2];e=a+120|0;l=c[e>>2]|0;m=b+(l*12&-1)|0;n=+g[m>>2];o=+g[m+4>>2];p=+g[b+(l*12&-1)+8>>2];q=+S(+k);r=+R(+k);s=+S(+p);t=+R(+p);u=+g[a+156>>2];v=+g[a+160>>2];w=+g[a+164>>2];x=+g[a+168>>2];y=+g[a+80>>2]- +g[a+140>>2];z=+g[a+84>>2]- +g[a+144>>2];A=r*y-q*z;B=q*y+r*z;z=+g[a+88>>2]- +g[a+148>>2];r=+g[a+92>>2]- +g[a+152>>2];y=t*z-s*r;q=s*z+t*r;r=u+v;t=r+w*B*B+x*q*q;z=-0.0-B;s=w*A*z-x*q*y;C=w*z-x*q;z=r+w*A*A+x*y*y;r=w*A+x*y;D=w+x;E=n+y-i-A;F=o+q-j-B;if(+g[a+68>>2]>0.0){G=+P(+(E*E+F*F));H=t*z-s*s;if(H!=0.0){I=1.0/H}else{I=H}H=-0.0-(z*E-s*F)*I;J=-0.0-(t*F-s*E)*I;K=A*J-B*H;L=0.0;M=G;N=y*J-q*H;O=H;Q=J}else{J=p-k- +g[a+96>>2];H=+P(+(E*E+F*F));if(J>0.0){T=J}else{T=-0.0-J}G=D*z-r*r;I=r*C-D*s;U=r*s-C*z;V=C*U+(t*G+s*I);if(V!=0.0){W=1.0/V}else{W=V}V=r*E;X=(C*(F*s-z*E)+(t*(z*J-r*F)+s*(V-s*J)))*W;z=-0.0-(E*G+F*I+U*J)*W;U=-0.0-(C*(V-C*F)+(t*(D*F-r*J)+s*(C*J-D*E)))*W;K=A*U-B*z-X;L=T;M=H;N=y*U-q*z-X;O=z;Q=U}U=+(j-u*Q);g[h>>2]=i-u*O;g[h+4>>2]=U;g[(c[f>>2]|0)+((c[d>>2]|0)*12&-1)+8>>2]=k-w*K;d=(c[f>>2]|0)+((c[e>>2]|0)*12&-1)|0;K=+(o+v*Q);g[d>>2]=n+v*O;g[d+4>>2]=K;g[(c[f>>2]|0)+((c[e>>2]|0)*12&-1)+8>>2]=p+x*N;if(M>.004999999888241291){Y=0;return Y|0}Y=L<=.03490658849477768;return Y|0}function gk(b){b=b|0;var d=0,e=0,f=0,j=0.0;d=i;e=c[(c[b+48>>2]|0)+8>>2]|0;f=c[(c[b+52>>2]|0)+8>>2]|0;db(6344,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(11336,(u=i,i=i+8|0,c[u>>2]=e,u)|0);db(8808,(u=i,i=i+8|0,c[u>>2]=f,u)|0);db(6768,(u=i,i=i+8|0,c[u>>2]=a[b+61|0]&1,u)|0);j=+g[b+84>>2];db(5992,(u=i,i=i+16|0,h[u>>3]=+g[b+80>>2],h[u+8>>3]=j,u)|0);j=+g[b+92>>2];db(5536,(u=i,i=i+16|0,h[u>>3]=+g[b+88>>2],h[u+8>>3]=j,u)|0);db(5072,(u=i,i=i+8|0,h[u>>3]=+g[b+96>>2],u)|0);db(12768,(u=i,i=i+8|0,h[u>>3]=+g[b+68>>2],u)|0);db(12472,(u=i,i=i+8|0,h[u>>3]=+g[b+72>>2],u)|0);db(11904,(u=i,i=i+8|0,c[u>>2]=c[b+56>>2],u)|0);i=d;return}function gl(a){a=a|0;vl(a);return}function gm(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0.0,J=0.0,K=0.0,L=0.0,M=0.0,N=0.0,O=0.0,P=0.0,Q=0.0,T=0.0,U=0.0,V=0.0,W=0.0,X=0.0,Y=0.0,Z=0.0,_=0.0,$=0.0,aa=0.0,ab=0.0,ac=0.0,ad=0.0,ae=0.0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0,ao=0,ap=0,aq=0,ar=0,as=0,at=0,au=0,av=0,aw=0,ax=0,ay=0,az=0,aA=0,aB=0,aC=0,aD=0,aE=0,aF=0,aG=0,aH=0,aI=0,aJ=0,aK=0,aL=0,aM=0,aN=0,aO=0,aP=0;e=c[b+48>>2]|0;f=c[e+8>>2]|0;h=b+132|0;c[h>>2]=f;i=c[b+52>>2]|0;j=c[i+8>>2]|0;l=b+136|0;c[l>>2]=j;m=e+28|0;n=b+140|0;o=c[m>>2]|0;p=c[m+4>>2]|0;c[n>>2]=o;c[n+4>>2]=p;n=i+28|0;m=b+148|0;q=c[n>>2]|0;r=c[n+4>>2]|0;c[m>>2]=q;c[m+4>>2]=r;s=+g[e+120>>2];g[b+156>>2]=s;t=+g[i+120>>2];g[b+160>>2]=t;u=+g[e+128>>2];g[b+164>>2]=u;v=+g[i+128>>2];g[b+168>>2]=v;i=c[d+24>>2]|0;e=i+(f*12&-1)|0;w=+g[e>>2];x=+g[e+4>>2];y=+g[i+(f*12&-1)+8>>2];e=d+28|0;m=c[e>>2]|0;n=m+(f*12&-1)|0;z=+g[n>>2];A=+g[n+4>>2];B=+g[m+(f*12&-1)+8>>2];n=i+(j*12&-1)|0;C=+g[n>>2];D=+g[n+4>>2];E=+g[i+(j*12&-1)+8>>2];i=m+(j*12&-1)|0;F=+g[i>>2];G=+g[i+4>>2];H=+g[m+(j*12&-1)+8>>2];I=+S(+y);J=+R(+y);y=+S(+E);K=+R(+E);E=+g[b+76>>2]-(c[k>>2]=o,+g[k>>2]);L=+g[b+80>>2]-(c[k>>2]=p,+g[k>>2]);M=J*E-I*L;N=I*E+J*L;L=+g[b+84>>2]-(c[k>>2]=q,+g[k>>2]);E=+g[b+88>>2]-(c[k>>2]=r,+g[k>>2]);O=K*L-y*E;P=y*L+K*E;E=C+O-w-M;w=D+P-x-N;x=+g[b+100>>2];D=+g[b+104>>2];C=J*x-I*D;K=I*x+J*D;r=b+180|0;D=+K;g[r>>2]=C;g[r+4>>2]=D;D=M+E;M=N+w;N=K*D-C*M;g[b+196>>2]=N;x=O*K-P*C;g[b+200>>2]=x;L=s+t;y=L+N*u*N+x*v*x;if(y>0.0){Q=1.0/y}else{Q=y}g[b+204>>2]=Q;r=b+212|0;g[r>>2]=0.0;q=b+216|0;g[q>>2]=0.0;p=b+220|0;g[p>>2]=0.0;Q=+g[b+68>>2];do{if(Q>0.0){y=+g[b+92>>2];T=+g[b+96>>2];U=J*y-I*T;V=I*y+J*T;o=b+172|0;T=+V;g[o>>2]=U;g[o+4>>2]=T;T=D*V-M*U;g[b+188>>2]=T;y=O*V-P*U;g[b+192>>2]=y;W=L+T*u*T+y*v*y;if(W<=0.0){break}y=1.0/W;g[r>>2]=y;T=Q*6.2831854820251465;X=T*y*T;Y=+g[d>>2];Z=Y*(T*y*2.0*+g[b+72>>2]+Y*X);if(Z>0.0){_=1.0/Z}else{_=Z}g[p>>2]=_;g[q>>2]=(E*U+w*V)*Y*X*_;X=W+_;g[r>>2]=X;if(X<=0.0){break}g[r>>2]=1.0/X}else{g[b+116>>2]=0.0}}while(0);do{if((a[b+128|0]&1)==0){g[b+208>>2]=0.0;g[b+112>>2]=0.0}else{_=v+u;r=b+208|0;g[r>>2]=_;if(_<=0.0){break}g[r>>2]=1.0/_}}while(0);if((a[d+20|0]&1)==0){g[b+108>>2]=0.0;g[b+116>>2]=0.0;g[b+112>>2]=0.0;$=B;aa=H;ab=F;ac=G;ad=z;ae=A;af=c[e>>2]|0;ag=af+(f*12&-1)|0;ah=ag;ai=(g[k>>2]=ad,c[k>>2]|0);aj=(g[k>>2]=ae,c[k>>2]|0);ak=aj;al=0;am=0;an=ak;ao=ai;ap=0;aq=am|ao;ar=an|ap;as=ah|0;c[as>>2]=aq;at=ah+4|0;c[at>>2]=ar;au=c[h>>2]|0;av=c[e>>2]|0;aw=av+(au*12&-1)+8|0;g[aw>>2]=$;ax=c[l>>2]|0;ay=c[e>>2]|0;az=ay+(ax*12&-1)|0;aA=az;aB=(g[k>>2]=ab,c[k>>2]|0);aC=(g[k>>2]=ac,c[k>>2]|0);aD=aC;aE=0;aF=0;aG=aD;aH=aB;aI=0;aJ=aF|aH;aK=aG|aI;aL=aA|0;c[aL>>2]=aJ;aM=aA+4|0;c[aM>>2]=aK;aN=c[l>>2]|0;aO=c[e>>2]|0;aP=aO+(aN*12&-1)+8|0;g[aP>>2]=aa;return}else{r=d+8|0;d=b+108|0;_=+g[r>>2]*+g[d>>2];g[d>>2]=_;d=b+116|0;w=+g[r>>2]*+g[d>>2];g[d>>2]=w;d=b+112|0;E=+g[r>>2]*+g[d>>2];g[d>>2]=E;Q=_*C+w*+g[b+172>>2];C=_*K+w*+g[b+176>>2];$=B-(E+(_*N+w*+g[b+188>>2]))*u;aa=H+(E+(_*x+w*+g[b+192>>2]))*v;ab=F+Q*t;ac=G+C*t;ad=z-Q*s;ae=A-C*s;af=c[e>>2]|0;ag=af+(f*12&-1)|0;ah=ag;ai=(g[k>>2]=ad,c[k>>2]|0);aj=(g[k>>2]=ae,c[k>>2]|0);ak=aj;al=0;am=0;an=ak;ao=ai;ap=0;aq=am|ao;ar=an|ap;as=ah|0;c[as>>2]=aq;at=ah+4|0;c[at>>2]=ar;au=c[h>>2]|0;av=c[e>>2]|0;aw=av+(au*12&-1)+8|0;g[aw>>2]=$;ax=c[l>>2]|0;ay=c[e>>2]|0;az=ay+(ax*12&-1)|0;aA=az;aB=(g[k>>2]=ab,c[k>>2]|0);aC=(g[k>>2]=ac,c[k>>2]|0);aD=aC;aE=0;aF=0;aG=aD;aH=aB;aI=0;aJ=aF|aH;aK=aG|aI;aL=aA|0;c[aL>>2]=aJ;aM=aA+4|0;c[aM>>2]=aK;aN=c[l>>2]|0;aO=c[e>>2]|0;aP=aO+(aN*12&-1)+8|0;g[aP>>2]=aa;return}}function gn(b,d){b=b|0;d=d|0;var e=0,f=0,h=0,i=0;e=b|0;c[e>>2]=19312;f=d+8|0;h=d+12|0;if((c[f>>2]|0)==(c[h>>2]|0)){ba(7272,173,15744,9072)}else{c[b+4>>2]=c[d>>2];c[b+8>>2]=0;c[b+12>>2]=0;c[b+48>>2]=c[f>>2];c[b+52>>2]=c[h>>2];c[b+56>>2]=0;a[b+61|0]=a[d+16|0]&1;a[b+60|0]=0;c[b+64>>2]=c[d+4>>2];vq(b+16|0,0,32);c[e>>2]=20184;e=d+20|0;h=b+76|0;f=c[e+4>>2]|0;c[h>>2]=c[e>>2];c[h+4>>2]=f;f=d+28|0;h=b+84|0;e=c[f+4>>2]|0;c[h>>2]=c[f>>2];c[h+4>>2]=e;e=d+36|0;h=b+92|0;f=c[e>>2]|0;i=c[e+4>>2]|0;c[h>>2]=f;c[h+4>>2]=i;h=b+100|0;g[h>>2]=(c[k>>2]=i,+g[k>>2])*-1.0;c[h+4>>2]=f;g[b+204>>2]=0.0;g[b+108>>2]=0.0;g[b+208>>2]=0.0;g[b+112>>2]=0.0;g[b+212>>2]=0.0;g[b+116>>2]=0.0;g[b+120>>2]=+g[d+48>>2];g[b+124>>2]=+g[d+52>>2];a[b+128|0]=a[d+44|0]&1;g[b+68>>2]=+g[d+56>>2];g[b+72>>2]=+g[d+60>>2];g[b+216>>2]=0.0;g[b+220>>2]=0.0;vq(b+172|0,0,16);return}}function go(a){a=a|0;return}function gp(a,b){a=a|0;b=b|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0,j=0,k=0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0,r=0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0;d=+g[a+156>>2];e=+g[a+160>>2];f=+g[a+164>>2];h=+g[a+168>>2];i=a+132|0;j=c[i>>2]|0;k=b+28|0;l=c[k>>2]|0;m=l+(j*12&-1)|0;n=+g[m>>2];o=+g[m+4>>2];p=+g[l+(j*12&-1)+8>>2];m=a+136|0;q=c[m>>2]|0;r=l+(q*12&-1)|0;s=+g[r>>2];t=+g[r+4>>2];u=+g[l+(q*12&-1)+8>>2];v=+g[a+172>>2];w=+g[a+176>>2];x=+g[a+192>>2];y=+g[a+188>>2];q=a+116|0;z=+g[q>>2];A=(+g[a+216>>2]+(u*x+(v*(s-n)+w*(t-o))-p*y)+ +g[a+220>>2]*z)*(-0.0- +g[a+212>>2]);g[q>>2]=z+A;z=v*A;v=w*A;w=n-d*z;n=o-d*v;o=p-f*A*y;y=s+e*z;z=t+e*v;v=u+h*A*x;q=a+112|0;x=+g[q>>2];A=+g[b>>2]*+g[a+120>>2];u=x+(v-o- +g[a+124>>2])*(-0.0- +g[a+208>>2]);t=-0.0-A;s=u>2]=A;s=A-x;x=o-f*s;o=v+h*s;s=+g[a+180>>2];v=+g[a+184>>2];A=+g[a+200>>2];t=+g[a+196>>2];u=((y-w)*s+(z-n)*v+A*o-t*x)*(-0.0- +g[a+204>>2]);q=a+108|0;g[q>>2]=+g[q>>2]+u;p=s*u;s=v*u;q=(c[k>>2]|0)+(j*12&-1)|0;v=+(n-d*s);g[q>>2]=w-d*p;g[q+4>>2]=v;g[(c[k>>2]|0)+((c[i>>2]|0)*12&-1)+8>>2]=x-f*t*u;i=(c[k>>2]|0)+((c[m>>2]|0)*12&-1)|0;t=+(z+e*s);g[i>>2]=y+e*p;g[i+4>>2]=t;g[(c[k>>2]|0)+((c[m>>2]|0)*12&-1)+8>>2]=o+h*A*u;return}function gq(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+48>>2]|0;e=+g[d+24>>2];f=+g[b+76>>2];h=+g[d+20>>2];i=+g[b+80>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function gr(a,b){a=a|0;b=b|0;var d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;d=c[b+52>>2]|0;e=+g[d+24>>2];f=+g[b+84>>2];h=+g[d+20>>2];i=+g[b+88>>2];j=f*h+e*i+ +g[d+16>>2];g[a>>2]=+g[d+12>>2]+(e*f-h*i);g[a+4>>2]=j;return}function gs(a,b,c){a=a|0;b=b|0;c=+c;var d=0.0,e=0.0,f=0.0;d=+g[b+108>>2];e=+g[b+116>>2];f=(d*+g[b+184>>2]+e*+g[b+176>>2])*c;g[a>>2]=(d*+g[b+180>>2]+e*+g[b+172>>2])*c;g[a+4>>2]=f;return}function gt(a,b){a=a|0;b=+b;return+(+g[a+112>>2]*b)}function gu(a){a=a|0;return c[a+68>>2]|0}function gv(a){a=a|0;return c[a+64>>2]|0}function gw(a,b){a=a|0;b=b|0;c[a+68>>2]=b;return}function gx(a,b){a=a|0;b=b|0;c[a+76>>2]=b;return}function gy(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function gz(a,b){a=a|0;b=b|0;c[a+60>>2]=b;return}function gA(a){a=a|0;return c[a+72>>2]|0}function gB(a,b){a=a|0;b=b|0;c[a+72>>2]=b;return}function gC(a){a=a|0;return a|0}function gD(a){a=a|0;return c[a+60>>2]|0}function gE(a){a=a|0;return c[a+76>>2]|0}function gF(a){a=a|0;return c[a+48>>2]|0}function gG(a){a=a|0;return c[a+52>>2]|0}function gH(a,b){a=a|0;b=+b;g[a+68>>2]=b;return}function gI(a){a=a|0;return c[a+64>>2]|0}function gJ(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function gK(a){a=a|0;return c[a+12>>2]|0}function gL(a){a=a|0;return a+80|0}function gM(a){a=a|0;return a+88|0}function gN(a){a=a|0;return+(+g[a+68>>2])}function gO(a){a=a|0;return+(+g[a+104>>2])}function gP(a){a=a|0;return+(+g[a+72>>2])}function gQ(b){b=b|0;return(a[b+61|0]&1)!=0|0}function gR(a){a=a|0;return c[a+4>>2]|0}function gS(a,b){a=a|0;b=+b;g[a+72>>2]=b;return}function gT(a,b){a=a|0;b=+b;g[a+104>>2]=b;return}function gU(a){a=a|0;var d=0;if((b[(c[a+48>>2]|0)+4>>1]&32)==0){d=0;return d|0}d=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;return d|0}function gV(a){a=a|0;return+(+g[a+20>>2])}function gW(a,b){a=a|0;b=+b;g[a+16>>2]=b;return}function gX(a){a=a|0;return c[a+12>>2]|0}function gY(a,b){a=a|0;b=+b;g[a+20>>2]=b;return}function gZ(a){a=a|0;return c[a+8>>2]|0}function g_(a){a=a|0;return c[a+4>>2]|0}function g$(a){a=a|0;return+(+g[a+16>>2])}function g0(a){a=a|0;return c[a+40>>2]|0}function g1(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0,m=0,n=0.0,o=0.0,p=0.0,q=0.0,r=0.0,s=0.0,t=0.0,u=0.0,v=0.0,w=0.0,x=0.0,y=0.0,z=0.0,A=0.0,B=0.0,C=0.0,D=0.0,E=0.0,F=0.0,G=0.0,H=0.0,I=0;d=a+132|0;e=c[d>>2]|0;f=b+24|0;b=c[f>>2]|0;h=b+(e*12&-1)|0;i=+g[h>>2];j=+g[h+4>>2];k=+g[b+(e*12&-1)+8>>2];e=a+136|0;l=c[e>>2]|0;m=b+(l*12&-1)|0;n=+g[m>>2];o=+g[m+4>>2];p=+g[b+(l*12&-1)+8>>2];q=+S(+k);r=+R(+k);s=+S(+p);t=+R(+p);u=+g[a+76>>2]- +g[a+140>>2];v=+g[a+80>>2]- +g[a+144>>2];w=r*u-q*v;x=q*u+r*v;v=+g[a+84>>2]- +g[a+148>>2];u=+g[a+88>>2]- +g[a+152>>2];y=t*v-s*u;z=s*v+t*u;u=n-i+y-w;t=o-j+z-x;v=+g[a+100>>2];s=+g[a+104>>2];A=r*v-q*s;B=q*v+r*s;s=A*u+B*t;r=+g[a+156>>2];v=+g[a+160>>2];q=+g[a+164>>2];C=+g[a+196>>2];D=+g[a+168>>2];E=+g[a+200>>2];F=r+v+C*q*C+E*D*E;if(F!=0.0){G=(-0.0-s)/F}else{G=0.0}F=A*G;E=B*G;C=+(j-E*r);g[h>>2]=i-F*r;g[h+4>>2]=C;g[(c[f>>2]|0)+((c[d>>2]|0)*12&-1)+8>>2]=k-(B*(w+u)-A*(x+t))*G*q;d=(c[f>>2]|0)+((c[e>>2]|0)*12&-1)|0;q=+(o+E*v);g[d>>2]=n+F*v;g[d+4>>2]=q;g[(c[f>>2]|0)+((c[e>>2]|0)*12&-1)+8>>2]=p+(y*B-z*A)*G*D;if(s>0.0){H=s;I=H<=.004999999888241291;return I|0}H=-0.0-s;I=H<=.004999999888241291;return I|0}function g2(b){b=b|0;var d=0,e=0,f=0,j=0.0;d=i;e=c[(c[b+48>>2]|0)+8>>2]|0;f=c[(c[b+52>>2]|0)+8>>2]|0;db(6288,(u=i,i=i+1|0,i=i+7>>3<<3,c[u>>2]=0,u)|0);db(11336,(u=i,i=i+8|0,c[u>>2]=e,u)|0);db(8808,(u=i,i=i+8|0,c[u>>2]=f,u)|0);db(6768,(u=i,i=i+8|0,c[u>>2]=a[b+61|0]&1,u)|0);j=+g[b+80>>2];db(5992,(u=i,i=i+16|0,h[u>>3]=+g[b+76>>2],h[u+8>>3]=j,u)|0);j=+g[b+88>>2];db(5536,(u=i,i=i+16|0,h[u>>3]=+g[b+84>>2],h[u+8>>3]=j,u)|0);j=+g[b+96>>2];db(5032,(u=i,i=i+16|0,h[u>>3]=+g[b+92>>2],h[u+8>>3]=j,u)|0);db(4760,(u=i,i=i+8|0,c[u>>2]=a[b+128|0]&1,u)|0);db(4488,(u=i,i=i+8|0,h[u>>3]=+g[b+124>>2],u)|0);db(4232,(u=i,i=i+8|0,h[u>>3]=+g[b+120>>2],u)|0);db(12768,(u=i,i=i+8|0,h[u>>3]=+g[b+68>>2],u)|0);db(12472,(u=i,i=i+8|0,h[u>>3]=+g[b+72>>2],u)|0);db(11904,(u=i,i=i+8|0,c[u>>2]=c[b+56>>2],u)|0);i=d;return}function g3(a){a=a|0;vl(a);return}function g4(){var a=0;a=vo(80)|0;b3(a);c[a+60>>2]=0;c[a+64>>2]=0;c[a+68>>2]=4192;c[a+72>>2]=4184;c[a+76>>2]=0;return a|0}function g5(a,b,c){a=a|0;b=b|0;c=c|0;dv(a,b,c);return}function g6(a){a=a|0;dx(a);return}function g7(a){a=a|0;dy(a|0,a);return}function g8(a){a=a|0;if((a|0)==0){return}vi(c[a+32>>2]|0);vi(c[a+44>>2]|0);vi(c[a+4>>2]|0);vl(a);return}function g9(a,b){a=a|0;b=b|0;dp(a,b);return}function ha(a,b){a=a|0;b=b|0;var c=0;c=a;a=b;vp(c|0,a|0,60)|0;return}function hb(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[22936]|0)){a[22936]=1}bp[c[(c[b>>2]|0)+4>>2]&511](e,b);b=c[e+4>>2]|0;f=408;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 408}function hc(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[22944]|0)){a[22944]=1}bp[c[c[b>>2]>>2]&511](e,b);b=c[e+4>>2]|0;f=400;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 400}function hd(b,d){b=b|0;d=+d;var e=0,f=0,g=0;e=i;i=i+8|0;f=e|0;if(!(a[22816]|0)){a[22816]=1}bN[c[(c[b>>2]|0)+8>>2]&127](f,b,d);b=c[f+4>>2]|0;g=312;c[g>>2]=c[f>>2];c[g+4>>2]=b;i=e;return 312}function he(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+24>>2]&511](a);return}function hf(a){a=a|0;bo[c[(c[a>>2]|0)+16>>2]&511](a);return}function hg(a,b){a=a|0;b=+b;return+(+bw[c[(c[a>>2]|0)+12>>2]&127](a,b))}function hh(a,c){a=a|0;c=c|0;var d=0,e=0;d=a+32|0;e=c;b[d>>1]=b[e>>1]|0;b[d+2>>1]=b[e+2>>1]|0;b[d+4>>1]=b[e+4>>1]|0;dI(a);return}function hi(){var a=0;a=vo(44)|0;b[a+32>>1]=1;b[a+34>>1]=-1;b[a+36>>1]=0;c[a+40>>2]=0;c[a+24>>2]=0;c[a+28>>2]=0;vq(a|0,0,16);return a|0}function hj(b){b=b|0;var d=0,e=0,f=0,h=0;d=vo(176)|0;e=d;c[e>>2]=19312;f=c[b+8>>2]|0;h=c[b+12>>2]|0;if((f|0)!=(h|0)){c[d+4>>2]=c[b>>2];c[d+8>>2]=0;c[d+12>>2]=0;c[d+48>>2]=f;c[d+52>>2]=h;c[d+56>>2]=0;a[d+61|0]=a[b+16|0]&1;a[d+60|0]=0;c[d+64>>2]=c[b+4>>2];vq(d+16|0,0,32);c[e>>2]=19912;e=b+20|0;h=d+80|0;f=c[e+4>>2]|0;c[h>>2]=c[e>>2];c[h+4>>2]=f;f=b+28|0;h=d+88|0;e=c[f+4>>2]|0;c[h>>2]=c[f>>2];c[h+4>>2]=e;g[d+104>>2]=+g[b+36>>2];g[d+68>>2]=+g[b+40>>2];g[d+72>>2]=+g[b+44>>2];g[d+100>>2]=0.0;g[d+96>>2]=0.0;g[d+76>>2]=0.0;return d|0}ba(7272,173,15744,9072);return 0}function hk(a,b){a=a|0;b=+b;g[a>>2]=b;return}function hl(d,e){d=d|0;e=e|0;var f=0,h=0,i=0;f=d+38|0;if((e&1|0)==(a[f]&1|0)){return}h=c[d+8>>2]|0;d=h+4|0;i=b[d>>1]|0;if((i&2)==0){b[d>>1]=i|2;g[h+144>>2]=0.0}a[f]=e&1;return}function hm(a,b){a=a|0;b=b|0;return(c[a+24>>2]|0)+(b*28&-1)|0}function hn(a,b){a=a|0;b=b|0;c[a+40>>2]=b;return}function ho(a){a=a|0;return a+32|0}function hp(b){b=b|0;return(a[b+38|0]&1)!=0|0}function hq(a){a=a|0;return c[(c[a+12>>2]|0)+4>>2]|0}function hr(a){a=a|0;return+(+g[a>>2])}function hs(a){a=a|0;return c[a+48>>2]|0}function ht(a){a=a|0;return c[a+52>>2]|0}function hu(a,b){a=a|0;b=+b;g[a+84>>2]=b;return}function hv(a){a=a|0;return c[a+64>>2]|0}function hw(a,b){a=a|0;b=+b;g[a+104>>2]=b;return}function hx(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function hy(a){a=a|0;return c[a+12>>2]|0}function hz(a){a=a|0;return+(+g[a+104>>2])}function hA(a){a=a|0;return a+76|0}function hB(a){a=a|0;return+(+g[a+84>>2])}function hC(a){a=a|0;return+(+g[a+88>>2])}function hD(b){b=b|0;return(a[b+61|0]&1)!=0|0}function hE(a,d){a=a|0;d=d|0;var e=0,f=0,h=0;e=c[a+52>>2]|0;f=e+4|0;h=b[f>>1]|0;if((h&2)==0){b[f>>1]=h|2;g[e+144>>2]=0.0}e=d;d=a+76|0;a=c[e+4>>2]|0;c[d>>2]=c[e>>2];c[d+4>>2]=a;return}function hF(a){a=a|0;return c[a+4>>2]|0}function hG(a,b){a=a|0;b=+b;g[a+88>>2]=b;return}function hH(a){a=a|0;var d=0;if((b[(c[a+48>>2]|0)+4>>1]&32)==0){d=0;return d|0}d=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;return d|0}function hI(a){a=a|0;return c[a+48>>2]|0}function hJ(a){a=a|0;return c[a+4>>2]|0}function hK(b){b=b|0;var d=0,e=0;if(!(a[22832]|0)){a[22832]=1}d=b+76|0;b=c[d+4>>2]|0;e=24;c[e>>2]=c[d>>2];c[e+4>>2]=b;return 24}function hL(b){b=b|0;var d=0,e=0;if(!(a[22840]|0)){a[22840]=1}d=b+68|0;b=c[d+4>>2]|0;e=16;c[e>>2]=c[d>>2];c[e+4>>2]=b;return 16}function hM(a){a=a|0;return c[a+64>>2]|0}function hN(a){a=a|0;return c[a+52>>2]|0}function hO(b){b=b|0;return(a[b+61|0]&1)!=0|0}function hP(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function hQ(a){a=a|0;return c[a+12>>2]|0}function hR(a){a=a|0;var d=0;if((b[(c[a+48>>2]|0)+4>>1]&32)==0){d=0;return d|0}d=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;return d|0}function hS(a){a=a|0;return+(+g[a+112>>2])}function hT(a){a=a|0;var b=0,d=0.0,e=0,f=0.0,h=0.0,i=0.0,j=0,k=0.0;b=c[a>>2]|0;if((b|0)==-1){d=0.0;return+d}e=c[a+4>>2]|0;f=(+g[e+(b*36&-1)+8>>2]- +g[e+(b*36&-1)>>2]+(+g[e+(b*36&-1)+12>>2]- +g[e+(b*36&-1)+4>>2]))*2.0;b=c[a+12>>2]|0;if((b|0)>0){h=0.0;a=0;while(1){if((c[e+(a*36&-1)+32>>2]|0)<0){i=h}else{i=h+(+g[e+(a*36&-1)+8>>2]- +g[e+(a*36&-1)>>2]+(+g[e+(a*36&-1)+12>>2]- +g[e+(a*36&-1)+4>>2]))*2.0}j=a+1|0;if((j|0)<(b|0)){h=i;a=j}else{k=i;break}}}else{k=0.0}d=k/f;return+d}function hU(a){a=a|0;var b=0,d=0;b=c[a>>2]|0;if((b|0)==-1){d=0;return d|0}d=c[(c[a+4>>2]|0)+(b*36&-1)+32>>2]|0;return d|0}function hV(a){a=a|0;return c[a+28>>2]|0}function hW(a,b){a=a|0;b=b|0;var d=0;d=c[a+12>>2]|0;bN[c[(c[d>>2]|0)+28>>2]&127](d,b,+g[a>>2]);return}function hX(a,b){a=a|0;b=b|0;var d=0;d=c[a+12>>2]|0;return bv[c[(c[d>>2]|0)+16>>2]&127](d,(c[a+8>>2]|0)+12|0,b)|0}function hY(a){a=a|0;if((a|0)==0){return}vl(a);return}function hZ(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0;f=c[a+12>>2]|0;return bI[c[(c[f>>2]|0)+20>>2]&127](f,b,d,(c[a+8>>2]|0)+12|0,e)|0}function h_(a){a=a|0;dI(a);return}function h$(a,b){a=a|0;b=b|0;dJ(a,b);return}function h0(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[23e3]|0)){a[23e3]=1}bp[c[(c[b>>2]|0)+4>>2]&511](e,b);b=c[e+4>>2]|0;f=224;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 224}function h1(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[23008]|0)){a[23008]=1}bp[c[c[b>>2]>>2]&511](e,b);b=c[e+4>>2]|0;f=136;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 136}function h2(a){a=a|0;var b=0;b=vo(168)|0;fv(b,a);return b|0}function h3(b,d){b=b|0;d=+d;var e=0,f=0,g=0;e=i;i=i+8|0;f=e|0;if(!(a[22856]|0)){a[22856]=1}bN[c[(c[b>>2]|0)+8>>2]&127](f,b,d);b=c[f+4>>2]|0;g=40;c[g>>2]=c[f>>2];c[g+4>>2]=b;i=e;return 40}function h4(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+24>>2]&511](a);return}function h5(a){a=a|0;bo[c[(c[a>>2]|0)+16>>2]&511](a);return}function h6(a,b){a=a|0;b=+b;return+(+bw[c[(c[a>>2]|0)+12>>2]&127](a,b))}function h7(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+24>>2]&511](a);return}function h8(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[22960]|0)){a[22960]=1}bp[c[c[b>>2]>>2]&511](e,b);b=c[e+4>>2]|0;f=32;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 32}function h9(a,b){a=a|0;b=+b;return+(+bw[c[(c[a>>2]|0)+12>>2]&127](a,b))}function ia(a){a=a|0;bo[c[(c[a>>2]|0)+16>>2]&511](a);return}function ib(a){a=a|0;var b=0,d=0.0,e=0.0,f=0.0,h=0.0,i=0,j=0.0,k=0.0;b=c[a+52>>2]|0;d=+g[b+24>>2];e=+g[a+100>>2];f=+g[b+20>>2];h=+g[a+104>>2];i=a+76|0;j=+g[b+12>>2]+(d*e-f*h)- +g[i>>2];k=e*f+d*h+ +g[b+16>>2]- +g[i+4>>2];return+(+P(+(j*j+k*k)))}function ic(a){a=a|0;var b=0,d=0.0,e=0.0,f=0.0,h=0.0,i=0,j=0.0,k=0.0;b=c[a+48>>2]|0;d=+g[b+24>>2];e=+g[a+92>>2];f=+g[b+20>>2];h=+g[a+96>>2];i=a+68|0;j=+g[b+12>>2]+(d*e-f*h)- +g[i>>2];k=e*f+d*h+ +g[b+16>>2]- +g[i+4>>2];return+(+P(+(j*j+k*k)))}function id(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[22952]|0)){a[22952]=1}bp[c[(c[b>>2]|0)+4>>2]&511](e,b);b=c[e+4>>2]|0;f=8;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 8}function ie(b,d){b=b|0;d=+d;var e=0,f=0,g=0;e=i;i=i+8|0;f=e|0;if(!(a[22824]|0)){a[22824]=1}bN[c[(c[b>>2]|0)+8>>2]&127](f,b,d);b=c[f+4>>2]|0;g=392;c[g>>2]=c[f>>2];c[g+4>>2]=b;i=e;return 392}function ig(a){a=a|0;var b=0;b=vo(196)|0;fJ(b,a);return b|0}function ih(a){a=a|0;if((a|0)==0){return}vi(c[a+32>>2]|0);vi(c[a+44>>2]|0);vi(c[a+4>>2]|0);vl(a);return}function ii(){var a=0;a=vo(60)|0;b3(a);return a|0}function ij(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0;d=a+40|0;e=c[d>>2]|0;f=a+36|0;g=a+32|0;if((e|0)==(c[f>>2]|0)){a=c[g>>2]|0;c[f>>2]=e<<1;f=vh(e<<3)|0;c[g>>2]=f;h=a;a=c[d>>2]<<2;vp(f|0,h|0,a)|0;vi(h);i=c[d>>2]|0}else{i=e}c[(c[g>>2]|0)+(i<<2)>>2]=b;c[d>>2]=(c[d>>2]|0)+1;return}function ik(a,b,c){a=a|0;b=b|0;c=c|0;return b4(a,b,c)|0}function il(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;if(!(cn(a|0,b,d,e)|0)){return}e=a+40|0;d=c[e>>2]|0;f=a+36|0;g=a+32|0;if((d|0)==(c[f>>2]|0)){a=c[g>>2]|0;c[f>>2]=d<<1;f=vh(d<<3)|0;c[g>>2]=f;h=a;a=c[e>>2]<<2;vp(f|0,h|0,a)|0;vi(h);i=c[e>>2]|0}else{i=d}c[(c[g>>2]|0)+(i<<2)>>2]=b;c[e>>2]=(c[e>>2]|0)+1;return}function im(a,b){a=a|0;b=b|0;do{if((b|0)>-1){if((c[a+12>>2]|0)<=(b|0)){break}return(c[a+4>>2]|0)+(b*36&-1)|0}}while(0);ba(10360,159,14456,9904);return 0}function io(a,b){a=a|0;b=b|0;do{if((b|0)>-1){if((c[a+12>>2]|0)<=(b|0)){break}return c[(c[a+4>>2]|0)+(b*36&-1)+16>>2]|0}}while(0);ba(10360,153,14408,9904);return 0}function ip(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;b=c[a+12>>2]|0;if((b|0)<=0){d=0;return d|0}e=c[a+4>>2]|0;a=0;f=0;while(1){if((c[e+(a*36&-1)+32>>2]|0)<2){g=f}else{h=c[e+(a*36&-1)+24>>2]|0;if((h|0)==-1){i=429;break}j=(c[e+((c[e+(a*36&-1)+28>>2]|0)*36&-1)+32>>2]|0)-(c[e+(h*36&-1)+32>>2]|0)|0;h=(j|0)>0?j:-j|0;g=(f|0)>(h|0)?f:h}h=a+1|0;if((h|0)<(b|0)){a=h;f=g}else{d=g;i=433;break}}if((i|0)==429){ba(11392,686,14312,7360);return 0}else if((i|0)==433){return d|0}return 0}function iq(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0;if((b|0)<=-1){ba(10360,159,14456,9904);return 0}e=c[a+12>>2]|0;if((e|0)<=(b|0)){ba(10360,159,14456,9904);return 0}f=c[a+4>>2]|0;if((d|0)>-1&(e|0)>(d|0)){return(+g[f+(d*36&-1)>>2]- +g[f+(b*36&-1)+8>>2]>0.0|+g[f+(d*36&-1)+4>>2]- +g[f+(b*36&-1)+12>>2]>0.0|+g[f+(b*36&-1)>>2]- +g[f+(d*36&-1)+8>>2]>0.0|+g[f+(b*36&-1)+4>>2]- +g[f+(d*36&-1)+12>>2]>0.0)^1|0}else{ba(10360,159,14456,9904);return 0}return 0}function ir(b,c){b=b|0;c=c|0;a[b+102994|0]=c&1;return}function is(a){a=a|0;var b=0,d=0.0,e=0,f=0.0,h=0.0,i=0.0,j=0,k=0.0;b=c[a+102872>>2]|0;if((b|0)==-1){d=0.0;return+d}e=c[a+102876>>2]|0;f=(+g[e+(b*36&-1)+8>>2]- +g[e+(b*36&-1)>>2]+(+g[e+(b*36&-1)+12>>2]- +g[e+(b*36&-1)+4>>2]))*2.0;b=c[a+102884>>2]|0;if((b|0)>0){h=0.0;a=0;while(1){if((c[e+(a*36&-1)+32>>2]|0)<0){i=h}else{i=h+(+g[e+(a*36&-1)+8>>2]- +g[e+(a*36&-1)>>2]+(+g[e+(a*36&-1)+12>>2]- +g[e+(a*36&-1)+4>>2]))*2.0}j=a+1|0;if((j|0)<(b|0)){h=i;a=j}else{k=i;break}}}else{k=0.0}d=k/f;return+d}function it(a){a=a|0;var b=0,d=0;b=c[a+102872>>2]|0;if((b|0)==-1){d=0;return d|0}d=c[(c[a+102876>>2]|0)+(b*36&-1)+32>>2]|0;return d|0}function iu(a){a=a|0;return a+102996|0}function iv(b){b=b|0;return(a[b+102994|0]&1)!=0|0}function iw(a){a=a|0;return a+102872|0}function ix(a,b){a=a|0;b=b|0;c[a+102944>>2]=b;return}function iy(b,c){b=b|0;c=c|0;a[b+102993|0]=c&1;return}function iz(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+102968|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function iA(a){a=a|0;return c[a+102960>>2]|0}function iB(a){a=a|0;return(c[a+102868>>2]&4|0)!=0|0}function iC(b){b=b|0;return(a[b+102993|0]&1)!=0|0}function iD(a){a=a|0;return c[a+102956>>2]|0}function iE(a){a=a|0;return c[a+102952>>2]|0}function iF(a,b){a=a|0;b=b|0;c[a+102980>>2]=b;return}function iG(a){a=a|0;return c[a+102964>>2]|0}function iH(a){a=a|0;var b=0,d=0;b=c[a+102952>>2]|0;if((b|0)==0){return}else{d=b}do{g[d+76>>2]=0.0;g[d+80>>2]=0.0;g[d+84>>2]=0.0;d=c[d+96>>2]|0;}while((d|0)!=0);return}function iI(b){b=b|0;return(a[b+102992|0]&1)!=0|0}function iJ(d,e){d=d|0;e=e|0;var f=0,h=0;f=d+102976|0;if((e&1|0)==(a[f]&1|0)){return}a[f]=e&1;if(e){return}e=c[d+102952>>2]|0;if((e|0)==0){return}else{h=e}do{e=h+4|0;d=b[e>>1]|0;if((d&2)==0){b[e>>1]=d|2;g[h+144>>2]=0.0}h=c[h+96>>2]|0;}while((h|0)!=0);return}function iK(b){b=b|0;return(a[b+102976|0]&1)!=0|0}function iL(a){a=a|0;return c[a+102900>>2]|0}function iM(a){a=a|0;return(c[a+102868>>2]&2|0)!=0|0}function iN(a){a=a|0;return c[a+102932>>2]|0}function iO(a,b){a=a|0;b=b|0;c[a+102984>>2]=b;return}function iP(a,b){a=a|0;b=b|0;var d=0;d=a+102868|0;a=c[d>>2]|0;c[d>>2]=b?a|4:a&-5;return}function iQ(b){b=b|0;var d=0,e=0;if(!(a[23096]|0)){a[23096]=1}d=b+102968|0;b=c[d+4>>2]|0;e=384;c[e>>2]=c[d>>2];c[e+4>>2]=b;return 384}function iR(a){a=a|0;return c[a+102936>>2]|0}function iS(b,c){b=b|0;c=c|0;a[b+102992|0]=c&1;return}function iT(a,b){a=a|0;b=b|0;c[a+102940>>2]=b;return}function iU(a){a=a|0;return c[a+48>>2]|0}function iV(a){a=a|0;return c[a+52>>2]|0}function iW(a){a=a|0;return c[a+64>>2]|0}function iX(a){a=a|0;return a+84|0}function iY(a){a=a|0;return+(+g[a+120>>2])}function iZ(a){a=a|0;return c[a+12>>2]|0}function i_(a){a=a|0;return a+68|0}function i$(a,d){a=a|0;d=+d;var e=0,f=0,h=0,i=0;e=c[a+48>>2]|0;f=e+4|0;h=b[f>>1]|0;if((h&2)==0){b[f>>1]=h|2;g[e+144>>2]=0.0}e=c[a+52>>2]|0;h=e+4|0;f=b[h>>1]|0;if((f&2)!=0){i=a+132|0;g[i>>2]=d;return}b[h>>1]=f|2;g[e+144>>2]=0.0;i=a+132|0;g[i>>2]=d;return}function i0(a){a=a|0;return a+76|0}function i1(a){a=a|0;return+(+g[a+132>>2])}function i2(a,d){a=a|0;d=+d;var e=0,f=0,h=0,i=0;e=c[a+48>>2]|0;f=e+4|0;h=b[f>>1]|0;if((h&2)==0){b[f>>1]=h|2;g[e+144>>2]=0.0}e=c[a+52>>2]|0;h=e+4|0;f=b[h>>1]|0;if((f&2)!=0){i=a+128|0;g[i>>2]=d;return}b[h>>1]=f|2;g[e+144>>2]=0.0;i=a+128|0;g[i>>2]=d;return}function i3(d,e){d=d|0;e=e|0;var f=0,h=0,i=0,j=0;f=d+136|0;if((e&1|0)==(a[f]&1|0)){return}h=c[d+48>>2]|0;i=h+4|0;j=b[i>>1]|0;if((j&2)==0){b[i>>1]=j|2;g[h+144>>2]=0.0}h=c[d+52>>2]|0;j=h+4|0;i=b[j>>1]|0;if((i&2)==0){b[j>>1]=i|2;g[h+144>>2]=0.0}a[f]=e&1;g[d+112>>2]=0.0;return}function i4(b){b=b|0;return(a[b+137|0]&1)!=0|0}function i5(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function i6(a){a=a|0;return+(+g[a+128>>2])}function i7(b){b=b|0;return(a[b+61|0]&1)!=0|0}function i8(a){a=a|0;var b=0,d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0,p=0;b=c[a+48>>2]|0;d=c[a+52>>2]|0;e=+g[a+68>>2]- +g[b+28>>2];f=+g[a+72>>2]- +g[b+32>>2];h=+g[b+24>>2];i=+g[b+20>>2];j=e*h-f*i;k=h*f+e*i;e=+g[a+76>>2]- +g[d+28>>2];f=+g[a+80>>2]- +g[d+32>>2];l=+g[d+24>>2];m=+g[d+20>>2];n=e*l-f*m;o=l*f+e*m;m=+g[a+84>>2];e=+g[a+88>>2];f=h*m-i*e;l=i*m+h*e;a=b+64|0;p=d+64|0;e=+g[b+72>>2];h=+g[d+72>>2];m=-0.0-e;return+((o+ +g[d+48>>2]-(k+ +g[b+48>>2]))*f*e+(n+ +g[d+44>>2]-(j+ +g[b+44>>2]))*l*m+(l*(+g[p+4>>2]+n*h- +g[a+4>>2]-j*e)+f*(+g[p>>2]+o*(-0.0-h)- +g[a>>2]-k*m)))}function i9(d,e){d=d|0;e=e|0;var f=0,h=0,i=0,j=0,k=0;f=c[d+48>>2]|0;h=f+4|0;i=b[h>>1]|0;if((i&2)==0){b[h>>1]=i|2;g[f+144>>2]=0.0}f=c[d+52>>2]|0;i=f+4|0;h=b[i>>1]|0;if((h&2)!=0){j=d+137|0;k=e&1;a[j]=k;return}b[i>>1]=h|2;g[f+144>>2]=0.0;j=d+137|0;k=e&1;a[j]=k;return}function ja(a){a=a|0;return+(+g[a+100>>2])}function jb(a,b){a=a|0;b=+b;return+(+g[a+116>>2]*b)}function jc(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;d=c[a+40>>2]|0;e=a+32|0;f=0;while(1){if((f|0)>=(d|0)){break}g=(c[e>>2]|0)+(f<<2)|0;if((c[g>>2]|0)==(b|0)){h=549;break}else{f=f+1|0}}if((h|0)==549){c[g>>2]=-1}g=a+28|0;c[g>>2]=(c[g>>2]|0)-1;cl(a|0,b);return}function jd(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0;e=i;i=i+8|0;f=e|0;g=a+102872|0;c[f>>2]=g;c[f+4>>2]=b;d8(g|0,f,d);i=e;return}function je(a){a=a|0;dZ(a);return}function jf(a,b){a=a|0;b=b|0;dR(a,b);return}function jg(a){a=a|0;var b=0;b=vo(103028)|0;dO(b,a);return b|0}function jh(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;dV(a,b,c,d);return}function ji(a,b){a=a|0;b=b|0;dQ(a,b);return}function jj(a,b){a=a|0;b=b|0;return dS(a,b)|0}function jk(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0,j=0,k=0;f=i;i=i+32|0;h=f|0;j=f+8|0;k=a+102872|0;c[h>>2]=k;c[h+4>>2]=b;g[j+16>>2]=1.0;b=d;d=j;a=c[b+4>>2]|0;c[d>>2]=c[b>>2];c[d+4>>2]=a;a=e;e=j+8|0;d=c[a+4>>2]|0;c[e>>2]=c[a>>2];c[e+4>>2]=d;d6(k|0,h,j);i=f;return}function jl(a){a=a|0;if((a|0)==0){return}dP(a);vl(a);return}function jm(a){a=a|0;dX(a);return}function jn(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[22896]|0)){a[22896]=1}bp[c[c[b>>2]>>2]&511](e,b);b=c[e+4>>2]|0;f=376;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 376}function jo(a){a=a|0;var b=0;b=vo(256)|0;fx(b,a);return b|0}function jp(b,d){b=b|0;d=+d;var e=0,f=0,g=0;e=i;i=i+8|0;f=e|0;if(!(a[22792]|0)){a[22792]=1}bN[c[(c[b>>2]|0)+8>>2]&127](f,b,d);b=c[f+4>>2]|0;g=368;c[g>>2]=c[f>>2];c[g+4>>2]=b;i=e;return 368}function jq(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+24>>2]&511](a);return}function jr(a){a=a|0;bo[c[(c[a>>2]|0)+16>>2]&511](a);return}function js(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;b=c[a+102884>>2]|0;if((b|0)<=0){d=0;return d|0}e=c[a+102876>>2]|0;a=0;f=0;while(1){if((c[e+(a*36&-1)+32>>2]|0)<2){g=f}else{h=c[e+(a*36&-1)+24>>2]|0;if((h|0)==-1){i=588;break}j=(c[e+((c[e+(a*36&-1)+28>>2]|0)*36&-1)+32>>2]|0)-(c[e+(h*36&-1)+32>>2]|0)|0;h=(j|0)>0?j:-j|0;g=(f|0)>(h|0)?f:h}h=a+1|0;if((h|0)<(b|0)){a=h;f=g}else{d=g;i=592;break}}if((i|0)==592){return d|0}else if((i|0)==588){ba(11392,686,14312,7360);return 0}return 0}function jt(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;if((c[a+102868>>2]&2|0)!=0){ba(10624,109,15664,12392);return 0}d=df(a|0,152)|0;if((d|0)==0){e=0}else{f=d;dh(f,b,a);e=f}c[e+92>>2]=0;f=a+102952|0;c[e+96>>2]=c[f>>2];b=c[f>>2]|0;if((b|0)!=0){c[b+92>>2]=e}c[f>>2]=e;f=a+102960|0;c[f>>2]=(c[f>>2]|0)+1;return e|0}function ju(a){a=a|0;return 1}function jv(a,b){a=a|0;b=b|0;return 0}function jw(a){a=a|0;var b=0,d=0.0,e=0.0,f=0.0,h=0.0,i=0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0;b=c[a+48>>2]|0;d=+g[b+24>>2];e=+g[a+68>>2];f=+g[b+20>>2];h=+g[a+72>>2];i=c[a+52>>2]|0;j=+g[i+24>>2];k=+g[a+76>>2];l=+g[i+20>>2];m=+g[a+80>>2];n=+g[a+84>>2];o=+g[a+88>>2];return+((+g[i+12>>2]+(j*k-l*m)-(+g[b+12>>2]+(d*e-f*h)))*(d*n-f*o)+(k*l+j*m+ +g[i+16>>2]-(e*f+d*h+ +g[b+16>>2]))*(f*n+d*o))}function jx(a){a=a|0;return c[a+4>>2]|0}function jy(b){b=b|0;return(a[b+136|0]&1)!=0|0}function jz(a){a=a|0;return+(+g[a+124>>2])}function jA(a){a=a|0;var d=0;if((b[(c[a+48>>2]|0)+4>>1]&32)==0){d=0;return d|0}d=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;return d|0}function jB(a){a=a|0;return c[a+4>>2]|0}function jC(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function jD(a){a=a|0;return+(+g[a+8>>2])}function jE(a,b){a=a|0;b=b|0;return a+12|0}function jF(a,b){a=a|0;b=b|0;return a+12|0}function jG(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+12|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function jH(a){a=a|0;return a+12|0}function jI(a){a=a|0;return c[a+48>>2]|0}function jJ(a){a=a|0;return c[a+52>>2]|0}function jK(a){a=a|0;return c[a+64>>2]|0}function jL(a){a=a|0;return a+92|0}function jM(a,b){a=a|0;b=+b;g[a+72>>2]=b;return}function jN(a){a=a|0;return c[a+12>>2]|0}function jO(a){a=a|0;return+(+g[a+68>>2])}function jP(a){a=a|0;return a+76|0}function jQ(a,d){a=a|0;d=+d;var e=0,f=0,h=0,i=0;e=c[a+48>>2]|0;f=e+4|0;h=b[f>>1]|0;if((h&2)==0){b[f>>1]=h|2;g[e+144>>2]=0.0}e=c[a+52>>2]|0;h=e+4|0;f=b[h>>1]|0;if((f&2)!=0){i=a+124|0;g[i>>2]=d;return}b[h>>1]=f|2;g[e+144>>2]=0.0;i=a+124|0;g[i>>2]=d;return}function jR(a){a=a|0;return a+84|0}function jS(a){a=a|0;return+(+g[a+124>>2])}function jT(a,b){a=a|0;b=+b;return+(+g[a+112>>2]*b)}function jU(b){b=b|0;return(a[b+128|0]&1)!=0|0}function jV(a){a=a|0;var b=0,d=0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0,k=0.0,l=0.0,m=0.0,n=0.0,o=0.0;b=c[a+48>>2]|0;d=c[a+52>>2]|0;e=+g[b+24>>2];f=+g[a+76>>2];h=+g[b+20>>2];i=+g[a+80>>2];j=+g[d+24>>2];k=+g[a+84>>2];l=+g[d+20>>2];m=+g[a+88>>2];n=+g[a+92>>2];o=+g[a+96>>2];return+((+g[d+12>>2]+(j*k-l*m)-(+g[b+12>>2]+(e*f-h*i)))*(e*n-h*o)+(k*l+j*m+ +g[d+16>>2]-(f*h+e*i+ +g[b+16>>2]))*(h*n+e*o))}function jW(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function jX(a){a=a|0;return+(+g[a+72>>2])}function jY(a,d){a=a|0;d=+d;var e=0,f=0,h=0,i=0;e=c[a+48>>2]|0;f=e+4|0;h=b[f>>1]|0;if((h&2)==0){b[f>>1]=h|2;g[e+144>>2]=0.0}e=c[a+52>>2]|0;h=e+4|0;f=b[h>>1]|0;if((f&2)!=0){i=a+120|0;g[i>>2]=d;return}b[h>>1]=f|2;g[e+144>>2]=0.0;i=a+120|0;g[i>>2]=d;return}function jZ(b){b=b|0;return(a[b+61|0]&1)!=0|0}function j_(a){a=a|0;return+(+g[(c[a+52>>2]|0)+72>>2]- +g[(c[a+48>>2]|0)+72>>2])}function j$(d,e){d=d|0;e=e|0;var f=0,h=0,i=0,j=0,k=0;f=c[d+48>>2]|0;h=f+4|0;i=b[h>>1]|0;if((i&2)==0){b[h>>1]=i|2;g[f+144>>2]=0.0}f=c[d+52>>2]|0;i=f+4|0;h=b[i>>1]|0;if((h&2)!=0){j=d+128|0;k=e&1;a[j]=k;return}b[i>>1]=h|2;g[f+144>>2]=0.0;j=d+128|0;k=e&1;a[j]=k;return}function j0(a){a=a|0;return+(+g[a+120>>2])}function j1(a){a=a|0;return c[a+4>>2]|0}function j2(a,b){a=a|0;b=+b;g[a+68>>2]=b;return}function j3(a){a=a|0;var d=0;if((b[(c[a+48>>2]|0)+4>>1]&32)==0){d=0;return d|0}d=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;return d|0}function j4(a,b){a=a|0;b=b|0;var d=0;d=a+4|0;c[d>>2]=c[d>>2]|b;return}function j5(a,b){a=a|0;b=b|0;var d=0;d=a+4|0;c[d>>2]=c[d>>2]&(b^-1);return}function j6(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function j7(a){a=a|0;return c[a+4>>2]|0}function j8(a){a=a|0;return c[a+12>>2]|0}function j9(a){a=a|0;return c[a+48>>2]|0}function ka(a){a=a|0;return c[a+52>>2]|0}function kb(a){a=a|0;return c[a+64>>2]|0}function kc(a){a=a|0;return c[a+4>>2]|0}function kd(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function ke(b){b=b|0;return(a[b+61|0]&1)!=0|0}function kf(a){a=a|0;var d=0;if((b[(c[a+48>>2]|0)+4>>1]&32)==0){d=0;return d|0}d=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;return d|0}function kg(a){a=a|0;return c[a+68>>2]|0}function kh(a){a=a|0;return c[a+72>>2]|0}function ki(a,b){a=a|0;b=+b;return+(+bw[c[(c[a>>2]|0)+12>>2]&127](a,b))}function kj(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[22888]|0)){a[22888]=1}bp[c[(c[b>>2]|0)+4>>2]&511](e,b);b=c[e+4>>2]|0;f=360;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 360}function kk(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+4>>2]&511](a);return}function kl(a,b,d){a=a|0;b=b|0;d=+d;bN[c[(c[a>>2]|0)+28>>2]&127](a,b,d);return}function km(a,b){a=a|0;b=b|0;return bF[c[(c[a>>2]|0)+8>>2]&255](a,b)|0}function kn(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;return bI[c[(c[a>>2]|0)+20>>2]&127](a,b,d,e,f)|0}function ko(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;bO[c[(c[a>>2]|0)+24>>2]&127](a,b,d,e);return}function kp(a){a=a|0;return bq[c[(c[a>>2]|0)+12>>2]&1023](a)|0}function kq(a,b,d){a=a|0;b=b|0;d=d|0;return bv[c[(c[a>>2]|0)+16>>2]&127](a,b,d)|0}function kr(){var a=0;a=vo(20)|0;c[a>>2]=20136;vq(a+4|0,0,16);return a|0}function ks(a,b){a=a|0;b=b|0;aT(a|0,b|0);return}function kt(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[22984]|0)){a[22984]=1}bp[c[(c[b>>2]|0)+4>>2]&511](e,b);b=c[e+4>>2]|0;f=352;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 352}function ku(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[22992]|0)){a[22992]=1}bp[c[c[b>>2]>>2]&511](e,b);b=c[e+4>>2]|0;f=344;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 344}function kv(a){a=a|0;var b=0;b=vo(224)|0;gn(b,a);return b|0}function kw(b,d){b=b|0;d=+d;var e=0,f=0,g=0;e=i;i=i+8|0;f=e|0;if(!(a[22848]|0)){a[22848]=1}bN[c[(c[b>>2]|0)+8>>2]&127](f,b,d);b=c[f+4>>2]|0;g=336;c[g>>2]=c[f>>2];c[g+4>>2]=b;i=e;return 336}function kx(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+24>>2]&511](a);return}function ky(a){a=a|0;bo[c[(c[a>>2]|0)+16>>2]&511](a);return}function kz(a,b){a=a|0;b=+b;return+(+bw[c[(c[a>>2]|0)+12>>2]&127](a,b))}function kA(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+4>>2]&511](a);return}function kB(a,b){a=a|0;b=b|0;bp[c[(c[a>>2]|0)+28>>2]&511](a,b);return}function kC(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;bO[c[(c[a>>2]|0)+8>>2]&127](a,b,d,e);return}function kD(a,b,d,e,f){a=a|0;b=b|0;d=+d;e=e|0;f=f|0;bn[c[(c[a>>2]|0)+20>>2]&63](a,b,d,e,f);return}function kE(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;bO[c[(c[a>>2]|0)+12>>2]&127](a,b,d,e);return}function kF(a,b,d,e){a=a|0;b=b|0;d=+d;e=e|0;br[c[(c[a>>2]|0)+16>>2]&63](a,b,d,e);return}function kG(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;bO[c[(c[a>>2]|0)+24>>2]&127](a,b,d,e);return}function kH(){var a=0;a=vo(8)|0;c[a>>2]=19368;c[a+4>>2]=0;return a|0}function kI(a,b){a=a|0;b=+b;return+(+bw[c[(c[a>>2]|0)+12>>2]&127](a,b))}function kJ(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[23112]|0)){a[23112]=1}bp[c[c[b>>2]>>2]&511](e,b);b=c[e+4>>2]|0;f=328;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 328}function kK(a){a=a|0;bo[c[(c[a>>2]|0)+16>>2]&511](a);return}function kL(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[23104]|0)){a[23104]=1}bp[c[(c[b>>2]|0)+4>>2]&511](e,b);b=c[e+4>>2]|0;f=320;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 320}function kM(b,d){b=b|0;d=+d;var e=0,f=0,g=0;e=i;i=i+8|0;f=e|0;if(!(a[22968]|0)){a[22968]=1}bN[c[(c[b>>2]|0)+8>>2]&127](f,b,d);b=c[f+4>>2]|0;g=304;c[g>>2]=c[f>>2];c[g+4>>2]=b;i=e;return 304}function kN(a){a=a|0;var b=0;b=vo(276)|0;e6(b,a);return b|0}function kO(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[23056]|0)){a[23056]=1}bp[c[c[b>>2]>>2]&511](e,b);b=c[e+4>>2]|0;f=296;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 296}function kP(a,b){a=a|0;b=+b;return+(+bw[c[(c[a>>2]|0)+12>>2]&127](a,b))}function kQ(a,d,e){a=a|0;d=+d;e=+e;var f=0,h=0,i=0,j=0;if(d>e){ba(6832,575,17248,11440)}f=a+120|0;do{if(+g[f>>2]==d){if(+g[a+124>>2]!=e){break}return}}while(0);h=c[a+48>>2]|0;i=h+4|0;j=b[i>>1]|0;if((j&2)==0){b[i>>1]=j|2;g[h+144>>2]=0.0}h=c[a+52>>2]|0;j=h+4|0;i=b[j>>1]|0;if((i&2)==0){b[j>>1]=i|2;g[h+144>>2]=0.0}g[f>>2]=d;g[a+124>>2]=e;g[a+112>>2]=0.0;return}function kR(a){a=a|0;return c[a+4>>2]|0}function kS(a){a=a|0;return c[a+64>>2]|0}function kT(a){a=a|0;return c[a+52>>2]|0}function kU(b){b=b|0;return(a[b+61|0]&1)!=0|0}function kV(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function kW(a){a=a|0;return c[a+48>>2]|0}function kX(a){a=a|0;return c[a+12>>2]|0}function kY(a){a=a|0;var d=0;if((b[(c[a+48>>2]|0)+4>>1]&32)==0){d=0;return d|0}d=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;return d|0}function kZ(a){a=a|0;return+(+g[a+152>>2])}function k_(a){a=a|0;var b=0,d=0;b=c[a>>2]|0;if((b|0)==-1){d=0;return d|0}d=c[(c[a+4>>2]|0)+(b*36&-1)+32>>2]|0;return d|0}function k$(a){a=a|0;var b=0,d=0.0,e=0,f=0.0,h=0.0,i=0.0,j=0,k=0.0;b=c[a>>2]|0;if((b|0)==-1){d=0.0;return+d}e=c[a+4>>2]|0;f=(+g[e+(b*36&-1)+8>>2]- +g[e+(b*36&-1)>>2]+(+g[e+(b*36&-1)+12>>2]- +g[e+(b*36&-1)+4>>2]))*2.0;b=c[a+12>>2]|0;if((b|0)>0){h=0.0;a=0;while(1){if((c[e+(a*36&-1)+32>>2]|0)<0){i=h}else{i=h+(+g[e+(a*36&-1)+8>>2]- +g[e+(a*36&-1)>>2]+(+g[e+(a*36&-1)+12>>2]- +g[e+(a*36&-1)+4>>2]))*2.0}j=a+1|0;if((j|0)<(b|0)){h=i;a=j}else{k=i;break}}}else{k=0.0}d=k/f;return+d}function k0(a){a=a|0;return c[a+48>>2]|0}function k1(a){a=a|0;return c[a+52>>2]|0}function k2(a,b){a=a|0;b=+b;g[a+68>>2]=b;return}function k3(a){a=a|0;return c[a+64>>2]|0}function k4(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function k5(a){a=a|0;return c[a+12>>2]|0}function k6(a){a=a|0;return a+80|0}function k7(a){a=a|0;return a+88|0}function k8(a){a=a|0;return+(+g[a+68>>2])}function k9(a){a=a|0;return+(+g[a+72>>2])}function la(b){b=b|0;return(a[b+61|0]&1)!=0|0}function lb(a){a=a|0;return+(+g[a+96>>2])}function lc(a){a=a|0;return c[a+4>>2]|0}function ld(a,b){a=a|0;b=+b;g[a+72>>2]=b;return}function le(a){a=a|0;var d=0;if((b[(c[a+48>>2]|0)+4>>1]&32)==0){d=0;return d|0}d=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;return d|0}function lf(a){a=a|0;return c[a+48>>2]|0}function lg(a){a=a|0;return c[a+52>>2]|0}function lh(a){a=a|0;return c[a+64>>2]|0}function li(a){a=a|0;return+(+g[a+120>>2])}function lj(a){a=a|0;return c[a+12>>2]|0}function lk(a){a=a|0;return a+68|0}function ll(a,d){a=a|0;d=+d;var e=0,f=0,h=0,i=0;e=c[a+48>>2]|0;f=e+4|0;h=b[f>>1]|0;if((h&2)==0){b[f>>1]=h|2;g[e+144>>2]=0.0}e=c[a+52>>2]|0;h=e+4|0;f=b[h>>1]|0;if((f&2)!=0){i=a+108|0;g[i>>2]=d;return}b[h>>1]=f|2;g[e+144>>2]=0.0;i=a+108|0;g[i>>2]=d;return}function lm(a){a=a|0;return a+76|0}function ln(a){a=a|0;return+(+g[(c[a+52>>2]|0)+56>>2]- +g[(c[a+48>>2]|0)+56>>2]- +g[a+116>>2])}function lo(a){a=a|0;return+(+g[a+108>>2])}function lp(a,b){a=a|0;b=+b;return+(+g[a+96>>2]*b)}function lq(b){b=b|0;return(a[b+112|0]&1)!=0|0}function lr(a){a=a|0;bo[c[(c[a>>2]|0)+16>>2]&511](a);return}function ls(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+24>>2]&511](a);return}function lt(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[23048]|0)){a[23048]=1}bp[c[(c[b>>2]|0)+4>>2]&511](e,b);b=c[e+4>>2]|0;f=288;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 288}function lu(b,d){b=b|0;d=+d;var e=0,f=0,g=0;e=i;i=i+8|0;f=e|0;if(!(a[22880]|0)){a[22880]=1}bN[c[(c[b>>2]|0)+8>>2]&127](f,b,d);b=c[f+4>>2]|0;g=280;c[g>>2]=c[f>>2];c[g+4>>2]=b;i=e;return 280}function lv(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=+f;return+(+bG[c[(c[a>>2]|0)+8>>2]&63](a,b,d,e,f))}function lw(){var a=0;a=vo(4)|0;c[a>>2]=19608;return a|0}function lx(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+4>>2]&511](a);return}function ly(a){a=a|0;if((a|0)==0){return}vi(c[a+4>>2]|0);vl(a);return}function lz(){var a=0,b=0,d=0,e=0,f=0,g=0;a=vo(28)|0;b=a;c[a>>2]=-1;c[a+12>>2]=16;c[a+8>>2]=0;d=vh(576)|0;e=d;c[a+4>>2]=e;vq(d|0,0,576);f=0;while(1){g=f+1|0;c[e+(f*36&-1)+20>>2]=g;c[e+(f*36&-1)+32>>2]=-1;if((g|0)<15){f=g}else{break}}c[d+560>>2]=-1;c[d+572>>2]=-1;c[a+16>>2]=0;c[a+20>>2]=0;c[a+24>>2]=0;return b|0}function lA(a){a=a|0;ct(a);return}function lB(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,h=0,i=0.0;e=cj(a)|0;f=a+4|0;h=(c[f>>2]|0)+(e*36&-1)|0;i=+(+g[b+4>>2]+-.10000000149011612);g[h>>2]=+g[b>>2]+-.10000000149011612;g[h+4>>2]=i;h=(c[f>>2]|0)+(e*36&-1)+8|0;i=+(+g[b+12>>2]+.10000000149011612);g[h>>2]=+g[b+8>>2]+.10000000149011612;g[h+4>>2]=i;c[(c[f>>2]|0)+(e*36&-1)+16>>2]=d;c[(c[f>>2]|0)+(e*36&-1)+32>>2]=0;ck(a,e);return e|0}function lC(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return cn(a,b,c,d)|0}function lD(a){a=a|0;cs(a);return}function lE(a,b){a=a|0;b=b|0;cl(a,b);return}function lF(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[23016]|0)){a[23016]=1}bp[c[(c[b>>2]|0)+4>>2]&511](e,b);b=c[e+4>>2]|0;f=272;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 272}function lG(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[23024]|0)){a[23024]=1}bp[c[c[b>>2]>>2]&511](e,b);b=c[e+4>>2]|0;f=264;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 264}function lH(b,d){b=b|0;d=+d;var e=0,f=0,g=0;e=i;i=i+8|0;f=e|0;if(!(a[22864]|0)){a[22864]=1}bN[c[(c[b>>2]|0)+8>>2]&127](f,b,d);b=c[f+4>>2]|0;g=256;c[g>>2]=c[f>>2];c[g+4>>2]=b;i=e;return 256}function lI(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+24>>2]&511](a);return}function lJ(a){a=a|0;bo[c[(c[a>>2]|0)+16>>2]&511](a);return}function lK(a,b){a=a|0;b=+b;return+(+bw[c[(c[a>>2]|0)+12>>2]&127](a,b))}function lL(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[22912]|0)){a[22912]=1}bp[c[c[b>>2]>>2]&511](e,b);b=c[e+4>>2]|0;f=248;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 248}function lM(a,b){a=a|0;b=+b;if(b==b&!(C=0.0,C!=C)&b>+-p&b<+p){g[a+152>>2]=b;return}else{ba(7384,398,18616,6992)}}function lN(a,b){a=a|0;b=b|0;do{if((b|0)>-1){if((c[a+12>>2]|0)<=(b|0)){break}return(c[a+4>>2]|0)+(b*36&-1)|0}}while(0);ba(10360,159,14456,9904);return 0}function lO(a,b){a=a|0;b=b|0;do{if((b|0)>-1){if((c[a+12>>2]|0)<=(b|0)){break}return c[(c[a+4>>2]|0)+(b*36&-1)+16>>2]|0}}while(0);ba(10360,153,14408,9904);return 0}function lP(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;b=c[a+12>>2]|0;if((b|0)<=0){d=0;return d|0}e=c[a+4>>2]|0;a=0;f=0;while(1){if((c[e+(a*36&-1)+32>>2]|0)<2){g=f}else{h=c[e+(a*36&-1)+24>>2]|0;if((h|0)==-1){i=891;break}j=(c[e+((c[e+(a*36&-1)+28>>2]|0)*36&-1)+32>>2]|0)-(c[e+(h*36&-1)+32>>2]|0)|0;h=(j|0)>0?j:-j|0;g=(f|0)>(h|0)?f:h}h=a+1|0;if((h|0)<(b|0)){a=h;f=g}else{d=g;i=896;break}}if((i|0)==891){ba(11392,686,14312,7360);return 0}else if((i|0)==896){return d|0}return 0}function lQ(b){b=b|0;var d=0,e=0,f=0,h=0;d=vo(208)|0;e=d;c[e>>2]=19312;f=c[b+8>>2]|0;h=c[b+12>>2]|0;if((f|0)!=(h|0)){c[d+4>>2]=c[b>>2];c[d+8>>2]=0;c[d+12>>2]=0;c[d+48>>2]=f;c[d+52>>2]=h;c[d+56>>2]=0;a[d+61|0]=a[b+16|0]&1;a[d+60|0]=0;c[d+64>>2]=c[b+4>>2];vq(d+16|0,0,32);c[e>>2]=20344;e=b+20|0;h=d+80|0;f=c[e+4>>2]|0;c[h>>2]=c[e>>2];c[h+4>>2]=f;f=b+28|0;h=d+88|0;e=c[f+4>>2]|0;c[h>>2]=c[f>>2];c[h+4>>2]=e;g[d+96>>2]=+g[b+36>>2];g[d+68>>2]=+g[b+40>>2];g[d+72>>2]=+g[b+44>>2];g[d+104>>2]=0.0;g[d+108>>2]=0.0;g[d+112>>2]=0.0;return d|0}ba(7272,173,15744,9072);return 0}function lR(b){b=b|0;var d=0,e=0,f=0,h=0;d=vo(228)|0;e=d;c[e>>2]=19312;f=c[b+8>>2]|0;h=c[b+12>>2]|0;if((f|0)!=(h|0)){c[d+4>>2]=c[b>>2];c[d+8>>2]=0;c[d+12>>2]=0;c[d+48>>2]=f;c[d+52>>2]=h;c[d+56>>2]=0;a[d+61|0]=a[b+16|0]&1;a[d+60|0]=0;c[d+64>>2]=c[b+4>>2];vq(d+16|0,0,32);c[e>>2]=19768;e=b+20|0;h=d+68|0;f=c[e+4>>2]|0;c[h>>2]=c[e>>2];c[h+4>>2]=f;f=b+28|0;h=d+76|0;e=c[f+4>>2]|0;c[h>>2]=c[f>>2];c[h+4>>2]=e;g[d+116>>2]=+g[b+36>>2];vq(d+84|0,0,16);g[d+120>>2]=+g[b+44>>2];g[d+124>>2]=+g[b+48>>2];g[d+104>>2]=+g[b+60>>2];g[d+108>>2]=+g[b+56>>2];a[d+112|0]=a[b+40|0]&1;a[d+100|0]=a[b+52|0]&1;c[d+224>>2]=0;return d|0}ba(7272,173,15744,9072);return 0}function lS(a){a=a|0;return}function lT(a){a=a|0;return+0.0}function lU(d,e){d=d|0;e=e|0;var f=0,h=0,i=0,j=0;f=d+112|0;if((e&1|0)==(a[f]&1|0)){return}h=c[d+48>>2]|0;i=h+4|0;j=b[i>>1]|0;if((j&2)==0){b[i>>1]=j|2;g[h+144>>2]=0.0}h=c[d+52>>2]|0;j=h+4|0;i=b[j>>1]|0;if((i&2)==0){b[j>>1]=i|2;g[h+144>>2]=0.0}a[f]=e&1;g[d+92>>2]=0.0;return}function lV(b){b=b|0;return(a[b+100|0]&1)!=0|0}function lW(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function lX(a,d){a=a|0;d=+d;var e=0,f=0,h=0,i=0;e=c[a+48>>2]|0;f=e+4|0;h=b[f>>1]|0;if((h&2)==0){b[f>>1]=h|2;g[e+144>>2]=0.0}e=c[a+52>>2]|0;h=e+4|0;f=b[h>>1]|0;if((f&2)!=0){i=a+104|0;g[i>>2]=d;return}b[h>>1]=f|2;g[e+144>>2]=0.0;i=a+104|0;g[i>>2]=d;return}function lY(b){b=b|0;return(a[b+61|0]&1)!=0|0}function lZ(a){a=a|0;return+(+g[(c[a+52>>2]|0)+72>>2]- +g[(c[a+48>>2]|0)+72>>2])}function l_(d,e){d=d|0;e=e|0;var f=0,h=0,i=0,j=0,k=0;f=c[d+48>>2]|0;h=f+4|0;i=b[h>>1]|0;if((i&2)==0){b[h>>1]=i|2;g[f+144>>2]=0.0}f=c[d+52>>2]|0;i=f+4|0;h=b[i>>1]|0;if((h&2)!=0){j=d+100|0;k=e&1;a[j]=k;return}b[i>>1]=h|2;g[f+144>>2]=0.0;j=d+100|0;k=e&1;a[j]=k;return}function l$(a){a=a|0;return+(+g[a+116>>2])}function l0(a){a=a|0;return+(+g[a+104>>2])}function l1(a){a=a|0;return c[a+4>>2]|0}function l2(a){a=a|0;return+(+g[a+124>>2])}function l3(a){a=a|0;var d=0;if((b[(c[a+48>>2]|0)+4>>1]&32)==0){d=0;return d|0}d=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;return d|0}function l4(a){a=a|0;return c[a+4>>2]|0}function l5(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function l6(a){a=a|0;return+(+g[a+8>>2])}function l7(a){a=a|0;return c[a+12>>2]|0}function l8(a){a=a|0;return c[a+16>>2]|0}function l9(b,d){b=b|0;d=d|0;var e=0,f=0;e=d;d=b+20|0;f=c[e+4>>2]|0;c[d>>2]=c[e>>2];c[d+4>>2]=f;a[b+36|0]=1;return}function ma(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function mb(b,d){b=b|0;d=d|0;var e=0,f=0;e=d;d=b+28|0;f=c[e+4>>2]|0;c[d>>2]=c[e>>2];c[d+4>>2]=f;a[b+37|0]=1;return}function mc(a,b){a=a|0;b=b|0;c[a+16>>2]=b;return}function md(a){a=a|0;return c[a+12>>2]|0}function me(a){a=a|0;return+(+g[a+84>>2])}function mf(a){a=a|0;return c[a+48>>2]|0}function mg(b){b=b|0;return(a[b+61|0]&1)!=0|0}function mh(a){a=a|0;return c[a+64>>2]|0}function mi(a){a=a|0;return c[a+4>>2]|0}function mj(a){a=a|0;return c[a+52>>2]|0}function mk(a){a=a|0;return a+68|0}function ml(a,b){a=a|0;b=+b;g[a+84>>2]=b;return}function mm(a){a=a|0;return a+76|0}function mn(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function mo(b,d){b=b|0;d=+d;var e=0,f=0,g=0;e=i;i=i+8|0;f=e|0;if(!(a[22800]|0)){a[22800]=1}bN[c[(c[b>>2]|0)+8>>2]&127](f,b,d);b=c[f+4>>2]|0;g=240;c[g>>2]=c[f>>2];c[g+4>>2]=b;i=e;return 240}function mp(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+24>>2]&511](a);return}function mq(a){a=a|0;bo[c[(c[a>>2]|0)+16>>2]&511](a);return}function mr(a,b){a=a|0;b=+b;return+(+bw[c[(c[a>>2]|0)+12>>2]&127](a,b))}function ms(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[22904]|0)){a[22904]=1}bp[c[(c[b>>2]|0)+4>>2]&511](e,b);b=c[e+4>>2]|0;f=232;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 232}function mt(){return vo(1)|0}function mu(a){a=a|0;if((a|0)==0){return}vl(a|0);return}function mv(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+4>>2]&511](a);return}function mw(){var a=0;a=vo(4)|0;c[a>>2]=19640;return a|0}function mx(a,b){a=a|0;b=b|0;bp[c[(c[a>>2]|0)+12>>2]&511](a,b);return}function my(a,b){a=a|0;b=b|0;bp[c[(c[a>>2]|0)+8>>2]&511](a,b);return}function mz(a,b,d){a=a|0;b=b|0;d=d|0;bL[c[(c[a>>2]|0)+16>>2]&127](a,b,d);return}function mA(a,b,d){a=a|0;b=b|0;d=d|0;bL[c[(c[a>>2]|0)+20>>2]&127](a,b,d);return}function mB(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+4>>2]&511](a);return}function mC(a,b,d){a=a|0;b=b|0;d=+d;bN[c[(c[a>>2]|0)+28>>2]&127](a,b,d);return}function mD(a,b){a=a|0;b=b|0;return bF[c[(c[a>>2]|0)+8>>2]&255](a,b)|0}function mE(a,b,c){a=a|0;b=b|0;c=c|0;cX(a,b,c);return}function mF(){var b=0;b=vo(40)|0;c[b>>2]=20296;c[b+4>>2]=3;g[b+8>>2]=.009999999776482582;c[b+12>>2]=0;c[b+16>>2]=0;a[b+36|0]=0;a[b+37|0]=0;return b|0}function mG(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;bO[c[(c[a>>2]|0)+24>>2]&127](a,b,d,e);return}function mH(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;return bI[c[(c[a>>2]|0)+20>>2]&127](a,b,d,e,f)|0}function mI(a){a=a|0;return bq[c[(c[a>>2]|0)+12>>2]&1023](a)|0}function mJ(a,b,d){a=a|0;b=b|0;d=d|0;return bv[c[(c[a>>2]|0)+16>>2]&127](a,b,d)|0}function mK(a,b){a=a|0;b=b|0;return bF[c[(c[a>>2]|0)+8>>2]&255](a,b)|0}function mL(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+4>>2]&511](a);return}function mM(){var a=0;a=vo(4)|0;c[a>>2]=19824;return a|0}function mN(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0;if((a|0)==0){return}b=a+4|0;d=a|0;e=c[d>>2]|0;if((c[b>>2]|0)>0){f=0;g=e;while(1){vi(c[g+(f<<3)+4>>2]|0);h=f+1|0;i=c[d>>2]|0;if((h|0)<(c[b>>2]|0)){f=h;g=i}else{j=i;break}}}else{j=e}vi(j);vl(a);return}function mO(a){a=a|0;var b=0,d=0,e=0;b=a+4|0;d=a|0;if((c[b>>2]|0)>0){e=0;do{vi(c[(c[d>>2]|0)+(e<<3)+4>>2]|0);e=e+1|0;}while((e|0)<(c[b>>2]|0))}c[b>>2]=0;vq(c[d>>2]|0,0,c[a+8>>2]<<3|0);vq(a+12|0,0,56);return}function mP(a,b){a=a|0;b=b|0;return df(a,b)|0}function mQ(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+24>>2]&511](a);return}function mR(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[23040]|0)){a[23040]=1}bp[c[c[b>>2]>>2]&511](e,b);b=c[e+4>>2]|0;f=216;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 216}function mS(a,b){a=a|0;b=+b;return+(+bw[c[(c[a>>2]|0)+12>>2]&127](a,b))}function mT(a){a=a|0;bo[c[(c[a>>2]|0)+16>>2]&511](a);return}function mU(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[23032]|0)){a[23032]=1}bp[c[(c[b>>2]|0)+4>>2]&511](e,b);b=c[e+4>>2]|0;f=208;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 208}function mV(a,d,e){a=a|0;d=+d;e=+e;var f=0,h=0,i=0,j=0;if(d>e){ba(6488,473,17496,11440)}f=a+120|0;do{if(+g[f>>2]==d){if(+g[a+124>>2]!=e){break}return}}while(0);h=c[a+48>>2]|0;i=h+4|0;j=b[i>>1]|0;if((j&2)==0){b[i>>1]=j|2;g[h+144>>2]=0.0}h=c[a+52>>2]|0;j=h+4|0;i=b[j>>1]|0;if((i&2)==0){b[j>>1]=i|2;g[h+144>>2]=0.0}g[a+92>>2]=0.0;g[f>>2]=d;g[a+124>>2]=e;return}function mW(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=b+12|0;if((c[f>>2]|0)!=0){ba(6208,48,18448,11256)}g=b+16|0;if((c[g>>2]|0)!=0){ba(6208,48,18448,11256)}if((e|0)>1){c[g>>2]=e;h=vh(e<<3)|0;c[f>>2]=h;f=d;d=c[g>>2]<<3;vp(h|0,f|0,d)|0;a[b+36|0]=0;a[b+37|0]=0;return}else{ba(6208,49,18448,6736)}}function mX(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,i=0;f=b+12|0;if((c[f>>2]|0)!=0){ba(6208,34,18504,11256)}g=b+16|0;if((c[g>>2]|0)!=0){ba(6208,34,18504,11256)}if((e|0)>2){h=e+1|0;c[g>>2]=h;i=vh(h<<3)|0;c[f>>2]=i;h=d;d=e<<3;vp(i|0,h|0,d)|0;d=c[f>>2]|0;h=d;i=d+(e<<3)|0;e=c[h+4>>2]|0;c[i>>2]=c[h>>2];c[i+4>>2]=e;e=c[f>>2]|0;f=e+((c[g>>2]|0)-2<<3)|0;g=b+20|0;i=c[f+4>>2]|0;c[g>>2]=c[f>>2];c[g+4>>2]=i;i=e+8|0;e=b+28|0;g=c[i+4>>2]|0;c[e>>2]=c[i>>2];c[e+4>>2]=g;a[b+36|0]=1;a[b+37|0]=1;return}else{ba(6208,35,18504,5016)}}function mY(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;if((e|0)==0){return}if((e|0)<=0){ba(5352|0,164,17448|0,8376|0)}if((e|0)>640){vi(d);return}f=a[e+22064|0]|0;if((f&255)>=14){ba(5352|0,173,17448|0,6544|0)}e=b+12+((f&255)<<2)|0;c[d>>2]=c[e>>2];c[e>>2]=d;return}function mZ(){var b=0,d=0,e=0,f=0,g=0,h=0,i=0;b=vo(68)|0;d=b;c[b+8>>2]=128;c[b+4>>2]=0;e=vh(1024)|0;c[b>>2]=e;vq(e|0,0,1024);vq(b+12|0,0,56);if((a[22056]&1)==0){f=0;g=1}else{return d|0}while(1){if((f|0)>=14){h=1080;break}if((g|0)>(c[22712+(f<<2)>>2]|0)){b=f+1|0;a[g+22064|0]=b&255;i=b}else{a[g+22064|0]=f&255;i=f}b=g+1|0;if((b|0)<641){f=i;g=b}else{h=1086;break}}if((h|0)==1080){ba(5352,73,17368,10976);return 0}else if((h|0)==1086){a[22056]=1;return d|0}return 0}function m_(a){a=a|0;return c[a+164>>2]|0}function m$(a){a=a|0;var d=0;if((b[(c[a+48>>2]|0)+4>>1]&32)==0){d=0;return d|0}d=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;return d|0}function m0(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function m1(a){a=a|0;return+(+g[a+8>>2])}function m2(a,b){a=a|0;b=b|0;return a+20+(b<<3)|0}function m3(a,b,d){a=a|0;b=+b;d=+d;var e=0.0,f=0.0;c[a+148>>2]=4;e=-0.0-b;f=-0.0-d;g[a+20>>2]=e;g[a+24>>2]=f;g[a+28>>2]=b;g[a+32>>2]=f;g[a+36>>2]=b;g[a+40>>2]=d;g[a+44>>2]=e;g[a+48>>2]=d;g[a+84>>2]=0.0;g[a+88>>2]=-1.0;g[a+92>>2]=1.0;g[a+96>>2]=0.0;g[a+100>>2]=0.0;g[a+104>>2]=1.0;g[a+108>>2]=-1.0;g[a+112>>2]=0.0;g[a+12>>2]=0.0;g[a+16>>2]=0.0;return}function m4(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+12|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function m5(a,b){a=a|0;b=b|0;c[a+148>>2]=b;return}function m6(a){a=a|0;return c[a+148>>2]|0}function m7(a){a=a|0;return c[a+4>>2]|0}function m8(a){a=a|0;return c[a+148>>2]|0}function m9(a){a=a|0;return a+12|0}function na(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0;f=d;d=b+12|0;g=c[f+4>>2]|0;c[d>>2]=c[f>>2];c[d+4>>2]=g;g=e;e=b+20|0;d=c[g+4>>2]|0;c[e>>2]=c[g>>2];c[e+4>>2]=d;a[b+44|0]=0;a[b+45|0]=0;return}function nb(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function nc(a){a=a|0;return+(+g[a+8>>2])}function nd(a){a=a|0;return c[a+4>>2]|0}function ne(a){a=a|0;return c[a+12>>2]|0}function nf(a,b){a=a|0;b=b|0;var d=0;d=a+4|0;a=c[d>>2]|0;c[d>>2]=b?a|4:a&-5;return}function ng(a){a=a|0;return+(+g[a+140>>2])}function nh(a){a=a|0;return+(+g[a+136>>2])}function ni(a){a=a|0;return(c[a+4>>2]&2|0)!=0|0}function nj(a){a=a|0;return(c[a+4>>2]&4|0)!=0|0}function nk(a){a=a|0;return c[a+52>>2]|0}function nl(a,b){a=a|0;b=+b;g[a+136>>2]=b;return}function nm(a){a=a|0;return c[a+48>>2]|0}function nn(a){a=a|0;return c[a+56>>2]|0}function no(a){a=a|0;return c[a+60>>2]|0}function np(a,b){a=a|0;b=+b;g[a+140>>2]=b;return}function nq(a){a=a|0;return a+64|0}function nr(a){a=a|0;var b=0.0,d=0.0;b=+g[(c[a+48>>2]|0)+20>>2];d=+g[(c[a+52>>2]|0)+20>>2];g[a+140>>2]=b>d?b:d;return}function ns(a){a=a|0;return+(+g[a+8>>2])}function nt(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function nu(a){a=a|0;return c[a+4>>2]|0}function nv(a){a=a|0;return+(+g[a+56>>2])}function nw(a){a=a|0;return c[a+148>>2]|0}function nx(a){a=a|0;return(b[a+4>>1]&4)!=0|0}function ny(a,b){a=a|0;b=+b;g[a+136>>2]=b;return}function nz(a,b){a=a|0;b=+b;g[a+140>>2]=b;return}function nA(a,b){a=a|0;b=b|0;c[a+148>>2]=b;return}function nB(a){a=a|0;return+(+g[a+72>>2])}function nC(a){a=a|0;return c[a+100>>2]|0}function nD(a,d,e){a=a|0;d=d|0;e=e|0;var f=0,h=0;if((c[a>>2]|0)!=2){return}f=a+4|0;h=b[f>>1]|0;if((h&2)==0){b[f>>1]=h|2;g[a+144>>2]=0.0}h=d|0;f=a+76|0;g[f>>2]=+g[h>>2]+ +g[f>>2];f=d+4|0;d=a+80|0;g[d>>2]=+g[f>>2]+ +g[d>>2];d=a+84|0;g[d>>2]=+g[d>>2]+((+g[e>>2]- +g[a+44>>2])*+g[f>>2]-(+g[e+4>>2]- +g[a+48>>2])*+g[h>>2]);return}function nE(b,c){b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0;if(!(a[23088]|0)){a[23088]=1}d=+g[c>>2]- +g[b+12>>2];e=+g[c+4>>2]- +g[b+16>>2];f=+g[b+24>>2];h=+g[b+20>>2];i=+(f*e+d*(-0.0-h));b=192;g[b>>2]=d*f+e*h;g[b+4>>2]=i;return 192}function nF(a,d){a=a|0;d=d|0;var e=0.0,f=0.0,h=0,i=0;if((c[a>>2]|0)==0){return}e=+g[d>>2];f=+g[d+4>>2];do{if(e*e+f*f>0.0){h=a+4|0;i=b[h>>1]|0;if((i&2)!=0){break}b[h>>1]=i|2;g[a+144>>2]=0.0}}while(0);i=d;d=a+64|0;a=c[i+4>>2]|0;c[d>>2]=c[i>>2];c[d+4>>2]=a;return}function nG(a){a=a|0;return c[a+108>>2]|0}function nH(b){b=b|0;var d=0,e=0;if(!(a[22976]|0)){a[22976]=1}d=b+64|0;b=c[d+4>>2]|0;e=184;c[e>>2]=c[d>>2];c[e+4>>2]=b;return 184}function nI(a){a=a|0;return c[a+96>>2]|0}function nJ(a,c){a=a|0;c=c|0;var d=0,e=0;d=a+4|0;e=b[d>>1]|0;if(c){b[d>>1]=e|4;return}c=e&-5;b[d>>1]=c;if((e&2)!=0){return}b[d>>1]=c|2;g[a+144>>2]=0.0;return}function nK(a){a=a|0;return+(+g[a+116>>2])}function nL(a,d){a=a|0;d=+d;var e=0,f=0;if((c[a>>2]|0)==0){return}do{if(d*d>0.0){e=a+4|0;f=b[e>>1]|0;if((f&2)!=0){break}b[e>>1]=f|2;g[a+144>>2]=0.0}}while(0);g[a+72>>2]=d;return}function nM(a,b){a=a|0;b=b|0;var d=0,e=0,f=0.0,h=0.0;d=a+116|0;g[b>>2]=+g[d>>2];e=a+28|0;f=+g[e>>2];h=+g[a+32>>2];g[b+12>>2]=+g[a+124>>2]+ +g[d>>2]*(f*f+h*h);d=e;e=b+4|0;b=c[d+4>>2]|0;c[e>>2]=c[d>>2];c[e+4>>2]=b;return}function nN(b,c){b=b|0;c=c|0;var d=0.0,e=0.0,f=0;if(!(a[22776]|0)){a[22776]=1}d=+g[b+72>>2];e=+(d*(+g[c>>2]- +g[b+44>>2])+ +g[b+68>>2]);f=176;g[f>>2]=+g[b+64>>2]+(+g[c+4>>2]- +g[b+48>>2])*(-0.0-d);g[f+4>>2]=e;return 176}function nO(b,d){b=b|0;d=+d;var e=0,f=0,g=0;e=i;i=i+8|0;f=e|0;if(!(a[22872]|0)){a[22872]=1}bN[c[(c[b>>2]|0)+8>>2]&127](f,b,d);b=c[f+4>>2]|0;g=200;c[g>>2]=c[f>>2];c[g+4>>2]=b;i=e;return 200}function nP(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+4>>2]&511](a);return}function nQ(a,b,c){a=a|0;b=b|0;c=c|0;dc(a,b,c);return}function nR(a,b,d){a=a|0;b=b|0;d=+d;bN[c[(c[a>>2]|0)+28>>2]&127](a,b,d);return}function nS(a,b){a=a|0;b=b|0;return bF[c[(c[a>>2]|0)+8>>2]&255](a,b)|0}function nT(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;return bI[c[(c[a>>2]|0)+20>>2]&127](a,b,d,e,f)|0}function nU(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;cW(a,b,c,d,e);return}function nV(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;bO[c[(c[a>>2]|0)+24>>2]&127](a,b,d,e);return}function nW(a){a=a|0;return bq[c[(c[a>>2]|0)+12>>2]&1023](a)|0}function nX(a,b,d){a=a|0;b=b|0;d=d|0;return bv[c[(c[a>>2]|0)+16>>2]&127](a,b,d)|0}function nY(){var a=0;a=vo(152)|0;c[a>>2]=20032;c[a+4>>2]=2;g[a+8>>2]=.009999999776482582;c[a+148>>2]=0;g[a+12>>2]=0.0;g[a+16>>2]=0.0;return a|0}function nZ(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+4>>2]&511](a);return}function n_(a,b,d){a=a|0;b=b|0;d=+d;bN[c[(c[a>>2]|0)+28>>2]&127](a,b,d);return}function n$(a,b){a=a|0;b=b|0;return bF[c[(c[a>>2]|0)+8>>2]&255](a,b)|0}function n0(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;return bI[c[(c[a>>2]|0)+20>>2]&127](a,b,d,e,f)|0}function n1(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;bO[c[(c[a>>2]|0)+24>>2]&127](a,b,d,e);return}function n2(a){a=a|0;return bq[c[(c[a>>2]|0)+12>>2]&1023](a)|0}function n3(a,b,d){a=a|0;b=b|0;d=d|0;return bv[c[(c[a>>2]|0)+16>>2]&127](a,b,d)|0}function n4(){var a=0;a=vo(48)|0;c[a>>2]=20512;c[a+4>>2]=1;g[a+8>>2]=.009999999776482582;vq(a+28|0,0,18);return a|0}function n5(a,b){a=a|0;b=b|0;var d=0,e=0;d=c[a+48>>2]|0;e=c[a+52>>2]|0;cd(b,a+64|0,(c[d+8>>2]|0)+12|0,+g[(c[d+12>>2]|0)+8>>2],(c[e+8>>2]|0)+12|0,+g[(c[e+12>>2]|0)+8>>2]);return}function n6(a){a=a|0;g[a+136>>2]=+P(+(+g[(c[a+48>>2]|0)+16>>2]*+g[(c[a+52>>2]|0)+16>>2]));return}function n7(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;bO[c[c[a>>2]>>2]&127](a,b,d,e);return}function n8(a,b,d){a=a|0;b=b|0;d=+d;bN[c[(c[a>>2]|0)+28>>2]&127](a,b,d);return}function n9(a,b){a=a|0;b=b|0;return bF[c[(c[a>>2]|0)+8>>2]&255](a,b)|0}function oa(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;return bI[c[(c[a>>2]|0)+20>>2]&127](a,b,d,e,f)|0}function ob(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;bO[c[(c[a>>2]|0)+24>>2]&127](a,b,d,e);return}function oc(a){a=a|0;return bq[c[(c[a>>2]|0)+12>>2]&1023](a)|0}function od(a,b,d){a=a|0;b=b|0;d=d|0;return bv[c[(c[a>>2]|0)+16>>2]&127](a,b,d)|0}function oe(a,b){a=a|0;b=b|0;dt(a,b);return}function of(a,b,c){a=a|0;b=b|0;c=+c;ds(a,b,c);return}function og(a){a=a|0;dj(a);return}function oh(b){b=b|0;var d=0,e=0,f=0,h=0;d=vo(168)|0;e=d;c[e>>2]=19312;f=c[b+8>>2]|0;h=c[b+12>>2]|0;if((f|0)!=(h|0)){c[d+4>>2]=c[b>>2];c[d+8>>2]=0;c[d+12>>2]=0;c[d+48>>2]=f;c[d+52>>2]=h;c[d+56>>2]=0;a[d+61|0]=a[b+16|0]&1;a[d+60|0]=0;c[d+64>>2]=c[b+4>>2];vq(d+16|0,0,32);c[e>>2]=20400;e=b+20|0;h=d+68|0;f=c[e+4>>2]|0;c[h>>2]=c[e>>2];c[h+4>>2]=f;f=b+28|0;h=d+76|0;e=c[f+4>>2]|0;c[h>>2]=c[f>>2];c[h+4>>2]=e;g[d+84>>2]=+g[b+36>>2];g[d+160>>2]=0.0;g[d+92>>2]=0.0;c[d+164>>2]=0;g[d+88>>2]=0.0;return d|0}ba(7272,173,15744,9072);return 0}function oi(a,d){a=a|0;d=d|0;var e=0,f=0;if((c[a>>2]|0)!=2){return}e=a+4|0;f=b[e>>1]|0;if((f&2)==0){b[e>>1]=f|2;g[a+144>>2]=0.0}f=a+76|0;g[f>>2]=+g[d>>2]+ +g[f>>2];f=a+80|0;g[f>>2]=+g[d+4>>2]+ +g[f>>2];return}function oj(a,d){a=a|0;d=+d;var e=0,f=0;if((c[a>>2]|0)!=2){return}e=a+4|0;f=b[e>>1]|0;if((f&2)==0){b[e>>1]=f|2;g[a+144>>2]=0.0}f=a+84|0;g[f>>2]=+g[f>>2]+d;return}function ok(a){a=a|0;return(b[a+4>>1]&2)!=0|0}function ol(a){a=a|0;return a+12|0}function om(a){a=a|0;return a+44|0}function on(a){a=a|0;return+(+g[a+136>>2])}function oo(a,d,e){a=a|0;d=d|0;e=e|0;var f=0,h=0,i=0.0,j=0.0;if((c[a>>2]|0)!=2){return}f=a+4|0;h=b[f>>1]|0;if((h&2)==0){b[f>>1]=h|2;g[a+144>>2]=0.0}i=+g[a+120>>2];h=d|0;f=d+4|0;j=i*+g[f>>2];d=a+64|0;g[d>>2]=i*+g[h>>2]+ +g[d>>2];d=a+68|0;g[d>>2]=j+ +g[d>>2];d=a+72|0;g[d>>2]=+g[d>>2]+ +g[a+128>>2]*((+g[e>>2]- +g[a+44>>2])*+g[f>>2]-(+g[e+4>>2]- +g[a+48>>2])*+g[h>>2]);return}function op(a){a=a|0;return(b[a+4>>1]&16)!=0|0}function oq(a){a=a|0;return a+28|0}function or(b,c){b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0;if(!(a[23064]|0)){a[23064]=1}d=+g[b+24>>2];e=+g[c>>2];f=+g[b+20>>2];h=+g[c+4>>2];i=+(e*f+d*h);c=168;g[c>>2]=d*e-f*h;g[c+4>>2]=i;return 168}function os(b,c){b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0,j=0.0;if(!(a[22784]|0)){a[22784]=1}d=+g[b+24>>2];e=+g[c>>2];f=+g[b+20>>2];h=+g[c+4>>2];i=+g[b+72>>2];j=+(i*(+g[b+12>>2]+(d*e-f*h)- +g[b+44>>2])+ +g[b+68>>2]);c=160;g[c>>2]=+g[b+64>>2]+(e*f+d*h+ +g[b+16>>2]- +g[b+48>>2])*(-0.0-i);g[c+4>>2]=j;return 160}function ot(a){a=a|0;return c[a+112>>2]|0}function ou(b,c){b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0;if(!(a[23080]|0)){a[23080]=1}d=+g[b+24>>2];e=+g[c>>2];f=+g[b+20>>2];h=+g[c+4>>2];i=+(e*f+d*h+ +g[b+16>>2]);c=152;g[c>>2]=+g[b+12>>2]+(d*e-f*h);g[c+4>>2]=i;return 152}function ov(a){a=a|0;return+(+g[a+132>>2])}function ow(a){a=a|0;return(b[a+4>>1]&8)!=0|0}function ox(a){a=a|0;return c[a+88>>2]|0}function oy(b,c){b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0.0;if(!(a[23072]|0)){a[23072]=1}d=+g[b+24>>2];e=+g[c>>2];f=+g[b+20>>2];h=+g[c+4>>2];i=+(e*(-0.0-f)+d*h);c=144;g[c>>2]=d*e+f*h;g[c+4>>2]=i;return 144}function oz(a,b){a=a|0;b=+b;g[a+132>>2]=b;return}function oA(a,c){a=a|0;c=c|0;var d=0;d=a+4|0;a=b[d>>1]|0;b[d>>1]=c?a|8:a&-9;return}function oB(a){a=a|0;return c[a>>2]|0}function oC(a){a=a|0;return+(+g[a+140>>2])}function oD(a){a=a|0;var b=0.0,c=0.0;b=+g[a+28>>2];c=+g[a+32>>2];return+(+g[a+124>>2]+ +g[a+116>>2]*(b*b+c*c))}function oE(a){a=a|0;return(b[a+4>>1]&32)!=0|0}function oF(a,d){a=a|0;d=+d;var e=0,f=0;if((c[a>>2]|0)!=2){return}e=a+4|0;f=b[e>>1]|0;if((f&2)==0){b[e>>1]=f|2;g[a+144>>2]=0.0}f=a+72|0;g[f>>2]=+g[f>>2]+ +g[a+128>>2]*d;return}function oG(a){a=a|0;return a+12|0}function oH(a){a=a|0;return+(+g[a+96>>2])}function oI(b){b=b|0;return(a[b+61|0]&1)!=0|0}function oJ(a){a=a|0;return c[a+64>>2]|0}function oK(a){a=a|0;return c[a+4>>2]|0}function oL(a){a=a|0;return c[a+52>>2]|0}function oM(a){a=a|0;return a+68|0}function oN(a){a=a|0;return a+76|0}function oO(a,b){a=a|0;b=b|0;c[a+64>>2]=b;return}function oP(a){a=a|0;return c[a+48>>2]|0}function oQ(a){a=a|0;return c[a+12>>2]|0}function oR(a){a=a|0;return+(+g[a+100>>2])}function oS(a){a=a|0;var d=0;if((b[(c[a+48>>2]|0)+4>>1]&32)==0){d=0;return d|0}d=(b[(c[a+52>>2]|0)+4>>1]&32)!=0;return d|0}function oT(a){a=a|0;return c[a+102408>>2]|0}function oU(a,c){a=a|0;c=c|0;b[a+2>>1]=c;return}function oV(a,c){a=a|0;c=c|0;b[a>>1]=c;return}function oW(a){a=a|0;return b[a+4>>1]|0}function oX(a,b){a=a|0;b=b|0;di(a,b);return}function oY(a,b){a=a|0;b=b|0;return dk(a,b)|0}function oZ(d,e,f){d=d|0;e=e|0;f=+f;var h=0,j=0;h=i;i=i+32|0;j=h|0;b[j+22>>1]=1;b[j+24>>1]=-1;b[j+26>>1]=0;c[j+4>>2]=0;g[j+8>>2]=.20000000298023224;g[j+12>>2]=0.0;a[j+20|0]=0;c[j>>2]=e;g[j+16>>2]=f;e=dk(d,j)|0;i=h;return e|0}function o_(a,b){a=a|0;b=b|0;dr(a,b);return}function o$(a,c){a=a|0;c=c|0;var d=0,e=0;d=a+4|0;e=b[d>>1]|0;if(!c){b[d>>1]=e&-3;g[a+144>>2]=0.0;vq(a+64|0,0,24);return}if((e&2)!=0){return}b[d>>1]=e|2;g[a+144>>2]=0.0;return}function o0(a){a=a|0;dn(a);return}function o1(a,b){a=a|0;b=b|0;dq(a,b);return}function o2(a,c){a=a|0;c=c|0;var d=0,e=0;d=a+4|0;e=b[d>>1]|0;b[d>>1]=c?e|16:e&-17;dj(a);return}function o3(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[22928]|0)){a[22928]=1}bp[c[c[b>>2]>>2]&511](e,b);b=c[e+4>>2]|0;f=128;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 128}function o4(a,b){a=a|0;b=+b;return+(+bw[c[(c[a>>2]|0)+12>>2]&127](a,b))}function o5(a){a=a|0;bo[c[(c[a>>2]|0)+16>>2]&511](a);return}function o6(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+24>>2]&511](a);return}function o7(b){b=b|0;var d=0,e=0,f=0;d=i;i=i+8|0;e=d|0;if(!(a[22920]|0)){a[22920]=1}bp[c[(c[b>>2]|0)+4>>2]&511](e,b);b=c[e+4>>2]|0;f=120;c[f>>2]=c[e>>2];c[f+4>>2]=b;i=d;return 120}function o8(b,d){b=b|0;d=+d;var e=0,f=0,g=0;e=i;i=i+8|0;f=e|0;if(!(a[22808]|0)){a[22808]=1}bN[c[(c[b>>2]|0)+8>>2]&127](f,b,d);b=c[f+4>>2]|0;g=112;c[g>>2]=c[f>>2];c[g+4>>2]=b;i=e;return 112}function o9(){var a=0;a=vo(102800)|0;c[a+102400>>2]=0;c[a+102404>>2]=0;c[a+102408>>2]=0;c[a+102796>>2]=0;return a|0}function pa(a,b){a=a|0;b=b|0;dg(a,b);return}function pb(a){a=a|0;if((a|0)==0){return}bo[c[(c[a>>2]|0)+4>>2]&511](a);return}function pc(a,b){a=a|0;b=b|0;bp[c[(c[a>>2]|0)+8>>2]&511](a,b);return}function pd(){var a=0;a=vo(4)|0;c[a>>2]=19576;return a|0}function pe(a){a=a|0;if((a|0)==0){return}vl(a);return}function pf(a,b){a=a|0;b=+b;do{if(b==b&!(C=0.0,C!=C)&b>+-p){if(!(b<+p&b>=0.0)){break}g[a+100>>2]=b;return}}while(0);ba(7624,228,17552,9328)}function pg(a,b){a=a|0;b=+b;do{if(b==b&!(C=0.0,C!=C)&b>+-p){if(!(b<+p&b>=0.0)){break}g[a+96>>2]=b;return}}while(0);ba(7624,217,17600,11752)}function ph(b){b=b|0;var d=0,e=0,f=0,h=0;d=vo(180)|0;e=d;c[e>>2]=19312;f=c[b+8>>2]|0;h=c[b+12>>2]|0;if((f|0)!=(h|0)){c[d+4>>2]=c[b>>2];c[d+8>>2]=0;c[d+12>>2]=0;c[d+48>>2]=f;c[d+52>>2]=h;c[d+56>>2]=0;a[d+61|0]=a[b+16|0]&1;a[d+60|0]=0;c[d+64>>2]=c[b+4>>2];vq(d+16|0,0,32);c[e>>2]=19856;e=b+20|0;h=d+68|0;f=c[e+4>>2]|0;c[h>>2]=c[e>>2];c[h+4>>2]=f;f=b+28|0;h=d+76|0;e=c[f+4>>2]|0;c[h>>2]=c[f>>2];c[h+4>>2]=e;g[d+84>>2]=0.0;g[d+88>>2]=0.0;g[d+92>>2]=0.0;g[d+96>>2]=+g[b+36>>2];g[d+100>>2]=+g[b+40>>2];return d|0}ba(7272,173,15744,9072);return 0}function pi(a){a=a|0;if((a|0)==0){return}if((c[a+102400>>2]|0)!=0){ba(4840,32,17e3,10664)}if((c[a+102796>>2]|0)==0){vl(a|0);return}else{ba(4840,33,17e3,7952)}}function pj(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0;e=b+102796|0;f=c[e>>2]|0;if((f|0)>=32){ba(4840,38,17040,6448);return 0}g=b+102412+(f*12&-1)|0;c[b+102412+(f*12&-1)+4>>2]=d;h=b+102400|0;i=c[h>>2]|0;if((i+d|0)>102400){c[g>>2]=vh(d)|0;a[b+102412+(f*12&-1)+8|0]=1}else{c[g>>2]=b+i;a[b+102412+(f*12&-1)+8|0]=0;c[h>>2]=(c[h>>2]|0)+d}h=b+102404|0;f=(c[h>>2]|0)+d|0;c[h>>2]=f;h=b+102408|0;b=c[h>>2]|0;c[h>>2]=(b|0)>(f|0)?b:f;c[e>>2]=(c[e>>2]|0)+1;return c[g>>2]|0}function pk(a,c){a=a|0;c=c|0;b[a+4>>1]=c;return}function pl(a){a=a|0;return b[a+2>>1]|0}function pm(a){a=a|0;return b[a>>1]|0}function pn(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+20|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function po(a,b){a=a|0;b=b|0;return c[a+8>>2]|0}function pp(a,b){a=a|0;b=b|0;return c[a+12>>2]|0}function pq(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+28|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function pr(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function ps(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function pt(a){a=a|0;return+(+g[a+36>>2])}function pu(a){a=a|0;return a+20|0}function pv(a,b){a=a|0;b=+b;g[a+36>>2]=b;return}function pw(a){a=a|0;return a+28|0}function px(b,c){b=b|0;c=c|0;return(a[b+16|0]&1)!=0|0}function py(a,b){a=a|0;b=+b;g[a+40>>2]=b;return}function pz(b,c){b=b|0;c=c|0;a[b+16|0]=c&1;return}function pA(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0.0,i=0,j=0.0,k=0.0,l=0.0,m=0.0;c[a+8>>2]=b;c[a+12>>2]=d;f=e|0;h=+g[f>>2]- +g[b+12>>2];i=e+4|0;j=+g[i>>2]- +g[b+16>>2];k=+g[b+24>>2];l=+g[b+20>>2];b=a+20|0;m=+(k*j+h*(-0.0-l));g[b>>2]=h*k+j*l;g[b+4>>2]=m;m=+g[f>>2]- +g[d+12>>2];l=+g[i>>2]- +g[d+16>>2];j=+g[d+24>>2];k=+g[d+20>>2];d=a+28|0;h=+(j*l+m*(-0.0-k));g[d>>2]=m*j+l*k;g[d+4>>2]=h;return}function pB(a){a=a|0;return+(+g[a+40>>2])}function pC(a){a=a|0;return+(+g[a+28>>2])}function pD(b){b=b|0;return(a[b+37|0]&1)!=0|0}function pE(a){a=a|0;return c[a>>2]|0}function pF(b){b=b|0;return(a[b+36|0]&1)!=0|0}function pG(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+4|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function pH(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+16|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function pI(b){b=b|0;return(a[b+39|0]&1)!=0|0}function pJ(a){a=a|0;return c[a+44>>2]|0}function pK(a,b){a=a|0;b=+b;g[a+32>>2]=b;return}function pL(b,c){b=b|0;c=c|0;a[b+38|0]=c&1;return}function pM(b,c){b=b|0;c=c|0;a[b+36|0]=c&1;return}function pN(a){a=a|0;return+(+g[a+48>>2])}function pO(a,b){a=a|0;b=+b;g[a+24>>2]=b;return}function pP(a,b){a=a|0;b=b|0;c[a+44>>2]=b;return}function pQ(a){a=a|0;return a+4|0}function pR(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function pS(a,b){a=a|0;b=+b;g[a+48>>2]=b;return}function pT(a){a=a|0;return+(+g[a+32>>2])}function pU(b,c){b=b|0;c=c|0;a[b+39|0]=c&1;return}function pV(b,c){b=b|0;c=c|0;a[b+40|0]=c&1;return}function pW(a,b){a=a|0;b=+b;g[a+12>>2]=b;return}function pX(a){a=a|0;return+(+g[a+12>>2])}function pY(a){a=a|0;return+(+g[a+24>>2])}function pZ(a){a=a|0;return a+16|0}function p_(b){b=b|0;return(a[b+40|0]&1)!=0|0}function p$(a,b){a=a|0;b=+b;g[a+28>>2]=b;return}function p0(b){b=b|0;return(a[b+38|0]&1)!=0|0}function p1(b,c){b=b|0;c=c|0;a[b+37|0]=c&1;return}function p2(a,b){a=a|0;b=+b;g[a>>2]=b;return}function p3(a,b,c){a=a|0;b=+b;c=+c;g[a>>2]=b;g[a+4>>2]=c;return}function p4(a){a=a|0;return+(+g[a>>2])}function p5(a){a=a|0;return+(+g[a+4>>2])}function p6(a,b){a=a|0;b=+b;g[a+4>>2]=b;return}function p7(a){a=a|0;var b=0.0,c=0;b=+g[a>>2];if(!(b==b&!(C=0.0,C!=C)&b>+-p&b<+p)){c=0;return c|0}b=+g[a+4>>2];if(!(b==b&!(C=0.0,C!=C)&b>+-p)){c=0;return c|0}c=b<+p;return c|0}function p8(b){b=b|0;var c=0.0,d=0;if(!(a[23168]|0)){a[23168]=1}c=+(+g[b>>2]);d=104;g[d>>2]=-0.0- +g[b+4>>2];g[d+4>>2]=c;return 104}function p9(a){a=a|0;var b=0.0,c=0.0;b=+g[a>>2];c=+g[a+4>>2];return+(b*b+c*c)}function qa(a,b){a=a|0;b=b|0;var c=0;c=a|0;g[c>>2]=+g[b>>2]+ +g[c>>2];c=a+4|0;g[c>>2]=+g[b+4>>2]+ +g[c>>2];return}function qb(a){a=a|0;g[a>>2]=0.0;g[a+4>>2]=0.0;return}function qc(a,b){a=a|0;b=+b;var c=0;c=a|0;g[c>>2]=+g[c>>2]*b;c=a+4|0;g[c>>2]=+g[c>>2]*b;return}function qd(b){b=b|0;var c=0.0,d=0;if(!(a[23160]|0)){a[23160]=1}c=+(-0.0- +g[b+4>>2]);d=96;g[d>>2]=-0.0- +g[b>>2];g[d+4>>2]=c;return 96}function qe(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function qf(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;g[a>>2]=b;g[a+4>>2]=c;g[a+8>>2]=d;return}function qg(a){a=a|0;return+(+g[a+8>>2])}function qh(a,b){a=a|0;b=b|0;var c=0;c=a|0;g[c>>2]=+g[b>>2]+ +g[c>>2];c=a+4|0;g[c>>2]=+g[b+4>>2]+ +g[c>>2];c=a+8|0;g[c>>2]=+g[b+8>>2]+ +g[c>>2];return}function qi(a){a=a|0;g[a>>2]=0.0;g[a+4>>2]=0.0;g[a+8>>2]=0.0;return}function qj(a,b){a=a|0;b=+b;var c=0;c=a|0;g[c>>2]=+g[c>>2]*b;c=a+4|0;g[c>>2]=+g[c>>2]*b;c=a+8|0;g[c>>2]=+g[c>>2]*b;return}function qk(b){b=b|0;var c=0.0,d=0.0;if(!(a[23152]|0)){a[23152]=1}c=-0.0- +g[b+4>>2];d=-0.0- +g[b+8>>2];g[20]=-0.0- +g[b>>2];g[21]=c;g[22]=d;return 80}function ql(a){a=a|0;return+(+g[a+24>>2])}function qm(a,b){a=a|0;b=+b;g[a+24>>2]=b;return}function qn(a){a=a|0;return c[a+16>>2]|0}function qo(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0,i=0.0,j=0.0,k=0.0,l=0.0,m=0,n=0,o=0;d=c[a+16>>2]|0;e=c[a+20>>2]|0;if((e|0)<=1){f=0;h=d+(f<<3)|0;return h|0}i=+g[b+4>>2];j=+g[b>>2];k=i*+g[d+4>>2]+j*+g[d>>2];b=1;a=0;while(1){l=j*+g[d+(b<<3)>>2]+i*+g[d+(b<<3)+4>>2];m=l>k;n=m?b:a;o=b+1|0;if((o|0)<(e|0)){k=m?l:k;b=o;a=n}else{f=n;break}}h=d+(f<<3)|0;return h|0}function qp(a){a=a|0;return c[a+20>>2]|0}function qq(a){a=a|0;return c[a+20>>2]|0}function qr(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,h=0.0,i=0.0,j=0.0,k=0.0,l=0,m=0,n=0;d=c[a+16>>2]|0;e=c[a+20>>2]|0;if((e|0)<=1){f=0;return f|0}h=+g[b+4>>2];i=+g[b>>2];j=h*+g[d+4>>2]+i*+g[d>>2];b=1;a=0;while(1){k=i*+g[d+(b<<3)>>2]+h*+g[d+(b<<3)+4>>2];l=k>j;m=l?b:a;n=b+1|0;if((n|0)<(e|0)){j=l?k:j;b=n;a=m}else{f=m;break}}return f|0}function qs(a,b){a=a|0;b=b|0;c[a+16>>2]=b;return}function qt(a,b){a=a|0;b=b|0;c[a+20>>2]=b;return}function qu(b){b=b|0;return(a[b+20|0]&1)!=0|0}function qv(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function qw(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function qx(a){a=a|0;return+(+g[a+16>>2])}function qy(a){a=a|0;return c[a>>2]|0}function qz(a,b){a=a|0;b=+b;g[a+16>>2]=b;return}function qA(a,b){a=a|0;b=+b;g[a+12>>2]=b;return}function qB(a){a=a|0;return+(+g[a+12>>2])}function qC(b,c){b=b|0;c=c|0;a[b+20|0]=c&1;return}function qD(a){a=a|0;return a+22|0}function qE(a){a=a|0;return+(+g[a+8>>2])}function qF(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function qG(a){a=a|0;return c[a+4>>2]|0}function qH(){var a=0;a=vo(6)|0;b[a>>1]=1;b[a+2>>1]=-1;b[a+4>>1]=0;return a|0}function qI(a){a=a|0;if((a|0)==0){return}vl(a);return}function qJ(){var a=0;a=vo(44)|0;vq(a|0,0,17);c[a>>2]=9;vq(a+20|0,0,24);return a|0}function qK(){var b=0;b=vo(52)|0;c[b+44>>2]=0;vq(b+4|0,0,32);a[b+36|0]=1;a[b+37|0]=1;a[b+38|0]=0;a[b+39|0]=0;c[b>>2]=0;a[b+40|0]=1;g[b+48>>2]=1.0;return b|0}function qL(a){a=a|0;if((a|0)==0){return}vl(a);return}function qM(a){a=a|0;var b=0,c=0.0,d=0,e=0.0,f=0.0,h=0.0,i=0.0;b=a|0;c=+g[b>>2];d=a+4|0;e=+g[d>>2];f=+P(+(c*c+e*e));if(f<1.1920928955078125e-7){h=0.0;return+h}i=1.0/f;g[b>>2]=c*i;g[d>>2]=e*i;h=f;return+h}function qN(){return vo(8)|0}function qO(a,b){a=+a;b=+b;var c=0;c=vo(8)|0;g[c>>2]=a;g[c+4>>2]=b;return c|0}function qP(a){a=a|0;var b=0.0,c=0.0;b=+g[a>>2];c=+g[a+4>>2];return+(+P(+(b*b+c*c)))}function qQ(a){a=a|0;if((a|0)==0){return}vl(a);return}function qR(a){a=a|0;if((a|0)==0){return}vl(a);return}function qS(){return vo(12)|0}function qT(a,b,c){a=+a;b=+b;c=+c;var d=0;d=vo(12)|0;g[d>>2]=a;g[d+4>>2]=b;g[d+8>>2]=c;return d|0}function qU(a,b,c){a=a|0;b=b|0;c=c|0;cf(a,b,c);return}function qV(){var a=0;a=vo(28)|0;c[a+16>>2]=0;c[a+20>>2]=0;g[a+24>>2]=0.0;return a|0}function qW(a){a=a|0;if((a|0)==0){return}vl(a);return}function qX(a){a=a|0;if((a|0)==0){return}vl(a);return}function qY(){var d=0;d=vo(28)|0;b[d+22>>1]=1;b[d+24>>1]=-1;b[d+26>>1]=0;c[d>>2]=0;c[d+4>>2]=0;g[d+8>>2]=.20000000298023224;g[d+12>>2]=0.0;g[d+16>>2]=0.0;a[d+20|0]=0;return d|0}function qZ(a,c){a=a|0;c=c|0;var d=0;d=a+22|0;a=c;b[d>>1]=b[a>>1]|0;b[d+2>>1]=b[a+2>>1]|0;b[d+4>>1]=b[a+4>>1]|0;return}function q_(a,b){a=a|0;b=b|0;do{if((b|0)>-1){if((c[a+20>>2]|0)<=(b|0)){break}return(c[a+16>>2]|0)+(b<<3)|0}}while(0);ba(7536,103,13816,6368);return 0}function q$(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+20|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function q0(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+28|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function q1(a){a=a|0;return+(+g[a+68>>2])}function q2(b){b=b|0;return(a[b+60|0]&1)!=0|0}function q3(a){a=a|0;return+(+g[a+44>>2])}function q4(b,c){b=b|0;c=c|0;a[b+48|0]=c&1;return}function q5(a,b){a=a|0;b=+b;g[a+68>>2]=b;return}function q6(a){a=a|0;return a+36|0}function q7(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function q8(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function q9(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0.0,j=0,k=0.0,l=0.0,m=0,n=0.0,o=0,p=0.0;c[a+8>>2]=b;c[a+12>>2]=d;h=e|0;i=+g[h>>2]- +g[b+12>>2];j=e+4|0;k=+g[j>>2]- +g[b+16>>2];e=b+24|0;l=+g[e>>2];m=b+20|0;n=+g[m>>2];o=a+20|0;p=+(l*k+i*(-0.0-n));g[o>>2]=i*l+k*n;g[o+4>>2]=p;p=+g[h>>2]- +g[d+12>>2];n=+g[j>>2]- +g[d+16>>2];k=+g[d+24>>2];l=+g[d+20>>2];j=a+28|0;i=+(k*n+p*(-0.0-l));g[j>>2]=p*k+n*l;g[j+4>>2]=i;i=+g[e>>2];l=+g[f>>2];n=+g[m>>2];k=+g[f+4>>2];f=a+36|0;p=+(l*(-0.0-n)+i*k);g[f>>2]=i*l+n*k;g[f+4>>2]=p;g[a+44>>2]=+g[d+56>>2]- +g[b+56>>2];return}function ra(a,b){a=a|0;b=+b;g[a+52>>2]=b;return}function rb(a){a=a|0;return+(+g[a+56>>2])}function rc(b){b=b|0;return(a[b+48|0]&1)!=0|0}function rd(a,b){a=a|0;b=+b;g[a+44>>2]=b;return}function re(a){a=a|0;return a+20|0}function rf(a){a=a|0;return a+28|0}function rg(b,c){b=b|0;c=c|0;return(a[b+16|0]&1)!=0|0}function rh(a,b){a=a|0;b=b|0;return c[a+8>>2]|0}function ri(a,b){a=a|0;b=b|0;return c[a+12>>2]|0}function rj(a,b){a=a|0;b=+b;g[a+56>>2]=b;return}function rk(a){a=a|0;return+(+g[a+64>>2])}function rl(a,b){a=a|0;b=+b;g[a+64>>2]=b;return}function rm(b,c){b=b|0;c=c|0;a[b+60|0]=c&1;return}function rn(b,c){b=b|0;c=c|0;a[b+16|0]=c&1;return}function ro(a){a=a|0;return+(+g[a+52>>2])}function rp(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+36|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function rq(b){b=b|0;var c=0.0,d=0;if(!(a[23136]|0)){a[23136]=1}c=+(+g[b+4>>2]);d=72;g[d>>2]=-0.0- +g[b>>2];g[d+4>>2]=c;return 72}function rr(b){b=b|0;var c=0.0,d=0;if(!(a[23144]|0)){a[23144]=1}c=+(+g[b>>2]);d=64;g[d>>2]=+g[b+4>>2];g[d+4>>2]=c;return 64}function rs(a,b){a=a|0;b=+b;g[a+4>>2]=b;return}function rt(a){a=a|0;g[a>>2]=0.0;g[a+4>>2]=1.0;return}function ru(a){a=a|0;return+(+g[a+4>>2])}function rv(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+20|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function rw(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+28|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function rx(a){a=a|0;return+(+g[a+52>>2])}function ry(a,b){a=a|0;b=+b;g[a+48>>2]=b;return}function rz(a,b){a=a|0;b=+b;g[a+56>>2]=b;return}function rA(a,b){a=a|0;b=+b;g[a+52>>2]=b;return}function rB(a){a=a|0;return a+36|0}function rC(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function rD(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function rE(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0.0,j=0,k=0.0,l=0.0,m=0,n=0.0,o=0.0;c[a+8>>2]=b;c[a+12>>2]=d;h=e|0;i=+g[h>>2]- +g[b+12>>2];j=e+4|0;k=+g[j>>2]- +g[b+16>>2];e=b+24|0;l=+g[e>>2];m=b+20|0;n=+g[m>>2];b=a+20|0;o=+(l*k+i*(-0.0-n));g[b>>2]=i*l+k*n;g[b+4>>2]=o;o=+g[h>>2]- +g[d+12>>2];n=+g[j>>2]- +g[d+16>>2];k=+g[d+24>>2];l=+g[d+20>>2];d=a+28|0;i=+(k*n+o*(-0.0-l));g[d>>2]=o*k+n*l;g[d+4>>2]=i;i=+g[e>>2];l=+g[f>>2];n=+g[m>>2];k=+g[f+4>>2];f=a+36|0;o=+(l*(-0.0-n)+i*k);g[f>>2]=i*l+n*k;g[f+4>>2]=o;return}function rF(a){a=a|0;return+(+g[a+56>>2])}function rG(a,b){a=a|0;b=+b;g[a+60>>2]=b;return}function rH(a){a=a|0;return a+20|0}function rI(a){a=a|0;return+(+g[a+48>>2])}function rJ(a){a=a|0;return a+28|0}function rK(b,c){b=b|0;c=c|0;return(a[b+16|0]&1)!=0|0}function rL(b){b=b|0;return(a[b+44|0]&1)!=0|0}function rM(a){a=a|0;return+(+g[a+60>>2])}function rN(a,b){a=a|0;b=b|0;return c[a+8>>2]|0}function rO(a,b){a=a|0;b=b|0;return c[a+12>>2]|0}function rP(b,c){b=b|0;c=c|0;a[b+44|0]=c&1;return}function rQ(b,c){b=b|0;c=c|0;a[b+16|0]=c&1;return}function rR(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+36|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function rS(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+20|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function rT(a){a=a|0;return+(+g[a+44>>2])}function rU(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+28|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function rV(a,b){a=a|0;b=+b;g[a+44>>2]=b;return}function rW(b){b=b|0;return(a[b+52|0]&1)!=0|0}function rX(a,b){a=a|0;b=+b;g[a+48>>2]=b;return}function rY(a){a=a|0;return+(+g[a+36>>2])}function rZ(b,c){b=b|0;c=c|0;a[b+40|0]=c&1;return}function r_(a){a=a|0;return+(+g[a+56>>2])}function r$(a,b){a=a|0;b=+b;g[a+56>>2]=b;return}function r0(a){a=a|0;return+(+g[a+60>>2])}function r1(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function r2(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function r3(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0.0,i=0,j=0.0,k=0.0,l=0.0,m=0.0;c[a+8>>2]=b;c[a+12>>2]=d;f=e|0;h=+g[f>>2]- +g[b+12>>2];i=e+4|0;j=+g[i>>2]- +g[b+16>>2];k=+g[b+24>>2];l=+g[b+20>>2];e=a+20|0;m=+(k*j+h*(-0.0-l));g[e>>2]=h*k+j*l;g[e+4>>2]=m;m=+g[f>>2]- +g[d+12>>2];l=+g[i>>2]- +g[d+16>>2];j=+g[d+24>>2];k=+g[d+20>>2];i=a+28|0;h=+(j*l+m*(-0.0-k));g[i>>2]=m*j+l*k;g[i+4>>2]=h;g[a+36>>2]=+g[d+56>>2]- +g[b+56>>2];return}function r4(b){b=b|0;return(a[b+40|0]&1)!=0|0}function r5(a){a=a|0;return+(+g[a+48>>2])}function r6(a,b){a=a|0;b=+b;g[a+36>>2]=b;return}function r7(a){a=a|0;return a+20|0}function r8(a){a=a|0;return a+28|0}function r9(b,c){b=b|0;c=c|0;return(a[b+16|0]&1)!=0|0}function sa(a,b){a=a|0;b=b|0;return c[a+8>>2]|0}function sb(a,b){a=a|0;b=b|0;return c[a+12>>2]|0}function sc(a,b){a=a|0;b=+b;g[a+60>>2]=b;return}function sd(b,c){b=b|0;c=c|0;a[b+52|0]=c&1;return}function se(b,c){b=b|0;c=c|0;a[b+16|0]=c&1;return}function sf(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+36|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function sg(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+44|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function sh(a,b){a=a|0;b=+b;g[a+60>>2]=b;return}function si(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+28|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function sj(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+20|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function sk(a){a=a|0;return a+28|0}function sl(a){a=a|0;return a+20|0}function sm(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function sn(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function so(a){a=a|0;return+(+g[a+60>>2])}function sp(a){a=a|0;return a+36|0}function sq(a){a=a|0;return a+44|0}function sr(b,c){b=b|0;c=c|0;return(a[b+16|0]&1)!=0|0}function ss(a,b){a=a|0;b=+b;g[a+56>>2]=b;return}function st(a,b){a=a|0;b=+b;g[a+52>>2]=b;return}function su(a,b){a=a|0;b=b|0;return c[a+8>>2]|0}function sv(a,b){a=a|0;b=b|0;return c[a+12>>2]|0}function sw(){var b=0;b=vo(72)|0;vq(b|0,0,17);c[b>>2]=2;vq(b+20|0,0,16);g[b+36>>2]=1.0;g[b+40>>2]=0.0;g[b+44>>2]=0.0;a[b+48|0]=0;g[b+52>>2]=0.0;g[b+56>>2]=0.0;a[b+60|0]=0;g[b+64>>2]=0.0;g[b+68>>2]=0.0;return b|0}function sx(a){a=a|0;if((a|0)==0){return}vl(a);return}function sy(a){a=a|0;if((a|0)==0){return}vl(a);return}function sz(a,b){a=a|0;b=+b;g[a>>2]=+S(+b);g[a+4>>2]=+R(+b);return}function sA(a){a=a|0;return+(+X(+(+g[a>>2]),+(+g[a+4>>2])))}function sB(){return vo(8)|0}function sC(a){a=+a;var b=0;b=vo(8)|0;g[b>>2]=+S(+a);g[b+4>>2]=+R(+a);return b|0}function sD(){var b=0;b=vo(64)|0;vq(b|0,0,17);c[b>>2]=7;vq(b+20|0,0,16);g[b+36>>2]=1.0;g[b+40>>2]=0.0;a[b+44|0]=0;g[b+48>>2]=0.0;g[b+52>>2]=0.0;g[b+56>>2]=2.0;g[b+60>>2]=.699999988079071;return b|0}function sE(a){a=a|0;if((a|0)==0){return}vl(a);return}function sF(){var b=0;b=vo(64)|0;vq(b|0,0,17);c[b>>2]=1;g[b+44>>2]=0.0;g[b+48>>2]=0.0;g[b+60>>2]=0.0;g[b+56>>2]=0.0;a[b+52|0]=0;vq(b+20|0,0,21);return b|0}function sG(a){a=a|0;if((a|0)==0){return}vl(a);return}function sH(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;fI(a,b,c,d,e,f,g,h);return}function sI(a){a=a|0;if((a|0)==0){return}vl(a);return}function sJ(a){a=a|0;return+(+g[a+56>>2])}function sK(a){a=a|0;return+(+g[a+52>>2])}function sL(b,c){b=b|0;c=c|0;a[b+16|0]=c&1;return}function sM(a){a=a|0;return c[a+8>>2]|0}function sN(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function sO(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function sP(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function sQ(a){a=a|0;return c[a+12>>2]|0}function sR(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function sS(b){b=b|0;return(a[b+16|0]&1)!=0|0}function sT(a){a=a|0;return c[a>>2]|0}function sU(b,c){b=b|0;c=c|0;a[b+16|0]=c&1;return}function sV(a){a=a|0;return c[a+4>>2]|0}function sW(a,b){a=a|0;b=b|0;var d=0;d=b;b=a;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function sX(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+8|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function sY(a){a=a|0;return a|0}function sZ(a){a=a|0;return a+8|0}function s_(a){a=a|0;g[a>>2]=0.0;g[a+4>>2]=0.0;g[a+8>>2]=0.0;g[a+12>>2]=1.0;return}function s$(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;g[a>>2]=b;g[a+4>>2]=c;g[a+8>>2]=d;return}function s0(a,b){a=a|0;b=+b;g[a>>2]=b;return}function s1(a){a=a|0;return+(+g[a>>2])}function s2(a,b){a=a|0;b=+b;g[a+8>>2]=b;return}function s3(a){a=a|0;return+(+g[a+4>>2])}function s4(a){a=a|0;return+(+g[a+8>>2])}function s5(a,b){a=a|0;b=+b;g[a+4>>2]=b;return}function s6(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+8|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function s7(a){a=a|0;var b=0.0,c=0.0,d=0.0,e=0.0,f=0;b=+g[a+8>>2];c=+g[a>>2];d=+g[a+12>>2];e=+g[a+4>>2];if(!(b-c>=0.0&d-e>=0.0)){f=0;return f|0}if(!(c==c&!(C=0.0,C!=C)&c>+-p&c<+p)){f=0;return f|0}if(!(e==e&!(C=0.0,C!=C)&e>+-p&e<+p)){f=0;return f|0}if(!(b==b&!(C=0.0,C!=C)&b>+-p&b<+p)){f=0;return f|0}if(!(d==d&!(C=0.0,C!=C)&d>+-p)){f=0;return f|0}f=d<+p;return f|0}function s8(a,b){a=a|0;b=b|0;var c=0;if(+g[a>>2]>+g[b>>2]){c=0;return c|0}if(+g[a+4>>2]>+g[b+4>>2]){c=0;return c|0}if(+g[b+8>>2]>+g[a+8>>2]){c=0;return c|0}c=+g[b+12>>2]<=+g[a+12>>2];return c|0}function s9(b){b=b|0;var c=0.0,d=0;if(!(a[23120]|0)){a[23120]=1}c=+((+g[b+12>>2]- +g[b+4>>2])*.5);d=56;g[d>>2]=(+g[b+8>>2]- +g[b>>2])*.5;g[d+4>>2]=c;return 56}function ta(b){b=b|0;var c=0.0,d=0;if(!(a[23128]|0)){a[23128]=1}c=+((+g[b+4>>2]+ +g[b+12>>2])*.5);d=48;g[d>>2]=(+g[b>>2]+ +g[b+8>>2])*.5;g[d+4>>2]=c;return 48}function tb(a){a=a|0;return a+8|0}function tc(a){a=a|0;return+((+g[a+8>>2]- +g[a>>2]+(+g[a+12>>2]- +g[a+4>>2]))*2.0)}function td(a,b){a=a|0;b=b|0;var c=0.0,d=0.0,e=0.0,f=0.0,h=0,i=0.0;c=+g[a>>2];d=+g[b>>2];e=+g[a+4>>2];f=+g[b+4>>2];h=a;i=+(e>2]=c>2]=i;h=a+8|0;i=+g[h>>2];d=+g[b+8>>2];c=+g[a+12>>2];f=+g[b+12>>2];b=h;e=+(c>f?c:f);g[b>>2]=i>d?i:d;g[b+4>>2]=e;return}function te(a,b,c){a=a|0;b=b|0;c=c|0;var d=0.0,e=0.0,f=0.0,h=0.0,i=0,j=0.0;d=+g[b>>2];e=+g[c>>2];f=+g[b+4>>2];h=+g[c+4>>2];i=a;j=+(f>2]=d>2]=j;j=+g[b+8>>2];e=+g[c+8>>2];d=+g[b+12>>2];h=+g[c+12>>2];c=a+8|0;f=+(d>h?d:h);g[c>>2]=j>e?j:e;g[c+4>>2]=f;return}function tf(a,b){a=a|0;b=b|0;var d=0;d=b;b=a;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function tg(a){a=a|0;return a|0}function th(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+20|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function ti(a,b){a=a|0;b=b|0;return c[a+8>>2]|0}function tj(a,b){a=a|0;b=b|0;return c[a+12>>2]|0}function tk(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+28|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function tl(a){a=a|0;return+(+g[a+40>>2])}function tm(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function tn(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function to(a,b){a=a|0;b=+b;g[a+36>>2]=b;return}function tp(a){a=a|0;return a+20|0}function tq(a){a=a|0;return+(+g[a+36>>2])}function tr(a){a=a|0;return a+28|0}function ts(b,c){b=b|0;c=c|0;return(a[b+16|0]&1)!=0|0}function tt(a){a=a|0;return+(+g[a+44>>2])}function tu(b,c){b=b|0;c=c|0;a[b+16|0]=c&1;return}function tv(a,b){a=a|0;b=+b;g[a+40>>2]=b;return}function tw(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,h=0.0,i=0,j=0.0,k=0.0,l=0.0,m=0.0;c[a+8>>2]=b;c[a+12>>2]=d;f=e|0;h=+g[f>>2]- +g[b+12>>2];i=e+4|0;j=+g[i>>2]- +g[b+16>>2];k=+g[b+24>>2];l=+g[b+20>>2];e=a+20|0;m=+(k*j+h*(-0.0-l));g[e>>2]=h*k+j*l;g[e+4>>2]=m;m=+g[f>>2]- +g[d+12>>2];l=+g[i>>2]- +g[d+16>>2];j=+g[d+24>>2];k=+g[d+20>>2];i=a+28|0;h=+(j*l+m*(-0.0-k));g[i>>2]=m*j+l*k;g[i+4>>2]=h;g[a+36>>2]=+g[d+56>>2]- +g[b+56>>2];return}function tx(a,b){a=a|0;b=+b;g[a+44>>2]=b;return}function ty(a,b){a=a|0;b=b|0;return c[a+8>>2]|0}function tz(a,b){a=a|0;b=b|0;return c[a+12>>2]|0}function tA(a,b){a=a|0;b=+b;g[a+36>>2]=b;return}function tB(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function tC(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function tD(a){a=a|0;return+(+g[a+28>>2])}function tE(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+20|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function tF(a,b){a=a|0;b=+b;g[a+28>>2]=b;return}function tG(a){a=a|0;return+(+g[a+32>>2])}function tH(a){a=a|0;return a+20|0}function tI(b,c){b=b|0;c=c|0;return(a[b+16|0]&1)!=0|0}function tJ(b,c){b=b|0;c=c|0;a[b+16|0]=c&1;return}function tK(a,b){a=a|0;b=+b;g[a+32>>2]=b;return}function tL(a){a=a|0;return+(+g[a+36>>2])}function tM(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+20|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return} +function tN(a,b){a=a|0;b=b|0;return c[a+8>>2]|0}function tO(a,b){a=a|0;b=b|0;return c[a+12>>2]|0}function tP(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+28|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function tQ(a,b){a=a|0;b=+b;g[a+44>>2]=b;return}function tR(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function tS(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function tT(a){a=a|0;return+(+g[a+36>>2])}function tU(a){a=a|0;return a+20|0}function tV(a){a=a|0;return+(+g[a+40>>2])}function tW(a){a=a|0;return a+28|0}function tX(b,c){b=b|0;c=c|0;return(a[b+16|0]&1)!=0|0}function tY(a){a=a|0;return+(+g[a+44>>2])}function tZ(b,c){b=b|0;c=c|0;a[b+16|0]=c&1;return}function t_(a,b){a=a|0;b=+b;g[a+36>>2]=b;return}function t$(a,b){a=a|0;b=+b;g[a+40>>2]=b;return}function t0(){var b=0;b=vo(64)|0;vq(b|0,0,16);c[b>>2]=4;g[b+20>>2]=-1.0;g[b+24>>2]=1.0;g[b+28>>2]=1.0;g[b+32>>2]=1.0;g[b+36>>2]=-1.0;g[b+40>>2]=0.0;g[b+44>>2]=1.0;g[b+48>>2]=0.0;g[b+52>>2]=0.0;g[b+56>>2]=0.0;g[b+60>>2]=1.0;a[b+16|0]=1;return b|0}function t1(a){a=a|0;if((a|0)==0){return}vl(a);return}function t2(){var a=0;a=vo(20)|0;vq(a|0,0,17);return a|0}function t3(a){a=a|0;if((a|0)==0){return}vl(a);return}function t4(a,b,d){a=a|0;b=b|0;d=+d;var e=0,f=0;e=b;b=a;f=c[e+4>>2]|0;c[b>>2]=c[e>>2];c[b+4>>2]=f;g[a+8>>2]=+S(+d);g[a+12>>2]=+R(+d);return}function t5(){return vo(16)|0}function t6(a,b){a=a|0;b=b|0;var d=0,e=0,f=0;d=vo(16)|0;e=a;a=d;f=c[e+4>>2]|0;c[a>>2]=c[e>>2];c[a+4>>2]=f;f=b;b=d+8|0;a=c[f+4>>2]|0;c[b>>2]=c[f>>2];c[b+4>>2]=a;return d|0}function t7(a){a=a|0;if((a|0)==0){return}vl(a);return}function t8(){return vo(12)|0}function t9(a,b,c){a=+a;b=+b;c=+c;var d=0;d=vo(12)|0;g[d>>2]=a;g[d+4>>2]=b;g[d+8>>2]=c;return d|0}function ua(a){a=a|0;if((a|0)==0){return}vl(a);return}function ub(){return vo(16)|0}function uc(a,b,c){a=a|0;b=b|0;c=c|0;return cc(a,b,c)|0}function ud(a){a=a|0;if((a|0)==0){return}vl(a);return}function ue(){var a=0;a=vo(48)|0;vq(a|0,0,17);c[a>>2]=8;vq(a+20|0,0,28);return a|0}function uf(){var a=0;a=vo(40)|0;vq(a|0,0,17);c[a>>2]=5;g[a+20>>2]=0.0;g[a+24>>2]=0.0;g[a+28>>2]=0.0;g[a+32>>2]=5.0;g[a+36>>2]=.699999988079071;return a|0}function ug(a){a=a|0;if((a|0)==0){return}vl(a);return}function uh(){var a=0;a=vo(48)|0;vq(a|0,0,17);c[a>>2]=3;vq(a+20|0,0,16);g[a+36>>2]=1.0;g[a+40>>2]=0.0;g[a+44>>2]=0.0;return a|0}function ui(a){a=a|0;if((a|0)==0){return}vl(a);return}function uj(a){a=a|0;return}function uk(a,b){a=a|0;b=b|0;return}function ul(a,b){a=a|0;b=b|0;return}function um(a){a=a|0;return}function un(a,b){a=a|0;b=b|0;return 0}function uo(a){a=a|0;return}function up(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+0.0}function uq(a){a=a|0;return}function ur(a){a=a|0;return}function us(a){a=a|0;return}function ut(a,b){a=a|0;b=b|0;return c[a+8>>2]|0}function uu(a,b){a=a|0;b=b|0;return c[a+12>>2]|0}function uv(a){a=a|0;return c[a+20>>2]|0}function uw(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function ux(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function uy(a,b){a=a|0;b=b|0;c[a+24>>2]=b;return}function uz(a,b){a=a|0;b=+b;g[a+28>>2]=b;return}function uA(b,c){b=b|0;c=c|0;return(a[b+16|0]&1)!=0|0}function uB(a){a=a|0;return c[a+24>>2]|0}function uC(b,c){b=b|0;c=c|0;a[b+16|0]=c&1;return}function uD(a){a=a|0;return+(+g[a+28>>2])}function uE(a,b){a=a|0;b=b|0;c[a+20>>2]=b;return}function uF(a,b){a=a|0;b=b|0;c[a+4>>2]=b;return}function uG(a){a=a|0;return c[a+8>>2]|0}function uH(a){a=a|0;return c[a>>2]|0}function uI(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function uJ(a){a=a|0;return c[a+12>>2]|0}function uK(a,b){a=a|0;b=b|0;c[a>>2]=b;return}function uL(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function uM(a){a=a|0;return c[a+4>>2]|0}function uN(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+20|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function uO(a,b){a=a|0;b=b|0;return c[a+8>>2]|0}function uP(a,b){a=a|0;b=b|0;return c[a+12>>2]|0}function uQ(a,b){a=a|0;b=b|0;var d=0;d=b;b=a+28|0;a=c[d+4>>2]|0;c[b>>2]=c[d>>2];c[b+4>>2]=a;return}function uR(a,b){a=a|0;b=b|0;c[a+8>>2]=b;return}function uS(a,b){a=a|0;b=b|0;c[a+12>>2]=b;return}function uT(a){a=a|0;return a+20|0}function uU(a){a=a|0;return+(+g[a+36>>2])}function uV(a){a=a|0;return a+28|0}function uW(b,c){b=b|0;c=c|0;return(a[b+16|0]&1)!=0|0}function uX(b,c){b=b|0;c=c|0;a[b+16|0]=c&1;return}function uY(a,b){a=a|0;b=+b;g[a+36>>2]=b;return}function uZ(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0;if((c[d+8>>2]|0)!=(b|0)){return}b=d+16|0;g=c[b>>2]|0;if((g|0)==0){c[b>>2]=e;c[d+24>>2]=f;c[d+36>>2]=1;return}if((g|0)!=(e|0)){e=d+36|0;c[e>>2]=(c[e>>2]|0)+1;c[d+24>>2]=2;a[d+54|0]=1;return}e=d+24|0;if((c[e>>2]|0)!=2){return}c[e>>2]=f;return}function u_(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;if((c[d+8>>2]|0)==(b|0)){if((c[d+4>>2]|0)!=(e|0)){return}g=d+28|0;if((c[g>>2]|0)==1){return}c[g>>2]=f;return}if((c[d>>2]|0)!=(b|0)){return}do{if((c[d+16>>2]|0)!=(e|0)){b=d+20|0;if((c[b>>2]|0)==(e|0)){break}c[d+32>>2]=f;c[b>>2]=e;b=d+40|0;c[b>>2]=(c[b>>2]|0)+1;do{if((c[d+36>>2]|0)==1){if((c[d+24>>2]|0)!=2){break}a[d+54|0]=1}}while(0);c[d+44>>2]=4;return}}while(0);if((f|0)!=1){return}c[d+32>>2]=1;return}function u$(a,b,d,e,f){a=a|0;b=b|0;d=d|0;e=e|0;f=f|0;var h=0,i=0.0,j=0,k=0.0,l=0.0,m=0.0,n=0.0;c[a+8>>2]=b;c[a+12>>2]=d;h=e|0;i=+g[h>>2]- +g[b+12>>2];j=e+4|0;k=+g[j>>2]- +g[b+16>>2];l=+g[b+24>>2];m=+g[b+20>>2];b=a+20|0;n=+(l*k+i*(-0.0-m));g[b>>2]=i*l+k*m;g[b+4>>2]=n;b=f|0;n=+g[b>>2]- +g[d+12>>2];e=f+4|0;m=+g[e>>2]- +g[d+16>>2];k=+g[d+24>>2];l=+g[d+20>>2];d=a+28|0;i=+(k*m+n*(-0.0-l));g[d>>2]=n*k+m*l;g[d+4>>2]=i;i=+g[b>>2]- +g[h>>2];l=+g[e>>2]- +g[j>>2];g[a+36>>2]=+P(+(i*i+l*l));return}function u0(a){a=a|0;if((a|0)==0){return}vl(a);return}function u1(){var a=0;a=vo(32)|0;vq(a|0,0,17);c[a>>2]=6;c[a+20>>2]=0;c[a+24>>2]=0;g[a+28>>2]=1.0;return a|0}function u2(a){a=a|0;if((a|0)==0){return}vl(a);return}function u3(){return vo(16)|0}function u4(a){a=a|0;if((a|0)==0){return}vl(a);return}function u5(){var a=0;a=vo(40)|0;vq(a|0,0,17);c[a>>2]=10;g[a+20>>2]=-1.0;g[a+24>>2]=0.0;g[a+28>>2]=1.0;g[a+32>>2]=0.0;g[a+36>>2]=0.0;return a|0}function u6(a){a=a|0;vl(a);return}function u7(a){a=a|0;vl(a);return}function u8(a){a=a|0;vl(a);return}function u9(a){a=a|0;vl(a);return}function va(a){a=a|0;vl(a);return}function vb(a,b,d){a=a|0;b=b|0;d=d|0;var e=0,f=0,g=0,h=0,j=0;e=i;i=i+56|0;f=e|0;do{if((a|0)==(b|0)){g=1}else{if((b|0)==0){g=0;break}h=vd(b,21432,21416,-1)|0;j=h;if((h|0)==0){g=0;break}vq(f|0,0,56);c[f>>2]=j;c[f+8>>2]=a;c[f+12>>2]=-1;c[f+48>>2]=1;bO[c[(c[h>>2]|0)+28>>2]&127](j,f,c[d>>2]|0,1);if((c[f+24>>2]|0)!=1){g=0;break}c[d>>2]=c[f+16>>2];g=1}}while(0);i=e;return g|0}function vc(b,d,e,f){b=b|0;d=d|0;e=e|0;f=f|0;var g=0;if((b|0)!=(c[d+8>>2]|0)){g=c[b+8>>2]|0;bO[c[(c[g>>2]|0)+28>>2]&127](g,d,e,f);return}g=d+16|0;b=c[g>>2]|0;if((b|0)==0){c[g>>2]=e;c[d+24>>2]=f;c[d+36>>2]=1;return}if((b|0)!=(e|0)){e=d+36|0;c[e>>2]=(c[e>>2]|0)+1;c[d+24>>2]=2;a[d+54|0]=1;return}e=d+24|0;if((c[e>>2]|0)!=2){return}c[e>>2]=f;return}function vd(a,b,d,e){a=a|0;b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0,j=0,k=0,l=0,m=0,n=0,o=0;f=i;i=i+56|0;g=f|0;h=c[a>>2]|0;j=a+(c[h-8>>2]|0)|0;k=c[h-4>>2]|0;h=k;c[g>>2]=d;c[g+4>>2]=a;c[g+8>>2]=b;c[g+12>>2]=e;e=g+16|0;b=g+20|0;a=g+24|0;l=g+28|0;m=g+32|0;n=g+40|0;vq(e|0,0,39);if((k|0)==(d|0)){c[g+48>>2]=1;bA[c[(c[k>>2]|0)+20>>2]&63](h,g,j,j,1,0);i=f;return((c[a>>2]|0)==1?j:0)|0}bl[c[(c[k>>2]|0)+24>>2]&63](h,g,j,1,0);j=c[g+36>>2]|0;do{if((j|0)==1){if((c[a>>2]|0)!=1){if((c[n>>2]|0)!=0){o=0;break}if((c[l>>2]|0)!=1){o=0;break}if((c[m>>2]|0)!=1){o=0;break}}o=c[e>>2]|0}else if((j|0)==0){if((c[n>>2]|0)!=1){o=0;break}if((c[l>>2]|0)!=1){o=0;break}o=(c[m>>2]|0)==1?c[b>>2]|0:0}else{o=0}}while(0);i=f;return o|0}function ve(b,d,e,f,g){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;var h=0,i=0,j=0,k=0,l=0,m=0,n=0;h=b|0;if((h|0)==(c[d+8>>2]|0)){if((c[d+4>>2]|0)!=(e|0)){return}i=d+28|0;if((c[i>>2]|0)==1){return}c[i>>2]=f;return}if((h|0)!=(c[d>>2]|0)){h=c[b+8>>2]|0;bl[c[(c[h>>2]|0)+24>>2]&63](h,d,e,f,g);return}do{if((c[d+16>>2]|0)!=(e|0)){h=d+20|0;if((c[h>>2]|0)==(e|0)){break}c[d+32>>2]=f;i=d+44|0;if((c[i>>2]|0)==4){return}j=d+52|0;a[j]=0;k=d+53|0;a[k]=0;l=c[b+8>>2]|0;bA[c[(c[l>>2]|0)+20>>2]&63](l,d,e,e,1,g);if((a[k]&1)==0){m=0;n=1971}else{if((a[j]&1)==0){m=1;n=1971}}L2185:do{if((n|0)==1971){c[h>>2]=e;j=d+40|0;c[j>>2]=(c[j>>2]|0)+1;do{if((c[d+36>>2]|0)==1){if((c[d+24>>2]|0)!=2){n=1974;break}a[d+54|0]=1;if(m){break L2185}}else{n=1974}}while(0);if((n|0)==1974){if(m){break}}c[i>>2]=4;return}}while(0);c[i>>2]=3;return}}while(0);if((f|0)!=1){return}c[d+32>>2]=1;return}function vf(b,d,e,f,g,h){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0,j=0;if((b|0)!=(c[d+8>>2]|0)){i=c[b+8>>2]|0;bA[c[(c[i>>2]|0)+20>>2]&63](i,d,e,f,g,h);return}a[d+53|0]=1;if((c[d+4>>2]|0)!=(f|0)){return}a[d+52|0]=1;f=d+16|0;h=c[f>>2]|0;if((h|0)==0){c[f>>2]=e;c[d+24>>2]=g;c[d+36>>2]=1;if(!((c[d+48>>2]|0)==1&(g|0)==1)){return}a[d+54|0]=1;return}if((h|0)!=(e|0)){e=d+36|0;c[e>>2]=(c[e>>2]|0)+1;a[d+54|0]=1;return}e=d+24|0;h=c[e>>2]|0;if((h|0)==2){c[e>>2]=g;j=g}else{j=h}if(!((c[d+48>>2]|0)==1&(j|0)==1)){return}a[d+54|0]=1;return}function vg(b,d,e,f,g,h){b=b|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;var i=0;if((c[d+8>>2]|0)!=(b|0)){return}a[d+53|0]=1;if((c[d+4>>2]|0)!=(f|0)){return}a[d+52|0]=1;f=d+16|0;b=c[f>>2]|0;if((b|0)==0){c[f>>2]=e;c[d+24>>2]=g;c[d+36>>2]=1;if(!((c[d+48>>2]|0)==1&(g|0)==1)){return}a[d+54|0]=1;return}if((b|0)!=(e|0)){e=d+36|0;c[e>>2]=(c[e>>2]|0)+1;a[d+54|0]=1;return}e=d+24|0;b=c[e>>2]|0;if((b|0)==2){c[e>>2]=g;i=g}else{i=b}if(!((c[d+48>>2]|0)==1&(i|0)==1)){return}a[d+54|0]=1;return}function vh(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ab=0,ac=0,ad=0,ae=0,af=0,ag=0,ah=0,ai=0,aj=0,ak=0,al=0,am=0,an=0,ao=0,ap=0,aq=0,ar=0,as=0,at=0,au=0,av=0,aw=0,ax=0,ay=0,az=0,aA=0,aB=0,aC=0,aD=0,aE=0,aF=0,aG=0;do{if(a>>>0<245){if(a>>>0<11){b=16}else{b=a+11&-8}d=b>>>3;e=c[3258]|0;f=e>>>(d>>>0);if((f&3|0)!=0){g=(f&1^1)+d|0;h=g<<1;i=13072+(h<<2)|0;j=13072+(h+2<<2)|0;h=c[j>>2]|0;k=h+8|0;l=c[k>>2]|0;do{if((i|0)==(l|0)){c[3258]=e&(1<>>0<(c[3262]|0)>>>0){aO();return 0;return 0}m=l+12|0;if((c[m>>2]|0)==(h|0)){c[m>>2]=i;c[j>>2]=l;break}else{aO();return 0;return 0}}}while(0);l=g<<3;c[h+4>>2]=l|3;j=h+(l|4)|0;c[j>>2]=c[j>>2]|1;n=k;return n|0}if(b>>>0<=(c[3260]|0)>>>0){o=b;break}if((f|0)!=0){j=2<>>12&16;i=j>>>(l>>>0);j=i>>>5&8;m=i>>>(j>>>0);i=m>>>2&4;p=m>>>(i>>>0);m=p>>>1&2;q=p>>>(m>>>0);p=q>>>1&1;r=(j|l|i|m|p)+(q>>>(p>>>0))|0;p=r<<1;q=13072+(p<<2)|0;m=13072+(p+2<<2)|0;p=c[m>>2]|0;i=p+8|0;l=c[i>>2]|0;do{if((q|0)==(l|0)){c[3258]=e&(1<>>0<(c[3262]|0)>>>0){aO();return 0;return 0}j=l+12|0;if((c[j>>2]|0)==(p|0)){c[j>>2]=q;c[m>>2]=l;break}else{aO();return 0;return 0}}}while(0);l=r<<3;m=l-b|0;c[p+4>>2]=b|3;q=p;e=q+b|0;c[q+(b|4)>>2]=m|1;c[q+l>>2]=m;l=c[3260]|0;if((l|0)!=0){q=c[3263]|0;d=l>>>3;l=d<<1;f=13072+(l<<2)|0;k=c[3258]|0;h=1<>2]|0;if(g>>>0>=(c[3262]|0)>>>0){s=g;t=d;break}aO();return 0;return 0}}while(0);c[t>>2]=q;c[s+12>>2]=q;c[q+8>>2]=s;c[q+12>>2]=f}c[3260]=m;c[3263]=e;n=i;return n|0}l=c[3259]|0;if((l|0)==0){o=b;break}h=(l&-l)-1|0;l=h>>>12&16;k=h>>>(l>>>0);h=k>>>5&8;p=k>>>(h>>>0);k=p>>>2&4;r=p>>>(k>>>0);p=r>>>1&2;d=r>>>(p>>>0);r=d>>>1&1;g=c[13336+((h|l|k|p|r)+(d>>>(r>>>0))<<2)>>2]|0;r=g;d=g;p=(c[g+4>>2]&-8)-b|0;while(1){g=c[r+16>>2]|0;if((g|0)==0){k=c[r+20>>2]|0;if((k|0)==0){break}else{u=k}}else{u=g}g=(c[u+4>>2]&-8)-b|0;k=g>>>0

>>0;r=u;d=k?u:d;p=k?g:p}r=d;i=c[3262]|0;if(r>>>0>>0){aO();return 0;return 0}e=r+b|0;m=e;if(r>>>0>=e>>>0){aO();return 0;return 0}e=c[d+24>>2]|0;f=c[d+12>>2]|0;do{if((f|0)==(d|0)){q=d+20|0;g=c[q>>2]|0;if((g|0)==0){k=d+16|0;l=c[k>>2]|0;if((l|0)==0){v=0;break}else{w=l;x=k}}else{w=g;x=q}while(1){q=w+20|0;g=c[q>>2]|0;if((g|0)!=0){w=g;x=q;continue}q=w+16|0;g=c[q>>2]|0;if((g|0)==0){break}else{w=g;x=q}}if(x>>>0>>0){aO();return 0;return 0}else{c[x>>2]=0;v=w;break}}else{q=c[d+8>>2]|0;if(q>>>0>>0){aO();return 0;return 0}g=q+12|0;if((c[g>>2]|0)!=(d|0)){aO();return 0;return 0}k=f+8|0;if((c[k>>2]|0)==(d|0)){c[g>>2]=f;c[k>>2]=q;v=f;break}else{aO();return 0;return 0}}}while(0);L2330:do{if((e|0)!=0){f=d+28|0;i=13336+(c[f>>2]<<2)|0;do{if((d|0)==(c[i>>2]|0)){c[i>>2]=v;if((v|0)!=0){break}c[3259]=c[3259]&(1<>2]^-1);break L2330}else{if(e>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}q=e+16|0;if((c[q>>2]|0)==(d|0)){c[q>>2]=v}else{c[e+20>>2]=v}if((v|0)==0){break L2330}}}while(0);if(v>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}c[v+24>>2]=e;f=c[d+16>>2]|0;do{if((f|0)!=0){if(f>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}else{c[v+16>>2]=f;c[f+24>>2]=v;break}}}while(0);f=c[d+20>>2]|0;if((f|0)==0){break}if(f>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}else{c[v+20>>2]=f;c[f+24>>2]=v;break}}}while(0);if(p>>>0<16){e=p+b|0;c[d+4>>2]=e|3;f=r+(e+4)|0;c[f>>2]=c[f>>2]|1}else{c[d+4>>2]=b|3;c[r+(b|4)>>2]=p|1;c[r+(p+b)>>2]=p;f=c[3260]|0;if((f|0)!=0){e=c[3263]|0;i=f>>>3;f=i<<1;q=13072+(f<<2)|0;k=c[3258]|0;g=1<>2]|0;if(l>>>0>=(c[3262]|0)>>>0){y=l;z=i;break}aO();return 0;return 0}}while(0);c[z>>2]=e;c[y+12>>2]=e;c[e+8>>2]=y;c[e+12>>2]=q}c[3260]=p;c[3263]=m}f=d+8|0;if((f|0)==0){o=b;break}else{n=f}return n|0}else{if(a>>>0>4294967231){o=-1;break}f=a+11|0;g=f&-8;k=c[3259]|0;if((k|0)==0){o=g;break}r=-g|0;i=f>>>8;do{if((i|0)==0){A=0}else{if(g>>>0>16777215){A=31;break}f=(i+1048320|0)>>>16&8;l=i<>>16&4;j=l<>>16&2;B=14-(h|f|l)+(j<>>15)|0;A=g>>>((B+7|0)>>>0)&1|B<<1}}while(0);i=c[13336+(A<<2)>>2]|0;L2378:do{if((i|0)==0){C=0;D=r;E=0}else{if((A|0)==31){F=0}else{F=25-(A>>>1)|0}d=0;m=r;p=i;q=g<>2]&-8;l=B-g|0;if(l>>>0>>0){if((B|0)==(g|0)){C=p;D=l;E=p;break L2378}else{G=p;H=l}}else{G=d;H=m}l=c[p+20>>2]|0;B=c[p+16+(q>>>31<<2)>>2]|0;j=(l|0)==0|(l|0)==(B|0)?e:l;if((B|0)==0){C=G;D=H;E=j;break}else{d=G;m=H;p=B;q=q<<1;e=j}}}}while(0);if((E|0)==0&(C|0)==0){i=2<>>12&16;e=i>>>(r>>>0);i=e>>>5&8;q=e>>>(i>>>0);e=q>>>2&4;p=q>>>(e>>>0);q=p>>>1&2;m=p>>>(q>>>0);p=m>>>1&1;I=c[13336+((i|r|e|q|p)+(m>>>(p>>>0))<<2)>>2]|0}else{I=E}if((I|0)==0){J=D;K=C}else{p=I;m=D;q=C;while(1){e=(c[p+4>>2]&-8)-g|0;r=e>>>0>>0;i=r?e:m;e=r?p:q;r=c[p+16>>2]|0;if((r|0)!=0){p=r;m=i;q=e;continue}r=c[p+20>>2]|0;if((r|0)==0){J=i;K=e;break}else{p=r;m=i;q=e}}}if((K|0)==0){o=g;break}if(J>>>0>=((c[3260]|0)-g|0)>>>0){o=g;break}q=K;m=c[3262]|0;if(q>>>0>>0){aO();return 0;return 0}p=q+g|0;k=p;if(q>>>0>=p>>>0){aO();return 0;return 0}e=c[K+24>>2]|0;i=c[K+12>>2]|0;do{if((i|0)==(K|0)){r=K+20|0;d=c[r>>2]|0;if((d|0)==0){j=K+16|0;B=c[j>>2]|0;if((B|0)==0){L=0;break}else{M=B;N=j}}else{M=d;N=r}while(1){r=M+20|0;d=c[r>>2]|0;if((d|0)!=0){M=d;N=r;continue}r=M+16|0;d=c[r>>2]|0;if((d|0)==0){break}else{M=d;N=r}}if(N>>>0>>0){aO();return 0;return 0}else{c[N>>2]=0;L=M;break}}else{r=c[K+8>>2]|0;if(r>>>0>>0){aO();return 0;return 0}d=r+12|0;if((c[d>>2]|0)!=(K|0)){aO();return 0;return 0}j=i+8|0;if((c[j>>2]|0)==(K|0)){c[d>>2]=i;c[j>>2]=r;L=i;break}else{aO();return 0;return 0}}}while(0);L2428:do{if((e|0)!=0){i=K+28|0;m=13336+(c[i>>2]<<2)|0;do{if((K|0)==(c[m>>2]|0)){c[m>>2]=L;if((L|0)!=0){break}c[3259]=c[3259]&(1<>2]^-1);break L2428}else{if(e>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}r=e+16|0;if((c[r>>2]|0)==(K|0)){c[r>>2]=L}else{c[e+20>>2]=L}if((L|0)==0){break L2428}}}while(0);if(L>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}c[L+24>>2]=e;i=c[K+16>>2]|0;do{if((i|0)!=0){if(i>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}else{c[L+16>>2]=i;c[i+24>>2]=L;break}}}while(0);i=c[K+20>>2]|0;if((i|0)==0){break}if(i>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}else{c[L+20>>2]=i;c[i+24>>2]=L;break}}}while(0);do{if(J>>>0<16){e=J+g|0;c[K+4>>2]=e|3;i=q+(e+4)|0;c[i>>2]=c[i>>2]|1}else{c[K+4>>2]=g|3;c[q+(g|4)>>2]=J|1;c[q+(J+g)>>2]=J;i=J>>>3;if(J>>>0<256){e=i<<1;m=13072+(e<<2)|0;r=c[3258]|0;j=1<>2]|0;if(d>>>0>=(c[3262]|0)>>>0){O=d;P=i;break}aO();return 0;return 0}}while(0);c[P>>2]=k;c[O+12>>2]=k;c[q+(g+8)>>2]=O;c[q+(g+12)>>2]=m;break}e=p;j=J>>>8;do{if((j|0)==0){Q=0}else{if(J>>>0>16777215){Q=31;break}r=(j+1048320|0)>>>16&8;i=j<>>16&4;B=i<>>16&2;l=14-(d|r|i)+(B<>>15)|0;Q=J>>>((l+7|0)>>>0)&1|l<<1}}while(0);j=13336+(Q<<2)|0;c[q+(g+28)>>2]=Q;c[q+(g+20)>>2]=0;c[q+(g+16)>>2]=0;m=c[3259]|0;l=1<>2]=e;c[q+(g+24)>>2]=j;c[q+(g+12)>>2]=e;c[q+(g+8)>>2]=e;break}if((Q|0)==31){R=0}else{R=25-(Q>>>1)|0}l=J<>2]|0;while(1){if((c[m+4>>2]&-8|0)==(J|0)){break}S=m+16+(l>>>31<<2)|0;j=c[S>>2]|0;if((j|0)==0){T=2177;break}else{l=l<<1;m=j}}if((T|0)==2177){if(S>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}else{c[S>>2]=e;c[q+(g+24)>>2]=m;c[q+(g+12)>>2]=e;c[q+(g+8)>>2]=e;break}}l=m+8|0;j=c[l>>2]|0;i=c[3262]|0;if(m>>>0>>0){aO();return 0;return 0}if(j>>>0>>0){aO();return 0;return 0}else{c[j+12>>2]=e;c[l>>2]=e;c[q+(g+8)>>2]=j;c[q+(g+12)>>2]=m;c[q+(g+24)>>2]=0;break}}}while(0);q=K+8|0;if((q|0)==0){o=g;break}else{n=q}return n|0}}while(0);K=c[3260]|0;if(o>>>0<=K>>>0){S=K-o|0;J=c[3263]|0;if(S>>>0>15){R=J;c[3263]=R+o;c[3260]=S;c[R+(o+4)>>2]=S|1;c[R+K>>2]=S;c[J+4>>2]=o|3}else{c[3260]=0;c[3263]=0;c[J+4>>2]=K|3;S=J+(K+4)|0;c[S>>2]=c[S>>2]|1}n=J+8|0;return n|0}J=c[3261]|0;if(o>>>0>>0){S=J-o|0;c[3261]=S;J=c[3264]|0;K=J;c[3264]=K+o;c[K+(o+4)>>2]=S|1;c[J+4>>2]=o|3;n=J+8|0;return n|0}do{if((c[104]|0)==0){J=a0(8)|0;if((J-1&J|0)==0){c[106]=J;c[105]=J;c[107]=-1;c[108]=2097152;c[109]=0;c[3369]=0;c[104]=(bj(0)|0)&-16^1431655768;break}else{aO();return 0;return 0}}}while(0);J=o+48|0;S=c[106]|0;K=o+47|0;R=S+K|0;Q=-S|0;S=R&Q;if(S>>>0<=o>>>0){n=0;return n|0}O=c[3368]|0;do{if((O|0)!=0){P=c[3366]|0;L=P+S|0;if(L>>>0<=P>>>0|L>>>0>O>>>0){n=0}else{break}return n|0}}while(0);L2520:do{if((c[3369]&4|0)==0){O=c[3264]|0;L2522:do{if((O|0)==0){T=2207}else{L=O;P=13480;while(1){U=P|0;M=c[U>>2]|0;if(M>>>0<=L>>>0){V=P+4|0;if((M+(c[V>>2]|0)|0)>>>0>L>>>0){break}}M=c[P+8>>2]|0;if((M|0)==0){T=2207;break L2522}else{P=M}}if((P|0)==0){T=2207;break}L=R-(c[3261]|0)&Q;if(L>>>0>=2147483647){W=0;break}m=be(L|0)|0;e=(m|0)==((c[U>>2]|0)+(c[V>>2]|0)|0);X=e?m:-1;Y=e?L:0;Z=m;_=L;T=2216}}while(0);do{if((T|0)==2207){O=be(0)|0;if((O|0)==-1){W=0;break}g=O;L=c[105]|0;m=L-1|0;if((m&g|0)==0){$=S}else{$=S-g+(m+g&-L)|0}L=c[3366]|0;g=L+$|0;if(!($>>>0>o>>>0&$>>>0<2147483647)){W=0;break}m=c[3368]|0;if((m|0)!=0){if(g>>>0<=L>>>0|g>>>0>m>>>0){W=0;break}}m=be($|0)|0;g=(m|0)==(O|0);X=g?O:-1;Y=g?$:0;Z=m;_=$;T=2216}}while(0);L2542:do{if((T|0)==2216){m=-_|0;if((X|0)!=-1){aa=Y;ab=X;T=2227;break L2520}do{if((Z|0)!=-1&_>>>0<2147483647&_>>>0>>0){g=c[106]|0;O=K-_+g&-g;if(O>>>0>=2147483647){ac=_;break}if((be(O|0)|0)==-1){be(m|0)|0;W=Y;break L2542}else{ac=O+_|0;break}}else{ac=_}}while(0);if((Z|0)==-1){W=Y}else{aa=ac;ab=Z;T=2227;break L2520}}}while(0);c[3369]=c[3369]|4;ad=W;T=2224}else{ad=0;T=2224}}while(0);do{if((T|0)==2224){if(S>>>0>=2147483647){break}W=be(S|0)|0;Z=be(0)|0;if(!((Z|0)!=-1&(W|0)!=-1&W>>>0>>0)){break}ac=Z-W|0;Z=ac>>>0>(o+40|0)>>>0;Y=Z?W:-1;if((Y|0)!=-1){aa=Z?ac:ad;ab=Y;T=2227}}}while(0);do{if((T|0)==2227){ad=(c[3366]|0)+aa|0;c[3366]=ad;if(ad>>>0>(c[3367]|0)>>>0){c[3367]=ad}ad=c[3264]|0;L2562:do{if((ad|0)==0){S=c[3262]|0;if((S|0)==0|ab>>>0>>0){c[3262]=ab}c[3370]=ab;c[3371]=aa;c[3373]=0;c[3267]=c[104];c[3266]=-1;S=0;do{Y=S<<1;ac=13072+(Y<<2)|0;c[13072+(Y+3<<2)>>2]=ac;c[13072+(Y+2<<2)>>2]=ac;S=S+1|0;}while(S>>>0<32);S=ab+8|0;if((S&7|0)==0){ae=0}else{ae=-S&7}S=aa-40-ae|0;c[3264]=ab+ae;c[3261]=S;c[ab+(ae+4)>>2]=S|1;c[ab+(aa-36)>>2]=40;c[3265]=c[108]}else{S=13480;while(1){af=c[S>>2]|0;ag=S+4|0;ah=c[ag>>2]|0;if((ab|0)==(af+ah|0)){T=2239;break}ac=c[S+8>>2]|0;if((ac|0)==0){break}else{S=ac}}do{if((T|0)==2239){if((c[S+12>>2]&8|0)!=0){break}ac=ad;if(!(ac>>>0>=af>>>0&ac>>>0>>0)){break}c[ag>>2]=ah+aa;ac=c[3264]|0;Y=(c[3261]|0)+aa|0;Z=ac;W=ac+8|0;if((W&7|0)==0){ai=0}else{ai=-W&7}W=Y-ai|0;c[3264]=Z+ai;c[3261]=W;c[Z+(ai+4)>>2]=W|1;c[Z+(Y+4)>>2]=40;c[3265]=c[108];break L2562}}while(0);if(ab>>>0<(c[3262]|0)>>>0){c[3262]=ab}S=ab+aa|0;Y=13480;while(1){aj=Y|0;if((c[aj>>2]|0)==(S|0)){T=2249;break}Z=c[Y+8>>2]|0;if((Z|0)==0){break}else{Y=Z}}do{if((T|0)==2249){if((c[Y+12>>2]&8|0)!=0){break}c[aj>>2]=ab;S=Y+4|0;c[S>>2]=(c[S>>2]|0)+aa;S=ab+8|0;if((S&7|0)==0){ak=0}else{ak=-S&7}S=ab+(aa+8)|0;if((S&7|0)==0){al=0}else{al=-S&7}S=ab+(al+aa)|0;Z=S;W=ak+o|0;ac=ab+W|0;_=ac;K=S-(ab+ak)-o|0;c[ab+(ak+4)>>2]=o|3;do{if((Z|0)==(c[3264]|0)){J=(c[3261]|0)+K|0;c[3261]=J;c[3264]=_;c[ab+(W+4)>>2]=J|1}else{if((Z|0)==(c[3263]|0)){J=(c[3260]|0)+K|0;c[3260]=J;c[3263]=_;c[ab+(W+4)>>2]=J|1;c[ab+(J+W)>>2]=J;break}J=aa+4|0;X=c[ab+(J+al)>>2]|0;if((X&3|0)==1){$=X&-8;V=X>>>3;L2607:do{if(X>>>0<256){U=c[ab+((al|8)+aa)>>2]|0;Q=c[ab+(aa+12+al)>>2]|0;R=13072+(V<<1<<2)|0;do{if((U|0)!=(R|0)){if(U>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}if((c[U+12>>2]|0)==(Z|0)){break}aO();return 0;return 0}}while(0);if((Q|0)==(U|0)){c[3258]=c[3258]&(1<>>0<(c[3262]|0)>>>0){aO();return 0;return 0}m=Q+8|0;if((c[m>>2]|0)==(Z|0)){am=m;break}aO();return 0;return 0}}while(0);c[U+12>>2]=Q;c[am>>2]=U}else{R=S;m=c[ab+((al|24)+aa)>>2]|0;P=c[ab+(aa+12+al)>>2]|0;do{if((P|0)==(R|0)){O=al|16;g=ab+(J+O)|0;L=c[g>>2]|0;if((L|0)==0){e=ab+(O+aa)|0;O=c[e>>2]|0;if((O|0)==0){an=0;break}else{ao=O;ap=e}}else{ao=L;ap=g}while(1){g=ao+20|0;L=c[g>>2]|0;if((L|0)!=0){ao=L;ap=g;continue}g=ao+16|0;L=c[g>>2]|0;if((L|0)==0){break}else{ao=L;ap=g}}if(ap>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}else{c[ap>>2]=0;an=ao;break}}else{g=c[ab+((al|8)+aa)>>2]|0;if(g>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}L=g+12|0;if((c[L>>2]|0)!=(R|0)){aO();return 0;return 0}e=P+8|0;if((c[e>>2]|0)==(R|0)){c[L>>2]=P;c[e>>2]=g;an=P;break}else{aO();return 0;return 0}}}while(0);if((m|0)==0){break}P=ab+(aa+28+al)|0;U=13336+(c[P>>2]<<2)|0;do{if((R|0)==(c[U>>2]|0)){c[U>>2]=an;if((an|0)!=0){break}c[3259]=c[3259]&(1<>2]^-1);break L2607}else{if(m>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}Q=m+16|0;if((c[Q>>2]|0)==(R|0)){c[Q>>2]=an}else{c[m+20>>2]=an}if((an|0)==0){break L2607}}}while(0);if(an>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}c[an+24>>2]=m;R=al|16;P=c[ab+(R+aa)>>2]|0;do{if((P|0)!=0){if(P>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}else{c[an+16>>2]=P;c[P+24>>2]=an;break}}}while(0);P=c[ab+(J+R)>>2]|0;if((P|0)==0){break}if(P>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}else{c[an+20>>2]=P;c[P+24>>2]=an;break}}}while(0);aq=ab+(($|al)+aa)|0;ar=$+K|0}else{aq=Z;ar=K}J=aq+4|0;c[J>>2]=c[J>>2]&-2;c[ab+(W+4)>>2]=ar|1;c[ab+(ar+W)>>2]=ar;J=ar>>>3;if(ar>>>0<256){V=J<<1;X=13072+(V<<2)|0;P=c[3258]|0;m=1<>2]|0;if(U>>>0>=(c[3262]|0)>>>0){as=U;at=J;break}aO();return 0;return 0}}while(0);c[at>>2]=_;c[as+12>>2]=_;c[ab+(W+8)>>2]=as;c[ab+(W+12)>>2]=X;break}V=ac;m=ar>>>8;do{if((m|0)==0){au=0}else{if(ar>>>0>16777215){au=31;break}P=(m+1048320|0)>>>16&8;$=m<>>16&4;U=$<>>16&2;Q=14-(J|P|$)+(U<<$>>>15)|0;au=ar>>>((Q+7|0)>>>0)&1|Q<<1}}while(0);m=13336+(au<<2)|0;c[ab+(W+28)>>2]=au;c[ab+(W+20)>>2]=0;c[ab+(W+16)>>2]=0;X=c[3259]|0;Q=1<>2]=V;c[ab+(W+24)>>2]=m;c[ab+(W+12)>>2]=V;c[ab+(W+8)>>2]=V;break}if((au|0)==31){av=0}else{av=25-(au>>>1)|0}Q=ar<>2]|0;while(1){if((c[X+4>>2]&-8|0)==(ar|0)){break}aw=X+16+(Q>>>31<<2)|0;m=c[aw>>2]|0;if((m|0)==0){T=2322;break}else{Q=Q<<1;X=m}}if((T|0)==2322){if(aw>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}else{c[aw>>2]=V;c[ab+(W+24)>>2]=X;c[ab+(W+12)>>2]=V;c[ab+(W+8)>>2]=V;break}}Q=X+8|0;m=c[Q>>2]|0;$=c[3262]|0;if(X>>>0<$>>>0){aO();return 0;return 0}if(m>>>0<$>>>0){aO();return 0;return 0}else{c[m+12>>2]=V;c[Q>>2]=V;c[ab+(W+8)>>2]=m;c[ab+(W+12)>>2]=X;c[ab+(W+24)>>2]=0;break}}}while(0);n=ab+(ak|8)|0;return n|0}}while(0);Y=ad;W=13480;while(1){ax=c[W>>2]|0;if(ax>>>0<=Y>>>0){ay=c[W+4>>2]|0;az=ax+ay|0;if(az>>>0>Y>>>0){break}}W=c[W+8>>2]|0}W=ax+(ay-39)|0;if((W&7|0)==0){aA=0}else{aA=-W&7}W=ax+(ay-47+aA)|0;ac=W>>>0<(ad+16|0)>>>0?Y:W;W=ac+8|0;_=ab+8|0;if((_&7|0)==0){aB=0}else{aB=-_&7}_=aa-40-aB|0;c[3264]=ab+aB;c[3261]=_;c[ab+(aB+4)>>2]=_|1;c[ab+(aa-36)>>2]=40;c[3265]=c[108];c[ac+4>>2]=27;c[W>>2]=c[3370];c[W+4>>2]=c[13484>>2];c[W+8>>2]=c[13488>>2];c[W+12>>2]=c[13492>>2];c[3370]=ab;c[3371]=aa;c[3373]=0;c[3372]=W;W=ac+28|0;c[W>>2]=7;if((ac+32|0)>>>0>>0){_=W;while(1){W=_+4|0;c[W>>2]=7;if((_+8|0)>>>0>>0){_=W}else{break}}}if((ac|0)==(Y|0)){break}_=ac-ad|0;W=Y+(_+4)|0;c[W>>2]=c[W>>2]&-2;c[ad+4>>2]=_|1;c[Y+_>>2]=_;W=_>>>3;if(_>>>0<256){K=W<<1;Z=13072+(K<<2)|0;S=c[3258]|0;m=1<>2]|0;if(Q>>>0>=(c[3262]|0)>>>0){aC=Q;aD=W;break}aO();return 0;return 0}}while(0);c[aD>>2]=ad;c[aC+12>>2]=ad;c[ad+8>>2]=aC;c[ad+12>>2]=Z;break}K=ad;m=_>>>8;do{if((m|0)==0){aE=0}else{if(_>>>0>16777215){aE=31;break}S=(m+1048320|0)>>>16&8;Y=m<>>16&4;W=Y<>>16&2;Q=14-(ac|S|Y)+(W<>>15)|0;aE=_>>>((Q+7|0)>>>0)&1|Q<<1}}while(0);m=13336+(aE<<2)|0;c[ad+28>>2]=aE;c[ad+20>>2]=0;c[ad+16>>2]=0;Z=c[3259]|0;Q=1<>2]=K;c[ad+24>>2]=m;c[ad+12>>2]=ad;c[ad+8>>2]=ad;break}if((aE|0)==31){aF=0}else{aF=25-(aE>>>1)|0}Q=_<>2]|0;while(1){if((c[Z+4>>2]&-8|0)==(_|0)){break}aG=Z+16+(Q>>>31<<2)|0;m=c[aG>>2]|0;if((m|0)==0){T=2357;break}else{Q=Q<<1;Z=m}}if((T|0)==2357){if(aG>>>0<(c[3262]|0)>>>0){aO();return 0;return 0}else{c[aG>>2]=K;c[ad+24>>2]=Z;c[ad+12>>2]=ad;c[ad+8>>2]=ad;break}}Q=Z+8|0;_=c[Q>>2]|0;m=c[3262]|0;if(Z>>>0>>0){aO();return 0;return 0}if(_>>>0>>0){aO();return 0;return 0}else{c[_+12>>2]=K;c[Q>>2]=K;c[ad+8>>2]=_;c[ad+12>>2]=Z;c[ad+24>>2]=0;break}}}while(0);ad=c[3261]|0;if(ad>>>0<=o>>>0){break}_=ad-o|0;c[3261]=_;ad=c[3264]|0;Q=ad;c[3264]=Q+o;c[Q+(o+4)>>2]=_|1;c[ad+4>>2]=o|3;n=ad+8|0;return n|0}}while(0);c[(bg()|0)>>2]=12;n=0;return n|0}function vi(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0;if((a|0)==0){return}b=a-8|0;d=b;e=c[3262]|0;if(b>>>0>>0){aO()}f=c[a-4>>2]|0;g=f&3;if((g|0)==1){aO()}h=f&-8;i=a+(h-8)|0;j=i;L2779:do{if((f&1|0)==0){k=c[b>>2]|0;if((g|0)==0){return}l=-8-k|0;m=a+l|0;n=m;o=k+h|0;if(m>>>0>>0){aO()}if((n|0)==(c[3263]|0)){p=a+(h-4)|0;if((c[p>>2]&3|0)!=3){q=n;r=o;break}c[3260]=o;c[p>>2]=c[p>>2]&-2;c[a+(l+4)>>2]=o|1;c[i>>2]=o;return}p=k>>>3;if(k>>>0<256){k=c[a+(l+8)>>2]|0;s=c[a+(l+12)>>2]|0;t=13072+(p<<1<<2)|0;do{if((k|0)!=(t|0)){if(k>>>0>>0){aO()}if((c[k+12>>2]|0)==(n|0)){break}aO()}}while(0);if((s|0)==(k|0)){c[3258]=c[3258]&(1<>>0>>0){aO()}v=s+8|0;if((c[v>>2]|0)==(n|0)){u=v;break}aO()}}while(0);c[k+12>>2]=s;c[u>>2]=k;q=n;r=o;break}t=m;p=c[a+(l+24)>>2]|0;v=c[a+(l+12)>>2]|0;do{if((v|0)==(t|0)){w=a+(l+20)|0;x=c[w>>2]|0;if((x|0)==0){y=a+(l+16)|0;z=c[y>>2]|0;if((z|0)==0){A=0;break}else{B=z;C=y}}else{B=x;C=w}while(1){w=B+20|0;x=c[w>>2]|0;if((x|0)!=0){B=x;C=w;continue}w=B+16|0;x=c[w>>2]|0;if((x|0)==0){break}else{B=x;C=w}}if(C>>>0>>0){aO()}else{c[C>>2]=0;A=B;break}}else{w=c[a+(l+8)>>2]|0;if(w>>>0>>0){aO()}x=w+12|0;if((c[x>>2]|0)!=(t|0)){aO()}y=v+8|0;if((c[y>>2]|0)==(t|0)){c[x>>2]=v;c[y>>2]=w;A=v;break}else{aO()}}}while(0);if((p|0)==0){q=n;r=o;break}v=a+(l+28)|0;m=13336+(c[v>>2]<<2)|0;do{if((t|0)==(c[m>>2]|0)){c[m>>2]=A;if((A|0)!=0){break}c[3259]=c[3259]&(1<>2]^-1);q=n;r=o;break L2779}else{if(p>>>0<(c[3262]|0)>>>0){aO()}k=p+16|0;if((c[k>>2]|0)==(t|0)){c[k>>2]=A}else{c[p+20>>2]=A}if((A|0)==0){q=n;r=o;break L2779}}}while(0);if(A>>>0<(c[3262]|0)>>>0){aO()}c[A+24>>2]=p;t=c[a+(l+16)>>2]|0;do{if((t|0)!=0){if(t>>>0<(c[3262]|0)>>>0){aO()}else{c[A+16>>2]=t;c[t+24>>2]=A;break}}}while(0);t=c[a+(l+20)>>2]|0;if((t|0)==0){q=n;r=o;break}if(t>>>0<(c[3262]|0)>>>0){aO()}else{c[A+20>>2]=t;c[t+24>>2]=A;q=n;r=o;break}}else{q=d;r=h}}while(0);d=q;if(d>>>0>=i>>>0){aO()}A=a+(h-4)|0;e=c[A>>2]|0;if((e&1|0)==0){aO()}do{if((e&2|0)==0){if((j|0)==(c[3264]|0)){B=(c[3261]|0)+r|0;c[3261]=B;c[3264]=q;c[q+4>>2]=B|1;if((q|0)==(c[3263]|0)){c[3263]=0;c[3260]=0}if(B>>>0<=(c[3265]|0)>>>0){return}vn(0)|0;return}if((j|0)==(c[3263]|0)){B=(c[3260]|0)+r|0;c[3260]=B;c[3263]=q;c[q+4>>2]=B|1;c[d+B>>2]=B;return}B=(e&-8)+r|0;C=e>>>3;L2884:do{if(e>>>0<256){u=c[a+h>>2]|0;g=c[a+(h|4)>>2]|0;b=13072+(C<<1<<2)|0;do{if((u|0)!=(b|0)){if(u>>>0<(c[3262]|0)>>>0){aO()}if((c[u+12>>2]|0)==(j|0)){break}aO()}}while(0);if((g|0)==(u|0)){c[3258]=c[3258]&(1<>>0<(c[3262]|0)>>>0){aO()}f=g+8|0;if((c[f>>2]|0)==(j|0)){D=f;break}aO()}}while(0);c[u+12>>2]=g;c[D>>2]=u}else{b=i;f=c[a+(h+16)>>2]|0;t=c[a+(h|4)>>2]|0;do{if((t|0)==(b|0)){p=a+(h+12)|0;v=c[p>>2]|0;if((v|0)==0){m=a+(h+8)|0;k=c[m>>2]|0;if((k|0)==0){E=0;break}else{F=k;G=m}}else{F=v;G=p}while(1){p=F+20|0;v=c[p>>2]|0;if((v|0)!=0){F=v;G=p;continue}p=F+16|0;v=c[p>>2]|0;if((v|0)==0){break}else{F=v;G=p}}if(G>>>0<(c[3262]|0)>>>0){aO()}else{c[G>>2]=0;E=F;break}}else{p=c[a+h>>2]|0;if(p>>>0<(c[3262]|0)>>>0){aO()}v=p+12|0;if((c[v>>2]|0)!=(b|0)){aO()}m=t+8|0;if((c[m>>2]|0)==(b|0)){c[v>>2]=t;c[m>>2]=p;E=t;break}else{aO()}}}while(0);if((f|0)==0){break}t=a+(h+20)|0;u=13336+(c[t>>2]<<2)|0;do{if((b|0)==(c[u>>2]|0)){c[u>>2]=E;if((E|0)!=0){break}c[3259]=c[3259]&(1<>2]^-1);break L2884}else{if(f>>>0<(c[3262]|0)>>>0){aO()}g=f+16|0;if((c[g>>2]|0)==(b|0)){c[g>>2]=E}else{c[f+20>>2]=E}if((E|0)==0){break L2884}}}while(0);if(E>>>0<(c[3262]|0)>>>0){aO()}c[E+24>>2]=f;b=c[a+(h+8)>>2]|0;do{if((b|0)!=0){if(b>>>0<(c[3262]|0)>>>0){aO()}else{c[E+16>>2]=b;c[b+24>>2]=E;break}}}while(0);b=c[a+(h+12)>>2]|0;if((b|0)==0){break}if(b>>>0<(c[3262]|0)>>>0){aO()}else{c[E+20>>2]=b;c[b+24>>2]=E;break}}}while(0);c[q+4>>2]=B|1;c[d+B>>2]=B;if((q|0)!=(c[3263]|0)){H=B;break}c[3260]=B;return}else{c[A>>2]=e&-2;c[q+4>>2]=r|1;c[d+r>>2]=r;H=r}}while(0);r=H>>>3;if(H>>>0<256){d=r<<1;e=13072+(d<<2)|0;A=c[3258]|0;E=1<>2]|0;if(h>>>0>=(c[3262]|0)>>>0){I=h;J=r;break}aO()}}while(0);c[J>>2]=q;c[I+12>>2]=q;c[q+8>>2]=I;c[q+12>>2]=e;return}e=q;I=H>>>8;do{if((I|0)==0){K=0}else{if(H>>>0>16777215){K=31;break}J=(I+1048320|0)>>>16&8;d=I<>>16&4;A=d<>>16&2;r=14-(E|J|d)+(A<>>15)|0;K=H>>>((r+7|0)>>>0)&1|r<<1}}while(0);I=13336+(K<<2)|0;c[q+28>>2]=K;c[q+20>>2]=0;c[q+16>>2]=0;r=c[3259]|0;d=1<>2]=e;c[q+24>>2]=I;c[q+12>>2]=q;c[q+8>>2]=q}else{if((K|0)==31){L=0}else{L=25-(K>>>1)|0}A=H<>2]|0;while(1){if((c[J+4>>2]&-8|0)==(H|0)){break}M=J+16+(A>>>31<<2)|0;E=c[M>>2]|0;if((E|0)==0){N=2536;break}else{A=A<<1;J=E}}if((N|0)==2536){if(M>>>0<(c[3262]|0)>>>0){aO()}else{c[M>>2]=e;c[q+24>>2]=J;c[q+12>>2]=q;c[q+8>>2]=q;break}}A=J+8|0;B=c[A>>2]|0;E=c[3262]|0;if(J>>>0>>0){aO()}if(B>>>0>>0){aO()}else{c[B+12>>2]=e;c[A>>2]=e;c[q+8>>2]=B;c[q+12>>2]=J;c[q+24>>2]=0;break}}}while(0);q=(c[3266]|0)-1|0;c[3266]=q;if((q|0)==0){O=13488}else{return}while(1){q=c[O>>2]|0;if((q|0)==0){break}else{O=q+8|0}}c[3266]=-1;return}function vj(a){a=a|0;return}function vk(a){a=a|0;return 6752|0}function vl(a){a=a|0;if((a|0)!=0){vi(a)}return}function vm(a){a=a|0;vl(a);return}function vn(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;do{if((c[104]|0)==0){b=a0(8)|0;if((b-1&b|0)==0){c[106]=b;c[105]=b;c[107]=-1;c[108]=2097152;c[109]=0;c[3369]=0;c[104]=(bj(0)|0)&-16^1431655768;break}else{aO();return 0;return 0}}}while(0);if(a>>>0>=4294967232){d=0;return d|0}b=c[3264]|0;if((b|0)==0){d=0;return d|0}e=c[3261]|0;do{if(e>>>0>(a+40|0)>>>0){f=c[106]|0;g=$((((-40-a-1+e+f|0)>>>0)/(f>>>0)>>>0)-1|0,f)|0;h=b;i=13480;while(1){j=c[i>>2]|0;if(j>>>0<=h>>>0){if((j+(c[i+4>>2]|0)|0)>>>0>h>>>0){k=i;break}}j=c[i+8>>2]|0;if((j|0)==0){k=0;break}else{i=j}}if((c[k+12>>2]&8|0)!=0){break}i=be(0)|0;h=k+4|0;if((i|0)!=((c[k>>2]|0)+(c[h>>2]|0)|0)){break}j=be(-(g>>>0>2147483646?-2147483648-f|0:g)|0)|0;l=be(0)|0;if(!((j|0)!=-1&l>>>0>>0)){break}j=i-l|0;if((i|0)==(l|0)){break}c[h>>2]=(c[h>>2]|0)-j;c[3366]=(c[3366]|0)-j;h=c[3264]|0;m=(c[3261]|0)-j|0;j=h;n=h+8|0;if((n&7|0)==0){o=0}else{o=-n&7}n=m-o|0;c[3264]=j+o;c[3261]=n;c[j+(o+4)>>2]=n|1;c[j+(m+4)>>2]=40;c[3265]=c[108];d=(i|0)!=(l|0)&1;return d|0}}while(0);if((c[3261]|0)>>>0<=(c[3265]|0)>>>0){d=0;return d|0}c[3265]=-1;d=0;return d|0}function vo(a){a=a|0;var b=0,d=0,e=0;b=(a|0)==0?1:a;while(1){d=vh(b)|0;if((d|0)!=0){e=2620;break}a=(B=c[5692]|0,c[5692]=B+0,B);if((a|0)==0){break}bM[a&63]()}if((e|0)==2620){return d|0}d=bf(4)|0;c[d>>2]=19248;aN(d|0,21384,78);return 0}function vp(b,d,e){b=b|0;d=d|0;e=e|0;var f=0;f=b|0;if((b&3)==(d&3)){while(b&3){if((e|0)==0)return f|0;a[b]=a[d]|0;b=b+1|0;d=d+1|0;e=e-1|0}while((e|0)>=4){c[b>>2]=c[d>>2];b=b+4|0;d=d+4|0;e=e-4|0}}while((e|0)>0){a[b]=a[d]|0;b=b+1|0;d=d+1|0;e=e-1|0}return f|0}function vq(b,d,e){b=b|0;d=d|0;e=e|0;var f=0,g=0,h=0;f=b+e|0;if((e|0)>=20){d=d&255;e=b&3;g=d|d<<8|d<<16|d<<24;h=f&~3;if(e){e=b+4-e|0;while((b|0)<(e|0)){a[b]=d;b=b+1|0}}while((b|0)<(h|0)){c[b>>2]=g;b=b+4|0}}while((b|0)<(f|0)){a[b]=d;b=b+1|0}}function vr(b){b=b|0;var c=0;c=b;while(a[c]|0){c=c+1|0}return c-b|0}function vs(){a1()}function vt(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;bl[a&63](b|0,c|0,d|0,e|0,f|0)}function vu(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(0,a|0,b|0,c|0,d|0,e|0)}function vv(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(1,a|0,b|0,c|0,d|0,e|0)}function vw(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(2,a|0,b|0,c|0,d|0,e|0)}function vx(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(3,a|0,b|0,c|0,d|0,e|0)}function vy(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(4,a|0,b|0,c|0,d|0,e|0)}function vz(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(5,a|0,b|0,c|0,d|0,e|0)}function vA(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(6,a|0,b|0,c|0,d|0,e|0)}function vB(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(7,a|0,b|0,c|0,d|0,e|0)}function vC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(8,a|0,b|0,c|0,d|0,e|0)}function vD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(9,a|0,b|0,c|0,d|0,e|0)}function vE(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(10,a|0,b|0,c|0,d|0,e|0)}function vF(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(11,a|0,b|0,c|0,d|0,e|0)}function vG(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(12,a|0,b|0,c|0,d|0,e|0)}function vH(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(13,a|0,b|0,c|0,d|0,e|0)}function vI(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(14,a|0,b|0,c|0,d|0,e|0)}function vJ(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(15,a|0,b|0,c|0,d|0,e|0)}function vK(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(16,a|0,b|0,c|0,d|0,e|0)}function vL(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(17,a|0,b|0,c|0,d|0,e|0)}function vM(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(18,a|0,b|0,c|0,d|0,e|0)}function vN(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;af(19,a|0,b|0,c|0,d|0,e|0)}function vO(a,b,c){a=a|0;b=b|0;c=+c;bm[a&255](b|0,+c)}function vP(a,b){a=a|0;b=+b;af(0,a|0,+b)}function vQ(a,b){a=a|0;b=+b;af(1,a|0,+b)}function vR(a,b){a=a|0;b=+b;af(2,a|0,+b)}function vS(a,b){a=a|0;b=+b;af(3,a|0,+b)}function vT(a,b){a=a|0;b=+b;af(4,a|0,+b)}function vU(a,b){a=a|0;b=+b;af(5,a|0,+b)}function vV(a,b){a=a|0;b=+b;af(6,a|0,+b)}function vW(a,b){a=a|0;b=+b;af(7,a|0,+b)}function vX(a,b){a=a|0;b=+b;af(8,a|0,+b)}function vY(a,b){a=a|0;b=+b;af(9,a|0,+b)}function vZ(a,b){a=a|0;b=+b;af(10,a|0,+b)}function v_(a,b){a=a|0;b=+b;af(11,a|0,+b)}function v$(a,b){a=a|0;b=+b;af(12,a|0,+b)}function v0(a,b){a=a|0;b=+b;af(13,a|0,+b)}function v1(a,b){a=a|0;b=+b;af(14,a|0,+b)}function v2(a,b){a=a|0;b=+b;af(15,a|0,+b)}function v3(a,b){a=a|0;b=+b;af(16,a|0,+b)}function v4(a,b){a=a|0;b=+b;af(17,a|0,+b)}function v5(a,b){a=a|0;b=+b;af(18,a|0,+b)}function v6(a,b){a=a|0;b=+b;af(19,a|0,+b)}function v7(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=+d;e=e|0;f=f|0;bn[a&63](b|0,c|0,+d,e|0,f|0)}function v8(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(0,a|0,b|0,+c,d|0,e|0)}function v9(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(1,a|0,b|0,+c,d|0,e|0)}function wa(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(2,a|0,b|0,+c,d|0,e|0)}function wb(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(3,a|0,b|0,+c,d|0,e|0)}function wc(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(4,a|0,b|0,+c,d|0,e|0)}function wd(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(5,a|0,b|0,+c,d|0,e|0)}function we(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(6,a|0,b|0,+c,d|0,e|0)}function wf(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(7,a|0,b|0,+c,d|0,e|0)}function wg(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(8,a|0,b|0,+c,d|0,e|0)}function wh(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(9,a|0,b|0,+c,d|0,e|0)}function wi(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(10,a|0,b|0,+c,d|0,e|0)}function wj(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(11,a|0,b|0,+c,d|0,e|0)}function wk(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(12,a|0,b|0,+c,d|0,e|0)}function wl(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(13,a|0,b|0,+c,d|0,e|0)}function wm(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(14,a|0,b|0,+c,d|0,e|0)}function wn(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(15,a|0,b|0,+c,d|0,e|0)}function wo(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(16,a|0,b|0,+c,d|0,e|0)}function wp(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(17,a|0,b|0,+c,d|0,e|0)}function wq(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(18,a|0,b|0,+c,d|0,e|0)}function wr(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;af(19,a|0,b|0,+c,d|0,e|0)}function ws(a,b){a=a|0;b=b|0;bo[a&511](b|0)}function wt(a){a=a|0;af(0,a|0)}function wu(a){a=a|0;af(1,a|0)}function wv(a){a=a|0;af(2,a|0)}function ww(a){a=a|0;af(3,a|0)}function wx(a){a=a|0;af(4,a|0)}function wy(a){a=a|0;af(5,a|0)}function wz(a){a=a|0;af(6,a|0)}function wA(a){a=a|0;af(7,a|0)}function wB(a){a=a|0;af(8,a|0)}function wC(a){a=a|0;af(9,a|0)}function wD(a){a=a|0;af(10,a|0)}function wE(a){a=a|0;af(11,a|0)}function wF(a){a=a|0;af(12,a|0)}function wG(a){a=a|0;af(13,a|0)}function wH(a){a=a|0;af(14,a|0)}function wI(a){a=a|0;af(15,a|0)}function wJ(a){a=a|0;af(16,a|0)}function wK(a){a=a|0;af(17,a|0)}function wL(a){a=a|0;af(18,a|0)}function wM(a){a=a|0;af(19,a|0)}function wN(a,b,c){a=a|0;b=b|0;c=c|0;bp[a&511](b|0,c|0)}function wO(a,b){a=a|0;b=b|0;af(0,a|0,b|0)}function wP(a,b){a=a|0;b=b|0;af(1,a|0,b|0)}function wQ(a,b){a=a|0;b=b|0;af(2,a|0,b|0)}function wR(a,b){a=a|0;b=b|0;af(3,a|0,b|0)}function wS(a,b){a=a|0;b=b|0;af(4,a|0,b|0)}function wT(a,b){a=a|0;b=b|0;af(5,a|0,b|0)}function wU(a,b){a=a|0;b=b|0;af(6,a|0,b|0)}function wV(a,b){a=a|0;b=b|0;af(7,a|0,b|0)}function wW(a,b){a=a|0;b=b|0;af(8,a|0,b|0)}function wX(a,b){a=a|0;b=b|0;af(9,a|0,b|0)}function wY(a,b){a=a|0;b=b|0;af(10,a|0,b|0)}function wZ(a,b){a=a|0;b=b|0;af(11,a|0,b|0)}function w_(a,b){a=a|0;b=b|0;af(12,a|0,b|0)}function w$(a,b){a=a|0;b=b|0;af(13,a|0,b|0)}function w0(a,b){a=a|0;b=b|0;af(14,a|0,b|0)}function w1(a,b){a=a|0;b=b|0;af(15,a|0,b|0)}function w2(a,b){a=a|0;b=b|0;af(16,a|0,b|0)}function w3(a,b){a=a|0;b=b|0;af(17,a|0,b|0)}function w4(a,b){a=a|0;b=b|0;af(18,a|0,b|0)}function w5(a,b){a=a|0;b=b|0;af(19,a|0,b|0)}function w6(a,b){a=a|0;b=b|0;return bq[a&1023](b|0)|0}function w7(a){a=a|0;return af(0,a|0)|0}function w8(a){a=a|0;return af(1,a|0)|0}function w9(a){a=a|0;return af(2,a|0)|0}function xa(a){a=a|0;return af(3,a|0)|0}function xb(a){a=a|0;return af(4,a|0)|0}function xc(a){a=a|0;return af(5,a|0)|0}function xd(a){a=a|0;return af(6,a|0)|0}function xe(a){a=a|0;return af(7,a|0)|0}function xf(a){a=a|0;return af(8,a|0)|0}function xg(a){a=a|0;return af(9,a|0)|0}function xh(a){a=a|0;return af(10,a|0)|0}function xi(a){a=a|0;return af(11,a|0)|0}function xj(a){a=a|0;return af(12,a|0)|0}function xk(a){a=a|0;return af(13,a|0)|0}function xl(a){a=a|0;return af(14,a|0)|0}function xm(a){a=a|0;return af(15,a|0)|0}function xn(a){a=a|0;return af(16,a|0)|0}function xo(a){a=a|0;return af(17,a|0)|0}function xp(a){a=a|0;return af(18,a|0)|0}function xq(a){a=a|0;return af(19,a|0)|0}function xr(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=+d;e=e|0;br[a&63](b|0,c|0,+d,e|0)}function xs(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(0,a|0,b|0,+c,d|0)}function xt(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(1,a|0,b|0,+c,d|0)}function xu(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(2,a|0,b|0,+c,d|0)}function xv(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(3,a|0,b|0,+c,d|0)}function xw(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(4,a|0,b|0,+c,d|0)}function xx(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(5,a|0,b|0,+c,d|0)}function xy(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(6,a|0,b|0,+c,d|0)}function xz(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(7,a|0,b|0,+c,d|0)}function xA(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(8,a|0,b|0,+c,d|0)}function xB(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(9,a|0,b|0,+c,d|0)}function xC(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(10,a|0,b|0,+c,d|0)}function xD(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(11,a|0,b|0,+c,d|0)}function xE(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(12,a|0,b|0,+c,d|0)}function xF(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(13,a|0,b|0,+c,d|0)}function xG(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(14,a|0,b|0,+c,d|0)}function xH(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(15,a|0,b|0,+c,d|0)}function xI(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(16,a|0,b|0,+c,d|0)}function xJ(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(17,a|0,b|0,+c,d|0)}function xK(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(18,a|0,b|0,+c,d|0)}function xL(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;af(19,a|0,b|0,+c,d|0)}function xM(a,b){a=a|0;b=+b;return bs[a&63](+b)|0}function xN(a){a=+a;return af(0,+a)|0}function xO(a){a=+a;return af(1,+a)|0}function xP(a){a=+a;return af(2,+a)|0}function xQ(a){a=+a;return af(3,+a)|0}function xR(a){a=+a;return af(4,+a)|0}function xS(a){a=+a;return af(5,+a)|0}function xT(a){a=+a;return af(6,+a)|0}function xU(a){a=+a;return af(7,+a)|0}function xV(a){a=+a;return af(8,+a)|0}function xW(a){a=+a;return af(9,+a)|0}function xX(a){a=+a;return af(10,+a)|0}function xY(a){a=+a;return af(11,+a)|0}function xZ(a){a=+a;return af(12,+a)|0}function x_(a){a=+a;return af(13,+a)|0}function x$(a){a=+a;return af(14,+a)|0}function x0(a){a=+a;return af(15,+a)|0}function x1(a){a=+a;return af(16,+a)|0}function x2(a){a=+a;return af(17,+a)|0}function x3(a){a=+a;return af(18,+a)|0}function x4(a){a=+a;return af(19,+a)|0}function x5(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return bt[a&63](b|0,c|0,d|0,e|0)|0}function x6(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(0,a|0,b|0,c|0,d|0)|0}function x7(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(1,a|0,b|0,c|0,d|0)|0}function x8(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(2,a|0,b|0,c|0,d|0)|0}function x9(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(3,a|0,b|0,c|0,d|0)|0}function ya(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(4,a|0,b|0,c|0,d|0)|0}function yb(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(5,a|0,b|0,c|0,d|0)|0}function yc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(6,a|0,b|0,c|0,d|0)|0}function yd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(7,a|0,b|0,c|0,d|0)|0}function ye(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(8,a|0,b|0,c|0,d|0)|0}function yf(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(9,a|0,b|0,c|0,d|0)|0}function yg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(10,a|0,b|0,c|0,d|0)|0}function yh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(11,a|0,b|0,c|0,d|0)|0}function yi(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(12,a|0,b|0,c|0,d|0)|0}function yj(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(13,a|0,b|0,c|0,d|0)|0}function yk(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(14,a|0,b|0,c|0,d|0)|0}function yl(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(15,a|0,b|0,c|0,d|0)|0}function ym(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(16,a|0,b|0,c|0,d|0)|0}function yn(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(17,a|0,b|0,c|0,d|0)|0}function yo(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(18,a|0,b|0,c|0,d|0)|0}function yp(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return af(19,a|0,b|0,c|0,d|0)|0}function yq(a,b,c,d,e,f){a=a|0;b=b|0;c=+c;d=+d;e=e|0;f=+f;bu[a&63](b|0,+c,+d,e|0,+f)}function yr(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(0,a|0,+b,+c,d|0,+e)}function ys(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(1,a|0,+b,+c,d|0,+e)}function yt(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(2,a|0,+b,+c,d|0,+e)}function yu(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(3,a|0,+b,+c,d|0,+e)}function yv(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(4,a|0,+b,+c,d|0,+e)}function yw(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(5,a|0,+b,+c,d|0,+e)}function yx(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(6,a|0,+b,+c,d|0,+e)}function yy(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(7,a|0,+b,+c,d|0,+e)}function yz(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(8,a|0,+b,+c,d|0,+e)}function yA(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(9,a|0,+b,+c,d|0,+e)}function yB(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(10,a|0,+b,+c,d|0,+e)}function yC(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(11,a|0,+b,+c,d|0,+e)}function yD(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(12,a|0,+b,+c,d|0,+e)}function yE(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(13,a|0,+b,+c,d|0,+e)}function yF(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(14,a|0,+b,+c,d|0,+e)}function yG(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(15,a|0,+b,+c,d|0,+e)}function yH(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(16,a|0,+b,+c,d|0,+e)}function yI(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(17,a|0,+b,+c,d|0,+e)}function yJ(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(18,a|0,+b,+c,d|0,+e)}function yK(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;af(19,a|0,+b,+c,d|0,+e)}function yL(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;return bv[a&127](b|0,c|0,d|0)|0}function yM(a,b,c){a=a|0;b=b|0;c=c|0;return af(0,a|0,b|0,c|0)|0}function yN(a,b,c){a=a|0;b=b|0;c=c|0;return af(1,a|0,b|0,c|0)|0}function yO(a,b,c){a=a|0;b=b|0;c=c|0;return af(2,a|0,b|0,c|0)|0}function yP(a,b,c){a=a|0;b=b|0;c=c|0;return af(3,a|0,b|0,c|0)|0}function yQ(a,b,c){a=a|0;b=b|0;c=c|0;return af(4,a|0,b|0,c|0)|0}function yR(a,b,c){a=a|0;b=b|0;c=c|0;return af(5,a|0,b|0,c|0)|0}function yS(a,b,c){a=a|0;b=b|0;c=c|0;return af(6,a|0,b|0,c|0)|0}function yT(a,b,c){a=a|0;b=b|0;c=c|0;return af(7,a|0,b|0,c|0)|0}function yU(a,b,c){a=a|0;b=b|0;c=c|0;return af(8,a|0,b|0,c|0)|0}function yV(a,b,c){a=a|0;b=b|0;c=c|0;return af(9,a|0,b|0,c|0)|0}function yW(a,b,c){a=a|0;b=b|0;c=c|0;return af(10,a|0,b|0,c|0)|0}function yX(a,b,c){a=a|0;b=b|0;c=c|0;return af(11,a|0,b|0,c|0)|0}function yY(a,b,c){a=a|0;b=b|0;c=c|0;return af(12,a|0,b|0,c|0)|0}function yZ(a,b,c){a=a|0;b=b|0;c=c|0;return af(13,a|0,b|0,c|0)|0}function y_(a,b,c){a=a|0;b=b|0;c=c|0;return af(14,a|0,b|0,c|0)|0}function y$(a,b,c){a=a|0;b=b|0;c=c|0;return af(15,a|0,b|0,c|0)|0}function y0(a,b,c){a=a|0;b=b|0;c=c|0;return af(16,a|0,b|0,c|0)|0}function y1(a,b,c){a=a|0;b=b|0;c=c|0;return af(17,a|0,b|0,c|0)|0}function y2(a,b,c){a=a|0;b=b|0;c=c|0;return af(18,a|0,b|0,c|0)|0}function y3(a,b,c){a=a|0;b=b|0;c=c|0;return af(19,a|0,b|0,c|0)|0}function y4(a,b,c){a=a|0;b=b|0;c=+c;return+bw[a&127](b|0,+c)}function y5(a,b){a=a|0;b=+b;return+af(0,a|0,+b)}function y6(a,b){a=a|0;b=+b;return+af(1,a|0,+b)}function y7(a,b){a=a|0;b=+b;return+af(2,a|0,+b)}function y8(a,b){a=a|0;b=+b;return+af(3,a|0,+b)}function y9(a,b){a=a|0;b=+b;return+af(4,a|0,+b)}function za(a,b){a=a|0;b=+b;return+af(5,a|0,+b)}function zb(a,b){a=a|0;b=+b;return+af(6,a|0,+b)}function zc(a,b){a=a|0;b=+b;return+af(7,a|0,+b)}function zd(a,b){a=a|0;b=+b;return+af(8,a|0,+b)}function ze(a,b){a=a|0;b=+b;return+af(9,a|0,+b)}function zf(a,b){a=a|0;b=+b;return+af(10,a|0,+b)}function zg(a,b){a=a|0;b=+b;return+af(11,a|0,+b)}function zh(a,b){a=a|0;b=+b;return+af(12,a|0,+b)}function zi(a,b){a=a|0;b=+b;return+af(13,a|0,+b)}function zj(a,b){a=a|0;b=+b;return+af(14,a|0,+b)}function zk(a,b){a=a|0;b=+b;return+af(15,a|0,+b)}function zl(a,b){a=a|0;b=+b;return+af(16,a|0,+b)}function zm(a,b){a=a|0;b=+b;return+af(17,a|0,+b)}function zn(a,b){a=a|0;b=+b;return+af(18,a|0,+b)}function zo(a,b){a=a|0;b=+b;return+af(19,a|0,+b)}function zp(a,b,c,d){a=a|0;b=b|0;c=+c;d=+d;bx[a&63](b|0,+c,+d)}function zq(a,b,c){a=a|0;b=+b;c=+c;af(0,a|0,+b,+c)}function zr(a,b,c){a=a|0;b=+b;c=+c;af(1,a|0,+b,+c)}function zs(a,b,c){a=a|0;b=+b;c=+c;af(2,a|0,+b,+c)}function zt(a,b,c){a=a|0;b=+b;c=+c;af(3,a|0,+b,+c)}function zu(a,b,c){a=a|0;b=+b;c=+c;af(4,a|0,+b,+c)}function zv(a,b,c){a=a|0;b=+b;c=+c;af(5,a|0,+b,+c)}function zw(a,b,c){a=a|0;b=+b;c=+c;af(6,a|0,+b,+c)}function zx(a,b,c){a=a|0;b=+b;c=+c;af(7,a|0,+b,+c)}function zy(a,b,c){a=a|0;b=+b;c=+c;af(8,a|0,+b,+c)}function zz(a,b,c){a=a|0;b=+b;c=+c;af(9,a|0,+b,+c)}function zA(a,b,c){a=a|0;b=+b;c=+c;af(10,a|0,+b,+c)}function zB(a,b,c){a=a|0;b=+b;c=+c;af(11,a|0,+b,+c)}function zC(a,b,c){a=a|0;b=+b;c=+c;af(12,a|0,+b,+c)}function zD(a,b,c){a=a|0;b=+b;c=+c;af(13,a|0,+b,+c)}function zE(a,b,c){a=a|0;b=+b;c=+c;af(14,a|0,+b,+c)}function zF(a,b,c){a=a|0;b=+b;c=+c;af(15,a|0,+b,+c)}function zG(a,b,c){a=a|0;b=+b;c=+c;af(16,a|0,+b,+c)}function zH(a,b,c){a=a|0;b=+b;c=+c;af(17,a|0,+b,+c)}function zI(a,b,c){a=a|0;b=+b;c=+c;af(18,a|0,+b,+c)}function zJ(a,b,c){a=a|0;b=+b;c=+c;af(19,a|0,+b,+c)}function zK(a,b,c,d,e,f,g,h,i){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=h|0;i=+i;by[a&63](b|0,c|0,d|0,e|0,f|0,g|0,h|0,+i)}function zL(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(0,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function zM(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(1,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function zN(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(2,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function zO(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(3,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function zP(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(4,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function zQ(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(5,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function zR(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(6,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function zS(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(7,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function zT(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(8,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function zU(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(9,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function zV(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(10,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function zW(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(11,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function zX(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(12,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function zY(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(13,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function zZ(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(14,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function z_(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(15,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function z$(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(16,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function z0(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(17,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function z1(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(18,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function z2(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;af(19,a|0,b|0,c|0,d|0,e|0,f|0,g|0,+h)}function z3(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=+d;e=+e;bz[a&63](b|0,+c,+d,+e)}function z4(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(0,a|0,+b,+c,+d)}function z5(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(1,a|0,+b,+c,+d)}function z6(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(2,a|0,+b,+c,+d)}function z7(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(3,a|0,+b,+c,+d)}function z8(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(4,a|0,+b,+c,+d)}function z9(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(5,a|0,+b,+c,+d)}function Aa(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(6,a|0,+b,+c,+d)}function Ab(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(7,a|0,+b,+c,+d)}function Ac(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(8,a|0,+b,+c,+d)}function Ad(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(9,a|0,+b,+c,+d)}function Ae(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(10,a|0,+b,+c,+d)}function Af(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(11,a|0,+b,+c,+d)}function Ag(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(12,a|0,+b,+c,+d)}function Ah(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(13,a|0,+b,+c,+d)}function Ai(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(14,a|0,+b,+c,+d)}function Aj(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(15,a|0,+b,+c,+d)}function Ak(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(16,a|0,+b,+c,+d)}function Al(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(17,a|0,+b,+c,+d)}function Am(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(18,a|0,+b,+c,+d)}function An(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;af(19,a|0,+b,+c,+d)}function Ao(a,b,c,d,e,f,g){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;bA[a&63](b|0,c|0,d|0,e|0,f|0,g|0)}function Ap(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(0,a|0,b|0,c|0,d|0,e|0,f|0)}function Aq(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(1,a|0,b|0,c|0,d|0,e|0,f|0)}function Ar(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(2,a|0,b|0,c|0,d|0,e|0,f|0)}function As(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(3,a|0,b|0,c|0,d|0,e|0,f|0)}function At(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(4,a|0,b|0,c|0,d|0,e|0,f|0)}function Au(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(5,a|0,b|0,c|0,d|0,e|0,f|0)}function Av(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(6,a|0,b|0,c|0,d|0,e|0,f|0)}function Aw(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(7,a|0,b|0,c|0,d|0,e|0,f|0)}function Ax(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(8,a|0,b|0,c|0,d|0,e|0,f|0)}function Ay(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(9,a|0,b|0,c|0,d|0,e|0,f|0)}function Az(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(10,a|0,b|0,c|0,d|0,e|0,f|0)}function AA(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(11,a|0,b|0,c|0,d|0,e|0,f|0)}function AB(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(12,a|0,b|0,c|0,d|0,e|0,f|0)}function AC(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(13,a|0,b|0,c|0,d|0,e|0,f|0)}function AD(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(14,a|0,b|0,c|0,d|0,e|0,f|0)}function AE(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(15,a|0,b|0,c|0,d|0,e|0,f|0)}function AF(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(16,a|0,b|0,c|0,d|0,e|0,f|0)}function AG(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(17,a|0,b|0,c|0,d|0,e|0,f|0)}function AH(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(18,a|0,b|0,c|0,d|0,e|0,f|0)}function AI(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;af(19,a|0,b|0,c|0,d|0,e|0,f|0)}function AJ(a,b,c,d){a=a|0;b=b|0;c=c|0;d=+d;return bB[a&63](b|0,c|0,+d)|0}function AK(a,b,c){a=a|0;b=b|0;c=+c;return af(0,a|0,b|0,+c)|0}function AL(a,b,c){a=a|0;b=b|0;c=+c;return af(1,a|0,b|0,+c)|0}function AM(a,b,c){a=a|0;b=b|0;c=+c;return af(2,a|0,b|0,+c)|0}function AN(a,b,c){a=a|0;b=b|0;c=+c;return af(3,a|0,b|0,+c)|0}function AO(a,b,c){a=a|0;b=b|0;c=+c;return af(4,a|0,b|0,+c)|0}function AP(a,b,c){a=a|0;b=b|0;c=+c;return af(5,a|0,b|0,+c)|0}function AQ(a,b,c){a=a|0;b=b|0;c=+c;return af(6,a|0,b|0,+c)|0}function AR(a,b,c){a=a|0;b=b|0;c=+c;return af(7,a|0,b|0,+c)|0}function AS(a,b,c){a=a|0;b=b|0;c=+c;return af(8,a|0,b|0,+c)|0}function AT(a,b,c){a=a|0;b=b|0;c=+c;return af(9,a|0,b|0,+c)|0}function AU(a,b,c){a=a|0;b=b|0;c=+c;return af(10,a|0,b|0,+c)|0}function AV(a,b,c){a=a|0;b=b|0;c=+c;return af(11,a|0,b|0,+c)|0}function AW(a,b,c){a=a|0;b=b|0;c=+c;return af(12,a|0,b|0,+c)|0}function AX(a,b,c){a=a|0;b=b|0;c=+c;return af(13,a|0,b|0,+c)|0}function AY(a,b,c){a=a|0;b=b|0;c=+c;return af(14,a|0,b|0,+c)|0}function AZ(a,b,c){a=a|0;b=b|0;c=+c;return af(15,a|0,b|0,+c)|0}function A_(a,b,c){a=a|0;b=b|0;c=+c;return af(16,a|0,b|0,+c)|0}function A$(a,b,c){a=a|0;b=b|0;c=+c;return af(17,a|0,b|0,+c)|0}function A0(a,b,c){a=a|0;b=b|0;c=+c;return af(18,a|0,b|0,+c)|0}function A1(a,b,c){a=a|0;b=b|0;c=+c;return af(19,a|0,b|0,+c)|0}function A2(a,b,c){a=a|0;b=b|0;c=+c;return bC[a&63](b|0,+c)|0}function A3(a,b){a=a|0;b=+b;return af(0,a|0,+b)|0}function A4(a,b){a=a|0;b=+b;return af(1,a|0,+b)|0}function A5(a,b){a=a|0;b=+b;return af(2,a|0,+b)|0}function A6(a,b){a=a|0;b=+b;return af(3,a|0,+b)|0}function A7(a,b){a=a|0;b=+b;return af(4,a|0,+b)|0}function A8(a,b){a=a|0;b=+b;return af(5,a|0,+b)|0}function A9(a,b){a=a|0;b=+b;return af(6,a|0,+b)|0}function Ba(a,b){a=a|0;b=+b;return af(7,a|0,+b)|0}function Bb(a,b){a=a|0;b=+b;return af(8,a|0,+b)|0}function Bc(a,b){a=a|0;b=+b;return af(9,a|0,+b)|0}function Bd(a,b){a=a|0;b=+b;return af(10,a|0,+b)|0}function Be(a,b){a=a|0;b=+b;return af(11,a|0,+b)|0}function Bf(a,b){a=a|0;b=+b;return af(12,a|0,+b)|0}function Bg(a,b){a=a|0;b=+b;return af(13,a|0,+b)|0}function Bh(a,b){a=a|0;b=+b;return af(14,a|0,+b)|0}function Bi(a,b){a=a|0;b=+b;return af(15,a|0,+b)|0}function Bj(a,b){a=a|0;b=+b;return af(16,a|0,+b)|0}function Bk(a,b){a=a|0;b=+b;return af(17,a|0,+b)|0}function Bl(a,b){a=a|0;b=+b;return af(18,a|0,+b)|0}function Bm(a,b){a=a|0;b=+b;return af(19,a|0,+b)|0}function Bn(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;bD[a&63](b|0,+c,d|0,e|0)}function Bo(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(0,a|0,+b,c|0,d|0)}function Bp(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(1,a|0,+b,c|0,d|0)}function Bq(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(2,a|0,+b,c|0,d|0)}function Br(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(3,a|0,+b,c|0,d|0)}function Bs(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(4,a|0,+b,c|0,d|0)}function Bt(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(5,a|0,+b,c|0,d|0)}function Bu(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(6,a|0,+b,c|0,d|0)}function Bv(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(7,a|0,+b,c|0,d|0)}function Bw(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(8,a|0,+b,c|0,d|0)}function Bx(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(9,a|0,+b,c|0,d|0)}function By(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(10,a|0,+b,c|0,d|0)}function Bz(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(11,a|0,+b,c|0,d|0)}function BA(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(12,a|0,+b,c|0,d|0)}function BB(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(13,a|0,+b,c|0,d|0)}function BC(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(14,a|0,+b,c|0,d|0)}function BD(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(15,a|0,+b,c|0,d|0)}function BE(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(16,a|0,+b,c|0,d|0)}function BF(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(17,a|0,+b,c|0,d|0)}function BG(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(18,a|0,+b,c|0,d|0)}function BH(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;af(19,a|0,+b,c|0,d|0)}function BI(a,b){a=a|0;b=b|0;return+bE[a&511](b|0)}function BJ(a){a=a|0;return+af(0,a|0)}function BK(a){a=a|0;return+af(1,a|0)}function BL(a){a=a|0;return+af(2,a|0)}function BM(a){a=a|0;return+af(3,a|0)}function BN(a){a=a|0;return+af(4,a|0)}function BO(a){a=a|0;return+af(5,a|0)}function BP(a){a=a|0;return+af(6,a|0)}function BQ(a){a=a|0;return+af(7,a|0)}function BR(a){a=a|0;return+af(8,a|0)}function BS(a){a=a|0;return+af(9,a|0)}function BT(a){a=a|0;return+af(10,a|0)}function BU(a){a=a|0;return+af(11,a|0)}function BV(a){a=a|0;return+af(12,a|0)}function BW(a){a=a|0;return+af(13,a|0)}function BX(a){a=a|0;return+af(14,a|0)}function BY(a){a=a|0;return+af(15,a|0)}function BZ(a){a=a|0;return+af(16,a|0)}function B_(a){a=a|0;return+af(17,a|0)}function B$(a){a=a|0;return+af(18,a|0)}function B0(a){a=a|0;return+af(19,a|0)}function B1(a,b,c){a=a|0;b=b|0;c=c|0;return bF[a&255](b|0,c|0)|0}function B2(a,b){a=a|0;b=b|0;return af(0,a|0,b|0)|0}function B3(a,b){a=a|0;b=b|0;return af(1,a|0,b|0)|0}function B4(a,b){a=a|0;b=b|0;return af(2,a|0,b|0)|0}function B5(a,b){a=a|0;b=b|0;return af(3,a|0,b|0)|0}function B6(a,b){a=a|0;b=b|0;return af(4,a|0,b|0)|0}function B7(a,b){a=a|0;b=b|0;return af(5,a|0,b|0)|0}function B8(a,b){a=a|0;b=b|0;return af(6,a|0,b|0)|0}function B9(a,b){a=a|0;b=b|0;return af(7,a|0,b|0)|0}function Ca(a,b){a=a|0;b=b|0;return af(8,a|0,b|0)|0}function Cb(a,b){a=a|0;b=b|0;return af(9,a|0,b|0)|0}function Cc(a,b){a=a|0;b=b|0;return af(10,a|0,b|0)|0}function Cd(a,b){a=a|0;b=b|0;return af(11,a|0,b|0)|0}function Ce(a,b){a=a|0;b=b|0;return af(12,a|0,b|0)|0}function Cf(a,b){a=a|0;b=b|0;return af(13,a|0,b|0)|0}function Cg(a,b){a=a|0;b=b|0;return af(14,a|0,b|0)|0}function Ch(a,b){a=a|0;b=b|0;return af(15,a|0,b|0)|0}function Ci(a,b){a=a|0;b=b|0;return af(16,a|0,b|0)|0}function Cj(a,b){a=a|0;b=b|0;return af(17,a|0,b|0)|0}function Ck(a,b){a=a|0;b=b|0;return af(18,a|0,b|0)|0}function Cl(a,b){a=a|0;b=b|0;return af(19,a|0,b|0)|0}function Cm(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=+f;return+bG[a&63](b|0,c|0,d|0,e|0,+f)}function Cn(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(0,a|0,b|0,c|0,d|0,+e)}function Co(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(1,a|0,b|0,c|0,d|0,+e)}function Cp(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(2,a|0,b|0,c|0,d|0,+e)}function Cq(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(3,a|0,b|0,c|0,d|0,+e)}function Cr(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(4,a|0,b|0,c|0,d|0,+e)}function Cs(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(5,a|0,b|0,c|0,d|0,+e)}function Ct(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(6,a|0,b|0,c|0,d|0,+e)}function Cu(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(7,a|0,b|0,c|0,d|0,+e)}function Cv(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(8,a|0,b|0,c|0,d|0,+e)}function Cw(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(9,a|0,b|0,c|0,d|0,+e)}function Cx(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(10,a|0,b|0,c|0,d|0,+e)}function Cy(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(11,a|0,b|0,c|0,d|0,+e)}function Cz(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(12,a|0,b|0,c|0,d|0,+e)}function CA(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(13,a|0,b|0,c|0,d|0,+e)}function CB(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(14,a|0,b|0,c|0,d|0,+e)}function CC(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(15,a|0,b|0,c|0,d|0,+e)}function CD(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(16,a|0,b|0,c|0,d|0,+e)}function CE(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(17,a|0,b|0,c|0,d|0,+e)}function CF(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(18,a|0,b|0,c|0,d|0,+e)}function CG(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;return+af(19,a|0,b|0,c|0,d|0,+e)}function CH(a){a=a|0;return bH[a&127]()|0}function CI(){return af(0)|0}function CJ(){return af(1)|0}function CK(){return af(2)|0}function CL(){return af(3)|0}function CM(){return af(4)|0}function CN(){return af(5)|0}function CO(){return af(6)|0}function CP(){return af(7)|0}function CQ(){return af(8)|0}function CR(){return af(9)|0}function CS(){return af(10)|0}function CT(){return af(11)|0}function CU(){return af(12)|0}function CV(){return af(13)|0}function CW(){return af(14)|0}function CX(){return af(15)|0}function CY(){return af(16)|0}function CZ(){return af(17)|0}function C_(){return af(18)|0}function C$(){return af(19)|0}function C0(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;return bI[a&127](b|0,c|0,d|0,e|0,f|0)|0}function C1(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(0,a|0,b|0,c|0,d|0,e|0)|0}function C2(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(1,a|0,b|0,c|0,d|0,e|0)|0}function C3(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(2,a|0,b|0,c|0,d|0,e|0)|0}function C4(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(3,a|0,b|0,c|0,d|0,e|0)|0}function C5(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(4,a|0,b|0,c|0,d|0,e|0)|0}function C6(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(5,a|0,b|0,c|0,d|0,e|0)|0}function C7(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(6,a|0,b|0,c|0,d|0,e|0)|0}function C8(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(7,a|0,b|0,c|0,d|0,e|0)|0}function C9(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(8,a|0,b|0,c|0,d|0,e|0)|0}function Da(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(9,a|0,b|0,c|0,d|0,e|0)|0}function Db(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(10,a|0,b|0,c|0,d|0,e|0)|0}function Dc(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(11,a|0,b|0,c|0,d|0,e|0)|0}function Dd(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(12,a|0,b|0,c|0,d|0,e|0)|0}function De(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(13,a|0,b|0,c|0,d|0,e|0)|0}function Df(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(14,a|0,b|0,c|0,d|0,e|0)|0}function Dg(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(15,a|0,b|0,c|0,d|0,e|0)|0}function Dh(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(16,a|0,b|0,c|0,d|0,e|0)|0}function Di(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(17,a|0,b|0,c|0,d|0,e|0)|0}function Dj(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(18,a|0,b|0,c|0,d|0,e|0)|0}function Dk(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;return af(19,a|0,b|0,c|0,d|0,e|0)|0}function Dl(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;return bJ[a&63](+b,+c,+d)|0}function Dm(a,b,c){a=+a;b=+b;c=+c;return af(0,+a,+b,+c)|0}function Dn(a,b,c){a=+a;b=+b;c=+c;return af(1,+a,+b,+c)|0}function Do(a,b,c){a=+a;b=+b;c=+c;return af(2,+a,+b,+c)|0}function Dp(a,b,c){a=+a;b=+b;c=+c;return af(3,+a,+b,+c)|0}function Dq(a,b,c){a=+a;b=+b;c=+c;return af(4,+a,+b,+c)|0}function Dr(a,b,c){a=+a;b=+b;c=+c;return af(5,+a,+b,+c)|0}function Ds(a,b,c){a=+a;b=+b;c=+c;return af(6,+a,+b,+c)|0}function Dt(a,b,c){a=+a;b=+b;c=+c;return af(7,+a,+b,+c)|0}function Du(a,b,c){a=+a;b=+b;c=+c;return af(8,+a,+b,+c)|0}function Dv(a,b,c){a=+a;b=+b;c=+c;return af(9,+a,+b,+c)|0}function Dw(a,b,c){a=+a;b=+b;c=+c;return af(10,+a,+b,+c)|0}function Dx(a,b,c){a=+a;b=+b;c=+c;return af(11,+a,+b,+c)|0}function Dy(a,b,c){a=+a;b=+b;c=+c;return af(12,+a,+b,+c)|0}function Dz(a,b,c){a=+a;b=+b;c=+c;return af(13,+a,+b,+c)|0}function DA(a,b,c){a=+a;b=+b;c=+c;return af(14,+a,+b,+c)|0}function DB(a,b,c){a=+a;b=+b;c=+c;return af(15,+a,+b,+c)|0}function DC(a,b,c){a=+a;b=+b;c=+c;return af(16,+a,+b,+c)|0}function DD(a,b,c){a=+a;b=+b;c=+c;return af(17,+a,+b,+c)|0}function DE(a,b,c){a=+a;b=+b;c=+c;return af(18,+a,+b,+c)|0}function DF(a,b,c){a=+a;b=+b;c=+c;return af(19,+a,+b,+c)|0}function DG(a,b,c){a=a|0;b=+b;c=+c;return bK[a&63](+b,+c)|0}function DH(a,b){a=+a;b=+b;return af(0,+a,+b)|0}function DI(a,b){a=+a;b=+b;return af(1,+a,+b)|0}function DJ(a,b){a=+a;b=+b;return af(2,+a,+b)|0}function DK(a,b){a=+a;b=+b;return af(3,+a,+b)|0}function DL(a,b){a=+a;b=+b;return af(4,+a,+b)|0}function DM(a,b){a=+a;b=+b;return af(5,+a,+b)|0}function DN(a,b){a=+a;b=+b;return af(6,+a,+b)|0}function DO(a,b){a=+a;b=+b;return af(7,+a,+b)|0}function DP(a,b){a=+a;b=+b;return af(8,+a,+b)|0}function DQ(a,b){a=+a;b=+b;return af(9,+a,+b)|0}function DR(a,b){a=+a;b=+b;return af(10,+a,+b)|0}function DS(a,b){a=+a;b=+b;return af(11,+a,+b)|0}function DT(a,b){a=+a;b=+b;return af(12,+a,+b)|0}function DU(a,b){a=+a;b=+b;return af(13,+a,+b)|0}function DV(a,b){a=+a;b=+b;return af(14,+a,+b)|0}function DW(a,b){a=+a;b=+b;return af(15,+a,+b)|0}function DX(a,b){a=+a;b=+b;return af(16,+a,+b)|0}function DY(a,b){a=+a;b=+b;return af(17,+a,+b)|0}function DZ(a,b){a=+a;b=+b;return af(18,+a,+b)|0}function D_(a,b){a=+a;b=+b;return af(19,+a,+b)|0}function D$(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;bL[a&127](b|0,c|0,d|0)}function D0(a,b,c){a=a|0;b=b|0;c=c|0;af(0,a|0,b|0,c|0)}function D1(a,b,c){a=a|0;b=b|0;c=c|0;af(1,a|0,b|0,c|0)}function D2(a,b,c){a=a|0;b=b|0;c=c|0;af(2,a|0,b|0,c|0)}function D3(a,b,c){a=a|0;b=b|0;c=c|0;af(3,a|0,b|0,c|0)}function D4(a,b,c){a=a|0;b=b|0;c=c|0;af(4,a|0,b|0,c|0)}function D5(a,b,c){a=a|0;b=b|0;c=c|0;af(5,a|0,b|0,c|0)}function D6(a,b,c){a=a|0;b=b|0;c=c|0;af(6,a|0,b|0,c|0)}function D7(a,b,c){a=a|0;b=b|0;c=c|0;af(7,a|0,b|0,c|0)}function D8(a,b,c){a=a|0;b=b|0;c=c|0;af(8,a|0,b|0,c|0)}function D9(a,b,c){a=a|0;b=b|0;c=c|0;af(9,a|0,b|0,c|0)}function Ea(a,b,c){a=a|0;b=b|0;c=c|0;af(10,a|0,b|0,c|0)}function Eb(a,b,c){a=a|0;b=b|0;c=c|0;af(11,a|0,b|0,c|0)}function Ec(a,b,c){a=a|0;b=b|0;c=c|0;af(12,a|0,b|0,c|0)}function Ed(a,b,c){a=a|0;b=b|0;c=c|0;af(13,a|0,b|0,c|0)}function Ee(a,b,c){a=a|0;b=b|0;c=c|0;af(14,a|0,b|0,c|0)}function Ef(a,b,c){a=a|0;b=b|0;c=c|0;af(15,a|0,b|0,c|0)}function Eg(a,b,c){a=a|0;b=b|0;c=c|0;af(16,a|0,b|0,c|0)}function Eh(a,b,c){a=a|0;b=b|0;c=c|0;af(17,a|0,b|0,c|0)}function Ei(a,b,c){a=a|0;b=b|0;c=c|0;af(18,a|0,b|0,c|0)}function Ej(a,b,c){a=a|0;b=b|0;c=c|0;af(19,a|0,b|0,c|0)}function Ek(a){a=a|0;bM[a&63]()}function El(){af(0)}function Em(){af(1)}function En(){af(2)}function Eo(){af(3)}function Ep(){af(4)}function Eq(){af(5)}function Er(){af(6)}function Es(){af(7)}function Et(){af(8)}function Eu(){af(9)}function Ev(){af(10)}function Ew(){af(11)}function Ex(){af(12)}function Ey(){af(13)}function Ez(){af(14)}function EA(){af(15)}function EB(){af(16)}function EC(){af(17)}function ED(){af(18)}function EE(){af(19)}function EF(a,b,c,d){a=a|0;b=b|0;c=c|0;d=+d;bN[a&127](b|0,c|0,+d)}function EG(a,b,c){a=a|0;b=b|0;c=+c;af(0,a|0,b|0,+c)}function EH(a,b,c){a=a|0;b=b|0;c=+c;af(1,a|0,b|0,+c)}function EI(a,b,c){a=a|0;b=b|0;c=+c;af(2,a|0,b|0,+c)}function EJ(a,b,c){a=a|0;b=b|0;c=+c;af(3,a|0,b|0,+c)}function EK(a,b,c){a=a|0;b=b|0;c=+c;af(4,a|0,b|0,+c)}function EL(a,b,c){a=a|0;b=b|0;c=+c;af(5,a|0,b|0,+c)}function EM(a,b,c){a=a|0;b=b|0;c=+c;af(6,a|0,b|0,+c)}function EN(a,b,c){a=a|0;b=b|0;c=+c;af(7,a|0,b|0,+c)}function EO(a,b,c){a=a|0;b=b|0;c=+c;af(8,a|0,b|0,+c)}function EP(a,b,c){a=a|0;b=b|0;c=+c;af(9,a|0,b|0,+c)}function EQ(a,b,c){a=a|0;b=b|0;c=+c;af(10,a|0,b|0,+c)}function ER(a,b,c){a=a|0;b=b|0;c=+c;af(11,a|0,b|0,+c)}function ES(a,b,c){a=a|0;b=b|0;c=+c;af(12,a|0,b|0,+c)}function ET(a,b,c){a=a|0;b=b|0;c=+c;af(13,a|0,b|0,+c)}function EU(a,b,c){a=a|0;b=b|0;c=+c;af(14,a|0,b|0,+c)}function EV(a,b,c){a=a|0;b=b|0;c=+c;af(15,a|0,b|0,+c)}function EW(a,b,c){a=a|0;b=b|0;c=+c;af(16,a|0,b|0,+c)}function EX(a,b,c){a=a|0;b=b|0;c=+c;af(17,a|0,b|0,+c)}function EY(a,b,c){a=a|0;b=b|0;c=+c;af(18,a|0,b|0,+c)}function EZ(a,b,c){a=a|0;b=b|0;c=+c;af(19,a|0,b|0,+c)}function E_(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;bO[a&127](b|0,c|0,d|0,e|0)}function E$(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(0,a|0,b|0,c|0,d|0)}function E0(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(1,a|0,b|0,c|0,d|0)}function E1(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(2,a|0,b|0,c|0,d|0)}function E2(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(3,a|0,b|0,c|0,d|0)}function E3(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(4,a|0,b|0,c|0,d|0)}function E4(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(5,a|0,b|0,c|0,d|0)}function E5(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(6,a|0,b|0,c|0,d|0)}function E6(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(7,a|0,b|0,c|0,d|0)}function E7(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(8,a|0,b|0,c|0,d|0)}function E8(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(9,a|0,b|0,c|0,d|0)}function E9(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(10,a|0,b|0,c|0,d|0)}function Fa(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(11,a|0,b|0,c|0,d|0)}function Fb(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(12,a|0,b|0,c|0,d|0)}function Fc(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(13,a|0,b|0,c|0,d|0)}function Fd(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(14,a|0,b|0,c|0,d|0)}function Fe(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(15,a|0,b|0,c|0,d|0)}function Ff(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(16,a|0,b|0,c|0,d|0)}function Fg(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(17,a|0,b|0,c|0,d|0)}function Fh(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(18,a|0,b|0,c|0,d|0)}function Fi(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;af(19,a|0,b|0,c|0,d|0)}function Fj(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;aa(0)}function Fk(a,b){a=a|0;b=+b;aa(1)}function Fl(a,b,c,d,e){a=a|0;b=b|0;c=+c;d=d|0;e=e|0;aa(2)}function Fm(a){a=a|0;aa(3)}function Fn(a,b){a=a|0;b=b|0;aa(4)}function Fo(a){a=a|0;aa(5);return 0}function Fp(a,b,c,d){a=a|0;b=b|0;c=+c;d=d|0;aa(6)}function Fq(a){a=+a;aa(7);return 0}function Fr(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;aa(8);return 0}function Fs(a,b,c,d,e){a=a|0;b=+b;c=+c;d=d|0;e=+e;aa(9)}function Ft(a,b,c){a=a|0;b=b|0;c=c|0;aa(10);return 0}function Fu(a,b){a=a|0;b=+b;aa(11);return 0.0}function Fv(a,b,c){a=a|0;b=+b;c=+c;aa(12)}function Fw(a,b,c,d,e,f,g,h){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;g=g|0;h=+h;aa(13)}function Fx(a,b,c,d){a=a|0;b=+b;c=+c;d=+d;aa(14)}function Fy(a,b,c,d,e,f){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;f=f|0;aa(15)}function Fz(a,b,c){a=a|0;b=b|0;c=+c;aa(16);return 0}function FA(a,b){a=a|0;b=+b;aa(17);return 0}function FB(a,b,c,d){a=a|0;b=+b;c=c|0;d=d|0;aa(18)}function FC(a){a=a|0;aa(19);return 0.0}function FD(a,b){a=a|0;b=b|0;aa(20);return 0}function FE(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=+e;aa(21);return 0.0}function FF(){aa(22);return 0}function FG(a,b,c,d,e){a=a|0;b=b|0;c=c|0;d=d|0;e=e|0;aa(23);return 0}function FH(a,b,c){a=+a;b=+b;c=+c;aa(24);return 0}function FI(a,b){a=+a;b=+b;aa(25);return 0}function FJ(a,b,c){a=a|0;b=b|0;c=c|0;aa(26)}function FK(){aa(27)}function FL(a,b,c){a=a|0;b=b|0;c=+c;aa(28)}function FM(a,b,c,d){a=a|0;b=b|0;c=c|0;d=d|0;aa(29)} +// EMSCRIPTEN_END_FUNCS +var bl=[Fj,Fj,vu,Fj,vv,Fj,vw,Fj,vx,Fj,vy,Fj,vz,Fj,vA,Fj,vB,Fj,vC,Fj,vD,Fj,vE,Fj,vF,Fj,vG,Fj,vH,Fj,vI,Fj,vJ,Fj,vK,Fj,vL,Fj,vM,Fj,vN,Fj,rE,Fj,u$,Fj,ve,Fj,u_,Fj,q9,Fj,Fj,Fj,Fj,Fj,Fj,Fj,Fj,Fj,Fj,Fj,Fj,Fj];var bm=[Fk,Fk,vP,Fk,vQ,Fk,vR,Fk,vS,Fk,vT,Fk,vU,Fk,vV,Fk,vW,Fk,vX,Fk,vY,Fk,vZ,Fk,v_,Fk,v$,Fk,v0,Fk,v1,Fk,v2,Fk,v3,Fk,v4,Fk,v5,Fk,v6,Fk,gY,Fk,t$,Fk,rz,Fk,q5,Fk,i2,Fk,jY,Fk,ny,Fk,gT,Fk,qc,Fk,ra,Fk,s0,Fk,rs,Fk,qj,Fk,hu,Fk,ss,Fk,jM,Fk,nl,Fk,rj,Fk,hG,Fk,oj,Fk,qz,Fk,pv,Fk,np,Fk,hw,Fk,rl,Fk,pg,Fk,qA,Fk,qm,Fk,sh,Fk,m0,Fk,pf,Fk,pS,Fk,nb,Fk,rV,Fk,r6,Fk,sz,Fk,tK,Fk,ry,Fk,sc,Fk,i$,Fk,nz,Fk,rA,Fk,tF,Fk,p6,Fk,t_,Fk,nt,Fk,j2,Fk,pO,Fk,ll,Fk,jC,Fk,rX,Fk,p$,Fk,uz,Fk,tQ,Fk,s2,Fk,nL,Fk,tA,Fk,qe,Fk,tv,Fk,gH,Fk,st,Fk,p2,Fk,gW,Fk,ld,Fk,s5,Fk,oF,Fk,gS,Fk,uY,Fk,rd,Fk,qF,Fk,r$,Fk,ml,Fk,l5,Fk,hk,Fk,oz,Fk,rG,Fk,tx,Fk,jQ,Fk,py,Fk,pW,Fk,pK,Fk,k2,Fk,lX,Fk,to,Fk,lM,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk,Fk];var bn=[Fl,Fl,v8,Fl,v9,Fl,wa,Fl,wb,Fl,wc,Fl,wd,Fl,we,Fl,wf,Fl,wg,Fl,wh,Fl,wi,Fl,wj,Fl,wk,Fl,wl,Fl,wm,Fl,wn,Fl,wo,Fl,wp,Fl,wq,Fl,wr,Fl,c3,Fl,kD,Fl,Fl,Fl,Fl,Fl,Fl,Fl,Fl,Fl,Fl,Fl,Fl,Fl,Fl,Fl,Fl,Fl,Fl,Fl];var bo=[Fm,Fm,wt,Fm,wu,Fm,wv,Fm,ww,Fm,wx,Fm,wy,Fm,wz,Fm,wA,Fm,wB,Fm,wC,Fm,wD,Fm,wE,Fm,wF,Fm,wG,Fm,wH,Fm,wI,Fm,wJ,Fm,wK,Fm,wL,Fm,wM,Fm,go,Fm,nP,Fm,jq,Fm,fj,Fm,mN,Fm,lD,Fm,fW,Fm,cU,Fm,eV,Fm,u0,Fm,ee,Fm,fg,Fm,u6,Fm,f1,Fm,pb,Fm,ih,Fm,eu,Fm,fG,Fm,vj,Fm,cD,Fm,lx,Fm,jm,Fm,sG,Fm,lA,Fm,qR,Fm,o0,Fm,eR,Fm,fL,Fm,fS,Fm,lI,Fm,u8,Fm,e4,Fm,rt,Fm,cy,Fm,dl,Fm,eB,Fm,cR,Fm,g8,Fm,lr,Fm,um,Fm,mv,Fm,hY,Fm,ls,Fm,ge,Fm,ur,Fm,qI,Fm,d5,Fm,fA,Fm,h5,Fm,cF,Fm,mu,Fm,nr,Fm,sE,Fm,iH,Fm,ly,Fm,dG,Fm,t1,Fm,he,Fm,gl,Fm,e5,Fm,nZ,Fm,mO,Fm,fH,Fm,c$,Fm,qb,Fm,sx,Fm,ez,Fm,ua,Fm,hf,Fm,c_,Fm,dm,Fm,ei,Fm,lS,Fm,mL,Fm,et,Fm,pi,Fm,g3,Fm,mB,Fm,kx,Fm,qW,Fm,h_,Fm,qi,Fm,n6,Fm,ff,Fm,fh,Fm,mT,Fm,qQ,Fm,mq,Fm,h4,Fm,c9,Fm,je,Fm,va,Fm,mp,Fm,ex,Fm,u7,Fm,kA,Fm,ed,Fm,d_,Fm,gc,Fm,s_,Fm,t7,Fm,u4,Fm,pe,Fm,ia,Fm,d1,Fm,eg,Fm,da,Fm,d3,Fm,kk,Fm,vm,Fm,fT,Fm,cx,Fm,qL,Fm,t3,Fm,jl,Fm,og,Fm,g7,Fm,fi,Fm,mQ,Fm,ug,Fm,o5,Fm,h7,Fm,f5,Fm,uq,Fm,us,Fm,ft,Fm,kK,Fm,d$,Fm,ud,Fm,eZ,Fm,eJ,Fm,gk,Fm,eU,Fm,uo,Fm,jr,Fm,e9,Fm,lJ,Fm,ky,Fm,sy,Fm,g2,Fm,sI,Fm,qX,Fm,es,Fm,ui,Fm,o6,Fm,fn,Fm,u2,Fm,u9,Fm,eL,Fm,gb,Fm,g6,Fm,f2,Fm,uj,Fm,fu,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm,Fm];var bp=[Fn,Fn,wO,Fn,wP,Fn,wQ,Fn,wR,Fn,wS,Fn,wT,Fn,wU,Fn,wV,Fn,wW,Fn,wX,Fn,wY,Fn,wZ,Fn,w_,Fn,w$,Fn,w0,Fn,w1,Fn,w2,Fn,w3,Fn,w4,Fn,w5,Fn,sf,Fn,lU,Fn,i3,Fn,fy,Fn,oU,Fn,qa,Fn,lE,Fn,r1,Fn,rQ,Fn,h$,Fn,hx,Fn,iz,Fn,r2,Fn,sP,Fn,ij,Fn,qC,Fn,gx,Fn,tS,Fn,k4,Fn,fQ,Fn,fB,Fn,eS,Fn,uL,Fn,f7,Fn,tk,Fn,m4,Fn,sO,Fn,iP,Fn,nf,Fn,th,Fn,pH,Fn,uQ,Fn,eE,Fn,pM,Fn,uN,Fn,jW,Fn,f3,Fn,j4,Fn,i9,Fn,q0,Fn,o1,Fn,oe,Fn,fp,Fn,sm,Fn,e2,Fn,uC,Fn,uX,Fn,uK,Fn,pk,Fn,ek,Fn,o_,Fn,fO,Fn,jf,Fn,c5,Fn,ul,Fn,n5,Fn,pc,Fn,gr,Fn,j$,Fn,ec,Fn,f$,Fn,ji,Fn,ir,Fn,hP,Fn,f6,Fn,sL,Fn,gy,Fn,pa,Fn,rm,Fn,tR,Fn,sN,Fn,gd,Fn,mb,Fn,kd,Fn,si,Fn,fN,Fn,fa,Fn,rD,Fn,oX,Fn,gm,Fn,tu,Fn,j6,Fn,pz,Fn,iJ,Fn,sX,Fn,gJ,Fn,gB,Fn,e$,Fn,nM,Fn,rC,Fn,fC,Fn,gf,Fn,mx,Fn,eG,Fn,rP,Fn,uS,Fn,pL,Fn,pV,Fn,iO,Fn,oA,Fn,q7,Fn,qZ,Fn,hn,Fn,gw,Fn,rS,Fn,sR,Fn,ha,Fn,fY,Fn,pG,Fn,fz,Fn,rv,Fn,fw,Fn,q8,Fn,fb,Fn,qv,Fn,hl,Fn,g9,Fn,sg,Fn,ea,Fn,td,Fn,e7,Fn,mc,Fn,uR,Fn,s6,Fn,rU,Fn,pn,Fn,dC,Fn,eX,Fn,sj,Fn,oi,Fn,i5,Fn,o2,Fn,p1,Fn,ps,Fn,e8,Fn,kV,Fn,uk,Fn,tE,Fn,rw,Fn,pr,Fn,f9,Fn,q$,Fn,qt,Fn,lW,Fn,tf,Fn,j5,Fn,ks,Fn,fq,Fn,o$,Fn,oV,Fn,rR,Fn,iF,Fn,tC,Fn,oO,Fn,iy,Fn,tM,Fn,my,Fn,se,Fn,pR,Fn,ux,Fn,e_,Fn,e3,Fn,ma,Fn,fX,Fn,fU,Fn,l9,Fn,hh,Fn,eO,Fn,tB,Fn,fs,Fn,jc,Fn,uF,Fn,eI,Fn,gp,Fn,m5,Fn,ix,Fn,qw,Fn,mn,Fn,hW,Fn,dB,Fn,uw,Fn,uy,Fn,hE,Fn,uI,Fn,pP,Fn,rn,Fn,pq,Fn,rp,Fn,rZ,Fn,fV,Fn,uE,Fn,jG,Fn,iT,Fn,l_,Fn,tZ,Fn,tP,Fn,sn,Fn,fM,Fn,nA,Fn,gg,Fn,nJ,Fn,nF,Fn,gz,Fn,tn,Fn,sU,Fn,kB,Fn,eM,Fn,pU,Fn,sd,Fn,tJ,Fn,eN,Fn,sW,Fn,iS,Fn,gq,Fn,q4,Fn,qs,Fn,qh,Fn,tm,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn,Fn];var bq=[Fo,Fo,w7,Fo,w8,Fo,w9,Fo,xa,Fo,xb,Fo,xc,Fo,xd,Fo,xe,Fo,xf,Fo,xg,Fo,xh,Fo,xi,Fo,xj,Fo,xk,Fo,xl,Fo,xm,Fo,xn,Fo,xo,Fo,xp,Fo,xq,Fo,qn,Fo,gK,Fo,hF,Fo,sT,Fo,jx,Fo,lk,Fo,kf,Fo,hQ,Fo,r7,Fo,rf,Fo,iG,Fo,k6,Fo,r8,Fo,iE,Fo,hR,Fo,iN,Fo,iZ,Fo,p8,Fo,pZ,Fo,jI,Fo,g_,Fo,mm,Fo,iK,Fo,iI,Fo,gI,Fo,tH,Fo,iU,Fo,nx,Fo,pl,Fo,pI,Fo,ho,Fo,pQ,Fo,oJ,Fo,iL,Fo,lF,Fo,q2,Fo,pF,Fo,id,Fo,iV,Fo,gL,Fo,mk,Fo,oT,Fo,lt,Fo,gu,Fo,gG,Fo,qd,Fo,i0,Fo,uV,Fo,no,Fo,qy,Fo,r4,Fo,op,Fo,j9,Fo,oS,Fo,sV,Fo,ht,Fo,gC,Fo,nq,Fo,lQ,Fo,le,Fo,lG,Fo,m8,Fo,iM,Fo,uG,Fo,qq,Fo,qD,Fo,jK,Fo,tg,Fo,oL,Fo,lq,Fo,rL,Fo,nW,Fo,j8,Fo,lL,Fo,h2,Fo,nG,Fo,p7,Fo,sp,Fo,hs,Fo,kR,Fo,hH,Fo,o3,Fo,nn,Fo,gX,Fo,mi,Fo,iA,Fo,jB,Fo,kY,Fo,j7,Fo,ms,Fo,j3,Fo,mU,Fo,oh,Fo,oP,Fo,kc,Fo,mf,Fo,mR,Fo,k7,Fo,lj,Fo,hy,Fo,m_,Fo,ox,Fo,jN,Fo,kg,Fo,hJ,Fo,nu,Fo,nH,Fo,gE,Fo,hO,Fo,mj,Fo,rr,Fo,gv,Fo,m6,Fo,mh,Fo,kS,Fo,kt,Fo,ph,Fo,i7,Fo,hp,Fo,tU,Fo,rJ,Fo,p_,Fo,lP,Fo,uH,Fo,hq,Fo,m9,Fo,i4,Fo,pu,Fo,k3,Fo,ni,Fo,p0,Fo,o7,Fo,m$,Fo,m7,Fo,iX,Fo,hI,Fo,iQ,Fo,iu,Fo,iW,Fo,jy,Fo,h8,Fo,pE,Fo,ta,Fo,gQ,Fo,pw,Fo,cw,Fo,gD,Fo,ku,Fo,n2,Fo,hj,Fo,l7,Fo,hL,Fo,lV,Fo,ot,Fo,ke,Fo,hA,Fo,ne,Fo,cI,Fo,rH,Fo,lm,Fo,iC,Fo,hD,Fo,lc,Fo,ka,Fo,hv,Fo,sS,Fo,kU,Fo,iB,Fo,nj,Fo,la,Fo,tr,Fo,i_,Fo,gZ,Fo,nm,Fo,k0,Fo,q6,Fo,lR,Fo,lY,Fo,jA,Fo,jJ,Fo,sM,Fo,iR,Fo,vk,Fo,jP,Fo,l1,Fo,tb,Fo,uT,Fo,lf,Fo,hV,Fo,kj,Fo,k1,Fo,kL,Fo,iw,Fo,nk,Fo,rq,Fo,mg,Fo,ip,Fo,s9,Fo,qG,Fo,tp,Fo,k_,Fo,it,Fo,s7,Fo,oq,Fo,jL,Fo,sQ,Fo,l8,Fo,jn,Fo,k5,Fo,rB,Fo,kJ,Fo,kv,Fo,gR,Fo,kb,Fo,l3,Fo,ju,Fo,oG,Fo,hc,Fo,g0,Fo,uM,Fo,rW,Fo,uJ,Fo,lg,Fo,lh,Fo,oB,Fo,md,Fo,kO,Fo,ol,Fo,jo,Fo,hb,Fo,jU,Fo,gF,Fo,gM,Fo,l4,Fo,kW,Fo,jZ,Fo,jH,Fo,pD,Fo,h0,Fo,sq,Fo,om,Fo,sY,Fo,kh,Fo,ow,Fo,oM,Fo,kX,Fo,rc,Fo,nC,Fo,tW,Fo,hK,Fo,sk,Fo,jR,Fo,uB,Fo,ok,Fo,h1,Fo,iv,Fo,oN,Fo,oW,Fo,qu,Fo,pJ,Fo,qp,Fo,gU,Fo,oI,Fo,js,Fo,sl,Fo,nI,Fo,hU,Fo,oE,Fo,hM,Fo,cG,Fo,cE,Fo,hN,Fo,nw,Fo,oK,Fo,kN,Fo,ig,Fo,sZ,Fo,uv,Fo,oQ,Fo,oc,Fo,kT,Fo,mI,Fo,j1,Fo,pm,Fo,iD,Fo,kp,Fo,qk,Fo,gA,Fo,jg,Fo,nd,Fo,re,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo,Fo];var br=[Fp,Fp,xs,Fp,xt,Fp,xu,Fp,xv,Fp,xw,Fp,xx,Fp,xy,Fp,xz,Fp,xA,Fp,xB,Fp,xC,Fp,xD,Fp,xE,Fp,xF,Fp,xG,Fp,xH,Fp,xI,Fp,xJ,Fp,xK,Fp,xL,Fp,kF,Fp,c2,Fp,Fp,Fp,Fp,Fp,Fp,Fp,Fp,Fp,Fp,Fp,Fp,Fp,Fp,Fp,Fp,Fp,Fp,Fp];var bs=[Fq,Fq,xN,Fq,xO,Fq,xP,Fq,xQ,Fq,xR,Fq,xS,Fq,xT,Fq,xU,Fq,xV,Fq,xW,Fq,xX,Fq,xY,Fq,xZ,Fq,x_,Fq,x$,Fq,x0,Fq,x1,Fq,x2,Fq,x3,Fq,x4,Fq,sC,Fq,Fq,Fq,Fq,Fq,Fq,Fq,Fq,Fq,Fq,Fq,Fq,Fq,Fq,Fq,Fq,Fq,Fq,Fq,Fq,Fq];var bt=[Fr,Fr,x6,Fr,x7,Fr,x8,Fr,x9,Fr,ya,Fr,yb,Fr,yc,Fr,yd,Fr,ye,Fr,yf,Fr,yg,Fr,yh,Fr,yi,Fr,yj,Fr,yk,Fr,yl,Fr,ym,Fr,yn,Fr,yo,Fr,yp,Fr,hZ,Fr,lC,Fr,Fr,Fr,Fr,Fr,Fr,Fr,Fr,Fr,Fr,Fr,Fr,Fr,Fr,Fr,Fr,Fr,Fr,Fr];var bu=[Fs,Fs,yr,Fs,ys,Fs,yt,Fs,yu,Fs,yv,Fs,yw,Fs,yx,Fs,yy,Fs,yz,Fs,yA,Fs,yB,Fs,yC,Fs,yD,Fs,yE,Fs,yF,Fs,yG,Fs,yH,Fs,yI,Fs,yJ,Fs,yK,Fs,nU,Fs,Fs,Fs,Fs,Fs,Fs,Fs,Fs,Fs,Fs,Fs,Fs,Fs,Fs,Fs,Fs,Fs,Fs,Fs,Fs,Fs];var bv=[Ft,Ft,yM,Ft,yN,Ft,yO,Ft,yP,Ft,yQ,Ft,yR,Ft,yS,Ft,yT,Ft,yU,Ft,yV,Ft,yW,Ft,yX,Ft,yY,Ft,yZ,Ft,y_,Ft,y$,Ft,y0,Ft,y1,Ft,y2,Ft,y3,Ft,lB,Ft,n3,Ft,ik,Ft,nX,Ft,iq,Ft,vb,Ft,cJ,Ft,kq,Ft,d0,Ft,mJ,Ft,od,Ft,c6,Ft,cH,Ft,cC,Ft,uc,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft,Ft];var bw=[Fu,Fu,y5,Fu,y6,Fu,y7,Fu,y8,Fu,y9,Fu,za,Fu,zb,Fu,zc,Fu,zd,Fu,ze,Fu,zf,Fu,zg,Fu,zh,Fu,zi,Fu,zj,Fu,zk,Fu,zl,Fu,zm,Fu,zn,Fu,zo,Fu,jb,Fu,ki,Fu,mS,Fu,gt,Fu,fo,Fu,fd,Fu,h6,Fu,jT,Fu,gi,Fu,h9,Fu,f4,Fu,o4,Fu,f_,Fu,hg,Fu,lp,Fu,kz,Fu,lK,Fu,mr,Fu,fE,Fu,fK,Fu,kP,Fu,e1,Fu,kI,Fu,eK,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu,Fu];var bx=[Fv,Fv,zq,Fv,zr,Fv,zs,Fv,zt,Fv,zu,Fv,zv,Fv,zw,Fv,zx,Fv,zy,Fv,zz,Fv,zA,Fv,zB,Fv,zC,Fv,zD,Fv,zE,Fv,zF,Fv,zG,Fv,zH,Fv,zI,Fv,zJ,Fv,kQ,Fv,mV,Fv,m3,Fv,p3,Fv,Fv,Fv,Fv,Fv,Fv,Fv,Fv,Fv,Fv,Fv,Fv,Fv,Fv,Fv];var by=[Fw,Fw,zL,Fw,zM,Fw,zN,Fw,zO,Fw,zP,Fw,zQ,Fw,zR,Fw,zS,Fw,zT,Fw,zU,Fw,zV,Fw,zW,Fw,zX,Fw,zY,Fw,zZ,Fw,z_,Fw,z$,Fw,z0,Fw,z1,Fw,z2,Fw,sH,Fw,Fw,Fw,Fw,Fw,Fw,Fw,Fw,Fw,Fw,Fw,Fw,Fw,Fw,Fw,Fw,Fw,Fw,Fw,Fw,Fw];var bz=[Fx,Fx,z4,Fx,z5,Fx,z6,Fx,z7,Fx,z8,Fx,z9,Fx,Aa,Fx,Ab,Fx,Ac,Fx,Ad,Fx,Ae,Fx,Af,Fx,Ag,Fx,Ah,Fx,Ai,Fx,Aj,Fx,Ak,Fx,Al,Fx,Am,Fx,An,Fx,qf,Fx,s$,Fx,Fx,Fx,Fx,Fx,Fx,Fx,Fx,Fx,Fx,Fx,Fx,Fx,Fx,Fx,Fx,Fx,Fx,Fx];var bA=[Fy,Fy,Ap,Fy,Aq,Fy,Ar,Fy,As,Fy,At,Fy,Au,Fy,Av,Fy,Aw,Fy,Ax,Fy,Ay,Fy,Az,Fy,AA,Fy,AB,Fy,AC,Fy,AD,Fy,AE,Fy,AF,Fy,AG,Fy,AH,Fy,AI,Fy,vf,Fy,vg,Fy,Fy,Fy,Fy,Fy,Fy,Fy,Fy,Fy,Fy,Fy,Fy,Fy,Fy,Fy,Fy,Fy,Fy,Fy];var bB=[Fz,Fz,AK,Fz,AL,Fz,AM,Fz,AN,Fz,AO,Fz,AP,Fz,AQ,Fz,AR,Fz,AS,Fz,AT,Fz,AU,Fz,AV,Fz,AW,Fz,AX,Fz,AY,Fz,AZ,Fz,A_,Fz,A$,Fz,A0,Fz,A1,Fz,oZ,Fz,Fz,Fz,Fz,Fz,Fz,Fz,Fz,Fz,Fz,Fz,Fz,Fz,Fz,Fz,Fz,Fz,Fz,Fz,Fz,Fz];var bC=[FA,FA,A3,FA,A4,FA,A5,FA,A6,FA,A7,FA,A8,FA,A9,FA,Ba,FA,Bb,FA,Bc,FA,Bd,FA,Be,FA,Bf,FA,Bg,FA,Bh,FA,Bi,FA,Bj,FA,Bk,FA,Bl,FA,Bm,FA,kw,FA,kM,FA,jp,FA,mo,FA,nO,FA,h3,FA,lH,FA,ie,FA,o8,FA,hd,FA,lu,FA];var bD=[FB,FB,Bo,FB,Bp,FB,Bq,FB,Br,FB,Bs,FB,Bt,FB,Bu,FB,Bv,FB,Bw,FB,Bx,FB,By,FB,Bz,FB,BA,FB,BB,FB,BC,FB,BD,FB,BE,FB,BF,FB,BG,FB,BH,FB,jh,FB,FB,FB,FB,FB,FB,FB,FB,FB,FB,FB,FB,FB,FB,FB,FB,FB,FB,FB,FB,FB];var bE=[FC,FC,BJ,FC,BK,FC,BL,FC,BM,FC,BN,FC,BO,FC,BP,FC,BQ,FC,BR,FC,BS,FC,BT,FC,BU,FC,BV,FC,BW,FC,BX,FC,BY,FC,BZ,FC,B_,FC,B$,FC,B0,FC,jO,FC,l0,FC,k8,FC,ov,FC,gP,FC,p5,FC,nc,FC,oC,FC,tL,FC,lZ,FC,tG,FC,hC,FC,m1,FC,pB,FC,pC,FC,jw,FC,pT,FC,nK,FC,jX,FC,tY,FC,iY,FC,j_,FC,tq,FC,ro,FC,l$,FC,rk,FC,nB,FC,g$,FC,ql,FC,uD,FC,r5,FC,rI,FC,jS,FC,ln,FC,qg,FC,qB,FC,rx,FC,on,FC,oD,FC,gO,FC,l6,FC,tT,FC,tD,FC,qM,FC,oH,FC,hz,FC,rF,FC,nv,FC,tV,FC,sJ,FC,lb,FC,qE,FC,qP,FC,hT,FC,rM,FC,hB,FC,ng,FC,sK,FC,ns,FC,gN,FC,s3,FC,li,FC,pt,FC,sA,FC,gV,FC,s1,FC,jD,FC,r_,FC,p9,FC,qx,FC,k$,FC,ru,FC,q3,FC,nh,FC,hS,FC,lT,FC,tl,FC,me,FC,is,FC,uU,FC,oR,FC,tc,FC,l2,FC,i8,FC,s4,FC,r0,FC,jz,FC,hr,FC,k9,FC,q1,FC,ic,FC,i1,FC,pY,FC,jV,FC,tt,FC,rT,FC,rb,FC,p4,FC,j0,FC,i6,FC,lo,FC,kZ,FC,so,FC,rY,FC,pN,FC,pX,FC,ja,FC,ib,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC,FC];var bF=[FD,FD,B2,FD,B3,FD,B4,FD,B5,FD,B6,FD,B7,FD,B8,FD,B9,FD,Ca,FD,Cb,FD,Cc,FD,Cd,FD,Ce,FD,Cf,FD,Cg,FD,Ch,FD,Ci,FD,Cj,FD,Ck,FD,Cl,FD,io,FD,hm,FD,t6,FD,tj,FD,sr,FD,hX,FD,rO,FD,ts,FD,tN,FD,sb,FD,r9,FD,fR,FD,tO,FD,nE,FD,lO,FD,rN,FD,im,FD,jF,FD,qo,FD,uW,FD,cP,FD,m2,FD,ti,FD,fF,FD,su,FD,nS,FD,po,FD,fm,FD,oy,FD,jv,FD,sa,FD,cV,FD,sv,FD,pp,FD,lN,FD,px,FD,uu,FD,km,FD,ri,FD,pj,FD,du,FD,n9,FD,ga,FD,uP,FD,jj,FD,tI,FD,rg,FD,jt,FD,jE,FD,fe,FD,cS,FD,uO,FD,os,FD,g1,FD,mD,FD,eY,FD,rK,FD,nN,FD,uA,FD,oY,FD,cB,FD,ut,FD,ou,FD,f0,FD,qr,FD,or,FD,un,FD,n$,FD,rh,FD,tz,FD,tX,FD,mK,FD,mP,FD,s8,FD,eT,FD,gj,FD,q_,FD,ty,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD,FD];var bG=[FE,FE,Cn,FE,Co,FE,Cp,FE,Cq,FE,Cr,FE,Cs,FE,Ct,FE,Cu,FE,Cv,FE,Cw,FE,Cx,FE,Cy,FE,Cz,FE,CA,FE,CB,FE,CC,FE,CD,FE,CE,FE,CF,FE,CG,FE,lv,FE,up,FE,FE,FE,FE,FE,FE,FE,FE,FE,FE,FE,FE,FE,FE,FE,FE,FE,FE,FE];var bH=[FF,FF,CI,FF,CJ,FF,CK,FF,CL,FF,CM,FF,CN,FF,CO,FF,CP,FF,CQ,FF,CR,FF,CS,FF,CT,FF,CU,FF,CV,FF,CW,FF,CX,FF,CY,FF,CZ,FF,C_,FF,C$,FF,qH,FF,g4,FF,lw,FF,mF,FF,sB,FF,o9,FF,mZ,FF,t5,FF,lz,FF,qY,FF,qJ,FF,ue,FF,kH,FF,ub,FF,sw,FF,kr,FF,qK,FF,ii,FF,pd,FF,mM,FF,t0,FF,hi,FF,uf,FF,mt,FF,t8,FF,qV,FF,nY,FF,sD,FF,u5,FF,n4,FF,qN,FF,sF,FF,mw,FF,uh,FF,u3,FF,qS,FF,t2,FF,u1,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF];var bI=[FG,FG,C1,FG,C2,FG,C3,FG,C4,FG,C5,FG,C6,FG,C7,FG,C8,FG,C9,FG,Da,FG,Db,FG,Dc,FG,Dd,FG,De,FG,Df,FG,Dg,FG,Dh,FG,Di,FG,Dj,FG,Dk,FG,dd,FG,n0,FG,kn,FG,oa,FG,cY,FG,d9,FG,eH,FG,mH,FG,nT,FG,eD,FG,ej,FG,eF,FG,cQ,FG,cT,FG,eW,FG,eb,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG,FG];var bJ=[FH,FH,Dm,FH,Dn,FH,Do,FH,Dp,FH,Dq,FH,Dr,FH,Ds,FH,Dt,FH,Du,FH,Dv,FH,Dw,FH,Dx,FH,Dy,FH,Dz,FH,DA,FH,DB,FH,DC,FH,DD,FH,DE,FH,DF,FH,t9,FH,qT,FH,FH,FH,FH,FH,FH,FH,FH,FH,FH,FH,FH,FH,FH,FH,FH,FH,FH,FH];var bK=[FI,FI,DH,FI,DI,FI,DJ,FI,DK,FI,DL,FI,DM,FI,DN,FI,DO,FI,DP,FI,DQ,FI,DR,FI,DS,FI,DT,FI,DU,FI,DV,FI,DW,FI,DX,FI,DY,FI,DZ,FI,D_,FI,qO,FI,FI,FI,FI,FI,FI,FI,FI,FI,FI,FI,FI,FI,FI,FI,FI,FI,FI,FI,FI,FI];var bL=[FJ,FJ,D0,FJ,D1,FJ,D2,FJ,D3,FJ,D4,FJ,D5,FJ,D6,FJ,D7,FJ,D8,FJ,D9,FJ,Ea,FJ,Eb,FJ,Ec,FJ,Ed,FJ,Ee,FJ,Ef,FJ,Eg,FJ,Eh,FJ,Ei,FJ,Ej,FJ,mz,FJ,mA,FJ,mX,FJ,dD,FJ,mW,FJ,te,FJ,mY,FJ,nQ,FJ,g5,FJ,jd,FJ,mE,FJ,qU,FJ,na,FJ,nD,FJ,dE,FJ,oo,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ,FJ];var bM=[FK,FK,El,FK,Em,FK,En,FK,Eo,FK,Ep,FK,Eq,FK,Er,FK,Es,FK,Et,FK,Eu,FK,Ev,FK,Ew,FK,Ex,FK,Ey,FK,Ez,FK,EA,FK,EB,FK,EC,FK,ED,FK,EE,FK,vs,FK,FK,FK,FK,FK,FK,FK,FK,FK,FK,FK,FK,FK,FK,FK,FK,FK,FK,FK,FK,FK];var bN=[FL,FL,EG,FL,EH,FL,EI,FL,EJ,FL,EK,FL,EL,FL,EM,FL,EN,FL,EO,FL,EP,FL,EQ,FL,ER,FL,ES,FL,ET,FL,EU,FL,EV,FL,EW,FL,EX,FL,EY,FL,EZ,FL,cO,FL,t4,FL,fc,FL,n_,FL,cL,FL,gs,FL,fZ,FL,fr,FL,n8,FL,f8,FL,kl,FL,of,FL,mC,FL,fD,FL,nR,FL,e0,FL,de,FL,gh,FL,eP,FL,fP,FL,cN,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL,FL];var bO=[FM,FM,E$,FM,E0,FM,E1,FM,E2,FM,E3,FM,E4,FM,E5,FM,E6,FM,E7,FM,E8,FM,E9,FM,Fa,FM,Fb,FM,Fc,FM,Fd,FM,Fe,FM,Ff,FM,Fg,FM,Fh,FM,Fi,FM,cK,FM,cM,FM,kC,FM,kE,FM,il,FM,cZ,FM,d2,FM,c0,FM,eA,FM,vc,FM,ey,FM,nV,FM,mG,FM,n1,FM,d4,FM,n7,FM,uZ,FM,ko,FM,tw,FM,ew,FM,c1,FM,c7,FM,c4,FM,ef,FM,eQ,FM,jk,FM,kG,FM,pA,FM,r3,FM,ob,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM,FM];return{_emscripten_bind_b2WheelJoint__GetSpringFrequencyHz_p0:jO,_emscripten_bind_b2Fixture__SetRestitution_p1:gY,_emscripten_bind_b2PolygonShape____destroy___p0:nP,_emscripten_bind_b2RevoluteJoint__EnableLimit_p1:lU,_emscripten_bind_b2DistanceProxy__get_m_vertices_p0:qn,_emscripten_bind_b2PrismaticJoint__EnableLimit_p1:i3,_emscripten_bind_b2WheelJointDef__Initialize_p4:rE,_emscripten_bind_b2DistanceJointDef__set_frequencyHz_p1:t$,_emscripten_bind_b2PrismaticJoint__GetMotorForce_p1:jb,_emscripten_bind_b2Body__IsSleepingAllowed_p0:nx,_emscripten_bind_b2Vec2__b2Vec2_p2:qO,_emscripten_bind_b2RevoluteJoint__GetMaxMotorTorque_p0:l0,_emscripten_bind_b2WeldJoint__GetFrequency_p0:k8,_emscripten_bind_b2MouseJoint__GetType_p0:hF,_emscripten_bind_b2RayCastCallback__b2RayCastCallback_p0:lw,_emscripten_bind_b2Body__GetLinearDamping_p0:ov,_emscripten_bind_b2Vec2__b2Vec2_p0:qN,_emscripten_bind_b2PrismaticJoint__GetType_p0:jx,_emscripten_bind_b2PrismaticJoint____destroy___p0:jq,_emscripten_bind_b2WheelJointDef__set_frequencyHz_p1:rz,_emscripten_bind_b2BlockAllocator____destroy___p0:mN,_emscripten_bind_b2Vec2__op_add_p1:qa,_emscripten_bind_b2World__GetJointList_p0:iD,_emscripten_bind_b2Transform__Set_p2:t4,_emscripten_bind_b2EdgeShape__RayCast_p4:n0,_emscripten_bind_b2RevoluteJoint__GetLocalAnchorA_p0:lk,_emscripten_bind_b2DistanceJoint__GetDampingRatio_p0:gP,_emscripten_bind_b2PulleyJointDef__set_bodyA_p1:sm,_emscripten_bind_b2DynamicTree__Validate_p0:lD,_emscripten_bind_b2DynamicTree__DestroyProxy_p1:lE,_emscripten_bind_b2Joint__IsActive_p0:kf,_emscripten_bind_b2PulleyJoint__GetNext_p0:hQ,_emscripten_bind_b2RevoluteJointDef__get_localAnchorA_p0:r7,_emscripten_bind_b2GearJoint__IsActive_p0:kY,_emscripten_bind_b2EdgeShape__get_m_radius_p0:nc,_emscripten_bind_b2PrismaticJointDef__get_localAnchorB_p0:rf,_emscripten_bind_b2RevoluteJointDef__set_bodyA_p1:r1,_emscripten_bind_b2World__GetJointCount_p0:iG,_emscripten_bind_b2DynamicTree__CreateProxy_p2:lB,_emscripten_bind_b2WheelJointDef__set_collideConnected_p1:rQ,_emscripten_bind_b2WeldJoint__GetLocalAnchorA_p0:k6,_emscripten_bind_b2RevoluteJointDef__get_localAnchorB_p0:r8,_emscripten_bind_b2Body__GetGravityScale_p0:oC,_emscripten_bind_b2Fixture__Dump_p1:h$,_emscripten_bind_b2World__GetBodyList_p0:iE,_emscripten_bind_b2PulleyJoint__IsActive_p0:hR,_emscripten_bind_b2MouseJoint__SetUserData_p1:hx,_emscripten_bind_b2World__GetContactList_p0:iN,_emscripten_bind_b2PrismaticJoint__GetNext_p0:iZ,_emscripten_bind_b2Vec2__Skew_p0:p8,_emscripten_bind_b2BodyDef__get_linearVelocity_p0:pZ,_emscripten_bind_b2Body__GetPosition_p0:oG,_emscripten_bind_b2WheelJoint__GetReactionForce_p1:kw,_emscripten_bind_b2PrismaticJointDef__set_motorSpeed_p1:q5,_emscripten_bind_b2PrismaticJoint__SetMaxMotorForce_p1:i2,_emscripten_bind_b2ChainShape__b2ChainShape_p0:mF,_emscripten_bind_b2CircleShape__RayCast_p4:kn,_emscripten_bind_b2WheelJoint__GetBodyA_p0:jI,_emscripten_bind_b2RevoluteJointDef__set_bodyB_p1:r2,_emscripten_bind_b2MouseJointDef__get_dampingRatio_p0:tL,_emscripten_bind_b2JointDef__set_bodyB_p1:sP,_emscripten_bind_b2RevoluteJoint__GetJointSpeed_p0:lZ,_emscripten_bind_b2RopeJoint__GetLocalAnchorB_p0:mm,_emscripten_bind_b2Fixture__GetAABB_p1:hm,_emscripten_bind_b2BroadPhase__TouchProxy_p1:ij,_emscripten_bind_b2FixtureDef__set_isSensor_p1:qC,_emscripten_bind_b2World__GetAllowSleeping_p0:iK,_emscripten_bind_b2DestructionListener____destroy___p0:pb,_emscripten_bind_b2BroadPhase____destroy___p0:ih,_emscripten_bind_b2World__GetWarmStarting_p0:iI,_emscripten_bind_b2Rot__b2Rot_p1:sC,_emscripten_bind_b2Rot__b2Rot_p0:sB,_emscripten_bind_b2DistanceJoint__GetUserData_p0:gI,_emscripten_bind_b2MouseJointDef__get_frequencyHz_p0:tG,_emscripten_bind_b2ContactManager__set_m_allocator_p1:gx,_emscripten_bind_b2WheelJoint__SetMaxMotorTorque_p1:jY,_emscripten_bind_b2RopeJointDef__get_collideConnected_p1:uW,_emscripten_bind_b2MouseJointDef__get_target_p0:tH,_emscripten_bind_b2WeldJoint__SetUserData_p1:k4,_emscripten_bind_b2PrismaticJoint__GetBodyA_p0:iU,_emscripten_bind_b2FrictionJointDef____destroy___p0:qI,_emscripten_bind_b2RopeJoint__GetMaxLength_p0:me,_emscripten_bind_b2MouseJoint__GetDampingRatio_p0:hC,_emscripten_bind_b2DistanceJoint__GetNext_p0:gK,_emscripten_bind_b2Filter__get_maskBits_p0:pl,_emscripten_bind_b2RayCastCallback____destroy___p0:lx,_emscripten_bind_b2World__Dump_p0:jm,_emscripten_bind_b2RevoluteJointDef____destroy___p0:sG,_emscripten_bind_b2PrismaticJoint__GetAnchorA_p0:jn,_emscripten_bind_b2BodyDef__get_bullet_p0:pI,_emscripten_bind_b2Body__SetAngularDamping_p1:ny,_emscripten_bind_b2DynamicTree__RebuildBottomUp_p0:lA,_emscripten_bind_b2Fixture__GetFilterData_p0:ho,_emscripten_bind_b2DistanceJoint__SetLength_p1:gT,_emscripten_bind_b2BodyDef__get_position_p0:pQ,_emscripten_bind_b2FrictionJoint__GetUserData_p0:oJ,_emscripten_bind_b2PolygonShape__get_m_radius_p0:m1,_emscripten_bind_b2ContactEdge__set_next_p1:uL,_emscripten_bind_b2Transform__b2Transform_p2:t6,_emscripten_bind_b2FrictionJointDef__get_maxTorque_p0:pB,_emscripten_bind_b2WeldJointDef__set_localAnchorB_p1:tk,_emscripten_bind_b2World__GetProxyCount_p0:iL,_emscripten_bind_b2WeldJointDef__get_bodyB_p1:tj,_emscripten_bind_b2PrismaticJointDef__set_lowerTranslation_p1:ra,_emscripten_bind_b2PolygonShape__set_m_centroid_p1:m4,_emscripten_bind_b2GearJoint__GetAnchorA_p0:kO,_emscripten_bind_b2PulleyJointDef__get_collideConnected_p1:sr,_emscripten_bind_b2Vec3____destroy___p0:qR,_emscripten_bind_b2Color__set_r_p1:s0,_emscripten_bind_b2PrismaticJointDef__get_enableMotor_p0:q2,_emscripten_bind_b2BodyDef__get_linearDamping_p0:pC,_emscripten_bind_b2EdgeShape__ComputeMass_p2:n_,_emscripten_bind_b2RayCastCallback__ReportFixture_p4:lv,_emscripten_bind_b2Body__Dump_p0:o0,_emscripten_bind_b2BodyDef__get_allowSleep_p0:pF,_emscripten_bind_b2AABB__get_lowerBound_p0:tg,_emscripten_bind_b2PulleyJoint__GetAnchorB_p0:id,_emscripten_bind_b2PrismaticJoint__GetReactionTorque_p1:ki,_emscripten_bind_b2JointDef__set_bodyA_p1:sO,_emscripten_bind_b2PrismaticJoint__GetBodyB_p0:iV,_emscripten_bind_b2DistanceJoint__GetLocalAnchorA_p0:gL,_emscripten_bind_b2RopeJoint__GetLocalAnchorA_p0:mk,_emscripten_bind_b2Rot__set_c_p1:rs,_emscripten_bind_b2Vec3__op_mul_p1:qj,_emscripten_bind_b2StackAllocator__GetMaxAllocation_p0:oT,_emscripten_bind_b2MouseJoint__SetFrequency_p1:hu,_emscripten_bind_b2WeldJoint__GetAnchorA_p0:lG,_emscripten_bind_b2World__SetAutoClearForces_p1:iP,_emscripten_bind_b2Contact__SetEnabled_p1:nf,_emscripten_bind_b2ContactManager__get_m_contactFilter_p0:gu,_emscripten_bind_b2BodyDef__get_angularDamping_p0:pT,_emscripten_bind_b2WeldJointDef__set_localAnchorA_p1:th,_emscripten_bind_b2DistanceJoint__GetBodyB_p0:gG,_emscripten_bind_b2PulleyJointDef__set_lengthB_p1:ss,_emscripten_bind_b2Vec2__op_sub_p0:qd,_emscripten_bind_b2PrismaticJoint__GetLocalAnchorB_p0:i0,_emscripten_bind_b2RopeJointDef__get_localAnchorB_p0:uV,_emscripten_bind_b2Contact__GetChildIndexB_p0:no,_emscripten_bind_b2Fixture__TestPoint_p1:hX,_emscripten_bind_b2FixtureDef__get_shape_p0:qy,_emscripten_bind_b2WheelJointDef__get_bodyB_p1:rO,_emscripten_bind_b2RevoluteJointDef__get_enableLimit_p0:r4,_emscripten_bind_b2BodyDef__set_linearVelocity_p1:pH,_emscripten_bind_b2Body__GetMass_p0:nK,_emscripten_bind_b2WeldJoint____destroy___p0:lI,_emscripten_bind_b2WheelJoint__GetSpringDampingRatio_p0:jX,_emscripten_bind_b2RopeJointDef__set_localAnchorB_p1:uQ,_emscripten_bind_b2Body__IsFixedRotation_p0:op,_emscripten_bind_b2Rot__SetIdentity_p0:rt,_emscripten_bind_b2WheelJoint__SetSpringDampingRatio_p1:jM,_emscripten_bind_b2Joint__SetUserData_p1:kd,_emscripten_bind_b2FrictionJoint__IsActive_p0:oS,_emscripten_bind_b2JointDef__get_userData_p0:sV,_emscripten_bind_b2Draw__DrawPolygon_p3:kC,_emscripten_bind_b2MouseJoint__GetBodyB_p0:ht,_emscripten_bind_b2DistanceJointDef__get_dampingRatio_p0:tY,_emscripten_bind_b2ContactManager__get_m_broadPhase_p0:gC,_emscripten_bind_b2RopeJoint__GetReactionTorque_p1:mS,_emscripten_bind_b2PrismaticJoint__GetLowerLimit_p0:iY,_emscripten_bind_b2Contact__GetManifold_p0:nq,_emscripten_bind_b2Contact__SetFriction_p1:nl,_emscripten_bind_b2WheelJoint__GetJointSpeed_p0:j_,_emscripten_bind_b2BodyDef__set_allowSleep_p1:pM,_emscripten_bind_b2Fixture__RayCast_p3:hZ,_emscripten_bind_b2WeldJointDef__get_referenceAngle_p0:tq,_emscripten_bind_b2Fixture____destroy___p0:hY,_emscripten_bind_b2RopeJointDef__set_localAnchorA_p1:uN,_emscripten_bind_b2WheelJoint__SetUserData_p1:jW,_emscripten_bind_b2WeldJoint__b2WeldJoint_p1:lQ,_emscripten_bind_b2WeldJoint__IsActive_p0:le,_emscripten_bind_b2Draw__DrawSolidPolygon_p3:kE,_emscripten_bind_b2ContactManager____destroy___p0:g8,_emscripten_bind_b2GearJoint__GetAnchorB_p0:lt,_emscripten_bind_b2PrismaticJointDef__get_lowerTranslation_p0:ro,_emscripten_bind_b2PolygonShape__get_m_vertexCount_p0:m8,_emscripten_bind_b2RevoluteJoint__GetReferenceAngle_p0:l$,_emscripten_bind_b2DistanceJointDef__Initialize_p4:u$,_emscripten_bind_b2World__IsLocked_p0:iM,_emscripten_bind_b2ContactEdge__get_prev_p0:uG,_emscripten_bind_b2Joint__GetReactionForce_p1:kM,_emscripten_bind_b2WeldJointDef__get_collideConnected_p1:ts,_emscripten_bind_b2Draw__AppendFlags_p1:j4,_emscripten_bind_b2PrismaticJointDef__get_maxMotorForce_p0:rk,_emscripten_bind_b2PrismaticJointDef__set_upperTranslation_p1:rj,_emscripten_bind_b2PrismaticJoint__EnableMotor_p1:i9,_emscripten_bind_b2PrismaticJoint__GetReactionForce_p1:jp,_emscripten_bind_b2Shape__RayCast_p4:oa,_emscripten_bind_b2GearJoint__Dump_p0:lr,_emscripten_bind_b2Body__DestroyFixture_p1:o1,_emscripten_bind_b2Body__SetActive_p1:oe,_emscripten_bind_b2PrismaticJoint__GetCollideConnected_p0:i7,_emscripten_bind_b2ContactListener____destroy___p0:mv,_emscripten_bind_b2MouseJoint__SetDampingRatio_p1:hG,_emscripten_bind_b2Body__ApplyTorque_p1:oj,_emscripten_bind_b2DistanceProxy__GetVertexCount_p0:qq,_emscripten_bind_b2PulleyJoint__GetRatio_p0:hS,_emscripten_bind_b2FixtureDef__set_density_p1:qz,_emscripten_bind_b2RopeJoint__b2RopeJoint_p1:oh,_emscripten_bind_b2FixtureDef__get_filter_p0:qD,_emscripten_bind_b2WheelJoint__GetUserData_p0:jK,_emscripten_bind_b2GearJointDef__set_collideConnected_p1:uC,_emscripten_bind_b2GearJoint____destroy___p0:ls,_emscripten_bind_b2Body__GetAngularVelocity_p0:nB,_emscripten_bind_b2DistanceJointDef__get_bodyA_p1:tN,_emscripten_bind_b2RevoluteJoint__EnableMotor_p1:l_,_emscripten_bind_b2Body__SetType_p1:oX,_emscripten_bind_b2PolygonShape__set_m_vertexCount_p1:m5,_emscripten_bind_b2RopeJointDef__set_collideConnected_p1:uX,_emscripten_bind_b2FrictionJoint__GetBodyB_p0:oL,_emscripten_bind_b2RevoluteJoint__IsLimitEnabled_p0:lq,_emscripten_bind_b2FrictionJointDef__set_maxForce_p1:pv,_emscripten_bind_b2Timer__GetMilliseconds_p0:lT,_emscripten_bind_b2WheelJointDef__get_enableMotor_p0:rL,_emscripten_bind_b2RevoluteJointDef__get_bodyB_p1:sb,_emscripten_bind_b2PolygonShape__GetChildCount_p0:nW,_emscripten_bind_b2BlockAllocator__b2BlockAllocator_p0:mZ,_emscripten_bind_b2ContactEdge__set_other_p1:uK,_emscripten_bind_b2Body__GetMassData_p1:nM,_emscripten_bind_b2Joint__GetNext_p0:j8,_emscripten_bind_b2WeldJoint__GetReactionForce_p1:lH,_emscripten_bind_b2RevoluteJoint__GetAnchorA_p0:lL,_emscripten_bind_b2Filter__set_groupIndex_p1:pk,_emscripten_bind_b2PrismaticJointDef__set_maxMotorForce_p1:rl,_emscripten_bind_b2FrictionJoint__SetMaxForce_p1:pg,_malloc:vh,_emscripten_bind_b2MouseJoint__b2MouseJoint_p1:h2,_emscripten_bind_b2MouseJoint__Dump_p0:h5,_emscripten_bind_b2FixtureDef__set_restitution_p1:qA,_emscripten_bind_b2Shape__GetChildCount_p0:oc,_emscripten_bind_b2Body__GetJointList_p0:nG,_emscripten_bind_b2Timer____destroy___p0:mu,_emscripten_bind_b2Vec2__IsValid_p0:p7,_emscripten_bind_b2Contact__ResetRestitution_p0:nr,_emscripten_bind_b2RevoluteJointDef__get_collideConnected_p1:r9,_emscripten_bind_b2DynamicTree__MoveProxy_p3:lC,_emscripten_bind_b2Transform__b2Transform_p0:t5,_emscripten_bind_b2PulleyJointDef__get_localAnchorA_p0:sp,_emscripten_bind_b2RevoluteJointDef__get_bodyA_p1:sa,_emscripten_bind_b2WheelJointDef____destroy___p0:sE,_emscripten_bind_b2MouseJoint__GetBodyA_p0:hs,_emscripten_bind_b2GearJoint__GetType_p0:kR,_emscripten_bind_b2Body__SetMassData_p1:o_,_emscripten_bind_b2MouseJoint__IsActive_p0:hH,_emscripten_bind_b2Contact__GetChildIndexA_p0:nn,_emscripten_bind_b2Fixture__GetShape_p0:gX,_emscripten_bind_b2DistanceProxy__set_m_radius_p1:qm,_emscripten_bind_b2DistanceJointDef__get_bodyB_p1:tO,_emscripten_bind_b2RevoluteJoint__GetLowerLimit_p0:li,_emscripten_bind_b2World__DestroyJoint_p1:jf,_emscripten_bind_b2PulleyJointDef__set_ratio_p1:sh,_emscripten_bind_b2DynamicTree__b2DynamicTree_p0:lz,_emscripten_bind_b2RopeJoint__GetType_p0:mi,_emscripten_bind_b2Body__GetLocalPoint_p1:nE,_emscripten_bind_b2World__GetBodyCount_p0:iA,_emscripten_bind_b2CircleShape__GetType_p0:jB,_emscripten_bind_b2DistanceProxy__get_m_radius_p0:ql,_emscripten_bind_b2World__ClearForces_p0:iH,_emscripten_bind_b2DynamicTree____destroy___p0:ly,_emscripten_bind_b2Contact__GetWorldManifold_p1:n5,_emscripten_bind_b2DynamicTree__GetUserData_p1:lO,_emscripten_bind_b2JointDef____destroy___p0:t1,_emscripten_bind_b2DistanceProxy__GetVertex_p1:q_,_emscripten_bind_b2Draw__GetFlags_p0:j7,_emscripten_bind_b2PolygonShape__Set_p2:nQ,_emscripten_bind_b2DistanceJoint____destroy___p0:he,_emscripten_bind_b2DestructionListener__SayGoodbye_p1:pc,_emscripten_bind_b2BodyDef____destroy___p0:qL,_emscripten_bind_b2EdgeShape____destroy___p0:nZ,_emscripten_bind_b2GearJointDef__get_ratio_p0:uD,_emscripten_bind_b2BlockAllocator__Clear_p0:mO,_emscripten_bind_b2RopeJoint__GetAnchorB_p0:mU,_emscripten_bind_b2BodyDef__set_type_p1:pR,_emscripten_bind_b2WheelJoint__EnableMotor_p1:j$,_emscripten_bind_b2FrictionJoint__GetBodyA_p0:oP,_emscripten_bind_b2RopeJoint__GetBodyA_p0:mf,_emscripten_bind_b2WheelJointDef__get_bodyA_p1:rN,_emscripten_bind_b2RopeJoint__GetAnchorA_p0:mR,_emscripten_bind_b2GearJointDef__get_collideConnected_p1:uA,_emscripten_bind_b2RevoluteJointDef__get_upperAngle_p0:r5,_emscripten_bind_b2WeldJoint__GetLocalAnchorB_p0:k7,_emscripten_bind_b2PolygonShape__set_m_radius_p1:m0,_emscripten_bind_b2Vec2__SetZero_p0:qb,_emscripten_bind_b2WheelJointDef__get_maxMotorTorque_p0:rI,_emscripten_bind_b2ChainShape__CreateLoop_p2:mX,_emscripten_bind_b2RevoluteJoint__GetNext_p0:lj,_emscripten_bind_b2World__DestroyBody_p1:ji,_emscripten_bind_b2World__SetSubStepping_p1:ir,_emscripten_bind_b2PulleyJoint__SetUserData_p1:hP,_emscripten_bind_b2WheelJoint__GetMotorSpeed_p0:jS,_emscripten_bind_b2RopeJoint__GetLimitState_p0:m_,_emscripten_bind_b2PrismaticJointDef____destroy___p0:sx,_emscripten_bind_b2PulleyJointDef__set_collideConnected_p1:sL,_emscripten_bind_b2WheelJoint__GetNext_p0:jN,_emscripten_bind_b2World__SetContactFilter_p1:iT,_emscripten_bind_b2BroadPhase__GetFatAABB_p1:im,_emscripten_bind_b2FrictionJoint__SetMaxTorque_p1:pf,_emscripten_bind_b2ContactManager__set_m_contactCount_p1:gy,_emscripten_bind_b2Body__GetLinearVelocity_p0:nH,_emscripten_bind_b2ContactManager__get_m_allocator_p0:gE,_emscripten_bind_b2AABB____destroy___p0:ua,_emscripten_bind_b2PulleyJoint__GetCollideConnected_p0:hO,_emscripten_bind_b2Joint__GetUserData_p0:kb,_emscripten_bind_b2Rot__GetXAxis_p0:rr,_emscripten_bind_b2ContactManager__get_m_contactCount_p0:gv,_emscripten_bind_b2DistanceJoint__Dump_p0:hf,_emscripten_bind_b2PolygonShape__GetVertexCount_p0:m6,_emscripten_bind_b2StackAllocator__Free_p1:pa,_emscripten_bind_b2CircleShape__GetSupportVertex_p1:jF,_emscripten_bind_b2DistanceProxy__GetSupportVertex_p1:qo,_emscripten_bind_b2DistanceJointDef__set_bodyA_p1:tR,_emscripten_bind_b2JointDef__set_userData_p1:sN,_emscripten_bind_b2GearJoint__GetBodyB_p0:kT,_emscripten_bind_b2Vec3__get_z_p0:qg,_emscripten_bind_b2RopeJoint__GetUserData_p0:mh,_emscripten_bind_b2GearJoint__GetUserData_p0:kS,_emscripten_bind_b2FixtureDef__get_restitution_p0:qB,_emscripten_bind_b2WheelJoint__GetAnchorB_p0:kt,_emscripten_bind_b2FixtureDef__b2FixtureDef_p0:qY,_emscripten_bind_b2WheelJointDef__get_motorSpeed_p0:rx,_emscripten_bind_b2FrictionJoint__b2FrictionJoint_p1:ph,_emscripten_bind_b2Body__GetAngularDamping_p0:on,_emscripten_bind_b2ChainShape__GetChildCount_p0:mI,_emscripten_bind_b2ChainShape__SetNextVertex_p1:mb,_emscripten_bind_b2Joint__GetBodyA_p0:j9,_emscripten_bind_b2Fixture__IsSensor_p0:hp,_emscripten_bind_b2Filter__set_maskBits_p1:oU,_emscripten_bind_b2PulleyJointDef__set_groundAnchorB_p1:si,_emscripten_bind_b2ContactListener__PreSolve_p2:mz,_emscripten_bind_b2WheelJointDef__get_localAnchorB_p0:rJ,_emscripten_bind_b2WheelJointDef__set_bodyB_p1:rD,_emscripten_bind_b2BroadPhase__MoveProxy_p3:il,_emscripten_bind_b2BodyDef__get_active_p0:p_,_emscripten_bind_b2CircleShape__GetVertexCount_p0:ju,_emscripten_bind_b2Timer__Reset_p0:lS,_emscripten_bind_b2QueryCallback____destroy___p0:mL,_emscripten_bind_b2World__b2World_p1:jg,_emscripten_bind_b2Vec3__Set_p3:qf,_emscripten_bind_b2PrismaticJointDef__get_motorSpeed_p0:q1,_emscripten_bind_b2RevoluteJointDef__set_referenceAngle_p1:r6,_emscripten_bind_b2StackAllocator____destroy___p0:pi,_emscripten_bind_b2ContactEdge__get_other_p0:uH,_emscripten_bind_b2Fixture__GetType_p0:hq,_emscripten_bind_b2ContactListener__PostSolve_p2:mA,_emscripten_bind_b2WeldJointDef__set_collideConnected_p1:tu,_emscripten_bind_b2Contact__SetRestitution_p1:np,_emscripten_bind_b2Body__GetInertia_p0:oD,_emscripten_bind_b2FrictionJointDef__b2FrictionJointDef_p0:qJ,_emscripten_bind_b2PolygonShape__get_m_centroid_p0:m9,_emscripten_bind_b2PrismaticJoint__IsMotorEnabled_p0:i4,_emscripten_bind_b2FrictionJointDef__get_localAnchorA_p0:pu,_emscripten_bind_b2Draw__SetFlags_p1:j6,_emscripten_bind_b2WeldJoint__GetUserData_p0:k3,_emscripten_bind_b2WeldJointDef__b2WeldJointDef_p0:ue,_emscripten_bind_b2FrictionJointDef__set_collideConnected_p1:pz,_emscripten_bind_b2World__SetAllowSleeping_p1:iJ,_emscripten_bind_b2BodyDef__set_gravityScale_p1:pS,_emscripten_bind_b2Contact__IsTouching_p0:ni,_emscripten_bind_b2Transform__set_q_p1:sX,_emscripten_bind_b2FrictionJoint__GetAnchorB_p0:o7,_emscripten_bind_b2World__RayCast_p3:jk,_emscripten_bind_b2WeldJointDef__get_bodyA_p1:ti,_emscripten_bind_b2WheelJoint__GetMotorTorque_p1:jT,_emscripten_bind_b2Draw__b2Draw_p0:kH,_emscripten_bind_b2ChainShape____destroy___p0:mB,_emscripten_bind_b2ChainShape__get_m_radius_p0:l6,_emscripten_bind_b2RopeJoint__IsActive_p0:m$,_emscripten_bind_b2EdgeShape__set_m_radius_p1:nb,_emscripten_bind_b2DistanceJointDef__get_length_p0:tT,_emscripten_bind_b2DistanceJoint__SetUserData_p1:gJ,_emscripten_bind_b2ContactManager__set_m_contactListener_p1:gB,_emscripten_bind_b2MouseJointDef__get_maxForce_p0:tD,_emscripten_bind_b2WheelJoint____destroy___p0:kx,_emscripten_bind_b2PulleyJoint__GetBodyA_p0:hI,_emscripten_bind_b2MouseJoint__SetMaxForce_p1:hw,_emscripten_bind_b2World__GetGravity_p0:iQ,_emscripten_bind_b2WheelJointDef__set_bodyA_p1:rC,_emscripten_bind_b2AABB__b2AABB_p0:ub,_emscripten_bind_b2DistanceProxy____destroy___p0:qW,_emscripten_bind_b2RevoluteJointDef__set_lowerAngle_p1:rV,_emscripten_bind_b2World__GetProfile_p0:iu,_emscripten_bind_b2PulleyJointDef__get_bodyA_p1:su,_emscripten_bind_b2PulleyJointDef__set_groundAnchorA_p1:sj,_emscripten_bind_b2PolygonShape__Clone_p1:nS,_emscripten_bind_b2PrismaticJoint__GetUserData_p0:iW,_emscripten_bind_b2PrismaticJoint__IsLimitEnabled_p0:jy,_emscripten_bind_b2PulleyJoint__GetAnchorA_p0:h8,_emscripten_bind_b2Fixture__Refilter_p0:h_,_emscripten_bind_b2Vec3__SetZero_p0:qi,_emscripten_bind_b2ContactListener__EndContact_p1:mx,_emscripten_bind_b2Vec2__Normalize_p0:qM,_emscripten_bind_b2Shape__ComputeMass_p2:n8,_emscripten_bind_b2FrictionJoint__GetMaxForce_p0:oH,_emscripten_bind_b2BodyDef__get_type_p0:pE,_emscripten_bind_b2FixtureDef__get_userData_p0:qG,_emscripten_bind_b2MouseJointDef__get_collideConnected_p1:tI,_emscripten_bind_b2Contact__ResetFriction_p0:n6,_emscripten_bind_b2WeldJointDef__Initialize_p3:tw,_emscripten_bind_b2DistanceJoint__GetCollideConnected_p0:gQ,_emscripten_bind_b2Rot__Set_p1:sz,_emscripten_bind_b2ChainShape__RayCast_p4:mH,_emscripten_bind_b2RevoluteJoint__GetReactionForce_p1:mo,_emscripten_bind_b2PrismaticJointDef__b2PrismaticJointDef_p0:sw,_emscripten_bind_b2FrictionJointDef__get_localAnchorB_p0:pw,_emscripten_bind_b2MouseJoint__GetMaxForce_p0:hz,_emscripten_bind_b2RopeJoint__Dump_p0:mT,_emscripten_bind_b2WheelJointDef__set_enableMotor_p1:rP,_emscripten_bind_b2ContactManager__get_m_contactList_p0:gD,_emscripten_bind_b2PolygonShape__ComputeAABB_p3:nV,_emscripten_bind_b2RopeJointDef__set_bodyB_p1:uS,_emscripten_bind_b2BodyDef__set_fixedRotation_p1:pL,_emscripten_bind_b2WheelJoint__GetAnchorA_p0:ku,_emscripten_bind_b2GearJoint__GetBodyA_p0:kW,_emscripten_bind_b2CircleShape__b2CircleShape_p0:kr,_emscripten_bind_b2EdgeShape__GetChildCount_p0:n2,_emscripten_bind_b2BodyDef__set_active_p1:pV,_emscripten_bind_b2FrictionJointDef__get_bodyA_p1:po,_emscripten_bind_b2PulleyJoint__GetReactionTorque_p1:h9,_emscripten_bind_b2DistanceJoint__b2DistanceJoint_p1:hj,_emscripten_bind_b2Vec2____destroy___p0:qQ,_emscripten_bind_b2ChainShape__get_m_vertices_p0:l7,_emscripten_bind_b2BodyDef__b2BodyDef_p0:qK,_emscripten_bind_b2RevoluteJoint__Dump_p0:mq,_emscripten_bind_b2RevoluteJointDef__b2RevoluteJointDef_p0:sF,_emscripten_bind_b2World__SetDebugDraw_p1:iO,_emscripten_bind_b2MouseJoint____destroy___p0:h4,_emscripten_bind_b2RevoluteJoint__IsMotorEnabled_p0:lV,_emscripten_bind_b2MouseJointDef__set_frequencyHz_p1:tK,_emscripten_bind_b2DestructionListener__b2DestructionListener_p0:pd,_emscripten_bind_b2WheelJointDef__get_frequencyHz_p0:rF,_emscripten_bind_b2Filter__b2Filter_p0:qH,_emscripten_bind_b2World____destroy___p0:jl,_emscripten_bind_b2Body__SetBullet_p1:oA,_emscripten_bind_b2Body__GetAngle_p0:nv,_emscripten_bind_b2PrismaticJointDef__set_bodyA_p1:q7,_emscripten_bind_b2MouseJoint__GetTarget_p0:hA,_emscripten_bind_b2DistanceJointDef__get_frequencyHz_p0:tV,_emscripten_bind_b2Contact__GetNext_p0:ne,_emscripten_bind_b2World__DrawDebugData_p0:je,_emscripten_bind_b2RevoluteJointDef__set_maxMotorTorque_p1:sc,_emscripten_bind_b2Vec2__LengthSquared_p0:p9,_emscripten_bind_b2WheelJointDef__get_localAnchorA_p0:rH,_emscripten_bind_b2RevoluteJoint____destroy___p0:mp,_emscripten_bind_b2PulleyJointDef__get_lengthB_p0:sJ,_emscripten_bind_b2WeldJoint__GetReferenceAngle_p0:lb,_strlen:vr,_emscripten_bind_b2FixtureDef__set_filter_p1:qZ,_emscripten_bind_b2ChainShape__CreateChain_p2:mW,_emscripten_bind_b2Body__GetLocalVector_p1:oy,_emscripten_bind_b2Fixture__SetUserData_p1:hn,_emscripten_bind_b2RevoluteJoint__GetLocalAnchorB_p0:lm,_emscripten_bind_b2FrictionJointDef__set_maxTorque_p1:py,_emscripten_bind_b2ChainShape__ComputeAABB_p3:mG,_emscripten_bind_b2RopeJoint__GetReactionForce_p1:nO,_emscripten_bind_b2CircleShape__GetSupport_p1:jv,_emscripten_bind_b2World__GetContinuousPhysics_p0:iC,_emscripten_bind_b2FrictionJointDef__get_maxForce_p0:pt,_emscripten_bind_b2Draw____destroy___p0:kA,_emscripten_bind_b2RevoluteJointDef__set_localAnchorA_p1:rS,_emscripten_bind_b2MouseJoint__GetCollideConnected_p0:hD,_emscripten_bind_b2MouseJoint__GetReactionForce_p1:h3,_emscripten_bind_b2JointDef__set_type_p1:sR,_emscripten_bind_b2Color__Set_p3:s$,_emscripten_bind_b2WeldJoint__GetType_p0:lc,_emscripten_bind_b2Joint__GetBodyB_p0:ka,_emscripten_bind_b2ContactManager__set_m_broadPhase_p1:ha,_emscripten_bind_b2JointDef__get_type_p0:sT,_emscripten_bind_b2BodyDef__set_position_p1:pG,_emscripten_bind_b2Vec2__Length_p0:qP,_emscripten_bind_b2MouseJoint__GetUserData_p0:hv,_emscripten_bind_b2JointDef__get_collideConnected_p0:sS,_emscripten_bind_b2BroadPhase__GetTreeQuality_p0:hT,_emscripten_bind_b2WheelJointDef__get_dampingRatio_p0:rM,_emscripten_bind_b2RopeJoint__GetBodyB_p0:mj,_emscripten_bind_b2Joint__GetCollideConnected_p0:ke,_emscripten_bind_b2FrictionJoint__GetReactionTorque_p1:o4,_emscripten_bind_b2PulleyJointDef__get_bodyB_p1:sv,_emscripten_bind_b2ContactManager__set_m_contactFilter_p1:gw,_emscripten_bind_b2FrictionJoint__GetAnchorA_p0:o3,_emscripten_bind_b2EdgeShape__ComputeAABB_p3:n1,_emscripten_bind_b2BodyDef__set_awake_p1:p1,_emscripten_bind_b2FrictionJointDef__get_bodyB_p1:pp,_emscripten_bind_b2PrismaticJoint__SetMotorSpeed_p1:i$,_emscripten_bind_b2PolygonShape__RayCast_p4:nT,_emscripten_bind_b2CircleShape__ComputeMass_p2:kl,_emscripten_bind_b2MouseJoint__GetFrequency_p0:hB,_emscripten_bind_b2Contact__IsEnabled_p0:nj,_emscripten_bind_b2PrismaticJointDef__set_bodyB_p1:q8,_emscripten_bind_b2FixtureDef__set_userData_p1:qv,_emscripten_bind_b2Fixture__SetSensor_p1:hl,_emscripten_bind_b2Shape__GetType_p0:nu,_emscripten_bind_b2WeldJointDef__get_localAnchorB_p0:tr,_emscripten_bind_b2ContactManager__Destroy_p1:g9,_emscripten_bind_b2PrismaticJoint__GetLocalAnchorA_p0:i_,_emscripten_bind_b2WheelJointDef__set_motorSpeed_p1:rA,_emscripten_bind_b2Contact__Evaluate_p3:n7,_emscripten_bind_b2PulleyJointDef__set_localAnchorB_p1:sg,_emscripten_bind_b2RevoluteJoint__GetType_p0:l1,_emscripten_bind_b2AABB__Combine_p1:td,_emscripten_bind_b2GearJoint__GetReactionTorque_p1:kP,_emscripten_bind_b2AABB__Combine_p2:te,_emscripten_bind_b2PulleyJointDef__get_lengthA_p0:sK,_emscripten_bind_b2Shape__get_m_radius_p0:ns,_emscripten_bind_b2ChainShape__set_m_count_p1:mc,_emscripten_bind_b2RopeJointDef__set_bodyA_p1:uR,_emscripten_bind_b2DynamicTree__GetFatAABB_p1:lN,_emscripten_bind_b2DistanceJoint__GetFrequency_p0:gN,_emscripten_bind_b2PrismaticJoint__SetLimits_p2:kQ,_emscripten_bind_b2PulleyJointDef__b2PulleyJointDef_p0:t0,_emscripten_bind_b2Color__get_g_p0:s3,_emscripten_bind_b2Fixture__GetBody_p0:gZ,_emscripten_bind_b2FrictionJointDef__get_collideConnected_p1:px,_emscripten_bind_b2WheelJointDef__set_maxMotorTorque_p1:ry,_emscripten_bind_b2GearJointDef__get_bodyB_p1:uu,_emscripten_bind_b2AABB__set_upperBound_p1:s6,_emscripten_bind_b2Contact__GetFixtureA_p0:nm,_emscripten_bind_b2RevoluteJointDef__set_localAnchorB_p1:rU,_emscripten_bind_b2WheelJointDef__set_localAnchorA_p1:rv,_emscripten_bind_b2DistanceJointDef__set_bodyB_p1:tS,_emscripten_bind_b2Transform__SetIdentity_p0:s_,_emscripten_bind_b2FrictionJointDef__set_localAnchorA_p1:pn,_emscripten_bind_b2Body__SetTransform_p2:of,_emscripten_bind_b2DistanceJoint__GetReactionTorque_p1:hg,_emscripten_bind_b2StackAllocator__b2StackAllocator_p0:o9,_emscripten_bind_b2MouseJointDef__set_maxForce_p1:tF,_emscripten_bind_b2RevoluteJoint__GetMotorTorque_p1:lp,_emscripten_bind_b2Vec2__set_y_p1:p6,_emscripten_bind_b2CircleShape__Clone_p1:km,_emscripten_bind_b2Rot__GetAngle_p0:sA,_emscripten_bind_b2Color____destroy___p0:t7,_emscripten_bind_b2WeldJoint__GetBodyA_p0:k0,_emscripten_bind_b2Fixture__GetRestitution_p0:gV,_emscripten_bind_b2DistanceJointDef__set_length_p1:t_,_emscripten_bind_b2PrismaticJointDef__get_localAxisA_p0:q6,_emscripten_bind_b2Color__b2Color_p3:t9,_emscripten_bind_b2Body__ApplyForceToCenter_p1:oi,_emscripten_bind_b2PrismaticJoint__SetUserData_p1:i5,_emscripten_bind_b2Color__get_r_p0:s1,_emscripten_bind_b2RevoluteJoint__b2RevoluteJoint_p1:lR,_emscripten_bind_b2RevoluteJoint__GetCollideConnected_p0:lY,_emscripten_bind_b2PrismaticJoint__IsActive_p0:jA,_emscripten_bind_b2Body__SetFixedRotation_p1:o2,_emscripten_bind_b2RopeJointDef____destroy___p0:u4,_emscripten_bind_b2PrismaticJointDef__get_bodyB_p1:ri,_emscripten_bind_b2Shape__set_m_radius_p1:nt,_emscripten_bind_b2WheelJoint__GetBodyB_p0:jJ,_emscripten_bind_b2JointDef__get_bodyA_p0:sM,_emscripten_bind_b2World__GetContactCount_p0:iR,_emscripten_bind_b2Fixture__b2Fixture_p0:hi,_emscripten_bind_b2StackAllocator__Allocate_p1:pj,_emscripten_bind_b2Body__SetGravityScale_p1:nz,_emscripten_bind_b2BroadPhase__CreateProxy_p2:ik,_emscripten_bind_b2WheelJoint__GetLocalAnchorA_p0:jP,_emscripten_bind_b2FrictionJointDef__set_bodyB_p1:ps,_emscripten_bind_b2WheelJoint__SetSpringFrequencyHz_p1:j2,_emscripten_bind_b2MouseJointDef__b2MouseJointDef_p0:uf,_emscripten_bind_b2PrismaticJointDef__set_localAnchorB_p1:q0,_emscripten_bind_b2Filter____destroy___p0:pe,_emscripten_bind_b2PrismaticJointDef__set_enableMotor_p1:rm,_emscripten_bind_b2Fixture__GetUserData_p0:g0,_emscripten_bind_b2AABB__get_upperBound_p0:tb,_emscripten_bind_b2PulleyJoint__Dump_p0:ia,_emscripten_bind_b2RopeJointDef__get_localAnchorA_p0:uT,_emscripten_bind_b2CircleShape__get_m_radius_p0:jD,_emscripten_bind_b2DistanceJoint__GetLength_p0:gO,_emscripten_bind_b2BodyDef__set_angularVelocity_p1:pO,_emscripten_bind_b2RevoluteJointDef__get_motorSpeed_p0:r_,_emscripten_bind_b2PulleyJointDef__set_localAnchorA_p1:sf,_emscripten_bind_b2RevoluteJoint__SetMotorSpeed_p1:ll,_emscripten_bind_b2WeldJoint__GetReactionTorque_p1:lK,_emscripten_bind_b2GearJoint__SetUserData_p1:kV,_emscripten_bind_b2PrismaticJoint__GetAnchorB_p0:kj,_emscripten_bind_b2MouseJointDef__set_target_p1:tE,_emscripten_bind_b2WeldJoint__GetBodyB_p0:k1,_emscripten_bind_b2PolygonShape__TestPoint_p2:nX,_emscripten_bind_b2WheelJointDef__set_localAnchorB_p1:rw,_emscripten_bind_b2WheelJoint__GetReactionTorque_p1:kz,_emscripten_bind_b2FrictionJointDef__set_bodyA_p1:pr,_emscripten_bind_b2Color__b2Color_p0:t8,_emscripten_bind_b2BroadPhase__TestOverlap_p2:iq,_emscripten_bind_b2PrismaticJointDef__set_localAnchorA_p1:q$,_emscripten_bind_b2RevoluteJoint__GetReactionTorque_p1:mr,_emscripten_bind_b2Joint__GetAnchorB_p0:kL,_emscripten_bind_b2CircleShape__set_m_radius_p1:jC,_memcpy:vp,_emscripten_bind_b2World__GetContactManager_p0:iw,_emscripten_bind_b2RevoluteJoint__SetUserData_p1:lW,_emscripten_bind_b2Contact__GetFixtureB_p0:nk,_emscripten_bind_b2Rot__GetYAxis_p0:rq,_emscripten_bind_b2RevoluteJointDef__set_upperAngle_p1:rX,_emscripten_bind_b2Shape__Clone_p1:n9,_emscripten_bind_b2PulleyJoint__GetType_p0:hJ,_emscripten_bind_b2AABB__set_lowerBound_p1:tf,_emscripten_bind_b2RopeJoint__GetCollideConnected_p0:mg,_emscripten_bind_b2DistanceJoint__IsActive_p0:gU,_emscripten_bind_b2BodyDef__set_linearDamping_p1:p$,_emscripten_bind_b2BroadPhase__GetTreeBalance_p0:ip,_emscripten_bind_b2AABB__GetExtents_p0:s9,_emscripten_bind_b2CircleShape____destroy___p0:kk,_emscripten_bind_b2WeldJoint__SetFrequency_p1:k2,_emscripten_bind_b2GearJointDef__set_ratio_p1:uz,_emscripten_bind_b2FixtureDef__get_density_p0:qx,_emscripten_bind_b2AABB__GetCenter_p0:ta,_emscripten_bind_b2Draw__ClearFlags_p1:j5,_emscripten_bind_b2WeldJointDef__get_localAnchorA_p0:tp,_emscripten_bind_b2PolygonShape__GetType_p0:m7,_emscripten_bind_b2DistanceJointDef__set_dampingRatio_p1:tQ,_emscripten_bind_b2BroadPhase__GetUserData_p1:io,_emscripten_bind_b2Rot__get_c_p0:ru,_emscripten_bind_b2World__GetAutoClearForces_p0:iB,_emscripten_bind_b2World__GetTreeHeight_p0:it,_emscripten_bind_b2AABB__IsValid_p0:s7,_emscripten_bind_b2RevoluteJoint__GetAnchorB_p0:ms,_emscripten_bind_b2RopeJointDef__get_bodyB_p1:uP,_emscripten_bind_b2World__CreateJoint_p1:jj,_emscripten_bind_b2WheelJoint__GetDefinition_p1:ks,_emscripten_bind_b2Color__set_b_p1:s2,_emscripten_bind_b2PrismaticJointDef__get_referenceAngle_p0:q3,_emscripten_bind_b2Body__GetLocalCenter_p0:oq,_emscripten_bind_b2WheelJoint__GetLocalAxisA_p0:jL,_emscripten_bind_b2Contact__GetFriction_p0:nh,_emscripten_bind_b2Body__SetAngularVelocity_p1:nL,_emscripten_bind_b2PrismaticJoint__GetJointSpeed_p0:i8,_emscripten_bind_b2CircleShape__TestPoint_p2:kq,_emscripten_bind_b2Body__SetAwake_p1:o$,_emscripten_bind_b2Filter__set_categoryBits_p1:oV,_emscripten_bind_b2ChainShape__ComputeMass_p2:mC,_emscripten_bind_b2PrismaticJointDef__get_collideConnected_p1:rg,_emscripten_bind_b2World__CreateBody_p1:jt,_emscripten_bind_b2JointDef__get_bodyB_p0:sQ,_emscripten_bind_b2ChainShape__get_m_count_p0:l8,_emscripten_bind_b2Joint__GetType_p0:kc,_emscripten_bind_b2WheelJoint__GetCollideConnected_p0:jZ,_emscripten_bind_b2WheelJointDef__set_localAxisA_p1:rR,_emscripten_bind_b2CircleShape__GetVertex_p1:jE,_emscripten_bind_b2WeldJoint__GetNext_p0:k5,_emscripten_bind_b2WeldJoint__GetCollideConnected_p0:la,_emscripten_bind_b2World__SetDestructionListener_p1:iF,_emscripten_bind_b2WheelJointDef__get_localAxisA_p0:rB,_emscripten_bind_b2Joint__GetAnchorA_p0:kJ,_emscripten_bind_b2DistanceProxy__b2DistanceProxy_p0:qV,_emscripten_bind_b2WheelJoint__IsActive_p0:j3,_emscripten_bind_b2Transform____destroy___p0:t3,_emscripten_bind_b2PolygonShape__ComputeMass_p2:nR,_emscripten_bind_b2RopeJointDef__get_bodyA_p1:uO,_emscripten_bind_b2WheelJoint__b2WheelJoint_p1:kv,_emscripten_bind_b2Body__GetLinearVelocityFromLocalPoint_p1:os,_emscripten_bind_b2Draw__DrawTransform_p1:kB,_emscripten_bind_b2DistanceJoint__GetType_p0:gR,_emscripten_bind_b2MouseJointDef__set_bodyB_p1:tC,_emscripten_bind_b2Fixture__GetFriction_p0:g$,_emscripten_bind_b2Body__GetWorld_p0:ox,_emscripten_bind_b2PolygonShape__b2PolygonShape_p0:nY,_emscripten_bind_b2WeldJointDef__set_frequencyHz_p1:tv,_emscripten_bind_b2RevoluteJoint__GetJointAngle_p0:ln,_emscripten_bind_b2Body__ResetMassData_p0:og,_emscripten_bind_b2RevoluteJoint__IsActive_p0:l3,_emscripten_bind_b2FrictionJoint__SetUserData_p1:oO,_emscripten_bind_b2PulleyJoint__GetReactionForce_p1:ie,_emscripten_bind_b2Timer__b2Timer_p0:mt,_emscripten_bind_b2World__SetContinuousPhysics_p1:iy,_emscripten_bind_b2ContactManager__FindNewContacts_p0:g7,_emscripten_bind_b2DistanceJointDef__get_localAnchorA_p0:tU,_emscripten_bind_b2DynamicTree__GetMaxBalance_p0:lP,_emscripten_bind_b2PolygonShape__GetVertex_p1:m2,_emscripten_bind_b2WeldJointDef__get_frequencyHz_p0:tl,_emscripten_bind_b2ContactListener__BeginContact_p1:my,_emscripten_bind_b2RevoluteJointDef__set_collideConnected_p1:se,_emscripten_bind_b2DistanceJoint__GetAnchorA_p0:hc,_emscripten_bind_b2PrismaticJoint__GetLocalAxisA_p0:iX,_emscripten_bind_b2ChainShape__Clone_p1:mD,_emscripten_bind_b2GearJointDef__b2GearJointDef_p0:u1,_emscripten_bind_b2RevoluteJoint__GetBodyA_p0:lf,_emscripten_bind_b2Body__ApplyForce_p2:nD,_emscripten_bind_b2MouseJoint__GetReactionTorque_p1:h6,_emscripten_bind_b2Vec2__get_y_p0:p5,_emscripten_bind_b2ContactEdge__get_contact_p0:uM,_emscripten_bind_b2GearJointDef__set_bodyB_p1:ux,_emscripten_bind_b2RevoluteJointDef__get_enableMotor_p0:rW,_emscripten_bind_b2RopeJoint____destroy___p0:mQ,_emscripten_bind_b2WheelJointDef__b2WheelJointDef_p0:sD,_emscripten_bind_b2DistanceJoint__SetFrequency_p1:gH,_emscripten_bind_b2PulleyJointDef__set_lengthA_p1:st,_emscripten_bind_b2FixtureDef__get_friction_p0:qE,_emscripten_bind_b2ContactEdge__get_next_p0:uJ,_emscripten_bind_b2RevoluteJoint__GetBodyB_p0:lg,_emscripten_bind_b2RevoluteJoint__GetUserData_p0:lh,_emscripten_bind_b2Body__GetType_p0:oB,_emscripten_bind_b2World__Step_p3:jh,_emscripten_bind_b2Vec2__set_x_p1:p2,_emscripten_bind_b2ContactManager__b2ContactManager_p0:g4,_emscripten_bind_b2RopeJoint__GetNext_p0:md,_emscripten_bind_b2WeldJoint__SetDampingRatio_p1:ld,_emscripten_bind_b2World__GetTreeQuality_p0:is,_emscripten_bind_b2WeldJoint__GetAnchorB_p0:lF,_emscripten_bind_b2Contact__GetRestitution_p0:ng,_emscripten_bind_b2MouseJointDef____destroy___p0:ug,_emscripten_bind_b2Body__GetTransform_p0:ol,_emscripten_bind_b2PrismaticJoint__b2PrismaticJoint_p1:jo,_emscripten_bind_b2RopeJointDef__get_maxLength_p0:uU,_emscripten_bind_b2DistanceJoint__GetAnchorB_p0:hb,_emscripten_bind_b2ChainShape__set_m_vertices_p1:ma,_emscripten_bind_b2EdgeShape__TestPoint_p2:n3,_emscripten_bind_b2FrictionJoint__GetMaxTorque_p0:oR,_emscripten_bind_b2RopeJointDef__b2RopeJointDef_p0:u5,_emscripten_bind_b2ContactManager__AddPair_p2:g5,_emscripten_bind_b2Color__set_g_p1:s5,_emscripten_bind_b2WheelJoint__IsMotorEnabled_p0:jU,_emscripten_bind_b2QueryCallback__b2QueryCallback_p0:mM,_emscripten_bind_b2WheelJointDef__get_collideConnected_p1:rK,_emscripten_bind_b2FrictionJoint__Dump_p0:o5,_emscripten_bind_b2ChainShape__SetPrevVertex_p1:l9,_emscripten_bind_b2AABB__GetPerimeter_p0:tc,_emscripten_bind_b2DistanceProxy__set_m_count_p1:qt,_emscripten_bind_b2Body__GetLinearVelocityFromWorldPoint_p1:nN,_emscripten_bind_b2MouseJointDef__set_bodyA_p1:tB,_emscripten_bind_b2DynamicTree__GetAreaRatio_p0:k$,_emscripten_bind_b2World__QueryAABB_p2:jd,_emscripten_bind_b2RevoluteJoint__GetUpperLimit_p0:l2,_emscripten_bind_b2World__SetGravity_p1:iz,_emscripten_bind_b2PulleyJointDef__Initialize_p7:sH,_emscripten_bind_b2Color__get_b_p0:s4,_emscripten_bind_b2DistanceJoint__GetBodyA_p0:gF,_emscripten_bind_b2BroadPhase__DestroyProxy_p1:jc,_emscripten_bind_b2PulleyJoint____destroy___p0:h7,_emscripten_bind_b2BroadPhase__GetProxyCount_p0:hV,_emscripten_bind_b2DistanceJoint__GetLocalAnchorB_p0:gM,_emscripten_bind_b2ChainShape__GetChildEdge_p2:mE,_emscripten_bind_b2EdgeShape__b2EdgeShape_p0:n4,_emscripten_bind_b2ContactEdge__set_contact_p1:uF,_emscripten_bind_b2WheelJoint__SetMotorSpeed_p1:jQ,_emscripten_bind_b2ChainShape__GetType_p0:l4,_emscripten_bind_b2Fixture__SetFilterData_p1:hh,_emscripten_bind_b2Body__ApplyAngularImpulse_p1:oF,_emscripten_bind_b2RevoluteJoint__SetLimits_p2:mV,_emscripten_bind_b2ChainShape__TestPoint_p2:mJ,_emscripten_bind_b2RevoluteJointDef__get_maxMotorTorque_p0:r0,_emscripten_bind_b2CircleShape__get_m_p_p0:jH,_emscripten_bind_b2BodyDef__get_awake_p0:pD,_emscripten_bind_b2MouseJoint__GetAnchorB_p0:h0,_emscripten_bind_b2Body__CreateFixture_p1:oY,_emscripten_bind_b2Body__CreateFixture_p2:oZ,_emscripten_bind_b2GearJointDef____destroy___p0:u0,_emscripten_bind_b2Fixture__GetDensity_p0:hr,_emscripten_bind_b2PrismaticJoint__GetJointTranslation_p0:jw,_emscripten_bind_b2WeldJoint__GetDampingRatio_p0:k9,_emscripten_bind_b2FrictionJoint__GetReactionForce_p1:o8,_emscripten_bind_b2BodyDef__set_userData_p1:pP,_emscripten_bind_b2World__SetContactListener_p1:ix,_emscripten_bind_b2PulleyJointDef__get_localAnchorB_p0:sq,_emscripten_bind_b2FixtureDef__set_shape_p1:qw,_emscripten_bind_b2DistanceJoint__SetDampingRatio_p1:gS,_emscripten_bind_b2Joint__Dump_p0:kK,_emscripten_bind_b2Shape__TestPoint_p2:od,_emscripten_bind_b2RopeJointDef__set_maxLength_p1:uY,_emscripten_bind_b2RopeJoint__SetUserData_p1:mn,_emscripten_bind_b2Transform__get_p_p0:sY,_emscripten_bind_b2PulleyJoint__GetLengthA_p0:ic,_emscripten_bind_b2GearJoint__GetJoint2_p0:kh,_emscripten_bind_b2Fixture__GetMassData_p1:hW,_emscripten_bind_b2Body__IsBullet_p0:ow,_emscripten_bind_b2WeldJointDef____destroy___p0:ud,_emscripten_bind_b2PrismaticJoint__GetMotorSpeed_p0:i1,_emscripten_bind_b2GearJointDef__get_bodyA_p1:ut,_emscripten_bind_b2Draw__DrawCircle_p3:kF,_emscripten_bind_b2FrictionJoint__GetLocalAnchorA_p0:oM,_emscripten_bind_b2Body__GetWorldPoint_p1:ou,_emscripten_bind_b2PrismaticJointDef__set_referenceAngle_p1:rd,_emscripten_bind_b2GearJointDef__set_bodyA_p1:uw,_emscripten_bind_b2RevoluteJointDef__set_motorSpeed_p1:r$,_emscripten_bind_b2BodyDef__set_bullet_p1:pU,_emscripten_bind_b2BodyDef__get_angularVelocity_p0:pY,_emscripten_bind_b2GearJoint__GetNext_p0:kX,_emscripten_bind_b2PrismaticJointDef__get_enableLimit_p0:rc,_emscripten_bind_b2BodyDef__get_fixedRotation_p0:p0,_emscripten_bind_b2Body__GetFixtureList_p0:nC,_emscripten_bind_b2WheelJoint__GetJointTranslation_p0:jV,_emscripten_bind_b2WeldJointDef__get_dampingRatio_p0:tt,_emscripten_bind_b2RopeJoint__SetMaxLength_p1:ml,_emscripten_bind_b2DistanceJointDef__get_localAnchorB_p0:tW,_emscripten_bind_b2PulleyJoint__GetGroundAnchorB_p0:hK,_emscripten_bind_b2PulleyJointDef__get_groundAnchorB_p0:sk,_emscripten_bind_b2GearJointDef__set_joint2_p1:uy,_emscripten_bind_b2BroadPhase__b2BroadPhase_p0:ii,_emscripten_bind_b2RevoluteJointDef__get_lowerAngle_p0:rT,_emscripten_bind_b2MouseJoint__SetTarget_p1:hE,_emscripten_bind_b2ContactEdge__set_prev_p1:uI,_emscripten_bind_b2PrismaticJointDef__get_upperTranslation_p0:rb,_emscripten_bind_b2ChainShape__set_m_radius_p1:l5,_emscripten_bind_b2Vec2__get_x_p0:p4,_emscripten_bind_b2DistanceProxy__GetSupport_p1:qr,_emscripten_bind_b2WheelJoint__GetLocalAnchorB_p0:jR,_emscripten_bind_b2GearJointDef__get_joint2_p0:uB,_emscripten_bind_b2PrismaticJointDef__set_collideConnected_p1:rn,_emscripten_bind_b2FrictionJointDef__set_localAnchorB_p1:pq,_emscripten_bind_b2PrismaticJointDef__set_localAxisA_p1:rp,_emscripten_bind_b2Fixture__SetDensity_p1:hk,_emscripten_bind_b2RevoluteJointDef__set_enableLimit_p1:rZ,_emscripten_bind_b2Body__IsAwake_p0:ok,_emscripten_bind_b2MouseJoint__GetAnchorA_p0:h1,_emscripten_bind_b2PolygonShape__SetAsBox_p4:nU,_emscripten_bind_b2PolygonShape__SetAsBox_p2:m3,_emscripten_bind_b2GearJointDef__set_joint1_p1:uE,_emscripten_bind_b2Draw__DrawSolidCircle_p4:kD,_emscripten_bind_b2World__GetSubStepping_p0:iv,_emscripten_bind_b2FrictionJoint__GetLocalAnchorB_p0:oN,_free:vi,_emscripten_bind_b2Body__SetLinearDamping_p1:oz,_emscripten_bind_b2Body__GetWorldVector_p1:or,_emscripten_bind_b2Fixture__SetFriction_p1:gW,_emscripten_bind_b2Filter__get_groupIndex_p0:oW,_emscripten_bind_b2FixtureDef__get_isSensor_p0:qu,_emscripten_bind_b2PrismaticJoint__GetUpperLimit_p0:jz,_emscripten_bind_b2PrismaticJoint__Dump_p0:jr,_emscripten_bind_b2Vec2__op_mul_p1:qc,_emscripten_bind_b2DistanceProxy__Set_p2:qU,_emscripten_bind_b2EdgeShape__Set_p2:na,_emscripten_bind_b2BodyDef__get_userData_p0:pJ,_emscripten_bind_b2CircleShape__set_m_p_p1:jG,_emscripten_bind_b2WheelJoint__GetMaxMotorTorque_p0:j0,_emscripten_bind_b2GearJoint__GetJoint1_p0:kg,_emscripten_bind_b2WheelJointDef__set_dampingRatio_p1:rG,_emscripten_bind_b2DistanceJointDef__set_collideConnected_p1:tZ,_emscripten_bind_b2DistanceProxy__get_m_count_p0:qp,_emscripten_bind_b2WeldJointDef__set_dampingRatio_p1:tx,_emscripten_bind_b2DistanceJointDef__set_localAnchorB_p1:tP,_emscripten_bind_b2GearJoint__GetCollideConnected_p0:kU,_emscripten_bind_b2FrictionJoint__GetCollideConnected_p0:oI,_memset:vq,_emscripten_bind_b2WheelJoint__Dump_p0:ky,_emscripten_bind_b2World__GetTreeBalance_p0:js,_emscripten_bind_b2ContactListener__b2ContactListener_p0:mw,_emscripten_bind_b2Rot____destroy___p0:sy,_emscripten_bind_b2PrismaticJoint__GetMaxMotorForce_p0:i6,_emscripten_bind_b2PulleyJointDef__set_bodyB_p1:sn,_emscripten_bind_b2PulleyJointDef__get_groundAnchorA_p0:sl,_emscripten_bind_b2RevoluteJoint__GetMotorSpeed_p0:lo,_emscripten_bind_b2DistanceJointDef__b2DistanceJointDef_p0:uh,_emscripten_bind_b2Body__GetNext_p0:nI,_emscripten_bind_b2BroadPhase__GetTreeHeight_p0:hU,_emscripten_bind_b2Draw__DrawSegment_p3:kG,_emscripten_bind_b2Body__IsActive_p0:oE,_emscripten_bind_b2Vec2__Set_p2:p3,_emscripten_bind_b2PulleyJoint__GetUserData_p0:hM,_emscripten_bind_b2ContactEdge__b2ContactEdge_p0:u3,_emscripten_bind_b2Vec3__b2Vec3_p3:qT,_emscripten_bind_b2Vec3__b2Vec3_p0:qS,_emscripten_bind_b2PulleyJoint__GetGroundAnchorA_p0:hL,_emscripten_bind_b2JointDef__b2JointDef_p0:t2,_emscripten_bind_b2PulleyJoint__GetBodyB_p0:hN,_emscripten_bind_b2PulleyJointDef____destroy___p0:sI,_emscripten_bind_b2FixtureDef____destroy___p0:qX,_emscripten_bind_b2EdgeShape__Clone_p1:n$,_emscripten_bind_b2Body__GetUserData_p0:nw,_emscripten_bind_b2Body__SetUserData_p1:nA,_emscripten_bind_b2FixtureDef__set_friction_p1:qF,_emscripten_bind_b2PrismaticJointDef__get_bodyA_p1:rh,_emscripten_bind_b2FrictionJoint__GetType_p0:oK,_emscripten_bind_b2DistanceJointDef____destroy___p0:ui,_emscripten_bind_b2FrictionJointDef__Initialize_p3:pA,_emscripten_bind_b2GearJoint__b2GearJoint_p1:kN,_emscripten_bind_b2Body__SetSleepingAllowed_p1:nJ,_emscripten_bind_b2Body__SetLinearVelocity_p1:nF,_emscripten_bind_b2Body__ApplyLinearImpulse_p2:oo,_emscripten_bind_b2PulleyJoint__b2PulleyJoint_p1:ig,_emscripten_bind_b2MouseJointDef__get_bodyB_p1:tz,_emscripten_bind_b2ContactManager__set_m_contactList_p1:gz,_emscripten_bind_b2MouseJoint__GetNext_p0:hy,_emscripten_bind_b2Transform__get_q_p0:sZ,_emscripten_bind_b2DistanceJointDef__get_collideConnected_p1:tX,_emscripten_bind_b2WeldJointDef__set_bodyB_p1:tn,_emscripten_bind_b2DistanceJoint__GetReactionForce_p1:hd,_emscripten_bind_b2FrictionJoint____destroy___p0:o6,_emscripten_bind_b2JointDef__set_collideConnected_p1:sU,_emscripten_bind_b2CircleShape__ComputeAABB_p3:ko,_emscripten_bind_b2QueryCallback__ReportFixture_p1:mK,_emscripten_bind_b2GearJoint__GetRatio_p0:kZ,_emscripten_bind_b2BlockAllocator__Allocate_p1:mP,_emscripten_bind_b2GearJointDef__get_joint1_p0:uv,_emscripten_bind_b2AABB__Contains_p1:s8,_emscripten_bind_b2FrictionJoint__GetNext_p0:oQ,_emscripten_bind_b2ContactEdge____destroy___p0:u2,_emscripten_bind_b2RevoluteJointDef__Initialize_p3:r3,_emscripten_bind_b2BodyDef__set_angle_p1:pW,_emscripten_bind_b2PrismaticJointDef__Initialize_p4:q9,_emscripten_bind_b2Body__GetContactList_p0:ot,_emscripten_bind_b2MouseJointDef__set_dampingRatio_p1:tA,_emscripten_bind_b2PulleyJointDef__get_ratio_p0:so,_emscripten_bind_b2GearJoint__GetReactionForce_p1:lu,_emscripten_bind_b2Body__GetWorldCenter_p0:om,_emscripten_bind_b2RevoluteJointDef__set_enableMotor_p1:sd,_emscripten_bind_b2DistanceJointDef__set_localAnchorA_p1:tM,_emscripten_bind_b2BodyDef__set_angularDamping_p1:pK,_emscripten_bind_b2MouseJointDef__set_collideConnected_p1:tJ,_emscripten_bind_b2Shape__ComputeAABB_p3:ob,_emscripten_bind_b2Joint__GetReactionTorque_p1:kI,_emscripten_bind_b2WheelJoint__GetType_p0:j1,_emscripten_bind_b2Vec3__op_add_p1:qh,_emscripten_bind_b2Filter__get_categoryBits_p0:pm,_emscripten_bind_b2Vec3__set_z_p1:qe,_emscripten_bind_b2CircleShape__GetChildCount_p0:kp,_emscripten_bind_b2Transform__set_p_p1:sW,_emscripten_bind_b2Fixture__GetNext_p0:g_,_emscripten_bind_b2World__SetWarmStarting_p1:iS,_emscripten_bind_b2Vec3__op_sub_p0:qk,_emscripten_bind_b2ContactManager__Collide_p0:g6,_emscripten_bind_b2RevoluteJointDef__get_referenceAngle_p0:rY,_emscripten_bind_b2ContactManager__get_m_contactListener_p0:gA,_emscripten_bind_b2AABB__RayCast_p2:uc,_emscripten_bind_b2WeldJoint__Dump_p0:lJ,_emscripten_bind_b2PrismaticJointDef__set_enableLimit_p1:q4,_emscripten_bind_b2EdgeShape__GetType_p0:nd,_emscripten_bind_b2BodyDef__get_gravityScale_p0:pN,_emscripten_bind_b2DistanceProxy__set_m_vertices_p1:qs,_emscripten_bind_b2RevoluteJoint__SetMaxMotorTorque_p1:lX,_emscripten_bind_b2MouseJointDef__get_bodyA_p1:ty,_emscripten_bind_b2PulleyJoint__GetLengthB_p0:ib,_emscripten_bind_b2WeldJointDef__set_referenceAngle_p1:to,_emscripten_bind_b2BlockAllocator__Free_p2:mY,_emscripten_bind_b2PrismaticJointDef__get_localAnchorA_p0:re,_emscripten_bind_b2GearJoint__SetRatio_p1:lM,_emscripten_bind_b2BodyDef__get_angle_p0:pX,_emscripten_bind_b2PrismaticJoint__GetReferenceAngle_p0:ja,_emscripten_bind_b2WeldJointDef__set_bodyA_p1:tm,_emscripten_bind_b2DynamicTree__GetHeight_p0:k_,stackAlloc:bP,stackSave:bQ,stackRestore:bR,setThrew:bS,setTempRet0:bV,setTempRet1:bW,setTempRet2:bX,setTempRet3:bY,setTempRet4:bZ,setTempRet5:b_,setTempRet6:b$,setTempRet7:b0,setTempRet8:b1,setTempRet9:b2,dynCall_viiiii:vt,dynCall_vif:vO,dynCall_viifii:v7,dynCall_vi:ws,dynCall_vii:wN,dynCall_ii:w6,dynCall_viifi:xr,dynCall_if:xM,dynCall_iiiii:x5,dynCall_viffif:yq,dynCall_iiii:yL,dynCall_fif:y4,dynCall_viff:zp,dynCall_viiiiiiif:zK,dynCall_vifff:z3,dynCall_viiiiii:Ao,dynCall_iiif:AJ,dynCall_iif:A2,dynCall_vifii:Bn,dynCall_fi:BI,dynCall_iii:B1,dynCall_fiiiif:Cm,dynCall_i:CH,dynCall_iiiiii:C0,dynCall_ifff:Dl,dynCall_iff:DG,dynCall_viii:D$,dynCall_v:Ek,dynCall_viif:EF,dynCall_viiii:E_} +// EMSCRIPTEN_END_ASM +})({Math:Math,Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array},{abort:Ea,assert:qa,asmPrintInt:function(a,c){Module.print("int "+a+","+c)},asmPrintFloat:function(a,c){Module.print("float "+a+","+c)},min:Ic,jsCall:function(){var a=Array.prototype.slice.call(arguments);return sa[a[0]].apply(l,a.slice(1))},invoke_viiiii:function(a, +c,d,e,g,h){try{Module.dynCall_viiiii(a,c,d,e,g,h)}catch(i){"number"!==typeof i&&"longjmp"!==i&&b(i),x.setThrew(1,0)}},invoke_vif:function(a,c,d){try{Module.dynCall_vif(a,c,d)}catch(e){"number"!==typeof e&&"longjmp"!==e&&b(e),x.setThrew(1,0)}},invoke_viifii:function(a,c,d,e,g,h){try{Module.dynCall_viifii(a,c,d,e,g,h)}catch(i){"number"!==typeof i&&"longjmp"!==i&&b(i),x.setThrew(1,0)}},invoke_vi:function(a,c){try{Module.dynCall_vi(a,c)}catch(d){"number"!==typeof d&&"longjmp"!==d&&b(d),x.setThrew(1,0)}}, +invoke_vii:function(a,c,d){try{Module.dynCall_vii(a,c,d)}catch(e){"number"!==typeof e&&"longjmp"!==e&&b(e),x.setThrew(1,0)}},invoke_ii:function(a,c){try{return Module.dynCall_ii(a,c)}catch(d){"number"!==typeof d&&"longjmp"!==d&&b(d),x.setThrew(1,0)}},invoke_viifi:function(a,c,d,e,g){try{Module.dynCall_viifi(a,c,d,e,g)}catch(h){"number"!==typeof h&&"longjmp"!==h&&b(h),x.setThrew(1,0)}},invoke_if:function(a,c){try{return Module.dynCall_if(a,c)}catch(d){"number"!==typeof d&&"longjmp"!==d&&b(d),x.setThrew(1, +0)}},invoke_iiiii:function(a,c,d,e,g){try{return Module.dynCall_iiiii(a,c,d,e,g)}catch(h){"number"!==typeof h&&"longjmp"!==h&&b(h),x.setThrew(1,0)}},invoke_viffif:function(a,c,d,e,g,h){try{Module.dynCall_viffif(a,c,d,e,g,h)}catch(i){"number"!==typeof i&&"longjmp"!==i&&b(i),x.setThrew(1,0)}},invoke_iiii:function(a,c,d,e){try{return Module.dynCall_iiii(a,c,d,e)}catch(g){"number"!==typeof g&&"longjmp"!==g&&b(g),x.setThrew(1,0)}},invoke_fif:function(a,c,d){try{return Module.dynCall_fif(a,c,d)}catch(e){"number"!== +typeof e&&"longjmp"!==e&&b(e),x.setThrew(1,0)}},invoke_viff:function(a,c,d,e){try{Module.dynCall_viff(a,c,d,e)}catch(g){"number"!==typeof g&&"longjmp"!==g&&b(g),x.setThrew(1,0)}},invoke_viiiiiiif:function(a,c,d,e,g,h,i,k,r){try{Module.dynCall_viiiiiiif(a,c,d,e,g,h,i,k,r)}catch(H){"number"!==typeof H&&"longjmp"!==H&&b(H),x.setThrew(1,0)}},invoke_vifff:function(a,c,d,e,g){try{Module.dynCall_vifff(a,c,d,e,g)}catch(h){"number"!==typeof h&&"longjmp"!==h&&b(h),x.setThrew(1,0)}},invoke_viiiiii:function(a, +c,d,e,g,h,i){try{Module.dynCall_viiiiii(a,c,d,e,g,h,i)}catch(k){"number"!==typeof k&&"longjmp"!==k&&b(k),x.setThrew(1,0)}},invoke_iiif:function(a,c,d,e){try{return Module.dynCall_iiif(a,c,d,e)}catch(g){"number"!==typeof g&&"longjmp"!==g&&b(g),x.setThrew(1,0)}},invoke_iif:function(a,c,d){try{return Module.dynCall_iif(a,c,d)}catch(e){"number"!==typeof e&&"longjmp"!==e&&b(e),x.setThrew(1,0)}},invoke_vifii:function(a,c,d,e,g){try{Module.dynCall_vifii(a,c,d,e,g)}catch(h){"number"!==typeof h&&"longjmp"!== +h&&b(h),x.setThrew(1,0)}},invoke_fi:function(a,c){try{return Module.dynCall_fi(a,c)}catch(d){"number"!==typeof d&&"longjmp"!==d&&b(d),x.setThrew(1,0)}},invoke_iii:function(a,c,d){try{return Module.dynCall_iii(a,c,d)}catch(e){"number"!==typeof e&&"longjmp"!==e&&b(e),x.setThrew(1,0)}},invoke_fiiiif:function(a,c,d,e,g,h){try{return Module.dynCall_fiiiif(a,c,d,e,g,h)}catch(i){"number"!==typeof i&&"longjmp"!==i&&b(i),x.setThrew(1,0)}},invoke_i:function(a){try{return Module.dynCall_i(a)}catch(c){"number"!== +typeof c&&"longjmp"!==c&&b(c),x.setThrew(1,0)}},invoke_iiiiii:function(a,c,d,e,g,h){try{return Module.dynCall_iiiiii(a,c,d,e,g,h)}catch(i){"number"!==typeof i&&"longjmp"!==i&&b(i),x.setThrew(1,0)}},invoke_ifff:function(a,c,d,e){try{return Module.dynCall_ifff(a,c,d,e)}catch(g){"number"!==typeof g&&"longjmp"!==g&&b(g),x.setThrew(1,0)}},invoke_iff:function(a,c,d){try{return Module.dynCall_iff(a,c,d)}catch(e){"number"!==typeof e&&"longjmp"!==e&&b(e),x.setThrew(1,0)}},invoke_viii:function(a,c,d,e){try{Module.dynCall_viii(a, +c,d,e)}catch(g){"number"!==typeof g&&"longjmp"!==g&&b(g),x.setThrew(1,0)}},invoke_v:function(a){try{Module.dynCall_v(a)}catch(c){"number"!==typeof c&&"longjmp"!==c&&b(c),x.setThrew(1,0)}},invoke_viif:function(a,c,d,e){try{Module.dynCall_viif(a,c,d,e)}catch(g){"number"!==typeof g&&"longjmp"!==g&&b(g),x.setThrew(1,0)}},invoke_viiii:function(a,c,d,e,g){try{Module.dynCall_viiii(a,c,d,e,g)}catch(h){"number"!==typeof h&&"longjmp"!==h&&b(h),x.setThrew(1,0)}},_llvm_va_end:aa(),_cosf:Cb,_floorf:Db,___cxa_throw:tc, +_abort:function(){Ha=j;b("abort() at "+Error().stack)},_fprintf:lc,_llvm_eh_exception:pc,_printf:mc,_sqrtf:zb,__ZNK12b2WheelJoint13GetDefinitionEP15b2WheelJointDef:function(){Module.printErr("missing function: _ZNK12b2WheelJoint13GetDefinitionEP15b2WheelJointDef");Ea(-1)},___setErrNo:Lb,_fwrite:gc,_send:dc,_write:fc,_exit:function(a){xb(a)},_llvm_lifetime_end:aa(),___cxa_find_matching_catch:function(a,c){-1==a&&(a=q[pc.e>>2]);-1==c&&(c=q[pc.e+4>>2]);var d=Array.prototype.slice.call(arguments,2);0!= +c&&!rc(c)&&0==q[q[c>>2]-8>>2]&&(a=q[a>>2]);for(var e=0;e>2])},___cxa_is_number_type:rc,__reallyNegative:ic,___resumeException:function(a){0==q[pc.e>>2]&&(q[pc.e>>2]=a);b(a+" - Exception catching is disabled, this exception cannot be caught. Compile with -s DISABLE_EXCEPTION_CATCHING=0 or DISABLE_EXCEPTION_CATCHING=2 to catch.")},__formatString:jc,___cxa_does_inherit:sc,__ZSt9terminatev:function(){xb(-1234)},_sinf:Bb,___assert_func:function(a,c,d,e){b("Assertion failed: "+(e?Oa(e):"unknown condition")+", at: "+[a?Oa(a):"unknown filename",c,d?Oa(d): +"unknown function"]+" at "+Error().stack)},__ZSt18uncaught_exceptionv:qc,_pwrite:ec,___cxa_call_unexpected:function(a){Module.i("Unexpected exception thrown, this is not properly supported - aborting");Ha=j;b(a)},_sbrk:oc,___cxa_allocate_exception:function(a){return Ya(a)},___errno_location:function(){return Kb},___gxx_personality_v0:aa(),_llvm_lifetime_start:aa(),_time:function(a){var c=Math.floor(Date.now()/1E3);a&&(q[a>>2]=c);return c},__exit:xb,STACKTOP:ka,STACK_MAX:db,tempDoublePtr:wb,ABORT:Ha, +NaN:NaN,Infinity:Infinity,__ZTVN10__cxxabiv120__si_class_type_infoE:s,__ZTVN10__cxxabiv117__class_type_infoE:t},fb),Jc=Module._emscripten_bind_b2WheelJoint__GetSpringFrequencyHz_p0=x._emscripten_bind_b2WheelJoint__GetSpringFrequencyHz_p0,Kc=Module._emscripten_bind_b2Fixture__SetRestitution_p1=x._emscripten_bind_b2Fixture__SetRestitution_p1,Lc=Module._emscripten_bind_b2PolygonShape____destroy___p0=x._emscripten_bind_b2PolygonShape____destroy___p0,Mc=Module._emscripten_bind_b2RevoluteJoint__EnableLimit_p1= +x._emscripten_bind_b2RevoluteJoint__EnableLimit_p1,Nc=Module._emscripten_bind_b2DistanceProxy__get_m_vertices_p0=x._emscripten_bind_b2DistanceProxy__get_m_vertices_p0,Oc=Module._emscripten_bind_b2PrismaticJoint__EnableLimit_p1=x._emscripten_bind_b2PrismaticJoint__EnableLimit_p1,Pc=Module._emscripten_bind_b2WheelJointDef__Initialize_p4=x._emscripten_bind_b2WheelJointDef__Initialize_p4,Qc=Module._emscripten_bind_b2DistanceJointDef__set_frequencyHz_p1=x._emscripten_bind_b2DistanceJointDef__set_frequencyHz_p1, +Rc=Module._emscripten_bind_b2PrismaticJoint__GetMotorForce_p1=x._emscripten_bind_b2PrismaticJoint__GetMotorForce_p1,Sc=Module._emscripten_bind_b2Body__IsSleepingAllowed_p0=x._emscripten_bind_b2Body__IsSleepingAllowed_p0,Tc=Module._emscripten_bind_b2Vec2__b2Vec2_p2=x._emscripten_bind_b2Vec2__b2Vec2_p2,Uc=Module._emscripten_bind_b2RevoluteJoint__GetMaxMotorTorque_p0=x._emscripten_bind_b2RevoluteJoint__GetMaxMotorTorque_p0,Vc=Module._emscripten_bind_b2WeldJoint__GetFrequency_p0=x._emscripten_bind_b2WeldJoint__GetFrequency_p0, +Wc=Module._emscripten_bind_b2MouseJoint__GetType_p0=x._emscripten_bind_b2MouseJoint__GetType_p0,Xc=Module._emscripten_bind_b2RayCastCallback__b2RayCastCallback_p0=x._emscripten_bind_b2RayCastCallback__b2RayCastCallback_p0,Yc=Module._emscripten_bind_b2Body__GetLinearDamping_p0=x._emscripten_bind_b2Body__GetLinearDamping_p0,Zc=Module._emscripten_bind_b2Vec2__b2Vec2_p0=x._emscripten_bind_b2Vec2__b2Vec2_p0,$c=Module._emscripten_bind_b2PrismaticJoint__GetType_p0=x._emscripten_bind_b2PrismaticJoint__GetType_p0, +ad=Module._emscripten_bind_b2PrismaticJoint____destroy___p0=x._emscripten_bind_b2PrismaticJoint____destroy___p0,bd=Module._emscripten_bind_b2WheelJointDef__set_frequencyHz_p1=x._emscripten_bind_b2WheelJointDef__set_frequencyHz_p1,cd=Module._emscripten_bind_b2BlockAllocator____destroy___p0=x._emscripten_bind_b2BlockAllocator____destroy___p0,dd=Module._emscripten_bind_b2Vec2__op_add_p1=x._emscripten_bind_b2Vec2__op_add_p1,ed=Module._emscripten_bind_b2World__GetJointList_p0=x._emscripten_bind_b2World__GetJointList_p0, +fd=Module._emscripten_bind_b2Transform__Set_p2=x._emscripten_bind_b2Transform__Set_p2,gd=Module._emscripten_bind_b2EdgeShape__RayCast_p4=x._emscripten_bind_b2EdgeShape__RayCast_p4,hd=Module._emscripten_bind_b2RevoluteJoint__GetLocalAnchorA_p0=x._emscripten_bind_b2RevoluteJoint__GetLocalAnchorA_p0,id=Module._emscripten_bind_b2DistanceJoint__GetDampingRatio_p0=x._emscripten_bind_b2DistanceJoint__GetDampingRatio_p0,jd=Module._emscripten_bind_b2PulleyJointDef__set_bodyA_p1=x._emscripten_bind_b2PulleyJointDef__set_bodyA_p1, +kd=Module._emscripten_bind_b2DynamicTree__Validate_p0=x._emscripten_bind_b2DynamicTree__Validate_p0,ld=Module._emscripten_bind_b2DynamicTree__DestroyProxy_p1=x._emscripten_bind_b2DynamicTree__DestroyProxy_p1,md=Module._emscripten_bind_b2Joint__IsActive_p0=x._emscripten_bind_b2Joint__IsActive_p0,nd=Module._emscripten_bind_b2PulleyJoint__GetNext_p0=x._emscripten_bind_b2PulleyJoint__GetNext_p0,od=Module._emscripten_bind_b2RevoluteJointDef__get_localAnchorA_p0=x._emscripten_bind_b2RevoluteJointDef__get_localAnchorA_p0, +pd=Module._emscripten_bind_b2GearJoint__IsActive_p0=x._emscripten_bind_b2GearJoint__IsActive_p0,qd=Module._emscripten_bind_b2EdgeShape__get_m_radius_p0=x._emscripten_bind_b2EdgeShape__get_m_radius_p0,rd=Module._emscripten_bind_b2PrismaticJointDef__get_localAnchorB_p0=x._emscripten_bind_b2PrismaticJointDef__get_localAnchorB_p0,sd=Module._emscripten_bind_b2RevoluteJointDef__set_bodyA_p1=x._emscripten_bind_b2RevoluteJointDef__set_bodyA_p1,td=Module._emscripten_bind_b2World__GetJointCount_p0=x._emscripten_bind_b2World__GetJointCount_p0, +ud=Module._emscripten_bind_b2DynamicTree__CreateProxy_p2=x._emscripten_bind_b2DynamicTree__CreateProxy_p2,vd=Module._emscripten_bind_b2WheelJointDef__set_collideConnected_p1=x._emscripten_bind_b2WheelJointDef__set_collideConnected_p1,wd=Module._emscripten_bind_b2WeldJoint__GetLocalAnchorA_p0=x._emscripten_bind_b2WeldJoint__GetLocalAnchorA_p0,xd=Module._emscripten_bind_b2RevoluteJointDef__get_localAnchorB_p0=x._emscripten_bind_b2RevoluteJointDef__get_localAnchorB_p0,yd=Module._emscripten_bind_b2Body__GetGravityScale_p0= +x._emscripten_bind_b2Body__GetGravityScale_p0,zd=Module._emscripten_bind_b2Fixture__Dump_p1=x._emscripten_bind_b2Fixture__Dump_p1,Ad=Module._emscripten_bind_b2World__GetBodyList_p0=x._emscripten_bind_b2World__GetBodyList_p0,Bd=Module._emscripten_bind_b2PulleyJoint__IsActive_p0=x._emscripten_bind_b2PulleyJoint__IsActive_p0,Cd=Module._emscripten_bind_b2MouseJoint__SetUserData_p1=x._emscripten_bind_b2MouseJoint__SetUserData_p1,Dd=Module._emscripten_bind_b2World__GetContactList_p0=x._emscripten_bind_b2World__GetContactList_p0, +Ed=Module._emscripten_bind_b2PrismaticJoint__GetNext_p0=x._emscripten_bind_b2PrismaticJoint__GetNext_p0,Fd=Module._emscripten_bind_b2Vec2__Skew_p0=x._emscripten_bind_b2Vec2__Skew_p0,Gd=Module._emscripten_bind_b2BodyDef__get_linearVelocity_p0=x._emscripten_bind_b2BodyDef__get_linearVelocity_p0,Hd=Module._emscripten_bind_b2Body__GetPosition_p0=x._emscripten_bind_b2Body__GetPosition_p0,Id=Module._emscripten_bind_b2WheelJoint__GetReactionForce_p1=x._emscripten_bind_b2WheelJoint__GetReactionForce_p1,Jd= +Module._emscripten_bind_b2PrismaticJointDef__set_motorSpeed_p1=x._emscripten_bind_b2PrismaticJointDef__set_motorSpeed_p1,Kd=Module._emscripten_bind_b2PrismaticJoint__SetMaxMotorForce_p1=x._emscripten_bind_b2PrismaticJoint__SetMaxMotorForce_p1,Ld=Module._emscripten_bind_b2ChainShape__b2ChainShape_p0=x._emscripten_bind_b2ChainShape__b2ChainShape_p0,Md=Module._emscripten_bind_b2CircleShape__RayCast_p4=x._emscripten_bind_b2CircleShape__RayCast_p4,Nd=Module._emscripten_bind_b2WheelJoint__GetBodyA_p0=x._emscripten_bind_b2WheelJoint__GetBodyA_p0, +Od=Module._emscripten_bind_b2RevoluteJointDef__set_bodyB_p1=x._emscripten_bind_b2RevoluteJointDef__set_bodyB_p1,Pd=Module._emscripten_bind_b2MouseJointDef__get_dampingRatio_p0=x._emscripten_bind_b2MouseJointDef__get_dampingRatio_p0,Qd=Module._emscripten_bind_b2JointDef__set_bodyB_p1=x._emscripten_bind_b2JointDef__set_bodyB_p1,Rd=Module._emscripten_bind_b2RevoluteJoint__GetJointSpeed_p0=x._emscripten_bind_b2RevoluteJoint__GetJointSpeed_p0,Sd=Module._emscripten_bind_b2RopeJoint__GetLocalAnchorB_p0= +x._emscripten_bind_b2RopeJoint__GetLocalAnchorB_p0,Td=Module._emscripten_bind_b2Fixture__GetAABB_p1=x._emscripten_bind_b2Fixture__GetAABB_p1,Ud=Module._emscripten_bind_b2BroadPhase__TouchProxy_p1=x._emscripten_bind_b2BroadPhase__TouchProxy_p1,Vd=Module._emscripten_bind_b2FixtureDef__set_isSensor_p1=x._emscripten_bind_b2FixtureDef__set_isSensor_p1,Wd=Module._emscripten_bind_b2World__GetAllowSleeping_p0=x._emscripten_bind_b2World__GetAllowSleeping_p0,Xd=Module._emscripten_bind_b2DestructionListener____destroy___p0= +x._emscripten_bind_b2DestructionListener____destroy___p0,Yd=Module._emscripten_bind_b2BroadPhase____destroy___p0=x._emscripten_bind_b2BroadPhase____destroy___p0,Zd=Module._emscripten_bind_b2World__GetWarmStarting_p0=x._emscripten_bind_b2World__GetWarmStarting_p0,$d=Module._emscripten_bind_b2Rot__b2Rot_p1=x._emscripten_bind_b2Rot__b2Rot_p1,ae=Module._emscripten_bind_b2Rot__b2Rot_p0=x._emscripten_bind_b2Rot__b2Rot_p0,be=Module._emscripten_bind_b2DistanceJoint__GetUserData_p0=x._emscripten_bind_b2DistanceJoint__GetUserData_p0, +ce=Module._emscripten_bind_b2MouseJointDef__get_frequencyHz_p0=x._emscripten_bind_b2MouseJointDef__get_frequencyHz_p0,de=Module._emscripten_bind_b2ContactManager__set_m_allocator_p1=x._emscripten_bind_b2ContactManager__set_m_allocator_p1,ee=Module._emscripten_bind_b2WheelJoint__SetMaxMotorTorque_p1=x._emscripten_bind_b2WheelJoint__SetMaxMotorTorque_p1,fe=Module._emscripten_bind_b2RopeJointDef__get_collideConnected_p1=x._emscripten_bind_b2RopeJointDef__get_collideConnected_p1,ge=Module._emscripten_bind_b2MouseJointDef__get_target_p0= +x._emscripten_bind_b2MouseJointDef__get_target_p0,he=Module._emscripten_bind_b2WeldJoint__SetUserData_p1=x._emscripten_bind_b2WeldJoint__SetUserData_p1,ie=Module._emscripten_bind_b2PrismaticJoint__GetBodyA_p0=x._emscripten_bind_b2PrismaticJoint__GetBodyA_p0,je=Module._emscripten_bind_b2FrictionJointDef____destroy___p0=x._emscripten_bind_b2FrictionJointDef____destroy___p0,ke=Module._emscripten_bind_b2RopeJoint__GetMaxLength_p0=x._emscripten_bind_b2RopeJoint__GetMaxLength_p0,le=Module._emscripten_bind_b2MouseJoint__GetDampingRatio_p0= +x._emscripten_bind_b2MouseJoint__GetDampingRatio_p0,me=Module._emscripten_bind_b2DistanceJoint__GetNext_p0=x._emscripten_bind_b2DistanceJoint__GetNext_p0,ne=Module._emscripten_bind_b2Filter__get_maskBits_p0=x._emscripten_bind_b2Filter__get_maskBits_p0,oe=Module._emscripten_bind_b2RayCastCallback____destroy___p0=x._emscripten_bind_b2RayCastCallback____destroy___p0,pe=Module._emscripten_bind_b2World__Dump_p0=x._emscripten_bind_b2World__Dump_p0,qe=Module._emscripten_bind_b2RevoluteJointDef____destroy___p0= +x._emscripten_bind_b2RevoluteJointDef____destroy___p0,re=Module._emscripten_bind_b2PrismaticJoint__GetAnchorA_p0=x._emscripten_bind_b2PrismaticJoint__GetAnchorA_p0,se=Module._emscripten_bind_b2BodyDef__get_bullet_p0=x._emscripten_bind_b2BodyDef__get_bullet_p0,te=Module._emscripten_bind_b2Body__SetAngularDamping_p1=x._emscripten_bind_b2Body__SetAngularDamping_p1,ue=Module._emscripten_bind_b2DynamicTree__RebuildBottomUp_p0=x._emscripten_bind_b2DynamicTree__RebuildBottomUp_p0,ve=Module._emscripten_bind_b2Fixture__GetFilterData_p0= +x._emscripten_bind_b2Fixture__GetFilterData_p0,we=Module._emscripten_bind_b2DistanceJoint__SetLength_p1=x._emscripten_bind_b2DistanceJoint__SetLength_p1,xe=Module._emscripten_bind_b2BodyDef__get_position_p0=x._emscripten_bind_b2BodyDef__get_position_p0,ye=Module._emscripten_bind_b2FrictionJoint__GetUserData_p0=x._emscripten_bind_b2FrictionJoint__GetUserData_p0,ze=Module._emscripten_bind_b2PolygonShape__get_m_radius_p0=x._emscripten_bind_b2PolygonShape__get_m_radius_p0,Ae=Module._emscripten_bind_b2ContactEdge__set_next_p1= +x._emscripten_bind_b2ContactEdge__set_next_p1,Be=Module._emscripten_bind_b2Transform__b2Transform_p2=x._emscripten_bind_b2Transform__b2Transform_p2,Ce=Module._emscripten_bind_b2FrictionJointDef__get_maxTorque_p0=x._emscripten_bind_b2FrictionJointDef__get_maxTorque_p0,De=Module._emscripten_bind_b2WeldJointDef__set_localAnchorB_p1=x._emscripten_bind_b2WeldJointDef__set_localAnchorB_p1,Ee=Module._emscripten_bind_b2World__GetProxyCount_p0=x._emscripten_bind_b2World__GetProxyCount_p0,Fe=Module._emscripten_bind_b2WeldJointDef__get_bodyB_p1= +x._emscripten_bind_b2WeldJointDef__get_bodyB_p1,Ge=Module._emscripten_bind_b2PrismaticJointDef__set_lowerTranslation_p1=x._emscripten_bind_b2PrismaticJointDef__set_lowerTranslation_p1,He=Module._emscripten_bind_b2PolygonShape__set_m_centroid_p1=x._emscripten_bind_b2PolygonShape__set_m_centroid_p1,Ie=Module._emscripten_bind_b2GearJoint__GetAnchorA_p0=x._emscripten_bind_b2GearJoint__GetAnchorA_p0,Je=Module._emscripten_bind_b2PulleyJointDef__get_collideConnected_p1=x._emscripten_bind_b2PulleyJointDef__get_collideConnected_p1, +Ke=Module._emscripten_bind_b2Vec3____destroy___p0=x._emscripten_bind_b2Vec3____destroy___p0,Le=Module._emscripten_bind_b2Color__set_r_p1=x._emscripten_bind_b2Color__set_r_p1,Me=Module._emscripten_bind_b2PrismaticJointDef__get_enableMotor_p0=x._emscripten_bind_b2PrismaticJointDef__get_enableMotor_p0,Ne=Module._emscripten_bind_b2BodyDef__get_linearDamping_p0=x._emscripten_bind_b2BodyDef__get_linearDamping_p0,Oe=Module._emscripten_bind_b2EdgeShape__ComputeMass_p2=x._emscripten_bind_b2EdgeShape__ComputeMass_p2, +Pe=Module._emscripten_bind_b2RayCastCallback__ReportFixture_p4=x._emscripten_bind_b2RayCastCallback__ReportFixture_p4,Qe=Module._emscripten_bind_b2Body__Dump_p0=x._emscripten_bind_b2Body__Dump_p0,Re=Module._emscripten_bind_b2BodyDef__get_allowSleep_p0=x._emscripten_bind_b2BodyDef__get_allowSleep_p0,Se=Module._emscripten_bind_b2AABB__get_lowerBound_p0=x._emscripten_bind_b2AABB__get_lowerBound_p0,Te=Module._emscripten_bind_b2PulleyJoint__GetAnchorB_p0=x._emscripten_bind_b2PulleyJoint__GetAnchorB_p0, +Ue=Module._emscripten_bind_b2PrismaticJoint__GetReactionTorque_p1=x._emscripten_bind_b2PrismaticJoint__GetReactionTorque_p1,Ve=Module._emscripten_bind_b2JointDef__set_bodyA_p1=x._emscripten_bind_b2JointDef__set_bodyA_p1,We=Module._emscripten_bind_b2PrismaticJoint__GetBodyB_p0=x._emscripten_bind_b2PrismaticJoint__GetBodyB_p0,Xe=Module._emscripten_bind_b2DistanceJoint__GetLocalAnchorA_p0=x._emscripten_bind_b2DistanceJoint__GetLocalAnchorA_p0,Ye=Module._emscripten_bind_b2RopeJoint__GetLocalAnchorA_p0= +x._emscripten_bind_b2RopeJoint__GetLocalAnchorA_p0,Ze=Module._emscripten_bind_b2Rot__set_c_p1=x._emscripten_bind_b2Rot__set_c_p1,$e=Module._emscripten_bind_b2Vec3__op_mul_p1=x._emscripten_bind_b2Vec3__op_mul_p1,af=Module._emscripten_bind_b2StackAllocator__GetMaxAllocation_p0=x._emscripten_bind_b2StackAllocator__GetMaxAllocation_p0,bf=Module._emscripten_bind_b2MouseJoint__SetFrequency_p1=x._emscripten_bind_b2MouseJoint__SetFrequency_p1,cf=Module._emscripten_bind_b2WeldJoint__GetAnchorA_p0=x._emscripten_bind_b2WeldJoint__GetAnchorA_p0, +df=Module._emscripten_bind_b2World__SetAutoClearForces_p1=x._emscripten_bind_b2World__SetAutoClearForces_p1,ef=Module._emscripten_bind_b2Contact__SetEnabled_p1=x._emscripten_bind_b2Contact__SetEnabled_p1,ff=Module._emscripten_bind_b2ContactManager__get_m_contactFilter_p0=x._emscripten_bind_b2ContactManager__get_m_contactFilter_p0,gf=Module._emscripten_bind_b2BodyDef__get_angularDamping_p0=x._emscripten_bind_b2BodyDef__get_angularDamping_p0,hf=Module._emscripten_bind_b2WeldJointDef__set_localAnchorA_p1= +x._emscripten_bind_b2WeldJointDef__set_localAnchorA_p1,jf=Module._emscripten_bind_b2DistanceJoint__GetBodyB_p0=x._emscripten_bind_b2DistanceJoint__GetBodyB_p0,kf=Module._emscripten_bind_b2PulleyJointDef__set_lengthB_p1=x._emscripten_bind_b2PulleyJointDef__set_lengthB_p1,lf=Module._emscripten_bind_b2Vec2__op_sub_p0=x._emscripten_bind_b2Vec2__op_sub_p0,mf=Module._emscripten_bind_b2PrismaticJoint__GetLocalAnchorB_p0=x._emscripten_bind_b2PrismaticJoint__GetLocalAnchorB_p0,nf=Module._emscripten_bind_b2RopeJointDef__get_localAnchorB_p0= +x._emscripten_bind_b2RopeJointDef__get_localAnchorB_p0,of=Module._emscripten_bind_b2Contact__GetChildIndexB_p0=x._emscripten_bind_b2Contact__GetChildIndexB_p0,pf=Module._emscripten_bind_b2Fixture__TestPoint_p1=x._emscripten_bind_b2Fixture__TestPoint_p1,qf=Module._emscripten_bind_b2FixtureDef__get_shape_p0=x._emscripten_bind_b2FixtureDef__get_shape_p0,rf=Module._emscripten_bind_b2WheelJointDef__get_bodyB_p1=x._emscripten_bind_b2WheelJointDef__get_bodyB_p1,sf=Module._emscripten_bind_b2RevoluteJointDef__get_enableLimit_p0= +x._emscripten_bind_b2RevoluteJointDef__get_enableLimit_p0,tf=Module._emscripten_bind_b2BodyDef__set_linearVelocity_p1=x._emscripten_bind_b2BodyDef__set_linearVelocity_p1,uf=Module._emscripten_bind_b2Body__GetMass_p0=x._emscripten_bind_b2Body__GetMass_p0,vf=Module._emscripten_bind_b2WeldJoint____destroy___p0=x._emscripten_bind_b2WeldJoint____destroy___p0,wf=Module._emscripten_bind_b2WheelJoint__GetSpringDampingRatio_p0=x._emscripten_bind_b2WheelJoint__GetSpringDampingRatio_p0,xf=Module._emscripten_bind_b2RopeJointDef__set_localAnchorB_p1= +x._emscripten_bind_b2RopeJointDef__set_localAnchorB_p1,yf=Module._emscripten_bind_b2Body__IsFixedRotation_p0=x._emscripten_bind_b2Body__IsFixedRotation_p0,zf=Module._emscripten_bind_b2Rot__SetIdentity_p0=x._emscripten_bind_b2Rot__SetIdentity_p0,Af=Module._emscripten_bind_b2WheelJoint__SetSpringDampingRatio_p1=x._emscripten_bind_b2WheelJoint__SetSpringDampingRatio_p1,Bf=Module._emscripten_bind_b2Joint__SetUserData_p1=x._emscripten_bind_b2Joint__SetUserData_p1,Cf=Module._emscripten_bind_b2FrictionJoint__IsActive_p0= +x._emscripten_bind_b2FrictionJoint__IsActive_p0,Df=Module._emscripten_bind_b2JointDef__get_userData_p0=x._emscripten_bind_b2JointDef__get_userData_p0,Ef=Module._emscripten_bind_b2Draw__DrawPolygon_p3=x._emscripten_bind_b2Draw__DrawPolygon_p3,Ff=Module._emscripten_bind_b2MouseJoint__GetBodyB_p0=x._emscripten_bind_b2MouseJoint__GetBodyB_p0,Gf=Module._emscripten_bind_b2DistanceJointDef__get_dampingRatio_p0=x._emscripten_bind_b2DistanceJointDef__get_dampingRatio_p0,Hf=Module._emscripten_bind_b2ContactManager__get_m_broadPhase_p0= +x._emscripten_bind_b2ContactManager__get_m_broadPhase_p0,If=Module._emscripten_bind_b2RopeJoint__GetReactionTorque_p1=x._emscripten_bind_b2RopeJoint__GetReactionTorque_p1,Jf=Module._emscripten_bind_b2PrismaticJoint__GetLowerLimit_p0=x._emscripten_bind_b2PrismaticJoint__GetLowerLimit_p0,Kf=Module._emscripten_bind_b2Contact__GetManifold_p0=x._emscripten_bind_b2Contact__GetManifold_p0,Lf=Module._emscripten_bind_b2Contact__SetFriction_p1=x._emscripten_bind_b2Contact__SetFriction_p1,Mf=Module._emscripten_bind_b2WheelJoint__GetJointSpeed_p0= +x._emscripten_bind_b2WheelJoint__GetJointSpeed_p0,Nf=Module._emscripten_bind_b2BodyDef__set_allowSleep_p1=x._emscripten_bind_b2BodyDef__set_allowSleep_p1,Of=Module._emscripten_bind_b2Fixture__RayCast_p3=x._emscripten_bind_b2Fixture__RayCast_p3,Pf=Module._emscripten_bind_b2WeldJointDef__get_referenceAngle_p0=x._emscripten_bind_b2WeldJointDef__get_referenceAngle_p0,Qf=Module._emscripten_bind_b2Fixture____destroy___p0=x._emscripten_bind_b2Fixture____destroy___p0,Rf=Module._emscripten_bind_b2RopeJointDef__set_localAnchorA_p1= +x._emscripten_bind_b2RopeJointDef__set_localAnchorA_p1,Sf=Module._emscripten_bind_b2WheelJoint__SetUserData_p1=x._emscripten_bind_b2WheelJoint__SetUserData_p1,Tf=Module._emscripten_bind_b2WeldJoint__b2WeldJoint_p1=x._emscripten_bind_b2WeldJoint__b2WeldJoint_p1,Uf=Module._emscripten_bind_b2WeldJoint__IsActive_p0=x._emscripten_bind_b2WeldJoint__IsActive_p0,Vf=Module._emscripten_bind_b2Draw__DrawSolidPolygon_p3=x._emscripten_bind_b2Draw__DrawSolidPolygon_p3,Wf=Module._emscripten_bind_b2ContactManager____destroy___p0= +x._emscripten_bind_b2ContactManager____destroy___p0,Xf=Module._emscripten_bind_b2GearJoint__GetAnchorB_p0=x._emscripten_bind_b2GearJoint__GetAnchorB_p0,Yf=Module._emscripten_bind_b2PrismaticJointDef__get_lowerTranslation_p0=x._emscripten_bind_b2PrismaticJointDef__get_lowerTranslation_p0,Zf=Module._emscripten_bind_b2PolygonShape__get_m_vertexCount_p0=x._emscripten_bind_b2PolygonShape__get_m_vertexCount_p0,$f=Module._emscripten_bind_b2RevoluteJoint__GetReferenceAngle_p0=x._emscripten_bind_b2RevoluteJoint__GetReferenceAngle_p0, +ag=Module._emscripten_bind_b2DistanceJointDef__Initialize_p4=x._emscripten_bind_b2DistanceJointDef__Initialize_p4,bg=Module._emscripten_bind_b2World__IsLocked_p0=x._emscripten_bind_b2World__IsLocked_p0,cg=Module._emscripten_bind_b2ContactEdge__get_prev_p0=x._emscripten_bind_b2ContactEdge__get_prev_p0,dg=Module._emscripten_bind_b2Joint__GetReactionForce_p1=x._emscripten_bind_b2Joint__GetReactionForce_p1,eg=Module._emscripten_bind_b2WeldJointDef__get_collideConnected_p1=x._emscripten_bind_b2WeldJointDef__get_collideConnected_p1, +fg=Module._emscripten_bind_b2Draw__AppendFlags_p1=x._emscripten_bind_b2Draw__AppendFlags_p1,gg=Module._emscripten_bind_b2PrismaticJointDef__get_maxMotorForce_p0=x._emscripten_bind_b2PrismaticJointDef__get_maxMotorForce_p0,hg=Module._emscripten_bind_b2PrismaticJointDef__set_upperTranslation_p1=x._emscripten_bind_b2PrismaticJointDef__set_upperTranslation_p1,ig=Module._emscripten_bind_b2PrismaticJoint__EnableMotor_p1=x._emscripten_bind_b2PrismaticJoint__EnableMotor_p1,jg=Module._emscripten_bind_b2PrismaticJoint__GetReactionForce_p1= +x._emscripten_bind_b2PrismaticJoint__GetReactionForce_p1,kg=Module._emscripten_bind_b2Shape__RayCast_p4=x._emscripten_bind_b2Shape__RayCast_p4,lg=Module._emscripten_bind_b2GearJoint__Dump_p0=x._emscripten_bind_b2GearJoint__Dump_p0,mg=Module._emscripten_bind_b2Body__DestroyFixture_p1=x._emscripten_bind_b2Body__DestroyFixture_p1,ng=Module._emscripten_bind_b2Body__SetActive_p1=x._emscripten_bind_b2Body__SetActive_p1,og=Module._emscripten_bind_b2PrismaticJoint__GetCollideConnected_p0=x._emscripten_bind_b2PrismaticJoint__GetCollideConnected_p0, +pg=Module._emscripten_bind_b2ContactListener____destroy___p0=x._emscripten_bind_b2ContactListener____destroy___p0,qg=Module._emscripten_bind_b2MouseJoint__SetDampingRatio_p1=x._emscripten_bind_b2MouseJoint__SetDampingRatio_p1,rg=Module._emscripten_bind_b2Body__ApplyTorque_p1=x._emscripten_bind_b2Body__ApplyTorque_p1,sg=Module._emscripten_bind_b2DistanceProxy__GetVertexCount_p0=x._emscripten_bind_b2DistanceProxy__GetVertexCount_p0,tg=Module._emscripten_bind_b2PulleyJoint__GetRatio_p0=x._emscripten_bind_b2PulleyJoint__GetRatio_p0, +ug=Module._emscripten_bind_b2FixtureDef__set_density_p1=x._emscripten_bind_b2FixtureDef__set_density_p1,vg=Module._emscripten_bind_b2RopeJoint__b2RopeJoint_p1=x._emscripten_bind_b2RopeJoint__b2RopeJoint_p1,wg=Module._emscripten_bind_b2FixtureDef__get_filter_p0=x._emscripten_bind_b2FixtureDef__get_filter_p0,xg=Module._emscripten_bind_b2WheelJoint__GetUserData_p0=x._emscripten_bind_b2WheelJoint__GetUserData_p0,yg=Module._emscripten_bind_b2GearJointDef__set_collideConnected_p1=x._emscripten_bind_b2GearJointDef__set_collideConnected_p1, +zg=Module._emscripten_bind_b2GearJoint____destroy___p0=x._emscripten_bind_b2GearJoint____destroy___p0,Ag=Module._emscripten_bind_b2Body__GetAngularVelocity_p0=x._emscripten_bind_b2Body__GetAngularVelocity_p0,Bg=Module._emscripten_bind_b2DistanceJointDef__get_bodyA_p1=x._emscripten_bind_b2DistanceJointDef__get_bodyA_p1,Cg=Module._emscripten_bind_b2RevoluteJoint__EnableMotor_p1=x._emscripten_bind_b2RevoluteJoint__EnableMotor_p1,Dg=Module._emscripten_bind_b2Body__SetType_p1=x._emscripten_bind_b2Body__SetType_p1, +Eg=Module._emscripten_bind_b2PolygonShape__set_m_vertexCount_p1=x._emscripten_bind_b2PolygonShape__set_m_vertexCount_p1,Fg=Module._emscripten_bind_b2RopeJointDef__set_collideConnected_p1=x._emscripten_bind_b2RopeJointDef__set_collideConnected_p1,Gg=Module._emscripten_bind_b2FrictionJoint__GetBodyB_p0=x._emscripten_bind_b2FrictionJoint__GetBodyB_p0,Hg=Module._emscripten_bind_b2RevoluteJoint__IsLimitEnabled_p0=x._emscripten_bind_b2RevoluteJoint__IsLimitEnabled_p0,Ig=Module._emscripten_bind_b2FrictionJointDef__set_maxForce_p1= +x._emscripten_bind_b2FrictionJointDef__set_maxForce_p1,Jg=Module._emscripten_bind_b2Timer__GetMilliseconds_p0=x._emscripten_bind_b2Timer__GetMilliseconds_p0,Kg=Module._emscripten_bind_b2WheelJointDef__get_enableMotor_p0=x._emscripten_bind_b2WheelJointDef__get_enableMotor_p0,Lg=Module._emscripten_bind_b2RevoluteJointDef__get_bodyB_p1=x._emscripten_bind_b2RevoluteJointDef__get_bodyB_p1,Mg=Module._emscripten_bind_b2PolygonShape__GetChildCount_p0=x._emscripten_bind_b2PolygonShape__GetChildCount_p0,Ng= +Module._emscripten_bind_b2BlockAllocator__b2BlockAllocator_p0=x._emscripten_bind_b2BlockAllocator__b2BlockAllocator_p0,Og=Module._emscripten_bind_b2ContactEdge__set_other_p1=x._emscripten_bind_b2ContactEdge__set_other_p1,Pg=Module._emscripten_bind_b2Body__GetMassData_p1=x._emscripten_bind_b2Body__GetMassData_p1,Qg=Module._emscripten_bind_b2Joint__GetNext_p0=x._emscripten_bind_b2Joint__GetNext_p0,Rg=Module._emscripten_bind_b2WeldJoint__GetReactionForce_p1=x._emscripten_bind_b2WeldJoint__GetReactionForce_p1, +Sg=Module._emscripten_bind_b2RevoluteJoint__GetAnchorA_p0=x._emscripten_bind_b2RevoluteJoint__GetAnchorA_p0,Tg=Module._emscripten_bind_b2Filter__set_groupIndex_p1=x._emscripten_bind_b2Filter__set_groupIndex_p1,Ug=Module._emscripten_bind_b2PrismaticJointDef__set_maxMotorForce_p1=x._emscripten_bind_b2PrismaticJointDef__set_maxMotorForce_p1,Vg=Module._emscripten_bind_b2FrictionJoint__SetMaxForce_p1=x._emscripten_bind_b2FrictionJoint__SetMaxForce_p1,Ya=Module._malloc=x._malloc,Wg=Module._emscripten_bind_b2MouseJoint__b2MouseJoint_p1= +x._emscripten_bind_b2MouseJoint__b2MouseJoint_p1,Xg=Module._emscripten_bind_b2MouseJoint__Dump_p0=x._emscripten_bind_b2MouseJoint__Dump_p0,Yg=Module._emscripten_bind_b2FixtureDef__set_restitution_p1=x._emscripten_bind_b2FixtureDef__set_restitution_p1,Zg=Module._emscripten_bind_b2Shape__GetChildCount_p0=x._emscripten_bind_b2Shape__GetChildCount_p0,$g=Module._emscripten_bind_b2Body__GetJointList_p0=x._emscripten_bind_b2Body__GetJointList_p0,ah=Module._emscripten_bind_b2Timer____destroy___p0=x._emscripten_bind_b2Timer____destroy___p0, +bh=Module._emscripten_bind_b2Vec2__IsValid_p0=x._emscripten_bind_b2Vec2__IsValid_p0,ch=Module._emscripten_bind_b2Contact__ResetRestitution_p0=x._emscripten_bind_b2Contact__ResetRestitution_p0,dh=Module._emscripten_bind_b2RevoluteJointDef__get_collideConnected_p1=x._emscripten_bind_b2RevoluteJointDef__get_collideConnected_p1,eh=Module._emscripten_bind_b2DynamicTree__MoveProxy_p3=x._emscripten_bind_b2DynamicTree__MoveProxy_p3,fh=Module._emscripten_bind_b2Transform__b2Transform_p0=x._emscripten_bind_b2Transform__b2Transform_p0, +gh=Module._emscripten_bind_b2PulleyJointDef__get_localAnchorA_p0=x._emscripten_bind_b2PulleyJointDef__get_localAnchorA_p0,hh=Module._emscripten_bind_b2RevoluteJointDef__get_bodyA_p1=x._emscripten_bind_b2RevoluteJointDef__get_bodyA_p1,ih=Module._emscripten_bind_b2WheelJointDef____destroy___p0=x._emscripten_bind_b2WheelJointDef____destroy___p0,jh=Module._emscripten_bind_b2MouseJoint__GetBodyA_p0=x._emscripten_bind_b2MouseJoint__GetBodyA_p0,kh=Module._emscripten_bind_b2GearJoint__GetType_p0=x._emscripten_bind_b2GearJoint__GetType_p0, +lh=Module._emscripten_bind_b2Body__SetMassData_p1=x._emscripten_bind_b2Body__SetMassData_p1,mh=Module._emscripten_bind_b2MouseJoint__IsActive_p0=x._emscripten_bind_b2MouseJoint__IsActive_p0,nh=Module._emscripten_bind_b2Contact__GetChildIndexA_p0=x._emscripten_bind_b2Contact__GetChildIndexA_p0,oh=Module._emscripten_bind_b2Fixture__GetShape_p0=x._emscripten_bind_b2Fixture__GetShape_p0,ph=Module._emscripten_bind_b2DistanceProxy__set_m_radius_p1=x._emscripten_bind_b2DistanceProxy__set_m_radius_p1,qh= +Module._emscripten_bind_b2DistanceJointDef__get_bodyB_p1=x._emscripten_bind_b2DistanceJointDef__get_bodyB_p1,rh=Module._emscripten_bind_b2RevoluteJoint__GetLowerLimit_p0=x._emscripten_bind_b2RevoluteJoint__GetLowerLimit_p0,sh=Module._emscripten_bind_b2World__DestroyJoint_p1=x._emscripten_bind_b2World__DestroyJoint_p1,th=Module._emscripten_bind_b2PulleyJointDef__set_ratio_p1=x._emscripten_bind_b2PulleyJointDef__set_ratio_p1,uh=Module._emscripten_bind_b2DynamicTree__b2DynamicTree_p0=x._emscripten_bind_b2DynamicTree__b2DynamicTree_p0, +vh=Module._emscripten_bind_b2RopeJoint__GetType_p0=x._emscripten_bind_b2RopeJoint__GetType_p0,wh=Module._emscripten_bind_b2Body__GetLocalPoint_p1=x._emscripten_bind_b2Body__GetLocalPoint_p1,xh=Module._emscripten_bind_b2World__GetBodyCount_p0=x._emscripten_bind_b2World__GetBodyCount_p0,yh=Module._emscripten_bind_b2CircleShape__GetType_p0=x._emscripten_bind_b2CircleShape__GetType_p0,zh=Module._emscripten_bind_b2DistanceProxy__get_m_radius_p0=x._emscripten_bind_b2DistanceProxy__get_m_radius_p0,Ah=Module._emscripten_bind_b2World__ClearForces_p0= +x._emscripten_bind_b2World__ClearForces_p0,Bh=Module._emscripten_bind_b2DynamicTree____destroy___p0=x._emscripten_bind_b2DynamicTree____destroy___p0,Ch=Module._emscripten_bind_b2Contact__GetWorldManifold_p1=x._emscripten_bind_b2Contact__GetWorldManifold_p1,Dh=Module._emscripten_bind_b2DynamicTree__GetUserData_p1=x._emscripten_bind_b2DynamicTree__GetUserData_p1,Eh=Module._emscripten_bind_b2JointDef____destroy___p0=x._emscripten_bind_b2JointDef____destroy___p0,Fh=Module._emscripten_bind_b2DistanceProxy__GetVertex_p1= +x._emscripten_bind_b2DistanceProxy__GetVertex_p1,Gh=Module._emscripten_bind_b2Draw__GetFlags_p0=x._emscripten_bind_b2Draw__GetFlags_p0,Hh=Module._emscripten_bind_b2PolygonShape__Set_p2=x._emscripten_bind_b2PolygonShape__Set_p2,Ih=Module._emscripten_bind_b2DistanceJoint____destroy___p0=x._emscripten_bind_b2DistanceJoint____destroy___p0,Jh=Module._emscripten_bind_b2DestructionListener__SayGoodbye_p1=x._emscripten_bind_b2DestructionListener__SayGoodbye_p1,Kh=Module._emscripten_bind_b2BodyDef____destroy___p0= +x._emscripten_bind_b2BodyDef____destroy___p0,Lh=Module._emscripten_bind_b2EdgeShape____destroy___p0=x._emscripten_bind_b2EdgeShape____destroy___p0,Mh=Module._emscripten_bind_b2GearJointDef__get_ratio_p0=x._emscripten_bind_b2GearJointDef__get_ratio_p0,Nh=Module._emscripten_bind_b2BlockAllocator__Clear_p0=x._emscripten_bind_b2BlockAllocator__Clear_p0,Oh=Module._emscripten_bind_b2RopeJoint__GetAnchorB_p0=x._emscripten_bind_b2RopeJoint__GetAnchorB_p0,Ph=Module._emscripten_bind_b2BodyDef__set_type_p1= +x._emscripten_bind_b2BodyDef__set_type_p1,Qh=Module._emscripten_bind_b2WheelJoint__EnableMotor_p1=x._emscripten_bind_b2WheelJoint__EnableMotor_p1,Rh=Module._emscripten_bind_b2FrictionJoint__GetBodyA_p0=x._emscripten_bind_b2FrictionJoint__GetBodyA_p0,Sh=Module._emscripten_bind_b2RopeJoint__GetBodyA_p0=x._emscripten_bind_b2RopeJoint__GetBodyA_p0,Th=Module._emscripten_bind_b2WheelJointDef__get_bodyA_p1=x._emscripten_bind_b2WheelJointDef__get_bodyA_p1,Uh=Module._emscripten_bind_b2RopeJoint__GetAnchorA_p0= +x._emscripten_bind_b2RopeJoint__GetAnchorA_p0,Vh=Module._emscripten_bind_b2GearJointDef__get_collideConnected_p1=x._emscripten_bind_b2GearJointDef__get_collideConnected_p1,Wh=Module._emscripten_bind_b2RevoluteJointDef__get_upperAngle_p0=x._emscripten_bind_b2RevoluteJointDef__get_upperAngle_p0,Xh=Module._emscripten_bind_b2WeldJoint__GetLocalAnchorB_p0=x._emscripten_bind_b2WeldJoint__GetLocalAnchorB_p0,Yh=Module._emscripten_bind_b2PolygonShape__set_m_radius_p1=x._emscripten_bind_b2PolygonShape__set_m_radius_p1, +Zh=Module._emscripten_bind_b2Vec2__SetZero_p0=x._emscripten_bind_b2Vec2__SetZero_p0,$h=Module._emscripten_bind_b2WheelJointDef__get_maxMotorTorque_p0=x._emscripten_bind_b2WheelJointDef__get_maxMotorTorque_p0,ai=Module._emscripten_bind_b2ChainShape__CreateLoop_p2=x._emscripten_bind_b2ChainShape__CreateLoop_p2,bi=Module._emscripten_bind_b2RevoluteJoint__GetNext_p0=x._emscripten_bind_b2RevoluteJoint__GetNext_p0,ci=Module._emscripten_bind_b2World__DestroyBody_p1=x._emscripten_bind_b2World__DestroyBody_p1, +di=Module._emscripten_bind_b2World__SetSubStepping_p1=x._emscripten_bind_b2World__SetSubStepping_p1,ei=Module._emscripten_bind_b2PulleyJoint__SetUserData_p1=x._emscripten_bind_b2PulleyJoint__SetUserData_p1,fi=Module._emscripten_bind_b2WheelJoint__GetMotorSpeed_p0=x._emscripten_bind_b2WheelJoint__GetMotorSpeed_p0,gi=Module._emscripten_bind_b2RopeJoint__GetLimitState_p0=x._emscripten_bind_b2RopeJoint__GetLimitState_p0,hi=Module._emscripten_bind_b2PrismaticJointDef____destroy___p0=x._emscripten_bind_b2PrismaticJointDef____destroy___p0, +ii=Module._emscripten_bind_b2PulleyJointDef__set_collideConnected_p1=x._emscripten_bind_b2PulleyJointDef__set_collideConnected_p1,ji=Module._emscripten_bind_b2WheelJoint__GetNext_p0=x._emscripten_bind_b2WheelJoint__GetNext_p0,ki=Module._emscripten_bind_b2World__SetContactFilter_p1=x._emscripten_bind_b2World__SetContactFilter_p1,li=Module._emscripten_bind_b2BroadPhase__GetFatAABB_p1=x._emscripten_bind_b2BroadPhase__GetFatAABB_p1,mi=Module._emscripten_bind_b2FrictionJoint__SetMaxTorque_p1=x._emscripten_bind_b2FrictionJoint__SetMaxTorque_p1, +ni=Module._emscripten_bind_b2ContactManager__set_m_contactCount_p1=x._emscripten_bind_b2ContactManager__set_m_contactCount_p1,oi=Module._emscripten_bind_b2Body__GetLinearVelocity_p0=x._emscripten_bind_b2Body__GetLinearVelocity_p0,pi=Module._emscripten_bind_b2ContactManager__get_m_allocator_p0=x._emscripten_bind_b2ContactManager__get_m_allocator_p0,qi=Module._emscripten_bind_b2AABB____destroy___p0=x._emscripten_bind_b2AABB____destroy___p0,ri=Module._emscripten_bind_b2PulleyJoint__GetCollideConnected_p0= +x._emscripten_bind_b2PulleyJoint__GetCollideConnected_p0,si=Module._emscripten_bind_b2Joint__GetUserData_p0=x._emscripten_bind_b2Joint__GetUserData_p0,ti=Module._emscripten_bind_b2Rot__GetXAxis_p0=x._emscripten_bind_b2Rot__GetXAxis_p0,ui=Module._emscripten_bind_b2ContactManager__get_m_contactCount_p0=x._emscripten_bind_b2ContactManager__get_m_contactCount_p0,vi=Module._emscripten_bind_b2DistanceJoint__Dump_p0=x._emscripten_bind_b2DistanceJoint__Dump_p0,wi=Module._emscripten_bind_b2PolygonShape__GetVertexCount_p0= +x._emscripten_bind_b2PolygonShape__GetVertexCount_p0,xi=Module._emscripten_bind_b2StackAllocator__Free_p1=x._emscripten_bind_b2StackAllocator__Free_p1,yi=Module._emscripten_bind_b2CircleShape__GetSupportVertex_p1=x._emscripten_bind_b2CircleShape__GetSupportVertex_p1,zi=Module._emscripten_bind_b2DistanceProxy__GetSupportVertex_p1=x._emscripten_bind_b2DistanceProxy__GetSupportVertex_p1,Ai=Module._emscripten_bind_b2DistanceJointDef__set_bodyA_p1=x._emscripten_bind_b2DistanceJointDef__set_bodyA_p1,Bi= +Module._emscripten_bind_b2JointDef__set_userData_p1=x._emscripten_bind_b2JointDef__set_userData_p1,Ci=Module._emscripten_bind_b2GearJoint__GetBodyB_p0=x._emscripten_bind_b2GearJoint__GetBodyB_p0,Di=Module._emscripten_bind_b2Vec3__get_z_p0=x._emscripten_bind_b2Vec3__get_z_p0,Ei=Module._emscripten_bind_b2RopeJoint__GetUserData_p0=x._emscripten_bind_b2RopeJoint__GetUserData_p0,Fi=Module._emscripten_bind_b2GearJoint__GetUserData_p0=x._emscripten_bind_b2GearJoint__GetUserData_p0,Gi=Module._emscripten_bind_b2FixtureDef__get_restitution_p0= +x._emscripten_bind_b2FixtureDef__get_restitution_p0,Hi=Module._emscripten_bind_b2WheelJoint__GetAnchorB_p0=x._emscripten_bind_b2WheelJoint__GetAnchorB_p0,Ii=Module._emscripten_bind_b2FixtureDef__b2FixtureDef_p0=x._emscripten_bind_b2FixtureDef__b2FixtureDef_p0,Ji=Module._emscripten_bind_b2WheelJointDef__get_motorSpeed_p0=x._emscripten_bind_b2WheelJointDef__get_motorSpeed_p0,Ki=Module._emscripten_bind_b2FrictionJoint__b2FrictionJoint_p1=x._emscripten_bind_b2FrictionJoint__b2FrictionJoint_p1,Li=Module._emscripten_bind_b2Body__GetAngularDamping_p0= +x._emscripten_bind_b2Body__GetAngularDamping_p0,Mi=Module._emscripten_bind_b2ChainShape__GetChildCount_p0=x._emscripten_bind_b2ChainShape__GetChildCount_p0,Ni=Module._emscripten_bind_b2ChainShape__SetNextVertex_p1=x._emscripten_bind_b2ChainShape__SetNextVertex_p1,Oi=Module._emscripten_bind_b2Joint__GetBodyA_p0=x._emscripten_bind_b2Joint__GetBodyA_p0,Pi=Module._emscripten_bind_b2Fixture__IsSensor_p0=x._emscripten_bind_b2Fixture__IsSensor_p0,Qi=Module._emscripten_bind_b2Filter__set_maskBits_p1=x._emscripten_bind_b2Filter__set_maskBits_p1, +Ri=Module._emscripten_bind_b2PulleyJointDef__set_groundAnchorB_p1=x._emscripten_bind_b2PulleyJointDef__set_groundAnchorB_p1,Si=Module._emscripten_bind_b2ContactListener__PreSolve_p2=x._emscripten_bind_b2ContactListener__PreSolve_p2,Ti=Module._emscripten_bind_b2WheelJointDef__get_localAnchorB_p0=x._emscripten_bind_b2WheelJointDef__get_localAnchorB_p0,Ui=Module._emscripten_bind_b2WheelJointDef__set_bodyB_p1=x._emscripten_bind_b2WheelJointDef__set_bodyB_p1,Vi=Module._emscripten_bind_b2BroadPhase__MoveProxy_p3= +x._emscripten_bind_b2BroadPhase__MoveProxy_p3,Wi=Module._emscripten_bind_b2BodyDef__get_active_p0=x._emscripten_bind_b2BodyDef__get_active_p0,Xi=Module._emscripten_bind_b2CircleShape__GetVertexCount_p0=x._emscripten_bind_b2CircleShape__GetVertexCount_p0,Yi=Module._emscripten_bind_b2Timer__Reset_p0=x._emscripten_bind_b2Timer__Reset_p0,Zi=Module._emscripten_bind_b2QueryCallback____destroy___p0=x._emscripten_bind_b2QueryCallback____destroy___p0,$i=Module._emscripten_bind_b2World__b2World_p1=x._emscripten_bind_b2World__b2World_p1, +aj=Module._emscripten_bind_b2Vec3__Set_p3=x._emscripten_bind_b2Vec3__Set_p3,bj=Module._emscripten_bind_b2PrismaticJointDef__get_motorSpeed_p0=x._emscripten_bind_b2PrismaticJointDef__get_motorSpeed_p0,cj=Module._emscripten_bind_b2RevoluteJointDef__set_referenceAngle_p1=x._emscripten_bind_b2RevoluteJointDef__set_referenceAngle_p1,dj=Module._emscripten_bind_b2StackAllocator____destroy___p0=x._emscripten_bind_b2StackAllocator____destroy___p0,ej=Module._emscripten_bind_b2ContactEdge__get_other_p0=x._emscripten_bind_b2ContactEdge__get_other_p0, +fj=Module._emscripten_bind_b2Fixture__GetType_p0=x._emscripten_bind_b2Fixture__GetType_p0,gj=Module._emscripten_bind_b2ContactListener__PostSolve_p2=x._emscripten_bind_b2ContactListener__PostSolve_p2,hj=Module._emscripten_bind_b2WeldJointDef__set_collideConnected_p1=x._emscripten_bind_b2WeldJointDef__set_collideConnected_p1,ij=Module._emscripten_bind_b2Contact__SetRestitution_p1=x._emscripten_bind_b2Contact__SetRestitution_p1,jj=Module._emscripten_bind_b2Body__GetInertia_p0=x._emscripten_bind_b2Body__GetInertia_p0, +kj=Module._emscripten_bind_b2FrictionJointDef__b2FrictionJointDef_p0=x._emscripten_bind_b2FrictionJointDef__b2FrictionJointDef_p0,lj=Module._emscripten_bind_b2PolygonShape__get_m_centroid_p0=x._emscripten_bind_b2PolygonShape__get_m_centroid_p0,mj=Module._emscripten_bind_b2PrismaticJoint__IsMotorEnabled_p0=x._emscripten_bind_b2PrismaticJoint__IsMotorEnabled_p0,nj=Module._emscripten_bind_b2FrictionJointDef__get_localAnchorA_p0=x._emscripten_bind_b2FrictionJointDef__get_localAnchorA_p0,oj=Module._emscripten_bind_b2Draw__SetFlags_p1= +x._emscripten_bind_b2Draw__SetFlags_p1,pj=Module._emscripten_bind_b2WeldJoint__GetUserData_p0=x._emscripten_bind_b2WeldJoint__GetUserData_p0,qj=Module._emscripten_bind_b2WeldJointDef__b2WeldJointDef_p0=x._emscripten_bind_b2WeldJointDef__b2WeldJointDef_p0,rj=Module._emscripten_bind_b2FrictionJointDef__set_collideConnected_p1=x._emscripten_bind_b2FrictionJointDef__set_collideConnected_p1,sj=Module._emscripten_bind_b2World__SetAllowSleeping_p1=x._emscripten_bind_b2World__SetAllowSleeping_p1,tj=Module._emscripten_bind_b2BodyDef__set_gravityScale_p1= +x._emscripten_bind_b2BodyDef__set_gravityScale_p1,uj=Module._emscripten_bind_b2Contact__IsTouching_p0=x._emscripten_bind_b2Contact__IsTouching_p0,vj=Module._emscripten_bind_b2Transform__set_q_p1=x._emscripten_bind_b2Transform__set_q_p1,wj=Module._emscripten_bind_b2FrictionJoint__GetAnchorB_p0=x._emscripten_bind_b2FrictionJoint__GetAnchorB_p0,xj=Module._emscripten_bind_b2World__RayCast_p3=x._emscripten_bind_b2World__RayCast_p3,yj=Module._emscripten_bind_b2WeldJointDef__get_bodyA_p1=x._emscripten_bind_b2WeldJointDef__get_bodyA_p1, +zj=Module._emscripten_bind_b2WheelJoint__GetMotorTorque_p1=x._emscripten_bind_b2WheelJoint__GetMotorTorque_p1,Aj=Module._emscripten_bind_b2Draw__b2Draw_p0=x._emscripten_bind_b2Draw__b2Draw_p0,Bj=Module._emscripten_bind_b2ChainShape____destroy___p0=x._emscripten_bind_b2ChainShape____destroy___p0,Cj=Module._emscripten_bind_b2ChainShape__get_m_radius_p0=x._emscripten_bind_b2ChainShape__get_m_radius_p0,Dj=Module._emscripten_bind_b2RopeJoint__IsActive_p0=x._emscripten_bind_b2RopeJoint__IsActive_p0,Ej= +Module._emscripten_bind_b2EdgeShape__set_m_radius_p1=x._emscripten_bind_b2EdgeShape__set_m_radius_p1,Fj=Module._emscripten_bind_b2DistanceJointDef__get_length_p0=x._emscripten_bind_b2DistanceJointDef__get_length_p0,Gj=Module._emscripten_bind_b2DistanceJoint__SetUserData_p1=x._emscripten_bind_b2DistanceJoint__SetUserData_p1,Hj=Module._emscripten_bind_b2ContactManager__set_m_contactListener_p1=x._emscripten_bind_b2ContactManager__set_m_contactListener_p1,Ij=Module._emscripten_bind_b2MouseJointDef__get_maxForce_p0= +x._emscripten_bind_b2MouseJointDef__get_maxForce_p0,Jj=Module._emscripten_bind_b2WheelJoint____destroy___p0=x._emscripten_bind_b2WheelJoint____destroy___p0,Kj=Module._emscripten_bind_b2PulleyJoint__GetBodyA_p0=x._emscripten_bind_b2PulleyJoint__GetBodyA_p0,Lj=Module._emscripten_bind_b2MouseJoint__SetMaxForce_p1=x._emscripten_bind_b2MouseJoint__SetMaxForce_p1,Mj=Module._emscripten_bind_b2World__GetGravity_p0=x._emscripten_bind_b2World__GetGravity_p0,Nj=Module._emscripten_bind_b2WheelJointDef__set_bodyA_p1= +x._emscripten_bind_b2WheelJointDef__set_bodyA_p1,Oj=Module._emscripten_bind_b2AABB__b2AABB_p0=x._emscripten_bind_b2AABB__b2AABB_p0,Pj=Module._emscripten_bind_b2DistanceProxy____destroy___p0=x._emscripten_bind_b2DistanceProxy____destroy___p0,Qj=Module._emscripten_bind_b2RevoluteJointDef__set_lowerAngle_p1=x._emscripten_bind_b2RevoluteJointDef__set_lowerAngle_p1,Rj=Module._emscripten_bind_b2World__GetProfile_p0=x._emscripten_bind_b2World__GetProfile_p0,Sj=Module._emscripten_bind_b2PulleyJointDef__get_bodyA_p1= +x._emscripten_bind_b2PulleyJointDef__get_bodyA_p1,Tj=Module._emscripten_bind_b2PulleyJointDef__set_groundAnchorA_p1=x._emscripten_bind_b2PulleyJointDef__set_groundAnchorA_p1,Uj=Module._emscripten_bind_b2PolygonShape__Clone_p1=x._emscripten_bind_b2PolygonShape__Clone_p1,Vj=Module._emscripten_bind_b2PrismaticJoint__GetUserData_p0=x._emscripten_bind_b2PrismaticJoint__GetUserData_p0,Wj=Module._emscripten_bind_b2PrismaticJoint__IsLimitEnabled_p0=x._emscripten_bind_b2PrismaticJoint__IsLimitEnabled_p0,Xj= +Module._emscripten_bind_b2PulleyJoint__GetAnchorA_p0=x._emscripten_bind_b2PulleyJoint__GetAnchorA_p0,Yj=Module._emscripten_bind_b2Fixture__Refilter_p0=x._emscripten_bind_b2Fixture__Refilter_p0,Zj=Module._emscripten_bind_b2Vec3__SetZero_p0=x._emscripten_bind_b2Vec3__SetZero_p0,$j=Module._emscripten_bind_b2ContactListener__EndContact_p1=x._emscripten_bind_b2ContactListener__EndContact_p1,ak=Module._emscripten_bind_b2Vec2__Normalize_p0=x._emscripten_bind_b2Vec2__Normalize_p0,bk=Module._emscripten_bind_b2Shape__ComputeMass_p2= +x._emscripten_bind_b2Shape__ComputeMass_p2,ck=Module._emscripten_bind_b2FrictionJoint__GetMaxForce_p0=x._emscripten_bind_b2FrictionJoint__GetMaxForce_p0,dk=Module._emscripten_bind_b2BodyDef__get_type_p0=x._emscripten_bind_b2BodyDef__get_type_p0,ek=Module._emscripten_bind_b2FixtureDef__get_userData_p0=x._emscripten_bind_b2FixtureDef__get_userData_p0,fk=Module._emscripten_bind_b2MouseJointDef__get_collideConnected_p1=x._emscripten_bind_b2MouseJointDef__get_collideConnected_p1,gk=Module._emscripten_bind_b2Contact__ResetFriction_p0= +x._emscripten_bind_b2Contact__ResetFriction_p0,hk=Module._emscripten_bind_b2WeldJointDef__Initialize_p3=x._emscripten_bind_b2WeldJointDef__Initialize_p3,ik=Module._emscripten_bind_b2DistanceJoint__GetCollideConnected_p0=x._emscripten_bind_b2DistanceJoint__GetCollideConnected_p0,jk=Module._emscripten_bind_b2Rot__Set_p1=x._emscripten_bind_b2Rot__Set_p1,kk=Module._emscripten_bind_b2ChainShape__RayCast_p4=x._emscripten_bind_b2ChainShape__RayCast_p4,lk=Module._emscripten_bind_b2RevoluteJoint__GetReactionForce_p1= +x._emscripten_bind_b2RevoluteJoint__GetReactionForce_p1,mk=Module._emscripten_bind_b2PrismaticJointDef__b2PrismaticJointDef_p0=x._emscripten_bind_b2PrismaticJointDef__b2PrismaticJointDef_p0,nk=Module._emscripten_bind_b2FrictionJointDef__get_localAnchorB_p0=x._emscripten_bind_b2FrictionJointDef__get_localAnchorB_p0,ok=Module._emscripten_bind_b2MouseJoint__GetMaxForce_p0=x._emscripten_bind_b2MouseJoint__GetMaxForce_p0,pk=Module._emscripten_bind_b2RopeJoint__Dump_p0=x._emscripten_bind_b2RopeJoint__Dump_p0, +qk=Module._emscripten_bind_b2WheelJointDef__set_enableMotor_p1=x._emscripten_bind_b2WheelJointDef__set_enableMotor_p1,rk=Module._emscripten_bind_b2ContactManager__get_m_contactList_p0=x._emscripten_bind_b2ContactManager__get_m_contactList_p0,sk=Module._emscripten_bind_b2PolygonShape__ComputeAABB_p3=x._emscripten_bind_b2PolygonShape__ComputeAABB_p3,tk=Module._emscripten_bind_b2RopeJointDef__set_bodyB_p1=x._emscripten_bind_b2RopeJointDef__set_bodyB_p1,uk=Module._emscripten_bind_b2BodyDef__set_fixedRotation_p1= +x._emscripten_bind_b2BodyDef__set_fixedRotation_p1,vk=Module._emscripten_bind_b2WheelJoint__GetAnchorA_p0=x._emscripten_bind_b2WheelJoint__GetAnchorA_p0,wk=Module._emscripten_bind_b2GearJoint__GetBodyA_p0=x._emscripten_bind_b2GearJoint__GetBodyA_p0,xk=Module._emscripten_bind_b2CircleShape__b2CircleShape_p0=x._emscripten_bind_b2CircleShape__b2CircleShape_p0,yk=Module._emscripten_bind_b2EdgeShape__GetChildCount_p0=x._emscripten_bind_b2EdgeShape__GetChildCount_p0,zk=Module._emscripten_bind_b2BodyDef__set_active_p1= +x._emscripten_bind_b2BodyDef__set_active_p1,Ak=Module._emscripten_bind_b2FrictionJointDef__get_bodyA_p1=x._emscripten_bind_b2FrictionJointDef__get_bodyA_p1,Bk=Module._emscripten_bind_b2PulleyJoint__GetReactionTorque_p1=x._emscripten_bind_b2PulleyJoint__GetReactionTorque_p1,Ck=Module._emscripten_bind_b2DistanceJoint__b2DistanceJoint_p1=x._emscripten_bind_b2DistanceJoint__b2DistanceJoint_p1,Dk=Module._emscripten_bind_b2Vec2____destroy___p0=x._emscripten_bind_b2Vec2____destroy___p0,Ek=Module._emscripten_bind_b2ChainShape__get_m_vertices_p0= +x._emscripten_bind_b2ChainShape__get_m_vertices_p0,Fk=Module._emscripten_bind_b2BodyDef__b2BodyDef_p0=x._emscripten_bind_b2BodyDef__b2BodyDef_p0,Gk=Module._emscripten_bind_b2RevoluteJoint__Dump_p0=x._emscripten_bind_b2RevoluteJoint__Dump_p0,Hk=Module._emscripten_bind_b2RevoluteJointDef__b2RevoluteJointDef_p0=x._emscripten_bind_b2RevoluteJointDef__b2RevoluteJointDef_p0,Ik=Module._emscripten_bind_b2World__SetDebugDraw_p1=x._emscripten_bind_b2World__SetDebugDraw_p1,Jk=Module._emscripten_bind_b2MouseJoint____destroy___p0= +x._emscripten_bind_b2MouseJoint____destroy___p0,Kk=Module._emscripten_bind_b2RevoluteJoint__IsMotorEnabled_p0=x._emscripten_bind_b2RevoluteJoint__IsMotorEnabled_p0,Lk=Module._emscripten_bind_b2MouseJointDef__set_frequencyHz_p1=x._emscripten_bind_b2MouseJointDef__set_frequencyHz_p1,Mk=Module._emscripten_bind_b2DestructionListener__b2DestructionListener_p0=x._emscripten_bind_b2DestructionListener__b2DestructionListener_p0,Nk=Module._emscripten_bind_b2WheelJointDef__get_frequencyHz_p0=x._emscripten_bind_b2WheelJointDef__get_frequencyHz_p0, +Ok=Module._emscripten_bind_b2Filter__b2Filter_p0=x._emscripten_bind_b2Filter__b2Filter_p0,Pk=Module._emscripten_bind_b2World____destroy___p0=x._emscripten_bind_b2World____destroy___p0,Qk=Module._emscripten_bind_b2Body__SetBullet_p1=x._emscripten_bind_b2Body__SetBullet_p1,Rk=Module._emscripten_bind_b2Body__GetAngle_p0=x._emscripten_bind_b2Body__GetAngle_p0,Sk=Module._emscripten_bind_b2PrismaticJointDef__set_bodyA_p1=x._emscripten_bind_b2PrismaticJointDef__set_bodyA_p1,Tk=Module._emscripten_bind_b2MouseJoint__GetTarget_p0= +x._emscripten_bind_b2MouseJoint__GetTarget_p0,Uk=Module._emscripten_bind_b2DistanceJointDef__get_frequencyHz_p0=x._emscripten_bind_b2DistanceJointDef__get_frequencyHz_p0,Vk=Module._emscripten_bind_b2Contact__GetNext_p0=x._emscripten_bind_b2Contact__GetNext_p0,Wk=Module._emscripten_bind_b2World__DrawDebugData_p0=x._emscripten_bind_b2World__DrawDebugData_p0,Xk=Module._emscripten_bind_b2RevoluteJointDef__set_maxMotorTorque_p1=x._emscripten_bind_b2RevoluteJointDef__set_maxMotorTorque_p1,Yk=Module._emscripten_bind_b2Vec2__LengthSquared_p0= +x._emscripten_bind_b2Vec2__LengthSquared_p0,Zk=Module._emscripten_bind_b2WheelJointDef__get_localAnchorA_p0=x._emscripten_bind_b2WheelJointDef__get_localAnchorA_p0,$k=Module._emscripten_bind_b2RevoluteJoint____destroy___p0=x._emscripten_bind_b2RevoluteJoint____destroy___p0,al=Module._emscripten_bind_b2PulleyJointDef__get_lengthB_p0=x._emscripten_bind_b2PulleyJointDef__get_lengthB_p0,bl=Module._emscripten_bind_b2WeldJoint__GetReferenceAngle_p0=x._emscripten_bind_b2WeldJoint__GetReferenceAngle_p0,hc= +Module._strlen=x._strlen,cl=Module._emscripten_bind_b2FixtureDef__set_filter_p1=x._emscripten_bind_b2FixtureDef__set_filter_p1,dl=Module._emscripten_bind_b2ChainShape__CreateChain_p2=x._emscripten_bind_b2ChainShape__CreateChain_p2,el=Module._emscripten_bind_b2Body__GetLocalVector_p1=x._emscripten_bind_b2Body__GetLocalVector_p1,fl=Module._emscripten_bind_b2Fixture__SetUserData_p1=x._emscripten_bind_b2Fixture__SetUserData_p1,gl=Module._emscripten_bind_b2RevoluteJoint__GetLocalAnchorB_p0=x._emscripten_bind_b2RevoluteJoint__GetLocalAnchorB_p0, +hl=Module._emscripten_bind_b2FrictionJointDef__set_maxTorque_p1=x._emscripten_bind_b2FrictionJointDef__set_maxTorque_p1,il=Module._emscripten_bind_b2ChainShape__ComputeAABB_p3=x._emscripten_bind_b2ChainShape__ComputeAABB_p3,jl=Module._emscripten_bind_b2RopeJoint__GetReactionForce_p1=x._emscripten_bind_b2RopeJoint__GetReactionForce_p1,kl=Module._emscripten_bind_b2CircleShape__GetSupport_p1=x._emscripten_bind_b2CircleShape__GetSupport_p1,ll=Module._emscripten_bind_b2World__GetContinuousPhysics_p0=x._emscripten_bind_b2World__GetContinuousPhysics_p0, +ml=Module._emscripten_bind_b2FrictionJointDef__get_maxForce_p0=x._emscripten_bind_b2FrictionJointDef__get_maxForce_p0,nl=Module._emscripten_bind_b2Draw____destroy___p0=x._emscripten_bind_b2Draw____destroy___p0,ol=Module._emscripten_bind_b2RevoluteJointDef__set_localAnchorA_p1=x._emscripten_bind_b2RevoluteJointDef__set_localAnchorA_p1,pl=Module._emscripten_bind_b2MouseJoint__GetCollideConnected_p0=x._emscripten_bind_b2MouseJoint__GetCollideConnected_p0,ql=Module._emscripten_bind_b2MouseJoint__GetReactionForce_p1= +x._emscripten_bind_b2MouseJoint__GetReactionForce_p1,rl=Module._emscripten_bind_b2JointDef__set_type_p1=x._emscripten_bind_b2JointDef__set_type_p1,sl=Module._emscripten_bind_b2Color__Set_p3=x._emscripten_bind_b2Color__Set_p3,tl=Module._emscripten_bind_b2WeldJoint__GetType_p0=x._emscripten_bind_b2WeldJoint__GetType_p0,ul=Module._emscripten_bind_b2Joint__GetBodyB_p0=x._emscripten_bind_b2Joint__GetBodyB_p0,vl=Module._emscripten_bind_b2ContactManager__set_m_broadPhase_p1=x._emscripten_bind_b2ContactManager__set_m_broadPhase_p1, +wl=Module._emscripten_bind_b2JointDef__get_type_p0=x._emscripten_bind_b2JointDef__get_type_p0,xl=Module._emscripten_bind_b2BodyDef__set_position_p1=x._emscripten_bind_b2BodyDef__set_position_p1,yl=Module._emscripten_bind_b2Vec2__Length_p0=x._emscripten_bind_b2Vec2__Length_p0,zl=Module._emscripten_bind_b2MouseJoint__GetUserData_p0=x._emscripten_bind_b2MouseJoint__GetUserData_p0,Al=Module._emscripten_bind_b2JointDef__get_collideConnected_p0=x._emscripten_bind_b2JointDef__get_collideConnected_p0,Bl= +Module._emscripten_bind_b2BroadPhase__GetTreeQuality_p0=x._emscripten_bind_b2BroadPhase__GetTreeQuality_p0,Cl=Module._emscripten_bind_b2WheelJointDef__get_dampingRatio_p0=x._emscripten_bind_b2WheelJointDef__get_dampingRatio_p0,Dl=Module._emscripten_bind_b2RopeJoint__GetBodyB_p0=x._emscripten_bind_b2RopeJoint__GetBodyB_p0,El=Module._emscripten_bind_b2Joint__GetCollideConnected_p0=x._emscripten_bind_b2Joint__GetCollideConnected_p0,Fl=Module._emscripten_bind_b2FrictionJoint__GetReactionTorque_p1=x._emscripten_bind_b2FrictionJoint__GetReactionTorque_p1, +Gl=Module._emscripten_bind_b2PulleyJointDef__get_bodyB_p1=x._emscripten_bind_b2PulleyJointDef__get_bodyB_p1,Hl=Module._emscripten_bind_b2ContactManager__set_m_contactFilter_p1=x._emscripten_bind_b2ContactManager__set_m_contactFilter_p1,Il=Module._emscripten_bind_b2FrictionJoint__GetAnchorA_p0=x._emscripten_bind_b2FrictionJoint__GetAnchorA_p0,Jl=Module._emscripten_bind_b2EdgeShape__ComputeAABB_p3=x._emscripten_bind_b2EdgeShape__ComputeAABB_p3,Kl=Module._emscripten_bind_b2BodyDef__set_awake_p1=x._emscripten_bind_b2BodyDef__set_awake_p1, +Ll=Module._emscripten_bind_b2FrictionJointDef__get_bodyB_p1=x._emscripten_bind_b2FrictionJointDef__get_bodyB_p1,Ml=Module._emscripten_bind_b2PrismaticJoint__SetMotorSpeed_p1=x._emscripten_bind_b2PrismaticJoint__SetMotorSpeed_p1,Nl=Module._emscripten_bind_b2PolygonShape__RayCast_p4=x._emscripten_bind_b2PolygonShape__RayCast_p4,Ol=Module._emscripten_bind_b2CircleShape__ComputeMass_p2=x._emscripten_bind_b2CircleShape__ComputeMass_p2,Pl=Module._emscripten_bind_b2MouseJoint__GetFrequency_p0=x._emscripten_bind_b2MouseJoint__GetFrequency_p0, +Ql=Module._emscripten_bind_b2Contact__IsEnabled_p0=x._emscripten_bind_b2Contact__IsEnabled_p0,Rl=Module._emscripten_bind_b2PrismaticJointDef__set_bodyB_p1=x._emscripten_bind_b2PrismaticJointDef__set_bodyB_p1,Sl=Module._emscripten_bind_b2FixtureDef__set_userData_p1=x._emscripten_bind_b2FixtureDef__set_userData_p1,Tl=Module._emscripten_bind_b2Fixture__SetSensor_p1=x._emscripten_bind_b2Fixture__SetSensor_p1,Ul=Module._emscripten_bind_b2Shape__GetType_p0=x._emscripten_bind_b2Shape__GetType_p0,Vl=Module._emscripten_bind_b2WeldJointDef__get_localAnchorB_p0= +x._emscripten_bind_b2WeldJointDef__get_localAnchorB_p0,Wl=Module._emscripten_bind_b2ContactManager__Destroy_p1=x._emscripten_bind_b2ContactManager__Destroy_p1,Xl=Module._emscripten_bind_b2PrismaticJoint__GetLocalAnchorA_p0=x._emscripten_bind_b2PrismaticJoint__GetLocalAnchorA_p0,Yl=Module._emscripten_bind_b2WheelJointDef__set_motorSpeed_p1=x._emscripten_bind_b2WheelJointDef__set_motorSpeed_p1,Zl=Module._emscripten_bind_b2Contact__Evaluate_p3=x._emscripten_bind_b2Contact__Evaluate_p3,$l=Module._emscripten_bind_b2PulleyJointDef__set_localAnchorB_p1= +x._emscripten_bind_b2PulleyJointDef__set_localAnchorB_p1,am=Module._emscripten_bind_b2RevoluteJoint__GetType_p0=x._emscripten_bind_b2RevoluteJoint__GetType_p0,bm=Module._emscripten_bind_b2AABB__Combine_p1=x._emscripten_bind_b2AABB__Combine_p1,cm=Module._emscripten_bind_b2GearJoint__GetReactionTorque_p1=x._emscripten_bind_b2GearJoint__GetReactionTorque_p1,dm=Module._emscripten_bind_b2AABB__Combine_p2=x._emscripten_bind_b2AABB__Combine_p2,em=Module._emscripten_bind_b2PulleyJointDef__get_lengthA_p0= +x._emscripten_bind_b2PulleyJointDef__get_lengthA_p0,fm=Module._emscripten_bind_b2Shape__get_m_radius_p0=x._emscripten_bind_b2Shape__get_m_radius_p0,gm=Module._emscripten_bind_b2ChainShape__set_m_count_p1=x._emscripten_bind_b2ChainShape__set_m_count_p1,hm=Module._emscripten_bind_b2RopeJointDef__set_bodyA_p1=x._emscripten_bind_b2RopeJointDef__set_bodyA_p1,im=Module._emscripten_bind_b2DynamicTree__GetFatAABB_p1=x._emscripten_bind_b2DynamicTree__GetFatAABB_p1,jm=Module._emscripten_bind_b2DistanceJoint__GetFrequency_p0= +x._emscripten_bind_b2DistanceJoint__GetFrequency_p0,km=Module._emscripten_bind_b2PrismaticJoint__SetLimits_p2=x._emscripten_bind_b2PrismaticJoint__SetLimits_p2,lm=Module._emscripten_bind_b2PulleyJointDef__b2PulleyJointDef_p0=x._emscripten_bind_b2PulleyJointDef__b2PulleyJointDef_p0,mm=Module._emscripten_bind_b2Color__get_g_p0=x._emscripten_bind_b2Color__get_g_p0,nm=Module._emscripten_bind_b2Fixture__GetBody_p0=x._emscripten_bind_b2Fixture__GetBody_p0,om=Module._emscripten_bind_b2FrictionJointDef__get_collideConnected_p1= +x._emscripten_bind_b2FrictionJointDef__get_collideConnected_p1,pm=Module._emscripten_bind_b2WheelJointDef__set_maxMotorTorque_p1=x._emscripten_bind_b2WheelJointDef__set_maxMotorTorque_p1,qm=Module._emscripten_bind_b2GearJointDef__get_bodyB_p1=x._emscripten_bind_b2GearJointDef__get_bodyB_p1,rm=Module._emscripten_bind_b2AABB__set_upperBound_p1=x._emscripten_bind_b2AABB__set_upperBound_p1,sm=Module._emscripten_bind_b2Contact__GetFixtureA_p0=x._emscripten_bind_b2Contact__GetFixtureA_p0,tm=Module._emscripten_bind_b2RevoluteJointDef__set_localAnchorB_p1= +x._emscripten_bind_b2RevoluteJointDef__set_localAnchorB_p1,um=Module._emscripten_bind_b2WheelJointDef__set_localAnchorA_p1=x._emscripten_bind_b2WheelJointDef__set_localAnchorA_p1,vm=Module._emscripten_bind_b2DistanceJointDef__set_bodyB_p1=x._emscripten_bind_b2DistanceJointDef__set_bodyB_p1,wm=Module._emscripten_bind_b2Transform__SetIdentity_p0=x._emscripten_bind_b2Transform__SetIdentity_p0,xm=Module._emscripten_bind_b2FrictionJointDef__set_localAnchorA_p1=x._emscripten_bind_b2FrictionJointDef__set_localAnchorA_p1, +ym=Module._emscripten_bind_b2Body__SetTransform_p2=x._emscripten_bind_b2Body__SetTransform_p2,zm=Module._emscripten_bind_b2DistanceJoint__GetReactionTorque_p1=x._emscripten_bind_b2DistanceJoint__GetReactionTorque_p1,Am=Module._emscripten_bind_b2StackAllocator__b2StackAllocator_p0=x._emscripten_bind_b2StackAllocator__b2StackAllocator_p0,Bm=Module._emscripten_bind_b2MouseJointDef__set_maxForce_p1=x._emscripten_bind_b2MouseJointDef__set_maxForce_p1,Cm=Module._emscripten_bind_b2RevoluteJoint__GetMotorTorque_p1= +x._emscripten_bind_b2RevoluteJoint__GetMotorTorque_p1,Dm=Module._emscripten_bind_b2Vec2__set_y_p1=x._emscripten_bind_b2Vec2__set_y_p1,Em=Module._emscripten_bind_b2CircleShape__Clone_p1=x._emscripten_bind_b2CircleShape__Clone_p1,Fm=Module._emscripten_bind_b2Rot__GetAngle_p0=x._emscripten_bind_b2Rot__GetAngle_p0,Gm=Module._emscripten_bind_b2Color____destroy___p0=x._emscripten_bind_b2Color____destroy___p0,Hm=Module._emscripten_bind_b2WeldJoint__GetBodyA_p0=x._emscripten_bind_b2WeldJoint__GetBodyA_p0, +Im=Module._emscripten_bind_b2Fixture__GetRestitution_p0=x._emscripten_bind_b2Fixture__GetRestitution_p0,Jm=Module._emscripten_bind_b2DistanceJointDef__set_length_p1=x._emscripten_bind_b2DistanceJointDef__set_length_p1,Km=Module._emscripten_bind_b2PrismaticJointDef__get_localAxisA_p0=x._emscripten_bind_b2PrismaticJointDef__get_localAxisA_p0,Lm=Module._emscripten_bind_b2Color__b2Color_p3=x._emscripten_bind_b2Color__b2Color_p3,Mm=Module._emscripten_bind_b2Body__ApplyForceToCenter_p1=x._emscripten_bind_b2Body__ApplyForceToCenter_p1, +Nm=Module._emscripten_bind_b2PrismaticJoint__SetUserData_p1=x._emscripten_bind_b2PrismaticJoint__SetUserData_p1,Om=Module._emscripten_bind_b2Color__get_r_p0=x._emscripten_bind_b2Color__get_r_p0,Pm=Module._emscripten_bind_b2RevoluteJoint__b2RevoluteJoint_p1=x._emscripten_bind_b2RevoluteJoint__b2RevoluteJoint_p1,Qm=Module._emscripten_bind_b2RevoluteJoint__GetCollideConnected_p0=x._emscripten_bind_b2RevoluteJoint__GetCollideConnected_p0,Rm=Module._emscripten_bind_b2PrismaticJoint__IsActive_p0=x._emscripten_bind_b2PrismaticJoint__IsActive_p0, +Sm=Module._emscripten_bind_b2Body__SetFixedRotation_p1=x._emscripten_bind_b2Body__SetFixedRotation_p1,Tm=Module._emscripten_bind_b2RopeJointDef____destroy___p0=x._emscripten_bind_b2RopeJointDef____destroy___p0,Um=Module._emscripten_bind_b2PrismaticJointDef__get_bodyB_p1=x._emscripten_bind_b2PrismaticJointDef__get_bodyB_p1,Vm=Module._emscripten_bind_b2Shape__set_m_radius_p1=x._emscripten_bind_b2Shape__set_m_radius_p1,Wm=Module._emscripten_bind_b2WheelJoint__GetBodyB_p0=x._emscripten_bind_b2WheelJoint__GetBodyB_p0, +Xm=Module._emscripten_bind_b2JointDef__get_bodyA_p0=x._emscripten_bind_b2JointDef__get_bodyA_p0,Ym=Module._emscripten_bind_b2World__GetContactCount_p0=x._emscripten_bind_b2World__GetContactCount_p0,Zm=Module._emscripten_bind_b2Fixture__b2Fixture_p0=x._emscripten_bind_b2Fixture__b2Fixture_p0,$m=Module._emscripten_bind_b2StackAllocator__Allocate_p1=x._emscripten_bind_b2StackAllocator__Allocate_p1,an=Module._emscripten_bind_b2Body__SetGravityScale_p1=x._emscripten_bind_b2Body__SetGravityScale_p1,bn= +Module._emscripten_bind_b2BroadPhase__CreateProxy_p2=x._emscripten_bind_b2BroadPhase__CreateProxy_p2,cn=Module._emscripten_bind_b2WheelJoint__GetLocalAnchorA_p0=x._emscripten_bind_b2WheelJoint__GetLocalAnchorA_p0,dn=Module._emscripten_bind_b2FrictionJointDef__set_bodyB_p1=x._emscripten_bind_b2FrictionJointDef__set_bodyB_p1,en=Module._emscripten_bind_b2WheelJoint__SetSpringFrequencyHz_p1=x._emscripten_bind_b2WheelJoint__SetSpringFrequencyHz_p1,fn=Module._emscripten_bind_b2MouseJointDef__b2MouseJointDef_p0= +x._emscripten_bind_b2MouseJointDef__b2MouseJointDef_p0,gn=Module._emscripten_bind_b2PrismaticJointDef__set_localAnchorB_p1=x._emscripten_bind_b2PrismaticJointDef__set_localAnchorB_p1,hn=Module._emscripten_bind_b2Filter____destroy___p0=x._emscripten_bind_b2Filter____destroy___p0,jn=Module._emscripten_bind_b2PrismaticJointDef__set_enableMotor_p1=x._emscripten_bind_b2PrismaticJointDef__set_enableMotor_p1,kn=Module._emscripten_bind_b2Fixture__GetUserData_p0=x._emscripten_bind_b2Fixture__GetUserData_p0, +ln=Module._emscripten_bind_b2AABB__get_upperBound_p0=x._emscripten_bind_b2AABB__get_upperBound_p0,mn=Module._emscripten_bind_b2PulleyJoint__Dump_p0=x._emscripten_bind_b2PulleyJoint__Dump_p0,nn=Module._emscripten_bind_b2RopeJointDef__get_localAnchorA_p0=x._emscripten_bind_b2RopeJointDef__get_localAnchorA_p0,on=Module._emscripten_bind_b2CircleShape__get_m_radius_p0=x._emscripten_bind_b2CircleShape__get_m_radius_p0,pn=Module._emscripten_bind_b2DistanceJoint__GetLength_p0=x._emscripten_bind_b2DistanceJoint__GetLength_p0, +qn=Module._emscripten_bind_b2BodyDef__set_angularVelocity_p1=x._emscripten_bind_b2BodyDef__set_angularVelocity_p1,rn=Module._emscripten_bind_b2RevoluteJointDef__get_motorSpeed_p0=x._emscripten_bind_b2RevoluteJointDef__get_motorSpeed_p0,sn=Module._emscripten_bind_b2PulleyJointDef__set_localAnchorA_p1=x._emscripten_bind_b2PulleyJointDef__set_localAnchorA_p1,tn=Module._emscripten_bind_b2RevoluteJoint__SetMotorSpeed_p1=x._emscripten_bind_b2RevoluteJoint__SetMotorSpeed_p1,un=Module._emscripten_bind_b2WeldJoint__GetReactionTorque_p1= +x._emscripten_bind_b2WeldJoint__GetReactionTorque_p1,vn=Module._emscripten_bind_b2GearJoint__SetUserData_p1=x._emscripten_bind_b2GearJoint__SetUserData_p1,wn=Module._emscripten_bind_b2PrismaticJoint__GetAnchorB_p0=x._emscripten_bind_b2PrismaticJoint__GetAnchorB_p0,xn=Module._emscripten_bind_b2MouseJointDef__set_target_p1=x._emscripten_bind_b2MouseJointDef__set_target_p1,yn=Module._emscripten_bind_b2WeldJoint__GetBodyB_p0=x._emscripten_bind_b2WeldJoint__GetBodyB_p0,zn=Module._emscripten_bind_b2PolygonShape__TestPoint_p2= +x._emscripten_bind_b2PolygonShape__TestPoint_p2,An=Module._emscripten_bind_b2WheelJointDef__set_localAnchorB_p1=x._emscripten_bind_b2WheelJointDef__set_localAnchorB_p1,Bn=Module._emscripten_bind_b2WheelJoint__GetReactionTorque_p1=x._emscripten_bind_b2WheelJoint__GetReactionTorque_p1,Cn=Module._emscripten_bind_b2FrictionJointDef__set_bodyA_p1=x._emscripten_bind_b2FrictionJointDef__set_bodyA_p1,Dn=Module._emscripten_bind_b2Color__b2Color_p0=x._emscripten_bind_b2Color__b2Color_p0,En=Module._emscripten_bind_b2BroadPhase__TestOverlap_p2= +x._emscripten_bind_b2BroadPhase__TestOverlap_p2,Fn=Module._emscripten_bind_b2PrismaticJointDef__set_localAnchorA_p1=x._emscripten_bind_b2PrismaticJointDef__set_localAnchorA_p1,Gn=Module._emscripten_bind_b2RevoluteJoint__GetReactionTorque_p1=x._emscripten_bind_b2RevoluteJoint__GetReactionTorque_p1,Hn=Module._emscripten_bind_b2Joint__GetAnchorB_p0=x._emscripten_bind_b2Joint__GetAnchorB_p0,In=Module._emscripten_bind_b2CircleShape__set_m_radius_p1=x._emscripten_bind_b2CircleShape__set_m_radius_p1,yb= +Module._memcpy=x._memcpy,Jn=Module._emscripten_bind_b2World__GetContactManager_p0=x._emscripten_bind_b2World__GetContactManager_p0,Kn=Module._emscripten_bind_b2RevoluteJoint__SetUserData_p1=x._emscripten_bind_b2RevoluteJoint__SetUserData_p1,Ln=Module._emscripten_bind_b2Contact__GetFixtureB_p0=x._emscripten_bind_b2Contact__GetFixtureB_p0,Mn=Module._emscripten_bind_b2Rot__GetYAxis_p0=x._emscripten_bind_b2Rot__GetYAxis_p0,Nn=Module._emscripten_bind_b2RevoluteJointDef__set_upperAngle_p1=x._emscripten_bind_b2RevoluteJointDef__set_upperAngle_p1, +On=Module._emscripten_bind_b2Shape__Clone_p1=x._emscripten_bind_b2Shape__Clone_p1,Pn=Module._emscripten_bind_b2PulleyJoint__GetType_p0=x._emscripten_bind_b2PulleyJoint__GetType_p0,Qn=Module._emscripten_bind_b2AABB__set_lowerBound_p1=x._emscripten_bind_b2AABB__set_lowerBound_p1,Rn=Module._emscripten_bind_b2RopeJoint__GetCollideConnected_p0=x._emscripten_bind_b2RopeJoint__GetCollideConnected_p0,Sn=Module._emscripten_bind_b2DistanceJoint__IsActive_p0=x._emscripten_bind_b2DistanceJoint__IsActive_p0,Tn= +Module._emscripten_bind_b2BodyDef__set_linearDamping_p1=x._emscripten_bind_b2BodyDef__set_linearDamping_p1,Un=Module._emscripten_bind_b2BroadPhase__GetTreeBalance_p0=x._emscripten_bind_b2BroadPhase__GetTreeBalance_p0,Vn=Module._emscripten_bind_b2AABB__GetExtents_p0=x._emscripten_bind_b2AABB__GetExtents_p0,Wn=Module._emscripten_bind_b2CircleShape____destroy___p0=x._emscripten_bind_b2CircleShape____destroy___p0,Xn=Module._emscripten_bind_b2WeldJoint__SetFrequency_p1=x._emscripten_bind_b2WeldJoint__SetFrequency_p1, +Yn=Module._emscripten_bind_b2GearJointDef__set_ratio_p1=x._emscripten_bind_b2GearJointDef__set_ratio_p1,Zn=Module._emscripten_bind_b2FixtureDef__get_density_p0=x._emscripten_bind_b2FixtureDef__get_density_p0,$n=Module._emscripten_bind_b2AABB__GetCenter_p0=x._emscripten_bind_b2AABB__GetCenter_p0,ao=Module._emscripten_bind_b2Draw__ClearFlags_p1=x._emscripten_bind_b2Draw__ClearFlags_p1,bo=Module._emscripten_bind_b2WeldJointDef__get_localAnchorA_p0=x._emscripten_bind_b2WeldJointDef__get_localAnchorA_p0, +co=Module._emscripten_bind_b2PolygonShape__GetType_p0=x._emscripten_bind_b2PolygonShape__GetType_p0,eo=Module._emscripten_bind_b2DistanceJointDef__set_dampingRatio_p1=x._emscripten_bind_b2DistanceJointDef__set_dampingRatio_p1,fo=Module._emscripten_bind_b2BroadPhase__GetUserData_p1=x._emscripten_bind_b2BroadPhase__GetUserData_p1,go=Module._emscripten_bind_b2Rot__get_c_p0=x._emscripten_bind_b2Rot__get_c_p0,ho=Module._emscripten_bind_b2World__GetAutoClearForces_p0=x._emscripten_bind_b2World__GetAutoClearForces_p0, +io=Module._emscripten_bind_b2World__GetTreeHeight_p0=x._emscripten_bind_b2World__GetTreeHeight_p0,jo=Module._emscripten_bind_b2AABB__IsValid_p0=x._emscripten_bind_b2AABB__IsValid_p0,ko=Module._emscripten_bind_b2RevoluteJoint__GetAnchorB_p0=x._emscripten_bind_b2RevoluteJoint__GetAnchorB_p0,lo=Module._emscripten_bind_b2RopeJointDef__get_bodyB_p1=x._emscripten_bind_b2RopeJointDef__get_bodyB_p1,mo=Module._emscripten_bind_b2World__CreateJoint_p1=x._emscripten_bind_b2World__CreateJoint_p1,no=Module._emscripten_bind_b2WheelJoint__GetDefinition_p1= +x._emscripten_bind_b2WheelJoint__GetDefinition_p1,oo=Module._emscripten_bind_b2Color__set_b_p1=x._emscripten_bind_b2Color__set_b_p1,po=Module._emscripten_bind_b2PrismaticJointDef__get_referenceAngle_p0=x._emscripten_bind_b2PrismaticJointDef__get_referenceAngle_p0,qo=Module._emscripten_bind_b2Body__GetLocalCenter_p0=x._emscripten_bind_b2Body__GetLocalCenter_p0,ro=Module._emscripten_bind_b2WheelJoint__GetLocalAxisA_p0=x._emscripten_bind_b2WheelJoint__GetLocalAxisA_p0,so=Module._emscripten_bind_b2Contact__GetFriction_p0= +x._emscripten_bind_b2Contact__GetFriction_p0,to=Module._emscripten_bind_b2Body__SetAngularVelocity_p1=x._emscripten_bind_b2Body__SetAngularVelocity_p1,uo=Module._emscripten_bind_b2PrismaticJoint__GetJointSpeed_p0=x._emscripten_bind_b2PrismaticJoint__GetJointSpeed_p0,vo=Module._emscripten_bind_b2CircleShape__TestPoint_p2=x._emscripten_bind_b2CircleShape__TestPoint_p2,wo=Module._emscripten_bind_b2Body__SetAwake_p1=x._emscripten_bind_b2Body__SetAwake_p1,xo=Module._emscripten_bind_b2Filter__set_categoryBits_p1= +x._emscripten_bind_b2Filter__set_categoryBits_p1,yo=Module._emscripten_bind_b2ChainShape__ComputeMass_p2=x._emscripten_bind_b2ChainShape__ComputeMass_p2,zo=Module._emscripten_bind_b2PrismaticJointDef__get_collideConnected_p1=x._emscripten_bind_b2PrismaticJointDef__get_collideConnected_p1,Ao=Module._emscripten_bind_b2World__CreateBody_p1=x._emscripten_bind_b2World__CreateBody_p1,Bo=Module._emscripten_bind_b2JointDef__get_bodyB_p0=x._emscripten_bind_b2JointDef__get_bodyB_p0,Co=Module._emscripten_bind_b2ChainShape__get_m_count_p0= +x._emscripten_bind_b2ChainShape__get_m_count_p0,Do=Module._emscripten_bind_b2Joint__GetType_p0=x._emscripten_bind_b2Joint__GetType_p0,Eo=Module._emscripten_bind_b2WheelJoint__GetCollideConnected_p0=x._emscripten_bind_b2WheelJoint__GetCollideConnected_p0,Fo=Module._emscripten_bind_b2WheelJointDef__set_localAxisA_p1=x._emscripten_bind_b2WheelJointDef__set_localAxisA_p1,Go=Module._emscripten_bind_b2CircleShape__GetVertex_p1=x._emscripten_bind_b2CircleShape__GetVertex_p1,Ho=Module._emscripten_bind_b2WeldJoint__GetNext_p0= +x._emscripten_bind_b2WeldJoint__GetNext_p0,Io=Module._emscripten_bind_b2WeldJoint__GetCollideConnected_p0=x._emscripten_bind_b2WeldJoint__GetCollideConnected_p0,Jo=Module._emscripten_bind_b2World__SetDestructionListener_p1=x._emscripten_bind_b2World__SetDestructionListener_p1,Ko=Module._emscripten_bind_b2WheelJointDef__get_localAxisA_p0=x._emscripten_bind_b2WheelJointDef__get_localAxisA_p0,Lo=Module._emscripten_bind_b2Joint__GetAnchorA_p0=x._emscripten_bind_b2Joint__GetAnchorA_p0,Mo=Module._emscripten_bind_b2DistanceProxy__b2DistanceProxy_p0= +x._emscripten_bind_b2DistanceProxy__b2DistanceProxy_p0,No=Module._emscripten_bind_b2WheelJoint__IsActive_p0=x._emscripten_bind_b2WheelJoint__IsActive_p0,Oo=Module._emscripten_bind_b2Transform____destroy___p0=x._emscripten_bind_b2Transform____destroy___p0,Po=Module._emscripten_bind_b2PolygonShape__ComputeMass_p2=x._emscripten_bind_b2PolygonShape__ComputeMass_p2,Qo=Module._emscripten_bind_b2RopeJointDef__get_bodyA_p1=x._emscripten_bind_b2RopeJointDef__get_bodyA_p1,Ro=Module._emscripten_bind_b2WheelJoint__b2WheelJoint_p1= +x._emscripten_bind_b2WheelJoint__b2WheelJoint_p1,So=Module._emscripten_bind_b2Body__GetLinearVelocityFromLocalPoint_p1=x._emscripten_bind_b2Body__GetLinearVelocityFromLocalPoint_p1,To=Module._emscripten_bind_b2Draw__DrawTransform_p1=x._emscripten_bind_b2Draw__DrawTransform_p1,Uo=Module._emscripten_bind_b2DistanceJoint__GetType_p0=x._emscripten_bind_b2DistanceJoint__GetType_p0,Vo=Module._emscripten_bind_b2MouseJointDef__set_bodyB_p1=x._emscripten_bind_b2MouseJointDef__set_bodyB_p1,Wo=Module._emscripten_bind_b2Fixture__GetFriction_p0= +x._emscripten_bind_b2Fixture__GetFriction_p0,Xo=Module._emscripten_bind_b2Body__GetWorld_p0=x._emscripten_bind_b2Body__GetWorld_p0,Yo=Module._emscripten_bind_b2PolygonShape__b2PolygonShape_p0=x._emscripten_bind_b2PolygonShape__b2PolygonShape_p0,Zo=Module._emscripten_bind_b2WeldJointDef__set_frequencyHz_p1=x._emscripten_bind_b2WeldJointDef__set_frequencyHz_p1,$o=Module._emscripten_bind_b2RevoluteJoint__GetJointAngle_p0=x._emscripten_bind_b2RevoluteJoint__GetJointAngle_p0,ap=Module._emscripten_bind_b2Body__ResetMassData_p0= +x._emscripten_bind_b2Body__ResetMassData_p0,bp=Module._emscripten_bind_b2RevoluteJoint__IsActive_p0=x._emscripten_bind_b2RevoluteJoint__IsActive_p0,cp=Module._emscripten_bind_b2FrictionJoint__SetUserData_p1=x._emscripten_bind_b2FrictionJoint__SetUserData_p1,dp=Module._emscripten_bind_b2PulleyJoint__GetReactionForce_p1=x._emscripten_bind_b2PulleyJoint__GetReactionForce_p1,ep=Module._emscripten_bind_b2Timer__b2Timer_p0=x._emscripten_bind_b2Timer__b2Timer_p0,fp=Module._emscripten_bind_b2World__SetContinuousPhysics_p1= +x._emscripten_bind_b2World__SetContinuousPhysics_p1,gp=Module._emscripten_bind_b2ContactManager__FindNewContacts_p0=x._emscripten_bind_b2ContactManager__FindNewContacts_p0,hp=Module._emscripten_bind_b2DistanceJointDef__get_localAnchorA_p0=x._emscripten_bind_b2DistanceJointDef__get_localAnchorA_p0,ip=Module._emscripten_bind_b2DynamicTree__GetMaxBalance_p0=x._emscripten_bind_b2DynamicTree__GetMaxBalance_p0,jp=Module._emscripten_bind_b2PolygonShape__GetVertex_p1=x._emscripten_bind_b2PolygonShape__GetVertex_p1, +kp=Module._emscripten_bind_b2WeldJointDef__get_frequencyHz_p0=x._emscripten_bind_b2WeldJointDef__get_frequencyHz_p0,lp=Module._emscripten_bind_b2ContactListener__BeginContact_p1=x._emscripten_bind_b2ContactListener__BeginContact_p1,mp=Module._emscripten_bind_b2RevoluteJointDef__set_collideConnected_p1=x._emscripten_bind_b2RevoluteJointDef__set_collideConnected_p1,np=Module._emscripten_bind_b2DistanceJoint__GetAnchorA_p0=x._emscripten_bind_b2DistanceJoint__GetAnchorA_p0,op=Module._emscripten_bind_b2PrismaticJoint__GetLocalAxisA_p0= +x._emscripten_bind_b2PrismaticJoint__GetLocalAxisA_p0,pp=Module._emscripten_bind_b2ChainShape__Clone_p1=x._emscripten_bind_b2ChainShape__Clone_p1,qp=Module._emscripten_bind_b2GearJointDef__b2GearJointDef_p0=x._emscripten_bind_b2GearJointDef__b2GearJointDef_p0,rp=Module._emscripten_bind_b2RevoluteJoint__GetBodyA_p0=x._emscripten_bind_b2RevoluteJoint__GetBodyA_p0,sp=Module._emscripten_bind_b2Body__ApplyForce_p2=x._emscripten_bind_b2Body__ApplyForce_p2,tp=Module._emscripten_bind_b2MouseJoint__GetReactionTorque_p1= +x._emscripten_bind_b2MouseJoint__GetReactionTorque_p1,up=Module._emscripten_bind_b2Vec2__get_y_p0=x._emscripten_bind_b2Vec2__get_y_p0,vp=Module._emscripten_bind_b2ContactEdge__get_contact_p0=x._emscripten_bind_b2ContactEdge__get_contact_p0,wp=Module._emscripten_bind_b2GearJointDef__set_bodyB_p1=x._emscripten_bind_b2GearJointDef__set_bodyB_p1,xp=Module._emscripten_bind_b2RevoluteJointDef__get_enableMotor_p0=x._emscripten_bind_b2RevoluteJointDef__get_enableMotor_p0,yp=Module._emscripten_bind_b2RopeJoint____destroy___p0= +x._emscripten_bind_b2RopeJoint____destroy___p0,zp=Module._emscripten_bind_b2WheelJointDef__b2WheelJointDef_p0=x._emscripten_bind_b2WheelJointDef__b2WheelJointDef_p0,Ap=Module._emscripten_bind_b2DistanceJoint__SetFrequency_p1=x._emscripten_bind_b2DistanceJoint__SetFrequency_p1,Bp=Module._emscripten_bind_b2PulleyJointDef__set_lengthA_p1=x._emscripten_bind_b2PulleyJointDef__set_lengthA_p1,Cp=Module._emscripten_bind_b2FixtureDef__get_friction_p0=x._emscripten_bind_b2FixtureDef__get_friction_p0,Dp=Module._emscripten_bind_b2ContactEdge__get_next_p0= +x._emscripten_bind_b2ContactEdge__get_next_p0,Ep=Module._emscripten_bind_b2RevoluteJoint__GetBodyB_p0=x._emscripten_bind_b2RevoluteJoint__GetBodyB_p0,Fp=Module._emscripten_bind_b2RevoluteJoint__GetUserData_p0=x._emscripten_bind_b2RevoluteJoint__GetUserData_p0,Gp=Module._emscripten_bind_b2Body__GetType_p0=x._emscripten_bind_b2Body__GetType_p0,Hp=Module._emscripten_bind_b2World__Step_p3=x._emscripten_bind_b2World__Step_p3,Ip=Module._emscripten_bind_b2Vec2__set_x_p1=x._emscripten_bind_b2Vec2__set_x_p1, +Jp=Module._emscripten_bind_b2ContactManager__b2ContactManager_p0=x._emscripten_bind_b2ContactManager__b2ContactManager_p0,Kp=Module._emscripten_bind_b2RopeJoint__GetNext_p0=x._emscripten_bind_b2RopeJoint__GetNext_p0,Lp=Module._emscripten_bind_b2WeldJoint__SetDampingRatio_p1=x._emscripten_bind_b2WeldJoint__SetDampingRatio_p1,Mp=Module._emscripten_bind_b2World__GetTreeQuality_p0=x._emscripten_bind_b2World__GetTreeQuality_p0,Np=Module._emscripten_bind_b2WeldJoint__GetAnchorB_p0=x._emscripten_bind_b2WeldJoint__GetAnchorB_p0, +Op=Module._emscripten_bind_b2Contact__GetRestitution_p0=x._emscripten_bind_b2Contact__GetRestitution_p0,Pp=Module._emscripten_bind_b2MouseJointDef____destroy___p0=x._emscripten_bind_b2MouseJointDef____destroy___p0,Qp=Module._emscripten_bind_b2Body__GetTransform_p0=x._emscripten_bind_b2Body__GetTransform_p0,Rp=Module._emscripten_bind_b2PrismaticJoint__b2PrismaticJoint_p1=x._emscripten_bind_b2PrismaticJoint__b2PrismaticJoint_p1,Sp=Module._emscripten_bind_b2RopeJointDef__get_maxLength_p0=x._emscripten_bind_b2RopeJointDef__get_maxLength_p0, +Tp=Module._emscripten_bind_b2DistanceJoint__GetAnchorB_p0=x._emscripten_bind_b2DistanceJoint__GetAnchorB_p0,Up=Module._emscripten_bind_b2ChainShape__set_m_vertices_p1=x._emscripten_bind_b2ChainShape__set_m_vertices_p1,Vp=Module._emscripten_bind_b2EdgeShape__TestPoint_p2=x._emscripten_bind_b2EdgeShape__TestPoint_p2,Wp=Module._emscripten_bind_b2FrictionJoint__GetMaxTorque_p0=x._emscripten_bind_b2FrictionJoint__GetMaxTorque_p0,Xp=Module._emscripten_bind_b2RopeJointDef__b2RopeJointDef_p0=x._emscripten_bind_b2RopeJointDef__b2RopeJointDef_p0, +Yp=Module._emscripten_bind_b2ContactManager__AddPair_p2=x._emscripten_bind_b2ContactManager__AddPair_p2,Zp=Module._emscripten_bind_b2Color__set_g_p1=x._emscripten_bind_b2Color__set_g_p1,$p=Module._emscripten_bind_b2WheelJoint__IsMotorEnabled_p0=x._emscripten_bind_b2WheelJoint__IsMotorEnabled_p0,aq=Module._emscripten_bind_b2QueryCallback__b2QueryCallback_p0=x._emscripten_bind_b2QueryCallback__b2QueryCallback_p0,bq=Module._emscripten_bind_b2WheelJointDef__get_collideConnected_p1=x._emscripten_bind_b2WheelJointDef__get_collideConnected_p1, +cq=Module._emscripten_bind_b2FrictionJoint__Dump_p0=x._emscripten_bind_b2FrictionJoint__Dump_p0,dq=Module._emscripten_bind_b2ChainShape__SetPrevVertex_p1=x._emscripten_bind_b2ChainShape__SetPrevVertex_p1,eq=Module._emscripten_bind_b2AABB__GetPerimeter_p0=x._emscripten_bind_b2AABB__GetPerimeter_p0,fq=Module._emscripten_bind_b2DistanceProxy__set_m_count_p1=x._emscripten_bind_b2DistanceProxy__set_m_count_p1,gq=Module._emscripten_bind_b2Body__GetLinearVelocityFromWorldPoint_p1=x._emscripten_bind_b2Body__GetLinearVelocityFromWorldPoint_p1, +hq=Module._emscripten_bind_b2MouseJointDef__set_bodyA_p1=x._emscripten_bind_b2MouseJointDef__set_bodyA_p1,iq=Module._emscripten_bind_b2DynamicTree__GetAreaRatio_p0=x._emscripten_bind_b2DynamicTree__GetAreaRatio_p0,jq=Module._emscripten_bind_b2World__QueryAABB_p2=x._emscripten_bind_b2World__QueryAABB_p2,kq=Module._emscripten_bind_b2RevoluteJoint__GetUpperLimit_p0=x._emscripten_bind_b2RevoluteJoint__GetUpperLimit_p0,lq=Module._emscripten_bind_b2World__SetGravity_p1=x._emscripten_bind_b2World__SetGravity_p1, +mq=Module._emscripten_bind_b2PulleyJointDef__Initialize_p7=x._emscripten_bind_b2PulleyJointDef__Initialize_p7,nq=Module._emscripten_bind_b2Color__get_b_p0=x._emscripten_bind_b2Color__get_b_p0,oq=Module._emscripten_bind_b2DistanceJoint__GetBodyA_p0=x._emscripten_bind_b2DistanceJoint__GetBodyA_p0,pq=Module._emscripten_bind_b2BroadPhase__DestroyProxy_p1=x._emscripten_bind_b2BroadPhase__DestroyProxy_p1,qq=Module._emscripten_bind_b2PulleyJoint____destroy___p0=x._emscripten_bind_b2PulleyJoint____destroy___p0, +rq=Module._emscripten_bind_b2BroadPhase__GetProxyCount_p0=x._emscripten_bind_b2BroadPhase__GetProxyCount_p0,sq=Module._emscripten_bind_b2DistanceJoint__GetLocalAnchorB_p0=x._emscripten_bind_b2DistanceJoint__GetLocalAnchorB_p0,tq=Module._emscripten_bind_b2ChainShape__GetChildEdge_p2=x._emscripten_bind_b2ChainShape__GetChildEdge_p2,uq=Module._emscripten_bind_b2EdgeShape__b2EdgeShape_p0=x._emscripten_bind_b2EdgeShape__b2EdgeShape_p0,vq=Module._emscripten_bind_b2ContactEdge__set_contact_p1=x._emscripten_bind_b2ContactEdge__set_contact_p1, +wq=Module._emscripten_bind_b2WheelJoint__SetMotorSpeed_p1=x._emscripten_bind_b2WheelJoint__SetMotorSpeed_p1,xq=Module._emscripten_bind_b2ChainShape__GetType_p0=x._emscripten_bind_b2ChainShape__GetType_p0,yq=Module._emscripten_bind_b2Fixture__SetFilterData_p1=x._emscripten_bind_b2Fixture__SetFilterData_p1,zq=Module._emscripten_bind_b2Body__ApplyAngularImpulse_p1=x._emscripten_bind_b2Body__ApplyAngularImpulse_p1,Aq=Module._emscripten_bind_b2RevoluteJoint__SetLimits_p2=x._emscripten_bind_b2RevoluteJoint__SetLimits_p2, +Bq=Module._emscripten_bind_b2ChainShape__TestPoint_p2=x._emscripten_bind_b2ChainShape__TestPoint_p2,Cq=Module._emscripten_bind_b2RevoluteJointDef__get_maxMotorTorque_p0=x._emscripten_bind_b2RevoluteJointDef__get_maxMotorTorque_p0,Dq=Module._emscripten_bind_b2CircleShape__get_m_p_p0=x._emscripten_bind_b2CircleShape__get_m_p_p0,Eq=Module._emscripten_bind_b2BodyDef__get_awake_p0=x._emscripten_bind_b2BodyDef__get_awake_p0,Fq=Module._emscripten_bind_b2MouseJoint__GetAnchorB_p0=x._emscripten_bind_b2MouseJoint__GetAnchorB_p0, +Gq=Module._emscripten_bind_b2Body__CreateFixture_p1=x._emscripten_bind_b2Body__CreateFixture_p1,Hq=Module._emscripten_bind_b2Body__CreateFixture_p2=x._emscripten_bind_b2Body__CreateFixture_p2,Iq=Module._emscripten_bind_b2GearJointDef____destroy___p0=x._emscripten_bind_b2GearJointDef____destroy___p0,Jq=Module._emscripten_bind_b2Fixture__GetDensity_p0=x._emscripten_bind_b2Fixture__GetDensity_p0,Kq=Module._emscripten_bind_b2PrismaticJoint__GetJointTranslation_p0=x._emscripten_bind_b2PrismaticJoint__GetJointTranslation_p0, +Lq=Module._emscripten_bind_b2WeldJoint__GetDampingRatio_p0=x._emscripten_bind_b2WeldJoint__GetDampingRatio_p0,Mq=Module._emscripten_bind_b2FrictionJoint__GetReactionForce_p1=x._emscripten_bind_b2FrictionJoint__GetReactionForce_p1,Nq=Module._emscripten_bind_b2BodyDef__set_userData_p1=x._emscripten_bind_b2BodyDef__set_userData_p1,Oq=Module._emscripten_bind_b2World__SetContactListener_p1=x._emscripten_bind_b2World__SetContactListener_p1,Pq=Module._emscripten_bind_b2PulleyJointDef__get_localAnchorB_p0= +x._emscripten_bind_b2PulleyJointDef__get_localAnchorB_p0,Qq=Module._emscripten_bind_b2FixtureDef__set_shape_p1=x._emscripten_bind_b2FixtureDef__set_shape_p1,Rq=Module._emscripten_bind_b2DistanceJoint__SetDampingRatio_p1=x._emscripten_bind_b2DistanceJoint__SetDampingRatio_p1,Sq=Module._emscripten_bind_b2Joint__Dump_p0=x._emscripten_bind_b2Joint__Dump_p0,Tq=Module._emscripten_bind_b2Shape__TestPoint_p2=x._emscripten_bind_b2Shape__TestPoint_p2,Uq=Module._emscripten_bind_b2RopeJointDef__set_maxLength_p1= +x._emscripten_bind_b2RopeJointDef__set_maxLength_p1,Vq=Module._emscripten_bind_b2RopeJoint__SetUserData_p1=x._emscripten_bind_b2RopeJoint__SetUserData_p1,Wq=Module._emscripten_bind_b2Transform__get_p_p0=x._emscripten_bind_b2Transform__get_p_p0,Xq=Module._emscripten_bind_b2PulleyJoint__GetLengthA_p0=x._emscripten_bind_b2PulleyJoint__GetLengthA_p0,Yq=Module._emscripten_bind_b2GearJoint__GetJoint2_p0=x._emscripten_bind_b2GearJoint__GetJoint2_p0,Zq=Module._emscripten_bind_b2Fixture__GetMassData_p1=x._emscripten_bind_b2Fixture__GetMassData_p1, +$q=Module._emscripten_bind_b2Body__IsBullet_p0=x._emscripten_bind_b2Body__IsBullet_p0,ar=Module._emscripten_bind_b2WeldJointDef____destroy___p0=x._emscripten_bind_b2WeldJointDef____destroy___p0,br=Module._emscripten_bind_b2PrismaticJoint__GetMotorSpeed_p0=x._emscripten_bind_b2PrismaticJoint__GetMotorSpeed_p0,cr=Module._emscripten_bind_b2GearJointDef__get_bodyA_p1=x._emscripten_bind_b2GearJointDef__get_bodyA_p1,dr=Module._emscripten_bind_b2Draw__DrawCircle_p3=x._emscripten_bind_b2Draw__DrawCircle_p3, +er=Module._emscripten_bind_b2FrictionJoint__GetLocalAnchorA_p0=x._emscripten_bind_b2FrictionJoint__GetLocalAnchorA_p0,fr=Module._emscripten_bind_b2Body__GetWorldPoint_p1=x._emscripten_bind_b2Body__GetWorldPoint_p1,gr=Module._emscripten_bind_b2PrismaticJointDef__set_referenceAngle_p1=x._emscripten_bind_b2PrismaticJointDef__set_referenceAngle_p1,hr=Module._emscripten_bind_b2GearJointDef__set_bodyA_p1=x._emscripten_bind_b2GearJointDef__set_bodyA_p1,ir=Module._emscripten_bind_b2RevoluteJointDef__set_motorSpeed_p1= +x._emscripten_bind_b2RevoluteJointDef__set_motorSpeed_p1,jr=Module._emscripten_bind_b2BodyDef__set_bullet_p1=x._emscripten_bind_b2BodyDef__set_bullet_p1,kr=Module._emscripten_bind_b2BodyDef__get_angularVelocity_p0=x._emscripten_bind_b2BodyDef__get_angularVelocity_p0,lr=Module._emscripten_bind_b2GearJoint__GetNext_p0=x._emscripten_bind_b2GearJoint__GetNext_p0,mr=Module._emscripten_bind_b2PrismaticJointDef__get_enableLimit_p0=x._emscripten_bind_b2PrismaticJointDef__get_enableLimit_p0,nr=Module._emscripten_bind_b2BodyDef__get_fixedRotation_p0= +x._emscripten_bind_b2BodyDef__get_fixedRotation_p0,or=Module._emscripten_bind_b2Body__GetFixtureList_p0=x._emscripten_bind_b2Body__GetFixtureList_p0,pr=Module._emscripten_bind_b2WheelJoint__GetJointTranslation_p0=x._emscripten_bind_b2WheelJoint__GetJointTranslation_p0,qr=Module._emscripten_bind_b2WeldJointDef__get_dampingRatio_p0=x._emscripten_bind_b2WeldJointDef__get_dampingRatio_p0,rr=Module._emscripten_bind_b2RopeJoint__SetMaxLength_p1=x._emscripten_bind_b2RopeJoint__SetMaxLength_p1,sr=Module._emscripten_bind_b2DistanceJointDef__get_localAnchorB_p0= +x._emscripten_bind_b2DistanceJointDef__get_localAnchorB_p0,tr=Module._emscripten_bind_b2PulleyJoint__GetGroundAnchorB_p0=x._emscripten_bind_b2PulleyJoint__GetGroundAnchorB_p0,ur=Module._emscripten_bind_b2PulleyJointDef__get_groundAnchorB_p0=x._emscripten_bind_b2PulleyJointDef__get_groundAnchorB_p0,vr=Module._emscripten_bind_b2GearJointDef__set_joint2_p1=x._emscripten_bind_b2GearJointDef__set_joint2_p1,wr=Module._emscripten_bind_b2BroadPhase__b2BroadPhase_p0=x._emscripten_bind_b2BroadPhase__b2BroadPhase_p0, +xr=Module._emscripten_bind_b2RevoluteJointDef__get_lowerAngle_p0=x._emscripten_bind_b2RevoluteJointDef__get_lowerAngle_p0,yr=Module._emscripten_bind_b2MouseJoint__SetTarget_p1=x._emscripten_bind_b2MouseJoint__SetTarget_p1,zr=Module._emscripten_bind_b2ContactEdge__set_prev_p1=x._emscripten_bind_b2ContactEdge__set_prev_p1,Ar=Module._emscripten_bind_b2PrismaticJointDef__get_upperTranslation_p0=x._emscripten_bind_b2PrismaticJointDef__get_upperTranslation_p0,Br=Module._emscripten_bind_b2ChainShape__set_m_radius_p1= +x._emscripten_bind_b2ChainShape__set_m_radius_p1,Cr=Module._emscripten_bind_b2Vec2__get_x_p0=x._emscripten_bind_b2Vec2__get_x_p0,Dr=Module._emscripten_bind_b2DistanceProxy__GetSupport_p1=x._emscripten_bind_b2DistanceProxy__GetSupport_p1,Er=Module._emscripten_bind_b2WheelJoint__GetLocalAnchorB_p0=x._emscripten_bind_b2WheelJoint__GetLocalAnchorB_p0,Fr=Module._emscripten_bind_b2GearJointDef__get_joint2_p0=x._emscripten_bind_b2GearJointDef__get_joint2_p0,Gr=Module._emscripten_bind_b2PrismaticJointDef__set_collideConnected_p1= +x._emscripten_bind_b2PrismaticJointDef__set_collideConnected_p1,Hr=Module._emscripten_bind_b2FrictionJointDef__set_localAnchorB_p1=x._emscripten_bind_b2FrictionJointDef__set_localAnchorB_p1,Ir=Module._emscripten_bind_b2PrismaticJointDef__set_localAxisA_p1=x._emscripten_bind_b2PrismaticJointDef__set_localAxisA_p1,Jr=Module._emscripten_bind_b2Fixture__SetDensity_p1=x._emscripten_bind_b2Fixture__SetDensity_p1,Kr=Module._emscripten_bind_b2RevoluteJointDef__set_enableLimit_p1=x._emscripten_bind_b2RevoluteJointDef__set_enableLimit_p1, +Lr=Module._emscripten_bind_b2Body__IsAwake_p0=x._emscripten_bind_b2Body__IsAwake_p0,Mr=Module._emscripten_bind_b2MouseJoint__GetAnchorA_p0=x._emscripten_bind_b2MouseJoint__GetAnchorA_p0,Nr=Module._emscripten_bind_b2PolygonShape__SetAsBox_p4=x._emscripten_bind_b2PolygonShape__SetAsBox_p4,Or=Module._emscripten_bind_b2PolygonShape__SetAsBox_p2=x._emscripten_bind_b2PolygonShape__SetAsBox_p2,Pr=Module._emscripten_bind_b2GearJointDef__set_joint1_p1=x._emscripten_bind_b2GearJointDef__set_joint1_p1,Qr=Module._emscripten_bind_b2Draw__DrawSolidCircle_p4= +x._emscripten_bind_b2Draw__DrawSolidCircle_p4,Rr=Module._emscripten_bind_b2World__GetSubStepping_p0=x._emscripten_bind_b2World__GetSubStepping_p0,Sr=Module._emscripten_bind_b2FrictionJoint__GetLocalAnchorB_p0=x._emscripten_bind_b2FrictionJoint__GetLocalAnchorB_p0;Module._free=x._free; +var Tr=Module._emscripten_bind_b2Body__SetLinearDamping_p1=x._emscripten_bind_b2Body__SetLinearDamping_p1,Ur=Module._emscripten_bind_b2Body__GetWorldVector_p1=x._emscripten_bind_b2Body__GetWorldVector_p1,Vr=Module._emscripten_bind_b2Fixture__SetFriction_p1=x._emscripten_bind_b2Fixture__SetFriction_p1,Wr=Module._emscripten_bind_b2Filter__get_groupIndex_p0=x._emscripten_bind_b2Filter__get_groupIndex_p0,Xr=Module._emscripten_bind_b2FixtureDef__get_isSensor_p0=x._emscripten_bind_b2FixtureDef__get_isSensor_p0, +Yr=Module._emscripten_bind_b2PrismaticJoint__GetUpperLimit_p0=x._emscripten_bind_b2PrismaticJoint__GetUpperLimit_p0,Zr=Module._emscripten_bind_b2PrismaticJoint__Dump_p0=x._emscripten_bind_b2PrismaticJoint__Dump_p0,$r=Module._emscripten_bind_b2Vec2__op_mul_p1=x._emscripten_bind_b2Vec2__op_mul_p1,as=Module._emscripten_bind_b2DistanceProxy__Set_p2=x._emscripten_bind_b2DistanceProxy__Set_p2,bs=Module._emscripten_bind_b2EdgeShape__Set_p2=x._emscripten_bind_b2EdgeShape__Set_p2,cs=Module._emscripten_bind_b2BodyDef__get_userData_p0= +x._emscripten_bind_b2BodyDef__get_userData_p0,ds=Module._emscripten_bind_b2CircleShape__set_m_p_p1=x._emscripten_bind_b2CircleShape__set_m_p_p1,es=Module._emscripten_bind_b2WheelJoint__GetMaxMotorTorque_p0=x._emscripten_bind_b2WheelJoint__GetMaxMotorTorque_p0,fs=Module._emscripten_bind_b2GearJoint__GetJoint1_p0=x._emscripten_bind_b2GearJoint__GetJoint1_p0,gs=Module._emscripten_bind_b2WheelJointDef__set_dampingRatio_p1=x._emscripten_bind_b2WheelJointDef__set_dampingRatio_p1,hs=Module._emscripten_bind_b2DistanceJointDef__set_collideConnected_p1= +x._emscripten_bind_b2DistanceJointDef__set_collideConnected_p1,is=Module._emscripten_bind_b2DistanceProxy__get_m_count_p0=x._emscripten_bind_b2DistanceProxy__get_m_count_p0,js=Module._emscripten_bind_b2WeldJointDef__set_dampingRatio_p1=x._emscripten_bind_b2WeldJointDef__set_dampingRatio_p1,ks=Module._emscripten_bind_b2DistanceJointDef__set_localAnchorB_p1=x._emscripten_bind_b2DistanceJointDef__set_localAnchorB_p1,ls=Module._emscripten_bind_b2GearJoint__GetCollideConnected_p0=x._emscripten_bind_b2GearJoint__GetCollideConnected_p0, +ms=Module._emscripten_bind_b2FrictionJoint__GetCollideConnected_p0=x._emscripten_bind_b2FrictionJoint__GetCollideConnected_p0,Ab=Module._memset=x._memset,ns=Module._emscripten_bind_b2WheelJoint__Dump_p0=x._emscripten_bind_b2WheelJoint__Dump_p0,os=Module._emscripten_bind_b2World__GetTreeBalance_p0=x._emscripten_bind_b2World__GetTreeBalance_p0,ps=Module._emscripten_bind_b2ContactListener__b2ContactListener_p0=x._emscripten_bind_b2ContactListener__b2ContactListener_p0,qs=Module._emscripten_bind_b2Rot____destroy___p0= +x._emscripten_bind_b2Rot____destroy___p0,rs=Module._emscripten_bind_b2PrismaticJoint__GetMaxMotorForce_p0=x._emscripten_bind_b2PrismaticJoint__GetMaxMotorForce_p0,ss=Module._emscripten_bind_b2PulleyJointDef__set_bodyB_p1=x._emscripten_bind_b2PulleyJointDef__set_bodyB_p1,ts=Module._emscripten_bind_b2PulleyJointDef__get_groundAnchorA_p0=x._emscripten_bind_b2PulleyJointDef__get_groundAnchorA_p0,us=Module._emscripten_bind_b2RevoluteJoint__GetMotorSpeed_p0=x._emscripten_bind_b2RevoluteJoint__GetMotorSpeed_p0, +vs=Module._emscripten_bind_b2DistanceJointDef__b2DistanceJointDef_p0=x._emscripten_bind_b2DistanceJointDef__b2DistanceJointDef_p0,ws=Module._emscripten_bind_b2Body__GetNext_p0=x._emscripten_bind_b2Body__GetNext_p0,xs=Module._emscripten_bind_b2BroadPhase__GetTreeHeight_p0=x._emscripten_bind_b2BroadPhase__GetTreeHeight_p0,ys=Module._emscripten_bind_b2Draw__DrawSegment_p3=x._emscripten_bind_b2Draw__DrawSegment_p3,zs=Module._emscripten_bind_b2Body__IsActive_p0=x._emscripten_bind_b2Body__IsActive_p0,As= +Module._emscripten_bind_b2Vec2__Set_p2=x._emscripten_bind_b2Vec2__Set_p2,Bs=Module._emscripten_bind_b2PulleyJoint__GetUserData_p0=x._emscripten_bind_b2PulleyJoint__GetUserData_p0,Cs=Module._emscripten_bind_b2ContactEdge__b2ContactEdge_p0=x._emscripten_bind_b2ContactEdge__b2ContactEdge_p0,Ds=Module._emscripten_bind_b2Vec3__b2Vec3_p3=x._emscripten_bind_b2Vec3__b2Vec3_p3,Es=Module._emscripten_bind_b2Vec3__b2Vec3_p0=x._emscripten_bind_b2Vec3__b2Vec3_p0,Fs=Module._emscripten_bind_b2PulleyJoint__GetGroundAnchorA_p0= +x._emscripten_bind_b2PulleyJoint__GetGroundAnchorA_p0,Gs=Module._emscripten_bind_b2JointDef__b2JointDef_p0=x._emscripten_bind_b2JointDef__b2JointDef_p0,Hs=Module._emscripten_bind_b2PulleyJoint__GetBodyB_p0=x._emscripten_bind_b2PulleyJoint__GetBodyB_p0,Is=Module._emscripten_bind_b2PulleyJointDef____destroy___p0=x._emscripten_bind_b2PulleyJointDef____destroy___p0,Js=Module._emscripten_bind_b2FixtureDef____destroy___p0=x._emscripten_bind_b2FixtureDef____destroy___p0,Ks=Module._emscripten_bind_b2EdgeShape__Clone_p1= +x._emscripten_bind_b2EdgeShape__Clone_p1,Ls=Module._emscripten_bind_b2Body__GetUserData_p0=x._emscripten_bind_b2Body__GetUserData_p0,Ms=Module._emscripten_bind_b2Body__SetUserData_p1=x._emscripten_bind_b2Body__SetUserData_p1,Ns=Module._emscripten_bind_b2FixtureDef__set_friction_p1=x._emscripten_bind_b2FixtureDef__set_friction_p1,Os=Module._emscripten_bind_b2PrismaticJointDef__get_bodyA_p1=x._emscripten_bind_b2PrismaticJointDef__get_bodyA_p1,Ps=Module._emscripten_bind_b2FrictionJoint__GetType_p0=x._emscripten_bind_b2FrictionJoint__GetType_p0, +Qs=Module._emscripten_bind_b2DistanceJointDef____destroy___p0=x._emscripten_bind_b2DistanceJointDef____destroy___p0,Rs=Module._emscripten_bind_b2FrictionJointDef__Initialize_p3=x._emscripten_bind_b2FrictionJointDef__Initialize_p3,Ss=Module._emscripten_bind_b2GearJoint__b2GearJoint_p1=x._emscripten_bind_b2GearJoint__b2GearJoint_p1,Ts=Module._emscripten_bind_b2Body__SetSleepingAllowed_p1=x._emscripten_bind_b2Body__SetSleepingAllowed_p1,Us=Module._emscripten_bind_b2Body__SetLinearVelocity_p1=x._emscripten_bind_b2Body__SetLinearVelocity_p1, +Vs=Module._emscripten_bind_b2Body__ApplyLinearImpulse_p2=x._emscripten_bind_b2Body__ApplyLinearImpulse_p2,Ws=Module._emscripten_bind_b2PulleyJoint__b2PulleyJoint_p1=x._emscripten_bind_b2PulleyJoint__b2PulleyJoint_p1,Xs=Module._emscripten_bind_b2MouseJointDef__get_bodyB_p1=x._emscripten_bind_b2MouseJointDef__get_bodyB_p1,Ys=Module._emscripten_bind_b2ContactManager__set_m_contactList_p1=x._emscripten_bind_b2ContactManager__set_m_contactList_p1,Zs=Module._emscripten_bind_b2MouseJoint__GetNext_p0=x._emscripten_bind_b2MouseJoint__GetNext_p0, +$s=Module._emscripten_bind_b2Transform__get_q_p0=x._emscripten_bind_b2Transform__get_q_p0,at=Module._emscripten_bind_b2DistanceJointDef__get_collideConnected_p1=x._emscripten_bind_b2DistanceJointDef__get_collideConnected_p1,bt=Module._emscripten_bind_b2WeldJointDef__set_bodyB_p1=x._emscripten_bind_b2WeldJointDef__set_bodyB_p1,ct=Module._emscripten_bind_b2DistanceJoint__GetReactionForce_p1=x._emscripten_bind_b2DistanceJoint__GetReactionForce_p1,dt=Module._emscripten_bind_b2FrictionJoint____destroy___p0= +x._emscripten_bind_b2FrictionJoint____destroy___p0,et=Module._emscripten_bind_b2JointDef__set_collideConnected_p1=x._emscripten_bind_b2JointDef__set_collideConnected_p1,ft=Module._emscripten_bind_b2CircleShape__ComputeAABB_p3=x._emscripten_bind_b2CircleShape__ComputeAABB_p3,gt=Module._emscripten_bind_b2QueryCallback__ReportFixture_p1=x._emscripten_bind_b2QueryCallback__ReportFixture_p1,ht=Module._emscripten_bind_b2GearJoint__GetRatio_p0=x._emscripten_bind_b2GearJoint__GetRatio_p0,it=Module._emscripten_bind_b2BlockAllocator__Allocate_p1= +x._emscripten_bind_b2BlockAllocator__Allocate_p1,jt=Module._emscripten_bind_b2GearJointDef__get_joint1_p0=x._emscripten_bind_b2GearJointDef__get_joint1_p0,kt=Module._emscripten_bind_b2AABB__Contains_p1=x._emscripten_bind_b2AABB__Contains_p1,lt=Module._emscripten_bind_b2FrictionJoint__GetNext_p0=x._emscripten_bind_b2FrictionJoint__GetNext_p0,mt=Module._emscripten_bind_b2ContactEdge____destroy___p0=x._emscripten_bind_b2ContactEdge____destroy___p0,nt=Module._emscripten_bind_b2RevoluteJointDef__Initialize_p3= +x._emscripten_bind_b2RevoluteJointDef__Initialize_p3,ot=Module._emscripten_bind_b2BodyDef__set_angle_p1=x._emscripten_bind_b2BodyDef__set_angle_p1,pt=Module._emscripten_bind_b2PrismaticJointDef__Initialize_p4=x._emscripten_bind_b2PrismaticJointDef__Initialize_p4,qt=Module._emscripten_bind_b2Body__GetContactList_p0=x._emscripten_bind_b2Body__GetContactList_p0,rt=Module._emscripten_bind_b2MouseJointDef__set_dampingRatio_p1=x._emscripten_bind_b2MouseJointDef__set_dampingRatio_p1,st=Module._emscripten_bind_b2PulleyJointDef__get_ratio_p0= +x._emscripten_bind_b2PulleyJointDef__get_ratio_p0,tt=Module._emscripten_bind_b2GearJoint__GetReactionForce_p1=x._emscripten_bind_b2GearJoint__GetReactionForce_p1,ut=Module._emscripten_bind_b2Body__GetWorldCenter_p0=x._emscripten_bind_b2Body__GetWorldCenter_p0,vt=Module._emscripten_bind_b2RevoluteJointDef__set_enableMotor_p1=x._emscripten_bind_b2RevoluteJointDef__set_enableMotor_p1,wt=Module._emscripten_bind_b2DistanceJointDef__set_localAnchorA_p1=x._emscripten_bind_b2DistanceJointDef__set_localAnchorA_p1, +xt=Module._emscripten_bind_b2BodyDef__set_angularDamping_p1=x._emscripten_bind_b2BodyDef__set_angularDamping_p1,yt=Module._emscripten_bind_b2MouseJointDef__set_collideConnected_p1=x._emscripten_bind_b2MouseJointDef__set_collideConnected_p1,zt=Module._emscripten_bind_b2Shape__ComputeAABB_p3=x._emscripten_bind_b2Shape__ComputeAABB_p3,At=Module._emscripten_bind_b2Joint__GetReactionTorque_p1=x._emscripten_bind_b2Joint__GetReactionTorque_p1,Bt=Module._emscripten_bind_b2WheelJoint__GetType_p0=x._emscripten_bind_b2WheelJoint__GetType_p0, +Ct=Module._emscripten_bind_b2Vec3__op_add_p1=x._emscripten_bind_b2Vec3__op_add_p1,Dt=Module._emscripten_bind_b2Filter__get_categoryBits_p0=x._emscripten_bind_b2Filter__get_categoryBits_p0,Et=Module._emscripten_bind_b2Vec3__set_z_p1=x._emscripten_bind_b2Vec3__set_z_p1,Ft=Module._emscripten_bind_b2CircleShape__GetChildCount_p0=x._emscripten_bind_b2CircleShape__GetChildCount_p0,Gt=Module._emscripten_bind_b2Transform__set_p_p1=x._emscripten_bind_b2Transform__set_p_p1,Ht=Module._emscripten_bind_b2Fixture__GetNext_p0= +x._emscripten_bind_b2Fixture__GetNext_p0,It=Module._emscripten_bind_b2World__SetWarmStarting_p1=x._emscripten_bind_b2World__SetWarmStarting_p1,Jt=Module._emscripten_bind_b2Vec3__op_sub_p0=x._emscripten_bind_b2Vec3__op_sub_p0,Kt=Module._emscripten_bind_b2ContactManager__Collide_p0=x._emscripten_bind_b2ContactManager__Collide_p0,Lt=Module._emscripten_bind_b2RevoluteJointDef__get_referenceAngle_p0=x._emscripten_bind_b2RevoluteJointDef__get_referenceAngle_p0,Mt=Module._emscripten_bind_b2ContactManager__get_m_contactListener_p0= +x._emscripten_bind_b2ContactManager__get_m_contactListener_p0,Nt=Module._emscripten_bind_b2AABB__RayCast_p2=x._emscripten_bind_b2AABB__RayCast_p2,Ot=Module._emscripten_bind_b2WeldJoint__Dump_p0=x._emscripten_bind_b2WeldJoint__Dump_p0,Pt=Module._emscripten_bind_b2PrismaticJointDef__set_enableLimit_p1=x._emscripten_bind_b2PrismaticJointDef__set_enableLimit_p1,Qt=Module._emscripten_bind_b2EdgeShape__GetType_p0=x._emscripten_bind_b2EdgeShape__GetType_p0,Rt=Module._emscripten_bind_b2BodyDef__get_gravityScale_p0= +x._emscripten_bind_b2BodyDef__get_gravityScale_p0,St=Module._emscripten_bind_b2DistanceProxy__set_m_vertices_p1=x._emscripten_bind_b2DistanceProxy__set_m_vertices_p1,Tt=Module._emscripten_bind_b2RevoluteJoint__SetMaxMotorTorque_p1=x._emscripten_bind_b2RevoluteJoint__SetMaxMotorTorque_p1,Ut=Module._emscripten_bind_b2MouseJointDef__get_bodyA_p1=x._emscripten_bind_b2MouseJointDef__get_bodyA_p1,Vt=Module._emscripten_bind_b2PulleyJoint__GetLengthB_p0=x._emscripten_bind_b2PulleyJoint__GetLengthB_p0,Wt= +Module._emscripten_bind_b2WeldJointDef__set_referenceAngle_p1=x._emscripten_bind_b2WeldJointDef__set_referenceAngle_p1,Xt=Module._emscripten_bind_b2BlockAllocator__Free_p2=x._emscripten_bind_b2BlockAllocator__Free_p2,Yt=Module._emscripten_bind_b2PrismaticJointDef__get_localAnchorA_p0=x._emscripten_bind_b2PrismaticJointDef__get_localAnchorA_p0,Zt=Module._emscripten_bind_b2GearJoint__SetRatio_p1=x._emscripten_bind_b2GearJoint__SetRatio_p1,$t=Module._emscripten_bind_b2BodyDef__get_angle_p0=x._emscripten_bind_b2BodyDef__get_angle_p0, +au=Module._emscripten_bind_b2PrismaticJoint__GetReferenceAngle_p0=x._emscripten_bind_b2PrismaticJoint__GetReferenceAngle_p0,bu=Module._emscripten_bind_b2WeldJointDef__set_bodyA_p1=x._emscripten_bind_b2WeldJointDef__set_bodyA_p1,cu=Module._emscripten_bind_b2DynamicTree__GetHeight_p0=x._emscripten_bind_b2DynamicTree__GetHeight_p0;Module.dynCall_viiiii=x.dynCall_viiiii;Module.dynCall_vif=x.dynCall_vif;Module.dynCall_viifii=x.dynCall_viifii;Module.dynCall_vi=x.dynCall_vi;Module.dynCall_vii=x.dynCall_vii; +Module.dynCall_ii=x.dynCall_ii;Module.dynCall_viifi=x.dynCall_viifi;Module.dynCall_if=x.dynCall_if;Module.dynCall_iiiii=x.dynCall_iiiii;Module.dynCall_viffif=x.dynCall_viffif;Module.dynCall_iiii=x.dynCall_iiii;Module.dynCall_fif=x.dynCall_fif;Module.dynCall_viff=x.dynCall_viff;Module.dynCall_viiiiiiif=x.dynCall_viiiiiiif;Module.dynCall_vifff=x.dynCall_vifff;Module.dynCall_viiiiii=x.dynCall_viiiiii;Module.dynCall_iiif=x.dynCall_iiif;Module.dynCall_iif=x.dynCall_iif;Module.dynCall_vifii=x.dynCall_vifii; +Module.dynCall_fi=x.dynCall_fi;Module.dynCall_iii=x.dynCall_iii;Module.dynCall_fiiiif=x.dynCall_fiiiif;Module.dynCall_i=x.dynCall_i;Module.dynCall_iiiiii=x.dynCall_iiiiii;Module.dynCall_ifff=x.dynCall_ifff;Module.dynCall_iff=x.dynCall_iff;Module.dynCall_viii=x.dynCall_viii;Module.dynCall_v=x.dynCall_v;Module.dynCall_viif=x.dynCall_viif;Module.dynCall_viiii=x.dynCall_viiii;var xa=function(a){return x.stackAlloc(a)},ja=function(){return x.stackSave()},ma=function(a){x.stackRestore(a)},kc=l; +Module.callMain=function(a){function c(){for(var a=0;3>a;a++)e.push(0)}qa(0==ob,"cannot call main when async dependencies remain! (listen on __ATMAIN__)");qa(!Module.preRun||0==Module.preRun.length,"cannot call main when preRun functions remain to be called");a=a||[];kb||(kb=j,gb(hb));var d=a.length+1,e=[Xa(lb("/bin/this.program"),"i8",0)];c();for(var g=0;g 20 ) { + updateStats(); + statusUpdateCounter = 0; + } +} + +function draw() { + + //black background + context.fillStyle = 'rgb(0,0,0)'; + context.fillRect( 0, 0, canvas.width, canvas.height ); + + context.save(); + context.translate(canvasOffset.x, canvasOffset.y); + context.scale(1,-1); + context.scale(PTM,PTM); + context.lineWidth /= PTM; + + drawAxes(context); + + context.fillStyle = 'rgb(255,255,0)'; + world.DrawDebugData(); + + if ( mouseJoint != null ) { + //mouse joint is not drawn with regular joints in debug draw + var p1 = mouseJoint.GetAnchorB(); + var p2 = mouseJoint.GetTarget(); + context.strokeStyle = 'rgb(204,204,204)'; + context.beginPath(); + context.moveTo(p1.get_x(),p1.get_y()); + context.lineTo(p2.get_x(),p2.get_y()); + context.stroke(); + } + + context.restore(); +} + +function updateStats() { + if ( ! showStats ) + return; + var currentViewCenterWorld = getWorldPointFromPixelPoint( viewCenterPixel ); + var fbSpan = document.getElementById('feedbackSpan'); + fbSpan.innerHTML = + "Status: "+(run?'running':'paused') + + "
Physics step time (average of last 60 steps): "+myRound(frameTime60,2)+"ms" + + //"
Mouse down: "+mouseDown + + "
PTM: "+myRound(PTM,2) + + "
View center: "+myRound(currentViewCenterWorld.x,3)+", "+myRound(currentViewCenterWorld.y,3) + + //"
Canvas offset: "+myRound(canvasOffset.x,0)+", "+myRound(canvasOffset.y,0) + + "
Mouse pos (pixel): "+mousePosPixel.x+", "+mousePosPixel.y + + "
Mouse pos (world): "+myRound(mousePosWorld.x,3)+", "+myRound(mousePosWorld.y,3); +} + +window.requestAnimFrame = (function(){ + return window.requestAnimationFrame || + window.webkitRequestAnimationFrame || + window.mozRequestAnimationFrame || + window.oRequestAnimationFrame || + window.msRequestAnimationFrame || + function( callback ){ + window.setTimeout(callback, 1000 / 60); + }; +})(); + +function animate() { + if ( run ) + requestAnimFrame( animate ); + step(); +} + +function pause() { + run = !run; + if (run) + animate(); + updateStats(); +} diff --git a/app/Lib/Vendor/Box2D/helpers.js b/app/Lib/Vendor/Box2D/helpers.js new file mode 100644 index 0000000..c91f847 --- /dev/null +++ b/app/Lib/Vendor/Box2D/helpers.js @@ -0,0 +1,106 @@ +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