Timeline for How to optimize collision detection
Current License: CC BY-SA 3.0
20 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 16, 2020 at 10:15 | history | edited | CommunityBot |
Commonmark migration
|
|
| Jun 6, 2014 at 13:04 | answer | added | async | timeline score: 2 | |
| Jun 6, 2014 at 10:09 | comment | added | Niklas | @OriginalDaemon I do use git, but I have not committed my try. What a shame, I guess. As you can see, Marco said that QuadTree isn't really good in my case, since collision detection is linear. | |
| Jun 6, 2014 at 9:43 | comment | added | OriginalDaemon | @Niklas - you mention destroying the QuadTree implementation which I take it means you can't get it back. If you haven't done already you might want to check out version control software like; git, subversion, mercurial and many more. | |
| Jun 6, 2014 at 9:15 | history | edited | Niklas | CC BY-SA 3.0 |
edited body
|
| Jun 6, 2014 at 9:14 | vote | accept | Niklas | ||
| Jun 6, 2014 at 0:08 | answer | added | badweasel | timeline score: 5 | |
| Jun 5, 2014 at 23:01 | answer | added | Andon M. Coleman | timeline score: 5 | |
| Jun 5, 2014 at 20:06 | comment | added | bummzack | @Niklas Yes, exactly. There should be an implementation for this in libgdx called "Pool". | |
| Jun 5, 2014 at 19:52 | comment | added | Niklas | @bummzack Do you mean the Object Pool Pattern? | |
| Jun 5, 2014 at 18:59 | comment | added | bummzack | Don't use Box2d for simple rectangle or circle checks.. you don't need a physics engine for that and the code you posted is fine. I guess your problem is allocating memory for new enemies (and garbage-collection of unused enemies). Look into object pools and re-use your expired entities instead of allocating new objects. | |
| Jun 5, 2014 at 18:15 | comment | added | Niklas | Is it possible to dynamically create the enemies, more specifically the x and y coordinate? I have never done anything with box2d. | |
| Jun 5, 2014 at 18:08 | comment | added | Gustavo Maciel | If you're not too much into implementing a collision system, add box2d to your project, make everything kinematic or static, keep your old code. Then you'll only have to listen to the callbacks. | |
| Jun 5, 2014 at 18:04 | comment | added | Niklas | I am using the normal API for that. This one for rectangles and this one for circles. Memory Allocation could be problem, I've got an object for every Enemy. (Coordinates, color and stuff like that is in it). Once I am done with an enemy (it's out of the gamefield) I set the object to null. So that should help, I guess. Also I render only enemies, which are in the gamefield and not outside of the bounds. | |
| Jun 5, 2014 at 18:00 | comment | added | bummzack | If your game lags with 200 enemies, then your collision check is probably inefficient? Are you performing a quick broad-phase (eg. circle vs. circle test)? I think you should profile your application to figure out what portion of your code creates the lag (could be something entirely different than collision detection, like memory-allocation). | |
| Jun 5, 2014 at 16:23 | comment | added | Niklas | @GustavoMaciel well since there can be up to 200-300 enemies, it sometimes lags. | |
| Jun 5, 2014 at 16:19 | review | First posts | |||
| Jun 5, 2014 at 18:22 | |||||
| Jun 5, 2014 at 16:16 | comment | added | Marco13 | When you only have to check the player against all enemies, this should not be sooo much of a problem (assuming that the number of enemies is in the order of that displayed in the image). It's a simple linear search. (The situation would be different if you also wanted to detect collisions among enemies - this would be quadratic, and could become an issue). That said, considering the effort for updating data structures like quadtrees, I assume that using these will make the check slower than the simple linear search. | |
| Jun 5, 2014 at 16:14 | comment | added | Gustavo Maciel |
There's no other way AFAIK. Or you have a tree and check only enemies that the tree specify as near enemies, or you check for every entity. By any means, it doesn't seem like your app will suffer for performance. Bother with this only if extremely necessary.
|
|
| Jun 5, 2014 at 16:02 | history | asked | Niklas | CC BY-SA 3.0 |