Commit e8fa3733 authored by Gaurav Arora (gaa721)'s avatar Gaurav Arora (gaa721)
Browse files

Complete

parent 08645b40
No preview for this file type
This diff is collapsed.
File added
File added
File added
dragon.png

93.3 KB

This diff is collapsed.
......@@ -7,71 +7,116 @@
<script src="lib/prototype-1.6.0.2.js"></script>
<!-- box2djs -->
<script src='js/box2d/common/b2Settings.js'></script>
<script src='js/box2d/common/math/b2Vec2.js'></script>
<script src='js/box2d/common/math/b2Mat22.js'></script>
<script src='js/box2d/common/math/b2Math.js'></script>
<script src='js/box2d/collision/b2AABB.js'></script>
<script src='js/box2d/collision/b2Bound.js'></script>
<script src='js/box2d/collision/b2BoundValues.js'></script>
<script src='js/box2d/collision/b2Pair.js'></script>
<script src='js/box2d/collision/b2PairCallback.js'></script>
<script src='js/box2d/collision/b2BufferedPair.js'></script>
<script src='js/box2d/collision/b2PairManager.js'></script>
<script src='js/box2d/collision/b2BroadPhase.js'></script>
<script src='js/box2d/collision/b2Collision.js'></script>
<script src='js/box2d/collision/Features.js'></script>
<script src='js/box2d/collision/b2ContactID.js'></script>
<script src='js/box2d/collision/b2ContactPoint.js'></script>
<script src='js/box2d/collision/b2Distance.js'></script>
<script src='js/box2d/collision/b2Manifold.js'></script>
<script src='js/box2d/collision/b2OBB.js'></script>
<script src='js/box2d/collision/b2Proxy.js'></script>
<script src='js/box2d/collision/ClipVertex.js'></script>
<script src='js/box2d/collision/shapes/b2Shape.js'></script>
<script src='js/box2d/collision/shapes/b2ShapeDef.js'></script>
<script src='js/box2d/collision/shapes/b2BoxDef.js'></script>
<script src='js/box2d/collision/shapes/b2CircleDef.js'></script>
<script src='js/box2d/collision/shapes/b2CircleShape.js'></script>
<script src='js/box2d/collision/shapes/b2MassData.js'></script>
<script src='js/box2d/collision/shapes/b2PolyDef.js'></script>
<script src='js/box2d/collision/shapes/b2PolyShape.js'></script>
<script src='js/box2d/dynamics/b2Body.js'></script>
<script src='js/box2d/dynamics/b2BodyDef.js'></script>
<script src='js/box2d/dynamics/b2CollisionFilter.js'></script>
<script src='js/box2d/dynamics/b2Island.js'></script>
<script src='js/box2d/dynamics/b2TimeStep.js'></script>
<script src='js/box2d/dynamics/contacts/b2ContactNode.js'></script>
<script src='js/box2d/dynamics/contacts/b2Contact.js'></script>
<script src='js/box2d/dynamics/contacts/b2ContactConstraint.js'></script>
<script src='js/box2d/dynamics/contacts/b2ContactConstraintPoint.js'></script>
<script src='js/box2d/dynamics/contacts/b2ContactRegister.js'></script>
<script src='js/box2d/dynamics/contacts/b2ContactSolver.js'></script>
<script src='js/box2d/dynamics/contacts/b2CircleContact.js'></script>
<script src='js/box2d/dynamics/contacts/b2Conservative.js'></script>
<script src='js/box2d/dynamics/contacts/b2NullContact.js'></script>
<script src='js/box2d/dynamics/contacts/b2PolyAndCircleContact.js'></script>
<script src='js/box2d/dynamics/contacts/b2PolyContact.js'></script>
<script src='js/box2d/dynamics/b2ContactManager.js'></script>
<script src='js/box2d/dynamics/b2World.js'></script>
<script src='js/box2d/dynamics/b2WorldListener.js'></script>
<script src='js/box2d/dynamics/joints/b2JointNode.js'></script>
<script src='js/box2d/dynamics/joints/b2Joint.js'></script>
<script src='js/box2d/dynamics/joints/b2JointDef.js'></script>
<script src='js/box2d/dynamics/joints/b2DistanceJoint.js'></script>
<script src='js/box2d/dynamics/joints/b2DistanceJointDef.js'></script>
<script src='js/box2d/dynamics/joints/b2Jacobian.js'></script>
<script src='js/box2d/dynamics/joints/b2GearJoint.js'></script>
<script src='js/box2d/dynamics/joints/b2GearJointDef.js'></script>
<script src='js/box2d/dynamics/joints/b2MouseJoint.js'></script>
<script src='js/box2d/dynamics/joints/b2MouseJointDef.js'></script>
<script src='js/box2d/dynamics/joints/b2PrismaticJoint.js'></script>
<script src='js/box2d/dynamics/joints/b2PrismaticJointDef.js'></script>
<script src='js/box2d/dynamics/joints/b2PulleyJoint.js'></script>
<script src='js/box2d/dynamics/joints/b2PulleyJointDef.js'></script>
<script src='js/box2d/dynamics/joints/b2RevoluteJoint.js'></script>
<script src='js/box2d/dynamics/joints/b2RevoluteJointDef.js'></script>
<script src="javascript/misc/extend.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2BoundValues.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2PairManager.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/b2TimeStep.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Controllers/b2Controller.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Controllers/b2GravityController.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/b2DestructionListener.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Contacts/b2ContactEdge.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/Shapes/b2EdgeChainDef.js" type="text/javascript"></script>
<script src="javascript/Box2D/Common/Math/b2Vec2.js" type="text/javascript"></script>
<script src="javascript/Box2D/Common/Math/b2Vec3.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2DistanceProxy.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Contacts/b2ContactFactory.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Controllers/b2ConstantAccelController.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2SeparationFunction.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2DynamicTreePair.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Contacts/b2ContactConstraintPoint.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Controllers/b2ControllerEdge.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2DistanceInput.js" type="text/javascript"></script>
<script src="javascript/Box2D/Common/b2Settings.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2Proxy.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2Point.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2WorldManifold.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2RayCastOutput.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Controllers/b2ConstantForceController.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/Shapes/b2MassData.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2DynamicTree.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2JointEdge.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2RayCastInput.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/Features.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/b2FilterData.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2AABB.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2Jacobian.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2Bound.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2SimplexVertex.js" type="text/javascript"></script>
<script src="javascript/Box2D/Common/Math/b2Mat22.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2SimplexCache.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/Shapes/b2Shape.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2Segment.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Contacts/b2ContactRegister.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/b2DebugDraw.js" type="text/javascript"></script>
<script src="javascript/Box2D/Common/Math/b2Sweep.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2DistanceOutput.js" type="text/javascript"></script>
<script src="javascript/Box2D/Common/Math/b2Mat33.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Contacts/b2PositionSolverManifold.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2OBB.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2Pair.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/b2FixtureDef.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2ContactID.js" type="text/javascript"></script>
<script src="javascript/Box2D/Common/Math/b2Transform.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/Shapes/b2EdgeShape.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Controllers/b2BuoyancyController.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/b2Body.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/b2ContactImpulse.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Controllers/b2TensorDampingController.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2ManifoldPoint.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/Shapes/b2PolygonShape.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/b2Fixture.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2DynamicTreeNode.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/b2BodyDef.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2DynamicTreeBroadPhase.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2BroadPhase.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2Manifold.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/Shapes/b2CircleShape.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2Joint.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2LineJoint.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Contacts/b2ContactSolver.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2Simplex.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2WeldJoint.js" type="text/javascript"></script>
<script src="javascript/Box2D/Common/Math/b2Math.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2PulleyJoint.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2PrismaticJoint.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2RevoluteJoint.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2JointDef.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2LineJointDef.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2DistanceJoint.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2PulleyJointDef.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2DistanceJointDef.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2FrictionJointDef.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2WeldJointDef.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2GearJointDef.js" type="text/javascript"></script>
<script src="javascript/Box2D/Common/b2Color.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2FrictionJoint.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2Distance.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2MouseJoint.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2PrismaticJointDef.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2TimeOfImpact.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2GearJoint.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2TOIInput.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2RevoluteJointDef.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Joints/b2MouseJointDef.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Contacts/b2Contact.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Contacts/b2ContactConstraint.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Contacts/b2ContactResult.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Contacts/b2PolygonContact.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/ClipVertex.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/b2ContactFilter.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Contacts/b2NullContact.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/b2ContactListener.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/b2Island.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Contacts/b2PolyAndEdgeContact.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2Collision.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Contacts/b2PolyAndCircleContact.js" type="text/javascript"></script>
<script src="javascript/Box2D/Collision/b2ContactPoint.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Contacts/b2CircleContact.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/Contacts/b2EdgeAndCircleContact.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/b2ContactManager.js" type="text/javascript"></script>
<script src="javascript/Box2D/Dynamics/b2World.js" type="text/javascript"></script>
<script language="javascript" src="SAT.js"></script>
<script language="javascript" src="howler.js"></script>
<script src = "gamepad.js"></script>
<script language="javascript" src="scenario.js"></script>
<script language="javascript" src="boat.js "></script>
......
var ClipVertex = function() {
this.__varz();
this.__constructor.apply(this, arguments);
}
ClipVertex.prototype.__constructor = function(){}
ClipVertex.prototype.__varz = function(){
this.v = new b2Vec2();
this.id = new b2ContactID();
}
// static methods
// static attributes
// methods
ClipVertex.prototype.Set = function (other) {
this.v.SetV(other.v);
this.id.Set(other.id);
}
// attributes
ClipVertex.prototype.v = new b2Vec2();
ClipVertex.prototype.id = new b2ContactID();
\ No newline at end of file
var Features = function() {
this.__varz();
this.__constructor.apply(this, arguments);
}
Features.prototype.__constructor = function(){}
Features.prototype.__varz = function(){
}
// static methods
// static attributes
// methods
Features.prototype.__defineGetter__("referenceEdge", function() {
return this._referenceEdge;
});
Features.prototype.__defineSetter__("referenceEdge", function(value) {
this._referenceEdge = value;
this._m_id._key = (this._m_id._key & 0xffffff00) | (this._referenceEdge & 0x000000ff);
});
Features.prototype.__defineGetter__("incidentEdge", function() {
return this._incidentEdge;
});
Features.prototype.__defineSetter__("incidentEdge", function(value) {
this._incidentEdge = value;
this._m_id._key = (this._m_id._key & 0xffff00ff) | ((this._incidentEdge << 8) & 0x0000ff00);
});
Features.prototype.__defineGetter__("incidentVertex", function() {
return this._incidentVertex;
});
Features.prototype.__defineSetter__("incidentVertex", function(value) {
this._incidentVertex = value;
this._m_id._key = (this._m_id._key & 0xff00ffff) | ((this._incidentVertex << 16) & 0x00ff0000);
});
Features.prototype.__defineGetter__("flip", function() {
return this._flip;
});
Features.prototype.__defineSetter__("flip", function(value) {
this._flip = value;
this._m_id._key = (this._m_id._key & 0x00ffffff) | ((this._flip << 24) & 0xff000000);
});
// attributes
Features.prototype._referenceEdge = 0;
Features.prototype._incidentEdge = 0;
Features.prototype._incidentVertex = 0;
Features.prototype._flip = 0;
Features.prototype._m_id = null;
\ No newline at end of file
var b2CircleShape = function() {
b2Shape.prototype.__varz.call(this)
this.__varz();
this.__constructor.apply(this, arguments);
}
extend(b2CircleShape.prototype, b2Shape.prototype)
b2CircleShape.prototype._super = b2Shape.prototype;
b2CircleShape.prototype.__constructor = function (radius ) {
this._super.__constructor.apply(this, []);
this.m_type = b2Shape.e_circleShape;
this.m_radius = radius;
}
b2CircleShape.prototype.__varz = function(){
this.m_p = new b2Vec2();
}
// static methods
// static attributes
// methods
b2CircleShape.prototype.Copy = function () {
var s = new b2CircleShape();
s.Set(this);
return s;
}
b2CircleShape.prototype.Set = function (other) {
this._super.Set.apply(this, [other]);
if (isInstanceOf(other, b2CircleShape))
{
var other2 = other;
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) {
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) {
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) {
this.m_radius = radius;
}
// attributes
b2CircleShape.prototype.m_p = new b2Vec2();
\ No newline at end of file
var b2EdgeChainDef = function() {
this.__varz();
this.__constructor.apply(this, arguments);
}
b2EdgeChainDef.prototype.__constructor = function () {
this.vertexCount = 0;
this.isALoop = true;
this.vertices = [];
}
b2EdgeChainDef.prototype.__varz = function(){
}
// static methods
// static attributes
// methods
// attributes
b2EdgeChainDef.prototype.vertices = null;
b2EdgeChainDef.prototype.vertexCount = null;
b2EdgeChainDef.prototype.isALoop = null;
\ No newline at end of file
var b2EdgeShape = function() {
b2Shape.prototype.__varz.call(this)
this.__varz();
this.__constructor.apply(this, arguments);
}
extend(b2EdgeShape.prototype, b2Shape.prototype)
b2EdgeShape.prototype._super = b2Shape.prototype;
b2EdgeShape.prototype.__constructor = function (v1, v2) {
this._super.__constructor.apply(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.__varz = function(){
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();
}
// static methods
// static attributes
// methods
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;
}
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) {
massData.mass = 0;
massData.center.SetV(this.m_v1);
massData.I = 0;
}
b2EdgeShape.prototype.ComputeSubmergedArea = function (
normal,
offset,
xf,
c) {
var v0 = new b2Vec2(normal.x * offset, normal.y * offset);
var v1 = b2Math.MulX(xf, this.m_v1);