@@ -265,7 +265,7 @@ export class SightHandler {
265
265
object : testTarget ,
266
266
} ;
267
267
result = LevelsConfig . handlers . SightHandler . performLOSTest ( this . config . source . object , point , this , this . config . type ) ;
268
- if ( canvas . effects . darknessSources . size ) result = result && wrapped ( ...args ) ;
268
+ // if(canvas.effects.darknessSources.size) result = result && wrapped(...args);
269
269
} else {
270
270
result = wrapped ( ...args ) ;
271
271
}
@@ -278,6 +278,7 @@ export class SightHandler {
278
278
* @returns {boolean } Whether the wall should be ignored
279
279
*/
280
280
static shouldIgnoreWall ( wall , collisionType , options ) {
281
+ if ( ! wall ) return false ;
281
282
const proximity = this . shouldIgnoreProximityWall ( wall . document , options . A , options . B , options . source ?. vision ?. data ?. externalRadius ?? 0 ) ;
282
283
if ( collisionType === 0 ) {
283
284
return (
@@ -300,7 +301,7 @@ export class SightHandler {
300
301
const d = document . threshold ?. sight ;
301
302
if ( ! d || d . sight < 30 ) return false ; // No threshold applies
302
303
const proximity = document . sight === CONST . WALL_SENSE_TYPES . PROXIMITY ;
303
- const pt = foundry . utils . closestPointToSegment ( source , document . object . A , document . object . B ) ;
304
+ const pt = foundry . utils . closestPointToSegment ( source , document . object . edge . a , document . object . edge . b ) ;
304
305
//const ptTarget = foundry.utils.closestPointToSegment(target, document.object.A, document.object.B);
305
306
//const targetDistance = Math.hypot(ptTarget.x - target.x, ptTarget.y - target.y);
306
307
const sourceDistance = Math . hypot ( pt . x - source . x , pt . y - source . y ) ;
@@ -394,6 +395,10 @@ export class SightHandler {
394
395
}
395
396
//Get wall heights flags, avoid infinity, use arbitrary large number instead
396
397
function getWallHeightRange3Dcollision ( wall ) {
398
+ if ( ! wall ) return [ - 1e9 , 1e9 ] ;
399
+ if ( wall . elevation !== undefined ) {
400
+ return [ wall . elevation , wall . document . flags . levels ?. rangeTop ?? Infinity ] ;
401
+ }
397
402
let { top, bottom } = WallHeight . getWallBounds ( wall ) ;
398
403
if ( bottom == - Infinity ) bottom = - 1e9 ;
399
404
if ( top == Infinity ) top = 1e9 ;
@@ -410,19 +415,20 @@ export class SightHandler {
410
415
const rect = new PIXI . Rectangle ( rectX , rectY , rectW , rectH ) ;
411
416
const walls = canvas . walls . quadtree . getObjects ( rect ) ;
412
417
let terrainWalls = 0 ;
413
- for ( let wall of walls ) {
414
- if ( this . shouldIgnoreWall ( wall , TYPE , options ) ) continue ;
415
-
416
- let isTerrain = ( TYPE === 0 && wall . document . sight === CONST . WALL_SENSE_TYPES . LIMITED ) || ( TYPE === 1 && wall . document . move === CONST . WALL_SENSE_TYPES . LIMITED ) || ( TYPE === 2 && wall . document . sound === CONST . WALL_SENSE_TYPES . LIMITED ) || ( TYPE === 3 && wall . document . light === CONST . WALL_SENSE_TYPES . LIMITED ) ;
418
+ for ( const [ k , edge ] of canvas . edges ) {
419
+ if ( this . shouldIgnoreWall ( edge . object , TYPE , options ) ) continue ;
420
+
421
+ 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 ) ;
417
422
418
423
//declare points in 3d space of the rectangle created by the wall
419
- const wallBotTop = getWallHeightRange3Dcollision ( wall ) ;
420
- const wx1 = wall . document . c [ 0 ] ;
421
- const wx2 = wall . document . c [ 2 ] ;
422
- const wx3 = wall . document . c [ 2 ] ;
423
- const wy1 = wall . document . c [ 1 ] ;
424
- const wy2 = wall . document . c [ 3 ] ;
425
- const wy3 = wall . document . c [ 3 ] ;
424
+ const wallBotTop = getWallHeightRange3Dcollision ( edge . object ) ;
425
+
426
+ const wx1 = edge . a . x ;
427
+ const wx2 = edge . b . x ;
428
+ const wx3 = edge . b . x ;
429
+ const wy1 = edge . a . y ;
430
+ const wy2 = edge . b . y ;
431
+ const wy3 = edge . b . y ;
426
432
const wz1 = wallBotTop [ 0 ] ;
427
433
const wz2 = wallBotTop [ 0 ] ;
428
434
const wz3 = wallBotTop [ 1 ] ;
@@ -442,11 +448,11 @@ export class SightHandler {
442
448
443
449
//Check for directional walls
444
450
445
- if ( wall . direction !== null ) {
451
+ if ( edge . direction ) {
446
452
// Directional walls where the ray angle is not in the same hemisphere
447
453
const rayAngle = Math . atan2 ( y1 - y0 , x1 - x0 ) ;
448
454
const angleBounds = [ rayAngle - Math . PI / 2 , rayAngle + Math . PI / 2 ] ;
449
- if ( ! wall . isDirectionBetweenAngles ( ...angleBounds ) ) continue ;
455
+ if ( edge . object ?. isDirectionBetweenAngles && ! edge . object . isDirectionBetweenAngles ( ...angleBounds ) ) continue ;
450
456
}
451
457
452
458
//calculate intersection point
@@ -462,6 +468,7 @@ export class SightHandler {
462
468
continue ;
463
469
}
464
470
if ( isb && iz <= wallBotTop [ 1 ] && iz >= wallBotTop [ 0 ] ) return { x : ix , y : iy , z : iz } ;
471
+
465
472
}
466
473
return false ;
467
474
}
0 commit comments