@woosh/meep-engine 2.131.41 → 2.131.42
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/package.json
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"description": "Pure JavaScript game engine. Fully featured and production ready.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"author": "Alexander Goldring",
|
|
8
|
-
"version": "2.131.
|
|
8
|
+
"version": "2.131.42",
|
|
9
9
|
"main": "build/meep.module.js",
|
|
10
10
|
"module": "build/meep.module.js",
|
|
11
11
|
"exports": {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param {number[]} result
|
|
4
|
+
* @param {number} result_offset
|
|
5
|
+
* @param {BVH} bvh
|
|
6
|
+
* @param {number[]|Float32Array|AABB3} aabb
|
|
7
|
+
*/
|
|
8
|
+
export function bvh_query_user_data_overlaps_aabb(result: number[], result_offset: number, bvh: BVH, aabb: number[] | Float32Array | AABB3): number;
|
|
9
|
+
//# sourceMappingURL=bvh_query_user_data_overlaps_aabb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bvh_query_user_data_overlaps_aabb.d.ts","sourceRoot":"","sources":["../../../../../../src/core/bvh2/bvh3/query/bvh_query_user_data_overlaps_aabb.js"],"names":[],"mappings":"AASA;;;;;;GAMG;AACH,0DALW,MAAM,EAAE,iBACR,MAAM,kBAEN,MAAM,EAAE,GAAC,YAAY,QAAM,UAoErC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//
|
|
2
|
+
import { SCRATCH_UINT32_TRAVERSAL_STACK } from "../../../collection/SCRATCH_UINT32_TRAVERSAL_STACK.js";
|
|
3
|
+
import { aabb3_intersects_aabb3 } from "../../../geom/3d/aabb/aabb3_intersects_aabb3.js";
|
|
4
|
+
import { NULL_NODE } from "../BVH.js";
|
|
5
|
+
|
|
6
|
+
const stack = SCRATCH_UINT32_TRAVERSAL_STACK;
|
|
7
|
+
|
|
8
|
+
const scratch_aabb = new Float32Array(6);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param {number[]} result
|
|
13
|
+
* @param {number} result_offset
|
|
14
|
+
* @param {BVH} bvh
|
|
15
|
+
* @param {number[]|Float32Array|AABB3} aabb
|
|
16
|
+
*/
|
|
17
|
+
export function bvh_query_user_data_overlaps_aabb(
|
|
18
|
+
result,
|
|
19
|
+
result_offset,
|
|
20
|
+
bvh,
|
|
21
|
+
aabb
|
|
22
|
+
) {
|
|
23
|
+
const root = bvh.root;
|
|
24
|
+
|
|
25
|
+
if (root === NULL_NODE) {
|
|
26
|
+
return 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @type {number}
|
|
32
|
+
*/
|
|
33
|
+
const stack_top = stack.pointer++;
|
|
34
|
+
|
|
35
|
+
stack[stack_top] = root;
|
|
36
|
+
|
|
37
|
+
let result_cursor = result_offset;
|
|
38
|
+
|
|
39
|
+
while (stack.pointer > stack_top) {
|
|
40
|
+
stack.pointer--;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
*
|
|
44
|
+
* @type {number}
|
|
45
|
+
*/
|
|
46
|
+
const node = stack[stack.pointer];
|
|
47
|
+
|
|
48
|
+
// test node against the ray
|
|
49
|
+
bvh.node_get_aabb(node, scratch_aabb);
|
|
50
|
+
|
|
51
|
+
const intersection_exists = aabb3_intersects_aabb3(
|
|
52
|
+
scratch_aabb[0], scratch_aabb[1], scratch_aabb[2],
|
|
53
|
+
scratch_aabb[3], scratch_aabb[4], scratch_aabb[5],
|
|
54
|
+
aabb[0], aabb[1], aabb[2],
|
|
55
|
+
aabb[3], aabb[4], aabb[5]
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
if (!intersection_exists) {
|
|
59
|
+
// fully outside
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const node_is_leaf = bvh.node_is_leaf(node);
|
|
64
|
+
|
|
65
|
+
if (node_is_leaf) {
|
|
66
|
+
// leaf node
|
|
67
|
+
result[result_cursor++] = bvh.node_get_user_data(node);
|
|
68
|
+
|
|
69
|
+
} else {
|
|
70
|
+
// read in-order
|
|
71
|
+
const child1 = bvh.node_get_child1(node);
|
|
72
|
+
const child2 = bvh.node_get_child2(node);
|
|
73
|
+
|
|
74
|
+
// write to stack in reverse order, so that fist child ends up being visited first
|
|
75
|
+
stack[stack.pointer++] = child1;
|
|
76
|
+
stack[stack.pointer++] = child2;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// drop stack frame
|
|
81
|
+
|
|
82
|
+
return result_cursor - result_offset;
|
|
83
|
+
}
|