From d0662601129c7439a70146b76fb6738b7348dec5 Mon Sep 17 00:00:00 2001 From: "Prozi (Jacek Pietal)" Date: Tue, 20 Aug 2024 07:47:35 +0200 Subject: [PATCH] feat: do not separate body on trigger collide --- dist/demo/demo.js | 8 +++++--- dist/system.js | 8 +++++--- docs/assets/main.js | 4 +++- docs/classes/System.html | 20 ++++++++++---------- docs/demo/demo.js | 8 +++++--- package.json | 10 ++++++---- src/system.ts | 8 +++++--- yarn.lock | 34 +++++++++++++++++----------------- 8 files changed, 56 insertions(+), 44 deletions(-) diff --git a/dist/demo/demo.js b/dist/demo/demo.js index 30d9b14e..4cb4cc9a 100644 --- a/dist/demo/demo.js +++ b/dist/demo/demo.js @@ -4028,9 +4028,11 @@ which is good. See: http://baagoe.com/en/RandomMusings/hash/avalanche.xhtml /** * @param response */ - const addOffsets = ({ overlapV: { x, y } }) => { - offsets.x += x; - offsets.y += y; + const addOffsets = ({ b: { isTrigger }, overlapV: { x, y } }) => { + if (!isTrigger) { + offsets.x += x; + offsets.y += y; + } }; this.checkOne(body, addOffsets); if (offsets.x || offsets.y) { diff --git a/dist/system.js b/dist/system.js index 7b169bcf..9d98805e 100644 --- a/dist/system.js +++ b/dist/system.js @@ -47,9 +47,11 @@ class System extends base_system_1.BaseSystem { /** * @param response */ - const addOffsets = ({ overlapV: { x, y } }) => { - offsets.x += x; - offsets.y += y; + const addOffsets = ({ b: { isTrigger }, overlapV: { x, y } }) => { + if (!isTrigger) { + offsets.x += x; + offsets.y += y; + } }; this.checkOne(body, addOffsets); if (offsets.x || offsets.y) { diff --git a/docs/assets/main.js b/docs/assets/main.js index 5f0de445..22969f90 100644 --- a/docs/assets/main.js +++ b/docs/assets/main.js @@ -2139,7 +2139,9 @@ window.translations = { let r = e.appendChild(document.createElement("a")); (r.href = K + t.path), n && (r.className = n), - location.pathname === r.pathname && r.classList.add("current"), + location.pathname === r.pathname && + !r.href.includes("#") && + r.classList.add("current"), t.kind && (r.innerHTML = ``), (r.appendChild(document.createElement("span")).textContent = t.text); diff --git a/docs/classes/System.html b/docs/classes/System.html index 67488659..449dea98 100644 --- a/docs/classes/System.html +++ b/docs/classes/System.html @@ -1830,8 +1830,8 @@

  • Defined in src/system.ts:134src/system.ts:136
  • @@ -1924,8 +1924,8 @@

  • Defined in src/system.ts:119src/system.ts:121
  • @@ -2016,8 +2016,8 @@

  • Defined in src/system.ts:148src/system.ts:150
  • @@ -2110,8 +2110,8 @@

  • Defined in src/system.ts:93src/system.ts:95
  • @@ -3605,8 +3605,8 @@

  • Defined in src/system.ts:215src/system.ts:217
  • diff --git a/docs/demo/demo.js b/docs/demo/demo.js index 30d9b14e..4cb4cc9a 100644 --- a/docs/demo/demo.js +++ b/docs/demo/demo.js @@ -4028,9 +4028,11 @@ which is good. See: http://baagoe.com/en/RandomMusings/hash/avalanche.xhtml /** * @param response */ - const addOffsets = ({ overlapV: { x, y } }) => { - offsets.x += x; - offsets.y += y; + const addOffsets = ({ b: { isTrigger }, overlapV: { x, y } }) => { + if (!isTrigger) { + offsets.x += x; + offsets.y += y; + } }; this.checkOne(body, addOffsets); if (offsets.x || offsets.y) { diff --git a/package.json b/package.json index 9c24e129..8182ee23 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "detect-collisions", - "version": "9.12.0", + "version": "9.13.0", "description": "Detect collisions between different shapes such as Points, Lines, Boxes, Polygons (including concave), Ellipses, and Circles. Features include RayCasting and support for offsets, rotation, scaling, bounding box padding, with options for static and trigger bodies (non-colliding).", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -39,6 +39,7 @@ "files": [ "dist/*.*", "dist/bodies/*.*", + "dist/demo/*.*", "dist/external/*.*" ], "keywords": [ @@ -74,8 +75,8 @@ "sat": "^0.9.0" }, "devDependencies": { - "@types/node": "^22.3.0", - "@types/rbush": "^3.0.3", + "@types/node": "^22.4.1", + "@types/rbush": "^3.0.4", "chef-express": "^2.1.4", "html-webpack-plugin": "^5.6.0", "husky": "^9.1.4", @@ -88,13 +89,14 @@ "ts-jest": "^29.2.4", "ts-loader": "^9.5.1", "tslint": "^6.1.3", - "typedoc": "^0.26.5", + "typedoc": "^0.26.6", "typescript": "^5", "webpack": "^5.93.0", "webpack-cli": "^5.1.4", "webpack-dev-server": "^5.0.4" }, "resolutions": { + "@types/node": "^22.4.1", "canvas": "^2.11.2", "minimist": "^1.2.6", "terser": "^5.14.2", diff --git a/src/system.ts b/src/system.ts index 082e8c6e..bdef5813 100644 --- a/src/system.ts +++ b/src/system.ts @@ -75,9 +75,11 @@ export class System extends BaseSystem { /** * @param response */ - const addOffsets = ({ overlapV: { x, y } }: Response) => { - offsets.x += x; - offsets.y += y; + const addOffsets = ({ b: { isTrigger }, overlapV: { x, y } }: Response) => { + if (!isTrigger) { + offsets.x += x; + offsets.y += y; + } }; this.checkOne(body, addOffsets); diff --git a/yarn.lock b/yarn.lock index aaff28dd..221f11d2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -820,12 +820,12 @@ dependencies: undici-types "~5.26.4" -"@types/node@^22.3.0": - version "22.3.0" - resolved "https://registry.yarnpkg.com/@types/node/-/node-22.3.0.tgz#7f8da0e2b72c27c4f9bd3cb5ef805209d04d4f9e" - integrity sha512-nrWpWVaDZuaVc5X84xJ0vNrLvomM205oQyLsRt7OHNZbSHslcWsvgFR7O7hire2ZonjLrWBbedmotmIlJDVd6g== +"@types/node@^22.4.1": + version "22.4.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-22.4.1.tgz#9b595d292c65b94c20923159e2ce947731b6fdce" + integrity sha512-1tbpb9325+gPnKK0dMm+/LMriX0vKxf6RnB0SZUqfyVkQ4fMgUSySqhxE/y8Jvs4NyF1yHzTfG9KlnkIODxPKg== dependencies: - undici-types "~6.18.2" + undici-types "~6.19.2" "@types/qs@*": version "6.9.15" @@ -837,10 +837,10 @@ resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb" integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ== -"@types/rbush@^3.0.3": - version "3.0.3" - resolved "https://registry.yarnpkg.com/@types/rbush/-/rbush-3.0.3.tgz#f7ba6bc940e0913678f5df119e7a7803f1842ece" - integrity sha512-lX55lR0iYCgapxD3IrgujpQA1zDxwZI5qMRelKvmKAsSMplFVr7wmMpG7/6+Op2tjrgEex8o3vjg8CRDrRNYxg== +"@types/rbush@^3.0.4": + version "3.0.4" + resolved "https://registry.yarnpkg.com/@types/rbush/-/rbush-3.0.4.tgz#265d84ec76dc48e464e95ae4f58e085f28f0a227" + integrity sha512-knSt9cCW8jj1ZSFcFeBZaX++OucmfPxxHiRwTahZfJlnQsek7O0bazTJHWD2RVj9LEoejUYF2de3/stf+QXcXw== "@types/retry@0.12.2": version "0.12.2" @@ -4481,10 +4481,10 @@ type-is@~1.6.18: media-typer "0.3.0" mime-types "~2.1.24" -typedoc@^0.26.5: - version "0.26.5" - resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.26.5.tgz#08032bd57cac3d56e8ac296a07e3482dc0c645ac" - integrity sha512-Vn9YKdjKtDZqSk+by7beZ+xzkkr8T8CYoiasqyt4TTRFy5+UHzL/mF/o4wGBjRF+rlWQHDb0t6xCpA3JNL5phg== +typedoc@^0.26.6: + version "0.26.6" + resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.26.6.tgz#9cb3d6f0ed5070f86af169c3f88ca2c9b7031f59" + integrity sha512-SfEU3SH3wHNaxhFPjaZE2kNl/NFtLNW5c1oHsg7mti7GjmUj1Roq6osBQeMd+F4kL0BoRBBr8gQAuqBlfFu8LA== dependencies: lunr "^2.3.9" markdown-it "^14.1.0" @@ -4507,10 +4507,10 @@ undici-types@~5.26.4: resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617" integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA== -undici-types@~6.18.2: - version "6.18.2" - resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.18.2.tgz#8b678cf939d4fc9ec56be3c68ed69c619dee28b0" - integrity sha512-5ruQbENj95yDYJNS3TvcaxPMshV7aizdv/hWYjGIKoANWKjhWNBsr2YEuYZKodQulB1b8l7ILOuDQep3afowQQ== +undici-types@~6.19.2: + version "6.19.8" + resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-6.19.8.tgz#35111c9d1437ab83a7cdc0abae2f26d88eda0a02" + integrity sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw== unpipe@1.0.0, unpipe@~1.0.0: version "1.0.0"