Skip to content

Commit

Permalink
rare bug that appears in v8 (most likely v9 as well) that is continge…
Browse files Browse the repository at this point in the history
…nt on rays which are cast directly at wall endpoints.
  • Loading branch information
David-Zvekic committed May 20, 2023
1 parent 76af9e8 commit 7a66079
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
18 changes: 18 additions & 0 deletions TokensVisible.js
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,23 @@ tokensVisible.SightLayer._DI_castRays=function(x, y, distance, {density=4, endpo
if(rayAccuracy<1.5) density = density* (2/3) * rayAccuracy; // density can never be worse than standard
if(density<Math.min(2,originaldensity))density=Math.min(2,originaldensity); // dont want to make the quality too good/expensive. Use Supermode for that.


if(typeof(this._adjustRayAngle) == "undefined") {
// FoundryVTT8,9 code (not tested for 9 yet)
// First prioritize rays which are cast directly at wall endpoints
for ( let e of endpoints ) {
let angle = Math.atan2(e[1]-y, e[0]-x);
if ( limitAngle ) {
angle = this._normalizeAngle(aMin, angle);
if ( !angle.between(aMin, aMax) ) continue;
}
const ray = Ray.fromAngle(x, y, angle, distance);
cast(ray, false);
}

}
else
{ // FoundryVTT7 code
// First prioritize rays which are cast directly at wall endpoints
for ( let e of endpoints ) {
const ray = Ray.fromAngle(x, y, Math.atan2(e[1]-y, e[0]-x), distance);
Expand All @@ -722,6 +739,7 @@ tokensVisible.SightLayer._DI_castRays=function(x, y, distance, {density=4, endpo
}
cast(ray);
}
}

if (rayAccuracy<1.5) {
let varx = 0;
Expand Down
6 changes: 3 additions & 3 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
"title": "Your Tokens Visible",
"description": "Usability and vision enhancements for Tokens",
"author": "David Zvekic",
"version": "3.1.1",
"version": "3.1.2",
"compatibleCoreVersion": "9.280",
"minimumCoreVersion": "0.7.9",
"url":"https://github.com/David-Zvekic/TokensVisible",
"manifest": "https://github.com/David-Zvekic/TokensVisible/releases/download/v3.1.1/module.json",
"download": "https://github.com/David-Zvekic/TokensVisible/releases/download/v3.1.1/TokensVisible.zip",
"manifest": "https://github.com/David-Zvekic/TokensVisible/releases/download/v3.1.2/module.json",
"download": "https://github.com/David-Zvekic/TokensVisible/releases/download/v3.1.2/TokensVisible.zip",
"esmodules": [
"./lib/colorsettings/colorSetting.js", "TokensVisible.js"
],
Expand Down

0 comments on commit 7a66079

Please sign in to comment.