Section 1
//AbstractMain (com.kerb.game.AbstractMain)
package com.kerb.game {
import flash.display.*;
import flash.events.*;
public class AbstractMain extends Sprite {
protected var PreviousSectionClass:Class;
protected var currentSection:AbstractSection;
protected var overlaySprite:Sprite;
protected var contentSprite:Sprite;
public function AbstractMain(){
contentSprite = new Sprite();
addChild(contentSprite);
overlaySprite = new Sprite();
overlaySprite.mouseEnabled = false;
addChild(overlaySprite);
}
protected function gotoSection(_arg1:Class):void{
disposeCurrentSection();
currentSection = new (_arg1);
currentSection.setPreviousSection(PreviousSectionClass);
currentSection.addEventListener(Event.COMPLETE, onSectionComplete);
contentSprite.addChild(currentSection);
PreviousSectionClass = _arg1;
}
protected function disposeCurrentSection():void{
if (currentSection != null){
currentSection.removeEventListener(Event.COMPLETE, onSectionComplete);
currentSection.dispose();
contentSprite.removeChild(currentSection);
};
}
protected function onIdentClick(_arg1:MouseEvent):void{
}
protected function onIdentComplete(_arg1:Event):void{
currentSection.removeEventListener(MouseEvent.CLICK, onIdentClick);
onSectionComplete(_arg1);
}
protected function showIdent(_arg1:MovieClip, _arg2:Class):void{
disposeCurrentSection();
currentSection = new Ident(_arg1, _arg2);
currentSection.addEventListener(Event.COMPLETE, onIdentComplete);
currentSection.addEventListener(MouseEvent.CLICK, onIdentClick);
currentSection.buttonMode = true;
contentSprite.addChild(currentSection);
}
protected function onSectionComplete(_arg1:Event):void{
gotoSection(currentSection.getNextSection());
}
}
}//package com.kerb.game
Section 2
//AbstractPreload (com.kerb.game.AbstractPreload)
package com.kerb.game {
import flash.events.*;
import flash.display.*;
import flash.ui.*;
import flash.utils.*;
import flash.net.*;
public class AbstractPreload extends MovieClip {
protected var lowQualityItem:ContextMenuItem;
protected var url:String;
protected var highQualityItem:ContextMenuItem;
protected var mediumQualityItem:ContextMenuItem;
public static const KERB_SITE_URL:String = "http://www.kerb.co.uk";
public static const DOWNLOAD_THIS_GAME_URL:String = "http://blog.kerb.co.uk/download.php?url=";
public static const KERB_GAMES_URL:String = "http://www.kerbgames.com";
public function AbstractPreload(){
initStage();
initContextMenu();
}
protected function initContextMenu():void{
var _local1:ContextMenuItem;
contextMenu = new ContextMenu();
contextMenu.hideBuiltInItems();
url = loaderInfo.url;
_local1 = new ContextMenuItem("Built by Kerb!", false);
_local1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onKerbMenuItemSelect);
contextMenu.customItems.push(_local1);
_local1 = new ContextMenuItem("Download This Game", true);
_local1.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, onDownloadMenuItemSelect);
contextMenu.customItems.push(_local1);
}
protected function onKerbMenuItemSelect(_arg1:Event):void{
navigateToURL(new URLRequest(KERB_SITE_URL), "_blank");
}
protected function initStage():void{
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.stageFocusRect = false;
}
protected function onDownloadMenuItemSelect(_arg1:Event):void{
navigateToURL(new URLRequest((DOWNLOAD_THIS_GAME_URL + url)), "_blank");
}
protected function initMainContent(_arg1:String):void{
var _local2:Class = Class(getDefinitionByName(_arg1));
if (_local2){
addChild((new (_local2) as DisplayObject));
};
}
protected function onQualityMenuItemSelect(_arg1:Event):void{
lowQualityItem.caption = "Low Quality (fast)";
mediumQualityItem.caption = "Medium Quality";
highQualityItem.caption = "High Quality (slow)";
switch (_arg1.currentTarget){
case lowQualityItem:
lowQualityItem.caption = ("• " + lowQualityItem.caption);
stage.quality = StageQuality.LOW;
break;
case mediumQualityItem:
mediumQualityItem.caption = ("• " + mediumQualityItem.caption);
stage.quality = StageQuality.MEDIUM;
break;
case highQualityItem:
highQualityItem.caption = ("• " + highQualityItem.caption);
stage.quality = StageQuality.HIGH;
break;
};
}
}
}//package com.kerb.game
Section 3
//AbstractSection (com.kerb.game.AbstractSection)
package com.kerb.game {
import flash.display.*;
import flash.events.*;
import com.kerb.utils.*;
public class AbstractSection extends MovieClip implements IDisposable {
protected var NextSectionClass:Class;
protected var PreviousSectionClass:Class;
protected var keyboardNavigator:KeyboardNavigator;
public function AbstractSection(){
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
protected function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
keyboardNavigator = new KeyboardNavigator(stage);
init();
}
public function setPreviousSection(_arg1:Class):void{
this.PreviousSectionClass = _arg1;
}
public function dispose():void{
keyboardNavigator.dispose();
}
protected function gotoNextSection():void{
dispatchEvent(new Event(Event.COMPLETE));
}
protected function init():void{
}
public function getNextSection():Class{
return (NextSectionClass);
}
}
}//package com.kerb.game
Section 4
//Ident (com.kerb.game.Ident)
package com.kerb.game {
import flash.display.*;
import flash.events.*;
public class Ident extends AbstractSection {
protected var mc:MovieClip;
public function Ident(_arg1:MovieClip, _arg2:Class){
this.mc = _arg1;
this.NextSectionClass = _arg2;
}
override protected function init():void{
mc.x = (0.5 * stage.stageWidth);
mc.y = (0.5 * stage.stageHeight);
addChild(mc);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
protected function onEnterFrame(_arg1:Event):void{
if (mc.currentFrame == mc.totalFrames){
mc.stop();
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
dispatchEvent(new Event(Event.COMPLETE));
};
}
override public function dispose():void{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
}//package com.kerb.game
Section 5
//KeyboardNavigator (com.kerb.game.KeyboardNavigator)
package com.kerb.game {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import flash.ui.*;
public class KeyboardNavigator {
private var stage:Stage;
private var tabIndexes:Array;
private var keyListenerSet:Boolean;
private var controllableItems:Dictionary;
private var defaultAction:Function;
public function KeyboardNavigator(_arg1:Stage){
this.stage = _arg1;
init();
}
public function addInteractiveObject(_arg1:InteractiveObject, _arg2:Function, _arg3:int=-1):void{
controllableItems[_arg1] = _arg2;
if (_arg3 > -1){
tabIndexes[_arg3] = _arg1;
_arg1.tabEnabled = true;
};
_arg1.tabIndex = _arg3;
active = true;
}
protected function onKeyDown(_arg1:KeyboardEvent):void{
var _local2:Function;
var _local3:int;
var _local4:InteractiveObject;
if ((((_arg1.keyCode == Keyboard.ENTER)) || ((_arg1.keyCode == Keyboard.SPACE)))){
_local2 = controllableItems[stage.focus];
if (_local2 == null){
defaultAction();
} else {
_local2();
};
} else {
_local3 = -1;
_local4 = null;
if ((((stage.focus is InteractiveObject)) && (!((stage.focus == stage))))){
_local3 = (stage.focus as InteractiveObject).tabIndex;
};
if (_local3 == -1){
} else {
if (_arg1.keyCode == Keyboard.LEFT){
_local4 = getNextLowestTabIndex(_local3);
if (_local4 == null){
_local4 = getHighestTabIndex();
};
} else {
if (_arg1.keyCode == Keyboard.RIGHT){
_local4 = getNextHighestTabIndex(_local3);
if (_local4 == null){
_local4 = getLowestTabIndex();
};
};
};
};
if (_local4){
stage.focus = _local4;
};
};
}
public function setDefaultAction(_arg1:Function):void{
this.defaultAction = _arg1;
active = true;
}
public function get active():Boolean{
return (keyListenerSet);
}
protected function getNextLowestTabIndex(_arg1:int):InteractiveObject{
var _local2:InteractiveObject;
var _local3:int = tabIndexes.length;
var _local4:int = (_arg1 - 1);
while (_local4 >= 0) {
if (tabIndexes[_local4] != undefined){
_local2 = tabIndexes[_local4];
break;
};
_local4--;
};
return (_local2);
}
public function set active(_arg1:Boolean):void{
if (((keyListenerSet) && (!(_arg1)))){
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
keyListenerSet = false;
} else {
if (((!(keyListenerSet)) && (_arg1))){
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
keyListenerSet = true;
};
};
}
protected function init():void{
controllableItems = new Dictionary();
tabIndexes = new Array();
defaultAction = new Function();
stage.focus = stage;
keyListenerSet = false;
}
protected function getHighestTabIndex():InteractiveObject{
var _local1:InteractiveObject;
var _local2:int = (tabIndexes.length - 1);
while (_local2 >= 0) {
if (tabIndexes[_local2] != undefined){
_local1 = tabIndexes[_local2];
break;
};
_local2--;
};
return (_local1);
}
protected function getLowestTabIndex():InteractiveObject{
var _local1:InteractiveObject;
var _local2:int = tabIndexes.length;
var _local3:int;
while (_local3 < _local2) {
if (tabIndexes[_local3] != undefined){
_local1 = tabIndexes[_local3];
break;
};
_local3++;
};
return (_local1);
}
protected function getNextHighestTabIndex(_arg1:int):InteractiveObject{
var _local2:InteractiveObject;
var _local3:int = tabIndexes.length;
var _local4:int = (_arg1 + 1);
while (_local4 < _local3) {
if (tabIndexes[_local4] != undefined){
_local2 = tabIndexes[_local4];
break;
};
_local4++;
};
return (_local2);
}
public function dispose():void{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
controllableItems = null;
tabIndexes = null;
defaultAction = null;
}
}
}//package com.kerb.game
Section 6
//KerbLog (com.kerb.logger.KerbLog)
package com.kerb.logger {
import flash.display.*;
import flash.events.*;
public final class KerbLog extends EventDispatcher {
private var _view:KerbLogView;
private var _level:KerbLogLevel;
private var _entries:Array;
private static const MAX_ENTRIES:uint = 100;
private static var _allow:Boolean = false;
private static var _instance:KerbLog = null;
public function KerbLog(){
if (!_allow){
throw (new Error("direct instantiation of uk.kerb.utils.logger.Log is forbidden"));
};
_entries = new Array();
_level = KerbLogLevel.Info;
_view = new KerbLogView(this);
}
public function set stage(_arg1:Stage):void{
_view.stage = _arg1;
}
private function _add(_arg1:String):void{
_entries.push(new KerbLogEntry(_arg1));
if (_entries.length > MAX_ENTRIES){
_entries.shift();
};
}
public function fatal(_arg1:String):void{
_add(_arg1);
if ((((((_level == KerbLogLevel.Fatal)) || ((_level == KerbLogLevel.Info)))) || ((_level == KerbLogLevel.Debug)))){
_dispatch();
};
}
public function info(_arg1:String):void{
_add(_arg1);
if ((((_level == KerbLogLevel.Info)) || ((_level == KerbLogLevel.Debug)))){
_dispatch();
};
}
public function set level(_arg1:KerbLogLevel):void{
_level = _arg1;
}
private function _dispatch():void{
dispatchEvent(new KerbLogEvent(_entries[(_entries.length - 1)]));
}
public function debug(_arg1:String):void{
_add(_arg1);
if (_level == KerbLogLevel.Debug){
_dispatch();
};
}
public function get level():KerbLogLevel{
return (_level);
}
public static function instance():KerbLog{
if (_instance == null){
_allow = true;
_instance = new (KerbLog);
_allow = false;
};
return (_instance);
}
}
}//package com.kerb.logger
Section 7
//KerbLogEntry (com.kerb.logger.KerbLogEntry)
package com.kerb.logger {
final class KerbLogEntry {
private var _message:String;
private var _date:Date;
function KerbLogEntry(_arg1:String){
_message = _arg1;
_date = new Date();
}
public function get message():String{
return (_message);
}
public function get date():Date{
return (_date);
}
}
}//package com.kerb.logger
Section 8
//KerbLogEvent (com.kerb.logger.KerbLogEvent)
package com.kerb.logger {
import flash.events.*;
final class KerbLogEvent extends Event {
private var _logEntry:KerbLogEntry;
public static const TYPE:String = "onLogEntry";
function KerbLogEvent(_arg1:KerbLogEntry){
super(TYPE);
_logEntry = _arg1;
}
public function get logEntry():KerbLogEntry{
return (_logEntry);
}
}
}//package com.kerb.logger
Section 9
//KerbLogLevel (com.kerb.logger.KerbLogLevel)
package com.kerb.logger {
public final class KerbLogLevel {
public static const Debug:KerbLogLevel = new (KerbLogLevel);
;
public static const Fatal:KerbLogLevel = new (KerbLogLevel);
;
public static const Info:KerbLogLevel = new (KerbLogLevel);
;
public static const None:KerbLogLevel = new (KerbLogLevel);
;
}
}//package com.kerb.logger
Section 10
//KerbLogView (com.kerb.logger.KerbLogView)
package com.kerb.logger {
import flash.display.*;
import flash.events.*;
import com.kerb.logger.*;
import flash.utils.*;
import flash.text.*;
import flash.ui.*;
import flash.system.*;
final class KerbLogView {
private var _container:Sprite;
private var _log:KerbLog;
private var _timer:Timer;// = null
private var _dragBar:Sprite;
private var _closeButton:Sprite;
private var _textField:TextField;
private var _frames:uint;// = 0
private var _minimized:Boolean;// = false
private var _clearButton:Sprite;
private var _minButton:Sprite;
private var _copyButton:Sprite;
private var _fps:TextField;
private var _greyBox:Sprite;
private var _stage:Stage;
private static const HEIGHT:uint = 100;
private static const DRAG_BAR_HEIGHT:uint = 10;
private static const COLOUR_BLUE:uint = 0xFF;
private static const MARGIN:uint = 5;
private static const COLOUR_GREEN:uint = 0x66CC00;
private static const COLOUR_GREY:uint = 0x999999;
private static const BUTTON_LENGTH:uint = 10;
private static const DISPLAY_FONT_SIZE:uint = 11;
private static const COLOUR_WHITE:uint = 0xFFFFFF;
private static const COLOUR_RED:uint = 0xFF0000;
private static const DISPLAY_FONT_COLOUR:uint = 0xFFFFFF;
function KerbLogView(_arg1:KerbLog){
_log = _arg1;
_log.addEventListener(KerbLogEvent.TYPE, _eventHandler);
_timer = new Timer(1000);
_timer.addEventListener(TimerEvent.TIMER, _onTimer);
}
private function _onCloseButtonClick(_arg1:MouseEvent):void{
_container.visible = false;
}
private function _createMinButton():void{
_minButton = new Sprite();
_minButton.x = ((_container.width - (2.5 * BUTTON_LENGTH)) - MARGIN);
_minButton.y = MARGIN;
_minButton.graphics.beginFill(COLOUR_RED);
_minButton.graphics.lineStyle(0, COLOUR_WHITE);
_minButton.graphics.drawRect(0, 0, BUTTON_LENGTH, BUTTON_LENGTH);
_minButton.graphics.endFill();
_minButton.graphics.moveTo(0, (BUTTON_LENGTH / 2));
_minButton.graphics.lineTo(BUTTON_LENGTH, (BUTTON_LENGTH / 2));
_minButton.buttonMode = true;
_minButton.addEventListener(MouseEvent.CLICK, _onMinButtonClick, false, 0, true);
_container.addChild(_minButton);
}
private function _createGraphics():void{
if (_container == null){
_createContainer();
_createDragBar();
_createFPSTextField();
_createCloseButton();
_createMinButton();
_createClearButton();
_createCopyButton();
_createTextField();
_container.addEventListener(MouseEvent.MOUSE_OVER, _onMouseOver);
_timer.start();
_container.addEventListener(Event.ENTER_FRAME, _onEnterFrame);
} else {
if (!_container.visible){
_container.visible = true;
};
};
}
private function _onDragBarMouseUp(_arg1:MouseEvent):void{
_container.removeEventListener(MouseEvent.MOUSE_MOVE, _onContainerMouseMove);
_container.stopDrag();
}
private function _onDragBarMouseDown(_arg1:MouseEvent):void{
_container.addEventListener(MouseEvent.MOUSE_MOVE, _onContainerMouseMove);
_container.startDrag();
}
private function _onEnterFrame(_arg1:Event):void{
_frames++;
}
private function _onCopyButtonClick(_arg1:MouseEvent):void{
System.setClipboard(_textField.text);
}
private function _createCopyButton():void{
_copyButton = new Sprite();
_copyButton.x = ((_container.width - (5.5 * BUTTON_LENGTH)) - MARGIN);
_copyButton.y = MARGIN;
_copyButton.graphics.beginFill(COLOUR_GREEN);
_copyButton.graphics.lineStyle(0, COLOUR_WHITE);
_copyButton.graphics.drawRect(0, 0, BUTTON_LENGTH, BUTTON_LENGTH);
_copyButton.graphics.endFill();
_copyButton.buttonMode = true;
_copyButton.addEventListener(MouseEvent.CLICK, _onCopyButtonClick, false, 0, true);
_container.addChild(_copyButton);
}
private function _onTimer(_arg1:TimerEvent):void{
_fps.text = (String(_frames) + " fps");
_frames = 0;
}
private function _onMinButtonClick(_arg1:MouseEvent):void{
_doMinButtonClick();
}
private function _createDragBar():void{
_dragBar = new Sprite();
_dragBar.x = 0;
_dragBar.y = 0;
_dragBar.graphics.beginFill(COLOUR_BLUE);
_dragBar.graphics.lineStyle(0, COLOUR_WHITE, 0);
_dragBar.graphics.drawRect(0, 0, _container.width, (2 * BUTTON_LENGTH));
_dragBar.graphics.endFill();
_dragBar.buttonMode = true;
_dragBar.addEventListener(MouseEvent.MOUSE_DOWN, _onDragBarMouseDown, false, 0, true);
_dragBar.addEventListener(MouseEvent.MOUSE_UP, _onDragBarMouseUp, false, 0, true);
_container.addChild(_dragBar);
}
private function _createFPSTextField():void{
_fps = new TextField();
_fps.x = MARGIN;
_fps.y = 1;
_fps.width = 100;
_fps.height = 30;
_fps.autoSize = TextFieldAutoSize.NONE;
_fps.embedFonts = false;
_fps.antiAliasType = AntiAliasType.NORMAL;
_fps.wordWrap = true;
_fps.selectable = false;
_fps.mouseEnabled = false;
_fps.defaultTextFormat = new TextFormat("_typewriter", DISPLAY_FONT_SIZE, DISPLAY_FONT_COLOUR);
_container.addChild(_fps);
}
private function _eventHandler(_arg1:KerbLogEvent):void{
var _local2:String;
_createGraphics();
if (_textField != null){
_local2 = ((timeTo24HourString(_arg1.logEntry.date) + ": ") + _arg1.logEntry.message);
_textField.appendText((_local2 + "\n"));
trace(_local2);
_textField.scrollV = _textField.maxScrollV;
};
}
private function _doMinButtonClick():void{
_minimized = !(_minimized);
_greyBox.visible = !(_minimized);
_textField.visible = !(_minimized);
_container.y = ((_stage.stageHeight - (_minimized) ? (2 * BUTTON_LENGTH) : HEIGHT) - MARGIN);
}
private function _createClearButton():void{
_clearButton = new Sprite();
_clearButton.x = ((_container.width - (4 * BUTTON_LENGTH)) - MARGIN);
_clearButton.y = MARGIN;
_clearButton.graphics.beginFill(COLOUR_GREY);
_clearButton.graphics.lineStyle(0, COLOUR_WHITE);
_clearButton.graphics.drawRect(0, 0, BUTTON_LENGTH, BUTTON_LENGTH);
_clearButton.graphics.endFill();
_clearButton.buttonMode = true;
_clearButton.addEventListener(MouseEvent.CLICK, _onClearButtonClick, false, 0, true);
_container.addChild(_clearButton);
}
private function _createTextField():void{
_textField = new TextField();
_textField.x = MARGIN;
_textField.y = ((2 * BUTTON_LENGTH) + MARGIN);
_textField.width = (_container.width - (2 * MARGIN));
_textField.height = ((_container.height - (2 * BUTTON_LENGTH)) - (2 * MARGIN));
_textField.autoSize = TextFieldAutoSize.NONE;
_textField.embedFonts = false;
_textField.antiAliasType = AntiAliasType.NORMAL;
_textField.wordWrap = true;
_textField.defaultTextFormat = new TextFormat("_typewriter", DISPLAY_FONT_SIZE, DISPLAY_FONT_COLOUR);
_container.addChild(_textField);
}
private function _onClearButtonClick(_arg1:MouseEvent):void{
_textField.text = "";
}
private function _createContainer():void{
_container = new Sprite();
_container.x = MARGIN;
_container.y = ((_stage.stageHeight - HEIGHT) - MARGIN);
_greyBox = new Sprite();
_greyBox.graphics.beginFill(COLOUR_GREY);
_greyBox.graphics.drawRect(0, 0, (_stage.stageWidth - (2 * MARGIN)), (HEIGHT - (2 * BUTTON_LENGTH)));
_greyBox.graphics.endFill();
_greyBox.y = (2 * BUTTON_LENGTH);
_container.addChild(_greyBox);
_stage.addChild(_container);
}
private function _createCloseButton():void{
_closeButton = new Sprite();
_closeButton.x = ((_container.width - BUTTON_LENGTH) - MARGIN);
_closeButton.y = MARGIN;
_closeButton.graphics.beginFill(COLOUR_RED);
_closeButton.graphics.lineStyle(0, COLOUR_WHITE);
_closeButton.graphics.drawRect(0, 0, BUTTON_LENGTH, BUTTON_LENGTH);
_closeButton.graphics.endFill();
_closeButton.graphics.moveTo(0, 0);
_closeButton.graphics.lineTo(BUTTON_LENGTH, BUTTON_LENGTH);
_closeButton.graphics.moveTo(BUTTON_LENGTH, 0);
_closeButton.graphics.lineTo(0, BUTTON_LENGTH);
_closeButton.buttonMode = true;
_closeButton.addEventListener(MouseEvent.CLICK, _onCloseButtonClick, false, 0, true);
_container.addChild(_closeButton);
}
private function _onContainerMouseMove(_arg1:MouseEvent):void{
_arg1.updateAfterEvent();
}
private function _onMouseOver(_arg1:MouseEvent):void{
Mouse.show();
}
public function set stage(_arg1:Stage):void{
_stage = _arg1;
}
public static function timeTo24HourString(_arg1:Date):String{
var _local2 = "";
_local2 = (_local2 + numberToFixedLengthString(_arg1.getHours(), 2, 0, "0"));
_local2 = (_local2 + ":");
_local2 = (_local2 + numberToFixedLengthString(_arg1.getMinutes(), 2, 0, "0"));
_local2 = (_local2 + ":");
_local2 = (_local2 + numberToFixedLengthString(_arg1.getSeconds(), 2, 0, "0"));
return (_local2);
}
public static function numberToFixedLengthString(_arg1:Number, _arg2:uint=4, _arg3:uint=4, _arg4:String=" "):String{
var _local5:String = String(((_arg1 == 0)) ? _arg1 : _arg1.toFixed(_arg3));
var _local6:uint = _arg2;
if (_arg3 > 0){
_local6 = (_local6 + (1 + _arg3));
};
_arg4 = _arg4.charAt(0);
while (_local5.length < _local6) {
_local5 = (_arg4 + _local5);
};
return (_local5);
}
}
}//package com.kerb.logger
Section 11
//ExtendedSound (com.kerb.sound.ExtendedSound)
package com.kerb.sound {
import flash.events.*;
import flash.media.*;
import flash.utils.*;
public class ExtendedSound extends Sound {
protected var fadeStartVolume:Number;
protected var panStartPosition:Number;
protected var masterVolume:Number;// = 1
protected var panTimer:Timer;
protected var fadeTimer:Timer;
protected var paused:Boolean;
protected var fadeDuration:Number;
protected var fadeStartTime:Number;
protected var fadeEndVolume:Number;
protected var playingLoops:Number;
protected var panEndPosition:Number;
protected var panStartTime:Number;
protected var panDuration:Number;
protected var pauseTime:Number;
protected var transform:SoundTransform;
protected var soundChannel:SoundChannel;
private static const TIMER_UPDATE_RATE:Number = 20;
public function stop():void{
if (soundChannel != null){
soundChannel.stop();
soundChannel.removeEventListener(Event.SOUND_COMPLETE, onSoundComplete);
soundChannel = null;
};
}
protected function updatePan(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number = ((getTimer() - panStartTime) / panDuration);
if (_local3 >= 1){
stopPan();
_local2 = panEndPosition;
} else {
if (_local3 > 0){
_local2 = ((_local3 * (panEndPosition - panStartPosition)) + panStartPosition);
};
};
var _local4:Number = soundChannel.soundTransform.volume;
transform = new SoundTransform(_local4, _local2);
soundChannel.soundTransform = transform;
}
public function fadeTo(_arg1:Number, _arg2:Number):void{
if (((soundChannel) && (soundChannel.soundTransform))){
fadeStartTime = getTimer();
fadeDuration = _arg2;
fadeStartVolume = (soundChannel.soundTransform.volume / masterVolume);
fadeEndVolume = _arg1;
startFade();
};
}
public function setMasterVolume(_arg1:Number):void{
var _local2:Number;
masterVolume = Math.max(0, Math.min(1, _arg1));
if (soundChannel != null){
_local2 = soundChannel.soundTransform.pan;
transform = new SoundTransform((_arg1 * masterVolume), _local2);
soundChannel.soundTransform = transform;
};
}
protected function stopFade():void{
if (((!((fadeTimer == null))) && (fadeTimer.running))){
fadeTimer.reset();
};
}
public function setVolume(_arg1:Number):void{
var _local2:Number;
if (soundChannel != null){
_arg1 = Math.max(0, Math.min(1, _arg1));
_local2 = soundChannel.soundTransform.pan;
transform = new SoundTransform((_arg1 * masterVolume), _local2);
soundChannel.soundTransform = transform;
stopFade();
};
}
public function fadeOut(_arg1:Number=0):void{
if ((((((_arg1 > 0)) && (soundChannel))) && (soundChannel.soundTransform))){
fadeStartTime = getTimer();
fadeDuration = _arg1;
fadeStartVolume = (soundChannel.soundTransform.volume / masterVolume);
fadeEndVolume = 0;
startFade();
} else {
stop();
};
}
override public function play(_arg1:Number=0, _arg2:int=0, _arg3:SoundTransform=null):SoundChannel{
if (_arg3 != null){
_arg3.volume = (_arg3.volume * masterVolume);
} else {
_arg3 = new SoundTransform(masterVolume);
};
soundChannel = super.play(_arg1, _arg2, _arg3);
soundChannel.addEventListener(Event.SOUND_COMPLETE, onSoundComplete);
playingLoops = _arg2;
transform = _arg3;
paused = false;
return (soundChannel);
}
protected function stopPan():void{
if (((!((panTimer == null))) && (panTimer.running))){
panTimer.reset();
};
}
public function fadeIn(_arg1:Number=0, _arg2:Number=1, _arg3:Number=0, _arg4:int=0, _arg5:Number=0):SoundChannel{
fadeStartVolume = Math.max(0, Math.min(1, _arg1));
play(_arg5, _arg4, new SoundTransform((fadeStartVolume * masterVolume)));
if (_arg3 > 0){
fadeStartTime = getTimer();
fadeDuration = _arg3;
fadeEndVolume = Math.max(0, Math.min(1, _arg2));
startFade();
};
return (soundChannel);
}
protected function onSoundComplete(_arg1:Event):void{
dispatchEvent(_arg1);
}
public function get position():Number{
if (soundChannel == null){
return (0);
};
return (soundChannel.position);
}
protected function startPan():void{
if (panTimer == null){
panTimer = new Timer(TIMER_UPDATE_RATE);
panTimer.addEventListener(TimerEvent.TIMER, updatePan);
};
stopPan();
panTimer.start();
}
public function setPan(_arg1:Number):void{
var _local2:Number;
if (soundChannel != null){
_arg1 = Math.max(-1, Math.min(1, _arg1));
_local2 = soundChannel.soundTransform.volume;
transform = new SoundTransform(_local2, _arg1);
soundChannel.soundTransform = transform;
stopPan();
};
}
protected function updateFade(_arg1:TimerEvent):void{
var _local2:Number;
var _local3:Number = ((getTimer() - fadeStartTime) / fadeDuration);
if (_local3 >= 1){
stopFade();
_local2 = fadeEndVolume;
} else {
if (_local3 > 0){
_local2 = ((_local3 * (fadeEndVolume - fadeStartVolume)) + fadeStartVolume);
};
};
var _local4:Number = soundChannel.soundTransform.pan;
transform = new SoundTransform((_local2 * masterVolume), _local4);
soundChannel.soundTransform = transform;
}
public function getSoundChannel():SoundChannel{
return (soundChannel);
}
override public function toString():String{
var _local1:String = getQualifiedClassName(this);
if (soundChannel != null){
_local1 = (_local1 + ((" vol[" + (soundChannel.soundTransform.volume / masterVolume)) + "]"));
_local1 = (_local1 + ((" pan[" + soundChannel.soundTransform.pan) + "]"));
};
return (_local1);
}
public function pause():void{
if (soundChannel == null){
return;
};
pauseTime = soundChannel.position;
stop();
}
public function panTo(_arg1:Number, _arg2:Number):void{
if (_arg2 > 0){
panStartTime = getTimer();
panDuration = _arg2;
panStartPosition = soundChannel.soundTransform.pan;
panEndPosition = _arg1;
startPan();
} else {
setPan(_arg1);
};
}
public function unpause():void{
play(pauseTime, playingLoops, transform);
}
protected function startFade():void{
if (fadeTimer == null){
fadeTimer = new Timer(TIMER_UPDATE_RATE);
fadeTimer.addEventListener(TimerEvent.TIMER, updateFade);
};
stopFade();
fadeTimer.start();
}
}
}//package com.kerb.sound
Section 12
//SoundManager (com.kerb.sound.SoundManager)
package com.kerb.sound {
import flash.utils.*;
public class SoundManager {
private var sounds:Array;
private var prevMasterVolume:Number;
private var muteState:Boolean;// = false
private var masterVolume:Number;// = 1
public function SoundManager(){
prevMasterVolume = masterVolume;
sounds = new Array();
super();
}
public function unregisterSound(_arg1:String):void{
if (sounds[_arg1] != null){
sounds[_arg1].stop();
sounds[_arg1] = null;
};
}
public function stopAllSounds():void{
var _local1:String;
for (_local1 in sounds) {
sounds[_local1].stop();
};
}
public function setMasterVolume(_arg1:Number):void{
var _local2:String;
prevMasterVolume = masterVolume;
masterVolume = Math.max(0, Math.min(1, _arg1));
for (_local2 in sounds) {
sounds[_local2].setMasterVolume(masterVolume);
};
}
public function get muted():Boolean{
return (muteState);
}
public function registerSound(_arg1:ExtendedSound, _arg2:String=null, _arg3:Boolean=false):void{
if (_arg2 == null){
_arg2 = getQualifiedClassName(_arg1);
};
if (sounds[_arg2] != null){
if (_arg3){
unregisterSound(_arg2);
} else {
throw (new Error((("Class name conflict: A sound with the class name [" + _arg2) + "] already exists in SoundManager.")));
};
};
sounds[_arg2] = _arg1;
_arg1.setMasterVolume(masterVolume);
}
public function unmute():void{
if (muteState){
muteState = false;
setMasterVolume(prevMasterVolume);
};
}
public function getSoundByClassName(_arg1:String):ExtendedSound{
return (sounds[_arg1]);
}
public function mute():void{
if (!muteState){
muteState = true;
setMasterVolume(0);
};
}
public function toString():String{
var _local2:String;
var _local1 = "====================\n";
_local1 = (_local1 + "SoundManager\n");
_local1 = (_local1 + "--------------------\n");
_local1 = (_local1 + (("master vol[" + masterVolume) + "]\n"));
_local1 = (_local1 + "--------------------");
for (_local2 in sounds) {
_local1 = (_local1 + ("\n" + sounds[_local2].toString()));
};
_local1 = (_local1 + "\n====================");
return (_local1);
}
}
}//package com.kerb.sound
Section 13
//DoubleQuick (com.kerb.tracking.DoubleQuick)
package com.kerb.tracking {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.utils.*;
public class DoubleQuick {
private static const SO_SESSION_PROPERTY_NAME:String = "sessionkey";
private static const SO_NAME:String = "doublequick";
private static const TICKER_PERIOD:Number = 30000;
private static const TRACKER_SESSION_URL:String = "http://doublequick.kerb.co.uk/tracking/session.htm";
private static const TICKER_URL:String = "http://doublequick.kerb.co.uk/tracking/ticker.htm";
private static const TRACKER_URL:String = "http://doublequick.kerb.co.uk/tracking/trackflash.htm";
private static const SO_EXPIRY_PROPERTY_NAME:String = "expo";
private static var tickerURL:URLRequest = null;
private static var initialised:Boolean = false;
private static var queue:Array = new Array();
private static var projectId:Number;
private static var baseurl:String;
private static var dq:DoubleQuick;
private static var traceEvents:Boolean;
public function startTimer():void{
var _local1:Timer = new Timer(TICKER_PERIOD, 0);
_local1.start();
_local1.addEventListener(TimerEvent.TIMER, pingProxy);
}
public function pingProxy(_arg1:TimerEvent):void{
DoubleQuick.ping();
}
private static function doTrace(_arg1:String):void{
if (traceEvents){
trace(_arg1);
};
}
public static function event(_arg1:Number):void{
var loader:URLLoader;
var request:URLRequest;
var watchId = _arg1;
if (!initialised){
doTrace(("Queueing event " + watchId));
queue.push(watchId);
} else {
doTrace(("Tracking event " + watchId));
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener);
request = generateURL(watchId);
request.method = URLRequestMethod.GET;
try {
loader.load(request);
} catch(error:Error) {
};
};
}
public static function click(_arg1:Number):void{
doTrace(("Tracking clickThrough " + _arg1));
navigateToURL(generateURL(_arg1));
}
private static function dummyListener(_arg1:Event):void{
}
private static function onInit(_arg1:Event):void{
var _local4:Date;
var _local2:URLLoader = URLLoader(_arg1.target);
var _local3:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
if (((!((_local2.data["sessionkey"] == ""))) && (!((_local2.data["sessionkey"] == null))))){
doTrace(("acquired session key " + _local2.data["sessionkey"]));
_local3.setProperty(DoubleQuick.SO_SESSION_PROPERTY_NAME, _local2.data["sessionkey"]);
_local4 = new Date((new Date().getTime() + ((_local2.data["timeout"] * 60) * 1000)));
_local3.setProperty(DoubleQuick.SO_EXPIRY_PROPERTY_NAME, _local4);
};
DoubleQuick.initialisationFinished();
}
public static function init(_arg1:DisplayObject, _arg2:Number, _arg3:Boolean=true):void{
var loader:URLLoader;
var request:URLRequest;
var root = _arg1;
var _projectId = _arg2;
var _traceEvents = _arg3;
projectId = _projectId;
traceEvents = _traceEvents;
baseurl = root.loaderInfo.url;
doTrace(((("Tracking initialised with project " + projectId) + " and baseurl ") + baseurl));
var so:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
var isExpired:Boolean;
var currentDate:Date = new Date();
if (currentDate < so.data[DoubleQuick.SO_EXPIRY_PROPERTY_NAME]){
isExpired = false;
};
if ((((so.data[DoubleQuick.SO_SESSION_PROPERTY_NAME] == undefined)) || (isExpired))){
doTrace("requesting new session key");
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, onInit);
loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener);
request = new URLRequest(((TRACKER_SESSION_URL + "?project=") + projectId));
request.method = URLRequestMethod.GET;
try {
loader.load(request);
} catch(error:Error) {
};
} else {
DoubleQuick.initialisationFinished();
};
}
public static function initialisationFinished():void{
doTrace("Tracking initialised");
initialised = true;
var _local1:int;
while (_local1 < queue.length) {
event(queue[_local1]);
_local1++;
};
queue = new Array();
var _local2:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
tickerURL = new URLRequest(((((TICKER_URL + "?project=") + projectId) + "&session=") + _local2.data[DoubleQuick.SO_SESSION_PROPERTY_NAME]));
tickerURL.method = URLRequestMethod.GET;
dq = new (DoubleQuick);
dq.startTimer();
}
public static function ping():void{
var loader:URLLoader;
if (tickerURL != null){
loader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(IOErrorEvent.IO_ERROR, dummyListener);
doTrace("Tracking ticker");
try {
loader.load(tickerURL);
} catch(error:Error) {
};
};
}
private static function generateURL(_arg1:Number):URLRequest{
var _local2:SharedObject = SharedObject.getLocal(DoubleQuick.SO_NAME);
var _local3:String = ((((((((TRACKER_URL + "?watch=") + _arg1) + "&project=") + projectId) + "&session=") + _local2.data[DoubleQuick.SO_SESSION_PROPERTY_NAME]) + "&baseurl=") + escape(baseurl));
return (new URLRequest(_local3));
}
}
}//package com.kerb.tracking
Section 14
//AssetFactory (com.kerb.utils.AssetFactory)
package com.kerb.utils {
import flash.events.*;
import flash.display.*;
import flash.media.*;
import com.kerb.sound.*;
public final class AssetFactory extends EventDispatcher {
private var _loader:Loader;// = null
public static const EVENT_ASSET_FACTORY_READY:String = "EVENT_ASSET_FACTORY_READY";
public function initialize(_arg1:Class):void{
_loader = new Loader();
_loader.contentLoaderInfo.addEventListener(Event.INIT, _onLibraryReady);
_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _onIOError);
_loader.loadBytes(new (_arg1));
}
public function createExtendedSound(_arg1:String):ExtendedSound{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as ExtendedSound));
}
public function createDisplayObject(_arg1:String):DisplayObject{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as DisplayObject));
}
private function _onLibraryReady(_arg1:Event):void{
_loader.contentLoaderInfo.removeEventListener(Event.INIT, _onLibraryReady);
dispatchEvent(new Event(EVENT_ASSET_FACTORY_READY));
}
public function createSound(_arg1:String):Sound{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as Sound));
}
public function createMovieClip(_arg1:String):MovieClip{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new (_local2) as MovieClip));
}
public function createBitmapDataObject(_arg1:String):BitmapData{
var _local2:Class = Class(_loader.contentLoaderInfo.applicationDomain.getDefinition(_arg1));
return ((new _local2(0, 0) as BitmapData));
}
private function _onIOError(_arg1:Event):void{
}
}
}//package com.kerb.utils
Section 15
//Crypto (com.kerb.utils.Crypto)
package com.kerb.utils {
public final class Crypto {
private static var KEYS:Array = new Array("98sdfa23Ql", "ADF8b3w2fq", "ER2b79hwfO", "clkenf0FSj", "4R7d6ASYU3", "ASDQsjhW02", "kCQ6YH9asc", "ADIx7g19SP", "Nd98fhiOAF", "a09hADNFkf");
private static var SALT:String = "8008135";
public static function encrypt(_arg1:int):String{
var _local2:String = ((_arg1 + "") + SALT);
var _local3 = "";
var _local4:int = Math.floor((Math.random() * KEYS.length));
var _local5:int = _local4;
var _local6:int;
while (_local6 < _local2.length) {
_local3 = (_local3 + KEYS[_local5].charAt(parseInt(_local2.charAt(_local6))));
_local5 = ((_local5 + 1) % KEYS.length);
_local6++;
};
_local3 = (_local3 + ("" + _local4));
return (_local3);
}
public static function decrypt(_arg1:String):int{
var _local6:int;
var _local2:int = parseInt(_arg1.substr(-1));
var _local3:String = _arg1.substr(0, (_arg1.length - 1));
var _local4 = "";
var _local5:int;
while (_local5 < _local3.length) {
_local6 = KEYS[_local2].indexOf(_local3.charAt(_local5));
if (_local6 > -1){
_local4 = (_local4 + ("" + _local6));
} else {
return (0);
};
_local2 = ((_local2 + 1) % KEYS.length);
_local5++;
};
if (_local4.substr(-(SALT.length)) != SALT){
return (0);
};
return (parseInt(_local4.substr(0, (_local4.length - SALT.length))));
}
}
}//package com.kerb.utils
Section 16
//IDisposable (com.kerb.utils.IDisposable)
package com.kerb.utils {
public interface IDisposable {
function dispose():void;
}
}//package com.kerb.utils
Section 17
//GameAssets (com.kerb.veronicas.assets.GameAssets)
package com.kerb.veronicas.assets {
import flash.display.*;
import flash.events.*;
import com.kerb.utils.*;
public class GameAssets extends EventDispatcher {
private const swfBytes:Class;
private var _af:AssetFactory;
private static var _instance:GameAssets;
public function GameAssets(){
swfBytes = GameAssets_swfBytes;
super();
_af = new AssetFactory();
_af.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, _onAssetFactoryReady);
_af.initialize(swfBytes);
}
public function createDisplayObject(_arg1:String):DisplayObject{
return (_af.createDisplayObject(_arg1));
}
private function _onAssetFactoryReady(_arg1:Event):void{
_af.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, _onAssetFactoryReady);
dispatchEvent(new Event(Event.COMPLETE));
}
public static function instance():GameAssets{
if (_instance == null){
_instance = new (GameAssets);
};
return (_instance);
}
}
}//package com.kerb.veronicas.assets
Section 18
//GameAssets_swfBytes (com.kerb.veronicas.assets.GameAssets_swfBytes)
package com.kerb.veronicas.assets {
import mx.core.*;
public class GameAssets_swfBytes extends ByteArrayAsset {
}
}//package com.kerb.veronicas.assets
Section 19
//GeneralAssets (com.kerb.veronicas.assets.GeneralAssets)
package com.kerb.veronicas.assets {
import flash.display.*;
import flash.events.*;
import com.kerb.sound.*;
import com.kerb.utils.*;
public final class GeneralAssets extends EventDispatcher {
private const swfBytes:Class;
private var _af:AssetFactory;
private static var _instance:GeneralAssets;
public function GeneralAssets(){
swfBytes = GeneralAssets_swfBytes;
super();
_af = new AssetFactory();
_af.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, _onAssetFactoryReady);
_af.initialize(swfBytes);
}
public function createTransition():MovieClip{
return ((_af.createDisplayObject("GeneralAssetTransition") as MovieClip));
}
public function createPreloader():MovieClip{
return ((_af.createDisplayObject("GeneralAssetPreloader") as MovieClip));
}
public function createGameComplete():MovieClip{
return ((_af.createDisplayObject("GeneralAssetGameComplete") as MovieClip));
}
public function createSound(_arg1:String):ExtendedSound{
return (_af.createExtendedSound(_arg1));
}
private function _onAssetFactoryReady(_arg1:Event):void{
_af.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, _onAssetFactoryReady);
dispatchEvent(new Event(Event.COMPLETE));
}
public function createTitle():MovieClip{
return ((_af.createDisplayObject("GeneralAssetTitle") as MovieClip));
}
public static function instance():GeneralAssets{
if (_instance == null){
_instance = new (GeneralAssets);
};
return (_instance);
}
}
}//package com.kerb.veronicas.assets
Section 20
//GeneralAssets_swfBytes (com.kerb.veronicas.assets.GeneralAssets_swfBytes)
package com.kerb.veronicas.assets {
import mx.core.*;
public class GeneralAssets_swfBytes extends ByteArrayAsset {
}
}//package com.kerb.veronicas.assets
Section 21
//AbstractLevel (com.kerb.veronicas.game.screens.AbstractLevel)
package com.kerb.veronicas.game.screens {
import flash.events.*;
import com.kerb.veronicas.game.*;
public class AbstractLevel extends AbstractScreen {
protected var renderer:Renderer;
protected var udm:UserDataManager;
protected var hud:HUD;
public function AbstractLevel(_arg1:UserDataManager){
this.udm = _arg1;
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
protected function init():void{
hud = new HUD();
addChild(hud);
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
init();
}
override public function dispose():void{
}
}
}//package com.kerb.veronicas.game.screens
Section 22
//AbstractScreen (com.kerb.veronicas.game.screens.AbstractScreen)
package com.kerb.veronicas.game.screens {
import flash.display.*;
import com.kerb.utils.*;
public class AbstractScreen extends Sprite implements IDisposable {
public function dispose():void{
}
}
}//package com.kerb.veronicas.game.screens
Section 23
//Level1 (com.kerb.veronicas.game.screens.Level1)
package com.kerb.veronicas.game.screens {
import flash.display.*;
import flash.events.*;
import com.kerb.veronicas.assets.*;
import com.kerb.veronicas.*;
import com.kerb.veronicas.game.*;
import de.polygonal.motor2.dynamics.*;
import com.kerb.tracking.*;
import flash.text.*;
import flash.ui.*;
public class Level1 extends AbstractLevel {
private const INITIAL_LIVES:Number = 3;
private const RATINGS_SCORES:Array;
private const BEAM_Y:Number = 280;
private const MIN_TICKS_BETWEEN_BALLS:Number = 15;
private const RATINGS_TEXT:Array;
private var loadedPercent:int;
private var lives:int;
private var score:int;
private var instructions:MovieClip;
private var paused:Boolean;
private var beam:Beam;
private var ticksSinceLastBall:int;// = 0
private var _playTheVideo:MovieClip;
private var fg:MovieClip;
private var physics:Physics;
private var veronica1:MovieClip;
private var veronica2:MovieClip;
private var avatar:Avatar;
private var balls:Array;
private var gameClip:Sprite;
private var _getTheMusic:GetTheMusic;
private var __song:ISong;
private var musictime:MovieClip;
private var lastBallFrom:int;// = 2
private static var _instructionsShown:Boolean = false;
public function Level1(_arg1:UserDataManager){
RATINGS_TEXT = ["A Chart Flop", "A Chart Topper", "Untouchable"];
RATINGS_SCORES = [0, 2000, 4000];
super(_arg1);
}
private function _onPlayTheVideoClicked(_arg1:Event=null):void{
DoubleQuick.click(377);
}
private function helpClosed(_arg1:Event=null):void{
unpauseLevel();
}
override protected function init():void{
physics = new Physics(550, 600);
lives = INITIAL_LIVES;
score = 0;
instructions = (GameAssets.instance().createDisplayObject("instructions_mc") as MovieClip);
var _local1:MovieClip = (instructions.getChildByName("play_btn") as MovieClip);
_setupMovieClipAsButton(_local1, true);
_local1.addEventListener(MouseEvent.CLICK, helpClosed);
initBG();
initBeamAndAvatar();
initFG();
balls = new Array();
super.init();
__song = Config.instance().getSong();
if (__song == null){
throw (new Error("song cannot be null"));
};
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true);
updateScore();
updateTimer();
startLevel();
if (!_instructionsShown){
_instructionsShown = true;
helpClicked();
};
}
private function unpauseLevel():void{
if (!paused){
return;
};
paused = false;
if (__song != null){
__song.unpause();
};
if (instructions.parent != null){
stage.focus = stage;
removeChild(instructions);
};
addEventListener(Event.ENTER_FRAME, onEnterFrame);
veronica1.anim_mc.play();
veronica2.anim_mc.play();
veronica1.anim_mc.balls_mc.play();
veronica2.anim_mc.balls_mc.play();
beam.play();
avatar.play();
}
private function stopLevel():void{
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
if (__song != null){
__song.removeEventListener(Event.SOUND_COMPLETE, onSongFinished);
__song.stop();
};
}
override public function dispose():void{
stopLevel();
}
private function _onVeronicasLogoClicked(_arg1:MouseEvent):void{
DoubleQuick.click(379);
}
private function onSongFinished(_arg1:Event=null):void{
trace("FINISHED SONG");
dispatchEvent(new Event(Game.EVENT_WIN_LEVEL));
}
private function onEnterFrame(_arg1:Event=null):void{
ticksSinceLastBall++;
if ((((Math.random() < 0.1)) && ((ticksSinceLastBall > MIN_TICKS_BETWEEN_BALLS)))){
addBall();
};
var _local2:int = balls.length;
while (--_local2 > -1) {
if (balls[_local2].update()){
balls[_local2].dispose();
balls.splice(_local2, 1);
} else {
if (balls[_local2].checkCollision(avatar.x, avatar.y, Avatar.RADIUS)){
Main.smSFX.getSoundByClassName("catchball_snd").play();
trace("HIT!");
balls[_local2].dispose();
new ScoreBubble(this, avatar.x, (avatar.y - 120), balls[_local2].score);
score = (score + balls[_local2].score);
balls.splice(_local2, 1);
avatar.catchBall();
updateScore();
GameComplete.score = score;
};
};
};
beam.update();
if (avatar.update(beam)){
lifeLost();
};
physics.step();
updateTimer();
}
private function pauseLevel():void{
if (paused){
return;
};
paused = true;
if (__song != null){
__song.pause();
};
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
veronica1.anim_mc.stop();
veronica2.anim_mc.stop();
veronica1.anim_mc.balls_mc.stop();
veronica2.anim_mc.balls_mc.stop();
beam.stop();
avatar.stop();
}
private function _onGetTheMusicClicked(_arg1:Event):void{
if (instructions.parent == null){
pauseLevel();
};
_setupMovieClipAsButton(_playTheVideo, false);
}
private function helpClicked(_arg1:Event=null):void{
if (instructions.parent == null){
pauseLevel();
addChild(instructions);
};
}
private function lifeLost():void{
var _local1:int;
lives--;
trace((("LOSE LIFE, " + lives) + " LEFT"));
if (lives > 0){
avatar.dispose();
beam.dispose();
_local1 = balls.length;
while (--_local1 > -1) {
balls[_local1].dispose();
};
balls = new Array();
initBeamAndAvatar();
initFG();
} else {
dispatchEvent(new Event(Game.EVENT_LOSE_LEVEL));
};
}
private function startLevel():void{
addEventListener(Event.ENTER_FRAME, onEnterFrame);
if (__song != null){
__song.play();
__song.addEventListener(Event.SOUND_COMPLETE, onSongFinished);
};
}
private function addBall():void{
var _local1:Number = (Math.random() * 175);
_local1 = (175 - ((_local1 * _local1) / 175));
var _local2:Number = (275 + (((Math.random() < 0.5)) ? 1 : -1 * _local1));
var _local3:Number = -50;
var _local4:int;
var _local5:uint = 3;
var _local6:uint = 2;
var _local7:RigidBody = physics.addCircle(_local2, _local3, Ball.RADIUS, Ball.DENSITY, 1, _local5, _local6);
var _local8:MovieClip = (GameAssets.instance().createDisplayObject("ball_mc") as MovieClip);
var _local9:Ball = new Ball(_local7, _local8);
balls.push(_local9);
gameClip.addChild(_local8);
_local9.updatePosition();
if (lastBallFrom == 1){
veronica2.anim_mc.balls_mc.gotoAndPlay("fireball");
} else {
veronica1.anim_mc.balls_mc.gotoAndPlay("fireball");
};
lastBallFrom = (3 - lastBallFrom);
ticksSinceLastBall = 0;
}
private function updateScore():void{
var _local1:TextField = (fg.getChildByName("score_txt") as TextField);
var _local2:TextField = (fg.getChildByName("rating_txt") as TextField);
if ((((_local1 == null)) || ((_local2 == null)))){
return;
};
_local1.text = ("" + score);
var _local3:String = RATINGS_TEXT[0];
var _local4:int;
while (_local4 < RATINGS_SCORES.length) {
if (score > RATINGS_SCORES[_local4]){
_local3 = RATINGS_TEXT[_local4];
};
_local4++;
};
_local2.text = (GameComplete.ratingText = _local3);
}
private function initFG():void{
var _local1:MovieClip;
var _local2:MovieClip;
var _local3:MovieClip;
var _local4:SimpleButton;
if (fg == null){
fg = (GameAssets.instance().createDisplayObject("gamefg_mc") as MovieClip);
_local1 = (fg.getChildByName("timer_mc") as MovieClip);
_local2 = (_local1.getChildByName("gauge_mc") as MovieClip);
musictime = (_local2.getChildByName("musictime_mc") as MovieClip);
_local3 = (fg.getChildByName("help_btn") as MovieClip);
_setupMovieClipAsButton(_local3, true);
_local3.addEventListener(MouseEvent.CLICK, helpClicked);
_local4 = (fg.getChildByName("veronicas_btn") as SimpleButton);
if (_local4 != null){
_local4.addEventListener(MouseEvent.CLICK, _onVeronicasLogoClicked);
};
} else {
removeChild(fg);
};
addChild(fg);
(fg.getChildByName("life1_mc") as MovieClip).gotoAndStop(((lives)==3) ? "_active" : ((lives)>2) ? 1 : "_dead");
(fg.getChildByName("life2_mc") as MovieClip).gotoAndStop(((lives)==2) ? "_active" : ((lives)>1) ? 1 : "_dead");
(fg.getChildByName("life3_mc") as MovieClip).gotoAndStop(((lives)==1) ? "_active" : ((lives)>0) ? 1 : "_dead");
}
private function initBG():void{
var _local1:MovieClip = (GameAssets.instance().createDisplayObject("gamebg_mc") as MovieClip);
addChild(_local1);
gameClip = new Sprite();
addChild(gameClip);
var _local2:MovieClip = (GameAssets.instance().createDisplayObject("masker_mc") as MovieClip);
gameClip.mask = _local2;
veronica1 = (GameAssets.instance().createDisplayObject("veronica1_mc") as MovieClip);
veronica2 = (GameAssets.instance().createDisplayObject("veronica2_mc") as MovieClip);
gameClip.addChild(veronica1);
gameClip.addChild(veronica2);
gameClip.addChild(GameAssets.instance().createDisplayObject("purpleglow_mc"));
_getTheMusic = new GetTheMusic((_local1.getChildByName("getTheMusic_mc") as MovieClip));
_getTheMusic.addEventListener(GetTheMusic.EVENT_CLICKED, _onGetTheMusicClicked);
_getTheMusic.addEventListener(GetTheMusic.EVENT_CLOSED, _onGetTheMusicClosed);
_playTheVideo = (_local1.getChildByName("seevideo_btn") as MovieClip);
_playTheVideo.addEventListener(MouseEvent.CLICK, _onPlayTheVideoClicked);
_setupMovieClipAsButton(_playTheVideo, true);
}
private function _onGetTheMusicClosed(_arg1:Event):void{
if (instructions.parent == null){
unpauseLevel();
};
_setupMovieClipAsButton(_playTheVideo, true);
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == Keyboard.SPACE)) || ((_arg1.keyCode == Keyboard.ENTER)))){
if (instructions.parent != null){
helpClosed();
};
};
if (_arg1.keyCode == Keyboard.DELETE){
dispatchEvent(new Event(Game.EVENT_LOSE_LEVEL));
} else {
if (_arg1.keyCode == Keyboard.INSERT){
dispatchEvent(new Event(Game.EVENT_WIN_LEVEL));
};
};
}
private function onTimeOut(_arg1:Event=null):void{
trace("TIME OUT");
dispatchEvent(new Event(Game.EVENT_LOSE_LEVEL));
}
private function initBeamAndAvatar():void{
var _local1:int;
var _local2:uint;
var _local3:uint = 3;
var _local4:RigidBody = physics.addBox(275, BEAM_Y, 350, 45, Beam.DENSITY, Beam.FRICTION, _local1, _local2, _local3);
var _local5:MovieClip = (GameAssets.instance().createDisplayObject("beam_mc") as MovieClip);
beam = new Beam(_local4, _local5, physics);
gameClip.addChild(_local5);
beam.updatePosition();
_local1 = 0;
_local2 = 1;
_local3 = 1;
_local4 = physics.addCircle(275, (BEAM_Y - (Avatar.RADIUS + 22.5)), Avatar.RADIUS, Avatar.DENSITY, _local1, _local2, _local3, "avatar");
_local5 = (GameAssets.instance().createDisplayObject((("avatar" + lives) + "_mc")) as MovieClip);
avatar = new Avatar(_local4, _local5, stage);
gameClip.addChild(_local5);
avatar.updatePosition(beam);
}
private function updateTimer():void{
if (__song == null){
return;
};
musictime.gotoAndStop(Math.ceil((musictime.totalFrames * Math.min(1, (__song.position / __song.length)))));
}
private static function _setupMovieClipAsButton(_arg1:MovieClip, _arg2:Boolean):void{
_arg1.mouseEnabled = _arg2;
_arg1.buttonMode = _arg2;
_arg1.useHandCursor = _arg2;
_arg1.mouseChildren = false;
}
}
}//package com.kerb.veronicas.game.screens
Section 24
//Avatar (com.kerb.veronicas.game.Avatar)
package com.kerb.veronicas.game {
import flash.display.*;
import flash.events.*;
import com.kerb.veronicas.*;
import de.polygonal.motor2.dynamics.*;
import flash.ui.*;
public class Avatar {
private var catching:Boolean;// = false
private var leftDown:Boolean;
private var dir:int;// = 1
private var mc:MovieClip;
private var rightDown:Boolean;
private var dying:Boolean;// = false
private var rb:RigidBody;
private var appearing:Boolean;// = true
public static const RADIUS:Number = 20;
public static const DENSITY:Number = 100;
public static const MOVE_FORCE:Number = 6000000;
public function Avatar(_arg1:RigidBody, _arg2:MovieClip, _arg3:Stage){
this.rb = _arg1;
this.mc = _arg2;
_arg3.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true);
_arg3.addEventListener(KeyboardEvent.KEY_UP, onKeyUp, false, 0, true);
_arg2.addEventListener("CATCHING_FINISHED", onCatchFinished);
_arg2.addEventListener("APPEARING_FINISHED", onAppearFinished);
_arg2.gotoAndStop("appearing");
}
public function die():void{
if (dying){
return;
};
leftDown = false;
rightDown = false;
dying = true;
mc.gotoAndStop("dying");
Main.smSFX.getSoundByClassName("die_snd").play();
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if (((appearing) || (dying))){
return;
};
if (_arg1.keyCode == Keyboard.LEFT){
leftDown = true;
dir = -1;
};
if (_arg1.keyCode == Keyboard.RIGHT){
rightDown = true;
dir = 1;
};
}
public function play(_arg1:Event=null):void{
mc.removeEventListener(Event.ENTER_FRAME, play);
if (mc.anim_mc == null){
mc.addEventListener(Event.ENTER_FRAME, play);
} else {
mc.anim_mc.play();
};
}
public function update(_arg1:Beam):Boolean{
var _local2:Number = 0;
var _local3:Number = 0;
var _local4:Number = _arg1.getAngleInRadians();
if (leftDown){
rb.wakeUp();
_local2 = (Math.cos(_local4) * -(MOVE_FORCE));
_local3 = (Math.sin(_local4) * -(MOVE_FORCE));
rb.applyForce(_local2, _local3);
};
if (rightDown){
rb.wakeUp();
_local2 = (Math.cos(_local4) * MOVE_FORCE);
_local3 = (Math.sin(_local4) * MOVE_FORCE);
rb.applyForce(_local2, _local3);
};
updatePosition(_arg1);
if ((((_local4 < (-(Math.PI) / 3))) || ((_local4 > (Math.PI / 3))))){
die();
};
if (rb.y > 500){
die();
};
return ((rb.y > 500));
}
public function stop(_arg1:Event=null):void{
mc.removeEventListener(Event.ENTER_FRAME, stop);
if (mc.anim_mc == null){
mc.addEventListener(Event.ENTER_FRAME, stop);
} else {
mc.anim_mc.stop();
};
}
public function updatePosition(_arg1:Beam):void{
var _local2:Number = _arg1.getAngleInRadians();
var _local3:Number = (Math.cos((_local2 + (Math.PI / 2))) * RADIUS);
var _local4:Number = (Math.sin((_local2 + (Math.PI / 2))) * RADIUS);
mc.x = (rb.x + _local3);
mc.y = (rb.y + _local4);
mc.rotation = ((_local2 * 180) / Math.PI);
mc.scaleX = dir;
}
public function dispose():void{
rb.world.destroyBody(rb);
if (((!((mc == null))) && (!((mc.parent == null))))){
mc.parent.removeChild(mc);
};
}
public function onAppearFinished(_arg1:Event=null):void{
appearing = false;
mc.gotoAndStop("walking");
}
public function onCatchFinished(_arg1:Event=null):void{
catching = false;
mc.gotoAndStop("walking");
}
public function catchBall():void{
catching = true;
mc.gotoAndStop("walking");
mc.gotoAndStop("catching");
}
public function get x():Number{
return (rb.x);
}
public function get y():Number{
return (rb.y);
}
private function onKeyUp(_arg1:KeyboardEvent):void{
if (((appearing) || (dying))){
return;
};
if (_arg1.keyCode == Keyboard.LEFT){
leftDown = false;
if (rightDown){
dir = 1;
};
};
if (_arg1.keyCode == Keyboard.RIGHT){
rightDown = false;
if (leftDown){
dir = 1;
};
};
}
}
}//package com.kerb.veronicas.game
Section 25
//Ball (com.kerb.veronicas.game.Ball)
package com.kerb.veronicas.game {
import flash.display.*;
import de.polygonal.motor2.dynamics.*;
public class Ball {
private var rb:RigidBody;
public var score:int;
private var mc:MovieClip;
public static const RADIUS:Number = 20;
private static const INIT_SCORE:int = 100;
public static const DENSITY:Number = 0.01;
public function Ball(_arg1:RigidBody, _arg2:MovieClip){
this.rb = _arg1;
this.mc = _arg2;
this.score = INIT_SCORE;
}
public function updatePosition():void{
mc.x = rb.x;
mc.y = rb.y;
mc.alpha = (score / INIT_SCORE);
}
public function update():Boolean{
updatePosition();
if (--score == 0){
return (true);
};
return (false);
}
public function checkCollision(_arg1:Number, _arg2:Number, _arg3:Number):Boolean{
var _local4:Number = (_arg1 - rb.x);
var _local5:Number = (_arg2 - rb.y);
var _local6:Number = (RADIUS + _arg3);
var _local7:Number = ((_local4 * _local4) + (_local5 * _local5));
if (_local7 < (_local6 * _local6)){
return (true);
};
return (false);
}
public function dispose():void{
rb.world.destroyBody(rb);
if (((!((mc == null))) && (!((mc.parent == null))))){
mc.parent.removeChild(mc);
};
}
}
}//package com.kerb.veronicas.game
Section 26
//Beam (com.kerb.veronicas.game.Beam)
package com.kerb.veronicas.game {
import flash.display.*;
import de.polygonal.motor2.dynamics.*;
import flash.geom.*;
import de.polygonal.motor2.dynamics.joints.*;
import de.polygonal.motor2.dynamics.joints.data.*;
public class Beam {
private var rb:RigidBody;
private var mc:MovieClip;
private var rjd:RevoluteJointData;
public static const DENSITY:Number = 400;
public static const FRICTION:Number = 0.9;
public function Beam(_arg1:RigidBody, _arg2:MovieClip, _arg3:Physics){
this.rb = _arg1;
this.mc = _arg2;
var _local4:RigidBody = _arg3.world.getGroundBody();
rjd = new RevoluteJointData(_local4, _arg1, new Point(_arg1.x, _arg1.y));
rjd.enableLimit = true;
rjd.lowerAngle = (-(Math.PI) / 2);
rjd.upperAngle = (Math.PI / 2);
rjd.enableMotor = true;
rjd.motorSpeed = 0;
rjd.maxMotorTorque = 1000000;
(_arg3.world.createJoint(rjd) as RevoluteJoint);
}
public function stop():void{
mc.stop();
}
public function update():void{
updatePosition();
}
public function updatePosition():void{
mc.x = rb.x;
mc.y = rb.y;
mc.rotation = ((rb.r * 180) / Math.PI);
}
public function play():void{
mc.play();
}
public function getAngleInRadians():Number{
return (rb.r);
}
public function dispose():void{
rb.world.destroyBody(rb);
if (((!((mc == null))) && (!((mc.parent == null))))){
mc.parent.removeChild(mc);
};
}
}
}//package com.kerb.veronicas.game
Section 27
//Game (com.kerb.veronicas.game.Game)
package com.kerb.veronicas.game {
import flash.events.*;
import com.kerb.sound.*;
import com.kerb.veronicas.*;
import com.kerb.game.*;
import com.kerb.veronicas.game.screens.*;
public class Game extends AbstractSection {
private var level:AbstractLevel;
private var udm:UserDataManager;
private var levels:Array;
private var currLevelNum:int;
private var currScreen:AbstractScreen;
public static const EVENT_RETRY_LEVEL:String = "onLevelRetry";
public static const EVENT_WIN_LEVEL:String = "onLevelWin";
public static const EVENT_NEXT_LEVEL:String = "onLevelNext";
public static const EVENT_LOSE_LEVEL:String = "onLevelLose";
private static var song:ExtendedSound;
private function removeLevel():void{
if (level){
level.removeEventListener(EVENT_WIN_LEVEL, onLevelWin);
level.removeEventListener(EVENT_LOSE_LEVEL, onLevelLose);
removeCurrentScreen();
level = null;
};
}
private function onLevelLose(_arg1:Event=null):void{
removeLevel();
gameComplete(false);
}
private function gameComplete(_arg1:Boolean):void{
NextSectionClass = GameComplete;
GameComplete.success = _arg1;
var _local2:Transition = new Transition();
_local2.addEventListener(Event.COMPLETE, _onTransitionComplete);
_local2.draw();
}
private function _onTransitionComplete(_arg1:Event):void{
gotoNextSection();
}
private function removeCurrentScreen():void{
if (currScreen){
currScreen.dispose();
removeChild(currScreen);
currScreen = null;
};
}
override protected function init():void{
levels = [Level1];
udm = new UserDataManager(levels.length, true);
initLevel(0);
}
private function onLevelWin(_arg1:Event=null):void{
udm.setLevelCompleted(currLevelNum);
removeLevel();
gameComplete(true);
}
private function songLoaded():void{
addChild(currScreen);
}
private function initLevel(_arg1:int):void{
removeLevel();
removeCurrentScreen();
currLevelNum = _arg1;
level = new levels[_arg1](udm);
level.addEventListener(EVENT_WIN_LEVEL, onLevelWin);
level.addEventListener(EVENT_LOSE_LEVEL, onLevelLose);
currScreen = level;
addChild(currScreen);
}
override public function dispose():void{
removeLevel();
removeCurrentScreen();
super.dispose();
}
}
}//package com.kerb.veronicas.game
Section 28
//HUD (com.kerb.veronicas.game.HUD)
package com.kerb.veronicas.game {
import flash.display.*;
public class HUD extends Sprite {
}
}//package com.kerb.veronicas.game
Section 29
//ISong (com.kerb.veronicas.game.ISong)
package com.kerb.veronicas.game {
import flash.events.*;
public interface ISong extends IEventDispatcher {
function stop():void;
function play():void;
function pause():void;
function get length():Number;
function get position():Number;
function unpause():void;
}
}//package com.kerb.veronicas.game
Section 30
//Physics (com.kerb.veronicas.game.Physics)
package com.kerb.veronicas.game {
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.nbody.*;
public class Physics {
public var world:World;
private static const TIME_STEP:Number = 0.1;
private static const GRAVITY:Number = 18;
private static const NUM_ITERATIONS:int = 10;
public function Physics(_arg1:Number, _arg2:Number){
init(_arg1, _arg2);
}
private function init(_arg1:Number, _arg2:Number):void{
var _local3:Number = 400;
var _local4:AABB2 = new AABB2(-(_local3), -(_local3), (_arg1 + _local3), (_arg2 + _local3));
var _local5:Boolean;
world = new World(_local4, _local5);
world.setGravity(0, GRAVITY);
world.setBroadPhase(new SAP());
var _local6:Number = (_local3 * 0.5);
var _local7:Number = (_local3 * 0.25);
addBox(-(_local7), (0.5 * _arg2), _local6, (_arg2 + _local6));
addBox((_arg1 + _local7), (0.5 * _arg2), _local6, (_arg2 + _local6));
addBox((0.5 * _arg1), -(_local7), (_arg1 + _local6), _local6);
addBox((0.5 * _arg1), (_arg2 + _local7), (_arg1 + _local6), _local6);
}
public function addCircle(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number=0, _arg5:int=-1, _arg6:uint=0, _arg7:uint=0, _arg8:String=null):RigidBody{
var _local9:CircleData;
var _local10:RigidBodyData;
_local9 = new CircleData(_arg4, _arg3);
_local9.groupIndex = _arg5;
_local9.maskBits = _arg6;
_local9.categoryBits = _arg7;
_local10 = new RigidBodyData(_arg1, _arg2);
_local10.addShapeData(_local9);
return (createRigidBody(_local10, _arg8));
}
public function addLine(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Boolean, _arg6:int=-1, _arg7:String=null):RigidBody{
var _local8:ShapeData;
var _local9:RigidBodyData;
var _local10:Point = new Point(0, 0);
var _local11:Point = new Point((_arg3 - _arg1), (_arg4 - _arg2));
_local8 = new LineData(_local10, _local11, false, _arg5);
_local8.groupIndex = _arg6;
_local9 = new RigidBodyData(_arg1, _arg2);
_local9.addShapeData(_local8);
return (createRigidBody(_local9, _arg7));
}
public function createRigidBody(_arg1:RigidBodyData, _arg2:String=null):RigidBody{
var _local3:RigidBody = world.createBody(_arg1);
_local3.userData = {id:_arg2, owner:null};
return (_local3);
}
public function addBox(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number, _arg5:Number=0, _arg6:Number=0.3, _arg7:int=-1, _arg8:uint=0, _arg9:uint=0, _arg10:String=null):RigidBody{
var _local11:BoxData;
var _local12:RigidBodyData;
_local11 = new BoxData(_arg5, _arg3, _arg4);
_local11.groupIndex = _arg7;
_local11.friction = _arg6;
var _local13:Number = 0;
_local12 = new RigidBodyData(_arg1, _arg2, _local13);
_local12.addShapeData(_local11);
return (createRigidBody(_local12, _arg10));
}
public function destroyRigidBody(_arg1:RigidBody):void{
world.destroyBody(_arg1);
}
public function step():void{
world.step(TIME_STEP, NUM_ITERATIONS);
world.step(TIME_STEP, NUM_ITERATIONS);
world.step(TIME_STEP, NUM_ITERATIONS);
}
public function getShapes():Array{
return (world.getShapeList());
}
}
}//package com.kerb.veronicas.game
Section 31
//Renderer (com.kerb.veronicas.game.Renderer)
package com.kerb.veronicas.game {
import flash.display.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
public class Renderer extends Sprite {
private var debugSprite:Sprite;
public function Renderer(){
debugSprite = new Sprite();
addChild(debugSprite);
}
public function draw(_arg1:Physics):void{
drawWireframes(_arg1.getShapes());
}
private function drawWireframes(_arg1:Array):void{
var _local3:V2;
var _local4:ShapeSkeleton;
var _local5:int;
var _local6:int;
var _local2:Graphics = debugSprite.graphics;
_local2.clear();
_local2.lineStyle(0, 0);
_local5 = 0;
while (_local5 < _arg1.length) {
_local4 = _arg1[_local5];
if (_local4.body.userData.id == "avatar"){
_local2.beginFill(0xFF0000, 0.5);
} else {
_local2.beginFill(0xFFFFFF, 0.5);
};
if ((_local4 is CircleShape)){
_local2.drawCircle((_local4.body.x + _local4.mx), (_local4.body.y + _local4.my), (_local4 as CircleShape).radius);
} else {
_local4.toWorldSpace();
_local3 = _local4.worldVertexChain;
_local2.moveTo(_local3.x, _local3.y);
_local6 = 0;
while (_local6 < _local4.vertexCount) {
_local3 = _local3.next;
_local2.lineTo(_local3.x, _local3.y);
_local6++;
};
};
_local2.endFill();
_local5++;
};
}
}
}//package com.kerb.veronicas.game
Section 32
//ScoreBubble (com.kerb.veronicas.game.ScoreBubble)
package com.kerb.veronicas.game {
import flash.display.*;
import flash.events.*;
import com.kerb.veronicas.assets.*;
public class ScoreBubble {
private var mc:MovieClip;
public function ScoreBubble(_arg1:Sprite, _arg2:Number, _arg3:Number, _arg4:Number){
this.mc = (GameAssets.instance().createDisplayObject("scoreup_mc") as MovieClip);
mc.x = _arg2;
mc.y = _arg3;
mc.scorebox_mc.score_txt.text = ("" + _arg4);
mc.addEventListener("SCORE_FINISHED", onScoreFinished);
_arg1.addChild(mc);
}
private function onScoreFinished(_arg1:Event=null):void{
mc.removeEventListener("SCORE_FINISHED", onScoreFinished);
mc.parent.removeChild(mc);
}
}
}//package com.kerb.veronicas.game
Section 33
//SongFLV (com.kerb.veronicas.game.SongFLV)
package com.kerb.veronicas.game {
import flash.events.*;
import com.kerb.logger.*;
import flash.net.*;
import flash.utils.*;
import flash.media.*;
public final class SongFLV extends EventDispatcher implements ISong {
private var _length:Number;
private var _timer:Timer;
private var _allBytesLoaded:Boolean;// = false
private var _dispatchedComplete:Boolean;// = false
private var _songURL:String;
private var _firstTime:Boolean;// = true
private var _stream:NetStream;
private var _lengthCalculated:Boolean;// = false
private var _connection:NetConnection;
public function SongFLV(_arg1:String){
_songURL = _arg1;
_preload();
}
public function stop():void{
_stream.pause();
_stream.seek(0);
}
public function unpause():void{
_stream.resume();
}
private function _dispatchProgressEvent():void{
var _local1:ProgressEvent = new ProgressEvent(ProgressEvent.PROGRESS);
_local1.bytesLoaded = _stream.bytesLoaded;
_local1.bytesTotal = _stream.bytesTotal;
dispatchEvent(_local1);
}
private function _onNetStatus(_arg1:NetStatusEvent):void{
KerbLog.instance().info((("SongFLV::_onNetStatus: \"" + _arg1.info.code) + "\""));
if (_arg1.info.code == "NetStream.Play.Stop"){
dispatchEvent(new Event(Event.SOUND_COMPLETE));
};
}
private function _preload():void{
_connection = new NetConnection();
_connection.connect(null);
_stream = new NetStream(_connection);
_stream.client = this;
_stream.bufferTime = 1;
_stream.receiveAudio(true);
_stream.receiveVideo(false);
_stream.soundTransform = new SoundTransform(0);
_stream.play(_songURL);
_stream.addEventListener(NetStatusEvent.NET_STATUS, _onNetStatus);
_timer = new Timer(100);
_timer.addEventListener(TimerEvent.TIMER, _onTimer);
_timer.start();
}
private function _checkReady():void{
if (((_allBytesLoaded) && (_lengthCalculated))){
if (!_dispatchedComplete){
_dispatchedComplete = true;
_stream.seek(0);
_stream.pause();
_dispatchProgressEvent();
};
};
}
public function onMetaData(_arg1:Object):void{
_length = parseFloat(_arg1.duration);
_lengthCalculated = true;
_checkReady();
}
public function get length():Number{
return ((1000 * _length));
}
private function _onTimer(_arg1:TimerEvent):void{
if (_stream.bytesLoaded >= _stream.bytesTotal){
_timer.removeEventListener(TimerEvent.TIMER, _onTimer);
_timer.stop();
_timer = null;
_allBytesLoaded = true;
_checkReady();
} else {
_dispatchProgressEvent();
};
}
public function onCuePoint(_arg1:Object):void{
}
public function pause():void{
_stream.pause();
}
public function get position():Number{
return ((1000 * _stream.time));
}
public function play():void{
if (_firstTime){
_stream.soundTransform = new SoundTransform(1);
_stream.seek(0);
_stream.resume();
_firstTime = false;
} else {
_stream.seek(0);
_stream.resume();
};
}
}
}//package com.kerb.veronicas.game
Section 34
//UserDataManager (com.kerb.veronicas.game.UserDataManager)
package com.kerb.veronicas.game {
import flash.net.*;
public class UserDataManager {
private const SALT:String = "1.61803";
private const KEYS:Array;
private var levelScores:Array;
private var numLevels:int;
private var so:SharedObject;
private var levelsCompleted:Array;
public function UserDataManager(_arg1:int=1, _arg2:Boolean=false){
var numLevels = _arg1;
var readLocalData = _arg2;
KEYS = ["cKdpailJCtMqBz", "MhDUOTpACSiwZu", "TWwenNZQCYmtdz", "eisaGZBxdkYVLr"];
super();
this.numLevels = numLevels;
levelScores = new Array();
levelsCompleted = new Array();
var i:int;
while (i < numLevels) {
levelScores[i] = 0;
levelsCompleted[i] = false;
i = (i + 1);
};
try {
so = SharedObject.getLocal("game");
} catch(e:Error) {
trace(e);
};
if (readLocalData){
readData();
};
writeData();
}
private function decrypt(_arg1:String):String{
var _local2:int = parseInt(_arg1.substr(-1));
var _local3 = "";
_arg1 = _arg1.substr(0, (_arg1.length - 1));
var _local4:int;
while (_local4 < _arg1.length) {
_local3 = (_local3 + String.fromCharCode((KEYS[_local2].indexOf(_arg1.charAt(_local4)) + 44)));
_local2 = ((_local2 + 1) % KEYS.length);
_local4++;
};
if (_local3.substr(-(SALT.length)) != SALT){
return ("");
};
return (_local3.substr(0, (_local3.length - SALT.length)));
}
public function setScore(_arg1:Number, _arg2:int=0, _arg3:Boolean=false):void{
if (inRange(_arg2)){
if (((_arg3) || ((_arg1 > levelScores[_arg2])))){
levelScores[_arg2] = _arg1;
};
};
writeData();
}
private function inRange(_arg1:int):Boolean{
return ((((_arg1 >= 0)) && ((_arg1 < numLevels))));
}
public function getLevelCompleted(_arg1:int):Boolean{
return (levelsCompleted[_arg1]);
}
public function readData():void{
var _local1:int;
var _local2:int;
var _local3:String;
var _local4:int;
var _local5:Array;
if (so){
if (so.data.a){
_local3 = decrypt(so.data.a);
_local5 = _local3.split(",");
_local1 = 0;
while (_local1 < _local5.length) {
levelScores[_local1] = parseFloat(_local5[_local1]);
if (isNaN(levelScores[_local1])){
levelScores[_local1] = 0;
};
_local1++;
};
};
if (so.data.b){
_local4 = parseInt(decrypt(so.data.b));
_local1 = 1;
_local2 = 0;
while (_local1 <= _local4) {
levelsCompleted[_local2] = !(((_local4 & _local1) == 0));
_local1 = (_local1 * 2);
_local2++;
};
};
};
}
public function getTotalScore():Number{
var _local1:Number = 0;
var _local2:int;
while (_local2 < numLevels) {
_local1 = (_local1 + levelScores[_local2]);
_local2++;
};
return (_local1);
}
private function encrypt(_arg1:String):String{
var _local2:int = (Math.random() * KEYS.length);
var _local3:int = _local2;
var _local4 = "";
_arg1 = (_arg1 + SALT);
var _local5:int;
while (_local5 < _arg1.length) {
_local4 = (_local4 + KEYS[_local3].charAt((_arg1.charCodeAt(_local5) - 44)));
_local3 = ((_local3 + 1) % KEYS.length);
_local5++;
};
_local4 = (_local4 + _local2);
return (_local4);
}
public function getLevelsCompleted():Array{
return (levelsCompleted);
}
public function writeData():void{
var sum:int;
var i:int;
if (so){
so.data.a = encrypt(levelScores.toString());
sum = 0;
i = 0;
while (i < numLevels) {
if (levelsCompleted[i]){
sum = (sum + Math.pow(2, i));
};
i = (i + 1);
};
so.data.b = encrypt(sum.toString());
try {
so.flush(10000);
} catch(e:Error) {
trace(e);
};
};
}
public function getLevelScore(_arg1:int=0):Number{
return (levelScores[_arg1]);
}
public function setLevelCompleted(_arg1:int, _arg2:Boolean=true):void{
if (inRange(_arg1)){
levelsCompleted[_arg1] = _arg2;
};
writeData();
}
public function addToScore(_arg1:Number, _arg2:int=0):void{
if (inRange(_arg2)){
levelScores[_arg2] = (levelScores[_arg2] + _arg1);
};
writeData();
}
public function allLevelsCompleted():Boolean{
var _local1:int;
while (_local1 < numLevels) {
if (!levelsCompleted[_local1]){
return (false);
};
_local1++;
};
return (true);
}
}
}//package com.kerb.veronicas.game
Section 35
//Config (com.kerb.veronicas.Config)
package com.kerb.veronicas {
import com.kerb.veronicas.game.*;
public final class Config {
private var _artURL:String;
private var _videoURL:String;
private var _song:ISong;
private var _saveScoreURL:String;
private var _songURL:String;
private static var _instance:Config;
public function getArtURL():String{
return (_artURL);
}
public function getSong():ISong{
return (_song);
}
public function getSongURL():String{
return (_songURL);
}
public function getVideoURL():String{
return (_videoURL);
}
public function init(_arg1:XML):void{
_artURL = _arg1.child("artURL");
_songURL = _arg1.child("songURL");
_videoURL = _arg1.child("videoURL");
_saveScoreURL = _arg1.child("saveScoreURL");
}
public function getSaveScoreURL():String{
return (_saveScoreURL);
}
public function setSong(_arg1:ISong):void{
_song = _arg1;
}
public static function instance():Config{
if (_instance == null){
_instance = new (Config);
};
return (_instance);
}
}
}//package com.kerb.veronicas
Section 36
//Constants (com.kerb.veronicas.Constants)
package com.kerb.veronicas {
public final class Constants {
public static const MASTER_XML_FILE:String = "config.xml";
public static const MASTER_XML_URL:String = "http://theveronicasuk.com/game/";
public static const USE_LOCAL_CONFIG_XML:Boolean = false;
public static const DEG_2_RAD:Number = 0.0174532925199433;
public static const showIdent:Boolean = false;
public static const RAD_2_DEG:Number = 57.2957795130823;
public static var locale:String = "en_GB";
}
}//package com.kerb.veronicas
Section 37
//GameComplete (com.kerb.veronicas.GameComplete)
package com.kerb.veronicas {
import flash.display.*;
import flash.events.*;
import com.kerb.logger.*;
import com.kerb.veronicas.assets.*;
import com.kerb.veronicas.game.*;
import flash.net.*;
import com.kerb.game.*;
import com.kerb.utils.*;
import com.kerb.tracking.*;
import flash.text.*;
import flash.media.*;
public class GameComplete extends AbstractSection {
private var _video:Video;
private var _resultText:TextField;
private var _playAgain:MovieClip;
private var _ratingText:TextField;
private var _submitScore:MovieClip;
private var _stream:NetStream;
private var _veronicasButton:SimpleButton;
private var _nameTxt:TextField;
private var _clip:MovieClip;
private var _seeLargeVideo:MovieClip;
private var _videoParent:DisplayObjectContainer;
private var _seeVideo:MovieClip;
private var _scoreText:TextField;
private var _getTheMusic:GetTheMusic;
private var _nameTextCleared:Boolean;// = false
private var _stuff:MovieClip;
private var _connection:NetConnection;
private static const WIN_TEXT:String = "Hell Yeah!";
private static const LOSE_TEXT:String = "It's All Over!";
public static var success:Boolean = false;
public static var score:int = 0;
public static var ratingText:String = "";
public function GameComplete(){
_clip = GeneralAssets.instance().createGameComplete();
addChild(_clip);
}
private function _onNameTextFocus(_arg1:Event=null):void{
if (_nameTextCleared){
return;
};
_nameTxt.text = "";
_nameTextCleared = true;
}
private function _onSubmitScoreClicked(_arg1:MouseEvent):void{
var _local2:String = _nameTxt.text;
if ((((_local2.length > 0)) && (_nameTextCleared))){
DoubleQuick.event(408);
_stuff.gotoAndStop("submitted");
_doSubmitScore();
};
}
override protected function init():void{
var _local1:String;
DoubleQuick.event(372);
_stuff = (_clip.getChildByName("stuff_mc") as MovieClip);
if (_stuff != null){
_playAgain = (_stuff.getChildByName("playAgain_mc") as MovieClip);
if (_playAgain != null){
_playAgain.addEventListener(MouseEvent.CLICK, _onPlayAgainClick);
_setupMovieClipAsButton(_playAgain, true);
keyboardNavigator.setDefaultAction(_onPlayAgainClick);
keyboardNavigator.addInteractiveObject(_playAgain, _onPlayAgainClick, 1);
} else {
KerbLog.instance().info("\"playAgain_mc\" missing from timeline");
};
_submitScore = (_stuff.getChildByName("submitScore_mc") as MovieClip);
if (_submitScore != null){
_submitScore.addEventListener(MouseEvent.CLICK, _onSubmitScoreClicked);
_setupMovieClipAsButton(_submitScore, true);
} else {
KerbLog.instance().info("\"submitScore_mc\" missing from timeline");
};
_resultText = (_stuff.getChildByName("result_txt") as TextField);
if (_resultText != null){
_resultText.text = (success) ? WIN_TEXT : LOSE_TEXT;
} else {
KerbLog.instance().info("\"result_txt\" missing from timeline");
};
_ratingText = (_stuff.getChildByName("rating_txt") as TextField);
if (_ratingText != null){
_ratingText.text = ratingText;
} else {
KerbLog.instance().info("\"rating_txt\" missing from timeline");
};
_scoreText = (_stuff.getChildByName("score_txt") as TextField);
if (_scoreText != null){
_local1 = score.toString();
while (_local1.length < 4) {
_local1 = ("0" + _local1);
};
_scoreText.text = _local1;
} else {
KerbLog.instance().info("\"score_txt\" missing from timeline");
};
_nameTxt = (_stuff.getChildByName("name_txt") as TextField);
if (_nameTxt != null){
_nameTextCleared = false;
_nameTxt.addEventListener(FocusEvent.FOCUS_IN, _onNameTextFocus);
} else {
KerbLog.instance().info("\"name_txt\" missing from timeline");
};
} else {
KerbLog.instance().info("\"stuff_mc\" missing from timeline");
};
_veronicasButton = (_clip.getChildByName("veronicas_btn") as SimpleButton);
if (_veronicasButton != null){
_veronicasButton.addEventListener(MouseEvent.CLICK, _onVeronicasLogoClicked);
};
_getTheMusic = new GetTheMusic((_clip.getChildByName("getTheMusic_mc") as MovieClip));
_getTheMusic.addEventListener(GetTheMusic.EVENT_CLICKED, _onGetTheMusicClicked);
_getTheMusic.addEventListener(GetTheMusic.EVENT_CLOSED, _onGetTheMusicClosed);
_seeVideo = (_clip.getChildByName("seeVideo_mc") as MovieClip);
if (_seeVideo != null){
_seeVideo.addEventListener(MouseEvent.CLICK, _onSeeVideoClicked);
_seeVideo.addEventListener(MouseEvent.ROLL_OVER, _onSeeVideoRolledOver);
_seeVideo.addEventListener(MouseEvent.ROLL_OUT, _onSeeVideoRolledOut);
_setupMovieClipAsButton(_seeVideo, true);
} else {
KerbLog.instance().info("\"seeVideo_mc\" missing from timeline");
};
_seeLargeVideo = (_clip.getChildByName("seeLargeVideo_mc") as MovieClip);
if (_seeLargeVideo != null){
_seeLargeVideo.addEventListener(MouseEvent.CLICK, _onSeeLargeVideoClicked);
_setupMovieClipAsButton(_seeLargeVideo, true);
} else {
KerbLog.instance().info("\"seeLargeVideo_mc\" missing from timeline");
};
_videoParent = (_clip.getChildByName("video_mc") as MovieClip);
if (_videoParent != null){
} else {
KerbLog.instance().info("\"video_mc\" missing from timeline");
};
_playVideo();
}
public function onCuePoint(_arg1:Object):void{
}
private function _playVideo():void{
_connection = new NetConnection();
_connection.connect(null);
_stream = new NetStream(_connection);
_stream.client = this;
_video = new Video(247, 148);
_video.rotation = -3.3;
_video.x = -125;
_video.y = -106;
_videoParent.addChild(_video);
_video.attachNetStream(_stream);
_stream.bufferTime = 1;
_stream.receiveAudio(true);
_stream.receiveVideo(true);
_stream.play(Config.instance().getVideoURL());
}
private function _stopVideo():void{
if (_stream != null){
_stream.close();
};
_stream = null;
if (_connection != null){
_connection.close();
};
_connection = null;
if (((((!((_videoParent == null))) && (!((_video == null))))) && (_videoParent.contains(_video)))){
_videoParent.removeChild(_video);
};
}
private function _onSeeLargeVideoClicked(_arg1:MouseEvent):void{
DoubleQuick.click(377);
}
private function _onVeronicasLogoClicked(_arg1:MouseEvent):void{
DoubleQuick.click(379);
}
private function _onGetTheMusicClicked(_arg1:Event):void{
_setupMovieClipAsButton(_seeVideo, false);
}
private function _onSeeVideoClicked(_arg1:MouseEvent):void{
DoubleQuick.click(377);
}
public function onMetaData(_arg1:Object):void{
}
private function _doSubmitScore():void{
KerbLog.instance().info("GameComplete::_doSubmitScore");
KerbLog.instance().info((" score is " + score.toString()));
KerbLog.instance().info(((" name is \"" + _nameTxt.text) + "\""));
var _local1:URLRequest = new URLRequest(Config.instance().getSaveScoreURL());
_local1.method = URLRequestMethod.POST;
var _local2:URLVariables = new URLVariables();
_local2.username = _nameTxt.text;
_local2.score = escape(Crypto.encrypt(score));
_local1.data = _local2;
var _local3:URLLoader = new URLLoader(_local1);
_local3.addEventListener(Event.COMPLETE, _onScoreSubmittedToServer);
_local3.dataFormat = URLLoaderDataFormat.VARIABLES;
_local3.load(_local1);
}
private function _onTransitionComplete(_arg1:Event):void{
gotoNextSection();
}
private function _onGetTheMusicClosed(_arg1:Event):void{
_setupMovieClipAsButton(_seeVideo, true);
}
private function _onScoreSubmittedToServer(_arg1:Event):void{
KerbLog.instance().info("GameComplete::_onScoreSubmittedToServer");
}
private function _onSeeVideoRolledOut(_arg1:MouseEvent):void{
_seeVideo.gotoAndStop("_up");
}
private function _onSeeVideoRolledOver(_arg1:MouseEvent):void{
_seeVideo.gotoAndPlay("_over");
}
private function _onPlayAgainClick(_arg1:MouseEvent=null):void{
DoubleQuick.event(373);
_playAgain.removeEventListener(MouseEvent.CLICK, _onPlayAgainClick);
_setupMovieClipAsButton(_playAgain, false);
success = false;
ratingText = "";
score = 0;
_stopVideo();
NextSectionClass = Game;
var _local2:Transition = new Transition();
_local2.addEventListener(Event.COMPLETE, _onTransitionComplete);
_local2.draw();
}
private static function _setupMovieClipAsButton(_arg1:MovieClip, _arg2:Boolean):void{
_arg1.mouseEnabled = _arg2;
_arg1.buttonMode = _arg2;
_arg1.useHandCursor = _arg2;
_arg1.mouseChildren = false;
}
}
}//package com.kerb.veronicas
Section 38
//GetTheMusic (com.kerb.veronicas.GetTheMusic)
package com.kerb.veronicas {
import flash.display.*;
import flash.events.*;
import com.kerb.logger.*;
import com.kerb.tracking.*;
public final class GetTheMusic extends EventDispatcher {
private var _buttonUK:MovieClip;
private var _getTheMusic:MovieClip;
private var _buttonDE:MovieClip;
private var _countries:MovieClip;
private var _closeCountries:MovieClip;
private var _buttonIT:MovieClip;
public static const EVENT_CLOSED:String = "EVENT_CLOSED";
public static const EVENT_CLICKED:String = "EVENT_CLICKED";
public function GetTheMusic(_arg1:MovieClip){
_getTheMusic = _arg1;
_init();
}
private function _onButtonUKClicked(_arg1:MouseEvent):void{
_getTheMusic.addEventListener(Event.COMPLETE, _onGetTheMusicClosed);
_getTheMusic.gotoAndPlay("close");
_enableCountries(false);
DoubleQuick.click(374);
}
private function _onGetTheMusicClicked(_arg1:MouseEvent):void{
_getTheMusic.removeEventListener(MouseEvent.CLICK, _onGetTheMusicClicked);
_getTheMusic.removeEventListener(MouseEvent.ROLL_OVER, _onGetTheMusicRolledOver);
_getTheMusic.removeEventListener(MouseEvent.ROLL_OUT, _onGetTheMusicRolledOut);
_getTheMusic.mouseChildren = true;
_getTheMusic.gotoAndPlay("open");
_enableCountries(true);
dispatchEvent(new Event(EVENT_CLICKED));
}
private function _onGetTheMusicRolledOver(_arg1:MouseEvent):void{
_getTheMusic.gotoAndStop("over");
}
private function _onButtonDEClicked(_arg1:MouseEvent):void{
_getTheMusic.addEventListener(Event.COMPLETE, _onGetTheMusicClosed);
_getTheMusic.gotoAndPlay("close");
_enableCountries(false);
DoubleQuick.click(375);
}
private function _onGetTheMusicRolledOut(_arg1:MouseEvent):void{
_getTheMusic.gotoAndStop("normal");
}
private function _onButtonITClicked(_arg1:MouseEvent):void{
_getTheMusic.addEventListener(Event.COMPLETE, _onGetTheMusicClosed);
_getTheMusic.gotoAndPlay("close");
_enableCountries(false);
DoubleQuick.click(376);
}
private function _onCloseCountriesClicked(_arg1:MouseEvent):void{
_getTheMusic.addEventListener(Event.COMPLETE, _onGetTheMusicClosed);
_getTheMusic.gotoAndPlay("close");
_enableCountries(false);
}
private function _init():void{
if (_getTheMusic != null){
_getTheMusic.addEventListener(MouseEvent.CLICK, _onGetTheMusicClicked);
_getTheMusic.addEventListener(MouseEvent.ROLL_OVER, _onGetTheMusicRolledOver);
_getTheMusic.addEventListener(MouseEvent.ROLL_OUT, _onGetTheMusicRolledOut);
_setupMovieClipAsButton(_getTheMusic, true);
} else {
KerbLog.instance().info("\"getTheMusic_mc\" missing from timeline");
};
}
private function _enableCountries(_arg1:Boolean):void{
if (((!((_getTheMusic == null))) && ((_countries == null)))){
_countries = (_getTheMusic.getChildByName("countries_mc") as MovieClip);
if (_countries != null){
_closeCountries = (_countries.getChildByName("close_mc") as MovieClip);
_buttonUK = (_countries.getChildByName("uk_mc") as MovieClip);
_buttonDE = (_countries.getChildByName("de_mc") as MovieClip);
_buttonIT = (_countries.getChildByName("it_mc") as MovieClip);
} else {
KerbLog.instance().info("\"countries_mc\" missing from timeline");
};
};
if (_arg1){
_closeCountries.addEventListener(MouseEvent.CLICK, _onCloseCountriesClicked);
_setupMovieClipAsButton(_closeCountries, true);
_buttonUK.addEventListener(MouseEvent.CLICK, _onButtonUKClicked);
_setupMovieClipAsButton(_buttonUK, true);
_buttonDE.addEventListener(MouseEvent.CLICK, _onButtonDEClicked);
_setupMovieClipAsButton(_buttonDE, true);
_buttonIT.addEventListener(MouseEvent.CLICK, _onButtonITClicked);
_setupMovieClipAsButton(_buttonIT, true);
} else {
_closeCountries.removeEventListener(MouseEvent.CLICK, _onCloseCountriesClicked);
_setupMovieClipAsButton(_closeCountries, false);
_closeCountries.gotoAndStop("_up");
_buttonUK.removeEventListener(MouseEvent.CLICK, _onButtonUKClicked);
_setupMovieClipAsButton(_buttonUK, false);
_buttonDE.removeEventListener(MouseEvent.CLICK, _onButtonDEClicked);
_setupMovieClipAsButton(_buttonDE, false);
_buttonIT.removeEventListener(MouseEvent.CLICK, _onButtonITClicked);
_setupMovieClipAsButton(_buttonIT, false);
};
}
private function _onGetTheMusicClosed(_arg1:Event):void{
_getTheMusic.gotoAndStop("normal");
_getTheMusic.addEventListener(MouseEvent.CLICK, _onGetTheMusicClicked);
_getTheMusic.addEventListener(MouseEvent.ROLL_OVER, _onGetTheMusicRolledOver);
_getTheMusic.addEventListener(MouseEvent.ROLL_OUT, _onGetTheMusicRolledOut);
_getTheMusic.mouseChildren = false;
dispatchEvent(new Event(EVENT_CLOSED));
}
private static function _setupMovieClipAsButton(_arg1:MovieClip, _arg2:Boolean):void{
_arg1.mouseEnabled = _arg2;
_arg1.buttonMode = _arg2;
_arg1.useHandCursor = _arg2;
_arg1.mouseChildren = false;
}
}
}//package com.kerb.veronicas
Section 39
//Main (com.kerb.veronicas.Main)
package com.kerb.veronicas {
import flash.events.*;
import com.kerb.veronicas.assets.*;
import com.kerb.sound.*;
import com.kerb.game.*;
public class Main extends AbstractMain {
public static var smMusic:SoundManager;
public static var smSFX:SoundManager;
public function Main(){
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function _start():void{
Transition.parent = stage;
Transition.clip = GeneralAssets.instance().createTransition();
var _local1:Transition = new Transition();
_local1.addEventListener(Event.COMPLETE, _onTransitionComplete);
_local1.draw();
}
override protected function onIdentComplete(_arg1:Event):void{
super.onIdentComplete(_arg1);
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
_initSounds();
_start();
}
private function _onTransitionComplete(_arg1:Event):void{
gotoSection(Title);
}
private function _initSounds():void{
smMusic = new SoundManager();
smSFX = new SoundManager();
smSFX.registerSound(GeneralAssets.instance().createSound("catchball_snd"));
smSFX.registerSound(GeneralAssets.instance().createSound("die_snd"));
}
}
}//package com.kerb.veronicas
Section 40
//Preloader (com.kerb.veronicas.Preloader)
package com.kerb.veronicas {
import flash.events.*;
import flash.display.*;
import com.kerb.game.*;
import com.kerb.utils.*;
import flash.utils.*;
public class Preloader extends AbstractPreload {
private var af:AssetFactory;
private var SWFBytes:Class;
public static var mc:MovieClip;
public function Preloader(){
SWFBytes = Preloader_SWFBytes;
super();
stop();
af = new AssetFactory();
af.addEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
af.initialize(SWFBytes);
}
private function onAssetFactoryReady(_arg1:Event):void{
af.removeEventListener(AssetFactory.EVENT_ASSET_FACTORY_READY, onAssetFactoryReady);
mc = (af.createDisplayObject("PreloadAsset") as MovieClip);
getContinueButton().visible = false;
getNoInternet().visible = false;
addChildAt(mc, 0);
af = null;
checkFlashvars();
drawLetterbox();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function checkFlashvars():void{
if (root.loaderInfo.parameters.locale){
Constants.locale = root.loaderInfo.parameters.locale;
};
}
private function drawLetterbox():void{
var _local1:int = loaderInfo.width;
var _local2:int = loaderInfo.height;
var _local3:Sprite = new Sprite();
var _local4:Graphics = _local3.graphics;
_local4.beginFill(0);
_local4.drawRect(-1000, -1000, (2000 + _local1), 1000);
_local4.drawRect(-1000, _local2, (2000 + _local1), 1000);
_local4.drawRect(-1000, -1000, 1000, (1000 + _local2));
_local4.drawRect(_local1, -1000, 1000, (1000 + _local2));
_local4.endFill();
addChild(_local3);
}
private function onEnterFrame(_arg1:Event):void{
var _local2:int = root.loaderInfo.bytesLoaded;
var _local3:int = root.loaderInfo.bytesTotal;
var _local4:int = Math.ceil(((100 * _local2) / _local3));
if (_local4 == 100){
preloadComplete();
};
}
private function preloadComplete():void{
var _local1:Class;
if (currentFrame == 1){
nextFrame();
} else {
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
_local1 = Class(getDefinitionByName("com.kerb.veronicas.Veronicas"));
addChild((new (_local1) as DisplayObject));
};
}
public static function hidePreloader():void{
if (mc.parent != null){
mc.parent.removeChild(mc);
};
}
public static function getNoInternet():MovieClip{
return ((mc.getChildByName("nointernet_mc") as MovieClip));
}
public static function getLoadingClip():MovieClip{
return ((mc.getChildByName("loading_mc") as MovieClip));
}
public static function getContinueButton():MovieClip{
return ((mc.getChildByName("continue_btn") as MovieClip));
}
}
}//package com.kerb.veronicas
Section 41
//Preloader_SWFBytes (com.kerb.veronicas.Preloader_SWFBytes)
package com.kerb.veronicas {
import mx.core.*;
public class Preloader_SWFBytes extends ByteArrayAsset {
}
}//package com.kerb.veronicas
Section 42
//Title (com.kerb.veronicas.Title)
package com.kerb.veronicas {
import flash.display.*;
import flash.events.*;
import com.kerb.logger.*;
import com.kerb.veronicas.assets.*;
import com.kerb.veronicas.game.*;
import com.kerb.game.*;
import com.kerb.tracking.*;
public class Title extends AbstractSection {
private var _veronicasButton:SimpleButton;
private var _playButton:MovieClip;
private var _getTheMusic:GetTheMusic;
private var _clip:MovieClip;
public function Title(){
_clip = GeneralAssets.instance().createTitle();
addChild(_clip);
}
private function _onPlayRolledOut(_arg1:MouseEvent):void{
_playButton.gotoAndStop("_up");
}
private function _onTransitionComplete(_arg1:Event):void{
gotoNextSection();
}
private function _onPlayRolledOver(_arg1:MouseEvent):void{
_playButton.gotoAndPlay("_over");
}
private function _onVeronicasLogoClicked(_arg1:MouseEvent):void{
DoubleQuick.click(379);
}
override protected function init():void{
_playButton = (_clip.getChildByName("play_mc") as MovieClip);
if (_playButton != null){
_playButton.addEventListener(MouseEvent.CLICK, _onPlayClicked);
_playButton.addEventListener(MouseEvent.ROLL_OVER, _onPlayRolledOver);
_playButton.addEventListener(MouseEvent.ROLL_OUT, _onPlayRolledOut);
_setupMovieClipAsButton(_playButton, true);
keyboardNavigator.setDefaultAction(_onPlayClicked);
keyboardNavigator.addInteractiveObject(_playButton, _onPlayClicked, 1);
} else {
KerbLog.instance().info("\"play_mc\" missing from timeline");
};
_veronicasButton = (_clip.getChildByName("veronicas_btn") as SimpleButton);
if (_veronicasButton != null){
_veronicasButton.addEventListener(MouseEvent.CLICK, _onVeronicasLogoClicked);
};
_getTheMusic = new GetTheMusic((_clip.getChildByName("getTheMusic_mc") as MovieClip));
_getTheMusic.addEventListener(GetTheMusic.EVENT_CLICKED, _onGetTheMusicClicked);
_getTheMusic.addEventListener(GetTheMusic.EVENT_CLOSED, _onGetTheMusicClosed);
}
private function _onPlayClicked(_arg1:MouseEvent=null):void{
_playButton.removeEventListener(MouseEvent.CLICK, _onPlayClicked);
NextSectionClass = Game;
var _local2:Transition = new Transition();
_local2.addEventListener(Event.COMPLETE, _onTransitionComplete);
_local2.draw();
}
private function _onGetTheMusicClosed(_arg1:Event):void{
_setupMovieClipAsButton(_playButton, true);
}
private function _onGetTheMusicClicked(_arg1:Event):void{
_setupMovieClipAsButton(_playButton, false);
}
override public function dispose():void{
super.dispose();
}
private static function _setupMovieClipAsButton(_arg1:MovieClip, _arg2:Boolean):void{
_arg1.mouseEnabled = _arg2;
_arg1.buttonMode = _arg2;
_arg1.useHandCursor = _arg2;
_arg1.mouseChildren = false;
}
}
}//package com.kerb.veronicas
Section 43
//Transition (com.kerb.veronicas.Transition)
package com.kerb.veronicas {
import flash.display.*;
import flash.events.*;
public final class Transition extends EventDispatcher {
private var _lastFrame:int;
public static var clip:MovieClip;
public static var parent:DisplayObjectContainer;
private function _onEnterFrame(_arg1:Event):void{
var _local2:int = clip.currentFrame;
if (_local2 == _lastFrame){
clip.removeEventListener(Event.ENTER_FRAME, _onEnterFrame);
if (parent.contains(clip)){
parent.removeChild(clip);
};
clip.visible = false;
};
_lastFrame = _local2;
}
public function draw():void{
if (!clip.hasEventListener(Event.COMPLETE)){
clip.addEventListener(Event.COMPLETE, _onClipComplete);
};
if (clip.parent == null){
parent.addChild(clip);
};
clip.visible = true;
clip.gotoAndPlay(1);
}
private function _onClipComplete(_arg1:Event):void{
clip.removeEventListener(Event.COMPLETE, _onClipComplete);
dispatchEvent(_arg1);
_lastFrame = clip.currentFrame;
clip.addEventListener(Event.ENTER_FRAME, _onEnterFrame);
}
}
}//package com.kerb.veronicas
Section 44
//Veronicas (com.kerb.veronicas.Veronicas)
package com.kerb.veronicas {
import flash.display.*;
import flash.events.*;
import com.kerb.logger.*;
import com.kerb.veronicas.assets.*;
import com.kerb.veronicas.game.*;
import flash.net.*;
import com.kerb.tracking.*;
import flash.ui.*;
public class Veronicas extends Sprite {
private var _gameAssetsReady:Boolean;
private var _songLoaded:Boolean;
private var _xml:XML;
private var _art:MovieClip;
private var _generalAssetsReady:Boolean;
public function Veronicas(){
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}
private function _songProgress(_arg1:ProgressEvent):void{
var _local2:SongFLV = (_arg1.target as SongFLV);
var _local3:Number = (_arg1.bytesLoaded / _arg1.bytesTotal);
var _local4:uint = Math.floor((100 * _local3));
if (_local4 >= 100){
_local2.removeEventListener(ProgressEvent.PROGRESS, _songProgress);
_songLoaded = true;
_somethingFinishedLoading();
};
}
private function onKeyDown(_arg1:KeyboardEvent):void{
if ((((_arg1.keyCode == Keyboard.SPACE)) || ((_arg1.keyCode == Keyboard.ENTER)))){
_start();
};
}
private function _onXMLLoadSuccess(_arg1:Event):void{
Config.instance().init(new XML(_arg1.target.data));
_preloadArt();
}
private function _initTracking():void{
DoubleQuick.init(root, 93);
DoubleQuick.event(367);
}
private function _onXMLLoadFailure(_arg1:IOErrorEvent):void{
Preloader.getNoInternet().visible = true;
}
private function _onArtCompleteHandler(_arg1:Event):void{
var e = _arg1;
var contentLoaderInfo:LoaderInfo = (e.target as LoaderInfo);
try {
_art = (contentLoaderInfo.content as MovieClip);
addChildAt(_art, 0);
_preloadSong();
} catch(error:SecurityError) {
KerbLog.instance().info(error.message);
};
}
private function _loadConfigXML():void{
var _local2:String;
var _local1:URLLoader = new URLLoader();
_local1.addEventListener(Event.COMPLETE, _onXMLLoadSuccess);
_local1.addEventListener(IOErrorEvent.IO_ERROR, _onXMLLoadFailure);
if (Constants.USE_LOCAL_CONFIG_XML){
_local2 = Constants.MASTER_XML_FILE;
} else {
_local2 = (Constants.MASTER_XML_URL + Constants.MASTER_XML_FILE);
};
_local1.load(new URLRequest(_local2));
}
private function _onArtProgressHandler(_arg1:Event):void{
}
private function _onGameAssetsReady(_arg1:Event):void{
GameAssets.instance().removeEventListener(Event.COMPLETE, _onGameAssetsReady);
_gameAssetsReady = true;
_somethingFinishedLoading();
}
private function onAddedToStage(_arg1:Event):void{
removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
GeneralAssets.instance().addEventListener(Event.COMPLETE, _onGeneralAssetsReady);
GameAssets.instance().addEventListener(Event.COMPLETE, _onGameAssetsReady);
KerbLog.instance().stage = stage;
KerbLog.instance().level = KerbLogLevel.None;
var _local2:int = loaderInfo.width;
var _local3:int = loaderInfo.height;
var _local4:Sprite = new Sprite();
var _local5:Graphics = _local4.graphics;
_local5.beginFill(0);
_local5.drawRect(-1000, -1000, (2000 + _local2), 1000);
_local5.drawRect(-1000, _local3, (2000 + _local2), 1000);
_local5.drawRect(-1000, -1000, 1000, (1000 + _local3));
_local5.drawRect(_local2, -1000, 1000, (1000 + _local3));
_local5.endFill();
addChild(_local4);
_loadConfigXML();
}
private function _start(_arg1:Event=null):void{
stage.removeEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
var _local2:MovieClip = Preloader.getContinueButton();
if (_local2 != null){
_local2.removeEventListener(MouseEvent.CLICK, _start);
};
var _local3:SimpleButton = (Preloader.mc.getChildByName("veronicas_btn") as SimpleButton);
if (_local3 != null){
_local3.removeEventListener(MouseEvent.CLICK, _onVeronicasLogoClicked);
};
if (((!((_art == null))) && (contains(_art)))){
removeChild(_art);
};
_art = null;
Preloader.hidePreloader();
addChildAt(new Main(), 0);
}
private function _onVeronicasLogoClicked(_arg1:MouseEvent):void{
DoubleQuick.click(379);
}
private function _onArtIOErrorHandler(_arg1:Event):void{
Preloader.getNoInternet().visible = true;
}
private function _somethingFinishedLoading():void{
if (((((!(_songLoaded)) || (!(_generalAssetsReady)))) || (!(_gameAssetsReady)))){
return;
};
_initTracking();
var _local1:SimpleButton = (Preloader.mc.getChildByName("veronicas_btn") as SimpleButton);
if (_local1 != null){
_local1.addEventListener(MouseEvent.CLICK, _onVeronicasLogoClicked);
};
var _local2:MovieClip = Preloader.getContinueButton();
if (_local2 != null){
_local2.visible = true;
_setupMovieClipAsButton(_local2, true);
_local2.addEventListener(MouseEvent.CLICK, _start);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
} else {
_start();
};
var _local3:MovieClip = Preloader.getLoadingClip();
if (_local3 != null){
_local3.visible = false;
};
}
private function _onGeneralAssetsReady(_arg1:Event):void{
GeneralAssets.instance().removeEventListener(Event.COMPLETE, _onGeneralAssetsReady);
_generalAssetsReady = true;
_somethingFinishedLoading();
}
private function _preloadArt():void{
var _local1:URLRequest = new URLRequest(Config.instance().getArtURL());
var _local2:Loader = new Loader();
_local2.contentLoaderInfo.addEventListener(Event.COMPLETE, _onArtCompleteHandler);
_local2.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, _onArtProgressHandler);
_local2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, _onArtIOErrorHandler);
_local2.load(_local1);
}
private function _preloadSong():void{
var _local1:SongFLV = new SongFLV(Config.instance().getSongURL());
Config.instance().setSong(_local1);
_local1.addEventListener(ProgressEvent.PROGRESS, _songProgress);
}
private static function _setupMovieClipAsButton(_arg1:MovieClip, _arg2:Boolean):void{
_arg1.mouseEnabled = _arg2;
_arg1.buttonMode = _arg2;
_arg1.useHandCursor = _arg2;
_arg1.mouseChildren = false;
}
}
}//package com.kerb.veronicas
Section 45
//Array2 (de.polygonal.ds.Array2)
package de.polygonal.ds {
public class Array2 implements Collection {
private var _a:Array;
private var _h:int;
private var _w:int;
public function Array2(_arg1:int, _arg2:int){
if ((((_arg1 < 2)) || ((_arg2 < 2)))){
throw (new Error("illegal size"));
};
_a = new Array((_w = _arg1), (_h = _arg2));
fill(null);
}
public function get size():int{
return ((_w * _h));
}
public function fill(_arg1):void{
var _local3:int;
var _local4:Class;
var _local2:int = (_w * _h);
if ((_arg1 is Class)){
_local4 = (_arg1 as Class);
_local3 = 0;
while (_local3 < _local2) {
_a[_local3] = new (_local4);
_local3++;
};
} else {
_local3 = 0;
while (_local3 < _local2) {
_a[_local3] = _arg1;
_local3++;
};
};
}
public function get width():int{
return (_w);
}
public function getCol(_arg1:int):Array{
var _local2:Array = [];
var _local3:int;
while (_local3 < _h) {
_local2[_local3] = _a[int(((_local3 * _w) + _arg1))];
_local3++;
};
return (_local2);
}
public function shiftDown():void{
if (_h == 1){
return;
};
var _local1:int = ((_h - 1) * _w);
_a = _a.slice(_local1, (_local1 + _w)).concat(_a);
_a.splice((_h * _w), _w);
}
public function set width(_arg1:int):void{
resize(_arg1, _h);
}
public function appendCol(_arg1:Array):void{
_arg1.length = _h;
var _local2:int;
while (_local2 < _h) {
_a.splice((((_local2 * _w) + _w) + _local2), 0, _arg1[_local2]);
_local2++;
};
_w++;
}
public function set height(_arg1:int):void{
resize(_w, _arg1);
}
public function clear():void{
_a = new Array(size);
}
public function get(_arg1:int, _arg2:int){
return (_a[int(((_arg2 * _w) + _arg1))]);
}
public function setRow(_arg1:uint, _arg2:Array):void{
if ((((_arg1 < 0)) || ((_arg1 > _h)))){
throw (new Error("row index out of bounds"));
};
var _local3:int = (_arg1 * _w);
var _local4:int;
while (_local4 < _w) {
_a[int((_local3 + _local4))] = _arg2[_local4];
_local4++;
};
}
public function prependCol(_arg1:Array):void{
_arg1.length = _h;
var _local2:int;
while (_local2 < _h) {
_a.splice(((_local2 * _w) + _local2), 0, _arg1[_local2]);
_local2++;
};
_w++;
}
public function isEmpty():Boolean{
return (false);
}
public function toArray():Array{
var _local1:Array = _a.concat();
var _local2:int = size;
if (_local1.length > _local2){
_local1.length = _local2;
};
return (_local1);
}
public function contains(_arg1):Boolean{
var _local2:int = size;
var _local3:int;
while (_local3 < _local2) {
if (_a[_local3] === _arg1){
return (true);
};
_local3++;
};
return (false);
}
public function appendRow(_arg1:Array):void{
_arg1.length = _w;
_a = _a.concat(_arg1);
_h++;
}
public function dump():String{
var _local2:int;
var _local3:*;
var _local5:int;
var _local1 = "Array2\n{";
var _local4:int;
while (_local4 < _h) {
_local1 = (_local1 + ("\n" + "\t"));
_local2 = (_local4 * _w);
_local5 = 0;
while (_local5 < _w) {
_local3 = _a[int((_local2 + _local5))];
_local1 = (_local1 + (("[" + ((_local3)!=undefined) ? _local3 : "?") + "]"));
_local5++;
};
_local4++;
};
_local1 = (_local1 + "\n}");
return (_local1);
}
public function getArray():Array{
return (_a);
}
public function getRow(_arg1:int):Array{
var _local2:int = (_arg1 * _w);
return (_a.slice(_local2, (_local2 + _w)));
}
public function get height():int{
return (_h);
}
public function shiftLeft():void{
var _local2:int;
if (_w == 1){
return;
};
var _local1:int = (_w - 1);
var _local3:int;
while (_local3 < _h) {
_local2 = ((_local3 * _w) + _local1);
_a.splice(_local2, 0, _a.splice((_local2 - _local1), 1));
_local3++;
};
}
public function getIterator():Iterator{
return (new Array2Iterator(this));
}
public function prependRow(_arg1:Array):void{
_arg1.length = _w;
_a = _arg1.concat(_a);
_h++;
}
public function set(_arg1:int, _arg2:int, _arg3):void{
_a[int(((_arg2 * _w) + _arg1))] = _arg3;
}
public function resize(_arg1:int, _arg2:int):void{
var _local6:int;
var _local7:int;
var _local8:int;
var _local9:int;
if ((((_arg1 < 2)) || ((_arg2 < 2)))){
throw (new Error("illegal size"));
};
var _local3:Array = _a.concat();
_a.length = 0;
_a.length = (_arg1 * _arg2);
var _local4:int = ((_arg1 < _w)) ? _arg1 : _w;
var _local5:int = ((_arg2 < _h)) ? _arg2 : _h;
_local7 = 0;
while (_local7 < _local5) {
_local8 = (_local7 * _arg1);
_local9 = (_local7 * _w);
_local6 = 0;
while (_local6 < _local4) {
_a[int((_local8 + _local6))] = _local3[int((_local9 + _local6))];
_local6++;
};
_local7++;
};
_w = _arg1;
_h = _arg2;
}
public function transpose():void{
var _local3:int;
var _local1:Array = _a.concat();
var _local2:int;
while (_local2 < _h) {
_local3 = 0;
while (_local3 < _w) {
_a[int(((_local3 * _w) + _local2))] = _local1[int(((_local2 * _w) + _local3))];
_local3++;
};
_local2++;
};
}
public function shiftRight():void{
var _local2:int;
if (_w == 1){
return;
};
var _local1:int = (_w - 1);
var _local3:int;
while (_local3 < _h) {
_local2 = ((_local3 * _w) + _local1);
_a.splice((_local2 - _local1), 0, _a.splice(_local2, 1));
_local3++;
};
}
public function toString():String{
return ((((("[Array2, width=" + width) + ", height=") + height) + "]"));
}
public function shiftUp():void{
if (_h == 1){
return;
};
_a = _a.concat(_a.slice(0, _w));
_a.splice(0, _w);
}
public function setCol(_arg1:int, _arg2:Array):void{
if ((((_arg1 < 0)) || ((_arg1 > _w)))){
throw (new Error("column index out of bounds"));
};
var _local3:int;
while (_local3 < _h) {
_a[int(((_local3 * _w) + _arg1))] = _arg2[_local3];
_local3++;
};
}
}
}//package de.polygonal.ds
class Array2Iterator implements Iterator {
private var _xCursor:int;
private var _a2:Array2;
private var _yCursor:int;
private function Array2Iterator(_arg1:Array2){
_a2 = _arg1;
_xCursor = (_yCursor = 0);
}
public function start():void{
_xCursor = (_yCursor = 0);
}
public function hasNext():Boolean{
return ((((_yCursor * _a2.width) + _xCursor) < _a2.size));
}
public function get data(){
return (_a2.get(_xCursor, _yCursor));
}
public function set data(_arg1):void{
_a2.set(_xCursor, _yCursor, _arg1);
}
public function next(){
var _local1:* = data;
if (++_xCursor == _a2.width){
_yCursor++;
_xCursor = 0;
};
return (_local1);
}
}
Section 46
//ArrayedQueue (de.polygonal.ds.ArrayedQueue)
package de.polygonal.ds {
public class ArrayedQueue implements Collection {
private var _que:Array;
private var _count:int;
private var _size:int;
private var _front:int;
private var _divisor:int;
public function ArrayedQueue(_arg1:int){
init(_arg1);
}
public function get size():int{
return (_count);
}
public function isEmpty():Boolean{
return ((_count == 0));
}
public function get maxSize():int{
return (_size);
}
public function enqueue(_arg1):Boolean{
if (_size != _count){
_que[int(((_count++ + _front) & _divisor))] = _arg1;
return (true);
};
return (false);
}
public function clear():void{
_que = new Array(_size);
_front = (_count = 0);
var _local1:int;
while (_local1 < _size) {
_que[_local1] = null;
_local1++;
};
}
private function init(_arg1:int):void{
if (!(((_arg1 > 0)) && (((_arg1 & (_arg1 - 1)) == 0)))){
_arg1 = (_arg1 | (_arg1 >> 1));
_arg1 = (_arg1 | (_arg1 >> 2));
_arg1 = (_arg1 | (_arg1 >> 4));
_arg1 = (_arg1 | (_arg1 >> 8));
_arg1 = (_arg1 | (_arg1 >> 16));
_arg1++;
};
_size = _arg1;
_divisor = (_arg1 - 1);
clear();
}
public function peek(){
return (_que[_front]);
}
public function toArray():Array{
var _local1:Array = new Array(_count);
var _local2:int;
while (_local2 < _count) {
_local1[_local2] = _que[int(((_local2 + _front) & _divisor))];
_local2++;
};
return (_local1);
}
public function contains(_arg1):Boolean{
var _local2:int;
while (_local2 < _count) {
if (_que[int(((_local2 + _front) & _divisor))] === _arg1){
return (true);
};
_local2++;
};
return (false);
}
public function getIterator():Iterator{
return (new ArrayedQueueIterator(this));
}
public function dispose():void{
if (!_front){
_que[int((_size - 1))] = null;
} else {
_que[int((_front - 1))] = null;
};
}
public function back(){
return (_que[int((((_count - 1) + _front) & _divisor))]);
}
public function getAt(_arg1:int){
if (_arg1 >= _count){
return (null);
};
return (_que[int(((_arg1 + _front) & _divisor))]);
}
public function toString():String{
return ((("[ArrayedQueue, size=" + size) + "]"));
}
public function dequeue(){
var _local1:*;
if (_count > 0){
_local1 = _que[int(_front++)];
if (_front == _size){
_front = 0;
};
_count--;
return (_local1);
};
return (null);
}
public function dump():String{
var _local2:int;
var _local1 = "[ArrayedQueue]\n";
_local1 = (_local1 + (("\t" + getAt(_local2)) + " -> front\n"));
_local2 = 1;
while (_local2 < _count) {
_local1 = (_local1 + (("\t" + getAt(_local2)) + "\n"));
_local2++;
};
return (_local1);
}
public function setAt(_arg1:int, _arg2):void{
if (_arg1 >= _count){
return;
};
_que[int(((_arg1 + _front) & _divisor))] = _arg2;
}
}
}//package de.polygonal.ds
class ArrayedQueueIterator implements Iterator {
private var _que:ArrayedQueue;
private var _cursor:int;
private function ArrayedQueueIterator(_arg1:ArrayedQueue){
_que = _arg1;
_cursor = 0;
}
public function get data(){
return (_que.getAt(_cursor));
}
public function next(){
if (_cursor < _que.size){
return (_que.getAt(_cursor++));
};
return (null);
}
public function hasNext():Boolean{
return ((_cursor < _que.size));
}
public function set data(_arg1):void{
_que.setAt(_cursor, _arg1);
}
public function start():void{
_cursor = 0;
}
}
Section 47
//BinaryTreeNode (de.polygonal.ds.BinaryTreeNode)
package de.polygonal.ds {
public class BinaryTreeNode {
public var left:BinaryTreeNode;
public var data;
public var parent:BinaryTreeNode;
public var right:BinaryTreeNode;
public function BinaryTreeNode(_arg1){
this.data = _arg1;
parent = (left = (right = null));
}
public function destroy():void{
if (left){
left.destroy();
};
left = null;
if (right){
right.destroy();
};
right = null;
}
public function setLeft(_arg1):void{
if (!left){
left = new BinaryTreeNode(_arg1);
left.parent = this;
} else {
left.data = data;
};
}
public function toString():String{
return ((("[BinaryTreeNode, data= " + data) + "]"));
}
public function getDepth(_arg1:BinaryTreeNode=null):int{
var _local2 = -1;
var _local3 = -1;
if (_arg1 == null){
_arg1 = this;
};
if (_arg1.left){
_local2 = getDepth(_arg1.left);
};
if (_arg1.right){
_local3 = getDepth(_arg1.right);
};
return ((((_local2 > _local3)) ? _local2 : _local3 + 1));
}
public function count():int{
var _local1 = 1;
if (left){
_local1 = (_local1 + left.count());
};
if (right){
_local1 = (_local1 + right.count());
};
return (_local1);
}
public function isLeft():Boolean{
return ((this == parent.left));
}
public function isRight():Boolean{
return ((this == parent.right));
}
public function setRight(_arg1):void{
if (!right){
right = new BinaryTreeNode(_arg1);
right.parent = this;
} else {
right.data = data;
};
}
public static function inorder(_arg1:BinaryTreeNode, _arg2:Function):void{
if (_arg1){
if (_arg1.left){
BinaryTreeNode.inorder(_arg1.left, _arg2);
};
_arg2(_arg1);
if (_arg1.right){
BinaryTreeNode.inorder(_arg1.right, _arg2);
};
};
}
public static function preorder(_arg1:BinaryTreeNode, _arg2:Function):void{
if (_arg1){
_arg2(_arg1);
if (_arg1.left){
BinaryTreeNode.preorder(_arg1.left, _arg2);
};
if (_arg1.right){
BinaryTreeNode.preorder(_arg1.right, _arg2);
};
};
}
public static function postorder(_arg1:BinaryTreeNode, _arg2:Function):void{
if (_arg1){
if (_arg1.left){
BinaryTreeNode.postorder(_arg1.left, _arg2);
};
if (_arg1.right){
BinaryTreeNode.postorder(_arg1.right, _arg2);
};
_arg2(_arg1);
};
}
}
}//package de.polygonal.ds
Section 48
//Collection (de.polygonal.ds.Collection)
package de.polygonal.ds {
public interface Collection {
function get size():int;
function isEmpty():Boolean;
function getIterator():Iterator;
function clear():void;
function toArray():Array;
function contains(_arg1):Boolean;
}
}//package de.polygonal.ds
Section 49
//Iterator (de.polygonal.ds.Iterator)
package de.polygonal.ds {
public interface Iterator {
function start():void;
function set data(_arg1):void;
function get data();
function next();
function hasNext():Boolean;
}
}//package de.polygonal.ds
Section 50
//BroadPhase (de.polygonal.motor2.collision.nbody.BroadPhase)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
public interface BroadPhase {
function findPairs():void;
function moveProxy(_arg1:int):void;
function setWorldBounds(_arg1:AABB2):void;
function queryAABB(_arg1:AABB2, _arg2:Array, _arg3:int=2147483647):int;
function setPairHandler(_arg1:PairCallback):void;
function insideBounds(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean;
function createProxy(_arg1:ShapeSkeleton):int;
function destroyProxy(_arg1:int):void;
function deconstruct():void;
function getProxy(_arg1:int):Proxy;
function getProxyList():Array;
function queryCircle(_arg1:Circle2, _arg2:Array, _arg3:int=2147483647):int;
}
}//package de.polygonal.motor2.collision.nbody
Section 51
//BufferedPair (de.polygonal.motor2.collision.nbody.BufferedPair)
package de.polygonal.motor2.collision.nbody {
public class BufferedPair extends UnbufferedPair {
public var bits:int;
public var next:int;
public static const PAIR_FINAL:int = 4;
public static const PAIR_BUFFERED:int = 1;
public static const PAIR_ACTIVE:int = 8;
public static const PAIR_REMOVED:int = 2;
public function getFinal():Boolean{
return (((bits & PAIR_FINAL) == PAIR_FINAL));
}
public function setBuffered():void{
bits = (bits | PAIR_BUFFERED);
}
public function clrBuffered():void{
bits = (bits & ~(PAIR_BUFFERED));
}
public function getRemoved():Boolean{
return (((bits & PAIR_REMOVED) == PAIR_REMOVED));
}
public function setFinal():void{
bits = (bits | PAIR_FINAL);
}
public function getBuffered():Boolean{
return (((bits & PAIR_BUFFERED) == PAIR_BUFFERED));
}
public function clrRemoved():void{
bits = (bits & ~(PAIR_REMOVED));
}
public function setRemoved():void{
bits = (bits | PAIR_REMOVED);
}
}
}//package de.polygonal.motor2.collision.nbody
Section 52
//BufferedPairManager (de.polygonal.motor2.collision.nbody.BufferedPairManager)
package de.polygonal.motor2.collision.nbody {
import flash.utils.*;
public class BufferedPairManager {
public var _callback:PairCallback;
private var _freePair:int;
private var _pairTable:Dictionary;
private var _pairCount:int;
public var _broadPhase:BroadPhase;
private var _pairBuffer:Array;
private var _pairs:Array;
private var _pairBufferCount:int;
public static const NULL_PAIR:int = 0xFFFF;
public function BufferedPairManager(_arg1:int, _arg2:PairCallback, _arg3:BroadPhase){
var _local4:BufferedPair;
var _local5:int;
super();
_callback = _arg2;
_broadPhase = _arg3;
_pairTable = new Dictionary(true);
_pairs = new Array((_arg1 + 1), true);
_local5 = 1;
while (_local5 < (_arg1 + 1)) {
_local4 = new BufferedPair();
_local4.proxyId1 = Proxy.NULL_PROXY;
_local4.proxyId2 = Proxy.NULL_PROXY;
_local4.contact = null;
_local4.bits = 0;
_local4.next = (_local5 + 1);
_pairs[_local5] = _local4;
_local5++;
};
_pairs[_arg1].next = NULL_PAIR;
_freePair = 1;
_pairCount = 0;
_pairBufferCount = 0;
_pairBuffer = new Array(_arg1, true);
_local5 = 0;
while (_local5 < _arg1) {
_pairBuffer[_local5] = new BufferedPair();
_local5++;
};
}
private function getKey(_arg1:int, _arg2:int):int{
if (_arg1 < _arg2){
return (((_arg1 << 16) | _arg2));
};
return (((_arg2 << 16) | _arg1));
}
public function commit():void{
var _local1:BufferedPair;
var _local3:int;
var _local4:int;
var _local5:BufferedPair;
var _local7:Proxy;
var _local8:Proxy;
var _local2:int;
var _local6:int;
while (_local6 < _pairBufferCount) {
_local1 = _pairBuffer[_local6];
_local3 = getKey(_local1.proxyId1, _local1.proxyId2);
_local4 = _pairTable[_local3];
_local5 = _pairs[_local4];
_local5.clrBuffered();
_local7 = _broadPhase.getProxy(_local5.proxyId1);
_local8 = _broadPhase.getProxy(_local5.proxyId2);
if (_local5.getRemoved()){
if (_local5.getFinal()){
_callback.pairRemoved(_local5.contact);
};
_local1 = _pairBuffer[_local2];
_local1.proxyId1 = _local5.proxyId1;
_local1.proxyId2 = _local5.proxyId2;
_local2++;
} else {
if (!_local5.getFinal()){
_local5.contact = _callback.pairAdded(_local7.shape, _local8.shape);
_local5.setFinal();
};
};
_local6++;
};
_local6 = 0;
while (_local6 < _local2) {
_local1 = _pairBuffer[_local6];
_local3 = getKey(_local1.proxyId1, _local1.proxyId2);
_local4 = _pairTable[_local3];
delete _pairTable[_local3];
_local5 = _pairs[_local4];
_local5.proxyId1 = Proxy.NULL_PROXY;
_local5.proxyId2 = Proxy.NULL_PROXY;
_local5.bits = 0;
_local5.contact = null;
_local5.next = _freePair;
_freePair = _local4;
_pairCount--;
_local6++;
};
_pairBufferCount = 0;
}
public function addPair(_arg1:int, _arg2:int):void{
var _local4:BufferedPair;
var _local6:BufferedPair;
var _local3:int = getKey(_arg1, _arg2);
var _local5:int = _pairTable[_local3];
if (_local5 == 0){
_local5 = _freePair;
_pairTable[_local3] = _local5;
_local4 = _pairs[_local5];
_local4.proxyId1 = _arg1;
_local4.proxyId2 = _arg2;
_local4.bits = 0;
_local4.contact = null;
_freePair = _local4.next;
_pairCount++;
} else {
_local4 = _pairs[_local5];
};
if (!_local4.getBuffered()){
_local4.setBuffered();
_local6 = _pairBuffer[_pairBufferCount];
_local6.proxyId1 = _local4.proxyId1;
_local6.proxyId2 = _local4.proxyId2;
_pairBufferCount++;
};
_local4.clrRemoved();
}
public function removePair(_arg1:int, _arg2:int):void{
var _local6:BufferedPair;
var _local3:int = getKey(_arg1, _arg2);
var _local4:int = _pairTable[_local3];
if (_local4 == 0){
return;
};
var _local5:BufferedPair = _pairs[_local4];
if (!_local5.getBuffered()){
_local5.setBuffered();
_local6 = _pairBuffer[_pairBufferCount];
_local6.proxyId1 = _local5.proxyId1;
_local6.proxyId2 = _local5.proxyId2;
_pairBufferCount++;
};
_local5.setRemoved();
}
}
}//package de.polygonal.motor2.collision.nbody
Section 53
//ExhaustiveSearch (de.polygonal.motor2.collision.nbody.ExhaustiveSearch)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.*;
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import flash.system.*;
public class ExhaustiveSearch implements BroadPhase {
private var _xmax:Number;
private var _ymin:Number;
private var _proxyCount:int;
private var _freeProxy:int;
private var _ymax:Number;
private var _proxyPool:Array;
private var _proxyList:LinkedProxy;
private var _pairManager:UnbufferedPairManager;
private var _xmin:Number;
public function ExhaustiveSearch(){
var _local3:LinkedProxy;
super();
var _local1:uint = System.totalMemory;
var _local2:int = Constants.k_maxProxies;
_proxyPool = new Array(_local2, true);
var _local4:int;
while (_local4 < (_local2 - 1)) {
_local3 = new LinkedProxy();
_local3.setNext((_local4 + 1));
_local3.id = _local4;
_proxyPool[_local4] = _local3;
_local4++;
};
_local3 = new LinkedProxy();
_local3.setNext(Proxy.NULL_PROXY);
_local3.id = (_local2 - 1);
_proxyPool[(_local2 - 1)] = _local3;
trace("/*////////////////////////////////////////////////////////*");
trace(" * EXHAUSTIVE SEARCH STATISTICS");
trace((" * max proxies = " + _local2));
trace(((" * memory = " + ((System.totalMemory - _local1) >> 10)) + " KiB"));
trace(" ////////////////////////////////////////////////////////*/");
trace("");
}
public function getProxyList():Array{
var _local2:int;
var _local1:Array = new Array(_proxyCount, true);
var _local3:LinkedProxy = _proxyList;
while (_local3 != null) {
var _temp1 = _local2;
_local2 = (_local2 + 1);
var _local4 = _temp1;
_local1[_local4] = _local3;
_local3 = _local3.next;
};
return (_local1);
}
public function getProxy(_arg1:int):Proxy{
return (_proxyPool[_arg1]);
}
public function insideBounds(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
if (_arg1 < _xmin){
return (false);
};
if (_arg3 > _xmax){
return (false);
};
if (_arg2 < _ymin){
return (false);
};
if (_arg4 > _ymax){
return (false);
};
return (true);
}
public function createProxy(_arg1:ShapeSkeleton):int{
var _local2:int = _freeProxy;
var _local3:LinkedProxy = _proxyPool[_local2];
_freeProxy = _local3.getNext();
_local3.next = _proxyList;
if (_proxyList){
_proxyList.prev = _local3;
};
_proxyList = _local3;
_local3.shape = _arg1;
_proxyCount++;
return (_local2);
}
public function setPairHandler(_arg1:PairCallback):void{
_pairManager = new UnbufferedPairManager(_arg1, this);
}
public function destroyProxy(_arg1:int):void{
var _local5:ShapeSkeleton;
if (_arg1 == Proxy.NULL_PROXY){
return;
};
var _local2:LinkedProxy = _proxyPool[_arg1];
var _local3:LinkedProxy = _proxyList;
var _local4:ShapeSkeleton = _local2.shape;
var _local6:Number = _local4.xmin;
var _local7:Number = _local4.xmax;
var _local8:Number = _local4.ymin;
var _local9:Number = _local4.ymax;
while (_local3 != null) {
if (_local2 == _local3){
_local3 = _local3.next;
} else {
_local5 = _local3.shape;
if ((((((((_local6 > _local5.xmax)) || ((_local7 < _local5.xmin)))) || ((_local8 > _local5.ymax)))) || ((_local9 < _local5.ymin)))){
_local3 = _local3.next;
} else {
if (_pairManager.removePair(_arg1, _local3.id)){
_local3.overlapCount--;
};
_local3 = _local3.next;
};
};
};
if (_local2.prev){
_local2.prev.next = _local2.next;
};
if (_local2.next){
_local2.next.prev = _local2.prev;
};
if (_local2 == _proxyList){
_proxyList = _local2.next;
};
_local2.setNext(_freeProxy);
_freeProxy = _arg1;
_local2.reset();
_proxyCount--;
}
public function moveProxy(_arg1:int):void{
}
public function setWorldBounds(_arg1:AABB2):void{
_xmin = _arg1.xmin;
_ymin = _arg1.ymin;
_xmax = _arg1.xmax;
_ymax = _arg1.ymax;
}
public function findPairs():void{
var _local1:LinkedProxy;
var _local2:ShapeSkeleton;
var _local3:LinkedProxy;
var _local4:ShapeSkeleton;
_local1 = _proxyList;
while (_local1 != null) {
_local2 = _local1.shape;
_local3 = _local1.next;
while (_local3 != null) {
_local4 = _local3.shape;
if ((((((((_local2.xmin > _local4.xmax)) || ((_local2.xmax < _local4.xmin)))) || ((_local2.ymin > _local4.ymax)))) || ((_local2.ymax < _local4.ymin)))){
if ((_local1.overlapCount * _local3.overlapCount) > 0){
if (_pairManager.removePair(_local1.id, _local3.id)){
_local1.overlapCount++;
_local3.overlapCount++;
};
};
} else {
if (_pairManager.addPair(_local1.id, _local3.id)){
_local1.overlapCount++;
_local3.overlapCount++;
};
};
_local3 = _local3.next;
};
_local1 = _local1.next;
};
}
public function queryAABB(_arg1:AABB2, _arg2:Array, _arg3:int=2147483647):int{
var _local9:ShapeSkeleton;
if (_arg2.fixed){
_arg3 = _arg2.length;
};
var _local4:Number = _arg1.xmin;
var _local5:Number = _arg1.xmax;
var _local6:Number = _arg1.ymin;
var _local7:Number = _arg1.ymax;
var _local8:LinkedProxy = _proxyList;
var _local10:int;
while (_local8 != null) {
_local9 = _local8.shape;
if ((((((((_local9.xmin > _local5)) || ((_local9.xmax < _local4)))) || ((_local9.ymin > _local7)))) || ((_local9.ymax < _local6)))){
_local8 = _local8.next;
} else {
var _temp1 = _local10;
_local10 = (_local10 + 1);
var _local11 = _temp1;
_arg2[_local11] = _local9;
if (_local10 == _arg3){
break;
};
_local8 = _local8.next;
};
};
return (_local10);
}
public function deconstruct():void{
var _local1:LinkedProxy;
var _local2:LinkedProxy = _proxyList;
while (_local2 != null) {
_local1 = _local2;
_local2 = _local2.next;
_local1.next = null;
_local1.prev = null;
_local1.shape = null;
};
_proxyPool = null;
_pairManager = null;
}
public function queryCircle(_arg1:Circle2, _arg2:Array, _arg3:int=2147483647):int{
var _local8:ShapeSkeleton;
if (_arg2.fixed){
_arg3 = _arg2.length;
};
var _local4:Number = _arg1.c.x;
var _local5:Number = _arg1.c.y;
var _local6:Number = _arg1.radius;
var _local7:LinkedProxy = _proxyList;
var _local9:int;
while (_local7 != null) {
_local8 = _local7.shape;
if ((((_local8.x - _local4) * (_local8.x - _local4)) + ((_local8.y - _local5) * (_local8.y - _local5))) <= ((_local8.radius + _local6) * (_local8.radius + _local6))){
var _temp1 = _local9;
_local9 = (_local9 + 1);
var _local10 = _temp1;
_arg2[_local10] = _local8;
if (_local9 == _arg3){
break;
};
};
_local7 = _local7.next;
};
return (_local9);
}
}
}//package de.polygonal.motor2.collision.nbody
Section 54
//LinkedProxy (de.polygonal.motor2.collision.nbody.LinkedProxy)
package de.polygonal.motor2.collision.nbody {
public class LinkedProxy extends Proxy {
public var next:LinkedProxy;
public var prev:LinkedProxy;
override public function reset():void{
next = null;
prev = null;
super.reset();
}
}
}//package de.polygonal.motor2.collision.nbody
Section 55
//PairCallback (de.polygonal.motor2.collision.nbody.PairCallback)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
public interface PairCallback {
function pairRemoved(_arg1:Contact):void;
function pairAdded(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):Contact;
}
}//package de.polygonal.motor2.collision.nbody
Section 56
//Proxy (de.polygonal.motor2.collision.nbody.Proxy)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.collision.shapes.*;
public class Proxy {
public var shape:ShapeSkeleton;
public var overlapCount:int;
private var _next:int;
public var id:int;
public static const NULL_PROXY:int = 0xFFFF;
public function getNext():int{
return (_next);
}
public function reset():void{
overlapCount = 0;
shape = null;
}
public function setNext(_arg1:int):void{
_next = _arg1;
}
}
}//package de.polygonal.motor2.collision.nbody
Section 57
//SAP (de.polygonal.motor2.collision.nbody.SAP)
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 flash.system.*;
public class SAP implements BroadPhase {
private var _yQuantizationFactor:Number;
private var _xmin0:Number;
private var _ymin:Number;
private var _ymin1:Number;
private var _tempInterval:QueryInterval;
private var _maxProxies:int;
private var _ymax:Number;
private var _proxyPool:Array;
private var _ybounds:Array;
private var _pairManager:BufferedPairManager;
private var _xmin:Number;
private var _xmin1:Number;
private var _xmax0:Number;
private var _ymax1:Number;
private var _xQuantizationFactor:Number;
private var _xmax:Number;
private var _ymax0:Number;
private var _ymin0:Number;
private var _xmax1:Number;
private var _proxyCount:int;
private var _freeProxy:int;
private var _queryResultCount:int;
private var _queryResults:Array;
private var _xbounds:Array;
private var _timeStamp:int;
public function SAP(){
var _local2:SAPProxy;
super();
var _local1:uint = System.totalMemory;
_maxProxies = Constants.k_maxProxies;
_queryResults = new Array(_maxProxies, true);
_tempInterval = new QueryInterval();
_proxyPool = new Array(Constants.k_maxPairs, true);
var _local3:int;
while (_local3 < (_maxProxies - 1)) {
_local2 = new SAPProxy();
_proxyPool[_local3] = _local2;
_local2.setNext((_local3 + 1));
_local2.reset();
_local3++;
};
_local2 = (_proxyPool[(_maxProxies - 1)] = new SAPProxy());
_local2.setNext(Proxy.NULL_PROXY);
_local2.reset();
_proxyCount = (_freeProxy = (_queryResultCount = 0));
_timeStamp = 1;
_xbounds = new Array((2 * _maxProxies));
_ybounds = new Array((2 * _maxProxies));
_local3 = 0;
while (_local3 < (_maxProxies << 1)) {
_xbounds[_local3] = new Bound();
_ybounds[_local3] = new Bound();
_local3++;
};
}
public function getProxyList():Array{
return (null);
}
private function binarySearch(_arg1:Array, _arg2:int, _arg3:int):int{
var _local6:int;
var _local7:Bound;
var _local4:int;
var _local5:int = (_arg2 - 1);
while (_local4 <= _local5) {
_local6 = ((_local4 + _local5) >> 1);
_local7 = _arg1[_local6];
if (_local7.value > _arg3){
_local5 = (_local6 - 1);
} else {
if (_local7.value < _arg3){
_local4 = (_local6 + 1);
} else {
_local4 = _local6;
break;
};
};
};
return (_local4);
}
private function rangeQuery(_arg1:QueryInterval, _arg2:int, _arg3:int, _arg4:Array, _arg5:int, _arg6:int):void{
var _local9:int;
var _local10:int;
var _local11:SAPProxy;
var _local7:int = (_arg1.lower = binarySearch(_arg4, _arg5, _arg2));
var _local8:int = (_arg1.upper = binarySearch(_arg4, _arg5, _arg3));
_local9 = _local7;
while (_local9 < _local8) {
if (_arg4[_local9].isLower()){
incrementOverlapCount(_arg4[_local9].proxyId);
};
_local9++;
};
if (_local7 > 0){
_local9 = (_local7 - 1);
_local10 = _arg4[_local9].stabbingCount;
if (_arg6 == 0){
while (_local10 > 0) {
if (_arg4[_local9].isLower()){
_local11 = _proxyPool[_arg4[_local9].proxyId];
if (_local7 <= _local11.xmax){
incrementOverlapCount(_arg4[_local9].proxyId);
_local10--;
};
};
_local9--;
};
} else {
while (_local10 > 0) {
if (_arg4[_local9].isLower()){
_local11 = _proxyPool[_arg4[_local9].proxyId];
if (_local7 <= _local11.ymax){
incrementOverlapCount(_arg4[_local9].proxyId);
_local10--;
};
};
_local9--;
};
};
};
}
public function destroyProxy(_arg1:int):void{
var _local2:Bound;
var _local3:Bound;
var _local5:SAPProxy;
var _local7:int;
var _local8:int;
var _local9:int;
var _local10:int;
var _local11:int;
var _local12:int;
if (_arg1 == Proxy.NULL_PROXY){
return;
};
var _local4:SAPProxy = _proxyPool[_arg1];
var _local6 = (_proxyCount << 1);
_local7 = _local4.xmin;
_local9 = _local4.xmax;
_local2 = _xbounds[_local7];
_local8 = _local2.value;
_local3 = _xbounds[_local9];
_local10 = _local3.value;
_xbounds.splice(_local7, 1);
_xbounds.splice((_local9 - 1), 1);
_local11 = (_local6 - 2);
_local12 = _local7;
while (_local12 < _local11) {
_local2 = _xbounds[_local12];
_local5 = _proxyPool[_local2.proxyId];
if (_local2.isLower()){
_local5.xmin = _local12;
} else {
_local5.xmax = _local12;
};
_local12++;
};
_local11 = (_local9 - 1);
_local12 = _local7;
while (_local12 < _local11) {
_local2 = _xbounds[_local12];
_local2.stabbingCount--;
_local12++;
};
rangeQuery(_tempInterval, _local8, _local10, _xbounds, (_local6 - 2), 0);
_local7 = _local4.ymin;
_local9 = _local4.ymax;
_local2 = _ybounds[_local7];
_local8 = _local2.value;
_local3 = _ybounds[_local9];
_local10 = _local3.value;
_ybounds.splice(_local7, 1);
_ybounds.splice((_local9 - 1), 1);
_local11 = (_local6 - 2);
_local12 = _local7;
while (_local12 < _local11) {
_local2 = _ybounds[_local12];
_local5 = _proxyPool[_local2.proxyId];
if (_local2.isLower()){
_local5.ymin = _local12;
} else {
_local5.ymax = _local12;
};
_local12++;
};
_local11 = (_local9 - 1);
_local12 = _local7;
while (_local12 < _local11) {
_local2 = _ybounds[_local12];
_local2.stabbingCount--;
_local12++;
};
rangeQuery(_tempInterval, _local8, _local10, _ybounds, (_local6 - 2), 1);
var _local13:int;
while (_local13 < _queryResultCount) {
_pairManager.removePair(_arg1, _queryResults[_local13]);
_local13++;
};
_pairManager.commit();
_queryResultCount = 0;
incrementTimeStamp();
_local4.shape = null;
_local4.overlapCount = Constants.k_invalid;
_local4.xmin = Constants.k_invalid;
_local4.ymin = Constants.k_invalid;
_local4.xmax = Constants.k_invalid;
_local4.ymax = Constants.k_invalid;
_local4.setNext(_freeProxy);
_freeProxy = _arg1;
_proxyCount--;
}
public function moveProxy(_arg1:int):void{
var _local4:int;
var _local5:Bound;
var _local6:SAPProxy;
var _local7:SAPProxy;
var _local8:int;
var _local9:int;
var _local10:Bound;
var _local11:Bound;
var _local12:int;
var _local13:int;
var _local14:int;
var _local15:int;
var _local16:int;
var _local17:int;
var _local2:SAPProxy = _proxyPool[_arg1];
var _local3 = (_proxyCount << 1);
_xmin1 = ((_xQuantizationFactor * (clamp(_local2.shape.xmin, _xmin, _xmax) - _xmin)) & (0xFFFF - 1));
_xmax1 = ((_xQuantizationFactor * (clamp(_local2.shape.xmax, _xmin, _xmax) - _xmin)) | 1);
_ymin1 = ((_yQuantizationFactor * (clamp(_local2.shape.ymin, _ymin, _ymax) - _ymin)) & (0xFFFF - 1));
_ymax1 = ((_yQuantizationFactor * (clamp(_local2.shape.ymax, _ymin, _ymax) - _ymin)) | 1);
_xmin0 = _xbounds[_local2.xmin].value;
_xmax0 = _xbounds[_local2.xmax].value;
_ymin0 = _ybounds[_local2.ymin].value;
_ymax0 = _ybounds[_local2.ymax].value;
_local12 = _local2.xmin;
_local15 = _local2.xmax;
_local13 = _xmin1;
_local16 = _xmax1;
_local14 = (_local13 - _xbounds[_local12].value);
_local17 = (_local16 - _xbounds[_local15].value);
_xbounds[_local12].value = _local13;
_xbounds[_local15].value = _local16;
if (_local14 < 0){
_local4 = _local12;
while ((((_local4 > 0)) && ((_local13 < _xbounds[int((_local4 - 1))].value)))) {
_local5 = _xbounds[_local4];
_local10 = _xbounds[int((_local4 - 1))];
_local8 = _local10.proxyId;
_local6 = _proxyPool[_local10.proxyId];
_local10.stabbingCount++;
if (_local10.isUpper()){
if (testOverlap(_xmin1, _ymin1, _xmax1, _ymax1, _local6)){
_pairManager.addPair(_arg1, _local8);
};
_local6.xmax++;
_local5.stabbingCount++;
} else {
_local6.xmin++;
_local5.stabbingCount--;
};
_local2.xmin--;
swapBounds(_local5, _local10);
_local4--;
};
};
if (_local17 > 0){
_local4 = _local15;
while ((((_local4 < (_local3 - 1))) && ((_xbounds[int((_local4 + 1))].value <= _local16)))) {
_local5 = _xbounds[_local4];
_local11 = _xbounds[int((_local4 + 1))];
_local9 = _local11.proxyId;
_local7 = _proxyPool[_local9];
_local11.stabbingCount++;
if (_local11.isLower()){
if (testOverlap(_xmin1, _ymin1, _xmax1, _ymax1, _local7)){
_pairManager.addPair(_arg1, _local9);
};
_local7.xmin--;
_local5.stabbingCount++;
} else {
_local7.xmax--;
_local5.stabbingCount--;
};
_local2.xmax++;
swapBounds(_local5, _local11);
_local4++;
};
};
if (_local14 > 0){
_local4 = _local12;
while ((((_local4 < (_local3 - 1))) && ((_xbounds[int((_local4 + 1))].value <= _local13)))) {
_local5 = _xbounds[_local4];
_local11 = _xbounds[int((_local4 + 1))];
_local9 = _local11.proxyId;
_local7 = _proxyPool[_local9];
_local11.stabbingCount--;
if (_local11.isUpper()){
if (testOverlap(_xmin0, _ymin0, _xmax0, _ymax0, _local7)){
_pairManager.removePair(_arg1, _local9);
};
_local7.xmax--;
_local5.stabbingCount--;
} else {
_local7.xmin--;
_local5.stabbingCount++;
};
_local2.xmin++;
swapBounds(_local5, _local11);
_local4++;
};
};
if (_local17 < 0){
_local4 = _local15;
while ((((_local4 > 0)) && ((_local16 < _xbounds[int((_local4 - 1))].value)))) {
_local5 = _xbounds[_local4];
_local10 = _xbounds[(_local4 - 1)];
_local8 = _local10.proxyId;
_local6 = _proxyPool[_local8];
_local10.stabbingCount--;
if (_local10.isLower()){
if (testOverlap(_xmin0, _ymin0, _xmax0, _ymax0, _local6)){
_pairManager.removePair(_arg1, _local8);
};
_local6.xmin++;
_local5.stabbingCount--;
} else {
_local6.xmax++;
_local5.stabbingCount++;
};
_local2.xmax--;
swapBounds(_local5, _local10);
_local4--;
};
};
_local12 = _local2.ymin;
_local15 = _local2.ymax;
_local13 = _ymin1;
_local16 = _ymax1;
_local14 = (_local13 - _ybounds[_local12].value);
_local17 = (_local16 - _ybounds[_local15].value);
_ybounds[_local12].value = _local13;
_ybounds[_local15].value = _local16;
if (_local14 < 0){
_local4 = _local12;
while ((((_local4 > 0)) && ((_local13 < _ybounds[int((_local4 - 1))].value)))) {
_local5 = _ybounds[_local4];
_local10 = _ybounds[int((_local4 - 1))];
_local8 = _local10.proxyId;
_local6 = _proxyPool[_local10.proxyId];
_local10.stabbingCount++;
if (_local10.isUpper()){
if (testOverlap(_xmin1, _ymin1, _xmax1, _ymax1, _local6)){
_pairManager.addPair(_arg1, _local8);
};
_local6.ymax++;
_local5.stabbingCount++;
} else {
_local6.ymin++;
_local5.stabbingCount--;
};
_local2.ymin--;
swapBounds(_local5, _local10);
_local4--;
};
};
if (_local17 > 0){
_local4 = _local15;
while ((((_local4 < (_local3 - 1))) && ((_ybounds[int((_local4 + 1))].value <= _local16)))) {
_local5 = _ybounds[_local4];
_local11 = _ybounds[int((_local4 + 1))];
_local9 = _local11.proxyId;
_local7 = _proxyPool[_local9];
_local11.stabbingCount++;
if (_local11.isLower()){
if (testOverlap(_xmin1, _ymin1, _xmax1, _ymax1, _local7)){
_pairManager.addPair(_arg1, _local9);
};
_local7.ymin--;
_local5.stabbingCount++;
} else {
_local7.ymax--;
_local5.stabbingCount--;
};
_local2.ymax++;
swapBounds(_local5, _local11);
_local4++;
};
};
if (_local14 > 0){
_local4 = _local12;
while ((((_local4 < (_local3 - 1))) && ((_ybounds[int((_local4 + 1))].value <= _local13)))) {
_local5 = _ybounds[_local4];
_local11 = _ybounds[int((_local4 + 1))];
_local9 = _local11.proxyId;
_local7 = _proxyPool[_local9];
_local11.stabbingCount--;
if (_local11.isUpper()){
if (testOverlap(_xmin0, _ymin0, _xmax0, _ymax0, _local7)){
_pairManager.removePair(_arg1, _local9);
};
_local7.ymax--;
_local5.stabbingCount--;
} else {
_local7.ymin--;
_local5.stabbingCount++;
};
_local2.ymin++;
swapBounds(_local5, _local11);
_local4++;
};
};
if (_local17 < 0){
_local4 = _local15;
while ((((_local4 > 0)) && ((_local16 < _ybounds[int((_local4 - 1))].value)))) {
_local5 = _ybounds[_local4];
_local10 = _ybounds[(_local4 - 1)];
_local8 = _local10.proxyId;
_local6 = _proxyPool[_local8];
_local10.stabbingCount--;
if (_local10.isLower()){
if (testOverlap(_xmin0, _ymin0, _xmax0, _ymax0, _local6)){
_pairManager.removePair(_arg1, _local8);
};
_local6.ymin++;
_local5.stabbingCount--;
} else {
_local6.ymax++;
_local5.stabbingCount++;
};
_local2.ymax--;
swapBounds(_local5, _local10);
_local4--;
};
};
}
private function incrementOverlapCount(_arg1:int):void{
var _local2:SAPProxy = _proxyPool[_arg1];
if (_local2.timeStamp < _timeStamp){
_local2.timeStamp = _timeStamp;
_local2.overlapCount = 1;
} else {
_local2.overlapCount = 2;
_queryResults[_queryResultCount] = _arg1;
_queryResultCount++;
};
}
public function findPairs():void{
_pairManager.commit();
}
public function setWorldBounds(_arg1:AABB2):void{
_xmin = _arg1.xmin;
_xmax = _arg1.xmax;
_ymin = _arg1.ymin;
_ymax = _arg1.ymax;
var _local2:Number = (_arg1.xmax - _arg1.xmin);
var _local3:Number = (_arg1.ymax - _arg1.ymin);
_xQuantizationFactor = (0xFFFF / _local2);
_yQuantizationFactor = (0xFFFF / _local3);
}
public function queryAABB(_arg1:AABB2, _arg2:Array, _arg3:int=2147483647):int{
var _local5:SAPProxy;
if (_arg2.fixed){
_arg3 = _arg2.length;
};
_xmin0 = ((_xQuantizationFactor * (clamp(_arg1.xmin, _xmin, _xmax) - _xmin)) & (0xFFFF - 1));
_xmax0 = ((_xQuantizationFactor * (clamp(_arg1.xmax, _xmin, _xmax) - _xmin)) | 1);
_ymin0 = ((_yQuantizationFactor * (clamp(_arg1.ymin, _ymin, _ymax) - _ymin)) & (0xFFFF - 1));
_ymax0 = ((_yQuantizationFactor * (clamp(_arg1.ymax, _ymin, _ymax) - _ymin)) | 1);
rangeQuery(_tempInterval, _xmin0, _xmax0, _xbounds, (_proxyCount << 1), 0);
rangeQuery(_tempInterval, _ymin0, _ymax0, _ybounds, (_proxyCount << 1), 1);
var _local4:int;
while (_local4 < _queryResultCount) {
_local5 = _proxyPool[int(_queryResults[_local4])];
_arg2[_local4] = _local5.shape;
if (_local4 == _arg3){
break;
};
_local4++;
};
_queryResultCount = 0;
incrementTimeStamp();
return (_local4);
}
public function queryCircle(_arg1:Circle2, _arg2:Array, _arg3:int=2147483647):int{
var _local7:ShapeSkeleton;
if (_arg2.fixed){
_arg3 = _arg2.length;
};
var _local4:Number = _arg1.c.x;
var _local5:Number = _arg1.c.y;
var _local6:Number = _arg1.radius;
var _local8:int;
var _local9:int;
while (_local9 < _maxProxies) {
_local7 = _proxyPool[_local9].shape;
if (_local7 == null){
} else {
if ((((_local7.x - _local4) * (_local7.x - _local4)) + ((_local7.y - _local5) * (_local7.y - _local5))) <= ((_local7.radius + _local6) * (_local7.radius + _local6))){
var _temp1 = _local8;
_local8 = (_local8 + 1);
var _local10 = _temp1;
_arg2[_local10] = _local7;
};
};
_local9++;
};
return (_local8);
}
private function clamp(_arg1:Number, _arg2:Number, _arg3:Number):Number{
return (((_arg1)<_arg2) ? _arg2 : ((_arg1)>_arg3) ? _arg3 : _arg1);
}
public function insideBounds(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):Boolean{
var _local5:Number = (_arg1 - _xmax);
var _local6:Number = (_xmin - _arg3);
var _local7:Number = (_arg2 - _ymax);
var _local8:Number = (_ymin - _arg4);
_local5 = ((_local5 > _local6)) ? _local5 : _local6;
_local7 = ((_local7 > _local8)) ? _local7 : _local8;
return ((((_local5 > _local7)) ? _local5 : _local7 < 0));
}
public function createProxy(_arg1:ShapeSkeleton):int{
var _local5:int;
var _local6:Bound;
var _local7:Bound;
var _local8:int;
var _local9:Bound;
var _local10:int;
var _local2:int = _freeProxy;
var _local3:SAPProxy = _proxyPool[_local2];
_freeProxy = _local3.getNext();
_local3.overlapCount = 0;
_local3.shape = _arg1;
_xmin0 = ((_xQuantizationFactor * (clamp(_arg1.xmin, _xmin, _xmax) - _xmin)) & (0xFFFF - 1));
_xmax0 = ((_xQuantizationFactor * (clamp(_arg1.xmax, _xmin, _xmax) - _xmin)) | 1);
_ymin0 = ((_yQuantizationFactor * (clamp(_arg1.ymin, _ymin, _ymax) - _ymin)) & (0xFFFF - 1));
_ymax0 = ((_yQuantizationFactor * (clamp(_arg1.ymax, _ymin, _ymax) - _ymin)) | 1);
var _local4 = (_proxyCount << 1);
rangeQuery(_tempInterval, _xmin0, _xmax0, _xbounds, _local4, 0);
_local8 = _tempInterval.lower;
_local10 = _tempInterval.upper;
_xbounds.splice(_local8, 0, new Bound());
_local10++;
_xbounds.splice(_local10, 0, new Bound());
_local7 = _xbounds[_local8];
_local7.value = _xmin0;
_local7.proxyId = _local2;
_local9 = _xbounds[_local10];
_local9.value = _xmax0;
_local9.proxyId = _local2;
_local7.stabbingCount = ((_local8)==0) ? 0 : _xbounds[int((_local8 - 1))].stabbingCount;
_local9.stabbingCount = _xbounds[int((_local10 - 1))].stabbingCount;
_local5 = _local8;
while (_local5 < _local10) {
_xbounds[_local5].stabbingCount++;
_local5++;
};
_local5 = _local8;
while (_local5 < (_local4 + 2)) {
_local6 = _xbounds[_local5];
_local3 = _proxyPool[_local6.proxyId];
if (_local6.isLower()){
_local3.xmin = _local5;
} else {
_local3.xmax = _local5;
};
_local5++;
};
rangeQuery(_tempInterval, _ymin0, _ymax0, _ybounds, _local4, 1);
_local8 = _tempInterval.lower;
_local10 = _tempInterval.upper;
_ybounds.splice(_local8, 0, new Bound());
_local10++;
_ybounds.splice(_local10, 0, new Bound());
_local7 = _ybounds[_local8];
_local7.value = _ymin0;
_local7.proxyId = _local2;
_local9 = _ybounds[_local10];
_local9.value = _ymax0;
_local9.proxyId = _local2;
_local7.stabbingCount = ((_local8)==0) ? 0 : _ybounds[int((_local8 - 1))].stabbingCount;
_local9.stabbingCount = _ybounds[int((_local10 - 1))].stabbingCount;
_local5 = _local8;
while (_local5 < _local10) {
_ybounds[_local5].stabbingCount++;
_local5++;
};
_local5 = _local8;
while (_local5 < (_local4 + 2)) {
_local6 = _ybounds[_local5];
_local3 = _proxyPool[_local6.proxyId];
if (_local6.isLower()){
_local3.ymin = _local5;
} else {
_local3.ymax = _local5;
};
_local5++;
};
_proxyCount++;
var _local11:int;
while (_local11 < _queryResultCount) {
_pairManager.addPair(_local2, _queryResults[_local11]);
_local11++;
};
_pairManager.commit();
_queryResultCount = 0;
incrementTimeStamp();
return (_local2);
}
public function setPairHandler(_arg1:PairCallback):void{
_pairManager = new BufferedPairManager(Constants.k_maxPairs, _arg1, this);
}
private function incrementTimeStamp():void{
var _local1:int;
if (_timeStamp == 0xFFFF){
_local1 = 0;
while (_local1 < _maxProxies) {
_proxyPool[_local1].timeStamp = 0;
_local1++;
};
_timeStamp = 1;
} else {
_timeStamp++;
};
}
private function testOverlap(_arg1:int, _arg2:int, _arg3:int, _arg4:int, _arg5:SAPProxy):Boolean{
if (_arg1 > _xbounds[_arg5.xmax].value){
return (false);
};
if (_arg3 < _xbounds[_arg5.xmin].value){
return (false);
};
if (_arg2 > _ybounds[_arg5.ymax].value){
return (false);
};
if (_arg4 < _ybounds[_arg5.ymin].value){
return (false);
};
return (true);
}
public function getProxy(_arg1:int):Proxy{
var _local2:SAPProxy = _proxyPool[_arg1];
if (_arg1 == Proxy.NULL_PROXY){
return (null);
};
return (_local2);
}
public function deconstruct():void{
var _local1:int;
while (_local1 < _maxProxies) {
_proxyPool[_local1].shape = null;
_local1++;
};
_proxyPool = null;
}
public function querySegment(_arg1:Point, _arg2:Point, _arg3:Array, _arg4:int=-1):int{
return (0);
}
private function swapBounds(_arg1:Bound, _arg2:Bound):void{
var _local3:int = _arg2.value;
_arg2.value = _arg1.value;
_arg1.value = _local3;
_local3 = _arg2.proxyId;
_arg2.proxyId = _arg1.proxyId;
_arg1.proxyId = _local3;
_local3 = _arg2.stabbingCount;
_arg2.stabbingCount = _arg1.stabbingCount;
_arg1.stabbingCount = _local3;
}
}
}//package de.polygonal.motor2.collision.nbody
class QueryInterval {
public var lower:int;
public var upper:int;
private function QueryInterval(){
}
}
class BoundValues {
public var ymin:int;
public var xmin:int;
public var ymax:int;
public var xmax:int;
private function BoundValues(){
}
}
class Bound {
public var value:int;
public var proxyId:int;
public var stabbingCount:int;
private function Bound(){
}
public function swap(_arg1:Bound):void{
var _local2:int;
_local2 = value;
value = _arg1.value;
_arg1.value = _local2;
_local2 = proxyId;
proxyId = _arg1.proxyId;
_arg1.proxyId = _local2;
_local2 = stabbingCount;
stabbingCount = _arg1.stabbingCount;
_arg1.stabbingCount = _local2;
}
public function isLower():Boolean{
return (((value & 1) == 0));
}
public function isUpper():Boolean{
return (((value & 1) == 1));
}
}
Section 58
//SAPProxy (de.polygonal.motor2.collision.nbody.SAPProxy)
package de.polygonal.motor2.collision.nbody {
public class SAPProxy extends Proxy {
public var ymax:int;
public var xmax:int;
public var ymin:int;
public var xmin:int;
public var timeStamp:int;
override public function getNext():int{
return (xmin);
}
override public function reset():void{
timeStamp = 0;
overlapCount = 0xFFFF;
shape = null;
}
override public function setNext(_arg1:int):void{
xmin = _arg1;
}
}
}//package de.polygonal.motor2.collision.nbody
Section 59
//UnbufferedPair (de.polygonal.motor2.collision.nbody.UnbufferedPair)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.dynamics.contact.*;
public class UnbufferedPair {
public var contact:Contact;
public var proxyId1:int;
public var proxyId2:int;
}
}//package de.polygonal.motor2.collision.nbody
Section 60
//UnbufferedPairManager (de.polygonal.motor2.collision.nbody.UnbufferedPairManager)
package de.polygonal.motor2.collision.nbody {
import de.polygonal.motor2.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import flash.utils.*;
public class UnbufferedPairManager {
private var _callback:PairCallback;
private var _poolMask:int;
private var _writeIndex:int;
private var _pairTable:Dictionary;
private var _pairCount:int;
private var _broadPhase:BroadPhase;
private var _pairPool:Array;
private var _readIndex:int;
public function UnbufferedPairManager(_arg1:PairCallback, _arg2:BroadPhase){
_callback = _arg1;
_broadPhase = _arg2;
_pairTable = new Dictionary();
var _local3:int = Constants.k_maxPairs;
_pairPool = new Array(_local3, true);
var _local4:int;
while (_local4 < _local3) {
_pairPool[_local4] = new UnbufferedPair();
_local4++;
};
_poolMask = (_local3 - 1);
}
private function getKey(_arg1:int, _arg2:int):int{
if (_arg1 > _arg2){
return (((_arg2 << 16) | _arg1));
};
return (((_arg1 << 16) | _arg2));
}
public function addPair(_arg1:int, _arg2:int):Boolean{
var _local3:int = getKey(_arg1, _arg2);
if (_pairTable[_local3]){
return (false);
};
var _local4:UnbufferedPair = _pairPool[_readIndex];
_readIndex = ((_readIndex + 1) & _poolMask);
var _local5:ShapeSkeleton = _broadPhase.getProxy(_arg1).shape;
var _local6:ShapeSkeleton = _broadPhase.getProxy(_arg2).shape;
var _local7:Contact = _callback.pairAdded(_local5, _local6);
_local4.proxyId1 = _arg1;
_local4.proxyId2 = _arg2;
_local4.contact = _local7;
_pairCount++;
_pairTable[_local3] = _local4;
return (true);
}
public function removePair(_arg1:int, _arg2:int):Boolean{
var _local3:int = getKey(_arg1, _arg2);
var _local4:UnbufferedPair = _pairTable[_local3];
if (_local4 == null){
return (false);
};
_callback.pairRemoved(_local4.contact);
_local4.contact = null;
_pairPool[_writeIndex] = _local4;
_writeIndex = ((_writeIndex + 1) & _poolMask);
_pairCount--;
delete _pairTable[_local3];
return (true);
}
}
}//package de.polygonal.motor2.collision.nbody
Section 61
//CollideBox (de.polygonal.motor2.collision.pairwise.CollideBox)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollideBox implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:int;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:int;
var _local19:int;
var _local20:int;
var _local21:ShapeSkeleton;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:int;
var _local29:int;
var _local30:int;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local39:Number;
var _local40:Number;
var _local41:Number;
var _local42:Number;
var _local43:Number;
var _local44:Number;
var _local45:Number;
var _local46:ContactPoint;
var _local5:BoxContact = BoxContact(_arg4);
var _local12:Number = (_arg3.x - _arg2.x);
var _local13:Number = (_arg3.y - _arg2.y);
_local11 = _local5.sepAxisId;
if (_local11 == 0){
_local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21));
if (_local14 < 0){
_local14 = -(_local14);
};
_local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22));
if (_local16 < 0){
_local16 = -(_local16);
};
_local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = _arg2.r11;
_local7 = _arg2.r21;
_local18 = 3;
} else {
_local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = -(_arg2.r11);
_local7 = -(_arg2.r21);
_local18 = 1;
};
_local10 = _local9;
_local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22));
if (_local17 < 0){
_local17 = -(_local17);
};
_local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21));
if (_local15 < 0){
_local15 = -(_local15);
};
_local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = _arg2.r12;
_local7 = _arg2.r22;
_local18 = 0;
};
} else {
_local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = -(_arg2.r12);
_local7 = -(_arg2.r22);
_local18 = 2;
};
};
_local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = _arg3.r11;
_local7 = _arg3.r21;
_local18 = 1;
};
} else {
_local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = -(_arg3.r11);
_local7 = -(_arg3.r21);
_local18 = 3;
};
};
_local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = _arg3.r12;
_local7 = _arg3.r22;
_local18 = 2;
};
} else {
_local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = -(_arg3.r12);
_local7 = -(_arg3.r22);
_local18 = 0;
};
};
} else {
if (_local11 == 1){
_local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22));
if (_local17 < 0){
_local17 = -(_local17);
};
_local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21));
if (_local15 < 0){
_local15 = -(_local15);
};
_local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = _arg2.r12;
_local7 = _arg2.r22;
_local18 = 0;
} else {
_local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = -(_arg2.r12);
_local7 = -(_arg2.r22);
_local18 = 2;
};
_local10 = _local9;
_local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21));
if (_local14 < 0){
_local14 = -(_local14);
};
_local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22));
if (_local16 < 0){
_local16 = -(_local16);
};
_local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = _arg2.r11;
_local7 = _arg2.r21;
_local18 = 3;
};
} else {
_local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = -(_arg2.r11);
_local7 = -(_arg2.r21);
_local18 = 1;
};
};
_local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = _arg3.r11;
_local7 = _arg3.r21;
_local18 = 1;
};
} else {
_local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = -(_arg3.r11);
_local7 = -(_arg3.r21);
_local18 = 3;
};
};
_local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = _arg3.r12;
_local7 = _arg3.r22;
_local18 = 2;
};
} else {
_local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = -(_arg3.r12);
_local7 = -(_arg3.r22);
_local18 = 0;
};
};
} else {
if (_local11 == 2){
_local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21));
if (_local14 < 0){
_local14 = -(_local14);
};
_local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21));
if (_local15 < 0){
_local15 = -(_local15);
};
_local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = _arg3.r11;
_local7 = _arg3.r21;
_local18 = 1;
} else {
_local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = -(_arg3.r11);
_local7 = -(_arg3.r21);
_local18 = 3;
};
_local10 = _local9;
_local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22));
if (_local16 < 0){
_local16 = -(_local16);
};
_local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22));
if (_local17 < 0){
_local17 = -(_local17);
};
_local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = _arg2.r11;
_local7 = _arg2.r21;
_local18 = 3;
};
} else {
_local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = -(_arg2.r11);
_local7 = -(_arg2.r21);
_local18 = 1;
};
};
_local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = _arg2.r12;
_local7 = _arg2.r22;
_local18 = 0;
};
} else {
_local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = -(_arg2.r12);
_local7 = -(_arg2.r22);
_local18 = 2;
};
};
_local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = _arg3.r12;
_local7 = _arg3.r22;
_local18 = 2;
};
} else {
_local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_local5.sepAxisId = 3;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ey))){
_local11 = 3;
_local10 = _local9;
_local6 = -(_arg3.r12);
_local7 = -(_arg3.r22);
_local18 = 0;
};
};
} else {
if (_local11 == 3){
_local16 = ((_arg2.r11 * _arg3.r12) + (_arg2.r21 * _arg3.r22));
if (_local16 < 0){
_local16 = -(_local16);
};
_local17 = ((_arg2.r12 * _arg3.r12) + (_arg2.r22 * _arg3.r22));
if (_local17 < 0){
_local17 = -(_local17);
};
_local8 = ((_arg3.r12 * _local12) + (_arg3.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = _arg3.r12;
_local7 = _arg3.r22;
_local18 = 2;
} else {
_local9 = ((-(_local8) - ((_local16 * _arg2.ex) + (_local17 * _arg2.ey))) - _arg3.ey);
if (_local9 > 0){
_arg1.pointCount = 0;
return;
};
_local6 = -(_arg3.r12);
_local7 = -(_arg3.r22);
_local18 = 0;
};
_local10 = _local9;
_local14 = ((_arg2.r11 * _arg3.r11) + (_arg2.r21 * _arg3.r21));
if (_local14 < 0){
_local14 = -(_local14);
};
_local15 = ((_arg2.r12 * _arg3.r11) + (_arg2.r22 * _arg3.r21));
if (_local15 < 0){
_local15 = -(_local15);
};
_local8 = ((_arg2.r11 * _local12) + (_arg2.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = _arg2.r11;
_local7 = _arg2.r21;
_local18 = 3;
};
} else {
_local9 = ((-(_local8) - _arg2.ex) - ((_local14 * _arg3.ex) + (_local16 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 0;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ex))){
_local11 = 0;
_local10 = _local9;
_local6 = -(_arg2.r11);
_local7 = -(_arg2.r21);
_local18 = 1;
};
};
_local8 = ((_arg2.r12 * _local12) + (_arg2.r22 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = _arg2.r12;
_local7 = _arg2.r22;
_local18 = 0;
};
} else {
_local9 = ((-(_local8) - _arg2.ey) - ((_local15 * _arg3.ex) + (_local17 * _arg3.ey)));
if (_local9 > 0){
_local5.sepAxisId = 1;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg2.ey))){
_local11 = 1;
_local10 = _local9;
_local6 = -(_arg2.r12);
_local7 = -(_arg2.r22);
_local18 = 2;
};
};
_local8 = ((_arg3.r11 * _local12) + (_arg3.r21 * _local13));
if (_local8 > 0){
_local9 = ((_local8 - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = _arg3.r11;
_local7 = _arg3.r21;
_local18 = 1;
};
} else {
_local9 = ((-(_local8) - ((_local14 * _arg2.ex) + (_local15 * _arg2.ey))) - _arg3.ex);
if (_local9 > 0){
_local5.sepAxisId = 2;
_arg1.pointCount = 0;
return;
};
if (_local9 > ((0.95 * _local10) + (0.01 * _arg3.ex))){
_local11 = 2;
_local10 = _local9;
_local6 = -(_arg3.r11);
_local7 = -(_arg3.r21);
_local18 = 3;
};
};
};
};
};
};
if (_local11 == 0){
_local21 = _arg3;
_local22 = (((_arg2.x * _local6) + (_arg2.y * _local7)) + _arg2.ex);
_local26 = _arg2.r12;
_local27 = _arg2.r22;
_local23 = ((_arg2.x * _local26) + (_arg2.y * _local27));
_local24 = (-(_local23) + _arg2.ey);
_local28 = 1;
_local25 = (_local23 + _arg2.ey);
_local29 = 3;
} else {
if (_local11 == 1){
_local21 = _arg3;
_local22 = (((_arg2.x * _local6) + (_arg2.y * _local7)) + _arg2.ey);
_local26 = _arg2.r11;
_local27 = _arg2.r21;
_local23 = ((_arg2.x * _local26) + (_arg2.y * _local27));
_local24 = (-(_local23) + _arg2.ex);
_local28 = 2;
_local25 = (_local23 + _arg2.ex);
_local29 = 4;
} else {
if (_local11 == 2){
_local21 = _arg2;
_local30 = 1;
_local6 = -(_local6);
_local7 = -(_local7);
_local22 = (((_arg3.x * _local6) + (_arg3.y * _local7)) + _arg3.ex);
_local26 = _arg3.r12;
_local27 = _arg3.r22;
_local23 = ((_arg3.x * _local26) + (_arg3.y * _local27));
_local24 = (-(_local23) + _arg3.ey);
_local28 = 1;
_local25 = (_local23 + _arg3.ey);
_local29 = 3;
} else {
if (_local11 == 3){
_local21 = _arg2;
_local30 = 1;
_local6 = -(_local6);
_local7 = -(_local7);
_local22 = (((_arg3.x * _local6) + (_arg3.y * _local7)) + _arg3.ey);
_local26 = _arg3.r11;
_local27 = _arg3.r21;
_local23 = ((_arg3.x * _local26) + (_arg3.y * _local27));
_local24 = (-(_local23) + _arg3.ex);
_local28 = 2;
_local25 = (_local23 + _arg3.ex);
_local29 = 4;
};
};
};
};
var _local35:Number = ((-(_local21.r11) * _local6) - (_local21.r21 * _local7));
var _local36:Number = ((-(_local21.r12) * _local6) - (_local21.r22 * _local7));
if (((_local35 < 0)) ? -(_local35) : _local35 > ((_local36 < 0)) ? -(_local36) : _local36){
if (_local35 > 0){
_local31 = _local21.ex;
_local33 = -(_local21.ey);
_local32 = _local21.ex;
_local34 = _local21.ey;
if (_local36 > 0){
_local19 = 0;
_local20 = 3;
} else {
_local19 = 3;
_local20 = 0;
};
} else {
_local31 = -(_local21.ex);
_local33 = _local21.ey;
_local32 = -(_local21.ex);
_local34 = -(_local21.ey);
if (_local36 > 0){
_local19 = 1;
_local20 = 2;
} else {
_local19 = 2;
_local20 = 1;
};
};
} else {
if (_local36 > 0){
_local31 = _local21.ex;
_local33 = _local21.ey;
_local32 = -(_local21.ex);
_local34 = _local21.ey;
if (_local35 > 0){
_local19 = 0;
_local20 = 1;
} else {
_local19 = 1;
_local20 = 0;
};
} else {
_local31 = -(_local21.ex);
_local33 = -(_local21.ey);
_local32 = _local21.ex;
_local34 = -(_local21.ey);
if (_local35 > 0){
_local19 = 3;
_local20 = 2;
} else {
_local19 = 2;
_local20 = 3;
};
};
};
var _local37:Number = _local31;
var _local38:Number = _local33;
_local31 = ((_local21.x + (_local21.r11 * _local37)) + (_local21.r12 * _local38));
_local33 = ((_local21.y + (_local21.r21 * _local37)) + (_local21.r22 * _local38));
_local37 = _local32;
_local38 = _local34;
_local32 = ((_local21.x + (_local21.r11 * _local37)) + (_local21.r12 * _local38));
_local34 = ((_local21.y + (_local21.r21 * _local37)) + (_local21.r22 * _local38));
_local43 = (((_local31 * -(_local26)) + (_local33 * -(_local27))) - _local24);
_local44 = (((_local32 * -(_local26)) + (_local34 * -(_local27))) - _local24);
if ((_local43 * _local44) < 0){
_local45 = (_local43 / (_local43 - _local44));
if (_local43 < 0){
_local39 = _local31;
_local41 = _local33;
_local40 = (_local39 + (_local45 * (_local32 - _local39)));
_local42 = (_local41 + (_local45 * (_local34 - _local41)));
} else {
_local39 = _local32;
_local41 = _local34;
_local40 = (_local31 + (_local45 * (_local39 - _local31)));
_local42 = (_local33 + (_local45 * (_local41 - _local33)));
};
} else {
if (_local43 > 0){
_arg1.pointCount = 0;
return;
};
if (_local43 < _local44){
_local39 = _local31;
_local41 = _local33;
_local40 = _local32;
_local42 = _local34;
} else {
_local40 = _local31;
_local42 = _local33;
_local39 = _local32;
_local41 = _local34;
};
};
_local43 = (((_local39 * _local26) + (_local41 * _local27)) - _local25);
_local44 = (((_local40 * _local26) + (_local42 * _local27)) - _local25);
if ((_local43 * _local44) < 0){
_local45 = (_local43 / (_local43 - _local44));
_local39 = (_local39 + (_local45 * (_local40 - _local39)));
_local41 = (_local41 + (_local45 * (_local42 - _local41)));
} else {
if (_local43 > 0){
_arg1.pointCount = 0;
return;
};
};
_local9 = (((_local6 * _local39) + (_local7 * _local41)) - _local22);
if (_local9 <= 0){
_arg1.pointCount = 1;
if (_local30){
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
} else {
_arg1.nx = _local6;
_arg1.ny = _local7;
};
_local46 = _arg1.c0;
_local46.sep = _local9;
_local46.x = _local39;
_local46.y = _local41;
_local46.id.flip = _local30;
_local46.id.incEdge = _local20;
_local46.id.incVert = _local19;
_local46.id.refFace = _local18;
_local46.id.bake();
_local9 = (((_local6 * _local40) + (_local7 * _local42)) - _local22);
if (_local9 <= 0){
_arg1.pointCount = 2;
_local46 = _arg1.c1;
_local46.sep = _local9;
_local46.x = _local40;
_local46.y = _local42;
_local46.id.flip = _local30;
_local46.id.incEdge = _local20;
_local46.id.incVert = _local19;
_local46.id.refFace = _local18;
_local46.id.bake();
};
} else {
_local9 = (((_local6 * _local40) + (_local7 * _local42)) - _local22);
if (_local9 <= 0){
_arg1.pointCount = 1;
if (_local30){
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
} else {
_arg1.nx = _local6;
_arg1.ny = _local7;
};
_local46 = _arg1.c0;
_local46.sep = _local9;
_local46.x = _local40;
_local46.y = _local42;
_local46.id.flip = _local30;
_local46.id.incEdge = _local20;
_local46.id.incVert = _local19;
_local46.id.refFace = _local18;
_local46.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 62
//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 _local11:int;
var _local12:int;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:V2;
var _local21:V2;
var _local22:V2;
var _local23:V2;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:BoxCircleContact;
var _local29:Number;
var _local30:Number;
var _local31:int;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local10:int = ContactID.NULL_FEATURE;
if (_arg1.pointCount == 1){
_local11 = _local10;
_local12 = _local10;
_local13 = _arg2.x;
_local14 = _arg2.y;
_local15 = (_arg3.x - _arg2.x);
_local16 = (_arg3.y - _arg2.y);
_local17 = 0;
_local18 = 0;
_local19 = ((_local15 * _arg2.r11) + (_local16 * _arg2.r21));
if (_local19 < -(_arg2.ex)){
_local18 = (_local19 + _arg2.ex);
_local19 = -(_arg2.ex);
_local12 = (1 + 1);
_local11 = _local12;
} else {
if (_local19 > _arg2.ex){
_local18 = (_local19 - _arg2.ex);
_local19 = _arg2.ex;
_local12 = (3 + 1);
_local11 = _local12;
};
};
_local13 = (_local13 + (_arg2.r11 * _local19));
_local14 = (_local14 + (_arg2.r21 * _local19));
_local17 = (_local17 + (_local18 * _local18));
_local18 = 0;
_local19 = ((_local15 * _arg2.r12) + (_local16 * _arg2.r22));
if (_local19 < -(_arg2.ey)){
_local18 = (_local19 + _arg2.ey);
_local19 = -(_arg2.ey);
_local12 = _local10;
if (_local11 == (1 + 1)){
_local11 = (2 + 1);
} else {
if (_local11 == _local10){
_local12 = (2 + 1);
};
};
} else {
if (_local19 > _arg2.ey){
_local18 = (_local19 - _arg2.ey);
_local19 = _arg2.ey;
_local12 = _local10;
if (_local11 == (3 + 1)){
_local11 = (0 + 1);
} else {
if (_local11 == _local10){
_local12 = (0 + 1);
};
};
} else {
_local11 = _local10;
};
};
_local13 = (_local13 + (_arg2.r12 * _local19));
_local14 = (_local14 + (_arg2.r22 * _local19));
_local5 = (_local17 + (_local18 * _local18));
if (_local5 >= _arg3.radiusSq){
_arg1.pointCount = 0;
return;
};
_arg1.pointCount = 1;
_local9 = _arg1.c0;
_local9.id.refFace = _local10;
_local9.id.flip = 0;
if (_local5 == 0){
_local9.id.incVert = _local10;
_local7 = ((_local15 * _arg2.r11) + (_local16 * _arg2.r21));
_local8 = ((_local15 * _arg2.r12) + (_local16 * _arg2.r22));
if (_local7 > 0){
if (_local8 > 0){
if ((_arg2.ex - _local7) < (_arg2.ey - _local8)){
_arg1.nx = _arg2.r11;
_arg1.ny = _arg2.r21;
_local9.sep = ((_arg3.radius + _arg2.ex) - _local7);
_local9.id.incEdge = 3;
} else {
_arg1.nx = _arg2.r12;
_arg1.ny = _arg2.r22;
_local9.sep = ((_arg3.radius + _arg2.ey) - _local8);
_local9.id.incEdge = 0;
};
} else {
if ((_arg2.ex - _local7) < (_arg2.ey + _local8)){
_arg1.nx = _arg2.r11;
_arg1.ny = _arg2.r21;
_local9.sep = ((_arg3.radius + _arg2.ex) - _local7);
_local9.id.incEdge = 3;
} else {
_arg1.nx = -(_arg2.r12);
_arg1.ny = -(_arg2.r22);
_local9.sep = ((_arg3.radius + _arg2.ey) + _local8);
_local9.id.incEdge = 2;
};
};
} else {
if (_local8 > 0){
if ((_arg2.ex + _local7) < (_arg2.ey - _local8)){
_arg1.nx = -(_arg2.r11);
_arg1.ny = -(_arg2.r21);
_local9.sep = ((_arg3.radius + _arg2.ex) + _local7);
_local9.id.incEdge = 1;
} else {
_arg1.nx = _arg2.r12;
_arg1.ny = _arg2.r22;
_local9.sep = ((_arg3.radius + _arg2.ey) - _local8);
_local9.id.incEdge = 0;
};
} else {
if ((_arg2.ex + _local7) < (_arg2.ey + _local8)){
_arg1.nx = -(_arg2.r11);
_arg1.ny = -(_arg2.r21);
_local9.sep = ((_arg3.radius + _arg2.ex) + _local7);
_local9.id.incEdge = 1;
} else {
_arg1.nx = -(_arg2.r12);
_arg1.ny = -(_arg2.r22);
_local9.sep = ((_arg3.radius + _arg2.ey) + _local8);
_local9.id.incEdge = 2;
};
};
};
_local9.sep = -(_local9.sep);
} else {
_local7 = (_arg3.x - _local13);
_local8 = (_arg3.y - _local14);
_local6 = Math.sqrt(((_local7 * _local7) + (_local8 * _local8)));
_arg1.nx = (_local7 / _local6);
_arg1.ny = (_local8 / _local6);
_local9.id.incVert = _local11;
_local9.id.incEdge = _local12;
_local9.sep = -((_arg3.radius - Math.sqrt(_local5)));
};
_local9.x = (_arg3.x - (_arg3.radius * _arg1.nx));
_local9.y = (_arg3.y - (_arg3.radius * _arg1.ny));
_local9.id.bake();
} else {
_local24 = _arg3.x;
_local25 = _arg3.y;
_local27 = _arg3.radius;
_local5 = -2147483648;
_local28 = BoxCircleContact(_arg4);
_local20 = _local28.p;
_local21 = _local28.d;
_local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y)));
if (_local26 > _local27){
_arg1.pointCount = 0;
_local28.p = _local20;
_local28.d = _local21;
return;
};
if (_local26 > _local5){
_local5 = _local26;
_local22 = _local21;
_local23 = _local20;
};
_local20 = _local20.next;
_local21 = _local21.next;
_local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y)));
if (_local26 > _local27){
_local28.p = _local20;
_local28.d = _local21;
_arg1.pointCount = 0;
return;
};
if (_local26 > _local5){
_local5 = _local26;
_local22 = _local21;
_local23 = _local20;
};
_local20 = _local20.next;
_local21 = _local21.next;
_local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y)));
if (_local26 > _local27){
_local28.p = _local20;
_local28.d = _local21;
_arg1.pointCount = 0;
return;
};
if (_local26 > _local5){
_local5 = _local26;
_local22 = _local21;
_local23 = _local20;
};
_local20 = _local20.next;
_local21 = _local21.next;
_local26 = ((_local21.x * (_local24 - _local20.x)) + (_local21.y * (_local25 - _local20.y)));
if (_local26 > _local27){
_local28.p = _local20;
_local28.d = _local21;
_arg1.pointCount = 0;
return;
};
if (_local26 > _local5){
_local5 = _local26;
_local22 = _local21;
_local23 = _local20;
};
if (_local5 < 1E-6){
_arg1.pointCount = 1;
_arg1.nx = _local22.x;
_arg1.ny = _local22.y;
_local9 = _arg1.c0;
_local9.id.incEdge = _local22.index;
_local9.id.incVert = _local10;
_local9.id.refFace = _local10;
_local9.id.flip = 0;
_local9.id.bake();
_local9.x = (_local24 - (_local27 * _arg1.nx));
_local9.y = (_local25 - (_local27 * _arg1.ny));
_local9.sep = (_local5 - _local27);
return;
};
_local31 = _local23.index;
if (_local31 == 0){
_local6 = (_arg2.ex * 2);
_local29 = -(_arg2.r11);
_local30 = -(_arg2.r21);
} else {
if (_local31 == 1){
_local29 = -(_arg2.r12);
_local30 = -(_arg2.r22);
_local6 = (_arg2.ey * 2);
} else {
if (_local31 == 2){
_local29 = _arg2.r11;
_local30 = _arg2.r21;
_local6 = (_arg2.ex * 2);
} else {
if (_local31 == 3){
_local29 = _arg2.r12;
_local30 = _arg2.r22;
_local6 = (_arg2.ey * 2);
};
};
};
};
if (_local6 < 1E-6){
_local7 = (_local24 - _local23.x);
_local8 = (_local25 - _local23.y);
_local32 = ((_local7 * _local7) + (_local8 * _local8));
if (_local32 > _arg3.radiusSq){
_arg1.pointCount = 0;
return;
};
_local32 = Math.sqrt(_local32);
_local7 = (_local7 / _local32);
_local8 = (_local8 / _local32);
_arg1.pointCount = 1;
_arg1.nx = _local7;
_arg1.ny = _local8;
_local9 = _arg1.c0;
_local9.id.incVert = (_local31 + 1);
_local9.id.incEdge = _local10;
_local9.id.refFace = _local10;
_local9.id.flip = 0;
_local9.id.bake();
_local9.x = (_local24 - (_arg3.radius * _local7));
_local9.y = (_local25 - (_arg3.radius * _local8));
_local9.sep = (_local32 - _local27);
return;
};
_local9 = _arg1.c0;
_local9.id.flip = 0;
_local9.id.refFace = _local10;
_local35 = (((_local24 - _local23.x) * _local29) + ((_local25 - _local23.y) * _local30));
if (_local35 <= 0){
_local33 = _local23.x;
_local34 = _local23.y;
_local9.id.incVert = _local23.index;
_local9.id.incEdge = _local10;
} else {
if (_local35 >= _local6){
_local33 = _local23.next.x;
_local34 = _local23.next.y;
_local9.id.incVert = _local23.next.index;
_local9.id.incEdge = _local10;
} else {
_local33 = ((_local29 * _local35) + _local23.x);
_local34 = ((_local30 * _local35) + _local23.y);
_local9.id.incVert = _local10;
_local9.id.incEdge = _local23.index;
};
};
_local7 = (_local24 - _local33);
_local8 = (_local25 - _local34);
_local32 = ((_local7 * _local7) + (_local8 * _local8));
if (_local32 > _arg3.radiusSq){
_arg1.pointCount = 0;
return;
};
_local32 = Math.sqrt(_local32);
_local7 = (_local7 / _local32);
_local8 = (_local8 / _local32);
_arg1.pointCount = 1;
_arg1.nx = _local7;
_arg1.ny = _local8;
_local9.x = (_local24 - (_local27 * _local7));
_local9.y = (_local25 - (_local27 * _local8));
_local9.sep = (_local32 - _local27);
_local9.id.bake();
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 63
//CollideBoxLineDoubleSided (de.polygonal.motor2.collision.pairwise.CollideBoxLineDoubleSided)
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 CollideBoxLineDoubleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:V2;
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:Number;
var _local16:Number;
var _local28:int;
var _local32:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:ContactPoint;
var _local42:V2;
var _local12:Number = -2147483648;
var _local13:int;
_local8 = _arg3.worldVertexChain;
_local7 = _arg3.worldNormalChain;
_local5 = _arg2.worldVertexChain;
var _local14:V2 = _local5;
var _local15:Number = ((_local5.x * _local7.x) + (_local5.y * _local7.y));
_local5 = _local5.next;
_local16 = ((_local5.x * _local7.x) + (_local5.y * _local7.y));
if (_local16 < _local15){
_local15 = _local16;
_local14 = _local5;
};
_local5 = _local5.next;
_local16 = ((_local5.x * _local7.x) + (_local5.y * _local7.y));
if (_local16 < _local15){
_local15 = _local16;
_local14 = _local5;
};
_local5 = _local5.next;
_local16 = ((_local5.x * _local7.x) + (_local5.y * _local7.y));
if (_local16 < _local15){
_local15 = _local16;
_local14 = _local5;
};
_local5 = _local14;
_local11 = ((_local7.x * (_local5.x - _local8.x)) + (_local7.y * (_local5.y - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local5;
_local13 = 1;
};
_local8 = _local8.next;
_local7 = _local7.next;
_local5 = _local5.next.next;
_local11 = ((_local7.x * (_local5.x - _local8.x)) + (_local7.y * (_local5.y - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local5;
_local13 = 1;
};
var _local17:V2 = _arg3.worldVertexChain;
var _local18:V2 = _local17.next;
var _local19:Number = _local17.x;
var _local20:Number = _local18.x;
var _local21:Number = _local17.y;
var _local22:Number = _local18.y;
_local8 = _arg2.worldVertexChain.next;
_local7 = _arg2.worldNormalChain.next;
if (((_local19 * _local7.x) + (_local21 * _local7.y)) < ((_local20 * _local7.x) + (_local22 * _local7.y))){
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
} else {
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
};
_local8 = _arg2.worldVertexChain;
_local7 = _arg2.worldNormalChain;
if (((_local19 * _local7.x) + (_local21 * _local7.y)) < ((_local20 * _local7.x) + (_local22 * _local7.y))){
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
} else {
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local6 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
};
var _local23:ShapeSkeleton = _arg2;
var _local24:Number = _local6.x;
var _local25:Number = _local6.y;
var _local26:int = _local9.index;
var _local27:int = _local10.index;
var _local29:V2 = _local10.edge.n;
var _local30:Number = ((_local29.x * _local24) + (_local29.y * _local25));
if (((_local29.prev.x * _local24) + (_local29.prev.y * _local25)) < _local30){
_local10 = _local10.prev;
_local28 = _local29.prev.index;
} else {
if (((_local29.next.x * _local24) + (_local29.next.y * _local25)) < _local30){
_local10 = _local10.next;
_local28 = _local29.next.index;
};
};
var _local31:Number = (((_local23.x * _local24) + (_local23.y * _local25)) + (((_local9.x - _local23.x) * _local24) + ((_local9.y - _local23.y) * _local25)));
if (_local23.regularShape){
_local32 = ((_local23.y * _local24) - (_local23.x * _local25));
} else {
_local42 = _local23.offsets[_local9.index];
_local32 = ((((_local23.y + (_local23.r21 * _local42.x)) + (_local23.r22 * _local42.y)) * _local24) - (((_local23.x + (_local23.r11 * _local42.x)) + (_local23.r12 * _local42.y)) * _local25));
};
var _local33:Number = (_local9.edge.mag / 2);
_local38 = ((((_local10.x * _local25) - (_local10.y * _local24)) + _local32) - _local33);
_local39 = ((((_local10.next.x * _local25) - (_local10.next.y * _local24)) + _local32) - _local33);
if ((_local38 * _local39) < 0){
_local40 = (_local38 / (_local38 - _local39));
if (_local38 < 0){
_local34 = _local10.x;
_local36 = _local10.y;
_local35 = (_local34 + (_local40 * (_local10.next.x - _local34)));
_local37 = (_local36 + (_local40 * (_local10.next.y - _local36)));
} else {
_local34 = _local10.next.x;
_local36 = _local10.next.y;
_local35 = (_local10.x + (_local40 * (_local34 - _local10.x)));
_local37 = (_local10.y + (_local40 * (_local36 - _local10.y)));
};
} else {
if (_local38 > 0){
_arg1.pointCount = 0;
return;
};
if (_local38 < _local39){
_local34 = _local10.x;
_local36 = _local10.y;
_local35 = _local10.next.x;
_local37 = _local10.next.y;
} else {
_local35 = _local10.x;
_local37 = _local10.y;
_local34 = _local10.next.x;
_local36 = _local10.next.y;
};
};
_local38 = ((((_local36 * _local24) - _local32) - _local33) - (_local34 * _local25));
_local39 = ((((_local37 * _local24) - _local32) - _local33) - (_local35 * _local25));
if ((_local38 * _local39) < 0){
_local40 = (_local38 / (_local38 - _local39));
_local34 = (_local34 + (_local40 * (_local35 - _local34)));
_local36 = (_local36 + (_local40 * (_local37 - _local36)));
} else {
if (_local38 > 0){
_arg1.pointCount = 0;
return;
};
};
_local12 = (((_local24 * _local34) + (_local25 * _local36)) - _local31);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local13){
_arg1.nx = -(_local24);
_arg1.ny = -(_local25);
} else {
_arg1.nx = _local24;
_arg1.ny = _local25;
};
_local41 = _arg1.c0;
_local41.sep = _local12;
_local41.x = _local34;
_local41.y = _local36;
_local41.id.flip = _local13;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
_local12 = (((_local24 * _local35) + (_local25 * _local37)) - _local31);
if (_local12 <= 0){
_arg1.pointCount = 2;
_local41 = _arg1.c1;
_local41.sep = _local12;
_local41.x = _local35;
_local41.y = _local37;
_local41.id.flip = _local13;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
};
} else {
_local12 = (((_local24 * _local35) + (_local25 * _local37)) - _local31);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local13){
_arg1.nx = -(_local24);
_arg1.ny = -(_local25);
} else {
_arg1.nx = _local24;
_arg1.ny = _local25;
};
_local41 = _arg1.c0;
_local41.sep = _local12;
_local41.x = _local35;
_local41.y = _local37;
_local41.id.flip = _local13;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 64
//CollideBoxLineSingleSided (de.polygonal.motor2.collision.pairwise.CollideBoxLineSingleSided)
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 CollideBoxLineSingleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:Number;
var _local16:Number;
var _local28:int;
var _local32:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:ContactPoint;
var _local42:V2;
var _local5:V2 = _arg3.worldNormalChain;
if ((((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d) < 0){
_arg4.disabled = true;
_arg1.pointCount = 0;
return;
};
var _local12:Number = -2147483648;
var _local13:int;
_local8 = _arg3.worldVertexChain;
_local7 = _arg3.worldNormalChain;
_local6 = _arg2.worldVertexChain;
var _local14:V2 = _local6;
var _local15:Number = ((_local6.x * _local7.x) + (_local6.y * _local7.y));
_local6 = _local6.next;
_local16 = ((_local6.x * _local7.x) + (_local6.y * _local7.y));
if (_local16 < _local15){
_local15 = _local16;
_local14 = _local6;
};
_local6 = _local6.next;
_local16 = ((_local6.x * _local7.x) + (_local6.y * _local7.y));
if (_local16 < _local15){
_local15 = _local16;
_local14 = _local6;
};
_local6 = _local6.next;
_local16 = ((_local6.x * _local7.x) + (_local6.y * _local7.y));
if (_local16 < _local15){
_local15 = _local16;
_local14 = _local6;
};
_local6 = _local14;
_local11 = ((_local7.x * (_local6.x - _local8.x)) + (_local7.y * (_local6.y - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local6;
_local13 = 1;
};
_local8 = _local8.next;
_local7 = _local7.next;
_local6 = _local6.next.next;
_local11 = ((_local7.x * (_local6.x - _local8.x)) + (_local7.y * (_local6.y - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local6;
_local13 = 1;
};
var _local17:V2 = _arg3.worldVertexChain;
var _local18:V2 = _local17.next;
var _local19:Number = _local17.x;
var _local20:Number = _local18.x;
var _local21:Number = _local17.y;
var _local22:Number = _local18.y;
_local8 = _arg2.worldVertexChain.next;
_local7 = _arg2.worldNormalChain.next;
if (((_local19 * _local7.x) + (_local21 * _local7.y)) < ((_local20 * _local7.x) + (_local22 * _local7.y))){
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
} else {
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
};
_local8 = _arg2.worldVertexChain;
_local7 = _arg2.worldNormalChain;
if (((_local19 * _local7.x) + (_local21 * _local7.y)) < ((_local20 * _local7.x) + (_local22 * _local7.y))){
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
} else {
_local11 = ((_local7.x * (_local20 - _local8.x)) + (_local7.y * (_local22 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local18;
_local13 = 0;
};
_local8 = _local8.next.next;
_local7 = _local7.next.next;
_local11 = ((_local7.x * (_local19 - _local8.x)) + (_local7.y * (_local21 - _local8.y)));
if (_local11 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local11 * 0.95) + 0.01) > _local12){
_local12 = _local11;
_local5 = _local7;
_local9 = _local8;
_local10 = _local17;
_local13 = 0;
};
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
var _local23:ShapeSkeleton = _arg2;
var _local24:Number = _local5.x;
var _local25:Number = _local5.y;
var _local26:int = _local9.index;
var _local27:int = _local10.index;
var _local29:V2 = _local10.edge.n;
var _local30:Number = ((_local29.x * _local24) + (_local29.y * _local25));
if (((_local29.prev.x * _local24) + (_local29.prev.y * _local25)) < _local30){
_local10 = _local10.prev;
_local28 = _local29.prev.index;
} else {
if (((_local29.next.x * _local24) + (_local29.next.y * _local25)) < _local30){
_local10 = _local10.next;
_local28 = _local29.next.index;
};
};
var _local31:Number = (((_local23.x * _local24) + (_local23.y * _local25)) + (((_local9.x - _local23.x) * _local24) + ((_local9.y - _local23.y) * _local25)));
if (_local23.regularShape){
_local32 = ((_local23.y * _local24) - (_local23.x * _local25));
} else {
_local42 = _local23.offsets[_local9.index];
_local32 = ((((_local23.y + (_local23.r21 * _local42.x)) + (_local23.r22 * _local42.y)) * _local24) - (((_local23.x + (_local23.r11 * _local42.x)) + (_local23.r12 * _local42.y)) * _local25));
};
var _local33:Number = (_local9.edge.mag / 2);
_local38 = ((((_local10.x * _local25) - (_local10.y * _local24)) + _local32) - _local33);
_local39 = ((((_local10.next.x * _local25) - (_local10.next.y * _local24)) + _local32) - _local33);
if ((_local38 * _local39) < 0){
_local40 = (_local38 / (_local38 - _local39));
if (_local38 < 0){
_local34 = _local10.x;
_local36 = _local10.y;
_local35 = (_local34 + (_local40 * (_local10.next.x - _local34)));
_local37 = (_local36 + (_local40 * (_local10.next.y - _local36)));
} else {
_local34 = _local10.next.x;
_local36 = _local10.next.y;
_local35 = (_local10.x + (_local40 * (_local34 - _local10.x)));
_local37 = (_local10.y + (_local40 * (_local36 - _local10.y)));
};
} else {
if (_local38 > 0){
_arg1.pointCount = 0;
return;
};
if (_local38 < _local39){
_local34 = _local10.x;
_local36 = _local10.y;
_local35 = _local10.next.x;
_local37 = _local10.next.y;
} else {
_local35 = _local10.x;
_local37 = _local10.y;
_local34 = _local10.next.x;
_local36 = _local10.next.y;
};
};
_local38 = ((((_local36 * _local24) - _local32) - _local33) - (_local34 * _local25));
_local39 = ((((_local37 * _local24) - _local32) - _local33) - (_local35 * _local25));
if ((_local38 * _local39) < 0){
_local40 = (_local38 / (_local38 - _local39));
_local34 = (_local34 + (_local40 * (_local35 - _local34)));
_local36 = (_local36 + (_local40 * (_local37 - _local36)));
} else {
if (_local38 > 0){
_arg1.pointCount = 0;
return;
};
};
_local12 = (((_local24 * _local34) + (_local25 * _local36)) - _local31);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local13){
_arg1.nx = -(_local24);
_arg1.ny = -(_local25);
} else {
_arg1.nx = _local24;
_arg1.ny = _local25;
};
_local41 = _arg1.c0;
_local41.sep = _local12;
_local41.x = _local34;
_local41.y = _local36;
_local41.id.flip = _local13;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
_local12 = (((_local24 * _local35) + (_local25 * _local37)) - _local31);
if (_local12 <= 0){
_arg1.pointCount = 2;
_local41 = _arg1.c1;
_local41.sep = _local12;
_local41.x = _local35;
_local41.y = _local37;
_local41.id.flip = _local13;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
};
} else {
_local12 = (((_local24 * _local35) + (_local25 * _local37)) - _local31);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local13){
_arg1.nx = -(_local24);
_arg1.ny = -(_local25);
} else {
_arg1.nx = _local24;
_arg1.ny = _local25;
};
_local41 = _arg1.c0;
_local41.sep = _local12;
_local41.x = _local35;
_local41.y = _local37;
_local41.id.flip = _local13;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 65
//CollideBoxPlaneDoubleSided (de.polygonal.motor2.collision.pairwise.CollideBoxPlaneDoubleSided)
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 CollideBoxPlaneDoubleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local15:Number;
var _local18:int;
var _local19:int;
var _local5:Number = _arg3.worldNormalChain.x;
var _local6:Number = _arg3.worldNormalChain.y;
var _local7:Number = ((_local5 * _arg2.r11) + (_local6 * _arg2.r21));
var _local8:Number = ((_local5 * _arg2.r12) + (_local6 * _arg2.r22));
var _local9:Number = ((_arg2.ex * ((_local7 < 0)) ? -(_local7) : _local7) + (_arg2.ey * ((_local8 < 0)) ? -(_local8) : _local8));
var _local10:Number = _arg3.d;
var _local11:Number = (((_local5 * _arg2.x) + (_local6 * _arg2.y)) - _local10);
if (_local11 > 0){
if (_local11 > _local9){
_arg1.pointCount = 0;
return;
};
} else {
if (_local11 < -(_local9)){
_arg1.pointCount = 0;
return;
};
_local5 = -(_local5);
_local6 = -(_local6);
_local10 = -(_local10);
};
var _local12:V2 = _arg2.worldVertexChain;
var _local13:V2 = _local12;
var _local14:Number = ((_local12.x * _local5) + (_local12.y * _local6));
_local12 = _local12.next;
_local15 = ((_local12.x * _local5) + (_local12.y * _local6));
if (_local15 < _local14){
_local14 = _local15;
_local13 = _local12;
};
_local12 = _local12.next;
_local15 = ((_local12.x * _local5) + (_local12.y * _local6));
if (_local15 < _local14){
_local14 = _local15;
_local13 = _local12;
};
_local12 = _local12.next;
_local15 = ((_local12.x * _local5) + (_local12.y * _local6));
if (_local15 < _local14){
_local14 = _local15;
_local13 = _local12;
};
_local12 = _local13;
_arg1.nx = -(_local5);
_arg1.ny = -(_local6);
_arg1.pointCount = 1;
var _local16:ContactPoint = _arg1.c0;
_local16.sep = (((_local12.x * _local5) + (_local12.y * _local6)) - _local10);
_local16.x = _local12.x;
_local16.y = _local12.y;
var _local17:V2 = _local12.edge.n;
var _local20:Number = ((_local17.x * _local5) + (_local17.y * _local6));
if (((_local17.prev.x * _local5) + (_local17.prev.y * _local6)) < _local20){
_local18 = _local17.prev.index;
_local16.id.flip = 0;
_local16.id.incEdge = _local18;
_local16.id.incVert = _local19;
_local16.id.refFace = 0;
_local16.id.bake();
_local12 = _local12.prev;
_local11 = (((_local12.x * _local5) + (_local12.y * _local6)) - _local10);
if (_local11 < 0){
_local16 = _arg1.c1;
_local16.sep = _local11;
_local16.x = _local12.x;
_local16.y = _local12.y;
_local16.id.flip = 0;
_local16.id.incEdge = _local18;
_local16.id.incVert = _local19;
_local16.id.refFace = 0;
_local16.id.bake();
_arg1.pointCount++;
};
} else {
_local18 = _local17.next.index;
_local16.id.flip = 0;
_local16.id.incEdge = _local18;
_local16.id.incVert = _local19;
_local16.id.refFace = 0;
_local16.id.bake();
_local12 = _local12.next;
_local11 = (((_local12.x * _local5) + (_local12.y * _local6)) - _local10);
if (_local11 < 0){
_local16 = _arg1.c1;
_local16.sep = _local11;
_local16.x = _local12.x;
_local16.y = _local12.y;
_local16.id.flip = 0;
_local16.id.incEdge = _local18;
_local16.id.incVert = _local19;
_local16.id.refFace = 0;
_local16.id.bake();
_arg1.pointCount++;
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 66
//CollideBoxPlaneSingleSided (de.polygonal.motor2.collision.pairwise.CollideBoxPlaneSingleSided)
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 CollideBoxPlaneSingleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:Number;
var _local7:V2;
var _local8:V2;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:ContactPoint;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local5:Number = _arg3.worldNormalChain.x;
_local6 = _arg3.worldNormalChain.y;
if (_arg1.pointCount > 0){
_local8 = _arg2.worldVertexChain;
_local7 = _local8;
_local9 = ((_local7.x * _local5) + (_local7.y * _local6));
_local7 = _local7.next;
_local10 = ((_local7.x * _local5) + (_local7.y * _local6));
if (_local10 < _local9){
_local9 = _local10;
_local8 = _local7;
};
_local7 = _local7.next;
_local10 = ((_local7.x * _local5) + (_local7.y * _local6));
if (_local10 < _local9){
_local9 = _local10;
_local8 = _local7;
};
_local7 = _local7.next;
_local10 = ((_local7.x * _local5) + (_local7.y * _local6));
if (_local10 < _local9){
_local9 = _local10;
_local8 = _local7;
};
_local7 = _local8;
_local11 = _arg3.d;
_local12 = (((_local7.x * _local5) + (_local7.y * _local6)) - _local11);
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
_arg1.pointCount = 1;
_arg1.nx = -(_local5);
_arg1.ny = -(_local6);
_local13 = _arg1.c0;
_local13.sep = _local12;
_local13.x = _local7.x;
_local13.y = _local7.y;
_local13.id.key = 0;
_local12 = (((_local7.prev.x * _local5) + (_local7.prev.y * _local6)) - _local11);
if (_local12 < 0){
_local13.id.key = 1;
_local13 = _arg1.c1;
_local13.sep = _local12;
_local13.x = _local7.prev.x;
_local13.y = _local7.prev.y;
_local13.id.key = 1;
_arg1.pointCount++;
} else {
_local12 = (((_local7.next.x * _local5) + (_local7.next.y * _local6)) - _local11);
if (_local12 < 0){
_local13.id.key = 1;
_local13 = _arg1.c1;
_local13.sep = _local12;
_local13.x = _local7.next.x;
_local13.y = _local7.next.y;
_local13.id.key = 1;
_arg1.pointCount++;
};
};
} else {
_local14 = ((_local5 * _arg2.r11) + (_local6 * _arg2.r21));
_local15 = ((_local5 * _arg2.r12) + (_local6 * _arg2.r22));
_local16 = ((_arg2.ex * ((_local14 < 0)) ? -(_local14) : _local14) + (_arg2.ey * ((_local15 < 0)) ? -(_local15) : _local15));
if ((((_local5 * _arg2.x) + (_local6 * _arg2.y)) - _arg3.d) > _local16){
_arg1.pointCount = 0;
return;
};
_local11 = _arg3.d;
_local8 = _arg2.worldVertexChain;
_local7 = _local8;
_local9 = ((_local7.x * _local5) + (_local7.y * _local6));
_local7 = _local7.next;
_local10 = ((_local7.x * _local5) + (_local7.y * _local6));
if (_local10 < _local9){
_local9 = _local10;
_local8 = _local7;
};
_local7 = _local7.next;
_local10 = ((_local7.x * _local5) + (_local7.y * _local6));
if (_local10 < _local9){
_local9 = _local10;
_local8 = _local7;
};
_local7 = _local7.next;
_local10 = ((_local7.x * _local5) + (_local7.y * _local6));
if (_local10 < _local9){
_local9 = _local10;
_local8 = _local7;
};
_local7 = _local8;
_local12 = (((_local7.x * _local5) + (_local7.y * _local6)) - _local11);
_arg1.pointCount = 1;
_arg1.nx = -(_local5);
_arg1.ny = -(_local6);
_local13 = _arg1.c0;
_local13.sep = _local12;
_local13.x = _local7.x;
_local13.y = _local7.y;
_local13.id.key = 0;
_local12 = (((_local7.prev.x * _local5) + (_local7.prev.y * _local6)) - _local11);
if (_local12 < 0){
_local13.id.key = 1;
_local13 = _arg1.c1;
_local13.sep = _local12;
_local13.x = _local7.prev.x;
_local13.y = _local7.prev.y;
_local13.id.key = 1;
_arg1.pointCount++;
} else {
_local12 = (((_local7.next.x * _local5) + (_local7.next.y * _local6)) - _local11);
if (_local12 < 0){
_local13.id.key = 1;
_local13 = _arg1.c1;
_local13.sep = _local12;
_local13.x = _local7.next.x;
_local13.y = _local7.next.y;
_local13.id.key = 1;
_arg1.pointCount++;
};
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 67
//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 68
//CollideCircleLineDoubleSided (de.polygonal.motor2.collision.pairwise.CollideCircleLineDoubleSided)
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 CollideCircleLineDoubleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ContactPoint;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local6:V2 = _arg3.worldVertexChain;
var _local7:V2 = _local6.next;
var _local8:Number = _arg2.radiusSq;
var _local9:Number = _local6.x;
var _local10:Number = _local7.x;
var _local11:Number = _arg2.x;
var _local12:Number = _local6.y;
var _local13:Number = _local7.y;
var _local14:Number = _arg2.y;
var _local15:Number = (_local10 - _local9);
var _local16:Number = (_local13 - _local12);
var _local17:Number = (_local11 - _local9);
var _local18:Number = (_local14 - _local12);
var _local23:Number = ((_local17 * _local15) + (_local18 * _local16));
if (_local23 < 0){
_local19 = ((_local17 * _local17) + (_local18 * _local18));
if (_local19 > _local8){
_arg1.pointCount = 0;
return;
};
_local20 = Math.sqrt(_local19);
_local21 = (_local17 / _local20);
_local22 = (_local18 / _local20);
_local5 = _arg1.c0;
_local5.id.incEdge = _local6.index;
_local5.id.incVert = _local6.index;
} else {
_local25 = (_local10 - _local11);
_local26 = (_local13 - _local14);
_local23 = ((_local25 * _local15) + (_local26 * _local16));
if (_local23 < 0){
_local19 = ((_local25 * _local25) + (_local26 * _local26));
if (_local19 > _local8){
_arg1.pointCount = 0;
return;
};
_local20 = Math.sqrt(_local19);
_local21 = (-(_local25) / _local20);
_local22 = (-(_local26) / _local20);
_local5 = _arg1.c0;
_local5.id.incEdge = _local7.index;
_local5.id.incVert = _local7.index;
} else {
_local27 = ((_local18 * _local15) - (_local17 * _local16));
_local19 = ((((_local18 * _local15) - (_local17 * _local16)) * _local27) / ((_local15 * _local15) + (_local16 * _local16)));
if (_local19 > _local8){
_arg1.pointCount = 0;
return;
};
_local20 = Math.sqrt(_local19);
_local21 = (-(_local13) + _local12);
_local22 = (_local10 - _local9);
_local28 = (Math.sqrt(((_local21 * _local21) + (_local22 * _local22))) * ((((_local21 * _local17) + (_local22 * _local18)) < 0)) ? -1 : 1);
_local21 = (_local21 / _local28);
_local22 = (_local22 / _local28);
_local5 = _arg1.c0;
_local5.id.incEdge = _local6.index;
_local5.id.incVert = _local7.index;
};
};
_arg1.pointCount = 1;
_arg1.nx = -(_local21);
_arg1.ny = -(_local22);
_local5.id.refFace = ContactID.NULL_FEATURE;
_local5.id.flip = 0;
_local5.id.bake();
var _local24:Number = _arg2.radius;
_local5.x = (_local11 - (_local24 * _local21));
_local5.y = (_local14 - (_local24 * _local22));
_local5.sep = (_local20 - _local24);
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 69
//CollideCircleLineSingleSided (de.polygonal.motor2.collision.pairwise.CollideCircleLineSingleSided)
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 CollideCircleLineSingleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ContactPoint;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local6:V2 = _arg3.worldNormalChain;
if ((((_arg2.x * _local6.x) + (_arg2.y * _local6.y)) - _arg3.d) < 0){
_arg4.disabled = true;
_arg1.pointCount = 0;
return;
};
var _local7:V2 = _arg3.worldVertexChain;
var _local8:V2 = _local7.next;
var _local9:Number = _arg2.radiusSq;
var _local10:Number = _local7.x;
var _local11:Number = _local8.x;
var _local12:Number = _arg2.x;
var _local13:Number = _local7.y;
var _local14:Number = _local8.y;
var _local15:Number = _arg2.y;
var _local16:Number = (_local11 - _local10);
var _local17:Number = (_local14 - _local13);
var _local18:Number = (_local12 - _local10);
var _local19:Number = (_local15 - _local13);
var _local24:Number = ((_local18 * _local16) + (_local19 * _local17));
if (_local24 < 0){
_local22 = _arg3.worldNormalChain.x;
_local23 = _arg3.worldNormalChain.y;
if (((_local22 * _local18) + (_local23 * _local19)) < 0){
_arg1.pointCount = 0;
return;
};
_local20 = ((_local18 * _local18) + (_local19 * _local19));
if (_local20 > _local9){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
_local21 = Math.sqrt(_local20);
_local22 = (_local18 / _local21);
_local23 = (_local19 / _local21);
_local5 = _arg1.c0;
_local5.id.incEdge = _local7.index;
_local5.id.incVert = _local7.index;
} else {
_local26 = (_local11 - _local12);
_local27 = (_local14 - _local15);
_local24 = ((_local26 * _local16) + (_local27 * _local17));
_local22 = _arg3.worldNormalChain.x;
_local23 = _arg3.worldNormalChain.y;
if (((_local22 * _local26) + (_local23 * _local27)) > 0){
_arg1.pointCount = 0;
return;
};
if (_local24 < 0){
_local20 = ((_local26 * _local26) + (_local27 * _local27));
if (_local20 > _local9){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
_local21 = Math.sqrt(_local20);
_local22 = (-(_local26) / _local21);
_local23 = (-(_local27) / _local21);
_local5 = _arg1.c0;
_local5.id.incEdge = _local8.index;
_local5.id.incVert = _local8.index;
} else {
_local28 = ((_local19 * _local16) - (_local18 * _local17));
if (_local28 > 0){
_arg1.pointCount = 0;
return;
};
_local20 = ((_local28 * _local28) / ((_local16 * _local16) + (_local17 * _local17)));
if (_local20 > _local9){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
_local21 = Math.sqrt(_local20);
_local22 = (-(_local14) + _local13);
_local23 = (_local11 - _local10);
_local29 = (Math.sqrt(((_local22 * _local22) + (_local23 * _local23))) * ((((_local22 * _local18) + (_local23 * _local19)) < 0)) ? -1 : 1);
_local22 = (_local22 / _local29);
_local23 = (_local23 / _local29);
_local5 = _arg1.c0;
_local5.id.incEdge = _local7.index;
_local5.id.incVert = _local8.index;
};
};
_arg1.pointCount = 1;
_arg1.nx = -(_local22);
_arg1.ny = -(_local23);
_local5.id.refFace = ContactID.NULL_FEATURE;
_local5.id.flip = 0;
_local5.id.bake();
var _local25:Number = _arg2.radius;
_local5.x = (_local12 - (_local25 * _local22));
_local5.y = (_local15 - (_local25 * _local23));
_local5.sep = (_local21 - _local25);
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 70
//CollideCirclePlaneDoubleSided (de.polygonal.motor2.collision.pairwise.CollideCirclePlaneDoubleSided)
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 CollideCirclePlaneDoubleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ContactPoint;
var _local7:Number;
var _local6:V2 = _arg3.worldNormalChain;
_local7 = _arg2.radius;
var _local8:Number = (((_arg2.x * _local6.x) + (_arg2.y * _local6.y)) - _arg3.d);
if (_local8 > 0){
if (_local8 <= _local7){
_arg1.pointCount = 1;
_arg1.nx = -(_local6.x);
_arg1.ny = -(_local6.y);
_local5 = _arg1.c0;
_local5.id.key = 0;
_local5.sep = (_local8 - _local7);
_local5.x = (_arg2.x - (_local7 * _local6.x));
_local5.y = (_arg2.y - (_local7 * _local6.y));
return;
};
} else {
if (-(_local8) <= _local7){
_arg1.pointCount = 1;
_arg1.nx = _local6.x;
_arg1.ny = _local6.y;
_local5 = _arg1.c0;
_local5.id.key = 1;
_local5.sep = (-(_local7) - _local8);
_local5.x = (_arg2.x + (_local7 * _local6.x));
_local5.y = (_arg2.y + (_local7 * _local6.y));
return;
};
};
_arg1.pointCount = 0;
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 71
//CollideCirclePlaneSingleSided (de.polygonal.motor2.collision.pairwise.CollideCirclePlaneSingleSided)
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 CollideCirclePlaneSingleSided implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local7:Number;
var _local8:ContactPoint;
var _local5:V2 = _arg3.worldNormalChain;
var _local6:Number = _arg2.radius;
_local7 = (((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d);
if (_local7 <= _local6){
_arg1.pointCount = 1;
_arg1.nx = -(_local5.x);
_arg1.ny = -(_local5.y);
_local8 = _arg1.c0;
_local8.x = (_arg2.x - (_local6 * _local5.x));
_local8.y = (_arg2.y - (_local6 * _local5.y));
_local8.sep = (_local7 - _local6);
return;
};
_arg1.pointCount = 0;
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 72
//CollidePolyBSP (de.polygonal.motor2.collision.pairwise.CollidePolyBSP)
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 CollidePolyBSP implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local13:Number;
var _local14:int;
var _local15:ConvexBSPNode;
var _local21:int;
var _local25:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:ContactPoint;
var _local35:V2;
var _local5:PolyContact = PolyContact(_arg4);
var _local12:Number = -2147483648;
_local6 = _local5.p;
_local7 = _local5.d;
if (_local5.firstOut){
while (true) {
_local15 = _arg3.BSPNode;
while (_local15.R) {
_local15 = ((((_local15.N.x * _local7.y) - (_local15.N.y * _local7.x)))<=0) ? _local15.R : _local15.L;
};
_local8 = _local15.V;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
_local6 = _arg3.worldVertexChain;
_local7 = _arg3.worldNormalChain;
while (true) {
_local15 = _arg2.BSPNode;
while (_local15.R) {
_local15 = ((((_local15.N.x * _local7.y) - (_local15.N.y * _local7.x)))<=0) ? _local15.R : _local15.L;
};
_local8 = _local15.V;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = false;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
} else {
while (true) {
_local15 = _arg2.BSPNode;
while (_local15.R) {
_local15 = ((((_local15.N.x * _local7.y) - (_local15.N.y * _local7.x)))<=0) ? _local15.R : _local15.L;
};
_local8 = _local15.V;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
_local6 = _arg2.worldVertexChain;
_local7 = _arg2.worldNormalChain;
while (true) {
_local15 = _arg3.BSPNode;
while (_local15.R) {
_local15 = ((((_local15.N.x * _local7.y) - (_local15.N.y * _local7.x)))<=0) ? _local15.R : _local15.L;
};
_local8 = _local15.V;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = true;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 0;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
};
var _local16:ShapeSkeleton = (_local14) ? _arg3 : _arg2;
var _local17:Number = _local9.x;
var _local18:Number = _local9.y;
var _local19:int = _local11.index;
var _local20:int = _local10.index;
var _local22:V2 = _local10.edge.n;
var _local23:Number = ((_local22.x * _local17) + (_local22.y * _local18));
if (((_local22.prev.x * _local17) + (_local22.prev.y * _local18)) < _local23){
_local10 = _local10.prev;
_local21 = _local22.prev.index;
} else {
if (((_local22.next.x * _local17) + (_local22.next.y * _local18)) < _local23){
_local10 = _local10.next;
_local21 = _local22.next.index;
};
};
var _local24:Number = (((_local16.x * _local17) + (_local16.y * _local18)) + (((_local11.x - _local16.x) * _local17) + ((_local11.y - _local16.y) * _local18)));
if (_local16.regularShape){
_local25 = ((_local16.y * _local17) - (_local16.x * _local18));
} else {
_local35 = _local16.offsets[_local11.index];
_local25 = ((((_local16.y + (_local16.r21 * _local35.x)) + (_local16.r22 * _local35.y)) * _local17) - (((_local16.x + (_local16.r11 * _local35.x)) + (_local16.r12 * _local35.y)) * _local18));
};
var _local26:Number = (_local11.edge.mag / 2);
_local31 = ((((_local10.x * _local18) - (_local10.y * _local17)) + _local25) - _local26);
_local32 = ((((_local10.next.x * _local18) - (_local10.next.y * _local17)) + _local25) - _local26);
if ((_local31 * _local32) < 0){
_local33 = (_local31 / (_local31 - _local32));
if (_local31 < 0){
_local27 = _local10.x;
_local29 = _local10.y;
_local28 = (_local27 + (_local33 * (_local10.next.x - _local27)));
_local30 = (_local29 + (_local33 * (_local10.next.y - _local29)));
} else {
_local27 = _local10.next.x;
_local29 = _local10.next.y;
_local28 = (_local10.x + (_local33 * (_local27 - _local10.x)));
_local30 = (_local10.y + (_local33 * (_local29 - _local10.y)));
};
} else {
if (_local31 > 0){
_arg1.pointCount = 0;
return;
};
if (_local31 < _local32){
_local27 = _local10.x;
_local29 = _local10.y;
_local28 = _local10.next.x;
_local30 = _local10.next.y;
} else {
_local28 = _local10.x;
_local30 = _local10.y;
_local27 = _local10.next.x;
_local29 = _local10.next.y;
};
};
_local31 = ((((_local29 * _local17) - _local25) - _local26) - (_local27 * _local18));
_local32 = ((((_local30 * _local17) - _local25) - _local26) - (_local28 * _local18));
if ((_local31 * _local32) < 0){
_local33 = (_local31 / (_local31 - _local32));
_local27 = (_local27 + (_local33 * (_local28 - _local27)));
_local29 = (_local29 + (_local33 * (_local30 - _local29)));
} else {
if (_local31 > 0){
_arg1.pointCount = 0;
return;
};
};
_local12 = (((_local17 * _local27) + (_local18 * _local29)) - _local24);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local17);
_arg1.ny = -(_local18);
} else {
_arg1.nx = _local17;
_arg1.ny = _local18;
};
_local34 = _arg1.c0;
_local34.sep = _local12;
_local34.x = _local27;
_local34.y = _local29;
_local34.id.flip = _local14;
_local34.id.incEdge = _local21;
_local34.id.incVert = _local20;
_local34.id.refFace = _local19;
_local34.id.bake();
_local12 = (((_local17 * _local28) + (_local18 * _local30)) - _local24);
if (_local12 <= 0){
_arg1.pointCount = 2;
_local34 = _arg1.c1;
_local34.sep = _local12;
_local34.x = _local28;
_local34.y = _local30;
_local34.id.flip = _local14;
_local34.id.incEdge = _local21;
_local34.id.incVert = _local20;
_local34.id.refFace = _local19;
_local34.id.bake();
};
} else {
_local12 = (((_local17 * _local28) + (_local18 * _local30)) - _local24);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local17);
_arg1.ny = -(_local18);
} else {
_arg1.nx = _local17;
_arg1.ny = _local18;
};
_local34 = _arg1.c0;
_local34.sep = _local12;
_local34.x = _local28;
_local34.y = _local30;
_local34.id.flip = _local14;
_local34.id.incEdge = _local21;
_local34.id.incVert = _local20;
_local34.id.refFace = _local19;
_local34.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 73
//CollidePolyCHC (de.polygonal.motor2.collision.pairwise.CollidePolyCHC)
package de.polygonal.motor2.collision.pairwise {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import flash.utils.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class CollidePolyCHC implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local13:Number;
var _local14:int;
var _local16:Number;
var _local17:Number;
var _local23:int;
var _local27:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:ContactPoint;
var _local37:V2;
var _local5:PolyContact = PolyContact(_arg4);
var _local12:Number = -2147483648;
var _local15:Dictionary = _local5.hc;
_local6 = _local5.p;
_local7 = _local5.d;
if (_local5.firstOut){
while (true) {
_local8 = ((_local15[_local7]) || (_arg3.worldVertexChain));
_local17 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
while (true) {
_local16 = ((_local8.prev.x * _local7.x) + (_local8.prev.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.prev;
_local17 = _local16;
} else {
_local16 = ((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.next;
_local17 = _local16;
} else {
break;
};
};
};
_local15[_local7] = _local8;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
_local6 = _arg3.worldVertexChain;
_local7 = _arg3.worldNormalChain;
while (true) {
_local8 = ((_local15[_local7]) || (_arg2.worldVertexChain));
_local17 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
while (true) {
_local16 = ((_local8.prev.x * _local7.x) + (_local8.prev.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.prev;
_local17 = _local16;
} else {
_local16 = ((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.next;
_local17 = _local16;
} else {
break;
};
};
};
_local15[_local7] = _local8;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = false;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
} else {
while (true) {
_local8 = ((_local15[_local7]) || (_arg2.worldVertexChain));
_local17 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
while (true) {
_local16 = ((_local8.prev.x * _local7.x) + (_local8.prev.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.prev;
_local17 = _local16;
} else {
_local16 = ((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.next;
_local17 = _local16;
} else {
break;
};
};
};
_local15[_local7] = _local8;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
_local6 = _arg2.worldVertexChain;
_local7 = _arg2.worldNormalChain;
while (true) {
_local8 = ((_local15[_local7]) || (_arg3.worldVertexChain));
_local17 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
while (true) {
_local16 = ((_local8.prev.x * _local7.x) + (_local8.prev.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.prev;
_local17 = _local16;
} else {
_local16 = ((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y));
if (_local16 < _local17){
_local8 = _local8.next;
_local17 = _local16;
} else {
break;
};
};
};
_local15[_local7] = _local8;
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = true;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 0;
};
if (_local6.isTail){
break;
};
_local6 = _local6.next;
_local7 = _local7.next;
};
};
var _local18:ShapeSkeleton = (_local14) ? _arg3 : _arg2;
var _local19:Number = _local9.x;
var _local20:Number = _local9.y;
var _local21:int = _local11.index;
var _local22:int = _local10.index;
var _local24:V2 = _local10.edge.n;
var _local25:Number = ((_local24.x * _local19) + (_local24.y * _local20));
if (((_local24.prev.x * _local19) + (_local24.prev.y * _local20)) < _local25){
_local10 = _local10.prev;
_local23 = _local24.prev.index;
} else {
if (((_local24.next.x * _local19) + (_local24.next.y * _local20)) < _local25){
_local10 = _local10.next;
_local23 = _local24.next.index;
};
};
var _local26:Number = (((_local18.x * _local19) + (_local18.y * _local20)) + (((_local11.x - _local18.x) * _local19) + ((_local11.y - _local18.y) * _local20)));
if (_local18.regularShape){
_local27 = ((_local18.y * _local19) - (_local18.x * _local20));
} else {
_local37 = _local18.offsets[_local11.index];
_local27 = ((((_local18.y + (_local18.r21 * _local37.x)) + (_local18.r22 * _local37.y)) * _local19) - (((_local18.x + (_local18.r11 * _local37.x)) + (_local18.r12 * _local37.y)) * _local20));
};
var _local28:Number = (_local11.edge.mag / 2);
_local33 = ((((_local10.x * _local20) - (_local10.y * _local19)) + _local27) - _local28);
_local34 = ((((_local10.next.x * _local20) - (_local10.next.y * _local19)) + _local27) - _local28);
if ((_local33 * _local34) < 0){
_local35 = (_local33 / (_local33 - _local34));
if (_local33 < 0){
_local29 = _local10.x;
_local31 = _local10.y;
_local30 = (_local29 + (_local35 * (_local10.next.x - _local29)));
_local32 = (_local31 + (_local35 * (_local10.next.y - _local31)));
} else {
_local29 = _local10.next.x;
_local31 = _local10.next.y;
_local30 = (_local10.x + (_local35 * (_local29 - _local10.x)));
_local32 = (_local10.y + (_local35 * (_local31 - _local10.y)));
};
} else {
if (_local33 > 0){
_arg1.pointCount = 0;
return;
};
if (_local33 < _local34){
_local29 = _local10.x;
_local31 = _local10.y;
_local30 = _local10.next.x;
_local32 = _local10.next.y;
} else {
_local30 = _local10.x;
_local32 = _local10.y;
_local29 = _local10.next.x;
_local31 = _local10.next.y;
};
};
_local33 = ((((_local31 * _local19) - _local27) - _local28) - (_local29 * _local20));
_local34 = ((((_local32 * _local19) - _local27) - _local28) - (_local30 * _local20));
if ((_local33 * _local34) < 0){
_local35 = (_local33 / (_local33 - _local34));
_local29 = (_local29 + (_local35 * (_local30 - _local29)));
_local31 = (_local31 + (_local35 * (_local32 - _local31)));
} else {
if (_local33 > 0){
_arg1.pointCount = 0;
return;
};
};
_local12 = (((_local19 * _local29) + (_local20 * _local31)) - _local26);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local19);
_arg1.ny = -(_local20);
} else {
_arg1.nx = _local19;
_arg1.ny = _local20;
};
_local36 = _arg1.c0;
_local36.sep = _local12;
_local36.x = _local29;
_local36.y = _local31;
_local36.id.flip = _local14;
_local36.id.incEdge = _local23;
_local36.id.incVert = _local22;
_local36.id.refFace = _local21;
_local36.id.bake();
_local12 = (((_local19 * _local30) + (_local20 * _local32)) - _local26);
if (_local12 <= 0){
_arg1.pointCount = 2;
_local36 = _arg1.c1;
_local36.sep = _local12;
_local36.x = _local30;
_local36.y = _local32;
_local36.id.flip = _local14;
_local36.id.incEdge = _local23;
_local36.id.incVert = _local22;
_local36.id.refFace = _local21;
_local36.id.bake();
};
} else {
_local12 = (((_local19 * _local30) + (_local20 * _local32)) - _local26);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local19);
_arg1.ny = -(_local20);
} else {
_arg1.nx = _local19;
_arg1.ny = _local20;
};
_local36 = _arg1.c0;
_local36.sep = _local12;
_local36.x = _local30;
_local36.y = _local32;
_local36.id.flip = _local14;
_local36.id.incEdge = _local23;
_local36.id.incVert = _local22;
_local36.id.refFace = _local21;
_local36.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 74
//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 _local11:Number;
var _local12:Number;
var _local17:Number;
var _local19:Number;
var _local21:Number;
var _local22:ContactPoint;
var _local24:Number;
var _local25:Number;
var _local9:Number = _arg3.x;
var _local10:Number = _arg3.y;
_local12 = _arg3.radius;
var _local13:Number = -2147483648;
var _local14:ConvexCircleContact = ConvexCircleContact(_arg4);
_local5 = _local14.p;
_local6 = _local14.d;
var _local15:int = _local5.prev.index;
while (true) {
_local11 = ((_local6.x * (_local9 - _local5.x)) + (_local6.y * (_local10 - _local5.y)));
if (_local11 > _local12){
_arg1.pointCount = 0;
_local14.p = _local5;
_local14.d = _local6;
return;
};
if (_local11 > _local13){
_local13 = _local11;
_local7 = _local6;
_local8 = _local5;
};
if (_local5.index == _local15){
break;
};
_local5 = _local5.next;
_local6 = _local6.next;
};
if (_local13 < 1E-6){
_arg1.pointCount = 1;
_arg1.nx = _local7.x;
_arg1.ny = _local7.y;
_local22 = _arg1.c0;
_local22.id.incEdge = (_local7.index + 1);
_local22.id.incVert = 254;
_local22.id.refFace = 254;
_local22.id.flip = 0;
_local22.id.bake();
_local22.x = (_local9 - (_local12 * _arg1.nx));
_local22.y = (_local10 - (_local12 * _arg1.ny));
_local22.sep = (_local13 - _local12);
return;
};
var _local16:E2 = _local8.edge;
var _local18:Number = ((_arg2.r11 * _local16.d.x) + (_arg2.r12 * _local16.d.y));
var _local20:Number = ((_arg2.r21 * _local16.d.x) + (_arg2.r22 * _local16.d.y));
if (_local16.mag < 1E-6){
_local17 = (_local9 - _local8.x);
_local19 = (_local10 - _local8.y);
_local21 = ((_local17 * _local17) + (_local19 * _local19));
if (_local21 > _arg3.radiusSq){
};
_arg1.pointCount = 0;
return;
};
var _local23:Number = (((_local9 - _local8.x) * _local18) + ((_local10 - _local8.y) * _local20));
_local22 = _arg1.c0;
_local22.id.refFace = 254;
_local22.id.flip = 0;
if (_local23 <= 0){
_local24 = _local8.x;
_local25 = _local8.y;
_local22.id.incVert = (_local8.index + 1);
_local22.id.incEdge = 254;
} else {
if (_local23 >= _local16.mag){
_local24 = _local8.next.x;
_local25 = _local8.next.y;
_local22.id.incVert = (_local8.next.index + 1);
_local22.id.incEdge = 254;
} else {
_local24 = ((_local18 * _local23) + _local8.x);
_local25 = ((_local20 * _local23) + _local8.y);
_local22.id.incVert = 254;
_local22.id.incEdge = (_local8.index + 1);
};
};
_local17 = (_local9 - _local24);
_local19 = (_local10 - _local25);
_local21 = ((_local17 * _local17) + (_local19 * _local19));
if (_local21 > _arg3.radiusSq){
_arg1.pointCount = 0;
return;
};
_local21 = Math.sqrt(_local21);
_local17 = (_local17 / _local21);
_local19 = (_local19 / _local21);
_arg1.pointCount = 1;
_arg1.nx = _local17;
_arg1.ny = _local19;
_local22.x = (_local9 - (_arg3.radius * _local17));
_local22.y = (_local10 - (_arg3.radius * _local19));
_local22.sep = (_local21 - _local12);
_local22.id.bake();
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 75
//CollidePolyLineDoubleSidedBSP (de.polygonal.motor2.collision.pairwise.CollidePolyLineDoubleSidedBSP)
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 CollidePolyLineDoubleSidedBSP implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:V2;
var _local13:Number;
var _local22:ShapeSkeleton;
var _local23:ShapeSkeleton;
var _local28:int;
var _local32:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:ContactPoint;
var _local42:V2;
var _local14:Number = -2147483648;
var _local15:int;
_local10 = _arg3.worldVertexChain;
_local9 = _arg3.worldNormalChain;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local6 = _local5.N;
_local5 = ((((-(_local6.y) * _local9.x) + (_local6.x * _local9.y)))<=0) ? _local5.R : _local5.L;
};
_local7 = _local5.V;
_local13 = ((_local9.x * (_local7.x - _local10.x)) + (_local9.y * (_local7.y - _local10.y)));
if (_local13 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local14){
_local14 = _local13;
_local8 = _local9;
_local11 = _local10;
_local12 = _local7;
_local15 = 1;
};
_local10 = _local10.next;
_local9 = _local9.next;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local6 = _local5.N;
_local5 = ((((-(_local6.y) * _local9.x) + (_local6.x * _local9.y)))<=0) ? _local5.R : _local5.L;
};
_local7 = _local5.V;
_local13 = ((_local9.x * (_local7.x - _local10.x)) + (_local9.y * (_local7.y - _local10.y)));
if (_local13 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local14){
_local14 = _local13;
_local8 = _local9;
_local11 = _local10;
_local12 = _local7;
_local15 = 1;
};
var _local16:V2 = _arg3.worldVertexChain;
var _local17:V2 = _local16.next;
var _local18:Number = _local16.x;
var _local19:Number = _local17.x;
var _local20:Number = _local16.y;
var _local21:Number = _local17.y;
_local10 = _arg2.worldVertexChain;
_local9 = _arg2.worldNormalChain;
while (true) {
if (((_local18 * _local9.x) + (_local20 * _local9.y)) < ((_local19 * _local9.x) + (_local21 * _local9.y))){
_local13 = ((_local9.x * (_local18 - _local10.x)) + (_local9.y * (_local20 - _local10.y)));
if (_local13 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local14){
_local14 = _local13;
_local8 = _local9;
_local11 = _local10;
_local12 = _local16;
_local15 = 0;
};
} else {
_local13 = ((_local9.x * (_local19 - _local10.x)) + (_local9.y * (_local21 - _local10.y)));
if (_local13 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local14){
_local14 = _local13;
_local8 = _local9;
_local11 = _local10;
_local12 = _local17;
_local15 = 0;
};
};
if (_local10.isTail){
break;
};
_local10 = _local10.next;
_local9 = _local9.next;
};
if (_local15){
_local22 = _arg3;
_local23 = _arg2;
} else {
_local22 = _arg2;
_local23 = _arg3;
};
var _local24:Number = _local8.x;
var _local25:Number = _local8.y;
var _local26:int = _local11.index;
var _local27:int = _local12.index;
var _local29:V2 = _local12.edge.n;
var _local30:Number = ((_local29.x * _local24) + (_local29.y * _local25));
if (((_local29.prev.x * _local24) + (_local29.prev.y * _local25)) < _local30){
_local12 = _local12.prev;
_local28 = _local29.prev.index;
} else {
if (((_local29.next.x * _local24) + (_local29.next.y * _local25)) < _local30){
_local12 = _local12.next;
_local28 = _local29.next.index;
};
};
var _local31:Number = (((_local22.x * _local24) + (_local22.y * _local25)) + (((_local11.x - _local22.x) * _local24) + ((_local11.y - _local22.y) * _local25)));
if (_local22.regularShape){
_local32 = ((_local22.y * _local24) - (_local22.x * _local25));
} else {
_local42 = _local22.offsets[_local11.index];
_local32 = ((((_local22.y + (_local22.r21 * _local42.x)) + (_local22.r22 * _local42.y)) * _local24) - (((_local22.x + (_local22.r11 * _local42.x)) + (_local22.r12 * _local42.y)) * _local25));
};
var _local33:Number = (_local11.edge.mag / 2);
_local38 = ((((_local12.x * _local25) - (_local12.y * _local24)) + _local32) - _local33);
_local39 = ((((_local12.next.x * _local25) - (_local12.next.y * _local24)) + _local32) - _local33);
if ((_local38 * _local39) < 0){
_local40 = (_local38 / (_local38 - _local39));
if (_local38 < 0){
_local34 = _local12.x;
_local36 = _local12.y;
_local35 = (_local34 + (_local40 * (_local12.next.x - _local34)));
_local37 = (_local36 + (_local40 * (_local12.next.y - _local36)));
} else {
_local34 = _local12.next.x;
_local36 = _local12.next.y;
_local35 = (_local12.x + (_local40 * (_local34 - _local12.x)));
_local37 = (_local12.y + (_local40 * (_local36 - _local12.y)));
};
} else {
if (_local38 > 0){
_arg1.pointCount = 0;
return;
};
if (_local38 < _local39){
_local34 = _local12.x;
_local36 = _local12.y;
_local35 = _local12.next.x;
_local37 = _local12.next.y;
} else {
_local35 = _local12.x;
_local37 = _local12.y;
_local34 = _local12.next.x;
_local36 = _local12.next.y;
};
};
_local38 = ((((_local36 * _local24) - _local32) - _local33) - (_local34 * _local25));
_local39 = ((((_local37 * _local24) - _local32) - _local33) - (_local35 * _local25));
if ((_local38 * _local39) < 0){
_local40 = (_local38 / (_local38 - _local39));
_local34 = (_local34 + (_local40 * (_local35 - _local34)));
_local36 = (_local36 + (_local40 * (_local37 - _local36)));
} else {
if (_local38 > 0){
_arg1.pointCount = 0;
return;
};
};
_local14 = (((_local24 * _local34) + (_local25 * _local36)) - _local31);
if (_local14 <= 0){
_arg1.pointCount = 1;
if (_local15){
_arg1.nx = -(_local24);
_arg1.ny = -(_local25);
} else {
_arg1.nx = _local24;
_arg1.ny = _local25;
};
_local41 = _arg1.c0;
_local41.sep = _local14;
_local41.x = _local34;
_local41.y = _local36;
_local41.id.flip = _local15;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
_local14 = (((_local24 * _local35) + (_local25 * _local37)) - _local31);
if (_local14 <= 0){
_arg1.pointCount = 2;
_local41 = _arg1.c1;
_local41.sep = _local14;
_local41.x = _local35;
_local41.y = _local37;
_local41.id.flip = _local15;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
};
} else {
_local14 = (((_local24 * _local35) + (_local25 * _local37)) - _local31);
if (_local14 <= 0){
_arg1.pointCount = 1;
if (_local15){
_arg1.nx = -(_local24);
_arg1.ny = -(_local25);
} else {
_arg1.nx = _local24;
_arg1.ny = _local25;
};
_local41 = _arg1.c0;
_local41.sep = _local14;
_local41.x = _local35;
_local41.y = _local37;
_local41.id.flip = _local15;
_local41.id.incEdge = _local28;
_local41.id.incVert = _local27;
_local41.id.refFace = _local26;
_local41.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 76
//CollidePolyLineDoubleSidedCHC (de.polygonal.motor2.collision.pairwise.CollidePolyLineDoubleSidedCHC)
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 CollidePolyLineDoubleSidedCHC implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local14:Number;
var _local15:Number;
var _local23:ShapeSkeleton;
var _local24:ShapeSkeleton;
var _local29:int;
var _local33:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:Number;
var _local42:ContactPoint;
var _local43:V2;
var _local5:PolyLineContact = PolyLineContact(_arg4);
var _local13:Number = -2147483648;
var _local16:int;
_local9 = _arg3.worldVertexChain;
_local8 = _arg3.worldNormalChain;
_local6 = _local5.hint1;
_local15 = ((_local6.x * _local8.x) + (_local6.y * _local8.y));
while (true) {
_local14 = ((_local6.prev.x * _local8.x) + (_local6.prev.y * _local8.y));
if (_local14 < _local15){
_local6 = _local6.prev;
_local15 = _local14;
} else {
_local14 = ((_local6.next.x * _local8.x) + (_local6.next.y * _local8.y));
if (_local14 < _local15){
_local6 = _local6.next;
_local15 = _local14;
} else {
break;
};
};
};
_local5.hint1 = _local6;
_local12 = ((_local8.x * (_local6.x - _local9.x)) + (_local8.y * (_local6.y - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local6;
_local16 = 1;
};
_local9 = _local9.next;
_local8 = _local8.next;
_local6 = _local5.hint2;
_local15 = ((_local6.x * _local8.x) + (_local6.y * _local8.y));
while (true) {
_local14 = ((_local6.prev.x * _local8.x) + (_local6.prev.y * _local8.y));
if (_local14 < _local15){
_local6 = _local6.prev;
_local15 = _local14;
} else {
_local14 = ((_local6.next.x * _local8.x) + (_local6.next.y * _local8.y));
if (_local14 < _local15){
_local6 = _local6.next;
_local15 = _local14;
} else {
break;
};
};
};
_local5.hint2 = _local6;
_local12 = ((_local8.x * (_local6.x - _local9.x)) + (_local8.y * (_local6.y - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local6;
_local16 = 1;
};
var _local17:V2 = _arg3.worldVertexChain;
var _local18:V2 = _local17.next;
var _local19:Number = _local17.x;
var _local20:Number = _local18.x;
var _local21:Number = _local17.y;
var _local22:Number = _local18.y;
_local9 = _arg2.worldVertexChain;
_local8 = _arg2.worldNormalChain;
while (true) {
if (((_local19 * _local8.x) + (_local21 * _local8.y)) < ((_local20 * _local8.x) + (_local22 * _local8.y))){
_local12 = ((_local8.x * (_local19 - _local9.x)) + (_local8.y * (_local21 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local17;
_local16 = 0;
};
} else {
_local12 = ((_local8.x * (_local20 - _local9.x)) + (_local8.y * (_local22 - _local9.y)));
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local7 = _local8;
_local10 = _local9;
_local11 = _local18;
_local16 = 0;
};
};
if (_local9.isTail){
break;
};
_local9 = _local9.next;
_local8 = _local8.next;
};
if (_local16){
_local23 = _arg3;
_local24 = _arg2;
} else {
_local23 = _arg2;
_local24 = _arg3;
};
var _local25:Number = _local7.x;
var _local26:Number = _local7.y;
var _local27:int = _local10.index;
var _local28:int = _local11.index;
var _local30:V2 = _local11.edge.n;
var _local31:Number = ((_local30.x * _local25) + (_local30.y * _local26));
if (((_local30.prev.x * _local25) + (_local30.prev.y * _local26)) < _local31){
_local11 = _local11.prev;
_local29 = _local30.prev.index;
} else {
if (((_local30.next.x * _local25) + (_local30.next.y * _local26)) < _local31){
_local11 = _local11.next;
_local29 = _local30.next.index;
};
};
var _local32:Number = (((_local23.x * _local25) + (_local23.y * _local26)) + (((_local10.x - _local23.x) * _local25) + ((_local10.y - _local23.y) * _local26)));
if (_local23.regularShape){
_local33 = ((_local23.y * _local25) - (_local23.x * _local26));
} else {
_local43 = _local23.offsets[_local10.index];
_local33 = ((((_local23.y + (_local23.r21 * _local43.x)) + (_local23.r22 * _local43.y)) * _local25) - (((_local23.x + (_local23.r11 * _local43.x)) + (_local23.r12 * _local43.y)) * _local26));
};
var _local34:Number = (_local10.edge.mag / 2);
_local39 = ((((_local11.x * _local26) - (_local11.y * _local25)) + _local33) - _local34);
_local40 = ((((_local11.next.x * _local26) - (_local11.next.y * _local25)) + _local33) - _local34);
if ((_local39 * _local40) < 0){
_local41 = (_local39 / (_local39 - _local40));
if (_local39 < 0){
_local35 = _local11.x;
_local37 = _local11.y;
_local36 = (_local35 + (_local41 * (_local11.next.x - _local35)));
_local38 = (_local37 + (_local41 * (_local11.next.y - _local37)));
} else {
_local35 = _local11.next.x;
_local37 = _local11.next.y;
_local36 = (_local11.x + (_local41 * (_local35 - _local11.x)));
_local38 = (_local11.y + (_local41 * (_local37 - _local11.y)));
};
} else {
if (_local39 > 0){
_arg1.pointCount = 0;
return;
};
if (_local39 < _local40){
_local35 = _local11.x;
_local37 = _local11.y;
_local36 = _local11.next.x;
_local38 = _local11.next.y;
} else {
_local36 = _local11.x;
_local38 = _local11.y;
_local35 = _local11.next.x;
_local37 = _local11.next.y;
};
};
_local39 = ((((_local37 * _local25) - _local33) - _local34) - (_local35 * _local26));
_local40 = ((((_local38 * _local25) - _local33) - _local34) - (_local36 * _local26));
if ((_local39 * _local40) < 0){
_local41 = (_local39 / (_local39 - _local40));
_local35 = (_local35 + (_local41 * (_local36 - _local35)));
_local37 = (_local37 + (_local41 * (_local38 - _local37)));
} else {
if (_local39 > 0){
_arg1.pointCount = 0;
return;
};
};
_local13 = (((_local25 * _local35) + (_local26 * _local37)) - _local32);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local16){
_arg1.nx = -(_local25);
_arg1.ny = -(_local26);
} else {
_arg1.nx = _local25;
_arg1.ny = _local26;
};
_local42 = _arg1.c0;
_local42.sep = _local13;
_local42.x = _local35;
_local42.y = _local37;
_local42.id.flip = _local16;
_local42.id.incEdge = _local29;
_local42.id.incVert = _local28;
_local42.id.refFace = _local27;
_local42.id.bake();
_local13 = (((_local25 * _local36) + (_local26 * _local38)) - _local32);
if (_local13 <= 0){
_arg1.pointCount = 2;
_local42 = _arg1.c1;
_local42.sep = _local13;
_local42.x = _local36;
_local42.y = _local38;
_local42.id.flip = _local16;
_local42.id.incEdge = _local29;
_local42.id.incVert = _local28;
_local42.id.refFace = _local27;
_local42.id.bake();
};
} else {
_local13 = (((_local25 * _local36) + (_local26 * _local38)) - _local32);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local16){
_arg1.nx = -(_local25);
_arg1.ny = -(_local26);
} else {
_arg1.nx = _local25;
_arg1.ny = _local26;
};
_local42 = _arg1.c0;
_local42.sep = _local13;
_local42.x = _local36;
_local42.y = _local38;
_local42.id.flip = _local16;
_local42.id.incEdge = _local29;
_local42.id.incVert = _local28;
_local42.id.refFace = _local27;
_local42.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 77
//CollidePolyLineSingleSidedBSP (de.polygonal.motor2.collision.pairwise.CollidePolyLineSingleSidedBSP)
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 CollidePolyLineSingleSidedBSP implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:ConvexBSPNode;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local21:ShapeSkeleton;
var _local22:ShapeSkeleton;
var _local27:int;
var _local31:Number;
var _local33:Number;
var _local34:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:ContactPoint;
var _local41:V2;
var _local5:V2 = _arg3.worldNormalChain;
if ((((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d) < 0){
_arg4.disabled = true;
_arg1.pointCount = 0;
return;
};
var _local13:Number = -2147483648;
var _local14:int;
_local9 = _arg3.worldVertexChain;
_local8 = _arg3.worldNormalChain;
_local6 = _arg2.BSPNode;
while (_local6.R) {
_local6 = ((((-(_local6.N.y) * _local8.x) + (_local6.N.x * _local8.y)))<=0) ? _local6.R : _local6.L;
};
_local7 = _local6.V;
_local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local7;
_local14 = 1;
};
_local9 = _local9.next;
_local8 = _local8.next;
_local6 = _arg2.BSPNode;
while (_local6.R) {
_local6 = ((((-(_local6.N.y) * _local8.x) + (_local6.N.x * _local8.y)))<=0) ? _local6.R : _local6.L;
};
_local7 = _local6.V;
_local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local7;
_local14 = 1;
};
var _local15:V2 = _arg3.worldVertexChain;
var _local16:V2 = _local15.next;
var _local17:Number = _local15.x;
var _local18:Number = _local16.x;
var _local19:Number = _local15.y;
var _local20:Number = _local16.y;
_local9 = _arg2.worldVertexChain;
_local8 = _arg2.worldNormalChain;
while (true) {
if (((_local17 * _local8.x) + (_local19 * _local8.y)) < ((_local18 * _local8.x) + (_local20 * _local8.y))){
_local12 = ((_local8.x * (_local17 - _local9.x)) + (_local8.y * (_local19 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local15;
_local14 = 0;
};
} else {
_local12 = ((_local8.x * (_local18 - _local9.x)) + (_local8.y * (_local20 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local16;
_local14 = 0;
};
};
if (_local9.isTail){
break;
};
_local9 = _local9.next;
_local8 = _local8.next;
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
if (_local14){
_local21 = _arg3;
_local22 = _arg2;
} else {
_local21 = _arg2;
_local22 = _arg3;
};
var _local23:Number = _local5.x;
var _local24:Number = _local5.y;
var _local25:int = _local10.index;
var _local26:int = _local11.index;
var _local28:V2 = _local11.edge.n;
var _local29:Number = ((_local28.x * _local23) + (_local28.y * _local24));
if (((_local28.prev.x * _local23) + (_local28.prev.y * _local24)) < _local29){
_local11 = _local11.prev;
_local27 = _local28.prev.index;
} else {
if (((_local28.next.x * _local23) + (_local28.next.y * _local24)) < _local29){
_local11 = _local11.next;
_local27 = _local28.next.index;
};
};
var _local30:Number = (((_local21.x * _local23) + (_local21.y * _local24)) + (((_local10.x - _local21.x) * _local23) + ((_local10.y - _local21.y) * _local24)));
if (_local21.regularShape){
_local31 = ((_local21.y * _local23) - (_local21.x * _local24));
} else {
_local41 = _local21.offsets[_local10.index];
_local31 = ((((_local21.y + (_local21.r21 * _local41.x)) + (_local21.r22 * _local41.y)) * _local23) - (((_local21.x + (_local21.r11 * _local41.x)) + (_local21.r12 * _local41.y)) * _local24));
};
var _local32:Number = (_local10.edge.mag / 2);
_local37 = ((((_local11.x * _local24) - (_local11.y * _local23)) + _local31) - _local32);
_local38 = ((((_local11.next.x * _local24) - (_local11.next.y * _local23)) + _local31) - _local32);
if ((_local37 * _local38) < 0){
_local39 = (_local37 / (_local37 - _local38));
if (_local37 < 0){
_local33 = _local11.x;
_local35 = _local11.y;
_local34 = (_local33 + (_local39 * (_local11.next.x - _local33)));
_local36 = (_local35 + (_local39 * (_local11.next.y - _local35)));
} else {
_local33 = _local11.next.x;
_local35 = _local11.next.y;
_local34 = (_local11.x + (_local39 * (_local33 - _local11.x)));
_local36 = (_local11.y + (_local39 * (_local35 - _local11.y)));
};
} else {
if (_local37 > 0){
_arg1.pointCount = 0;
return;
};
if (_local37 < _local38){
_local33 = _local11.x;
_local35 = _local11.y;
_local34 = _local11.next.x;
_local36 = _local11.next.y;
} else {
_local34 = _local11.x;
_local36 = _local11.y;
_local33 = _local11.next.x;
_local35 = _local11.next.y;
};
};
_local37 = ((((_local35 * _local23) - _local31) - _local32) - (_local33 * _local24));
_local38 = ((((_local36 * _local23) - _local31) - _local32) - (_local34 * _local24));
if ((_local37 * _local38) < 0){
_local39 = (_local37 / (_local37 - _local38));
_local33 = (_local33 + (_local39 * (_local34 - _local33)));
_local35 = (_local35 + (_local39 * (_local36 - _local35)));
} else {
if (_local37 > 0){
_arg1.pointCount = 0;
return;
};
};
_local13 = (((_local23 * _local33) + (_local24 * _local35)) - _local30);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local23);
_arg1.ny = -(_local24);
} else {
_arg1.nx = _local23;
_arg1.ny = _local24;
};
_local40 = _arg1.c0;
_local40.sep = _local13;
_local40.x = _local33;
_local40.y = _local35;
_local40.id.flip = _local14;
_local40.id.incEdge = _local27;
_local40.id.incVert = _local26;
_local40.id.refFace = _local25;
_local40.id.bake();
_local13 = (((_local23 * _local34) + (_local24 * _local36)) - _local30);
if (_local13 <= 0){
_arg1.pointCount = 2;
_local40 = _arg1.c1;
_local40.sep = _local13;
_local40.x = _local34;
_local40.y = _local36;
_local40.id.flip = _local14;
_local40.id.incEdge = _local27;
_local40.id.incVert = _local26;
_local40.id.refFace = _local25;
_local40.id.bake();
};
} else {
_local13 = (((_local23 * _local34) + (_local24 * _local36)) - _local30);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local23);
_arg1.ny = -(_local24);
} else {
_arg1.nx = _local23;
_arg1.ny = _local24;
};
_local40 = _arg1.c0;
_local40.sep = _local13;
_local40.x = _local34;
_local40.y = _local36;
_local40.id.flip = _local14;
_local40.id.incEdge = _local27;
_local40.id.incVert = _local26;
_local40.id.refFace = _local25;
_local40.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 78
//CollidePolyLineSingleSidedCHC (de.polygonal.motor2.collision.pairwise.CollidePolyLineSingleSidedCHC)
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 CollidePolyLineSingleSidedCHC implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local14:Number;
var _local15:Number;
var _local23:ShapeSkeleton;
var _local24:ShapeSkeleton;
var _local29:int;
var _local33:Number;
var _local35:Number;
var _local36:Number;
var _local37:Number;
var _local38:Number;
var _local39:Number;
var _local40:Number;
var _local41:Number;
var _local42:ContactPoint;
var _local43:V2;
var _local5:V2 = _arg3.worldNormalChain;
if ((((_arg2.x * _local5.x) + (_arg2.y * _local5.y)) - _arg3.d) < 0){
_arg4.disabled = true;
_arg1.pointCount = 0;
return;
};
var _local6:PolyLineContact = PolyLineContact(_arg4);
var _local13:Number = -2147483648;
var _local16:int;
_local9 = _arg3.worldVertexChain;
_local8 = _arg3.worldNormalChain;
_local7 = _local6.hint1;
_local15 = ((_local7.x * _local8.x) + (_local7.y * _local8.y));
while (true) {
_local14 = ((_local7.prev.x * _local8.x) + (_local7.prev.y * _local8.y));
if (_local14 < _local15){
_local7 = _local7.prev;
_local15 = _local14;
} else {
_local14 = ((_local7.next.x * _local8.x) + (_local7.next.y * _local8.y));
if (_local14 < _local15){
_local7 = _local7.next;
_local15 = _local14;
} else {
break;
};
};
};
_local6.hint1 = _local7;
_local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local7;
_local16 = 1;
};
_local9 = _local9.next;
_local8 = _local8.next;
_local7 = _local6.hint2;
_local15 = ((_local7.x * _local8.x) + (_local7.y * _local8.y));
while (true) {
_local14 = ((_local7.prev.x * _local8.x) + (_local7.prev.y * _local8.y));
if (_local14 < _local15){
_local7 = _local7.prev;
_local15 = _local14;
} else {
_local14 = ((_local7.next.x * _local8.x) + (_local7.next.y * _local8.y));
if (_local14 < _local15){
_local7 = _local7.next;
_local15 = _local14;
} else {
break;
};
};
};
_local6.hint2 = _local7;
_local12 = ((_local8.x * (_local7.x - _local9.x)) + (_local8.y * (_local7.y - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local7;
_local16 = 1;
};
var _local17:V2 = _arg3.worldVertexChain;
var _local18:V2 = _local17.next;
var _local19:Number = _local17.x;
var _local20:Number = _local18.x;
var _local21:Number = _local17.y;
var _local22:Number = _local18.y;
_local9 = _arg2.worldVertexChain;
_local8 = _arg2.worldNormalChain;
while (true) {
if (((_local19 * _local8.x) + (_local21 * _local8.y)) < ((_local20 * _local8.x) + (_local22 * _local8.y))){
_local12 = ((_local8.x * (_local19 - _local9.x)) + (_local8.y * (_local21 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local17;
_local16 = 0;
};
} else {
_local12 = ((_local8.x * (_local20 - _local9.x)) + (_local8.y * (_local22 - _local9.y)));
if (_local12 > 0){
_arg4.disabled = false;
_arg1.pointCount = 0;
return;
};
if (((_local12 * 0.95) + 0.01) > _local13){
_local13 = _local12;
_local5 = _local8;
_local10 = _local9;
_local11 = _local18;
_local16 = 0;
};
};
if (_local9.isTail){
break;
};
_local9 = _local9.next;
_local8 = _local8.next;
};
if (_arg4.disabled){
_arg1.pointCount = 0;
return;
};
if (_local16){
_local23 = _arg3;
_local24 = _arg2;
} else {
_local23 = _arg2;
_local24 = _arg3;
};
var _local25:Number = _local5.x;
var _local26:Number = _local5.y;
var _local27:int = _local10.index;
var _local28:int = _local11.index;
var _local30:V2 = _local11.edge.n;
var _local31:Number = ((_local30.x * _local25) + (_local30.y * _local26));
if (((_local30.prev.x * _local25) + (_local30.prev.y * _local26)) < _local31){
_local11 = _local11.prev;
_local29 = _local30.prev.index;
} else {
if (((_local30.next.x * _local25) + (_local30.next.y * _local26)) < _local31){
_local11 = _local11.next;
_local29 = _local30.next.index;
};
};
var _local32:Number = (((_local23.x * _local25) + (_local23.y * _local26)) + (((_local10.x - _local23.x) * _local25) + ((_local10.y - _local23.y) * _local26)));
if (_local23.regularShape){
_local33 = ((_local23.y * _local25) - (_local23.x * _local26));
} else {
_local43 = _local23.offsets[_local10.index];
_local33 = ((((_local23.y + (_local23.r21 * _local43.x)) + (_local23.r22 * _local43.y)) * _local25) - (((_local23.x + (_local23.r11 * _local43.x)) + (_local23.r12 * _local43.y)) * _local26));
};
var _local34:Number = (_local10.edge.mag / 2);
_local39 = ((((_local11.x * _local26) - (_local11.y * _local25)) + _local33) - _local34);
_local40 = ((((_local11.next.x * _local26) - (_local11.next.y * _local25)) + _local33) - _local34);
if ((_local39 * _local40) < 0){
_local41 = (_local39 / (_local39 - _local40));
if (_local39 < 0){
_local35 = _local11.x;
_local37 = _local11.y;
_local36 = (_local35 + (_local41 * (_local11.next.x - _local35)));
_local38 = (_local37 + (_local41 * (_local11.next.y - _local37)));
} else {
_local35 = _local11.next.x;
_local37 = _local11.next.y;
_local36 = (_local11.x + (_local41 * (_local35 - _local11.x)));
_local38 = (_local11.y + (_local41 * (_local37 - _local11.y)));
};
} else {
if (_local39 > 0){
_arg1.pointCount = 0;
return;
};
if (_local39 < _local40){
_local35 = _local11.x;
_local37 = _local11.y;
_local36 = _local11.next.x;
_local38 = _local11.next.y;
} else {
_local36 = _local11.x;
_local38 = _local11.y;
_local35 = _local11.next.x;
_local37 = _local11.next.y;
};
};
_local39 = ((((_local37 * _local25) - _local33) - _local34) - (_local35 * _local26));
_local40 = ((((_local38 * _local25) - _local33) - _local34) - (_local36 * _local26));
if ((_local39 * _local40) < 0){
_local41 = (_local39 / (_local39 - _local40));
_local35 = (_local35 + (_local41 * (_local36 - _local35)));
_local37 = (_local37 + (_local41 * (_local38 - _local37)));
} else {
if (_local39 > 0){
_arg1.pointCount = 0;
return;
};
};
_local13 = (((_local25 * _local35) + (_local26 * _local37)) - _local32);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local16){
_arg1.nx = -(_local25);
_arg1.ny = -(_local26);
} else {
_arg1.nx = _local25;
_arg1.ny = _local26;
};
_local42 = _arg1.c0;
_local42.sep = _local13;
_local42.x = _local35;
_local42.y = _local37;
_local42.id.flip = _local16;
_local42.id.incEdge = _local29;
_local42.id.incVert = _local28;
_local42.id.refFace = _local27;
_local42.id.bake();
_local13 = (((_local25 * _local36) + (_local26 * _local38)) - _local32);
if (_local13 <= 0){
_arg1.pointCount = 2;
_local42 = _arg1.c1;
_local42.sep = _local13;
_local42.x = _local36;
_local42.y = _local38;
_local42.id.flip = _local16;
_local42.id.incEdge = _local29;
_local42.id.incVert = _local28;
_local42.id.refFace = _local27;
_local42.id.bake();
};
} else {
_local13 = (((_local25 * _local36) + (_local26 * _local38)) - _local32);
if (_local13 <= 0){
_arg1.pointCount = 1;
if (_local16){
_arg1.nx = -(_local25);
_arg1.ny = -(_local26);
} else {
_arg1.nx = _local25;
_arg1.ny = _local26;
};
_local42 = _arg1.c0;
_local42.sep = _local13;
_local42.x = _local36;
_local42.y = _local38;
_local42.id.flip = _local16;
_local42.id.incEdge = _local29;
_local42.id.incVert = _local28;
_local42.id.refFace = _local27;
_local42.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 79
//CollidePolyPlaneDoubleSidedBSP (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneDoubleSidedBSP)
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 CollidePolyPlaneDoubleSidedBSP implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local9:V2;
var _local10:int;
var _local11:ContactPoint;
var _local12:Number;
var _local6:Number = _arg3.worldNormalChain.x;
var _local7:Number = _arg3.worldNormalChain.y;
var _local8:Number = _arg3.d;
if ((((_arg2.x * _local6) + (_arg2.y * _local7)) - _local8) > 0){
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L;
};
_local9 = _local5.V;
_local12 = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8);
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
} else {
_local6 = -(_local6);
_local7 = -(_local7);
_local8 = -(_local8);
_local10 = 1;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L;
};
_local9 = _local5.V;
_local12 = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8);
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
};
_arg1.pointCount = 1;
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
_local11 = _arg1.c0;
_local11.sep = _local12;
_local11.x = _local9.x;
_local11.y = _local9.y;
_local11.id.key = _local10;
_local12 = (((_local9.prev.x * _local6) + (_local9.prev.y * _local7)) - _local8);
if (_local12 < 0){
_local11.id.key = -(~(_local10));
_local11 = _arg1.c1;
_local11.sep = _local12;
_local11.x = _local9.prev.x;
_local11.y = _local9.prev.y;
_local11.id.key = -(~(_local10));
_arg1.pointCount++;
} else {
_local12 = (((_local9.next.x * _local6) + (_local9.next.y * _local7)) - _local8);
if (_local12 < 0){
_local11.id.key = -(~(_local10));
_local11 = _arg1.c1;
_local11.sep = _local12;
_local11.x = _local9.next.x;
_local11.y = _local9.next.y;
_local11.id.key = -(~(_local10));
_arg1.pointCount++;
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 80
//CollidePolyPlaneDoubleSidedCHC (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneDoubleSidedCHC)
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 CollidePolyPlaneDoubleSidedCHC implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local8:Number;
var _local9:Number;
var _local11:V2;
var _local12:int;
var _local13:ContactPoint;
var _local14:Number;
var _local5:PolyLineContact = PolyLineContact(_arg4);
var _local6:Number = _arg3.worldNormalChain.x;
var _local7:Number = _arg3.worldNormalChain.y;
var _local10:Number = _arg3.d;
if ((((_arg2.x * _local6) + (_arg2.y * _local7)) - _local10) > 0){
_local11 = _local5.hint1;
_local9 = ((_local11.x * _local6) + (_local11.y * _local7));
while (true) {
_local8 = ((_local11.prev.x * _local6) + (_local11.prev.y * _local7));
if (_local8 < _local9){
_local11 = _local11.prev;
_local9 = _local8;
} else {
_local8 = ((_local11.next.x * _local6) + (_local11.next.y * _local7));
if (_local8 < _local9){
_local11 = _local11.next;
_local9 = _local8;
} else {
break;
};
};
};
_local5.hint1 = _local11;
_local14 = (((_local11.x * _local6) + (_local11.y * _local7)) - _local10);
if (_local14 > 0){
_arg1.pointCount = 0;
return;
};
} else {
_local6 = -(_local6);
_local7 = -(_local7);
_local10 = -(_local10);
_local12 = 1;
_local11 = _local5.hint2;
_local9 = ((_local11.x * _local6) + (_local11.y * _local7));
while (true) {
_local8 = ((_local11.prev.x * _local6) + (_local11.prev.y * _local7));
if (_local8 < _local9){
_local11 = _local11.prev;
_local9 = _local8;
} else {
_local8 = ((_local11.next.x * _local6) + (_local11.next.y * _local7));
if (_local8 < _local9){
_local11 = _local11.next;
_local9 = _local8;
} else {
break;
};
};
};
_local5.hint2 = _local11;
_local14 = (((_local11.x * _local6) + (_local11.y * _local7)) - _local10);
if (_local14 > 0){
_arg1.pointCount = 0;
return;
};
};
_arg1.pointCount = 1;
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
_local13 = _arg1.c0;
_local13.sep = _local14;
_local13.x = _local11.x;
_local13.y = _local11.y;
_local13.id.key = _local12;
_local14 = (((_local11.prev.x * _local6) + (_local11.prev.y * _local7)) - _local10);
if (_local14 < 0){
_local13.id.key = -(~(_local12));
_local13 = _arg1.c1;
_local13.sep = _local14;
_local13.x = _local11.prev.x;
_local13.y = _local11.prev.y;
_local13.id.key = -(~(_local12));
_arg1.pointCount++;
} else {
_local14 = (((_local11.next.x * _local6) + (_local11.next.y * _local7)) - _local10);
if (_local14 < 0){
_local13.id.key = -(~(_local12));
_local13 = _arg1.c1;
_local13.sep = _local14;
_local13.x = _local11.next.x;
_local13.y = _local11.next.y;
_local13.id.key = -(~(_local12));
_arg1.pointCount++;
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 81
//CollidePolyPlaneSingleSidedBSP (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneSingleSidedBSP)
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 CollidePolyPlaneSingleSidedBSP implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local5:ConvexBSPNode;
var _local7:Number;
var _local8:Number;
var _local6:Number = _arg3.worldNormalChain.x;
_local7 = _arg3.worldNormalChain.y;
_local8 = _arg3.d;
_local5 = _arg2.BSPNode;
while (_local5.R) {
_local5 = ((((_local5.N.x * _local7) - (_local5.N.y * _local6)))<=0) ? _local5.R : _local5.L;
};
var _local9:V2 = _local5.V;
var _local10:Number = (((_local9.x * _local6) + (_local9.y * _local7)) - _local8);
if (_local10 > 0){
_arg1.pointCount = 0;
return;
};
_arg1.nx = -(_local6);
_arg1.ny = -(_local7);
_arg1.pointCount = 1;
var _local11:ContactPoint = _arg1.c0;
_local11.sep = _local10;
_local11.x = _local9.x;
_local11.y = _local9.y;
_local11.id.key = 0;
_local10 = (((_local9.prev.x * _local6) + (_local9.prev.y * _local7)) - _local8);
if (_local10 < 0){
_local11.id.key = 1;
_local11 = _arg1.c1;
_local11.sep = _local10;
_local11.x = _local9.prev.x;
_local11.y = _local9.prev.y;
_local11.id.key = 1;
_arg1.pointCount++;
} else {
_local10 = (((_local9.next.x * _local6) + (_local9.next.y * _local7)) - _local8);
if (_local10 < 0){
_local11.id.key = 1;
_local11 = _arg1.c1;
_local11.sep = _local10;
_local11.x = _local9.next.x;
_local11.y = _local9.next.y;
_local11.id.key = 1;
_arg1.pointCount++;
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 82
//CollidePolyPlaneSingleSidedCHC (de.polygonal.motor2.collision.pairwise.CollidePolyPlaneSingleSidedCHC)
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 CollidePolyPlaneSingleSidedCHC implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:Number;
var _local7:Number;
var _local10:Number;
var _local5:Number = _arg3.worldNormalChain.x;
_local6 = _arg3.worldNormalChain.y;
_local7 = _arg3.d;
var _local8:PolyLineContact = PolyLineContact(_arg4);
var _local9:V2 = _local8.hint1;
var _local11:Number = ((_local9.x * _local5) + (_local9.y * _local6));
while (true) {
_local10 = ((_local9.prev.x * _local5) + (_local9.prev.y * _local6));
if (_local10 < _local11){
_local9 = _local9.prev;
_local11 = _local10;
} else {
_local10 = ((_local9.next.x * _local5) + (_local9.next.y * _local6));
if (_local10 < _local11){
_local9 = _local9.next;
_local11 = _local10;
} else {
break;
};
};
};
_local8.hint1 = _local9;
var _local12:Number = (((_local9.x * _local5) + (_local9.y * _local6)) - _local7);
if (_local12 > 0){
_arg1.pointCount = 0;
return;
};
_arg1.nx = -(_local5);
_arg1.ny = -(_local6);
_arg1.pointCount = 1;
var _local13:ContactPoint = _arg1.c0;
_local13.sep = _local12;
_local13.x = _local9.x;
_local13.y = _local9.y;
_local13.id.key = 0;
_local12 = (((_local9.prev.x * _local5) + (_local9.prev.y * _local6)) - _local7);
if (_local12 < 0){
_local13.id.key = 1;
_local13 = _arg1.c1;
_local13.sep = _local12;
_local13.x = _local9.prev.x;
_local13.y = _local9.prev.y;
_local13.id.key = 1;
_arg1.pointCount++;
} else {
_local12 = (((_local9.next.x * _local5) + (_local9.next.y * _local6)) - _local7);
if (_local12 < 0){
_local13.id.key = 1;
_local13 = _arg1.c1;
_local13.sep = _local12;
_local13.x = _local9.next.x;
_local13.y = _local9.next.y;
_local13.id.key = 1;
_arg1.pointCount++;
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 83
//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 84
//CollideTriangleHC (de.polygonal.motor2.collision.pairwise.CollideTriangleHC)
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 CollideTriangleHC implements Collider {
public function collide(_arg1:Manifold, _arg2:ShapeSkeleton, _arg3:ShapeSkeleton, _arg4:Contact):void{
var _local6:V2;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local13:Number;
var _local14:int;
var _local15:Number;
var _local16:Number;
var _local22:int;
var _local26:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
var _local32:Number;
var _local33:Number;
var _local34:Number;
var _local35:ContactPoint;
var _local36:V2;
var _local5:PolyContact = PolyContact(_arg4);
var _local12:Number = -2147483648;
_local6 = _local5.p;
_local7 = _local5.d;
if (_local5.firstOut){
_local8 = _arg3.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg3.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg3.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
};
_local6 = _arg3.worldVertexChain;
_local7 = _arg3.worldNormalChain;
_local8 = _arg2.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = false;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg2.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = false;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg2.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = false;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
} else {
_local8 = _arg2.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg2.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg2.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 1;
};
_local6 = _arg2.worldVertexChain;
_local7 = _arg2.worldNormalChain;
_local8 = _arg3.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = true;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 0;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg3.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = true;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 0;
};
_local6 = _local6.next;
_local7 = _local7.next;
_local8 = _arg3.worldVertexChain;
_local15 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
_local8 = _local8.next;
_local16 = ((_local8.x * _local7.x) + (_local8.y * _local7.y));
if (_local16 < _local15){
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local16) ? _local8.next : _local8;
} else {
_local8 = ((((_local8.next.x * _local7.x) + (_local8.next.y * _local7.y)))<_local15) ? _local8.next : _local8.prev;
};
_local13 = ((_local7.x * (_local8.x - _local6.x)) + (_local7.y * (_local8.y - _local6.y)));
if (_local13 > 0){
_local5.p = _local6;
_local5.d = _local7;
_local5.firstOut = true;
_arg1.pointCount = 0;
return;
};
if (((_local13 * 0.95) + 0.01) > _local12){
_local12 = _local13;
_local9 = _local7;
_local11 = _local6;
_local10 = _local8;
_local14 = 0;
};
};
var _local17:ShapeSkeleton = (_local14) ? _arg3 : _arg2;
var _local18:Number = _local9.x;
var _local19:Number = _local9.y;
var _local20:int = _local11.index;
var _local21:int = _local10.index;
var _local23:V2 = _local10.edge.n;
var _local24:Number = ((_local23.x * _local18) + (_local23.y * _local19));
if (((_local23.prev.x * _local18) + (_local23.prev.y * _local19)) < _local24){
_local10 = _local10.prev;
_local22 = _local23.prev.index;
} else {
if (((_local23.next.x * _local18) + (_local23.next.y * _local19)) < _local24){
_local10 = _local10.next;
_local22 = _local23.next.index;
};
};
var _local25:Number = (((_local17.x * _local18) + (_local17.y * _local19)) + (((_local11.x - _local17.x) * _local18) + ((_local11.y - _local17.y) * _local19)));
if (_local17.regularShape){
_local26 = ((_local17.y * _local18) - (_local17.x * _local19));
} else {
_local36 = _local17.offsets[_local11.index];
_local26 = ((((_local17.y + (_local17.r21 * _local36.x)) + (_local17.r22 * _local36.y)) * _local18) - (((_local17.x + (_local17.r11 * _local36.x)) + (_local17.r12 * _local36.y)) * _local19));
};
var _local27:Number = (_local11.edge.mag / 2);
_local32 = ((((_local10.x * _local19) - (_local10.y * _local18)) + _local26) - _local27);
_local33 = ((((_local10.next.x * _local19) - (_local10.next.y * _local18)) + _local26) - _local27);
if ((_local32 * _local33) < 0){
_local34 = (_local32 / (_local32 - _local33));
if (_local32 < 0){
_local28 = _local10.x;
_local30 = _local10.y;
_local29 = (_local28 + (_local34 * (_local10.next.x - _local28)));
_local31 = (_local30 + (_local34 * (_local10.next.y - _local30)));
} else {
_local28 = _local10.next.x;
_local30 = _local10.next.y;
_local29 = (_local10.x + (_local34 * (_local28 - _local10.x)));
_local31 = (_local10.y + (_local34 * (_local30 - _local10.y)));
};
} else {
if (_local32 > 0){
_arg1.pointCount = 0;
return;
};
if (_local32 < _local33){
_local28 = _local10.x;
_local30 = _local10.y;
_local29 = _local10.next.x;
_local31 = _local10.next.y;
} else {
_local29 = _local10.x;
_local31 = _local10.y;
_local28 = _local10.next.x;
_local30 = _local10.next.y;
};
};
_local32 = ((((_local30 * _local18) - _local26) - _local27) - (_local28 * _local19));
_local33 = ((((_local31 * _local18) - _local26) - _local27) - (_local29 * _local19));
if ((_local32 * _local33) < 0){
_local34 = (_local32 / (_local32 - _local33));
_local28 = (_local28 + (_local34 * (_local29 - _local28)));
_local30 = (_local30 + (_local34 * (_local31 - _local30)));
} else {
if (_local32 > 0){
_arg1.pointCount = 0;
return;
};
};
_local12 = (((_local18 * _local28) + (_local19 * _local30)) - _local25);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local18);
_arg1.ny = -(_local19);
} else {
_arg1.nx = _local18;
_arg1.ny = _local19;
};
_local35 = _arg1.c0;
_local35.sep = _local12;
_local35.x = _local28;
_local35.y = _local30;
_local35.id.flip = _local14;
_local35.id.incEdge = _local22;
_local35.id.incVert = _local21;
_local35.id.refFace = _local20;
_local35.id.bake();
_local12 = (((_local18 * _local29) + (_local19 * _local31)) - _local25);
if (_local12 <= 0){
_arg1.pointCount = 2;
_local35 = _arg1.c1;
_local35.sep = _local12;
_local35.x = _local29;
_local35.y = _local31;
_local35.id.flip = _local14;
_local35.id.incEdge = _local22;
_local35.id.incVert = _local21;
_local35.id.refFace = _local20;
_local35.id.bake();
};
} else {
_local12 = (((_local18 * _local29) + (_local19 * _local31)) - _local25);
if (_local12 <= 0){
_arg1.pointCount = 1;
if (_local14){
_arg1.nx = -(_local18);
_arg1.ny = -(_local19);
} else {
_arg1.nx = _local18;
_arg1.ny = _local19;
};
_local35 = _arg1.c0;
_local35.sep = _local12;
_local35.x = _local29;
_local35.y = _local31;
_local35.id.flip = _local14;
_local35.id.incEdge = _local22;
_local35.id.incVert = _local21;
_local35.id.refFace = _local20;
_local35.id.bake();
};
};
}
}
}//package de.polygonal.motor2.collision.pairwise
Section 85
//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);
}
public function get height():Number{
return (_h);
}
override protected function computeMass():void{
_mass = ((_density * _w) * _h);
_I = ((_mass / 12) * ((_w * _w) + (_h * _h)));
_cm = new V2();
}
public function set width(_arg1:Number):void{
_w = _arg1;
invalidate();
}
override public function getShapeClass():Class{
return (BoxShape);
}
public function set height(_arg1:Number):void{
_h = _arg1;
invalidate();
}
override public function get area():Number{
return ((_w * _h));
}
override protected function setType():void{
type = ShapeTypes.BOX;
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 86
//CircleData (de.polygonal.motor2.collision.shapes.data.CircleData)
package de.polygonal.motor2.collision.shapes.data {
import de.polygonal.motor2.math.*;
import de.polygonal.motor2.collision.shapes.*;
public class CircleData extends ShapeData {
private var _radius:Number;
public function CircleData(_arg1:Number, _arg2:Number){
super(_arg1);
this.radius = Math.abs(_arg2);
}
public function set radius(_arg1:Number):void{
_radius = _arg1;
invalidate();
}
public function get radius():Number{
return (_radius);
}
override protected function computeMass():void{
_mass = (((_density * Math.PI) * radius) * radius);
_I = (((0.5 * _mass) * radius) * radius);
_cm = new V2();
}
override public function getShapeClass():Class{
return (CircleShape);
}
override public function get area():Number{
return (((Math.PI * _radius) * _radius));
}
override protected function setType():void{
type = ShapeTypes.CIRCLE;
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 87
//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 a:Point;
public const b:Point;
public var infinite:Boolean;
public var doubleSided:Boolean;
public function LineData(_arg1:Point, _arg2:Point, _arg3:Boolean=false, _arg4:Boolean=true){
a = new Point();
b = new Point();
super(0);
var _local5:Number = (_arg2.x - _arg1.x);
var _local6:Number = (_arg2.y - _arg1.y);
if (Math.sqrt((((_local5 * _local5) + _local6) + _local6)) <= 1E-6){
throw (new Error("overlapping vertices detected"));
};
var _local7:Number = (_arg1.x + ((_arg2.x - _arg1.x) * 0.5));
var _local8:Number = (_arg1.y + ((_arg2.y - _arg1.y) * 0.5));
this.a.x = (_arg1.x - _local7);
this.b.x = (_arg2.x - _local7);
this.a.y = (_arg1.y - _local8);
this.b.y = (_arg2.y - _local8);
this.infinite = _arg3;
this.doubleSided = _arg4;
}
override protected function setType():void{
type = ShapeTypes.LINE;
}
override public function getShapeClass():Class{
return (LineShape);
}
override public function get density():Number{
return (0);
}
override protected function computeMass():void{
_mass = 0;
_I = 0;
_cm = new V2((a.x + (0.5 * (b.x - a.x))), (a.y + (0.5 * (b.y - a.y))));
}
override public function get area():Number{
return (0);
}
override public function set density(_arg1:Number):void{
super.density = 0;
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 88
//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 isSensor:Boolean;
protected var _cm:V2;
public var groupIndex:int;
public var userData;
public var maskBits:int;
public var categoryBits:int;
public var mr:Number;
protected var _density:Number;
private var _restitution:Number;
public var my:Number;
public var mx:Number;
public var type:int;
protected var _I:Number;
protected var _mass:Number;
private var _friction:Number;
public var next:ShapeData;
public function ShapeData(_arg1:Number){
this.density = _arg1;
init();
}
public function getInertia():Number{
if (_density == 0){
return (0);
};
if (isNaN(_I)){
computeMass();
};
return (_I);
}
public function get area():Number{
return (NaN);
}
private function init():void{
setType();
mx = (my = (mr = 0));
friction = 0.2;
restitution = 0;
categoryBits = 1;
maskBits = 0xFFFF;
groupIndex = 0;
}
public function clrMaskBit(_arg1:int):void{
maskBits = (maskBits & ~((1 << _arg1)));
}
public function invalidate():void{
_mass = Number.NaN;
_I = Number.NaN;
_cm = null;
}
public function setMaskBit(_arg1:int):void{
maskBits = (maskBits | (1 << _arg1));
}
public function getCM():V2{
if (_cm == null){
computeMass();
};
return (_cm);
}
protected function setType():void{
type = ShapeTypes.UNKNOWN;
}
public function clrCategoryBit(_arg1:int):void{
categoryBits = (categoryBits & ~((1 << _arg1)));
}
protected function computeMass():void{
}
public function getShapeClass():Class{
return (null);
}
public function set density(_arg1:Number):void{
_density = _arg1;
invalidate();
}
public function set restitution(_arg1:Number):void{
_restitution = ((_arg1)<0) ? 0 : ((_arg1)>1) ? 1 : _arg1;
}
public function get density():Number{
return (_density);
}
public function get restitution():Number{
return (_restitution);
}
public function setCategoryBit(_arg1:int):void{
categoryBits = (categoryBits | (1 << _arg1));
}
public function getMass():Number{
if (_density == 0){
return (0);
};
if (isNaN(_mass)){
computeMass();
};
return (_mass);
}
public function set friction(_arg1:Number):void{
_friction = ((_arg1)<0) ? 0 : ((_arg1)>1) ? 1 : _arg1;
}
public function get friction():Number{
return (_friction);
}
}
}//package de.polygonal.motor2.collision.shapes.data
Section 89
//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.*;
public class BoxShape extends ShapeSkeleton {
private var _r22:Number;
private var _mr:Number;
private var _r21:Number;
private var _r11:Number;
private var _r12:Number;
public function BoxShape(_arg1:BoxData, _arg2:RigidBody){
super(_arg1, _arg2);
setup(_arg1, _arg2);
}
override public function update():Boolean{
synced = false;
if (_mr == 0){
r11 = body.r11;
r12 = body.r12;
r21 = body.r21;
r22 = body.r22;
} else {
r11 = ((_r11 * body.r11) + (_r12 * body.r21));
r21 = ((_r21 * body.r11) + (_r22 * body.r21));
r12 = ((_r11 * body.r12) + (_r12 * body.r22));
r22 = ((_r21 * body.r12) + (_r22 * body.r22));
};
x = ((body.x + (body.r11 * mx)) + (body.r12 * my));
y = ((body.y + (body.r21 * mx)) + (body.r22 * my));
xmin = (xmax = x);
ymin = (ymax = y);
if (r11 > 0){
xmin = (xmin - (r11 * ex));
xmax = (xmax + (r11 * ex));
} else {
xmin = (xmin + (r11 * ex));
xmax = (xmax - (r11 * ex));
};
if (r12 > 0){
xmin = (xmin - (r12 * ey));
xmax = (xmax + (r12 * ey));
} else {
xmin = (xmin + (r12 * ey));
xmax = (xmax - (r12 * ey));
};
if (r21 > 0){
ymin = (ymin - (r21 * ex));
ymax = (ymax + (r21 * ex));
} else {
ymin = (ymin + (r21 * ex));
ymax = (ymax - (r21 * ex));
};
if (r22 > 0){
ymin = (ymin - (r22 * ey));
ymax = (ymax + (r22 * ey));
} else {
ymin = (ymin + (r22 * ey));
ymax = (ymax - (r22 * ey));
};
return (super.update());
}
override public function pointInside(_arg1:Point):Boolean{
var _local2:Number;
var _local3:Number;
var _local4:Number;
_local2 = (_arg1.x - x);
_local3 = (_arg1.y - y);
_local4 = ((_local2 * r11) + (_local3 * r21));
if (_local4 > ex){
return (false);
};
if (_local4 < -(ex)){
return (false);
};
_local4 = ((_local2 * r12) + (_local3 * r22));
if (_local4 > ey){
return (false);
};
if (_local4 < -(ey)){
return (false);
};
return (true);
}
override public function toWorldSpace():void{
if (synced){
return;
};
synced = true;
var _local1:Number = (r11 * ex);
var _local2:Number = (r12 * ey);
var _local3:Number = (r21 * ex);
var _local4:Number = (r22 * ey);
v0.x = ((x + _local1) + _local2);
n0.x = r12;
v0.y = ((y + _local3) + _local4);
n0.y = r22;
v1.x = ((x - _local1) + _local2);
n1.x = -(r11);
v1.y = ((y - _local3) + _local4);
n1.y = -(r21);
v2.x = ((x - _local1) - _local2);
n2.x = -(r12);
v2.y = ((y - _local3) - _local4);
n2.y = -(r22);
v3.x = ((x + _local1) - _local2);
n3.x = r11;
v3.y = ((y + _local3) - _local4);
n3.y = r21;
}
override public function closestPoint(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
if (_arg2){
_local3 = (_arg1.x - (_arg2.x = x));
_local4 = (_arg1.y - (_arg2.y = y));
_local5 = ((_local3 * r11) + (_local4 * r21));
if (_local5 > ex){
_local5 = ex;
} else {
if (_local5 < -(ex)){
_local5 = -(ex);
};
};
_arg2.x = (_arg2.x + (r11 * _local5));
_arg2.y = (_arg2.y + (r21 * _local5));
_local5 = ((_local3 * r12) + (_local4 * r22));
if (_local5 > ey){
_local5 = ey;
} else {
if (_local5 < -(ey)){
_local5 = -(ey);
};
};
_arg2.x = (_arg2.x + (r12 * _local5));
_arg2.y = (_arg2.y + (r22 * _local5));
} else {
_local3 = (_arg1.x - (_arg1.x = x));
_local4 = (_arg1.y - (_arg1.y = y));
_local5 = ((_local3 * r11) + (_local4 * r21));
if (_local5 > ex){
_local5 = ex;
} else {
if (_local5 < -(ex)){
_local5 = -(ex);
};
};
_arg1.x = (_arg1.x + (r11 * _local5));
_arg1.y = (_arg1.y + (r21 * _local5));
_local5 = ((_local3 * r12) + (_local4 * r22));
if (_local5 > ey){
_local5 = ey;
} else {
if (_local5 < -(ey)){
_local5 = -(ey);
};
};
_arg1.x = (_arg1.x + (r12 * _local5));
_arg1.y = (_arg1.y + (r22 * _local5));
};
}
override public function triangulate():void{
triangleList = new Tri2(v0, v1, v3);
triangleList.next = new Tri2(v3, v1, v2);
}
override protected function setType():void{
type = ShapeTypes.BOX;
}
private function setup(_arg1:BoxData, _arg2:RigidBody):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Array;
var _local8:V2;
_local3 = _arg2.cx;
_local5 = _arg2.cy;
mx = (_arg1.mx - _local3);
my = (_arg1.my - _local5);
_local4 = Math.sin(_arg1.mr);
_local6 = Math.cos(_arg1.mr);
_r11 = _local6;
_r12 = -(_local4);
_r21 = _local4;
_r22 = _local6;
_mr = _arg1.mr;
ex = (_arg1.width * 0.5);
ey = (_arg1.height * 0.5);
xmin = -(ex);
xmax = ex;
xmin = -(ey);
ymax = ey;
radiusSq = ((ex * ex) + (ey * ey));
radius = Math.sqrt(radiusSq);
vertexCount = 4;
_local7 = new Array(vertexCount, true);
_local8 = (_local7[0] = new V2());
_local8.x = ((mx + (_r11 * ex)) + (_r12 * ey));
_local8.y = ((my + (_r21 * ex)) + (_r22 * ey));
_local8 = (_local7[1] = new V2());
_local8.x = ((mx + (_r11 * -(ex))) + (_r12 * ey));
_local8.y = ((my + (_r21 * -(ex))) + (_r22 * ey));
_local8 = (_local7[2] = new V2());
_local8.x = ((mx + (_r11 * -(ex))) + (_r12 * -(ey)));
_local8.y = ((my + (_r21 * -(ex))) + (_r22 * -(ey)));
_local8 = (_local7[3] = new V2());
_local8.x = ((mx + (_r11 * ex)) + (_r12 * -(ey)));
_local8.y = ((my + (_r21 * ex)) + (_r22 * -(ey)));
initPoly(_local7, vertexCount, true, mx, my);
_local8 = worldVertexChain;
v0 = _local8;
_local8 = _local8.next;
v1 = _local8;
_local8 = _local8.next;
v2 = _local8;
_local8 = _local8.next;
v3 = _local8;
_local8 = worldNormalChain;
n0 = _local8;
_local8 = _local8.next;
n1 = _local8;
_local8 = _local8.next;
n2 = _local8;
_local8 = _local8.next;
n3 = _local8;
var _local9:ConvexBSPNode = new ConvexBSPNode();
_local9.N = n0;
_local9.I = 0;
_local9.L = new ConvexBSPNode();
_local9.L.N = n3;
_local9.L.I = 3;
_local9.L.L = new ConvexBSPNode();
_local9.L.L.V = v3;
_local9.L.L.I = 3;
_local9.L.R = new ConvexBSPNode();
_local9.L.R.V = v0;
_local9.L.R.I = 0;
_local9.R = new ConvexBSPNode();
_local9.R.N = n1;
_local9.R.I = 1;
_local9.R.L = new ConvexBSPNode();
_local9.R.L.V = v1;
_local9.R.L.I = 1;
_local9.R.R = new ConvexBSPNode();
_local9.R.R.V = v2;
_local9.R.R.I = 2;
BSPNode = _local9;
update();
createProxy();
}
override public function getShapeOffset(_arg1:Point):void{
_arg1.x = ((mx * _r11) + (my * _r12));
_arg1.y = ((mx * _r21) + (my * _r22));
}
}
}//package de.polygonal.motor2.collision.shapes
Section 90
//CircleShape (de.polygonal.motor2.collision.shapes.CircleShape)
package de.polygonal.motor2.collision.shapes {
import de.polygonal.motor2.dynamics.*;
import flash.geom.*;
import de.polygonal.motor2.collision.shapes.data.*;
public class CircleShape extends ShapeSkeleton {
public function CircleShape(_arg1:CircleData, _arg2:RigidBody){
super(_arg1, _arg2);
setup(_arg1, _arg2);
}
override public function update():Boolean{
synced = false;
x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my)));
y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my)));
xmin = (x - radius);
ymin = (y - radius);
xmax = (x + radius);
ymax = (y + radius);
return (super.update());
}
override public function pointInside(_arg1:Point):Boolean{
return (((((_arg1.x - x) * (_arg1.x - x)) + ((_arg1.y - y) * (_arg1.y - y))) <= radiusSq));
}
private function setup(_arg1:CircleData, _arg2:RigidBody):void{
var _local3:Number = _arg2.cx;
var _local4:Number = _arg2.cy;
mx = (_arg1.mx - _local3);
my = (_arg1.my - _local4);
x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my)));
y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my)));
radius = _arg1.radius;
radiusSq = (radius * radius);
ex = radius;
ey = radius;
xmin = -(ex);
xmax = ex;
xmin = -(ey);
ymax = ey;
vertexCount = 0;
update();
createProxy();
}
override protected function setType():void{
type = ShapeTypes.CIRCLE;
}
override public function closestPoint(_arg1:Point, _arg2:Point=null):void{
var _local3:Number = (_arg1.x - x);
var _local4:Number = (_arg1.y - y);
var _local5:Number = Math.sqrt(((_local3 * _local3) + (_local4 * _local4)));
if (_local5 > 1E-6){
if (_arg2){
_arg2.x = (x + ((_local3 / _local5) * radius));
_arg2.y = (y + ((_local4 / _local5) * radius));
} else {
_arg1.x = (x + ((_local3 / _local5) * radius));
_arg1.y = (y + ((_local4 / _local5) * radius));
};
} else {
if (_arg2){
_arg2.x = x;
_arg2.y = y;
} else {
_arg1.x = x;
_arg1.y = y;
};
};
}
}
}//package de.polygonal.motor2.collision.shapes
Section 91
//LineShape (de.polygonal.motor2.collision.shapes.LineShape)
package de.polygonal.motor2.collision.shapes {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.*;
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);
}
private function clip(_arg1:V2, _arg2:V2):Boolean{
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local3:V2 = worldVertexChain.edge.d;
var _local4:AABB2 = body.world.getWorldBounds();
var _local5:Number = -2147483647;
var _local6:Number = 2147483647;
if (((_local3.x < 0)) ? -(_local3.x) : _local3.x < 1E-6){
if (x < _local4.xmin){
return (false);
};
if (x > _local4.xmax){
return (false);
};
} else {
_local7 = ((_local4.xmin - x) / _local3.x);
_local8 = ((_local4.xmax - x) / _local3.x);
if (_local7 > _local8){
_local9 = _local7;
_local7 = _local8;
_local8 = _local9;
};
if (_local7 > _local5){
_local5 = _local7;
};
if (_local8 < _local6){
_local6 = _local8;
};
if (_local5 > _local6){
return (false);
};
};
if (((_local3.y < 0)) ? -(_local3.y) : _local3.y < 1E-6){
if (y < _local4.ymin){
return (false);
};
if (y > _local4.ymax){
return (false);
};
} else {
_local7 = ((_local4.ymin - y) / _local3.y);
_local8 = ((_local4.ymax - y) / _local3.y);
if (_local7 > _local8){
_local9 = _local7;
_local7 = _local8;
_local8 = _local9;
};
if (_local7 > _local5){
_local5 = _local7;
};
if (_local8 < _local6){
_local6 = _local8;
};
if (_local5 > _local6){
return (false);
};
};
_arg1.x = (x + (_local3.x * _local5));
_arg1.y = (y + (_local3.y * _local5));
_arg2.x = (x + (_local3.x * _local6));
_arg2.y = (y + (_local3.y * _local6));
return (true);
}
override public function toWorldSpace():void{
var _local1:V2 = worldVertexChain;
var _local2:V2 = modelVertexChain;
var _local3:V2 = worldNormalChain;
var _local4:V2 = modelNormalChain;
var _local5:Number = body.x;
var _local6:Number = body.y;
_local1.x = (((r11 * _local2.x) + (r12 * _local2.y)) + _local5);
_local1.y = (((r21 * _local2.x) + (r22 * _local2.y)) + _local6);
_local3.x = ((r11 * _local4.x) + (r12 * _local4.y));
_local3.y = ((r21 * _local4.x) + (r22 * _local4.y));
_local1 = _local1.next;
_local3 = _local3.next;
_local2 = _local2.next;
_local4 = _local4.next;
_local1.x = (((r11 * _local2.x) + (r12 * _local2.y)) + _local5);
_local1.y = (((r21 * _local2.x) + (r22 * _local2.y)) + _local6);
_local3.x = ((r11 * _local4.x) + (r12 * _local4.y));
_local3.y = ((r21 * _local4.x) + (r22 * _local4.y));
}
override public function update():Boolean{
var _local1:V2;
var _local2:V2;
var _local3:Number;
var _local4:Number;
synced = false;
x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my)));
y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my)));
if (infinite){
_local1 = new V2();
_local2 = new V2();
if (clip(_local1, _local2)){
if (_local1.x < _local2.x){
xmin = _local1.x;
xmax = _local2.x;
} else {
xmin = _local2.x;
xmax = _local1.x;
};
if (_local1.y < _local2.y){
ymin = _local1.y;
ymax = _local2.y;
} else {
ymin = _local2.y;
ymax = _local1.y;
};
if ((xmax - xmin) < Constants.k_minLineAABBThickness){
_local3 = (xmax - xmin);
xmin = (xmin - ((Constants.k_minLineAABBThickness * 0.5) - _local3));
xmax = (xmax + ((Constants.k_minLineAABBThickness * 0.5) - _local3));
};
if ((ymax - ymin) < Constants.k_minLineAABBThickness){
_local4 = (ymax - ymin);
ymin = (ymin - ((Constants.k_minLineAABBThickness * 0.5) - _local4));
ymax = (ymax + ((Constants.k_minLineAABBThickness * 0.5) - _local4));
};
xmin = int((xmin + 0.5));
ymin = int((ymin + 0.5));
xmax = int(xmax);
ymax = int(ymax);
} else {
xmin = (body.world.getWorldBounds().xmin - 1);
};
} else {
xmin = (x - ex);
ymin = (y - ey);
xmax = (x + ex);
ymax = (y + ey);
};
return (super.update());
}
override protected function setType():void{
type = ShapeTypes.LINE;
}
private function setup(_arg1:LineData, _arg2:RigidBody):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Array;
var _local8:V2;
infinite = _arg1.infinite;
doubleSided = _arg1.doubleSided;
_local3 = _arg2.cx;
_local5 = _arg2.cy;
mx = (_arg1.mx - _local3);
my = (_arg1.my - _local5);
x = (body.x + (((r11 = body.r11) * mx) + ((r12 = body.r12) * my)));
y = (body.y + (((r21 = body.r21) * mx) + ((r22 = body.r22) * my)));
_local4 = (_arg1.b.x - _arg1.a.x);
_local6 = (_arg1.b.y - _arg1.a.y);
var _local9:Number = Math.sqrt(((_local4 * _local4) + (_local6 * _local6)));
vertexCount = 2;
_local7 = new Array(vertexCount);
_local8 = (_local7[0] = new V2());
_local8.x = ((mx + (r11 * _arg1.a.x)) + (r12 * _arg1.a.y));
_local8.y = ((my + (r21 * _arg1.a.x)) + (r22 * _arg1.a.y));
_local8 = (_local7[1] = new V2());
_local8.x = ((mx + (r11 * _arg1.b.x)) + (r12 * _arg1.b.y));
_local8.y = ((my + (r21 * _arg1.b.x)) + (r22 * _arg1.b.y));
initPoly(_local7, vertexCount, true);
radius = (_local9 / 2);
radiusSq = (radius * radius);
toWorldSpace();
if (!infinite){
_local8 = worldVertexChain;
xmin = Math.min(_local8.x, _local8.next.x);
xmax = Math.max(_local8.x, _local8.next.x);
ymin = Math.min(_local8.y, _local8.next.y);
ymax = Math.max(_local8.y, _local8.next.y);
xmin = int((xmin + 0.5));
ymin = int((ymin + 0.5));
xmax = int(xmax);
ymax = int(ymax);
ex = ((xmax - xmin) / 2);
ey = ((ymax - ymin) / 2);
if ((ex * 2) < Constants.k_minLineAABBThickness){
ex = (ex + ((Constants.k_minLineAABBThickness * 0.5) - ex));
};
if (ey < Constants.k_minLineAABBThickness){
ey = (ey + ((Constants.k_minLineAABBThickness * 0.5) - ey));
};
} else {
ex = NaN;
ey = NaN;
};
_local4 = (worldVertexChain.next.x - worldVertexChain.x);
_local6 = (worldVertexChain.next.y - worldVertexChain.y);
_local9 = Math.sqrt(((_local4 * _local4) + (_local6 * _local6)));
_local4 = (_local4 / _local9);
_local6 = (_local6 / _local9);
d = ((worldNormalChain.x * worldVertexChain.x) + (worldNormalChain.y * worldVertexChain.y));
update();
createProxy();
}
}
}//package de.polygonal.motor2.collision.shapes
Section 92
//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 maskBits:int;
public var r12:Number;
public var userData;
public var broadPhase:BroadPhase;
public var r11:Number;
public var proxyId:int;
public var worldNormalChain:V2;
public var r21:Number;
public var categoryBits:int;
public var modelNormalChain:V2;
public var r22:Number;
public var type:int;
public var ymin:Number;
public var offsets:Array;
public var ymax:Number;
public var regularShape:Boolean;
public var restitution:Number;
public var d:Number;
public var x:Number;
public var y:Number;
public var synced:Boolean;// = false
public var v1:V2;
public var v2:V2;
public var v3:V2;
public var v0:V2;
public var n0:V2;
public var n1:V2;
public var n2:V2;
public var n3:V2;
public var worldVertexChain:V2;
public var area:Number;
public var radiusSq:Number;
public var radius:Number;
public var groupIndex:int;
public var modelVertexChain:V2;
public var body:RigidBody;
public var mx:Number;
public var my:Number;
public var ex:Number;
public var ey:Number;
public var BSPNode:ConvexBSPNode;
public var triangleList:Tri2;
public var vertexCount:int;
public var xmin:Number;
public var xmax:Number;
public var next:ShapeSkeleton;
public var friction:Number;
public function ShapeSkeleton(_arg1:ShapeData, _arg2:RigidBody){
friction = _arg1.friction;
restitution = _arg1.restitution;
area = _arg1.area;
body = _arg2;
groupIndex = _arg1.groupIndex;
categoryBits = _arg1.categoryBits;
maskBits = _arg1.maskBits;
setType();
broadPhase = body.world.getBroadPhase();
proxyId = Proxy.NULL_PROXY;
}
public function refreshProxy():void{
if (proxyId != Proxy.NULL_PROXY){
broadPhase.destroyProxy(proxyId);
createProxy();
};
}
public function getShapeOffset(_arg1:Point):void{
_arg1.x = mx;
_arg1.y = my;
}
public function toWorldSpace():void{
}
public function deconstruct():void{
BSPNode = null;
modelVertexChain = (modelNormalChain = (worldVertexChain = (worldNormalChain = null)));
offsets = null;
triangleList = null;
if (proxyId != Proxy.NULL_PROXY){
broadPhase.destroyProxy(proxyId);
proxyId = Proxy.NULL_PROXY;
};
broadPhase = null;
}
public function extractEdgeList(_arg1:V2):Array{
var _local2:V2 = _arg1;
var _local3:Array = new Array(vertexCount, true);
var _local4:int;
while (_local4 < vertexCount) {
_local3[_local4] = _local2.edge.d;
_local2 = _local2.next;
_local4++;
};
return (_local3);
}
public function closestPoint(_arg1:Point, _arg2:Point=null):void{
}
protected function setType():void{
type = ShapeTypes.UNKNOWN;
}
public function pointInside(_arg1:Point):Boolean{
return (false);
}
public function update():Boolean{
if (proxyId == Proxy.NULL_PROXY){
return (false);
};
if (broadPhase.insideBounds(xmin, ymin, xmax, ymax)){
broadPhase.moveProxy(proxyId);
return (true);
};
return (false);
}
protected function computeMinAreaRect(_arg1:V2, _arg2:V2):Number{
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:V2;
var _local30:V2;
var _local31:V2;
var _local32:V2;
var _local33:int;
var _local34:Number;
var _local3:Number = Number.MAX_VALUE;
_local29 = modelVertexChain;
_local30 = modelVertexChain.next;
_local31 = modelVertexChain;
_local33 = 0;
while (_local33 < vertexCount) {
_local17 = (_local30.x - _local29.x);
_local20 = (_local30.y - _local29.y);
_local28 = Math.sqrt(((_local17 * _local17) + (_local20 * _local20)));
_local17 = (_local17 / _local28);
_local20 = (_local20 / _local28);
_local18 = -(_local20);
_local21 = _local17;
_local15 = ((_local31.x * _local17) + (_local31.y * _local20));
_local13 = _local15;
_local16 = ((_local31.x * _local18) + (_local31.y * _local21));
_local14 = _local16;
_local32 = modelVertexChain.next;
while (true) {
_local27 = ((_local32.x * _local17) + (_local32.y * _local20));
if (_local27 < _local13){
_local13 = _local27;
} else {
if (_local27 > _local15){
_local15 = _local27;
};
};
_local27 = ((_local32.x * _local18) + (_local32.y * _local21));
if (_local27 < _local14){
_local14 = _local27;
} else {
if (_local27 > _local16){
_local16 = _local27;
};
};
if (_local32.isTail){
break;
};
_local32 = _local32.next;
};
_local4 = ((_local15 - _local13) * (_local16 - _local14));
if (_local4 < _local3){
_local3 = _local4;
_local5 = (_local17 * _local13);
_local6 = (_local20 * _local13);
_local7 = (_local17 * _local15);
_local8 = (_local20 * _local15);
_local9 = (_local18 * _local14);
_local10 = (_local21 * _local14);
_local11 = (_local18 * _local16);
_local12 = (_local21 * _local16);
};
_local29 = _local30;
_local30 = _local30.next;
_local33++;
};
_local19 = (_local7 - _local5);
_local22 = (_local8 - _local6);
_local25 = Math.sqrt(((_local19 * _local19) + (_local22 * _local22)));
_local23 = Math.atan2(_local22, _local19);
_local19 = (_local11 - _local9);
_local22 = (_local12 - _local10);
_local26 = Math.sqrt(((_local19 * _local19) + (_local22 * _local22)));
_local24 = Math.atan2(_local22, _local19);
if (((_local24 < 0)) ? -(_local24) : _local24 < ((_local23 < 0)) ? -(_local23) : _local23){
_local34 = _local24;
_arg2.x = (_local26 / 2);
_arg2.y = (_local25 / 2);
} else {
_local34 = _local23;
_arg2.x = (_local25 / 2);
_arg2.y = (_local26 / 2);
};
_arg1.x = ((_local5 + _local9) + (((_local7 + _local11) - (_local5 + _local9)) / 2));
_arg1.y = ((_local6 + _local10) + (((_local8 + _local12) - (_local6 + _local10)) / 2));
return (_local34);
}
public function triangulate():void{
}
protected function createProxy():void{
if (((broadPhase) && (broadPhase.insideBounds(xmin, ymin, xmax, ymax)))){
proxyId = broadPhase.createProxy(this);
} else {
proxyId = Proxy.NULL_PROXY;
body.freeze();
};
}
protected function initPoly(_arg1:Array, _arg2:int, _arg3:Boolean, _arg4:Number=0, _arg5:Number=0):void{
var _local6:int;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:V2;
var _local13:V2;
var _local14:V2;
var _local15:V2;
var _local16:V2;
var _local17:V2;
var _local18:V2;
var _local19:E2;
var _local21:Number;
var _local22:Number;
var _local23:Number;
regularShape = _arg3;
_local15 = _arg1[0];
modelVertexChain = _local15;
_local16 = new V2();
worldVertexChain = _local16;
_local15.index = 0;
_local16.index = 0;
_local15.isHead = true;
_local16.isHead = true;
_local17 = new V2();
modelNormalChain = _local17;
_local18 = new V2();
worldNormalChain = _local18;
_local17.index = 0;
_local18.index = 0;
_local17.isHead = true;
_local18.isHead = true;
_local6 = 1;
while (_local6 < _arg2) {
_local12 = _arg1[_local6];
_local13 = _local15;
_local14 = _local12;
_local14.index = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local15 = _local15.next;
_local13 = _local16;
_local14 = new V2();
_local14.index = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local16 = _local16.next;
_local13 = _local17;
_local14 = new V2();
_local14.index = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local17 = _local17.next;
_local13 = _local18;
_local14 = new V2();
_local14.index = _local6;
_local13.next = _local14;
_local14.prev = _local13;
_local18 = _local18.next;
_local6++;
};
_local15.isTail = true;
_local15.next = modelVertexChain;
modelVertexChain.prev = _local15;
_local16.isTail = true;
_local16.next = worldVertexChain;
worldVertexChain.prev = _local16;
_local17.isTail = true;
_local17.next = modelNormalChain;
modelNormalChain.prev = _local17;
_local18.isTail = true;
_local18.next = worldNormalChain;
worldNormalChain.prev = _local18;
var _local20:Array = new Array(_arg2, true);
offsets = new Array(_arg2, true);
_local18 = worldNormalChain;
_local16 = worldVertexChain;
_local17 = modelNormalChain;
_local13 = modelVertexChain;
_local14 = _local13.next;
_local6 = 0;
while (_local6 < _arg2) {
_local7 = (_local14.x - _local13.x);
_local8 = (_local14.y - _local13.y);
_local11 = Math.sqrt(((_local7 * _local7) + (_local8 * _local8)));
_local7 = (_local7 / _local11);
_local8 = (_local8 / _local11);
_local20[_local6] = new V2(_local7, _local8);
_local9 = _local8;
_local10 = -(_local7);
_local17.x = _local9;
_local17.y = _local10;
_local17 = _local17.next;
_local21 = ((body.cx + _local13.x) + ((_local14.x - _local13.x) * 0.5));
_local22 = ((body.cy + _local13.y) + ((_local14.y - _local13.y) * 0.5));
_local23 = (((_local21 - _arg4) * _local9) + ((_local22 - _arg5) * _local10));
if (!_arg3){
offsets[_local6] = new V2((_local21 + (-(_local9) * _local23)), (_local22 + (-(_local10) * _local23)));
};
_local19 = new E2();
_local19.v = _local13;
_local19.w = _local13.next;
_local19.n = _local17;
_local19.d = _local20[_local6];
_local19.mag = _local11;
_local13.edge = _local19;
_local13 = _local14;
_local14 = _local13.next;
_local19 = new E2();
_local19.v = _local16;
_local19.w = _local16.next;
_local19.n = _local18;
_local19.d = _local20[_local6];
_local19.mag = _local11;
_local16.edge = _local19;
_local16 = _local16.next;
_local18 = _local18.next;
_local6++;
};
_local12 = modelVertexChain;
_local6 = 0;
while (_local6 < _arg2) {
_local12.edge.next = _local12.next.edge;
_local12.edge.prev = _local12.prev.edge;
_local12 = _local12.next;
_local6++;
};
_local12 = worldVertexChain;
_local6 = 0;
while (_local6 < _arg2) {
_local12.edge.next = _local12.next.edge;
_local12.edge.prev = _local12.prev.edge;
_local12 = _local12.next;
_local6++;
};
}
}
}//package de.polygonal.motor2.collision.shapes
Section 93
//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 94
//BoxCircleContact (de.polygonal.motor2.dynamics.contact.generator.BoxCircleContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class BoxCircleContact extends ConvexCircleContact {
private static const COLLIDE_BOX_CIRCLE:CollideBoxCircle = new CollideBoxCircle();
public function BoxCircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
return (COLLIDE_BOX_CIRCLE);
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 95
//BoxContact (de.polygonal.motor2.dynamics.contact.generator.BoxContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class BoxContact extends ConvexContact {
public var sepAxisId:int;
private static const COLLIDE_BOX:CollideBox = new CollideBox();
public function BoxContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
return (COLLIDE_BOX);
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 96
//BoxLineContact (de.polygonal.motor2.dynamics.contact.generator.BoxLineContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class BoxLineContact extends ConvexContact {
public var sid:int;// = -1
private static const COLLIDE_BOX_LINE_DS:CollideBoxLineDoubleSided = new CollideBoxLineDoubleSided();
private static const COLLIDE_BOX_LINE_SS:CollideBoxLineSingleSided = new CollideBoxLineSingleSided();
private static const COLLIDE_BOX_PLANE_DS:CollideBoxPlaneDoubleSided = new CollideBoxPlaneDoubleSided();
private static const COLLIDE_BOX_PLANE_SS:CollideBoxPlaneSingleSided = new CollideBoxPlaneSingleSided();
public function BoxLineContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
var _local1:LineShape = LineShape(shape2);
if (_local1.infinite){
if (_local1.doubleSided){
return (COLLIDE_BOX_PLANE_DS);
};
return (COLLIDE_BOX_PLANE_SS);
};
if (_local1.doubleSided){
return (COLLIDE_BOX_LINE_DS);
};
return (COLLIDE_BOX_LINE_SS);
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 97
//CircleContact (de.polygonal.motor2.dynamics.contact.generator.CircleContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.collision.pairwise.*;
public class CircleContact extends Contact {
public var manifold:Manifold;
private static const COLLIDE_CIRCLE:CollideCircle = new CollideCircle();
public function CircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
manifold = (manifolds[0] = new Manifold());
manifold.c0.Pn = 0;
manifold.c0.Pt = 0;
}
override public function evaluate():void{
_collider.collide(manifold, shape1, shape2, null);
manifoldCount = ((manifold.pointCount > 0)) ? 1 : 0;
}
override protected function getCollider():Collider{
return (COLLIDE_CIRCLE);
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 98
//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.dynamics.contact.*;
import de.polygonal.motor2.collision.pairwise.*;
public class CircleLineContact extends Contact {
private var _m1Cp1:ContactPoint;
private var _Pt0:Number;
public var manifold:Manifold;
private var _Pn0:Number;
private var _id0:uint;
private static const COLLIDE_CIRCLE_PLANE_DS:CollideCirclePlaneDoubleSided = new CollideCirclePlaneDoubleSided();
private static const COLLIDE_CIRCLE_PLANE_SS:CollideCirclePlaneSingleSided = new CollideCirclePlaneSingleSided();
private static const COLLIDE_CIRCLE_LINE_DS:CollideCircleLineDoubleSided = new CollideCircleLineDoubleSided();
private static const COLLIDE_CIRCLE_LINE_SS:CollideCircleLineSingleSided = new CollideCircleLineSingleSided();
public function CircleLineContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
manifold = (manifolds[0] = new Manifold());
_m1Cp1 = manifold.c0;
manifold.c0.Pn = 0;
manifold.c0.Pt = 0;
}
override protected function getCollider():Collider{
var _local1:LineShape = LineShape(shape2);
if (_local1.infinite){
if (_local1.doubleSided){
return (COLLIDE_CIRCLE_PLANE_DS);
};
return (COLLIDE_CIRCLE_PLANE_SS);
};
if (_local1.doubleSided){
return (COLLIDE_CIRCLE_LINE_DS);
};
return (COLLIDE_CIRCLE_LINE_SS);
}
override public function evaluate():void{
var _local1:int;
var _local2:int;
if (World.doWarmStarting){
_m1Cp1.matched = false;
_local1 = manifold.pointCount;
if (_local1 > 0){
_id0 = _m1Cp1.id.key;
_Pn0 = _m1Cp1.Pn;
_Pt0 = _m1Cp1.Pt;
};
_collider.collide(manifold, shape1, shape2, this);
_local2 = manifold.pointCount;
if (_local2 > 0){
manifoldCount = 1;
} else {
manifoldCount = 0;
return;
};
_m1Cp1.Pn = 0;
_m1Cp1.Pt = 0;
if ((((_local1 == 1)) && ((_local2 == 1)))){
if (_m1Cp1.id.key == _id0){
_m1Cp1.Pn = _Pn0;
_m1Cp1.Pt = _Pt0;
_m1Cp1.matched = true;
};
};
} else {
_collider.collide(manifold, shape1, shape2, this);
manifoldCount = ((manifold.pointCount > 0)) ? 1 : 0;
};
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 99
//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 _m1Cp1:ContactPoint;
public var d:V2;
private var _Pt0:Number;
public var manifold:Manifold;
private var _Pn0:Number;
private var _id0:uint;
public var p:V2;
public function ConvexCircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
manifold = (manifolds[0] = new Manifold());
_m1Cp1 = manifold.c0;
p = _arg1.worldVertexChain;
d = _arg1.worldNormalChain;
}
override public function evaluate():void{
var _local1:int;
var _local2:int;
if (!shape1.synced){
shape1.toWorldSpace();
};
if (World.doWarmStarting){
_m1Cp1.matched = false;
_local1 = manifold.pointCount;
if (_local1 > 0){
_id0 = _m1Cp1.id.key;
_Pn0 = _m1Cp1.Pn;
_Pt0 = _m1Cp1.Pt;
};
_collider.collide(manifold, shape1, shape2, this);
_local2 = manifold.pointCount;
if (_local2 > 0){
manifoldCount = 1;
} else {
manifoldCount = 0;
return;
};
_m1Cp1.Pn = 0;
_m1Cp1.Pt = 0;
if ((((_local1 == 1)) && ((_local2 == 1)))){
if (_m1Cp1.id.key == _id0){
_m1Cp1.Pn = _Pn0;
_m1Cp1.Pt = _Pt0;
_m1Cp1.matched = true;
};
};
} else {
_collider.collide(manifold, shape1, shape2, this);
if (manifold.pointCount > 0){
manifoldCount = 1;
} else {
manifoldCount = 0;
return;
};
};
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 100
//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 _m1Cp1:ContactPoint;
private var _Pn0_1:Number;
private var _Pn0_2:Number;
private var _Pt0_2:Number;
private var _id0_1:uint;
private var _m1Cp2:ContactPoint;
public var manifold:Manifold;
private var _id0_2:uint;
private var _Pt0_1:Number;
public function ConvexContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
manifold = (manifolds[0] = new Manifold());
_m1Cp1 = manifold.c0;
_m1Cp2 = manifold.c1;
}
override public function evaluate():void{
var _local1:int;
var _local2:int;
var _local3:int;
if (!shape1.synced){
shape1.toWorldSpace();
};
if (!shape2.synced){
shape2.toWorldSpace();
};
if (World.doWarmStarting){
_m1Cp1.matched = false;
_m1Cp2.matched = false;
_local1 = manifold.pointCount;
if (_local1 > 0){
_id0_1 = _m1Cp1.id.key;
_Pn0_1 = _m1Cp1.Pn;
_Pt0_1 = _m1Cp1.Pt;
if (_local1 > 1){
_id0_2 = _m1Cp2.id.key;
_Pn0_2 = _m1Cp2.Pn;
_Pt0_2 = _m1Cp2.Pt;
};
};
_collider.collide(manifold, shape1, shape2, this);
_local2 = manifold.pointCount;
if (_local2 > 0){
manifoldCount = 1;
} else {
manifoldCount = 0;
return;
};
_m1Cp1.Pn = 0;
_m1Cp1.Pt = 0;
_m1Cp2.Pn = 0;
_m1Cp2.Pt = 0;
if (_local2 == 1){
if (_local1 == 1){
if (_m1Cp1.id.key == _id0_1){
_m1Cp1.Pn = _Pn0_1;
_m1Cp1.Pt = _Pt0_1;
_m1Cp1.matched = true;
};
} else {
if (_local1 == 2){
_local3 = _m1Cp1.id.key;
if (_local3 == _id0_1){
_m1Cp1.Pn = _Pn0_1;
_m1Cp1.Pt = _Pt0_1;
_m1Cp1.matched = true;
} else {
if (_local3 == _id0_2){
};
};
_m1Cp1.Pn = _Pn0_2;
_m1Cp1.Pt = _Pn0_2;
_m1Cp1.matched = true;
};
};
} else {
if (_local2 == 2){
if (_local1 == 1){
if (_m1Cp1.id.key == _id0_1){
_m1Cp1.Pn = _Pn0_1;
_m1Cp1.Pt = _Pt0_1;
_m1Cp1.matched = true;
} else {
if (_m1Cp2.id.key == _id0_1){
_m1Cp2.Pn = _Pn0_1;
_m1Cp2.Pt = _Pt0_1;
_m1Cp2.matched = true;
};
};
} else {
if (_local1 == 2){
if (_m1Cp1.id.key == _id0_1){
_m1Cp1.Pn = _Pn0_1;
_m1Cp1.Pt = _Pt0_1;
_m1Cp1.matched = true;
if (_m1Cp2.id.key == _id0_2){
_m1Cp2.Pn = _Pn0_2;
_m1Cp2.Pt = _Pt0_2;
_m1Cp2.matched = true;
return;
};
} else {
if (_m1Cp1.id.key == _id0_2){
_m1Cp1.Pn = _Pn0_2;
_m1Cp1.Pt = _Pt0_2;
_m1Cp1.matched = true;
if (_m1Cp2.id.key == _id0_1){
_m1Cp2.Pn = _Pn0_1;
_m1Cp2.Pt = _Pt0_1;
_m1Cp2.matched = true;
return;
};
};
};
if (_m1Cp2.id.key == _id0_1){
_m1Cp2.Pn = _Pn0_1;
_m1Cp2.Pt = _Pt0_1;
_m1Cp2.matched = true;
} else {
if (_m1Cp2.id.key == _id0_2){
_m1Cp2.Pn = _Pn0_2;
_m1Cp2.Pt = _Pt0_2;
_m1Cp2.matched = true;
};
};
};
};
};
};
} else {
_collider.collide(manifold, shape1, shape2, this);
manifoldCount = ((manifold.pointCount > 0)) ? 1 : 0;
};
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 101
//PolyCircleContact (de.polygonal.motor2.dynamics.contact.generator.PolyCircleContact)
package de.polygonal.motor2.dynamics.contact.generator {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class PolyCircleContact extends ConvexCircleContact {
private static const COLLIDE_POLY_CIRCLE:CollidePolyCircle = new CollidePolyCircle();
public function PolyCircleContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
}
override protected function getCollider():Collider{
return (COLLIDE_POLY_CIRCLE);
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 102
//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.*;
import flash.utils.*;
public class PolyContact extends ConvexContact {
public var p:V2;
public var d:V2;
public var hc:Dictionary;
public var firstOut:Boolean;
private static const COLLIDE_TRIANGLE_HC:CollideTriangleHC = new CollideTriangleHC();
private static const COLLIDE_POLY_CHC:CollidePolyCHC = new CollidePolyCHC();
private static const COLLIDE_POLY_BSP:CollidePolyBSP = new CollidePolyBSP();
public function PolyContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
firstOut = true;
p = _arg1.worldVertexChain;
d = _arg1.worldNormalChain;
if ((_arg1.vertexCount + _arg2.vertexCount) > 10){
hc = new Dictionary(true);
};
}
override public function flush():void{
hc = null;
}
override protected function getCollider():Collider{
if ((shape1.vertexCount + shape2.vertexCount) > 10){
return (COLLIDE_POLY_CHC);
};
if ((((shape1.vertexCount == 3)) && ((shape2.vertexCount == 3)))){
return (COLLIDE_TRIANGLE_HC);
};
return (COLLIDE_POLY_BSP);
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 103
//PolyLineContact (de.polygonal.motor2.dynamics.contact.generator.PolyLineContact)
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 PolyLineContact extends ConvexContact {
public var hint1:V2;
public var hint2:V2;
private static const COLLIDE_POLY_PLANE_DS_CHC:CollidePolyPlaneDoubleSidedCHC = new CollidePolyPlaneDoubleSidedCHC();
private static const COLLIDE_POLY_PLANE_DS_BSP:CollidePolyPlaneDoubleSidedBSP = new CollidePolyPlaneDoubleSidedBSP();
private static const COLLIDE_POLY_LINE_DS_CHC:CollidePolyLineDoubleSidedCHC = new CollidePolyLineDoubleSidedCHC();
private static const COLLIDE_POLY_PLANE_SS_CHC:CollidePolyPlaneSingleSidedCHC = new CollidePolyPlaneSingleSidedCHC();
private static const COLLIDE_POLY_PLANE_SS_BSP:CollidePolyPlaneSingleSidedBSP = new CollidePolyPlaneSingleSidedBSP();
private static const COLLIDE_POLY_LINE_DS_BSP:CollidePolyLineDoubleSidedBSP = new CollidePolyLineDoubleSidedBSP();
private static const COLLIDE_POLY_LINE_SS_CHC:CollidePolyLineSingleSidedCHC = new CollidePolyLineSingleSidedCHC();
private static const COLLIDE_POLY_LINE_SS_BSP:CollidePolyLineSingleSidedBSP = new CollidePolyLineSingleSidedBSP();
public function PolyLineContact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
super(_arg1, _arg2);
var _local3 = (_arg1.vertexCount > 10);
if (_local3){
hint1 = _arg1.worldVertexChain;
hint2 = hint1;
};
}
override protected function getCollider():Collider{
var _local1 = (shape1.vertexCount > 10);
var _local2:LineShape = LineShape(shape2);
if (_local2.infinite){
if (_local2.doubleSided){
if (_local1){
return (COLLIDE_POLY_PLANE_DS_CHC);
};
return (COLLIDE_POLY_PLANE_DS_BSP);
};
if (_local1){
return (COLLIDE_POLY_PLANE_SS_CHC);
};
return (COLLIDE_POLY_PLANE_SS_BSP);
};
if (_local2.doubleSided){
if (_local1){
return (COLLIDE_POLY_LINE_DS_CHC);
};
return (COLLIDE_POLY_LINE_DS_BSP);
};
if (_local1){
return (COLLIDE_POLY_LINE_SS_CHC);
};
return (COLLIDE_POLY_LINE_SS_BSP);
}
}
}//package de.polygonal.motor2.dynamics.contact.generator
Section 104
//SIContactSolver (de.polygonal.motor2.dynamics.contact.solver.SIContactSolver)
package de.polygonal.motor2.dynamics.contact.solver {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.*;
import de.polygonal.motor2.dynamics.contact.*;
public class SIContactSolver {
private var _maxLinCorrection:Number;
private var _linSlop:Number;
private var _velThreshold:Number;
public var contactCount:int;
public var contacts:Array;
public function SIContactSolver():void{
_linSlop = Constants.k_linSlop;
_velThreshold = Constants.k_velocityThreshold;
_maxLinCorrection = Constants.k_maxLinCorrection;
}
public function solvePosConstraints(_arg1:Number):Boolean{
var _local2:int;
var _local3:int;
var _local4:int;
var _local5:Contact;
var _local6:Manifold;
var _local7:ContactPoint;
var _local8:RigidBody;
var _local9:RigidBody;
var _local10:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local11:Number = 0;
_local2 = 0;
while (_local2 < contactCount) {
_local5 = contacts[_local2];
_local8 = _local5.body1;
_local9 = _local5.body2;
_local3 = 0;
while (_local3 < _local5.manifoldCount) {
_local6 = _local5.manifolds[_local3];
_local12 = _local6.nx;
_local17 = _local6.ny;
_local4 = 0;
while (_local4 < _local6.pointCount) {
_local7 = _local6.points[_local4];
_local15 = ((_local8.r11 * _local7.l_r1x) + (_local8.r12 * _local7.l_r1y));
_local20 = ((_local8.r21 * _local7.l_r1x) + (_local8.r22 * _local7.l_r1y));
_local16 = ((_local9.r11 * _local7.l_r2x) + (_local9.r12 * _local7.l_r2y));
_local21 = ((_local9.r21 * _local7.l_r2x) + (_local9.r22 * _local7.l_r2y));
_local14 = ((_local9.x + _local16) - (_local8.x + _local15));
_local19 = ((_local9.y + _local21) - (_local8.y + _local20));
_local10 = (((_local14 * _local12) + (_local19 * _local17)) + _local7.sep);
_local11 = ((_local11 < _local10)) ? _local11 : _local10;
_local24 = (_local10 + _linSlop);
_local25 = -(_maxLinCorrection);
_local26 = 0;
_local27 = (_arg1 * ((_local24)<_local25) ? _local25 : ((_local24)>_local26) ? _local26 : _local24);
_local28 = (-(_local7.nMass) * _local27);
_local29 = _local7.Pp;
_local7.Pp = (_local29 + _local28);
if (_local7.Pp < 0){
_local7.Pp = 0;
};
_local28 = (_local7.Pp - _local29);
_local13 = (_local28 * _local12);
_local18 = (_local28 * _local17);
_local8.x = (_local8.x - (_local8.invMass * _local13));
_local8.y = (_local8.y - (_local8.invMass * _local18));
_local8.r = (_local8.r - (_local8.invI * ((_local15 * _local18) - (_local20 * _local13))));
_local22 = Math.cos(_local8.r);
_local23 = Math.sin(_local8.r);
_local8.r11 = _local22;
_local8.r12 = -(_local23);
_local8.r21 = _local23;
_local8.r22 = _local22;
_local9.x = (_local9.x + (_local9.invMass * _local13));
_local9.y = (_local9.y + (_local9.invMass * _local18));
_local9.r = (_local9.r + (_local9.invI * ((_local16 * _local18) - (_local21 * _local13))));
_local22 = Math.cos(_local9.r);
_local23 = Math.sin(_local9.r);
_local9.r11 = _local22;
_local9.r12 = -(_local23);
_local9.r21 = _local23;
_local9.r22 = _local22;
_local4++;
};
_local3++;
};
_local2++;
};
return ((_local11 >= -(_linSlop)));
}
public function setContacts(_arg1:Array, _arg2:int):void{
this.contacts = _arg1;
this.contactCount = _arg2;
}
public function preStep():void{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:RigidBody;
var _local5:RigidBody;
var _local6:Number;
var _local7:Number;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:Number;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Contact;
var _local18:Manifold;
var _local19:ContactPoint;
_local1 = 0;
while (_local1 < contactCount) {
_local17 = contacts[_local1];
_local4 = (contacts[_local1].body1 = _local17.shape1.body);
_local5 = (_local17.body2 = _local17.shape2.body);
_local2 = 0;
while (_local2 < _local17.manifoldCount) {
_local18 = _local17.manifolds[_local2];
_local6 = _local18.nx;
_local10 = _local18.ny;
_local3 = 0;
while (_local3 < _local18.pointCount) {
_local19 = _local18.points[_local3];
_local8 = (_local19.x - _local4.x);
_local12 = (_local19.y - _local4.y);
_local9 = (_local19.x - _local5.x);
_local13 = (_local19.y - _local5.y);
if (World.doPositionCorrection){
_local19.l_r1x = ((_local4.r11 * _local8) + (_local4.r21 * _local12));
_local19.l_r1y = ((_local4.r12 * _local8) + (_local4.r22 * _local12));
_local19.l_r2x = ((_local5.r11 * _local9) + (_local5.r21 * _local13));
_local19.l_r2y = ((_local5.r12 * _local9) + (_local5.r22 * _local13));
};
_local19.w_r1x = _local8;
_local19.w_r1y = _local12;
_local19.w_r2x = _local9;
_local19.w_r2y = _local13;
_local14 = ((_local8 * _local10) - (_local12 * _local6));
_local15 = ((_local9 * _local10) - (_local13 * _local6));
_local19.nMass = (1 / (((_local4.invMass + _local5.invMass) + ((_local4.invI * _local14) * _local14)) + ((_local5.invI * _local15) * _local15)));
_local14 = ((_local8 * -(_local6)) - (_local12 * _local10));
_local15 = ((_local9 * -(_local6)) - (_local13 * _local10));
_local19.tMass = (1 / (((_local4.invMass + _local5.invMass) + ((_local4.invI * _local14) * _local14)) + ((_local5.invI * _local15) * _local15)));
_local16 = ((_local6 * (((_local5.vx - (_local5.w * _local13)) - _local4.vx) + (_local4.w * _local12))) + (_local10 * (((_local5.vy + (_local5.w * _local9)) - _local4.vy) - (_local4.w * _local8))));
_local19.velBias = ((_local16 < -(_velThreshold))) ? (-(_local17.restitution) * _local16) : 0;
if (World.doWarmStarting){
_local7 = ((_local19.Pn * _local6) + (_local19.Pt * _local10));
_local11 = ((_local19.Pn * _local10) + (_local19.Pt * -(_local6)));
_local4.vx = (_local4.vx - (_local4.invMass * _local7));
_local4.vy = (_local4.vy - (_local4.invMass * _local11));
_local4.w = (_local4.w - (_local4.invI * ((_local8 * _local11) - (_local12 * _local7))));
_local5.vx = (_local5.vx + (_local5.invMass * _local7));
_local5.vy = (_local5.vy + (_local5.invMass * _local11));
_local5.w = (_local5.w + (_local5.invI * ((_local9 * _local11) - (_local13 * _local7))));
} else {
_local19.Pn = (_local19.Pt = 0);
};
_local19.Pp = 0;
_local3++;
};
_local2++;
};
_local1++;
};
}
public function solveVelConstraints():void{
var _local1:int;
var _local2:int;
var _local3:int;
var _local4:Contact;
var _local5:Manifold;
var _local6:ContactPoint;
var _local7:RigidBody;
var _local8:Number;
var _local9:Number;
var _local10:Number;
var _local11:Number;
var _local12:Number;
var _local13:RigidBody;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local25:Number;
var _local26:Number;
var _local27:Number;
var _local28:Number;
var _local29:Number;
var _local30:Number;
var _local31:Number;
_local1 = 0;
while (_local1 < contactCount) {
_local4 = contacts[_local1];
_local7 = _local4.body1;
_local13 = _local4.body2;
_local8 = _local7.invMass;
_local9 = _local7.invI;
_local14 = _local13.invMass;
_local15 = _local13.invI;
_local10 = _local7.vx;
_local11 = _local7.vy;
_local12 = _local7.w;
_local16 = _local13.vx;
_local17 = _local13.vy;
_local18 = _local13.w;
_local2 = 0;
while (_local2 < _local4.manifoldCount) {
_local5 = _local4.manifolds[_local2];
_local19 = _local5.nx;
_local22 = _local5.ny;
_local3 = 0;
while (_local3 < _local5.pointCount) {
_local6 = _local5.points[_local3];
_local25 = _local6.w_r1x;
_local26 = _local6.w_r1y;
_local27 = _local6.w_r2x;
_local28 = _local6.w_r2y;
_local21 = (((_local16 - (_local18 * _local28)) - _local10) + (_local12 * _local26));
_local24 = (((_local17 + (_local18 * _local27)) - _local11) - (_local12 * _local25));
_local30 = (-(_local6.nMass) * (((_local21 * _local19) + (_local24 * _local22)) - _local6.velBias));
_local29 = (_local6.Pn + _local30);
if (_local29 < 0){
_local29 = 0;
};
_local30 = (_local29 - _local6.Pn);
_local20 = (_local30 * _local19);
_local23 = (_local30 * _local22);
_local10 = (_local10 - (_local8 * _local20));
_local11 = (_local11 - (_local8 * _local23));
_local12 = (_local12 - (_local9 * ((_local25 * _local23) - (_local26 * _local20))));
_local16 = (_local16 + (_local14 * _local20));
_local17 = (_local17 + (_local14 * _local23));
_local18 = (_local18 + (_local15 * ((_local27 * _local23) - (_local28 * _local20))));
_local6.Pn = _local29;
_local21 = (((_local16 - (_local18 * _local28)) - _local10) + (_local12 * _local26));
_local24 = (((_local17 + (_local18 * _local27)) - _local11) - (_local12 * _local25));
_local30 = (((_local6.tMass * -(_local22)) * _local21) + (_local19 * _local24));
_local31 = (_local4.friction * _local6.Pn);
_local29 = (_local6.Pt + _local30);
_local29 = ((_local29)<-(_local31)) ? -(_local31) : ((_local29)>_local31) ? _local31 : _local29;
_local30 = (_local29 - _local6.Pt);
_local20 = (_local30 * _local22);
_local23 = (_local30 * -(_local19));
_local10 = (_local10 - (_local8 * _local20));
_local11 = (_local11 - (_local8 * _local23));
_local12 = (_local12 - (_local9 * ((_local25 * _local23) - (_local26 * _local20))));
_local16 = (_local16 + (_local14 * _local20));
_local17 = (_local17 + (_local14 * _local23));
_local18 = (_local18 + (_local15 * ((_local27 * _local23) - (_local28 * _local20))));
_local6.Pt = _local29;
_local3++;
};
_local2++;
};
_local7.vx = _local10;
_local7.vy = _local11;
_local7.w = _local12;
_local13.vx = _local16;
_local13.vy = _local17;
_local13.w = _local18;
_local1++;
};
}
}
}//package de.polygonal.motor2.dynamics.contact.solver
Section 105
//Contact (de.polygonal.motor2.dynamics.contact.Contact)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.collision.pairwise.*;
public class Contact {
public var next:Contact;
public var body1:RigidBody;
public var body2:RigidBody;
protected var _collider:Collider;
public var stateBits:int;
public var manifoldCount:int;
public var manifolds:Array;
public var restitution:Number;
public var node1:ContactNode;
public var node2:ContactNode;
public var shape2:ShapeSkeleton;
public var prev:Contact;
public var shape1:ShapeSkeleton;
public var friction:Number;
public var secondary:Boolean;
public var disabled:Boolean;
public static const k_bitIsland:int = 32;
public function Contact(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton){
init(_arg1, _arg2);
}
public function flush():void{
}
public function evaluate():void{
}
protected function init(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):void{
shape1 = _arg1;
shape2 = _arg2;
manifoldCount = 0;
manifolds = new Array(2, true);
friction = Math.sqrt((_arg1.friction * _arg2.friction));
restitution = ((_arg1.restitution > _arg2.restitution)) ? _arg1.restitution : _arg2.restitution;
_collider = getCollider();
node1 = new ContactNode();
node2 = new ContactNode();
}
protected function getCollider():Collider{
return (null);
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 106
//ContactFactory (de.polygonal.motor2.dynamics.contact.ContactFactory)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.ds.*;
import de.polygonal.motor2.dynamics.contact.generator.*;
public class ContactFactory {
private static var _contactMatrix:Array2;
public function ContactFactory(){
initializeContactMatrix();
}
private function initializeContactMatrix():void{
_contactMatrix = new Array2(ShapeTypes.SHAPE_COUNT, ShapeTypes.SHAPE_COUNT);
_contactMatrix.fill(ContactRegister);
registerContactHandler(BoxContact, ShapeTypes.BOX, ShapeTypes.BOX);
registerContactHandler(PolyContact, ShapeTypes.BOX, ShapeTypes.POLY);
registerContactHandler(BoxCircleContact, ShapeTypes.BOX, ShapeTypes.CIRCLE);
registerContactHandler(BoxLineContact, ShapeTypes.BOX, ShapeTypes.LINE);
registerContactHandler(PolyContact, ShapeTypes.POLY, ShapeTypes.POLY);
registerContactHandler(PolyCircleContact, ShapeTypes.POLY, ShapeTypes.CIRCLE);
registerContactHandler(PolyLineContact, ShapeTypes.POLY, ShapeTypes.LINE);
registerContactHandler(CircleContact, ShapeTypes.CIRCLE, ShapeTypes.CIRCLE);
registerContactHandler(CircleLineContact, ShapeTypes.CIRCLE, ShapeTypes.LINE);
}
public function destroy(_arg1:Contact):void{
if (_arg1.manifoldCount > 0){
_arg1.shape1.body.wakeUp();
_arg1.shape2.body.wakeUp();
};
_contactMatrix.get(_arg1.shape1.type, _arg1.shape2.type).deconstruct(_arg1);
}
public function create(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):Contact{
var _local5:Contact;
var _local6:int;
var _local7:Manifold;
var _local3:ContactRegister = _contactMatrix.get(_arg1.type, _arg2.type);
var _local4:Class = _local3.constructor;
if (_local4){
if (_local3.primary){
return (new _local4(_arg1, _arg2));
};
_local5 = new _local4(_arg2, _arg1);
_local5.secondary = true;
_local6 = 0;
while (_local6 < _local5.manifoldCount) {
_local7 = _local5.manifolds[_local6];
_local5.manifolds[_local6].nx = -(_local7.nx);
_local7.ny = -(_local7.ny);
_local6++;
};
return (_local5);
};
return (null);
}
private function registerContactHandler(_arg1:Class, _arg2:int, _arg3:int):void{
ContactRegister(_contactMatrix.get(_arg2, _arg3)).constructor = _arg1;
ContactRegister(_contactMatrix.get(_arg2, _arg3)).primary = true;
if (_arg2 != _arg3){
ContactRegister(_contactMatrix.get(_arg3, _arg2)).constructor = _arg1;
ContactRegister(_contactMatrix.get(_arg3, _arg2)).primary = false;
};
}
}
}//package de.polygonal.motor2.dynamics.contact
class ContactRegister {
public var primary:Boolean;
public var deconstruct:Function;
public var constructor:Class;
private function ContactRegister(){
}
}
Section 107
//ContactFilter (de.polygonal.motor2.dynamics.contact.ContactFilter)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.collision.shapes.*;
public class ContactFilter {
public function shouldCollide(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):Boolean{
if (_arg1.groupIndex == _arg2.groupIndex){
if (_arg1.groupIndex != 0){
return ((_arg1.groupIndex > 0));
};
};
return (((!(((_arg1.maskBits & _arg2.categoryBits) == 0))) && (!(((_arg1.categoryBits & _arg2.maskBits) == 0)))));
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 108
//ContactID (de.polygonal.motor2.dynamics.contact.ContactID)
package de.polygonal.motor2.dynamics.contact {
public class ContactID {
public var flip:int;
public var incVert:int;
public var refFace:int;
public var incEdge:int;
public var key:uint;
public static const NULL_FEATURE:int = 254;
public function toString():String{
return (((((((((refFace + "|") + incEdge) + "|") + incVert) + "|") + flip) + " -> ") + key));
}
public function bake():void{
key = ((((-(~(refFace)) << 24) | (-(~(incEdge)) << 16)) | (-(~(incVert)) << 8)) | -(~(flip)));
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 109
//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 PairCallback {
private var _contactFilter:ContactFilter;
private var _callback:ContactCallback;
private var _contactFactory:ContactFactory;
public var statsContactCount:int;
private var _world:World;
private static const NULL_CONTACT:NullContact = new NullContact();
public function ContactManager(_arg1:World){
_world = _arg1;
_contactFactory = new ContactFactory();
setCallback(new NullCallback());
}
public function collide():void{
var _local2:RigidBody;
var _local3:RigidBody;
var _local4:int;
var _local5:int;
var _local6:ContactNode;
var _local1:Contact = _world.contactList;
while (_local1) {
_local2 = _local1.shape1.body;
_local3 = _local1.shape2.body;
if (((_local2.stateBits & _local3.stateBits) & RigidBody.k_bitSleep)){
_local1 = _local1.next;
} else {
_local4 = _local1.manifoldCount;
_local1.evaluate();
_local5 = _local1.manifoldCount;
if ((((_local4 == 0)) && ((_local5 > 0)))){
_local6 = _local1.node1;
_local6.contact = _local1;
_local6.other = _local3;
_local6.prev = null;
_local6.next = _local2.contactList;
if (_local6.next){
_local6.next.prev = _local6;
};
_local2.contactList = _local6;
_local6 = _local1.node2;
_local6.contact = _local1;
_local6.other = _local2;
_local6.prev = null;
_local6.next = _local3.contactList;
if (_local6.next){
_local6.next.prev = _local6;
};
_local3.contactList = _local6;
} else {
if ((((_local4 > 0)) && ((_local5 == 0)))){
_local6 = _local1.node1;
if (_local6.next){
_local6.next.prev = _local6.prev;
};
if (_local6.prev){
_local6.prev.next = _local6.next;
};
if (_local6 == _local2.contactList){
_local2.contactList = _local6.next;
};
_local6.next = (_local6.prev = null);
_local6 = _local1.node2;
if (_local6.next){
_local6.next.prev = _local6.prev;
};
if (_local6.prev){
_local6.prev.next = _local6.next;
};
if (_local6 == _local3.contactList){
_local3.contactList = _local6.next;
};
_local6.next = (_local6.prev = null);
};
};
_local1 = _local1.next;
};
};
}
public function setCallback(_arg1:ContactCallback):void{
_callback = _arg1;
}
private function destroyContact(_arg1:Contact):void{
var _local2:RigidBody;
var _local3:RigidBody;
var _local4:ContactNode;
if (_world.contactCount == 0){
return;
};
if (_arg1.prev){
_arg1.prev.next = _arg1.next;
};
if (_arg1.next){
_arg1.next.prev = _arg1.prev;
};
if (_arg1 == _world.contactList){
_world.contactList = _arg1.next;
};
_arg1.flush();
if (_arg1.manifoldCount > 0){
_local2 = _arg1.shape1.body;
_local2.stateBits = (_local2.stateBits & ~(RigidBody.k_bitSleep));
_local2.sleepTime = 0;
_local3 = _arg1.shape2.body;
_local3.stateBits = (_local3.stateBits & ~(RigidBody.k_bitSleep));
_local3.sleepTime = 0;
_local4 = _arg1.node1;
if (_local4.next){
_local4.next.prev = _local4.prev;
};
if (_local4.prev){
_local4.prev.next = _local4.next;
};
if (_local4 == _local2.contactList){
_local2.contactList = _local4.next;
};
_local4.next = (_local4.prev = null);
_local4 = _arg1.node2;
if (_local4.next){
_local4.next.prev = _local4.prev;
};
if (_local4.prev){
_local4.prev.next = _local4.next;
};
if (_local4 == _local3.contactList){
_local3.contactList = _local4.next;
};
_local4.next = (_local4.prev = null);
};
_world.contactCount--;
}
public function pairAdded(_arg1:ShapeSkeleton, _arg2:ShapeSkeleton):Contact{
statsContactCount++;
var _local3:RigidBody = _arg1.body;
var _local4:RigidBody = _arg2.body;
if (((_local3.stateBits & _local4.stateBits) & RigidBody.k_bitStatic)){
return (NULL_CONTACT);
};
if (_local3 == _local4){
return (NULL_CONTACT);
};
if (_local4.isConnected(_local3)){
return (NULL_CONTACT);
};
if (!_contactFilter.shouldCollide(_arg1, _arg2)){
return (NULL_CONTACT);
};
var _local5:Contact = _contactFactory.create(_arg1, _arg2);
if (_local5 == null){
return (NULL_CONTACT);
};
_local5.prev = null;
_local5.next = _world.contactList;
if (_world.contactList){
_world.contactList.prev = _local5;
};
_world.contactList = _local5;
_world.contactCount++;
_callback.onContactAdded(_local5);
return (_local5);
}
public function setFilter(_arg1:ContactFilter):void{
_contactFilter = _arg1;
}
public function pairRemoved(_arg1:Contact):void{
statsContactCount++;
if ((((_arg1 == null)) || ((_arg1 == NULL_CONTACT)))){
return;
};
_callback.onContactRemoved(_arg1);
destroyContact(_arg1);
}
}
}//package de.polygonal.motor2.dynamics.contact
import de.polygonal.motor2.*;
class NullCallback implements ContactCallback {
private function NullCallback(){
}
public function onContactRemoved(_arg1:Contact):void{
}
public function onContactAdded(_arg1:Contact):void{
}
}
Section 110
//ContactNode (de.polygonal.motor2.dynamics.contact.ContactNode)
package de.polygonal.motor2.dynamics.contact {
import de.polygonal.motor2.dynamics.*;
public class ContactNode {
public var other:RigidBody;
public var prev:ContactNode;
public var contact:Contact;
public var next:ContactNode;
public function ContactNode(){
init();
}
private function init():void{
prev = (next = null);
other = null;
contact = null;
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 111
//ContactPoint (de.polygonal.motor2.dynamics.contact.ContactPoint)
package de.polygonal.motor2.dynamics.contact {
public class ContactPoint {
public var nMass:Number;
public var l_r1x:Number;
public var l_r1y:Number;
public var w_r1x:Number;
public var w_r1y:Number;
public var tMass:Number;
public var id:ContactID;
public var Pn:Number;
public var Pp:Number;
public var matched:Boolean;// = false
public var sep:Number;
public var l_r2y:Number;
public var Pt:Number;
public var w_r2y:Number;
public var l_r2x:Number;
public var w_r2x:Number;
public var x:Number;
public var y:Number;
public var velBias:Number;
public function ContactPoint():void{
init();
}
public function init():void{
id = new ContactID();
x = (y = (sep = (velBias = (Pn = (Pt = (Pp = (nMass = (tMass = 0))))))));
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 112
//Manifold (de.polygonal.motor2.dynamics.contact.Manifold)
package de.polygonal.motor2.dynamics.contact {
public class Manifold {
public var points:Array;
public var nx:Number;
public var ny:Number;
public var c0:ContactPoint;
public var c1:ContactPoint;
public var pointCount:int;
public function Manifold(){
init();
}
public function init():void{
c0 = new ContactPoint();
c1 = new ContactPoint();
points = new Array(2, true);
points[0] = c0;
points[1] = c1;
pointCount = 0;
}
}
}//package de.polygonal.motor2.dynamics.contact
Section 113
//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 114
//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 planeNormal:V2;
private var _cp0:V2;
public var linDrag:Number;
public var density:Number;
private var _cp1:V2;
public var angDrag:Number;
public var planeOffset:Number;
private var _clipTri0:ClipTriangle;
private var _clipTri1:ClipTriangle;
public var velocity:V2;
public function Buoyancy(_arg1:Number, _arg2:V2, _arg3:Number, _arg4:Number=5, _arg5:Number=0.5, _arg6:V2=null){
_clipTri0 = new ClipTriangle();
_clipTri1 = new ClipTriangle();
_cp0 = new V2();
_cp1 = new V2();
super();
this.planeOffset = _arg1;
this.planeNormal = _arg2;
this.density = _arg3;
this.linDrag = _arg4;
this.angDrag = _arg5;
this.velocity = (_arg6) ? _arg6 : new V2();
}
private function clipTriangle(_arg1:Tri2, _arg2:Number, _arg3:ClipTriangle, _arg4:ClipTriangle):int{
var _local11:V2;
var _local12:V2;
var _local13:V2;
var _local14:Number;
var _local15:Number;
var _local16:Number;
var _local17:Number;
var _local5:int;
var _local6:int;
var _local7:V2;
var _local8:V2;
var _local9:V2;
var _local10:V2;
if (_arg1.a.y > _arg2){
_local6++;
_local8 = _arg1.a;
} else {
_local5++;
_local7 = _arg1.a;
};
if (_arg1.b.y > _arg2){
_local6++;
if (_local8){
_local10 = _arg1.b;
} else {
_local8 = _arg1.b;
};
} else {
_local5++;
if (_local7){
_local9 = _arg1.b;
} else {
_local7 = _arg1.b;
};
};
if (_arg1.c.y > _arg2){
_local6++;
if (_local8){
_local10 = _arg1.c;
} else {
_local8 = _arg1.c;
};
} else {
_local5++;
if (_local7){
_local9 = _arg1.c;
} else {
_local7 = _arg1.c;
};
};
if (_local5 == 0){
_arg3.a = _arg1.a;
_arg3.b = _arg1.b;
_arg3.c = _arg1.c;
return (1);
};
if (_local6 == 0){
return (-1);
};
if (_local5 == 1){
_local11 = _local7;
_local12 = _local8;
_local14 = (_local11.y - _arg2);
_local15 = (_local12.y - _arg2);
_local16 = (_local14 / (_local14 - _local15));
_cp0.x = (_local11.x + (_local16 * (_local12.x - _local11.x)));
_cp0.y = (_local11.y + (_local16 * (_local12.y - _local11.y)));
_local12 = _local10;
_local15 = (_local12.y - _arg2);
_local16 = (_local14 / (_local14 - _local15));
_cp1.x = (_local11.x + (_local16 * (_local12.x - _local11.x)));
_cp1.y = (_local11.y + (_local16 * (_local12.y - _local11.y)));
if (_cp0.x > _cp1.x){
_local13 = _cp0;
_cp0 = _cp1;
_cp1 = _local13;
};
_local17 = (((_local8.x - _local11.x) * (_local10.y - _local11.y)) - ((_local8.y - _local11.y) * (_local10.x - _local11.x)));
if (_local8.x > _cp1.x){
_arg3.a = _local10;
_arg3.b = _cp1;
_arg3.c = _local8;
if (_local17 > 0){
_arg4.a = _local10;
_arg4.b = _cp1;
_arg4.c = _cp0;
} else {
_arg4.a = _local8;
_arg4.b = _cp1;
_arg4.c = _cp0;
};
return (2);
} else {
if (_local10.x < _cp0.x){
_arg3.a = _local10;
_arg3.b = _cp0;
_arg3.c = _local8;
if (_local17 > 0){
_arg4.a = _local8;
_arg4.b = _cp1;
_arg4.c = _cp0;
} else {
_arg4.a = _local10;
_arg4.b = _cp1;
_arg4.c = _cp0;
};
return (2);
} else {
_arg3.a = _local8;
_arg3.b = _local10;
_arg3.c = _cp0;
_arg4.a = _cp0;
_arg4.b = _local10;
_arg4.c = _cp1;
return (2);
};
};
} else {
if (_local5 == 2){
_local11 = _local8;
_local12 = _local7;
_local14 = (_local11.y - _arg2);
_local15 = (_local12.y - _arg2);
_local16 = (_local14 / (_local14 - _local15));
_cp0.x = (_local11.x + (_local16 * (_local12.x - _local11.x)));
_cp0.y = (_local11.y + (_local16 * (_local12.y - _local11.y)));
_local12 = _local9;
_local15 = (_local12.y - _arg2);
_local16 = (_local14 / (_local14 - _local15));
_cp1.x = (_local11.x + (_local16 * (_local12.x - _local11.x)));
_cp1.y = (_local11.y + (_local16 * (_local12.y - _local11.y)));
if (_cp0.x > _cp1.x){
_local13 = _cp0;
_cp0 = _cp1;
_cp1 = _local13;
};
_arg3.a = _cp1;
_arg3.b = _cp0;
_arg3.c = _local8;
return (1);
};
};
return (-1);
}
override public function evaluate(_arg1:RigidBody):void{
var _local8:int;
var _local9:V2;
var _local10:V2;
var _local11:V2;
var _local12:Number;
var _local13:ShapeSkeleton;
var _local14:Tri2;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local24:Number;
var _local2:Number = 0;
var _local3:Number = 0;
var _local4:Number = 2147483648;
var _local5:Number = -2147483648;
var _local6:Number = 0;
var _local7:Number = 0;
_local13 = _arg1.shapeList;
while (_local13) {
_local2 = (_local2 + _local13.area);
if (_local13.ymax < planeOffset){
} else {
if (_local13.ymin >= planeOffset){
_local12 = _local13.area;
_local6 = (_local6 + (_local12 * _local13.x));
_local7 = (_local7 + (_local12 * _local13.y));
_local3 = (_local3 + _local12);
if (_local13.xmin < _local4){
_local4 = _local13.xmin;
};
if (_local13.xmax > _local5){
_local5 = _local13.xmax;
};
} else {
if (_local13.type == ShapeTypes.CIRCLE){
_local21 = _local13.radius;
_local22 = (_local13.ymax - planeOffset);
_local12 = (((_local21 * _local21) * Math.acos(((_local21 - _local22) / _local21))) - ((_local21 - _local22) * Math.sqrt((((2 * _local21) * _local22) - (_local22 * _local22)))));
_local23 = ((2 * _local21) - _local22);
_local24 = ((3 * (_local23 * _local23)) / (4 * ((3 * _local21) - _local22)));
_local6 = (_local6 + (_local13.x * _local12));
_local7 = (_local7 + ((_local13.y + _local24) * _local12));
_local3 = (_local3 + _local12);
if (_local13.xmin < _local4){
_local4 = _local13.xmin;
};
if (_local13.xmax > _local5){
_local5 = _local13.xmax;
};
} else {
if (!_local13.synced){
_local13.toWorldSpace();
};
_local14 = _local13.triangleList;
while (_local14) {
_local8 = clipTriangle(_local14, planeOffset, _clipTri0, _clipTri1);
if (_local8 > 0){
_local9 = _clipTri0.a;
_local10 = _clipTri0.b;
_local11 = _clipTri0.c;
_local12 = ((((_local10.x - _local9.x) * (_local11.y - _local9.y)) - ((_local10.y - _local9.y) * (_local11.x - _local9.x))) / 2);
if (_local12 < 0){
_local12 = -(_local12);
};
if (_local12 > 1E-5){
_local6 = (_local6 + ((_local12 * ((_local9.x + _local10.x) + _local11.x)) / 3));
_local7 = (_local7 + ((_local12 * ((_local9.y + _local10.y) + _local11.y)) / 3));
_local3 = (_local3 + _local12);
};
};
if (_local8 > 1){
_local9 = _clipTri1.a;
_local10 = _clipTri1.b;
_local11 = _clipTri1.c;
_local12 = ((((_local10.x - _local9.x) * (_local11.y - _local9.y)) - ((_local10.y - _local9.y) * (_local11.x - _local9.x))) / 2);
if (_local12 < 0){
_local12 = -(_local12);
};
if (_local12 > 1E-5){
_local6 = (_local6 + ((_local12 * ((_local9.x + _local10.x) + _local11.x)) / 3));
_local7 = (_local7 + ((_local12 * ((_local9.y + _local10.y) + _local11.y)) / 3));
_local3 = (_local3 + _local12);
};
};
if (_local13.xmin < _local4){
_local4 = _local13.xmin;
};
if (_local13.xmax > _local5){
_local5 = _local13.xmax;
};
_local14 = _local14.next;
};
};
};
};
_local13 = _local13.next;
};
_local6 = (_local6 / _local3);
_local7 = (_local7 / _local3);
if (_local3 <= 1E-5){
return;
};
var _local15:Number = ((density * _local3) * _arg1.world.gravity.y);
var _local16:Number = ((_arg1.mass * _local3) / _local2);
var _local17:Number = (_local6 - _arg1.x);
var _local18:Number = (_local7 - _arg1.y);
var _local19:Number = ((planeNormal.x * _local15) + ((_local16 * linDrag) * (velocity.x - (_arg1.vx - (_arg1.w * _local18)))));
var _local20:Number = ((planeNormal.y * _local15) + ((_local16 * linDrag) * (velocity.y - (_arg1.vy + (_arg1.w * _local17)))));
_arg1.fx = (_arg1.fx + _local19);
_arg1.fy = (_arg1.fy + _local20);
_arg1.t = (_arg1.t + (((_local17 * _local20) - (_local18 * _local19)) + (((-(_local16) * angDrag) * ((_local5 - _local4) * (_local5 - _local4))) * _arg1.w)));
}
}
}//package de.polygonal.motor2.dynamics.forces
import de.polygonal.motor2.math.*;
class Plane2 {
public var d:Number;// = 0
public var n:V2;
private function Plane2(){
n = new V2();
super();
}
}
class ClipTriangle {
public var a:V2;
public var c:V2;
public var b:V2;
private function ClipTriangle(){
a = new V2();
b = new V2();
c = new V2();
super();
}
}
Section 115
//ForceGenerator (de.polygonal.motor2.dynamics.forces.ForceGenerator)
package de.polygonal.motor2.dynamics.forces {
import de.polygonal.motor2.dynamics.*;
public class ForceGenerator {
public var isActive:Boolean;
public function ForceGenerator(){
init();
}
public function evaluate(_arg1:RigidBody):void{
}
public function init():void{
isActive = true;
}
}
}//package de.polygonal.motor2.dynamics.forces
Section 116
//ForceRegistry (de.polygonal.motor2.dynamics.forces.ForceRegistry)
package de.polygonal.motor2.dynamics.forces {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.*;
import de.polygonal.ds.*;
public class ForceRegistry {
private var _idQue:ArrayedQueue;
private var _registration:ForceNode;
public function ForceRegistry(){
init();
}
public function init():void{
_registration = null;
var _local1:int = Constants.k_maxForceGenerators;
_idQue = new ArrayedQueue(_local1);
var _local2:int;
while (_local2 < _local1) {
_idQue.enqueue(_local2);
_local2++;
};
}
public function add(_arg1:RigidBody, _arg2:ForceGenerator):int{
var _local3:int = _idQue.dequeue();
var _local4:ForceNode = new ForceNode(_arg1, _arg2);
_local4.next = _registration;
if (_registration){
_registration.prev = _local4;
};
_registration = _local4;
return (_local3);
}
public function remove(_arg1:RigidBody, _arg2:ForceGenerator):Boolean{
var _local3:ForceNode = _registration;
while (_local3) {
if ((((_local3.force == _arg2)) && ((_local3.body == _arg1)))){
if (_local3.prev){
_local3.prev.next = _local3.next;
};
if (_local3.next){
_local3.next.prev = _local3.prev;
};
if (_local3 == _registration){
_registration = _local3.next;
};
return (true);
};
_local3 = _local3.next;
};
return (false);
}
public function evaluate():void{
var _local2:ForceGenerator;
var _local1:ForceNode = _registration;
while (_local1) {
_local2 = _local1.force;
if (_local2.isActive){
_local2.evaluate(_local1.body);
};
_local1 = _local1.next;
};
}
public function clear():void{
var _local2:ForceNode;
var _local1:ForceNode = _registration;
_registration = null;
while (_local1) {
_local2 = _local1.next;
_local1.next = (_local1.prev = null);
_local1 = _local2;
};
}
}
}//package de.polygonal.motor2.dynamics.forces
import de.polygonal.motor2.dynamics.*;
class ForceNode {
public var body:RigidBody;
public var prev:ForceNode;
public var next:ForceNode;
public var force:ForceGenerator;
private function ForceNode(_arg1:RigidBody, _arg2:ForceGenerator){
this.body = _arg1;
this.force = _arg2;
init();
}
public function init():void{
prev = (next = null);
}
}
Section 117
//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 118
//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 lowerAngle:Number;
public var referenceAngle:Number;
public var upperAngle:Number;
public var enableMotor:Boolean;
public var motorSpeed:Number;
public var maxMotorTorque:Number;
public var enableLimit:Boolean;
public function RevoluteJointData(_arg1:RigidBody, _arg2:RigidBody, _arg3: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;
var _local4:Point = 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 protected function setType():void{
type = JointTypes.REVOLUTE;
}
override public function getJointClass():Class{
return (RevoluteJoint);
}
}
}//package de.polygonal.motor2.dynamics.joints.data
Section 119
//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 preparePosSolver():void{
}
public function getReactionForce():Point{
return (null);
}
public function getAnchor2():Point{
_anchor2.x = ((body2.x + (body2.r11 * la2x)) + (body2.r12 * la2y));
_anchor2.y = ((body2.y + (body2.r21 * la2x)) + (body2.r22 * la2y));
return (_anchor2);
}
public function getReactionTorque():Number{
return (0);
}
public function solveVelConstraints(_arg1:Number, _arg2:int):void{
}
public function solvePosConstraints():Boolean{
return (true);
}
protected function setType(_arg1:int):void{
this.type = _arg1;
}
public function preStep(_arg1:Number):void{
_dt = _arg1;
_invdt = (1 / _arg1);
}
public function getAnchor1():Point{
_anchor1.x = ((body1.x + (body1.r11 * la1x)) + (body1.r12 * la1y));
_anchor1.y = ((body1.y + (body1.r21 * la1x)) + (body1.r22 * la1y));
return (_anchor1);
}
}
}//package de.polygonal.motor2.dynamics.joints
Section 120
//JointNode (de.polygonal.motor2.dynamics.joints.JointNode)
package de.polygonal.motor2.dynamics.joints {
import de.polygonal.motor2.dynamics.*;
public class JointNode {
public var other:RigidBody;
public var next:JointNode;
public var prev:JointNode;
public var joint:Joint;
}
}//package de.polygonal.motor2.dynamics.joints
Section 121
//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 122
//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 123
//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 _motorMass:Number;
private var _k11:Number;
private var _k12:Number;
private var _k13:Number;
private var _r1x:Number;
private var _motorImpulse:Number;
private var _r1y:Number;
private var _k21:Number;
private var _k22:Number;
private var _k23:Number;
public var enableMotor:Boolean;
private var _limitState:int;
private var _r2x:Number;
private var _r2y:Number;
private var _k31:Number;
private var _k32:Number;
private var _k33:Number;
public var upperAngle:Number;
public var lowerAngle:Number;
public var motorSpeed:Number;
public var maxMotorTorque:Number;
private var _impulseX:Number;
private var _impulseY:Number;
private var _referenceAngle:Number;
private var _impulseZ:Number;
public var enableLimit:Boolean;
public function RevoluteJoint(_arg1:RevoluteJointData){
super(_arg1);
var _local2:RevoluteJointData = (_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 getReactionTorque():Number{
return ((_invdt * _impulseZ));
}
override public function preStep(_arg1:Number):void{
var _local8:Number;
var _local9:Number;
super.preStep(_arg1);
var _local2:RigidBody = body1;
var _local3:RigidBody = 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));
var _local4:Number = _local2.invMass;
var _local5:Number = _local2.invI;
var _local6:Number = _local3.invMass;
var _local7:Number = _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;
};
}
override public function getReactionForce():Point{
_reactionForce.x = (_impulseX * _invdt);
_reactionForce.y = (_impulseY * _invdt);
return (_reactionForce);
}
public function getMotorTorque():Number{
return (_motorImpulse);
}
public function setLimits(_arg1:Number, _arg2:Number):void{
if (_arg1 < _arg2){
lowerAngle = _arg1;
upperAngle = _arg2;
};
}
public function getJointSpeed():Number{
return ((body2.w - body1.w));
}
public function getJointAngle():Number{
return (((body2.r - body1.r) - _referenceAngle));
}
override public function solvePosConstraints():Boolean{
var _local20:Number;
var _local21:Number;
var _local22:Number;
var _local23:Number;
var _local1:RigidBody = body1;
var _local2:RigidBody = body2;
var _local3:Number = ((_local1.r11 * la1x) + (_local1.r12 * la1y));
var _local4:Number = ((_local1.r21 * la1x) + (_local1.r22 * la1y));
var _local5:Number = ((_local2.r11 * la2x) + (_local2.r12 * la2y));
var _local6:Number = ((_local2.r21 * la2x) + (_local2.r22 * la2y));
var _local7:Number = 0;
var _local8:Number = 0;
var _local9:Number = 0;
var _local10:Number = 0;
var _local11:Number = 0;
var _local12:Number = 0;
var _local13:Number = 0;
var _local14:Number = 0;
if (((enableLimit) && (!((_limitState == LimitState.INACTIVE))))){
_local20 = ((body2.r - body1.r) - _referenceAngle);
_local21 = 0;
if (_limitState == LimitState.EQUAL){
_local9 = ((_local20)<-(Constants.k_maxAngCorrection)) ? -(Constants.k_maxAngCorrection) : ((_local20)>Constants.k_maxAngCorrection) ? Constants.k_maxAngCorrection : _local20;
_local21 = (-(_motorMass) * _local9);
_local8 = ((_local9 > 0)) ? _local9 : -(_local9);
} else {
if (_limitState == LimitState.LOWER){
_local9 = (_local20 - lowerAngle);
_local8 = -(_local9);
_local12 = (_local9 + Constants.k_angSlop);
_local9 = ((_local12)<-(Constants.k_maxAngCorrection)) ? -(Constants.k_maxAngCorrection) : ((_local12)>0) ? 0 : _local12;
_local21 = (-(_motorMass) * _local9);
} else {
if (_limitState == LimitState.UPPER){
_local9 = (_local20 - upperAngle);
_local8 = _local9;
_local12 = (_local9 - Constants.k_angSlop);
_local9 = ((_local12)<0) ? 0 : ((_local12)>Constants.k_maxAngCorrection) ? Constants.k_maxAngCorrection : _local12;
_local21 = (-(_motorMass) * _local9);
};
};
};
body1.r = (body1.r - (body1.invI * _local21));
body2.r = (body2.r + (body2.invI * _local21));
};
_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)));
var _local15:Number = (10 * Constants.k_linSlop);
var _local16:Number = ((_local10 * _local10) + (_local11 * _local11));
if (_local16 > (_local15 * _local15)){
_local16 = (1 / Math.sqrt(_local16));
_local22 = (body1.invMass + body2.invMass);
if (_local22 > 1E-8){
_local23 = (1 / _local22);
} else {
throw (new Error("division by zero"));
};
_local13 = (-(_local23) * _local10);
_local14 = (-(_local23) * _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)));
var _local17:Number = ((_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))));
var _local18:Number = Math.sin(body1.r);
var _local19:Number = Math.cos(body1.r);
body1.r11 = _local19;
body1.r12 = -(_local18);
body1.r21 = _local18;
body1.r22 = _local19;
_local18 = Math.sin(body2.r);
_local19 = Math.cos(body2.r);
body2.r11 = _local19;
body2.r12 = -(_local18);
body2.r21 = _local18;
body2.r22 = _local19;
return ((((_local7 <= Constants.k_linSlop)) && ((_local8 <= Constants.k_angSlop))));
}
override public function solveVelConstraints(_arg1:Number, _arg2:int):void{
var _local16:Number;
var _local17:Number;
var _local18:Number;
var _local19:Number;
var _local20:Number;
var _local21:Number;
var _local3:Number = body1.vx;
var _local4:Number = body1.vy;
var _local5:Number = body2.vx;
var _local6:Number = body2.vy;
var _local7:Number = body1.w;
var _local8:Number = body2.w;
var _local9:RigidBody = body1;
var _local10:RigidBody = 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));
var _local11:Number = 0;
var _local12:Number = 0;
var _local13:Number = 0;
var _local14:Number = 0;
var _local15:Number = 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;
}
}
}//package de.polygonal.motor2.dynamics.joints
Section 124
//Island (de.polygonal.motor2.dynamics.Island)
package de.polygonal.motor2.dynamics {
import de.polygonal.motor2.*;
import de.polygonal.motor2.dynamics.contact.solver.*;
public class Island {
public var bodies:Array;
public var contactSolver:SIContactSolver;
public var jointCount:int;
public var joints:Array;
public var bodyCount:int;
public var positionError:Number;
public var contacts:Array;
public var contactCount:int;
public var bodyList:RigidBody;
public var positionIterations:int;
public function Island(){
bodyCount = 0;
contactCount = 0;
jointCount = 0;
bodyList = null;
bodies = new Array();
contacts = new Array();
joints = new Array();
contactSolver = new SIContactSolver();
}
public function solve(_arg1:Number, _arg2:Number, _arg3:int, _arg4:Number):void{
var _local5:int;
var _local6:int;
var _local7:RigidBody;
var _local8:Number;
var _local9:Number;
var _local10:Boolean;
var _local11:Boolean;
_local5 = 0;
while (_local5 < bodyCount) {
_local7 = bodies[_local5];
if (_local7.invMass == 0){
} else {
_local7.vx = ((_local7.vx + (_arg4 * (_arg1 + (_local7.invMass * _local7.fx)))) * _local7.linDamping);
_local7.vy = ((_local7.vy + (_arg4 * (_arg2 + (_local7.invMass * _local7.fy)))) * _local7.linDamping);
_local7.w = ((_local7.w + (_arg4 * (_local7.invI * _local7.t))) * _local7.angDamping);
};
_local5++;
};
contactSolver.setContacts(contacts, contactCount);
contactSolver.preStep();
_local6 = 0;
while (_local6 < jointCount) {
joints[_local6].preStep(_arg4);
_local6++;
};
_local5 = 0;
while (_local5 < _arg3) {
contactSolver.solveVelConstraints();
_local6 = 0;
while (_local6 < jointCount) {
joints[_local6].solveVelConstraints(_arg4, _arg3);
_local6++;
};
_local5++;
};
_local5 = 0;
while (_local5 < bodyCount) {
_local7 = bodies[_local5];
if (_local7.invMass == 0){
} else {
_local7.x = (_local7.x + (_arg4 * _local7.vx));
_local7.y = (_local7.y + (_arg4 * _local7.vy));
_local7.r = (_local7.r + (_arg4 * _local7.w));
_local9 = Math.cos(_local7.r);
_local8 = Math.sin(_local7.r);
_local7.r11 = _local9;
_local7.r12 = -(_local8);
_local7.r21 = _local8;
_local7.r22 = _local9;
};
_local5++;
};
if (World.doPositionCorrection){
_local5 = 0;
while (_local5 < _arg3) {
_local10 = contactSolver.solvePosConstraints(Constants.k_contactBaumgarte);
_local11 = true;
_local6 = 0;
while (_local6 < jointCount) {
_local11 = joints[_local6].solvePosConstraints();
_local11 = ((_local11) && (_local11));
_local6++;
};
if (((_local10) && (_local11))){
break;
};
_local5++;
};
};
}
public function updateSleep(_arg1:Number):void{
var _local5:RigidBody;
var _local6:int;
var _local2:Number = 2147483648;
var _local3:Number = Constants.k_linSleepToleranceSq;
var _local4:Number = Constants.k_angSleepToleranceSq;
_local6 = 0;
while (_local6 < bodyCount) {
_local5 = bodies[_local6];
if (_local5.invMass == 0){
} else {
if ((_local5.stateBits & RigidBody.k_bitAllowSleep) == 0){
_local5.sleepTime = 0;
_local2 = 0;
};
if (((((((_local5.stateBits & RigidBody.k_bitAllowSleep) == 0)) || (((_local5.w * _local5.w) > _local4)))) || ((((_local5.vx * _local5.vx) + (_local5.vy * _local5.vy)) > _local3)))){
_local5.sleepTime = 0;
_local2 = 0;
} else {
_local5.sleepTime = (_local5.sleepTime + _arg1);
_local2 = ((_local2 < _local5.sleepTime)) ? _local2 : _local5.sleepTime;
};
};
_local6++;
};
if (_local2 >= Constants.k_timeToSleep){
_local6 = 0;
while (_local6 < bodyCount) {
_local5 = bodies[_local6];
bodies[_local6].stateBits = (_local5.stateBits | RigidBody.k_bitSleep);
_local6++;
};
};
}
}
}//package de.polygonal.motor2.dynamics
Section 125
//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.joints.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.collision.nbody.*;
public class RigidBody {
public var r:Number;
public var invMass:Number;
public var world:World;
public var r12:Number;
public var userData;
public var r11:Number;
public var linDamping:Number;
public var r22:Number;
public var prev:RigidBody;
public var stateBits:int;
public var r21:Number;
public var vx:Number;
public var vy:Number;
public var sleepTime:Number;
public var angDamping:Number;
public var I:Number;
public var jointList:JointNode;
public var fx:Number;
public var fy:Number;
public var contactList:ContactNode;
public var shapeList:ShapeSkeleton;
public var next:RigidBody;
public var mass:Number;
public var cx:Number;
public var cy:Number;
public var x:Number;
public var y:Number;
public var t:Number;
public var shapeCount:int;
public var w:Number;
public var invI:Number;
public static const k_bitDestroy:int = 16;
public static const k_bitAllowSleep:int = 8;
public static const k_bitIsland:int = 32;
public static const k_bitStatic:int = 1;
public static const k_bitFrozen:int = 2;
public static const k_bitSleep:int = 4;
public function RigidBody(_arg1:World, _arg2:RigidBodyData){
init(_arg1, _arg2);
}
public function refreshProxy():void{
var _local1:ShapeSkeleton = shapeList;
while (_local1) {
_local1.refreshProxy();
_local1 = _local1.next;
};
}
public function getWorldDirection(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
if (_arg2){
_arg2.x = ((r11 * _arg1.x) + (r12 * _arg1.y));
_arg2.y = ((r21 * _arg1.x) + (r22 * _arg1.y));
} else {
_local3 = _arg1.x;
_arg1.x = ((r11 * _local3) + (r12 * _arg1.y));
_arg1.y = ((r21 * _local3) + (r22 * _arg1.y));
};
}
public function wakeUp():void{
stateBits = (stateBits & ~(k_bitSleep));
sleepTime = 0;
}
public function putToSleep():void{
stateBits = (stateBits | k_bitSleep);
sleepTime = 0;
vx = (vy = (w = (fx = (fy = (t = 0)))));
}
public function deconstruct():void{
var _local2:ShapeSkeleton;
prev = (next = null);
var _local1:ShapeSkeleton = shapeList;
while (_local1) {
_local2 = _local1;
_local1 = _local1.next;
_local2.deconstruct();
};
}
public function getWorldPoint(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
if (_arg2){
_arg2.x = (x + ((r11 * _arg1.x) + (r12 * _arg1.y)));
_arg2.y = (y + ((r21 * _arg1.x) + (r22 * _arg1.y)));
} else {
_local3 = _arg1.x;
_arg1.x = (x + ((r11 * _local3) + (r12 * _arg1.y)));
_arg1.y = (y + ((r21 * _local3) + (r22 * _arg1.y)));
};
}
public function applyTorque(_arg1:Number):void{
if ((stateBits & k_bitSleep) == 0){
t = (t + _arg1);
};
}
public function getOrigin(_arg1:V2):void{
_arg1.x = (x - ((r11 * cx) + (r12 * cy)));
_arg1.y = (y - ((r21 * cx) + (r22 * cy)));
}
public function applyForce(_arg1:Number, _arg2:Number):void{
if ((stateBits & k_bitSleep) == 0){
this.fx = (this.fx + _arg1);
this.fy = (this.fy + _arg2);
};
}
public function freeze():void{
stateBits = (stateBits | k_bitFrozen);
vx = (vy = (w = 0));
}
private function init(_arg1:World, _arg2:RigidBodyData):void{
var _local3:Number;
var _local4:Number;
var _local5:Number;
var _local6:Number;
var _local7:Number;
var _local8:ShapeData;
var _local9:ShapeSkeleton;
var _local10:Class;
this.world = _arg1;
x = _arg2.x;
y = _arg2.y;
r = _arg2.r;
_local3 = Math.cos(r);
_local4 = Math.sin(r);
r11 = _local3;
r12 = -(_local4);
r21 = _local4;
r22 = _local3;
vx = (vy = (w = 0));
fx = (fy = (t = 0));
mass = (invMass = (I = (invI = 0)));
cx = (cy = 0);
linDamping = (1 - _arg2.linDamping);
linDamping = ((linDamping)<0) ? 0 : ((linDamping)>1) ? 1 : linDamping;
angDamping = (1 - _arg2.angDamping);
angDamping = ((angDamping)<0) ? 0 : ((angDamping)>1) ? 1 : angDamping;
shapeCount = 0;
stateBits = 0;
sleepTime = 0;
if (_arg2.allowSleep){
stateBits = (stateBits | k_bitAllowSleep);
};
if (_arg2.isSleeping){
stateBits = (stateBits | k_bitSleep);
};
jointList = null;
contactList = null;
next = (prev = null);
_local8 = _arg2.shapeDataList;
while (_local8) {
_local5 = _local8.getMass();
mass = (mass + _local5);
cx = (cx + (_local5 * (_local8.mx + _local8.getCM().x)));
cy = (cy + (_local5 * (_local8.my + _local8.getCM().y)));
shapeCount++;
_local8 = _local8.next;
};
if (mass > 0){
cx = (cx / mass);
cy = (cy / mass);
x = (x + ((r11 * cx) + (r12 * cy)));
y = (y + ((r21 * cx) + (r22 * cy)));
} else {
stateBits = (stateBits | k_bitStatic);
};
if (!_arg2.preventRotation){
_local8 = _arg2.shapeDataList;
while (_local8) {
I = (I + _local8.getInertia());
_local6 = ((_local8.mx + _local8.getCM().x) - cx);
_local7 = ((_local8.my + _local8.getCM().y) - cy);
I = (I + (_local8.getMass() * ((_local6 * _local6) + (_local7 * _local7))));
_local8 = _local8.next;
};
if (I > 0){
invI = (1 / I);
};
};
invMass = ((mass)>0) ? (1 / mass) : 0;
if (((!(_arg2.isSleeping)) && ((invMass > 0)))){
vx = (_arg2.vx + (-(_arg2.w) * cy));
vy = (_arg2.vy + (_arg2.w * cy));
w = _arg2.w;
};
_local8 = _arg2.shapeDataList;
while (_local8) {
_local10 = _local8.getShapeClass();
_local9 = new _local10(_local8, this);
_local9.next = shapeList;
shapeList = _local9;
_local8 = _local8.next;
};
}
public function updateShapes(_arg1:Boolean=false):Boolean{
var _local2:Number = Math.cos(r);
var _local3:Number = Math.sin(r);
r11 = _local2;
r12 = -(_local3);
r21 = _local3;
r22 = _local2;
var _local4:Boolean;
var _local5:ShapeSkeleton = shapeList;
while (_local5) {
if (!_local5.update()){
_local4 = false;
break;
};
if (_arg1){
_local5.toWorldSpace();
};
_local5 = _local5.next;
};
if (!_local4){
freeze();
_local5 = shapeList;
while (_local5) {
if (_local5.proxyId != Proxy.NULL_PROXY){
world.getBroadPhase().destroyProxy(_local5.proxyId);
_local5.proxyId = Proxy.NULL_PROXY;
};
_local5 = _local5.next;
};
return (false);
};
return (true);
}
public function allowSleeping(_arg1:Boolean):void{
if (_arg1){
stateBits = (stateBits | k_bitAllowSleep);
} else {
stateBits = (stateBits & ~(k_bitAllowSleep));
wakeUp();
};
}
public function applyImpulse(_arg1:Number, _arg2:Number):void{
if ((stateBits & k_bitSleep) == 0){
vx = (vx + (invMass * _arg1));
vy = (vy + (invMass * _arg2));
};
}
public function setOrigin(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Number;
var _local5:Number;
var _local6:ShapeSkeleton;
if ((stateBits & k_bitFrozen) == 0){
r = _arg3;
_local4 = Math.cos(r);
_local5 = Math.sin(r);
r11 = _local4;
r12 = -(_local5);
r21 = _local5;
r22 = _local4;
this.x = (_arg1 + ((r11 * cx) + (r12 * cy)));
this.y = (_arg2 + ((r21 * cx) + (r22 * cy)));
_local6 = shapeList;
while (_local6) {
_local6.update();
_local6 = _local6.next;
};
};
}
public function isConnected(_arg1:RigidBody):Boolean{
var _local2:JointNode = jointList;
while (_local2) {
if (_local2.other == _arg1){
return ((_local2.joint.collideConnected == false));
};
_local2 = _local2.next;
};
return (false);
}
public function applyForceAt(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
if ((stateBits & k_bitSleep) == 0){
this.fx = (this.fx + _arg1);
this.fy = (this.fy + _arg2);
t = (t + (((_arg3 - x) * _arg2) - ((_arg4 - y) * _arg1)));
};
}
public function isStatic():Boolean{
return (((stateBits & k_bitStatic) == k_bitStatic));
}
public function applyImpulseAt(_arg1:Number, _arg2:Number, _arg3:Number, _arg4:Number):void{
if ((stateBits & k_bitSleep) == 0){
vx = (vx + (invMass * _arg1));
vy = (vy + (invMass * _arg2));
w = (w + (((invI * (_arg3 - x)) * _arg2) - ((invI * (_arg4 - y)) * _arg1)));
};
}
public function getModelDirection(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
if (_arg2){
_arg2.x = ((r11 * _arg1.x) + (r21 * _arg1.y));
_arg2.y = ((r12 * _arg1.x) + (r22 * _arg1.y));
} else {
_local3 = _arg1.x;
_arg1.x = ((r11 * _local3) + (r21 * _arg1.y));
_arg1.y = ((r12 * _local3) + (r22 * _arg1.y));
};
}
public function setCenter(_arg1:Number, _arg2:Number, _arg3:Number):void{
var _local4:Number;
var _local5:Number;
var _local6:ShapeSkeleton;
if ((stateBits & k_bitFrozen) == 0){
r = _arg3;
_local4 = Math.cos(r);
_local5 = Math.sin(r);
r11 = _local4;
r12 = -(_local5);
r21 = _local5;
r22 = _local4;
this.x = _arg1;
this.y = _arg2;
_local6 = shapeList;
while (_local6) {
_local6.update();
_local6 = _local6.next;
};
};
}
public function getCenter(_arg1:V2):void{
_arg1.x = x;
_arg1.y = y;
}
public function rotate(_arg1:Number):void{
if (_arg1 < 0){
_arg1 = (_arg1 + 360);
} else {
if (_arg1 > 360){
_arg1 = (_arg1 - 360);
};
};
r = (_arg1 * (Math.PI / 180));
updateShapes();
}
public function getModelPoint(_arg1:Point, _arg2:Point=null):void{
var _local3:Number;
if (_arg2){
_arg2.x = ((r11 * (_arg1.x - x)) + (r21 * (_arg1.y - y)));
_arg2.y = ((r12 * (_arg1.x - x)) + (r22 * (_arg1.y - y)));
} else {
_local3 = _arg1.x;
_arg1.x = ((r11 * (_local3 - x)) + (r21 * (_arg1.y - y)));
_arg1.y = ((r12 * (_local3 - x)) + (r22 * (_arg1.y - y)));
};
}
public function isFrozen():Boolean{
return (((stateBits & k_bitFrozen) == k_bitFrozen));
}
public function isSleeping():Boolean{
return (((stateBits & k_bitSleep) == k_bitSleep));
}
}
}//package de.polygonal.motor2.dynamics
Section 126
//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 127
//AABB2 (de.polygonal.motor2.math.AABB2)
package de.polygonal.motor2.math {
public class AABB2 {
public var ymax:Number;
public var xmax:Number;
public var ymin:Number;
public var xmin:Number;
public function AABB2(_arg1:Number=1.79769313486232E308, _arg2:Number=1.79769313486232E308, _arg3:Number=4.94065645841247E-324, _arg4:Number=4.94065645841247E-324){
this.xmin = _arg1;
this.ymin = _arg2;
this.xmax = _arg3;
this.ymax = _arg4;
}
public function isEmpty():Boolean{
return ((((xmin > xmax)) || ((ymin > ymax))));
}
public function empty():void{
xmin = (ymin = 2147483647);
xmax = (ymax = -2147483648);
}
public function addPoint(_arg1:Number, _arg2:Number):void{
if (_arg1 < xmin){
xmin = _arg1;
};
if (_arg1 > xmax){
xmax = _arg1;
};
if (_arg2 < ymin){
ymin = _arg2;
};
if (_arg2 > ymax){
ymax = _arg2;
};
}
public function copy():AABB2{
return (new AABB2(xmin, ymin, xmax, ymax));
}
}
}//package de.polygonal.motor2.math
Section 128
//Circle2 (de.polygonal.motor2.math.Circle2)
package de.polygonal.motor2.math {
import flash.geom.*;
public class Circle2 {
public const c:Point;
public var radius:Number;
public function Circle2(_arg1:Number, _arg2:Number, _arg3:Number){
c = new Point();
super();
c.x = _arg1;
c.y = _arg2;
radius = _arg3;
}
public function copy():Circle2{
return (new Circle2(c.x, c.y, radius));
}
}
}//package de.polygonal.motor2.math
Section 129
//ConvexBSPNode (de.polygonal.motor2.math.ConvexBSPNode)
package de.polygonal.motor2.math {
import de.polygonal.ds.*;
public class ConvexBSPNode extends BinaryTreeNode {
public var R:ConvexBSPNode;
public var V:V2;
public var I:int;
public var L:ConvexBSPNode;
public var N:V2;
public function ConvexBSPNode(){
super(null);
init();
}
private function init():void{
L = (R = null);
N = (V = null);
I = -1;
}
}
}//package de.polygonal.motor2.math
Section 130
//E2 (de.polygonal.motor2.math.E2)
package de.polygonal.motor2.math {
public class E2 {
public var mag:Number;// = 0
public var d:V2;
public var n:V2;
public var prev:E2;
public var v:V2;
public var w:V2;
public var next:E2;
}
}//package de.polygonal.motor2.math
Section 131
//Tri2 (de.polygonal.motor2.math.Tri2)
package de.polygonal.motor2.math {
public class Tri2 {
public var a:V2;
public var c:V2;
public var b:V2;
public var cm:V2;
public var area:Number;
public var next:Tri2;
public function Tri2(_arg1:V2, _arg2:V2, _arg3:V2){
this.a = _arg1;
this.b = _arg2;
this.c = _arg3;
area = ((((_arg2.x - _arg1.x) * (_arg3.y - _arg1.y)) - ((_arg2.y - _arg1.y) * (_arg3.x - _arg1.x))) / 2);
cm = new V2((((_arg1.x + _arg2.x) + _arg3.x) / 3), (((_arg1.y + _arg2.y) + _arg3.y) / 3));
}
}
}//package de.polygonal.motor2.math
Section 132
//V2 (de.polygonal.motor2.math.V2)
package de.polygonal.motor2.math {
import flash.geom.*;
public class V2 extends Point {
public var isTail:Boolean;
public var next:V2;
public var isHead:Boolean;
public var index:int;
public var prev:V2;
public var edge:E2;
public function V2(_arg1:Number=0, _arg2:Number=0){
super(_arg1, _arg2);
index = -1;
}
public function getAt(_arg1:int):V2{
var _local2:V2 = this;
while (_local2) {
if (_local2.index == _arg1){
return (_local2);
};
if (_local2.isTail){
break;
};
_local2 = _local2.next;
};
return (null);
}
override public function toString():String{
return ((((((((((("{V2, index=" + index) + ", head=") + int(isHead)) + ", tail=") + int(isTail)) + ", x=") + x.toFixed(2)) + ", y=") + y.toFixed(2)) + "}"));
}
public function copy():V2{
return (new V2(x, y));
}
public function deconstruct():void{
var _local2:V2;
var _local1:V2 = this;
while (_local1) {
_local2 = _local1.next;
_local1 = null;
_local1 = _local2;
};
}
public function toArray():Array{
var _local1:int = (index + 1);
var _local2:V2 = next;
while (!(_local2.isHead)) {
_local1++;
_local2 = _local2.next;
};
var _local3:Array = new Array(_local1, true);
_local2 = this;
var _local4:int;
while (_local4 < _local1) {
_local3[_local4] = _local2;
_local2 = _local2.next;
_local4++;
};
return (_local3);
}
}
}//package de.polygonal.motor2.math
Section 133
//Constants (de.polygonal.motor2.Constants)
package de.polygonal.motor2 {
public class Constants {
public static const k_timeUnitsPerSecond:Number = 1;
public static const k_angSleepTolerance:Number = 0;
public static const k_maxManifoldPoints:int = 2;
public static const k_minLineAABBThickness:Number = 20;
public static const k_linSleepToleranceSq:Number = 0.25;
public static const k_linSleepTolerance:Number = 0.5;
public static const k_linSlopSq:Number = 0.0625;
public static const k_linSlop:Number = 0.25;
public static const k_angSleepToleranceSq:Number = 0;
public static const k_maxForceGenerators:int = (1 << 9);
public static const k_maxShapesPerBody:int = 64;
public static const k_maxLinCorrection:Number = 10;
public static const k_angSlop:Number = 0;
public static const k_lengthUnitsPerMeter:Number = 50;
public static const k_invalid:int = 4095;
public static const k_maxPolyVertices:int = 8;
public static const k_contactBaumgarte:Number = 0.2;
public static const k_maxAngCorrection:Number = 0.139626340159546;
public static const k_maxPairs:int = (k_maxProxies << 3);
public static const k_maxProxies:int = (1 << 9);
public static const k_massUnitsPerKilogram:Number = 1;
public static const k_velocityThreshold:Number = 50;
public static const k_timeToSleep:Number = 0.5;
}
}//package de.polygonal.motor2
Section 134
//ContactCallback (de.polygonal.motor2.ContactCallback)
package de.polygonal.motor2 {
import de.polygonal.motor2.dynamics.contact.*;
public interface ContactCallback {
function onContactRemoved(_arg1:Contact):void;
function onContactAdded(_arg1:Contact):void;
}
}//package de.polygonal.motor2
Section 135
//World (de.polygonal.motor2.World)
package de.polygonal.motor2 {
import flash.events.*;
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.shapes.*;
import de.polygonal.motor2.dynamics.joints.*;
import de.polygonal.motor2.dynamics.contact.*;
import de.polygonal.motor2.collision.nbody.*;
import de.polygonal.motor2.dynamics.joints.data.*;
import de.polygonal.motor2.dynamics.forces.*;
public class World extends EventDispatcher {
public var doSleep:Boolean;
private var _shapeCount:int;
private var _bodyCount:int;
private var _contactManager:ContactManager;
private var _callback:WorldCallback;
private var _worldBounds:AABB2;
private var _island:Island;
public var bodyDestroyList:RigidBody;
private var _broadPhase:BroadPhase;
private var _jointCount:int;
public var jointList:Joint;
private var _forceRegistry:ForceRegistry;
public var gravity:Point;
public var contactCount:int;
public var contactList:Contact;
public var bodyList:RigidBody;
private var _groundBody:RigidBody;
public static var doWarmStarting:Boolean = true;
public static var doPositionCorrection:Boolean = true;
public static var stats_timeSimStep:int = 0;
public static var stats_SepAxisQueryCount:int = 0;
public function World(_arg1:AABB2, _arg2:Boolean=true){
if (_arg1.isEmpty()){
throw (new Error("invalid world bounds"));
};
_worldBounds = _arg1.copy();
_worldBounds.xmin = int(_worldBounds.xmin);
_worldBounds.ymin = int(_worldBounds.ymin);
_worldBounds.xmax = int(_worldBounds.xmax);
_worldBounds.ymax = int(_worldBounds.ymax);
this.doSleep = _arg2;
setGravity(0, 100);
setCallback(new NullCallback());
_contactManager = new ContactManager(this);
_contactManager.setFilter(new ContactFilter());
_groundBody = new RigidBody(this, new RigidBodyData());
_forceRegistry = new ForceRegistry();
_island = new Island();
}
public function getBroadPhase():BroadPhase{
return (_broadPhase);
}
public function setGravity(_arg1:Number, _arg2:Number):void{
if (gravity == null){
gravity = new Point();
};
gravity.x = _arg1;
gravity.y = _arg2;
}
public function setBroadPhase(_arg1:BroadPhase):void{
var _local2:Array;
var _local3:ShapeSkeleton;
var _local4:int;
if (_bodyCount == 0){
_broadPhase = _arg1;
_broadPhase.setWorldBounds(_worldBounds);
_broadPhase.setPairHandler(_contactManager);
} else {
_local2 = getShapeList();
_local4 = 0;
while (_local4 < _local2.length) {
_local3 = _local2[_local4];
_broadPhase.destroyProxy(_local3.proxyId);
_local3.proxyId = Proxy.NULL_PROXY;
_local3.broadPhase = null;
_local4++;
};
_broadPhase.deconstruct();
_broadPhase = _arg1;
_broadPhase.setWorldBounds(_worldBounds);
_broadPhase.setPairHandler(_contactManager);
_local4 = 0;
while (_local4 < _local2.length) {
_local3 = _local2[_local4];
_local3.broadPhase = _broadPhase;
_local3.proxyId = _broadPhase.createProxy(_local3);
_local4++;
};
};
}
public function getShapeList():Array{
var _local1:Array = new Array(_shapeCount, true);
var _local2:int;
var _local3:RigidBody = bodyList;
if (_local3 == null){
return (_local1);
};
var _local4:ShapeSkeleton = _local3.shapeList;
while (true) {
if (_local4 != null){
var _temp1 = _local2;
_local2 = (_local2 + 1);
var _local5 = _temp1;
_local1[_local5] = _local4;
_local4 = _local4.next;
} else {
_local3 = _local3.next;
if (_local3 != null){
_local4 = _local3.shapeList;
var _temp2 = _local2;
_local2 = (_local2 + 1);
_local5 = _temp2;
_local1[_local5] = _local4;
_local4 = _local4.next;
} else {
break;
};
};
};
return (_local1);
}
public function destroyJoint(_arg1:Joint):void{
var _local5:RigidBody;
var _local6:ShapeSkeleton;
var _local2:Boolean = _arg1.collideConnected;
if (_arg1.prev){
_arg1.prev.next = _arg1.next;
};
if (_arg1.next){
_arg1.next.prev = _arg1.prev;
};
if (_arg1 == jointList){
jointList = _arg1.next;
};
var _local3:RigidBody = _arg1.body1;
var _local4:RigidBody = _arg1.body2;
_local3.wakeUp();
_local4.wakeUp();
if (_arg1.node1.prev){
_arg1.node1.prev.next = _arg1.node1.next;
};
if (_arg1.node1.next){
_arg1.node1.next.prev = _arg1.node1.prev;
};
if (_arg1.node1 == _local3.jointList){
_local3.jointList = _arg1.node1.next;
};
_arg1.node1.prev = null;
_arg1.node1.next = null;
if (_arg1.node2.prev){
_arg1.node2.prev.next = _arg1.node2.next;
};
if (_arg1.node2.next){
_arg1.node2.next.prev = _arg1.node2.prev;
};
if (_arg1.node2 == _local4.jointList){
_local4.jointList = _arg1.node2.next;
};
_arg1.node2.prev = null;
_arg1.node2.next = null;
_jointCount--;
if (!_local2){
_local5 = ((_local3.shapeCount < _local4.shapeCount)) ? _local3 : _local4;
_local6 = _local5.shapeList;
while (_local6) {
_local6.refreshProxy();
_local6 = _local6.next;
};
};
}
public function getWorldBounds():AABB2{
return (_worldBounds);
}
public function createBody(_arg1:RigidBodyData):RigidBody{
if (_broadPhase == null){
setBroadPhase(new ExhaustiveSearch());
};
var _local2:RigidBody = new RigidBody(this, _arg1);
_local2.next = bodyList;
if (bodyList){
bodyList.prev = _local2;
};
bodyList = _local2;
_bodyCount++;
var _local3:ShapeData = _arg1.shapeDataList;
while (_local3 != null) {
_shapeCount++;
_local3 = _local3.next;
};
return (_local2);
}
public function getGroundBody():RigidBody{
return (_groundBody);
}
public function setContactCallback(_arg1:ContactCallback):void{
_contactManager.setCallback(_arg1);
}
public function setCallback(_arg1:WorldCallback):void{
_callback = _arg1;
}
public function addForce(_arg1:RigidBody, _arg2:ForceGenerator):Boolean{
var _local3:ShapeSkeleton;
if (_arg1 == null){
return (false);
};
if ((_arg2 is Buoyancy)){
_local3 = _arg1.shapeList;
while (_local3) {
_local3.triangulate();
_local3 = _local3.next;
};
};
_forceRegistry.add(_arg1, _arg2);
return (true);
}
public function destroyBody(_arg1:RigidBody):Boolean{
var _local3:JointNode;
var _local5:ShapeSkeleton;
if (_bodyCount == 0){
return (false);
};
if ((_arg1.stateBits & RigidBody.k_bitDestroy)){
return (false);
};
var _local2:JointNode = _arg1.jointList;
while (_local2) {
_local3 = _local2;
_local2 = _local2.next;
_callback.onJointDestroyed(_local3.joint);
destroyJoint(_local3.joint);
};
var _local4:ShapeSkeleton = _arg1.shapeList;
while (_local4) {
_local5 = _local4;
_local4 = _local4.next;
_shapeCount--;
_callback.onShapeDestroyed(_local5);
};
if (_arg1.prev){
_arg1.prev.next = _arg1.next;
};
if (_arg1.next){
_arg1.next.prev = _arg1.prev;
};
if (_arg1 == bodyList){
bodyList = _arg1.next;
};
_arg1.stateBits = (_arg1.stateBits | RigidBody.k_bitDestroy);
if (_bodyCount > 0){
_bodyCount--;
};
_arg1.deconstruct();
_callback.onBodyDestroyed(_arg1);
return (true);
}
public function step(_arg1:Number, _arg2:int):void{
var _local3:RigidBody;
var _local4:Contact;
var _local5:Joint;
var _local6:int;
var _local8:int;
var _local9:RigidBody;
var _local10:ContactNode;
var _local11:JointNode;
var _local12:RigidBody;
var _local14:Joint;
_contactManager.collide();
_forceRegistry.evaluate();
_local3 = bodyList;
while (_local3) {
_local3.stateBits = (_local3.stateBits & ~(32));
_local3 = _local3.next;
};
_local4 = contactList;
while (_local4) {
_local4.stateBits = (_local4.stateBits & ~(Contact.k_bitIsland));
_local4 = _local4.next;
};
_local5 = jointList;
while (_local5) {
_local5.stateBits = (_local5.stateBits & ~(32));
_local5 = _local5.next;
};
var _local7:Array = [];
var _local13 = (((RigidBody.k_bitStatic | RigidBody.k_bitSleep) | RigidBody.k_bitFrozen) | RigidBody.k_bitIsland);
_local12 = bodyList;
while (_local12 != null) {
if ((_local12.stateBits & _local13)){
} else {
_island.bodyCount = 0;
_island.contactCount = 0;
_island.jointCount = 0;
_local7[0] = _local12;
_local8 = 1;
_local12.stateBits = (_local12.stateBits | 32);
while (_local8 > 0) {
--_local8;
_local3 = _local7[_local8];
_island.bodies[int(_island.bodyCount++)] = _local3;
_local3.stateBits = (_local3.stateBits & ~(RigidBody.k_bitSleep));
if ((_local3.stateBits & RigidBody.k_bitStatic)){
} else {
_local10 = _local3.contactList;
while (_local10) {
if ((_local10.contact.stateBits & Contact.k_bitIsland)){
} else {
_island.contacts[int(_island.contactCount++)] = _local10.contact;
_local10.contact.stateBits = (_local10.contact.stateBits | Contact.k_bitIsland);
_local9 = _local10.other;
if ((_local9.stateBits & 32)){
} else {
var _temp1 = _local8;
_local8 = (_local8 + 1);
var _local15 = _temp1;
_local7[_local15] = _local9;
_local9.stateBits = (_local9.stateBits | 32);
};
};
_local10 = _local10.next;
};
_local11 = _local3.jointList;
while (_local11) {
_local14 = _local11.joint;
if ((_local14.stateBits & 32)){
} else {
_island.joints[int(_island.jointCount++)] = _local14;
_local14.stateBits = (_local14.stateBits | 32);
_local9 = _local11.other;
if ((_local9.stateBits & 32)){
} else {
var _temp2 = _local8;
_local8 = (_local8 + 1);
_local15 = _temp2;
_local7[_local15] = _local9;
_local9.stateBits = (_local9.stateBits | 32);
};
};
_local11 = _local11.next;
};
};
};
_island.solve(gravity.x, gravity.y, _arg2, _arg1);
if (doSleep){
_island.updateSleep(_arg1);
};
_local6 = 0;
while (_local6 < _island.bodyCount) {
_local3 = _island.bodies[_local6];
if ((_local3.stateBits & RigidBody.k_bitStatic)){
_local3.stateBits = (_local3.stateBits & ~(32));
};
_local6++;
};
};
_local12 = _local12.next;
};
_local13 = (_local13 & ~(RigidBody.k_bitIsland));
_local3 = bodyList;
while (_local3 != null) {
if ((_local3.stateBits & _local13) > 0){
_local3 = _local3.next;
} else {
_local3.fx = (_local3.fy = (_local3.t = 0));
if (!_local3.updateShapes()){
_callback.onBodyLeftWorld(_local3);
};
_local3 = _local3.next;
};
};
_broadPhase.findPairs();
}
public function getBodyList():Array{
var _local1:Array = new Array(_bodyCount, true);
var _local2:int;
var _local3:RigidBody = bodyList;
if (_local3 == null){
return (_local1);
};
while (_local3 != null) {
var _temp1 = _local2;
_local2 = (_local2 + 1);
var _local4 = _temp1;
_local1[_local4] = _local3;
_local3 = _local3.next;
};
return (_local1);
}
public function removeForce(_arg1:RigidBody, _arg2:ForceGenerator):Boolean{
return (_forceRegistry.remove(_arg1, _arg2));
}
public function getShapeCount():int{
return (_shapeCount);
}
public function getBodyCount():int{
return (_bodyCount);
}
public function createJoint(_arg1:JointData):Joint{
var _local4:RigidBody;
var _local5:ShapeSkeleton;
var _local2:Class = _arg1.getJointClass();
var _local3:Joint = (new _local2(_arg1) as Joint);
_local3.prev = null;
_local3.next = jointList;
if (jointList){
jointList.prev = _local3;
};
jointList = _local3;
_jointCount++;
_local3.node1.joint = _local3;
_local3.node1.other = _local3.body2;
_local3.node1.prev = null;
_local3.node1.next = _local3.body1.jointList;
if (_local3.body1.jointList){
_local3.body1.jointList.prev = _local3.node1;
};
_local3.body1.jointList = _local3.node1;
_local3.node2.joint = _local3;
_local3.node2.other = _local3.body1;
_local3.node2.prev = null;
_local3.node2.next = _local3.body2.jointList;
if (_local3.body2.jointList){
_local3.body2.jointList.prev = _local3.node2;
};
_local3.body2.jointList = _local3.node2;
if (!_arg1.collideConnected){
_local4 = ((_arg1.body1.shapeCount < _arg1.body2.shapeCount)) ? _arg1.body1 : _arg1.body2;
_local5 = _local4.shapeList;
while (_local5) {
_local5.refreshProxy();
_local5 = _local5.next;
};
};
return (_local3);
}
public function setContactFilter(_arg1:ContactFilter):void{
_contactManager.setFilter(_arg1);
}
public function deconstruct():void{
destroyBody(_groundBody);
_broadPhase = null;
}
}
}//package de.polygonal.motor2
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.joints.*;
class NullCallback implements WorldCallback {
private function NullCallback(){
}
public function onBodyLeftWorld(_arg1:RigidBody):void{
}
public function onJointDestroyed(_arg1:Joint):void{
}
public function onBodyDestroyed(_arg1:RigidBody):void{
}
public function onShapeDestroyed(_arg1:ShapeSkeleton):void{
}
}
Section 136
//WorldCallback (de.polygonal.motor2.WorldCallback)
package de.polygonal.motor2 {
import de.polygonal.motor2.dynamics.*;
import de.polygonal.motor2.collision.shapes.*;
import de.polygonal.motor2.dynamics.joints.*;
public interface WorldCallback {
function onBodyDestroyed(_arg1:RigidBody):void;
function onBodyLeftWorld(_arg1:RigidBody):void;
function onJointDestroyed(_arg1:Joint):void;
function onShapeDestroyed(_arg1:ShapeSkeleton):void;
}
}//package de.polygonal.motor2
Section 137
//ByteArrayAsset (mx.core.ByteArrayAsset)
package mx.core {
import flash.utils.*;
public class ByteArrayAsset extends ByteArray implements IFlexAsset {
mx_internal static const VERSION:String = "3.2.0.3958";
}
}//package mx.core
Section 138
//IFlexAsset (mx.core.IFlexAsset)
package mx.core {
public interface IFlexAsset {
}
}//package mx.core
Section 139
//mx_internal (mx.core.mx_internal)
package mx.core {
public namespace mx_internal = "http://www.adobe.com/2006/flex/mx/internal";
}//package mx.core
Section 140
//Veronicas (Veronicas)
package {
import flash.display.*;
import com.kerb.veronicas.*;
public class Veronicas extends Sprite {
private var _ensureDocumentClassIsCompiledIntoSWF:Veronicas;
}
}//package