Skip to content

Commit

Permalink
feat: do not separate body on trigger collide
Browse files Browse the repository at this point in the history
  • Loading branch information
Prozi committed Aug 20, 2024
1 parent 8684da2 commit d066260
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 44 deletions.
8 changes: 5 additions & 3 deletions dist/demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 5 additions & 3 deletions dist/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion docs/assets/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `<svg width="20" height="20" viewBox="0 0 24 24" fill="none" class="tsd-kind-icon"><use href="#icon-${t.kind}"></use></svg>`),
(r.appendChild(document.createElement("span")).textContent = t.text);
Expand Down
20 changes: 10 additions & 10 deletions docs/classes/System.html
Original file line number Diff line number Diff line change
Expand Up @@ -1830,8 +1830,8 @@ <h4 class="tsd-returns-title">
<li>
Defined in
<a
href="https://github.com/Prozi/detect-collisions/blob/master/src/system.ts#L134"
>src/system.ts:134</a
href="https://github.com/Prozi/detect-collisions/blob/master/src/system.ts#L136"
>src/system.ts:136</a
>
</li>
</ul>
Expand Down Expand Up @@ -1924,8 +1924,8 @@ <h4 class="tsd-returns-title">
<li>
Defined in
<a
href="https://github.com/Prozi/detect-collisions/blob/master/src/system.ts#L119"
>src/system.ts:119</a
href="https://github.com/Prozi/detect-collisions/blob/master/src/system.ts#L121"
>src/system.ts:121</a
>
</li>
</ul>
Expand Down Expand Up @@ -2016,8 +2016,8 @@ <h4 class="tsd-returns-title">
<li>
Defined in
<a
href="https://github.com/Prozi/detect-collisions/blob/master/src/system.ts#L148"
>src/system.ts:148</a
href="https://github.com/Prozi/detect-collisions/blob/master/src/system.ts#L150"
>src/system.ts:150</a
>
</li>
</ul>
Expand Down Expand Up @@ -2110,8 +2110,8 @@ <h4 class="tsd-returns-title">
<li>
Defined in
<a
href="https://github.com/Prozi/detect-collisions/blob/master/src/system.ts#L93"
>src/system.ts:93</a
href="https://github.com/Prozi/detect-collisions/blob/master/src/system.ts#L95"
>src/system.ts:95</a
>
</li>
</ul>
Expand Down Expand Up @@ -3605,8 +3605,8 @@ <h4 class="tsd-returns-title">
<li>
Defined in
<a
href="https://github.com/Prozi/detect-collisions/blob/master/src/system.ts#L215"
>src/system.ts:215</a
href="https://github.com/Prozi/detect-collisions/blob/master/src/system.ts#L217"
>src/system.ts:217</a
>
</li>
</ul>
Expand Down
8 changes: 5 additions & 3 deletions docs/demo/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -39,6 +39,7 @@
"files": [
"dist/*.*",
"dist/bodies/*.*",
"dist/demo/*.*",
"dist/external/*.*"
],
"keywords": [
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
8 changes: 5 additions & 3 deletions src/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,11 @@ export class System<TBody extends Body = Body> extends BaseSystem<TBody> {
/**
* @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);
Expand Down
34 changes: 17 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit d066260

Please sign in to comment.