@woosh/meep-engine 2.94.0 → 2.94.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/build/meep.cjs +41 -37
- package/build/meep.min.js +1 -1
- package/build/meep.module.js +41 -37
- package/package.json +1 -1
- package/src/core/collection/heap/Uint32Heap.d.ts.map +1 -1
- package/src/core/collection/heap/Uint32Heap.js +22 -17
- package/src/engine/navigation/grid/find_path_on_grid_astar.d.ts.map +1 -1
- package/src/engine/navigation/grid/find_path_on_grid_astar.js +18 -19
- package/src/engine/navigation/grid/find_path_on_grid_astar.spec.js +2 -2
- package/src/engine/ui/GUIEngine.js +1 -1
package/build/meep.cjs
CHANGED
|
@@ -102844,7 +102844,7 @@ class GUIEngine {
|
|
|
102844
102844
|
|
|
102845
102845
|
constructor() {
|
|
102846
102846
|
|
|
102847
|
-
this.ticker.
|
|
102847
|
+
this.ticker.onTick.add(d => {
|
|
102848
102848
|
|
|
102849
102849
|
|
|
102850
102850
|
let ctx = null;
|
|
@@ -116253,17 +116253,17 @@ class Uint32Heap {
|
|
|
116253
116253
|
const size = this.__size;
|
|
116254
116254
|
|
|
116255
116255
|
while (true) {
|
|
116256
|
-
const
|
|
116257
|
-
const
|
|
116256
|
+
const left = (i << 1) + 1;
|
|
116257
|
+
const right = left + 1;
|
|
116258
116258
|
|
|
116259
116259
|
let smallest = i;
|
|
116260
116260
|
|
|
116261
|
-
if (
|
|
116262
|
-
smallest =
|
|
116261
|
+
if (left < size && this.compare(left, smallest)) {
|
|
116262
|
+
smallest = left;
|
|
116263
116263
|
}
|
|
116264
116264
|
|
|
116265
|
-
if (
|
|
116266
|
-
smallest =
|
|
116265
|
+
if (right < size && this.compare(right, smallest)) {
|
|
116266
|
+
smallest = right;
|
|
116267
116267
|
}
|
|
116268
116268
|
|
|
116269
116269
|
if (smallest === i) {
|
|
@@ -116337,19 +116337,23 @@ class Uint32Heap {
|
|
|
116337
116337
|
|
|
116338
116338
|
pop_min() {
|
|
116339
116339
|
|
|
116340
|
-
const
|
|
116340
|
+
const new_size = this.__size - 1;
|
|
116341
|
+
this.__size = new_size;
|
|
116341
116342
|
|
|
116342
|
-
this.
|
|
116343
|
+
const uint32 = this.__data_uint32;
|
|
116344
|
+
const top_id = uint32[1];
|
|
116343
116345
|
|
|
116344
|
-
|
|
116345
|
-
|
|
116346
|
-
|
|
116346
|
+
// move bottom element to the top.
|
|
116347
|
+
// the top doesn't need to be moved down as we have discarded it already
|
|
116348
|
+
const i2 = new_size << 1; // same as *2
|
|
116347
116349
|
|
|
116348
|
-
|
|
116349
|
-
|
|
116350
|
-
}
|
|
116350
|
+
uint32[0] = uint32[i2];
|
|
116351
|
+
uint32[1] = uint32[i2 + 1];
|
|
116351
116352
|
|
|
116352
|
-
|
|
116353
|
+
// re-balance
|
|
116354
|
+
this.heap_down(0);
|
|
116355
|
+
|
|
116356
|
+
return top_id;
|
|
116353
116357
|
}
|
|
116354
116358
|
|
|
116355
116359
|
/**
|
|
@@ -116367,6 +116371,7 @@ class Uint32Heap {
|
|
|
116367
116371
|
const _id = uint32[address];
|
|
116368
116372
|
|
|
116369
116373
|
if (_id === id) {
|
|
116374
|
+
// reverse address to index
|
|
116370
116375
|
return (address >>> 1);
|
|
116371
116376
|
}
|
|
116372
116377
|
}
|
|
@@ -116380,7 +116385,7 @@ class Uint32Heap {
|
|
|
116380
116385
|
* @param {number} id
|
|
116381
116386
|
* @returns {boolean}
|
|
116382
116387
|
*/
|
|
116383
|
-
contains(id){
|
|
116388
|
+
contains(id) {
|
|
116384
116389
|
return this.find_index_by_id(id) !== -1;
|
|
116385
116390
|
}
|
|
116386
116391
|
|
|
@@ -116511,7 +116516,7 @@ class Uint32Heap {
|
|
|
116511
116516
|
|
|
116512
116517
|
// insert at the end
|
|
116513
116518
|
const index = current_size;
|
|
116514
|
-
const address = index << 1;
|
|
116519
|
+
const address = index << 1; // same as *2
|
|
116515
116520
|
|
|
116516
116521
|
// write data
|
|
116517
116522
|
this.__data_float32[address] = score;
|
|
@@ -116709,6 +116714,12 @@ const open = new Uint32Heap();
|
|
|
116709
116714
|
const closed = new BitSet();
|
|
116710
116715
|
closed.preventShrink();
|
|
116711
116716
|
|
|
116717
|
+
/**
|
|
116718
|
+
* Contains refined heuristic value
|
|
116719
|
+
* @type {Float32Array}
|
|
116720
|
+
*/
|
|
116721
|
+
let g_score = new Float32Array(1024);
|
|
116722
|
+
|
|
116712
116723
|
/**
|
|
116713
116724
|
*
|
|
116714
116725
|
* @param {number[]|Uint8Array|Uint16Array|Float32Array} field
|
|
@@ -116732,14 +116743,15 @@ function find_path_on_grid_astar(
|
|
|
116732
116743
|
open.clear();
|
|
116733
116744
|
closed.reset();
|
|
116734
116745
|
|
|
116735
|
-
|
|
116736
|
-
* Contains refined heuristic value
|
|
116737
|
-
* @type {number[]}
|
|
116738
|
-
*/
|
|
116739
|
-
const g_score = [];
|
|
116746
|
+
const cell_count = width * height;
|
|
116740
116747
|
|
|
116741
|
-
g_score
|
|
116748
|
+
if (g_score.length < cell_count) {
|
|
116749
|
+
g_score = new Float32Array(cell_count);
|
|
116750
|
+
}
|
|
116742
116751
|
|
|
116752
|
+
g_score.fill(Infinity, 0, cell_count);
|
|
116753
|
+
|
|
116754
|
+
g_score[start] = 0;
|
|
116743
116755
|
|
|
116744
116756
|
open.insert(start, heuristic(start, goal, width));
|
|
116745
116757
|
|
|
@@ -116783,27 +116795,19 @@ function find_path_on_grid_astar(
|
|
|
116783
116795
|
// updated path cost
|
|
116784
116796
|
const cost_so_far = g_score[currentNode] + transition_cost;
|
|
116785
116797
|
|
|
116786
|
-
|
|
116798
|
+
if (cost_so_far < g_score[neighbor]) {
|
|
116787
116799
|
|
|
116788
|
-
|
|
116789
|
-
|
|
116790
|
-
if (not_in_open_set || cost_so_far < g_score[neighbor]) {
|
|
116791
|
-
|
|
116792
|
-
// update refined score
|
|
116800
|
+
// update actual cost
|
|
116793
116801
|
g_score[neighbor] = cost_so_far;
|
|
116794
116802
|
|
|
116795
116803
|
const remaining_heuristic = heuristic(neighbor, goal, width);
|
|
116796
116804
|
|
|
116797
116805
|
const refined_heuristic = cost_so_far + remaining_heuristic;
|
|
116798
116806
|
|
|
116799
|
-
|
|
116800
|
-
|
|
116801
|
-
open.insert(neighbor, refined_heuristic);
|
|
116802
|
-
} else {
|
|
116803
|
-
// Already seen the node, but since it has been re-scored we need to reorder it in the heap
|
|
116804
|
-
open.__update_score_by_index(index_in_open_set, refined_heuristic);
|
|
116805
|
-
}
|
|
116807
|
+
// Pushing to heap will put it in proper place based on the 'f' value.
|
|
116808
|
+
open.insert_or_update(neighbor, refined_heuristic);
|
|
116806
116809
|
}
|
|
116810
|
+
|
|
116807
116811
|
}
|
|
116808
116812
|
}
|
|
116809
116813
|
|