Skip to content

Commit d79fcfa

Browse files
committed
Collider HashGrid Ray Casting fully implemented
A couple issues compounded the problem. Implemented a generic `castRay()` to allow for full Moller-Trumbore ray intersection. _To update collider type specific rays at a later date As of right now, `castRay()` is still gaining a lot of performance on three's Raycaster for data pre-calculations and hash grid implementation _It doesn't work on animated collision objects however
1 parent 44fb7d0 commit d79fcfa

File tree

8 files changed

+228
-307
lines changed

8 files changed

+228
-307
lines changed

Public/js/pxlNavLoader_basic.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ const enableStaticCamera = false;
6565
// Options are - OFF, VAPOR
6666
const skyHaze = pxlEnums.SKY_HAZE.VAPOR;
6767

68+
// Collision Detection Grid
69+
// Collision objects are split into a grid for faster collision detection
70+
// gridSize - The size of the grid
71+
// gridReference - Grid scene reference threshold to scale `gridSize`
72+
const collisionScale = {
73+
'gridSize' : 100,
74+
'gridReference' : 1000
75+
};
76+
6877

6978

7079
// -- -- -- -- -- -- -- -- -- -- -- -- -- -- //
@@ -81,6 +90,7 @@ const skyHaze = pxlEnums.SKY_HAZE.VAPOR;
8190
let pxlNavOptions = Object.assign({},pxlOptions);
8291
pxlNavOptions.verbose = verbose;
8392
pxlNavOptions.antiAliasing = antiAliasing;
93+
pxlNavOptions.collisionScale = collisionScale;
8494
pxlNavOptions.pxlRoomRoot = pxlRoomRootPath;
8595
pxlNavOptions.staticCamera = enableStaticCamera;
8696
pxlNavOptions.skyHaze = skyHaze;

Source/js/pxlNav.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class pxlNav{
243243
// Default Grid Size 50, Collider Bounds as reference 1000.0
244244
// The reference bounds are used to scale down the grid size for smaller bbox colliders,
245245
// Helping with higher poly counts for performance
246-
this.pxlColliders = new pxlBase.Colliders( this.verbose, 50, 1000.0 );
246+
this.pxlColliders = new pxlBase.Colliders( this.verbose, this.options["collisionScale"]["gridSize"], this.options["collisionScale"]["gridReference"] );
247247

248248

249249
this.pxlCamera = new pxlBase.Camera();

Source/js/pxlNav/RoomClass.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class RoomEnvironment{
226226
}
227227

228228
setUserHeight( toHeight=1 ){
229-
this.pxlEnv.pxlCamera.setUserHeight( toHeight );
229+
this.pxlEnv.pxlCamera.setUserHeight( toHeight, this.roomName );
230230
}
231231

232232
resetCamera(){
@@ -422,7 +422,7 @@ class RoomEnvironment{
422422
hasCollidersOfType = this.colliderActive;
423423
break;
424424
case COLLIDER_TYPE.WALL:
425-
hasCollidersOfType = this.colliderActive;
425+
hasCollidersOfType = this.antiColliderActive;
426426
break;
427427
case COLLIDER_TYPE.WALL_TOP:
428428
hasCollidersOfType = this.antiColliderTopActive;
@@ -464,23 +464,27 @@ class RoomEnvironment{
464464
// Kick out if the collider type is not active
465465
// ( No colliders of the given type exist )
466466
if( colliderType == COLLIDER_TYPE.WALL && !this.antiColliderActive ){
467+
forHashing = this.antiColliderList;
467468
return forHashing;
468469
}else if( colliderType == COLLIDER_TYPE.WALL_TOP && !this.antiColliderTopActive ){
469-
return forHashing;
470-
}else if( colliderType == COLLIDER_TYPE.ROOM_WARP && !this.hasRoomWarp ){
470+
forHashing = this.antiColliderTopList;
471471
return forHashing;
472472
}else if( colliderType == COLLIDER_TYPE.PORTAL_WARP && !this.hasPortalExit ){
473+
forHashing = this.portalList;
474+
return forHashing;
475+
}else if( colliderType == COLLIDER_TYPE.ROOM_WARP && !this.hasRoomWarp ){
476+
forHashing = this.roomWarp;
473477
return forHashing;
474478
}else if( colliderType == COLLIDER_TYPE.HOVERABLE && !this.hasHoverables ){
475-
this.hoverableList=[];
476-
this.hoverableObj=null;
477-
this.hasClickables=false;
478-
this.clickableList=[];
479+
forHashing = this.hoverableList;
479480
return forHashing;
480481
}else if( colliderType == COLLIDER_TYPE.CLICKABLE && !this.hasClickables ){
482+
forHashing = this.clickableList;
481483
return forHashing;
482484
}
483485

486+
// TODO : Quadrant hashing for colliders should be removed from pxlNav support, with new grid hashing system implemented
487+
// TODO : Maya tools and FBX requirements needs updating for the new collider system
484488
switch( colliderType ){
485489
case COLLIDER_TYPE.FLOOR:
486490
forHashing = [

0 commit comments

Comments
 (0)