|
Xkeeper Level: 263 ![]() Posts: 17473/25353 EXP: 297157138 For next: 1803315 Since: 07-03-07 Pronouns: they/them/???????? Since last post: 3 days Last activity: 14 hours |
| |
|
![]() Register - Login | |||||
|
Main
- Memberlist
- Active users
- Calendar
- Wiki
- IRC Chat
- Online users Ranks - Rules/FAQ - Stats - Latest Posts - Color Chart - Smilies |
|
| | |||
| Jul - Craziness Domain - another thing |
- - ![]() |
| Next newer thread | Next older thread |
|
Xkeeper Level: 263 ![]() Posts: 17473/25353 EXP: 297157138 For next: 1803315 Since: 07-03-07 Pronouns: they/them/???????? Since last post: 3 days Last activity: 14 hours |
| |
|
|
Sails 2800 ![]() ![]() ![]() ![]() ![]() ![]() as a video game grows old its content and internal logic deteriorateÿ Level: 102 ![]() Posts: 2374/2803 EXP: 10922943 For next: 167024 Since: 07-04-07 Pronouns: He/Him From: MA Since last post: 120 days Last activity: 29 days |
|
|
|
Xkeeper Level: 263 ![]() Posts: 17474/25353 EXP: 297157138 For next: 1803315 Since: 07-03-07 Pronouns: they/them/???????? Since last post: 3 days Last activity: 14 hours |
|
|
Xkeeper Level: 263 ![]() Posts: 17483/25353 EXP: 297157138 For next: 1803315 Since: 07-03-07 Pronouns: they/them/???????? Since last post: 3 days Last activity: 14 hours |
| |
|
|
Miasmir Member ![]() Level: 50 Posts: 334/528 EXP: 891156 For next: 56161 Since: 07-26-07 From: Lavastone (don't tell the pirate orcs) Since last post: 87 days Last activity: 6 days |
|
| Super tired collision detection ramblings incoming. Haven't played the game or read the source. Probably making huge wrong assumptions. Trying to help anyway.
With a circle represented as a center (x,y) and a radius and a rectangle by four points (x,y) (this choice of representation for a rectangle seems reasonable because it generalizes to convex polygons for this collision detection case, if you've got some matrix-based shenanigans I don't know how I'd do this for that) there's a fairly simple way to determine collisions between circles and rectangles. Basically, you want to find the closest point to the circle on the rectangle, and see if that point is within the radius of the circle. This closest point is either one of the vertices or a point on an edge; if it's a point on an edge then it's the image of the center when it's projected onto that edge. So you check to see if any of the vertices is within the circle, and if not, then you take the closest edge (the edge with the two closest vertices as endpoints) and project the center onto that line. If the projection is not between the two closest vertices, there is no collision. In all other cases there is a collision. Between two rectangles of arbitrary orientation, edge vs edge collisions are uncommon and you may even want to ignore them because it makes things easier and instead check only vertex/edge collisions. There is a vertex/edge collision if and only if at least one vertex is inside the other rectangle. It could be best to apply a coordinate transform so that one rectangle is at 0° and then use your existing bounds check function on each of the vertices of the other. The general convex polygon case generally requires you to identify the edges closest to the center of the other polygon and find the intersection of those edges, then check if that intersection actually lies on both polygons. The case you mention with two rectangles crossing and no vertex inside another rectangle happens more or less depending on the speeds and shapes of the rectangles. If it's an issue then the line intersection method is more appropriate than bounds checking on each vertex. Heck, just use that anyway, it's not like performance intensive nonsense is likely to be a concern. if performance intensive nonsense becomes a concern, look into some of the methods that rely on data from previous frames to save calculation time. That's typically how it's done for crazy 3D simulations for science. In that case I'd actually advise you to start with Wikipedia's page on collision detection; it goes into surprising detail on a few of these issues. |
|
Darkdata Ruins!? ♥ Level: 103 ![]() Posts: 1672/2892 EXP: 11446674 For next: 24732 Since: 07-04-07 Since last post: 203 days Last activity: 11 days |
|
Press 4/5 for new weapons!
4: Stardust-Shooter - Shoots a large laggy circle around your ship, or a fast small circle. 5: ??? never gave it a real name, Ringtoss? Shoots a ring weapon from your ship, slowbig, fastsmall again. ____________________ |
|
Sails 2800 ![]() ![]() ![]() ![]() ![]() ![]() as a video game grows old its content and internal logic deteriorateÿ Level: 102 ![]() Posts: 2377/2803 EXP: 10922943 For next: 167024 Since: 07-04-07 Pronouns: He/Him From: MA Since last post: 120 days Last activity: 29 days |
|
|
|
Xkeeper Level: 263 ![]() Posts: 17485/25353 EXP: 297157138 For next: 1803315 Since: 07-03-07 Pronouns: they/them/???????? Since last post: 3 days Last activity: 14 hours |
| |
|
|
plushifoxed King Yoshi la chica dijo... Mood: ![]() Level: 119 ![]() Posts: 3371/3990 EXP: 18466834 For next: 462457 Since: 08-22-07 Pronouns: it/its or she/her From: kamihama city Since last post: 2 days Last activity: 1 day |
| ||
|
|||
Sukasa![]() Level: 123 Posts: 2655/4326 EXP: 20936842 For next: 294424 Since: 07-07-07 Since last post: 1.1 years Last activity: 1.1 years |
| ||||||||
|
|
Tina Beep boop Level: 79 Posts: 1451/1549 EXP: 4471849 For next: 107618 Since: 08-10-07 Since last post: 3.4 years Last activity: 3.4 years |
| |||
|
| Next newer thread | Next older thread |
| Jul - Craziness Domain - another thing |
- - ![]() |
|
Acmlmboard - commit 47be4dc [2021-08-23]
©2000-2022 Acmlm, Xkeeper, Kaito Sinclaire, et al.
|