@flighthq/collision 0.1.0
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/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/manifold.d.ts +4 -0
- package/dist/manifold.d.ts.map +1 -0
- package/dist/manifold.js +14 -0
- package/dist/manifold.js.map +1 -0
- package/dist/pointContainment.d.ts +3 -0
- package/dist/pointContainment.d.ts.map +1 -0
- package/dist/pointContainment.js +71 -0
- package/dist/pointContainment.js.map +1 -0
- package/dist/segmentCollision.d.ts +7 -0
- package/dist/segmentCollision.d.ts.map +1 -0
- package/dist/segmentCollision.js +161 -0
- package/dist/segmentCollision.js.map +1 -0
- package/dist/shapeCollision.d.ts +12 -0
- package/dist/shapeCollision.d.ts.map +1 -0
- package/dist/shapeCollision.js +441 -0
- package/dist/shapeCollision.js.map +1 -0
- package/dist/testCollision.d.ts +3 -0
- package/dist/testCollision.d.ts.map +1 -0
- package/dist/testCollision.js +90 -0
- package/dist/testCollision.js.map +1 -0
- package/package.json +38 -0
- package/src/manifold.test.ts +31 -0
- package/src/pointContainment.test.ts +56 -0
- package/src/segmentCollision.test.ts +108 -0
- package/src/shapeCollision.test.ts +329 -0
- package/src/testCollision.test.ts +60 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifold.d.ts","sourceRoot":"","sources":["../src/manifold.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAKzD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI,CAKnE;AAGD,wBAAgB,uBAAuB,IAAI,iBAAiB,CAE3D"}
|
package/dist/manifold.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Clears a manifold to the non-overlapping state: `overlapping` false, normal and depth zero. The
|
|
2
|
+
// narrow-phase tests call this on their disjoint path, so a reused `out` never carries a stale
|
|
3
|
+
// normal into a miss.
|
|
4
|
+
export function clearCollisionManifold(out) {
|
|
5
|
+
out.overlapping = false;
|
|
6
|
+
out.normalX = 0;
|
|
7
|
+
out.normalY = 0;
|
|
8
|
+
out.depth = 0;
|
|
9
|
+
}
|
|
10
|
+
// Allocates a fresh manifold in the non-overlapping state, ready to be passed as an `out` parameter.
|
|
11
|
+
export function createCollisionManifold() {
|
|
12
|
+
return { overlapping: false, normalX: 0, normalY: 0, depth: 0 };
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=manifold.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manifold.js","sourceRoot":"","sources":["../src/manifold.ts"],"names":[],"mappings":"AAEA,kGAAkG;AAClG,+FAA+F;AAC/F,sBAAsB;AACtB,MAAM,UAAU,sBAAsB,CAAC,GAAsB;IAC3D,GAAG,CAAC,WAAW,GAAG,KAAK,CAAC;IACxB,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC;IAChB,GAAG,CAAC,OAAO,GAAG,CAAC,CAAC;IAChB,GAAG,CAAC,KAAK,GAAG,CAAC,CAAC;AAChB,CAAC;AAED,qGAAqG;AACrG,MAAM,UAAU,uBAAuB;IACrC,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointContainment.d.ts","sourceRoot":"","sources":["../src/pointContainment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAQtD,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CA2C7G"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const EPS = 1e-9;
|
|
2
|
+
// Whether the point (`x`,`y`) lies inside a collider. Boundary-inclusive: a point exactly on the
|
|
3
|
+
// edge of any shape counts as contained. For the area-less kinds this degrades to an on-shape test —
|
|
4
|
+
// `segment` returns true when the point lies on the segment (within epsilon), `point` when the two
|
|
5
|
+
// points coincide (within epsilon). Unknown kinds return false. The polygon is assumed convex.
|
|
6
|
+
export function getCollisionShapeContainsPoint(shape, x, y) {
|
|
7
|
+
switch (shape.kind) {
|
|
8
|
+
case 'circle': {
|
|
9
|
+
const dx = x - shape.x;
|
|
10
|
+
const dy = y - shape.y;
|
|
11
|
+
return dx * dx + dy * dy <= shape.radius * shape.radius;
|
|
12
|
+
}
|
|
13
|
+
case 'aabb':
|
|
14
|
+
return x >= shape.minX && x <= shape.maxX && y >= shape.minY && y <= shape.maxY;
|
|
15
|
+
case 'obb': {
|
|
16
|
+
const cos = Math.cos(shape.rotation);
|
|
17
|
+
const sin = Math.sin(shape.rotation);
|
|
18
|
+
const dx = x - shape.x;
|
|
19
|
+
const dy = y - shape.y;
|
|
20
|
+
const localX = dx * cos + dy * sin;
|
|
21
|
+
const localY = -dx * sin + dy * cos;
|
|
22
|
+
return Math.abs(localX) <= shape.halfW && Math.abs(localY) <= shape.halfH;
|
|
23
|
+
}
|
|
24
|
+
case 'polygon':
|
|
25
|
+
return isPointInConvexPolygon(x, y, shape.points, shape.points.length >> 1);
|
|
26
|
+
case 'segment': {
|
|
27
|
+
const dx = shape.x1 - shape.x0;
|
|
28
|
+
const dy = shape.y1 - shape.y0;
|
|
29
|
+
const lengthSquared = dx * dx + dy * dy;
|
|
30
|
+
let t = 0;
|
|
31
|
+
if (lengthSquared > EPS) {
|
|
32
|
+
t = ((x - shape.x0) * dx + (y - shape.y0) * dy) / lengthSquared;
|
|
33
|
+
t = t < 0 ? 0 : t > 1 ? 1 : t;
|
|
34
|
+
}
|
|
35
|
+
const closestX = shape.x0 + t * dx;
|
|
36
|
+
const closestY = shape.y0 + t * dy;
|
|
37
|
+
const ddx = x - closestX;
|
|
38
|
+
const ddy = y - closestY;
|
|
39
|
+
return ddx * ddx + ddy * ddy <= EPS;
|
|
40
|
+
}
|
|
41
|
+
case 'point': {
|
|
42
|
+
const dx = x - shape.x;
|
|
43
|
+
const dy = y - shape.y;
|
|
44
|
+
return dx * dx + dy * dy <= EPS;
|
|
45
|
+
}
|
|
46
|
+
default:
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
// Convex point-in-polygon by sign consistency of the edge cross products. Winding-agnostic: the
|
|
51
|
+
// point is inside when it lies on the same side of (or on) every edge. `pn` is the vertex count.
|
|
52
|
+
function isPointInConvexPolygon(x, y, px, pn) {
|
|
53
|
+
let positive = false;
|
|
54
|
+
let negative = false;
|
|
55
|
+
for (let i = 0; i < pn; i++) {
|
|
56
|
+
const j = (i + 1) % pn;
|
|
57
|
+
const x0 = px[i << 1];
|
|
58
|
+
const y0 = px[(i << 1) + 1];
|
|
59
|
+
const x1 = px[j << 1];
|
|
60
|
+
const y1 = px[(j << 1) + 1];
|
|
61
|
+
const cross = (x1 - x0) * (y - y0) - (y1 - y0) * (x - x0);
|
|
62
|
+
if (cross > EPS)
|
|
63
|
+
positive = true;
|
|
64
|
+
else if (cross < -EPS)
|
|
65
|
+
negative = true;
|
|
66
|
+
if (positive && negative)
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
return true;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=pointContainment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pointContainment.js","sourceRoot":"","sources":["../src/pointContainment.ts"],"names":[],"mappings":"AAEA,MAAM,GAAG,GAAG,IAAI,CAAC;AAEjB,iGAAiG;AACjG,qGAAqG;AACrG,mGAAmG;AACnG,+FAA+F;AAC/F,MAAM,UAAU,8BAA8B,CAAC,KAA+B,EAAE,CAAS,EAAE,CAAS;IAClG,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,QAAQ,CAAC,CAAC,CAAC;YACd,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;YACvB,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;YACvB,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC1D,CAAC;QACD,KAAK,MAAM;YACT,OAAO,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC;QAClF,KAAK,KAAK,CAAC,CAAC,CAAC;YACX,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACrC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;YACrC,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;YACv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AC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC;QAC1D,IAAI,KAAK,GAAG,GAAG;YAAE,QAAQ,GAAG,IAAI,CAAC;aAC5B,IAAI,KAAK,GAAG,CAAC,GAAG;YAAE,QAAQ,GAAG,IAAI,CAAC;QACvC,IAAI,QAAQ,IAAI,QAAQ;YAAE,OAAO,KAAK,CAAC;IACzC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CollisionAabb, CollisionCircle, CollisionObb, CollisionPolygon, CollisionSegment } from '@flighthq/types';
|
|
2
|
+
export declare function testSegmentAabbCollision(a: Readonly<CollisionSegment>, b: Readonly<CollisionAabb>): boolean;
|
|
3
|
+
export declare function testSegmentCircleCollision(a: Readonly<CollisionSegment>, b: Readonly<CollisionCircle>): boolean;
|
|
4
|
+
export declare function testSegmentObbCollision(a: Readonly<CollisionSegment>, b: Readonly<CollisionObb>): boolean;
|
|
5
|
+
export declare function testSegmentPolygonCollision(a: Readonly<CollisionSegment>, b: Readonly<CollisionPolygon>): boolean;
|
|
6
|
+
export declare function testSegmentSegmentCollision(a: Readonly<CollisionSegment>, b: Readonly<CollisionSegment>): boolean;
|
|
7
|
+
//# sourceMappingURL=segmentCollision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segmentCollision.d.ts","sourceRoot":"","sources":["../src/segmentCollision.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AASxH,wBAAgB,wBAAwB,CAAC,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,GAAG,OAAO,CAE3G;AAGD,wBAAgB,0BAA0B,CAAC,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,GAAG,OAAO,CAgB/G;AAID,wBAAgB,uBAAuB,CAAC,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,OAAO,CAYzG;AAID,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAuBjH;AAGD,wBAAgB,2BAA2B,CAAC,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAEjH"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// Segment-vs-shape overlap queries. Segments are area-less, so these return a boolean rather than a
|
|
2
|
+
// manifold (a swept/contact answer is a later phase). All are boundary-inclusive: a segment that
|
|
3
|
+
// just grazes a shape counts as overlapping.
|
|
4
|
+
const EPS = 1e-9;
|
|
5
|
+
// Whether a segment overlaps an axis-aligned box (Liang–Barsky slab clip; inclusive).
|
|
6
|
+
export function testSegmentAabbCollision(a, b) {
|
|
7
|
+
return isSegmentOverlappingBox(a.x0, a.y0, a.x1, a.y1, b.minX, b.minY, b.maxX, b.maxY);
|
|
8
|
+
}
|
|
9
|
+
// Whether a segment overlaps a circle (nearest point on the segment within the radius; inclusive).
|
|
10
|
+
export function testSegmentCircleCollision(a, b) {
|
|
11
|
+
const x0 = a.x0;
|
|
12
|
+
const y0 = a.y0;
|
|
13
|
+
const dx = a.x1 - x0;
|
|
14
|
+
const dy = a.y1 - y0;
|
|
15
|
+
const lengthSquared = dx * dx + dy * dy;
|
|
16
|
+
let t = 0;
|
|
17
|
+
if (lengthSquared > EPS) {
|
|
18
|
+
t = ((b.x - x0) * dx + (b.y - y0) * dy) / lengthSquared;
|
|
19
|
+
t = t < 0 ? 0 : t > 1 ? 1 : t;
|
|
20
|
+
}
|
|
21
|
+
const closestX = x0 + t * dx;
|
|
22
|
+
const closestY = y0 + t * dy;
|
|
23
|
+
const ddx = b.x - closestX;
|
|
24
|
+
const ddy = b.y - closestY;
|
|
25
|
+
return ddx * ddx + ddy * ddy <= b.radius * b.radius;
|
|
26
|
+
}
|
|
27
|
+
// Whether a segment overlaps an oriented box (transformed into the box's local frame, then tested as
|
|
28
|
+
// segment-vs-AABB; inclusive).
|
|
29
|
+
export function testSegmentObbCollision(a, b) {
|
|
30
|
+
const cos = Math.cos(b.rotation);
|
|
31
|
+
const sin = Math.sin(b.rotation);
|
|
32
|
+
const d0x = a.x0 - b.x;
|
|
33
|
+
const d0y = a.y0 - b.y;
|
|
34
|
+
const d1x = a.x1 - b.x;
|
|
35
|
+
const d1y = a.y1 - b.y;
|
|
36
|
+
const localX0 = d0x * cos + d0y * sin;
|
|
37
|
+
const localY0 = -d0x * sin + d0y * cos;
|
|
38
|
+
const localX1 = d1x * cos + d1y * sin;
|
|
39
|
+
const localY1 = -d1x * sin + d1y * cos;
|
|
40
|
+
return isSegmentOverlappingBox(localX0, localY0, localX1, localY1, -b.halfW, -b.halfH, b.halfW, b.halfH);
|
|
41
|
+
}
|
|
42
|
+
// Whether a segment overlaps a convex polygon: true if either endpoint is inside, or the segment
|
|
43
|
+
// crosses any polygon edge (inclusive). The polygon is assumed convex.
|
|
44
|
+
export function testSegmentPolygonCollision(a, b) {
|
|
45
|
+
const points = b.points;
|
|
46
|
+
const pn = points.length >> 1;
|
|
47
|
+
if (isPointInConvexPolygon(a.x0, a.y0, points, pn))
|
|
48
|
+
return true;
|
|
49
|
+
if (isPointInConvexPolygon(a.x1, a.y1, points, pn))
|
|
50
|
+
return true;
|
|
51
|
+
for (let i = 0; i < pn; i++) {
|
|
52
|
+
const j = (i + 1) % pn;
|
|
53
|
+
if (isSegmentsIntersecting(a.x0, a.y0, a.x1, a.y1, points[i << 1], points[(i << 1) + 1], points[j << 1], points[(j << 1) + 1])) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
// Whether two segments intersect, including touching endpoints and collinear overlap (inclusive).
|
|
60
|
+
export function testSegmentSegmentCollision(a, b) {
|
|
61
|
+
return isSegmentsIntersecting(a.x0, a.y0, a.x1, a.y1, b.x0, b.y0, b.x1, b.y1);
|
|
62
|
+
}
|
|
63
|
+
// Convex point-in-polygon by sign consistency of the edge cross products (winding-agnostic,
|
|
64
|
+
// boundary-inclusive). `pn` is the vertex count.
|
|
65
|
+
function isPointInConvexPolygon(x, y, px, pn) {
|
|
66
|
+
let positive = false;
|
|
67
|
+
let negative = false;
|
|
68
|
+
for (let i = 0; i < pn; i++) {
|
|
69
|
+
const j = (i + 1) % pn;
|
|
70
|
+
const x0 = px[i << 1];
|
|
71
|
+
const y0 = px[(i << 1) + 1];
|
|
72
|
+
const x1 = px[j << 1];
|
|
73
|
+
const y1 = px[(j << 1) + 1];
|
|
74
|
+
const cross = (x1 - x0) * (y - y0) - (y1 - y0) * (x - x0);
|
|
75
|
+
if (cross > EPS)
|
|
76
|
+
positive = true;
|
|
77
|
+
else if (cross < -EPS)
|
|
78
|
+
negative = true;
|
|
79
|
+
if (positive && negative)
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
// Whether segment (a0,a1) intersects segment (b0,b1). Handles the parallel/collinear cases by
|
|
85
|
+
// projecting onto the first segment and testing interval overlap.
|
|
86
|
+
function isSegmentsIntersecting(ax0, ay0, ax1, ay1, bx0, by0, bx1, by1) {
|
|
87
|
+
const d1x = ax1 - ax0;
|
|
88
|
+
const d1y = ay1 - ay0;
|
|
89
|
+
const d2x = bx1 - bx0;
|
|
90
|
+
const d2y = by1 - by0;
|
|
91
|
+
const denom = d1x * d2y - d1y * d2x;
|
|
92
|
+
const ex = bx0 - ax0;
|
|
93
|
+
const ey = by0 - ay0;
|
|
94
|
+
if (Math.abs(denom) < EPS) {
|
|
95
|
+
// Parallel; intersect only if collinear and their projections onto d1 overlap.
|
|
96
|
+
if (Math.abs(ex * d1y - ey * d1x) > EPS)
|
|
97
|
+
return false;
|
|
98
|
+
const lengthSquared = d1x * d1x + d1y * d1y;
|
|
99
|
+
if (lengthSquared < EPS) {
|
|
100
|
+
// Segment A is degenerate (a point): true if it lies on B.
|
|
101
|
+
const bLengthSquared = d2x * d2x + d2y * d2y;
|
|
102
|
+
if (bLengthSquared < EPS) {
|
|
103
|
+
return Math.abs(ex) < EPS && Math.abs(ey) < EPS;
|
|
104
|
+
}
|
|
105
|
+
let tb = ((ax0 - bx0) * d2x + (ay0 - by0) * d2y) / bLengthSquared;
|
|
106
|
+
tb = tb < 0 ? 0 : tb > 1 ? 1 : tb;
|
|
107
|
+
const qx = bx0 + tb * d2x;
|
|
108
|
+
const qy = by0 + tb * d2y;
|
|
109
|
+
return (ax0 - qx) * (ax0 - qx) + (ay0 - qy) * (ay0 - qy) < EPS;
|
|
110
|
+
}
|
|
111
|
+
const t0 = (ex * d1x + ey * d1y) / lengthSquared;
|
|
112
|
+
const t1 = ((bx1 - ax0) * d1x + (by1 - ay0) * d1y) / lengthSquared;
|
|
113
|
+
const lo = t0 < t1 ? t0 : t1;
|
|
114
|
+
const hi = t0 < t1 ? t1 : t0;
|
|
115
|
+
return hi >= -EPS && lo <= 1 + EPS;
|
|
116
|
+
}
|
|
117
|
+
const t = (ex * d2y - ey * d2x) / denom;
|
|
118
|
+
const u = (ex * d1y - ey * d1x) / denom;
|
|
119
|
+
return t >= -EPS && t <= 1 + EPS && u >= -EPS && u <= 1 + EPS;
|
|
120
|
+
}
|
|
121
|
+
// Liang–Barsky segment-vs-AABB overlap (inclusive). Clips the segment parameter to [0,1] against the
|
|
122
|
+
// four box slabs; overlap survives when the clipped interval stays non-empty.
|
|
123
|
+
function isSegmentOverlappingBox(x0, y0, x1, y1, minX, minY, maxX, maxY) {
|
|
124
|
+
const dx = x1 - x0;
|
|
125
|
+
const dy = y1 - y0;
|
|
126
|
+
clipRange.t0 = 0;
|
|
127
|
+
clipRange.t1 = 1;
|
|
128
|
+
// Each slab contributes a `p*t <= q` constraint; `p === 0` means the segment is parallel to it.
|
|
129
|
+
if (!clipSegmentSlab(-dx, x0 - minX))
|
|
130
|
+
return false;
|
|
131
|
+
if (!clipSegmentSlab(dx, maxX - x0))
|
|
132
|
+
return false;
|
|
133
|
+
if (!clipSegmentSlab(-dy, y0 - minY))
|
|
134
|
+
return false;
|
|
135
|
+
if (!clipSegmentSlab(dy, maxY - y0))
|
|
136
|
+
return false;
|
|
137
|
+
return clipRange.t0 <= clipRange.t1;
|
|
138
|
+
}
|
|
139
|
+
// Narrows the shared clip range against one Liang–Barsky slab constraint `p*t <= q`. Returns false
|
|
140
|
+
// when the constraint rejects the whole segment. Mutates `clipRange` in place (no allocation).
|
|
141
|
+
function clipSegmentSlab(p, q) {
|
|
142
|
+
if (Math.abs(p) < EPS) {
|
|
143
|
+
return q >= 0;
|
|
144
|
+
}
|
|
145
|
+
const r = q / p;
|
|
146
|
+
if (p < 0) {
|
|
147
|
+
if (r > clipRange.t1)
|
|
148
|
+
return false;
|
|
149
|
+
if (r > clipRange.t0)
|
|
150
|
+
clipRange.t0 = r;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
if (r < clipRange.t0)
|
|
154
|
+
return false;
|
|
155
|
+
if (r < clipRange.t1)
|
|
156
|
+
clipRange.t1 = r;
|
|
157
|
+
}
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
const clipRange = { t0: 0, t1: 1 };
|
|
161
|
+
//# sourceMappingURL=segmentCollision.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"segmentCollision.js","sourceRoot":"","sources":["../src/segmentCollision.ts"],"names":[],"mappings":"AAEA,o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C,GAAG,SAAS,CAAC,EAAE;YAAE,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,GAAG,SAAS,CAAC,EAAE;YAAE,OAAO,KAAK,CAAC;QACnC,IAAI,CAAC,GAAG,SAAS,CAAC,EAAE;YAAE,SAAS,CAAC,EAAE,GAAG,CAAC,CAAC;IACzC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,SAAS,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CollisionAabb, CollisionCircle, CollisionManifold, CollisionObb, CollisionPolygon } from '@flighthq/types';
|
|
2
|
+
export declare function testAabbAabbCollision(a: Readonly<CollisionAabb>, b: Readonly<CollisionAabb>, out: CollisionManifold): boolean;
|
|
3
|
+
export declare function testAabbObbCollision(a: Readonly<CollisionAabb>, b: Readonly<CollisionObb>, out: CollisionManifold): boolean;
|
|
4
|
+
export declare function testAabbPolygonCollision(a: Readonly<CollisionAabb>, b: Readonly<CollisionPolygon>, out: CollisionManifold): boolean;
|
|
5
|
+
export declare function testCircleAabbCollision(a: Readonly<CollisionCircle>, b: Readonly<CollisionAabb>, out: CollisionManifold): boolean;
|
|
6
|
+
export declare function testCircleCircleCollision(a: Readonly<CollisionCircle>, b: Readonly<CollisionCircle>, out: CollisionManifold): boolean;
|
|
7
|
+
export declare function testCircleObbCollision(a: Readonly<CollisionCircle>, b: Readonly<CollisionObb>, out: CollisionManifold): boolean;
|
|
8
|
+
export declare function testCirclePolygonCollision(a: Readonly<CollisionCircle>, b: Readonly<CollisionPolygon>, out: CollisionManifold): boolean;
|
|
9
|
+
export declare function testObbObbCollision(a: Readonly<CollisionObb>, b: Readonly<CollisionObb>, out: CollisionManifold): boolean;
|
|
10
|
+
export declare function testObbPolygonCollision(a: Readonly<CollisionObb>, b: Readonly<CollisionPolygon>, out: CollisionManifold): boolean;
|
|
11
|
+
export declare function testPolygonPolygonCollision(a: Readonly<CollisionPolygon>, b: Readonly<CollisionPolygon>, out: CollisionManifold): boolean;
|
|
12
|
+
//# sourceMappingURL=shapeCollision.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shapeCollision.d.ts","sourceRoot":"","sources":["../src/shapeCollision.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,YAAY,EACZ,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AAqBzB,wBAAgB,qBAAqB,CACnC,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,EAC1B,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,EAC1B,GAAG,EAAE,iBAAiB,GACrB,OAAO,CAkCT;AAGD,wBAAgB,oBAAoB,CAClC,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,EAC1B,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,EACzB,GAAG,EAAE,iBAAiB,GACrB,OAAO,CAIT;AAGD,wBAAgB,wBAAwB,CACtC,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,EAC1B,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAC7B,GAAG,EAAE,iBAAiB,GACrB,OAAO,CAIT;AAID,wBAAgB,uBAAuB,CACrC,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,EAC5B,CAAC,EAAE,QAAQ,CAAC,aAAa,CAAC,EAC1B,GAAG,EAAE,iBAAiB,GACrB,OAAO,CAET;AAID,wBAAgB,yBAAyB,CACvC,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,EAC5B,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,EAC5B,GAAG,EAAE,iBAAiB,GACrB,OAAO,CA4BT;AAID,wBAAgB,sBAAsB,CACpC,CAAC,EAAE,QAAQ,CAAC,eAAe,CAAC,EAC5B,CAAC,EAA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