mrpas 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -38,10 +38,13 @@ class Mrpas {
38
38
  let previousEndSlope;
39
39
  let cellTransparent = false;
40
40
  let transparencyChecked;
41
+ let firstCell;
42
+ let behindOpen = false;
43
+ let diagonalOpen;
41
44
  for (y = originY + deltaY; y >= minY && y <= maxY; y += deltaY, obstaclesInLastLine = totalObstacles, ++iteration) {
42
45
  halfSlope = 0.5 / iteration;
43
46
  previousEndSlope = -1;
44
- for (processedCell = Math.floor(minSlope * iteration + 0.5), x = originX + (processedCell * deltaX); processedCell <= iteration && x >= minX && x <= maxX; x += deltaX, ++processedCell, previousEndSlope = endSlope) {
47
+ for (firstCell = processedCell = Math.floor(minSlope * iteration + 0.5), x = originX + (processedCell * deltaX); processedCell <= iteration && x >= minX && x <= maxX; x += deltaX, ++processedCell, previousEndSlope = endSlope) {
45
48
  visible = true;
46
49
  extended = false;
47
50
  centreSlope = processedCell / iteration;
@@ -49,10 +52,12 @@ class Mrpas {
49
52
  endSlope = centreSlope + halfSlope;
50
53
  transparencyChecked = false;
51
54
  if (obstaclesInLastLine > 0) {
52
- if (!(isVisible(x, y - deltaY) &&
53
- isTransparent(x, y - deltaY)) &&
54
- !(isVisible(x - deltaX, y - deltaY) &&
55
- isTransparent(x - deltaX, y - deltaY))) {
55
+ diagonalOpen = behindOpen;
56
+ behindOpen = isVisible(x, y - deltaY) && isTransparent(x, y - deltaY);
57
+ if (!behindOpen &&
58
+ !(processedCell > firstCell
59
+ ? diagonalOpen
60
+ : isVisible(x - deltaX, y - deltaY) && isTransparent(x - deltaX, y - deltaY))) {
56
61
  visible = false;
57
62
  }
58
63
  else {
@@ -103,6 +108,9 @@ class Mrpas {
103
108
  }
104
109
  }
105
110
  }
111
+ if (minSlope > 1) {
112
+ break;
113
+ }
106
114
  }
107
115
  }
108
116
  computeOctantX(deltaX, deltaY, data) {
@@ -133,10 +141,13 @@ class Mrpas {
133
141
  let previousEndSlope;
134
142
  let cellTransparent = false;
135
143
  let transparencyChecked;
144
+ let firstCell;
145
+ let behindOpen = false;
146
+ let diagonalOpen;
136
147
  for (x = originX + deltaX; x >= minX && x <= maxX; x += deltaX, obstaclesInLastLine = totalObstacles, ++iteration) {
137
148
  halfSlope = 0.5 / iteration;
138
149
  previousEndSlope = -1;
139
- for (processedCell = Math.floor(minSlope * iteration + 0.5), y = originY + (processedCell * deltaY); processedCell <= iteration && y >= minY && y <= maxY; y += deltaY, ++processedCell, previousEndSlope = endSlope) {
150
+ for (firstCell = processedCell = Math.floor(minSlope * iteration + 0.5), y = originY + (processedCell * deltaY); processedCell <= iteration && y >= minY && y <= maxY; y += deltaY, ++processedCell, previousEndSlope = endSlope) {
140
151
  visible = true;
141
152
  extended = false;
142
153
  centreSlope = processedCell / iteration;
@@ -144,10 +155,12 @@ class Mrpas {
144
155
  endSlope = centreSlope + halfSlope;
145
156
  transparencyChecked = false;
146
157
  if (obstaclesInLastLine > 0) {
147
- if (!(isVisible(x - deltaX, y) &&
148
- isTransparent(x - deltaX, y)) &&
149
- !(isVisible(x - deltaX, y - deltaY) &&
150
- isTransparent(x - deltaX, y - deltaY))) {
158
+ diagonalOpen = behindOpen;
159
+ behindOpen = isVisible(x - deltaX, y) && isTransparent(x - deltaX, y);
160
+ if (!behindOpen &&
161
+ !(processedCell > firstCell
162
+ ? diagonalOpen
163
+ : isVisible(x - deltaX, y - deltaY) && isTransparent(x - deltaX, y - deltaY))) {
151
164
  visible = false;
152
165
  }
153
166
  else {
@@ -198,6 +211,9 @@ class Mrpas {
198
211
  }
199
212
  }
200
213
  }
214
+ if (minSlope > 1) {
215
+ break;
216
+ }
201
217
  }
202
218
  }
203
219
  setMapDimensions(mapWidth, mapHeight) {
package/dist/esm/index.js CHANGED
@@ -35,10 +35,13 @@ export class Mrpas {
35
35
  let previousEndSlope;
36
36
  let cellTransparent = false;
37
37
  let transparencyChecked;
38
+ let firstCell;
39
+ let behindOpen = false;
40
+ let diagonalOpen;
38
41
  for (y = originY + deltaY; y >= minY && y <= maxY; y += deltaY, obstaclesInLastLine = totalObstacles, ++iteration) {
39
42
  halfSlope = 0.5 / iteration;
40
43
  previousEndSlope = -1;
41
- for (processedCell = Math.floor(minSlope * iteration + 0.5), x = originX + (processedCell * deltaX); processedCell <= iteration && x >= minX && x <= maxX; x += deltaX, ++processedCell, previousEndSlope = endSlope) {
44
+ for (firstCell = processedCell = Math.floor(minSlope * iteration + 0.5), x = originX + (processedCell * deltaX); processedCell <= iteration && x >= minX && x <= maxX; x += deltaX, ++processedCell, previousEndSlope = endSlope) {
42
45
  visible = true;
43
46
  extended = false;
44
47
  centreSlope = processedCell / iteration;
@@ -46,10 +49,12 @@ export class Mrpas {
46
49
  endSlope = centreSlope + halfSlope;
47
50
  transparencyChecked = false;
48
51
  if (obstaclesInLastLine > 0) {
49
- if (!(isVisible(x, y - deltaY) &&
50
- isTransparent(x, y - deltaY)) &&
51
- !(isVisible(x - deltaX, y - deltaY) &&
52
- isTransparent(x - deltaX, y - deltaY))) {
52
+ diagonalOpen = behindOpen;
53
+ behindOpen = isVisible(x, y - deltaY) && isTransparent(x, y - deltaY);
54
+ if (!behindOpen &&
55
+ !(processedCell > firstCell
56
+ ? diagonalOpen
57
+ : isVisible(x - deltaX, y - deltaY) && isTransparent(x - deltaX, y - deltaY))) {
53
58
  visible = false;
54
59
  }
55
60
  else {
@@ -100,6 +105,9 @@ export class Mrpas {
100
105
  }
101
106
  }
102
107
  }
108
+ if (minSlope > 1) {
109
+ break;
110
+ }
103
111
  }
104
112
  }
105
113
  computeOctantX(deltaX, deltaY, data) {
@@ -130,10 +138,13 @@ export class Mrpas {
130
138
  let previousEndSlope;
131
139
  let cellTransparent = false;
132
140
  let transparencyChecked;
141
+ let firstCell;
142
+ let behindOpen = false;
143
+ let diagonalOpen;
133
144
  for (x = originX + deltaX; x >= minX && x <= maxX; x += deltaX, obstaclesInLastLine = totalObstacles, ++iteration) {
134
145
  halfSlope = 0.5 / iteration;
135
146
  previousEndSlope = -1;
136
- for (processedCell = Math.floor(minSlope * iteration + 0.5), y = originY + (processedCell * deltaY); processedCell <= iteration && y >= minY && y <= maxY; y += deltaY, ++processedCell, previousEndSlope = endSlope) {
147
+ for (firstCell = processedCell = Math.floor(minSlope * iteration + 0.5), y = originY + (processedCell * deltaY); processedCell <= iteration && y >= minY && y <= maxY; y += deltaY, ++processedCell, previousEndSlope = endSlope) {
137
148
  visible = true;
138
149
  extended = false;
139
150
  centreSlope = processedCell / iteration;
@@ -141,10 +152,12 @@ export class Mrpas {
141
152
  endSlope = centreSlope + halfSlope;
142
153
  transparencyChecked = false;
143
154
  if (obstaclesInLastLine > 0) {
144
- if (!(isVisible(x - deltaX, y) &&
145
- isTransparent(x - deltaX, y)) &&
146
- !(isVisible(x - deltaX, y - deltaY) &&
147
- isTransparent(x - deltaX, y - deltaY))) {
155
+ diagonalOpen = behindOpen;
156
+ behindOpen = isVisible(x - deltaX, y) && isTransparent(x - deltaX, y);
157
+ if (!behindOpen &&
158
+ !(processedCell > firstCell
159
+ ? diagonalOpen
160
+ : isVisible(x - deltaX, y - deltaY) && isTransparent(x - deltaX, y - deltaY))) {
148
161
  visible = false;
149
162
  }
150
163
  else {
@@ -195,6 +208,9 @@ export class Mrpas {
195
208
  }
196
209
  }
197
210
  }
211
+ if (minSlope > 1) {
212
+ break;
213
+ }
198
214
  }
199
215
  }
200
216
  setMapDimensions(mapWidth, mapHeight) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mrpas",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "A Field of View (FOV) computation algorithm.",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -23,15 +23,18 @@
23
23
  },
24
24
  "repository": {
25
25
  "type": "git",
26
- "url": "https://bitbucket.org/umbraprojekt/mrpas.git"
26
+ "url": "git+https://github.com/mingos777/mrpas.git"
27
+ },
28
+ "bugs": {
29
+ "url": "https://github.com/mingos777/mrpas/issues"
27
30
  },
28
31
  "keywords": [
29
32
  "fov",
30
33
  "roguelike"
31
34
  ],
32
- "author": "Dominik Marczuk <mingos.nospam@gmail.com> (http://dominikmarczuk.pl)",
35
+ "author": "Dominik Marczuk <mingos.nospam@gmail.com> (https://dominikmarczuk.pl)",
33
36
  "license": "BSD-2-Clause",
34
- "homepage": "https://bitbucket.org/mingos/mrpas",
37
+ "homepage": "https://github.com/mingos777/mrpas",
35
38
  "devDependencies": {
36
39
  "typescript": "^7.0.2"
37
40
  }
File without changes