Section 1
//MochiBot (com.mochibot.MochiBot)
package com.mochibot {
import flash.display.*;
import flash.net.*;
import flash.system.*;
public dynamic class MochiBot extends Sprite {
public static const TESTING_TAG:String = "...";
public static function track(_arg1:Sprite, _arg2:String):MochiBot{
var _local3:MochiBot;
var _local4:String;
var _local5:URLVariables;
var _local6:String;
var _local7:URLRequest;
var _local8:Loader;
if ((((_arg2 == "")) || ((_arg2 == TESTING_TAG)))){
return (null);
};
if (Security.sandboxType == "localWithFile"){
return (null);
};
_local3 = new (MochiBot);
_arg1.addChild(_local3);
Security.allowDomain("*");
Security.allowInsecureDomain("*");
_local4 = "http://core.mochibot.com/my/core.swf";
_local5 = new URLVariables();
_local5["sb"] = Security.sandboxType;
_local5["v"] = Capabilities.version;
_local5["swfid"] = _arg2;
_local5["mv"] = "8";
_local5["fv"] = "9";
_local6 = _local3.root.loaderInfo.loaderURL;
if (_local6.indexOf("http") == 0){
_local5["url"] = _local6;
} else {
_local5["url"] = "local";
};
_local7 = new URLRequest(_local4);
_local7.contentType = "application/x-www-form-urlencoded";
_local7.method = URLRequestMethod.POST;
_local7.data = _local5;
_local8 = new Loader();
_local3.addChild(_local8);
_local8.load(_local7);
return (_local3);
}
}
}//package com.mochibot
Section 2
//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 fill(_arg1):void{
var _local2:int;
var _local3:int;
var _local4:Class;
_local2 = (_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 get size():int{
return ((_w * _h));
}
public function getCol(_arg1:int):Array{
var _local2:Array;
var _local3:int;
_local2 = [];
_local3 = 0;
while (_local3 < _h) {
_local2[_local3] = _a[int(((_local3 * _w) + _arg1))];
_local3++;
};
return (_local2);
}
public function shiftLeft():void{
var _local1:int;
var _local2:int;
var _local3:int;
if (_w == 1){
return;
};
_local1 = (_w - 1);
_local3 = 0;
while (_local3 < _h) {
_local2 = ((_local3 * _w) + _local1);
_a.splice(_local2, 0, _a.splice((_local2 - _local1), 1));
_local3++;
};
}
public function set width(_arg1:int):void{
resize(_arg1, _h);
}
public function appendCol(_arg1:Array):void{
var _local2:int;
_arg1.length = _h;
_local2 = 0;
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 shiftDown():void{
var _local1:int;
if (_h == 1){
return;
};
_local1 = ((_h - 1) * _w);
_a = _a.slice(_local1, (_local1 + _w)).concat(_a);
_a.splice((_h * _w), _w);
}
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{
var _local3:int;
var _local4:int;
if ((((_arg1 < 0)) || ((_arg1 > _h)))){
throw (new Error("row index out of bounds"));
};
_local3 = (_arg1 * _w);
_local4 = 0;
while (_local4 < _w) {
_a[int((_local3 + _local4))] = _arg2[_local4];
_local4++;
};
}
public function prependCol(_arg1:Array):void{
var _local2:int;
_arg1.length = _h;
_local2 = 0;
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;
var _local2:int;
_local1 = _a.concat();
_local2 = size;
if (_local1.length > _local2){
_local1.length = _local2;
};
return (_local1);
}
public function contains(_arg1):Boolean{
var _local2:int;
var _local3:int;
_local2 = size;
_local3 = 0;
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 _local1:String;
var _local2:int;
var _local3:*;
var _local4:int;
var _local5:int;
_local1 = "Array2\n{";
_local4 = 0;
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;
_local2 = (_arg1 * _w);
return (_a.slice(_local2, (_local2 + _w)));
}
public function get height():int{
return (_h);
}
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 _local3:Array;
var _local4:int;
var _local5:int;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
if ((((_arg1 < 2)) || ((_arg2 < 2)))){
throw (new Error("illegal size"));
};
_local3 = _a.concat();
_a.length = 0;
_a.length = (_arg1 * _arg2);
_local4 = ((_arg1 < _w)) ? _arg1 : _w;
_local5 = ((_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 _local1:Array;
var _local2:int;
var _local3:int;
_local1 = _a.concat();
_local2 = 0;
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 _local1:int;
var _local2:int;
var _local3:int;
if (_w == 1){
return;
};
_local1 = (_w - 1);
_local3 = 0;
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{
var _local3:int;
if ((((_arg1 < 0)) || ((_arg1 > _w)))){
throw (new Error("column index out of bounds"));
};
_local3 = 0;
while (_local3 < _h) {
_a[int(((_local3 * _w) + _arg1))] = _arg2[_local3];
_local3++;
};
}
}
}//package de.polygonal.ds
class Array2Iterator implements Iterator {
private var _a2:Array2;
private var _xCursor:int;
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:*;
_local1 = data;
if (++_xCursor == _a2.width){
_yCursor++;
_xCursor = 0;
};
return (_local1);
}
}
Section 3
//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 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{
var _local1:int;
_que = new Array(_size);
_front = (_count = 0);
_local1 = 0;
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 get size():int{
return (_count);
}
public function peek(){
return (_que[_front]);
}
public function toArray():Array{
var _local1:Array;
var _local2:int;
_local1 = new Array(_count);
_local2 = 0;
while (_local2 < _count) {
_local1[_local2] = _que[int(((_local2 + _front) & _divisor))];
_local2++;
};
return (_local1);
}
public function dispose():void{
if (!_front){
_que[int((_size - 1))] = null;
} else {
_que[int((_front - 1))] = null;
};
}
public function getIterator():Iterator{
return (new ArrayedQueueIterator(this));
}
public function contains(_arg1):Boolean{
var _local2:int;
_local2 = 0;
while (_local2 < _count) {
if (_que[int(((_local2 + _front) & _divisor))] === _arg1){
return (true);
};
_local2++;
};
return (false);
}
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 _local1:String;
var _local2:int;
_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 start():void{
_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);
}
}
Section 4
//BinaryTreeNode (de.polygonal.ds.BinaryTreeNode)
package de.polygonal.ds {
public class BinaryTreeNode {
public var data;
public var left:BinaryTreeNode;
public var parent:BinaryTreeNode;
public var right:BinaryTreeNode;
public function BinaryTreeNode(_arg1){
this.data = _arg1;
parent = (left = (right = null));
}
public function isLeft():Boolean{
return ((this == parent.left));
}
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:int;
var _local3:int;
_local2 = -1;
_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 isRight():Boolean{
return ((this == parent.right));
}
public function count():int{
var _local1:int;
_local1 = 1;
if (left){
_local1 = (_local1 + left.count());
};
if (right){
_local1 = (_local1 + right.count());
};
return (_local1);
}
public function setRight(_arg1):void{
if (!right){
right = new BinaryTreeNode(_arg1);
right.parent = this;
} else {
right.data = data;
};
}
public function destroy():void{
if (left){
left.destroy();
};
left = null;
if (right){
right.destroy();
};
right = null;
}
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 5
//Collection (de.polygonal.ds.Collection)
package de.polygonal.ds {
public interface Collection {
function isEmpty():Boolean;
function getIterator():Iterator;
function get size():int;
function clear():void;
function toArray():Array;
function contains(_arg1):Boolean;
}
}//package de.polygonal.ds
Section 6
//Iterator (de.polygonal.ds.Iterator)
package de.polygonal.ds {
public interface Iterator {
function start():void;
function next();
function set data(_arg1):void;
function get data();
function hasNext():Boolean;
}
}//package de.polygonal.ds
Section 7
//PM_PRNG (de.polygonal.math.PM_PRNG)
package de.polygonal.math {
public class PM_PRNG {
public var seed:uint;
public function PM_PRNG(){
seed = 1;
}
public function nextIntRange(_arg1:Number, _arg2:Number):uint{
_arg1 = (_arg1 - 0.4999);
_arg2 = (_arg2 + 0.4999);
return (Math.round((_arg1 + ((_arg2 - _arg1) * nextDouble()))));
}
public function nextDouble():Number{
return ((gen() / 2147483647));
}
public function nextDoubleRange(_arg1:Number, _arg2:Number):Number{
return ((_arg1 + ((_arg2 - _arg1) * nextDouble())));
}
public function nextInt():uint{
return (gen());
}
private function gen():uint{
return ((seed = ((seed * 16807) % 2147483647)));
}
}
}//package de.polygonal.math
Section 8
//BroadPhase (de.polygonal.motor2.collision.nbody.BroadPhase)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.*;
import de.polygonal.motor2.math.*;
import flash.geom.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.ds.*;
public class BroadPhase implements IBroadPhase {
public var proxyLookup:Array;
public var world:World;
protected var _ymin:Number;
protected var _ymax:Number;
protected var _xmin:Number;
public var pairBuffer:Array;
public var proxyList:ShapeProxy;
protected var _xmax:Number;
protected var _pairHandler:IPairCallback;
public var freeProxy:int;
public var proxyIdQueue:ArrayedQueue;
public var worldAABB:AABB2;
public var proxyQue:ArrayedQueue;
public var pairBufferCount:int;
public function BroadPhase(){
init();
}
public function init():void{
var _local1:ShapeProxy;
var _local2:int;
var _local3:int;
_local2 = Constants.k_maxProxies;
proxyLookup = new Array(_local2);
proxyQue = new ArrayedQueue(_local2);
_local3 = 0;
while (_local3 < _local2) {
_local1 = new ShapeProxy();
_local1.id = (_local3 + 1);
proxyQue.enqueue(_local1);
proxyLookup[_local1.id] = _local1;
_local3++;
};
proxyList = null;
pairBuffer = new Array(Constants.k_maxPairs);
pairBufferCount = 0;
_local2 = Constants.k_maxPairs;
}
public function inRange2(_arg1:Number):Boolean{
return (false);
}
public function moveProxy(_arg1:int):void{
}
protected function addBufferedPair(_arg1:int, _arg2:int):void{
var _local3:ShapeProxy;
var _local4:ShapeProxy;
var _local5:Pair;
_local3 = proxyLookup[_arg1];
_local4 = proxyLookup[_arg2];
if (_local3.groupIndex == _local4.groupIndex){
if (_local3.groupIndex != 0){
if (_local3.groupIndex <= 0){
return;
};
};
};
if ((_local3.maskBits & _local4.categoryBits) == 0){
return;
};
if ((_local3.categoryBits & _local4.maskBits) == 0){
return;
};
if (_local5 == null){
return;
};
if (_local5.isBuffered() == false){
if (pairBufferCount < Constants.k_maxPairs){
_local5.setBuffered();
pairBufferCount++;
};
};
_local5.clearRemoved();
}
public function inRange(_arg1:AABB2):Boolean{
return (false);
}
public function search():void{
}
public function setWorldBounds(_arg1:AABB2):void{
this.worldAABB = _arg1;
_xmin = worldAABB.xmin;
_ymin = worldAABB.ymin;
_xmax = worldAABB.xmax;
_ymax = worldAABB.ymax;
}
public function query(_arg1:Point, _arg2:Number, _arg3:Array, _arg4:int):int{
return (0);
}
public function removeProxy(_arg1:int):void{
var _local2:ShapeProxy;
_local2 = proxyLookup[_arg1];
if (_local2.prev){
_local2.prev.next = _local2.next;
};
if (_local2.next){
_local2.next.prev = _local2.prev;
};
if (_local2 == proxyList){
proxyList = _local2.next;
};
_local2.init();
proxyQue.enqueue(_local2);
}
public function setPairHandler(_arg1:IPairCallback):void{
_pairHandler = _arg1;
}
public function createProxy(_arg1:int, _arg2:int, _arg3:int, _arg4:ShapeSkeleton):int{
var _local5:ShapeProxy;
_local5 = proxyQue.dequeue();
_local5.shape = _arg4;
_local5.groupIndex = _arg1;
_local5.categoryBits = _arg2;
_local5.maskBits = _arg3;
proxyLookup[_local5.id] = _local5;
_local5.next = proxyList;
if (proxyList){
proxyList.prev = _local5;
};
proxyList = _local5;
return (_local5.id);
}
public function setWorld(_arg1:World):void{
this.world = _arg1;
}
public function insideBounds(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
return (false);
}
public function Flush():void{
}
protected function removeBufferedPair(_arg1:int, _arg2:int):void{
var _local3:Pair;
if (_local3 == null){
return;
};
if (_local3.isBuffered() == false){
if (pairBufferCount < Constants.k_maxPairs){
_local3.setBuffered();
pairBuffer[pairBufferCount].proxyId1 = _local3.proxyId1;
pairBuffer[pairBufferCount].proxyId2 = _local3.proxyId2;
pairBufferCount++;
};
};
_local3.setRemoved();
}
}
}//package de.polygonal.motor2.collision.nbody
Section 9
//ExhaustiveSearch (de.polygonal.motor2.collision.nbody.ExhaustiveSearch)
package de.polygonal.motor2.collision.nbody {
import flash.geom.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import flash.utils.*;
public class ExhaustiveSearch extends BroadPhase {
public var _pairs:Dictionary;
public function ExhaustiveSearch(){
_pairs = new Dictionary(true);
}
override public function search():void{
var _local1:ShapeProxy;
var _local2:ShapeSkeleton;
var _local3:int;
var _local4:ShapeProxy;
var _local5:ShapeSkeleton;
var _local6:int;
var _local7:Contact;
var _local8:int;
var _local9:Pair;
_local1 = proxyList;
while (_local1) {
_local3 = _local1.id;
_local2 = _local1.shape;
_local4 = _local1.next;
while (_local4) {
_local6 = _local4.id;
_local5 = _local4.shape;
if (_local1.groupIndex == _local4.groupIndex){
//unresolved if
//unresolved if
} else {
if ((_local1.maskBits & _local4.categoryBits) == 0){
} else {
if ((_local1.categoryBits & _local4.maskBits) == 0){
} else {
if ((((((((_local2.xmin > _local5.xmax)) || ((_local2.xmax < _local5.xmin)))) || ((_local2.ymin > _local5.ymax)))) || ((_local2.ymax < _local5.ymin)))){
if ((((_local1.overlapCount > 0)) && ((_local4.overlapCount > 0)))){
if (_local3 < _local6){
_local8 = ((_local3 << 16) | (_local6 << 8));
} else {
_local8 = ((_local6 << 16) | (_local3 << 8));
};
_local9 = _pairs[_local8];
if (_local9){
_local1.overlapCount--;
_local4.overlapCount--;
_pairHandler.pairRemoved(_local3, _local6, (_local9.userData as Contact));
_pairs[_local8] = undefined;
};
};
} else {
if (_local3 < _local6){
_local8 = ((_local3 << 16) | (_local6 << 8));
} else {
_local8 = ((_local6 << 16) | (_local3 << 8));
};
if (_pairs[_local8] == undefined){
_local1.overlapCount++;
_local4.overlapCount++;
_local7 = _pairHandler.pairAdded(_local2, _local5);
_pairs[_local8] = new Pair(_local3, _local6, _local7);
};
};
};
};
};
_local4 = _local4.next;
};
_local1 = _local1.next;
};
}
override public function query(_arg1:Point, _arg2:Number, _arg3:Array, _arg4:int):int{
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:int;
var _local11:ShapeSkeleton;
var _local12:ShapeProxy;
_local5 = _arg1.x;
_local7 = _arg1.y;
_local9 = (_arg2 * _arg2);
_local12 = proxyList;
while (_local12) {
_local11 = _local12.shape;
_local6 = (_local11.x - _local5);
_local8 = (_local11.y - _local7);
if (((_local6 * _local6) + (_local8 * _local8)) < _local9){
var _temp1 = _local10;
_local10 = (_local10 + 1);
var _local13 = _temp1;
_arg3[_local13] = _local11;
if (_local10 == _arg4){
break;
};
};
_local12 = _local12.next;
};
return (_local10);
}
override public function insideBounds(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
return (true);
}
}
}//package de.polygonal.motor2.collision.nbody
Section 10
//IBroadPhase (de.polygonal.motor2.collision.nbody.IBroadPhase)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.*;
import de.polygonal.motor2.math.*;
import flash.geom.*;
import de.polygonal.motor2.collision.shapes.*;
public interface IBroadPhase {
function setWorldBounds(_arg1:AABB2):void;
function search():void;
function removeProxy(_arg1:int):void;
function setPairHandler(_arg1:IPairCallback):void;
function query(_arg1:Point, _arg2:Number, _arg3:Array, _arg4:int):int;
function setWorld(_arg1:World):void;
function insideBounds(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean;
function createProxy(_arg1:int, _arg2:int, _arg3:int, _arg4:ShapeSkeleton):int;
function inRange(_arg1:AABB2):Boolean;
function moveProxy(_arg1:int):void;
}
}//package de.polygonal.motor2.collision.nbody
Section 11
//IPairCallback (de.polygonal.motor2.collision.nbody.IPairCallback)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.dynamics.contact.*;
public interface IPairCallback {
function pairRemoved(_arg1, _arg2, _arg3):void;
function pairAdded(_arg1, _arg2):Contact;
}
}//package de.polygonal.motor2.collision.nbody
Section 12
//Pair (de.polygonal.motor2.collision.nbody.Pair)
package de.polygonal.motor2.collision.nbody {
public class Pair {
public var proxyId1:int;
public var proxyId2:int;
public var status:int;
public var userData;
public static const PAIR_BUFFERED:int = (1 << 1);
public static const PAIR_RECEIVED:int = (1 << 2);
public static const MAX_PROXIES:int = (1 << 10);
public static const NULL_PAIR:int = (1 << 16);
public static const TABLE_MASK:int = (TABLE_CAPACITY - 1);
public static const TABLE_CAPACITY:int = MAX_PAIRS;
public static const PAIR_REMOVED:int = (1 << 3);
public static const NULL_PROXY:int = (1 << 16);
public static const MAX_PAIRS:int = (MAX_PROXIES << 3);
public function Pair(_arg1:int=0, _arg2:int=0, _arg3=null):void{
if (_arg1 > _arg2){
this.proxyId1 = _arg2;
this.proxyId2 = _arg1;
} else {
this.proxyId1 = _arg1;
this.proxyId2 = _arg2;
};
this.userData = _arg3;
}
public function setBuffered():void{
status = (status | PAIR_BUFFERED);
}
public function isReceived():Boolean{
return (((status & PAIR_RECEIVED) == PAIR_RECEIVED));
}
public function clearBuffered():void{
status = (status & ~(PAIR_BUFFERED));
}
public function isRemoved():Boolean{
return (((status & PAIR_REMOVED) == PAIR_REMOVED));
}
public function init(_arg1:int, _arg2:int, _arg3):void{
if (_arg1 > _arg2){
this.proxyId1 = _arg2;
this.proxyId2 = _arg1;
} else {
this.proxyId1 = _arg1;
this.proxyId2 = _arg2;
};
this.userData = _arg3;
}
public function isBuffered():Boolean{
return (((status & PAIR_BUFFERED) == PAIR_BUFFERED));
}
public function clearRemoved():void{
status = (status & ~(PAIR_REMOVED));
}
public function setReceived():void{
status = (status | PAIR_RECEIVED);
}
public function setRemoved():void{
status = (status | PAIR_REMOVED);
}
}
}//package de.polygonal.motor2.collision.nbody
Section 13
//ShapeProxy (de.polygonal.motor2.collision.nbody.ShapeProxy)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.collision.shapes.*;
public class ShapeProxy {
public var categoryBits:int;
public var overlapCount:int;
public var shape:ShapeSkeleton;
public var maskBits:int;
public var prev:ShapeProxy;
public var groupIndex:int;
public var next:ShapeProxy;
public var id:int;
public var userData;
public static const NULL_PROXY:int = 2147483647;
public function ShapeProxy(){
init();
}
public function updateIntervals():void{
}
public function init():void{
next = (prev = null);
shape = null;
id = (categoryBits = (maskBits = (groupIndex = -1)));
overlapCount = 0;
}
}
}//package de.polygonal.motor2.collision.nbody
Section 14
//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 _local5:BoxContact;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:int;
var _local12:Number;
var _local13:Number;
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 _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:Number;
var _local42:Number;
var _local43:Number;
var _local44:Number;
var _local45:Number;
var _local46:ContactPoint;
_local5 = BoxContact(_arg4);
_local12 = (_arg3.x - _arg2.x);
_local13 = (_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;
};
};
};
};
_local35 = ((-(_local21.r11) * _local6) - (_local21.r21 * _local7));
_local36 = ((-(_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;
};
};
};
_local37 = _local31;
_local38 = _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 15
//CollideBoxCircle (de.polygonal.motor2.collision.pairwise.CollideBoxCircle)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
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 _local10:int;
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;
_local10 = 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.I;
_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.I;
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.I;
_local9.id.incEdge = _local10;
} else {
if (_local35 >= _local6){
_local33 = _local23.next.x;
_local34 = _local23.next.y;
_local9.id.incVert = _local23.next.I;
_local9.id.incEdge = _local10;
} else {
_local33 = ((_local29 * _local35) + _local23.x);
_local34 = ((_local30 * _local35) + _local23.y);
_local9.id.incVert = _local10;
_local9.id.incEdge = _local23.I;
};
};
_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 16
//CollideBoxLineDS (de.polygonal.motor2.collision.pairwise.CollideBoxLineDS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideBoxLineDS 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:Number;
var _local13:Number;
var _local14:int;
var _local15:V2;
var _local16:V2;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:ShapeSkeleton;
var _local22:Number;
var _local23:Number;
var _local24:int;
var _local25:int;
var _local26:int;
var _local27:V2;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:ContactPoint;
var _local40:V2;
_local13 = -2147483648;
_local14 = 0;
_local9 = _arg3.worldVertexChain;
_local8 = _arg3.worldNormalChain;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((-(_local5.N.y) * _local8.x) + (_local5.N.x * _local8.y)))<=0) ? _local5.R : _local5.L;
};
_local6 = _local5.V;
_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;
_local14 = 1;
};
_local9 = _local9.next;
_local8 = _local8.next;
_local6 = _local6.next.next;
_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;
_local14 = 1;
};
_local15 = _arg3.worldVertexChain;
_local16 = _local15.next;
_local17 = _local15.x;
_local18 = _local16.x;
_local19 = _local15.y;
_local20 = _local16.y;
_local9 = _arg2.worldVertexChain.next;
_local8 = _arg2.worldNormalChain.next;
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){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local15;
_local14 = 0;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local16;
_local14 = 0;
};
} else {
_local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local16;
_local14 = 0;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_local12 = ((_local8.x * (_local17 - _local9.x)) + (_local8.y * (_local19 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local15;
_local14 = 0;
};
};
_local9 = _arg2.worldVertexChain;
_local8 = _arg2.worldNormalChain;
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){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local15;
_local14 = 0;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local16;
_local14 = 0;
};
} else {
_local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local16;
_local14 = 0;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_local12 = ((_local8.x * (_local17 - _local9.x)) + (_local8.y * (_local19 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local15;
_local14 = 0;
};
};
_local21 = _arg2;
_local22 = _local7.x;
_local23 = _local7.y;
_local24 = _local10.I;
_local25 = _local11.I;
_local27 = _local11.userData.n;
_local28 = ((_local27.x * _local22) + (_local27.y * _local23));
if (((_local27.prev.x * _local22) + (_local27.prev.y * _local23)) < _local28){
_local11 = _local11.prev;
_local26 = _local27.prev.I;
} else {
if (((_local27.next.x * _local22) + (_local27.next.y * _local23)) < _local28){
_local11 = _local11.next;
_local26 = _local27.next.I;
};
};
_local29 = (((_local21.x * _local22) + (_local21.y * _local23)) + (((_local10.x - _local21.x) * _local22) + ((_local10.y - _local21.y) * _local23)));
if (_local21.regularShape){
_local30 = ((_local21.y * _local22) - (_local21.x * _local23));
} else {
_local40 = _local21.offsets[_local10.I];
_local30 = ((((_local21.y + (_local21.r21 * _local40.x)) + (_local21.r22 * _local40.y)) * _local22) - (((_local21.x + (_local21.r11 * _local40.x)) + (_local21.r12 * _local40.y)) * _local23));
};
_local31 = (_local10.userData.mag / 2);
_local36 = ((((_local11.x * _local23) - (_local11.y * _local22)) + _local30) - _local31);
_local37 = ((((_local11.next.x * _local23) - (_local11.next.y * _local22)) + _local30) - _local31);
if ((_local36 * _local37) < 0){
_local38 = (_local36 / (_local36 - _local37));
if (_local36 < 0){
_local32 = _local11.x;
_local34 = _local11.y;
_local33 = (_local32 + (_local38 * (_local11.next.x - _local32)));
_local35 = (_local34 + (_local38 * (_local11.next.y - _local34)));
} else {
_local32 = _local11.next.x;
_local34 = _local11.next.y;
_local33 = (_local11.x + (_local38 * (_local32 - _local11.x)));
_local35 = (_local11.y + (_local38 * (_local34 - _local11.y)));
};
} else {
if (_local36 > 0){
_arg1.pointCount = 0;
return;
};
if (_local36 < _local37){
_local32 = _local11.x;
_local34 = _local11.y;
_local33 = _local11.next.x;
_local35 = _local11.next.y;
} else {
_local33 = _local11.x;
_local35 = _local11.y;
_local32 = _local11.next.x;
_local34 = _local11.next.y;
};
};
_local36 = ((((_local34 * _local22) - _local30) - _local31) - (_local32 * _local23));
_local37 = ((((_local35 * _local22) - _local30) - _local31) - (_local33 * _local23));
if ((_local36 * _local37) < 0){
_local38 = (_local36 / (_local36 - _local37));
_local32 = (_local32 + (_local38 * (_local33 - _local32)));
_local34 = (_local34 + (_local38 * (_local35 - _local34)));
} else {
if (_local36 > 0){
_arg1.pointCount = 0;
return;
};
};
_local13 = (((_local22 * _local32) + (_local23 * _local34)) - _local29);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local22);
_arg1.ny = -(_local23);
} else {
_arg1.nx = _local22;
_arg1.ny = _local23;
};
_local39 = _arg1.c0;
_local39.sep = _local13;
_local39.x = _local32;
_local39.y = _local34;
_local39.id.flip = _local14;
_local39.id.incEdge = _local26;
_local39.id.incVert = _local25;
_local39.id.refFace = _local24;
_local39.id.bake();
_local13 = (((_local22 * _local33) + (_local23 * _local35)) - _local29);
if (_local13 <= 0){
_arg1.pointCount = 2;
_local39 = _arg1.c1;
_local39.sep = _local13;
_local39.x = _local33;
_local39.y = _local35;
_local39.id.flip = _local14;
_local39.id.incEdge = _local26;
_local39.id.incVert = _local25;
_local39.id.refFace = _local24;
_local39.id.bake();
};
} else {
_local13 = (((_local22 * _local33) + (_local23 * _local35)) - _local29);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local22);
_arg1.ny = -(_local23);
} else {
_arg1.nx = _local22;
_arg1.ny = _local23;
};
_local39 = _arg1.c0;
_local39.sep = _local13;
_local39.x = _local33;
_local39.y = _local35;
_local39.id.flip = _local14;
_local39.id.incEdge = _local26;
_local39.id.incVert = _local25;
_local39.id.refFace = _local24;
_local39.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 17
//CollideBoxLineSS (de.polygonal.motor2.collision.pairwise.CollideBoxLineSS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideBoxLineSS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:V2;
var _local6:ConvexBSPNode;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local13:Number;
var _local14:int;
var _local15:V2;
var _local16:V2;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:ShapeSkeleton;
var _local22:Number;
var _local23:Number;
var _local24:int;
var _local25:int;
var _local26:int;
var _local27:V2;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:ContactPoint;
var _local40:V2;
_local5 = _arg3.worldNormalChain;
if ((((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d) < 0){
_arg4.disabled = true;
_arg1.pointCount = 0;
return;
};
_local13 = -2147483648;
_local14 = 0;
_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;
_local7 = _local7.next.next;
_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;
};
_local15 = _arg3.worldVertexChain;
_local16 = _local15.next;
_local17 = _local15.x;
_local18 = _local16.x;
_local19 = _local15.y;
_local20 = _local16.y;
_local9 = _arg2.worldVertexChain.next;
_local8 = _arg2.worldNormalChain.next;
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;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_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;
};
} 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;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_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;
};
};
_local9 = _arg2.worldVertexChain;
_local8 = _arg2.worldNormalChain;
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;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_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;
};
} 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;
};
_local9 = _local9.next.next;
_local8 = _local8.next.next;
_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;
};
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
_local21 = _arg2;
_local22 = _local5.x;
_local23 = _local5.y;
_local24 = _local10.I;
_local25 = _local11.I;
_local27 = _local11.userData.n;
_local28 = ((_local27.x * _local22) + (_local27.y * _local23));
if (((_local27.prev.x * _local22) + (_local27.prev.y * _local23)) < _local28){
_local11 = _local11.prev;
_local26 = _local27.prev.I;
} else {
if (((_local27.next.x * _local22) + (_local27.next.y * _local23)) < _local28){
_local11 = _local11.next;
_local26 = _local27.next.I;
};
};
_local29 = (((_local21.x * _local22) + (_local21.y * _local23)) + (((_local10.x - _local21.x) * _local22) + ((_local10.y - _local21.y) * _local23)));
if (_local21.regularShape){
_local30 = ((_local21.y * _local22) - (_local21.x * _local23));
} else {
_local40 = _local21.offsets[_local10.I];
_local30 = ((((_local21.y + (_local21.r21 * _local40.x)) + (_local21.r22 * _local40.y)) * _local22) - (((_local21.x + (_local21.r11 * _local40.x)) + (_local21.r12 * _local40.y)) * _local23));
};
_local31 = (_local10.userData.mag / 2);
_local36 = ((((_local11.x * _local23) - (_local11.y * _local22)) + _local30) - _local31);
_local37 = ((((_local11.next.x * _local23) - (_local11.next.y * _local22)) + _local30) - _local31);
if ((_local36 * _local37) < 0){
_local38 = (_local36 / (_local36 - _local37));
if (_local36 < 0){
_local32 = _local11.x;
_local34 = _local11.y;
_local33 = (_local32 + (_local38 * (_local11.next.x - _local32)));
_local35 = (_local34 + (_local38 * (_local11.next.y - _local34)));
} else {
_local32 = _local11.next.x;
_local34 = _local11.next.y;
_local33 = (_local11.x + (_local38 * (_local32 - _local11.x)));
_local35 = (_local11.y + (_local38 * (_local34 - _local11.y)));
};
} else {
if (_local36 > 0){
_arg1.pointCount = 0;
return;
};
if (_local36 < _local37){
_local32 = _local11.x;
_local34 = _local11.y;
_local33 = _local11.next.x;
_local35 = _local11.next.y;
} else {
_local33 = _local11.x;
_local35 = _local11.y;
_local32 = _local11.next.x;
_local34 = _local11.next.y;
};
};
_local36 = ((((_local34 * _local22) - _local30) - _local31) - (_local32 * _local23));
_local37 = ((((_local35 * _local22) - _local30) - _local31) - (_local33 * _local23));
if ((_local36 * _local37) < 0){
_local38 = (_local36 / (_local36 - _local37));
_local32 = (_local32 + (_local38 * (_local33 - _local32)));
_local34 = (_local34 + (_local38 * (_local35 - _local34)));
} else {
if (_local36 > 0){
_arg1.pointCount = 0;
return;
};
};
_local13 = (((_local22 * _local32) + (_local23 * _local34)) - _local29);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local22);
_arg1.ny = -(_local23);
} else {
_arg1.nx = _local22;
_arg1.ny = _local23;
};
_local39 = _arg1.c0;
_local39.sep = _local13;
_local39.x = _local32;
_local39.y = _local34;
_local39.id.flip = _local14;
_local39.id.incEdge = _local26;
_local39.id.incVert = _local25;
_local39.id.refFace = _local24;
_local39.id.bake();
_local13 = (((_local22 * _local33) + (_local23 * _local35)) - _local29);
if (_local13 <= 0){
_arg1.pointCount = 2;
_local39 = _arg1.c1;
_local39.sep = _local13;
_local39.x = _local33;
_local39.y = _local35;
_local39.id.flip = _local14;
_local39.id.incEdge = _local26;
_local39.id.incVert = _local25;
_local39.id.refFace = _local24;
_local39.id.bake();
};
} else {
_local13 = (((_local22 * _local33) + (_local23 * _local35)) - _local29);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local22);
_arg1.ny = -(_local23);
} else {
_arg1.nx = _local22;
_arg1.ny = _local23;
};
_local39 = _arg1.c0;
_local39.sep = _local13;
_local39.x = _local33;
_local39.y = _local35;
_local39.id.flip = _local14;
_local39.id.incEdge = _local26;
_local39.id.incVert = _local25;
_local39.id.refFace = _local24;
_local39.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 18
//CollideBoxPlaneDS (de.polygonal.motor2.collision.pairwise.CollideBoxPlaneDS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideBoxPlaneDS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:V2;
var _local14:ContactPoint;
var _local15:V2;
var _local16:int;
var _local17:int;
var _local18:Number;
_local6 = _arg3.worldNormalChain.x;
_local7 = _arg3.worldNormalChain.y;
_local8 = ((_local6 * _arg2.r11) + (_local7 * _arg2.r21));
_local9 = ((_local6 * _arg2.r12) + (_local7 * _arg2.r22));
_local10 = ((_arg2.ex * ((_local8 < 0)) ? -(_local8) : _local8) + (_arg2.ey * ((_local9 < 0)) ? -(_local9) : _local9));
_local11 = _arg3.d;
_local12 = (((_local6 * _arg2.x) + (_local7 * _arg2.y)) - _local11);
if (_local12 > 0){
if (_local12 > _local10){
_arg1.pointCount = 0;
return;
};
} else {
if (_local12 < -(_local10)){
_arg1.pointCount = 0;
return;
};
_local6 = -(_local6);
_local7 = -(_local7);
_local11 = -(_local11);
};
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L;
};
_local13 = _local5.V;
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
_arg1.pointCount = 1;
_local14 = _arg1.c0;
_local14.sep = (((_local13.x * _local6) + (_local13.y * _local7)) - _local11);
_local14.x = _local13.x;
_local14.y = _local13.y;
_local15 = _local13.userData.n;
_local18 = ((_local15.x * _local6) + (_local15.y * _local7));
if (((_local15.prev.x * _local6) + (_local15.prev.y * _local7)) < _local18){
_local16 = _local15.prev.I;
_local14.id.flip = 0;
_local14.id.incEdge = _local16;
_local14.id.incVert = _local17;
_local14.id.refFace = 0;
_local14.id.bake();
_local13 = _local13.prev;
_local12 = (((_local13.x * _local6) + (_local13.y * _local7)) - _local11);
if (_local12 < 0){
_local14 = _arg1.c1;
_local14.sep = _local12;
_local14.x = _local13.x;
_local14.y = _local13.y;
_local14.id.flip = 0;
_local14.id.incEdge = _local16;
_local14.id.incVert = _local17;
_local14.id.refFace = 0;
_local14.id.bake();
_arg1.pointCount++;
};
} else {
_local16 = _local15.next.I;
_local14.id.flip = 0;
_local14.id.incEdge = _local16;
_local14.id.incVert = _local17;
_local14.id.refFace = 0;
_local14.id.bake();
_local13 = _local13.next;
_local12 = (((_local13.x * _local6) + (_local13.y * _local7)) - _local11);
if (_local12 < 0){
_local14 = _arg1.c1;
_local14.sep = _local12;
_local14.x = _local13.x;
_local14.y = _local13.y;
_local14.id.flip = 0;
_local14.id.incEdge = _local16;
_local14.id.incVert = _local17;
_local14.id.refFace = 0;
_local14.id.bake();
_arg1.pointCount++;
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 19
//CollideBoxPlaneSS (de.polygonal.motor2.collision.pairwise.CollideBoxPlaneSS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideBoxPlaneSS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:V2;
var _local10:Number;
var _local11:ContactPoint;
var _local12:Number;
var _local13:Number;
var _local14:Number;
_local6 = _arg3.worldNormalChain.x;
_local7 = _arg3.worldNormalChain.y;
if (_arg1.pointCount > 0){
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L;
};
_local8 = _arg3.d;
_local9 = _local5.V;
_local10 = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8);
if (_local10 > 0){
_arg1.pointCount = 0;
return;
};
_arg1.pointCount = 1;
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
_local11 = _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++;
};
};
} else {
_local12 = ((_local6 * _arg2.r11) + (_local7 * _arg2.r21));
_local13 = ((_local6 * _arg2.r12) + (_local7 * _arg2.r22));
_local14 = ((_arg2.ex * ((_local12 < 0)) ? -(_local12) : _local12) + (_arg2.ey * ((_local13 < 0)) ? -(_local13) : _local13));
if ((((_local6 * _arg2.x) + (_local7 * _arg2.y)) - _arg3.d) > _local14){
_arg1.pointCount = 0;
return;
};
_local8 = _arg3.d;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L;
};
_local9 = _local5.V;
_local10 = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8);
_arg1.pointCount = 1;
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
_local11 = _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 20
//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 21
//CollideCircleLineDS (de.polygonal.motor2.collision.pairwise.CollideCircleLineDS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideCircleLineDS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ContactPoint;
var _local6:V2;
var _local7:V2;
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;
_local6 = _arg3.worldVertexChain;
_local7 = _local6.next;
_local8 = _arg2.radiusSq;
_local9 = _local6.x;
_local10 = _local7.x;
_local11 = _arg2.x;
_local12 = _local6.y;
_local13 = _local7.y;
_local14 = _arg2.y;
_local15 = (_local10 - _local9);
_local16 = (_local13 - _local12);
_local17 = (_local11 - _local9);
_local18 = (_local14 - _local12);
_local23 = ((_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.I;
_local5.id.incVert = _local6.I;
} 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.I;
_local5.id.incVert = _local7.I;
} 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.I;
_local5.id.incVert = _local7.I;
};
};
_arg1.pointCount = 1;
_arg1.nx = -(_local21);
_arg1.ny = -(_local22);
_local5.id.refFace = ContactID.NULL_FEATURE;
_local5.id.flip = 0;
_local5.id.bake();
_local24 = _arg2.radius;
_local5.x = (_local11 - (_local24 * _local21));
_local5.y = (_local14 - (_local24 * _local22));
_local5.sep = (_local20 - _local24);
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 22
//CollideCircleLineSS (de.polygonal.motor2.collision.pairwise.CollideCircleLineSS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideCircleLineSS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ContactPoint;
var _local6:V2;
var _local7:V2;
var _local8:V2;
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:Number;
_local6 = _arg3.worldNormalChain;
if ((((_arg2.x * _local6.x) + (_arg2.y * _local6.y)) - _arg3.d) < 0){
_arg4.disabled = true;
_arg1.pointCount = 0;
return;
};
_local7 = _arg3.worldVertexChain;
_local8 = _local7.next;
_local9 = _arg2.radiusSq;
_local10 = _local7.x;
_local11 = _local8.x;
_local12 = _arg2.x;
_local13 = _local7.y;
_local14 = _local8.y;
_local15 = _arg2.y;
_local16 = (_local11 - _local10);
_local17 = (_local14 - _local13);
_local18 = (_local12 - _local10);
_local19 = (_local15 - _local13);
_local24 = ((_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.I;
_local5.id.incVert = _local7.I;
} 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.I;
_local5.id.incVert = _local8.I;
} 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.I;
_local5.id.incVert = _local8.I;
};
};
_arg1.pointCount = 1;
_arg1.nx = -(_local22);
_arg1.ny = -(_local23);
_local5.id.refFace = ContactID.NULL_FEATURE;
_local5.id.flip = 0;
_local5.id.bake();
_local25 = _arg2.radius;
_local5.x = (_local12 - (_local25 * _local22));
_local5.y = (_local15 - (_local25 * _local23));
_local5.sep = (_local21 - _local25);
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 23
//CollideCirclePlaneDS (de.polygonal.motor2.collision.pairwise.CollideCirclePlaneDS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideCirclePlaneDS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ContactPoint;
var _local6:V2;
var _local7:Number;
var _local8:Number;
_local6 = _arg3.worldNormalChain;
_local7 = _arg2.radius;
_local8 = (((_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 24
//CollideCirclePlaneSS (de.polygonal.motor2.collision.pairwise.CollideCirclePlaneSS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollideCirclePlaneSS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:V2;
var _local6:Number;
var _local7:Number;
var _local8:ContactPoint;
_local5 = _arg3.worldNormalChain;
_local6 = _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 25
//CollidePoly (de.polygonal.motor2.collision.pairwise.CollidePoly)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollidePoly implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:PolyContact;
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local13:Number;
var _local14:int;
var _local15:ConvexBSPNode;
var _local16:ShapeSkeleton;
var _local17:Number;
var _local18:Number;
var _local19:int;
var _local20:int;
var _local21:int;
var _local22:V2;
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;
var _local32:Number;
var _local33:Number;
var _local34:ContactPoint;
var _local35:V2;
_local5 = PolyContact(_arg4);
_local12 = -2147483648;
_local6 = _local5.p;
_local7 = _local5.d;
if (_local5.firstOut){
while (true) {
_local15 = _arg3.BSPNode;
while (_local15.R) {
_local15 = ((((-(_local15.N.y) * _local7.x) + (_local15.N.x * _local7.y)))<=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.last){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
_local6 = _arg3.worldVertexChain;
_local7 = _arg3.worldNormalChain;
while (true) {
_local15 = _arg2.BSPNode;
while (_local15.R) {
_local15 = ((((-(_local15.N.y) * _local7.x) + (_local15.N.x * _local7.y)))<=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.last){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
} else {
while (true) {
_local15 = _arg2.BSPNode;
while (_local15.R) {
_local15 = ((((-(_local15.N.y) * _local7.x) + (_local15.N.x * _local7.y)))<=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.last){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
_local6 = _arg2.worldVertexChain;
_local7 = _arg2.worldNormalChain;
while (true) {
_local15 = _arg3.BSPNode;
while (_local15.R) {
_local15 = ((((-(_local15.N.y) * _local7.x) + (_local15.N.x * _local7.y)))<=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.last){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
};
_local16 = (_local14) ? _arg3 : _arg2;
_local17 = _local9.x;
_local18 = _local9.y;
_local19 = _local11.I;
_local20 = _local10.I;
_local22 = _local10.userData.n;
_local23 = ((_local22.x * _local17) + (_local22.y * _local18));
if (((_local22.prev.x * _local17) + (_local22.prev.y * _local18)) < _local23){
_local10 = _local10.prev;
_local21 = _local22.prev.I;
} else {
if (((_local22.next.x * _local17) + (_local22.next.y * _local18)) < _local23){
_local10 = _local10.next;
_local21 = _local22.next.I;
};
};
_local24 = (((_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.I];
_local25 = ((((_local16.y + (_local16.r21 * _local35.x)) + (_local16.r22 * _local35.y)) * _local17) - (((_local16.x + (_local16.r11 * _local35.x)) + (_local16.r12 * _local35.y)) * _local18));
};
_local26 = (_local11.userData.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 26
//CollidePolyCircle (de.polygonal.motor2.collision.pairwise.CollidePolyCircle)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
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 _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:ConvexCircleContact;
var _local15:int;
var _local16:E2;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:ContactPoint;
var _local23:Number;
var _local24:Number;
var _local25:Number;
_local9 = _arg3.x;
_local10 = _arg3.y;
_local12 = _arg3.radius;
_local13 = -2147483648;
_local14 = ConvexCircleContact(_arg4);
_local5 = _local14.p;
_local6 = _local14.d;
_local15 = _local5.prev.I;
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.I == _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.I + 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;
};
_local16 = _local8.userData;
_local18 = ((_arg2.r11 * _local16.d.x) + (_arg2.r12 * _local16.d.y));
_local20 = ((_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;
};
_local23 = (((_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.I + 1);
_local22.id.incEdge = 254;
} else {
if (_local23 >= _local16.mag){
_local24 = _local8.next.x;
_local25 = _local8.next.y;
_local22.id.incVert = (_local8.next.I + 1);
_local22.id.incEdge = 254;
} else {
_local24 = ((_local18 * _local23) + _local8.x);
_local25 = ((_local20 * _local23) + _local8.y);
_local22.id.incVert = 254;
_local22.id.incEdge = (_local8.I + 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 27
//CollidePolyLineDS (de.polygonal.motor2.collision.pairwise.CollidePolyLineDS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollidePolyLineDS 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 _local14:Number;
var _local15:int;
var _local16:V2;
var _local17:V2;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:ShapeSkeleton;
var _local23:ShapeSkeleton;
var _local24:Number;
var _local25:Number;
var _local26:int;
var _local27:int;
var _local28:int;
var _local29:V2;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:ContactPoint;
var _local42:V2;
_local14 = -2147483648;
_local15 = 0;
_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;
};
_local16 = _arg3.worldVertexChain;
_local17 = _local16.next;
_local18 = _local16.x;
_local19 = _local17.x;
_local20 = _local16.y;
_local21 = _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.last){
break;
};
_local10 = _local10.next;
_local9 = _local9.next;
};
if (_local15){
_local22 = _arg3;
_local23 = _arg2;
} else {
_local22 = _arg2;
_local23 = _arg3;
};
_local24 = _local8.x;
_local25 = _local8.y;
_local26 = _local11.I;
_local27 = _local12.I;
_local29 = _local12.userData.n;
_local30 = ((_local29.x * _local24) + (_local29.y * _local25));
if (((_local29.prev.x * _local24) + (_local29.prev.y * _local25)) < _local30){
_local12 = _local12.prev;
_local28 = _local29.prev.I;
} else {
if (((_local29.next.x * _local24) + (_local29.next.y * _local25)) < _local30){
_local12 = _local12.next;
_local28 = _local29.next.I;
};
};
_local31 = (((_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.I];
_local32 = ((((_local22.y + (_local22.r21 * _local42.x)) + (_local22.r22 * _local42.y)) * _local24) - (((_local22.x + (_local22.r11 * _local42.x)) + (_local22.r12 * _local42.y)) * _local25));
};
_local33 = (_local11.userData.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 28
//CollidePolyLineSS (de.polygonal.motor2.collision.pairwise.CollidePolyLineSS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollidePolyLineSS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:V2;
var _local6:ConvexBSPNode;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local13:Number;
var _local14:int;
var _local15:V2;
var _local16:V2;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:ShapeSkeleton;
var _local22:ShapeSkeleton;
var _local23:Number;
var _local24:Number;
var _local25:int;
var _local26:int;
var _local27:int;
var _local28:V2;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:ContactPoint;
var _local41:V2;
_local5 = _arg3.worldNormalChain;
if ((((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d) < 0){
_arg4.disabled = true;
_arg1.pointCount = 0;
return;
};
_local13 = -2147483648;
_local14 = 0;
_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;
};
_local15 = _arg3.worldVertexChain;
_local16 = _local15.next;
_local17 = _local15.x;
_local18 = _local16.x;
_local19 = _local15.y;
_local20 = _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.last){
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;
};
_local23 = _local5.x;
_local24 = _local5.y;
_local25 = _local10.I;
_local26 = _local11.I;
_local28 = _local11.userData.n;
_local29 = ((_local28.x * _local23) + (_local28.y * _local24));
if (((_local28.prev.x * _local23) + (_local28.prev.y * _local24)) < _local29){
_local11 = _local11.prev;
_local27 = _local28.prev.I;
} else {
if (((_local28.next.x * _local23) + (_local28.next.y * _local24)) < _local29){
_local11 = _local11.next;
_local27 = _local28.next.I;
};
};
_local30 = (((_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.I];
_local31 = ((((_local21.y + (_local21.r21 * _local41.x)) + (_local21.r22 * _local41.y)) * _local23) - (((_local21.x + (_local21.r11 * _local41.x)) + (_local21.r12 * _local41.y)) * _local24));
};
_local32 = (_local10.userData.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 29
//CollidePolyPlaneDS (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneDS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollidePolyPlaneDS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:V2;
var _local10:int;
var _local11:ContactPoint;
var _local12:Number;
_local6 = _arg3.worldNormalChain.x;
_local7 = _arg3.worldNormalChain.y;
_local8 = _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 30
//CollidePolyPlaneSS (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneSS)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CollidePolyPlaneSS implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:V2;
var _local10:Number;
var _local11:ContactPoint;
_local6 = _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;
};
_local9 = _local5.V;
_local10 = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8);
if (_local10 > 0){
_arg1.pointCount = 0;
return;
};
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
_arg1.pointCount = 1;
_local11 = _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 31
//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 32
//BoxData (de.polygonal.motor2.collision.shapes.data.BoxData)
package de.polygonal.motor2.collision.shapes.data {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
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);
}
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 get area():Number{
return ((_w * _h));
}
public function set height(_arg1:Number):void{
_h = _arg1;
invalidate();
}
override public function getShapeClass():Class{
return (BoxShape);
}
public function get height():Number{
return (_h);
}
override protected function setType():void{
type = ShapeTypes.BOX;
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 33
//LineData (de.polygonal.motor2.collision.shapes.data.LineData)
package de.polygonal.motor2.collision.shapes.data {
import de.polygonal.motor2.math.*;
import flash.geom.*;
import de.polygonal.motor2.collision.shapes.*;
public class LineData extends ShapeData {
public const b:Point;
public const a:Point;
public var infinite:Boolean;
public var doubleSided:Boolean;
public function LineData(_arg1:Point, _arg2:Point, _arg3:Boolean=false, _arg4:Boolean=true){
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
a = new Point();
b = new Point();
super(0);
_local5 = (_arg2.x - _arg1.x);
_local6 = (_arg2.y - _arg1.y);
if (Math.sqrt((((_local5 * _local5) + _local6) + _local6)) <= 1E-6){
throw (new Error("overlapping vertices detected"));
};
_local7 = (_arg1.x + ((_arg2.x - _arg1.x) * 0.5));
_local8 = (_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 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;
}
override public function getShapeClass():Class{
return (LineShape);
}
override public function get density():Number{
return (0);
}
override protected function setType():void{
type = ShapeTypes.LINE;
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 34
//PolyData (de.polygonal.motor2.collision.shapes.data.PolyData)
package de.polygonal.motor2.collision.shapes.data {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
public class PolyData extends ShapeData {
private var _vertexCount:int;
private var _radius:Number;
private var _regular:Boolean;
private var _vertices:Array;
private var _area:Number;
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 _local11:Number;
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(parseFloat(_arg1[0]), parseFloat(_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(parseFloat(_arg1[_local3]), parseFloat(_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;
_local11 = 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);
_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 public function get area():Number{
return (_area);
}
public function getVertexCount():int{
return (_vertexCount);
}
public function isRegular():Boolean{
return (_regular);
}
public function get radius():Number{
return (_radius);
}
override protected function setType():void{
type = ShapeTypes.POLY;
}
override protected function computeMass():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
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:int;
_local1 = 0;
_local2 = 0;
_local3 = 0;
_local4 = 0;
_local5 = 0;
_local8 = 0;
_local19 = (1 / 3);
_local21 = 0;
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 getShapeClass():Class{
return (PolyShape);
}
public function getVertices():Array{
var _local1:int;
var _local2:Array;
_local2 = new Array(_vertexCount);
_local1 = 0;
while (_local1 < _vertexCount) {
_local2[_local1] = new V2(_vertices[_local1].x, _vertices[_local1].y);
_local1++;
};
return (_local2);
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 35
//ShapeData (de.polygonal.motor2.collision.shapes.data.ShapeData)
package de.polygonal.motor2.collision.shapes.data {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
public class ShapeData {
public var next:ShapeData;
private var _restitution:Number;
public var type:int;
protected var _I:Number;
public var maskBits:int;
public var groupIndex:int;
private var _friction:Number;
protected var _mass:Number;
public var categoryBits:int;
public var mr:Number;
protected var _density:Number;
public var mx:Number;
public var my:Number;
protected var _cm:V2;
public function ShapeData(_arg1:Number){
this.density = _arg1;
init();
}
public function getCM():V2{
if (_cm == null){
computeMass();
};
return (_cm);
}
public function getInertia():Number{
if (_density == 0){
return (0);
};
if (isNaN(_I)){
computeMass();
};
return (_I);
}
public function get area():Number{
return (NaN);
}
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;
}
private function init():void{
setType();
mx = (my = (mr = 0));
friction = 0.2;
restitution = 0;
categoryBits = 1;
maskBits = 0xFFFF;
groupIndex = 0;
}
public function getShapeClass():Class{
return (null);
}
public function invalidate():void{
_mass = Number.NaN;
_I = Number.NaN;
_cm = null;
}
protected function computeMass():void{
}
public function get density():Number{
return (_density);
}
public function get restitution():Number{
return (_restitution);
}
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);
}
protected function setType():void{
type = ShapeTypes.UNKNOWN;
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 36
//BoxShape (de.polygonal.motor2.collision.shapes.BoxShape)
package de.polygonal.motor2.collision.shapes {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.math.*;
import flash.geom.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.ds.*;
public class BoxShape extends ShapeSkeleton {
private var _v0:V2;
private var _v2:V2;
private var _v3:V2;
private var _v1:V2;
private var _n1:V2;
private var _n2:V2;
private var _n0:V2;
private var _n3:V2;
private var _r11:Number;
private var _r12:Number;
private var _mr:Number;
private var _r22:Number;
private var _r21:Number;
public function BoxShape(_arg1:BoxData, _arg2:RigidBody){
super(_arg1, _arg2);
setup(_arg1, _arg2);
}
override public function getShapeOffset(_arg1:Point):void{
_arg1.x = ((mx * _r11) + (my * _r12));
_arg1.y = ((mx * _r21) + (my * _r22));
}
override public function toWorldSpace():void{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
if (synced){
return;
};
synced = true;
_local1 = (r11 * ex);
_local2 = (r12 * ey);
_local3 = (r21 * ex);
_local4 = (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;
}
private function setup(_arg1:BoxData, _arg2:RigidBody):void{
var xLocalCenter:Number;
var sin:Number;
var yLocalCenter:Number;
var cos:Number;
var modelVertexList:Array;
var v:V2;
var sd = _arg1;
var rb = _arg2;
xLocalCenter = rb.cx;
yLocalCenter = rb.cy;
mx = (sd.mx - xLocalCenter);
my = (sd.my - yLocalCenter);
sin = Math.sin(sd.mr);
cos = Math.cos(sd.mr);
_r11 = cos;
_r12 = -(sin);
_r21 = sin;
_r22 = cos;
_mr = sd.mr;
ex = (sd.width * 0.5);
ey = (sd.height * 0.5);
xmin = -(ex);
xmax = ex;
xmin = -(ey);
ymax = ey;
radiusSq = ((ex * ex) + (ey * ey));
radius = Math.sqrt(radiusSq);
vertexCount = 4;
modelVertexList = new Array(vertexCount);
v = (modelVertexList[0] = new V2());
v.x = ((mx + (_r11 * ex)) + (_r12 * ey));
v.y = ((my + (_r21 * ex)) + (_r22 * ey));
v = (modelVertexList[1] = new V2());
v.x = ((mx + (_r11 * -(ex))) + (_r12 * ey));
v.y = ((my + (_r21 * -(ex))) + (_r22 * ey));
v = (modelVertexList[2] = new V2());
v.x = ((mx + (_r11 * -(ex))) + (_r12 * -(ey)));
v.y = ((my + (_r21 * -(ex))) + (_r22 * -(ey)));
v = (modelVertexList[3] = new V2());
v.x = ((mx + (_r11 * ex)) + (_r12 * -(ey)));
v.y = ((my + (_r21 * ex)) + (_r22 * -(ey)));
initPoly(modelVertexList, vertexCount, true, mx, my);
v = worldVertexChain;
_v0 = v;
v = v.next;
_v1 = v;
v = v.next;
_v2 = v;
v = v.next;
_v3 = v;
v = worldNormalChain;
_n0 = v;
v = v.next;
_n1 = v;
v = v.next;
_n2 = v;
v = v.next;
_n3 = v;
BSPNode = ConvexBSP.createBSP(vertexCount, modelNormalChain.toArray(), _edges);
BinaryTreeNode.inorder(BSPNode, function (_arg1:ConvexBSPNode):void{
_arg1.N = worldNormalChain.getAt(_arg1.I);
_arg1.V = worldVertexChain.getAt(_arg1.I);
});
createProxy(sd.groupIndex, sd.categoryBits, sd.maskBits);
}
override public function triangulate():void{
triangleList = new Tri2(_v0, _v1, _v3);
triangleList.next = new Tri2(_v3, _v1, _v2);
}
override public function closestPoint(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
if (_arg2){
_local3 = (x - (_arg2.x = x));
_local4 = (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 = (x - (_arg1.x = x));
_local4 = (y - (_arg1.y = y));
_local5 = ((_local3 * r11) + (_local4 * r21));
if (_local5 > ex){
_local5 = ex;
} else {
if (_local5 < -(ex)){
_local5 = -(ex);
};
};
x = (x + (r11 * _local5));
y = (y + (r21 * _local5));
_local5 = ((_local3 * r12) + (_local4 * r22));
if (_local5 > ey){
_local5 = ey;
} else {
if (_local5 < -(ey)){
_local5 = -(ey);
};
};
x = (x + (r12 * _local5));
y = (y + (r22 * _local5));
};
}
override protected function setType():void{
type = ShapeTypes.BOX;
}
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 update():void{
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)));
};
super.update();
}
}
}//package de.polygonal.motor2.collision.shapes
Section 37
//LineShape (de.polygonal.motor2.collision.shapes.LineShape)
package de.polygonal.motor2.collision.shapes {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.data.*;
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);
}
override public function update():void{
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 - ex);
ymin = (y - ey);
xmax = (x + ex);
ymax = (y + ey);
super.update();
}
override protected function setType():void{
type = ShapeTypes.LINE;
}
override public function toWorldSpace():void{
var _local1:V2;
var _local2:V2;
var _local3:V2;
var _local4:V2;
var _local5:Number;
var _local6:Number;
_local1 = worldVertexChain;
_local2 = modelVertexChain;
_local3 = worldNormalChain;
_local4 = modelNormalChain;
_local5 = body.x;
_local6 = 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));
}
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;
var _local9:Number;
var _local10:AABB2;
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);
_local9 = 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){
_local10 = body.world.worldAABB;
xmin = _local10.xmin;
ymin = _local10.ymin;
xmax = _local10.xmax;
ymax = _local10.ymax;
} else {
if ((((Math.abs(_local4) < 0.001)) || ((Math.abs(_local6) < 0.001)))){
xmin = (x - radius);
ymin = (y - radius);
xmax = (x + radius);
ymax = (y + radius);
} else {
_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);
};
};
ex = ((xmax - xmin) / 2);
ey = ((ymax - ymin) / 2);
createProxy(_arg1.groupIndex, _arg1.categoryBits, _arg1.maskBits);
update();
_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));
}
}
}//package de.polygonal.motor2.collision.shapes
Section 38
//PolyShape (de.polygonal.motor2.collision.shapes.PolyShape)
package de.polygonal.motor2.collision.shapes {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.math.*;
import flash.geom.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.ds.*;
public class PolyShape extends ShapeSkeleton {
private var _y:Number;
private var _r11:Number;
private var _r12:Number;
private var _triCenter:V2;
private var _r22:Number;
private var _r21:Number;
private var _x:Number;
public function PolyShape(_arg1:PolyData, _arg2:RigidBody){
super(_arg1, _arg2);
setup(_arg1, _arg2);
}
override public function toWorldSpace():void{
var _local1:V2;
var _local2:V2;
var _local3:V2;
var _local4:V2;
var _local5:Number;
var _local6:Number;
_local1 = worldVertexChain;
_local2 = modelVertexChain;
_local3 = worldNormalChain;
_local4 = modelNormalChain;
_local5 = body.x;
_local6 = 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.last){
break;
};
_local1 = _local1.next;
_local2 = _local2.next;
_local3 = _local3.next;
_local4 = _local4.next;
};
}
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 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);
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;
BSPNode = ConvexBSP.createBSP(vertexCount, modelNormalChain.toArray(), _edges);
BinaryTreeNode.inorder(BSPNode, function (_arg1:ConvexBSPNode):void{
_arg1.N = worldNormalChain.getAt(_arg1.I);
_arg1.V = worldVertexChain.getAt(_arg1.I);
});
createProxy(sd.groupIndex, sd.categoryBits, sd.maskBits);
}
public function getWorldOBB():V2{
var _local1:Number;
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:V2;
var _local6:V2;
var _local7:V2;
var _local8:V2;
_local1 = (_r11 * ex);
_local2 = (_r21 * ex);
_local3 = (_r12 * ey);
_local4 = (_r22 * ey);
_local5 = new V2((((_x + mx) + _local1) - _local3), (((_y + my) + _local2) - _local4));
_local6 = new V2((((_x + mx) - _local1) - _local3), (((_y + my) - _local2) - _local4));
_local7 = new V2((((_x + mx) - _local1) + _local3), (((_y + my) - _local2) + _local4));
_local8 = new V2((((_x + mx) + _local1) + _local3), (((_y + my) + _local2) + _local4));
_local5.next = _local6;
_local6.next = _local7;
_local7.next = _local8;
return (_local5);
}
override public function triangulate():void{
var _local1:V2;
var _local2:Tri2;
_triCenter = new V2(x, y);
_local1 = worldVertexChain;
while (true) {
_local2 = new Tri2(_local1, _local1.next, _triCenter);
_local2.next = triangleList;
triangleList = _local2;
if (_local1.last){
break;
};
_local1 = _local1.next;
};
}
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 _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:V2;
var _local17:V2;
_local13 = -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.last){
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;
}
override public function pointInside(_arg1:Point):Boolean{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:V2;
var _local7:V2;
_local2 = _arg1.x;
_local3 = _arg1.y;
_local4 = ((r11 * (_local2 - this.x)) + (r21 * (_local3 - this.y)));
_local5 = ((r12 * (_local2 - this.x)) + (r22 * (_local3 - this.y)));
_local6 = modelVertexChain;
_local7 = modelNormalChain;
while (_local6) {
if ((((_local4 - _local6.x) * _local7.x) + ((_local5 - _local6.y) * _local7.y)) > 0){
return (false);
};
if (_local6.last){
break;
};
_local7 = _local7.next;
_local6 = _local6.next;
};
return (true);
}
override public function update():void{
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;
};
super.update();
}
}
}//package de.polygonal.motor2.collision.shapes
Section 39
//ShapeSkeleton (de.polygonal.motor2.collision.shapes.ShapeSkeleton)
package de.polygonal.motor2.collision.shapes {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.math.*;
import flash.geom.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.collision.nbody.*;
public class ShapeSkeleton {
public var y:Number;
public var synced:Boolean;// = false
public var worldVertexChain:V2;
public var area:Number;
public var radiusSq:Number;
public var radius:Number;
public var r12:Number;
public var modelVertexChain:V2;
public var r11:Number;
public var body:RigidBody;
public var proxyId:int;
public var mx:Number;
public var my:Number;
public var worldNormalChain:V2;
public var r21:Number;
public var r22:Number;
public var ex:Number;
public var ey:Number;
public var modelNormalChain:V2;
public var ymin:Number;
public var type:int;
protected var _broadPhase:IBroadPhase;
public var offsets:Array;
public var BSPNode:ConvexBSPNode;
public var triangleList:Tri2;
public var ymax:Number;
protected var _edges:Array;
public var xmin:Number;
public var vertexCount:int;
public var regularShape:Boolean;
public var restitution:Number;
public var d:Number;
public var xmax:Number;
public var next:ShapeSkeleton;
public var x:Number;
public var friction:Number;
public function ShapeSkeleton(_arg1:ShapeData, _arg2:RigidBody){
synced = false;
super();
friction = _arg1.friction;
restitution = _arg1.restitution;
area = _arg1.area;
body = _arg2;
setType();
_broadPhase = body.world.getBroadPhase();
proxyId = ShapeProxy.NULL_PROXY;
}
public function triangulate():void{
}
public function closestPoint(_arg1:Point, _arg2:Point=null):void{
}
protected function setType():void{
type = ShapeTypes.UNKNOWN;
}
public function update():void{
if (proxyId == ShapeProxy.NULL_PROXY){
return;
};
if (_broadPhase.insideBounds(xmin, ymin, xmax, ymax)){
_broadPhase.moveProxy(proxyId);
} else {
_broadPhase.removeProxy(proxyId);
proxyId = ShapeProxy.NULL_PROXY;
body.freeze();
};
}
protected function computeMinAreaRect(_arg1:V2, _arg2:V2):Number{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
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;
_local3 = 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.last){
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 pointInside(_arg1:Point):Boolean{
return (false);
}
protected function createProxy(_arg1:int, _arg2:int, _arg3:int):void{
update();
if (_broadPhase.insideBounds(xmin, ymin, xmax, ymax)){
proxyId = _broadPhase.createProxy(_arg1, _arg2, _arg3, this);
} else {
proxyId = ShapeProxy.NULL_PROXY;
body.freeze();
};
}
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)));
_edges = (offsets = null);
triangleList = null;
if (proxyId != ShapeProxy.NULL_PROXY){
_broadPhase.removeProxy(proxyId);
};
_broadPhase = null;
}
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 _local20:Number;
var _local21:Number;
var _local22:Number;
regularShape = _arg3;
_local15 = _arg1[0];
modelVertexChain = _local15;
_local16 = new V2();
worldVertexChain = _local16;
_local15.I = 0;
_local16.I = 0;
_local17 = new V2();
modelNormalChain = _local17;
_local18 = new V2();
worldNormalChain = _local18;
_local17.I = 0;
_local18.I = 0;
_local6 = 1;
while (_local6 < _arg2) {
_local12 = _arg1[_local6];
_local13 = _local15;
_local14 = _local12;
_local14.I = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local15 = _local15.next;
_local13 = _local16;
_local14 = new V2();
_local14.I = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local16 = _local16.next;
_local13 = _local17;
_local14 = new V2();
_local14.I = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local17 = _local17.next;
_local13 = _local18;
_local14 = new V2();
_local14.I = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local18 = _local18.next;
_local6++;
};
_local15.last = true;
_local15.next = modelVertexChain;
modelVertexChain.prev = _local15;
_local16.last = true;
_local16.next = worldVertexChain;
worldVertexChain.prev = _local16;
_local17.last = true;
_local17.next = modelNormalChain;
modelNormalChain.prev = _local17;
_local18.last = true;
_local18.next = worldNormalChain;
worldNormalChain.prev = _local18;
_edges = [];
offsets = [];
_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);
_edges[_local6] = new V2(_local7, _local8);
_local9 = _local8;
_local10 = -(_local7);
_local17.x = _local9;
_local17.y = _local10;
_local17 = _local17.next;
_local20 = ((body.cx + _local13.x) + ((_local14.x - _local13.x) * 0.5));
_local21 = ((body.cy + _local13.y) + ((_local14.y - _local13.y) * 0.5));
_local22 = (((_local20 - _arg4) * _local9) + ((_local21 - _arg5) * _local10));
if (!_arg3){
offsets[_local6] = new V2((_local20 + (-(_local9) * _local22)), (_local21 + (-(_local10) * _local22)));
};
_local19 = new E2();
_local19.v = _local13;
_local19.w = _local13.next;
_local19.n = _local17;
_local19.d = _edges[_local6];
_local19.mag = _local11;
_local13.userData = _local19;
_local13 = _local14;
_local14 = _local13.next;
_local19 = new E2();
_local19.v = _local16;
_local19.w = _local16.next;
_local19.n = _local18;
_local19.d = _edges[_local6];
_local19.mag = _local11;
_local16.userData = _local19;
_local16 = _local16.next;
_local18 = _local18.next;
_local6++;
};
}
}
}//package de.polygonal.motor2.collision.shapes
Section 40
//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 41
//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 {
public function BoxCircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
return (new CollideBoxCircle());
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 42
//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;
public function BoxContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
return (new CollideBox());
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 43
//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
public function BoxLineContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
sid = -1;
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
var _local1:LineShape;
_local1 = LineShape(shape2);
if (_local1.infinite){
if (_local1.doubleSided){
return (new CollideBoxPlaneDS());
};
return (new CollideBoxPlaneSS());
};
if (_local1.doubleSided){
return (new CollideBoxLineDS());
};
return (new CollideBoxLineSS());
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 44
//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.collision.pairwise.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CircleContact extends Contact {
public var manifold:Manifold;
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 (new CollideCircle());
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 45
//CircleLineContact (de.polygonal.motor2.dynamics.contact.generator.CircleLineContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
import de.polygonal.motor2.dynamics.contact.*;
public class CircleLineContact extends Contact {
private var _Pn0:Number;
private var _Pt0:Number;
private var _m1Cp1:ContactPoint;
public var manifold:Manifold;
private var _id0:uint;
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 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;
};
}
override protected function getCollider():Collider{
var _local1:LineShape;
_local1 = LineShape(shape2);
if (_local1.infinite){
if (_local1.doubleSided){
return (new CollideCirclePlaneDS());
};
return (new CollideCirclePlaneSS());
};
if (_local1.doubleSided){
return (new CollideCircleLineDS());
};
return (new CollideCircleLineSS());
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 46
//ConvexCircleContact (de.polygonal.motor2.dynamics.contact.generator.ConvexCircleContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class ConvexCircleContact extends Contact {
private var _Pn0:Number;
private var _id0:uint;
private var _Pt0:Number;
public var manifold:Manifold;
private var _m1Cp1:ContactPoint;
public var d:V2;
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 47
//ConvexContact (de.polygonal.motor2.dynamics.contact.generator.ConvexContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public class ConvexContact extends Contact {
private var _Pn0_1:Number;
private var _Pn0_2:Number;
private var _Pt0_1:Number;
private var _Pt0_2:Number;
public var manifold:Manifold;
private var _m1Cp1:ContactPoint;
private var _id0_1:uint;
private var _id0_2:uint;
private var _m1Cp2:ContactPoint;
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 48
//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 {
public function PolyCircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
return (new CollidePolyCircle());
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 49
//PolyContact (de.polygonal.motor2.dynamics.contact.generator.PolyContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class PolyContact extends ConvexContact {
public var firstOut:Boolean;
public var p:V2;
public var d:V2;
public function PolyContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
firstOut = true;
p = _arg1.worldVertexChain;
d = _arg1.worldNormalChain;
}
override protected function getCollider():Collider{
return (new CollidePoly());
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 50
//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.collision.pairwise.*;
public class PolyLineContact extends ConvexContact {
public function PolyLineContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
var _local1:LineShape;
_local1 = LineShape(shape2);
if (_local1.infinite){
if (_local1.doubleSided){
return (new CollidePolyPlaneDS());
};
return (new CollidePolyPlaneSS());
};
if (_local1.doubleSided){
return (new CollidePolyLineDS());
};
return (new CollidePolyLineSS());
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 51
//IContactSolver (de.polygonal.motor2.dynamics.contact.solver.IContactSolver)
package de.polygonal.motor2.dynamics.contact.solver {
public interface IContactSolver {
}
}//package de.polygonal.motor2.dynamics.contact.solver
Section 52
//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 implements IContactSolver {
private var _maxLinCorrection:Number;
private var _linSlop:Number;
private var _velThreshold:Number;
public var contacts:Array;
public var contactCount:int;
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 _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
_local11 = 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 postSolve():void{
}
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++;
};
}
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.vx * _local12))) + (_local10 * (((_local5.vy + (_local5.w * _local9)) - _local4.vy) - (_local4.vy * _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 setContacts(_arg1:Array, _arg2:int):void{
this.contacts = _arg1;
this.contactCount = _arg2;
}
public function preSolve():void{
}
public function solve():void{
}
}
}//package de.polygonal.motor2.dynamics.contact.solver
Section 53
//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 friction:Number;
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 next:Contact;
public var secondary:Boolean;
public var disabled:Boolean;
public static const k_bitDestroy:int = 1;
public static const k_bitIsland:int = 32;
public function Contact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
init(_arg1, _arg2);
}
public function evaluate():void{
}
protected function init(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):void{
shape1 = _arg1;
shape2 = _arg2;
manifoldCount = 0;
manifolds = [];
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 54
//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 _local3:ContactRegister;
var _local4:Class;
var _local5:Contact;
var _local6:int;
var _local7:Manifold;
_local3 = _contactMatrix.get(_arg1.type, _arg2.type);
_local4 = _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 55
//ContactID (de.polygonal.motor2.dynamics.contact.ContactID)
package de.polygonal.motor2.dynamics.contact {
public class ContactID {
public var flip:int;
public var refFace:int;
public var incVert: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 56
//ContactManager (de.polygonal.motor2.dynamics.contact.ContactManager)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.nbody.*;
public class ContactManager implements IPairCallback {
private var _contactFactory:ContactFactory;
private var _world:World;
public var statsContactCount:int;
public var destroyImmediate:Boolean;
private static const NULL_CONTACT:NullContact = new NullContact();
public function ContactManager(_arg1:World){
this._world = _arg1;
_contactFactory = new ContactFactory();
}
public function cleanContactList():void{
var _local1:Contact;
var _local2:Contact;
_local1 = _world.contactList;
while (_local1) {
_local2 = _local1;
_local1 = _local1.next;
if ((_local2.stateBits & Contact.k_bitDestroy)){
destroyContact(_local2);
};
_local2 = null;
};
}
public function collide():void{
var _local1:Contact;
var _local2:RigidBody;
var _local3:RigidBody;
var _local4:int;
var _local5:int;
var _local6:ContactNode;
_local1 = _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 pairRemoved(_arg1, _arg2, _arg3):void{
var _local4:Contact;
statsContactCount--;
if (_arg3 == null){
return;
};
_local4 = (_arg3 as Contact);
if (_local4 != NULL_CONTACT){
if (destroyImmediate == true){
destroyContact(_local4);
_local4 = null;
} else {
_local4.stateBits = (_local4.stateBits | Contact.k_bitDestroy);
};
};
}
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;
};
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, _arg2):Contact{
var _local3:ShapeSkeleton;
var _local4:ShapeSkeleton;
var _local5:RigidBody;
var _local6:RigidBody;
var _local7:Contact;
var _local8:ShapeSkeleton;
var _local9:RigidBody;
statsContactCount++;
_local3 = (_arg1 as ShapeSkeleton);
_local4 = (_arg2 as ShapeSkeleton);
_local5 = _local3.body;
_local6 = _local4.body;
if (_local5 == _local6){
return (NULL_CONTACT);
};
if (((_local5.stateBits & _local6.stateBits) & RigidBody.k_bitStatic)){
return (NULL_CONTACT);
};
if (_local6.invMass == 0){
_local8 = _local3;
_local3 = _local4;
_local4 = _local8;
_local9 = _local5;
_local5 = _local6;
_local6 = _local9;
};
if (_local6.isConnected(_local5)){
return (NULL_CONTACT);
};
_local7 = _contactFactory.create(_local3, _local4);
if (_local7 == null){
return (NULL_CONTACT);
};
_local7.prev = null;
_local7.next = _world.contactList;
if (_world.contactList){
_world.contactList.prev = _local7;
};
_world.contactList = _local7;
_world.contactCount++;
return (_local7);
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 57
//ContactNode (de.polygonal.motor2.dynamics.contact.ContactNode)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.dynamics.*;
public class ContactNode {
public var next:ContactNode;
public var other:RigidBody;
public var contact:Contact;
public var prev:ContactNode;
public function ContactNode(){
init();
}
private function init():void{
prev = (next = null);
other = null;
contact = null;
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 58
//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 tMass:Number;
public var w_r1x:Number;
public var w_r1y: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{
matched = false;
super();
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 59
//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 = [c0, c1];
pointCount = 0;
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 60
//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 61
//Buoyancy (de.polygonal.motor2.dynamics.forces.Buoyancy)
package de.polygonal.motor2.dynamics.forces {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
public class Buoyancy extends ForceGenerator {
public var planeOffset:Number;
public var velocity:V2;
public var planeNormal:V2;
private var _cp0:V2;
public var linDrag:Number;
public var density:Number;
private var _cp1:V2;
public var angDrag:Number;
private var _clipTri0:ClipTriangle;
private var _clipTri1:ClipTriangle;
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();
}
override public function evaluate(_arg1:RigidBody):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:int;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local13:ShapeSkeleton;
var _local14:Tri2;
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;
_local2 = 0;
_local3 = 0;
_local4 = 2147483648;
_local5 = -2147483648;
_local6 = 0;
_local7 = 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;
};
_local15 = ((density * _local3) * _arg1.world.gravity.y);
_local16 = ((_arg1.mass * _local3) / _local2);
_local17 = (_local6 - _arg1.x);
_local18 = (_local7 - _arg1.y);
_local19 = ((planeNormal.x * _local15) + ((_local16 * linDrag) * (velocity.x - (_arg1.vx - (_arg1.w * _local18)))));
_local20 = ((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)));
}
private function clipTriangle(_arg1:Tri2, _arg2:Number, _arg3:ClipTriangle, _arg4:ClipTriangle):int{
var _local5:int;
var _local6:int;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:V2;
var _local13:V2;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
_local5 = 0;
_local6 = 0;
_local7 = null;
_local8 = null;
_local9 = null;
_local10 = null;
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);
}
}
}//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();
d = 0;
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 62
//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 init():void{
isActive = true;
}
public function evaluate(_arg1:RigidBody):void{
}
}
}//package de.polygonal.motor2.dynamics.forces
Section 63
//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 remove(_arg1:RigidBody, _arg2:ForceGenerator):Boolean{
var _local3:ForceNode;
_local3 = _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 add(_arg1:RigidBody, _arg2:ForceGenerator):int{
var _local3:int;
var _local4:ForceNode;
_local3 = _idQue.dequeue();
_local4 = new ForceNode(_arg1, _arg2);
_local4.next = _registration;
if (_registration){
_registration.prev = _local4;
};
_registration = _local4;
return (_local3);
}
public function clear():void{
var _local1:ForceNode;
var _local2:ForceNode;
_local1 = _registration;
_registration = null;
while (_local1) {
_local2 = _local1.next;
_local1.next = (_local1.prev = null);
_local1 = _local2;
};
}
public function init():void{
var _local1:int;
var _local2:int;
_registration = null;
_local1 = Constants.k_maxForceGenerators;
_idQue = new ArrayedQueue(_local1);
_local2 = 0;
while (_local2 < _local1) {
_idQue.enqueue(_local2);
_local2++;
};
}
public function evaluate():void{
var _local1:ForceNode;
var _local2:ForceGenerator;
_local1 = _registration;
while (_local1) {
_local2 = _local1.force;
if (_local2.isActive){
_local2.evaluate(_local1.body);
};
_local1 = _local1.next;
};
}
}
}//package de.polygonal.motor2.dynamics.forces
import de.polygonal.motor2.dynamics.*;
class ForceNode {
public var body:RigidBody;
public var next:ForceNode;
public var force:ForceGenerator;
public var prev:ForceNode;
private function ForceNode(_arg1:RigidBody, _arg2:ForceGenerator){
this.body = _arg1;
this.force = _arg2;
init();
}
public function init():void{
prev = (next = null);
}
}
Section 64
//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 65
//RevoluteJointData (de.polygonal.motor2.dynamics.joints.data.RevoluteJointData)
package de.polygonal.motor2.dynamics.joints.data {
import de.polygonal.motor2.dynamics.*;
import flash.geom.*;
import de.polygonal.motor2.dynamics.joints.*;
public class RevoluteJointData extends JointData {
public const anchor1:Point;
public const anchor2:Point;
public var referenceAngle:Number;
public var upperAngle:Number;
public var motorSpeed:Number;
public var lowerAngle:Number;
public var maxMotorTorque:Number;
public var enableMotor:Boolean;
public var enableLimit:Boolean;
public function RevoluteJointData(_arg1:RigidBody, _arg2:RigidBody, _arg3:Point){
var _local4:Point;
anchor1 = new Point();
anchor2 = new Point();
super(_arg1, _arg2);
referenceAngle = (_arg2.r - _arg1.r);
lowerAngle = (upperAngle = 0);
enableLimit = false;
motorSpeed = (maxMotorTorque = 0);
enableMotor = false;
_local4 = new Point();
_arg1.getModelPoint(_arg3, _local4);
anchor1.x = _local4.x;
anchor1.y = _local4.y;
_arg2.getModelPoint(_arg3, _local4);
anchor2.x = _local4.x;
anchor2.y = _local4.y;
}
override public function getJointClass():Class{
return (RevoluteJoint);
}
override protected function setType():void{
type = JointTypes.REVOLUTE;
}
}
}//package de.polygonal.motor2.dynamics.joints.data
Section 66
//Joint (de.polygonal.motor2.dynamics.joints.Joint)
package de.polygonal.motor2.dynamics.joints {
import de.polygonal.motor2.dynamics.*;
import flash.geom.*;
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 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);
}
public function preparePosSolver():void{
}
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 67
//JointNode (de.polygonal.motor2.dynamics.joints.JointNode)
package de.polygonal.motor2.dynamics.joints {
import de.polygonal.motor2.dynamics.*;
public class JointNode {
public var joint:Joint;
public var other:RigidBody;
public var next:JointNode;
public var prev:JointNode;
}
}//package de.polygonal.motor2.dynamics.joints
Section 68
//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 69
//LimitState (de.polygonal.motor2.dynamics.joints.LimitState)
package de.polygonal.motor2.dynamics.joints {
public class LimitState {
public static const LOWER:int = 1;
public static const EQUAL:int = 3;
public static const UPPER:int = 2;
public static const INACTIVE:int = 0;
}
}//package de.polygonal.motor2.dynamics.joints
Section 70
//RevoluteJoint (de.polygonal.motor2.dynamics.joints.RevoluteJoint)
package de.polygonal.motor2.dynamics.joints {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.*;
import flash.geom.*;
import de.polygonal.motor2.dynamics.joints.data.*;
public class RevoluteJoint extends Joint {
private var _k11:Number;
private var _k12:Number;
private var _k13:Number;
private var _k21:Number;
private var _k22:Number;
private var _k23:Number;
private var _limitState:int;
private var _k31:Number;
private var _k32:Number;
private var _k33:Number;
public var upperAngle:Number;
public var lowerAngle:Number;
private var _impulseX:Number;
private var _impulseY:Number;
private var _referenceAngle:Number;
private var _impulseZ:Number;
private var _motorMass:Number;
private var _r1x:Number;
private var _r1y:Number;
private var _motorImpulse:Number;
public var enableMotor:Boolean;
private var _r2x:Number;
private var _r2y:Number;
public var motorSpeed:Number;
public var maxMotorTorque:Number;
public var enableLimit:Boolean;
public function RevoluteJoint(_arg1:RevoluteJointData){
var _local2:RevoluteJointData;
super(_arg1);
_local2 = (_arg1 as RevoluteJointData);
la1x = _local2.anchor1.x;
la1y = _local2.anchor1.y;
la2x = _local2.anchor2.x;
la2y = _local2.anchor2.y;
_referenceAngle = _local2.referenceAngle;
lowerAngle = _local2.lowerAngle;
upperAngle = _local2.upperAngle;
maxMotorTorque = _local2.maxMotorTorque;
motorSpeed = _local2.motorSpeed;
enableLimit = _local2.enableLimit;
enableMotor = _local2.enableMotor;
_impulseX = (_impulseY = (_impulseZ = 0));
_motorImpulse = 0;
}
override public function preStep(_arg1:Number):void{
var _local2:RigidBody;
var _local3:RigidBody;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
super.preStep(_arg1);
_local2 = body1;
_local3 = body2;
_r1x = ((_local2.r11 * la1x) + (_local2.r12 * la1y));
_r1y = ((_local2.r21 * la1x) + (_local2.r22 * la1y));
_r2x = ((_local3.r11 * la2x) + (_local3.r12 * la2y));
_r2y = ((_local3.r21 * la2x) + (_local3.r22 * la2y));
_local4 = _local2.invMass;
_local5 = _local2.invI;
_local6 = _local3.invMass;
_local7 = _local3.invI;
_k11 = (((_local4 + _local6) + ((_r1y * _r1y) * _local5)) + ((_r2y * _r2y) * _local7));
_k12 = (_k21 = (((-(_r1y) * _r1x) * _local5) - ((_r2y * _r2x) * _local7)));
_k31 = (_k13 = ((-(_r1y) * _local5) - (_r2y * _local7)));
_k22 = (((_local4 + _local6) + ((_r1x * _r1x) * _local5)) + ((_r2x * _r2x) * _local7));
_k32 = (_k23 = ((_r1x * _local5) + (_r2x * _local7)));
_k33 = (_local5 + _local7);
_motorMass = (1 / (_local5 + _local7));
if (!enableMotor){
_motorImpulse = 0;
};
if (enableLimit){
_local8 = ((_local3.r - _local2.r) - _referenceAngle);
_local9 = (upperAngle - lowerAngle);
if (((_local9 < 0)) ? -(_local9) : _local9 < (2 * Constants.k_angSlop)){
_limitState = LimitState.EQUAL;
} else {
if (_local8 <= lowerAngle){
if (_limitState != LimitState.LOWER){
_impulseZ = 0;
};
_limitState = LimitState.LOWER;
} else {
if (_local8 >= upperAngle){
if (_limitState != LimitState.UPPER){
_impulseZ = 0;
};
_limitState = LimitState.UPPER;
} else {
_limitState = LimitState.INACTIVE;
_impulseZ = 0;
};
};
};
};
if (World.doWarmStarting){
_local2.vx = (_local2.vx - (_local4 * _impulseX));
_local2.vy = (_local2.vy - (_local4 * _impulseY));
_local2.w = (_local2.w - (_local5 * (((_r1x * _impulseY) - (_r1y * _impulseX)) + (_motorImpulse + _impulseZ))));
_local3.vx = (_local3.vx + (_local6 * _impulseX));
_local3.vy = (_local3.vy + (_local6 * _impulseY));
_local3.w = (_local3.w + (_local7 * (((_r2x * _impulseY) - (_r2y * _impulseX)) + (_motorImpulse + _impulseZ))));
} else {
_impulseX = 0;
_impulseY = 0;
_impulseZ = 0;
_motorImpulse = 0;
};
}
public function setLimits(_arg1:Number, _arg2:Number):void{
if (_arg1 < _arg2){
lowerAngle = _arg1;
upperAngle = _arg2;
};
}
public function getJointAngle():Number{
return (((body2.r - body1.r) - _referenceAngle));
}
override public function solvePosConstraints():Boolean{
var _local1:RigidBody;
var _local2:RigidBody;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
_local1 = body1;
_local2 = body2;
_local3 = ((_local1.r11 * la1x) + (_local1.r12 * la1y));
_local4 = ((_local1.r21 * la1x) + (_local1.r22 * la1y));
_local5 = ((_local2.r11 * la2x) + (_local2.r12 * la2y));
_local6 = ((_local2.r21 * la2x) + (_local2.r22 * la2y));
_local7 = 0;
_local8 = 0;
_local9 = 0;
_local10 = 0;
_local11 = 0;
_local12 = 0;
_local13 = 0;
_local14 = 0;
if (((enableLimit) && (!((_limitState == LimitState.INACTIVE))))){
_local18 = ((body2.r - body1.r) - _referenceAngle);
_local19 = 0;
if (_limitState == LimitState.EQUAL){
_local9 = ((_local18)<-(Constants.k_maxAngCorrection)) ? -(Constants.k_maxAngCorrection) : ((_local18)>Constants.k_maxAngCorrection) ? Constants.k_maxAngCorrection : _local18;
_local19 = (-(_motorMass) * _local9);
_local8 = ((_local9 > 0)) ? _local9 : -(_local9);
} else {
if (_limitState == LimitState.LOWER){
_local9 = (_local18 - lowerAngle);
_local8 = -(_local9);
_local12 = (_local9 + Constants.k_angSlop);
_local9 = ((_local12)<-(Constants.k_maxAngCorrection)) ? -(Constants.k_maxAngCorrection) : ((_local12)>0) ? 0 : _local12;
_local19 = (-(_motorMass) * _local9);
} else {
if (_limitState == LimitState.UPPER){
_local9 = (_local18 - upperAngle);
_local8 = _local9;
_local12 = (_local9 - Constants.k_angSlop);
_local9 = ((_local12)<0) ? 0 : ((_local12)>Constants.k_maxAngCorrection) ? Constants.k_maxAngCorrection : _local12;
_local19 = (-(_motorMass) * _local9);
};
};
};
body1.r = (body1.r - (body1.invI * _local19));
body2.r = (body2.r + (body2.invI * _local19));
};
_local3 = ((_local1.r11 * la1x) + (_local1.r12 * la1y));
_local4 = ((_local1.r21 * la1x) + (_local1.r22 * la1y));
_local5 = ((_local2.r11 * la2x) + (_local2.r12 * la2y));
_local6 = ((_local2.r21 * la2x) + (_local2.r22 * la2y));
_local10 = (((body2.x + _local5) - body1.x) - _local3);
_local11 = (((body2.y + _local6) - body1.y) - _local4);
_local7 = Math.sqrt(((_local10 * _local10) + (_local11 * _local11)));
_local15 = (10 * Constants.k_linSlop);
_local16 = ((_local10 * _local10) + (_local11 * _local11));
if (_local16 > (_local15 * _local15)){
_local16 = (1 / Math.sqrt(_local16));
_local20 = (body1.invMass + body2.invMass);
if (_local20 > 1E-8){
_local21 = (1 / _local20);
} else {
throw (new Error("division by zero"));
};
_local13 = (-(_local21) * _local10);
_local14 = (-(_local21) * _local11);
body1.x = (body1.x - ((0.5 * body1.invMass) * _local13));
body1.y = (body1.y - ((0.5 * body1.invMass) * _local14));
body2.x = (body2.x + ((0.5 * body2.invMass) * _local13));
body2.y = (body2.y + ((0.5 * body2.invMass) * _local14));
_local10 = (((body2.x + _local5) - body1.x) - _local3);
_local11 = (((body2.y + _local6) - body1.y) - _local4);
};
_k11 = (((body1.invMass + body2.invMass) + ((body1.invI * _local4) * _local4)) + ((body2.invI * _local6) * _local6));
_k22 = (((body1.invMass + body2.invMass) + ((body1.invI * _local3) * _local3)) + ((body2.invI * _local5) * _local5));
_k21 = (_k12 = (((-(body1.invI) * _local3) * _local4) - ((body2.invI * _local5) * _local6)));
_local17 = ((_k11 * _k22) - (_k12 * _k21));
if (_local17 != 0){
_local17 = (1 / _local17);
} else {
throw (new Error("division by zero"));
};
_local13 = (_local17 * ((-(_k22) * _local10) + (_k12 * _local11)));
_local14 = (_local17 * ((-(_k11) * _local11) + (_k21 * _local10)));
body1.x = (body1.x - (body1.invMass * _local13));
body1.y = (body1.y - (body1.invMass * _local14));
body1.r = (body1.r - (body1.invI * ((_local3 * _local14) - (_local4 * _local13))));
body2.x = (body2.x + (body2.invMass * _local13));
body2.y = (body2.y + (body2.invMass * _local14));
body2.r = (body2.r + (body2.invI * ((_local5 * _local14) - (_local6 * _local13))));
return ((((_local7 <= Constants.k_linSlop)) && ((_local8 <= Constants.k_angSlop))));
}
override public function solveVelConstraints(_arg1:Number, _arg2:int):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:RigidBody;
var _local10:RigidBody;
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;
_local3 = body1.vx;
_local4 = body1.vy;
_local5 = body2.vx;
_local6 = body2.vy;
_local7 = body1.w;
_local8 = body2.w;
_local9 = body1;
_local10 = body2;
_r1x = ((_local9.r11 * la1x) + (_local9.r12 * la1y));
_r1y = ((_local9.r21 * la1x) + (_local9.r22 * la1y));
_r2x = ((_local10.r11 * la2x) + (_local10.r12 * la2y));
_r2y = ((_local10.r21 * la2x) + (_local10.r22 * la2y));
_local11 = 0;
_local12 = 0;
_local13 = 0;
_local14 = 0;
_local15 = 0;
if (((enableMotor) && (!((_limitState == LimitState.EQUAL))))){
_local16 = ((_local8 - _local7) - motorSpeed);
_local11 = (-(_motorMass) * _local16);
_local17 = _motorImpulse;
_local18 = (_arg1 * maxMotorTorque);
_motorImpulse = (((_motorImpulse + _local11))<-(_local18)) ? -(_local18) : (((_motorImpulse + _local11))>_local18) ? _local18 : (_motorImpulse + _local11);
_local11 = (_motorImpulse - _local17);
_local7 = (_local7 - (body1.invI * _local11));
_local8 = (_local8 + (body2.invI * _local11));
};
if (((enableLimit) && (!((_limitState == LimitState.INACTIVE))))){
_local13 = (((_local5 - (_local8 * _r2y)) - _local3) + (_local7 * _r1y));
_local14 = (((_local6 + (_local8 * _r2x)) - _local4) - (_local7 * _r1x));
_local15 = (_local8 - _local7);
_local12 = (((((_k22 * _k33) - (_k32 * _k23)) * _k11) + (((_k32 * _k13) - (_k12 * _k33)) * _k21)) + (((_k12 * _k23) - (_k22 * _k13)) * _k31));
if (_local12 != 0){
_local12 = (1 / _local12);
} else {
throw (new Error("division by zero"));
};
_local19 = (_local12 * (((-(((_k22 * _k33) - (_k32 * _k23))) * _local13) - (((_k32 * _k13) - (_k12 * _k33)) * _local14)) - (((_k12 * _k23) - (_k22 * _k13)) * _local15)));
_local20 = (_local12 * (((((-(_local14) * _k33) + (_local15 * _k23)) * _k11) + (((-(_local15) * _k13) + (_local13 * _k33)) * _k21)) + (((-(_local13) * _k23) + (_local14 * _k13)) * _k31)));
_local21 = (_local12 * (((((-(_k22) * _local15) + (_k32 * _local14)) * _k11) + (((-(_k32) * _local13) + (_k12 * _local15)) * _k21)) + (((-(_k12) * _local14) + (_k22 * _local13)) * _k31)));
if (_limitState == LimitState.EQUAL){
_impulseX = (_impulseX + _local19);
_impulseY = (_impulseY + _local20);
_impulseZ = (_impulseZ + _local21);
} else {
if (_limitState == LimitState.LOWER){
_local11 = (_impulseZ + _local21);
if (_local11 < 0){
_local12 = ((_k11 * _k22) - (_k12 * _k21));
if (_local12 != 0){
_local12 = (1 / _local12);
} else {
throw (new Error("division by zero"));
};
_local19 = (_local12 * ((-(_k22) * _local13) + (_k12 * _local14)));
_local20 = (_local12 * ((-(_k11) * _local14) + (_k21 * _local13)));
_local21 = -(_impulseZ);
_impulseX = (_impulseX + _local19);
_impulseY = (_impulseY + _local20);
_impulseZ = 0;
};
} else {
if (_limitState == LimitState.UPPER){
_local11 = (_impulseZ + _local21);
if (_local11 > 0){
_local12 = ((_k11 * _k22) - (_k12 * _k21));
if (_local12 != 0){
_local12 = (1 / _local12);
} else {
throw (new Error("division by zero"));
};
_local19 = (_local12 * ((-(_k22) * _local13) + (_k12 * _local14)));
_local20 = (_local12 * ((-(_k11) * _local14) + (_k21 * _local13)));
_local21 = -(_impulseZ);
_impulseX = (_impulseX + _local19);
_impulseY = (_impulseY + _local20);
_impulseZ = 0;
};
};
};
};
_local3 = (_local3 - (body1.invMass * _local19));
_local4 = (_local4 - (body1.invMass * _local20));
_local7 = (_local7 - (body1.invI * (((_r1x * _local20) - (_r1y * _local19)) + _local21)));
_local5 = (_local5 + (body2.invMass * _local19));
_local6 = (_local6 + (body2.invMass * _local20));
_local8 = (_local8 + (body2.invI * (((_r2x * _local20) - (_r2y * _local19)) + _local21)));
} else {
_local13 = (((_local5 - (_local8 * _r2y)) - _local3) + (_local7 * _r1y));
_local14 = (((_local6 + (_local8 * _r2x)) - _local4) - (_local7 * _r1x));
_local12 = ((_k11 * _k22) - (_k12 * _k21));
if (_local12 != 0){
_local12 = (1 / _local12);
} else {
throw (new Error("division by zero"));
};
_local19 = (_local12 * ((-(_k22) * _local13) + (_k12 * _local14)));
_local20 = (_local12 * ((-(_k11) * _local14) + (_k21 * _local13)));
_impulseX = (_impulseX + _local19);
_impulseY = (_impulseY + _local20);
_local3 = (_local3 - (body1.invMass * _local19));
_local4 = (_local4 - (body1.invMass * _local20));
_local7 = (_local7 - (body1.invI * ((_r1x * _local20) - (_r1y * _local19))));
_local5 = (_local5 + (body2.invMass * _local19));
_local6 = (_local6 + (body2.invMass * _local20));
_local8 = (_local8 + (body2.invI * ((_r2x * _local20) - (_r2y * _local19))));
};
body1.vx = _local3;
body1.vy = _local4;
body1.w = _local7;
body2.vx = _local5;
body2.vy = _local6;
body2.w = _local8;
}
override public function getReactionTorque():Number{
return ((_invdt * _impulseZ));
}
override public function getReactionForce():Point{
_reactionForce.x = (_impulseX * _invdt);
_reactionForce.y = (_impulseY * _invdt);
return (_reactionForce);
}
public function getMotorTorque():Number{
return (_motorImpulse);
}
public function getJointSpeed():Number{
return ((body2.w - body1.w));
}
}
}//package de.polygonal.motor2.dynamics.joints
Section 71
//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 bodyCount:int;
public var contactSolver:IContactSolver;
public var contactCount:int;
public var contacts:Array;
public var positionError:Number;
public var bodyList:RigidBody;
public var jointCount:int;
public var joints:Array;
public var positionIterations:int;
public static var numIslands:int = 0;
public static var bodiesPerIsland:Array = [];
public function Island(){
bodyCount = 0;
contactCount = 0;
jointCount = 0;
bodyList = null;
bodies = [];
contacts = [];
joints = [];
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:SIContactSolver;
var _local9:Number;
var _local10:Number;
var _local11:Boolean;
var _local12: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++;
};
_local8 = SIContactSolver(contactSolver);
_local8.setContacts(contacts, contactCount);
_local8.preStep();
_local6 = 0;
while (_local6 < jointCount) {
joints[_local6].preStep(_arg4);
_local6++;
};
_local5 = 0;
while (_local5 < _arg3) {
_local8.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));
_local10 = Math.cos(_local7.r);
_local9 = Math.sin(_local7.r);
_local7.r11 = _local10;
_local7.r12 = -(_local9);
_local7.r21 = _local9;
_local7.r22 = _local10;
};
_local5++;
};
if (World.doPositionCorrection){
_local5 = 0;
while (_local5 < _arg3) {
_local11 = _local8.solvePosConstraints(Constants.k_contactBaumgarte);
_local12 = true;
_local6 = 0;
while (_local6 < jointCount) {
_local12 = joints[_local6].solvePosConstraints();
_local12 = ((_local12) && (_local12));
_local6++;
};
if (((_local11) && (_local12))){
break;
};
_local5++;
};
};
_local5 = 0;
while (_local5 < bodyCount) {
_local7 = bodies[_local5];
if (_local7.invMass == 0){
} else {
_local7.updateShapes();
_local7.fx = (_local7.fy = (_local7.t = 0));
};
_local5++;
};
}
public function init():void{
bodies.length = 0;
contacts.length = 0;
joints.length = 0;
}
public function setContactSolver(_arg1:IContactSolver):void{
contactSolver = _arg1;
}
public function updateSleep(_arg1:Number):void{
var _local2:Number;
var _local3:Number;
var _local4:Number;
var _local5:RigidBody;
var _local6:int;
_local2 = 2147483648;
_local3 = Constants.k_linSleepToleranceSq;
_local4 = 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
class RBNode {
public var body:RigidBody;
public var next:RBNode;
private function RBNode(){
}
}
Section 72
//RigidBody (de.polygonal.motor2.dynamics.RigidBody)
package de.polygonal.motor2.dynamics {
import de.polygonal.motor2.*;
import de.polygonal.motor2.math.*;
import flash.geom.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.joints.*;
public class RigidBody {
public var invMass:Number;
public var r12:Number;
public var r:Number;
public var r11:Number;
public var id:int;
public var world:World;
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 t:Number;
public var cx:Number;
public var cy:Number;
public var x:Number;
public var y:Number;
public var mass: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_bitExclude:int = (((k_bitStatic | k_bitIsland) | k_bitSleep) | k_bitFrozen);
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 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 _local1:ShapeSkeleton;
var _local2:ShapeSkeleton;
prev = (next = null);
_local1 = shapeList;
while (_local1) {
_local2 = _local1;
_local1 = _local1.next;
_local2.deconstruct();
};
}
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():void{
var _local1:Number;
var _local2:Number;
var _local3:ShapeSkeleton;
_local1 = Math.cos(r);
_local2 = Math.sin(r);
r11 = _local1;
r12 = -(_local2);
r21 = _local2;
r22 = _local1;
_local3 = shapeList;
while (_local3) {
_local3.update();
_local3 = _local3.next;
};
}
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 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 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 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) - ((_arg4 - y) * _arg1)));
};
}
public function isConnected(_arg1:RigidBody):Boolean{
return (false);
}
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 73
//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 74
//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 copy():AABB2{
return (new AABB2(xmin, ymin, xmax, ymax));
}
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;
};
}
}
}//package de.polygonal.motor2.math
Section 75
//ConvexBSP (de.polygonal.motor2.math.ConvexBSP)
package de.polygonal.motor2.math {
public class ConvexBSP {
public static var VERTEX_ORDER:Number = 1;
public static function createInternalNode(_arg1:int, _arg2:Array, _arg3:Array, _arg4:Array, _arg5:Array):ConvexBSPNode{
var _local6:ConvexBSPNode;
var _local7:ConvexBSPNode;
var _local8:Array;
var _local9:Array;
var _local10:Array;
var _local11:Array;
var _local12:Array;
var _local13:V2;
var _local14:V2;
var _local15:Number;
var _local16:Number;
var _local17:int;
var _local18:int;
var _local19:int;
var _local20:Number;
var _local21:int;
var _local22:ConvexBSPNode;
_local8 = [];
_local9 = [];
_local10 = [];
_local11 = [];
_local18 = _arg4.length;
_local12 = new Array();
_local21 = int(((_arg4[0] + _arg4[int((_local18 - 1))]) / 2));
_local13 = _arg3[_local21];
_local15 = (_local13.x * VERTEX_ORDER);
_local16 = (_local13.y * VERTEX_ORDER);
_local19 = (_arg4[0] - 1);
if (_local19 < 0){
_local19 = (_local18 - 1);
};
_local14 = _arg2[_local19];
_local12[0] = ((_local15 * _local14.x) + (_local16 * _local14.y));
_local17 = 0;
while (_local17 < _local18) {
_local19 = _arg4[_local17];
if (_local19 == _local21){
_local12[int((_local17 + 1))] = 1;
} else {
_local14 = _arg2[_local19];
_local20 = (_local12[int((_local17 + 1))] = ((_local15 * _local14.x) + (_local16 * _local14.y)));
if ((_local20 >= 0)){
_local8[_local8.length] = _local19;
} else {
_local9[_local9.length] = _local19;
};
};
_local17++;
};
_local19 = (_arg4[int((_local18 - 1))] + 1);
if (_local19 == _arg1){
_local19 = 0;
};
_local14 = _arg2[_local19];
_local12[_local12.length] = ((_local15 * _local14.x) + (_local16 * _local14.y));
_local18 = _arg5.length;
_local17 = 0;
while (_local17 < _local18) {
if ((((_local12[_local17] >= 0)) && ((_local12[int((_local17 + 1))] >= 0)))){
_local10[_local10.length] = _arg5[_local17];
} else {
_local11[_local11.length] = _arg5[_local17];
};
_local17++;
};
_local7 = null;
if (_local8.length > 0){
_local7 = createInternalNode(_arg1, _arg2, _arg3, _local8, _local10);
} else {
if (_local10.length > 0){
_local7 = createNode(_local10[0][1]);
};
};
_local6 = null;
if (_local9.length > 0){
_local6 = createInternalNode(_arg1, _arg2, _arg3, _local9, _local11);
} else {
_local6 = createNode(_local11[0][1]);
};
_local22 = createNode(_local21, _local7, _local6);
return (_local22);
}
public static function createBSP(_arg1:int, _arg2:Array, _arg3:Array):ConvexBSPNode{
var _local4:Array;
var _local5:Array;
var _local6:Array;
var _local7:Array;
var _local8:V2;
var _local9:V2;
var _local10:Number;
var _local11:Number;
var _local12:int;
var _local13:Number;
var _local14:Number;
var _local15:ConvexBSPNode;
var _local16:ConvexBSPNode;
_local4 = [];
_local5 = [];
_local6 = [];
_local7 = [];
_local8 = _arg3[0];
_local10 = (_local8.x * VERTEX_ORDER);
_local11 = (_local8.y * VERTEX_ORDER);
_local13 = 0;
_local12 = 1;
while (_local12 < _arg1) {
_local9 = _arg2[_local12];
_local14 = ((_local10 * _local9.x) + (_local11 * _local9.y));
if (_local14 >= 0){
_local4[_local4.length] = _local12;
} else {
_local5[_local5.length] = _local12;
};
if ((((_local13 >= 0)) && ((_local14 >= 0)))){
_local6[_local6.length] = [(_local12 - 1), _local12];
} else {
if ((((_local13 <= 0)) && ((_local14 <= 0)))){
_local7[_local7.length] = [(_local12 - 1), _local12];
} else {
_local6[_local6.length] = [(_local12 - 1), _local12];
_local7[_local7.length] = [(_local12 - 1), _local12];
};
};
_local13 = _local14;
_local12++;
};
_local7[_local7.length] = [(_arg1 - 1), 0];
_local15 = createInternalNode(_arg1, _arg2, _arg3, _local4, _local6);
_local16 = createInternalNode(_arg1, _arg2, _arg3, _local5, _local7);
return (createNode(0, _local15, _local16));
}
public static function createNode(_arg1:int, _arg2:ConvexBSPNode=null, _arg3:ConvexBSPNode=null):ConvexBSPNode{
var _local4:ConvexBSPNode;
_local4 = 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 76
//ConvexBSPNode (de.polygonal.motor2.math.ConvexBSPNode)
package de.polygonal.motor2.math {
import de.polygonal.ds.*;
public class ConvexBSPNode extends BinaryTreeNode {
public var L:ConvexBSPNode;
public var I:int;
public var R:ConvexBSPNode;
public var N:V2;
public var V: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 77
//E2 (de.polygonal.motor2.math.E2)
package de.polygonal.motor2.math {
public class E2 {
public var d:V2;
public var mag:Number;// = 0
public var n:V2;
public var v:V2;
public var w:V2;
public function E2(){
mag = 0;
super();
}
}
}//package de.polygonal.motor2.math
Section 78
//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 next:Tri2;
public var area:Number;
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 79
//V2 (de.polygonal.motor2.math.V2)
package de.polygonal.motor2.math {
import flash.geom.*;
public class V2 extends Point {
public var I:int;
public var userData;
public var last:Boolean;
public var prev:V2;
public var next:V2;
public function V2(_arg1:Number=0, _arg2:Number=0){
super(_arg1, _arg2);
next = (prev = null);
last = false;
I = -1;
}
public function toArray():Array{
var _local1:V2;
var _local2:int;
var _local3:Array;
_local1 = this;
_local2 = 1;
_local3 = [_local1];
if (last){
return (_local3);
};
_local1 = _local1.next;
while (_local1) {
var _temp1 = _local2;
_local2 = (_local2 + 1);
var _local4 = _temp1;
_local3[_local4] = _local1;
if (_local1.last){
break;
};
_local1 = _local1.next;
};
return (_local3);
}
public function getAt(_arg1:int):V2{
var _local2:V2;
_local2 = this;
while (_local2) {
if (_local2.I == _arg1){
return (_local2);
};
if (_local2.last){
break;
};
_local2 = _local2.next;
};
return (null);
}
override public function toString():String{
return ((((((((("{V2, x=" + x.toFixed(2)) + ", y=") + y.toFixed(2)) + ", I=") + I) + ", last = ") + int(last)) + "}"));
}
public function deconstruct():void{
var _local1:V2;
var _local2:V2;
_local1 = this;
while (_local1) {
_local2 = _local1.next;
_local1 = null;
_local1 = _local2;
};
}
public function copy():V2{
return (new V2(x, y));
}
}
}//package de.polygonal.motor2.math
Section 80
//Constants (de.polygonal.motor2.Constants)
package de.polygonal.motor2 {
public class Constants {
public static const k_velocityThreshold:Number = 50;
public static const k_timeUnitsPerSecond:Number = 1;
public static const k_maxManifoldPoints:int = 2;
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.000123456790123457;
public static const k_maxForceGenerators:int = 0x0200;
public static const k_maxShapesPerBody:int = 64;
public static const k_maxLinCorrection:Number = 10;
public static const k_angSlop:Number = 0.0349065850398866;
public static const k_lengthUnitsPerMeter:Number = 50;
public static const k_maxProxies:int = 0x0200;
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 = 4096;
public static const k_angSleepTolerance:Number = 0.0111111111111111;
public static const k_massUnitsPerKilogram:Number = 1;
public static const k_timeToSleep:Number = 0.5;
}
}//package de.polygonal.motor2
Section 81
//World (de.polygonal.motor2.World)
package de.polygonal.motor2 {
import flash.events.*;
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.joints.data.*;
import de.polygonal.motor2.collision.nbody.*;
import de.polygonal.motor2.dynamics.forces.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.joints.*;
public class World extends EventDispatcher {
public const gravity:V2;
public var doSleep:Boolean;
private var _bodyCount:int;
private var _contactManager:ContactManager;
private var _contactCount:int;
private var _island:Island;
public var bodyDestroyList:RigidBody;
private var _jointCount:int;
public var jointList:Joint;
public var groundBody:RigidBody;
public var contactCount:int;
private var _forceRegistry:ForceRegistry;
public var contactList:Contact;
private var _broadphase:IBroadPhase;
public var bodyList:RigidBody;
public var worldAABB:AABB2;
private var _bodyIdCount:int;
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){
gravity = new V2();
super();
this.worldAABB = _arg1.copy();
this.doSleep = _arg2;
init();
}
public function getBroadPhase():IBroadPhase{
return (_broadphase);
}
public function init():void{
bodyList = null;
bodyDestroyList = null;
contactList = null;
jointList = null;
_bodyCount = 0;
_contactCount = 0;
setGravity(0, 100);
_contactManager = new ContactManager(this);
_forceRegistry = new ForceRegistry();
_island = new Island();
_bodyIdCount = 0;
setBroadPhase(new ExhaustiveSearch());
}
public function setGravity(_arg1:Number, _arg2:Number):void{
gravity.x = _arg1;
gravity.y = _arg2;
}
public function setBroadPhase(_arg1:IBroadPhase):void{
if (bodyList){
return;
};
_broadphase = _arg1;
_broadphase.setWorld(this);
_broadphase.setWorldBounds(worldAABB);
_broadphase.setPairHandler(_contactManager);
}
public function setWorldBounds(_arg1:AABB2):void{
}
public function getWorldBounds():AABB2{
return (null);
}
private function destroyJoint(_arg1:Joint):void{
var _local2:Boolean;
var _local3:RigidBody;
var _local4:RigidBody;
var _local5:RigidBody;
var _local6:ShapeSkeleton;
_local2 = _arg1.collideConnected;
if (_arg1.prev){
_arg1.prev.next = _arg1.next;
};
if (_arg1.next){
_arg1.next.prev = _arg1.prev;
};
if (_arg1 == jointList){
jointList = _arg1.next;
};
_local3 = _arg1.body1;
_local4 = _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 = _local6.next;
};
};
}
public function createBody(_arg1:RigidBodyData):RigidBody{
var _local2:RigidBody;
_local2 = new RigidBody(this, _arg1);
_local2.id = _bodyIdCount++;
_local2.next = bodyList;
if (bodyList){
bodyList.prev = _local2;
};
bodyList = _local2;
_bodyCount++;
return (_local2);
}
public function getGroundBody():RigidBody{
return (null);
}
public function destroyBody(_arg1:RigidBody):Boolean{
if (_bodyCount == 0){
return (false);
};
if ((_arg1.stateBits & RigidBody.k_bitDestroy)){
return (false);
};
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.prev = null;
_arg1.next = bodyDestroyList;
bodyDestroyList = _arg1;
return (true);
}
public function step(_arg1:Number, _arg2:int):void{
var _local3:RigidBody;
var _local4:Contact;
var _local5:Joint;
var _local6:int;
var _local7:Array;
var _local8:int;
var _local9:RigidBody;
var _local10:ContactNode;
var _local11:JointNode;
var _local12:RigidBody;
var _local13:Joint;
_contactManager.cleanContactList();
cleanBodyList();
_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;
};
_local7 = [];
_local12 = bodyList;
while (_local12 != null) {
if ((_local12.stateBits & RigidBody.k_bitExclude)){
} 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 _local14 = _temp1;
_local7[_local14] = _local9;
_local9.stateBits = (_local9.stateBits | 32);
};
};
_local10 = _local10.next;
};
_local11 = _local3.jointList;
while (_local11) {
_local13 = _local11.joint;
if ((_local13.stateBits & 32)){
} else {
_island.joints[int(_island.jointCount++)] = _local13;
_local13.stateBits = (_local13.stateBits | 32);
_local9 = _local11.other;
if ((_local9.stateBits & 32)){
} else {
var _temp2 = _local8;
_local8 = (_local8 + 1);
_local14 = _temp2;
_local7[_local14] = _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));
};
if ((_local3.stateBits & RigidBody.k_bitFrozen)){
};
_local6++;
};
};
_local12 = _local12.next;
};
_broadphase.search();
}
public function removeForce(_arg1:RigidBody, _arg2:ForceGenerator):Boolean{
return (_forceRegistry.remove(_arg1, _arg2));
}
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);
}
private function cleanBodyList():void{
var _local1:RigidBody;
var _local2:RigidBody;
var _local3:JointNode;
var _local4:JointNode;
_contactManager.destroyImmediate = true;
_local1 = bodyDestroyList;
while (_local1) {
_local2 = _local1;
_local1 = _local1.next;
_local3 = _local2.jointList;
while (_local3) {
_local4 = _local3;
_local3 = _local3.next;
destroyJoint(_local4.joint);
};
_local2.deconstruct();
_local2 = null;
};
bodyDestroyList = null;
_contactManager.destroyImmediate = false;
}
public function createJoint(_arg1:JointData):Joint{
var _local2:Class;
var _local3:Joint;
var _local4:RigidBody;
var _local5:ShapeSkeleton;
_local2 = _arg1.getJointClass();
_local3 = (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 = _local5.next;
};
};
return (_local3);
}
public function deconstruct():void{
destroyBody(groundBody);
_broadphase = null;
}
}
}//package de.polygonal.motor2
Section 82
//Background (Background)
package {
import flash.display.*;
import flash.events.*;
public class Background extends Sprite {
private var bmp:BitmapData;
public function Background(_arg1:Stage){
var _local2:int;
var _local3:int;
super();
bmp = new BitmapData(2, 2, false);
_local2 = 0;
while (_local2 < bmp.height) {
_local3 = 0;
while (_local3 < bmp.width) {
bmp.setPixel(_local3, _local2, (((_local2 % 2) == 0)) ? (((141 << 16) | (173 << 8)) | 14) : (((155 << 16) | (188 << 8)) | 15));
_local3++;
};
_local2++;
};
render(_arg1.stageWidth, _arg1.stageHeight);
_arg1.addEventListener(Event.RESIZE, resizeHandler);
}
private function render(_arg1:Number, _arg2:Number):void{
graphics.beginBitmapFill(bmp);
graphics.drawRect((-((_arg1 - 800)) / 2), (-((_arg2 - 600)) / 2), _arg1, _arg2);
graphics.endFill();
}
private function resizeHandler(_arg1:Event):void{
render(stage.stageWidth, stage.stageHeight);
}
}
}//package
Section 83
//EngineSound (EngineSound)
package {
import flash.media.*;
public dynamic class EngineSound extends Sound {
}
}//package
Section 84
//Fan (Fan)
package {
import flash.display.*;
public dynamic class Fan extends MovieClip {
public var rotate:MovieClip;
}
}//package
Section 85
//Fruit (Fruit)
package {
import flash.display.*;
public class Fruit extends MovieClip {
private const RADIUS:int = 225;
private var music:Music;
private var timer:int;
private var rawr:Rawr;
private var touchTimer:int;
private var posX:int;
private var posY:int;
private var game:Game;
public function Fruit(_arg1:Game, _arg2:Rawr, _arg3:Music){
this.game = _arg1;
this.rawr = _arg2;
this.music = _arg3;
position();
}
private function position():void{
var _local1:*;
var _local2:*;
var _local3:*;
var _local4:*;
do {
_local1 = ((Math.random() * Math.PI) * 2);
_local2 = ((Math.random() * 1000) + 500);
_local3 = (Math.cos(_local1) * _local2);
_local4 = ((Math.sin(_local1) * _local2) + 1700);
} while ((((_local3 - posX) * (_local3 - posX)) + ((_local4 - posY) * (_local4 - posY))) < (1000 * 1000));
posX = _local3;
posY = _local4;
}
public function getX():int{
return (posX);
}
public function getY():int{
return (posY);
}
public function main(_arg1:int, _arg2:int):void{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
x = (posX - _arg1);
y = (posY - _arg2);
scaleX = (scaleY = (1 + (Math.sin((timer++ * 0.3)) * 0.1)));
_local3 = (posX - rawr.getBody().x);
_local4 = (posY - rawr.getBody().y);
_local5 = ((_local3 * _local3) + (_local4 * _local4));
if (_local5 < (RADIUS * RADIUS)){
touchTimer++;
if (touchTimer > (Main.FPS * 0.5)){
touchTimer = 0;
game.gotFruit();
music.playFruitSound();
_local6 = 0;
while (_local6 < 5) {
game.addSmoke(posX, posY, (Math.cos((((Math.PI * 2) / 5) * _local6)) * 4), (Math.sin((((Math.PI * 2) / 5) * _local6)) * 4));
_local6++;
};
position();
_local6 = 0;
while (_local6 < 5) {
game.addSmoke(posX, posY, (Math.cos((((Math.PI * 2) / 5) * _local6)) * 4), (Math.sin((((Math.PI * 2) / 5) * _local6)) * 4));
_local6++;
};
};
};
}
}
}//package
Section 86
//FruitSound (FruitSound)
package {
import flash.media.*;
public dynamic class FruitSound extends Sound {
}
}//package
Section 87
//Fuel (Fuel)
package {
import flash.display.*;
public class Fuel {
private var value:Number;
private var fuelMeter:MovieClip;
private var fuelMeterBg:MovieClip;
public function Fuel(_arg1:Sprite, _arg2:Sprite){
var _local3:BitmapData;
super();
value = 1;
fuelMeter = new FuelMeter();
fuelMeter.x = 20;
fuelMeter.y = 570;
_local3 = new BitmapData(1, 2, false);
_local3.setPixel(0, 0, 3170864);
_local3.setPixel(0, 1, 9153551);
fuelMeter.graphics.beginBitmapFill(_local3);
fuelMeter.graphics.drawRect(-3, -3, 766, 14);
fuelMeter.graphics.endFill();
}
public function plus(_arg1:Number):void{
value = (value + _arg1);
if (value > 1){
value = 1;
};
}
public function minus(_arg1:Number):void{
value = (value - _arg1);
if (value < 0){
value = 0;
};
}
public function main():void{
fuelMeter.gotoAndStop(int((fuelMeter.totalFrames * value)));
}
public function getValue():Number{
return (value);
}
public function getFuelMeter():MovieClip{
return (fuelMeter);
}
}
}//package
Section 88
//FuelMeter (FuelMeter)
package {
import flash.display.*;
public dynamic class FuelMeter extends MovieClip {
}
}//package
Section 89
//FuelMeterBg (FuelMeterBg)
package {
import flash.display.*;
public dynamic class FuelMeterBg extends MovieClip {
}
}//package
Section 90
//Game (Game)
package {
import flash.display.*;
import flash.events.*;
public class Game extends Sprite {
private var worldX:Number;
private var worldY:Number;
private var fruit:Fruit;
private var music:Music;
private var fruitsCollected:int;
private var terrain:Terrain;
private var mainClass:Main;
private var outlineCanvas:Sprite;
private var timer:Timer;
private var physics:Physics;
private var rawr:Rawr;
private var smoke:Array;
private var miniMap:MiniMap;
private var fillCanvas:Sprite;
private var fuel:Fuel;
private var gameOverTimer:int;
public function Game(_arg1:Stage, _arg2:Main){
var _local3:Sprite;
super();
this.mainClass = _arg2;
outlineCanvas = new Sprite();
fillCanvas = new Sprite();
physics = new Physics(this);
music = new Music();
fuel = new Fuel(outlineCanvas, fillCanvas);
rawr = new Rawr(this, physics, fuel, music, outlineCanvas, fillCanvas);
terrain = new Terrain(physics);
fruit = new Fruit(this, rawr, music);
miniMap = new MiniMap(terrain, rawr, fruit);
timer = new Timer(this);
worldX = 0;
worldY = 0;
smoke = [];
addChild(outlineCanvas);
addChild(fillCanvas);
addChild(rawr.getFan());
addChild(fruit);
addChild(miniMap);
addChild(fuel.getFuelMeter());
addChild(timer);
_local3 = new Sprite();
_local3.graphics.beginFill(0);
_local3.graphics.drawRect(0, 0, 800, 600);
_local3.graphics.endFill();
addChild(_local3);
outlineCanvas.mask = _local3;
_local3 = new Sprite();
_local3.graphics.beginFill(0);
_local3.graphics.drawRect(0, 0, 800, 600);
_local3.graphics.endFill();
addChild(_local3);
fillCanvas.mask = _local3;
addEventListener(Event.ENTER_FRAME, main);
_arg1.addEventListener(KeyboardEvent.KEY_DOWN, rawr.keyHandler);
_arg1.addEventListener(KeyboardEvent.KEY_UP, rawr.keyHandler);
}
public function addPolygonRenderer(_arg1:PolygonRenderer):void{
fillCanvas.addChild(_arg1);
outlineCanvas.addChild(_arg1.background);
}
public function addSmoke(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
smoke.push(new Smoke(_arg1, _arg2, _arg3, _arg4, outlineCanvas, fillCanvas));
}
public function main(_arg1:Event):void{
var _local2:PolygonRenderer;
var _local3:int;
var _local4:int;
var _local5:Number;
worldX = (worldX + (((rawr.getBody().x - 400) - worldX) * 0.3));
worldY = (worldY + (((rawr.getBody().y - 300) - worldY) * 0.3));
if ((((rawr.getBody().y > 5000)) && ((gameOverTimer == 0)))){
rawr.resetPosition();
worldX = (rawr.getBody().x - 400);
worldY = (rawr.getBody().y - 300);
_local4 = 0;
while (_local4 < 8) {
_local5 = (((Math.PI * 2) / 8) * _local4);
addSmoke((rawr.getBody().x + (Math.cos(_local5) * 60)), (rawr.getBody().y + (Math.sin(_local5) * 60)), (Math.cos(_local5) * 3), (Math.sin(_local5) * 3));
_local4++;
};
};
physics.main();
rawr.main(worldX, worldY);
terrain.main(worldX, worldY);
fruit.main(worldX, worldY);
miniMap.main(rawr.getBody().x, rawr.getBody().y);
fuel.main();
timer.main();
if (gameOverTimer > 0){
gameOverTimer++;
music.fadeDown((1 - (gameOverTimer / (10 * Main.FPS))));
if (gameOverTimer > (10 * Main.FPS)){
removeEventListener(Event.ENTER_FRAME, main);
music.stop();
mainClass.gameOver(fruitsCollected, timer.getTotalTime());
};
};
for each (_local2 in physics.getRenderObjects()) {
_local2.render(worldX, worldY);
};
rawr.fillGaps(worldX, worldY);
_local3 = (smoke.length - 1);
while (_local3 >= 0) {
smoke[_local3].main(worldX, worldY);
if (smoke[_local3].remove()){
smoke.splice(_local3, 1);
};
_local3--;
};
}
public function gameOver():void{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, rawr.keyHandler);
stage.removeEventListener(KeyboardEvent.KEY_UP, rawr.keyHandler);
gameOverTimer = 1;
music.stopEngine();
}
public function gotFruit():void{
if (gameOverTimer == 0){
timer.gotFruit();
};
fruitsCollected++;
}
public function removePolygonRenderer(_arg1:PolygonRenderer):void{
if (fillCanvas.contains(_arg1)){
fillCanvas.removeChild(_arg1);
};
if (outlineCanvas.contains(_arg1.background)){
outlineCanvas.removeChild(_arg1.background);
};
}
}
}//package
Section 91
//HelmetBack (HelmetBack)
package {
import flash.display.*;
public dynamic class HelmetBack extends MovieClip {
}
}//package
Section 92
//HelmetFront (HelmetFront)
package {
import flash.display.*;
public dynamic class HelmetFront extends MovieClip {
}
}//package
Section 93
//Letter (Letter)
package {
import flash.display.*;
public class Letter {
private var vy:Number;
private var bottomStartX:Number;
private var bottomStartY:Number;
private var vx:Number;
private var angle:Number;
private var top:Sprite;
private var a:Number;
private var b:Number;
private var bottom:Sprite;
private var topStartY:Number;
private var topStartX:Number;
public function Letter(_arg1:int, _arg2:Sprite, _arg3:Sprite){
var _local4:Number;
var _local5:Number;
super();
this.top = _arg2;
this.bottom = _arg3;
_arg2.parent.addChild(_arg2.parent.removeChild(_arg2));
topStartX = _arg2.x;
topStartY = _arg2.y;
bottomStartX = _arg3.x;
bottomStartY = _arg3.y;
a = (b = 0);
_local4 = ((Math.PI * 2) * Math.random());
_local5 = (((Math.random() * 1) + 1) / 3);
vx = ((Math.cos(_local4) * _local5) * 1.1);
vy = (Math.sin(_local4) * _local5);
angle = (((_arg1 * Math.PI) * 2) * 0.1);
}
public function main():void{
var _local1:Number;
var _local2:Number;
a = (a + vx);
b = (b + vy);
vx = (vx + (-(a) * 0.02));
vy = (vy + (-(b) * 0.02));
vx = (vx * 0.98);
vy = (vy * 0.98);
_local1 = ((Math.PI * 2) * Math.random());
_local2 = (((Math.random() * 1) + 1) / 20);
vx = (vx + ((Math.cos(_local1) * _local2) * 1.1));
vy = (vy + (Math.sin(_local1) * _local2));
angle = (angle - 0.25);
top.x = (topStartX + a);
top.y = ((topStartY + b) + (Math.sin(angle) * 15));
bottom.x = (bottomStartX + a);
bottom.y = ((bottomStartY + b) + (Math.sin(angle) * 15));
}
}
}//package
Section 94
//Main (Main)
package {
import flash.display.*;
import flash.events.*;
import com.mochibot.*;
import flash.ui.*;
import flash.text.*;
import flash.net.*;
public class Main extends Sprite {
private const ITEM_C:String = "Demake of Jetpack Brontosaurus";
private const ITEM_A:String = "Game by Kian Bashiri";
private const ITEM_B:String = "Music by CCIVORY";
private const LINK_A:String = "http://www.mazapan.se";
private const LINK_C:String = "http://www.jetpackbrontosaurus.com";
private const LINK_D:String = "http://tigsource.com/articles/2008/08/01/tigcompo-bootleg-demakes";
private const LINK_B:String = "http://www.myspace.com/ccivory";
private const ITEM_D:String = "for a TIGSource competiton";
private var letters:Array;
private var background:Background;
private var contextMenuItemFlashbang:ContextMenuItem;
private var title:Sprite;
private var contextMenuItemTIGSource:ContextMenuItem;
private var contextMenuItemKian:ContextMenuItem;
private var contextMenuItemMusic:ContextMenuItem;
private var game:Game;
public static const FPS:uint = 30;
public function Main(){
var _local1:ContextMenu;
super();
stage.frameRate = FPS;
stage.scaleMode = StageScaleMode.NO_SCALE;
_local1 = new ContextMenu();
_local1.hideBuiltInItems();
contextMenuItemKian = new ContextMenuItem(ITEM_A);
contextMenuItemMusic = new ContextMenuItem(ITEM_B);
contextMenuItemFlashbang = new ContextMenuItem(ITEM_C, true);
contextMenuItemTIGSource = new ContextMenuItem(ITEM_D);
contextMenuItemKian.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, contextMenuHandler);
contextMenuItemMusic.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, contextMenuHandler);
contextMenuItemFlashbang.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, contextMenuHandler);
contextMenuItemTIGSource.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, contextMenuHandler);
_local1.customItems.push(contextMenuItemKian);
_local1.customItems.push(contextMenuItemMusic);
_local1.customItems.push(contextMenuItemFlashbang);
_local1.customItems.push(contextMenuItemTIGSource);
contextMenu = _local1;
addChild((background = new Background(stage)));
addEventListener(Event.ENTER_FRAME, mainLoader);
}
public function init():void{
var _local1:int;
addChild((title = new Title()));
letters = [];
_local1 = 0;
while (_local1 < 14) {
letters.push(new Letter(_local1, (title.getChildByName(("a" + _local1)) as Sprite), (title.getChildByName(("b" + _local1)) as Sprite)));
_local1++;
};
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
addEventListener(Event.ENTER_FRAME, mainloop);
}
private function mainLoader(_arg1:Event):void{
if ((((root.loaderInfo.bytesLoaded == root.loaderInfo.bytesTotal)) && ((root.loaderInfo.bytesTotal > 0)))){
removeEventListener(Event.ENTER_FRAME, mainLoader);
MochiBot.track(this, "0419a2cb");
init();
};
}
private function keyHandler(_arg1:KeyboardEvent):void{
if (_arg1.keyCode == Keyboard.SPACE){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
removeEventListener(Event.ENTER_FRAME, mainloop);
removeChild(title);
game = new Game(stage, this);
addChild(game);
};
}
private function contextMenuHandler(_arg1:ContextMenuEvent):void{
var _local2:String;
_local2 = "";
switch (_arg1.target){
case contextMenuItemKian:
_local2 = LINK_A;
break;
case contextMenuItemMusic:
_local2 = LINK_B;
break;
case contextMenuItemFlashbang:
_local2 = LINK_C;
break;
case contextMenuItemTIGSource:
_local2 = LINK_D;
break;
};
if (_local2 != ""){
navigateToURL(new URLRequest(_local2), "_blank");
};
}
private function mainloop(_arg1:Event):void{
var _local2:Letter;
for each (_local2 in letters) {
_local2.main();
};
}
public function gameOver(_arg1:int, _arg2:int):void{
var _local3:int;
var _local4:int;
var _local5:String;
_local3 = ((_arg2 / 60) % 60);
_local4 = (_arg2 % 60);
_local5 = ((((_local3 < 10)) ? ("0" + _local3) : _local3 + ":") + ((_local4 < 10)) ? ("0" + _local4) : _local4);
removeChild(game);
game = null;
init();
TextField(title.getChildByName("out")).text = (((((_arg1 + " fruit") + ((_arg1)!=1) ? "s" : "") + " collected in ") + _local5) + "!");
}
}
}//package
Section 95
//MiniMap (MiniMap)
package {
import flash.display.*;
import de.polygonal.math.*;
public class MiniMap extends Sprite {
private const HEIGHT:int = 150;
private const SCALE:Number = 0.1;
private const WIDTH:int = 150;
private var fruit:Fruit;
private var terrain:Terrain;
private var timer:int;
private var rawr:Rawr;
private var content:Sprite;
private var fruitLayer:Sprite;
private var random:PM_PRNG;
public function MiniMap(_arg1:Terrain, _arg2:Rawr, _arg3:Fruit){
this.terrain = _arg1;
this.rawr = _arg2;
this.fruit = _arg3;
this.random = new PM_PRNG();
init();
}
private function init():void{
var _local1:BitmapData;
var _local2:Sprite;
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
_local1 = new BitmapData(1, 2, false);
_local1.setPixel(0, 0, 3170864);
_local1.setPixel(0, 1, 9153551);
x = (((800 - WIDTH) - 15) - 2);
y = 15;
graphics.beginBitmapFill(_local1);
graphics.drawRect(0, 0, WIDTH, HEIGHT);
graphics.endFill();
content = new Sprite();
addChild(content);
_local2 = new Sprite();
_local2.graphics.beginFill(0);
_local2.graphics.drawRect(0, 0, WIDTH, HEIGHT);
_local2.graphics.endFill();
addChild(_local2);
content.mask = _local2;
fruitLayer = new Sprite();
addChild(fruitLayer);
_local2 = new Sprite();
addChild(_local2);
_local2.graphics.beginFill(9153551);
_local2.graphics.drawCircle((WIDTH / 2), (HEIGHT / 2), 4);
_local2.graphics.endFill();
_local8 = -4;
while (_local8 <= 4) {
_local9 = -2;
while (_local9 <= 6) {
random.seed = ((((_local8 + (_local9 * 1000)) + terrain.PRNG_CONSTANT) % 268435455) + 1);
_local5 = Math.sqrt((Math.pow(((_local8 + 0.5) * terrain.BUCKET_WIDTH), 2) + Math.pow((((_local9 + 0.5) * terrain.BUCKET_HEIGHT) - 1700), 2)));
_local6 = Math.max(0, Math.min(((4 + (3 * random.nextDouble())) * Math.sin(((Math.PI * 0.5) * (1 - (Math.min(_local5, 1500) / 1500))))), 7));
_local7 = 0;
while (_local7 < _local6) {
_local3 = ((((_local8 + random.nextDouble()) * terrain.BUCKET_WIDTH) + 800) * SCALE);
_local4 = ((((_local9 + random.nextDouble()) * terrain.BUCKET_HEIGHT) + 600) * SCALE);
random.nextDouble();
content.graphics.beginFill(3170864);
content.graphics.drawCircle(_local3, _local4, 8);
content.graphics.endFill();
_local7++;
};
if ((((_local8 == 0)) && ((_local9 == 0)))){
_local3 = ((400 + 800) * SCALE);
_local4 = ((400 + 600) * SCALE);
content.graphics.beginFill(3170864);
content.graphics.drawCircle(_local3, _local4, 8);
content.graphics.endFill();
};
_local9++;
};
_local8++;
};
}
public function main(_arg1:Number, _arg2:Number):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
content.x = ((-(_arg1) * SCALE) - 5);
content.y = ((-(_arg2) * SCALE) + 15);
timer++;
_local3 = ((Math.sin((timer * 0.3)) * 0.25) + 1);
_local4 = (((fruit.getX() + 800) - _arg1) * SCALE);
_local5 = (((fruit.getY() + 600) - _arg2) * SCALE);
if (_local4 < 0){
_local5 = ((HEIGHT / 2) + (((WIDTH / 2) / ((WIDTH / 2) - _local4)) * (_local5 - (HEIGHT / 2))));
_local4 = 0;
};
if (_local4 > WIDTH){
_local5 = ((HEIGHT / 2) - (((WIDTH / 2) / ((WIDTH / 2) - _local4)) * (_local5 - (HEIGHT / 2))));
_local4 = WIDTH;
};
if (_local5 < 0){
_local4 = ((WIDTH / 2) + (((HEIGHT / 2) / ((WIDTH / 2) - _local5)) * (_local4 - (WIDTH / 2))));
_local5 = 0;
};
if (_local5 > HEIGHT){
_local4 = ((WIDTH / 2) - (((HEIGHT / 2) / ((WIDTH / 2) - _local5)) * (_local4 - (WIDTH / 2))));
_local5 = HEIGHT;
};
fruitLayer.graphics.clear();
fruitLayer.graphics.beginFill(3170864);
fruitLayer.graphics.drawCircle(_local4, _local5, (6 * _local3));
fruitLayer.graphics.endFill();
fruitLayer.graphics.beginFill(9153551);
fruitLayer.graphics.drawCircle(_local4, _local5, (4 * _local3));
fruitLayer.graphics.endFill();
}
}
}//package
Section 96
//Music (Music)
package {
import flash.media.*;
import flash.net.*;
public class Music {
private const TRANSFORM_MUTE:SoundTransform;
private const SOUND_VOLUME:Number = 0.5;
private const MUSIC_VOLUME:Number = 1;
private const MUSIC_URL:String = "dreamland(echo).mp3";
private const TRANSFORM_SOUND_FX:SoundTransform;
private var music:SoundChannel;
private var engineSound:SoundChannel;
private var fruitSound:Sound;
public function Music(){
TRANSFORM_SOUND_FX = new SoundTransform(SOUND_VOLUME);
TRANSFORM_MUTE = new SoundTransform(0);
super();
music = new Sound(new URLRequest(MUSIC_URL)).play(0, int.MAX_VALUE, new SoundTransform(MUSIC_VOLUME));
engineSound = Sound(new EngineSound()).play(0, int.MAX_VALUE, TRANSFORM_MUTE);
fruitSound = new FruitSound();
}
public function fadeDown(_arg1:Number):void{
music.soundTransform = new SoundTransform((MUSIC_VOLUME * _arg1));
}
public function startEngine():void{
if (engineSound.soundTransform.volume == TRANSFORM_MUTE.volume){
engineSound.soundTransform = TRANSFORM_SOUND_FX;
};
}
public function stopEngine():void{
if (engineSound.soundTransform.volume == TRANSFORM_SOUND_FX.volume){
engineSound.soundTransform = TRANSFORM_MUTE;
};
}
public function stop():void{
engineSound.stop();
music.stop();
}
public function playFruitSound():void{
if (TRANSFORM_SOUND_FX.volume > 0){
fruitSound.play(0, 0);
};
}
}
}//package
Section 97
//Physics (Physics)
package {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.*;
import de.polygonal.motor2.math.*;
import flash.geom.*;
import de.polygonal.motor2.collision.shapes.data.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.joints.data.*;
public class Physics {
private var world:World;
private var game:Game;
private var renderObjects:Array;
public function Physics(_arg1:Game){
this.game = _arg1;
this.renderObjects = [];
world = new World(new AABB2(int.MIN_VALUE, int.MIN_VALUE, int.MAX_VALUE, int.MAX_VALUE), false);
world.setGravity(0, 100);
World.doWarmStarting = true;
}
public function createPolygon(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Array, _arg6:Number=1, _arg7:Number=0):RigidBody{
var _local8:PolyData;
_local8 = new PolyData(_arg4, _arg5);
_local8.friction = _arg6;
_local8.restitution = _arg7;
return (createBody(_local8, _arg1, _arg2, _arg3));
}
public function getRenderObjects():Array{
return (renderObjects);
}
public function removeRigidBody(_arg1:RigidBody):void{
var _local2:int;
_local2 = (renderObjects.length - 1);
while (_local2 >= 0) {
if (_arg1.shapeList == renderObjects[_local2].getShape()){
game.removePolygonRenderer(renderObjects[_local2]);
renderObjects.splice(_local2, 1);
break;
};
_local2--;
};
world.destroyBody(_arg1);
}
public function createBody(_arg1:ShapeData, _arg2:Number, _arg3:Number, _arg4:Number):RigidBody{
var _local5:RigidBodyData;
var _local6:RigidBody;
var _local7:PolygonRenderer;
_local5 = new RigidBodyData(_arg2, _arg3, _arg4);
_local5.addShapeData(_arg1);
_local6 = world.createBody(_local5);
_local7 = new PolygonRenderer(_local6.shapeList);
renderObjects.push(_local7);
game.addPolygonRenderer(_local7);
return (_local6);
}
public function createBox(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number=1, _arg7:Number=0.2, _arg8:Number=0):RigidBody{
var _local9:BoxData;
_local9 = new BoxData(_arg6, _arg4, _arg5);
_local9.friction = _arg7;
_local9.restitution = _arg8;
return (createBody(_local9, _arg1, _arg2, _arg3));
}
public function main():void{
world.step((1 / Main.FPS), 50);
}
public function createAnglularConstraint(_arg1:RigidBody, _arg2:RigidBody, _arg3:Number, _arg4:Number, _arg5:Number, _arg6:Number){
var _local7:RevoluteJointData;
_local7 = new RevoluteJointData(_arg1, _arg2, new Point(_arg3, _arg4));
_local7.collideConnected = false;
_local7.enableLimit = true;
_local7.lowerAngle = _arg5;
_local7.upperAngle = _arg6;
world.createJoint(_local7);
}
}
}//package
Section 98
//PolygonRenderer (PolygonRenderer)
package {
import flash.display.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
public class PolygonRenderer extends Sprite {
public var background:Sprite;
private var shape:ShapeSkeleton;
private var edgeColor:uint;
private var fillColor:uint;
private static const DEG_TO_RAD:Number = 57.2957795130823;
public function PolygonRenderer(_arg1:ShapeSkeleton){
this.shape = _arg1;
edgeColor = 0x333333;
fillColor = 0xFFFFFF;
background = new Sprite();
redraw();
}
public function render(_arg1:Number, _arg2:Number):void{
x = (background.x = (shape.body.x - _arg1));
y = (background.y = (shape.body.y - _arg2));
rotation = (background.rotation = (shape.body.r * DEG_TO_RAD));
}
public function getShape():ShapeSkeleton{
return (shape);
}
public function redraw():void{
var _local1:V2;
edgeColor = 3170864;
fillColor = 9153551;
graphics.clear();
graphics.lineStyle(0, fillColor);
graphics.beginFill(fillColor);
background.graphics.clear();
background.graphics.lineStyle(8, edgeColor);
background.graphics.beginFill(edgeColor);
_local1 = shape.modelVertexChain;
graphics.moveTo(_local1.x, _local1.y);
background.graphics.moveTo(_local1.x, _local1.y);
while (true) {
graphics.lineTo(_local1.x, _local1.y);
background.graphics.lineTo(_local1.x, _local1.y);
if (_local1.last){
graphics.lineTo(_local1.next.x, _local1.next.y);
background.graphics.lineTo(_local1.next.x, _local1.next.y);
break;
};
_local1 = _local1.next;
};
graphics.endFill();
background.graphics.endFill();
}
}
}//package
Section 99
//Rawr (Rawr)
package {
import flash.display.*;
import flash.events.*;
import de.polygonal.motor2.dynamics.*;
import flash.ui.*;
public class Rawr {
private const RAD_TO_DEG:Number;
private var fanAngle:Number;
private var frontleg1:RigidBody;
private var frontleg2:RigidBody;
private var fan:Sprite;
private var body:RigidBody;
private var music:Music;
private var neck1:RigidBody;
private var neck2:RigidBody;
private var neck3:RigidBody;
private var fuel:Fuel;
private var helmetFront:Sprite;
private var physics:Physics;
private var backleg1:RigidBody;
private var backleg2:RigidBody;
private var parts:Array;
private var tail1:RigidBody;
private var tail2:RigidBody;
private var tail3:RigidBody;
private var gapFiller:Sprite;
private var head:RigidBody;
private var tail4:RigidBody;
private var game:Game;
private var helmetBack:Sprite;
private var keyState:Array;
public function Rawr(_arg1:Game, _arg2:Physics, _arg3:Fuel, _arg4:Music, _arg5:Sprite, _arg6:Sprite){
var _local7:String;
RAD_TO_DEG = (180 / Math.PI);
super();
this.game = _arg1;
this.physics = _arg2;
this.fuel = _arg3;
this.music = _arg4;
gapFiller = new Sprite();
fan = new Fan();
fanAngle = 0;
helmetFront = new HelmetFront();
helmetBack = new HelmetBack();
keyState = new Array(300);
for (_local7 in keyState) {
keyState[int(_local7)] = false;
};
body = _arg2.createPolygon(0, 0, 0, 400, [359, 290, 381, 273, 407, 271, 435, 284, 435, 304, 418, 313, 374, 313]);
neck1 = _arg2.createPolygon(0, 0, 0, 100, [435, 284, 457, 281, 462, 296, 435, 304]);
neck2 = _arg2.createPolygon(0, 0, 0, 100, [457, 281, 472, 269, 481, 277, 462, 296]);
neck3 = _arg2.createPolygon(0, 0, 0, 100, [472, 269, 488, 0x0101, 494, 269, 481, 277]);
head = _arg2.createPolygon(0, 0, 0, 150, [488, 0x0101, 495, 250, 503, 250, 509, 0x0101, 509, 268, 494, 269]);
tail1 = _arg2.createPolygon(0, 0, 0, 150, [359, 290, 374, 313, 358, 313, 350, 306]);
tail2 = _arg2.createPolygon(0, 0, 0, 175, [338, 323, 350, 306, 358, 313, 344, 331]);
tail3 = _arg2.createPolygon(0, 0, 0, 300, [320, 332, 338, 323, 344, 331, 320, 342]);
tail4 = _arg2.createPolygon(0, 0, 0, 325, [289, 342, 320, 332, 320, 342]);
backleg1 = _arg2.createPolygon(0, 0, 0, 100, [374, 313, 392, 313, 392, 325, 376, 325]);
backleg2 = _arg2.createPolygon(0, 0, 0, 100, [376, 325, 392, 325, 392, 338, 378, 338]);
frontleg1 = _arg2.createPolygon(0, 0, 0, 100, [418, 313, 435, 304, 432, 325, 418, 326]);
frontleg2 = _arg2.createPolygon(0, 0, 0, 100, [418, 326, 432, 325, 430, 339, 418, 339]);
parts = [];
parts.push(new RigidBodyBackup(body));
parts.push(new RigidBodyBackup(neck1));
parts.push(new RigidBodyBackup(neck2));
parts.push(new RigidBodyBackup(neck3));
parts.push(new RigidBodyBackup(head));
parts.push(new RigidBodyBackup(tail1));
parts.push(new RigidBodyBackup(tail2));
parts.push(new RigidBodyBackup(tail3));
parts.push(new RigidBodyBackup(tail4));
parts.push(new RigidBodyBackup(backleg1));
parts.push(new RigidBodyBackup(backleg2));
parts.push(new RigidBodyBackup(frontleg1));
parts.push(new RigidBodyBackup(frontleg2));
_arg2.createAnglularConstraint(body, neck1, 435, 294, (-(Math.PI) / 3), (Math.PI / 3));
_arg2.createAnglularConstraint(neck1, neck2, 459, 288, (-(Math.PI) / 3), (Math.PI / 3));
_arg2.createAnglularConstraint(neck2, neck3, 476, 273, (-(Math.PI) / 3), (Math.PI / 3));
_arg2.createAnglularConstraint(neck3, head, 491, 263, (-(Math.PI) / 3), (Math.PI / 3));
_arg2.createAnglularConstraint(body, tail1, 367, 301, (-(Math.PI) / 3), (Math.PI / 3));
_arg2.createAnglularConstraint(tail1, tail2, 354, 309, (-(Math.PI) / 3), (Math.PI / 3));
_arg2.createAnglularConstraint(tail2, tail3, 341, 327, (-(Math.PI) / 3), (Math.PI / 3));
_arg2.createAnglularConstraint(tail3, tail4, 320, 337, (-(Math.PI) / 3), (Math.PI / 3));
_arg2.createAnglularConstraint(body, backleg1, 383, 313, (-(Math.PI) / 3), (Math.PI / 3));
_arg2.createAnglularConstraint(backleg1, backleg2, 384, 325, (-(Math.PI) / 3), (Math.PI / 3));
_arg2.createAnglularConstraint(body, frontleg1, 426, 309, (-(Math.PI) / 3), (Math.PI / 3));
_arg2.createAnglularConstraint(frontleg1, frontleg2, 425, 325, (-(Math.PI) / 3), (Math.PI / 3));
_arg6.addChild(helmetFront);
_arg5.addChild(helmetBack);
_arg6.addChild(gapFiller);
}
public function getBody():RigidBody{
return (body);
}
public function resetPosition():void{
var _local1:RigidBodyBackup;
for each (_local1 in parts) {
_local1.reset();
};
fanAngle = 0;
}
public function fillGaps(_arg1:Number, _arg2:Number):void{
}
public function main(_arg1:Number, _arg2:Number):void{
var _local3:Number;
var _local4:Number;
fan.x = (body.x - _arg1);
fan.y = (body.y - _arg2);
fan.rotation = (body.r * RAD_TO_DEG);
fan.getChildByName("rotate").rotation = (fanAngle * RAD_TO_DEG);
helmetFront.x = (helmetBack.x = (head.x - _arg1));
helmetFront.y = (helmetBack.y = (head.y - _arg2));
helmetFront.rotation = (helmetBack.rotation = (head.r * RAD_TO_DEG));
_local3 = (body.r % (Math.PI * 2));
if (_local3 < Math.PI){
body.r = (body.r + ((0 - _local3) * 0.05));
} else {
body.r = (body.r + (((Math.PI * 2) - _local3) * 0.05));
};
if (keyState[Keyboard.UP]){
if (fuel.getValue() > 0){
_local4 = ((body.r + fanAngle) - (Math.PI * 0.5));
body.vx = (body.vx + (Math.cos(_local4) * 20));
body.vy = (body.vy + (Math.sin(_local4) * 20));
fuel.minus(0.015);
music.startEngine();
game.addSmoke((body.x - (Math.cos(_local4) * 10)), (body.y - (Math.sin(_local4) * 10)), (-(Math.cos(_local4)) * 5), (-(Math.sin(_local4)) * 5));
} else {
music.stopEngine();
};
} else {
fuel.plus(0.006);
music.stopEngine();
};
if (keyState[Keyboard.LEFT]){
fanAngle = (fanAngle - 0.2);
};
if (keyState[Keyboard.RIGHT]){
fanAngle = (fanAngle + 0.2);
};
}
public function getFan():Sprite{
return (fan);
}
public function keyHandler(_arg1:KeyboardEvent):void{
keyState[_arg1.keyCode] = Boolean((_arg1.type == KeyboardEvent.KEY_DOWN));
}
}
}//package
Section 100
//RigidBodyBackup (RigidBodyBackup)
package {
import de.polygonal.motor2.dynamics.*;
public class RigidBodyBackup {
private var rb:RigidBody;
private var r:Number;
private var x:Number;
private var y:Number;
public function RigidBodyBackup(_arg1:RigidBody){
this.rb = _arg1;
x = _arg1.x;
y = _arg1.y;
r = _arg1.r;
}
public function reset():void{
rb.setCenter(x, y, r);
rb.vx = (rb.vy = 0);
rb.t = 0;
}
}
}//package
Section 101
//Smoke (Smoke)
package {
import flash.display.*;
public class Smoke {
private var vx:Number;
private var vy:Number;
private var smokeFill:MovieClip;
private var outlines:Sprite;
private var smokeOutline:MovieClip;
private var fills:Sprite;
private var x:Number;
private var y:Number;
private var life:int;
public function Smoke(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Sprite, _arg6:Sprite){
var _local7:uint;
super();
this.x = _arg1;
this.y = _arg2;
this.vx = _arg3;
this.vy = _arg4;
this.outlines = _arg5;
this.fills = _arg6;
this.life = 50;
smokeFill = new SmokeFill();
smokeOutline = new SmokeOutline();
_local7 = ((Math.random() * smokeFill.totalFrames) + 1);
smokeFill.gotoAndStop(_local7);
smokeOutline.gotoAndStop(_local7);
smokeFill.rotation = (smokeOutline.rotation = (Math.random() * 360));
smokeFill.x = (smokeOutline.x = -999);
_arg6.addChild(smokeFill);
_arg5.addChild(smokeOutline);
}
public function main(_arg1:Number, _arg2:Number):void{
if (life > 0){
life--;
if (life == 0){
fills.removeChild(smokeFill);
outlines.removeChild(smokeOutline);
} else {
x = (x + vx);
y = (y + vy);
smokeFill.x = (smokeOutline.x = (x - _arg1));
smokeFill.y = (smokeOutline.y = (y - _arg2));
smokeFill.scaleX = (smokeFill.scaleY = (((life / 50) * 0.75) + 0.25));
smokeOutline.scaleX = (smokeOutline.scaleY = (((life / 50) * 0.5) + 0.5));
};
};
}
public function remove():Boolean{
return ((life == 0));
}
}
}//package
Section 102
//SmokeFill (SmokeFill)
package {
import flash.display.*;
public dynamic class SmokeFill extends MovieClip {
}
}//package
Section 103
//SmokeOutline (SmokeOutline)
package {
import flash.display.*;
public dynamic class SmokeOutline extends MovieClip {
}
}//package
Section 104
//Terrain (Terrain)
package {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.math.*;
public class Terrain {
public const BUCKET_WIDTH:uint = 400;
public const BUCKET_HEIGHT:uint = 500;
public const PRNG_CONSTANT:int;
private var random:PM_PRNG;
private var boxUnused:Array;
private var circleUnused:Array;
private var triangleBucket:Array;
private var boxBucket:Array;
private var physics:Physics;
private var circleBucket:Array;
private var screenX:int;
private var screenY:int;
private var triangleUnused:Array;
public function Terrain(_arg1:Physics){
PRNG_CONSTANT = (Math.random() * 0xFFFFFF);
super();
this.physics = _arg1;
this.random = new PM_PRNG();
screenX = (screenY = int.MAX_VALUE);
init();
}
private function clear(_arg1:Array, _arg2:Array):void{
var _local3:RigidBody;
for each (_local3 in _arg1) {
_local3.setCenter(99999, 0, 0);
_arg2.push(_local3);
};
_arg1.length = 0;
}
private function init():void{
var _local1:int;
boxBucket = [];
boxUnused = [];
triangleBucket = [];
triangleUnused = [];
circleBucket = [];
circleUnused = [];
_local1 = 0;
while (_local1 < 40) {
boxUnused.push(physics.createBox(99999, 0, 0, 200, 100, 0, 1));
triangleUnused.push(physics.createPolygon(99999, 0, 0, 0, [-140, 0, 140, 0, 0, 100], 1));
circleUnused.push(physics.createPolygon(99999, 0, 0, 0, [120, 0, 84.85, 84.85, 0, 120, -84.85, 84.85, -120, 0], 1));
_local1++;
};
}
private function getUnusedBody(_arg1:uint):RigidBody{
var _local2:RigidBody;
var _local3:Array;
var _local4:Array;
switch ((_arg1 % 3)){
case 0:
_local3 = boxUnused;
_local4 = boxBucket;
break;
case 1:
_local3 = triangleUnused;
_local4 = triangleBucket;
break;
case 2:
_local3 = circleUnused;
_local4 = circleBucket;
break;
default:
throw (new Error("Wrong type"));
};
if (_local3.length == 0){
throw (new Error((((((((("There are no unused rigid bodies (Type " + _arg1) + ", [") + boxUnused.length) + ",") + triangleUnused.length) + ",") + circleUnused.length) + "])")));
};
_local2 = RigidBody(_local3.pop());
_local4.push(_local2);
return (_local2);
}
private function generateSquare(_arg1:int, _arg2:int):void{
var _local3:RigidBody;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:uint;
var _local8:Number;
var _local9:int;
var _local10:int;
random.seed = ((((_arg1 + (_arg2 * 1000)) + PRNG_CONSTANT) % 268435455) + 1);
_local8 = Math.sqrt((Math.pow(((_arg1 + 0.5) * BUCKET_WIDTH), 2) + Math.pow((((_arg2 + 0.5) * BUCKET_HEIGHT) - 1700), 2)));
_local9 = Math.max(0, Math.min(((4 + (3 * random.nextDouble())) * Math.sin(((Math.PI * 0.5) * (1 - (Math.min(_local8, 1500) / 1500))))), 7));
_local10 = 0;
while (_local10 < _local9) {
var _temp1 = _local7;
_local7 = (_local7 + 1);
_local3 = getUnusedBody((_temp1 % 3));
_local4 = ((_arg1 + random.nextDouble()) * BUCKET_WIDTH);
_local5 = ((_arg2 + random.nextDouble()) * BUCKET_HEIGHT);
_local6 = (((random.nextDouble() - 0.5) * Math.PI) * 0.25);
_local3.setCenter(_local4, _local5, _local6);
_local10++;
};
if ((((_arg1 == 0)) && ((_arg2 == 0)))){
getUnusedBody(2).setCenter(400, 400, -0.04);
};
}
public function main(_arg1:Number, _arg2:Number):void{
var _local3:int;
var _local4:int;
var _local5:int;
var _local6:int;
_arg1 = (_arg1 - 150);
_arg2 = (_arg2 - 150);
_local3 = (int((_arg1 / BUCKET_WIDTH)) + ((_arg1 < 0)) ? -1 : 0);
_local4 = (int((_arg2 / BUCKET_HEIGHT)) + ((_arg2 < 0)) ? -1 : 0);
if (((!((screenX == _local3))) || (!((screenY == _local4))))){
screenX = _local3;
screenY = _local4;
clear(boxBucket, boxUnused);
clear(triangleBucket, triangleUnused);
clear(circleBucket, circleUnused);
_local5 = 0;
while (_local5 < 4) {
_local6 = 0;
while (_local6 < 3) {
generateSquare((_local3 + _local5), (_local4 + _local6));
_local6++;
};
_local5++;
};
};
}
}
}//package
Section 105
//Timer (Timer)
package {
import flash.display.*;
import flash.text.*;
public class Timer extends Sprite {
private var totalTime:int;
private var fruitsCollected:int;
private var time:int;
private var textfield:TextField;
private var game:Game;
public function Timer(_arg1:Game){
var _local2:TextFormat;
super();
this.game = _arg1;
time = (((1 * 60) + 30) * Main.FPS);
textfield = new TextField();
textfield.width = 200;
textfield.selectable = (textfield.tabEnabled = false);
textfield.x = (400 - (textfield.width / 2));
textfield.y = 15;
_local2 = new TextFormat("Gimenells", 40, 3170864);
_local2.align = "center";
textfield.defaultTextFormat = _local2;
addChild(textfield);
}
public function getTotalTime():int{
return ((totalTime / Main.FPS));
}
public function main():void{
var _local1:int;
var _local2:int;
time--;
totalTime++;
_local1 = (((Math.max(0, time) / Main.FPS) / 60) % 60);
_local2 = ((Math.max(0, time) / Main.FPS) % 60);
textfield.text = ((((_local1 < 10)) ? ("0" + _local1) : _local1 + ":") + ((_local2 < 10)) ? ("0" + _local2) : _local2);
if (time == 0){
game.gameOver();
};
if (time < 0){
textfield.visible = Boolean(((int((-(time) * 0.1)) % 2) == 0));
};
}
public function gotFruit():void{
time = (time + (15 * Main.FPS));
fruitsCollected++;
}
}
}//package
Section 106
//Title (Title)
package {
import flash.display.*;
import flash.text.*;
public dynamic class Title extends Sprite {
public var b10:MovieClip;
public var a6:MovieClip;
public var a8:MovieClip;
public var b0:MovieClip;
public var b2:MovieClip;
public var b4:MovieClip;
public var b5:MovieClip;
public var b11:MovieClip;
public var b6:MovieClip;
public var b1:MovieClip;
public var b3:MovieClip;
public var a5:MovieClip;
public var b8:MovieClip;
public var b12:MovieClip;
public var a11:MovieClip;
public var a13:MovieClip;
public var b9:MovieClip;
public var a12:MovieClip;
public var b7:MovieClip;
public var out:TextField;
public var a10:MovieClip;
public var b13:MovieClip;
public var a0:MovieClip;
public var a2:MovieClip;
public var a1:MovieClip;
public var a3:MovieClip;
public var a4:MovieClip;
public var a7:MovieClip;
public var a9:MovieClip;
}
}//package