@@ -101,6 +101,7 @@ module.exports = {
101
101
Quaternion : _dereq_ ( './math/Quaternion' ) ,
102
102
Ray : _dereq_ ( './collision/Ray' ) ,
103
103
RaycastVehicle : _dereq_ ( './objects/RaycastVehicle' ) ,
104
+ RaycastResult : _dereq_ ( './collision/RaycastResult' ) ,
104
105
RigidVehicle : _dereq_ ( './objects/RigidVehicle' ) ,
105
106
RotationalEquation : _dereq_ ( './equations/RotationalEquation' ) ,
106
107
RotationalMotorEquation : _dereq_ ( './equations/RotationalMotorEquation' ) ,
@@ -116,7 +117,7 @@ module.exports = {
116
117
World : _dereq_ ( './world/World' ) ,
117
118
} ;
118
119
119
- } , { "../package.json" :1 , "./collision/ArrayCollisionMatrix" :4 , "./collision/Broadphase" :5 , "./collision/GridBroadphase" :6 , "./collision/NaiveBroadphase" :7 , "./collision/ObjectCollisionMatrix" :8 , "./collision/Ray" :9 , "./collision/SAPBroadphase" :11 , "./constraints/Constraint" :12 , "./constraints/DistanceConstraint" :13 , "./constraints/HingeConstraint" :14 , "./constraints/PointToPointConstraint" :15 , "./equations/ContactEquation" :16 , "./equations/Equation" :17 , "./equations/FrictionEquation" :18 , "./equations/RotationalEquation" :19 , "./equations/RotationalMotorEquation" :20 , "./material/ContactMaterial" :21 , "./material/Material" :22 , "./math/Mat3" :24 , "./math/Quaternion" :25 , "./math/Vec3" :27 , "./objects/Body" :28 , "./objects/RaycastVehicle" :29 , "./objects/RigidVehicle" :30 , "./objects/SPHSystem" :31 , "./objects/Spring" :32 , "./shapes/Box" :34 , "./shapes/ConvexPolyhedron" :35 , "./shapes/Cylinder" :36 , "./shapes/Heightfield" :37 , "./shapes/Particle" :38 , "./shapes/Plane" :39 , "./shapes/Shape" :40 , "./shapes/Sphere" :41 , "./solver/GSSolver" :42 , "./solver/Solver" :43 , "./solver/SplitSolver" :44 , "./utils/EventTarget" :45 , "./utils/Pool" :46 , "./utils/Vec3Pool" :49 , "./world/Narrowphase" :50 , "./world/World" :51 } ] , 3 :[ function ( _dereq_ , module , exports ) {
120
+ } , { "../package.json" :1 , "./collision/ArrayCollisionMatrix" :4 , "./collision/Broadphase" :5 , "./collision/GridBroadphase" :6 , "./collision/NaiveBroadphase" :7 , "./collision/ObjectCollisionMatrix" :8 , "./collision/Ray" :9 , "./collision/RaycastResult" :10 , "./collision/SAPBroadphase" :11 , "./constraints/Constraint" :12 , "./constraints/DistanceConstraint" :13 , "./constraints/HingeConstraint" :14 , "./constraints/PointToPointConstraint" :15 , "./equations/ContactEquation" :16 , "./equations/Equation" :17 , "./equations/FrictionEquation" :18 , "./equations/RotationalEquation" :19 , "./equations/RotationalMotorEquation" :20 , "./material/ContactMaterial" :21 , "./material/Material" :22 , "./math/Mat3" :24 , "./math/Quaternion" :25 , "./math/Vec3" :27 , "./objects/Body" :28 , "./objects/RaycastVehicle" :29 , "./objects/RigidVehicle" :30 , "./objects/SPHSystem" :31 , "./objects/Spring" :32 , "./shapes/Box" :34 , "./shapes/ConvexPolyhedron" :35 , "./shapes/Cylinder" :36 , "./shapes/Heightfield" :37 , "./shapes/Particle" :38 , "./shapes/Plane" :39 , "./shapes/Shape" :40 , "./shapes/Sphere" :41 , "./solver/GSSolver" :42 , "./solver/Solver" :43 , "./solver/SplitSolver" :44 , "./utils/EventTarget" :45 , "./utils/Pool" :46 , "./utils/Vec3Pool" :49 , "./world/Narrowphase" :50 , "./world/World" :51 } ] , 3 :[ function ( _dereq_ , module , exports ) {
120
121
var Vec3 = _dereq_ ( '../math/Vec3' ) ;
121
122
var Utils = _dereq_ ( '../utils/Utils' ) ;
122
123
@@ -483,12 +484,7 @@ Broadphase.prototype.doBoundingBoxBroadphase = function(bi,bj,pairs1,pairs2){
483
484
}
484
485
485
486
// Check AABB / AABB
486
- if ( ! ( bi . aabb . upperBound . x < bj . aabb . lowerBound . x ||
487
- bi . aabb . upperBound . y < bj . aabb . lowerBound . y ||
488
- bi . aabb . upperBound . z < bj . aabb . lowerBound . z ||
489
- bi . aabb . lowerBound . x > bj . aabb . upperBound . x ||
490
- bi . aabb . lowerBound . y > bj . aabb . upperBound . y ||
491
- bi . aabb . lowerBound . z > bj . aabb . upperBound . z ) ) {
487
+ if ( bi . aabb . overlaps ( bj . aabb ) ) {
492
488
pairs1 . push ( bi ) ;
493
489
pairs2 . push ( bj ) ;
494
490
}
@@ -1657,7 +1653,7 @@ SAPBroadphase.prototype.collisionPairs = function(world,p1,p2){
1657
1653
break ;
1658
1654
}
1659
1655
1660
- this . doBoundingSphereBroadphase ( bi , bj , p1 , p2 ) ;
1656
+ this . intersectionTest ( bi , bj , p1 , p2 ) ;
1661
1657
}
1662
1658
}
1663
1659
} ;
@@ -6945,11 +6941,40 @@ Box.prototype.forEachWorldCorner = function(pos,quat,callback){
6945
6941
}
6946
6942
} ;
6947
6943
6944
+ var worldCornersTemp = [
6945
+ new Vec3 ( ) ,
6946
+ new Vec3 ( ) ,
6947
+ new Vec3 ( ) ,
6948
+ new Vec3 ( ) ,
6949
+ new Vec3 ( ) ,
6950
+ new Vec3 ( ) ,
6951
+ new Vec3 ( ) ,
6952
+ new Vec3 ( )
6953
+ ] ;
6948
6954
Box . prototype . calculateWorldAABB = function ( pos , quat , min , max ) {
6949
- // Get each axis max
6950
- min . set ( Infinity , Infinity , Infinity ) ;
6951
- max . set ( - Infinity , - Infinity , - Infinity ) ;
6952
- this . forEachWorldCorner ( pos , quat , function ( x , y , z ) {
6955
+
6956
+ var e = this . halfExtents ;
6957
+ worldCornersTemp [ 0 ] . set ( e . x , e . y , e . z ) ;
6958
+ worldCornersTemp [ 1 ] . set ( - e . x , e . y , e . z ) ;
6959
+ worldCornersTemp [ 2 ] . set ( - e . x , - e . y , e . z ) ;
6960
+ worldCornersTemp [ 3 ] . set ( - e . x , - e . y , - e . z ) ;
6961
+ worldCornersTemp [ 4 ] . set ( e . x , - e . y , - e . z ) ;
6962
+ worldCornersTemp [ 5 ] . set ( e . x , e . y , - e . z ) ;
6963
+ worldCornersTemp [ 6 ] . set ( - e . x , e . y , - e . z ) ;
6964
+ worldCornersTemp [ 7 ] . set ( e . x , - e . y , e . z ) ;
6965
+
6966
+ var wc = worldCornersTemp [ 0 ] ;
6967
+ quat . vmult ( wc , wc ) ;
6968
+ pos . vadd ( wc , wc ) ;
6969
+ max . copy ( wc ) ;
6970
+ min . copy ( wc ) ;
6971
+ for ( var i = 1 ; i < 8 ; i ++ ) {
6972
+ var wc = worldCornersTemp [ i ] ;
6973
+ quat . vmult ( wc , wc ) ;
6974
+ pos . vadd ( wc , wc ) ;
6975
+ var x = wc . x ;
6976
+ var y = wc . y ;
6977
+ var z = wc . z ;
6953
6978
if ( x > max . x ) {
6954
6979
max . x = x ;
6955
6980
}
@@ -6969,7 +6994,32 @@ Box.prototype.calculateWorldAABB = function(pos,quat,min,max){
6969
6994
if ( z < min . z ) {
6970
6995
min . z = z ;
6971
6996
}
6972
- } ) ;
6997
+ }
6998
+
6999
+ // Get each axis max
7000
+ // min.set(Infinity,Infinity,Infinity);
7001
+ // max.set(-Infinity,-Infinity,-Infinity);
7002
+ // this.forEachWorldCorner(pos,quat,function(x,y,z){
7003
+ // if(x > max.x){
7004
+ // max.x = x;
7005
+ // }
7006
+ // if(y > max.y){
7007
+ // max.y = y;
7008
+ // }
7009
+ // if(z > max.z){
7010
+ // max.z = z;
7011
+ // }
7012
+
7013
+ // if(x < min.x){
7014
+ // min.x = x;
7015
+ // }
7016
+ // if(y < min.y){
7017
+ // min.y = y;
7018
+ // }
7019
+ // if(z < min.z){
7020
+ // min.z = z;
7021
+ // }
7022
+ // });
6973
7023
} ;
6974
7024
6975
7025
} , { "../math/Vec3" :27 , "./ConvexPolyhedron" :35 , "./Shape" :40 } ] , 35 :[ function ( _dereq_ , module , exports ) {
@@ -9430,6 +9480,10 @@ Narrowphase.prototype.getContacts = function(p1,p2,world,result,oldcontacts){
9430
9480
xj . vadd ( bj . position , xj ) ;
9431
9481
var sj = bj . shapes [ j ] ;
9432
9482
9483
+ if ( xi . distanceTo ( xj ) > si . boundingSphereRadius + sj . boundingSphereRadius ) {
9484
+ break ;
9485
+ }
9486
+
9433
9487
// Get contacts
9434
9488
var resolver = this [ si . type | sj . type ] ;
9435
9489
if ( resolver ) {
@@ -10020,6 +10074,10 @@ Narrowphase.prototype.sphereConvex = function(result,si,sj,xi,xj,qi,qj,bi,bj){
10020
10074
var R = si . radius ;
10021
10075
var penetrating_sides = [ ] ;
10022
10076
10077
+ if ( convex_to_sphere . norm2 ( ) > si . boundingSphereRadius + sj . boundingSphereRadius ) {
10078
+ return ;
10079
+ }
10080
+
10023
10081
// Check corners
10024
10082
for ( var i = 0 ; i !== verts . length ; i ++ ) {
10025
10083
var v = verts [ i ] ;
@@ -10321,6 +10379,11 @@ var convexConvex_q = new Vec3();
10321
10379
Narrowphase . prototype [ Shape . types . CONVEXPOLYHEDRON ] =
10322
10380
Narrowphase . prototype . convexConvex = function ( result , si , sj , xi , xj , qi , qj , bi , bj , rsi , rsj ) {
10323
10381
var sepAxis = convexConvex_sepAxis ;
10382
+
10383
+ if ( xi . distanceTo ( xj ) > si . boundingSphereRadius + sj . boundingSphereRadius ) {
10384
+ return ;
10385
+ }
10386
+
10324
10387
if ( si . findSeparatingAxis ( sj , xi , qi , xj , qj , sepAxis ) ) {
10325
10388
var res = [ ] ;
10326
10389
var q = convexConvex_q ;
0 commit comments