Skip to content

Commit

Permalink
a
Browse files Browse the repository at this point in the history
  • Loading branch information
theripper93 committed Jun 23, 2024
1 parent aa5b4bd commit 325afd3
Show file tree
Hide file tree
Showing 11 changed files with 36 additions and 39 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion packs/levels-samples/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-002630
MANIFEST-002632
6 changes: 3 additions & 3 deletions packs/levels-samples/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2024/06/23-17:17:16.925 8fd4 Recovering log #2628
2024/06/23-17:17:16.928 8fd4 Delete type=0 #2628
2024/06/23-17:17:16.928 8fd4 Delete type=3 #2626
2024/06/23-17:39:07.484 1278 Recovering log #2631
2024/06/23-17:39:07.487 1278 Delete type=0 #2631
2024/06/23-17:39:07.487 1278 Delete type=3 #2630
11 changes: 3 additions & 8 deletions packs/levels-samples/LOG.old
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
2024/06/23-17:06:07.406 3eb0 Recovering log #2624
2024/06/23-17:06:07.409 3eb0 Delete type=0 #2624
2024/06/23-17:06:07.409 3eb0 Delete type=3 #2622
2024/06/23-17:14:02.610 3190 Level-0 table #2629: started
2024/06/23-17:14:02.611 3190 Level-0 table #2629: 0 bytes OK
2024/06/23-17:14:02.612 3190 Delete type=0 #2627
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)
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)
2024/06/23-17:17:16.925 8fd4 Recovering log #2628
2024/06/23-17:17:16.928 8fd4 Delete type=0 #2628
2024/06/23-17:17:16.928 8fd4 Delete type=3 #2626
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion packs/macros/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-002625
MANIFEST-002627
6 changes: 3 additions & 3 deletions packs/macros/LOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
2024/06/23-17:17:16.916 3eb0 Recovering log #2623
2024/06/23-17:17:16.920 3eb0 Delete type=0 #2623
2024/06/23-17:17:16.920 3eb0 Delete type=3 #2621
2024/06/23-17:39:07.476 5ee4 Recovering log #2626
2024/06/23-17:39:07.481 5ee4 Delete type=0 #2626
2024/06/23-17:39:07.481 5ee4 Delete type=3 #2625
11 changes: 3 additions & 8 deletions packs/macros/LOG.old
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
2024/06/23-17:06:07.399 69a4 Recovering log #2619
2024/06/23-17:06:07.403 69a4 Delete type=0 #2619
2024/06/23-17:06:07.403 69a4 Delete type=3 #2617
2024/06/23-17:14:02.605 3190 Level-0 table #2624: started
2024/06/23-17:14:02.605 3190 Level-0 table #2624: 0 bytes OK
2024/06/23-17:14:02.607 3190 Delete type=0 #2622
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)
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)
2024/06/23-17:17:16.916 3eb0 Recovering log #2623
2024/06/23-17:17:16.920 3eb0 Delete type=0 #2623
2024/06/23-17:17:16.920 3eb0 Delete type=3 #2621
Binary file not shown.
37 changes: 22 additions & 15 deletions scripts/handlers/sightHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ export class SightHandler {
object: testTarget,
};
result = LevelsConfig.handlers.SightHandler.performLOSTest(this.config.source.object, point, this, this.config.type);
if(canvas.effects.darknessSources.size) result = result && wrapped(...args);
//if(canvas.effects.darknessSources.size) result = result && wrapped(...args);
} else {
result = wrapped(...args);
}
Expand All @@ -278,6 +278,7 @@ export class SightHandler {
* @returns {boolean} Whether the wall should be ignored
*/
static shouldIgnoreWall(wall, collisionType, options) {
if(!wall) return false;
const proximity = this.shouldIgnoreProximityWall(wall.document, options.A, options.B, options.source?.vision?.data?.externalRadius ?? 0);
if (collisionType === 0) {
return (
Expand All @@ -300,7 +301,7 @@ export class SightHandler {
const d = document.threshold?.sight;
if (!d || d.sight < 30) return false; // No threshold applies
const proximity = document.sight === CONST.WALL_SENSE_TYPES.PROXIMITY;
const pt = foundry.utils.closestPointToSegment(source, document.object.A, document.object.B);
const pt = foundry.utils.closestPointToSegment(source, document.object.edge.a, document.object.edge.b);
//const ptTarget = foundry.utils.closestPointToSegment(target, document.object.A, document.object.B);
//const targetDistance = Math.hypot(ptTarget.x - target.x, ptTarget.y - target.y);
const sourceDistance = Math.hypot(pt.x - source.x, pt.y - source.y);
Expand Down Expand Up @@ -394,6 +395,10 @@ export class SightHandler {
}
//Get wall heights flags, avoid infinity, use arbitrary large number instead
function getWallHeightRange3Dcollision(wall) {
if(!wall) return [-1e9, 1e9];
if (wall.elevation !== undefined) {
return [wall.elevation, wall.document.flags.levels?.rangeTop ?? Infinity];
}
let { top, bottom } = WallHeight.getWallBounds(wall);
if (bottom == -Infinity) bottom = -1e9;
if (top == Infinity) top = 1e9;
Expand All @@ -410,19 +415,20 @@ export class SightHandler {
const rect = new PIXI.Rectangle(rectX, rectY, rectW, rectH);
const walls = canvas.walls.quadtree.getObjects(rect);
let terrainWalls = 0;
for (let wall of walls) {
if (this.shouldIgnoreWall(wall, TYPE, options)) continue;

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);
for (const [k, edge] of canvas.edges) {
if (this.shouldIgnoreWall(edge.object, TYPE, options)) continue;
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);

//declare points in 3d space of the rectangle created by the wall
const wallBotTop = getWallHeightRange3Dcollision(wall);
const wx1 = wall.document.c[0];
const wx2 = wall.document.c[2];
const wx3 = wall.document.c[2];
const wy1 = wall.document.c[1];
const wy2 = wall.document.c[3];
const wy3 = wall.document.c[3];
const wallBotTop = getWallHeightRange3Dcollision(edge.object);

const wx1 = edge.a.x;
const wx2 = edge.b.x;
const wx3 = edge.b.x;
const wy1 = edge.a.y;
const wy2 = edge.b.y;
const wy3 = edge.b.y;
const wz1 = wallBotTop[0];
const wz2 = wallBotTop[0];
const wz3 = wallBotTop[1];
Expand All @@ -442,11 +448,11 @@ export class SightHandler {

//Check for directional walls

if (wall.direction !== null) {
if (edge.direction) {
// Directional walls where the ray angle is not in the same hemisphere
const rayAngle = Math.atan2(y1 - y0, x1 - x0);
const angleBounds = [rayAngle - Math.PI / 2, rayAngle + Math.PI / 2];
if (!wall.isDirectionBetweenAngles(...angleBounds)) continue;
if (edge.object?.isDirectionBetweenAngles && !edge.object.isDirectionBetweenAngles(...angleBounds)) continue;
}

//calculate intersection point
Expand All @@ -462,6 +468,7 @@ export class SightHandler {
continue;
}
if (isb && iz <= wallBotTop[1] && iz >= wallBotTop[0]) return { x: ix, y: iy, z: iz };

}
return false;
}
Expand Down

0 comments on commit 325afd3

Please sign in to comment.