Timeline for How can I optimize a collision engine where order is significant and collision is conditional based on object group?
Current License: CC BY-SA 3.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 26, 2013 at 13:27 | comment | added | Vittorio Romeo | let us continue this discussion in chat | |
Jun 25, 2013 at 13:35 | comment | added | Maik Semder | @Vittorio That should be the point of the question. I would completely start a new question, this one already has too much noise. Focus on how to find/filter neighboring bodies quickly without looping through all of them. | |
Jun 25, 2013 at 13:02 | comment | added | Vittorio Romeo |
@MaikSemder a body can occupy more than a single cell. Considering body A: A occupies more cells. A has to check every body in every cell it occupies. Some of these bodies can, themselves, occupy more cells (this is why A has to check for duplicates). In the end, A needs a collection of unique, nearby bodies of groups it needs to check collision against. That's why I need the getBodiesToCheck function. Hope I explained myself - let me know if something is not clear
|
|
Jun 25, 2013 at 12:57 | comment | added | Maik Semder | @Vittorio so you already have the "neighbour" information? A spatial structure is there to get this information quickly. So your grid knows all the bodies nearby already, then why adding them into arrays each frame? | |
Jun 25, 2013 at 12:50 | comment | added | Vittorio Romeo | @MaikSemder I do have a spatial structure, it's a 2D grid. In fact, the question is all about the 2D grid spatial structure. Or am I missing the point here? | |
Jun 25, 2013 at 12:48 | comment | added | Maik Semder | @Vittorio Ah, I thought that is what a group is, the collectiuon of nearby bodies. That makes the problem clearer, you will need some kind of spatial hashing like octrees, BSPs or other acceleration structures. Please make it clearer in your question that you dont have it and remove all the noise from the qustion body. You might want to check the bullet sources for inspiration. | |
Jun 25, 2013 at 12:41 | comment | added | Vittorio Romeo |
@MaikSemder: I'll update the question now. - bodiesToCheck basically is (from the point of view of a body) "the vector of nearby bodies that are part of a group I have to check collision against". So, even if I know what groups I have to check collision against, I still to know what bodies from those groups are nearby.
|
|
Jun 25, 2013 at 12:23 | comment | added | Maik Semder | @Vittorio would be nice if you put this info into the questions, thats a game-changer ;) Particularily I mean the part that getBodiesToCheck is called for all bodies, so 10000 times each frame. I wonder, you said they were in groups, so why put them into the bodiesToCheck-array, if you already have the group information. You might elaborate on that part, looks like a very good optimization candidate to me. | |
Jun 25, 2013 at 11:36 | comment | added | Vittorio Romeo |
@MaikSemder: the profiler doesn't go deeper than the function itself. The whole function is the bottleneck, because it's being called once per frame per body. 10000 bodies = 10000 getBodiesToCheck calls per frame. I suspect the constant cleaning/pushing in the vector is the bottleneck of the function itself. The contains method is also part of the slowdown, but since bodiesToCheck never has more than 8-10 bodies in it, it should be that slow
|
|
Jun 25, 2013 at 11:16 | comment | added | Maik Semder | @Vittorio, then which part of getBodiesToCheck is the bottleneck? We need information in order to help. | |
Jun 25, 2013 at 9:03 | comment | added | Vittorio Romeo |
std::map is not a bottleneck - I also remember trying dense_hash_set and not gaining any kind of performance.
|
|
Jun 25, 2013 at 9:02 | comment | added | Vittorio Romeo |
"Are you allocating these bodies with raw new calls?" I'm not explicitly calling new when pushing bodies to the getBodiesToCheck vector - do you mean it is happening internally? Is there a way to prevent that while still having a dynamic-sized collection of bodies?
|
|
Jun 25, 2013 at 6:18 | history | edited | RandyGaul | CC BY-SA 3.0 |
added 3 characters in body
|
Jun 25, 2013 at 6:11 | history | answered | RandyGaul | CC BY-SA 3.0 |