Section 1
//Avatar (com.kerb.hurlBerl.game.physics.Avatar)
package com.kerb.hurlBerl.game.physics {
import flash.display.*;
import com.kerb.hurlBerl.game.utils.*;
import flash.utils.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.dynamics.contact.*;
import com.kerb.hurlBerl.*;
public class Avatar extends MoveableBody {
public var landed:Boolean;// = false
protected var onGroundContactThreshold:Number;// = 0.5
protected var runForce:Number;// = 20000
protected var jumpImpulse:Number;// = 50000
protected var h:int;// = 60
protected var restitution:Number;// = 0.2
private var wobbleCounter:Number;
protected var density:Number;// = 0.2
protected var mask:int;// = 0xFFFF
protected var preventRotation:Boolean;// = false
protected var w:int;// = 30
protected var friction:Number;// = 0.9
protected var category:int;// = 0xFFFF
protected var group:int;// = 1
public function Avatar(_arg1:Number, _arg2:Number, _arg3:Physics){
var _local4:MovieClip;
_local4 = Main.af.createMovieClip("AvatarAsset");
var _local5:CircleData = _arg3.createCircleData((0.5 * w), 0, (0.5 * h), density, friction);
var _local6:CircleData = _arg3.createCircleData((0.5 * w), 0, (-0.5 * h), density, friction);
var _local7:BoxData = _arg3.createBoxData(w, h, 0, 0, 0, density, friction, restitution, group, category, mask);
var _local8:RigidBodyData = new RigidBodyData(_arg1, _arg2, (0.5 * Math.PI));
_local8.addShapeData(_local7);
_local8.addShapeData(_local5);
_local8.addShapeData(_local6);
_local8.angDamping = 0.02;
_local8.preventRotation = preventRotation;
var _local9:RigidBody = _arg3.world.createBody(_local8);
_local9.allowSleeping(false);
super(_local9, _local4);
wobbleCounter = 0;
}
public function get width():Number{
return (w);
}
override public function serialise():ByteArray{
var _local1:Object = new Object();
_local1.x = rb.x;
_local1.y = rb.y;
_local1.r = rb.r;
_local1.vx = rb.vx;
_local1.vy = rb.vy;
var _local2:ByteArray = new ByteArray();
_local2.writeObject(_local1);
return (_local2);
}
override public function update():void{
super.update();
}
public function get onGround():Boolean{
var _local2:Manifold;
var _local3:Number;
var _local1:ContactNode = rb.contactList;
while (_local1) {
_local2 = _local1.contact.manifolds[0];
_local3 = _local2.ny;
if (_local1.contact.shape2.body == rb){
_local3 = -(_local3);
};
if (_local3 > onGroundContactThreshold){
return (true);
};
_local1 = _local1.next;
};
return (false);
}
public function checkKeys(_arg1:int):void{
if ((_arg1 & KeyboardControl.LEFT_DOWN)){
rb.applyForce(-(runForce), 0);
};
if ((_arg1 & KeyboardControl.RIGHT_DOWN)){
rb.applyForce(runForce, 0);
};
if ((((_arg1 & KeyboardControl.UP_PRESSED)) && (onGround))){
rb.applyImpulse(0, -(jumpImpulse));
};
}
override public function deserialise(_arg1:ByteArray):void{
_arg1.position = 0;
var _local2:Object = _arg1.readObject();
rb.x = _local2.x;
rb.y = _local2.y;
rb.r = _local2.r;
rb.vx = _local2.vx;
rb.vy = _local2.vy;
}
public function wobble():void{
wobbleCounter = (wobbleCounter + (((Math.random() * 0.5) - 0.25) + 0.5));
rb.r = ((0.1 * Math.sin(wobbleCounter)) + (0.5 * Math.PI));
}
public function get height():Number{
return (h);
}
public function get x():Number{
return (rb.x);
}
public function get y():Number{
return (rb.y);
}
}
}//package com.kerb.hurlBerl.game.physics
Section 2
//MoveableBody (com.kerb.hurlBerl.game.physics.MoveableBody)
package com.kerb.hurlBerl.game.physics {
import flash.display.*;
import com.kerb.hurlBerl.game.utils.*;
import flash.utils.*;
import de.polygonal.motor2.dynamics.*;
import com.kerb.hurlBerl.*;
public class MoveableBody implements ISerialisable {
public var rb:RigidBody;
public var mc:MovieClip;
public static const MAX_VELOCITY:Number = 100;
public function MoveableBody(_arg1:RigidBody, _arg2:MovieClip=null){
this.rb = _arg1;
this.mc = ((_arg2)==null) ? new MovieClip() : _arg2;
}
public function update():void{
mc.x = rb.x;
mc.y = rb.y;
mc.rotation = (Constants.RAD_2_DEG * rb.r);
if (rb.vx > MAX_VELOCITY){
rb.vx = MAX_VELOCITY;
} else {
if (rb.vx < -(MAX_VELOCITY)){
rb.vx = -(MAX_VELOCITY);
};
};
if (rb.vy > MAX_VELOCITY){
rb.vy = MAX_VELOCITY;
} else {
if (rb.vy < -(MAX_VELOCITY)){
rb.vy = -(MAX_VELOCITY);
};
};
}
public function deserialise(_arg1:ByteArray):void{
throw (new Error("All child instances of MoveableBody must override deserialise()"));
}
public function serialise():ByteArray{
throw (new Error("All child instances of MoveableBody must override serialise()"));
}
}
}//package com.kerb.hurlBerl.game.physics
Section 3
//Physics (com.kerb.hurlBerl.game.physics.Physics)
package com.kerb.hurlBerl.game.physics {
import flash.display.*;
import flash.geom.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.joints.*;
import com.kerb.hurlBerl.*;
public class Physics {
protected var wh:int;
public var world:World;
protected var ww:int;
public var terrain:Terrain;
protected static const ALLOW_SLEEP:Boolean = true;
protected static const GRAVITY_X:Number = 0;
protected static const GRAVITY_Y:Number = 12;
public static const DEFAULT_RESTITUTION:Number = 0.1;
protected static const NUM_ITERATIONS:int = 10;
public static const DEFAULT_FRICTION:Number = 0.3;
protected static const TIME_STEP:Number = 0.1;
public function Physics(_arg1:int, _arg2:int, _arg3:XML=null){
ww = _arg1;
wh = _arg2;
initWorld();
if (_arg3){
initTerrain(_arg3);
};
}
protected function initTerrain(_arg1:XML):void{
terrain = new Terrain(ww, wh);
terrain.initTerrain(_arg1, this);
}
public function step():void{
world.step(TIME_STEP, NUM_ITERATIONS);
world.step(TIME_STEP, NUM_ITERATIONS);
world.step(TIME_STEP, NUM_ITERATIONS);
if (terrain){
terrain.update(world);
};
}
public function addPoly(_arg1:Number, _arg2:Number, _arg3:Array, _arg4:Number=0, _arg5:Number=0, _arg6:Number=0.3, _arg7:Number=0.1, _arg8:Boolean=false, _arg9:int=0, _arg10:uint=1, _arg11:uint=0xFFFF):RigidBody{
var _local12:PolyData = createPolyData(_arg3, 0, 0, 0, _arg5, _arg6, _arg7, _arg9, _arg10, _arg11);
var _local13:RigidBodyData = new RigidBodyData(_arg1, _arg2, _arg4);
_local13.preventRotation = _arg8;
_local13.addShapeData(_local12);
return (world.createBody(_local13));
}
public function drawWireframes(_arg1:Graphics):void{
var _local4:ShapeSkeleton;
var _local5:int;
var _local2:Array = world.getShapeList();
var _local3:int = _local2.length;
_arg1.clear();
_arg1.lineStyle(Constants.RIGID_BODY_STROKE_THICKNESS, Constants.RIGID_BODY_STROKE_COLOUR);
_local5 = 0;
while (_local5 < _local3) {
_local4 = _local2[_local5];
_arg1.beginFill(Constants.RIGID_BODY_FILL_COLOUR, Constants.RIGID_BODY_FILL_ALPHA);
if (_local4.body.userData){
_arg1.beginFill(0xFF0000);
};
drawShape(_local4, _arg1);
_arg1.endFill();
_local5++;
};
_arg1.lineStyle();
if (terrain){
terrain.drawBins(_arg1);
};
}
public function get worldWidth():int{
return (ww);
}
public function addCompoundShape(_arg1:Number, _arg2:Number, _arg3:Array, _arg4:Number=0, _arg5:Boolean=false):RigidBody{
var _local6:RigidBodyData = new RigidBodyData(_arg1, _arg2, _arg4);
_local6.preventRotation = _arg5;
var _local7:int = _arg3.length;
var _local8:int;
while (_local8 < _local7) {
_local6.addShapeData(_arg3[_local8]);
_local8++;
};
return (world.createBody(_local6));
}
public function addCircle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number=0, _arg5:Number=0.3, _arg6:Number=0.1, _arg7:Boolean=false, _arg8:int=0, _arg9:uint=1, _arg10:uint=0xFFFF):RigidBody{
var _local11:CircleData = createCircleData(_arg3, 0, 0, _arg4, _arg5, _arg6, _arg8, _arg9, _arg10);
var _local12:RigidBodyData = new RigidBodyData(_arg1, _arg2);
_local12.preventRotation = _arg7;
_local12.addShapeData(_local11);
return (world.createBody(_local12));
}
public function get worldHeight():int{
return (wh);
}
public function createLineData(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0, _arg6:Number=0, _arg7:Number=0.3, _arg8:Number=0.1, _arg9:Boolean=true, _arg10:Boolean=false, _arg11:int=0, _arg12:uint=1, _arg13:uint=0xFFFF):LineData{
var _local14:Point = new Point(0, 0);
var _local15:Point = new Point((_arg3 - _arg1), (_arg4 - _arg2));
var _local16:LineData = new LineData(_local14, _local15, _arg10, _arg9);
_local16.density = _arg6;
_local16.friction = _arg7;
_local16.restitution = _arg8;
_local16.groupIndex = _arg11;
_local16.categoryBits = _arg12;
_local16.maskBits = _arg13;
_local16.mx = _arg1;
_local16.my = _arg2;
_local16.mr = _arg5;
return (_local16);
}
public function dispose():void{
if (terrain){
terrain.dispose();
};
var _local1:RigidBody = world.bodyList;
while (_local1) {
world.destroyBody(_local1);
_local1 = _local1.next;
};
var _local2:Joint = world.jointList;
while (_local2) {
world.destroyJoint(_local2);
_local2 = _local2.next;
};
world = null;
}
protected function initWorld():void{
var _local1:Number = 400;
var _local2:AABB2 = new AABB2(-(_local1), (-1000 - _local1), (ww + _local1), ((wh + _local1) + 1000));
world = new World(_local2, ALLOW_SLEEP);
world.setGravity(GRAVITY_X, GRAVITY_Y);
var _local3:Number = (0.5 * ww);
var _local4:Number = (0.5 * wh);
var _local5:Number = (0.5 * _local1);
var _local6:Number = (2 * _local1);
addBox(-(_local5), _local4, _local1, ((2 * wh) + _local6));
addBox((ww + _local5), _local4, _local1, ((2 * wh) + _local6));
addBox(_local3, (-1000 - _local5), (ww + _local6), _local1);
addBox(_local3, (wh + _local5), (ww + _local6), _local1);
}
public function addBox(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0, _arg6:Number=0, _arg7:Number=0.3, _arg8:Number=0.1, _arg9:Boolean=false, _arg10:int=0, _arg11:uint=1, _arg12:uint=0xFFFF):RigidBody{
var _local13:BoxData = createBoxData(_arg3, _arg4, 0, 0, 0, _arg6, _arg7, _arg8, _arg10, _arg11, _arg12);
var _local14:RigidBodyData = new RigidBodyData(_arg1, _arg2, _arg5);
_local14.preventRotation = _arg9;
_local14.addShapeData(_local13);
return (world.createBody(_local14));
}
public function createPolyData(_arg1:Array, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0, _arg6:Number=0.3, _arg7:Number=0.1, _arg8:int=0, _arg9:uint=1, _arg10:uint=0xFFFF):PolyData{
var _local11:PolyData = new PolyData(_arg5, _arg1);
_local11.mx = _arg2;
_local11.my = _arg3;
_local11.mr = _arg4;
_local11.friction = _arg6;
_local11.restitution = _arg7;
_local11.groupIndex = _arg8;
_local11.categoryBits = _arg9;
_local11.maskBits = _arg10;
return (_local11);
}
public function createCircleData(_arg1:Number, _arg2:Number=0, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0.3, _arg6:Number=0.1, _arg7:int=0, _arg8:uint=1, _arg9:uint=0xFFFF):CircleData{
var _local10:CircleData = new CircleData(_arg4, _arg1);
_local10.mx = _arg2;
_local10.my = _arg3;
_local10.friction = _arg5;
_local10.restitution = _arg6;
_local10.groupIndex = _arg7;
_local10.categoryBits = _arg8;
_local10.maskBits = _arg9;
return (_local10);
}
protected function drawShapeCentre(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Graphics):void{
var _local6:Number = 3;
_arg3 = (_arg3 * _local6);
_arg4 = (_arg4 * _local6);
_arg5.moveTo(_arg1, _arg2);
_arg5.lineTo((_arg1 + _arg4), (_arg2 - _arg3));
_arg5.moveTo(_arg1, _arg2);
_arg5.lineTo((_arg1 - _arg4), (_arg2 + _arg3));
_arg5.moveTo(_arg1, _arg2);
_arg5.lineTo((_arg1 + _arg3), (_arg2 + _arg4));
_arg5.moveTo(_arg1, _arg2);
_arg5.lineTo((_arg1 - _arg3), (_arg2 - _arg4));
}
public function createBoxData(_arg1:Number, _arg2:Number, _arg3:Number=0, _arg4:Number=0, _arg5:Number=0, _arg6:Number=0, _arg7:Number=0.3, _arg8:Number=0.1, _arg9:int=0, _arg10:uint=1, _arg11:uint=0xFFFF):BoxData{
var _local12:BoxData = new BoxData(_arg6, _arg1, _arg2);
_local12.mx = _arg3;
_local12.my = _arg4;
_local12.mr = _arg5;
_local12.friction = _arg7;
_local12.restitution = _arg8;
_local12.groupIndex = _arg9;
_local12.categoryBits = _arg10;
_local12.maskBits = _arg11;
return (_local12);
}
public function addLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0, _arg6:Number=0.3, _arg7:Number=0.1, _arg8:Boolean=true, _arg9:Boolean=false, _arg10:Boolean=false, _arg11:int=0, _arg12:uint=1, _arg13:uint=0xFFFF):RigidBody{
var _local14:LineData = createLineData(0, 0, (_arg3 - _arg1), (_arg4 - _arg2), 0, _arg5, _arg6, _arg7, _arg8, _arg9, _arg11, _arg12, _arg13);
var _local15:RigidBodyData = new RigidBodyData((0.5 * (_arg1 + _arg3)), (0.5 * (_arg2 + _arg4)));
_local15.preventRotation = _arg10;
_local15.addShapeData(_local14);
return (world.createBody(_local15));
}
protected function drawShape(_arg1:ShapeSkeleton, _arg2:Graphics):void{
var _local4:V2;
_arg1.toWorldSpace();
var _local3:V2 = _arg1.worldVertexChain;
if (_arg1.type == ShapeTypes.CIRCLE){
_arg2.moveTo(_arg1.x, _arg1.y);
_arg2.drawCircle(_arg1.x, _arg1.y, _arg1.radius);
drawShapeCentre(_arg1.x, _arg1.y, _arg1.r11, _arg1.r21, _arg2);
} else {
if ((((_arg1.type == ShapeTypes.LINE)) && (LineShape(_arg1).infinite))){
_local4 = _arg1.modelVertexChain.edge.d;
_arg2.moveTo((_local3.x - (_local4.x * 1000)), (_local3.y - (_local4.y * 1000)));
_local3 = _local3.next;
_arg2.lineTo((_local3.x + (_local4.x * 1000)), (_local3.y + (_local4.y * 1000)));
} else {
_arg2.moveTo(_local3.x, _local3.y);
while (true) {
_arg2.lineTo(_local3.x, _local3.y);
if (_local3.isTail){
_arg2.lineTo(_local3.next.x, _local3.next.y);
break;
};
_local3 = _local3.next;
};
if (_arg1.type != ShapeTypes.LINE){
drawShapeCentre(_arg1.x, _arg1.y, _arg1.r11, _arg1.r21, _arg2);
};
};
};
}
}
}//package com.kerb.hurlBerl.game.physics
Section 4
//Terrain (com.kerb.hurlBerl.game.physics.Terrain)
package com.kerb.hurlBerl.game.physics {
import flash.display.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.*;
import com.kerb.hurlBerl.*;
public class Terrain {
protected var moveableBodies:Array;
protected var numActiveBodies:int;
protected var binHeight:Number;
protected var bins:Array;
protected var rows:int;
protected var activeBodies:Array;
protected var numMoveableBodies:int;
protected var cols:int;
protected var numBins:int;
protected var binWidth:Number;
protected static const MASK_BITS:int = 0xFFFF;
protected static const DEAULT_BIN_HEIGHT:Number = 200;
protected static const CATEGORY_BITS:int = 1;
protected static const DEAULT_BIN_WIDTH:Number = 200;
protected static const GROUP:int = 1;
public function Terrain(_arg1:int, _arg2:int, _arg3:int=200, _arg4:int=200){
this.binWidth = _arg3;
this.binHeight = _arg4;
initBins(_arg1, _arg2);
activeBodies = new Array();
numActiveBodies = 0;
moveableBodies = new Array();
numMoveableBodies = 0;
}
protected function initRectTerrainBody(_arg1:XML, _arg2:Physics, _arg3:Number):void{
var _local4:Number = _arg1.@x;
var _local5:Number = _arg1.@y;
var _local6:Number = _arg1.@w;
var _local7:Number = _arg1.@h;
var _local8:Number = _arg1.@r;
var _local9:Number = _arg1.@fn;
var _local10:Number = _arg1.@rn;
var _local11:BoxData = _arg2.createBoxData(_local6, _local7, 0, 0, 0, 0, _local9, _local10, GROUP, CATEGORY_BITS, MASK_BITS);
var _local12:RigidBodyData = new RigidBodyData(_local4, _local5, _local8);
_local12.addShapeData(_local11);
createTerrainBody(_local12, _arg2.world, _arg3);
}
public function initTerrain(_arg1:XML, _arg2:Physics, _arg3:Number=100):void{
var _local7:XML;
var _local4:Number = _arg1.attribute("default-friction");
var _local5:Number = _arg1.attribute("default-restitution");
var _local6:XMLList = _arg1.children();
for each (_local7 in _local6) {
if (_local7.@fn.toString() == ""){
_local7.@fn = _local4;
};
if (_local7.@rn.toString() == ""){
_local7.@rn = _local5;
};
switch (_local7.@type.toString()){
case "circ":
initCircTerrainBody(_local7, _arg2, _arg3);
break;
case "rect":
initRectTerrainBody(_local7, _arg2, _arg3);
break;
};
};
trace("/*////////////////////////////////////////////////////////*");
trace(" * TERRAIN STATISTICS");
trace(((" * " + _local6.length()) + " terrain bodies"));
trace(((((((" * " + numBins) + " bins in a ") + cols) + " x ") + rows) + " matrix"));
trace(" ////////////////////////////////////////////////////////*/");
}
protected function initCircTerrainBody(_arg1:XML, _arg2:Physics, _arg3:Number):void{
var _local4:Number = _arg1.@x;
var _local5:Number = _arg1.@y;
var _local6:Number = _arg1.@r;
var _local7:Number = _arg1.@fn;
var _local8:Number = _arg1.@rn;
var _local9:CircleData = _arg2.createCircleData(_local6, 0, 0, 0, _local7, _local8, GROUP, CATEGORY_BITS, MASK_BITS);
var _local10:RigidBodyData = new RigidBodyData(_local4, _local5);
_local10.addShapeData(_local9);
createTerrainBody(_local10, _arg2.world, _arg3);
}
public function unregisterMoveableBody(_arg1:MoveableBody):void{
if (moveableBodies.indexOf(_arg1) != -1){
moveableBodies.splice(moveableBodies.indexOf(_arg1), 1);
numMoveableBodies--;
};
}
public function update(_arg1:World):void{
var _local2:int;
var _local3:int;
var _local4:Number;
var _local5:Number;
var _local6:TerrainBody;
var _local7:MoveableBody;
var _local8:Array;
var _local9:Array = new Array();
_local2 = 0;
while (_local2 < numActiveBodies) {
_local6 = activeBodies[_local2];
_local6.marked = true;
_local2++;
};
_local2 = 0;
while (_local2 < numMoveableBodies) {
_local7 = moveableBodies[_local2];
_local4 = _local7.rb.x;
_local5 = _local7.rb.y;
_local8 = getBin(_local4, _local5);
if (_local8){
_local3 = 0;
while (_local3 < _local8.length) {
_local6 = _local8[_local3];
if (_local6.checkCollision(_local4, _local5, _arg1)){
if (_local6.marked){
_local6.marked = false;
} else {
_local9.push(_local6);
};
};
_local3++;
};
};
_local2++;
};
_local2 = numActiveBodies;
while (--_local2 > -1) {
_local6 = activeBodies[_local2];
if (_local6.marked){
_local6.marked = false;
_local6.destroyRigidBody(_arg1);
activeBodies.splice(_local2, 1);
numActiveBodies--;
};
};
activeBodies = activeBodies.concat(_local9);
numActiveBodies = (numActiveBodies + _local9.length);
}
protected function getBin(_arg1:Number, _arg2:Number):Array{
var _local3:int = (_arg1 / binWidth);
var _local4:int = (_arg2 / binHeight);
var _local5:int = ((_local4 * cols) + _local3);
if ((((_local5 < 0)) || ((_local5 >= numBins)))){
return (null);
};
return (bins[_local5]);
}
protected function createTerrainBody(_arg1:RigidBodyData, _arg2:World, _arg3:Number):void{
var _local10:int;
var _local11:int;
var _local4:TerrainBody = new TerrainBody(_arg1, _arg2, _arg3);
var _local5:int = (_local4.l / binWidth);
var _local6:int = (_local4.r / binWidth);
var _local7:int = (_local4.t / binHeight);
var _local8:int = (_local4.b / binHeight);
if (_local5 < 0){
_local5 = 0;
};
if (_local6 < 0){
_local6 = 0;
};
if (_local7 < 0){
_local7 = 0;
};
if (_local8 < 0){
_local8 = 0;
};
var _local9:int = _local7;
while (_local9 <= _local8) {
_local10 = _local5;
while (_local10 <= _local6) {
_local11 = ((_local9 * cols) + _local10);
if (_local11 < numBins){
bins[_local11].push(_local4);
};
_local10++;
};
_local9++;
};
}
public function dispose():void{
bins = null;
activeBodies = null;
moveableBodies = null;
}
public function registerMoveableBody(_arg1:MoveableBody):void{
if (moveableBodies.indexOf(_arg1) == -1){
moveableBodies.push(_arg1);
numMoveableBodies++;
};
}
public function drawBins(_arg1:Graphics):void{
_arg1.lineStyle(0, Constants.BIN_GRID_COLOUR, 0.2);
var _local2:int;
while (_local2 <= rows) {
_arg1.moveTo(0, (_local2 * binHeight));
_arg1.lineTo((cols * binWidth), (_local2 * binHeight));
_local2++;
};
var _local3:int;
while (_local3 <= cols) {
_arg1.moveTo((_local3 * binWidth), 0);
_arg1.lineTo((_local3 * binWidth), (rows * binHeight));
_local3++;
};
}
protected function initBins(_arg1:int, _arg2:int):void{
cols = Math.ceil((_arg1 / binWidth));
rows = Math.ceil((_arg2 / binHeight));
numBins = (cols * rows);
bins = new Array(numBins);
var _local3:int;
while (_local3 < numBins) {
bins[_local3] = new Array();
_local3++;
};
}
}
}//package com.kerb.hurlBerl.game.physics
Section 5
//TerrainBody (com.kerb.hurlBerl.game.physics.TerrainBody)
package com.kerb.hurlBerl.game.physics {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.*;
public class TerrainBody {
public var b:Number;
public var l:Number;
protected var rb:RigidBody;
public var r:Number;
public var marked:Boolean;
public var t:Number;
protected var rbd:RigidBodyData;
public function TerrainBody(_arg1:RigidBodyData, _arg2:World, _arg3:Number){
this.rbd = _arg1;
rb = _arg2.createBody(_arg1);
l = Number.MAX_VALUE;
r = Number.MIN_VALUE;
t = Number.MAX_VALUE;
b = Number.MIN_VALUE;
var _local4:ShapeSkeleton = rb.shapeList;
while (_local4) {
if (_local4.xmin < l){
l = _local4.xmin;
};
if (_local4.xmax > r){
r = _local4.xmax;
};
if (_local4.ymin < t){
t = _local4.ymin;
};
if (_local4.ymax > b){
b = _local4.ymax;
};
_local4 = _local4.next;
};
l = (l - _arg3);
r = (r + _arg3);
t = (t - _arg3);
b = (b + _arg3);
_arg2.destroyBody(rb);
rb = null;
marked = false;
}
public function checkCollision(_arg1:Number, _arg2:Number, _arg3:World):Boolean{
if (_arg1 > l){
if (_arg1 < r){
if (_arg2 > t){
if (_arg2 < b){
if (rb == null){
rb = _arg3.createBody(rbd);
};
return (true);
} else {
if (rb){
_arg3.destroyBody(rb);
rb = null;
};
};
} else {
if (rb){
_arg3.destroyBody(rb);
rb = null;
};
};
} else {
if (rb){
_arg3.destroyBody(rb);
rb = null;
};
};
} else {
if (rb){
_arg3.destroyBody(rb);
rb = null;
};
};
return (false);
}
public function destroyRigidBody(_arg1:World):void{
if (rb){
_arg1.destroyBody(rb);
rb = null;
};
}
}
}//package com.kerb.hurlBerl.game.physics
Section 6
//AbstractLayer (com.kerb.hurlBerl.game.render.layers.AbstractLayer)
package com.kerb.hurlBerl.game.render.layers {
import flash.display.*;
import flash.geom.*;
public class AbstractLayer {
public var sprite:Sprite;
public var height:int;
public var width:int;
public var next:AbstractLayer;
public var x:Number;
public var y:Number;
protected var id:int;
protected static var idCount:int = 0;
public function AbstractLayer(_arg1:int, _arg2:int){
id = idCount++;
super();
this.width = _arg1;
this.height = _arg2;
x = 0;
y = 0;
sprite = new Sprite();
}
public function localToViewport(_arg1:Point):void{
}
public function update(_arg1:Number, _arg2:Number, _arg3:int, _arg4:int):void{
}
public function viewportToLocal(_arg1:Point):void{
}
public function dispose():void{
}
}
}//package com.kerb.hurlBerl.game.render.layers
Section 7
//BitmapAsset (com.kerb.hurlBerl.game.render.layers.BitmapAsset)
package com.kerb.hurlBerl.game.render.layers {
public class BitmapAsset {
public var col:int;
public var b:int;
public var l:int;
public var r:int;
public var next:BitmapAsset;
public var t:int;
public var row:int;
public var id:String;
public function BitmapAsset(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:String){
l = _arg1;
r = (_arg1 + _arg3);
t = _arg2;
b = (_arg2 + _arg4);
this.id = _arg5;
}
public function setGridCoordinates(_arg1:int, _arg2:int):void{
this.col = _arg1;
this.row = _arg2;
}
}
}//package com.kerb.hurlBerl.game.render.layers
Section 8
//BitmapGridLayer (com.kerb.hurlBerl.game.render.layers.BitmapGridLayer)
package com.kerb.hurlBerl.game.render.layers {
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import com.kerb.hurlBerl.*;
public class BitmapGridLayer extends BitmapLayer {
protected var rowHeight:int;
protected var tiles:Dictionary;
protected var colWidth:int;
protected var tileRect:Rectangle;
public function BitmapGridLayer(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:XML){
tiles = new Dictionary();
super(_arg1, _arg2, _arg3, _arg4, _arg5);
}
override public function update(_arg1:Number, _arg2:Number, _arg3:int, _arg4:int):void{
var _local9:int;
var _local10:int;
var _local11:BitmapData;
this.x = _arg1;
this.y = _arg2;
var _local5:int = (-(_arg1) / colWidth);
var _local6:int = (((_arg3 - _arg1) / colWidth) + 1);
var _local7:int = (-(_arg2) / rowHeight);
var _local8:int = (((_arg4 - _arg2) / rowHeight) + 1);
displayBitmapData.lock();
if (backgroundBitmapData){
displayBitmapData.copyPixels(backgroundBitmapData, displayBitmapData.rect, ZERO_POINT);
} else {
displayBitmapData.fillRect(displayBitmapData.rect, 0);
};
_local9 = _local7;
while (_local9 <= _local8) {
pt.y = ((_local9 * rowHeight) + _arg2);
_local10 = _local5;
while (_local10 <= _local6) {
if (tiles[((_local10 + "|") + _local9)]){
_local11 = bitmaps[tiles[((_local10 + "|") + _local9)]];
if (_local11){
pt.x = ((_local10 * colWidth) + _arg1);
displayBitmapData.copyPixels(_local11, tileRect, pt);
};
};
_local10++;
};
_local9++;
};
displayBitmapData.unlock();
}
override protected function initBitmaps(_arg1:XML):void{
var _local2:XML;
var _local3:String;
var _local4:String;
var _local5:BitmapData;
var _local6:BitmapData;
var _local7:int;
var _local8:int;
var _local9:int;
var _local10:int;
var _local11:BitmapAsset;
colWidth = parseInt(_arg1.@colWidth);
rowHeight = parseInt(_arg1.@rowHeight);
tileRect = new Rectangle(0, 0, colWidth, rowHeight);
for each (_local2 in _arg1..source) {
_local3 = _local2.@id.toString();
_local4 = _local2.@linkage.toString();
_local5 = Main.af.createBitmapDataObject(_local4);
_local6 = new BitmapData(colWidth, rowHeight, true, 0);
_local6.copyPixels(_local5, _local6.rect, ZERO_POINT);
bitmaps[_local3] = _local6;
};
_local5.dispose();
for each (_local2 in _arg1..bitmap) {
_local9 = parseInt(_local2.@col);
_local10 = parseInt(_local2.@row);
_local3 = _local2.@id.toString();
if (bitmaps[_local3]){
tiles[((_local9 + "|") + _local10)] = _local3;
};
};
}
override public function dispose():void{
super.dispose();
tiles = null;
}
}
}//package com.kerb.hurlBerl.game.render.layers
Section 9
//BitmapLayer (com.kerb.hurlBerl.game.render.layers.BitmapLayer)
package com.kerb.hurlBerl.game.render.layers {
import flash.display.*;
import flash.geom.*;
import flash.utils.*;
import com.kerb.hurlBerl.*;
public class BitmapLayer extends AbstractLayer {
protected var head:BitmapAsset;
protected var pt:Point;
protected var backgroundBitmapData:BitmapData;
protected var bitmaps:Dictionary;
protected var displayBitmap:Bitmap;
protected var displayBitmapData:BitmapData;
protected static const SMOOTHING:Boolean = false;
protected static const PIXEL_SNAPPING:String = PixelSnapping.NEVER;
protected static const ZERO_POINT:Point = new Point(0, 0);
public function BitmapLayer(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:XML){
super(_arg1, _arg2);
displayBitmapData = new BitmapData(_arg3, _arg4, true, 0);
displayBitmap = new Bitmap(displayBitmapData, PIXEL_SNAPPING, SMOOTHING);
sprite.addChild(displayBitmap);
bitmaps = new Dictionary();
pt = new Point();
initBitmaps(_arg5);
}
override public function update(_arg1:Number, _arg2:Number, _arg3:int, _arg4:int):void{
var _local10:BitmapData;
this.x = _arg1;
this.y = _arg2;
var _local5:Number = -(_arg1);
var _local6:Number = (_local5 + _arg3);
var _local7:Number = -(_arg2);
var _local8:Number = (_local7 + _arg4);
displayBitmapData.lock();
if (backgroundBitmapData){
displayBitmapData.copyPixels(backgroundBitmapData, displayBitmapData.rect, ZERO_POINT);
} else {
displayBitmapData.fillRect(displayBitmapData.rect, 0);
};
var _local9:BitmapAsset = head;
while (_local9) {
if (_local9.l < _local6){
if (_local9.r > _local5){
if (_local9.t < _local8){
if (_local9.b > _local7){
pt.x = (_local9.l + _arg1);
pt.y = (_local9.t + _arg2);
_local10 = bitmaps[_local9.id];
displayBitmapData.copyPixels(_local10, _local10.rect, pt);
};
};
};
};
_local9 = _local9.next;
};
displayBitmapData.unlock();
}
public function setBackground(_arg1:IBitmapDrawable):void{
backgroundBitmapData = displayBitmapData.clone();
backgroundBitmapData.draw(_arg1);
}
protected function initBitmaps(_arg1:XML):void{
var _local2:XML;
var _local3:String;
var _local4:String;
var _local5:BitmapData;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
var _local10:BitmapAsset;
for each (_local2 in _arg1..source) {
_local3 = _local2.@id.toString();
_local4 = _local2.@linkage.toString();
_local5 = Main.af.createBitmapDataObject(_local4);
bitmaps[_local3] = _local5;
};
for each (_local2 in _arg1..bitmap) {
_local6 = parseInt(_local2.@x);
_local7 = parseInt(_local2.@y);
_local3 = _local2.@id.toString();
if (bitmaps[_local3]){
_local8 = bitmaps[_local3].width;
_local9 = bitmaps[_local3].height;
_local10 = new BitmapAsset(_local6, _local7, _local8, _local9, _local3);
_local10.next = head;
head = _local10;
};
};
}
override public function dispose():void{
displayBitmapData.dispose();
if (backgroundBitmapData){
backgroundBitmapData.dispose();
};
head = null;
bitmaps = null;
}
}
}//package com.kerb.hurlBerl.game.render.layers
Section 10
//EmptyLayer (com.kerb.hurlBerl.game.render.layers.EmptyLayer)
package com.kerb.hurlBerl.game.render.layers {
public class EmptyLayer extends AbstractLayer {
public function EmptyLayer(_arg1:int, _arg2:int){
super(_arg1, _arg2);
}
override public function update(_arg1:Number, _arg2:Number, _arg3:int, _arg4:int):void{
this.x = _arg1;
this.y = _arg2;
sprite.x = _arg1;
sprite.y = _arg2;
}
}
}//package com.kerb.hurlBerl.game.render.layers
Section 11
//MovieClipLayer (com.kerb.hurlBerl.game.render.layers.MovieClipLayer)
package com.kerb.hurlBerl.game.render.layers {
import flash.display.*;
import flash.geom.*;
public class MovieClipLayer extends AbstractLayer {
protected var head:MovieClip;
public function MovieClipLayer(_arg1:int, _arg2:int, _arg3:MovieClip, _arg4:Boolean=false){
super(_arg1, _arg2);
if (_arg4){
sprite.addChild(_arg3);
} else {
initMovieClips(_arg3);
};
}
override public function update(_arg1:Number, _arg2:Number, _arg3:int, _arg4:int):void{
this.x = _arg1;
this.y = _arg2;
sprite.x = _arg1;
sprite.y = _arg2;
var _local5:Number = -(_arg1);
var _local6:Number = (_local5 + _arg3);
var _local7:Number = -(_arg2);
var _local8:Number = (_local7 + _arg4);
var _local9:MovieClip = head;
while (_local9) {
if (_local9.l < _local6){
if (_local9.r > _local5){
if (_local9.t < _local8){
if (_local9.b > _local7){
if (!_local9.parent){
_local9.container.addChild(_local9);
};
} else {
if (_local9.parent){
_local9.container.removeChild(_local9);
};
};
} else {
if (_local9.parent){
_local9.container.removeChild(_local9);
};
};
} else {
if (_local9.parent){
_local9.container.removeChild(_local9);
};
};
} else {
if (_local9.parent){
_local9.container.removeChild(_local9);
};
};
_local9 = _local9.next;
};
}
protected function initMovieClips(_arg1:MovieClip):void{
var _local2:int;
var _local3:int;
var _local4:MovieClip;
var _local5:MovieClip;
var _local6:Sprite;
var _local7:Rectangle;
var _local8:Boolean;
if (_arg1){
_local3 = _arg1.numChildren;
_local2 = 0;
while (_local2 < _local3) {
if ((_arg1.getChildAt(_local2) is MovieClip)){
_local5 = (_arg1.getChildAt(_local2) as MovieClip);
_arg1.removeChild(_local5);
_local2--;
_local3--;
if (_local4){
_local4.next = _local5;
} else {
head = _local5;
};
_local4 = _local5;
_local6 = new Sprite();
_local5.container = _local6;
sprite.addChild(_local6);
_local5.cacheAsBitmap = true;
_local7 = _local5.getBounds(_arg1);
_local5.l = _local7.left;
_local5.r = _local7.right;
_local5.t = _local7.top;
_local5.b = _local7.bottom;
} else {
_local8 = true;
};
_local2++;
};
};
if (_local8){
trace(("WARNING: LAYER " + id));
trace((("The source movieclip (" + _arg1) + ") contains children that are not movieclips."));
trace("These children will not be rendered.");
};
}
}
}//package com.kerb.hurlBerl.game.render.layers
Section 12
//Camera (com.kerb.hurlBerl.game.render.Camera)
package com.kerb.hurlBerl.game.render {
public class Camera {
protected var _goalX:Number;
protected var _goalY:Number;
protected var _easingX:Number;
protected var _easingY:Number;
protected var _x:Number;
protected var _y:Number;
public function Camera(_arg1:Number, _arg2:Number){
cutTo(_arg1, _arg2);
setEasing(1, 1);
}
public function get y():Number{
return (_y);
}
public function get easingX():Number{
return (_easingX);
}
public function cutTo(_arg1:Number, _arg2:Number):void{
_goalX = (_x = _arg1);
_goalY = (_y = _arg2);
}
public function get goalX():Number{
return (_goalX);
}
public function moveBy(_arg1:Number, _arg2:Number):void{
_goalX = (_goalX + _arg1);
_goalY = (_goalY + _arg2);
}
public function update():void{
_x = (_x + (_easingX * (_goalX - _x)));
_y = (_y + (_easingY * (_goalY - _y)));
}
public function get goalY():Number{
return (_goalY);
}
public function setEasing(_arg1:Number, _arg2:Number):void{
if (_arg1 > 1){
_arg1 = 1;
} else {
if (_arg1 < 0){
_arg1 = 0;
};
};
_easingX = _arg1;
if (_arg2 > 1){
_arg2 = 1;
} else {
if (_arg2 < 0){
_arg2 = 0;
};
};
_easingY = _arg2;
}
public function get x():Number{
return (_x);
}
public function moveTo(_arg1:Number, _arg2:Number):void{
_goalX = _arg1;
_goalY = _arg2;
}
public function get easingY():Number{
return (_easingY);
}
}
}//package com.kerb.hurlBerl.game.render
Section 13
//Renderer (com.kerb.hurlBerl.game.render.Renderer)
package com.kerb.hurlBerl.game.render {
import flash.display.*;
import flash.geom.*;
import com.kerb.hurlBerl.game.render.layers.*;
import com.kerb.hurlBerl.*;
public class Renderer extends Sprite {
protected var cpxHalf:Number;
protected var scaledViewportWidth:Number;
protected var scaledCameraRect:Rectangle;
protected var camera:Camera;
protected var cameraRect:Rectangle;
protected var cpx:Number;
protected var cameraRatioX:Number;
protected var cameraRatioY:Number;
protected var zoomScale:Number;
protected var cameraLayer:AbstractLayer;
protected var viewportWidth:int;
protected var moveableLayers:AbstractLayer;
protected var cpy:Number;
protected var layerMask:Shape;
protected var fixedLayers:AbstractLayer;
protected var scaledViewportHeight:Number;
protected var viewportHeight:int;
protected var layerSprite:Sprite;
protected var cpyHalf:Number;
public function Renderer(_arg1:int, _arg2:int, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number){
zoomScale = 1;
layerSprite = new Sprite();
addChild(layerSprite);
setViewport(_arg1, _arg2);
camera = new Camera(_arg3, _arg4);
cameraRect = new Rectangle(0, 0, _arg1, _arg2);
scaledCameraRect = new Rectangle(0, 0, _arg1, _arg2);
setCameraPadding(_arg5, _arg6);
graphics.beginFill(Constants.VIEWPORT_BACKGROUND_COLOUR);
graphics.drawRect(0, 0, _arg1, _arg2);
graphics.endFill();
}
public function set scale(_arg1:Number):void{
zoomScale = _arg1;
layerSprite.scaleX = (layerSprite.scaleY = zoomScale);
scaledViewportWidth = (viewportWidth / zoomScale);
scaledViewportHeight = (viewportHeight / zoomScale);
scaledCameraRect.left = (cameraRect.left / zoomScale);
scaledCameraRect.right = (cameraRect.right / zoomScale);
scaledCameraRect.top = (cameraRect.top / zoomScale);
scaledCameraRect.bottom = (cameraRect.bottom / zoomScale);
}
public function getCamera():Camera{
return (camera);
}
public function dispose():void{
var _local1:AbstractLayer;
_local1 = fixedLayers;
while (_local1) {
_local1.dispose();
_local1 = _local1.next;
};
fixedLayers = null;
_local1 = moveableLayers;
while (_local1) {
_local1.dispose();
_local1 = _local1.next;
};
moveableLayers = null;
cameraLayer = null;
camera = null;
}
public function createBitmapGridLayer(_arg1:int, _arg2:int, _arg3:XML, _arg4:Boolean=false, _arg5:int=-1):BitmapGridLayer{
var _local6:BitmapGridLayer = new BitmapGridLayer(_arg1, _arg2, viewportWidth, viewportHeight, _arg3);
setupNewLayer(_local6, _arg4, _arg5);
return (_local6);
}
public function getCameraRect():Rectangle{
return (cameraRect);
}
public function createEmptyLayer(_arg1:int, _arg2:int, _arg3:Boolean=false, _arg4:int=-1):EmptyLayer{
var _local5:EmptyLayer = new EmptyLayer(_arg1, _arg2);
setupNewLayer(_local5, _arg3, _arg4);
return (_local5);
}
public function setViewport(_arg1:int, _arg2:int):void{
viewportWidth = _arg1;
viewportHeight = _arg2;
scaledViewportWidth = (viewportWidth / zoomScale);
scaledViewportHeight = (viewportHeight / zoomScale);
if (!layerMask){
layerMask = new Shape();
addChild(layerMask);
this.mask = layerMask;
};
layerMask.graphics.clear();
layerMask.graphics.beginFill(0);
layerMask.graphics.drawRect(0, 0, _arg1, _arg2);
layerMask.graphics.endFill();
}
public function createMovieClipLayer(_arg1:int, _arg2:int, _arg3:MovieClip, _arg4:Boolean=false, _arg5:Boolean=false, _arg6:int=-1):MovieClipLayer{
var _local7:MovieClipLayer = new MovieClipLayer(_arg1, _arg2, _arg3, _arg5);
setupNewLayer(_local7, _arg4, _arg6);
return (_local7);
}
protected function setupNewLayer(_arg1:AbstractLayer, _arg2:Boolean=false, _arg3:int=-1):void{
if (_arg3 == -1){
layerSprite.addChild(_arg1.sprite);
} else {
if (_arg3 < 0){
_arg3 = 0;
} else {
if (_arg3 > layerSprite.numChildren){
_arg3 = layerSprite.numChildren;
};
};
layerSprite.addChildAt(_arg1.sprite, _arg3);
};
if ((((_arg1.width == 0)) && ((_arg1.height == 0)))){
_arg1.next = fixedLayers;
fixedLayers = _arg1;
_arg1.update(_arg1.x, _arg1.y, scaledViewportWidth, scaledViewportHeight);
} else {
_arg1.next = moveableLayers;
moveableLayers = _arg1;
};
if (((_arg2) || ((cameraLayer == null)))){
setCameraLayer(_arg1);
};
}
public function get cameraPaddingY():Number{
return (cpy);
}
public function get vh():int{
return (viewportHeight);
}
public function get vw():int{
return (viewportWidth);
}
public function setCameraRect(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
cameraRect.x = _arg1;
cameraRect.y = _arg2;
cameraRect.width = _arg3;
cameraRect.height = _arg4;
scaledCameraRect.left = (cameraRect.left / zoomScale);
scaledCameraRect.right = (cameraRect.right / zoomScale);
scaledCameraRect.top = (cameraRect.top / zoomScale);
scaledCameraRect.bottom = (cameraRect.bottom / zoomScale);
}
public function draw(_arg1:Number, _arg2:Number):void{
var _local6:Number;
var _local7:Number;
camera.moveTo(_arg1, _arg2);
camera.update();
var _local3:Number = ((camera.x - cpxHalf) / (cameraLayer.width - cpx));
var _local4:Number = ((camera.y - cpyHalf) / (cameraLayer.height - cpy));
cameraLayer.x = ((_local3 * scaledCameraRect.width) + (scaledCameraRect.left - camera.x));
cameraLayer.y = ((_local4 * scaledCameraRect.height) + (scaledCameraRect.top - camera.y));
var _local5:AbstractLayer = moveableLayers;
while (_local5) {
if (_local5 == cameraLayer){
_local6 = _local5.x;
_local7 = _local5.y;
} else {
if (_local5.width == 0){
_local6 = 0;
} else {
_local6 = (_local3 * (scaledViewportWidth - _local5.width));
};
if (_local5.height == 0){
_local7 = 0;
} else {
_local7 = (_local4 * (scaledViewportHeight - _local5.height));
};
};
_local5.update(_local6, _local7, scaledViewportWidth, scaledViewportHeight);
_local5 = _local5.next;
};
}
public function get scale():Number{
return (zoomScale);
}
public function createBitmapLayer(_arg1:int, _arg2:int, _arg3:XML, _arg4:Boolean=false, _arg5:int=-1):BitmapLayer{
var _local6:BitmapLayer = new BitmapLayer(_arg1, _arg2, viewportWidth, viewportHeight, _arg3);
setupNewLayer(_local6, _arg4, _arg5);
return (_local6);
}
public function setCameraLayer(_arg1:AbstractLayer):void{
cameraLayer = _arg1;
var _local2:int = cameraLayer.width;
var _local3:int = cameraLayer.height;
}
public function setCameraPadding(_arg1:Number, _arg2:Number):void{
cpx = _arg1;
cpy = _arg2;
cpxHalf = (0.5 * cpx);
cpyHalf = (0.5 * cpy);
}
public function get cameraPaddingX():Number{
return (cpx);
}
public function getPointInViewport(_arg1:Number, _arg2:Number):Point{
var _local3:Point = new Point(_arg1, _arg2);
return (cameraLayer.sprite.globalToLocal(_local3));
}
}
}//package com.kerb.hurlBerl.game.render
Section 14
//ISerialisable (com.kerb.hurlBerl.game.utils.ISerialisable)
package com.kerb.hurlBerl.game.utils {
import flash.utils.*;
public interface ISerialisable {
function deserialise(_arg1:ByteArray):void;
function serialise():ByteArray;
}
}//package com.kerb.hurlBerl.game.utils
Section 15
//KeyboardControl (com.kerb.hurlBerl.game.utils.KeyboardControl)
package com.kerb.hurlBerl.game.utils {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.ui.*;
import flash.errors.*;
public class KeyboardControl extends EventDispatcher implements ISerialisable {
protected var k:uint;// = 0
protected var replayingHistory:Boolean;
protected var replayCompleteEvent:Event;
protected var history:ByteArray;
public static const RIGHT_DOWN:uint = (1 << 3);
public static const UP_DOWN:uint = (1 << 5);
protected static const LEFT:uint = (LEFT_PRESSED + LEFT_DOWN);
protected static const ALL_PRESSED:uint = ((((LEFT_PRESSED + RIGHT_PRESSED) + UP_PRESSED) + DOWN_PRESSED) + SPACE_PRESSED);
public static const LEFT_PRESSED:uint = (1 << 0);
public static const LEFT_DOWN:uint = (1 << 1);
public static const SPACE_DOWN:uint = (1 << 9);
public static const UP_PRESSED:uint = (1 << 4);
public static const DOWN_DOWN:uint = (1 << 7);
protected static const ALL_DOWN:uint = ((((LEFT_DOWN + RIGHT_DOWN) + UP_DOWN) + DOWN_DOWN) + SPACE_DOWN);
public static const DOWN_PRESSED:uint = (1 << 6);
protected static const SPACE:uint = (SPACE_PRESSED + SPACE_DOWN);
public static const SPACE_PRESSED:uint = (1 << 8);
protected static const UP:uint = (UP_PRESSED + UP_DOWN);
protected static const DOWN:uint = (DOWN_PRESSED + DOWN_DOWN);
protected static const RIGHT:uint = (RIGHT_PRESSED + RIGHT_DOWN);
public static const RIGHT_PRESSED:uint = (1 << 2);
public function KeyboardControl(_arg1:Stage){
_arg1.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true);
_arg1.addEventListener(KeyboardEvent.KEY_UP, onKeyUp, false, 0, true);
replayCompleteEvent = new Event(Event.COMPLETE);
resetHistory();
}
protected function onKeyDown(_arg1:KeyboardEvent):void{
var _local2:uint = _arg1.keyCode;
if ((((_local2 == Keyboard.LEFT)) && (!((k & LEFT_DOWN))))){
k = (k | LEFT);
} else {
if ((((_local2 == Keyboard.RIGHT)) && (!((k & RIGHT_DOWN))))){
k = (k | RIGHT);
} else {
if ((((_local2 == Keyboard.UP)) && (!((k & UP_DOWN))))){
k = (k | UP);
} else {
if ((((_local2 == Keyboard.DOWN)) && (!((k & DOWN_DOWN))))){
k = (k | DOWN);
} else {
if ((((_local2 == Keyboard.SPACE)) && (!((k & SPACE_DOWN))))){
k = (k | SPACE);
};
};
};
};
};
}
public function get keys():uint{
var kOut:uint;
if (replayingHistory){
try {
kOut = history.readUnsignedInt();
} catch(e:EOFError) {
kOut = 0;
dispatchEvent(replayCompleteEvent);
};
} else {
history.writeUnsignedInt(k);
kOut = k;
k = (k & ALL_DOWN);
};
return (kOut);
}
public function resetHistory():void{
history = new ByteArray();
replayingHistory = false;
}
public function deserialise(_arg1:ByteArray):void{
_arg1.position = 0;
var _local2:Object = _arg1.readObject();
history = _local2.history;
}
public function serialise():ByteArray{
var _local1:Object = new Object();
_local1.history = history;
var _local2:ByteArray = new ByteArray();
_local2.writeObject(_local1);
return (_local2);
}
protected function onKeyUp(_arg1:KeyboardEvent):void{
var _local2:uint = _arg1.keyCode;
if (_local2 == Keyboard.LEFT){
k = (k & ~(LEFT));
} else {
if (_local2 == Keyboard.RIGHT){
k = (k & ~(RIGHT));
} else {
if (_local2 == Keyboard.UP){
k = (k & ~(UP));
} else {
if (_local2 == Keyboard.DOWN){
k = (k & ~(DOWN));
} else {
if (_local2 == Keyboard.SPACE){
k = (k & ~(SPACE));
};
};
};
};
};
}
public function replayHistory():void{
history.position = 0;
replayingHistory = true;
}
}
}//package com.kerb.hurlBerl.game.utils
Section 16
//Serialiser (com.kerb.hurlBerl.game.utils.Serialiser)
package com.kerb.hurlBerl.game.utils {
import flash.utils.*;
public class Serialiser {
protected var items:Array;
protected var data:ByteArray;
public function Serialiser(){
items = new Array();
data = new ByteArray();
}
public function get checkpoint():ByteArray{
return (data);
}
public function saveCheckpoint():ByteArray{
data = new ByteArray();
var _local1:int = items.length;
var _local2:int;
while (_local2 < _local1) {
data.writeObject(items[_local2].serialise());
_local2++;
};
return (data);
}
public function unwatch(_arg1:ISerialisable):void{
items.splice(items.indexOf(_arg1), 1);
}
public function set checkpoint(_arg1:ByteArray):void{
this.data = _arg1;
}
public function restoreCheckpoint():void{
data.position = 0;
var _local1:int = items.length;
var _local2:int;
while (_local2 < _local1) {
items[_local2].deserialise(data.readObject());
_local2++;
};
}
public function watch(_arg1:ISerialisable):void{
if (items.indexOf(_arg1) == -1){
items.push(_arg1);
};
}
}
}//package com.kerb.hurlBerl.game.utils
Section 17
//AbstractScreen (com.kerb.hurlBerl.screens.AbstractScreen)
package com.kerb.hurlBerl.screens {
import flash.events.*;
import flash.display.*;
public class AbstractScreen extends Sprite {
protected var keyNav:KeyboardNavigator;
public function AbstractScreen(){
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage, false, 0, true);
}
protected function init():void{
}
public function hide():void{
deactivate();
dispatchEvent(new ScreenEvent(ScreenEvent.REMOVE_THIS));
}
public function notifyUnderneath():void{
}
protected function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
keyNav = new KeyboardNavigator(stage);
stage.focus = stage;
init();
}
public function deactivate():void{
if (keyNav){
keyNav.dispose();
};
stage.focus = stage;
}
public function notifyOnTop():void{
}
public function dispose():void{
deactivate();
}
}
}//package com.kerb.hurlBerl.screens
Section 18
//DebugControlPanel (com.kerb.hurlBerl.screens.DebugControlPanel)
package com.kerb.hurlBerl.screens {
import flash.events.*;
import flash.display.*;
import com.kerb.hurlBerl.*;
public class DebugControlPanel extends AbstractScreen {
private var mc:MovieClip;
override protected function init():void{
mc = Main.af.createMovieClip("DebugControlPanelScreenAsset");
addChild(mc);
mc.close_btn.addEventListener(MouseEvent.CLICK, onCloseClick, false, 0, true);
keyNav.setDefaultAction(onCloseClick);
}
override public function deactivate():void{
super.deactivate();
mc.close_btn.removeEventListener(MouseEvent.CLICK, onCloseClick);
}
private function onCloseClick(_arg1:MouseEvent=null):void{
dispatchEvent(new ScreenEvent(ScreenEvent.REMOVE_THIS));
}
}
}//package com.kerb.hurlBerl.screens
Section 19
//Game (com.kerb.hurlBerl.screens.Game)
package com.kerb.hurlBerl.screens {
import flash.events.*;
import flash.display.*;
import flash.geom.*;
import com.kerb.hurlBerl.game.render.layers.*;
import com.kerb.hurlBerl.game.render.*;
import com.kerb.hurlBerl.game.utils.*;
import com.kerb.hurlBerl.game.physics.*;
import com.kerb.hurlBerl.*;
import mx.core.*;
import com.kerb.ui.*;
import com.kerb.tracking.*;
public class Game extends AbstractScreen {
public var BitmapGridAssetData:Class;
private var meter:MovieClip;
private var power:Number;
private var state:int;
private var ui:MovieClip;
private var swingMC:MovieClip;
protected var uiLayer:EmptyLayer;
protected var wireframeLayer:EmptyLayer;
private var paused:Boolean;
private var xMungeOffset:Number;// = 250
protected var renderer:Renderer;
protected var physics:Physics;
protected var serialiser:Serialiser;
private var throwForceX:Number;// = 0
private var throwForceY:Number;// = 0
protected var avatar:Avatar;
private var angle:Number;// = 0
private var clouds:Array;
public var TerrainData:Class;
private var landingCounter:int;
private var numStepsToApplyPower:int;// = 0
protected var avatarLayer:EmptyLayer;
protected var keyControl:KeyboardControl;
private static const MAX_POWER_FRAME:int = 35;
private static const NUM_LANDING_FRAMES:int = 60;
private static const MAX_POWER:Number = 800000;
private static const STATE_SET_PITCH:int = 1;
private static const STATE_THROW:int = 3;
private static const STATE_LAND:int = 4;
private static const STATE_SET_POWER:int = 0;
private static const STATE_SET_THROW:int = 2;
private static const STATE_BAD_THROW:int = 5;
private static const MIN_POWER:Number = 20000;
public static var score:int;
public function Game(){
TerrainData = Game_TerrainData;
BitmapGridAssetData = Game_BitmapGridAssetData;
super();
}
protected function createXML(_arg1:Class):XML{
var _local4:XML;
var _local2:ByteArrayAsset = ByteArrayAsset(new (_arg1));
var _local3:String = _local2.readUTFBytes(3);
if (_local3.length == 1){
return (new XML(_local2.readUTFBytes((_local2.length - 3))));
};
return (new XML((_local3 + _local2.readUTFBytes((_local2.length - 3)))));
}
override protected function init():void{
var _local3:int;
var _local10:int;
var _local11:MovieClip;
keyNav.dispose();
keyNav = null;
var _local1 = 20000;
var _local2 = 3000;
physics = new Physics(_local1, _local2, createXML(TerrainData));
avatar = new Avatar(350, 2980, physics);
physics.terrain.registerMoveableBody(avatar);
clouds = new Array();
clouds.push(new Point(1100, 800));
clouds.push(new Point(1300, 1800));
clouds.push(new Point(1900, 2100));
clouds.push(new Point(2008, 1100));
clouds.push(new Point(2300, 1600));
clouds.push(new Point(2700, 1915));
clouds.push(new Point(3300, 2073));
clouds.push(new Point(2650, 700));
clouds.push(new Point(3005, 1100));
clouds.push(new Point(3500, 1400));
clouds.push(new Point(3900, 2230));
clouds.push(new Point(4250, 1550));
clouds.push(new Point(4279, 1072));
clouds.push(new Point(4400, 2230));
clouds.push(new Point(5000, 2430));
clouds.push(new Point(5098, 1605));
clouds.push(new Point(5700, 1600));
clouds.push(new Point(5800, 1100));
clouds.push(new Point(6300, 700));
clouds.push(new Point(6515, 1998));
clouds.push(new Point(7100, 1500));
clouds.push(new Point(7300, 1100));
clouds.push(new Point(7800, 2100));
clouds.push(new Point(8073, 1626));
clouds.push(new Point(8233, 830));
clouds.push(new Point(8800, 2000));
clouds.push(new Point(8800, 1400));
clouds.push(new Point(9451, 1334));
clouds.push(new Point(9600, 2500));
clouds.push(new Point(10200, 2300));
clouds.push(new Point(10700, 2000));
clouds.push(new Point(11188, 2461));
clouds.push(new Point(12451, 2500));
clouds.push(new Point(12600, 1334));
clouds.push(new Point(13200, 2461));
clouds.push(new Point(13700, 2300));
clouds.push(new Point(14188, 2000));
_local3 = clouds.length;
while (--_local3 > -1) {
clouds.push(new Point((clouds[_local3].x + 800), (clouds[_local3].y - 500)));
};
Main.smSFX.getSoundByClassName("CheerSound").stop();
Main.smSFX.getSoundByClassName("GameMusicSound").play(0, 99999999);
var _local4 = 550;
var _local5 = 400;
var _local6:Number = avatar.x;
var _local7:Number = avatar.y;
var _local8:Number = avatar.width;
var _local9:Number = avatar.height;
renderer = new Renderer(_local4, _local5, _local6, _local7, _local8, _local9);
renderer.x = 0;
renderer.y = 0;
renderer.setCameraRect(100, 100, 350, 200);
renderer.getCamera().setEasing(0.5, 0.5);
renderer.createMovieClipLayer(0, 1000, Main.af.createMovieClip("GameBackgroundAsset"));
renderer.createBitmapGridLayer(_local1, (0.5 * _local2), createXML(BitmapGridAssetData));
avatarLayer = renderer.createEmptyLayer(physics.worldWidth, physics.worldHeight, true);
if (Constants.locale == "it_IT"){
swingMC = Main.af.createMovieClip("SwingITAsset");
} else {
if (Constants.locale == "de_DE"){
swingMC = Main.af.createMovieClip("SwingDEAsset");
} else {
swingMC = Main.af.createMovieClip("SwingENAsset");
};
};
swingMC.x = 350;
swingMC.y = 2850;
swingMC.scaleX = (swingMC.scaleY = 0.7);
swingMC.loop = true;
avatarLayer.sprite.addChild(swingMC);
_local3 = 0;
while (_local3 < clouds.length) {
_local10 = ((3 * Math.random()) + 1);
_local11 = Main.af.createMovieClip((("Cloud" + _local10) + "Asset"));
_local11.x = clouds[_local3].x;
_local11.y = clouds[_local3].y;
avatarLayer.sprite.addChild(_local11);
_local3++;
};
uiLayer = renderer.createEmptyLayer(0, 0);
if (Constants.locale == "it_IT"){
ui = Main.af.createMovieClip("GameScreenITAsset");
} else {
if (Constants.locale == "de_DE"){
ui = Main.af.createMovieClip("GameScreenDEAsset");
} else {
ui = Main.af.createMovieClip("GameScreenENAsset");
};
};
ui.logo_btn.addEventListener(MouseEvent.CLICK, onLogoClick, false, 0, true);
ui.help_btn.addEventListener(MouseEvent.CLICK, onHelpClick, false, 0, true);
ui.distance_txt.htmlText = "<b>0000</b>";
uiLayer.sprite.addChild(ui);
serialiser = new Serialiser();
serialiser.watch(avatar);
avatarLayer.sprite.addChild(avatar.mc);
avatar.mc.scaleX = 1.5;
avatar.mc.scaleY = 1.5;
avatar.mc.visible = false;
addChild(renderer);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true);
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false, 0, true);
state = STATE_SET_PITCH;
meter = Main.af.createMovieClip("PitchMeterAsset");
meter.x = 333;
meter.y = 154;
uiLayer.sprite.addChild(meter);
score = 0;
startGame();
}
override public function dispose():void{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
ui.logo_btn.removeEventListener(MouseEvent.CLICK, onLogoClick);
ui.help_btn.removeEventListener(MouseEvent.CLICK, onHelpClick);
avatar = null;
physics.dispose();
physics = null;
renderer.dispose();
removeChild(renderer);
renderer = null;
}
private function onLogoClick(_arg1:MouseEvent):void{
DoubleQuick.click(455);
}
override public function notifyOnTop():void{
resume();
}
public function resume():void{
addEventListener(Event.ENTER_FRAME, onEnterFrame);
paused = false;
}
protected function onEnterFrame(_arg1:Event):void{
var _local2:Number;
var _local7:Number;
var _local8:Number;
var _local9:int;
var _local10:Number;
var _local11:MovieClip;
var _local12:Number;
var _local13:Number;
var _local3:int;
while (_local3 < clouds.length) {
_local7 = (avatar.x - clouds[_local3].x);
_local8 = (avatar.y - clouds[_local3].y);
_local2 = ((_local7 * _local7) + (_local8 * _local8));
if (_local2 < (100 * 100)){
avatar.rb.applyForce(throwForceX, throwForceY);
_local9 = (Math.random() * 200);
Main.smSFX.getSoundByClassName("BounceSound").play(_local9);
};
_local3++;
};
if (state == STATE_THROW){
if (xMungeOffset > 10){
xMungeOffset = (xMungeOffset - 10);
};
if (swingMC.currentFrame <= 24){
if (swingMC.currentFrame == 24){
numStepsToApplyPower = 10;
avatar.rb.setCenter((swingMC.x + 80), (swingMC.y - 80), 1.57);
avatar.mc.visible = true;
};
} else {
if (numStepsToApplyPower-- > 0){
avatar.rb.applyForceAt(throwForceX, throwForceY, avatar.x, (avatar.y + 2));
};
avatar.wobble();
_local2 = (avatar.x / 20);
if (avatar.y >= 2980){
if (!avatar.landed){
avatar.landed = true;
_local11 = Main.af.createMovieClip("AvatarLandingAsset");
avatarLayer.sprite.removeChild(avatar.mc);
avatar.mc = _local11;
avatarLayer.sprite.addChild(avatar.mc);
Main.smSFX.getSoundByClassName("WindSound").stop();
Main.smSFX.getSoundByClassName("LandingSound").play();
};
_local10 = ((avatar.rb.vx * avatar.rb.vx) + (avatar.rb.vy * avatar.rb.vy));
if (_local10 < 2){
landingCounter = 0;
state = STATE_LAND;
Main.smSFX.getSoundByClassName("CheerSound").play();
};
};
ui.distance_txt.htmlText = (("<b>" + ("0000" + int(_local2)).substr(-4)) + "</b>");
};
} else {
if (state == STATE_BAD_THROW){
if (swingMC.currentFrame == swingMC.totalFrames){
score = 0;
dispatchEvent(new ScreenEvent(ScreenEvent.SWAP_IN, GameOver));
Main.smSFX.getSoundByClassName("GameMusicSound").fadeOut(1000);
return;
};
} else {
if (state == STATE_LAND){
if (landingCounter++ == NUM_LANDING_FRAMES){
score = (avatar.x / 2);
dispatchEvent(new ScreenEvent(ScreenEvent.SWAP_IN, GameOver));
Main.smSFX.getSoundByClassName("GameMusicSound").fadeOut(1000);
return;
};
};
};
};
physics.step();
avatar.update();
renderer.draw((avatar.x - xMungeOffset), avatar.y);
if (avatar.onGround){
_local12 = (avatar.rb.r + (100 * Math.PI));
_local12 = (_local12 % (2 * Math.PI));
_local13 = ((1.5 * Math.PI) - _local12);
if (_local13 < 0){
_local13 = -(_local13);
};
if (_local13 < (0.25 * Math.PI)){
avatar.rb.applyTorque(10000000);
};
};
var _local4:Number = 1.3;
var _local5:Number = 0.7;
var _local6:Number = ((((_local4 - _local5) * avatar.y) / 3000) + _local5);
avatar.mc.scaleX = (avatar.mc.scaleY = _local6);
}
private function onHelpClick(_arg1:MouseEvent):void{
dispatchEvent(new ScreenEvent(ScreenEvent.SHOW_ABOVE, Help));
}
private function checkUserInteraction():void{
var _local1:Number;
var _local2:int;
var _local3:MovieClip;
if (paused){
return;
};
if (meter){
meter.mc.stop();
};
if (state == STATE_SET_PITCH){
_local1 = ((meter.mc.bar.rotation + 18) / (70 - 18));
_local1 = ((_local1 * (90 - 1)) + 1);
angle = (Constants.DEG_2_RAD * _local1);
uiLayer.sprite.removeChild(meter);
meter = null;
meter = Main.af.createMovieClip("PowerMeterAsset");
meter.x = 355;
meter.y = 182;
uiLayer.sprite.addChild(meter);
state = STATE_SET_POWER;
} else {
if (state == STATE_SET_POWER){
_local2 = meter.mc.currentFrame;
if (_local2 > MAX_POWER_FRAME){
_local2 = (meter.mc.totalFrames - _local2);
};
power = (_local2 / MAX_POWER_FRAME);
power = (power * power);
power = ((power * (MAX_POWER - MIN_POWER)) + MIN_POWER);
uiLayer.sprite.removeChild(meter);
meter = null;
throwForceX = (power * Math.cos(angle));
throwForceY = (power * Math.sin(angle));
if (Constants.locale == "it_IT"){
_local3 = Main.af.createMovieClip("ThrowButtonITAsset");
} else {
if (Constants.locale == "de_DE"){
_local3 = Main.af.createMovieClip("ThrowButtonDEAsset");
} else {
_local3 = Main.af.createMovieClip("ThrowButtonENAsset");
};
};
_local3.x = 359;
_local3.y = 179;
_local3.name = "throwButton";
_local3.mouseEnabled = false;
_local3.mouseChildren = false;
uiLayer.sprite.addChild(_local3);
state = STATE_SET_THROW;
} else {
if (state == STATE_SET_THROW){
uiLayer.sprite.removeChild(uiLayer.sprite.getChildByName("throwButton"));
if ((((swingMC.currentFrame < 3)) || ((swingMC.currentFrame > 12)))){
trace(("GOOD:" + swingMC.currentFrame));
Main.smSFX.getSoundByClassName("WindSound").fadeIn(0, 1, 5000, 99999999);
state = STATE_THROW;
} else {
trace(("BAD:" + swingMC.currentFrame));
state = STATE_BAD_THROW;
landingCounter = 0;
swingMC.gotoAndPlay("badThrow");
Main.smSFX.getSoundByClassName("BooSound").play();
};
swingMC.loop = false;
Main.smSFX.getSoundByClassName("SpinSound").fadeOut(1200);
};
};
};
}
private function onKeyDown(_arg1:KeyboardEvent):void{
checkUserInteraction();
}
private function onMouseDown(_arg1:MouseEvent):void{
if (!(((_arg1.target is SimpleButton)) || ((_arg1.target is Toggle)))){
checkUserInteraction();
} else {
if (_arg1.target.name == "throwButton"){
checkUserInteraction();
};
};
}
protected function onHistoryPlaybackComplete(_arg1:Event):void{
serialiser.restoreCheckpoint();
keyControl.resetHistory();
}
override public function notifyUnderneath():void{
pause();
}
override public function deactivate():void{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
super.deactivate();
}
public function pause():void{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
paused = true;
}
protected function startGame():void{
serialiser.saveCheckpoint();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
Main.smSFX.getSoundByClassName("SpinSound").play(0, 99999999);
paused = false;
}
}
}//package com.kerb.hurlBerl.screens
Section 20
//Game_BitmapGridAssetData (com.kerb.hurlBerl.screens.Game_BitmapGridAssetData)
package com.kerb.hurlBerl.screens {
import mx.core.*;
public class Game_BitmapGridAssetData extends ByteArrayAsset {
}
}//package com.kerb.hurlBerl.screens
Section 21
//Game_TerrainData (com.kerb.hurlBerl.screens.Game_TerrainData)
package com.kerb.hurlBerl.screens {
import mx.core.*;
public class Game_TerrainData extends ByteArrayAsset {
}
}//package com.kerb.hurlBerl.screens
Section 22
//GameOver (com.kerb.hurlBerl.screens.GameOver)
package com.kerb.hurlBerl.screens {
import flash.events.*;
import flash.display.*;
import com.kerb.hurlBerl.*;
import com.kerb.tracking.*;
public class GameOver extends AbstractScreen {
private var mc:MovieClip;
override protected function init():void{
if (Constants.locale == "it_IT"){
mc = Main.af.createMovieClip("GameOverScreenITAsset");
} else {
if (Constants.locale == "de_DE"){
mc = Main.af.createMovieClip("GameOverScreenDEAsset");
} else {
mc = Main.af.createMovieClip("GameOverScreenENAsset");
};
};
addChild(mc);
mc.cta_btn.addEventListener(MouseEvent.CLICK, onCTAClick, false, 0, true);
mc.playAgain_btn.addEventListener(MouseEvent.CLICK, onPlayAgainClick, false, 0, true);
mc.logo_btn.addEventListener(MouseEvent.CLICK, onLogoClick, false, 0, true);
mc.url_btn.addEventListener(MouseEvent.CLICK, onURLClick, false, 0, true);
mc.tellFriend_btn.addEventListener(MouseEvent.CLICK, onTellFriendClick, false, 0, true);
keyNav.setDefaultAction(onPlayAgainClick);
keyNav.addInteractiveObject(mc.cta_btn, onCTAClick, 1);
keyNav.addInteractiveObject(mc.playAgain_btn, onPlayAgainClick, 2);
if (Game.score == 0){
mc.score_txt.text = "";
mc.youScored_mc.visible = false;
} else {
mc.score_txt.htmlText = (("<b>" + ("0000" + Game.score).substr(-4)) + "</b>");
mc.foul1_txt.text = "";
mc.foul2_txt.text = "";
};
DoubleQuick.event(453);
}
override public function deactivate():void{
super.deactivate();
mc.cta_btn.removeEventListener(MouseEvent.CLICK, onCTAClick);
mc.playAgain_btn.removeEventListener(MouseEvent.CLICK, onPlayAgainClick);
mc.logo_btn.removeEventListener(MouseEvent.CLICK, onLogoClick);
mc.url_btn.removeEventListener(MouseEvent.CLICK, onURLClick);
mc.tellFriend_btn.removeEventListener(MouseEvent.CLICK, onTellFriendClick);
}
private function onCTAClick(_arg1:MouseEvent=null):void{
DoubleQuick.click(457);
}
private function onURLClick(_arg1:MouseEvent=null):void{
DoubleQuick.click(456);
}
private function onTellFriendClick(_arg1:MouseEvent=null):void{
DoubleQuick.event(459);
}
private function onPlayAgainClick(_arg1:MouseEvent=null):void{
DoubleQuick.event(454);
Main.smSFX.getSoundByClassName("GameMusicSound").stop();
dispatchEvent(new ScreenEvent(ScreenEvent.SWAP_IN, Game));
}
private function onLogoClick(_arg1:MouseEvent=null):void{
DoubleQuick.click(455);
}
}
}//package com.kerb.hurlBerl.screens
Section 23
//Help (com.kerb.hurlBerl.screens.Help)
package com.kerb.hurlBerl.screens {
import flash.events.*;
public class Help extends Instructions {
override protected function onPlayClick(_arg1:MouseEvent=null):void{
dispatchEvent(new ScreenEvent(ScreenEvent.REMOVE_THIS));
}
}
}//package com.kerb.hurlBerl.screens
Section 24
//Instructions (com.kerb.hurlBerl.screens.Instructions)
package com.kerb.hurlBerl.screens {
import flash.events.*;
import flash.display.*;
import com.kerb.hurlBerl.*;
import com.kerb.tracking.*;
public class Instructions extends AbstractScreen {
private var mc:MovieClip;
override protected function init():void{
if (Constants.locale == "it_IT"){
mc = Main.af.createMovieClip("InstructionsScreenITAsset");
} else {
if (Constants.locale == "de_DE"){
mc = Main.af.createMovieClip("InstructionsScreenDEAsset");
} else {
mc = Main.af.createMovieClip("InstructionsScreenENAsset");
};
};
addChild(mc);
mc.play_btn.addEventListener(MouseEvent.CLICK, onPlayClick, false, 0, true);
mc.logo_btn.addEventListener(MouseEvent.CLICK, onLogoClick, false, 0, true);
keyNav.setDefaultAction(onPlayClick);
}
override public function deactivate():void{
super.deactivate();
mc.play_btn.removeEventListener(MouseEvent.CLICK, onPlayClick);
mc.logo_btn.removeEventListener(MouseEvent.CLICK, onLogoClick);
}
protected function onPlayClick(_arg1:MouseEvent=null):void{
dispatchEvent(new ScreenEvent(ScreenEvent.SWAP_IN, Game));
}
private function onLogoClick(_arg1:MouseEvent=null):void{
DoubleQuick.click(455);
}
}
}//package com.kerb.hurlBerl.screens
Section 25
//KeyboardNavigator (com.kerb.hurlBerl.screens.KeyboardNavigator)
package com.kerb.hurlBerl.screens {
import flash.events.*;
import flash.display.*;
import flash.utils.*;
import flash.ui.*;
public class KeyboardNavigator {
protected var stage:Stage;
protected var tabIndexes:Array;
protected var keyListenerSet:Boolean;
protected var controllableItems:Dictionary;
protected var defaultAction:Function;
public function KeyboardNavigator(_arg1:Stage){
this.stage = _arg1;
init();
}
public function addInteractiveObject(_arg1:InteractiveObject, _arg2:Function, _arg3:int=-1):void{
controllableItems[_arg1] = _arg2;
if (_arg3 > -1){
tabIndexes[_arg3] = _arg1;
_arg1.tabEnabled = true;
};
_arg1.tabIndex = _arg3;
active = true;
}
protected function onKeyDown(_arg1:KeyboardEvent):void{
var _local2:Function;
var _local3:int;
var _local4:InteractiveObject;
if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){
_local2 = controllableItems[stage.focus];
if (_local2 == null){
defaultAction();
} else {
_local2();
};
} else {
_local3 = -1;
_local4 = null;
if ((((stage.focus is InteractiveObject)) && (!((stage.focus == stage))))){
_local3 = (stage.focus as InteractiveObject).tabIndex;
};
if (_local3 == -1){
} else {
if (_arg1.keyCode == Keyboard.LEFT){
_local4 = getNextLowestTabIndex(_local3);
if (_local4 == null){
_local4 = getHighestTabIndex();
};
} else {
if (_arg1.keyCode == Keyboard.RIGHT){
_local4 = getNextHighestTabIndex(_local3);
if (_local4 == null){
_local4 = getLowestTabIndex();
};
};
};
};
if (_local4){
stage.focus = _local4;
};
};
}
public function setDefaultAction(_arg1:Function):void{
this.defaultAction = _arg1;
active = true;
}
public function get active():Boolean{
return (keyListenerSet);
}
protected function getNextLowestTabIndex(_arg1:int):InteractiveObject{
var _local2:InteractiveObject;
var _local3:int = tabIndexes.length;
var _local4:int = (_arg1 - 1);
while (_local4 >= 0) {
if (tabIndexes[_local4] != undefined){
_local2 = tabIndexes[_local4];
break;
};
_local4--;
};
return (_local2);
}
public function set active(_arg1:Boolean):void{
if (((keyListenerSet) && (!(_arg1)))){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
keyListenerSet = false;
} else {
if (((!(keyListenerSet)) && (_arg1))){
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true);
keyListenerSet = true;
};
};
}
protected function init():void{
controllableItems = new Dictionary();
tabIndexes = new Array();
defaultAction = new Function();
stage.focus = stage;
keyListenerSet = false;
}
protected function getHighestTabIndex():InteractiveObject{
var _local1:InteractiveObject;
var _local2:int = (tabIndexes.length - 1);
while (_local2 >= 0) {
if (tabIndexes[_local2] != undefined){
_local1 = tabIndexes[_local2];
break;
};
_local2--;
};
return (_local1);
}
protected function getLowestTabIndex():InteractiveObject{
var _local1:InteractiveObject;
var _local2:int = tabIndexes.length;
var _local3:int;
while (_local3 < _local2) {
if (tabIndexes[_local3] != undefined){
_local1 = tabIndexes[_local3];
break;
};
_local3++;
};
return (_local1);
}
protected function getNextHighestTabIndex(_arg1:int):InteractiveObject{
var _local2:InteractiveObject;
var _local3:int = tabIndexes.length;
var _local4:int = (_arg1 + 1);
while (_local4 < _local3) {
if (tabIndexes[_local4] != undefined){
_local2 = tabIndexes[_local4];
break;
};
_local4++;
};
return (_local2);
}
public function dispose():void{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
controllableItems = null;
tabIndexes = null;
defaultAction = null;
}
}
}//package com.kerb.hurlBerl.screens
Section 26
//ScreenEvent (com.kerb.hurlBerl.screens.ScreenEvent)
package com.kerb.hurlBerl.screens {
import flash.events.*;
public class ScreenEvent extends Event {
public var ScreenClass:Class;
public static const SHOW_BELOW:String = "onShowBelow";
public static const SWAP_IN:String = "onSwapIn";
public static const HIDE_OTHER:String = "onHideOther";
public static const REMOVE_OTHER:String = "onRemoveOther";
public static const REMOVE_THIS:String = "onRemoveThis";
public static const SHOW_ABOVE:String = "onShowAbove";
public function ScreenEvent(_arg1:String, _arg2:Class=null){
super(_arg1);
this.ScreenClass = _arg2;
}
public function get sourceScreen():AbstractScreen{
return (AbstractScreen(target));
}
}
}//package com.kerb.hurlBerl.screens
Section 27
//ScreenManager (com.kerb.hurlBerl.screens.ScreenManager)
package com.kerb.hurlBerl.screens {
import flash.display.*;
import flash.utils.*;
public class ScreenManager {
public var sprite:Sprite;
public var screenA:AbstractScreen;
public var screenB:AbstractScreen;
public function ScreenManager(_arg1:Class){
sprite = new Sprite();
addScreen(new (_arg1), 0);
}
protected function onShowAbove(_arg1:ScreenEvent):void{
onRemoveOther(_arg1);
var _local2:AbstractScreen = _arg1.sourceScreen;
var _local3:int = getZIndex(_local2);
var _local4:AbstractScreen = new _arg1.ScreenClass();
addScreen(_local4, (_local3 + 1));
}
public function get containerSprite():Sprite{
return (sprite);
}
protected function onRemoveThis(_arg1:ScreenEvent):void{
removeScreen(_arg1.sourceScreen);
}
public function addScreen(_arg1:AbstractScreen, _arg2:int):void{
if (_arg1 == null){
return;
};
if (getQualifiedClassName(_arg1) == getQualifiedClassName(screenA)){
return;
};
if (getQualifiedClassName(_arg1) == getQualifiedClassName(screenB)){
return;
};
_arg1.addEventListener(ScreenEvent.HIDE_OTHER, onHideOther, false, 0, true);
_arg1.addEventListener(ScreenEvent.REMOVE_OTHER, onRemoveOther, false, 0, true);
_arg1.addEventListener(ScreenEvent.REMOVE_THIS, onRemoveThis, false, 0, true);
_arg1.addEventListener(ScreenEvent.SHOW_ABOVE, onShowAbove, false, 0, true);
_arg1.addEventListener(ScreenEvent.SHOW_BELOW, onShowBelow, false, 0, true);
_arg1.addEventListener(ScreenEvent.SWAP_IN, onSwapIn, false, 0, true);
sprite.addChildAt(_arg1, _arg2);
if (screenA == null){
screenA = _arg1;
} else {
if (screenB != null){
removeScreen(screenB);
};
screenB = _arg1;
};
if (((screenA) && (screenB))){
if (sprite.getChildIndex(screenA) < sprite.getChildIndex(screenB)){
screenA.notifyUnderneath();
screenB.notifyOnTop();
} else {
screenA.notifyOnTop();
screenB.notifyUnderneath();
};
};
}
protected function getZIndex(_arg1:AbstractScreen):int{
var _local2:int;
if (_arg1.parent == sprite){
_local2 = sprite.getChildIndex(_arg1);
};
return (_local2);
}
protected function onHideOther(_arg1:ScreenEvent):void{
if (screenA != _arg1.sourceScreen){
screenA.hide();
} else {
if (screenB != _arg1.sourceScreen){
screenB.hide();
};
};
}
public function removeScreen(_arg1:AbstractScreen):void{
if (_arg1 == null){
return;
};
_arg1.removeEventListener(ScreenEvent.HIDE_OTHER, onHideOther);
_arg1.removeEventListener(ScreenEvent.REMOVE_OTHER, onRemoveOther);
_arg1.removeEventListener(ScreenEvent.REMOVE_THIS, onRemoveThis);
_arg1.removeEventListener(ScreenEvent.SHOW_ABOVE, onShowAbove);
_arg1.removeEventListener(ScreenEvent.SHOW_BELOW, onShowBelow);
_arg1.removeEventListener(ScreenEvent.SWAP_IN, onSwapIn);
_arg1.dispose();
if (screenA == _arg1){
screenA = null;
if (screenB){
screenB.notifyOnTop();
};
} else {
if (screenB == _arg1){
screenB = null;
if (screenA){
screenA.notifyOnTop();
};
};
};
if (_arg1.parent == sprite){
sprite.removeChild(_arg1);
};
}
protected function onRemoveOther(_arg1:ScreenEvent):void{
if (screenA != _arg1.sourceScreen){
removeScreen(screenA);
} else {
if (screenB != _arg1.sourceScreen){
removeScreen(screenB);
};
};
}
protected function onSwapIn(_arg1:ScreenEvent):void{
var _local2:AbstractScreen = _arg1.sourceScreen;
var _local3:int = getZIndex(_local2);
var _local4:AbstractScreen = new _arg1.ScreenClass();
removeScreen(_local2);
addScreen(_local4, _local3);
}
protected function onShowBelow(_arg1:ScreenEvent):void{
onRemoveOther(_arg1);
var _local2:AbstractScreen = _arg1.sourceScreen;
var _local3:int = getZIndex(_local2);
var _local4:AbstractScreen = new _arg1.ScreenClass();
addScreen(_local4, _local3);
}
}
}//package com.kerb.hurlBerl.screens
Section 28
//Title (com.kerb.hurlBerl.screens.Title)
package com.kerb.hurlBerl.screens {
import flash.events.*;
import flash.display.*;
import com.kerb.hurlBerl.*;
import com.kerb.tracking.*;
public class Title extends AbstractScreen {
private var mc:MovieClip;
private static var musicPlaying:Boolean = false;
override protected function init():void{
if (Constants.locale == "it_IT"){
mc = Main.af.createMovieClip("TitleScreenITAsset");
} else {
if (Constants.locale == "de_DE"){
mc = Main.af.createMovieClip("TitleScreenDEAsset");
} else {
mc = Main.af.createMovieClip("TitleScreenENAsset");
};
};
addChild(mc);
mc.next_btn.addEventListener(MouseEvent.CLICK, onNextClick, false, 0, true);
mc.english_btn.addEventListener(MouseEvent.CLICK, onEnglishClick, false, 0, true);
mc.italian_btn.addEventListener(MouseEvent.CLICK, onItalianClick, false, 0, true);
mc.german_btn.addEventListener(MouseEvent.CLICK, onGermanClick, false, 0, true);
mc.logo_btn.addEventListener(MouseEvent.CLICK, onLogoClick, false, 0, true);
keyNav.setDefaultAction(onNextClick);
keyNav.addInteractiveObject(mc.next_btn, onNextClick, 1);
keyNav.addInteractiveObject(mc.english_btn, onEnglishClick, 2);
keyNav.addInteractiveObject(mc.italian_btn, onItalianClick, 3);
if (!musicPlaying){
musicPlaying = true;
Main.smSFX.getSoundByClassName("TitleMusicSound").play(0, 99999999);
};
}
private function onGermanClick(_arg1:MouseEvent=null):void{
Constants.locale = "de_DE";
dispatchEvent(new ScreenEvent(ScreenEvent.SWAP_IN, Title));
}
override public function deactivate():void{
super.deactivate();
mc.next_btn.removeEventListener(MouseEvent.CLICK, onNextClick);
mc.english_btn.removeEventListener(MouseEvent.CLICK, onEnglishClick);
mc.italian_btn.removeEventListener(MouseEvent.CLICK, onItalianClick);
mc.german_btn.removeEventListener(MouseEvent.CLICK, onGermanClick);
mc.logo_btn.removeEventListener(MouseEvent.CLICK, onLogoClick);
}
private function onLogoClick(_arg1:MouseEvent=null):void{
DoubleQuick.click(455);
}
private function onNextClick(_arg1:MouseEvent=null):void{
if (Constants.locale == "it_IT"){
DoubleQuick.event(451);
} else {
DoubleQuick.event(452);
};
Main.smSFX.getSoundByClassName("TitleMusicSound").fadeOut(1000);
musicPlaying = false;
dispatchEvent(new ScreenEvent(ScreenEvent.SWAP_IN, Instructions));
}
private function onEnglishClick(_arg1:MouseEvent=null):void{
Constants.locale = "en_GB";
dispatchEvent(new ScreenEvent(ScreenEvent.SWAP_IN, Title));
}
private function onItalianClick(_arg1:MouseEvent=null):void{
Constants.locale = "it_IT";
dispatchEvent(new ScreenEvent(ScreenEvent.SWAP_IN, Title));
}
}
}//package com.kerb.hurlBerl.screens
Section 29
//Constants (com.kerb.hurlBerl.Constants)
package com.kerb.hurlBerl {
public class Constants {
public static const SHOW_QUALITY_MENU:Boolean = false;
public static const RIGID_BODY_FILL_ALPHA:Number = 0.3;
public static const BIN_GRID_COLOUR:uint = 0xFFFF00;
public static const RAD_2_DEG:Number = 57.2957795130823;
public static const RIGID_BODY_STROKE_COLOUR:uint = 0xFFFFFF;
public static const MAIN_CLASS_NAME:String = "HurlBerl";
public static const KERB_SITE_URL:String = "http://www.kerb.co.uk";
public static const EMAIL_SUBJECT_EN:String = "";
public static const EMAIL_SUBJECT_IT:String = "";
public static const EMAIL_BODY_EN:String = "";
public static const VIEWPORT_BACKGROUND_COLOUR:uint = 81227;
public static const EMAIL_BODY_IT:String = "";
public static const CAMERA_COLOUR:uint = 0xFF00;
public static const SHOW_KERB_MENU_LINK:Boolean = false;
public static const DEG_2_RAD:Number = 0.0174532925199433;
public static const RIGID_BODY_FILL_COLOUR:uint = 0xFFFFFF;
public static const VIEWPORT_BORDER_COLOUR:uint = 0xFF00;
public static const EMAIL_SUBJECT_DE:String = "";
public static const RIGID_BODY_STROKE_THICKNESS:Number = 0;
public static const EMAIL_BODY_DE:String = "";
public static const KERB_GAMES_URL:String = "http://www.kerbgames.com";
public static var basePath:String = "";
public static var locale:String = "";
}
}//package com.kerb.hurlBerl
Section 30
//Main (com.kerb.hurlBerl.Main)
package com.kerb.hurlBerl {
import flash.events.*;
import flash.display.*;
import com.kerb.hurlBerl.screens.*;
import com.kerb.sound.*;
import com.kerb.utils.*;
import com.kerb.ui.*;
import com.kerb.tracking.*;
public class Main extends Sprite {
protected var screenManager:ScreenManager;
protected var debugControlPanelScreen:DebugControlPanel;
protected var SWFBytes:Class;
public static const smSFX:SoundManager = new SoundManager();
public static const af:AssetFactory = new AssetFactory();
public function Main(_arg1:Class){
this.SWFBytes = _arg1;
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage, false, 0, true);
}
protected function onSoundToggle(_arg1:Event):void{
if (Toggle(_arg1.target).isOn){
smSFX.unmute();
} else {
smSFX.mute();
};
}
protected function initTracking():void{
DoubleQuick.init(root, 95, false);
DoubleQuick.event(450);
}
protected function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
af.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady, false, 0, true);
af.initialize(SWFBytes);
}
protected function onAssetFactoryReady(_arg1:Event):void{
af.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
init();
}
protected function init():void{
initTracking();
initSounds();
initScreenManager();
}
protected function initScreenManager():void{
screenManager = new ScreenManager(Title);
addChildAt(screenManager.containerSprite, 0);
}
protected function initSounds():void{
smSFX.registerSound(af.createExtendedSound("LandingSound"));
smSFX.registerSound(af.createExtendedSound("SpinSound"));
smSFX.registerSound(af.createExtendedSound("WindSound"));
smSFX.registerSound(af.createExtendedSound("BounceSound"));
smSFX.registerSound(af.createExtendedSound("BooSound"));
smSFX.registerSound(af.createExtendedSound("CheerSound"));
smSFX.registerSound(af.createExtendedSound("GameMusicSound"));
smSFX.registerSound(af.createExtendedSound("TitleMusicSound"));
var _local1:Toggle = (af.createDisplayObject("SoundToggleAsset") as Toggle);
_local1.x = 509;
_local1.y = 9;
addChild(_local1);
_local1.isOn = true;
_local1.addEventListener(Event.CHANGE, onSoundToggle, false, 0, true);
}
}
}//package com.kerb.hurlBerl
Section 31
//Preload (com.kerb.hurlBerl.Preload)
package com.kerb.hurlBerl {
import flash.events.*;
import flash.display.*;
import com.kerb.utils.*;
import flash.ui.*;
import flash.utils.*;
import flash.net.*;
public class Preload extends MovieClip {
protected var af:AssetFactory;
protected var SWFBytes:Class;
protected var url:String;
protected var highQualityItem:ContextMenuItem;
protected var mc:MovieClip;
protected var mediumQualityItem:ContextMenuItem;
protected var lowQualityItem:ContextMenuItem;
public function Preload(){
SWFBytes = Preload_SWFBytes;
super();
stop();
checkFlashvars();
initStage();
initContextMenu();
initAssetFactory();
}
protected function drawLetterbox():void{
var _local1:int = loaderInfo.width;
var _local2:int = loaderInfo.height;
var _local3:Sprite = new Sprite();
var _local4:Graphics = _local3.graphics;
_local4.beginFill(0);
_local4.drawRect(-1000, -1000, (2000 + _local1), 1000);
_local4.drawRect(-1000, _local2, (2000 + _local1), 1000);
_local4.drawRect(-1000, -1000, 1000, (1000 + _local2));
_local4.drawRect(_local1, -1000, 1000, (1000 + _local2));
_local4.endFill();
addChild(_local3);
}
protected function preloadComplete():void{
var _local1:Class;
if (currentFrame == 1){
nextFrame();
} else {
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
_local1 = Class(getDefinitionByName(Constants.MAIN_CLASS_NAME));
addChild((new (_local1) as DisplayObject));
removeChild(mc);
mc = null;
};
}
protected function initContextMenu():void{
var _local1:ContextMenuItem;
contextMenu = new ContextMenu();
contextMenu.hideBuiltInItems();
url = loaderInfo.url;
if (Constants.SHOW_KERB_MENU_LINK){
_local1 = new ContextMenuItem("Built by Kerb!", false);
_local1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onKerbMenuItemSelect);
contextMenu.customItems.push(_local1);
};
if (Constants.SHOW_QUALITY_MENU){
lowQualityItem = new ContextMenuItem("Low Quality (fastest)", true);
lowQualityItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onQualityMenuItemSelect);
contextMenu.customItems.push(lowQualityItem);
mediumQualityItem = new ContextMenuItem("Medium Quality", false);
mediumQualityItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onQualityMenuItemSelect);
contextMenu.customItems.push(mediumQualityItem);
highQualityItem = new ContextMenuItem("• High Quality (slowest)", false);
highQualityItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onQualityMenuItemSelect);
contextMenu.customItems.push(highQualityItem);
};
}
protected function initStage():void{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.stageFocusRect = false;
}
protected function initAssetFactory():void{
af = new AssetFactory();
af.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
af.initialize(SWFBytes);
}
protected function checkFlashvars():void{
if (root.loaderInfo.parameters.locale){
Constants.locale = root.loaderInfo.parameters.locale;
};
if (root.loaderInfo.parameters.basePath){
Constants.basePath = root.loaderInfo.parameters.basePath;
};
}
protected function onQualityMenuItemSelect(_arg1:Event):void{
lowQualityItem.caption = "Low Quality (fast)";
mediumQualityItem.caption = "Medium Quality";
highQualityItem.caption = "High Quality (slow)";
switch (_arg1.currentTarget){
case lowQualityItem:
lowQualityItem.caption = ("• " + lowQualityItem.caption);
stage.quality = StageQuality.LOW;
break;
case mediumQualityItem:
mediumQualityItem.caption = ("• " + mediumQualityItem.caption);
stage.quality = StageQuality.MEDIUM;
break;
case highQualityItem:
highQualityItem.caption = ("• " + highQualityItem.caption);
stage.quality = StageQuality.HIGH;
break;
};
}
protected function onKerbMenuItemSelect(_arg1:Event):void{
navigateToURL(new URLRequest(Constants.KERB_SITE_URL), "_blank");
}
protected function onAssetFactoryReady(_arg1:Event):void{
af.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
mc = (af.createDisplayObject("PreloadAsset") as MovieClip);
addChildAt(mc, 0);
af = null;
drawLetterbox();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
protected function onEnterFrame(_arg1:Event):void{
var _local2:int = root.loaderInfo.bytesLoaded;
var _local3:int = root.loaderInfo.bytesTotal;
var _local4:int = Math.ceil(((100 * _local2) / _local3));
if (mc.currentFrame != _local4){
mc.gotoAndStop(_local4);
mc.percent_txt.text = (_local4 + "%");
};
if (_local4 == 100){
preloadComplete();
};
}
}
}//package com.kerb.hurlBerl
Section 32
//Preload_SWFBytes (com.kerb.hurlBerl.Preload_SWFBytes)
package com.kerb.hurlBerl {
import mx.core.*;
public class Preload_SWFBytes extends ByteArrayAsset {
}
}//package com.kerb.hurlBerl
Section 33
//ExtendedSound (com.kerb.sound.ExtendedSound)
package com.kerb.sound {
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class ExtendedSound extends Sound {
protected var fadeStartVolume:Number;
protected var panStartPosition:Number;
protected var stopAfterFade:Boolean;
protected var masterVolume:Number;// = 1
protected var panTimer:Timer;
protected var fadeTimer:Timer;
protected var paused:Boolean;
protected var fadeDuration:Number;
protected var fadeStartTime:Number;
protected var fadeEndVolume:Number;
protected var playingLoops:Number;
protected var panEndPosition:Number;
protected var actualVolume:Number;// = 1
protected var panStartTime:Number;
protected var panDuration:Number;
protected var pauseTime:Number;
protected var transform:SoundTransform;
protected var soundChannel:SoundChannel;
private static const TIMER_UPDATE_RATE:Number = 20;
public function stop():void{
stopFade();
if (soundChannel != null){
soundChannel.stop();
soundChannel.removeEventListener(Event.SOUND_COMPLETE, onSoundComplete);
soundChannel = null;
stopFade();
};
}
protected function updatePan(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number = ((getTimer() - panStartTime) / panDuration);
if (_local3 >= 1){
stopPan();
_local2 = panEndPosition;
} else {
if (_local3 > 0){
_local2 = ((_local3 * (panEndPosition - panStartPosition)) + panStartPosition);
};
};
if (soundChannel == null){
return;
};
var _local4:Number = soundChannel.soundTransform.volume;
transform = new SoundTransform(_local4, _local2);
soundChannel.soundTransform = transform;
}
public function fadeTo(_arg1:Number, _arg2:Number):void{
if (((soundChannel) && (soundChannel.soundTransform))){
fadeStartTime = getTimer();
fadeDuration = _arg2;
fadeStartVolume = (soundChannel.soundTransform.volume / masterVolume);
fadeEndVolume = _arg1;
startFade();
};
}
public function setMasterVolume(_arg1:Number):void{
var _local2:Number;
masterVolume = Math.max(0, Math.min(1, _arg1));
if (soundChannel != null){
_local2 = soundChannel.soundTransform.pan;
transform = new SoundTransform((actualVolume * masterVolume), _local2);
soundChannel.soundTransform = transform;
};
}
protected function stopFade():void{
if (((!((fadeTimer == null))) && (fadeTimer.running))){
fadeTimer.reset();
};
}
public function setVolume(_arg1:Number):void{
var _local2:Number;
if (soundChannel != null){
actualVolume = Math.max(0, Math.min(1, _arg1));
_local2 = soundChannel.soundTransform.pan;
transform = new SoundTransform((actualVolume * masterVolume), _local2);
soundChannel.soundTransform = transform;
stopFade();
};
}
public function fadeOut(_arg1:Number=0):void{
if ((((((_arg1 > 0)) && (soundChannel))) && (soundChannel.soundTransform))){
fadeStartTime = getTimer();
fadeDuration = _arg1;
fadeStartVolume = (soundChannel.soundTransform.volume / masterVolume);
fadeEndVolume = 0;
stopAfterFade = true;
startFade();
} else {
stop();
};
}
override public function play(_arg1:Number=0, _arg2:int=0, _arg3:SoundTransform=null):SoundChannel{
if (_arg3 != null){
actualVolume = _arg3.volume;
} else {
actualVolume = 1;
_arg3 = new SoundTransform(masterVolume);
};
_arg3.volume = (actualVolume * masterVolume);
soundChannel = super.play(_arg1, _arg2, _arg3);
if (soundChannel != null){
soundChannel.addEventListener(Event.SOUND_COMPLETE, onSoundComplete);
};
playingLoops = _arg2;
transform = _arg3;
paused = false;
return (soundChannel);
}
protected function stopPan():void{
if (((!((panTimer == null))) && (panTimer.running))){
panTimer.reset();
};
}
protected function onSoundComplete(_arg1:Event):void{
dispatchEvent(_arg1);
}
public function get position():Number{
if (soundChannel == null){
return (0);
};
return (soundChannel.position);
}
public function fadeIn(_arg1:Number=0, _arg2:Number=1, _arg3:Number=0, _arg4:int=0, _arg5:Number=0):SoundChannel{
fadeStartVolume = Math.max(0, Math.min(1, _arg1));
play(_arg5, _arg4, new SoundTransform((fadeStartVolume * masterVolume)));
if (_arg3 > 0){
fadeStartTime = getTimer();
fadeDuration = _arg3;
fadeEndVolume = Math.max(0, Math.min(1, _arg2));
startFade();
};
return (soundChannel);
}
public function setPan(_arg1:Number):void{
var _local2:Number;
if (soundChannel != null){
_arg1 = Math.max(-1, Math.min(1, _arg1));
_local2 = soundChannel.soundTransform.volume;
transform = new SoundTransform(_local2, _arg1);
soundChannel.soundTransform = transform;
stopPan();
};
}
protected function startPan():void{
if (panTimer == null){
panTimer = new Timer(TIMER_UPDATE_RATE);
panTimer.addEventListener(TimerEvent.TIMER, updatePan);
};
stopPan();
panTimer.start();
}
protected function updateFade(_arg1:TimerEvent):void{
var _local2:Number = ((getTimer() - fadeStartTime) / fadeDuration);
if (_local2 >= 1){
if (stopAfterFade){
stopAfterFade = false;
stop();
} else {
stopFade();
};
actualVolume = fadeEndVolume;
} else {
if (_local2 > 0){
actualVolume = ((_local2 * (fadeEndVolume - fadeStartVolume)) + fadeStartVolume);
};
};
if (soundChannel == null){
return;
};
var _local3:Number = soundChannel.soundTransform.pan;
transform = new SoundTransform((actualVolume * masterVolume), _local3);
soundChannel.soundTransform = transform;
}
public function getSoundChannel():SoundChannel{
return (soundChannel);
}
override public function toString():String{
var _local1:String = getQualifiedClassName(this);
if (soundChannel != null){
_local1 = (_local1 + ((" vol[" + (soundChannel.soundTransform.volume / masterVolume)) + "]"));
_local1 = (_local1 + ((" pan[" + soundChannel.soundTransform.pan) + "]"));
};
return (_local1);
}
public function pause():void{
if (soundChannel == null){
return;
};
pauseTime = soundChannel.position;
stop();
}
public function panTo(_arg1:Number, _arg2:Number):void{
if (_arg2 > 0){
panStartTime = getTimer();
panDuration = _arg2;
panStartPosition = soundChannel.soundTransform.pan;
panEndPosition = _arg1;
startPan();
} else {
setPan(_arg1);
};
}
public function unpause():void{
play(pauseTime, playingLoops, transform);
}
protected function startFade():void{
if (fadeTimer == null){
fadeTimer = new Timer(TIMER_UPDATE_RATE);
fadeTimer.addEventListener(TimerEvent.TIMER, updateFade);
};
stopFade();
fadeTimer.start();
}
}
}//package com.kerb.sound
Section 34
//SoundManager (com.kerb.sound.SoundManager)
package com.kerb.sound {
import flash.utils.*;
public class SoundManager {
private var sounds:Array;
private var prevMasterVolume:Number;
private var muteState:Boolean;// = false
private var masterVolume:Number;// = 1
public function SoundManager(){
prevMasterVolume = masterVolume;
sounds = new Array();
super();
}
public function unregisterSound(_arg1:String):void{
if (sounds[_arg1] != null){
sounds[_arg1].stop();
sounds[_arg1] = null;
};
}
public function stopAllSounds():void{
var _local1:String;
for (_local1 in sounds) {
sounds[_local1].stop();
};
}
public function setMasterVolume(_arg1:Number):void{
var _local2:String;
prevMasterVolume = masterVolume;
masterVolume = Math.max(0, Math.min(1, _arg1));
for (_local2 in sounds) {
sounds[_local2].setMasterVolume(masterVolume);
};
}
public function get muted():Boolean{
return (muteState);
}
public function registerSound(_arg1:ExtendedSound, _arg2:String=null, _arg3:Boolean=false):void{
if (_arg2 == null){
_arg2 = getQualifiedClassName(_arg1);
};
if (sounds[_arg2] != null){
if (_arg3){
unregisterSound(_arg2);
} else {
throw (new Error((("Class name conflict: A sound with the class name [" + _arg2) + "] already exists in SoundManager.")));
};
};
sounds[_arg2] = _arg1;
_arg1.setMasterVolume(masterVolume);
}
public function unmute():void{
if (muteState){
muteState = false;
setMasterVolume(prevMasterVolume);
};
}
public function getSoundByClassName(_arg1:String):ExtendedSound{
return (sounds[_arg1]);
}
public function mute():void{
if (!muteState){
muteState = true;
setMasterVolume(0);
};
}
public function toString():String{
var _local2:String;
var _local1 = "====================\n";
_local1 = (_local1 + "SoundManager\n");
_local1 = (_local1 + "--------------------\n");
_local1 = (_local1 + (("master vol[" + masterVolume) + "]\n"));
_local1 = (_local1 + "--------------------");
for (_local2 in sounds) {
_local1 = (_local1 + ("\n" + sounds[_local2].toString()));
};
_local1 = (_local1 + "\n====================");
return (_local1);
}
}
}//package com.kerb.sound
Section 35
//DoubleQuick (com.kerb.tracking.DoubleQuick)
package com.kerb.tracking {
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.utils.*;
public class DoubleQuick {
private static const SO_SESSION_PROPERTY_NAME:String = "sessionkey";
private static const SO_NAME:String = "doublequick";
private static const TICKER_PERIOD:Number = 30000;
private static const TRACKER_SESSION_URL:String = "http://doublequick.kerb.co.uk/tracking/session.htm";
private static const TICKER_URL:String = "http://doublequick.kerb.co.uk/tracking/ticker.htm";
private static const TRACKER_URL:String = "http://doublequick.kerb.co.uk/tracking/trackflash.htm";
private static const SO_EXPIRY_PROPERTY_NAME:String = "expo";
private static var tickerURL:URLRequest = null;
private static var initialised:Boolean = false;
private static var queue:Array = new Array();
private static var projectId:Number;
private static var baseurl:String;
private static var dq:DoubleQuick;
private static var traceEvents:Boolean;
public function startTimer():void{
var _local1:Timer = new Timer(TICKER_PERIOD, 0);
_local1.start();
_local1.addEventListener(TimerEvent.TIMER, pingProxy, false, 0, true);
}
public function pingProxy(_arg1:TimerEvent):void{
DoubleQuick.ping();
}
private static function doTrace(_arg1:String):void{
if (traceEvents){
trace(_arg1);
};
}
public static function event(_arg1:Number):void{
var loader:URLLoader;
var request:URLRequest;
var watchId = _arg1;
if (!initialised){
doTrace((("DoubleQuick event " + watchId) + " queued"));
queue.push(watchId);
} else {
doTrace(("DoubleQuick event " + watchId));
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(IOErrorEvent.IO_ERROR, onError, false, 0, true);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError, false, 0, true);
request = generateURL(watchId);
request.method = URLRequestMethod.GET;
try {
loader.load(request);
} catch(error:Error) {
onError();
};
};
}
public static function click(_arg1:Number, _arg2:String=null):void{
doTrace(("DoubleQuick clickThrough " + _arg1));
navigateToURL(generateURL(_arg1), _arg2);
}
private static function onInit(_arg1:Event):void{
var _local4:Date;
var _local2:URLLoader = URLLoader(_arg1.target);
var _local3:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
if (((!((_local2.data["sessionkey"] == ""))) && (!((_local2.data["sessionkey"] == null))))){
doTrace(("DoubleQuick acquired session key " + _local2.data["sessionkey"]));
_local3.setProperty(DoubleQuick.SO_SESSION_PROPERTY_NAME, _local2.data["sessionkey"]);
_local4 = new Date((new Date().getTime() + ((_local2.data["timeout"] * 60) * 1000)));
_local3.setProperty(DoubleQuick.SO_EXPIRY_PROPERTY_NAME, _local4);
};
DoubleQuick.initialisationFinished();
}
public static function init(_arg1:DisplayObject, _arg2:Number, _arg3:Boolean=true):void{
var loader:URLLoader;
var request:URLRequest;
var root = _arg1;
var _projectId = _arg2;
var _traceEvents = _arg3;
projectId = _projectId;
traceEvents = _traceEvents;
baseurl = root.loaderInfo.url;
doTrace(((("DoubleQuick initialising with project " + projectId) + " and baseurl ") + baseurl));
var so:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
var isExpired:Boolean;
var currentDate:Date = new Date();
if (currentDate < so.data[DoubleQuick.SO_EXPIRY_PROPERTY_NAME]){
isExpired = false;
};
if ((((so.data[DoubleQuick.SO_SESSION_PROPERTY_NAME] == undefined)) || (isExpired))){
doTrace("DoubleQuick requesting new session key");
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, onInit, false, 0, true);
loader.addEventListener(IOErrorEvent.IO_ERROR, onError, false, 0, true);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError, false, 0, true);
request = new URLRequest(((TRACKER_SESSION_URL + "?project=") + projectId));
request.method = URLRequestMethod.GET;
try {
loader.load(request);
} catch(error:Error) {
onError();
};
} else {
DoubleQuick.initialisationFinished();
};
}
public static function initialisationFinished():void{
doTrace("DoubleQuick initialised");
initialised = true;
var _local1:int;
while (_local1 < queue.length) {
event(queue[_local1]);
_local1++;
};
queue = new Array();
var _local2:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
tickerURL = new URLRequest(((((TICKER_URL + "?project=") + projectId) + "&session=") + _local2.data[DoubleQuick.SO_SESSION_PROPERTY_NAME]));
tickerURL.method = URLRequestMethod.GET;
dq = new (DoubleQuick);
dq.startTimer();
}
private static function onError(_arg1:Event=null):void{
}
public static function ping():void{
var loader:URLLoader;
if (tickerURL != null){
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(IOErrorEvent.IO_ERROR, onError, false, 0, true);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, onError, false, 0, true);
doTrace("DoubleQuick ticker");
try {
loader.load(tickerURL);
} catch(error:Error) {
onError();
};
};
}
private static function generateURL(_arg1:Number):URLRequest{
var _local2:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
var _local3:String = ((((((((TRACKER_URL + "?watch=") + _arg1) + "&project=") + projectId) + "&session=") + _local2.data[DoubleQuick.SO_SESSION_PROPERTY_NAME]) + "&baseurl=") + escape(baseurl));
return (new URLRequest(_local3));
}
}
}//package com.kerb.tracking
Section 36
//Toggle (com.kerb.ui.Toggle)
package com.kerb.ui {
import flash.events.*;
import flash.display.*;
import com.kerb.utils.*;
import flash.text.*;
public class Toggle extends MovieClip implements IDisposable {
protected var _isOn:Boolean;
protected var _state:int;
protected var _label:String;
public static const STATE_DOWN:int = 2;
public static const STATE_UP:int = 0;
public static const STATE_OVER:int = 1;
protected static var stateLabels:Array = ["upOff", "overOff", "downOff", "upOn", "overOn", "downOn"];
public function Toggle(){
_state = STATE_UP;
_label = "";
isOn = false;
buttonMode = true;
mouseChildren = false;
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
protected function onMouseDown(_arg1:MouseEvent):void{
_state = STATE_DOWN;
update();
}
protected function onMouseUp(_arg1:MouseEvent):void{
_state = STATE_OVER;
isOn = !(_isOn);
}
protected function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
init();
}
public function get isOn():Boolean{
return (_isOn);
}
protected function onRollOut(_arg1:MouseEvent):void{
_state = STATE_UP;
update();
}
public function set label(_arg1:String):void{
this._label = _arg1;
updateLabel();
}
public function get state():int{
return (_state);
}
public function get label():String{
return (_label);
}
protected function init():void{
var _local2:int;
var _local1:int;
while (_local1 < numChildren) {
if ((getChildAt(_local1) is TextField)){
_local2 = 0;
while (_local2 < totalFrames) {
addFrameScript(_local2, updateLabel);
_local2++;
};
break;
};
_local1++;
};
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
addEventListener(MouseEvent.ROLL_OVER, onRollOver);
addEventListener(MouseEvent.ROLL_OUT, onRollOut);
}
protected function update():void{
gotoAndStop(stateLabels[((_isOn) ? 3 : 0 + state)]);
}
public function set isOn(_arg1:Boolean):void{
this._isOn = _arg1;
update();
dispatchEvent(new Event(Event.CHANGE));
}
protected function updateLabel():void{
var _local1:int;
while (_local1 < numChildren) {
if ((getChildAt(_local1) is TextField)){
(getChildAt(_local1) as TextField).text = _label;
break;
};
_local1++;
};
}
protected function onRollOver(_arg1:MouseEvent):void{
_state = STATE_OVER;
update();
}
public function dispose():void{
removeEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
removeEventListener(MouseEvent.MOUSE_UP, onMouseUp);
removeEventListener(MouseEvent.ROLL_OVER, onRollOver);
removeEventListener(MouseEvent.ROLL_OUT, onRollOut);
}
}
}//package com.kerb.ui
Section 37
//AssetFactory (com.kerb.utils.AssetFactory)
package com.kerb.utils {
import flash.events.*;
import flash.display.*;
import flash.media.*;
import com.kerb.sound.*;
public final class AssetFactory extends EventDispatcher {
private var _loader:Loader;// = null
public static const EVENT_ASSET_FACTORY_READY:String = "EVENT_ASSET_FACTORY_READY";
public function initialize(_arg1:Class):void{
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.INIT, _onLibraryReady);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _onIOError);
_loader.loadBytes(new (_arg1));
}
public function createExtendedSound(_arg1:String):ExtendedSound{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as ExtendedSound));
}
public function createDisplayObject(_arg1:String):DisplayObject{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as DisplayObject));
}
private function _onLibraryReady(_arg1:Event):void{
_loader.contentLoaderInfo.removeEventListener(Event.INIT, _onLibraryReady);
dispatchEvent(new Event(EVENT_ASSET_FACTORY_READY));
}
public function createSound(_arg1:String):Sound{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as Sound));
}
public function createMovieClip(_arg1:String):MovieClip{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as MovieClip));
}
public function createBitmapDataObject(_arg1:String):BitmapData{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new _local2(0, 0) as BitmapData));
}
private function _onIOError(_arg1:Event):void{
}
}
}//package com.kerb.utils
Section 38
//IDisposable (com.kerb.utils.IDisposable)
package com.kerb.utils {
public interface IDisposable {
function dispose():void;
}
}//package com.kerb.utils
Section 39
//Array2 (de.polygonal.ds.Array2)
package de.polygonal.ds {
public class Array2 implements Collection {
private var _a:Array;
private var _h:int;
private var _w:int;
public function Array2(_arg1:int, _arg2:int){
if ((((_arg1 < 2)) || ((_arg2 < 2)))){
throw (new Error("illegal size"));
};
_a = new Array((_w = _arg1), (_h = _arg2));
fill(null);
}
public function get size():int{
return ((_w * _h));
}
public function fill(_arg1):void{
var _local3:int;
var _local4:Class;
var _local2:int = (_w * _h);
if ((_arg1 is Class)){
_local4 = (_arg1 as Class);
_local3 = 0;
while (_local3 < _local2) {
_a[_local3] = new (_local4);
_local3++;
};
} else {
_local3 = 0;
while (_local3 < _local2) {
_a[_local3] = _arg1;
_local3++;
};
};
}
public function get width():int{
return (_w);
}
public function getCol(_arg1:int):Array{
var _local2:Array = [];
var _local3:int;
while (_local3 < _h) {
_local2[_local3] = _a[int(((_local3 * _w) + _arg1))];
_local3++;
};
return (_local2);
}
public function shiftDown():void{
if (_h == 1){
return;
};
var _local1:int = ((_h - 1) * _w);
_a = _a.slice(_local1, (_local1 + _w)).concat(_a);
_a.splice((_h * _w), _w);
}
public function set width(_arg1:int):void{
resize(_arg1, _h);
}
public function appendCol(_arg1:Array):void{
_arg1.length = _h;
var _local2:int;
while (_local2 < _h) {
_a.splice((((_local2 * _w) + _w) + _local2), 0, _arg1[_local2]);
_local2++;
};
_w++;
}
public function set height(_arg1:int):void{
resize(_w, _arg1);
}
public function clear():void{
_a = new Array(size);
}
public function get(_arg1:int, _arg2:int){
return (_a[int(((_arg2 * _w) + _arg1))]);
}
public function setRow(_arg1:uint, _arg2:Array):void{
if ((((_arg1 < 0)) || ((_arg1 > _h)))){
throw (new Error("row index out of bounds"));
};
var _local3:int = (_arg1 * _w);
var _local4:int;
while (_local4 < _w) {
_a[int((_local3 + _local4))] = _arg2[_local4];
_local4++;
};
}
public function prependCol(_arg1:Array):void{
_arg1.length = _h;
var _local2:int;
while (_local2 < _h) {
_a.splice(((_local2 * _w) + _local2), 0, _arg1[_local2]);
_local2++;
};
_w++;
}
public function isEmpty():Boolean{
return (false);
}
public function toArray():Array{
var _local1:Array = _a.concat();
var _local2:int = size;
if (_local1.length > _local2){
_local1.length = _local2;
};
return (_local1);
}
public function contains(_arg1):Boolean{
var _local2:int = size;
var _local3:int;
while (_local3 < _local2) {
if (_a[_local3] === _arg1){
return (true);
};
_local3++;
};
return (false);
}
public function appendRow(_arg1:Array):void{
_arg1.length = _w;
_a = _a.concat(_arg1);
_h++;
}
public function dump():String{
var _local2:int;
var _local3:*;
var _local5:int;
var _local1 = "Array2\n{";
var _local4:int;
while (_local4 < _h) {
_local1 = (_local1 + ("\n" + "\t"));
_local2 = (_local4 * _w);
_local5 = 0;
while (_local5 < _w) {
_local3 = _a[int((_local2 + _local5))];
_local1 = (_local1 + (("[" + ((_local3)!=undefined) ? _local3 : "?") + "]"));
_local5++;
};
_local4++;
};
_local1 = (_local1 + "\n}");
return (_local1);
}
public function getArray():Array{
return (_a);
}
public function getRow(_arg1:int):Array{
var _local2:int = (_arg1 * _w);
return (_a.slice(_local2, (_local2 + _w)));
}
public function get height():int{
return (_h);
}
public function shiftLeft():void{
var _local2:int;
if (_w == 1){
return;
};
var _local1:int = (_w - 1);
var _local3:int;
while (_local3 < _h) {
_local2 = ((_local3 * _w) + _local1);
_a.splice(_local2, 0, _a.splice((_local2 - _local1), 1));
_local3++;
};
}
public function getIterator():Iterator{
return (new Array2Iterator(this));
}
public function prependRow(_arg1:Array):void{
_arg1.length = _w;
_a = _arg1.concat(_a);
_h++;
}
public function set(_arg1:int, _arg2:int, _arg3):void{
_a[int(((_arg2 * _w) + _arg1))] = _arg3;
}
public function resize(_arg1:int, _arg2:int):void{
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
if ((((_arg1 < 2)) || ((_arg2 < 2)))){
throw (new Error("illegal size"));
};
var _local3:Array = _a.concat();
_a.length = 0;
_a.length = (_arg1 * _arg2);
var _local4:int = ((_arg1 < _w)) ? _arg1 : _w;
var _local5:int = ((_arg2 < _h)) ? _arg2 : _h;
_local7 = 0;
while (_local7 < _local5) {
_local8 = (_local7 * _arg1);
_local9 = (_local7 * _w);
_local6 = 0;
while (_local6 < _local4) {
_a[int((_local8 + _local6))] = _local3[int((_local9 + _local6))];
_local6++;
};
_local7++;
};
_w = _arg1;
_h = _arg2;
}
public function transpose():void{
var _local3:int;
var _local1:Array = _a.concat();
var _local2:int;
while (_local2 < _h) {
_local3 = 0;
while (_local3 < _w) {
_a[int(((_local3 * _w) + _local2))] = _local1[int(((_local2 * _w) + _local3))];
_local3++;
};
_local2++;
};
}
public function shiftRight():void{
var _local2:int;
if (_w == 1){
return;
};
var _local1:int = (_w - 1);
var _local3:int;
while (_local3 < _h) {
_local2 = ((_local3 * _w) + _local1);
_a.splice((_local2 - _local1), 0, _a.splice(_local2, 1));
_local3++;
};
}
public function toString():String{
return ((((("[Array2, width=" + width) + ", height=") + height) + "]"));
}
public function shiftUp():void{
if (_h == 1){
return;
};
_a = _a.concat(_a.slice(0, _w));
_a.splice(0, _w);
}
public function setCol(_arg1:int, _arg2:Array):void{
if ((((_arg1 < 0)) || ((_arg1 > _w)))){
throw (new Error("column index out of bounds"));
};
var _local3:int;
while (_local3 < _h) {
_a[int(((_local3 * _w) + _arg1))] = _arg2[_local3];
_local3++;
};
}
}
}//package de.polygonal.ds
class Array2Iterator implements Iterator {
private var _xCursor:int;
private var _a2:Array2;
private var _yCursor:int;
private function Array2Iterator(_arg1:Array2){
_a2 = _arg1;
_xCursor = (_yCursor = 0);
}
public function start():void{
_xCursor = (_yCursor = 0);
}
public function hasNext():Boolean{
return ((((_yCursor * _a2.width) + _xCursor) < _a2.size));
}
public function get data(){
return (_a2.get(_xCursor, _yCursor));
}
public function set data(_arg1):void{
_a2.set(_xCursor, _yCursor, _arg1);
}
public function next(){
var _local1:* = data;
if (++_xCursor == _a2.width){
_yCursor++;
_xCursor = 0;
};
return (_local1);
}
}
Section 40
//ArrayedQueue (de.polygonal.ds.ArrayedQueue)
package de.polygonal.ds {
public class ArrayedQueue implements Collection {
private var _que:Array;
private var _count:int;
private var _size:int;
private var _front:int;
private var _divisor:int;
public function ArrayedQueue(_arg1:int){
init(_arg1);
}
public function get size():int{
return (_count);
}
public function isEmpty():Boolean{
return ((_count == 0));
}
public function get maxSize():int{
return (_size);
}
public function enqueue(_arg1):Boolean{
if (_size != _count){
_que[int(((_count++ + _front) & _divisor))] = _arg1;
return (true);
};
return (false);
}
public function clear():void{
_que = new Array(_size);
_front = (_count = 0);
var _local1:int;
while (_local1 < _size) {
_que[_local1] = null;
_local1++;
};
}
private function init(_arg1:int):void{
if (!(((_arg1 > 0)) && (((_arg1 & (_arg1 - 1)) == 0)))){
_arg1 = (_arg1 | (_arg1 >> 1));
_arg1 = (_arg1 | (_arg1 >> 2));
_arg1 = (_arg1 | (_arg1 >> 4));
_arg1 = (_arg1 | (_arg1 >> 8));
_arg1 = (_arg1 | (_arg1 >> 16));
_arg1++;
};
_size = _arg1;
_divisor = (_arg1 - 1);
clear();
}
public function peek(){
return (_que[_front]);
}
public function toArray():Array{
var _local1:Array = new Array(_count);
var _local2:int;
while (_local2 < _count) {
_local1[_local2] = _que[int(((_local2 + _front) & _divisor))];
_local2++;
};
return (_local1);
}
public function contains(_arg1):Boolean{
var _local2:int;
while (_local2 < _count) {
if (_que[int(((_local2 + _front) & _divisor))] === _arg1){
return (true);
};
_local2++;
};
return (false);
}
public function getIterator():Iterator{
return (new ArrayedQueueIterator(this));
}
public function dispose():void{
if (!_front){
_que[int((_size - 1))] = null;
} else {
_que[int((_front - 1))] = null;
};
}
public function back(){
return (_que[int((((_count - 1) + _front) & _divisor))]);
}
public function getAt(_arg1:int){
if (_arg1 >= _count){
return (null);
};
return (_que[int(((_arg1 + _front) & _divisor))]);
}
public function toString():String{
return ((("[ArrayedQueue, size=" + size) + "]"));
}
public function dequeue(){
var _local1:*;
if (_count > 0){
_local1 = _que[int(_front++)];
if (_front == _size){
_front = 0;
};
_count--;
return (_local1);
};
return (null);
}
public function dump():String{
var _local2:int;
var _local1 = "[ArrayedQueue]\n";
_local1 = (_local1 + (("\t" + getAt(_local2)) + " -> front\n"));
_local2 = 1;
while (_local2 < _count) {
_local1 = (_local1 + (("\t" + getAt(_local2)) + "\n"));
_local2++;
};
return (_local1);
}
public function setAt(_arg1:int, _arg2):void{
if (_arg1 >= _count){
return;
};
_que[int(((_arg1 + _front) & _divisor))] = _arg2;
}
}
}//package de.polygonal.ds
class ArrayedQueueIterator implements Iterator {
private var _que:ArrayedQueue;
private var _cursor:int;
private function ArrayedQueueIterator(_arg1:ArrayedQueue){
_que = _arg1;
_cursor = 0;
}
public function get data(){
return (_que.getAt(_cursor));
}
public function next(){
if (_cursor < _que.size){
return (_que.getAt(_cursor++));
};
return (null);
}
public function hasNext():Boolean{
return ((_cursor < _que.size));
}
public function set data(_arg1):void{
_que.setAt(_cursor, _arg1);
}
public function start():void{
_cursor = 0;
}
}
Section 41
//BinaryTreeNode (de.polygonal.ds.BinaryTreeNode)
package de.polygonal.ds {
public class BinaryTreeNode {
public var left:BinaryTreeNode;
public var data;
public var parent:BinaryTreeNode;
public var right:BinaryTreeNode;
public function BinaryTreeNode(_arg1){
this.data = _arg1;
parent = (left = (right = null));
}
public function destroy():void{
if (left){
left.destroy();
};
left = null;
if (right){
right.destroy();
};
right = null;
}
public function setLeft(_arg1):void{
if (!left){
left = new BinaryTreeNode(_arg1);
left.parent = this;
} else {
left.data = data;
};
}
public function toString():String{
return ((("[BinaryTreeNode, data= " + data) + "]"));
}
public function getDepth(_arg1:BinaryTreeNode=null):int{
var _local2 = -1;
var _local3 = -1;
if (_arg1 == null){
_arg1 = this;
};
if (_arg1.left){
_local2 = getDepth(_arg1.left);
};
if (_arg1.right){
_local3 = getDepth(_arg1.right);
};
return ((((_local2 > _local3)) ? _local2 : _local3 + 1));
}
public function count():int{
var _local1 = 1;
if (left){
_local1 = (_local1 + left.count());
};
if (right){
_local1 = (_local1 + right.count());
};
return (_local1);
}
public function isLeft():Boolean{
return ((this == parent.left));
}
public function isRight():Boolean{
return ((this == parent.right));
}
public function setRight(_arg1):void{
if (!right){
right = new BinaryTreeNode(_arg1);
right.parent = this;
} else {
right.data = data;
};
}
public static function inorder(_arg1:BinaryTreeNode, _arg2:Function):void{
if (_arg1){
if (_arg1.left){
BinaryTreeNode.inorder(_arg1.left, _arg2);
};
_arg2(_arg1);
if (_arg1.right){
BinaryTreeNode.inorder(_arg1.right, _arg2);
};
};
}
public static function preorder(_arg1:BinaryTreeNode, _arg2:Function):void{
if (_arg1){
_arg2(_arg1);
if (_arg1.left){
BinaryTreeNode.preorder(_arg1.left, _arg2);
};
if (_arg1.right){
BinaryTreeNode.preorder(_arg1.right, _arg2);
};
};
}
public static function postorder(_arg1:BinaryTreeNode, _arg2:Function):void{
if (_arg1){
if (_arg1.left){
BinaryTreeNode.postorder(_arg1.left, _arg2);
};
if (_arg1.right){
BinaryTreeNode.postorder(_arg1.right, _arg2);
};
_arg2(_arg1);
};
}
}
}//package de.polygonal.ds
Section 42
//Collection (de.polygonal.ds.Collection)
package de.polygonal.ds {
public interface Collection {
function get size():int;
function isEmpty():Boolean;
function getIterator():Iterator;
function clear():void;
function toArray():Array;
function contains(_arg1):Boolean;
}
}//package de.polygonal.ds
Section 43
//Iterator (de.polygonal.ds.Iterator)
package de.polygonal.ds {
public interface Iterator {
function start():void;
function set data(_arg1):void;
function get data();
function next();
function hasNext():Boolean;
}
}//package de.polygonal.ds
Section 44
//BroadPhase (de.polygonal.motor2.collision.nbody.BroadPhase)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
public interface BroadPhase {
function findPairs():void;
function moveProxy(_arg1:int):void;
function setWorldBounds(_arg1:AABB2):void;
function queryAABB(_arg1:AABB2, _arg2:Array, _arg3:int=2147483647):int;
function setPairHandler(_arg1:PairCallback):void;
function insideBounds(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean;
function createProxy(_arg1:ShapeSkeleton):int;
function destroyProxy(_arg1:int):void;
function deconstruct():void;
function getProxy(_arg1:int):Proxy;
function getProxyList():Array;
function queryCircle(_arg1:Circle2, _arg2:Array, _arg3:int=2147483647):int;
}
}//package de.polygonal.motor2.collision.nbody
Section 45
//ExhaustiveSearch (de.polygonal.motor2.collision.nbody.ExhaustiveSearch)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.*;
import de.polygonal.motor2.math.*;
import flash.system.*;
public class ExhaustiveSearch implements BroadPhase {
private var _xmax:Number;
private var _ymin:Number;
private var _proxyCount:int;
private var _freeProxy:int;
private var _ymax:Number;
private var _proxyPool:Array;
private var _proxyList:LinkedProxy;
private var _pairManager:UnbufferedPairManager;
private var _xmin:Number;
public function ExhaustiveSearch(){
var _local3:LinkedProxy;
super();
var _local1:uint = System.totalMemory;
var _local2:int = Constants.k_maxProxies;
_proxyPool = new Array(_local2, true);
var _local4:int;
while (_local4 < (_local2 - 1)) {
_local3 = new LinkedProxy();
_local3.setNext((_local4 + 1));
_local3.id = _local4;
_proxyPool[_local4] = _local3;
_local4++;
};
_local3 = new LinkedProxy();
_local3.setNext(Proxy.NULL_PROXY);
_local3.id = (_local2 - 1);
_proxyPool[(_local2 - 1)] = _local3;
trace("/*////////////////////////////////////////////////////////*");
trace(" * EXHAUSTIVE SEARCH STATISTICS");
trace((" * max proxies = " + _local2));
trace(((" * memory = " + ((System.totalMemory - _local1) >> 10)) + " KiB"));
trace(" ////////////////////////////////////////////////////////*/");
trace("");
}
public function getProxyList():Array{
var _local2:int;
var _local1:Array = new Array(_proxyCount, true);
var _local3:LinkedProxy = _proxyList;
while (_local3 != null) {
var _temp1 = _local2;
_local2 = (_local2 + 1);
var _local4 = _temp1;
_local1[_local4] = _local3;
_local3 = _local3.next;
};
return (_local1);
}
public function getProxy(_arg1:int):Proxy{
return (_proxyPool[_arg1]);
}
public function insideBounds(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
if (_arg1 < _xmin){
return (false);
};
if (_arg3 > _xmax){
return (false);
};
if (_arg2 < _ymin){
return (false);
};
if (_arg4 > _ymax){
return (false);
};
return (true);
}
public function createProxy(_arg1:ShapeSkeleton):int{
var _local2:int = _freeProxy;
var _local3:LinkedProxy = _proxyPool[_local2];
_freeProxy = _local3.getNext();
_local3.next = _proxyList;
if (_proxyList){
_proxyList.prev = _local3;
};
_proxyList = _local3;
_local3.shape = _arg1;
_proxyCount++;
return (_local2);
}
public function setPairHandler(_arg1:PairCallback):void{
_pairManager = new UnbufferedPairManager(_arg1, this);
}
public function destroyProxy(_arg1:int):void{
var _local5:ShapeSkeleton;
if (_arg1 == Proxy.NULL_PROXY){
return;
};
var _local2:LinkedProxy = _proxyPool[_arg1];
var _local3:LinkedProxy = _proxyList;
var _local4:ShapeSkeleton = _local2.shape;
var _local6:Number = _local4.xmin;
var _local7:Number = _local4.xmax;
var _local8:Number = _local4.ymin;
var _local9:Number = _local4.ymax;
while (_local3 != null) {
if (_local2 == _local3){
_local3 = _local3.next;
} else {
_local5 = _local3.shape;
if ((((((((_local6 > _local5.xmax)) || ((_local7 < _local5.xmin)))) || ((_local8 > _local5.ymax)))) || ((_local9 < _local5.ymin)))){
_local3 = _local3.next;
} else {
if (_pairManager.removePair(_arg1, _local3.id)){
_local3.overlapCount--;
};
_local3 = _local3.next;
};
};
};
if (_local2.prev){
_local2.prev.next = _local2.next;
};
if (_local2.next){
_local2.next.prev = _local2.prev;
};
if (_local2 == _proxyList){
_proxyList = _local2.next;
};
_local2.setNext(_freeProxy);
_freeProxy = _arg1;
_local2.reset();
_proxyCount--;
}
public function moveProxy(_arg1:int):void{
}
public function setWorldBounds(_arg1:AABB2):void{
_xmin = _arg1.xmin;
_ymin = _arg1.ymin;
_xmax = _arg1.xmax;
_ymax = _arg1.ymax;
}
public function findPairs():void{
var _local1:LinkedProxy;
var _local2:ShapeSkeleton;
var _local3:LinkedProxy;
var _local4:ShapeSkeleton;
_local1 = _proxyList;
while (_local1 != null) {
_local2 = _local1.shape;
_local3 = _local1.next;
while (_local3 != null) {
_local4 = _local3.shape;
if ((((((((_local2.xmin > _local4.xmax)) || ((_local2.xmax < _local4.xmin)))) || ((_local2.ymin > _local4.ymax)))) || ((_local2.ymax < _local4.ymin)))){
if ((_local1.overlapCount * _local3.overlapCount) > 0){
if (_pairManager.removePair(_local1.id, _local3.id)){
_local1.overlapCount++;
_local3.overlapCount++;
};
};
} else {
if (_pairManager.addPair(_local1.id, _local3.id)){
_local1.overlapCount++;
_local3.overlapCount++;
};
};
_local3 = _local3.next;
};
_local1 = _local1.next;
};
}
public function queryAABB(_arg1:AABB2, _arg2:Array, _arg3:int=2147483647):int{
var _local9:ShapeSkeleton;
if (_arg2.fixed){
_arg3 = _arg2.length;
};
var _local4:Number = _arg1.xmin;
var _local5:Number = _arg1.xmax;
var _local6:Number = _arg1.ymin;
var _local7:Number = _arg1.ymax;
var _local8:LinkedProxy = _proxyList;
var _local10:int;
while (_local8 != null) {
_local9 = _local8.shape;
if ((((((((_local9.xmin > _local5)) || ((_local9.xmax < _local4)))) || ((_local9.ymin > _local7)))) || ((_local9.ymax < _local6)))){
_local8 = _local8.next;
} else {
var _temp1 = _local10;
_local10 = (_local10 + 1);
var _local11 = _temp1;
_arg2[_local11] = _local9;
if (_local10 == _arg3){
break;
};
_local8 = _local8.next;
};
};
return (_local10);
}
public function deconstruct():void{
var _local1:LinkedProxy;
var _local2:LinkedProxy = _proxyList;
while (_local2 != null) {
_local1 = _local2;
_local2 = _local2.next;
_local1.next = null;
_local1.prev = null;
_local1.shape = null;
};
_proxyPool = null;
_pairManager = null;
}
public function queryCircle(_arg1:Circle2, _arg2:Array, _arg3:int=2147483647):int{
var _local8:ShapeSkeleton;
if (_arg2.fixed){
_arg3 = _arg2.length;
};
var _local4:Number = _arg1.c.x;
var _local5:Number = _arg1.c.y;
var _local6:Number = _arg1.radius;
var _local7:LinkedProxy = _proxyList;
var _local9:int;
while (_local7 != null) {
_local8 = _local7.shape;
if ((((_local8.x - _local4) * (_local8.x - _local4)) + ((_local8.y - _local5) * (_local8.y - _local5))) <= ((_local8.radius + _local6) * (_local8.radius + _local6))){
var _temp1 = _local9;
_local9 = (_local9 + 1);
var _local10 = _temp1;
_arg2[_local10] = _local8;
if (_local9 == _arg3){
break;
};
};
_local7 = _local7.next;
};
return (_local9);
}
}
}//package de.polygonal.motor2.collision.nbody
Section 46
//LinkedProxy (de.polygonal.motor2.collision.nbody.LinkedProxy)
package de.polygonal.motor2.collision.nbody {
public class LinkedProxy extends Proxy {
public var next:LinkedProxy;
public var prev:LinkedProxy;
override public function reset():void{
next = null;
prev = null;
super.reset();
}
}
}//package de.polygonal.motor2.collision.nbody
Section 47
//PairCallback (de.polygonal.motor2.collision.nbody.PairCallback)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public interface PairCallback {
function pairRemoved(_arg1:Contact):void;
function pairAdded(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):Contact;
}
}//package de.polygonal.motor2.collision.nbody
Section 48
//Proxy (de.polygonal.motor2.collision.nbody.Proxy)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.collision.shapes.*;
public class Proxy {
public var shape:ShapeSkeleton;
public var overlapCount:int;
private var _next:int;
public var id:int;
public static const NULL_PROXY:int = 0xFFFF;
public function getNext():int{
return (_next);
}
public function reset():void{
overlapCount = 0;
shape = null;
}
public function setNext(_arg1:int):void{
_next = _arg1;
}
}
}//package de.polygonal.motor2.collision.nbody
Section 49
//UnbufferedPair (de.polygonal.motor2.collision.nbody.UnbufferedPair)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.dynamics.contact.*;
public class UnbufferedPair {
public var contact:Contact;
public var proxyId1:int;
public var proxyId2:int;
}
}//package de.polygonal.motor2.collision.nbody
Section 50
//UnbufferedPairManager (de.polygonal.motor2.collision.nbody.UnbufferedPairManager)
package de.polygonal.motor2.collision.nbody {
import flash.utils.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.*;
import de.polygonal.motor2.dynamics.contact.*;
public class UnbufferedPairManager {
private var _callback:PairCallback;
private var _poolMask:int;
private var _writeIndex:int;
private var _pairTable:Dictionary;
private var _pairCount:int;
private var _broadPhase:BroadPhase;
private var _pairPool:Array;
private var _readIndex:int;
public function UnbufferedPairManager(_arg1:PairCallback, _arg2:BroadPhase){
_callback = _arg1;
_broadPhase = _arg2;
_pairTable = new Dictionary();
var _local3:int = Constants.k_maxPairs;
_pairPool = new Array(_local3, true);
var _local4:int;
while (_local4 < _local3) {
_pairPool[_local4] = new UnbufferedPair();
_local4++;
};
_poolMask = (_local3 - 1);
}
private function getKey(_arg1:int, _arg2:int):int{
if (_arg1 > _arg2){
return (((_arg2 << 16) | _arg1));
};
return (((_arg1 << 16) | _arg2));
}
public function addPair(_arg1:int, _arg2:int):Boolean{
var _local3:int = getKey(_arg1, _arg2);
if (_pairTable[_local3]){
return (false);
};
var _local4:UnbufferedPair = _pairPool[_readIndex];
_readIndex = ((_readIndex + 1) & _poolMask);
var _local5:ShapeSkeleton = _broadPhase.getProxy(_arg1).shape;
var _local6:ShapeSkeleton = _broadPhase.getProxy(_arg2).shape;
var _local7:Contact = _callback.pairAdded(_local5, _local6);
_local4.proxyId1 = _arg1;
_local4.proxyId2 = _arg2;
_local4.contact = _local7;
_pairCount++;
_pairTable[_local3] = _local4;
return (true);
}
public function removePair(_arg1:int, _arg2:int):Boolean{
var _local3:int = getKey(_arg1, _arg2);
var _local4:UnbufferedPair = _pairTable[_local3];
if (_local4 == null){
return (false);
};
_callback.pairRemoved(_local4.contact);
_local4.contact = null;
_pairPool[_writeIndex] = _local4;
_writeIndex = ((_writeIndex + 1) & _poolMask);
_pairCount--;
delete _pairTable[_local3];
return (true);
}
}
}//package de.polygonal.motor2.collision.nbody
Section 51
//CollideBox (de.polygonal.motor2.collision.pairwise.CollideBox)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollideBox implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:int;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:int;
var _local19:int;
var _local20:int;
var _local21:ShapeSkeleton;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:int;
var _local29:int;
var _local30:int;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local39:Number;
var _local40:Number;
var _local41:Number;
var _local42:Number;
var _local43:Number;
var _local44:Number;
var _local45:Number;
var _local46:ContactPoint;
var _local5:BoxContact = BoxContact(_arg4);
var _local12:Number = (_arg3.x - _arg2.x);
var _local13:Number = (_arg3.y - _arg2.y);
_local11 = _local5.sepAxisId;
if (_local11 == 0){
_local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21));
if (_local14 < 0){
_local14 = -(_local14);
};
_local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22));
if (_local16 < 0){
_local16 = -(_local16);
};
_local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = _arg2.r11;
_local7 = _arg2.r21;
_local18 = 3;
} else {
_local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = -(_arg2.r11);
_local7 = -(_arg2.r21);
_local18 = 1;
};
_local10 = _local9;
_local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22));
if (_local17 < 0){
_local17 = -(_local17);
};
_local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21));
if (_local15 < 0){
_local15 = -(_local15);
};
_local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = _arg2.r12;
_local7 = _arg2.r22;
_local18 = 0;
};
} else {
_local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = -(_arg2.r12);
_local7 = -(_arg2.r22);
_local18 = 2;
};
};
_local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = _arg3.r11;
_local7 = _arg3.r21;
_local18 = 1;
};
} else {
_local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = -(_arg3.r11);
_local7 = -(_arg3.r21);
_local18 = 3;
};
};
_local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = _arg3.r12;
_local7 = _arg3.r22;
_local18 = 2;
};
} else {
_local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = -(_arg3.r12);
_local7 = -(_arg3.r22);
_local18 = 0;
};
};
} else {
if (_local11 == 1){
_local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22));
if (_local17 < 0){
_local17 = -(_local17);
};
_local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21));
if (_local15 < 0){
_local15 = -(_local15);
};
_local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = _arg2.r12;
_local7 = _arg2.r22;
_local18 = 0;
} else {
_local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = -(_arg2.r12);
_local7 = -(_arg2.r22);
_local18 = 2;
};
_local10 = _local9;
_local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21));
if (_local14 < 0){
_local14 = -(_local14);
};
_local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22));
if (_local16 < 0){
_local16 = -(_local16);
};
_local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = _arg2.r11;
_local7 = _arg2.r21;
_local18 = 3;
};
} else {
_local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = -(_arg2.r11);
_local7 = -(_arg2.r21);
_local18 = 1;
};
};
_local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = _arg3.r11;
_local7 = _arg3.r21;
_local18 = 1;
};
} else {
_local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = -(_arg3.r11);
_local7 = -(_arg3.r21);
_local18 = 3;
};
};
_local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = _arg3.r12;
_local7 = _arg3.r22;
_local18 = 2;
};
} else {
_local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = -(_arg3.r12);
_local7 = -(_arg3.r22);
_local18 = 0;
};
};
} else {
if (_local11 == 2){
_local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21));
if (_local14 < 0){
_local14 = -(_local14);
};
_local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21));
if (_local15 < 0){
_local15 = -(_local15);
};
_local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = _arg3.r11;
_local7 = _arg3.r21;
_local18 = 1;
} else {
_local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = -(_arg3.r11);
_local7 = -(_arg3.r21);
_local18 = 3;
};
_local10 = _local9;
_local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22));
if (_local16 < 0){
_local16 = -(_local16);
};
_local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22));
if (_local17 < 0){
_local17 = -(_local17);
};
_local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = _arg2.r11;
_local7 = _arg2.r21;
_local18 = 3;
};
} else {
_local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = -(_arg2.r11);
_local7 = -(_arg2.r21);
_local18 = 1;
};
};
_local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = _arg2.r12;
_local7 = _arg2.r22;
_local18 = 0;
};
} else {
_local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = -(_arg2.r12);
_local7 = -(_arg2.r22);
_local18 = 2;
};
};
_local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = _arg3.r12;
_local7 = _arg3.r22;
_local18 = 2;
};
} else {
_local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = -(_arg3.r12);
_local7 = -(_arg3.r22);
_local18 = 0;
};
};
} else {
if (_local11 == 3){
_local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22));
if (_local16 < 0){
_local16 = -(_local16);
};
_local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22));
if (_local17 < 0){
_local17 = -(_local17);
};
_local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = _arg3.r12;
_local7 = _arg3.r22;
_local18 = 2;
} else {
_local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = -(_arg3.r12);
_local7 = -(_arg3.r22);
_local18 = 0;
};
_local10 = _local9;
_local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21));
if (_local14 < 0){
_local14 = -(_local14);
};
_local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21));
if (_local15 < 0){
_local15 = -(_local15);
};
_local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = _arg2.r11;
_local7 = _arg2.r21;
_local18 = 3;
};
} else {
_local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = -(_arg2.r11);
_local7 = -(_arg2.r21);
_local18 = 1;
};
};
_local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = _arg2.r12;
_local7 = _arg2.r22;
_local18 = 0;
};
} else {
_local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = -(_arg2.r12);
_local7 = -(_arg2.r22);
_local18 = 2;
};
};
_local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = _arg3.r11;
_local7 = _arg3.r21;
_local18 = 1;
};
} else {
_local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = -(_arg3.r11);
_local7 = -(_arg3.r21);
_local18 = 3;
};
};
};
};
};
};
if (_local11 == 0){
_local21 = _arg3;
_local22 = (((_arg2.x * _local6) + (_arg2.y * _local7)) + _arg2.ex);
_local26 = _arg2.r12;
_local27 = _arg2.r22;
_local23 = ((_arg2.x * _local26) + (_arg2.y * _local27));
_local24 = (-(_local23) + _arg2.ey);
_local28 = 1;
_local25 = (_local23 + _arg2.ey);
_local29 = 3;
} else {
if (_local11 == 1){
_local21 = _arg3;
_local22 = (((_arg2.x * _local6) + (_arg2.y * _local7)) + _arg2.ey);
_local26 = _arg2.r11;
_local27 = _arg2.r21;
_local23 = ((_arg2.x * _local26) + (_arg2.y * _local27));
_local24 = (-(_local23) + _arg2.ex);
_local28 = 2;
_local25 = (_local23 + _arg2.ex);
_local29 = 4;
} else {
if (_local11 == 2){
_local21 = _arg2;
_local30 = 1;
_local6 = -(_local6);
_local7 = -(_local7);
_local22 = (((_arg3.x * _local6) + (_arg3.y * _local7)) + _arg3.ex);
_local26 = _arg3.r12;
_local27 = _arg3.r22;
_local23 = ((_arg3.x * _local26) + (_arg3.y * _local27));
_local24 = (-(_local23) + _arg3.ey);
_local28 = 1;
_local25 = (_local23 + _arg3.ey);
_local29 = 3;
} else {
if (_local11 == 3){
_local21 = _arg2;
_local30 = 1;
_local6 = -(_local6);
_local7 = -(_local7);
_local22 = (((_arg3.x * _local6) + (_arg3.y * _local7)) + _arg3.ey);
_local26 = _arg3.r11;
_local27 = _arg3.r21;
_local23 = ((_arg3.x * _local26) + (_arg3.y * _local27));
_local24 = (-(_local23) + _arg3.ex);
_local28 = 2;
_local25 = (_local23 + _arg3.ex);
_local29 = 4;
};
};
};
};
var _local35:Number = ((-(_local21.r11) * _local6) - (_local21.r21 * _local7));
var _local36:Number = ((-(_local21.r12) * _local6) - (_local21.r22 * _local7));
if (((_local35 < 0)) ? -(_local35) : _local35 > ((_local36 < 0)) ? -(_local36) : _local36){
if (_local35 > 0){
_local31 = _local21.ex;
_local33 = -(_local21.ey);
_local32 = _local21.ex;
_local34 = _local21.ey;
if (_local36 > 0){
_local19 = 0;
_local20 = 3;
} else {
_local19 = 3;
_local20 = 0;
};
} else {
_local31 = -(_local21.ex);
_local33 = _local21.ey;
_local32 = -(_local21.ex);
_local34 = -(_local21.ey);
if (_local36 > 0){
_local19 = 1;
_local20 = 2;
} else {
_local19 = 2;
_local20 = 1;
};
};
} else {
if (_local36 > 0){
_local31 = _local21.ex;
_local33 = _local21.ey;
_local32 = -(_local21.ex);
_local34 = _local21.ey;
if (_local35 > 0){
_local19 = 0;
_local20 = 1;
} else {
_local19 = 1;
_local20 = 0;
};
} else {
_local31 = -(_local21.ex);
_local33 = -(_local21.ey);
_local32 = _local21.ex;
_local34 = -(_local21.ey);
if (_local35 > 0){
_local19 = 3;
_local20 = 2;
} else {
_local19 = 2;
_local20 = 3;
};
};
};
var _local37:Number = _local31;
var _local38:Number = _local33;
_local31 = ((_local21.x + (_local21.r11 * _local37)) + (_local21.r12 * _local38));
_local33 = ((_local21.y + (_local21.r21 * _local37)) + (_local21.r22 * _local38));
_local37 = _local32;
_local38 = _local34;
_local32 = ((_local21.x + (_local21.r11 * _local37)) + (_local21.r12 * _local38));
_local34 = ((_local21.y + (_local21.r21 * _local37)) + (_local21.r22 * _local38));
_local43 = (((_local31 * -(_local26)) + (_local33 * -(_local27))) - _local24);
_local44 = (((_local32 * -(_local26)) + (_local34 * -(_local27))) - _local24);
if ((_local43 * _local44) < 0){
_local45 = (_local43 / (_local43 - _local44));
if (_local43 < 0){
_local39 = _local31;
_local41 = _local33;
_local40 = (_local39 + (_local45 * (_local32 - _local39)));
_local42 = (_local41 + (_local45 * (_local34 - _local41)));
} else {
_local39 = _local32;
_local41 = _local34;
_local40 = (_local31 + (_local45 * (_local39 - _local31)));
_local42 = (_local33 + (_local45 * (_local41 - _local33)));
};
} else {
if (_local43 > 0){
_arg1.pointCount = 0;
return;
};
if (_local43 < _local44){
_local39 = _local31;
_local41 = _local33;
_local40 = _local32;
_local42 = _local34;
} else {
_local40 = _local31;
_local42 = _local33;
_local39 = _local32;
_local41 = _local34;
};
};
_local43 = (((_local39 * _local26) + (_local41 * _local27)) - _local25);
_local44 = (((_local40 * _local26) + (_local42 * _local27)) - _local25);
if ((_local43 * _local44) < 0){
_local45 = (_local43 / (_local43 - _local44));
_local39 = (_local39 + (_local45 * (_local40 - _local39)));
_local41 = (_local41 + (_local45 * (_local42 - _local41)));
} else {
if (_local43 > 0){
_arg1.pointCount = 0;
return;
};
};
_local9 = (((_local6 * _local39) + (_local7 * _local41)) - _local22);
if (_local9 <= 0){
_arg1.pointCount = 1;
if (_local30){
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
} else {
_arg1.nx = _local6;
_arg1.ny = _local7;
};
_local46 = _arg1.c0;
_local46.sep = _local9;
_local46.x = _local39;
_local46.y = _local41;
_local46.id.flip = _local30;
_local46.id.incEdge = _local20;
_local46.id.incVert = _local19;
_local46.id.refFace = _local18;
_local46.id.bake();
_local9 = (((_local6 * _local40) + (_local7 * _local42)) - _local22);
if (_local9 <= 0){
_arg1.pointCount = 2;
_local46 = _arg1.c1;
_local46.sep = _local9;
_local46.x = _local40;
_local46.y = _local42;
_local46.id.flip = _local30;
_local46.id.incEdge = _local20;
_local46.id.incVert = _local19;
_local46.id.refFace = _local18;
_local46.id.bake();
};
} else {
_local9 = (((_local6 * _local40) + (_local7 * _local42)) - _local22);
if (_local9 <= 0){
_arg1.pointCount = 1;
if (_local30){
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
} else {
_arg1.nx = _local6;
_arg1.ny = _local7;
};
_local46 = _arg1.c0;
_local46.sep = _local9;
_local46.x = _local40;
_local46.y = _local42;
_local46.id.flip = _local30;
_local46.id.incEdge = _local20;
_local46.id.incVert = _local19;
_local46.id.refFace = _local18;
_local46.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 52
//CollideBoxCircle (de.polygonal.motor2.collision.pairwise.CollideBoxCircle)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollideBoxCircle implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:ContactPoint;
var _local11:int;
var _local12:int;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:V2;
var _local21:V2;
var _local22:V2;
var _local23:V2;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:BoxCircleContact;
var _local29:Number;
var _local30:Number;
var _local31:int;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local10:int = ContactID.NULL_FEATURE;
if (_arg1.pointCount == 1){
_local11 = _local10;
_local12 = _local10;
_local13 = _arg2.x;
_local14 = _arg2.y;
_local15 = (_arg3.x - _arg2.x);
_local16 = (_arg3.y - _arg2.y);
_local17 = 0;
_local18 = 0;
_local19 = ((_local15 * _arg2.r11) + (_local16 * _arg2.r21));
if (_local19 < -(_arg2.ex)){
_local18 = (_local19 + _arg2.ex);
_local19 = -(_arg2.ex);
_local12 = (1 + 1);
_local11 = _local12;
} else {
if (_local19 > _arg2.ex){
_local18 = (_local19 - _arg2.ex);
_local19 = _arg2.ex;
_local12 = (3 + 1);
_local11 = _local12;
};
};
_local13 = (_local13 + (_arg2.r11 * _local19));
_local14 = (_local14 + (_arg2.r21 * _local19));
_local17 = (_local17 + (_local18 * _local18));
_local18 = 0;
_local19 = ((_local15 * _arg2.r12) + (_local16 * _arg2.r22));
if (_local19 < -(_arg2.ey)){
_local18 = (_local19 + _arg2.ey);
_local19 = -(_arg2.ey);
_local12 = _local10;
if (_local11 == (1 + 1)){
_local11 = (2 + 1);
} else {
if (_local11 == _local10){
_local12 = (2 + 1);
};
};
} else {
if (_local19 > _arg2.ey){
_local18 = (_local19 - _arg2.ey);
_local19 = _arg2.ey;
_local12 = _local10;
if (_local11 == (3 + 1)){
_local11 = (0 + 1);
} else {
if (_local11 == _local10){
_local12 = (0 + 1);
};
};
} else {
_local11 = _local10;
};
};
_local13 = (_local13 + (_arg2.r12 * _local19));
_local14 = (_local14 + (_arg2.r22 * _local19));
_local5 = (_local17 + (_local18 * _local18));
if (_local5 >= _arg3.radiusSq){
_arg1.pointCount = 0;
return;
};
_arg1.pointCount = 1;
_local9 = _arg1.c0;
_local9.id.refFace = _local10;
_local9.id.flip = 0;
if (_local5 == 0){
_local9.id.incVert = _local10;
_local7 = ((_local15 * _arg2.r11) + (_local16 * _arg2.r21));
_local8 = ((_local15 * _arg2.r12) + (_local16 * _arg2.r22));
if (_local7 > 0){
if (_local8 > 0){
if ((_arg2.ex - _local7) < (_arg2.ey - _local8)){
_arg1.nx = _arg2.r11;
_arg1.ny = _arg2.r21;
_local9.sep = ((_arg3.radius + _arg2.ex) - _local7);
_local9.id.incEdge = 3;
} else {
_arg1.nx = _arg2.r12;
_arg1.ny = _arg2.r22;
_local9.sep = ((_arg3.radius + _arg2.ey) - _local8);
_local9.id.incEdge = 0;
};
} else {
if ((_arg2.ex - _local7) < (_arg2.ey + _local8)){
_arg1.nx = _arg2.r11;
_arg1.ny = _arg2.r21;
_local9.sep = ((_arg3.radius + _arg2.ex) - _local7);
_local9.id.incEdge = 3;
} else {
_arg1.nx = -(_arg2.r12);
_arg1.ny = -(_arg2.r22);
_local9.sep = ((_arg3.radius + _arg2.ey) + _local8);
_local9.id.incEdge = 2;
};
};
} else {
if (_local8 > 0){
if ((_arg2.ex + _local7) < (_arg2.ey - _local8)){
_arg1.nx = -(_arg2.r11);
_arg1.ny = -(_arg2.r21);
_local9.sep = ((_arg3.radius + _arg2.ex) + _local7);
_local9.id.incEdge = 1;
} else {
_arg1.nx = _arg2.r12;
_arg1.ny = _arg2.r22;
_local9.sep = ((_arg3.radius + _arg2.ey) - _local8);
_local9.id.incEdge = 0;
};
} else {
if ((_arg2.ex + _local7) < (_arg2.ey + _local8)){
_arg1.nx = -(_arg2.r11);
_arg1.ny = -(_arg2.r21);
_local9.sep = ((_arg3.radius + _arg2.ex) + _local7);
_local9.id.incEdge = 1;
} else {
_arg1.nx = -(_arg2.r12);
_arg1.ny = -(_arg2.r22);
_local9.sep = ((_arg3.radius + _arg2.ey) + _local8);
_local9.id.incEdge = 2;
};
};
};
_local9.sep = -(_local9.sep);
} else {
_local7 = (_arg3.x - _local13);
_local8 = (_arg3.y - _local14);
_local6 = Math.sqrt(((_local7 * _local7) + (_local8 * _local8)));
_arg1.nx = (_local7 / _local6);
_arg1.ny = (_local8 / _local6);
_local9.id.incVert = _local11;
_local9.id.incEdge = _local12;
_local9.sep = -((_arg3.radius - Math.sqrt(_local5)));
};
_local9.x = (_arg3.x - (_arg3.radius * _arg1.nx));
_local9.y = (_arg3.y - (_arg3.radius * _arg1.ny));
_local9.id.bake();
} else {
_local24 = _arg3.x;
_local25 = _arg3.y;
_local27 = _arg3.radius;
_local5 = -2147483648;
_local28 = BoxCircleContact(_arg4);
_local20 = _local28.p;
_local21 = _local28.d;
_local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y)));
if (_local26 > _local27){
_arg1.pointCount = 0;
_local28.p = _local20;
_local28.d = _local21;
return;
};
if (_local26 > _local5){
_local5 = _local26;
_local22 = _local21;
_local23 = _local20;
};
_local20 = _local20.next;
_local21 = _local21.next;
_local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y)));
if (_local26 > _local27){
_local28.p = _local20;
_local28.d = _local21;
_arg1.pointCount = 0;
return;
};
if (_local26 > _local5){
_local5 = _local26;
_local22 = _local21;
_local23 = _local20;
};
_local20 = _local20.next;
_local21 = _local21.next;
_local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y)));
if (_local26 > _local27){
_local28.p = _local20;
_local28.d = _local21;
_arg1.pointCount = 0;
return;
};
if (_local26 > _local5){
_local5 = _local26;
_local22 = _local21;
_local23 = _local20;
};
_local20 = _local20.next;
_local21 = _local21.next;
_local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y)));
if (_local26 > _local27){
_local28.p = _local20;
_local28.d = _local21;
_arg1.pointCount = 0;
return;
};
if (_local26 > _local5){
_local5 = _local26;
_local22 = _local21;
_local23 = _local20;
};
if (_local5 < 1E-6){
_arg1.pointCount = 1;
_arg1.nx = _local22.x;
_arg1.ny = _local22.y;
_local9 = _arg1.c0;
_local9.id.incEdge = _local22.index;
_local9.id.incVert = _local10;
_local9.id.refFace = _local10;
_local9.id.flip = 0;
_local9.id.bake();
_local9.x = (_local24 - (_local27 * _arg1.nx));
_local9.y = (_local25 - (_local27 * _arg1.ny));
_local9.sep = (_local5 - _local27);
return;
};
_local31 = _local23.index;
if (_local31 == 0){
_local6 = (_arg2.ex * 2);
_local29 = -(_arg2.r11);
_local30 = -(_arg2.r21);
} else {
if (_local31 == 1){
_local29 = -(_arg2.r12);
_local30 = -(_arg2.r22);
_local6 = (_arg2.ey * 2);
} else {
if (_local31 == 2){
_local29 = _arg2.r11;
_local30 = _arg2.r21;
_local6 = (_arg2.ex * 2);
} else {
if (_local31 == 3){
_local29 = _arg2.r12;
_local30 = _arg2.r22;
_local6 = (_arg2.ey * 2);
};
};
};
};
if (_local6 < 1E-6){
_local7 = (_local24 - _local23.x);
_local8 = (_local25 - _local23.y);
_local32 = ((_local7 * _local7) + (_local8 * _local8));
if (_local32 > _arg3.radiusSq){
_arg1.pointCount = 0;
return;
};
_local32 = Math.sqrt(_local32);
_local7 = (_local7 / _local32);
_local8 = (_local8 / _local32);
_arg1.pointCount = 1;
_arg1.nx = _local7;
_arg1.ny = _local8;
_local9 = _arg1.c0;
_local9.id.incVert = (_local31 + 1);
_local9.id.incEdge = _local10;
_local9.id.refFace = _local10;
_local9.id.flip = 0;
_local9.id.bake();
_local9.x = (_local24 - (_arg3.radius * _local7));
_local9.y = (_local25 - (_arg3.radius * _local8));
_local9.sep = (_local32 - _local27);
return;
};
_local9 = _arg1.c0;
_local9.id.flip = 0;
_local9.id.refFace = _local10;
_local35 = (((_local24 - _local23.x) * _local29) + ((_local25 - _local23.y) * _local30));
if (_local35 <= 0){
_local33 = _local23.x;
_local34 = _local23.y;
_local9.id.incVert = _local23.index;
_local9.id.incEdge = _local10;
} else {
if (_local35 >= _local6){
_local33 = _local23.next.x;
_local34 = _local23.next.y;
_local9.id.incVert = _local23.next.index;
_local9.id.incEdge = _local10;
} else {
_local33 = ((_local29 * _local35) + _local23.x);
_local34 = ((_local30 * _local35) + _local23.y);
_local9.id.incVert = _local10;
_local9.id.incEdge = _local23.index;
};
};
_local7 = (_local24 - _local33);
_local8 = (_local25 - _local34);
_local32 = ((_local7 * _local7) + (_local8 * _local8));
if (_local32 > _arg3.radiusSq){
_arg1.pointCount = 0;
return;
};
_local32 = Math.sqrt(_local32);
_local7 = (_local7 / _local32);
_local8 = (_local8 / _local32);
_arg1.pointCount = 1;
_arg1.nx = _local7;
_arg1.ny = _local8;
_local9.x = (_local24 - (_local27 * _local7));
_local9.y = (_local25 - (_local27 * _local8));
_local9.sep = (_local32 - _local27);
_local9.id.bake();
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 53
//CollideBoxLineDoubleSided (de.polygonal.motor2.collision.pairwise.CollideBoxLineDoubleSided)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideBoxLineDoubleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:V2;
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:Number;
var _local16:Number;
var _local28:int;
var _local32:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:ContactPoint;
var _local42:V2;
var _local12:Number = -2147483648;
var _local13:int;
_local8 = _arg3.worldVertexChain;
_local7 = _arg3.worldNormalChain;
_local5 = _arg2.worldVertexChain;
var _local14:V2 = _local5;
var _local15:Number = ((_local5.x * _local7.x) + (_local5.y * _local7.y));
_local5 = _local5.next;
_local16 = ((_local5.x * _local7.x) + (_local5.y * _local7.y));
if (_local16 < _local15){
_local15 = _local16;
_local14 = _local5;
};
_local5 = _local5.next;
_local16 = ((_local5.x * _local7.x) + (_local5.y * _local7.y));
if (_local16 < _local15){
_local15 = _local16;
_local14 = _local5;
};
_local5 = _local5.next;
_local16 = ((_local5.x * _local7.x) + (_local5.y * _local7.y));
if (_local16 < _local15){
_local15 = _local16;
_local14 = _local5;
};
_local5 = _local14;
_local11 = ((_local7.x * (_local5.x - _local8.x)) + (_local7.y * (_local5.y - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local5;
_local13 = 1;
};
_local8 = _local8.next;
_local7 = _local7.next;
_local5 = _local5.next.next;
_local11 = ((_local7.x * (_local5.x - _local8.x)) + (_local7.y * (_local5.y - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local5;
_local13 = 1;
};
var _local17:V2 = _arg3.worldVertexChain;
var _local18:V2 = _local17.next;
var _local19:Number = _local17.x;
var _local20:Number = _local18.x;
var _local21:Number = _local17.y;
var _local22:Number = _local18.y;
_local8 = _arg2.worldVertexChain.next;
_local7 = _arg2.worldNormalChain.next;
if (((_local19 * _local7.x) + (_local21 * _local7.y)) < ((_local20 * _local7.x) + (_local22 * _local7.y))){
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
} else {
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
};
_local8 = _arg2.worldVertexChain;
_local7 = _arg2.worldNormalChain;
if (((_local19 * _local7.x) + (_local21 * _local7.y)) < ((_local20 * _local7.x) + (_local22 * _local7.y))){
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
} else {
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
};
var _local23:ShapeSkeleton = _arg2;
var _local24:Number = _local6.x;
var _local25:Number = _local6.y;
var _local26:int = _local9.index;
var _local27:int = _local10.index;
var _local29:V2 = _local10.edge.n;
var _local30:Number = ((_local29.x * _local24) + (_local29.y * _local25));
if (((_local29.prev.x * _local24) + (_local29.prev.y * _local25)) < _local30){
_local10 = _local10.prev;
_local28 = _local29.prev.index;
} else {
if (((_local29.next.x * _local24) + (_local29.next.y * _local25)) < _local30){
_local10 = _local10.next;
_local28 = _local29.next.index;
};
};
var _local31:Number = (((_local23.x * _local24) + (_local23.y * _local25)) + (((_local9.x - _local23.x) * _local24) + ((_local9.y - _local23.y) * _local25)));
if (_local23.regularShape){
_local32 = ((_local23.y * _local24) - (_local23.x * _local25));
} else {
_local42 = _local23.offsets[_local9.index];
_local32 = ((((_local23.y + (_local23.r21 * _local42.x)) + (_local23.r22 * _local42.y)) * _local24) - (((_local23.x + (_local23.r11 * _local42.x)) + (_local23.r12 * _local42.y)) * _local25));
};
var _local33:Number = (_local9.edge.mag / 2);
_local38 = ((((_local10.x * _local25) - (_local10.y * _local24)) + _local32) - _local33);
_local39 = ((((_local10.next.x * _local25) - (_local10.next.y * _local24)) + _local32) - _local33);
if ((_local38 * _local39) < 0){
_local40 = (_local38 / (_local38 - _local39));
if (_local38 < 0){
_local34 = _local10.x;
_local36 = _local10.y;
_local35 = (_local34 + (_local40 * (_local10.next.x - _local34)));
_local37 = (_local36 + (_local40 * (_local10.next.y - _local36)));
} else {
_local34 = _local10.next.x;
_local36 = _local10.next.y;
_local35 = (_local10.x + (_local40 * (_local34 - _local10.x)));
_local37 = (_local10.y + (_local40 * (_local36 - _local10.y)));
};
} else {
if (_local38 > 0){
_arg1.pointCount = 0;
return;
};
if (_local38 < _local39){
_local34 = _local10.x;
_local36 = _local10.y;
_local35 = _local10.next.x;
_local37 = _local10.next.y;
} else {
_local35 = _local10.x;
_local37 = _local10.y;
_local34 = _local10.next.x;
_local36 = _local10.next.y;
};
};
_local38 = ((((_local36 * _local24) - _local32) - _local33) - (_local34 * _local25));
_local39 = ((((_local37 * _local24) - _local32) - _local33) - (_local35 * _local25));
if ((_local38 * _local39) < 0){
_local40 = (_local38 / (_local38 - _local39));
_local34 = (_local34 + (_local40 * (_local35 - _local34)));
_local36 = (_local36 + (_local40 * (_local37 - _local36)));
} else {
if (_local38 > 0){
_arg1.pointCount = 0;
return;
};
};
_local12 = (((_local24 * _local34) + (_local25 * _local36)) - _local31);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local13){
_arg1.nx = -(_local24);
_arg1.ny = -(_local25);
} else {
_arg1.nx = _local24;
_arg1.ny = _local25;
};
_local41 = _arg1.c0;
_local41.sep = _local12;
_local41.x = _local34;
_local41.y = _local36;
_local41.id.flip = _local13;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
_local12 = (((_local24 * _local35) + (_local25 * _local37)) - _local31);
if (_local12 <= 0){
_arg1.pointCount = 2;
_local41 = _arg1.c1;
_local41.sep = _local12;
_local41.x = _local35;
_local41.y = _local37;
_local41.id.flip = _local13;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
};
} else {
_local12 = (((_local24 * _local35) + (_local25 * _local37)) - _local31);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local13){
_arg1.nx = -(_local24);
_arg1.ny = -(_local25);
} else {
_arg1.nx = _local24;
_arg1.ny = _local25;
};
_local41 = _arg1.c0;
_local41.sep = _local12;
_local41.x = _local35;
_local41.y = _local37;
_local41.id.flip = _local13;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 54
//CollideBoxLineSingleSided (de.polygonal.motor2.collision.pairwise.CollideBoxLineSingleSided)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideBoxLineSingleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:Number;
var _local16:Number;
var _local28:int;
var _local32:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:ContactPoint;
var _local42:V2;
var _local5:V2 = _arg3.worldNormalChain;
if ((((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d) < 0){
_arg4.disabled = true;
_arg1.pointCount = 0;
return;
};
var _local12:Number = -2147483648;
var _local13:int;
_local8 = _arg3.worldVertexChain;
_local7 = _arg3.worldNormalChain;
_local6 = _arg2.worldVertexChain;
var _local14:V2 = _local6;
var _local15:Number = ((_local6.x * _local7.x) + (_local6.y * _local7.y));
_local6 = _local6.next;
_local16 = ((_local6.x * _local7.x) + (_local6.y * _local7.y));
if (_local16 < _local15){
_local15 = _local16;
_local14 = _local6;
};
_local6 = _local6.next;
_local16 = ((_local6.x * _local7.x) + (_local6.y * _local7.y));
if (_local16 < _local15){
_local15 = _local16;
_local14 = _local6;
};
_local6 = _local6.next;
_local16 = ((_local6.x * _local7.x) + (_local6.y * _local7.y));
if (_local16 < _local15){
_local15 = _local16;
_local14 = _local6;
};
_local6 = _local14;
_local11 = ((_local7.x * (_local6.x - _local8.x)) + (_local7.y * (_local6.y - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local6;
_local13 = 1;
};
_local8 = _local8.next;
_local7 = _local7.next;
_local6 = _local6.next.next;
_local11 = ((_local7.x * (_local6.x - _local8.x)) + (_local7.y * (_local6.y - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local6;
_local13 = 1;
};
var _local17:V2 = _arg3.worldVertexChain;
var _local18:V2 = _local17.next;
var _local19:Number = _local17.x;
var _local20:Number = _local18.x;
var _local21:Number = _local17.y;
var _local22:Number = _local18.y;
_local8 = _arg2.worldVertexChain.next;
_local7 = _arg2.worldNormalChain.next;
if (((_local19 * _local7.x) + (_local21 * _local7.y)) < ((_local20 * _local7.x) + (_local22 * _local7.y))){
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
} else {
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
};
_local8 = _arg2.worldVertexChain;
_local7 = _arg2.worldNormalChain;
if (((_local19 * _local7.x) + (_local21 * _local7.y)) < ((_local20 * _local7.x) + (_local22 * _local7.y))){
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
} else {
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
var _local23:ShapeSkeleton = _arg2;
var _local24:Number = _local5.x;
var _local25:Number = _local5.y;
var _local26:int = _local9.index;
var _local27:int = _local10.index;
var _local29:V2 = _local10.edge.n;
var _local30:Number = ((_local29.x * _local24) + (_local29.y * _local25));
if (((_local29.prev.x * _local24) + (_local29.prev.y * _local25)) < _local30){
_local10 = _local10.prev;
_local28 = _local29.prev.index;
} else {
if (((_local29.next.x * _local24) + (_local29.next.y * _local25)) < _local30){
_local10 = _local10.next;
_local28 = _local29.next.index;
};
};
var _local31:Number = (((_local23.x * _local24) + (_local23.y * _local25)) + (((_local9.x - _local23.x) * _local24) + ((_local9.y - _local23.y) * _local25)));
if (_local23.regularShape){
_local32 = ((_local23.y * _local24) - (_local23.x * _local25));
} else {
_local42 = _local23.offsets[_local9.index];
_local32 = ((((_local23.y + (_local23.r21 * _local42.x)) + (_local23.r22 * _local42.y)) * _local24) - (((_local23.x + (_local23.r11 * _local42.x)) + (_local23.r12 * _local42.y)) * _local25));
};
var _local33:Number = (_local9.edge.mag / 2);
_local38 = ((((_local10.x * _local25) - (_local10.y * _local24)) + _local32) - _local33);
_local39 = ((((_local10.next.x * _local25) - (_local10.next.y * _local24)) + _local32) - _local33);
if ((_local38 * _local39) < 0){
_local40 = (_local38 / (_local38 - _local39));
if (_local38 < 0){
_local34 = _local10.x;
_local36 = _local10.y;
_local35 = (_local34 + (_local40 * (_local10.next.x - _local34)));
_local37 = (_local36 + (_local40 * (_local10.next.y - _local36)));
} else {
_local34 = _local10.next.x;
_local36 = _local10.next.y;
_local35 = (_local10.x + (_local40 * (_local34 - _local10.x)));
_local37 = (_local10.y + (_local40 * (_local36 - _local10.y)));
};
} else {
if (_local38 > 0){
_arg1.pointCount = 0;
return;
};
if (_local38 < _local39){
_local34 = _local10.x;
_local36 = _local10.y;
_local35 = _local10.next.x;
_local37 = _local10.next.y;
} else {
_local35 = _local10.x;
_local37 = _local10.y;
_local34 = _local10.next.x;
_local36 = _local10.next.y;
};
};
_local38 = ((((_local36 * _local24) - _local32) - _local33) - (_local34 * _local25));
_local39 = ((((_local37 * _local24) - _local32) - _local33) - (_local35 * _local25));
if ((_local38 * _local39) < 0){
_local40 = (_local38 / (_local38 - _local39));
_local34 = (_local34 + (_local40 * (_local35 - _local34)));
_local36 = (_local36 + (_local40 * (_local37 - _local36)));
} else {
if (_local38 > 0){
_arg1.pointCount = 0;
return;
};
};
_local12 = (((_local24 * _local34) + (_local25 * _local36)) - _local31);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local13){
_arg1.nx = -(_local24);
_arg1.ny = -(_local25);
} else {
_arg1.nx = _local24;
_arg1.ny = _local25;
};
_local41 = _arg1.c0;
_local41.sep = _local12;
_local41.x = _local34;
_local41.y = _local36;
_local41.id.flip = _local13;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
_local12 = (((_local24 * _local35) + (_local25 * _local37)) - _local31);
if (_local12 <= 0){
_arg1.pointCount = 2;
_local41 = _arg1.c1;
_local41.sep = _local12;
_local41.x = _local35;
_local41.y = _local37;
_local41.id.flip = _local13;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
};
} else {
_local12 = (((_local24 * _local35) + (_local25 * _local37)) - _local31);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local13){
_arg1.nx = -(_local24);
_arg1.ny = -(_local25);
} else {
_arg1.nx = _local24;
_arg1.ny = _local25;
};
_local41 = _arg1.c0;
_local41.sep = _local12;
_local41.x = _local35;
_local41.y = _local37;
_local41.id.flip = _local13;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 55
//CollideBoxPlaneDoubleSided (de.polygonal.motor2.collision.pairwise.CollideBoxPlaneDoubleSided)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideBoxPlaneDoubleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local15:Number;
var _local18:int;
var _local19:int;
var _local5:Number = _arg3.worldNormalChain.x;
var _local6:Number = _arg3.worldNormalChain.y;
var _local7:Number = ((_local5 * _arg2.r11) + (_local6 * _arg2.r21));
var _local8:Number = ((_local5 * _arg2.r12) + (_local6 * _arg2.r22));
var _local9:Number = ((_arg2.ex * ((_local7 < 0)) ? -(_local7) : _local7) + (_arg2.ey * ((_local8 < 0)) ? -(_local8) : _local8));
var _local10:Number = _arg3.d;
var _local11:Number = (((_local5 * _arg2.x) + (_local6 * _arg2.y)) - _local10);
if (_local11 > 0){
if (_local11 > _local9){
_arg1.pointCount = 0;
return;
};
} else {
if (_local11 < -(_local9)){
_arg1.pointCount = 0;
return;
};
_local5 = -(_local5);
_local6 = -(_local6);
_local10 = -(_local10);
};
var _local12:V2 = _arg2.worldVertexChain;
var _local13:V2 = _local12;
var _local14:Number = ((_local12.x * _local5) + (_local12.y * _local6));
_local12 = _local12.next;
_local15 = ((_local12.x * _local5) + (_local12.y * _local6));
if (_local15 < _local14){
_local14 = _local15;
_local13 = _local12;
};
_local12 = _local12.next;
_local15 = ((_local12.x * _local5) + (_local12.y * _local6));
if (_local15 < _local14){
_local14 = _local15;
_local13 = _local12;
};
_local12 = _local12.next;
_local15 = ((_local12.x * _local5) + (_local12.y * _local6));
if (_local15 < _local14){
_local14 = _local15;
_local13 = _local12;
};
_local12 = _local13;
_arg1.nx = -(_local5);
_arg1.ny = -(_local6);
_arg1.pointCount = 1;
var _local16:ContactPoint = _arg1.c0;
_local16.sep = (((_local12.x * _local5) + (_local12.y * _local6)) - _local10);
_local16.x = _local12.x;
_local16.y = _local12.y;
var _local17:V2 = _local12.edge.n;
var _local20:Number = ((_local17.x * _local5) + (_local17.y * _local6));
if (((_local17.prev.x * _local5) + (_local17.prev.y * _local6)) < _local20){
_local18 = _local17.prev.index;
_local16.id.flip = 0;
_local16.id.incEdge = _local18;
_local16.id.incVert = _local19;
_local16.id.refFace = 0;
_local16.id.bake();
_local12 = _local12.prev;
_local11 = (((_local12.x * _local5) + (_local12.y * _local6)) - _local10);
if (_local11 < 0){
_local16 = _arg1.c1;
_local16.sep = _local11;
_local16.x = _local12.x;
_local16.y = _local12.y;
_local16.id.flip = 0;
_local16.id.incEdge = _local18;
_local16.id.incVert = _local19;
_local16.id.refFace = 0;
_local16.id.bake();
_arg1.pointCount++;
};
} else {
_local18 = _local17.next.index;
_local16.id.flip = 0;
_local16.id.incEdge = _local18;
_local16.id.incVert = _local19;
_local16.id.refFace = 0;
_local16.id.bake();
_local12 = _local12.next;
_local11 = (((_local12.x * _local5) + (_local12.y * _local6)) - _local10);
if (_local11 < 0){
_local16 = _arg1.c1;
_local16.sep = _local11;
_local16.x = _local12.x;
_local16.y = _local12.y;
_local16.id.flip = 0;
_local16.id.incEdge = _local18;
_local16.id.incVert = _local19;
_local16.id.refFace = 0;
_local16.id.bake();
_arg1.pointCount++;
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 56
//CollideBoxPlaneSingleSided (de.polygonal.motor2.collision.pairwise.CollideBoxPlaneSingleSided)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideBoxPlaneSingleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:Number;
var _local7:V2;
var _local8:V2;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:ContactPoint;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local5:Number = _arg3.worldNormalChain.x;
_local6 = _arg3.worldNormalChain.y;
if (_arg1.pointCount > 0){
_local8 = _arg2.worldVertexChain;
_local7 = _local8;
_local9 = ((_local7.x * _local5) + (_local7.y * _local6));
_local7 = _local7.next;
_local10 = ((_local7.x * _local5) + (_local7.y * _local6));
if (_local10 < _local9){
_local9 = _local10;
_local8 = _local7;
};
_local7 = _local7.next;
_local10 = ((_local7.x * _local5) + (_local7.y * _local6));
if (_local10 < _local9){
_local9 = _local10;
_local8 = _local7;
};
_local7 = _local7.next;
_local10 = ((_local7.x * _local5) + (_local7.y * _local6));
if (_local10 < _local9){
_local9 = _local10;
_local8 = _local7;
};
_local7 = _local8;
_local11 = _arg3.d;
_local12 = (((_local7.x * _local5) + (_local7.y * _local6)) - _local11);
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
_arg1.pointCount = 1;
_arg1.nx = -(_local5);
_arg1.ny = -(_local6);
_local13 = _arg1.c0;
_local13.sep = _local12;
_local13.x = _local7.x;
_local13.y = _local7.y;
_local13.id.key = 0;
_local12 = (((_local7.prev.x * _local5) + (_local7.prev.y * _local6)) - _local11);
if (_local12 < 0){
_local13.id.key = 1;
_local13 = _arg1.c1;
_local13.sep = _local12;
_local13.x = _local7.prev.x;
_local13.y = _local7.prev.y;
_local13.id.key = 1;
_arg1.pointCount++;
} else {
_local12 = (((_local7.next.x * _local5) + (_local7.next.y * _local6)) - _local11);
if (_local12 < 0){
_local13.id.key = 1;
_local13 = _arg1.c1;
_local13.sep = _local12;
_local13.x = _local7.next.x;
_local13.y = _local7.next.y;
_local13.id.key = 1;
_arg1.pointCount++;
};
};
} else {
_local14 = ((_local5 * _arg2.r11) + (_local6 * _arg2.r21));
_local15 = ((_local5 * _arg2.r12) + (_local6 * _arg2.r22));
_local16 = ((_arg2.ex * ((_local14 < 0)) ? -(_local14) : _local14) + (_arg2.ey * ((_local15 < 0)) ? -(_local15) : _local15));
if ((((_local5 * _arg2.x) + (_local6 * _arg2.y)) - _arg3.d) > _local16){
_arg1.pointCount = 0;
return;
};
_local11 = _arg3.d;
_local8 = _arg2.worldVertexChain;
_local7 = _local8;
_local9 = ((_local7.x * _local5) + (_local7.y * _local6));
_local7 = _local7.next;
_local10 = ((_local7.x * _local5) + (_local7.y * _local6));
if (_local10 < _local9){
_local9 = _local10;
_local8 = _local7;
};
_local7 = _local7.next;
_local10 = ((_local7.x * _local5) + (_local7.y * _local6));
if (_local10 < _local9){
_local9 = _local10;
_local8 = _local7;
};
_local7 = _local7.next;
_local10 = ((_local7.x * _local5) + (_local7.y * _local6));
if (_local10 < _local9){
_local9 = _local10;
_local8 = _local7;
};
_local7 = _local8;
_local12 = (((_local7.x * _local5) + (_local7.y * _local6)) - _local11);
_arg1.pointCount = 1;
_arg1.nx = -(_local5);
_arg1.ny = -(_local6);
_local13 = _arg1.c0;
_local13.sep = _local12;
_local13.x = _local7.x;
_local13.y = _local7.y;
_local13.id.key = 0;
_local12 = (((_local7.prev.x * _local5) + (_local7.prev.y * _local6)) - _local11);
if (_local12 < 0){
_local13.id.key = 1;
_local13 = _arg1.c1;
_local13.sep = _local12;
_local13.x = _local7.prev.x;
_local13.y = _local7.prev.y;
_local13.id.key = 1;
_arg1.pointCount++;
} else {
_local12 = (((_local7.next.x * _local5) + (_local7.next.y * _local6)) - _local11);
if (_local12 < 0){
_local13.id.key = 1;
_local13 = _arg1.c1;
_local13.sep = _local12;
_local13.x = _local7.next.x;
_local13.y = _local7.next.y;
_local13.id.key = 1;
_arg1.pointCount++;
};
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 57
//CollideCircle (de.polygonal.motor2.collision.pairwise.CollideCircle)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideCircle implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
_local5 = (_arg3.x - _arg2.x);
_local6 = (_arg3.y - _arg2.y);
_local7 = ((_local5 * _local5) + (_local6 * _local6));
_local8 = (_arg2.radius + _arg3.radius);
if (_local7 > (_local8 * _local8)){
_arg1.pointCount = 0;
return;
};
if (_local7 < 1E-8){
_arg1.c0.sep = -(_local8);
_arg1.nx = 0;
_arg1.ny = 1;
_arg1.c0.x = _arg3.x;
_arg1.c0.y = (_arg3.y - _arg3.radius);
} else {
_local9 = Math.sqrt(_local7);
_arg1.c0.sep = (_local9 - _local8);
_arg1.c0.x = (_arg3.x - (_arg3.radius * (_arg1.nx = ((1 / _local9) * _local5))));
_arg1.c0.y = (_arg3.y - (_arg3.radius * (_arg1.ny = ((1 / _local9) * _local6))));
};
_arg1.pointCount = 1;
_arg1.c0.id.key = 0;
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 58
//CollideCircleLineDoubleSided (de.polygonal.motor2.collision.pairwise.CollideCircleLineDoubleSided)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideCircleLineDoubleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ContactPoint;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local6:V2 = _arg3.worldVertexChain;
var _local7:V2 = _local6.next;
var _local8:Number = _arg2.radiusSq;
var _local9:Number = _local6.x;
var _local10:Number = _local7.x;
var _local11:Number = _arg2.x;
var _local12:Number = _local6.y;
var _local13:Number = _local7.y;
var _local14:Number = _arg2.y;
var _local15:Number = (_local10 - _local9);
var _local16:Number = (_local13 - _local12);
var _local17:Number = (_local11 - _local9);
var _local18:Number = (_local14 - _local12);
var _local23:Number = ((_local17 * _local15) + (_local18 * _local16));
if (_local23 < 0){
_local19 = ((_local17 * _local17) + (_local18 * _local18));
if (_local19 > _local8){
_arg1.pointCount = 0;
return;
};
_local20 = Math.sqrt(_local19);
_local21 = (_local17 / _local20);
_local22 = (_local18 / _local20);
_local5 = _arg1.c0;
_local5.id.incEdge = _local6.index;
_local5.id.incVert = _local6.index;
} else {
_local25 = (_local10 - _local11);
_local26 = (_local13 - _local14);
_local23 = ((_local25 * _local15) + (_local26 * _local16));
if (_local23 < 0){
_local19 = ((_local25 * _local25) + (_local26 * _local26));
if (_local19 > _local8){
_arg1.pointCount = 0;
return;
};
_local20 = Math.sqrt(_local19);
_local21 = (-(_local25) / _local20);
_local22 = (-(_local26) / _local20);
_local5 = _arg1.c0;
_local5.id.incEdge = _local7.index;
_local5.id.incVert = _local7.index;
} else {
_local27 = ((_local18 * _local15) - (_local17 * _local16));
_local19 = ((((_local18 * _local15) - (_local17 * _local16)) * _local27) / ((_local15 * _local15) + (_local16 * _local16)));
if (_local19 > _local8){
_arg1.pointCount = 0;
return;
};
_local20 = Math.sqrt(_local19);
_local21 = (-(_local13) + _local12);
_local22 = (_local10 - _local9);
_local28 = (Math.sqrt(((_local21 * _local21) + (_local22 * _local22))) * ((((_local21 * _local17) + (_local22 * _local18)) < 0)) ? -1 : 1);
_local21 = (_local21 / _local28);
_local22 = (_local22 / _local28);
_local5 = _arg1.c0;
_local5.id.incEdge = _local6.index;
_local5.id.incVert = _local7.index;
};
};
_arg1.pointCount = 1;
_arg1.nx = -(_local21);
_arg1.ny = -(_local22);
_local5.id.refFace = ContactID.NULL_FEATURE;
_local5.id.flip = 0;
_local5.id.bake();
var _local24:Number = _arg2.radius;
_local5.x = (_local11 - (_local24 * _local21));
_local5.y = (_local14 - (_local24 * _local22));
_local5.sep = (_local20 - _local24);
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 59
//CollideCircleLineSingleSided (de.polygonal.motor2.collision.pairwise.CollideCircleLineSingleSided)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideCircleLineSingleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ContactPoint;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local6:V2 = _arg3.worldNormalChain;
if ((((_arg2.x * _local6.x) + (_arg2.y * _local6.y)) - _arg3.d) < 0){
_arg4.disabled = true;
_arg1.pointCount = 0;
return;
};
var _local7:V2 = _arg3.worldVertexChain;
var _local8:V2 = _local7.next;
var _local9:Number = _arg2.radiusSq;
var _local10:Number = _local7.x;
var _local11:Number = _local8.x;
var _local12:Number = _arg2.x;
var _local13:Number = _local7.y;
var _local14:Number = _local8.y;
var _local15:Number = _arg2.y;
var _local16:Number = (_local11 - _local10);
var _local17:Number = (_local14 - _local13);
var _local18:Number = (_local12 - _local10);
var _local19:Number = (_local15 - _local13);
var _local24:Number = ((_local18 * _local16) + (_local19 * _local17));
if (_local24 < 0){
_local22 = _arg3.worldNormalChain.x;
_local23 = _arg3.worldNormalChain.y;
if (((_local22 * _local18) + (_local23 * _local19)) < 0){
_arg1.pointCount = 0;
return;
};
_local20 = ((_local18 * _local18) + (_local19 * _local19));
if (_local20 > _local9){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
_local21 = Math.sqrt(_local20);
_local22 = (_local18 / _local21);
_local23 = (_local19 / _local21);
_local5 = _arg1.c0;
_local5.id.incEdge = _local7.index;
_local5.id.incVert = _local7.index;
} else {
_local26 = (_local11 - _local12);
_local27 = (_local14 - _local15);
_local24 = ((_local26 * _local16) + (_local27 * _local17));
_local22 = _arg3.worldNormalChain.x;
_local23 = _arg3.worldNormalChain.y;
if (((_local22 * _local26) + (_local23 * _local27)) > 0){
_arg1.pointCount = 0;
return;
};
if (_local24 < 0){
_local20 = ((_local26 * _local26) + (_local27 * _local27));
if (_local20 > _local9){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
_local21 = Math.sqrt(_local20);
_local22 = (-(_local26) / _local21);
_local23 = (-(_local27) / _local21);
_local5 = _arg1.c0;
_local5.id.incEdge = _local8.index;
_local5.id.incVert = _local8.index;
} else {
_local28 = ((_local19 * _local16) - (_local18 * _local17));
if (_local28 > 0){
_arg1.pointCount = 0;
return;
};
_local20 = ((_local28 * _local28) / ((_local16 * _local16) + (_local17 * _local17)));
if (_local20 > _local9){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
_local21 = Math.sqrt(_local20);
_local22 = (-(_local14) + _local13);
_local23 = (_local11 - _local10);
_local29 = (Math.sqrt(((_local22 * _local22) + (_local23 * _local23))) * ((((_local22 * _local18) + (_local23 * _local19)) < 0)) ? -1 : 1);
_local22 = (_local22 / _local29);
_local23 = (_local23 / _local29);
_local5 = _arg1.c0;
_local5.id.incEdge = _local7.index;
_local5.id.incVert = _local8.index;
};
};
_arg1.pointCount = 1;
_arg1.nx = -(_local22);
_arg1.ny = -(_local23);
_local5.id.refFace = ContactID.NULL_FEATURE;
_local5.id.flip = 0;
_local5.id.bake();
var _local25:Number = _arg2.radius;
_local5.x = (_local12 - (_local25 * _local22));
_local5.y = (_local15 - (_local25 * _local23));
_local5.sep = (_local21 - _local25);
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 60
//CollideCirclePlaneDoubleSided (de.polygonal.motor2.collision.pairwise.CollideCirclePlaneDoubleSided)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideCirclePlaneDoubleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ContactPoint;
var _local7:Number;
var _local6:V2 = _arg3.worldNormalChain;
_local7 = _arg2.radius;
var _local8:Number = (((_arg2.x * _local6.x) + (_arg2.y * _local6.y)) - _arg3.d);
if (_local8 > 0){
if (_local8 <= _local7){
_arg1.pointCount = 1;
_arg1.nx = -(_local6.x);
_arg1.ny = -(_local6.y);
_local5 = _arg1.c0;
_local5.id.key = 0;
_local5.sep = (_local8 - _local7);
_local5.x = (_arg2.x - (_local7 * _local6.x));
_local5.y = (_arg2.y - (_local7 * _local6.y));
return;
};
} else {
if (-(_local8) <= _local7){
_arg1.pointCount = 1;
_arg1.nx = _local6.x;
_arg1.ny = _local6.y;
_local5 = _arg1.c0;
_local5.id.key = 1;
_local5.sep = (-(_local7) - _local8);
_local5.x = (_arg2.x + (_local7 * _local6.x));
_local5.y = (_arg2.y + (_local7 * _local6.y));
return;
};
};
_arg1.pointCount = 0;
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 61
//CollideCirclePlaneSingleSided (de.polygonal.motor2.collision.pairwise.CollideCirclePlaneSingleSided)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideCirclePlaneSingleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local7:Number;
var _local8:ContactPoint;
var _local5:V2 = _arg3.worldNormalChain;
var _local6:Number = _arg2.radius;
_local7 = (((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d);
if (_local7 <= _local6){
_arg1.pointCount = 1;
_arg1.nx = -(_local5.x);
_arg1.ny = -(_local5.y);
_local8 = _arg1.c0;
_local8.x = (_arg2.x - (_local6 * _local5.x));
_local8.y = (_arg2.y - (_local6 * _local5.y));
_local8.sep = (_local7 - _local6);
return;
};
_arg1.pointCount = 0;
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 62
//CollidePolyBSP (de.polygonal.motor2.collision.pairwise.CollidePolyBSP)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollidePolyBSP implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local13:Number;
var _local14:int;
var _local15:ConvexBSPNode;
var _local21:int;
var _local25:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:ContactPoint;
var _local35:V2;
var _local5:PolyContact = PolyContact(_arg4);
var _local12:Number = -2147483648;
_local6 = _local5.p;
_local7 = _local5.d;
if (_local5.firstOut){
while (true) {
_local15 = _arg3.BSPNode;
while (_local15.R) {
_local15 = ((((_local15.N.x * _local7.y) - (_local15.N.y * _local7.x)))<=0) ? _local15.R : _local15.L;
};
_local8 = _local15.V;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
_local6 = _arg3.worldVertexChain;
_local7 = _arg3.worldNormalChain;
while (true) {
_local15 = _arg2.BSPNode;
while (_local15.R) {
_local15 = ((((_local15.N.x * _local7.y) - (_local15.N.y * _local7.x)))<=0) ? _local15.R : _local15.L;
};
_local8 = _local15.V;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = false;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
} else {
while (true) {
_local15 = _arg2.BSPNode;
while (_local15.R) {
_local15 = ((((_local15.N.x * _local7.y) - (_local15.N.y * _local7.x)))<=0) ? _local15.R : _local15.L;
};
_local8 = _local15.V;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
_local6 = _arg2.worldVertexChain;
_local7 = _arg2.worldNormalChain;
while (true) {
_local15 = _arg3.BSPNode;
while (_local15.R) {
_local15 = ((((_local15.N.x * _local7.y) - (_local15.N.y * _local7.x)))<=0) ? _local15.R : _local15.L;
};
_local8 = _local15.V;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = true;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 0;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
};
var _local16:ShapeSkeleton = (_local14) ? _arg3 : _arg2;
var _local17:Number = _local9.x;
var _local18:Number = _local9.y;
var _local19:int = _local11.index;
var _local20:int = _local10.index;
var _local22:V2 = _local10.edge.n;
var _local23:Number = ((_local22.x * _local17) + (_local22.y * _local18));
if (((_local22.prev.x * _local17) + (_local22.prev.y * _local18)) < _local23){
_local10 = _local10.prev;
_local21 = _local22.prev.index;
} else {
if (((_local22.next.x * _local17) + (_local22.next.y * _local18)) < _local23){
_local10 = _local10.next;
_local21 = _local22.next.index;
};
};
var _local24:Number = (((_local16.x * _local17) + (_local16.y * _local18)) + (((_local11.x - _local16.x) * _local17) + ((_local11.y - _local16.y) * _local18)));
if (_local16.regularShape){
_local25 = ((_local16.y * _local17) - (_local16.x * _local18));
} else {
_local35 = _local16.offsets[_local11.index];
_local25 = ((((_local16.y + (_local16.r21 * _local35.x)) + (_local16.r22 * _local35.y)) * _local17) - (((_local16.x + (_local16.r11 * _local35.x)) + (_local16.r12 * _local35.y)) * _local18));
};
var _local26:Number = (_local11.edge.mag / 2);
_local31 = ((((_local10.x * _local18) - (_local10.y * _local17)) + _local25) - _local26);
_local32 = ((((_local10.next.x * _local18) - (_local10.next.y * _local17)) + _local25) - _local26);
if ((_local31 * _local32) < 0){
_local33 = (_local31 / (_local31 - _local32));
if (_local31 < 0){
_local27 = _local10.x;
_local29 = _local10.y;
_local28 = (_local27 + (_local33 * (_local10.next.x - _local27)));
_local30 = (_local29 + (_local33 * (_local10.next.y - _local29)));
} else {
_local27 = _local10.next.x;
_local29 = _local10.next.y;
_local28 = (_local10.x + (_local33 * (_local27 - _local10.x)));
_local30 = (_local10.y + (_local33 * (_local29 - _local10.y)));
};
} else {
if (_local31 > 0){
_arg1.pointCount = 0;
return;
};
if (_local31 < _local32){
_local27 = _local10.x;
_local29 = _local10.y;
_local28 = _local10.next.x;
_local30 = _local10.next.y;
} else {
_local28 = _local10.x;
_local30 = _local10.y;
_local27 = _local10.next.x;
_local29 = _local10.next.y;
};
};
_local31 = ((((_local29 * _local17) - _local25) - _local26) - (_local27 * _local18));
_local32 = ((((_local30 * _local17) - _local25) - _local26) - (_local28 * _local18));
if ((_local31 * _local32) < 0){
_local33 = (_local31 / (_local31 - _local32));
_local27 = (_local27 + (_local33 * (_local28 - _local27)));
_local29 = (_local29 + (_local33 * (_local30 - _local29)));
} else {
if (_local31 > 0){
_arg1.pointCount = 0;
return;
};
};
_local12 = (((_local17 * _local27) + (_local18 * _local29)) - _local24);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local17);
_arg1.ny = -(_local18);
} else {
_arg1.nx = _local17;
_arg1.ny = _local18;
};
_local34 = _arg1.c0;
_local34.sep = _local12;
_local34.x = _local27;
_local34.y = _local29;
_local34.id.flip = _local14;
_local34.id.incEdge = _local21;
_local34.id.incVert = _local20;
_local34.id.refFace = _local19;
_local34.id.bake();
_local12 = (((_local17 * _local28) + (_local18 * _local30)) - _local24);
if (_local12 <= 0){
_arg1.pointCount = 2;
_local34 = _arg1.c1;
_local34.sep = _local12;
_local34.x = _local28;
_local34.y = _local30;
_local34.id.flip = _local14;
_local34.id.incEdge = _local21;
_local34.id.incVert = _local20;
_local34.id.refFace = _local19;
_local34.id.bake();
};
} else {
_local12 = (((_local17 * _local28) + (_local18 * _local30)) - _local24);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local17);
_arg1.ny = -(_local18);
} else {
_arg1.nx = _local17;
_arg1.ny = _local18;
};
_local34 = _arg1.c0;
_local34.sep = _local12;
_local34.x = _local28;
_local34.y = _local30;
_local34.id.flip = _local14;
_local34.id.incEdge = _local21;
_local34.id.incVert = _local20;
_local34.id.refFace = _local19;
_local34.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 63
//CollidePolyCHC (de.polygonal.motor2.collision.pairwise.CollidePolyCHC)
package de.polygonal.motor2.collision.pairwise {
import flash.utils.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollidePolyCHC implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local13:Number;
var _local14:int;
var _local16:Number;
var _local17:Number;
var _local23:int;
var _local27:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:ContactPoint;
var _local37:V2;
var _local5:PolyContact = PolyContact(_arg4);
var _local12:Number = -2147483648;
var _local15:Dictionary = _local5.hc;
_local6 = _local5.p;
_local7 = _local5.d;
if (_local5.firstOut){
while (true) {
_local8 = ((_local15[_local7]) || (_arg3.worldVertexChain));
_local17 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
while (true) {
_local16 = ((_local8.prev.x * _local7.x) + (_local8.prev.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.prev;
_local17 = _local16;
} else {
_local16 = ((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.next;
_local17 = _local16;
} else {
break;
};
};
};
_local15[_local7] = _local8;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
_local6 = _arg3.worldVertexChain;
_local7 = _arg3.worldNormalChain;
while (true) {
_local8 = ((_local15[_local7]) || (_arg2.worldVertexChain));
_local17 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
while (true) {
_local16 = ((_local8.prev.x * _local7.x) + (_local8.prev.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.prev;
_local17 = _local16;
} else {
_local16 = ((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.next;
_local17 = _local16;
} else {
break;
};
};
};
_local15[_local7] = _local8;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = false;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
} else {
while (true) {
_local8 = ((_local15[_local7]) || (_arg2.worldVertexChain));
_local17 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
while (true) {
_local16 = ((_local8.prev.x * _local7.x) + (_local8.prev.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.prev;
_local17 = _local16;
} else {
_local16 = ((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.next;
_local17 = _local16;
} else {
break;
};
};
};
_local15[_local7] = _local8;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
_local6 = _arg2.worldVertexChain;
_local7 = _arg2.worldNormalChain;
while (true) {
_local8 = ((_local15[_local7]) || (_arg3.worldVertexChain));
_local17 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
while (true) {
_local16 = ((_local8.prev.x * _local7.x) + (_local8.prev.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.prev;
_local17 = _local16;
} else {
_local16 = ((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.next;
_local17 = _local16;
} else {
break;
};
};
};
_local15[_local7] = _local8;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = true;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 0;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
};
var _local18:ShapeSkeleton = (_local14) ? _arg3 : _arg2;
var _local19:Number = _local9.x;
var _local20:Number = _local9.y;
var _local21:int = _local11.index;
var _local22:int = _local10.index;
var _local24:V2 = _local10.edge.n;
var _local25:Number = ((_local24.x * _local19) + (_local24.y * _local20));
if (((_local24.prev.x * _local19) + (_local24.prev.y * _local20)) < _local25){
_local10 = _local10.prev;
_local23 = _local24.prev.index;
} else {
if (((_local24.next.x * _local19) + (_local24.next.y * _local20)) < _local25){
_local10 = _local10.next;
_local23 = _local24.next.index;
};
};
var _local26:Number = (((_local18.x * _local19) + (_local18.y * _local20)) + (((_local11.x - _local18.x) * _local19) + ((_local11.y - _local18.y) * _local20)));
if (_local18.regularShape){
_local27 = ((_local18.y * _local19) - (_local18.x * _local20));
} else {
_local37 = _local18.offsets[_local11.index];
_local27 = ((((_local18.y + (_local18.r21 * _local37.x)) + (_local18.r22 * _local37.y)) * _local19) - (((_local18.x + (_local18.r11 * _local37.x)) + (_local18.r12 * _local37.y)) * _local20));
};
var _local28:Number = (_local11.edge.mag / 2);
_local33 = ((((_local10.x * _local20) - (_local10.y * _local19)) + _local27) - _local28);
_local34 = ((((_local10.next.x * _local20) - (_local10.next.y * _local19)) + _local27) - _local28);
if ((_local33 * _local34) < 0){
_local35 = (_local33 / (_local33 - _local34));
if (_local33 < 0){
_local29 = _local10.x;
_local31 = _local10.y;
_local30 = (_local29 + (_local35 * (_local10.next.x - _local29)));
_local32 = (_local31 + (_local35 * (_local10.next.y - _local31)));
} else {
_local29 = _local10.next.x;
_local31 = _local10.next.y;
_local30 = (_local10.x + (_local35 * (_local29 - _local10.x)));
_local32 = (_local10.y + (_local35 * (_local31 - _local10.y)));
};
} else {
if (_local33 > 0){
_arg1.pointCount = 0;
return;
};
if (_local33 < _local34){
_local29 = _local10.x;
_local31 = _local10.y;
_local30 = _local10.next.x;
_local32 = _local10.next.y;
} else {
_local30 = _local10.x;
_local32 = _local10.y;
_local29 = _local10.next.x;
_local31 = _local10.next.y;
};
};
_local33 = ((((_local31 * _local19) - _local27) - _local28) - (_local29 * _local20));
_local34 = ((((_local32 * _local19) - _local27) - _local28) - (_local30 * _local20));
if ((_local33 * _local34) < 0){
_local35 = (_local33 / (_local33 - _local34));
_local29 = (_local29 + (_local35 * (_local30 - _local29)));
_local31 = (_local31 + (_local35 * (_local32 - _local31)));
} else {
if (_local33 > 0){
_arg1.pointCount = 0;
return;
};
};
_local12 = (((_local19 * _local29) + (_local20 * _local31)) - _local26);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local19);
_arg1.ny = -(_local20);
} else {
_arg1.nx = _local19;
_arg1.ny = _local20;
};
_local36 = _arg1.c0;
_local36.sep = _local12;
_local36.x = _local29;
_local36.y = _local31;
_local36.id.flip = _local14;
_local36.id.incEdge = _local23;
_local36.id.incVert = _local22;
_local36.id.refFace = _local21;
_local36.id.bake();
_local12 = (((_local19 * _local30) + (_local20 * _local32)) - _local26);
if (_local12 <= 0){
_arg1.pointCount = 2;
_local36 = _arg1.c1;
_local36.sep = _local12;
_local36.x = _local30;
_local36.y = _local32;
_local36.id.flip = _local14;
_local36.id.incEdge = _local23;
_local36.id.incVert = _local22;
_local36.id.refFace = _local21;
_local36.id.bake();
};
} else {
_local12 = (((_local19 * _local30) + (_local20 * _local32)) - _local26);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local19);
_arg1.ny = -(_local20);
} else {
_arg1.nx = _local19;
_arg1.ny = _local20;
};
_local36 = _arg1.c0;
_local36.sep = _local12;
_local36.x = _local30;
_local36.y = _local32;
_local36.id.flip = _local14;
_local36.id.incEdge = _local23;
_local36.id.incVert = _local22;
_local36.id.refFace = _local21;
_local36.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 64
//CollidePolyCircle (de.polygonal.motor2.collision.pairwise.CollidePolyCircle)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollidePolyCircle implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:V2;
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local11:Number;
var _local12:Number;
var _local17:Number;
var _local19:Number;
var _local21:Number;
var _local22:ContactPoint;
var _local24:Number;
var _local25:Number;
var _local9:Number = _arg3.x;
var _local10:Number = _arg3.y;
_local12 = _arg3.radius;
var _local13:Number = -2147483648;
var _local14:ConvexCircleContact = ConvexCircleContact(_arg4);
_local5 = _local14.p;
_local6 = _local14.d;
var _local15:int = _local5.prev.index;
while (true) {
_local11 = ((_local6.x * (_local9 - _local5.x)) + (_local6.y * (_local10 - _local5.y)));
if (_local11 > _local12){
_arg1.pointCount = 0;
_local14.p = _local5;
_local14.d = _local6;
return;
};
if (_local11 > _local13){
_local13 = _local11;
_local7 = _local6;
_local8 = _local5;
};
if (_local5.index == _local15){
break;
};
_local5 = _local5.next;
_local6 = _local6.next;
};
if (_local13 < 1E-6){
_arg1.pointCount = 1;
_arg1.nx = _local7.x;
_arg1.ny = _local7.y;
_local22 = _arg1.c0;
_local22.id.incEdge = (_local7.index + 1);
_local22.id.incVert = 254;
_local22.id.refFace = 254;
_local22.id.flip = 0;
_local22.id.bake();
_local22.x = (_local9 - (_local12 * _arg1.nx));
_local22.y = (_local10 - (_local12 * _arg1.ny));
_local22.sep = (_local13 - _local12);
return;
};
var _local16:E2 = _local8.edge;
var _local18:Number = ((_arg2.r11 * _local16.d.x) + (_arg2.r12 * _local16.d.y));
var _local20:Number = ((_arg2.r21 * _local16.d.x) + (_arg2.r22 * _local16.d.y));
if (_local16.mag < 1E-6){
_local17 = (_local9 - _local8.x);
_local19 = (_local10 - _local8.y);
_local21 = ((_local17 * _local17) + (_local19 * _local19));
if (_local21 > _arg3.radiusSq){
};
_arg1.pointCount = 0;
return;
};
var _local23:Number = (((_local9 - _local8.x) * _local18) + ((_local10 - _local8.y) * _local20));
_local22 = _arg1.c0;
_local22.id.refFace = 254;
_local22.id.flip = 0;
if (_local23 <= 0){
_local24 = _local8.x;
_local25 = _local8.y;
_local22.id.incVert = (_local8.index + 1);
_local22.id.incEdge = 254;
} else {
if (_local23 >= _local16.mag){
_local24 = _local8.next.x;
_local25 = _local8.next.y;
_local22.id.incVert = (_local8.next.index + 1);
_local22.id.incEdge = 254;
} else {
_local24 = ((_local18 * _local23) + _local8.x);
_local25 = ((_local20 * _local23) + _local8.y);
_local22.id.incVert = 254;
_local22.id.incEdge = (_local8.index + 1);
};
};
_local17 = (_local9 - _local24);
_local19 = (_local10 - _local25);
_local21 = ((_local17 * _local17) + (_local19 * _local19));
if (_local21 > _arg3.radiusSq){
_arg1.pointCount = 0;
return;
};
_local21 = Math.sqrt(_local21);
_local17 = (_local17 / _local21);
_local19 = (_local19 / _local21);
_arg1.pointCount = 1;
_arg1.nx = _local17;
_arg1.ny = _local19;
_local22.x = (_local9 - (_arg3.radius * _local17));
_local22.y = (_local10 - (_arg3.radius * _local19));
_local22.sep = (_local21 - _local12);
_local22.id.bake();
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 65
//CollidePolyLineDoubleSidedBSP (de.polygonal.motor2.collision.pairwise.CollidePolyLineDoubleSidedBSP)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollidePolyLineDoubleSidedBSP implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:V2;
var _local13:Number;
var _local22:ShapeSkeleton;
var _local23:ShapeSkeleton;
var _local28:int;
var _local32:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:ContactPoint;
var _local42:V2;
var _local14:Number = -2147483648;
var _local15:int;
_local10 = _arg3.worldVertexChain;
_local9 = _arg3.worldNormalChain;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local6 = _local5.N;
_local5 = ((((-(_local6.y) * _local9.x) + (_local6.x * _local9.y)))<=0) ? _local5.R : _local5.L;
};
_local7 = _local5.V;
_local13 = ((_local9.x * (_local7.x - _local10.x)) + (_local9.y * (_local7.y - _local10.y)));
if (_local13 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local14){
_local14 = _local13;
_local8 = _local9;
_local11 = _local10;
_local12 = _local7;
_local15 = 1;
};
_local10 = _local10.next;
_local9 = _local9.next;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local6 = _local5.N;
_local5 = ((((-(_local6.y) * _local9.x) + (_local6.x * _local9.y)))<=0) ? _local5.R : _local5.L;
};
_local7 = _local5.V;
_local13 = ((_local9.x * (_local7.x - _local10.x)) + (_local9.y * (_local7.y - _local10.y)));
if (_local13 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local14){
_local14 = _local13;
_local8 = _local9;
_local11 = _local10;
_local12 = _local7;
_local15 = 1;
};
var _local16:V2 = _arg3.worldVertexChain;
var _local17:V2 = _local16.next;
var _local18:Number = _local16.x;
var _local19:Number = _local17.x;
var _local20:Number = _local16.y;
var _local21:Number = _local17.y;
_local10 = _arg2.worldVertexChain;
_local9 = _arg2.worldNormalChain;
while (true) {
if (((_local18 * _local9.x) + (_local20 * _local9.y)) < ((_local19 * _local9.x) + (_local21 * _local9.y))){
_local13 = ((_local9.x * (_local18 - _local10.x)) + (_local9.y * (_local20 - _local10.y)));
if (_local13 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local14){
_local14 = _local13;
_local8 = _local9;
_local11 = _local10;
_local12 = _local16;
_local15 = 0;
};
} else {
_local13 = ((_local9.x * (_local19 - _local10.x)) + (_local9.y * (_local21 - _local10.y)));
if (_local13 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local14){
_local14 = _local13;
_local8 = _local9;
_local11 = _local10;
_local12 = _local17;
_local15 = 0;
};
};
if (_local10.isTail){
break;
};
_local10 = _local10.next;
_local9 = _local9.next;
};
if (_local15){
_local22 = _arg3;
_local23 = _arg2;
} else {
_local22 = _arg2;
_local23 = _arg3;
};
var _local24:Number = _local8.x;
var _local25:Number = _local8.y;
var _local26:int = _local11.index;
var _local27:int = _local12.index;
var _local29:V2 = _local12.edge.n;
var _local30:Number = ((_local29.x * _local24) + (_local29.y * _local25));
if (((_local29.prev.x * _local24) + (_local29.prev.y * _local25)) < _local30){
_local12 = _local12.prev;
_local28 = _local29.prev.index;
} else {
if (((_local29.next.x * _local24) + (_local29.next.y * _local25)) < _local30){
_local12 = _local12.next;
_local28 = _local29.next.index;
};
};
var _local31:Number = (((_local22.x * _local24) + (_local22.y * _local25)) + (((_local11.x - _local22.x) * _local24) + ((_local11.y - _local22.y) * _local25)));
if (_local22.regularShape){
_local32 = ((_local22.y * _local24) - (_local22.x * _local25));
} else {
_local42 = _local22.offsets[_local11.index];
_local32 = ((((_local22.y + (_local22.r21 * _local42.x)) + (_local22.r22 * _local42.y)) * _local24) - (((_local22.x + (_local22.r11 * _local42.x)) + (_local22.r12 * _local42.y)) * _local25));
};
var _local33:Number = (_local11.edge.mag / 2);
_local38 = ((((_local12.x * _local25) - (_local12.y * _local24)) + _local32) - _local33);
_local39 = ((((_local12.next.x * _local25) - (_local12.next.y * _local24)) + _local32) - _local33);
if ((_local38 * _local39) < 0){
_local40 = (_local38 / (_local38 - _local39));
if (_local38 < 0){
_local34 = _local12.x;
_local36 = _local12.y;
_local35 = (_local34 + (_local40 * (_local12.next.x - _local34)));
_local37 = (_local36 + (_local40 * (_local12.next.y - _local36)));
} else {
_local34 = _local12.next.x;
_local36 = _local12.next.y;
_local35 = (_local12.x + (_local40 * (_local34 - _local12.x)));
_local37 = (_local12.y + (_local40 * (_local36 - _local12.y)));
};
} else {
if (_local38 > 0){
_arg1.pointCount = 0;
return;
};
if (_local38 < _local39){
_local34 = _local12.x;
_local36 = _local12.y;
_local35 = _local12.next.x;
_local37 = _local12.next.y;
} else {
_local35 = _local12.x;
_local37 = _local12.y;
_local34 = _local12.next.x;
_local36 = _local12.next.y;
};
};
_local38 = ((((_local36 * _local24) - _local32) - _local33) - (_local34 * _local25));
_local39 = ((((_local37 * _local24) - _local32) - _local33) - (_local35 * _local25));
if ((_local38 * _local39) < 0){
_local40 = (_local38 / (_local38 - _local39));
_local34 = (_local34 + (_local40 * (_local35 - _local34)));
_local36 = (_local36 + (_local40 * (_local37 - _local36)));
} else {
if (_local38 > 0){
_arg1.pointCount = 0;
return;
};
};
_local14 = (((_local24 * _local34) + (_local25 * _local36)) - _local31);
if (_local14 <= 0){
_arg1.pointCount = 1;
if (_local15){
_arg1.nx = -(_local24);
_arg1.ny = -(_local25);
} else {
_arg1.nx = _local24;
_arg1.ny = _local25;
};
_local41 = _arg1.c0;
_local41.sep = _local14;
_local41.x = _local34;
_local41.y = _local36;
_local41.id.flip = _local15;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
_local14 = (((_local24 * _local35) + (_local25 * _local37)) - _local31);
if (_local14 <= 0){
_arg1.pointCount = 2;
_local41 = _arg1.c1;
_local41.sep = _local14;
_local41.x = _local35;
_local41.y = _local37;
_local41.id.flip = _local15;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
};
} else {
_local14 = (((_local24 * _local35) + (_local25 * _local37)) - _local31);
if (_local14 <= 0){
_arg1.pointCount = 1;
if (_local15){
_arg1.nx = -(_local24);
_arg1.ny = -(_local25);
} else {
_arg1.nx = _local24;
_arg1.ny = _local25;
};
_local41 = _arg1.c0;
_local41.sep = _local14;
_local41.x = _local35;
_local41.y = _local37;
_local41.id.flip = _local15;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 66
//CollidePolyLineDoubleSidedCHC (de.polygonal.motor2.collision.pairwise.CollidePolyLineDoubleSidedCHC)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollidePolyLineDoubleSidedCHC implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local14:Number;
var _local15:Number;
var _local23:ShapeSkeleton;
var _local24:ShapeSkeleton;
var _local29:int;
var _local33:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:Number;
var _local42:ContactPoint;
var _local43:V2;
var _local5:PolyLineContact = PolyLineContact(_arg4);
var _local13:Number = -2147483648;
var _local16:int;
_local9 = _arg3.worldVertexChain;
_local8 = _arg3.worldNormalChain;
_local6 = _local5.hint1;
_local15 = ((_local6.x * _local8.x) + (_local6.y * _local8.y));
while (true) {
_local14 = ((_local6.prev.x * _local8.x) + (_local6.prev.y * _local8.y));
if (_local14 < _local15){
_local6 = _local6.prev;
_local15 = _local14;
} else {
_local14 = ((_local6.next.x * _local8.x) + (_local6.next.y * _local8.y));
if (_local14 < _local15){
_local6 = _local6.next;
_local15 = _local14;
} else {
break;
};
};
};
_local5.hint1 = _local6;
_local12 = ((_local8.x * (_local6.x - _local9.x)) + (_local8.y * (_local6.y - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local6;
_local16 = 1;
};
_local9 = _local9.next;
_local8 = _local8.next;
_local6 = _local5.hint2;
_local15 = ((_local6.x * _local8.x) + (_local6.y * _local8.y));
while (true) {
_local14 = ((_local6.prev.x * _local8.x) + (_local6.prev.y * _local8.y));
if (_local14 < _local15){
_local6 = _local6.prev;
_local15 = _local14;
} else {
_local14 = ((_local6.next.x * _local8.x) + (_local6.next.y * _local8.y));
if (_local14 < _local15){
_local6 = _local6.next;
_local15 = _local14;
} else {
break;
};
};
};
_local5.hint2 = _local6;
_local12 = ((_local8.x * (_local6.x - _local9.x)) + (_local8.y * (_local6.y - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local6;
_local16 = 1;
};
var _local17:V2 = _arg3.worldVertexChain;
var _local18:V2 = _local17.next;
var _local19:Number = _local17.x;
var _local20:Number = _local18.x;
var _local21:Number = _local17.y;
var _local22:Number = _local18.y;
_local9 = _arg2.worldVertexChain;
_local8 = _arg2.worldNormalChain;
while (true) {
if (((_local19 * _local8.x) + (_local21 * _local8.y)) < ((_local20 * _local8.x) + (_local22 * _local8.y))){
_local12 = ((_local8.x * (_local19 - _local9.x)) + (_local8.y * (_local21 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local17;
_local16 = 0;
};
} else {
_local12 = ((_local8.x * (_local20 - _local9.x)) + (_local8.y * (_local22 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local18;
_local16 = 0;
};
};
if (_local9.isTail){
break;
};
_local9 = _local9.next;
_local8 = _local8.next;
};
if (_local16){
_local23 = _arg3;
_local24 = _arg2;
} else {
_local23 = _arg2;
_local24 = _arg3;
};
var _local25:Number = _local7.x;
var _local26:Number = _local7.y;
var _local27:int = _local10.index;
var _local28:int = _local11.index;
var _local30:V2 = _local11.edge.n;
var _local31:Number = ((_local30.x * _local25) + (_local30.y * _local26));
if (((_local30.prev.x * _local25) + (_local30.prev.y * _local26)) < _local31){
_local11 = _local11.prev;
_local29 = _local30.prev.index;
} else {
if (((_local30.next.x * _local25) + (_local30.next.y * _local26)) < _local31){
_local11 = _local11.next;
_local29 = _local30.next.index;
};
};
var _local32:Number = (((_local23.x * _local25) + (_local23.y * _local26)) + (((_local10.x - _local23.x) * _local25) + ((_local10.y - _local23.y) * _local26)));
if (_local23.regularShape){
_local33 = ((_local23.y * _local25) - (_local23.x * _local26));
} else {
_local43 = _local23.offsets[_local10.index];
_local33 = ((((_local23.y + (_local23.r21 * _local43.x)) + (_local23.r22 * _local43.y)) * _local25) - (((_local23.x + (_local23.r11 * _local43.x)) + (_local23.r12 * _local43.y)) * _local26));
};
var _local34:Number = (_local10.edge.mag / 2);
_local39 = ((((_local11.x * _local26) - (_local11.y * _local25)) + _local33) - _local34);
_local40 = ((((_local11.next.x * _local26) - (_local11.next.y * _local25)) + _local33) - _local34);
if ((_local39 * _local40) < 0){
_local41 = (_local39 / (_local39 - _local40));
if (_local39 < 0){
_local35 = _local11.x;
_local37 = _local11.y;
_local36 = (_local35 + (_local41 * (_local11.next.x - _local35)));
_local38 = (_local37 + (_local41 * (_local11.next.y - _local37)));
} else {
_local35 = _local11.next.x;
_local37 = _local11.next.y;
_local36 = (_local11.x + (_local41 * (_local35 - _local11.x)));
_local38 = (_local11.y + (_local41 * (_local37 - _local11.y)));
};
} else {
if (_local39 > 0){
_arg1.pointCount = 0;
return;
};
if (_local39 < _local40){
_local35 = _local11.x;
_local37 = _local11.y;
_local36 = _local11.next.x;
_local38 = _local11.next.y;
} else {
_local36 = _local11.x;
_local38 = _local11.y;
_local35 = _local11.next.x;
_local37 = _local11.next.y;
};
};
_local39 = ((((_local37 * _local25) - _local33) - _local34) - (_local35 * _local26));
_local40 = ((((_local38 * _local25) - _local33) - _local34) - (_local36 * _local26));
if ((_local39 * _local40) < 0){
_local41 = (_local39 / (_local39 - _local40));
_local35 = (_local35 + (_local41 * (_local36 - _local35)));
_local37 = (_local37 + (_local41 * (_local38 - _local37)));
} else {
if (_local39 > 0){
_arg1.pointCount = 0;
return;
};
};
_local13 = (((_local25 * _local35) + (_local26 * _local37)) - _local32);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local16){
_arg1.nx = -(_local25);
_arg1.ny = -(_local26);
} else {
_arg1.nx = _local25;
_arg1.ny = _local26;
};
_local42 = _arg1.c0;
_local42.sep = _local13;
_local42.x = _local35;
_local42.y = _local37;
_local42.id.flip = _local16;
_local42.id.incEdge = _local29;
_local42.id.incVert = _local28;
_local42.id.refFace = _local27;
_local42.id.bake();
_local13 = (((_local25 * _local36) + (_local26 * _local38)) - _local32);
if (_local13 <= 0){
_arg1.pointCount = 2;
_local42 = _arg1.c1;
_local42.sep = _local13;
_local42.x = _local36;
_local42.y = _local38;
_local42.id.flip = _local16;
_local42.id.incEdge = _local29;
_local42.id.incVert = _local28;
_local42.id.refFace = _local27;
_local42.id.bake();
};
} else {
_local13 = (((_local25 * _local36) + (_local26 * _local38)) - _local32);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local16){
_arg1.nx = -(_local25);
_arg1.ny = -(_local26);
} else {
_arg1.nx = _local25;
_arg1.ny = _local26;
};
_local42 = _arg1.c0;
_local42.sep = _local13;
_local42.x = _local36;
_local42.y = _local38;
_local42.id.flip = _local16;
_local42.id.incEdge = _local29;
_local42.id.incVert = _local28;
_local42.id.refFace = _local27;
_local42.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 67
//CollidePolyLineSingleSidedBSP (de.polygonal.motor2.collision.pairwise.CollidePolyLineSingleSidedBSP)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollidePolyLineSingleSidedBSP implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:ConvexBSPNode;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local21:ShapeSkeleton;
var _local22:ShapeSkeleton;
var _local27:int;
var _local31:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:ContactPoint;
var _local41:V2;
var _local5:V2 = _arg3.worldNormalChain;
if ((((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d) < 0){
_arg4.disabled = true;
_arg1.pointCount = 0;
return;
};
var _local13:Number = -2147483648;
var _local14:int;
_local9 = _arg3.worldVertexChain;
_local8 = _arg3.worldNormalChain;
_local6 = _arg2.BSPNode;
while (_local6.R) {
_local6 = ((((-(_local6.N.y) * _local8.x) + (_local6.N.x * _local8.y)))<=0) ? _local6.R : _local6.L;
};
_local7 = _local6.V;
_local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local7;
_local14 = 1;
};
_local9 = _local9.next;
_local8 = _local8.next;
_local6 = _arg2.BSPNode;
while (_local6.R) {
_local6 = ((((-(_local6.N.y) * _local8.x) + (_local6.N.x * _local8.y)))<=0) ? _local6.R : _local6.L;
};
_local7 = _local6.V;
_local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local7;
_local14 = 1;
};
var _local15:V2 = _arg3.worldVertexChain;
var _local16:V2 = _local15.next;
var _local17:Number = _local15.x;
var _local18:Number = _local16.x;
var _local19:Number = _local15.y;
var _local20:Number = _local16.y;
_local9 = _arg2.worldVertexChain;
_local8 = _arg2.worldNormalChain;
while (true) {
if (((_local17 * _local8.x) + (_local19 * _local8.y)) < ((_local18 * _local8.x) + (_local20 * _local8.y))){
_local12 = ((_local8.x * (_local17 - _local9.x)) + (_local8.y * (_local19 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local15;
_local14 = 0;
};
} else {
_local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local16;
_local14 = 0;
};
};
if (_local9.isTail){
break;
};
_local9 = _local9.next;
_local8 = _local8.next;
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
if (_local14){
_local21 = _arg3;
_local22 = _arg2;
} else {
_local21 = _arg2;
_local22 = _arg3;
};
var _local23:Number = _local5.x;
var _local24:Number = _local5.y;
var _local25:int = _local10.index;
var _local26:int = _local11.index;
var _local28:V2 = _local11.edge.n;
var _local29:Number = ((_local28.x * _local23) + (_local28.y * _local24));
if (((_local28.prev.x * _local23) + (_local28.prev.y * _local24)) < _local29){
_local11 = _local11.prev;
_local27 = _local28.prev.index;
} else {
if (((_local28.next.x * _local23) + (_local28.next.y * _local24)) < _local29){
_local11 = _local11.next;
_local27 = _local28.next.index;
};
};
var _local30:Number = (((_local21.x * _local23) + (_local21.y * _local24)) + (((_local10.x - _local21.x) * _local23) + ((_local10.y - _local21.y) * _local24)));
if (_local21.regularShape){
_local31 = ((_local21.y * _local23) - (_local21.x * _local24));
} else {
_local41 = _local21.offsets[_local10.index];
_local31 = ((((_local21.y + (_local21.r21 * _local41.x)) + (_local21.r22 * _local41.y)) * _local23) - (((_local21.x + (_local21.r11 * _local41.x)) + (_local21.r12 * _local41.y)) * _local24));
};
var _local32:Number = (_local10.edge.mag / 2);
_local37 = ((((_local11.x * _local24) - (_local11.y * _local23)) + _local31) - _local32);
_local38 = ((((_local11.next.x * _local24) - (_local11.next.y * _local23)) + _local31) - _local32);
if ((_local37 * _local38) < 0){
_local39 = (_local37 / (_local37 - _local38));
if (_local37 < 0){
_local33 = _local11.x;
_local35 = _local11.y;
_local34 = (_local33 + (_local39 * (_local11.next.x - _local33)));
_local36 = (_local35 + (_local39 * (_local11.next.y - _local35)));
} else {
_local33 = _local11.next.x;
_local35 = _local11.next.y;
_local34 = (_local11.x + (_local39 * (_local33 - _local11.x)));
_local36 = (_local11.y + (_local39 * (_local35 - _local11.y)));
};
} else {
if (_local37 > 0){
_arg1.pointCount = 0;
return;
};
if (_local37 < _local38){
_local33 = _local11.x;
_local35 = _local11.y;
_local34 = _local11.next.x;
_local36 = _local11.next.y;
} else {
_local34 = _local11.x;
_local36 = _local11.y;
_local33 = _local11.next.x;
_local35 = _local11.next.y;
};
};
_local37 = ((((_local35 * _local23) - _local31) - _local32) - (_local33 * _local24));
_local38 = ((((_local36 * _local23) - _local31) - _local32) - (_local34 * _local24));
if ((_local37 * _local38) < 0){
_local39 = (_local37 / (_local37 - _local38));
_local33 = (_local33 + (_local39 * (_local34 - _local33)));
_local35 = (_local35 + (_local39 * (_local36 - _local35)));
} else {
if (_local37 > 0){
_arg1.pointCount = 0;
return;
};
};
_local13 = (((_local23 * _local33) + (_local24 * _local35)) - _local30);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local23);
_arg1.ny = -(_local24);
} else {
_arg1.nx = _local23;
_arg1.ny = _local24;
};
_local40 = _arg1.c0;
_local40.sep = _local13;
_local40.x = _local33;
_local40.y = _local35;
_local40.id.flip = _local14;
_local40.id.incEdge = _local27;
_local40.id.incVert = _local26;
_local40.id.refFace = _local25;
_local40.id.bake();
_local13 = (((_local23 * _local34) + (_local24 * _local36)) - _local30);
if (_local13 <= 0){
_arg1.pointCount = 2;
_local40 = _arg1.c1;
_local40.sep = _local13;
_local40.x = _local34;
_local40.y = _local36;
_local40.id.flip = _local14;
_local40.id.incEdge = _local27;
_local40.id.incVert = _local26;
_local40.id.refFace = _local25;
_local40.id.bake();
};
} else {
_local13 = (((_local23 * _local34) + (_local24 * _local36)) - _local30);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local23);
_arg1.ny = -(_local24);
} else {
_arg1.nx = _local23;
_arg1.ny = _local24;
};
_local40 = _arg1.c0;
_local40.sep = _local13;
_local40.x = _local34;
_local40.y = _local36;
_local40.id.flip = _local14;
_local40.id.incEdge = _local27;
_local40.id.incVert = _local26;
_local40.id.refFace = _local25;
_local40.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 68
//CollidePolyLineSingleSidedCHC (de.polygonal.motor2.collision.pairwise.CollidePolyLineSingleSidedCHC)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollidePolyLineSingleSidedCHC implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local14:Number;
var _local15:Number;
var _local23:ShapeSkeleton;
var _local24:ShapeSkeleton;
var _local29:int;
var _local33:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:Number;
var _local42:ContactPoint;
var _local43:V2;
var _local5:V2 = _arg3.worldNormalChain;
if ((((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d) < 0){
_arg4.disabled = true;
_arg1.pointCount = 0;
return;
};
var _local6:PolyLineContact = PolyLineContact(_arg4);
var _local13:Number = -2147483648;
var _local16:int;
_local9 = _arg3.worldVertexChain;
_local8 = _arg3.worldNormalChain;
_local7 = _local6.hint1;
_local15 = ((_local7.x * _local8.x) + (_local7.y * _local8.y));
while (true) {
_local14 = ((_local7.prev.x * _local8.x) + (_local7.prev.y * _local8.y));
if (_local14 < _local15){
_local7 = _local7.prev;
_local15 = _local14;
} else {
_local14 = ((_local7.next.x * _local8.x) + (_local7.next.y * _local8.y));
if (_local14 < _local15){
_local7 = _local7.next;
_local15 = _local14;
} else {
break;
};
};
};
_local6.hint1 = _local7;
_local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local7;
_local16 = 1;
};
_local9 = _local9.next;
_local8 = _local8.next;
_local7 = _local6.hint2;
_local15 = ((_local7.x * _local8.x) + (_local7.y * _local8.y));
while (true) {
_local14 = ((_local7.prev.x * _local8.x) + (_local7.prev.y * _local8.y));
if (_local14 < _local15){
_local7 = _local7.prev;
_local15 = _local14;
} else {
_local14 = ((_local7.next.x * _local8.x) + (_local7.next.y * _local8.y));
if (_local14 < _local15){
_local7 = _local7.next;
_local15 = _local14;
} else {
break;
};
};
};
_local6.hint2 = _local7;
_local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local7;
_local16 = 1;
};
var _local17:V2 = _arg3.worldVertexChain;
var _local18:V2 = _local17.next;
var _local19:Number = _local17.x;
var _local20:Number = _local18.x;
var _local21:Number = _local17.y;
var _local22:Number = _local18.y;
_local9 = _arg2.worldVertexChain;
_local8 = _arg2.worldNormalChain;
while (true) {
if (((_local19 * _local8.x) + (_local21 * _local8.y)) < ((_local20 * _local8.x) + (_local22 * _local8.y))){
_local12 = ((_local8.x * (_local19 - _local9.x)) + (_local8.y * (_local21 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local17;
_local16 = 0;
};
} else {
_local12 = ((_local8.x * (_local20 - _local9.x)) + (_local8.y * (_local22 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local18;
_local16 = 0;
};
};
if (_local9.isTail){
break;
};
_local9 = _local9.next;
_local8 = _local8.next;
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
if (_local16){
_local23 = _arg3;
_local24 = _arg2;
} else {
_local23 = _arg2;
_local24 = _arg3;
};
var _local25:Number = _local5.x;
var _local26:Number = _local5.y;
var _local27:int = _local10.index;
var _local28:int = _local11.index;
var _local30:V2 = _local11.edge.n;
var _local31:Number = ((_local30.x * _local25) + (_local30.y * _local26));
if (((_local30.prev.x * _local25) + (_local30.prev.y * _local26)) < _local31){
_local11 = _local11.prev;
_local29 = _local30.prev.index;
} else {
if (((_local30.next.x * _local25) + (_local30.next.y * _local26)) < _local31){
_local11 = _local11.next;
_local29 = _local30.next.index;
};
};
var _local32:Number = (((_local23.x * _local25) + (_local23.y * _local26)) + (((_local10.x - _local23.x) * _local25) + ((_local10.y - _local23.y) * _local26)));
if (_local23.regularShape){
_local33 = ((_local23.y * _local25) - (_local23.x * _local26));
} else {
_local43 = _local23.offsets[_local10.index];
_local33 = ((((_local23.y + (_local23.r21 * _local43.x)) + (_local23.r22 * _local43.y)) * _local25) - (((_local23.x + (_local23.r11 * _local43.x)) + (_local23.r12 * _local43.y)) * _local26));
};
var _local34:Number = (_local10.edge.mag / 2);
_local39 = ((((_local11.x * _local26) - (_local11.y * _local25)) + _local33) - _local34);
_local40 = ((((_local11.next.x * _local26) - (_local11.next.y * _local25)) + _local33) - _local34);
if ((_local39 * _local40) < 0){
_local41 = (_local39 / (_local39 - _local40));
if (_local39 < 0){
_local35 = _local11.x;
_local37 = _local11.y;
_local36 = (_local35 + (_local41 * (_local11.next.x - _local35)));
_local38 = (_local37 + (_local41 * (_local11.next.y - _local37)));
} else {
_local35 = _local11.next.x;
_local37 = _local11.next.y;
_local36 = (_local11.x + (_local41 * (_local35 - _local11.x)));
_local38 = (_local11.y + (_local41 * (_local37 - _local11.y)));
};
} else {
if (_local39 > 0){
_arg1.pointCount = 0;
return;
};
if (_local39 < _local40){
_local35 = _local11.x;
_local37 = _local11.y;
_local36 = _local11.next.x;
_local38 = _local11.next.y;
} else {
_local36 = _local11.x;
_local38 = _local11.y;
_local35 = _local11.next.x;
_local37 = _local11.next.y;
};
};
_local39 = ((((_local37 * _local25) - _local33) - _local34) - (_local35 * _local26));
_local40 = ((((_local38 * _local25) - _local33) - _local34) - (_local36 * _local26));
if ((_local39 * _local40) < 0){
_local41 = (_local39 / (_local39 - _local40));
_local35 = (_local35 + (_local41 * (_local36 - _local35)));
_local37 = (_local37 + (_local41 * (_local38 - _local37)));
} else {
if (_local39 > 0){
_arg1.pointCount = 0;
return;
};
};
_local13 = (((_local25 * _local35) + (_local26 * _local37)) - _local32);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local16){
_arg1.nx = -(_local25);
_arg1.ny = -(_local26);
} else {
_arg1.nx = _local25;
_arg1.ny = _local26;
};
_local42 = _arg1.c0;
_local42.sep = _local13;
_local42.x = _local35;
_local42.y = _local37;
_local42.id.flip = _local16;
_local42.id.incEdge = _local29;
_local42.id.incVert = _local28;
_local42.id.refFace = _local27;
_local42.id.bake();
_local13 = (((_local25 * _local36) + (_local26 * _local38)) - _local32);
if (_local13 <= 0){
_arg1.pointCount = 2;
_local42 = _arg1.c1;
_local42.sep = _local13;
_local42.x = _local36;
_local42.y = _local38;
_local42.id.flip = _local16;
_local42.id.incEdge = _local29;
_local42.id.incVert = _local28;
_local42.id.refFace = _local27;
_local42.id.bake();
};
} else {
_local13 = (((_local25 * _local36) + (_local26 * _local38)) - _local32);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local16){
_arg1.nx = -(_local25);
_arg1.ny = -(_local26);
} else {
_arg1.nx = _local25;
_arg1.ny = _local26;
};
_local42 = _arg1.c0;
_local42.sep = _local13;
_local42.x = _local36;
_local42.y = _local38;
_local42.id.flip = _local16;
_local42.id.incEdge = _local29;
_local42.id.incVert = _local28;
_local42.id.refFace = _local27;
_local42.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 69
//CollidePolyPlaneDoubleSidedBSP (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneDoubleSidedBSP)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollidePolyPlaneDoubleSidedBSP implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local9:V2;
var _local10:int;
var _local11:ContactPoint;
var _local12:Number;
var _local6:Number = _arg3.worldNormalChain.x;
var _local7:Number = _arg3.worldNormalChain.y;
var _local8:Number = _arg3.d;
if ((((_arg2.x * _local6) + (_arg2.y * _local7)) - _local8) > 0){
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L;
};
_local9 = _local5.V;
_local12 = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8);
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
} else {
_local6 = -(_local6);
_local7 = -(_local7);
_local8 = -(_local8);
_local10 = 1;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L;
};
_local9 = _local5.V;
_local12 = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8);
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
};
_arg1.pointCount = 1;
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
_local11 = _arg1.c0;
_local11.sep = _local12;
_local11.x = _local9.x;
_local11.y = _local9.y;
_local11.id.key = _local10;
_local12 = (((_local9.prev.x * _local6) + (_local9.prev.y * _local7)) - _local8);
if (_local12 < 0){
_local11.id.key = -(~(_local10));
_local11 = _arg1.c1;
_local11.sep = _local12;
_local11.x = _local9.prev.x;
_local11.y = _local9.prev.y;
_local11.id.key = -(~(_local10));
_arg1.pointCount++;
} else {
_local12 = (((_local9.next.x * _local6) + (_local9.next.y * _local7)) - _local8);
if (_local12 < 0){
_local11.id.key = -(~(_local10));
_local11 = _arg1.c1;
_local11.sep = _local12;
_local11.x = _local9.next.x;
_local11.y = _local9.next.y;
_local11.id.key = -(~(_local10));
_arg1.pointCount++;
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 70
//CollidePolyPlaneDoubleSidedCHC (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneDoubleSidedCHC)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollidePolyPlaneDoubleSidedCHC implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local8:Number;
var _local9:Number;
var _local11:V2;
var _local12:int;
var _local13:ContactPoint;
var _local14:Number;
var _local5:PolyLineContact = PolyLineContact(_arg4);
var _local6:Number = _arg3.worldNormalChain.x;
var _local7:Number = _arg3.worldNormalChain.y;
var _local10:Number = _arg3.d;
if ((((_arg2.x * _local6) + (_arg2.y * _local7)) - _local10) > 0){
_local11 = _local5.hint1;
_local9 = ((_local11.x * _local6) + (_local11.y * _local7));
while (true) {
_local8 = ((_local11.prev.x * _local6) + (_local11.prev.y * _local7));
if (_local8 < _local9){
_local11 = _local11.prev;
_local9 = _local8;
} else {
_local8 = ((_local11.next.x * _local6) + (_local11.next.y * _local7));
if (_local8 < _local9){
_local11 = _local11.next;
_local9 = _local8;
} else {
break;
};
};
};
_local5.hint1 = _local11;
_local14 = (((_local11.x * _local6) + (_local11.y * _local7)) - _local10);
if (_local14 > 0){
_arg1.pointCount = 0;
return;
};
} else {
_local6 = -(_local6);
_local7 = -(_local7);
_local10 = -(_local10);
_local12 = 1;
_local11 = _local5.hint2;
_local9 = ((_local11.x * _local6) + (_local11.y * _local7));
while (true) {
_local8 = ((_local11.prev.x * _local6) + (_local11.prev.y * _local7));
if (_local8 < _local9){
_local11 = _local11.prev;
_local9 = _local8;
} else {
_local8 = ((_local11.next.x * _local6) + (_local11.next.y * _local7));
if (_local8 < _local9){
_local11 = _local11.next;
_local9 = _local8;
} else {
break;
};
};
};
_local5.hint2 = _local11;
_local14 = (((_local11.x * _local6) + (_local11.y * _local7)) - _local10);
if (_local14 > 0){
_arg1.pointCount = 0;
return;
};
};
_arg1.pointCount = 1;
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
_local13 = _arg1.c0;
_local13.sep = _local14;
_local13.x = _local11.x;
_local13.y = _local11.y;
_local13.id.key = _local12;
_local14 = (((_local11.prev.x * _local6) + (_local11.prev.y * _local7)) - _local10);
if (_local14 < 0){
_local13.id.key = -(~(_local12));
_local13 = _arg1.c1;
_local13.sep = _local14;
_local13.x = _local11.prev.x;
_local13.y = _local11.prev.y;
_local13.id.key = -(~(_local12));
_arg1.pointCount++;
} else {
_local14 = (((_local11.next.x * _local6) + (_local11.next.y * _local7)) - _local10);
if (_local14 < 0){
_local13.id.key = -(~(_local12));
_local13 = _arg1.c1;
_local13.sep = _local14;
_local13.x = _local11.next.x;
_local13.y = _local11.next.y;
_local13.id.key = -(~(_local12));
_arg1.pointCount++;
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 71
//CollidePolyPlaneSingleSidedBSP (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneSingleSidedBSP)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollidePolyPlaneSingleSidedBSP implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local7:Number;
var _local8:Number;
var _local6:Number = _arg3.worldNormalChain.x;
_local7 = _arg3.worldNormalChain.y;
_local8 = _arg3.d;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L;
};
var _local9:V2 = _local5.V;
var _local10:Number = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8);
if (_local10 > 0){
_arg1.pointCount = 0;
return;
};
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
_arg1.pointCount = 1;
var _local11:ContactPoint = _arg1.c0;
_local11.sep = _local10;
_local11.x = _local9.x;
_local11.y = _local9.y;
_local11.id.key = 0;
_local10 = (((_local9.prev.x * _local6) + (_local9.prev.y * _local7)) - _local8);
if (_local10 < 0){
_local11.id.key = 1;
_local11 = _arg1.c1;
_local11.sep = _local10;
_local11.x = _local9.prev.x;
_local11.y = _local9.prev.y;
_local11.id.key = 1;
_arg1.pointCount++;
} else {
_local10 = (((_local9.next.x * _local6) + (_local9.next.y * _local7)) - _local8);
if (_local10 < 0){
_local11.id.key = 1;
_local11 = _arg1.c1;
_local11.sep = _local10;
_local11.x = _local9.next.x;
_local11.y = _local9.next.y;
_local11.id.key = 1;
_arg1.pointCount++;
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 72
//CollidePolyPlaneSingleSidedCHC (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneSingleSidedCHC)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollidePolyPlaneSingleSidedCHC implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:Number;
var _local7:Number;
var _local10:Number;
var _local5:Number = _arg3.worldNormalChain.x;
_local6 = _arg3.worldNormalChain.y;
_local7 = _arg3.d;
var _local8:PolyLineContact = PolyLineContact(_arg4);
var _local9:V2 = _local8.hint1;
var _local11:Number = ((_local9.x * _local5) + (_local9.y * _local6));
while (true) {
_local10 = ((_local9.prev.x * _local5) + (_local9.prev.y * _local6));
if (_local10 < _local11){
_local9 = _local9.prev;
_local11 = _local10;
} else {
_local10 = ((_local9.next.x * _local5) + (_local9.next.y * _local6));
if (_local10 < _local11){
_local9 = _local9.next;
_local11 = _local10;
} else {
break;
};
};
};
_local8.hint1 = _local9;
var _local12:Number = (((_local9.x * _local5) + (_local9.y * _local6)) - _local7);
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
_arg1.nx = -(_local5);
_arg1.ny = -(_local6);
_arg1.pointCount = 1;
var _local13:ContactPoint = _arg1.c0;
_local13.sep = _local12;
_local13.x = _local9.x;
_local13.y = _local9.y;
_local13.id.key = 0;
_local12 = (((_local9.prev.x * _local5) + (_local9.prev.y * _local6)) - _local7);
if (_local12 < 0){
_local13.id.key = 1;
_local13 = _arg1.c1;
_local13.sep = _local12;
_local13.x = _local9.prev.x;
_local13.y = _local9.prev.y;
_local13.id.key = 1;
_arg1.pointCount++;
} else {
_local12 = (((_local9.next.x * _local5) + (_local9.next.y * _local6)) - _local7);
if (_local12 < 0){
_local13.id.key = 1;
_local13 = _arg1.c1;
_local13.sep = _local12;
_local13.x = _local9.next.x;
_local13.y = _local9.next.y;
_local13.id.key = 1;
_arg1.pointCount++;
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 73
//Collider (de.polygonal.motor2.collision.pairwise.Collider)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public interface Collider {
function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void;
}
}//package de.polygonal.motor2.collision.pairwise
Section 74
//CollideTriangleHC (de.polygonal.motor2.collision.pairwise.CollideTriangleHC)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollideTriangleHC implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local13:Number;
var _local14:int;
var _local15:Number;
var _local16:Number;
var _local22:int;
var _local26:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:ContactPoint;
var _local36:V2;
var _local5:PolyContact = PolyContact(_arg4);
var _local12:Number = -2147483648;
_local6 = _local5.p;
_local7 = _local5.d;
if (_local5.firstOut){
_local8 = _arg3.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg3.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg3.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
};
_local6 = _arg3.worldVertexChain;
_local7 = _arg3.worldNormalChain;
_local8 = _arg2.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = false;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg2.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = false;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg2.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = false;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
} else {
_local8 = _arg2.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg2.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg2.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
_local6 = _arg2.worldVertexChain;
_local7 = _arg2.worldNormalChain;
_local8 = _arg3.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = true;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 0;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg3.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = true;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 0;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg3.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = true;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 0;
};
};
var _local17:ShapeSkeleton = (_local14) ? _arg3 : _arg2;
var _local18:Number = _local9.x;
var _local19:Number = _local9.y;
var _local20:int = _local11.index;
var _local21:int = _local10.index;
var _local23:V2 = _local10.edge.n;
var _local24:Number = ((_local23.x * _local18) + (_local23.y * _local19));
if (((_local23.prev.x * _local18) + (_local23.prev.y * _local19)) < _local24){
_local10 = _local10.prev;
_local22 = _local23.prev.index;
} else {
if (((_local23.next.x * _local18) + (_local23.next.y * _local19)) < _local24){
_local10 = _local10.next;
_local22 = _local23.next.index;
};
};
var _local25:Number = (((_local17.x * _local18) + (_local17.y * _local19)) + (((_local11.x - _local17.x) * _local18) + ((_local11.y - _local17.y) * _local19)));
if (_local17.regularShape){
_local26 = ((_local17.y * _local18) - (_local17.x * _local19));
} else {
_local36 = _local17.offsets[_local11.index];
_local26 = ((((_local17.y + (_local17.r21 * _local36.x)) + (_local17.r22 * _local36.y)) * _local18) - (((_local17.x + (_local17.r11 * _local36.x)) + (_local17.r12 * _local36.y)) * _local19));
};
var _local27:Number = (_local11.edge.mag / 2);
_local32 = ((((_local10.x * _local19) - (_local10.y * _local18)) + _local26) - _local27);
_local33 = ((((_local10.next.x * _local19) - (_local10.next.y * _local18)) + _local26) - _local27);
if ((_local32 * _local33) < 0){
_local34 = (_local32 / (_local32 - _local33));
if (_local32 < 0){
_local28 = _local10.x;
_local30 = _local10.y;
_local29 = (_local28 + (_local34 * (_local10.next.x - _local28)));
_local31 = (_local30 + (_local34 * (_local10.next.y - _local30)));
} else {
_local28 = _local10.next.x;
_local30 = _local10.next.y;
_local29 = (_local10.x + (_local34 * (_local28 - _local10.x)));
_local31 = (_local10.y + (_local34 * (_local30 - _local10.y)));
};
} else {
if (_local32 > 0){
_arg1.pointCount = 0;
return;
};
if (_local32 < _local33){
_local28 = _local10.x;
_local30 = _local10.y;
_local29 = _local10.next.x;
_local31 = _local10.next.y;
} else {
_local29 = _local10.x;
_local31 = _local10.y;
_local28 = _local10.next.x;
_local30 = _local10.next.y;
};
};
_local32 = ((((_local30 * _local18) - _local26) - _local27) - (_local28 * _local19));
_local33 = ((((_local31 * _local18) - _local26) - _local27) - (_local29 * _local19));
if ((_local32 * _local33) < 0){
_local34 = (_local32 / (_local32 - _local33));
_local28 = (_local28 + (_local34 * (_local29 - _local28)));
_local30 = (_local30 + (_local34 * (_local31 - _local30)));
} else {
if (_local32 > 0){
_arg1.pointCount = 0;
return;
};
};
_local12 = (((_local18 * _local28) + (_local19 * _local30)) - _local25);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local18);
_arg1.ny = -(_local19);
} else {
_arg1.nx = _local18;
_arg1.ny = _local19;
};
_local35 = _arg1.c0;
_local35.sep = _local12;
_local35.x = _local28;
_local35.y = _local30;
_local35.id.flip = _local14;
_local35.id.incEdge = _local22;
_local35.id.incVert = _local21;
_local35.id.refFace = _local20;
_local35.id.bake();
_local12 = (((_local18 * _local29) + (_local19 * _local31)) - _local25);
if (_local12 <= 0){
_arg1.pointCount = 2;
_local35 = _arg1.c1;
_local35.sep = _local12;
_local35.x = _local29;
_local35.y = _local31;
_local35.id.flip = _local14;
_local35.id.incEdge = _local22;
_local35.id.incVert = _local21;
_local35.id.refFace = _local20;
_local35.id.bake();
};
} else {
_local12 = (((_local18 * _local29) + (_local19 * _local31)) - _local25);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local18);
_arg1.ny = -(_local19);
} else {
_arg1.nx = _local18;
_arg1.ny = _local19;
};
_local35 = _arg1.c0;
_local35.sep = _local12;
_local35.x = _local29;
_local35.y = _local31;
_local35.id.flip = _local14;
_local35.id.incEdge = _local22;
_local35.id.incVert = _local21;
_local35.id.refFace = _local20;
_local35.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 75
//BoxData (de.polygonal.motor2.collision.shapes.data.BoxData)
package de.polygonal.motor2.collision.shapes.data {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
public class BoxData extends ShapeData {
private var _h:Number;
private var _w:Number;
public function BoxData(_arg1:Number, _arg2:Number, _arg3:Number){
super(_arg1);
this.width = _arg2;
this.height = _arg3;
}
public function get width():Number{
return (_w);
}
public function get height():Number{
return (_h);
}
override protected function computeMass():void{
_mass = ((_density * _w) * _h);
_I = ((_mass / 12) * ((_w * _w) + (_h * _h)));
_cm = new V2();
}
public function set width(_arg1:Number):void{
_w = _arg1;
invalidate();
}
override public function getShapeClass():Class{
return (BoxShape);
}
public function set height(_arg1:Number):void{
_h = _arg1;
invalidate();
}
override public function get area():Number{
return ((_w * _h));
}
override protected function setType():void{
type = ShapeTypes.BOX;
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 76
//CircleData (de.polygonal.motor2.collision.shapes.data.CircleData)
package de.polygonal.motor2.collision.shapes.data {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
public class CircleData extends ShapeData {
private var _radius:Number;
public function CircleData(_arg1:Number, _arg2:Number){
super(_arg1);
this.radius = Math.abs(_arg2);
}
public function set radius(_arg1:Number):void{
_radius = _arg1;
invalidate();
}
public function get radius():Number{
return (_radius);
}
override protected function computeMass():void{
_mass = (((_density * Math.PI) * radius) * radius);
_I = (((0.5 * _mass) * radius) * radius);
_cm = new V2();
}
override public function getShapeClass():Class{
return (CircleShape);
}
override public function get area():Number{
return (((Math.PI * _radius) * _radius));
}
override protected function setType():void{
type = ShapeTypes.CIRCLE;
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 77
//LineData (de.polygonal.motor2.collision.shapes.data.LineData)
package de.polygonal.motor2.collision.shapes.data {
import flash.geom.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
public class LineData extends ShapeData {
public const a:Point;
public const b:Point;
public var infinite:Boolean;
public var doubleSided:Boolean;
public function LineData(_arg1:Point, _arg2:Point, _arg3:Boolean=false, _arg4:Boolean=true){
a = new Point();
b = new Point();
super(0);
var _local5:Number = (_arg2.x - _arg1.x);
var _local6:Number = (_arg2.y - _arg1.y);
if (Math.sqrt((((_local5 * _local5) + _local6) + _local6)) <= 1E-6){
throw (new Error("overlapping vertices detected"));
};
var _local7:Number = (_arg1.x + ((_arg2.x - _arg1.x) * 0.5));
var _local8:Number = (_arg1.y + ((_arg2.y - _arg1.y) * 0.5));
this.a.x = (_arg1.x - _local7);
this.b.x = (_arg2.x - _local7);
this.a.y = (_arg1.y - _local8);
this.b.y = (_arg2.y - _local8);
this.infinite = _arg3;
this.doubleSided = _arg4;
}
override protected function setType():void{
type = ShapeTypes.LINE;
}
override public function getShapeClass():Class{
return (LineShape);
}
override public function get density():Number{
return (0);
}
override protected function computeMass():void{
_mass = 0;
_I = 0;
_cm = new V2((a.x + (0.5 * (b.x - a.x))), (a.y + (0.5 * (b.y - a.y))));
}
override public function get area():Number{
return (0);
}
override public function set density(_arg1:Number):void{
super.density = 0;
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 78
//PolyData (de.polygonal.motor2.collision.shapes.data.PolyData)
package de.polygonal.motor2.collision.shapes.data {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
public class PolyData extends ShapeData {
private var _vertices:Array;
private var _area:Number;
private var _radius:Number;
private var _vertexCount:int;
private var _regular:Boolean;
public function PolyData(_arg1:Number, _arg2:Array){
super(_arg1);
setVertices(_arg2);
}
private function setVertices(_arg1:Array):void{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:Number;
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
if ((_local4 % 2) != 0){
throw (new Error("invalid source data"));
};
_local4 = (_arg1.length / 2);
_vertices = null;
if (_local4 < 3){
throw (new Error("invalid source data"));
};
_local6 = new V2(_arg1[0], _arg1[1]);
_local10 = _local6;
if (((isNaN(_local6.x)) || (isNaN(_local6.y)))){
throw (new Error("invalid source data"));
};
_local2 = 1;
_local3 = 2;
while (_local2 < _local4) {
_local7 = new V2(_arg1[_local3], _arg1[int((_local3 + 1))]);
_local3 = (_local3 + 2);
if (((isNaN(_local7.x)) || (isNaN(_local7.y)))){
throw (new Error("invalid source data"));
};
_local6.next = _local7;
_local6 = _local7;
_local2++;
};
_local6.next = _local10;
_local6 = _local10;
_local2 = 0;
while (_local2 < (_local4 - 1)) {
_local7 = _local6.next;
_local3 = (_local2 + 1);
while (_local3 < _local4) {
if ((((_local7.x - _local6.x) * (_local7.x - _local6.x)) + ((_local7.y - _local6.y) * (_local7.y - _local6.y))) < 0.1){
throw (new Error("overlapping vertices detected"));
};
_local7 = _local7.next;
_local3++;
};
_local6 = _local6.next;
_local2++;
};
_local6 = _local10;
var _local11:Number = 0;
_local2 = 0;
while (_local2 < _local4) {
_local7 = _local6.next;
_local11 = (_local11 + ((_local6.x * _local7.y) - (_local6.y * _local7.x)));
_local6 = _local7;
_local2++;
};
if (_local11 < 0){
throw (new Error("vertices are not clockwise ordered"));
};
_local6 = _local10;
_local7 = _local6.next;
_local2 = 0;
while (_local2 < _local4) {
_local12 = (_local7.x - _local6.x);
_local13 = (_local7.y - _local6.y);
_local9 = _local7.next;
_local3 = 0;
while (_local3 < (_local4 - 2)) {
if (((_local12 * (_local9.y - _local6.y)) - ((_local9.x - _local6.x) * _local13)) < 0){
throw (new Error("shape is not convex"));
};
_local9 = _local9.next;
_local3++;
};
_local6 = _local7;
_local7 = _local6.next;
_local2++;
};
_vertexCount = _local4;
_vertices = new Array(_local4, true);
_local2 = 0;
_local6 = _local10;
while (_local2 < _local4) {
_vertices[_local2] = _local6;
_local6 = _local6.next;
_local2++;
};
_regular = true;
_local6 = _local10;
_local7 = _local6.next;
_local8 = _local7.next;
_local14 = (_local8.x - _local7.x);
_local15 = (_local8.y - _local7.y);
_local16 = (_local7.x - _local6.x);
_local17 = (_local7.y - _local6.y);
_local11 = Math.atan2(((_local14 * _local17) - (_local15 * _local16)), ((_local14 * _local16) + (_local15 * _local17)));
_local2 = 1;
while (_local2 < _local4) {
_local6 = _local7;
_local7 = _local8;
_local8 = _local8.next;
_local14 = (_local8.x - _local7.x);
_local15 = (_local8.y - _local7.y);
_local16 = (_local7.x - _local6.x);
_local17 = (_local7.y - _local6.y);
_local18 = Math.atan2(((_local14 * _local17) - (_local15 * _local16)), ((_local14 * _local16) + (_local15 * _local17)));
if (Math.abs((_local11 - _local18)) > 1E-6){
_regular = false;
break;
};
_local2++;
};
_local5 = Number.MIN_VALUE;
_local6 = _local10;
_local2 = 0;
_local6 = _local10;
while (_local2 < _local4) {
_local5 = Math.max(_local5, ((_local6.x * _local6.x) + (_local6.y * _local6.y)));
_local6 = _local6.next;
_local2++;
};
_radius = Math.sqrt(_local5);
invalidate();
}
override protected function computeMass():void{
var _local6:Number;
var _local7: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 _local20:V2;
var _local1:Number = 0;
var _local2:Number = 0;
var _local3:Number = 0;
var _local4:Number = 0;
var _local5:Number = 0;
var _local8:Number = 0;
var _local19:Number = (1 / 3);
var _local21:int;
while (_local21 < _vertexCount) {
_local20 = _vertices[_local21];
_local6 = _local20.x;
_local7 = _local20.y;
_local20 = _vertices[int(((_local21 + 1) % _vertexCount))];
_local9 = _local20.x;
_local10 = _local20.y;
_local11 = (_local6 - _local5);
_local12 = (_local7 - _local8);
_local13 = (_local9 - _local5);
_local14 = (_local10 - _local8);
_local15 = ((_local11 * _local14) - (_local12 * _local13));
_local16 = (0.5 * _local15);
_local3 = (_local3 + _local16);
_local1 = (_local1 + ((_local16 * _local19) * ((_local5 + _local6) + _local9)));
_local2 = (_local2 + ((_local16 * _local19) * ((_local8 + _local7) + _local10)));
_local17 = ((_local19 * ((0.25 * (((_local11 * _local11) + (_local13 * _local11)) + (_local13 * _local13))) + ((_local5 * _local11) + (_local5 * _local13)))) + ((0.5 * _local5) * _local5));
_local18 = ((_local19 * ((0.25 * (((_local12 * _local12) + (_local14 * _local12)) + (_local14 * _local14))) + ((_local8 * _local12) + (_local8 * _local14)))) + ((0.5 * _local8) * _local8));
_local4 = (_local4 + (_local15 * (_local17 + _local18)));
_local21++;
};
_mass = (_density * _local3);
_local1 = (_local1 / _local3);
_local2 = (_local2 / _local3);
_cm = new V2(_local1, _local2);
_I = (_density * (_local4 - (_local3 * ((_local1 * _local1) + (_local2 * _local2)))));
_area = _local3;
}
override public function get area():Number{
return (_area);
}
public function getVertices():Array{
var _local1:int;
var _local2:Array;
_local2 = new Array(_vertexCount, true);
_local1 = 0;
while (_local1 < _vertexCount) {
_local2[_local1] = new V2(_vertices[_local1].x, _vertices[_local1].y);
_local1++;
};
return (_local2);
}
public function isRegular():Boolean{
return (_regular);
}
override public function getShapeClass():Class{
return (PolyShape);
}
public function getVertexCount():int{
return (_vertexCount);
}
public function get radius():Number{
return (_radius);
}
override protected function setType():void{
type = ShapeTypes.POLY;
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 79
//ShapeData (de.polygonal.motor2.collision.shapes.data.ShapeData)
package de.polygonal.motor2.collision.shapes.data {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
public class ShapeData {
public var isSensor:Boolean;
protected var _cm:V2;
public var groupIndex:int;
public var userData;
public var maskBits:int;
public var categoryBits:int;
public var mr:Number;
protected var _density:Number;
private var _restitution:Number;
public var my:Number;
public var mx:Number;
public var type:int;
protected var _I:Number;
protected var _mass:Number;
private var _friction:Number;
public var next:ShapeData;
public function ShapeData(_arg1:Number){
this.density = _arg1;
init();
}
public function getInertia():Number{
if (_density == 0){
return (0);
};
if (isNaN(_I)){
computeMass();
};
return (_I);
}
public function get area():Number{
return (NaN);
}
private function init():void{
setType();
mx = (my = (mr = 0));
friction = 0.2;
restitution = 0;
categoryBits = 1;
maskBits = 0xFFFF;
groupIndex = 0;
}
public function clrMaskBit(_arg1:int):void{
maskBits = (maskBits & ~((1 << _arg1)));
}
public function invalidate():void{
_mass = Number.NaN;
_I = Number.NaN;
_cm = null;
}
public function setMaskBit(_arg1:int):void{
maskBits = (maskBits | (1 << _arg1));
}
public function getCM():V2{
if (_cm == null){
computeMass();
};
return (_cm);
}
protected function setType():void{
type = ShapeTypes.UNKNOWN;
}
public function clrCategoryBit(_arg1:int):void{
categoryBits = (categoryBits & ~((1 << _arg1)));
}
protected function computeMass():void{
}
public function getShapeClass():Class{
return (null);
}
public function set density(_arg1:Number):void{
_density = _arg1;
invalidate();
}
public function set restitution(_arg1:Number):void{
_restitution = ((_arg1)<0) ? 0 : ((_arg1)>1) ? 1 : _arg1;
}
public function get density():Number{
return (_density);
}
public function get restitution():Number{
return (_restitution);
}
public function setCategoryBit(_arg1:int):void{
categoryBits = (categoryBits | (1 << _arg1));
}
public function getMass():Number{
if (_density == 0){
return (0);
};
if (isNaN(_mass)){
computeMass();
};
return (_mass);
}
public function set friction(_arg1:Number):void{
_friction = ((_arg1)<0) ? 0 : ((_arg1)>1) ? 1 : _arg1;
}
public function get friction():Number{
return (_friction);
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 80
//BoxShape (de.polygonal.motor2.collision.shapes.BoxShape)
package de.polygonal.motor2.collision.shapes {
import flash.geom.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.math.*;
public class BoxShape extends ShapeSkeleton {
private var _r22:Number;
private var _mr:Number;
private var _r21:Number;
private var _r11:Number;
private var _r12:Number;
public function BoxShape(_arg1:BoxData, _arg2:RigidBody){
super(_arg1, _arg2);
setup(_arg1, _arg2);
}
override public function update():Boolean{
synced = false;
if (_mr == 0){
r11 = body.r11;
r12 = body.r12;
r21 = body.r21;
r22 = body.r22;
} else {
r11 = ((_r11 * body.r11) + (_r12 * body.r21));
r21 = ((_r21 * body.r11) + (_r22 * body.r21));
r12 = ((_r11 * body.r12) + (_r12 * body.r22));
r22 = ((_r21 * body.r12) + (_r22 * body.r22));
};
x = ((body.x + (body.r11 * mx)) + (body.r12 * my));
y = ((body.y + (body.r21 * mx)) + (body.r22 * my));
xmin = (xmax = x);
ymin = (ymax = y);
if (r11 > 0){
xmin = (xmin - (r11 * ex));
xmax = (xmax + (r11 * ex));
} else {
xmin = (xmin + (r11 * ex));
xmax = (xmax - (r11 * ex));
};
if (r12 > 0){
xmin = (xmin - (r12 * ey));
xmax = (xmax + (r12 * ey));
} else {
xmin = (xmin + (r12 * ey));
xmax = (xmax - (r12 * ey));
};
if (r21 > 0){
ymin = (ymin - (r21 * ex));
ymax = (ymax + (r21 * ex));
} else {
ymin = (ymin + (r21 * ex));
ymax = (ymax - (r21 * ex));
};
if (r22 > 0){
ymin = (ymin - (r22 * ey));
ymax = (ymax + (r22 * ey));
} else {
ymin = (ymin + (r22 * ey));
ymax = (ymax - (r22 * ey));
};
return (super.update());
}
override public function pointInside(_arg1:Point):Boolean{
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local2 = (_arg1.x - x);
_local3 = (_arg1.y - y);
_local4 = ((_local2 * r11) + (_local3 * r21));
if (_local4 > ex){
return (false);
};
if (_local4 < -(ex)){
return (false);
};
_local4 = ((_local2 * r12) + (_local3 * r22));
if (_local4 > ey){
return (false);
};
if (_local4 < -(ey)){
return (false);
};
return (true);
}
override public function toWorldSpace():void{
if (synced){
return;
};
synced = true;
var _local1:Number = (r11 * ex);
var _local2:Number = (r12 * ey);
var _local3:Number = (r21 * ex);
var _local4:Number = (r22 * ey);
v0.x = ((x + _local1) + _local2);
n0.x = r12;
v0.y = ((y + _local3) + _local4);
n0.y = r22;
v1.x = ((x - _local1) + _local2);
n1.x = -(r11);
v1.y = ((y - _local3) + _local4);
n1.y = -(r21);
v2.x = ((x - _local1) - _local2);
n2.x = -(r12);
v2.y = ((y - _local3) - _local4);
n2.y = -(r22);
v3.x = ((x + _local1) - _local2);
n3.x = r11;
v3.y = ((y + _local3) - _local4);
n3.y = r21;
}
override public function closestPoint(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
if (_arg2){
_local3 = (_arg1.x - (_arg2.x = x));
_local4 = (_arg1.y - (_arg2.y = y));
_local5 = ((_local3 * r11) + (_local4 * r21));
if (_local5 > ex){
_local5 = ex;
} else {
if (_local5 < -(ex)){
_local5 = -(ex);
};
};
_arg2.x = (_arg2.x + (r11 * _local5));
_arg2.y = (_arg2.y + (r21 * _local5));
_local5 = ((_local3 * r12) + (_local4 * r22));
if (_local5 > ey){
_local5 = ey;
} else {
if (_local5 < -(ey)){
_local5 = -(ey);
};
};
_arg2.x = (_arg2.x + (r12 * _local5));
_arg2.y = (_arg2.y + (r22 * _local5));
} else {
_local3 = (_arg1.x - (_arg1.x = x));
_local4 = (_arg1.y - (_arg1.y = y));
_local5 = ((_local3 * r11) + (_local4 * r21));
if (_local5 > ex){
_local5 = ex;
} else {
if (_local5 < -(ex)){
_local5 = -(ex);
};
};
_arg1.x = (_arg1.x + (r11 * _local5));
_arg1.y = (_arg1.y + (r21 * _local5));
_local5 = ((_local3 * r12) + (_local4 * r22));
if (_local5 > ey){
_local5 = ey;
} else {
if (_local5 < -(ey)){
_local5 = -(ey);
};
};
_arg1.x = (_arg1.x + (r12 * _local5));
_arg1.y = (_arg1.y + (r22 * _local5));
};
}
override public function triangulate():void{
triangleList = new Tri2(v0, v1, v3);
triangleList.next = new Tri2(v3, v1, v2);
}
override protected function setType():void{
type = ShapeTypes.BOX;
}
private function setup(_arg1:BoxData, _arg2:RigidBody):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Array;
var _local8:V2;
_local3 = _arg2.cx;
_local5 = _arg2.cy;
mx = (_arg1.mx - _local3);
my = (_arg1.my - _local5);
_local4 = Math.sin(_arg1.mr);
_local6 = Math.cos(_arg1.mr);
_r11 = _local6;
_r12 = -(_local4);
_r21 = _local4;
_r22 = _local6;
_mr = _arg1.mr;
ex = (_arg1.width * 0.5);
ey = (_arg1.height * 0.5);
xmin = -(ex);
xmax = ex;
xmin = -(ey);
ymax = ey;
radiusSq = ((ex * ex) + (ey * ey));
radius = Math.sqrt(radiusSq);
vertexCount = 4;
_local7 = new Array(vertexCount, true);
_local8 = (_local7[0] = new V2());
_local8.x = ((mx + (_r11 * ex)) + (_r12 * ey));
_local8.y = ((my + (_r21 * ex)) + (_r22 * ey));
_local8 = (_local7[1] = new V2());
_local8.x = ((mx + (_r11 * -(ex))) + (_r12 * ey));
_local8.y = ((my + (_r21 * -(ex))) + (_r22 * ey));
_local8 = (_local7[2] = new V2());
_local8.x = ((mx + (_r11 * -(ex))) + (_r12 * -(ey)));
_local8.y = ((my + (_r21 * -(ex))) + (_r22 * -(ey)));
_local8 = (_local7[3] = new V2());
_local8.x = ((mx + (_r11 * ex)) + (_r12 * -(ey)));
_local8.y = ((my + (_r21 * ex)) + (_r22 * -(ey)));
initPoly(_local7, vertexCount, true, mx, my);
_local8 = worldVertexChain;
v0 = _local8;
_local8 = _local8.next;
v1 = _local8;
_local8 = _local8.next;
v2 = _local8;
_local8 = _local8.next;
v3 = _local8;
_local8 = worldNormalChain;
n0 = _local8;
_local8 = _local8.next;
n1 = _local8;
_local8 = _local8.next;
n2 = _local8;
_local8 = _local8.next;
n3 = _local8;
var _local9:ConvexBSPNode = new ConvexBSPNode();
_local9.N = n0;
_local9.I = 0;
_local9.L = new ConvexBSPNode();
_local9.L.N = n3;
_local9.L.I = 3;
_local9.L.L = new ConvexBSPNode();
_local9.L.L.V = v3;
_local9.L.L.I = 3;
_local9.L.R = new ConvexBSPNode();
_local9.L.R.V = v0;
_local9.L.R.I = 0;
_local9.R = new ConvexBSPNode();
_local9.R.N = n1;
_local9.R.I = 1;
_local9.R.L = new ConvexBSPNode();
_local9.R.L.V = v1;
_local9.R.L.I = 1;
_local9.R.R = new ConvexBSPNode();
_local9.R.R.V = v2;
_local9.R.R.I = 2;
BSPNode = _local9;
update();
createProxy();
}
override public function getShapeOffset(_arg1:Point):void{
_arg1.x = ((mx * _r11) + (my * _r12));
_arg1.y = ((mx * _r21) + (my * _r22));
}
}
}//package de.polygonal.motor2.collision.shapes
Section 81
//CircleShape (de.polygonal.motor2.collision.shapes.CircleShape)
package de.polygonal.motor2.collision.shapes {
import flash.geom.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
public class CircleShape extends ShapeSkeleton {
public function CircleShape(_arg1:CircleData, _arg2:RigidBody){
super(_arg1, _arg2);
setup(_arg1, _arg2);
}
override public function update():Boolean{
synced = false;
x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my)));
y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my)));
xmin = (x - radius);
ymin = (y - radius);
xmax = (x + radius);
ymax = (y + radius);
return (super.update());
}
override public function pointInside(_arg1:Point):Boolean{
return (((((_arg1.x - x) * (_arg1.x - x)) + ((_arg1.y - y) * (_arg1.y - y))) <= radiusSq));
}
private function setup(_arg1:CircleData, _arg2:RigidBody):void{
var _local3:Number = _arg2.cx;
var _local4:Number = _arg2.cy;
mx = (_arg1.mx - _local3);
my = (_arg1.my - _local4);
x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my)));
y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my)));
radius = _arg1.radius;
radiusSq = (radius * radius);
ex = radius;
ey = radius;
xmin = -(ex);
xmax = ex;
xmin = -(ey);
ymax = ey;
vertexCount = 0;
update();
createProxy();
}
override protected function setType():void{
type = ShapeTypes.CIRCLE;
}
override public function closestPoint(_arg1:Point, _arg2:Point=null):void{
var _local3:Number = (_arg1.x - x);
var _local4:Number = (_arg1.y - y);
var _local5:Number = Math.sqrt(((_local3 * _local3) + (_local4 * _local4)));
if (_local5 > 1E-6){
if (_arg2){
_arg2.x = (x + ((_local3 / _local5) * radius));
_arg2.y = (y + ((_local4 / _local5) * radius));
} else {
_arg1.x = (x + ((_local3 / _local5) * radius));
_arg1.y = (y + ((_local4 / _local5) * radius));
};
} else {
if (_arg2){
_arg2.x = x;
_arg2.y = y;
} else {
_arg1.x = x;
_arg1.y = y;
};
};
}
}
}//package de.polygonal.motor2.collision.shapes
Section 82
//LineShape (de.polygonal.motor2.collision.shapes.LineShape)
package de.polygonal.motor2.collision.shapes {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.*;
import de.polygonal.motor2.math.*;
public class LineShape extends ShapeSkeleton {
public var infinite:Boolean;
public var doubleSided:Boolean;
public function LineShape(_arg1:LineData, _arg2:RigidBody){
super(_arg1, _arg2);
setup(_arg1, _arg2);
}
private function clip(_arg1:V2, _arg2:V2):Boolean{
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local3:V2 = worldVertexChain.edge.d;
var _local4:AABB2 = body.world.getWorldBounds();
var _local5:Number = -2147483647;
var _local6:Number = 2147483647;
if (((_local3.x < 0)) ? -(_local3.x) : _local3.x < 1E-6){
if (x < _local4.xmin){
return (false);
};
if (x > _local4.xmax){
return (false);
};
} else {
_local7 = ((_local4.xmin - x) / _local3.x);
_local8 = ((_local4.xmax - x) / _local3.x);
if (_local7 > _local8){
_local9 = _local7;
_local7 = _local8;
_local8 = _local9;
};
if (_local7 > _local5){
_local5 = _local7;
};
if (_local8 < _local6){
_local6 = _local8;
};
if (_local5 > _local6){
return (false);
};
};
if (((_local3.y < 0)) ? -(_local3.y) : _local3.y < 1E-6){
if (y < _local4.ymin){
return (false);
};
if (y > _local4.ymax){
return (false);
};
} else {
_local7 = ((_local4.ymin - y) / _local3.y);
_local8 = ((_local4.ymax - y) / _local3.y);
if (_local7 > _local8){
_local9 = _local7;
_local7 = _local8;
_local8 = _local9;
};
if (_local7 > _local5){
_local5 = _local7;
};
if (_local8 < _local6){
_local6 = _local8;
};
if (_local5 > _local6){
return (false);
};
};
_arg1.x = (x + (_local3.x * _local5));
_arg1.y = (y + (_local3.y * _local5));
_arg2.x = (x + (_local3.x * _local6));
_arg2.y = (y + (_local3.y * _local6));
return (true);
}
override public function toWorldSpace():void{
var _local1:V2 = worldVertexChain;
var _local2:V2 = modelVertexChain;
var _local3:V2 = worldNormalChain;
var _local4:V2 = modelNormalChain;
var _local5:Number = body.x;
var _local6:Number = body.y;
_local1.x = (((r11 * _local2.x) + (r12 * _local2.y)) + _local5);
_local1.y = (((r21 * _local2.x) + (r22 * _local2.y)) + _local6);
_local3.x = ((r11 * _local4.x) + (r12 * _local4.y));
_local3.y = ((r21 * _local4.x) + (r22 * _local4.y));
_local1 = _local1.next;
_local3 = _local3.next;
_local2 = _local2.next;
_local4 = _local4.next;
_local1.x = (((r11 * _local2.x) + (r12 * _local2.y)) + _local5);
_local1.y = (((r21 * _local2.x) + (r22 * _local2.y)) + _local6);
_local3.x = ((r11 * _local4.x) + (r12 * _local4.y));
_local3.y = ((r21 * _local4.x) + (r22 * _local4.y));
}
override public function update():Boolean{
var _local1:V2;
var _local2:V2;
var _local3:Number;
var _local4:Number;
synced = false;
x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my)));
y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my)));
if (infinite){
_local1 = new V2();
_local2 = new V2();
if (clip(_local1, _local2)){
if (_local1.x < _local2.x){
xmin = _local1.x;
xmax = _local2.x;
} else {
xmin = _local2.x;
xmax = _local1.x;
};
if (_local1.y < _local2.y){
ymin = _local1.y;
ymax = _local2.y;
} else {
ymin = _local2.y;
ymax = _local1.y;
};
if ((xmax - xmin) < Constants.k_minLineAABBThickness){
_local3 = (xmax - xmin);
xmin = (xmin - ((Constants.k_minLineAABBThickness * 0.5) - _local3));
xmax = (xmax + ((Constants.k_minLineAABBThickness * 0.5) - _local3));
};
if ((ymax - ymin) < Constants.k_minLineAABBThickness){
_local4 = (ymax - ymin);
ymin = (ymin - ((Constants.k_minLineAABBThickness * 0.5) - _local4));
ymax = (ymax + ((Constants.k_minLineAABBThickness * 0.5) - _local4));
};
xmin = int((xmin + 0.5));
ymin = int((ymin + 0.5));
xmax = int(xmax);
ymax = int(ymax);
} else {
xmin = (body.world.getWorldBounds().xmin - 1);
};
} else {
xmin = (x - ex);
ymin = (y - ey);
xmax = (x + ex);
ymax = (y + ey);
};
return (super.update());
}
override protected function setType():void{
type = ShapeTypes.LINE;
}
private function setup(_arg1:LineData, _arg2:RigidBody):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Array;
var _local8:V2;
infinite = _arg1.infinite;
doubleSided = _arg1.doubleSided;
_local3 = _arg2.cx;
_local5 = _arg2.cy;
mx = (_arg1.mx - _local3);
my = (_arg1.my - _local5);
x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my)));
y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my)));
_local4 = (_arg1.b.x - _arg1.a.x);
_local6 = (_arg1.b.y - _arg1.a.y);
var _local9:Number = Math.sqrt(((_local4 * _local4) + (_local6 * _local6)));
vertexCount = 2;
_local7 = new Array(vertexCount);
_local8 = (_local7[0] = new V2());
_local8.x = ((mx + (r11 * _arg1.a.x)) + (r12 * _arg1.a.y));
_local8.y = ((my + (r21 * _arg1.a.x)) + (r22 * _arg1.a.y));
_local8 = (_local7[1] = new V2());
_local8.x = ((mx + (r11 * _arg1.b.x)) + (r12 * _arg1.b.y));
_local8.y = ((my + (r21 * _arg1.b.x)) + (r22 * _arg1.b.y));
initPoly(_local7, vertexCount, true);
radius = (_local9 / 2);
radiusSq = (radius * radius);
toWorldSpace();
if (!infinite){
_local8 = worldVertexChain;
xmin = Math.min(_local8.x, _local8.next.x);
xmax = Math.max(_local8.x, _local8.next.x);
ymin = Math.min(_local8.y, _local8.next.y);
ymax = Math.max(_local8.y, _local8.next.y);
xmin = int((xmin + 0.5));
ymin = int((ymin + 0.5));
xmax = int(xmax);
ymax = int(ymax);
ex = ((xmax - xmin) / 2);
ey = ((ymax - ymin) / 2);
if ((ex * 2) < Constants.k_minLineAABBThickness){
ex = (ex + ((Constants.k_minLineAABBThickness * 0.5) - ex));
};
if (ey < Constants.k_minLineAABBThickness){
ey = (ey + ((Constants.k_minLineAABBThickness * 0.5) - ey));
};
} else {
ex = NaN;
ey = NaN;
};
_local4 = (worldVertexChain.next.x - worldVertexChain.x);
_local6 = (worldVertexChain.next.y - worldVertexChain.y);
_local9 = Math.sqrt(((_local4 * _local4) + (_local6 * _local6)));
_local4 = (_local4 / _local9);
_local6 = (_local6 / _local9);
d = ((worldNormalChain.x * worldVertexChain.x) + (worldNormalChain.y * worldVertexChain.y));
update();
createProxy();
}
}
}//package de.polygonal.motor2.collision.shapes
Section 83
//PolyShape (de.polygonal.motor2.collision.shapes.PolyShape)
package de.polygonal.motor2.collision.shapes {
import flash.geom.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.math.*;
import de.polygonal.ds.*;
public class PolyShape extends ShapeSkeleton {
private var _x:Number;
private var _y:Number;
private var _triCenter:V2;
private var _r21:Number;
private var _r11:Number;
private var _r12:Number;
private var _r22:Number;
public function PolyShape(_arg1:PolyData, _arg2:RigidBody){
super(_arg1, _arg2);
setup(_arg1, _arg2);
}
override public function update():Boolean{
var _local1:Number;
synced = false;
x = ((body.x + ((r11 = body.r11) * mx)) + ((r12 = body.r12) * my));
y = ((body.y + ((r21 = body.r21) * mx)) + ((r22 = body.r22) * my));
xmin = (xmax = ((x + (r11 * _x)) + (r12 * _y)));
ymin = (ymax = ((y + (r21 * _x)) + (r22 * _y)));
_local1 = ((_r11 * r11) + (_r12 * r21));
if (_local1 > 0){
xmin = (xmin + (_local1 * -(ex)));
xmax = (xmax + (_local1 * ex));
} else {
xmin = (xmin + (_local1 * ex));
xmax = (xmax + (_local1 * -(ex)));
};
_local1 = ((_r11 * r12) + (_r12 * r22));
if (_local1 > 0){
xmin = (xmin + (_local1 * -(ey)));
xmax = (xmax + (_local1 * ey));
} else {
xmin = (xmin + (_local1 * ey));
xmax = (xmax + (_local1 * -(ey)));
};
_local1 = ((_r21 * r11) + (_r22 * r21));
if (_local1 > 0){
ymin = (ymin + (_local1 * -(ex)));
ymax = (ymax + (_local1 * ex));
} else {
ymin = (ymin + (_local1 * ex));
ymax = (ymax + (_local1 * -(ex)));
};
_local1 = ((_r21 * r12) + (_r22 * r22));
if (_local1 > 0){
ymin = (ymin + (_local1 * -(ey)));
ymax = (ymax + (_local1 * ey));
} else {
ymin = (ymin + (_local1 * ey));
ymax = (ymax + (_local1 * -(ey)));
};
if (_triCenter){
_triCenter.x = x;
_triCenter.y = y;
};
return (super.update());
}
override public function pointInside(_arg1:Point):Boolean{
var _local2:Number = _arg1.x;
var _local3:Number = _arg1.y;
var _local4:Number = ((r11 * (_local2 - this.x)) + (r21 * (_local3 - this.y)));
var _local5:Number = ((r12 * (_local2 - this.x)) + (r22 * (_local3 - this.y)));
var _local6:V2 = modelVertexChain;
var _local7:V2 = modelNormalChain;
while (_local6) {
if ((((_local4 - _local6.x) * _local7.x) + ((_local5 - _local6.y) * _local7.y)) > 0){
return (false);
};
if (_local6.isTail){
break;
};
_local7 = _local7.next;
_local6 = _local6.next;
};
return (true);
}
override public function triangulate():void{
var _local2:Tri2;
_triCenter = new V2(x, y);
var _local1:V2 = worldVertexChain;
while (true) {
_local2 = new Tri2(_local1, _local1.next, _triCenter);
_local2.next = triangleList;
triangleList = _local2;
if (_local1.isTail){
break;
};
_local1 = _local1.next;
};
}
override public function toWorldSpace():void{
var _local1:V2 = worldVertexChain;
var _local2:V2 = modelVertexChain;
var _local3:V2 = worldNormalChain;
var _local4:V2 = modelNormalChain;
var _local5:Number = body.x;
var _local6:Number = body.y;
while (true) {
_local1.x = (((r11 * _local2.x) + (r12 * _local2.y)) + _local5);
_local1.y = (((r21 * _local2.x) + (r22 * _local2.y)) + _local6);
_local3.x = ((r11 * _local4.x) + (r12 * _local4.y));
_local3.y = ((r21 * _local4.x) + (r22 * _local4.y));
if (_local1.isTail){
break;
};
_local1 = _local1.next;
_local2 = _local2.next;
_local3 = _local3.next;
_local4 = _local4.next;
};
}
public function getWorldOBB():V2{
var _local1:Number = (_r11 * ex);
var _local2:Number = (_r21 * ex);
var _local3:Number = (_r12 * ey);
var _local4:Number = (_r22 * ey);
var _local5:V2 = new V2((((_x + mx) + _local1) - _local3), (((_y + my) + _local2) - _local4));
var _local6:V2 = new V2((((_x + mx) - _local1) - _local3), (((_y + my) - _local2) - _local4));
var _local7:V2 = new V2((((_x + mx) - _local1) + _local3), (((_y + my) - _local2) + _local4));
var _local8:V2 = new V2((((_x + mx) + _local1) + _local3), (((_y + my) + _local2) + _local4));
_local5.next = _local6;
_local6.next = _local7;
_local7.next = _local8;
return (_local5);
}
override public function closestPoint(_arg1:Point, _arg2:Point=null):void{
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 _local14:Number;
var _local15:Number;
var _local16:V2;
var _local17:V2;
var _local13:Number = -1;
_local6 = ((r11 * (x - this.x)) + (r21 * (y - this.y)));
_local11 = ((r12 * (x - this.x)) + (r22 * (y - this.y)));
_local16 = modelVertexChain;
_local17 = _local16.next;
while (true) {
_local3 = (_local17.x - _local16.x);
_local8 = (_local17.y - _local16.y);
_local4 = (_local6 - _local16.x);
_local9 = (_local11 - _local16.y);
if (((_local4 * _local3) + (_local9 * _local8)) > 0){
_local15 = (((_local4 * _local3) + (_local9 * _local8)) / ((_local3 * _local3) + (_local8 * _local8)));
_local15 = ((_local15)<0) ? 0 : ((_local15)>1) ? 1 : _local15;
_local5 = (_local16.x + (_local3 * _local15));
_local10 = (_local16.y + (_local8 * _local15));
_local14 = (((_local6 - _local5) * (_local6 - _local5)) + ((_local11 - _local10) * (_local11 - _local10)));
if ((((_local14 < _local13)) || ((_local13 < 0)))){
_local13 = _local14;
_local7 = ((this.x + (r11 * _local5)) + (r12 * _local10));
_local12 = ((this.y + (r21 * _local5)) + (r22 * _local10));
};
};
if (_local16.isTail){
break;
};
_local16 = _local17;
_local17 = _local17.next;
};
if (_arg2){
_arg2.x = _local7;
_arg2.y = _local12;
} else {
_arg1.x = _local7;
_arg1.y = _local12;
};
}
override protected function setType():void{
type = ShapeTypes.POLY;
}
private function setup(_arg1:PolyData, _arg2:RigidBody):void{
var xLocalCenter:Number;
var xt:Number;
var s:Number;
var yLocalCenter:Number;
var yt:Number;
var c:Number;
var verts:Array;
var modelVertexList:Array;
var i:int;
var r:Number;
var v:V2;
var pos:V2;
var ext:V2;
var node:ConvexBSPNode;
var sd = _arg1;
var rb = _arg2;
xLocalCenter = rb.cx;
yLocalCenter = rb.cy;
mx = (sd.mx - xLocalCenter);
my = (sd.my - yLocalCenter);
s = Math.sin(sd.mr);
c = Math.cos(sd.mr);
r11 = c;
r12 = -(s);
r21 = s;
r22 = c;
radius = sd.radius;
radiusSq = (radius * radius);
vertexCount = sd.getVertexCount();
modelVertexList = new Array(vertexCount, true);
verts = sd.getVertices();
i = 0;
while (i < vertexCount) {
v = verts[i];
xt = ((mx + (r11 * v.x)) + (r12 * v.y));
yt = ((my + (r21 * v.x)) + (r22 * v.y));
modelVertexList[i] = new V2(xt, yt);
i = (i + 1);
};
initPoly(modelVertexList, vertexCount, sd.isRegular(), mx, my);
pos = new V2();
ext = new V2();
r = computeMinAreaRect(pos, ext);
_x = (pos.x - mx);
ex = ext.x;
_y = (pos.y - my);
ey = ext.y;
s = Math.sin(r);
c = Math.cos(r);
_r11 = c;
_r12 = -(s);
_r21 = s;
_r22 = c;
if (vertexCount == 3){
node = new ConvexBSPNode();
node.I = 0;
node.N = worldNormalChain;
node.L = new ConvexBSPNode();
node.L.I = 2;
node.L.N = worldNormalChain.prev;
node.L.L = new ConvexBSPNode();
node.L.L.I = 2;
node.L.L.V = worldVertexChain.prev;
node.L.R = new ConvexBSPNode();
node.L.R.I = 0;
node.L.R.V = worldVertexChain;
node.R = new ConvexBSPNode();
node.R.I = 1;
node.R.N = worldNormalChain.next;
node.R.L = new ConvexBSPNode();
node.R.L.I = 1;
node.R.L.V = worldVertexChain.next;
node.R.R = new ConvexBSPNode();
node.R.R.I = 2;
node.R.R.V = worldVertexChain.prev;
BSPNode = node;
} else {
BSPNode = ConvexBSP.createBSP(vertexCount, modelNormalChain.toArray(), extractEdgeList(modelVertexChain));
BinaryTreeNode.inorder(BSPNode, function (_arg1:ConvexBSPNode):void{
_arg1.N = worldNormalChain.getAt(_arg1.I);
_arg1.V = worldVertexChain.getAt(_arg1.I);
});
};
update();
createProxy();
}
}
}//package de.polygonal.motor2.collision.shapes
Section 84
//ShapeSkeleton (de.polygonal.motor2.collision.shapes.ShapeSkeleton)
package de.polygonal.motor2.collision.shapes {
import flash.geom.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.nbody.*;
public class ShapeSkeleton {
public var maskBits:int;
public var r12:Number;
public var userData;
public var broadPhase:BroadPhase;
public var r11:Number;
public var proxyId:int;
public var worldNormalChain:V2;
public var r21:Number;
public var categoryBits:int;
public var modelNormalChain:V2;
public var r22:Number;
public var type:int;
public var ymin:Number;
public var offsets:Array;
public var ymax:Number;
public var regularShape:Boolean;
public var restitution:Number;
public var d:Number;
public var x:Number;
public var y:Number;
public var synced:Boolean;// = false
public var v1:V2;
public var v2:V2;
public var v3:V2;
public var v0:V2;
public var n0:V2;
public var n1:V2;
public var n2:V2;
public var n3:V2;
public var worldVertexChain:V2;
public var area:Number;
public var radiusSq:Number;
public var radius:Number;
public var groupIndex:int;
public var modelVertexChain:V2;
public var body:RigidBody;
public var mx:Number;
public var my:Number;
public var ex:Number;
public var ey:Number;
public var BSPNode:ConvexBSPNode;
public var triangleList:Tri2;
public var vertexCount:int;
public var xmin:Number;
public var xmax:Number;
public var next:ShapeSkeleton;
public var friction:Number;
public function ShapeSkeleton(_arg1:ShapeData, _arg2:RigidBody){
friction = _arg1.friction;
restitution = _arg1.restitution;
area = _arg1.area;
body = _arg2;
groupIndex = _arg1.groupIndex;
categoryBits = _arg1.categoryBits;
maskBits = _arg1.maskBits;
setType();
broadPhase = body.world.getBroadPhase();
proxyId = Proxy.NULL_PROXY;
}
public function refreshProxy():void{
if (proxyId != Proxy.NULL_PROXY){
broadPhase.destroyProxy(proxyId);
createProxy();
};
}
public function getShapeOffset(_arg1:Point):void{
_arg1.x = mx;
_arg1.y = my;
}
public function toWorldSpace():void{
}
public function deconstruct():void{
BSPNode = null;
modelVertexChain = (modelNormalChain = (worldVertexChain = (worldNormalChain = null)));
offsets = null;
triangleList = null;
if (proxyId != Proxy.NULL_PROXY){
broadPhase.destroyProxy(proxyId);
proxyId = Proxy.NULL_PROXY;
};
broadPhase = null;
}
public function extractEdgeList(_arg1:V2):Array{
var _local2:V2 = _arg1;
var _local3:Array = new Array(vertexCount, true);
var _local4:int;
while (_local4 < vertexCount) {
_local3[_local4] = _local2.edge.d;
_local2 = _local2.next;
_local4++;
};
return (_local3);
}
public function closestPoint(_arg1:Point, _arg2:Point=null):void{
}
protected function setType():void{
type = ShapeTypes.UNKNOWN;
}
public function pointInside(_arg1:Point):Boolean{
return (false);
}
public function update():Boolean{
if (proxyId == Proxy.NULL_PROXY){
return (false);
};
if (broadPhase.insideBounds(xmin, ymin, xmax, ymax)){
broadPhase.moveProxy(proxyId);
return (true);
};
return (false);
}
protected function computeMinAreaRect(_arg1:V2, _arg2:V2):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;
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:V2;
var _local30:V2;
var _local31:V2;
var _local32:V2;
var _local33:int;
var _local34:Number;
var _local3:Number = Number.MAX_VALUE;
_local29 = modelVertexChain;
_local30 = modelVertexChain.next;
_local31 = modelVertexChain;
_local33 = 0;
while (_local33 < vertexCount) {
_local17 = (_local30.x - _local29.x);
_local20 = (_local30.y - _local29.y);
_local28 = Math.sqrt(((_local17 * _local17) + (_local20 * _local20)));
_local17 = (_local17 / _local28);
_local20 = (_local20 / _local28);
_local18 = -(_local20);
_local21 = _local17;
_local15 = ((_local31.x * _local17) + (_local31.y * _local20));
_local13 = _local15;
_local16 = ((_local31.x * _local18) + (_local31.y * _local21));
_local14 = _local16;
_local32 = modelVertexChain.next;
while (true) {
_local27 = ((_local32.x * _local17) + (_local32.y * _local20));
if (_local27 < _local13){
_local13 = _local27;
} else {
if (_local27 > _local15){
_local15 = _local27;
};
};
_local27 = ((_local32.x * _local18) + (_local32.y * _local21));
if (_local27 < _local14){
_local14 = _local27;
} else {
if (_local27 > _local16){
_local16 = _local27;
};
};
if (_local32.isTail){
break;
};
_local32 = _local32.next;
};
_local4 = ((_local15 - _local13) * (_local16 - _local14));
if (_local4 < _local3){
_local3 = _local4;
_local5 = (_local17 * _local13);
_local6 = (_local20 * _local13);
_local7 = (_local17 * _local15);
_local8 = (_local20 * _local15);
_local9 = (_local18 * _local14);
_local10 = (_local21 * _local14);
_local11 = (_local18 * _local16);
_local12 = (_local21 * _local16);
};
_local29 = _local30;
_local30 = _local30.next;
_local33++;
};
_local19 = (_local7 - _local5);
_local22 = (_local8 - _local6);
_local25 = Math.sqrt(((_local19 * _local19) + (_local22 * _local22)));
_local23 = Math.atan2(_local22, _local19);
_local19 = (_local11 - _local9);
_local22 = (_local12 - _local10);
_local26 = Math.sqrt(((_local19 * _local19) + (_local22 * _local22)));
_local24 = Math.atan2(_local22, _local19);
if (((_local24 < 0)) ? -(_local24) : _local24 < ((_local23 < 0)) ? -(_local23) : _local23){
_local34 = _local24;
_arg2.x = (_local26 / 2);
_arg2.y = (_local25 / 2);
} else {
_local34 = _local23;
_arg2.x = (_local25 / 2);
_arg2.y = (_local26 / 2);
};
_arg1.x = ((_local5 + _local9) + (((_local7 + _local11) - (_local5 + _local9)) / 2));
_arg1.y = ((_local6 + _local10) + (((_local8 + _local12) - (_local6 + _local10)) / 2));
return (_local34);
}
public function triangulate():void{
}
protected function createProxy():void{
if (((broadPhase) && (broadPhase.insideBounds(xmin, ymin, xmax, ymax)))){
proxyId = broadPhase.createProxy(this);
} else {
proxyId = Proxy.NULL_PROXY;
body.freeze();
};
}
protected function initPoly(_arg1:Array, _arg2:int, _arg3:Boolean, _arg4:Number=0, _arg5:Number=0):void{
var _local6:int;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:V2;
var _local13:V2;
var _local14:V2;
var _local15:V2;
var _local16:V2;
var _local17:V2;
var _local18:V2;
var _local19:E2;
var _local21:Number;
var _local22:Number;
var _local23:Number;
regularShape = _arg3;
_local15 = _arg1[0];
modelVertexChain = _local15;
_local16 = new V2();
worldVertexChain = _local16;
_local15.index = 0;
_local16.index = 0;
_local15.isHead = true;
_local16.isHead = true;
_local17 = new V2();
modelNormalChain = _local17;
_local18 = new V2();
worldNormalChain = _local18;
_local17.index = 0;
_local18.index = 0;
_local17.isHead = true;
_local18.isHead = true;
_local6 = 1;
while (_local6 < _arg2) {
_local12 = _arg1[_local6];
_local13 = _local15;
_local14 = _local12;
_local14.index = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local15 = _local15.next;
_local13 = _local16;
_local14 = new V2();
_local14.index = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local16 = _local16.next;
_local13 = _local17;
_local14 = new V2();
_local14.index = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local17 = _local17.next;
_local13 = _local18;
_local14 = new V2();
_local14.index = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local18 = _local18.next;
_local6++;
};
_local15.isTail = true;
_local15.next = modelVertexChain;
modelVertexChain.prev = _local15;
_local16.isTail = true;
_local16.next = worldVertexChain;
worldVertexChain.prev = _local16;
_local17.isTail = true;
_local17.next = modelNormalChain;
modelNormalChain.prev = _local17;
_local18.isTail = true;
_local18.next = worldNormalChain;
worldNormalChain.prev = _local18;
var _local20:Array = new Array(_arg2, true);
offsets = new Array(_arg2, true);
_local18 = worldNormalChain;
_local16 = worldVertexChain;
_local17 = modelNormalChain;
_local13 = modelVertexChain;
_local14 = _local13.next;
_local6 = 0;
while (_local6 < _arg2) {
_local7 = (_local14.x - _local13.x);
_local8 = (_local14.y - _local13.y);
_local11 = Math.sqrt(((_local7 * _local7) + (_local8 * _local8)));
_local7 = (_local7 / _local11);
_local8 = (_local8 / _local11);
_local20[_local6] = new V2(_local7, _local8);
_local9 = _local8;
_local10 = -(_local7);
_local17.x = _local9;
_local17.y = _local10;
_local17 = _local17.next;
_local21 = ((body.cx + _local13.x) + ((_local14.x - _local13.x) * 0.5));
_local22 = ((body.cy + _local13.y) + ((_local14.y - _local13.y) * 0.5));
_local23 = (((_local21 - _arg4) * _local9) + ((_local22 - _arg5) * _local10));
if (!_arg3){
offsets[_local6] = new V2((_local21 + (-(_local9) * _local23)), (_local22 + (-(_local10) * _local23)));
};
_local19 = new E2();
_local19.v = _local13;
_local19.w = _local13.next;
_local19.n = _local17;
_local19.d = _local20[_local6];
_local19.mag = _local11;
_local13.edge = _local19;
_local13 = _local14;
_local14 = _local13.next;
_local19 = new E2();
_local19.v = _local16;
_local19.w = _local16.next;
_local19.n = _local18;
_local19.d = _local20[_local6];
_local19.mag = _local11;
_local16.edge = _local19;
_local16 = _local16.next;
_local18 = _local18.next;
_local6++;
};
_local12 = modelVertexChain;
_local6 = 0;
while (_local6 < _arg2) {
_local12.edge.next = _local12.next.edge;
_local12.edge.prev = _local12.prev.edge;
_local12 = _local12.next;
_local6++;
};
_local12 = worldVertexChain;
_local6 = 0;
while (_local6 < _arg2) {
_local12.edge.next = _local12.next.edge;
_local12.edge.prev = _local12.prev.edge;
_local12 = _local12.next;
_local6++;
};
}
}
}//package de.polygonal.motor2.collision.shapes
Section 85
//ShapeTypes (de.polygonal.motor2.collision.shapes.ShapeTypes)
package de.polygonal.motor2.collision.shapes {
public class ShapeTypes {
public static const UNKNOWN:int = 0;
public static const BOX:int = 2;
public static const POLY:int = 3;
public static const CIRCLE:int = 1;
public static const SHAPE_COUNT:int = 5;
public static const LINE:int = 4;
public static function getName(_arg1:int):String{
switch (_arg1){
case 1:
return ("CIRCLE");
case 2:
return ("BOX");
case 3:
return ("POLY");
case 4:
return ("LINE");
};
return ("UNKNOWN");
}
}
}//package de.polygonal.motor2.collision.shapes
Section 86
//BoxCircleContact (de.polygonal.motor2.dynamics.contact.generator.BoxCircleContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class BoxCircleContact extends ConvexCircleContact {
private static const COLLIDE_BOX_CIRCLE:CollideBoxCircle = new CollideBoxCircle();
public function BoxCircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
return (COLLIDE_BOX_CIRCLE);
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 87
//BoxContact (de.polygonal.motor2.dynamics.contact.generator.BoxContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class BoxContact extends ConvexContact {
public var sepAxisId:int;
private static const COLLIDE_BOX:CollideBox = new CollideBox();
public function BoxContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
return (COLLIDE_BOX);
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 88
//BoxLineContact (de.polygonal.motor2.dynamics.contact.generator.BoxLineContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class BoxLineContact extends ConvexContact {
public var sid:int;// = -1
private static const COLLIDE_BOX_LINE_DS:CollideBoxLineDoubleSided = new CollideBoxLineDoubleSided();
private static const COLLIDE_BOX_LINE_SS:CollideBoxLineSingleSided = new CollideBoxLineSingleSided();
private static const COLLIDE_BOX_PLANE_DS:CollideBoxPlaneDoubleSided = new CollideBoxPlaneDoubleSided();
private static const COLLIDE_BOX_PLANE_SS:CollideBoxPlaneSingleSided = new CollideBoxPlaneSingleSided();
public function BoxLineContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
var _local1:LineShape = LineShape(shape2);
if (_local1.infinite){
if (_local1.doubleSided){
return (COLLIDE_BOX_PLANE_DS);
};
return (COLLIDE_BOX_PLANE_SS);
};
if (_local1.doubleSided){
return (COLLIDE_BOX_LINE_DS);
};
return (COLLIDE_BOX_LINE_SS);
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 89
//CircleContact (de.polygonal.motor2.dynamics.contact.generator.CircleContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.collision.pairwise.*;
public class CircleContact extends Contact {
public var manifold:Manifold;
private static const COLLIDE_CIRCLE:CollideCircle = new CollideCircle();
public function CircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
manifold = (manifolds[0] = new Manifold());
manifold.c0.Pn = 0;
manifold.c0.Pt = 0;
}
override public function evaluate():void{
_collider.collide(manifold, shape1, shape2, null);
manifoldCount = ((manifold.pointCount > 0)) ? 1 : 0;
}
override protected function getCollider():Collider{
return (COLLIDE_CIRCLE);
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 90
//CircleLineContact (de.polygonal.motor2.dynamics.contact.generator.CircleLineContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.collision.pairwise.*;
public class CircleLineContact extends Contact {
private var _m1Cp1:ContactPoint;
private var _Pt0:Number;
public var manifold:Manifold;
private var _Pn0:Number;
private var _id0:uint;
private static const COLLIDE_CIRCLE_PLANE_DS:CollideCirclePlaneDoubleSided = new CollideCirclePlaneDoubleSided();
private static const COLLIDE_CIRCLE_PLANE_SS:CollideCirclePlaneSingleSided = new CollideCirclePlaneSingleSided();
private static const COLLIDE_CIRCLE_LINE_DS:CollideCircleLineDoubleSided = new CollideCircleLineDoubleSided();
private static const COLLIDE_CIRCLE_LINE_SS:CollideCircleLineSingleSided = new CollideCircleLineSingleSided();
public function CircleLineContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
manifold = (manifolds[0] = new Manifold());
_m1Cp1 = manifold.c0;
manifold.c0.Pn = 0;
manifold.c0.Pt = 0;
}
override protected function getCollider():Collider{
var _local1:LineShape = LineShape(shape2);
if (_local1.infinite){
if (_local1.doubleSided){
return (COLLIDE_CIRCLE_PLANE_DS);
};
return (COLLIDE_CIRCLE_PLANE_SS);
};
if (_local1.doubleSided){
return (COLLIDE_CIRCLE_LINE_DS);
};
return (COLLIDE_CIRCLE_LINE_SS);
}
override public function evaluate():void{
var _local1:int;
var _local2:int;
if (World.doWarmStarting){
_m1Cp1.matched = false;
_local1 = manifold.pointCount;
if (_local1 > 0){
_id0 = _m1Cp1.id.key;
_Pn0 = _m1Cp1.Pn;
_Pt0 = _m1Cp1.Pt;
};
_collider.collide(manifold, shape1, shape2, this);
_local2 = manifold.pointCount;
if (_local2 > 0){
manifoldCount = 1;
} else {
manifoldCount = 0;
return;
};
_m1Cp1.Pn = 0;
_m1Cp1.Pt = 0;
if ((((_local1 == 1)) && ((_local2 == 1)))){
if (_m1Cp1.id.key == _id0){
_m1Cp1.Pn = _Pn0;
_m1Cp1.Pt = _Pt0;
_m1Cp1.matched = true;
};
};
} else {
_collider.collide(manifold, shape1, shape2, this);
manifoldCount = ((manifold.pointCount > 0)) ? 1 : 0;
};
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 91
//ConvexCircleContact (de.polygonal.motor2.dynamics.contact.generator.ConvexCircleContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.contact.*;
public class ConvexCircleContact extends Contact {
private var _m1Cp1:ContactPoint;
public var d:V2;
private var _Pt0:Number;
public var manifold:Manifold;
private var _Pn0:Number;
private var _id0:uint;
public var p:V2;
public function ConvexCircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
manifold = (manifolds[0] = new Manifold());
_m1Cp1 = manifold.c0;
p = _arg1.worldVertexChain;
d = _arg1.worldNormalChain;
}
override public function evaluate():void{
var _local1:int;
var _local2:int;
if (!shape1.synced){
shape1.toWorldSpace();
};
if (World.doWarmStarting){
_m1Cp1.matched = false;
_local1 = manifold.pointCount;
if (_local1 > 0){
_id0 = _m1Cp1.id.key;
_Pn0 = _m1Cp1.Pn;
_Pt0 = _m1Cp1.Pt;
};
_collider.collide(manifold, shape1, shape2, this);
_local2 = manifold.pointCount;
if (_local2 > 0){
manifoldCount = 1;
} else {
manifoldCount = 0;
return;
};
_m1Cp1.Pn = 0;
_m1Cp1.Pt = 0;
if ((((_local1 == 1)) && ((_local2 == 1)))){
if (_m1Cp1.id.key == _id0){
_m1Cp1.Pn = _Pn0;
_m1Cp1.Pt = _Pt0;
_m1Cp1.matched = true;
};
};
} else {
_collider.collide(manifold, shape1, shape2, this);
if (manifold.pointCount > 0){
manifoldCount = 1;
} else {
manifoldCount = 0;
return;
};
};
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 92
//ConvexContact (de.polygonal.motor2.dynamics.contact.generator.ConvexContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.*;
import de.polygonal.motor2.dynamics.contact.*;
public class ConvexContact extends Contact {
private var _m1Cp1:ContactPoint;
private var _Pn0_1:Number;
private var _Pn0_2:Number;
private var _Pt0_2:Number;
private var _id0_1:uint;
private var _m1Cp2:ContactPoint;
public var manifold:Manifold;
private var _id0_2:uint;
private var _Pt0_1:Number;
public function ConvexContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
manifold = (manifolds[0] = new Manifold());
_m1Cp1 = manifold.c0;
_m1Cp2 = manifold.c1;
}
override public function evaluate():void{
var _local1:int;
var _local2:int;
var _local3:int;
if (!shape1.synced){
shape1.toWorldSpace();
};
if (!shape2.synced){
shape2.toWorldSpace();
};
if (World.doWarmStarting){
_m1Cp1.matched = false;
_m1Cp2.matched = false;
_local1 = manifold.pointCount;
if (_local1 > 0){
_id0_1 = _m1Cp1.id.key;
_Pn0_1 = _m1Cp1.Pn;
_Pt0_1 = _m1Cp1.Pt;
if (_local1 > 1){
_id0_2 = _m1Cp2.id.key;
_Pn0_2 = _m1Cp2.Pn;
_Pt0_2 = _m1Cp2.Pt;
};
};
_collider.collide(manifold, shape1, shape2, this);
_local2 = manifold.pointCount;
if (_local2 > 0){
manifoldCount = 1;
} else {
manifoldCount = 0;
return;
};
_m1Cp1.Pn = 0;
_m1Cp1.Pt = 0;
_m1Cp2.Pn = 0;
_m1Cp2.Pt = 0;
if (_local2 == 1){
if (_local1 == 1){
if (_m1Cp1.id.key == _id0_1){
_m1Cp1.Pn = _Pn0_1;
_m1Cp1.Pt = _Pt0_1;
_m1Cp1.matched = true;
};
} else {
if (_local1 == 2){
_local3 = _m1Cp1.id.key;
if (_local3 == _id0_1){
_m1Cp1.Pn = _Pn0_1;
_m1Cp1.Pt = _Pt0_1;
_m1Cp1.matched = true;
} else {
if (_local3 == _id0_2){
};
};
_m1Cp1.Pn = _Pn0_2;
_m1Cp1.Pt = _Pn0_2;
_m1Cp1.matched = true;
};
};
} else {
if (_local2 == 2){
if (_local1 == 1){
if (_m1Cp1.id.key == _id0_1){
_m1Cp1.Pn = _Pn0_1;
_m1Cp1.Pt = _Pt0_1;
_m1Cp1.matched = true;
} else {
if (_m1Cp2.id.key == _id0_1){
_m1Cp2.Pn = _Pn0_1;
_m1Cp2.Pt = _Pt0_1;
_m1Cp2.matched = true;
};
};
} else {
if (_local1 == 2){
if (_m1Cp1.id.key == _id0_1){
_m1Cp1.Pn = _Pn0_1;
_m1Cp1.Pt = _Pt0_1;
_m1Cp1.matched = true;
if (_m1Cp2.id.key == _id0_2){
_m1Cp2.Pn = _Pn0_2;
_m1Cp2.Pt = _Pt0_2;
_m1Cp2.matched = true;
return;
};
} else {
if (_m1Cp1.id.key == _id0_2){
_m1Cp1.Pn = _Pn0_2;
_m1Cp1.Pt = _Pt0_2;
_m1Cp1.matched = true;
if (_m1Cp2.id.key == _id0_1){
_m1Cp2.Pn = _Pn0_1;
_m1Cp2.Pt = _Pt0_1;
_m1Cp2.matched = true;
return;
};
};
};
if (_m1Cp2.id.key == _id0_1){
_m1Cp2.Pn = _Pn0_1;
_m1Cp2.Pt = _Pt0_1;
_m1Cp2.matched = true;
} else {
if (_m1Cp2.id.key == _id0_2){
_m1Cp2.Pn = _Pn0_2;
_m1Cp2.Pt = _Pt0_2;
_m1Cp2.matched = true;
};
};
};
};
};
};
} else {
_collider.collide(manifold, shape1, shape2, this);
manifoldCount = ((manifold.pointCount > 0)) ? 1 : 0;
};
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 93
//PolyCircleContact (de.polygonal.motor2.dynamics.contact.generator.PolyCircleContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class PolyCircleContact extends ConvexCircleContact {
private static const COLLIDE_POLY_CIRCLE:CollidePolyCircle = new CollidePolyCircle();
public function PolyCircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
return (COLLIDE_POLY_CIRCLE);
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 94
//PolyContact (de.polygonal.motor2.dynamics.contact.generator.PolyContact)
package de.polygonal.motor2.dynamics.contact.generator {
import flash.utils.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.pairwise.*;
public class PolyContact extends ConvexContact {
public var p:V2;
public var d:V2;
public var hc:Dictionary;
public var firstOut:Boolean;
private static const COLLIDE_TRIANGLE_HC:CollideTriangleHC = new CollideTriangleHC();
private static const COLLIDE_POLY_CHC:CollidePolyCHC = new CollidePolyCHC();
private static const COLLIDE_POLY_BSP:CollidePolyBSP = new CollidePolyBSP();
public function PolyContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
firstOut = true;
p = _arg1.worldVertexChain;
d = _arg1.worldNormalChain;
if ((_arg1.vertexCount + _arg2.vertexCount) > 10){
hc = new Dictionary(true);
};
}
override public function flush():void{
hc = null;
}
override protected function getCollider():Collider{
if ((shape1.vertexCount + shape2.vertexCount) > 10){
return (COLLIDE_POLY_CHC);
};
if ((((shape1.vertexCount == 3)) && ((shape2.vertexCount == 3)))){
return (COLLIDE_TRIANGLE_HC);
};
return (COLLIDE_POLY_BSP);
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 95
//PolyLineContact (de.polygonal.motor2.dynamics.contact.generator.PolyLineContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.pairwise.*;
public class PolyLineContact extends ConvexContact {
public var hint1:V2;
public var hint2:V2;
private static const COLLIDE_POLY_PLANE_DS_CHC:CollidePolyPlaneDoubleSidedCHC = new CollidePolyPlaneDoubleSidedCHC();
private static const COLLIDE_POLY_PLANE_DS_BSP:CollidePolyPlaneDoubleSidedBSP = new CollidePolyPlaneDoubleSidedBSP();
private static const COLLIDE_POLY_LINE_DS_CHC:CollidePolyLineDoubleSidedCHC = new CollidePolyLineDoubleSidedCHC();
private static const COLLIDE_POLY_PLANE_SS_CHC:CollidePolyPlaneSingleSidedCHC = new CollidePolyPlaneSingleSidedCHC();
private static const COLLIDE_POLY_PLANE_SS_BSP:CollidePolyPlaneSingleSidedBSP = new CollidePolyPlaneSingleSidedBSP();
private static const COLLIDE_POLY_LINE_DS_BSP:CollidePolyLineDoubleSidedBSP = new CollidePolyLineDoubleSidedBSP();
private static const COLLIDE_POLY_LINE_SS_CHC:CollidePolyLineSingleSidedCHC = new CollidePolyLineSingleSidedCHC();
private static const COLLIDE_POLY_LINE_SS_BSP:CollidePolyLineSingleSidedBSP = new CollidePolyLineSingleSidedBSP();
public function PolyLineContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
var _local3 = (_arg1.vertexCount > 10);
if (_local3){
hint1 = _arg1.worldVertexChain;
hint2 = hint1;
};
}
override protected function getCollider():Collider{
var _local1 = (shape1.vertexCount > 10);
var _local2:LineShape = LineShape(shape2);
if (_local2.infinite){
if (_local2.doubleSided){
if (_local1){
return (COLLIDE_POLY_PLANE_DS_CHC);
};
return (COLLIDE_POLY_PLANE_DS_BSP);
};
if (_local1){
return (COLLIDE_POLY_PLANE_SS_CHC);
};
return (COLLIDE_POLY_PLANE_SS_BSP);
};
if (_local2.doubleSided){
if (_local1){
return (COLLIDE_POLY_LINE_DS_CHC);
};
return (COLLIDE_POLY_LINE_DS_BSP);
};
if (_local1){
return (COLLIDE_POLY_LINE_SS_CHC);
};
return (COLLIDE_POLY_LINE_SS_BSP);
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 96
//SIContactSolver (de.polygonal.motor2.dynamics.contact.solver.SIContactSolver)
package de.polygonal.motor2.dynamics.contact.solver {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.*;
import de.polygonal.motor2.dynamics.contact.*;
public class SIContactSolver {
private var _maxLinCorrection:Number;
private var _linSlop:Number;
private var _velThreshold:Number;
public var contactCount:int;
public var contacts:Array;
public function SIContactSolver():void{
_linSlop = Constants.k_linSlop;
_velThreshold = Constants.k_velocityThreshold;
_maxLinCorrection = Constants.k_maxLinCorrection;
}
public function solvePosConstraints(_arg1:Number):Boolean{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:Contact;
var _local6:Manifold;
var _local7:ContactPoint;
var _local8:RigidBody;
var _local9:RigidBody;
var _local10: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 _local11:Number = 0;
_local2 = 0;
while (_local2 < contactCount) {
_local5 = contacts[_local2];
_local8 = _local5.body1;
_local9 = _local5.body2;
_local3 = 0;
while (_local3 < _local5.manifoldCount) {
_local6 = _local5.manifolds[_local3];
_local12 = _local6.nx;
_local17 = _local6.ny;
_local4 = 0;
while (_local4 < _local6.pointCount) {
_local7 = _local6.points[_local4];
_local15 = ((_local8.r11 * _local7.l_r1x) + (_local8.r12 * _local7.l_r1y));
_local20 = ((_local8.r21 * _local7.l_r1x) + (_local8.r22 * _local7.l_r1y));
_local16 = ((_local9.r11 * _local7.l_r2x) + (_local9.r12 * _local7.l_r2y));
_local21 = ((_local9.r21 * _local7.l_r2x) + (_local9.r22 * _local7.l_r2y));
_local14 = ((_local9.x + _local16) - (_local8.x + _local15));
_local19 = ((_local9.y + _local21) - (_local8.y + _local20));
_local10 = (((_local14 * _local12) + (_local19 * _local17)) + _local7.sep);
_local11 = ((_local11 < _local10)) ? _local11 : _local10;
_local24 = (_local10 + _linSlop);
_local25 = -(_maxLinCorrection);
_local26 = 0;
_local27 = (_arg1 * ((_local24)<_local25) ? _local25 : ((_local24)>_local26) ? _local26 : _local24);
_local28 = (-(_local7.nMass) * _local27);
_local29 = _local7.Pp;
_local7.Pp = (_local29 + _local28);
if (_local7.Pp < 0){
_local7.Pp = 0;
};
_local28 = (_local7.Pp - _local29);
_local13 = (_local28 * _local12);
_local18 = (_local28 * _local17);
_local8.x = (_local8.x - (_local8.invMass * _local13));
_local8.y = (_local8.y - (_local8.invMass * _local18));
_local8.r = (_local8.r - (_local8.invI * ((_local15 * _local18) - (_local20 * _local13))));
_local22 = Math.cos(_local8.r);
_local23 = Math.sin(_local8.r);
_local8.r11 = _local22;
_local8.r12 = -(_local23);
_local8.r21 = _local23;
_local8.r22 = _local22;
_local9.x = (_local9.x + (_local9.invMass * _local13));
_local9.y = (_local9.y + (_local9.invMass * _local18));
_local9.r = (_local9.r + (_local9.invI * ((_local16 * _local18) - (_local21 * _local13))));
_local22 = Math.cos(_local9.r);
_local23 = Math.sin(_local9.r);
_local9.r11 = _local22;
_local9.r12 = -(_local23);
_local9.r21 = _local23;
_local9.r22 = _local22;
_local4++;
};
_local3++;
};
_local2++;
};
return ((_local11 >= -(_linSlop)));
}
public function setContacts(_arg1:Array, _arg2:int):void{
this.contacts = _arg1;
this.contactCount = _arg2;
}
public function preStep():void{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:RigidBody;
var _local5:RigidBody;
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:Contact;
var _local18:Manifold;
var _local19:ContactPoint;
_local1 = 0;
while (_local1 < contactCount) {
_local17 = contacts[_local1];
_local4 = (contacts[_local1].body1 = _local17.shape1.body);
_local5 = (_local17.body2 = _local17.shape2.body);
_local2 = 0;
while (_local2 < _local17.manifoldCount) {
_local18 = _local17.manifolds[_local2];
_local6 = _local18.nx;
_local10 = _local18.ny;
_local3 = 0;
while (_local3 < _local18.pointCount) {
_local19 = _local18.points[_local3];
_local8 = (_local19.x - _local4.x);
_local12 = (_local19.y - _local4.y);
_local9 = (_local19.x - _local5.x);
_local13 = (_local19.y - _local5.y);
if (World.doPositionCorrection){
_local19.l_r1x = ((_local4.r11 * _local8) + (_local4.r21 * _local12));
_local19.l_r1y = ((_local4.r12 * _local8) + (_local4.r22 * _local12));
_local19.l_r2x = ((_local5.r11 * _local9) + (_local5.r21 * _local13));
_local19.l_r2y = ((_local5.r12 * _local9) + (_local5.r22 * _local13));
};
_local19.w_r1x = _local8;
_local19.w_r1y = _local12;
_local19.w_r2x = _local9;
_local19.w_r2y = _local13;
_local14 = ((_local8 * _local10) - (_local12 * _local6));
_local15 = ((_local9 * _local10) - (_local13 * _local6));
_local19.nMass = (1 / (((_local4.invMass + _local5.invMass) + ((_local4.invI * _local14) * _local14)) + ((_local5.invI * _local15) * _local15)));
_local14 = ((_local8 * -(_local6)) - (_local12 * _local10));
_local15 = ((_local9 * -(_local6)) - (_local13 * _local10));
_local19.tMass = (1 / (((_local4.invMass + _local5.invMass) + ((_local4.invI * _local14) * _local14)) + ((_local5.invI * _local15) * _local15)));
_local16 = ((_local6 * (((_local5.vx - (_local5.w * _local13)) - _local4.vx) + (_local4.w * _local12))) + (_local10 * (((_local5.vy + (_local5.w * _local9)) - _local4.vy) - (_local4.w * _local8))));
_local19.velBias = ((_local16 < -(_velThreshold))) ? (-(_local17.restitution) * _local16) : 0;
if (World.doWarmStarting){
_local7 = ((_local19.Pn * _local6) + (_local19.Pt * _local10));
_local11 = ((_local19.Pn * _local10) + (_local19.Pt * -(_local6)));
_local4.vx = (_local4.vx - (_local4.invMass * _local7));
_local4.vy = (_local4.vy - (_local4.invMass * _local11));
_local4.w = (_local4.w - (_local4.invI * ((_local8 * _local11) - (_local12 * _local7))));
_local5.vx = (_local5.vx + (_local5.invMass * _local7));
_local5.vy = (_local5.vy + (_local5.invMass * _local11));
_local5.w = (_local5.w + (_local5.invI * ((_local9 * _local11) - (_local13 * _local7))));
} else {
_local19.Pn = (_local19.Pt = 0);
};
_local19.Pp = 0;
_local3++;
};
_local2++;
};
_local1++;
};
}
public function solveVelConstraints():void{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:Contact;
var _local5:Manifold;
var _local6:ContactPoint;
var _local7:RigidBody;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:RigidBody;
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;
_local1 = 0;
while (_local1 < contactCount) {
_local4 = contacts[_local1];
_local7 = _local4.body1;
_local13 = _local4.body2;
_local8 = _local7.invMass;
_local9 = _local7.invI;
_local14 = _local13.invMass;
_local15 = _local13.invI;
_local10 = _local7.vx;
_local11 = _local7.vy;
_local12 = _local7.w;
_local16 = _local13.vx;
_local17 = _local13.vy;
_local18 = _local13.w;
_local2 = 0;
while (_local2 < _local4.manifoldCount) {
_local5 = _local4.manifolds[_local2];
_local19 = _local5.nx;
_local22 = _local5.ny;
_local3 = 0;
while (_local3 < _local5.pointCount) {
_local6 = _local5.points[_local3];
_local25 = _local6.w_r1x;
_local26 = _local6.w_r1y;
_local27 = _local6.w_r2x;
_local28 = _local6.w_r2y;
_local21 = (((_local16 - (_local18 * _local28)) - _local10) + (_local12 * _local26));
_local24 = (((_local17 + (_local18 * _local27)) - _local11) - (_local12 * _local25));
_local30 = (-(_local6.nMass) * (((_local21 * _local19) + (_local24 * _local22)) - _local6.velBias));
_local29 = (_local6.Pn + _local30);
if (_local29 < 0){
_local29 = 0;
};
_local30 = (_local29 - _local6.Pn);
_local20 = (_local30 * _local19);
_local23 = (_local30 * _local22);
_local10 = (_local10 - (_local8 * _local20));
_local11 = (_local11 - (_local8 * _local23));
_local12 = (_local12 - (_local9 * ((_local25 * _local23) - (_local26 * _local20))));
_local16 = (_local16 + (_local14 * _local20));
_local17 = (_local17 + (_local14 * _local23));
_local18 = (_local18 + (_local15 * ((_local27 * _local23) - (_local28 * _local20))));
_local6.Pn = _local29;
_local21 = (((_local16 - (_local18 * _local28)) - _local10) + (_local12 * _local26));
_local24 = (((_local17 + (_local18 * _local27)) - _local11) - (_local12 * _local25));
_local30 = (((_local6.tMass * -(_local22)) * _local21) + (_local19 * _local24));
_local31 = (_local4.friction * _local6.Pn);
_local29 = (_local6.Pt + _local30);
_local29 = ((_local29)<-(_local31)) ? -(_local31) : ((_local29)>_local31) ? _local31 : _local29;
_local30 = (_local29 - _local6.Pt);
_local20 = (_local30 * _local22);
_local23 = (_local30 * -(_local19));
_local10 = (_local10 - (_local8 * _local20));
_local11 = (_local11 - (_local8 * _local23));
_local12 = (_local12 - (_local9 * ((_local25 * _local23) - (_local26 * _local20))));
_local16 = (_local16 + (_local14 * _local20));
_local17 = (_local17 + (_local14 * _local23));
_local18 = (_local18 + (_local15 * ((_local27 * _local23) - (_local28 * _local20))));
_local6.Pt = _local29;
_local3++;
};
_local2++;
};
_local7.vx = _local10;
_local7.vy = _local11;
_local7.w = _local12;
_local13.vx = _local16;
_local13.vy = _local17;
_local13.w = _local18;
_local1++;
};
}
}
}//package de.polygonal.motor2.dynamics.contact.solver
Section 97
//Contact (de.polygonal.motor2.dynamics.contact.Contact)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class Contact {
public var next:Contact;
public var body1:RigidBody;
public var body2:RigidBody;
protected var _collider:Collider;
public var stateBits:int;
public var manifoldCount:int;
public var manifolds:Array;
public var restitution:Number;
public var node1:ContactNode;
public var node2:ContactNode;
public var shape2:ShapeSkeleton;
public var prev:Contact;
public var shape1:ShapeSkeleton;
public var friction:Number;
public var secondary:Boolean;
public var disabled:Boolean;
public static const k_bitIsland:int = 32;
public function Contact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
init(_arg1, _arg2);
}
public function flush():void{
}
public function evaluate():void{
}
protected function init(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):void{
shape1 = _arg1;
shape2 = _arg2;
manifoldCount = 0;
manifolds = new Array(2, true);
friction = Math.sqrt((_arg1.friction * _arg2.friction));
restitution = ((_arg1.restitution > _arg2.restitution)) ? _arg1.restitution : _arg2.restitution;
_collider = getCollider();
node1 = new ContactNode();
node2 = new ContactNode();
}
protected function getCollider():Collider{
return (null);
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 98
//ContactFactory (de.polygonal.motor2.dynamics.contact.ContactFactory)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.ds.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class ContactFactory {
private static var _contactMatrix:Array2;
public function ContactFactory(){
initializeContactMatrix();
}
private function initializeContactMatrix():void{
_contactMatrix = new Array2(ShapeTypes.SHAPE_COUNT, ShapeTypes.SHAPE_COUNT);
_contactMatrix.fill(ContactRegister);
registerContactHandler(BoxContact, ShapeTypes.BOX, ShapeTypes.BOX);
registerContactHandler(PolyContact, ShapeTypes.BOX, ShapeTypes.POLY);
registerContactHandler(BoxCircleContact, ShapeTypes.BOX, ShapeTypes.CIRCLE);
registerContactHandler(BoxLineContact, ShapeTypes.BOX, ShapeTypes.LINE);
registerContactHandler(PolyContact, ShapeTypes.POLY, ShapeTypes.POLY);
registerContactHandler(PolyCircleContact, ShapeTypes.POLY, ShapeTypes.CIRCLE);
registerContactHandler(PolyLineContact, ShapeTypes.POLY, ShapeTypes.LINE);
registerContactHandler(CircleContact, ShapeTypes.CIRCLE, ShapeTypes.CIRCLE);
registerContactHandler(CircleLineContact, ShapeTypes.CIRCLE, ShapeTypes.LINE);
}
public function destroy(_arg1:Contact):void{
if (_arg1.manifoldCount > 0){
_arg1.shape1.body.wakeUp();
_arg1.shape2.body.wakeUp();
};
_contactMatrix.get(_arg1.shape1.type, _arg1.shape2.type).deconstruct(_arg1);
}
public function create(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):Contact{
var _local5:Contact;
var _local6:int;
var _local7:Manifold;
var _local3:ContactRegister = _contactMatrix.get(_arg1.type, _arg2.type);
var _local4:Class = _local3.constructor;
if (_local4){
if (_local3.primary){
return (new _local4(_arg1, _arg2));
};
_local5 = new _local4(_arg2, _arg1);
_local5.secondary = true;
_local6 = 0;
while (_local6 < _local5.manifoldCount) {
_local7 = _local5.manifolds[_local6];
_local5.manifolds[_local6].nx = -(_local7.nx);
_local7.ny = -(_local7.ny);
_local6++;
};
return (_local5);
};
return (null);
}
private function registerContactHandler(_arg1:Class, _arg2:int, _arg3:int):void{
ContactRegister(_contactMatrix.get(_arg2, _arg3)).constructor = _arg1;
ContactRegister(_contactMatrix.get(_arg2, _arg3)).primary = true;
if (_arg2 != _arg3){
ContactRegister(_contactMatrix.get(_arg3, _arg2)).constructor = _arg1;
ContactRegister(_contactMatrix.get(_arg3, _arg2)).primary = false;
};
}
}
}//package de.polygonal.motor2.dynamics.contact
class ContactRegister {
public var primary:Boolean;
public var deconstruct:Function;
public var constructor:Class;
private function ContactRegister(){
}
}
Section 99
//ContactFilter (de.polygonal.motor2.dynamics.contact.ContactFilter)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.collision.shapes.*;
public class ContactFilter {
public function shouldCollide(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):Boolean{
if (_arg1.groupIndex == _arg2.groupIndex){
if (_arg1.groupIndex != 0){
return ((_arg1.groupIndex > 0));
};
};
return (((!(((_arg1.maskBits & _arg2.categoryBits) == 0))) && (!(((_arg1.categoryBits & _arg2.maskBits) == 0)))));
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 100
//ContactID (de.polygonal.motor2.dynamics.contact.ContactID)
package de.polygonal.motor2.dynamics.contact {
public class ContactID {
public var flip:int;
public var incVert:int;
public var refFace:int;
public var incEdge:int;
public var key:uint;
public static const NULL_FEATURE:int = 254;
public function toString():String{
return (((((((((refFace + "|") + incEdge) + "|") + incVert) + "|") + flip) + " -> ") + key));
}
public function bake():void{
key = ((((-(~(refFace)) << 24) | (-(~(incEdge)) << 16)) | (-(~(incVert)) << 8)) | -(~(flip)));
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 101
//ContactManager (de.polygonal.motor2.dynamics.contact.ContactManager)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.*;
import de.polygonal.motor2.collision.nbody.*;
public class ContactManager implements PairCallback {
private var _contactFilter:ContactFilter;
private var _callback:ContactCallback;
private var _contactFactory:ContactFactory;
public var statsContactCount:int;
private var _world:World;
private static const NULL_CONTACT:NullContact = new NullContact();
public function ContactManager(_arg1:World){
_world = _arg1;
_contactFactory = new ContactFactory();
setCallback(new NullCallback());
}
public function collide():void{
var _local2:RigidBody;
var _local3:RigidBody;
var _local4:int;
var _local5:int;
var _local6:ContactNode;
var _local1:Contact = _world.contactList;
while (_local1) {
_local2 = _local1.shape1.body;
_local3 = _local1.shape2.body;
if (((_local2.stateBits & _local3.stateBits) & RigidBody.k_bitSleep)){
_local1 = _local1.next;
} else {
_local4 = _local1.manifoldCount;
_local1.evaluate();
_local5 = _local1.manifoldCount;
if ((((_local4 == 0)) && ((_local5 > 0)))){
_local6 = _local1.node1;
_local6.contact = _local1;
_local6.other = _local3;
_local6.prev = null;
_local6.next = _local2.contactList;
if (_local6.next){
_local6.next.prev = _local6;
};
_local2.contactList = _local6;
_local6 = _local1.node2;
_local6.contact = _local1;
_local6.other = _local2;
_local6.prev = null;
_local6.next = _local3.contactList;
if (_local6.next){
_local6.next.prev = _local6;
};
_local3.contactList = _local6;
} else {
if ((((_local4 > 0)) && ((_local5 == 0)))){
_local6 = _local1.node1;
if (_local6.next){
_local6.next.prev = _local6.prev;
};
if (_local6.prev){
_local6.prev.next = _local6.next;
};
if (_local6 == _local2.contactList){
_local2.contactList = _local6.next;
};
_local6.next = (_local6.prev = null);
_local6 = _local1.node2;
if (_local6.next){
_local6.next.prev = _local6.prev;
};
if (_local6.prev){
_local6.prev.next = _local6.next;
};
if (_local6 == _local3.contactList){
_local3.contactList = _local6.next;
};
_local6.next = (_local6.prev = null);
};
};
_local1 = _local1.next;
};
};
}
public function setCallback(_arg1:ContactCallback):void{
_callback = _arg1;
}
private function destroyContact(_arg1:Contact):void{
var _local2:RigidBody;
var _local3:RigidBody;
var _local4:ContactNode;
if (_world.contactCount == 0){
return;
};
if (_arg1.prev){
_arg1.prev.next = _arg1.next;
};
if (_arg1.next){
_arg1.next.prev = _arg1.prev;
};
if (_arg1 == _world.contactList){
_world.contactList = _arg1.next;
};
_arg1.flush();
if (_arg1.manifoldCount > 0){
_local2 = _arg1.shape1.body;
_local2.stateBits = (_local2.stateBits & ~(RigidBody.k_bitSleep));
_local2.sleepTime = 0;
_local3 = _arg1.shape2.body;
_local3.stateBits = (_local3.stateBits & ~(RigidBody.k_bitSleep));
_local3.sleepTime = 0;
_local4 = _arg1.node1;
if (_local4.next){
_local4.next.prev = _local4.prev;
};
if (_local4.prev){
_local4.prev.next = _local4.next;
};
if (_local4 == _local2.contactList){
_local2.contactList = _local4.next;
};
_local4.next = (_local4.prev = null);
_local4 = _arg1.node2;
if (_local4.next){
_local4.next.prev = _local4.prev;
};
if (_local4.prev){
_local4.prev.next = _local4.next;
};
if (_local4 == _local3.contactList){
_local3.contactList = _local4.next;
};
_local4.next = (_local4.prev = null);
};
_world.contactCount--;
}
public function pairAdded(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):Contact{
statsContactCount++;
var _local3:RigidBody = _arg1.body;
var _local4:RigidBody = _arg2.body;
if (((_local3.stateBits & _local4.stateBits) & RigidBody.k_bitStatic)){
return (NULL_CONTACT);
};
if (_local3 == _local4){
return (NULL_CONTACT);
};
if (_local4.isConnected(_local3)){
return (NULL_CONTACT);
};
if (!_contactFilter.shouldCollide(_arg1, _arg2)){
return (NULL_CONTACT);
};
var _local5:Contact = _contactFactory.create(_arg1, _arg2);
if (_local5 == null){
return (NULL_CONTACT);
};
_local5.prev = null;
_local5.next = _world.contactList;
if (_world.contactList){
_world.contactList.prev = _local5;
};
_world.contactList = _local5;
_world.contactCount++;
_callback.onContactAdded(_local5);
return (_local5);
}
public function setFilter(_arg1:ContactFilter):void{
_contactFilter = _arg1;
}
public function pairRemoved(_arg1:Contact):void{
statsContactCount++;
if ((((_arg1 == null)) || ((_arg1 == NULL_CONTACT)))){
return;
};
_callback.onContactRemoved(_arg1);
destroyContact(_arg1);
}
}
}//package de.polygonal.motor2.dynamics.contact
import de.polygonal.motor2.*;
class NullCallback implements ContactCallback {
private function NullCallback(){
}
public function onContactRemoved(_arg1:Contact):void{
}
public function onContactAdded(_arg1:Contact):void{
}
}
Section 102
//ContactNode (de.polygonal.motor2.dynamics.contact.ContactNode)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.dynamics.*;
public class ContactNode {
public var other:RigidBody;
public var prev:ContactNode;
public var contact:Contact;
public var next:ContactNode;
public function ContactNode(){
init();
}
private function init():void{
prev = (next = null);
other = null;
contact = null;
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 103
//ContactPoint (de.polygonal.motor2.dynamics.contact.ContactPoint)
package de.polygonal.motor2.dynamics.contact {
public class ContactPoint {
public var nMass:Number;
public var l_r1x:Number;
public var l_r1y:Number;
public var w_r1x:Number;
public var w_r1y:Number;
public var tMass:Number;
public var id:ContactID;
public var Pn:Number;
public var Pp:Number;
public var matched:Boolean;// = false
public var sep:Number;
public var l_r2y:Number;
public var Pt:Number;
public var w_r2y:Number;
public var l_r2x:Number;
public var w_r2x:Number;
public var x:Number;
public var y:Number;
public var velBias:Number;
public function ContactPoint():void{
init();
}
public function init():void{
id = new ContactID();
x = (y = (sep = (velBias = (Pn = (Pt = (Pp = (nMass = (tMass = 0))))))));
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 104
//Manifold (de.polygonal.motor2.dynamics.contact.Manifold)
package de.polygonal.motor2.dynamics.contact {
public class Manifold {
public var points:Array;
public var nx:Number;
public var ny:Number;
public var c0:ContactPoint;
public var c1:ContactPoint;
public var pointCount:int;
public function Manifold(){
init();
}
public function init():void{
c0 = new ContactPoint();
c1 = new ContactPoint();
points = new Array(2, true);
points[0] = c0;
points[1] = c1;
pointCount = 0;
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 105
//NullContact (de.polygonal.motor2.dynamics.contact.NullContact)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.collision.shapes.*;
public class NullContact extends Contact {
public function NullContact(){
super(null, null);
}
override protected function init(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):void{
}
override public function evaluate():void{
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 106
//Buoyancy (de.polygonal.motor2.dynamics.forces.Buoyancy)
package de.polygonal.motor2.dynamics.forces {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
public class Buoyancy extends ForceGenerator {
public var planeNormal:V2;
private var _cp0:V2;
public var linDrag:Number;
public var density:Number;
private var _cp1:V2;
public var angDrag:Number;
public var planeOffset:Number;
private var _clipTri0:ClipTriangle;
private var _clipTri1:ClipTriangle;
public var velocity:V2;
public function Buoyancy(_arg1:Number, _arg2:V2, _arg3:Number, _arg4:Number=5, _arg5:Number=0.5, _arg6:V2=null){
_clipTri0 = new ClipTriangle();
_clipTri1 = new ClipTriangle();
_cp0 = new V2();
_cp1 = new V2();
super();
this.planeOffset = _arg1;
this.planeNormal = _arg2;
this.density = _arg3;
this.linDrag = _arg4;
this.angDrag = _arg5;
this.velocity = (_arg6) ? _arg6 : new V2();
}
private function clipTriangle(_arg1:Tri2, _arg2:Number, _arg3:ClipTriangle, _arg4:ClipTriangle):int{
var _local11:V2;
var _local12:V2;
var _local13:V2;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local5:int;
var _local6:int;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
if (_arg1.a.y > _arg2){
_local6++;
_local8 = _arg1.a;
} else {
_local5++;
_local7 = _arg1.a;
};
if (_arg1.b.y > _arg2){
_local6++;
if (_local8){
_local10 = _arg1.b;
} else {
_local8 = _arg1.b;
};
} else {
_local5++;
if (_local7){
_local9 = _arg1.b;
} else {
_local7 = _arg1.b;
};
};
if (_arg1.c.y > _arg2){
_local6++;
if (_local8){
_local10 = _arg1.c;
} else {
_local8 = _arg1.c;
};
} else {
_local5++;
if (_local7){
_local9 = _arg1.c;
} else {
_local7 = _arg1.c;
};
};
if (_local5 == 0){
_arg3.a = _arg1.a;
_arg3.b = _arg1.b;
_arg3.c = _arg1.c;
return (1);
};
if (_local6 == 0){
return (-1);
};
if (_local5 == 1){
_local11 = _local7;
_local12 = _local8;
_local14 = (_local11.y - _arg2);
_local15 = (_local12.y - _arg2);
_local16 = (_local14 / (_local14 - _local15));
_cp0.x = (_local11.x + (_local16 * (_local12.x - _local11.x)));
_cp0.y = (_local11.y + (_local16 * (_local12.y - _local11.y)));
_local12 = _local10;
_local15 = (_local12.y - _arg2);
_local16 = (_local14 / (_local14 - _local15));
_cp1.x = (_local11.x + (_local16 * (_local12.x - _local11.x)));
_cp1.y = (_local11.y + (_local16 * (_local12.y - _local11.y)));
if (_cp0.x > _cp1.x){
_local13 = _cp0;
_cp0 = _cp1;
_cp1 = _local13;
};
_local17 = (((_local8.x - _local11.x) * (_local10.y - _local11.y)) - ((_local8.y - _local11.y) * (_local10.x - _local11.x)));
if (_local8.x > _cp1.x){
_arg3.a = _local10;
_arg3.b = _cp1;
_arg3.c = _local8;
if (_local17 > 0){
_arg4.a = _local10;
_arg4.b = _cp1;
_arg4.c = _cp0;
} else {
_arg4.a = _local8;
_arg4.b = _cp1;
_arg4.c = _cp0;
};
return (2);
} else {
if (_local10.x < _cp0.x){
_arg3.a = _local10;
_arg3.b = _cp0;
_arg3.c = _local8;
if (_local17 > 0){
_arg4.a = _local8;
_arg4.b = _cp1;
_arg4.c = _cp0;
} else {
_arg4.a = _local10;
_arg4.b = _cp1;
_arg4.c = _cp0;
};
return (2);
} else {
_arg3.a = _local8;
_arg3.b = _local10;
_arg3.c = _cp0;
_arg4.a = _cp0;
_arg4.b = _local10;
_arg4.c = _cp1;
return (2);
};
};
} else {
if (_local5 == 2){
_local11 = _local8;
_local12 = _local7;
_local14 = (_local11.y - _arg2);
_local15 = (_local12.y - _arg2);
_local16 = (_local14 / (_local14 - _local15));
_cp0.x = (_local11.x + (_local16 * (_local12.x - _local11.x)));
_cp0.y = (_local11.y + (_local16 * (_local12.y - _local11.y)));
_local12 = _local9;
_local15 = (_local12.y - _arg2);
_local16 = (_local14 / (_local14 - _local15));
_cp1.x = (_local11.x + (_local16 * (_local12.x - _local11.x)));
_cp1.y = (_local11.y + (_local16 * (_local12.y - _local11.y)));
if (_cp0.x > _cp1.x){
_local13 = _cp0;
_cp0 = _cp1;
_cp1 = _local13;
};
_arg3.a = _cp1;
_arg3.b = _cp0;
_arg3.c = _local8;
return (1);
};
};
return (-1);
}
override public function evaluate(_arg1:RigidBody):void{
var _local8:int;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local13:ShapeSkeleton;
var _local14:Tri2;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local2:Number = 0;
var _local3:Number = 0;
var _local4:Number = 2147483648;
var _local5:Number = -2147483648;
var _local6:Number = 0;
var _local7:Number = 0;
_local13 = _arg1.shapeList;
while (_local13) {
_local2 = (_local2 + _local13.area);
if (_local13.ymax < planeOffset){
} else {
if (_local13.ymin >= planeOffset){
_local12 = _local13.area;
_local6 = (_local6 + (_local12 * _local13.x));
_local7 = (_local7 + (_local12 * _local13.y));
_local3 = (_local3 + _local12);
if (_local13.xmin < _local4){
_local4 = _local13.xmin;
};
if (_local13.xmax > _local5){
_local5 = _local13.xmax;
};
} else {
if (_local13.type == ShapeTypes.CIRCLE){
_local21 = _local13.radius;
_local22 = (_local13.ymax - planeOffset);
_local12 = (((_local21 * _local21) * Math.acos(((_local21 - _local22) / _local21))) - ((_local21 - _local22) * Math.sqrt((((2 * _local21) * _local22) - (_local22 * _local22)))));
_local23 = ((2 * _local21) - _local22);
_local24 = ((3 * (_local23 * _local23)) / (4 * ((3 * _local21) - _local22)));
_local6 = (_local6 + (_local13.x * _local12));
_local7 = (_local7 + ((_local13.y + _local24) * _local12));
_local3 = (_local3 + _local12);
if (_local13.xmin < _local4){
_local4 = _local13.xmin;
};
if (_local13.xmax > _local5){
_local5 = _local13.xmax;
};
} else {
if (!_local13.synced){
_local13.toWorldSpace();
};
_local14 = _local13.triangleList;
while (_local14) {
_local8 = clipTriangle(_local14, planeOffset, _clipTri0, _clipTri1);
if (_local8 > 0){
_local9 = _clipTri0.a;
_local10 = _clipTri0.b;
_local11 = _clipTri0.c;
_local12 = ((((_local10.x - _local9.x) * (_local11.y - _local9.y)) - ((_local10.y - _local9.y) * (_local11.x - _local9.x))) / 2);
if (_local12 < 0){
_local12 = -(_local12);
};
if (_local12 > 1E-5){
_local6 = (_local6 + ((_local12 * ((_local9.x + _local10.x) + _local11.x)) / 3));
_local7 = (_local7 + ((_local12 * ((_local9.y + _local10.y) + _local11.y)) / 3));
_local3 = (_local3 + _local12);
};
};
if (_local8 > 1){
_local9 = _clipTri1.a;
_local10 = _clipTri1.b;
_local11 = _clipTri1.c;
_local12 = ((((_local10.x - _local9.x) * (_local11.y - _local9.y)) - ((_local10.y - _local9.y) * (_local11.x - _local9.x))) / 2);
if (_local12 < 0){
_local12 = -(_local12);
};
if (_local12 > 1E-5){
_local6 = (_local6 + ((_local12 * ((_local9.x + _local10.x) + _local11.x)) / 3));
_local7 = (_local7 + ((_local12 * ((_local9.y + _local10.y) + _local11.y)) / 3));
_local3 = (_local3 + _local12);
};
};
if (_local13.xmin < _local4){
_local4 = _local13.xmin;
};
if (_local13.xmax > _local5){
_local5 = _local13.xmax;
};
_local14 = _local14.next;
};
};
};
};
_local13 = _local13.next;
};
_local6 = (_local6 / _local3);
_local7 = (_local7 / _local3);
if (_local3 <= 1E-5){
return;
};
var _local15:Number = ((density * _local3) * _arg1.world.gravity.y);
var _local16:Number = ((_arg1.mass * _local3) / _local2);
var _local17:Number = (_local6 - _arg1.x);
var _local18:Number = (_local7 - _arg1.y);
var _local19:Number = ((planeNormal.x * _local15) + ((_local16 * linDrag) * (velocity.x - (_arg1.vx - (_arg1.w * _local18)))));
var _local20:Number = ((planeNormal.y * _local15) + ((_local16 * linDrag) * (velocity.y - (_arg1.vy + (_arg1.w * _local17)))));
_arg1.fx = (_arg1.fx + _local19);
_arg1.fy = (_arg1.fy + _local20);
_arg1.t = (_arg1.t + (((_local17 * _local20) - (_local18 * _local19)) + (((-(_local16) * angDrag) * ((_local5 - _local4) * (_local5 - _local4))) * _arg1.w)));
}
}
}//package de.polygonal.motor2.dynamics.forces
import de.polygonal.motor2.math.*;
class Plane2 {
public var d:Number;// = 0
public var n:V2;
private function Plane2(){
n = new V2();
super();
}
}
class ClipTriangle {
public var a:V2;
public var c:V2;
public var b:V2;
private function ClipTriangle(){
a = new V2();
b = new V2();
c = new V2();
super();
}
}
Section 107
//ForceGenerator (de.polygonal.motor2.dynamics.forces.ForceGenerator)
package de.polygonal.motor2.dynamics.forces {
import de.polygonal.motor2.dynamics.*;
public class ForceGenerator {
public var isActive:Boolean;
public function ForceGenerator(){
init();
}
public function evaluate(_arg1:RigidBody):void{
}
public function init():void{
isActive = true;
}
}
}//package de.polygonal.motor2.dynamics.forces
Section 108
//ForceRegistry (de.polygonal.motor2.dynamics.forces.ForceRegistry)
package de.polygonal.motor2.dynamics.forces {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.*;
import de.polygonal.ds.*;
public class ForceRegistry {
private var _idQue:ArrayedQueue;
private var _registration:ForceNode;
public function ForceRegistry(){
init();
}
public function init():void{
_registration = null;
var _local1:int = Constants.k_maxForceGenerators;
_idQue = new ArrayedQueue(_local1);
var _local2:int;
while (_local2 < _local1) {
_idQue.enqueue(_local2);
_local2++;
};
}
public function add(_arg1:RigidBody, _arg2:ForceGenerator):int{
var _local3:int = _idQue.dequeue();
var _local4:ForceNode = new ForceNode(_arg1, _arg2);
_local4.next = _registration;
if (_registration){
_registration.prev = _local4;
};
_registration = _local4;
return (_local3);
}
public function remove(_arg1:RigidBody, _arg2:ForceGenerator):Boolean{
var _local3:ForceNode = _registration;
while (_local3) {
if ((((_local3.force == _arg2)) && ((_local3.body == _arg1)))){
if (_local3.prev){
_local3.prev.next = _local3.next;
};
if (_local3.next){
_local3.next.prev = _local3.prev;
};
if (_local3 == _registration){
_registration = _local3.next;
};
return (true);
};
_local3 = _local3.next;
};
return (false);
}
public function evaluate():void{
var _local2:ForceGenerator;
var _local1:ForceNode = _registration;
while (_local1) {
_local2 = _local1.force;
if (_local2.isActive){
_local2.evaluate(_local1.body);
};
_local1 = _local1.next;
};
}
public function clear():void{
var _local2:ForceNode;
var _local1:ForceNode = _registration;
_registration = null;
while (_local1) {
_local2 = _local1.next;
_local1.next = (_local1.prev = null);
_local1 = _local2;
};
}
}
}//package de.polygonal.motor2.dynamics.forces
import de.polygonal.motor2.dynamics.*;
class ForceNode {
public var body:RigidBody;
public var prev:ForceNode;
public var next:ForceNode;
public var force:ForceGenerator;
private function ForceNode(_arg1:RigidBody, _arg2:ForceGenerator){
this.body = _arg1;
this.force = _arg2;
init();
}
public function init():void{
prev = (next = null);
}
}
Section 109
//JointData (de.polygonal.motor2.dynamics.joints.data.JointData)
package de.polygonal.motor2.dynamics.joints.data {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.dynamics.joints.*;
public class JointData {
public var collideConnected:Boolean;
public var body1:RigidBody;
public var body2:RigidBody;
public var userData;
public var type:int;
public function JointData(_arg1:RigidBody, _arg2:RigidBody){
this.body1 = _arg1;
this.body2 = _arg2;
setType();
userData = null;
}
public function getJointClass():Class{
return (null);
}
protected function setType():void{
type = JointTypes.UNKNOWN;
}
}
}//package de.polygonal.motor2.dynamics.joints.data
Section 110
//Joint (de.polygonal.motor2.dynamics.joints.Joint)
package de.polygonal.motor2.dynamics.joints {
import flash.geom.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.dynamics.joints.data.*;
public class Joint {
protected const _anchor2:Point;
protected const _reactionForce:Point;
protected const _anchor1:Point;
public var next:Joint;
public var body1:RigidBody;
public var body2:RigidBody;
protected var _invdt:Number;
public var userData;
public var la1x:Number;
public var la1y:Number;
public var collideConnected:Boolean;
public var node1:JointNode;
public var node2:JointNode;
public var prev:Joint;
public var stateBits:int;
public var type:int;
public var la2x:Number;
public var la2y:Number;
protected var _dt:Number;
public static const k_bitIsland:int = 32;
public function Joint(_arg1:JointData){
_reactionForce = new Point();
_anchor1 = new Point();
_anchor2 = new Point();
super();
type = _arg1.type;
body1 = _arg1.body1;
body2 = _arg1.body2;
collideConnected = _arg1.collideConnected;
userData = _arg1.userData;
node1 = new JointNode();
node2 = new JointNode();
}
public function preparePosSolver():void{
}
public function getReactionForce():Point{
return (null);
}
public function getAnchor2():Point{
_anchor2.x = ((body2.x + (body2.r11 * la2x)) + (body2.r12 * la2y));
_anchor2.y = ((body2.y + (body2.r21 * la2x)) + (body2.r22 * la2y));
return (_anchor2);
}
public function getReactionTorque():Number{
return (0);
}
public function solveVelConstraints(_arg1:Number, _arg2:int):void{
}
public function solvePosConstraints():Boolean{
return (true);
}
protected function setType(_arg1:int):void{
this.type = _arg1;
}
public function preStep(_arg1:Number):void{
_dt = _arg1;
_invdt = (1 / _arg1);
}
public function getAnchor1():Point{
_anchor1.x = ((body1.x + (body1.r11 * la1x)) + (body1.r12 * la1y));
_anchor1.y = ((body1.y + (body1.r21 * la1x)) + (body1.r22 * la1y));
return (_anchor1);
}
}
}//package de.polygonal.motor2.dynamics.joints
Section 111
//JointNode (de.polygonal.motor2.dynamics.joints.JointNode)
package de.polygonal.motor2.dynamics.joints {
import de.polygonal.motor2.dynamics.*;
public class JointNode {
public var other:RigidBody;
public var next:JointNode;
public var prev:JointNode;
public var joint:Joint;
}
}//package de.polygonal.motor2.dynamics.joints
Section 112
//JointTypes (de.polygonal.motor2.dynamics.joints.JointTypes)
package de.polygonal.motor2.dynamics.joints {
public class JointTypes {
public static const MOUSE:int = 2;
public static const REVOLUTE:int = 3;
public static const PRISMATIC:int = 6;
public static const GEAR:int = 5;
public static const DISTANCE:int = 1;
public static const UNKNOWN:int = 0;
public static const PULLEY:int = 4;
}
}//package de.polygonal.motor2.dynamics.joints
Section 113
//Island (de.polygonal.motor2.dynamics.Island)
package de.polygonal.motor2.dynamics {
import de.polygonal.motor2.*;
import de.polygonal.motor2.dynamics.contact.solver.*;
public class Island {
public var bodies:Array;
public var contactSolver:SIContactSolver;
public var jointCount:int;
public var joints:Array;
public var bodyCount:int;
public var positionError:Number;
public var contacts:Array;
public var contactCount:int;
public var bodyList:RigidBody;
public var positionIterations:int;
public function Island(){
bodyCount = 0;
contactCount = 0;
jointCount = 0;
bodyList = null;
bodies = new Array();
contacts = new Array();
joints = new Array();
contactSolver = new SIContactSolver();
}
public function solve(_arg1:Number, _arg2:Number, _arg3:int, _arg4:Number):void{
var _local5:int;
var _local6:int;
var _local7:RigidBody;
var _local8:Number;
var _local9:Number;
var _local10:Boolean;
var _local11:Boolean;
_local5 = 0;
while (_local5 < bodyCount) {
_local7 = bodies[_local5];
if (_local7.invMass == 0){
} else {
_local7.vx = ((_local7.vx + (_arg4 * (_arg1 + (_local7.invMass * _local7.fx)))) * _local7.linDamping);
_local7.vy = ((_local7.vy + (_arg4 * (_arg2 + (_local7.invMass * _local7.fy)))) * _local7.linDamping);
_local7.w = ((_local7.w + (_arg4 * (_local7.invI * _local7.t))) * _local7.angDamping);
};
_local5++;
};
contactSolver.setContacts(contacts, contactCount);
contactSolver.preStep();
_local6 = 0;
while (_local6 < jointCount) {
joints[_local6].preStep(_arg4);
_local6++;
};
_local5 = 0;
while (_local5 < _arg3) {
contactSolver.solveVelConstraints();
_local6 = 0;
while (_local6 < jointCount) {
joints[_local6].solveVelConstraints(_arg4, _arg3);
_local6++;
};
_local5++;
};
_local5 = 0;
while (_local5 < bodyCount) {
_local7 = bodies[_local5];
if (_local7.invMass == 0){
} else {
_local7.x = (_local7.x + (_arg4 * _local7.vx));
_local7.y = (_local7.y + (_arg4 * _local7.vy));
_local7.r = (_local7.r + (_arg4 * _local7.w));
_local9 = Math.cos(_local7.r);
_local8 = Math.sin(_local7.r);
_local7.r11 = _local9;
_local7.r12 = -(_local8);
_local7.r21 = _local8;
_local7.r22 = _local9;
};
_local5++;
};
if (World.doPositionCorrection){
_local5 = 0;
while (_local5 < _arg3) {
_local10 = contactSolver.solvePosConstraints(Constants.k_contactBaumgarte);
_local11 = true;
_local6 = 0;
while (_local6 < jointCount) {
_local11 = joints[_local6].solvePosConstraints();
_local11 = ((_local11) && (_local11));
_local6++;
};
if (((_local10) && (_local11))){
break;
};
_local5++;
};
};
}
public function updateSleep(_arg1:Number):void{
var _local5:RigidBody;
var _local6:int;
var _local2:Number = 2147483648;
var _local3:Number = Constants.k_linSleepToleranceSq;
var _local4:Number = Constants.k_angSleepToleranceSq;
_local6 = 0;
while (_local6 < bodyCount) {
_local5 = bodies[_local6];
if (_local5.invMass == 0){
} else {
if ((_local5.stateBits & RigidBody.k_bitAllowSleep) == 0){
_local5.sleepTime = 0;
_local2 = 0;
};
if (((((((_local5.stateBits & RigidBody.k_bitAllowSleep) == 0)) || (((_local5.w * _local5.w) > _local4)))) || ((((_local5.vx * _local5.vx) + (_local5.vy * _local5.vy)) > _local3)))){
_local5.sleepTime = 0;
_local2 = 0;
} else {
_local5.sleepTime = (_local5.sleepTime + _arg1);
_local2 = ((_local2 < _local5.sleepTime)) ? _local2 : _local5.sleepTime;
};
};
_local6++;
};
if (_local2 >= Constants.k_timeToSleep){
_local6 = 0;
while (_local6 < bodyCount) {
_local5 = bodies[_local6];
bodies[_local6].stateBits = (_local5.stateBits | RigidBody.k_bitSleep);
_local6++;
};
};
}
}
}//package de.polygonal.motor2.dynamics
Section 114
//RigidBody (de.polygonal.motor2.dynamics.RigidBody)
package de.polygonal.motor2.dynamics {
import flash.geom.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.joints.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.collision.nbody.*;
public class RigidBody {
public var r:Number;
public var invMass:Number;
public var world:World;
public var r12:Number;
public var userData;
public var r11:Number;
public var linDamping:Number;
public var r22:Number;
public var prev:RigidBody;
public var stateBits:int;
public var r21:Number;
public var vx:Number;
public var vy:Number;
public var sleepTime:Number;
public var angDamping:Number;
public var I:Number;
public var jointList:JointNode;
public var fx:Number;
public var fy:Number;
public var contactList:ContactNode;
public var shapeList:ShapeSkeleton;
public var next:RigidBody;
public var mass:Number;
public var cx:Number;
public var cy:Number;
public var x:Number;
public var y:Number;
public var t:Number;
public var shapeCount:int;
public var w:Number;
public var invI:Number;
public static const k_bitDestroy:int = 16;
public static const k_bitAllowSleep:int = 8;
public static const k_bitIsland:int = 32;
public static const k_bitStatic:int = 1;
public static const k_bitFrozen:int = 2;
public static const k_bitSleep:int = 4;
public function RigidBody(_arg1:World, _arg2:RigidBodyData){
init(_arg1, _arg2);
}
public function refreshProxy():void{
var _local1:ShapeSkeleton = shapeList;
while (_local1) {
_local1.refreshProxy();
_local1 = _local1.next;
};
}
public function getWorldDirection(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
if (_arg2){
_arg2.x = ((r11 * _arg1.x) + (r12 * _arg1.y));
_arg2.y = ((r21 * _arg1.x) + (r22 * _arg1.y));
} else {
_local3 = _arg1.x;
_arg1.x = ((r11 * _local3) + (r12 * _arg1.y));
_arg1.y = ((r21 * _local3) + (r22 * _arg1.y));
};
}
public function wakeUp():void{
stateBits = (stateBits & ~(k_bitSleep));
sleepTime = 0;
}
public function putToSleep():void{
stateBits = (stateBits | k_bitSleep);
sleepTime = 0;
vx = (vy = (w = (fx = (fy = (t = 0)))));
}
public function deconstruct():void{
var _local2:ShapeSkeleton;
prev = (next = null);
var _local1:ShapeSkeleton = shapeList;
while (_local1) {
_local2 = _local1;
_local1 = _local1.next;
_local2.deconstruct();
};
}
public function getWorldPoint(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
if (_arg2){
_arg2.x = (x + ((r11 * _arg1.x) + (r12 * _arg1.y)));
_arg2.y = (y + ((r21 * _arg1.x) + (r22 * _arg1.y)));
} else {
_local3 = _arg1.x;
_arg1.x = (x + ((r11 * _local3) + (r12 * _arg1.y)));
_arg1.y = (y + ((r21 * _local3) + (r22 * _arg1.y)));
};
}
public function applyTorque(_arg1:Number):void{
if ((stateBits & k_bitSleep) == 0){
t = (t + _arg1);
};
}
public function getOrigin(_arg1:V2):void{
_arg1.x = (x - ((r11 * cx) + (r12 * cy)));
_arg1.y = (y - ((r21 * cx) + (r22 * cy)));
}
public function applyForce(_arg1:Number, _arg2:Number):void{
if ((stateBits & k_bitSleep) == 0){
this.fx = (this.fx + _arg1);
this.fy = (this.fy + _arg2);
};
}
public function freeze():void{
stateBits = (stateBits | k_bitFrozen);
vx = (vy = (w = 0));
}
private function init(_arg1:World, _arg2:RigidBodyData):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:ShapeData;
var _local9:ShapeSkeleton;
var _local10:Class;
this.world = _arg1;
x = _arg2.x;
y = _arg2.y;
r = _arg2.r;
_local3 = Math.cos(r);
_local4 = Math.sin(r);
r11 = _local3;
r12 = -(_local4);
r21 = _local4;
r22 = _local3;
vx = (vy = (w = 0));
fx = (fy = (t = 0));
mass = (invMass = (I = (invI = 0)));
cx = (cy = 0);
linDamping = (1 - _arg2.linDamping);
linDamping = ((linDamping)<0) ? 0 : ((linDamping)>1) ? 1 : linDamping;
angDamping = (1 - _arg2.angDamping);
angDamping = ((angDamping)<0) ? 0 : ((angDamping)>1) ? 1 : angDamping;
shapeCount = 0;
stateBits = 0;
sleepTime = 0;
if (_arg2.allowSleep){
stateBits = (stateBits | k_bitAllowSleep);
};
if (_arg2.isSleeping){
stateBits = (stateBits | k_bitSleep);
};
jointList = null;
contactList = null;
next = (prev = null);
_local8 = _arg2.shapeDataList;
while (_local8) {
_local5 = _local8.getMass();
mass = (mass + _local5);
cx = (cx + (_local5 * (_local8.mx + _local8.getCM().x)));
cy = (cy + (_local5 * (_local8.my + _local8.getCM().y)));
shapeCount++;
_local8 = _local8.next;
};
if (mass > 0){
cx = (cx / mass);
cy = (cy / mass);
x = (x + ((r11 * cx) + (r12 * cy)));
y = (y + ((r21 * cx) + (r22 * cy)));
} else {
stateBits = (stateBits | k_bitStatic);
};
if (!_arg2.preventRotation){
_local8 = _arg2.shapeDataList;
while (_local8) {
I = (I + _local8.getInertia());
_local6 = ((_local8.mx + _local8.getCM().x) - cx);
_local7 = ((_local8.my + _local8.getCM().y) - cy);
I = (I + (_local8.getMass() * ((_local6 * _local6) + (_local7 * _local7))));
_local8 = _local8.next;
};
if (I > 0){
invI = (1 / I);
};
};
invMass = ((mass)>0) ? (1 / mass) : 0;
if (((!(_arg2.isSleeping)) && ((invMass > 0)))){
vx = (_arg2.vx + (-(_arg2.w) * cy));
vy = (_arg2.vy + (_arg2.w * cy));
w = _arg2.w;
};
_local8 = _arg2.shapeDataList;
while (_local8) {
_local10 = _local8.getShapeClass();
_local9 = new _local10(_local8, this);
_local9.next = shapeList;
shapeList = _local9;
_local8 = _local8.next;
};
}
public function updateShapes(_arg1:Boolean=false):Boolean{
var _local2:Number = Math.cos(r);
var _local3:Number = Math.sin(r);
r11 = _local2;
r12 = -(_local3);
r21 = _local3;
r22 = _local2;
var _local4:Boolean;
var _local5:ShapeSkeleton = shapeList;
while (_local5) {
if (!_local5.update()){
_local4 = false;
break;
};
if (_arg1){
_local5.toWorldSpace();
};
_local5 = _local5.next;
};
if (!_local4){
freeze();
_local5 = shapeList;
while (_local5) {
if (_local5.proxyId != Proxy.NULL_PROXY){
world.getBroadPhase().destroyProxy(_local5.proxyId);
_local5.proxyId = Proxy.NULL_PROXY;
};
_local5 = _local5.next;
};
return (false);
};
return (true);
}
public function allowSleeping(_arg1:Boolean):void{
if (_arg1){
stateBits = (stateBits | k_bitAllowSleep);
} else {
stateBits = (stateBits & ~(k_bitAllowSleep));
wakeUp();
};
}
public function applyImpulse(_arg1:Number, _arg2:Number):void{
if ((stateBits & k_bitSleep) == 0){
vx = (vx + (invMass * _arg1));
vy = (vy + (invMass * _arg2));
};
}
public function setOrigin(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Number;
var _local5:Number;
var _local6:ShapeSkeleton;
if ((stateBits & k_bitFrozen) == 0){
r = _arg3;
_local4 = Math.cos(r);
_local5 = Math.sin(r);
r11 = _local4;
r12 = -(_local5);
r21 = _local5;
r22 = _local4;
this.x = (_arg1 + ((r11 * cx) + (r12 * cy)));
this.y = (_arg2 + ((r21 * cx) + (r22 * cy)));
_local6 = shapeList;
while (_local6) {
_local6.update();
_local6 = _local6.next;
};
};
}
public function isConnected(_arg1:RigidBody):Boolean{
var _local2:JointNode = jointList;
while (_local2) {
if (_local2.other == _arg1){
return ((_local2.joint.collideConnected == false));
};
_local2 = _local2.next;
};
return (false);
}
public function applyForceAt(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
if ((stateBits & k_bitSleep) == 0){
this.fx = (this.fx + _arg1);
this.fy = (this.fy + _arg2);
t = (t + (((_arg3 - x) * _arg2) - ((_arg4 - y) * _arg1)));
};
}
public function isStatic():Boolean{
return (((stateBits & k_bitStatic) == k_bitStatic));
}
public function applyImpulseAt(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
if ((stateBits & k_bitSleep) == 0){
vx = (vx + (invMass * _arg1));
vy = (vy + (invMass * _arg2));
w = (w + (((invI * (_arg3 - x)) * _arg2) - ((invI * (_arg4 - y)) * _arg1)));
};
}
public function getModelDirection(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
if (_arg2){
_arg2.x = ((r11 * _arg1.x) + (r21 * _arg1.y));
_arg2.y = ((r12 * _arg1.x) + (r22 * _arg1.y));
} else {
_local3 = _arg1.x;
_arg1.x = ((r11 * _local3) + (r21 * _arg1.y));
_arg1.y = ((r12 * _local3) + (r22 * _arg1.y));
};
}
public function setCenter(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Number;
var _local5:Number;
var _local6:ShapeSkeleton;
if ((stateBits & k_bitFrozen) == 0){
r = _arg3;
_local4 = Math.cos(r);
_local5 = Math.sin(r);
r11 = _local4;
r12 = -(_local5);
r21 = _local5;
r22 = _local4;
this.x = _arg1;
this.y = _arg2;
_local6 = shapeList;
while (_local6) {
_local6.update();
_local6 = _local6.next;
};
};
}
public function getCenter(_arg1:V2):void{
_arg1.x = x;
_arg1.y = y;
}
public function rotate(_arg1:Number):void{
if (_arg1 < 0){
_arg1 = (_arg1 + 360);
} else {
if (_arg1 > 360){
_arg1 = (_arg1 - 360);
};
};
r = (_arg1 * (Math.PI / 180));
updateShapes();
}
public function getModelPoint(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
if (_arg2){
_arg2.x = ((r11 * (_arg1.x - x)) + (r21 * (_arg1.y - y)));
_arg2.y = ((r12 * (_arg1.x - x)) + (r22 * (_arg1.y - y)));
} else {
_local3 = _arg1.x;
_arg1.x = ((r11 * (_local3 - x)) + (r21 * (_arg1.y - y)));
_arg1.y = ((r12 * (_local3 - x)) + (r22 * (_arg1.y - y)));
};
}
public function isFrozen():Boolean{
return (((stateBits & k_bitFrozen) == k_bitFrozen));
}
public function isSleeping():Boolean{
return (((stateBits & k_bitSleep) == k_bitSleep));
}
}
}//package de.polygonal.motor2.dynamics
Section 115
//RigidBodyData (de.polygonal.motor2.dynamics.RigidBodyData)
package de.polygonal.motor2.dynamics {
import de.polygonal.motor2.collision.shapes.data.*;
public class RigidBodyData {
public var y:Number;
public var vx:Number;
public var vy:Number;
public var angDamping:Number;
public var allowSleep:Boolean;
public var shapeDataList:ShapeData;
public var linDamping:Number;
public var r:Number;
public var isSleeping:Boolean;
public var preventRotation:Boolean;
public var w:Number;
public var x:Number;
public function RigidBodyData(_arg1:Number=0, _arg2:Number=0, _arg3:Number=0){
init();
this.x = _arg1;
this.y = _arg2;
this.r = _arg3;
}
public function addShapeData(_arg1:ShapeData):void{
if (_arg1 == null){
return;
};
_arg1.next = shapeDataList;
shapeDataList = _arg1;
}
public function move(_arg1:Number, _arg2:Number):void{
this.x = _arg1;
this.y = _arg2;
}
public function init():void{
x = (y = (r = (vx = (vy = (w = 0)))));
allowSleep = true;
isSleeping = false;
linDamping = 0;
angDamping = 0;
preventRotation = false;
shapeDataList = null;
}
public function rotate(_arg1:Number):void{
if (_arg1 < 0){
_arg1 = (_arg1 + 360);
} else {
if (_arg1 > 360){
_arg1 = (_arg1 - 360);
};
};
r = (_arg1 * (Math.PI / 180));
}
}
}//package de.polygonal.motor2.dynamics
Section 116
//AABB2 (de.polygonal.motor2.math.AABB2)
package de.polygonal.motor2.math {
public class AABB2 {
public var ymax:Number;
public var xmax:Number;
public var ymin:Number;
public var xmin:Number;
public function AABB2(_arg1:Number=1.79769313486232E308, _arg2:Number=1.79769313486232E308, _arg3:Number=4.94065645841247E-324, _arg4:Number=4.94065645841247E-324){
this.xmin = _arg1;
this.ymin = _arg2;
this.xmax = _arg3;
this.ymax = _arg4;
}
public function isEmpty():Boolean{
return ((((xmin > xmax)) || ((ymin > ymax))));
}
public function empty():void{
xmin = (ymin = 2147483647);
xmax = (ymax = -2147483648);
}
public function addPoint(_arg1:Number, _arg2:Number):void{
if (_arg1 < xmin){
xmin = _arg1;
};
if (_arg1 > xmax){
xmax = _arg1;
};
if (_arg2 < ymin){
ymin = _arg2;
};
if (_arg2 > ymax){
ymax = _arg2;
};
}
public function copy():AABB2{
return (new AABB2(xmin, ymin, xmax, ymax));
}
}
}//package de.polygonal.motor2.math
Section 117
//Circle2 (de.polygonal.motor2.math.Circle2)
package de.polygonal.motor2.math {
import flash.geom.*;
public class Circle2 {
public const c:Point;
public var radius:Number;
public function Circle2(_arg1:Number, _arg2:Number, _arg3:Number){
c = new Point();
super();
c.x = _arg1;
c.y = _arg2;
radius = _arg3;
}
public function copy():Circle2{
return (new Circle2(c.x, c.y, radius));
}
}
}//package de.polygonal.motor2.math
Section 118
//ConvexBSP (de.polygonal.motor2.math.ConvexBSP)
package de.polygonal.motor2.math {
public class ConvexBSP {
public static function createBSP(_arg1:int, _arg2:Array, _arg3:Array):ConvexBSPNode{
var _local8:Array;
var _local9:ConvexBSPNode;
var _local10:ConvexBSPNode;
var _local13:Number;
var _local4:Array = new Array();
var _local5:Array = new Array();
var _local6:Array = new Array();
var _local7:Array = new Array();
var _local11:Number = 0;
var _local12 = 1;
while (_local12 < _arg1) {
_local13 = ((_arg3[0].x * _arg2[_local12].x) + (_arg3[0].y * _arg2[_local12].y));
if (_local13 >= 0){
_local4.push(_local12);
} else {
_local6.push(_local12);
};
_local8 = new Array(2, true);
_local8[0] = (_local12 - 1);
_local8[1] = _local12;
if ((((_local11 >= 0)) && ((_local13 >= 0)))){
_local7.push(_local8);
} else {
if ((((_local11 <= 0)) && ((_local13 <= 0)))){
_local5.push(_local8);
} else {
_local5.push(_local8);
_local7.push(_local8);
};
};
_local11 = _local13;
_local12++;
};
_local8 = new Array();
_local8[0] = (_arg1 - 1);
_local8[1] = 0;
_local5.push(_local8);
_local9 = createInternalNode(_arg1, _arg2, _arg3, _local4, _local7);
_local10 = createInternalNode(_arg1, _arg2, _arg3, _local6, _local5);
return (createNode(0, _local9, _local10));
}
public static function createInternalNode(_arg1:int, _arg2:Array, _arg3:Array, _arg4:Array, _arg5:Array):ConvexBSPNode{
var _local12:int;
var _local16:int;
var _local17:int;
var _local18:Number;
var _local19:V2;
var _local20:ConvexBSPNode;
var _local21:ConvexBSPNode;
var _local6:Array = new Array();
var _local7:Array = new Array();
var _local8:Array = new Array();
var _local9:Array = new Array();
var _local10:int = _arg4.length;
var _local11:int = _arg5.length;
if (_local10 > 1){
if ((_local11 & 1) == 0){
_local12 = ((_arg4[0] + _arg4[int((_local10 - 1))]) >> 1);
} else {
if ((_local11 & 1) == 1){
_local12 = (((_arg4[0] + _arg4[int((_local10 - 1))]) / 2) + 0.5);
};
};
} else {
_local12 = _arg4[0];
};
var _local13:Number = _arg3[_local12].x;
var _local14:Number = _arg3[_local12].y;
var _local15:Array = new Array();
_local16 = 0;
while (_local16 < _local10) {
_local17 = _arg4[_local16];
if (_local12 == _local17){
_local15[_local16] = _local17;
} else {
_local19 = _arg2[_local17];
_local18 = ((_local13 * _local19.x) + (_local14 * _local19.y));
_local15[_local16] = _local18;
if (_local18 >= 0){
_local6.push(_local17);
} else {
_local8.push(_local17);
};
};
_local16++;
};
_local15.unshift(-1);
_local15.push(1);
_local16 = 0;
while (_local16 < _local11) {
if ((((_local15[_local16] >= 0)) && ((_local15[int((_local16 + 1))] >= 0)))){
_local9.push(_arg5[_local16]);
} else {
_local7.push(_arg5[_local16]);
};
_local16++;
};
if (_local8.length > 0){
_local20 = createInternalNode(_arg1, _arg2, _arg3, _local8, _local7);
} else {
if (_local7.length > 0){
_local20 = createNode(_local7[0][1]);
};
};
if (_local6.length > 0){
_local21 = createInternalNode(_arg1, _arg2, _arg3, _local6, _local9);
} else {
if (_local9.length > 0){
_local21 = createNode(_local9[0][1]);
};
};
var _local22:ConvexBSPNode = createNode(_local12, _local21, _local20);
return (_local22);
}
public static function createNode(_arg1:int, _arg2:ConvexBSPNode=null, _arg3:ConvexBSPNode=null):ConvexBSPNode{
var _local4:ConvexBSPNode = new ConvexBSPNode();
_local4.I = _arg1;
_local4.R = _arg2;
_local4.L = _arg3;
_local4.right = _arg2;
_local4.left = _arg3;
return (_local4);
}
}
}//package de.polygonal.motor2.math
Section 119
//ConvexBSPNode (de.polygonal.motor2.math.ConvexBSPNode)
package de.polygonal.motor2.math {
import de.polygonal.ds.*;
public class ConvexBSPNode extends BinaryTreeNode {
public var R:ConvexBSPNode;
public var V:V2;
public var I:int;
public var L:ConvexBSPNode;
public var N:V2;
public function ConvexBSPNode(){
super(null);
init();
}
private function init():void{
L = (R = null);
N = (V = null);
I = -1;
}
}
}//package de.polygonal.motor2.math
Section 120
//E2 (de.polygonal.motor2.math.E2)
package de.polygonal.motor2.math {
public class E2 {
public var mag:Number;// = 0
public var d:V2;
public var n:V2;
public var prev:E2;
public var v:V2;
public var w:V2;
public var next:E2;
}
}//package de.polygonal.motor2.math
Section 121
//Tri2 (de.polygonal.motor2.math.Tri2)
package de.polygonal.motor2.math {
public class Tri2 {
public var a:V2;
public var c:V2;
public var b:V2;
public var cm:V2;
public var area:Number;
public var next:Tri2;
public function Tri2(_arg1:V2, _arg2:V2, _arg3:V2){
this.a = _arg1;
this.b = _arg2;
this.c = _arg3;
area = ((((_arg2.x - _arg1.x) * (_arg3.y - _arg1.y)) - ((_arg2.y - _arg1.y) * (_arg3.x - _arg1.x))) / 2);
cm = new V2((((_arg1.x + _arg2.x) + _arg3.x) / 3), (((_arg1.y + _arg2.y) + _arg3.y) / 3));
}
}
}//package de.polygonal.motor2.math
Section 122
//V2 (de.polygonal.motor2.math.V2)
package de.polygonal.motor2.math {
import flash.geom.*;
public class V2 extends Point {
public var isTail:Boolean;
public var next:V2;
public var isHead:Boolean;
public var index:int;
public var prev:V2;
public var edge:E2;
public function V2(_arg1:Number=0, _arg2:Number=0){
super(_arg1, _arg2);
index = -1;
}
public function getAt(_arg1:int):V2{
var _local2:V2 = this;
while (_local2) {
if (_local2.index == _arg1){
return (_local2);
};
if (_local2.isTail){
break;
};
_local2 = _local2.next;
};
return (null);
}
override public function toString():String{
return ((((((((((("{V2, index=" + index) + ", head=") + int(isHead)) + ", tail=") + int(isTail)) + ", x=") + x.toFixed(2)) + ", y=") + y.toFixed(2)) + "}"));
}
public function copy():V2{
return (new V2(x, y));
}
public function deconstruct():void{
var _local2:V2;
var _local1:V2 = this;
while (_local1) {
_local2 = _local1.next;
_local1 = null;
_local1 = _local2;
};
}
public function toArray():Array{
var _local1:int = (index + 1);
var _local2:V2 = next;
while (!(_local2.isHead)) {
_local1++;
_local2 = _local2.next;
};
var _local3:Array = new Array(_local1, true);
_local2 = this;
var _local4:int;
while (_local4 < _local1) {
_local3[_local4] = _local2;
_local2 = _local2.next;
_local4++;
};
return (_local3);
}
}
}//package de.polygonal.motor2.math
Section 123
//Constants (de.polygonal.motor2.Constants)
package de.polygonal.motor2 {
public class Constants {
public static const k_timeUnitsPerSecond:Number = 1;
public static const k_angSleepTolerance:Number = 0;
public static const k_maxManifoldPoints:int = 2;
public static const k_minLineAABBThickness:Number = 20;
public static const k_linSleepToleranceSq:Number = 0.25;
public static const k_linSleepTolerance:Number = 0.5;
public static const k_linSlopSq:Number = 0.0625;
public static const k_linSlop:Number = 0.25;
public static const k_angSleepToleranceSq:Number = 0;
public static const k_maxForceGenerators:int = (1 << 9);
public static const k_maxShapesPerBody:int = 64;
public static const k_maxLinCorrection:Number = 10;
public static const k_angSlop:Number = 0;
public static const k_lengthUnitsPerMeter:Number = 50;
public static const k_invalid:int = 4095;
public static const k_maxPolyVertices:int = 8;
public static const k_contactBaumgarte:Number = 0.2;
public static const k_maxAngCorrection:Number = 0.139626340159546;
public static const k_maxPairs:int = (k_maxProxies << 3);
public static const k_maxProxies:int = (1 << 10);
public static const k_massUnitsPerKilogram:Number = 1;
public static const k_velocityThreshold:Number = 50;
public static const k_timeToSleep:Number = 0.5;
}
}//package de.polygonal.motor2
Section 124
//ContactCallback (de.polygonal.motor2.ContactCallback)
package de.polygonal.motor2 {
import de.polygonal.motor2.dynamics.contact.*;
public interface ContactCallback {
function onContactRemoved(_arg1:Contact):void;
function onContactAdded(_arg1:Contact):void;
}
}//package de.polygonal.motor2
Section 125
//World (de.polygonal.motor2.World)
package de.polygonal.motor2 {
import flash.events.*;
import flash.geom.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.dynamics.joints.data.*;
import de.polygonal.motor2.dynamics.joints.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.collision.nbody.*;
import de.polygonal.motor2.dynamics.forces.*;
public class World extends EventDispatcher {
public var doSleep:Boolean;
private var _shapeCount:int;
private var _bodyCount:int;
private var _contactManager:ContactManager;
private var _callback:WorldCallback;
private var _worldBounds:AABB2;
private var _island:Island;
public var bodyDestroyList:RigidBody;
private var _broadPhase:BroadPhase;
private var _jointCount:int;
public var jointList:Joint;
private var _forceRegistry:ForceRegistry;
public var gravity:Point;
public var contactCount:int;
public var contactList:Contact;
public var bodyList:RigidBody;
private var _groundBody:RigidBody;
public static var doWarmStarting:Boolean = true;
public static var doPositionCorrection:Boolean = true;
public static var stats_timeSimStep:int = 0;
public static var stats_SepAxisQueryCount:int = 0;
public function World(_arg1:AABB2, _arg2:Boolean=true){
if (_arg1.isEmpty()){
throw (new Error("invalid world bounds"));
};
_worldBounds = _arg1.copy();
_worldBounds.xmin = int(_worldBounds.xmin);
_worldBounds.ymin = int(_worldBounds.ymin);
_worldBounds.xmax = int(_worldBounds.xmax);
_worldBounds.ymax = int(_worldBounds.ymax);
this.doSleep = _arg2;
setGravity(0, 100);
setCallback(new NullCallback());
_contactManager = new ContactManager(this);
_contactManager.setFilter(new ContactFilter());
_groundBody = new RigidBody(this, new RigidBodyData());
_forceRegistry = new ForceRegistry();
_island = new Island();
}
public function getBroadPhase():BroadPhase{
return (_broadPhase);
}
public function setGravity(_arg1:Number, _arg2:Number):void{
if (gravity == null){
gravity = new Point();
};
gravity.x = _arg1;
gravity.y = _arg2;
}
public function setBroadPhase(_arg1:BroadPhase):void{
var _local2:Array;
var _local3:ShapeSkeleton;
var _local4:int;
if (_bodyCount == 0){
_broadPhase = _arg1;
_broadPhase.setWorldBounds(_worldBounds);
_broadPhase.setPairHandler(_contactManager);
} else {
_local2 = getShapeList();
_local4 = 0;
while (_local4 < _local2.length) {
_local3 = _local2[_local4];
_broadPhase.destroyProxy(_local3.proxyId);
_local3.proxyId = Proxy.NULL_PROXY;
_local3.broadPhase = null;
_local4++;
};
_broadPhase.deconstruct();
_broadPhase = _arg1;
_broadPhase.setWorldBounds(_worldBounds);
_broadPhase.setPairHandler(_contactManager);
_local4 = 0;
while (_local4 < _local2.length) {
_local3 = _local2[_local4];
_local3.broadPhase = _broadPhase;
_local3.proxyId = _broadPhase.createProxy(_local3);
_local4++;
};
};
}
public function getShapeList():Array{
var _local1:Array = new Array(_shapeCount, true);
var _local2:int;
var _local3:RigidBody = bodyList;
if (_local3 == null){
return (_local1);
};
var _local4:ShapeSkeleton = _local3.shapeList;
while (true) {
if (_local4 != null){
var _temp1 = _local2;
_local2 = (_local2 + 1);
var _local5 = _temp1;
_local1[_local5] = _local4;
_local4 = _local4.next;
} else {
_local3 = _local3.next;
if (_local3 != null){
_local4 = _local3.shapeList;
var _temp2 = _local2;
_local2 = (_local2 + 1);
_local5 = _temp2;
_local1[_local5] = _local4;
_local4 = _local4.next;
} else {
break;
};
};
};
return (_local1);
}
public function destroyJoint(_arg1:Joint):void{
var _local5:RigidBody;
var _local6:ShapeSkeleton;
var _local2:Boolean = _arg1.collideConnected;
if (_arg1.prev){
_arg1.prev.next = _arg1.next;
};
if (_arg1.next){
_arg1.next.prev = _arg1.prev;
};
if (_arg1 == jointList){
jointList = _arg1.next;
};
var _local3:RigidBody = _arg1.body1;
var _local4:RigidBody = _arg1.body2;
_local3.wakeUp();
_local4.wakeUp();
if (_arg1.node1.prev){
_arg1.node1.prev.next = _arg1.node1.next;
};
if (_arg1.node1.next){
_arg1.node1.next.prev = _arg1.node1.prev;
};
if (_arg1.node1 == _local3.jointList){
_local3.jointList = _arg1.node1.next;
};
_arg1.node1.prev = null;
_arg1.node1.next = null;
if (_arg1.node2.prev){
_arg1.node2.prev.next = _arg1.node2.next;
};
if (_arg1.node2.next){
_arg1.node2.next.prev = _arg1.node2.prev;
};
if (_arg1.node2 == _local4.jointList){
_local4.jointList = _arg1.node2.next;
};
_arg1.node2.prev = null;
_arg1.node2.next = null;
_jointCount--;
if (!_local2){
_local5 = ((_local3.shapeCount < _local4.shapeCount)) ? _local3 : _local4;
_local6 = _local5.shapeList;
while (_local6) {
_local6.refreshProxy();
_local6 = _local6.next;
};
};
}
public function getWorldBounds():AABB2{
return (_worldBounds);
}
public function createBody(_arg1:RigidBodyData):RigidBody{
if (_broadPhase == null){
setBroadPhase(new ExhaustiveSearch());
};
var _local2:RigidBody = new RigidBody(this, _arg1);
_local2.next = bodyList;
if (bodyList){
bodyList.prev = _local2;
};
bodyList = _local2;
_bodyCount++;
var _local3:ShapeData = _arg1.shapeDataList;
while (_local3 != null) {
_shapeCount++;
_local3 = _local3.next;
};
return (_local2);
}
public function getGroundBody():RigidBody{
return (_groundBody);
}
public function setContactCallback(_arg1:ContactCallback):void{
_contactManager.setCallback(_arg1);
}
public function setCallback(_arg1:WorldCallback):void{
_callback = _arg1;
}
public function addForce(_arg1:RigidBody, _arg2:ForceGenerator):Boolean{
var _local3:ShapeSkeleton;
if (_arg1 == null){
return (false);
};
if ((_arg2 is Buoyancy)){
_local3 = _arg1.shapeList;
while (_local3) {
_local3.triangulate();
_local3 = _local3.next;
};
};
_forceRegistry.add(_arg1, _arg2);
return (true);
}
public function destroyBody(_arg1:RigidBody):Boolean{
var _local3:JointNode;
var _local5:ShapeSkeleton;
if (_bodyCount == 0){
return (false);
};
if ((_arg1.stateBits & RigidBody.k_bitDestroy)){
return (false);
};
var _local2:JointNode = _arg1.jointList;
while (_local2) {
_local3 = _local2;
_local2 = _local2.next;
_callback.onJointDestroyed(_local3.joint);
destroyJoint(_local3.joint);
};
var _local4:ShapeSkeleton = _arg1.shapeList;
while (_local4) {
_local5 = _local4;
_local4 = _local4.next;
_shapeCount--;
_callback.onShapeDestroyed(_local5);
};
if (_arg1.prev){
_arg1.prev.next = _arg1.next;
};
if (_arg1.next){
_arg1.next.prev = _arg1.prev;
};
if (_arg1 == bodyList){
bodyList = _arg1.next;
};
_arg1.stateBits = (_arg1.stateBits | RigidBody.k_bitDestroy);
if (_bodyCount > 0){
_bodyCount--;
};
_arg1.deconstruct();
_callback.onBodyDestroyed(_arg1);
return (true);
}
public function step(_arg1:Number, _arg2:int):void{
var _local3:RigidBody;
var _local4:Contact;
var _local5:Joint;
var _local6:int;
var _local8:int;
var _local9:RigidBody;
var _local10:ContactNode;
var _local11:JointNode;
var _local12:RigidBody;
var _local14:Joint;
_contactManager.collide();
_forceRegistry.evaluate();
_local3 = bodyList;
while (_local3) {
_local3.stateBits = (_local3.stateBits & ~(32));
_local3 = _local3.next;
};
_local4 = contactList;
while (_local4) {
_local4.stateBits = (_local4.stateBits & ~(Contact.k_bitIsland));
_local4 = _local4.next;
};
_local5 = jointList;
while (_local5) {
_local5.stateBits = (_local5.stateBits & ~(32));
_local5 = _local5.next;
};
var _local7:Array = [];
var _local13 = (((RigidBody.k_bitStatic | RigidBody.k_bitSleep) | RigidBody.k_bitFrozen) | RigidBody.k_bitIsland);
_local12 = bodyList;
while (_local12 != null) {
if ((_local12.stateBits & _local13)){
} else {
_island.bodyCount = 0;
_island.contactCount = 0;
_island.jointCount = 0;
_local7[0] = _local12;
_local8 = 1;
_local12.stateBits = (_local12.stateBits | 32);
while (_local8 > 0) {
--_local8;
_local3 = _local7[_local8];
_island.bodies[int(_island.bodyCount++)] = _local3;
_local3.stateBits = (_local3.stateBits & ~(RigidBody.k_bitSleep));
if ((_local3.stateBits & RigidBody.k_bitStatic)){
} else {
_local10 = _local3.contactList;
while (_local10) {
if ((_local10.contact.stateBits & Contact.k_bitIsland)){
} else {
_island.contacts[int(_island.contactCount++)] = _local10.contact;
_local10.contact.stateBits = (_local10.contact.stateBits | Contact.k_bitIsland);
_local9 = _local10.other;
if ((_local9.stateBits & 32)){
} else {
var _temp1 = _local8;
_local8 = (_local8 + 1);
var _local15 = _temp1;
_local7[_local15] = _local9;
_local9.stateBits = (_local9.stateBits | 32);
};
};
_local10 = _local10.next;
};
_local11 = _local3.jointList;
while (_local11) {
_local14 = _local11.joint;
if ((_local14.stateBits & 32)){
} else {
_island.joints[int(_island.jointCount++)] = _local14;
_local14.stateBits = (_local14.stateBits | 32);
_local9 = _local11.other;
if ((_local9.stateBits & 32)){
} else {
var _temp2 = _local8;
_local8 = (_local8 + 1);
_local15 = _temp2;
_local7[_local15] = _local9;
_local9.stateBits = (_local9.stateBits | 32);
};
};
_local11 = _local11.next;
};
};
};
_island.solve(gravity.x, gravity.y, _arg2, _arg1);
if (doSleep){
_island.updateSleep(_arg1);
};
_local6 = 0;
while (_local6 < _island.bodyCount) {
_local3 = _island.bodies[_local6];
if ((_local3.stateBits & RigidBody.k_bitStatic)){
_local3.stateBits = (_local3.stateBits & ~(32));
};
_local6++;
};
};
_local12 = _local12.next;
};
_local13 = (_local13 & ~(RigidBody.k_bitIsland));
_local3 = bodyList;
while (_local3 != null) {
if ((_local3.stateBits & _local13) > 0){
_local3 = _local3.next;
} else {
_local3.fx = (_local3.fy = (_local3.t = 0));
if (!_local3.updateShapes()){
_callback.onBodyLeftWorld(_local3);
};
_local3 = _local3.next;
};
};
_broadPhase.findPairs();
}
public function getBodyList():Array{
var _local1:Array = new Array(_bodyCount, true);
var _local2:int;
var _local3:RigidBody = bodyList;
if (_local3 == null){
return (_local1);
};
while (_local3 != null) {
var _temp1 = _local2;
_local2 = (_local2 + 1);
var _local4 = _temp1;
_local1[_local4] = _local3;
_local3 = _local3.next;
};
return (_local1);
}
public function removeForce(_arg1:RigidBody, _arg2:ForceGenerator):Boolean{
return (_forceRegistry.remove(_arg1, _arg2));
}
public function getShapeCount():int{
return (_shapeCount);
}
public function getBodyCount():int{
return (_bodyCount);
}
public function createJoint(_arg1:JointData):Joint{
var _local4:RigidBody;
var _local5:ShapeSkeleton;
var _local2:Class = _arg1.getJointClass();
var _local3:Joint = (new _local2(_arg1) as Joint);
_local3.prev = null;
_local3.next = jointList;
if (jointList){
jointList.prev = _local3;
};
jointList = _local3;
_jointCount++;
_local3.node1.joint = _local3;
_local3.node1.other = _local3.body2;
_local3.node1.prev = null;
_local3.node1.next = _local3.body1.jointList;
if (_local3.body1.jointList){
_local3.body1.jointList.prev = _local3.node1;
};
_local3.body1.jointList = _local3.node1;
_local3.node2.joint = _local3;
_local3.node2.other = _local3.body1;
_local3.node2.prev = null;
_local3.node2.next = _local3.body2.jointList;
if (_local3.body2.jointList){
_local3.body2.jointList.prev = _local3.node2;
};
_local3.body2.jointList = _local3.node2;
if (!_arg1.collideConnected){
_local4 = ((_arg1.body1.shapeCount < _arg1.body2.shapeCount)) ? _arg1.body1 : _arg1.body2;
_local5 = _local4.shapeList;
while (_local5) {
_local5.refreshProxy();
_local5 = _local5.next;
};
};
return (_local3);
}
public function setContactFilter(_arg1:ContactFilter):void{
_contactManager.setFilter(_arg1);
}
public function deconstruct():void{
destroyBody(_groundBody);
_broadPhase = null;
}
}
}//package de.polygonal.motor2
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.joints.*;
class NullCallback implements WorldCallback {
private function NullCallback(){
}
public function onBodyLeftWorld(_arg1:RigidBody):void{
}
public function onJointDestroyed(_arg1:Joint):void{
}
public function onBodyDestroyed(_arg1:RigidBody):void{
}
public function onShapeDestroyed(_arg1:ShapeSkeleton):void{
}
}
Section 126
//WorldCallback (de.polygonal.motor2.WorldCallback)
package de.polygonal.motor2 {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.joints.*;
public interface WorldCallback {
function onBodyDestroyed(_arg1:RigidBody):void;
function onBodyLeftWorld(_arg1:RigidBody):void;
function onJointDestroyed(_arg1:Joint):void;
function onShapeDestroyed(_arg1:ShapeSkeleton):void;
}
}//package de.polygonal.motor2
Section 127
//ByteArrayAsset (mx.core.ByteArrayAsset)
package mx.core {
import flash.utils.*;
public class ByteArrayAsset extends ByteArray {
}
}//package mx.core
Section 128
//HurlBerl (HurlBerl)
package {
import flash.events.*;
import flash.display.*;
import com.kerb.hurlBerl.*;
public class HurlBerl extends Sprite {
private var SWFBytes:Class;
public function HurlBerl(){
SWFBytes = HurlBerl_SWFBytes;
super();
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
var _local2:int = loaderInfo.width;
var _local3:int = loaderInfo.height;
var _local4:Sprite = new Sprite();
var _local5:Graphics = _local4.graphics;
_local5.beginFill(0);
_local5.drawRect(-1000, -1000, (2000 + _local2), 1000);
_local5.drawRect(-1000, _local3, (2000 + _local2), 1000);
_local5.drawRect(-1000, -1000, 1000, (1000 + _local3));
_local5.drawRect(_local2, -1000, 1000, (1000 + _local3));
_local5.endFill();
addChild(_local4);
addChildAt(new Main(SWFBytes), 0);
}
}
}//package
Section 129
//HurlBerl_SWFBytes (HurlBerl_SWFBytes)
package {
import mx.core.*;
public class HurlBerl_SWFBytes extends ByteArrayAsset {
}
}//package