Skip to content

Commit

Permalink
fix: rotate concave Polygon's internal convexPolygon cache (#78)
Browse files Browse the repository at this point in the history
* test: add test for rotation concave polygons

* fix: set angle when updating convexPolygons

* chore: build concave fix

* feat: bump version
  • Loading branch information
RedPhoenixQ committed Jul 15, 2024
1 parent 4826ed0 commit 1da9ea2
Show file tree
Hide file tree
Showing 82 changed files with 1,149 additions and 724 deletions.
5 changes: 5 additions & 0 deletions dist/bodies/polygon.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ class Polygon extends sat_1.Polygon {
(0, optimized_1.forEach)(this.convexPolygons, (polygon) => {
polygon.pos.x = this.pos.x;
polygon.pos.y = this.pos.y;
if (polygon.angle !== this.angle) {
// Must use setAngle to recalculate the points of the Polygon
polygon.setAngle(this.angle);
}
});
}
/**
Expand Down Expand Up @@ -291,6 +295,7 @@ class Polygon extends sat_1.Polygon {
}
this.convexPolygons[index].pos.x = this.pos.x;
this.convexPolygons[index].pos.y = this.pos.y;
this.convexPolygons[index].angle = this.angle;
this.convexPolygons[index].setPoints((0, utils_1.ensurePolygonPoints)((0, optimized_1.map)(points, utils_1.mapArrayToVector)));
});
// trim array length
Expand Down
71 changes: 36 additions & 35 deletions dist/demo/demo.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/assets/navigation.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/assets/search.js

Large diffs are not rendered by default.

165 changes: 96 additions & 69 deletions docs/classes/Box.html

Large diffs are not rendered by default.

174 changes: 90 additions & 84 deletions docs/classes/Circle.html

Large diffs are not rendered by default.

171 changes: 99 additions & 72 deletions docs/classes/Ellipse.html

Large diffs are not rendered by default.

156 changes: 90 additions & 66 deletions docs/classes/Line.html

Large diffs are not rendered by default.

165 changes: 96 additions & 69 deletions docs/classes/Point.html

Large diffs are not rendered by default.

153 changes: 90 additions & 63 deletions docs/classes/Polygon.html

Large diffs are not rendered by default.

70 changes: 56 additions & 14 deletions docs/classes/RBush.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ <h4>Type Parameters</h4>
</section>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/rbush/index.d.ts:8</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/rbush/index.d.ts:8
</li>
</ul>
</aside>
<section class="tsd-panel-group tsd-index-group">
Expand Down Expand Up @@ -306,7 +309,10 @@ <h4 class="tsd-returns-title">
<div class="tsd-comment tsd-typography"></div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/rbush/index.d.ts:20</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/rbush/index.d.ts:20
</li>
</ul>
</aside>
</li>
Expand Down Expand Up @@ -359,7 +365,10 @@ <h4 class="tsd-returns-title">
<div class="tsd-comment tsd-typography"></div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/rbush/index.d.ts:77</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/rbush/index.d.ts:77
</li>
</ul>
</aside>
</li>
Expand Down Expand Up @@ -415,7 +424,10 @@ <h4 class="tsd-returns-title">
<div class="tsd-comment tsd-typography"></div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/rbush/index.d.ts:61</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/rbush/index.d.ts:61
</li>
</ul>
</aside>
</li>
Expand Down Expand Up @@ -483,7 +495,10 @@ <h4 class="tsd-returns-title">
<div class="tsd-comment tsd-typography"></div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/rbush/index.d.ts:85</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/rbush/index.d.ts:85
</li>
</ul>
</aside>
</li>
Expand Down Expand Up @@ -579,7 +594,10 @@ <h4>Example</h4>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/rbush/index.d.ts:130</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/rbush/index.d.ts:130
</li>
</ul>
</aside>
</li>
Expand Down Expand Up @@ -675,7 +693,10 @@ <h4>Example</h4>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/rbush/index.d.ts:154</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/rbush/index.d.ts:154
</li>
</ul>
</aside>
</li>
Expand Down Expand Up @@ -765,7 +786,10 @@ <h4 class="tsd-returns-title">
<div class="tsd-comment tsd-typography"></div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/rbush/index.d.ts:183</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/rbush/index.d.ts:183
</li>
</ul>
</aside>
</li>
Expand Down Expand Up @@ -844,7 +868,10 @@ <h4 class="tsd-returns-title">
<div class="tsd-comment tsd-typography"></div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/rbush/index.d.ts:27</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/rbush/index.d.ts:27
</li>
</ul>
</aside>
</li>
Expand Down Expand Up @@ -935,7 +962,10 @@ <h4 class="tsd-returns-title">
<div class="tsd-comment tsd-typography"></div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/rbush/index.d.ts:44</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/rbush/index.d.ts:44
</li>
</ul>
</aside>
</li>
Expand Down Expand Up @@ -1085,7 +1115,10 @@ <h4 class="tsd-returns-title">
<div class="tsd-comment tsd-typography"></div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/rbush/index.d.ts:56</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/rbush/index.d.ts:56
</li>
</ul>
</aside>
</li>
Expand Down Expand Up @@ -1163,7 +1196,10 @@ <h4 class="tsd-returns-title">
<div class="tsd-comment tsd-typography"></div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/rbush/index.d.ts:72</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/rbush/index.d.ts:72
</li>
</ul>
</aside>
</li>
Expand Down Expand Up @@ -1244,7 +1280,10 @@ <h4>Example</h4>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/rbush/index.d.ts:106</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/rbush/index.d.ts:106
</li>
</ul>
</aside>
</li>
Expand Down Expand Up @@ -1297,7 +1336,10 @@ <h4 class="tsd-returns-title">
<div class="tsd-comment tsd-typography"></div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/rbush/index.d.ts:167</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/rbush/index.d.ts:167
</li>
</ul>
</aside>
</li>
Expand Down
50 changes: 40 additions & 10 deletions docs/classes/Response.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ <h1>Class Response</h1>
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/sat/index.d.ts:70</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/sat/index.d.ts:70
</li>
</ul>
</aside>
<section class="tsd-panel-group tsd-index-group">
Expand Down Expand Up @@ -213,7 +216,10 @@ <h4 class="tsd-returns-title">
</h4>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/sat/index.d.ts:71</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/sat/index.d.ts:71
</li>
</ul>
</aside>
</li>
Expand All @@ -238,7 +244,10 @@ <h3 class="tsd-anchor-link">
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/sat/index.d.ts:73</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/sat/index.d.ts:73
</li>
</ul>
</aside>
</section>
Expand All @@ -258,7 +267,10 @@ <h3 class="tsd-anchor-link">
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/sat/index.d.ts:78</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/sat/index.d.ts:78
</li>
</ul>
</aside>
</section>
Expand All @@ -278,7 +290,10 @@ <h3 class="tsd-anchor-link">
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/sat/index.d.ts:74</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/sat/index.d.ts:74
</li>
</ul>
</aside>
</section>
Expand All @@ -298,7 +313,10 @@ <h3 class="tsd-anchor-link">
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/sat/index.d.ts:79</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/sat/index.d.ts:79
</li>
</ul>
</aside>
</section>
Expand All @@ -318,7 +336,10 @@ <h3 class="tsd-anchor-link">
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/sat/index.d.ts:75</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/sat/index.d.ts:75
</li>
</ul>
</aside>
</section>
Expand All @@ -343,7 +364,10 @@ <h3 class="tsd-anchor-link">
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/sat/index.d.ts:76</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/sat/index.d.ts:76
</li>
</ul>
</aside>
</section>
Expand All @@ -368,7 +392,10 @@ <h3 class="tsd-anchor-link">
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/sat/index.d.ts:77</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/sat/index.d.ts:77
</li>
</ul>
</aside>
</section>
Expand Down Expand Up @@ -414,7 +441,10 @@ <h4 class="tsd-returns-title">
</h4>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/sat/index.d.ts:81</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/sat/index.d.ts:81
</li>
</ul>
</aside>
</li>
Expand Down
20 changes: 16 additions & 4 deletions docs/classes/SATCircle.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,10 @@ <h4>
</section>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/sat/index.d.ts:36</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/sat/index.d.ts:36
</li>
</ul>
</aside>
<section class="tsd-panel-group tsd-index-group">
Expand Down Expand Up @@ -222,7 +225,10 @@ <h4 class="tsd-returns-title">
</h4>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/sat/index.d.ts:37</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/sat/index.d.ts:37
</li>
</ul>
</aside>
</li>
Expand All @@ -249,7 +255,10 @@ <h3 class="tsd-anchor-link">
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/sat/index.d.ts:39</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/sat/index.d.ts:39
</li>
</ul>
</aside>
</section>
Expand All @@ -269,7 +278,10 @@ <h3 class="tsd-anchor-link">
</div>
<aside class="tsd-sources">
<ul>
<li>Defined in node_modules/@types/sat/index.d.ts:40</li>
<li>
Defined in
node_modules/.pnpm/@[email protected]/node_modules/@types/sat/index.d.ts:40
</li>
</ul>
</aside>
</section>
Expand Down
Loading

0 comments on commit 1da9ea2

Please sign in to comment.