@flighthq/collision 0.3.1-next.837.46a9259 → 0.3.1-next.847.2e6f8bf
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 +4 -4
- package/src/shapeCollision.test.ts +23 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flighthq/collision",
|
|
3
|
-
"version": "0.3.1-next.
|
|
3
|
+
"version": "0.3.1-next.847.2e6f8bf",
|
|
4
4
|
"author": "Joshua Granick and other contributors",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -38,9 +38,9 @@
|
|
|
38
38
|
"clean:dist": "tsx ../../scripts/clean-package-dist.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@flighthq/geometry": "0.3.1-next.
|
|
42
|
-
"@flighthq/log": "0.3.1-next.
|
|
43
|
-
"@flighthq/types": "0.3.1-next.
|
|
41
|
+
"@flighthq/geometry": "0.3.1-next.847.2e6f8bf",
|
|
42
|
+
"@flighthq/log": "0.3.1-next.847.2e6f8bf",
|
|
43
|
+
"@flighthq/types": "0.3.1-next.847.2e6f8bf"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"typescript": "^5.3.0"
|
|
@@ -126,6 +126,29 @@ describe('testAabbObbCollision', () => {
|
|
|
126
126
|
expect(out.depth).toBeCloseTo(1);
|
|
127
127
|
});
|
|
128
128
|
|
|
129
|
+
it.each([
|
|
130
|
+
['a zero half-width', { x: 2, y: 5, halfW: 0, halfH: 3, rotation: 0 }],
|
|
131
|
+
['a zero half-height', { x: 6, y: 5, halfW: 3, halfH: 0, rotation: 0 }],
|
|
132
|
+
['a negative half-width', { x: 6, y: 5, halfW: -3, halfH: 3, rotation: 0 }],
|
|
133
|
+
['a non-finite half-width', { x: 6, y: 5, halfW: Number.NaN, halfH: 3, rotation: 0 }],
|
|
134
|
+
['a non-finite half-height', { x: 6, y: 5, halfW: 3, halfH: Number.POSITIVE_INFINITY, rotation: 0 }],
|
|
135
|
+
['a non-finite rotation', { x: 6, y: 5, halfW: 3, halfH: 3, rotation: Number.NaN }],
|
|
136
|
+
['a non-finite center', { x: Number.NaN, y: 5, halfW: 3, halfH: 3, rotation: 0 }],
|
|
137
|
+
])('rejects an OBB with %s', (_case, b) => {
|
|
138
|
+
// The AABB path has had a zero-extent rejection test since it was written; the OBB path never got
|
|
139
|
+
// the matching one, so every field check in isValidObb was unpinned — including the two `> 0`
|
|
140
|
+
// extent tests, which a `>= 0` would have satisfied just as well. Walking the SHAPE's fields rather
|
|
141
|
+
// than the guards that happen to exist is what reaches the ones nobody thought to cover.
|
|
142
|
+
// Each degenerate box is placed where it WOULD overlap the AABB if validation wrongly accepted it:
|
|
143
|
+
// a zero-extent box parked outside the AABB returns false either way and pins nothing.
|
|
144
|
+
const out = createCollisionManifold();
|
|
145
|
+
out.overlapping = true;
|
|
146
|
+
out.normalX = 1;
|
|
147
|
+
out.depth = 4;
|
|
148
|
+
expect(testAabbObbCollision({ minX: 0, minY: 0, maxX: 4, maxY: 10 }, b as CollisionObb, out)).toBe(false);
|
|
149
|
+
expect(out).toEqual({ depth: 0, normalX: 0, normalY: 0, overlapping: false });
|
|
150
|
+
});
|
|
151
|
+
|
|
129
152
|
it('overlaps an axis-aligned OBB and pushes the box off it', () => {
|
|
130
153
|
const out = createCollisionManifold();
|
|
131
154
|
const a: CollisionAabb = { minX: 0, minY: 0, maxX: 4, maxY: 10 };
|