Commit e7daba3
authored
fix!: Remove middle intersection point on shared line segments in collision detection (#4004)
When two line segments were collinear and overlapping,
`LineSegment.intersections` returned a single synthetic point: the
average of the overlap's end points. For shape collision detection this
meant that two shapes sharing an edge (for example two axis-aligned
rectangles standing side by side) reported both the real corner points
and an extra point in the middle of the shared edge.
This PR changes the collinear-overlap case of
`LineSegment.intersections` to return the actual end points of the
overlapping section instead of their average. Segments that only touch
in a single point still return that one point. As a result, collision
detection on shared edges now only reports the end points of the shared
segment, without the synthetic middle point.
The dartdoc on `LineSegment.intersections` and
`PolygonPolygonIntersections.intersect` has been updated to describe the
new behavior, and the affected tests now assert the overlap end points.1 parent 698f261 commit e7daba3
4 files changed
Lines changed: 19 additions & 27 deletions
File tree
- packages/flame
- lib/src/geometry
- test/collisions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
68 | | - | |
69 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
70 | 72 | | |
71 | 73 | | |
72 | 74 | | |
| |||
86 | 88 | | |
87 | 89 | | |
88 | 90 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
| 91 | + | |
94 | 92 | | |
95 | 93 | | |
96 | | - | |
| 94 | + | |
97 | 95 | | |
98 | 96 | | |
99 | 97 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
| 34 | + | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
Lines changed: 9 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
107 | 107 | | |
108 | 108 | | |
109 | 109 | | |
110 | | - | |
111 | | - | |
112 | | - | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
113 | 113 | | |
114 | | - | |
115 | 114 | | |
116 | 115 | | |
117 | 116 | | |
118 | 117 | | |
119 | 118 | | |
120 | 119 | | |
121 | 120 | | |
122 | | - | |
123 | | - | |
124 | | - | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
125 | 124 | | |
126 | | - | |
127 | 125 | | |
128 | 126 | | |
129 | 127 | | |
| |||
312 | 310 | | |
313 | 311 | | |
314 | 312 | | |
315 | | - | |
316 | 313 | | |
317 | 314 | | |
318 | 315 | | |
319 | 316 | | |
320 | 317 | | |
321 | | - | |
| 318 | + | |
322 | 319 | | |
323 | 320 | | |
324 | 321 | | |
| |||
377 | 374 | | |
378 | 375 | | |
379 | 376 | | |
380 | | - | |
381 | 377 | | |
382 | | - | |
383 | 378 | | |
384 | 379 | | |
385 | 380 | | |
386 | 381 | | |
387 | 382 | | |
388 | | - | |
| 383 | + | |
389 | 384 | | |
390 | 385 | | |
391 | 386 | | |
| |||
457 | 452 | | |
458 | 453 | | |
459 | 454 | | |
460 | | - | |
461 | 455 | | |
462 | 456 | | |
463 | 457 | | |
464 | 458 | | |
465 | 459 | | |
466 | | - | |
| 460 | + | |
467 | 461 | | |
468 | 462 | | |
469 | 463 | | |
| |||
0 commit comments