@woosh/meep-engine 2.87.4 → 2.87.5
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 +1 -1
- package/src/core/geom/2d/aabb/aabb2_intersects_ray.d.ts +2 -2
- package/src/core/geom/2d/aabb/aabb2_intersects_ray.d.ts.map +1 -1
- package/src/core/geom/2d/aabb/aabb2_intersects_ray.js +4 -7
- package/src/core/geom/2d/aabb/aabb2_intersects_ray.spec.js +3 -3
- package/src/core/geom/2d/quad-tree/qt_query_data_raycast.d.ts.map +1 -1
- package/src/core/geom/2d/quad-tree/qt_query_data_raycast.js +9 -5
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @param {number} origin_y
|
|
9
9
|
* @param {number} direction_x
|
|
10
10
|
* @param {number} direction_y
|
|
11
|
-
* @return {
|
|
11
|
+
* @return {boolean} true if hit found and false otherwise
|
|
12
12
|
*/
|
|
13
|
-
export function aabb2_intersects_ray(x0: number, y0: number, x1: number, y1: number, origin_x: number, origin_y: number, direction_x: number, direction_y: number):
|
|
13
|
+
export function aabb2_intersects_ray(x0: number, y0: number, x1: number, y1: number, origin_x: number, origin_y: number, direction_x: number, direction_y: number): boolean;
|
|
14
14
|
//# sourceMappingURL=aabb2_intersects_ray.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aabb2_intersects_ray.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/aabb/aabb2_intersects_ray.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,yCAVW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,YACN,MAAM,YACN,MAAM,eACN,MAAM,eACN,MAAM,GACL,
|
|
1
|
+
{"version":3,"file":"aabb2_intersects_ray.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/aabb/aabb2_intersects_ray.js"],"names":[],"mappings":"AAEA;;;;;;;;;;;GAWG;AACH,yCAVW,MAAM,MACN,MAAM,MACN,MAAM,MACN,MAAM,YACN,MAAM,YACN,MAAM,eACN,MAAM,eACN,MAAM,GACL,OAAO,CAqClB"}
|
|
@@ -10,7 +10,7 @@ import { fabsf } from "../../../math/fabsf.js";
|
|
|
10
10
|
* @param {number} origin_y
|
|
11
11
|
* @param {number} direction_x
|
|
12
12
|
* @param {number} direction_y
|
|
13
|
-
* @return {
|
|
13
|
+
* @return {boolean} true if hit found and false otherwise
|
|
14
14
|
*/
|
|
15
15
|
export function aabb2_intersects_ray(
|
|
16
16
|
x0, y0,
|
|
@@ -25,9 +25,8 @@ export function aabb2_intersects_ray(
|
|
|
25
25
|
|
|
26
26
|
const diff_x = origin_x - center_x;
|
|
27
27
|
|
|
28
|
-
|
|
29
28
|
if (diff_x * direction_x >= 0.0 && fabsf(diff_x) > extents_x) {
|
|
30
|
-
return
|
|
29
|
+
return false;
|
|
31
30
|
}
|
|
32
31
|
|
|
33
32
|
// Y projection
|
|
@@ -37,9 +36,8 @@ export function aabb2_intersects_ray(
|
|
|
37
36
|
|
|
38
37
|
const diff_y = origin_y - center_y;
|
|
39
38
|
|
|
40
|
-
|
|
41
39
|
if (diff_y * direction_y >= 0.0 && fabsf(diff_y) > extents_y) {
|
|
42
|
-
return
|
|
40
|
+
return false;
|
|
43
41
|
}
|
|
44
42
|
|
|
45
43
|
const abs_direction_y = fabsf(direction_y);
|
|
@@ -48,6 +46,5 @@ export function aabb2_intersects_ray(
|
|
|
48
46
|
|
|
49
47
|
const f2 = fabsf(direction_x * diff_y - direction_y * diff_x);
|
|
50
48
|
|
|
51
|
-
|
|
52
|
-
return distance_g - f2;
|
|
49
|
+
return f2 <= extents_x * abs_direction_y + extents_y * abs_direction_x;
|
|
53
50
|
}
|
|
@@ -7,7 +7,7 @@ test("diagonal ray hit", () => {
|
|
|
7
7
|
1, 1, 2, 2, 0, 0,
|
|
8
8
|
Math.SQRT2, Math.SQRT2
|
|
9
9
|
)
|
|
10
|
-
).
|
|
10
|
+
).toBe(true);
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
expect(
|
|
@@ -15,14 +15,14 @@ test("diagonal ray hit", () => {
|
|
|
15
15
|
1, 1, 2, 2, 3, 3,
|
|
16
16
|
-Math.SQRT2, -Math.SQRT2
|
|
17
17
|
)
|
|
18
|
-
).
|
|
18
|
+
).toBe(true);
|
|
19
19
|
|
|
20
20
|
expect(
|
|
21
21
|
aabb2_intersects_ray(
|
|
22
22
|
1, 1, 2, 2, 3, 0,
|
|
23
23
|
-Math.SQRT2, Math.SQRT2
|
|
24
24
|
)
|
|
25
|
-
).
|
|
25
|
+
).toBe(true);
|
|
26
26
|
|
|
27
27
|
|
|
28
28
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"qt_query_data_raycast.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/quad-tree/qt_query_data_raycast.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"qt_query_data_raycast.d.ts","sourceRoot":"","sources":["../../../../../../src/core/geom/2d/quad-tree/qt_query_data_raycast.js"],"names":[],"mappings":"AASA;;;;;;;;;;;GAWG;AACH,0EATW,MAAM,YACN,MAAM,eACN,MAAM,eACN,MAAM,gBACN,MAAM,2CAGJ,mBAAiB,SAAS,CA6EtC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { aabb2_distance_sqr_to_point } from "../aabb/aabb2_distance_sqr_to_point.js";
|
|
1
2
|
import { aabb2_intersects_ray } from "../aabb/aabb2_intersects_ray.js";
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -45,13 +46,14 @@ export function qt_query_data_raycast(
|
|
|
45
46
|
--stack_pointer;
|
|
46
47
|
const node = node_stack[stack_pointer];
|
|
47
48
|
|
|
48
|
-
const
|
|
49
|
+
const hit_node = aabb2_intersects_ray(node.x0, node.y0, node.x1, node.y1, origin_x, origin_y, direction_x, direction_y);
|
|
49
50
|
|
|
50
|
-
if (
|
|
51
|
-
// no hit
|
|
51
|
+
if (!hit_node) {
|
|
52
52
|
continue;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
const d2 = aabb2_distance_sqr_to_point(node.x0, node.y0, node.x1, node.y1, origin_x, origin_y);
|
|
56
|
+
|
|
55
57
|
if (d2 > best_match_distance) {
|
|
56
58
|
// too far, not a match
|
|
57
59
|
continue;
|
|
@@ -63,12 +65,14 @@ export function qt_query_data_raycast(
|
|
|
63
65
|
for (let i = 0; i < data_count; i++) {
|
|
64
66
|
const datum = data[i];
|
|
65
67
|
|
|
66
|
-
const
|
|
68
|
+
const hit_datum = aabb2_intersects_ray(datum.x0, datum.y0, datum.x1, datum.y1, origin_x, origin_y, direction_x, direction_y);
|
|
67
69
|
|
|
68
|
-
if (
|
|
70
|
+
if (!hit_datum) {
|
|
69
71
|
continue;
|
|
70
72
|
}
|
|
71
73
|
|
|
74
|
+
const d_to_datum = aabb2_distance_sqr_to_point(datum.x0, datum.y0, datum.x1, datum.y1, origin_x, origin_y);
|
|
75
|
+
|
|
72
76
|
if (d_to_datum < best_match_distance && predicate.call(
|
|
73
77
|
predicateContext,
|
|
74
78
|
datum.data,
|