Skip to content

Commit 325afd3

Browse files
committed
a
1 parent aa5b4bd commit 325afd3

File tree

11 files changed

+36
-39
lines changed

11 files changed

+36
-39
lines changed
File renamed without changes.

packs/levels-samples/CURRENT

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
MANIFEST-002630
1+
MANIFEST-002632

packs/levels-samples/LOG

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
2024/06/23-17:17:16.925 8fd4 Recovering log #2628
2-
2024/06/23-17:17:16.928 8fd4 Delete type=0 #2628
3-
2024/06/23-17:17:16.928 8fd4 Delete type=3 #2626
1+
2024/06/23-17:39:07.484 1278 Recovering log #2631
2+
2024/06/23-17:39:07.487 1278 Delete type=0 #2631
3+
2024/06/23-17:39:07.487 1278 Delete type=3 #2630

packs/levels-samples/LOG.old

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
2024/06/23-17:06:07.406 3eb0 Recovering log #2624
2-
2024/06/23-17:06:07.409 3eb0 Delete type=0 #2624
3-
2024/06/23-17:06:07.409 3eb0 Delete type=3 #2622
4-
2024/06/23-17:14:02.610 3190 Level-0 table #2629: started
5-
2024/06/23-17:14:02.611 3190 Level-0 table #2629: 0 bytes OK
6-
2024/06/23-17:14:02.612 3190 Delete type=0 #2627
7-
2024/06/23-17:14:02.613 3190 Manual compaction at level-0 from '!scenes!i1noRqT20RD5stIK' @ 72057594037927935 : 1 .. '!scenes.walls!zksLSgRdh6f8jiUO.z5ptMNOLPqAgK6MH' @ 0 : 0; will stop at (end)
8-
2024/06/23-17:14:02.613 3190 Manual compaction at level-1 from '!scenes!i1noRqT20RD5stIK' @ 72057594037927935 : 1 .. '!scenes.walls!zksLSgRdh6f8jiUO.z5ptMNOLPqAgK6MH' @ 0 : 0; will stop at (end)
1+
2024/06/23-17:17:16.925 8fd4 Recovering log #2628
2+
2024/06/23-17:17:16.928 8fd4 Delete type=0 #2628
3+
2024/06/23-17:17:16.928 8fd4 Delete type=3 #2626
Binary file not shown.
File renamed without changes.

packs/macros/CURRENT

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
MANIFEST-002625
1+
MANIFEST-002627

packs/macros/LOG

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
2024/06/23-17:17:16.916 3eb0 Recovering log #2623
2-
2024/06/23-17:17:16.920 3eb0 Delete type=0 #2623
3-
2024/06/23-17:17:16.920 3eb0 Delete type=3 #2621
1+
2024/06/23-17:39:07.476 5ee4 Recovering log #2626
2+
2024/06/23-17:39:07.481 5ee4 Delete type=0 #2626
3+
2024/06/23-17:39:07.481 5ee4 Delete type=3 #2625

packs/macros/LOG.old

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
2024/06/23-17:06:07.399 69a4 Recovering log #2619
2-
2024/06/23-17:06:07.403 69a4 Delete type=0 #2619
3-
2024/06/23-17:06:07.403 69a4 Delete type=3 #2617
4-
2024/06/23-17:14:02.605 3190 Level-0 table #2624: started
5-
2024/06/23-17:14:02.605 3190 Level-0 table #2624: 0 bytes OK
6-
2024/06/23-17:14:02.607 3190 Delete type=0 #2622
7-
2024/06/23-17:14:02.607 3190 Manual compaction at level-0 from '!macros!2LfY4Ky5rRDkK7h8' @ 72057594037927935 : 1 .. '!macros!yx7Eb76rfzjh0LEO' @ 0 : 0; will stop at (end)
8-
2024/06/23-17:14:02.607 3190 Manual compaction at level-1 from '!macros!2LfY4Ky5rRDkK7h8' @ 72057594037927935 : 1 .. '!macros!yx7Eb76rfzjh0LEO' @ 0 : 0; will stop at (end)
1+
2024/06/23-17:17:16.916 3eb0 Recovering log #2623
2+
2024/06/23-17:17:16.920 3eb0 Delete type=0 #2623
3+
2024/06/23-17:17:16.920 3eb0 Delete type=3 #2621
Binary file not shown.

scripts/handlers/sightHandler.js

+22-15
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ export class SightHandler {
265265
object: testTarget,
266266
};
267267
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);
269269
} else {
270270
result = wrapped(...args);
271271
}
@@ -278,6 +278,7 @@ export class SightHandler {
278278
* @returns {boolean} Whether the wall should be ignored
279279
*/
280280
static shouldIgnoreWall(wall, collisionType, options) {
281+
if(!wall) return false;
281282
const proximity = this.shouldIgnoreProximityWall(wall.document, options.A, options.B, options.source?.vision?.data?.externalRadius ?? 0);
282283
if (collisionType === 0) {
283284
return (
@@ -300,7 +301,7 @@ export class SightHandler {
300301
const d = document.threshold?.sight;
301302
if (!d || d.sight < 30) return false; // No threshold applies
302303
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);
304305
//const ptTarget = foundry.utils.closestPointToSegment(target, document.object.A, document.object.B);
305306
//const targetDistance = Math.hypot(ptTarget.x - target.x, ptTarget.y - target.y);
306307
const sourceDistance = Math.hypot(pt.x - source.x, pt.y - source.y);
@@ -394,6 +395,10 @@ export class SightHandler {
394395
}
395396
//Get wall heights flags, avoid infinity, use arbitrary large number instead
396397
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+
}
397402
let { top, bottom } = WallHeight.getWallBounds(wall);
398403
if (bottom == -Infinity) bottom = -1e9;
399404
if (top == Infinity) top = 1e9;
@@ -410,19 +415,20 @@ export class SightHandler {
410415
const rect = new PIXI.Rectangle(rectX, rectY, rectW, rectH);
411416
const walls = canvas.walls.quadtree.getObjects(rect);
412417
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);
417422

418423
//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;
426432
const wz1 = wallBotTop[0];
427433
const wz2 = wallBotTop[0];
428434
const wz3 = wallBotTop[1];
@@ -442,11 +448,11 @@ export class SightHandler {
442448

443449
//Check for directional walls
444450

445-
if (wall.direction !== null) {
451+
if (edge.direction) {
446452
// Directional walls where the ray angle is not in the same hemisphere
447453
const rayAngle = Math.atan2(y1 - y0, x1 - x0);
448454
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;
450456
}
451457

452458
//calculate intersection point
@@ -462,6 +468,7 @@ export class SightHandler {
462468
continue;
463469
}
464470
if (isb && iz <= wallBotTop[1] && iz >= wallBotTop[0]) return { x: ix, y: iy, z: iz };
471+
465472
}
466473
return false;
467474
}

0 commit comments

Comments
 (0)