Section 1
//b2BoxDef (Engine.Collision.Shapes.b2BoxDef)
package Engine.Collision.Shapes {
import Engine.Common.Math.*;
public class b2BoxDef extends b2ShapeDef {
public var extents:b2Vec2;
public function b2BoxDef(){
type = b2Shape.e_boxShape;
extents = new b2Vec2(1, 1);
}
}
}//package Engine.Collision.Shapes
Section 2
//b2CircleDef (Engine.Collision.Shapes.b2CircleDef)
package Engine.Collision.Shapes {
public class b2CircleDef extends b2ShapeDef {
public var radius:Number;
public function b2CircleDef(){
type = b2Shape.e_circleShape;
radius = 1;
}
}
}//package Engine.Collision.Shapes
Section 3
//b2CircleShape (Engine.Collision.Shapes.b2CircleShape)
package Engine.Collision.Shapes {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
import Engine.Collision.*;
public class b2CircleShape extends b2Shape {
public var m_localPosition:b2Vec2;
public var m_radius:Number;
public function b2CircleShape(_arg1:b2ShapeDef, _arg2:b2Body, _arg3:b2Vec2){
var _local4:b2CircleDef;
var _local5:b2AABB;
var _local6:b2BroadPhase;
m_localPosition = new b2Vec2();
super(_arg1, _arg2);
_local4 = (_arg1 as b2CircleDef);
m_localPosition.Set((_arg1.localPosition.x - _arg3.x), (_arg1.localPosition.y - _arg3.y));
m_type = b2Shape.e_circleShape;
m_radius = _local4.radius;
m_R.SetM(m_body.m_R);
m_position.SetV(m_localPosition);
m_position.MulM(m_R);
m_position.Add(m_body.m_position);
_local5 = new b2AABB();
_local5.minVertex.Set((m_position.x - m_radius), (m_position.y - m_radius));
_local5.maxVertex.Set((m_position.x + m_radius), (m_position.y + m_radius));
_local6 = m_body.m_world.m_broadPhase;
if (_local6.InRange(_local5)){
m_proxyId = _local6.CreateProxy(_local5, _arg1.groupIndex, _arg1.categoryBits, _arg1.maskBits, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
if (m_proxyId == b2Pair.b2_nullProxy){
m_body.Freeze();
};
}
override public function ResetProxy(_arg1:b2BroadPhase){
var _local2:b2Proxy;
var _local3:int;
var _local4:uint;
var _local5:uint;
var _local6:b2AABB;
if (m_proxyId == b2Pair.b2_nullProxy){
return;
};
_local2 = _arg1.GetProxy(m_proxyId);
_local3 = _local2.groupIndex;
_local4 = _local2.categoryBits;
_local5 = _local2.maskBits;
_arg1.DestroyProxy(m_proxyId);
_local2 = null;
_local6 = new b2AABB();
_local6.minVertex.Set((m_position.x - m_radius), (m_position.y - m_radius));
_local6.maxVertex.Set((m_position.x + m_radius), (m_position.y + m_radius));
if (_arg1.InRange(_local6)){
m_proxyId = _arg1.CreateProxy(_local6, _local3, _local4, _local5, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
if (m_proxyId == b2Pair.b2_nullProxy){
m_body.Freeze();
};
}
override public function Support(_arg1:Number, _arg2:Number):b2Vec2{
var _local3:Number;
_local3 = Math.sqrt(((_arg1 * _arg1) + (_arg2 * _arg2)));
_arg1 = (_arg1 / _local3);
_arg2 = (_arg2 / _local3);
return (new b2Vec2((m_position.x + (m_radius * _arg1)), (m_position.y + (m_radius * _arg2))));
}
override public function Synchronize(_arg1:b2Vec2, _arg2:b2Mat22){
var _local3:b2AABB;
var _local4:b2BroadPhase;
m_R.SetM(_arg2);
m_position.SetV(m_localPosition);
m_position.MulM(_arg2);
m_position.Add(_arg1);
if (m_proxyId == b2Pair.b2_nullProxy){
return;
};
_local3 = new b2AABB();
_local3.minVertex.Set((m_position.x - m_radius), (m_position.y - m_radius));
_local3.maxVertex.Set((m_position.x + m_radius), (m_position.y + m_radius));
_local4 = m_body.m_world.m_broadPhase;
if (_local4.InRange(_local3)){
_local4.MoveProxy(m_proxyId, _local3);
} else {
_local4.DestroyProxy(m_proxyId);
m_proxyId = b2Pair.b2_nullProxy;
m_body.Freeze();
};
}
override public function TestPoint(_arg1:b2Vec2):Boolean{
var _local2:b2Vec2;
_local2 = new b2Vec2();
_local2.SetV(_arg1);
_local2.Subtract(m_position);
return ((b2Math.b2Dot(_local2, _local2) <= (m_radius * m_radius)));
}
}
}//package Engine.Collision.Shapes
Section 4
//b2MassData (Engine.Collision.Shapes.b2MassData)
package Engine.Collision.Shapes {
import Engine.Common.Math.*;
public class b2MassData {
public var mass:Number;// = 0
public var center:b2Vec2;
public var I:Number;// = 0
public function b2MassData(){
mass = 0;
center = new b2Vec2(0, 0);
I = 0;
super();
}
}
}//package Engine.Collision.Shapes
Section 5
//b2PolyDef (Engine.Collision.Shapes.b2PolyDef)
package Engine.Collision.Shapes {
import Engine.Common.Math.*;
import Engine.Common.*;
public class b2PolyDef extends b2ShapeDef {
public var vertexCount:int;
public var vertices:Array;
public function b2PolyDef(){
var _local1:int;
vertices = new Array(b2Settings.b2_maxPolyVertices);
super();
type = b2Shape.e_polyShape;
vertexCount = 0;
_local1 = 0;
while (_local1 < b2Settings.b2_maxPolyVertices) {
vertices[_local1] = new b2Vec2();
_local1++;
};
}
}
}//package Engine.Collision.Shapes
Section 6
//b2PolyShape (Engine.Collision.Shapes.b2PolyShape)
package Engine.Collision.Shapes {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
import Engine.Collision.*;
import Engine.Common.*;
public class b2PolyShape extends b2Shape {
public var m_vertices:Array;
public var m_normals:Array;
public var m_nextVert:Array;
public var m_localOBB:b2OBB;
public var m_vertexCount:int;
public function b2PolyShape(_arg1:b2ShapeDef, _arg2:b2Body, _arg3:b2Vec2){
var _local4:int;
var _local5:b2Vec2;
var _local6:b2Vec2;
var _local7:b2AABB;
var _local8:b2Mat22;
var _local9:Number;
var _local10:Number;
var _local11:b2Vec2;
var _local12:b2Vec2;
var _local13:b2Mat22;
var _local14:b2Mat22;
var _local15:b2Vec2;
var _local16:b2BroadPhase;
var _local17:b2BoxDef;
var _local18:b2PolyDef;
var _local19:b2Vec2;
m_localOBB = new b2OBB();
super(_arg1, _arg2);
_local7 = new b2AABB();
m_vertices = new Array(b2Settings.b2_maxPolyVertices);
m_nextVert = new Array();
m_normals = new Array(b2Settings.b2_maxPolyVertices);
m_type = b2Shape.e_polyShape;
_local8 = new b2Mat22(_arg1.localRotation);
_local9 = (_arg1.localPosition.x - _arg3.x);
_local10 = (_arg1.localPosition.y - _arg3.y);
if (_arg1.type == b2Shape.e_boxShape){
_local17 = (_arg1 as b2BoxDef);
m_vertexCount = 4;
_local5 = _local17.extents;
m_vertices[0] = new b2Vec2(_local5.x, _local5.y);
_local6 = m_vertices[0];
_local6.MulM(_local8);
_local6.x = (_local6.x + _local9);
_local6.y = (_local6.y + _local10);
m_vertices[1] = new b2Vec2(-(_local5.x), _local5.y);
_local6 = m_vertices[1];
_local6.MulM(_local8);
_local6.x = (_local6.x + _local9);
_local6.y = (_local6.y + _local10);
m_vertices[2] = new b2Vec2(-(_local5.x), -(_local5.y));
_local6 = m_vertices[2];
_local6.MulM(_local8);
_local6.x = (_local6.x + _local9);
_local6.y = (_local6.y + _local10);
m_vertices[3] = new b2Vec2(_local5.x, -(_local5.y));
_local6 = m_vertices[3];
_local6.MulM(_local8);
_local6.x = (_local6.x + _local9);
_local6.y = (_local6.y + _local10);
} else {
_local18 = (_arg1 as b2PolyDef);
m_vertexCount = _local18.vertexCount;
_local4 = 0;
while (_local4 < m_vertexCount) {
m_vertices[_local4] = _local18.vertices[_local4].Copy();
_local6 = m_vertices[_local4];
_local6.MulM(_local8);
_local6.x = (_local6.x + _local9);
_local6.y = (_local6.y + _local10);
_local4++;
};
};
_local11 = new b2Vec2(Number.MAX_VALUE, Number.MAX_VALUE);
_local12 = new b2Vec2(-(Number.MAX_VALUE), -(Number.MAX_VALUE));
_local4 = 0;
while (_local4 < m_vertexCount) {
_local11 = b2Math.b2MinV(_local11, m_vertices[_local4]);
_local12 = b2Math.b2MaxV(_local12, m_vertices[_local4]);
_local4++;
};
m_localOBB.R.SetIdentity();
m_localOBB.center.Set(((_local11.x + _local12.x) * 0.5), ((_local11.y + _local12.y) * 0.5));
m_localOBB.extents.Set(((_local12.x - _local11.x) * 0.5), ((_local12.y - _local11.y) * 0.5));
_local4 = 0;
while (_local4 < m_vertexCount) {
m_nextVert[_local4] = (((_local4 + 1) < m_vertexCount)) ? (_local4 + 1) : 0;
_local19 = m_vertices[m_nextVert[_local4]].Copy();
_local19.Subtract(m_vertices[_local4]);
m_normals[_local4] = new b2Vec2();
_local6 = m_normals[_local4];
_local6.SetV(_local19);
_local6.CrossVF(1);
_local6.Normalize();
_local4++;
};
_local4 = 0;
while (_local4 < m_vertexCount) {
_local4++;
};
m_R = m_body.m_R.Copy();
m_position.SetV(m_body.m_position);
_local13 = b2Math.b2MulMM(m_R, m_localOBB.R);
_local14 = b2Math.b2AbsM(_local13);
_local5 = b2Math.b2MulMV(_local14, m_localOBB.extents);
_local15 = b2Math.b2MulMV(m_R, m_localOBB.center);
_local15.Add(m_position);
_local7.minVertex.SetV(_local15);
_local7.minVertex.Subtract(_local5);
_local7.maxVertex.SetV(_local15);
_local7.maxVertex.Add(_local5);
_local16 = m_body.m_world.m_broadPhase;
if (_local16.InRange(_local7)){
m_proxyId = _local16.CreateProxy(_local7, _arg1.groupIndex, _arg1.categoryBits, _arg1.maskBits, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
if (m_proxyId == b2Pair.b2_nullProxy){
m_body.Freeze();
};
}
override public function ResetProxy(_arg1:b2BroadPhase){
var _local2:b2Proxy;
var _local3:int;
var _local4:uint;
var _local5:uint;
var _local6:b2Mat22;
var _local7:b2Mat22;
var _local8:b2Vec2;
var _local9:b2Vec2;
var _local10:b2AABB;
if (m_proxyId == b2Pair.b2_nullProxy){
return;
};
_local2 = _arg1.GetProxy(m_proxyId);
_local3 = _local2.groupIndex;
_local4 = _local2.categoryBits;
_local5 = _local2.maskBits;
_arg1.DestroyProxy(m_proxyId);
_local2 = null;
_local6 = b2Math.b2MulMM(m_R, m_localOBB.R);
_local7 = b2Math.b2AbsM(_local6);
_local8 = b2Math.b2MulMV(_local7, m_localOBB.extents);
_local9 = b2Math.b2MulMV(m_R, m_localOBB.center);
_local9.Add(m_position);
_local10 = new b2AABB();
_local10.minVertex.SetV(_local9);
_local10.minVertex.Subtract(_local8);
_local10.maxVertex.SetV(_local9);
_local10.maxVertex.Add(_local8);
if (_arg1.InRange(_local10)){
m_proxyId = _arg1.CreateProxy(_local10, _local3, _local4, _local5, this);
} else {
m_proxyId = b2Pair.b2_nullProxy;
};
if (m_proxyId == b2Pair.b2_nullProxy){
m_body.Freeze();
};
}
override public function Support(_arg1:Number, _arg2:Number):b2Vec2{
var _local3:Number;
var _local4:Number;
var _local5:int;
var _local6:Number;
var _local7:int;
var _local8:Number;
_local3 = ((_arg1 * m_R.col1.x) + (_arg2 * m_R.col1.y));
_local4 = ((_arg1 * m_R.col2.x) + (_arg2 * m_R.col2.y));
_local5 = 0;
_local6 = ((m_vertices[0].x * _local3) + (m_vertices[0].y * _local4));
_local7 = 1;
while (_local7 < m_vertexCount) {
_local8 = ((m_vertices[_local7].x * _local3) + (m_vertices[_local7].y * _local4));
if (_local8 > _local6){
_local5 = _local7;
_local6 = _local8;
};
_local7++;
};
return (new b2Vec2((m_position.x + ((m_R.col1.x * m_vertices[_local5].x) + (m_R.col2.x * m_vertices[_local5].y))), (m_position.y + ((m_R.col1.y * m_vertices[_local5].x) + (m_R.col2.y * m_vertices[_local5].y)))));
}
override public function Synchronize(_arg1:b2Vec2, _arg2:b2Mat22){
var _local3:b2Mat22;
var _local4:b2Mat22;
var _local5:b2Vec2;
var _local6:b2Vec2;
var _local7:b2AABB;
var _local8:b2BroadPhase;
m_R.SetM(_arg2);
m_position.SetV(_arg1);
if (m_proxyId == b2Pair.b2_nullProxy){
return;
};
_local3 = b2Math.b2MulMM(m_R, m_localOBB.R);
_local4 = b2Math.b2AbsM(_local3);
_local5 = b2Math.b2MulMV(_local4, m_localOBB.extents);
_local6 = b2Math.b2MulMV(m_R, m_localOBB.center);
_local6.Add(m_position);
_local7 = new b2AABB();
_local7.minVertex.SetV(_local6);
_local7.minVertex.Subtract(_local5);
_local7.maxVertex.SetV(_local6);
_local7.maxVertex.Add(_local5);
_local8 = m_body.m_world.m_broadPhase;
if (_local8.InRange(_local7)){
_local8.MoveProxy(m_proxyId, _local7);
} else {
_local8.DestroyProxy(m_proxyId);
m_proxyId = b2Pair.b2_nullProxy;
m_body.Freeze();
};
}
override public function TestPoint(_arg1:b2Vec2):Boolean{
var _local2:b2Vec2;
var _local3:int;
var _local4:b2Vec2;
var _local5:Number;
_local2 = new b2Vec2();
_local2.SetV(_arg1);
_local2.Subtract(m_position);
_local2.MulTM(m_R);
_local3 = 0;
while (_local3 < m_vertexCount) {
_local4 = new b2Vec2();
_local4.SetV(_local2);
_local4.Subtract(m_vertices[_local3]);
_local5 = b2Math.b2Dot(m_normals[_local3], _local4);
if (_local5 > 0){
return (false);
};
_local3++;
};
return (true);
}
}
}//package Engine.Collision.Shapes
Section 7
//b2Shape (Engine.Collision.Shapes.b2Shape)
package Engine.Collision.Shapes {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
import Engine.Collision.*;
public class b2Shape {
public var m_R:b2Mat22;
public var m_next:b2Shape;
public var m_type:int;
public var m_friction:Number;
public var m_density:Number;
public var m_proxyId:int;
public var m_userData;// = null
public var m_body:b2Body;
public var m_restitution:Number;
public var m_position:b2Vec2;
public static const e_boxShape:int = 1;
public static const e_unknownShape:int = -1;
public static const e_shapeTypeCount:int = 4;
public static const e_circleShape:int = 0;
public static const e_meshShape:int = 3;
public static const e_polyShape:int = 2;
public function b2Shape(_arg1:b2ShapeDef, _arg2:b2Body){
m_userData = null;
m_position = new b2Vec2();
m_R = new b2Mat22();
super();
m_userData = _arg1.userData;
m_friction = _arg1.friction;
m_restitution = _arg1.restitution;
m_body = _arg2;
m_proxyId = b2Pair.b2_nullProxy;
m_density = _arg1.density;
}
public function GetPosition():b2Vec2{
return (m_position);
}
public function GetNext():b2Shape{
return (m_next);
}
public function GetType():int{
return (m_type);
}
public function GetUserData(){
return (m_userData);
}
public function Support(_arg1:Number, _arg2:Number):b2Vec2{
return (null);
}
public function Synchronize(_arg1:b2Vec2, _arg2:b2Mat22){
}
public function GetRotationMatrix():b2Mat22{
return (m_R);
}
public function GetBody():b2Body{
return (m_body);
}
public function TestPoint(_arg1:b2Vec2):Boolean{
return (false);
}
public function ResetProxy(_arg1:b2BroadPhase){
}
public static function Destroy(_arg1:b2Shape){
if (_arg1.m_proxyId != b2Pair.b2_nullProxy){
_arg1.m_body.m_world.m_broadPhase.DestroyProxy(_arg1.m_proxyId);
};
}
public static function PolyMass(_arg1:b2MassData, _arg2:Array, _arg3:int, _arg4:Number){
var _local5:b2Vec2;
var _local6:Number;
var _local7:Number;
var _local8:b2Vec2;
var _local9:Number;
var _local10:int;
var _local11:b2Vec2;
var _local12:b2Vec2;
var _local13:b2Vec2;
var _local14:b2Vec2;
var _local15:b2Vec2;
var _local16:Number;
var _local17:Number;
var _local18:b2Vec2;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
_local5 = new b2Vec2();
_local5.SetZero();
_local6 = 0;
_local7 = 0;
_local8 = new b2Vec2(0, 0);
_local9 = (1 / 3);
_local10 = 0;
while (_local10 < _arg3) {
_local11 = _local8;
_local12 = _arg2[_local10];
_local13 = (((_local10 + 1) < _arg3)) ? _arg2[(_local10 + 1)] : _arg2[0];
_local14 = b2Math.SubtractVV(_local12, _local11);
_local15 = b2Math.SubtractVV(_local13, _local11);
_local16 = b2Math.b2CrossVV(_local14, _local15);
_local17 = (0.5 * _local16);
_local6 = (_local6 + _local17);
_local18 = new b2Vec2();
_local18.SetV(_local11);
_local18.Add(_local12);
_local18.Add(_local13);
_local18.Multiply((_local9 * _local17));
_local5.Add(_local18);
_local19 = _local11.x;
_local20 = _local11.y;
_local21 = _local14.x;
_local22 = _local14.y;
_local23 = _local15.x;
_local24 = _local15.y;
_local25 = ((_local9 * ((0.25 * (((_local21 * _local21) + (_local23 * _local21)) + (_local23 * _local23))) + ((_local19 * _local21) + (_local19 * _local23)))) + ((0.5 * _local19) * _local19));
_local26 = ((_local9 * ((0.25 * (((_local22 * _local22) + (_local24 * _local22)) + (_local24 * _local24))) + ((_local20 * _local22) + (_local20 * _local24)))) + ((0.5 * _local20) * _local20));
_local7 = (_local7 + (_local16 * (_local25 + _local26)));
_local10++;
};
_arg1.mass = (_arg4 * _local6);
_local5.Multiply((1 / _local6));
_arg1.center = _local5;
_local7 = (_arg4 * (_local7 - (_local6 * b2Math.b2Dot(_local5, _local5))));
_arg1.I = _local7;
}
public static function Create(_arg1:b2ShapeDef, _arg2:b2Body, _arg3:b2Vec2):b2Shape{
switch (_arg1.type){
case e_circleShape:
return (new b2CircleShape(_arg1, _arg2, _arg3));
case e_boxShape:
case e_polyShape:
return (new b2PolyShape(_arg1, _arg2, _arg3));
};
return (null);
}
}
}//package Engine.Collision.Shapes
Section 8
//b2ShapeDef (Engine.Collision.Shapes.b2ShapeDef)
package Engine.Collision.Shapes {
import Engine.Common.Math.*;
import Engine.Common.*;
public class b2ShapeDef {
public var groupIndex:int;
public var categoryBits:int;
public var localRotation:Number;
public var restitution:Number;
public var userData;// = null
public var density:Number;
public var maskBits:int;
public var type:int;
public var localPosition:b2Vec2;
public var friction:Number;
public function b2ShapeDef(){
userData = null;
super();
type = b2Shape.e_unknownShape;
userData = null;
localPosition = new b2Vec2(0, 0);
localRotation = 0;
friction = 0.2;
restitution = 0;
density = 0;
categoryBits = 1;
maskBits = 0xFFFF;
groupIndex = 0;
}
public function ComputeMass(_arg1:b2MassData){
var _local2:b2CircleDef;
var _local3:b2BoxDef;
var _local4:b2PolyDef;
_arg1.center = new b2Vec2(0, 0);
if (density == 0){
_arg1.mass = 0;
_arg1.center.Set(0, 0);
_arg1.I = 0;
};
switch (type){
case b2Shape.e_circleShape:
_local2 = (this as b2CircleDef);
_arg1.mass = (((density * b2Settings.b2_pi) * _local2.radius) * _local2.radius);
_arg1.center.Set(0, 0);
_arg1.I = (((0.5 * _arg1.mass) * _local2.radius) * _local2.radius);
break;
case b2Shape.e_boxShape:
_local3 = (this as b2BoxDef);
_arg1.mass = (((4 * density) * _local3.extents.x) * _local3.extents.y);
_arg1.center.Set(0, 0);
_arg1.I = ((_arg1.mass / 3) * b2Math.b2Dot(_local3.extents, _local3.extents));
break;
case b2Shape.e_polyShape:
_local4 = (this as b2PolyDef);
b2Shape.PolyMass(_arg1, _local4.vertices, _local4.vertexCount, density);
break;
default:
_arg1.mass = 0;
_arg1.center.Set(0, 0);
_arg1.I = 0;
break;
};
}
}
}//package Engine.Collision.Shapes
Section 9
//b2AABB (Engine.Collision.b2AABB)
package Engine.Collision {
import Engine.Common.Math.*;
public class b2AABB {
public var minVertex:b2Vec2;
public var maxVertex:b2Vec2;
public function b2AABB(){
minVertex = new b2Vec2();
maxVertex = new b2Vec2();
super();
}
public function IsValid():Boolean{
var _local1:Number;
var _local2:Number;
var _local3:Boolean;
_local1 = maxVertex.x;
_local2 = maxVertex.y;
_local1 = maxVertex.x;
_local2 = maxVertex.y;
_local1 = (_local1 - minVertex.x);
_local2 = (_local2 - minVertex.y);
_local3 = (((_local1 >= 0)) && ((_local2 >= 0)));
_local3 = ((((_local3) && (minVertex.IsValid()))) && (maxVertex.IsValid()));
return (_local3);
}
}
}//package Engine.Collision
Section 10
//b2Bound (Engine.Collision.b2Bound)
package Engine.Collision {
public class b2Bound {
public var proxyId:uint;
public var stabbingCount:uint;
public var value:uint;
public function Swap(_arg1:b2Bound){
var _local2:uint;
var _local3:uint;
var _local4:uint;
_local2 = value;
_local3 = proxyId;
_local4 = stabbingCount;
value = _arg1.value;
proxyId = _arg1.proxyId;
stabbingCount = _arg1.stabbingCount;
_arg1.value = _local2;
_arg1.proxyId = _local3;
_arg1.stabbingCount = _local4;
}
public function IsLower():Boolean{
return (((value & 1) == 0));
}
public function IsUpper():Boolean{
return (((value & 1) == 1));
}
}
}//package Engine.Collision
Section 11
//b2BroadPhase (Engine.Collision.b2BroadPhase)
package Engine.Collision {
import Engine.Common.Math.*;
import Engine.Common.*;
public class b2BroadPhase {
public var m_quantizationFactor:b2Vec2;
public var m_pairBuffer:Array;
public var m_worldAABB:b2AABB;
public var m_bounds:Array;
public var m_freeProxy:uint;
public var m_pairCallback:b2PairCallback;
public var m_proxyCount:int;
public var m_proxyPool:Array;
public var m_queryResultCount:int;
public var m_pairManager:b2PairManager;
public var m_pairBufferCount:int;
public var m_timeStamp:uint;
public var m_queryResults:Array;
public static const b2_nullEdge:uint = b2Settings.USHRT_MAX;
public static const b2_invalid:uint = b2Settings.USHRT_MAX;
public static var s_validate:Boolean = false;
public function b2BroadPhase(_arg1:b2AABB, _arg2:b2PairCallback){
var _local3:int;
var _local4:Number;
var _local5:Number;
var _local6:b2Proxy;
var _local7:int;
m_pairManager = new b2PairManager();
m_proxyPool = new Array(b2Settings.b2_maxPairs);
m_pairBuffer = new Array(b2Settings.b2_maxPairs);
m_bounds = new Array((2 * b2Settings.b2_maxProxies));
m_queryResults = new Array(b2Settings.b2_maxProxies);
m_quantizationFactor = new b2Vec2();
super();
m_worldAABB = _arg1;
m_pairCallback = _arg2;
m_proxyCount = 0;
_local3 = 0;
while (_local3 < b2Settings.b2_maxProxies) {
m_queryResults[_local3] = 0;
_local3++;
};
m_bounds = new Array(2);
_local3 = 0;
while (_local3 < 2) {
m_bounds[_local3] = new Array((2 * b2Settings.b2_maxProxies));
_local7 = 0;
while (_local7 < (2 * b2Settings.b2_maxProxies)) {
m_bounds[_local3][_local7] = new b2Bound();
_local7++;
};
_local3++;
};
_local3 = 0;
while (_local3 < b2Settings.b2_maxPairs) {
m_pairBuffer[_local3] = new b2BufferedPair();
_local3++;
};
_local4 = _arg1.maxVertex.x;
_local5 = _arg1.maxVertex.y;
_local4 = (_local4 - _arg1.minVertex.x);
_local5 = (_local5 - _arg1.minVertex.y);
m_quantizationFactor.x = (b2Settings.USHRT_MAX / _local4);
m_quantizationFactor.y = (b2Settings.USHRT_MAX / _local5);
_local3 = 0;
while (_local3 < (b2Settings.b2_maxProxies - 1)) {
_local6 = new b2Proxy();
m_proxyPool[_local3] = _local6;
_local6.SetNext((_local3 + 1));
_local6.timeStamp = 0;
_local6.overlapCount = b2_invalid;
_local6.userData = null;
_local3++;
};
_local6 = new b2Proxy();
m_proxyPool[(b2Settings.b2_maxProxies - 1)] = _local6;
_local6.SetNext(b2Pair.b2_nullProxy);
_local6.timeStamp = 0;
_local6.overlapCount = b2_invalid;
_local6.userData = null;
m_freeProxy = 0;
m_pairBufferCount = 0;
m_timeStamp = 1;
m_queryResultCount = 0;
}
public function ValidatePairs(){
var _local1:uint;
var _local2:int;
var _local3:b2Pair;
var _local4:b2Proxy;
var _local5:b2Proxy;
_local1 = m_pairManager.GetCount();
m_pairBuffer.sortOn(["proxyId1", "proxyId2"], Array.NUMERIC);
_local2 = 0;
while (_local2 < m_pairBufferCount) {
if (_local2 > 0){
};
_local3 = m_pairManager.Find(m_pairBuffer[_local2].proxyId1, m_pairBuffer[_local2].proxyId2);
_local4 = m_proxyPool[_local3.proxyId1];
_local5 = m_proxyPool[_local3.proxyId2];
_local2++;
};
}
public function QueryAABB(_arg1:b2AABB, _arg2, _arg3:int):int{
var _local4:Array;
var _local5:Array;
var _local6:uint;
var _local7:uint;
var _local8:Array;
var _local9:Array;
var _local10:int;
var _local11:int;
var _local12:b2Proxy;
_local4 = new Array();
_local5 = new Array();
ComputeBounds(_local4, _local5, _arg1);
_local8 = [_local6];
_local9 = [_local7];
Query(_local8, _local9, _local4[0], _local5[0], m_bounds[0], (2 * m_proxyCount), 0);
Query(_local8, _local9, _local4[1], _local5[1], m_bounds[1], (2 * m_proxyCount), 1);
_local10 = 0;
_local11 = 0;
while ((((_local11 < m_queryResultCount)) && ((_local10 < _arg3)))) {
_local12 = m_proxyPool[m_queryResults[_local11]];
_arg2[_local11] = _local12.userData;
_local11++;
_local10++;
};
m_queryResultCount = 0;
IncrementTimeStamp();
return (_local10);
}
private function RemoveBufferedPair(_arg1:uint, _arg2:uint){
var _local3:b2Pair;
_local3 = m_pairManager.Find(_arg1, _arg2);
if (_local3 == null){
return;
};
if (_local3.IsBuffered() == false){
if (m_pairBufferCount < b2Settings.b2_maxPairs){
_local3.SetBuffered();
m_pairBuffer[m_pairBufferCount].proxyId1 = _local3.proxyId1;
m_pairBuffer[m_pairBufferCount].proxyId2 = _local3.proxyId2;
m_pairBufferCount++;
};
};
_local3.SetRemoved();
}
public function GetProxy(_arg1:int):b2Proxy{
if ((((_arg1 == b2Pair.b2_nullProxy)) || ((m_proxyPool[_arg1].IsValid() == false)))){
return (null);
};
return (m_proxyPool[_arg1]);
}
public function Flush(){
var _local1:int;
var _local2:int;
var _local3:b2Pair;
var _local4:b2Proxy;
var _local5:b2Proxy;
_local2 = 0;
_local1 = 0;
while (_local1 < m_pairBufferCount) {
_local3 = m_pairManager.Find(m_pairBuffer[_local1].proxyId1, m_pairBuffer[_local1].proxyId2);
_local4 = m_proxyPool[_local3.proxyId1];
_local5 = m_proxyPool[_local3.proxyId2];
if (_local3.IsRemoved()){
if (_local3.IsReceived()){
m_pairCallback.PairRemoved(_local4.userData, _local5.userData, _local3.userData);
};
m_pairBuffer[_local2].proxyId1 = _local3.proxyId1;
m_pairBuffer[_local2].proxyId2 = _local3.proxyId2;
_local2++;
} else {
_local3.ClearBuffered();
if (_local3.IsReceived() == false){
_local3.userData = m_pairCallback.PairAdded(_local4.userData, _local5.userData);
_local3.SetReceived();
};
};
_local1++;
};
_local1 = 0;
while (_local1 < _local2) {
m_pairManager.Remove(m_pairBuffer[_local1].proxyId1, m_pairBuffer[_local1].proxyId2);
_local1++;
};
m_pairBufferCount = 0;
}
private function IncrementTimeStamp(){
var _local1:uint;
if (m_timeStamp == b2Settings.USHRT_MAX){
_local1 = 0;
while (_local1 < b2Settings.b2_maxProxies) {
m_proxyPool[_local1].timeStamp = 0;
_local1++;
};
m_timeStamp = 1;
} else {
m_timeStamp++;
};
}
private function Query(_arg1:Array, _arg2:Array, _arg3:uint, _arg4:uint, _arg5:Array, _arg6:uint, _arg7:int){
var _local8:uint;
var _local9:uint;
var _local10:uint;
var _local11:int;
var _local12:int;
var _local13:b2Proxy;
_local8 = BinarySearch(_arg5, _arg6, _arg3);
_local9 = BinarySearch(_arg5, _arg6, _arg4);
_local10 = _local8;
while (_local10 < _local9) {
if (_arg5[_local10].IsLower()){
IncrementOverlapCount(_arg5[_local10].proxyId);
};
_local10++;
};
if (_local8 > 0){
_local11 = (_local8 - 1);
_local12 = _arg5[_local11].stabbingCount;
while (_local12) {
if (_arg5[_local11].IsLower()){
_local13 = m_proxyPool[_arg5[_local11].proxyId];
if (_local8 <= _local13.upperBounds[_arg7]){
IncrementOverlapCount(_arg5[_local11].proxyId);
_local12--;
};
};
_local11--;
};
};
_arg1[0] = _local8;
_arg2[0] = _local9;
}
private function ComputeBounds(_arg1:Array, _arg2:Array, _arg3:b2AABB){
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
_local4 = _arg3.minVertex.x;
_local5 = _arg3.minVertex.y;
_local4 = b2Math.b2Min(_local4, m_worldAABB.maxVertex.x);
_local5 = b2Math.b2Min(_local5, m_worldAABB.maxVertex.y);
_local4 = b2Math.b2Max(_local4, m_worldAABB.minVertex.x);
_local5 = b2Math.b2Max(_local5, m_worldAABB.minVertex.y);
_local6 = _arg3.maxVertex.x;
_local7 = _arg3.maxVertex.y;
_local6 = b2Math.b2Min(_local6, m_worldAABB.maxVertex.x);
_local7 = b2Math.b2Min(_local7, m_worldAABB.maxVertex.y);
_local6 = b2Math.b2Max(_local6, m_worldAABB.minVertex.x);
_local7 = b2Math.b2Max(_local7, m_worldAABB.minVertex.y);
_arg1[0] = (uint((m_quantizationFactor.x * (_local4 - m_worldAABB.minVertex.x))) & (b2Settings.USHRT_MAX - 1));
_arg2[0] = ((uint((m_quantizationFactor.x * (_local6 - m_worldAABB.minVertex.x))) & 0xFFFF) | 1);
_arg1[1] = (uint((m_quantizationFactor.y * (_local5 - m_worldAABB.minVertex.y))) & (b2Settings.USHRT_MAX - 1));
_arg2[1] = ((uint((m_quantizationFactor.y * (_local7 - m_worldAABB.minVertex.y))) & 0xFFFF) | 1);
}
public function ShouldCollide(_arg1:int, _arg2:int):Boolean{
var _local3:b2Proxy;
var _local4:b2Proxy;
var _local5:Boolean;
_local3 = m_proxyPool[_arg1];
_local4 = m_proxyPool[_arg2];
if ((((_local3.groupIndex == _local4.groupIndex)) && (!((_local3.groupIndex == 0))))){
return ((_local3.groupIndex > 0));
};
_local5 = ((!(((_local3.maskBits & _local4.categoryBits) == 0))) && (!(((_local3.categoryBits & _local4.maskBits) == 0))));
return (_local5);
}
public function CreateProxy(_arg1:b2AABB, _arg2:int, _arg3:int, _arg4:int, _arg5):uint{
var _local6:uint;
var _local7:b2Proxy;
var _local8:uint;
var _local9:uint;
var _local10:Array;
var _local11:Array;
var _local12:int;
var _local13:int;
var _local14:Array;
var _local15:uint;
var _local16:uint;
var _local17:Array;
var _local18:Array;
var _local19:Array;
var _local20:int;
var _local21:int;
var _local22:b2Bound;
var _local23:b2Bound;
var _local24:int;
var _local25:b2Proxy;
var _local26:b2Pair;
if (m_freeProxy == b2Pair.b2_nullProxy){
return (b2Pair.b2_nullProxy);
};
Flush();
_local8 = m_freeProxy;
_local7 = m_proxyPool[_local8];
m_freeProxy = _local7.GetNext();
_local7.overlapCount = 0;
_local7.groupIndex = _arg2;
_local7.categoryBits = _arg3;
_local7.maskBits = _arg4;
_local7.userData = _arg5;
_local9 = (2 * m_proxyCount);
_local10 = new Array();
_local11 = new Array();
ComputeBounds(_local10, _local11, _arg1);
_local12 = 0;
while (_local12 < 2) {
_local14 = m_bounds[_local12];
_local17 = [_local15];
_local18 = [_local16];
Query(_local17, _local18, _local10[_local12], _local11[_local12], _local14, _local9, _local12);
_local15 = _local17[0];
_local16 = _local18[0];
_local19 = new Array();
_local21 = (_local9 - _local16);
_local20 = 0;
while (_local20 < _local21) {
_local19[_local20] = new b2Bound();
_local22 = _local19[_local20];
_local23 = _local14[(_local16 + _local20)];
_local22.value = _local23.value;
_local22.proxyId = _local23.proxyId;
_local22.stabbingCount = _local23.stabbingCount;
_local20++;
};
_local21 = _local19.length;
_local24 = (_local16 + 2);
_local20 = 0;
while (_local20 < _local21) {
_local23 = _local19[_local20];
_local22 = _local14[(_local24 + _local20)];
_local22.value = _local23.value;
_local22.proxyId = _local23.proxyId;
_local22.stabbingCount = _local23.stabbingCount;
_local20++;
};
_local19 = new Array();
_local21 = (_local16 - _local15);
_local20 = 0;
while (_local20 < _local21) {
_local19[_local20] = new b2Bound();
_local22 = _local19[_local20];
_local23 = _local14[(_local15 + _local20)];
_local22.value = _local23.value;
_local22.proxyId = _local23.proxyId;
_local22.stabbingCount = _local23.stabbingCount;
_local20++;
};
_local21 = _local19.length;
_local24 = (_local15 + 1);
_local20 = 0;
while (_local20 < _local21) {
_local23 = _local19[_local20];
_local22 = _local14[(_local24 + _local20)];
_local22.value = _local23.value;
_local22.proxyId = _local23.proxyId;
_local22.stabbingCount = _local23.stabbingCount;
_local20++;
};
_local16++;
_local14[_local15].value = _local10[_local12];
_local14[_local15].proxyId = _local8;
_local14[_local16].value = _local11[_local12];
_local14[_local16].proxyId = _local8;
_local14[_local15].stabbingCount = ((_local15 == 0)) ? 0 : _local14[(_local15 - 1)].stabbingCount;
_local14[_local16].stabbingCount = _local14[(_local16 - 1)].stabbingCount;
_local6 = _local15;
while (_local6 < _local16) {
_local14[_local6].stabbingCount++;
_local6++;
};
_local6 = _local15;
while (_local6 < (_local9 + 2)) {
_local25 = m_proxyPool[_local14[_local6].proxyId];
if (_local14[_local6].IsLower()){
_local25.lowerBounds[_local12] = _local6;
} else {
_local25.upperBounds[_local12] = _local6;
};
_local6++;
};
_local12++;
};
m_proxyCount++;
_local13 = 0;
while (_local13 < m_queryResultCount) {
if (ShouldCollide(_local8, m_queryResults[_local13]) == false){
} else {
_local26 = m_pairManager.Add(_local8, m_queryResults[_local13]);
if (_local26 == null){
} else {
_local26.userData = m_pairCallback.PairAdded(_local7.userData, m_proxyPool[m_queryResults[_local13]].userData);
_local26.SetReceived();
};
};
_local13++;
};
m_queryResultCount = 0;
IncrementTimeStamp();
return (_local8);
}
public function DestroyProxy(_arg1:uint){
var _local2:b2Proxy;
var _local3:uint;
var _local4:int;
var _local5:int;
var _local6:Array;
var _local7:uint;
var _local8:uint;
var _local9:uint;
var _local10:uint;
var _local11:Array;
var _local12:int;
var _local13:int;
var _local14:b2Bound;
var _local15:b2Bound;
var _local16:int;
var _local17:uint;
var _local18:int;
var _local19:b2Proxy;
var _local20:b2Proxy;
var _local21:*;
if (_arg1 == b2Pair.b2_nullProxy){
return;
};
Flush();
_local2 = m_proxyPool[_arg1];
_local3 = (2 * m_proxyCount);
_local4 = 0;
while (_local4 < 2) {
_local6 = m_bounds[_local4];
_local7 = _local2.lowerBounds[_local4];
_local8 = _local2.upperBounds[_local4];
_local9 = _local6[_local7].value;
_local10 = _local6[_local8].value;
_local11 = new Array();
_local13 = ((_local8 - _local7) - 1);
_local12 = 0;
while (_local12 < _local13) {
_local11[_local12] = new b2Bound();
_local14 = _local11[_local12];
_local15 = _local6[((_local7 + 1) + _local12)];
_local14.value = _local15.value;
_local14.proxyId = _local15.proxyId;
_local14.stabbingCount = _local15.stabbingCount;
_local12++;
};
_local13 = _local11.length;
_local16 = _local7;
_local12 = 0;
while (_local12 < _local13) {
_local15 = _local11[_local12];
_local14 = _local6[(_local16 + _local12)];
_local14.value = _local15.value;
_local14.proxyId = _local15.proxyId;
_local14.stabbingCount = _local15.stabbingCount;
_local12++;
};
_local11 = new Array();
_local13 = ((_local3 - _local8) - 1);
_local12 = 0;
while (_local12 < _local13) {
_local11[_local12] = new b2Bound();
_local14 = _local11[_local12];
_local15 = _local6[((_local8 + 1) + _local12)];
_local14.value = _local15.value;
_local14.proxyId = _local15.proxyId;
_local14.stabbingCount = _local15.stabbingCount;
_local12++;
};
_local13 = _local11.length;
_local16 = (_local8 - 1);
_local12 = 0;
while (_local12 < _local13) {
_local15 = _local11[_local12];
_local14 = _local6[(_local16 + _local12)];
_local14.value = _local15.value;
_local14.proxyId = _local15.proxyId;
_local14.stabbingCount = _local15.stabbingCount;
_local12++;
};
_local13 = (_local3 - 2);
_local17 = _local7;
while (_local17 < _local13) {
_local19 = m_proxyPool[_local6[_local17].proxyId];
if (_local6[_local17].IsLower()){
_local19.lowerBounds[_local4] = _local17;
} else {
_local19.upperBounds[_local4] = _local17;
};
_local17++;
};
_local13 = (_local8 - 1);
_local18 = _local7;
while (_local18 < _local13) {
_local6[_local18].stabbingCount--;
_local18++;
};
Query(new Array(), new Array(), _local9, _local10, _local6, (_local3 - 2), _local4);
_local4++;
};
_local5 = 0;
while (_local5 < m_queryResultCount) {
_local20 = m_proxyPool[m_queryResults[_local5]];
_local21 = m_pairManager.Remove(_arg1, m_queryResults[_local5]);
m_pairCallback.PairRemoved(_local2.userData, _local20.userData, _local21);
_local5++;
};
m_queryResultCount = 0;
IncrementTimeStamp();
_local2.userData = null;
_local2.overlapCount = b2_invalid;
_local2.SetNext(m_freeProxy);
m_freeProxy = _arg1;
m_proxyCount--;
}
private function TestOverlap(_arg1:b2Proxy, _arg2:b2Proxy):Boolean{
var _local3:int;
var _local4:Array;
_local3 = 0;
while (_local3 < 2) {
_local4 = m_bounds[_local3];
if (_local4[_arg1.lowerBounds[_local3]].value > _local4[_arg2.upperBounds[_local3]].value){
return (false);
};
if (_local4[_arg1.upperBounds[_local3]].value < _local4[_arg2.lowerBounds[_local3]].value){
return (false);
};
_local3++;
};
return (true);
}
public function Validate(){
var _local1:b2Pair;
var _local2:b2Proxy;
var _local3:b2Proxy;
var _local4:Boolean;
var _local5:int;
var _local6:Array;
var _local7:uint;
var _local8:int;
var _local9:int;
var _local10:b2Bound;
var _local11:uint;
var _local12:uint;
var _local13:uint;
var _local14:b2Bound;
var _local15:uint;
var _local16:b2Proxy;
var _local17:b2Bound;
_local5 = 0;
while (_local5 < 2) {
_local10 = m_bounds[_local5];
_local11 = (2 * m_proxyCount);
_local12 = 0;
_local13 = 0;
while (_local13 < _local11) {
_local14 = _local10[_local13];
if (_local13 > 0){
_local17 = _local10[(_local13 - 1)];
};
_local15 = _local14.proxyId;
_local16 = m_proxyPool[_local14.proxyId];
if (_local14.IsLower() == true){
_local12++;
} else {
_local12--;
};
_local13++;
};
_local5++;
};
_local6 = m_pairManager.GetPairs();
_local7 = m_pairManager.GetCount();
m_pairBuffer.sortOn(["proxyId1", "proxyId2"], Array.NUMERIC);
_local8 = 0;
while (_local8 < m_pairBufferCount) {
if (_local8 > 0){
};
_local1 = m_pairManager.Find(m_pairBuffer[_local8].proxyId1, m_pairBuffer[_local8].proxyId2);
_local2 = m_proxyPool[_local1.proxyId1];
_local3 = m_proxyPool[_local1.proxyId2];
_local4 = TestOverlap(_local2, _local3);
if (_local1.IsRemoved() == true){
};
_local8++;
};
_local9 = 0;
while (_local9 < _local7) {
_local1 = _local6[_local9];
_local2 = m_proxyPool[_local1.proxyId1];
_local3 = m_proxyPool[_local1.proxyId2];
_local4 = TestOverlap(_local2, _local3);
if (_local1.IsBuffered()){
if (_local1.IsRemoved() == true){
};
};
_local9++;
};
}
private function IncrementOverlapCount(_arg1:uint){
var _local2:b2Proxy;
_local2 = m_proxyPool[_arg1];
if (_local2.timeStamp < m_timeStamp){
_local2.timeStamp = m_timeStamp;
_local2.overlapCount = 1;
} else {
_local2.overlapCount = 2;
m_queryResults[m_queryResultCount] = _arg1;
m_queryResultCount++;
};
}
public function InRange(_arg1:b2AABB):Boolean{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local2 = _arg1.minVertex.x;
_local3 = _arg1.minVertex.y;
_local2 = (_local2 - m_worldAABB.maxVertex.x);
_local3 = (_local3 - m_worldAABB.maxVertex.y);
_local4 = m_worldAABB.minVertex.x;
_local5 = m_worldAABB.minVertex.y;
_local4 = (_local4 - _arg1.maxVertex.x);
_local5 = (_local5 - _arg1.maxVertex.y);
_local2 = b2Math.b2Max(_local2, _local4);
_local3 = b2Math.b2Max(_local3, _local5);
return ((b2Math.b2Max(_local2, _local3) < 0));
}
private function AddBufferedPair(_arg1:uint, _arg2:uint){
var _local3:b2Pair;
if (ShouldCollide(_arg1, _arg2) == false){
return;
};
_local3 = m_pairManager.Add(_arg1, _arg2);
if (_local3 == null){
return;
};
if (_local3.IsBuffered() == false){
if (m_pairBufferCount < b2Settings.b2_maxPairs){
_local3.SetBuffered();
m_pairBuffer[m_pairBufferCount].proxyId1 = _local3.proxyId1;
m_pairBuffer[m_pairBufferCount].proxyId2 = _local3.proxyId2;
m_pairBufferCount++;
};
};
_local3.ClearRemoved();
}
public function MoveProxy(_arg1:uint, _arg2:b2AABB){
var _local3:uint;
var _local4:b2Bound;
var _local5:b2Bound;
var _local6:b2Bound;
var _local7:uint;
var _local8:b2Proxy;
var _local9:uint;
var _local10:b2Proxy;
var _local11:Array;
var _local12:Array;
var _local13:uint;
var _local14:Array;
var _local15:uint;
var _local16:uint;
var _local17:uint;
var _local18:uint;
var _local19:int;
var _local20:int;
var _local21:uint;
var _local22:b2Proxy;
if ((((_arg1 == b2Pair.b2_nullProxy)) || ((b2Settings.b2_maxProxies <= _arg1)))){
return;
};
if (_arg2.IsValid() == false){
return;
};
_local9 = (2 * m_proxyCount);
_local10 = m_proxyPool[_arg1];
_local11 = new Array();
_local12 = new Array();
ComputeBounds(_local11, _local12, _arg2);
_local13 = 0;
while (_local13 < 2) {
_local14 = m_bounds[_local13];
_local15 = _local10.lowerBounds[_local13];
_local16 = _local10.upperBounds[_local13];
_local17 = _local11[_local13];
_local18 = _local12[_local13];
_local19 = (_local17 - _local14[_local15].value);
_local20 = (_local18 - _local14[_local16].value);
_local14[_local15].value = _local17;
_local14[_local16].value = _local18;
if (_local19 < 0){
_local3 = _local15;
while ((((_local3 > 0)) && ((_local17 < _local14[(_local3 - 1)].value)))) {
_local4 = _local14[_local3];
_local5 = _local14[(_local3 - 1)];
_local21 = _local5.proxyId;
_local22 = m_proxyPool[_local5.proxyId];
_local5.stabbingCount++;
if (_local5.IsUpper() == true){
if (TestOverlap(_local10, _local22)){
AddBufferedPair(_arg1, _local21);
};
var _local23 = _local22.upperBounds;
var _local24 = _local13;
var _local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
_local4.stabbingCount++;
} else {
_local23 = _local22.lowerBounds;
_local24 = _local13;
_local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
_local4.stabbingCount--;
};
_local23 = _local10.lowerBounds;
_local24 = _local13;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
_local4.Swap(_local5);
_local3--;
};
};
if (_local20 > 0){
_local3 = _local16;
while ((((_local3 < (_local9 - 1))) && ((_local14[(_local3 + 1)].value <= _local18)))) {
_local4 = _local14[_local3];
_local6 = _local14[(_local3 + 1)];
_local7 = _local6.proxyId;
_local8 = m_proxyPool[_local7];
_local6.stabbingCount++;
if (_local6.IsLower() == true){
if (TestOverlap(_local10, _local8)){
AddBufferedPair(_arg1, _local7);
};
_local23 = _local8.lowerBounds;
_local24 = _local13;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
_local4.stabbingCount++;
} else {
_local23 = _local8.upperBounds;
_local24 = _local13;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
_local4.stabbingCount--;
};
_local23 = _local10.upperBounds;
_local24 = _local13;
_local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
_local4.Swap(_local6);
_local3++;
};
};
if (_local19 > 0){
_local3 = _local15;
while ((((_local3 < (_local9 - 1))) && ((_local14[(_local3 + 1)].value <= _local17)))) {
_local4 = _local14[_local3];
_local6 = _local14[(_local3 + 1)];
_local7 = _local6.proxyId;
_local8 = m_proxyPool[_local7];
_local6.stabbingCount--;
if (_local6.IsUpper()){
RemoveBufferedPair(_arg1, _local7);
_local23 = _local8.upperBounds;
_local24 = _local13;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
_local4.stabbingCount--;
} else {
_local23 = _local8.lowerBounds;
_local24 = _local13;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
_local4.stabbingCount++;
};
_local23 = _local10.lowerBounds;
_local24 = _local13;
_local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
_local4.Swap(_local6);
_local3++;
};
};
if (_local20 < 0){
_local3 = _local16;
while ((((_local3 > 0)) && ((_local18 < _local14[(_local3 - 1)].value)))) {
_local4 = _local14[_local3];
_local5 = _local14[(_local3 - 1)];
_local21 = _local5.proxyId;
_local22 = m_proxyPool[_local21];
_local5.stabbingCount--;
if (_local5.IsLower() == true){
RemoveBufferedPair(_arg1, _local21);
_local23 = _local22.lowerBounds;
_local24 = _local13;
_local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
_local4.stabbingCount--;
} else {
_local23 = _local22.upperBounds;
_local24 = _local13;
_local25 = (_local23[_local24] + 1);
_local23[_local24] = _local25;
_local4.stabbingCount++;
};
_local23 = _local10.upperBounds;
_local24 = _local13;
_local25 = (_local23[_local24] - 1);
_local23[_local24] = _local25;
_local4.Swap(_local5);
_local3--;
};
};
_local13++;
};
}
public static function BinarySearch(_arg1:Array, _arg2:int, _arg3:uint):uint{
var _local4:int;
var _local5:int;
var _local6:int;
_local4 = 0;
_local5 = (_arg2 - 1);
while (_local4 <= _local5) {
_local6 = ((_local4 + _local5) / 2);
if (_arg1[_local6].value > _arg3){
_local5 = (_local6 - 1);
} else {
if (_arg1[_local6].value < _arg3){
_local4 = (_local6 + 1);
} else {
return (uint(_local6));
};
};
};
return (uint(_local4));
}
public static function Equals(_arg1:b2BufferedPair, _arg2:b2BufferedPair):Boolean{
if ((((_arg1.proxyId1 == _arg2.proxyId1)) && ((_arg1.proxyId2 == _arg2.proxyId2)))){
return (true);
};
return (false);
}
public static function LessThanBP(_arg1:b2BufferedPair, _arg2:b2BufferedPair):Boolean{
if (_arg1.proxyId1 < _arg2.proxyId1){
return (true);
};
if (_arg1.proxyId1 == _arg2.proxyId1){
return ((_arg1.proxyId2 < _arg2.proxyId2));
};
return (false);
}
}
}//package Engine.Collision
Section 12
//b2BufferedPair (Engine.Collision.b2BufferedPair)
package Engine.Collision {
public class b2BufferedPair {
public var proxyId1:uint;
public var proxyId2:uint;
}
}//package Engine.Collision
Section 13
//b2Collision (Engine.Collision.b2Collision)
package Engine.Collision {
import Engine.Common.Math.*;
import Engine.Collision.Shapes.*;
import Engine.Common.*;
public class b2Collision {
public static const b2_nullFeature:uint = 0xFF;
private static var b2CollidePolyTempVec:b2Vec2 = new b2Vec2();
public static function EdgeSeparation(_arg1:b2PolyShape, _arg2:int, _arg3:b2PolyShape):Number{
var _local4:int;
var _local5:Array;
var _local6:int;
var _local7:Array;
var _local8:int;
var _local9:int;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:b2Mat22;
var _local17:Number;
var _local18:Number;
var _local19:int;
var _local20:Number;
var _local21:int;
var _local22:b2Vec2;
var _local23:b2Vec2;
var _local24:Number;
var _local25:b2Vec2;
var _local26:Number;
_local4 = _arg1.m_vertexCount;
_local5 = _arg1.m_vertices;
_local6 = _arg3.m_vertexCount;
_local7 = _arg3.m_vertices;
_local8 = _arg2;
_local9 = (((_arg2 + 1) == _local4)) ? 0 : (_arg2 + 1);
_local10 = (_local5[_local9].x - _local5[_local8].x);
_local11 = (_local5[_local9].y - _local5[_local8].y);
_local12 = _local10;
_local10 = _local11;
_local11 = -(_local12);
_local13 = (1 / Math.sqrt(((_local10 * _local10) + (_local11 * _local11))));
_local10 = (_local10 * _local13);
_local11 = (_local11 * _local13);
_local14 = _local10;
_local15 = _local11;
_local12 = _local14;
_local16 = _arg1.m_R;
_local14 = ((_local16.col1.x * _local12) + (_local16.col2.x * _local15));
_local15 = ((_local16.col1.y * _local12) + (_local16.col2.y * _local15));
_local17 = _local14;
_local18 = _local15;
_local16 = _arg3.m_R;
_local12 = ((_local17 * _local16.col1.x) + (_local18 * _local16.col1.y));
_local18 = ((_local17 * _local16.col2.x) + (_local18 * _local16.col2.y));
_local17 = _local12;
_local19 = 0;
_local20 = Number.MAX_VALUE;
_local21 = 0;
while (_local21 < _local6) {
_local25 = _local7[_local21];
_local26 = ((_local25.x * _local17) + (_local25.y * _local18));
if (_local26 < _local20){
_local20 = _local26;
_local19 = _local21;
};
_local21++;
};
_local22 = new b2Vec2();
_local22.SetV(_local5[_local8]);
_local22.MulM(_arg1.m_R);
_local22.Add(_arg1.m_position);
_local23 = new b2Vec2();
_local23.SetV(_local7[_local19]);
_local23.MulM(_arg3.m_R);
_local23.Add(_arg3.m_position);
_local23.Subtract(_local22);
_local24 = ((_local23.x * _local14) + (_local23.y * _local15));
return (_local24);
}
public static function b2TestOverlap(_arg1:b2AABB, _arg2:b2AABB):Boolean{
var _local3:b2Vec2;
var _local4:b2Vec2;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local3 = _arg2.minVertex;
_local4 = _arg1.maxVertex;
_local5 = (_local3.x - _local4.x);
_local6 = (_local3.y - _local4.y);
_local3 = _arg1.minVertex;
_local4 = _arg2.maxVertex;
_local7 = (_local3.x - _local4.x);
_local8 = (_local3.y - _local4.y);
if ((((_local5 > 0)) || ((_local6 > 0)))){
return (false);
};
if ((((_local7 > 0)) || ((_local8 > 0)))){
return (false);
};
return (true);
}
public static function FindIncidentEdge(_arg1:Array, _arg2:b2PolyShape, _arg3:int, _arg4:b2PolyShape){
var _local5:int;
var _local6:Array;
var _local7:int;
var _local8:Array;
var _local9:int;
var _local10:int;
var _local11:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:b2Mat22;
var _local19:Number;
var _local20:Number;
var _local21:int;
var _local22:int;
var _local23:Number;
var _local24:int;
var _local25:ClipVertex;
var _local26:int;
var _local27:int;
var _local28:Number;
var _local29:Number;
var _local30:Number;
_local5 = _arg2.m_vertexCount;
_local6 = _arg2.m_vertices;
_local7 = _arg4.m_vertexCount;
_local8 = _arg4.m_vertices;
_local9 = _arg3;
_local10 = (((_arg3 + 1) == _local5)) ? 0 : (_arg3 + 1);
_local11 = _local6[_local10];
_local12 = _local11.x;
_local13 = _local11.y;
_local11 = _local6[_local9];
_local12 = (_local12 - _local11.x);
_local13 = (_local13 - _local11.y);
_local14 = _local12;
_local12 = _local13;
_local13 = -(_local14);
_local15 = (1 / Math.sqrt(((_local12 * _local12) + (_local13 * _local13))));
_local12 = (_local12 * _local15);
_local13 = (_local13 * _local15);
_local16 = _local12;
_local17 = _local13;
_local14 = _local16;
_local18 = _arg2.m_R;
_local16 = ((_local18.col1.x * _local14) + (_local18.col2.x * _local17));
_local17 = ((_local18.col1.y * _local14) + (_local18.col2.y * _local17));
_local19 = _local16;
_local20 = _local17;
_local18 = _arg4.m_R;
_local14 = ((_local19 * _local18.col1.x) + (_local20 * _local18.col1.y));
_local20 = ((_local19 * _local18.col2.x) + (_local20 * _local18.col2.y));
_local19 = _local14;
_local23 = Number.MAX_VALUE;
_local24 = 0;
while (_local24 < _local7) {
_local26 = _local24;
_local27 = (((_local24 + 1) < _local7)) ? (_local24 + 1) : 0;
_local11 = _local8[_local27];
_local28 = _local11.x;
_local29 = _local11.y;
_local11 = _local8[_local26];
_local28 = (_local28 - _local11.x);
_local29 = (_local29 - _local11.y);
_local14 = _local28;
_local28 = _local29;
_local29 = -(_local14);
_local15 = (1 / Math.sqrt(((_local28 * _local28) + (_local29 * _local29))));
_local28 = (_local28 * _local15);
_local29 = (_local29 * _local15);
_local30 = ((_local28 * _local19) + (_local29 * _local20));
if (_local30 < _local23){
_local23 = _local30;
_local21 = _local26;
_local22 = _local27;
};
_local24++;
};
_local25 = _arg1[0];
_local11 = _local25.v;
_local11.SetV(_local8[_local21]);
_local11.MulM(_arg4.m_R);
_local11.Add(_arg4.m_position);
_local25.id.features.referenceFace = _arg3;
_local25.id.features.incidentEdge = _local21;
_local25.id.features.incidentVertex = _local21;
_local25 = _arg1[1];
_local11 = _local25.v;
_local11.SetV(_local8[_local22]);
_local11.MulM(_arg4.m_R);
_local11.Add(_arg4.m_position);
_local25.id.features.referenceFace = _arg3;
_local25.id.features.incidentEdge = _local21;
_local25.id.features.incidentVertex = _local22;
}
public static function b2CollidePolyAndCircle(_arg1:b2Manifold, _arg2:b2PolyShape, _arg3:b2CircleShape){
var _local4:b2ContactPoint;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:b2Mat22;
var _local10:Number;
var _local11:Number;
var _local12:int;
var _local13:Number;
var _local14:Number;
var _local15:int;
var _local16:int;
var _local17:int;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:b2Vec2;
_arg1.pointCount = 0;
_local7 = (_arg3.m_position.x - _arg2.m_position.x);
_local8 = (_arg3.m_position.y - _arg2.m_position.y);
_local9 = _arg2.m_R;
_local10 = ((_local7 * _local9.col1.x) + (_local8 * _local9.col1.y));
_local8 = ((_local7 * _local9.col2.x) + (_local8 * _local9.col2.y));
_local7 = _local10;
_local12 = 0;
_local13 = -(Number.MAX_VALUE);
_local14 = _arg3.m_radius;
_local15 = 0;
while (_local15 < _arg2.m_vertexCount) {
_local24 = ((_arg2.m_normals[_local15].x * (_local7 - _arg2.m_vertices[_local15].x)) + (_arg2.m_normals[_local15].y * (_local8 - _arg2.m_vertices[_local15].y)));
if (_local24 > _local14){
return;
};
if (_local24 > _local13){
_local13 = _local24;
_local12 = _local15;
};
_local15++;
};
if (_local13 < Number.MIN_VALUE){
_arg1.pointCount = 1;
_local25 = _arg2.m_normals[_local12];
_arg1.normal.x = ((_local9.col1.x * _local25.x) + (_local9.col2.x * _local25.y));
_arg1.normal.y = ((_local9.col1.y * _local25.x) + (_local9.col2.y * _local25.y));
_local4 = _arg1.points[0];
_local4.id.features.incidentEdge = _local12;
_local4.id.features.incidentVertex = b2_nullFeature;
_local4.id.features.referenceFace = b2_nullFeature;
_local4.id.features.flip = 0;
_local4.position.x = (_arg3.m_position.x - (_local14 * _arg1.normal.x));
_local4.position.y = (_arg3.m_position.y - (_local14 * _arg1.normal.y));
_local4.separation = (_local13 - _local14);
return;
};
_local16 = _local12;
_local17 = _arg2.m_nextVert[_local16];
_local18 = (_arg2.m_vertices[_local17].x - _arg2.m_vertices[_local16].x);
_local19 = (_arg2.m_vertices[_local17].y - _arg2.m_vertices[_local16].y);
_local20 = Math.sqrt(((_local18 * _local18) + (_local19 * _local19)));
_local18 = (_local18 / _local20);
_local19 = (_local19 / _local20);
if (_local20 < Number.MIN_VALUE){
_local5 = (_local7 - _arg2.m_vertices[_local16].x);
_local6 = (_local8 - _arg2.m_vertices[_local16].y);
_local11 = Math.sqrt(((_local5 * _local5) + (_local6 * _local6)));
_local5 = (_local5 / _local11);
_local6 = (_local6 / _local11);
if (_local11 > _local14){
return;
};
_arg1.pointCount = 1;
_arg1.normal.Set(((_local9.col1.x * _local5) + (_local9.col2.x * _local6)), ((_local9.col1.y * _local5) + (_local9.col2.y * _local6)));
_local4 = _arg1.points[0];
_local4.id.features.incidentEdge = b2_nullFeature;
_local4.id.features.incidentVertex = _local16;
_local4.id.features.referenceFace = b2_nullFeature;
_local4.id.features.flip = 0;
_local4.position.x = (_arg3.m_position.x - (_local14 * _arg1.normal.x));
_local4.position.y = (_arg3.m_position.y - (_local14 * _arg1.normal.y));
_local4.separation = (_local11 - _local14);
return;
};
_local21 = (((_local7 - _arg2.m_vertices[_local16].x) * _local18) + ((_local8 - _arg2.m_vertices[_local16].y) * _local19));
_local4 = _arg1.points[0];
_local4.id.features.incidentEdge = b2_nullFeature;
_local4.id.features.incidentVertex = b2_nullFeature;
_local4.id.features.referenceFace = b2_nullFeature;
_local4.id.features.flip = 0;
if (_local21 <= 0){
_local22 = _arg2.m_vertices[_local16].x;
_local23 = _arg2.m_vertices[_local16].y;
_local4.id.features.incidentVertex = _local16;
} else {
if (_local21 >= _local20){
_local22 = _arg2.m_vertices[_local17].x;
_local23 = _arg2.m_vertices[_local17].y;
_local4.id.features.incidentVertex = _local17;
} else {
_local22 = ((_local18 * _local21) + _arg2.m_vertices[_local16].x);
_local23 = ((_local19 * _local21) + _arg2.m_vertices[_local16].y);
_local4.id.features.incidentEdge = _local16;
};
};
_local5 = (_local7 - _local22);
_local6 = (_local8 - _local23);
_local11 = Math.sqrt(((_local5 * _local5) + (_local6 * _local6)));
_local5 = (_local5 / _local11);
_local6 = (_local6 / _local11);
if (_local11 > _local14){
return;
};
_arg1.pointCount = 1;
_arg1.normal.Set(((_local9.col1.x * _local5) + (_local9.col2.x * _local6)), ((_local9.col1.y * _local5) + (_local9.col2.y * _local6)));
_local4.position.x = (_arg3.m_position.x - (_local14 * _arg1.normal.x));
_local4.position.y = (_arg3.m_position.y - (_local14 * _arg1.normal.y));
_local4.separation = (_local11 - _local14);
}
public static function FindMaxSeparation(_arg1:Array, _arg2:b2PolyShape, _arg3:b2PolyShape):Number{
var _local4:int;
var _local5:Array;
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local8:int;
var _local9:Number;
var _local10:int;
var _local11:int;
var _local12:Number;
var _local13:int;
var _local14:Number;
var _local15:int;
var _local16:Number;
var _local17:int;
var _local18:Number;
var _local19:int;
var _local20:Number;
_local4 = _arg2.m_vertexCount;
_local5 = _arg2.m_vertices;
_local6 = new b2Vec2();
_local6.SetV(_arg3.m_position);
_local6.Subtract(_arg2.m_position);
_local7 = new b2Vec2();
_local7.SetV(_local6);
_local7.MulTM(_arg2.m_R);
_local8 = 0;
_local9 = -(Number.MAX_VALUE);
_local10 = 0;
while (_local10 < _local4) {
_local18 = b2Math.b2Dot(_local5[_local10], _local7);
if (_local18 > _local9){
_local9 = _local18;
_local8 = _local10;
};
_local10++;
};
_local11 = (((_local8 - 1) >= 0)) ? (_local8 - 1) : (_local4 - 1);
_local12 = EdgeSeparation(_arg2, _local11, _arg3);
if (_local12 > 0){
return (_local12);
};
_local13 = _local8;
_local14 = EdgeSeparation(_arg2, _local13, _arg3);
if (_local14 > 0){
return (_local14);
};
if (_local12 > _local14){
_local17 = -1;
_local15 = _local11;
_local16 = _local12;
} else {
_local17 = 1;
_local15 = _local13;
_local16 = _local14;
};
while (true) {
if (_local17 == -1){
_local19 = (((_local15 - 1) >= 0)) ? (_local15 - 1) : (_local4 - 1);
} else {
_local19 = (((_local15 + 1) < _local4)) ? (_local15 + 1) : 0;
};
_local20 = EdgeSeparation(_arg2, _local19, _arg3);
if (_local20 > 0){
return (_local20);
};
if (_local20 > _local16){
_local15 = _local19;
_local16 = _local20;
} else {
break;
};
};
_arg1[0] = _local15;
return (_local16);
}
public static function ClipSegmentToLine(_arg1:Array, _arg2:Array, _arg3:b2Vec2, _arg4:Number):int{
var _local5:int;
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:b2Vec2;
_local5 = 0;
_local6 = _arg2[0].v;
_local7 = _arg2[1].v;
_local8 = (b2Math.b2Dot(_arg3, _arg2[0].v) - _arg4);
_local9 = (b2Math.b2Dot(_arg3, _arg2[1].v) - _arg4);
if (_local8 <= 0){
var _temp1 = _local5;
_local5 = (_local5 + 1);
var _local12 = _temp1;
_arg1[_local12] = _arg2[0];
};
if (_local9 <= 0){
var _temp2 = _local5;
_local5 = (_local5 + 1);
_local12 = _temp2;
_arg1[_local12] = _arg2[1];
};
if ((_local8 * _local9) < 0){
_local10 = (_local8 / (_local8 - _local9));
_local11 = _arg1[_local5].v;
_local11.x = (_local6.x + (_local10 * (_local7.x - _local6.x)));
_local11.y = (_local6.y + (_local10 * (_local7.y - _local6.y)));
if (_local8 > 0){
_arg1[_local5].id = _arg2[0].id;
} else {
_arg1[_local5].id = _arg2[1].id;
};
_local5++;
};
return (_local5);
}
public static function b2CollidePoly(_arg1:b2Manifold, _arg2:b2PolyShape, _arg3:b2PolyShape){
var _local4:int;
var _local5:Array;
var _local6:Number;
var _local7:int;
var _local8:Array;
var _local9:Number;
var _local10:b2PolyShape;
var _local11:b2PolyShape;
var _local12:int;
var _local13:int;
var _local14:Number;
var _local15:Number;
var _local16:Array;
var _local17:int;
var _local18:Array;
var _local19:b2Vec2;
var _local20:b2Vec2;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:b2Mat22;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Array;
var _local38:Array;
var _local39:int;
var _local40:int;
var _local41:int;
var _local42:b2Vec2;
var _local43:Number;
var _local44:b2ContactPoint;
_arg1.pointCount = 0;
_local4 = 0;
_local5 = [_local4];
_local6 = FindMaxSeparation(_local5, _arg2, _arg3);
_local4 = _local5[0];
if (_local6 > 0){
return;
};
_local7 = 0;
_local8 = [_local7];
_local9 = FindMaxSeparation(_local8, _arg3, _arg2);
_local7 = _local8[0];
if (_local9 > 0){
return;
};
_local14 = 0.98;
_local15 = 0.001;
if (_local9 > ((_local14 * _local6) + _local15)){
_local10 = _arg3;
_local11 = _arg2;
_local12 = _local7;
_local13 = 1;
} else {
_local10 = _arg2;
_local11 = _arg3;
_local12 = _local4;
_local13 = 0;
};
_local16 = [new ClipVertex(), new ClipVertex()];
FindIncidentEdge(_local16, _local10, _local12, _local11);
_local17 = _local10.m_vertexCount;
_local18 = _local10.m_vertices;
_local19 = _local18[_local12];
_local20 = (((_local12 + 1) < _local17)) ? _local18[(_local12 + 1)] : _local18[0];
_local21 = (_local20.x - _local19.x);
_local22 = (_local20.y - _local19.y);
_local23 = (_local20.x - _local19.x);
_local24 = (_local20.y - _local19.y);
_local25 = _local23;
_local26 = _local10.m_R;
_local23 = ((_local26.col1.x * _local25) + (_local26.col2.x * _local24));
_local24 = ((_local26.col1.y * _local25) + (_local26.col2.y * _local24));
_local27 = (1 / Math.sqrt(((_local23 * _local23) + (_local24 * _local24))));
_local23 = (_local23 * _local27);
_local24 = (_local24 * _local27);
_local28 = _local23;
_local29 = _local24;
_local25 = _local28;
_local28 = _local29;
_local29 = -(_local25);
_local30 = _local19.x;
_local31 = _local19.y;
_local25 = _local30;
_local26 = _local10.m_R;
_local30 = ((_local26.col1.x * _local25) + (_local26.col2.x * _local31));
_local31 = ((_local26.col1.y * _local25) + (_local26.col2.y * _local31));
_local30 = (_local30 + _local10.m_position.x);
_local31 = (_local31 + _local10.m_position.y);
_local32 = _local20.x;
_local33 = _local20.y;
_local25 = _local32;
_local26 = _local10.m_R;
_local32 = ((_local26.col1.x * _local25) + (_local26.col2.x * _local33));
_local33 = ((_local26.col1.y * _local25) + (_local26.col2.y * _local33));
_local32 = (_local32 + _local10.m_position.x);
_local33 = (_local33 + _local10.m_position.y);
_local34 = ((_local28 * _local30) + (_local29 * _local31));
_local35 = -(((_local23 * _local30) + (_local24 * _local31)));
_local36 = ((_local23 * _local32) + (_local24 * _local33));
_local37 = [new ClipVertex(), new ClipVertex()];
_local38 = [new ClipVertex(), new ClipVertex()];
b2CollidePolyTempVec.Set(-(_local23), -(_local24));
_local39 = ClipSegmentToLine(_local37, _local16, b2CollidePolyTempVec, _local35);
if (_local39 < 2){
return;
};
b2CollidePolyTempVec.Set(_local23, _local24);
_local39 = ClipSegmentToLine(_local38, _local37, b2CollidePolyTempVec, _local36);
if (_local39 < 2){
return;
};
if (_local13){
_arg1.normal.Set(-(_local28), -(_local29));
} else {
_arg1.normal.Set(_local28, _local29);
};
_local40 = 0;
_local41 = 0;
while (_local41 < b2Settings.b2_maxManifoldPoints) {
_local42 = _local38[_local41].v;
_local43 = (((_local28 * _local42.x) + (_local29 * _local42.y)) - _local34);
if (_local43 <= 0){
_local44 = _arg1.points[_local40];
_local44.separation = _local43;
_local44.position.SetV(_local38[_local41].v);
_local44.id.Set(_local38[_local41].id);
_local44.id.features.flip = _local13;
_local40++;
};
_local41++;
};
_arg1.pointCount = _local40;
}
public static function b2CollideCircle(_arg1:b2Manifold, _arg2:b2CircleShape, _arg3:b2CircleShape){
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:b2ContactPoint;
var _local10:Number;
var _local11:Number;
_arg1.pointCount = 0;
_local4 = (_arg3.m_position.x - _arg2.m_position.x);
_local5 = (_arg3.m_position.y - _arg2.m_position.y);
_local6 = ((_local4 * _local4) + (_local5 * _local5));
_local7 = (_arg2.m_radius + _arg3.m_radius);
if (_local6 > (_local7 * _local7)){
return;
};
if (_local6 < Number.MIN_VALUE){
_local8 = -(_local7);
_arg1.normal.Set(0, 1);
} else {
_local10 = Math.sqrt(_local6);
_local8 = (_local10 - _local7);
_local11 = (1 / _local10);
_arg1.normal.x = (_local11 * _local4);
_arg1.normal.y = (_local11 * _local5);
};
_arg1.pointCount = 1;
_local9 = _arg1.points[0];
_local9.id.key = 0;
_local9.separation = _local8;
_local9.position.x = (_arg3.m_position.x - (_arg3.m_radius * _arg1.normal.x));
_local9.position.y = (_arg3.m_position.y - (_arg3.m_radius * _arg1.normal.y));
}
}
}//package Engine.Collision
Section 14
//b2ContactID (Engine.Collision.b2ContactID)
package Engine.Collision {
public class b2ContactID {
public var _key:uint;
public var features:Features;
public function b2ContactID(){
features = new Features();
super();
features._m_id = this;
}
public function Set(_arg1:b2ContactID){
key = _arg1._key;
}
public function Copy():b2ContactID{
var _local1:b2ContactID;
_local1 = new b2ContactID();
_local1.key = key;
return (_local1);
}
public function get key():uint{
return (_key);
}
public function set key(_arg1:uint){
_key = _arg1;
features._referenceFace = (_key & 0xFF);
features._incidentEdge = (((_key & 0xFF00) >> 8) & 0xFF);
features._incidentVertex = (((_key & 0xFF0000) >> 16) & 0xFF);
features._flip = (((_key & 4278190080) >> 24) & 0xFF);
}
}
}//package Engine.Collision
Section 15
//b2ContactPoint (Engine.Collision.b2ContactPoint)
package Engine.Collision {
import Engine.Common.Math.*;
public class b2ContactPoint {
public var separation:Number;
public var position:b2Vec2;
public var normalImpulse:Number;
public var tangentImpulse:Number;
public var id:b2ContactID;
public function b2ContactPoint(){
position = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Engine.Collision
Section 16
//b2Manifold (Engine.Collision.b2Manifold)
package Engine.Collision {
import Engine.Common.Math.*;
import Engine.Common.*;
public class b2Manifold {
public var points:Array;
public var pointCount:int;
public var normal:b2Vec2;
public function b2Manifold(){
var _local1:int;
super();
points = new Array(b2Settings.b2_maxManifoldPoints);
_local1 = 0;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
points[_local1] = new b2ContactPoint();
_local1++;
};
normal = new b2Vec2();
}
}
}//package Engine.Collision
Section 17
//b2OBB (Engine.Collision.b2OBB)
package Engine.Collision {
import Engine.Common.Math.*;
public class b2OBB {
public var R:b2Mat22;
public var center:b2Vec2;
public var extents:b2Vec2;
public function b2OBB(){
R = new b2Mat22();
center = new b2Vec2();
extents = new b2Vec2();
super();
}
}
}//package Engine.Collision
Section 18
//b2Pair (Engine.Collision.b2Pair)
package Engine.Collision {
import Engine.Common.*;
public class b2Pair {
public var userData;// = null
public var proxyId1:uint;
public var proxyId2:uint;
public var status:uint;
public static var b2_tableMask:int = (b2_tableCapacity - 1);
public static var e_pairRemoved:uint = 2;
public static var b2_nullPair:uint = b2Settings.USHRT_MAX;
public static var e_pairBuffered:uint = 1;
public static var e_pairReceived:uint = 4;
public static var b2_nullProxy:uint = b2Settings.USHRT_MAX;
public static var b2_tableCapacity:int = b2Settings.b2_maxPairs;
public function b2Pair(){
userData = null;
super();
}
public function SetBuffered(){
status = (status | e_pairBuffered);
}
public function SetReceived(){
status = (status | e_pairReceived);
}
public function IsBuffered():Boolean{
return (((status & e_pairBuffered) == e_pairBuffered));
}
public function IsReceived():Boolean{
return (((status & e_pairReceived) == e_pairReceived));
}
public function ClearBuffered(){
status = (status & ~(e_pairBuffered));
}
public function ClearRemoved(){
status = (status & ~(e_pairRemoved));
}
public function IsRemoved():Boolean{
return (((status & e_pairRemoved) == e_pairRemoved));
}
public function SetRemoved(){
status = (status | e_pairRemoved);
}
}
}//package Engine.Collision
Section 19
//b2PairCallback (Engine.Collision.b2PairCallback)
package Engine.Collision {
public class b2PairCallback {
public function PairRemoved(_arg1, _arg2, _arg3){
}
public function PairAdded(_arg1, _arg2){
return (null);
}
}
}//package Engine.Collision
Section 20
//b2PairManager (Engine.Collision.b2PairManager)
package Engine.Collision {
import Engine.Common.Math.*;
import Engine.Common.*;
public class b2PairManager {
public var m_next:Array;
public var m_pairs:Array;
public var m_pairCount:int;
public var m_hashTable:Array;
public function b2PairManager(){
var _local1:uint;
super();
m_hashTable = new Array(b2Pair.b2_tableCapacity);
_local1 = 0;
while (_local1 < b2Pair.b2_tableCapacity) {
m_hashTable[_local1] = b2Pair.b2_nullPair;
_local1++;
};
m_next = new Array(b2Settings.b2_maxPairs);
_local1 = 0;
while (_local1 < b2Settings.b2_maxPairs) {
m_next[_local1] = b2Pair.b2_nullPair;
_local1++;
};
m_pairs = new Array(b2Settings.b2_maxPairs);
_local1 = 0;
while (_local1 < b2Settings.b2_maxPairs) {
m_pairs[_local1] = new b2Pair();
_local1++;
};
m_pairCount = 0;
}
public function Find(_arg1:uint, _arg2:uint):b2Pair{
var _local3:uint;
var _local4:uint;
var _local5:uint;
if (_arg1 > _arg2){
_local5 = _arg1;
_arg1 = _arg2;
_arg2 = _local5;
};
_local3 = (Hash(_arg1, _arg2) & b2Pair.b2_tableMask);
_local4 = m_hashTable[_local3];
while (((!((_local4 == b2Pair.b2_nullPair))) && ((Equals(m_pairs[_local4], _arg1, _arg2) == false)))) {
_local4 = m_next[_local4];
};
if (_local4 == b2Pair.b2_nullPair){
return (null);
};
return (m_pairs[_local4]);
}
public function Add(_arg1:uint, _arg2:uint):b2Pair{
var _local3:uint;
var _local4:int;
var _local5:b2Pair;
var _local6:uint;
if (_arg1 > _arg2){
_local6 = _arg1;
_arg1 = _arg2;
_arg2 = _local6;
};
_local3 = (Hash(_arg1, _arg2) & b2Pair.b2_tableMask);
_local4 = FindHash(_arg1, _arg2, _local3);
_local5 = ((_local4)!=b2Settings.USHRT_MAX) ? m_pairs[_local4] : null;
if (_local5 != null){
return (_local5);
};
if (m_pairCount == b2Settings.b2_maxPairs){
return (null);
};
_local5 = m_pairs[m_pairCount];
_local5.proxyId1 = _arg1;
_local5.proxyId2 = _arg2;
_local5.status = 0;
_local5.userData = null;
m_next[m_pairCount] = m_hashTable[_local3];
m_hashTable[_local3] = m_pairCount;
m_pairCount++;
return (_local5);
}
public function GetPairs():Array{
return (m_pairs);
}
public function Remove(_arg1:uint, _arg2:uint){
var _local3:uint;
var _local4:int;
var _local5:b2Pair;
var _local6:*;
var _local7:uint;
var _local8:uint;
var _local9:uint;
var _local10:b2Pair;
var _local11:uint;
var _local12:uint;
if (_arg1 > _arg2){
_local12 = _arg1;
_arg1 = _arg2;
_arg2 = _local12;
};
_local3 = (Hash(_arg1, _arg2) & b2Pair.b2_tableMask);
_local4 = FindHash(_arg1, _arg2, _local3);
_local5 = ((_local4)!=b2Settings.USHRT_MAX) ? m_pairs[_local4] : null;
if (_local5 == null){
return (null);
};
_local6 = _local5.userData;
_local7 = m_hashTable[_local3];
_local8 = b2Pair.b2_nullPair;
while (_local7 != _local4) {
_local8 = _local7;
_local7 = m_next[_local7];
};
if (_local8 != b2Pair.b2_nullPair){
m_next[_local8] = m_next[_local4];
} else {
m_hashTable[_local3] = m_next[_local4];
};
_local9 = (m_pairCount - 1);
if (_local9 == _local4){
m_pairCount--;
return (_local6);
};
_local10 = m_pairs[_local9];
_local11 = (Hash(_local10.proxyId1, _local10.proxyId2) & b2Pair.b2_tableMask);
_local7 = m_hashTable[_local11];
_local8 = b2Pair.b2_nullPair;
while (_local7 != _local9) {
_local8 = _local7;
_local7 = m_next[_local7];
};
if (_local8 != b2Pair.b2_nullPair){
m_next[_local8] = m_next[_local9];
} else {
m_hashTable[_local11] = m_next[_local9];
};
m_pairs[_local4].userData = m_pairs[_local9].userData;
m_pairs[_local4].proxyId1 = m_pairs[_local9].proxyId1;
m_pairs[_local4].proxyId2 = m_pairs[_local9].proxyId2;
m_pairs[_local4].status = m_pairs[_local9].status;
m_next[_local4] = m_hashTable[_local11];
m_hashTable[_local11] = _local4;
m_pairCount--;
return (_local6);
}
public function GetCount():int{
return (m_pairCount);
}
private function FindHash(_arg1:uint, _arg2:uint, _arg3:uint):int{
var _local4:uint;
_local4 = m_hashTable[_arg3];
while (((!((_local4 == b2Pair.b2_nullPair))) && ((Equals(m_pairs[_local4], _arg1, _arg2) == false)))) {
_local4 = m_next[_local4];
};
if (_local4 == b2Pair.b2_nullPair){
return (b2Settings.USHRT_MAX);
};
return (_local4);
}
public static function Hash(_arg1:uint, _arg2:uint):uint{
var _local3:uint;
_local3 = (((_arg2 << 16) & 4294901760) | _arg1);
_local3 = (~(_local3) + ((_local3 << 15) & 4294934528));
_local3 = (_local3 ^ ((_local3 >> 12) & 1048575));
_local3 = (_local3 + ((_local3 << 2) & 4294967292));
_local3 = (_local3 ^ ((_local3 >> 4) & 268435455));
_local3 = (_local3 * 2057);
_local3 = (_local3 ^ ((_local3 >> 16) & 0xFFFF));
return (_local3);
}
public static function Equals(_arg1:b2Pair, _arg2:uint, _arg3:uint):Boolean{
return ((((_arg1.proxyId1 == _arg2)) && ((_arg1.proxyId2 == _arg3))));
}
}
}//package Engine.Collision
Section 21
//b2Proxy (Engine.Collision.b2Proxy)
package Engine.Collision {
public class b2Proxy {
public var categoryBits:uint;
public var overlapCount:uint;
public var lowerBounds:Array;
public var upperBounds:Array;
public var maskBits:uint;
public var groupIndex:int;
public var userData;// = null
public var timeStamp:uint;
public function b2Proxy(){
lowerBounds = [uint(0), uint(0)];
upperBounds = [uint(0), uint(0)];
userData = null;
super();
}
public function GetNext():uint{
return (lowerBounds[0]);
}
public function IsValid():Boolean{
return (!((overlapCount == b2BroadPhase.b2_invalid)));
}
public function SetNext(_arg1:uint){
lowerBounds[0] = (_arg1 & 0xFFFF);
}
}
}//package Engine.Collision
Section 22
//ClipVertex (Engine.Collision.ClipVertex)
package Engine.Collision {
import Engine.Common.Math.*;
public class ClipVertex {
public var v:b2Vec2;
public var id:b2ContactID;
public function ClipVertex(){
v = new b2Vec2();
id = new b2ContactID();
super();
}
}
}//package Engine.Collision
Section 23
//Features (Engine.Collision.Features)
package Engine.Collision {
public class Features {
public var _referenceFace:int;
public var _incidentEdge:int;
public var _flip:int;
public var _incidentVertex:int;
public var _m_id:b2ContactID;
public function get referenceFace():int{
return (_referenceFace);
}
public function set incidentVertex(_arg1:int){
_incidentVertex = _arg1;
_m_id._key = ((_m_id._key & 4278255615) | ((_incidentVertex << 16) & 0xFF0000));
}
public function get flip():int{
return (_flip);
}
public function get incidentEdge():int{
return (_incidentEdge);
}
public function set referenceFace(_arg1:int){
_referenceFace = _arg1;
_m_id._key = ((_m_id._key & 4294967040) | (_referenceFace & 0xFF));
}
public function set flip(_arg1:int){
_flip = _arg1;
_m_id._key = ((_m_id._key & 0xFFFFFF) | ((_flip << 24) & 4278190080));
}
public function get incidentVertex():int{
return (_incidentVertex);
}
public function set incidentEdge(_arg1:int){
_incidentEdge = _arg1;
_m_id._key = ((_m_id._key & 4294902015) | ((_incidentEdge << 8) & 0xFF00));
}
}
}//package Engine.Collision
Section 24
//b2Mat22 (Engine.Common.Math.b2Mat22)
package Engine.Common.Math {
public class b2Mat22 {
public var col1:b2Vec2;
public var col2:b2Vec2;
public function b2Mat22(_arg1:Number=0, _arg2:b2Vec2=null, _arg3:b2Vec2=null){
var _local4:Number;
var _local5:Number;
col1 = new b2Vec2();
col2 = new b2Vec2();
super();
if (((!((_arg2 == null))) && (!((_arg3 == null))))){
col1.SetV(_arg2);
col2.SetV(_arg3);
} else {
_local4 = Math.cos(_arg1);
_local5 = Math.sin(_arg1);
col1.x = _local4;
col2.x = -(_local5);
col1.y = _local5;
col2.y = _local4;
};
}
public function SetIdentity(){
col1.x = 1;
col2.x = 0;
col1.y = 0;
col2.y = 1;
}
public function Set(_arg1:Number){
var _local2:Number;
var _local3:Number;
_local2 = Math.cos(_arg1);
_local3 = Math.sin(_arg1);
col1.x = _local2;
col2.x = -(_local3);
col1.y = _local3;
col2.y = _local2;
}
public function SetVV(_arg1:b2Vec2, _arg2:b2Vec2){
col1.SetV(_arg1);
col2.SetV(_arg2);
}
public function SetZero(){
col1.x = 0;
col2.x = 0;
col1.y = 0;
col2.y = 0;
}
public function SetM(_arg1:b2Mat22){
col1.SetV(_arg1.col1);
col2.SetV(_arg1.col2);
}
public function AddM(_arg1:b2Mat22){
col1.x = (col1.x + _arg1.col1.x);
col1.y = (col1.y + _arg1.col1.y);
col2.x = (col2.x + _arg1.col2.x);
col2.y = (col2.y + _arg1.col2.y);
}
public function Abs(){
col1.Abs();
col2.Abs();
}
public function Copy():b2Mat22{
return (new b2Mat22(0, col1, col2));
}
public function Invert(_arg1:b2Mat22):b2Mat22{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
_local2 = col1.x;
_local3 = col2.x;
_local4 = col1.y;
_local5 = col2.y;
_local6 = ((_local2 * _local5) - (_local3 * _local4));
_local6 = (1 / _local6);
_arg1.col1.x = (_local6 * _local5);
_arg1.col2.x = (-(_local6) * _local3);
_arg1.col1.y = (-(_local6) * _local4);
_arg1.col2.y = (_local6 * _local2);
return (_arg1);
}
public function Solve(_arg1:b2Vec2, _arg2:Number, _arg3:Number):b2Vec2{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local4 = col1.x;
_local5 = col2.x;
_local6 = col1.y;
_local7 = col2.y;
_local8 = ((_local4 * _local7) - (_local5 * _local6));
_local8 = (1 / _local8);
_arg1.x = (_local8 * ((_local7 * _arg2) - (_local5 * _arg3)));
_arg1.y = (_local8 * ((_local4 * _arg3) - (_local6 * _arg2)));
return (_arg1);
}
}
}//package Engine.Common.Math
Section 25
//b2Math (Engine.Common.Math.b2Math)
package Engine.Common.Math {
public class b2Math {
public static function b2CrossVF(_arg1:b2Vec2, _arg2:Number):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2((_arg2 * _arg1.y), (-(_arg2) * _arg1.x));
return (_local3);
}
public static function AddVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2((_arg1.x + _arg2.x), (_arg1.y + _arg2.y));
return (_local3);
}
public static function b2IsValid(_arg1:Number){
return (isFinite(_arg1));
}
public static function b2Swap(_arg1:Array, _arg2:Array){
var _local3:*;
_local3 = _arg1[0];
_arg1[0] = _arg2[0];
_arg2[0] = _local3;
}
public static function b2Abs(_arg1:Number):Number{
return (((_arg1 > 0)) ? _arg1 : -(_arg1));
}
public static function b2AbsM(_arg1:b2Mat22):b2Mat22{
var _local2:b2Mat22;
_local2 = new b2Mat22(0, b2AbsV(_arg1.col1), b2AbsV(_arg1.col2));
return (_local2);
}
public static function SubtractVV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2((_arg1.x - _arg2.x), (_arg1.y - _arg2.y));
return (_local3);
}
public static function b2CrossVV(_arg1:b2Vec2, _arg2:b2Vec2):Number{
return (((_arg1.x * _arg2.y) - (_arg1.y * _arg2.x)));
}
public static function b2Clamp(_arg1:Number, _arg2:Number, _arg3:Number):Number{
return (b2Max(_arg2, b2Min(_arg1, _arg3)));
}
public static function b2AbsV(_arg1:b2Vec2):b2Vec2{
var _local2:b2Vec2;
_local2 = new b2Vec2(b2Abs(_arg1.x), b2Abs(_arg1.y));
return (_local2);
}
public static function b2MinV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2(b2Min(_arg1.x, _arg2.x), b2Min(_arg1.y, _arg2.y));
return (_local3);
}
public static function b2Dot(_arg1:b2Vec2, _arg2:b2Vec2):Number{
return (((_arg1.x * _arg2.x) + (_arg1.y * _arg2.y)));
}
public static function b2CrossFV(_arg1:Number, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2((-(_arg1) * _arg2.y), (_arg1 * _arg2.x));
return (_local3);
}
public static function AddMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Mat22;
_local3 = new b2Mat22(0, AddVV(_arg1.col1, _arg2.col1), AddVV(_arg1.col2, _arg2.col2));
return (_local3);
}
public static function b2MulTMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Vec2;
var _local4:b2Vec2;
var _local5:b2Mat22;
_local3 = new b2Vec2(b2Dot(_arg1.col1, _arg2.col1), b2Dot(_arg1.col2, _arg2.col1));
_local4 = new b2Vec2(b2Dot(_arg1.col1, _arg2.col2), b2Dot(_arg1.col2, _arg2.col2));
_local5 = new b2Mat22(0, _local3, _local4);
return (_local5);
}
public static function b2MaxV(_arg1:b2Vec2, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2(b2Max(_arg1.x, _arg2.x), b2Max(_arg1.y, _arg2.y));
return (_local3);
}
public static function b2IsPowerOfTwo(_arg1:uint):Boolean{
var _local2:Boolean;
_local2 = (((_arg1 > 0)) && (((_arg1 & (_arg1 - 1)) == 0)));
return (_local2);
}
public static function b2ClampV(_arg1:b2Vec2, _arg2:b2Vec2, _arg3:b2Vec2):b2Vec2{
return (b2MaxV(_arg2, b2MinV(_arg1, _arg3)));
}
public static function MulFV(_arg1:Number, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2((_arg1 * _arg2.x), (_arg1 * _arg2.y));
return (_local3);
}
public static function b2MulTMV(_arg1:b2Mat22, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2(b2Dot(_arg2, _arg1.col1), b2Dot(_arg2, _arg1.col2));
return (_local3);
}
public static function b2Min(_arg1:Number, _arg2:Number):Number{
return (((_arg1 < _arg2)) ? _arg1 : _arg2);
}
public static function b2Random():Number{
return (((Math.random() * 2) - 1));
}
public static function b2MulMM(_arg1:b2Mat22, _arg2:b2Mat22):b2Mat22{
var _local3:b2Mat22;
_local3 = new b2Mat22(0, b2MulMV(_arg1, _arg2.col1), b2MulMV(_arg1, _arg2.col2));
return (_local3);
}
public static function b2NextPowerOfTwo(_arg1:uint):uint{
_arg1 = (_arg1 | ((_arg1 >> 1) & 2147483647));
_arg1 = (_arg1 | ((_arg1 >> 2) & 1073741823));
_arg1 = (_arg1 | ((_arg1 >> 4) & 268435455));
_arg1 = (_arg1 | ((_arg1 >> 8) & 0xFFFFFF));
_arg1 = (_arg1 | ((_arg1 >> 16) & 0xFFFF));
return ((_arg1 + 1));
}
public static function b2Max(_arg1:Number, _arg2:Number):Number{
return (((_arg1 > _arg2)) ? _arg1 : _arg2);
}
public static function b2MulMV(_arg1:b2Mat22, _arg2:b2Vec2):b2Vec2{
var _local3:b2Vec2;
_local3 = new b2Vec2(((_arg1.col1.x * _arg2.x) + (_arg1.col2.x * _arg2.y)), ((_arg1.col1.y * _arg2.x) + (_arg1.col2.y * _arg2.y)));
return (_local3);
}
}
}//package Engine.Common.Math
Section 26
//b2Vec2 (Engine.Common.Math.b2Vec2)
package Engine.Common.Math {
public class b2Vec2 {
public var x:Number;
public var y:Number;
public function b2Vec2(_arg1:Number=0, _arg2:Number=0){
x = _arg1;
y = _arg2;
}
public function Set(_arg1:Number=0, _arg2:Number=0){
x = _arg1;
y = _arg2;
}
public function Multiply(_arg1:Number){
x = (x * _arg1);
y = (y * _arg1);
}
public function Length():Number{
return (Math.sqrt(((x * x) + (y * y))));
}
public function Add(_arg1:b2Vec2){
x = (x + _arg1.x);
y = (y + _arg1.y);
}
public function SetZero(){
x = 0;
y = 0;
}
public function CrossVF(_arg1:Number){
var _local2:Number;
_local2 = x;
x = (_arg1 * y);
y = (-(_arg1) * _local2);
}
public function MaxV(_arg1:b2Vec2){
x = ((x > _arg1.x)) ? x : _arg1.x;
y = ((y > _arg1.y)) ? y : _arg1.y;
}
public function SetV(_arg1:b2Vec2){
x = _arg1.x;
y = _arg1.y;
}
public function Negative():b2Vec2{
return (new b2Vec2(-(x), -(y)));
}
public function Abs(){
x = Math.abs(x);
y = Math.abs(y);
}
public function Copy():b2Vec2{
return (new b2Vec2(x, y));
}
public function MulTM(_arg1:b2Mat22){
var _local2:Number;
_local2 = b2Math.b2Dot(this, _arg1.col1);
y = b2Math.b2Dot(this, _arg1.col2);
x = _local2;
}
public function IsValid():Boolean{
return (((b2Math.b2IsValid(x)) && (b2Math.b2IsValid(y))));
}
public function MinV(_arg1:b2Vec2){
x = ((x < _arg1.x)) ? x : _arg1.x;
y = ((y < _arg1.y)) ? y : _arg1.y;
}
public function MulM(_arg1:b2Mat22){
var _local2:Number;
_local2 = x;
x = ((_arg1.col1.x * _local2) + (_arg1.col2.x * y));
y = ((_arg1.col1.y * _local2) + (_arg1.col2.y * y));
}
public function Normalize():Number{
var _local1:Number;
var _local2:Number;
_local1 = Length();
if (_local1 < Number.MIN_VALUE){
return (0);
};
_local2 = (1 / _local1);
x = (x * _local2);
y = (y * _local2);
return (_local1);
}
public function Subtract(_arg1:b2Vec2){
x = (x - _arg1.x);
y = (y - _arg1.y);
}
public function CrossFV(_arg1:Number){
var _local2:Number;
_local2 = x;
x = (-(_arg1) * y);
y = (_arg1 * _local2);
}
public static function Make(_arg1:Number, _arg2:Number):b2Vec2{
return (new b2Vec2(_arg1, _arg2));
}
}
}//package Engine.Common.Math
Section 27
//b2Settings (Engine.Common.b2Settings)
package Engine.Common {
import Engine.Common.Math.*;
public class b2Settings {
public static const b2_lengthUnitsPerMeter:Number = 1;
public static const b2_angularSleepTolerance:Number = 0.0111111111111111;
public static const b2_linearSleepTolerance:Number = 0.01;
public static const b2_angularSlop:Number = 0.0349065850398866;
public static const b2_linearSlop:Number = 0.005;
public static const b2_pi:Number = 3.14159265358979;
public static const b2_maxShapesPerBody:int = 64;
public static const b2_maxProxies:int = 0x0400;
public static const b2_velocityThreshold:Number = 1;
public static const b2_timeToSleep:Number = 0.5;
public static const b2_contactBaumgarte:Number = 0.2;
public static const b2_maxPairs:int = 8192;
public static const b2_maxManifoldPoints:int = 2;
public static const b2_maxAngularCorrection:Number = 0.139626340159546;
public static const b2_massUnitsPerKilogram:Number = 1;
public static const USHRT_MAX:int = 0xFFFF;
public static const b2_maxLinearCorrection:Number = 0.2;
public static const b2_maxPolyVertices:int = 8;
public static const b2_timeUnitsPerSecond:Number = 1;
public static function b2Assert(_arg1:Boolean){
var _local2:b2Vec2;
if (!_arg1){
_local2.x++;
};
}
}
}//package Engine.Common
Section 28
//b2CircleContact (Engine.Dynamics.Contacts.b2CircleContact)
package Engine.Dynamics.Contacts {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
import Engine.Collision.Shapes.*;
import Engine.Collision.*;
import Engine.Common.*;
public class b2CircleContact extends b2Contact {
public var m_manifold:Array;
public function b2CircleContact(_arg1:b2Shape, _arg2:b2Shape){
m_manifold = [new b2Manifold()];
super(_arg1, _arg2);
m_manifold[0].pointCount = 0;
m_manifold[0].points[0].normalImpulse = 0;
m_manifold[0].points[0].tangentImpulse = 0;
}
override public function GetManifolds():Array{
return (m_manifold);
}
override public function Evaluate(){
b2Collision.b2CollideCircle(m_manifold[0], (m_shape1 as b2CircleShape), (m_shape2 as b2CircleShape));
if (m_manifold[0].pointCount > 0){
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
}
public static function Destroy(_arg1:b2Contact, _arg2){
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
return (new b2CircleContact(_arg1, _arg2));
}
}
}//package Engine.Dynamics.Contacts
Section 29
//b2Contact (Engine.Dynamics.Contacts.b2Contact)
package Engine.Dynamics.Contacts {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
import Engine.Collision.Shapes.*;
import Engine.Collision.*;
import Engine.Common.*;
public class b2Contact {
public var m_shape1:b2Shape;
public var m_shape2:b2Shape;
public var m_prev:b2Contact;
public var m_next:b2Contact;
public var m_friction:Number;
public var m_manifoldCount:int;
public var m_node1:b2ContactNode;
public var m_node2:b2ContactNode;
public var m_restitution:Number;
public var m_flags:uint;
public static var s_registers:Array;
public static var s_initialized:Boolean = false;
public static var e_islandFlag:uint = 1;
public static var e_destroyFlag:uint = 2;
public function b2Contact(_arg1:b2Shape=null, _arg2:b2Shape=null){
m_node1 = new b2ContactNode();
m_node2 = new b2ContactNode();
super();
m_flags = 0;
if (((!(_arg1)) || (!(_arg2)))){
m_shape1 = null;
m_shape2 = null;
return;
};
m_shape1 = _arg1;
m_shape2 = _arg2;
m_manifoldCount = 0;
m_friction = Math.sqrt((m_shape1.m_friction * m_shape2.m_friction));
m_restitution = b2Math.b2Max(m_shape1.m_restitution, m_shape2.m_restitution);
m_prev = null;
m_next = null;
m_node1.contact = null;
m_node1.prev = null;
m_node1.next = null;
m_node1.other = null;
m_node2.contact = null;
m_node2.prev = null;
m_node2.next = null;
m_node2.other = null;
}
public function GetShape1():b2Shape{
return (m_shape1);
}
public function GetNext():b2Contact{
return (m_next);
}
public function GetShape2():b2Shape{
return (m_shape2);
}
public function GetManifoldCount():int{
return (m_manifoldCount);
}
public function GetManifolds():Array{
return (null);
}
public function Evaluate(){
}
public static function InitializeRegisters(){
var _local1:int;
var _local2:int;
s_registers = new Array(b2Shape.e_shapeTypeCount);
_local1 = 0;
while (_local1 < b2Shape.e_shapeTypeCount) {
s_registers[_local1] = new Array(b2Shape.e_shapeTypeCount);
_local2 = 0;
while (_local2 < b2Shape.e_shapeTypeCount) {
s_registers[_local1][_local2] = new b2ContactRegister();
_local2++;
};
_local1++;
};
AddType(b2CircleContact.Create, b2CircleContact.Destroy, b2Shape.e_circleShape, b2Shape.e_circleShape);
AddType(b2PolyAndCircleContact.Create, b2PolyAndCircleContact.Destroy, b2Shape.e_polyShape, b2Shape.e_circleShape);
AddType(b2PolyContact.Create, b2PolyContact.Destroy, b2Shape.e_polyShape, b2Shape.e_polyShape);
}
public static function Destroy(_arg1:b2Contact, _arg2){
var _local3:int;
var _local4:int;
var _local5:*;
if (_arg1.GetManifoldCount() > 0){
_arg1.m_shape1.m_body.WakeUp();
_arg1.m_shape2.m_body.WakeUp();
};
_local3 = _arg1.m_shape1.m_type;
_local4 = _arg1.m_shape2.m_type;
_local5 = s_registers[_local3][_local4].destroyFcn;
_local5(_arg1, _arg2);
}
public static function AddType(_arg1, _arg2, _arg3:int, _arg4:int){
s_registers[_arg3][_arg4].createFcn = _arg1;
s_registers[_arg3][_arg4].destroyFcn = _arg2;
s_registers[_arg3][_arg4].primary = true;
if (_arg3 != _arg4){
s_registers[_arg4][_arg3].createFcn = _arg1;
s_registers[_arg4][_arg3].destroyFcn = _arg2;
s_registers[_arg4][_arg3].primary = false;
};
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
var _local4:int;
var _local5:int;
var _local6:*;
var _local7:b2Contact;
var _local8:int;
var _local9:b2Manifold;
if (s_initialized == false){
InitializeRegisters();
s_initialized = true;
};
_local4 = _arg1.m_type;
_local5 = _arg2.m_type;
_local6 = s_registers[_local4][_local5].createFcn;
if (_local6){
if (s_registers[_local4][_local5].primary){
return (_local6(_arg1, _arg2, _arg3));
};
_local7 = _local6(_arg2, _arg1, _arg3);
_local8 = 0;
while (_local8 < _local7.GetManifoldCount()) {
_local9 = _local7.GetManifolds()[_local8];
_local7.GetManifolds()[_local8].normal = _local9.normal.Negative();
_local8++;
};
return (_local7);
//unresolved jump
};
return (null);
}
}
}//package Engine.Dynamics.Contacts
Section 30
//b2ContactConstraint (Engine.Dynamics.Contacts.b2ContactConstraint)
package Engine.Dynamics.Contacts {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
import Engine.Collision.*;
import Engine.Common.*;
public class b2ContactConstraint {
public var points:Array;
public var restitution:Number;
public var body1:b2Body;
public var manifold:b2Manifold;
public var normal:b2Vec2;
public var body2:b2Body;
public var friction:Number;
public var pointCount:int;
public function b2ContactConstraint(){
var _local1:int;
normal = new b2Vec2();
super();
points = new Array(b2Settings.b2_maxManifoldPoints);
_local1 = 0;
while (_local1 < b2Settings.b2_maxManifoldPoints) {
points[_local1] = new b2ContactConstraintPoint();
_local1++;
};
}
}
}//package Engine.Dynamics.Contacts
Section 31
//b2ContactConstraintPoint (Engine.Dynamics.Contacts.b2ContactConstraintPoint)
package Engine.Dynamics.Contacts {
import Engine.Common.Math.*;
public class b2ContactConstraintPoint {
public var separation:Number;
public var positionImpulse:Number;
public var normalImpulse:Number;
public var tangentImpulse:Number;
public var localAnchor1:b2Vec2;
public var localAnchor2:b2Vec2;
public var tangentMass:Number;
public var normalMass:Number;
public var velocityBias:Number;
public function b2ContactConstraintPoint(){
localAnchor1 = new b2Vec2();
localAnchor2 = new b2Vec2();
super();
}
}
}//package Engine.Dynamics.Contacts
Section 32
//b2ContactNode (Engine.Dynamics.Contacts.b2ContactNode)
package Engine.Dynamics.Contacts {
import Engine.Dynamics.*;
public class b2ContactNode {
public var next:b2ContactNode;
public var other:b2Body;
public var contact:b2Contact;
public var prev:b2ContactNode;
}
}//package Engine.Dynamics.Contacts
Section 33
//b2ContactRegister (Engine.Dynamics.Contacts.b2ContactRegister)
package Engine.Dynamics.Contacts {
public class b2ContactRegister {
public var primary:Boolean;
public var createFcn;
public var destroyFcn;
}
}//package Engine.Dynamics.Contacts
Section 34
//b2ContactSolver (Engine.Dynamics.Contacts.b2ContactSolver)
package Engine.Dynamics.Contacts {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
import Engine.Collision.*;
import Engine.Common.*;
public class b2ContactSolver {
public var m_constraintCount:int;
public var m_constraints:Array;
public var m_allocator;
public function b2ContactSolver(_arg1:Array, _arg2:int, _arg3){
var _local4:int;
var _local5:b2Vec2;
var _local6:b2Mat22;
var _local7:int;
var _local8:b2Contact;
var _local9:b2Body;
var _local10:b2Body;
var _local11:int;
var _local12:Array;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:int;
var _local22:b2Manifold;
var _local23:Number;
var _local24:Number;
var _local25:b2ContactConstraint;
var _local26:*;
var _local27:b2ContactPoint;
var _local28:b2ContactConstraintPoint;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:Number;
var _local42:Number;
var _local43:Number;
var _local44:Number;
var _local45:Number;
m_constraints = new Array();
super();
m_allocator = _arg3;
m_constraintCount = 0;
_local4 = 0;
while (_local4 < _arg2) {
m_constraintCount = (m_constraintCount + _arg1[_local4].GetManifoldCount());
_local4++;
};
_local4 = 0;
while (_local4 < m_constraintCount) {
m_constraints[_local4] = new b2ContactConstraint();
_local4++;
};
_local7 = 0;
_local4 = 0;
while (_local4 < _arg2) {
_local8 = _arg1[_local4];
_local9 = _local8.m_shape1.m_body;
_local10 = _local8.m_shape2.m_body;
_local11 = _local8.GetManifoldCount();
_local12 = _local8.GetManifolds();
_local13 = _local8.m_friction;
_local14 = _local8.m_restitution;
_local15 = _local9.m_linearVelocity.x;
_local16 = _local9.m_linearVelocity.y;
_local17 = _local10.m_linearVelocity.x;
_local18 = _local10.m_linearVelocity.y;
_local19 = _local9.m_angularVelocity;
_local20 = _local10.m_angularVelocity;
_local21 = 0;
while (_local21 < _local11) {
_local22 = _local12[_local21];
_local23 = _local22.normal.x;
_local24 = _local22.normal.y;
_local25 = m_constraints[_local7];
_local25.body1 = _local9;
_local25.body2 = _local10;
_local25.manifold = _local22;
_local25.normal.x = _local23;
_local25.normal.y = _local24;
_local25.pointCount = _local22.pointCount;
_local25.friction = _local13;
_local25.restitution = _local14;
_local26 = 0;
while (_local26 < _local25.pointCount) {
_local27 = _local22.points[_local26];
_local28 = _local25.points[_local26];
_local28.normalImpulse = _local27.normalImpulse;
_local28.tangentImpulse = _local27.tangentImpulse;
_local28.separation = _local27.separation;
_local29 = (_local27.position.x - _local9.m_position.x);
_local30 = (_local27.position.y - _local9.m_position.y);
_local31 = (_local27.position.x - _local10.m_position.x);
_local32 = (_local27.position.y - _local10.m_position.y);
_local5 = _local28.localAnchor1;
_local6 = _local9.m_R;
_local5.x = ((_local29 * _local6.col1.x) + (_local30 * _local6.col1.y));
_local5.y = ((_local29 * _local6.col2.x) + (_local30 * _local6.col2.y));
_local5 = _local28.localAnchor2;
_local6 = _local10.m_R;
_local5.x = ((_local31 * _local6.col1.x) + (_local32 * _local6.col1.y));
_local5.y = ((_local31 * _local6.col2.x) + (_local32 * _local6.col2.y));
_local33 = ((_local29 * _local29) + (_local30 * _local30));
_local34 = ((_local31 * _local31) + (_local32 * _local32));
_local35 = ((_local29 * _local23) + (_local30 * _local24));
_local36 = ((_local31 * _local23) + (_local32 * _local24));
_local37 = (_local9.m_invMass + _local10.m_invMass);
_local37 = (_local37 + ((_local9.m_invI * (_local33 - (_local35 * _local35))) + (_local10.m_invI * (_local34 - (_local36 * _local36)))));
_local28.normalMass = (1 / _local37);
_local38 = _local24;
_local39 = -(_local23);
_local40 = ((_local29 * _local38) + (_local30 * _local39));
_local41 = ((_local31 * _local38) + (_local32 * _local39));
_local42 = (_local9.m_invMass + _local10.m_invMass);
_local42 = (_local42 + ((_local9.m_invI * (_local33 - (_local40 * _local40))) + (_local10.m_invI * (_local34 - (_local41 * _local41)))));
_local28.tangentMass = (1 / _local42);
_local43 = (((_local17 + (-(_local20) * _local32)) - _local15) - (-(_local19) * _local30));
_local44 = (((_local18 + (_local20 * _local31)) - _local16) - (_local19 * _local29));
_local45 = ((_local25.normal.x * _local43) + (_local25.normal.y * _local44));
if (_local45 < -(b2Settings.b2_velocityThreshold)){
_local28.velocityBias = (-(_local25.restitution) * _local45);
} else {
_local28.velocityBias = 0;
};
_local26++;
};
_local7++;
_local21++;
};
_local4++;
};
}
public function SolvePositionConstraints(_arg1:Number):Boolean{
var _local2:Number;
var _local3:b2Mat22;
var _local4:b2Vec2;
var _local5:int;
var _local6:b2ContactConstraint;
var _local7:b2Body;
var _local8:b2Body;
var _local9:b2Vec2;
var _local10:Number;
var _local11:b2Vec2;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:int;
var _local22:int;
var _local23:b2ContactConstraintPoint;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
_local2 = 0;
_local5 = 0;
while (_local5 < m_constraintCount) {
_local6 = m_constraints[_local5];
_local7 = _local6.body1;
_local8 = _local6.body2;
_local9 = _local7.m_position;
_local10 = _local7.m_rotation;
_local11 = _local8.m_position;
_local12 = _local8.m_rotation;
_local13 = _local7.m_invMass;
_local14 = _local7.m_invI;
_local15 = _local8.m_invMass;
_local16 = _local8.m_invI;
_local17 = _local6.normal.x;
_local18 = _local6.normal.y;
_local19 = _local18;
_local20 = -(_local17);
_local21 = _local6.pointCount;
_local22 = 0;
while (_local22 < _local21) {
_local23 = _local6.points[_local22];
_local3 = _local7.m_R;
_local4 = _local23.localAnchor1;
_local24 = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
_local25 = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
_local3 = _local8.m_R;
_local4 = _local23.localAnchor2;
_local26 = ((_local3.col1.x * _local4.x) + (_local3.col2.x * _local4.y));
_local27 = ((_local3.col1.y * _local4.x) + (_local3.col2.y * _local4.y));
_local28 = (_local9.x + _local24);
_local29 = (_local9.y + _local25);
_local30 = (_local11.x + _local26);
_local31 = (_local11.y + _local27);
_local32 = (_local30 - _local28);
_local33 = (_local31 - _local29);
_local34 = (((_local32 * _local17) + (_local33 * _local18)) + _local23.separation);
_local2 = b2Math.b2Min(_local2, _local34);
_local35 = (_arg1 * b2Math.b2Clamp((_local34 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0));
_local36 = (-(_local23.normalMass) * _local35);
_local37 = _local23.positionImpulse;
_local23.positionImpulse = b2Math.b2Max((_local37 + _local36), 0);
_local36 = (_local23.positionImpulse - _local37);
_local38 = (_local36 * _local17);
_local39 = (_local36 * _local18);
_local9.x = (_local9.x - (_local13 * _local38));
_local9.y = (_local9.y - (_local13 * _local39));
_local10 = (_local10 - (_local14 * ((_local24 * _local39) - (_local25 * _local38))));
_local7.m_R.Set(_local10);
_local11.x = (_local11.x + (_local15 * _local38));
_local11.y = (_local11.y + (_local15 * _local39));
_local12 = (_local12 + (_local16 * ((_local26 * _local39) - (_local27 * _local38))));
_local8.m_R.Set(_local12);
_local22++;
};
_local7.m_rotation = _local10;
_local8.m_rotation = _local12;
_local5++;
};
return ((_local2 >= -(b2Settings.b2_linearSlop)));
}
public function SolveVelocityConstraints(){
var _local1:int;
var _local2:b2ContactConstraintPoint;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:b2Mat22;
var _local14:b2Vec2;
var _local15:int;
var _local16:b2ContactConstraint;
var _local17:b2Body;
var _local18:b2Body;
var _local19:Number;
var _local20:b2Vec2;
var _local21:Number;
var _local22:b2Vec2;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:int;
var _local32:Number;
var _local33:Number;
var _local34:Number;
_local15 = 0;
while (_local15 < m_constraintCount) {
_local16 = m_constraints[_local15];
_local17 = _local16.body1;
_local18 = _local16.body2;
_local19 = _local17.m_angularVelocity;
_local20 = _local17.m_linearVelocity;
_local21 = _local18.m_angularVelocity;
_local22 = _local18.m_linearVelocity;
_local23 = _local17.m_invMass;
_local24 = _local17.m_invI;
_local25 = _local18.m_invMass;
_local26 = _local18.m_invI;
_local27 = _local16.normal.x;
_local28 = _local16.normal.y;
_local29 = _local28;
_local30 = -(_local27);
_local31 = _local16.pointCount;
_local1 = 0;
while (_local1 < _local31) {
_local2 = _local16.points[_local1];
_local13 = _local17.m_R;
_local14 = _local2.localAnchor1;
_local3 = ((_local13.col1.x * _local14.x) + (_local13.col2.x * _local14.y));
_local4 = ((_local13.col1.y * _local14.x) + (_local13.col2.y * _local14.y));
_local13 = _local18.m_R;
_local14 = _local2.localAnchor2;
_local5 = ((_local13.col1.x * _local14.x) + (_local13.col2.x * _local14.y));
_local6 = ((_local13.col1.y * _local14.x) + (_local13.col2.y * _local14.y));
_local7 = (((_local22.x + (-(_local21) * _local6)) - _local20.x) - (-(_local19) * _local4));
_local8 = (((_local22.y + (_local21 * _local5)) - _local20.y) - (_local19 * _local3));
_local32 = ((_local7 * _local27) + (_local8 * _local28));
_local9 = (-(_local2.normalMass) * (_local32 - _local2.velocityBias));
_local10 = b2Math.b2Max((_local2.normalImpulse + _local9), 0);
_local9 = (_local10 - _local2.normalImpulse);
_local11 = (_local9 * _local27);
_local12 = (_local9 * _local28);
_local20.x = (_local20.x - (_local23 * _local11));
_local20.y = (_local20.y - (_local23 * _local12));
_local19 = (_local19 - (_local24 * ((_local3 * _local12) - (_local4 * _local11))));
_local22.x = (_local22.x + (_local25 * _local11));
_local22.y = (_local22.y + (_local25 * _local12));
_local21 = (_local21 + (_local26 * ((_local5 * _local12) - (_local6 * _local11))));
_local2.normalImpulse = _local10;
_local7 = (((_local22.x + (-(_local21) * _local6)) - _local20.x) - (-(_local19) * _local4));
_local8 = (((_local22.y + (_local21 * _local5)) - _local20.y) - (_local19 * _local3));
_local33 = ((_local7 * _local29) + (_local8 * _local30));
_local9 = (_local2.tangentMass * -(_local33));
_local34 = (_local16.friction * _local2.normalImpulse);
_local10 = b2Math.b2Clamp((_local2.tangentImpulse + _local9), -(_local34), _local34);
_local9 = (_local10 - _local2.tangentImpulse);
_local11 = (_local9 * _local29);
_local12 = (_local9 * _local30);
_local20.x = (_local20.x - (_local23 * _local11));
_local20.y = (_local20.y - (_local23 * _local12));
_local19 = (_local19 - (_local24 * ((_local3 * _local12) - (_local4 * _local11))));
_local22.x = (_local22.x + (_local25 * _local11));
_local22.y = (_local22.y + (_local25 * _local12));
_local21 = (_local21 + (_local26 * ((_local5 * _local12) - (_local6 * _local11))));
_local2.tangentImpulse = _local10;
_local1++;
};
_local17.m_angularVelocity = _local19;
_local18.m_angularVelocity = _local21;
_local15++;
};
}
public function PreSolve(){
var _local1:b2Vec2;
var _local2:b2Vec2;
var _local3:b2Mat22;
var _local4:int;
var _local5:b2ContactConstraint;
var _local6:b2Body;
var _local7:b2Body;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:int;
var _local17:int;
var _local18:b2ContactConstraintPoint;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:b2ContactConstraintPoint;
_local4 = 0;
while (_local4 < m_constraintCount) {
_local5 = m_constraints[_local4];
_local6 = _local5.body1;
_local7 = _local5.body2;
_local8 = _local6.m_invMass;
_local9 = _local6.m_invI;
_local10 = _local7.m_invMass;
_local11 = _local7.m_invI;
_local12 = _local5.normal.x;
_local13 = _local5.normal.y;
_local14 = _local13;
_local15 = -(_local12);
if (b2World.s_enableWarmStarting){
_local17 = _local5.pointCount;
_local16 = 0;
while (_local16 < _local17) {
_local18 = _local5.points[_local16];
_local19 = ((_local18.normalImpulse * _local12) + (_local18.tangentImpulse * _local14));
_local20 = ((_local18.normalImpulse * _local13) + (_local18.tangentImpulse * _local15));
_local3 = _local6.m_R;
_local1 = _local18.localAnchor1;
_local21 = ((_local3.col1.x * _local1.x) + (_local3.col2.x * _local1.y));
_local22 = ((_local3.col1.y * _local1.x) + (_local3.col2.y * _local1.y));
_local3 = _local7.m_R;
_local1 = _local18.localAnchor2;
_local23 = ((_local3.col1.x * _local1.x) + (_local3.col2.x * _local1.y));
_local24 = ((_local3.col1.y * _local1.x) + (_local3.col2.y * _local1.y));
_local6.m_angularVelocity = (_local6.m_angularVelocity - (_local9 * ((_local21 * _local20) - (_local22 * _local19))));
_local6.m_linearVelocity.x = (_local6.m_linearVelocity.x - (_local8 * _local19));
_local6.m_linearVelocity.y = (_local6.m_linearVelocity.y - (_local8 * _local20));
_local7.m_angularVelocity = (_local7.m_angularVelocity + (_local11 * ((_local23 * _local20) - (_local24 * _local19))));
_local7.m_linearVelocity.x = (_local7.m_linearVelocity.x + (_local10 * _local19));
_local7.m_linearVelocity.y = (_local7.m_linearVelocity.y + (_local10 * _local20));
_local18.positionImpulse = 0;
_local16++;
};
} else {
_local17 = _local5.pointCount;
_local16 = 0;
while (_local16 < _local17) {
_local25 = _local5.points[_local16];
_local25.normalImpulse = 0;
_local25.tangentImpulse = 0;
_local25.positionImpulse = 0;
_local16++;
};
};
_local4++;
};
}
public function PostSolve(){
var _local1:int;
var _local2:b2ContactConstraint;
var _local3:b2Manifold;
var _local4:int;
var _local5:b2ContactPoint;
var _local6:b2ContactConstraintPoint;
_local1 = 0;
while (_local1 < m_constraintCount) {
_local2 = m_constraints[_local1];
_local3 = _local2.manifold;
_local4 = 0;
while (_local4 < _local2.pointCount) {
_local5 = _local3.points[_local4];
_local6 = _local2.points[_local4];
_local5.normalImpulse = _local6.normalImpulse;
_local5.tangentImpulse = _local6.tangentImpulse;
_local4++;
};
_local1++;
};
}
}
}//package Engine.Dynamics.Contacts
Section 35
//b2NullContact (Engine.Dynamics.Contacts.b2NullContact)
package Engine.Dynamics.Contacts {
public class b2NullContact extends b2Contact {
override public function GetManifolds():Array{
return (null);
}
override public function Evaluate(){
}
}
}//package Engine.Dynamics.Contacts
Section 36
//b2PolyAndCircleContact (Engine.Dynamics.Contacts.b2PolyAndCircleContact)
package Engine.Dynamics.Contacts {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
import Engine.Collision.Shapes.*;
import Engine.Collision.*;
import Engine.Common.*;
public class b2PolyAndCircleContact extends b2Contact {
public var m_manifold:Array;
public function b2PolyAndCircleContact(_arg1:b2Shape, _arg2:b2Shape){
m_manifold = [new b2Manifold()];
super(_arg1, _arg2);
b2Settings.b2Assert((m_shape1.m_type == b2Shape.e_polyShape));
b2Settings.b2Assert((m_shape2.m_type == b2Shape.e_circleShape));
m_manifold[0].pointCount = 0;
m_manifold[0].points[0].normalImpulse = 0;
m_manifold[0].points[0].tangentImpulse = 0;
}
override public function GetManifolds():Array{
return (m_manifold);
}
override public function Evaluate(){
b2Collision.b2CollidePolyAndCircle(m_manifold[0], (m_shape1 as b2PolyShape), (m_shape2 as b2CircleShape));
if (m_manifold[0].pointCount > 0){
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
}
public static function Destroy(_arg1:b2Contact, _arg2){
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
return (new b2PolyAndCircleContact(_arg1, _arg2));
}
}
}//package Engine.Dynamics.Contacts
Section 37
//b2PolyContact (Engine.Dynamics.Contacts.b2PolyContact)
package Engine.Dynamics.Contacts {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
import Engine.Collision.Shapes.*;
import Engine.Collision.*;
import Engine.Common.*;
public class b2PolyContact extends b2Contact {
public var m_manifold:Array;
private var m0:b2Manifold;
public function b2PolyContact(_arg1:b2Shape, _arg2:b2Shape){
m0 = new b2Manifold();
m_manifold = [new b2Manifold()];
super(_arg1, _arg2);
m_manifold[0].pointCount = 0;
}
override public function GetManifolds():Array{
return (m_manifold);
}
override public function Evaluate(){
var _local1:b2Manifold;
var _local2:Array;
var _local3:int;
var _local4:b2ContactPoint;
var _local5:b2ContactPoint;
var _local6:Array;
var _local7:int;
var _local8:b2ContactPoint;
var _local9:uint;
var _local10:int;
var _local11:b2ContactPoint;
var _local12:b2ContactID;
_local1 = m_manifold[0];
_local2 = m0.points;
_local3 = 0;
while (_local3 < _local1.pointCount) {
_local4 = _local2[_local3];
_local5 = _local1.points[_local3];
_local4.normalImpulse = _local5.normalImpulse;
_local4.tangentImpulse = _local5.tangentImpulse;
_local4.id = _local5.id.Copy();
_local3++;
};
m0.pointCount = _local1.pointCount;
b2Collision.b2CollidePoly(_local1, (m_shape1 as b2PolyShape), (m_shape2 as b2PolyShape));
if (_local1.pointCount > 0){
_local6 = [false, false];
_local7 = 0;
while (_local7 < _local1.pointCount) {
_local8 = _local1.points[_local7];
_local8.normalImpulse = 0;
_local8.tangentImpulse = 0;
_local9 = _local8.id.key;
_local10 = 0;
while (_local10 < m0.pointCount) {
if (_local6[_local10] == true){
} else {
_local11 = m0.points[_local10];
_local12 = _local11.id;
if (_local12.key == _local9){
_local6[_local10] = true;
_local8.normalImpulse = _local11.normalImpulse;
_local8.tangentImpulse = _local11.tangentImpulse;
break;
};
};
_local10++;
};
_local7++;
};
m_manifoldCount = 1;
} else {
m_manifoldCount = 0;
};
}
public static function Destroy(_arg1:b2Contact, _arg2){
}
public static function Create(_arg1:b2Shape, _arg2:b2Shape, _arg3):b2Contact{
return (new b2PolyContact(_arg1, _arg2));
}
}
}//package Engine.Dynamics.Contacts
Section 38
//b2DistanceJoint (Engine.Dynamics.Joints.b2DistanceJoint)
package Engine.Dynamics.Joints {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
import Engine.Common.*;
public class b2DistanceJoint extends b2Joint {
public var m_localAnchor2:b2Vec2;
public var m_mass:Number;
public var m_localAnchor1:b2Vec2;
public var m_u:b2Vec2;
public var m_impulse:Number;
public var m_length:Number;
public function b2DistanceJoint(_arg1:b2DistanceJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_u = new b2Vec2();
super(_arg1);
_local2 = m_body1.m_R;
_local3 = (_arg1.anchorPoint1.x - m_body1.m_position.x);
_local4 = (_arg1.anchorPoint1.y - m_body1.m_position.y);
m_localAnchor1.x = ((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y));
m_localAnchor1.y = ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y));
_local2 = m_body2.m_R;
_local3 = (_arg1.anchorPoint2.x - m_body2.m_position.x);
_local4 = (_arg1.anchorPoint2.y - m_body2.m_position.y);
m_localAnchor2.x = ((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y));
m_localAnchor2.y = ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y));
_local3 = (_arg1.anchorPoint2.x - _arg1.anchorPoint1.x);
_local4 = (_arg1.anchorPoint2.y - _arg1.anchorPoint1.y);
m_length = Math.sqrt(((_local3 * _local3) + (_local4 * _local4)));
m_impulse = 0;
}
override public function SolveVelocityConstraints(_arg1:b2StepInfo){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
_local2 = m_body1.m_R;
_local3 = ((_local2.col1.x * m_localAnchor1.x) + (_local2.col2.x * m_localAnchor1.y));
_local4 = ((_local2.col1.y * m_localAnchor1.x) + (_local2.col2.y * m_localAnchor1.y));
_local2 = m_body2.m_R;
_local5 = ((_local2.col1.x * m_localAnchor2.x) + (_local2.col2.x * m_localAnchor2.y));
_local6 = ((_local2.col1.y * m_localAnchor2.x) + (_local2.col2.y * m_localAnchor2.y));
_local7 = (m_body1.m_linearVelocity.x + (-(m_body1.m_angularVelocity) * _local4));
_local8 = (m_body1.m_linearVelocity.y + (m_body1.m_angularVelocity * _local3));
_local9 = (m_body2.m_linearVelocity.x + (-(m_body2.m_angularVelocity) * _local6));
_local10 = (m_body2.m_linearVelocity.y + (m_body2.m_angularVelocity * _local5));
_local11 = ((m_u.x * (_local9 - _local7)) + (m_u.y * (_local10 - _local8)));
_local12 = (-(m_mass) * _local11);
m_impulse = (m_impulse + _local12);
_local13 = (_local12 * m_u.x);
_local14 = (_local12 * m_u.y);
m_body1.m_linearVelocity.x = (m_body1.m_linearVelocity.x - (m_body1.m_invMass * _local13));
m_body1.m_linearVelocity.y = (m_body1.m_linearVelocity.y - (m_body1.m_invMass * _local14));
m_body1.m_angularVelocity = (m_body1.m_angularVelocity - (m_body1.m_invI * ((_local3 * _local14) - (_local4 * _local13))));
m_body2.m_linearVelocity.x = (m_body2.m_linearVelocity.x + (m_body2.m_invMass * _local13));
m_body2.m_linearVelocity.y = (m_body2.m_linearVelocity.y + (m_body2.m_invMass * _local14));
m_body2.m_angularVelocity = (m_body2.m_angularVelocity + (m_body2.m_invI * ((_local5 * _local14) - (_local6 * _local13))));
}
override public function GetAnchor1():b2Vec2{
return (b2Math.AddVV(m_body1.m_position, b2Math.b2MulMV(m_body1.m_R, m_localAnchor1)));
}
override public function GetAnchor2():b2Vec2{
return (b2Math.AddVV(m_body2.m_position, b2Math.b2MulMV(m_body2.m_R, m_localAnchor2)));
}
override public function PrepareVelocitySolver(){
var _local1:b2Mat22;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
_local1 = m_body1.m_R;
_local2 = ((_local1.col1.x * m_localAnchor1.x) + (_local1.col2.x * m_localAnchor1.y));
_local3 = ((_local1.col1.y * m_localAnchor1.x) + (_local1.col2.y * m_localAnchor1.y));
_local1 = m_body2.m_R;
_local4 = ((_local1.col1.x * m_localAnchor2.x) + (_local1.col2.x * m_localAnchor2.y));
_local5 = ((_local1.col1.y * m_localAnchor2.x) + (_local1.col2.y * m_localAnchor2.y));
m_u.x = (((m_body2.m_position.x + _local4) - m_body1.m_position.x) - _local2);
m_u.y = (((m_body2.m_position.y + _local5) - m_body1.m_position.y) - _local3);
_local6 = Math.sqrt(((m_u.x * m_u.x) + (m_u.y * m_u.y)));
if (_local6 > b2Settings.b2_linearSlop){
m_u.Multiply((1 / _local6));
} else {
m_u.SetZero();
};
_local7 = ((_local2 * m_u.y) - (_local3 * m_u.x));
_local8 = ((_local4 * m_u.y) - (_local5 * m_u.x));
m_mass = (((m_body1.m_invMass + ((m_body1.m_invI * _local7) * _local7)) + m_body2.m_invMass) + ((m_body2.m_invI * _local8) * _local8));
m_mass = (1 / m_mass);
if (b2World.s_enableWarmStarting){
_local9 = (m_impulse * m_u.x);
_local10 = (m_impulse * m_u.y);
m_body1.m_linearVelocity.x = (m_body1.m_linearVelocity.x - (m_body1.m_invMass * _local9));
m_body1.m_linearVelocity.y = (m_body1.m_linearVelocity.y - (m_body1.m_invMass * _local10));
m_body1.m_angularVelocity = (m_body1.m_angularVelocity - (m_body1.m_invI * ((_local2 * _local10) - (_local3 * _local9))));
m_body2.m_linearVelocity.x = (m_body2.m_linearVelocity.x + (m_body2.m_invMass * _local9));
m_body2.m_linearVelocity.y = (m_body2.m_linearVelocity.y + (m_body2.m_invMass * _local10));
m_body2.m_angularVelocity = (m_body2.m_angularVelocity + (m_body2.m_invI * ((_local4 * _local10) - (_local5 * _local9))));
} else {
m_impulse = 0;
};
}
override public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
var _local2:b2Vec2;
_local2 = new b2Vec2();
_local2.SetV(m_u);
_local2.Multiply((m_impulse * _arg1));
return (_local2);
}
override public function SolvePositionConstraints():Boolean{
var _local1:b2Mat22;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
_local1 = m_body1.m_R;
_local2 = ((_local1.col1.x * m_localAnchor1.x) + (_local1.col2.x * m_localAnchor1.y));
_local3 = ((_local1.col1.y * m_localAnchor1.x) + (_local1.col2.y * m_localAnchor1.y));
_local1 = m_body2.m_R;
_local4 = ((_local1.col1.x * m_localAnchor2.x) + (_local1.col2.x * m_localAnchor2.y));
_local5 = ((_local1.col1.y * m_localAnchor2.x) + (_local1.col2.y * m_localAnchor2.y));
_local6 = (((m_body2.m_position.x + _local4) - m_body1.m_position.x) - _local2);
_local7 = (((m_body2.m_position.y + _local5) - m_body1.m_position.y) - _local3);
_local8 = Math.sqrt(((_local6 * _local6) + (_local7 * _local7)));
_local6 = (_local6 / _local8);
_local7 = (_local7 / _local8);
_local9 = (_local8 - m_length);
_local9 = b2Math.b2Clamp(_local9, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local10 = (-(m_mass) * _local9);
m_u.Set(_local6, _local7);
_local11 = (_local10 * m_u.x);
_local12 = (_local10 * m_u.y);
m_body1.m_position.x = (m_body1.m_position.x - (m_body1.m_invMass * _local11));
m_body1.m_position.y = (m_body1.m_position.y - (m_body1.m_invMass * _local12));
m_body1.m_rotation = (m_body1.m_rotation - (m_body1.m_invI * ((_local2 * _local12) - (_local3 * _local11))));
m_body2.m_position.x = (m_body2.m_position.x + (m_body2.m_invMass * _local11));
m_body2.m_position.y = (m_body2.m_position.y + (m_body2.m_invMass * _local12));
m_body2.m_rotation = (m_body2.m_rotation + (m_body2.m_invI * ((_local4 * _local12) - (_local5 * _local11))));
m_body1.m_R.Set(m_body1.m_rotation);
m_body2.m_R.Set(m_body2.m_rotation);
return ((b2Math.b2Abs(_local9) < b2Settings.b2_linearSlop));
}
}
}//package Engine.Dynamics.Joints
Section 39
//b2DistanceJointDef (Engine.Dynamics.Joints.b2DistanceJointDef)
package Engine.Dynamics.Joints {
import Engine.Common.Math.*;
public class b2DistanceJointDef extends b2JointDef {
public var anchorPoint2:b2Vec2;
public var anchorPoint1:b2Vec2;
public function b2DistanceJointDef(){
anchorPoint1 = new b2Vec2();
anchorPoint2 = new b2Vec2();
super();
type = b2Joint.e_distanceJoint;
}
}
}//package Engine.Dynamics.Joints
Section 40
//b2GearJoint (Engine.Dynamics.Joints.b2GearJoint)
package Engine.Dynamics.Joints {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
import Engine.Common.*;
public class b2GearJoint extends b2Joint {
public var m_impulse:Number;
public var m_mass:Number;
public var m_prismatic1:b2PrismaticJoint;
public var m_prismatic2:b2PrismaticJoint;
public var m_ground1:b2Body;
public var m_ground2:b2Body;
public var m_constant:Number;
public var m_revolute1:b2RevoluteJoint;
public var m_revolute2:b2RevoluteJoint;
public var m_groundAnchor1:b2Vec2;
public var m_groundAnchor2:b2Vec2;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_ratio:Number;
public var m_J:b2Jacobian;
public function b2GearJoint(_arg1:b2GearJointDef){
var _local2:Number;
var _local3:Number;
m_groundAnchor1 = new b2Vec2();
m_groundAnchor2 = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_J = new b2Jacobian();
super(_arg1);
m_revolute1 = null;
m_prismatic1 = null;
m_revolute2 = null;
m_prismatic2 = null;
m_ground1 = _arg1.joint1.m_body1;
m_body1 = _arg1.joint1.m_body2;
if (_arg1.joint1.m_type == b2Joint.e_revoluteJoint){
m_revolute1 = (_arg1.joint1 as b2RevoluteJoint);
m_groundAnchor1.SetV(m_revolute1.m_localAnchor1);
m_localAnchor1.SetV(m_revolute1.m_localAnchor2);
_local2 = m_revolute1.GetJointAngle();
} else {
m_prismatic1 = (_arg1.joint1 as b2PrismaticJoint);
m_groundAnchor1.SetV(m_prismatic1.m_localAnchor1);
m_localAnchor1.SetV(m_prismatic1.m_localAnchor2);
_local2 = m_prismatic1.GetJointTranslation();
};
m_ground2 = _arg1.joint2.m_body1;
m_body2 = _arg1.joint2.m_body2;
if (_arg1.joint2.m_type == b2Joint.e_revoluteJoint){
m_revolute2 = (_arg1.joint2 as b2RevoluteJoint);
m_groundAnchor2.SetV(m_revolute2.m_localAnchor1);
m_localAnchor2.SetV(m_revolute2.m_localAnchor2);
_local3 = m_revolute2.GetJointAngle();
} else {
m_prismatic2 = (_arg1.joint2 as b2PrismaticJoint);
m_groundAnchor2.SetV(m_prismatic2.m_localAnchor1);
m_localAnchor2.SetV(m_prismatic2.m_localAnchor2);
_local3 = m_prismatic2.GetJointTranslation();
};
m_ratio = _arg1.ratio;
m_constant = (_local2 + (m_ratio * _local3));
m_impulse = 0;
}
override public function GetAnchor1():b2Vec2{
var _local1:b2Mat22;
_local1 = m_body1.m_R;
return (new b2Vec2((m_body1.m_position.x + ((_local1.col1.x * m_localAnchor1.x) + (_local1.col2.x * m_localAnchor1.y))), (m_body1.m_position.y + ((_local1.col1.y * m_localAnchor1.x) + (_local1.col2.y * m_localAnchor1.y)))));
}
override public function GetAnchor2():b2Vec2{
var _local1:b2Mat22;
_local1 = m_body2.m_R;
return (new b2Vec2((m_body2.m_position.x + ((_local1.col1.x * m_localAnchor2.x) + (_local1.col2.x * m_localAnchor2.y))), (m_body2.m_position.y + ((_local1.col1.y * m_localAnchor2.x) + (_local1.col2.y * m_localAnchor2.y)))));
}
override public function PrepareVelocitySolver(){
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Body;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:b2Mat22;
var _local10:b2Vec2;
var _local11:Number;
var _local12:Number;
_local1 = m_ground1;
_local2 = m_ground2;
_local3 = m_body1;
_local4 = m_body2;
_local12 = 0;
m_J.SetZero();
if (m_revolute1){
m_J.angular1 = -1;
_local12 = (_local12 + _local3.m_invI);
} else {
_local9 = _local1.m_R;
_local10 = m_prismatic1.m_localXAxis1;
_local5 = ((_local9.col1.x * _local10.x) + (_local9.col2.x * _local10.y));
_local6 = ((_local9.col1.y * _local10.x) + (_local9.col2.y * _local10.y));
_local9 = _local3.m_R;
_local7 = ((_local9.col1.x * m_localAnchor1.x) + (_local9.col2.x * m_localAnchor1.y));
_local8 = ((_local9.col1.y * m_localAnchor1.x) + (_local9.col2.y * m_localAnchor1.y));
_local11 = ((_local7 * _local6) - (_local8 * _local5));
m_J.linear1.Set(-(_local5), -(_local6));
m_J.angular1 = -(_local11);
_local12 = (_local12 + (_local3.m_invMass + ((_local3.m_invI * _local11) * _local11)));
};
if (m_revolute2){
m_J.angular2 = -(m_ratio);
_local12 = (_local12 + ((m_ratio * m_ratio) * _local4.m_invI));
} else {
_local9 = _local2.m_R;
_local10 = m_prismatic2.m_localXAxis1;
_local5 = ((_local9.col1.x * _local10.x) + (_local9.col2.x * _local10.y));
_local6 = ((_local9.col1.y * _local10.x) + (_local9.col2.y * _local10.y));
_local9 = _local4.m_R;
_local7 = ((_local9.col1.x * m_localAnchor2.x) + (_local9.col2.x * m_localAnchor2.y));
_local8 = ((_local9.col1.y * m_localAnchor2.x) + (_local9.col2.y * m_localAnchor2.y));
_local11 = ((_local7 * _local6) - (_local8 * _local5));
m_J.linear2.Set((-(m_ratio) * _local5), (-(m_ratio) * _local6));
m_J.angular2 = (-(m_ratio) * _local11);
_local12 = (_local12 + ((m_ratio * m_ratio) * (_local4.m_invMass + ((_local4.m_invI * _local11) * _local11))));
};
m_mass = (1 / _local12);
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local3.m_invMass * m_impulse) * m_J.linear1.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local3.m_invMass * m_impulse) * m_J.linear1.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local3.m_invI * m_impulse) * m_J.angular1));
_local4.m_linearVelocity.x = (_local4.m_linearVelocity.x + ((_local4.m_invMass * m_impulse) * m_J.linear2.x));
_local4.m_linearVelocity.y = (_local4.m_linearVelocity.y + ((_local4.m_invMass * m_impulse) * m_J.linear2.y));
_local4.m_angularVelocity = (_local4.m_angularVelocity + ((_local4.m_invI * m_impulse) * m_J.angular2));
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2());
}
override public function SolvePositionConstraints():Boolean{
var _local1:Number;
var _local2:b2Body;
var _local3:b2Body;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
_local1 = 0;
_local2 = m_body1;
_local3 = m_body2;
if (m_revolute1){
_local4 = m_revolute1.GetJointAngle();
} else {
_local4 = m_prismatic1.GetJointTranslation();
};
if (m_revolute2){
_local5 = m_revolute2.GetJointAngle();
} else {
_local5 = m_prismatic2.GetJointTranslation();
};
_local6 = (m_constant - (_local4 + (m_ratio * _local5)));
_local7 = (-(m_mass) * _local6);
_local2.m_position.x = (_local2.m_position.x + ((_local2.m_invMass * _local7) * m_J.linear1.x));
_local2.m_position.y = (_local2.m_position.y + ((_local2.m_invMass * _local7) * m_J.linear1.y));
_local2.m_rotation = (_local2.m_rotation + ((_local2.m_invI * _local7) * m_J.angular1));
_local3.m_position.x = (_local3.m_position.x + ((_local3.m_invMass * _local7) * m_J.linear2.x));
_local3.m_position.y = (_local3.m_position.y + ((_local3.m_invMass * _local7) * m_J.linear2.y));
_local3.m_rotation = (_local3.m_rotation + ((_local3.m_invI * _local7) * m_J.angular2));
_local2.m_R.Set(_local2.m_rotation);
_local3.m_R.Set(_local3.m_rotation);
return ((_local1 < b2Settings.b2_linearSlop));
}
override public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
public function GetRatio():Number{
return (m_ratio);
}
override public function SolveVelocityConstraints(_arg1:b2StepInfo){
var _local2:b2Body;
var _local3:b2Body;
var _local4:Number;
var _local5:Number;
_local2 = m_body1;
_local3 = m_body2;
_local4 = m_J.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity);
_local5 = (-(m_mass) * _local4);
m_impulse = (m_impulse + _local5);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local2.m_invMass * _local5) * m_J.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local2.m_invMass * _local5) * m_J.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local2.m_invI * _local5) * m_J.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local3.m_invMass * _local5) * m_J.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local3.m_invMass * _local5) * m_J.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local3.m_invI * _local5) * m_J.angular2));
}
}
}//package Engine.Dynamics.Joints
Section 41
//b2GearJointDef (Engine.Dynamics.Joints.b2GearJointDef)
package Engine.Dynamics.Joints {
public class b2GearJointDef extends b2JointDef {
public var joint2:b2Joint;
public var joint1:b2Joint;
public var ratio:Number;
public function b2GearJointDef(){
type = b2Joint.e_gearJoint;
joint1 = null;
joint2 = null;
ratio = 1;
}
}
}//package Engine.Dynamics.Joints
Section 42
//b2Jacobian (Engine.Dynamics.Joints.b2Jacobian)
package Engine.Dynamics.Joints {
import Engine.Common.Math.*;
public class b2Jacobian {
public var linear1:b2Vec2;
public var linear2:b2Vec2;
public var angular2:Number;
public var angular1:Number;
public function b2Jacobian(){
linear1 = new b2Vec2();
linear2 = new b2Vec2();
super();
}
public function Set(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number){
linear1.SetV(_arg1);
angular1 = _arg2;
linear2.SetV(_arg3);
angular2 = _arg4;
}
public function SetZero(){
linear1.SetZero();
angular1 = 0;
linear2.SetZero();
angular2 = 0;
}
public function Compute(_arg1:b2Vec2, _arg2:Number, _arg3:b2Vec2, _arg4:Number):Number{
return ((((((linear1.x * _arg1.x) + (linear1.y * _arg1.y)) + (angular1 * _arg2)) + ((linear2.x * _arg3.x) + (linear2.y * _arg3.y))) + (angular2 * _arg4)));
}
}
}//package Engine.Dynamics.Joints
Section 43
//b2Joint (Engine.Dynamics.Joints.b2Joint)
package Engine.Dynamics.Joints {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
public class b2Joint {
public var m_islandFlag:Boolean;
public var m_collideConnected:Boolean;
public var m_prev:b2Joint;
public var m_next:b2Joint;
public var m_type:int;
public var m_node1:b2JointNode;
public var m_node2:b2JointNode;
public var m_userData;
public var m_body1:b2Body;
public var m_body2:b2Body;
public static const e_unknownJoint:int = 0;
public static const e_inactiveLimit:int = 0;
public static const e_atUpperLimit:int = 2;
public static const e_atLowerLimit:int = 1;
public static const e_gearJoint:int = 6;
public static const e_revoluteJoint:int = 1;
public static const e_equalLimits:int = 3;
public static const e_distanceJoint:int = 3;
public static const e_pulleyJoint:int = 4;
public static const e_prismaticJoint:int = 2;
public static const e_mouseJoint:int = 5;
public function b2Joint(_arg1:b2JointDef){
m_node1 = new b2JointNode();
m_node2 = new b2JointNode();
super();
m_type = _arg1.type;
m_prev = null;
m_next = null;
m_body1 = _arg1.body1;
m_body2 = _arg1.body2;
m_collideConnected = _arg1.collideConnected;
m_islandFlag = false;
m_userData = _arg1.userData;
}
public function GetAnchor1():b2Vec2{
return (null);
}
public function GetAnchor2():b2Vec2{
return (null);
}
public function GetNext():b2Joint{
return (m_next);
}
public function GetType():int{
return (m_type);
}
public function GetBody2():b2Body{
return (m_body2);
}
public function PrepareVelocitySolver(){
}
public function PreparePositionSolver(){
}
public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
public function GetUserData(){
return (m_userData);
}
public function GetReactionForce(_arg1:Number):b2Vec2{
return (null);
}
public function SolvePositionConstraints():Boolean{
return (false);
}
public function GetBody1():b2Body{
return (m_body1);
}
public function SolveVelocityConstraints(_arg1:b2StepInfo){
}
public static function Destroy(_arg1:b2Joint, _arg2){
}
public static function Create(_arg1:b2JointDef, _arg2):b2Joint{
var _local3:b2Joint;
_local3 = null;
switch (_arg1.type){
case e_distanceJoint:
_local3 = new b2DistanceJoint((_arg1 as b2DistanceJointDef));
break;
case e_mouseJoint:
_local3 = new b2MouseJoint((_arg1 as b2MouseJointDef));
break;
case e_prismaticJoint:
_local3 = new b2PrismaticJoint((_arg1 as b2PrismaticJointDef));
break;
case e_revoluteJoint:
_local3 = new b2RevoluteJoint((_arg1 as b2RevoluteJointDef));
break;
case e_pulleyJoint:
_local3 = new b2PulleyJoint((_arg1 as b2PulleyJointDef));
break;
case e_gearJoint:
_local3 = new b2GearJoint((_arg1 as b2GearJointDef));
break;
default:
break;
};
return (_local3);
}
}
}//package Engine.Dynamics.Joints
Section 44
//b2JointDef (Engine.Dynamics.Joints.b2JointDef)
package Engine.Dynamics.Joints {
import Engine.Dynamics.*;
public class b2JointDef {
public var collideConnected:Boolean;
public var body1:b2Body;
public var body2:b2Body;
public var userData;
public var type:int;
public function b2JointDef(){
type = b2Joint.e_unknownJoint;
userData = null;
body1 = null;
body2 = null;
collideConnected = false;
}
}
}//package Engine.Dynamics.Joints
Section 45
//b2JointNode (Engine.Dynamics.Joints.b2JointNode)
package Engine.Dynamics.Joints {
import Engine.Dynamics.*;
public class b2JointNode {
public var joint:b2Joint;
public var other:b2Body;
public var next:b2JointNode;
public var prev:b2JointNode;
}
}//package Engine.Dynamics.Joints
Section 46
//b2MouseJoint (Engine.Dynamics.Joints.b2MouseJoint)
package Engine.Dynamics.Joints {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
import Engine.Common.*;
public class b2MouseJoint extends b2Joint {
public var m_beta:Number;
public var m_target:b2Vec2;
public var m_impulse:b2Vec2;
public var m_ptpMass:b2Mat22;
public var m_localAnchor:b2Vec2;
private var K1:b2Mat22;
private var K2:b2Mat22;
private var K:b2Mat22;
public var m_gamma:Number;
public var m_C:b2Vec2;
public var m_maxForce:Number;
public function b2MouseJoint(_arg1:b2MouseJointDef){
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
m_localAnchor = new b2Vec2();
m_target = new b2Vec2();
m_impulse = new b2Vec2();
m_ptpMass = new b2Mat22();
m_C = new b2Vec2();
super(_arg1);
m_target.SetV(_arg1.target);
_local2 = (m_target.x - m_body2.m_position.x);
_local3 = (m_target.y - m_body2.m_position.y);
m_localAnchor.x = ((_local2 * m_body2.m_R.col1.x) + (_local3 * m_body2.m_R.col1.y));
m_localAnchor.y = ((_local2 * m_body2.m_R.col2.x) + (_local3 * m_body2.m_R.col2.y));
m_maxForce = _arg1.maxForce;
m_impulse.SetZero();
_local4 = m_body2.m_mass;
_local5 = ((2 * b2Settings.b2_pi) * _arg1.frequencyHz);
_local6 = (((2 * _local4) * _arg1.dampingRatio) * _local5);
_local7 = ((_local4 * _local5) * _local5);
m_gamma = (1 / (_local6 + (_arg1.timeStep * _local7)));
m_beta = ((_arg1.timeStep * _local7) / (_local6 + (_arg1.timeStep * _local7)));
}
override public function GetAnchor1():b2Vec2{
return (m_target);
}
override public function GetAnchor2():b2Vec2{
var _local1:b2Vec2;
_local1 = b2Math.b2MulMV(m_body2.m_R, m_localAnchor);
_local1.Add(m_body2.m_position);
return (_local1);
}
override public function PrepareVelocitySolver(){
var _local1:b2Body;
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
_local1 = m_body2;
_local2 = _local1.m_R;
_local3 = ((_local2.col1.x * m_localAnchor.x) + (_local2.col2.x * m_localAnchor.y));
_local4 = ((_local2.col1.y * m_localAnchor.x) + (_local2.col2.y * m_localAnchor.y));
_local5 = _local1.m_invMass;
_local6 = _local1.m_invI;
K1.col1.x = _local5;
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = _local5;
K2.col1.x = ((_local6 * _local4) * _local4);
K2.col2.x = ((-(_local6) * _local3) * _local4);
K2.col1.y = ((-(_local6) * _local3) * _local4);
K2.col2.y = ((_local6 * _local3) * _local3);
K.SetM(K1);
K.AddM(K2);
K.col1.x = (K.col1.x + m_gamma);
K.col2.y = (K.col2.y + m_gamma);
K.Invert(m_ptpMass);
m_C.x = ((_local1.m_position.x + _local3) - m_target.x);
m_C.y = ((_local1.m_position.y + _local4) - m_target.y);
_local1.m_angularVelocity = (_local1.m_angularVelocity * 0.98);
_local7 = m_impulse.x;
_local8 = m_impulse.y;
_local1.m_linearVelocity.x = (_local1.m_linearVelocity.x + (_local5 * _local7));
_local1.m_linearVelocity.y = (_local1.m_linearVelocity.y + (_local5 * _local8));
_local1.m_angularVelocity = (_local1.m_angularVelocity + (_local6 * ((_local3 * _local8) - (_local4 * _local7))));
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
var _local2:b2Vec2;
_local2 = new b2Vec2();
_local2.SetV(m_impulse);
_local2.Multiply(_arg1);
return (_local2);
}
override public function SolvePositionConstraints():Boolean{
return (true);
}
override public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
public function SetTarget(_arg1:b2Vec2){
m_body2.WakeUp();
m_target = _arg1;
}
override public function SolveVelocityConstraints(_arg1:b2StepInfo){
var _local2:b2Body;
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
_local2 = m_body2;
_local3 = _local2.m_R;
_local4 = ((_local3.col1.x * m_localAnchor.x) + (_local3.col2.x * m_localAnchor.y));
_local5 = ((_local3.col1.y * m_localAnchor.x) + (_local3.col2.y * m_localAnchor.y));
_local6 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local5));
_local7 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local4));
_local3 = m_ptpMass;
_local8 = ((_local6 + ((m_beta * _arg1.inv_dt) * m_C.x)) + (m_gamma * m_impulse.x));
_local9 = ((_local7 + ((m_beta * _arg1.inv_dt) * m_C.y)) + (m_gamma * m_impulse.y));
_local10 = -(((_local3.col1.x * _local8) + (_local3.col2.x * _local9)));
_local11 = -(((_local3.col1.y * _local8) + (_local3.col2.y * _local9)));
_local12 = m_impulse.x;
_local13 = m_impulse.y;
m_impulse.x = (m_impulse.x + _local10);
m_impulse.y = (m_impulse.y + _local11);
_local14 = m_impulse.Length();
if (_local14 > (_arg1.dt * m_maxForce)){
m_impulse.Multiply(((_arg1.dt * m_maxForce) / _local14));
};
_local10 = (m_impulse.x - _local12);
_local11 = (m_impulse.y - _local13);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local10));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local11));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local4 * _local11) - (_local5 * _local10))));
}
}
}//package Engine.Dynamics.Joints
Section 47
//b2MouseJointDef (Engine.Dynamics.Joints.b2MouseJointDef)
package Engine.Dynamics.Joints {
import Engine.Common.Math.*;
public class b2MouseJointDef extends b2JointDef {
public var frequencyHz:Number;
public var dampingRatio:Number;
public var maxForce:Number;
public var target:b2Vec2;
public var timeStep:Number;
public function b2MouseJointDef(){
target = new b2Vec2();
super();
type = b2Joint.e_mouseJoint;
maxForce = 0;
frequencyHz = 5;
dampingRatio = 0.7;
timeStep = (1 / 60);
}
}
}//package Engine.Dynamics.Joints
Section 48
//b2PrismaticJoint (Engine.Dynamics.Joints.b2PrismaticJoint)
package Engine.Dynamics.Joints {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
import Engine.Common.*;
public class b2PrismaticJoint extends b2Joint {
public var m_initialAngle:Number;
public var m_lowerTranslation:Number;
public var m_localXAxis1:b2Vec2;
public var m_enableLimit:Boolean;
public var m_maxMotorForce:Number;
public var m_angularMass:Number;
public var m_localYAxis1:b2Vec2;
public var m_linearImpulse:Number;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_motorMass:Number;
public var m_limitState:int;
public var m_linearMass:Number;
public var m_upperTranslation:Number;
public var m_angularImpulse:Number;
public var m_motorImpulse:Number;
public var m_motorJacobian:b2Jacobian;
public var m_limitImpulse:Number;
public var m_motorSpeed:Number;
public var m_enableMotor:Boolean;
public var m_limitPositionImpulse:Number;
public var m_linearJacobian:b2Jacobian;
public function b2PrismaticJoint(_arg1:b2PrismaticJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_localXAxis1 = new b2Vec2();
m_localYAxis1 = new b2Vec2();
m_linearJacobian = new b2Jacobian();
m_motorJacobian = new b2Jacobian();
super(_arg1);
_local2 = m_body1.m_R;
_local3 = (_arg1.anchorPoint.x - m_body1.m_position.x);
_local4 = (_arg1.anchorPoint.y - m_body1.m_position.y);
m_localAnchor1.Set(((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y)), ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y)));
_local2 = m_body2.m_R;
_local3 = (_arg1.anchorPoint.x - m_body2.m_position.x);
_local4 = (_arg1.anchorPoint.y - m_body2.m_position.y);
m_localAnchor2.Set(((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y)), ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y)));
_local2 = m_body1.m_R;
_local3 = _arg1.axis.x;
_local4 = _arg1.axis.y;
m_localXAxis1.Set(((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y)), ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y)));
m_localYAxis1.x = -(m_localXAxis1.y);
m_localYAxis1.y = m_localXAxis1.x;
m_initialAngle = (m_body2.m_rotation - m_body1.m_rotation);
m_linearJacobian.SetZero();
m_linearMass = 0;
m_linearImpulse = 0;
m_angularMass = 0;
m_angularImpulse = 0;
m_motorJacobian.SetZero();
m_motorMass = 0;
m_motorImpulse = 0;
m_limitImpulse = 0;
m_limitPositionImpulse = 0;
m_lowerTranslation = _arg1.lowerTranslation;
m_upperTranslation = _arg1.upperTranslation;
m_maxMotorForce = _arg1.motorForce;
m_motorSpeed = _arg1.motorSpeed;
m_enableLimit = _arg1.enableLimit;
m_enableMotor = _arg1.enableMotor;
}
override public function GetAnchor1():b2Vec2{
var _local1:b2Body;
var _local2:b2Vec2;
_local1 = m_body1;
_local2 = new b2Vec2();
_local2.SetV(m_localAnchor1);
_local2.MulM(_local1.m_R);
_local2.Add(_local1.m_position);
return (_local2);
}
override public function GetAnchor2():b2Vec2{
var _local1:b2Body;
var _local2:b2Vec2;
_local1 = m_body2;
_local2 = new b2Vec2();
_local2.SetV(m_localAnchor2);
_local2.MulM(_local1.m_R);
_local2.Add(_local1.m_position);
return (_local2);
}
override public function PrepareVelocitySolver(){
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
_local1 = m_body1;
_local2 = m_body2;
_local3 = _local1.m_R;
_local4 = ((_local3.col1.x * m_localAnchor1.x) + (_local3.col2.x * m_localAnchor1.y));
_local5 = ((_local3.col1.y * m_localAnchor1.x) + (_local3.col2.y * m_localAnchor1.y));
_local3 = _local2.m_R;
_local6 = ((_local3.col1.x * m_localAnchor2.x) + (_local3.col2.x * m_localAnchor2.y));
_local7 = ((_local3.col1.y * m_localAnchor2.x) + (_local3.col2.y * m_localAnchor2.y));
_local8 = _local1.m_invMass;
_local9 = _local2.m_invMass;
_local10 = _local1.m_invI;
_local11 = _local2.m_invI;
_local3 = _local1.m_R;
_local12 = ((_local3.col1.x * m_localYAxis1.x) + (_local3.col2.x * m_localYAxis1.y));
_local13 = ((_local3.col1.y * m_localYAxis1.x) + (_local3.col2.y * m_localYAxis1.y));
_local14 = ((_local2.m_position.x + _local6) - _local1.m_position.x);
_local15 = ((_local2.m_position.y + _local7) - _local1.m_position.y);
m_linearJacobian.linear1.x = -(_local12);
m_linearJacobian.linear1.y = -(_local13);
m_linearJacobian.linear2.x = _local12;
m_linearJacobian.linear2.y = _local13;
m_linearJacobian.angular1 = -(((_local14 * _local13) - (_local15 * _local12)));
m_linearJacobian.angular2 = ((_local6 * _local13) - (_local7 * _local12));
m_linearMass = (((_local8 + ((_local10 * m_linearJacobian.angular1) * m_linearJacobian.angular1)) + _local9) + ((_local11 * m_linearJacobian.angular2) * m_linearJacobian.angular2));
m_linearMass = (1 / m_linearMass);
m_angularMass = (1 / (_local10 + _local11));
if (((m_enableLimit) || (m_enableMotor))){
_local3 = _local1.m_R;
_local16 = ((_local3.col1.x * m_localXAxis1.x) + (_local3.col2.x * m_localXAxis1.y));
_local17 = ((_local3.col1.y * m_localXAxis1.x) + (_local3.col2.y * m_localXAxis1.y));
m_motorJacobian.linear1.x = -(_local16);
m_motorJacobian.linear1.y = -(_local17);
m_motorJacobian.linear2.x = _local16;
m_motorJacobian.linear2.y = _local17;
m_motorJacobian.angular1 = -(((_local14 * _local17) - (_local15 * _local16)));
m_motorJacobian.angular2 = ((_local6 * _local17) - (_local7 * _local16));
m_motorMass = (((_local8 + ((_local10 * m_motorJacobian.angular1) * m_motorJacobian.angular1)) + _local9) + ((_local11 * m_motorJacobian.angular2) * m_motorJacobian.angular2));
m_motorMass = (1 / m_motorMass);
if (m_enableLimit){
_local18 = (_local14 - _local4);
_local19 = (_local15 - _local5);
_local20 = ((_local16 * _local18) + (_local17 * _local19));
if (b2Math.b2Abs((m_upperTranslation - m_lowerTranslation)) < (2 * b2Settings.b2_linearSlop)){
m_limitState = e_equalLimits;
} else {
if (_local20 <= m_lowerTranslation){
if (m_limitState != e_atLowerLimit){
m_limitImpulse = 0;
};
m_limitState = e_atLowerLimit;
} else {
if (_local20 >= m_upperTranslation){
if (m_limitState != e_atUpperLimit){
m_limitImpulse = 0;
};
m_limitState = e_atUpperLimit;
} else {
m_limitState = e_inactiveLimit;
m_limitImpulse = 0;
};
};
};
};
};
if (m_enableMotor == false){
m_motorImpulse = 0;
};
if (m_enableLimit == false){
m_limitImpulse = 0;
};
if (b2World.s_enableWarmStarting){
_local21 = ((m_linearImpulse * m_linearJacobian.linear1.x) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.linear1.x));
_local22 = ((m_linearImpulse * m_linearJacobian.linear1.y) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.linear1.y));
_local23 = ((m_linearImpulse * m_linearJacobian.linear2.x) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.linear2.x));
_local24 = ((m_linearImpulse * m_linearJacobian.linear2.y) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.linear2.y));
_local25 = (((m_linearImpulse * m_linearJacobian.angular1) - m_angularImpulse) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.angular1));
_local26 = (((m_linearImpulse * m_linearJacobian.angular2) + m_angularImpulse) + ((m_motorImpulse + m_limitImpulse) * m_motorJacobian.angular2));
_local1.m_linearVelocity.x = (_local1.m_linearVelocity.x + (_local8 * _local21));
_local1.m_linearVelocity.y = (_local1.m_linearVelocity.y + (_local8 * _local22));
_local1.m_angularVelocity = (_local1.m_angularVelocity + (_local10 * _local25));
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local9 * _local23));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local9 * _local24));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local11 * _local26));
} else {
m_linearImpulse = 0;
m_angularImpulse = 0;
m_limitImpulse = 0;
m_motorImpulse = 0;
};
m_limitPositionImpulse = 0;
}
public function GetJointTranslation():Number{
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
_local1 = m_body1;
_local2 = m_body2;
_local3 = _local1.m_R;
_local4 = ((_local3.col1.x * m_localAnchor1.x) + (_local3.col2.x * m_localAnchor1.y));
_local5 = ((_local3.col1.y * m_localAnchor1.x) + (_local3.col2.y * m_localAnchor1.y));
_local3 = _local2.m_R;
_local6 = ((_local3.col1.x * m_localAnchor2.x) + (_local3.col2.x * m_localAnchor2.y));
_local7 = ((_local3.col1.y * m_localAnchor2.x) + (_local3.col2.y * m_localAnchor2.y));
_local8 = (_local1.m_position.x + _local4);
_local9 = (_local1.m_position.y + _local5);
_local10 = (_local2.m_position.x + _local6);
_local11 = (_local2.m_position.y + _local7);
_local12 = (_local10 - _local8);
_local13 = (_local11 - _local9);
_local3 = _local1.m_R;
_local14 = ((_local3.col1.x * m_localXAxis1.x) + (_local3.col2.x * m_localXAxis1.y));
_local15 = ((_local3.col1.y * m_localXAxis1.x) + (_local3.col2.y * m_localXAxis1.y));
_local16 = ((_local14 * _local12) + (_local15 * _local13));
return (_local16);
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
var _local2:Number;
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
_local2 = (_arg1 * m_limitImpulse);
_local3 = m_body1.m_R;
_local4 = (_local2 * ((_local3.col1.x * m_localXAxis1.x) + (_local3.col2.x * m_localXAxis1.y)));
_local5 = (_local2 * ((_local3.col1.y * m_localXAxis1.x) + (_local3.col2.y * m_localXAxis1.y)));
_local6 = (_local2 * ((_local3.col1.x * m_localYAxis1.x) + (_local3.col2.x * m_localYAxis1.y)));
_local7 = (_local2 * ((_local3.col1.y * m_localYAxis1.x) + (_local3.col2.y * m_localYAxis1.y)));
return (new b2Vec2((_local4 + _local6), (_local5 + _local7)));
}
override public function SolvePositionConstraints():Boolean{
var _local1:Number;
var _local2:Number;
var _local3:b2Body;
var _local4:b2Body;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:b2Mat22;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
_local3 = m_body1;
_local4 = m_body2;
_local5 = _local3.m_invMass;
_local6 = _local4.m_invMass;
_local7 = _local3.m_invI;
_local8 = _local4.m_invI;
_local9 = _local3.m_R;
_local10 = ((_local9.col1.x * m_localAnchor1.x) + (_local9.col2.x * m_localAnchor1.y));
_local11 = ((_local9.col1.y * m_localAnchor1.x) + (_local9.col2.y * m_localAnchor1.y));
_local9 = _local4.m_R;
_local12 = ((_local9.col1.x * m_localAnchor2.x) + (_local9.col2.x * m_localAnchor2.y));
_local13 = ((_local9.col1.y * m_localAnchor2.x) + (_local9.col2.y * m_localAnchor2.y));
_local14 = (_local3.m_position.x + _local10);
_local15 = (_local3.m_position.y + _local11);
_local16 = (_local4.m_position.x + _local12);
_local17 = (_local4.m_position.y + _local13);
_local18 = (_local16 - _local14);
_local19 = (_local17 - _local15);
_local9 = _local3.m_R;
_local20 = ((_local9.col1.x * m_localYAxis1.x) + (_local9.col2.x * m_localYAxis1.y));
_local21 = ((_local9.col1.y * m_localYAxis1.x) + (_local9.col2.y * m_localYAxis1.y));
_local22 = ((_local20 * _local18) + (_local21 * _local19));
_local22 = b2Math.b2Clamp(_local22, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local23 = (-(m_linearMass) * _local22);
_local3.m_position.x = (_local3.m_position.x + ((_local5 * _local23) * m_linearJacobian.linear1.x));
_local3.m_position.y = (_local3.m_position.y + ((_local5 * _local23) * m_linearJacobian.linear1.y));
_local3.m_rotation = (_local3.m_rotation + ((_local7 * _local23) * m_linearJacobian.angular1));
_local4.m_position.x = (_local4.m_position.x + ((_local6 * _local23) * m_linearJacobian.linear2.x));
_local4.m_position.y = (_local4.m_position.y + ((_local6 * _local23) * m_linearJacobian.linear2.y));
_local4.m_rotation = (_local4.m_rotation + ((_local8 * _local23) * m_linearJacobian.angular2));
_local24 = b2Math.b2Abs(_local22);
_local25 = ((_local4.m_rotation - _local3.m_rotation) - m_initialAngle);
_local25 = b2Math.b2Clamp(_local25, -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
_local26 = (-(m_angularMass) * _local25);
_local3.m_rotation = (_local3.m_rotation - (_local3.m_invI * _local26));
_local3.m_R.Set(_local3.m_rotation);
_local4.m_rotation = (_local4.m_rotation + (_local4.m_invI * _local26));
_local4.m_R.Set(_local4.m_rotation);
_local27 = b2Math.b2Abs(_local25);
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local9 = _local3.m_R;
_local10 = ((_local9.col1.x * m_localAnchor1.x) + (_local9.col2.x * m_localAnchor1.y));
_local11 = ((_local9.col1.y * m_localAnchor1.x) + (_local9.col2.y * m_localAnchor1.y));
_local9 = _local4.m_R;
_local12 = ((_local9.col1.x * m_localAnchor2.x) + (_local9.col2.x * m_localAnchor2.y));
_local13 = ((_local9.col1.y * m_localAnchor2.x) + (_local9.col2.y * m_localAnchor2.y));
_local14 = (_local3.m_position.x + _local10);
_local15 = (_local3.m_position.y + _local11);
_local16 = (_local4.m_position.x + _local12);
_local17 = (_local4.m_position.y + _local13);
_local18 = (_local16 - _local14);
_local19 = (_local17 - _local15);
_local9 = _local3.m_R;
_local28 = ((_local9.col1.x * m_localXAxis1.x) + (_local9.col2.x * m_localXAxis1.y));
_local29 = ((_local9.col1.y * m_localXAxis1.x) + (_local9.col2.y * m_localXAxis1.y));
_local30 = ((_local28 * _local18) + (_local29 * _local19));
_local31 = 0;
if (m_limitState == e_equalLimits){
_local1 = b2Math.b2Clamp(_local30, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local31 = (-(m_motorMass) * _local1);
_local24 = b2Math.b2Max(_local24, b2Math.b2Abs(_local25));
} else {
if (m_limitState == e_atLowerLimit){
_local1 = (_local30 - m_lowerTranslation);
_local24 = b2Math.b2Max(_local24, -(_local1));
_local1 = b2Math.b2Clamp((_local1 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local31 = (-(m_motorMass) * _local1);
_local2 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Max((m_limitPositionImpulse + _local31), 0);
_local31 = (m_limitPositionImpulse - _local2);
} else {
if (m_limitState == e_atUpperLimit){
_local1 = (_local30 - m_upperTranslation);
_local24 = b2Math.b2Max(_local24, _local1);
_local1 = b2Math.b2Clamp((_local1 - b2Settings.b2_linearSlop), 0, b2Settings.b2_maxLinearCorrection);
_local31 = (-(m_motorMass) * _local1);
_local2 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Min((m_limitPositionImpulse + _local31), 0);
_local31 = (m_limitPositionImpulse - _local2);
};
};
};
_local3.m_position.x = (_local3.m_position.x + ((_local5 * _local31) * m_motorJacobian.linear1.x));
_local3.m_position.y = (_local3.m_position.y + ((_local5 * _local31) * m_motorJacobian.linear1.y));
_local3.m_rotation = (_local3.m_rotation + ((_local7 * _local31) * m_motorJacobian.angular1));
_local3.m_R.Set(_local3.m_rotation);
_local4.m_position.x = (_local4.m_position.x + ((_local6 * _local31) * m_motorJacobian.linear2.x));
_local4.m_position.y = (_local4.m_position.y + ((_local6 * _local31) * m_motorJacobian.linear2.y));
_local4.m_rotation = (_local4.m_rotation + ((_local8 * _local31) * m_motorJacobian.angular2));
_local4.m_R.Set(_local4.m_rotation);
};
return ((((_local24 <= b2Settings.b2_linearSlop)) && ((_local27 <= b2Settings.b2_angularSlop))));
}
public function GetJointSpeed():Number{
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:b2Vec2;
var _local17:b2Vec2;
var _local18:Number;
var _local19:Number;
var _local20:Number;
_local1 = m_body1;
_local2 = m_body2;
_local3 = _local1.m_R;
_local4 = ((_local3.col1.x * m_localAnchor1.x) + (_local3.col2.x * m_localAnchor1.y));
_local5 = ((_local3.col1.y * m_localAnchor1.x) + (_local3.col2.y * m_localAnchor1.y));
_local3 = _local2.m_R;
_local6 = ((_local3.col1.x * m_localAnchor2.x) + (_local3.col2.x * m_localAnchor2.y));
_local7 = ((_local3.col1.y * m_localAnchor2.x) + (_local3.col2.y * m_localAnchor2.y));
_local8 = (_local1.m_position.x + _local4);
_local9 = (_local1.m_position.y + _local5);
_local10 = (_local2.m_position.x + _local6);
_local11 = (_local2.m_position.y + _local7);
_local12 = (_local10 - _local8);
_local13 = (_local11 - _local9);
_local3 = _local1.m_R;
_local14 = ((_local3.col1.x * m_localXAxis1.x) + (_local3.col2.x * m_localXAxis1.y));
_local15 = ((_local3.col1.y * m_localXAxis1.x) + (_local3.col2.y * m_localXAxis1.y));
_local16 = _local1.m_linearVelocity;
_local17 = _local2.m_linearVelocity;
_local18 = _local1.m_angularVelocity;
_local19 = _local2.m_angularVelocity;
_local20 = (((_local12 * (-(_local18) * _local15)) + (_local13 * (_local18 * _local14))) + ((_local14 * (((_local17.x + (-(_local19) * _local7)) - _local16.x) - (-(_local18) * _local5))) + (_local15 * (((_local17.y + (_local19 * _local6)) - _local16.y) - (_local18 * _local4)))));
return (_local20);
}
public function SetMotorSpeed(_arg1:Number){
m_motorSpeed = _arg1;
}
public function GetMotorForce(_arg1:Number):Number{
return ((_arg1 * m_motorImpulse));
}
public function SetMotorForce(_arg1:Number){
m_maxMotorForce = _arg1;
}
override public function GetReactionTorque(_arg1:Number):Number{
return ((_arg1 * m_angularImpulse));
}
override public function SolveVelocityConstraints(_arg1:b2StepInfo){
var _local2:b2Body;
var _local3:b2Body;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:*;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
_local2 = m_body1;
_local3 = m_body2;
_local4 = _local2.m_invMass;
_local5 = _local3.m_invMass;
_local6 = _local2.m_invI;
_local7 = _local3.m_invI;
_local9 = m_linearJacobian.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity);
_local10 = (-(m_linearMass) * _local9);
m_linearImpulse = (m_linearImpulse + _local10);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local4 * _local10) * m_linearJacobian.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local4 * _local10) * m_linearJacobian.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local6 * _local10) * m_linearJacobian.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local5 * _local10) * m_linearJacobian.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local5 * _local10) * m_linearJacobian.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local7 * _local10) * m_linearJacobian.angular2));
_local11 = (_local3.m_angularVelocity - _local2.m_angularVelocity);
_local12 = (-(m_angularMass) * _local11);
m_angularImpulse = (m_angularImpulse + _local12);
_local2.m_angularVelocity = (_local2.m_angularVelocity - (_local6 * _local12));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local7 * _local12));
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
_local13 = (m_motorJacobian.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity) - m_motorSpeed);
_local14 = (-(m_motorMass) * _local13);
_local15 = m_motorImpulse;
m_motorImpulse = b2Math.b2Clamp((m_motorImpulse + _local14), (-(_arg1.dt) * m_maxMotorForce), (_arg1.dt * m_maxMotorForce));
_local14 = (m_motorImpulse - _local15);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local4 * _local14) * m_motorJacobian.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local4 * _local14) * m_motorJacobian.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local6 * _local14) * m_motorJacobian.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local5 * _local14) * m_motorJacobian.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local5 * _local14) * m_motorJacobian.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local7 * _local14) * m_motorJacobian.angular2));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local16 = m_motorJacobian.Compute(_local2.m_linearVelocity, _local2.m_angularVelocity, _local3.m_linearVelocity, _local3.m_angularVelocity);
_local17 = (-(m_motorMass) * _local16);
if (m_limitState == e_equalLimits){
m_limitImpulse = (m_limitImpulse + _local17);
} else {
if (m_limitState == e_atLowerLimit){
_local8 = m_limitImpulse;
m_limitImpulse = b2Math.b2Max((m_limitImpulse + _local17), 0);
_local17 = (m_limitImpulse - _local8);
} else {
if (m_limitState == e_atUpperLimit){
_local8 = m_limitImpulse;
m_limitImpulse = b2Math.b2Min((m_limitImpulse + _local17), 0);
_local17 = (m_limitImpulse - _local8);
};
};
};
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + ((_local4 * _local17) * m_motorJacobian.linear1.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + ((_local4 * _local17) * m_motorJacobian.linear1.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + ((_local6 * _local17) * m_motorJacobian.angular1));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + ((_local5 * _local17) * m_motorJacobian.linear2.x));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + ((_local5 * _local17) * m_motorJacobian.linear2.y));
_local3.m_angularVelocity = (_local3.m_angularVelocity + ((_local7 * _local17) * m_motorJacobian.angular2));
};
}
}
}//package Engine.Dynamics.Joints
Section 49
//b2PrismaticJointDef (Engine.Dynamics.Joints.b2PrismaticJointDef)
package Engine.Dynamics.Joints {
import Engine.Common.Math.*;
public class b2PrismaticJointDef extends b2JointDef {
public var motorSpeed:Number;
public var anchorPoint:b2Vec2;
public var axis:b2Vec2;
public var upperTranslation:Number;
public var lowerTranslation:Number;
public var enableMotor:Boolean;
public var motorForce:Number;
public var enableLimit:Boolean;
public function b2PrismaticJointDef(){
type = b2Joint.e_prismaticJoint;
anchorPoint = new b2Vec2(0, 0);
axis = new b2Vec2(0, 0);
lowerTranslation = 0;
upperTranslation = 0;
motorForce = 0;
motorSpeed = 0;
enableLimit = false;
enableMotor = false;
}
}
}//package Engine.Dynamics.Joints
Section 50
//b2PulleyJoint (Engine.Dynamics.Joints.b2PulleyJoint)
package Engine.Dynamics.Joints {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
import Engine.Common.*;
public class b2PulleyJoint extends b2Joint {
public var m_ground:b2Body;
public var m_maxLength2:Number;
public var m_limitState1:int;
public var m_maxLength1:Number;
public var m_pulleyImpulse:Number;
public var m_limitPositionImpulse1:Number;
public var m_constant:Number;
public var m_ratio:Number;
public var m_groundAnchor1:b2Vec2;
public var m_groundAnchor2:b2Vec2;
public var m_limitPositionImpulse2:Number;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
public var m_limitState2:int;
public var m_limitMass2:Number;
public var m_limitMass1:Number;
public var m_limitImpulse2:Number;
public var m_u1:b2Vec2;
public var m_u2:b2Vec2;
public var m_limitImpulse1:Number;
public var m_pulleyMass:Number;
public static var b2_minPulleyLength:Number = 1;
public function b2PulleyJoint(_arg1:b2PulleyJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
m_groundAnchor1 = new b2Vec2();
m_groundAnchor2 = new b2Vec2();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_u1 = new b2Vec2();
m_u2 = new b2Vec2();
super(_arg1);
m_ground = m_body1.m_world.m_groundBody;
m_groundAnchor1.x = (_arg1.groundPoint1.x - m_ground.m_position.x);
m_groundAnchor1.y = (_arg1.groundPoint1.y - m_ground.m_position.y);
m_groundAnchor2.x = (_arg1.groundPoint2.x - m_ground.m_position.x);
m_groundAnchor2.y = (_arg1.groundPoint2.y - m_ground.m_position.y);
_local2 = m_body1.m_R;
_local3 = (_arg1.anchorPoint1.x - m_body1.m_position.x);
_local4 = (_arg1.anchorPoint1.y - m_body1.m_position.y);
m_localAnchor1.x = ((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y));
m_localAnchor1.y = ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y));
_local2 = m_body2.m_R;
_local3 = (_arg1.anchorPoint2.x - m_body2.m_position.x);
_local4 = (_arg1.anchorPoint2.y - m_body2.m_position.y);
m_localAnchor2.x = ((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y));
m_localAnchor2.y = ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y));
m_ratio = _arg1.ratio;
_local3 = (_arg1.groundPoint1.x - _arg1.anchorPoint1.x);
_local4 = (_arg1.groundPoint1.y - _arg1.anchorPoint1.y);
_local5 = Math.sqrt(((_local3 * _local3) + (_local4 * _local4)));
_local3 = (_arg1.groundPoint2.x - _arg1.anchorPoint2.x);
_local4 = (_arg1.groundPoint2.y - _arg1.anchorPoint2.y);
_local6 = Math.sqrt(((_local3 * _local3) + (_local4 * _local4)));
_local7 = b2Math.b2Max((0.5 * b2_minPulleyLength), _local5);
_local8 = b2Math.b2Max((0.5 * b2_minPulleyLength), _local6);
m_constant = (_local7 + (m_ratio * _local8));
m_maxLength1 = b2Math.b2Clamp(_arg1.maxLength1, _local7, (m_constant - (m_ratio * b2_minPulleyLength)));
m_maxLength2 = b2Math.b2Clamp(_arg1.maxLength2, _local8, ((m_constant - b2_minPulleyLength) / m_ratio));
m_pulleyImpulse = 0;
m_limitImpulse1 = 0;
m_limitImpulse2 = 0;
}
public function GetLength1():Number{
var _local1:b2Mat22;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local1 = m_body1.m_R;
_local2 = (m_body1.m_position.x + ((_local1.col1.x * m_localAnchor1.x) + (_local1.col2.x * m_localAnchor1.y)));
_local3 = (m_body1.m_position.y + ((_local1.col1.y * m_localAnchor1.x) + (_local1.col2.y * m_localAnchor1.y)));
_local4 = (_local2 - (m_ground.m_position.x + m_groundAnchor1.x));
_local5 = (_local3 - (m_ground.m_position.y + m_groundAnchor1.y));
return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5))));
}
override public function GetAnchor1():b2Vec2{
var _local1:b2Mat22;
_local1 = m_body1.m_R;
return (new b2Vec2((m_body1.m_position.x + ((_local1.col1.x * m_localAnchor1.x) + (_local1.col2.x * m_localAnchor1.y))), (m_body1.m_position.y + ((_local1.col1.y * m_localAnchor1.x) + (_local1.col2.y * m_localAnchor1.y)))));
}
override public function GetAnchor2():b2Vec2{
var _local1:b2Mat22;
_local1 = m_body2.m_R;
return (new b2Vec2((m_body2.m_position.x + ((_local1.col1.x * m_localAnchor2.x) + (_local1.col2.x * m_localAnchor2.y))), (m_body2.m_position.y + ((_local1.col1.y * m_localAnchor2.x) + (_local1.col2.y * m_localAnchor2.y)))));
}
override public function PrepareVelocitySolver(){
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
_local1 = m_body1;
_local2 = m_body2;
_local3 = _local1.m_R;
_local4 = ((_local3.col1.x * m_localAnchor1.x) + (_local3.col2.x * m_localAnchor1.y));
_local5 = ((_local3.col1.y * m_localAnchor1.x) + (_local3.col2.y * m_localAnchor1.y));
_local3 = _local2.m_R;
_local6 = ((_local3.col1.x * m_localAnchor2.x) + (_local3.col2.x * m_localAnchor2.y));
_local7 = ((_local3.col1.y * m_localAnchor2.x) + (_local3.col2.y * m_localAnchor2.y));
_local8 = (_local1.m_position.x + _local4);
_local9 = (_local1.m_position.y + _local5);
_local10 = (_local2.m_position.x + _local6);
_local11 = (_local2.m_position.y + _local7);
_local12 = (m_ground.m_position.x + m_groundAnchor1.x);
_local13 = (m_ground.m_position.y + m_groundAnchor1.y);
_local14 = (m_ground.m_position.x + m_groundAnchor2.x);
_local15 = (m_ground.m_position.y + m_groundAnchor2.y);
m_u1.Set((_local8 - _local12), (_local9 - _local13));
m_u2.Set((_local10 - _local14), (_local11 - _local15));
_local16 = m_u1.Length();
_local17 = m_u2.Length();
if (_local16 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / _local16));
} else {
m_u1.SetZero();
};
if (_local17 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / _local17));
} else {
m_u2.SetZero();
};
if (_local16 < m_maxLength1){
m_limitState1 = e_inactiveLimit;
m_limitImpulse1 = 0;
} else {
m_limitState1 = e_atUpperLimit;
m_limitPositionImpulse1 = 0;
};
if (_local17 < m_maxLength2){
m_limitState2 = e_inactiveLimit;
m_limitImpulse2 = 0;
} else {
m_limitState2 = e_atUpperLimit;
m_limitPositionImpulse2 = 0;
};
_local18 = ((_local4 * m_u1.y) - (_local5 * m_u1.x));
_local19 = ((_local6 * m_u2.y) - (_local7 * m_u2.x));
m_limitMass1 = (_local1.m_invMass + ((_local1.m_invI * _local18) * _local18));
m_limitMass2 = (_local2.m_invMass + ((_local2.m_invI * _local19) * _local19));
m_pulleyMass = (m_limitMass1 + ((m_ratio * m_ratio) * m_limitMass2));
m_limitMass1 = (1 / m_limitMass1);
m_limitMass2 = (1 / m_limitMass2);
m_pulleyMass = (1 / m_pulleyMass);
_local20 = ((-(m_pulleyImpulse) - m_limitImpulse1) * m_u1.x);
_local21 = ((-(m_pulleyImpulse) - m_limitImpulse1) * m_u1.y);
_local22 = (((-(m_ratio) * m_pulleyImpulse) - m_limitImpulse2) * m_u2.x);
_local23 = (((-(m_ratio) * m_pulleyImpulse) - m_limitImpulse2) * m_u2.y);
_local1.m_linearVelocity.x = (_local1.m_linearVelocity.x + (_local1.m_invMass * _local20));
_local1.m_linearVelocity.y = (_local1.m_linearVelocity.y + (_local1.m_invMass * _local21));
_local1.m_angularVelocity = (_local1.m_angularVelocity + (_local1.m_invI * ((_local4 * _local21) - (_local5 * _local20))));
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local22));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local23));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local6 * _local23) - (_local7 * _local22))));
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
return (new b2Vec2());
}
override public function SolvePositionConstraints():Boolean{
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
_local1 = m_body1;
_local2 = m_body2;
_local4 = (m_ground.m_position.x + m_groundAnchor1.x);
_local5 = (m_ground.m_position.y + m_groundAnchor1.y);
_local6 = (m_ground.m_position.x + m_groundAnchor2.x);
_local7 = (m_ground.m_position.y + m_groundAnchor2.y);
_local21 = 0;
_local3 = _local1.m_R;
_local8 = ((_local3.col1.x * m_localAnchor1.x) + (_local3.col2.x * m_localAnchor1.y));
_local9 = ((_local3.col1.y * m_localAnchor1.x) + (_local3.col2.y * m_localAnchor1.y));
_local3 = _local2.m_R;
_local10 = ((_local3.col1.x * m_localAnchor2.x) + (_local3.col2.x * m_localAnchor2.y));
_local11 = ((_local3.col1.y * m_localAnchor2.x) + (_local3.col2.y * m_localAnchor2.y));
_local12 = (_local1.m_position.x + _local8);
_local13 = (_local1.m_position.y + _local9);
_local14 = (_local2.m_position.x + _local10);
_local15 = (_local2.m_position.y + _local11);
m_u1.Set((_local12 - _local4), (_local13 - _local5));
m_u2.Set((_local14 - _local6), (_local15 - _local7));
_local16 = m_u1.Length();
_local17 = m_u2.Length();
if (_local16 > b2Settings.b2_linearSlop){
m_u1.Multiply((1 / _local16));
} else {
m_u1.SetZero();
};
if (_local17 > b2Settings.b2_linearSlop){
m_u2.Multiply((1 / _local17));
} else {
m_u2.SetZero();
};
_local18 = ((m_constant - _local16) - (m_ratio * _local17));
_local21 = b2Math.b2Max(_local21, Math.abs(_local18));
_local18 = b2Math.b2Clamp(_local18, -(b2Settings.b2_maxLinearCorrection), b2Settings.b2_maxLinearCorrection);
_local19 = (-(m_pulleyMass) * _local18);
_local12 = (-(_local19) * m_u1.x);
_local13 = (-(_local19) * m_u1.y);
_local14 = ((-(m_ratio) * _local19) * m_u2.x);
_local15 = ((-(m_ratio) * _local19) * m_u2.y);
_local1.m_position.x = (_local1.m_position.x + (_local1.m_invMass * _local12));
_local1.m_position.y = (_local1.m_position.y + (_local1.m_invMass * _local13));
_local1.m_rotation = (_local1.m_rotation + (_local1.m_invI * ((_local8 * _local13) - (_local9 * _local12))));
_local2.m_position.x = (_local2.m_position.x + (_local2.m_invMass * _local14));
_local2.m_position.y = (_local2.m_position.y + (_local2.m_invMass * _local15));
_local2.m_rotation = (_local2.m_rotation + (_local2.m_invI * ((_local10 * _local15) - (_local11 * _local14))));
_local1.m_R.Set(_local1.m_rotation);
_local2.m_R.Set(_local2.m_rotation);
if (m_limitState1 == e_atUpperLimit){
_local3 = _local1.m_R;
_local8 = ((_local3.col1.x * m_localAnchor1.x) + (_local3.col2.x * m_localAnchor1.y));
_local9 = ((_local3.col1.y * m_localAnchor1.x) + (_local3.col2.y * m_localAnchor1.y));
_local12 = (_local1.m_position.x + _local8);
_local13 = (_local1.m_position.y + _local9);
m_u1.Set((_local12 - _local4), (_local13 - _local5));
_local16 = m_u1.Length();
if (_local16 > b2Settings.b2_linearSlop){
m_u1.x = (m_u1.x * (1 / _local16));
m_u1.y = (m_u1.y * (1 / _local16));
} else {
m_u1.SetZero();
};
_local18 = (m_maxLength1 - _local16);
_local21 = b2Math.b2Max(_local21, -(_local18));
_local18 = b2Math.b2Clamp((_local18 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local19 = (-(m_limitMass1) * _local18);
_local20 = m_limitPositionImpulse1;
m_limitPositionImpulse1 = b2Math.b2Max(0, (m_limitPositionImpulse1 + _local19));
_local19 = (m_limitPositionImpulse1 - _local20);
_local12 = (-(_local19) * m_u1.x);
_local13 = (-(_local19) * m_u1.y);
_local1.m_position.x = (_local1.m_position.x + (_local1.m_invMass * _local12));
_local1.m_position.y = (_local1.m_position.y + (_local1.m_invMass * _local13));
_local1.m_rotation = (_local1.m_rotation + (_local1.m_invI * ((_local8 * _local13) - (_local9 * _local12))));
_local1.m_R.Set(_local1.m_rotation);
};
if (m_limitState2 == e_atUpperLimit){
_local3 = _local2.m_R;
_local10 = ((_local3.col1.x * m_localAnchor2.x) + (_local3.col2.x * m_localAnchor2.y));
_local11 = ((_local3.col1.y * m_localAnchor2.x) + (_local3.col2.y * m_localAnchor2.y));
_local14 = (_local2.m_position.x + _local10);
_local15 = (_local2.m_position.y + _local11);
m_u2.Set((_local14 - _local6), (_local15 - _local7));
_local17 = m_u2.Length();
if (_local17 > b2Settings.b2_linearSlop){
m_u2.x = (m_u2.x * (1 / _local17));
m_u2.y = (m_u2.y * (1 / _local17));
} else {
m_u2.SetZero();
};
_local18 = (m_maxLength2 - _local17);
_local21 = b2Math.b2Max(_local21, -(_local18));
_local18 = b2Math.b2Clamp((_local18 + b2Settings.b2_linearSlop), -(b2Settings.b2_maxLinearCorrection), 0);
_local19 = (-(m_limitMass2) * _local18);
_local20 = m_limitPositionImpulse2;
m_limitPositionImpulse2 = b2Math.b2Max(0, (m_limitPositionImpulse2 + _local19));
_local19 = (m_limitPositionImpulse2 - _local20);
_local14 = (-(_local19) * m_u2.x);
_local15 = (-(_local19) * m_u2.y);
_local2.m_position.x = (_local2.m_position.x + (_local2.m_invMass * _local14));
_local2.m_position.y = (_local2.m_position.y + (_local2.m_invMass * _local15));
_local2.m_rotation = (_local2.m_rotation + (_local2.m_invI * ((_local10 * _local15) - (_local11 * _local14))));
_local2.m_R.Set(_local2.m_rotation);
};
return ((_local21 < b2Settings.b2_linearSlop));
}
public function GetGroundPoint1():b2Vec2{
return (new b2Vec2((m_ground.m_position.x + m_groundAnchor1.x), (m_ground.m_position.y + m_groundAnchor1.y)));
}
public function GetGroundPoint2():b2Vec2{
return (new b2Vec2((m_ground.m_position.x + m_groundAnchor2.x), (m_ground.m_position.y + m_groundAnchor2.y)));
}
override public function GetReactionTorque(_arg1:Number):Number{
return (0);
}
public function GetRatio():Number{
return (m_ratio);
}
public function GetLength2():Number{
var _local1:b2Mat22;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
_local1 = m_body2.m_R;
_local2 = (m_body2.m_position.x + ((_local1.col1.x * m_localAnchor2.x) + (_local1.col2.x * m_localAnchor2.y)));
_local3 = (m_body2.m_position.y + ((_local1.col1.y * m_localAnchor2.x) + (_local1.col2.y * m_localAnchor2.y)));
_local4 = (_local2 - (m_ground.m_position.x + m_groundAnchor2.x));
_local5 = (_local3 - (m_ground.m_position.y + m_groundAnchor2.y));
return (Math.sqrt(((_local4 * _local4) + (_local5 * _local5))));
}
override public function SolveVelocityConstraints(_arg1:b2StepInfo){
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Mat22;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
_local2 = m_body1;
_local3 = m_body2;
_local4 = _local2.m_R;
_local5 = ((_local4.col1.x * m_localAnchor1.x) + (_local4.col2.x * m_localAnchor1.y));
_local6 = ((_local4.col1.y * m_localAnchor1.x) + (_local4.col2.y * m_localAnchor1.y));
_local4 = _local3.m_R;
_local7 = ((_local4.col1.x * m_localAnchor2.x) + (_local4.col2.x * m_localAnchor2.y));
_local8 = ((_local4.col1.y * m_localAnchor2.x) + (_local4.col2.y * m_localAnchor2.y));
_local9 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local6));
_local10 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local5));
_local11 = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local8));
_local12 = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local7));
_local17 = (-(((m_u1.x * _local9) + (m_u1.y * _local10))) - (m_ratio * ((m_u2.x * _local11) + (m_u2.y * _local12))));
_local18 = (-(m_pulleyMass) * _local17);
m_pulleyImpulse = (m_pulleyImpulse + _local18);
_local13 = (-(_local18) * m_u1.x);
_local14 = (-(_local18) * m_u1.y);
_local15 = ((-(m_ratio) * _local18) * m_u2.x);
_local16 = ((-(m_ratio) * _local18) * m_u2.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local13));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local14));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local14) - (_local6 * _local13))));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local15));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local16));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local7 * _local16) - (_local8 * _local15))));
if (m_limitState1 == e_atUpperLimit){
_local9 = (_local2.m_linearVelocity.x + (-(_local2.m_angularVelocity) * _local6));
_local10 = (_local2.m_linearVelocity.y + (_local2.m_angularVelocity * _local5));
_local17 = -(((m_u1.x * _local9) + (m_u1.y * _local10)));
_local18 = (-(m_limitMass1) * _local17);
_local19 = m_limitImpulse1;
m_limitImpulse1 = b2Math.b2Max(0, (m_limitImpulse1 + _local18));
_local18 = (m_limitImpulse1 - _local19);
_local13 = (-(_local18) * m_u1.x);
_local14 = (-(_local18) * m_u1.y);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local2.m_invMass * _local13));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local2.m_invMass * _local14));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local2.m_invI * ((_local5 * _local14) - (_local6 * _local13))));
};
if (m_limitState2 == e_atUpperLimit){
_local11 = (_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local8));
_local12 = (_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local7));
_local17 = -(((m_u2.x * _local11) + (m_u2.y * _local12)));
_local18 = (-(m_limitMass2) * _local17);
_local19 = m_limitImpulse2;
m_limitImpulse2 = b2Math.b2Max(0, (m_limitImpulse2 + _local18));
_local18 = (m_limitImpulse2 - _local19);
_local15 = (-(_local18) * m_u2.x);
_local16 = (-(_local18) * m_u2.y);
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local15));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local16));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local7 * _local16) - (_local8 * _local15))));
};
}
}
}//package Engine.Dynamics.Joints
Section 51
//b2PulleyJointDef (Engine.Dynamics.Joints.b2PulleyJointDef)
package Engine.Dynamics.Joints {
import Engine.Common.Math.*;
public class b2PulleyJointDef extends b2JointDef {
public var groundPoint1:b2Vec2;
public var groundPoint2:b2Vec2;
public var ratio:Number;
public var maxLength1:Number;
public var maxLength2:Number;
public var anchorPoint1:b2Vec2;
public var anchorPoint2:b2Vec2;
public function b2PulleyJointDef(){
groundPoint1 = new b2Vec2();
groundPoint2 = new b2Vec2();
anchorPoint1 = new b2Vec2();
anchorPoint2 = new b2Vec2();
super();
type = b2Joint.e_pulleyJoint;
groundPoint1.Set(-1, 1);
groundPoint2.Set(1, 1);
anchorPoint1.Set(-1, 0);
anchorPoint2.Set(1, 0);
maxLength1 = (0.5 * b2PulleyJoint.b2_minPulleyLength);
maxLength2 = (0.5 * b2PulleyJoint.b2_minPulleyLength);
ratio = 1;
collideConnected = true;
}
}
}//package Engine.Dynamics.Joints
Section 52
//b2RevoluteJoint (Engine.Dynamics.Joints.b2RevoluteJoint)
package Engine.Dynamics.Joints {
import Engine.Dynamics.*;
import Engine.Common.Math.*;
import Engine.Common.*;
public class b2RevoluteJoint extends b2Joint {
public var m_intialAngle:Number;
public var m_enableLimit:Boolean;
public var m_limitState:int;
public var m_ptpMass:b2Mat22;
public var m_motorMass:Number;
public var m_localAnchor1:b2Vec2;
public var m_localAnchor2:b2Vec2;
private var K1:b2Mat22;
private var K2:b2Mat22;
private var K3:b2Mat22;
private var K:b2Mat22;
public var m_limitImpulse:Number;
public var m_motorImpulse:Number;
public var m_enableMotor:Boolean;
public var m_lowerAngle:Number;
public var m_limitPositionImpulse:Number;
public var m_maxMotorTorque:Number;
public var m_upperAngle:Number;
public var m_motorSpeed:Number;
public var m_ptpImpulse:b2Vec2;
static var tImpulse:b2Vec2 = new b2Vec2();
public function b2RevoluteJoint(_arg1:b2RevoluteJointDef){
var _local2:b2Mat22;
var _local3:Number;
var _local4:Number;
K = new b2Mat22();
K1 = new b2Mat22();
K2 = new b2Mat22();
K3 = new b2Mat22();
m_localAnchor1 = new b2Vec2();
m_localAnchor2 = new b2Vec2();
m_ptpImpulse = new b2Vec2();
m_ptpMass = new b2Mat22();
super(_arg1);
_local2 = m_body1.m_R;
_local3 = (_arg1.anchorPoint.x - m_body1.m_position.x);
_local4 = (_arg1.anchorPoint.y - m_body1.m_position.y);
m_localAnchor1.x = ((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y));
m_localAnchor1.y = ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y));
_local2 = m_body2.m_R;
_local3 = (_arg1.anchorPoint.x - m_body2.m_position.x);
_local4 = (_arg1.anchorPoint.y - m_body2.m_position.y);
m_localAnchor2.x = ((_local3 * _local2.col1.x) + (_local4 * _local2.col1.y));
m_localAnchor2.y = ((_local3 * _local2.col2.x) + (_local4 * _local2.col2.y));
m_intialAngle = (m_body2.m_rotation - m_body1.m_rotation);
m_ptpImpulse.Set(0, 0);
m_motorImpulse = 0;
m_limitImpulse = 0;
m_limitPositionImpulse = 0;
m_lowerAngle = _arg1.lowerAngle;
m_upperAngle = _arg1.upperAngle;
m_maxMotorTorque = _arg1.motorTorque;
m_motorSpeed = _arg1.motorSpeed;
m_enableLimit = _arg1.enableLimit;
m_enableMotor = _arg1.enableMotor;
}
override public function GetAnchor1():b2Vec2{
var _local1:b2Mat22;
_local1 = m_body1.m_R;
return (new b2Vec2((m_body1.m_position.x + ((_local1.col1.x * m_localAnchor1.x) + (_local1.col2.x * m_localAnchor1.y))), (m_body1.m_position.y + ((_local1.col1.y * m_localAnchor1.x) + (_local1.col2.y * m_localAnchor1.y)))));
}
override public function GetAnchor2():b2Vec2{
var _local1:b2Mat22;
_local1 = m_body2.m_R;
return (new b2Vec2((m_body2.m_position.x + ((_local1.col1.x * m_localAnchor2.x) + (_local1.col2.x * m_localAnchor2.y))), (m_body2.m_position.y + ((_local1.col1.y * m_localAnchor2.x) + (_local1.col2.y * m_localAnchor2.y)))));
}
override public function PrepareVelocitySolver(){
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2Mat22;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
_local1 = m_body1;
_local2 = m_body2;
_local3 = _local1.m_R;
_local4 = ((_local3.col1.x * m_localAnchor1.x) + (_local3.col2.x * m_localAnchor1.y));
_local5 = ((_local3.col1.y * m_localAnchor1.x) + (_local3.col2.y * m_localAnchor1.y));
_local3 = _local2.m_R;
_local6 = ((_local3.col1.x * m_localAnchor2.x) + (_local3.col2.x * m_localAnchor2.y));
_local7 = ((_local3.col1.y * m_localAnchor2.x) + (_local3.col2.y * m_localAnchor2.y));
_local8 = _local1.m_invMass;
_local9 = _local2.m_invMass;
_local10 = _local1.m_invI;
_local11 = _local2.m_invI;
K1.col1.x = (_local8 + _local9);
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = (_local8 + _local9);
K2.col1.x = ((_local10 * _local5) * _local5);
K2.col2.x = ((-(_local10) * _local4) * _local5);
K2.col1.y = ((-(_local10) * _local4) * _local5);
K2.col2.y = ((_local10 * _local4) * _local4);
K3.col1.x = ((_local11 * _local7) * _local7);
K3.col2.x = ((-(_local11) * _local6) * _local7);
K3.col1.y = ((-(_local11) * _local6) * _local7);
K3.col2.y = ((_local11 * _local6) * _local6);
K.SetM(K1);
K.AddM(K2);
K.AddM(K3);
K.Invert(m_ptpMass);
m_motorMass = (1 / (_local10 + _local11));
if (m_enableMotor == false){
m_motorImpulse = 0;
};
if (m_enableLimit){
_local12 = ((_local2.m_rotation - _local1.m_rotation) - m_intialAngle);
if (b2Math.b2Abs((m_upperAngle - m_lowerAngle)) < (2 * b2Settings.b2_angularSlop)){
m_limitState = e_equalLimits;
} else {
if (_local12 <= m_lowerAngle){
if (m_limitState != e_atLowerLimit){
m_limitImpulse = 0;
};
m_limitState = e_atLowerLimit;
} else {
if (_local12 >= m_upperAngle){
if (m_limitState != e_atUpperLimit){
m_limitImpulse = 0;
};
m_limitState = e_atUpperLimit;
} else {
m_limitState = e_inactiveLimit;
m_limitImpulse = 0;
};
};
};
} else {
m_limitImpulse = 0;
};
if (b2World.s_enableWarmStarting){
_local1.m_linearVelocity.x = (_local1.m_linearVelocity.x - (_local8 * m_ptpImpulse.x));
_local1.m_linearVelocity.y = (_local1.m_linearVelocity.y - (_local8 * m_ptpImpulse.y));
_local1.m_angularVelocity = (_local1.m_angularVelocity - (_local10 * ((((_local4 * m_ptpImpulse.y) - (_local5 * m_ptpImpulse.x)) + m_motorImpulse) + m_limitImpulse)));
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x + (_local9 * m_ptpImpulse.x));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y + (_local9 * m_ptpImpulse.y));
_local2.m_angularVelocity = (_local2.m_angularVelocity + (_local11 * ((((_local6 * m_ptpImpulse.y) - (_local7 * m_ptpImpulse.x)) + m_motorImpulse) + m_limitImpulse)));
} else {
m_ptpImpulse.SetZero();
m_motorImpulse = 0;
m_limitImpulse = 0;
};
m_limitPositionImpulse = 0;
}
override public function GetReactionForce(_arg1:Number):b2Vec2{
var _local2:b2Vec2;
_local2 = m_ptpImpulse.Copy();
_local2.Multiply(_arg1);
return (_local2);
}
override public function SolvePositionConstraints():Boolean{
var _local1:Number;
var _local2:Number;
var _local3:b2Body;
var _local4:b2Body;
var _local5:Number;
var _local6:b2Mat22;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
_local3 = m_body1;
_local4 = m_body2;
_local5 = 0;
_local6 = _local3.m_R;
_local7 = ((_local6.col1.x * m_localAnchor1.x) + (_local6.col2.x * m_localAnchor1.y));
_local8 = ((_local6.col1.y * m_localAnchor1.x) + (_local6.col2.y * m_localAnchor1.y));
_local6 = _local4.m_R;
_local9 = ((_local6.col1.x * m_localAnchor2.x) + (_local6.col2.x * m_localAnchor2.y));
_local10 = ((_local6.col1.y * m_localAnchor2.x) + (_local6.col2.y * m_localAnchor2.y));
_local11 = (_local3.m_position.x + _local7);
_local12 = (_local3.m_position.y + _local8);
_local13 = (_local4.m_position.x + _local9);
_local14 = (_local4.m_position.y + _local10);
_local15 = (_local13 - _local11);
_local16 = (_local14 - _local12);
_local5 = Math.sqrt(((_local15 * _local15) + (_local16 * _local16)));
_local17 = _local3.m_invMass;
_local18 = _local4.m_invMass;
_local19 = _local3.m_invI;
_local20 = _local4.m_invI;
K1.col1.x = (_local17 + _local18);
K1.col2.x = 0;
K1.col1.y = 0;
K1.col2.y = (_local17 + _local18);
K2.col1.x = ((_local19 * _local8) * _local8);
K2.col2.x = ((-(_local19) * _local7) * _local8);
K2.col1.y = ((-(_local19) * _local7) * _local8);
K2.col2.y = ((_local19 * _local7) * _local7);
K3.col1.x = ((_local20 * _local10) * _local10);
K3.col2.x = ((-(_local20) * _local9) * _local10);
K3.col1.y = ((-(_local20) * _local9) * _local10);
K3.col2.y = ((_local20 * _local9) * _local9);
K.SetM(K1);
K.AddM(K2);
K.AddM(K3);
K.Solve(tImpulse, -(_local15), -(_local16));
_local21 = tImpulse.x;
_local22 = tImpulse.y;
_local3.m_position.x = (_local3.m_position.x - (_local3.m_invMass * _local21));
_local3.m_position.y = (_local3.m_position.y - (_local3.m_invMass * _local22));
_local3.m_rotation = (_local3.m_rotation - (_local3.m_invI * ((_local7 * _local22) - (_local8 * _local21))));
_local3.m_R.Set(_local3.m_rotation);
_local4.m_position.x = (_local4.m_position.x + (_local4.m_invMass * _local21));
_local4.m_position.y = (_local4.m_position.y + (_local4.m_invMass * _local22));
_local4.m_rotation = (_local4.m_rotation + (_local4.m_invI * ((_local9 * _local22) - (_local10 * _local21))));
_local4.m_R.Set(_local4.m_rotation);
_local23 = 0;
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local24 = ((_local4.m_rotation - _local3.m_rotation) - m_intialAngle);
_local25 = 0;
if (m_limitState == e_equalLimits){
_local2 = b2Math.b2Clamp(_local24, -(b2Settings.b2_maxAngularCorrection), b2Settings.b2_maxAngularCorrection);
_local25 = (-(m_motorMass) * _local2);
_local23 = b2Math.b2Abs(_local2);
} else {
if (m_limitState == e_atLowerLimit){
_local2 = (_local24 - m_lowerAngle);
_local23 = b2Math.b2Max(0, -(_local2));
_local2 = b2Math.b2Clamp((_local2 + b2Settings.b2_angularSlop), -(b2Settings.b2_maxAngularCorrection), 0);
_local25 = (-(m_motorMass) * _local2);
_local1 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Max((m_limitPositionImpulse + _local25), 0);
_local25 = (m_limitPositionImpulse - _local1);
} else {
if (m_limitState == e_atUpperLimit){
_local2 = (_local24 - m_upperAngle);
_local23 = b2Math.b2Max(0, _local2);
_local2 = b2Math.b2Clamp((_local2 - b2Settings.b2_angularSlop), 0, b2Settings.b2_maxAngularCorrection);
_local25 = (-(m_motorMass) * _local2);
_local1 = m_limitPositionImpulse;
m_limitPositionImpulse = b2Math.b2Min((m_limitPositionImpulse + _local25), 0);
_local25 = (m_limitPositionImpulse - _local1);
};
};
};
_local3.m_rotation = (_local3.m_rotation - (_local3.m_invI * _local25));
_local3.m_R.Set(_local3.m_rotation);
_local4.m_rotation = (_local4.m_rotation + (_local4.m_invI * _local25));
_local4.m_R.Set(_local4.m_rotation);
};
return ((((_local5 <= b2Settings.b2_linearSlop)) && ((_local23 <= b2Settings.b2_angularSlop))));
}
public function GetJointSpeed():Number{
return ((m_body2.m_angularVelocity - m_body1.m_angularVelocity));
}
public function SetMotorSpeed(_arg1:Number){
m_motorSpeed = _arg1;
}
public function SetMotorTorque(_arg1:Number){
m_maxMotorTorque = _arg1;
}
public function GetJointAngle():Number{
return ((m_body2.m_rotation - m_body1.m_rotation));
}
public function GetMotorTorque(_arg1:Number):Number{
return ((_arg1 * m_motorImpulse));
}
override public function GetReactionTorque(_arg1:Number):Number{
return ((_arg1 * m_limitImpulse));
}
override public function SolveVelocityConstraints(_arg1:b2StepInfo){
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Mat22;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
_local2 = m_body1;
_local3 = m_body2;
_local4 = _local2.m_R;
_local5 = ((_local4.col1.x * m_localAnchor1.x) + (_local4.col2.x * m_localAnchor1.y));
_local6 = ((_local4.col1.y * m_localAnchor1.x) + (_local4.col2.y * m_localAnchor1.y));
_local4 = _local3.m_R;
_local7 = ((_local4.col1.x * m_localAnchor2.x) + (_local4.col2.x * m_localAnchor2.y));
_local8 = ((_local4.col1.y * m_localAnchor2.x) + (_local4.col2.y * m_localAnchor2.y));
_local10 = (((_local3.m_linearVelocity.x + (-(_local3.m_angularVelocity) * _local8)) - _local2.m_linearVelocity.x) - (-(_local2.m_angularVelocity) * _local6));
_local11 = (((_local3.m_linearVelocity.y + (_local3.m_angularVelocity * _local7)) - _local2.m_linearVelocity.y) - (_local2.m_angularVelocity * _local5));
_local12 = -(((m_ptpMass.col1.x * _local10) + (m_ptpMass.col2.x * _local11)));
_local13 = -(((m_ptpMass.col1.y * _local10) + (m_ptpMass.col2.y * _local11)));
m_ptpImpulse.x = (m_ptpImpulse.x + _local12);
m_ptpImpulse.y = (m_ptpImpulse.y + _local13);
_local2.m_linearVelocity.x = (_local2.m_linearVelocity.x - (_local2.m_invMass * _local12));
_local2.m_linearVelocity.y = (_local2.m_linearVelocity.y - (_local2.m_invMass * _local13));
_local2.m_angularVelocity = (_local2.m_angularVelocity - (_local2.m_invI * ((_local5 * _local13) - (_local6 * _local12))));
_local3.m_linearVelocity.x = (_local3.m_linearVelocity.x + (_local3.m_invMass * _local12));
_local3.m_linearVelocity.y = (_local3.m_linearVelocity.y + (_local3.m_invMass * _local13));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * ((_local7 * _local13) - (_local8 * _local12))));
if (((m_enableMotor) && (!((m_limitState == e_equalLimits))))){
_local14 = ((_local3.m_angularVelocity - _local2.m_angularVelocity) - m_motorSpeed);
_local15 = (-(m_motorMass) * _local14);
_local16 = m_motorImpulse;
m_motorImpulse = b2Math.b2Clamp((m_motorImpulse + _local15), (-(_arg1.dt) * m_maxMotorTorque), (_arg1.dt * m_maxMotorTorque));
_local15 = (m_motorImpulse - _local16);
_local2.m_angularVelocity = (_local2.m_angularVelocity - (_local2.m_invI * _local15));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * _local15));
};
if (((m_enableLimit) && (!((m_limitState == e_inactiveLimit))))){
_local17 = (_local3.m_angularVelocity - _local2.m_angularVelocity);
_local18 = (-(m_motorMass) * _local17);
if (m_limitState == e_equalLimits){
m_limitImpulse = (m_limitImpulse + _local18);
} else {
if (m_limitState == e_atLowerLimit){
_local9 = m_limitImpulse;
m_limitImpulse = b2Math.b2Max((m_limitImpulse + _local18), 0);
_local18 = (m_limitImpulse - _local9);
} else {
if (m_limitState == e_atUpperLimit){
_local9 = m_limitImpulse;
m_limitImpulse = b2Math.b2Min((m_limitImpulse + _local18), 0);
_local18 = (m_limitImpulse - _local9);
};
};
};
_local2.m_angularVelocity = (_local2.m_angularVelocity - (_local2.m_invI * _local18));
_local3.m_angularVelocity = (_local3.m_angularVelocity + (_local3.m_invI * _local18));
};
}
}
}//package Engine.Dynamics.Joints
Section 53
//b2RevoluteJointDef (Engine.Dynamics.Joints.b2RevoluteJointDef)
package Engine.Dynamics.Joints {
import Engine.Common.Math.*;
public class b2RevoluteJointDef extends b2JointDef {
public var upperAngle:Number;
public var lowerAngle:Number;
public var motorSpeed:Number;
public var anchorPoint:b2Vec2;
public var motorTorque:Number;
public var enableMotor:Boolean;
public var enableLimit:Boolean;
public function b2RevoluteJointDef(){
type = b2Joint.e_revoluteJoint;
anchorPoint = new b2Vec2(0, 0);
lowerAngle = 0;
upperAngle = 0;
motorTorque = 0;
motorSpeed = 0;
enableLimit = false;
enableMotor = false;
}
}
}//package Engine.Dynamics.Joints
Section 54
//b2Body (Engine.Dynamics.b2Body)
package Engine.Dynamics {
import Engine.Dynamics.Joints.*;
import Engine.Common.Math.*;
import Engine.Collision.Shapes.*;
import Engine.Dynamics.Contacts.*;
import Engine.Common.*;
public class b2Body {
public var m_next:b2Body;
public var m_mass:Number;
public var m_contactList:b2ContactNode;
public var m_angularVelocity:Number;
public var m_rotation:Number;
public var m_shapeList:b2Shape;
public var m_R:b2Mat22;
public var m_force:b2Vec2;
public var m_torque:Number;
public var m_userData;
public var m_linearVelocity:b2Vec2;
public var m_invMass:Number;
public var m_position:b2Vec2;
public var m_flags:uint;
public var m_world:b2World;
public var m_invI:Number;
public var m_shapeCount:int;
public var m_linearDamping:Number;
public var m_prev:b2Body;
public var m_angularDamping:Number;
public var m_center:b2Vec2;
public var m_sleepTime:Number;
public var m_I:Number;
public var m_jointList:b2JointNode;
public static var e_frozenFlag:uint = 2;
public static var e_sleepFlag:uint = 8;
public static var e_islandFlag:uint = 4;
public static var e_destroyFlag:uint = 32;
public static var e_allowSleepFlag:uint = 16;
public static var e_staticFlag:uint = 1;
public function b2Body(_arg1:b2BodyDef, _arg2:b2World){
var _local3:int;
var _local4:b2ShapeDef;
var _local5:b2MassData;
var _local6:Array;
var _local7:b2Vec2;
var _local8:b2Shape;
m_position = new b2Vec2();
m_R = new b2Mat22(0);
super();
m_flags = 0;
m_position.SetV(_arg1.position);
m_rotation = _arg1.rotation;
m_R.Set(m_rotation);
m_world = _arg2;
m_linearDamping = b2Math.b2Clamp((1 - _arg1.linearDamping), 0, 1);
m_angularDamping = b2Math.b2Clamp((1 - _arg1.angularDamping), 0, 1);
m_force = new b2Vec2(0, 0);
m_torque = 0;
m_mass = 0;
_local6 = new Array(b2Settings.b2_maxShapesPerBody);
_local3 = 0;
while (_local3 < b2Settings.b2_maxShapesPerBody) {
_local6[_local3] = new b2MassData();
_local3++;
};
m_shapeCount = 0;
m_center = new b2Vec2(0, 0);
_local3 = 0;
while (_local3 < b2Settings.b2_maxShapesPerBody) {
_local4 = _arg1.shapes[_local3];
if (_local4 == null){
break;
};
_local5 = _local6[_local3];
_local4.ComputeMass(_local5);
m_mass = (m_mass + _local5.mass);
m_center.Add(b2Math.MulFV(_local5.mass, b2Math.AddVV(_local4.localPosition, _local5.center)));
m_shapeCount++;
_local3++;
};
if (m_mass > 0){
m_center.Multiply((1 / m_mass));
m_position.Add(b2Math.b2MulMV(m_R, m_center));
} else {
m_flags = (m_flags | e_staticFlag);
};
m_I = 0;
_local3 = 0;
while (_local3 < m_shapeCount) {
_local4 = _arg1.shapes[_local3];
_local5 = _local6[_local3];
m_I = (m_I + _local5.I);
_local7 = b2Math.SubtractVV(b2Math.AddVV(_local4.localPosition, _local5.center), m_center);
m_I = (m_I + (_local5.mass * b2Math.b2Dot(_local7, _local7)));
_local3++;
};
if (m_mass > 0){
m_invMass = (1 / m_mass);
} else {
m_invMass = 0;
};
if ((((m_I > 0)) && ((_arg1.preventRotation == false)))){
m_invI = (1 / m_I);
} else {
m_I = 0;
m_invI = 0;
};
m_linearVelocity = b2Math.AddVV(_arg1.linearVelocity, b2Math.b2CrossFV(_arg1.angularVelocity, m_center));
m_angularVelocity = _arg1.angularVelocity;
m_jointList = null;
m_contactList = null;
m_prev = null;
m_next = null;
m_shapeList = null;
_local3 = 0;
while (_local3 < m_shapeCount) {
_local4 = _arg1.shapes[_local3];
_local8 = b2Shape.Create(_local4, this, m_center);
_local8.m_next = m_shapeList;
m_shapeList = _local8;
_local3++;
};
m_sleepTime = 0;
if (_arg1.allowSleep){
m_flags = (m_flags | e_allowSleepFlag);
};
if (_arg1.isSleeping){
m_flags = (m_flags | e_sleepFlag);
};
if ((((m_flags & e_sleepFlag)) || ((m_invMass == 0)))){
m_linearVelocity.Set(0, 0);
m_angularVelocity = 0;
};
m_userData = _arg1.userData;
}
public function SetCenterPosition(_arg1:b2Vec2, _arg2:Number){
var _local3:b2Shape;
if (IsFrozen()){
return;
};
m_rotation = _arg2;
m_R.Set(m_rotation);
m_position.SetV(_arg1);
_local3 = m_shapeList;
while (_local3 != null) {
_local3.Synchronize(m_position, m_R);
_local3 = _local3.m_next;
};
m_world.m_broadPhase.Flush();
}
public function GetWorldPoint(_arg1:b2Vec2):b2Vec2{
return (b2Math.AddVV(m_position, b2Math.b2MulMV(m_R, _arg1)));
}
public function SetLinearVelocity(_arg1:b2Vec2){
m_linearVelocity.SetV(_arg1);
}
public function IsFrozen():Boolean{
return (((m_flags & e_frozenFlag) == e_frozenFlag));
}
public function IsSleeping():Boolean{
return (((m_flags & e_sleepFlag) == e_sleepFlag));
}
public function GetInertia():Number{
return (m_I);
}
public function GetLocalVector(_arg1:b2Vec2):b2Vec2{
return (b2Math.b2MulTMV(m_R, _arg1));
}
public function GetLinearVelocity():b2Vec2{
return (m_linearVelocity);
}
public function GetJointList():b2JointNode{
return (m_jointList);
}
public function GetRotationMatrix():b2Mat22{
return (m_R);
}
public function Freeze(){
m_flags = (m_flags | e_frozenFlag);
m_linearVelocity.SetZero();
m_angularVelocity = 0;
}
public function SetAngularVelocity(_arg1:Number){
m_angularVelocity = _arg1;
}
public function SynchronizeShapes(){
var _local1:b2Shape;
_local1 = m_shapeList;
while (_local1 != null) {
_local1.Synchronize(m_position, m_R);
_local1 = _local1.m_next;
};
}
public function ApplyForce(_arg1:b2Vec2, _arg2:b2Vec2){
if (IsSleeping() == false){
m_force.Add(_arg1);
m_torque = (m_torque + b2Math.b2CrossVV(b2Math.SubtractVV(_arg2, m_position), _arg1));
};
}
public function GetOriginPosition():b2Vec2{
return (b2Math.SubtractVV(m_position, b2Math.b2MulMV(m_R, m_center)));
}
public function ApplyImpulse(_arg1:b2Vec2, _arg2:b2Vec2){
if (IsSleeping() == false){
m_linearVelocity.Add(b2Math.MulFV(m_invMass, _arg1));
m_angularVelocity = (m_angularVelocity + (m_invI * b2Math.b2CrossVV(b2Math.SubtractVV(_arg2, m_position), _arg1)));
};
}
public function GetContactList():b2ContactNode{
return (m_contactList);
}
public function GetAngularVelocity():Number{
return (m_angularVelocity);
}
public function GetMass():Number{
return (m_mass);
}
public function GetShapeList():b2Shape{
return (m_shapeList);
}
public function SetOriginPosition(_arg1:b2Vec2, _arg2:Number){
var _local3:b2Shape;
if (IsFrozen()){
return;
};
m_rotation = _arg2;
m_R.Set(m_rotation);
m_position = b2Math.AddVV(_arg1, b2Math.b2MulMV(m_R, m_center));
_local3 = m_shapeList;
while (_local3 != null) {
_local3.Synchronize(m_position, m_R);
_local3 = _local3.m_next;
};
m_world.m_broadPhase.Flush();
}
public function GetLocalPoint(_arg1:b2Vec2):b2Vec2{
return (b2Math.b2MulTMV(m_R, b2Math.SubtractVV(_arg1, m_position)));
}
public function GetRotation():Number{
return (m_rotation);
}
public function IsStatic():Boolean{
return (((m_flags & e_staticFlag) == e_staticFlag));
}
public function Destroy(){
var _local1:b2Shape;
var _local2:b2Shape;
_local1 = m_shapeList;
while (_local1) {
_local2 = _local1;
_local1 = _local1.m_next;
b2Shape.Destroy(_local2);
};
}
public function GetWorldVector(_arg1:b2Vec2):b2Vec2{
return (b2Math.b2MulMV(m_R, _arg1));
}
public function GetNext():b2Body{
return (m_next);
}
public function IsConnected(_arg1:b2Body):Boolean{
var _local2:b2JointNode;
_local2 = m_jointList;
while (_local2 != null) {
if (_local2.other == _arg1){
return ((_local2.joint.m_collideConnected == false));
};
_local2 = _local2.next;
};
return (false);
}
public function GetUserData(){
return (m_userData);
}
public function GetCenterPosition():b2Vec2{
return (m_position);
}
public function ApplyTorque(_arg1:Number){
if (IsSleeping() == false){
m_torque = (m_torque + _arg1);
};
}
public function AllowSleeping(_arg1:Boolean){
if (_arg1){
m_flags = (m_flags | e_allowSleepFlag);
} else {
m_flags = (m_flags & ~(e_allowSleepFlag));
WakeUp();
};
}
public function WakeUp(){
m_flags = (m_flags & ~(e_sleepFlag));
m_sleepTime = 0;
}
}
}//package Engine.Dynamics
Section 55
//b2BodyDef (Engine.Dynamics.b2BodyDef)
package Engine.Dynamics {
import Engine.Common.Math.*;
import Engine.Collision.Shapes.*;
import Engine.Common.*;
public class b2BodyDef {
public var angularDamping:Number;
public var rotation:Number;
public var allowSleep:Boolean;
public var userData;
public var linearDamping:Number;
public var angularVelocity:Number;
public var linearVelocity:b2Vec2;
public var position:b2Vec2;
public var shapes:Array;
public var isSleeping:Boolean;
public var preventRotation:Boolean;
public function b2BodyDef(){
var _local1:int;
shapes = new Array();
super();
userData = null;
_local1 = 0;
while (_local1 < b2Settings.b2_maxShapesPerBody) {
shapes[_local1] = null;
_local1++;
};
position = new b2Vec2(0, 0);
rotation = 0;
linearVelocity = new b2Vec2(0, 0);
angularVelocity = 0;
linearDamping = 0;
angularDamping = 0;
allowSleep = true;
isSleeping = false;
preventRotation = false;
}
public function AddShape(_arg1:b2ShapeDef){
var _local2:int;
_local2 = 0;
while (_local2 < b2Settings.b2_maxShapesPerBody) {
if (shapes[_local2] == null){
shapes[_local2] = _arg1;
break;
};
_local2++;
};
}
}
}//package Engine.Dynamics
Section 56
//b2ContactManager (Engine.Dynamics.b2ContactManager)
package Engine.Dynamics {
import Engine.Collision.Shapes.*;
import Engine.Dynamics.Contacts.*;
import Engine.Collision.*;
public class b2ContactManager extends b2PairCallback {
public var m_world:b2World;
public var m_destroyImmediate:Boolean;
public var m_nullContact:b2NullContact;
public function b2ContactManager(){
m_nullContact = new b2NullContact();
super();
m_world = null;
m_destroyImmediate = false;
}
public function Collide(){
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2ContactNode;
var _local4:b2ContactNode;
var _local5:b2Contact;
var _local6:int;
var _local7:int;
_local5 = m_world.m_contactList;
while (_local5 != null) {
if (((_local5.m_shape1.m_body.IsSleeping()) && (_local5.m_shape2.m_body.IsSleeping()))){
} else {
_local6 = _local5.GetManifoldCount();
_local5.Evaluate();
_local7 = _local5.GetManifoldCount();
if ((((_local6 == 0)) && ((_local7 > 0)))){
_local1 = _local5.m_shape1.m_body;
_local2 = _local5.m_shape2.m_body;
_local3 = _local5.m_node1;
_local4 = _local5.m_node2;
_local3.contact = _local5;
_local3.other = _local2;
_local3.prev = null;
_local3.next = _local1.m_contactList;
if (_local3.next != null){
_local3.next.prev = _local5.m_node1;
};
_local1.m_contactList = _local5.m_node1;
_local4.contact = _local5;
_local4.other = _local1;
_local4.prev = null;
_local4.next = _local2.m_contactList;
if (_local4.next != null){
_local4.next.prev = _local4;
};
_local2.m_contactList = _local4;
} else {
if ((((_local6 > 0)) && ((_local7 == 0)))){
_local1 = _local5.m_shape1.m_body;
_local2 = _local5.m_shape2.m_body;
_local3 = _local5.m_node1;
_local4 = _local5.m_node2;
if (_local3.prev){
_local3.prev.next = _local3.next;
};
if (_local3.next){
_local3.next.prev = _local3.prev;
};
if (_local3 == _local1.m_contactList){
_local1.m_contactList = _local3.next;
};
_local3.prev = null;
_local3.next = null;
if (_local4.prev){
_local4.prev.next = _local4.next;
};
if (_local4.next){
_local4.next.prev = _local4.prev;
};
if (_local4 == _local2.m_contactList){
_local2.m_contactList = _local4.next;
};
_local4.prev = null;
_local4.next = null;
};
};
};
_local5 = _local5.m_next;
};
}
public function DestroyContact(_arg1:b2Contact){
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2ContactNode;
var _local5:b2ContactNode;
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1 == m_world.m_contactList){
m_world.m_contactList = _arg1.m_next;
};
if (_arg1.GetManifoldCount() > 0){
_local2 = _arg1.m_shape1.m_body;
_local3 = _arg1.m_shape2.m_body;
_local4 = _arg1.m_node1;
_local5 = _arg1.m_node2;
_local2.WakeUp();
_local3.WakeUp();
if (_local4.prev){
_local4.prev.next = _local4.next;
};
if (_local4.next){
_local4.next.prev = _local4.prev;
};
if (_local4 == _local2.m_contactList){
_local2.m_contactList = _local4.next;
};
_local4.prev = null;
_local4.next = null;
if (_local5.prev){
_local5.prev.next = _local5.next;
};
if (_local5.next){
_local5.next.prev = _local5.prev;
};
if (_local5 == _local3.m_contactList){
_local3.m_contactList = _local5.next;
};
_local5.prev = null;
_local5.next = null;
};
b2Contact.Destroy(_arg1, m_world.m_blockAllocator);
m_world.m_contactCount--;
}
override public function PairAdded(_arg1, _arg2){
var _local3:b2Shape;
var _local4:b2Shape;
var _local5:b2Body;
var _local6:b2Body;
var _local7:b2Contact;
var _local8:b2Shape;
var _local9:b2Body;
_local3 = (_arg1 as b2Shape);
_local4 = (_arg2 as b2Shape);
_local5 = _local3.m_body;
_local6 = _local4.m_body;
if (((_local5.IsStatic()) && (_local6.IsStatic()))){
return (m_nullContact);
};
if (_local3.m_body == _local4.m_body){
return (m_nullContact);
};
if (_local6.m_invMass == 0){
_local8 = _local3;
_local3 = _local4;
_local4 = _local8;
_local9 = _local5;
_local5 = _local6;
_local6 = _local9;
};
if (_local6.IsConnected(_local5)){
return (m_nullContact);
};
_local7 = b2Contact.Create(_local3, _local4, m_world.m_blockAllocator);
if (_local7 == null){
return (m_nullContact);
};
_local7.m_prev = null;
_local7.m_next = m_world.m_contactList;
if (m_world.m_contactList != null){
m_world.m_contactList.m_prev = _local7;
};
m_world.m_contactList = _local7;
m_world.m_contactCount++;
return (_local7);
}
public function CleanContactList(){
var _local1:b2Contact;
var _local2:b2Contact;
_local1 = m_world.m_contactList;
while (_local1 != null) {
_local2 = _local1;
_local1 = _local1.m_next;
if ((_local2.m_flags & b2Contact.e_destroyFlag)){
DestroyContact(_local2);
_local2 = null;
};
};
}
override public function PairRemoved(_arg1, _arg2, _arg3){
var _local4:b2Contact;
if (_arg3 == null){
return;
};
_local4 = (_arg3 as b2Contact);
if (_local4 != m_nullContact){
if (m_destroyImmediate == true){
DestroyContact(_local4);
_local4 = null;
} else {
_local4.m_flags = (_local4.m_flags | b2Contact.e_destroyFlag);
};
};
}
}
}//package Engine.Dynamics
Section 57
//b2Island (Engine.Dynamics.b2Island)
package Engine.Dynamics {
import Engine.Dynamics.Joints.*;
import Engine.Common.Math.*;
import Engine.Dynamics.Contacts.*;
import Engine.Common.*;
public class b2Island {
public var m_positionError:Number;
public var m_bodyCapacity:int;
public var m_bodies:Array;
public var m_joints:Array;
public var m_jointCapacity:int;
public var m_contactCount:int;
public var m_contacts:Array;
public var m_contactCapacity:int;
public var m_jointCount:int;
public var m_allocator;
public var m_bodyCount:int;
public static var m_positionIterationCount;
public function b2Island(_arg1:int, _arg2:int, _arg3:int, _arg4){
var _local5:int;
super();
m_bodyCapacity = _arg1;
m_contactCapacity = _arg2;
m_jointCapacity = _arg3;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_bodies = new Array(_arg1);
_local5 = 0;
while (_local5 < _arg1) {
m_bodies[_local5] = null;
_local5++;
};
m_contacts = new Array(_arg2);
_local5 = 0;
while (_local5 < _arg2) {
m_contacts[_local5] = null;
_local5++;
};
m_joints = new Array(_arg3);
_local5 = 0;
while (_local5 < _arg3) {
m_joints[_local5] = null;
_local5++;
};
m_allocator = _arg4;
}
public function AddBody(_arg1:b2Body){
var _local2 = m_bodyCount++;
m_bodies[_local2] = _arg1;
}
public function AddJoint(_arg1:b2Joint){
var _local2 = m_jointCount++;
m_joints[_local2] = _arg1;
}
public function Solve(_arg1:b2StepInfo, _arg2:b2Vec2){
var _local3:int;
var _local4:b2Body;
var _local5:b2ContactSolver;
var _local6:int;
var _local7:Boolean;
var _local8:Boolean;
var _local9:Boolean;
_local3 = 0;
while (_local3 < m_bodyCount) {
_local4 = m_bodies[_local3];
if (_local4.m_invMass == 0){
} else {
_local4.m_linearVelocity.Add(b2Math.MulFV(_arg1.dt, b2Math.AddVV(_arg2, b2Math.MulFV(_local4.m_invMass, _local4.m_force))));
_local4.m_angularVelocity = (_local4.m_angularVelocity + ((_arg1.dt * _local4.m_invI) * _local4.m_torque));
_local4.m_linearVelocity.Multiply(_local4.m_linearDamping);
_local4.m_angularVelocity = (_local4.m_angularVelocity * _local4.m_angularDamping);
};
_local3++;
};
_local5 = new b2ContactSolver(m_contacts, m_contactCount, m_allocator);
_local5.PreSolve();
_local3 = 0;
while (_local3 < m_jointCount) {
m_joints[_local3].PrepareVelocitySolver();
_local3++;
};
_local3 = 0;
while (_local3 < _arg1.iterations) {
_local5.SolveVelocityConstraints();
_local6 = 0;
while (_local6 < m_jointCount) {
m_joints[_local6].SolveVelocityConstraints(_arg1);
_local6++;
};
_local3++;
};
_local3 = 0;
while (_local3 < m_bodyCount) {
_local4 = m_bodies[_local3];
if (_local4.m_invMass == 0){
} else {
_local4.m_position.x = (_local4.m_position.x + (_arg1.dt * _local4.m_linearVelocity.x));
_local4.m_position.y = (_local4.m_position.y + (_arg1.dt * _local4.m_linearVelocity.y));
_local4.m_rotation = (_local4.m_rotation + (_arg1.dt * _local4.m_angularVelocity));
_local4.m_R.Set(_local4.m_rotation);
};
_local3++;
};
_local3 = 0;
while (_local3 < m_jointCount) {
m_joints[_local3].PreparePositionSolver();
_local3++;
};
if (b2World.s_enablePositionCorrection){
m_positionIterationCount = 0;
while (m_positionIterationCount < _arg1.iterations) {
_local7 = _local5.SolvePositionConstraints(b2Settings.b2_contactBaumgarte);
_local8 = true;
_local3 = 0;
while (_local3 < m_jointCount) {
_local9 = m_joints[_local3].SolvePositionConstraints();
_local8 = ((_local8) && (_local9));
_local3++;
};
if (((_local7) && (_local8))){
break;
};
m_positionIterationCount++;
};
};
_local5.PostSolve();
_local3 = 0;
while (_local3 < m_bodyCount) {
_local4 = m_bodies[_local3];
if (_local4.m_invMass == 0){
} else {
_local4.m_R.Set(_local4.m_rotation);
_local4.SynchronizeShapes();
_local4.m_force.Set(0, 0);
_local4.m_torque = 0;
};
_local3++;
};
}
public function AddContact(_arg1:b2Contact){
var _local2 = m_contactCount++;
m_contacts[_local2] = _arg1;
}
public function Clear(){
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
}
public function UpdateSleep(_arg1:Number){
var _local2:int;
var _local3:b2Body;
var _local4:Number;
var _local5:Number;
var _local6:Number;
_local4 = Number.MAX_VALUE;
_local5 = (b2Settings.b2_linearSleepTolerance * b2Settings.b2_linearSleepTolerance);
_local6 = (b2Settings.b2_angularSleepTolerance * b2Settings.b2_angularSleepTolerance);
_local2 = 0;
while (_local2 < m_bodyCount) {
_local3 = m_bodies[_local2];
if (_local3.m_invMass == 0){
} else {
if ((_local3.m_flags & b2Body.e_allowSleepFlag) == 0){
_local3.m_sleepTime = 0;
_local4 = 0;
};
if (((((((_local3.m_flags & b2Body.e_allowSleepFlag) == 0)) || (((_local3.m_angularVelocity * _local3.m_angularVelocity) > _local6)))) || ((b2Math.b2Dot(_local3.m_linearVelocity, _local3.m_linearVelocity) > _local5)))){
_local3.m_sleepTime = 0;
_local4 = 0;
} else {
_local3.m_sleepTime = (_local3.m_sleepTime + _arg1);
_local4 = b2Math.b2Min(_local4, _local3.m_sleepTime);
};
};
_local2++;
};
if (_local4 >= b2Settings.b2_timeToSleep){
_local2 = 0;
while (_local2 < m_bodyCount) {
_local3 = m_bodies[_local2];
_local3.m_flags = (_local3.m_flags | b2Body.e_sleepFlag);
_local2++;
};
};
}
}
}//package Engine.Dynamics
Section 58
//b2StepInfo (Engine.Dynamics.b2StepInfo)
package Engine.Dynamics {
public class b2StepInfo {
public var dt:Number;
public var iterations:int;
public var inv_dt:Number;
}
}//package Engine.Dynamics
Section 59
//b2World (Engine.Dynamics.b2World)
package Engine.Dynamics {
import Engine.Dynamics.Joints.*;
import Engine.Common.Math.*;
import Engine.Collision.Shapes.*;
import Engine.Dynamics.Contacts.*;
import Engine.Collision.*;
public class b2World {
public var m_bodyCount:int;
public var m_gravity:b2Vec2;
public var m_listener:b2WorldListener;
private var step:b2StepInfo;
public var m_positionIterationCount:int;
public var m_blockAllocator;
public var m_contactList:b2Contact;
public var m_groundBody:b2Body;
public var m_contactCount:int;
public var m_broadPhase:b2BroadPhase;
public var m_stackAllocator;
public var m_jointCount:int;
public var m_bodyList:b2Body;
public var m_doSleep:Boolean;
public var m_bodyDestroyList:b2Body;
public var m_jointList:b2Joint;
public var m_contactManager:b2ContactManager;
public static var s_enableWarmStarting:int = 1;
public static var s_enablePositionCorrection:int = 1;
public function b2World(_arg1:b2AABB, _arg2:b2Vec2, _arg3:Boolean){
var _local4:b2BodyDef;
step = new b2StepInfo();
m_contactManager = new b2ContactManager();
super();
m_listener = null;
m_bodyList = null;
m_contactList = null;
m_jointList = null;
m_bodyCount = 0;
m_contactCount = 0;
m_jointCount = 0;
m_bodyDestroyList = null;
m_doSleep = _arg3;
m_gravity = _arg2;
m_contactManager.m_world = this;
m_broadPhase = new b2BroadPhase(_arg1, m_contactManager);
_local4 = new b2BodyDef();
m_groundBody = CreateBody(_local4);
}
public function GetContactList():b2Contact{
return (m_contactList);
}
public function CreateJoint(_arg1:b2JointDef):b2Joint{
var _local2:b2Joint;
var _local3:b2Body;
var _local4:b2Shape;
_local2 = b2Joint.Create(_arg1, m_blockAllocator);
_local2.m_prev = null;
_local2.m_next = m_jointList;
if (m_jointList){
m_jointList.m_prev = _local2;
};
m_jointList = _local2;
m_jointCount++;
_local2.m_node1.joint = _local2;
_local2.m_node1.other = _local2.m_body2;
_local2.m_node1.prev = null;
_local2.m_node1.next = _local2.m_body1.m_jointList;
if (_local2.m_body1.m_jointList){
_local2.m_body1.m_jointList.prev = _local2.m_node1;
};
_local2.m_body1.m_jointList = _local2.m_node1;
_local2.m_node2.joint = _local2;
_local2.m_node2.other = _local2.m_body1;
_local2.m_node2.prev = null;
_local2.m_node2.next = _local2.m_body2.m_jointList;
if (_local2.m_body2.m_jointList){
_local2.m_body2.m_jointList.prev = _local2.m_node2;
};
_local2.m_body2.m_jointList = _local2.m_node2;
if (_arg1.collideConnected == false){
_local3 = ((_arg1.body1.m_shapeCount < _arg1.body2.m_shapeCount)) ? _arg1.body1 : _arg1.body2;
_local4 = _local3.m_shapeList;
while (_local4) {
_local4.ResetProxy(m_broadPhase);
_local4 = _local4.m_next;
};
};
return (_local2);
}
public function DestroyJoint(_arg1:b2Joint){
var _local2:Boolean;
var _local3:b2Body;
var _local4:b2Body;
var _local5:b2Body;
var _local6:b2Shape;
_local2 = _arg1.m_collideConnected;
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1 == m_jointList){
m_jointList = _arg1.m_next;
};
_local3 = _arg1.m_body1;
_local4 = _arg1.m_body2;
_local3.WakeUp();
_local4.WakeUp();
if (_arg1.m_node1.prev){
_arg1.m_node1.prev.next = _arg1.m_node1.next;
};
if (_arg1.m_node1.next){
_arg1.m_node1.next.prev = _arg1.m_node1.prev;
};
if (_arg1.m_node1 == _local3.m_jointList){
_local3.m_jointList = _arg1.m_node1.next;
};
_arg1.m_node1.prev = null;
_arg1.m_node1.next = null;
if (_arg1.m_node2.prev){
_arg1.m_node2.prev.next = _arg1.m_node2.next;
};
if (_arg1.m_node2.next){
_arg1.m_node2.next.prev = _arg1.m_node2.prev;
};
if (_arg1.m_node2 == _local4.m_jointList){
_local4.m_jointList = _arg1.m_node2.next;
};
_arg1.m_node2.prev = null;
_arg1.m_node2.next = null;
b2Joint.Destroy(_arg1, m_blockAllocator);
m_jointCount--;
if (_local2 == false){
_local5 = ((_local3.m_shapeCount < _local4.m_shapeCount)) ? _local3 : _local4;
_local6 = _local5.m_shapeList;
while (_local6) {
_local6.ResetProxy(m_broadPhase);
_local6 = _local6.m_next;
};
};
}
public function DestroyBody(_arg1:b2Body){
if ((_arg1.m_flags & b2Body.e_destroyFlag)){
return;
};
if (_arg1.m_prev){
_arg1.m_prev.m_next = _arg1.m_next;
};
if (_arg1.m_next){
_arg1.m_next.m_prev = _arg1.m_prev;
};
if (_arg1 == m_bodyList){
m_bodyList = _arg1.m_next;
};
_arg1.m_flags = (_arg1.m_flags | b2Body.e_destroyFlag);
m_bodyCount--;
_arg1.m_prev = null;
_arg1.m_next = m_bodyDestroyList;
m_bodyDestroyList = _arg1;
}
public function SetListener(_arg1:b2WorldListener){
m_listener = _arg1;
}
public function CreateBody(_arg1:b2BodyDef):b2Body{
var _local2:b2Body;
_local2 = new b2Body(_arg1, this);
_local2.m_prev = null;
_local2.m_next = m_bodyList;
if (m_bodyList){
m_bodyList.m_prev = _local2;
};
m_bodyList = _local2;
m_bodyCount++;
return (_local2);
}
public function GetGroundBody():b2Body{
return (m_groundBody);
}
public function Query(_arg1:b2AABB, _arg2:Array, _arg3:int):int{
var _local4:Array;
var _local5:int;
var _local6:int;
_local4 = new Array();
_local5 = m_broadPhase.QueryAABB(_arg1, _local4, _arg3);
_local6 = 0;
while (_local6 < _local5) {
_arg2[_local6] = (_local4[_local6] as b2Shape);
_local6++;
};
return (_local5);
}
public function CleanBodyList(){
var _local1:b2Body;
var _local2:b2Body;
var _local3:b2JointNode;
var _local4:b2JointNode;
m_contactManager.m_destroyImmediate = true;
_local1 = m_bodyDestroyList;
while (_local1) {
_local2 = _local1;
_local1 = _local1.m_next;
_local3 = _local2.m_jointList;
while (_local3) {
_local4 = _local3;
_local3 = _local3.next;
if (m_listener){
m_listener.NotifyJointDestroyed(_local4.joint);
};
DestroyJoint(_local4.joint);
};
_local2.Destroy();
};
m_bodyDestroyList = null;
m_contactManager.m_destroyImmediate = false;
}
public function Step(_arg1:Number, _arg2:int){
var _local3:b2Body;
var _local4:b2Body;
var _local5:b2Island;
var _local6:b2Contact;
var _local7:b2Joint;
var _local8:int;
var _local9:Array;
var _local10:int;
var _local11:b2Body;
var _local12:int;
var _local13:int;
var _local14:b2ContactNode;
var _local15:b2JointNode;
var _local16:uint;
step.dt = _arg1;
step.iterations = _arg2;
if (_arg1 > 0){
step.inv_dt = (1 / _arg1);
} else {
step.inv_dt = 0;
};
m_positionIterationCount = 0;
m_contactManager.CleanContactList();
CleanBodyList();
m_contactManager.Collide();
_local5 = new b2Island(m_bodyCount, m_contactCount, m_jointCount, m_stackAllocator);
_local3 = m_bodyList;
while (_local3 != null) {
_local3.m_flags = (_local3.m_flags & ~(b2Body.e_islandFlag));
_local3 = _local3.m_next;
};
_local6 = m_contactList;
while (_local6 != null) {
_local6.m_flags = (_local6.m_flags & ~(b2Contact.e_islandFlag));
_local6 = _local6.m_next;
};
_local7 = m_jointList;
while (_local7 != null) {
_local7.m_islandFlag = false;
_local7 = _local7.m_next;
};
_local8 = m_bodyCount;
_local9 = new Array(m_bodyCount);
_local10 = 0;
while (_local10 < m_bodyCount) {
_local9[_local10] = null;
_local10++;
};
_local11 = m_bodyList;
while (_local11 != null) {
if ((_local11.m_flags & (((b2Body.e_staticFlag | b2Body.e_islandFlag) | b2Body.e_sleepFlag) | b2Body.e_frozenFlag))){
} else {
_local5.Clear();
_local12 = 0;
var _temp1 = _local12;
_local12 = (_local12 + 1);
var _local17 = _temp1;
_local9[_local17] = _local11;
_local11.m_flags = (_local11.m_flags | b2Body.e_islandFlag);
while (_local12 > 0) {
--_local12;
_local3 = _local9[_local12];
_local5.AddBody(_local3);
_local3.m_flags = (_local3.m_flags & ~(b2Body.e_sleepFlag));
if ((_local3.m_flags & b2Body.e_staticFlag)){
} else {
_local14 = _local3.m_contactList;
while (_local14 != null) {
if ((_local14.contact.m_flags & b2Contact.e_islandFlag)){
} else {
_local5.AddContact(_local14.contact);
_local14.contact.m_flags = (_local14.contact.m_flags | b2Contact.e_islandFlag);
_local4 = _local14.other;
if ((_local4.m_flags & b2Body.e_islandFlag)){
} else {
var _temp2 = _local12;
_local12 = (_local12 + 1);
var _local18 = _temp2;
_local9[_local18] = _local4;
_local4.m_flags = (_local4.m_flags | b2Body.e_islandFlag);
};
};
_local14 = _local14.next;
};
_local15 = _local3.m_jointList;
while (_local15 != null) {
if (_local15.joint.m_islandFlag == true){
} else {
_local5.AddJoint(_local15.joint);
_local15.joint.m_islandFlag = true;
_local4 = _local15.other;
if ((_local4.m_flags & b2Body.e_islandFlag)){
} else {
var _temp3 = _local12;
_local12 = (_local12 + 1);
_local18 = _temp3;
_local9[_local18] = _local4;
_local4.m_flags = (_local4.m_flags | b2Body.e_islandFlag);
};
};
_local15 = _local15.next;
};
};
};
_local5.Solve(step, m_gravity);
m_positionIterationCount = b2Math.b2Max(m_positionIterationCount, b2Island.m_positionIterationCount);
if (m_doSleep){
_local5.UpdateSleep(_arg1);
};
_local13 = 0;
while (_local13 < _local5.m_bodyCount) {
_local3 = _local5.m_bodies[_local13];
if ((_local3.m_flags & b2Body.e_staticFlag)){
_local3.m_flags = (_local3.m_flags & ~(b2Body.e_islandFlag));
};
if (((_local3.IsFrozen()) && (m_listener))){
_local16 = m_listener.NotifyBoundaryViolated(_local3);
if (_local16 == b2WorldListener.b2_destroyBody){
DestroyBody(_local3);
_local3 = null;
_local5.m_bodies[_local13] = null;
};
};
_local13++;
};
};
_local11 = _local11.m_next;
};
m_broadPhase.Flush();
}
public function GetJointList():b2Joint{
return (m_jointList);
}
public function GetBodyList():b2Body{
return (m_bodyList);
}
}
}//package Engine.Dynamics
Section 60
//b2WorldListener (Engine.Dynamics.b2WorldListener)
package Engine.Dynamics {
import Engine.Dynamics.Joints.*;
public class b2WorldListener {
public static var b2_freezeBody:uint = 0;
public static var b2_destroyBody:uint = 1;
public function NotifyBoundaryViolated(_arg1:b2Body):uint{
return (b2_freezeBody);
}
public function NotifyJointDestroyed(_arg1:b2Joint){
}
}
}//package Engine.Dynamics
Section 61
//SKTModelControl (Engine.Dynamics.SKTModelControl)
package Engine.Dynamics {
import Engine.Dynamics.Joints.*;
import Engine.Common.Math.*;
import Engine.Collision.Shapes.*;
import Engine.Dynamics.Contacts.*;
import Engine.Collision.*;
import Engine.Common.*;
public class SKTModelControl {
private var m_world:b2World;
private var m_physScale:Number;// = 30
public function SKTModelControl(_arg1){
m_physScale = 30;
super();
m_world = _arg1.m_world;
}
public function MakePulleyJoint(_arg1:b2Body, _arg2:b2Body, _arg3:Object, _arg4:Object, _arg5:Number):b2PulleyJoint{
var _local6:b2PulleyJointDef;
_local6 = new b2PulleyJointDef();
_local6.body1 = _arg1;
_local6.body2 = _arg2;
_local6.groundPoint1.Set((_arg3.gPos.x / m_physScale), (_arg3.gPos.y / m_physScale));
_local6.anchorPoint1.Set((_arg3.ancPos.x / m_physScale), (_arg3.ancPos.y / m_physScale));
_local6.groundPoint2.Set((_arg4.gPos.x / m_physScale), (_arg4.gPos.y / m_physScale));
_local6.anchorPoint2.Set((_arg4.ancPos.x / m_physScale), (_arg4.ancPos.y / m_physScale));
_local6.ratio = _arg5;
_local6.maxLength1 = (_arg3.len / m_physScale);
_local6.maxLength2 = (_arg4.len / m_physScale);
return ((m_world.CreateJoint(_local6) as b2PulleyJoint));
}
public function GetB2Vec2():b2Vec2{
return (new b2Vec2());
}
private function ModelCircleReset(_arg1:b2Body, _arg2:Number):void{
var _local3:b2Shape;
var _local4:Object;
var _local5:b2CircleShape;
_local3 = _arg1.GetShapeList();
_local4 = {};
_local4.x = (_arg1.GetCenterPosition().x * m_physScale);
_local4.y = (_arg1.GetCenterPosition().y * m_physScale);
_local4.rotation = _arg1.GetRotation();
_local4.friction = _local3.m_friction;
_local4.density = _local3.m_density;
_local4.restitution = _local3.m_restitution;
_local5 = (_local3 as b2CircleShape);
_local4.radius = ((_local5.m_radius * _arg2) * m_physScale);
DelModel(_arg1);
_arg1 = MakeCircle(_local4);
}
public function PolyTransform(_arg1:b2Body, _arg2:Array):void{
var _local3:b2Shape;
var _local4:b2PolyShape;
var _local5:int;
_local3 = _arg1.GetShapeList();
_local4 = (_local3 as b2PolyShape);
_local5 = 0;
while (_local5 < _arg2.length) {
_local4.m_vertices[_local5].x = (_arg2[_local5][0] / m_physScale);
_local4.m_vertices[_local5].y = (_arg2[_local5][1] / m_physScale);
_local5++;
};
ModelPolyReset(_arg1);
}
public function MakePoly(_arg1:Object):b2Body{
var _local2:b2BodyDef;
var _local3:b2PolyDef;
var _local4:int;
var _local5:b2Body;
_local2 = new b2BodyDef();
_local3 = new b2PolyDef();
_local3.vertexCount = _arg1.list.length;
_local4 = 0;
while (_local4 < _local3.vertexCount) {
_local3.vertices[_local4].Set((_arg1.list[_local4][0] / m_physScale), (_arg1.list[_local4][1] / m_physScale));
_local4++;
};
_local3.density = _arg1.density;
_local3.friction = _arg1.friction;
if (_arg1.restitution != null){
_local3.restitution = _arg1.restitution;
};
_local2.position.Set((_arg1.x / m_physScale), (_arg1.y / m_physScale));
_local2.rotation = _arg1.rotation;
_local2.AddShape(_local3);
_local5 = m_world.CreateBody(_local2);
return (_local5);
}
public function DelModel(_arg1:b2Body){
m_world.DestroyBody(_arg1);
}
public function MakeRevoJoint(_arg1:b2Body, _arg2:b2Body, _arg3, _arg4:Object):b2RevoluteJoint{
var _local5:b2RevoluteJointDef;
_local5 = new b2RevoluteJointDef();
_local5.anchorPoint.Set((_arg3.x / m_physScale), (_arg3.y / m_physScale));
if (_arg4.enableLimit != null){
_local5.enableLimit = _arg4.enableLimit;
};
if (_arg4.lowerAngle != null){
_local5.lowerAngle = (_arg4.lowerAngle / (180 / Math.PI));
};
if (_arg4.upperAngle != null){
_local5.upperAngle = (_arg4.upperAngle / (180 / Math.PI));
};
if (_arg4.enableMotor != null){
_local5.enableMotor = _arg4.enableMotor;
};
if (_arg4.motorTorque != null){
_local5.motorTorque = _arg4.motorTorque;
};
if (_arg4.motorSpeed != null){
_local5.motorSpeed = _arg4.motorSpeed;
};
_local5.body1 = _arg1;
_local5.body2 = _arg2;
return ((m_world.CreateJoint(_local5) as b2RevoluteJoint));
}
public function MakePriJoint(_arg1:b2Body, _arg2:b2Body, _arg3, _arg4:Number, _arg5:Number, _arg6:Object):b2PrismaticJoint{
var _local7:b2PrismaticJointDef;
_local7 = new b2PrismaticJointDef();
_local7.anchorPoint.Set((_arg3.x / m_physScale), (_arg3.y / m_physScale));
_local7.axis.Set(_arg4, _arg5);
if (_arg6.enableLimit != null){
_local7.enableLimit = _arg6.enableLimit;
};
if (_arg6.lowerTranslation != null){
_local7.lowerTranslation = _arg6.lowerTranslation;
};
if (_arg6.upperTranslation != null){
_local7.upperTranslation = _arg6.upperTranslation;
};
if (_arg6.enableMotor != null){
_local7.enableMotor = _arg6.enableMotor;
};
if (_arg6.motorForce != null){
_local7.motorForce = _arg6.motorForce;
};
if (_arg6.motorSpeed != null){
_local7.motorSpeed = _arg6.motorSpeed;
};
_local7.body1 = _arg1;
_local7.body2 = _arg2;
return ((m_world.CreateJoint(_local7) as b2PrismaticJoint));
}
private function ModelPolyReset(_arg1:b2Body):void{
var _local2:b2Shape;
var _local3:Object;
var _local4:b2PolyShape;
var _local5:int;
_local2 = _arg1.GetShapeList();
_local3 = {};
_local3.x = (_arg1.GetCenterPosition().x * m_physScale);
_local3.y = (_arg1.GetCenterPosition().y * m_physScale);
_local3.rotation = _arg1.GetRotation();
_local3.friction = _local2.m_friction;
_local3.density = _local2.m_density;
_local3.restitution = _local2.m_restitution;
_local4 = (_local2 as b2PolyShape);
_local3.list = [];
_local5 = 0;
while (_local5 < _local4.m_vertexCount) {
_local3.list.push([(_local4.m_vertices[_local5].x * m_physScale), (_local4.m_vertices[_local5].y * m_physScale)]);
_local5++;
};
DelModel(_arg1);
_arg1 = MakePoly(_local3);
}
public function MakeGearJoint(_arg1:b2Body, _arg2:b2Body, _arg3:b2Joint, _arg4:b2Joint, _arg5:Number):b2GearJoint{
var _local6:b2GearJointDef;
_local6 = new b2GearJointDef();
_local6.body1 = _arg1;
_local6.body2 = _arg2;
_local6.joint1 = _arg3;
_local6.joint2 = _arg4;
_local6.ratio = _arg5;
return ((m_world.CreateJoint(_local6) as b2GearJoint));
}
public function MakeDistJoint(_arg1:b2Body, _arg2:b2Body, _arg3, _arg4):b2DistanceJoint{
var _local5:b2DistanceJointDef;
_local5 = new b2DistanceJointDef();
_local5.body1 = _arg1;
_local5.body2 = _arg2;
_local5.anchorPoint1.Set((_arg3.x / m_physScale), (_arg3.y / m_physScale));
_local5.anchorPoint2.Set((_arg4.x / m_physScale), (_arg4.y / m_physScale));
return ((m_world.CreateJoint(_local5) as b2DistanceJoint));
}
public function SleepModel(_arg1:b2Body):void{
_arg1.m_flags = (_arg1.m_flags | b2Body.e_sleepFlag);
}
public function ScaleChange(_arg1:b2Body, _arg2:Number, _arg3:Number):void{
var _local4:b2Shape;
var _local5:b2PolyShape;
var _local6:int;
_local4 = _arg1.GetShapeList();
if (_local4.m_type == 0){
ModelCircleReset(_arg1, _arg2);
return;
};
_local5 = (_local4 as b2PolyShape);
_local6 = 0;
while (_local6 < _local5.m_vertexCount) {
_local5.m_vertices[_local6].x = (_local5.m_vertices[_local6].x * _arg2);
_local5.m_vertices[_local6].y = (_local5.m_vertices[_local6].y * _arg3);
_local6++;
};
ModelPolyReset(_arg1);
}
public function MakeBox(_arg1:Object):b2Body{
var _local2:b2BoxDef;
var _local3:b2BodyDef;
var _local4:b2Body;
_local2 = new b2BoxDef();
_local2.extents.Set((_arg1.width / m_physScale), (_arg1.height / m_physScale));
_local2.density = _arg1.density;
_local2.friction = _arg1.friction;
if (_arg1.restitution != null){
_local2.restitution = _arg1.restitution;
};
_local3 = new b2BodyDef();
_local3.AddShape(_local2);
_local3.position.Set((_arg1.x / m_physScale), (_arg1.y / m_physScale));
_local3.rotation = _arg1.rotation;
_local4 = m_world.CreateBody(_local3);
return (_local4);
}
public function MakeCircle(_arg1:Object):b2Body{
var _local2:b2BodyDef;
var _local3:b2CircleDef;
var _local4:b2Body;
_local2 = new b2BodyDef();
_local3 = new b2CircleDef();
_local3.density = _arg1.density;
_local3.radius = (_arg1.radius / m_physScale);
_local3.friction = _arg1.friction;
if (_arg1.restitution != null){
_local3.restitution = _arg1.restitution;
};
_local2.position.Set((_arg1.x / m_physScale), (_arg1.y / m_physScale));
_local2.rotation = _arg1.rotation;
_local2.AddShape(_local3);
_local4 = m_world.CreateBody(_local2);
return (_local4);
}
}
}//package Engine.Dynamics
Section 62
//FpsCounter (General.FpsCounter)
package General {
import flash.display.*;
import flash.text.*;
import flash.utils.*;
import flash.system.*;
public class FpsCounter extends Sprite {
var oldT:uint;
var mfpsCount:int;// = 0
var avgCount:int;// = 30
var avgCount2:int;// = 30
var textBox:TextField;
var mfpsCount2:int;// = 0
var textBox3:TextField;
var textBox2:TextField;
public function FpsCounter(){
mfpsCount = 0;
mfpsCount2 = 0;
avgCount = 30;
avgCount2 = 30;
super();
textBox = new TextField();
textBox.text = "fps average";
textBox.textColor = 11145540;
textBox.selectable = false;
textBox2 = new TextField();
textBox2.text = "fps (physics)";
textBox2.textColor = 11145540;
textBox2.selectable = false;
textBox2.y = 15;
textBox3 = new TextField();
textBox3.text = "memory wasted";
textBox3.textColor = 11145540;
textBox3.selectable = false;
textBox3.y = 30;
oldT = getTimer();
addChild(textBox);
addChild(textBox2);
addChild(textBox3);
}
public function updateEnd(){
}
public function updatePhys(_arg1:uint){
var _local2:uint;
var _local3:uint;
_local2 = getTimer();
_local3 = (_local2 - _arg1);
mfpsCount2 = (mfpsCount2 + _local3);
if (avgCount2 < 1){
textBox2.text = String((Math.round((1000 / (mfpsCount2 / 30))) + " fps (physics)"));
avgCount2 = 30;
mfpsCount2 = 0;
};
avgCount2--;
}
public function update(){
var _local1:uint;
var _local2:uint;
_local1 = getTimer();
_local2 = (_local1 - oldT);
mfpsCount = (mfpsCount + _local2);
if (avgCount < 1){
textBox.text = String((Math.round((1000 / (mfpsCount / 30))) + " fps average"));
avgCount = 30;
mfpsCount = 0;
};
avgCount--;
oldT = getTimer();
textBox3.text = (Math.round((System.totalMemory / (0x0400 * 0x0400))) + " MB used");
}
}
}//package General
Section 63
//FRateLimiter (General.FRateLimiter)
package General {
import flash.utils.*;
public class FRateLimiter {
static var newT:uint = oldT;
static var oldT:uint = getTimer();
public static function limitFrame(_arg1:uint){
var _local2:uint;
_local2 = (1000 / _arg1);
while (Math.abs((newT - oldT)) < _local2) {
newT = getTimer();
};
oldT = getTimer();
}
}
}//package General
Section 64
//Input (General.Input)
package General {
import flash.display.*;
import flash.events.*;
public class Input {
private static var keyArr:Array;
public static var ascii:Array;
public static var mouseX:Number = 0;
public static var mouseY:Number = 0;
private static var bufferSize:int;
public static var mouse:Sprite = new Sprite();
public static var mouseDown:Boolean = false;
public static var mouseReleased:Boolean = false;
public static var lastKey:int = 0;
public static var m_stageMc:Sprite;
private static var keyState:Array;
public static var timeSinceLastKey = 0;
private static var keyBuffer:Array;
public function Input(_arg1:Sprite){
var _local2:int;
var _local3:int;
super();
m_stageMc = _arg1;
ascii = new Array(222);
fillAscii();
keyState = new Array(222);
keyArr = new Array();
_local2 = 0;
while (_local2 < 222) {
keyState[_local2] = new int(0);
if (ascii[_local2] != undefined){
keyArr.push(_local2);
};
_local2++;
};
bufferSize = 5;
keyBuffer = new Array(bufferSize);
_local3 = 0;
while (_local3 < bufferSize) {
keyBuffer[_local3] = new Array(0, 0);
_local3++;
};
_arg1.stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPress, false, 0, true);
_arg1.stage.addEventListener(KeyboardEvent.KEY_UP, keyRelease, false, 0, true);
_arg1.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove, false, 0, true);
mouse.graphics.lineStyle(1, 0, 100);
mouse.graphics.moveTo(0, 0);
mouse.graphics.lineTo(0, 1);
}
public function mouseRelease(_arg1:MouseEvent){
mouseDown = false;
mouseReleased = true;
}
public function keyPress(_arg1:KeyboardEvent){
keyState[_arg1.keyCode] = Math.max(keyState[_arg1.keyCode], 1);
lastKey = _arg1.keyCode;
}
private function fillAscii(){
ascii[65] = "A";
ascii[66] = "B";
ascii[67] = "C";
ascii[68] = "D";
ascii[69] = "E";
ascii[70] = "F";
ascii[71] = "G";
ascii[72] = "H";
ascii[73] = "I";
ascii[74] = "J";
ascii[75] = "K";
ascii[76] = "L";
ascii[77] = "M";
ascii[78] = "N";
ascii[79] = "O";
ascii[80] = "P";
ascii[81] = "Q";
ascii[82] = "R";
ascii[83] = "S";
ascii[84] = "T";
ascii[85] = "U";
ascii[86] = "V";
ascii[87] = "W";
ascii[88] = "X";
ascii[89] = "Y";
ascii[90] = "Z";
ascii[48] = "0";
ascii[49] = "1";
ascii[50] = "2";
ascii[51] = "3";
ascii[52] = "4";
ascii[53] = "5";
ascii[54] = "6";
ascii[55] = "7";
ascii[56] = "8";
ascii[57] = "9";
ascii[32] = "Spacebar";
ascii[17] = "Ctrl";
ascii[16] = "Shift";
ascii[192] = "~";
ascii[38] = "up";
ascii[40] = "down";
ascii[37] = "left";
ascii[39] = "right";
ascii[96] = "Numpad 0";
ascii[97] = "Numpad 1";
ascii[98] = "Numpad 2";
ascii[99] = "Numpad 3";
ascii[100] = "Numpad 4";
ascii[101] = "Numpad 5";
ascii[102] = "Numpad 6";
ascii[103] = "Numpad 7";
ascii[104] = "Numpad 8";
ascii[105] = "Numpad 9";
ascii[111] = "Numpad /";
ascii[106] = "Numpad *";
ascii[109] = "Numpad -";
ascii[107] = "Numpad +";
ascii[110] = "Numpad .";
ascii[45] = "Insert";
ascii[46] = "Delete";
ascii[33] = "Page Up";
ascii[34] = "Page Down";
ascii[35] = "End";
ascii[36] = "Home";
ascii[112] = "F1";
ascii[113] = "F2";
ascii[114] = "F3";
ascii[115] = "F4";
ascii[116] = "F5";
ascii[117] = "F6";
ascii[118] = "F7";
ascii[119] = "F8";
ascii[188] = ",";
ascii[190] = ".";
ascii[186] = ";";
ascii[222] = "'";
ascii[219] = "[";
ascii[221] = "]";
ascii[189] = "-";
ascii[187] = "+";
ascii[220] = "\\";
ascii[191] = "/";
ascii[9] = "TAB";
ascii[8] = "Backspace";
}
public function mouseMove(_arg1:MouseEvent){
mouseX = (_arg1.stageX - m_stageMc.x);
mouseY = (_arg1.stageY - m_stageMc.y);
mouse.x = mouseX;
mouse.y = mouseY;
}
public function keyRelease(_arg1:KeyboardEvent){
var _local2:int;
keyState[_arg1.keyCode] = -1;
_local2 = (bufferSize - 1);
while (_local2 > 0) {
keyBuffer[_local2] = keyBuffer[(_local2 - 1)];
_local2--;
};
keyBuffer[0] = [_arg1.keyCode, 0];
}
public function getMouseXY_SKT():Array{
return ([mouseX, mouseY]);
}
public function mousePress(_arg1:MouseEvent){
mouseDown = true;
}
public static function getKeyHold(_arg1:int):int{
return (Math.max(0, keyState[_arg1]));
}
public static function update(){
var _local1:int;
var _local2:int;
_local1 = 0;
while (_local1 < keyArr.length) {
if (keyState[keyArr[_local1]] != 0){
var _local3 = keyState;
var _local4 = keyArr[_local1];
var _local5 = (_local3[_local4] + 1);
_local3[_local4] = _local5;
};
_local1++;
};
_local2 = 0;
while (_local2 < bufferSize) {
_local3 = keyBuffer[_local2];
_local4 = 1;
_local5 = (_local3[_local4] + 1);
_local3[_local4] = _local5;
_local2++;
};
mouseReleased = false;
}
public static function isKeyPressed(_arg1:int):Boolean{
timeSinceLastKey = 0;
return ((keyState[_arg1] == 1));
}
public static function isKeyDown(_arg1:int):Boolean{
return ((keyState[_arg1] > 0));
}
public static function getKeyString(_arg1:uint):String{
return (ascii[_arg1]);
}
public static function isKeyReleased(_arg1:int):Boolean{
return ((keyState[_arg1] == -1));
}
public static function isKeyInBuffer(_arg1:int, _arg2:int, _arg3:int){
return ((((keyBuffer[_arg2][0] == _arg1)) && ((keyBuffer[_arg2][1] <= _arg3))));
}
}
}//package General
Section 65
//gameDispMc_30 (hikkoshi01_fla.gameDispMc_30)
package hikkoshi01_fla {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.text.*;
import flash.utils.*;
import flash.geom.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.net.*;
import flash.printing.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class gameDispMc_30 extends MovieClip {
public var yardDisp:TextField;
public var scoreDisp:TextField;
public var startMc:MovieClip;
public function gameDispMc_30(){
addFrameScript(0, frame1);
}
function frame1(){
scoreDisp.text = String(Object(parent).gameScore);
startMc.throwCountDisp.gotoAndStop((Object(parent).throwCount + 1));
stop();
}
}
}//package hikkoshi01_fla
Section 66
//gameMc_8 (hikkoshi01_fla.gameMc_8)
package hikkoshi01_fla {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.text.*;
import flash.utils.*;
import flash.geom.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.net.*;
import flash.printing.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class gameMc_8 extends MovieClip {
public var m_physScale:int;
public var SeRoll:se_roll;
public var m_house_reizou;
public var seRollChannel:SoundChannel;
public var mc_oyabun:MovieClip;
public var bP;
public var j_touseki_omori;
public var m_house_tvashiL;
public var m_tBasePos:Object;
public var m_house_tvashiR;
public var m_house_bachanBon1;
public var endCheckTimer:Timer;
public var mc_omori:MovieClip;
public var mc_reizou:MovieClip;
public var j_flyingObj;
public var Rendering:Boolean;
public var m_house_bachanBon2;
public var tenmetsuTimer:Timer;
public var m_flyingObj;
public var j_kobun;
public var m_house_bachan;
public var mc_kobun:MovieClip;
public var fP;
public var mc_tousekiArm:MovieClip;
public var mc_houseWallL:MovieClip;
public var m_house_chabuL;
public var m_house_legL;
public var mc_houseWallR:MovieClip;
public var m_oyabun_body;
public var m_house_chabuR;
public var m_house_legR;
public var j_oyabun;
public var mc_bachan:MovieClip;
public var targetIconMc:MovieClip;
public var m_touseki_base;
public var mc_rope_omori:MovieClip;
public var m_touseki_omori;
public var m_oyabun_head;
public var m_house_tansu;
public var housePos:Object;
public var m_house_wallR;
public var flyingObjAssignmentList:Array;
public var m_house_wallL;
public var j_house_bachanHead;
public var mc_houseYuka:MovieClip;
public var MainMc:Main;
public var mc_rope_flying:MovieClip;
public var m_touseki_arm;
public var m_kobun_body;
public var flyingJointHosei:Array;
public var hukidashiMc:MovieClip;
public var j_house_tvashiL;
public var scrollVec:Point;
public var j_house_tvashiR;
public var mc_bg:MovieClip;
public var m_house_yane;
public var m_ground;
public var m_kobun_head;
public var bachanVoice:Boolean;
public var m_house_chabudai;
public var m_house_base;
public var m_house_daruma;
public var m_house_tv;
public var mc_yane:MovieClip;
public var throwCount:int;
public var mc_chabudai:MovieClip;
public var j_touseki_arm;
public var mc_houseLegL:MovieClip;
public var mc_tansu:MovieClip;
public var mc_houseLegR:MovieClip;
public var mc_daruma:MovieClip;
public var mc_touseki:MovieClip;
public var waitTime:int;
public var mc_tv:MovieClip;
public var m_house_bachanHead;
public var j_house_chabuL;
public var j_house_chabuR;
public var j_house_bachanBon1;
public var j_house_bachanBon2;
public function gameMc_8(){
addFrameScript(0, frame1);
}
public function tenmetsuTarget(_arg1:TimerEvent):void{
targetIconMc.alpha = (((tenmetsuTimer.currentCount % 2) * 0.5) + 0.3);
}
public function attachMcToModel(_arg1:MovieClip, _arg2):void{
var _local3:*;
_local3 = _arg2.GetCenterPosition();
_arg1.x = (_local3.x * m_physScale);
_arg1.y = (_local3.y * m_physScale);
_arg1.rotation = (_arg2.GetRotation() * (180 / Math.PI));
}
public function mouseDownSys(_arg1:MouseEvent):void{
var _local2:se_se1;
if (((!((j_flyingObj == null))) && (!((j_touseki_omori == null))))){
MainMc.m_currTest.m_world.DestroyJoint(j_flyingObj);
removeChild(mc_rope_flying);
mc_rope_flying = null;
j_flyingObj = null;
endCheckTimer.start();
seRollChannel = SeRoll.play(0, 20);
};
if (j_touseki_omori == null){
omoriSet();
mc_kobun.nextFrame();
_local2 = new se_se1();
_local2.play();
_local2 = null;
};
}
function frame1(){
throwCount = Object(parent).throwCount;
Rendering = false;
bachanVoice = false;
MainMc = new Main(this, "hoge", 2400, 1000, Rendering);
m_physScale = 30;
waitTime = 0;
parent.x = (800 - 2000);
scrollVec = new Point();
scrollVec.x = (((0 - parent.x) / 30) ^ 0);
scrollVec.y = (((0 - parent.y) / 30) ^ 0);
Object(parent).bgGrandMc.x = -(parent.x);
Object(parent).bgGrandMc.y = -(parent.y);
Object(parent).dispWindow.x = -(parent.x);
Object(parent).dispWindow.y = -(parent.y);
this.addEventListener(Event.ENTER_FRAME, gameStartEnterFrame, false, 0, true);
endCheckTimer = new Timer((1000 * 10), 1);
endCheckTimer.addEventListener(TimerEvent.TIMER, timeOut, false, 0, true);
m_ground = MainMc.m_currTest.m_world.m_groundBody;
m_touseki_base = MainMc.sktControl.MakeBox({x:320, y:980, rotation:0, width:60, height:15, density:0, friction:20});
m_tBasePos = {x:(m_touseki_base.GetCenterPosition().x * m_physScale), y:(m_touseki_base.GetCenterPosition().y * m_physScale)};
m_touseki_arm = MainMc.sktControl.MakeBox({x:m_tBasePos.x, y:(m_tBasePos.y - 230), rotation:0, width:30, height:6, density:50, friction:20});
j_touseki_arm = MainMc.sktControl.MakeRevoJoint(m_ground, m_touseki_arm, {x:(m_touseki_arm.GetCenterPosition().x * m_physScale), y:(m_touseki_arm.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:-30, upperAngle:270, enableMotor:false, motorTorque:300, motorSpeed:500});
mc_oyabun.x = (m_tBasePos.x + 200);
mc_oyabun.y = (m_tBasePos.y - 35);
mc_kobun.x = (m_tBasePos.x - 80);
mc_kobun.y = (m_tBasePos.y - 10);
housePos = {x:1772, y:950};
m_house_base = MainMc.sktControl.MakeBox({x:housePos.x, y:housePos.y, rotation:0, width:200, height:10, density:2, friction:20});
MainMc.sktControl.SleepModel(m_house_base);
m_house_legL = MainMc.sktControl.MakeBox({x:(housePos.x - 170), y:(housePos.y + 28), rotation:0, width:6, height:18, density:2, friction:20});
m_house_legR = MainMc.sktControl.MakeBox({x:(housePos.x + 170), y:(housePos.y + 28), rotation:0, width:6, height:18, density:2, friction:20});
MainMc.sktControl.SleepModel(m_house_legL);
MainMc.sktControl.SleepModel(m_house_legR);
m_house_wallR = MainMc.sktControl.MakeBox({x:(housePos.x + 170), y:(housePos.y - 160), rotation:0, width:6, height:150, density:2, friction:20});
m_house_wallL = MainMc.sktControl.MakeBox({x:(housePos.x - 166), y:(housePos.y - 278), rotation:0, width:6, height:34, density:2, friction:20});
MainMc.sktControl.SleepModel(m_house_wallR);
MainMc.sktControl.SleepModel(m_house_wallL);
m_house_yane = MainMc.sktControl.MakePoly({x:housePos.x, y:(housePos.y - 344), rotation:0, density:2, friction:20, list:[[86, -34], [210, 34], [-200, 34], [-86, -34]]});
MainMc.sktControl.SleepModel(m_house_yane);
mc_chabudai.visible = false;
mc_reizou.visible = false;
mc_tansu.visible = false;
mc_tv.visible = false;
mc_daruma.visible = false;
if (throwCount >= 0){
m_house_chabudai = MainMc.sktControl.MakeBox({x:(housePos.x - 22), y:(housePos.y - 46), rotation:0, width:48, height:4, density:2, friction:20});
m_house_chabuL = MainMc.sktControl.MakeBox({x:((housePos.x - 22) - 36), y:((housePos.y - 46) + 20), rotation:0, width:3, height:16, density:2, friction:20});
m_house_chabuR = MainMc.sktControl.MakeBox({x:((housePos.x - 22) + 36), y:((housePos.y - 46) + 20), rotation:0, width:3, height:16, density:2, friction:20});
MainMc.sktControl.SleepModel(m_house_chabudai);
MainMc.sktControl.SleepModel(m_house_chabuL);
MainMc.sktControl.SleepModel(m_house_chabuR);
j_house_chabuL = MainMc.sktControl.MakeRevoJoint(m_house_chabudai, m_house_chabuL, {x:(m_house_chabuL.GetCenterPosition().x * m_physScale), y:(m_house_chabuL.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
j_house_chabuR = MainMc.sktControl.MakeRevoJoint(m_house_chabudai, m_house_chabuR, {x:(m_house_chabuR.GetCenterPosition().x * m_physScale), y:(m_house_chabuR.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
mc_chabudai.visible = true;
};
if (throwCount >= 1){
m_house_reizou = MainMc.sktControl.MakeBox({x:(housePos.x + 132), y:(housePos.y - 48), rotation:0, width:24, height:40, density:0.8, friction:20, restitution:0.2});
MainMc.sktControl.SleepModel(m_house_reizou);
mc_reizou.visible = true;
};
if (throwCount >= 2){
m_house_tansu = MainMc.sktControl.MakeBox({x:(housePos.x + 70), y:(housePos.y - 64), rotation:0, width:34, height:54, density:0.35, friction:20});
MainMc.sktControl.SleepModel(m_house_tansu);
mc_tansu.visible = true;
};
if (throwCount >= 3){
m_house_tv = MainMc.sktControl.MakeBox({x:(housePos.x - 124), y:(housePos.y - 58), rotation:0, width:22, height:24, density:1, friction:20});
m_house_tvashiR = MainMc.sktControl.MakeBox({x:((housePos.x - 124) + 15), y:((housePos.y - 58) + 36), rotation:0, width:2, height:12, density:1, friction:20});
m_house_tvashiL = MainMc.sktControl.MakeBox({x:((housePos.x - 124) - 15), y:((housePos.y - 58) + 36), rotation:0, width:2, height:12, density:1, friction:20});
MainMc.sktControl.SleepModel(m_house_tv);
MainMc.sktControl.SleepModel(m_house_tvashiR);
MainMc.sktControl.SleepModel(m_house_tvashiL);
j_house_tvashiL = MainMc.sktControl.MakeRevoJoint(m_house_tv, m_house_tvashiL, {x:(m_house_tvashiL.GetCenterPosition().x * m_physScale), y:(m_house_tvashiL.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
j_house_tvashiR = MainMc.sktControl.MakeRevoJoint(m_house_tv, m_house_tvashiR, {x:(m_house_tvashiR.GetCenterPosition().x * m_physScale), y:(m_house_tvashiR.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
mc_tv.visible = true;
};
if (throwCount >= 4){
m_house_daruma = MainMc.sktControl.MakeCircle({x:(housePos.x + 88), y:(housePos.y - 136), rotation:0, radius:20, density:2, friction:2, restitution:0.4});
MainMc.sktControl.SleepModel(m_house_daruma);
mc_daruma.visible = true;
};
m_house_bachan = MainMc.sktControl.MakeCircle({x:(housePos.x - 4), y:(housePos.y - 68), rotation:0, radius:20, density:2, friction:2});
m_house_bachanHead = MainMc.sktControl.MakeCircle({x:(housePos.x - 20), y:(housePos.y - 100), rotation:0, radius:16, density:2, friction:2});
m_house_bachanBon1 = MainMc.sktControl.MakeCircle({x:(housePos.x - 16), y:(housePos.y - 128), rotation:0, radius:10, density:2, friction:2});
m_house_bachanBon2 = MainMc.sktControl.MakeCircle({x:(housePos.x + 4), y:(housePos.y - 116), rotation:0, radius:10, density:2, friction:2});
MainMc.sktControl.SleepModel(m_house_bachan);
MainMc.sktControl.SleepModel(m_house_bachanHead);
MainMc.sktControl.SleepModel(m_house_bachanBon1);
MainMc.sktControl.SleepModel(m_house_bachanBon2);
j_house_bachanHead = MainMc.sktControl.MakeRevoJoint(m_house_bachan, m_house_bachanHead, {x:(m_house_bachanHead.GetCenterPosition().x * m_physScale), y:(m_house_bachanHead.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
j_house_bachanBon1 = MainMc.sktControl.MakeRevoJoint(m_house_bachan, m_house_bachanBon1, {x:(m_house_bachanBon1.GetCenterPosition().x * m_physScale), y:(m_house_bachanBon1.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
j_house_bachanBon2 = MainMc.sktControl.MakeRevoJoint(m_house_bachan, m_house_bachanBon2, {x:(m_house_bachanBon2.GetCenterPosition().x * m_physScale), y:(m_house_bachanBon2.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
if (throwCount == 0){
bP = m_house_bachan.GetCenterPosition();
bP.x = (bP.x + (80 / m_physScale));
bP.y = (bP.y + (40 / m_physScale));
m_house_bachan.SetCenterPosition(bP, 0);
};
flyingObjAssignmentList = [m_house_chabudai, m_house_reizou, m_house_tansu, m_house_tv, m_house_daruma];
m_flyingObj = flyingObjAssignmentList[throwCount];
targetIconMc.x = (m_flyingObj.GetCenterPosition().x * m_physScale);
targetIconMc.y = (m_flyingObj.GetCenterPosition().y * m_physScale);
targetIconMc.gotoAndStop((throwCount + 1));
fP = MainMc.sktControl.GetB2Vec2();
fP.x = ((m_tBasePos.x - 220) / m_physScale);
fP.y = ((m_tBasePos.y - 180) / m_physScale);
m_flyingObj.SetCenterPosition(fP, 0);
flyingJointHosei = [{x:30, y:0}, {x:0, y:40}, {x:0, y:40}, {x:0, y:20}, {x:0, y:10}];
j_flyingObj = MainMc.sktControl.MakeDistJoint(m_touseki_arm, m_flyingObj, {x:((m_touseki_arm.GetCenterPosition().x * m_physScale) - 250), y:(m_touseki_arm.GetCenterPosition().y * m_physScale)}, {x:((m_flyingObj.GetCenterPosition().x * m_physScale) + flyingJointHosei[throwCount].x), y:((m_flyingObj.GetCenterPosition().y * m_physScale) + flyingJointHosei[throwCount].y)});
targetIconMc.alpha = 0.3;
tenmetsuTimer = new Timer(500, 0);
tenmetsuTimer.addEventListener(TimerEvent.TIMER, tenmetsuTarget, false, 0, true);
tenmetsuTimer.start();
SeRoll = new se_roll();
stop();
}
public function attachRopeMc(_arg1:MovieClip, _arg2, _arg3):void{
var _local4:Number;
var _local5:Number;
_local4 = getDistance(_arg2.x, _arg2.y, _arg3.x, _arg3.y);
_local5 = getRad(_arg2.x, _arg2.y, _arg3.x, _arg3.y);
_arg1.scaleX = (_local4 * 0.01);
_arg1.rotation = _local5;
_arg1.x = _arg2.x;
_arg1.y = _arg2.y;
}
public function getRad(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return (((Math.atan2((_arg4 - _arg2), (_arg3 - _arg1)) * 180) / Math.PI));
}
public function dispTargetDistance():Number{
var _local1:Object;
var _local2:Object;
var _local3:Number;
_local1 = {x:(m_flyingObj.GetCenterPosition().x * m_physScale), y:(m_flyingObj.GetCenterPosition().y * m_physScale)};
_local2 = {x:targetIconMc.x, y:targetIconMc.y};
_local3 = (getDistance(_local1.x, _local1.y, _local2.x, _local2.y) * 0.01);
return (_local3);
}
public function omoriSet():void{
m_touseki_omori = MainMc.sktControl.MakeBox({x:(m_tBasePos.x + 50), y:(m_tBasePos.y - 200), rotation:0, width:30, height:25, density:20, friction:20});
j_touseki_omori = MainMc.sktControl.MakeDistJoint(m_touseki_arm, m_touseki_omori, {x:((m_touseki_arm.GetCenterPosition().x * m_physScale) + 60), y:((m_touseki_arm.GetCenterPosition().y * m_physScale) - 40)}, {x:(m_touseki_omori.GetCenterPosition().x * m_physScale), y:((m_touseki_omori.GetCenterPosition().y * m_physScale) - 20)});
m_oyabun_body = MainMc.sktControl.MakeCircle({x:(m_tBasePos.x + 200), y:(m_tBasePos.y - 35), rotation:0, radius:53, density:2, friction:20});
m_oyabun_head = MainMc.sktControl.MakeBox({x:((m_oyabun_body.GetCenterPosition().x * m_physScale) - 5), y:((m_oyabun_body.GetCenterPosition().y * m_physScale) - 65), rotation:((-14 / 180) * Math.PI), width:20, height:30, density:2, friction:20});
MainMc.sktControl.SleepModel(m_oyabun_body);
MainMc.sktControl.SleepModel(m_oyabun_head);
j_oyabun = MainMc.sktControl.MakeRevoJoint(m_oyabun_body, m_oyabun_head, {x:(m_oyabun_body.GetCenterPosition().x * m_physScale), y:(m_oyabun_body.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
m_kobun_body = MainMc.sktControl.MakeBox({x:(m_tBasePos.x - 80), y:(m_tBasePos.y - 10), rotation:((-14 / 180) * Math.PI), width:15, height:24, density:2, friction:20});
m_kobun_head = MainMc.sktControl.MakeCircle({x:((m_kobun_body.GetCenterPosition().x * m_physScale) - 21), y:((m_kobun_body.GetCenterPosition().y * m_physScale) - 33), rotation:0, radius:17, density:2, friction:20});
MainMc.sktControl.SleepModel(m_kobun_body);
MainMc.sktControl.SleepModel(m_kobun_head);
j_kobun = MainMc.sktControl.MakeRevoJoint(m_kobun_body, m_kobun_head, {x:(m_kobun_body.GetCenterPosition().x * m_physScale), y:(m_kobun_body.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
}
public function gameStartEnterFrame(_arg1:Event):void{
var _local2:int;
var _local3:se_jingle;
_local2 = 80;
mcAttach();
hukidashiMc.x = (mc_bachan.x + 20);
hukidashiMc.y = (mc_bachan.y - 40);
hukidashiMc.gotoAndStop((throwCount + 1));
mc_bg.x = mc_houseYuka.x;
mc_bg.y = mc_houseYuka.y;
if (waitTime == (_local2 * 0.5)){
_local3 = new se_jingle();
_local3.play();
};
if (++waitTime < _local2){
return;
};
parent.x = Math.min((parent.x + scrollVec.x), 0);
parent.y = Math.min((parent.y + scrollVec.y), 0);
Object(parent).bgGrandMc.x = -(parent.x);
Object(parent).bgGrandMc.y = -(parent.y);
Object(parent).dispWindow.x = -(parent.x);
Object(parent).dispWindow.y = -(parent.y);
if (waitTime < (_local2 + 40)){
return;
};
hukidashiMc.visible = false;
this.removeEventListener(Event.ENTER_FRAME, gameStartEnterFrame, false);
this.addEventListener(Event.ENTER_FRAME, EnterFrame, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownSys, false, 0, true);
Object(parent).dispWindow.gotoAndStop("dispB");
}
public function timeOut(_arg1:TimerEvent):void{
endSys();
}
public function endGame():void{
this.removeEventListener(Event.ENTER_FRAME, EnterFrame);
stage.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownSys);
if (MainMc == null){
return;
};
MainMc.removeEventListener(Event.ENTER_FRAME, MainMc.update);
MainMc.graphics.clear();
MainMc.m_currTest = null;
MainMc = null;
}
public function getDistance(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Number{
return (Math.sqrt((Math.pow((_arg4 - _arg2), 2) + Math.pow((_arg3 - _arg1), 2))));
}
public function mcAttach():void{
attachMcToModel(mc_touseki, m_touseki_base);
attachMcToModel(mc_tousekiArm, m_touseki_arm);
attachMcToModel(mc_bachan, m_house_bachan);
attachMcToModel(mc_houseYuka, m_house_base);
attachMcToModel(mc_houseWallR, m_house_wallR);
attachMcToModel(mc_houseWallL, m_house_wallL);
attachMcToModel(mc_houseLegR, m_house_legR);
attachMcToModel(mc_houseLegL, m_house_legL);
attachMcToModel(mc_yane, m_house_yane);
if (throwCount >= 0){
attachMcToModel(mc_chabudai, m_house_chabudai);
};
if (throwCount >= 1){
attachMcToModel(mc_reizou, m_house_reizou);
};
if (throwCount >= 2){
attachMcToModel(mc_tansu, m_house_tansu);
};
if (throwCount >= 3){
attachMcToModel(mc_tv, m_house_tv);
};
if (throwCount >= 4){
attachMcToModel(mc_daruma, m_house_daruma);
};
if (m_touseki_omori != null){
attachMcToModel(mc_omori, m_touseki_omori);
attachRopeMc(mc_rope_omori, {x:(j_touseki_omori.GetAnchor1().x * m_physScale), y:(j_touseki_omori.GetAnchor1().y * m_physScale)}, {x:(j_touseki_omori.GetAnchor2().x * m_physScale), y:(j_touseki_omori.GetAnchor2().y * m_physScale)});
attachMcToModel(mc_oyabun, m_oyabun_body);
attachMcToModel(mc_kobun, m_kobun_body);
};
if (j_flyingObj != null){
attachRopeMc(mc_rope_flying, {x:(j_flyingObj.GetAnchor1().x * m_physScale), y:(j_flyingObj.GetAnchor1().y * m_physScale)}, {x:(j_flyingObj.GetAnchor2().x * m_physScale), y:(j_flyingObj.GetAnchor2().y * m_physScale)});
};
}
public function EnterFrame(_arg1:Event):void{
var _local2:se_bachan;
var _local3:se_se3;
parent.y = Math.min(Math.max((700 - (m_flyingObj.GetCenterPosition().y * m_physScale)), 0), 500);
parent.x = Math.max(Math.min((500 - (m_flyingObj.GetCenterPosition().x * m_physScale)), 0), (800 - 2000));
Object(parent).bgGrandMc.x = -(parent.x);
Object(parent).bgGrandMc.y = -(parent.y);
Object(parent).dispWindow.x = -(parent.x);
Object(parent).dispWindow.y = -(parent.y);
mcAttach();
mc_bg.x = mc_houseYuka.x;
mc_bg.y = mc_houseYuka.y;
mc_bg.rotation = mc_houseYuka.rotation;
if ((((mc_bg.y > 980)) && ((mc_bg.currentFrame == 1)))){
mc_bg.play();
};
Object(parent).dispWindow.yardDisp.text = String(dispTargetDistance());
if (((m_flyingObj.IsSleeping()) && ((j_flyingObj == null)))){
endSys();
return;
};
if (((!((m_flyingObj.m_contactList == null))) && ((j_flyingObj == null)))){
if (bachanVoice){
} else {
if ((((((((m_flyingObj.m_contactList.other == m_house_bachan)) || ((m_flyingObj.m_contactList.other == m_house_bachanHead)))) || ((m_flyingObj.m_contactList.other == m_house_bachanBon1)))) || ((m_flyingObj.m_contactList.other == m_house_bachanBon2)))){
_local2 = new se_bachan();
_local2.play();
_local2 = null;
bachanVoice = true;
};
};
if (seRollChannel != null){
seRollChannel.stop();
SeRoll = null;
seRollChannel = null;
_local3 = new se_se3();
_local3.play();
_local3 = null;
};
};
}
public function endSys():void{
var _local1:se_result;
if (Object(parent).dispWindow.currentLabel == "result"){
return;
};
endCheckTimer.stop();
endCheckTimer.removeEventListener(TimerEvent.TIMER, timeOut);
endCheckTimer = null;
Object(parent).dispWindow.gotoAndStop("result");
this.removeEventListener(Event.ENTER_FRAME, gameStartEnterFrame);
_local1 = new se_result();
_local1.play();
if ((parent.x + mc_bachan.x) > 950){
hukidashiMc.boardMc.scaleX = (hukidashiMc.boardMc.scaleX * -1);
hukidashiMc.x = (900 - parent.x);
hukidashiMc.y = ((300 + (1000 - stage.stageHeight)) - parent.y);
hukidashiMc.gotoAndStop(15);
hukidashiMc.visible = true;
} else {
hukidashiMc.x = (mc_bachan.x + 30);
hukidashiMc.y = (mc_bachan.y - 40);
};
mc_oyabun.nextFrame();
mc_kobun.nextFrame();
}
}
}//package hikkoshi01_fla
Section 67
//hukidashi_26 (hikkoshi01_fla.hukidashi_26)
package hikkoshi01_fla {
import flash.display.*;
public dynamic class hukidashi_26 extends MovieClip {
public var boardMc:MovieClip;
public function hukidashi_26(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package hikkoshi01_fla
Section 68
//MainTimeline (hikkoshi01_fla.MainTimeline)
package hikkoshi01_fla {
import flash.display.*;
public dynamic class MainTimeline extends MovieClip {
public var dispWindow:MovieClip;
public var gameMc:MovieClip;
public var bgMc:MovieClip;
public var bgGrandMc:MovieClip;
public var totalStats:Object;
public var throwCount:int;
public var gameScore:int;
public function MainTimeline(){
addFrameScript(1, frame2, 2, frame3, 3, frame4, 4, frame5, 5, frame6);
}
function frame3(){
throwCount = 0;
gameScore = 0;
totalStats = {distance:0, house:0, bachan:0};
}
function frame6(){
throwCount++;
if (throwCount == 5){
return;
};
gotoAndStop("game");
}
function frame5(){
stop();
}
function frame4(){
scoreInit();
stop();
}
function frame2(){
if (loaderInfo.bytesLoaded == loaderInfo.bytesTotal){
gotoAndStop("init");
} else {
gotoAndPlay(1);
};
}
public function scoreInit():void{
throwCount = 0;
gameScore = 0;
totalStats = {distance:0, house:0, bachan:0};
}
}
}//package hikkoshi01_fla
Section 69
//mc_bg_10 (hikkoshi01_fla.mc_bg_10)
package hikkoshi01_fla {
import flash.display.*;
public dynamic class mc_bg_10 extends MovieClip {
public function mc_bg_10(){
addFrameScript(0, frame1, 55, frame56);
}
function frame1(){
stop();
}
function frame56(){
stop();
}
}
}//package hikkoshi01_fla
Section 70
//mc_kobun_9 (hikkoshi01_fla.mc_kobun_9)
package hikkoshi01_fla {
import flash.display.*;
public dynamic class mc_kobun_9 extends MovieClip {
public function mc_kobun_9(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package hikkoshi01_fla
Section 71
//mc_oyabun_28 (hikkoshi01_fla.mc_oyabun_28)
package hikkoshi01_fla {
import flash.display.*;
public dynamic class mc_oyabun_28 extends MovieClip {
public function mc_oyabun_28(){
addFrameScript(0, frame1);
}
function frame1(){
stop();
}
}
}//package hikkoshi01_fla
Section 72
//resultDisp_33 (hikkoshi01_fla.resultDisp_33)
package hikkoshi01_fla {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.text.*;
import flash.utils.*;
import flash.geom.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.net.*;
import flash.printing.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class resultDisp_33 extends MovieClip {
public var distance:Number;
public var getScore:int;
public var distIndexNum:int;
public var stockScore:int;
public var rankHouseMc:MovieClip;
public var se1:se_hi1;
public var se3:se_hi3;
public var categoryScore:int;
public var scoreDisp:TextField;
public var se2:se_hi2;
public var mc_houseYuka:MovieClip;
public var rankDistMc:MovieClip;
public var mc_flyingObj:MovieClip;
public var distList:Array;
public var bRadList:Array;
public var bachanIndexNum:int;
public var gameMc:MovieClip;
public var addFrameScore:int;
public var oya:Object;
public var greatEffectMc:MovieClip;
public var houseIndexNum:int;
public var houseTotalRad:Number;
public var mc_houseWallR:MovieClip;
public var mc_houseWallL:MovieClip;
public var rankBachanMc:MovieClip;
public var mc_houseLegL:MovieClip;
public var mc_yane:MovieClip;
public var mc_bachan:MovieClip;
public var mc_houseLegR:MovieClip;
public var targetIconMc:MovieClip;
public var hRadList:Array;
public function resultDisp_33(){
addFrameScript(0, frame1, 23, frame24, 49, frame50, 75, frame76, 118, frame119);
}
function frame50(){
houseTotalRad = (((Math.abs(mc_yane.rotation) + Math.abs(mc_houseYuka.rotation)) + Math.abs(mc_houseWallR.rotation)) + Math.abs(mc_houseWallL.rotation));
hRadList = [0.1, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190];
houseIndexNum = listIndex(houseTotalRad, hRadList);
rankHouseMc.gotoAndStop((houseIndexNum + 1));
oya.totalStats.house = (oya.totalStats.house + houseTotalRad);
categoryScore = 0;
scoreDisp.text = String(categoryScore);
addScore((houseTotalRad ^ 0));
se2 = new se_hi2();
se2.play();
stop();
}
public function addScEnterFrame(_arg1:Event):void{
oya.gameScore = (oya.gameScore + Math.min(addFrameScore, stockScore));
categoryScore = (categoryScore + Math.min(addFrameScore, stockScore));
stockScore = (stockScore - addFrameScore);
Object(parent).scoreDisp.text = String(oya.gameScore);
scoreDisp.text = String(categoryScore);
if (stockScore > 0){
return;
};
stockScore = 0;
this.removeEventListener(Event.ENTER_FRAME, addScEnterFrame);
play();
}
function frame76(){
bRadList = [(0 + 11.25), (22.5 + 11.25), (45 + 11.25), (67.5 + 11.25), (90 + 11.25), (112.5 + 11.25), (135 + 11.25), (157.5 + 11.25)];
bachanIndexNum = listIndex(Math.abs(mc_bachan.rotation), bRadList);
rankBachanMc.gotoAndStop((bachanIndexNum + 1));
if ((((bachanIndexNum == 4)) && ((mc_bachan.rotation > 0)))){
rankBachanMc.gotoAndStop(11);
};
if ((((bachanIndexNum == 8)) && ((houseIndexNum == 12)))){
rankBachanMc.gotoAndStop(10);
};
oya.totalStats.bachan = (oya.totalStats.bachan + Math.abs(mc_bachan.rotation));
categoryScore = 0;
scoreDisp.text = String(categoryScore);
getScore = ((500 - Math.abs(mc_bachan.rotation)) ^ 0);
addScore(getScore);
se3 = new se_hi3();
se3.play();
stop();
}
public function addScore(_arg1:int):void{
stockScore = (stockScore + _arg1);
addFrameScore = Math.max(Math.floor((stockScore / 30)), 1);
this.addEventListener(Event.ENTER_FRAME, addScEnterFrame, false, 0, true);
}
function frame24(){
distList = [0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 3, 4, 5, 6, 7];
distIndexNum = listIndex(distance, distList);
rankDistMc.gotoAndStop((distIndexNum + 1));
oya.totalStats.distance = (oya.totalStats.distance + distance);
categoryScore = 0;
scoreDisp.text = String(categoryScore);
getScore = (((20 - distance) * 100) ^ 0);
getScore = (getScore + (((Math.max((10 - distIndexNum), 0) * 0.05) * getScore) ^ 0));
addScore(getScore);
gameMc.hukidashiMc.gotoAndStop(Math.max(Math.min((distIndexNum - 8), 15), 6));
gameMc.hukidashiMc.visible = true;
se1 = new se_hi1();
se1.play();
if (distance >= 0.4){
greatEffectMc.visible = false;
};
stop();
}
function frame119(){
gameMc.endGame();
if (gameMc.throwCount == 4){
Object(parent).gotoAndStop("total");
} else {
oya.play();
};
}
public function listIndex(_arg1:Number, _arg2:Array):int{
var _local3:Array;
_arg2.unshift(_arg1);
_local3 = _arg2.sort((Array.NUMERIC | Array.RETURNINDEXEDARRAY));
return (_local3.indexOf(0));
}
function frame1(){
oya = Object(parent.parent);
gameMc = oya.gameMc;
mc_flyingObj = gameMc.mc_flyingObj;
targetIconMc = gameMc.targetIconMc;
distance = gameMc.dispTargetDistance();
mc_yane = gameMc.mc_yane;
mc_houseLegL = gameMc.mc_houseLegL;
mc_houseLegR = gameMc.mc_houseLegR;
mc_houseYuka = gameMc.mc_houseYuka;
mc_houseWallR = gameMc.mc_houseWallR;
mc_houseWallL = gameMc.mc_houseWallL;
mc_bachan = gameMc.mc_bachan;
stockScore = 0;
categoryScore = 0;
}
}
}//package hikkoshi01_fla
Section 73
//sktRogo_1 (hikkoshi01_fla.sktRogo_1)
package hikkoshi01_fla {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.text.*;
import flash.utils.*;
import flash.geom.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.net.*;
import flash.printing.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class sktRogo_1 extends MovieClip {
public function sktRogo_1(){
addFrameScript(96, frame97);
}
function frame97(){
stop();
Object(parent).gotoAndStop("title");
}
}
}//package hikkoshi01_fla
Section 74
//throwStart_31 (hikkoshi01_fla.throwStart_31)
package hikkoshi01_fla {
import flash.display.*;
public dynamic class throwStart_31 extends MovieClip {
public var throwCountDisp:MovieClip;
public function throwStart_31(){
addFrameScript(0, frame1, 19, frame20);
}
function frame1(){
gotoAndPlay(2);
}
function frame20(){
stop();
}
}
}//package hikkoshi01_fla
Section 75
//title_box2d_2 (hikkoshi01_fla.title_box2d_2)
package hikkoshi01_fla {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.text.*;
import flash.utils.*;
import flash.geom.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.net.*;
import flash.printing.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class title_box2d_2 extends MovieClip {
public var m_physScale:int;
public var m_text10;
public var m_text12;
public var m_text13;
public var m_text14;
public var m_text15;
public var m_text16;
public var m_text17;
public var m_text19;
public var m_text18;
public var m_text11;
public var m_text22;
public var m_text26;
public var m_text21;
public var m_text24;
public var m_text1;
public var m_text6;
public var m_text7;
public var m_text8;
public var m_text3;
public var m_text5;
public var m_text20;
public var m_text34;
public var m_text9;
public var m_text2;
public var m_text30;
public var m_text32;
public var m_text28;
public var m_text29;
public var m_text36;
public var m_text37;
public var m_text38;
public var m_text4;
public var m_text33;
public var m_text25;
public var m_text35;
public var m_text27;
public var m_text39;
public var m_text31;
public var m_text40;
public var m_text41;
public var j_text1;
public var j_text2;
public var j_text3;
public var m_text23;
public var m_text43;
public var j_text4;
public var m_text42;
public var mc_text0:MovieClip;
public var mc_text1:MovieClip;
public var mc_text3:MovieClip;
public var mc_text4:MovieClip;
public var mc_text5:MovieClip;
public var mc_text7:MovieClip;
public var mc_text8:MovieClip;
public var mc_text9:MovieClip;
public var mc_text6:MovieClip;
public var mc_text2:MovieClip;
public var mc_text10:MovieClip;
public var mc_text11:MovieClip;
public var mc_text12:MovieClip;
public var mc_text13:MovieClip;
public var mc_text14:MovieClip;
public var mc_text15:MovieClip;
public var mc_text16:MovieClip;
public var mc_text17:MovieClip;
public var mc_text18:MovieClip;
public var mc_text19:MovieClip;
public var endCheckTimer:Timer;
public var mc_text21:MovieClip;
public var mc_text22:MovieClip;
public var mc_text23:MovieClip;
public var mc_text24:MovieClip;
public var mc_text25:MovieClip;
public var mc_text26:MovieClip;
public var mc_text20:MovieClip;
public var mc_text28:MovieClip;
public var mc_text29:MovieClip;
public var j_btn;
public var mc_text30:MovieClip;
public var MainMc:Main;
public var m_base;
public var mc_text27:MovieClip;
public var j_text10;
public var j_text19;
public var m_btn;
public var m_ground;
public var j_text22;
public var j_text24;
public var j_text26;
public var j_text31;
public var basePos:Object;
public var j_text38;
public var startBtnMc:MovieClip;
public var j_text42;
public var j_text41;
public function title_box2d_2(){
addFrameScript(0, frame1, 24, frame25);
}
public function attachMcToModel(_arg1:MovieClip, _arg2):void{
var _local3:*;
_local3 = _arg2.GetCenterPosition();
_arg1.x = (_local3.x * m_physScale);
_arg1.y = (_local3.y * m_physScale);
_arg1.rotation = (_arg2.GetRotation() * (180 / Math.PI));
}
function frame1(){
MainMc = new Main(this, "hoge", 1000, 500, false);
m_physScale = 30;
m_ground = MainMc.m_currTest.m_world.m_groundBody;
m_base = MainMc.sktControl.MakeBox({x:477, y:100, rotation:((3 / 180) * Math.PI), width:7, height:20, density:2, friction:20});
MainMc.sktControl.SleepModel(m_base);
basePos = {x:(m_base.GetCenterPosition().x * m_physScale), y:(m_base.GetCenterPosition().y * m_physScale)};
m_text1 = MainMc.sktControl.MakeBox({x:basePos.x, y:(basePos.y - 30), rotation:((-40 / 180) * Math.PI), width:9, height:12, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text1);
m_text2 = MainMc.sktControl.MakeBox({x:(basePos.x + 2), y:(basePos.y + 30), rotation:((-20 / 180) * Math.PI), width:7, height:14, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text2);
m_text3 = MainMc.sktControl.MakeBox({x:(basePos.x + 20), y:(basePos.y + 42), rotation:((90 / 180) * Math.PI), width:7, height:18, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text3);
m_text4 = MainMc.sktControl.MakeBox({x:(basePos.x + 50), y:(basePos.y + 32), rotation:((50 / 180) * Math.PI), width:7, height:18, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text4);
j_text1 = MainMc.sktControl.MakeRevoJoint(m_base, m_text1, {x:(m_text1.GetCenterPosition().x * m_physScale), y:(m_text1.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
j_text2 = MainMc.sktControl.MakeRevoJoint(m_base, m_text2, {x:(m_text2.GetCenterPosition().x * m_physScale), y:(m_text2.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
j_text3 = MainMc.sktControl.MakeRevoJoint(m_text2, m_text3, {x:(m_text3.GetCenterPosition().x * m_physScale), y:(m_text3.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
j_text4 = MainMc.sktControl.MakeRevoJoint(m_text3, m_text4, {x:(m_text4.GetCenterPosition().x * m_physScale), y:(m_text4.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
m_text5 = MainMc.sktControl.MakeBox({x:(basePos.x - 230), y:(basePos.y - 38), rotation:0, width:17, height:1, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text5);
m_text6 = MainMc.sktControl.MakeBox({x:(basePos.x - 222), y:(basePos.y - 12), rotation:0, width:10, height:1, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text6);
m_text7 = MainMc.sktControl.MakeBox({x:(basePos.x - 222), y:(basePos.y + 12), rotation:0, width:10, height:1, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text7);
m_text8 = MainMc.sktControl.MakeBox({x:(basePos.x - 207), y:(basePos.y - 24), rotation:0, width:7, height:18, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text8);
m_text9 = MainMc.sktControl.MakeBox({x:(basePos.x - 237), y:(basePos.y + 1), rotation:((5 / 180) * Math.PI), width:7, height:19, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text9);
m_text10 = MainMc.sktControl.MakeBox({x:(basePos.x - 209), y:(basePos.y + 28), rotation:((10 / 180) * Math.PI), width:7, height:22, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text10);
m_text11 = MainMc.sktControl.MakeBox({x:(basePos.x - 223), y:(basePos.y + 48), rotation:((80 / 180) * Math.PI), width:7, height:14, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text11);
m_text12 = MainMc.sktControl.MakeBox({x:(basePos.x - 167), y:(basePos.y + 5), rotation:0, width:8, height:50, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text12);
j_text10 = MainMc.sktControl.MakeRevoJoint(m_text10, m_text11, {x:(m_text10.GetCenterPosition().x * m_physScale), y:(m_text10.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
m_text13 = MainMc.sktControl.MakeBox({x:(basePos.x - 117), y:(basePos.y - 28), rotation:0, width:22, height:3, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text13);
m_text14 = MainMc.sktControl.MakeBox({x:(basePos.x - 117), y:(basePos.y - 8), rotation:0, width:26, height:3, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text14);
m_text15 = MainMc.sktControl.MakeBox({x:(basePos.x - 117), y:(basePos.y - 27), rotation:0, width:8, height:17, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text15);
m_text16 = MainMc.sktControl.MakeBox({x:(basePos.x - 105), y:(basePos.y + 12), rotation:0, width:10, height:3, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text16);
m_text17 = MainMc.sktControl.MakeBox({x:(basePos.x - 117), y:(basePos.y + 16), rotation:0, width:8, height:24, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text17);
m_text18 = MainMc.sktControl.MakeBox({x:(basePos.x - 135), y:(basePos.y + 30), rotation:((5 / 180) * Math.PI), width:6, height:26, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text18);
m_text19 = MainMc.sktControl.MakeBox({x:(basePos.x - 115), y:(basePos.y + 40), rotation:((-50 / 180) * Math.PI), width:5, height:18, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text19);
m_text20 = MainMc.sktControl.MakeBox({x:(basePos.x - 72), y:(basePos.y + 49), rotation:0, width:32, height:6, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text20);
j_text19 = MainMc.sktControl.MakeRevoJoint(m_text19, m_text20, {x:(m_text19.GetCenterPosition().x * m_physScale), y:(m_text19.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
m_text21 = MainMc.sktControl.MakeBox({x:(basePos.x - 59), y:(basePos.y - 24), rotation:0, width:22, height:3, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text21);
m_text22 = MainMc.sktControl.MakeBox({x:(basePos.x - 63), y:(basePos.y - 18), rotation:((-5 / 180) * Math.PI), width:6, height:27, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text22);
m_text23 = MainMc.sktControl.MakeBox({x:(basePos.x - 54), y:(basePos.y + 20), rotation:((-25 / 180) * Math.PI), width:7, height:18, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text23);
m_text24 = MainMc.sktControl.MakeBox({x:(basePos.x - 57), y:(basePos.y + 12), rotation:((35 / 180) * Math.PI), width:7, height:27, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text24);
j_text22 = MainMc.sktControl.MakeRevoJoint(m_text22, m_text24, {x:(m_text22.GetCenterPosition().x * m_physScale), y:(m_text22.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
j_text24 = MainMc.sktControl.MakeRevoJoint(m_text24, m_text23, {x:(m_text24.GetCenterPosition().x * m_physScale), y:(m_text24.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
m_text25 = MainMc.sktControl.MakeBox({x:(basePos.x - 45), y:(basePos.y - 38), rotation:((-40 / 180) * Math.PI), width:5, height:8, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text25);
m_text26 = MainMc.sktControl.MakeBox({x:(basePos.x - 83), y:(basePos.y + 20), rotation:((60 / 180) * Math.PI), width:7, height:14, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text26);
m_text27 = MainMc.sktControl.MakeBox({x:(basePos.x - 85), y:(basePos.y - 6), rotation:0, width:7, height:22, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text27);
j_text26 = MainMc.sktControl.MakeRevoJoint(m_text26, m_text27, {x:(m_text26.GetCenterPosition().x * m_physScale), y:(m_text26.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
m_text28 = MainMc.sktControl.MakeBox({x:(basePos.x + 130), y:(basePos.y - 32), rotation:0, width:44, height:3, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text28);
m_text29 = MainMc.sktControl.MakeBox({x:(basePos.x + 130), y:(basePos.y - 18), rotation:0, width:38, height:3, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text29);
m_text30 = MainMc.sktControl.MakeBox({x:(basePos.x + 130), y:(basePos.y - 4), rotation:0, width:50, height:3, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text30);
m_text31 = MainMc.sktControl.MakeBox({x:(basePos.x + 120), y:(basePos.y - 20), rotation:((20 / 180) * Math.PI), width:8, height:28, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text31);
m_text32 = MainMc.sktControl.MakeBox({x:(basePos.x + 100), y:(basePos.y + 12), rotation:((45 / 180) * Math.PI), width:6, height:24, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text32);
j_text31 = MainMc.sktControl.MakeRevoJoint(m_text31, m_text32, {x:(m_text31.GetCenterPosition().x * m_physScale), y:(m_text31.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
m_text33 = MainMc.sktControl.MakePoly({x:(basePos.x + 156), y:(basePos.y + 4), rotation:((-48 / 180) * Math.PI), density:2, friction:20, list:[[0, -26], [4, -26], [14, 28], [-11, 28]]});
MainMc.sktControl.SleepModel(m_text33);
m_text34 = MainMc.sktControl.MakeBox({x:(basePos.x + 130), y:(basePos.y + 18), rotation:0, width:30, height:3, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text34);
m_text35 = MainMc.sktControl.MakeBox({x:(basePos.x + 130), y:(basePos.y + 35), rotation:0, width:42, height:3, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text35);
m_text36 = MainMc.sktControl.MakeBox({x:(basePos.x + 130), y:(basePos.y + 30), rotation:0, width:8, height:26, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text36);
m_text37 = MainMc.sktControl.MakePoly({x:(basePos.x + 207), y:(basePos.y - 27), rotation:((45 / 180) * Math.PI), density:2, friction:20, list:[[-9, -16], [10, -20], [2, 24], [-2, 24]]});
MainMc.sktControl.SleepModel(m_text37);
m_text38 = MainMc.sktControl.MakeBox({x:(basePos.x + 209), y:(basePos.y + 1), rotation:((40 / 180) * Math.PI), width:8, height:28, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text38);
m_text39 = MainMc.sktControl.MakeBox({x:(basePos.x + 212), y:(basePos.y + 30), rotation:0, width:8, height:28, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text39);
j_text38 = MainMc.sktControl.MakeRevoJoint(m_text38, m_text39, {x:(m_text38.GetCenterPosition().x * m_physScale), y:(m_text38.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
m_text40 = MainMc.sktControl.MakeBox({x:(basePos.x + 260), y:(basePos.y - 36), rotation:0, width:26, height:3, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text40);
m_text41 = MainMc.sktControl.MakeBox({x:(basePos.x + 260), y:(basePos.y - 6), rotation:0, width:30, height:3, density:2, friction:20});
MainMc.sktControl.SleepModel(m_text41);
m_text42 = MainMc.sktControl.MakePoly({x:(basePos.x + 266), y:(basePos.y + 27), rotation:0, density:2, friction:20, list:[[-9, -32], [10, -32], [10, 22], [-9, 32]]});
MainMc.sktControl.SleepModel(m_text42);
m_text43 = MainMc.sktControl.MakePoly({x:(basePos.x + 252), y:(basePos.y + 50), rotation:0, density:2, friction:20, list:[[-10, -10], [10, -10], [10, 9], [6, 9]]});
MainMc.sktControl.SleepModel(m_text43);
j_text41 = MainMc.sktControl.MakeRevoJoint(m_text41, m_text42, {x:(m_text41.GetCenterPosition().x * m_physScale), y:(m_text41.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
j_text42 = MainMc.sktControl.MakeRevoJoint(m_text42, m_text43, {x:(m_text42.GetCenterPosition().x * m_physScale), y:(m_text42.GetCenterPosition().y * m_physScale)}, {enableLimit:true, lowerAngle:0, upperAngle:0});
m_btn = MainMc.sktControl.MakePoly({x:(basePos.x + 23), y:(basePos.y + 154), rotation:0, density:5, friction:0, list:[[0, -40], [96, 0], [0, 40], [-96, 0]]});
j_btn = MainMc.sktControl.MakeRevoJoint(m_ground, m_btn, {x:(m_btn.GetCenterPosition().x * m_physScale), y:((m_btn.GetCenterPosition().y * m_physScale) - 35)}, {});
MainMc.sktControl.SleepModel(m_btn);
mcAttach();
startBtnMc.addEventListener(MouseEvent.MOUSE_DOWN, btnPress, false, 0, true);
endCheckTimer = new Timer((1000 * 3), 1);
endCheckTimer.addEventListener(TimerEvent.TIMER_COMPLETE, timeOut, false, 0, true);
stop();
}
function frame25(){
endSys();
stop();
Object(parent).nextFrame();
}
public function feedOut():void{
endCheckTimer.stop();
endCheckTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, timeOut);
endCheckTimer = null;
play();
}
public function btnPress(_arg1:MouseEvent):void{
startBtnMc.removeEventListener(MouseEvent.MOUSE_DOWN, btnPress);
startBtnMc.play();
gameStart();
}
public function timeOut(_arg1:TimerEvent):void{
feedOut();
}
public function gameStart():void{
m_base.WakeUp();
m_text5.WakeUp();
m_text12.WakeUp();
m_text13.WakeUp();
m_text25.WakeUp();
m_text28.WakeUp();
m_text37.WakeUp();
m_text40.WakeUp();
m_text12.SetAngularVelocity(-5);
m_text30.SetAngularVelocity(15);
m_base.SetAngularVelocity(-5);
m_text22.SetAngularVelocity(5);
m_text41.SetAngularVelocity(5);
addEventListener(Event.ENTER_FRAME, EnterFrame, false, 0, true);
endCheckTimer.start();
}
public function EnterFrame(_arg1:Event):void{
mcAttach();
}
public function mcAttach():void{
attachMcToModel(mc_text0, m_base);
attachMcToModel(mc_text1, m_text5);
attachMcToModel(mc_text2, m_text6);
attachMcToModel(mc_text3, m_text7);
attachMcToModel(mc_text4, m_text8);
attachMcToModel(mc_text5, m_text9);
attachMcToModel(mc_text6, m_text10);
attachMcToModel(mc_text7, m_text12);
attachMcToModel(mc_text8, m_text13);
attachMcToModel(mc_text9, m_text14);
attachMcToModel(mc_text10, m_text15);
attachMcToModel(mc_text11, m_text16);
attachMcToModel(mc_text12, m_text17);
attachMcToModel(mc_text13, m_text18);
attachMcToModel(mc_text14, m_text19);
attachMcToModel(mc_text15, m_text21);
attachMcToModel(mc_text16, m_text22);
attachMcToModel(mc_text17, m_text25);
attachMcToModel(mc_text18, m_text26);
attachMcToModel(mc_text19, m_text28);
attachMcToModel(mc_text20, m_text29);
attachMcToModel(mc_text21, m_text30);
attachMcToModel(mc_text22, m_text31);
attachMcToModel(mc_text23, m_text33);
attachMcToModel(mc_text24, m_text34);
attachMcToModel(mc_text25, m_text35);
attachMcToModel(mc_text26, m_text36);
attachMcToModel(mc_text27, m_text37);
attachMcToModel(mc_text28, m_text39);
attachMcToModel(mc_text29, m_text40);
attachMcToModel(mc_text30, m_text41);
attachMcToModel(startBtnMc, m_btn);
}
public function endSys():void{
removeEventListener(Event.ENTER_FRAME, EnterFrame);
MainMc.removeEventListener(Event.ENTER_FRAME, MainMc.update);
MainMc.graphics.clear();
MainMc.m_currTest = null;
MainMc = null;
}
}
}//package hikkoshi01_fla
Section 76
//title_startBtn_3 (hikkoshi01_fla.title_startBtn_3)
package hikkoshi01_fla {
import flash.display.*;
public dynamic class title_startBtn_3 extends MovieClip {
public function title_startBtn_3(){
addFrameScript(0, frame1, 9, frame10);
}
function frame10(){
stop();
}
function frame1(){
stop();
}
}
}//package hikkoshi01_fla
Section 77
//titleRogo_b2Tex_5 (hikkoshi01_fla.titleRogo_b2Tex_5)
package hikkoshi01_fla {
import flash.display.*;
public dynamic class titleRogo_b2Tex_5 extends MovieClip {
public var num:int;
public function titleRogo_b2Tex_5(){
addFrameScript(0, frame1);
}
function frame1(){
num = int(name.substr(7));
gotoAndStop((num + 2));
}
}
}//package hikkoshi01_fla
Section 78
//totalResult_38 (hikkoshi01_fla.totalResult_38)
package hikkoshi01_fla {
import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.text.*;
import flash.utils.*;
import flash.geom.*;
import flash.system.*;
import adobe.utils.*;
import flash.accessibility.*;
import flash.errors.*;
import flash.external.*;
import flash.filters.*;
import flash.net.*;
import flash.printing.*;
import flash.ui.*;
import flash.xml.*;
public dynamic class totalResult_38 extends MovieClip {
public var bRotation:Number;
public var distance:Number;
public var titleBtn:SimpleButton;
public var distIndexNum:int;
public var rankHouseMc:MovieClip;
public var scoreDisp:TextField;
public var distList:Array;
public var houseTotalRad:Number;
public var rankDistMc:MovieClip;
public var bRadList:Array;
public var stats:Object;
public var bachanIndexNum:int;
public var retryBtn:SimpleButton;
public var oya:Object;
public var houseIndexNum:int;
public var gameMc:MovieClip;
public var hRadList:Array;
public var rankBachanMc:MovieClip;
public function totalResult_38(){
addFrameScript(0, frame1, 33, frame34, 52, frame53, 71, frame72, 79, frame80);
}
function frame72(){
bRotation = Math.floor((stats.bachan / 5));
bRadList = [(0 + 11.25), (22.5 + 11.25), (45 + 11.25), (67.5 + 11.25), (90 + 11.25), (112.5 + 11.25), (135 + 11.25), (157.5 + 11.25)];
bachanIndexNum = listIndex(bRotation, bRadList);
rankBachanMc.gotoAndStop((bachanIndexNum + 1));
}
function frame80(){
scoreDisp.text = String(oya.gameScore);
stop();
retryBtn.addEventListener(MouseEvent.MOUSE_DOWN, goRetry, false, 0, true);
titleBtn.addEventListener(MouseEvent.MOUSE_DOWN, goTitle, false, 0, true);
}
public function goTitle(_arg1:MouseEvent):void{
retryBtn.removeEventListener(MouseEvent.MOUSE_DOWN, goRetry);
titleBtn.removeEventListener(MouseEvent.MOUSE_DOWN, goTitle);
gameMc.endGame();
oya.x = 0;
oya.y = 0;
oya.gotoAndStop("title");
}
function frame34(){
distance = Math.floor((stats.distance / 5));
distList = [0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2, 3, 4, 5, 6, 7];
distIndexNum = listIndex(distance, distList);
rankDistMc.gotoAndStop((distIndexNum + 1));
}
public function goRetry(_arg1:MouseEvent):void{
retryBtn.removeEventListener(MouseEvent.MOUSE_DOWN, goRetry);
titleBtn.removeEventListener(MouseEvent.MOUSE_DOWN, goTitle);
gameMc.endGame();
oya.scoreInit();
oya.throwCount = -1;
oya.play();
}
public function listIndex(_arg1:Number, _arg2:Array):int{
var _local3:Array;
_arg2.unshift(_arg1);
_local3 = _arg2.sort((Array.NUMERIC | Array.RETURNINDEXEDARRAY));
return (_local3.indexOf(0));
}
function frame53(){
houseTotalRad = Math.floor((stats.house / 5));
hRadList = [0.1, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190];
houseIndexNum = listIndex(houseTotalRad, hRadList);
rankHouseMc.gotoAndStop((houseIndexNum + 1));
}
function frame1(){
oya = Object(parent.parent);
gameMc = oya.gameMc;
stats = oya.totalStats;
}
}
}//package hikkoshi01_fla
Section 79
//Test (TestBed.Test)
package TestBed {
import Engine.Dynamics.*;
import Engine.Dynamics.Joints.*;
import Engine.Common.Math.*;
import Engine.Collision.Shapes.*;
import flash.display.*;
import Engine.Dynamics.Contacts.*;
import Engine.Collision.*;
import General.*;
import Engine.Common.*;
import flash.utils.*;
public class Test {
public var m_world:b2World;
public var m_physScale:Number;// = 30
public var m_iterations:int;// = 10
private var mousePVec:b2Vec2;
public var m_timeStep:Number;// = 0.0333333333333333
public var m_sprite:Sprite;
public var m_bomb:b2Body;
public var m_mouseJoint:b2MouseJoint;
public static var mouseYWorldPhys:Number;
public static var mouseXWorldPhys:Number;
public static var mouseYWorld:Number;
public static var mouseXWorld:Number;
public function Test(_arg1:int, _arg2:int){
var _local3:b2AABB;
var _local4:b2Vec2;
var _local5:Boolean;
var _local6:b2BoxDef;
var _local7:*;
m_iterations = 10;
m_timeStep = (1 / 30);
m_physScale = 30;
mousePVec = new b2Vec2();
super();
_local3 = new b2AABB();
_local3.minVertex.Set(-100, -100);
_local3.maxVertex.Set(100, 100);
_local4 = new b2Vec2(0, 10);
_local5 = true;
m_world = new b2World(_local3, _local4, _local5);
m_sprite = Main.m_sprite;
_local6 = new b2BoxDef();
_local7 = new b2BodyDef();
_local7.AddShape(_local6);
_local6.extents.Set((100 / m_physScale), (((_arg2 + 50) / m_physScale) / 2));
_local7.position.Set((-95 / m_physScale), ((_arg2 / m_physScale) / 2));
m_world.CreateBody(_local7);
_local7.position.Set(((_arg1 + 95) / m_physScale), ((_arg2 / m_physScale) / 2));
m_world.CreateBody(_local7);
_local6.extents.Set((((_arg1 + 50) / m_physScale) / 2), (100 / m_physScale));
_local7.position.Set(((_arg1 / m_physScale) / 2), (-95 / m_physScale));
m_world.CreateBody(_local7);
_local7.position.Set(((_arg1 / m_physScale) / 2), ((_arg2 + 95) / m_physScale));
m_world.CreateBody(_local7);
}
public function GetBodyAtPoint_SKT(_arg1:Number, _arg2:Number, _arg3:Boolean=false):b2Body{
var _local4:b2Vec2;
var _local5:Number;
var _local6:Number;
var _local7:b2AABB;
var _local8:int;
var _local9:Array;
var _local10:int;
var _local11:b2Body;
var _local12:int;
var _local13:Boolean;
_local4 = new b2Vec2();
_local5 = (_arg1 / m_physScale);
_local6 = (_arg2 / m_physScale);
_local4.Set(_local5, _local6);
_local7 = new b2AABB();
_local7.minVertex.Set((_local5 - 0.001), (_local6 - 0.001));
_local7.maxVertex.Set((_local5 + 0.001), (_local6 + 0.001));
_local8 = 10;
_local9 = new Array();
_local10 = m_world.Query(_local7, _local9, _local8);
_local11 = null;
_local12 = 0;
while (_local12 < _local10) {
if ((((_local9[_local12].m_body.IsStatic() == false)) || (_arg3))){
_local13 = _local9[_local12].TestPoint(_local4);
if (_local13){
_local11 = _local9[_local12].m_body;
break;
};
};
_local12++;
};
return (_local11);
}
public function DrawJoint(_arg1:b2Joint){
var _local2:b2Body;
var _local3:b2Body;
var _local4:b2Vec2;
var _local5:b2Vec2;
var _local6:b2Vec2;
var _local7:b2Vec2;
var _local8:b2PulleyJoint;
var _local9:b2Vec2;
var _local10:b2Vec2;
_local2 = _arg1.m_body1;
_local3 = _arg1.m_body2;
_local4 = _local2.m_position;
_local5 = _local3.m_position;
_local6 = _arg1.GetAnchor1();
_local7 = _arg1.GetAnchor2();
m_sprite.graphics.lineStyle(1, 4500223, (1 / 1));
switch (_arg1.m_type){
case b2Joint.e_distanceJoint:
case b2Joint.e_mouseJoint:
m_sprite.graphics.moveTo((_local6.x * m_physScale), (_local6.y * m_physScale));
m_sprite.graphics.lineTo((_local7.x * m_physScale), (_local7.y * m_physScale));
break;
case b2Joint.e_pulleyJoint:
_local8 = (_arg1 as b2PulleyJoint);
_local9 = _local8.GetGroundPoint1();
_local10 = _local8.GetGroundPoint2();
m_sprite.graphics.moveTo((_local9.x * m_physScale), (_local9.y * m_physScale));
m_sprite.graphics.lineTo((_local6.x * m_physScale), (_local6.y * m_physScale));
m_sprite.graphics.moveTo((_local10.x * m_physScale), (_local10.y * m_physScale));
m_sprite.graphics.lineTo((_local7.x * m_physScale), (_local7.y * m_physScale));
break;
default:
if (_local2 == m_world.m_groundBody){
m_sprite.graphics.moveTo((_local6.x * m_physScale), (_local6.y * m_physScale));
m_sprite.graphics.lineTo((_local5.x * m_physScale), (_local5.y * m_physScale));
} else {
if (_local3 == m_world.m_groundBody){
m_sprite.graphics.moveTo((_local6.x * m_physScale), (_local6.y * m_physScale));
m_sprite.graphics.lineTo((_local4.x * m_physScale), (_local4.y * m_physScale));
} else {
m_sprite.graphics.moveTo((_local4.x * m_physScale), (_local4.y * m_physScale));
m_sprite.graphics.lineTo((_local6.x * m_physScale), (_local6.y * m_physScale));
m_sprite.graphics.lineTo((_local5.x * m_physScale), (_local5.y * m_physScale));
m_sprite.graphics.lineTo((_local7.x * m_physScale), (_local7.y * m_physScale));
};
};
};
}
public function DrawPairs(){
var _local1:b2BroadPhase;
var _local2:b2Vec2;
var _local3:int;
var _local4:b2Pair;
var _local5:uint;
var _local6:uint;
var _local7:b2Proxy;
var _local8:b2Proxy;
var _local9:b2AABB;
var _local10:b2AABB;
var _local11:b2Vec2;
var _local12:b2Vec2;
_local1 = m_world.m_broadPhase;
_local2 = new b2Vec2();
_local2.Set((1 / _local1.m_quantizationFactor.x), (1 / _local1.m_quantizationFactor.y));
_local3 = 0;
while (_local3 < _local1.m_pairManager.m_pairCount) {
_local4 = _local1.m_pairManager.m_pairs[_local3];
_local5 = _local4.proxyId1;
_local6 = _local4.proxyId2;
_local7 = _local1.m_proxyPool[_local5];
_local8 = _local1.m_proxyPool[_local6];
_local9 = new b2AABB();
_local10 = new b2AABB();
_local9.minVertex.x = (_local1.m_worldAABB.minVertex.x + (_local2.x * _local1.m_bounds[0][_local7.lowerBounds[0]].value));
_local9.minVertex.y = (_local1.m_worldAABB.minVertex.y + (_local2.y * _local1.m_bounds[1][_local7.lowerBounds[1]].value));
_local9.maxVertex.x = (_local1.m_worldAABB.minVertex.x + (_local2.x * _local1.m_bounds[0][_local7.upperBounds[0]].value));
_local9.maxVertex.y = (_local1.m_worldAABB.minVertex.y + (_local2.y * _local1.m_bounds[1][_local7.upperBounds[1]].value));
_local10.minVertex.x = (_local1.m_worldAABB.minVertex.x + (_local2.x * _local1.m_bounds[0][_local8.lowerBounds[0]].value));
_local10.minVertex.y = (_local1.m_worldAABB.minVertex.y + (_local2.y * _local1.m_bounds[1][_local8.lowerBounds[1]].value));
_local10.maxVertex.x = (_local1.m_worldAABB.minVertex.x + (_local2.x * _local1.m_bounds[0][_local8.upperBounds[0]].value));
_local10.maxVertex.y = (_local1.m_worldAABB.minVertex.y + (_local2.y * _local1.m_bounds[1][_local8.upperBounds[1]].value));
_local11 = b2Math.MulFV(0.5, b2Math.AddVV(_local9.minVertex, _local9.maxVertex));
_local12 = b2Math.MulFV(0.5, b2Math.AddVV(_local10.minVertex, _local10.maxVertex));
m_sprite.graphics.lineStyle(1, 16720418, 1);
m_sprite.graphics.moveTo((_local11.x * m_physScale), (_local11.y * m_physScale));
m_sprite.graphics.lineTo((_local12.x * m_physScale), (_local12.y * m_physScale));
_local3++;
};
}
public function MouseDrag(){
var _local1:b2Body;
var _local2:b2MouseJointDef;
var _local3:b2Vec2;
if (((Input.mouseDown) && (!(m_mouseJoint)))){
_local1 = GetBodyAtMouse();
if (_local1){
_local2 = new b2MouseJointDef();
_local2.body1 = m_world.m_groundBody;
_local2.body2 = _local1;
_local2.target.Set(mouseXWorldPhys, mouseYWorldPhys);
_local2.maxForce = (1000 * _local1.m_mass);
_local2.timeStep = m_timeStep;
m_mouseJoint = (m_world.CreateJoint(_local2) as b2MouseJoint);
_local1.WakeUp();
};
};
if (!Input.mouseDown){
if (m_mouseJoint){
m_world.DestroyJoint(m_mouseJoint);
m_mouseJoint = null;
};
};
if (m_mouseJoint){
_local3 = new b2Vec2(mouseXWorldPhys, mouseYWorldPhys);
m_mouseJoint.SetTarget(_local3);
};
}
public function GetBodyAtMouse(_arg1:Boolean=false):b2Body{
var _local2:b2AABB;
var _local3:int;
var _local4:Array;
var _local5:int;
var _local6:b2Body;
var _local7:int;
var _local8:Boolean;
mousePVec.Set(mouseXWorldPhys, mouseYWorldPhys);
_local2 = new b2AABB();
_local2.minVertex.Set((mouseXWorldPhys - 0.001), (mouseYWorldPhys - 0.001));
_local2.maxVertex.Set((mouseXWorldPhys + 0.001), (mouseYWorldPhys + 0.001));
_local3 = 10;
_local4 = new Array();
_local5 = m_world.Query(_local2, _local4, _local3);
_local6 = null;
_local7 = 0;
while (_local7 < _local5) {
if ((((_local4[_local7].m_body.IsStatic() == false)) || (_arg1))){
_local8 = _local4[_local7].TestPoint(mousePVec);
if (_local8){
_local6 = _local4[_local7].m_body;
break;
};
};
_local7++;
};
return (_local6);
}
public function DrawContacts(){
var _local1:b2Contact;
var _local2:Array;
var _local3:int;
var _local4:b2Manifold;
var _local5:int;
var _local6:b2Vec2;
_local1 = m_world.m_contactList;
while (_local1) {
_local2 = _local1.GetManifolds();
_local3 = 0;
while (_local3 < _local1.GetManifoldCount()) {
_local4 = _local2[_local3];
_local5 = 0;
while (_local5 < _local4.pointCount) {
m_sprite.graphics.lineStyle(_local4.points[_local5].normalImpulse, 1166591, 0.7);
_local6 = _local4.points[_local5].position;
m_sprite.graphics.moveTo((_local6.x * m_physScale), (_local6.y * m_physScale));
m_sprite.graphics.lineTo((_local6.x * m_physScale), (_local6.y * m_physScale));
_local5++;
};
_local3++;
};
_local1 = _local1.m_next;
};
}
public function releaseModel_SKT():void{
if (m_mouseJoint){
m_world.DestroyJoint(m_mouseJoint);
m_mouseJoint = null;
};
}
public function dragModel_SKT():void{
var _local1:b2Vec2;
if (m_mouseJoint){
_local1 = new b2Vec2(mouseXWorldPhys, mouseYWorldPhys);
m_mouseJoint.SetTarget(_local1);
};
}
public function DrawShape(_arg1:b2Shape){
var _local2:b2CircleShape;
var _local3:b2Vec2;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:int;
var _local9:b2Vec2;
var _local10:b2Vec2;
var _local11:b2Vec2;
var _local12:b2Vec2;
var _local13:b2PolyShape;
var _local14:b2Vec2;
switch (_arg1.m_type){
case b2Shape.e_circleShape:
_local2 = (_arg1 as b2CircleShape);
_local3 = _local2.m_position;
_local4 = _local2.m_radius;
_local5 = 16;
_local6 = ((2 * Math.PI) / _local5);
m_sprite.graphics.lineStyle(1, 0xFFFFFF, 1);
m_sprite.graphics.moveTo(((_local3.x + _local4) * m_physScale), (_local3.y * m_physScale));
_local7 = 0;
_local8 = 0;
while (_local8 < _local5) {
_local11 = new b2Vec2((_local4 * Math.cos(_local7)), (_local4 * Math.sin(_local7)));
_local12 = b2Math.AddVV(_local3, _local11);
m_sprite.graphics.lineTo((_local12.x * m_physScale), (_local12.y * m_physScale));
_local7 = (_local7 + _local6);
_local8++;
};
m_sprite.graphics.lineTo(((_local3.x + _local4) * m_physScale), (_local3.y * m_physScale));
m_sprite.graphics.moveTo((_local3.x * m_physScale), (_local3.y * m_physScale));
_local9 = _local2.m_R.col1;
_local10 = new b2Vec2((_local3.x + (_local4 * _local9.x)), (_local3.y + (_local4 * _local9.y)));
m_sprite.graphics.lineTo((_local10.x * m_physScale), (_local10.y * m_physScale));
break;
case b2Shape.e_polyShape:
_local13 = (_arg1 as b2PolyShape);
_local14 = b2Math.AddVV(_local13.m_position, b2Math.b2MulMV(_local13.m_R, _local13.m_vertices[_local8]));
m_sprite.graphics.lineStyle(1, 0xFFFFFF, 1);
m_sprite.graphics.moveTo((_local14.x * m_physScale), (_local14.y * m_physScale));
_local8 = 0;
while (_local8 < _local13.m_vertexCount) {
_local12 = b2Math.AddVV(_local13.m_position, b2Math.b2MulMV(_local13.m_R, _local13.m_vertices[_local8]));
m_sprite.graphics.lineTo((_local12.x * m_physScale), (_local12.y * m_physScale));
_local8++;
};
m_sprite.graphics.lineTo((_local14.x * m_physScale), (_local14.y * m_physScale));
break;
};
}
public function skt_GetModel(){
var _local1:*;
_local1 = m_world.m_bodyList.GetCenterPosition();
Main.m_aboutText.text = String((_local1.x * m_physScale));
}
public function GetPolyApexList_SKT(_arg1:b2Body):Array{
var _local2:int;
var _local3:b2Vec2;
var _local4:Array;
var _local5:b2Shape;
var _local6:b2PolyShape;
_local2 = 0;
_local4 = [];
_local5 = _arg1.GetShapeList();
switch (_local5.m_type){
case b2Shape.e_circleShape:
return ([]);
case b2Shape.e_polyShape:
_local6 = (_local5 as b2PolyShape);
_local2 = 0;
while (_local2 < _local6.m_vertexCount) {
_local3 = b2Math.AddVV(_local6.m_position, b2Math.b2MulMV(_local6.m_R, _local6.m_vertices[_local2]));
_local4.push([(_local3.x * m_physScale), (_local3.y * m_physScale)]);
_local2++;
};
break;
};
return (_local4);
}
public function Update(_arg1:Boolean){
var _local2:uint;
var _local3:b2Joint;
var _local4:b2Body;
var _local5:b2Shape;
UpdateMouseWorld();
dragModel_SKT();
_local2 = getTimer();
m_world.Step(m_timeStep, m_iterations);
Main.m_fpsCounter.updatePhys(_local2);
if (!_arg1){
return;
};
_local3 = m_world.m_jointList;
while (_local3) {
DrawJoint(_local3);
_local3 = _local3.m_next;
};
_local4 = m_world.m_bodyList;
while (_local4) {
_local5 = _local4.GetShapeList();
while (_local5 != null) {
DrawShape(_local5);
_local5 = _local5.GetNext();
};
_local4 = _local4.m_next;
};
}
public function UpdateMouseWorld(){
mouseXWorldPhys = (Input.mouseX / m_physScale);
mouseYWorldPhys = (Input.mouseY / m_physScale);
mouseXWorld = Input.mouseX;
mouseYWorld = Input.mouseY;
}
public function clickModel_SKT(_arg1:b2Body):void{
var _local2:b2MouseJointDef;
_local2 = new b2MouseJointDef();
_local2.body1 = m_world.m_groundBody;
_local2.body2 = _arg1;
_local2.target.Set(mouseXWorldPhys, mouseYWorldPhys);
_local2.maxForce = (1000 * _arg1.m_mass);
_local2.timeStep = m_timeStep;
m_mouseJoint = (m_world.CreateJoint(_local2) as b2MouseJoint);
_arg1.WakeUp();
}
}
}//package TestBed
Section 80
//Main (Main)
package {
import Engine.Dynamics.*;
import Engine.Dynamics.Joints.*;
import Engine.Common.Math.*;
import Engine.Collision.Shapes.*;
import flash.display.*;
import flash.events.*;
import Engine.Dynamics.Contacts.*;
import Engine.Collision.*;
import TestBed.*;
import General.*;
import flash.text.*;
public class Main extends MovieClip {
public var m_Rendering:Boolean;
public var MINE:MovieClip;
public var m_currTest:Test;
public var m_input:Input;
public var sktControl:SKTModelControl;
public var m_currId:int;// = 0
public static var m_fpsCounter:FpsCounter = new FpsCounter();
public static var m_sprite:Sprite;
public static var m_aboutText:TextField;
public function Main(_arg1:MovieClip, _arg2:String, _arg3:int, _arg4:int, _arg5:Boolean){
m_currId = 0;
super();
addEventListener(Event.ENTER_FRAME, update, false, 0, true);
m_fpsCounter.x = 7;
m_fpsCounter.y = 5;
addChildAt(m_fpsCounter, 0);
m_sprite = (_arg1 as Sprite);
m_input = new Input(m_sprite);
m_aboutText = _arg1.m_aboutTextN;
m_currTest = new Test(_arg3, _arg4);
m_Rendering = _arg5;
MINE = _arg1;
sktControl = new SKTModelControl(m_currTest);
}
public function update(_arg1:Event){
MINE.graphics.clear();
m_currTest.Update(m_Rendering);
m_fpsCounter.update();
FRateLimiter.limitFrame(30);
}
}
}//package
Section 81
//se_bachan (se_bachan)
package {
import flash.media.*;
public dynamic class se_bachan extends Sound {
}
}//package
Section 82
//se_hi1 (se_hi1)
package {
import flash.media.*;
public dynamic class se_hi1 extends Sound {
}
}//package
Section 83
//se_hi2 (se_hi2)
package {
import flash.media.*;
public dynamic class se_hi2 extends Sound {
}
}//package
Section 84
//se_hi3 (se_hi3)
package {
import flash.media.*;
public dynamic class se_hi3 extends Sound {
}
}//package
Section 85
//se_jingle (se_jingle)
package {
import flash.media.*;
public dynamic class se_jingle extends Sound {
}
}//package
Section 86
//se_result (se_result)
package {
import flash.media.*;
public dynamic class se_result extends Sound {
}
}//package
Section 87
//se_roll (se_roll)
package {
import flash.media.*;
public dynamic class se_roll extends Sound {
}
}//package
Section 88
//se_se1 (se_se1)
package {
import flash.media.*;
public dynamic class se_se1 extends Sound {
}
}//package
Section 89
//se_se2 (se_se2)
package {
import flash.media.*;
public dynamic class se_se2 extends Sound {
}
}//package
Section 90
//se_se3 (se_se3)
package {
import flash.media.*;
public dynamic class se_se3 extends Sound {
}
}//package