@@ -18,7 +18,7 @@ export class SightHandler {
18
18
static advancedLosTestVisibility ( sourceToken , tokenOrPoint , source , type = "sight" ) {
19
19
const angleTest = this . testInAngle ( sourceToken , tokenOrPoint , source ) ;
20
20
if ( ! angleTest ) return false ;
21
- return ! this . advancedLosTestInLos ( sourceToken , tokenOrPoint , type ) ;
21
+ return ! this . advancedLosTestInLos ( sourceToken , tokenOrPoint , type , source ) ;
22
22
const inLOS = ! this . advancedLosTestInLos ( sourceToken , tokenOrPoint , type ) ;
23
23
if ( sourceToken . vision . los === source ) return inLOS ;
24
24
const inRange = this . tokenInRange ( sourceToken , tokenOrPoint ) ;
@@ -58,15 +58,15 @@ export class SightHandler {
58
58
return tokenCorners ;
59
59
}
60
60
61
- static advancedLosTestInLos ( sourceToken , tokenOrPoint , type = "sight" ) {
62
- if ( ! ( tokenOrPoint instanceof Token ) || CONFIG . Levels . settings . get ( "preciseTokenVisibility" ) === false ) return this . checkCollision ( sourceToken , tokenOrPoint , type ) ;
61
+ static advancedLosTestInLos ( sourceToken , tokenOrPoint , type = "sight" , source ) {
62
+ if ( ! ( tokenOrPoint instanceof Token ) || CONFIG . Levels . settings . get ( "preciseTokenVisibility" ) === false ) return this . checkCollision ( sourceToken , tokenOrPoint , type , { sourcePolygon : source } ) ;
63
63
const sourceCenter = {
64
64
x : sourceToken . vision . x ,
65
65
y : sourceToken . vision . y ,
66
66
z : sourceToken . losHeight ,
67
67
} ;
68
68
for ( let point of this . getTestPoints ( tokenOrPoint ) ) {
69
- let collision = this . testCollision ( sourceCenter , point , type , { source : sourceToken , target : tokenOrPoint } ) ;
69
+ let collision = this . testCollision ( sourceCenter , point , type , { source : sourceToken , target : tokenOrPoint , sourcePolygon : source } ) ;
70
70
if ( ! collision ) return collision ;
71
71
}
72
72
return true ;
@@ -319,6 +319,7 @@ export class SightHandler {
319
319
**/
320
320
321
321
static testCollision ( p0 , p1 , type = "sight" , options = { } ) {
322
+ debugger
322
323
if ( canvas ?. scene ?. flags [ "levels-3d-preview" ] ?. object3dSight ) {
323
324
if ( ! game . Levels3DPreview ?. _active ) return true ;
324
325
return game . Levels3DPreview . interactionManager . computeSightCollision ( p0 , p1 , type ) ;
@@ -337,6 +338,7 @@ export class SightHandler {
337
338
338
339
const TYPE = type == "sight" ? 0 : type == "sound" ? 2 : type == "light" ? 3 : 1 ;
339
340
const ALPHATTHRESHOLD = type == "sight" ? 0.99 : 0.1 ;
341
+ const IGNOREDARKNESS = ! options ?. sourcePolygon ?. config ?. includeDarkness ;
340
342
//If the point are on the same Z axis return the 3d wall test
341
343
if ( z0 == z1 ) {
342
344
return walls3dTest . bind ( this ) ( ) ;
@@ -417,7 +419,7 @@ export class SightHandler {
417
419
let terrainWalls = 0 ;
418
420
for ( const [ k , edge ] of canvas . edges ) {
419
421
if ( this . shouldIgnoreWall ( edge . object , TYPE , options ) ) continue ;
420
-
422
+ if ( IGNOREDARKNESS && edge . type === "darkness" ) continue ;
421
423
let isTerrain = ( TYPE === 0 && edge . sight === CONST . WALL_SENSE_TYPES . LIMITED ) || ( TYPE === 1 && edge . move === CONST . WALL_MOVEMENT_TYPES . LIMITED ) || ( TYPE === 2 && edge . sound === CONST . WALL_MOVEMENT_TYPES . LIMITED ) || ( TYPE === 3 && edge . light === CONST . WALL_MOVEMENT_TYPES . LIMITED ) ;
422
424
423
425
//declare points in 3d space of the rectangle created by the wall
@@ -481,7 +483,7 @@ export class SightHandler {
481
483
* @param {String } type - "sight" or "move"/"collision" or "sound" or "light" (defaults to "sight")
482
484
* @returns {Boolean } returns the collision point if a collision is detected, flase if it's not
483
485
**/
484
- static checkCollision ( tokenOrPoint1 , tokenOrPoint2 , type = "sight" ) {
486
+ static checkCollision ( tokenOrPoint1 , tokenOrPoint2 , type = "sight" , options = { } ) {
485
487
const p0 =
486
488
tokenOrPoint1 instanceof Token
487
489
? {
@@ -498,6 +500,6 @@ export class SightHandler {
498
500
z : tokenOrPoint2 . losHeight ,
499
501
}
500
502
: tokenOrPoint2 ;
501
- return this . testCollision ( p0 , p1 , type , { source : tokenOrPoint1 , target : tokenOrPoint2 } ) ;
503
+ return this . testCollision ( p0 , p1 , type , { source : tokenOrPoint1 , target : tokenOrPoint2 , ... options } ) ;
502
504
}
503
505
}
0 commit comments