mirror of
https://github.com/MapMakersAndProgrammers/TankiOnline2.0DemoClient.git
synced 2025-10-26 01:49:11 -07:00
Deobfuscate remaining packages
This commit is contained in:
@@ -292,7 +292,7 @@ package alternativa.physics
|
|||||||
this.§_-nX§.copy(this.invInertia).append(this.baseMatrix).prependTransposed(this.baseMatrix);
|
this.§_-nX§.copy(this.invInertia).append(this.baseMatrix).prependTransposed(this.baseMatrix);
|
||||||
if(this.collisionPrimitives != null)
|
if(this.collisionPrimitives != null)
|
||||||
{
|
{
|
||||||
this.aabb.§_-GT§();
|
this.aabb.infinity();
|
||||||
for(item = this.collisionPrimitives.head; item != null; )
|
for(item = this.collisionPrimitives.head; item != null; )
|
||||||
{
|
{
|
||||||
primitive = item.primitive;
|
primitive = item.primitive;
|
||||||
@@ -302,7 +302,7 @@ package alternativa.physics
|
|||||||
primitive.transform.prepend(primitive.localTransform);
|
primitive.transform.prepend(primitive.localTransform);
|
||||||
}
|
}
|
||||||
primitive.calculateAABB();
|
primitive.calculateAABB();
|
||||||
this.aabb.§_-EH§(primitive.aabb);
|
this.aabb.addBoundBox(primitive.aabb);
|
||||||
item = item.next;
|
item = item.next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package alternativa.physics
|
|||||||
import alternativa.math.Matrix3;
|
import alternativa.math.Matrix3;
|
||||||
import alternativa.math.Vector3;
|
import alternativa.math.Vector3;
|
||||||
import alternativa.physics.collision.ICollisionDetector;
|
import alternativa.physics.collision.ICollisionDetector;
|
||||||
import alternativa.physics.collision.§_-LG§;
|
import alternativa.physics.collision.KdTreeCollisionDetector;
|
||||||
import alternativa.physics.constraints.Constraint;
|
import alternativa.physics.constraints.Constraint;
|
||||||
|
|
||||||
public class PhysicsScene
|
public class PhysicsScene
|
||||||
@@ -64,7 +64,7 @@ package alternativa.physics
|
|||||||
contact.next = new Contact(i);
|
contact.next = new Contact(i);
|
||||||
contact = contact.next;
|
contact = contact.next;
|
||||||
}
|
}
|
||||||
this.collisionDetector = new §_-LG§();
|
this.collisionDetector = new KdTreeCollisionDetector();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get gravity() : Vector3
|
public function get gravity() : Vector3
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package §_-1e§
|
package alternativa.physics.collision
|
||||||
{
|
{
|
||||||
import §_-KA§.§_-FW§;
|
import alternativa.physics.collision.types.BoundBox;
|
||||||
|
|
||||||
public class §_-D-§
|
public class CollisionKdTree
|
||||||
{
|
{
|
||||||
private static const nodeBoundBoxThreshold:§_-FW§ = new §_-FW§();
|
private static const nodeBoundBoxThreshold:BoundBox = new BoundBox();
|
||||||
|
|
||||||
private static const splitCoordsX:Vector.<Number> = new Vector.<Number>();
|
private static const splitCoordsX:Vector.<Number> = new Vector.<Number>();
|
||||||
|
|
||||||
@@ -20,13 +20,13 @@ package §_-1e§
|
|||||||
|
|
||||||
public var §_-eV§:int = 1;
|
public var §_-eV§:int = 1;
|
||||||
|
|
||||||
public var §_-5H§:§_-oZ§;
|
public var §_-5H§:CollisionKdNode;
|
||||||
|
|
||||||
public var §_-8A§:Vector.<§_-Nh§>;
|
public var §_-8A§:Vector.<CollisionPrimitive>;
|
||||||
|
|
||||||
public var §_-TO§:int;
|
public var §_-TO§:int;
|
||||||
|
|
||||||
public var staticBoundBoxes:Vector.<§_-FW§> = new Vector.<§_-FW§>();
|
public var staticBoundBoxes:Vector.<BoundBox> = new Vector.<BoundBox>();
|
||||||
|
|
||||||
private var §_-94§:int;
|
private var §_-94§:int;
|
||||||
|
|
||||||
@@ -34,25 +34,25 @@ package §_-1e§
|
|||||||
|
|
||||||
private var §_-ou§:Number;
|
private var §_-ou§:Number;
|
||||||
|
|
||||||
public function §_-D-§()
|
public function CollisionKdTree()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-J9§(collisionPrimitives:Vector.<§_-Nh§>, boundBox:§_-FW§ = null) : void
|
public function createTree(collisionPrimitives:Vector.<CollisionPrimitive>, boundBox:BoundBox = null) : void
|
||||||
{
|
{
|
||||||
var child:§_-Nh§ = null;
|
var child:CollisionPrimitive = null;
|
||||||
var childBoundBox:§_-FW§ = null;
|
var childBoundBox:BoundBox = null;
|
||||||
this.§_-8A§ = collisionPrimitives.concat();
|
this.§_-8A§ = collisionPrimitives.concat();
|
||||||
this.§_-TO§ = this.§_-8A§.length;
|
this.§_-TO§ = this.§_-8A§.length;
|
||||||
this.§_-5H§ = new §_-oZ§();
|
this.§_-5H§ = new CollisionKdNode();
|
||||||
this.§_-5H§.indices = new Vector.<int>();
|
this.§_-5H§.indices = new Vector.<int>();
|
||||||
var rootNodeBoundBox:§_-FW§ = this.§_-5H§.boundBox = boundBox != null ? boundBox : new §_-FW§();
|
var rootNodeBoundBox:BoundBox = this.§_-5H§.boundBox = boundBox != null ? boundBox : new BoundBox();
|
||||||
for(var i:int = 0; i < this.§_-TO§; i++)
|
for(var i:int = 0; i < this.§_-TO§; i++)
|
||||||
{
|
{
|
||||||
child = this.§_-8A§[i];
|
child = this.§_-8A§[i];
|
||||||
childBoundBox = this.staticBoundBoxes[i] = child.calculateAABB();
|
childBoundBox = this.staticBoundBoxes[i] = child.calculateAABB();
|
||||||
rootNodeBoundBox.§_-EH§(childBoundBox);
|
rootNodeBoundBox.addBoundBox(childBoundBox);
|
||||||
this.§_-5H§.indices[i] = i;
|
this.§_-5H§.indices[i] = i;
|
||||||
}
|
}
|
||||||
this.staticBoundBoxes.length = this.§_-TO§;
|
this.staticBoundBoxes.length = this.§_-TO§;
|
||||||
@@ -60,12 +60,12 @@ package §_-1e§
|
|||||||
splitCoordsX.length = splitCoordsY.length = splitCoordsZ.length = 0;
|
splitCoordsX.length = splitCoordsY.length = splitCoordsZ.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function splitNode(node:§_-oZ§) : void
|
private function splitNode(node:CollisionKdNode) : void
|
||||||
{
|
{
|
||||||
var nodeBoundBox:§_-FW§ = null;
|
var nodeBoundBox:BoundBox = null;
|
||||||
var i:int = 0;
|
var i:int = 0;
|
||||||
var j:int = 0;
|
var j:int = 0;
|
||||||
var boundBox:§_-FW§ = null;
|
var boundBox:BoundBox = null;
|
||||||
var min:Number = NaN;
|
var min:Number = NaN;
|
||||||
var max:Number = NaN;
|
var max:Number = NaN;
|
||||||
var indices:Vector.<int> = node.indices;
|
var indices:Vector.<int> = node.indices;
|
||||||
@@ -191,9 +191,9 @@ package §_-1e§
|
|||||||
_nodeBB[3] = nodeBoundBox.maxX;
|
_nodeBB[3] = nodeBoundBox.maxX;
|
||||||
_nodeBB[4] = nodeBoundBox.maxY;
|
_nodeBB[4] = nodeBoundBox.maxY;
|
||||||
_nodeBB[5] = nodeBoundBox.maxZ;
|
_nodeBB[5] = nodeBoundBox.maxZ;
|
||||||
this.§_-1k§(node,0,numSplitCoordsX,splitCoordsX,_nodeBB);
|
this.checkNodeAxis(node,0,numSplitCoordsX,splitCoordsX,_nodeBB);
|
||||||
this.§_-1k§(node,1,numSplitCoordsY,splitCoordsY,_nodeBB);
|
this.checkNodeAxis(node,1,numSplitCoordsY,splitCoordsY,_nodeBB);
|
||||||
this.§_-1k§(node,2,numSplitCoordsZ,splitCoordsZ,_nodeBB);
|
this.checkNodeAxis(node,2,numSplitCoordsZ,splitCoordsZ,_nodeBB);
|
||||||
if(this.§_-94§ < 0)
|
if(this.§_-94§ < 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@@ -202,10 +202,10 @@ package §_-1e§
|
|||||||
var axisY:Boolean = this.§_-94§ == 1;
|
var axisY:Boolean = this.§_-94§ == 1;
|
||||||
node.axis = this.§_-94§;
|
node.axis = this.§_-94§;
|
||||||
node.coord = this.§_-P5§;
|
node.coord = this.§_-P5§;
|
||||||
node.§_-Gm§ = new §_-oZ§();
|
node.§_-Gm§ = new CollisionKdNode();
|
||||||
node.§_-Gm§.parent = node;
|
node.§_-Gm§.parent = node;
|
||||||
node.§_-Gm§.boundBox = nodeBoundBox.clone();
|
node.§_-Gm§.boundBox = nodeBoundBox.clone();
|
||||||
node.§_-75§ = new §_-oZ§();
|
node.§_-75§ = new CollisionKdNode();
|
||||||
node.§_-75§.parent = node;
|
node.§_-75§.parent = node;
|
||||||
node.§_-75§.boundBox = nodeBoundBox.clone();
|
node.§_-75§.boundBox = nodeBoundBox.clone();
|
||||||
if(axisX)
|
if(axisX)
|
||||||
@@ -279,7 +279,7 @@ package §_-1e§
|
|||||||
if(node.§_-Xt§ != null)
|
if(node.§_-Xt§ != null)
|
||||||
{
|
{
|
||||||
node.§_-da§ = new CollisionKdTree2D(this,node);
|
node.§_-da§ = new CollisionKdTree2D(this,node);
|
||||||
node.§_-da§.§_-J9§();
|
node.§_-da§.createTree();
|
||||||
}
|
}
|
||||||
if(node.§_-Gm§.indices != null)
|
if(node.§_-Gm§.indices != null)
|
||||||
{
|
{
|
||||||
@@ -291,7 +291,7 @@ package §_-1e§
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-1k§(node:§_-oZ§, axis:int, numSplitCoords:int, splitCoords:Vector.<Number>, bb:Vector.<Number>) : void
|
private function checkNodeAxis(node:CollisionKdNode, axis:int, numSplitCoords:int, splitCoords:Vector.<Number>, bb:Vector.<Number>) : void
|
||||||
{
|
{
|
||||||
var currSplitCoord:Number = NaN;
|
var currSplitCoord:Number = NaN;
|
||||||
var minCoord:Number = NaN;
|
var minCoord:Number = NaN;
|
||||||
@@ -304,7 +304,7 @@ package §_-1e§
|
|||||||
var numObjects:int = 0;
|
var numObjects:int = 0;
|
||||||
var j:int = 0;
|
var j:int = 0;
|
||||||
var cost:Number = NaN;
|
var cost:Number = NaN;
|
||||||
var boundBox:§_-FW§ = null;
|
var boundBox:BoundBox = null;
|
||||||
var axis1:int = (axis + 1) % 3;
|
var axis1:int = (axis + 1) % 3;
|
||||||
var axis2:int = (axis + 2) % 3;
|
var axis2:int = (axis + 2) % 3;
|
||||||
var area:Number = (bb[axis1 + 3] - bb[axis1]) * (bb[axis2 + 3] - bb[axis2]);
|
var area:Number = (bb[axis1 + 3] - bb[axis1]) * (bb[axis2 + 3] - bb[axis2]);
|
||||||
@@ -370,20 +370,20 @@ package §_-1e§
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-YO§() : void
|
public function traceTree() : void
|
||||||
{
|
{
|
||||||
this.§_-es§("",this.§_-5H§);
|
this.traceNode("",this.§_-5H§);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-es§(str:String, node:§_-oZ§) : void
|
private function traceNode(str:String, node:CollisionKdNode) : void
|
||||||
{
|
{
|
||||||
if(node == null)
|
if(node == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
trace(str,node.axis == -1 ? "end" : (node.axis == 0 ? "X" : (node.axis == 1 ? "Y" : "Z")),"splitCoord=" + this.§_-P5§,"bound",node.boundBox,"objs:",node.indices);
|
trace(str,node.axis == -1 ? "end" : (node.axis == 0 ? "X" : (node.axis == 1 ? "Y" : "Z")),"splitCoord=" + this.§_-P5§,"bound",node.boundBox,"objs:",node.indices);
|
||||||
this.§_-es§(str + "-",node.§_-Gm§);
|
this.traceNode(str + "-",node.§_-Gm§);
|
||||||
this.§_-es§(str + "+",node.§_-75§);
|
this.traceNode(str + "+",node.§_-75§);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,10 @@
|
|||||||
package §_-1e§
|
package alternativa.physics.collision
|
||||||
{
|
{
|
||||||
import §_-KA§.§_-FW§;
|
import alternativa.physics.collision.types.BoundBox;
|
||||||
|
|
||||||
public class CollisionKdTree2D
|
public class CollisionKdTree2D
|
||||||
{
|
{
|
||||||
private static const nodeBoundBoxThreshold:§_-FW§ = new §_-FW§();
|
private static const nodeBoundBoxThreshold:BoundBox = new BoundBox();
|
||||||
|
|
||||||
private static const splitCoordsX:Vector.<Number> = new Vector.<Number>();
|
private static const splitCoordsX:Vector.<Number> = new Vector.<Number>();
|
||||||
|
|
||||||
@@ -20,11 +20,11 @@ package §_-1e§
|
|||||||
|
|
||||||
public var §_-eV§:int = 1;
|
public var §_-eV§:int = 1;
|
||||||
|
|
||||||
public var parentTree:§_-D-§;
|
public var parentTree:CollisionKdTree;
|
||||||
|
|
||||||
public var parentNode:§_-oZ§;
|
public var parentNode:CollisionKdNode;
|
||||||
|
|
||||||
public var §_-5H§:§_-oZ§;
|
public var §_-5H§:CollisionKdNode;
|
||||||
|
|
||||||
private var §_-94§:int;
|
private var §_-94§:int;
|
||||||
|
|
||||||
@@ -32,16 +32,16 @@ package §_-1e§
|
|||||||
|
|
||||||
private var §_-P5§:Number;
|
private var §_-P5§:Number;
|
||||||
|
|
||||||
public function CollisionKdTree2D(parentTree:§_-D-§, parentNode:§_-oZ§)
|
public function CollisionKdTree2D(parentTree:CollisionKdTree, parentNode:CollisionKdNode)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
this.parentTree = parentTree;
|
this.parentTree = parentTree;
|
||||||
this.parentNode = parentNode;
|
this.parentNode = parentNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-J9§() : void
|
public function createTree() : void
|
||||||
{
|
{
|
||||||
this.§_-5H§ = new §_-oZ§();
|
this.§_-5H§ = new CollisionKdNode();
|
||||||
this.§_-5H§.boundBox = this.parentNode.boundBox.clone();
|
this.§_-5H§.boundBox = this.parentNode.boundBox.clone();
|
||||||
this.§_-5H§.indices = new Vector.<int>();
|
this.§_-5H§.indices = new Vector.<int>();
|
||||||
var numObjects:int = int(this.parentNode.§_-Xt§.length);
|
var numObjects:int = int(this.parentNode.§_-Xt§.length);
|
||||||
@@ -52,16 +52,16 @@ package §_-1e§
|
|||||||
splitCoordsX.length = splitCoordsY.length = splitCoordsZ.length = 0;
|
splitCoordsX.length = splitCoordsY.length = splitCoordsZ.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function splitNode(node:§_-oZ§) : void
|
private function splitNode(node:CollisionKdNode) : void
|
||||||
{
|
{
|
||||||
var objects:Vector.<int> = null;
|
var objects:Vector.<int> = null;
|
||||||
var i:int = 0;
|
var i:int = 0;
|
||||||
var j:int = 0;
|
var j:int = 0;
|
||||||
var nodeBoundBox:§_-FW§ = null;
|
var nodeBoundBox:BoundBox = null;
|
||||||
var numSplitCoordsX:int = 0;
|
var numSplitCoordsX:int = 0;
|
||||||
var numSplitCoordsY:int = 0;
|
var numSplitCoordsY:int = 0;
|
||||||
var numSplitCoordsZ:int = 0;
|
var numSplitCoordsZ:int = 0;
|
||||||
var bb:§_-FW§ = null;
|
var bb:BoundBox = null;
|
||||||
var min:Number = NaN;
|
var min:Number = NaN;
|
||||||
var max:Number = NaN;
|
var max:Number = NaN;
|
||||||
if(node.indices.length <= this.§_-eV§)
|
if(node.indices.length <= this.§_-eV§)
|
||||||
@@ -77,7 +77,7 @@ package §_-1e§
|
|||||||
nodeBoundBoxThreshold.maxY = nodeBoundBox.maxY - this.threshold;
|
nodeBoundBoxThreshold.maxY = nodeBoundBox.maxY - this.threshold;
|
||||||
nodeBoundBoxThreshold.maxZ = nodeBoundBox.maxZ - this.threshold;
|
nodeBoundBoxThreshold.maxZ = nodeBoundBox.maxZ - this.threshold;
|
||||||
var doubleThreshold:Number = this.threshold * 2;
|
var doubleThreshold:Number = this.threshold * 2;
|
||||||
var staticBoundBoxes:Vector.<§_-FW§> = this.parentTree.staticBoundBoxes;
|
var staticBoundBoxes:Vector.<BoundBox> = this.parentTree.staticBoundBoxes;
|
||||||
var numObjects:int = int(objects.length);
|
var numObjects:int = int(objects.length);
|
||||||
for(i = 0; i < numObjects; )
|
for(i = 0; i < numObjects; )
|
||||||
{
|
{
|
||||||
@@ -133,15 +133,15 @@ package §_-1e§
|
|||||||
_nodeBB[5] = nodeBoundBox.maxZ;
|
_nodeBB[5] = nodeBoundBox.maxZ;
|
||||||
if(this.parentNode.axis != 0)
|
if(this.parentNode.axis != 0)
|
||||||
{
|
{
|
||||||
this.§_-1k§(node,0,numSplitCoordsX,splitCoordsX,_nodeBB);
|
this.checkNodeAxis(node,0,numSplitCoordsX,splitCoordsX,_nodeBB);
|
||||||
}
|
}
|
||||||
if(this.parentNode.axis != 1)
|
if(this.parentNode.axis != 1)
|
||||||
{
|
{
|
||||||
this.§_-1k§(node,1,numSplitCoordsY,splitCoordsY,_nodeBB);
|
this.checkNodeAxis(node,1,numSplitCoordsY,splitCoordsY,_nodeBB);
|
||||||
}
|
}
|
||||||
if(this.parentNode.axis != 2)
|
if(this.parentNode.axis != 2)
|
||||||
{
|
{
|
||||||
this.§_-1k§(node,2,numSplitCoordsZ,splitCoordsZ,_nodeBB);
|
this.checkNodeAxis(node,2,numSplitCoordsZ,splitCoordsZ,_nodeBB);
|
||||||
}
|
}
|
||||||
if(this.§_-94§ < 0)
|
if(this.§_-94§ < 0)
|
||||||
{
|
{
|
||||||
@@ -151,10 +151,10 @@ package §_-1e§
|
|||||||
var axisY:Boolean = this.§_-94§ == 1;
|
var axisY:Boolean = this.§_-94§ == 1;
|
||||||
node.axis = this.§_-94§;
|
node.axis = this.§_-94§;
|
||||||
node.coord = this.§_-P5§;
|
node.coord = this.§_-P5§;
|
||||||
node.§_-Gm§ = new §_-oZ§();
|
node.§_-Gm§ = new CollisionKdNode();
|
||||||
node.§_-Gm§.parent = node;
|
node.§_-Gm§.parent = node;
|
||||||
node.§_-Gm§.boundBox = nodeBoundBox.clone();
|
node.§_-Gm§.boundBox = nodeBoundBox.clone();
|
||||||
node.§_-75§ = new §_-oZ§();
|
node.§_-75§ = new CollisionKdNode();
|
||||||
node.§_-75§.parent = node;
|
node.§_-75§.parent = node;
|
||||||
node.§_-75§.boundBox = nodeBoundBox.clone();
|
node.§_-75§.boundBox = nodeBoundBox.clone();
|
||||||
if(axisX)
|
if(axisX)
|
||||||
@@ -229,7 +229,7 @@ package §_-1e§
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-1k§(node:§_-oZ§, axis:int, numSplitCoords:int, splitCoords:Vector.<Number>, bb:Vector.<Number>) : void
|
private function checkNodeAxis(node:CollisionKdNode, axis:int, numSplitCoords:int, splitCoords:Vector.<Number>, bb:Vector.<Number>) : void
|
||||||
{
|
{
|
||||||
var currSplitCoord:Number = NaN;
|
var currSplitCoord:Number = NaN;
|
||||||
var minCoord:Number = NaN;
|
var minCoord:Number = NaN;
|
||||||
@@ -242,11 +242,11 @@ package §_-1e§
|
|||||||
var numObjects:int = 0;
|
var numObjects:int = 0;
|
||||||
var j:int = 0;
|
var j:int = 0;
|
||||||
var cost:Number = NaN;
|
var cost:Number = NaN;
|
||||||
var boundBox:§_-FW§ = null;
|
var boundBox:BoundBox = null;
|
||||||
var axis1:int = (axis + 1) % 3;
|
var axis1:int = (axis + 1) % 3;
|
||||||
var axis2:int = (axis + 2) % 3;
|
var axis2:int = (axis + 2) % 3;
|
||||||
var area:Number = (bb[axis1 + 3] - bb[axis1]) * (bb[axis2 + 3] - bb[axis2]);
|
var area:Number = (bb[axis1 + 3] - bb[axis1]) * (bb[axis2 + 3] - bb[axis2]);
|
||||||
var staticBoundBoxes:Vector.<§_-FW§> = this.parentTree.staticBoundBoxes;
|
var staticBoundBoxes:Vector.<BoundBox> = this.parentTree.staticBoundBoxes;
|
||||||
for(var i:int = 0; i < numSplitCoords; i++)
|
for(var i:int = 0; i < numSplitCoords; i++)
|
||||||
{
|
{
|
||||||
currSplitCoord = splitCoords[i];
|
currSplitCoord = splitCoords[i];
|
||||||
@@ -1,23 +1,23 @@
|
|||||||
package §_-1e§
|
package alternativa.physics.collision
|
||||||
{
|
{
|
||||||
import §_-KA§.§_-FW§;
|
import alternativa.physics.collision.types.BoundBox;
|
||||||
import §_-KA§.§_-jr§;
|
import alternativa.physics.collision.types.RayHit;
|
||||||
import §_-US§.§_-6h§;
|
import alternativa.physics.Contact;
|
||||||
import §_-US§.§_-BV§;
|
import alternativa.physics.Body;
|
||||||
import §_-nl§.§_-bj§;
|
import alternativa.math.Vector3;
|
||||||
import §while§.§_-6O§;
|
import alternativa.physics.collision.colliders.SphereSphereCollider;
|
||||||
import §while§.§_-GQ§;
|
import alternativa.physics.collision.colliders.BoxRectCollider;
|
||||||
import §while§.§_-O8§;
|
import alternativa.physics.collision.colliders.BoxSphereCollider;
|
||||||
import §while§.§_-Ph§;
|
import alternativa.physics.collision.colliders.BoxBoxCollider;
|
||||||
import §while§.§_-hu§;
|
import alternativa.physics.collision.colliders.BoxTriangleCollider;
|
||||||
|
|
||||||
public class §_-LG§ implements §_-fx§
|
public class KdTreeCollisionDetector implements ICollisionDetector
|
||||||
{
|
{
|
||||||
private static var _rayAABB:§_-FW§ = new §_-FW§();
|
private static var _rayAABB:BoundBox = new BoundBox();
|
||||||
|
|
||||||
public var §_-bw§:§_-D-§;
|
public var §_-bw§:CollisionKdTree;
|
||||||
|
|
||||||
public var §_-Fz§:Vector.<§_-Nh§>;
|
public var §_-Fz§:Vector.<CollisionPrimitive>;
|
||||||
|
|
||||||
public var §_-iH§:int;
|
public var §_-iH§:int;
|
||||||
|
|
||||||
@@ -27,45 +27,45 @@ package §_-1e§
|
|||||||
|
|
||||||
private var §_-qC§:MinMax = new MinMax();
|
private var §_-qC§:MinMax = new MinMax();
|
||||||
|
|
||||||
private var §_-k8§:§_-bj§ = new §_-bj§();
|
private var §_-k8§:Vector3 = new Vector3();
|
||||||
|
|
||||||
private var §_-0q§:§_-bj§ = new §_-bj§();
|
private var §_-0q§:Vector3 = new Vector3();
|
||||||
|
|
||||||
private var §_-2P§:§_-jr§ = new §_-jr§();
|
private var §_-2P§:RayHit = new RayHit();
|
||||||
|
|
||||||
public function §_-LG§()
|
public function KdTreeCollisionDetector()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
this.§_-bw§ = new §_-D-§();
|
this.§_-bw§ = new CollisionKdTree();
|
||||||
this.§_-Fz§ = new Vector.<§_-Nh§>();
|
this.§_-Fz§ = new Vector.<CollisionPrimitive>();
|
||||||
this.§_-c2§(§_-Nh§.BOX,§_-Nh§.BOX,new §_-Ph§());
|
this.addCollider(CollisionPrimitive.BOX,CollisionPrimitive.BOX,new BoxBoxCollider());
|
||||||
this.§_-c2§(§_-Nh§.BOX,§_-Nh§.SPHERE,new §_-O8§());
|
this.addCollider(CollisionPrimitive.BOX,CollisionPrimitive.SPHERE,new BoxSphereCollider());
|
||||||
this.§_-c2§(§_-Nh§.BOX,§_-Nh§.RECT,new §_-GQ§());
|
this.addCollider(CollisionPrimitive.BOX,CollisionPrimitive.RECT,new BoxRectCollider());
|
||||||
this.§_-c2§(§_-Nh§.BOX,§_-Nh§.TRIANGLE,new §_-hu§());
|
this.addCollider(CollisionPrimitive.BOX,CollisionPrimitive.TRIANGLE,new BoxTriangleCollider());
|
||||||
this.§_-c2§(§_-Nh§.SPHERE,§_-Nh§.SPHERE,new §_-6O§());
|
this.addCollider(CollisionPrimitive.SPHERE,CollisionPrimitive.SPHERE,new SphereSphereCollider());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-6v§(primitive:§_-Nh§, isStatic:Boolean = true) : Boolean
|
public function addPrimitive(primitive:CollisionPrimitive, isStatic:Boolean = true) : Boolean
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-2V§(primitive:§_-Nh§, isStatic:Boolean = true) : Boolean
|
public function removePrimitive(primitive:CollisionPrimitive, isStatic:Boolean = true) : Boolean
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function init(collisionPrimitives:Vector.<§_-Nh§>) : void
|
public function init(collisionPrimitives:Vector.<CollisionPrimitive>) : void
|
||||||
{
|
{
|
||||||
this.§_-bw§.§_-J9§(collisionPrimitives);
|
this.§_-bw§.createTree(collisionPrimitives);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-63§(contacts:§_-6h§) : §_-6h§
|
public function getAllContacts(contacts:Contact) : Contact
|
||||||
{
|
{
|
||||||
return contacts;
|
return contacts;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContact(prim1:§_-Nh§, prim2:§_-Nh§, contact:§_-6h§) : Boolean
|
public function getContact(prim1:CollisionPrimitive, prim2:CollisionPrimitive, contact:Contact) : Boolean
|
||||||
{
|
{
|
||||||
if((prim1.collisionGroup & prim2.collisionGroup) == 0)
|
if((prim1.collisionGroup & prim2.collisionGroup) == 0)
|
||||||
{
|
{
|
||||||
@@ -79,7 +79,7 @@ package §_-1e§
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var collider:§_-hG§ = this.§_-P6§[prim1.type <= prim2.type ? prim1.type << 16 | prim2.type : prim2.type << 16 | prim1.type] as §_-hG§;
|
var collider:ICollider = this.§_-P6§[prim1.type <= prim2.type ? prim1.type << 16 | prim2.type : prim2.type << 16 | prim1.type] as ICollider;
|
||||||
if(collider != null && Boolean(collider.getContact(prim1,prim2,contact)))
|
if(collider != null && Boolean(collider.getContact(prim1,prim2,contact)))
|
||||||
{
|
{
|
||||||
if(prim1.postCollisionFilter != null && !prim1.postCollisionFilter.§_-eZ§(prim1,prim2))
|
if(prim1.postCollisionFilter != null && !prim1.postCollisionFilter.§_-eZ§(prim1,prim2))
|
||||||
@@ -95,7 +95,7 @@ package §_-1e§
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-A5§(prim1:§_-Nh§, prim2:§_-Nh§) : Boolean
|
public function testCollision(prim1:CollisionPrimitive, prim2:CollisionPrimitive) : Boolean
|
||||||
{
|
{
|
||||||
if((prim1.collisionGroup & prim2.collisionGroup) == 0)
|
if((prim1.collisionGroup & prim2.collisionGroup) == 0)
|
||||||
{
|
{
|
||||||
@@ -109,7 +109,7 @@ package §_-1e§
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var collider:§_-hG§ = this.§_-P6§[prim1.type <= prim2.type ? prim1.type << 16 | prim2.type : prim2.type << 16 | prim1.type] as §_-hG§;
|
var collider:ICollider = this.§_-P6§[prim1.type <= prim2.type ? prim1.type << 16 | prim2.type : prim2.type << 16 | prim1.type] as ICollider;
|
||||||
if(collider != null && Boolean(collider.haveCollision(prim1,prim2)))
|
if(collider != null && Boolean(collider.haveCollision(prim1,prim2)))
|
||||||
{
|
{
|
||||||
if(prim1.postCollisionFilter != null && !prim1.postCollisionFilter.§_-eZ§(prim1,prim2))
|
if(prim1.postCollisionFilter != null && !prim1.postCollisionFilter.§_-eZ§(prim1,prim2))
|
||||||
@@ -125,10 +125,10 @@ package §_-1e§
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function raycast(origin:§_-bj§, dir:§_-bj§, collisionGroup:int, maxTime:Number, predicate:§_-jn§, result:§_-jr§) : Boolean
|
public function raycast(origin:Vector3, dir:Vector3, collisionGroup:int, maxTime:Number, predicate:IRaycastFilter, result:RayHit) : Boolean
|
||||||
{
|
{
|
||||||
var hasStaticIntersection:Boolean = this.§_-cX§(origin,dir,collisionGroup,maxTime,predicate,result);
|
var hasStaticIntersection:Boolean = this.raycastStatic(origin,dir,collisionGroup,maxTime,predicate,result);
|
||||||
var hasDynamicIntersection:Boolean = this.§_-Tm§(origin,dir,collisionGroup,maxTime,predicate,this.§_-2P§);
|
var hasDynamicIntersection:Boolean = this.intersectRayWithDynamic(origin,dir,collisionGroup,maxTime,predicate,this.§_-2P§);
|
||||||
if(!(hasDynamicIntersection || hasStaticIntersection))
|
if(!(hasDynamicIntersection || hasStaticIntersection))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -149,9 +149,9 @@ package §_-1e§
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-cX§(origin:§_-bj§, dir:§_-bj§, collisionGroup:int, maxTime:Number, predicate:§_-jn§, result:§_-jr§) : Boolean
|
public function raycastStatic(origin:Vector3, dir:Vector3, collisionGroup:int, maxTime:Number, predicate:IRaycastFilter, result:RayHit) : Boolean
|
||||||
{
|
{
|
||||||
if(!this.§_-oL§(origin,dir,this.§_-bw§.§_-5H§.boundBox,this.§_-qC§))
|
if(!this.getRayBoundBoxIntersection(origin,dir,this.§_-bw§.§_-5H§.boundBox,this.§_-qC§))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -176,31 +176,31 @@ package §_-1e§
|
|||||||
{
|
{
|
||||||
this.§_-qC§.max = maxTime;
|
this.§_-qC§.max = maxTime;
|
||||||
}
|
}
|
||||||
var hasIntersection:Boolean = this.§_-NC§(this.§_-bw§.§_-5H§,origin,this.§_-0q§,dir,collisionGroup,this.§_-qC§.min,this.§_-qC§.max,predicate,result);
|
var hasIntersection:Boolean = this.testRayAgainstNode(this.§_-bw§.§_-5H§,origin,this.§_-0q§,dir,collisionGroup,this.§_-qC§.min,this.§_-qC§.max,predicate,result);
|
||||||
return hasIntersection ? result.t <= maxTime : false;
|
return hasIntersection ? result.t <= maxTime : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-9G§(body:§_-BV§, primitive:§_-Nh§) : Boolean
|
public function testBodyPrimitiveCollision(body:Body, primitive:CollisionPrimitive) : Boolean
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-c2§(type1:int, type2:int, collider:§_-hG§) : void
|
private function addCollider(type1:int, type2:int, collider:ICollider) : void
|
||||||
{
|
{
|
||||||
this.§_-P6§[type1 <= type2 ? type1 << 16 | type2 : type2 << 16 | type1] = collider;
|
this.§_-P6§[type1 <= type2 ? type1 << 16 | type2 : type2 << 16 | type1] = collider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-m1§(node:§_-oZ§, primitive:§_-Nh§, contacts:§_-6h§) : §_-6h§
|
private function getPrimitiveNodeCollisions(node:CollisionKdNode, primitive:CollisionPrimitive, contacts:Contact) : Contact
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-Tm§(origin:§_-bj§, dir:§_-bj§, collisionGroup:int, maxTime:Number, filter:§_-jn§, result:§_-jr§) : Boolean
|
private function intersectRayWithDynamic(origin:Vector3, dir:Vector3, collisionGroup:int, maxTime:Number, filter:IRaycastFilter, result:RayHit) : Boolean
|
||||||
{
|
{
|
||||||
var yy:Number = NaN;
|
var yy:Number = NaN;
|
||||||
var minTime:Number = NaN;
|
var minTime:Number = NaN;
|
||||||
var primitive:§_-Nh§ = null;
|
var primitive:CollisionPrimitive = null;
|
||||||
var paabb:§_-FW§ = null;
|
var paabb:BoundBox = null;
|
||||||
var t:Number = NaN;
|
var t:Number = NaN;
|
||||||
var xx:Number = origin.x + dir.x * maxTime;
|
var xx:Number = origin.x + dir.x * maxTime;
|
||||||
yy = origin.y + dir.y * maxTime;
|
yy = origin.y + dir.y * maxTime;
|
||||||
@@ -271,7 +271,7 @@ package §_-1e§
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-oL§(origin:§_-bj§, dir:§_-bj§, bb:§_-FW§, time:MinMax) : Boolean
|
private function getRayBoundBoxIntersection(origin:Vector3, dir:Vector3, bb:BoundBox, time:MinMax) : Boolean
|
||||||
{
|
{
|
||||||
var t1:Number = NaN;
|
var t1:Number = NaN;
|
||||||
var t2:Number = NaN;
|
var t2:Number = NaN;
|
||||||
@@ -348,12 +348,12 @@ package §_-1e§
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-NC§(node:§_-oZ§, origin:§_-bj§, localOrigin:§_-bj§, dir:§_-bj§, collisionGroup:int, t1:Number, t2:Number, predicate:§_-jn§, result:§_-jr§) : Boolean
|
private function testRayAgainstNode(node:CollisionKdNode, origin:Vector3, localOrigin:Vector3, dir:Vector3, collisionGroup:int, t1:Number, t2:Number, predicate:IRaycastFilter, result:RayHit) : Boolean
|
||||||
{
|
{
|
||||||
var splitTime:Number = NaN;
|
var splitTime:Number = NaN;
|
||||||
var currChildNode:§_-oZ§ = null;
|
var currChildNode:CollisionKdNode = null;
|
||||||
var intersects:Boolean = false;
|
var intersects:Boolean = false;
|
||||||
if(node.indices != null && this.§_-FH§(origin,dir,collisionGroup,this.§_-bw§.§_-8A§,node.indices,predicate,result))
|
if(node.indices != null && this.getRayNodeIntersection(origin,dir,collisionGroup,this.§_-bw§.§_-8A§,node.indices,predicate,result))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -398,9 +398,9 @@ package §_-1e§
|
|||||||
}
|
}
|
||||||
if(splitTime < t1 || splitTime > t2)
|
if(splitTime < t1 || splitTime > t2)
|
||||||
{
|
{
|
||||||
return this.§_-NC§(currChildNode,origin,localOrigin,dir,collisionGroup,t1,t2,predicate,result);
|
return this.testRayAgainstNode(currChildNode,origin,localOrigin,dir,collisionGroup,t1,t2,predicate,result);
|
||||||
}
|
}
|
||||||
intersects = this.§_-NC§(currChildNode,origin,localOrigin,dir,collisionGroup,t1,splitTime,predicate,result);
|
intersects = this.testRayAgainstNode(currChildNode,origin,localOrigin,dir,collisionGroup,t1,splitTime,predicate,result);
|
||||||
if(intersects)
|
if(intersects)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -408,12 +408,12 @@ package §_-1e§
|
|||||||
this.§_-0q§.x = origin.x + splitTime * dir.x;
|
this.§_-0q§.x = origin.x + splitTime * dir.x;
|
||||||
this.§_-0q§.y = origin.y + splitTime * dir.y;
|
this.§_-0q§.y = origin.y + splitTime * dir.y;
|
||||||
this.§_-0q§.z = origin.z + splitTime * dir.z;
|
this.§_-0q§.z = origin.z + splitTime * dir.z;
|
||||||
return this.§_-NC§(currChildNode == node.§_-Gm§ ? node.§_-75§ : node.§_-Gm§,origin,this.§_-0q§,dir,collisionGroup,splitTime,t2,predicate,result);
|
return this.testRayAgainstNode(currChildNode == node.§_-Gm§ ? node.§_-75§ : node.§_-Gm§,origin,this.§_-0q§,dir,collisionGroup,splitTime,t2,predicate,result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-FH§(origin:§_-bj§, dir:§_-bj§, collisionGroup:int, primitives:Vector.<§_-Nh§>, indices:Vector.<int>, filter:§_-jn§, intersection:§_-jr§) : Boolean
|
private function getRayNodeIntersection(origin:Vector3, dir:Vector3, collisionGroup:int, primitives:Vector.<CollisionPrimitive>, indices:Vector.<int>, filter:IRaycastFilter, intersection:RayHit) : Boolean
|
||||||
{
|
{
|
||||||
var primitive:§_-Nh§ = null;
|
var primitive:CollisionPrimitive = null;
|
||||||
var t:Number = NaN;
|
var t:Number = NaN;
|
||||||
var pnum:int = int(indices.length);
|
var pnum:int = int(indices.length);
|
||||||
var minTime:Number = 1e+308;
|
var minTime:Number = 1e+308;
|
||||||
@@ -5,7 +5,7 @@ package alternativa.physics.collision.colliders
|
|||||||
import alternativa.physics.Contact;
|
import alternativa.physics.Contact;
|
||||||
import alternativa.physics.ContactPoint;
|
import alternativa.physics.ContactPoint;
|
||||||
import alternativa.physics.collision.CollisionPrimitive;
|
import alternativa.physics.collision.CollisionPrimitive;
|
||||||
import alternativa.physics.collision.primitives.§_-m3§;
|
import alternativa.physics.collision.primitives.CollisionBox;
|
||||||
|
|
||||||
public class BoxBoxCollider extends BoxCollider
|
public class BoxBoxCollider extends BoxCollider
|
||||||
{
|
{
|
||||||
@@ -52,21 +52,21 @@ package alternativa.physics.collision.colliders
|
|||||||
|
|
||||||
override public function getContact(prim1:CollisionPrimitive, prim2:CollisionPrimitive, contact:Contact) : Boolean
|
override public function getContact(prim1:CollisionPrimitive, prim2:CollisionPrimitive, contact:Contact) : Boolean
|
||||||
{
|
{
|
||||||
var box1:§_-m3§ = null;
|
var box1:CollisionBox = null;
|
||||||
var box2:§_-m3§ = null;
|
var box2:CollisionBox = null;
|
||||||
if(!this.haveCollision(prim1,prim2))
|
if(!this.haveCollision(prim1,prim2))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(prim1.body != null)
|
if(prim1.body != null)
|
||||||
{
|
{
|
||||||
box1 = prim1 as §_-m3§;
|
box1 = prim1 as CollisionBox;
|
||||||
box2 = prim2 as §_-m3§;
|
box2 = prim2 as CollisionBox;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
box1 = prim2 as §_-m3§;
|
box1 = prim2 as CollisionBox;
|
||||||
box2 = prim1 as §_-m3§;
|
box2 = prim1 as CollisionBox;
|
||||||
}
|
}
|
||||||
if(this.§_-Wt§ < 6)
|
if(this.§_-Wt§ < 6)
|
||||||
{
|
{
|
||||||
@@ -87,20 +87,20 @@ package alternativa.physics.collision.colliders
|
|||||||
|
|
||||||
override public function haveCollision(prim1:CollisionPrimitive, prim2:CollisionPrimitive) : Boolean
|
override public function haveCollision(prim1:CollisionPrimitive, prim2:CollisionPrimitive) : Boolean
|
||||||
{
|
{
|
||||||
var box1:§_-m3§ = null;
|
var box1:CollisionBox = null;
|
||||||
var box2:§_-m3§ = null;
|
var box2:CollisionBox = null;
|
||||||
var transform1:Matrix4 = null;
|
var transform1:Matrix4 = null;
|
||||||
var transform2:Matrix4 = null;
|
var transform2:Matrix4 = null;
|
||||||
this.§_-hK§ = 10000000000;
|
this.§_-hK§ = 10000000000;
|
||||||
if(prim1.body != null)
|
if(prim1.body != null)
|
||||||
{
|
{
|
||||||
box1 = prim1 as §_-m3§;
|
box1 = prim1 as CollisionBox;
|
||||||
box2 = prim2 as §_-m3§;
|
box2 = prim2 as CollisionBox;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
box1 = prim2 as §_-m3§;
|
box1 = prim2 as CollisionBox;
|
||||||
box2 = prim1 as §_-m3§;
|
box2 = prim1 as CollisionBox;
|
||||||
}
|
}
|
||||||
transform1 = box1.transform;
|
transform1 = box1.transform;
|
||||||
transform2 = box2.transform;
|
transform2 = box2.transform;
|
||||||
@@ -188,13 +188,13 @@ package alternativa.physics.collision.colliders
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function findFaceContactPoints(box1:§_-m3§, box2:§_-m3§, vectorToBox1:Vector3, faceAxisIdx:int, contact:Contact) : Boolean
|
private function findFaceContactPoints(box1:CollisionBox, box2:CollisionBox, vectorToBox1:Vector3, faceAxisIdx:int, contact:Contact) : Boolean
|
||||||
{
|
{
|
||||||
var transform2:Matrix4 = null;
|
var transform2:Matrix4 = null;
|
||||||
var colAxis:Vector3 = null;
|
var colAxis:Vector3 = null;
|
||||||
var incidentAxisDot:Number = NaN;
|
var incidentAxisDot:Number = NaN;
|
||||||
var pen:Number = NaN;
|
var pen:Number = NaN;
|
||||||
var tmpBox:§_-m3§ = null;
|
var tmpBox:CollisionBox = null;
|
||||||
var dot:Number = NaN;
|
var dot:Number = NaN;
|
||||||
var absDot:Number = NaN;
|
var absDot:Number = NaN;
|
||||||
var v:Vector3 = null;
|
var v:Vector3 = null;
|
||||||
@@ -435,7 +435,7 @@ package alternativa.physics.collision.colliders
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function findEdgesIntersection(box1:§_-m3§, box2:§_-m3§, vectorToBox1:Vector3, axisIdx1:int, axisIdx2:int, contact:Contact) : void
|
private function findEdgesIntersection(box1:CollisionBox, box2:CollisionBox, vectorToBox1:Vector3, axisIdx1:int, axisIdx2:int, contact:Contact) : void
|
||||||
{
|
{
|
||||||
var halfLen1:Number = NaN;
|
var halfLen1:Number = NaN;
|
||||||
var halfLen2:Number = NaN;
|
var halfLen2:Number = NaN;
|
||||||
@@ -552,7 +552,7 @@ package alternativa.physics.collision.colliders
|
|||||||
cp.penetration = this.§_-hK§;
|
cp.penetration = this.§_-hK§;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function testMainAxis(box1:§_-m3§, box2:§_-m3§, axis:Vector3, axisIndex:int, toBox1:Vector3) : Boolean
|
private function testMainAxis(box1:CollisionBox, box2:CollisionBox, axis:Vector3, axisIndex:int, toBox1:Vector3) : Boolean
|
||||||
{
|
{
|
||||||
var overlap:Number = this.overlapOnAxis(box1,box2,axis,toBox1);
|
var overlap:Number = this.overlapOnAxis(box1,box2,axis,toBox1);
|
||||||
if(overlap < -this.epsilon)
|
if(overlap < -this.epsilon)
|
||||||
@@ -567,7 +567,7 @@ package alternativa.physics.collision.colliders
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function testDerivedAxis(box1:§_-m3§, box2:§_-m3§, axis1:Vector3, axis2:Vector3, axisIndex:int, toBox1:Vector3) : Boolean
|
private function testDerivedAxis(box1:CollisionBox, box2:CollisionBox, axis1:Vector3, axis2:Vector3, axisIndex:int, toBox1:Vector3) : Boolean
|
||||||
{
|
{
|
||||||
this.axis.x = axis1.y * axis2.z - axis1.z * axis2.y;
|
this.axis.x = axis1.y * axis2.z - axis1.z * axis2.y;
|
||||||
this.axis.y = axis1.z * axis2.x - axis1.x * axis2.z;
|
this.axis.y = axis1.z * axis2.x - axis1.x * axis2.z;
|
||||||
@@ -594,7 +594,7 @@ package alternativa.physics.collision.colliders
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function overlapOnAxis(box1:§_-m3§, box2:§_-m3§, axis:Vector3, vectorToBox1:Vector3) : Number
|
public function overlapOnAxis(box1:CollisionBox, box2:CollisionBox, axis:Vector3, vectorToBox1:Vector3) : Number
|
||||||
{
|
{
|
||||||
var m:Matrix4 = box1.transform;
|
var m:Matrix4 = box1.transform;
|
||||||
var d:Number = (m.a * axis.x + m.e * axis.y + m.i * axis.z) * box1.hs.x;
|
var d:Number = (m.a * axis.x + m.e * axis.y + m.i * axis.z) * box1.hs.x;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ package alternativa.physics.collision.colliders
|
|||||||
import alternativa.physics.ContactPoint;
|
import alternativa.physics.ContactPoint;
|
||||||
import alternativa.physics.collision.CollisionPrimitive;
|
import alternativa.physics.collision.CollisionPrimitive;
|
||||||
import alternativa.physics.collision.primitives.CollisionRect;
|
import alternativa.physics.collision.primitives.CollisionRect;
|
||||||
import alternativa.physics.collision.primitives.§_-m3§;
|
import alternativa.physics.collision.primitives.CollisionBox;
|
||||||
|
|
||||||
public class BoxRectCollider extends BoxCollider
|
public class BoxRectCollider extends BoxCollider
|
||||||
{
|
{
|
||||||
@@ -53,10 +53,10 @@ package alternativa.physics.collision.colliders
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var box:§_-m3§ = prim1 as §_-m3§;
|
var box:CollisionBox = prim1 as CollisionBox;
|
||||||
if(box == null)
|
if(box == null)
|
||||||
{
|
{
|
||||||
box = prim2 as §_-m3§;
|
box = prim2 as CollisionBox;
|
||||||
rect = prim1 as CollisionRect;
|
rect = prim1 as CollisionRect;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -91,14 +91,14 @@ package alternativa.physics.collision.colliders
|
|||||||
|
|
||||||
override public function haveCollision(prim1:CollisionPrimitive, prim2:CollisionPrimitive) : Boolean
|
override public function haveCollision(prim1:CollisionPrimitive, prim2:CollisionPrimitive) : Boolean
|
||||||
{
|
{
|
||||||
var box:§_-m3§ = null;
|
var box:CollisionBox = null;
|
||||||
var rect:CollisionRect = null;
|
var rect:CollisionRect = null;
|
||||||
var rectTransform:Matrix4 = null;
|
var rectTransform:Matrix4 = null;
|
||||||
this.§_-hK§ = 10000000000;
|
this.§_-hK§ = 10000000000;
|
||||||
box = prim1 as §_-m3§;
|
box = prim1 as CollisionBox;
|
||||||
if(box == null)
|
if(box == null)
|
||||||
{
|
{
|
||||||
box = prim2 as §_-m3§;
|
box = prim2 as CollisionBox;
|
||||||
rect = prim1 as CollisionRect;
|
rect = prim1 as CollisionRect;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -159,7 +159,7 @@ package alternativa.physics.collision.colliders
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function findFaceContactPoints(box:§_-m3§, rect:CollisionRect, vectorToBox:Vector3, faceAxisIdx:int, contact:Contact) : Boolean
|
private function findFaceContactPoints(box:CollisionBox, rect:CollisionRect, vectorToBox:Vector3, faceAxisIdx:int, contact:Contact) : Boolean
|
||||||
{
|
{
|
||||||
var pnum:int = 0;
|
var pnum:int = 0;
|
||||||
var i:int = 0;
|
var i:int = 0;
|
||||||
@@ -392,7 +392,7 @@ package alternativa.physics.collision.colliders
|
|||||||
return clipHighY(hs.y,pnum,this.points2,this.points1,this.epsilon);
|
return clipHighY(hs.y,pnum,this.points2,this.points1,this.epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function findEdgesIntersection(box:§_-m3§, rect:CollisionRect, vectorToBox:Vector3, axisIdx1:int, axisIdx2:int, contact:Contact) : Boolean
|
private function findEdgesIntersection(box:CollisionBox, rect:CollisionRect, vectorToBox:Vector3, axisIdx1:int, axisIdx2:int, contact:Contact) : Boolean
|
||||||
{
|
{
|
||||||
var halfLen1:Number = NaN;
|
var halfLen1:Number = NaN;
|
||||||
var halfLen2:Number = NaN;
|
var halfLen2:Number = NaN;
|
||||||
@@ -501,7 +501,7 @@ package alternativa.physics.collision.colliders
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function testMainAxis(box:§_-m3§, rect:CollisionRect, axis:Vector3, axisIndex:int, vectorToBox:Vector3) : Boolean
|
private function testMainAxis(box:CollisionBox, rect:CollisionRect, axis:Vector3, axisIndex:int, vectorToBox:Vector3) : Boolean
|
||||||
{
|
{
|
||||||
var overlap:Number = this.overlapOnAxis(box,rect,axis,vectorToBox);
|
var overlap:Number = this.overlapOnAxis(box,rect,axis,vectorToBox);
|
||||||
if(overlap < -this.epsilon)
|
if(overlap < -this.epsilon)
|
||||||
@@ -516,7 +516,7 @@ package alternativa.physics.collision.colliders
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function testDerivedAxis(box:§_-m3§, rect:CollisionRect, axis1:Vector3, axis2:Vector3, axisIndex:int, vectorToBox:Vector3) : Boolean
|
private function testDerivedAxis(box:CollisionBox, rect:CollisionRect, axis1:Vector3, axis2:Vector3, axisIndex:int, vectorToBox:Vector3) : Boolean
|
||||||
{
|
{
|
||||||
this.axis.x = axis1.y * axis2.z - axis1.z * axis2.y;
|
this.axis.x = axis1.y * axis2.z - axis1.z * axis2.y;
|
||||||
this.axis.y = axis1.z * axis2.x - axis1.x * axis2.z;
|
this.axis.y = axis1.z * axis2.x - axis1.x * axis2.z;
|
||||||
@@ -543,7 +543,7 @@ package alternativa.physics.collision.colliders
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function overlapOnAxis(box:§_-m3§, rect:CollisionRect, axis:Vector3, vectorToBox:Vector3) : Number
|
public function overlapOnAxis(box:CollisionBox, rect:CollisionRect, axis:Vector3, vectorToBox:Vector3) : Number
|
||||||
{
|
{
|
||||||
var m:Matrix4 = box.transform;
|
var m:Matrix4 = box.transform;
|
||||||
var d:Number = (m.a * axis.x + m.e * axis.y + m.i * axis.z) * box.hs.x;
|
var d:Number = (m.a * axis.x + m.e * axis.y + m.i * axis.z) * box.hs.x;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ package alternativa.physics.collision.colliders
|
|||||||
import alternativa.physics.collision.CollisionPrimitive;
|
import alternativa.physics.collision.CollisionPrimitive;
|
||||||
import alternativa.physics.collision.ICollider;
|
import alternativa.physics.collision.ICollider;
|
||||||
import alternativa.physics.collision.primitives.CollisionSphere;
|
import alternativa.physics.collision.primitives.CollisionSphere;
|
||||||
import alternativa.physics.collision.primitives.§_-m3§;
|
import alternativa.physics.collision.primitives.CollisionBox;
|
||||||
|
|
||||||
public class BoxSphereCollider implements ICollider
|
public class BoxSphereCollider implements ICollider
|
||||||
{
|
{
|
||||||
@@ -25,16 +25,16 @@ package alternativa.physics.collision.colliders
|
|||||||
|
|
||||||
public function getContact(prim1:CollisionPrimitive, prim2:CollisionPrimitive, contact:Contact) : Boolean
|
public function getContact(prim1:CollisionPrimitive, prim2:CollisionPrimitive, contact:Contact) : Boolean
|
||||||
{
|
{
|
||||||
var box:§_-m3§ = null;
|
var box:CollisionBox = null;
|
||||||
var sphere:CollisionSphere = prim1 as CollisionSphere;
|
var sphere:CollisionSphere = prim1 as CollisionSphere;
|
||||||
if(sphere == null)
|
if(sphere == null)
|
||||||
{
|
{
|
||||||
sphere = prim2 as CollisionSphere;
|
sphere = prim2 as CollisionSphere;
|
||||||
box = prim1 as §_-m3§;
|
box = prim1 as CollisionBox;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
box = prim2 as §_-m3§;
|
box = prim2 as CollisionBox;
|
||||||
}
|
}
|
||||||
sphere.transform.getAxis(3,this.§_-dt§);
|
sphere.transform.getAxis(3,this.§_-dt§);
|
||||||
box.transform.getAxis(3,this.bPos);
|
box.transform.getAxis(3,this.bPos);
|
||||||
@@ -102,16 +102,16 @@ package alternativa.physics.collision.colliders
|
|||||||
|
|
||||||
public function haveCollision(prim1:CollisionPrimitive, prim2:CollisionPrimitive) : Boolean
|
public function haveCollision(prim1:CollisionPrimitive, prim2:CollisionPrimitive) : Boolean
|
||||||
{
|
{
|
||||||
var box:§_-m3§ = null;
|
var box:CollisionBox = null;
|
||||||
var sphere:CollisionSphere = prim1 as CollisionSphere;
|
var sphere:CollisionSphere = prim1 as CollisionSphere;
|
||||||
if(sphere == null)
|
if(sphere == null)
|
||||||
{
|
{
|
||||||
sphere = prim2 as CollisionSphere;
|
sphere = prim2 as CollisionSphere;
|
||||||
box = prim1 as §_-m3§;
|
box = prim1 as CollisionBox;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
box = prim2 as §_-m3§;
|
box = prim2 as CollisionBox;
|
||||||
}
|
}
|
||||||
sphere.transform.getAxis(3,this.§_-dt§);
|
sphere.transform.getAxis(3,this.§_-dt§);
|
||||||
box.transform.getAxis(3,this.bPos);
|
box.transform.getAxis(3,this.bPos);
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package §while§
|
package alternativa.physics.collision.colliders
|
||||||
{
|
{
|
||||||
import §_-1e§.§_-Nh§;
|
import alternativa.physics.collision.CollisionPrimitive;
|
||||||
import §_-US§.§_-6h§;
|
import alternativa.physics.Contact;
|
||||||
import §_-US§.§_-cR§;
|
import alternativa.physics.ContactPoint;
|
||||||
import §_-nl§.Matrix4;
|
import alternativa.math.Matrix4;
|
||||||
import §_-nl§.§_-bj§;
|
import alternativa.math.Vector3;
|
||||||
import §_-pe§.§_-Pr§;
|
import alternativa.physics.collision.primitives.CollisionTriangle;
|
||||||
import §_-pe§.§_-m3§;
|
import alternativa.physics.collision.primitives.CollisionBox;
|
||||||
|
|
||||||
public class §_-hu§ extends §_-dj§
|
public class BoxTriangleCollider extends BoxCollider
|
||||||
{
|
{
|
||||||
public var epsilon:Number = 0.001;
|
public var epsilon:Number = 0.001;
|
||||||
|
|
||||||
@@ -16,58 +16,58 @@ package §while§
|
|||||||
|
|
||||||
private var §_-hK§:Number;
|
private var §_-hK§:Number;
|
||||||
|
|
||||||
private var toBox:§_-bj§ = new §_-bj§();
|
private var toBox:Vector3 = new Vector3();
|
||||||
|
|
||||||
private var axis:§_-bj§ = new §_-bj§();
|
private var axis:Vector3 = new Vector3();
|
||||||
|
|
||||||
private var §_-VZ§:§_-bj§ = new §_-bj§();
|
private var §_-VZ§:Vector3 = new Vector3();
|
||||||
|
|
||||||
private var axis10:§_-bj§ = new §_-bj§();
|
private var axis10:Vector3 = new Vector3();
|
||||||
|
|
||||||
private var axis11:§_-bj§ = new §_-bj§();
|
private var axis11:Vector3 = new Vector3();
|
||||||
|
|
||||||
private var axis12:§_-bj§ = new §_-bj§();
|
private var axis12:Vector3 = new Vector3();
|
||||||
|
|
||||||
private var axis20:§_-bj§ = new §_-bj§();
|
private var axis20:Vector3 = new Vector3();
|
||||||
|
|
||||||
private var axis21:§_-bj§ = new §_-bj§();
|
private var axis21:Vector3 = new Vector3();
|
||||||
|
|
||||||
private var axis22:§_-bj§ = new §_-bj§();
|
private var axis22:Vector3 = new Vector3();
|
||||||
|
|
||||||
private var points1:Vector.<§_-bj§> = new Vector.<§_-bj§>(8,true);
|
private var points1:Vector.<Vector3> = new Vector.<Vector3>(8,true);
|
||||||
|
|
||||||
private var points2:Vector.<§_-bj§> = new Vector.<§_-bj§>(8,true);
|
private var points2:Vector.<Vector3> = new Vector.<Vector3>(8,true);
|
||||||
|
|
||||||
public function §_-hu§()
|
public function BoxTriangleCollider()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
for(var i:int = 0; i < 8; i++)
|
for(var i:int = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
this.points1[i] = new §_-bj§();
|
this.points1[i] = new Vector3();
|
||||||
this.points2[i] = new §_-bj§();
|
this.points2[i] = new Vector3();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function getContact(prim1:§_-Nh§, prim2:§_-Nh§, contact:§_-6h§) : Boolean
|
override public function getContact(prim1:CollisionPrimitive, prim2:CollisionPrimitive, contact:Contact) : Boolean
|
||||||
{
|
{
|
||||||
var box:§_-m3§ = null;
|
var box:CollisionBox = null;
|
||||||
if(!this.haveCollision(prim1,prim2))
|
if(!this.haveCollision(prim1,prim2))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var tri:§_-Pr§ = prim1 as §_-Pr§;
|
var tri:CollisionTriangle = prim1 as CollisionTriangle;
|
||||||
if(tri == null)
|
if(tri == null)
|
||||||
{
|
{
|
||||||
box = §_-m3§(prim1);
|
box = CollisionBox(prim1);
|
||||||
tri = §_-Pr§(prim2);
|
tri = CollisionTriangle(prim2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
box = §_-m3§(prim2);
|
box = CollisionBox(prim2);
|
||||||
}
|
}
|
||||||
if(this.§_-Wt§ < 4)
|
if(this.§_-Wt§ < 4)
|
||||||
{
|
{
|
||||||
if(!this.§_-NV§(box,tri,this.toBox,this.§_-Wt§,contact))
|
if(!this.findFaceContactPoints(box,tri,this.toBox,this.§_-Wt§,contact))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@ package §while§
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.§_-Wt§ -= 4;
|
this.§_-Wt§ -= 4;
|
||||||
if(!this.§_-og§(box,tri,this.toBox,this.§_-Wt§ % 3,int(this.§_-Wt§ / 3),contact))
|
if(!this.findEdgesIntersection(box,tri,this.toBox,this.§_-Wt§ % 3,int(this.§_-Wt§ / 3),contact))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -91,21 +91,21 @@ package §while§
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function haveCollision(prim1:§_-Nh§, prim2:§_-Nh§) : Boolean
|
override public function haveCollision(prim1:CollisionPrimitive, prim2:CollisionPrimitive) : Boolean
|
||||||
{
|
{
|
||||||
var tri:§_-Pr§ = null;
|
var tri:CollisionTriangle = null;
|
||||||
var box:§_-m3§ = null;
|
var box:CollisionBox = null;
|
||||||
var triTransform:Matrix4 = null;
|
var triTransform:Matrix4 = null;
|
||||||
var v:§_-bj§ = null;
|
var v:Vector3 = null;
|
||||||
tri = prim1 as §_-Pr§;
|
tri = prim1 as CollisionTriangle;
|
||||||
if(tri == null)
|
if(tri == null)
|
||||||
{
|
{
|
||||||
box = §_-m3§(prim1);
|
box = CollisionBox(prim1);
|
||||||
tri = §_-Pr§(prim2);
|
tri = CollisionTriangle(prim2);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
box = §_-m3§(prim2);
|
box = CollisionBox(prim2);
|
||||||
}
|
}
|
||||||
var boxTransform:Matrix4 = box.transform;
|
var boxTransform:Matrix4 = box.transform;
|
||||||
triTransform = tri.transform;
|
triTransform = tri.transform;
|
||||||
@@ -116,28 +116,28 @@ package §while§
|
|||||||
this.axis.x = triTransform.c;
|
this.axis.x = triTransform.c;
|
||||||
this.axis.y = triTransform.g;
|
this.axis.y = triTransform.g;
|
||||||
this.axis.z = triTransform.k;
|
this.axis.z = triTransform.k;
|
||||||
if(!this.§_-mG§(box,tri,this.axis,0,this.toBox))
|
if(!this.testMainAxis(box,tri,this.axis,0,this.toBox))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.axis10.x = boxTransform.a;
|
this.axis10.x = boxTransform.a;
|
||||||
this.axis10.y = boxTransform.e;
|
this.axis10.y = boxTransform.e;
|
||||||
this.axis10.z = boxTransform.i;
|
this.axis10.z = boxTransform.i;
|
||||||
if(!this.§_-mG§(box,tri,this.axis10,1,this.toBox))
|
if(!this.testMainAxis(box,tri,this.axis10,1,this.toBox))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.axis11.x = boxTransform.b;
|
this.axis11.x = boxTransform.b;
|
||||||
this.axis11.y = boxTransform.f;
|
this.axis11.y = boxTransform.f;
|
||||||
this.axis11.z = boxTransform.j;
|
this.axis11.z = boxTransform.j;
|
||||||
if(!this.§_-mG§(box,tri,this.axis11,2,this.toBox))
|
if(!this.testMainAxis(box,tri,this.axis11,2,this.toBox))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.axis12.x = boxTransform.c;
|
this.axis12.x = boxTransform.c;
|
||||||
this.axis12.y = boxTransform.g;
|
this.axis12.y = boxTransform.g;
|
||||||
this.axis12.z = boxTransform.k;
|
this.axis12.z = boxTransform.k;
|
||||||
if(!this.§_-mG§(box,tri,this.axis12,3,this.toBox))
|
if(!this.testMainAxis(box,tri,this.axis12,3,this.toBox))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -145,15 +145,15 @@ package §while§
|
|||||||
this.axis20.x = triTransform.a * v.x + triTransform.b * v.y + triTransform.c * v.z;
|
this.axis20.x = triTransform.a * v.x + triTransform.b * v.y + triTransform.c * v.z;
|
||||||
this.axis20.y = triTransform.e * v.x + triTransform.f * v.y + triTransform.g * v.z;
|
this.axis20.y = triTransform.e * v.x + triTransform.f * v.y + triTransform.g * v.z;
|
||||||
this.axis20.z = triTransform.i * v.x + triTransform.j * v.y + triTransform.k * v.z;
|
this.axis20.z = triTransform.i * v.x + triTransform.j * v.y + triTransform.k * v.z;
|
||||||
if(!this.§_-kt§(box,tri,this.axis10,this.axis20,4,this.toBox))
|
if(!this.testDerivedAxis(box,tri,this.axis10,this.axis20,4,this.toBox))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!this.§_-kt§(box,tri,this.axis11,this.axis20,5,this.toBox))
|
if(!this.testDerivedAxis(box,tri,this.axis11,this.axis20,5,this.toBox))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!this.§_-kt§(box,tri,this.axis12,this.axis20,6,this.toBox))
|
if(!this.testDerivedAxis(box,tri,this.axis12,this.axis20,6,this.toBox))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -161,15 +161,15 @@ package §while§
|
|||||||
this.axis21.x = triTransform.a * v.x + triTransform.b * v.y + triTransform.c * v.z;
|
this.axis21.x = triTransform.a * v.x + triTransform.b * v.y + triTransform.c * v.z;
|
||||||
this.axis21.y = triTransform.e * v.x + triTransform.f * v.y + triTransform.g * v.z;
|
this.axis21.y = triTransform.e * v.x + triTransform.f * v.y + triTransform.g * v.z;
|
||||||
this.axis21.z = triTransform.i * v.x + triTransform.j * v.y + triTransform.k * v.z;
|
this.axis21.z = triTransform.i * v.x + triTransform.j * v.y + triTransform.k * v.z;
|
||||||
if(!this.§_-kt§(box,tri,this.axis10,this.axis21,7,this.toBox))
|
if(!this.testDerivedAxis(box,tri,this.axis10,this.axis21,7,this.toBox))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!this.§_-kt§(box,tri,this.axis11,this.axis21,8,this.toBox))
|
if(!this.testDerivedAxis(box,tri,this.axis11,this.axis21,8,this.toBox))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!this.§_-kt§(box,tri,this.axis12,this.axis21,9,this.toBox))
|
if(!this.testDerivedAxis(box,tri,this.axis12,this.axis21,9,this.toBox))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -177,24 +177,24 @@ package §while§
|
|||||||
this.axis22.x = triTransform.a * v.x + triTransform.b * v.y + triTransform.c * v.z;
|
this.axis22.x = triTransform.a * v.x + triTransform.b * v.y + triTransform.c * v.z;
|
||||||
this.axis22.y = triTransform.e * v.x + triTransform.f * v.y + triTransform.g * v.z;
|
this.axis22.y = triTransform.e * v.x + triTransform.f * v.y + triTransform.g * v.z;
|
||||||
this.axis22.z = triTransform.i * v.x + triTransform.j * v.y + triTransform.k * v.z;
|
this.axis22.z = triTransform.i * v.x + triTransform.j * v.y + triTransform.k * v.z;
|
||||||
if(!this.§_-kt§(box,tri,this.axis10,this.axis22,10,this.toBox))
|
if(!this.testDerivedAxis(box,tri,this.axis10,this.axis22,10,this.toBox))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!this.§_-kt§(box,tri,this.axis11,this.axis22,11,this.toBox))
|
if(!this.testDerivedAxis(box,tri,this.axis11,this.axis22,11,this.toBox))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if(!this.§_-kt§(box,tri,this.axis12,this.axis22,12,this.toBox))
|
if(!this.testDerivedAxis(box,tri,this.axis12,this.axis22,12,this.toBox))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-mG§(box:§_-m3§, tri:§_-Pr§, axis:§_-bj§, axisIndex:int, toBox:§_-bj§) : Boolean
|
private function testMainAxis(box:CollisionBox, tri:CollisionTriangle, axis:Vector3, axisIndex:int, toBox:Vector3) : Boolean
|
||||||
{
|
{
|
||||||
var overlap:Number = this.§true§(box,tri,axis,toBox);
|
var overlap:Number = this.overlapOnAxis(box,tri,axis,toBox);
|
||||||
if(overlap < -this.epsilon)
|
if(overlap < -this.epsilon)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -207,7 +207,7 @@ package §while§
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-kt§(box:§_-m3§, tri:§_-Pr§, axis1:§_-bj§, axis2:§_-bj§, axisIndex:int, toBox:§_-bj§) : Boolean
|
private function testDerivedAxis(box:CollisionBox, tri:CollisionTriangle, axis1:Vector3, axis2:Vector3, axisIndex:int, toBox:Vector3) : Boolean
|
||||||
{
|
{
|
||||||
var k:Number = NaN;
|
var k:Number = NaN;
|
||||||
this.axis.x = axis1.y * axis2.z - axis1.z * axis2.y;
|
this.axis.x = axis1.y * axis2.z - axis1.z * axis2.y;
|
||||||
@@ -222,7 +222,7 @@ package §while§
|
|||||||
this.axis.x *= k;
|
this.axis.x *= k;
|
||||||
this.axis.y *= k;
|
this.axis.y *= k;
|
||||||
this.axis.z *= k;
|
this.axis.z *= k;
|
||||||
var overlap:Number = this.§true§(box,tri,this.axis,toBox);
|
var overlap:Number = this.overlapOnAxis(box,tri,this.axis,toBox);
|
||||||
if(overlap < -this.epsilon)
|
if(overlap < -this.epsilon)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -235,7 +235,7 @@ package §while§
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §true§(box:§_-m3§, tri:§_-Pr§, axis:§_-bj§, toBox:§_-bj§) : Number
|
private function overlapOnAxis(box:CollisionBox, tri:CollisionTriangle, axis:Vector3, toBox:Vector3) : Number
|
||||||
{
|
{
|
||||||
var t:Matrix4 = box.transform;
|
var t:Matrix4 = box.transform;
|
||||||
var projection:Number = (t.a * axis.x + t.e * axis.y + t.i * axis.z) * box.hs.x;
|
var projection:Number = (t.a * axis.x + t.e * axis.y + t.i * axis.z) * box.hs.x;
|
||||||
@@ -294,23 +294,23 @@ package §while§
|
|||||||
return projection + max - vectorProjection;
|
return projection + max - vectorProjection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-NV§(box:§_-m3§, tri:§_-Pr§, toBox:§_-bj§, faceAxisIndex:int, contact:§_-6h§) : Boolean
|
private function findFaceContactPoints(box:CollisionBox, tri:CollisionTriangle, toBox:Vector3, faceAxisIndex:int, contact:Contact) : Boolean
|
||||||
{
|
{
|
||||||
if(faceAxisIndex == 0)
|
if(faceAxisIndex == 0)
|
||||||
{
|
{
|
||||||
return this.§_-hz§(box,tri,toBox,contact);
|
return this.getBoxToTriContact(box,tri,toBox,contact);
|
||||||
}
|
}
|
||||||
return this.§_-C-§(box,tri,toBox,faceAxisIndex,contact);
|
return this.getTriToBoxContact(box,tri,toBox,faceAxisIndex,contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-hz§(box:§_-m3§, tri:§_-Pr§, toBox:§_-bj§, contact:§_-6h§) : Boolean
|
private function getBoxToTriContact(box:CollisionBox, tri:CollisionTriangle, toBox:Vector3, contact:Contact) : Boolean
|
||||||
{
|
{
|
||||||
var cp:§_-cR§ = null;
|
var cp:ContactPoint = null;
|
||||||
var dot:Number = NaN;
|
var dot:Number = NaN;
|
||||||
var absDot:Number = NaN;
|
var absDot:Number = NaN;
|
||||||
var v:§_-bj§ = null;
|
var v:Vector3 = null;
|
||||||
var cpPos:§_-bj§ = null;
|
var cpPos:Vector3 = null;
|
||||||
var r:§_-bj§ = null;
|
var r:Vector3 = null;
|
||||||
var boxTransform:Matrix4 = box.transform;
|
var boxTransform:Matrix4 = box.transform;
|
||||||
var triTransform:Matrix4 = tri.transform;
|
var triTransform:Matrix4 = tri.transform;
|
||||||
this.§_-VZ§.x = triTransform.c;
|
this.§_-VZ§.x = triTransform.c;
|
||||||
@@ -343,7 +343,7 @@ package §while§
|
|||||||
§_-ho§(box.hs,incFaceAxisIdx,negativeFace,this.points1);
|
§_-ho§(box.hs,incFaceAxisIdx,negativeFace,this.points1);
|
||||||
boxTransform.§_-ZK§(this.points1,this.points2,4);
|
boxTransform.§_-ZK§(this.points1,this.points2,4);
|
||||||
triTransform.§_-iX§(this.points2,this.points1,4);
|
triTransform.§_-iX§(this.points2,this.points1,4);
|
||||||
var pnum:int = this.§_-MQ§(tri);
|
var pnum:int = this.clipByTriangle(tri);
|
||||||
contact.§_-P3§ = 0;
|
contact.§_-P3§ = 0;
|
||||||
for(var i:int = 0; i < pnum; )
|
for(var i:int = 0; i < pnum; )
|
||||||
{
|
{
|
||||||
@@ -373,12 +373,12 @@ package §while§
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-C-§(box:§_-m3§, tri:§_-Pr§, toBox:§_-bj§, faceAxisIdx:int, contact:§_-6h§) : Boolean
|
private function getTriToBoxContact(box:CollisionBox, tri:CollisionTriangle, toBox:Vector3, faceAxisIdx:int, contact:Contact) : Boolean
|
||||||
{
|
{
|
||||||
var penetration:Number = NaN;
|
var penetration:Number = NaN;
|
||||||
var cp:§_-cR§ = null;
|
var cp:ContactPoint = null;
|
||||||
var cpPos:§_-bj§ = null;
|
var cpPos:Vector3 = null;
|
||||||
var r:§_-bj§ = null;
|
var r:Vector3 = null;
|
||||||
faceAxisIdx--;
|
faceAxisIdx--;
|
||||||
var boxTransform:Matrix4 = box.transform;
|
var boxTransform:Matrix4 = box.transform;
|
||||||
var triTransform:Matrix4 = tri.transform;
|
var triTransform:Matrix4 = tri.transform;
|
||||||
@@ -390,7 +390,7 @@ package §while§
|
|||||||
this.§_-VZ§.y = -this.§_-VZ§.y;
|
this.§_-VZ§.y = -this.§_-VZ§.y;
|
||||||
this.§_-VZ§.z = -this.§_-VZ§.z;
|
this.§_-VZ§.z = -this.§_-VZ§.z;
|
||||||
}
|
}
|
||||||
var v:§_-bj§ = this.points1[0];
|
var v:Vector3 = this.points1[0];
|
||||||
v.x = tri.v0.x;
|
v.x = tri.v0.x;
|
||||||
v.y = tri.v0.y;
|
v.y = tri.v0.y;
|
||||||
v.z = tri.v0.z;
|
v.z = tri.v0.z;
|
||||||
@@ -404,12 +404,12 @@ package §while§
|
|||||||
v.z = tri.v2.z;
|
v.z = tri.v2.z;
|
||||||
triTransform.§_-ZK§(this.points1,this.points2,3);
|
triTransform.§_-ZK§(this.points1,this.points2,3);
|
||||||
boxTransform.§_-iX§(this.points2,this.points1,3);
|
boxTransform.§_-iX§(this.points2,this.points1,3);
|
||||||
var pnum:int = this.§_-kk§(box.hs,faceAxisIdx);
|
var pnum:int = this.clipByBox(box.hs,faceAxisIdx);
|
||||||
contact.§_-P3§ = 0;
|
contact.§_-P3§ = 0;
|
||||||
for(var i:int = 0; i < pnum; )
|
for(var i:int = 0; i < pnum; )
|
||||||
{
|
{
|
||||||
v = this.points1[i];
|
v = this.points1[i];
|
||||||
penetration = this.§_-iN§(box.hs,v,faceAxisIdx,negativeFace);
|
penetration = this.getPointBoxPenetration(box.hs,v,faceAxisIdx,negativeFace);
|
||||||
if(penetration > -this.epsilon)
|
if(penetration > -this.epsilon)
|
||||||
{
|
{
|
||||||
cp = contact.points[contact.§_-P3§++];
|
cp = contact.points[contact.§_-P3§++];
|
||||||
@@ -435,7 +435,7 @@ package §while§
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-iN§(hs:§_-bj§, p:§_-bj§, faceAxisIdx:int, negativeFace:Boolean) : Number
|
private function getPointBoxPenetration(hs:Vector3, p:Vector3, faceAxisIdx:int, negativeFace:Boolean) : Number
|
||||||
{
|
{
|
||||||
switch(faceAxisIdx)
|
switch(faceAxisIdx)
|
||||||
{
|
{
|
||||||
@@ -465,7 +465,7 @@ package §while§
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-kk§(hs:§_-bj§, faceAxisIdx:int) : int
|
private function clipByBox(hs:Vector3, faceAxisIdx:int) : int
|
||||||
{
|
{
|
||||||
var pnum:int = 3;
|
var pnum:int = 3;
|
||||||
switch(faceAxisIdx)
|
switch(faceAxisIdx)
|
||||||
@@ -529,32 +529,32 @@ package §while§
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-MQ§(tri:§_-Pr§) : int
|
private function clipByTriangle(tri:CollisionTriangle) : int
|
||||||
{
|
{
|
||||||
var vnum:int = 4;
|
var vnum:int = 4;
|
||||||
vnum = this.§_-NG§(tri.v0,tri.e0,this.points1,vnum,this.points2);
|
vnum = this.clipByLine(tri.v0,tri.e0,this.points1,vnum,this.points2);
|
||||||
if(vnum == 0)
|
if(vnum == 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
vnum = this.§_-NG§(tri.v1,tri.e1,this.points2,vnum,this.points1);
|
vnum = this.clipByLine(tri.v1,tri.e1,this.points2,vnum,this.points1);
|
||||||
if(vnum == 0)
|
if(vnum == 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return this.§_-NG§(tri.v2,tri.e2,this.points1,vnum,this.points2);
|
return this.clipByLine(tri.v2,tri.e2,this.points1,vnum,this.points2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-NG§(linePoint:§_-bj§, lineDir:§_-bj§, verticesIn:Vector.<§_-bj§>, vnum:int, verticesOut:Vector.<§_-bj§>) : int
|
private function clipByLine(linePoint:Vector3, lineDir:Vector3, verticesIn:Vector.<Vector3>, vnum:int, verticesOut:Vector.<Vector3>) : int
|
||||||
{
|
{
|
||||||
var t:Number = NaN;
|
var t:Number = NaN;
|
||||||
var v:§_-bj§ = null;
|
var v:Vector3 = null;
|
||||||
var v2:§_-bj§ = null;
|
var v2:Vector3 = null;
|
||||||
var offset2:Number = NaN;
|
var offset2:Number = NaN;
|
||||||
var nx:Number = -lineDir.y;
|
var nx:Number = -lineDir.y;
|
||||||
var ny:Number = Number(lineDir.x);
|
var ny:Number = Number(lineDir.x);
|
||||||
var offset:Number = linePoint.x * nx + linePoint.y * ny;
|
var offset:Number = linePoint.x * nx + linePoint.y * ny;
|
||||||
var v1:§_-bj§ = verticesIn[int(vnum - 1)];
|
var v1:Vector3 = verticesIn[int(vnum - 1)];
|
||||||
var offset1:Number = v1.x * nx + v1.y * ny;
|
var offset1:Number = v1.x * nx + v1.y * ny;
|
||||||
var num:int = 0;
|
var num:int = 0;
|
||||||
for(var i:int = 0; i < vnum; i++)
|
for(var i:int = 0; i < vnum; i++)
|
||||||
@@ -596,7 +596,7 @@ package §while§
|
|||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-og§(box:§_-m3§, tri:§_-Pr§, toBox:§_-bj§, boxAxisIdx:int, triAxisIdx:int, contact:§_-6h§) : Boolean
|
private function findEdgesIntersection(box:CollisionBox, tri:CollisionTriangle, toBox:Vector3, boxAxisIdx:int, triAxisIdx:int, contact:Contact) : Boolean
|
||||||
{
|
{
|
||||||
var tmpx1:Number = NaN;
|
var tmpx1:Number = NaN;
|
||||||
var tmpy1:Number = NaN;
|
var tmpy1:Number = NaN;
|
||||||
@@ -641,7 +641,7 @@ package §while§
|
|||||||
var z2:Number = triTransform.i * tmpx2 + triTransform.j * tmpy2 + triTransform.k * tmpz2 + triTransform.l;
|
var z2:Number = triTransform.i * tmpx2 + triTransform.j * tmpy2 + triTransform.k * tmpz2 + triTransform.l;
|
||||||
var boxTransform:Matrix4 = box.transform;
|
var boxTransform:Matrix4 = box.transform;
|
||||||
boxTransform.getAxis(boxAxisIdx,this.axis10);
|
boxTransform.getAxis(boxAxisIdx,this.axis10);
|
||||||
var v:§_-bj§ = contact.normal;
|
var v:Vector3 = contact.normal;
|
||||||
v.x = this.axis10.y * this.axis20.z - this.axis10.z * this.axis20.y;
|
v.x = this.axis10.y * this.axis20.z - this.axis10.z * this.axis20.y;
|
||||||
v.y = this.axis10.z * this.axis20.x - this.axis10.x * this.axis20.z;
|
v.y = this.axis10.z * this.axis20.x - this.axis10.x * this.axis20.z;
|
||||||
v.z = this.axis10.x * this.axis20.y - this.axis10.y * this.axis20.x;
|
v.z = this.axis10.x * this.axis20.y - this.axis10.y * this.axis20.x;
|
||||||
@@ -698,13 +698,13 @@ package §while§
|
|||||||
var t1:Number = (c2 * k - c1) / det;
|
var t1:Number = (c2 * k - c1) / det;
|
||||||
var t2:Number = (c2 - c1 * k) / det;
|
var t2:Number = (c2 - c1 * k) / det;
|
||||||
contact.§_-P3§ = 1;
|
contact.§_-P3§ = 1;
|
||||||
var cp:§_-cR§ = contact.points[0];
|
var cp:ContactPoint = contact.points[0];
|
||||||
cp.penetration = this.§_-hK§;
|
cp.penetration = this.§_-hK§;
|
||||||
v = cp.pos;
|
v = cp.pos;
|
||||||
v.x = 0.5 * (x1 + this.axis10.x * t1 + x2 + this.axis20.x * t2);
|
v.x = 0.5 * (x1 + this.axis10.x * t1 + x2 + this.axis20.x * t2);
|
||||||
v.y = 0.5 * (y1 + this.axis10.y * t1 + y2 + this.axis20.y * t2);
|
v.y = 0.5 * (y1 + this.axis10.y * t1 + y2 + this.axis20.y * t2);
|
||||||
v.z = 0.5 * (z1 + this.axis10.z * t1 + z2 + this.axis20.z * t2);
|
v.z = 0.5 * (z1 + this.axis10.z * t1 + z2 + this.axis20.z * t2);
|
||||||
var r:§_-bj§ = cp.r1;
|
var r:Vector3 = cp.r1;
|
||||||
r.x = v.x - boxTransform.d;
|
r.x = v.x - boxTransform.d;
|
||||||
r.y = v.y - boxTransform.h;
|
r.y = v.y - boxTransform.h;
|
||||||
r.z = v.z - boxTransform.l;
|
r.z = v.z - boxTransform.l;
|
||||||
@@ -1,21 +1,21 @@
|
|||||||
package §_-pe§
|
package alternativa.physics.collision.primitives
|
||||||
{
|
{
|
||||||
import §_-1e§.§_-Nh§;
|
import alternativa.physics.collision.CollisionPrimitive;
|
||||||
import §_-KA§.§_-FW§;
|
import alternativa.physics.collision.types.BoundBox;
|
||||||
import §_-nl§.Matrix4;
|
import alternativa.math.Matrix4;
|
||||||
import §_-nl§.§_-bj§;
|
import alternativa.math.Vector3;
|
||||||
|
|
||||||
public class §_-m3§ extends §_-Nh§
|
public class CollisionBox extends CollisionPrimitive
|
||||||
{
|
{
|
||||||
public var hs:§_-bj§ = new §_-bj§();
|
public var hs:Vector3 = new Vector3();
|
||||||
|
|
||||||
public function §_-m3§(hs:§_-bj§, collisionGroup:int, collisionMask:int)
|
public function CollisionBox(hs:Vector3, collisionGroup:int, collisionMask:int)
|
||||||
{
|
{
|
||||||
super(BOX,collisionGroup,collisionMask);
|
super(BOX,collisionGroup,collisionMask);
|
||||||
this.hs.copy(hs);
|
this.hs.copy(hs);
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function calculateAABB() : §_-FW§
|
override public function calculateAABB() : BoundBox
|
||||||
{
|
{
|
||||||
var t:Matrix4 = null;
|
var t:Matrix4 = null;
|
||||||
var xx:Number = NaN;
|
var xx:Number = NaN;
|
||||||
@@ -46,9 +46,9 @@ package §_-pe§
|
|||||||
return aabb;
|
return aabb;
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function copyFrom(source:§_-Nh§) : §_-Nh§
|
override public function copyFrom(source:CollisionPrimitive) : CollisionPrimitive
|
||||||
{
|
{
|
||||||
var box:§_-m3§ = source as §_-m3§;
|
var box:CollisionBox = source as CollisionBox;
|
||||||
if(box == null)
|
if(box == null)
|
||||||
{
|
{
|
||||||
return this;
|
return this;
|
||||||
@@ -58,12 +58,12 @@ package §_-pe§
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected function createPrimitive() : §_-Nh§
|
override protected function createPrimitive() : CollisionPrimitive
|
||||||
{
|
{
|
||||||
return new §_-m3§(this.hs,collisionGroup,collisionMask);
|
return new CollisionBox(this.hs,collisionGroup,collisionMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
override public function raycast(origin:§_-bj§, vector:§_-bj§, epsilon:Number, normal:§_-bj§) : Number
|
override public function raycast(origin:Vector3, vector:Vector3, epsilon:Number, normal:Vector3) : Number
|
||||||
{
|
{
|
||||||
var t1:Number = NaN;
|
var t1:Number = NaN;
|
||||||
var t2:Number = NaN;
|
var t2:Number = NaN;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package §_-KA§
|
package alternativa.physics.collision.types
|
||||||
{
|
{
|
||||||
import §_-nl§.§_-bj§;
|
import alternativa.math.Vector3;
|
||||||
|
|
||||||
public class §_-FW§
|
public class BoundBox
|
||||||
{
|
{
|
||||||
public var minX:Number = 1e+308;
|
public var minX:Number = 1e+308;
|
||||||
|
|
||||||
@@ -16,12 +16,12 @@ package §_-KA§
|
|||||||
|
|
||||||
public var maxZ:Number = -1e+308;
|
public var maxZ:Number = -1e+308;
|
||||||
|
|
||||||
public function §_-FW§()
|
public function BoundBox()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-k2§(minX:Number, minY:Number, minZ:Number, maxX:Number, maxY:Number, maxZ:Number) : void
|
public function setSize(minX:Number, minY:Number, minZ:Number, maxX:Number, maxY:Number, maxZ:Number) : void
|
||||||
{
|
{
|
||||||
this.minX = minX;
|
this.minX = minX;
|
||||||
this.minY = minY;
|
this.minY = minY;
|
||||||
@@ -31,7 +31,7 @@ package §_-KA§
|
|||||||
this.maxZ = maxZ;
|
this.maxZ = maxZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-Gd§(delta:Number) : void
|
public function increase(delta:Number) : void
|
||||||
{
|
{
|
||||||
this.minX -= delta;
|
this.minX -= delta;
|
||||||
this.minY -= delta;
|
this.minY -= delta;
|
||||||
@@ -41,7 +41,7 @@ package §_-KA§
|
|||||||
this.maxZ += delta;
|
this.maxZ += delta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-EH§(boundBox:§_-FW§) : void
|
public function addBoundBox(boundBox:BoundBox) : void
|
||||||
{
|
{
|
||||||
this.minX = boundBox.minX < this.minX ? boundBox.minX : this.minX;
|
this.minX = boundBox.minX < this.minX ? boundBox.minX : this.minX;
|
||||||
this.minY = boundBox.minY < this.minY ? boundBox.minY : this.minY;
|
this.minY = boundBox.minY < this.minY ? boundBox.minY : this.minY;
|
||||||
@@ -51,7 +51,7 @@ package §_-KA§
|
|||||||
this.maxZ = boundBox.maxZ > this.maxZ ? boundBox.maxZ : this.maxZ;
|
this.maxZ = boundBox.maxZ > this.maxZ ? boundBox.maxZ : this.maxZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-aW§(x:Number, y:Number, z:Number) : void
|
public function addPoint(x:Number, y:Number, z:Number) : void
|
||||||
{
|
{
|
||||||
if(x < this.minX)
|
if(x < this.minX)
|
||||||
{
|
{
|
||||||
@@ -79,7 +79,7 @@ package §_-KA§
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-GT§() : void
|
public function infinity() : void
|
||||||
{
|
{
|
||||||
this.minX = 1e+308;
|
this.minX = 1e+308;
|
||||||
this.minY = 1e+308;
|
this.minY = 1e+308;
|
||||||
@@ -89,32 +89,32 @@ package §_-KA§
|
|||||||
this.maxZ = -1e+308;
|
this.maxZ = -1e+308;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function intersects(bb:§_-FW§, epsilon:Number) : Boolean
|
public function intersects(bb:BoundBox, epsilon:Number) : Boolean
|
||||||
{
|
{
|
||||||
return !(this.minX > bb.maxX + epsilon || this.maxX < bb.minX - epsilon || this.minY > bb.maxY + epsilon || this.maxY < bb.minY - epsilon || this.minZ > bb.maxZ + epsilon || this.maxZ < bb.minZ - epsilon);
|
return !(this.minX > bb.maxX + epsilon || this.maxX < bb.minX - epsilon || this.minY > bb.maxY + epsilon || this.maxY < bb.minY - epsilon || this.minZ > bb.maxZ + epsilon || this.maxZ < bb.minZ - epsilon);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-Wu§(point:§_-bj§, epsilon:Number) : Boolean
|
public function containsPoint(point:Vector3, epsilon:Number) : Boolean
|
||||||
{
|
{
|
||||||
return point.x > this.minX - epsilon && point.x < this.maxX + epsilon && point.y > this.minY - epsilon && point.y < this.maxY + epsilon && point.z > this.minZ - epsilon && point.z < this.maxZ + epsilon;
|
return point.x > this.minX - epsilon && point.x < this.maxX + epsilon && point.y > this.minY - epsilon && point.y < this.maxY + epsilon && point.z > this.minZ - epsilon && point.z < this.maxZ + epsilon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-ot§() : Number
|
public function getSizeX() : Number
|
||||||
{
|
{
|
||||||
return this.maxX - this.minX;
|
return this.maxX - this.minX;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-jP§() : Number
|
public function getSizeY() : Number
|
||||||
{
|
{
|
||||||
return this.maxY - this.minY;
|
return this.maxY - this.minY;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-Ix§() : Number
|
public function getSizeZ() : Number
|
||||||
{
|
{
|
||||||
return this.maxZ - this.minZ;
|
return this.maxZ - this.minZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function copyFrom(boundBox:§_-FW§) : void
|
public function copyFrom(boundBox:BoundBox) : void
|
||||||
{
|
{
|
||||||
this.minX = boundBox.minX;
|
this.minX = boundBox.minX;
|
||||||
this.minY = boundBox.minY;
|
this.minY = boundBox.minY;
|
||||||
@@ -124,9 +124,9 @@ package §_-KA§
|
|||||||
this.maxZ = boundBox.maxZ;
|
this.maxZ = boundBox.maxZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function clone() : §_-FW§
|
public function clone() : BoundBox
|
||||||
{
|
{
|
||||||
var clone:§_-FW§ = new §_-FW§();
|
var clone:BoundBox = new BoundBox();
|
||||||
clone.copyFrom(this);
|
clone.copyFrom(this);
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ package alternativa.tanks.game.entities.map
|
|||||||
import alternativa.physics.collision.CollisionPrimitive;
|
import alternativa.physics.collision.CollisionPrimitive;
|
||||||
import alternativa.physics.collision.primitives.CollisionRect;
|
import alternativa.physics.collision.primitives.CollisionRect;
|
||||||
import alternativa.physics.collision.primitives.CollisionTriangle;
|
import alternativa.physics.collision.primitives.CollisionTriangle;
|
||||||
import alternativa.physics.collision.primitives.§_-m3§;
|
import alternativa.physics.collision.primitives.CollisionBox;
|
||||||
import alternativa.tanks.game.EntityComponent;
|
import alternativa.tanks.game.EntityComponent;
|
||||||
import alternativa.tanks.game.GameKernel;
|
import alternativa.tanks.game.GameKernel;
|
||||||
import alternativa.tanks.game.subsystems.inputsystem.KeyboardEventType;
|
import alternativa.tanks.game.subsystems.inputsystem.KeyboardEventType;
|
||||||
@@ -272,9 +272,9 @@ package alternativa.tanks.game.entities.map
|
|||||||
for(var i:int = 0; i < numCollisionPrimitives; )
|
for(var i:int = 0; i < numCollisionPrimitives; )
|
||||||
{
|
{
|
||||||
collisionPrimitive = collisionPrimitives[i];
|
collisionPrimitive = collisionPrimitives[i];
|
||||||
if(collisionPrimitive is §_-m3§)
|
if(collisionPrimitive is CollisionBox)
|
||||||
{
|
{
|
||||||
physicsVisualContainer.addChild(this.createPhysicsVisualBox(§_-m3§(collisionPrimitive),boxMaterial));
|
physicsVisualContainer.addChild(this.createPhysicsVisualBox(CollisionBox(collisionPrimitive),boxMaterial));
|
||||||
}
|
}
|
||||||
else if(collisionPrimitive is CollisionTriangle)
|
else if(collisionPrimitive is CollisionTriangle)
|
||||||
{
|
{
|
||||||
@@ -285,7 +285,7 @@ package alternativa.tanks.game.entities.map
|
|||||||
return physicsVisualContainer;
|
return physicsVisualContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createPhysicsVisualBox(collisionBox:§_-m3§, material:Material) : Box
|
private function createPhysicsVisualBox(collisionBox:CollisionBox, material:Material) : Box
|
||||||
{
|
{
|
||||||
var size:Vector3 = collisionBox.hs.clone().scale(2);
|
var size:Vector3 = collisionBox.hs.clone().scale(2);
|
||||||
var box:Box = new Box(size.x,size.y,size.z);
|
var box:Box = new Box(size.x,size.y,size.z);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ package alternativa.tanks.game.entities.tank.graphics
|
|||||||
import alternativa.math.Vector3;
|
import alternativa.math.Vector3;
|
||||||
import alternativa.physics.Body;
|
import alternativa.physics.Body;
|
||||||
import alternativa.physics.CollisionPrimitiveListItem;
|
import alternativa.physics.CollisionPrimitiveListItem;
|
||||||
import alternativa.physics.collision.primitives.§_-m3§;
|
import alternativa.physics.collision.primitives.CollisionBox;
|
||||||
import alternativa.tanks.game.EntityComponent;
|
import alternativa.tanks.game.EntityComponent;
|
||||||
import alternativa.tanks.game.GameKernel;
|
import alternativa.tanks.game.GameKernel;
|
||||||
import alternativa.tanks.game.entities.tank.TankHull;
|
import alternativa.tanks.game.entities.tank.TankHull;
|
||||||
@@ -48,7 +48,7 @@ package alternativa.tanks.game.entities.tank.graphics
|
|||||||
|
|
||||||
override public function initComponent() : void
|
override public function initComponent() : void
|
||||||
{
|
{
|
||||||
var collisionBox:§_-m3§ = null;
|
var collisionBox:CollisionBox = null;
|
||||||
var hs:Vector3 = null;
|
var hs:Vector3 = null;
|
||||||
var box:Box = null;
|
var box:Box = null;
|
||||||
var wireFrame:WireFrame = null;
|
var wireFrame:WireFrame = null;
|
||||||
@@ -58,7 +58,7 @@ package alternativa.tanks.game.entities.tank.graphics
|
|||||||
var body:Body = this.chassis.getBody();
|
var body:Body = this.chassis.getBody();
|
||||||
for(var item:CollisionPrimitiveListItem = body.collisionPrimitives.head; item != null; )
|
for(var item:CollisionPrimitiveListItem = body.collisionPrimitives.head; item != null; )
|
||||||
{
|
{
|
||||||
collisionBox = §_-m3§(item.primitive);
|
collisionBox = CollisionBox(item.primitive);
|
||||||
hs = collisionBox.hs.clone().scale(2);
|
hs = collisionBox.hs.clone().scale(2);
|
||||||
box = new Box(hs.x,hs.y,hs.z);
|
box = new Box(hs.x,hs.y,hs.z);
|
||||||
wireFrame = WireFrame.createEdges(box,16711680);
|
wireFrame = WireFrame.createEdges(box,16711680);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ package alternativa.tanks.game.entities.tank.physics.chassis.tracked.legacy
|
|||||||
import alternativa.physics.PhysicsScene;
|
import alternativa.physics.PhysicsScene;
|
||||||
import alternativa.physics.PhysicsUtils;
|
import alternativa.physics.PhysicsUtils;
|
||||||
import alternativa.physics.collision.CollisionPrimitive;
|
import alternativa.physics.collision.CollisionPrimitive;
|
||||||
import alternativa.physics.collision.primitives.§_-m3§;
|
import alternativa.physics.collision.primitives.CollisionBox;
|
||||||
import alternativa.physics.collision.types.BoundBox;
|
import alternativa.physics.collision.types.BoundBox;
|
||||||
import alternativa.tanks.game.EntityComponent;
|
import alternativa.tanks.game.EntityComponent;
|
||||||
import alternativa.tanks.game.GameEvents;
|
import alternativa.tanks.game.GameEvents;
|
||||||
@@ -243,12 +243,12 @@ package alternativa.tanks.game.entities.tank.physics.chassis.tracked.legacy
|
|||||||
{
|
{
|
||||||
var collisionPrimitive:CollisionPrimitive = null;
|
var collisionPrimitive:CollisionPrimitive = null;
|
||||||
var primitiveTransform:Matrix4 = null;
|
var primitiveTransform:Matrix4 = null;
|
||||||
boundBox.§_-GT§();
|
boundBox.infinity();
|
||||||
for each(collisionPrimitive in this.§_-DC§)
|
for each(collisionPrimitive in this.§_-DC§)
|
||||||
{
|
{
|
||||||
primitiveTransform = collisionPrimitive.transform;
|
primitiveTransform = collisionPrimitive.transform;
|
||||||
collisionPrimitive.transform = collisionPrimitive.localTransform || Matrix4.IDENTITY;
|
collisionPrimitive.transform = collisionPrimitive.localTransform || Matrix4.IDENTITY;
|
||||||
boundBox.§_-EH§(collisionPrimitive.calculateAABB());
|
boundBox.addBoundBox(collisionPrimitive.calculateAABB());
|
||||||
collisionPrimitive.transform = primitiveTransform;
|
collisionPrimitive.transform = primitiveTransform;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -613,11 +613,11 @@ package alternativa.tanks.game.entities.tank.physics.chassis.tracked.legacy
|
|||||||
private function createPrimitives(geometryData:Vector.<BoxData>, primitives:Vector.<CollisionPrimitive>, collisionGroup:int, collisionMask:int) : void
|
private function createPrimitives(geometryData:Vector.<BoxData>, primitives:Vector.<CollisionPrimitive>, collisionGroup:int, collisionMask:int) : void
|
||||||
{
|
{
|
||||||
var boxData:BoxData = null;
|
var boxData:BoxData = null;
|
||||||
var primitive:§_-m3§ = null;
|
var primitive:CollisionBox = null;
|
||||||
primitives.length = 0;
|
primitives.length = 0;
|
||||||
for each(boxData in geometryData)
|
for each(boxData in geometryData)
|
||||||
{
|
{
|
||||||
primitive = new §_-m3§(boxData.hs,collisionGroup,collisionMask);
|
primitive = new CollisionBox(boxData.hs,collisionGroup,collisionMask);
|
||||||
primitive.localTransform = boxData.matrix.clone();
|
primitive.localTransform = boxData.matrix.clone();
|
||||||
primitive.body = this.body;
|
primitive.body = this.body;
|
||||||
primitives.push(primitive);
|
primitives.push(primitive);
|
||||||
|
|||||||
@@ -1,77 +1,77 @@
|
|||||||
package §_-fT§
|
package alternativa.tanks.game.physics
|
||||||
{
|
{
|
||||||
import §_-1e§.§_-D-§;
|
import alternativa.physics.collision.CollisionKdTree;
|
||||||
import §_-1e§.§_-Nh§;
|
import alternativa.physics.collision.CollisionPrimitive;
|
||||||
import §_-1e§.§_-hG§;
|
import alternativa.physics.collision.ICollider;
|
||||||
import §_-1e§.§_-jn§;
|
import alternativa.physics.collision.IRaycastFilter;
|
||||||
import §_-1e§.§_-oZ§;
|
import alternativa.physics.collision.CollisionKdNode;
|
||||||
import §_-KA§.§_-FW§;
|
import alternativa.physics.collision.types.BoundBox;
|
||||||
import §_-KA§.§_-jr§;
|
import alternativa.physics.collision.types.RayHit;
|
||||||
import §_-US§.§_-4q§;
|
import alternativa.physics.CollisionPrimitiveListItem;
|
||||||
import §_-US§.§_-6h§;
|
import alternativa.physics.Contact;
|
||||||
import §_-US§.§_-BV§;
|
import alternativa.physics.Body;
|
||||||
import §_-US§.§_-G2§;
|
import alternativa.physics.CollisionPrimitiveList;
|
||||||
import §_-nl§.§_-bj§;
|
import alternativa.math.Vector3;
|
||||||
import §while§.§_-GQ§;
|
import alternativa.physics.collision.colliders.BoxRectCollider;
|
||||||
import §while§.§_-Ph§;
|
import alternativa.physics.collision.colliders.BoxBoxCollider;
|
||||||
import §while§.§_-hu§;
|
import alternativa.physics.collision.colliders.BoxTriangleCollider;
|
||||||
|
|
||||||
public class §_-ZI§ implements §_-Zm§
|
public class TanksCollisionDetector implements ITanksCollisionDetector
|
||||||
{
|
{
|
||||||
public var §_-bw§:§_-D-§;
|
public var §_-bw§:CollisionKdTree;
|
||||||
|
|
||||||
public var threshold:Number = 0.0001;
|
public var threshold:Number = 0.0001;
|
||||||
|
|
||||||
private var §_-P6§:Object;
|
private var §_-P6§:Object;
|
||||||
|
|
||||||
private var §_-Wj§:Vector.<§_-YY§>;
|
private var §_-Wj§:Vector.<BodyCollisionData>;
|
||||||
|
|
||||||
private var §_-LK§:int;
|
private var §_-LK§:int;
|
||||||
|
|
||||||
private var §_-By§:Vector.<§_-BV§>;
|
private var §_-By§:Vector.<Body>;
|
||||||
|
|
||||||
private var numBodies:int;
|
private var numBodies:int;
|
||||||
|
|
||||||
private var §_-qC§:MinMax = new MinMax();
|
private var §_-qC§:MinMax = new MinMax();
|
||||||
|
|
||||||
private var §_-k8§:§_-bj§ = new §_-bj§();
|
private var §_-k8§:Vector3 = new Vector3();
|
||||||
|
|
||||||
private var §_-0q§:§_-bj§ = new §_-bj§();
|
private var §_-0q§:Vector3 = new Vector3();
|
||||||
|
|
||||||
private var §_-2P§:§_-jr§ = new §_-jr§();
|
private var §_-2P§:RayHit = new RayHit();
|
||||||
|
|
||||||
private var _rayAABB:§_-FW§ = new §_-FW§();
|
private var _rayAABB:BoundBox = new BoundBox();
|
||||||
|
|
||||||
public function §_-ZI§()
|
public function TanksCollisionDetector()
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
this.§_-bw§ = new §_-D-§();
|
this.§_-bw§ = new CollisionKdTree();
|
||||||
this.§_-By§ = new Vector.<§_-BV§>();
|
this.§_-By§ = new Vector.<Body>();
|
||||||
this.§_-Wj§ = new Vector.<§_-YY§>();
|
this.§_-Wj§ = new Vector.<BodyCollisionData>();
|
||||||
this.§_-P6§ = new Object();
|
this.§_-P6§ = new Object();
|
||||||
this.§_-c2§(§_-Nh§.BOX,§_-Nh§.BOX,new §_-Ph§());
|
this.addCollider(CollisionPrimitive.BOX,CollisionPrimitive.BOX,new BoxBoxCollider());
|
||||||
this.§_-c2§(§_-Nh§.BOX,§_-Nh§.RECT,new §_-GQ§());
|
this.addCollider(CollisionPrimitive.BOX,CollisionPrimitive.RECT,new BoxRectCollider());
|
||||||
this.§_-c2§(§_-Nh§.BOX,§_-Nh§.TRIANGLE,new §_-hu§());
|
this.addCollider(CollisionPrimitive.BOX,CollisionPrimitive.TRIANGLE,new BoxTriangleCollider());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-oT§(primitive:§_-Nh§) : void
|
public function addStaticPrimitive(primitive:CollisionPrimitive) : void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-HZ§(primitive:§_-Nh§) : void
|
public function removeStaticPrimitive(primitive:CollisionPrimitive) : void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-9F§() : void
|
public function prepareForRaycasts() : void
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-Vy§(collisionPrimitives:Vector.<§_-Nh§>, boundBox:§_-FW§ = null) : void
|
public function prepareForRaycasts(collisionPrimitives:Vector.<CollisionPrimitive>, boundBox:BoundBox = null) : void
|
||||||
{
|
{
|
||||||
this.§_-bw§.§_-J9§(collisionPrimitives,boundBox);
|
this.§_-bw§.createTree(collisionPrimitives,boundBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-pN§(tankPhysicsEntry:§_-YY§) : void
|
public function addBodyCollisionData(tankPhysicsEntry:BodyCollisionData) : void
|
||||||
{
|
{
|
||||||
if(this.§_-Wj§.indexOf(tankPhysicsEntry) >= 0)
|
if(this.§_-Wj§.indexOf(tankPhysicsEntry) >= 0)
|
||||||
{
|
{
|
||||||
@@ -81,7 +81,7 @@ package §_-fT§
|
|||||||
this.§_-Wj§[_loc2_] = tankPhysicsEntry;
|
this.§_-Wj§[_loc2_] = tankPhysicsEntry;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-qP§(tankPhysicsEntry:§_-YY§) : void
|
public function removeBodyCollisionData(tankPhysicsEntry:BodyCollisionData) : void
|
||||||
{
|
{
|
||||||
var index:Number = Number(this.§_-Wj§.indexOf(tankPhysicsEntry));
|
var index:Number = Number(this.§_-Wj§.indexOf(tankPhysicsEntry));
|
||||||
if(index < 0)
|
if(index < 0)
|
||||||
@@ -92,13 +92,13 @@ package §_-fT§
|
|||||||
this.§_-Wj§[this.§_-LK§] = null;
|
this.§_-Wj§[this.§_-LK§] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-D8§(body:§_-BV§) : void
|
public function addBody(body:Body) : void
|
||||||
{
|
{
|
||||||
var _loc2_:* = this.numBodies++;
|
var _loc2_:* = this.numBodies++;
|
||||||
this.§_-By§[_loc2_] = body;
|
this.§_-By§[_loc2_] = body;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-2x§(body:§_-BV§) : void
|
public function removeBody(body:Body) : void
|
||||||
{
|
{
|
||||||
var index:int = int(this.§_-By§.indexOf(body));
|
var index:int = int(this.§_-By§.indexOf(body));
|
||||||
if(index < 0)
|
if(index < 0)
|
||||||
@@ -109,11 +109,11 @@ package §_-fT§
|
|||||||
this.§_-By§[this.numBodies] = null;
|
this.§_-By§[this.numBodies] = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-7u§(center:§_-bj§, radius:Number, filter:§_-VN§) : Vector.<§_-bB§>
|
public function getObjectsInRadius(center:Vector3, radius:Number, filter:IRadiusQueryFilter) : Vector.<BodyDistance>
|
||||||
{
|
{
|
||||||
var result:Vector.<§_-bB§> = null;
|
var result:Vector.<BodyDistance> = null;
|
||||||
var tankPhysicsEntry:§_-YY§ = null;
|
var tankPhysicsEntry:BodyCollisionData = null;
|
||||||
var position:§_-bj§ = null;
|
var position:Vector3 = null;
|
||||||
var dx:Number = NaN;
|
var dx:Number = NaN;
|
||||||
var dy:Number = NaN;
|
var dy:Number = NaN;
|
||||||
var dz:Number = NaN;
|
var dz:Number = NaN;
|
||||||
@@ -133,9 +133,9 @@ package §_-fT§
|
|||||||
{
|
{
|
||||||
if(result == null)
|
if(result == null)
|
||||||
{
|
{
|
||||||
result = new Vector.<§_-bB§>();
|
result = new Vector.<BodyDistance>();
|
||||||
}
|
}
|
||||||
result.push(new §_-bB§(tankPhysicsEntry.body,Math.sqrt(distance)));
|
result.push(new BodyDistance(tankPhysicsEntry.body,Math.sqrt(distance)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
@@ -143,18 +143,18 @@ package §_-fT§
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-63§(contact:§_-6h§) : §_-6h§
|
public function getAllContacts(contact:Contact) : Contact
|
||||||
{
|
{
|
||||||
return this.§_-Uu§(contact);
|
return this.getTankContacts(contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getContact(prim1:§_-Nh§, prim2:§_-Nh§, contact:§_-6h§) : Boolean
|
public function getContact(prim1:CollisionPrimitive, prim2:CollisionPrimitive, contact:Contact) : Boolean
|
||||||
{
|
{
|
||||||
if((prim1.collisionMask & prim2.collisionGroup) == 0 || (prim2.collisionMask & prim1.collisionGroup) == 0 || !prim1.aabb.intersects(prim2.aabb,0.01))
|
if((prim1.collisionMask & prim2.collisionGroup) == 0 || (prim2.collisionMask & prim1.collisionGroup) == 0 || !prim1.aabb.intersects(prim2.aabb,0.01))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var collider:§_-hG§ = this.§_-P6§[prim1.type | prim2.type];
|
var collider:ICollider = this.§_-P6§[prim1.type | prim2.type];
|
||||||
if(collider != null && Boolean(collider.getContact(prim1,prim2,contact)))
|
if(collider != null && Boolean(collider.getContact(prim1,prim2,contact)))
|
||||||
{
|
{
|
||||||
if(prim1.postCollisionFilter != null && !prim1.postCollisionFilter.§_-eZ§(prim1,prim2))
|
if(prim1.postCollisionFilter != null && !prim1.postCollisionFilter.§_-eZ§(prim1,prim2))
|
||||||
@@ -166,7 +166,7 @@ package §_-fT§
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-A5§(prim1:§_-Nh§, prim2:§_-Nh§) : Boolean
|
public function testCollision(prim1:CollisionPrimitive, prim2:CollisionPrimitive) : Boolean
|
||||||
{
|
{
|
||||||
if((prim1.collisionMask & prim2.collisionGroup) == 0 || (prim2.collisionMask & prim1.collisionGroup) == 0)
|
if((prim1.collisionMask & prim2.collisionGroup) == 0 || (prim2.collisionMask & prim1.collisionGroup) == 0)
|
||||||
{
|
{
|
||||||
@@ -180,7 +180,7 @@ package §_-fT§
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var collider:§_-hG§ = this.§_-P6§[prim1.type | prim2.type];
|
var collider:ICollider = this.§_-P6§[prim1.type | prim2.type];
|
||||||
if(collider != null && Boolean(collider.haveCollision(prim1,prim2)))
|
if(collider != null && Boolean(collider.haveCollision(prim1,prim2)))
|
||||||
{
|
{
|
||||||
if(prim1.postCollisionFilter != null && !prim1.postCollisionFilter.§_-eZ§(prim1,prim2))
|
if(prim1.postCollisionFilter != null && !prim1.postCollisionFilter.§_-eZ§(prim1,prim2))
|
||||||
@@ -192,10 +192,10 @@ package §_-fT§
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function raycast(origin:§_-bj§, dir:§_-bj§, collisionMask:int, maxTime:Number, filter:§_-jn§, result:§_-jr§) : Boolean
|
public function raycast(origin:Vector3, dir:Vector3, collisionMask:int, maxTime:Number, filter:IRaycastFilter, result:RayHit) : Boolean
|
||||||
{
|
{
|
||||||
var hasStaticIntersection:Boolean = this.§_-cX§(origin,dir,collisionMask,maxTime,filter,result);
|
var hasStaticIntersection:Boolean = this.raycastStatic(origin,dir,collisionMask,maxTime,filter,result);
|
||||||
var hasDynamicIntersection:Boolean = this.§_-eu§(origin,dir,collisionMask,maxTime,filter,this.§_-2P§);
|
var hasDynamicIntersection:Boolean = this.raycastTanks(origin,dir,collisionMask,maxTime,filter,this.§_-2P§);
|
||||||
if(!(hasDynamicIntersection || hasStaticIntersection))
|
if(!(hasDynamicIntersection || hasStaticIntersection))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -216,9 +216,9 @@ package §_-fT§
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-cX§(origin:§_-bj§, dir:§_-bj§, collisionMask:int, maxTime:Number, filter:§_-jn§, result:§_-jr§) : Boolean
|
public function raycastStatic(origin:Vector3, dir:Vector3, collisionMask:int, maxTime:Number, filter:IRaycastFilter, result:RayHit) : Boolean
|
||||||
{
|
{
|
||||||
if(!this.§_-oL§(origin,dir,this.§_-bw§.§_-5H§.boundBox,this.§_-qC§))
|
if(!this.getRayBoundBoxIntersection(origin,dir,this.§_-bw§.§_-5H§.boundBox,this.§_-qC§))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -243,34 +243,34 @@ package §_-fT§
|
|||||||
{
|
{
|
||||||
this.§_-qC§.max = maxTime;
|
this.§_-qC§.max = maxTime;
|
||||||
}
|
}
|
||||||
var hasIntersection:Boolean = this.§_-NC§(this.§_-bw§.§_-5H§,origin,this.§_-0q§,dir,collisionMask,this.§_-qC§.min,this.§_-qC§.max,filter,result);
|
var hasIntersection:Boolean = this.testRayAgainstNode(this.§_-bw§.§_-5H§,origin,this.§_-0q§,dir,collisionMask,this.§_-qC§.min,this.§_-qC§.max,filter,result);
|
||||||
return hasIntersection ? result.t <= maxTime : false;
|
return hasIntersection ? result.t <= maxTime : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function §_-TL§(primitive:§_-Nh§) : Boolean
|
public function testPrimitiveTreeCollision(primitive:CollisionPrimitive) : Boolean
|
||||||
{
|
{
|
||||||
return this.§_-B8§(primitive,this.§_-bw§.§_-5H§);
|
return this.testPrimitiveNodeCollision(primitive,this.§_-bw§.§_-5H§);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-c2§(type1:int, type2:int, collider:§_-hG§) : void
|
private function addCollider(type1:int, type2:int, collider:ICollider) : void
|
||||||
{
|
{
|
||||||
this.§_-P6§[type1 | type2] = collider;
|
this.§_-P6§[type1 | type2] = collider;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-Uu§(contact:§_-6h§) : §_-6h§
|
private function getTankContacts(contact:Contact) : Contact
|
||||||
{
|
{
|
||||||
var tankEntry:§_-YY§ = null;
|
var tankEntry:BodyCollisionData = null;
|
||||||
var body:§_-BV§ = null;
|
var body:Body = null;
|
||||||
var listItem:§_-4q§ = null;
|
var listItem:CollisionPrimitiveListItem = null;
|
||||||
var j:int = 0;
|
var j:int = 0;
|
||||||
var otherTankEntry:§_-YY§ = null;
|
var otherTankEntry:BodyCollisionData = null;
|
||||||
for(var i:int = 0; i < this.§_-LK§; i++)
|
for(var i:int = 0; i < this.§_-LK§; i++)
|
||||||
{
|
{
|
||||||
tankEntry = this.§_-Wj§[i];
|
tankEntry = this.§_-Wj§[i];
|
||||||
body = tankEntry.body;
|
body = tankEntry.body;
|
||||||
for(listItem = body.collisionPrimitives.head; listItem != null; )
|
for(listItem = body.collisionPrimitives.head; listItem != null; )
|
||||||
{
|
{
|
||||||
contact = this.§_-m1§(this.§_-bw§.§_-5H§,listItem.primitive,contact);
|
contact = this.getPrimitiveNodeCollisions(this.§_-bw§.§_-5H§,listItem.primitive,contact);
|
||||||
listItem = listItem.next;
|
listItem = listItem.next;
|
||||||
}
|
}
|
||||||
for(j = i + 1; j < this.§_-LK§; )
|
for(j = i + 1; j < this.§_-LK§; )
|
||||||
@@ -278,7 +278,7 @@ package §_-fT§
|
|||||||
otherTankEntry = this.§_-Wj§[j];
|
otherTankEntry = this.§_-Wj§[j];
|
||||||
if(body.aabb.intersects(otherTankEntry.body.aabb,0.1))
|
if(body.aabb.intersects(otherTankEntry.body.aabb,0.1))
|
||||||
{
|
{
|
||||||
contact = this.§_-4I§(tankEntry,otherTankEntry,contact);
|
contact = this.getTanksCollision(tankEntry,otherTankEntry,contact);
|
||||||
}
|
}
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
@@ -286,15 +286,15 @@ package §_-fT§
|
|||||||
return contact;
|
return contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-4I§(tankEntry1:§_-YY§, tankEntry2:§_-YY§, contact:§_-6h§) : §_-6h§
|
private function getTanksCollision(tankEntry1:BodyCollisionData, tankEntry2:BodyCollisionData, contact:Contact) : Contact
|
||||||
{
|
{
|
||||||
var primitive1:§_-Nh§ = null;
|
var primitive1:CollisionPrimitive = null;
|
||||||
var numSimplePrimitives2:int = 0;
|
var numSimplePrimitives2:int = 0;
|
||||||
var j:int = 0;
|
var j:int = 0;
|
||||||
var primitive2:§_-Nh§ = null;
|
var primitive2:CollisionPrimitive = null;
|
||||||
var skipCollision:Boolean = false;
|
var skipCollision:Boolean = false;
|
||||||
var body1:§_-BV§ = tankEntry1.body;
|
var body1:Body = tankEntry1.body;
|
||||||
var body2:§_-BV§ = tankEntry2.body;
|
var body2:Body = tankEntry2.body;
|
||||||
var numSimplePrimitives1:int = int(tankEntry1.simplePrimitives.length);
|
var numSimplePrimitives1:int = int(tankEntry1.simplePrimitives.length);
|
||||||
var firstFilterTest:Boolean = true;
|
var firstFilterTest:Boolean = true;
|
||||||
for(var i:int = 0; i < numSimplePrimitives1; i++)
|
for(var i:int = 0; i < numSimplePrimitives1; i++)
|
||||||
@@ -331,14 +331,14 @@ package §_-fT§
|
|||||||
return contact;
|
return contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-AX§(primitives1:§_-G2§, primitives2:§_-G2§) : Boolean
|
private function testContacts2(primitives1:CollisionPrimitiveList, primitives2:CollisionPrimitiveList) : Boolean
|
||||||
{
|
{
|
||||||
var item2:§_-4q§ = null;
|
var item2:CollisionPrimitiveListItem = null;
|
||||||
for(var item1:§_-4q§ = primitives1.head; item1 != null; )
|
for(var item1:CollisionPrimitiveListItem = primitives1.head; item1 != null; )
|
||||||
{
|
{
|
||||||
for(item2 = primitives2.head; item2 != null; )
|
for(item2 = primitives2.head; item2 != null; )
|
||||||
{
|
{
|
||||||
if(this.§_-A5§(item1.primitive,item2.primitive))
|
if(this.testCollision(item1.primitive,item2.primitive))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -349,11 +349,11 @@ package §_-fT§
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-bH§(primitives:§_-G2§) : Boolean
|
private function primitivesHaveCollision(primitives:CollisionPrimitiveList) : Boolean
|
||||||
{
|
{
|
||||||
for(var item:§_-4q§ = primitives.head; item != null; )
|
for(var item:CollisionPrimitiveListItem = primitives.head; item != null; )
|
||||||
{
|
{
|
||||||
if(this.§_-TL§(item.primitive))
|
if(this.testPrimitiveTreeCollision(item.primitive))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -362,11 +362,11 @@ package §_-fT§
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-m1§(node:§_-oZ§, primitive:§_-Nh§, contact:§_-6h§) : §_-6h§
|
private function getPrimitiveNodeCollisions(node:CollisionKdNode, primitive:CollisionPrimitive, contact:Contact) : Contact
|
||||||
{
|
{
|
||||||
var min:Number = NaN;
|
var min:Number = NaN;
|
||||||
var max:Number = NaN;
|
var max:Number = NaN;
|
||||||
var primitives:Vector.<§_-Nh§> = null;
|
var primitives:Vector.<CollisionPrimitive> = null;
|
||||||
var indices:Vector.<int> = null;
|
var indices:Vector.<int> = null;
|
||||||
var i:int = 0;
|
var i:int = 0;
|
||||||
if(node.indices != null)
|
if(node.indices != null)
|
||||||
@@ -402,24 +402,24 @@ package §_-fT§
|
|||||||
}
|
}
|
||||||
if(min < node.coord)
|
if(min < node.coord)
|
||||||
{
|
{
|
||||||
contact = this.§_-m1§(node.§_-Gm§,primitive,contact);
|
contact = this.getPrimitiveNodeCollisions(node.§_-Gm§,primitive,contact);
|
||||||
}
|
}
|
||||||
if(max > node.coord)
|
if(max > node.coord)
|
||||||
{
|
{
|
||||||
contact = this.§_-m1§(node.§_-75§,primitive,contact);
|
contact = this.getPrimitiveNodeCollisions(node.§_-75§,primitive,contact);
|
||||||
}
|
}
|
||||||
if(node.§_-da§ != null && min < node.coord && max > node.coord)
|
if(node.§_-da§ != null && min < node.coord && max > node.coord)
|
||||||
{
|
{
|
||||||
contact = this.§_-m1§(node.§_-da§.§_-5H§,primitive,contact);
|
contact = this.getPrimitiveNodeCollisions(node.§_-da§.§_-5H§,primitive,contact);
|
||||||
}
|
}
|
||||||
return contact;
|
return contact;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-B8§(primitive:§_-Nh§, node:§_-oZ§) : Boolean
|
private function testPrimitiveNodeCollision(primitive:CollisionPrimitive, node:CollisionKdNode) : Boolean
|
||||||
{
|
{
|
||||||
var min:Number = NaN;
|
var min:Number = NaN;
|
||||||
var max:Number = NaN;
|
var max:Number = NaN;
|
||||||
var primitives:Vector.<§_-Nh§> = null;
|
var primitives:Vector.<CollisionPrimitive> = null;
|
||||||
var indices:Vector.<int> = null;
|
var indices:Vector.<int> = null;
|
||||||
var i:int = 0;
|
var i:int = 0;
|
||||||
if(node.indices != null)
|
if(node.indices != null)
|
||||||
@@ -428,7 +428,7 @@ package §_-fT§
|
|||||||
indices = node.indices;
|
indices = node.indices;
|
||||||
for(i = indices.length - 1; i >= 0; )
|
for(i = indices.length - 1; i >= 0; )
|
||||||
{
|
{
|
||||||
if(this.§_-A5§(primitive,primitives[indices[i]]))
|
if(this.testCollision(primitive,primitives[indices[i]]))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -455,21 +455,21 @@ package §_-fT§
|
|||||||
}
|
}
|
||||||
if(node.§_-da§ != null && min < node.coord && max > node.coord)
|
if(node.§_-da§ != null && min < node.coord && max > node.coord)
|
||||||
{
|
{
|
||||||
if(this.§_-B8§(primitive,node.§_-da§.§_-5H§))
|
if(this.testPrimitiveNodeCollision(primitive,node.§_-da§.§_-5H§))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(min < node.coord)
|
if(min < node.coord)
|
||||||
{
|
{
|
||||||
if(this.§_-B8§(primitive,node.§_-Gm§))
|
if(this.testPrimitiveNodeCollision(primitive,node.§_-Gm§))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(max > node.coord)
|
if(max > node.coord)
|
||||||
{
|
{
|
||||||
if(this.§_-B8§(primitive,node.§_-75§))
|
if(this.testPrimitiveNodeCollision(primitive,node.§_-75§))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -477,13 +477,13 @@ package §_-fT§
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-eu§(origin:§_-bj§, dir:§_-bj§, collisionMask:int, maxTime:Number, filter:§_-jn§, result:§_-jr§) : Boolean
|
private function raycastTanks(origin:Vector3, dir:Vector3, collisionMask:int, maxTime:Number, filter:IRaycastFilter, result:RayHit) : Boolean
|
||||||
{
|
{
|
||||||
var tankPhysicsEntry:§_-YY§ = null;
|
var tankPhysicsEntry:BodyCollisionData = null;
|
||||||
var body:§_-BV§ = null;
|
var body:Body = null;
|
||||||
var aabb:§_-FW§ = null;
|
var aabb:BoundBox = null;
|
||||||
var collisionPrimitiveListItem:§_-4q§ = null;
|
var collisionPrimitiveListItem:CollisionPrimitiveListItem = null;
|
||||||
var primitive:§_-Nh§ = null;
|
var primitive:CollisionPrimitive = null;
|
||||||
var t:Number = NaN;
|
var t:Number = NaN;
|
||||||
var xx:Number = origin.x + dir.x * maxTime;
|
var xx:Number = origin.x + dir.x * maxTime;
|
||||||
var yy:Number = origin.y + dir.y * maxTime;
|
var yy:Number = origin.y + dir.y * maxTime;
|
||||||
@@ -571,7 +571,7 @@ package §_-fT§
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-oL§(origin:§_-bj§, dir:§_-bj§, bb:§_-FW§, time:MinMax) : Boolean
|
private function getRayBoundBoxIntersection(origin:Vector3, dir:Vector3, bb:BoundBox, time:MinMax) : Boolean
|
||||||
{
|
{
|
||||||
var t1:Number = NaN;
|
var t1:Number = NaN;
|
||||||
var t2:Number = NaN;
|
var t2:Number = NaN;
|
||||||
@@ -648,15 +648,15 @@ package §_-fT§
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-NC§(node:§_-oZ§, origin:§_-bj§, localOrigin:§_-bj§, dir:§_-bj§, collisionMask:int, t1:Number, t2:Number, filter:§_-jn§, result:§_-jr§) : Boolean
|
private function testRayAgainstNode(node:CollisionKdNode, origin:Vector3, localOrigin:Vector3, dir:Vector3, collisionMask:int, t1:Number, t2:Number, filter:IRaycastFilter, result:RayHit) : Boolean
|
||||||
{
|
{
|
||||||
var splitTime:Number = NaN;
|
var splitTime:Number = NaN;
|
||||||
var currChildNode:§_-oZ§ = null;
|
var currChildNode:CollisionKdNode = null;
|
||||||
var intersects:Boolean = false;
|
var intersects:Boolean = false;
|
||||||
var splitNode:§_-oZ§ = null;
|
var splitNode:CollisionKdNode = null;
|
||||||
var i:int = 0;
|
var i:int = 0;
|
||||||
var primitive:§_-Nh§ = null;
|
var primitive:CollisionPrimitive = null;
|
||||||
if(node.indices != null && this.§_-FH§(origin,dir,collisionMask,this.§_-bw§.§_-8A§,node.indices,filter,result))
|
if(node.indices != null && this.getRayNodeIntersection(origin,dir,collisionMask,this.§_-bw§.§_-8A§,node.indices,filter,result))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -701,9 +701,9 @@ package §_-fT§
|
|||||||
}
|
}
|
||||||
if(splitTime < t1 || splitTime > t2)
|
if(splitTime < t1 || splitTime > t2)
|
||||||
{
|
{
|
||||||
return this.§_-NC§(currChildNode,origin,localOrigin,dir,collisionMask,t1,t2,filter,result);
|
return this.testRayAgainstNode(currChildNode,origin,localOrigin,dir,collisionMask,t1,t2,filter,result);
|
||||||
}
|
}
|
||||||
intersects = this.§_-NC§(currChildNode,origin,localOrigin,dir,collisionMask,t1,splitTime,filter,result);
|
intersects = this.testRayAgainstNode(currChildNode,origin,localOrigin,dir,collisionMask,t1,splitTime,filter,result);
|
||||||
if(intersects)
|
if(intersects)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
@@ -751,12 +751,12 @@ package §_-fT§
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.§_-NC§(currChildNode == node.§_-Gm§ ? node.§_-75§ : node.§_-Gm§,origin,this.§_-0q§,dir,collisionMask,splitTime,t2,filter,result);
|
return this.testRayAgainstNode(currChildNode == node.§_-Gm§ ? node.§_-75§ : node.§_-Gm§,origin,this.§_-0q§,dir,collisionMask,splitTime,t2,filter,result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-FH§(origin:§_-bj§, dir:§_-bj§, collisionMask:int, primitives:Vector.<§_-Nh§>, indices:Vector.<int>, filter:§_-jn§, intersection:§_-jr§) : Boolean
|
private function getRayNodeIntersection(origin:Vector3, dir:Vector3, collisionMask:int, primitives:Vector.<CollisionPrimitive>, indices:Vector.<int>, filter:IRaycastFilter, intersection:RayHit) : Boolean
|
||||||
{
|
{
|
||||||
var primitive:§_-Nh§ = null;
|
var primitive:CollisionPrimitive = null;
|
||||||
var t:Number = NaN;
|
var t:Number = NaN;
|
||||||
var pnum:int = int(indices.length);
|
var pnum:int = int(indices.length);
|
||||||
var minTime:Number = 1e+308;
|
var minTime:Number = 1e+308;
|
||||||
@@ -791,15 +791,15 @@ package §_-fT§
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-Yu§(body1:§_-BV§, body2:§_-BV§, contact:§_-6h§) : §_-6h§
|
private function collideBodies(body1:Body, body2:Body, contact:Contact) : Contact
|
||||||
{
|
{
|
||||||
return this.§_-bO§(body1.collisionPrimitives,body2.collisionPrimitives,contact);
|
return this.getContacts2(body1.collisionPrimitives,body2.collisionPrimitives,contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function §_-bO§(primitives1:§_-G2§, primitives2:§_-G2§, contact:§_-6h§) : §_-6h§
|
private function getContacts2(primitives1:CollisionPrimitiveList, primitives2:CollisionPrimitiveList, contact:Contact) : Contact
|
||||||
{
|
{
|
||||||
var item2:§_-4q§ = null;
|
var item2:CollisionPrimitiveListItem = null;
|
||||||
for(var item1:§_-4q§ = primitives1.head; item1 != null; )
|
for(var item1:CollisionPrimitiveListItem = primitives1.head; item1 != null; )
|
||||||
{
|
{
|
||||||
for(item2 = primitives2.head; item2 != null; )
|
for(item2 = primitives2.head; item2 != null; )
|
||||||
{
|
{
|
||||||
@@ -2,9 +2,9 @@ package alternativa.tanks.game.physics
|
|||||||
{
|
{
|
||||||
import alternativa.math.Matrix4;
|
import alternativa.math.Matrix4;
|
||||||
import alternativa.math.Vector3;
|
import alternativa.math.Vector3;
|
||||||
import alternativa.physics.collision.primitives.§_-m3§;
|
import alternativa.physics.collision.primitives.CollisionBox;
|
||||||
|
|
||||||
public class TurretCollisioinBox extends §_-m3§
|
public class TurretCollisioinBox extends CollisionBox
|
||||||
{
|
{
|
||||||
public var m:Matrix4;
|
public var m:Matrix4;
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,8 @@ package alternativa.tanks.game.physics.collision.uniformgrid
|
|||||||
import alternativa.physics.collision.IRaycastFilter;
|
import alternativa.physics.collision.IRaycastFilter;
|
||||||
import alternativa.physics.collision.colliders.BoxBoxCollider;
|
import alternativa.physics.collision.colliders.BoxBoxCollider;
|
||||||
import alternativa.physics.collision.colliders.BoxRectCollider;
|
import alternativa.physics.collision.colliders.BoxRectCollider;
|
||||||
import alternativa.physics.collision.colliders.§_-hu§;
|
import alternativa.physics.collision.colliders.BoxTriangleCollider;
|
||||||
import alternativa.physics.collision.primitives.§_-m3§;
|
import alternativa.physics.collision.primitives.CollisionBox;
|
||||||
import alternativa.physics.collision.types.BoundBox;
|
import alternativa.physics.collision.types.BoundBox;
|
||||||
import alternativa.physics.collision.types.RayHit;
|
import alternativa.physics.collision.types.RayHit;
|
||||||
import alternativa.tanks.game.physics.*;
|
import alternativa.tanks.game.physics.*;
|
||||||
@@ -26,7 +26,7 @@ package alternativa.tanks.game.physics.collision.uniformgrid
|
|||||||
|
|
||||||
private static var normal:Vector3 = new Vector3();
|
private static var normal:Vector3 = new Vector3();
|
||||||
|
|
||||||
private static var collisionBox:§_-m3§ = new §_-m3§(new Vector3(),4294967295,0);
|
private static var collisionBox:CollisionBox = new CollisionBox(new Vector3(),4294967295,0);
|
||||||
|
|
||||||
private var cellSize:Number;
|
private var cellSize:Number;
|
||||||
|
|
||||||
@@ -244,15 +244,15 @@ package alternativa.tanks.game.physics.collision.uniformgrid
|
|||||||
{
|
{
|
||||||
var collisionPrimitive:CollisionPrimitive = null;
|
var collisionPrimitive:CollisionPrimitive = null;
|
||||||
this.cellSize = cellSize;
|
this.cellSize = cellSize;
|
||||||
this.§_-aq§.§_-GT§();
|
this.§_-aq§.infinity();
|
||||||
for each(collisionPrimitive in staticPrimitives)
|
for each(collisionPrimitive in staticPrimitives)
|
||||||
{
|
{
|
||||||
this.§_-aq§.§_-EH§(collisionPrimitive.calculateAABB());
|
this.§_-aq§.addBoundBox(collisionPrimitive.calculateAABB());
|
||||||
}
|
}
|
||||||
this.§_-aq§.§_-Gd§(cellSize + EPSILON);
|
this.§_-aq§.increase(cellSize + EPSILON);
|
||||||
this.numCellsX = int(this.§_-aq§.§_-ot§() / cellSize) + 1;
|
this.numCellsX = int(this.§_-aq§.getSizeX() / cellSize) + 1;
|
||||||
this.numCellsY = int(this.§_-aq§.§_-jP§() / cellSize) + 1;
|
this.numCellsY = int(this.§_-aq§.getSizeY() / cellSize) + 1;
|
||||||
this.numCellsZ = int(this.§_-aq§.§_-Ix§() / cellSize) + 1;
|
this.numCellsZ = int(this.§_-aq§.getSizeZ() / cellSize) + 1;
|
||||||
this.§_-00§ = this.numCellsX * this.numCellsY * this.numCellsZ;
|
this.§_-00§ = this.numCellsX * this.numCellsY * this.numCellsZ;
|
||||||
this.§_-aq§.maxX = this.§_-aq§.minX + this.numCellsX * cellSize;
|
this.§_-aq§.maxX = this.§_-aq§.minX + this.numCellsX * cellSize;
|
||||||
this.§_-aq§.maxY = this.§_-aq§.minY + this.numCellsY * cellSize;
|
this.§_-aq§.maxY = this.§_-aq§.minY + this.numCellsY * cellSize;
|
||||||
@@ -653,7 +653,7 @@ package alternativa.tanks.game.physics.collision.uniformgrid
|
|||||||
var axis:int = -1;
|
var axis:int = -1;
|
||||||
var entryTime:Number = 0;
|
var entryTime:Number = 0;
|
||||||
var p:Vector3 = new Vector3();
|
var p:Vector3 = new Vector3();
|
||||||
var pointInBounds:Boolean = Boolean(this.§_-aq§.§_-Wu§(origin,EPSILON));
|
var pointInBounds:Boolean = Boolean(this.§_-aq§.containsPoint(origin,EPSILON));
|
||||||
if(!pointInBounds)
|
if(!pointInBounds)
|
||||||
{
|
{
|
||||||
collisionBox.hs.reset(this.cellSize * this.numCellsX / 2,this.cellSize * this.numCellsY / 2,this.cellSize * this.numCellsZ / 2);
|
collisionBox.hs.reset(this.cellSize * this.numCellsX / 2,this.cellSize * this.numCellsY / 2,this.cellSize * this.numCellsZ / 2);
|
||||||
@@ -913,7 +913,7 @@ package alternativa.tanks.game.physics.collision.uniformgrid
|
|||||||
this.§_-P6§ = new Object();
|
this.§_-P6§ = new Object();
|
||||||
this.addCollider(CollisionPrimitive.BOX,CollisionPrimitive.BOX,new BoxBoxCollider());
|
this.addCollider(CollisionPrimitive.BOX,CollisionPrimitive.BOX,new BoxBoxCollider());
|
||||||
this.addCollider(CollisionPrimitive.BOX,CollisionPrimitive.RECT,new BoxRectCollider());
|
this.addCollider(CollisionPrimitive.BOX,CollisionPrimitive.RECT,new BoxRectCollider());
|
||||||
this.addCollider(CollisionPrimitive.BOX,CollisionPrimitive.TRIANGLE,new §_-hu§());
|
this.addCollider(CollisionPrimitive.BOX,CollisionPrimitive.TRIANGLE,new BoxTriangleCollider());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ package alternativa.tanks.game.subsystems.physicssystem
|
|||||||
import alternativa.physics.collision.types.BoundBox;
|
import alternativa.physics.collision.types.BoundBox;
|
||||||
import alternativa.tanks.game.GameTask;
|
import alternativa.tanks.game.GameTask;
|
||||||
import alternativa.tanks.game.physics.ITanksCollisionDetector;
|
import alternativa.tanks.game.physics.ITanksCollisionDetector;
|
||||||
import alternativa.tanks.game.physics.§_-ZI§;
|
import alternativa.tanks.game.physics.TanksCollisionDetector;
|
||||||
import alternativa.tanks.game.physics.collision.uniformgrid.UniformGridCollisionDetector;
|
import alternativa.tanks.game.physics.collision.uniformgrid.UniformGridCollisionDetector;
|
||||||
import alternativa.tanks.game.subsystems.deferredcommandssystem.DeferredCommand;
|
import alternativa.tanks.game.subsystems.deferredcommandssystem.DeferredCommand;
|
||||||
import alternativa.tanks.game.subsystems.timesystem.TimeSystem;
|
import alternativa.tanks.game.subsystems.timesystem.TimeSystem;
|
||||||
@@ -64,7 +64,7 @@ package alternativa.tanks.game.subsystems.physicssystem
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
this.physicsScene.collisionDetector = new §_-ZI§();
|
this.physicsScene.collisionDetector = new TanksCollisionDetector();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ package alternativa.tanks.game.subsystems.physicssystem
|
|||||||
public function initCollisionGeometry(collisionPrimitives:Vector.<CollisionPrimitive>) : void
|
public function initCollisionGeometry(collisionPrimitives:Vector.<CollisionPrimitive>) : void
|
||||||
{
|
{
|
||||||
var gridCellSize:Number = NaN;
|
var gridCellSize:Number = NaN;
|
||||||
var _loc3_:§_-ZI§ = null;
|
var _loc3_:TanksCollisionDetector = null;
|
||||||
var _loc4_:BoundBox = null;
|
var _loc4_:BoundBox = null;
|
||||||
var _loc5_:Number = NaN;
|
var _loc5_:Number = NaN;
|
||||||
if(USE_GRID_COLLISION_DETECTOR)
|
if(USE_GRID_COLLISION_DETECTOR)
|
||||||
@@ -107,11 +107,11 @@ package alternativa.tanks.game.subsystems.physicssystem
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_loc3_ = §_-ZI§(this.physicsScene.collisionDetector);
|
_loc3_ = TanksCollisionDetector(this.physicsScene.collisionDetector);
|
||||||
_loc4_ = new BoundBox();
|
_loc4_ = new BoundBox();
|
||||||
_loc5_ = 20000;
|
_loc5_ = 20000;
|
||||||
_loc4_.setSize(-_loc5_,-_loc5_,-_loc5_,_loc5_,_loc5_,_loc5_);
|
_loc4_.setSize(-_loc5_,-_loc5_,-_loc5_,_loc5_,_loc5_,_loc5_);
|
||||||
_loc3_.§_-Vy§(collisionPrimitives,_loc4_);
|
_loc3_.prepareForRaycasts(collisionPrimitives,_loc4_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ package alternativa.tanks.game.utils
|
|||||||
import alternativa.physics.collision.CollisionPrimitive;
|
import alternativa.physics.collision.CollisionPrimitive;
|
||||||
import alternativa.physics.collision.primitives.CollisionRect;
|
import alternativa.physics.collision.primitives.CollisionRect;
|
||||||
import alternativa.physics.collision.primitives.CollisionTriangle;
|
import alternativa.physics.collision.primitives.CollisionTriangle;
|
||||||
import alternativa.physics.collision.primitives.§_-m3§;
|
import alternativa.physics.collision.primitives.CollisionBox;
|
||||||
|
|
||||||
public class PhysicsParsingUtils
|
public class PhysicsParsingUtils
|
||||||
{
|
{
|
||||||
@@ -30,7 +30,7 @@ package alternativa.tanks.game.utils
|
|||||||
halfSize.y = maxY - minY;
|
halfSize.y = maxY - minY;
|
||||||
halfSize.z = maxZ - minZ;
|
halfSize.z = maxZ - minZ;
|
||||||
halfSize.scale(0.5);
|
halfSize.scale(0.5);
|
||||||
var collisionBox:§_-m3§ = new §_-m3§(halfSize,collisionGroup,collisionMask);
|
var collisionBox:CollisionBox = new CollisionBox(halfSize,collisionGroup,collisionMask);
|
||||||
collisionBox.transform.setMatrix(mesh.x,mesh.y,mesh.z,mesh.rotationX,mesh.rotationY,mesh.rotationZ);
|
collisionBox.transform.setMatrix(mesh.x,mesh.y,mesh.z,mesh.rotationX,mesh.rotationY,mesh.rotationZ);
|
||||||
var midPoint:Vector3 = new Vector3(0.5 * (maxX + minX),0.5 * (maxY + minY),0.5 * (maxZ + minZ));
|
var midPoint:Vector3 = new Vector3(0.5 * (maxX + minX),0.5 * (maxY + minY),0.5 * (maxZ + minZ));
|
||||||
midPoint.transform4(collisionBox.transform);
|
midPoint.transform4(collisionBox.transform);
|
||||||
|
|||||||
Reference in New Issue
Block a user