Skip to content

Commit

Permalink
Fix Ghostly Gaze
Browse files Browse the repository at this point in the history
  • Loading branch information
dev7355608 committed Sep 1, 2024
1 parent 1fd2deb commit 54503f4
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
6 changes: 3 additions & 3 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"email": "[email protected]"
}
],
"version": "2.3.3",
"version": "2.3.4",
"compatibility": {
"minimum": "12",
"verified": "12"
Expand Down Expand Up @@ -60,8 +60,8 @@
},
"url": "https://github.com/dev7355608/vision-5e",
"manifest": "https://github.com/dev7355608/vision-5e/releases/latest/download/module.json",
"download": "https://github.com/dev7355608/vision-5e/releases/download/v2.3.3/module.zip",
"changelog": "https://github.com/dev7355608/vision-5e/releases/tag/v2.3.3",
"download": "https://github.com/dev7355608/vision-5e/releases/download/v2.3.4/module.zip",
"changelog": "https://github.com/dev7355608/vision-5e/releases/tag/v2.3.4",
"bugs": "https://github.com/dev7355608/vision-5e/issues",
"readme": "https://raw.githubusercontent.com/dev7355608/vision-5e/main/README.md",
"license": "https://raw.githubusercontent.com/dev7355608/vision-5e/main/LICENSE"
Expand Down
26 changes: 18 additions & 8 deletions scripts/vision-source.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,20 @@ export default (PointVisionSource) => class extends PointVisionSource {
polygon = polygonClass.create(origin, config);

if (this.data.unconstrainedRadius > 0) {
const radius = this.data.unconstrainedRadius;
const circle = new PIXI.Circle(origin.x, origin.y, radius);
const density = PIXI.Circle.approximateVertexDensity(radius);

polygon.points = WeilerAthertonClipper.union(this.los, circle, { density })[0].points;
polygon.bounds = this.los.getBounds();
const radius = Math.min(this.data.unconstrainedRadius, polygon.config.radius);
let union = new PIXI.Circle(origin.x, origin.y, radius).intersectPolygon(polygon, {
clipType: ClipperLib.ClipType.ctUnion,
scalingFactor: 100,
density: PIXI.Circle.approximateVertexDensity(radius)
});
const bounds = polygon.config.useInnerBounds ? canvas.dimensions.sceneRect : canvas.dimensions.rect;

if (Math.min(origin.x - bounds.left, bounds.right - origin.x, origin.y - bounds.top, bounds.bottom - origin.y) < radius) {
union = bounds.intersectPolygon(union, { scalingFactor: 100 });
}

polygon.points = union.points;
polygon.bounds = polygon.getBounds();
}
}

Expand Down Expand Up @@ -71,9 +79,11 @@ export default (PointVisionSource) => class extends PointVisionSource {
const config = this._getPolygonConfiguration();

config.type = "universal";
config.radius = this.data.unconstrainedRadius;
config.radius = Math.min(this.data.unconstrainedRadius, this.los.config.radius);
config.useInnerBounds = this.los.config.useInnerBounds;

this.los.points = polygonClass.create(origin, config).points;
this.los.points = polygonClass.create(origin, config).intersectPolygon(this.los,
{ clipType: ClipperLib.ClipType.ctUnion, scalingFactor: 100 }).points;
this.los.bounds = this.los.getBounds();
}

Expand Down

0 comments on commit 54503f4

Please sign in to comment.